@haystackeditor/cli 0.15.26 → 0.15.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +52 -23
  2. package/dist/assets/hooks/agent-context/detect.ts +7 -7
  3. package/dist/assets/hooks/agent-context/parsers/claude.ts +1 -1
  4. package/dist/assets/hooks/package-lock.json +598 -0
  5. package/dist/assets/hooks/scripts/commit-msg.sh +1 -3
  6. package/dist/assets/hooks/scripts/post-commit.sh +1 -3
  7. package/dist/assets/hooks/scripts/pre-push.sh +1 -4
  8. package/dist/assets/hooks/scripts/prepare-commit-msg.sh +1 -2
  9. package/dist/assets/skills/map-cloud-verifier-universe/SKILL.md +2051 -0
  10. package/dist/assets/skills/map-cloud-verifier-universe/agents/openai.yaml +4 -0
  11. package/dist/assets/skills/map-cloud-verifier-universe/references/output-contract.md +3411 -0
  12. package/dist/assets/telemetry/browser-runtime.js +1469 -0
  13. package/dist/assets/telemetry/runtime.cjs +1503 -0
  14. package/dist/commands/cloud-verifier-behaviors.d.ts +27 -0
  15. package/dist/commands/cloud-verifier-behaviors.js +218 -0
  16. package/dist/commands/cloud-verifier-data-store-census.d.ts +47 -0
  17. package/dist/commands/cloud-verifier-data-store-census.js +539 -0
  18. package/dist/commands/cloud-verifier-data-store-drift.d.ts +42 -0
  19. package/dist/commands/cloud-verifier-data-store-drift.js +158 -0
  20. package/dist/commands/cloud-verifier-identity-census.d.ts +88 -0
  21. package/dist/commands/cloud-verifier-identity-census.js +4057 -0
  22. package/dist/commands/cloud-verifier-materialization.d.ts +16 -0
  23. package/dist/commands/cloud-verifier-materialization.js +704 -0
  24. package/dist/commands/cloud-verifier-pascal-selector-census.d.ts +29 -0
  25. package/dist/commands/cloud-verifier-pascal-selector-census.js +1382 -0
  26. package/dist/commands/cloud-verifier-python-manifest-selector-census.d.ts +27 -0
  27. package/dist/commands/cloud-verifier-python-manifest-selector-census.js +2015 -0
  28. package/dist/commands/cloud-verifier-specialized-operational-census.d.ts +51 -0
  29. package/dist/commands/cloud-verifier-specialized-operational-census.js +11432 -0
  30. package/dist/commands/cloud-verifier-universe.d.ts +31 -0
  31. package/dist/commands/cloud-verifier-universe.js +10178 -0
  32. package/dist/commands/design-verify.d.ts +31 -0
  33. package/dist/commands/design-verify.js +285 -0
  34. package/dist/commands/hooks.d.ts +1 -5
  35. package/dist/commands/hooks.js +12 -114
  36. package/dist/commands/install-session-hooks.d.ts +2 -2
  37. package/dist/commands/install-session-hooks.js +71 -21
  38. package/dist/commands/mcp.js +1 -34
  39. package/dist/commands/pr.js +2 -7
  40. package/dist/commands/prepare-universe-review.d.ts +115 -0
  41. package/dist/commands/prepare-universe-review.js +1092 -0
  42. package/dist/commands/production-source-deny-policy.d.ts +15 -0
  43. package/dist/commands/production-source-deny-policy.js +100 -0
  44. package/dist/commands/scaffold-provisional-universe.d.ts +468 -0
  45. package/dist/commands/scaffold-provisional-universe.js +808 -0
  46. package/dist/commands/schema-cmd.js +32 -0
  47. package/dist/commands/setup.d.ts +1 -2
  48. package/dist/commands/setup.js +18 -272
  49. package/dist/commands/skills.d.ts +2 -2
  50. package/dist/commands/skills.js +415 -47
  51. package/dist/commands/submit.js +1 -2
  52. package/dist/commands/telemetry.d.ts +53 -0
  53. package/dist/commands/telemetry.js +832 -0
  54. package/dist/commands/verify-hosted.d.ts +13 -0
  55. package/dist/commands/verify-hosted.js +49 -1
  56. package/dist/commands/verify-precompute.d.ts +19 -0
  57. package/dist/commands/verify-precompute.js +328 -0
  58. package/dist/index.js +168 -47
  59. package/dist/schema.d.ts +1 -2
  60. package/dist/schema.js +1 -2
  61. package/dist/triage/prompts.d.ts +0 -7
  62. package/dist/triage/prompts.js +0 -145
  63. package/dist/triage/runner.js +10 -28
  64. package/dist/triage/types.d.ts +1 -8
  65. package/dist/types.d.ts +8 -8
  66. package/dist/types.js +1 -1
  67. package/dist/utils/design-verifier-api.d.ts +200 -0
  68. package/dist/utils/design-verifier-api.js +271 -0
  69. package/dist/utils/design-verifier-result.d.ts +57 -0
  70. package/dist/utils/design-verifier-result.js +345 -0
  71. package/dist/utils/git.d.ts +5 -1
  72. package/dist/utils/git.js +19 -9
  73. package/dist/utils/github-api.js +11 -14
  74. package/dist/utils/haystack-api.d.ts +2 -0
  75. package/dist/utils/haystack-api.js +10 -3
  76. package/dist/utils/hooks.d.ts +1 -15
  77. package/dist/utils/hooks.js +3 -128
  78. package/dist/utils/telemetry.d.ts +2 -0
  79. package/dist/utils/telemetry.js +81 -8
  80. package/package.json +8 -2
  81. package/schemas/cloud-verifier.v1.json +69 -3
  82. package/schemas/{pr.v2.json → pr.v3.json} +3 -12
  83. package/dist/commands/traces.d.ts +0 -48
  84. package/dist/commands/traces.js +0 -92
  85. package/dist/triage/traces.d.ts +0 -20
  86. package/dist/triage/traces.js +0 -311
  87. package/schemas/traces.v1.json +0 -53
