@ornexus/neocortex 4.60.71 → 4.60.73
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 +1211 -1217
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/package.json +2 -2
- package/packages/client/dist/adapters/adapter-registry.js +108 -1
- package/packages/client/dist/adapters/antigravity-adapter.js +77 -2
- package/packages/client/dist/adapters/claude-code-adapter.js +79 -3
- package/packages/client/dist/adapters/codex-adapter.js +80 -2
- package/packages/client/dist/adapters/cursor-adapter.js +115 -4
- package/packages/client/dist/adapters/gemini-adapter.js +71 -2
- package/packages/client/dist/adapters/grok-adapter.js +42 -2
- package/packages/client/dist/adapters/index.js +22 -1
- package/packages/client/dist/adapters/platform-detector.js +212 -1
- package/packages/client/dist/adapters/target-adapter.js +12 -0
- package/packages/client/dist/adapters/vscode-adapter.js +72 -2
- package/packages/client/dist/agent/refresh-stubs.js +417 -2
- package/packages/client/dist/agent/update-agent-yaml.js +102 -1
- package/packages/client/dist/agent/update-description.js +251 -1
- package/packages/client/dist/cache/crypto-utils.js +78 -1
- package/packages/client/dist/cache/encrypted-cache.js +108 -1
- package/packages/client/dist/cache/in-memory-asset-cache.js +73 -1
- package/packages/client/dist/cache/index.js +13 -1
- package/packages/client/dist/cache/protected-pi-boundary.js +44 -1
- package/packages/client/dist/checkpoint/checkpoint-client-reader.js +127 -2
- package/packages/client/dist/checkpoint/index.js +11 -1
- package/packages/client/dist/checkpoint/shared-checkpoint-types.js +32 -1
- package/packages/client/dist/cli.js +358 -5
- package/packages/client/dist/commands/activate.js +394 -8
- package/packages/client/dist/commands/architecture-answers.js +274 -7
- package/packages/client/dist/commands/architecture-memory-terminal.js +253 -4
- package/packages/client/dist/commands/architecture-non-ui-continuation.js +100 -1
- package/packages/client/dist/commands/architecture-root-binding.js +51 -1
- package/packages/client/dist/commands/cache-status.js +112 -2
- package/packages/client/dist/commands/config.js +88 -1
- package/packages/client/dist/commands/doctor.js +635 -2
- package/packages/client/dist/commands/invoke.js +7200 -143
- package/packages/client/dist/commands/legacy-epic-terminal.js +71 -1
- package/packages/client/dist/commands/legacy-story-branch.js +96 -1
- package/packages/client/dist/commands/legacy-story-pr.js +276 -1
- package/packages/client/dist/commands/mutation-qa-checkpoint.js +285 -5
- package/packages/client/dist/commands/mutation-qa-gate.js +54 -1
- package/packages/client/dist/commands/mutation-qa-git.js +41 -1
- package/packages/client/dist/commands/mutation-qa-policy.js +102 -1
- package/packages/client/dist/commands/mutation-qa-run.js +219 -3
- package/packages/client/dist/commands/mutation-qa-verdict.js +149 -1
- package/packages/client/dist/commands/mutation-qa.js +220 -1
- package/packages/client/dist/commands/native-agent.js +136 -2
- package/packages/client/dist/commands/planning-diagnosis.js +43 -1
- package/packages/client/dist/commands/planning-generation.js +53 -1
- package/packages/client/dist/commands/planning-memory.js +40 -1
- package/packages/client/dist/commands/planning-research.js +42 -1
- package/packages/client/dist/commands/private-session.js +75 -1
- package/packages/client/dist/commands/property-qa.js +139 -1
- package/packages/client/dist/commands/qa-control.js +16 -1
- package/packages/client/dist/commands/qa-scan-browser-launch.js +55 -1
- package/packages/client/dist/commands/qa-scan-browser-route.js +28 -1
- package/packages/client/dist/commands/qa-scan-capture.js +663 -5
- package/packages/client/dist/commands/qa-scan-discovery.js +376 -3
- package/packages/client/dist/commands/qa-scan-review.js +826 -5
- package/packages/client/dist/commands/qa-synthetic-backend-capture.js +266 -1
- package/packages/client/dist/commands/qa-synthetic-backend-review.js +297 -1
- package/packages/client/dist/commands/qa-synthetic-backend.js +340 -2
- package/packages/client/dist/commands/qa-synthetic-broker-port.js +85 -1
- package/packages/client/dist/commands/qa-synthetic-browser.js +39 -1
- package/packages/client/dist/commands/refactor-characterization.js +671 -21
- package/packages/client/dist/commands/refactor-commit.js +399 -13
- package/packages/client/dist/commands/refactor-control.js +142 -3
- package/packages/client/dist/commands/refactor-cpp-assertions.js +93 -3
- package/packages/client/dist/commands/refactor-review.js +283 -5
- package/packages/client/dist/commands/refactor-root.js +588 -7
- package/packages/client/dist/commands/refresh-memory.js +156 -3
- package/packages/client/dist/commands/shared-architecture-non-ui.js +24 -1
- package/packages/client/dist/commands/story-checkpoint.js +171 -1
- package/packages/client/dist/config/profile-directory.js +13 -1
- package/packages/client/dist/config/resolver-selection.js +278 -1
- package/packages/client/dist/config/secure-config.js +281 -12
- package/packages/client/dist/config.js +223 -2
- package/packages/client/dist/constants.js +25 -1
- package/packages/client/dist/context/context-collector.js +222 -2
- package/packages/client/dist/context/context-sanitizer.js +145 -1
- package/packages/client/dist/continuity/autonomous-governance.js +285 -1
- package/packages/client/dist/continuity/continuity-client-state-store.js +1587 -1
- package/packages/client/dist/continuity/invoke-hooks.js +129 -1
- package/packages/client/dist/continuity/migrations/001-initial-schema.js +12 -2
- package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +12 -2
- package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +12 -2
- package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +12 -2
- package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +12 -2
- package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +10 -2
- package/packages/client/dist/continuity/native-agent-store.js +69 -1
- package/packages/client/dist/continuity/native-agent-types.js +90 -1
- package/packages/client/dist/continuity/outbox.js +117 -1
- package/packages/client/dist/continuity/runner-bootstrap-policy.js +172 -1
- package/packages/client/dist/continuity/sqlite-store.d.ts +22 -1
- package/packages/client/dist/continuity/sqlite-store.js +2612 -81
- package/packages/client/dist/effects/invoke-effect-gateways.js +62 -1
- package/packages/client/dist/errors/error-messages.js +228 -2
- package/packages/client/dist/errors/frontmatter-diagnostics.js +125 -1
- package/packages/client/dist/evidence/collector.js +347 -1
- package/packages/client/dist/evidence/index.js +1 -1
- package/packages/client/dist/evidence/types.js +2 -0
- package/packages/client/dist/fs/atomic-state-replace.js +152 -1
- package/packages/client/dist/generated/command-registry.generated.js +4076 -1
- package/packages/client/dist/generated/public-projections.generated.js +149 -1
- package/packages/client/dist/git/direct-yolo-c01-retry.js +138 -4
- package/packages/client/dist/git/direct-yolo-checkpoint.js +1234 -4
- package/packages/client/dist/git/epic-operational-state.d.ts +198 -0
- package/packages/client/dist/git/epic-operational-state.js +672 -0
- package/packages/client/dist/git/git-lifecycle-step-ids.js +14 -1
- package/packages/client/dist/git/git-lifecycle-store.d.ts +9 -1
- package/packages/client/dist/git/git-lifecycle-store.js +1981 -9
- package/packages/client/dist/git/legacy-story-branch-checkpoint.js +259 -9
- package/packages/client/dist/git/legacy-story-branch-setup.js +348 -4
- package/packages/client/dist/git/legacy-story-pr.js +3538 -70
- package/packages/client/dist/git/secure-filesystem-boundary.js +182 -5
- package/packages/client/dist/graph-retrieval/pre-command-hook.js +284 -1
- package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +237 -1
- package/packages/client/dist/i18n/first-run.js +60 -2
- package/packages/client/dist/index.js +47 -1
- package/packages/client/dist/invocation/invoke-input.js +24 -1
- package/packages/client/dist/license/index.js +5 -1
- package/packages/client/dist/license/license-client.js +304 -1
- package/packages/client/dist/machine/fingerprint.js +163 -2
- package/packages/client/dist/machine/index.js +5 -1
- package/packages/client/dist/memory/project-memory-path-scope.js +62 -1
- package/packages/client/dist/memory/project-memory-writer.js +1007 -40
- package/packages/client/dist/memory/shared-project-memory-types.js +253 -2
- package/packages/client/dist/migrations/epic-lifecycle-backfill.d.ts +97 -0
- package/packages/client/dist/migrations/epic-lifecycle-backfill.js +1060 -0
- package/packages/client/dist/migrations/project-identity-capability.js +50 -1
- package/packages/client/dist/migrations/project-identity.js +493 -7
- package/packages/client/dist/migrations/state-json.d.ts +22 -0
- package/packages/client/dist/migrations/state-json.js +393 -4
- package/packages/client/dist/policy/architecture-policy.js +184 -2
- package/packages/client/dist/policy/index.js +7 -1
- package/packages/client/dist/policy/shared-policy-types.js +38 -0
- package/packages/client/dist/policy/subagent-approval-policy.js +55 -1
- package/packages/client/dist/private-execution/clean-baseline.js +279 -2
- package/packages/client/dist/private-execution/codex-executor.js +574 -4
- package/packages/client/dist/private-execution/codex-host-runtime.js +137 -1
- package/packages/client/dist/private-execution/codex-lifecycle-guard.js +97 -1
- package/packages/client/dist/private-execution/codex-scoped-permissions.js +128 -1
- package/packages/client/dist/private-execution/delivery.js +410 -13
- package/packages/client/dist/private-execution/diagnosis-root-review.js +294 -2
- package/packages/client/dist/private-execution/frozen-handoff.js +19 -6
- package/packages/client/dist/private-execution/implementation-validation.js +106 -2
- package/packages/client/dist/private-execution/isolated-admission.js +1432 -23
- package/packages/client/dist/private-execution/isolated-session.js +725 -5
- package/packages/client/dist/private-execution/isolated-workspace.js +122 -1
- package/packages/client/dist/private-execution/pact-consumer-runtime.js +409 -3
- package/packages/client/dist/private-execution/pact-test-source.js +258 -1
- package/packages/client/dist/private-execution/pact-toolchain.js +290 -3
- package/packages/client/dist/private-execution/pact-write-set.js +172 -1
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +406 -5
- package/packages/client/dist/private-execution/planning-generation-checkpoint.js +462 -5
- package/packages/client/dist/private-execution/planning-memory-checkpoint.js +139 -3
- package/packages/client/dist/private-execution/planning-research-checkpoint.js +325 -4
- package/packages/client/dist/private-execution/private-report-store.js +42 -1
- package/packages/client/dist/private-execution/property-test-candidate.js +103 -1
- package/packages/client/dist/private-execution/property-test-choices.js +147 -3
- package/packages/client/dist/private-execution/property-test-plan.js +271 -7
- package/packages/client/dist/private-execution/property-test-review.js +258 -4
- package/packages/client/dist/private-execution/property-test-runtime.js +372 -9
- package/packages/client/dist/private-execution/property-test-source.js +139 -1
- package/packages/client/dist/private-execution/root-checkpoint.js +80 -1
- package/packages/client/dist/private-execution/root-memory-git-evidence.js +135 -3
- package/packages/client/dist/private-execution/root-memory-recovery.js +93 -1
- package/packages/client/dist/private-execution/root-memory-request.js +29 -1
- package/packages/client/dist/private-execution/root-memory-scope.js +178 -1
- package/packages/client/dist/private-execution/root-memory-writer.js +102 -1
- package/packages/client/dist/private-execution/session-lease.js +63 -1
- package/packages/client/dist/private-execution/shared-private-admission-types.js +50 -1
- package/packages/client/dist/private-execution/shared-project-validation.js +66 -1
- package/packages/client/dist/private-execution/shared-root-memory-types.js +61 -1
- package/packages/client/dist/private-execution/ux-source-validation.js +372 -1
- package/packages/client/dist/private-execution/ux-write-set.js +191 -2
- package/packages/client/dist/registry/registry-reconciliation.js +234 -1
- package/packages/client/dist/resilience/circuit-breaker.js +170 -1
- package/packages/client/dist/resilience/degradation-manager.js +164 -1
- package/packages/client/dist/resilience/freshness-indicator.js +100 -1
- package/packages/client/dist/resilience/index.js +8 -1
- package/packages/client/dist/resilience/recovery-detector.js +74 -1
- package/packages/client/dist/resolvers/asset-resolver.js +13 -0
- package/packages/client/dist/resolvers/local-resolver.js +255 -8
- package/packages/client/dist/resolvers/remote-resolver.js +233 -1
- package/packages/client/dist/runner/binary.js +404 -1
- package/packages/client/dist/runner/cli.js +1571 -17
- package/packages/client/dist/runner/headless/adapters.js +49 -1
- package/packages/client/dist/runner/headless/claude-code-adapter.js +79 -1
- package/packages/client/dist/runner/headless/continuous-story-workspace.js +1628 -11
- package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +69 -1
- package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +110 -2
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +1236 -8
- package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +318 -2
- package/packages/client/dist/runner/headless/fake-adapter.js +62 -1
- package/packages/client/dist/runner/headless/managed-profile.js +132 -1
- package/packages/client/dist/runner/headless/opencode-adapter.js +145 -2
- package/packages/client/dist/runner/headless/prepared-story-bundle.js +43 -1
- package/packages/client/dist/runner/headless/resolver.js +231 -1
- package/packages/client/dist/runner/headless/run-yolo.js +885 -1
- package/packages/client/dist/runner/headless/run-yoloop.js +2574 -2
- package/packages/client/dist/runner/headless/types.js +574 -2
- package/packages/client/dist/runner/local-console.js +396 -13
- package/packages/client/dist/runner/portal-sync-worker.js +1487 -1
- package/packages/client/dist/runner/project-identity.js +106 -1
- package/packages/client/dist/runner/scheduler.js +995 -7
- package/packages/client/dist/runner-cli.js +18 -2
- package/packages/client/dist/state/invocation-shape.js +13 -1
- package/packages/client/dist/state/project-state-snapshot.d.ts +8 -0
- package/packages/client/dist/state/project-state-snapshot.js +1731 -1
- package/packages/client/dist/state/state-json-repair.js +785 -3
- package/packages/client/dist/state/structural-dag-projection.js +118 -1
- package/packages/client/dist/telemetry/index.js +5 -1
- package/packages/client/dist/telemetry/offline-queue.js +131 -1
- package/packages/client/dist/tier/index.js +5 -1
- package/packages/client/dist/tier/tier-aware-client.js +405 -1
- package/packages/client/dist/types/index.js +38 -1
- package/packages/client/dist/version.js +27 -1
- package/packages/client/dist/yolo/change-evidence-collector.js +126 -1
- package/packages/client/dist/yolo/invoke-envelope-capability.js +62 -1
- package/packages/client/dist/yolo/spec-envelope-collector.js +184 -5
- package/packages/client/dist/yoloop/discovery-hook.js +300 -2
- package/packages/client/dist/yoloop/index.js +8 -1
- package/packages/client/dist/yoloop/invoke-hooks.js +669 -12
- package/packages/client/dist/yoloop/shared-discover-epics.js +1007 -1
- package/packages/client/dist/yoloop/shared-yoloop-types.d.ts +65 -1
- package/packages/client/dist/yoloop/shared-yoloop-types.js +33 -1
- package/packages/client/dist/yoloop/target-normalization.js +180 -1
- package/packages/client/dist/yoloop/yoloop-client-state-store.d.ts +8 -0
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1920 -1
- package/packages/shared/dist/yolo/spec-envelope.js +3 -6
- 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 +1,100 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
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 - Freshness Indicator
|
|
15
|
+
*
|
|
16
|
+
* Enriches cache responses with freshness metadata for user-facing display.
|
|
17
|
+
* Formats cache age as human-readable strings and generates appropriate
|
|
18
|
+
* warning prefixes based on degradation level.
|
|
19
|
+
*
|
|
20
|
+
* Story 42.9
|
|
21
|
+
*/
|
|
22
|
+
import { DegradationLevel } from './degradation-manager.js';
|
|
23
|
+
// ── Defaults ──────────────────────────────────────────────────────────────
|
|
24
|
+
const DEFAULT_CONFIG = {
|
|
25
|
+
staleThresholdMs: 86_400_000, // 24 hours
|
|
26
|
+
warningThresholdMs: 43_200_000, // 12 hours
|
|
27
|
+
};
|
|
28
|
+
// ── FreshnessIndicator ──────────────────────────────────────────────────
|
|
29
|
+
export class FreshnessIndicator {
|
|
30
|
+
config;
|
|
31
|
+
constructor(config) {
|
|
32
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Format a duration in ms as human-readable age string.
|
|
36
|
+
* Examples: "30m ago", "4h ago", "2d ago"
|
|
37
|
+
*/
|
|
38
|
+
formatAge(ageMs) {
|
|
39
|
+
if (ageMs < 0)
|
|
40
|
+
return 'just now';
|
|
41
|
+
const seconds = Math.floor(ageMs / 1_000);
|
|
42
|
+
const minutes = Math.floor(ageMs / 60_000);
|
|
43
|
+
const hours = Math.floor(ageMs / 3_600_000);
|
|
44
|
+
const days = Math.floor(ageMs / 86_400_000);
|
|
45
|
+
if (days >= 1)
|
|
46
|
+
return `${days}d ago`;
|
|
47
|
+
if (hours >= 1)
|
|
48
|
+
return `${hours}h ago`;
|
|
49
|
+
if (minutes >= 1)
|
|
50
|
+
return `${minutes}m ago`;
|
|
51
|
+
if (seconds >= 1)
|
|
52
|
+
return `${seconds}s ago`;
|
|
53
|
+
return 'just now';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Evaluate freshness of a cache entry.
|
|
57
|
+
*/
|
|
58
|
+
evaluate(cacheAgeMs, _ttlMs) {
|
|
59
|
+
const stale = cacheAgeMs > this.config.staleThresholdMs;
|
|
60
|
+
const aged = cacheAgeMs > this.config.warningThresholdMs;
|
|
61
|
+
let warning = null;
|
|
62
|
+
let prefix = '[CACHED]';
|
|
63
|
+
if (stale) {
|
|
64
|
+
const ageStr = this.formatAge(cacheAgeMs);
|
|
65
|
+
prefix = `[STALE CACHE - ${ageStr}]`;
|
|
66
|
+
warning = `WARNING: STALE - cached ${ageStr}`;
|
|
67
|
+
}
|
|
68
|
+
else if (aged) {
|
|
69
|
+
const ageStr = this.formatAge(cacheAgeMs);
|
|
70
|
+
prefix = `[CACHED]`;
|
|
71
|
+
warning = `WARNING - cached ${ageStr}`;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
cached: true,
|
|
75
|
+
cacheAgeMs,
|
|
76
|
+
stale,
|
|
77
|
+
warning,
|
|
78
|
+
prefix,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Format prefix string based on degradation level and optional age.
|
|
83
|
+
*/
|
|
84
|
+
formatPrefix(level, ageMs) {
|
|
85
|
+
switch (level) {
|
|
86
|
+
case DegradationLevel.ONLINE:
|
|
87
|
+
return '';
|
|
88
|
+
case DegradationLevel.HIGH_LATENCY:
|
|
89
|
+
return ageMs != null ? `[CACHED] cached ${this.formatAge(ageMs)}` : '[CACHED]';
|
|
90
|
+
case DegradationLevel.SERVER_DOWN:
|
|
91
|
+
return ageMs != null ? `[CACHED] cached ${this.formatAge(ageMs)}` : '[CACHED]';
|
|
92
|
+
case DegradationLevel.STALE_CACHE:
|
|
93
|
+
return ageMs != null ? `[STALE CACHE - ${this.formatAge(ageMs)}]` : '[STALE CACHE]';
|
|
94
|
+
case DegradationLevel.NO_CACHE:
|
|
95
|
+
return '[ERROR]';
|
|
96
|
+
default:
|
|
97
|
+
return '';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*/
|
|
5
|
+
export { ClientCircuitBreaker } from './circuit-breaker.js';
|
|
6
|
+
export { DegradationManager, DegradationLevel } from './degradation-manager.js';
|
|
7
|
+
export { FreshnessIndicator } from './freshness-indicator.js';
|
|
8
|
+
export { RecoveryDetector } from './recovery-detector.js';
|
|
@@ -1 +1,74 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
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
|
+
// ── RecoveryDetector ─────────────────────────────────────────────────────
|
|
14
|
+
export class RecoveryDetector {
|
|
15
|
+
actions;
|
|
16
|
+
constructor(actions) {
|
|
17
|
+
this.actions = actions;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Execute full recovery sequence.
|
|
21
|
+
* Each step is independent - failures are captured but don't block others.
|
|
22
|
+
*/
|
|
23
|
+
async onRecovery() {
|
|
24
|
+
const result = {
|
|
25
|
+
circuitClosed: false,
|
|
26
|
+
jwtRefreshed: false,
|
|
27
|
+
cacheSynced: false,
|
|
28
|
+
telemetryFlushed: { sent: 0, failed: 0 },
|
|
29
|
+
notification: '[ONLINE] Server connection restored',
|
|
30
|
+
};
|
|
31
|
+
// Step 1: Close circuit breaker
|
|
32
|
+
try {
|
|
33
|
+
await this.actions.circuitBreaker.recordSuccess();
|
|
34
|
+
result.circuitClosed = true;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Non-critical: breaker will close on next successful call
|
|
38
|
+
}
|
|
39
|
+
// Step 2: Re-validate JWT
|
|
40
|
+
try {
|
|
41
|
+
const token = await this.actions.licenseClient.getToken();
|
|
42
|
+
result.jwtRefreshed = token !== null;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Non-critical: will be retried on next server call
|
|
46
|
+
}
|
|
47
|
+
// Step 3: Sync cache (background - just attempt, don't block)
|
|
48
|
+
try {
|
|
49
|
+
// We don't actually sync here - the next resolver call will
|
|
50
|
+
// update the cache automatically via fetchWithCacheFallback.
|
|
51
|
+
// We just mark as synced since the circuit is now closed.
|
|
52
|
+
result.cacheSynced = true;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Non-critical
|
|
56
|
+
}
|
|
57
|
+
// Step 4: Flush telemetry queue
|
|
58
|
+
try {
|
|
59
|
+
const flushResult = await this.actions.telemetryQueue.flush(async (events) => {
|
|
60
|
+
const response = await fetch(`${this.actions.serverUrl}/api/v1/telemetry/batch`, {
|
|
61
|
+
method: 'POST',
|
|
62
|
+
headers: { 'Content-Type': 'application/json' },
|
|
63
|
+
body: JSON.stringify({ events }),
|
|
64
|
+
});
|
|
65
|
+
return response.ok;
|
|
66
|
+
});
|
|
67
|
+
result.telemetryFlushed = flushResult;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Non-critical: queue will be flushed on next recovery
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
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
|
+
export {};
|
|
@@ -1,8 +1,255 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
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 - LocalResolver
|
|
15
|
+
*
|
|
16
|
+
* Resolves pipeline assets from the local filesystem.
|
|
17
|
+
* Used in development mode when core/ directory is available locally.
|
|
18
|
+
* Replicates the current CLI behavior of reading .md files directly.
|
|
19
|
+
*/
|
|
20
|
+
import { readFile, access } from 'node:fs/promises';
|
|
21
|
+
import { join, resolve } from 'node:path';
|
|
22
|
+
import { ResolverMode, } from '../types/index.js';
|
|
23
|
+
// ── Frontmatter Parser ───────────────────────────────────────────────────
|
|
24
|
+
const FRONTMATTER_REGEX = /^---\n([\s\S]*?)\n---/;
|
|
25
|
+
/**
|
|
26
|
+
* Parse YAML-like frontmatter from markdown content.
|
|
27
|
+
* Simple key-value parser sufficient for step/skill frontmatter.
|
|
28
|
+
*/
|
|
29
|
+
function parseFrontmatter(content) {
|
|
30
|
+
const match = content.match(FRONTMATTER_REGEX);
|
|
31
|
+
if (!match) {
|
|
32
|
+
return { frontmatter: {}, body: content };
|
|
33
|
+
}
|
|
34
|
+
const frontmatter = {};
|
|
35
|
+
const lines = match[1].split('\n');
|
|
36
|
+
for (const line of lines) {
|
|
37
|
+
const colonIndex = line.indexOf(':');
|
|
38
|
+
if (colonIndex === -1)
|
|
39
|
+
continue;
|
|
40
|
+
const key = line.slice(0, colonIndex).trim().replace(/^['"]|['"]$/g, '');
|
|
41
|
+
let value = line.slice(colonIndex + 1).trim();
|
|
42
|
+
// Remove surrounding quotes
|
|
43
|
+
if (typeof value === 'string') {
|
|
44
|
+
value = value.replace(/^['"]|['"]$/g, '');
|
|
45
|
+
}
|
|
46
|
+
// Parse booleans
|
|
47
|
+
if (value === 'true')
|
|
48
|
+
value = true;
|
|
49
|
+
else if (value === 'false')
|
|
50
|
+
value = false;
|
|
51
|
+
frontmatter[key] = value;
|
|
52
|
+
}
|
|
53
|
+
const body = content.slice(match[0].length).trimStart();
|
|
54
|
+
return { frontmatter, body };
|
|
55
|
+
}
|
|
56
|
+
// ── LocalResolver Implementation ─────────────────────────────────────────
|
|
57
|
+
export class LocalResolver {
|
|
58
|
+
mode = ResolverMode.LOCAL;
|
|
59
|
+
projectRoot;
|
|
60
|
+
stepPathIndex;
|
|
61
|
+
constructor(options) {
|
|
62
|
+
this.projectRoot = resolve(options.projectRoot);
|
|
63
|
+
}
|
|
64
|
+
async resolveStep(stepId, _context) {
|
|
65
|
+
const relativePath = (await this.resolveStepPathIndex()).get(stepId);
|
|
66
|
+
if (!relativePath)
|
|
67
|
+
throw new Error(`Step '${stepId}' is not present in the canonical registry`);
|
|
68
|
+
const fullPath = join(this.projectRoot, relativePath);
|
|
69
|
+
const raw = await readFile(fullPath, 'utf-8');
|
|
70
|
+
const { frontmatter, body } = parseFrontmatter(raw);
|
|
71
|
+
return {
|
|
72
|
+
id: stepId,
|
|
73
|
+
content: body,
|
|
74
|
+
frontmatter,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
resolveStepPathIndex() {
|
|
78
|
+
this.stepPathIndex ??= this.loadStepPathIndex();
|
|
79
|
+
return this.stepPathIndex;
|
|
80
|
+
}
|
|
81
|
+
async loadStepPathIndex() {
|
|
82
|
+
const registryPath = join(this.projectRoot, 'core', 'data', 'step-registry.json');
|
|
83
|
+
const parsed = JSON.parse(await readFile(registryPath, 'utf8'));
|
|
84
|
+
const index = new Map();
|
|
85
|
+
const bootstrap = parsed['asset_bootstrap'];
|
|
86
|
+
if (bootstrap && typeof bootstrap === 'object' && !Array.isArray(bootstrap)) {
|
|
87
|
+
const assets = bootstrap['assets'];
|
|
88
|
+
if (!Array.isArray(assets))
|
|
89
|
+
throw new Error('manifest-generation-mismatch');
|
|
90
|
+
for (const raw of assets) {
|
|
91
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
92
|
+
throw new Error('manifest-schema-invalid');
|
|
93
|
+
const asset = raw;
|
|
94
|
+
if (asset['type'] !== 'step')
|
|
95
|
+
continue;
|
|
96
|
+
const assetPath = asset['relative_path'];
|
|
97
|
+
if (typeof assetPath !== 'string' || !assetPath.startsWith('steps/') || assetPath.includes('..')) {
|
|
98
|
+
throw new Error('manifest-schema-invalid');
|
|
99
|
+
}
|
|
100
|
+
const relativePath = `core/${assetPath}`;
|
|
101
|
+
const { frontmatter } = parseFrontmatter(await readFile(join(this.projectRoot, relativePath), 'utf8'));
|
|
102
|
+
const id = frontmatter['id'];
|
|
103
|
+
if (typeof id !== 'string' || !/^step-[a-z0-9][a-z0-9._-]*$/.test(id)) {
|
|
104
|
+
throw new Error('manifest-required-step-unresolved');
|
|
105
|
+
}
|
|
106
|
+
if (index.has(id))
|
|
107
|
+
throw new Error('manifest-duplicate-reference');
|
|
108
|
+
index.set(id, relativePath);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// Explicit legacy partial projection: exact registry files only, with no
|
|
113
|
+
// category/path inference after a miss.
|
|
114
|
+
const groups = parsed['steps'];
|
|
115
|
+
if (!groups || typeof groups !== 'object' || Array.isArray(groups))
|
|
116
|
+
throw new Error('manifest-generation-mismatch');
|
|
117
|
+
for (const entries of Object.values(groups)) {
|
|
118
|
+
if (!Array.isArray(entries))
|
|
119
|
+
continue;
|
|
120
|
+
for (const raw of entries) {
|
|
121
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
122
|
+
throw new Error('manifest-schema-invalid');
|
|
123
|
+
const entry = raw;
|
|
124
|
+
const id = entry['id'];
|
|
125
|
+
const file = entry['file'];
|
|
126
|
+
if (typeof id !== 'string' || typeof file !== 'string' || !file.startsWith('core/steps/') || file.includes('..')) {
|
|
127
|
+
throw new Error('manifest-schema-invalid');
|
|
128
|
+
}
|
|
129
|
+
if (index.has(id))
|
|
130
|
+
throw new Error('manifest-duplicate-reference');
|
|
131
|
+
index.set(id, file);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (index.size === 0)
|
|
136
|
+
throw new Error('manifest-generation-mismatch');
|
|
137
|
+
return index;
|
|
138
|
+
}
|
|
139
|
+
async resolveSkill(skillId, _context) {
|
|
140
|
+
// Skills are organized in: core/skills/{category}/{skillId}.md
|
|
141
|
+
// or: core/skills/step-skills/{step}/{skillId}.md
|
|
142
|
+
// Try multiple paths to find the skill
|
|
143
|
+
const searchPaths = [
|
|
144
|
+
`core/skills/${skillId}.md`,
|
|
145
|
+
`core/skills/step-skills/${skillId}.md`,
|
|
146
|
+
];
|
|
147
|
+
// Also try with nested path: "diagnose/prompt-enricher" -> core/skills/step-skills/diagnose/prompt-enricher.md
|
|
148
|
+
if (skillId.includes('/')) {
|
|
149
|
+
searchPaths.unshift(`core/skills/step-skills/${skillId}.md`);
|
|
150
|
+
searchPaths.unshift(`core/skills/${skillId}.md`);
|
|
151
|
+
}
|
|
152
|
+
let raw = null;
|
|
153
|
+
let resolvedPath = '';
|
|
154
|
+
for (const searchPath of searchPaths) {
|
|
155
|
+
const fullPath = join(this.projectRoot, searchPath);
|
|
156
|
+
try {
|
|
157
|
+
raw = await readFile(fullPath, 'utf-8');
|
|
158
|
+
resolvedPath = searchPath;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// Try next path
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (raw === null) {
|
|
166
|
+
throw new Error(`Skill '${skillId}' not found. Searched: ${searchPaths.join(', ')}`);
|
|
167
|
+
}
|
|
168
|
+
const { frontmatter, body } = parseFrontmatter(raw);
|
|
169
|
+
return {
|
|
170
|
+
id: skillId,
|
|
171
|
+
content: body,
|
|
172
|
+
metadata: { ...frontmatter, resolvedPath },
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async resolveStandard(standardId) {
|
|
176
|
+
const fullPath = join(this.projectRoot, 'core', 'standards', standardId);
|
|
177
|
+
let content;
|
|
178
|
+
try {
|
|
179
|
+
content = await readFile(fullPath, 'utf-8');
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// Try with .md extension if not present
|
|
183
|
+
if (!standardId.endsWith('.md')) {
|
|
184
|
+
content = await readFile(`${fullPath}.md`, 'utf-8');
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
throw new Error(`Standard '${standardId}' not found at ${fullPath}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
id: standardId,
|
|
192
|
+
content,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
async resolveRegistry() {
|
|
196
|
+
const fullPath = join(this.projectRoot, 'core', 'data', 'step-registry.json');
|
|
197
|
+
const raw = await readFile(fullPath, 'utf-8');
|
|
198
|
+
return JSON.parse(raw);
|
|
199
|
+
}
|
|
200
|
+
async assemblePrompt(stepId, context) {
|
|
201
|
+
// Resolve the step content
|
|
202
|
+
const step = await this.resolveStep(stepId, context);
|
|
203
|
+
// Build variables map from context
|
|
204
|
+
const variables = {
|
|
205
|
+
'{story_id}': context.storyId,
|
|
206
|
+
'{story_title}': context.storyTitle,
|
|
207
|
+
'{step_id}': stepId,
|
|
208
|
+
'{step_name}': step.frontmatter['name'] || stepId,
|
|
209
|
+
'{current_status}': context.currentStatus,
|
|
210
|
+
'{epic_id}': context.epicId,
|
|
211
|
+
'{branch_name}': context.branchName,
|
|
212
|
+
'{platform_target}': context.platformTarget,
|
|
213
|
+
};
|
|
214
|
+
// Substitute variables in step content
|
|
215
|
+
let prompt = step.content;
|
|
216
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
217
|
+
prompt = prompt.replaceAll(key, value);
|
|
218
|
+
}
|
|
219
|
+
// Resolve skills referenced in step frontmatter
|
|
220
|
+
const includedSkills = [];
|
|
221
|
+
const skillsRef = step.frontmatter['skills'];
|
|
222
|
+
if (skillsRef && typeof skillsRef === 'string') {
|
|
223
|
+
const skillIds = skillsRef.split(',').map((s) => s.trim());
|
|
224
|
+
for (const sid of skillIds) {
|
|
225
|
+
try {
|
|
226
|
+
const skill = await this.resolveSkill(sid, context);
|
|
227
|
+
prompt += `\n\n---\n\n# Skill: ${sid}\n\n${skill.content}`;
|
|
228
|
+
includedSkills.push(sid);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
// Skill not found - skip
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
prompt,
|
|
237
|
+
variables,
|
|
238
|
+
includedSkills,
|
|
239
|
+
includedStandards: [],
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
async isAvailable() {
|
|
243
|
+
try {
|
|
244
|
+
const corePath = join(this.projectRoot, 'core');
|
|
245
|
+
await access(corePath);
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
async dispose() {
|
|
253
|
+
// LocalResolver holds no resources to release
|
|
254
|
+
}
|
|
255
|
+
}
|