issue-flow 0.18.0 → 0.20.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 +43 -97
- package/dist/agent-4DHRKZ2Z.js +32 -0
- package/dist/{analyze-Q4ONIWRZ.js → analyze-UEJ2R3H5.js} +42 -41
- package/dist/analyze-UEJ2R3H5.js.map +1 -0
- package/dist/{apply-EEFPY2W4.js → apply-QDYNQMUX.js} +22 -24
- package/dist/apply-QDYNQMUX.js.map +1 -0
- package/dist/artifacts-AMJQJFFV.js +82 -0
- package/dist/artifacts-AMJQJFFV.js.map +1 -0
- package/dist/{bench-WWWXLTFH.js → bench-RNRXVEFK.js} +42 -42
- package/dist/{chunk-RYOUZ6EK.js → chunk-23VHVVKW.js} +3 -3
- package/dist/chunk-2EYLOS5I.js +99 -0
- package/dist/chunk-2EYLOS5I.js.map +1 -0
- package/dist/{chunk-C5TL7T4V.js → chunk-2YM2VH6R.js} +2 -2
- package/dist/{chunk-XUEMATVY.js → chunk-37O2FMAN.js} +28 -25
- package/dist/chunk-37O2FMAN.js.map +1 -0
- package/dist/chunk-44RF3VFG.js +717 -0
- package/dist/chunk-44RF3VFG.js.map +1 -0
- package/dist/chunk-6AOZCWN2.js +21 -0
- package/dist/chunk-6AOZCWN2.js.map +1 -0
- package/dist/chunk-7MJGYPHF.js +1571 -0
- package/dist/chunk-7MJGYPHF.js.map +1 -0
- package/dist/{chunk-SA6HXL4Y.js → chunk-7WBUEBD5.js} +9 -9
- package/dist/chunk-7WBUEBD5.js.map +1 -0
- package/dist/chunk-7ZZUSMBJ.js +35 -0
- package/dist/chunk-7ZZUSMBJ.js.map +1 -0
- package/dist/{chunk-QJ44VG5G.js → chunk-ADH6RJNX.js} +3 -3
- package/dist/{chunk-34OCSKOB.js → chunk-AKL5UPR6.js} +159 -114
- package/dist/chunk-AKL5UPR6.js.map +1 -0
- package/dist/{chunk-7F7LGMVO.js → chunk-BTBJ5UOO.js} +12 -12
- package/dist/{chunk-7F7LGMVO.js.map → chunk-BTBJ5UOO.js.map} +1 -1
- package/dist/{chunk-HOAHMERN.js → chunk-CLZ6RRZL.js} +21 -21
- package/dist/chunk-DBLXLKGU.js +1201 -0
- package/dist/chunk-DBLXLKGU.js.map +1 -0
- package/dist/{chunk-DUS5ZNKL.js → chunk-DIMDAYZS.js} +7 -6
- package/dist/chunk-DZ3DZ3EN.js +278 -0
- package/dist/chunk-DZ3DZ3EN.js.map +1 -0
- package/dist/{chunk-CRGIQFUQ.js → chunk-E2H3JV2E.js} +3 -1
- package/dist/chunk-E2H3JV2E.js.map +1 -0
- package/dist/{chunk-45WZ6GMI.js → chunk-EORDSKWZ.js} +17 -17
- package/dist/chunk-EORDSKWZ.js.map +1 -0
- package/dist/{chunk-LTH6XYZ3.js → chunk-EYKPWHT7.js} +40 -30
- package/dist/chunk-EYKPWHT7.js.map +1 -0
- package/dist/{chunk-OODXFCQV.js → chunk-FU2FQ4JE.js} +14 -16
- package/dist/{chunk-OODXFCQV.js.map → chunk-FU2FQ4JE.js.map} +1 -1
- package/dist/{chunk-V7QOIQYC.js → chunk-G442RDFX.js} +9 -23
- package/dist/{chunk-V7QOIQYC.js.map → chunk-G442RDFX.js.map} +1 -1
- package/dist/{chunk-QPGEFLMY.js → chunk-I64N6RL6.js} +7 -7
- package/dist/{chunk-KRAGAUKD.js → chunk-JBYXJOJJ.js} +201 -64
- package/dist/chunk-JBYXJOJJ.js.map +1 -0
- package/dist/{chunk-SOM4QA6C.js → chunk-JCR5C5A7.js} +93 -18
- package/dist/chunk-JCR5C5A7.js.map +1 -0
- package/dist/{chunk-RNFUVKC3.js → chunk-K5NM26NV.js} +30 -13
- package/dist/chunk-K5NM26NV.js.map +1 -0
- package/dist/{chunk-YVPZUN6X.js → chunk-KUA6KBBD.js} +335 -38
- package/dist/chunk-KUA6KBBD.js.map +1 -0
- package/dist/{chunk-KMCS76ZW.js → chunk-KUL64XUF.js} +44 -12
- package/dist/chunk-KUL64XUF.js.map +1 -0
- package/dist/{chunk-HAKDLR6N.js → chunk-MAJ6QDRL.js} +65 -78
- package/dist/chunk-MAJ6QDRL.js.map +1 -0
- package/dist/{chunk-DGRTJD5R.js → chunk-MML2G7IC.js} +7 -7
- package/dist/chunk-NP47HRX2.js +136 -0
- package/dist/chunk-NP47HRX2.js.map +1 -0
- package/dist/{chunk-3R27MJ5R.js → chunk-PFWHHYEO.js} +3 -3
- package/dist/{chunk-ECU7YO7S.js → chunk-PM5YWJYO.js} +22 -6
- package/dist/chunk-PM5YWJYO.js.map +1 -0
- package/dist/{chunk-E4I6MMHD.js → chunk-PXPTIXJF.js} +154 -101
- package/dist/chunk-PXPTIXJF.js.map +1 -0
- package/dist/{chunk-CWSQVHVV.js → chunk-QJHZ3HYJ.js} +248 -102
- package/dist/chunk-QJHZ3HYJ.js.map +1 -0
- package/dist/{chunk-LI35PIIS.js → chunk-RDPK7LYK.js} +20 -117
- package/dist/chunk-RDPK7LYK.js.map +1 -0
- package/dist/{chunk-PMLE7KAQ.js → chunk-RMIBLFG3.js} +30 -14
- package/dist/chunk-RMIBLFG3.js.map +1 -0
- package/dist/{chunk-62GVVZQO.js → chunk-T736DSZI.js} +32 -316
- package/dist/chunk-T736DSZI.js.map +1 -0
- package/dist/{chunk-TZYINKCC.js → chunk-UDUUUFQF.js} +57 -29
- package/dist/chunk-UDUUUFQF.js.map +1 -0
- package/dist/{chunk-NEWNXZ65.js → chunk-V7GETODQ.js} +36 -28
- package/dist/{chunk-NEWNXZ65.js.map → chunk-V7GETODQ.js.map} +1 -1
- package/dist/{chunk-PPZ3K4YM.js → chunk-VHQMMY2D.js} +2 -2
- package/dist/{chunk-ZVZMWNCG.js → chunk-VJ3PF6B7.js} +50 -16
- package/dist/chunk-VJ3PF6B7.js.map +1 -0
- package/dist/{chunk-L6HSKTQE.js → chunk-W7LZLJAF.js} +4 -4
- package/dist/{chunk-6K2LCFG6.js → chunk-WB4FA2EH.js} +70 -81
- package/dist/chunk-WB4FA2EH.js.map +1 -0
- package/dist/{chunk-LGHND47K.js → chunk-WQSGL5LX.js} +22 -16
- package/dist/chunk-WQSGL5LX.js.map +1 -0
- package/dist/{chunk-ICM463EO.js → chunk-XNK5UN2D.js} +5 -649
- package/dist/chunk-XNK5UN2D.js.map +1 -0
- package/dist/{chunk-7UMMFOL2.js → chunk-Y2KOWABB.js} +39 -24
- package/dist/chunk-Y2KOWABB.js.map +1 -0
- package/dist/{chunk-QF7VEL3M.js → chunk-YC24E66P.js} +568 -158
- package/dist/chunk-YC24E66P.js.map +1 -0
- package/dist/{chunk-EG2MGDP5.js → chunk-Z6RCKCVB.js} +52 -46
- package/dist/chunk-Z6RCKCVB.js.map +1 -0
- package/dist/{chunk-YUNBOUQH.js → chunk-ZPGNVBWY.js} +8 -8
- package/dist/cli.js +132 -62
- package/dist/cli.js.map +1 -1
- package/dist/compat-OJG76J4I.js +24 -0
- package/dist/{config-LEBZZCJP.js → config-6YTWPDBK.js} +20 -17
- package/dist/{contract-JH2WBIO6.js → contract-HWLFFL3F.js} +2 -2
- package/dist/{conventions-XOT6YW5L.js → conventions-5UPOTU42.js} +20 -16
- package/dist/{conventions-XOT6YW5L.js.map → conventions-5UPOTU42.js.map} +1 -1
- package/dist/db-QAZG4LQD.js +264 -0
- package/dist/db-QAZG4LQD.js.map +1 -0
- package/dist/diagnostics-YEFB42E5.js +25 -0
- package/dist/execute-QCT64D37.js +38 -0
- package/dist/{generate-JGW5JSKB.js → generate-QATMDKOK.js} +46 -43
- package/dist/generate-QATMDKOK.js.map +1 -0
- package/dist/{git-A2IP32PQ.js → git-XGOECXWG.js} +2 -3
- package/dist/history-NBPUZVGQ.js +101 -0
- package/dist/history-NBPUZVGQ.js.map +1 -0
- package/dist/init-4LB2YKWP.js +28 -0
- package/dist/{operations-O4FORFIH.js → operations-RUQP2Y2F.js} +78 -52
- package/dist/operations-RUQP2Y2F.js.map +1 -0
- package/dist/{permissions-G4XCAESF.js → permissions-QZPUUBSO.js} +5 -6
- package/dist/plan-2NMSHTMD.js +38 -0
- package/dist/{policy-U5NBFAO5.js → policy-RKKFF5A2.js} +17 -15
- package/dist/{policy-U5NBFAO5.js.map → policy-RKKFF5A2.js.map} +1 -1
- package/dist/pr-QKFO5HI3.js +42 -0
- package/dist/pr-review-H2BFD6F2.js +33 -0
- package/dist/prd-ET6XKYRS.js +37 -0
- package/dist/{ps-76L6ZAZL.js → ps-UIKSOUAQ.js} +26 -15
- package/dist/ps-UIKSOUAQ.js.map +1 -0
- package/dist/{recorder-2BAKPBRA.js → recorder-LOU3PTIE.js} +11 -7
- package/dist/registry-HV7M6MAH.js +17 -0
- package/dist/repository-RCRR6RDE.js +80 -0
- package/dist/resume-BWJZGBLZ.js +278 -0
- package/dist/resume-BWJZGBLZ.js.map +1 -0
- package/dist/review-2MTZLNSS.js +38 -0
- package/dist/routing-RM5ABHHD.js +35 -0
- package/dist/run-XMACQBRJ.js +61 -0
- package/dist/{session-publisher-KAJQRHNZ.js → session-publisher-Q5TNEZPX.js} +3 -3
- package/dist/session-publisher-Q5TNEZPX.js.map +1 -0
- package/dist/{state-manager-UPHO2EA2.js → state-manager-SRN4VJSX.js} +9 -4
- package/dist/state-manager-SRN4VJSX.js.map +1 -0
- package/dist/{usage-KTMYXAPF.js → usage-JOODVE5O.js} +69 -63
- package/dist/usage-JOODVE5O.js.map +1 -0
- package/dist/web-TLMWJ2BM.js +205 -0
- package/dist/web-TLMWJ2BM.js.map +1 -0
- package/package.json +22 -8
- package/prompts/analyze.md +16 -19
- package/prompts/execute.md +73 -144
- package/prompts/generate.md +23 -10
- package/prompts/plan.md +32 -60
- package/prompts/pr-review.md +58 -40
- package/prompts/pr.md +50 -16
- package/prompts/prd.md +26 -19
- package/prompts/review.md +41 -18
- package/web/public/app.js +111 -112
- package/dist/agent-HMZTXCRT.js +0 -30
- package/dist/analyze-Q4ONIWRZ.js.map +0 -1
- package/dist/apply-EEFPY2W4.js.map +0 -1
- package/dist/chunk-34OCSKOB.js.map +0 -1
- package/dist/chunk-45WZ6GMI.js.map +0 -1
- package/dist/chunk-62GVVZQO.js.map +0 -1
- package/dist/chunk-6K2LCFG6.js.map +0 -1
- package/dist/chunk-7UMMFOL2.js.map +0 -1
- package/dist/chunk-CRGIQFUQ.js.map +0 -1
- package/dist/chunk-CWSQVHVV.js.map +0 -1
- package/dist/chunk-E4I6MMHD.js.map +0 -1
- package/dist/chunk-ECU7YO7S.js.map +0 -1
- package/dist/chunk-EG2MGDP5.js.map +0 -1
- package/dist/chunk-HAKDLR6N.js.map +0 -1
- package/dist/chunk-ICM463EO.js.map +0 -1
- package/dist/chunk-KMCS76ZW.js.map +0 -1
- package/dist/chunk-KRAGAUKD.js.map +0 -1
- package/dist/chunk-LGHND47K.js.map +0 -1
- package/dist/chunk-LI35PIIS.js.map +0 -1
- package/dist/chunk-LTH6XYZ3.js.map +0 -1
- package/dist/chunk-PMLE7KAQ.js.map +0 -1
- package/dist/chunk-QF7VEL3M.js.map +0 -1
- package/dist/chunk-RNFUVKC3.js.map +0 -1
- package/dist/chunk-SA6HXL4Y.js.map +0 -1
- package/dist/chunk-SOM4QA6C.js.map +0 -1
- package/dist/chunk-TZYINKCC.js.map +0 -1
- package/dist/chunk-WCCZJL7W.js +0 -141
- package/dist/chunk-WCCZJL7W.js.map +0 -1
- package/dist/chunk-XEYH6ZZI.js +0 -289
- package/dist/chunk-XEYH6ZZI.js.map +0 -1
- package/dist/chunk-XUEMATVY.js.map +0 -1
- package/dist/chunk-XZUEFTUP.js +0 -243
- package/dist/chunk-XZUEFTUP.js.map +0 -1
- package/dist/chunk-YVPZUN6X.js.map +0 -1
- package/dist/chunk-ZVZMWNCG.js.map +0 -1
- package/dist/diagnostics-HTCWF7F4.js +0 -23
- package/dist/execute-LELOSR5T.js +0 -37
- package/dist/generate-JGW5JSKB.js.map +0 -1
- package/dist/init-TO6MUXO4.js +0 -26
- package/dist/operations-O4FORFIH.js.map +0 -1
- package/dist/plan-OXAT344Q.js +0 -34
- package/dist/pr-UZHNKKZC.js +0 -39
- package/dist/pr-review-Q4ACAWDM.js +0 -32
- package/dist/prd-6CYEMLDY.js +0 -33
- package/dist/ps-76L6ZAZL.js.map +0 -1
- package/dist/registry-XLHHYLTR.js +0 -15
- package/dist/resume-URCU6CIJ.js +0 -244
- package/dist/resume-URCU6CIJ.js.map +0 -1
- package/dist/review-LVZT2TMW.js +0 -35
- package/dist/routing-EK6RBZM4.js +0 -33
- package/dist/run-2RXJCJKT.js +0 -56
- package/dist/usage-KTMYXAPF.js.map +0 -1
- package/dist/web-B5UPHHR5.js +0 -172
- package/dist/web-B5UPHHR5.js.map +0 -1
- /package/dist/{agent-HMZTXCRT.js.map → agent-4DHRKZ2Z.js.map} +0 -0
- /package/dist/{bench-WWWXLTFH.js.map → bench-RNRXVEFK.js.map} +0 -0
- /package/dist/{chunk-RYOUZ6EK.js.map → chunk-23VHVVKW.js.map} +0 -0
- /package/dist/{chunk-C5TL7T4V.js.map → chunk-2YM2VH6R.js.map} +0 -0
- /package/dist/{chunk-QJ44VG5G.js.map → chunk-ADH6RJNX.js.map} +0 -0
- /package/dist/{chunk-HOAHMERN.js.map → chunk-CLZ6RRZL.js.map} +0 -0
- /package/dist/{chunk-DUS5ZNKL.js.map → chunk-DIMDAYZS.js.map} +0 -0
- /package/dist/{chunk-QPGEFLMY.js.map → chunk-I64N6RL6.js.map} +0 -0
- /package/dist/{chunk-DGRTJD5R.js.map → chunk-MML2G7IC.js.map} +0 -0
- /package/dist/{chunk-3R27MJ5R.js.map → chunk-PFWHHYEO.js.map} +0 -0
- /package/dist/{chunk-PPZ3K4YM.js.map → chunk-VHQMMY2D.js.map} +0 -0
- /package/dist/{chunk-L6HSKTQE.js.map → chunk-W7LZLJAF.js.map} +0 -0
- /package/dist/{chunk-YUNBOUQH.js.map → chunk-ZPGNVBWY.js.map} +0 -0
- /package/dist/{config-LEBZZCJP.js.map → compat-OJG76J4I.js.map} +0 -0
- /package/dist/{contract-JH2WBIO6.js.map → config-6YTWPDBK.js.map} +0 -0
- /package/dist/{diagnostics-HTCWF7F4.js.map → contract-HWLFFL3F.js.map} +0 -0
- /package/dist/{execute-LELOSR5T.js.map → diagnostics-YEFB42E5.js.map} +0 -0
- /package/dist/{git-A2IP32PQ.js.map → execute-QCT64D37.js.map} +0 -0
- /package/dist/{init-TO6MUXO4.js.map → git-XGOECXWG.js.map} +0 -0
- /package/dist/{permissions-G4XCAESF.js.map → init-4LB2YKWP.js.map} +0 -0
- /package/dist/{plan-OXAT344Q.js.map → permissions-QZPUUBSO.js.map} +0 -0
- /package/dist/{pr-UZHNKKZC.js.map → plan-2NMSHTMD.js.map} +0 -0
- /package/dist/{pr-review-Q4ACAWDM.js.map → pr-QKFO5HI3.js.map} +0 -0
- /package/dist/{prd-6CYEMLDY.js.map → pr-review-H2BFD6F2.js.map} +0 -0
- /package/dist/{recorder-2BAKPBRA.js.map → prd-ET6XKYRS.js.map} +0 -0
- /package/dist/{registry-XLHHYLTR.js.map → recorder-LOU3PTIE.js.map} +0 -0
- /package/dist/{review-LVZT2TMW.js.map → registry-HV7M6MAH.js.map} +0 -0
- /package/dist/{routing-EK6RBZM4.js.map → repository-RCRR6RDE.js.map} +0 -0
- /package/dist/{run-2RXJCJKT.js.map → review-2MTZLNSS.js.map} +0 -0
- /package/dist/{session-publisher-KAJQRHNZ.js.map → routing-RM5ABHHD.js.map} +0 -0
- /package/dist/{state-manager-UPHO2EA2.js.map → run-XMACQBRJ.js.map} +0 -0
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/cli-options.ts","../src/issues/cli-flags.ts","../src/resilience/cli-flags.ts"],"sourcesContent":["import { Command, InvalidArgumentError, Option } from 'commander';\nimport { parseAgentPhaseFlag } from './agents/resolve.js';\nimport { type AgentCliOverrides, isAgentProviderId } from './agents/types.js';\nimport {\n CliFlagError,\n resolveQueueScopeFlags,\n resolveRunPhaseFlags,\n resolveUserStoryNumberingFlags,\n resolveWebOverrides,\n} from './cli-options.js';\nimport {\n setAgentCliOverrides,\n setIssuesCliOverrides,\n setResilienceCliOverrides,\n setRoutingCliOverrides,\n setVerifyCliOverrides,\n setWebCliOverrides,\n} from './config.js';\nimport { installShutdownHandlers } from './core/shutdown.js';\nimport { setGlobalTimeout, setInactivityTimeout, setVerbose } from './core/verbose.js';\nimport {\n IssueFlagError,\n resolveGenerateTarget,\n resolveIssuesOverrides,\n} from './issues/cli-flags.js';\nimport type { IssueGenerateTarget } from './issues/types.js';\nimport { resolveResilienceOverrides } from './resilience/cli-flags.js';\nimport type { RoutingConfig } from './schemas.js';\nimport { printError } from './ui/logger.js';\nimport { getPackageVersion } from './version.js';\n\nconst version = getPackageVersion();\n\n/**\n * Parse a numeric string, throwing InvalidArgumentError if not a valid number.\n */\nfunction parseInteger(value: string): number {\n const parsed = parseInt(value, 10);\n if (Number.isNaN(parsed) || parsed < 0) {\n throw new InvalidArgumentError('Must be a non-negative integer.');\n }\n return parsed;\n}\n\nfunction parseUsd(value: string): number {\n const parsed = Number.parseFloat(value);\n if (!Number.isFinite(parsed) || parsed < 0) {\n throw new InvalidArgumentError('Must be a non-negative number.');\n }\n return parsed;\n}\n\nfunction collectString(value: string, previous: string[]): string[] {\n return [...previous, value];\n}\n\n/** Parse `--on-issue-failure <mode>`, rejecting anything but the three modes. */\nfunction parseQueueFailureMode(value: string): 'stop' | 'skip' | 'block' {\n if (value === 'stop' || value === 'skip' || value === 'block') return value;\n throw new InvalidArgumentError('Must be one of: stop, skip, block.');\n}\n\n/**\n * Parse `--start-us <n>`: a User Story number is 1-based, so 0 is rejected\n * along with everything `parseInteger` already rejects.\n */\nfunction parseStartUs(value: string): number {\n const parsed = parseInteger(value);\n if (parsed < 1) {\n throw new InvalidArgumentError('Must be a positive integer (US-001 is the first story).');\n }\n return parsed;\n}\n\n/**\n * Add the User Story numbering override options to a subcommand that\n * triggers `plan` (`run` and `plan` itself) — see issue #36.\n */\nfunction withUserStoryNumberingOptions(cmd: Command): Command {\n return cmd\n .option('--continue', 'Continue User Story numbering from the last used in this project')\n .option(\n '--start-us <n>',\n 'Force User Story numbering to start at a specific number, ignoring history',\n parseStartUs,\n );\n}\n\n/**\n * Add shared options (--verbose) to a subcommand.\n */\nfunction withGlobalOptions(cmd: Command): Command {\n return (\n cmd\n .option('-v, --verbose', 'Show agent progress output in real time')\n .option(\n '-t, --timeout <seconds>',\n 'Override headless timeout in seconds (0 = no limit)',\n parseInteger,\n )\n // The second, tighter instrument beside the absolute timeout: a phase that\n // has said nothing for this long is stuck, not slow. `0` turns it off.\n .option(\n '--inactivity-timeout <seconds>',\n 'Stop the agent after this many seconds with no output (0 = no watchdog)',\n parseInteger,\n )\n .option(\n '--agent <provider>',\n 'Run every phase on this agent (claude|codex|cursor|antigravity)',\n )\n .option('--agent-model <model>', 'Override the model for every phase')\n .option(\n '--agent-phase <phase>=<provider>[:<model>]',\n 'Override one phase (repeatable)',\n collectAgentPhase,\n {} as AgentCliOverrides['phases'],\n )\n .option('--verify-level <level>', 'Acceptance-contract level: L0 | L1 | L2 | L3 | L5')\n .option('--no-cross-verify', 'Keep L2 off even when a trigger would fire')\n .option('--no-escalation', 'Keep routing.escalation.enabled off')\n .option('--max-cost <usd>', 'Issue cost ceiling in USD (Issue Flow enforces it)', parseUsd)\n .option('--max-duration <seconds>', 'Issue duration ceiling in seconds', parseInteger)\n );\n}\n\nfunction collectAgentPhase(\n value: string,\n previous: NonNullable<AgentCliOverrides['phases']> | undefined,\n): NonNullable<AgentCliOverrides['phases']> {\n const parsed = parseAgentPhaseFlag(value);\n return { ...previous, [parsed.phase]: parsed.block };\n}\n\nfunction resolveAgentOverrides(opts: Record<string, unknown>): AgentCliOverrides {\n const overrides: AgentCliOverrides = {};\n if (typeof opts.agent === 'string') {\n if (!isAgentProviderId(opts.agent)) {\n throw new InvalidArgumentError('Must be one of: claude, codex, cursor, antigravity.');\n }\n overrides.forceProvider = opts.agent;\n }\n if (typeof opts.agentModel === 'string') {\n overrides.forceModel = opts.agentModel;\n }\n if (opts.agentPhase && typeof opts.agentPhase === 'object') {\n overrides.phases = opts.agentPhase as AgentCliOverrides['phases'];\n }\n return overrides;\n}\n\nconst VERIFY_LEVELS = ['L0', 'L1', 'L2', 'L3', 'L5'] as const;\n\nfunction resolveVerifyOverrides(opts: Record<string, unknown>): {\n level?: (typeof VERIFY_LEVELS)[number];\n crossVerify?: boolean;\n} {\n const overrides: { level?: (typeof VERIFY_LEVELS)[number]; crossVerify?: boolean } = {};\n if (typeof opts.verifyLevel === 'string') {\n if (!VERIFY_LEVELS.includes(opts.verifyLevel as (typeof VERIFY_LEVELS)[number])) {\n throw new InvalidArgumentError('Must be one of: L0, L1, L2, L3, L5.');\n }\n overrides.level = opts.verifyLevel as (typeof VERIFY_LEVELS)[number];\n }\n if (opts.crossVerify === false) overrides.crossVerify = false;\n return overrides;\n}\n\nfunction resolveRoutingOverrides(opts: Record<string, unknown>): Partial<RoutingConfig> {\n const overrides: Partial<RoutingConfig> = {};\n if (opts.escalation === false) {\n overrides.escalation = {\n enabled: false,\n minAttemptsBeforeEscalation: 2,\n maxEscalations: 2,\n maxRungs: ['effort', 'model', 'harness'],\n };\n }\n if (typeof opts.maxCost === 'number' || typeof opts.maxDuration === 'number') {\n overrides.ceilings = {\n maxCostUsdPerIssue: typeof opts.maxCost === 'number' ? opts.maxCost : null,\n maxDurationMsPerIssue: typeof opts.maxDuration === 'number' ? opts.maxDuration * 1000 : null,\n maxExecutionsPerIssue: null,\n onCeiling: 'block',\n };\n }\n return overrides;\n}\n\n/**\n * Add the resilience options to a subcommand, in the shape `--web` and\n * `--pr-review` already follow: declared here, resolved into configuration\n * overrides by the preAction hook, and applied through the same ladder every\n * other key climbs.\n */\nfunction withResilienceOptions(cmd: Command): Command {\n return cmd\n .option('--continuous', 'Long-running profile: keep going without supervision')\n .option('--resilient', 'Alias of --continuous')\n .option('--no-failover', 'Never migrate a phase to another agent provider')\n .option('--auto-decompose', 'Act on a decomposition report instead of only writing it');\n}\n\n/**\n * Add web monitoring options to a subcommand (run and execute only).\n * The values are resolved into CLI overrides by the preAction hook below;\n * loadWebConfig() applies the flag > env > file > defaults precedence.\n */\nfunction withWebOptions(cmd: Command): Command {\n return cmd\n .option('--web', 'Enable the web monitoring server')\n .option('--serve', 'Alias for --web')\n .option('--restart-web', 'Restart the web monitor before serving it (implies --web)')\n .option('--port <n>', 'Web server port (default: 3737)', parseInteger)\n .option('--host <h>', 'Web server host (default: 0.0.0.0)')\n .option('--refresh <s>', 'Suggested UI polling interval in seconds', parseInteger)\n .option('--web-log-limit <n>', 'Max log entries kept in the snapshot', parseInteger)\n .option('--web-no-logs', 'Exclude logs from the published snapshot');\n}\n\n/**\n * Add the Issue provider options to a subcommand.\n *\n * Declared once here (like withWebOptions) so no command repeats the flag\n * list; the preAction hook below turns them into config overrides, and\n * loadIssuesConfig() applies the flag > .issue-flow.json > defaults precedence.\n */\nfunction withIssueOptions(cmd: Command): Command {\n return cmd\n .option('--local', 'Prefer the local file Issue provider')\n .option('--github', 'Prefer the GitHub Issue provider')\n .option('--prefer-local', 'On divergence, use the local version without asking')\n .option('--prefer-github', 'On divergence, use the GitHub version without asking')\n .option('--ask', 'On divergence, ask which version to use (interactive only)');\n}\n\nconst program = new Command();\n\nprogram\n .name('issue-flow')\n .description(\n 'Unified CLI for orchestrating the full issue-flow pipeline via Claude Code, Codex CLI, Cursor CLI or Antigravity CLI.',\n )\n .version(version);\n\nprogram.hook('preAction', (_thisCommand, actionCommand) => {\n // Installed once, before any command runs: a `Ctrl+C` during a six-hour run\n // has to write a checkpoint and stop the agent, not kill the process\n // mid-phase and leave `session.json` on `running` forever.\n installShutdownHandlers();\n\n const opts = actionCommand.opts();\n if (opts.verbose) {\n setVerbose(true);\n }\n if (opts.timeout !== undefined) {\n setGlobalTimeout(opts.timeout * 1000);\n }\n if (opts.inactivityTimeout !== undefined) {\n setInactivityTimeout(opts.inactivityTimeout * 1000);\n }\n setWebCliOverrides(resolveWebOverrides(opts));\n try {\n setVerifyCliOverrides(resolveVerifyOverrides(opts));\n setAgentCliOverrides(resolveAgentOverrides(opts));\n setRoutingCliOverrides(resolveRoutingOverrides(opts));\n } catch (error) {\n if (error instanceof InvalidArgumentError) {\n printError(error.message);\n process.exit(1);\n }\n throw error;\n }\n // The CLI rung of the `resilience` ladder. `--continuous` expands here into\n // the settings it implies, with every granular flag applied on top of it.\n setResilienceCliOverrides(\n resolveResilienceOverrides({\n continuous: opts.continuous,\n resilient: opts.resilient,\n failover: opts.failover,\n autoDecompose: opts.autoDecompose,\n inactivityTimeout: opts.inactivityTimeout,\n onIssueFailure: opts.onIssueFailure,\n }),\n );\n try {\n setIssuesCliOverrides(resolveIssuesOverrides(opts));\n } catch (error) {\n if (error instanceof IssueFlagError) {\n printError(error.message);\n process.exit(1);\n }\n throw error;\n }\n});\n\n// ── init ────────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('init')\n .description(\n 'Check prerequisites and report (or create) the conventions this repository is missing',\n )\n .option('--apply', 'Create the missing files instead of only reporting them')\n .option('--json', 'Emit the plan as JSON')\n .option('--scope <dir>', 'Resolve the conventions for a subdirectory (monorepo)')\n .option('--check-only', 'Only verify prerequisites, as earlier releases did')\n .option('--no-agent-prompt', 'Skip the first-run agent choice'),\n ),\n).action(\n async (options: {\n apply?: boolean;\n json?: boolean;\n scope?: string;\n checkOnly?: boolean;\n agentPrompt?: boolean;\n }) => {\n const { loadIssuesConfig } = await import('./config.js');\n const { runInit } = await import('./commands/init.js');\n const { preferredProvider } = await loadIssuesConfig();\n const code = await runInit(preferredProvider, {\n ...options,\n noAgentPrompt: options.agentPrompt === false,\n });\n process.exit(code);\n },\n);\n\n// ── generate ────────────────────────────────────────────────────────────────\nwithGlobalOptions(\n program\n .command('generate')\n .description('Draft an issue with the configured agent and create it')\n .requiredOption('--prompt <text>', 'Issue description text')\n .option('--github', 'Create the issue on GitHub')\n .option('--local', 'Create the issue under issues/<n>/ only')\n .option('--both', 'Create the issue on GitHub and mirror it locally'),\n).action(async (options: { prompt: string; github?: boolean; local?: boolean; both?: boolean }) => {\n let target: IssueGenerateTarget | undefined;\n try {\n target = resolveGenerateTarget(options);\n } catch (error) {\n if (error instanceof IssueFlagError) {\n printError(error.message);\n process.exit(1);\n }\n throw error;\n }\n\n const { runGenerate } = await import('./commands/generate.js');\n const code = await runGenerate(options.prompt, target);\n process.exit(code);\n});\n\n// ── run ─────────────────────────────────────────────────────────────────────\nwithUserStoryNumberingOptions(\n withResilienceOptions(\n withWebOptions(\n withIssueOptions(\n withGlobalOptions(\n program\n .command('run')\n .description(\n 'Execute the full pipeline: prd → plan → execute → review → pr (→ pr-review, optional)',\n )\n .argument('<issues...>', 'Issue number(s): 42, \"42,43\" or 42 43')\n .option('--mode <mode>', 'Execution mode: auto | manual', 'auto')\n .option('--from <phase>', 'Resume from a specific phase')\n .option(\n '--no-branch',\n 'Run pipeline on current branch without creating a new branch or PR',\n )\n .option('--pr-review', 'Review the created Pull Request after the pr phase')\n .option('-y, --yes', 'Run the whole discovered hierarchy without confirmation')\n .option('--cascade', 'Run the children of a container, without implementing it')\n .option('--only', 'Run just the issues informed, without their hierarchy')\n // Same two flags `execute` has always had, forwarded to the execute\n // phase of the pipeline: a `run` is the only way most users reach that\n // loop, and had no way to widen its retry budget.\n .option(\n '--retry-limit <number>',\n 'Retry transient Claude failures up to N consecutive times',\n parseInteger,\n )\n .option('--retry-forever', 'Retry transient Claude failures indefinitely')\n // What one failing issue does to the rest of a queue. `stop` is what\n // every release before this flag did, and stays the default.\n .option(\n '--on-issue-failure <mode>',\n 'In a queue, on a failing issue: stop | skip | block',\n parseQueueFailureMode,\n )\n .option('-d, --background', 'Detach after confirmation and return the terminal')\n .addOption(new Option('--detached-child').hideHelp()),\n ),\n ),\n ),\n ),\n).action(\n async (\n issues: string[],\n options: {\n mode: string;\n from?: string;\n branch?: boolean;\n prReview?: boolean;\n yes?: boolean;\n only?: boolean;\n continue?: boolean;\n startUs?: number;\n retryLimit?: number;\n retryForever?: boolean;\n onIssueFailure?: 'stop' | 'skip' | 'block';\n background?: boolean;\n detachedChild?: boolean;\n restartWeb?: boolean;\n },\n ) => {\n let phases: ReturnType<typeof resolveRunPhaseFlags>;\n let scope: ReturnType<typeof resolveQueueScopeFlags>;\n let numbering: ReturnType<typeof resolveUserStoryNumberingFlags>;\n try {\n phases = resolveRunPhaseFlags(options);\n scope = resolveQueueScopeFlags(options);\n numbering = resolveUserStoryNumberingFlags(options);\n } catch (error) {\n if (error instanceof CliFlagError) {\n printError(error.message);\n process.exit(1);\n }\n throw error;\n }\n\n const { runPipeline } = await import('./commands/run.js');\n const code = await runPipeline(\n issues,\n options.mode,\n options.from,\n phases.noBranch,\n phases.prReview,\n {\n yes: scope.yes,\n only: scope.only,\n cascade: scope.cascade,\n continueNumbering: numbering.continueFlag,\n startUs: numbering.startUs,\n retryLimit: options.retryLimit,\n retryForever: options.retryForever,\n onIssueFailure: options.onIssueFailure,\n background: options.background,\n detachedChild: options.detachedChild,\n restartWeb: options.restartWeb,\n },\n );\n process.exit(code);\n },\n);\n\n// ── resume ──────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('resume')\n .description('Resume an interrupted pipeline from the phase it stopped at')\n .argument('[issue]', 'Issue to resume. Omitted: the most recently attempted one')\n .option('--all', 'Resume every unfinished issue of this project, in order')\n .option('--mode <mode>', 'Execution mode: auto | manual', 'auto'),\n ),\n).action(async (issue: string | undefined, options: { all?: boolean; mode?: string }) => {\n const { runResume } = await import('./commands/resume.js');\n const code = await runResume(issue, {\n ...(options.all === undefined ? {} : { all: options.all }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n });\n process.exit(code);\n});\n\n// ── status / runs / logs / pause / cancel ───────────────────────────────────\n// The operation surface of a long run. Every one of them reads state that\n// already exists; only pause and cancel write anything, and what they write is\n// a signal to the process that owns the run.\nwithGlobalOptions(\n program\n .command('status')\n .description('What is running right now, in which phase, and since when')\n .argument('[issue]', 'Restrict the report to one issue')\n .option('--json', 'Emit the assembled state as JSON'),\n).action(async (issue: string | undefined, options: { json?: boolean }) => {\n const { runStatus } = await import('./commands/operations.js');\n process.exit(\n await runStatus(issue, { ...(options.json === undefined ? {} : { json: options.json }) }),\n );\n});\n\nwithGlobalOptions(\n program\n .command('usage')\n .description('Aggregate execution telemetry from tasks.json')\n .argument('[issue]', 'Restrict the report to one issue')\n .option('--issue <issue>', 'Same as the positional argument')\n .option('--since <date>', 'Only executions started on or after this ISO date')\n .option('--by <key>', 'Group by harness, provider, model, purpose or status')\n .option('--json', 'Emit the assembled totals as JSON'),\n).action(\n async (\n issue: string | undefined,\n options: { issue?: string; since?: string; by?: string; json?: boolean },\n ) => {\n const { runUsage, USAGE_GROUP_KEYS } = await import('./commands/usage.js');\n const by = options.by;\n if (by !== undefined && !(USAGE_GROUP_KEYS as readonly string[]).includes(by)) {\n printError('Must be one of: harness, provider, model, purpose, status.');\n process.exit(1);\n }\n process.exit(\n await runUsage(issue ?? options.issue, {\n ...(options.since === undefined ? {} : { since: options.since }),\n ...(by === undefined ? {} : { by: by as (typeof USAGE_GROUP_KEYS)[number] }),\n ...(options.json === undefined ? {} : { json: options.json }),\n }),\n );\n },\n);\n\nwithGlobalOptions(\n program\n .command('ps')\n .description('Every issue-flow run active on this machine')\n .option('--json', 'Emit the listing as JSON')\n .option('--watch', 'Refresh the listing until interrupted'),\n).action(async (options: { json?: boolean; watch?: boolean }) => {\n const { runPs } = await import('./commands/ps.js');\n process.exit(await runPs(options));\n});\n\nwithGlobalOptions(\n program.command('runs').description('History of the runs of this project, with how each ended'),\n).action(async () => {\n const { runRuns } = await import('./commands/operations.js');\n process.exit(await runRuns());\n});\n\nwithGlobalOptions(\n program\n .command('logs')\n .description('Read the execution journal (events.jsonl), filtered and readable')\n .argument('[issue]', 'Issue to read. Omitted: the most recently attempted one')\n .option('--issue <issue>', 'Same as the positional argument')\n .option('--follow', 'Keep reading as the journal grows')\n .option('--tail <n>', 'How many entries to show first (default 50)', parseInteger)\n .option('--kind <kinds>', 'Only these event types, comma separated (retry, phase:end, …)'),\n).action(\n async (\n issue: string | undefined,\n options: { issue?: string; follow?: boolean; tail?: number; kind?: string },\n ) => {\n const { runLogs } = await import('./commands/operations.js');\n const kinds =\n options.kind === undefined\n ? undefined\n : options.kind\n .split(',')\n .map((kind) => kind.trim())\n .filter((kind) => kind !== '');\n process.exit(\n await runLogs(issue ?? options.issue, {\n ...(kinds === undefined ? {} : { kind: kinds }),\n ...(options.follow === undefined ? {} : { follow: options.follow }),\n ...(options.tail === undefined ? {} : { tail: options.tail }),\n }),\n );\n },\n);\n\nwithGlobalOptions(\n program\n .command('pause')\n .description('Ask the running pipeline to stop after writing a checkpoint'),\n).action(async () => {\n const { runPause } = await import('./commands/operations.js');\n process.exit(await runPause());\n});\n\nwithGlobalOptions(\n program\n .command('cancel')\n .description('Stop the run and mark the issue so a resume does not pick it up')\n .argument('[issue]', 'Issue to cancel. Omitted: the most recently attempted one'),\n).action(async (issue: string | undefined) => {\n const { runCancel } = await import('./commands/operations.js');\n process.exit(await runCancel(issue));\n});\n\n// ── analyze ─────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('analyze')\n .description('Analyze an issue with the configured agent')\n .argument('<issue>', 'Issue number'),\n ),\n).action(async (issue: string) => {\n const { runAnalyze } = await import('./commands/analyze.js');\n const code = await runAnalyze(issue);\n process.exit(code);\n});\n\n// ── prd ─────────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('prd')\n .description('Generate a PRD from an analyzed issue with the configured agent')\n .argument('<issue>', 'Issue number'),\n ),\n).action(async (issue: string) => {\n const { runPrd } = await import('./commands/prd.js');\n const code = await runPrd(issue);\n process.exit(code);\n});\n\n// ── plan ────────────────────────────────────────────────────────────────────\nwithUserStoryNumberingOptions(\n withIssueOptions(\n withGlobalOptions(\n program\n .command('plan')\n .description('Convert a PRD to a tasks.json task plan with the configured agent')\n .argument('<issue>', 'Issue number'),\n ),\n ),\n).action(async (issue: string, options: { continue?: boolean; startUs?: number }) => {\n let numbering: ReturnType<typeof resolveUserStoryNumberingFlags>;\n try {\n numbering = resolveUserStoryNumberingFlags(options);\n } catch (error) {\n if (error instanceof CliFlagError) {\n printError(error.message);\n process.exit(1);\n }\n throw error;\n }\n\n const { runPlan } = await import('./commands/plan.js');\n const code = await runPlan(issue, undefined, numbering);\n process.exit(code);\n});\n\n// ── execute ─────────────────────────────────────────────────────────────────\nwithWebOptions(\n withGlobalOptions(\n program\n .command('execute')\n .description('Run the iterative story execution loop (issue-flow engine)')\n .option('--issue <number>', 'Issue number — reads artifacts from issues/N/')\n .option('--max-iterations <number>', 'Stop after N iterations', parseInteger)\n .option(\n '--retry-limit <number>',\n 'Retry transient Claude failures up to N consecutive times',\n parseInteger,\n )\n .option('--retry-forever', 'Retry transient Claude failures indefinitely')\n .argument(\n '[max-iterations]',\n 'Backward-compatible alias for --max-iterations N',\n parseInteger,\n ),\n ),\n).action(\n async (\n positionalMaxIter: number | undefined,\n options: {\n issue?: string;\n maxIterations?: number;\n retryLimit?: number;\n retryForever?: boolean;\n restartWeb?: boolean;\n },\n ) => {\n try {\n const { runExecute } = await import('./commands/execute.js');\n const code = await runExecute(positionalMaxIter, options);\n process.exit(code);\n } catch (error) {\n printError(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n },\n);\n\n// ── review ──────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('review')\n .description('Validate an issue resolution with the configured agent')\n .argument('<issue>', 'Issue number'),\n ),\n).action(async (issue: string) => {\n const { runReview } = await import('./commands/review.js');\n const code = await runReview(issue);\n process.exit(code);\n});\n\n// ── pr ──────────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('pr')\n .description('Create a pull request with the configured agent')\n .argument('<issue>', 'Issue number'),\n ),\n).action(async (issue: string) => {\n const { runPr } = await import('./commands/pr.js');\n const code = await runPr(issue);\n process.exit(code);\n});\n\n// ── web ─────────────────────────────────────────────────────────────────────\nconst webCommand = program.command('web').description('Manage the web monitoring server');\n\nwebCommand\n .command('serve')\n .description(\n 'Run the web monitor server in the foreground (internal — spawned detached by --web)',\n )\n .option('--port <n>', 'Web server port (default: 3737)', parseInteger)\n .option('--host <h>', 'Web server host (default: 0.0.0.0)')\n .option('--refresh <s>', 'Suggested UI polling interval in seconds', parseInteger)\n .action(async (options: { port?: number; host?: string; refresh?: number }) => {\n const { runWebServe } = await import('./commands/web.js');\n const code = await runWebServe(options);\n // On success this process stays alive for as long as the server is bound\n // (server.ts binds it with unref: false) — only a failure exits here.\n if (code !== 0) {\n process.exit(code);\n }\n });\n\nwebCommand\n .command('stop')\n .description('Stop the running web monitor server')\n .action(async () => {\n const { runWebStop } = await import('./commands/web.js');\n const code = await runWebStop();\n process.exit(code);\n });\n\n// ── policy ──────────────────────────────────────────────────────────────\nwithGlobalOptions(\n program\n .command('policy')\n .description('Inspect the policies discovered in this repository and their provenance')\n .option('--scope <dir>', 'Resolve the policy for a subdirectory (monorepo)')\n .option('--json', 'Emit the resolved policy as JSON'),\n).action(async (options: { scope?: string; json?: boolean }) => {\n const { runPolicy } = await import('./commands/policy.js');\n const code = await runPolicy(options);\n process.exit(code);\n});\n\nconst routingCommand = withGlobalOptions(\n program.command('routing').description('Inspect and configure adaptive harness/model routing'),\n);\nroutingCommand\n .option('--json', 'Emit the resolved routing config as JSON')\n .action(async (_options: unknown, command: Command) => {\n const { runRoutingInspect } = await import('./commands/routing.js');\n process.exit(await runRoutingInspect(command.opts()));\n });\nroutingCommand\n .command('explain')\n .description('Explain the resolved routing target for every phase')\n .option('--json', 'Emit JSON')\n .action(async (_options: unknown, command: Command) => {\n const { runRoutingExplain } = await import('./commands/routing.js');\n process.exit(await runRoutingExplain(command.optsWithGlobals()));\n });\nroutingCommand\n .command('use')\n .description('Enable an embedded routing policy')\n .argument('<policy>', 'Policy name (recommended)')\n .option('--global', 'Write ~/.issue-flow/config.json (default)')\n .option('--project', 'Write .issue-flow.json instead')\n .option('--active', 'Apply the policy to future runs instead of leaving routing in shadow mode')\n .action(async (policy: string, _options: unknown, command: Command) => {\n const { runRoutingUse } = await import('./commands/routing.js');\n process.exit(await runRoutingUse(policy, command.optsWithGlobals()));\n });\nroutingCommand\n .command('report')\n .description('Shadow agreement between selected and actual harness')\n .option('--issue <n>', 'Issue number')\n .option('--json', 'Emit JSON')\n .action(async (_options: unknown, command: Command) => {\n const { runRoutingReport } = await import('./commands/routing.js');\n process.exit(await runRoutingReport(command.optsWithGlobals()));\n });\n\nconst conventionsCommand = withGlobalOptions(\n program\n .command('conventions')\n .description('Compute the repository Git convention (branch, commit, PR title)'),\n);\nconventionsCommand\n .command('branch')\n .description('Print the deterministic branch name for an issue')\n .option('--issue <n>', 'Issue number')\n .option('--title <text>', 'Issue title, when the issue cannot be resolved')\n .option('--json', 'Emit JSON')\n .action(async (options: { issue?: string; title?: string; json?: boolean }) => {\n const { runConventionsBranch } = await import('./commands/conventions.js');\n process.exit(await runConventionsBranch(options));\n });\nconventionsCommand\n .command('commit')\n .description('Print a Conventional Commit message')\n .requiredOption('--type <type>', 'Change type (feat, fix, docs, …)')\n .option('--scope <scope>', 'Optional scope')\n .requiredOption('--subject <text>', 'Commit subject')\n .option('--issue <n>', 'Issue number for the Refs trailer')\n .option('--story <id>', 'Story id (US-010)')\n .option('--breaking <text>', 'Breaking change description')\n .option('--json', 'Emit JSON')\n .action(\n async (options: {\n type: string;\n scope?: string;\n subject: string;\n issue?: string;\n story?: string;\n breaking?: string;\n json?: boolean;\n }) => {\n const { runConventionsCommit } = await import('./commands/conventions.js');\n process.exit(await runConventionsCommit(options));\n },\n );\nconventionsCommand\n .command('pr-title')\n .description('Print the Conventional Commit Pull Request title')\n .option('--issue <n>', 'Issue number')\n .option('--title <text>', 'Issue title, when the issue cannot be resolved')\n .option('--json', 'Emit JSON')\n .action(async (options: { issue?: string; title?: string; json?: boolean }) => {\n const { runConventionsPrTitle } = await import('./commands/conventions.js');\n process.exit(await runConventionsPrTitle(options));\n });\n\n// ── agent ───────────────────────────────────────────────────────────────\nconst agentCommand = withGlobalOptions(\n program\n .command('agent')\n .description('Inspect the resolved agent and model for each phase')\n .option('--json', 'Emit the resolved agent configuration as JSON'),\n);\nagentCommand.action(async (options: { json?: boolean }) => {\n const { runAgent } = await import('./commands/agent.js');\n const code = await runAgent(options);\n process.exit(code);\n});\n\nagentCommand\n .command('use')\n .description('Write an agent preference to config.json or .issue-flow.json')\n .argument('<provider>', 'claude, codex, cursor or antigravity')\n .option('--model <model>', 'Model identifier for this preference')\n .option('--global', 'Write to ~/.issue-flow/config.json (default)')\n .option('--project', 'Write to .issue-flow.json in the repository')\n .option('--phase <phase>', 'Write only the override for this phase')\n .action(\n async (\n provider: string,\n options: { model?: string; global?: boolean; project?: boolean; phase?: string },\n ) => {\n const { runAgentUse } = await import('./commands/agent.js');\n const code = await runAgentUse(provider, options);\n process.exit(code);\n },\n );\n\n// ── pr-review ───────────────────────────────────────────────────────────────\nwithGlobalOptions(\n program\n .command('pr-review')\n .description('Review a Pull Request as a whole with the configured agent')\n .argument('[pr]', 'Pull Request number (discovered from the session when omitted)')\n .option('--issue <n>', 'Issue the Pull Request belongs to')\n .option('--round <n>', 'Rewrite a specific review round instead of appending a new one')\n .option('--yes', 'Skip the confirmation of the discovered Pull Request')\n .option(\n '--fail-on <level>',\n 'Verdict that fails the command: request-changes | suggestions | none',\n ),\n).action(\n async (\n pr: string | undefined,\n options: { issue?: string; round?: string; yes?: boolean; failOn?: string },\n ) => {\n const { runPrReview } = await import('./commands/pr-review.js');\n const code = await runPrReview(pr, options);\n process.exit(code);\n },\n);\n\n// ── bench ───────────────────────────────────────────────────────────────────\nwithGlobalOptions(\n program\n .command('bench')\n .description('Measure the corpus: synthetic (CI) or real (paid, on demand)')\n .option('--mode <mode>', 'synthetic (default, free) or real (fixtures + harness)')\n .option(\n '--task <class>',\n 'Corpus class (repeatable): trivial, small, medium, analysis',\n collectString,\n [],\n )\n .option('--arm <name>', 'Experiment arm (repeatable). Default: baseline', collectString, [])\n .option('--repeats <n>', 'Repetitions per cell (default 5)', parseInteger)\n // Campaign-wide ceilings, distinct from the per-issue `--max-cost` /\n // `--max-duration` of `withGlobalOptions`: one campaign runs many issues,\n // and the two budgets are not the same number. The names differ because\n // the flags coexist on this command — and because the units differ too.\n .option(\n '--campaign-max-cost <usd>',\n 'Campaign cost ceiling in USD (evaluateCeilings)',\n parseUsd,\n )\n .option(\n '--campaign-max-duration <ms>',\n 'Campaign duration ceiling in milliseconds',\n parseInteger,\n )\n .option('--out <path>', 'Write the markdown report to this path')\n .option('--yes', 'Skip the paid-campaign confirmation')\n .option('--repo <path>', 'Investigation escape; does not produce a publishable row')\n .option('--json', 'Also emit the campaign JSON'),\n).action(\n async (options: {\n mode?: string;\n task?: string[];\n arm?: string[];\n repeats?: number;\n campaignMaxCost?: number;\n campaignMaxDuration?: number;\n out?: string;\n yes?: boolean;\n repo?: string;\n json?: boolean;\n }) => {\n if (options.mode !== undefined && options.mode !== 'synthetic' && options.mode !== 'real') {\n printError(\"Unknown bench mode. Use 'synthetic' or 'real'.\");\n process.exit(1);\n }\n const { runBench } = await import('./commands/bench.js');\n process.exit(\n await runBench({\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.task === undefined || options.task.length === 0 ? {} : { task: options.task }),\n ...(options.arm === undefined || options.arm.length === 0 ? {} : { arm: options.arm }),\n ...(options.repeats === undefined ? {} : { repeats: options.repeats }),\n ...(options.campaignMaxCost === undefined ? {} : { maxCost: options.campaignMaxCost }),\n ...(options.campaignMaxDuration === undefined\n ? {}\n : { maxDuration: options.campaignMaxDuration }),\n ...(options.out === undefined ? {} : { out: options.out }),\n ...(options.yes === undefined ? {} : { yes: options.yes }),\n ...(options.repo === undefined ? {} : { repo: options.repo }),\n ...(options.json === undefined ? {} : { json: options.json }),\n }),\n );\n },\n);\n\nprogram.action(async () => {\n const { listLiveRuns } = await import('./execution/registry.js');\n const runs = await listLiveRuns();\n if (runs.length === 0) {\n program.help();\n return;\n }\n const { runPs } = await import('./commands/ps.js');\n process.exit(await runPs());\n});\n\nprogram.parse();\n","/**\n * Pure mappings from parsed CLI options to command arguments.\n *\n * They live outside cli.ts because that module runs `program.parse()` on\n * import, so anything defined there is untestable.\n */\n\nimport type { WebConfig } from './schemas.js';\n\n/** Extract ephemeral/config-backed web flags from commander's camel-cased options. */\nexport function resolveWebOverrides(opts: Record<string, unknown>): Partial<WebConfig> {\n const overrides: Partial<WebConfig> = {};\n if (opts.web === true || opts.serve === true || opts.restartWeb === true) {\n overrides.enabled = true;\n }\n if (opts.port !== undefined) overrides.port = opts.port as number;\n if (opts.host !== undefined) overrides.host = opts.host as string;\n if (opts.refresh !== undefined) overrides.refreshSeconds = opts.refresh as number;\n if (opts.webLogLimit !== undefined) overrides.logLimit = opts.webLogLimit as number;\n if (opts.webNoLogs === true) overrides.includeLogs = false;\n return overrides;\n}\n\n/** Shape commander produces for a negated boolean option (`--no-branch`). */\nexport interface BranchFlagOptions {\n branch?: boolean;\n}\n\n/**\n * Translate commander's `--no-branch` into the tri-state `runPipeline` expects.\n *\n * Commander stores a negated option under its positive name: `--no-branch`\n * yields `{ branch: false }` and never a `noBranch` key. Reading `noBranch`\n * silently dropped the flag, so the pipeline always created a branch and opened\n * a PR.\n *\n * `undefined` (flag absent) is preserved on purpose: `runPipeline` uses it to\n * tell \"the user said nothing, keep the mode persisted in tasks.json\" apart\n * from an explicit choice.\n */\nexport function resolveNoBranch(options: BranchFlagOptions): boolean | undefined {\n return options.branch === false ? true : undefined;\n}\n\n/** Invalid flag combination on a command, reported as a CLI error. */\nexport class CliFlagError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'CliFlagError';\n }\n}\n\n/** Options `run` accepts that select which phases the pipeline executes. */\nexport interface RunPhaseFlagOptions extends BranchFlagOptions {\n prReview?: boolean;\n}\n\n/** Phase selection `runPipeline` expects, both entries tri-state. */\nexport interface RunPhaseFlags {\n noBranch: boolean | undefined;\n prReview: boolean | undefined;\n}\n\n/** Scope flags of `run`, deciding what a discovered hierarchy does. */\nexport interface QueueScopeFlagOptions {\n yes?: boolean;\n only?: boolean;\n cascade?: boolean;\n}\n\n/** Resolved scope answer; both absent means \"ask, when the terminal allows it\". */\nexport interface QueueScopeFlags {\n yes: boolean | undefined;\n only: boolean | undefined;\n cascade: boolean | undefined;\n}\n\n/**\n * Resolve `--yes` / `--only`, rejecting the combination that has no meaning.\n *\n * They answer the same question in opposite ways — run everything that was\n * discovered, or run only what was asked for — so passing both is a mistake\n * worth naming rather than silently resolving by precedence.\n *\n * @throws CliFlagError when both are present.\n */\nexport function resolveQueueScopeFlags(options: QueueScopeFlagOptions): QueueScopeFlags {\n if (options.yes === true && options.only === true) {\n throw new CliFlagError(\n '--yes cannot be combined with --only: --yes runs the whole discovered hierarchy, ' +\n '--only runs just the issues you informed.',\n );\n }\n if (options.cascade === true && options.only === true) {\n throw new CliFlagError(\n '--cascade cannot be combined with --only: --cascade runs the container hierarchy, ' +\n '--only runs just the issues you informed.',\n );\n }\n\n return {\n yes: options.yes === true ? true : undefined,\n only: options.only === true ? true : undefined,\n cascade: options.cascade === true ? true : undefined,\n };\n}\n\n/**\n * Resolve the phase-selection flags of `run`, rejecting the one combination\n * that cannot work.\n *\n * `--no-branch` skips the `pr` phase, so there is no Pull Request for\n * `--pr-review` to review. Failing here — before any phase runs — beats\n * discovering it at the end of a full pipeline.\n *\n * Both values stay `undefined` when the user passed nothing: `runPipeline`\n * uses that to tell \"no opinion, keep what tasks.json persisted\" apart from an\n * explicit choice.\n *\n * @throws CliFlagError when `--pr-review` is combined with `--no-branch`.\n */\nexport function resolveRunPhaseFlags(options: RunPhaseFlagOptions): RunPhaseFlags {\n const noBranch = resolveNoBranch(options);\n const prReview = options.prReview === true ? true : undefined;\n\n if (prReview === true && noBranch === true) {\n throw new CliFlagError(\n '--pr-review cannot be combined with --no-branch: --no-branch skips the pr phase, ' +\n 'so there is no Pull Request to review.',\n );\n }\n\n return { noBranch, prReview };\n}\n\n/** Options `run` and `plan` accept to override User Story numbering (issue #36). */\nexport interface UserStoryNumberingFlagOptions {\n continue?: boolean;\n startUs?: number;\n}\n\n/** Resolved User Story numbering override, ready for `determineUserStoryNumbering()`. */\nexport interface UserStoryNumberingFlags {\n continueFlag: boolean;\n startUs: number | undefined;\n}\n\n/**\n * Resolve the `--continue` / `--start-us <n>` override of the User Story\n * numbering cascade (issue #36), rejecting the one combination that cannot\n * work: the two disagree about whether history should be consulted at all.\n *\n * @throws CliFlagError when both flags are passed together.\n */\nexport function resolveUserStoryNumberingFlags(\n options: UserStoryNumberingFlagOptions,\n): UserStoryNumberingFlags {\n const continueFlag = options.continue === true;\n const startUs = options.startUs;\n\n if (continueFlag && startUs !== undefined) {\n throw new CliFlagError(\n '--continue and --start-us cannot be combined: choose either the last known numbering ' +\n '(--continue) or an explicit override (--start-us).',\n );\n }\n\n return { continueFlag, startUs };\n}\n","import type { IssueGenerateTarget, IssuesConfig } from './types.js';\n\n/**\n * Mapping from the Issue provider CLI flags to configuration overrides.\n *\n * Kept out of cli.ts (which runs `program.parse()` on import) so the\n * precedence rules stay unit-testable. Only the keys the user actually passed\n * are returned: a key present with `undefined` would override .issue-flow.json\n * when the layers are merged.\n */\n\nexport interface IssueCliFlags {\n local?: boolean;\n github?: boolean;\n preferLocal?: boolean;\n preferGithub?: boolean;\n ask?: boolean;\n}\n\n/** Invalid flag combination, reported to the user as a CLI error. */\nexport class IssueFlagError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'IssueFlagError';\n }\n}\n\n/**\n * Translate the parsed options of a command into `IssuesConfig` overrides.\n *\n * @throws IssueFlagError when mutually exclusive flags are combined.\n */\nexport function resolveIssuesOverrides(opts: IssueCliFlags): Partial<IssuesConfig> {\n const overrides: Partial<IssuesConfig> = {};\n\n if (opts.local === true && opts.github === true) {\n throw new IssueFlagError('--local and --github are mutually exclusive; pass only one.');\n }\n if (opts.local === true) {\n overrides.preferredProvider = 'local';\n }\n if (opts.github === true) {\n overrides.preferredProvider = 'github';\n }\n\n const conflictFlags = [\n opts.preferLocal === true ? '--prefer-local' : null,\n opts.preferGithub === true ? '--prefer-github' : null,\n opts.ask === true ? '--ask' : null,\n ].filter((flag): flag is string => flag !== null);\n\n if (conflictFlags.length > 1) {\n throw new IssueFlagError(\n `${conflictFlags.join(', ')} are mutually exclusive; pass only one conflict policy.`,\n );\n }\n if (opts.preferLocal === true) {\n overrides.conflictPolicy = 'prefer-local';\n }\n if (opts.preferGithub === true) {\n overrides.conflictPolicy = 'prefer-github';\n }\n if (opts.ask === true) {\n overrides.conflictPolicy = 'ask';\n }\n\n return overrides;\n}\n\n/** Destination flags accepted by `generate`. */\nexport interface GenerateTargetFlags {\n github?: boolean;\n local?: boolean;\n both?: boolean;\n}\n\n/**\n * Destination the generated Issue is created in, or `undefined` when the user\n * passed no flag (the caller then falls back to `defaultGenerateTarget`).\n *\n * @throws IssueFlagError when more than one destination is requested.\n */\nexport function resolveGenerateTarget(opts: GenerateTargetFlags): IssueGenerateTarget | undefined {\n const selected: IssueGenerateTarget[] = [];\n if (opts.github === true) selected.push('github');\n if (opts.local === true) selected.push('local');\n if (opts.both === true) selected.push('both');\n\n if (selected.length > 1) {\n throw new IssueFlagError(\n `${selected.map((target) => `--${target}`).join(', ')} are mutually exclusive; ` +\n 'pass only one destination.',\n );\n }\n\n return selected[0];\n}\n","import { DEFAULT_INACTIVITY_TIMEOUT_MS } from '../core/watchdog.js';\nimport type { ResilienceConfig } from '../storage/schemas.js';\n\n/**\n * The resilience flags, turned into the CLI rung of the configuration ladder.\n *\n * Kept out of `cli.ts` (which runs `program.parse()` on import) so the mapping\n * is testable on its own, the same reason `cli-options.ts` and\n * `issues/cli-flags.ts` live outside it.\n *\n * **`--continuous` is a profile, not a mechanism.** Long autonomous work needs\n * about six behaviours turned on at once, and asking for six flags is asking\n * for five of them to be forgotten. So the profile names the *intent* — \"keep\n * going without me\" — and expands to the settings that intent implies, every\n * one of which stays adjustable on its own.\n */\n\nexport interface ResilienceFlags {\n /** `--continuous` / `--resilient`: the long-running profile. */\n continuous?: boolean;\n resilient?: boolean;\n /** `--no-failover`: never migrate a phase to another provider. */\n failover?: boolean;\n /** `--auto-decompose`: act on a decomposition report instead of reporting. */\n autoDecompose?: boolean;\n /** `--inactivity-timeout <seconds>`: the watchdog budget. */\n inactivityTimeout?: number;\n /** `--on-issue-failure <mode>`: what a failing issue does to the queue. */\n onIssueFailure?: 'stop' | 'skip' | 'block';\n}\n\n/**\n * What `--continuous` turns on.\n *\n * The retry side is the `continuous` **profile** of `resolvePolicy()` — network\n * and rate limits retried forever, wider budgets for the rest — rather than a\n * list of numbers repeated here, so the two cannot drift. The rest is what the\n * profile implies at the pipeline level: keep the queue moving, keep a journal\n * of what happened, and notice an agent that has gone quiet.\n */\nfunction continuousProfile(): ResilienceConfig {\n return {\n profile: 'continuous',\n providers: { failover: true },\n queue: { onIssueFailure: 'skip' },\n journal: { enabled: true },\n watchdog: { inactivityTimeoutMs: DEFAULT_INACTIVITY_TIMEOUT_MS },\n };\n}\n\n/**\n * Resolve the flags into one `resilience` object.\n *\n * The profile is applied first and the granular flags on top of it, which is\n * the whole precedence rule: **an explicit flag always beats the profile**.\n * `--continuous --no-failover` is a coherent thing to ask for and means exactly\n * what it says.\n */\nexport function resolveResilienceOverrides(flags: ResilienceFlags): ResilienceConfig {\n const continuous = flags.continuous === true || flags.resilient === true;\n const overrides: ResilienceConfig = continuous ? continuousProfile() : {};\n\n // Commander maps `--no-failover` to `failover: false`, and leaves the field\n // absent when the flag was not passed — so `false` here is always explicit.\n if (flags.failover === false) {\n overrides.providers = { ...overrides.providers, failover: false };\n }\n if (flags.autoDecompose === true) {\n overrides.decompose = { ...overrides.decompose, auto: true };\n }\n if (flags.inactivityTimeout !== undefined) {\n overrides.watchdog = {\n ...overrides.watchdog,\n inactivityTimeoutMs: flags.inactivityTimeout * 1000,\n };\n }\n if (flags.onIssueFailure !== undefined)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AAAA,QACxD,GAAI,QAAQ,QAAQ,SAAY,CAAC,IAAI,EAAE,KAAK,QAAQ,IAAI;AAAA,QACxD,GAAI,QAAQ,SAAS,SAAY,CAAC,IAAI,EAAE,MAAM,QAAQ,KAAK;AAAA,QAC3D,GAAI,QAAQ,SAAS,SAAY,CAAC,IAAI,EAAE,MAAM,QAAQ,KAAK;AAAA,MAC7D,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,QAAQ,OAAO,YAAY;AACzB,QAAM,EAAE,aAAa,IAAI,MAAM,OAAO,wBAAyB;AAC/D,QAAM,OAAO,MAAM,aAAa;AAChC,MAAI,KAAK,WAAW,GAAG;AACrB,YAAQ,KAAK;AACb;AAAA,EACF;AACA,QAAM,EAAE,MAAM,IAAI,MAAM,OAAO,kBAAkB;AACjD,UAAQ,KAAK,MAAM,MAAM,CAAC;AAC5B,CAAC;AAED,QAAQ,MAAM;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/cli-options.ts","../src/issues/cli-flags.ts","../src/resilience/cli-flags.ts"],"sourcesContent":["import { Command, InvalidArgumentError, Option } from 'commander';\nimport { parseAgentPhaseFlag } from './agents/resolve.js';\nimport { type AgentCliOverrides, isAgentProviderId } from './agents/types.js';\nimport {\n CliFlagError,\n resolveQueueScopeFlags,\n resolveRunPhaseFlags,\n resolveUserStoryNumberingFlags,\n resolveWebOverrides,\n} from './cli-options.js';\nimport {\n setAgentCliOverrides,\n setIssuesCliOverrides,\n setResilienceCliOverrides,\n setRoutingCliOverrides,\n setVerifyCliOverrides,\n setWebCliOverrides,\n} from './config.js';\nimport { installShutdownHandlers } from './core/shutdown.js';\nimport { setGlobalTimeout, setInactivityTimeout, setVerbose } from './core/verbose.js';\nimport {\n IssueFlagError,\n resolveGenerateTarget,\n resolveIssuesOverrides,\n} from './issues/cli-flags.js';\nimport type { IssueGenerateTarget } from './issues/types.js';\nimport { resolveResilienceOverrides } from './resilience/cli-flags.js';\nimport type { RoutingConfig } from './schemas.js';\nimport { printError } from './ui/logger.js';\nimport { getPackageVersion } from './version.js';\n\nconst version = getPackageVersion();\n\n/**\n * Parse a numeric string, throwing InvalidArgumentError if not a valid number.\n */\nfunction parseInteger(value: string): number {\n const parsed = parseInt(value, 10);\n if (Number.isNaN(parsed) || parsed < 0) {\n throw new InvalidArgumentError('Must be a non-negative integer.');\n }\n return parsed;\n}\n\nfunction parseUsd(value: string): number {\n const parsed = Number.parseFloat(value);\n if (!Number.isFinite(parsed) || parsed < 0) {\n throw new InvalidArgumentError('Must be a non-negative number.');\n }\n return parsed;\n}\n\nfunction collectString(value: string, previous: string[]): string[] {\n return [...previous, value];\n}\n\n/** Parse `--on-issue-failure <mode>`, rejecting anything but the three modes. */\nfunction parseQueueFailureMode(value: string): 'stop' | 'skip' | 'block' {\n if (value === 'stop' || value === 'skip' || value === 'block') return value;\n throw new InvalidArgumentError('Must be one of: stop, skip, block.');\n}\n\n/**\n * Parse `--start-us <n>`: a User Story number is 1-based, so 0 is rejected\n * along with everything `parseInteger` already rejects.\n */\nfunction parseStartUs(value: string): number {\n const parsed = parseInteger(value);\n if (parsed < 1) {\n throw new InvalidArgumentError('Must be a positive integer (US-001 is the first story).');\n }\n return parsed;\n}\n\n/**\n * Add the User Story numbering override options to a subcommand that\n * triggers `plan` (`run` and `plan` itself) — see issue #36.\n */\nfunction withUserStoryNumberingOptions(cmd: Command): Command {\n return cmd\n .option('--continue', 'Continue User Story numbering from the last used in this project')\n .option(\n '--start-us <n>',\n 'Force User Story numbering to start at a specific number, ignoring history',\n parseStartUs,\n );\n}\n\n/**\n * Add shared options (--verbose) to a subcommand.\n */\nfunction withGlobalOptions(cmd: Command): Command {\n return (\n cmd\n .option('-v, --verbose', 'Show agent progress output in real time')\n .option(\n '-t, --timeout <seconds>',\n 'Override headless timeout in seconds (0 = no limit)',\n parseInteger,\n )\n // The second, tighter instrument beside the absolute timeout: a phase that\n // has said nothing for this long is stuck, not slow. `0` turns it off.\n .option(\n '--inactivity-timeout <seconds>',\n 'Stop the agent after this many seconds with no output (0 = no watchdog)',\n parseInteger,\n )\n .option(\n '--agent <provider>',\n 'Run every phase on this agent (claude|codex|cursor|antigravity|opencode)',\n )\n .option('--agent-model <model>', 'Override the model for every phase')\n .option(\n '--agent-phase <phase>=<provider>[:<model>]',\n 'Override one phase (repeatable)',\n collectAgentPhase,\n {} as AgentCliOverrides['phases'],\n )\n .option('--verify-level <level>', 'Acceptance-contract level: L0 | L1 | L2 | L3 | L5')\n .option('--no-cross-verify', 'Keep L2 off even when a trigger would fire')\n .option('--no-escalation', 'Keep routing.escalation.enabled off')\n .option('--max-cost <usd>', 'Issue cost ceiling in USD (Issue Flow enforces it)', parseUsd)\n .option('--max-duration <seconds>', 'Issue duration ceiling in seconds', parseInteger)\n );\n}\n\nfunction collectAgentPhase(\n value: string,\n previous: NonNullable<AgentCliOverrides['phases']> | undefined,\n): NonNullable<AgentCliOverrides['phases']> {\n const parsed = parseAgentPhaseFlag(value);\n return { ...previous, [parsed.phase]: parsed.block };\n}\n\nfunction resolveAgentOverrides(opts: Record<string, unknown>): AgentCliOverrides {\n const overrides: AgentCliOverrides = {};\n if (typeof opts.agent === 'string') {\n if (!isAgentProviderId(opts.agent)) {\n throw new InvalidArgumentError(\n 'Must be one of: claude, codex, cursor, antigravity, opencode.',\n );\n }\n overrides.forceProvider = opts.agent;\n }\n if (typeof opts.agentModel === 'string') {\n overrides.forceModel = opts.agentModel;\n }\n if (opts.agentPhase && typeof opts.agentPhase === 'object') {\n overrides.phases = opts.agentPhase as AgentCliOverrides['phases'];\n }\n return overrides;\n}\n\nconst VERIFY_LEVELS = ['L0', 'L1', 'L2', 'L3', 'L5'] as const;\n\nfunction resolveVerifyOverrides(opts: Record<string, unknown>): {\n level?: (typeof VERIFY_LEVELS)[number];\n crossVerify?: boolean;\n} {\n const overrides: { level?: (typeof VERIFY_LEVELS)[number]; crossVerify?: boolean } = {};\n if (typeof opts.verifyLevel === 'string') {\n if (!VERIFY_LEVELS.includes(opts.verifyLevel as (typeof VERIFY_LEVELS)[number])) {\n throw new InvalidArgumentError('Must be one of: L0, L1, L2, L3, L5.');\n }\n overrides.level = opts.verifyLevel as (typeof VERIFY_LEVELS)[number];\n }\n if (opts.crossVerify === false) overrides.crossVerify = false;\n return overrides;\n}\n\nfunction resolveRoutingOverrides(opts: Record<string, unknown>): Partial<RoutingConfig> {\n const overrides: Partial<RoutingConfig> = {};\n if (opts.escalation === false) {\n overrides.escalation = {\n enabled: false,\n minAttemptsBeforeEscalation: 2,\n maxEscalations: 2,\n maxRungs: ['effort', 'model', 'harness'],\n };\n }\n if (typeof opts.maxCost === 'number' || typeof opts.maxDuration === 'number') {\n overrides.ceilings = {\n maxCostUsdPerIssue: typeof opts.maxCost === 'number' ? opts.maxCost : null,\n maxDurationMsPerIssue: typeof opts.maxDuration === 'number' ? opts.maxDuration * 1000 : null,\n maxExecutionsPerIssue: null,\n onCeiling: 'block',\n };\n }\n return overrides;\n}\n\n/**\n * Add the resilience options to a subcommand, in the shape `--web` and\n * `--pr-review` already follow: declared here, resolved into configuration\n * overrides by the preAction hook, and applied through the same ladder every\n * other key climbs.\n */\nfunction withResilienceOptions(cmd: Command): Command {\n return cmd\n .option('--continuous', 'Long-running profile: keep going without supervision')\n .option('--resilient', 'Alias of --continuous')\n .option('--no-failover', 'Never migrate a phase to another agent provider')\n .option('--auto-decompose', 'Act on a decomposition report instead of only writing it');\n}\n\n/**\n * Add web monitoring options to a subcommand (run and execute only).\n * The values are resolved into CLI overrides by the preAction hook below;\n * loadWebConfig() applies the flag > env > file > defaults precedence.\n */\nfunction withWebOptions(cmd: Command): Command {\n return cmd\n .option('--web', 'Enable the web monitoring server')\n .option('--serve', 'Alias for --web')\n .option('--restart-web', 'Restart the web monitor before serving it (implies --web)')\n .option('--port <n>', 'Web server port (default: 3737)', parseInteger)\n .option('--host <h>', 'Web server host (default: 0.0.0.0)')\n .option('--refresh <s>', 'Suggested UI polling interval in seconds', parseInteger)\n .option('--web-log-limit <n>', 'Max log entries kept in the snapshot', parseInteger)\n .option('--web-no-logs', 'Exclude logs from the published snapshot');\n}\n\n/**\n * Add the Issue provider options to a subcommand.\n *\n * Declared once here (like withWebOptions) so no command repeats the flag\n * list; the preAction hook below turns them into config overrides, and\n * loadIssuesConfig() applies the flag > .issue-flow.json > defaults precedence.\n */\nfunction withIssueOptions(cmd: Command): Command {\n return cmd\n .option('--local', 'Prefer the local file Issue provider')\n .option('--github', 'Prefer the GitHub Issue provider')\n .option('--prefer-local', 'On divergence, use the local version without asking')\n .option('--prefer-github', 'On divergence, use the GitHub version without asking')\n .option('--ask', 'On divergence, ask which version to use (interactive only)');\n}\n\nconst program = new Command();\n\nprogram\n .name('issue-flow')\n .description(\n 'Unified CLI for orchestrating the full issue-flow pipeline via Claude Code, Codex CLI, Cursor CLI or Antigravity CLI.',\n )\n .version(version);\n\nprogram.hook('preAction', (_thisCommand, actionCommand) => {\n // Installed once, before any command runs: a `Ctrl+C` during a six-hour run\n // has to write a checkpoint and stop the agent, not kill the process\n // mid-phase and leave `session.json` on `running` forever.\n installShutdownHandlers();\n\n const opts = actionCommand.opts();\n if (opts.verbose) {\n setVerbose(true);\n }\n if (opts.timeout !== undefined) {\n setGlobalTimeout(opts.timeout * 1000);\n }\n if (opts.inactivityTimeout !== undefined) {\n setInactivityTimeout(opts.inactivityTimeout * 1000);\n }\n setWebCliOverrides(resolveWebOverrides(opts));\n try {\n setVerifyCliOverrides(resolveVerifyOverrides(opts));\n setAgentCliOverrides(resolveAgentOverrides(opts));\n setRoutingCliOverrides(resolveRoutingOverrides(opts));\n } catch (error) {\n if (error instanceof InvalidArgumentError) {\n printError(error.message);\n process.exit(1);\n }\n throw error;\n }\n // The CLI rung of the `resilience` ladder. `--continuous` expands here into\n // the settings it implies, with every granular flag applied on top of it.\n setResilienceCliOverrides(\n resolveResilienceOverrides({\n continuous: opts.continuous,\n resilient: opts.resilient,\n failover: opts.failover,\n autoDecompose: opts.autoDecompose,\n inactivityTimeout: opts.inactivityTimeout,\n onIssueFailure: opts.onIssueFailure,\n }),\n );\n try {\n setIssuesCliOverrides(resolveIssuesOverrides(opts));\n } catch (error) {\n if (error instanceof IssueFlagError) {\n printError(error.message);\n process.exit(1);\n }\n throw error;\n }\n});\n\n// ── init ────────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('init')\n .description(\n 'Check prerequisites and report (or create) the conventions this repository is missing',\n )\n .option('--apply', 'Create the missing files instead of only reporting them')\n .option('--json', 'Emit the plan as JSON')\n .option('--scope <dir>', 'Resolve the conventions for a subdirectory (monorepo)')\n .option('--check-only', 'Only verify prerequisites, as earlier releases did')\n .option('--no-agent-prompt', 'Skip the first-run agent choice'),\n ),\n).action(\n async (options: {\n apply?: boolean;\n json?: boolean;\n scope?: string;\n checkOnly?: boolean;\n agentPrompt?: boolean;\n }) => {\n const { loadIssuesConfig } = await import('./config.js');\n const { runInit } = await import('./commands/init.js');\n const { preferredProvider } = await loadIssuesConfig();\n const code = await runInit(preferredProvider, {\n ...options,\n noAgentPrompt: options.agentPrompt === false,\n });\n process.exit(code);\n },\n);\n\n// ── generate ────────────────────────────────────────────────────────────────\nwithGlobalOptions(\n program\n .command('generate')\n .description('Draft an issue with the configured agent and create it')\n .requiredOption('--prompt <text>', 'Issue description text')\n .option('--github', 'Create the issue on GitHub')\n .option('--local', 'Create the issue under issues/<n>/ only')\n .option('--both', 'Create the issue on GitHub and mirror it locally'),\n).action(async (options: { prompt: string; github?: boolean; local?: boolean; both?: boolean }) => {\n let target: IssueGenerateTarget | undefined;\n try {\n target = resolveGenerateTarget(options);\n } catch (error) {\n if (error instanceof IssueFlagError) {\n printError(error.message);\n process.exit(1);\n }\n throw error;\n }\n\n const { runGenerate } = await import('./commands/generate.js');\n const code = await runGenerate(options.prompt, target);\n process.exit(code);\n});\n\n// ── run ─────────────────────────────────────────────────────────────────────\nwithUserStoryNumberingOptions(\n withResilienceOptions(\n withWebOptions(\n withIssueOptions(\n withGlobalOptions(\n program\n .command('run')\n .description(\n 'Execute the full pipeline: prd → plan → execute → review → pr (→ pr-review, optional)',\n )\n .argument('<issues...>', 'Issue number(s): 42, \"42,43\" or 42 43')\n .option('--mode <mode>', 'Execution mode: auto | manual', 'auto')\n .option('--from <phase>', 'Resume from a specific phase')\n .option(\n '--no-branch',\n 'Run pipeline on current branch without creating a new branch or PR',\n )\n .option('--pr-review', 'Review the created Pull Request after the pr phase')\n .option('--close-issue', 'Close issues after successful delivery; remember this choice')\n .option('--no-close-issue', 'Revoke automatic issue closure')\n .option('-y, --yes', 'Run the whole discovered hierarchy without confirmation')\n .option('--cascade', 'Run the children of a container, without implementing it')\n .option('--only', 'Run just the issues informed, without their hierarchy')\n // Same two flags `execute` has always had, forwarded to the execute\n // phase of the pipeline: a `run` is the only way most users reach that\n // loop, and had no way to widen its retry budget.\n .option(\n '--retry-limit <number>',\n 'Retry transient Claude failures up to N consecutive times',\n parseInteger,\n )\n .option('--retry-forever', 'Retry transient Claude failures indefinitely')\n // What one failing issue does to the rest of a queue. `stop` is what\n // every release before this flag did, and stays the default.\n .option(\n '--on-issue-failure <mode>',\n 'In a queue, on a failing issue: stop | skip | block',\n parseQueueFailureMode,\n )\n .option('-d, --background', 'Detach after confirmation and return the terminal')\n .addOption(new Option('--detached-child').hideHelp()),\n ),\n ),\n ),\n ),\n).action(\n async (\n issues: string[],\n options: {\n mode: string;\n from?: string;\n branch?: boolean;\n prReview?: boolean;\n closeIssue?: boolean;\n yes?: boolean;\n only?: boolean;\n continue?: boolean;\n startUs?: number;\n retryLimit?: number;\n retryForever?: boolean;\n onIssueFailure?: 'stop' | 'skip' | 'block';\n background?: boolean;\n detachedChild?: boolean;\n restartWeb?: boolean;\n },\n ) => {\n let phases: ReturnType<typeof resolveRunPhaseFlags>;\n let scope: ReturnType<typeof resolveQueueScopeFlags>;\n let numbering: ReturnType<typeof resolveUserStoryNumberingFlags>;\n try {\n phases = resolveRunPhaseFlags(options);\n scope = resolveQueueScopeFlags(options);\n numbering = resolveUserStoryNumberingFlags(options);\n } catch (error) {\n if (error instanceof CliFlagError) {\n printError(error.message);\n process.exit(1);\n }\n throw error;\n }\n\n const { runPipeline } = await import('./commands/run.js');\n const code = await runPipeline(\n issues,\n options.mode,\n options.from,\n phases.noBranch,\n phases.prReview,\n {\n closeIssue: options.closeIssue,\n yes: scope.yes,\n only: scope.only,\n cascade: scope.cascade,\n continueNumbering: numbering.continueFlag,\n startUs: numbering.startUs,\n retryLimit: options.retryLimit,\n retryForever: options.retryForever,\n onIssueFailure: options.onIssueFailure,\n background: options.background,\n detachedChild: options.detachedChild,\n restartWeb: options.restartWeb,\n },\n );\n process.exit(code);\n },\n);\n\n// ── resume ──────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('resume')\n .description('Resume an interrupted pipeline from the phase it stopped at')\n .argument('[issue]', 'Issue to resume. Omitted: the most recently attempted one')\n .option('--all', 'Resume every unfinished issue of this project, in order')\n .option('--close-issue', 'Close issues after successful delivery; remember this choice')\n .option('--no-close-issue', 'Revoke automatic issue closure')\n .option('--mode <mode>', 'Execution mode: auto | manual', 'auto'),\n ),\n).action(\n async (\n issue: string | undefined,\n options: { all?: boolean; mode?: string; closeIssue?: boolean },\n ) => {\n const { runResume } = await import('./commands/resume.js');\n const code = await runResume(issue, {\n ...(options.closeIssue === undefined ? {} : { closeIssue: options.closeIssue }),\n ...(options.all === undefined ? {} : { all: options.all }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n });\n process.exit(code);\n },\n);\n\n// Explicit-file inspection works outside a repository and without an agent.\nconst artifactsCommand = program\n .command('artifacts')\n .description('Inspect local artifacts without changing files or CLI state');\n// Argument failures are part of this machine-readable command's contract too.\nif (process.argv.includes('--json')) {\n artifactsCommand.configureOutput({ writeErr: () => {} }).exitOverride((error) => {\n if (error.exitCode === 0) process.exit(0);\n console.log(\n JSON.stringify({\n schemaVersion: 1,\n ok: false,\n data: null,\n errors: [{ code: 'arguments', path: '', message: error.message }],\n }),\n );\n process.exit(1);\n });\n}\nfor (const operation of ['plan', 'issue']) {\n const command = artifactsCommand.command(operation).argument('[file]', 'Artifact path');\n if (operation === 'issue') command.argument('[metadata]', 'Optional metadata.json');\n else command.option('--context', 'Select current execution facts without history');\n command.option('--json', 'Emit a versioned JSON inspection').allowExcessArguments(false);\n command.action(async (...args: unknown[]) => {\n const file = args[0] as string | undefined;\n const metadata = operation === 'issue' ? (args[1] as string | undefined) : undefined;\n const options = args[operation === 'issue' ? 2 : 1] as { json?: boolean; context?: boolean };\n const { runArtifacts } = await import('./commands/artifacts.js');\n process.exit(\n await runArtifacts(options.context ? 'context' : operation, file, metadata, options.json),\n );\n });\n}\n\n// ── status / runs / logs / pause / cancel ───────────────────────────────────\n// The operation surface of a long run. Every one of them reads state that\n// already exists; only pause and cancel write anything, and what they write is\n// a signal to the process that owns the run.\nwithGlobalOptions(\n program\n .command('status')\n .description('What is running right now, in which phase, and since when')\n .argument('[issue]', 'Restrict the report to one issue')\n .option('--json', 'Emit the assembled state as JSON'),\n).action(async (issue: string | undefined, options: { json?: boolean }) => {\n const { runStatus } = await import('./commands/operations.js');\n process.exit(\n await runStatus(issue, { ...(options.json === undefined ? {} : { json: options.json }) }),\n );\n});\n\nwithGlobalOptions(\n program\n .command('usage')\n .description('Aggregate execution telemetry from SQLite')\n .argument('[issue]', 'Restrict the report to one issue')\n .option('--issue <issue>', 'Same as the positional argument')\n .option('--since <date>', 'Only executions started on or after this ISO date')\n .option('--by <key>', 'Group by harness, provider, model, purpose, trigger or status')\n .option('--json', 'Emit the assembled totals as JSON'),\n).action(\n async (\n issue: string | undefined,\n options: { issue?: string; since?: string; by?: string; json?: boolean },\n ) => {\n const { runUsage, USAGE_GROUP_KEYS } = await import('./commands/usage.js');\n const by = options.by;\n if (by !== undefined && !(USAGE_GROUP_KEYS as readonly string[]).includes(by)) {\n printError('Must be one of: harness, provider, model, purpose, trigger, status.');\n process.exit(1);\n }\n process.exit(\n await runUsage(issue ?? options.issue, {\n ...(options.since === undefined ? {} : { since: options.since }),\n ...(by === undefined ? {} : { by: by as (typeof USAGE_GROUP_KEYS)[number] }),\n ...(options.json === undefined ? {} : { json: options.json }),\n }),\n );\n },\n);\n\nwithGlobalOptions(\n program\n .command('ps')\n .description('Every issue-flow run active on this machine')\n .option('--json', 'Emit the listing as JSON')\n .option('--watch', 'Refresh the listing until interrupted'),\n).action(async (options: { json?: boolean; watch?: boolean }) => {\n const { runPs } = await import('./commands/ps.js');\n process.exit(await runPs(options));\n});\n\n// ── db ──────────────────────────────────────────────────────────────────────\nconst db = program.command('db').description('Inspect and maintain the Issue Flow SQLite database');\n\ndb.command('check')\n .description('Run SQLite integrity_check')\n .action(async () => {\n const { runDbCheck } = await import('./commands/db.js');\n process.exit(await runDbCheck());\n });\n\ndb.command('backup')\n .description('Create a consistent SQLite backup')\n .option('--destination <path>', 'Where to write the backup')\n .action(async (options: { destination?: string }) => {\n const { runDbBackup } = await import('./commands/db.js');\n process.exit(await runDbBackup(options.destination));\n });\n\ndb.command('vacuum')\n .description('Rebuild the SQLite database to reclaim unused space')\n .action(async () => {\n const { runDbVacuum } = await import('./commands/db.js');\n process.exit(await runDbVacuum());\n });\n\ndb.command('export')\n .description('Export structured SQLite state as readable JSON')\n .option('--destination <path>', 'Where to write the JSON export (stdout by default)')\n .action(async (options: { destination?: string }) => {\n const { runDbExport } = await import('./commands/db.js');\n process.exit(await runDbExport(options.destination));\n });\n\ndb.command('verify')\n .description('Compare task and queue projections with canonical SQLite state')\n .action(async () => {\n const { runDbVerify } = await import('./commands/db.js');\n process.exit(await runDbVerify());\n });\n\ndb.command('import')\n .description('Import preserved compatibility artifacts')\n .option('--with-events', 'Also import the potentially large JSONL journal')\n .action(async (options: { withEvents?: boolean }) => {\n const { runDbImport } = await import('./commands/db.js');\n process.exit(await runDbImport(options));\n });\n\nwithGlobalOptions(\n program.command('runs').description('History of the runs of this project, with how each ended'),\n).action(async () => {\n const { runRuns } = await import('./commands/operations.js');\n process.exit(await runRuns());\n});\n\nwithGlobalOptions(\n program\n .command('history')\n .description('Relational phase, invocation and verdict history for one issue')\n .argument('<issue>', 'Issue identifier')\n .option('--json', 'Emit the complete history as JSON'),\n).action(async (issue: string, options: { json?: boolean }) => {\n const { runHistory } = await import('./commands/history.js');\n process.exit(await runHistory(issue, options));\n});\n\nwithGlobalOptions(\n program\n .command('logs')\n .description('Read the execution journal (events.jsonl), filtered and readable')\n .argument('[issue]', 'Issue to read. Omitted: the most recently attempted one')\n .option('--issue <issue>', 'Same as the positional argument')\n .option('--follow', 'Keep reading as the journal grows')\n .option('--tail <n>', 'How many entries to show first (default 50)', parseInteger)\n .option('--kind <kinds>', 'Only these event types, comma separated (retry, phase:end, …)'),\n).action(\n async (\n issue: string | undefined,\n options: { issue?: string; follow?: boolean; tail?: number; kind?: string },\n ) => {\n const { runLogs } = await import('./commands/operations.js');\n const kinds =\n options.kind === undefined\n ? undefined\n : options.kind\n .split(',')\n .map((kind) => kind.trim())\n .filter((kind) => kind !== '');\n process.exit(\n await runLogs(issue ?? options.issue, {\n ...(kinds === undefined ? {} : { kind: kinds }),\n ...(options.follow === undefined ? {} : { follow: options.follow }),\n ...(options.tail === undefined ? {} : { tail: options.tail }),\n }),\n );\n },\n);\n\nwithGlobalOptions(\n program\n .command('pause')\n .description('Ask the running pipeline to stop after writing a checkpoint'),\n).action(async () => {\n const { runPause } = await import('./commands/operations.js');\n process.exit(await runPause());\n});\n\nwithGlobalOptions(\n program\n .command('cancel')\n .description('Stop the run and mark the issue so a resume does not pick it up')\n .argument('[issue]', 'Issue to cancel. Omitted: the most recently attempted one'),\n).action(async (issue: string | undefined) => {\n const { runCancel } = await import('./commands/operations.js');\n process.exit(await runCancel(issue));\n});\n\n// ── analyze ─────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('analyze')\n .description('Analyze an issue with the configured agent')\n .argument('<issue>', 'Issue number'),\n ),\n).action(async (issue: string) => {\n const { runAnalyze } = await import('./commands/analyze.js');\n const code = await runAnalyze(issue);\n process.exit(code);\n});\n\n// ── prd ─────────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('prd')\n .description('Generate a PRD from an analyzed issue with the configured agent')\n .argument('<issue>', 'Issue number'),\n ),\n).action(async (issue: string) => {\n const { runPrd } = await import('./commands/prd.js');\n const code = await runPrd(issue);\n process.exit(code);\n});\n\n// ── plan ────────────────────────────────────────────────────────────────────\nwithUserStoryNumberingOptions(\n withIssueOptions(\n withGlobalOptions(\n program\n .command('plan')\n .description('Convert a PRD to a tasks.json task plan with the configured agent')\n .argument('<issue>', 'Issue number'),\n ),\n ),\n).action(async (issue: string, options: { continue?: boolean; startUs?: number }) => {\n let numbering: ReturnType<typeof resolveUserStoryNumberingFlags>;\n try {\n numbering = resolveUserStoryNumberingFlags(options);\n } catch (error) {\n if (error instanceof CliFlagError) {\n printError(error.message);\n process.exit(1);\n }\n throw error;\n }\n\n const { runPlan } = await import('./commands/plan.js');\n const code = await runPlan(issue, undefined, numbering);\n process.exit(code);\n});\n\n// ── execute ─────────────────────────────────────────────────────────────────\nwithWebOptions(\n withGlobalOptions(\n program\n .command('execute')\n .description('Run the iterative story execution loop (issue-flow engine)')\n .option('--issue <number>', 'Issue number — reads artifacts from issues/N/')\n .option('--max-iterations <number>', 'Stop after N iterations', parseInteger)\n .option(\n '--retry-limit <number>',\n 'Retry transient Claude failures up to N consecutive times',\n parseInteger,\n )\n .option('--retry-forever', 'Retry transient Claude failures indefinitely')\n .argument(\n '[max-iterations]',\n 'Backward-compatible alias for --max-iterations N',\n parseInteger,\n ),\n ),\n).action(\n async (\n positionalMaxIter: number | undefined,\n options: {\n issue?: string;\n maxIterations?: number;\n retryLimit?: number;\n retryForever?: boolean;\n restartWeb?: boolean;\n },\n ) => {\n try {\n const { runExecute } = await import('./commands/execute.js');\n const code = await runExecute(positionalMaxIter, options);\n process.exit(code);\n } catch (error) {\n printError(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n },\n);\n\n// ── review ──────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('review')\n .description('Validate an issue resolution with the configured agent')\n .argument('<issue>', 'Issue number'),\n ),\n).action(async (issue: string) => {\n const { runReview } = await import('./commands/review.js');\n const code = await runReview(issue);\n process.exit(code);\n});\n\n// ── pr ──────────────────────────────────────────────────────────────────────\nwithIssueOptions(\n withGlobalOptions(\n program\n .command('pr')\n .description('Create a pull request with the configured agent')\n .argument('<issue>', 'Issue number'),\n ),\n).action(async (issue: string) => {\n const { runPr } = await import('./commands/pr.js');\n const code = await runPr(issue);\n process.exit(code);\n});\n\n// ── web ─────────────────────────────────────────────────────────────────────\nconst webCommand = program.command('web').description('Manage the web monitoring server');\n\nwebCommand\n .command('serve')\n .description(\n 'Run the web monitor server in the foreground (internal — spawned detached by --web)',\n )\n .option('--port <n>', 'Web server port (default: 3737)', parseInteger)\n .option('--host <h>', 'Web server host (default: 0.0.0.0)')\n .option('--refresh <s>', 'Suggested UI polling interval in seconds', parseInteger)\n .action(async (options: { port?: number; host?: string; refresh?: number }) => {\n const { runWebServe } = await import('./commands/web.js');\n const code = await runWebServe(options);\n // On success this process stays alive for as long as the server is bound\n // (server.ts binds it with unref: false) — only a failure exits here.\n if (code !== 0) {\n process.exit(code);\n }\n });\n\nwebCommand\n .command('stop')\n .description('Stop the running web monitor server')\n .action(async () => {\n const { runWebStop } = await import('./commands/web.js');\n const code = await runWebStop();\n process.exit(code);\n });\n\n// ── policy ──────────────────────────────────────────────────────────────\nwithGlobalOptions(\n program\n .command('policy')\n .description('Inspect the policies discovered in this repository and their provenance')\n .option('--scope <dir>', 'Resolve the policy for a subdirectory (monorepo)')\n .option('--json', 'Emit the resolved policy as JSON'),\n).action(async (options: { scope?: string; json?: boolean }) => {\n const { runPolicy } = await import('./commands/policy.js');\n const code = await runPolicy(options);\n process.exit(code);\n});\n\nconst routingCommand = withGlobalOptions(\n program.command('routing').description('Inspect and configure adaptive harness/model routing'),\n);\nroutingCommand\n .option('--json', 'Emit the resolved routing config as JSON')\n .action(async (_options: unknown, command: Command) => {\n const { runRoutingInspect } = await import('./commands/routing.js');\n process.exit(await runRoutingInspect(command.opts()));\n });\nroutingCommand\n .command('explain')\n .description('Explain the resolved routing target for every phase')\n .option('--json', 'Emit JSON')\n .action(async (_options: unknown, command: Command) => {\n const { runRoutingExplain } = await import('./commands/routing.js');\n process.exit(await runRoutingExplain(command.optsWithGlobals()));\n });\nroutingCommand\n .command('use')\n .description('Enable an embedded routing policy')\n .argument('<policy>', 'Policy name (recommended)')\n .option('--global', 'Write ~/.issue-flow/config.json (default)')\n .option('--project', 'Write .issue-flow.json instead')\n .option('--active', 'Apply the policy to future runs instead of leaving routing in shadow mode')\n .action(async (policy: string, _options: unknown, command: Command) => {\n const { runRoutingUse } = await import('./commands/routing.js');\n process.exit(await runRoutingUse(policy, command.optsWithGlobals()));\n });\nroutingCommand\n .command('report')\n .description('Shadow agreement between selected and actual harness')\n .option('--issue <n>', 'Issue number')\n .option('--json', 'Emit JSON')\n .action(async (_options: unknown, command: Command) => {\n const { runRoutingReport } = await import('./commands/routing.js');\n process.exit(await runRoutingReport(command.optsWithGlobals()));\n });\n\nconst conventionsCommand = withGlobalOptions(\n program\n .command('conventions')\n .description('Compute the repository Git convention (branch, commit, PR title)'),\n);\nconventionsCommand\n .command('branch')\n .description('Print the deterministic branch name for an issue')\n .option('--issue <n>', 'Issue number')\n .option('--title <text>', 'Issue title, when the issue cannot be resolved')\n .option('--json', 'Emit JSON')\n .action(async (options: { issue?: string; title?: string; json?: boolean }) => {\n const { runConventionsBranch } = await import('./commands/conventions.js');\n process.exit(await runConventionsBranch(options));\n });\nconventionsCommand\n .command('commit')\n .description('Print a Conventional Commit message')\n .requiredOption('--type <type>', 'Change type (feat, fix, docs, …)')\n .option('--scope <scope>', 'Optional scope')\n .requiredOption('--subject <text>', 'Commit subject')\n .option('--issue <n>', 'Issue number for the Refs trailer')\n .option('--story <id>', 'Story id (US-010)')\n .option('--breaking <text>', 'Breaking change description')\n .option('--json', 'Emit JSON')\n .action(\n async (options: {\n type: string;\n scope?: string;\n subject: string;\n issue?: string;\n story?: string;\n breaking?: string;\n json?: boolean;\n }) => {\n const { runConventionsCommit } = await import('./commands/conventions.js');\n process.exit(await runConventionsCommit(options));\n },\n );\nconventionsCommand\n .command('pr-title')\n .description('Print the Conventional Commit Pull Request title')\n .option('--issue <n>', 'Issue number')\n .option('--title <text>', 'Issue title, when the issue cannot be resolved')\n .option('--json', 'Emit JSON')\n .action(async (options: { issue?: string; title?: string; json?: boolean }) => {\n const { runConventionsPrTitle } = await import('./commands/conventions.js');\n process.exit(await runConventionsPrTitle(options));\n });\n\n// ── agent ───────────────────────────────────────────────────────────────\nconst agentCommand = withGlobalOptions(\n program\n .command('agent')\n .description('Inspect the resolved agent and model for each phase')\n .option('--json', 'Emit the resolved agent configuration as JSON'),\n);\nagentCommand.action(async (options: { json?: boolean }) => {\n const { runAgent } = await import('./commands/agent.js');\n const code = await runAgent(options);\n process.exit(code);\n});\n\nagentCommand\n .command('use')\n .description('Write an agent preference to config.json or .issue-flow.json')\n .argument('<provider>', 'claude, codex, cursor, antigravity or opencode')\n .option('--model <model>', 'Model identifier for this preference')\n .option('--global', 'Write to ~/.issue-flow/config.json (default)')\n .option('--project', 'Write to .issue-flow.json in the repository')\n .option('--phase <phase>', 'Write only the override for this phase')\n .action(\n async (\n provider: string,\n options: { model?: string; global?: boolean; project?: boolean; phase?: string },\n ) => {\n const { runAgentUse } = await import('./commands/agent.js');\n const code = await runAgentUse(provider, options);\n process.exit(code);\n },\n );\n\n// ── pr-review ───────────────────────────────────────────────────────────────\nwithGlobalOptions(\n program\n .command('pr-review')\n .description('Review a Pull Request as a whole with the configured agent')\n .argument('[pr]', 'Pull Request number (discovered from the session when omitted)')\n .option('--issue <n>', 'Issue the Pull Request belongs to')\n .option('--round <n>', 'Rewrite a specific review round instead of appending a new one')\n .option('--yes', 'Skip the confirmation of the discovered Pull Request')\n .option(\n '--fail-on <level>',\n 'Verdict that fails the command: request-changes | suggestions | none',\n ),\n).action(\n async (\n pr: string | undefined,\n options: { issue?: string; round?: string; yes?: boolean; failOn?: string },\n ) => {\n const { runPrReview } = await import('./commands/pr-review.js');\n const code = await runPrReview(pr, options);\n process.exit(code);\n },\n);\n\n// ── bench ───────────────────────────────────────────────────────────────────\nwithGlobalOptions(\n program\n .command('bench')\n .description('Measure the corpus: synthetic (CI) or real (paid, on demand)')\n .option('--mode <mode>', 'synthetic (default, free) or real (fixtures + harness)')\n .option(\n '--task <class>',\n 'Corpus class (repeatable): trivial, small, medium, analysis',\n collectString,\n [],\n )\n .option('--arm <name>', 'Experiment arm (repeatable). Default: baseline', collectString, [])\n .option('--repeats <n>', 'Repetitions per cell (default 5)', parseInteger)\n // Campaign-wide ceilings, distinct from the per-issue `--max-cost` /\n // `--max-duration` of `withGlobalOptions`: one campaign runs many issues,\n // and the two budgets are not the same number. The names differ because\n // the flags coexist on this command — and because the units differ too.\n .option(\n '--campaign-max-cost <usd>',\n 'Campaign cost ceiling in USD (evaluateCeilings)',\n parseUsd,\n )\n .option(\n '--campaign-max-duration <ms>',\n 'Campaign duration ceiling in milliseconds',\n parseInteger,\n )\n .option('--out <path>', 'Write the markdown report to this path')\n .option('--yes', 'Skip the paid-campaign confirmation')\n .option('--repo <path>', 'Investigation escape; does not produce a publishable row')\n .option('--json', 'Also emit the campaign JSON'),\n).action(\n async (options: {\n mode?: string;\n task?: string[];\n arm?: string[];\n repeats?: number;\n campaignMaxCost?: number;\n campaignMaxDuration?: number;\n out?: string;\n yes?: boolean;\n repo?: string;\n json?: boolean;\n }) => {\n if (options.mode !== undefined && options.mode !== 'synthetic' && options.mode !== 'real') {\n printError(\"Unknown bench mode. Use 'synthetic' or 'real'.\");\n process.exit(1);\n }\n const { runBench } = await import('./commands/bench.js');\n process.exit(\n await runBench({\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.task === undefined || options.task.length === 0 ? {} : { task: options.task }),\n ...(options.arm === undefined || options.arm.length === 0 ? {} : { arm: options.arm }),\n ...(options.repeats === undefined ? {} : { repeats: options.repeats }),\n ...(options.campaignMaxCost === undefined ? {} : { maxCost: options.campaignMaxCost }),\n ...(options.campaignMaxDuration === undefined\n ? {}\n : { maxDuration: options.campaignMaxDuration }),\n ...(options.out === undefined ? {} : { out: options.out }),\n ...(options.yes === undefined ? {} : { yes: options.yes }),\n ...(options.repo === undefined ? {} : { repo: options.repo }),\n ...(options.json === undefined ? {} : { json: options.json }),\n }),\n );\n },\n);\n\nprogram.action(async () => {\n const { listLiveRuns } = await import('./execution/registry.js');\n const runs = await listLiveRuns();\n if (runs.length === 0) {\n program.help();\n return;\n }\n const { runPs } = await import('./commands/ps.js');\n process.exit(await runPs());\n});\n\nprogram.parse();\n","/**\n * Pure mappings from parsed CLI options to command arguments.\n *\n * They live outside cli.ts because that module runs `program.parse()` on\n * import, so anything defined there is untestable.\n */\n\nimport type { WebConfig } from './schemas.js';\n\n/** Extract ephemeral/config-backed web flags from commander's camel-cased options. */\nexport function resolveWebOverrides(opts: Record<string, unknown>): Partial<WebConfig> {\n const overrides: Partial<WebConfig> = {};\n if (opts.web === true || opts.serve === true || opts.restartWeb === true) {\n overrides.enabled = true;\n }\n if (opts.port !== undefined) overrides.port = opts.port as number;\n if (opts.host !== undefined) overrides.host = opts.host as string;\n if (opts.refresh !== undefined) overrides.refreshSeconds = opts.refresh as number;\n if (opts.webLogLimit !== undefined) overrides.logLimit = opts.webLogLimit as number;\n if (opts.webNoLogs === true) overrides.includeLogs = false;\n return overrides;\n}\n\n/** Shape commander produces for a negated boolean option (`--no-branch`). */\nexport interface BranchFlagOptions {\n branch?: boolean;\n}\n\n/**\n * Translate commander's `--no-branch` into the tri-state `runPipeline` expects.\n *\n * Commander stores a negated option under its positive name: `--no-branch`\n * yields `{ branch: false }` and never a `noBranch` key. Reading `noBranch`\n * silently dropped the flag, so the pipeline always created a branch and opened\n * a PR.\n *\n * `undefined` (flag absent) is preserved on purpose: `runPipeline` uses it to\n * tell \"the user said nothing, keep the mode persisted in tasks.json\" apart\n * from an explicit choice.\n */\nexport function resolveNoBranch(options: BranchFlagOptions): boolean | undefined {\n return options.branch === false ? true : undefined;\n}\n\n/** Invalid flag combination on a command, reported as a CLI error. */\nexport class CliFlagError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'CliFlagError';\n }\n}\n\n/** Options `run` accepts that select which phases the pipeline executes. */\nexport interface RunPhaseFlagOptions extends BranchFlagOptions {\n prReview?: boolean;\n}\n\n/** Phase selection `runPipeline` expects, both entries tri-state. */\nexport interface RunPhaseFlags {\n noBranch: boolean | undefined;\n prReview: boolean | undefined;\n}\n\n/** Scope flags of `run`, deciding what a discovered hierarchy does. */\nexport interface QueueScopeFlagOptions {\n yes?: boolean;\n only?: boolean;\n cascade?: boolean;\n}\n\n/** Resolved scope answer; both absent means \"ask, when the terminal allows it\". */\nexport interface QueueScopeFlags {\n yes: boolean | undefined;\n only: boolean | undefined;\n cascade: boolean | undefined;\n}\n\n/**\n * Resolve `--yes` / `--only`, rejecting the combination that has no meaning.\n *\n * They answer the same question in opposite ways — run everything that was\n * discovered, or run only what was asked for — so passing both is a mistake\n * worth naming rather than silently resolving by precedence.\n *\n * @throws CliFlagError when both are present.\n */\nexport function resolveQueueScopeFlags(options: QueueScopeFlagOptions): QueueScopeFlags {\n if (options.yes === true && options.only === true) {\n throw new CliFlagError(\n '--yes cannot be combined with --only: --yes runs the whole discovered hierarchy, ' +\n '--only runs just the issues you informed.',\n );\n }\n if (options.cascade === true && options.only === true) {\n throw new CliFlagError(\n '--cascade cannot be combined with --only: --cascade runs the container hierarchy, ' +\n '--only runs just the issues you informed.',\n );\n }\n\n return {\n yes: options.yes === true ? true : undefined,\n only: options.only === true ? true : undefined,\n cascade: options.cascade === true ? true : undefined,\n };\n}\n\n/**\n * Resolve the phase-selection flags of `run`, rejecting the one combination\n * that cannot work.\n *\n * `--no-branch` skips the `pr` phase, so there is no Pull Request for\n * `--pr-review` to review. Failing here — before any phase runs — beats\n * discovering it at the end of a full pipeline.\n *\n * Both values stay `undefined` when the user passed nothing: `runPipeline`\n * uses that to tell \"no opinion, keep what tasks.json persisted\" apart from an\n * explicit choice.\n *\n * @throws CliFlagError when `--pr-review` is combined with `--no-branch`.\n */\nexport function resolveRunPhaseFlags(options: RunPhaseFlagOptions): RunPhaseFlags {\n const noBranch = resolveNoBranch(options);\n const prReview = options.prReview === true ? true : undefined;\n\n if (prReview === true && noBranch === true) {\n throw new CliFlagError(\n '--pr-review cannot be combined with --no-branch: --no-branch skips the pr phase, ' +\n 'so there is no Pull Request to review.',\n );\n }\n\n return { noBranch, prReview };\n}\n\n/** Options `run` and `plan` accept to override User Story numbering (issue #36). */\nexport interface UserStoryNumberingFlagOptions {\n continue?: boolean;\n startUs?: number;\n}\n\n/** Resolved User Story numbering override, ready for `determineUserStoryNumbering()`. */\nexport interface UserStoryNumberingFlags {\n continueFlag: boolean;\n startUs: number | undefined;\n}\n\n/**\n * Resolve the `--continue` / `--start-us <n>` override of the User Story\n * numbering cascade (issue #36), rejecting the one combination that cannot\n * work: the two disagree about whether history should be consulted at all.\n *\n * @throws CliFlagError when both flags are passed together.\n */\nexport function resolveUserStoryNumberingFlags(\n options: UserStoryNumberingFlagOptions,\n): UserStoryNumberingFlags {\n const continueFlag = options.continue === true;\n const startUs = options.startUs;\n\n if (continueFlag && startUs !== undefined) {\n throw new CliFlagError(\n '--continue and --start-us cannot be combined: choose either the last known numbering ' +\n '(--continue) or an explicit override (--start-us).',\n );\n }\n\n return { continueFlag, startUs };\n}\n","import type { IssueGenerateTarget, IssuesConfig } from './types.js';\n\n/**\n * Mapping from the Issue provider CLI flags to configuration overrides.\n *\n * Kept out of cli.ts (which runs `program.parse()` on import) so the\n * precedence rules stay unit-testable. Only the keys the user actually passed\n * are returned: a key present with `undefined` would override .issue-flow.json\n * when the layers are merged.\n */\n\nexport interface IssueCliFlags {\n local?: boolean;\n github?: boolean;\n preferLocal?: boolean;\n preferGithub?: boolean;\n ask?: boolean;\n}\n\n/** Invalid flag combination, reported to the user as a CLI error. */\nexport class IssueFlagError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'IssueFlagError';\n }\n}\n\n/**\n * Translate the parsed options of a command into `IssuesConfig` overrides.\n *\n * @throws IssueFlagError when mutually exclusive flags are combined.\n */\nexport function resolveIssuesOverrides(opts: IssueCliFlags): Partial<IssuesConfig> {\n const overrides: Partial<IssuesConfig> = {};\n\n if (opts.local === true && opts.github === true) {\n throw new IssueFlagError('--local and --github are mutually exclusive; pass only one.');\n }\n if (opts.local === true) {\n overrides.preferredProvider = 'local';\n }\n if (opts.github === true) {\n overrides.preferredProvider = 'github';\n }\n\n const conflictFlags = [\n opts.preferLocal === true ? '--prefer-local' : null,\n opts.preferGithub === true ? '--prefer-github' : null,\n opts.ask === true ? '--ask' : null,\n ].filter((flag): flag is string => flag !== null);\n\n if (conflictFlags.length > 1) {\n throw new IssueFlagError(\n `${conflictFlags.join(', ')} are mutually exclusive; pass only one conflict policy.`,\n );\n }\n if (opts.preferLocal === true) {\n overrides.conflictPolicy = 'prefer-local';\n }\n if (opts.preferGithub === true) {\n overrides.conflictPolicy = 'prefer-github';\n }\n if (opts.ask === true) {\n overrides.conflictPolicy = 'ask';\n }\n\n return overrides;\n}\n\n/** Destination flags accepted by `generate`. */\nexport interface GenerateTargetFlags {\n github?: boolean;\n local?: boolean;\n both?: boolean;\n}\n\n/**\n * Destination the generated Issue is created in, or `undefined` when the user\n * passed no flag (the caller then falls back to `defaultGenerateTarget`).\n *\n * @throws IssueFlagError when more than one destination is requested.\n */\nexport function resolveGenerateTarget(opts: GenerateTargetFlags): IssueGenerateTarget | undefined {\n const selected: IssueGenerateTarget[] = [];\n if (opts.github === true) selected.push('github');\n if (opts.local === true) selected.push('local');\n if (opts.both === true) selected.push('both');\n\n if (selected.length > 1) {\n throw new IssueFlagError(\n `${selected.map((target) => `--${target}`).join(', ')} are mutually exclusive; ` +\n 'pass only one destination.',\n );\n }\n\n return selected[0];\n}\n","import { DEFAULT_INACTIVITY_TIMEOUT_MS } from '../core/watchdog.js';\nimport type { ResilienceConfig } from '../storage/schemas.js';\n\n/**\n * The resilience flags, turned into the CLI rung of the configuration ladder.\n *\n * Kept out of `cli.ts` (which runs `program.parse()` on import) so the mapping\n * is testable on its own, the same reason `cli-options.ts` and\n * `issues/cli-flags.ts` live outside it.\n *\n * **`--continuous` is a profile, not a mechanism.** Long autonomous work needs\n * about six behaviours turned on at once, and asking for six flags is asking\n * for five of them to be forgotten. So the profile names the *intent* — \"keep\n * going without me\" — and expands to the settings that intent implies, every\n * one of which stays adjustable on its own.\n */\n\nexport interface ResilienceFlags {\n /** `--continuous` / `--resilient`: the long-running profile. */\n continuous?: boolean;\n resilient?: boolean;\n /** `--no-failover`: never migrate a phase to another provider. */\n failover?: boolean;\n /** `--auto-decompose`: act on a decomposition report instead of reporting. */\n autoDecompose?: boolean;\n /** `--inactivity-timeout <seconds>`: the watchdog budget. */\n inactivityTimeout?: number;\n /** `--on-issue-failure <mode>`: what a failing issue does to the queue. */\n onIssueFailure?: 'stop' | 'skip' | 'block';\n}\n\n/**\n * What `--continuous` turns on.\n *\n * The retry side is the `continuous` **profile** of `resolvePolicy()` — network\n * and rate limits retried forever, wider budgets for the rest — rather than a\n * list of numbers repeated here, so the two cannot drift. The rest is what the\n * profile implies at the pipeline level: keep the queue moving, keep a journal\n * of what happened, and notice an agent that has gone quiet.\n */\nfunction continuousProfile(): ResilienceConfig {\n return {\n profile: 'continuous',\n providers: { failover: true },\n queue: { onIssueFailure: 'skip' },\n journal: { enabled: true },\n watchdog: { inactivityTimeoutMs: DEFAULT_INACTIVITY_TIMEOUT_MS },\n };\n}\n\n/**\n * Resolve the flags into one `resilience` object.\n *\n * The profile is applied first and the granular flags on top of it, which is\n * the whole precedence rule: **an explicit flag always beats the profile**.\n * `--continuous --no-failover` is a coherent thing to ask for and means exactly\n * what it says.\n */\nexport function resolveResilienceOverrides(flags: ResilienceFlags): ResilienceConfig {\n const continuous = flags.continuous === true || flags.resilient === true;\n const overrides: ResilienceConfig = continuous ? continuousProfile() : {};\n\n // Commander maps `--no-failover` to `failover: false`, and leaves the field\n // absent when the flag was not passed — so `false` here is always explicit.\n if (flags.failover === false) {\n overrides.providers = { ...overrides.providers, failover: false };\n }\n if (flags.autoDecompose === true) {\n overrides.decompose = { ...overrides.decompose, auto: true };\n }\n if (flags.inactivityTimeout !== undefined) {\n overrides.watchdog = {\n ...overrides.watchdog,\n inactivityTimeoutMs: flags.inactivityTimeout * 1000,\n };\n }\n if (flags.onIssueFailure !== undefined) {\n overrides.queue = { ...overrides.queue, onIssueFailure: flags.onIssueFailure };\n }\n\n return overrides;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,sBAAsB,cAAc;;;ACU/C,SAAS,oBAAoB,MAAmD;AACrF,QAAM,YAAgC,CAAC;AACvC,MAAI,KAAK,QAAQ,QAAQ,KAAK,UAAU,QAAQ,KAAK,eAAe,MAAM;AACxE,cAAU,UAAU;AAAA,EACtB;AACA,MAAI,KAAK,SAAS,OAAW,WAAU,OAAO,KAAK;AACnD,MAAI,KAAK,SAAS,OAAW,WAAU,OAAO,KAAK;AACnD,MAAI,KAAK,YAAY,OAAW,WAAU,iBAAiB,KAAK;AAChE,MAAI,KAAK,gBAAgB,OAAW,WAAU,WAAW,KAAK;AAC9D,MAAI,KAAK,cAAc,KAAM,WAAU,cAAc;AACrD,SAAO;AACT;AAmBO,SAAS,gBAAgB,SAAiD;AAC/E,SAAO,QAAQ,WAAW,QAAQ,OAAO;AAC3C;AAGO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAoCO,SAAS,uBAAuB,SAAiD;AACtF,MAAI,QAAQ,QAAQ,QAAQ,QAAQ,SAAS,MAAM;AACjD,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AAQ,MAAM;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
LEGACY_ISSUES_DIR_NAME,
|
|
4
|
+
METADATA_FILENAME,
|
|
5
|
+
migrateLegacyStorage,
|
|
6
|
+
recordUserStoryNumbering,
|
|
7
|
+
resolveStorageMode
|
|
8
|
+
} from "./chunk-RDPK7LYK.js";
|
|
9
|
+
import "./chunk-JCR5C5A7.js";
|
|
10
|
+
import "./chunk-NP47HRX2.js";
|
|
11
|
+
import "./chunk-44RF3VFG.js";
|
|
12
|
+
import "./chunk-7MJGYPHF.js";
|
|
13
|
+
import "./chunk-XNK5UN2D.js";
|
|
14
|
+
import "./chunk-MAJ6QDRL.js";
|
|
15
|
+
import "./chunk-KUA6KBBD.js";
|
|
16
|
+
import "./chunk-PFWHHYEO.js";
|
|
17
|
+
export {
|
|
18
|
+
LEGACY_ISSUES_DIR_NAME,
|
|
19
|
+
METADATA_FILENAME,
|
|
20
|
+
migrateLegacyStorage,
|
|
21
|
+
recordUserStoryNumbering,
|
|
22
|
+
resolveStorageMode
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=compat-OJG76J4I.js.map
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
DEFAULTS,
|
|
4
|
-
GLOBAL_CONFIG_FILENAME,
|
|
5
|
-
PROJECT_CONFIG_FILENAME,
|
|
6
4
|
WEB_CONFIG_FILENAME,
|
|
7
5
|
createConfig,
|
|
8
6
|
getActiveResilienceConfig,
|
|
@@ -10,7 +8,6 @@ import {
|
|
|
10
8
|
getInstallHint,
|
|
11
9
|
initResilienceConfig,
|
|
12
10
|
loadAgentConfig,
|
|
13
|
-
loadGlobalConfig,
|
|
14
11
|
loadIssuesConfig,
|
|
15
12
|
loadPolicyConfig,
|
|
16
13
|
loadPrReviewConfig,
|
|
@@ -30,20 +27,26 @@ import {
|
|
|
30
27
|
setVerifyCliOverrides,
|
|
31
28
|
setWebCliOverrides,
|
|
32
29
|
validateDependencies
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
import "./chunk-
|
|
40
|
-
import "./chunk-
|
|
41
|
-
import "./chunk-
|
|
42
|
-
import "./chunk-
|
|
43
|
-
import "./chunk-ICM463EO.js";
|
|
44
|
-
import "./chunk-XEYH6ZZI.js";
|
|
30
|
+
} from "./chunk-YC24E66P.js";
|
|
31
|
+
import {
|
|
32
|
+
GLOBAL_CONFIG_FILENAME,
|
|
33
|
+
PROJECT_CONFIG_FILENAME,
|
|
34
|
+
loadGlobalConfig
|
|
35
|
+
} from "./chunk-DBLXLKGU.js";
|
|
36
|
+
import "./chunk-I64N6RL6.js";
|
|
37
|
+
import "./chunk-DIMDAYZS.js";
|
|
38
|
+
import "./chunk-WB4FA2EH.js";
|
|
39
|
+
import "./chunk-VHQMMY2D.js";
|
|
45
40
|
import "./chunk-P3LRUNC6.js";
|
|
46
|
-
import "./chunk-
|
|
41
|
+
import "./chunk-RDPK7LYK.js";
|
|
42
|
+
import "./chunk-JCR5C5A7.js";
|
|
43
|
+
import "./chunk-NP47HRX2.js";
|
|
44
|
+
import "./chunk-44RF3VFG.js";
|
|
45
|
+
import "./chunk-7MJGYPHF.js";
|
|
46
|
+
import "./chunk-XNK5UN2D.js";
|
|
47
|
+
import "./chunk-MAJ6QDRL.js";
|
|
48
|
+
import "./chunk-KUA6KBBD.js";
|
|
49
|
+
import "./chunk-PFWHHYEO.js";
|
|
47
50
|
export {
|
|
48
51
|
DEFAULTS,
|
|
49
52
|
GLOBAL_CONFIG_FILENAME,
|
|
@@ -76,4 +79,4 @@ export {
|
|
|
76
79
|
setWebCliOverrides,
|
|
77
80
|
validateDependencies
|
|
78
81
|
};
|
|
79
|
-
//# sourceMappingURL=config-
|
|
82
|
+
//# sourceMappingURL=config-6YTWPDBK.js.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
resolveIssue
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DZ3DZ3EN.js";
|
|
5
|
+
import "./chunk-T736DSZI.js";
|
|
6
|
+
import "./chunk-7ZZUSMBJ.js";
|
|
5
7
|
import "./chunk-KMMASOA6.js";
|
|
6
8
|
import "./chunk-3D4A4B46.js";
|
|
7
9
|
import {
|
|
@@ -12,23 +14,25 @@ import {
|
|
|
12
14
|
loadRepositoryPolicy,
|
|
13
15
|
pullRequestTitle,
|
|
14
16
|
resolveChangeType
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-LI35PIIS.js";
|
|
17
|
+
} from "./chunk-WQSGL5LX.js";
|
|
18
|
+
import "./chunk-YC24E66P.js";
|
|
18
19
|
import {
|
|
19
20
|
printError
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-6K2LCFG6.js";
|
|
26
|
-
import "./chunk-PPZ3K4YM.js";
|
|
27
|
-
import "./chunk-SOM4QA6C.js";
|
|
28
|
-
import "./chunk-ICM463EO.js";
|
|
29
|
-
import "./chunk-XEYH6ZZI.js";
|
|
21
|
+
} from "./chunk-DBLXLKGU.js";
|
|
22
|
+
import "./chunk-I64N6RL6.js";
|
|
23
|
+
import "./chunk-DIMDAYZS.js";
|
|
24
|
+
import "./chunk-WB4FA2EH.js";
|
|
25
|
+
import "./chunk-VHQMMY2D.js";
|
|
30
26
|
import "./chunk-P3LRUNC6.js";
|
|
31
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-RDPK7LYK.js";
|
|
28
|
+
import "./chunk-JCR5C5A7.js";
|
|
29
|
+
import "./chunk-NP47HRX2.js";
|
|
30
|
+
import "./chunk-44RF3VFG.js";
|
|
31
|
+
import "./chunk-7MJGYPHF.js";
|
|
32
|
+
import "./chunk-XNK5UN2D.js";
|
|
33
|
+
import "./chunk-MAJ6QDRL.js";
|
|
34
|
+
import "./chunk-KUA6KBBD.js";
|
|
35
|
+
import "./chunk-PFWHHYEO.js";
|
|
32
36
|
|
|
33
37
|
// src/commands/conventions.ts
|
|
34
38
|
async function resolveIssueInput(issue, titleFlag) {
|
|
@@ -143,4 +147,4 @@ export {
|
|
|
143
147
|
runConventionsCommit,
|
|
144
148
|
runConventionsPrTitle
|
|
145
149
|
};
|
|
146
|
-
//# sourceMappingURL=conventions-
|
|
150
|
+
//# sourceMappingURL=conventions-5UPOTU42.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/conventions.ts"],"sourcesContent":["import {\n branchName,\n commitMessage,\n DEFAULT_BRANCH_CONVENTION,\n isChangeType,\n pullRequestTitle,\n resolveChangeType,\n} from '../conventions/git/index.js';\nimport { resolveIssue } from '../issues/resolver.js';\nimport { loadRepositoryPolicy } from '../policy/index.js';\nimport { printError } from '../ui/logger.js';\n\nexport interface ConventionsBranchOptions {\n issue?: string;\n title?: string;\n json?: boolean;\n}\n\nexport interface ConventionsCommitOptions {\n type: string;\n scope?: string;\n subject: string;\n issue?: string;\n story?: string;\n breaking?: string;\n json?: boolean;\n}\n\nexport interface ConventionsPrTitleOptions {\n issue?: string;\n title?: string;\n json?: boolean;\n}\n\nasync function resolveIssueInput(\n issue: string | undefined,\n titleFlag: string | undefined,\n): Promise<{\n number: number | null;\n title: string;\n labels: string[];\n titleConvention: string | null;\n typeMap: Record<string, string> | null;\n convention: string;\n} | null> {\n const policy = await loadRepositoryPolicy();\n if (issue === undefined || issue === '') {\n if (titleFlag === undefined || titleFlag === '') return null;\n return {\n number: null,\n title: titleFlag,\n labels: [],\n titleConvention: policy.issues.titleConvention,\n typeMap: policy.git.typeMap,\n convention: policy.git.branchConvention ?? DEFAULT_BRANCH_CONVENTION,\n };\n }\n\n const id = issue.replace(/^#/, '');\n try {\n const resolved = await resolveIssue(id);\n return {\n number: resolved.issue.number ?? (/^\\d+$/.test(id) ? Number(id) : null),\n title: titleFlag === undefined || titleFlag === '' ? resolved.issue.title : titleFlag,\n labels: resolved.issue.labels,\n titleConvention: policy.issues.titleConvention,\n typeMap: policy.git.typeMap,\n convention: policy.git.branchConvention ?? DEFAULT_BRANCH_CONVENTION,\n };\n } catch {\n if (titleFlag === undefined || titleFlag === '') return null;\n return {\n number: /^\\d+$/.test(id) ? Number(id) : null,\n title: titleFlag,\n labels: [],\n titleConvention: policy.issues.titleConvention,\n typeMap: policy.git.typeMap,\n convention: policy.git.branchConvention ?? DEFAULT_BRANCH_CONVENTION,\n };\n }\n}\n\nexport async function runConventionsBranch(options: ConventionsBranchOptions): Promise<number> {\n const input = await resolveIssueInput(options.issue, options.title);\n if (input === null) {\n printError('Provide --issue <n> and/or --title <text>.');\n return 1;\n }\n const change = resolveChangeType({\n labels: input.labels,\n title: input.title,\n titleConvention: input.titleConvention,\n typeMap: input.typeMap,\n });\n const name = branchName({\n type: change.type,\n issueNumber: input.number,\n title: input.title,\n convention: input.convention,\n });\n if (options.json === true) {\n console.log(\n JSON.stringify({ branch: name, type: change.type, source: change.source }, null, 2),\n );\n return 0;\n }\n console.log(name);\n return 0;\n}\n\nexport async function runConventionsCommit(options: ConventionsCommitOptions): Promise<number> {\n if (!isChangeType(options.type)) {\n printError(`Unknown type \"${options.type}\".`);\n return 1;\n }\n const issueNumber =\n options.issue !== undefined && /^\\d+$/.test(options.issue.replace(/^#/, ''))\n ? Number(options.issue.replace(/^#/, ''))\n : undefined;\n const message = commitMessage({\n type: options.type,\n scope: options.scope,\n subject: options.subject,\n issueNumber,\n storyId: options.story,\n breaking: options.breaking,\n });\n if (options.json === true) {\n console.log(JSON.stringify({ message }, null, 2));\n return 0;\n }\n console.log(message);\n return 0;\n}\n\nexport async function runConventionsPrTitle(options: ConventionsPrTitleOptions): Promise<number> {\n const input = await resolveIssueInput(options.issue, options.title);\n if (input === null) {\n printError('Provide --issue <n> and/or --title <text>.');\n return 1;\n }\n const change = resolveChangeType({\n labels: input.labels,\n title: input.title,\n titleConvention: input.titleConvention,\n typeMap: input.typeMap,\n });\n const title = pullRequestTitle({\n type: change.type,\n subject: input.title.replace(/^\\s*\\[[^\\]]+\\]\\s*/, ''),\n });\n if (options.json === true) {\n console.log(JSON.stringify({ title, type: change.type, source: change.source }, null, 2));\n return 0;\n }\n console.log(title);\n return 0;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/commands/conventions.ts"],"sourcesContent":["import {\n branchName,\n commitMessage,\n DEFAULT_BRANCH_CONVENTION,\n isChangeType,\n pullRequestTitle,\n resolveChangeType,\n} from '../conventions/git/index.js';\nimport { resolveIssue } from '../issues/resolver.js';\nimport { loadRepositoryPolicy } from '../policy/index.js';\nimport { printError } from '../ui/logger.js';\n\nexport interface ConventionsBranchOptions {\n issue?: string;\n title?: string;\n json?: boolean;\n}\n\nexport interface ConventionsCommitOptions {\n type: string;\n scope?: string;\n subject: string;\n issue?: string;\n story?: string;\n breaking?: string;\n json?: boolean;\n}\n\nexport interface ConventionsPrTitleOptions {\n issue?: string;\n title?: string;\n json?: boolean;\n}\n\nasync function resolveIssueInput(\n issue: string | undefined,\n titleFlag: string | undefined,\n): Promise<{\n number: number | null;\n title: string;\n labels: string[];\n titleConvention: string | null;\n typeMap: Record<string, string> | null;\n convention: string;\n} | null> {\n const policy = await loadRepositoryPolicy();\n if (issue === undefined || issue === '') {\n if (titleFlag === undefined || titleFlag === '') return null;\n return {\n number: null,\n title: titleFlag,\n labels: [],\n titleConvention: policy.issues.titleConvention,\n typeMap: policy.git.typeMap,\n convention: policy.git.branchConvention ?? DEFAULT_BRANCH_CONVENTION,\n };\n }\n\n const id = issue.replace(/^#/, '');\n try {\n const resolved = await resolveIssue(id);\n return {\n number: resolved.issue.number ?? (/^\\d+$/.test(id) ? Number(id) : null),\n title: titleFlag === undefined || titleFlag === '' ? resolved.issue.title : titleFlag,\n labels: resolved.issue.labels,\n titleConvention: policy.issues.titleConvention,\n typeMap: policy.git.typeMap,\n convention: policy.git.branchConvention ?? DEFAULT_BRANCH_CONVENTION,\n };\n } catch {\n if (titleFlag === undefined || titleFlag === '') return null;\n return {\n number: /^\\d+$/.test(id) ? Number(id) : null,\n title: titleFlag,\n labels: [],\n titleConvention: policy.issues.titleConvention,\n typeMap: policy.git.typeMap,\n convention: policy.git.branchConvention ?? DEFAULT_BRANCH_CONVENTION,\n };\n }\n}\n\nexport async function runConventionsBranch(options: ConventionsBranchOptions): Promise<number> {\n const input = await resolveIssueInput(options.issue, options.title);\n if (input === null) {\n printError('Provide --issue <n> and/or --title <text>.');\n return 1;\n }\n const change = resolveChangeType({\n labels: input.labels,\n title: input.title,\n titleConvention: input.titleConvention,\n typeMap: input.typeMap,\n });\n const name = branchName({\n type: change.type,\n issueNumber: input.number,\n title: input.title,\n convention: input.convention,\n });\n if (options.json === true) {\n console.log(\n JSON.stringify({ branch: name, type: change.type, source: change.source }, null, 2),\n );\n return 0;\n }\n console.log(name);\n return 0;\n}\n\nexport async function runConventionsCommit(options: ConventionsCommitOptions): Promise<number> {\n if (!isChangeType(options.type)) {\n printError(`Unknown type \"${options.type}\".`);\n return 1;\n }\n const issueNumber =\n options.issue !== undefined && /^\\d+$/.test(options.issue.replace(/^#/, ''))\n ? Number(options.issue.replace(/^#/, ''))\n : undefined;\n const message = commitMessage({\n type: options.type,\n scope: options.scope,\n subject: options.subject,\n issueNumber,\n storyId: options.story,\n breaking: options.breaking,\n });\n if (options.json === true) {\n console.log(JSON.stringify({ message }, null, 2));\n return 0;\n }\n console.log(message);\n return 0;\n}\n\nexport async function runConventionsPrTitle(options: ConventionsPrTitleOptions): Promise<number> {\n const input = await resolveIssueInput(options.issue, options.title);\n if (input === null) {\n printError('Provide --issue <n> and/or --title <text>.');\n return 1;\n }\n const change = resolveChangeType({\n labels: input.labels,\n title: input.title,\n titleConvention: input.titleConvention,\n typeMap: input.typeMap,\n });\n const title = pullRequestTitle({\n type: change.type,\n subject: input.title.replace(/^\\s*\\[[^\\]]+\\]\\s*/, ''),\n });\n if (options.json === true) {\n console.log(JSON.stringify({ title, type: change.type, source: change.source }, null, 2));\n return 0;\n }\n console.log(title);\n return 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,eAAe,kBACb,OACA,WAQQ;AACR,QAAM,SAAS,MAAM,qBAAqB;AAC1C,MAAI,UAAU,UAAa,UAAU,IAAI;AACvC,QAAI,cAAc,UAAa,cAAc,GAAI,QAAO;AACxD,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,QAAQ,CAAC;AAAA,MACT,iBAAiB,OAAO,OAAO;AAAA,MAC/B,SAAS,OAAO,IAAI;AAAA,MACpB,YAAY,OAAO,IAAI,oBAAoB;AAAA,IAC7C;AAAA,EACF;AAEA,QAAM,KAAK,MAAM,QAAQ,MAAM,EAAE;AACjC,MAAI;AACF,UAAM,WAAW,MAAM,aAAa,EAAE;AACtC,WAAO;AAAA,MACL,QAAQ,SAAS,MAAM,WAAW,QAAQ,KAAK,EAAE,IAAI,OAAO,EAAE,IAAI;AAAA,MAClE,OAAO,cAAc,UAAa,cAAc,KAAK,SAAS,MAAM,QAAQ;AAAA,MAC5E,QAAQ,SAAS,MAAM;AAAA,MACvB,iBAAiB,OAAO,OAAO;AAAA,MAC/B,SAAS,OAAO,IAAI;AAAA,MACpB,YAAY,OAAO,IAAI,oBAAoB;AAAA,IAC7C;AAAA,EACF,QAAQ;AACN,QAAI,cAAc,UAAa,cAAc,GAAI,QAAO;AACxD,WAAO;AAAA,MACL,QAAQ,QAAQ,KAAK,EAAE,IAAI,OAAO,EAAE,IAAI;AAAA,MACxC,OAAO;AAAA,MACP,QAAQ,CAAC;AAAA,MACT,iBAAiB,OAAO,OAAO;AAAA,MAC/B,SAAS,OAAO,IAAI;AAAA,MACpB,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