Skip to content

feat: render prompts with a skill filter and expose skill plugin and source - #224

Merged
swedishborgie merged 2 commits into
kitproj:mainfrom
BrianKWork:render-prompt-skill-filter
Oct 22, 2026
Merged

swedishborgie merged 2 commits into
kitproj:mainfrom
BrianKWork:render-prompt-skill-filter

Conversation

@BrianKWork

@BrianKWork BrianKWork commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Why

Agents sometimes refuse the task when the prompt lists skills. In about 15% of runs, Cursor treated the # Skills list (skill names, descriptions and SKILL.md paths in the user turn) as a prompt injection and declined to continue. Agents trust skills that arrive through their own skill support, such as a plugin, so codegen-runner wants to deliver skills that way and leave them out of the prompt's # Skills list.

Today the only way to leave them out is to rebuild this library's Skills section text and cut it out of Result.Prompt. That breaks silently whenever the prompt format changes. This PR lets the library do the rendering instead.

What changed

  • RenderPrompt(r *Result, opts ...RenderOption) (string, error) re-renders a prompt from an existing Result without running discovery again.
    • WithSkillFilter(keep func(skills.Skill) bool) leaves filtered skills out of the prompt. Result.Skills keeps the full list.
    • With no options, the output equals Result.Prompt.
    • It reuses the existing rules: no rules and no kept skills gives task-only output, and # Skills is dropped when no skills remain.
    • It returns ErrRuleSourcesMismatch when RuleSources and Rules don't line up.
  • Result.RuleSources carries the rule source paths the renderer needs.
  • skills.Skill gains two fields, both tagged xml:"-" so the prompt XML is unchanged:
    • Plugin: the skill's plugin frontmatter value.
    • SearchPath: the local search path the skill was found under.
  • WithSkillDiscovery(bool) discovers skills even when bootstrap is off. Rules and bootstrap scripts stay off, so a caller can recompute skills on every run.
  • buildPrompt now calls a pure renderPrompt, so Run's output is byte-for-byte unchanged.
  • The README API reference is updated.

Tests

  • TestRenderPrompt_NoOptionsMatchesRun
  • TestRenderPrompt_SkillFilter: keep some; keep none with rules (matches the no-skills render byte for byte); keep none without rules (task-only output)
  • TestRenderPrompt_RuleSourcesMismatch
  • TestSkillDiscovery_PluginAndSearchPath
  • TestWithSkillDiscovery

Checks run locally:

  • go test ./... passes.
    • The root package test reads ~/.agents/skills. It fails on a machine whose home folder has a skill with list-valued metadata, and passes with a clean HOME.
  • go vet and deadcode -test are clean.
  • golangci-lint run --new-from-rev=main reports 0 issues.
  • Existing findings in files this PR doesn't touch:
    • goimports wants to reformat enumerate_test.go.
    • unparam flags taskparser/markdownparser.go:157.

🤖 Generated with Claude Code

BrianKWork and others added 2 commits October 22, 2026 11:16
…source - (ACAP-4332)

Callers that deliver skills through an agent's native skill support had to
cut the Skills section out of Result.Prompt by re-creating its text, which
breaks whenever the prompt format changes.

- RenderPrompt re-renders a prompt from an existing Result without running
  discovery again. WithSkillFilter leaves filtered skills out of the prompt
  while Result.Skills keeps the full list. With no options the output equals
  Result.Prompt.
- Result.RuleSources carries the rule source paths the renderer needs.
- skills.Skill gains Plugin (from the "plugin" frontmatter key) and
  SearchPath. Neither appears in the prompt XML.
- WithSkillDiscovery discovers skills when bootstrap is off, so a caller can
  recompute skills per run without re-running rules or bootstrap scripts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds tests for namespace skills, lenient name inference, lint mode and the
skill cache keeping Plugin and SearchPath; for re-rendering a resume prompt
discovered with WithSkillDiscovery back to task only; and for fenced rule
content surviving RenderPrompt unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@swedishborgie
swedishborgie merged commit cbd4c21 into kitproj:main Oct 22, 2026
1 check passed
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.

2 participants