feat: capture opt-in instruction context#326
Conversation
0xroylee
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
[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.
| } | ||
| if (commit.instructionContext) { | ||
| console.log( | ||
| ` instruction_context: ${commit.instructionContext.files.length} files, raw_text=false`, |
There was a problem hiding this comment.
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.
|
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:
Happy to test or review a follow-up if useful. |
Summary
--instruction-contextsnapshot flag that hashes known local instruction files without recording raw prompt/transcript/instruction textinstruction_contextin snapshot history/details JSONWhy
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 --checknpx tsc --noEmitnpx biome check bundled-skills/pony-trail/scripts/snapshot_change.sh src/runtimes/ponytrail/snapshots.ts src/cli.ts tests/pony-trail-script.test.tssh -n bundled-skills/pony-trail/scripts/snapshot_change.sh--instruction-contextverifying AGENTS.md is hashed, CLAUDE.md is marked missing, and raw instruction text is not present ininstruction_contextNote: I could not run
bun testlocally because this container does not havebuninstalled; the Husky pre-commit hook failed for the same reason, so the commit was made after the checks above.