@ornexus/neocortex 4.60.68 → 4.60.69
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 +1194 -1194
- 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 +3 -290
- 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 +6 -0
- package/packages/client/dist/commands/invoke.js +142 -7140
- 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 -2536
- 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/git-lifecycle-step-ids.js +1 -14
- package/packages/client/dist/git/git-lifecycle-store.js +9 -1938
- 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/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 -344
- 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/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.js +2 -110
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +8 -1236
- 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.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 -1677
- 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 -185
- 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 -1723
- 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,100 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { isDeepStrictEqual } from 'node:util';
|
|
3
|
-
import { ARCHITECTURE_NON_UI_COMMANDS, ARCHITECTURE_PUBLIC_COMMANDS, parseArchitectureNonUiScopeReceipt } from './shared-architecture-non-ui.js';
|
|
4
|
-
const obj = (x) => !!x && typeof x === 'object' && !Array.isArray(x);
|
|
5
|
-
const commands = ARCHITECTURE_NON_UI_COMMANDS;
|
|
6
|
-
function boundScope(execution) {
|
|
7
|
-
const scope = parseArchitectureNonUiScopeReceipt(execution.nonUiScopeReceipt);
|
|
8
|
-
return scope && scope.targetEpicId === execution.targetEpicId && scope.graphRevision === execution.graphRevision
|
|
9
|
-
&& obj(execution.accounting) && scope.accountingId === execution.accounting.accountingId
|
|
10
|
-
&& obj(execution.evidenceExpectation) && scope.rootInputSha256 === execution.evidenceExpectation.inputHash ? scope : undefined;
|
|
11
|
-
}
|
|
12
|
-
export function architectureMemoryPredecessorCount(execution) {
|
|
13
|
-
if (execution.nonUiScopeReceipt === undefined)
|
|
14
|
-
return ARCHITECTURE_PUBLIC_COMMANDS.length - 1;
|
|
15
|
-
if (!boundScope(execution))
|
|
16
|
-
throw new Error('architecture-non-ui-scope-invalid');
|
|
17
|
-
return commands.length - 1;
|
|
18
|
-
}
|
|
19
|
-
function prefix(rows, n, target, graph) {
|
|
20
|
-
return Array.isArray(rows) && rows.length === n && rows.every((r, i) => obj(r) && r.targetEpicId === target && r.stageCommand === commands[i]
|
|
21
|
-
&& obj(r.completionEvidence) && obj(r.validationEvidence)
|
|
22
|
-
&& r.completionEvidence.stageCommand === r.stageCommand && r.completionEvidence.status === 'succeeded'
|
|
23
|
-
&& r.validationEvidence.stageCommand === r.stageCommand && r.validationEvidence.status === 'passed'
|
|
24
|
-
&& r.completionEvidence.targetEpicId === target && r.validationEvidence.targetEpicId === target
|
|
25
|
-
&& r.completionEvidence.artifactHash === r.validationEvidence.artifactHash
|
|
26
|
-
&& obj(r.validationEvidence.isolated) && obj(r.validationEvidence.regression)
|
|
27
|
-
&& r.validationEvidence.isolated.graphHash === graph && r.validationEvidence.regression.graphHash === graph);
|
|
28
|
-
}
|
|
29
|
-
function approvedReview(r) {
|
|
30
|
-
const d = r.reviewDecision, c = r.completionEvidence, v = r.validationEvidence;
|
|
31
|
-
return obj(d) && obj(c) && obj(v) && d.schemaVersion === 'ArchitectureReviewDecision/1' && d.decision === 'approved'
|
|
32
|
-
&& d.targetEpicId === r.targetEpicId && d.graphRevision === r.graphRevision && d.artifactHash === c.artifactHash
|
|
33
|
-
&& d.artifactHash === v.artifactHash && d.completionReceiptId === c.receiptId && d.validationReceiptId === v.receiptId;
|
|
34
|
-
}
|
|
35
|
-
export function classifyNonUiArchitectureTransition(request, execution, memoryReceiptValid = false) {
|
|
36
|
-
const checkpoint = execution.checkpoint;
|
|
37
|
-
if (!obj(checkpoint))
|
|
38
|
-
return;
|
|
39
|
-
const scope = boundScope(checkpoint);
|
|
40
|
-
if (!scope || scope.targetEpicId !== request.targetEpicId || scope.graphRevision !== request.graphRevision
|
|
41
|
-
|| !obj(request.evidenceExpectation) || scope.rootInputSha256 !== request.evidenceExpectation.inputHash
|
|
42
|
-
|| !obj(request.accounting) || scope.accountingId !== request.accounting.accountingId
|
|
43
|
-
|| request.nonUiScopeReceipt !== undefined && !isDeepStrictEqual(request.nonUiScopeReceipt, scope))
|
|
44
|
-
return;
|
|
45
|
-
const old = request.acceptedStages, next = checkpoint.acceptedStages, idx = commands.indexOf(String(request.currentStageCommand));
|
|
46
|
-
const target = request.targetEpicId, graph = request.graphRevision;
|
|
47
|
-
const same = (key) => isDeepStrictEqual(checkpoint[key], request[key]);
|
|
48
|
-
const idle = request.childStatus === undefined && request.completionEvidence === undefined && request.validationEvidence === undefined;
|
|
49
|
-
const cleared = checkpoint.childStatus === undefined && checkpoint.completionEvidence === undefined && checkpoint.validationEvidence === undefined;
|
|
50
|
-
if (request.currentStageCommand === 'arch-design-system' && request.continuationState === 'advance' && idle && cleared
|
|
51
|
-
&& checkpoint.currentStageCommand === 'arch-performance' && checkpoint.continuationState === 'advance'
|
|
52
|
-
&& execution.nextAction === 'resume' && prefix(old, commands.indexOf('arch-performance'), target, graph) && isDeepStrictEqual(next, old))
|
|
53
|
-
return 'advance';
|
|
54
|
-
if (idx < commands.indexOf('arch-security'))
|
|
55
|
-
return;
|
|
56
|
-
if (request.nonUiScopeReceipt === undefined && request.currentStageCommand !== 'arch-security')
|
|
57
|
-
return;
|
|
58
|
-
if (request.continuationState === 'complete' && request.currentStageCommand === 'update-memory'
|
|
59
|
-
&& checkpoint.continuationState === 'complete' && checkpoint.currentStageCommand === 'update-memory'
|
|
60
|
-
&& execution.nextAction === 'complete' && prefix(old, commands.length, target, graph) && isDeepStrictEqual(next, old)
|
|
61
|
-
&& ['childStatus', 'completionEvidence', 'validationEvidence', 'reviewDecision', 'terminalMemoryCheckpoint'].every(same)
|
|
62
|
-
&& memoryReceiptValid)
|
|
63
|
-
return 'complete-replay';
|
|
64
|
-
if (!prefix(old, idx, target, graph))
|
|
65
|
-
return;
|
|
66
|
-
if (idle && cleared && ['advance', 'delegate'].includes(String(request.continuationState))
|
|
67
|
-
&& checkpoint.currentStageCommand === request.currentStageCommand && checkpoint.continuationState === 'delegate'
|
|
68
|
-
&& execution.nextAction === 'delegate' && isDeepStrictEqual(next, old) && same('reviewDecision'))
|
|
69
|
-
return 'delegate';
|
|
70
|
-
const c = request.completionEvidence, v = request.validationEvidence;
|
|
71
|
-
if (request.childStatus !== 'succeeded' || !obj(c) || !obj(v) || c.status !== 'succeeded' || v.status !== 'passed'
|
|
72
|
-
|| c.stageCommand !== request.currentStageCommand || v.stageCommand !== request.currentStageCommand
|
|
73
|
-
|| c.targetEpicId !== target || v.targetEpicId !== target || c.artifactHash !== v.artifactHash)
|
|
74
|
-
return;
|
|
75
|
-
if (request.currentStageCommand === 'arch-review' && !approvedReview(request)) {
|
|
76
|
-
if (checkpoint.currentStageCommand === 'arch-review' && checkpoint.continuationState === 'ask-user'
|
|
77
|
-
&& execution.nextAction === 'ask-user' && isDeepStrictEqual(next, old)
|
|
78
|
-
&& ['childStatus', 'completionEvidence', 'validationEvidence'].every(same)
|
|
79
|
-
&& isDeepStrictEqual(checkpoint.questionIds, ['ARCH-REVIEW-A09-APPROVAL'])
|
|
80
|
-
&& request.reviewDecision === undefined)
|
|
81
|
-
return 'ask-user';
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
if (request.currentStageCommand === 'arch-review' && (request.continuationState !== 'ask-user'
|
|
85
|
-
|| !isDeepStrictEqual(request.questionIds, ['ARCH-REVIEW-A09-APPROVAL'])))
|
|
86
|
-
return;
|
|
87
|
-
const expected = [...old, { targetEpicId: target, stageCommand: request.currentStageCommand, completionEvidence: c, validationEvidence: v }];
|
|
88
|
-
if (!isDeepStrictEqual(next, expected) || !same('reviewDecision'))
|
|
89
|
-
return;
|
|
90
|
-
if (request.currentStageCommand === 'update-memory') {
|
|
91
|
-
if (checkpoint.currentStageCommand === 'update-memory' && checkpoint.continuationState === 'complete'
|
|
92
|
-
&& execution.nextAction === 'complete' && ['childStatus', 'completionEvidence', 'validationEvidence', 'terminalMemoryCheckpoint'].every(same)
|
|
93
|
-
&& memoryReceiptValid)
|
|
94
|
-
return 'complete';
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (cleared && checkpoint.currentStageCommand === commands[idx + 1] && checkpoint.continuationState === 'advance'
|
|
98
|
-
&& execution.nextAction === 'resume')
|
|
99
|
-
return 'advance';
|
|
100
|
-
}
|
|
1
|
+
import{isDeepStrictEqual as d}from"node:util";import{ARCHITECTURE_NON_UI_COMMANDS as R,ARCHITECTURE_PUBLIC_COMMANDS as A,parseArchitectureNonUiScopeReceipt as y}from"./shared-architecture-non-ui.js";const a=e=>!!e&&typeof e=="object"&&!Array.isArray(e),r=R;function C(e){const t=y(e.nonUiScopeReceipt);return t&&t.targetEpicId===e.targetEpicId&&t.graphRevision===e.graphRevision&&a(e.accounting)&&t.accountingId===e.accounting.accountingId&&a(e.evidenceExpectation)&&t.rootInputSha256===e.evidenceExpectation.inputHash?t:void 0}function D(e){if(e.nonUiScopeReceipt===void 0)return A.length-1;if(!C(e))throw new Error("architecture-non-ui-scope-invalid");return r.length-1}function f(e,t,c,n){return Array.isArray(e)&&e.length===t&&e.every((i,o)=>a(i)&&i.targetEpicId===c&&i.stageCommand===r[o]&&a(i.completionEvidence)&&a(i.validationEvidence)&&i.completionEvidence.stageCommand===i.stageCommand&&i.completionEvidence.status==="succeeded"&&i.validationEvidence.stageCommand===i.stageCommand&&i.validationEvidence.status==="passed"&&i.completionEvidence.targetEpicId===c&&i.validationEvidence.targetEpicId===c&&i.completionEvidence.artifactHash===i.validationEvidence.artifactHash&&a(i.validationEvidence.isolated)&&a(i.validationEvidence.regression)&&i.validationEvidence.isolated.graphHash===n&&i.validationEvidence.regression.graphHash===n)}function H(e){const t=e.reviewDecision,c=e.completionEvidence,n=e.validationEvidence;return a(t)&&a(c)&&a(n)&&t.schemaVersion==="ArchitectureReviewDecision/1"&&t.decision==="approved"&&t.targetEpicId===e.targetEpicId&&t.graphRevision===e.graphRevision&&t.artifactHash===c.artifactHash&&t.artifactHash===n.artifactHash&&t.completionReceiptId===c.receiptId&&t.validationReceiptId===n.receiptId}function O(e,t,c=!1){const n=t.checkpoint;if(!a(n))return;const i=C(n);if(!i||i.targetEpicId!==e.targetEpicId||i.graphRevision!==e.graphRevision||!a(e.evidenceExpectation)||i.rootInputSha256!==e.evidenceExpectation.inputHash||!a(e.accounting)||i.accountingId!==e.accounting.accountingId||e.nonUiScopeReceipt!==void 0&&!d(e.nonUiScopeReceipt,i))return;const o=e.acceptedStages,s=n.acceptedStages,l=r.indexOf(String(e.currentStageCommand)),p=e.targetEpicId,u=e.graphRevision,g=S=>d(n[S],e[S]),h=e.childStatus===void 0&&e.completionEvidence===void 0&&e.validationEvidence===void 0,E=n.childStatus===void 0&&n.completionEvidence===void 0&&n.validationEvidence===void 0;if(e.currentStageCommand==="arch-design-system"&&e.continuationState==="advance"&&h&&E&&n.currentStageCommand==="arch-performance"&&n.continuationState==="advance"&&t.nextAction==="resume"&&f(o,r.indexOf("arch-performance"),p,u)&&d(s,o))return"advance";if(l<r.indexOf("arch-security")||e.nonUiScopeReceipt===void 0&&e.currentStageCommand!=="arch-security")return;if(e.continuationState==="complete"&&e.currentStageCommand==="update-memory"&&n.continuationState==="complete"&&n.currentStageCommand==="update-memory"&&t.nextAction==="complete"&&f(o,r.length,p,u)&&d(s,o)&&["childStatus","completionEvidence","validationEvidence","reviewDecision","terminalMemoryCheckpoint"].every(g)&&c)return"complete-replay";if(!f(o,l,p,u))return;if(h&&E&&["advance","delegate"].includes(String(e.continuationState))&&n.currentStageCommand===e.currentStageCommand&&n.continuationState==="delegate"&&t.nextAction==="delegate"&&d(s,o)&&g("reviewDecision"))return"delegate";const m=e.completionEvidence,v=e.validationEvidence;if(e.childStatus!=="succeeded"||!a(m)||!a(v)||m.status!=="succeeded"||v.status!=="passed"||m.stageCommand!==e.currentStageCommand||v.stageCommand!==e.currentStageCommand||m.targetEpicId!==p||v.targetEpicId!==p||m.artifactHash!==v.artifactHash)return;if(e.currentStageCommand==="arch-review"&&!H(e))return n.currentStageCommand==="arch-review"&&n.continuationState==="ask-user"&&t.nextAction==="ask-user"&&d(s,o)&&["childStatus","completionEvidence","validationEvidence"].every(g)&&d(n.questionIds,["ARCH-REVIEW-A09-APPROVAL"])&&e.reviewDecision===void 0?"ask-user":void 0;if(e.currentStageCommand==="arch-review"&&(e.continuationState!=="ask-user"||!d(e.questionIds,["ARCH-REVIEW-A09-APPROVAL"])))return;const I=[...o,{targetEpicId:p,stageCommand:e.currentStageCommand,completionEvidence:m,validationEvidence:v}];if(!(!d(s,I)||!g("reviewDecision"))){if(e.currentStageCommand==="update-memory")return n.currentStageCommand==="update-memory"&&n.continuationState==="complete"&&t.nextAction==="complete"&&["childStatus","completionEvidence","validationEvidence","terminalMemoryCheckpoint"].every(g)&&c?"complete":void 0;if(E&&n.currentStageCommand===r[l+1]&&n.continuationState==="advance"&&t.nextAction==="resume")return"advance"}}export{D as architectureMemoryPredecessorCount,O as classifyNonUiArchitectureTransition};
|
|
@@ -1,51 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* A first architecture root may bind only to an explicitly selected,
|
|
3
|
-
* committed epic. The digest is stable across stage commits but changes when
|
|
4
|
-
* the epic source changes; it never grants child, Git or billing authority.
|
|
5
|
-
*/
|
|
6
|
-
import { createHash } from 'node:crypto';
|
|
7
|
-
import { execFileSync } from 'node:child_process';
|
|
8
|
-
import { lstatSync, realpathSync } from 'node:fs';
|
|
9
|
-
import { join, resolve } from 'node:path';
|
|
10
|
-
import { resolveClientPreFlightTrigger } from '../tier/tier-aware-client.js';
|
|
11
|
-
const EPIC_ID = /^P[1-9][0-9]{0,11}$/;
|
|
12
|
-
const OID = /^[a-f0-9]{40,64}$/;
|
|
13
|
-
export function explicitArchitectureEpicTarget(args) {
|
|
14
|
-
const match = args.match(/^\s*(\*?[^\s]+)[ \t]+"[^"\n]{1,4096}"[ \t]+@docs\/epics\/epic-(P[1-9][0-9]{0,11})\.md\s*$/);
|
|
15
|
-
return match && resolveClientPreFlightTrigger(match[1]) === 'arch-plan' ? match[2] : undefined;
|
|
16
|
-
}
|
|
17
|
-
export function deriveCommittedArchitectureEpicGraphRevision(projectRoot, epicId) {
|
|
18
|
-
if (!EPIC_ID.test(epicId))
|
|
19
|
-
throw new Error('architecture-root-epic-binding-invalid');
|
|
20
|
-
const root = resolve(projectRoot);
|
|
21
|
-
const relativePath = `docs/epics/epic-${epicId}.md`;
|
|
22
|
-
const path = join(root, relativePath);
|
|
23
|
-
try {
|
|
24
|
-
if (realpathSync(root) !== root)
|
|
25
|
-
throw new Error('architecture-root-epic-binding-invalid');
|
|
26
|
-
if (realpathSync(join(root, 'docs')) !== join(root, 'docs')
|
|
27
|
-
|| realpathSync(join(root, 'docs', 'epics')) !== join(root, 'docs', 'epics')
|
|
28
|
-
|| realpathSync(path) !== path)
|
|
29
|
-
throw new Error('architecture-root-epic-binding-invalid');
|
|
30
|
-
const entry = lstatSync(path);
|
|
31
|
-
if (!entry.isFile() || entry.isSymbolicLink() || entry.size > 256 * 1024) {
|
|
32
|
-
throw new Error('architecture-root-epic-binding-invalid');
|
|
33
|
-
}
|
|
34
|
-
const run = (arguments_) => execFileSync('git', [...arguments_], {
|
|
35
|
-
cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], maxBuffer: 1024 * 1024,
|
|
36
|
-
}).trim();
|
|
37
|
-
if (resolve(run(['rev-parse', '--show-toplevel'])) !== root) {
|
|
38
|
-
throw new Error('architecture-root-epic-binding-invalid');
|
|
39
|
-
}
|
|
40
|
-
const committed = run(['rev-parse', '--verify', `HEAD:${relativePath}`]);
|
|
41
|
-
const working = run(['hash-object', '--', relativePath]);
|
|
42
|
-
const staged = run(['ls-files', '--stage', '--', relativePath]).match(/^100644 ([a-f0-9]{40,64}) 0\t/);
|
|
43
|
-
if (!OID.test(committed) || working !== committed || staged?.[1] !== committed) {
|
|
44
|
-
throw new Error('architecture-root-epic-binding-invalid');
|
|
45
|
-
}
|
|
46
|
-
return createHash('sha256').update(`architecture-committed-epic-v1\0${epicId}\0${committed}`).digest('hex');
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
throw new Error('architecture-root-epic-binding-invalid');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
import{createHash as f}from"node:crypto";import{execFileSync as g}from"node:child_process";import{lstatSync as u,realpathSync as n}from"node:fs";import{join as t,resolve as d}from"node:path";import{resolveClientPreFlightTrigger as v}from"../tier/tier-aware-client.js";const w=/^P[1-9][0-9]{0,11}$/,E=/^[a-f0-9]{40,64}$/;function S(s){const r=s.match(/^\s*(\*?[^\s]+)[ \t]+"[^"\n]{1,4096}"[ \t]+@docs\/epics\/epic-(P[1-9][0-9]{0,11})\.md\s*$/);return r&&v(r[1])==="arch-plan"?r[2]:void 0}function A(s,r){if(!w.test(r))throw new Error("architecture-root-epic-binding-invalid");const i=d(s),e=`docs/epics/epic-${r}.md`,a=t(i,e);try{if(n(i)!==i)throw new Error("architecture-root-epic-binding-invalid");if(n(t(i,"docs"))!==t(i,"docs")||n(t(i,"docs","epics"))!==t(i,"docs","epics")||n(a)!==a)throw new Error("architecture-root-epic-binding-invalid");const h=u(a);if(!h.isFile()||h.isSymbolicLink()||h.size>256*1024)throw new Error("architecture-root-epic-binding-invalid");const o=l=>g("git",[...l],{cwd:i,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:1024*1024}).trim();if(d(o(["rev-parse","--show-toplevel"]))!==i)throw new Error("architecture-root-epic-binding-invalid");const c=o(["rev-parse","--verify",`HEAD:${e}`]),p=o(["hash-object","--",e]),m=o(["ls-files","--stage","--",e]).match(/^100644 ([a-f0-9]{40,64}) 0\t/);if(!E.test(c)||p!==c||m?.[1]!==c)throw new Error("architecture-root-epic-binding-invalid");return f("sha256").update(`architecture-committed-epic-v1\0${r}\0${c}`).digest("hex")}catch{throw new Error("architecture-root-epic-binding-invalid")}}export{A as deriveCommittedArchitectureEpicGraphRevision,S as explicitArchitectureEpicTarget};
|
|
@@ -1,112 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Copyright (c) 2026 OrNexus AI
|
|
4
|
-
*
|
|
5
|
-
* This file is part of Neocortex CLI, licensed under the
|
|
6
|
-
* Functional Source License, Version 1.1 (FSL-1.1).
|
|
7
|
-
*
|
|
8
|
-
* Change Date: February 20, 2029
|
|
9
|
-
* Change License: MIT
|
|
10
|
-
*
|
|
11
|
-
* See the LICENSE file in the project root for full license text.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* @neocortex/client - Cache Status Command
|
|
15
|
-
*
|
|
16
|
-
* Displays comprehensive cache and circuit breaker status information.
|
|
17
|
-
* Shows entry count, total size, age range, stale entries, circuit state,
|
|
18
|
-
* and telemetry queue stats.
|
|
19
|
-
*
|
|
20
|
-
* Story 42.9 - AC7
|
|
21
|
-
*/
|
|
22
|
-
import { readdir, stat } from 'node:fs/promises';
|
|
23
|
-
import { join } from 'node:path';
|
|
24
|
-
// ── Implementation ──────────────────────────────────────────────────────
|
|
25
|
-
/**
|
|
26
|
-
* Gather comprehensive cache status information.
|
|
27
|
-
*/
|
|
28
|
-
export async function getCacheStatus(options) {
|
|
29
|
-
const staleThreshold = options.staleThresholdMs ?? 86_400_000; // 24h default
|
|
30
|
-
let totalEntries = 0;
|
|
31
|
-
let totalSizeBytes = 0;
|
|
32
|
-
let staleEntries = 0;
|
|
33
|
-
let oldestEntry = null;
|
|
34
|
-
let newestEntry = null;
|
|
35
|
-
try {
|
|
36
|
-
const entries = await readdir(options.cacheDir);
|
|
37
|
-
const encFiles = entries.filter((e) => e.endsWith('.enc'));
|
|
38
|
-
totalEntries = encFiles.length;
|
|
39
|
-
const now = Date.now();
|
|
40
|
-
for (const file of encFiles) {
|
|
41
|
-
try {
|
|
42
|
-
const filePath = join(options.cacheDir, file);
|
|
43
|
-
const fileStat = await stat(filePath);
|
|
44
|
-
totalSizeBytes += fileStat.size;
|
|
45
|
-
const mtime = fileStat.mtime;
|
|
46
|
-
if (!oldestEntry || mtime < oldestEntry)
|
|
47
|
-
oldestEntry = mtime;
|
|
48
|
-
if (!newestEntry || mtime > newestEntry)
|
|
49
|
-
newestEntry = mtime;
|
|
50
|
-
if (now - mtime.getTime() > staleThreshold) {
|
|
51
|
-
staleEntries++;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
// Skip files that can't be stat'd
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
// Cache directory doesn't exist or can't be read
|
|
61
|
-
}
|
|
62
|
-
const circuitState = options.circuitBreaker.getState().state;
|
|
63
|
-
let telemetryQueueSize = 0;
|
|
64
|
-
try {
|
|
65
|
-
const queueStats = await options.telemetryQueue.getStats();
|
|
66
|
-
telemetryQueueSize = queueStats.count;
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
// Queue unavailable
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
totalEntries,
|
|
73
|
-
totalSizeBytes,
|
|
74
|
-
totalSizeFormatted: formatBytes(totalSizeBytes),
|
|
75
|
-
oldestEntry,
|
|
76
|
-
newestEntry,
|
|
77
|
-
staleEntries,
|
|
78
|
-
circuitState,
|
|
79
|
-
lastSync: newestEntry, // Most recent cache write approximates last sync
|
|
80
|
-
telemetryQueueSize,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Format cache status as a human-readable string for terminal output.
|
|
85
|
-
*/
|
|
86
|
-
export function formatCacheStatus(info) {
|
|
87
|
-
const lines = [
|
|
88
|
-
'+-------------------------------------------------+',
|
|
89
|
-
'| NEOCORTEX CACHE STATUS |',
|
|
90
|
-
'+-------------------------------------------------+',
|
|
91
|
-
`| Total entries: ${String(info.totalEntries).padEnd(29)}|`,
|
|
92
|
-
`| Total size: ${info.totalSizeFormatted.padEnd(29)}|`,
|
|
93
|
-
`| Oldest entry: ${(info.oldestEntry?.toISOString() ?? 'N/A').padEnd(29)}|`,
|
|
94
|
-
`| Newest entry: ${(info.newestEntry?.toISOString() ?? 'N/A').padEnd(29)}|`,
|
|
95
|
-
`| Stale entries: ${String(info.staleEntries).padEnd(29)}|`,
|
|
96
|
-
'|-------------------------------------------------|',
|
|
97
|
-
`| Circuit breaker: ${info.circuitState.padEnd(29)}|`,
|
|
98
|
-
`| Last sync: ${(info.lastSync?.toISOString() ?? 'N/A').padEnd(29)}|`,
|
|
99
|
-
`| Telemetry queue: ${(info.telemetryQueueSize + ' events').padEnd(29)}|`,
|
|
100
|
-
'+-------------------------------------------------+',
|
|
101
|
-
];
|
|
102
|
-
return lines.join('\n');
|
|
103
|
-
}
|
|
104
|
-
// ── Helpers ─────────────────────────────────────────────────────────────
|
|
105
|
-
function formatBytes(bytes) {
|
|
106
|
-
if (bytes === 0)
|
|
107
|
-
return '0 B';
|
|
108
|
-
const units = ['B', 'KB', 'MB', 'GB'];
|
|
109
|
-
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
110
|
-
const value = bytes / Math.pow(1024, i);
|
|
111
|
-
return `${value.toFixed(i === 0 ? 0 : 1)} ${units[i]}`;
|
|
112
|
-
}
|
|
1
|
+
import{readdir as y,stat as g}from"node:fs/promises";import{join as f}from"node:path";async function T(t){const r=t.staleThresholdMs??864e5;let e=0,s=0,c=0,i=null,a=null;try{const u=(await y(t.cacheDir)).filter(l=>l.endsWith(".enc"));e=u.length;const h=Date.now();for(const l of u)try{const m=f(t.cacheDir,l),d=await g(m);s+=d.size;const n=d.mtime;(!i||n<i)&&(i=n),(!a||n>a)&&(a=n),h-n.getTime()>r&&c++}catch{}}catch{}const S=t.circuitBreaker.getState().state;let o=0;try{o=(await t.telemetryQueue.getStats()).count}catch{}return{totalEntries:e,totalSizeBytes:s,totalSizeFormatted:$(s),oldestEntry:i,newestEntry:a,staleEntries:c,circuitState:S,lastSync:a,telemetryQueueSize:o}}function B(t){return["+-------------------------------------------------+","| NEOCORTEX CACHE STATUS |","+-------------------------------------------------+",`| Total entries: ${String(t.totalEntries).padEnd(29)}|`,`| Total size: ${t.totalSizeFormatted.padEnd(29)}|`,`| Oldest entry: ${(t.oldestEntry?.toISOString()??"N/A").padEnd(29)}|`,`| Newest entry: ${(t.newestEntry?.toISOString()??"N/A").padEnd(29)}|`,`| Stale entries: ${String(t.staleEntries).padEnd(29)}|`,"|-------------------------------------------------|",`| Circuit breaker: ${t.circuitState.padEnd(29)}|`,`| Last sync: ${(t.lastSync?.toISOString()??"N/A").padEnd(29)}|`,`| Telemetry queue: ${(t.telemetryQueueSize+" events").padEnd(29)}|`,"+-------------------------------------------------+"].join(`
|
|
2
|
+
`)}function $(t){if(t===0)return"0 B";const r=["B","KB","MB","GB"],e=Math.floor(Math.log(t)/Math.log(1024));return`${(t/Math.pow(1024,e)).toFixed(e===0?0:1)} ${r[e]}`}export{B as formatCacheStatus,T as getCacheStatus};
|
|
@@ -1,88 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { detectPlatform } from '../adapters/platform-detector.js';
|
|
3
|
-
import { ApprovalPolicyConfigError, getSubagentApprovalPolicy, resetSubagentApprovalMode, setSubagentApprovalMode, } from '../config.js';
|
|
4
|
-
function renderResult(result, json) {
|
|
5
|
-
const payload = {
|
|
6
|
-
evidence: SUBAGENT_APPROVAL_EVIDENCE,
|
|
7
|
-
...result.resolution,
|
|
8
|
-
auditEvent: result.auditEvent?.event,
|
|
9
|
-
};
|
|
10
|
-
if (json)
|
|
11
|
-
return JSON.stringify(payload, null, 2);
|
|
12
|
-
return [
|
|
13
|
-
SUBAGENT_APPROVAL_EVIDENCE,
|
|
14
|
-
`requested=${payload.requestedMode}`,
|
|
15
|
-
`effective=${payload.effectiveMode}`,
|
|
16
|
-
`source=${payload.source}`,
|
|
17
|
-
`scope=${payload.scope}`,
|
|
18
|
-
`platform=${payload.platformTarget}`,
|
|
19
|
-
`reason=${payload.effectiveReason}`,
|
|
20
|
-
`fallback=${payload.fallbackMode}`,
|
|
21
|
-
`fallbackReason=${payload.fallbackReasonCode ?? 'none'}`,
|
|
22
|
-
].join(' ');
|
|
23
|
-
}
|
|
24
|
-
export async function configCliHandler(args, dependencies = {}) {
|
|
25
|
-
const stdout = dependencies.stdout ?? console.log;
|
|
26
|
-
const stderr = dependencies.stderr ?? console.error;
|
|
27
|
-
let action = 'status';
|
|
28
|
-
let platformTarget;
|
|
29
|
-
let json = false;
|
|
30
|
-
let actionSeen = false;
|
|
31
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
32
|
-
const value = args[index];
|
|
33
|
-
if (value === '--json') {
|
|
34
|
-
json = true;
|
|
35
|
-
}
|
|
36
|
-
else if (value === '--platform-target') {
|
|
37
|
-
platformTarget = args[index + 1];
|
|
38
|
-
index += 1;
|
|
39
|
-
if (!platformTarget) {
|
|
40
|
-
stderr('Error: --platform-target requires a value.');
|
|
41
|
-
return 1;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else if (!actionSeen &&
|
|
45
|
-
(value === 'status' ||
|
|
46
|
-
value === 'max' ||
|
|
47
|
-
value === 'standard' ||
|
|
48
|
-
value === 'disabled' ||
|
|
49
|
-
value === 'reset')) {
|
|
50
|
-
action = value;
|
|
51
|
-
actionSeen = true;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
stderr('Error: expected status, max, standard, disabled, or reset.');
|
|
55
|
-
return 1;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const env = dependencies.env ?? process.env;
|
|
59
|
-
const detection = detectPlatform({
|
|
60
|
-
cwd: dependencies.cwd ?? process.cwd(),
|
|
61
|
-
env,
|
|
62
|
-
targetFlag: platformTarget,
|
|
63
|
-
});
|
|
64
|
-
const hostPolicy = deriveSubagentHostApprovalPolicy(detection.targetId);
|
|
65
|
-
const options = {
|
|
66
|
-
configFilePath: dependencies.configFilePath,
|
|
67
|
-
platformTarget: detection.targetId,
|
|
68
|
-
hostPolicy,
|
|
69
|
-
now: dependencies.now,
|
|
70
|
-
};
|
|
71
|
-
try {
|
|
72
|
-
const result = action === 'status'
|
|
73
|
-
? getSubagentApprovalPolicy(options)
|
|
74
|
-
: action === 'reset'
|
|
75
|
-
? resetSubagentApprovalMode(options)
|
|
76
|
-
: setSubagentApprovalMode(action, options);
|
|
77
|
-
stdout(renderResult(result, json));
|
|
78
|
-
return 0;
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
if (error instanceof ApprovalPolicyConfigError) {
|
|
82
|
-
stderr(`Error: ${error.reasonCode}`);
|
|
83
|
-
return 1;
|
|
84
|
-
}
|
|
85
|
-
stderr('Error: approval-policy-update-failed');
|
|
86
|
-
return 1;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
1
|
+
import{SUBAGENT_APPROVAL_EVIDENCE as d,deriveSubagentHostApprovalPolicy as v}from"../policy/subagent-approval-policy.js";import{detectPlatform as m}from"../adapters/platform-detector.js";import{ApprovalPolicyConfigError as E,getSubagentApprovalPolicy as b,resetSubagentApprovalMode as y,setSubagentApprovalMode as P}from"../config.js";function $(a,r){const t={evidence:d,...a.resolution,auditEvent:a.auditEvent?.event};return r?JSON.stringify(t,null,2):[d,`requested=${t.requestedMode}`,`effective=${t.effectiveMode}`,`source=${t.source}`,`scope=${t.scope}`,`platform=${t.platformTarget}`,`reason=${t.effectiveReason}`,`fallback=${t.fallbackMode}`,`fallbackReason=${t.fallbackReasonCode??"none"}`].join(" ")}async function w(a,r={}){const t=r.stdout??console.log,n=r.stderr??console.error;let s="status",l,i=!1,f=!1;for(let e=0;e<a.length;e+=1){const o=a[e];if(o==="--json")i=!0;else if(o==="--platform-target"){if(l=a[e+1],e+=1,!l)return n("Error: --platform-target requires a value."),1}else if(!f&&(o==="status"||o==="max"||o==="standard"||o==="disabled"||o==="reset"))s=o,f=!0;else return n("Error: expected status, max, standard, disabled, or reset."),1}const p=r.env??process.env,u=m({cwd:r.cwd??process.cwd(),env:p,targetFlag:l}),g=v(u.targetId),c={configFilePath:r.configFilePath,platformTarget:u.targetId,hostPolicy:g,now:r.now};try{const e=s==="status"?b(c):s==="reset"?y(c):P(s,c);return t($(e,i)),0}catch(e){return e instanceof E?(n(`Error: ${e.reasonCode}`),1):(n("Error: approval-policy-update-failed"),1)}}export{w as configCliHandler};
|