package/dist/index.js CHANGED
@@ -30,11 +30,18 @@ import { initCommand } from './commands/init.js';
30
30
  import { authListCommand, authUseCommand, loginCommand, logoutCommand, whoamiCommand, } from './commands/login.js';
31
31
  import { handleAgenticTool, handleAutoMerge, handleAutoFix, handleWaitForReviewers, isAutoMergeEnabled, isAutoFixEnabled } from './commands/config.js';
32
32
  import { installSkills, listSkills } from './commands/skills.js';
33
- import { hooksInstall, hooksStatus, hooksUpdate } from './commands/hooks.js';
33
+ import { cloudVerifierUniverseValidateCommand } from './commands/cloud-verifier-universe.js';
34
+ import { cloudVerifierIdentityCensusCommand } from './commands/cloud-verifier-identity-census.js';
35
+ import { cloudVerifierDataStoreDriftCommand } from './commands/cloud-verifier-data-store-drift.js';
36
+ import { cloudVerifierBehaviorsValidateCommand } from './commands/cloud-verifier-behaviors.js';
37
+ import { prepareUniverseReviewCommand } from './commands/prepare-universe-review.js';
38
+ import { scaffoldProvisionalUniverseCommand } from './commands/scaffold-provisional-universe.js';
39
+ import { hooksInstall, hooksStatus } from './commands/hooks.js';
34
40
  import { submitCommand } from './commands/submit.js';
35
41
  import { installSessionHooks, sessionHooksStatus } from './commands/install-session-hooks.js';
36
42
  import { listPolicies, addPolicy, removePolicy, initPolicies, addInstruction } from './commands/policy.js';
37
43
  import { triageCommand } from './commands/triage.js';
44
+ import { designVerifyCommand } from './commands/design-verify.js';
38
45
  import { dismissCommand, markReviewedCommand, undismissCommand } from './commands/dismiss.js';
39
46
  import { requestReviewCommand } from './commands/request-review.js';
40
47
  import { reviewCommand } from './commands/review.js';
@@ -42,7 +49,7 @@ import { prStatusCommand } from './commands/pr-status.js';
42
49
  import { prReadCommand } from './commands/pr.js';
43
50
  import { inboxListCommand } from './commands/inbox.js';
44
51
  import { askHaystackCommand } from './commands/ask.js';
45
- import { tracesGetCommand, tracesListCommand } from './commands/traces.js';
52
+ import { telemetryInstrumentCommand } from './commands/telemetry.js';
46
53
  import { setupCommand } from './commands/setup.js';
47
54
  import { schemaCommand, listSchemas } from './commands/schema-cmd.js';
48
55
  import { registerWebhook, listWebhooks, rotateWebhookSecret, setWebhookEnabled, listDeliveries, replayDelivery, } from './commands/webhooks.js';
@@ -126,7 +133,6 @@ program
126
133
  // Defining --no-auto-merge also accepts --auto-merge; default is "ask" unless
127
134
  // one is explicitly passed (detected via getOptionValueSource below).
128
135
  .option('--no-auto-merge', 'Set auto-merge in the written config (--auto-merge / --no-auto-merge; omit to be asked)')
129
- .option('--skip-entire', 'Skip the Entire CLI / git-hooks (session tracking) step')
130
136
  .option('--answers <file>', 'JSON file of {questionId: value} pre-supplied answers')
131
137
  .addHelpText('after', `
132
138
  Steps: verify GitHub App → select repos → scan (rules/policies/instructions) →
@@ -135,7 +141,7 @@ review → write .haystack/pr-rules.yml + review-policy.md + .haystack.json.
135
141
  Three ways to run:
136
142
  • Interactive (default): prompts in your terminal.
137
143
  • Autonomous/CI: supply every decision via flags, e.g.
138
- haystack setup --repo owner/name --yes --no-auto-merge --skip-entire
144
+ haystack setup --repo owner/name --yes --no-auto-merge
139
145
  • Coding agent: --json speaks NDJSON on stdout and reads answers on stdin, so an
140
146
  agent can auto-answer or relay questions to the user. Pre-supplied answers
141
147
  (flags / --answers) skip the matching question.
@@ -157,7 +163,6 @@ Examples:
157
163
  repos: options.repo,
158
164
  yes: options.yes,
159
165
  autoMerge: autoMergeExplicit ? options.autoMerge : undefined,
160
- skipEntire: options.skipEntire,
161
166
  answersFile: options.answers,
162
167
  });
163
168
  });
@@ -205,6 +210,18 @@ Examples:
205
210
  `)
206
211
  .action((specimen, options) => runPublicCommand(() => verifyCommand(specimen, options), options.json));
207
212
  const verifyRunArg = 'Run id, chapter id (newest run of that chapter), or "latest" (default)';
213
+ verify
214
+ .command('precompute')
215
+ .description('Precompute reusable verification inputs for the current working tree')
216
+ .option('--hook', 'Run silently as a best-effort repository hook')
217
+ .action(async (options) => {
218
+ await runPublicCommand(async () => {
219
+ const { verifyPrecomputeCommand } = await import('./commands/verify-precompute.js');
220
+ await verifyPrecomputeCommand(options);
221
+ });
222
+ if (options.hook)
223
+ process.exitCode = 0;
224
+ });
208
225
  const hostedVerify = verify
