issue-flow 0.11.0 → 0.12.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.
- package/README.md +1 -1
- package/dist/{analyze-7B5TORNK.js → analyze-OEET7KGE.js} +17 -11
- package/dist/analyze-OEET7KGE.js.map +1 -0
- package/dist/{apply-WUJHDD7A.js → apply-ZIA3C52S.js} +6 -4
- package/dist/{apply-WUJHDD7A.js.map → apply-ZIA3C52S.js.map} +1 -1
- package/dist/{chunk-6N7LZZ5U.js → chunk-3QHK4YQA.js} +204 -107
- package/dist/chunk-3QHK4YQA.js.map +1 -0
- package/dist/chunk-42PJFMAR.js +605 -0
- package/dist/chunk-42PJFMAR.js.map +1 -0
- package/dist/{chunk-PL6CNMVS.js → chunk-4JSOYE4G.js} +105 -19
- package/dist/chunk-4JSOYE4G.js.map +1 -0
- package/dist/chunk-56KS3TFQ.js +703 -0
- package/dist/chunk-56KS3TFQ.js.map +1 -0
- package/dist/{chunk-AAY6KM7N.js → chunk-73ATPIYX.js} +160 -154
- package/dist/chunk-73ATPIYX.js.map +1 -0
- package/dist/{chunk-MKD2D7WE.js → chunk-A4SLHOW7.js} +70 -13
- package/dist/chunk-A4SLHOW7.js.map +1 -0
- package/dist/chunk-BAUPQXPE.js +173 -0
- package/dist/chunk-BAUPQXPE.js.map +1 -0
- package/dist/{chunk-HC2MT7BX.js → chunk-BYZDPR7N.js} +14 -581
- package/dist/chunk-BYZDPR7N.js.map +1 -0
- package/dist/chunk-CD5ULRVC.js +615 -0
- package/dist/chunk-CD5ULRVC.js.map +1 -0
- package/dist/chunk-DIDUVL6O.js +1365 -0
- package/dist/chunk-DIDUVL6O.js.map +1 -0
- package/dist/{chunk-47VIN33V.js → chunk-EZATO3DW.js} +7 -5
- package/dist/{chunk-47VIN33V.js.map → chunk-EZATO3DW.js.map} +1 -1
- package/dist/{chunk-JW7WLSZ6.js → chunk-FADTCQGM.js} +48 -12
- package/dist/chunk-FADTCQGM.js.map +1 -0
- package/dist/{chunk-GANSDJV7.js → chunk-FJP3UQGD.js} +15 -13
- package/dist/chunk-FJP3UQGD.js.map +1 -0
- package/dist/chunk-KMMASOA6.js +134 -0
- package/dist/chunk-KMMASOA6.js.map +1 -0
- package/dist/{chunk-HQYXVIH6.js → chunk-LAFNLLQP.js} +3 -3
- package/dist/chunk-LWRSMTTZ.js +18 -0
- package/dist/chunk-LWRSMTTZ.js.map +1 -0
- package/dist/{chunk-MSPUB635.js → chunk-M5UCXTIT.js} +15 -12
- package/dist/chunk-M5UCXTIT.js.map +1 -0
- package/dist/chunk-M66SJHQQ.js +206 -0
- package/dist/chunk-M66SJHQQ.js.map +1 -0
- package/dist/{chunk-OBLVLIUS.js → chunk-MJULIKQU.js} +42 -6
- package/dist/chunk-MJULIKQU.js.map +1 -0
- package/dist/{chunk-RKTEV6EG.js → chunk-NS6R37II.js} +4 -4
- package/dist/{run-H75MD5BQ.js → chunk-NTMMF5UD.js} +515 -544
- package/dist/chunk-NTMMF5UD.js.map +1 -0
- package/dist/{chunk-UBIQXCVE.js → chunk-QCPGHBSZ.js} +16 -13
- package/dist/chunk-QCPGHBSZ.js.map +1 -0
- package/dist/{chunk-LVKQ2AKT.js → chunk-TSOLWK7Y.js} +8 -6
- package/dist/chunk-TSOLWK7Y.js.map +1 -0
- package/dist/{chunk-VCKX262Z.js → chunk-XQUSIEKA.js} +13 -10
- package/dist/chunk-XQUSIEKA.js.map +1 -0
- package/dist/chunk-Y5ZDJ4PJ.js +76 -0
- package/dist/chunk-Y5ZDJ4PJ.js.map +1 -0
- package/dist/cli.js +156 -26
- package/dist/cli.js.map +1 -1
- package/dist/{config-4THHOXNN.js → config-PRJGWW7J.js} +15 -3
- package/dist/execute-XBNVL753.js +18 -0
- package/dist/{generate-6RA2MFJB.js → generate-EGB4KV2B.js} +18 -11
- package/dist/generate-EGB4KV2B.js.map +1 -0
- package/dist/init-AJHCXJBP.js +10 -0
- package/dist/operations-BYT626KQ.js +365 -0
- package/dist/operations-BYT626KQ.js.map +1 -0
- package/dist/plan-QOZ3RIO6.js +21 -0
- package/dist/{policy-XQW5NUIE.js → policy-6S4GFC76.js} +6 -4
- package/dist/{policy-XQW5NUIE.js.map → policy-6S4GFC76.js.map} +1 -1
- package/dist/pr-EBBHD2ZX.js +26 -0
- package/dist/pr-review-VVMW5PO4.js +20 -0
- package/dist/prd-JQSZF7PR.js +21 -0
- package/dist/resume-PPCNQVVV.js +221 -0
- package/dist/resume-PPCNQVVV.js.map +1 -0
- package/dist/review-3F6MARWH.js +19 -0
- package/dist/run-RXE5GDQO.js +36 -0
- package/dist/run-RXE5GDQO.js.map +1 -0
- package/dist/state-manager-2EDVDBAR.js +34 -0
- package/dist/state-manager-2EDVDBAR.js.map +1 -0
- package/dist/{web-ANQQTTRD.js → web-EF5WIIGG.js} +13 -8
- package/dist/{web-ANQQTTRD.js.map → web-EF5WIIGG.js.map} +1 -1
- package/package.json +1 -1
- package/prompts/pr.md +11 -4
- package/web/public/app.js +12 -0
- package/dist/analyze-7B5TORNK.js.map +0 -1
- package/dist/chunk-3BOHTH4V.js +0 -58
- package/dist/chunk-3BOHTH4V.js.map +0 -1
- package/dist/chunk-6N7LZZ5U.js.map +0 -1
- package/dist/chunk-AAY6KM7N.js.map +0 -1
- package/dist/chunk-GANSDJV7.js.map +0 -1
- package/dist/chunk-HC2MT7BX.js.map +0 -1
- package/dist/chunk-HDV3YDTG.js +0 -52
- package/dist/chunk-HDV3YDTG.js.map +0 -1
- package/dist/chunk-JW7WLSZ6.js.map +0 -1
- package/dist/chunk-LVKQ2AKT.js.map +0 -1
- package/dist/chunk-MKD2D7WE.js.map +0 -1
- package/dist/chunk-MSPUB635.js.map +0 -1
- package/dist/chunk-OBLVLIUS.js.map +0 -1
- package/dist/chunk-PL6CNMVS.js.map +0 -1
- package/dist/chunk-UBIQXCVE.js.map +0 -1
- package/dist/chunk-VCKX262Z.js.map +0 -1
- package/dist/chunk-VQ5VN7DF.js +0 -1018
- package/dist/chunk-VQ5VN7DF.js.map +0 -1
- package/dist/execute-5OEKLM5X.js +0 -15
- package/dist/generate-6RA2MFJB.js.map +0 -1
- package/dist/init-PRMOTQ7N.js +0 -9
- package/dist/plan-KENR6MJ3.js +0 -17
- package/dist/pr-KDGKG4BP.js +0 -21
- package/dist/pr-review-CAMAB7KO.js +0 -17
- package/dist/prd-V3MWDIHK.js +0 -17
- package/dist/review-7LN47SAN.js +0 -15
- package/dist/run-H75MD5BQ.js.map +0 -1
- /package/dist/{chunk-HQYXVIH6.js.map → chunk-LAFNLLQP.js.map} +0 -0
- /package/dist/{chunk-RKTEV6EG.js.map → chunk-NS6R37II.js.map} +0 -0
- /package/dist/{config-4THHOXNN.js.map → config-PRJGWW7J.js.map} +0 -0
- /package/dist/{execute-5OEKLM5X.js.map → execute-XBNVL753.js.map} +0 -0
- /package/dist/{init-PRMOTQ7N.js.map → init-AJHCXJBP.js.map} +0 -0
- /package/dist/{plan-KENR6MJ3.js.map → plan-QOZ3RIO6.js.map} +0 -0
- /package/dist/{pr-KDGKG4BP.js.map → pr-EBBHD2ZX.js.map} +0 -0
- /package/dist/{pr-review-CAMAB7KO.js.map → pr-review-VVMW5PO4.js.map} +0 -0
- /package/dist/{prd-V3MWDIHK.js.map → prd-JQSZF7PR.js.map} +0 -0
- /package/dist/{review-7LN47SAN.js.map → review-3F6MARWH.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/shutdown.ts","../src/core/watchdog.ts"],"sourcesContent":["/**\n * Graceful shutdown: what a `Ctrl+C` does to a run that has been going for\n * hours.\n *\n * Before this module there was no `SIGINT` handler anywhere in the pipeline —\n * the only one in the project belonged to the web server — so an interrupt\n * killed the process mid-phase: nothing was marked as paused, no `session:end`\n * was published (leaving `session.json` on `running` forever), and the `claude`\n * child was orphaned rather than asked to stop. Resumption then worked by\n * accident, because a stale `in_progress` happens to be treated as \"do this\n * one first\".\n *\n * The sequence here is fixed, and the order is the whole design:\n *\n * 1. **stop accepting new work** — the process-wide `AbortSignal` fires, which\n * is the same signal every retry backoff already waits on, so a run sitting\n * in a two-minute delay stops in that instant instead of two minutes later;\n * 2. **write the checkpoint** — while the child is still alive and the state is\n * still coherent. Checkpointing after the kill would race the very writes it\n * is trying to capture;\n * 3. **ask the child to stop** — `SIGTERM`, then a grace period, then\n * `SIGKILL`. An agent given no chance to finish its sentence leaves a\n * half-written file behind;\n * 4. **close the surfaces** — the journal and the snapshot last, so everything\n * the previous steps published is on disk before the process ends.\n *\n * A second interrupt during the grace ends the process immediately: someone who\n * pressed `Ctrl+C` twice has said what they want, and waiting fifteen more\n * seconds to be polite is not it.\n */\n\n/** How long a child has to exit on its own before it is killed outright. */\nexport const SHUTDOWN_GRACE_MS = 15_000;\n\n/** How often the grace period checks whether the child is gone. */\nconst GRACE_POLL_MS = 100;\n\nexport type ShutdownReason = 'SIGINT' | 'SIGTERM';\n\n/** Exit codes by convention: 128 + the signal number. */\nconst EXIT_CODES: Readonly<Record<ShutdownReason, number>> = { SIGINT: 130, SIGTERM: 143 };\n\n/**\n * A child process the shutdown may terminate.\n *\n * Structural on purpose: an execa subprocess satisfies it without this module\n * depending on execa, and a test satisfies it with two lines.\n */\nexport interface TerminableChild {\n kill(signal?: NodeJS.Signals): boolean;\n /** Resolves once the process has exited, however it exited. Never rejects. */\n done: Promise<unknown>;\n}\n\nexport type ShutdownPhase =\n | /** Persist state. Runs while the child is still alive. */ 'checkpoint'\n | /** Flush and close output surfaces. Runs last. */ 'close';\n\nexport interface ShutdownHook {\n phase: ShutdownPhase;\n run: (reason: ShutdownReason) => void | Promise<void>;\n}\n\nexport interface InstallShutdownOptions {\n /** Grace given to a child between SIGTERM and SIGKILL. */\n graceMs?: number;\n /** Injectable exit, so a test can observe the code without dying. */\n exit?: (code: number) => void;\n /** Where the \"press again\" notice goes. Defaults to stderr. */\n notify?: (message: string) => void;\n /** Injectable signal source, so a test never touches the real process. */\n onSignal?: (signal: ShutdownReason, handler: () => void) => void;\n}\n\nlet controller: AbortController | null = null;\nlet installed = false;\nlet shuttingDown = false;\nlet forced = false;\nconst hooks = new Set<ShutdownHook>();\nconst children = new Set<TerminableChild>();\n\n/**\n * The process-wide abort signal.\n *\n * Created on first use rather than at install time, so a caller that only needs\n * the signal — a retry backoff, say — works identically whether or not handlers\n * were ever installed. That is what keeps every existing test path unchanged.\n */\nexport function getShutdownSignal(): AbortSignal {\n controller ??= new AbortController();\n return controller.signal;\n}\n\n/** Whether a shutdown has begun. New work must not be started after this. */\nexport function isShuttingDown(): boolean {\n return shuttingDown;\n}\n\n/** Register a hook. Returns the function that removes it again. */\nexport function onShutdown(hook: ShutdownHook): () => void {\n hooks.add(hook);\n return () => {\n hooks.delete(hook);\n };\n}\n\n/**\n * Register a child so the shutdown can ask it to stop.\n *\n * The returned function deregisters it, and **must** be called when the child\n * finishes normally: a set that only grows would have the shutdown signalling\n * pids that belong to something else entirely by then.\n */\nexport function registerChild(child: TerminableChild): () => void {\n children.add(child);\n return () => {\n children.delete(child);\n };\n}\n\n/**\n * Install the `SIGINT`/`SIGTERM` handlers, once per process.\n *\n * Idempotent by design: several entry points may call it, and a second set of\n * handlers would run the whole sequence twice — two checkpoints, two kills, two\n * exits.\n */\nexport function installShutdownHandlers(options: InstallShutdownOptions = {}): void {\n if (installed) return;\n installed = true;\n\n const listen =\n options.onSignal ??\n ((signal: ShutdownReason, handler: () => void) => {\n process.on(signal, handler);\n });\n\n for (const signal of ['SIGINT', 'SIGTERM'] as const) {\n listen(signal, () => {\n void beginShutdown(signal, options);\n });\n }\n}\n\n/**\n * Run the shutdown sequence. Exported for the callers that need to trigger it\n * without a signal (a fatal condition, a test).\n */\nexport async function beginShutdown(\n reason: ShutdownReason,\n options: InstallShutdownOptions = {},\n): Promise<void> {\n const exit = options.exit ?? ((code: number) => process.exit(code));\n const notify = options.notify ?? ((message: string) => process.stderr.write(`${message}\\n`));\n\n if (shuttingDown) {\n // Second interrupt. The person has said what they want.\n forced = true;\n killChildren('SIGKILL');\n exit(EXIT_CODES[reason]);\n return;\n }\n\n shuttingDown = true;\n // 1. Stop accepting new work, and cut every pending backoff short.\n getShutdownSignal();\n controller?.abort();\n notify(\n `\\nInterrupted. Saving a checkpoint and stopping the agent (press ${reason === 'SIGINT' ? 'Ctrl+C' : 'the signal'} again to quit now)…`,\n );\n\n // 2. Checkpoint, while the child is still alive and the state is coherent.\n await runHooks('checkpoint', reason, notify);\n\n // 3. Ask the child to stop, then insist.\n await terminateChildren(options.graceMs ?? SHUTDOWN_GRACE_MS);\n\n // 4. Close the output surfaces last, so everything above is on disk.\n await runHooks('close', reason, notify);\n\n exit(EXIT_CODES[reason]);\n}\n\nasync function runHooks(\n phase: ShutdownPhase,\n reason: ShutdownReason,\n notify: (message: string) => void,\n): Promise<void> {\n for (const hook of [...hooks]) {\n if (hook.phase !== phase) continue;\n try {\n await hook.run(reason);\n } catch (err) {\n // A hook that fails must not stop the ones after it: the journal still\n // has to be closed even if the checkpoint could not be written.\n notify(\n `issue-flow: a shutdown step failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n}\n\nfunction killChildren(signal: NodeJS.Signals): void {\n for (const child of [...children]) {\n try {\n child.kill(signal);\n } catch {\n // Already gone. Nothing to do.\n }\n }\n}\n\n/**\n * `SIGTERM`, then wait, then `SIGKILL`.\n *\n * The wait ends early when every child has exited, and immediately when a\n * second interrupt arrives — polling rather than racing the `done` promises so\n * that a child which never settles cannot hold the process open forever.\n */\nasync function terminateChildren(graceMs: number): Promise<void> {\n if (children.size === 0) return;\n\n const pending = [...children];\n let alive = pending.length;\n for (const child of pending) {\n void child.done.then(\n () => {\n alive--;\n },\n () => {\n alive--;\n },\n );\n }\n\n killChildren('SIGTERM');\n\n const deadline = Date.now() + graceMs;\n while (alive > 0 && !forced && Date.now() < deadline) {\n await sleep(GRACE_POLL_MS);\n }\n\n if (alive > 0) killChildren('SIGKILL');\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => {\n const timer = setTimeout(resolve, ms);\n timer.unref?.();\n });\n}\n\n/** Drop every handler, hook and child. For tests only. */\nexport function resetShutdownState(): void {\n controller = null;\n installed = false;\n shuttingDown = false;\n forced = false;\n hooks.clear();\n children.clear();\n}\n","import { SHUTDOWN_GRACE_MS, type TerminableChild } from './shutdown.js';\n\n/**\n * Inactivity watchdog: telling a long task from a stuck one.\n *\n * The pipeline had exactly one instrument for a hung agent — the absolute\n * timeout — and it cannot tell the difference between a phase that has been\n * working hard for fourteen minutes and a phase that has produced nothing for\n * fourteen minutes. The execute loop did not even have that: it runs with\n * `timeout: 0` by design, because its budget is iterations rather than seconds,\n * so a `claude` that hangs without printing anything hangs forever.\n *\n * What separates the two cases is *output*. An agent that is working emits\n * events continuously; one that is stuck emits nothing. So the watchdog watches\n * the stream, not the clock: every event is a heartbeat, and only the **absence**\n * of heartbeats for longer than the limit is a stall.\n *\n * The absolute timeout stays exactly where it was. This is a second, tighter\n * instrument, not a replacement: the ceiling still bounds a task that keeps\n * talking and never finishes.\n */\n\n/** Default silence before a child is considered stuck. */\nexport const DEFAULT_INACTIVITY_TIMEOUT_MS = 600_000;\n\nexport interface WatchdogOptions {\n /** Silence tolerated before the child is stopped. `0` disables the watchdog. */\n inactivityTimeoutMs?: number;\n /** The process to stop. Omitted for a watchdog that only reports. */\n child?: TerminableChild;\n /** Grace between `SIGTERM` and `SIGKILL`. Defaults to the shutdown's. */\n graceMs?: number;\n /** Called once, when the silence limit is crossed. */\n onStall?: (silentMs: number) => void;\n /** Injectable clock, so a test drives the silence without waiting for it. */\n clock?: () => number;\n /** Injectable timer factory, so a test can use fake timers deliberately. */\n setInterval?: (handler: () => void, ms: number) => NodeJS.Timeout;\n clearInterval?: (timer: NodeJS.Timeout) => void;\n}\n\nexport interface Watchdog {\n /** Record a sign of life. Called once per event of the stream. */\n beat(): void;\n /** Whether the watchdog decided the child was stuck. */\n readonly stalled: boolean;\n /** How long the child had been silent when it was judged. */\n readonly silentMs: number;\n /** Stop watching. Idempotent; always call it when the child finishes. */\n stop(): void;\n}\n\n/** How often the silence is measured, as a fraction of the limit. */\nconst CHECK_DIVISOR = 10;\nconst MIN_CHECK_MS = 250;\nconst MAX_CHECK_MS = 5_000;\n\nfunction checkIntervalFor(timeoutMs: number): number {\n return Math.min(MAX_CHECK_MS, Math.max(MIN_CHECK_MS, Math.floor(timeoutMs / CHECK_DIVISOR)));\n}\n\n/**\n * Watch a stream for silence and stop the child when it goes quiet.\n *\n * `inactivityTimeoutMs: 0` returns an inert watchdog: `beat()` is a no-op and\n * nothing is ever killed. That is the documented \"off\" switch, and it is what\n * keeps this feature opt-out without a second code path anywhere else.\n */\nexport function createWatchdog(options: WatchdogOptions = {}): Watchdog {\n const timeoutMs = options.inactivityTimeoutMs ?? DEFAULT_INACTIVITY_TIMEOUT_MS;\n const clock = options.clock ?? Date.now;\n const start = options.setInterval ?? ((handler, ms) => setInterval(handler, ms));\n const clear = options.clearInterval ?? ((timer) => clearInterval(timer));\n\n const state = { stalled: false, silentMs: 0 };\n\n if (timeoutMs <= 0) {\n return {\n beat: () => {},\n stop: () => {},\n get stalled() {\n return state.stalled;\n },\n get silentMs() {\n return state.silentMs;\n },\n };\n }\n\n let lastBeat = clock();\n let timer: NodeJS.Timeout | null = null;\n let killTimer: NodeJS.Timeout | null = null;\n\n const stop = (): void => {\n if (timer !== null) {\n clear(timer);\n timer = null;\n }\n if (killTimer !== null) {\n clearTimeout(killTimer);\n killTimer = null;\n }\n };\n\n const declareStalled = (): void => {\n state.stalled = true;\n state.silentMs = clock() - lastBeat;\n stop();\n options.onStall?.(state.silentMs);\n\n const child = options.child;\n if (child === undefined) return;\n\n // The same courtesy the shutdown extends: ask first, insist after. An agent\n // killed outright mid-write leaves a half-written file behind.\n child.kill('SIGTERM');\n killTimer = setTimeout(() => {\n child.kill('SIGKILL');\n }, options.graceMs ?? SHUTDOWN_GRACE_MS);\n killTimer.unref?.();\n void child.done.then(\n () => {\n if (killTimer !== null) {\n clearTimeout(killTimer);\n killTimer = null;\n }\n },\n () => {},\n );\n };\n\n timer = start(() => {\n if (state.stalled) return;\n if (clock() - lastBeat > timeoutMs) declareStalled();\n }, checkIntervalFor(timeoutMs));\n timer.unref?.();\n\n return {\n beat: () => {\n lastBeat = clock();\n },\n stop,\n get stalled() {\n return state.stalled;\n },\n get silentMs() {\n return state.silentMs;\n },\n };\n}\n\n/**\n * The message a stalled invocation reports.\n *\n * The wording is a contract, exactly like the timeout's: `classify()` reads it\n * as a last resort, and `stalled` has to survive the trip through a plain\n * string so the phase gets its retries.\n */\nexport function describeStall(silentMs: number): string {\n return `claude produced no output for ${Math.round(silentMs / 1000)}s and was stopped (stalled)`;\n}\n"],"mappings":";;;AAgCO,IAAM,oBAAoB;AAGjC,IAAM,gBAAgB;AAKtB,IAAM,aAAuD,EAAE,QAAQ,KAAK,SAAS,IAAI;AAkCzF,IAAI,aAAqC;AACzC,IAAI,YAAY;AAChB,IAAI,eAAe;AACnB,IAAI,SAAS;AACb,IAAM,QAAQ,oBAAI,IAAkB;AACpC,IAAM,WAAW,oBAAI,IAAqB;AASnC,SAAS,oBAAiC;AAC/C,iBAAe,IAAI,gBAAgB;AACnC,SAAO,WAAW;AACpB;AAQO,SAAS,WAAW,MAAgC;AACzD,QAAM,IAAI,IAAI;AACd,SAAO,MAAM;AACX,UAAM,OAAO,IAAI;AAAA,EACnB;AACF;AASO,SAAS,cAAc,OAAoC;AAChE,WAAS,IAAI,KAAK;AAClB,SAAO,MAAM;AACX,aAAS,OAAO,KAAK;AAAA,EACvB;AACF;AASO,SAAS,wBAAwB,UAAkC,CAAC,GAAS;AAClF,MAAI,UAAW;AACf,cAAY;AAEZ,QAAM,SACJ,QAAQ,aACP,CAAC,QAAwB,YAAwB;AAChD,YAAQ,GAAG,QAAQ,OAAO;AAAA,EAC5B;AAEF,aAAW,UAAU,CAAC,UAAU,SAAS,GAAY;AACnD,WAAO,QAAQ,MAAM;AACnB,WAAK,cAAc,QAAQ,OAAO;AAAA,IACpC,CAAC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AACX,cAAQ;AAAA,IACV;AACA,QAAI,cAAc,MAAM;AACtB,mBAAa,SAAS;AACtB,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,QAAM,iBAAiB,MAAY;AACjC,UAAM,UAAU;AAChB,UAAM,WAAW,MAAM,IAAI;AAC3B,SAAK;AACL,YAAQ,UAAU,MAAM,QAAQ;AAEhC,UAAM,QAAQ,QAAQ;AACtB,QAAI,UAAU,OAAW;AAIzB,UAAM,KAAK,SAAS;AACpB,gBAAY,WAAW,MAAM;AAC3B,YAAM,KAAK,SAAS;AAAA,IACtB,GAAG,QAAQ,WAAW,iBAAiB;AACvC,cAAU,QAAQ;AAClB,SAAK,MAAM,KAAK;AAAA,MACd,MAAM;AACJ,YAAI,cAAc,MAAM;AACtB,uBAAa,SAAS;AACtB,sBAAY;AAAA,QACd;AAAA,MACF;AAAA,MACA,MAAM;AAAA,MAAC;AAAA,IACT;AAAA,EACF;AAEA,UAAQ,MAAM,MAAM;AAClB,QAAI,MAAM,QAAS;AACnB,QAAI,MAAM,IAAI,WAAW,UAAW,gBAAe;AAAA,EACrD,GAAG,iBAAiB,SAAS,CAAC;AAC9B,QAAM,QAAQ;AAEd,SAAO;AAAA,IACL,MAAM,MAAM;AACV,iBAAW,MAAM;AAAA,IACnB;AAAA,IACA;AAAA,IACA,IAAI,UAAU;AACZ,aAAO,MAAM;AAAA,IACf;AAAA,IACA,IAAI,WAAW;AACb,aAAO,MAAM;AAAA,IACf;AAAA,EACF;AACF;AASO,SAAS,cAAc,UAA0B;AACtD,SAAO,iCAAiC,KAAK,MAAM,WAAW,GAAI,CAAC;AACrE;","names":["timer"]}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
loadRepositoryPolicy
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EZATO3DW.js";
|
|
5
5
|
import {
|
|
6
|
-
getBaseBranch,
|
|
7
6
|
loadPolicyConfig
|
|
8
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-42PJFMAR.js";
|
|
8
|
+
import {
|
|
9
|
+
getBaseBranch
|
|
10
|
+
} from "./chunk-DIDUVL6O.js";
|
|
11
|
+
import {
|
|
12
|
+
getSessionPublisher
|
|
13
|
+
} from "./chunk-BYZDPR7N.js";
|
|
9
14
|
import {
|
|
10
|
-
getSessionPublisher,
|
|
11
15
|
hasUsageData,
|
|
12
16
|
isoNow,
|
|
17
|
+
parseUsage,
|
|
13
18
|
sumUsage
|
|
14
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-CD5ULRVC.js";
|
|
15
20
|
|
|
16
21
|
// src/core/session-metrics.ts
|
|
17
22
|
function elapsedSecondsSince(startedAtMs) {
|
|
@@ -271,7 +276,38 @@ async function resolvePolicyPlaceholders(options = {}) {
|
|
|
271
276
|
return { ...projection, ...conventionPlaceholders(policy, fallbackBase) };
|
|
272
277
|
}
|
|
273
278
|
|
|
279
|
+
// src/core/stream.ts
|
|
280
|
+
import { createInterface } from "readline";
|
|
281
|
+
async function readClaudeStream(stdout, options = {}) {
|
|
282
|
+
const outcome = { result: "", isError: false, usage: null, events: 0, raw: "" };
|
|
283
|
+
const collected = [];
|
|
284
|
+
const lines = createInterface({ input: stdout });
|
|
285
|
+
for await (const line of lines) {
|
|
286
|
+
options.onLine?.(line);
|
|
287
|
+
if (line.trim() === "") continue;
|
|
288
|
+
outcome.events++;
|
|
289
|
+
collected.push(line);
|
|
290
|
+
let event;
|
|
291
|
+
try {
|
|
292
|
+
event = JSON.parse(line);
|
|
293
|
+
} catch {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
if (typeof event !== "object" || event === null) continue;
|
|
297
|
+
const record = event;
|
|
298
|
+
options.onEvent?.(record);
|
|
299
|
+
if (record.type === "result") {
|
|
300
|
+
outcome.result = typeof record.result === "string" ? record.result : "";
|
|
301
|
+
outcome.isError = record.is_error === true;
|
|
302
|
+
outcome.usage = parseUsage(record) ?? outcome.usage;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
outcome.raw = collected.join("\n");
|
|
306
|
+
return outcome;
|
|
307
|
+
}
|
|
308
|
+
|
|
274
309
|
export {
|
|
310
|
+
readClaudeStream,
|
|
275
311
|
elapsedSecondsSince,
|
|
276
312
|
getRunUsageTotals,
|
|
277
313
|
getPhaseUsageTotals,
|
|
@@ -282,4 +318,4 @@ export {
|
|
|
282
318
|
publishStoryMetrics,
|
|
283
319
|
resolvePolicyPlaceholders
|
|
284
320
|
};
|
|
285
|
-
//# sourceMappingURL=chunk-
|
|
321
|
+
//# sourceMappingURL=chunk-MJULIKQU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/session-metrics.ts","../src/policy/placeholders.ts","../src/core/stream.ts"],"sourcesContent":["import { type ClaudeUsage, hasUsageData, sumUsage } from './metrics.js';\nimport { getSessionPublisher } from './session-publisher.js';\nimport { isoNow } from './state-manager.js';\n\n/**\n * Publication helper for the single-invocation phases (analyze, generate, prd,\n * plan, review, pr, pr-review).\n *\n * Each of them owns its own `runHeadless` call, so the metrics are published\n * from inside the command rather than from the `instrumentedRunners` wrapper in\n * run.ts: the wrapper only sees `() => Promise<void>` and never touches the\n * HeadlessResult. Publishing here also covers standalone invocations\n * (`issue-flow prd 42`), which never go through the pipeline wrapper at all.\n */\n\n/** Whole seconds elapsed since a `Date.now()` mark, never negative. */\nexport function elapsedSecondsSince(startedAtMs: number): number {\n return Math.max(0, Math.round((Date.now() - startedAtMs) / 1000));\n}\n\n/**\n * Process-owned totals, accumulated alongside every published event.\n *\n * The session snapshot cannot be the source of the terminal summary: with web\n * monitoring off the publisher is a `NullPublisher` and its snapshot stays\n * empty, so the numbers would silently vanish exactly in the default mode.\n * These counters live in the process and are therefore independent of any\n * publisher.\n *\n * Only phase- and iteration-scoped usage is recorded. Story metrics are a\n * rateio of an iteration already counted here — adding them would double the\n * totals, the same rule the reducer follows.\n */\ninterface UsageAccumulator {\n all: ClaudeUsage;\n byPhase: Map<string, ClaudeUsage>;\n}\n\nfunction createAccumulator(): UsageAccumulator {\n return { all: {}, byPhase: new Map() };\n}\n\n/**\n * Stack of active accumulators, innermost last.\n *\n * The bottom entry is the process total and always exists. A multi-issue run\n * pushes one accumulator per issue (and one for the whole queue) so the terminal\n * summary of issue B never inherits what issue A spent — the leak `core/CLAUDE.md`\n * warned about when it stated that the module-level counters were safe \"only\n * under the current one-issue-per-process model\".\n *\n * Every publication feeds **all** active accumulators, so a scope is a view of\n * the same events rather than a redirection of them.\n */\nconst scopes: UsageAccumulator[] = [createAccumulator()];\n\n/** Innermost active scope: what `run` and the engine report right now. */\nfunction current(): UsageAccumulator {\n return scopes[scopes.length - 1] as UsageAccumulator;\n}\n\nfunction recordRunUsage(phase: string, usage: ClaudeUsage): void {\n for (const scope of scopes) {\n scope.all = sumUsage(scope.all, usage);\n scope.byPhase.set(phase, sumUsage(scope.byPhase.get(phase), usage));\n }\n}\n\n/** Everything the innermost active scope has spent, across all phases. */\nexport function getRunUsageTotals(): ClaudeUsage {\n return { ...current().all };\n}\n\n/** What a single phase has spent so far. Empty when the phase reported nothing. */\nexport function getPhaseUsageTotals(phase: string): ClaudeUsage {\n return { ...(current().byPhase.get(phase) ?? {}) };\n}\n\n/** A usage scope opened by {@link beginUsageScope}. */\nexport interface UsageScope {\n /** Everything published while this scope was open. */\n totals(): ClaudeUsage;\n /** What one phase published while this scope was open. */\n phaseTotals(phase: string): ClaudeUsage;\n /** Close the scope. Idempotent, and safe to call out of order. */\n end(): ClaudeUsage;\n}\n\n/**\n * Open a nested usage scope, for a run that processes several issues in one\n * process.\n *\n * The scope accumulates only what is published while it is open, which is what\n * lets a queue report a per-issue cost and a consolidated total from the same\n * stream of events. Closing it never discards anything: the outer scopes were\n * fed in parallel.\n */\nexport function beginUsageScope(): UsageScope {\n const accumulator = createAccumulator();\n scopes.push(accumulator);\n let open = true;\n\n return {\n totals: () => ({ ...accumulator.all }),\n phaseTotals: (phase: string) => ({ ...(accumulator.byPhase.get(phase) ?? {}) }),\n end: () => {\n if (open) {\n const index = scopes.indexOf(accumulator);\n // Never pop the process total, even if a caller double-ends a scope.\n if (index > 0) scopes.splice(index, 1);\n open = false;\n }\n return { ...accumulator.all };\n },\n };\n}\n\n/** Test seam: the counters are module state and must be cleared between runs. */\nexport function resetRunUsageTotals(): void {\n scopes.splice(0, scopes.length, createAccumulator());\n}\n\n/**\n * Publish one `metrics:update` event of scope `phase` for a headless\n * invocation.\n *\n * A no-op when the CLI reported no usage at all: an event with every field\n * undefined would bump the snapshot version without adding information, and the\n * reducer would leave every counter at null anyway.\n *\n * A command with more than one invocation (the retrying phases, or `review`\n * inside a correction cycle) calls this once per invocation — the reducer's\n * summing is what turns them into the phase total.\n *\n * Never throws and never returns a value: publishing metrics must not be able\n * to change a command's exit code.\n */\nexport function publishPhaseMetrics(\n phase: string,\n usage: ClaudeUsage | null | undefined,\n startedAtMs?: number,\n): void {\n if (usage == null || !hasUsageData(usage)) return;\n\n recordRunUsage(phase, usage);\n\n getSessionPublisher().publish({\n type: 'metrics:update',\n at: isoNow(),\n scope: 'phase',\n phase,\n ...usage,\n // Informational only: a phase's durationSeconds keeps coming exclusively\n // from phase:start/phase:end, so the reducer ignores this for scope 'phase'.\n durationSeconds: startedAtMs === undefined ? undefined : elapsedSecondsSince(startedAtMs),\n });\n}\n\n/** The execute loop is the only producer of iteration- and story-scoped metrics. */\nexport const EXECUTE_PHASE = 'execute';\n\n/**\n * Publish one `metrics:update` event of scope `iteration` for a pass of the\n * execute loop.\n *\n * Lands on the `execute` phase and on the issue-wide aggregate, exactly like a\n * phase-scoped event: an iteration *is* a slice of the execute phase. Failed\n * iterations (transient or fatal) publish too — those tokens were spent.\n *\n * A no-op when the CLI reported no usage. Never throws.\n */\nexport function publishIterationMetrics(\n iteration: number,\n usage: ClaudeUsage | null | undefined,\n durationSeconds?: number,\n): void {\n if (usage == null || !hasUsageData(usage)) return;\n\n recordRunUsage(EXECUTE_PHASE, usage);\n\n getSessionPublisher().publish({\n type: 'metrics:update',\n at: isoNow(),\n scope: 'iteration',\n phase: EXECUTE_PHASE,\n iteration,\n ...usage,\n // Informational only: the reducer keeps a phase's durationSeconds coming\n // exclusively from phase:start/phase:end.\n durationSeconds,\n });\n}\n\n/**\n * Publish one `metrics:update` event of scope `story`.\n *\n * The values are the rateio of the iteration that completed the story, so the\n * reducer deliberately keeps them off the phase and the aggregate — the\n * iteration event of the same cycle already counted them there.\n *\n * A no-op when there is neither usage nor a duration to report. Never throws.\n */\nexport function publishStoryMetrics(\n storyId: string,\n usage: ClaudeUsage | null | undefined,\n durationSeconds?: number,\n): void {\n if (!hasUsageData(usage) && durationSeconds === undefined) return;\n\n getSessionPublisher().publish({\n type: 'metrics:update',\n at: isoNow(),\n scope: 'story',\n storyId,\n ...(usage ?? {}),\n durationSeconds,\n });\n}\n","import { loadPolicyConfig } from '../config.js';\nimport { getBaseBranch } from '../utils/git.js';\nimport { loadRepositoryPolicy } from './resolve.js';\nimport type { IssueTemplate, PolicyDocument, RepositoryPolicy } from './types.js';\n\n/**\n * Projection of a {@link RepositoryPolicy} onto the prompt placeholders.\n *\n * The prompts receive a **summary**, never the raw files. Dumping\n * `CONTRIBUTING.md` and three `AGENTS.md` into every prompt would cost tokens on\n * every single run and drown the actual instruction — and it would duplicate,\n * inside Issue Flow, a rule that already lives in the repository.\n *\n * The whole projection is empty when the repository declares nothing, which is\n * what lets a prompt render byte for byte as it did before this layer existed.\n */\n\n/** Every placeholder this module produces. Ordered as they appear in a prompt. */\nexport const POLICY_PLACEHOLDER_KEYS = [\n '__REPO_POLICY__',\n '__REPO_ISSUE_TEMPLATES__',\n '__REPO_LABELS__',\n '__REPO_ISSUE_TYPES__',\n '__REPO_PR_TEMPLATE__',\n '__REPO_BASE_BRANCH__',\n '__REPO_CONVENTIONS__',\n '__REPO_DOCS__',\n] as const;\n\nexport type PolicyPlaceholderKey = (typeof POLICY_PLACEHOLDER_KEYS)[number];\n\n/** Every placeholder empty — the projection of \"this repository declares nothing\". */\nexport function emptyPolicyPlaceholders(): Record<string, string> {\n return Object.fromEntries(POLICY_PLACEHOLDER_KEYS.map((key) => [key, ''])) as Record<\n string,\n string\n >;\n}\n\n/**\n * Rough token count of a rendered section.\n *\n * Four characters per token is the usual English/Portuguese approximation and is\n * deliberately crude: the budget exists to stop a policy from swallowing the\n * prompt, not to bill anyone. Erring high is the safe direction, so the estimate\n * rounds up.\n */\nexport function estimateTokens(text: string): number {\n return Math.ceil(text.length / 4);\n}\n\n// ── Section renderers ───────────────────────────────────────────────────────\n\nfunction renderIssueTemplates(templates: IssueTemplate[]): string {\n if (templates.length === 0) return '';\n\n const lines = templates.map((template) => {\n const parts = [`- **${template.name ?? template.path}** (\\`${template.path}\\`)`];\n if (template.type !== null) parts.push(`type: ${template.type}`);\n if (template.labels.length > 0) parts.push(`labels: ${template.labels.join(', ')}`);\n if (template.title !== null) parts.push(`title prefix: \\`${template.title}\\``);\n if (template.about !== null) parts.push(template.about);\n return parts.join(' — ');\n });\n\n return lines.join('\\n');\n}\n\nfunction renderLabels(policy: RepositoryPolicy): string {\n if (policy.issues.labels.length === 0) return '';\n\n return policy.issues.labels\n .map((label) =>\n label.description === null ? `- ${label.name}` : `- ${label.name} — ${label.description}`,\n )\n .join('\\n');\n}\n\nfunction renderConventions(policy: RepositoryPolicy): string {\n const rows: string[] = [];\n if (policy.issues.titleConvention !== null) {\n rows.push(`- Issue title: ${policy.issues.titleConvention}`);\n }\n if (policy.pullRequests.titleConvention !== null) {\n rows.push(`- Pull Request title: ${policy.pullRequests.titleConvention}`);\n }\n if (policy.git.branchConvention !== null) {\n rows.push(`- Branch: ${policy.git.branchConvention}`);\n }\n if (policy.git.commitConvention !== null) {\n rows.push(`- Commit: ${policy.git.commitConvention}`);\n }\n return rows.join('\\n');\n}\n\n/**\n * Paths of the applicable documents — **never their content**.\n *\n * The agent has `Read` and fetches what it needs. Embedding the documents would\n * multiply the cost of every run and, worse, freeze a copy of the repository's\n * own rule inside a prompt.\n */\nfunction renderDocs(docs: PolicyDocument[]): string {\n if (docs.length === 0) return '';\n\n return docs\n .map((doc) => {\n const scope = doc.scope === '' ? '' : ` (applies to \\`${doc.scope}/\\`)`;\n return `- \\`${doc.path}\\`${scope}`;\n })\n .join('\\n');\n}\n\n// ── The budgeted summary ────────────────────────────────────────────────────\n\ninterface Section {\n /** Heading inside the summary. */\n title: string;\n body: string;\n /**\n * Kept whole even when the budget is blown. The essentials are the taxonomy\n * an agent cannot guess: it can re-read a document, but it cannot invent the\n * label a repository actually uses.\n */\n essential: boolean;\n /** Shown in place of the body once the budget is exhausted. */\n pointer: string;\n}\n\n/**\n * Compose `__REPO_POLICY__` within `budgetTokens`.\n *\n * Sections are added whole, in priority order, while they fit. A section that\n * does not fit is replaced **whole** by a pointer to where the agent can read it\n * — nothing is ever cut mid-sentence, because a summary truncated mid-rule is\n * worse than one that says where the rule lives.\n */\nexport function renderPolicySummary(policy: RepositoryPolicy, budgetTokens: number): string {\n const sections: Section[] = [\n {\n title: 'Base branch',\n body: policy.pullRequests.baseBranch ?? '',\n essential: true,\n pointer: '',\n },\n {\n title: 'Conventions',\n body: renderConventions(policy),\n essential: true,\n pointer: '',\n },\n {\n title: 'Issue Types',\n body: policy.issues.types.join(', '),\n essential: true,\n pointer: '',\n },\n {\n title: 'Issue Templates',\n body: renderIssueTemplates(policy.issues.templates),\n essential: true,\n pointer: 'Run `issue-flow policy --json` to read the templates in full.',\n },\n {\n title: 'Labels',\n body: renderLabels(policy),\n essential: true,\n pointer: 'Run `gh label list` to read the labels of this repository.',\n },\n {\n title: 'Pull Request template',\n body: policy.pullRequests.templates[0]?.path ?? '',\n essential: false,\n pointer: '',\n },\n {\n title: 'Policy documents',\n body: renderDocs(policy.docs),\n essential: false,\n pointer: '',\n },\n ];\n\n const rendered: string[] = [];\n let used = 0;\n\n for (const section of sections) {\n if (section.body.trim() === '') continue;\n\n const block = `### ${section.title}\\n\\n${section.body}`;\n const cost = estimateTokens(block);\n\n if (used + cost <= budgetTokens) {\n rendered.push(block);\n used += cost;\n continue;\n }\n\n // Over budget. An essential section keeps its slot as a pointer; a\n // non-essential one simply drops out.\n if (section.essential && section.pointer !== '') {\n const fallback = `### ${section.title}\\n\\n${section.pointer}`;\n rendered.push(fallback);\n used += estimateTokens(fallback);\n }\n }\n\n return rendered.join('\\n\\n');\n}\n\n/** True when the policy carries nothing a prompt could act on. */\nexport function isEmptyPolicy(policy: RepositoryPolicy): boolean {\n return (\n policy.issues.templates.length === 0 &&\n policy.issues.types.length === 0 &&\n policy.issues.labels.length === 0 &&\n policy.issues.titleConvention === null &&\n policy.pullRequests.templates.length === 0 &&\n policy.pullRequests.baseBranch === null &&\n policy.pullRequests.titleConvention === null &&\n policy.git.branchConvention === null &&\n policy.git.commitConvention === null &&\n policy.docs.length === 0\n );\n}\n\nexport interface PolicyPlaceholderOptions {\n /** Token budget for `__REPO_POLICY__`. Defaults to the resolved configuration. */\n budgetTokens?: number;\n}\n\n/**\n * Project a resolved policy onto the prompt placeholders.\n *\n * A `null` policy — or one that carries nothing — yields every placeholder\n * empty, which is what makes the rendered prompt identical to the pre-policy\n * one. This is the contract the whole feature rests on.\n */\nexport function policyPlaceholders(\n policy: RepositoryPolicy | null,\n options: PolicyPlaceholderOptions = {},\n): Record<string, string> {\n if (policy === null || !policy.enabled || isEmptyPolicy(policy)) {\n return emptyPolicyPlaceholders();\n }\n\n const budget = options.budgetTokens ?? DEFAULT_POLICY_CONTEXT_BUDGET;\n\n return {\n __REPO_POLICY__: renderPolicySummary(policy, budget),\n __REPO_ISSUE_TEMPLATES__: renderIssueTemplates(policy.issues.templates),\n __REPO_LABELS__: renderLabels(policy),\n __REPO_ISSUE_TYPES__: policy.issues.types.join(', '),\n // The one place a whole file is projected verbatim: a Pull Request body has\n // to *be* the template, so a summary of it would be useless.\n __REPO_PR_TEMPLATE__: policy.pullRequests.template ?? '',\n __REPO_BASE_BRANCH__: policy.pullRequests.baseBranch ?? '',\n __REPO_CONVENTIONS__: renderConventions(policy),\n __REPO_DOCS__: renderDocs(policy.docs),\n };\n}\n\n/** Default token budget for `__REPO_POLICY__`, overridable via `policy.contextBudget`. */\nexport const DEFAULT_POLICY_CONTEXT_BUDGET = 1500;\n\n// ── Conventions that always have a value ────────────────────────────────────\n\n/** Branch naming Issue Flow has always used, when the repository declares none. */\nexport const DEFAULT_BRANCH_CONVENTION = 'issue/{N}-{slug}';\n\n/**\n * Placeholders that must **never** render empty, because a prompt puts them\n * inside a command it asks the agent to run.\n *\n * `__BASE_BRANCH__` is the reason this group exists separately from the policy\n * projection. `prompts/pr.md` used to spell `main` three times — in\n * `git log main..HEAD`, in `git diff main...HEAD` and in `gh pr create --base\n * main`. In a repository whose base is `develop` that is not a missing feature\n * but an active defect: `main` often *exists* there too, so nothing fails — the\n * agent simply reviews the wrong diff and opens the Pull Request against the\n * wrong target.\n *\n * The resolution order is the repository's declared or discovered base, then\n * `getBaseBranch()`, whose own fallback is `main`. So a repository on `main`\n * renders exactly the text it rendered before.\n */\nexport function conventionPlaceholders(\n policy: RepositoryPolicy | null,\n baseBranchFallback: string,\n): Record<string, string> {\n return {\n __BASE_BRANCH__: policy?.pullRequests.baseBranch ?? baseBranchFallback,\n __BRANCH_CONVENTION__: policy?.git.branchConvention ?? DEFAULT_BRANCH_CONVENTION,\n // The one member of this group that may legitimately render empty: it gates\n // a conditional section rather than sitting inside a command.\n __COMMIT_CONVENTION__: policy?.git.commitConvention ?? '',\n };\n}\n\nexport interface ResolvePolicyPlaceholdersOptions {\n /** Repository root. Defaults to the git project root. */\n root?: string;\n /** Subdirectory the policy applies to, for monorepos. */\n scope?: string | null;\n}\n\n/**\n * Resolve the repository policy and project it, in one call.\n *\n * This is what every command uses. It **never throws and never warns**: a\n * repository that is not a git checkout, a discovery that fails, a `gh` that is\n * not installed — all of them yield the empty projection, and the command runs\n * exactly as it did before.\n *\n * The resolution itself is cached per `(root, scope)` by `loadRepositoryPolicy`,\n * so a pipeline that renders eight prompts still discovers once.\n */\nexport async function resolvePolicyPlaceholders(\n options: ResolvePolicyPlaceholdersOptions = {},\n): Promise<Record<string, string>> {\n let policy: RepositoryPolicy | null = null;\n let projection = emptyPolicyPlaceholders();\n try {\n policy = await loadRepositoryPolicy({ root: options.root, scope: options.scope ?? null });\n const config = await loadPolicyConfig({ projectRoot: policy.root });\n projection = policyPlaceholders(policy, { budgetTokens: config.contextBudget });\n } catch {\n // Discovery is an enrichment; the conventions below still have to resolve.\n policy = null;\n }\n\n let fallbackBase = 'main';\n try {\n fallbackBase = await getBaseBranch();\n } catch {\n // getBaseBranch() does not throw today, but its contract is \"never fails\",\n // and a base branch that cannot be resolved must not cost the whole prompt.\n }\n\n return { ...projection, ...conventionPlaceholders(policy, fallbackBase) };\n}\n","import { createInterface } from 'node:readline';\nimport type { Readable } from 'node:stream';\nimport { type ClaudeUsage, parseUsage } from './metrics.js';\n\n/**\n * Reading the CLI's `stream-json` output.\n *\n * The project used to ask for two different formats depending on whether the\n * user passed `--verbose`: `stream-json` when it had something to print, and a\n * single `json` envelope otherwise. The envelope is one write at the very end,\n * which means the non-verbose path — the common one, and the one that runs\n * unattended for hours — had **no signal at all** while the agent worked. An\n * agent that hung produced exactly the same observable behaviour as one that\n * was thinking.\n *\n * So the stream is now always what is requested, and only the *rendering*\n * differs: verbose prints each event, non-verbose feeds a spinner and a\n * watchdog heartbeat. This module is the half both share — the parsing, the\n * final result and the usage — so neither can drift from the other.\n */\n\n/** What a finished stream yielded. */\nexport interface StreamOutcome {\n /** Assistant text of the `result` event; `''` when none arrived. */\n result: string;\n /** Whether the `result` event reported an error. */\n isError: boolean;\n usage: ClaudeUsage | null;\n /** How many lines were read. `0` means the CLI printed nothing at all. */\n events: number;\n /**\n * Everything the stream printed, joined back together.\n *\n * The fallback for a CLI build that ignores `--output-format` and prints\n * plain text: the stream is consumed by the time the process finishes, so\n * `result.stdout` is empty and this is the only copy of what it said.\n */\n raw: string;\n}\n\nexport interface ReadStreamOptions {\n /** Called for every line, parsed or not. This is the watchdog's heartbeat. */\n onLine?: (line: string) => void;\n /** Called for every event that parsed, after `onLine`. */\n onEvent?: (event: Record<string, unknown>) => void;\n}\n\n/**\n * Consume `stream-json` from `stdout` until it ends.\n *\n * Malformed lines are skipped rather than fatal: the CLI interleaves its own\n * diagnostics with the stream, and a run must not die because one line was not\n * JSON. They still count as activity — a process writing anything is a process\n * that is alive, which is the only question the watchdog is asking.\n */\nexport async function readClaudeStream(\n stdout: Readable,\n options: ReadStreamOptions = {},\n): Promise<StreamOutcome> {\n const outcome: StreamOutcome = { result: '', isError: false, usage: null, events: 0, raw: '' };\n const collected: string[] = [];\n\n const lines = createInterface({ input: stdout });\n for await (const line of lines) {\n options.onLine?.(line);\n if (line.trim() === '') continue;\n outcome.events++;\n collected.push(line);\n\n let event: unknown;\n try {\n event = JSON.parse(line);\n } catch {\n continue;\n }\n if (typeof event !== 'object' || event === null) continue;\n\n const record = event as Record<string, unknown>;\n options.onEvent?.(record);\n\n if (record.type === 'result') {\n outcome.result = typeof record.result === 'string' ? record.result : '';\n outcome.isError = record.is_error === true;\n // Keep the previous metrics when this event carries none, so a malformed\n // trailing result never erases what was already captured.\n outcome.usage = parseUsage(record) ?? outcome.usage;\n }\n }\n\n outcome.raw = collected.join('\\n');\n return outcome;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBO,SAAS,oBAAoB,aAA6B;AAC/D,SAAO,KAAK,IAAI,GAAG,KAAK,OAAO,KAAK,IAAI,IAAI,eAAe,GAAI,CAAC;AAClE;AAoBA,SAAS,oBAAsC;AAC7C,SAAO,EAAE,KAAK,CAAC,GAAG,SAAS,oBAAI,IAAI,EAAE;AACvC;AAcA,IAAM,SAA6B,CAAC,kBAAkB,CAAC;AAGvD,SAAS,UAA4B;AACnC,SAAO,OAAO,OAAO,SAAS,CAAC;AACjC;AAEA,SAAS,eAAe,OAAe,OAA0B;AAC/D,aAAW,SAAS,QAAQ;AAC1B,UAAM,MAAM,SAAS,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ands/init.ts
|
|
10
10
|
import { execa } from "execa";
|
|
@@ -172,7 +172,7 @@ async function runInit(source = "github", options = {}) {
|
|
|
172
172
|
}
|
|
173
173
|
let plan;
|
|
174
174
|
try {
|
|
175
|
-
const { planRepositoryScaffold } = await import("./apply-
|
|
175
|
+
const { planRepositoryScaffold } = await import("./apply-ZIA3C52S.js");
|
|
176
176
|
plan = await planRepositoryScaffold({ scope: options.scope ?? null });
|
|
177
177
|
} catch (err) {
|
|
178
178
|
if (json) {
|
|
@@ -192,7 +192,7 @@ async function runInit(source = "github", options = {}) {
|
|
|
192
192
|
}
|
|
193
193
|
let applied = null;
|
|
194
194
|
if (options.apply === true) {
|
|
195
|
-
const { applyScaffoldPlan } = await import("./apply-
|
|
195
|
+
const { applyScaffoldPlan } = await import("./apply-ZIA3C52S.js");
|
|
196
196
|
applied = await applyScaffoldPlan(plan);
|
|
197
197
|
}
|
|
198
198
|
if (json) {
|
|
@@ -243,4 +243,4 @@ async function runInit(source = "github", options = {}) {
|
|
|
243
243
|
export {
|
|
244
244
|
runInit
|
|
245
245
|
};
|
|
246
|
-
//# sourceMappingURL=chunk-
|
|
246
|
+
//# sourceMappingURL=chunk-NS6R37II.js.map
|