@ornexus/neocortex 4.60.73 → 4.60.75
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.d.ts +27 -0
- 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.d.ts +38 -1
- 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/host-auth-broker.d.ts +31 -0
- package/packages/client/dist/config/host-auth-broker.js +1 -0
- package/packages/client/dist/config/host-auth-reference.d.ts +32 -0
- package/packages/client/dist/config/host-auth-reference.js +1 -0
- 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.d.ts +11 -0
- 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.d.ts +3 -0
- 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.d.ts +11 -1
- 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.d.ts +2 -0
- package/packages/client/dist/index.js +1 -47
- package/packages/client/dist/invocation/invoke-input.js +1 -24
- package/packages/client/dist/license/host-auth-recovery.d.ts +158 -0
- package/packages/client/dist/license/host-auth-recovery.js +1 -0
- package/packages/client/dist/license/index.js +1 -5
- package/packages/client/dist/license/license-client.d.ts +10 -1
- 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/epic-background-dispatcher.d.ts +61 -0
- package/packages/client/dist/runner/epic-background-dispatcher.js +1 -0
- package/packages/client/dist/runner/headless/adapters.js +1 -49
- package/packages/client/dist/runner/headless/background-root.d.ts +65 -0
- package/packages/client/dist/runner/headless/background-root.js +1 -0
- 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 +27 -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-environment-cleanup.d.ts +95 -0
- package/packages/client/dist/runner/headless/managed-environment-cleanup.js +1 -0
- 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.d.ts +7 -0
- 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.d.ts +21 -1
- 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/invocation/explicit-intent-recovery.d.ts +83 -0
- package/packages/shared/dist/invocation/explicit-intent-recovery.js +187 -0
- package/packages/shared/dist/invocation/index.d.ts +7 -0
- package/packages/shared/dist/invocation/index.js +22 -0
- 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 +24 -21
- package/targets-stubs/codex/README.md +6 -1
- package/targets-stubs/codex/neocortex.toml +7 -2
- package/targets-stubs/cursor/agent.md +2 -2
- package/targets-stubs/gemini-cli/agent.md +2 -2
- package/targets-stubs/opencode/neocortex-root.md +16 -1
- package/targets-stubs/opencode/neocortex.md +6 -0
- package/targets-stubs/vscode/neocortex.agent.md +2 -2
|
@@ -1,156 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { getProjectMemoryTarget, isProjectMemoryTargetId, listProjectMemoryTargets } from '../memory/shared-project-memory-types.js';
|
|
5
|
-
import { writeProjectMemoryTargetFiles } from '../memory/project-memory-writer.js';
|
|
6
|
-
function parseCsv(value) {
|
|
7
|
-
return (value ?? '').split(',').map((entry) => entry.trim()).filter(Boolean);
|
|
8
|
-
}
|
|
9
|
-
export function parseRefreshMemoryArgs(args) {
|
|
10
|
-
let projectRoot = process.cwd();
|
|
11
|
-
let dryRun = false;
|
|
12
|
-
let verify = false;
|
|
13
|
-
const requestedTargets = [];
|
|
14
|
-
const memoryNotes = [];
|
|
15
|
-
for (let index = 0; index < args.length; index++) {
|
|
16
|
-
const arg = args[index];
|
|
17
|
-
if (arg === '--dry-run' || arg === '--preview') {
|
|
18
|
-
dryRun = true;
|
|
19
|
-
}
|
|
20
|
-
else if (arg === '--verify') {
|
|
21
|
-
verify = true;
|
|
22
|
-
dryRun = true;
|
|
23
|
-
}
|
|
24
|
-
else if (arg === '--project-root') {
|
|
25
|
-
projectRoot = args[++index] ?? projectRoot;
|
|
26
|
-
}
|
|
27
|
-
else if (arg.startsWith('--project-root=')) {
|
|
28
|
-
projectRoot = arg.slice('--project-root='.length);
|
|
29
|
-
}
|
|
30
|
-
else if (arg === '--target' || arg === '--targets') {
|
|
31
|
-
requestedTargets.push(...parseCsv(args[++index]));
|
|
32
|
-
}
|
|
33
|
-
else if (arg.startsWith('--target=')) {
|
|
34
|
-
requestedTargets.push(...parseCsv(arg.slice('--target='.length)));
|
|
35
|
-
}
|
|
36
|
-
else if (arg.startsWith('--targets=')) {
|
|
37
|
-
requestedTargets.push(...parseCsv(arg.slice('--targets='.length)));
|
|
38
|
-
}
|
|
39
|
-
else if (arg === '--note' || arg === '--memory-note' || arg === '--change') {
|
|
40
|
-
const note = args[++index];
|
|
41
|
-
if (note)
|
|
42
|
-
memoryNotes.push(note);
|
|
43
|
-
}
|
|
44
|
-
else if (arg.startsWith('--note=')) {
|
|
45
|
-
memoryNotes.push(arg.slice('--note='.length));
|
|
46
|
-
}
|
|
47
|
-
else if (arg.startsWith('--memory-note=')) {
|
|
48
|
-
memoryNotes.push(arg.slice('--memory-note='.length));
|
|
49
|
-
}
|
|
50
|
-
else if (arg.startsWith('--change=')) {
|
|
51
|
-
memoryNotes.push(arg.slice('--change='.length));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (verify && (requestedTargets.length > 0 || memoryNotes.length > 0)) {
|
|
55
|
-
throw new Error('Project memory verification requires all targets and no update notes.');
|
|
56
|
-
}
|
|
57
|
-
const targetIds = requestedTargets.length > 0
|
|
58
|
-
? requestedTargets.map((target) => {
|
|
59
|
-
if (!isProjectMemoryTargetId(target))
|
|
60
|
-
throw new Error(`Unknown project-memory target: ${target}`);
|
|
61
|
-
return target;
|
|
62
|
-
})
|
|
63
|
-
: ['canonical', ...listProjectMemoryTargets().map((target) => target.targetId)];
|
|
64
|
-
return { projectRoot: resolve(projectRoot), targetIds: Array.from(new Set(targetIds)), dryRun, verify, memoryNotes };
|
|
65
|
-
}
|
|
66
|
-
export function refreshProjectMemoryTargets(options) {
|
|
67
|
-
return options.targetIds.map((targetId) => writeProjectMemoryTargetFiles({
|
|
68
|
-
projectRoot: options.projectRoot,
|
|
69
|
-
targetId,
|
|
70
|
-
dryRun: options.dryRun,
|
|
71
|
-
memoryNotes: options.memoryNotes ?? [],
|
|
72
|
-
backupDirectory: options.backupDirectory,
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
/** Root-only, read-only physical check; this is not independent stage QA or server authority. */
|
|
76
|
-
export function verifyProjectMemoryTargets(options) {
|
|
77
|
-
if (!options.verify || !options.dryRun || options.memoryNotes?.length
|
|
78
|
-
|| options.targetIds.join(',') !== ['canonical', ...listProjectMemoryTargets().map((target) => target.targetId)].join(',')) {
|
|
79
|
-
throw new Error('Project memory verification requires the complete read-only target set.');
|
|
80
|
-
}
|
|
81
|
-
const canonicalPath = join(options.projectRoot, 'NEOCORTEX.md');
|
|
82
|
-
let entry;
|
|
83
|
-
try {
|
|
84
|
-
entry = lstatSync(canonicalPath);
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
throw new Error('Canonical project memory is missing or unsafe.');
|
|
88
|
-
}
|
|
89
|
-
if (!entry.isFile() || entry.isSymbolicLink())
|
|
90
|
-
throw new Error('Canonical project memory must be a regular file.');
|
|
91
|
-
const canonical = readFileSync(canonicalPath, 'utf8');
|
|
92
|
-
const start = '<!-- NEOCORTEX-MEMORY-START -->';
|
|
93
|
-
const end = '<!-- NEOCORTEX-MEMORY-END -->';
|
|
94
|
-
const budget = getProjectMemoryTarget('canonical').budget;
|
|
95
|
-
if (canonical.split(start).length !== 2 || canonical.split(end).length !== 2
|
|
96
|
-
|| canonical.indexOf(start) >= canonical.indexOf(end)
|
|
97
|
-
|| Buffer.byteLength(canonical, 'utf8') > budget.maxBytes
|
|
98
|
-
|| canonical.split('\n').length > budget.maxLines) {
|
|
99
|
-
throw new Error('Canonical project memory markers or budget are invalid.');
|
|
100
|
-
}
|
|
101
|
-
const files = refreshProjectMemoryTargets(options).flatMap((result) => result.files);
|
|
102
|
-
if (files.some((file) => file.changed || file.mode === 'compatibility-materialized-fallback'
|
|
103
|
-
|| file.fallbackReason || file.remediationDebt)) {
|
|
104
|
-
throw new Error('Project memory verification found stale or fallback targets.');
|
|
105
|
-
}
|
|
106
|
-
let projection;
|
|
107
|
-
try {
|
|
108
|
-
projection = [...new Set(files.map((file) => file.relativeFile))].sort()
|
|
109
|
-
.map((relativeFile) => {
|
|
110
|
-
const bytes = readFileSync(join(options.projectRoot, relativeFile));
|
|
111
|
-
const mode = files.find((file) => file.relativeFile === relativeFile).mode;
|
|
112
|
-
return `${relativeFile}:${mode}:${createHash('sha256').update(bytes).digest('hex')}`;
|
|
113
|
-
});
|
|
114
|
-
if (readFileSync(canonicalPath, 'utf8') !== canonical
|
|
115
|
-
|| refreshProjectMemoryTargets(options).some((result) => result.changed)) {
|
|
116
|
-
throw new Error('project-memory-verification-race');
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
catch {
|
|
120
|
-
throw new Error('Project memory changed during verification.');
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
schemaVersion: 'ProjectMemoryVerification/1',
|
|
124
|
-
canonicalSha256: createHash('sha256').update(canonical).digest('hex'),
|
|
125
|
-
projectionSha256: createHash('sha256').update(projection.join('\n')).digest('hex'),
|
|
126
|
-
fileCount: projection.length,
|
|
127
|
-
publicSafe: true,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
export async function refreshMemoryCliHandler(args) {
|
|
131
|
-
try {
|
|
132
|
-
const options = parseRefreshMemoryArgs(args);
|
|
133
|
-
if (options.verify) {
|
|
134
|
-
const verification = verifyProjectMemoryTargets(options);
|
|
135
|
-
console.log(`Project memory verified: files=${verification.fileCount} canonical_sha256=${verification.canonicalSha256} projection_sha256=${verification.projectionSha256}`);
|
|
136
|
-
return 0;
|
|
137
|
-
}
|
|
138
|
-
const results = refreshProjectMemoryTargets(options);
|
|
139
|
-
const rows = results.flatMap((result) => result.files.map((file) => [
|
|
140
|
-
file.changed ? (options.dryRun ? 'would-change' : 'changed') : 'unchanged',
|
|
141
|
-
file.mode,
|
|
142
|
-
file.relativeFile,
|
|
143
|
-
file.fallbackReason ? `warning=${file.fallbackReason}` : undefined,
|
|
144
|
-
file.remediationDebt ? `debt=${file.remediationDebt}` : undefined,
|
|
145
|
-
file.reasonCodes && file.reasonCodes.length > 0 ? `reasons=${file.reasonCodes.join(',')}` : undefined,
|
|
146
|
-
].filter(Boolean).join(' ')));
|
|
147
|
-
console.log(`${options.dryRun ? 'Project memory preview' : 'Project memory refreshed'}: ${options.projectRoot}`);
|
|
148
|
-
for (const row of rows)
|
|
149
|
-
console.log(row);
|
|
150
|
-
return 0;
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
154
|
-
return 1;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
1
|
+
import{createHash as m}from"node:crypto";import{lstatSync as w,readFileSync as f}from"node:fs";import{join as u,resolve as R}from"node:path";import{getProjectMemoryTarget as b,isProjectMemoryTargetId as E,listProjectMemoryTargets as g}from"../memory/shared-project-memory-types.js";import{writeProjectMemoryTargetFiles as v}from"../memory/project-memory-writer.js";function h(r){return(r??"").split(",").map(t=>t.trim()).filter(Boolean)}function M(r){let t=process.cwd(),c=!1,i=!1;const a=[],o=[];for(let s=0;s<r.length;s++){const e=r[s];if(e==="--dry-run"||e==="--preview")c=!0;else if(e==="--verify")i=!0,c=!0;else if(e==="--project-root")t=r[++s]??t;else if(e.startsWith("--project-root="))t=e.slice(15);else if(e==="--target"||e==="--targets")a.push(...h(r[++s]));else if(e.startsWith("--target="))a.push(...h(e.slice(9)));else if(e.startsWith("--targets="))a.push(...h(e.slice(10)));else if(e==="--note"||e==="--memory-note"||e==="--change"){const n=r[++s];n&&o.push(n)}else e.startsWith("--note=")?o.push(e.slice(7)):e.startsWith("--memory-note=")?o.push(e.slice(14)):e.startsWith("--change=")&&o.push(e.slice(9))}if(i&&(a.length>0||o.length>0))throw new Error("Project memory verification requires all targets and no update notes.");const l=a.length>0?a.map(s=>{if(!E(s))throw new Error(`Unknown project-memory target: ${s}`);return s}):["canonical",...g().map(s=>s.targetId)];return{projectRoot:R(t),targetIds:Array.from(new Set(l)),dryRun:c,verify:i,memoryNotes:o}}function d(r){return r.targetIds.map(t=>v({projectRoot:r.projectRoot,targetId:t,dryRun:r.dryRun,memoryNotes:r.memoryNotes??[],backupDirectory:r.backupDirectory}))}function P(r){if(!r.verify||!r.dryRun||r.memoryNotes?.length||r.targetIds.join(",")!==["canonical",...g().map(n=>n.targetId)].join(","))throw new Error("Project memory verification requires the complete read-only target set.");const t=u(r.projectRoot,"NEOCORTEX.md");let c;try{c=w(t)}catch{throw new Error("Canonical project memory is missing or unsafe.")}if(!c.isFile()||c.isSymbolicLink())throw new Error("Canonical project memory must be a regular file.");const i=f(t,"utf8"),a="<!-- NEOCORTEX-MEMORY-START -->",o="<!-- NEOCORTEX-MEMORY-END -->",l=b("canonical").budget;if(i.split(a).length!==2||i.split(o).length!==2||i.indexOf(a)>=i.indexOf(o)||Buffer.byteLength(i,"utf8")>l.maxBytes||i.split(`
|
|
2
|
+
`).length>l.maxLines)throw new Error("Canonical project memory markers or budget are invalid.");const s=d(r).flatMap(n=>n.files);if(s.some(n=>n.changed||n.mode==="compatibility-materialized-fallback"||n.fallbackReason||n.remediationDebt))throw new Error("Project memory verification found stale or fallback targets.");let e;try{if(e=[...new Set(s.map(n=>n.relativeFile))].sort().map(n=>{const y=f(u(r.projectRoot,n)),p=s.find(j=>j.relativeFile===n).mode;return`${n}:${p}:${m("sha256").update(y).digest("hex")}`}),f(t,"utf8")!==i||d(r).some(n=>n.changed))throw new Error("project-memory-verification-race")}catch{throw new Error("Project memory changed during verification.")}return{schemaVersion:"ProjectMemoryVerification/1",canonicalSha256:m("sha256").update(i).digest("hex"),projectionSha256:m("sha256").update(e.join(`
|
|
3
|
+
`)).digest("hex"),fileCount:e.length,publicSafe:!0}}async function k(r){try{const t=M(r);if(t.verify){const a=P(t);return console.log(`Project memory verified: files=${a.fileCount} canonical_sha256=${a.canonicalSha256} projection_sha256=${a.projectionSha256}`),0}const i=d(t).flatMap(a=>a.files.map(o=>[o.changed?t.dryRun?"would-change":"changed":"unchanged",o.mode,o.relativeFile,o.fallbackReason?`warning=${o.fallbackReason}`:void 0,o.remediationDebt?`debt=${o.remediationDebt}`:void 0,o.reasonCodes&&o.reasonCodes.length>0?`reasons=${o.reasonCodes.join(",")}`:void 0].filter(Boolean).join(" ")));console.log(`${t.dryRun?"Project memory preview":"Project memory refreshed"}: ${t.projectRoot}`);for(const a of i)console.log(a);return 0}catch(t){return console.error(t instanceof Error?t.message:String(t)),1}}export{M as parseRefreshMemoryArgs,k as refreshMemoryCliHandler,d as refreshProjectMemoryTargets,P as verifyProjectMemoryTargets};
|
|
@@ -1,24 +1 @@
|
|
|
1
|
-
|
|
2
|
-
'arch-prd', 'arch-architecture', 'arch-fitness-functions', 'arch-api-contracts', 'generate-pacts',
|
|
3
|
-
'arch-api-integrations', 'arch-database', 'arch-security', 'arch-design-system', 'arch-ux-design',
|
|
4
|
-
'arch-performance', 'arch-testing', 'arch-infrastructure', 'arch-review', 'update-memory',
|
|
5
|
-
]);
|
|
6
|
-
export const ARCHITECTURE_NON_UI_COMMANDS = Object.freeze(ARCHITECTURE_PUBLIC_COMMANDS
|
|
7
|
-
.filter(command => command !== 'arch-design-system' && command !== 'arch-ux-design'));
|
|
8
|
-
const EXCLUDED = Object.freeze(['arch-design-system', 'arch-ux-design']);
|
|
9
|
-
export function parseArchitectureNonUiScopeReceipt(value) {
|
|
10
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
11
|
-
return undefined;
|
|
12
|
-
const receipt = value;
|
|
13
|
-
if (Object.keys(receipt).sort().join(',') !== ['schemaVersion', 'kind', 'licenseHash', 'projectHash', 'targetEpicId',
|
|
14
|
-
'graphRevision', 'rootInputSha256', 'accountingId', 'applicability', 'excludedStageCommands', 'macSha256', 'publicSafe'].sort().join(',')
|
|
15
|
-
|| receipt.schemaVersion !== 1 || receipt.kind !== 'ArchitectureNonUiScope/1' || receipt.publicSafe !== true
|
|
16
|
-
|| receipt.applicability !== 'non-ui' || typeof receipt.targetEpicId !== 'string'
|
|
17
|
-
|| !/^P[1-9][0-9]{0,11}$/.test(receipt.targetEpicId) || typeof receipt.accountingId !== 'string'
|
|
18
|
-
|| !/^arch-accounting-[a-f0-9]{32}$/.test(receipt.accountingId)
|
|
19
|
-
|| !['licenseHash', 'projectHash', 'graphRevision', 'rootInputSha256', 'macSha256'].every(key => typeof receipt[key] === 'string' && /^[a-f0-9]{64}$/.test(receipt[key]))
|
|
20
|
-
|| !Array.isArray(receipt.excludedStageCommands) || receipt.excludedStageCommands.length !== EXCLUDED.length
|
|
21
|
-
|| !receipt.excludedStageCommands.every((command, index) => command === EXCLUDED[index]))
|
|
22
|
-
return undefined;
|
|
23
|
-
return Object.freeze({ ...receipt, excludedStageCommands: EXCLUDED });
|
|
24
|
-
}
|
|
1
|
+
const i=Object.freeze(["arch-prd","arch-architecture","arch-fitness-functions","arch-api-contracts","generate-pacts","arch-api-integrations","arch-database","arch-security","arch-design-system","arch-ux-design","arch-performance","arch-testing","arch-infrastructure","arch-review","update-memory"]),n=Object.freeze(i.filter(t=>t!=="arch-design-system"&&t!=="arch-ux-design")),c=Object.freeze(["arch-design-system","arch-ux-design"]);function s(t){if(!t||typeof t!="object"||Array.isArray(t))return;const e=t;if(!(Object.keys(e).sort().join(",")!==["schemaVersion","kind","licenseHash","projectHash","targetEpicId","graphRevision","rootInputSha256","accountingId","applicability","excludedStageCommands","macSha256","publicSafe"].sort().join(",")||e.schemaVersion!==1||e.kind!=="ArchitectureNonUiScope/1"||e.publicSafe!==!0||e.applicability!=="non-ui"||typeof e.targetEpicId!="string"||!/^P[1-9][0-9]{0,11}$/.test(e.targetEpicId)||typeof e.accountingId!="string"||!/^arch-accounting-[a-f0-9]{32}$/.test(e.accountingId)||!["licenseHash","projectHash","graphRevision","rootInputSha256","macSha256"].every(r=>typeof e[r]=="string"&&/^[a-f0-9]{64}$/.test(e[r]))||!Array.isArray(e.excludedStageCommands)||e.excludedStageCommands.length!==c.length||!e.excludedStageCommands.every((r,a)=>r===c[a])))return Object.freeze({...e,excludedStageCommands:c})}export{n as ARCHITECTURE_NON_UI_COMMANDS,i as ARCHITECTURE_PUBLIC_COMMANDS,s as parseArchitectureNonUiScopeReceipt};
|
|
@@ -1,171 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { resolve } from 'node:path';
|
|
3
|
-
import { acceptDirectYoloSetupCheckpoint, beginDirectYoloStoryCommit, finalizeDirectYoloStoryCheckpoint, issueDirectYoloSetupLeaseHandoff, prepareDirectYoloSetup, recoverLegacyDirectYoloStoryCheckpoint, } from '../git/direct-yolo-checkpoint.js';
|
|
4
|
-
import { applyDirectYoloC01Retry, inspectDirectYoloC01Retry } from '../git/direct-yolo-c01-retry.js';
|
|
5
|
-
export function parseStoryCheckpointArgs(args) {
|
|
6
|
-
const action = args[0];
|
|
7
|
-
if (action !== 'setup' && action !== 'accept-setup' && action !== 'handoff' && action !== 'begin' && action !== 'finalize' && action !== 'recover' && action !== 'retry-c01') {
|
|
8
|
-
throw new Error('story-checkpoint-action-invalid');
|
|
9
|
-
}
|
|
10
|
-
let storyId = '';
|
|
11
|
-
let projectRoot = process.cwd();
|
|
12
|
-
let commitSha;
|
|
13
|
-
let remote = 'origin';
|
|
14
|
-
let push = false;
|
|
15
|
-
let format = 'plain';
|
|
16
|
-
let setupHandoffSessionId;
|
|
17
|
-
let setupHandoffTokenFile;
|
|
18
|
-
let expectedHeadSha;
|
|
19
|
-
let apply = false;
|
|
20
|
-
for (let index = 1; index < args.length; index++) {
|
|
21
|
-
const arg = args[index];
|
|
22
|
-
const next = () => args[++index] ?? '';
|
|
23
|
-
if (arg === '--story')
|
|
24
|
-
storyId = next();
|
|
25
|
-
else if (arg.startsWith('--story='))
|
|
26
|
-
storyId = arg.slice('--story='.length);
|
|
27
|
-
else if (arg === '--project-root')
|
|
28
|
-
projectRoot = next() || projectRoot;
|
|
29
|
-
else if (arg.startsWith('--project-root='))
|
|
30
|
-
projectRoot = arg.slice('--project-root='.length);
|
|
31
|
-
else if (arg === '--commit')
|
|
32
|
-
commitSha = next();
|
|
33
|
-
else if (arg.startsWith('--commit='))
|
|
34
|
-
commitSha = arg.slice('--commit='.length);
|
|
35
|
-
else if (arg === '--remote')
|
|
36
|
-
remote = next();
|
|
37
|
-
else if (arg.startsWith('--remote='))
|
|
38
|
-
remote = arg.slice('--remote='.length);
|
|
39
|
-
else if (arg === '--push' || arg === '--require-remote')
|
|
40
|
-
push = true;
|
|
41
|
-
else if (arg === '--setup-handoff-session')
|
|
42
|
-
setupHandoffSessionId = next();
|
|
43
|
-
else if (arg.startsWith('--setup-handoff-session='))
|
|
44
|
-
setupHandoffSessionId = arg.slice('--setup-handoff-session='.length);
|
|
45
|
-
else if (arg === '--setup-handoff-token-file')
|
|
46
|
-
setupHandoffTokenFile = next();
|
|
47
|
-
else if (arg.startsWith('--setup-handoff-token-file='))
|
|
48
|
-
setupHandoffTokenFile = arg.slice('--setup-handoff-token-file='.length);
|
|
49
|
-
else if (arg === '--expected-head')
|
|
50
|
-
expectedHeadSha = next();
|
|
51
|
-
else if (arg.startsWith('--expected-head='))
|
|
52
|
-
expectedHeadSha = arg.slice('--expected-head='.length);
|
|
53
|
-
else if (arg === '--apply')
|
|
54
|
-
apply = true;
|
|
55
|
-
else if (arg === '--format') {
|
|
56
|
-
const value = next();
|
|
57
|
-
if (value !== 'json' && value !== 'plain')
|
|
58
|
-
throw new Error('story-checkpoint-format-invalid');
|
|
59
|
-
format = value;
|
|
60
|
-
}
|
|
61
|
-
else if (arg.startsWith('--format=')) {
|
|
62
|
-
const value = arg.slice('--format='.length);
|
|
63
|
-
if (value !== 'json' && value !== 'plain')
|
|
64
|
-
throw new Error('story-checkpoint-format-invalid');
|
|
65
|
-
format = value;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
throw new Error('story-checkpoint-argument-invalid');
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (!storyId)
|
|
72
|
-
throw new Error('story-checkpoint-story-required');
|
|
73
|
-
if (action === 'recover' && !commitSha)
|
|
74
|
-
throw new Error('story-checkpoint-commit-required');
|
|
75
|
-
if (action === 'recover' && !push)
|
|
76
|
-
throw new Error('story-checkpoint-remote-proof-required');
|
|
77
|
-
if (action === 'finalize' && !push)
|
|
78
|
-
throw new Error('story-checkpoint-push-required');
|
|
79
|
-
if (action === 'begin' && (commitSha || push || remote !== 'origin'))
|
|
80
|
-
throw new Error('story-checkpoint-option-invalid');
|
|
81
|
-
if ((action === 'setup' || action === 'accept-setup' || action === 'handoff') && (commitSha || push || remote !== 'origin')) {
|
|
82
|
-
throw new Error('story-checkpoint-option-invalid');
|
|
83
|
-
}
|
|
84
|
-
if (action === 'finalize' && commitSha)
|
|
85
|
-
throw new Error('story-checkpoint-option-invalid');
|
|
86
|
-
if ((setupHandoffSessionId === undefined) !== (setupHandoffTokenFile === undefined)) {
|
|
87
|
-
throw new Error('story-checkpoint-setup-handoff-incomplete');
|
|
88
|
-
}
|
|
89
|
-
if (action !== 'begin' && (setupHandoffSessionId || setupHandoffTokenFile)) {
|
|
90
|
-
throw new Error('story-checkpoint-option-invalid');
|
|
91
|
-
}
|
|
92
|
-
if (action !== 'retry-c01' && (expectedHeadSha || apply))
|
|
93
|
-
throw new Error('story-checkpoint-option-invalid');
|
|
94
|
-
if (action === 'retry-c01' && (commitSha || push || remote !== 'origin'
|
|
95
|
-
|| apply && !/^[a-f0-9]{40,64}$/.test(expectedHeadSha ?? '')))
|
|
96
|
-
throw new Error('story-checkpoint-option-invalid');
|
|
97
|
-
return {
|
|
98
|
-
action, storyId, projectRoot: resolve(projectRoot), commitSha, remote, push, format,
|
|
99
|
-
...(expectedHeadSha ? { expectedHeadSha } : {}), ...(apply ? { apply } : {}),
|
|
100
|
-
...(setupHandoffSessionId ? { setupHandoffSessionId } : {}),
|
|
101
|
-
...(setupHandoffTokenFile ? { setupHandoffTokenFile: resolve(setupHandoffTokenFile) } : {}),
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
export async function storyCheckpointCliHandler(args) {
|
|
105
|
-
let options;
|
|
106
|
-
try {
|
|
107
|
-
options = parseStoryCheckpointArgs(args);
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
console.error(error instanceof Error ? error.message : 'story-checkpoint-arguments-invalid');
|
|
111
|
-
return 1;
|
|
112
|
-
}
|
|
113
|
-
if (options.action === 'retry-c01') {
|
|
114
|
-
try {
|
|
115
|
-
const result = options.apply
|
|
116
|
-
? await applyDirectYoloC01Retry(options.projectRoot, options.storyId, options.expectedHeadSha)
|
|
117
|
-
: await inspectDirectYoloC01Retry(options.projectRoot, options.storyId);
|
|
118
|
-
console.log(options.format === 'json' ? JSON.stringify(result, null, 2)
|
|
119
|
-
: `story-checkpoint retry-c01: ${options.apply ? 'committed' : 'eligible'}`);
|
|
120
|
-
return 0;
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
console.error(error instanceof Error ? error.message : 'direct-yolo-retry-unverified');
|
|
124
|
-
return 1;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
let setupLeaseHandoff;
|
|
128
|
-
if (options.setupHandoffSessionId && options.setupHandoffTokenFile) {
|
|
129
|
-
try {
|
|
130
|
-
setupLeaseHandoff = {
|
|
131
|
-
sessionId: options.setupHandoffSessionId,
|
|
132
|
-
token: (await readFile(options.setupHandoffTokenFile, 'utf8')).trim(),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
catch {
|
|
136
|
-
console.error('story-checkpoint-setup-handoff-read-failed');
|
|
137
|
-
return 1;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const result = options.action === 'setup'
|
|
141
|
-
? await prepareDirectYoloSetup(options)
|
|
142
|
-
: options.action === 'accept-setup'
|
|
143
|
-
? await acceptDirectYoloSetupCheckpoint(options)
|
|
144
|
-
: options.action === 'handoff'
|
|
145
|
-
? await issueDirectYoloSetupLeaseHandoff(options)
|
|
146
|
-
: options.action === 'begin'
|
|
147
|
-
? await beginDirectYoloStoryCommit({ ...options, ...(setupLeaseHandoff ? { setupLeaseHandoff } : {}) })
|
|
148
|
-
: options.action === 'finalize'
|
|
149
|
-
? await finalizeDirectYoloStoryCheckpoint(options)
|
|
150
|
-
: await recoverLegacyDirectYoloStoryCheckpoint({
|
|
151
|
-
...options,
|
|
152
|
-
commitSha: options.commitSha,
|
|
153
|
-
});
|
|
154
|
-
if (options.format === 'json') {
|
|
155
|
-
console.log(JSON.stringify({ action: options.action, ...result }, null, 2));
|
|
156
|
-
}
|
|
157
|
-
else if (result.ok) {
|
|
158
|
-
console.log(`story-checkpoint ${options.action}: ok`);
|
|
159
|
-
if (options.action === 'begin' && 'trailers' in result.value) {
|
|
160
|
-
for (const trailer of result.value.trailers)
|
|
161
|
-
console.log(trailer);
|
|
162
|
-
}
|
|
163
|
-
else if ('headSha' in result.value) {
|
|
164
|
-
console.log(`head=${result.value.headSha}`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
console.error(`story-checkpoint ${options.action}: ${result.reasonCode}`);
|
|
169
|
-
}
|
|
170
|
-
return result.ok ? 0 : 1;
|
|
171
|
-
}
|
|
1
|
+
import{readFile as w}from"node:fs/promises";import{resolve as m}from"node:path";import{acceptDirectYoloSetupCheckpoint as k,beginDirectYoloStoryCommit as g,finalizeDirectYoloStoryCheckpoint as v,issueDirectYoloSetupLeaseHandoff as S,prepareDirectYoloSetup as E,recoverLegacyDirectYoloStoryCheckpoint as H}from"../git/direct-yolo-checkpoint.js";import{applyDirectYoloC01Retry as j,inspectDirectYoloC01Retry as C}from"../git/direct-yolo-c01-retry.js";function x(a){const e=a[0];if(e!=="setup"&&e!=="accept-setup"&&e!=="handoff"&&e!=="begin"&&e!=="finalize"&&e!=="recover"&&e!=="retry-c01")throw new Error("story-checkpoint-action-invalid");let i="",r=process.cwd(),t,l="origin",s=!1,y="plain",f,p,h,d=!1;for(let u=1;u<a.length;u++){const o=a[u],n=()=>a[++u]??"";if(o==="--story")i=n();else if(o.startsWith("--story="))i=o.slice(8);else if(o==="--project-root")r=n()||r;else if(o.startsWith("--project-root="))r=o.slice(15);else if(o==="--commit")t=n();else if(o.startsWith("--commit="))t=o.slice(9);else if(o==="--remote")l=n();else if(o.startsWith("--remote="))l=o.slice(9);else if(o==="--push"||o==="--require-remote")s=!0;else if(o==="--setup-handoff-session")f=n();else if(o.startsWith("--setup-handoff-session="))f=o.slice(24);else if(o==="--setup-handoff-token-file")p=n();else if(o.startsWith("--setup-handoff-token-file="))p=o.slice(27);else if(o==="--expected-head")h=n();else if(o.startsWith("--expected-head="))h=o.slice(16);else if(o==="--apply")d=!0;else if(o==="--format"){const c=n();if(c!=="json"&&c!=="plain")throw new Error("story-checkpoint-format-invalid");y=c}else if(o.startsWith("--format=")){const c=o.slice(9);if(c!=="json"&&c!=="plain")throw new Error("story-checkpoint-format-invalid");y=c}else throw new Error("story-checkpoint-argument-invalid")}if(!i)throw new Error("story-checkpoint-story-required");if(e==="recover"&&!t)throw new Error("story-checkpoint-commit-required");if(e==="recover"&&!s)throw new Error("story-checkpoint-remote-proof-required");if(e==="finalize"&&!s)throw new Error("story-checkpoint-push-required");if(e==="begin"&&(t||s||l!=="origin"))throw new Error("story-checkpoint-option-invalid");if((e==="setup"||e==="accept-setup"||e==="handoff")&&(t||s||l!=="origin"))throw new Error("story-checkpoint-option-invalid");if(e==="finalize"&&t)throw new Error("story-checkpoint-option-invalid");if(f===void 0!=(p===void 0))throw new Error("story-checkpoint-setup-handoff-incomplete");if(e!=="begin"&&(f||p))throw new Error("story-checkpoint-option-invalid");if(e!=="retry-c01"&&(h||d))throw new Error("story-checkpoint-option-invalid");if(e==="retry-c01"&&(t||s||l!=="origin"||d&&!/^[a-f0-9]{40,64}$/.test(h??"")))throw new Error("story-checkpoint-option-invalid");return{action:e,storyId:i,projectRoot:m(r),commitSha:t,remote:l,push:s,format:y,...h?{expectedHeadSha:h}:{},...d?{apply:d}:{},...f?{setupHandoffSessionId:f}:{},...p?{setupHandoffTokenFile:m(p)}:{}}}async function I(a){let e;try{e=x(a)}catch(t){return console.error(t instanceof Error?t.message:"story-checkpoint-arguments-invalid"),1}if(e.action==="retry-c01")try{const t=e.apply?await j(e.projectRoot,e.storyId,e.expectedHeadSha):await C(e.projectRoot,e.storyId);return console.log(e.format==="json"?JSON.stringify(t,null,2):`story-checkpoint retry-c01: ${e.apply?"committed":"eligible"}`),0}catch(t){return console.error(t instanceof Error?t.message:"direct-yolo-retry-unverified"),1}let i;if(e.setupHandoffSessionId&&e.setupHandoffTokenFile)try{i={sessionId:e.setupHandoffSessionId,token:(await w(e.setupHandoffTokenFile,"utf8")).trim()}}catch{return console.error("story-checkpoint-setup-handoff-read-failed"),1}const r=e.action==="setup"?await E(e):e.action==="accept-setup"?await k(e):e.action==="handoff"?await S(e):e.action==="begin"?await g({...e,...i?{setupLeaseHandoff:i}:{}}):e.action==="finalize"?await v(e):await H({...e,commitSha:e.commitSha});if(e.format==="json")console.log(JSON.stringify({action:e.action,...r},null,2));else if(r.ok)if(console.log(`story-checkpoint ${e.action}: ok`),e.action==="begin"&&"trailers"in r.value)for(const t of r.value.trailers)console.log(t);else"headSha"in r.value&&console.log(`head=${r.value.headSha}`);else console.error(`story-checkpoint ${e.action}: ${r.reasonCode}`);return r.ok?0:1}export{x as parseStoryCheckpointArgs,I as storyCheckpointCliHandler};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type HostAuthOperation, type HostAuthReferenceV1 } from './host-auth-reference.js';
|
|
2
|
+
export interface HostAuthPublicResult {
|
|
3
|
+
readonly status: 'available' | 'unavailable' | 'denied';
|
|
4
|
+
readonly reasonCode: string;
|
|
5
|
+
readonly generation?: number;
|
|
6
|
+
readonly expiresAt?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface HostAuthAdapter {
|
|
9
|
+
readonly provider: 'codex' | 'opencode';
|
|
10
|
+
readonly target: string;
|
|
11
|
+
readonly operations: Readonly<Partial<Record<HostAuthOperation, (reference: HostAuthReferenceV1) => Promise<HostAuthPublicResult>>>>;
|
|
12
|
+
}
|
|
13
|
+
export interface HostAuthBrokerRequest {
|
|
14
|
+
readonly capability: object;
|
|
15
|
+
readonly reference: unknown;
|
|
16
|
+
readonly caller: 'host-runtime';
|
|
17
|
+
readonly expectedSubjectDigest: string;
|
|
18
|
+
readonly expectedPolicyDigest: string;
|
|
19
|
+
readonly expectedDispatchDigest: string;
|
|
20
|
+
readonly requiredScopes: readonly string[];
|
|
21
|
+
readonly minimumRevocationEpoch: number;
|
|
22
|
+
}
|
|
23
|
+
export interface HostAuthBroker {
|
|
24
|
+
execute(request: HostAuthBrokerRequest): Promise<HostAuthPublicResult>;
|
|
25
|
+
}
|
|
26
|
+
export interface HostAuthBrokerHandle {
|
|
27
|
+
readonly broker: HostAuthBroker;
|
|
28
|
+
/** Process-local authority. Never serialize or pass this object to a child. */
|
|
29
|
+
readonly capability: object;
|
|
30
|
+
}
|
|
31
|
+
export declare function createHostAuthBroker(adapter?: HostAuthAdapter): HostAuthBrokerHandle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{timingSafeEqual as f}from"node:crypto";import{parseHostAuthReference as c}from"./host-auth-reference.js";function n(r,a){return!/^[a-f0-9]{64}$/.test(r)||!/^[a-f0-9]{64}$/.test(a)?!1:f(Buffer.from(r,"hex"),Buffer.from(a,"hex"))}function p(r){const a=Object.freeze(Object.create(null)),u=new WeakSet([a]);let o=!1;const d=Object.freeze({async execute(t){if(!t.capability||!u.has(t.capability)||t.caller!=="host-runtime")return{status:"denied",reasonCode:"host-auth-origin-denied"};let e;try{e=c(t.reference)}catch(i){return{status:"denied",reasonCode:i instanceof Error?i.message:"host-auth-reference-invalid"}}if(!n(e.subjectDigest,t.expectedSubjectDigest)||!n(e.policyDigest,t.expectedPolicyDigest)||!n(e.dispatchDigest,t.expectedDispatchDigest))return{status:"denied",reasonCode:"host-auth-reference-invalid"};if(e.revocationEpoch<t.minimumRevocationEpoch)return{status:"denied",reasonCode:"host-auth-reference-revoked"};if(!t.requiredScopes.every(i=>e.scopes.includes(i)))return{status:"denied",reasonCode:"host-auth-scope-denied"};if(!r)return{status:"unavailable",reasonCode:"host-auth-capability-unavailable"};if(r.provider!==e.provider||r.target!==e.target)return{status:"denied",reasonCode:"host-auth-target-denied"};const s=r.operations[e.operation];if(!s)return{status:"denied",reasonCode:"host-auth-operation-denied"};if(o)return{status:"unavailable",reasonCode:"host-auth-capability-unavailable"};o=!0;try{return c(e),e.revocationEpoch<t.minimumRevocationEpoch?{status:"denied",reasonCode:"host-auth-reference-revoked"}:await s(e)}finally{o=!1}}});return Object.freeze({broker:d,capability:a})}export{p as createHostAuthBroker};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const HOST_AUTH_REFERENCE_SCHEMA: "HostAuthReference/1.0";
|
|
2
|
+
export declare const HOST_AUTH_REFERENCE_MAX_BYTES = 4096;
|
|
3
|
+
export declare const HOST_AUTH_REFERENCE_MAX_TTL_MS = 60000;
|
|
4
|
+
export type HostAuthProvider = 'codex' | 'opencode';
|
|
5
|
+
export type HostAuthOperation = 'inspect-session' | 'prepare-license-auth' | 'reconcile-license-auth' | 'authorize-business-replay';
|
|
6
|
+
export interface HostAuthReferenceV1 {
|
|
7
|
+
readonly schemaVersion: typeof HOST_AUTH_REFERENCE_SCHEMA;
|
|
8
|
+
readonly referenceId: string;
|
|
9
|
+
readonly provider: HostAuthProvider;
|
|
10
|
+
readonly authDomain: 'model-provider';
|
|
11
|
+
readonly target: string;
|
|
12
|
+
readonly operation: HostAuthOperation;
|
|
13
|
+
readonly scopes: readonly string[];
|
|
14
|
+
readonly issuedAt: string;
|
|
15
|
+
readonly expiresAt: string;
|
|
16
|
+
readonly revocationEpoch: number;
|
|
17
|
+
readonly subjectDigest: string;
|
|
18
|
+
readonly policyDigest: string;
|
|
19
|
+
readonly dispatchDigest: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class HostAuthReferenceError extends Error {
|
|
22
|
+
readonly reasonCode: string;
|
|
23
|
+
constructor(reasonCode: string);
|
|
24
|
+
}
|
|
25
|
+
export declare function parseHostAuthReference(input: unknown, options?: {
|
|
26
|
+
readonly now?: number;
|
|
27
|
+
readonly allowExpired?: boolean;
|
|
28
|
+
}): HostAuthReferenceV1;
|
|
29
|
+
export declare function createHostAuthReference(input: Omit<HostAuthReferenceV1, 'schemaVersion' | 'referenceId' | 'issuedAt' | 'expiresAt'> & {
|
|
30
|
+
readonly ttlMs?: number;
|
|
31
|
+
readonly now?: number;
|
|
32
|
+
}): HostAuthReferenceV1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{randomBytes as l}from"node:crypto";const p="HostAuthReference/1.0",u=4096,E=6e4,f=/^[a-f0-9]{64}$/,y=/^[A-Za-z0-9_-]{16,128}$/,A=/^[a-z0-9][a-z0-9._:-]{0,127}$/,S=/^[a-z][a-z0-9._:-]{0,79}$/,_=new Set(["codex","opencode"]),D=new Set(["inspect-session","prepare-license-auth","reconcile-license-auth","authorize-business-replay"]),d=["schemaVersion","referenceId","provider","authDomain","target","operation","scopes","issuedAt","expiresAt","revocationEpoch","subjectDigest","policyDigest","dispatchDigest"];class v extends Error{reasonCode;constructor(r){super(r),this.reasonCode=r,this.name="HostAuthReferenceError"}}function t(s){throw new v(s)}function w(s,r={}){let o=s;if(typeof s=="string"){Buffer.byteLength(s,"utf8")>u&&t("host-auth-reference-oversized");try{o=JSON.parse(s)}catch{t("host-auth-reference-invalid")}}(!o||typeof o!="object"||Array.isArray(o))&&t("host-auth-reference-invalid");const e=o,a=Object.keys(e);(a.length!==d.length||a.some(c=>!d.includes(c)))&&t("host-auth-reference-invalid"),(e.schemaVersion!==p||e.authDomain!=="model-provider")&&t("host-auth-reference-invalid"),(typeof e.provider!="string"||!_.has(e.provider))&&t("host-auth-reference-invalid"),(typeof e.operation!="string"||!D.has(e.operation))&&t("host-auth-operation-denied"),(typeof e.referenceId!="string"||!y.test(e.referenceId)||typeof e.target!="string"||!A.test(e.target)||typeof e.subjectDigest!="string"||!f.test(e.subjectDigest)||typeof e.policyDigest!="string"||!f.test(e.policyDigest)||typeof e.dispatchDigest!="string"||!f.test(e.dispatchDigest))&&t("host-auth-reference-invalid"),(!Array.isArray(e.scopes)||e.scopes.length===0||e.scopes.length>16||e.scopes.some(c=>typeof c!="string"||!S.test(c))||new Set(e.scopes).size!==e.scopes.length)&&t("host-auth-scope-denied"),(!Number.isSafeInteger(e.revocationEpoch)||e.revocationEpoch<0)&&t("host-auth-reference-invalid");const n=Date.parse(String(e.issuedAt)),i=Date.parse(String(e.expiresAt));(!Number.isFinite(n)||!Number.isFinite(i)||i<=n||i-n>E)&&t("host-auth-reference-invalid");const h=r.now??Date.now();(n>h+3e4||!r.allowExpired&&i<=h)&&t("host-auth-reference-expired");const g=JSON.stringify(e);return Buffer.byteLength(g,"utf8")>u&&t("host-auth-reference-oversized"),Object.freeze({...e,scopes:Object.freeze([...e.scopes])})}function R(s){const r=s.now??Date.now(),o=s.ttlMs??3e4,{now:e,ttlMs:a,...n}=s;return w({schemaVersion:p,referenceId:l(18).toString("base64url"),...n,issuedAt:new Date(r).toISOString(),expiresAt:new Date(r+o).toISOString()},{now:r})}export{u as HOST_AUTH_REFERENCE_MAX_BYTES,E as HOST_AUTH_REFERENCE_MAX_TTL_MS,p as HOST_AUTH_REFERENCE_SCHEMA,v as HostAuthReferenceError,R as createHostAuthReference,w as parseHostAuthReference};
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { basename, isAbsolute, join, normalize } from 'node:path';
|
|
3
|
-
/** Explicit isolated profile for local integration runs; the default remains unchanged. */
|
|
4
|
-
export function neocortexProfileDirectory() {
|
|
5
|
-
const override = process.env.NEOCORTEX_PROFILE_DIR;
|
|
6
|
-
if (override === undefined)
|
|
7
|
-
return join(homedir(), '.neocortex');
|
|
8
|
-
const normalized = normalize(override);
|
|
9
|
-
if (!isAbsolute(override) || /[\r\n\0]/.test(override) || basename(normalized) !== '.neocortex') {
|
|
10
|
-
throw new Error('neocortex-profile-dir-invalid');
|
|
11
|
-
}
|
|
12
|
-
return normalized;
|
|
13
|
-
}
|
|
1
|
+
import{homedir as o}from"node:os";import{basename as n,isAbsolute as i,join as t,normalize as c}from"node:path";function s(){const r=process.env.NEOCORTEX_PROFILE_DIR;if(r===void 0)return t(o(),".neocortex");const e=c(r);if(!i(r)||/[\r\n\0]/.test(r)||n(e)!==".neocortex")throw new Error("neocortex-profile-dir-invalid");return e}export{s as neocortexProfileDirectory};
|