Skip to content

feat: capture opt-in instruction context#326

Closed
caioribeiroclw-pixel wants to merge 1 commit into
0xroylee:mainfrom
caioribeiroclw-pixel:caio/instruction-context-snapshot
Closed

feat: capture opt-in instruction context#326
caioribeiroclw-pixel wants to merge 1 commit into
0xroylee:mainfrom
caioribeiroclw-pixel:caio/instruction-context-snapshot

Conversation

@caioribeiroclw-pixel

Copy link
Copy Markdown

Summary

  • add an opt-in --instruction-context snapshot flag that hashes known local instruction files without recording raw prompt/transcript/instruction text
  • parse and expose instruction_context in snapshot history/details JSON
  • cover the shell helper behavior with a regression test

Why

This is the small v1 shape discussed in #323: snapshot-local causality metadata so a later audit can tell whether a bad edit likely came from a changed instruction/rule surface rather than only the target file diff.

Validation

  • git diff --check
  • npx tsc --noEmit
  • npx biome check bundled-skills/pony-trail/scripts/snapshot_change.sh src/runtimes/ponytrail/snapshots.ts src/cli.ts tests/pony-trail-script.test.ts
  • sh -n bundled-skills/pony-trail/scripts/snapshot_change.sh
  • manual shell smoke for --instruction-context verifying AGENTS.md is hashed, CLAUDE.md is marked missing, and raw instruction text is not present in instruction_context

Note: I could not run bun test locally because this container does not have bun installed; the Husky pre-commit hook failed for the same reason, so the commit was made after the checks above.

@0xroylee 0xroylee left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the PR. CI is green now, and the feature direction is useful. I think there are still two issues worth fixing before merge: one safety boundary around symlinked instruction files, and one usability gap in the human history --details output.


instruction_context_file_json() {
rel_path=$1
path=$root/$rel_path

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

[blocking] This hashes $root/$rel_path without resolving the target and checking that it still lives inside $root. Because .cursor/rules/* can include symlinks, --instruction-context can hash a file outside the workspace while reporting only the workspace-relative symlink path. I reproduced this with .cursor/rules/external.mdc -> /private/tmp/...; the snapshot marked it captured and logged the external target hash. Please skip symlinks/out-of-root resolved paths, or mark them with a non-captured warning status.

Comment thread src/cli.ts
}
if (commit.instructionContext) {
console.log(
` instruction_context: ${commit.instructionContext.files.length} files, raw_text=false`,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This makes the details view less useful than the issue asks for. history --json includes the file paths and hashes, but history --details only prints a count and raw_text=false, so a human cannot compare which instruction file changed between snapshots. Please render at least path, status, bytes, and hash prefix/full hash in details mode while keeping the default compact view small.

@0xroylee 0xroylee linked an issue Jun 23, 2026 that may be closed by this pull request
@caioribeiroclw-pixel

Copy link
Copy Markdown
Author

Thanks for the detailed review. I saw #325 landed the project-owned implementation path, including the instruction-context CI fix, so I’m going to close this PR rather than keep a conflicting fork branch alive.

The two review points still look important for the merged implementation too:

  • symlinked instruction files should probably be marked as skipped_symlink / outside_workspace rather than followed silently
  • history --details should expose the compact instruction-context summary so users don’t need to inspect JSON to notice changed instruction hashes

Happy to test or review a follow-up if useful.

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.

Capture the active instruction surface for each snapshot

2 participants