209
226
  .command('hosted')
210
227
  .description('Run the production Cloud Verifier against exact GitHub commits');
@@ -647,7 +664,7 @@ program
647
664
  .addHelpText('after', `
648
665
  This command is designed for AI coding agents to submit PRs.
649
666
 
650
- 1. Runs pre-PR triage (code review, rules, instruction drift) via sub-agents
667
+ 1. Runs pre-PR triage (code review and rules) via sub-agents
651
668
  2. Pushes the current branch to origin
652
669
  3. Creates a pull request on GitHub
653
670
  4. Waits for Haystack analysis results (triggered via GitHub App webhook)
@@ -656,15 +673,14 @@ Pre-PR Triage:
656
673
  Before creating the PR, haystack spawns parallel sub-agents to check for:
657
674
  • Code review bugs (logic errors, null crashes, security issues)
658
675
  • Rule violations (from .haystack/pr-rules.yml)
659
- • Instruction drift (AI agent deviations from user instructions)
660
676
 
661
677
  Use --force to skip triage entirely.
662
678
  Use --no-wait to skip waiting for analysis results.
663
679
 
664
680
  Triage budgets:
665
681
  • --max-turns <n> Raise/lower the per-checker tool-use turn cap.
666
- Defaults: code-review 8, rules-validator 10,
667
- intent-drift 10. Applies the same N to all three.
682
+ Defaults: code-review 8, rules-validator 10.
683
+ Applies the same N to both.
668
684
  • --triage-timeout <sec> Raise/lower the per-checker wall-clock timeout
669
685
  (default: 180s).
670
686
 
@@ -782,7 +798,7 @@ inbox
782
798
  const prProgram = program.command('pr').description('Inspect one pull request');
783
799
  prProgram
784
800
  .command('get <ref>')
785
- .description('Get triage, merge blockers, and trace availability')
801
+ .description('Get triage and merge blockers')
786
802
  .option('--json', 'Output as JSON')
787
803
  .action((ref, options) => runPublicCommand(() => prReadCommand(ref, options), options.json));
788
804
  program
@@ -791,19 +807,32 @@ program
791
807
  .option('--json', 'Output the answer and every consulted customer-facing source as JSON')
792
808
  .option('--session <id>', 'Continue a previous Ask Haystack session')
793
809
  .action((ref, question, options) => runPublicCommand(() => askHaystackCommand(ref, question, options), options.json));
794
- const traces = program.command('traces').description('Inspect customer-owned Entire traces');
795
- traces
796
- .command('list <ref>')
797
- .description('List retained checkpoints for a pull request')
798
- .option('--json', 'Output as JSON')
799
- .action((ref, options) => runPublicCommand(() => tracesListCommand(ref, options), options.json));
800
- traces
801
- .command('get <ref> <checkpoint>')
802
- .description('Get retained transcript chunks for one checkpoint')
803
- .option('--cursor <cursor>', 'Zero-based chunk cursor')
804
- .option('--limit <count>', 'Chunks per page', '20')
805
- .option('--json', 'Output as JSON')
806
- .action((ref, checkpoint, options) => runPublicCommand(() => tracesGetCommand(ref, checkpoint, options), options.json));
810
+ const telemetry = program.command('telemetry').description('Add privacy-safe production telemetry without an application SDK');
811
+ telemetry
812
+ .command('instrument <dist>')
813
+ .description('Instrument compiled Node.js output without changing application source')
814
+ .requiredOption('--entry <file>', 'Entry file relative to the compiled output directory')
815
+ .option('--source-root <dir>', 'Source directory whose files correspond exactly to compiled output (default: sibling src/)')
816
+ .option('--include-symbols <file>', 'Experimental JSON allow-list of exact sourcePath + qualifiedName symbols')
817
+ .option('--json', 'Machine-readable instrumentation manifest')
818
+ .addHelpText('after', `
819
+ Run this once after the normal application build. It rewrites only compiled
820
+ JavaScript and copies a dependency-free runtime beside it; application source
821
+ does not import Haystack.
822
+
823
+ At runtime, telemetry stays off unless all three variables are set:
824
+ HAYSTACK_TELEMETRY=1
825
+ HAYSTACK_TELEMETRY_ENDPOINT=https://.../v3/telemetry
826
+ HAYSTACK_TELEMETRY_TOKEN=...
827
+
828
+ Example:
829
+ npm run build && haystack telemetry instrument dist --entry index.js
830
+ `)
831
+ .action((dist, options) => runPublicCommand(() => telemetryInstrumentCommand(dist, {
832
+ ...options,
833
+ includeSymbolsFile: options.includeSymbols,
834
+ includeSymbols: undefined,
835
+ }), options.json));
807
836
  program
808
837
  .command('dismiss <pr>')
809
838
  .description('Dismiss analysis findings for a PR')
@@ -826,6 +855,43 @@ Examples:
826
855
  haystack dismiss acme/widgets#99 # Dismiss for specific repo
827
856
  `)
828
857
  .action(dismissCommand);
