diffpact 0.4.2 → 0.4.3
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/CHANGELOG.md +16 -0
- package/README.md +19 -10
- package/bin/diffpact.mjs +5 -0
- package/dist/adapters/claude-code.d.ts +21 -0
- package/dist/adapters/codex.d.ts +31 -0
- package/dist/adapters/gemini-agy.d.ts +26 -0
- package/dist/adapters/vercel-board.d.ts +30 -0
- package/dist/amend.d.ts +46 -0
- package/dist/amend.js +9 -3
- package/dist/boundaries.d.ts +43 -0
- package/dist/canonical-json.d.ts +6 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +395 -124
- package/dist/delegate.d.ts +22 -0
- package/dist/doctor.d.ts +36 -0
- package/dist/git.d.ts +27 -0
- package/dist/git.js +15 -0
- package/dist/index.d.ts +19 -0
- package/dist/merge-verify.d.ts +31 -0
- package/dist/report.d.ts +25 -0
- package/dist/report.js +1 -1
- package/dist/review.d.ts +46 -0
- package/dist/runner.d.ts +45 -0
- package/dist/schema.d.ts +6 -0
- package/dist/types.d.ts +190 -0
- package/dist/verify.d.ts +45 -0
- package/dist/worktree.d.ts +82 -0
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
commitExists,
|
|
17
17
|
ensureGitInfoExclude,
|
|
18
18
|
isAncestor,
|
|
19
|
+
resolveCommitSha,
|
|
19
20
|
resolveCurrentBranch,
|
|
20
21
|
resolveHeadSha,
|
|
21
22
|
resolveRepoRoot,
|
|
@@ -82,12 +83,18 @@ function readStdinUtf8() {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
function printHelp() {
|
|
85
|
-
const text = `diffpact v0.4.
|
|
86
|
+
const text = `diffpact v0.4.3 — Stateless Git task contracts & cross-harness review gates
|
|
86
87
|
|
|
87
88
|
Usage:
|
|
88
|
-
diffpact [--contract <path>] [--json] <command> [options]
|
|
89
|
+
diffpact [--cwd <dir>] [--contract <path>] [--json] <command> [options]
|
|
89
90
|
diffpact <command> --help | diffpact help <command>
|
|
90
91
|
|
|
92
|
+
Global Options:
|
|
93
|
+
--cwd <dir>, -C <dir> Run command against target repo/worktree directory (default: current directory)
|
|
94
|
+
--contract <path> Path to contract.json relative to cwd (default: .diffpact/contract.json)
|
|
95
|
+
--json Emit machine-readable JSON output
|
|
96
|
+
-h, --help Show global or per-command help
|
|
97
|
+
|
|
91
98
|
Commands:
|
|
92
99
|
init Create .diffpact/contract.json pinned to starting_sha
|
|
93
100
|
amend Record hash-chained scope or starting_sha amendment with reason
|
|
@@ -126,7 +133,7 @@ Options:
|
|
|
126
133
|
--task-id <id> Task identifier (default: task-001)
|
|
127
134
|
--type <coding|research> Task type; research enforces empty allowed_paths (default: coding)
|
|
128
135
|
--mission <text> Human-readable task description
|
|
129
|
-
--starting-sha <sha>
|
|
136
|
+
--starting-sha <sha|ref> Pin starting commit (full SHA, short SHA, or Git ref; stored as 40-char SHA; default: HEAD)
|
|
130
137
|
--branch <name> Pin expected Git branch (default: current branch)
|
|
131
138
|
--implementer <a:s:h> Implementer identity "<agent_id>:<session_id>:<harness>"
|
|
132
139
|
Harnesses: claude-code | codex | crush | gemini-cli | agy | vercel-board | manual | other
|
|
@@ -217,7 +224,7 @@ Options:
|
|
|
217
224
|
Print the primary raw Git diff (starting_sha..HEAD) plus untracked files and the canonical
|
|
218
225
|
raw_diff_sha256 token for use with "diffpact review --diff-sha <sha>".
|
|
219
226
|
`,
|
|
220
|
-
review: `Usage: diffpact [--contract <path>] [--json] review --reviewer <a:s:h> (--diff-sha <sha> | --inspected-raw-diff) [options]
|
|
227
|
+
review: `Usage: diffpact [--cwd <dir>] [--contract <path>] [--json] review --reviewer <a:s:h> --verdict <approve|reject> (--diff-sha <sha> | --inspected-raw-diff) [options]
|
|
221
228
|
|
|
222
229
|
Record a non-self-certified review attestation bound to contract_sha256, receipt_sha256, candidate_sha, and raw_diff_sha256.
|
|
223
230
|
Set DIFFPACT_REVIEWER_SECRET in the orchestrator environment (automatically stripped from diffpact exec/run workers)
|
|
@@ -225,7 +232,7 @@ to HMAC-SHA256 sign and verify reviews so workers cannot forge reviewer attestat
|
|
|
225
232
|
|
|
226
233
|
Options:
|
|
227
234
|
--reviewer <a:s:h> Reviewer identity "<agent_id>:<session_id>:<harness>" (must differ from implementer)
|
|
228
|
-
--verdict <approve|reject> Review verdict (default
|
|
235
|
+
--verdict <approve|reject> Review verdict (required; no default)
|
|
229
236
|
--summary <text> Concise review summary
|
|
230
237
|
--finding <text> Specific finding line (repeatable)
|
|
231
238
|
--diff-sha <sha> Bind review cryptographically to raw_diff_sha256 from "diffpact diff" (recommended; >=12 hex chars)
|
|
@@ -329,15 +336,35 @@ function printCommandHelp(cmd ) {
|
|
|
329
336
|
return true;
|
|
330
337
|
}
|
|
331
338
|
|
|
339
|
+
function failCliArg(cmd , message , jsonOut ) {
|
|
340
|
+
const full = cmd ? `diffpact ${cmd}: ${message}` : `diffpact: ${message}`;
|
|
341
|
+
if (jsonOut) {
|
|
342
|
+
process.stdout.write(JSON.stringify({ exit_code: EXIT_INCOMPLETE, error: full }, null, 2) + '\n');
|
|
343
|
+
} else {
|
|
344
|
+
process.stderr.write(`${full}\n`);
|
|
345
|
+
}
|
|
346
|
+
return EXIT_INCOMPLETE;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function failUnknownFlag(cmd , flag , jsonOut , extraHint ) {
|
|
350
|
+
const hint = extraHint ? ` ${extraHint}` : '';
|
|
351
|
+
return failCliArg(
|
|
352
|
+
cmd,
|
|
353
|
+
`Unknown option "${flag}". Run "diffpact ${cmd} --help" for valid options.${hint}`,
|
|
354
|
+
jsonOut
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
|
|
332
358
|
async function executeBoundedWorkerCommand(options
|
|
333
359
|
|
|
360
|
+
|
|
334
361
|
|
|
335
362
|
|
|
336
363
|
|
|
337
364
|
|
|
338
365
|
) {
|
|
339
|
-
const { contractPath, childCmd, resume, heartbeatSec, label } = options;
|
|
340
|
-
const contractAbs = path.resolve(
|
|
366
|
+
const { contractPath, cwd, childCmd, resume, heartbeatSec, label } = options;
|
|
367
|
+
const contractAbs = path.resolve(cwd, contractPath);
|
|
341
368
|
if (!fs.existsSync(contractAbs)) {
|
|
342
369
|
process.stderr.write(`Missing contract at "${contractAbs}"\n`);
|
|
343
370
|
return EXIT_INCOMPLETE;
|
|
@@ -351,7 +378,7 @@ async function executeBoundedWorkerCommand(options
|
|
|
351
378
|
return EXIT_INCOMPLETE;
|
|
352
379
|
}
|
|
353
380
|
|
|
354
|
-
const repoRoot = resolveRepoRoot(
|
|
381
|
+
const repoRoot = resolveRepoRoot(cwd);
|
|
355
382
|
const headBefore = resolveHeadSha(repoRoot);
|
|
356
383
|
if (!commitExists(repoRoot, contract.starting_sha)) {
|
|
357
384
|
process.stderr.write(`starting_sha ${contract.starting_sha} missing\n`);
|
|
@@ -462,8 +489,10 @@ async function executeBoundedWorkerCommand(options
|
|
|
462
489
|
|
|
463
490
|
export async function runCli(argv ) {
|
|
464
491
|
let contractPath = process.env.DIFFPACT_CONTRACT ?? '.diffpact/contract.json';
|
|
492
|
+
let cwdArg ;
|
|
465
493
|
let jsonOut = false;
|
|
466
494
|
let helpRequested = false;
|
|
495
|
+
let missingGlobalValueFlag ;
|
|
467
496
|
|
|
468
497
|
const rest = [];
|
|
469
498
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -472,8 +501,18 @@ export async function runCli(argv ) {
|
|
|
472
501
|
rest.push('--', ...argv.slice(i + 1));
|
|
473
502
|
break;
|
|
474
503
|
}
|
|
475
|
-
if (arg === '--contract'
|
|
476
|
-
|
|
504
|
+
if (arg === '--contract') {
|
|
505
|
+
if (!argv[i + 1]) {
|
|
506
|
+
missingGlobalValueFlag = '--contract';
|
|
507
|
+
} else {
|
|
508
|
+
contractPath = argv[++i] ;
|
|
509
|
+
}
|
|
510
|
+
} else if (arg === '--cwd' || arg === '-C') {
|
|
511
|
+
if (!argv[i + 1]) {
|
|
512
|
+
missingGlobalValueFlag = arg;
|
|
513
|
+
} else {
|
|
514
|
+
cwdArg = argv[++i] ;
|
|
515
|
+
}
|
|
477
516
|
} else if (arg === '--json') {
|
|
478
517
|
jsonOut = true;
|
|
479
518
|
} else if (arg === '-h' || arg === '--help') {
|
|
@@ -495,14 +534,26 @@ export async function runCli(argv ) {
|
|
|
495
534
|
printHelp();
|
|
496
535
|
return 0;
|
|
497
536
|
}
|
|
537
|
+
if (missingGlobalValueFlag) {
|
|
538
|
+
return failCliArg(cmd ?? '', `Option "${missingGlobalValueFlag}" requires a value`, jsonOut);
|
|
539
|
+
}
|
|
498
540
|
if (!cmd) {
|
|
499
541
|
printHelp();
|
|
500
542
|
return EXIT_INCOMPLETE;
|
|
501
543
|
}
|
|
502
544
|
|
|
545
|
+
const workCwd = cwdArg ? path.resolve(process.cwd(), cwdArg) : process.cwd();
|
|
546
|
+
if (cwdArg) {
|
|
547
|
+
if (!fs.existsSync(workCwd) || !fs.statSync(workCwd).isDirectory()) {
|
|
548
|
+
return failCliArg(cmd, `Directory not found for --cwd: "${cwdArg}"`, jsonOut);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
503
552
|
const subArgs = rest.slice(1);
|
|
504
553
|
|
|
505
554
|
if (cmd === 'print-config') {
|
|
555
|
+
const badFlag = subArgs.find((a) => a.startsWith('-'));
|
|
556
|
+
if (badFlag) return failUnknownFlag('print-config', badFlag, jsonOut);
|
|
506
557
|
const kind = subArgs[0];
|
|
507
558
|
if (kind === 'claude-code') process.stdout.write(generateClaudeCodeConfig(contractPath) + '\n');
|
|
508
559
|
else if (kind === 'codex') process.stdout.write(generateCodexConfig(contractPath) + '\n');
|
|
@@ -535,20 +586,45 @@ export async function runCli(argv ) {
|
|
|
535
586
|
|
|
536
587
|
for (let i = 0; i < subArgs.length; i++) {
|
|
537
588
|
const a = subArgs[i] ;
|
|
538
|
-
if (a === '--task-id'
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
else if (a === '--
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
else if (a === '--
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
else if (a === '--
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
else if (a === '--
|
|
551
|
-
|
|
589
|
+
if (a === '--task-id') {
|
|
590
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--task-id" requires a value', jsonOut);
|
|
591
|
+
taskId = subArgs[++i] ;
|
|
592
|
+
} else if (a === '--type') {
|
|
593
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--type" requires a value', jsonOut);
|
|
594
|
+
taskType = subArgs[++i] ;
|
|
595
|
+
} else if (a === '--mission') {
|
|
596
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--mission" requires a value', jsonOut);
|
|
597
|
+
mission = subArgs[++i] ;
|
|
598
|
+
} else if (a === '--starting-sha') {
|
|
599
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--starting-sha" requires a value', jsonOut);
|
|
600
|
+
startingSha = subArgs[++i] ;
|
|
601
|
+
} else if (a === '--branch') {
|
|
602
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--branch" requires a value', jsonOut);
|
|
603
|
+
branch = subArgs[++i] ;
|
|
604
|
+
} else if (a === '--implementer') {
|
|
605
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--implementer" requires a value', jsonOut);
|
|
606
|
+
implementerSpec = subArgs[++i] ;
|
|
607
|
+
} else if (a === '--allow') {
|
|
608
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--allow" requires a value', jsonOut);
|
|
609
|
+
allowedPaths.push(subArgs[++i] );
|
|
610
|
+
} else if (a === '--read-only') {
|
|
611
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--read-only" requires a value', jsonOut);
|
|
612
|
+
readOnlyPaths.push(subArgs[++i] );
|
|
613
|
+
} else if (a === '--forbid') {
|
|
614
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--forbid" requires a value', jsonOut);
|
|
615
|
+
forbiddenPaths.push(subArgs[++i] );
|
|
616
|
+
} else if (a === '--max-budget') {
|
|
617
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--max-budget" requires a value', jsonOut);
|
|
618
|
+
maxBudgetUsd = Number(subArgs[++i] );
|
|
619
|
+
} else if (a === '--lockfile') {
|
|
620
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--lockfile" requires a value', jsonOut);
|
|
621
|
+
lockfilePath = subArgs[++i] ;
|
|
622
|
+
} else if (a === '--allow-no-checks') {
|
|
623
|
+
allowNoChecks = true;
|
|
624
|
+
} else if (a === '--allow-no-commit') {
|
|
625
|
+
allowNoCommit = true;
|
|
626
|
+
} else if (a === '--check') {
|
|
627
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--check" requires a value', jsonOut);
|
|
552
628
|
const rawChk = subArgs[++i] ;
|
|
553
629
|
const eq = rawChk.indexOf('=');
|
|
554
630
|
if (eq === -1) {
|
|
@@ -560,7 +636,8 @@ export async function runCli(argv ) {
|
|
|
560
636
|
forbid_skipped: true
|
|
561
637
|
});
|
|
562
638
|
}
|
|
563
|
-
} else if (a === '--advisory-check'
|
|
639
|
+
} else if (a === '--advisory-check') {
|
|
640
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--advisory-check" requires a value', jsonOut);
|
|
564
641
|
const rawChk = subArgs[++i] ;
|
|
565
642
|
const eq = rawChk.indexOf('=');
|
|
566
643
|
if (eq === -1) {
|
|
@@ -572,7 +649,8 @@ export async function runCli(argv ) {
|
|
|
572
649
|
forbid_skipped: false
|
|
573
650
|
});
|
|
574
651
|
}
|
|
575
|
-
} else if (a === '--check-timeout'
|
|
652
|
+
} else if (a === '--check-timeout') {
|
|
653
|
+
if (!subArgs[i + 1]) return failCliArg('init', 'Option "--check-timeout" requires a value', jsonOut);
|
|
576
654
|
const rawTo = subArgs[++i] ;
|
|
577
655
|
const eq = rawTo.indexOf('=');
|
|
578
656
|
if (eq > 0) {
|
|
@@ -581,6 +659,8 @@ export async function runCli(argv ) {
|
|
|
581
659
|
checkTimeouts.set(rawTo.slice(0, eq), sec);
|
|
582
660
|
}
|
|
583
661
|
}
|
|
662
|
+
} else {
|
|
663
|
+
return failUnknownFlag('init', a, jsonOut);
|
|
584
664
|
}
|
|
585
665
|
}
|
|
586
666
|
|
|
@@ -590,11 +670,17 @@ export async function runCli(argv ) {
|
|
|
590
670
|
}
|
|
591
671
|
|
|
592
672
|
try {
|
|
593
|
-
const repoRoot = resolveRepoRoot(
|
|
594
|
-
|
|
595
|
-
if (
|
|
596
|
-
|
|
597
|
-
|
|
673
|
+
const repoRoot = resolveRepoRoot(workCwd);
|
|
674
|
+
let resolvedSha ;
|
|
675
|
+
if (startingSha) {
|
|
676
|
+
const canonical = resolveCommitSha(repoRoot, startingSha);
|
|
677
|
+
if (!canonical || !commitExists(repoRoot, canonical)) {
|
|
678
|
+
process.stderr.write(`starting_sha "${startingSha}" does not resolve to a commit\n`);
|
|
679
|
+
return EXIT_STALE;
|
|
680
|
+
}
|
|
681
|
+
resolvedSha = canonical;
|
|
682
|
+
} else {
|
|
683
|
+
resolvedSha = resolveHeadSha(repoRoot);
|
|
598
684
|
}
|
|
599
685
|
const resolvedBranch = branch || resolveCurrentBranch(repoRoot);
|
|
600
686
|
const implementer = parseSessionSpec(implementerSpec, '--implementer');
|
|
@@ -644,7 +730,7 @@ export async function runCli(argv ) {
|
|
|
644
730
|
}
|
|
645
731
|
});
|
|
646
732
|
|
|
647
|
-
const outAbs = path.resolve(
|
|
733
|
+
const outAbs = path.resolve(workCwd, contractPath);
|
|
648
734
|
fs.mkdirSync(path.dirname(outAbs), { recursive: true });
|
|
649
735
|
fs.writeFileSync(outAbs, JSON.stringify(contract, null, 2) + '\n');
|
|
650
736
|
if (contractPath === '.diffpact/contract.json' || contractPath.startsWith('.diffpact/')) {
|
|
@@ -666,15 +752,19 @@ export async function runCli(argv ) {
|
|
|
666
752
|
if (cmd === 'verify') {
|
|
667
753
|
let heartbeatSec = process.stderr.isTTY ? 0 : 30;
|
|
668
754
|
for (let i = 0; i < subArgs.length; i++) {
|
|
669
|
-
|
|
755
|
+
const a = subArgs[i] ;
|
|
756
|
+
if (a === '--heartbeat-sec') {
|
|
757
|
+
if (!subArgs[i + 1]) return failCliArg('verify', 'Option "--heartbeat-sec" requires a value', jsonOut);
|
|
670
758
|
const parsed = Number(subArgs[++i] );
|
|
671
759
|
if (Number.isFinite(parsed) && parsed >= 0) heartbeatSec = parsed;
|
|
760
|
+
} else {
|
|
761
|
+
return failUnknownFlag('verify', a, jsonOut);
|
|
672
762
|
}
|
|
673
763
|
}
|
|
674
764
|
const res =
|
|
675
765
|
heartbeatSec > 0
|
|
676
|
-
? await runVerifyAsync({ contractPath, heartbeatSec })
|
|
677
|
-
: runVerify({ contractPath });
|
|
766
|
+
? await runVerifyAsync({ contractPath, cwd: workCwd, heartbeatSec })
|
|
767
|
+
: runVerify({ contractPath, cwd: workCwd });
|
|
678
768
|
if (jsonOut) {
|
|
679
769
|
process.stdout.write(JSON.stringify(res.receipt ?? { exit_code: res.exitCode, error: res.error }, null, 2) + '\n');
|
|
680
770
|
} else if (res.receipt) {
|
|
@@ -698,14 +788,17 @@ export async function runCli(argv ) {
|
|
|
698
788
|
}
|
|
699
789
|
|
|
700
790
|
if (cmd === 'diff') {
|
|
701
|
-
|
|
791
|
+
if (subArgs.length > 0) {
|
|
792
|
+
return failUnknownFlag('diff', subArgs[0] , jsonOut);
|
|
793
|
+
}
|
|
794
|
+
const contractAbs = path.resolve(workCwd, contractPath);
|
|
702
795
|
if (!fs.existsSync(contractAbs)) {
|
|
703
796
|
process.stderr.write(`Missing contract at "${contractAbs}"\n`);
|
|
704
797
|
return EXIT_INCOMPLETE;
|
|
705
798
|
}
|
|
706
799
|
try {
|
|
707
800
|
const contract = validateContract(JSON.parse(fs.readFileSync(contractAbs, 'utf8')));
|
|
708
|
-
const repoRoot = resolveRepoRoot(
|
|
801
|
+
const repoRoot = resolveRepoRoot(workCwd);
|
|
709
802
|
const headSha = resolveHeadSha(repoRoot);
|
|
710
803
|
const snap = collectRepoChanges(repoRoot, contract.starting_sha, headSha);
|
|
711
804
|
const patchText = runGitText(repoRoot, ['diff', '--binary', '-M', contract.starting_sha, headSha]);
|
|
@@ -754,17 +847,32 @@ export async function runCli(argv ) {
|
|
|
754
847
|
|
|
755
848
|
for (let i = 0; i < subArgs.length; i++) {
|
|
756
849
|
const a = subArgs[i] ;
|
|
757
|
-
if (a === '--from'
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
else if (a === '--
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
else if (a === '--
|
|
764
|
-
|
|
850
|
+
if (a === '--from') {
|
|
851
|
+
if (!subArgs[i + 1]) return failCliArg('merge-verify', 'Option "--from" requires a value', jsonOut);
|
|
852
|
+
fromPaths.push(subArgs[++i] );
|
|
853
|
+
} else if (a === '--base') {
|
|
854
|
+
if (!subArgs[i + 1]) return failCliArg('merge-verify', 'Option "--base" requires a value', jsonOut);
|
|
855
|
+
baseSha = subArgs[++i] ;
|
|
856
|
+
} else if (a === '--allow-integration') {
|
|
857
|
+
if (!subArgs[i + 1]) return failCliArg('merge-verify', 'Option "--allow-integration" requires a value', jsonOut);
|
|
858
|
+
allowIntegrationPaths.push(subArgs[++i] );
|
|
859
|
+
} else if (a === '--reason') {
|
|
860
|
+
if (!subArgs[i + 1]) return failCliArg('merge-verify', 'Option "--reason" requires a value', jsonOut);
|
|
861
|
+
integrationReason = subArgs[++i] ;
|
|
862
|
+
} else if (a === '--allow-untracked' || a === '--committed-only') {
|
|
863
|
+
allowUntracked = true;
|
|
864
|
+
} else if (a === '--write-receipt') {
|
|
865
|
+
if (!subArgs[i + 1]) return failCliArg('merge-verify', 'Option "--write-receipt" requires a value', jsonOut);
|
|
866
|
+
receiptPath = subArgs[++i] ;
|
|
867
|
+
} else if (a === '--no-write') {
|
|
868
|
+
writeReceipt = false;
|
|
869
|
+
} else if (a === '--heartbeat-sec') {
|
|
870
|
+
if (!subArgs[i + 1]) return failCliArg('merge-verify', 'Option "--heartbeat-sec" requires a value', jsonOut);
|
|
765
871
|
const parsed = Number(subArgs[++i] );
|
|
766
872
|
if (Number.isFinite(parsed) && parsed >= 0) heartbeatSec = parsed;
|
|
767
|
-
} else if (
|
|
873
|
+
} else if (a.startsWith('-')) {
|
|
874
|
+
return failUnknownFlag('merge-verify', a, jsonOut);
|
|
875
|
+
} else {
|
|
768
876
|
fromPaths.push(a);
|
|
769
877
|
}
|
|
770
878
|
}
|
|
@@ -778,6 +886,7 @@ export async function runCli(argv ) {
|
|
|
778
886
|
|
|
779
887
|
const res = await runMergeVerify({
|
|
780
888
|
fromPaths,
|
|
889
|
+
cwd: workCwd,
|
|
781
890
|
baseSha,
|
|
782
891
|
...(allowIntegrationPaths.length > 0 ? { allowIntegrationPaths } : {}),
|
|
783
892
|
...(integrationReason ? { integrationReason } : {}),
|
|
@@ -844,15 +953,20 @@ export async function runCli(argv ) {
|
|
|
844
953
|
let heartbeatSec = process.stderr.isTTY ? 0 : 30;
|
|
845
954
|
for (let i = 0; i < preFlags.length; i++) {
|
|
846
955
|
const a = preFlags[i] ;
|
|
847
|
-
if (a === '--resume' || a === '--allow-in-scope-dirty')
|
|
848
|
-
|
|
956
|
+
if (a === '--resume' || a === '--allow-in-scope-dirty') {
|
|
957
|
+
resume = true;
|
|
958
|
+
} else if (a === '--heartbeat-sec') {
|
|
959
|
+
if (!preFlags[i + 1]) return failCliArg(cmd, 'Option "--heartbeat-sec" requires a value', jsonOut);
|
|
849
960
|
const parsed = Number(preFlags[++i] );
|
|
850
961
|
if (Number.isFinite(parsed) && parsed >= 0) heartbeatSec = parsed;
|
|
962
|
+
} else {
|
|
963
|
+
return failUnknownFlag(cmd, a, jsonOut);
|
|
851
964
|
}
|
|
852
965
|
}
|
|
853
966
|
|
|
854
967
|
return executeBoundedWorkerCommand({
|
|
855
968
|
contractPath,
|
|
969
|
+
cwd: workCwd,
|
|
856
970
|
childCmd,
|
|
857
971
|
resume,
|
|
858
972
|
heartbeatSec,
|
|
@@ -873,17 +987,34 @@ export async function runCli(argv ) {
|
|
|
873
987
|
|
|
874
988
|
for (let i = 0; i < subArgs.length; i++) {
|
|
875
989
|
const a = subArgs[i] ;
|
|
876
|
-
if (a === '--harness'
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
else if (a === '--
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
else if (a === '--
|
|
883
|
-
|
|
884
|
-
|
|
990
|
+
if (a === '--harness') {
|
|
991
|
+
if (!subArgs[i + 1]) return failCliArg('run', 'Option "--harness" requires a value', jsonOut);
|
|
992
|
+
harnessRaw = subArgs[++i] ;
|
|
993
|
+
} else if (a === '--model') {
|
|
994
|
+
if (!subArgs[i + 1]) return failCliArg('run', 'Option "--model" requires a value', jsonOut);
|
|
995
|
+
model = subArgs[++i] ;
|
|
996
|
+
} else if (a === '--reasoning-effort') {
|
|
997
|
+
if (!subArgs[i + 1]) return failCliArg('run', 'Option "--reasoning-effort" requires a value', jsonOut);
|
|
998
|
+
reasoningEffort = subArgs[++i] ;
|
|
999
|
+
} else if (a === '--data-dir') {
|
|
1000
|
+
if (!subArgs[i + 1]) return failCliArg('run', 'Option "--data-dir" requires a value', jsonOut);
|
|
1001
|
+
dataDir = subArgs[++i] ;
|
|
1002
|
+
} else if (a === '--prompt') {
|
|
1003
|
+
if (!subArgs[i + 1]) return failCliArg('run', 'Option "--prompt" requires a value', jsonOut);
|
|
1004
|
+
prompt = subArgs[++i] ;
|
|
1005
|
+
} else if (a === '--prompt-file') {
|
|
1006
|
+
if (!subArgs[i + 1]) return failCliArg('run', 'Option "--prompt-file" requires a value', jsonOut);
|
|
1007
|
+
promptFile = subArgs[++i] ;
|
|
1008
|
+
} else if (a === '--resume' || a === '--allow-in-scope-dirty') {
|
|
1009
|
+
resume = true;
|
|
1010
|
+
} else if (a === '--dry-run') {
|
|
1011
|
+
dryRun = true;
|
|
1012
|
+
} else if (a === '--heartbeat-sec') {
|
|
1013
|
+
if (!subArgs[i + 1]) return failCliArg('run', 'Option "--heartbeat-sec" requires a value', jsonOut);
|
|
885
1014
|
const parsed = Number(subArgs[++i] );
|
|
886
1015
|
if (Number.isFinite(parsed) && parsed >= 0) heartbeatSec = parsed;
|
|
1016
|
+
} else {
|
|
1017
|
+
return failUnknownFlag('run', a, jsonOut);
|
|
887
1018
|
}
|
|
888
1019
|
}
|
|
889
1020
|
|
|
@@ -906,7 +1037,7 @@ export async function runCli(argv ) {
|
|
|
906
1037
|
}
|
|
907
1038
|
|
|
908
1039
|
if (promptFile) {
|
|
909
|
-
const absPrompt = path.resolve(
|
|
1040
|
+
const absPrompt = path.resolve(workCwd, promptFile);
|
|
910
1041
|
if (!fs.existsSync(absPrompt)) {
|
|
911
1042
|
process.stderr.write(`Prompt file not found: "${absPrompt}"\n`);
|
|
912
1043
|
return EXIT_INCOMPLETE;
|
|
@@ -918,7 +1049,7 @@ export async function runCli(argv ) {
|
|
|
918
1049
|
return EXIT_INCOMPLETE;
|
|
919
1050
|
}
|
|
920
1051
|
|
|
921
|
-
const repoRoot = resolveRepoRoot(
|
|
1052
|
+
const repoRoot = resolveRepoRoot(workCwd);
|
|
922
1053
|
const built = buildHarnessCommand({ harness, repoRoot, prompt, model, reasoningEffort, dataDir });
|
|
923
1054
|
if (dryRun) {
|
|
924
1055
|
if (jsonOut) {
|
|
@@ -938,6 +1069,7 @@ export async function runCli(argv ) {
|
|
|
938
1069
|
}
|
|
939
1070
|
return executeBoundedWorkerCommand({
|
|
940
1071
|
contractPath,
|
|
1072
|
+
cwd: workCwd,
|
|
941
1073
|
childCmd: [built.bin, ...built.args],
|
|
942
1074
|
resume,
|
|
943
1075
|
heartbeatSec,
|
|
@@ -955,11 +1087,24 @@ export async function runCli(argv ) {
|
|
|
955
1087
|
const nodeModulesDirs = [];
|
|
956
1088
|
for (let i = 1; i < subArgs.length; i++) {
|
|
957
1089
|
const a = subArgs[i] ;
|
|
958
|
-
if (a === '--branch'
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
else if (a === '--
|
|
962
|
-
|
|
1090
|
+
if (a === '--branch') {
|
|
1091
|
+
if (!subArgs[i + 1]) return failCliArg('worktree', 'Option "--branch" requires a value', jsonOut);
|
|
1092
|
+
branch = subArgs[++i] ;
|
|
1093
|
+
} else if (a === '--from') {
|
|
1094
|
+
if (!subArgs[i + 1]) return failCliArg('worktree', 'Option "--from" requires a value', jsonOut);
|
|
1095
|
+
fromRef = subArgs[++i] ;
|
|
1096
|
+
} else if (a === '--share-node-modules') {
|
|
1097
|
+
shareNodeModules = true;
|
|
1098
|
+
} else if (a === '--node-modules-dir') {
|
|
1099
|
+
if (!subArgs[i + 1]) return failCliArg('worktree', 'Option "--node-modules-dir" requires a value', jsonOut);
|
|
1100
|
+
nodeModulesDirs.push(subArgs[++i] );
|
|
1101
|
+
} else if (a.startsWith('-')) {
|
|
1102
|
+
return failUnknownFlag('worktree', a, jsonOut);
|
|
1103
|
+
} else if (!dir) {
|
|
1104
|
+
dir = a;
|
|
1105
|
+
} else {
|
|
1106
|
+
return failCliArg('worktree', `Unexpected extra positional argument "${a}"`, jsonOut);
|
|
1107
|
+
}
|
|
963
1108
|
}
|
|
964
1109
|
if (!dir || !branch) {
|
|
965
1110
|
process.stderr.write(
|
|
@@ -969,6 +1114,7 @@ export async function runCli(argv ) {
|
|
|
969
1114
|
}
|
|
970
1115
|
try {
|
|
971
1116
|
const res = createManagedWorktree({
|
|
1117
|
+
cwd: workCwd,
|
|
972
1118
|
dir,
|
|
973
1119
|
branch,
|
|
974
1120
|
fromRef,
|
|
@@ -1010,9 +1156,13 @@ export async function runCli(argv ) {
|
|
|
1010
1156
|
else if (a === '--force-delete-branch') forceDeleteBranch = true;
|
|
1011
1157
|
else if (a === '--force') force = true;
|
|
1012
1158
|
else if (a === '--require-verified') requireVerified = true;
|
|
1013
|
-
else if (a === '--archive-dir'
|
|
1014
|
-
|
|
1015
|
-
|
|
1159
|
+
else if (a === '--archive-dir') {
|
|
1160
|
+
if (!subArgs[i + 1]) return failCliArg('worktree', 'Option "--archive-dir" requires a value', jsonOut);
|
|
1161
|
+
archiveDir = subArgs[++i] ;
|
|
1162
|
+
} else if (a === '--no-archive') noArchive = true;
|
|
1163
|
+
else if (a.startsWith('-')) return failUnknownFlag('worktree', a, jsonOut);
|
|
1164
|
+
else if (!dir) dir = a;
|
|
1165
|
+
else return failCliArg('worktree', `Unexpected extra positional argument "${a}"`, jsonOut);
|
|
1016
1166
|
}
|
|
1017
1167
|
if (!dir) {
|
|
1018
1168
|
process.stderr.write(
|
|
@@ -1021,6 +1171,7 @@ export async function runCli(argv ) {
|
|
|
1021
1171
|
return EXIT_INCOMPLETE;
|
|
1022
1172
|
}
|
|
1023
1173
|
const res = removeManagedWorktree({
|
|
1174
|
+
cwd: workCwd,
|
|
1024
1175
|
dir,
|
|
1025
1176
|
deleteBranch,
|
|
1026
1177
|
forceDeleteBranch,
|
|
@@ -1050,7 +1201,7 @@ export async function runCli(argv ) {
|
|
|
1050
1201
|
|
|
1051
1202
|
if (cmd === 'review') {
|
|
1052
1203
|
let reviewerSpec = '';
|
|
1053
|
-
let
|
|
1204
|
+
let verdictRaw ;
|
|
1054
1205
|
let summary = 'Independent diff review completed';
|
|
1055
1206
|
let adapter = '';
|
|
1056
1207
|
let explicitInspectedRawDiff = false;
|
|
@@ -1065,21 +1216,45 @@ export async function runCli(argv ) {
|
|
|
1065
1216
|
|
|
1066
1217
|
for (let i = 0; i < flagArgs.length; i++) {
|
|
1067
1218
|
const a = flagArgs[i] ;
|
|
1068
|
-
if (a === '--reviewer'
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
else if (a === '--
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
else if (a === '--
|
|
1075
|
-
|
|
1076
|
-
|
|
1219
|
+
if (a === '--reviewer') {
|
|
1220
|
+
if (!flagArgs[i + 1]) return failCliArg('review', 'Option "--reviewer" requires a value', jsonOut);
|
|
1221
|
+
reviewerSpec = flagArgs[++i] ;
|
|
1222
|
+
} else if (a === '--verdict') {
|
|
1223
|
+
if (!flagArgs[i + 1]) return failCliArg('review', 'Option "--verdict" requires a value ("approve" or "reject")', jsonOut);
|
|
1224
|
+
verdictRaw = flagArgs[++i] ;
|
|
1225
|
+
} else if (a === '--summary') {
|
|
1226
|
+
if (!flagArgs[i + 1]) return failCliArg('review', 'Option "--summary" requires a value', jsonOut);
|
|
1227
|
+
summary = flagArgs[++i] ;
|
|
1228
|
+
} else if (a === '--finding') {
|
|
1229
|
+
if (!flagArgs[i + 1]) return failCliArg('review', 'Option "--finding" requires a value', jsonOut);
|
|
1230
|
+
findings.push(flagArgs[++i] );
|
|
1231
|
+
} else if (a === '--adapter') {
|
|
1232
|
+
if (!flagArgs[i + 1]) return failCliArg('review', 'Option "--adapter" requires a value', jsonOut);
|
|
1233
|
+
adapter = flagArgs[++i] ;
|
|
1234
|
+
} else if (a === '--lineage') {
|
|
1235
|
+
if (!flagArgs[i + 1]) return failCliArg('review', 'Option "--lineage" requires a value', jsonOut);
|
|
1236
|
+
lineageId = flagArgs[++i] ;
|
|
1237
|
+
} else if (a === '--diff-sha') {
|
|
1238
|
+
if (!flagArgs[i + 1]) return failCliArg('review', 'Option "--diff-sha" requires a value', jsonOut);
|
|
1239
|
+
diffSha = flagArgs[++i] ;
|
|
1240
|
+
} else if (a === '--inspected-raw-diff') {
|
|
1241
|
+
explicitInspectedRawDiff = true;
|
|
1242
|
+
} else if (a === '--summary-only') {
|
|
1243
|
+
summaryOnly = true;
|
|
1244
|
+
} else {
|
|
1245
|
+
const hint =
|
|
1246
|
+
a === '--decision' || a === '--status' || a === '--result'
|
|
1247
|
+
? 'Use --verdict <approve|reject>.'
|
|
1248
|
+
: undefined;
|
|
1249
|
+
return failUnknownFlag('review', a, jsonOut, hint);
|
|
1250
|
+
}
|
|
1077
1251
|
}
|
|
1078
1252
|
|
|
1079
1253
|
if (adapter === 'codex' && wrappedArgs.length > 0) {
|
|
1080
1254
|
const reviewerAgentId = reviewerSpec.split(':')[0] || 'codex-reviewer';
|
|
1081
1255
|
const res = runWrappedCodexReview({
|
|
1082
1256
|
contractPath,
|
|
1257
|
+
cwd: workCwd,
|
|
1083
1258
|
reviewerAgentId,
|
|
1084
1259
|
commandArgs: wrappedArgs,
|
|
1085
1260
|
inspectedRawDiff: !summaryOnly,
|
|
@@ -1095,6 +1270,22 @@ export async function runCli(argv ) {
|
|
|
1095
1270
|
return res.exitCode;
|
|
1096
1271
|
}
|
|
1097
1272
|
|
|
1273
|
+
if (!verdictRaw) {
|
|
1274
|
+
return failCliArg(
|
|
1275
|
+
'review',
|
|
1276
|
+
'Missing required --verdict <approve|reject> option (verdict never defaults to approve).',
|
|
1277
|
+
jsonOut
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
if (verdictRaw !== 'approve' && verdictRaw !== 'reject') {
|
|
1281
|
+
return failCliArg(
|
|
1282
|
+
'review',
|
|
1283
|
+
`Invalid --verdict "${verdictRaw}". Expected "approve" or "reject".`,
|
|
1284
|
+
jsonOut
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1287
|
+
const verdict = verdictRaw;
|
|
1288
|
+
|
|
1098
1289
|
// On CLI, raw-diff inspection is NEVER silently assumed true; reviewer must pass --diff-sha <sha> or --inspected-raw-diff
|
|
1099
1290
|
const inspectedRawDiff = !summaryOnly && (explicitInspectedRawDiff || Boolean(diffSha));
|
|
1100
1291
|
if (!inspectedRawDiff && !summaryOnly) {
|
|
@@ -1112,6 +1303,7 @@ export async function runCli(argv ) {
|
|
|
1112
1303
|
const reviewer = parseSessionSpec(reviewerSpec, '--reviewer');
|
|
1113
1304
|
const res = runReview({
|
|
1114
1305
|
contractPath,
|
|
1306
|
+
cwd: workCwd,
|
|
1115
1307
|
reviewer,
|
|
1116
1308
|
verdict,
|
|
1117
1309
|
summary,
|
|
@@ -1145,10 +1337,16 @@ export async function runCli(argv ) {
|
|
|
1145
1337
|
let integratorAgentId ;
|
|
1146
1338
|
for (let i = 0; i < subArgs.length; i++) {
|
|
1147
1339
|
const a = subArgs[i] ;
|
|
1148
|
-
if (a === '--require-review')
|
|
1149
|
-
|
|
1340
|
+
if (a === '--require-review') {
|
|
1341
|
+
requireReview = true;
|
|
1342
|
+
} else if (a === '--integrator') {
|
|
1343
|
+
if (!subArgs[i + 1]) return failCliArg('status', 'Option "--integrator" requires a value', jsonOut);
|
|
1344
|
+
integratorAgentId = subArgs[++i] ;
|
|
1345
|
+
} else {
|
|
1346
|
+
return failUnknownFlag('status', a, jsonOut);
|
|
1347
|
+
}
|
|
1150
1348
|
}
|
|
1151
|
-
const st = checkStatus({ contractPath, requireReview, integratorAgentId });
|
|
1349
|
+
const st = checkStatus({ contractPath, cwd: workCwd, requireReview, integratorAgentId });
|
|
1152
1350
|
if (jsonOut) {
|
|
1153
1351
|
process.stdout.write(JSON.stringify(st, null, 2) + '\n');
|
|
1154
1352
|
} else {
|
|
@@ -1168,19 +1366,37 @@ export async function runCli(argv ) {
|
|
|
1168
1366
|
|
|
1169
1367
|
for (let i = 0; i < subArgs.length; i++) {
|
|
1170
1368
|
const a = subArgs[i] ;
|
|
1171
|
-
if (a === '--subtask-id'
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
else if (a === '--
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
else if (a === '--
|
|
1369
|
+
if (a === '--subtask-id') {
|
|
1370
|
+
if (!subArgs[i + 1]) return failCliArg('delegate', 'Option "--subtask-id" requires a value', jsonOut);
|
|
1371
|
+
subtaskId = subArgs[++i] ;
|
|
1372
|
+
} else if (a === '--mission') {
|
|
1373
|
+
if (!subArgs[i + 1]) return failCliArg('delegate', 'Option "--mission" requires a value', jsonOut);
|
|
1374
|
+
mission = subArgs[++i] ;
|
|
1375
|
+
} else if (a === '--implementer') {
|
|
1376
|
+
if (!subArgs[i + 1]) return failCliArg('delegate', 'Option "--implementer" requires a value', jsonOut);
|
|
1377
|
+
implementerSpec = subArgs[++i] ;
|
|
1378
|
+
} else if (a === '--allow') {
|
|
1379
|
+
if (!subArgs[i + 1]) return failCliArg('delegate', 'Option "--allow" requires a value', jsonOut);
|
|
1380
|
+
allowedPaths.push(subArgs[++i] );
|
|
1381
|
+
} else if (a === '--budget') {
|
|
1382
|
+
if (!subArgs[i + 1]) return failCliArg('delegate', 'Option "--budget" requires a value', jsonOut);
|
|
1383
|
+
budgetUsd = Number(subArgs[++i] );
|
|
1384
|
+
} else if (a === '--branch') {
|
|
1385
|
+
if (!subArgs[i + 1]) return failCliArg('delegate', 'Option "--branch" requires a value', jsonOut);
|
|
1386
|
+
branch = subArgs[++i] ;
|
|
1387
|
+
} else if (a === '--worktree') {
|
|
1388
|
+
if (!subArgs[i + 1]) return failCliArg('delegate', 'Option "--worktree" requires a value', jsonOut);
|
|
1389
|
+
worktreePath = subArgs[++i] ;
|
|
1390
|
+
} else {
|
|
1391
|
+
return failUnknownFlag('delegate', a, jsonOut);
|
|
1392
|
+
}
|
|
1178
1393
|
}
|
|
1179
1394
|
|
|
1180
1395
|
try {
|
|
1181
1396
|
const implementer = parseSessionSpec(implementerSpec, '--implementer');
|
|
1182
1397
|
const res = createDelegatedSubcontract({
|
|
1183
1398
|
parentContractPath: contractPath,
|
|
1399
|
+
cwd: workCwd,
|
|
1184
1400
|
subtaskId,
|
|
1185
1401
|
mission,
|
|
1186
1402
|
allowedPaths,
|
|
@@ -1206,8 +1422,12 @@ export async function runCli(argv ) {
|
|
|
1206
1422
|
if (cmd === 'hook' || cmd === 'gate') {
|
|
1207
1423
|
const firstArgIsJson = Boolean(subArgs[0]?.trim().startsWith('{'));
|
|
1208
1424
|
const target = firstArgIsJson ? 'auto' : (subArgs[0] ?? 'auto');
|
|
1425
|
+
if (target.startsWith('-')) {
|
|
1426
|
+
return failUnknownFlag(cmd, target, jsonOut);
|
|
1427
|
+
}
|
|
1209
1428
|
const rawArgPayload = firstArgIsJson ? subArgs[0] : subArgs[1];
|
|
1210
1429
|
const stdinText = rawArgPayload ?? readStdinUtf8();
|
|
1430
|
+
const resolvedContractPath = cwdArg ? path.resolve(workCwd, contractPath) : contractPath;
|
|
1211
1431
|
|
|
1212
1432
|
let payload = {};
|
|
1213
1433
|
if (stdinText.trim()) {
|
|
@@ -1234,11 +1454,11 @@ export async function runCli(argv ) {
|
|
|
1234
1454
|
}
|
|
1235
1455
|
|
|
1236
1456
|
let res;
|
|
1237
|
-
if (resolvedTarget === 'claude-code') res = handleClaudeCodeHook(payload,
|
|
1238
|
-
else if (resolvedTarget === 'codex') res = handleCodexHook(payload,
|
|
1239
|
-
else if (resolvedTarget === 'codex-notify') res = handleCodexNotify(payload,
|
|
1240
|
-
else if (resolvedTarget === 'gemini') res = handleGeminiCliHook(payload,
|
|
1241
|
-
else if (resolvedTarget === 'agy') res = handleAgyHook(payload,
|
|
1457
|
+
if (resolvedTarget === 'claude-code') res = handleClaudeCodeHook(payload, resolvedContractPath);
|
|
1458
|
+
else if (resolvedTarget === 'codex') res = handleCodexHook(payload, resolvedContractPath);
|
|
1459
|
+
else if (resolvedTarget === 'codex-notify') res = handleCodexNotify(payload, resolvedContractPath);
|
|
1460
|
+
else if (resolvedTarget === 'gemini') res = handleGeminiCliHook(payload, resolvedContractPath);
|
|
1461
|
+
else if (resolvedTarget === 'agy') res = handleAgyHook(payload, resolvedContractPath);
|
|
1242
1462
|
else {
|
|
1243
1463
|
process.stderr.write(`Unknown hook target "${resolvedTarget}"\n`);
|
|
1244
1464
|
return 2;
|
|
@@ -1256,10 +1476,19 @@ export async function runCli(argv ) {
|
|
|
1256
1476
|
const positionals = [];
|
|
1257
1477
|
for (let i = 0; i < subArgs.length; i++) {
|
|
1258
1478
|
const a = subArgs[i] ;
|
|
1259
|
-
if (a === '--vb-bin'
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
else
|
|
1479
|
+
if (a === '--vb-bin') {
|
|
1480
|
+
if (!subArgs[i + 1]) return failCliArg('board', 'Option "--vb-bin" requires a value', jsonOut);
|
|
1481
|
+
vbBin = subArgs[++i] ;
|
|
1482
|
+
} else if (a === '--no-require-review') {
|
|
1483
|
+
requireReview = false;
|
|
1484
|
+
} else if (a === '--message') {
|
|
1485
|
+
if (!subArgs[i + 1]) return failCliArg('board', 'Option "--message" requires a value', jsonOut);
|
|
1486
|
+
summaryMessage = subArgs[++i] ;
|
|
1487
|
+
} else if (a.startsWith('-')) {
|
|
1488
|
+
return failUnknownFlag('board', a, jsonOut);
|
|
1489
|
+
} else {
|
|
1490
|
+
positionals.push(a);
|
|
1491
|
+
}
|
|
1263
1492
|
}
|
|
1264
1493
|
const action = positionals[0];
|
|
1265
1494
|
const taskId = positionals[1];
|
|
@@ -1269,7 +1498,7 @@ export async function runCli(argv ) {
|
|
|
1269
1498
|
}
|
|
1270
1499
|
|
|
1271
1500
|
if (action === 'post-contract') {
|
|
1272
|
-
const r = boardPostContract({ contractPath, taskId, vbBin });
|
|
1501
|
+
const r = boardPostContract({ contractPath, cwd: workCwd, taskId, vbBin });
|
|
1273
1502
|
if (jsonOut) process.stdout.write(JSON.stringify(r) + '\n');
|
|
1274
1503
|
else process.stdout.write(r.message + '\n');
|
|
1275
1504
|
return r.exitCode;
|
|
@@ -1277,6 +1506,7 @@ export async function runCli(argv ) {
|
|
|
1277
1506
|
if (action === 'complete') {
|
|
1278
1507
|
const r = boardCompleteGate({
|
|
1279
1508
|
contractPath,
|
|
1509
|
+
cwd: workCwd,
|
|
1280
1510
|
taskId,
|
|
1281
1511
|
vbBin,
|
|
1282
1512
|
requireReview,
|
|
@@ -1295,6 +1525,7 @@ export async function runCli(argv ) {
|
|
|
1295
1525
|
const positionals = [];
|
|
1296
1526
|
for (const a of subArgs) {
|
|
1297
1527
|
if (a === '--allow-empty') allowEmpty = true;
|
|
1528
|
+
else if (a.startsWith('-')) return failUnknownFlag('agy-verify-patch', a, jsonOut);
|
|
1298
1529
|
else positionals.push(a);
|
|
1299
1530
|
}
|
|
1300
1531
|
const patchPath = positionals[0];
|
|
@@ -1302,7 +1533,7 @@ export async function runCli(argv ) {
|
|
|
1302
1533
|
process.stderr.write('Usage: diffpact agy-verify-patch <patch-file> [--allow-empty]\n');
|
|
1303
1534
|
return EXIT_INCOMPLETE;
|
|
1304
1535
|
}
|
|
1305
|
-
const r = verifyAgyWorkerPatch({ contractPath, patchPath, allowEmpty });
|
|
1536
|
+
const r = verifyAgyWorkerPatch({ contractPath, cwd: workCwd, patchPath, allowEmpty });
|
|
1306
1537
|
if (jsonOut) {
|
|
1307
1538
|
process.stdout.write(JSON.stringify(r, null, 2) + '\n');
|
|
1308
1539
|
} else if (r.exitCode === 0) {
|
|
@@ -1314,12 +1545,7 @@ export async function runCli(argv ) {
|
|
|
1314
1545
|
}
|
|
1315
1546
|
|
|
1316
1547
|
if (cmd === 'amend') {
|
|
1317
|
-
|
|
1318
|
-
const hist = readAmendmentHistory(contractPath);
|
|
1319
|
-
if (jsonOut) process.stdout.write(JSON.stringify(hist, null, 2) + '\n');
|
|
1320
|
-
else process.stdout.write(`Amendments: ${hist.entries.length} (valid=${hist.valid})\n`);
|
|
1321
|
-
return hist.valid ? EXIT_PASS : EXIT_VIOLATION;
|
|
1322
|
-
}
|
|
1548
|
+
let showHistory = false;
|
|
1323
1549
|
let authorizedBy = '';
|
|
1324
1550
|
let reason = '';
|
|
1325
1551
|
let updateStartingSha ;
|
|
@@ -1328,15 +1554,39 @@ export async function runCli(argv ) {
|
|
|
1328
1554
|
const addForbiddenPaths = [];
|
|
1329
1555
|
for (let i = 0; i < subArgs.length; i++) {
|
|
1330
1556
|
const a = subArgs[i] ;
|
|
1331
|
-
if (a === '--
|
|
1332
|
-
|
|
1333
|
-
else if (a === '--
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
else if (a === '--
|
|
1557
|
+
if (a === '--history') {
|
|
1558
|
+
showHistory = true;
|
|
1559
|
+
} else if (a === '--authorized-by') {
|
|
1560
|
+
if (!subArgs[i + 1]) return failCliArg('amend', 'Option "--authorized-by" requires a value', jsonOut);
|
|
1561
|
+
authorizedBy = subArgs[++i] ;
|
|
1562
|
+
} else if (a === '--reason') {
|
|
1563
|
+
if (!subArgs[i + 1]) return failCliArg('amend', 'Option "--reason" requires a value', jsonOut);
|
|
1564
|
+
reason = subArgs[++i] ;
|
|
1565
|
+
} else if (a === '--add-allow') {
|
|
1566
|
+
if (!subArgs[i + 1]) return failCliArg('amend', 'Option "--add-allow" requires a value', jsonOut);
|
|
1567
|
+
addAllowedPaths.push(subArgs[++i] );
|
|
1568
|
+
} else if (a === '--add-read-only') {
|
|
1569
|
+
if (!subArgs[i + 1]) return failCliArg('amend', 'Option "--add-read-only" requires a value', jsonOut);
|
|
1570
|
+
addReadOnlyPaths.push(subArgs[++i] );
|
|
1571
|
+
} else if (a === '--add-forbid') {
|
|
1572
|
+
if (!subArgs[i + 1]) return failCliArg('amend', 'Option "--add-forbid" requires a value', jsonOut);
|
|
1573
|
+
addForbiddenPaths.push(subArgs[++i] );
|
|
1574
|
+
} else if (a === '--update-starting-sha') {
|
|
1575
|
+
if (!subArgs[i + 1]) return failCliArg('amend', 'Option "--update-starting-sha" requires a value', jsonOut);
|
|
1576
|
+
updateStartingSha = subArgs[++i] ;
|
|
1577
|
+
} else {
|
|
1578
|
+
return failUnknownFlag('amend', a, jsonOut);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
if (showHistory) {
|
|
1582
|
+
const hist = readAmendmentHistory(contractPath, workCwd);
|
|
1583
|
+
if (jsonOut) process.stdout.write(JSON.stringify(hist, null, 2) + '\n');
|
|
1584
|
+
else process.stdout.write(`Amendments: ${hist.entries.length} (valid=${hist.valid})\n`);
|
|
1585
|
+
return hist.valid ? EXIT_PASS : EXIT_VIOLATION;
|
|
1337
1586
|
}
|
|
1338
1587
|
const res = amendContract({
|
|
1339
1588
|
contractPath,
|
|
1589
|
+
cwd: workCwd,
|
|
1340
1590
|
authorizedBy,
|
|
1341
1591
|
reason,
|
|
1342
1592
|
addAllowedPaths,
|
|
@@ -1346,8 +1596,9 @@ export async function runCli(argv ) {
|
|
|
1346
1596
|
});
|
|
1347
1597
|
if (res.exitCode === 0 && res.entry) {
|
|
1348
1598
|
try {
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1599
|
+
const contractAbs = path.resolve(workCwd, contractPath);
|
|
1600
|
+
const parsed = validateContract(JSON.parse(fs.readFileSync(contractAbs, 'utf8')));
|
|
1601
|
+
appendLedgerEvent(contractAbs, {
|
|
1351
1602
|
kind: 'amend',
|
|
1352
1603
|
task_id: parsed.task_id,
|
|
1353
1604
|
exit_code: 0,
|
|
@@ -1371,7 +1622,10 @@ export async function runCli(argv ) {
|
|
|
1371
1622
|
}
|
|
1372
1623
|
|
|
1373
1624
|
if (cmd === 'doctor') {
|
|
1374
|
-
|
|
1625
|
+
if (subArgs.length > 0) {
|
|
1626
|
+
return failUnknownFlag('doctor', subArgs[0] , jsonOut);
|
|
1627
|
+
}
|
|
1628
|
+
const doc = runDoctor({ cwd: workCwd });
|
|
1375
1629
|
if (jsonOut) {
|
|
1376
1630
|
process.stdout.write(JSON.stringify(doc, null, 2) + '\n');
|
|
1377
1631
|
} else {
|
|
@@ -1394,18 +1648,28 @@ export async function runCli(argv ) {
|
|
|
1394
1648
|
}
|
|
1395
1649
|
|
|
1396
1650
|
if (cmd === 'install-hooks') {
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1651
|
+
let target ;
|
|
1652
|
+
let excludeInGitInfo = false;
|
|
1653
|
+
for (let i = 0; i < subArgs.length; i++) {
|
|
1654
|
+
const a = subArgs[i] ;
|
|
1655
|
+
if (a === '--exclude') {
|
|
1656
|
+
excludeInGitInfo = true;
|
|
1657
|
+
} else if (a === '--harness') {
|
|
1658
|
+
if (!subArgs[i + 1]) return failCliArg('install-hooks', 'Option "--harness" requires a value', jsonOut);
|
|
1659
|
+
target = subArgs[++i] ;
|
|
1660
|
+
} else if (a.startsWith('-')) {
|
|
1661
|
+
return failUnknownFlag('install-hooks', a, jsonOut);
|
|
1662
|
+
} else if (!target) {
|
|
1663
|
+
target = a ;
|
|
1664
|
+
} else {
|
|
1665
|
+
return failCliArg('install-hooks', `Unexpected extra argument "${a}"`, jsonOut);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1404
1668
|
if (!target || !['claude-code', 'codex', 'gemini', 'agy'].includes(target)) {
|
|
1405
1669
|
process.stderr.write('Usage: diffpact install-hooks <claude-code|codex|gemini|agy> [--exclude]\n');
|
|
1406
1670
|
return EXIT_INCOMPLETE;
|
|
1407
1671
|
}
|
|
1408
|
-
const r = installHarnessHooks({ target, contractPath, excludeInGitInfo });
|
|
1672
|
+
const r = installHarnessHooks({ target, cwd: workCwd, contractPath, excludeInGitInfo });
|
|
1409
1673
|
if (jsonOut) process.stdout.write(JSON.stringify(r, null, 2) + '\n');
|
|
1410
1674
|
else process.stdout.write(`${r.created ? 'Created' : 'Merged'} hooks in ${r.configPath}\n`);
|
|
1411
1675
|
return EXIT_PASS;
|
|
@@ -1414,12 +1678,19 @@ export async function runCli(argv ) {
|
|
|
1414
1678
|
if (cmd === 'report') {
|
|
1415
1679
|
let format = jsonOut ? 'json' : 'markdown';
|
|
1416
1680
|
for (let i = 0; i < subArgs.length; i++) {
|
|
1417
|
-
|
|
1681
|
+
const a = subArgs[i] ;
|
|
1682
|
+
if (a === '--format') {
|
|
1683
|
+
if (!subArgs[i + 1]) return failCliArg('report', 'Option "--format" requires a value', jsonOut);
|
|
1418
1684
|
const f = subArgs[++i] ;
|
|
1419
|
-
if (f
|
|
1685
|
+
if (f !== 'markdown' && f !== 'json' && f !== 'sarif') {
|
|
1686
|
+
return failCliArg('report', `Invalid --format "${f}". Expected markdown|json|sarif.`, jsonOut);
|
|
1687
|
+
}
|
|
1688
|
+
format = f;
|
|
1689
|
+
} else {
|
|
1690
|
+
return failUnknownFlag('report', a, jsonOut);
|
|
1420
1691
|
}
|
|
1421
1692
|
}
|
|
1422
|
-
const r = generateTaskReport({ contractPath, format });
|
|
1693
|
+
const r = generateTaskReport({ contractPath, cwd: workCwd, format });
|
|
1423
1694
|
if (r.error) {
|
|
1424
1695
|
process.stderr.write(`diffpact report error: ${r.error}\n`);
|
|
1425
1696
|
return r.exitCode;
|