@ironbee-ai/cli 0.30.0 → 0.31.0

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 (84) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/analytics/claude/emit.js +1 -1
  3. package/dist/analytics/claude/state.js +1 -1
  4. package/dist/analytics/codex/events-emit.js +2 -2
  5. package/dist/analytics/codex/subagent-transcripts.js +3 -3
  6. package/dist/clients/claude/hooks/activity-end.js +1 -1
  7. package/dist/clients/claude/hooks/activity-start.js +1 -1
  8. package/dist/clients/claude/hooks/clear-verdict.js +1 -1
  9. package/dist/clients/claude/hooks/require-verdict.js +2 -2
  10. package/dist/clients/claude/hooks/require-verification.js +3 -3
  11. package/dist/clients/claude/hooks/session-end.js +1 -1
  12. package/dist/clients/claude/hooks/session-start.js +4 -4
  13. package/dist/clients/claude/hooks/session-status.js +2 -2
  14. package/dist/clients/claude/hooks/subagent-start.js +1 -1
  15. package/dist/clients/claude/hooks/subagent-stop.js +1 -1
  16. package/dist/clients/claude/hooks/track-action-monitor.js +1 -1
  17. package/dist/clients/claude/hooks/track-action.js +1 -1
  18. package/dist/clients/claude/hooks/verify-gate.js +4 -4
  19. package/dist/clients/claude/platforms/scenario.android.md +1 -0
  20. package/dist/clients/claude/platforms/skill.android.md +4 -0
  21. package/dist/clients/claude/process-analytics.js +1 -1
  22. package/dist/clients/claude/statusline-toggle.js +2 -2
  23. package/dist/clients/codex/hooks/activity-end.js +1 -1
  24. package/dist/clients/codex/hooks/activity-start.js +1 -1
  25. package/dist/clients/codex/hooks/clear-verdict.js +3 -3
  26. package/dist/clients/codex/hooks/require-verdict.js +2 -2
  27. package/dist/clients/codex/hooks/require-verification.js +3 -3
  28. package/dist/clients/codex/hooks/session-start.js +3 -3
  29. package/dist/clients/codex/hooks/subagent-start.js +1 -1
  30. package/dist/clients/codex/hooks/subagent-stop.js +1 -1
  31. package/dist/clients/codex/hooks/track-action-monitor.js +1 -1
  32. package/dist/clients/codex/hooks/track-action-pre.js +1 -1
  33. package/dist/clients/codex/hooks/track-action.js +1 -1
  34. package/dist/clients/codex/hooks/verify-gate.js +1 -1
  35. package/dist/clients/codex/index.js +2 -2
  36. package/dist/clients/codex/platforms/command-verify.android.md +1 -0
  37. package/dist/clients/codex/platforms/rule.android.md +2 -1
  38. package/dist/clients/codex/platforms/scenario.android.md +1 -0
  39. package/dist/clients/codex/platforms/skill.android.md +4 -0
  40. package/dist/clients/codex/process-analytics.js +2 -2
  41. package/dist/clients/codex/thread-map.js +1 -1
  42. package/dist/clients/codex/util.js +44 -31
  43. package/dist/clients/cursor/hooks/activity-end.js +1 -1
  44. package/dist/clients/cursor/hooks/activity-start.js +1 -1
  45. package/dist/clients/cursor/hooks/clear-verdict.js +1 -1
  46. package/dist/clients/cursor/hooks/require-verdict.js +2 -2
  47. package/dist/clients/cursor/hooks/require-verification.js +3 -3
  48. package/dist/clients/cursor/hooks/session-end.js +1 -1
  49. package/dist/clients/cursor/hooks/session-start.js +4 -4
  50. package/dist/clients/cursor/hooks/track-action-monitor.js +1 -1
  51. package/dist/clients/cursor/hooks/track-action.js +1 -1
  52. package/dist/clients/cursor/hooks/verify-gate.js +1 -1
  53. package/dist/clients/cursor/platforms/command-verify.android.md +1 -0
  54. package/dist/clients/cursor/platforms/rule.android.md +2 -1
  55. package/dist/clients/cursor/platforms/scenario.android.md +1 -0
  56. package/dist/clients/cursor/platforms/skill.android.md +4 -0
  57. package/dist/commands/config.js +1 -1
  58. package/dist/commands/hook.js +10 -10
  59. package/dist/commands/import.js +3 -3
  60. package/dist/commands/process-job-file.js +1 -1
  61. package/dist/commands/queue.js +16 -16
  62. package/dist/commands/status.js +1 -1
  63. package/dist/commands/uninstall.js +1 -1
  64. package/dist/commands/verify.js +2 -2
  65. package/dist/hooks/core/actions.js +7 -7
  66. package/dist/hooks/core/session-state.js +1 -1
  67. package/dist/hooks/core/verification-context.js +8 -8
  68. package/dist/import/marker.js +2 -2
  69. package/dist/import/skip.js +1 -1
  70. package/dist/lib/config.js +1 -1
  71. package/dist/lib/install-version.js +1 -1
  72. package/dist/lib/runtime-paths.js +1 -0
  73. package/dist/otel/claude/daemon/process.js +1 -1
  74. package/dist/otel/claude/daemon/reprocess.js +1 -1
  75. package/dist/otel/claude/daemon/response-usage.js +2 -2
  76. package/dist/queue/drain.js +1 -1
  77. package/dist/queue/flush.js +1 -1
  78. package/dist/queue/paths.js +1 -1
  79. package/dist/queue/process-file.js +2 -2
  80. package/dist/queue/spawn.js +1 -1
  81. package/dist/tui/config/schema.js +1 -1
  82. package/dist/tui/queue/read.js +4 -4
  83. package/dist/tui/sessions/read.js +2 -2
  84. package/package.json +1 -1
@@ -1,24 +1,24 @@
1
- "use strict";var p=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var b=(i,e)=>p(i,"name",{value:e,configurable:!0});var P=(i,e)=>{for(var t in e)p(i,t,{get:e[t],enumerable:!0})},x=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of N(e))!C.call(i,n)&&n!==t&&p(i,n,{get:()=>e[n],enumerable:!(o=j(e,n))||o.enumerable});return i};var D=i=>x(p({},"__esModule",{value:!0}),i);var _={};P(_,{hookCommand:()=>r});module.exports=D(_);var I=require("commander"),E=require("../clients/registry"),S=require("../hooks/core/submit-verdict"),h=require("../hooks/core/verification-lifecycle"),u=require("../lib/config"),l=require("../lib/logger"),d=require("../lib/output"),m=require("../lib/stdin"),k=require("../hooks/core/session-state"),v=require("../clients/session-id"),f=require("../clients/agent-project-dir");function g(i,e){return(0,u.getVerificationEnabled)((0,u.loadConfig)(i))?!1:(l.logger.debug(`${e}: verification is disabled \u2014 silent no-op`),!0)}b(g,"isVerificationDisabled");function s(i){const e=i??process.env.IRONBEE_CLIENT;e||(process.stderr.write(`Error: client not specified. Use --client <name> or set IRONBEE_CLIENT env var.
2
- `),process.exit(1));const t=(0,E.findClient)(e);return t||(process.stderr.write(`Error: unknown client "${e}". Run \`ironbee install\` to set up.
3
- `),process.exit(1)),t}b(s,"resolveClient");const r=new I.Command("hook").description("Internal hook runners (invoked by the AI coding client)");r.command("verify-gate").description("Stop hook \u2014 gates task completion until browser verification passes").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runVerifyGate(t)}),r.command("clear-verdict").description("PostToolUse hook \u2014 clears stale verdict after code edits").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runClearVerdict(t)}),r.command("track-action").description("PostToolUse hook \u2014 tracks browser-devtools tool calls in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackAction(t)}),r.command("track-action-monitor").description("PostToolUse hook (monitoring-only mode) \u2014 submits send_event jobs for non-devtools tools and falls back to starting an activity if needed").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackActionMonitor(t)}),r.command("track-action-pre").description("Codex PreToolUse hook \u2014 stashes a hrtime timestamp keyed by tool_use_id so the matching PostToolUse can derive tool_call.duration (Codex hook stdin does not carry duration_ms). No-op on Claude/Cursor \u2014 their hosts provide duration natively.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackActionPre(t)}),r.command("subagent-start").description("SubagentStart hook \u2014 dispatched per client via IClient.runSubagentStart. Codex: writes the agent_id \u2192 parent session_id bridge (codex-threads.json). Claude: joins the sub-agent as an activity participant so the activity closes only when the last participant (main + all sub-agents) leaves.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSubagentStart?.(t)}),r.command("subagent-stop").description("SubagentStop hook \u2014 dispatched per client via IClient.runSubagentStop. Codex: prune the thread map + record the sub-agent's agent_transcript_path for the analytics fold. Claude: backstop that closes a verifier-owned activity/cycle the sub-agent left open without a verdict.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSubagentStop?.(t)}),r.command("activity-end").description("Stop hook (monitoring-only mode) \u2014 closes the active activity and triggers a background queue flush").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runActivityEnd(t)}),r.command("session-start").description("SessionStart hook \u2014 records session start in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSessionStart(t)}),r.command("session-status").description("Statusline command (Claude) \u2014 emits a session_status event and chains the user's original statusline").action(async()=>{await(0,E.findClient)("claude")?.runSessionStatus?.()}),r.command("require-verdict").description("PreToolUse hook \u2014 blocks file edits until verdict is submitted after browser tool usage").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").option("--soft","non-blocking assist-mode variant: stash file_change state but never block the edit").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runRequireVerdict(t,{soft:i.soft===!0})}),r.command("session-end").description("SessionEnd hook \u2014 records session end in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSessionEnd(t)}),r.command("activity-start").description("UserPromptSubmit/beforeSubmitPrompt hook \u2014 starts activity tracking on each agent turn").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runActivityStart(t)}),r.command("require-verification").description("PreToolUse hook \u2014 blocks browser tools until verification-start is called").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").option("--soft","non-blocking assist-mode variant: inject _metadata but never block the devtools call").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runRequireVerification(t,{soft:i.soft===!0})}),r.command("verification-start").description(`Start a verification cycle (called by agent via Bash). Optional --intent flag: "fix" arms the verify-gate's fix-until-pass backstop (a fail verdict keeps blocking even in a zero-edit window); "report" or omitted = verify-only run (clears any stale intent \u2014 "report" is a tolerated alias of omitting the flag, mirroring the command's mode token).`).option("--intent <mode>",'declared intent of this verification run: "fix" or "report"').action(async i=>{const e=(0,f.resolveAgentProjectDir)();if(g(e,"verification-start")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
1
+ "use strict";var g=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var E=(i,e)=>g(i,"name",{value:e,configurable:!0});var x=(i,e)=>{for(var t in e)g(i,t,{get:e[t],enumerable:!0})},D=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of C(e))!P.call(i,n)&&n!==t&&g(i,n,{get:()=>e[n],enumerable:!(o=N(e,n))||o.enumerable});return i};var _=i=>D(g({},"__esModule",{value:!0}),i);var O={};x(O,{hookCommand:()=>r});module.exports=_(O);var S=require("commander"),w=require("../clients/registry"),k=require("../hooks/core/submit-verdict"),y=require("../hooks/core/verification-lifecycle"),u=require("../lib/config"),l=require("../lib/logger"),d=require("../lib/output"),m=require("../lib/stdin"),j=require("../hooks/core/session-state"),v=require("../clients/session-id"),f=require("../clients/agent-project-dir"),p=require("../lib/runtime-paths");function h(i,e){return(0,u.getVerificationEnabled)((0,u.loadConfig)(i))?!1:(l.logger.debug(`${e}: verification is disabled \u2014 silent no-op`),!0)}E(h,"isVerificationDisabled");function s(i){const e=i??process.env.IRONBEE_CLIENT;e||(process.stderr.write(`Error: client not specified. Use --client <name> or set IRONBEE_CLIENT env var.
2
+ `),process.exit(1));const t=(0,w.findClient)(e);return t||(process.stderr.write(`Error: unknown client "${e}". Run \`ironbee install\` to set up.
3
+ `),process.exit(1)),t}E(s,"resolveClient");const r=new S.Command("hook").description("Internal hook runners (invoked by the AI coding client)");r.command("verify-gate").description("Stop hook \u2014 gates task completion until browser verification passes").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runVerifyGate(t)}),r.command("clear-verdict").description("PostToolUse hook \u2014 clears stale verdict after code edits").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runClearVerdict(t)}),r.command("track-action").description("PostToolUse hook \u2014 tracks browser-devtools tool calls in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackAction(t)}),r.command("track-action-monitor").description("PostToolUse hook (monitoring-only mode) \u2014 submits send_event jobs for non-devtools tools and falls back to starting an activity if needed").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackActionMonitor(t)}),r.command("track-action-pre").description("Codex PreToolUse hook \u2014 stashes a hrtime timestamp keyed by tool_use_id so the matching PostToolUse can derive tool_call.duration (Codex hook stdin does not carry duration_ms). No-op on Claude/Cursor \u2014 their hosts provide duration natively.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runTrackActionPre(t)}),r.command("subagent-start").description("SubagentStart hook \u2014 dispatched per client via IClient.runSubagentStart. Codex: writes the agent_id \u2192 parent session_id bridge (codex-threads.json). Claude: joins the sub-agent as an activity participant so the activity closes only when the last participant (main + all sub-agents) leaves.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSubagentStart?.(t)}),r.command("subagent-stop").description("SubagentStop hook \u2014 dispatched per client via IClient.runSubagentStop. Codex: prune the thread map + record the sub-agent's agent_transcript_path for the analytics fold. Claude: backstop that closes a verifier-owned activity/cycle the sub-agent left open without a verdict.").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSubagentStop?.(t)}),r.command("activity-end").description("Stop hook (monitoring-only mode) \u2014 closes the active activity and triggers a background queue flush").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runActivityEnd(t)}),r.command("session-start").description("SessionStart hook \u2014 records session start in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSessionStart(t)}),r.command("session-status").description("Statusline command (Claude) \u2014 emits a session_status event and chains the user's original statusline").action(async()=>{await(0,w.findClient)("claude")?.runSessionStatus?.()}),r.command("require-verdict").description("PreToolUse hook \u2014 blocks file edits until verdict is submitted after browser tool usage").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").option("--soft","non-blocking assist-mode variant: stash file_change state but never block the edit").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runRequireVerdict(t,{soft:i.soft===!0})}),r.command("session-end").description("SessionEnd hook \u2014 records session end in actions.jsonl").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runSessionEnd(t)}),r.command("activity-start").description("UserPromptSubmit/beforeSubmitPrompt hook \u2014 starts activity tracking on each agent turn").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runActivityStart(t)}),r.command("require-verification").description("PreToolUse hook \u2014 blocks browser tools until verification-start is called").option("--client <name>","client name (overrides IRONBEE_CLIENT env var)").option("--soft","non-blocking assist-mode variant: inject _metadata but never block the devtools call").action(async i=>{const e=s(i.client);if(!e)return;const t=e.resolveProjectDir();await e.runRequireVerification(t,{soft:i.soft===!0})}),r.command("verification-start").description(`Start a verification cycle (called by agent via Bash). Optional --intent flag: "fix" arms the verify-gate's fix-until-pass backstop (a fail verdict keeps blocking even in a zero-edit window); "report" or omitted = verify-only run (clears any stale intent \u2014 "report" is a tolerated alias of omitting the flag, mirroring the command's mode token).`).option("--intent <mode>",'declared intent of this verification run: "fix" or "report"').action(async i=>{const e=(0,f.resolveAgentProjectDir)();if(h(e,"verification-start")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
4
4
  `,0);return}i.intent!==void 0&&i.intent!=="fix"&&i.intent!=="report"&&(process.stderr.write(`Error: --intent must be "fix" or "report".
5
5
  `),process.exit(1));const t=i.intent;let o;try{o=JSON.parse((0,m.readStdin)())}catch{process.stderr.write(`Error: no JSON provided via stdin.
6
6
  `),process.exit(1)}const n=(0,v.resolveAgentSessionId)(o,e);n||(process.stderr.write(`Error: JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
7
- `),process.exit(1));const c=`${e}/.ironbee/sessions/${n}`;(0,l.setLogFile)(`${c}/session.log`);const a=(0,u.isRecordingEnabled)(e),w=await(0,h.startVerification)({sessionId:n,sessionDir:c,actionsFile:`${c}/actions.jsonl`,recordingEnabled:a,intent:t}),y={verification_id:w.verificationId,trace_id:w.traceId};a&&(y.recording_required=!0,y.message="Recording is required. Call bdt_content_start-recording BEFORE using any other browser tools."),(0,d.writeAndExit)(JSON.stringify(y)+`
8
- `,0)}),r.command("verification-end").description("End a verification cycle (called by agent via Bash)").action(async()=>{const i=(0,f.resolveAgentProjectDir)();if(g(i,"verification-end")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
7
+ `),process.exit(1));const c=(0,p.sessionDir)(e,n);(0,l.setLogFile)(`${c}/session.log`);const a=(0,u.isRecordingEnabled)(e),I=await(0,y.startVerification)({sessionId:n,sessionDir:c,actionsFile:`${c}/actions.jsonl`,recordingEnabled:a,intent:t}),b={verification_id:I.verificationId,trace_id:I.traceId};a&&(b.recording_required=!0,b.message="Recording is required. Call bdt_content_start-recording BEFORE using any other browser tools."),(0,d.writeAndExit)(JSON.stringify(b)+`
8
+ `,0)}),r.command("verification-end").description("End a verification cycle (called by agent via Bash)").action(async()=>{const i=(0,f.resolveAgentProjectDir)();if(h(i,"verification-end")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
9
9
  `,0);return}let e;try{e=JSON.parse((0,m.readStdin)())}catch{process.stderr.write(`Error: no JSON provided via stdin.
10
10
  `),process.exit(1)}const t=(0,v.resolveAgentSessionId)(e,i);t||(process.stderr.write(`Error: JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
11
- `),process.exit(1));const o=`${i}/.ironbee/sessions/${t}`;(0,l.setLogFile)(`${o}/session.log`);const n=await(0,h.endVerification)({sessionId:t,sessionDir:o,actionsFile:`${o}/actions.jsonl`});n.success?(0,d.writeAndExit)(JSON.stringify({verification_id:n.verificationId,trace_id:n.traceId})+`
11
+ `),process.exit(1));const o=(0,p.sessionDir)(i,t);(0,l.setLogFile)(`${o}/session.log`);const n=await(0,y.endVerification)({sessionId:t,sessionDir:o,actionsFile:`${o}/actions.jsonl`});n.success?(0,d.writeAndExit)(JSON.stringify({verification_id:n.verificationId,trace_id:n.traceId})+`
12
12
  `,0):(process.stderr.write(n.message+`
13
- `),process.exit(1))}),r.command("submit-verdict").description("Submit verification verdict (called by agent via Bash)").option("--project-dir <dir>","project directory (overrides env vars)").action(async i=>{const e=(0,f.resolveAgentProjectDir)(i.projectDir);if(g(e,"submit-verdict")){(0,d.writeAndExit)(`verification is disabled in this project; verdict ignored
13
+ `),process.exit(1))}),r.command("submit-verdict").description("Submit verification verdict (called by agent via Bash)").option("--project-dir <dir>","project directory (overrides env vars)").action(async i=>{const e=(0,f.resolveAgentProjectDir)(i.projectDir);if(h(e,"submit-verdict")){(0,d.writeAndExit)(`verification is disabled in this project; verdict ignored
14
14
  `,0);return}let t;try{t=(0,m.readStdin)()}catch{process.stderr.write(`Error: no verdict JSON provided via stdin.
15
15
  `),process.exit(1)}let o;try{o=JSON.parse(t)}catch{process.stderr.write(`Error: verdict is not valid JSON.
16
16
  `),process.exit(1)}const n=(0,v.resolveAgentSessionId)(o,e);n||(process.stderr.write(`Error: verdict JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
17
- `),process.exit(1));const c=`${e}/.ironbee/sessions/${n}`;(0,l.setLogFile)(`${c}/session.log`);const a=await(0,S.runSubmitVerdict)({sessionId:n,sessionDir:c,verdictFile:`${c}/verdict.json`,actionsFile:`${c}/actions.jsonl`,verdictJson:t,projectDir:e});a.success?(0,d.writeAndExit)(a.message+`
17
+ `),process.exit(1));const c=(0,p.sessionDir)(e,n);(0,l.setLogFile)(`${c}/session.log`);const a=await(0,k.runSubmitVerdict)({sessionId:n,sessionDir:c,verdictFile:`${c}/verdict.json`,actionsFile:`${c}/actions.jsonl`,verdictJson:t,projectDir:e});a.success?(0,d.writeAndExit)(a.message+`
18
18
  `,0):(process.stderr.write(a.message+`
19
- `),process.exit(1))}),r.command("record-fix").description("Record what was fixed after a fail verdict (called by agent via Bash). Stashed locally in state.json; merged into the next pass verdict's fixes. Emits no collector event.").action(async()=>{const i=(0,f.resolveAgentProjectDir)();if(g(i,"record-fix")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
19
+ `),process.exit(1))}),r.command("record-fix").description("Record what was fixed after a fail verdict (called by agent via Bash). Stashed locally in state.json; merged into the next pass verdict's fixes. Emits no collector event.").action(async()=>{const i=(0,f.resolveAgentProjectDir)();if(h(i,"record-fix")){(0,d.writeAndExit)(JSON.stringify({message:"verification is disabled in this project; ignoring"})+`
20
20
  `,0);return}let e;try{e=JSON.parse((0,m.readStdin)())}catch{process.stderr.write(`Error: no JSON provided via stdin.
21
21
  `),process.exit(1)}const t=(0,v.resolveAgentSessionId)(e,i);t||(process.stderr.write(`Error: JSON must include a "session_id" field, or run as a delegated sub-agent (your client resolves the session automatically).
22
22
  `),process.exit(1));const o=e.fixes,n=Array.isArray(o)?o.filter(a=>typeof a=="string"&&a.length>0):[];n.length===0&&(process.stderr.write(`Error: JSON must include a non-empty "fixes" array of strings.
23
- `),process.exit(1));const c=`${i}/.ironbee/sessions/${t}`;(0,l.setLogFile)(`${c}/session.log`),(0,k.addPendingFixes)(c,n),l.logger.debug(`record-fix: session=${t} recorded ${n.length} fix note(s)`),(0,d.writeAndExit)(JSON.stringify({recorded:n.length})+`
23
+ `),process.exit(1));const c=(0,p.sessionDir)(i,t);(0,l.setLogFile)(`${c}/session.log`),(0,j.addPendingFixes)(c,n),l.logger.debug(`record-fix: session=${t} recorded ${n.length} fix note(s)`),(0,d.writeAndExit)(JSON.stringify({recorded:n.length})+`
24
24
  `,0)});0&&(module.exports={hookCommand});
