fix: change ResourceFile.Content from string to []byte#117
Merged
richardpark-msft merged 5 commits intoMar 12, 2026
Conversation
…ary content Co-authored-by: richardpark-msft <51494936+richardpark-msft@users.noreply.github.com>
Co-authored-by: richardpark-msft <51494936+richardpark-msft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix copilot engine's resource files string requirement
fix: change ResourceFile.Content from string to []byte
Mar 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates how file resources are represented and written to disk during test/execution workflows by changing execution.ResourceFile.Content from string to raw []byte, avoiding repeated string/byte conversions and enabling non-text resources.
Changes:
- Change
internal/execution.ResourceFile.Contenttype fromstringto[]byte. - Update resource loading/writing code paths to pass bytes through without converting to/from string.
- Update affected tests to assert on
[]bytecontent (or convert tostringwhere needed for comparisons).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/orchestration/runner.go | Emits ResourceFile content as bytes for both inline and file-backed resources. |
| internal/orchestration/runner_orchestration_test.go | Updates assertions to match byte content for loaded resources. |
| internal/execution/engine.go | Changes ResourceFile.Content type to []byte. |
| internal/execution/workspace.go | Writes resource bytes directly via os.WriteFile (no conversion). |
| internal/execution/workspace_test.go | Updates test fixtures to use []byte content. |
| internal/execution/mock_engine_test.go | Updates mock execution tests to use byte resource content. |
| internal/execution/copilot_engine_test.go | Updates workspace resource setup test to use byte content. |
| cmd/waza/cmd_run_suggest.go | Loads skill resources as bytes without string conversion. |
| cmd/waza/cmd_run_suggest_test.go | Converts resource bytes to string for content comparisons; updates byte assertions. |
You can also share your feedback on Copilot code review. Take the survey.
chlowell
approved these changes
Mar 12, 2026
richardpark-msft
pushed a commit
to richardpark-msft/waza
that referenced
this pull request
Mar 13, 2026
… heuristic rules
richardpark-msft
pushed a commit
to richardpark-msft/waza
that referenced
this pull request
Mar 13, 2026
`waza dev` scores a SKILL.md file's frontmatter against heuristics and suggests improvements. It's basically equivalent to the `sensei` CLI. Closes microsoft#32, closes microsoft#33, closes microsoft#35 ### What it does `waza dev [skill-path]` reads a SKILL.md, scores its frontmatter for compliance (trigger phrases, anti-triggers, routing clarity, description length, token budget), and walks the user through improvements one at a time. In `--auto` mode it applies all suggestions without prompting. **Scoring levels** (Low → Medium → Medium-High → High) are determined by the presence of: - Trigger phrases (`USE FOR:`) - Anti-trigger phrases (`DO NOT USE FOR:`) - Routing clarity markers (`INVOKES:`, `**WORKFLOW SKILL**`, etc.) ### Example output ``` ── Iteration 1/5 ────────────────────────────────────────── Skill: skill-creator Score: Low Tokens: 4522 Description: 226 chars Triggers: 0 Anti-triggers: 0 Issues:⚠️ SKILL.md is 4522 tokens (soft limit 500) 📝 Suggested improvement (triggers): ──────────────────────────────────────── USE FOR: skill-creator, about skills, core principles, quick start, advanced features. ──────────────────────────────────────── Apply this improvement? [y/N]y Verified: score is now Medium ── Iteration 2/5 ────────────────────────────────────────── Skill: skill-creator Score: Medium Tokens: 4546 Description: 313 chars Triggers: 5 Anti-triggers: 0 Issues:⚠️ SKILL.md is 4546 tokens (soft limit 500) 📝 Suggested improvement (anti-triggers): ──────────────────────────────────────── DO NOT USE FOR: general coding questions unrelated to skill-creator, creating new projects from scratch. ──────────────────────────────────────── Apply this improvement? [y/N]y Verified: score is now Medium-High ✅ Target adherence level Medium-High reached! ╔══════════════════════════════════════════════════════════════════╗ ║ SENSEI SUMMARY: skill-creator ║ ╠══════════════════════════════════════════════════════════════════╣ ║ BEFORE AFTER ║ ║ ────── ───── ║ ║ Score: Low Score: Medium-High ║ ║ Tokens: 4522 Tokens: 4574 ║ ║ Triggers: 0 Triggers: 5 ║ ║ Anti-triggers: 0 Anti-triggers: 2 ║ ║ ║ ║ TOKEN STATUS:⚠️ Over soft limit (4574 > 500) ║ ╚══════════════════════════════════════════════════════════════════╝ ``` ### Flags | Flag | Default | Description | |------|---------|-------------| | `--target` | `medium-high` | Target adherence level | | `--max-iterations` | `5` | Max improvement iterations | | `--auto` | `false` | Apply improvements without prompting | ### Implementation New package `cmd/waza/dev/` with the following files: - **score.go** — `HeuristicScorer` implementing a `Scorer` interface. Pattern-matching heuristics for triggers, anti-triggers, and routing clarity. Validation for name format, description length, and token budget. - **loop.go** — The core `runDevLoop` function. Steps through description expansion, trigger addition, anti-trigger addition, and routing clarity. Declining a suggestion skips to the next applicable step rather than ending the loop. - **display.go** — Terminal output formatting. - **prompt.go** — User prompts for confirm (y/N). Uses a shared `bufio.Scanner` to avoid consuming stdin across multiple reads. - **root.go** — Cobra command registration. New package `waza/internal/skill` adds `Skill` and `Frontmatter` types and related un/marshaling functions. ### Preparatory refactor `internal/tokens` was extracted from `cmd/waza/tokens/internal/tokens` so the token estimation logic can be shared between the `tokens` subcommand and the new `dev` package. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ResourceFile.Content was a string before, which meant you couldn't safely add in binary content (for instance, an exe). There's no reason for it to be a string, and in Go, it's super easy to convert from []byte to string without loss, unlike the reverse.