issue-flow 0.15.0 → 0.16.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/dist/{agent-AT64RXTA.js → agent-PMWCDWOW.js} +12 -12
- package/dist/{analyze-O2PYDIFK.js → analyze-556KCJKZ.js} +20 -20
- package/dist/{apply-SSU6QCD4.js → apply-WVV7G7WN.js} +12 -12
- package/dist/{bench-ODFPAGW6.js → bench-UBFGKUHR.js} +18 -18
- package/dist/{chunk-KAHQ6F5C.js → chunk-2H43OVTU.js} +11 -11
- package/dist/{chunk-PCN7ZQND.js → chunk-4FUWWBTP.js} +6 -6
- package/dist/{chunk-5ZKBIXET.js → chunk-73TS2H42.js} +14 -14
- package/dist/{chunk-XLVGPXNL.js → chunk-AOAQU7PD.js} +2 -2
- package/dist/{chunk-6E2PEBFT.js → chunk-BSBJXPLC.js} +8 -8
- package/dist/chunk-C5TL7T4V.js +27 -0
- package/dist/chunk-C5TL7T4V.js.map +1 -0
- package/dist/{chunk-QRCGW2ZO.js → chunk-DBEMD34J.js} +6 -6
- package/dist/{chunk-FK4IDY6P.js → chunk-EPFC4LHT.js} +9 -9
- package/dist/{chunk-AYYMW33T.js → chunk-FKWYD44M.js} +2 -2
- package/dist/{chunk-RWEXK55D.js → chunk-G5LACAXO.js} +2 -2
- package/dist/{chunk-TBDP6QPJ.js → chunk-GPLP7EPL.js} +6 -6
- package/dist/{chunk-ARWNYXFL.js → chunk-GV2DABNZ.js} +12 -12
- package/dist/{chunk-XQHFC62U.js → chunk-GVOZ6NDO.js} +2 -2
- package/dist/{chunk-F4OK7KEP.js → chunk-H3EYBJZU.js} +7 -7
- package/dist/{chunk-3BWZO4YI.js → chunk-IAMIBZRF.js} +2 -2
- package/dist/{chunk-WM3Y7Q4A.js → chunk-J2LJB2OH.js} +10 -10
- package/dist/{chunk-MEFY4B7T.js → chunk-KV2K7MK2.js} +9 -9
- package/dist/{chunk-XG2NYDRA.js → chunk-MCLPSL6B.js} +3 -3
- package/dist/{chunk-ZXPASFHG.js → chunk-MXCOSPLJ.js} +2 -2
- package/dist/{chunk-MROS3SKL.js → chunk-NQCR3HSU.js} +3 -3
- package/dist/{chunk-2ZAM45PZ.js → chunk-OGN2NX57.js} +9 -9
- package/dist/{chunk-A35HE4V7.js → chunk-OGVWJO4S.js} +3 -3
- package/dist/{chunk-HGSYD57B.js → chunk-OLUOZLU5.js} +32 -28
- package/dist/chunk-OLUOZLU5.js.map +1 -0
- package/dist/{chunk-6SRE4KD7.js → chunk-OOX3RMD3.js} +4 -4
- package/dist/{chunk-6FXOU2KR.js → chunk-PGN2VX4Y.js} +6 -6
- package/dist/{chunk-XRLRKTQA.js → chunk-Q2TZA6AC.js} +11 -11
- package/dist/{chunk-XDKGA6UX.js → chunk-QVLIIGBU.js} +5 -2
- package/dist/chunk-QVLIIGBU.js.map +1 -0
- package/dist/{chunk-MGCOQU6N.js → chunk-QZOBR6YF.js} +4 -4
- package/dist/{chunk-UNQYMR3H.js → chunk-R42YHLDV.js} +2 -2
- package/dist/{chunk-6QYMSNVA.js → chunk-ROIIEVZH.js} +3 -2
- package/dist/chunk-ROIIEVZH.js.map +1 -0
- package/dist/{chunk-NVZMBXTE.js → chunk-SVDEWOUD.js} +4 -4
- package/dist/{chunk-ZFIXEYUJ.js → chunk-SW2MF47D.js} +26 -14
- package/dist/chunk-SW2MF47D.js.map +1 -0
- package/dist/{chunk-ZPIVCM7Q.js → chunk-VK65RNFA.js} +3 -3
- package/dist/{chunk-VR34TXHF.js → chunk-VTF4RWS5.js} +6 -6
- package/dist/{chunk-4RXYFWP7.js → chunk-WLJVL25O.js} +4 -4
- package/dist/{chunk-GSZCQUCY.js → chunk-WNROH2YE.js} +2 -2
- package/dist/{chunk-RPXDBX6R.js → chunk-X6GY3CM2.js} +3 -3
- package/dist/{chunk-BMHGRYL6.js → chunk-YA6FWFYW.js} +22 -21
- package/dist/chunk-YA6FWFYW.js.map +1 -0
- package/dist/cli.js +46 -45
- package/dist/cli.js.map +1 -1
- package/dist/{config-UMP6DBJB.js → config-UE7IP36J.js} +11 -11
- package/dist/{conventions-DKH7AE4T.js → conventions-Z3QC2NSG.js} +13 -13
- package/dist/{diagnostics-GOGCLTRS.js → diagnostics-2Z5HFQOO.js} +6 -6
- package/dist/execute-QYLJ5L4T.js +36 -0
- package/dist/{generate-AGBT7EHX.js → generate-PB4L7V5N.js} +20 -20
- package/dist/{git-AC542GU2.js → git-7MUOGVRG.js} +2 -2
- package/dist/init-XBERAZ4O.js +24 -0
- package/dist/{operations-JQYK2EMT.js → operations-QDJAFZUN.js} +13 -13
- package/dist/{permissions-6HL52K54.js → permissions-XVXXENVP.js} +3 -3
- package/dist/plan-RXOW32KY.js +34 -0
- package/dist/{policy-IMRXGG7X.js → policy-6WQZB6B2.js} +12 -12
- package/dist/pr-3WFYAVA7.js +39 -0
- package/dist/pr-review-RK63ZEMM.js +32 -0
- package/dist/prd-LRV6IW3E.js +33 -0
- package/dist/{ps-KUUZ6TUL.js → ps-CX7756QG.js} +10 -10
- package/dist/{recorder-BJ2KIAWT.js → recorder-RK6XZYF3.js} +5 -5
- package/dist/{registry-SB7XTMGE.js → registry-POSB35Q4.js} +5 -5
- package/dist/{resume-QNLQSCR5.js → resume-OQJZV3JH.js} +37 -36
- package/dist/{resume-QNLQSCR5.js.map → resume-OQJZV3JH.js.map} +1 -1
- package/dist/review-AEFISJZD.js +35 -0
- package/dist/{routing-TN7GLMGU.js → routing-EA5NJGNU.js} +12 -12
- package/dist/run-HSC7R33Y.js +55 -0
- package/dist/{session-publisher-T7EI3CIP.js → session-publisher-VVXOCJ2S.js} +2 -2
- package/dist/{state-manager-ZEPWTCA6.js → state-manager-TIC73GQY.js} +3 -3
- package/dist/{usage-QL563I7F.js → usage-WDDNSIHP.js} +10 -10
- package/dist/{web-PPSMNTQ6.js → web-IPGY52AK.js} +17 -16
- package/dist/{web-PPSMNTQ6.js.map → web-IPGY52AK.js.map} +1 -1
- package/package.json +1 -1
- package/web/AGENTS.md +5 -0
- package/web/public/app.css +13 -0
- package/web/public/app.js +48 -0
- package/web/public/index.html +6 -2
- package/dist/chunk-6QYMSNVA.js.map +0 -1
- package/dist/chunk-BMHGRYL6.js.map +0 -1
- package/dist/chunk-HGSYD57B.js.map +0 -1
- package/dist/chunk-XDKGA6UX.js.map +0 -1
- package/dist/chunk-ZFIXEYUJ.js.map +0 -1
- package/dist/execute-E3BRMDAQ.js +0 -35
- package/dist/init-LLBVJNPE.js +0 -24
- package/dist/plan-HSLWDJEZ.js +0 -34
- package/dist/pr-6TCZXG6K.js +0 -39
- package/dist/pr-review-6MWJO2NP.js +0 -32
- package/dist/prd-D6YDYAFX.js +0 -33
- package/dist/review-3KJ4BH2V.js +0 -35
- package/dist/run-5EHIFF2V.js +0 -54
- /package/dist/{agent-AT64RXTA.js.map → agent-PMWCDWOW.js.map} +0 -0
- /package/dist/{analyze-O2PYDIFK.js.map → analyze-556KCJKZ.js.map} +0 -0
- /package/dist/{apply-SSU6QCD4.js.map → apply-WVV7G7WN.js.map} +0 -0
- /package/dist/{bench-ODFPAGW6.js.map → bench-UBFGKUHR.js.map} +0 -0
- /package/dist/{chunk-KAHQ6F5C.js.map → chunk-2H43OVTU.js.map} +0 -0
- /package/dist/{chunk-PCN7ZQND.js.map → chunk-4FUWWBTP.js.map} +0 -0
- /package/dist/{chunk-5ZKBIXET.js.map → chunk-73TS2H42.js.map} +0 -0
- /package/dist/{chunk-XLVGPXNL.js.map → chunk-AOAQU7PD.js.map} +0 -0
- /package/dist/{chunk-6E2PEBFT.js.map → chunk-BSBJXPLC.js.map} +0 -0
- /package/dist/{chunk-QRCGW2ZO.js.map → chunk-DBEMD34J.js.map} +0 -0
- /package/dist/{chunk-FK4IDY6P.js.map → chunk-EPFC4LHT.js.map} +0 -0
- /package/dist/{chunk-AYYMW33T.js.map → chunk-FKWYD44M.js.map} +0 -0
- /package/dist/{chunk-RWEXK55D.js.map → chunk-G5LACAXO.js.map} +0 -0
- /package/dist/{chunk-TBDP6QPJ.js.map → chunk-GPLP7EPL.js.map} +0 -0
- /package/dist/{chunk-ARWNYXFL.js.map → chunk-GV2DABNZ.js.map} +0 -0
- /package/dist/{chunk-XQHFC62U.js.map → chunk-GVOZ6NDO.js.map} +0 -0
- /package/dist/{chunk-F4OK7KEP.js.map → chunk-H3EYBJZU.js.map} +0 -0
- /package/dist/{chunk-3BWZO4YI.js.map → chunk-IAMIBZRF.js.map} +0 -0
- /package/dist/{chunk-WM3Y7Q4A.js.map → chunk-J2LJB2OH.js.map} +0 -0
- /package/dist/{chunk-MEFY4B7T.js.map → chunk-KV2K7MK2.js.map} +0 -0
- /package/dist/{chunk-XG2NYDRA.js.map → chunk-MCLPSL6B.js.map} +0 -0
- /package/dist/{chunk-ZXPASFHG.js.map → chunk-MXCOSPLJ.js.map} +0 -0
- /package/dist/{chunk-MROS3SKL.js.map → chunk-NQCR3HSU.js.map} +0 -0
- /package/dist/{chunk-2ZAM45PZ.js.map → chunk-OGN2NX57.js.map} +0 -0
- /package/dist/{chunk-A35HE4V7.js.map → chunk-OGVWJO4S.js.map} +0 -0
- /package/dist/{chunk-6SRE4KD7.js.map → chunk-OOX3RMD3.js.map} +0 -0
- /package/dist/{chunk-6FXOU2KR.js.map → chunk-PGN2VX4Y.js.map} +0 -0
- /package/dist/{chunk-XRLRKTQA.js.map → chunk-Q2TZA6AC.js.map} +0 -0
- /package/dist/{chunk-MGCOQU6N.js.map → chunk-QZOBR6YF.js.map} +0 -0
- /package/dist/{chunk-UNQYMR3H.js.map → chunk-R42YHLDV.js.map} +0 -0
- /package/dist/{chunk-NVZMBXTE.js.map → chunk-SVDEWOUD.js.map} +0 -0
- /package/dist/{chunk-ZPIVCM7Q.js.map → chunk-VK65RNFA.js.map} +0 -0
- /package/dist/{chunk-VR34TXHF.js.map → chunk-VTF4RWS5.js.map} +0 -0
- /package/dist/{chunk-4RXYFWP7.js.map → chunk-WLJVL25O.js.map} +0 -0
- /package/dist/{chunk-GSZCQUCY.js.map → chunk-WNROH2YE.js.map} +0 -0
- /package/dist/{chunk-RPXDBX6R.js.map → chunk-X6GY3CM2.js.map} +0 -0
- /package/dist/{config-UMP6DBJB.js.map → config-UE7IP36J.js.map} +0 -0
- /package/dist/{conventions-DKH7AE4T.js.map → conventions-Z3QC2NSG.js.map} +0 -0
- /package/dist/{diagnostics-GOGCLTRS.js.map → diagnostics-2Z5HFQOO.js.map} +0 -0
- /package/dist/{execute-E3BRMDAQ.js.map → execute-QYLJ5L4T.js.map} +0 -0
- /package/dist/{generate-AGBT7EHX.js.map → generate-PB4L7V5N.js.map} +0 -0
- /package/dist/{git-AC542GU2.js.map → git-7MUOGVRG.js.map} +0 -0
- /package/dist/{init-LLBVJNPE.js.map → init-XBERAZ4O.js.map} +0 -0
- /package/dist/{operations-JQYK2EMT.js.map → operations-QDJAFZUN.js.map} +0 -0
- /package/dist/{permissions-6HL52K54.js.map → permissions-XVXXENVP.js.map} +0 -0
- /package/dist/{plan-HSLWDJEZ.js.map → plan-RXOW32KY.js.map} +0 -0
- /package/dist/{policy-IMRXGG7X.js.map → policy-6WQZB6B2.js.map} +0 -0
- /package/dist/{pr-6TCZXG6K.js.map → pr-3WFYAVA7.js.map} +0 -0
- /package/dist/{pr-review-6MWJO2NP.js.map → pr-review-RK63ZEMM.js.map} +0 -0
- /package/dist/{prd-D6YDYAFX.js.map → prd-LRV6IW3E.js.map} +0 -0
- /package/dist/{ps-KUUZ6TUL.js.map → ps-CX7756QG.js.map} +0 -0
- /package/dist/{recorder-BJ2KIAWT.js.map → recorder-RK6XZYF3.js.map} +0 -0
- /package/dist/{registry-SB7XTMGE.js.map → registry-POSB35Q4.js.map} +0 -0
- /package/dist/{review-3KJ4BH2V.js.map → review-AEFISJZD.js.map} +0 -0
- /package/dist/{routing-TN7GLMGU.js.map → routing-EA5NJGNU.js.map} +0 -0
- /package/dist/{run-5EHIFF2V.js.map → run-HSC7R33Y.js.map} +0 -0
- /package/dist/{session-publisher-T7EI3CIP.js.map → session-publisher-VVXOCJ2S.js.map} +0 -0
- /package/dist/{state-manager-ZEPWTCA6.js.map → state-manager-TIC73GQY.js.map} +0 -0
- /package/dist/{usage-QL563I7F.js.map → usage-WDDNSIHP.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/web/lock.ts","../src/web/server.ts"],"sourcesContent":["import { type ChildProcess, spawn as nodeSpawn } from 'node:child_process';\nimport { randomUUID } from 'node:crypto';\nimport { mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport chalk from 'chalk';\nimport { execa } from 'execa';\nimport { isoNow } from '../core/state-manager.js';\n// The liveness probe is shared with `storage/lock.ts`, which generalised this\n// module's guard into run ownership: one definition of \"is that pid alive\",\n// with one place to get the EPERM case right.\nimport { isProcessAlive } from '../storage/lock.js';\nimport { type GetGlobalRootOptions, getGlobalRoot } from '../storage/paths.js';\nimport { type WebLock, webLockSchema } from '../storage/schemas.js';\nimport { printInfo, printWarning } from '../ui/logger.js';\nimport { getPackageVersion } from '../version.js';\nimport { startWebServer, type WebServerHandle, type WebServerOptions } from './server.js';\n\n/**\n * Single-instance guard for the web monitoring server (`~/.issue-flow/web.lock`).\n *\n * A machine runs at most one monitoring server. Two entry points build on top\n * of the same lock:\n *\n * - `ensureSingleWebServer` binds (or reuses) a server **in the calling\n * process**. It is the low-level primitive, used by the `web serve` command\n * (the standalone process that ends up owning the lock) and by this\n * module's own tests. Nothing else should call it directly.\n * - `ensureWebMonitor` (US-002) is what `run`/`execute` call: it reuses an\n * active instance exactly like `ensureSingleWebServer`, but when none\n * exists it spawns `web serve` as a **detached** child instead of binding\n * locally, so the server outlives the pipeline process. Falls back to the\n * legacy in-process `startWebServer` (US-006) when the global storage tree\n * itself is unreachable.\n */\n\n/** Lock file name, sibling of `config.json` at the global storage root. */\nexport const WEB_LOCK_FILENAME = 'web.lock';\nexport const WEB_RESTART_LOCK_FILENAME = 'web.restart.lock';\n\n/** How long a health probe against a candidate instance waits before giving up. */\nconst HEALTH_PROBE_TIMEOUT_MS = 1000;\n\ninterface WebHealth {\n ok: true;\n pid?: number;\n instanceId?: string;\n startedAt?: string;\n uptime?: number;\n version?: string;\n}\n\ninterface ManagedWebInstance {\n lock: WebLock;\n health: WebHealth;\n source: 'lock' | 'port';\n}\n\nexport interface PortOwner {\n pid: number;\n command: string;\n}\n\n/**\n * A process that loses the atomic lock creation retries this many times,\n * waiting for the winner to finish starting up, before giving up.\n */\nconst LOCK_CLAIM_RETRIES = 5;\nconst LOCK_CLAIM_RETRY_DELAY_MS = 100;\n\nexport function getWebLockFile(options: GetGlobalRootOptions = {}): string {\n return join(getGlobalRoot(options), WEB_LOCK_FILENAME);\n}\n\nfunction getWebRestartLockFile(options: GetGlobalRootOptions = {}): string {\n return join(getGlobalRoot(options), WEB_RESTART_LOCK_FILENAME);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/** 0.0.0.0 is not a connectable address; probe loopback instead, same mapping\n * `startWebServer` uses to build its own display URL. */\nfunction probeUrl(host: string, port: number): string {\n const probeHost = host === '0.0.0.0' ? '127.0.0.1' : host;\n return `http://${probeHost}:${port}/api/health`;\n}\n\nasync function probeHealth(host: string, port: number): Promise<WebHealth | null> {\n try {\n const res = await fetch(probeUrl(host, port), {\n signal: AbortSignal.timeout(HEALTH_PROBE_TIMEOUT_MS),\n });\n if (!res.ok) return null;\n const body = (await res.json()) as Record<string, unknown>;\n if (body.ok !== true) return null;\n return {\n ok: true,\n ...(typeof body.pid === 'number' && Number.isInteger(body.pid) && body.pid > 0\n ? { pid: body.pid }\n : {}),\n ...(typeof body.instanceId === 'string' && body.instanceId !== ''\n ? { instanceId: body.instanceId }\n : {}),\n ...(typeof body.startedAt === 'string' && body.startedAt !== ''\n ? { startedAt: body.startedAt }\n : {}),\n ...(typeof body.uptime === 'number' && Number.isFinite(body.uptime)\n ? { uptime: body.uptime }\n : {}),\n ...(typeof body.version === 'string' && body.version !== '' ? { version: body.version } : {}),\n };\n } catch {\n return null;\n }\n}\n\nfunction sameLock(a: WebLock | null, b: WebLock): boolean {\n return (\n a !== null &&\n a.pid === b.pid &&\n a.port === b.port &&\n a.host === b.host &&\n a.startedAt === b.startedAt &&\n a.instanceId === b.instanceId\n );\n}\n\nasync function removeWebLockIfOwned(lockFile: string, expected: WebLock): Promise<void> {\n if (sameLock(await readWebLock(lockFile), expected)) {\n await removeWebLock(lockFile);\n }\n}\n\nasync function inspectProcessCommand(pid: number): Promise<string | null> {\n const invocation =\n process.platform === 'win32'\n ? {\n command: 'powershell.exe',\n args: [\n '-NoProfile',\n '-NonInteractive',\n '-Command',\n `(Get-CimInstance Win32_Process -Filter \"ProcessId = ${pid}\").CommandLine`,\n ],\n }\n : { command: 'ps', args: ['-p', String(pid), '-o', 'command='] };\n try {\n const result = await execa(invocation.command, invocation.args, { reject: false });\n const command = result.stdout.trim();\n return result.exitCode === 0 && command !== '' ? command : null;\n } catch {\n return null;\n }\n}\n\nasync function findListeningProcess(port: number): Promise<PortOwner | null> {\n try {\n let pids: number[];\n if (process.platform === 'win32') {\n const result = await execa(\n 'powershell.exe',\n [\n '-NoProfile',\n '-NonInteractive',\n '-Command',\n `(Get-NetTCPConnection -State Listen -LocalPort ${port} -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess -Unique) -join [Environment]::NewLine`,\n ],\n { reject: false },\n );\n pids = result.stdout\n .split(/\\s+/)\n .map(Number)\n .filter((pid) => Number.isInteger(pid) && pid > 0);\n } else {\n const result = await execa('lsof', ['-nP', '-t', `-iTCP:${port}`, '-sTCP:LISTEN'], {\n reject: false,\n });\n pids = result.stdout\n .split(/\\s+/)\n .map(Number)\n .filter((pid) => Number.isInteger(pid) && pid > 0);\n }\n const unique = [...new Set(pids)];\n if (unique.length !== 1) return null;\n const pid = unique[0] as number;\n const command = await inspectProcessCommand(pid);\n return command === null ? null : { pid, command };\n } catch {\n return null;\n }\n}\n\nfunction isIssueFlowWebServe(owner: PortOwner, port: number): boolean {\n const escapedPort = String(port).replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n return (\n /(?:^|\\s)web\\s+serve(?:\\s|$)/.test(owner.command) &&\n new RegExp(`(?:^|\\\\s)--port(?:=|\\\\s+)${escapedPort}(?:\\\\s|$)`).test(owner.command) &&\n /issue-flow|(?:^|[/\\\\])dist[/\\\\]cli\\.js/.test(owner.command)\n );\n}\n\n/** Malformed content (partial write, older/newer incompatible shape) reads as\n * \"no lock\" — the same degrade-to-absent behavior as `loadGlobalConfig()`. */\nexport async function readWebLock(lockFile: string): Promise<WebLock | null> {\n let raw: string;\n try {\n raw = await readFile(lockFile, 'utf-8');\n } catch {\n return null;\n }\n try {\n const result = webLockSchema.safeParse(JSON.parse(raw));\n return result.success ? result.data : null;\n } catch {\n return null;\n }\n}\n\nexport async function removeWebLock(lockFile: string): Promise<void> {\n try {\n await rm(lockFile, { force: true });\n } catch {\n /* best-effort cleanup */\n }\n}\n\n/**\n * A lock is only trustworthy when both signals agree: the owning process is\n * alive AND it answers `/api/health`. A dead pid is the obvious stale case;\n * a live pid that does not answer covers a process that still exists but\n * crashed before binding, was killed -9 leaving a zombie-adjacent state, or\n * whose port was reclaimed by something else entirely. Either way the lock is\n * removed so the next attempt starts clean instead of looping on it forever.\n */\nexport async function detectActiveInstance(lockFile: string): Promise<WebLock | null> {\n const lock = await readWebLock(lockFile);\n if (lock === null) return null;\n\n const health = isProcessAlive(lock.pid) ? await probeHealth(lock.host, lock.port) : null;\n if (health !== null && (lock.instanceId === undefined || health.instanceId === lock.instanceId)) {\n return lock;\n }\n\n await removeWebLockIfOwned(lockFile, lock);\n return null;\n}\n\n/**\n * Atomic exclusive create: `wx` fails with EEXIST when another process won\n * the race, which is what lets two concurrent invocations agree on a single\n * winner without a separate lock-of-the-lock.\n */\nasync function claimWebLock(lockFile: string, lock: WebLock): Promise<boolean> {\n try {\n await writeFile(lockFile, JSON.stringify(lock, null, 2), { encoding: 'utf-8', flag: 'wx' });\n return true;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'EEXIST') return false;\n throw err;\n }\n}\n\ninterface RestartLock {\n pid: number;\n operationId: string;\n startedAt: string;\n}\n\nasync function readRestartLock(file: string): Promise<RestartLock | null> {\n try {\n const value = JSON.parse(await readFile(file, 'utf-8')) as Record<string, unknown>;\n return typeof value.pid === 'number' &&\n Number.isInteger(value.pid) &&\n value.pid > 0 &&\n typeof value.operationId === 'string' &&\n value.operationId !== '' &&\n typeof value.startedAt === 'string' &&\n value.startedAt !== ''\n ? { pid: value.pid, operationId: value.operationId, startedAt: value.startedAt }\n : null;\n } catch {\n return null;\n }\n}\n\nasync function removeRestartLockIfOwned(file: string, expected: RestartLock): Promise<void> {\n const current = await readRestartLock(file);\n if (current?.operationId === expected.operationId) {\n await rm(file, { force: true }).catch(() => {});\n }\n}\n\nasync function waitForRestart(file: string, timeoutMs: number): Promise<boolean> {\n const deadline = Date.now() + timeoutMs;\n while (Date.now() < deadline) {\n const lock = await readRestartLock(file);\n if (lock === null) {\n // Missing or malformed means there is no owner we can safely wait for.\n // Do not unlink here: a restart may have claimed the path between the\n // read and this branch. The explicit acquirer cleans malformed files.\n return true;\n }\n if (!isProcessAlive(lock.pid)) {\n await removeRestartLockIfOwned(file, lock);\n return true;\n }\n await sleep(LOCK_CLAIM_RETRY_DELAY_MS);\n }\n return false;\n}\n\nasync function acquireRestartLock(\n file: string,\n timeoutMs: number,\n): Promise<{ lock: RestartLock; waited: boolean; release: () => Promise<void> } | null> {\n const deadline = Date.now() + timeoutMs;\n let waited = false;\n while (Date.now() < deadline) {\n const lock: RestartLock = {\n pid: process.pid,\n operationId: randomUUID(),\n startedAt: isoNow(),\n };\n try {\n await writeFile(file, JSON.stringify(lock, null, 2), { encoding: 'utf-8', flag: 'wx' });\n return {\n lock,\n waited,\n release: () => removeRestartLockIfOwned(file, lock),\n };\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== 'EEXIST') return null;\n }\n waited = true;\n const existing = await readRestartLock(file);\n if (existing === null || !isProcessAlive(existing.pid)) {\n if (existing === null) await rm(file, { force: true }).catch(() => {});\n else await removeRestartLockIfOwned(file, existing);\n continue;\n }\n await sleep(LOCK_CLAIM_RETRY_DELAY_MS);\n }\n return null;\n}\n\n/** Handle returned when reusing an already-running instance instead of\n * binding a new one — there is no local `Server` to hold, and closing it\n * must not tear down a server another process owns. */\nfunction reusedHandle(lock: WebLock): WebServerHandle {\n const displayHost = lock.host === '0.0.0.0' ? 'localhost' : lock.host;\n return {\n host: lock.host,\n port: lock.port,\n url: `http://${displayHost}:${lock.port}`,\n instanceId: lock.instanceId ?? `legacy-${lock.pid}-${lock.startedAt}`,\n close: async () => {},\n };\n}\n\n/**\n * Start the web monitoring server, first checking whether a live instance\n * already owns `web.lock` and reusing it instead of binding a second one.\n *\n * The lock is claimed only *after* a successful bind, never before: claiming\n * it with the port the server is about to (but hasn't yet) listen on would\n * make that lock briefly answer no health probe at all, and a concurrent\n * invocation would misread that gap as \"stale\" and delete a perfectly good\n * lock out from under its owner. Binding first also means two invocations\n * racing for the same fixed port never both reach the claim step — the OS\n * itself lets only one `listen()` succeed. The `wx` claim then exists for the\n * remaining race: two invocations that *both* manage to bind (only possible\n * with an ephemeral port) still agree on exactly one winner. The loser closes\n * the server it just opened and defers to whichever lock exists.\n *\n * Returns null exactly when `startWebServer` would: nothing here may affect\n * the pipeline, so a lock we cannot resolve after every retry degrades to \"no\n * server\" rather than throwing.\n */\nexport async function ensureSingleWebServer(\n options: WebServerOptions,\n lockOptions: GetGlobalRootOptions = {},\n): Promise<WebServerHandle | null> {\n const warn = options.warn ?? printWarning;\n const info = options.info ?? printInfo;\n const lockFile = getWebLockFile(lockOptions);\n\n for (let attempt = 0; attempt <= LOCK_CLAIM_RETRIES; attempt++) {\n const active = await detectActiveInstance(lockFile);\n if (active !== null) {\n info(`Reusing existing web monitor at ${reusedHandle(active).url}`);\n return reusedHandle(active);\n }\n\n const handle = await startWebServer(options);\n if (handle === null) {\n // Could not bind. Most likely another instance's listen() won a race\n // on the same fixed port between our detection above and this call —\n // its lock should be visible shortly. Anything else (port taken by an\n // unrelated process, invalid host, ...) fails the same way on the next\n // retry too, and the loop's own limit stops it from spinning forever.\n await sleep(LOCK_CLAIM_RETRY_DELAY_MS);\n continue;\n }\n\n let claimed: boolean;\n try {\n claimed = await claimWebLock(lockFile, {\n pid: process.pid,\n port: handle.port,\n host: handle.host,\n startedAt: isoNow(),\n instanceId: handle.instanceId,\n });\n } catch (err) {\n await handle.close();\n throw err;\n }\n\n if (!claimed) {\n // We bound successfully (an ephemeral port let both of us through),\n // but another invocation's lock got written first. We are not the\n // canonical instance: close what we just opened and defer to it.\n await handle.close();\n await sleep(LOCK_CLAIM_RETRY_DELAY_MS);\n continue;\n }\n\n const originalClose = handle.close;\n handle.close = async () => {\n await originalClose();\n await removeWebLock(lockFile);\n };\n return handle;\n }\n\n warn('Could not determine the web monitor lock ownership. Continuing without the web server.');\n return null;\n}\n\n/** Bounded wait for a freshly spawned `web serve` child to claim the lock. */\nconst DETACHED_CLAIM_TIMEOUT_MS = 5000;\nconst DETACHED_CLAIM_POLL_MS = 150;\n\nexport interface EnsureWebMonitorOptions extends GetGlobalRootOptions {\n /** Injectable for tests. Defaults to `node:child_process`'s `spawn`. */\n spawn?: (\n command: string,\n args: string[],\n options: { detached: true; stdio: 'ignore' },\n ) => ChildProcess;\n /** Node executable to spawn. Defaults to `process.execPath`. */\n execPath?: string;\n /** CLI entry script re-invoked as `<entry> web serve ...`. Defaults to `process.argv[1]`. */\n entryScript?: string;\n /** How long to wait for the spawned instance's lock to become healthy. */\n claimTimeoutMs?: number;\n claimPollIntervalMs?: number;\n /** Explicitly replace any managed monitor before spawning this entry point. */\n restart?: boolean;\n /** Injectable process operations used by restart and orphan recovery tests. */\n kill?: typeof process.kill;\n isAlive?: (pid: number) => boolean;\n findPortOwner?: (port: number) => Promise<PortOwner | null>;\n inspectProcess?: (pid: number) => Promise<string | null>;\n shutdownTimeoutMs?: number;\n restartLockTimeoutMs?: number;\n}\n\ninterface DiscoveryResult {\n instance: ManagedWebInstance | null;\n /** A monitor-like health endpoint answered, but ownership could not be proven. */\n unownedMonitor: boolean;\n}\n\nfunction inferredStartedAt(health: WebHealth): string {\n if (health.startedAt !== undefined) return health.startedAt;\n if (health.uptime !== undefined) {\n return new Date(Date.now() - Math.max(0, health.uptime) * 1000).toISOString();\n }\n return isoNow();\n}\n\nasync function discoverManagedInstance(\n lockFile: string,\n options: WebServerOptions,\n monitorOptions: EnsureWebMonitorOptions,\n): Promise<DiscoveryResult> {\n const existingLock = await readWebLock(lockFile);\n if (existingLock !== null) {\n const health = isProcessAlive(existingLock.pid)\n ? await probeHealth(existingLock.host, existingLock.port)\n : null;\n if (\n health !== null &&\n (existingLock.instanceId === undefined || health.instanceId === existingLock.instanceId)\n ) {\n return { instance: { lock: existingLock, health, source: 'lock' }, unownedMonitor: false };\n }\n await removeWebLockIfOwned(lockFile, existingLock);\n }\n\n // The global storage may have been deleted while the detached process kept\n // running. In that state there is no PID file to consult, so prove both\n // halves independently: an Issue Flow health endpoint and the command line\n // of the sole process listening on the configured port.\n const health = await probeHealth(options.host, options.port);\n if (health === null) return { instance: null, unownedMonitor: false };\n\n const inspect = monitorOptions.inspectProcess ?? inspectProcessCommand;\n let owner: PortOwner | null = null;\n if (health.pid !== undefined) {\n const command = await inspect(health.pid);\n if (command !== null) owner = { pid: health.pid, command };\n }\n owner ??= await (monitorOptions.findPortOwner ?? findListeningProcess)(options.port);\n if (owner === null || !isIssueFlowWebServe(owner, options.port)) {\n return { instance: null, unownedMonitor: true };\n }\n\n const recovered: WebLock = {\n pid: owner.pid,\n port: options.port,\n host: options.host,\n startedAt: inferredStartedAt(health),\n ...(health.instanceId === undefined ? {} : { instanceId: health.instanceId }),\n };\n const claimed = await claimWebLock(lockFile, recovered).catch(() => false);\n if (!claimed) {\n const winner = await readWebLock(lockFile);\n if (winner !== null) {\n const winnerHealth = await probeHealth(winner.host, winner.port);\n if (winnerHealth !== null) {\n return {\n instance: { lock: winner, health: winnerHealth, source: 'lock' },\n unownedMonitor: false,\n };\n }\n }\n }\n return { instance: { lock: recovered, health, source: 'port' }, unownedMonitor: false };\n}\n\nasync function stopManagedInstance(\n instance: ManagedWebInstance,\n lockFile: string,\n options: WebServerOptions,\n monitorOptions: EnsureWebMonitorOptions,\n): Promise<boolean> {\n const info = options.info ?? printInfo;\n const warn = options.warn ?? printWarning;\n const version =\n instance.health.version === undefined ? '' : `, version ${instance.health.version}`;\n info(`Web monitor: stopping previous instance (pid ${instance.lock.pid}${version}).`);\n\n try {\n (monitorOptions.kill ?? process.kill)(instance.lock.pid, 'SIGTERM');\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ESRCH') {\n await removeWebLockIfOwned(lockFile, instance.lock);\n info(`Web monitor: previous pid ${instance.lock.pid} was already gone; stale lock removed.`);\n return true;\n }\n warn(\n `Web monitor: failed to stop pid ${instance.lock.pid} (${err instanceof Error ? err.message : String(err)}). Continuing the pipeline without restarting it.`,\n );\n return false;\n }\n\n const isAlive = monitorOptions.isAlive ?? isProcessAlive;\n const deadline = Date.now() + (monitorOptions.shutdownTimeoutMs ?? 5000);\n const pollMs = monitorOptions.claimPollIntervalMs ?? DETACHED_CLAIM_POLL_MS;\n while (Date.now() < deadline) {\n const alive = isAlive(instance.lock.pid);\n const health = alive ? await probeHealth(instance.lock.host, instance.lock.port) : null;\n if (!alive || health === null) {\n await removeWebLockIfOwned(lockFile, instance.lock);\n info(`Web monitor: previous instance stopped (pid ${instance.lock.pid}).`);\n info(\n 'Web monitor: process-local static asset and ETag caches invalidated; no on-disk web build cache exists.',\n );\n return true;\n }\n await sleep(pollMs);\n }\n\n warn(\n `Web monitor: pid ${instance.lock.pid} did not confirm shutdown in time. Continuing the pipeline without starting a competing instance.`,\n );\n return false;\n}\n\nexport type StopWebMonitorResult = 'stopped' | 'not-running' | 'unowned' | 'failed';\n\n/** Stop the managed monitor without starting a replacement. Shared by\n * `web stop` and the restart path so both use identical ownership checks. */\nexport async function stopWebMonitor(\n options: Pick<WebServerOptions, 'port' | 'host' | 'info' | 'warn'>,\n monitorOptions: EnsureWebMonitorOptions = {},\n): Promise<StopWebMonitorResult> {\n const info = options.info ?? printInfo;\n const warn = options.warn ?? printWarning;\n let lockFile: string;\n let restartLockFile: string;\n try {\n await mkdir(getGlobalRoot(monitorOptions), { recursive: true });\n lockFile = getWebLockFile(monitorOptions);\n restartLockFile = getWebRestartLockFile(monitorOptions);\n } catch (err) {\n warn(\n `Web monitor: global storage unavailable (${err instanceof Error ? err.message : String(err)}).`,\n );\n return 'failed';\n }\n\n const lease = await acquireRestartLock(\n restartLockFile,\n monitorOptions.restartLockTimeoutMs ?? 5000,\n );\n if (lease === null) {\n warn('Web monitor: could not acquire the maintenance lock; no process was stopped.');\n return 'failed';\n }\n try {\n const stale = await readWebLock(lockFile);\n const discovered = await discoverManagedInstance(lockFile, options, monitorOptions);\n if (discovered.instance === null) {\n if (stale !== null && !isProcessAlive(stale.pid)) {\n info(`Web monitor: stale lock for dead pid ${stale.pid} removed.`);\n }\n if (discovered.unownedMonitor) {\n warn(\n `Web monitor: port ${options.port} looks like an Issue Flow monitor, but its process ownership could not be verified; it was left untouched.`,\n );\n return 'unowned';\n }\n info('No web monitor is currently running.');\n return 'not-running';\n }\n return (await stopManagedInstance(discovered.instance, lockFile, options, monitorOptions))\n ? 'stopped'\n : 'failed';\n } finally {\n await lease.release();\n }\n}\n\n/**\n * Entry point for `run`/`execute`: get a web monitor without binding one in\n * this process (US-002).\n *\n * 1. Reuse a live, healthy instance exactly like `ensureSingleWebServer`.\n * 2. Otherwise, spawn `<node> <cli> web serve --port … --host … [--refresh …]`\n * detached (`{ detached: true, stdio: 'ignore' }`) and `unref()`ed, so it\n * survives this process exiting and never pipes its own stdio back here.\n * 3. Poll the lock file (bounded) until the spawned instance claims it, then\n * return a *reused* handle for it — this process never owns that `Server`,\n * the same shape `ensureSingleWebServer`'s reuse path already returns.\n *\n * Two failure modes degrade gracefully rather than affecting the pipeline:\n * the global storage tree being unreachable (no resolvable home directory)\n * falls back to `startWebServer` bound right here, exactly the pre-US-001\n * behavior (US-006); a spawn or claim failure with the storage tree otherwise\n * healthy just returns null, same contract `startWebServer` itself has.\n */\nexport async function ensureWebMonitor(\n options: WebServerOptions,\n monitorOptions: EnsureWebMonitorOptions = {},\n): Promise<WebServerHandle | null> {\n const warn = options.warn ?? printWarning;\n const info = options.info ?? printInfo;\n\n let lockFile: string;\n let restartLockFile: string;\n try {\n await mkdir(getGlobalRoot(monitorOptions), { recursive: true });\n lockFile = getWebLockFile(monitorOptions);\n restartLockFile = getWebRestartLockFile(monitorOptions);\n } catch (err) {\n warn(\n `Web monitor: global storage unavailable (${err instanceof Error ? err.message : String(err)}). Falling back to legacy in-process mode.`,\n );\n return startWebServer(options);\n }\n\n const coordinationTimeout = monitorOptions.restartLockTimeoutMs ?? 5000;\n const restartRequestedAt = Date.now();\n const restartLease = monitorOptions.restart\n ? await acquireRestartLock(restartLockFile, coordinationTimeout)\n : null;\n if (monitorOptions.restart && restartLease === null) {\n warn(\n 'Web monitor: could not acquire the restart lock. Continuing the pipeline without changing the server.',\n );\n return null;\n }\n if (!monitorOptions.restart && !(await waitForRestart(restartLockFile, coordinationTimeout))) {\n warn(\n 'Web monitor: another restart is still in progress. Continuing the pipeline without starting a competing instance.',\n );\n return null;\n }\n\n try {\n const discovered = await discoverManagedInstance(lockFile, options, monitorOptions);\n const active = discovered.instance;\n if (\n monitorOptions.restart &&\n restartLease?.waited === true &&\n active !== null &&\n Date.parse(active.lock.startedAt) >= restartRequestedAt\n ) {\n info(\n `Web monitor: a concurrent restart already started pid ${active.lock.pid}; reusing ${reusedHandle(active.lock).url}`,\n );\n return reusedHandle(active.lock);\n }\n\n if (active !== null && !monitorOptions.restart) {\n if (active.source === 'port') {\n info(\n `Recovered orphaned web monitor pid ${active.lock.pid} on port ${active.lock.port} and restored web.lock.`,\n );\n }\n const running = active.health.version;\n info(\n `Reusing existing web monitor${running === undefined ? '' : ` v${running}`} at ${chalk.bold.cyan(reusedHandle(active.lock).url)}`,\n );\n // The dashboard is served from the monitor's own memory, so an older\n // process keeps showing an older UI no matter which CLI starts the run.\n // Saying so here is the only moment the user can act on it.\n const current = getPackageVersion();\n if (running !== undefined && running !== current) {\n warn(\n `Web monitor: it runs v${running} and this CLI is v${current}, so the dashboard is the older one. Replace it with --restart-web.`,\n );\n }\n return reusedHandle(active.lock);\n }\n\n if (active !== null && monitorOptions.restart) {\n if (!(await stopManagedInstance(active, lockFile, options, monitorOptions))) return null;\n } else if (discovered.unownedMonitor) {\n warn(\n `Web monitor: port ${options.port} answers an Issue Flow health check, but its owning process could not be verified. It was left untouched and no competing server was started.`,\n );\n return null;\n } else if (monitorOptions.restart) {\n info('Web monitor: no previous managed instance was found; starting a fresh one.');\n info('Web monitor: no on-disk web build cache exists; no files were removed.');\n }\n\n const execPath = monitorOptions.execPath ?? process.execPath;\n const entryScript = monitorOptions.entryScript ?? process.argv[1];\n if (entryScript === undefined) {\n warn('Web monitor: could not determine the CLI entry point to spawn a detached server.');\n return null;\n }\n\n const args = [\n entryScript,\n 'web',\n 'serve',\n '--port',\n String(options.port),\n '--host',\n options.host,\n ];\n if (options.refreshSeconds !== undefined) {\n args.push('--refresh', String(options.refreshSeconds));\n }\n\n const spawnFn = monitorOptions.spawn ?? nodeSpawn;\n try {\n const child = spawnFn(execPath, args, { detached: true, stdio: 'ignore' });\n child.unref();\n } catch (err) {\n warn(\n `Web monitor: failed to start the detached server (${err instanceof Error ? err.message : String(err)}). Continuing without the web server.`,\n );\n return null;\n }\n\n const timeoutMs = monitorOptions.claimTimeoutMs ?? DETACHED_CLAIM_TIMEOUT_MS;\n const pollMs = monitorOptions.claimPollIntervalMs ?? DETACHED_CLAIM_POLL_MS;\n const deadline = Date.now() + timeoutMs;\n while (Date.now() < deadline) {\n const claimed = await detectActiveInstance(lockFile);\n if (claimed !== null) {\n const handle = reusedHandle(claimed);\n const health = await probeHealth(claimed.host, claimed.port);\n if (monitorOptions.restart) {\n const version = health?.version === undefined ? '' : `, version ${health.version}`;\n info(\n `Web monitor: new instance started (pid ${claimed.pid}${version}) at ${chalk.bold.cyan(handle.url)}`,\n );\n } else {\n info(`Web monitor running at ${chalk.bold.cyan(handle.url)}`);\n }\n return handle;\n }\n await sleep(pollMs);\n }\n\n warn(\n 'Web monitor: the detached server did not start in time. Continuing without the web server.',\n );\n return null;\n } finally {\n await restartLease?.release();\n }\n}\n","import { createHash, randomUUID } from 'node:crypto';\nimport { readFile } from 'node:fs/promises';\nimport { createServer, type IncomingMessage, type Server, type ServerResponse } from 'node:http';\nimport type { AddressInfo } from 'node:net';\nimport { join } from 'node:path';\nimport chalk from 'chalk';\nimport { isAgentPhase, isAgentProviderId } from '../agents/types.js';\nimport { writeAgentPreference } from '../commands/agent.js';\nimport type { JournalEntry } from '../core/journal.js';\nimport { resolvePackageDir } from '../core/prompt-resolver.js';\nimport {\n NullPublisher,\n type SessionPublisher,\n type SessionSnapshot,\n} from '../core/session-state.js';\nimport { readDiagnostics } from '../storage/diagnostics.js';\nimport { printInfo, printWarning } from '../ui/logger.js';\nimport { getPackageVersion } from '../version.js';\nimport type { SessionDirectoryHandle } from './session-directory.js';\n\n/**\n * HTTP server for the web monitoring mode. Plain node:http — no new runtime\n * dependencies. Serves the publisher's in-memory snapshot (it never re-reads\n * issues/N/session.json) and the static UI assets.\n *\n * Resilience contract: nothing here may ever affect the pipeline. Listen\n * failures (EADDRINUSE included) log a warning and the execution continues\n * without a server; the server is unref()'d so it cannot keep the process\n * alive; request handling is wrapped so a handler error answers 500 instead\n * of crashing the process.\n */\n\n/** Max length of `issueDescription` on GET /api/sessions (dashboard preview). */\nexport const SESSION_LIST_DESCRIPTION_MAX = 280;\n\n/** Collapse whitespace and truncate for the sessions list payload. */\nexport function truncateSessionDescription(\n text: string | null | undefined,\n max = SESSION_LIST_DESCRIPTION_MAX,\n): string | null {\n if (text === null || text === undefined) return null;\n const normalized = text.replace(/\\s+/g, ' ').trim();\n if (normalized.length === 0) return normalized;\n if (normalized.length <= max) return normalized;\n return `${normalized.slice(0, max - 1).trimEnd()}…`;\n}\n\nexport interface WebServerOptions {\n /**\n * Legacy single-session mode (pre-US-003, still used by the US-006\n * fallback): serves this publisher's in-memory snapshot directly, with no\n * directory scan and no lock file involved. Mutually exclusive with\n * `sessions` — when both are given, `sessions` wins.\n */\n publisher?: SessionPublisher;\n /**\n * Multi-session mode: sessions discovered by polling the global storage\n * tree (`web/session-directory.ts`). This is what every current entry\n * point (`web serve`) passes; `publisher` only exists for the legacy path.\n */\n sessions?: SessionDirectoryHandle;\n port: number;\n host: string;\n /** Suggested UI polling interval, exposed via /api/health. */\n refreshSeconds?: number;\n /** Package version reported by /api/health. Default: read from package.json. */\n version?: string;\n /** Stable identity for this server process. Default: a fresh UUID at startup. */\n instanceId?: string;\n /** Directory holding index.html/app.css/app.js. Default: auto-resolved. */\n publicDir?: string;\n /** Info logger. Default: printInfo. */\n info?: (message: string) => void;\n /** Warning logger. Default: printWarning. */\n warn?: (message: string) => void;\n /**\n * Whether to `unref()` the underlying socket so it never keeps the process\n * alive on its own. Default `true`, matching the historical contract for a\n * server bound inline in the pipeline process. The standalone `web serve`\n * process (the detached server itself) passes `false`: it has nothing else\n * to do, so staying alive for as long as the server is bound *is* the job.\n */\n unref?: boolean;\n}\n\nexport interface WebServerHandle {\n /**\n * Absent when this handle represents an existing instance reused through\n * `ensureSingleWebServer` (`web/lock.ts`) instead of one bound locally.\n */\n server?: Server;\n /** Host the server is bound to. */\n host: string;\n /** Actual bound port (relevant when options.port is 0). */\n port: number;\n /** Human-facing access URL. */\n url: string;\n /** Identity exposed by health checks and written into web.lock. */\n instanceId: string;\n /** Close the server and release signal handlers. Idempotent, never rejects. */\n close(): Promise<void>;\n}\n\ninterface StaticAsset {\n body: string;\n contentType: string;\n}\n\nconst JSON_TYPE = 'application/json; charset=utf-8';\n\n/**\n * Uniform view over \"whatever sessions this server knows about\", so the route\n * handlers below never care whether they are backed by a single in-memory\n * publisher (legacy mode) or by the global directory scan (US-003/US-004).\n */\ninterface SessionSource {\n /** Every session currently considered active, in no particular order. */\n list(): SessionSnapshot[];\n /** A specific session by id, or undefined when it is not currently active. */\n get(sessionId: string): SessionSnapshot | undefined;\n events(sessionId: string): Promise<JournalEntry[] | undefined>;\n}\n\nfunction publisherSessionSource(publisher: SessionPublisher): SessionSource {\n return {\n list: () => {\n const snapshot = publisher.snapshot();\n return snapshot.sessionId === null ? [] : [snapshot];\n },\n get: (sessionId) => {\n const snapshot = publisher.snapshot();\n return snapshot.sessionId === sessionId ? snapshot : undefined;\n },\n events: async (sessionId) => (publisher.snapshot().sessionId === sessionId ? [] : undefined),\n };\n}\n\nfunction directorySessionSource(handle: SessionDirectoryHandle): SessionSource {\n return {\n list: () => handle.sessions().map((entry) => entry.snapshot),\n get: (sessionId) => handle.getSession(sessionId)?.snapshot,\n events: (sessionId) => handle.events(sessionId),\n };\n}\n\nfunction resolveSessionSource(options: WebServerOptions): SessionSource {\n if (options.sessions) return directorySessionSource(options.sessions);\n return publisherSessionSource(options.publisher ?? new NullPublisher());\n}\n\nconst STATIC_ROUTES: Record<string, { file: string; contentType: string }> = {\n '/': { file: 'index.html', contentType: 'text/html; charset=utf-8' },\n '/app.css': { file: 'app.css', contentType: 'text/css; charset=utf-8' },\n '/app.js': { file: 'app.js', contentType: 'text/javascript; charset=utf-8' },\n};\n\n/** Assets are read once at startup; missing files simply 404. */\nasync function loadStaticAssets(publicDir: string | null): Promise<Map<string, StaticAsset>> {\n const assets = new Map<string, StaticAsset>();\n if (publicDir === null) return assets;\n for (const [route, { file, contentType }] of Object.entries(STATIC_ROUTES)) {\n try {\n const body = await readFile(join(publicDir, file), 'utf-8');\n assets.set(route, { body, contentType });\n } catch {\n // Asset not present (e.g. UI not built yet) — route answers 404.\n }\n }\n return assets;\n}\n\n/** Headers applied to every response, including 304s and errors. */\nfunction baseHeaders(res: ServerResponse, instanceId: string): void {\n res.setHeader('Cache-Control', 'no-store');\n res.setHeader('X-Issue-Flow-Instance', instanceId);\n res.setHeader('X-Content-Type-Options', 'nosniff');\n res.setHeader('Referrer-Policy', 'no-referrer');\n res.setHeader('X-Robots-Tag', 'noindex, nofollow');\n}\n\nfunction respond(res: ServerResponse, status: number, contentType: string, body: string): void {\n res.statusCode = status;\n res.setHeader('Content-Type', contentType);\n res.end(body);\n}\n\nfunction respondJson(res: ServerResponse, status: number, payload: unknown): void {\n respond(res, status, JSON_TYPE, JSON.stringify(payload));\n}\n\nfunction isLoopbackHost(host: string): boolean {\n return host === '127.0.0.1' || host === '::1' || host === 'localhost';\n}\n\nasync function readJsonBody(req: IncomingMessage): Promise<unknown> {\n const chunks: Buffer[] = [];\n let size = 0;\n for await (const chunk of req) {\n const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);\n size += buffer.length;\n if (size > 64 * 1024) throw new Error('Request body too large.');\n chunks.push(buffer);\n }\n return JSON.parse(Buffer.concat(chunks).toString('utf-8') || '{}');\n}\n\n/**\n * Start the monitoring HTTP server. Returns null when the server could not\n * listen (port in use, invalid host, ...) — the pipeline continues without\n * monitoring, it is never brought down by the server.\n */\nexport async function startWebServer(options: WebServerOptions): Promise<WebServerHandle | null> {\n const info = options.info ?? printInfo;\n const warn = options.warn ?? printWarning;\n const version = options.version ?? getPackageVersion();\n const instanceId = options.instanceId ?? randomUUID();\n const startedAtMs = Date.now();\n\n // The UI ships at the package root as web/public/ (sibling of prompts/),\n // resolved the same way from src/ and from the published dist/ layout.\n const assets = await loadStaticAssets(\n options.publicDir ?? resolvePackageDir(join('web', 'public')),\n );\n\n const source = resolveSessionSource(options);\n\n // JSON serialization memoized per session id: an unchanged poll answers 304\n // with an empty body. Content-hashed rather than counter-based, unlike the\n // pre-multi-session version — a directory-backed session has no in-process\n // publisher to hand out a monotonic version(), and a hash works uniformly\n // for both sources.\n const statusCache = new Map<string, { body: string; etag: string }>();\n const statusPayload = (snapshot: SessionSnapshot): { body: string; etag: string } => {\n const key = snapshot.sessionId ?? '';\n const body = JSON.stringify(snapshot);\n const cached = statusCache.get(key);\n if (cached !== undefined && cached.body === body) return cached;\n const etag = `\"${createHash('sha1').update(body).digest('hex')}\"`;\n const entry = { body, etag };\n statusCache.set(key, entry);\n return entry;\n };\n\n const handleRequest = async (req: IncomingMessage, res: ServerResponse): Promise<void> => {\n baseHeaders(res, instanceId);\n\n const requestUrl = new URL(req.url ?? '/', 'http://localhost');\n const path = requestUrl.pathname;\n\n if (req.method === 'POST' && path === '/api/config/agent') {\n if (!isLoopbackHost(options.host)) {\n respondJson(res, 403, {\n error: 'Configuration writes are disabled when the monitor is not bound to loopback.',\n });\n return;\n }\n const body = await readJsonBody(req);\n if (body === null || typeof body !== 'object' || Array.isArray(body)) {\n respondJson(res, 400, { error: 'Expected a JSON object.' });\n return;\n }\n const input = body as { provider?: unknown; model?: unknown; phase?: unknown };\n if (typeof input.provider !== 'string' || !isAgentProviderId(input.provider)) {\n respondJson(res, 400, { error: 'Invalid provider.' });\n return;\n }\n if (\n input.phase !== undefined &&\n (typeof input.phase !== 'string' || !isAgentPhase(input.phase))\n ) {\n respondJson(res, 400, { error: 'Invalid phase.' });\n return;\n }\n if (input.model !== undefined && typeof input.model !== 'string') {\n respondJson(res, 400, { error: 'Invalid model.' });\n return;\n }\n const file = await writeAgentPreference({\n target: 'global',\n provider: input.provider,\n ...(input.model ? { model: input.model } : {}),\n ...(input.phase ? { phase: input.phase } : {}),\n });\n respondJson(res, 200, { ok: true, file, appliesTo: 'future executions' });\n return;\n }\n\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n respondJson(res, 404, { error: 'Not found' });\n return;\n }\n\n if (path === '/api/status' || path === '/status.json') {\n const sessionId = requestUrl.searchParams.get('session');\n let snapshot: SessionSnapshot | undefined;\n if (sessionId !== null) {\n snapshot = source.get(sessionId);\n if (snapshot === undefined) {\n respondJson(res, 404, { error: `No active session with id '${sessionId}'.` });\n return;\n }\n } else {\n // Back-compat shorthand (US-005): with exactly one active session,\n // GET /api/status with no query string still answers it directly, the\n // same behavior a single-session run always had. Zero or several\n // active sessions is genuinely ambiguous without an id and answers an\n // explicit error instead of guessing.\n const active = source.list();\n if (active.length === 0) {\n respondJson(res, 404, {\n error: 'No active session. Pass ?session=<id> — see GET /api/sessions.',\n });\n return;\n }\n if (active.length > 1) {\n respondJson(res, 409, {\n error: 'Multiple active sessions; specify ?session=<id>.',\n sessions: active.map((entry) => entry.sessionId),\n });\n return;\n }\n snapshot = active[0];\n }\n\n const { body, etag } = statusPayload(snapshot);\n res.setHeader('ETag', etag);\n if (req.headers['if-none-match'] === etag) {\n res.statusCode = 304;\n res.end();\n return;\n }\n respond(res, 200, JSON_TYPE, body);\n return;\n }\n\n if (path === '/api/sessions') {\n // Summary fields for the multi-session dashboard (issue #35): the full\n // SessionSnapshot is already in memory, so the client can render cards\n // from this single list without N× /api/status fetches per poll.\n // issueDescription is truncated — cards only need a short preview.\n respondJson(\n res,\n 200,\n source.list().map((snapshot) => ({\n sessionId: snapshot.sessionId,\n issueNumber: snapshot.issue.number,\n issueTitle: snapshot.issue.title,\n issueDescription: truncateSessionDescription(snapshot.issue.description),\n repositoryName: snapshot.repository.name,\n currentPhase: snapshot.currentPhase,\n progressPercent: snapshot.progress.percent,\n elapsedSeconds: snapshot.elapsedSeconds,\n status: snapshot.status,\n startedAt: snapshot.startedAt,\n updatedAt: snapshot.updatedAt,\n // Resilience fields, for a card that has to answer \"is this still\n // moving\" during a six-hour run. `updatedAt` is already the last\n // activity; these two say how hard the run has had to work for it.\n retries: snapshot.execution.retries,\n correctionCycle: snapshot.execution.correctionCycle,\n attempt: snapshot.resilience.attempt,\n provider: snapshot.resilience.provider,\n lastFailureKind: snapshot.resilience.lastFailureKind,\n cooldownUntil: snapshot.resilience.cooldownUntil,\n lastActivityAt: snapshot.resilience.lastActivityAt,\n statusUrl: `/api/status?session=${encodeURIComponent(snapshot.sessionId ?? '')}`,\n eventsUrl: `/api/events?session=${encodeURIComponent(snapshot.sessionId ?? '')}`,\n })),\n );\n return;\n }\n\n if (path === '/api/events') {\n const sessionId = requestUrl.searchParams.get('session');\n if (sessionId === null) {\n respondJson(res, 400, { error: 'Pass ?session=<id>.' });\n return;\n }\n const entries = await source.events(sessionId);\n if (entries === undefined) {\n respondJson(res, 404, { error: `No active session with id '${sessionId}'.` });\n return;\n }\n respondJson(res, 200, entries);\n return;\n }\n\n if (path === '/api/diagnostics') {\n const sessionId = requestUrl.searchParams.get('session') ?? undefined;\n respondJson(res, 200, await readDiagnostics({ sessionId, limit: 500 }));\n return;\n }\n\n if (path === '/api/config') {\n const sessionId = requestUrl.searchParams.get('session');\n const snapshot = sessionId === null ? undefined : source.get(sessionId);\n respondJson(res, 200, {\n effective: snapshot?.configuration ?? null,\n capturedForSession: snapshot?.sessionId ?? null,\n writable: isLoopbackHost(options.host),\n writeScope: 'global preferences for future executions',\n });\n return;\n }\n\n if (path === '/api/health') {\n respondJson(res, 200, {\n ok: true,\n pid: process.pid,\n instanceId,\n startedAt: new Date(startedAtMs).toISOString(),\n uptime: Math.round((Date.now() - startedAtMs) / 1000),\n version,\n refreshSeconds: options.refreshSeconds ?? 5,\n capabilities: isLoopbackHost(options.host) ? ['config:agent:write'] : [],\n });\n return;\n }\n\n const asset = assets.get(path);\n if (asset) {\n respond(res, 200, asset.contentType, asset.body);\n return;\n }\n\n respondJson(res, 404, { error: 'Not found' });\n };\n\n const server = createServer((req, res) => {\n void handleRequest(req, res).catch((err) => {\n try {\n respondJson(res, 500, { error: err instanceof Error ? err.message : String(err) });\n } catch {\n // Response already destroyed — nothing to do, never crash the process.\n }\n });\n });\n\n const listening = await new Promise<boolean>((resolve) => {\n const onError = (err: NodeJS.ErrnoException): void => {\n if (err.code === 'EADDRINUSE') {\n warn(\n `Web monitor port ${options.port} is already in use. Continuing without the web server.`,\n );\n } else {\n warn(`Web monitor failed to start (${err.message}). Continuing without the web server.`);\n }\n resolve(false);\n };\n server.once('error', onError);\n server.listen(options.port, options.host, () => {\n server.removeListener('error', onError);\n resolve(true);\n });\n });\n\n if (!listening) return null;\n\n // Never keep the process alive on its own, unless explicitly told not to\n // unref: the pipeline ending must end the process. The one exception is the\n // detached `web serve` process (options.unref === false) — it has no other\n // work, so staying alive for as long as the server is bound is the point.\n if (options.unref !== false) {\n server.unref();\n }\n // Post-listen errors must never become uncaught exceptions.\n server.on('error', (err) => {\n warn(`Web monitor server error: ${err.message}`);\n });\n\n const address = server.address() as AddressInfo;\n const port = address.port;\n const displayHost = options.host === '0.0.0.0' ? 'localhost' : options.host;\n const url = `http://${displayHost}:${port}`;\n\n if (options.host === '0.0.0.0') {\n warn('Web monitor bound to 0.0.0.0: anyone on your local network can view the session state.');\n }\n info(`Web monitor running at ${chalk.bold.cyan(url)}`);\n\n let closed = false;\n let closePromise: Promise<void> | null = null;\n\n const doClose = (): Promise<void> =>\n new Promise<void>((resolve) => {\n process.removeListener('SIGINT', onSignal);\n process.removeListener('SIGTERM', onSignal);\n server.close(() => resolve());\n // Drop idle keep-alive connections so close() never hangs.\n server.closeAllConnections();\n });\n\n const close = (): Promise<void> => {\n if (closed) return closePromise ?? Promise.resolve();\n closed = true;\n closePromise = doClose();\n return closePromise;\n };\n\n // `handle.close` is built here, but ensureSingleWebServer/ensureWebMonitor\n // and the `web serve` command each wrap it afterwards (to also remove the\n // lock file, stop the session-directory poller, ...). onSignal below calls\n // `handle.close()` — the *current* value of the property — rather than the\n // `close` closed over here, so a `kill -TERM <pid>` (including `issue-flow\n // web stop`) always runs the fully wrapped shutdown, not just this raw\n // socket close. Capturing `close` directly here was a real bug: the wrapped\n // behavior only ever ran for an *explicit* `handle.close()` call, leaving\n // the lock file (and the poller) behind on every signal-driven shutdown.\n const handle: WebServerHandle = { server, host: options.host, port, url, instanceId, close };\n\n // Explicit close on SIGINT/SIGTERM, then re-raise so the default\n // termination behavior still applies.\n const onSignal = (signal: NodeJS.Signals): void => {\n void handle.close().finally(() => {\n process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ACzE,YAAM,MAAM;AAAA,IACd,SAAS,KAAK;AACZ;AAAA,QACE,qDAAqD,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,MACvG;AACA,aAAO;AAAA,IACT;AAEA,UAAM,YAAY,eAAe,kBAAkB;AACnD,UAAM,SAAS,eAAe,uBAAuB;AACrD,UAAM,WAAW,KAAK,IAAI,IAAI;AAC9B,WAAO,KAAK,IAAI,IAAI,UAAU;AAC5B,YAAM,UAAU,MAAM,qBAAqB,QAAQ;AACnD,UAAI,YAAY,MAAM;AACpB,cAAM,SAAS,aAAa,OAAO;AACnC,cAAM,SAAS,MAAM,YAAY,QAAQ,MAAM,QAAQ,IAAI;AAC3D,YAAI,eAAe,SAAS;AAC1B,gBAAM,UAAU,QAAQ,YAAY,SAAY,KAAK,aAAa,OAAO,OAAO;AAChF;AAAA,YACE,0CAA0C,QAAQ,GAAG,GAAG,OAAO,QAAQA,OAAM,KAAK,KAAK,OAAO,GAAG,CAAC;AAAA,UACpG;AAAA,QACF,OAAO;AACL,eAAK,0BAA0BA,OAAM,KAAK,KAAK,OAAO,GAAG,CAAC,EAAE;AAAA,QAC9D;AACA,eAAO;AAAA,MACT;AACA,YAAM,MAAM,MAAM;AAAA,IACpB;AAEA;AAAA,MACE;AAAA,IACF;AACA,WAAO;AAAA,EACT,UAAE;AACA,UAAM,cAAc,QAAQ;AAAA,EAC9B;AACF;","names":["randomUUID","readFile","join","chalk","join","pid","readFile","randomUUID","health","chalk"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getPackageVersion
|
|
4
|
+
} from "./chunk-C5TL7T4V.js";
|
|
2
5
|
import {
|
|
3
6
|
DEFAULT_INACTIVITY_TIMEOUT_MS,
|
|
4
7
|
installShutdownHandlers,
|
|
@@ -9,30 +12,29 @@ import {
|
|
|
9
12
|
setRoutingCliOverrides,
|
|
10
13
|
setVerifyCliOverrides,
|
|
11
14
|
setWebCliOverrides
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-J2LJB2OH.js";
|
|
16
|
+
import "./chunk-VTF4RWS5.js";
|
|
14
17
|
import {
|
|
15
18
|
printError,
|
|
16
19
|
setGlobalTimeout,
|
|
17
20
|
setInactivityTimeout,
|
|
18
21
|
setVerbose
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-SVDEWOUD.js";
|
|
23
|
+
import "./chunk-ROIIEVZH.js";
|
|
24
|
+
import "./chunk-FKWYD44M.js";
|
|
22
25
|
import "./chunk-HAKDLR6N.js";
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-WNROH2YE.js";
|
|
27
|
+
import "./chunk-GPLP7EPL.js";
|
|
25
28
|
import "./chunk-P3LRUNC6.js";
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-R42YHLDV.js";
|
|
30
|
+
import "./chunk-GVOZ6NDO.js";
|
|
28
31
|
import {
|
|
29
32
|
isAgentProviderId
|
|
30
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-QVLIIGBU.js";
|
|
31
34
|
import "./chunk-7Z4Y3VKM.js";
|
|
32
35
|
import "./chunk-XEYH6ZZI.js";
|
|
33
36
|
|
|
34
37
|
// src/cli.ts
|
|
35
|
-
import { createRequire } from "module";
|
|
36
38
|
import { Command, InvalidArgumentError, Option } from "commander";
|
|
37
39
|
|
|
38
40
|
// src/cli-options.ts
|
|
@@ -179,8 +181,7 @@ function resolveResilienceOverrides(flags) {
|
|
|
179
181
|
}
|
|
180
182
|
|
|
181
183
|
// src/cli.ts
|
|
182
|
-
var
|
|
183
|
-
var { version } = require2("../package.json");
|
|
184
|
+
var version = getPackageVersion();
|
|
184
185
|
function parseInteger(value) {
|
|
185
186
|
const parsed = parseInt(value, 10);
|
|
186
187
|
if (Number.isNaN(parsed) || parsed < 0) {
|
|
@@ -352,8 +353,8 @@ withIssueOptions(
|
|
|
352
353
|
)
|
|
353
354
|
).action(
|
|
354
355
|
async (options) => {
|
|
355
|
-
const { loadIssuesConfig } = await import("./config-
|
|
356
|
-
const { runInit } = await import("./init-
|
|
356
|
+
const { loadIssuesConfig } = await import("./config-UE7IP36J.js");
|
|
357
|
+
const { runInit } = await import("./init-XBERAZ4O.js");
|
|
357
358
|
const { preferredProvider } = await loadIssuesConfig();
|
|
358
359
|
const code = await runInit(preferredProvider, {
|
|
359
360
|
...options,
|
|
@@ -375,7 +376,7 @@ withGlobalOptions(
|
|
|
375
376
|
}
|
|
376
377
|
throw error;
|
|
377
378
|
}
|
|
378
|
-
const { runGenerate } = await import("./generate-
|
|
379
|
+
const { runGenerate } = await import("./generate-PB4L7V5N.js");
|
|
379
380
|
const code = await runGenerate(options.prompt, target);
|
|
380
381
|
process.exit(code);
|
|
381
382
|
});
|
|
@@ -418,7 +419,7 @@ withUserStoryNumberingOptions(
|
|
|
418
419
|
}
|
|
419
420
|
throw error;
|
|
420
421
|
}
|
|
421
|
-
const { runPipeline } = await import("./run-
|
|
422
|
+
const { runPipeline } = await import("./run-HSC7R33Y.js");
|
|
422
423
|
const code = await runPipeline(
|
|
423
424
|
issues,
|
|
424
425
|
options.mode,
|
|
@@ -447,7 +448,7 @@ withIssueOptions(
|
|
|
447
448
|
program.command("resume").description("Resume an interrupted pipeline from the phase it stopped at").argument("[issue]", "Issue to resume. Omitted: the most recently attempted one").option("--all", "Resume every unfinished issue of this project, in order").option("--mode <mode>", "Execution mode: auto | manual", "auto")
|
|
448
449
|
)
|
|
449
450
|
).action(async (issue, options) => {
|
|
450
|
-
const { runResume } = await import("./resume-
|
|
451
|
+
const { runResume } = await import("./resume-OQJZV3JH.js");
|
|
451
452
|
const code = await runResume(issue, {
|
|
452
453
|
...options.all === void 0 ? {} : { all: options.all },
|
|
453
454
|
...options.mode === void 0 ? {} : { mode: options.mode }
|
|
@@ -457,7 +458,7 @@ withIssueOptions(
|
|
|
457
458
|
withGlobalOptions(
|
|
458
459
|
program.command("status").description("What is running right now, in which phase, and since when").argument("[issue]", "Restrict the report to one issue").option("--json", "Emit the assembled state as JSON")
|
|
459
460
|
).action(async (issue, options) => {
|
|
460
|
-
const { runStatus } = await import("./operations-
|
|
461
|
+
const { runStatus } = await import("./operations-QDJAFZUN.js");
|
|
461
462
|
process.exit(
|
|
462
463
|
await runStatus(issue, { ...options.json === void 0 ? {} : { json: options.json } })
|
|
463
464
|
);
|
|
@@ -466,7 +467,7 @@ withGlobalOptions(
|
|
|
466
467
|
program.command("usage").description("Aggregate execution telemetry from tasks.json").argument("[issue]", "Restrict the report to one issue").option("--issue <issue>", "Same as the positional argument").option("--since <date>", "Only executions started on or after this ISO date").option("--by <key>", "Group by harness, provider, model, purpose or status").option("--json", "Emit the assembled totals as JSON")
|
|
467
468
|
).action(
|
|
468
469
|
async (issue, options) => {
|
|
469
|
-
const { runUsage, USAGE_GROUP_KEYS } = await import("./usage-
|
|
470
|
+
const { runUsage, USAGE_GROUP_KEYS } = await import("./usage-WDDNSIHP.js");
|
|
470
471
|
const by = options.by;
|
|
471
472
|
if (by !== void 0 && !USAGE_GROUP_KEYS.includes(by)) {
|
|
472
473
|
printError("Must be one of: harness, provider, model, purpose, status.");
|
|
@@ -484,20 +485,20 @@ withGlobalOptions(
|
|
|
484
485
|
withGlobalOptions(
|
|
485
486
|
program.command("ps").description("Every issue-flow run active on this machine").option("--json", "Emit the listing as JSON").option("--watch", "Refresh the listing until interrupted")
|
|
486
487
|
).action(async (options) => {
|
|
487
|
-
const { runPs } = await import("./ps-
|
|
488
|
+
const { runPs } = await import("./ps-CX7756QG.js");
|
|
488
489
|
process.exit(await runPs(options));
|
|
489
490
|
});
|
|
490
491
|
withGlobalOptions(
|
|
491
492
|
program.command("runs").description("History of the runs of this project, with how each ended")
|
|
492
493
|
).action(async () => {
|
|
493
|
-
const { runRuns } = await import("./operations-
|
|
494
|
+
const { runRuns } = await import("./operations-QDJAFZUN.js");
|
|
494
495
|
process.exit(await runRuns());
|
|
495
496
|
});
|
|
496
497
|
withGlobalOptions(
|
|
497
498
|
program.command("logs").description("Read the execution journal (events.jsonl), filtered and readable").argument("[issue]", "Issue to read. Omitted: the most recently attempted one").option("--issue <issue>", "Same as the positional argument").option("--follow", "Keep reading as the journal grows").option("--tail <n>", "How many entries to show first (default 50)", parseInteger).option("--kind <kinds>", "Only these event types, comma separated (retry, phase:end, \u2026)")
|
|
498
499
|
).action(
|
|
499
500
|
async (issue, options) => {
|
|
500
|
-
const { runLogs } = await import("./operations-
|
|
501
|
+
const { runLogs } = await import("./operations-QDJAFZUN.js");
|
|
501
502
|
const kinds = options.kind === void 0 ? void 0 : options.kind.split(",").map((kind) => kind.trim()).filter((kind) => kind !== "");
|
|
502
503
|
process.exit(
|
|
503
504
|
await runLogs(issue ?? options.issue, {
|
|
@@ -511,13 +512,13 @@ withGlobalOptions(
|
|
|
511
512
|
withGlobalOptions(
|
|
512
513
|
program.command("pause").description("Ask the running pipeline to stop after writing a checkpoint")
|
|
513
514
|
).action(async () => {
|
|
514
|
-
const { runPause } = await import("./operations-
|
|
515
|
+
const { runPause } = await import("./operations-QDJAFZUN.js");
|
|
515
516
|
process.exit(await runPause());
|
|
516
517
|
});
|
|
517
518
|
withGlobalOptions(
|
|
518
519
|
program.command("cancel").description("Stop the run and mark the issue so a resume does not pick it up").argument("[issue]", "Issue to cancel. Omitted: the most recently attempted one")
|
|
519
520
|
).action(async (issue) => {
|
|
520
|
-
const { runCancel } = await import("./operations-
|
|
521
|
+
const { runCancel } = await import("./operations-QDJAFZUN.js");
|
|
521
522
|
process.exit(await runCancel(issue));
|
|
522
523
|
});
|
|
523
524
|
withIssueOptions(
|
|
@@ -525,7 +526,7 @@ withIssueOptions(
|
|
|
525
526
|
program.command("analyze").description("Analyze an issue with the configured agent").argument("<issue>", "Issue number")
|
|
526
527
|
)
|
|
527
528
|
).action(async (issue) => {
|
|
528
|
-
const { runAnalyze } = await import("./analyze-
|
|
529
|
+
const { runAnalyze } = await import("./analyze-556KCJKZ.js");
|
|
529
530
|
const code = await runAnalyze(issue);
|
|
530
531
|
process.exit(code);
|
|
531
532
|
});
|
|
@@ -534,7 +535,7 @@ withIssueOptions(
|
|
|
534
535
|
program.command("prd").description("Generate a PRD from an analyzed issue with the configured agent").argument("<issue>", "Issue number")
|
|
535
536
|
)
|
|
536
537
|
).action(async (issue) => {
|
|
537
|
-
const { runPrd } = await import("./prd-
|
|
538
|
+
const { runPrd } = await import("./prd-LRV6IW3E.js");
|
|
538
539
|
const code = await runPrd(issue);
|
|
539
540
|
process.exit(code);
|
|
540
541
|
});
|
|
@@ -555,7 +556,7 @@ withUserStoryNumberingOptions(
|
|
|
555
556
|
}
|
|
556
557
|
throw error;
|
|
557
558
|
}
|
|
558
|
-
const { runPlan } = await import("./plan-
|
|
559
|
+
const { runPlan } = await import("./plan-RXOW32KY.js");
|
|
559
560
|
const code = await runPlan(issue, void 0, numbering);
|
|
560
561
|
process.exit(code);
|
|
561
562
|
});
|
|
@@ -574,7 +575,7 @@ withWebOptions(
|
|
|
574
575
|
).action(
|
|
575
576
|
async (positionalMaxIter, options) => {
|
|
576
577
|
try {
|
|
577
|
-
const { runExecute } = await import("./execute-
|
|
578
|
+
const { runExecute } = await import("./execute-QYLJ5L4T.js");
|
|
578
579
|
const code = await runExecute(positionalMaxIter, options);
|
|
579
580
|
process.exit(code);
|
|
580
581
|
} catch (error) {
|
|
@@ -588,7 +589,7 @@ withIssueOptions(
|
|
|
588
589
|
program.command("review").description("Validate an issue resolution with the configured agent").argument("<issue>", "Issue number")
|
|
589
590
|
)
|
|
590
591
|
).action(async (issue) => {
|
|
591
|
-
const { runReview } = await import("./review-
|
|
592
|
+
const { runReview } = await import("./review-AEFISJZD.js");
|
|
592
593
|
const code = await runReview(issue);
|
|
593
594
|
process.exit(code);
|
|
594
595
|
});
|
|
@@ -597,7 +598,7 @@ withIssueOptions(
|
|
|
597
598
|
program.command("pr").description("Create a pull request with the configured agent").argument("<issue>", "Issue number")
|
|
598
599
|
)
|
|
599
600
|
).action(async (issue) => {
|
|
600
|
-
const { runPr } = await import("./pr-
|
|
601
|
+
const { runPr } = await import("./pr-3WFYAVA7.js");
|
|
601
602
|
const code = await runPr(issue);
|
|
602
603
|
process.exit(code);
|
|
603
604
|
});
|
|
@@ -605,21 +606,21 @@ var webCommand = program.command("web").description("Manage the web monitoring s
|
|
|
605
606
|
webCommand.command("serve").description(
|
|
606
607
|
"Run the web monitor server in the foreground (internal \u2014 spawned detached by --web)"
|
|
607
608
|
).option("--port <n>", "Web server port (default: 3737)", parseInteger).option("--host <h>", "Web server host (default: 0.0.0.0)").option("--refresh <s>", "Suggested UI polling interval in seconds", parseInteger).action(async (options) => {
|
|
608
|
-
const { runWebServe } = await import("./web-
|
|
609
|
+
const { runWebServe } = await import("./web-IPGY52AK.js");
|
|
609
610
|
const code = await runWebServe(options);
|
|
610
611
|
if (code !== 0) {
|
|
611
612
|
process.exit(code);
|
|
612
613
|
}
|
|
613
614
|
});
|
|
614
615
|
webCommand.command("stop").description("Stop the running web monitor server").action(async () => {
|
|
615
|
-
const { runWebStop } = await import("./web-
|
|
616
|
+
const { runWebStop } = await import("./web-IPGY52AK.js");
|
|
616
617
|
const code = await runWebStop();
|
|
617
618
|
process.exit(code);
|
|
618
619
|
});
|
|
619
620
|
withGlobalOptions(
|
|
620
621
|
program.command("policy").description("Inspect the policies discovered in this repository and their provenance").option("--scope <dir>", "Resolve the policy for a subdirectory (monorepo)").option("--json", "Emit the resolved policy as JSON")
|
|
621
622
|
).action(async (options) => {
|
|
622
|
-
const { runPolicy } = await import("./policy-
|
|
623
|
+
const { runPolicy } = await import("./policy-6WQZB6B2.js");
|
|
623
624
|
const code = await runPolicy(options);
|
|
624
625
|
process.exit(code);
|
|
625
626
|
});
|
|
@@ -627,41 +628,41 @@ var routingCommand = withGlobalOptions(
|
|
|
627
628
|
program.command("routing").description("Inspect the shadow router (records a recommendation, does not act)")
|
|
628
629
|
);
|
|
629
630
|
routingCommand.option("--json", "Emit the resolved routing config as JSON").action(async (options) => {
|
|
630
|
-
const { runRoutingInspect } = await import("./routing-
|
|
631
|
+
const { runRoutingInspect } = await import("./routing-EA5NJGNU.js");
|
|
631
632
|
process.exit(await runRoutingInspect(options));
|
|
632
633
|
});
|
|
633
634
|
routingCommand.command("report").description("Shadow agreement between selected and actual harness").option("--issue <n>", "Issue number").option("--json", "Emit JSON").action(async (options) => {
|
|
634
|
-
const { runRoutingReport } = await import("./routing-
|
|
635
|
+
const { runRoutingReport } = await import("./routing-EA5NJGNU.js");
|
|
635
636
|
process.exit(await runRoutingReport(options));
|
|
636
637
|
});
|
|
637
638
|
var conventionsCommand = withGlobalOptions(
|
|
638
639
|
program.command("conventions").description("Compute the repository Git convention (branch, commit, PR title)")
|
|
639
640
|
);
|
|
640
641
|
conventionsCommand.command("branch").description("Print the deterministic branch name for an issue").option("--issue <n>", "Issue number").option("--title <text>", "Issue title, when the issue cannot be resolved").option("--json", "Emit JSON").action(async (options) => {
|
|
641
|
-
const { runConventionsBranch } = await import("./conventions-
|
|
642
|
+
const { runConventionsBranch } = await import("./conventions-Z3QC2NSG.js");
|
|
642
643
|
process.exit(await runConventionsBranch(options));
|
|
643
644
|
});
|
|
644
645
|
conventionsCommand.command("commit").description("Print a Conventional Commit message").requiredOption("--type <type>", "Change type (feat, fix, docs, \u2026)").option("--scope <scope>", "Optional scope").requiredOption("--subject <text>", "Commit subject").option("--issue <n>", "Issue number for the Refs trailer").option("--story <id>", "Story id (US-010)").option("--breaking <text>", "Breaking change description").option("--json", "Emit JSON").action(
|
|
645
646
|
async (options) => {
|
|
646
|
-
const { runConventionsCommit } = await import("./conventions-
|
|
647
|
+
const { runConventionsCommit } = await import("./conventions-Z3QC2NSG.js");
|
|
647
648
|
process.exit(await runConventionsCommit(options));
|
|
648
649
|
}
|
|
649
650
|
);
|
|
650
651
|
conventionsCommand.command("pr-title").description("Print the Conventional Commit Pull Request title").option("--issue <n>", "Issue number").option("--title <text>", "Issue title, when the issue cannot be resolved").option("--json", "Emit JSON").action(async (options) => {
|
|
651
|
-
const { runConventionsPrTitle } = await import("./conventions-
|
|
652
|
+
const { runConventionsPrTitle } = await import("./conventions-Z3QC2NSG.js");
|
|
652
653
|
process.exit(await runConventionsPrTitle(options));
|
|
653
654
|
});
|
|
654
655
|
var agentCommand = withGlobalOptions(
|
|
655
656
|
program.command("agent").description("Inspect the resolved agent and model for each phase").option("--json", "Emit the resolved agent configuration as JSON")
|
|
656
657
|
);
|
|
657
658
|
agentCommand.action(async (options) => {
|
|
658
|
-
const { runAgent } = await import("./agent-
|
|
659
|
+
const { runAgent } = await import("./agent-PMWCDWOW.js");
|
|
659
660
|
const code = await runAgent(options);
|
|
660
661
|
process.exit(code);
|
|
661
662
|
});
|
|
662
663
|
agentCommand.command("use").description("Write an agent preference to config.json or .issue-flow.json").argument("<provider>", "claude, codex, cursor or antigravity").option("--model <model>", "Model identifier for this preference").option("--global", "Write to ~/.issue-flow/config.json (default)").option("--project", "Write to .issue-flow.json in the repository").option("--phase <phase>", "Write only the override for this phase").action(
|
|
663
664
|
async (provider, options) => {
|
|
664
|
-
const { runAgentUse } = await import("./agent-
|
|
665
|
+
const { runAgentUse } = await import("./agent-PMWCDWOW.js");
|
|
665
666
|
const code = await runAgentUse(provider, options);
|
|
666
667
|
process.exit(code);
|
|
667
668
|
}
|
|
@@ -673,7 +674,7 @@ withGlobalOptions(
|
|
|
673
674
|
)
|
|
674
675
|
).action(
|
|
675
676
|
async (pr, options) => {
|
|
676
|
-
const { runPrReview } = await import("./pr-review-
|
|
677
|
+
const { runPrReview } = await import("./pr-review-RK63ZEMM.js");
|
|
677
678
|
const code = await runPrReview(pr, options);
|
|
678
679
|
process.exit(code);
|
|
679
680
|
}
|
|
@@ -699,7 +700,7 @@ withGlobalOptions(
|
|
|
699
700
|
printError("Unknown bench mode. Use 'synthetic' or 'real'.");
|
|
700
701
|
process.exit(1);
|
|
701
702
|
}
|
|
702
|
-
const { runBench } = await import("./bench-
|
|
703
|
+
const { runBench } = await import("./bench-UBFGKUHR.js");
|
|
703
704
|
process.exit(
|
|
704
705
|
await runBench({
|
|
705
706
|
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
@@ -717,13 +718,13 @@ withGlobalOptions(
|
|
|
717
718
|
}
|
|
718
719
|
);
|
|
719
720
|
program.action(async () => {
|
|
720
|
-
const { listLiveRuns } = await import("./registry-
|
|
721
|
+
const { listLiveRuns } = await import("./registry-POSB35Q4.js");
|
|
721
722
|
const runs = await listLiveRuns();
|
|
722
723
|
if (runs.length === 0) {
|
|
723
724
|
program.help();
|
|
724
725
|
return;
|
|
725
726
|
}
|
|
726
|
-
const { runPs } = await import("./ps-
|
|
727
|
+
const { runPs } = await import("./ps-CX7756QG.js");
|
|
727
728
|
process.exit(await runPs());
|
|
728
729
|
});
|
|
729
730
|
program.parse();
|