@ornexus/neocortex 4.60.73 → 4.60.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/release-source.json +1 -1
- package/dist/sbom.cdx.json +1216 -1210
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/package.json +2 -2
- package/packages/client/dist/adapters/adapter-registry.js +1 -108
- package/packages/client/dist/adapters/antigravity-adapter.js +2 -77
- package/packages/client/dist/adapters/claude-code-adapter.js +3 -79
- package/packages/client/dist/adapters/codex-adapter.js +2 -80
- package/packages/client/dist/adapters/cursor-adapter.js +4 -115
- package/packages/client/dist/adapters/gemini-adapter.js +2 -71
- package/packages/client/dist/adapters/grok-adapter.js +2 -42
- package/packages/client/dist/adapters/index.js +1 -22
- package/packages/client/dist/adapters/platform-detector.js +1 -212
- package/packages/client/dist/adapters/target-adapter.js +0 -12
- package/packages/client/dist/adapters/vscode-adapter.js +2 -72
- package/packages/client/dist/agent/refresh-stubs.js +2 -417
- package/packages/client/dist/agent/update-agent-yaml.js +1 -102
- package/packages/client/dist/agent/update-description.js +1 -251
- package/packages/client/dist/cache/crypto-utils.js +1 -78
- package/packages/client/dist/cache/encrypted-cache.js +1 -108
- package/packages/client/dist/cache/in-memory-asset-cache.js +1 -73
- package/packages/client/dist/cache/index.js +1 -13
- package/packages/client/dist/cache/protected-pi-boundary.js +1 -44
- package/packages/client/dist/checkpoint/checkpoint-client-reader.js +2 -127
- package/packages/client/dist/checkpoint/index.js +1 -11
- package/packages/client/dist/checkpoint/shared-checkpoint-types.js +1 -32
- package/packages/client/dist/cli.js +5 -358
- package/packages/client/dist/commands/activate.js +8 -394
- package/packages/client/dist/commands/architecture-answers.js +7 -274
- package/packages/client/dist/commands/architecture-memory-terminal.js +4 -253
- package/packages/client/dist/commands/architecture-non-ui-continuation.js +1 -100
- package/packages/client/dist/commands/architecture-root-binding.js +1 -51
- package/packages/client/dist/commands/cache-status.js +2 -112
- package/packages/client/dist/commands/config.js +1 -88
- package/packages/client/dist/commands/doctor.js +2 -635
- package/packages/client/dist/commands/invoke.js +143 -7200
- package/packages/client/dist/commands/legacy-epic-terminal.js +1 -71
- package/packages/client/dist/commands/legacy-story-branch.js +1 -96
- package/packages/client/dist/commands/legacy-story-pr.js +1 -276
- package/packages/client/dist/commands/mutation-qa-checkpoint.js +5 -285
- package/packages/client/dist/commands/mutation-qa-gate.js +1 -54
- package/packages/client/dist/commands/mutation-qa-git.js +1 -41
- package/packages/client/dist/commands/mutation-qa-policy.js +1 -102
- package/packages/client/dist/commands/mutation-qa-run.js +3 -219
- package/packages/client/dist/commands/mutation-qa-verdict.js +1 -149
- package/packages/client/dist/commands/mutation-qa.js +1 -220
- package/packages/client/dist/commands/native-agent.js +2 -136
- package/packages/client/dist/commands/planning-diagnosis.js +1 -43
- package/packages/client/dist/commands/planning-generation.js +1 -53
- package/packages/client/dist/commands/planning-memory.js +1 -40
- package/packages/client/dist/commands/planning-research.js +1 -42
- package/packages/client/dist/commands/private-session.js +1 -75
- package/packages/client/dist/commands/property-qa.js +1 -139
- package/packages/client/dist/commands/qa-control.js +1 -16
- package/packages/client/dist/commands/qa-scan-browser-launch.js +1 -55
- package/packages/client/dist/commands/qa-scan-browser-route.js +1 -28
- package/packages/client/dist/commands/qa-scan-capture.js +5 -663
- package/packages/client/dist/commands/qa-scan-discovery.js +3 -376
- package/packages/client/dist/commands/qa-scan-review.js +5 -826
- package/packages/client/dist/commands/qa-synthetic-backend-capture.js +1 -266
- package/packages/client/dist/commands/qa-synthetic-backend-review.js +1 -297
- package/packages/client/dist/commands/qa-synthetic-backend.js +2 -340
- package/packages/client/dist/commands/qa-synthetic-broker-port.js +1 -85
- package/packages/client/dist/commands/qa-synthetic-browser.js +1 -39
- package/packages/client/dist/commands/refactor-characterization.js +21 -671
- package/packages/client/dist/commands/refactor-commit.js +13 -399
- package/packages/client/dist/commands/refactor-control.js +3 -142
- package/packages/client/dist/commands/refactor-cpp-assertions.js +3 -93
- package/packages/client/dist/commands/refactor-review.js +5 -283
- package/packages/client/dist/commands/refactor-root.js +7 -588
- package/packages/client/dist/commands/refresh-memory.js +3 -156
- package/packages/client/dist/commands/shared-architecture-non-ui.js +1 -24
- package/packages/client/dist/commands/story-checkpoint.js +1 -171
- package/packages/client/dist/config/profile-directory.js +1 -13
- package/packages/client/dist/config/resolver-selection.js +1 -278
- package/packages/client/dist/config/secure-config.js +12 -281
- package/packages/client/dist/config.js +2 -223
- package/packages/client/dist/constants.js +1 -25
- package/packages/client/dist/context/context-collector.js +2 -222
- package/packages/client/dist/context/context-sanitizer.js +1 -145
- package/packages/client/dist/continuity/autonomous-governance.js +1 -285
- package/packages/client/dist/continuity/continuity-client-state-store.js +1 -1587
- package/packages/client/dist/continuity/invoke-hooks.js +1 -129
- package/packages/client/dist/continuity/migrations/001-initial-schema.js +2 -12
- package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +2 -12
- package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +2 -12
- package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +2 -12
- package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +2 -12
- package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +2 -10
- package/packages/client/dist/continuity/native-agent-store.js +1 -69
- package/packages/client/dist/continuity/native-agent-types.js +1 -90
- package/packages/client/dist/continuity/outbox.js +1 -117
- package/packages/client/dist/continuity/runner-bootstrap-policy.js +1 -172
- package/packages/client/dist/continuity/sqlite-store.js +81 -2612
- package/packages/client/dist/effects/invoke-effect-gateways.js +1 -62
- package/packages/client/dist/errors/error-messages.js +2 -228
- package/packages/client/dist/errors/frontmatter-diagnostics.js +1 -125
- package/packages/client/dist/evidence/collector.js +1 -347
- package/packages/client/dist/evidence/index.js +1 -1
- package/packages/client/dist/evidence/types.js +0 -2
- package/packages/client/dist/fs/atomic-state-replace.js +1 -152
- package/packages/client/dist/generated/command-registry.generated.js +1 -4076
- package/packages/client/dist/generated/public-projections.generated.js +1 -149
- package/packages/client/dist/git/direct-yolo-c01-retry.js +4 -138
- package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -1234
- package/packages/client/dist/git/epic-operational-state.js +2 -672
- package/packages/client/dist/git/git-lifecycle-step-ids.js +1 -14
- package/packages/client/dist/git/git-lifecycle-store.d.ts +23 -0
- package/packages/client/dist/git/git-lifecycle-store.js +10 -1981
- package/packages/client/dist/git/legacy-story-branch-checkpoint.js +9 -259
- package/packages/client/dist/git/legacy-story-branch-setup.js +4 -348
- package/packages/client/dist/git/legacy-story-pr.js +70 -3538
- package/packages/client/dist/git/secure-filesystem-boundary.js +5 -182
- package/packages/client/dist/graph-retrieval/pre-command-hook.js +1 -284
- package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +1 -237
- package/packages/client/dist/i18n/first-run.js +2 -60
- package/packages/client/dist/index.js +1 -47
- package/packages/client/dist/invocation/invoke-input.js +1 -24
- package/packages/client/dist/license/index.js +1 -5
- package/packages/client/dist/license/license-client.js +1 -304
- package/packages/client/dist/machine/fingerprint.js +2 -163
- package/packages/client/dist/machine/index.js +1 -5
- package/packages/client/dist/memory/project-memory-path-scope.js +1 -62
- package/packages/client/dist/memory/project-memory-writer.js +40 -1007
- package/packages/client/dist/memory/shared-project-memory-types.js +2 -253
- package/packages/client/dist/migrations/epic-lifecycle-backfill.js +3 -1060
- package/packages/client/dist/migrations/project-identity-capability.js +1 -50
- package/packages/client/dist/migrations/project-identity.js +7 -493
- package/packages/client/dist/migrations/state-json.js +4 -393
- package/packages/client/dist/policy/architecture-policy.js +2 -184
- package/packages/client/dist/policy/index.js +1 -7
- package/packages/client/dist/policy/shared-policy-types.js +0 -38
- package/packages/client/dist/policy/subagent-approval-policy.js +1 -55
- package/packages/client/dist/private-execution/clean-baseline.js +2 -279
- package/packages/client/dist/private-execution/codex-executor.js +4 -574
- package/packages/client/dist/private-execution/codex-host-runtime.js +1 -137
- package/packages/client/dist/private-execution/codex-lifecycle-guard.js +1 -97
- package/packages/client/dist/private-execution/codex-scoped-permissions.js +1 -128
- package/packages/client/dist/private-execution/delivery.js +13 -410
- package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -294
- package/packages/client/dist/private-execution/frozen-handoff.js +6 -19
- package/packages/client/dist/private-execution/implementation-validation.js +2 -106
- package/packages/client/dist/private-execution/isolated-admission.js +23 -1432
- package/packages/client/dist/private-execution/isolated-session.js +5 -725
- package/packages/client/dist/private-execution/isolated-workspace.js +1 -122
- package/packages/client/dist/private-execution/pact-consumer-runtime.js +3 -409
- package/packages/client/dist/private-execution/pact-test-source.js +1 -258
- package/packages/client/dist/private-execution/pact-toolchain.js +3 -290
- package/packages/client/dist/private-execution/pact-write-set.js +1 -172
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -406
- package/packages/client/dist/private-execution/planning-generation-checkpoint.js +5 -462
- package/packages/client/dist/private-execution/planning-memory-checkpoint.js +3 -139
- package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -325
- package/packages/client/dist/private-execution/private-report-store.js +1 -42
- package/packages/client/dist/private-execution/property-test-candidate.js +1 -103
- package/packages/client/dist/private-execution/property-test-choices.js +3 -147
- package/packages/client/dist/private-execution/property-test-plan.js +7 -271
- package/packages/client/dist/private-execution/property-test-review.js +4 -258
- package/packages/client/dist/private-execution/property-test-runtime.js +9 -372
- package/packages/client/dist/private-execution/property-test-source.js +1 -139
- package/packages/client/dist/private-execution/root-checkpoint.js +1 -80
- package/packages/client/dist/private-execution/root-memory-git-evidence.js +3 -135
- package/packages/client/dist/private-execution/root-memory-recovery.js +1 -93
- package/packages/client/dist/private-execution/root-memory-request.js +1 -29
- package/packages/client/dist/private-execution/root-memory-scope.js +1 -178
- package/packages/client/dist/private-execution/root-memory-writer.js +1 -102
- package/packages/client/dist/private-execution/session-lease.js +1 -63
- package/packages/client/dist/private-execution/shared-private-admission-types.js +1 -50
- package/packages/client/dist/private-execution/shared-project-validation.js +1 -66
- package/packages/client/dist/private-execution/shared-root-memory-types.js +1 -61
- package/packages/client/dist/private-execution/ux-source-validation.js +1 -372
- package/packages/client/dist/private-execution/ux-write-set.js +2 -191
- package/packages/client/dist/registry/registry-reconciliation.js +1 -234
- package/packages/client/dist/resilience/circuit-breaker.js +1 -170
- package/packages/client/dist/resilience/degradation-manager.js +1 -164
- package/packages/client/dist/resilience/freshness-indicator.js +1 -100
- package/packages/client/dist/resilience/index.js +1 -8
- package/packages/client/dist/resilience/recovery-detector.js +1 -74
- package/packages/client/dist/resolvers/asset-resolver.js +0 -13
- package/packages/client/dist/resolvers/local-resolver.js +8 -255
- package/packages/client/dist/resolvers/remote-resolver.js +1 -233
- package/packages/client/dist/runner/binary.js +1 -404
- package/packages/client/dist/runner/cli.js +17 -1571
- package/packages/client/dist/runner/headless/adapters.js +1 -49
- package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -79
- package/packages/client/dist/runner/headless/continuous-story-workspace.js +11 -1628
- package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +1 -69
- package/packages/client/dist/runner/headless/epic-merge-candidate-qa.d.ts +1 -1
- package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +2 -110
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.d.ts +2 -0
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +10 -1236
- package/packages/client/dist/runner/headless/epic-terminal-git-runner.d.ts +18 -2
- package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +2 -318
- package/packages/client/dist/runner/headless/fake-adapter.js +1 -62
- package/packages/client/dist/runner/headless/managed-profile.js +1 -132
- package/packages/client/dist/runner/headless/opencode-adapter.js +2 -145
- package/packages/client/dist/runner/headless/prepared-story-bundle.js +1 -43
- package/packages/client/dist/runner/headless/resolver.js +1 -231
- package/packages/client/dist/runner/headless/run-yolo.js +1 -885
- package/packages/client/dist/runner/headless/run-yoloop.d.ts +1 -0
- package/packages/client/dist/runner/headless/run-yoloop.js +2 -2574
- package/packages/client/dist/runner/headless/types.js +2 -574
- package/packages/client/dist/runner/local-console.js +13 -396
- package/packages/client/dist/runner/portal-sync-worker.js +1 -1487
- package/packages/client/dist/runner/project-identity.js +1 -106
- package/packages/client/dist/runner/scheduler.js +7 -995
- package/packages/client/dist/runner-cli.js +2 -18
- package/packages/client/dist/state/invocation-shape.js +1 -13
- package/packages/client/dist/state/project-state-snapshot.js +1 -1731
- package/packages/client/dist/state/state-json-repair.js +3 -785
- package/packages/client/dist/state/structural-dag-projection.js +1 -118
- package/packages/client/dist/telemetry/index.js +1 -5
- package/packages/client/dist/telemetry/offline-queue.js +1 -131
- package/packages/client/dist/tier/index.js +1 -5
- package/packages/client/dist/tier/tier-aware-client.js +1 -405
- package/packages/client/dist/types/index.js +1 -38
- package/packages/client/dist/version.js +1 -27
- package/packages/client/dist/yolo/change-evidence-collector.js +1 -126
- package/packages/client/dist/yolo/invoke-envelope-capability.js +1 -62
- package/packages/client/dist/yolo/spec-envelope-collector.js +5 -184
- package/packages/client/dist/yoloop/discovery-hook.js +2 -300
- package/packages/client/dist/yoloop/index.js +1 -8
- package/packages/client/dist/yoloop/invoke-hooks.js +12 -669
- package/packages/client/dist/yoloop/shared-discover-epics.js +1 -1007
- package/packages/client/dist/yoloop/shared-yoloop-types.js +1 -33
- package/packages/client/dist/yoloop/target-normalization.js +1 -180
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1920
- package/packages/shared/dist/yolo/change-evidence.js +1 -1
- package/packages/shared/dist/yoloop/epic-terminal-git.js +144 -2
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/skill/SKILL.md +1 -1
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex-root.md +2 -2
- package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex.md +2 -2
- package/targets-stubs/codex/AGENTS.md +1 -1
- package/targets-stubs/cursor/agent.md +2 -2
- package/targets-stubs/gemini-cli/agent.md +2 -2
- package/targets-stubs/opencode/neocortex-root.md +1 -1
- package/targets-stubs/vscode/neocortex.agent.md +2 -2
|
@@ -1,71 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { resolve } from 'node:path';
|
|
3
|
-
import { acceptLegacyEpicFinalization, planLegacyEpicFinalization, readLegacyEpicTerminalAcceptance } from '../git/legacy-story-pr.js';
|
|
4
|
-
export function parseLegacyEpicTerminalArgs(args) {
|
|
5
|
-
const action = args[0];
|
|
6
|
-
if (action !== 'plan' && action !== 'accept' && action !== 'status') {
|
|
7
|
-
throw new Error('legacy-epic-terminal-action-invalid');
|
|
8
|
-
}
|
|
9
|
-
let epicId = '';
|
|
10
|
-
let projectRoot = process.cwd();
|
|
11
|
-
let format = 'plain';
|
|
12
|
-
let authorize = false;
|
|
13
|
-
let epicSeen = false;
|
|
14
|
-
let projectRootSeen = false;
|
|
15
|
-
let formatSeen = false;
|
|
16
|
-
for (let index = 1; index < args.length; index++) {
|
|
17
|
-
const arg = args[index];
|
|
18
|
-
const next = () => args[++index] ?? '';
|
|
19
|
-
if (arg === '--epic' || arg.startsWith('--epic=')) {
|
|
20
|
-
if (epicSeen)
|
|
21
|
-
throw new Error('legacy-epic-terminal-argument-invalid');
|
|
22
|
-
epicSeen = true;
|
|
23
|
-
epicId = arg === '--epic' ? next() : arg.slice('--epic='.length);
|
|
24
|
-
}
|
|
25
|
-
else if (arg === '--project-root' || arg.startsWith('--project-root=')) {
|
|
26
|
-
if (projectRootSeen)
|
|
27
|
-
throw new Error('legacy-epic-terminal-argument-invalid');
|
|
28
|
-
projectRootSeen = true;
|
|
29
|
-
projectRoot = arg === '--project-root' ? next() : arg.slice('--project-root='.length);
|
|
30
|
-
}
|
|
31
|
-
else if (arg === '--format' || arg.startsWith('--format=')) {
|
|
32
|
-
if (formatSeen)
|
|
33
|
-
throw new Error('legacy-epic-terminal-argument-invalid');
|
|
34
|
-
formatSeen = true;
|
|
35
|
-
const value = arg === '--format' ? next() : arg.slice('--format='.length);
|
|
36
|
-
if (value !== 'json' && value !== 'plain')
|
|
37
|
-
throw new Error('legacy-epic-terminal-format-invalid');
|
|
38
|
-
format = value;
|
|
39
|
-
}
|
|
40
|
-
else if (arg === '--authorize-root-qa' && !authorize)
|
|
41
|
-
authorize = true;
|
|
42
|
-
else
|
|
43
|
-
throw new Error('legacy-epic-terminal-argument-invalid');
|
|
44
|
-
}
|
|
45
|
-
if (!/^P[0-9]+$/.test(epicId) || !projectRoot) {
|
|
46
|
-
throw new Error('legacy-epic-terminal-target-invalid');
|
|
47
|
-
}
|
|
48
|
-
if ((action === 'accept') !== authorize)
|
|
49
|
-
throw new Error('legacy-epic-terminal-authorization-invalid');
|
|
50
|
-
return { action, epicId, projectRoot: resolve(projectRoot), format, authorize };
|
|
51
|
-
}
|
|
52
|
-
export async function legacyEpicTerminalCliHandler(args) {
|
|
53
|
-
let options;
|
|
54
|
-
try {
|
|
55
|
-
options = parseLegacyEpicTerminalArgs(args);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
console.error(error instanceof Error ? error.message : 'legacy-epic-terminal-arguments-invalid');
|
|
59
|
-
return 1;
|
|
60
|
-
}
|
|
61
|
-
const result = options.action === 'plan' ? await planLegacyEpicFinalization(options)
|
|
62
|
-
: options.action === 'status' ? await readLegacyEpicTerminalAcceptance(options)
|
|
63
|
-
: await acceptLegacyEpicFinalization(options);
|
|
64
|
-
if (options.format === 'json')
|
|
65
|
-
console.log(JSON.stringify({ action: options.action, ...result }));
|
|
66
|
-
else if (result.ok)
|
|
67
|
-
console.log(`legacy-epic-terminal ${options.action}: physical-stories=${result.value.storyCount} quota-release=unauthorized epic=${result.value.epicId}`);
|
|
68
|
-
else
|
|
69
|
-
console.error(`legacy-epic-terminal: ${result.reasonCode}`);
|
|
70
|
-
return result.ok ? 0 : 1;
|
|
71
|
-
}
|
|
1
|
+
import{resolve as g}from"node:path";import{acceptLegacyEpicFinalization as u,planLegacyEpicFinalization as h,readLegacyEpicTerminalAcceptance as y}from"../git/legacy-story-pr.js";function w(i){const e=i[0];if(e!=="plan"&&e!=="accept"&&e!=="status")throw new Error("legacy-epic-terminal-action-invalid");let r="",a=process.cwd(),s="plain",o=!1,p=!1,f=!1,m=!1;for(let n=1;n<i.length;n++){const t=i[n],c=()=>i[++n]??"";if(t==="--epic"||t.startsWith("--epic=")){if(p)throw new Error("legacy-epic-terminal-argument-invalid");p=!0,r=t==="--epic"?c():t.slice(7)}else if(t==="--project-root"||t.startsWith("--project-root=")){if(f)throw new Error("legacy-epic-terminal-argument-invalid");f=!0,a=t==="--project-root"?c():t.slice(15)}else if(t==="--format"||t.startsWith("--format=")){if(m)throw new Error("legacy-epic-terminal-argument-invalid");m=!0;const l=t==="--format"?c():t.slice(9);if(l!=="json"&&l!=="plain")throw new Error("legacy-epic-terminal-format-invalid");s=l}else if(t==="--authorize-root-qa"&&!o)o=!0;else throw new Error("legacy-epic-terminal-argument-invalid")}if(!/^P[0-9]+$/.test(r)||!a)throw new Error("legacy-epic-terminal-target-invalid");if(e==="accept"!==o)throw new Error("legacy-epic-terminal-authorization-invalid");return{action:e,epicId:r,projectRoot:g(a),format:s,authorize:o}}async function v(i){let e;try{e=w(i)}catch(a){return console.error(a instanceof Error?a.message:"legacy-epic-terminal-arguments-invalid"),1}const r=e.action==="plan"?await h(e):e.action==="status"?await y(e):await u(e);return e.format==="json"?console.log(JSON.stringify({action:e.action,...r})):r.ok?console.log(`legacy-epic-terminal ${e.action}: physical-stories=${r.value.storyCount} quota-release=unauthorized epic=${r.value.epicId}`):console.error(`legacy-epic-terminal: ${r.reasonCode}`),r.ok?0:1}export{v as legacyEpicTerminalCliHandler,w as parseLegacyEpicTerminalArgs};
|
|
@@ -1,96 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { resolve } from 'node:path';
|
|
3
|
-
import { planLegacyStoryBranchSetup, prepareLegacyStoryBranchSetup, } from '../git/legacy-story-branch-setup.js';
|
|
4
|
-
import { acceptLegacyStoryBranchC01 } from '../git/legacy-story-branch-checkpoint.js';
|
|
5
|
-
export function parseLegacyStoryBranchArgs(args) {
|
|
6
|
-
const action = args[0];
|
|
7
|
-
if (action !== 'setup' && action !== 'accept')
|
|
8
|
-
throw new Error('legacy-branch-action-invalid');
|
|
9
|
-
let storyId = '';
|
|
10
|
-
let projectRoot = process.cwd();
|
|
11
|
-
let dryRun = false;
|
|
12
|
-
let issueNumber;
|
|
13
|
-
let format = 'plain';
|
|
14
|
-
const issue = (value) => {
|
|
15
|
-
if (!/^[1-9][0-9]*$/.test(value))
|
|
16
|
-
throw new Error('legacy-branch-issue-number-invalid');
|
|
17
|
-
const number = Number(value);
|
|
18
|
-
if (!Number.isSafeInteger(number))
|
|
19
|
-
throw new Error('legacy-branch-issue-number-invalid');
|
|
20
|
-
return number;
|
|
21
|
-
};
|
|
22
|
-
for (let index = 1; index < args.length; index++) {
|
|
23
|
-
const arg = args[index];
|
|
24
|
-
const next = () => args[++index] ?? '';
|
|
25
|
-
if (arg === '--story')
|
|
26
|
-
storyId = next();
|
|
27
|
-
else if (arg.startsWith('--story='))
|
|
28
|
-
storyId = arg.slice('--story='.length);
|
|
29
|
-
else if (arg === '--project-root')
|
|
30
|
-
projectRoot = next();
|
|
31
|
-
else if (arg.startsWith('--project-root='))
|
|
32
|
-
projectRoot = arg.slice('--project-root='.length);
|
|
33
|
-
else if (arg === '--dry-run')
|
|
34
|
-
dryRun = true;
|
|
35
|
-
else if (arg === '--issue-number')
|
|
36
|
-
issueNumber = issue(next());
|
|
37
|
-
else if (arg.startsWith('--issue-number='))
|
|
38
|
-
issueNumber = issue(arg.slice('--issue-number='.length));
|
|
39
|
-
else if (arg === '--format') {
|
|
40
|
-
const value = next();
|
|
41
|
-
if (value !== 'json' && value !== 'plain')
|
|
42
|
-
throw new Error('legacy-branch-format-invalid');
|
|
43
|
-
format = value;
|
|
44
|
-
}
|
|
45
|
-
else if (arg.startsWith('--format=')) {
|
|
46
|
-
const value = arg.slice('--format='.length);
|
|
47
|
-
if (value !== 'json' && value !== 'plain')
|
|
48
|
-
throw new Error('legacy-branch-format-invalid');
|
|
49
|
-
format = value;
|
|
50
|
-
}
|
|
51
|
-
else
|
|
52
|
-
throw new Error('legacy-branch-argument-invalid');
|
|
53
|
-
}
|
|
54
|
-
if (!storyId)
|
|
55
|
-
throw new Error('legacy-branch-story-required');
|
|
56
|
-
if (!projectRoot)
|
|
57
|
-
throw new Error('legacy-branch-project-root-required');
|
|
58
|
-
if (action === 'accept' && (dryRun || !Number.isSafeInteger(issueNumber) || issueNumber <= 0)) {
|
|
59
|
-
throw new Error('legacy-branch-accept-options-invalid');
|
|
60
|
-
}
|
|
61
|
-
if (action === 'setup' && issueNumber !== undefined)
|
|
62
|
-
throw new Error('legacy-branch-setup-options-invalid');
|
|
63
|
-
return { action, storyId, projectRoot: resolve(projectRoot), dryRun, format,
|
|
64
|
-
...(issueNumber !== undefined ? { issueNumber } : {}) };
|
|
65
|
-
}
|
|
66
|
-
export async function legacyStoryBranchCliHandler(args) {
|
|
67
|
-
let options;
|
|
68
|
-
try {
|
|
69
|
-
options = parseLegacyStoryBranchArgs(args);
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
console.error(error instanceof Error ? error.message : 'legacy-branch-arguments-invalid');
|
|
73
|
-
return 1;
|
|
74
|
-
}
|
|
75
|
-
const result = options.action === 'accept'
|
|
76
|
-
? await acceptLegacyStoryBranchC01({ ...options, issueNumber: options.issueNumber })
|
|
77
|
-
: options.dryRun ? planLegacyStoryBranchSetup(options)
|
|
78
|
-
: await prepareLegacyStoryBranchSetup(options);
|
|
79
|
-
if (options.format === 'json') {
|
|
80
|
-
console.log(JSON.stringify({ action: options.action === 'accept' ? 'accept'
|
|
81
|
-
: options.dryRun ? 'plan' : 'setup', ...result }));
|
|
82
|
-
}
|
|
83
|
-
else if (result.ok) {
|
|
84
|
-
console.log(`legacy-story-branch ${options.action === 'accept' ? 'accept'
|
|
85
|
-
: options.dryRun ? 'plan' : 'setup'}: ok`);
|
|
86
|
-
console.log(`branch=${result.value.branch}`);
|
|
87
|
-
if ('worktreePath' in result.value)
|
|
88
|
-
console.log(`worktree=${result.value.worktreePath}`);
|
|
89
|
-
if ('checkpointAccepted' in result.value) {
|
|
90
|
-
console.log(`checkpoint=${result.value.checkpointAccepted ? 'accepted' : 'unaccepted'}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else
|
|
94
|
-
console.error(`legacy-story-branch: ${result.reasonCode}`);
|
|
95
|
-
return result.ok ? 0 : 1;
|
|
96
|
-
}
|
|
1
|
+
import{resolve as h}from"node:path";import{planLegacyStoryBranchSetup as f,prepareLegacyStoryBranchSetup as y}from"../git/legacy-story-branch-setup.js";import{acceptLegacyStoryBranchC01 as g}from"../git/legacy-story-branch-checkpoint.js";function d(i){const e=i[0];if(e!=="setup"&&e!=="accept")throw new Error("legacy-branch-action-invalid");let t="",o=process.cwd(),l=!1,n,u="plain";const p=c=>{if(!/^[1-9][0-9]*$/.test(c))throw new Error("legacy-branch-issue-number-invalid");const r=Number(c);if(!Number.isSafeInteger(r))throw new Error("legacy-branch-issue-number-invalid");return r};for(let c=1;c<i.length;c++){const r=i[c],s=()=>i[++c]??"";if(r==="--story")t=s();else if(r.startsWith("--story="))t=r.slice(8);else if(r==="--project-root")o=s();else if(r.startsWith("--project-root="))o=r.slice(15);else if(r==="--dry-run")l=!0;else if(r==="--issue-number")n=p(s());else if(r.startsWith("--issue-number="))n=p(r.slice(15));else if(r==="--format"){const a=s();if(a!=="json"&&a!=="plain")throw new Error("legacy-branch-format-invalid");u=a}else if(r.startsWith("--format=")){const a=r.slice(9);if(a!=="json"&&a!=="plain")throw new Error("legacy-branch-format-invalid");u=a}else throw new Error("legacy-branch-argument-invalid")}if(!t)throw new Error("legacy-branch-story-required");if(!o)throw new Error("legacy-branch-project-root-required");if(e==="accept"&&(l||!Number.isSafeInteger(n)||n<=0))throw new Error("legacy-branch-accept-options-invalid");if(e==="setup"&&n!==void 0)throw new Error("legacy-branch-setup-options-invalid");return{action:e,storyId:t,projectRoot:h(o),dryRun:l,format:u,...n!==void 0?{issueNumber:n}:{}}}async function v(i){let e;try{e=d(i)}catch(o){return console.error(o instanceof Error?o.message:"legacy-branch-arguments-invalid"),1}const t=e.action==="accept"?await g({...e,issueNumber:e.issueNumber}):e.dryRun?f(e):await y(e);return e.format==="json"?console.log(JSON.stringify({action:e.action==="accept"?"accept":e.dryRun?"plan":"setup",...t})):t.ok?(console.log(`legacy-story-branch ${e.action==="accept"?"accept":e.dryRun?"plan":"setup"}: ok`),console.log(`branch=${t.value.branch}`),"worktreePath"in t.value&&console.log(`worktree=${t.value.worktreePath}`),"checkpointAccepted"in t.value&&console.log(`checkpoint=${t.value.checkpointAccepted?"accepted":"unaccepted"}`)):console.error(`legacy-story-branch: ${t.reasonCode}`),t.ok?0:1}export{v as legacyStoryBranchCliHandler,d as parseLegacyStoryBranchArgs};
|
|
@@ -1,276 +1 @@
|
|
|
1
|
-
/** Root-only CLI for legacy C09 sync, C10 PR, C11 review and C12 merge boundaries. */
|
|
2
|
-
import { resolve } from 'node:path';
|
|
3
|
-
import { acceptLegacyStoryPrC10, acceptLegacyStoryPrPostMergeC12, acceptLegacyStoryPrReviewC11, acceptLegacyStoryCommitC08, acceptLegacyStorySyncC09, createLegacyStoryPr, mergeLegacyStoryPrC12, planLegacyStoryCommitC08, planLegacyStoryPr, planLegacyStoryPrMergeC12, planLegacyStoryPrMergeDecisionC12, planLegacyStoryPrReview, planLegacyStoryPrPostMergeC12, planLegacyStoryPrRemoteDebtBeforePrepareC12, observeLegacyStoryPrReviewC11, planLegacyStorySyncC09, prepareLegacyStoryPrMergeC12, recordLegacyStoryPrRemoteDebtC12 } from '../git/legacy-story-pr.js';
|
|
4
|
-
export function parseLegacyStoryPrArgs(args) {
|
|
5
|
-
const action = args[0];
|
|
6
|
-
if (action !== 'commit-plan' && action !== 'commit-accept' && action !== 'sync-plan' && action !== 'sync-accept' && action !== 'plan' && action !== 'create' && action !== 'accept'
|
|
7
|
-
&& action !== 'review-plan' && action !== 'review-observe' && action !== 'review-accept' && action !== 'merge-plan'
|
|
8
|
-
&& action !== 'merge-prepare' && action !== 'merge-debt-plan' && action !== 'merge-decision' && action !== 'merge-debt-record'
|
|
9
|
-
&& action !== 'merge-execute' && action !== 'merge-reconcile'
|
|
10
|
-
&& action !== 'post-merge-plan' && action !== 'post-merge-accept') {
|
|
11
|
-
throw new Error('legacy-story-pr-action-invalid');
|
|
12
|
-
}
|
|
13
|
-
let storyId = '';
|
|
14
|
-
let projectRoot = process.cwd();
|
|
15
|
-
let bodyFile = '';
|
|
16
|
-
let reportFile = '';
|
|
17
|
-
let prNumber = 0;
|
|
18
|
-
let authorize = false;
|
|
19
|
-
let authorizeReview = false;
|
|
20
|
-
let authorizePrUpdate = false;
|
|
21
|
-
let recordRemoteDebt = false;
|
|
22
|
-
let authorizeMerge = false;
|
|
23
|
-
let authorizePostMerge = false;
|
|
24
|
-
let authorizeSync = false;
|
|
25
|
-
let authorizeCommit = false;
|
|
26
|
-
let format = 'plain';
|
|
27
|
-
for (let index = 1; index < args.length; index++) {
|
|
28
|
-
const arg = args[index];
|
|
29
|
-
const next = () => args[++index] ?? '';
|
|
30
|
-
if (arg === '--story')
|
|
31
|
-
storyId = next();
|
|
32
|
-
else if (arg.startsWith('--story='))
|
|
33
|
-
storyId = arg.slice('--story='.length);
|
|
34
|
-
else if (arg === '--project-root')
|
|
35
|
-
projectRoot = next();
|
|
36
|
-
else if (arg.startsWith('--project-root='))
|
|
37
|
-
projectRoot = arg.slice('--project-root='.length);
|
|
38
|
-
else if (arg === '--body-file')
|
|
39
|
-
bodyFile = next();
|
|
40
|
-
else if (arg.startsWith('--body-file='))
|
|
41
|
-
bodyFile = arg.slice('--body-file='.length);
|
|
42
|
-
else if (arg === '--report-file')
|
|
43
|
-
reportFile = next();
|
|
44
|
-
else if (arg.startsWith('--report-file='))
|
|
45
|
-
reportFile = arg.slice('--report-file='.length);
|
|
46
|
-
else if (arg === '--pr-number' || arg.startsWith('--pr-number=')) {
|
|
47
|
-
const value = arg === '--pr-number' ? next() : arg.slice('--pr-number='.length);
|
|
48
|
-
if (!/^[1-9][0-9]*$/.test(value))
|
|
49
|
-
throw new Error('legacy-story-pr-number-invalid');
|
|
50
|
-
prNumber = Number(value);
|
|
51
|
-
if (!Number.isSafeInteger(prNumber))
|
|
52
|
-
throw new Error('legacy-story-pr-number-invalid');
|
|
53
|
-
}
|
|
54
|
-
else if (arg === '--authorize-pr-create')
|
|
55
|
-
authorize = true;
|
|
56
|
-
else if (arg === '--authorize-review')
|
|
57
|
-
authorizeReview = true;
|
|
58
|
-
else if (arg === '--authorize-pr-update')
|
|
59
|
-
authorizePrUpdate = true;
|
|
60
|
-
else if (arg === '--record-remote-debt')
|
|
61
|
-
recordRemoteDebt = true;
|
|
62
|
-
else if (arg === '--authorize-merge')
|
|
63
|
-
authorizeMerge = true;
|
|
64
|
-
else if (arg === '--authorize-post-merge')
|
|
65
|
-
authorizePostMerge = true;
|
|
66
|
-
else if (arg === '--authorize-sync')
|
|
67
|
-
authorizeSync = true;
|
|
68
|
-
else if (arg === '--authorize-commit')
|
|
69
|
-
authorizeCommit = true;
|
|
70
|
-
else if (arg === '--format' || arg.startsWith('--format=')) {
|
|
71
|
-
const value = arg === '--format' ? next() : arg.slice('--format='.length);
|
|
72
|
-
if (value !== 'json' && value !== 'plain')
|
|
73
|
-
throw new Error('legacy-story-pr-format-invalid');
|
|
74
|
-
format = value;
|
|
75
|
-
}
|
|
76
|
-
else
|
|
77
|
-
throw new Error('legacy-story-pr-argument-invalid');
|
|
78
|
-
}
|
|
79
|
-
if (!storyId || !projectRoot)
|
|
80
|
-
throw new Error('legacy-story-pr-target-required');
|
|
81
|
-
if (action !== 'post-merge-accept' && authorizePostMerge)
|
|
82
|
-
throw new Error('legacy-story-pr-argument-invalid');
|
|
83
|
-
if (action !== 'sync-accept' && authorizeSync)
|
|
84
|
-
throw new Error('legacy-story-pr-argument-invalid');
|
|
85
|
-
if (action !== 'commit-accept' && authorizeCommit)
|
|
86
|
-
throw new Error('legacy-story-pr-argument-invalid');
|
|
87
|
-
if (action !== 'merge-prepare' && recordRemoteDebt)
|
|
88
|
-
throw new Error('legacy-story-pr-argument-invalid');
|
|
89
|
-
if (action === 'commit-plan' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || prNumber))
|
|
90
|
-
throw new Error('legacy-story-pr-commit-plan-options-invalid');
|
|
91
|
-
if (action === 'commit-accept' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || !authorizeCommit || bodyFile || reportFile || prNumber))
|
|
92
|
-
throw new Error('legacy-story-pr-commit-accept-options-invalid');
|
|
93
|
-
if (action === 'sync-plan' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || prNumber))
|
|
94
|
-
throw new Error('legacy-story-pr-sync-plan-options-invalid');
|
|
95
|
-
if (action === 'sync-accept' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || !authorizeSync || bodyFile || reportFile || prNumber))
|
|
96
|
-
throw new Error('legacy-story-pr-sync-accept-options-invalid');
|
|
97
|
-
if (action === 'plan' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || prNumber))
|
|
98
|
-
throw new Error('legacy-story-pr-plan-options-invalid');
|
|
99
|
-
if (action === 'create' && (!authorize || authorizeReview || authorizePrUpdate || authorizeMerge || !bodyFile || reportFile || prNumber))
|
|
100
|
-
throw new Error('legacy-story-pr-create-options-invalid');
|
|
101
|
-
if (action === 'accept' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || !prNumber))
|
|
102
|
-
throw new Error('legacy-story-pr-accept-options-invalid');
|
|
103
|
-
if (action === 'review-plan' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || !prNumber))
|
|
104
|
-
throw new Error('legacy-story-pr-review-plan-options-invalid');
|
|
105
|
-
if (action === 'review-observe' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || !prNumber))
|
|
106
|
-
throw new Error('legacy-story-pr-review-observe-options-invalid');
|
|
107
|
-
if (action === 'review-accept' && (authorize || !authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || !reportFile || !prNumber))
|
|
108
|
-
throw new Error('legacy-story-pr-review-accept-options-invalid');
|
|
109
|
-
if (action === 'merge-plan' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || !prNumber))
|
|
110
|
-
throw new Error('legacy-story-pr-merge-plan-options-invalid');
|
|
111
|
-
if (action === 'merge-prepare' && (authorize || authorizeReview || !authorizePrUpdate || authorizeMerge || bodyFile || reportFile || !prNumber))
|
|
112
|
-
throw new Error('legacy-story-pr-merge-prepare-options-invalid');
|
|
113
|
-
if (action === 'merge-debt-plan' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || !prNumber))
|
|
114
|
-
throw new Error('legacy-story-pr-merge-debt-plan-options-invalid');
|
|
115
|
-
if (action === 'merge-decision' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || !prNumber))
|
|
116
|
-
throw new Error('legacy-story-pr-merge-decision-options-invalid');
|
|
117
|
-
if (action === 'merge-debt-record' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || !prNumber))
|
|
118
|
-
throw new Error('legacy-story-pr-merge-debt-record-options-invalid');
|
|
119
|
-
if (action === 'merge-execute' && (authorize || authorizeReview || authorizePrUpdate || !authorizeMerge || bodyFile || reportFile || !prNumber))
|
|
120
|
-
throw new Error('legacy-story-pr-merge-execute-options-invalid');
|
|
121
|
-
if (action === 'merge-reconcile' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || !prNumber))
|
|
122
|
-
throw new Error('legacy-story-pr-merge-reconcile-options-invalid');
|
|
123
|
-
if (action === 'post-merge-plan' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || bodyFile || reportFile || !prNumber))
|
|
124
|
-
throw new Error('legacy-story-pr-post-merge-plan-options-invalid');
|
|
125
|
-
if (action === 'post-merge-accept' && (authorize || authorizeReview || authorizePrUpdate || authorizeMerge || !authorizePostMerge || bodyFile || reportFile || !prNumber))
|
|
126
|
-
throw new Error('legacy-story-pr-post-merge-accept-options-invalid');
|
|
127
|
-
return { action, storyId, projectRoot: resolve(projectRoot), authorize, authorizeReview, authorizePrUpdate, recordRemoteDebt, authorizeMerge, authorizePostMerge, authorizeSync, authorizeCommit, format,
|
|
128
|
-
...(bodyFile ? { bodyFile: resolve(bodyFile) } : {}),
|
|
129
|
-
...(reportFile ? { reportFile: resolve(reportFile) } : {}),
|
|
130
|
-
...(prNumber ? { prNumber } : {}) };
|
|
131
|
-
}
|
|
132
|
-
export async function legacyStoryPrCliHandler(args) {
|
|
133
|
-
let options;
|
|
134
|
-
try {
|
|
135
|
-
options = parseLegacyStoryPrArgs(args);
|
|
136
|
-
}
|
|
137
|
-
catch (error) {
|
|
138
|
-
console.error(error instanceof Error ? error.message : 'legacy-story-pr-arguments-invalid');
|
|
139
|
-
return 1;
|
|
140
|
-
}
|
|
141
|
-
if (options.action === 'commit-plan') {
|
|
142
|
-
const result = planLegacyStoryCommitC08(options);
|
|
143
|
-
if (options.format === 'json')
|
|
144
|
-
console.log(JSON.stringify({ action: options.action, ...result }));
|
|
145
|
-
else if (result.ok)
|
|
146
|
-
console.log(`legacy-story-pr commit-plan: staged-basis-confirmed checkpoint=unaccepted story=${result.value.storyId} paths=${result.value.changedPaths.length}`);
|
|
147
|
-
else
|
|
148
|
-
console.error(`legacy-story-pr: ${result.reasonCode}`);
|
|
149
|
-
return result.ok ? 0 : 1;
|
|
150
|
-
}
|
|
151
|
-
if (options.action === 'commit-accept') {
|
|
152
|
-
const result = await acceptLegacyStoryCommitC08({ ...options, authorize: options.authorizeCommit });
|
|
153
|
-
if (options.format === 'json')
|
|
154
|
-
console.log(JSON.stringify({ action: options.action, ...result }));
|
|
155
|
-
else if (result.ok)
|
|
156
|
-
console.log(`legacy-story-pr commit-accept: checkpoint=accepted story=${result.value.storyId} head=${result.value.checkpointHeadSha}`);
|
|
157
|
-
else
|
|
158
|
-
console.error(`legacy-story-pr: ${result.reasonCode}`);
|
|
159
|
-
return result.ok ? 0 : 1;
|
|
160
|
-
}
|
|
161
|
-
if (options.action === 'sync-plan') {
|
|
162
|
-
const result = planLegacyStorySyncC09(options);
|
|
163
|
-
if (options.format === 'json')
|
|
164
|
-
console.log(JSON.stringify({ action: options.action, ...result }));
|
|
165
|
-
else if (result.ok)
|
|
166
|
-
console.log(`legacy-story-pr sync-plan: physical-basis-confirmed checkpoint=unaccepted story=${result.value.storyId} base=${result.value.baseSha}`);
|
|
167
|
-
else
|
|
168
|
-
console.error(`legacy-story-pr: ${result.reasonCode}`);
|
|
169
|
-
return result.ok ? 0 : 1;
|
|
170
|
-
}
|
|
171
|
-
if (options.action === 'sync-accept') {
|
|
172
|
-
const result = await acceptLegacyStorySyncC09({ ...options, authorize: options.authorizeSync });
|
|
173
|
-
if (options.format === 'json')
|
|
174
|
-
console.log(JSON.stringify({ action: options.action, ...result }));
|
|
175
|
-
else if (result.ok)
|
|
176
|
-
console.log(`legacy-story-pr sync-accept: checkpoint=accepted story=${result.value.storyId} head=${result.value.checkpointHeadSha}`);
|
|
177
|
-
else
|
|
178
|
-
console.error(`legacy-story-pr: ${result.reasonCode}`);
|
|
179
|
-
return result.ok ? 0 : 1;
|
|
180
|
-
}
|
|
181
|
-
if (options.action === 'merge-execute') {
|
|
182
|
-
const decision = await planLegacyStoryPrMergeDecisionC12({ ...options, prNumber: options.prNumber });
|
|
183
|
-
if (!decision.ok || !decision.value.canMerge) {
|
|
184
|
-
const reason = decision.ok ? 'legacy-story-pr-merge-remote-debt-required' : decision.reasonCode;
|
|
185
|
-
if (options.format === 'json')
|
|
186
|
-
console.log(JSON.stringify({ action: options.action, ok: false, reasonCode: reason }));
|
|
187
|
-
else
|
|
188
|
-
console.error(`legacy-story-pr: ${reason}`);
|
|
189
|
-
return 1;
|
|
190
|
-
}
|
|
191
|
-
const result = await mergeLegacyStoryPrC12({ ...options, prNumber: options.prNumber,
|
|
192
|
-
authorize: options.authorizeMerge, rootDecision: decision.value });
|
|
193
|
-
if (options.format === 'json')
|
|
194
|
-
console.log(JSON.stringify({ action: options.action, ...result }));
|
|
195
|
-
else if (result.ok)
|
|
196
|
-
console.log(`legacy-story-pr merge-execute: physical-merge-confirmed checkpoint=unaccepted story=${result.value.storyId} pr=${result.value.prNumber}`);
|
|
197
|
-
else
|
|
198
|
-
console.error(`legacy-story-pr: ${result.reasonCode}`);
|
|
199
|
-
return result.ok ? 0 : 1;
|
|
200
|
-
}
|
|
201
|
-
if (options.action === 'merge-reconcile') {
|
|
202
|
-
// No root decision: the core may only read back a previously journaled
|
|
203
|
-
// attempt. It cannot issue a new provider merge from this action.
|
|
204
|
-
const result = await mergeLegacyStoryPrC12({ ...options, prNumber: options.prNumber, authorize: true });
|
|
205
|
-
if (options.format === 'json')
|
|
206
|
-
console.log(JSON.stringify({ action: options.action, ...result }));
|
|
207
|
-
else if (result.ok)
|
|
208
|
-
console.log(`legacy-story-pr merge-reconcile: physical-merge-confirmed checkpoint=unaccepted story=${result.value.storyId} pr=${result.value.prNumber}`);
|
|
209
|
-
else
|
|
210
|
-
console.error(`legacy-story-pr: ${result.reasonCode}`);
|
|
211
|
-
return result.ok ? 0 : 1;
|
|
212
|
-
}
|
|
213
|
-
if (options.action === 'post-merge-plan') {
|
|
214
|
-
const result = await planLegacyStoryPrPostMergeC12({ ...options, prNumber: options.prNumber });
|
|
215
|
-
if (options.format === 'json')
|
|
216
|
-
console.log(JSON.stringify({ action: options.action, ...result }));
|
|
217
|
-
else if (result.ok)
|
|
218
|
-
console.log(`legacy-story-pr post-merge-plan: physical-basis-confirmed checkpoint=unaccepted story=${result.value.storyId} pr=${result.value.prNumber}`);
|
|
219
|
-
else
|
|
220
|
-
console.error(`legacy-story-pr: ${result.reasonCode}`);
|
|
221
|
-
return result.ok ? 0 : 1;
|
|
222
|
-
}
|
|
223
|
-
if (options.action === 'post-merge-accept') {
|
|
224
|
-
const result = await acceptLegacyStoryPrPostMergeC12({ ...options, prNumber: options.prNumber,
|
|
225
|
-
authorize: options.authorizePostMerge });
|
|
226
|
-
if (options.format === 'json')
|
|
227
|
-
console.log(JSON.stringify({ action: options.action, ...result }));
|
|
228
|
-
else if (result.ok)
|
|
229
|
-
console.log(`legacy-story-pr post-merge-accept: checkpoint=accepted story=${result.value.storyId} pr=${result.value.prNumber} issue=${result.value.issueNumber}`);
|
|
230
|
-
else
|
|
231
|
-
console.error(`legacy-story-pr: ${result.reasonCode}`);
|
|
232
|
-
return result.ok ? 0 : 1;
|
|
233
|
-
}
|
|
234
|
-
if (options.action === 'review-observe') {
|
|
235
|
-
const result = await observeLegacyStoryPrReviewC11({ ...options, prNumber: options.prNumber });
|
|
236
|
-
if (options.format === 'json')
|
|
237
|
-
console.log(JSON.stringify({ action: options.action, ...result }));
|
|
238
|
-
else if (result.ok)
|
|
239
|
-
console.log(`legacy-story-pr review-observe: categorical-reasons=${result.value.observation.reasonCodes.join(',') || 'none'} checkpoint=unaccepted merge=unauthorized`);
|
|
240
|
-
else
|
|
241
|
-
console.error(`legacy-story-pr: ${result.reasonCode}`);
|
|
242
|
-
return result.ok ? 0 : 1;
|
|
243
|
-
}
|
|
244
|
-
const result = options.action === 'plan' ? planLegacyStoryPr(options)
|
|
245
|
-
: options.action === 'create' ? await createLegacyStoryPr({ ...options, bodyFile: options.bodyFile })
|
|
246
|
-
: options.action === 'accept' ? await acceptLegacyStoryPrC10({ ...options, prNumber: options.prNumber })
|
|
247
|
-
: options.action === 'review-plan' ? await planLegacyStoryPrReview({ ...options, prNumber: options.prNumber })
|
|
248
|
-
: options.action === 'review-accept' ? await acceptLegacyStoryPrReviewC11({ ...options, prNumber: options.prNumber,
|
|
249
|
-
reportFile: options.reportFile, authorize: options.authorizeReview })
|
|
250
|
-
: options.action === 'merge-plan' ? await planLegacyStoryPrMergeC12({ ...options, prNumber: options.prNumber })
|
|
251
|
-
: options.action === 'merge-debt-plan' ? await planLegacyStoryPrRemoteDebtBeforePrepareC12({ ...options, prNumber: options.prNumber })
|
|
252
|
-
: options.action === 'merge-decision' ? await planLegacyStoryPrMergeDecisionC12({ ...options, prNumber: options.prNumber })
|
|
253
|
-
: options.action === 'merge-debt-record' ? await recordLegacyStoryPrRemoteDebtC12({ ...options, prNumber: options.prNumber })
|
|
254
|
-
: await prepareLegacyStoryPrMergeC12({ ...options, prNumber: options.prNumber,
|
|
255
|
-
authorize: options.authorizePrUpdate });
|
|
256
|
-
if (options.format === 'json')
|
|
257
|
-
console.log(JSON.stringify({ action: options.action, ...result }));
|
|
258
|
-
else if (result.ok) {
|
|
259
|
-
const debtRequired = 'canMerge' in result.value && result.value.canMerge === false;
|
|
260
|
-
const recordedDebtDecision = 'registrySha256' in result.value;
|
|
261
|
-
console.log(`legacy-story-pr ${options.action}: ${options.action === 'merge-debt-record' ? 'journaled-not-registry' : debtRequired ? 'debt-required' : recordedDebtDecision ? 'recorded-debt-merge-attempt-authorized' : 'ok'}`);
|
|
262
|
-
console.log(`story=${result.value.storyId}${'branch' in result.value ? ` branch=${result.value.branch}` : ''}`);
|
|
263
|
-
if (debtRequired && 'reasonCodes' in result.value)
|
|
264
|
-
console.log(`reasons=${result.value.reasonCodes.join(',')}`);
|
|
265
|
-
if (recordedDebtDecision && 'nonBlockingChecks' in result.value) {
|
|
266
|
-
console.log(`nonBlockingReasons=${result.value.nonBlockingChecks.map((check) => check.checkName).join(',')}`);
|
|
267
|
-
}
|
|
268
|
-
if ('registryRecorded' in result.value)
|
|
269
|
-
console.log(`registryRecorded=${result.value.registryRecorded}`);
|
|
270
|
-
if ('number' in result.value)
|
|
271
|
-
console.log(`pr=${result.value.number} checkpoint=${result.value.checkpointAccepted ? 'accepted' : 'unaccepted'}`);
|
|
272
|
-
}
|
|
273
|
-
else
|
|
274
|
-
console.error(`legacy-story-pr: ${result.reasonCode}`);
|
|
275
|
-
return result.ok ? 0 : 1;
|
|
276
|
-
}
|
|
1
|
+
import{resolve as v}from"node:path";import{acceptLegacyStoryPrC10 as S,acceptLegacyStoryPrPostMergeC12 as $,acceptLegacyStoryPrReviewC11 as C,acceptLegacyStoryCommitC08 as E,acceptLegacyStorySyncC09 as z,createLegacyStoryPr as P,mergeLegacyStoryPrC12 as N,planLegacyStoryCommitC08 as j,planLegacyStoryPr as L,planLegacyStoryPrMergeC12 as R,planLegacyStoryPrMergeDecisionC12 as k,planLegacyStoryPrReview as M,planLegacyStoryPrPostMergeC12 as I,planLegacyStoryPrRemoteDebtBeforePrepareC12 as J,observeLegacyStoryPrReviewC11 as O,planLegacyStorySyncC09 as x,prepareLegacyStoryPrMergeC12 as F,recordLegacyStoryPrRemoteDebtC12 as D}from"../git/legacy-story-pr.js";function W(y){const e=y[0];if(e!=="commit-plan"&&e!=="commit-accept"&&e!=="sync-plan"&&e!=="sync-accept"&&e!=="plan"&&e!=="create"&&e!=="accept"&&e!=="review-plan"&&e!=="review-observe"&&e!=="review-accept"&&e!=="merge-plan"&&e!=="merge-prepare"&&e!=="merge-debt-plan"&&e!=="merge-decision"&&e!=="merge-debt-record"&&e!=="merge-execute"&&e!=="merge-reconcile"&&e!=="post-merge-plan"&&e!=="post-merge-accept")throw new Error("legacy-story-pr-action-invalid");let i="",r=process.cwd(),o="",t="",c=0,n=!1,s=!1,l=!1,w=!1,p=!1,m=!1,f=!1,d=!1,b="plain";for(let h=1;h<y.length;h++){const a=y[h],g=()=>y[++h]??"";if(a==="--story")i=g();else if(a.startsWith("--story="))i=a.slice(8);else if(a==="--project-root")r=g();else if(a.startsWith("--project-root="))r=a.slice(15);else if(a==="--body-file")o=g();else if(a.startsWith("--body-file="))o=a.slice(12);else if(a==="--report-file")t=g();else if(a.startsWith("--report-file="))t=a.slice(14);else if(a==="--pr-number"||a.startsWith("--pr-number=")){const u=a==="--pr-number"?g():a.slice(12);if(!/^[1-9][0-9]*$/.test(u))throw new Error("legacy-story-pr-number-invalid");if(c=Number(u),!Number.isSafeInteger(c))throw new Error("legacy-story-pr-number-invalid")}else if(a==="--authorize-pr-create")n=!0;else if(a==="--authorize-review")s=!0;else if(a==="--authorize-pr-update")l=!0;else if(a==="--record-remote-debt")w=!0;else if(a==="--authorize-merge")p=!0;else if(a==="--authorize-post-merge")m=!0;else if(a==="--authorize-sync")f=!0;else if(a==="--authorize-commit")d=!0;else if(a==="--format"||a.startsWith("--format=")){const u=a==="--format"?g():a.slice(9);if(u!=="json"&&u!=="plain")throw new Error("legacy-story-pr-format-invalid");b=u}else throw new Error("legacy-story-pr-argument-invalid")}if(!i||!r)throw new Error("legacy-story-pr-target-required");if(e!=="post-merge-accept"&&m)throw new Error("legacy-story-pr-argument-invalid");if(e!=="sync-accept"&&f)throw new Error("legacy-story-pr-argument-invalid");if(e!=="commit-accept"&&d)throw new Error("legacy-story-pr-argument-invalid");if(e!=="merge-prepare"&&w)throw new Error("legacy-story-pr-argument-invalid");if(e==="commit-plan"&&(n||s||l||p||o||t||c))throw new Error("legacy-story-pr-commit-plan-options-invalid");if(e==="commit-accept"&&(n||s||l||p||!d||o||t||c))throw new Error("legacy-story-pr-commit-accept-options-invalid");if(e==="sync-plan"&&(n||s||l||p||o||t||c))throw new Error("legacy-story-pr-sync-plan-options-invalid");if(e==="sync-accept"&&(n||s||l||p||!f||o||t||c))throw new Error("legacy-story-pr-sync-accept-options-invalid");if(e==="plan"&&(n||s||l||p||o||t||c))throw new Error("legacy-story-pr-plan-options-invalid");if(e==="create"&&(!n||s||l||p||!o||t||c))throw new Error("legacy-story-pr-create-options-invalid");if(e==="accept"&&(n||s||l||p||o||t||!c))throw new Error("legacy-story-pr-accept-options-invalid");if(e==="review-plan"&&(n||s||l||p||o||t||!c))throw new Error("legacy-story-pr-review-plan-options-invalid");if(e==="review-observe"&&(n||s||l||p||o||t||!c))throw new Error("legacy-story-pr-review-observe-options-invalid");if(e==="review-accept"&&(n||!s||l||p||o||!t||!c))throw new Error("legacy-story-pr-review-accept-options-invalid");if(e==="merge-plan"&&(n||s||l||p||o||t||!c))throw new Error("legacy-story-pr-merge-plan-options-invalid");if(e==="merge-prepare"&&(n||s||!l||p||o||t||!c))throw new Error("legacy-story-pr-merge-prepare-options-invalid");if(e==="merge-debt-plan"&&(n||s||l||p||o||t||!c))throw new Error("legacy-story-pr-merge-debt-plan-options-invalid");if(e==="merge-decision"&&(n||s||l||p||o||t||!c))throw new Error("legacy-story-pr-merge-decision-options-invalid");if(e==="merge-debt-record"&&(n||s||l||p||o||t||!c))throw new Error("legacy-story-pr-merge-debt-record-options-invalid");if(e==="merge-execute"&&(n||s||l||!p||o||t||!c))throw new Error("legacy-story-pr-merge-execute-options-invalid");if(e==="merge-reconcile"&&(n||s||l||p||o||t||!c))throw new Error("legacy-story-pr-merge-reconcile-options-invalid");if(e==="post-merge-plan"&&(n||s||l||p||o||t||!c))throw new Error("legacy-story-pr-post-merge-plan-options-invalid");if(e==="post-merge-accept"&&(n||s||l||p||!m||o||t||!c))throw new Error("legacy-story-pr-post-merge-accept-options-invalid");return{action:e,storyId:i,projectRoot:v(r),authorize:n,authorizeReview:s,authorizePrUpdate:l,recordRemoteDebt:w,authorizeMerge:p,authorizePostMerge:m,authorizeSync:f,authorizeCommit:d,format:b,...o?{bodyFile:v(o)}:{},...t?{reportFile:v(t)}:{},...c?{prNumber:c}:{}}}async function H(y){let e;try{e=W(y)}catch(r){return console.error(r instanceof Error?r.message:"legacy-story-pr-arguments-invalid"),1}if(e.action==="commit-plan"){const r=j(e);return e.format==="json"?console.log(JSON.stringify({action:e.action,...r})):r.ok?console.log(`legacy-story-pr commit-plan: staged-basis-confirmed checkpoint=unaccepted story=${r.value.storyId} paths=${r.value.changedPaths.length}`):console.error(`legacy-story-pr: ${r.reasonCode}`),r.ok?0:1}if(e.action==="commit-accept"){const r=await E({...e,authorize:e.authorizeCommit});return e.format==="json"?console.log(JSON.stringify({action:e.action,...r})):r.ok?console.log(`legacy-story-pr commit-accept: checkpoint=accepted story=${r.value.storyId} head=${r.value.checkpointHeadSha}`):console.error(`legacy-story-pr: ${r.reasonCode}`),r.ok?0:1}if(e.action==="sync-plan"){const r=x(e);return e.format==="json"?console.log(JSON.stringify({action:e.action,...r})):r.ok?console.log(`legacy-story-pr sync-plan: physical-basis-confirmed checkpoint=unaccepted story=${r.value.storyId} base=${r.value.baseSha}`):console.error(`legacy-story-pr: ${r.reasonCode}`),r.ok?0:1}if(e.action==="sync-accept"){const r=await z({...e,authorize:e.authorizeSync});return e.format==="json"?console.log(JSON.stringify({action:e.action,...r})):r.ok?console.log(`legacy-story-pr sync-accept: checkpoint=accepted story=${r.value.storyId} head=${r.value.checkpointHeadSha}`):console.error(`legacy-story-pr: ${r.reasonCode}`),r.ok?0:1}if(e.action==="merge-execute"){const r=await k({...e,prNumber:e.prNumber});if(!r.ok||!r.value.canMerge){const t=r.ok?"legacy-story-pr-merge-remote-debt-required":r.reasonCode;return e.format==="json"?console.log(JSON.stringify({action:e.action,ok:!1,reasonCode:t})):console.error(`legacy-story-pr: ${t}`),1}const o=await N({...e,prNumber:e.prNumber,authorize:e.authorizeMerge,rootDecision:r.value});return e.format==="json"?console.log(JSON.stringify({action:e.action,...o})):o.ok?console.log(`legacy-story-pr merge-execute: physical-merge-confirmed checkpoint=unaccepted story=${o.value.storyId} pr=${o.value.prNumber}`):console.error(`legacy-story-pr: ${o.reasonCode}`),o.ok?0:1}if(e.action==="merge-reconcile"){const r=await N({...e,prNumber:e.prNumber,authorize:!0});return e.format==="json"?console.log(JSON.stringify({action:e.action,...r})):r.ok?console.log(`legacy-story-pr merge-reconcile: physical-merge-confirmed checkpoint=unaccepted story=${r.value.storyId} pr=${r.value.prNumber}`):console.error(`legacy-story-pr: ${r.reasonCode}`),r.ok?0:1}if(e.action==="post-merge-plan"){const r=await I({...e,prNumber:e.prNumber});return e.format==="json"?console.log(JSON.stringify({action:e.action,...r})):r.ok?console.log(`legacy-story-pr post-merge-plan: physical-basis-confirmed checkpoint=unaccepted story=${r.value.storyId} pr=${r.value.prNumber}`):console.error(`legacy-story-pr: ${r.reasonCode}`),r.ok?0:1}if(e.action==="post-merge-accept"){const r=await $({...e,prNumber:e.prNumber,authorize:e.authorizePostMerge});return e.format==="json"?console.log(JSON.stringify({action:e.action,...r})):r.ok?console.log(`legacy-story-pr post-merge-accept: checkpoint=accepted story=${r.value.storyId} pr=${r.value.prNumber} issue=${r.value.issueNumber}`):console.error(`legacy-story-pr: ${r.reasonCode}`),r.ok?0:1}if(e.action==="review-observe"){const r=await O({...e,prNumber:e.prNumber});return e.format==="json"?console.log(JSON.stringify({action:e.action,...r})):r.ok?console.log(`legacy-story-pr review-observe: categorical-reasons=${r.value.observation.reasonCodes.join(",")||"none"} checkpoint=unaccepted merge=unauthorized`):console.error(`legacy-story-pr: ${r.reasonCode}`),r.ok?0:1}const i=e.action==="plan"?L(e):e.action==="create"?await P({...e,bodyFile:e.bodyFile}):e.action==="accept"?await S({...e,prNumber:e.prNumber}):e.action==="review-plan"?await M({...e,prNumber:e.prNumber}):e.action==="review-accept"?await C({...e,prNumber:e.prNumber,reportFile:e.reportFile,authorize:e.authorizeReview}):e.action==="merge-plan"?await R({...e,prNumber:e.prNumber}):e.action==="merge-debt-plan"?await J({...e,prNumber:e.prNumber}):e.action==="merge-decision"?await k({...e,prNumber:e.prNumber}):e.action==="merge-debt-record"?await D({...e,prNumber:e.prNumber}):await F({...e,prNumber:e.prNumber,authorize:e.authorizePrUpdate});if(e.format==="json")console.log(JSON.stringify({action:e.action,...i}));else if(i.ok){const r="canMerge"in i.value&&i.value.canMerge===!1,o="registrySha256"in i.value;console.log(`legacy-story-pr ${e.action}: ${e.action==="merge-debt-record"?"journaled-not-registry":r?"debt-required":o?"recorded-debt-merge-attempt-authorized":"ok"}`),console.log(`story=${i.value.storyId}${"branch"in i.value?` branch=${i.value.branch}`:""}`),r&&"reasonCodes"in i.value&&console.log(`reasons=${i.value.reasonCodes.join(",")}`),o&&"nonBlockingChecks"in i.value&&console.log(`nonBlockingReasons=${i.value.nonBlockingChecks.map(t=>t.checkName).join(",")}`),"registryRecorded"in i.value&&console.log(`registryRecorded=${i.value.registryRecorded}`),"number"in i.value&&console.log(`pr=${i.value.number} checkpoint=${i.value.checkpointAccepted?"accepted":"unaccepted"}`)}else console.error(`legacy-story-pr: ${i.reasonCode}`);return i.ok?0:1}export{H as legacyStoryPrCliHandler,W as parseLegacyStoryPrArgs};
|