858
+ program
859
+ .command('design-verify <pr>')
860
+ // "verification" is a banned word in top-level help (public-contract test
861
+ // keeps retired auto-fix/verification wording out of the CLI surface).
862
+ .description('Run a blind design-by-execution review of a PR')
863
+ .option('--json', 'Machine-readable output')
864
+ .option('--no-wait', 'Return after the run is admitted instead of waiting for its verdict')
865
+ .option('--run <run-id>', 'Resume and wait for an existing exact run id')
866
+ .option('--poll-interval <seconds>', 'Status polling interval', '3')
867
+ .option('--timeout <seconds>', 'Maximum time to wait; the server run continues after timeout', '7200')
868
+ .option('--case <case-id>', 'Select one exact generated case for universe exploration')
869
+ .option('--universe <role>', 'Select control-before, before, or after')
870
+ .option('--replay', 'Replay the registered case command in the selected universe')
871
+ .option('--exec-json <argv>', 'Run a JSON argv array in the selected universe')
872
+ .option('--cwd <path>', 'Repository-relative working directory for --exec-json')
873
+ .option('--command-timeout <seconds>', 'Maximum selected-universe command runtime')
874
+ .option('--action <action-id>', 'Resume one exact universe action')
875
+ .addHelpText('after', `
876
+ Executes the change instead of reading it: infers intent from the diff
877
+ alone, designs pre-registered behavioral test cases, runs control-before,
878
+ before, and after in isolated sandboxes, and reports anomaly candidates
879
+ outside the registered intent.
880
+
881
+ The command waits for a behavioral verdict by default. Use --no-wait to
882
+ return the run id immediately, or --run <run-id> to resume waiting.
883
+
884
+ After a completed run, inspect or replay one retained case universe without
885
+ receiving provider credentials:
886
+ haystack design-verify owner/repo#123 --run RUN --case case-00001 --universe before --replay
887
+ haystack design-verify owner/repo#123 --run RUN --case case-00001 --universe after --exec-json '["rg","TODO"]'
888
+
889
+ PR identifier formats:
890
+ 123 PR number (uses current repo)
891
+ owner/repo#123 Fully qualified
892
+ https://github.com/owner/repo/pull/123 GitHub URL
893
+ `)
894
+ .action(designVerifyCommand);
829
895
  program
830
896
  .command('mark-reviewed <pr>')
831
897
  .description('Mark human review as not needed for a PR')
@@ -1035,73 +1101,128 @@ Examples:
1035
1101
  // Skills subcommands
1036
1102
  const skills = program
1037
1103
  .command('skills')
1038
- .description('Manage AI skills for Claude Code');
1104
+ .description('Manage AI skills for coding agents');
1039
1105
  skills
1040
1106
  .command('install')
1041
- .description('Install Haystack skills into your coding CLI')
1107
+ .description('Install portable Haystack skills and optional coding-CLI shims')
1042
1108
  .option('--cli <name>', 'Target CLI: claude, codex, cursor, or manual')
1043
1109
  .addHelpText('after', `
1044
- This registers the Haystack MCP server with your coding CLI, enabling:
1045
- /setup-haystack - AI-assisted project setup
1110
+ This installs portable skills in the Git repository's .agents/skills directory:
1046
1111
  /submit - Submit a PR via Haystack
1112
+ /map-your-system - Map how Haystack QA can run this system
1113
+ /map-cloud-verifier-universe - Map a production-derived hermetic universe
1047
1114
  Supported CLIs:
1048
- claude Claude Code (auto-detected)
1049
- codex Codex CLI (auto-detected)
1050
- cursor Cursor IDE (auto-detected)
1051
- manual Show manual setup instructions
1115
+ claude Also install Claude Code command shims
1116
+ codex Use portable .agents/skills discovery only
1117
+ cursor Use portable .agents/skills discovery only
1118
+ manual Install portable skills and show their location
1052
1119
 
1053
1120
  Examples:
1054
- haystack skills install # Auto-detect and install
1121
+ haystack skills install # Install portable skills only
1055
1122
  haystack skills install --cli codex # Install for Codex only
1056
- haystack skills install --cli manual # Show manual instructions
1123
+ haystack skills install --cli claude # Also install Claude command shims
1057
1124
  `)
1058
- .action(installSkills);
1125
+ .action(async (opts) => {
1126
+ try {
1127
+ await installSkills(opts);
1128
+ }
1129
+ catch (err) {
1130
+ console.error(chalk.red('skills install failed:'), err instanceof Error ? err.message : err);
1131
+ process.exit(1);
1132
+ }
1133
+ });
1059
1134
  skills
1060
1135
  .command('list')
1061
1136
  .description('List available Haystack skills')
1062
1137
  .action(listSkills);
