Skip to content

FE-881: Cook agent loads the target repo's sandbox-scoped skills#227

Closed
kostandinang wants to merge 4 commits into
ka/fe-864-pi-timeout-600sfrom
ka/fe-881-cook-agent-skills
Closed

FE-881: Cook agent loads the target repo's sandbox-scoped skills#227
kostandinang wants to merge 4 commits into
ka/fe-864-pi-timeout-600sfrom
ka/fe-881-cook-agent-skills

Conversation

@kostandinang

@kostandinang kostandinang commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Stack Context

Stacks on FE-864 (#224). A refinement of cook-codebase-mode + the cook-time grounding direction (D160-K intact -- this is run-time, not the emitter). FE-881.

What?

  • cookResourceLoader(sandboxDir, agentDir, systemPrompt) -- points pi's discovery at the repo's .agents/skills / .claude/skills (deduped by realpath, since brunch-style repos symlink the two), then filters the result to paths under the sandbox via sandboxScopedSkills. pi's default discovery scans <cwd>/<config>/skills + <agentDir>/skills, not the Agent-Skills dirs, so the explicit additionalSkillPaths are required.
  • sandboxScopedSkills(skills, sandboxDir) -- pure filter: keeps only skills whose path resolves under the sandbox; drops global, sibling-slice, and prefix-lookalike paths.
  • The catalog reaches the model through pi's custom-prompt path (formatSkillsForPrompt, gated on the read tool -- every cook action has it), so the task-prompt override does not suppress it.

Why?

Brownfield cook builds on the user's repo, so the agent should see that repo's own skills and conventions. buildSessionOptions previously stripped all skills for hermeticity. This narrows the guarantee from "no skills" to "no skills from outside the repo" -- the cook agent gains the target codebase's configured skills while the developer's machine-global pi config still never leaks in.

Behavior / scope

  • Greenfield worktrees have no .agents/skills, so skills resolve empty and greenfield behavior is unchanged (protecting invariant).
  • Deferred follow-ons (separate slices): loading the repo's AGENTS.md/CLAUDE.md conventions; a project-trust gate for repo-authored skills.

Tests

npm run verify green (2060 passed, 2 skipped, build OK). New unit test pins sandboxScopedSkills (under / sibling / prefix-lookalike / global); new fs-integration test pins cookResourceLoader discovering the repo's .agents/skills and excluding an agentDir (global) skill.

kostandinang commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@kostandinang kostandinang changed the title FE-881: cook agent loads the target repo's sandbox-scoped skills FE-881: Cook agent loads the target repo's sandbox-scoped skills Jun 17, 2026
@kostandinang kostandinang marked this pull request as ready for review June 17, 2026 12:40
@cursor

cursor Bot commented Jun 17, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Loading repo-authored skills increases what the agent executes during brownfield cooks (trust boundary), though global skills remain excluded; remaining changes are UI/CLI and filesystem edge cases.

Overview
Brownfield cook agents now see skills from the target repo’s .agents/skills / .claude/skills (deduped by realpath), filtered by sandboxScopedSkills so machine-global, sibling-slice, and prefix-lookalike paths never load. Session setup uses cookResourceLoader instead of stripping all skills; greenfield worktrees without those dirs stay unchanged.

Presenter / CLI: plate advances only on lines matching ✓ promoted, not incidental “promoted” text (e.g. “nothing promoted”). Promotion failures emit cook-done with ok: false and a reason before exit.

Other: Activity heartbeat tail truncation counts the ellipsis in the 56-char cap; runPi defers creating the isolated agent dir until after timeout setup; Windows directory symlinks in copyMissingTopLevelEntries use junctions when needed.

Reviewed by Cursor Bugbot for commit a29e185. Bugbot is set up for automated code reviews on this repo. Configure here.

@kostandinang kostandinang force-pushed the ka/fe-881-cook-agent-skills branch from 433f0e2 to c7ba5fd Compare June 17, 2026 12:51
@kostandinang kostandinang changed the base branch from ka/fe-864-pi-timeout-600s to graphite-base/227 June 17, 2026 13:12
@kostandinang kostandinang changed the base branch from graphite-base/227 to ka/fe-864-pi-timeout-600s June 17, 2026 18:02
@kostandinang kostandinang self-assigned this Jun 18, 2026
@kostandinang kostandinang force-pushed the ka/fe-881-cook-agent-skills branch from d598bb0 to b8a554a Compare June 18, 2026 09:02

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b8a554a. Configure here.

Comment thread src/orchestrator/src/pi-actions.ts
@kostandinang kostandinang force-pushed the ka/fe-864-pi-timeout-600s branch from 7a7e1e5 to b48901c Compare June 18, 2026 09:06
@kostandinang kostandinang force-pushed the ka/fe-881-cook-agent-skills branch 2 times, most recently from e8c3f2d to fbd12b2 Compare June 18, 2026 09:19
@kostandinang kostandinang changed the base branch from ka/fe-864-pi-timeout-600s to graphite-base/227 June 18, 2026 09:44
@kostandinang kostandinang force-pushed the ka/fe-881-cook-agent-skills branch from fbd12b2 to c830824 Compare June 18, 2026 11:43
@kostandinang kostandinang changed the base branch from graphite-base/227 to ka/fe-864-pi-timeout-600s June 18, 2026 11:44
@kostandinang kostandinang force-pushed the ka/fe-881-cook-agent-skills branch from c830824 to a811396 Compare June 18, 2026 11:46
@kostandinang kostandinang requested a review from lunelson June 18, 2026 12:59
kostandinang and others added 3 commits June 18, 2026 14:15
Brownfield cook builds on the user's repo, so the agent should see that repo's
own skills. buildSessionOptions previously stripped all skills for hermeticity;
narrow that from "no skills" to "no skills from outside the repo":

- cookResourceLoader points pi's discovery at the repo's .agents/skills /
  .claude/skills (deduped by realpath; pi's defaults scan <cwd>/<config>/skills
  + <agentDir>/skills, not the Agent-Skills dirs) and filters the result to paths
  under the sandbox via sandboxScopedSkills.
- The skill catalog reaches the model through pi's custom-prompt path
  (formatSkillsForPrompt, gated on the read tool — every cook action has it).
- Greenfield worktrees have no such dir, so skills resolve empty and behavior is
  unchanged (protecting invariant).

Deferred follow-ons: AGENTS.md/conventions loading, a project-trust gate.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Keep retryable slice work non-terminal in the UI, emit completion on promotion failures, and clean up misleading verification/test signals reported by the stack review bots.

Co-authored-by: Cursor <cursoragent@cursor.com>
Include the leading ellipsis in the heartbeat truncation budget so progress details respect the configured maximum length.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pass a directory link type when sharing node_modules on Windows so lazy slice seeding can link folder targets reliably.

Co-authored-by: Cursor <cursoragent@cursor.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.

1 participant