@@ -1,7 +1,7 @@
1
- "use strict";var x=Object.create;var g=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var l=(e,o)=>g(e,"name",{value:o,configurable:!0});var P=(e,o)=>{for(var n in o)g(e,n,{get:o[n],enumerable:!0})},I=(e,o,n,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of j(o))!N.call(e,r)&&r!==n&&g(e,r,{get:()=>o[r],enumerable:!(s=_(o,r))||s.enumerable});return e};var O=(e,o,n)=>(n=e!=null?x(k(e)):{},I(o||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),F=e=>I(g({},"__esModule",{value:!0}),e);var K={};P(K,{importCommand:()=>U,parseFlags:()=>$,promptYesNo:()=>R});module.exports=F(K);var y=require("commander"),w=require("fs"),h=require("path"),M=O(require("readline")),t=require("../lib/output"),S=require("../lib/config"),C=require("../lib/collector"),E=require("../lib/logger"),i=require("../import");const B=4,D=1,z=32,U=new y.Command("import").description("Import historical Claude Code + Codex sessions to the IronBee Collector").option("--since <duration>","import sessions started within the given duration (e.g. 30d, 2w, 6m, 12h)").option("--from <iso-date>","explicit start date (e.g. 2025-04-01)").option("--to <iso-date>","explicit end date (defaults to now)").option("--transcript <path>","import a single transcript .jsonl file (Claude or Codex \u2014 detected from path)").option("--projects <paths>","comma-separated absolute project paths").option("--all-projects","import sessions from every project under ~/.claude/projects/ and ~/.codex/sessions/").option("--dry-run","print the summary and exit without sending events").option("--yes","skip the interactive confirm prompt").option("--force","do not skip sessions with existing .ironbee/sessions/<id>/ directories").option("--concurrency <n>","number of sessions to import in parallel").option("--batch-size <n>","events per collector POST (default: 100). Set to 1 to isolate which event a 400 rejects.").action(async e=>{let o;try{o=$(e)}catch(c){t.log.error(c instanceof Error?c.message:String(c)),process.exit(1)}(0,C.getCollectorTarget)(process.cwd())===null&&(t.log.error("Collector is not configured. ironbee import has no destination to send events to."),t.log.blank(),t.log.dim("To configure, add a collector section to ~/.ironbee/config.json (or your project's .ironbee/config.json):"),t.log.blank(),console.log(t.pc.dim(` {
1
+ "use strict";var _=Object.create;var g=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var l=(e,o)=>g(e,"name",{value:o,configurable:!0});var O=(e,o)=>{for(var n in o)g(e,n,{get:o[n],enumerable:!0})},I=(e,o,n,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of k(o))!P.call(e,r)&&r!==n&&g(e,r,{get:()=>o[r],enumerable:!(s=j(o,r))||s.enumerable});return e};var F=(e,o,n)=>(n=e!=null?_(N(e)):{},I(o||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),M=e=>I(g({},"__esModule",{value:!0}),e);var W={};O(W,{importCommand:()=>L,parseFlags:()=>R,promptYesNo:()=>T});module.exports=M(W);var y=require("commander"),w=require("fs"),h=require("path"),D=F(require("readline")),t=require("../lib/output"),S=require("../lib/config"),C=require("../lib/collector"),E=require("../lib/logger"),$=require("../lib/runtime-paths"),i=require("../import");const B=4,z=1,U=32,L=new y.Command("import").description("Import historical Claude Code + Codex sessions to the IronBee Collector").option("--since <duration>","import sessions started within the given duration (e.g. 30d, 2w, 6m, 12h)").option("--from <iso-date>","explicit start date (e.g. 2025-04-01)").option("--to <iso-date>","explicit end date (defaults to now)").option("--transcript <path>","import a single transcript .jsonl file (Claude or Codex \u2014 detected from path)").option("--projects <paths>","comma-separated absolute project paths").option("--all-projects","import sessions from every project under ~/.claude/projects/ and ~/.codex/sessions/").option("--dry-run","print the summary and exit without sending events").option("--yes","skip the interactive confirm prompt").option("--force","do not skip sessions with existing .ironbee/sessions/<id>/ directories").option("--concurrency <n>","number of sessions to import in parallel").option("--batch-size <n>","events per collector POST (default: 100). Set to 1 to isolate which event a 400 rejects.").action(async e=>{let o;try{o=R(e)}catch(c){t.log.error(c instanceof Error?c.message:String(c)),process.exit(1)}(0,C.getCollectorTarget)(process.cwd())===null&&(t.log.error("Collector is not configured. ironbee import has no destination to send events to."),t.log.blank(),t.log.dim("To configure, add a collector section to ~/.ironbee/config.json (or your project's .ironbee/config.json):"),t.log.blank(),console.log(t.pc.dim(` {
2
2
  "collector": {
3
3
  "url": "https://your-collector.example.com",
4
4
  "oauthToken": "<from \`ironbee login\`>"
5
5
  }
6
- }`)),t.log.blank(),t.log.dim("Required: `url` (non-empty), `enable !== false`, and AT LEAST ONE of `oauthToken` (preferred \u2014 `ironbee login` writes this) or `apiKey` (shared-key path for CI / deployment tooling). The IRONBEE_COLLECTOR=false env override also disables."),process.exit(1));const s=(0,i.findTranscripts)(o.scope),r=(0,i.applyTimeRange)(s,o.timeRange);r.length===0&&(t.log.warn("No transcripts found matching the given scope and time range."),process.exit(0)),t.log.info(`Scanning ${r.length} transcript(s)...`);const d=(0,i.estimateImport)({targets:r,timeRange:o.timeRange,concurrency:o.concurrency,force:o.force});q(d,o.dryRun),o.dryRun&&process.exit(0),d.toImportCount===0&&(t.log.warn("Nothing to import (all sessions already tracked). Use --force to re-import."),process.exit(0)),o.yes||await R("Proceed?")||(t.log.info("Aborted."),process.exit(0));const m=r.filter(c=>!Y(c,o.force)),a=new i.ProgressReporter(m.length);let p=!1;process.on("SIGINT",()=>{t.log.warn(`
7
- Received SIGINT \u2014 finishing in-flight sessions then exiting...`),p=!0});const b=await(0,i.runConcurrentPool)({items:m,concurrency:o.concurrency,shouldCancel:l(()=>p,"shouldCancel"),onStart:l((c,f)=>{a.onSessionStart(c.sessionId,f)},"onStart"),onComplete:l((c,f,T)=>{a.onSessionComplete(c,T)},"onComplete"),process:l(async c=>{try{return await(0,i.importSession)({target:c,force:o.force,batchSize:o.batchSize})}catch(f){return{sessionId:c.sessionId,status:"failed",eventsSent:(0,i.emptyEventCounts)(),reason:f instanceof Error?f.message:String(f)}}},"process")});a.finalSummary(),b.filter(c=>c.status==="failed").length>0&&process.exit(1)});function $(e){if([e.transcript!==void 0?1:0,e.projects!==void 0?1:0,e.allProjects===!0?1:0].reduce((a,p)=>a+p,0)>1)throw new Error("--transcript, --projects, and --all-projects are mutually exclusive");let n;if(e.transcript!==void 0)n={kind:"transcript",path:(0,h.resolve)(e.transcript)};else if(e.projects!==void 0){const a=e.projects.split(",").map(p=>p.trim()).filter(p=>p.length>0).map(p=>(0,h.resolve)(p));if(a.length===0)throw new Error("--projects must list at least one path");n={kind:"projects",paths:a}}else e.allProjects===!0?n={kind:"all-projects"}:n={kind:"current-project"};if(e.since!==void 0&&e.from!==void 0)throw new Error("--since and --from are mutually exclusive");let s=null;const r=Date.now();if(e.since!==void 0){const a=(0,i.parseSinceDuration)(e.since);if(a===null)throw new Error(`Invalid --since value: "${e.since}". Expected forms: 30d, 2w, 6m, 12h.`);s=(0,i.buildTimeRange)({sinceMs:a,nowMs:r})}else if(e.from!==void 0){const a=(0,i.parseIsoDate)(e.from);if(a===null)throw new Error(`Invalid --from value: "${e.from}". Expected ISO date (e.g. 2025-04-01).`);let p;if(e.to!==void 0){const b=(0,i.parseIsoDate)(e.to);if(b===null)throw new Error(`Invalid --to value: "${e.to}". Expected ISO date.`);p=b}s=(0,i.buildTimeRange)({fromMs:a,toMs:p,nowMs:r})}const d=A(e.concurrency),m=L(e.batchSize);return{scope:n,timeRange:s,dryRun:e.dryRun===!0,yes:e.yes===!0,force:e.force===!0,concurrency:d,batchSize:m}}l($,"parseFlags");function L(e){if(e===void 0)return null;const o=parseInt(e,10);if(!Number.isFinite(o)||o<1)throw new Error(`Invalid --batch-size value: "${e}". Must be an integer >= 1.`);return o}l(L,"resolveBatchSize");function A(e){if(e!==void 0){const s=parseInt(e,10);if(!Number.isFinite(s))throw new Error(`Invalid --concurrency value: "${e}". Must be an integer.`);return v(s)}const n=(0,S.loadConfig)(process.cwd()).import?.concurrency;return typeof n=="number"&&Number.isFinite(n)?v(n):B}l(A,"resolveConcurrency");function v(e){return Math.min(z,Math.max(D,Math.floor(e)))}l(v,"clamp");function Y(e,o){if(o)return!1;const n=`${e.projectDir}/.ironbee/sessions/${e.sessionId}`;try{return(0,w.existsSync)(n)}catch(s){return E.logger.debug(`import skip pre-check failed for ${n}: ${s instanceof Error?s.message:s}`),!1}}l(Y,"shouldSkipForRunner");function q(e,o){const n=o?"ironbee import \u2014 dry-run preview":"ironbee import \u2014 preview";t.log.blank(),console.log(t.pc.bold(n)),t.log.blank();const s=e.projects.reduce((r,d)=>r+d.found,0);console.log(`Scope: ${t.pc.bold(String(e.projects.length))} project(s), ${t.pc.bold(String(s))} session(s) found`);for(const r of e.projects)console.log(` ${t.pc.dim(r.projectDir.padEnd(50))} ${String(r.found).padStart(3)} sessions ${t.pc.dim(`${r.skipped} skipped`)}`);if(t.log.blank(),e.timeRange!==null){const r=new Date(e.timeRange.fromMs).toISOString().slice(0,10),d=new Date(e.timeRange.toMs).toISOString().slice(0,10);console.log(`Time range: ${t.pc.bold(r)} .. ${t.pc.bold(d)}`)}else console.log(`Time range: ${t.pc.dim("(no filter \u2014 every session)")}`);t.log.blank(),console.log(`To import: ${t.pc.bold(String(e.toImportCount))} session(s)`),console.log(" Estimated events:"),console.log(` session_start / session_end ${u(e.estimatedEvents.session_start+e.estimatedEvents.session_end)}`),console.log(` activity_start / activity_end ${u(e.estimatedEvents.activity_start+e.estimatedEvents.activity_end)}`),console.log(` tool_call ${u(e.estimatedEvents.tool_call)}`),console.log(` file_change ${u(e.estimatedEvents.file_change)}`),console.log(` api_request ${u(e.estimatedEvents.api_request)}`),console.log(` session_analytics ${u(e.estimatedEvents.session_analytics)}`),console.log(` session_turn_analytics ${u(e.estimatedEvents.session_turn_analytics)}`),console.log(` session_turn_step_analytics ${u(e.estimatedEvents.session_turn_step_analytics)}`),t.log.blank(),console.log(` Estimated total cost surfaced: ${t.pc.bold(`$${e.estimatedCostUsd.toFixed(2)}`)}`),console.log(` Estimated wire bytes: ${t.pc.dim(G(e.estimatedWireBytes))}`),console.log(` Collector endpoint: ${e.collectorUrl!==null?t.pc.bold(e.collectorUrl):t.pc.red("(not configured)")}`),console.log(` Concurrency: ${t.pc.bold(String(e.concurrency))} sessions in flight`),t.log.blank()}l(q,"renderSummary");function u(e){return e.toLocaleString("en-US")}l(u,"formatNum");function G(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}l(G,"formatBytes");async function R(e,o){const n=o?.createInterface??M.createInterface;return new Promise(s=>{const r=n({input:process.stdin,output:process.stdout});r.question(`${e} [Y/n] `,d=>{r.close();const m=d.trim().toLowerCase();if(m==="n"||m==="no"){s(!1);return}s(!0)})})}l(R,"promptYesNo");0&&(module.exports={importCommand,parseFlags,promptYesNo});
6
+ }`)),t.log.blank(),t.log.dim("Required: `url` (non-empty), `enable !== false`, and AT LEAST ONE of `oauthToken` (preferred \u2014 `ironbee login` writes this) or `apiKey` (shared-key path for CI / deployment tooling). The IRONBEE_COLLECTOR=false env override also disables."),process.exit(1));const s=(0,i.findTranscripts)(o.scope),r=(0,i.applyTimeRange)(s,o.timeRange);r.length===0&&(t.log.warn("No transcripts found matching the given scope and time range."),process.exit(0)),t.log.info(`Scanning ${r.length} transcript(s)...`);const d=(0,i.estimateImport)({targets:r,timeRange:o.timeRange,concurrency:o.concurrency,force:o.force});G(d,o.dryRun),o.dryRun&&process.exit(0),d.toImportCount===0&&(t.log.warn("Nothing to import (all sessions already tracked). Use --force to re-import."),process.exit(0)),o.yes||await T("Proceed?")||(t.log.info("Aborted."),process.exit(0));const m=r.filter(c=>!q(c,o.force)),a=new i.ProgressReporter(m.length);let p=!1;process.on("SIGINT",()=>{t.log.warn(`
7
+ Received SIGINT \u2014 finishing in-flight sessions then exiting...`),p=!0});const b=await(0,i.runConcurrentPool)({items:m,concurrency:o.concurrency,shouldCancel:l(()=>p,"shouldCancel"),onStart:l((c,f)=>{a.onSessionStart(c.sessionId,f)},"onStart"),onComplete:l((c,f,x)=>{a.onSessionComplete(c,x)},"onComplete"),process:l(async c=>{try{return await(0,i.importSession)({target:c,force:o.force,batchSize:o.batchSize})}catch(f){return{sessionId:c.sessionId,status:"failed",eventsSent:(0,i.emptyEventCounts)(),reason:f instanceof Error?f.message:String(f)}}},"process")});a.finalSummary(),b.filter(c=>c.status==="failed").length>0&&process.exit(1)});function R(e){if([e.transcript!==void 0?1:0,e.projects!==void 0?1:0,e.allProjects===!0?1:0].reduce((a,p)=>a+p,0)>1)throw new Error("--transcript, --projects, and --all-projects are mutually exclusive");let n;if(e.transcript!==void 0)n={kind:"transcript",path:(0,h.resolve)(e.transcript)};else if(e.projects!==void 0){const a=e.projects.split(",").map(p=>p.trim()).filter(p=>p.length>0).map(p=>(0,h.resolve)(p));if(a.length===0)throw new Error("--projects must list at least one path");n={kind:"projects",paths:a}}else e.allProjects===!0?n={kind:"all-projects"}:n={kind:"current-project"};if(e.since!==void 0&&e.from!==void 0)throw new Error("--since and --from are mutually exclusive");let s=null;const r=Date.now();if(e.since!==void 0){const a=(0,i.parseSinceDuration)(e.since);if(a===null)throw new Error(`Invalid --since value: "${e.since}". Expected forms: 30d, 2w, 6m, 12h.`);s=(0,i.buildTimeRange)({sinceMs:a,nowMs:r})}else if(e.from!==void 0){const a=(0,i.parseIsoDate)(e.from);if(a===null)throw new Error(`Invalid --from value: "${e.from}". Expected ISO date (e.g. 2025-04-01).`);let p;if(e.to!==void 0){const b=(0,i.parseIsoDate)(e.to);if(b===null)throw new Error(`Invalid --to value: "${e.to}". Expected ISO date.`);p=b}s=(0,i.buildTimeRange)({fromMs:a,toMs:p,nowMs:r})}const d=Y(e.concurrency),m=A(e.batchSize);return{scope:n,timeRange:s,dryRun:e.dryRun===!0,yes:e.yes===!0,force:e.force===!0,concurrency:d,batchSize:m}}l(R,"parseFlags");function A(e){if(e===void 0)return null;const o=parseInt(e,10);if(!Number.isFinite(o)||o<1)throw new Error(`Invalid --batch-size value: "${e}". Must be an integer >= 1.`);return o}l(A,"resolveBatchSize");function Y(e){if(e!==void 0){const s=parseInt(e,10);if(!Number.isFinite(s))throw new Error(`Invalid --concurrency value: "${e}". Must be an integer.`);return v(s)}const n=(0,S.loadConfig)(process.cwd()).import?.concurrency;return typeof n=="number"&&Number.isFinite(n)?v(n):B}l(Y,"resolveConcurrency");function v(e){return Math.min(U,Math.max(z,Math.floor(e)))}l(v,"clamp");function q(e,o){if(o)return!1;const n=(0,$.sessionDir)(e.projectDir,e.sessionId);try{return(0,w.existsSync)(n)}catch(s){return E.logger.debug(`import skip pre-check failed for ${n}: ${s instanceof Error?s.message:s}`),!1}}l(q,"shouldSkipForRunner");function G(e,o){const n=o?"ironbee import \u2014 dry-run preview":"ironbee import \u2014 preview";t.log.blank(),console.log(t.pc.bold(n)),t.log.blank();const s=e.projects.reduce((r,d)=>r+d.found,0);console.log(`Scope: ${t.pc.bold(String(e.projects.length))} project(s), ${t.pc.bold(String(s))} session(s) found`);for(const r of e.projects)console.log(` ${t.pc.dim(r.projectDir.padEnd(50))} ${String(r.found).padStart(3)} sessions ${t.pc.dim(`${r.skipped} skipped`)}`);if(t.log.blank(),e.timeRange!==null){const r=new Date(e.timeRange.fromMs).toISOString().slice(0,10),d=new Date(e.timeRange.toMs).toISOString().slice(0,10);console.log(`Time range: ${t.pc.bold(r)} .. ${t.pc.bold(d)}`)}else console.log(`Time range: ${t.pc.dim("(no filter \u2014 every session)")}`);t.log.blank(),console.log(`To import: ${t.pc.bold(String(e.toImportCount))} session(s)`),console.log(" Estimated events:"),console.log(` session_start / session_end ${u(e.estimatedEvents.session_start+e.estimatedEvents.session_end)}`),console.log(` activity_start / activity_end ${u(e.estimatedEvents.activity_start+e.estimatedEvents.activity_end)}`),console.log(` tool_call ${u(e.estimatedEvents.tool_call)}`),console.log(` file_change ${u(e.estimatedEvents.file_change)}`),console.log(` api_request ${u(e.estimatedEvents.api_request)}`),console.log(` session_analytics ${u(e.estimatedEvents.session_analytics)}`),console.log(` session_turn_analytics ${u(e.estimatedEvents.session_turn_analytics)}`),console.log(` session_turn_step_analytics ${u(e.estimatedEvents.session_turn_step_analytics)}`),t.log.blank(),console.log(` Estimated total cost surfaced: ${t.pc.bold(`$${e.estimatedCostUsd.toFixed(2)}`)}`),console.log(` Estimated wire bytes: ${t.pc.dim(K(e.estimatedWireBytes))}`),console.log(` Collector endpoint: ${e.collectorUrl!==null?t.pc.bold(e.collectorUrl):t.pc.red("(not configured)")}`),console.log(` Concurrency: ${t.pc.bold(String(e.concurrency))} sessions in flight`),t.log.blank()}l(G,"renderSummary");function u(e){return e.toLocaleString("en-US")}l(u,"formatNum");function K(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}l(K,"formatBytes");async function T(e,o){const n=o?.createInterface??D.createInterface;return new Promise(s=>{const r=n({input:process.stdin,output:process.stdout});r.question(`${e} [Y/n] `,d=>{r.close();const m=d.trim().toLowerCase();if(m==="n"||m==="no"){s(!1);return}s(!0)})})}l(T,"promptYesNo");0&&(module.exports={importCommand,parseFlags,promptYesNo});
@@ -1 +1 @@
1
- "use strict";var r=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(o,s)=>{for(var n in s)r(o,n,{get:s[n],enumerable:!0})},d=(o,s,n,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let e of p(s))!c.call(o,e)&&e!==n&&r(o,e,{get:()=>s[e],enumerable:!(t=m(s,e))||t.enumerable});return o};var f=o=>d(r({},"__esModule",{value:!0}),o);var h={};l(h,{processJobFileCommand:()=>b});module.exports=f(h);var a=require("commander"),i=require("../queue");const b=new a.Command("process-job-file").description("Internal worker \u2014 process one snapshot file").argument("<path>","absolute path to a snapshot file (jobs-<UUID>.jsonl)").action(async o=>{await(0,i.processFile)(o)});0&&(module.exports={processJobFileCommand});
1
+ "use strict";var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var m=(e,o)=>{for(var t in o)n(e,t,{get:o[t],enumerable:!0})},d=(e,o,t,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of c(o))!l.call(e,s)&&s!==t&&n(e,s,{get:()=>o[s],enumerable:!(r=p(o,s))||r.enumerable});return e};var h=e=>d(n({},"__esModule",{value:!0}),e);var b={};m(b,{processJobFileCommand:()=>j});module.exports=h(b);var i=require("commander"),a=require("../queue");const j=new i.Command("process-job-file").description("Internal worker \u2014 process one snapshot file").argument("<path>","absolute path to a snapshot file (jobs-<UUID>.jsonl)").option("--project <dir>","project dir the snapshot belongs to (required for the external runtime layout \u2014 the path alone can't recover it)").option("--session <id>","session id the snapshot belongs to").action(async(e,o)=>{await(0,a.processFile)(e,{projectDir:o.project,sessionId:o.session})});0&&(module.exports={processJobFileCommand});
@@ -1,37 +1,37 @@
1
- "use strict";var b=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var f=(e,t)=>b(e,"name",{value:t,configurable:!0});var B=(e,t)=>{for(var r in t)b(e,r,{get:t[r],enumerable:!0})},C=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of _(t))!q.call(e,c)&&c!==r&&b(e,c,{get:()=>t[c],enumerable:!(i=x(t,c))||i.enumerable});return e};var M=e=>C(b({},"__esModule",{value:!0}),e);var N={};B(N,{queueCommand:()=>v});module.exports=M(N);var E=require("commander"),a=require("fs"),h=require("path"),R=require("../lib/config"),o=require("../queue");function m(e){const t=(0,o.sessionsRoot)(e);if(!(0,a.existsSync)(t))return[];try{return(0,a.readdirSync)(t).filter(r=>{try{return(0,a.statSync)((0,h.join)(t,r)).isDirectory()}catch{return!1}})}catch{return[]}}f(m,"listSessionIds");function L(e){try{const t=(0,a.readFileSync)(e,"utf-8");return t.length===0?0:t.split(`
2
- `).filter(r=>r.length>0).length}catch{return 0}}f(L,"countLines");function k(e,t){const r=(0,o.queueDir)(e,t);if(!(0,a.existsSync)(r))return[];try{return(0,a.readdirSync)(r).filter(i=>o.SNAPSHOT_FILENAME_REGEX.test(i)).map(i=>(0,h.join)(r,i))}catch{return[]}}f(k,"listSnapshotsFor");function A(e,t){const r=(0,o.liveQueueFile)(e,t),i=(0,o.deadLetterFile)(e,t),c=k(e,t);let n=0;for(const s of c)try{n+=(0,a.statSync)(s).size}catch{}return{sessionId:t,liveLines:L(r),liveBytes:$(r),snapshotCount:c.length,snapshotBytes:n,deadLetterLines:L(i),deadLetterBytes:$(i)}}f(A,"collectStatus");function $(e){try{return(0,a.statSync)(e).size}catch{return 0}}f($,"fileSize");function T(e){const t=e.match(/^(\d+)\s*(d|h|m|s)$/);if(!t)throw new Error(`invalid duration "${e}" \u2014 use e.g. 14d, 2h, 30m, 60s`);return parseInt(t[1],10)*{s:1e3,m:6e4,h:36e5,d:864e5}[t[2]]}f(T,"parseDuration");const v=new E.Command("queue").description("Inspect and manage the file-backed job queue");v.command("status").description("Show queue counts per session (aggregated across the project)").option("--session <id>","limit to one session").option("--project-dir <dir>","project directory (overrides env/cwd)").action(e=>{const t=(0,o.resolveProjectDir)(e.projectDir),r=e.session?[e.session]:m(t);if(r.length===0){process.stdout.write(`No sessions found.
3
- `);return}let i=0,c=0,n=0;for(const s of r){const d=A(t,s);if(i+=d.liveLines,c+=d.snapshotCount,n+=d.deadLetterLines,process.stdout.write(`session=${s}
1
+ "use strict";var b=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var f=(e,t)=>b(e,"name",{value:t,configurable:!0});var C=(e,t)=>{for(var r in t)b(e,r,{get:t[r],enumerable:!0})},M=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of q(t))!B.call(e,c)&&c!==r&&b(e,c,{get:()=>t[c],enumerable:!(i=_(t,c))||i.enumerable});return e};var A=e=>M(b({},"__esModule",{value:!0}),e);var P={};C(P,{queueCommand:()=>w});module.exports=A(P);var E=require("commander"),R=require("../lib/runtime-paths"),a=require("fs"),y=require("path"),I=require("../lib/config"),o=require("../queue");function m(e){const t=(0,o.sessionsRoot)(e);if(!(0,a.existsSync)(t))return[];try{return(0,a.readdirSync)(t).filter(r=>{try{return(0,a.statSync)((0,y.join)(t,r)).isDirectory()}catch{return!1}})}catch{return[]}}f(m,"listSessionIds");function L(e){try{const t=(0,a.readFileSync)(e,"utf-8");return t.length===0?0:t.split(`
2
+ `).filter(r=>r.length>0).length}catch{return 0}}f(L,"countLines");function k(e,t){const r=(0,o.queueDir)(e,t);if(!(0,a.existsSync)(r))return[];try{return(0,a.readdirSync)(r).filter(i=>o.SNAPSHOT_FILENAME_REGEX.test(i)).map(i=>(0,y.join)(r,i))}catch{return[]}}f(k,"listSnapshotsFor");function T(e,t){const r=(0,o.liveQueueFile)(e,t),i=(0,o.deadLetterFile)(e,t),c=k(e,t);let n=0;for(const s of c)try{n+=(0,a.statSync)(s).size}catch{}return{sessionId:t,liveLines:L(r),liveBytes:$(r),snapshotCount:c.length,snapshotBytes:n,deadLetterLines:L(i),deadLetterBytes:$(i)}}f(T,"collectStatus");function $(e){try{return(0,a.statSync)(e).size}catch{return 0}}f($,"fileSize");function N(e){const t=e.match(/^(\d+)\s*(d|h|m|s)$/);if(!t)throw new Error(`invalid duration "${e}" \u2014 use e.g. 14d, 2h, 30m, 60s`);return parseInt(t[1],10)*{s:1e3,m:6e4,h:36e5,d:864e5}[t[2]]}f(N,"parseDuration");const w=new E.Command("queue").description("Inspect and manage the file-backed job queue");w.command("status").description("Show queue counts per session (aggregated across the project)").option("--session <id>","limit to one session").option("--project-dir <dir>","project directory (overrides env/cwd)").action(e=>{const t=(0,o.resolveProjectDir)(e.projectDir),r=e.session?[e.session]:m(t);if(r.length===0){process.stdout.write(`No sessions found.
3
+ `);return}let i=0,c=0,n=0;for(const s of r){const d=T(t,s);if(i+=d.liveLines,c+=d.snapshotCount,n+=d.deadLetterLines,process.stdout.write(`session=${s}
4
4
  `),process.stdout.write(` live: ${d.liveLines} lines (${d.liveBytes} B)
5
5
  `),process.stdout.write(` snapshots: ${d.snapshotCount} files (${d.snapshotBytes} B)
6
6
  `),process.stdout.write(` dead-letter: ${d.deadLetterLines} lines (${d.deadLetterBytes} B)
7
7
  `),d.deadLetterLines>0){const g=(0,o.readDeadLetterEntries)(t,s).slice(-3);for(const l of g)process.stdout.write(` [${l.received_at}] ${l.category}
8
8
  `)}}process.stdout.write(`
9
9
  Totals: live=${i} snapshots=${c} dead=${n}
10
- `)}),v.command("drain").description("Synchronously drain pending snapshots (per-session or all in the project)").option("--session <id>","drain one session").option("--project-dir <dir>","project directory (overrides env/cwd)").option("--skip-recent-ms <ms>","skip snapshots modified within the last N ms (race-avoidance for detached drainers spawned alongside active workers; default 0 = drain everything)").action(async e=>{const t=(0,o.resolveProjectDir)(e.projectDir),r=e.session?[e.session]:m(t),i=e.skipRecentMs?Number.parseInt(e.skipRecentMs,10):0;if(r.length===0){process.stdout.write(`Nothing to drain.
10
+ `)}),w.command("drain").description("Synchronously drain pending snapshots (per-session or all in the project)").option("--session <id>","drain one session").option("--project-dir <dir>","project directory (overrides env/cwd)").option("--skip-recent-ms <ms>","skip snapshots modified within the last N ms (race-avoidance for detached drainers spawned alongside active workers; default 0 = drain everything)").action(async e=>{const t=(0,o.resolveProjectDir)(e.projectDir),r=e.session?[e.session]:m(t),i=e.skipRecentMs?Number.parseInt(e.skipRecentMs,10):0;if(r.length===0){process.stdout.write(`Nothing to drain.
11
11
  `);return}let c=0;for(const n of r){const s=await(0,o.drain)(t,n,{skipRecentMs:i});process.stdout.write(`session=${n} processed=${s.snapshotsProcessed} remaining=${s.snapshotsRemaining} cleaned=${s.cleanedQueueDir}
12
12
  `),c+=s.snapshotsRemaining}c>0&&(process.stdout.write(`
13
13
  ${c} snapshot(s) remain \u2014 investigate worker.log.
14
- `),process.exit(1))}),v.command("purge").description("Destructive cleanup of queue state").option("--snapshots","delete all snapshot files in all sessions without processing").option("--sessions <spec>","remove old queue/ subdirs; use `older-than=<duration>`, e.g. `older-than=14d`").option("--project-dir <dir>","project directory (overrides env/cwd)").action(e=>{const t=(0,o.resolveProjectDir)(e.projectDir);if(!e.snapshots&&!e.sessions&&(process.stderr.write(`Error: pass --snapshots or --sessions older-than=<dur>.
14
+ `),process.exit(1))}),w.command("purge").description("Destructive cleanup of queue state").option("--snapshots","delete all snapshot files in all sessions without processing").option("--sessions <spec>","remove old queue/ subdirs; use `older-than=<duration>`, e.g. `older-than=14d`").option("--project-dir <dir>","project directory (overrides env/cwd)").action(e=>{const t=(0,o.resolveProjectDir)(e.projectDir);if(!e.snapshots&&!e.sessions&&(process.stderr.write(`Error: pass --snapshots or --sessions older-than=<dur>.
15
15
  `),process.exit(1)),e.snapshots){let r=0;for(const i of m(t))for(const c of k(t,i))try{(0,a.unlinkSync)(c),r++}catch{}process.stdout.write(`Removed ${r} snapshot file(s).
16
- `)}if(e.sessions){const r=e.sessions.match(/^older-than=(.+)$/);r||(process.stderr.write("Error: --sessions must be of the form `older-than=<duration>` (e.g. older-than=14d).\n"),process.exit(1));let i;try{i=Date.now()-T(r[1])}catch(n){process.stderr.write(`Error: ${n instanceof Error?n.message:String(n)}
17
- `),process.exit(1);return}let c=0;for(const n of m(t)){const s=(0,o.queueDir)(t,n);if(!(0,a.existsSync)(s))continue;let d;try{d=(0,a.statSync)(s)}catch{continue}if(d.mtimeMs>i)continue;let p=!1;try{const g=(0,a.readdirSync)(s);for(const l of g)if(l==="jobs.jsonl"&&$((0,h.join)(s,l))>0&&(p=!0),o.SNAPSHOT_FILENAME_REGEX.test(l)&&(p=!0),(l==="dead-letter.jsonl"||o.DEAD_LETTER_ROTATED_REGEX.test(l))&&$((0,h.join)(s,l))>0&&(p=!0),p)break}catch{continue}if(p){process.stdout.write(`skip session=${n} \u2014 has undelivered work or triage records
16
+ `)}if(e.sessions){const r=e.sessions.match(/^older-than=(.+)$/);r||(process.stderr.write("Error: --sessions must be of the form `older-than=<duration>` (e.g. older-than=14d).\n"),process.exit(1));let i;try{i=Date.now()-N(r[1])}catch(n){process.stderr.write(`Error: ${n instanceof Error?n.message:String(n)}
17
+ `),process.exit(1);return}let c=0;for(const n of m(t)){const s=(0,o.queueDir)(t,n);if(!(0,a.existsSync)(s))continue;let d;try{d=(0,a.statSync)(s)}catch{continue}if(d.mtimeMs>i)continue;let p=!1;try{const g=(0,a.readdirSync)(s);for(const l of g)if(l==="jobs.jsonl"&&$((0,y.join)(s,l))>0&&(p=!0),o.SNAPSHOT_FILENAME_REGEX.test(l)&&(p=!0),(l==="dead-letter.jsonl"||o.DEAD_LETTER_ROTATED_REGEX.test(l))&&$((0,y.join)(s,l))>0&&(p=!0),p)break}catch{continue}if(p){process.stdout.write(`skip session=${n} \u2014 has undelivered work or triage records
18
18
  `);continue}try{(0,a.rmSync)(s,{recursive:!0,force:!0}),c++,process.stdout.write(`removed queue/ for session=${n}
19
19
  `)}catch{}}process.stdout.write(`Removed ${c} queue/ subdir(s).
20
- `)}});const w=new E.Command("dead-letter").description("Inspect and act on dead-letter entries");w.command("list").description("List dead-letter entries").option("--session <id>","scope to one session").option("--limit <n>","limit output count",e=>parseInt(e,10),50).option("--project-dir <dir>","project directory (overrides env/cwd)").action(e=>{const t=(0,o.resolveProjectDir)(e.projectDir),r=e.session?[e.session]:m(t),i=[];for(const s of r)for(const d of(0,o.readDeadLetterEntries)(t,s))i.push({sessionId:s,entry:d});i.sort((s,d)=>s.entry.received_at.localeCompare(d.entry.received_at));const c=e.limit??50,n=i.slice(-c);for(const s of n){const d="original"in s.entry?s.entry.original.id:"(parse-error)";process.stdout.write(`[${s.entry.received_at}] session=${s.sessionId} id=${s.entry.id} original=${d} category=${s.entry.category}
20
+ `)}});const v=new E.Command("dead-letter").description("Inspect and act on dead-letter entries");v.command("list").description("List dead-letter entries").option("--session <id>","scope to one session").option("--limit <n>","limit output count",e=>parseInt(e,10),50).option("--project-dir <dir>","project directory (overrides env/cwd)").action(e=>{const t=(0,o.resolveProjectDir)(e.projectDir),r=e.session?[e.session]:m(t),i=[];for(const s of r)for(const d of(0,o.readDeadLetterEntries)(t,s))i.push({sessionId:s,entry:d});i.sort((s,d)=>s.entry.received_at.localeCompare(d.entry.received_at));const c=e.limit??50,n=i.slice(-c);for(const s of n){const d="original"in s.entry?s.entry.original.id:"(parse-error)";process.stdout.write(`[${s.entry.received_at}] session=${s.sessionId} id=${s.entry.id} original=${d} category=${s.entry.category}
21
21
  `)}process.stdout.write(`
22
22
  Total matching: ${i.length} (showing last ${n.length})
23
- `)}),w.command("stats").description("Histogram of dead-letter categories").option("--session <id>","scope to one session").option("--project-dir <dir>","project directory (overrides env/cwd)").action(e=>{const t=(0,o.resolveProjectDir)(e.projectDir),r=e.session?[e.session]:m(t),i=new Map;for(const n of r)for(const s of(0,o.readDeadLetterEntries)(t,n)){const d=i.get(s.category);i.set(s.category,(d??0)+1)}const c=[...i.entries()].sort((n,s)=>s[1]-n[1]);if(c.length===0){process.stdout.write(`No dead-letter entries.
23
+ `)}),v.command("stats").description("Histogram of dead-letter categories").option("--session <id>","scope to one session").option("--project-dir <dir>","project directory (overrides env/cwd)").action(e=>{const t=(0,o.resolveProjectDir)(e.projectDir),r=e.session?[e.session]:m(t),i=new Map;for(const n of r)for(const s of(0,o.readDeadLetterEntries)(t,n)){const d=i.get(s.category);i.set(s.category,(d??0)+1)}const c=[...i.entries()].sort((n,s)=>s[1]-n[1]);if(c.length===0){process.stdout.write(`No dead-letter entries.
24
24
  `);return}for(const[n,s]of c)process.stdout.write(`${String(s).padStart(6," ")} ${n}
25
- `)}),w.command("retry <job_id>").description("Re-queue a dead-letter entry by its original job id. Atomic read-modify-write.").option("--session <id>","force re-queue into a specific session (default: the owning session)").option("--project-dir <dir>","project directory (overrides env/cwd)").action((e,t)=>{const r=(0,o.resolveProjectDir)(t.projectDir);if(!(0,R.isJobQueueEnabled)(r)){process.stderr.write(`Error: jobQueue is disabled. Add a "jobQueue": {} section to config.json (or remove "enable": false) to retry.
26
- `),process.exit(1);return}const i=m(r);let c=null,n=null;for(const u of i){for(const y of(0,o.readDeadLetterEntries)(r,u))if("original"in y&&y.original.id===e){c=u,n=y;break}if(n)break}if(!n||!c){process.stderr.write(`Error: no dead-letter entry found with original id "${e}".
27
- `),process.exit(1);return}const s=t.session??c,d=(0,o.queueDir)(r,s),p=(0,h.join)(r,".ironbee","sessions",s);if(!(0,a.existsSync)(p)){process.stderr.write(`Error: target session "${s}" does not exist.
25
+ `)}),v.command("retry <job_id>").description("Re-queue a dead-letter entry by its original job id. Atomic read-modify-write.").option("--session <id>","force re-queue into a specific session (default: the owning session)").option("--project-dir <dir>","project directory (overrides env/cwd)").action((e,t)=>{const r=(0,o.resolveProjectDir)(t.projectDir);if(!(0,I.isJobQueueEnabled)(r)){process.stderr.write(`Error: jobQueue is disabled. Add a "jobQueue": {} section to config.json (or remove "enable": false) to retry.
26
+ `),process.exit(1);return}const i=m(r);let c=null,n=null;for(const u of i){for(const h of(0,o.readDeadLetterEntries)(r,u))if("original"in h&&h.original.id===e){c=u,n=h;break}if(n)break}if(!n||!c){process.stderr.write(`Error: no dead-letter entry found with original id "${e}".
27
+ `),process.exit(1);return}const s=t.session??c,d=(0,o.queueDir)(r,s),p=(0,R.sessionDir)(r,s);if(!(0,a.existsSync)(p)){process.stderr.write(`Error: target session "${s}" does not exist.
28
28
  `),process.exit(1);return}(0,a.mkdirSync)(d,{recursive:!0,mode:448});const g=(0,o.deadLetterFile)(r,c);let l;try{l=(0,a.readFileSync)(g,"utf-8")}catch(u){process.stderr.write(`Error reading dead-letter file: ${u instanceof Error?u.message:String(u)}
29
- `),process.exit(1);return}const I=l.split(`
30
- `),j=[];let S=!1;for(const u of I)if(u.length!==0){if(!S)try{const y=JSON.parse(u);if("original"in y&&y.original.id===e){S=!0;continue}}catch{}j.push(u)}const D=`${g}.tmp-${process.pid}-${Date.now()}`;try{(0,a.writeFileSync)(D,j.length>0?j.join(`
29
+ `),process.exit(1);return}const x=l.split(`
30
+ `),j=[];let S=!1;for(const u of x)if(u.length!==0){if(!S)try{const h=JSON.parse(u);if("original"in h&&h.original.id===e){S=!0;continue}}catch{}j.push(u)}const D=`${g}.tmp-${process.pid}-${Date.now()}`;try{(0,a.writeFileSync)(D,j.length>0?j.join(`
31
31
  `)+`
32
32
  `:"",{mode:384}),(0,a.renameSync)(D,g)}catch(u){try{(0,a.unlinkSync)(D)}catch{}process.stderr.write(`Error rewriting dead-letter file: ${u instanceof Error?u.message:String(u)}
33
33
  `),process.exit(1);return}try{const u=(0,o.submit)(r,s,n.original.type,n.original.data,{id:n.original.id});process.stdout.write(`Re-queued job id=${u} type=${n.original.type} session=${s}
34
34
  `)}catch(u){process.stderr.write(`Error re-submitting: ${u instanceof Error?u.message:String(u)}
35
- `),process.exit(1)}}),w.command("clear").description("Empty the live dead-letter file; pass --all to also remove rotated archives").option("--session <id>","scope to one session").option("--all","also unlink rotated dead-letter-<UUID>.jsonl archives").option("--project-dir <dir>","project directory (overrides env/cwd)").action(e=>{const t=(0,o.resolveProjectDir)(e.projectDir),r=e.session?[e.session]:m(t);let i=0,c=0;for(const n of r){const s=(0,o.deadLetterFile)(t,n);if((0,a.existsSync)(s))try{(0,a.writeFileSync)(s,"",{mode:384}),i++}catch{}if(e.all){const d=(0,o.queueDir)(t,n);let p;try{p=(0,a.readdirSync)(d)}catch{continue}for(const g of p)if(o.DEAD_LETTER_ROTATED_REGEX.test(g))try{(0,a.unlinkSync)((0,h.join)(d,g)),c++}catch{}}}e.all?process.stdout.write(`Cleared dead-letter for ${i} session(s); removed ${c} rotated archive(s).
35
+ `),process.exit(1)}}),v.command("clear").description("Empty the live dead-letter file; pass --all to also remove rotated archives").option("--session <id>","scope to one session").option("--all","also unlink rotated dead-letter-<UUID>.jsonl archives").option("--project-dir <dir>","project directory (overrides env/cwd)").action(e=>{const t=(0,o.resolveProjectDir)(e.projectDir),r=e.session?[e.session]:m(t);let i=0,c=0;for(const n of r){const s=(0,o.deadLetterFile)(t,n);if((0,a.existsSync)(s))try{(0,a.writeFileSync)(s,"",{mode:384}),i++}catch{}if(e.all){const d=(0,o.queueDir)(t,n);let p;try{p=(0,a.readdirSync)(d)}catch{continue}for(const g of p)if(o.DEAD_LETTER_ROTATED_REGEX.test(g))try{(0,a.unlinkSync)((0,y.join)(d,g)),c++}catch{}}}e.all?process.stdout.write(`Cleared dead-letter for ${i} session(s); removed ${c} rotated archive(s).
36
36
  `):process.stdout.write(`Cleared dead-letter for ${i} session(s). Use --all to also remove rotated archives.
37
- `)}),v.addCommand(w);0&&(module.exports={queueCommand});
37
+ `)}),w.addCommand(v);0&&(module.exports={queueCommand});
@@ -1 +1 @@
1
- "use strict";var d=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var m=(o,n)=>d(o,"name",{value:n,configurable:!0});var k=(o,n)=>{for(var e in n)d(o,e,{get:n[e],enumerable:!0})},S=(o,n,e,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of v(n))!h.call(o,t)&&t!==e&&d(o,t,{get:()=>n[t],enumerable:!(l=b(n,t))||l.enumerable});return o};var w=o=>S(d({},"__esModule",{value:!0}),o);var C={};k(C,{statusCommand:()=>_});module.exports=w(C);var y=require("commander"),i=require("fs"),c=require("path"),s=require("../lib/output");function j(o){const n=(0,c.join)(o,"actions.jsonl");if(!(0,i.existsSync)(n))return!1;let e;try{e=(0,i.readFileSync)(n,"utf-8")}catch{return!1}return e.includes('"type":"verification_requested"')||e.includes('"type": "verification_requested"')?!1:e.includes('"type":"session_start"')||e.includes('"type": "session_start"')}m(j,"isMonitoringOnlySession");const _=new y.Command("status").description("Show verification status for all active sessions").argument("[project-dir]","target project directory",".").action(o=>{const n=(0,c.resolve)(o),e=(0,c.join)(n,".ironbee","sessions");if(!(0,i.existsSync)(e)){s.log.warn("No .ironbee/sessions/ directory found. Run `ironbee install` first.");return}const l=(0,i.readdirSync)(e).filter(t=>(0,i.statSync)((0,c.join)(e,t)).isDirectory());if(l.length===0){s.log.dim(" .ironbee/sessions/ (no active sessions)");return}s.log.info(`Sessions in ${s.pc.dim(e)}`),s.log.blank();for(const t of l){const g=(0,c.join)(e,t,"verdict.json"),u=(0,c.join)(e,t,"retries"),a=(0,i.existsSync)(u)&&parseInt((0,i.readFileSync)(u,"utf-8"),10)||0;if(!(0,i.existsSync)(g)){console.log(` ${s.pc.bold(s.pc.cyan(t))}`),j((0,c.join)(e,t))?console.log(` ${s.pc.dim("verdict")} : ${s.pc.dim("none (monitoring-only session)")}`):console.log(` ${s.pc.dim("verdict")} : ${s.pc.yellow("missing")}`),a>0&&console.log(` ${s.pc.dim("retries")} : ${s.pc.yellow(`${a}/3`)}`),s.log.blank();continue}let r;try{r=JSON.parse((0,i.readFileSync)(g,"utf-8"))}catch{console.log(` ${s.pc.bold(s.pc.cyan(t))}`),console.log(` ${s.pc.dim("verdict")} : ${s.pc.red("invalid JSON")}`),s.log.blank();continue}const f=Array.isArray(r.checks)?r.checks.length:0,$=r.status==="pass"?s.pc.green:r.status==="not_applicable"?s.pc.dim:s.pc.red;if(console.log(` ${s.pc.bold(s.pc.cyan(t))}`),console.log(` ${s.pc.dim("status")} : ${$(r.status)}`),console.log(` ${s.pc.dim("checks")} : ${f>0?s.pc.green(String(f)):s.pc.yellow("0")}`),a>0&&console.log(` ${s.pc.dim("retries")} : ${s.pc.yellow(`${a}/3`)}`),r.status==="fail"&&r.issues?.length){console.log(` ${s.pc.dim("issues")} :`);for(const p of r.issues)console.log(` ${s.pc.red("\u2022")} ${p}`)}s.log.blank()}});0&&(module.exports={statusCommand});
1
+ "use strict";var d=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var m=(n,t)=>d(n,"name",{value:t,configurable:!0});var S=(n,t)=>{for(var e in t)d(n,e,{get:t[e],enumerable:!0})},w=(n,t,e,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of h(t))!k.call(n,o)&&o!==e&&d(n,o,{get:()=>t[o],enumerable:!(l=v(t,o))||l.enumerable});return n};var j=n=>w(d({},"__esModule",{value:!0}),n);var D={};S(D,{statusCommand:()=>C});module.exports=j(D);var y=require("commander"),i=require("fs"),c=require("path"),s=require("../lib/output"),$=require("../lib/runtime-paths");function _(n){const t=(0,c.join)(n,"actions.jsonl");if(!(0,i.existsSync)(t))return!1;let e;try{e=(0,i.readFileSync)(t,"utf-8")}catch{return!1}return e.includes('"type":"verification_requested"')||e.includes('"type": "verification_requested"')?!1:e.includes('"type":"session_start"')||e.includes('"type": "session_start"')}m(_,"isMonitoringOnlySession");const C=new y.Command("status").description("Show verification status for all active sessions").argument("[project-dir]","target project directory",".").action(n=>{const t=(0,c.resolve)(n),e=(0,$.sessionsRoot)(t);if(!(0,i.existsSync)(e)){s.log.warn("No .ironbee/sessions/ directory found. Run `ironbee install` first.");return}const l=(0,i.readdirSync)(e).filter(o=>(0,i.statSync)((0,c.join)(e,o)).isDirectory());if(l.length===0){s.log.dim(" .ironbee/sessions/ (no active sessions)");return}s.log.info(`Sessions in ${s.pc.dim(e)}`),s.log.blank();for(const o of l){const g=(0,c.join)(e,o,"verdict.json"),u=(0,c.join)(e,o,"retries"),a=(0,i.existsSync)(u)&&parseInt((0,i.readFileSync)(u,"utf-8"),10)||0;if(!(0,i.existsSync)(g)){console.log(` ${s.pc.bold(s.pc.cyan(o))}`),_((0,c.join)(e,o))?console.log(` ${s.pc.dim("verdict")} : ${s.pc.dim("none (monitoring-only session)")}`):console.log(` ${s.pc.dim("verdict")} : ${s.pc.yellow("missing")}`),a>0&&console.log(` ${s.pc.dim("retries")} : ${s.pc.yellow(`${a}/3`)}`),s.log.blank();continue}let r;try{r=JSON.parse((0,i.readFileSync)(g,"utf-8"))}catch{console.log(` ${s.pc.bold(s.pc.cyan(o))}`),console.log(` ${s.pc.dim("verdict")} : ${s.pc.red("invalid JSON")}`),s.log.blank();continue}const f=Array.isArray(r.checks)?r.checks.length:0,p=r.status==="pass"?s.pc.green:r.status==="not_applicable"?s.pc.dim:s.pc.red;if(console.log(` ${s.pc.bold(s.pc.cyan(o))}`),console.log(` ${s.pc.dim("status")} : ${p(r.status)}`),console.log(` ${s.pc.dim("checks")} : ${f>0?s.pc.green(String(f)):s.pc.yellow("0")}`),a>0&&console.log(` ${s.pc.dim("retries")} : ${s.pc.yellow(`${a}/3`)}`),r.status==="fail"&&r.issues?.length){console.log(` ${s.pc.dim("issues")} :`);for(const b of r.issues)console.log(` ${s.pc.red("\u2022")} ${b}`)}s.log.blank()}});0&&(module.exports={statusCommand});
@@ -1 +1 @@
1
- "use strict";var h=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var d=(t,n)=>h(t,"name",{value:n,configurable:!0});var k=(t,n)=>{for(var r in n)h(t,r,{get:n[r],enumerable:!0})},x=(t,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of A(n))!N.call(t,i)&&i!==r&&h(t,i,{get:()=>n[i],enumerable:!(o=S(n,i))||o.enumerable});return t};var U=t=>x(h({},"__esModule",{value:!0}),t);var T={};k(T,{runUninstallAll:()=>P,uninstallCommand:()=>R});module.exports=U(T);var I=require("commander"),f=require("fs"),p=require("path"),l=require("../clients/registry"),e=require("../lib/output"),y=require("../lib/prompt"),u=require("../lib/projects-registry"),$=require("../lib/telemetry");function C(){return l.REGISTERED_CLIENTS.map(n=>n.name).join(", ")}d(C,"clientNames");const b=10;function v(t,n){for(const i of n)i.uninstall(t);const r=n.map(i=>i.name);(0,u.removeProject)(t);const o=(0,p.join)(t,".ironbee");return(0,f.existsSync)(o)&&(0,f.rmSync)(o,{recursive:!0,force:!0}),r}d(v,"uninstallOne");function w(t){if(t===void 0||t==="all")return l.REGISTERED_CLIENTS;const n=(0,l.findClient)(t);if(n===void 0)throw new Error(`Unknown client: '${t}'. Available: ${C()}.`);return[n]}d(w,"resolveClientsForUninstall");async function P(t){const n=(0,u.listProjects)();if(n.length===0)return e.log.info("No registered projects. Nothing to uninstall."),{failures:0,total:0};const r=[],o=[];for(const s of n)((0,l.isProjectActive)(s)?r:o).push(s);if(r.length===0){if(e.log.info("No active registered projects to uninstall from."),o.length>0){for(const s of o)(0,u.removeProject)(s.path);e.log.step(`Pruned ${e.pc.bold(String(o.length))} stale registry entr${o.length===1?"y":"ies"}.`)}return{failures:0,total:0}}e.log.warn(`About to uninstall ironbee from ${e.pc.bold(String(r.length))} project(s):`);const i=r.slice(0,b);for(const s of i)console.log(` ${e.pc.dim("\xB7")} ${e.pc.dim(s.path)}`);r.length>b&&console.log(` ${e.pc.dim("\u2026and")} ${e.pc.bold(String(r.length-b))} ${e.pc.dim("more")}`),o.length>0&&e.log.dim(`(${o.length} stale registry entr${o.length===1?"y":"ies"} will also be pruned)`);let m;if(t.yes===!0?m=!0:(0,y.isInteractive)()?m=await(0,y.promptYesNo)("Continue?",!1):(e.log.error("Refusing to batch-uninstall without --yes in a non-interactive context."),process.exit(1)),!m)return e.log.info("Aborted."),{failures:0,total:0};e.log.blank();let c=0;const a=[];for(const s of r)try{e.log.label("project",e.pc.dim(s.path));const g=w(t.client),E=v(s.path,g);a.push(...E)}catch(g){c++,e.log.error(` ${s.path}: ${g instanceof Error?g.message:String(g)}`)}for(const s of o)(0,u.removeProject)(s.path);e.log.blank(),c===0?e.log.success(`Uninstalled from ${r.length} project(s).${o.length>0?` Pruned ${o.length} stale entr${o.length===1?"y":"ies"}.`:""} ${e.pc.dim("Restart your AI coding client(s) to apply.")}`):e.log.warn(`Completed with ${c} failure(s) \u2014 see above.`);const j=Array.from(new Set(a));return j.length>0&&await(0,$.trackUninstall)(j),{failures:c,total:r.length}}d(P,"runUninstallAll");const R=new I.Command("uninstall").description("Remove IronBee hooks and guidance files from a project. Use --all to uninstall across every registered project (destructive \u2014 confirms before acting).").argument("[project-dir]","target project directory",".").option("--client <name>",`client to uninstall for (${C()}), or "all"`).option("--all","Uninstall across every project in the user-home inventory (~/.ironbee/projects.json). The [project-dir] argument is ignored when --all is set. Prompts before acting unless --yes is also passed.").option("-y, --yes","Skip the confirmation prompt for --all (required in non-interactive contexts).").action(async(t,n)=>{if(n.all===!0){(await P({client:n.client,yes:n.yes})).failures>0&&process.exit(1);return}const r=(0,p.resolve)(t);(0,f.existsSync)(r)||(e.log.error(`Directory not found: ${r}`),process.exit(1));let o;if(n.client!==void 0)try{o=w(n.client)}catch(a){e.log.error(a instanceof Error?a.message:String(a)),process.exit(1)}else if(o=(0,l.detectClients)(r),o.length===0){e.log.info("No client detected. Nothing to uninstall.");return}const i=(0,p.join)(r,".ironbee"),m=(0,f.existsSync)(i),c=v(r,o);m&&e.log.step(`Removed ${e.pc.dim(i)}`),e.log.blank(),e.log.success(`IronBee removed. ${e.pc.dim("Restart your AI coding client to apply changes.")}`),await(0,$.trackUninstall)(c,r)});0&&(module.exports={runUninstallAll,uninstallCommand});
1
+ "use strict";var h=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var u=(n,t)=>h(n,"name",{value:t,configurable:!0});var k=(n,t)=>{for(var r in t)h(n,r,{get:t[r],enumerable:!0})},U=(n,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of A(t))!N.call(n,i)&&i!==r&&h(n,i,{get:()=>t[i],enumerable:!(o=S(t,i))||o.enumerable});return n};var T=n=>U(h({},"__esModule",{value:!0}),n);var _={};k(_,{runUninstallAll:()=>x,uninstallCommand:()=>D});module.exports=T(_);var E=require("commander"),a=require("fs"),p=require("path"),l=require("../clients/registry"),e=require("../lib/output"),y=require("../lib/prompt"),m=require("../lib/projects-registry"),P=require("../lib/runtime-paths"),v=require("../lib/telemetry");function C(){return l.REGISTERED_CLIENTS.map(t=>t.name).join(", ")}u(C,"clientNames");const b=10;function $(n){const t=(0,P.externalRuntimeRoot)(n);(0,a.existsSync)(t)&&(0,a.rmSync)(t,{recursive:!0,force:!0})}u($,"pruneExternalRuntimeRoot");function w(n,t){for(const i of t)i.uninstall(n);const r=t.map(i=>i.name);(0,m.removeProject)(n);const o=(0,p.join)(n,".ironbee");return(0,a.existsSync)(o)&&(0,a.rmSync)(o,{recursive:!0,force:!0}),$(n),r}u(w,"uninstallOne");function I(n){if(n===void 0||n==="all")return l.REGISTERED_CLIENTS;const t=(0,l.findClient)(n);if(t===void 0)throw new Error(`Unknown client: '${n}'. Available: ${C()}.`);return[t]}u(I,"resolveClientsForUninstall");async function x(n){const t=(0,m.listProjects)();if(t.length===0)return e.log.info("No registered projects. Nothing to uninstall."),{failures:0,total:0};const r=[],o=[];for(const s of t)((0,l.isProjectActive)(s)?r:o).push(s);if(r.length===0){if(e.log.info("No active registered projects to uninstall from."),o.length>0){for(const s of o)$(s.path),(0,m.removeProject)(s.path);e.log.step(`Pruned ${e.pc.bold(String(o.length))} stale registry entr${o.length===1?"y":"ies"}.`)}return{failures:0,total:0}}e.log.warn(`About to uninstall ironbee from ${e.pc.bold(String(r.length))} project(s):`);const i=r.slice(0,b);for(const s of i)console.log(` ${e.pc.dim("\xB7")} ${e.pc.dim(s.path)}`);r.length>b&&console.log(` ${e.pc.dim("\u2026and")} ${e.pc.bold(String(r.length-b))} ${e.pc.dim("more")}`),o.length>0&&e.log.dim(`(${o.length} stale registry entr${o.length===1?"y":"ies"} will also be pruned)`);let g;if(n.yes===!0?g=!0:(0,y.isInteractive)()?g=await(0,y.promptYesNo)("Continue?",!1):(e.log.error("Refusing to batch-uninstall without --yes in a non-interactive context."),process.exit(1)),!g)return e.log.info("Aborted."),{failures:0,total:0};e.log.blank();let f=0;const c=[];for(const s of r)try{e.log.label("project",e.pc.dim(s.path));const d=I(n.client),R=w(s.path,d);c.push(...R)}catch(d){f++,e.log.error(` ${s.path}: ${d instanceof Error?d.message:String(d)}`)}for(const s of o)$(s.path),(0,m.removeProject)(s.path);e.log.blank(),f===0?e.log.success(`Uninstalled from ${r.length} project(s).${o.length>0?` Pruned ${o.length} stale entr${o.length===1?"y":"ies"}.`:""} ${e.pc.dim("Restart your AI coding client(s) to apply.")}`):e.log.warn(`Completed with ${f} failure(s) \u2014 see above.`);const j=Array.from(new Set(c));return j.length>0&&await(0,v.trackUninstall)(j),{failures:f,total:r.length}}u(x,"runUninstallAll");const D=new E.Command("uninstall").description("Remove IronBee hooks and guidance files from a project. Use --all to uninstall across every registered project (destructive \u2014 confirms before acting).").argument("[project-dir]","target project directory",".").option("--client <name>",`client to uninstall for (${C()}), or "all"`).option("--all","Uninstall across every project in the user-home inventory (~/.ironbee/projects.json). The [project-dir] argument is ignored when --all is set. Prompts before acting unless --yes is also passed.").option("-y, --yes","Skip the confirmation prompt for --all (required in non-interactive contexts).").action(async(n,t)=>{if(t.all===!0){(await x({client:t.client,yes:t.yes})).failures>0&&process.exit(1);return}const r=(0,p.resolve)(n);(0,a.existsSync)(r)||(e.log.error(`Directory not found: ${r}`),process.exit(1));let o;if(t.client!==void 0)try{o=I(t.client)}catch(c){e.log.error(c instanceof Error?c.message:String(c)),process.exit(1)}else if(o=(0,l.detectClients)(r),o.length===0){e.log.info("No client detected. Nothing to uninstall.");return}const i=(0,p.join)(r,".ironbee"),g=(0,a.existsSync)(i),f=w(r,o);g&&e.log.step(`Removed ${e.pc.dim(i)}`),e.log.blank(),e.log.success(`IronBee removed. ${e.pc.dim("Restart your AI coding client to apply changes.")}`),await(0,v.trackUninstall)(f,r)});0&&(module.exports={runUninstallAll,uninstallCommand});
@@ -1,4 +1,4 @@
1
- "use strict";var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var c=(s,i)=>p(s,"name",{value:i,configurable:!0});var w=(s,i)=>{for(var n in i)p(s,n,{get:i[n],enumerable:!0})},A=(s,i,n,o)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of v(i))!_.call(s,t)&&t!==n&&p(s,t,{get:()=>i[t],enumerable:!(o=k(i,t))||o.enumerable});return s};var S=s=>A(p({},"__esModule",{value:!0}),s);var C={};w(C,{verifyCommand:()=>x});module.exports=S(C);var h=require("commander"),r=require("fs"),l=require("path"),e=require("../lib/output");function a(s){console.log(` ${e.pc.green("\u2713")} ${s}`)}c(a,"pass");function f(s,i){console.log(` ${e.pc.red("\u2717")} ${s}: ${e.pc.dim(i)}`)}c(f,"fail");function N(s){let i=!0;const n=s.status==="not_applicable",o=Array.isArray(s.not_applicable_cycles)?s.not_applicable_cycles:[];if(["pass","fail","not_applicable"].includes(s.status)?a(`status: ${s.status}`):(f("status",`unknown value "${s.status}" \u2014 must be "pass", "fail", or "not_applicable"`),i=!1),!n){const t=s.checks;Array.isArray(t)&&t.length>0?a(`checks (${t.length} item(s))`):(f("checks","checks is missing or empty"),i=!1)}return(n||o.length>0)&&(Array.isArray(s.reason)&&s.reason.length>0?a(`reason (${s.reason.length} item(s))`):(f("reason","required for N/A (global status or not_applicable_cycles)"),i=!1)),o.length>0&&a(`not_applicable_cycles: ${o.join(", ")}`),s.status==="fail"&&(!Array.isArray(s.issues)||s.issues.length===0?(f("issues",'required when status is "fail"'),i=!1):a(`errors (${s.issues.length} item(s))`)),i}c(N,"checkVerdict");function j(s){const i=(0,l.join)(s,"actions.jsonl");if(!(0,r.existsSync)(i))return!1;let n;try{n=(0,r.readFileSync)(i,"utf-8")}catch{return!1}return n.includes('"type":"verification_requested"')||n.includes('"type": "verification_requested"')?!1:n.includes('"type":"session_start"')||n.includes('"type": "session_start"')}c(j,"isMonitoringOnlySession");function D(s,i){if(i)return i;const n=(0,r.readdirSync)(s).filter(o=>(0,r.statSync)((0,l.join)(s,o)).isDirectory());return n.length===1?n[0]:null}c(D,"resolveSession");const x=new h.Command("verify").description("Validate a session verdict file (dry-run of the Stop hook checks)").argument("[session-id]","session ID to verify (auto-detected if only one active session)").option("-p, --project-dir <dir>","target project directory",".").action((s,i)=>{const n=(0,l.resolve)(i.projectDir),o=(0,l.join)(n,".ironbee","sessions");(0,r.existsSync)(o)||(e.log.error("No .ironbee/sessions/ directory found. Run `ironbee install` first."),process.exit(1));const t=D(o,s);if(!t){const g=(0,r.readdirSync)(o).filter($=>(0,r.statSync)((0,l.join)(o,$)).isDirectory());if(g.length===0){e.log.info("No sessions found. No verification has been written yet.");return}e.log.error(`Multiple sessions found. Specify a session ID:
1
+ "use strict";var p=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var c=(s,i)=>p(s,"name",{value:i,configurable:!0});var A=(s,i)=>{for(var n in i)p(s,n,{get:i[n],enumerable:!0})},S=(s,i,n,o)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of _(i))!w.call(s,t)&&t!==n&&p(s,t,{get:()=>i[t],enumerable:!(o=v(i,t))||o.enumerable});return s};var N=s=>S(p({},"__esModule",{value:!0}),s);var O={};A(O,{verifyCommand:()=>C});module.exports=N(O);var h=require("commander"),r=require("fs"),l=require("path"),e=require("../lib/output"),$=require("../lib/runtime-paths");function a(s){console.log(` ${e.pc.green("\u2713")} ${s}`)}c(a,"pass");function f(s,i){console.log(` ${e.pc.red("\u2717")} ${s}: ${e.pc.dim(i)}`)}c(f,"fail");function j(s){let i=!0;const n=s.status==="not_applicable",o=Array.isArray(s.not_applicable_cycles)?s.not_applicable_cycles:[];if(["pass","fail","not_applicable"].includes(s.status)?a(`status: ${s.status}`):(f("status",`unknown value "${s.status}" \u2014 must be "pass", "fail", or "not_applicable"`),i=!1),!n){const t=s.checks;Array.isArray(t)&&t.length>0?a(`checks (${t.length} item(s))`):(f("checks","checks is missing or empty"),i=!1)}return(n||o.length>0)&&(Array.isArray(s.reason)&&s.reason.length>0?a(`reason (${s.reason.length} item(s))`):(f("reason","required for N/A (global status or not_applicable_cycles)"),i=!1)),o.length>0&&a(`not_applicable_cycles: ${o.join(", ")}`),s.status==="fail"&&(!Array.isArray(s.issues)||s.issues.length===0?(f("issues",'required when status is "fail"'),i=!1):a(`errors (${s.issues.length} item(s))`)),i}c(j,"checkVerdict");function D(s){const i=(0,l.join)(s,"actions.jsonl");if(!(0,r.existsSync)(i))return!1;let n;try{n=(0,r.readFileSync)(i,"utf-8")}catch{return!1}return n.includes('"type":"verification_requested"')||n.includes('"type": "verification_requested"')?!1:n.includes('"type":"session_start"')||n.includes('"type": "session_start"')}c(D,"isMonitoringOnlySession");function x(s,i){if(i)return i;const n=(0,r.readdirSync)(s).filter(o=>(0,r.statSync)((0,l.join)(s,o)).isDirectory());return n.length===1?n[0]:null}c(x,"resolveSession");const C=new h.Command("verify").description("Validate a session verdict file (dry-run of the Stop hook checks)").argument("[session-id]","session ID to verify (auto-detected if only one active session)").option("-p, --project-dir <dir>","target project directory",".").action((s,i)=>{const n=(0,l.resolve)(i.projectDir),o=(0,$.sessionsRoot)(n);(0,r.existsSync)(o)||(e.log.error("No .ironbee/sessions/ directory found. Run `ironbee install` first."),process.exit(1));const t=x(o,s);if(!t){const g=(0,r.readdirSync)(o).filter(k=>(0,r.statSync)((0,l.join)(o,k)).isDirectory());if(g.length===0){e.log.info("No sessions found. No verification has been written yet.");return}e.log.error(`Multiple sessions found. Specify a session ID:
2
2
  ${g.join(`
3
- `)}`),process.exit(1)}const d=(0,l.join)(o,t,"verdict.json"),m=(0,l.join)(o,t,"retries");if(e.log.info(`Verifying session: ${e.pc.bold(e.pc.cyan(t))}`),e.log.blank(),!(0,r.existsSync)(d)){const g=(0,l.join)(o,t);if(j(g)){e.log.info(`${e.pc.dim("\xB7")} No verdict found \u2014 this session ran in ${e.pc.bold("monitoring-only mode")} (verification.enable: false).`),e.log.dim(" Nothing to validate. Toggle on with `ironbee verification enable` if you want enforcement.");return}f("verdict file",`not found at ${e.pc.dim(d)}`),e.log.blank(),console.log(` ${e.pc.bold(e.pc.red("\u2717 FAIL"))} ${e.pc.dim("\u2014 no verdict written yet.")}`),process.exit(1)}a(`verdict file exists: ${e.pc.dim(d)}`);let u;try{u=JSON.parse((0,r.readFileSync)(d,"utf-8"))}catch{f("verdict file","invalid JSON"),e.log.blank(),console.log(` ${e.pc.bold(e.pc.red("\u2717 FAIL"))} ${e.pc.dim("\u2014 verdict is not valid JSON.")}`),process.exit(1)}a("verdict is valid JSON"),e.log.blank();const y=N(u),b=(0,r.existsSync)(m)&&parseInt((0,r.readFileSync)(m,"utf-8"),10)||0;b>0&&console.log(`
3
+ `)}`),process.exit(1)}const d=(0,l.join)(o,t,"verdict.json"),m=(0,l.join)(o,t,"retries");if(e.log.info(`Verifying session: ${e.pc.bold(e.pc.cyan(t))}`),e.log.blank(),!(0,r.existsSync)(d)){const g=(0,l.join)(o,t);if(D(g)){e.log.info(`${e.pc.dim("\xB7")} No verdict found \u2014 this session ran in ${e.pc.bold("monitoring-only mode")} (verification.enable: false).`),e.log.dim(" Nothing to validate. Toggle on with `ironbee verification enable` if you want enforcement.");return}f("verdict file",`not found at ${e.pc.dim(d)}`),e.log.blank(),console.log(` ${e.pc.bold(e.pc.red("\u2717 FAIL"))} ${e.pc.dim("\u2014 no verdict written yet.")}`),process.exit(1)}a(`verdict file exists: ${e.pc.dim(d)}`);let u;try{u=JSON.parse((0,r.readFileSync)(d,"utf-8"))}catch{f("verdict file","invalid JSON"),e.log.blank(),console.log(` ${e.pc.bold(e.pc.red("\u2717 FAIL"))} ${e.pc.dim("\u2014 verdict is not valid JSON.")}`),process.exit(1)}a("verdict is valid JSON"),e.log.blank();const y=j(u),b=(0,r.existsSync)(m)&&parseInt((0,r.readFileSync)(m,"utf-8"),10)||0;b>0&&console.log(`
4
4
  ${e.pc.dim("retries:")} ${e.pc.yellow(`${b}/3`)}`),e.log.blank(),y&&u.status==="pass"?console.log(` ${e.pc.bold(e.pc.green("\u2713 PASS"))} ${e.pc.dim("\u2014 hook would allow completion.")}`):y&&u.status==="not_applicable"?console.log(` ${e.pc.bold(e.pc.green("\u2713 N/A"))} ${e.pc.dim("\u2014 no runtime surface; hook would allow (unless strict mode / fail-like prior verdict).")}`):y&&u.status==="fail"?console.log(` ${e.pc.bold(e.pc.red("\u2717 BLOCKED"))} ${e.pc.dim("\u2014 verdict status is fail. Fix issues and re-verify.")}`):console.log(` ${e.pc.bold(e.pc.red("\u2717 BLOCKED"))} ${e.pc.dim("\u2014 verdict has schema errors.")}`)});0&&(module.exports={verifyCommand});