1063
- // Hooks subcommands
1138
+ skills
1139
+ .command('census-universe')
1140
+ .description('Deterministically census Cloud Verifier source identities before mapping')
1141
+ .option('--json', 'Machine-readable result')
1142
+ .option('--root <path>', 'Repository root (default: current Git worktree)')
1143
+ .action((opts) => runPublicCommand(async () => cloudVerifierIdentityCensusCommand(opts), opts.json));
1144
+ skills
1145
+ .command('data-store-drift')
1146
+ .description('Check whether the detected data stores still match the checked-in map (per-PR drift gate)')
1147
+ .option('--json', 'Machine-readable result')
1148
+ .option('--root <path>', 'Repository root (default: current Git worktree)')
1149
+ .option('--baseline <path>', 'Baseline map path (default: .haystack/cloud-verifier/data-stores.json)')
1150
+ .option('--base-ref <ref>', 'Only run when the diff against this ref touches a store-relevant file')
1151
+ .option('--update', 'Write the current detected stores as the new baseline')
1152
+ .action((opts) => runPublicCommand(async () => cloudVerifierDataStoreDriftCommand(opts), opts.json));
1153
+ skills
1154
+ .command('validate-universe')
1155
+ .description('Validate Cloud Verifier universe artifacts and stable-ID references')
1156
+ .option('--json', 'Machine-readable result')
1157
+ .action(async (opts) => {
1158
+ try {
1159
+ await cloudVerifierUniverseValidateCommand(opts);
1160
+ }
1161
+ catch (err) {
1162
+ console.error(chalk.red('validate-universe failed:'), err instanceof Error ? err.message : err);
1163
+ process.exit(1);
1164
+ }
1165
+ });
1166
+ skills
1167
+ .command('validate-behaviors')
1168
+ .description('Validate customer actions and their exact runtime identities')
1169
+ .option('--json', 'Machine-readable result')
1170
+ .action(async (opts) => {
1171
+ try {
1172
+ await cloudVerifierBehaviorsValidateCommand(opts);
1173
+ }
1174
+ catch (err) {
1175
+ console.error(chalk.red('validate-behaviors failed:'), err instanceof Error ? err.message : err);
1176
+ process.exit(1);
1177
+ }
1178
+ });
1179
+ skills
1180
+ .command('scaffold-provisional-universe')
1181
+ .description('Create a compact missing-authority receipt from strict JSON facts')
1182
+ .requiredOption('--input <path>', 'Strict provisional-universe JSON input file')
1183
+ .action((opts) => runPublicCommand(async () => scaffoldProvisionalUniverseCommand(opts), true));
1184
+ skills
1185
+ .command('prepare-universe-review')
1186
+ .description('Create a tracked-source snapshot with conventional test paths removed')
1187
+ .option('--json', 'Machine-readable isolation result and snapshot manifest')
1188
+ .option('--exclude-inactive-submodule <path...>', 'Omit exact tracked gitlink paths explicitly known to be inactive')
1189
+ .option('--omit-unscannable-files', 'Omit files whose test content cannot be ruled out, instead of blocking the review. '
1190
+ + 'The reviewer still never sees a test; the omissions are recorded as uncovered scope')
1191
+ .option('--full-receipt', 'Include complete non-blocking path receipts in JSON output')
1192
+ .action((opts) => runPublicCommand(() => prepareUniverseReviewCommand(opts), opts.json));
1064
1193
  const hooks = program
1065
1194
  .command('hooks')
1066
1195
  .description('Manage git hooks for AI agent quality checks');
1067
1196
  hooks
1068
1197
  .command('install')
1069
- .description('Install Haystack git hooks and Entire CLI')
1070
- .option('--version <version>', 'Entire CLI version (default: pinned)')
1198
+ .description('Install Haystack git hooks')
1071
1199
  .option('-f, --force', 'Overwrite existing hooks')
1072
- .option('--skip-entire', 'Skip Entire binary download')
1073
1200
  .addHelpText('after', `
1074
1201
  This installs:
1075
1202
  • Git hooks for AI agent quality checks (pre-commit, commit-msg, etc.)
1076
1203
  • Agent context detector (identifies AI agent sessions)
1077
1204
  • Truncation checker (prevents code truncation by LLMs)
1078
- • Entire CLI binary for session tracking (powered by https://entire.dev)
1079
1205
 
1080
1206
  Hooks are installed to <repo>/hooks/ and git is configured to use them.
1081
1207
 
1082
1208
  Examples:
1083
- haystack hooks install # Install with pinned Entire version
1084
1209
  haystack hooks install --force # Overwrite existing hooks
1085
- haystack hooks install --skip-entire # Only install Haystack hooks
1086
1210
  `)
1087
1211
  .action(hooksInstall);
1088
1212
  hooks
1089
1213
  .command('status')
1090
1214
  .description('Check hooks installation status')
1091
1215
  .action(hooksStatus);
1092
- hooks
1093
- .command('update')
1094
- .description('Update Entire CLI to the latest version')
1095
- .action(hooksUpdate);
1096
1216
  hooks
1097
1217
  .command('install-session')
1098
- .description('Install session-start hooks for coding CLIs')
1218
+ .description('Install session-start and Stop hooks for coding CLIs')
1099
1219
  .option('--cli <name>', 'Target CLI: claude, codex, gemini, or all')
