Skip to content

fix: change ResourceFile.Content from string to []byte#117

Merged
richardpark-msft merged 5 commits into
mainfrom
copilot/fix-resource-files-string-requirement
Mar 12, 2026
Merged

fix: change ResourceFile.Content from string to []byte#117
richardpark-msft merged 5 commits into
mainfrom
copilot/fix-resource-files-string-requirement

Conversation

Copilot AI commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI and others added 2 commits March 12, 2026 02:31
…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
@richardpark-msft richardpark-msft marked this pull request as ready for review March 12, 2026 18:38
Copilot AI review requested due to automatic review settings March 12, 2026 18:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Content type from string to []byte.
  • Update resource loading/writing code paths to pass bytes through without converting to/from string.
  • Update affected tests to assert on []byte content (or convert to string where 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.

@richardpark-msft richardpark-msft merged commit a4a5387 into main Mar 12, 2026
10 checks passed
@richardpark-msft richardpark-msft deleted the copilot/fix-resource-files-string-requirement branch March 12, 2026 20:31
@spboyer spboyer mentioned this pull request Mar 12, 2026
4 tasks
richardpark-msft pushed a commit to richardpark-msft/waza that referenced this pull request Mar 13, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

copilot engine's resource files require content to be a string, but should allow []bytes

4 participants