@ornexus/neocortex 4.60.67 → 4.60.68
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.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 +290 -3
- 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 +7140 -142
- 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.js +2536 -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/git-lifecycle-step-ids.js +14 -1
- package/packages/client/dist/git/git-lifecycle-store.js +1938 -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/project-identity-capability.js +50 -1
- package/packages/client/dist/migrations/project-identity.js +493 -7
- package/packages/client/dist/migrations/state-json.js +344 -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/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.js +1677 -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 +185 -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.js +33 -1
- package/packages/client/dist/yoloop/target-normalization.js +180 -1
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1723 -1
- 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,212 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* Platform Detector - Auto-detects the current platform target.
|
|
6
|
+
*
|
|
7
|
+
* Uses explicit selection and runtime environment signals to identify which AI
|
|
8
|
+
* coding platform owns the current process. Filesystem markers can corroborate
|
|
9
|
+
* a runtime signal, but never select a platform by themselves.
|
|
10
|
+
*
|
|
11
|
+
* Detection priority:
|
|
12
|
+
* 1. --target flag (explicit override)
|
|
13
|
+
* 2. Unambiguous platform-owned runtime signal
|
|
14
|
+
* 3. Weak editor runtime signal when no agent runtime signal exists
|
|
15
|
+
* 4. Fail-closed fallback -> unknown
|
|
16
|
+
*
|
|
17
|
+
* Story 42.8
|
|
18
|
+
*/
|
|
19
|
+
import { existsSync } from 'node:fs';
|
|
20
|
+
import { join } from 'node:path';
|
|
21
|
+
const SAFE_HOST_VERSION = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/;
|
|
22
|
+
/**
|
|
23
|
+
* Build a bounded Codex host attestation independently from platform selection.
|
|
24
|
+
* Explicit target flags can select a fallback target, but never become trusted
|
|
25
|
+
* native-host evidence.
|
|
26
|
+
*/
|
|
27
|
+
export function detectNativeHostAttestation(context, detection = detectPlatform(context)) {
|
|
28
|
+
if (detection.targetId !== 'codex')
|
|
29
|
+
return undefined;
|
|
30
|
+
const hasCodexRuntime = [
|
|
31
|
+
'CODEX_THREAD_ID',
|
|
32
|
+
'CODEX_SESSION_ID',
|
|
33
|
+
'CODEX_SANDBOX_NETWORK_DISABLED',
|
|
34
|
+
].some((key) => context.env[key] !== undefined);
|
|
35
|
+
const desktopObserved = hasCodexRuntime && context.env.CODEX_REMOTE_PAYLOAD !== undefined;
|
|
36
|
+
const hostKind = desktopObserved
|
|
37
|
+
? 'codex-desktop'
|
|
38
|
+
: hasCodexRuntime
|
|
39
|
+
? 'codex-cli'
|
|
40
|
+
: 'unknown';
|
|
41
|
+
const candidateVersion = context.nativeHostVersion?.trim() ?? '';
|
|
42
|
+
const hostVersion = SAFE_HOST_VERSION.test(candidateVersion) ? candidateVersion : null;
|
|
43
|
+
const explicitOnly = !!context.targetFlag && !hasCodexRuntime;
|
|
44
|
+
return Object.freeze({
|
|
45
|
+
schemaVersion: 1,
|
|
46
|
+
platformTarget: 'codex',
|
|
47
|
+
hostKind,
|
|
48
|
+
hostVersion,
|
|
49
|
+
origin: explicitOnly
|
|
50
|
+
? 'explicit-override'
|
|
51
|
+
: desktopObserved
|
|
52
|
+
? 'host-observed'
|
|
53
|
+
: hasCodexRuntime
|
|
54
|
+
? 'environment'
|
|
55
|
+
: 'unknown',
|
|
56
|
+
confidence: explicitOnly || hostKind === 'unknown'
|
|
57
|
+
? 'unknown'
|
|
58
|
+
: desktopObserved
|
|
59
|
+
? 'observed'
|
|
60
|
+
: 'inferred',
|
|
61
|
+
publicSafe: true,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// ── Valid Target IDs ────────────────────────────────────────────────────────
|
|
65
|
+
const VALID_TARGETS = new Set([
|
|
66
|
+
'claude-code',
|
|
67
|
+
'cursor',
|
|
68
|
+
'vscode',
|
|
69
|
+
'gemini',
|
|
70
|
+
'codex',
|
|
71
|
+
'opencode',
|
|
72
|
+
'github-copilot-cli',
|
|
73
|
+
'kimi',
|
|
74
|
+
'antigravity',
|
|
75
|
+
'openclaw',
|
|
76
|
+
'grok',
|
|
77
|
+
'runner',
|
|
78
|
+
'unknown',
|
|
79
|
+
]);
|
|
80
|
+
const TARGET_ALIASES = Object.freeze({
|
|
81
|
+
claude: 'claude-code',
|
|
82
|
+
'claude-code': 'claude-code',
|
|
83
|
+
cursor: 'cursor',
|
|
84
|
+
vscode: 'vscode',
|
|
85
|
+
'vscode-copilot': 'vscode',
|
|
86
|
+
gemini: 'gemini',
|
|
87
|
+
'gemini-cli': 'gemini',
|
|
88
|
+
codex: 'codex',
|
|
89
|
+
'codex-cli': 'codex',
|
|
90
|
+
opencode: 'opencode',
|
|
91
|
+
'copilot-cli': 'github-copilot-cli',
|
|
92
|
+
'github-copilot-cli': 'github-copilot-cli',
|
|
93
|
+
kimi: 'kimi',
|
|
94
|
+
antigravity: 'antigravity',
|
|
95
|
+
openclaw: 'openclaw',
|
|
96
|
+
'open-claw': 'openclaw',
|
|
97
|
+
grok: 'grok',
|
|
98
|
+
'grok-build': 'grok',
|
|
99
|
+
runner: 'runner',
|
|
100
|
+
unknown: 'unknown',
|
|
101
|
+
});
|
|
102
|
+
/** Check if a string is a valid TargetId */
|
|
103
|
+
export function isValidTargetId(value) {
|
|
104
|
+
return VALID_TARGETS.has(value);
|
|
105
|
+
}
|
|
106
|
+
export function normalizeTargetId(value) {
|
|
107
|
+
return TARGET_ALIASES[value.trim().toLowerCase()] ?? null;
|
|
108
|
+
}
|
|
109
|
+
const defaultFileExists = (path) => existsSync(path);
|
|
110
|
+
// ── Detection Function ──────────────────────────────────────────────────────
|
|
111
|
+
/**
|
|
112
|
+
* Detect the current platform target based on the execution context.
|
|
113
|
+
*
|
|
114
|
+
* @param context - Detection context with cwd, env, and optional target flag
|
|
115
|
+
* @param fileExists - Injectable filesystem check (for testing)
|
|
116
|
+
* @returns Detection result with target ID, confidence, and reason
|
|
117
|
+
*/
|
|
118
|
+
export function detectPlatform(context, fileExists = defaultFileExists) {
|
|
119
|
+
// 1. Explicit --target flag (highest priority)
|
|
120
|
+
if (context.targetFlag) {
|
|
121
|
+
const normalized = normalizeTargetId(context.targetFlag);
|
|
122
|
+
if (normalized) {
|
|
123
|
+
return {
|
|
124
|
+
targetId: normalized,
|
|
125
|
+
confidence: 1.0,
|
|
126
|
+
reason: `Explicit --target=${normalized} flag`,
|
|
127
|
+
reasonCode: 'platform-target-explicit',
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
targetId: 'unknown',
|
|
132
|
+
confidence: 0,
|
|
133
|
+
reason: 'Explicit platform target is not recognized',
|
|
134
|
+
reasonCode: 'platform-target-invalid-override',
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const envIsSet = (key) => context.env[key] !== undefined;
|
|
138
|
+
const candidates = [];
|
|
139
|
+
const addCandidate = (targetId, signal, keys) => {
|
|
140
|
+
if (keys.some(envIsSet))
|
|
141
|
+
candidates.push({ targetId, signal });
|
|
142
|
+
};
|
|
143
|
+
addCandidate('claude-code', 'Claude Code runtime', ['CLAUDE_CODE', 'CLAUDE_AGENT']);
|
|
144
|
+
addCandidate('codex', 'Codex runtime', [
|
|
145
|
+
'CODEX_THREAD_ID',
|
|
146
|
+
'CODEX_SESSION_ID',
|
|
147
|
+
'CODEX_SANDBOX_NETWORK_DISABLED',
|
|
148
|
+
]);
|
|
149
|
+
addCandidate('opencode', 'OpenCode runtime', ['OPENCODE', 'OPENCODE_SESSION_ID']);
|
|
150
|
+
addCandidate('cursor', 'Cursor runtime', ['CURSOR_SESSION_ID', 'CURSOR_TRACE_ID']);
|
|
151
|
+
addCandidate('gemini', 'Gemini CLI runtime', ['GEMINI_CLI']);
|
|
152
|
+
addCandidate('github-copilot-cli', 'GitHub Copilot CLI runtime', ['COPILOT_CLI']);
|
|
153
|
+
addCandidate('kimi', 'Kimi Code runtime', ['KIMI_SESSION_ID', 'KIMI_CODE_SESSION_ID']);
|
|
154
|
+
addCandidate('antigravity', 'Antigravity runtime', [
|
|
155
|
+
'ANTIGRAVITY_SESSION_ID',
|
|
156
|
+
'ANTIGRAVITY_AGENT',
|
|
157
|
+
]);
|
|
158
|
+
addCandidate('openclaw', 'OpenClaw runtime', ['OPENCLAW_SESSION_ID', 'OPENCLAW_GATEWAY']);
|
|
159
|
+
addCandidate('grok', 'Grok Build runtime', ['GROK_SESSION_ID', 'GROK_AGENT', 'GROK_HOME']);
|
|
160
|
+
const uniqueCandidates = [...new Map(candidates.map((candidate) => [candidate.targetId, candidate])).values()];
|
|
161
|
+
if (uniqueCandidates.length > 1) {
|
|
162
|
+
return {
|
|
163
|
+
targetId: 'unknown',
|
|
164
|
+
confidence: 0,
|
|
165
|
+
reason: `Conflicting runtime platform signals: ${uniqueCandidates.map(({ targetId }) => targetId).sort().join(', ')}`,
|
|
166
|
+
reasonCode: 'platform-target-ambiguous',
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
if (uniqueCandidates.length === 1) {
|
|
170
|
+
const candidate = uniqueCandidates[0];
|
|
171
|
+
const corroboratingMarkers = {
|
|
172
|
+
'claude-code': 'CLAUDE.md',
|
|
173
|
+
codex: 'AGENTS.md',
|
|
174
|
+
cursor: '.cursor',
|
|
175
|
+
gemini: 'GEMINI.md',
|
|
176
|
+
vscode: '.vscode',
|
|
177
|
+
grok: 'AGENTS.md',
|
|
178
|
+
};
|
|
179
|
+
const marker = corroboratingMarkers[candidate.targetId];
|
|
180
|
+
const corroborated = marker ? fileExists(join(context.cwd, marker)) : false;
|
|
181
|
+
return {
|
|
182
|
+
targetId: candidate.targetId,
|
|
183
|
+
confidence: corroborated ? 0.98 : 0.95,
|
|
184
|
+
reason: `${candidate.signal} signal${corroborated ? ` corroborated by ${marker}` : ''}`,
|
|
185
|
+
reasonCode: 'platform-target-runtime-signal',
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
// Editor terminals are a weaker signal than an agent-owned process marker.
|
|
189
|
+
if (envIsSet('VSCODE_PID') || context.env['TERM_PROGRAM'] === 'vscode') {
|
|
190
|
+
return {
|
|
191
|
+
targetId: 'vscode',
|
|
192
|
+
confidence: 0.75,
|
|
193
|
+
reason: 'VS Code runtime signal without a stronger agent runtime signal',
|
|
194
|
+
reasonCode: 'platform-target-runtime-signal',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const filesystemMarkers = ['AGENTS.md', '.cursor', '.cursorrules', 'CLAUDE.md', '.vscode', 'GEMINI.md'];
|
|
198
|
+
if (filesystemMarkers.some((marker) => fileExists(join(context.cwd, marker)))) {
|
|
199
|
+
return {
|
|
200
|
+
targetId: 'unknown',
|
|
201
|
+
confidence: 0,
|
|
202
|
+
reason: 'Filesystem marker found without platform-owned runtime evidence',
|
|
203
|
+
reasonCode: 'platform-target-filesystem-only',
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
targetId: 'unknown',
|
|
208
|
+
confidence: 0,
|
|
209
|
+
reason: 'No platform runtime signals detected',
|
|
210
|
+
reasonCode: 'platform-target-unknown',
|
|
211
|
+
};
|
|
212
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* TargetAdapter Interface - Core abstraction for platform-specific prompt formatting.
|
|
6
|
+
*
|
|
7
|
+
* Each platform target (Claude Code, Cursor, VS Code, Gemini CLI, Codex, Antigravity)
|
|
8
|
+
* implements this interface to transform assembled prompts into platform-native format.
|
|
9
|
+
*
|
|
10
|
+
* Story 42.8
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
@@ -1,2 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* VS Code Adapter - Formats prompts for VS Code extension chat participant API.
|
|
6
|
+
*
|
|
7
|
+
* VS Code uses extensions and the chat API for AI interactions.
|
|
8
|
+
* This adapter formats prompts as system messages with structured
|
|
9
|
+
* instruction blocks suitable for the chat participant API.
|
|
10
|
+
*
|
|
11
|
+
* Story 42.8
|
|
12
|
+
*/
|
|
13
|
+
// ── Constants ───────────────────────────────────────────────────────────────
|
|
14
|
+
const TARGET_ID = 'vscode';
|
|
15
|
+
const MAX_CONTEXT_LENGTH = 128_000;
|
|
16
|
+
const CAPABILITIES = {
|
|
17
|
+
supportsMarkdown: true,
|
|
18
|
+
supportsMultiFile: true,
|
|
19
|
+
supportsMultiTurn: true,
|
|
20
|
+
supportsTools: true,
|
|
21
|
+
maxContextLength: MAX_CONTEXT_LENGTH,
|
|
22
|
+
};
|
|
23
|
+
// ── Implementation ──────────────────────────────────────────────────────────
|
|
24
|
+
export class VSCodeAdapter {
|
|
25
|
+
formatPrompt(assembledPrompt, platformInstructions, config) {
|
|
26
|
+
const sections = [];
|
|
27
|
+
// System instruction block for VS Code chat
|
|
28
|
+
sections.push('<system-instructions>');
|
|
29
|
+
sections.push(assembledPrompt);
|
|
30
|
+
sections.push('</system-instructions>');
|
|
31
|
+
// Tool definitions block
|
|
32
|
+
if (platformInstructions.tools && platformInstructions.tools.length > 0) {
|
|
33
|
+
sections.push('');
|
|
34
|
+
sections.push('<available-tools>');
|
|
35
|
+
for (const tool of platformInstructions.tools) {
|
|
36
|
+
sections.push(`- ${tool}`);
|
|
37
|
+
}
|
|
38
|
+
sections.push('</available-tools>');
|
|
39
|
+
}
|
|
40
|
+
// MCP configuration block
|
|
41
|
+
if (platformInstructions.mcpConfig && Object.keys(platformInstructions.mcpConfig).length > 0) {
|
|
42
|
+
sections.push('');
|
|
43
|
+
sections.push('<mcp-config>');
|
|
44
|
+
sections.push(JSON.stringify(platformInstructions.mcpConfig, null, 2));
|
|
45
|
+
sections.push('</mcp-config>');
|
|
46
|
+
}
|
|
47
|
+
// Context files as instruction references
|
|
48
|
+
if (platformInstructions.contextFiles && platformInstructions.contextFiles.length > 0) {
|
|
49
|
+
sections.push('');
|
|
50
|
+
sections.push('<context-files>');
|
|
51
|
+
for (const file of platformInstructions.contextFiles) {
|
|
52
|
+
sections.push(file);
|
|
53
|
+
}
|
|
54
|
+
sections.push('</context-files>');
|
|
55
|
+
}
|
|
56
|
+
let result = sections.join('\n');
|
|
57
|
+
const maxLength = config.maxPromptLength ?? MAX_CONTEXT_LENGTH;
|
|
58
|
+
if (result.length > maxLength) {
|
|
59
|
+
result = result.slice(0, maxLength);
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
getTargetId() {
|
|
64
|
+
return TARGET_ID;
|
|
65
|
+
}
|
|
66
|
+
getCapabilities() {
|
|
67
|
+
return CAPABILITIES;
|
|
68
|
+
}
|
|
69
|
+
getInjectionMethod() {
|
|
70
|
+
return 'api';
|
|
71
|
+
}
|
|
72
|
+
}
|