1100
1220
  .addHelpText('after', `
1101
1221
  Configures your coding CLI to run \`haystack triage --hook\` on session start.
1102
1222
  This shows pending PR analysis results when you open a new terminal session.
1223
+ Claude Code also runs \`haystack verify precompute --hook\` when a session stops.
1103
1224
 
1104
- Claude Code: Native SessionStart hook (.claude/settings.json)
1225
+ Claude Code: Native SessionStart and Stop hooks (.claude/settings.json)
1105
1226
  Codex CLI: AGENTS.md instructions
1106
1227
  Gemini CLI: GEMINI.md instructions
1107
1228
 
package/dist/schema.d.ts CHANGED
@@ -12,11 +12,10 @@
12
12
  export declare const SCHEMA_VERSIONS: {
13
13
  readonly triage: "2.0.0";
14
14
  readonly setup: "1.0.0";
15
- readonly pr: "2.0.0";
15
+ readonly pr: "3.0.0";
16
16
  readonly 'pr-status': "1.0.0";
17
17
  readonly inbox: "1.0.0";
18
18
  readonly ask: "1.0.0";
19
- readonly traces: "1.0.0";
20
19
  readonly submit: "1.0.0";
21
20
  readonly action: "1.0.0";
22
21
  readonly 'cloud-verifier': "1.0.0";
package/dist/schema.js CHANGED
@@ -12,11 +12,10 @@
12
12
  export const SCHEMA_VERSIONS = {
13
13
  triage: '2.0.0',
14
14
  setup: '1.0.0',
15
- pr: '2.0.0',
15
+ pr: '3.0.0',
16
16
  'pr-status': '1.0.0',
17
17
  inbox: '1.0.0',
18
18
  ask: '1.0.0',
19
- traces: '1.0.0',
20
19
  submit: '1.0.0',
21
20
  action: '1.0.0',
22
21
  'cloud-verifier': '1.0.0',
@@ -22,10 +22,3 @@ export declare function buildRulesValidatorPrompt(baseBranch: string, rulesYaml:
22
22
  filename: string;
23
23
  content: string;
24
24
  }[], precomputedDiff?: string | null): string | null;
25
- /**
26
- * Build the intent drift prompt.
27
- * Only runs if relevant trace files exist.
28
- *
29
- * @returns The prompt string, or null if no trace files provided.
30
- */
31
- export declare function buildIntentDriftPrompt(baseBranch: string, traceFiles: string[], outputPath: string, maxTurns: number, timeoutMs: number, precomputedDiff?: string | null): string | null;
@@ -37,21 +37,6 @@ const RULES_VALIDATOR_SCHEMA = `{
37
37
  "rulesChecked": 3,
38
38
  "passed": true
39
39
  }`;
40
- const INTENT_DRIFT_SCHEMA = `{
41
- "checker": "intent-drift",
42
- "issues": [
43
- {
44
- "file": "relative/path/to/file.ts",
45
- "line": 42,
46
- "severity": "error | warning | info",
47
- "message": "Description of the drift or incomplete fulfillment",
48
- "pattern": "intent_drift | incomplete_fulfillment | scope_creep | unspecified_decision | ignored_correction | weakened_posture | claimed_but_not_done"
49
- }
50
- ],
51
- "summary": "Brief 1-sentence summary",
52
- "sessionsChecked": 2,
53
- "passed": true
54
- }`;
55
40
  // ============================================================================
56
41
  // Prompt builders
57
42
  // ============================================================================
@@ -235,133 +220,3 @@ ${RULES_VALIDATOR_SCHEMA}
235
220
  - Set \`passed\` to \`false\` if any violations with severity "error" were found
236
221
  - You MUST write the result file even if no violations are found`;
237
222
  }