@@ -1,7 +1,7 @@
1
- "use strict";var v=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var c=(t,e)=>v(t,"name",{value:e,configurable:!0});var j=(t,e)=>{for(var i in e)v(t,i,{get:e[i],enumerable:!0})},P=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!N.call(t,r)&&r!==i&&v(t,r,{get:()=>e[r],enumerable:!(n=F(e,r))||n.enumerable});return t};var L=t=>P(v({},"__esModule",{value:!0}),t);var te={};j(te,{ActivityAwareEvent:()=>d.ActivityAwareEvent,Event:()=>d.Event,EventType:()=>d.EventType,EventTypeValue:()=>d.EventTypeValue,FixAwareEvent:()=>d.FixAwareEvent,VerificationAwareEvent:()=>d.VerificationAwareEvent,appendAction:()=>I,baseFields:()=>T,deterministicSessionEndId:()=>D,findDurationSinceLastAction:()=>G,findLastActionTimestamp:()=>W,getFileChangesSinceLastFailVerdict:()=>X,getFileChangesSinceLastVerification:()=>H,getToolCallsSinceLastFileChange:()=>K,getToolCallsSinceLastVerification:()=>z,hasFileChangesSinceLastVerification:()=>Q,hasToolCallsSinceLastVerdict:()=>B,hasVerifierEverEngaged:()=>Z,readActionsSinceLastMarker:()=>$,resolveProjectName:()=>V,summarizeFixFileChanges:()=>ee});module.exports=L(te);var l=require("fs"),y=require("crypto"),a=require("path"),f=require("../../lib/logger"),b=require("../../lib/collector"),w=require("../../lib/config"),k=require("../../queue/submit"),C=require("../../queue/types"),S=require("../../queue/register-handlers"),d=require("../../lib/event");function V(t){let e=t,i;for(;;){const n=(0,a.join)(e,".git");if((0,l.existsSync)(n)){const s=M(n);if(s==="directory"){const o=E(n);return o||(0,a.basename)(e)}if(s==="linked-pointer"){const o=_(n),u=o!==void 0?E(o):void 0;return u||(0,a.basename)(e)}s==="worktree-pointer"&&i===void 0&&(i=U(n))}const r=(0,a.dirname)(e);if(r===e)break;e=r}return i??(0,a.basename)(t)}c(V,"resolveProjectName");function M(t){try{const e=(0,l.statSync)(t);if(e.isDirectory())return"directory";if(!e.isFile())return"other";const i=_(t);return i===void 0?"other":(0,l.existsSync)((0,a.join)(i,"commondir"))?"worktree-pointer":"linked-pointer"}catch(e){return f.logger.debug(`resolveProjectName: stat failed for ${t}: ${e instanceof Error?e.message:e}`),"other"}}c(M,"classifyGitEntry");function _(t){try{const i=(0,l.readFileSync)(t,"utf-8").trim().match(/^gitdir:\s*(.+)$/m);if(!i)return;const n=i[1].trim();return(0,a.isAbsolute)(n)?n:(0,a.resolve)((0,a.dirname)(t),n)}catch(e){f.logger.debug(`resolveProjectName: pointer at ${t} unreadable: ${e instanceof Error?e.message:e}`);return}}c(_,"readGitdirPointer");function E(t){try{const e=(0,a.join)(t,"config");if(!(0,l.existsSync)(e))return;const i=q((0,l.readFileSync)(e,"utf-8"));return i?O(i):void 0}catch(e){f.logger.debug(`resolveProjectName: failed to read git config at ${t}: ${e instanceof Error?e.message:e}`);return}}c(E,"repoNameFromGitConfig");function U(t){const e=_(t);if(e===void 0)return;const i=(0,a.join)(e,"commondir");let n;try{if((0,l.existsSync)(i)){const o=(0,l.readFileSync)(i,"utf-8").trim();n=(0,a.isAbsolute)(o)?o:(0,a.resolve)(e,o)}else n=e}catch(o){f.logger.debug(`resolveProjectName: commondir at ${i} unreadable: ${o instanceof Error?o.message:o}`);return}const r=E(n);if(r)return r;const s=(0,a.basename)(n)===".git"?(0,a.basename)((0,a.dirname)(n)):(0,a.basename)(n);return s.length>0?s:void 0}c(U,"repoNameFromWorktreePointer");function q(t){const e=t.split(/\r?\n/);let i=null,n=null,r,s;for(const o of e){const u=o.trim();if(u.length===0||u.startsWith("#")||u.startsWith(";"))continue;const p=u.match(/^\[([^\s\]]+)(?:\s+"([^"]*)")?\]$/);if(p){i=p[1].toLowerCase(),n=p[2]??null;continue}if(i!=="remote"||n===null)continue;const m=u.match(/^url\s*=\s*(.+?)\s*$/i);if(!m)continue;const g=m[1];n==="origin"&&(r=g),s===void 0&&(s=g)}return r??s}c(q,"readFirstRemoteUrl");function O(t){let e=t.trim();if(e.length===0)return;const i=e.match(/^[^/@]+@[^/:]+:(.+)$/);if(i?e=i[1]:e=e.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]*\//i,""),e=e.replace(/[?#].*$/,"").replace(/\/+$/,""),e.length===0)return;const r=(e.split("/").pop()??"").replace(/\.git$/i,"");return r.length>0?r:void 0}c(O,"repoNameFromRemoteUrl");function T(t){const e=(0,a.basename)((0,a.dirname)(t)),i=(0,a.dirname)((0,a.dirname)((0,a.dirname)((0,a.dirname)(t)))),n=(0,a.dirname)(t),{getUserEmail:r,getUsageType:s,getUsagePlan:o}=require("./session-state"),u=r(n),p=s(n),m=o(n),g={id:(0,y.randomUUID)(),session_id:e,project_name:V(i)};return u&&(g.user_email=u),p&&(g.usage_type=p),m&&(g.usage_plan=m),g}c(T,"baseFields");function D(t){const e=(0,y.createHash)("sha256").update("session_end:"+t).digest("hex");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20,32)}`}c(D,"deterministicSessionEndId");async function I(t,e){const i=T(t);e.id||(e.id=i.id),e.session_id||(e.session_id=i.session_id),e.project_name||(e.project_name=i.project_name);try{(0,l.mkdirSync)((0,a.dirname)(t),{recursive:!0}),(0,l.appendFileSync)(t,JSON.stringify(e)+`
2
- `)}catch(n){f.logger.debug(`failed to append action to ${t}: ${n}`)}if(e.type!=="tool_call"){const n=(0,a.basename)((0,a.dirname)(t)),r=(0,a.dirname)((0,a.dirname)((0,a.dirname)((0,a.dirname)(t))));try{await(0,b.sendToCollector)(e,n,r)}catch(s){s instanceof b.RetriableCollectorError?J(r,n,e,s):f.logger.debug(`failed to send action to collector: ${s}`)}}}c(I,"appendAction");function J(t,e,i,n){if(!(0,w.isJobQueueEnabled)(t)){f.logger.debug(`collector fallback: jobQueue disabled, dropping type=${i.type} id=${i.id} (cause: ${n.message})`);return}try{(0,k.submit)(t,e,S.SEND_EVENT_TYPE,i),f.logger.debug(`collector fallback: enqueued type=${i.type} id=${i.id} as send_event (cause: ${n.message})`)}catch(r){if(r instanceof C.JobTooLargeError){f.logger.debug(`collector fallback: event too large for queue (${r.sizeBytes} bytes), dropping type=${i.type} id=${i.id}`);return}f.logger.debug(`collector fallback: queue submit failed for type=${i.type} id=${i.id}: ${r}`)}}c(J,"enqueueCollectorFallback");function G(t,e,i){if((0,l.existsSync)(t))try{const r=(0,l.readFileSync)(t,"utf-8").trim().split(`
3
- `).filter(s=>s.length>0);for(let s=r.length-1;s>=0;s--)try{const o=JSON.parse(r[s]);if(o.type===e&&typeof o.timestamp=="number")return i-o.timestamp}catch{}}catch(n){f.logger.debug(`failed to find duration for ${e}: ${n}`)}}c(G,"findDurationSinceLastAction");function $(t,e){return h(t,i=>i.type===e)}c($,"readActionsSinceLastMarker");function W(t){if((0,l.existsSync)(t))try{const i=(0,l.readFileSync)(t,"utf-8").trim().split(`
4
- `).filter(n=>n.length>0);for(let n=i.length-1;n>=0;n--)try{const r=JSON.parse(i[n]);if(typeof r.timestamp=="number")return r.timestamp}catch{}}catch(e){f.logger.debug(`failed to read last action timestamp from ${t}: ${e}`)}}c(W,"findLastActionTimestamp");function h(t,e){if(!(0,l.existsSync)(t))return[];try{const n=(0,l.readFileSync)(t,"utf-8").trim().split(`
5
- `).filter(o=>o.length>0);let r=-1;const s=[];for(let o=0;o<n.length;o++)try{const u=JSON.parse(n[o]);s.push(u),e(u)&&(r=o)}catch{}return s.slice(r+1)}catch(i){return f.logger.debug(`failed to read actions from ${t}: ${i}`),[]}}c(h,"readActionsSinceMatch");function A(t){return t.type!=="verification_requested"?!1:t.action==="allow"}c(A,"isAllowVerificationRequested");function x(t){if(t.type!=="tool_call")return!1;const e=t.verification_id;return typeof e=="string"&&e.length>0}c(x,"isVerificationScopedToolCall");function z(t){return h(t,A).filter(x)}c(z,"getToolCallsSinceLastVerification");function K(t){return $(t,"file_change").filter(x)}c(K,"getToolCallsSinceLastFileChange");function B(t){return $(t,"verdict_write").some(x)}c(B,"hasToolCallsSinceLastVerdict");function Q(t){return h(t,A).some(i=>i.type==="file_change")}c(Q,"hasFileChangesSinceLastVerification");function H(t){return h(t,A).filter(i=>i.type==="file_change")}c(H,"getFileChangesSinceLastVerification");function Y(t){return t.type!=="verdict_write"?!1:t.verdict?.status==="fail"}c(Y,"isFailVerdictWrite");function X(t){if(!(0,l.existsSync)(t))return[];try{const n=(0,l.readFileSync)(t,"utf-8").trim().split(`
6
- `).filter(o=>o.length>0).map(o=>{try{return JSON.parse(o)}catch{return null}});let r=-1;for(let o=0;o<n.length;o++){const u=n[o];u!==null&&Y(u)&&(r=o)}if(r<0)return[];const s=[];for(let o=r+1;o<n.length;o++){const u=n[o];u!==null&&u.type==="file_change"&&s.push(u)}return s}catch(e){return f.logger.debug(`failed to read file changes since last fail verdict: ${e}`),[]}}c(X,"getFileChangesSinceLastFailVerdict");function Z(t){if(!(0,l.existsSync)(t))return!1;try{const i=(0,l.readFileSync)(t,"utf-8").trim().split(`
7
- `).filter(n=>n.length>0);for(const n of i){let r;try{r=JSON.parse(n)}catch{continue}if(r.type==="verification_start")return!0;if(r.type==="tool_call"){const s=r;if(s.tool_type==="mcp"&&typeof s.mcp_server=="string"&&s.mcp_server.endsWith("-devtools"))return!0}}return!1}catch(e){return f.logger.debug(`failed to scan verifier engagement in ${t}: ${e}`),!1}}c(Z,"hasVerifierEverEngaged");function ee(t){if(t.length===0)return[];const e=new Map,i=[];for(const n of t){const r=n.file_path;let s=e.get(r);s||(s={op:n.operation,added:0,removed:0},e.set(r,s),i.push(r)),s.op=s.op==="create"||n.operation==="create"?"create":n.operation,s.added+=typeof n.lines_added=="number"?n.lines_added:0,s.removed+=typeof n.lines_removed=="number"?n.lines_removed:0}return i.map(n=>{const r=e.get(n);return`${r.op} ${n} (+${r.added}/-${r.removed})`})}c(ee,"summarizeFixFileChanges");0&&(module.exports={ActivityAwareEvent,Event,EventType,EventTypeValue,FixAwareEvent,VerificationAwareEvent,appendAction,baseFields,deterministicSessionEndId,findDurationSinceLastAction,findLastActionTimestamp,getFileChangesSinceLastFailVerdict,getFileChangesSinceLastVerification,getToolCallsSinceLastFileChange,getToolCallsSinceLastVerification,hasFileChangesSinceLastVerification,hasToolCallsSinceLastVerdict,hasVerifierEverEngaged,readActionsSinceLastMarker,resolveProjectName,summarizeFixFileChanges});
1
+ "use strict";var h=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var c=(t,e)=>h(t,"name",{value:e,configurable:!0});var N=(t,e)=>{for(var i in e)h(t,i,{get:e[i],enumerable:!0})},D=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of P(e))!R.call(t,r)&&r!==i&&h(t,r,{get:()=>e[r],enumerable:!(n=j(e,r))||n.enumerable});return t};var q=t=>D(h({},"__esModule",{value:!0}),t);var ne={};N(ne,{ActivityAwareEvent:()=>d.ActivityAwareEvent,Event:()=>d.Event,EventType:()=>d.EventType,EventTypeValue:()=>d.EventTypeValue,FixAwareEvent:()=>d.FixAwareEvent,VerificationAwareEvent:()=>d.VerificationAwareEvent,appendAction:()=>J,baseFields:()=>T,deterministicSessionEndId:()=>I,findDurationSinceLastAction:()=>W,findLastActionTimestamp:()=>z,getFileChangesSinceLastFailVerdict:()=>Z,getFileChangesSinceLastVerification:()=>Y,getToolCallsSinceLastFileChange:()=>B,getToolCallsSinceLastVerification:()=>K,hasFileChangesSinceLastVerification:()=>H,hasToolCallsSinceLastVerdict:()=>Q,hasVerifierEverEngaged:()=>ee,readActionsSinceLastMarker:()=>w,resolveProjectName:()=>F,summarizeFixFileChanges:()=>te});module.exports=q(ne);var l=require("fs"),b=require("crypto"),a=require("path"),f=require("../../lib/logger"),_=require("../../lib/collector"),k=require("../../lib/config"),C=require("../../queue/submit"),S=require("../../queue/types"),V=require("../../queue/register-handlers"),d=require("../../lib/event");function F(t){let e=t,i;for(;;){const n=(0,a.join)(e,".git");if((0,l.existsSync)(n)){const s=L(n);if(s==="directory"){const o=A(n);return o||(0,a.basename)(e)}if(s==="linked-pointer"){const o=E(n),u=o!==void 0?A(o):void 0;return u||(0,a.basename)(e)}s==="worktree-pointer"&&i===void 0&&(i=M(n))}const r=(0,a.dirname)(e);if(r===e)break;e=r}return i??(0,a.basename)(t)}c(F,"resolveProjectName");function L(t){try{const e=(0,l.statSync)(t);if(e.isDirectory())return"directory";if(!e.isFile())return"other";const i=E(t);return i===void 0?"other":(0,l.existsSync)((0,a.join)(i,"commondir"))?"worktree-pointer":"linked-pointer"}catch(e){return f.logger.debug(`resolveProjectName: stat failed for ${t}: ${e instanceof Error?e.message:e}`),"other"}}c(L,"classifyGitEntry");function E(t){try{const i=(0,l.readFileSync)(t,"utf-8").trim().match(/^gitdir:\s*(.+)$/m);if(!i)return;const n=i[1].trim();return(0,a.isAbsolute)(n)?n:(0,a.resolve)((0,a.dirname)(t),n)}catch(e){f.logger.debug(`resolveProjectName: pointer at ${t} unreadable: ${e instanceof Error?e.message:e}`);return}}c(E,"readGitdirPointer");function A(t){try{const e=(0,a.join)(t,"config");if(!(0,l.existsSync)(e))return;const i=U((0,l.readFileSync)(e,"utf-8"));return i?O(i):void 0}catch(e){f.logger.debug(`resolveProjectName: failed to read git config at ${t}: ${e instanceof Error?e.message:e}`);return}}c(A,"repoNameFromGitConfig");function M(t){const e=E(t);if(e===void 0)return;const i=(0,a.join)(e,"commondir");let n;try{if((0,l.existsSync)(i)){const o=(0,l.readFileSync)(i,"utf-8").trim();n=(0,a.isAbsolute)(o)?o:(0,a.resolve)(e,o)}else n=e}catch(o){f.logger.debug(`resolveProjectName: commondir at ${i} unreadable: ${o instanceof Error?o.message:o}`);return}const r=A(n);if(r)return r;const s=(0,a.basename)(n)===".git"?(0,a.basename)((0,a.dirname)(n)):(0,a.basename)(n);return s.length>0?s:void 0}c(M,"repoNameFromWorktreePointer");function U(t){const e=t.split(/\r?\n/);let i=null,n=null,r,s;for(const o of e){const u=o.trim();if(u.length===0||u.startsWith("#")||u.startsWith(";"))continue;const g=u.match(/^\[([^\s\]]+)(?:\s+"([^"]*)")?\]$/);if(g){i=g[1].toLowerCase(),n=g[2]??null;continue}if(i!=="remote"||n===null)continue;const p=u.match(/^url\s*=\s*(.+?)\s*$/i);if(!p)continue;const m=p[1];n==="origin"&&(r=m),s===void 0&&(s=m)}return r??s}c(U,"readFirstRemoteUrl");function O(t){let e=t.trim();if(e.length===0)return;const i=e.match(/^[^/@]+@[^/:]+:(.+)$/);if(i?e=i[1]:e=e.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]*\//i,""),e=e.replace(/[?#].*$/,"").replace(/\/+$/,""),e.length===0)return;const r=(e.split("/").pop()??"").replace(/\.git$/i,"");return r.length>0?r:void 0}c(O,"repoNameFromRemoteUrl");function T(t){const e=(0,a.basename)((0,a.dirname)(t)),i=(0,a.dirname)(t),{getUserEmail:n,getUsageType:r,getUsagePlan:s,getProjectDir:o}=require("./session-state"),u=o(i)??(0,a.dirname)((0,a.dirname)((0,a.dirname)(i))),g=n(i),p=r(i),m=s(i),v={id:(0,b.randomUUID)(),session_id:e,project_name:F(u)};return g&&(v.user_email=g),p&&(v.usage_type=p),m&&(v.usage_plan=m),v}c(T,"baseFields");function I(t){const e=(0,b.createHash)("sha256").update("session_end:"+t).digest("hex");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20,32)}`}c(I,"deterministicSessionEndId");async function J(t,e){const i=T(t);e.id||(e.id=i.id),e.session_id||(e.session_id=i.session_id),e.project_name||(e.project_name=i.project_name);try{(0,l.mkdirSync)((0,a.dirname)(t),{recursive:!0}),(0,l.appendFileSync)(t,JSON.stringify(e)+`
2
+ `)}catch(n){f.logger.debug(`failed to append action to ${t}: ${n}`)}if(e.type!=="tool_call"){const n=(0,a.dirname)(t),r=(0,a.basename)(n),{getProjectDir:s}=require("./session-state"),o=s(n)??(0,a.dirname)((0,a.dirname)((0,a.dirname)(n)));try{await(0,_.sendToCollector)(e,r,o)}catch(u){u instanceof _.RetriableCollectorError?G(o,r,e,u):f.logger.debug(`failed to send action to collector: ${u}`)}}}c(J,"appendAction");function G(t,e,i,n){if(!(0,k.isJobQueueEnabled)(t)){f.logger.debug(`collector fallback: jobQueue disabled, dropping type=${i.type} id=${i.id} (cause: ${n.message})`);return}try{(0,C.submit)(t,e,V.SEND_EVENT_TYPE,i),f.logger.debug(`collector fallback: enqueued type=${i.type} id=${i.id} as send_event (cause: ${n.message})`)}catch(r){if(r instanceof S.JobTooLargeError){f.logger.debug(`collector fallback: event too large for queue (${r.sizeBytes} bytes), dropping type=${i.type} id=${i.id}`);return}f.logger.debug(`collector fallback: queue submit failed for type=${i.type} id=${i.id}: ${r}`)}}c(G,"enqueueCollectorFallback");function W(t,e,i){if((0,l.existsSync)(t))try{const r=(0,l.readFileSync)(t,"utf-8").trim().split(`
3
+ `).filter(s=>s.length>0);for(let s=r.length-1;s>=0;s--)try{const o=JSON.parse(r[s]);if(o.type===e&&typeof o.timestamp=="number")return i-o.timestamp}catch{}}catch(n){f.logger.debug(`failed to find duration for ${e}: ${n}`)}}c(W,"findDurationSinceLastAction");function w(t,e){return y(t,i=>i.type===e)}c(w,"readActionsSinceLastMarker");function z(t){if((0,l.existsSync)(t))try{const i=(0,l.readFileSync)(t,"utf-8").trim().split(`
4
+ `).filter(n=>n.length>0);for(let n=i.length-1;n>=0;n--)try{const r=JSON.parse(i[n]);if(typeof r.timestamp=="number")return r.timestamp}catch{}}catch(e){f.logger.debug(`failed to read last action timestamp from ${t}: ${e}`)}}c(z,"findLastActionTimestamp");function y(t,e){if(!(0,l.existsSync)(t))return[];try{const n=(0,l.readFileSync)(t,"utf-8").trim().split(`
5
+ `).filter(o=>o.length>0);let r=-1;const s=[];for(let o=0;o<n.length;o++)try{const u=JSON.parse(n[o]);s.push(u),e(u)&&(r=o)}catch{}return s.slice(r+1)}catch(i){return f.logger.debug(`failed to read actions from ${t}: ${i}`),[]}}c(y,"readActionsSinceMatch");function x(t){return t.type!=="verification_requested"?!1:t.action==="allow"}c(x,"isAllowVerificationRequested");function $(t){if(t.type!=="tool_call")return!1;const e=t.verification_id;return typeof e=="string"&&e.length>0}c($,"isVerificationScopedToolCall");function K(t){return y(t,x).filter($)}c(K,"getToolCallsSinceLastVerification");function B(t){return w(t,"file_change").filter($)}c(B,"getToolCallsSinceLastFileChange");function Q(t){return w(t,"verdict_write").some($)}c(Q,"hasToolCallsSinceLastVerdict");function H(t){return y(t,x).some(i=>i.type==="file_change")}c(H,"hasFileChangesSinceLastVerification");function Y(t){return y(t,x).filter(i=>i.type==="file_change")}c(Y,"getFileChangesSinceLastVerification");function X(t){return t.type!=="verdict_write"?!1:t.verdict?.status==="fail"}c(X,"isFailVerdictWrite");function Z(t){if(!(0,l.existsSync)(t))return[];try{const n=(0,l.readFileSync)(t,"utf-8").trim().split(`
6
+ `).filter(o=>o.length>0).map(o=>{try{return JSON.parse(o)}catch{return null}});let r=-1;for(let o=0;o<n.length;o++){const u=n[o];u!==null&&X(u)&&(r=o)}if(r<0)return[];const s=[];for(let o=r+1;o<n.length;o++){const u=n[o];u!==null&&u.type==="file_change"&&s.push(u)}return s}catch(e){return f.logger.debug(`failed to read file changes since last fail verdict: ${e}`),[]}}c(Z,"getFileChangesSinceLastFailVerdict");function ee(t){if(!(0,l.existsSync)(t))return!1;try{const i=(0,l.readFileSync)(t,"utf-8").trim().split(`
7
+ `).filter(n=>n.length>0);for(const n of i){let r;try{r=JSON.parse(n)}catch{continue}if(r.type==="verification_start")return!0;if(r.type==="tool_call"){const s=r;if(s.tool_type==="mcp"&&typeof s.mcp_server=="string"&&s.mcp_server.endsWith("-devtools"))return!0}}return!1}catch(e){return f.logger.debug(`failed to scan verifier engagement in ${t}: ${e}`),!1}}c(ee,"hasVerifierEverEngaged");function te(t){if(t.length===0)return[];const e=new Map,i=[];for(const n of t){const r=n.file_path;let s=e.get(r);s||(s={op:n.operation,added:0,removed:0},e.set(r,s),i.push(r)),s.op=s.op==="create"||n.operation==="create"?"create":n.operation,s.added+=typeof n.lines_added=="number"?n.lines_added:0,s.removed+=typeof n.lines_removed=="number"?n.lines_removed:0}return i.map(n=>{const r=e.get(n);return`${r.op} ${n} (+${r.added}/-${r.removed})`})}c(te,"summarizeFixFileChanges");0&&(module.exports={ActivityAwareEvent,Event,EventType,EventTypeValue,FixAwareEvent,VerificationAwareEvent,appendAction,baseFields,deterministicSessionEndId,findDurationSinceLastAction,findLastActionTimestamp,getFileChangesSinceLastFailVerdict,getFileChangesSinceLastVerification,getToolCallsSinceLastFileChange,getToolCallsSinceLastVerification,hasFileChangesSinceLastVerification,hasToolCallsSinceLastVerdict,hasVerifierEverEngaged,readActionsSinceLastMarker,resolveProjectName,summarizeFixFileChanges});
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var a=(i,e)=>v(i,"name",{value:e,configurable:!0});var h=(i,e)=>{for(var n in e)v(i,n,{get:e[n],enumerable:!0})},_=(i,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!V.call(i,r)&&r!==n&&v(i,r,{get:()=>e[r],enumerable:!(t=A(e,r))||t.enumerable});return i};var b=i=>_(v({},"__esModule",{value:!0}),i);var St={};h(St,{addPendingFixes:()=>ct,clearActiveActivity:()=>gt,clearActiveFix:()=>z,clearActiveVerification:()=>F,clearPendingFixes:()=>st,clearVerifyIntent:()=>ut,closeOpenCycles:()=>vt,generateTraceId:()=>T,getActiveActivityId:()=>Q,getActiveFixId:()=>C,getActiveTraceId:()=>E,getActiveVerificationId:()=>w,getChainedStatusLine:()=>et,getContextInjectedVerificationId:()=>nt,getLastVerdictHadIssues:()=>U,getLastVerdictStatus:()=>q,getPendingFixes:()=>at,getPhase:()=>O,getRetries:()=>R,getUsagePlan:()=>D,getUsageType:()=>Z,getUserEmail:()=>X,getVerifyIntent:()=>ot,incrementRetries:()=>L,isActive:()=>G,isFailLikeVerdictStatus:()=>lt,isRecordingActive:()=>M,isRecordingRequired:()=>J,readState:()=>c,reconcileAbandonedActivity:()=>yt,reconcileForCompact:()=>It,reconcileSessionState:()=>pt,resetRetries:()=>$,setActive:()=>K,setActiveActivity:()=>ft,setActiveFix:()=>k,setActiveVerification:()=>P,setChainedStatusLine:()=>it,setContextInjectedVerificationId:()=>rt,setLastVerdictHadIssues:()=>H,setLastVerdictStatus:()=>j,setPhase:()=>N,setRecordingActive:()=>W,setRecordingRequired:()=>B,setUsage:()=>tt,setUserEmail:()=>Y,setVerifyIntent:()=>dt,writeState:()=>u});module.exports=b(St);var x=require("crypto"),f=require("fs"),y=require("path"),l=require("../../lib/logger"),g=require("./activity-participants"),p=require("../../lib/atomic"),d=require("./actions");const I="state.json",S={retries:0,activeVerificationId:null,activeTraceId:null,lastVerdictStatus:null,lastVerdictHadIssues:!1,activeFixId:null,activeActivityId:null,phase:null,recordingRequired:!1,recordingActive:!1,active:!1,userEmail:null,usageType:null,usagePlan:null,chainedStatusLine:null,contextInjectedVerificationId:null,pendingFixes:[],verifyIntent:null};function T(){return(0,x.randomBytes)(16).toString("hex")}a(T,"generateTraceId");function c(i){const e=(0,y.join)(i,I);if(!(0,f.existsSync)(e))return{...S};try{const n=(0,f.readFileSync)(e,"utf-8"),t=JSON.parse(n),r=["coding","verifying","fixing"],s=["api","subscription"];return{retries:typeof t.retries=="number"?t.retries:0,activeVerificationId:typeof t.activeVerificationId=="string"?t.activeVerificationId:null,activeTraceId:typeof t.activeTraceId=="string"?t.activeTraceId:null,lastVerdictStatus:typeof t.lastVerdictStatus=="string"?t.lastVerdictStatus:null,lastVerdictHadIssues:typeof t.lastVerdictHadIssues=="boolean"?t.lastVerdictHadIssues:!1,activeFixId:typeof t.activeFixId=="string"?t.activeFixId:null,activeActivityId:typeof t.activeActivityId=="string"?t.activeActivityId:null,phase:typeof t.phase=="string"&&r.includes(t.phase)?t.phase:null,recordingRequired:typeof t.recordingRequired=="boolean"?t.recordingRequired:!1,recordingActive:typeof t.recordingActive=="boolean"?t.recordingActive:!1,active:typeof t.active=="boolean"?t.active:!1,userEmail:typeof t.userEmail=="string"?t.userEmail:null,usageType:typeof t.usageType=="string"&&s.includes(t.usageType)?t.usageType:null,usagePlan:typeof t.usagePlan=="string"&&t.usagePlan.length>0?t.usagePlan:null,chainedStatusLine:typeof t.chainedStatusLine=="string"&&t.chainedStatusLine.length>0?t.chainedStatusLine:null,contextInjectedVerificationId:typeof t.contextInjectedVerificationId=="string"?t.contextInjectedVerificationId:null,pendingFixes:Array.isArray(t.pendingFixes)?t.pendingFixes.filter(o=>typeof o=="string"&&o.length>0):[],verifyIntent:typeof t.verifyIntent=="string"&&t.verifyIntent.length>0?t.verifyIntent:null}}catch(n){return l.logger.debug(`failed to read state from ${e}: ${n}`),{...S}}}a(c,"readState");function u(i,e){const n=(0,y.join)(i,I);try{(0,f.mkdirSync)(i,{recursive:!0});const t=`${n}.tmp.${process.pid}.${Date.now()}`,r=JSON.stringify(e,null,2);try{(0,f.writeFileSync)(t,r),(0,p.renameWithRetry)(t,n)}catch(s){try{(0,f.existsSync)(t)&&(0,f.unlinkSync)(t)}catch{}throw s}(0,p.sweepStaleTmpFiles)(n)}catch(t){l.logger.debug(`failed to write state to ${n}: ${t}`)}}a(u,"writeState");function w(i){return c(i).activeVerificationId??void 0}a(w,"getActiveVerificationId");function P(i,e,n){const t=c(i);t.activeVerificationId=e,t.activeTraceId=n,t.phase="verifying",u(i,t)}a(P,"setActiveVerification");function E(i){return c(i).activeTraceId??void 0}a(E,"getActiveTraceId");function F(i){const e=c(i);e.activeVerificationId=null,e.activeTraceId=null,e.phase="coding",u(i,e)}a(F,"clearActiveVerification");function R(i){return c(i).retries}a(R,"getRetries");function L(i){const e=c(i);return e.retries=e.retries+1,u(i,e),e.retries}a(L,"incrementRetries");function $(i){const e=c(i);e.retries=0,u(i,e)}a($,"resetRetries");function q(i){return c(i).lastVerdictStatus??void 0}a(q,"getLastVerdictStatus");function j(i,e){const n=c(i);n.lastVerdictStatus=e,u(i,n)}a(j,"setLastVerdictStatus");function U(i){return c(i).lastVerdictHadIssues===!0}a(U,"getLastVerdictHadIssues");function H(i,e){const n=c(i);n.lastVerdictHadIssues=e,u(i,n)}a(H,"setLastVerdictHadIssues");function k(i,e){const n=c(i);n.activeFixId=e,u(i,n)}a(k,"setActiveFix");function C(i){return c(i).activeFixId??void 0}a(C,"getActiveFixId");function z(i){const e=c(i);e.activeFixId=null,u(i,e)}a(z,"clearActiveFix");function N(i,e){const n=c(i);n.phase=e,u(i,n)}a(N,"setPhase");function O(i){return c(i).phase}a(O,"getPhase");function J(i){return c(i).recordingRequired}a(J,"isRecordingRequired");function B(i,e){const n=c(i);n.recordingRequired=e,u(i,n)}a(B,"setRecordingRequired");function M(i){return c(i).recordingActive}a(M,"isRecordingActive");function W(i,e){const n=c(i);n.recordingActive=e,u(i,n)}a(W,"setRecordingActive");function G(i){return c(i).active}a(G,"isActive");function K(i,e){const n=c(i);n.active=e,e||(n.activeActivityId=null),u(i,n)}a(K,"setActive");function Q(i){return c(i).activeActivityId??void 0}a(Q,"getActiveActivityId");function X(i){return c(i).userEmail??void 0}a(X,"getUserEmail");function Y(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.userEmail!==n&&(t.userEmail=n,u(i,t))}a(Y,"setUserEmail");function Z(i){return c(i).usageType??void 0}a(Z,"getUsageType");function D(i){return c(i).usagePlan??void 0}a(D,"getUsagePlan");function tt(i,e){const n=e.usage_type==="api"||e.usage_type==="subscription"?e.usage_type:null,t=typeof e.usage_plan=="string"&&e.usage_plan.length>0?e.usage_plan:null,r=c(i);r.usageType===n&&r.usagePlan===t||(r.usageType=n,r.usagePlan=t,u(i,r))}a(tt,"setUsage");function et(i){return c(i).chainedStatusLine??void 0}a(et,"getChainedStatusLine");function it(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.chainedStatusLine!==n&&(t.chainedStatusLine=n,u(i,t))}a(it,"setChainedStatusLine");function nt(i){return c(i).contextInjectedVerificationId??void 0}a(nt,"getContextInjectedVerificationId");function rt(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.contextInjectedVerificationId!==n&&(t.contextInjectedVerificationId=n,u(i,t))}a(rt,"setContextInjectedVerificationId");function at(i){return c(i).pendingFixes}a(at,"getPendingFixes");function ct(i,e){const n=e.filter(o=>typeof o=="string"&&o.length>0);if(n.length===0)return;const t=c(i),r=new Set(t.pendingFixes),s=[...t.pendingFixes];for(const o of n)r.has(o)||(r.add(o),s.push(o));s.length!==t.pendingFixes.length&&(t.pendingFixes=s,u(i,t))}a(ct,"addPendingFixes");function st(i){const e=c(i);e.pendingFixes.length!==0&&(e.pendingFixes=[],u(i,e))}a(st,"clearPendingFixes");function ot(i){return c(i).verifyIntent}a(ot,"getVerifyIntent");function dt(i,e){const n=c(i);n.verifyIntent!==e&&(n.verifyIntent=e,u(i,n))}a(dt,"setVerifyIntent");function ut(i){const e=c(i);e.verifyIntent!==null&&(e.verifyIntent=null,u(i,e))}a(ut,"clearVerifyIntent");function lt(i){return i==="fail"||i==="fail_reported"}a(lt,"isFailLikeVerdictStatus");function ft(i,e){const n=c(i);n.activeActivityId=e,n.active=!0,u(i,n)}a(ft,"setActiveActivity");function gt(i){const e=c(i);e.activeActivityId=null,e.active=!1,u(i,e)}a(gt,"clearActiveActivity");async function vt(i,e,n){const t=c(i);let r=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:n};await(0,d.appendAction)(e,o),l.logger.debug(`close-open-cycles: ended verification ${t.activeVerificationId} (${n})`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:n};await(0,d.appendAction)(e,o),l.logger.debug(`close-open-cycles: ended fix ${t.activeFixId} (${n})`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(vt,"closeOpenCycles");async function pt(i,e,n){const t=c(i);let r=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"session_reconcile"};await n(e,o),l.logger.debug(`reconcile: ended abandoned verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"session_reconcile"};await n(e,o),l.logger.debug(`reconcile: ended abandoned fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}if(t.active){const s=Date.now(),o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"session_reconcile"};await n(e,o),l.logger.debug(`reconcile: ended abandoned activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,(0,g.clearActivityParticipants)(i),r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(pt,"reconcileSessionState");async function yt(i,e,n){const t=c(i);if(!t.active&&!t.activeVerificationId&&!t.activeFixId&&t.verifyIntent===null||!(0,g.isParticipantPresent)(i,g.MAIN_PARTICIPANT_ID)&&(0,g.anyActiveParticipants)(i))return;let r=!1;const s=(0,d.findLastActionTimestamp)(e)??Date.now();if(t.activeVerificationId){const o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"interrupt_inferred"};await n(e,o),l.logger.debug(`interrupt-reconcile: ended verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"interrupt_inferred"};await n(e,o),l.logger.debug(`interrupt-reconcile: ended fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}if(t.active){const o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"interrupt_inferred"};await n(e,o),l.logger.debug(`interrupt-reconcile: ended activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,(0,g.clearActivityParticipants)(i),r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(yt,"reconcileAbandonedActivity");async function It(i,e,n){const t=c(i);let r=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"compact"};await n(e,o),l.logger.debug(`compact-reconcile: ended verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,r=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"compact"};await n(e,o),l.logger.debug(`compact-reconcile: ended fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),r=!0}if(t.active){const s=Date.now(),o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"compact"};await n(e,o),l.logger.debug(`compact-reconcile: ended activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,(0,g.clearActivityParticipants)(i),r=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,r=!0),t.phase!=="coding"&&(t.phase="coding",r=!0),t.verifyIntent!==null&&(t.verifyIntent=null,r=!0),r&&u(i,t)}a(It,"reconcileForCompact");0&&(module.exports={addPendingFixes,clearActiveActivity,clearActiveFix,clearActiveVerification,clearPendingFixes,clearVerifyIntent,closeOpenCycles,generateTraceId,getActiveActivityId,getActiveFixId,getActiveTraceId,getActiveVerificationId,getChainedStatusLine,getContextInjectedVerificationId,getLastVerdictHadIssues,getLastVerdictStatus,getPendingFixes,getPhase,getRetries,getUsagePlan,getUsageType,getUserEmail,getVerifyIntent,incrementRetries,isActive,isFailLikeVerdictStatus,isRecordingActive,isRecordingRequired,readState,reconcileAbandonedActivity,reconcileForCompact,reconcileSessionState,resetRetries,setActive,setActiveActivity,setActiveFix,setActiveVerification,setChainedStatusLine,setContextInjectedVerificationId,setLastVerdictHadIssues,setLastVerdictStatus,setPhase,setRecordingActive,setRecordingRequired,setUsage,setUserEmail,setVerifyIntent,writeState});
1
+ "use strict";var v=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var r=(i,e)=>v(i,"name",{value:e,configurable:!0});var V=(i,e)=>{for(var n in e)v(i,n,{get:e[n],enumerable:!0})},_=(i,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of m(e))!h.call(i,a)&&a!==n&&v(i,a,{get:()=>e[a],enumerable:!(t=A(e,a))||t.enumerable});return i};var b=i=>_(v({},"__esModule",{value:!0}),i);var At={};V(At,{addPendingFixes:()=>ot,clearActiveActivity:()=>pt,clearActiveFix:()=>z,clearActiveVerification:()=>F,clearPendingFixes:()=>dt,clearVerifyIntent:()=>lt,closeOpenCycles:()=>yt,generateTraceId:()=>T,getActiveActivityId:()=>Q,getActiveFixId:()=>C,getActiveTraceId:()=>E,getActiveVerificationId:()=>w,getChainedStatusLine:()=>nt,getContextInjectedVerificationId:()=>at,getLastVerdictHadIssues:()=>U,getLastVerdictStatus:()=>$,getPendingFixes:()=>st,getPhase:()=>O,getProjectDir:()=>Z,getRetries:()=>j,getUsagePlan:()=>et,getUsageType:()=>tt,getUserEmail:()=>X,getVerifyIntent:()=>ut,incrementRetries:()=>R,isActive:()=>G,isFailLikeVerdictStatus:()=>gt,isRecordingActive:()=>M,isRecordingRequired:()=>J,readState:()=>c,reconcileAbandonedActivity:()=>St,reconcileForCompact:()=>xt,reconcileSessionState:()=>It,resetRetries:()=>L,setActive:()=>K,setActiveActivity:()=>vt,setActiveFix:()=>k,setActiveVerification:()=>P,setChainedStatusLine:()=>rt,setContextInjectedVerificationId:()=>ct,setLastVerdictHadIssues:()=>H,setLastVerdictStatus:()=>q,setPhase:()=>N,setProjectDir:()=>D,setRecordingActive:()=>W,setRecordingRequired:()=>B,setUsage:()=>it,setUserEmail:()=>Y,setVerifyIntent:()=>ft,writeState:()=>u});module.exports=b(At);var x=require("crypto"),l=require("fs"),y=require("path"),f=require("../../lib/logger"),g=require("./activity-participants"),p=require("../../lib/atomic"),d=require("./actions");const I="state.json",S={retries:0,activeVerificationId:null,activeTraceId:null,lastVerdictStatus:null,lastVerdictHadIssues:!1,activeFixId:null,activeActivityId:null,phase:null,recordingRequired:!1,recordingActive:!1,active:!1,userEmail:null,usageType:null,usagePlan:null,chainedStatusLine:null,contextInjectedVerificationId:null,pendingFixes:[],verifyIntent:null};function T(){return(0,x.randomBytes)(16).toString("hex")}r(T,"generateTraceId");function c(i){const e=(0,y.join)(i,I);if(!(0,l.existsSync)(e))return{...S};try{const n=(0,l.readFileSync)(e,"utf-8"),t=JSON.parse(n),a=["coding","verifying","fixing"],s=["api","subscription"];return{retries:typeof t.retries=="number"?t.retries:0,activeVerificationId:typeof t.activeVerificationId=="string"?t.activeVerificationId:null,activeTraceId:typeof t.activeTraceId=="string"?t.activeTraceId:null,lastVerdictStatus:typeof t.lastVerdictStatus=="string"?t.lastVerdictStatus:null,lastVerdictHadIssues:typeof t.lastVerdictHadIssues=="boolean"?t.lastVerdictHadIssues:!1,activeFixId:typeof t.activeFixId=="string"?t.activeFixId:null,activeActivityId:typeof t.activeActivityId=="string"?t.activeActivityId:null,phase:typeof t.phase=="string"&&a.includes(t.phase)?t.phase:null,recordingRequired:typeof t.recordingRequired=="boolean"?t.recordingRequired:!1,recordingActive:typeof t.recordingActive=="boolean"?t.recordingActive:!1,active:typeof t.active=="boolean"?t.active:!1,userEmail:typeof t.userEmail=="string"?t.userEmail:null,usageType:typeof t.usageType=="string"&&s.includes(t.usageType)?t.usageType:null,usagePlan:typeof t.usagePlan=="string"&&t.usagePlan.length>0?t.usagePlan:null,projectDir:typeof t.projectDir=="string"&&t.projectDir.length>0?t.projectDir:void 0,chainedStatusLine:typeof t.chainedStatusLine=="string"&&t.chainedStatusLine.length>0?t.chainedStatusLine:null,contextInjectedVerificationId:typeof t.contextInjectedVerificationId=="string"?t.contextInjectedVerificationId:null,pendingFixes:Array.isArray(t.pendingFixes)?t.pendingFixes.filter(o=>typeof o=="string"&&o.length>0):[],verifyIntent:typeof t.verifyIntent=="string"&&t.verifyIntent.length>0?t.verifyIntent:null}}catch(n){return f.logger.debug(`failed to read state from ${e}: ${n}`),{...S}}}r(c,"readState");function u(i,e){const n=(0,y.join)(i,I);try{(0,l.mkdirSync)(i,{recursive:!0});const t=`${n}.tmp.${process.pid}.${Date.now()}`,a=JSON.stringify(e,null,2);try{(0,l.writeFileSync)(t,a),(0,p.renameWithRetry)(t,n)}catch(s){try{(0,l.existsSync)(t)&&(0,l.unlinkSync)(t)}catch{}throw s}(0,p.sweepStaleTmpFiles)(n)}catch(t){f.logger.debug(`failed to write state to ${n}: ${t}`)}}r(u,"writeState");function w(i){return c(i).activeVerificationId??void 0}r(w,"getActiveVerificationId");function P(i,e,n){const t=c(i);t.activeVerificationId=e,t.activeTraceId=n,t.phase="verifying",u(i,t)}r(P,"setActiveVerification");function E(i){return c(i).activeTraceId??void 0}r(E,"getActiveTraceId");function F(i){const e=c(i);e.activeVerificationId=null,e.activeTraceId=null,e.phase="coding",u(i,e)}r(F,"clearActiveVerification");function j(i){return c(i).retries}r(j,"getRetries");function R(i){const e=c(i);return e.retries=e.retries+1,u(i,e),e.retries}r(R,"incrementRetries");function L(i){const e=c(i);e.retries=0,u(i,e)}r(L,"resetRetries");function $(i){return c(i).lastVerdictStatus??void 0}r($,"getLastVerdictStatus");function q(i,e){const n=c(i);n.lastVerdictStatus=e,u(i,n)}r(q,"setLastVerdictStatus");function U(i){return c(i).lastVerdictHadIssues===!0}r(U,"getLastVerdictHadIssues");function H(i,e){const n=c(i);n.lastVerdictHadIssues=e,u(i,n)}r(H,"setLastVerdictHadIssues");function k(i,e){const n=c(i);n.activeFixId=e,u(i,n)}r(k,"setActiveFix");function C(i){return c(i).activeFixId??void 0}r(C,"getActiveFixId");function z(i){const e=c(i);e.activeFixId=null,u(i,e)}r(z,"clearActiveFix");function N(i,e){const n=c(i);n.phase=e,u(i,n)}r(N,"setPhase");function O(i){return c(i).phase}r(O,"getPhase");function J(i){return c(i).recordingRequired}r(J,"isRecordingRequired");function B(i,e){const n=c(i);n.recordingRequired=e,u(i,n)}r(B,"setRecordingRequired");function M(i){return c(i).recordingActive}r(M,"isRecordingActive");function W(i,e){const n=c(i);n.recordingActive=e,u(i,n)}r(W,"setRecordingActive");function G(i){return c(i).active}r(G,"isActive");function K(i,e){const n=c(i);n.active=e,e||(n.activeActivityId=null),u(i,n)}r(K,"setActive");function Q(i){return c(i).activeActivityId??void 0}r(Q,"getActiveActivityId");function X(i){return c(i).userEmail??void 0}r(X,"getUserEmail");function Y(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.userEmail!==n&&(t.userEmail=n,u(i,t))}r(Y,"setUserEmail");function Z(i){const e=c(i);return typeof e.projectDir=="string"&&e.projectDir.length>0?e.projectDir:void 0}r(Z,"getProjectDir");function D(i,e){const n=typeof e=="string"&&e.length>0?e:void 0;if(n===void 0)return;const t=c(i);t.projectDir!==n&&(t.projectDir=n,u(i,t))}r(D,"setProjectDir");function tt(i){return c(i).usageType??void 0}r(tt,"getUsageType");function et(i){return c(i).usagePlan??void 0}r(et,"getUsagePlan");function it(i,e){const n=e.usage_type==="api"||e.usage_type==="subscription"?e.usage_type:null,t=typeof e.usage_plan=="string"&&e.usage_plan.length>0?e.usage_plan:null,a=c(i);a.usageType===n&&a.usagePlan===t||(a.usageType=n,a.usagePlan=t,u(i,a))}r(it,"setUsage");function nt(i){return c(i).chainedStatusLine??void 0}r(nt,"getChainedStatusLine");function rt(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.chainedStatusLine!==n&&(t.chainedStatusLine=n,u(i,t))}r(rt,"setChainedStatusLine");function at(i){return c(i).contextInjectedVerificationId??void 0}r(at,"getContextInjectedVerificationId");function ct(i,e){const n=typeof e=="string"&&e.length>0?e:null,t=c(i);t.contextInjectedVerificationId!==n&&(t.contextInjectedVerificationId=n,u(i,t))}r(ct,"setContextInjectedVerificationId");function st(i){return c(i).pendingFixes}r(st,"getPendingFixes");function ot(i,e){const n=e.filter(o=>typeof o=="string"&&o.length>0);if(n.length===0)return;const t=c(i),a=new Set(t.pendingFixes),s=[...t.pendingFixes];for(const o of n)a.has(o)||(a.add(o),s.push(o));s.length!==t.pendingFixes.length&&(t.pendingFixes=s,u(i,t))}r(ot,"addPendingFixes");function dt(i){const e=c(i);e.pendingFixes.length!==0&&(e.pendingFixes=[],u(i,e))}r(dt,"clearPendingFixes");function ut(i){return c(i).verifyIntent}r(ut,"getVerifyIntent");function ft(i,e){const n=c(i);n.verifyIntent!==e&&(n.verifyIntent=e,u(i,n))}r(ft,"setVerifyIntent");function lt(i){const e=c(i);e.verifyIntent!==null&&(e.verifyIntent=null,u(i,e))}r(lt,"clearVerifyIntent");function gt(i){return i==="fail"||i==="fail_reported"}r(gt,"isFailLikeVerdictStatus");function vt(i,e){const n=c(i);n.activeActivityId=e,n.active=!0,u(i,n)}r(vt,"setActiveActivity");function pt(i){const e=c(i);e.activeActivityId=null,e.active=!1,u(i,e)}r(pt,"clearActiveActivity");async function yt(i,e,n){const t=c(i);let a=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:n};await(0,d.appendAction)(e,o),f.logger.debug(`close-open-cycles: ended verification ${t.activeVerificationId} (${n})`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,a=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:n};await(0,d.appendAction)(e,o),f.logger.debug(`close-open-cycles: ended fix ${t.activeFixId} (${n})`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),a=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,a=!0),t.phase!=="coding"&&(t.phase="coding",a=!0),t.verifyIntent!==null&&(t.verifyIntent=null,a=!0),a&&u(i,t)}r(yt,"closeOpenCycles");async function It(i,e,n){const t=c(i);let a=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"session_reconcile"};await n(e,o),f.logger.debug(`reconcile: ended abandoned verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,a=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"session_reconcile"};await n(e,o),f.logger.debug(`reconcile: ended abandoned fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),a=!0}if(t.active){const s=Date.now(),o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"session_reconcile"};await n(e,o),f.logger.debug(`reconcile: ended abandoned activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,(0,g.clearActivityParticipants)(i),a=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,a=!0),t.phase!=="coding"&&(t.phase="coding",a=!0),t.verifyIntent!==null&&(t.verifyIntent=null,a=!0),a&&u(i,t)}r(It,"reconcileSessionState");async function St(i,e,n){const t=c(i);if(!t.active&&!t.activeVerificationId&&!t.activeFixId&&t.verifyIntent===null||!(0,g.isParticipantPresent)(i,g.MAIN_PARTICIPANT_ID)&&(0,g.anyActiveParticipants)(i))return;let a=!1;const s=(0,d.findLastActionTimestamp)(e)??Date.now();if(t.activeVerificationId){const o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"interrupt_inferred"};await n(e,o),f.logger.debug(`interrupt-reconcile: ended verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,a=!0}if(t.activeFixId){const o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"interrupt_inferred"};await n(e,o),f.logger.debug(`interrupt-reconcile: ended fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),a=!0}if(t.active){const o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"interrupt_inferred"};await n(e,o),f.logger.debug(`interrupt-reconcile: ended activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,(0,g.clearActivityParticipants)(i),a=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,a=!0),t.phase!=="coding"&&(t.phase="coding",a=!0),t.verifyIntent!==null&&(t.verifyIntent=null,a=!0),a&&u(i,t)}r(St,"reconcileAbandonedActivity");async function xt(i,e,n){const t=c(i);let a=!1;if(t.activeVerificationId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"verification_end",timestamp:s,verification_id:t.activeVerificationId,activity_id:t.activeActivityId,trace_id:t.activeTraceId,duration:(0,d.findDurationSinceLastAction)(e,"verification_start",s),reason:"compact"};await n(e,o),f.logger.debug(`compact-reconcile: ended verification ${t.activeVerificationId}`),t.activeVerificationId=null,t.activeTraceId=null,t.contextInjectedVerificationId=null,a=!0}if(t.activeFixId){const s=Date.now(),o={...(0,d.baseFields)(e),type:"fix_end",timestamp:s,fix_id:t.activeFixId,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"fix_start",s),reason:"compact"};await n(e,o),f.logger.debug(`compact-reconcile: ended fix ${t.activeFixId}`),t.activeFixId=null,t.pendingFixes.length>0&&(t.pendingFixes=[]),a=!0}if(t.active){const s=Date.now(),o={...(0,d.baseFields)(e),type:"activity_end",timestamp:s,activity_id:t.activeActivityId,duration:(0,d.findDurationSinceLastAction)(e,"activity_start",s),reason:"compact"};await n(e,o),f.logger.debug(`compact-reconcile: ended activity ${t.activeActivityId??""}`),t.active=!1,t.activeActivityId=null,(0,g.clearActivityParticipants)(i),a=!0}(t.recordingRequired||t.recordingActive)&&(t.recordingRequired=!1,t.recordingActive=!1,a=!0),t.phase!=="coding"&&(t.phase="coding",a=!0),t.verifyIntent!==null&&(t.verifyIntent=null,a=!0),a&&u(i,t)}r(xt,"reconcileForCompact");0&&(module.exports={addPendingFixes,clearActiveActivity,clearActiveFix,clearActiveVerification,clearPendingFixes,clearVerifyIntent,closeOpenCycles,generateTraceId,getActiveActivityId,getActiveFixId,getActiveTraceId,getActiveVerificationId,getChainedStatusLine,getContextInjectedVerificationId,getLastVerdictHadIssues,getLastVerdictStatus,getPendingFixes,getPhase,getProjectDir,getRetries,getUsagePlan,getUsageType,getUserEmail,getVerifyIntent,incrementRetries,isActive,isFailLikeVerdictStatus,isRecordingActive,isRecordingRequired,readState,reconcileAbandonedActivity,reconcileForCompact,reconcileSessionState,resetRetries,setActive,setActiveActivity,setActiveFix,setActiveVerification,setChainedStatusLine,setContextInjectedVerificationId,setLastVerdictHadIssues,setLastVerdictStatus,setPhase,setProjectDir,setRecordingActive,setRecordingRequired,setUsage,setUserEmail,setVerifyIntent,writeState});
@@ -1,16 +1,16 @@
1
- "use strict";var y=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var g=(t,n)=>y(t,"name",{value:n,configurable:!0});var U=(t,n)=>{for(var i in n)y(t,i,{get:n[i],enumerable:!0})},W=(t,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of M(n))!H.call(t,e)&&e!==i&&y(t,e,{get:()=>n[e],enumerable:!(r=L(n,e))||r.enumerable});return t};var z=t=>W(y({},"__esModule",{value:!0}),t);var tt={};U(tt,{VERIFICATION_DOC_DIR:()=>b,VERIFICATION_DOC_FILE:()=>v,buildVerificationContext:()=>N,buildVerificationContextForSession:()=>j,buildVerificationContextOnceForCycle:()=>Z,collectChangedPaths:()=>A,renderChangedPathsBlock:()=>T,resolveContextFiles:()=>P});module.exports=z(tt);var D=require("fs"),o=require("path"),f=require("../../lib/config"),S=require("../../lib/git"),h=require("../../lib/logger"),O=require("./session-state"),w=require("./actions");const b=".ironbee",v="VERIFICATION.md",G=`===== IRONBEE \u2014 PROJECT VERIFICATION INSTRUCTIONS (path-scoped) =====
2
- `,J=`The following areas changed this cycle. Follow this guidance IN ADDITION to the standard verification flow.
1
+ "use strict";var y=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var g=(t,n)=>y(t,"name",{value:n,configurable:!0});var W=(t,n)=>{for(var i in n)y(t,i,{get:n[i],enumerable:!0})},z=(t,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of H(n))!U.call(t,e)&&e!==i&&y(t,e,{get:()=>n[e],enumerable:!(r=M(n,e))||r.enumerable});return t};var G=t=>z(y({},"__esModule",{value:!0}),t);var nt={};W(nt,{VERIFICATION_DOC_DIR:()=>b,VERIFICATION_DOC_FILE:()=>C,buildVerificationContext:()=>j,buildVerificationContextForSession:()=>_,buildVerificationContextOnceForCycle:()=>tt,collectChangedPaths:()=>P,renderChangedPathsBlock:()=>N,resolveContextFiles:()=>T});module.exports=G(nt);var D=require("fs"),o=require("path"),S=require("../../lib/runtime-paths"),u=require("../../lib/config"),w=require("../../lib/git"),h=require("../../lib/logger"),O=require("./session-state"),A=require("./actions");const b=".ironbee",C="VERIFICATION.md",J=`===== IRONBEE \u2014 PROJECT VERIFICATION INSTRUCTIONS (path-scoped) =====
2
+ `,q=`The following areas changed this cycle. Follow this guidance IN ADDITION to the standard verification flow.
3
3
  `,k=`====================================================================
4
- `;function C(t){return Buffer.byteLength(t,"utf-8")}g(C,"byteLen");function q(t){try{return(0,D.realpathSync)(t)}catch{return(0,o.resolve)(t)}}g(q,"canonicalDir");function K(t){const n=(0,o.resolve)(t),i=[];let r=n;for(;;)try{const e=(0,D.realpathSync)(r);return i.length>0?(0,o.join)(e,...i):e}catch{const e=(0,o.dirname)(r);if(e===r)return n;i.unshift((0,o.basename)(r)),r=e}}g(K,"canonicalizePath");function Q(t,n){const i=(0,o.relative)(t,n);return i.length>0&&!i.startsWith("..")&&!(0,o.isAbsolute)(i)}g(Q,"isUnderDir");function F(t){try{return(0,w.getFileChangesSinceLastVerification)(t).map(n=>n.file_path).filter(n=>typeof n=="string"&&n.length>0)}catch(n){return h.logger.debug(`verification-context: actions fallback failed: ${n instanceof Error?n.message:n}`),[]}}g(F,"changedFromActions");function A(t,n,i){let r;if(i.source==="actions")r=F(n);else{const s=(0,S.getChangedPaths)(t,i.commitDepth);r=s===null?F(n):s}const e=new Set;for(const s of r){const l=K((0,o.isAbsolute)(s)?s:(0,o.resolve)(t,s)),c=(0,o.relative)(t,l);c.length===0||c.startsWith("..")||(0,o.isAbsolute)(c)||c.split(o.sep).includes(b)||e.add(l)}return[...e]}g(A,"collectChangedPaths");function P(t,n){const i=new Map;for(const r of n){let e=(0,o.dirname)(r);if(!(e!==t&&!Q(t,e)))for(;;){const s=(0,o.join)(e,b,v);if(!i.has(s)&&(0,D.existsSync)(s))try{const c=(0,D.readFileSync)(s,"utf-8"),m=(0,o.relative)(t,e),d=m.length===0?"":m.split(o.sep).join("/"),u=d.length===0?0:d.split("/").length;i.set(s,{absPath:s,relDir:d,depth:u,content:c})}catch(c){h.logger.debug(`verification-context: failed to read ${s}: ${c instanceof Error?c.message:c}`)}if(e===t)break;const l=(0,o.dirname)(e);if(l===e)break;e=l}}return[...i.values()].sort((r,e)=>r.depth-e.depth||r.relDir.localeCompare(e.relDir))}g(P,"resolveContextFiles");function X(t){return t.relDir.length===0?{label:"(repo root)",path:`${b}/${v}`}:{label:`${t.relDir}/`,path:`${t.relDir}/${b}/${v}`}}g(X,"provenance");function E(t){const n=X(t);return`
4
+ `;function v(t){return Buffer.byteLength(t,"utf-8")}g(v,"byteLen");function K(t){try{return(0,D.realpathSync)(t)}catch{return(0,o.resolve)(t)}}g(K,"canonicalDir");function Q(t){const n=(0,o.resolve)(t),i=[];let r=n;for(;;)try{const e=(0,D.realpathSync)(r);return i.length>0?(0,o.join)(e,...i):e}catch{const e=(0,o.dirname)(r);if(e===r)return n;i.unshift((0,o.basename)(r)),r=e}}g(Q,"canonicalizePath");function X(t,n){const i=(0,o.relative)(t,n);return i.length>0&&!i.startsWith("..")&&!(0,o.isAbsolute)(i)}g(X,"isUnderDir");function F(t){try{return(0,A.getFileChangesSinceLastVerification)(t).map(n=>n.file_path).filter(n=>typeof n=="string"&&n.length>0)}catch(n){return h.logger.debug(`verification-context: actions fallback failed: ${n instanceof Error?n.message:n}`),[]}}g(F,"changedFromActions");function P(t,n,i){let r;if(i.source==="actions")r=F(n);else{const s=(0,w.getChangedPaths)(t,i.commitDepth);r=s===null?F(n):s}const e=new Set;for(const s of r){const l=Q((0,o.isAbsolute)(s)?s:(0,o.resolve)(t,s)),c=(0,o.relative)(t,l);c.length===0||c.startsWith("..")||(0,o.isAbsolute)(c)||c.split(o.sep).includes(b)||e.add(l)}return[...e]}g(P,"collectChangedPaths");function T(t,n){const i=new Map;for(const r of n){let e=(0,o.dirname)(r);if(!(e!==t&&!X(t,e)))for(;;){const s=(0,o.join)(e,b,C);if(!i.has(s)&&(0,D.existsSync)(s))try{const c=(0,D.readFileSync)(s,"utf-8"),m=(0,o.relative)(t,e),d=m.length===0?"":m.split(o.sep).join("/"),f=d.length===0?0:d.split("/").length;i.set(s,{absPath:s,relDir:d,depth:f,content:c})}catch(c){h.logger.debug(`verification-context: failed to read ${s}: ${c instanceof Error?c.message:c}`)}if(e===t)break;const l=(0,o.dirname)(e);if(l===e)break;e=l}}return[...i.values()].sort((r,e)=>r.depth-e.depth||r.relDir.localeCompare(e.relDir))}g(T,"resolveContextFiles");function Y(t){return t.relDir.length===0?{label:"(repo root)",path:`${b}/${C}`}:{label:`${t.relDir}/`,path:`${t.relDir}/${b}/${C}`}}g(Y,"provenance");function E(t){const n=Y(t);return`
5
5
  ## ${n.label} \u2014 ${n.path}
6
6
  ${t.content.trimEnd()}
7
- `}g(E,"renderBlock");const V=100;function T(t,n){if(n.length===0)return"";const i=n.map(s=>(0,o.relative)(t,s).split(o.sep).join("/")).sort(),r=i.slice(0,V),e=i.length>V?`
7
+ `}g(E,"renderBlock");const V=100;function N(t,n){if(n.length===0)return"";const i=n.map(s=>(0,o.relative)(t,s).split(o.sep).join("/")).sort(),r=i.slice(0,V),e=i.length>V?`
8
8
  - \u2026 +${i.length-V} more`:"";return`
9
9
  ## Changed files this cycle (${i.length})
10
10
  ${r.map(s=>`- ${s}`).join(`
11
11
  `)}${e}
12
- `}g(T,"renderChangedPathsBlock");function N(t,n){const i=n.changedPathsBlock??"";if(t.length===0&&i.length===0)return"";const r=[...t].sort((a,$)=>a.depth-$.depth||a.relDir.localeCompare($.relDir)),e=G+J+i,s=Math.max(0,n.maxBytes-C(e)-C(k)),l=[];let c=0;for(let a=r.length-1;a>=0;a--){const $=E(r[a]),x=C($);if(c+x<=s)l.push(r[a]),c+=x;else if(l.length===0){const I=Y(r[a],s);l.push(I);break}else break}const m=l.reverse(),d=r.length-m.length,u=[e];for(const a of m)u.push(E(a));return d>0&&u.push(`
12
+ `}g(N,"renderChangedPathsBlock");function j(t,n){const i=n.changedPathsBlock??"";if(t.length===0&&i.length===0)return"";const r=[...t].sort((a,$)=>a.depth-$.depth||a.relDir.localeCompare($.relDir)),e=J+q+i,s=Math.max(0,n.maxBytes-v(e)-v(k)),l=[];let c=0;for(let a=r.length-1;a>=0;a--){const $=E(r[a]),x=v($);if(c+x<=s)l.push(r[a]),c+=x;else if(l.length===0){const I=Z(r[a],s);l.push(I);break}else break}const m=l.reverse(),d=r.length-m.length,f=[e];for(const a of m)f.push(E(a));return d>0&&f.push(`
13
13
  [${d} less-specific VERIFICATION.md file(s) omitted to fit the ${n.maxBytes}-byte cap]
14
- `),u.push(k),u.join("")}g(N,"buildVerificationContext");function Y(t,n){const i=`
15
- ... (truncated)`,r=E({...t,content:""}),e=Math.max(0,n-C(r)-C(i)),s=Buffer.from(t.content,"utf-8").subarray(0,e).toString("utf-8");return{...t,content:s+i}}g(Y,"hardTruncate");function j(t,n,i){if(!(0,f.getVerificationContextEnabled)(i))return"";try{const r=q(t),e=(0,o.join)(r,".ironbee","sessions",n,"actions.jsonl"),s=(0,f.getVerificationContextSource)(i),l=A(r,e,{source:s,commitDepth:(0,f.getVerificationContextCommitDepth)(i)}),c=l.filter(p=>!(0,f.isIgnoredVerifyPath)(i,p)),m=l.length-c.length,d=new Set;for(const p of c){const R=(0,o.relative)(r,(0,o.dirname)(p)).split(o.sep).join("/");d.add(R.length===0?"(root)":R)}const u=[...d].sort(),a=50,$=u.slice(0,a),x=u.length>a?` [+${u.length-a} more]`:"";h.logger.debug(`verification-context: source=${s} changed in ${u.length} dir(s)`+(m>0?` (${m} ignored)`:"")+`: ${$.join(", ")}${x}`);const I=P(r,c);for(const p of I){const R=p.relDir.length>0?`${p.relDir}/${b}/${v}`:`${b}/${v}`,B=p.content.replace(/\s+/g," ").trim(),_=B.length>100?`${B.slice(0,100)}...`:B;h.logger.debug(`verification-context: \u2022 ${R} \u2014 ${C(p.content)} bytes :: ${_}`)}return N(I,{maxBytes:(0,f.getVerificationContextMaxBytes)(i),changedPathsBlock:T(r,c)})}catch(r){return h.logger.debug(`verification-context: build failed: ${r instanceof Error?r.message:r}`),""}}g(j,"buildVerificationContextForSession");function Z(t){const{projectDir:n,sessionId:i,sessionDir:r,activeVerificationId:e,config:s}=t;if(!e||!(0,f.getVerificationContextEnabled)(s)||(0,O.getContextInjectedVerificationId)(r)===e)return"";let l="";try{l=j(n,i,s)}catch(c){h.logger.debug(`verification-context: once-for-cycle build failed: ${c instanceof Error?c.message:c}`),l=""}if(l.length>0){const c=l.split(`
16
- ## `).length-1;h.logger.debug(`verification-context: injected ${Buffer.byteLength(l,"utf-8")} bytes, ${c} area(s) for cycle ${e}`)}else h.logger.debug(`verification-context: nothing to inject (no changed paths) for cycle ${e}`);return(0,O.setContextInjectedVerificationId)(r,e),l}g(Z,"buildVerificationContextOnceForCycle");0&&(module.exports={VERIFICATION_DOC_DIR,VERIFICATION_DOC_FILE,buildVerificationContext,buildVerificationContextForSession,buildVerificationContextOnceForCycle,collectChangedPaths,renderChangedPathsBlock,resolveContextFiles});
14
+ `),f.push(k),f.join("")}g(j,"buildVerificationContext");function Z(t,n){const i=`
15
+ ... (truncated)`,r=E({...t,content:""}),e=Math.max(0,n-v(r)-v(i)),s=Buffer.from(t.content,"utf-8").subarray(0,e).toString("utf-8");return{...t,content:s+i}}g(Z,"hardTruncate");function _(t,n,i){if(!(0,u.getVerificationContextEnabled)(i))return"";try{const r=K(t),e=(0,o.join)((0,S.sessionDir)(r,n),"actions.jsonl"),s=(0,u.getVerificationContextSource)(i),l=P(r,e,{source:s,commitDepth:(0,u.getVerificationContextCommitDepth)(i)}),c=l.filter(p=>!(0,u.isIgnoredVerifyPath)(i,p)),m=l.length-c.length,d=new Set;for(const p of c){const R=(0,o.relative)(r,(0,o.dirname)(p)).split(o.sep).join("/");d.add(R.length===0?"(root)":R)}const f=[...d].sort(),a=50,$=f.slice(0,a),x=f.length>a?` [+${f.length-a} more]`:"";h.logger.debug(`verification-context: source=${s} changed in ${f.length} dir(s)`+(m>0?` (${m} ignored)`:"")+`: ${$.join(", ")}${x}`);const I=T(r,c);for(const p of I){const R=p.relDir.length>0?`${p.relDir}/${b}/${C}`:`${b}/${C}`,B=p.content.replace(/\s+/g," ").trim(),L=B.length>100?`${B.slice(0,100)}...`:B;h.logger.debug(`verification-context: \u2022 ${R} \u2014 ${v(p.content)} bytes :: ${L}`)}return j(I,{maxBytes:(0,u.getVerificationContextMaxBytes)(i),changedPathsBlock:N(r,c)})}catch(r){return h.logger.debug(`verification-context: build failed: ${r instanceof Error?r.message:r}`),""}}g(_,"buildVerificationContextForSession");function tt(t){const{projectDir:n,sessionId:i,sessionDir:r,activeVerificationId:e,config:s}=t;if(!e||!(0,u.getVerificationContextEnabled)(s)||(0,O.getContextInjectedVerificationId)(r)===e)return"";let l="";try{l=_(n,i,s)}catch(c){h.logger.debug(`verification-context: once-for-cycle build failed: ${c instanceof Error?c.message:c}`),l=""}if(l.length>0){const c=l.split(`
16
+ ## `).length-1;h.logger.debug(`verification-context: injected ${Buffer.byteLength(l,"utf-8")} bytes, ${c} area(s) for cycle ${e}`)}else h.logger.debug(`verification-context: nothing to inject (no changed paths) for cycle ${e}`);return(0,O.setContextInjectedVerificationId)(r,e),l}g(tt,"buildVerificationContextOnceForCycle");0&&(module.exports={VERIFICATION_DOC_DIR,VERIFICATION_DOC_FILE,buildVerificationContext,buildVerificationContextForSession,buildVerificationContextOnceForCycle,collectChangedPaths,renderChangedPathsBlock,resolveContextFiles});
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var a=(r,t)=>s(r,"name",{value:t,configurable:!0});var M=(r,t)=>{for(var e in t)s(r,e,{get:t[e],enumerable:!0})},w=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of I(t))!S.call(r,i)&&i!==e&&s(r,i,{get:()=>t[i],enumerable:!(n=d(t,i))||n.enumerable});return r};var x=r=>w(s({},"__esModule",{value:!0}),r);var _={};M(_,{MARKER_SCHEMA_VERSION:()=>k,markerPath:()=>c,readImportMarker:()=>E,writeImportMarker:()=>y});module.exports=x(_);var o=require("fs"),u=require("path"),m=require("../lib/logger"),f=require("../lib/gitignore");const k="1.0";function c(r,t){return(0,u.join)(r,".ironbee","sessions",t,"imported.json")}a(c,"markerPath");function y(r,t,e,n,i){if(!(0,o.existsSync)(r))return m.logger.debug(`import marker: projectDir ${r} does not exist \u2014 skipping marker write`),!1;(0,f.ensureIronBeeGitignored)(r);const p=c(r,t),l={imported_at:new Date().toISOString(),transcript_path:e,transcript_offset:n,events_sent:i,schema_version:k};try{return(0,o.mkdirSync)((0,u.dirname)(p),{recursive:!0}),(0,o.writeFileSync)(p,JSON.stringify(l,null,2)+`
2
- `),!0}catch(g){return m.logger.debug(`import marker: write ${p} failed: ${g instanceof Error?g.message:g}`),!1}}a(y,"writeImportMarker");function E(r,t){const e=c(r,t);if(!(0,o.existsSync)(e))return null;try{const n=(0,o.readFileSync)(e,"utf-8");return JSON.parse(n)}catch(n){return m.logger.debug(`import marker: read ${e} failed: ${n instanceof Error?n.message:n}`),null}}a(E,"readImportMarker");0&&(module.exports={MARKER_SCHEMA_VERSION,markerPath,readImportMarker,writeImportMarker});
1
+ "use strict";var s=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var a=(r,t)=>s(r,"name",{value:t,configurable:!0});var w=(r,t)=>{for(var e in t)s(r,e,{get:t[e],enumerable:!0})},x=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of S(t))!M.call(r,i)&&i!==e&&s(r,i,{get:()=>t[i],enumerable:!(n=I(t,i))||n.enumerable});return r};var y=r=>x(s({},"__esModule",{value:!0}),r);var v={};w(v,{MARKER_SCHEMA_VERSION:()=>k,markerPath:()=>f,readImportMarker:()=>_,writeImportMarker:()=>E});module.exports=y(v);var o=require("fs"),p=require("path"),m=require("../lib/logger"),c=require("../lib/gitignore"),l=require("../lib/runtime-paths");const k="1.0";function f(r,t){return(0,p.join)((0,l.sessionDir)(r,t),"imported.json")}a(f,"markerPath");function E(r,t,e,n,i){if(!(0,o.existsSync)(r))return m.logger.debug(`import marker: projectDir ${r} does not exist \u2014 skipping marker write`),!1;(0,c.ensureIronBeeGitignored)(r);const u=f(r,t),d={imported_at:new Date().toISOString(),transcript_path:e,transcript_offset:n,events_sent:i,schema_version:k};try{return(0,o.mkdirSync)((0,p.dirname)(u),{recursive:!0}),(0,o.writeFileSync)(u,JSON.stringify(d,null,2)+`
2
+ `),!0}catch(g){return m.logger.debug(`import marker: write ${u} failed: ${g instanceof Error?g.message:g}`),!1}}a(E,"writeImportMarker");function _(r,t){const e=f(r,t);if(!(0,o.existsSync)(e))return null;try{const n=(0,o.readFileSync)(e,"utf-8");return JSON.parse(n)}catch(n){return m.logger.debug(`import marker: read ${e} failed: ${n instanceof Error?n.message:n}`),null}}a(_,"readImportMarker");0&&(module.exports={MARKER_SCHEMA_VERSION,markerPath,readImportMarker,writeImportMarker});
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var t=(n,o)=>e(n,"name",{value:o,configurable:!0});var a=(n,o)=>{for(var s in o)e(n,s,{get:o[s],enumerable:!0})},b=(n,o,s,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of p(o))!u.call(n,i)&&i!==s&&e(n,i,{get:()=>o[i],enumerable:!(r=m(o,i))||r.enumerable});return n};var c=n=>b(e({},"__esModule",{value:!0}),n);var x={};a(x,{shouldSkip:()=>g});module.exports=c(x);var f=require("fs"),l=require("path");function g(n,o,s){if(s)return!1;const r=(0,l.join)(n,".ironbee","sessions",o);return(0,f.existsSync)(r)}t(g,"shouldSkip");0&&(module.exports={shouldSkip});
1
+ "use strict";var e=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var t=(r,o)=>e(r,"name",{value:o,configurable:!0});var u=(r,o)=>{for(var s in o)e(r,s,{get:o[s],enumerable:!0})},c=(r,o,s,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of p(o))!a.call(r,i)&&i!==s&&e(r,i,{get:()=>o[i],enumerable:!(n=l(o,i))||n.enumerable});return r};var g=r=>c(e({},"__esModule",{value:!0}),r);var S={};u(S,{shouldSkip:()=>D});module.exports=g(S);var f=require("fs"),m=require("../lib/runtime-paths");function D(r,o,s){if(s)return!1;const n=(0,m.sessionDir)(r,o);return(0,f.existsSync)(n)}t(D,"shouldSkip");0&&(module.exports={shouldSkip});