238
- /**
239
- * Build the intent drift prompt.
240
- * Only runs if relevant trace files exist.
241
- *
242
- * @returns The prompt string, or null if no trace files provided.
243
- */
244
- export function buildIntentDriftPrompt(baseBranch, traceFiles, outputPath, maxTurns, timeoutMs, precomputedDiff) {
245
- if (traceFiles.length === 0)
246
- return null;
247
- const traceFileList = traceFiles.map(f => `- \`${f}\``).join('\n');
248
- return `You are an intent drift detector. Your job is to check whether an AI coding agent faithfully implemented what the user asked for.
249
-
250
- ${buildTimeBudgetHeader(maxTurns, timeoutMs)}## Context
251
-
252
- This PR was created by an AI coding agent. The agent's session transcripts (traces) are stored locally. You will compare what the user asked the agent to do against what was actually implemented in the diff.
253
-
254
- ## Instructions
255
-
256
- 1. Read each of these files (they contain the user's messages extracted from the agent session, one per section):
257
- ${traceFileList}
258
-
259
- 2. From each file, identify:
260
- - The user's original instruction/prompt (the first message)
261
- - Any follow-up instructions or corrections from the user
262
- - The final effective scope after later corrections or reframes
263
-
264
- 3. ${precomputedDiff ? 'Review the diff below' : `Run \`git diff ${baseBranch}...HEAD\``} to see what was actually implemented.
265
-
266
- 4. Compare the user's intent against the actual implementation. Look for:
267
-
268
- ### Intent Drift
269
- The agent implemented something DIFFERENT from what was asked:
270
- - User says "delay as long as possible" → agent uses a fixed 30s timeout
271
- - User says "only when X" → agent does it unconditionally
272
- - User says "use library A" → agent uses library B
273
- - User says "lazy load" → agent loads eagerly
274
-
275
- ### Incomplete Fulfillment
276
- The agent didn't finish everything that was asked:
277
- - User requested 3 things, agent only did 2
278
- - User requested a general/systematic guardrail or end-to-end behavior, but the diff only handles one known instance, one special case, or one side of the required wiring
279
- - User initially mentioned a known example, then clarified "not the specific case" / "the general class"; the diff still implements only the known example or category-specific check
280
- - Interface fields declared but never populated
281
- - A new keyed capability, event, route, config value, enum variant, or serialized field is referenced on one side of a boundary but the required registry, producer, consumer, schema, handler, persistence path, or delivery surface is missing
282
- - A change appears to work through local/dev/test defaults, mocks, or overrides, but the production wiring path needed to deliver the requested behavior was not updated
283
- - Functions stubbed with TODO/placeholder comments
284
- - Agent said "I'll skip X for now" for something the user explicitly requested
285
- - Tests not written when user asked for tests
286
-
287
- ### Scope Creep
288
- The agent added functionality the user never asked for:
289
- - User asks to fix a bug → agent also adds a cooldown, retry logic, or caching layer
290
- - User asks to investigate → agent proactively "fixes" things beyond what was discussed
291
- - User asks for one feature → agent bundles in extra features "while we're at it"
292
- - Any new mechanism not traceable to a user instruction
293
-
294
- ### Unspecified Decision
295
- The user authorized the task's GOAL, but the agent made a specific decision in HOW it carried it out that shapes the program's end output, externally observable behavior, or the data end-users/callers see — and the user never specified or approved that particular decision, and a reasonable user would plausibly want a say in it. Examples (general — do NOT pattern-match on specific keywords):
296
- - Silently dropping, capping, sampling, or transforming data that flows to the output
297
- - Picking a default that determines what end-users see
298
- - Resolving an ambiguous requirement one way when other materially different behaviors were equally valid
299
- - Choosing a fixed value where the choice changes results
300
- Do NOT flag internal implementation choices with no observable effect (naming, file layout, helper structure), decisions forced by correctness, or cosmetic defaults a user would not care about. When unsure whether a user would care, do not flag it — reserve this for decisions with real, user-visible ramifications. The difference from scope creep: scope creep is an unrequested *flow*; an unspecified decision is an unrequested, output-shaping choice *inside a requested flow*.
301
-
302
- ### Ignored Correction
303
- The user gave an explicit correction or redirection and the final code does NOT honor it:
304
- - User said "don't use a global / use X instead / that's racy, do Y" and the agent shipped the thing it was told not to
305
- - User said the target is the general class rather than the specific instance, but the agent still shipped only the instance-specific implementation
306
- - Agent applied the correction, then quietly reverted it in a later step
307
- - A general later "looks good" does NOT cancel a specific earlier correction
308
- This is high severity by default: the user actively steered and was overridden.
309
-
310
- ### Weakened Posture
311
- In service of an authorized goal, the agent relaxed or removed a security, safety, or correctness guard the user never asked to weaken:
312
- - Loosened an auth/permission/validation check, or broadened access (CORS, scopes)
313
- - Swallowed or silenced an error, removed an assertion/guard, hardcoded a bypass or credential
314
- - Disabled a test (.skip / xit), suppressed a type or lint check (any, @ts-ignore, disable comments)
315
- - Lowered a threshold/timeout that existed as a safeguard
316
- - Relaxed a CI/pipeline security or quality gate (a workflow check, audit, or validation policy) — especially so that the agent's OWN change would pass that gate
317
- High severity by default. (If the user explicitly asked to remove the guard, it is not a finding.)
318
- Tie-breaker for gate relaxations: when the agent's own work was failing a CI gate and the agent changed the gate so it would pass, that is weakened_posture even when the old gate looks buggy or overly strict, and even when a delegation ("shepherd this", "get it merged") covered the goal — whether the relaxation was right is exactly the judgment this flag hands to a human.
319
- Wording for weakened_posture findings: describe the decision reflectively, lede first, in plain English — sentence 1 says who weakened which protection and why ("To get this change through CI, the agent loosened the check that was blocking it"), sentence 2 gives the concrete change, then hand the call to a human. If a delegation covered the surrounding goal, say so; never claim "no user directive" when one exists. This is not an accusation of violating intent — it is a consequential decision a human should confirm.
320
-
321
- ### Claimed But Not Done
322
- The agent told the user it completed work that the diff does not actually contain, or contains only in a materially weaker form:
323
- - "I added error handling for timeouts" but no timeout handling exists in the diff
324
- - "Added tests for the edge case" but no test assertions exercise it
325
- - "Made the limit configurable" but the value is still hardcoded
326
- Compare each concrete claim the agent made to the user against what the diff actually shows. Only flag when the diff clearly contradicts or fails to support the claim; when unsure, do not flag.
327
-
328
- ## Red flags to search for in the diff
329
-
330
- - Fixed/hardcoded values where dynamic behavior was requested
331
- - TODO, FIXME, placeholder, stub comments in new code
332
- - Empty function bodies or early returns
333
- - Interface fields that are declared but never assigned anywhere
334
- - Feature-specific or instance-specific checks added after the user asked for a general guardrail against a broader failure mode
335
- - Earlier narrow examples treated as the whole task even though later user messages broadened or generalized the requested scope
336
- - New string-keyed names, enum variants, serialized fields, action types, routes, events, or config keys that have no matching entry in the surrounding registry, allow-list, schema, handler, producer, consumer, or template path
337
- - Comments or neighboring code saying "must also register/list/wire this" where the diff updated only the reference side
338
- - New mechanisms (cooldowns, retries, caches, rate limits) not requested by the user
339
- - Decisions that drop, limit, or reshape data flowing to the output, or pick a default that changes what end-users see, with no instruction specifying it
340
-
341
- ## Output
342
-
343
- Write your results to \`${outputPath}\` as JSON with this exact schema:
344
-
345
- \`\`\`json
346
- ${INTENT_DRIFT_SCHEMA}
347
- \`\`\`
348
-
349
- - Set \`sessionsChecked\` to the number of trace files you read
350
- - Set \`passed\` to \`true\` only when no intent-drift issues are found
351
- - Set \`passed\` to \`false\` when any issue is found (any pattern, any severity)
352
- - For each issue, set \`pattern\` to one of: "intent_drift", "incomplete_fulfillment", "scope_creep", "unspecified_decision", "ignored_correction", "weakened_posture", "claimed_but_not_done"
353
- - Write each issue's \`message\` in plain English for the PR author, lede first (what concretely happened, then why it matters); never reference this checker's machinery ("per policy", "extracted directives", "session shape")
354
- - You MUST write the result file even if no issues are found
355
-
356
- ## Severity guidelines
357
-
358
- - **error**: Core user intent violated — the main thing they asked for is wrong or missing, or large unrequested feature added
359
- - **warning**: Secondary requirement missed or approximated, or small unrequested mechanism added
360
- - **info**: Minor simplification that mostly still works as intended${precomputedDiff ? `
361
-
362
- ## Diff (precomputed)
363
-
364
- \`\`\`diff
365
- ${precomputedDiff}
366
- \`\`\`` : ''}`;
367
- }
@@ -8,8 +8,7 @@ import { execSync, spawn } from 'child_process';
8
8
  import { existsSync, readFileSync, mkdirSync, rmSync } from 'fs';
9
9
  import { join } from 'path';
10
10
  import chalk from 'chalk';
11
- import { buildCodeReviewPrompt, buildRulesValidatorPrompt, buildIntentDriftPrompt } from './prompts.js';
12
- import { findRelevantTraces } from './traces.js';
11
+ import { buildCodeReviewPrompt, buildRulesValidatorPrompt } from './prompts.js';
13
12
  import { resolveDiffBaseRef } from '../utils/git.js';
14
13
  import { trackError } from '../utils/telemetry.js';
15
14
  // ============================================================================
@@ -26,7 +25,6 @@ const DEFAULT_TIMEOUT_MS = 180_000; // 3 minutes
26
25
  const DEFAULT_MAX_TURNS = {
27
26
  'code-review': 8,
28
27
  'rules-validator': 10,
29
- 'intent-drift': 10,
30
28
  };
31
29
  // ============================================================================
32
30
  // Agent policy file discovery
@@ -101,7 +99,13 @@ export function buildCommand(cli, prompt, maxTurns) {
101
99
  case 'codex':
102
100
  return {
103
101
  command: 'codex',
104
- args: ['exec', prompt, '--full-auto'],
102
+ args: [
103
+ '--sandbox', 'workspace-write',
104
+ '--ask-for-approval', 'never',
105
+ 'exec',
106
+ '--ephemeral',
107
+ prompt,
108
+ ],
105
109
  };
106
110
  case 'gemini':
107
111
  return {
@@ -119,17 +123,12 @@ function spawnChecker(cli, config, cwd, timeoutMs) {
119
123
  const { command, args } = buildCommand(cli, config.prompt, config.maxTurns);
120
124
  let stdout = '';
121
125
  let stderr = '';
122
- const codexHome = join(cwd, '.haystack', 'triage', 'codex-home');
123
- if (cli === 'codex') {
124
- mkdirSync(codexHome, { recursive: true });
125
- }
126
126
  const proc = spawn(command, args, {
127
127
  cwd,
128
128
  stdio: ['ignore', 'pipe', 'pipe'],
129
129
  env: {
130
130
  ...process.env,
131
131
  CLAUDECODE: undefined,
132
- CODEX_HOME: cli === 'codex' ? codexHome : process.env.CODEX_HOME,
133
132
  },
134
133
  });
135
134
  proc.stdout?.on('data', (data) => {
@@ -276,8 +275,8 @@ export async function runTriage(gitRoot, baseBranch, options = {}) {
276
275
  // Resolve the ref to diff against once. Prefers origin/<base> over the bare
277
276
  // local <base> ref (which is often stale and balloons the diff with already-
278
277
  // merged code). Every git read below — the precomputed diff, the agent diff
279
- // commands in the prompts, and the changed-file scan in findRelevantTraces —
280
- // uses this single resolved ref so they all see the same fork point.
278
+ // commands in the prompts use this single resolved ref so they all see the
279
+ // same fork point.
281
280
  const diffBaseRef = resolveDiffBaseRef(baseBranch);
282
281
  if (diffBaseRef !== baseBranch) {
283
282
  console.log(chalk.dim(` Diff base: ${diffBaseRef}`));
@@ -323,26 +322,9 @@ export async function runTriage(gitRoot, baseBranch, options = {}) {
323
322
  });
324
323
  }
325
324
  }
326
- // 3. Intent drift (only if relevant trace files exist)
327
- const traceFiles = findRelevantTraces(gitRoot, diffBaseRef);
328
- if (traceFiles.length > 0) {
329
- const intentDriftOutput = join(triageDir, 'intent-drift.json');
330
- const driftPrompt = buildIntentDriftPrompt(diffBaseRef, traceFiles, intentDriftOutput, maxTurns['intent-drift'], timeoutMs, precomputedDiff);
331
- if (driftPrompt) {
332
- checkers.push({
333
- name: 'intent-drift',
334
- prompt: driftPrompt,
335
- outputFile: intentDriftOutput,
336
- maxTurns: maxTurns['intent-drift'],
337
- });
338
- }
339
- }
340
325
  // Log what we're running
341
326
  const checkerNames = checkers.map(c => c.name);
342
327
  console.log(chalk.dim(` Checkers: ${checkerNames.join(', ')}`));
343
- if (traceFiles.length > 0) {
344
- console.log(chalk.dim(` Traces: ${traceFiles.length} relevant session(s) found`));
345
- }
346
328
  console.log(chalk.dim(` Running ${checkers.length} checker(s) in parallel...\n`));
347
329
  // Spawn all checkers in parallel
348
330
  const spawnResults = await Promise.allSettled(checkers.map(async (checker) => {
@@ -28,14 +28,7 @@ export interface RulesValidatorResult {
28
28
  passed: boolean;
29
29
  rulesChecked: number;
30
30
  }
31
- export interface IntentDriftResult {
32
- checker: 'intent-drift';
33
- issues: TriageIssue[];
34
- summary: string;
35
- passed: boolean;
36
- sessionsChecked: number;
37
- }
38
- export type CheckerResult = CodeReviewResult | RulesValidatorResult | IntentDriftResult;
31
+ export type CheckerResult = CodeReviewResult | RulesValidatorResult;
39
32
  export interface TriageResult {
40
33
  passed: boolean;
41
34
  results: CheckerResult[];