@ornexus/neocortex 4.61.5 → 4.62.0

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.
Files changed (279) hide show
  1. package/dist/release-source.json +1 -1
  2. package/dist/sbom.cdx.json +1193 -1193
  3. package/install.ps1 +31 -34
  4. package/install.sh +1 -1
  5. package/package.json +5 -2
  6. package/packages/client/dist/adapters/adapter-registry.js +1 -108
  7. package/packages/client/dist/adapters/antigravity-adapter.js +2 -77
  8. package/packages/client/dist/adapters/claude-code-adapter.js +3 -79
  9. package/packages/client/dist/adapters/codex-adapter.js +2 -80
  10. package/packages/client/dist/adapters/cursor-adapter.js +4 -115
  11. package/packages/client/dist/adapters/gemini-adapter.js +2 -71
  12. package/packages/client/dist/adapters/grok-adapter.js +2 -42
  13. package/packages/client/dist/adapters/index.js +1 -22
  14. package/packages/client/dist/adapters/platform-detector.js +1 -220
  15. package/packages/client/dist/adapters/target-adapter.js +0 -12
  16. package/packages/client/dist/adapters/vscode-adapter.js +2 -72
  17. package/packages/client/dist/agent/refresh-stubs.js +2 -443
  18. package/packages/client/dist/agent/update-agent-yaml.js +1 -102
  19. package/packages/client/dist/agent/update-description.d.ts +8 -1
  20. package/packages/client/dist/agent/update-description.js +2 -260
  21. package/packages/client/dist/cache/crypto-utils.js +1 -78
  22. package/packages/client/dist/cache/encrypted-cache.js +1 -338
  23. package/packages/client/dist/cache/in-memory-asset-cache.js +1 -73
  24. package/packages/client/dist/cache/index.js +1 -13
  25. package/packages/client/dist/cache/protected-pi-boundary.js +1 -44
  26. package/packages/client/dist/checkpoint/checkpoint-client-reader.js +2 -127
  27. package/packages/client/dist/checkpoint/index.js +1 -11
  28. package/packages/client/dist/checkpoint/shared-checkpoint-types.js +1 -32
  29. package/packages/client/dist/cli.js +5 -364
  30. package/packages/client/dist/commands/activate.js +8 -394
  31. package/packages/client/dist/commands/architecture-answers.js +7 -274
  32. package/packages/client/dist/commands/architecture-memory-terminal.js +4 -253
  33. package/packages/client/dist/commands/architecture-non-ui-continuation.js +1 -100
  34. package/packages/client/dist/commands/architecture-root-binding.js +1 -51
  35. package/packages/client/dist/commands/cache-status.js +2 -112
  36. package/packages/client/dist/commands/config.js +1 -88
  37. package/packages/client/dist/commands/doctor.js +2 -635
  38. package/packages/client/dist/commands/invoke.d.ts +17 -0
  39. package/packages/client/dist/commands/invoke.js +148 -7822
  40. package/packages/client/dist/commands/legacy-epic-terminal.js +1 -71
  41. package/packages/client/dist/commands/legacy-story-branch.js +1 -96
  42. package/packages/client/dist/commands/legacy-story-pr.js +1 -276
  43. package/packages/client/dist/commands/mutation-qa-checkpoint.js +5 -285
  44. package/packages/client/dist/commands/mutation-qa-gate.js +1 -54
  45. package/packages/client/dist/commands/mutation-qa-git.js +1 -41
  46. package/packages/client/dist/commands/mutation-qa-policy.js +1 -102
  47. package/packages/client/dist/commands/mutation-qa-run.js +3 -219
  48. package/packages/client/dist/commands/mutation-qa-verdict.js +1 -149
  49. package/packages/client/dist/commands/mutation-qa.js +1 -220
  50. package/packages/client/dist/commands/native-agent.js +2 -136
  51. package/packages/client/dist/commands/planning-diagnosis.js +1 -43
  52. package/packages/client/dist/commands/planning-generation.js +1 -53
  53. package/packages/client/dist/commands/planning-memory.js +1 -40
  54. package/packages/client/dist/commands/planning-research.js +1 -42
  55. package/packages/client/dist/commands/private-session.js +1 -75
  56. package/packages/client/dist/commands/property-qa.js +1 -139
  57. package/packages/client/dist/commands/qa-control.js +1 -16
  58. package/packages/client/dist/commands/qa-scan-browser-launch.js +1 -55
  59. package/packages/client/dist/commands/qa-scan-browser-route.js +1 -28
  60. package/packages/client/dist/commands/qa-scan-capture.js +5 -663
  61. package/packages/client/dist/commands/qa-scan-discovery.js +3 -376
  62. package/packages/client/dist/commands/qa-scan-review.js +5 -826
  63. package/packages/client/dist/commands/qa-synthetic-backend-capture.js +1 -266
  64. package/packages/client/dist/commands/qa-synthetic-backend-review.js +1 -297
  65. package/packages/client/dist/commands/qa-synthetic-backend.js +2 -340
  66. package/packages/client/dist/commands/qa-synthetic-broker-port.js +1 -85
  67. package/packages/client/dist/commands/qa-synthetic-browser.js +1 -39
  68. package/packages/client/dist/commands/refactor-characterization.js +21 -671
  69. package/packages/client/dist/commands/refactor-commit.js +13 -399
  70. package/packages/client/dist/commands/refactor-control.js +3 -142
  71. package/packages/client/dist/commands/refactor-cpp-assertions.js +3 -93
  72. package/packages/client/dist/commands/refactor-review.js +5 -283
  73. package/packages/client/dist/commands/refactor-root.js +7 -588
  74. package/packages/client/dist/commands/refresh-memory.js +3 -174
  75. package/packages/client/dist/commands/shared-architecture-non-ui.js +1 -24
  76. package/packages/client/dist/commands/story-checkpoint.d.ts +5 -1
  77. package/packages/client/dist/commands/story-checkpoint.js +1 -203
  78. package/packages/client/dist/commands/story-worktree.js +5 -258
  79. package/packages/client/dist/config/host-auth-broker.js +1 -60
  80. package/packages/client/dist/config/host-auth-reference.js +1 -93
  81. package/packages/client/dist/config/profile-directory.js +1 -13
  82. package/packages/client/dist/config/resolver-selection.js +1 -278
  83. package/packages/client/dist/config/secure-config.js +12 -281
  84. package/packages/client/dist/config.js +2 -224
  85. package/packages/client/dist/constants.js +1 -25
  86. package/packages/client/dist/context/context-collector.js +2 -222
  87. package/packages/client/dist/context/context-sanitizer.js +1 -145
  88. package/packages/client/dist/continuity/autonomous-governance.js +1 -285
  89. package/packages/client/dist/continuity/continuity-client-state-store.js +1 -1587
  90. package/packages/client/dist/continuity/invoke-hooks.js +1 -129
  91. package/packages/client/dist/continuity/migrations/001-initial-schema.js +2 -12
  92. package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +2 -12
  93. package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +2 -12
  94. package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +2 -12
  95. package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +2 -12
  96. package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +2 -10
  97. package/packages/client/dist/continuity/native-agent-store.js +1 -69
  98. package/packages/client/dist/continuity/native-agent-types.js +1 -105
  99. package/packages/client/dist/continuity/outbox.js +1 -117
  100. package/packages/client/dist/continuity/runner-bootstrap-policy.js +1 -172
  101. package/packages/client/dist/continuity/sqlite-store.js +81 -2612
  102. package/packages/client/dist/effects/invoke-effect-gateways.js +1 -62
  103. package/packages/client/dist/errors/error-messages.js +2 -258
  104. package/packages/client/dist/errors/frontmatter-diagnostics.d.ts +10 -1
  105. package/packages/client/dist/errors/frontmatter-diagnostics.js +1 -125
  106. package/packages/client/dist/evidence/collector.js +1 -347
  107. package/packages/client/dist/evidence/index.js +1 -1
  108. package/packages/client/dist/evidence/types.js +0 -2
  109. package/packages/client/dist/fs/atomic-state-replace.js +1 -152
  110. package/packages/client/dist/generated/command-registry.generated.js +1 -4076
  111. package/packages/client/dist/generated/public-projections.generated.js +1 -149
  112. package/packages/client/dist/git/direct-yolo-c01-retry.js +4 -138
  113. package/packages/client/dist/git/direct-yolo-checkpoint.d.ts +94 -9
  114. package/packages/client/dist/git/direct-yolo-checkpoint.js +3 -1592
  115. package/packages/client/dist/git/epic-operational-state.js +2 -672
  116. package/packages/client/dist/git/git-lifecycle-step-ids.js +1 -14
  117. package/packages/client/dist/git/git-lifecycle-store.d.ts +88 -0
  118. package/packages/client/dist/git/git-lifecycle-store.js +9 -2529
  119. package/packages/client/dist/git/legacy-story-branch-checkpoint.js +9 -259
  120. package/packages/client/dist/git/legacy-story-branch-setup.js +4 -348
  121. package/packages/client/dist/git/legacy-story-pr.js +70 -3538
  122. package/packages/client/dist/git/neocortex-trailers.js +2 -53
  123. package/packages/client/dist/git/release-gate-env.d.ts +62 -0
  124. package/packages/client/dist/git/release-gate-env.js +1 -0
  125. package/packages/client/dist/git/secure-filesystem-boundary.d.ts +24 -0
  126. package/packages/client/dist/git/secure-filesystem-boundary.js +20 -186
  127. package/packages/client/dist/git/story-worktree-cleanup.js +4 -1058
  128. package/packages/client/dist/git/story-worktree-integration.d.ts +62 -0
  129. package/packages/client/dist/git/story-worktree-integration.js +3 -603
  130. package/packages/client/dist/git/story-worktree-manager.js +3 -843
  131. package/packages/client/dist/git/story-worktree-paths.js +1 -150
  132. package/packages/client/dist/git/story-write-set-extension.d.ts +44 -0
  133. package/packages/client/dist/git/story-write-set-extension.js +1 -0
  134. package/packages/client/dist/graph-retrieval/pre-command-hook.js +1 -284
  135. package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +1 -237
  136. package/packages/client/dist/i18n/first-run.js +2 -60
  137. package/packages/client/dist/index.js +1 -50
  138. package/packages/client/dist/invocation/invoke-input.js +1 -24
  139. package/packages/client/dist/license/host-auth-recovery.js +1 -401
  140. package/packages/client/dist/license/index.js +1 -5
  141. package/packages/client/dist/license/license-client.js +1 -337
  142. package/packages/client/dist/machine/fingerprint.js +2 -163
  143. package/packages/client/dist/machine/index.js +1 -5
  144. package/packages/client/dist/memory/project-memory-path-scope.js +1 -62
  145. package/packages/client/dist/memory/project-memory-writer.js +41 -1117
  146. package/packages/client/dist/memory/shared-project-memory-types.js +2 -259
  147. package/packages/client/dist/migrations/epic-lifecycle-backfill.js +3 -1060
  148. package/packages/client/dist/migrations/project-identity-capability.js +1 -50
  149. package/packages/client/dist/migrations/project-identity.js +7 -493
  150. package/packages/client/dist/migrations/state-json.js +4 -393
  151. package/packages/client/dist/policy/architecture-policy.js +2 -184
  152. package/packages/client/dist/policy/index.js +1 -7
  153. package/packages/client/dist/policy/shared-policy-types.js +0 -38
  154. package/packages/client/dist/policy/subagent-approval-policy.js +1 -57
  155. package/packages/client/dist/private-execution/clean-baseline.js +2 -279
  156. package/packages/client/dist/private-execution/codex-executor.js +4 -574
  157. package/packages/client/dist/private-execution/codex-host-runtime.js +1 -137
  158. package/packages/client/dist/private-execution/codex-lifecycle-guard.js +1 -97
  159. package/packages/client/dist/private-execution/codex-scoped-permissions.js +1 -128
  160. package/packages/client/dist/private-execution/delivery.js +13 -410
  161. package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -294
  162. package/packages/client/dist/private-execution/frozen-handoff.js +6 -19
  163. package/packages/client/dist/private-execution/implementation-validation.js +2 -106
  164. package/packages/client/dist/private-execution/isolated-admission.js +23 -1432
  165. package/packages/client/dist/private-execution/isolated-session.js +5 -725
  166. package/packages/client/dist/private-execution/isolated-workspace.js +1 -122
  167. package/packages/client/dist/private-execution/pact-consumer-runtime.js +3 -409
  168. package/packages/client/dist/private-execution/pact-test-source.js +1 -258
  169. package/packages/client/dist/private-execution/pact-toolchain.js +3 -290
  170. package/packages/client/dist/private-execution/pact-write-set.js +1 -172
  171. package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -406
  172. package/packages/client/dist/private-execution/planning-generation-checkpoint.js +5 -462
  173. package/packages/client/dist/private-execution/planning-memory-checkpoint.js +3 -139
  174. package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -325
  175. package/packages/client/dist/private-execution/private-report-store.js +1 -42
  176. package/packages/client/dist/private-execution/property-test-candidate.js +1 -103
  177. package/packages/client/dist/private-execution/property-test-choices.js +3 -147
  178. package/packages/client/dist/private-execution/property-test-plan.js +7 -271
  179. package/packages/client/dist/private-execution/property-test-review.js +4 -258
  180. package/packages/client/dist/private-execution/property-test-runtime.js +9 -372
  181. package/packages/client/dist/private-execution/property-test-source.js +1 -139
  182. package/packages/client/dist/private-execution/root-checkpoint.js +1 -80
  183. package/packages/client/dist/private-execution/root-memory-git-evidence.js +3 -135
  184. package/packages/client/dist/private-execution/root-memory-recovery.js +1 -93
  185. package/packages/client/dist/private-execution/root-memory-request.js +1 -29
  186. package/packages/client/dist/private-execution/root-memory-scope.js +1 -178
  187. package/packages/client/dist/private-execution/root-memory-writer.js +1 -102
  188. package/packages/client/dist/private-execution/session-lease.js +1 -63
  189. package/packages/client/dist/private-execution/shared-private-admission-types.js +1 -50
  190. package/packages/client/dist/private-execution/shared-project-validation.js +1 -66
  191. package/packages/client/dist/private-execution/shared-root-memory-types.js +1 -61
  192. package/packages/client/dist/private-execution/ux-source-validation.js +1 -372
  193. package/packages/client/dist/private-execution/ux-write-set.js +2 -191
  194. package/packages/client/dist/registry/registry-reconciliation.js +1 -234
  195. package/packages/client/dist/resilience/circuit-breaker.js +1 -170
  196. package/packages/client/dist/resilience/degradation-manager.js +1 -164
  197. package/packages/client/dist/resilience/freshness-indicator.js +1 -100
  198. package/packages/client/dist/resilience/index.js +1 -8
  199. package/packages/client/dist/resilience/recovery-detector.js +1 -74
  200. package/packages/client/dist/resolvers/asset-resolver.js +0 -13
  201. package/packages/client/dist/resolvers/local-resolver.js +8 -255
  202. package/packages/client/dist/resolvers/remote-resolver.js +1 -233
  203. package/packages/client/dist/runner/binary.js +1 -404
  204. package/packages/client/dist/runner/cli.js +17 -1571
  205. package/packages/client/dist/runner/epic-background-dispatcher.js +1 -124
  206. package/packages/client/dist/runner/headless/adapters.js +1 -49
  207. package/packages/client/dist/runner/headless/background-root.js +1 -85
  208. package/packages/client/dist/runner/headless/child-env.d.ts +92 -0
  209. package/packages/client/dist/runner/headless/child-env.js +1 -0
  210. package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -79
  211. package/packages/client/dist/runner/headless/continuous-story-workspace.js +11 -1776
  212. package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +1 -69
  213. package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +2 -111
  214. package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.d.ts +1 -0
  215. package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +10 -1464
  216. package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +2 -357
  217. package/packages/client/dist/runner/headless/fake-adapter.js +1 -62
  218. package/packages/client/dist/runner/headless/managed-environment-cleanup.js +1 -274
  219. package/packages/client/dist/runner/headless/managed-profile.js +1 -149
  220. package/packages/client/dist/runner/headless/opencode-adapter.js +2 -145
  221. package/packages/client/dist/runner/headless/prepared-story-bundle.js +1 -43
  222. package/packages/client/dist/runner/headless/resolver.js +1 -231
  223. package/packages/client/dist/runner/headless/run-yolo.js +1 -886
  224. package/packages/client/dist/runner/headless/run-yoloop.js +2 -2657
  225. package/packages/client/dist/runner/headless/types.js +2 -575
  226. package/packages/client/dist/runner/host-capacity.js +1 -59
  227. package/packages/client/dist/runner/local-console.js +13 -396
  228. package/packages/client/dist/runner/portal-sync-worker.js +1 -1487
  229. package/packages/client/dist/runner/project-identity.js +1 -106
  230. package/packages/client/dist/runner/scheduler.js +7 -995
  231. package/packages/client/dist/runner-cli.js +2 -18
  232. package/packages/client/dist/state/invocation-shape.js +1 -13
  233. package/packages/client/dist/state/project-state-snapshot.js +1 -1754
  234. package/packages/client/dist/state/state-json-repair.js +3 -785
  235. package/packages/client/dist/state/structural-dag-projection.js +1 -118
  236. package/packages/client/dist/telemetry/index.js +1 -5
  237. package/packages/client/dist/telemetry/offline-queue.js +1 -131
  238. package/packages/client/dist/tier/index.js +1 -5
  239. package/packages/client/dist/tier/tier-aware-client.js +1 -405
  240. package/packages/client/dist/types/index.js +1 -38
  241. package/packages/client/dist/version.js +1 -27
  242. package/packages/client/dist/yolo/change-evidence-collector.d.ts +10 -0
  243. package/packages/client/dist/yolo/change-evidence-collector.js +1 -262
  244. package/packages/client/dist/yolo/invoke-envelope-capability.d.ts +2 -0
  245. package/packages/client/dist/yolo/invoke-envelope-capability.js +1 -65
  246. package/packages/client/dist/yolo/project-manifest-projection-collector.d.ts +28 -0
  247. package/packages/client/dist/yolo/project-manifest-projection-collector.js +1 -0
  248. package/packages/client/dist/yolo/spec-envelope-collector.d.ts +9 -0
  249. package/packages/client/dist/yolo/spec-envelope-collector.js +5 -184
  250. package/packages/client/dist/yoloop/discovery-hook.js +2 -300
  251. package/packages/client/dist/yoloop/index.js +1 -8
  252. package/packages/client/dist/yoloop/invoke-hooks.js +12 -669
  253. package/packages/client/dist/yoloop/shared-discover-epics.d.ts +16 -0
  254. package/packages/client/dist/yoloop/shared-discover-epics.js +1 -1007
  255. package/packages/client/dist/yoloop/shared-yoloop-types.js +1 -33
  256. package/packages/client/dist/yoloop/target-normalization.js +1 -180
  257. package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1920
  258. package/packages/shared/dist/frontmatter-context-contract.js +164 -52
  259. package/packages/shared/dist/project-manifest-projection.js +199 -0
  260. package/packages/shared/dist/project-validation-commands.js +14 -6
  261. package/packages/shared/dist/yolo/spec-envelope-rules.js +85 -0
  262. package/packages/shared/dist/yolo/spec-envelope.js +33 -7
  263. package/packages/shared/dist/yoloop/epic-terminal-git.js +94 -6
  264. package/packages/shared/dist/yoloop/story-write-scope.js +212 -0
  265. package/targets-stubs/antigravity/gemini.md +1 -1
  266. package/targets-stubs/antigravity/install-antigravity.sh +13 -4
  267. package/targets-stubs/antigravity/skill/SKILL.md +1 -1
  268. package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
  269. package/targets-stubs/claude-code/neocortex-root.md +2 -2
  270. package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
  271. package/targets-stubs/claude-code/neocortex.md +5 -5
  272. package/targets-stubs/codex/AGENTS.md +1 -1
  273. package/targets-stubs/cursor/agent.md +2 -2
  274. package/targets-stubs/gemini-cli/agent.md +2 -2
  275. package/targets-stubs/lib/managed-config-merge.js +77 -1
  276. package/targets-stubs/lib/managed-profile.sh +7 -0
  277. package/targets-stubs/opencode/neocortex-root.md +1 -1
  278. package/targets-stubs/vscode/install-vscode.sh +21 -0
  279. package/targets-stubs/vscode/neocortex.agent.md +2 -2
@@ -1,443 +1,2 @@
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 - Stub Refresh Module
15
- *
16
- * Detects version mismatch between installed stubs and CLI version.
17
- * Re-copies full stub files from the package when outdated.
18
- *
19
- * Called by activate.ts BEFORE updateAgentDescription() to ensure
20
- * the stub file has all current sections (Banner, Plugin Guard, etc.)
21
- * before the regex patcher runs.
22
- *
23
- * Never throws -- stub refresh is non-critical.
24
- *
25
- * Story 55.1
26
- */
27
- import { readFileSync, writeFileSync, existsSync, mkdirSync, renameSync, unlinkSync } from 'node:fs';
28
- import { join, dirname, relative } from 'node:path';
29
- import { homedir } from 'node:os';
30
- import { createRequire } from 'node:module';
31
- import { fileURLToPath } from 'node:url';
32
- import { setSecureFilePermissions } from '../config/secure-config.js';
33
- // -- Banner Frame Constants ---------------------------------------------------
34
- const BANNER_INNER = 60;
35
- const BANNER_PREFIX_INNER = 25;
36
- const requireManagedHelper = createRequire(import.meta.url);
37
- function readManagedTierLabel(home) {
38
- try {
39
- const config = JSON.parse(readFileSync(join(home, '.neocortex', 'config.json'), 'utf8'));
40
- if (config.tier === 'free')
41
- return 'Free';
42
- if (config.tier === 'pro')
43
- return 'Pro';
44
- if (config.tier === 'enterprise')
45
- return 'Enterprise';
46
- }
47
- catch { /* optional display transform */ }
48
- return undefined;
49
- }
50
- // -- Version Patching ---------------------------------------------------------
51
- /**
52
- * Replace all version strings in a stub file with the given version.
53
- * Handles 4 patterns:
54
- * 1. Emoji description: 🧠 Neocortex vX.Y.Z
55
- * 2. Plain markdown header: # Neocortex vX.Y.Z
56
- * 3. Banner line: │ ### ######## vX.Y.Z ...│
57
- * 4. YAML version field: version: 'X.Y.Z'
58
- *
59
- * Never throws -- version patching is best-effort.
60
- * Story 71.2
61
- */
62
- export function patchVersionInFile(filePath, version) {
63
- try {
64
- const content = readFileSync(filePath, 'utf-8');
65
- const original = content;
66
- const patched = patchVersionInContent(content, version);
67
- if (patched !== original) {
68
- writeFileSync(filePath, patched, 'utf-8');
69
- }
70
- }
71
- catch {
72
- // Non-critical -- version patching is best-effort
73
- }
74
- }
75
- export function patchVersionInContent(content, version) {
76
- try {
77
- let patched = content.replace(/🧠 Neocortex v[\d.]+/g, `🧠 Neocortex v${version}`);
78
- // Pattern 2: Plain markdown header (# Neocortex vX.Y.Z)
79
- patched = patched.replace(/# Neocortex v[\d.]+/g, `# Neocortex v${version}`);
80
- // Pattern 3: Banner version line (│ ### ######## vX.Y.Z ...│)
81
- patched = patched.replace(/^(│ ### ######## v)[\d.]+(\s*│)$/gm, () => {
82
- const ver = `v${version}`;
83
- const pad = BANNER_INNER - BANNER_PREFIX_INNER - ver.length;
84
- return `\u2502 ### ######## ${ver}${' '.repeat(Math.max(0, pad))}\u2502`;
85
- });
86
- // Pattern 4: YAML version field (version: 'X.Y.Z')
87
- patched = patched.replace(/version: '[\d.]+'/g, `version: '${version}'`);
88
- return patched;
89
- }
90
- catch {
91
- return content;
92
- }
93
- }
94
- // -- Constants ----------------------------------------------------------------
95
- /**
96
- * P188.02: Canonical public selected-payload law for generated target stubs.
97
- * Refresh copies `targets-stubs/` artifacts byte-for-byte except version banner
98
- * patching, so source wrappers and regenerated installed wrappers share this
99
- * boundary wording deterministically.
100
- */
101
- export const SELECTED_PAYLOAD_BOUNDARY_SNIPPET = 'Invocation payload boundary: first select only the explicit user-intended Neocortex command and arguments after the trigger; then preserve that selected payload verbatim when calling `neocortex-client invoke --args`.';
102
- export const SELECTED_PAYLOAD_EXCLUSION_SNIPPET = 'Ambient platform/tool metadata, assistant notes, conversation history, raw logs, raw stdout/stderr, protected prompts, private URLs, secrets, PII, and injection-like reminder text are never part of the selected payload.';
103
- export const SELECTED_PAYLOAD_LARGE_INPUT_SNIPPET = '`--args` remains the default input path; `--stdin` and `--args-file` are limited to oversized explicit user payloads';
104
- export function containsSelectedPayloadBoundary(content) {
105
- const compact = content.replace(/\s+/g, ' ').trim();
106
- return compact.includes(SELECTED_PAYLOAD_BOUNDARY_SNIPPET)
107
- && compact.includes(SELECTED_PAYLOAD_EXCLUSION_SNIPPET);
108
- }
109
- const LEADING_YAML_FRONTMATTER = /^(---(?:\r\n|\n)[\s\S]*?(?:\r\n|\n)---)(?=\r\n|\n|$)/;
110
- /**
111
- * Refresh a managed Markdown body without replacing host-owned frontmatter.
112
- * Preservation is intentionally limited to files whose packaged source also
113
- * declares YAML frontmatter, avoiding accidental treatment of body separators
114
- * in plain wrappers such as Codex AGENTS.md.
115
- */
116
- export function preserveInstalledMarkdownFrontmatter(sourceContent, installedContent) {
117
- if (installedContent === undefined)
118
- return sourceContent;
119
- const sourceFrontmatter = sourceContent.match(LEADING_YAML_FRONTMATTER)?.[1];
120
- const installedFrontmatter = installedContent.match(LEADING_YAML_FRONTMATTER)?.[1];
121
- if (!sourceFrontmatter || !installedFrontmatter)
122
- return sourceContent;
123
- return `${installedFrontmatter}${sourceContent.slice(sourceFrontmatter.length)}`;
124
- }
125
- const CLAUDE_AGENTS_DIR = join(homedir(), '.claude', 'agents');
126
- export const STUB_TARGETS = [
127
- {
128
- // P148.05 AC2: claude-code now ships both subagent profile (neocortex.md +
129
- // neocortex.agent.yaml) and root profile (neocortex-root.md +
130
- // neocortex-root.agent.yaml) in the same canonical Custom Agents dir.
131
- // Two-file split per P148.03: subagent has guard wording, root does not.
132
- // Claude Code only discovers subagents at top-level `agents/*.md`, so the
133
- // agent markdown files live in ~/.claude/agents/ while `.version` and the
134
- // `.agent.yaml` metadata stay in the nested neocortex/ dir.
135
- destDir: join(CLAUDE_AGENTS_DIR, 'neocortex'),
136
- sourceDir: 'claude-code',
137
- files: [
138
- 'neocortex.md',
139
- 'neocortex.agent.yaml',
140
- 'neocortex-root.md',
141
- 'neocortex-root.agent.yaml',
142
- ],
143
- fileDestDirs: {
144
- 'neocortex.md': CLAUDE_AGENTS_DIR,
145
- 'neocortex-root.md': CLAUDE_AGENTS_DIR,
146
- },
147
- },
148
- {
149
- destDir: join(homedir(), '.gemini', 'agents'),
150
- sourceDir: 'gemini-cli',
151
- files: ['agent.md'],
152
- },
153
- {
154
- destDir: join(homedir(), '.cursor', 'agents'),
155
- sourceDir: 'cursor',
156
- files: ['agent.md'],
157
- },
158
- {
159
- destDir: join(homedir(), '.kimi-code', 'agents'),
160
- sourceDir: 'kimi',
161
- files: ['neocortex.md'],
162
- },
163
- {
164
- // P148.05 AC1: opencode root profile (root agent owns *yoloop loop) and
165
- // subagent profile (mode: subagent, recused outer root invocations) ship
166
- // in the canonical OpenCode Custom Agents dir. P148.01 introduced the
167
- // root/child split. Two-file topology mirrors claude-code, vscode, etc.
168
- destDir: join(homedir(), '.opencode', 'agents'),
169
- sourceDir: 'opencode',
170
- files: ['neocortex.md', 'neocortex-root.md'],
171
- },
172
- {
173
- destDir: join(homedir(), '.codex'),
174
- sourceDir: 'codex',
175
- // P124.01: Codex CLI requires uppercase AGENTS.md per docs
176
- // (https://developers.openai.com/codex/guides/agents-md). Lowercase
177
- // `agents.md` is silently ignored on case-sensitive filesystems
178
- // (Linux + APFS case-sensitive volumes).
179
- //
180
- // P148.05 AC3: Codex ships AGENTS.md as the project-root entrypoint
181
- // (root agent contract per P148.02). The subagent profile lives in
182
- // ~/.codex/agents/neocortex.toml and is installed via the dedicated
183
- // codex-subagent target below (different parent dir).
184
- files: ['AGENTS.md'],
185
- },
186
- {
187
- // P148.05 AC3: Codex subagent profile (neocortex.toml) lives in
188
- // ~/.codex/agents/, distinct from root AGENTS.md in ~/.codex/. Codex
189
- // discovers subagents via the agents/ dir per the official subagents
190
- // docs (https://developers.openai.com/codex/subagents). Refreshing this
191
- // target keeps the subagent guard wording (P127.06 isolation contract)
192
- // in sync with the published CLI version.
193
- destDir: join(homedir(), '.codex', 'agents'),
194
- sourceDir: 'codex',
195
- files: ['neocortex.toml'],
196
- },
197
- {
198
- // P124.02: VS Code Copilot canonical Custom Agents path is ~/.copilot/agents/<name>.agent.md
199
- // Source: https://code.visualstudio.com/docs/copilot/customization/custom-agents
200
- destDir: join(homedir(), '.copilot', 'agents'),
201
- sourceDir: 'vscode',
202
- files: ['neocortex.agent.md'],
203
- },
204
- {
205
- destDir: join(homedir(), '.agent', 'skills', 'neocortex'),
206
- sourceDir: 'antigravity',
207
- files: ['skill/SKILL.md'],
208
- },
209
- {
210
- destDir: join(homedir(), '.gemini', 'config', 'agents'),
211
- sourceDir: 'antigravity',
212
- files: ['neocortex.md'],
213
- },
214
- {
215
- destDir: join(homedir(), '.grok', 'skills', 'neocortex'),
216
- sourceDir: 'grok',
217
- files: ['SKILL.md'],
218
- },
219
- ];
220
- // -- Package Root Resolution --------------------------------------------------
221
- /**
222
- * Find the monorepo / npm package root by walking up from this file's location.
223
- * Looks for a package.json with name '@ornexus/neocortex' (monorepo root) or
224
- * '@neocortex/client' (client package root that contains targets-stubs after build).
225
- *
226
- * Returns null if not found within 10 levels.
227
- */
228
- export function findPackageRoot() {
229
- try {
230
- const thisFile = fileURLToPath(import.meta.url);
231
- let dir = dirname(thisFile);
232
- for (let i = 0; i < 10; i++) {
233
- try {
234
- const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8'));
235
- if (pkg.name === '@ornexus/neocortex') {
236
- return dir;
237
- }
238
- }
239
- catch { /* no package.json at this level */ }
240
- dir = dirname(dir);
241
- }
242
- }
243
- catch { /* fallback */ }
244
- return null;
245
- }
246
- // -- Version Comparison -------------------------------------------------------
247
- /**
248
- * Read the installed version from .version file in the dest directory.
249
- * Returns null if file doesn't exist or is unreadable.
250
- */
251
- function readInstalledVersion(destDir) {
252
- try {
253
- const versionFile = join(destDir, '.version');
254
- if (existsSync(versionFile)) {
255
- return readFileSync(versionFile, 'utf-8').trim() || null;
256
- }
257
- }
258
- catch { /* unreadable */ }
259
- return null;
260
- }
261
- function writeTextAtomic(filePath, content) {
262
- const temporaryPath = `${filePath}.tmp-${process.pid}`;
263
- try {
264
- writeFileSync(temporaryPath, content, 'utf8');
265
- setSecureFilePermissions(temporaryPath);
266
- renameSync(temporaryPath, filePath);
267
- setSecureFilePermissions(filePath);
268
- }
269
- catch (error) {
270
- try {
271
- if (existsSync(temporaryPath))
272
- unlinkSync(temporaryPath);
273
- }
274
- catch { /* best effort */ }
275
- throw error;
276
- }
277
- }
278
- /**
279
- * Refresh installed stubs if CLI version differs from installed version.
280
- *
281
- * For each stub target:
282
- * 1. Read .version from install dir
283
- * 2. Compare with cliVersion
284
- * 3. If different (or .version missing): re-copy all stub files + write .version
285
- * 4. If same: skip (no-op)
286
- *
287
- * When options.forceCreate is true, creates destDir if it doesn't exist.
288
- * When options.targetFilter is set, only processes matching target.
289
- *
290
- * Never throws -- stub refresh is non-critical.
291
- * Returns the number of targets that were refreshed.
292
- */
293
- export function refreshStubs(cliVersion, options) {
294
- try {
295
- const forceCreate = options?.forceCreate ?? false;
296
- const targetFilter = options?.targetFilter;
297
- const dryRun = options?.dryRun ?? false;
298
- const defaultHome = homedir();
299
- const home = options?.homeDir ?? defaultHome;
300
- const packageRoot = options?.packageRoot ?? findPackageRoot();
301
- if (!packageRoot) {
302
- return 0;
303
- }
304
- // targets-stubs/ is at the package root level
305
- const stubsRoot = join(packageRoot, 'targets-stubs');
306
- if (!existsSync(stubsRoot)) {
307
- return 0;
308
- }
309
- const helperPath = join(stubsRoot, 'lib', 'managed-config-merge.js');
310
- if (!existsSync(helperPath))
311
- return 0;
312
- const managed = requireManagedHelper(helperPath);
313
- const manifestFile = join(home, '.neocortex', 'managed-config-manifest.json');
314
- const tierLabel = readManagedTierLabel(home);
315
- try {
316
- managed.applyPolicy({
317
- configFile: join(home, '.neocortex', 'config.json'),
318
- manifestFile,
319
- baseDir: home,
320
- dryRun,
321
- });
322
- }
323
- catch {
324
- // Approval config mutation fails closed; profile refresh can remain independent.
325
- }
326
- let refreshed = 0;
327
- for (const target of STUB_TARGETS) {
328
- try {
329
- const rebase = (dir) => (options?.homeDir
330
- ? join(home, relative(defaultHome, dir))
331
- : dir);
332
- const destDir = rebase(target.destDir);
333
- // If targetFilter is set, skip non-matching targets
334
- if (targetFilter && target.sourceDir !== targetFilter) {
335
- continue;
336
- }
337
- // Epic 67 - Story 67.3: If forceCreate, create destDir when it doesn't exist
338
- if (!existsSync(destDir)) {
339
- if (forceCreate && !dryRun) {
340
- mkdirSync(destDir, { recursive: true });
341
- }
342
- else if (forceCreate && dryRun) {
343
- // A dry-run may plan creation without touching the destination.
344
- }
345
- else {
346
- continue;
347
- }
348
- }
349
- const installedVersion = readInstalledVersion(destDir);
350
- if (installedVersion === cliVersion) {
351
- continue; // Already up to date
352
- }
353
- // Source directory for this target
354
- const sourceDir = join(stubsRoot, target.sourceDir);
355
- if (!existsSync(sourceDir)) {
356
- continue;
357
- }
358
- // Copy each file
359
- let copiedAny = false;
360
- for (const file of target.files) {
361
- const src = join(sourceDir, file);
362
- const overrideDir = target.fileDestDirs?.[file];
363
- const dest = overrideDir ? join(rebase(overrideDir), file) : join(destDir, file);
364
- const legacyDest = overrideDir ? join(destDir, file) : null;
365
- if (existsSync(src)) {
366
- let content = readFileSync(src, 'utf8');
367
- if (file.endsWith('.md')) {
368
- // Migration: carry host-owned frontmatter over from the legacy
369
- // nested copy when the new destination does not exist yet.
370
- const installedPath = existsSync(dest)
371
- ? dest
372
- : (legacyDest && existsSync(legacyDest) ? legacyDest : null);
373
- const installedContent = installedPath ? readFileSync(installedPath, 'utf8') : undefined;
374
- content = preserveInstalledMarkdownFrontmatter(content, installedContent);
375
- }
376
- if (file.endsWith('.md') || file.endsWith('.yaml') || file.endsWith('.yml')) {
377
- content = patchVersionInContent(content, cliVersion);
378
- }
379
- const relativeDest = relative(home, dest).split('\\').join('/');
380
- const result = managed.applyProfileBytes({
381
- id: `profile-${target.sourceDir}-${relativeDest}`,
382
- content,
383
- destination: dest,
384
- manifestFile,
385
- baseDir: home,
386
- dryRun,
387
- allowLegacyAdoption: true,
388
- tierLabel,
389
- });
390
- if (result.action !== 'failed')
391
- copiedAny = true;
392
- if (legacyDest
393
- && !dryRun
394
- && result.action !== 'failed'
395
- && existsSync(dest)
396
- && existsSync(legacyDest)) {
397
- try {
398
- unlinkSync(legacyDest);
399
- }
400
- catch { /* best effort */ }
401
- }
402
- }
403
- }
404
- // Write .version file
405
- if (copiedAny && !dryRun) {
406
- const versionPath = join(destDir, '.version');
407
- writeTextAtomic(versionPath, cliVersion + '\n');
408
- refreshed++;
409
- }
410
- else if (copiedAny) {
411
- refreshed++;
412
- }
413
- }
414
- catch {
415
- // Non-critical -- continue with next target
416
- }
417
- }
418
- // P85.07: Touch update-check marker after stub refresh to prevent
419
- // redundant agent-side auto-update check immediately after postinstall.
420
- // This is complementary to P50 server-side version gate (426 UPGRADE_REQUIRED):
421
- // - Server-side (P50): hard block when version < MIN_CLIENT_VERSION
422
- // - Agent-side (P85): soft update when version < LATEST (npm registry)
423
- if (refreshed > 0) {
424
- try {
425
- // Keep explicit synthetic-home runs fully isolated from the real user
426
- // home. Production still resolves `home` from os.homedir().
427
- const markerDir = join(home, '.neocortex');
428
- mkdirSync(markerDir, { recursive: true });
429
- const marker = join(markerDir, '.update-check');
430
- writeFileSync(marker, '', { flag: 'w' });
431
- setSecureFilePermissions(marker);
432
- }
433
- catch {
434
- // Fail-open: marker touch is non-critical
435
- }
436
- }
437
- return refreshed;
438
- }
439
- catch {
440
- // Non-critical -- entire function is best-effort
441
- return 0;
442
- }
443
- }
1
+ import{readFileSync as m,writeFileSync as E,existsSync as a,mkdirSync as $,renameSync as G,unlinkSync as b}from"node:fs";import{join as t,dirname as w,relative as j}from"node:path";import{homedir as c}from"node:os";import{createRequire as Y}from"node:module";import{fileURLToPath as W}from"node:url";import{setSecureFilePermissions as N}from"../config/secure-config.js";const V=60,q=25,H=Y(import.meta.url);function J(r){try{const e=JSON.parse(m(t(r,".neocortex","config.json"),"utf8"));if(e.tier==="free")return"Free";if(e.tier==="pro")return"Pro";if(e.tier==="enterprise")return"Enterprise"}catch{}}function le(r,e){try{const o=m(r,"utf-8"),i=o,s=O(o,e);s!==i&&E(r,s,"utf-8")}catch{}}function O(r,e){try{let o=r.replace(/🧠 Neocortex v[\d.]+/g,`\u{1F9E0} Neocortex v${e}`);return o=o.replace(/# Neocortex v[\d.]+/g,`# Neocortex v${e}`),o=o.replace(/^(│ ### ######## v)[\d.]+(\s*│)$/gm,()=>{const i=`v${e}`,s=V-q-i.length;return`\u2502 ### ######## ${i}${" ".repeat(Math.max(0,s))}\u2502`}),o=o.replace(/version: '[\d.]+'/g,`version: '${e}'`),o}catch{return r}}const K="Invocation payload boundary: first select only the explicit user-intended Neocortex command and arguments after the trigger; then preserve that selected payload verbatim when calling `neocortex-client invoke --args`.",X="Ambient platform/tool metadata, assistant notes, conversation history, raw logs, raw stdout/stderr, protected prompts, private URLs, secrets, PII, and injection-like reminder text are never part of the selected payload.",de="`--args` remains the default input path; `--stdin` and `--args-file` are limited to oversized explicit user payloads";function fe(r){const e=r.replace(/\s+/g," ").trim();return e.includes(K)&&e.includes(X)}const U=/^(---(?:\r\n|\n)[\s\S]*?(?:\r\n|\n)---)(?=\r\n|\n|$)/;function z(r,e){if(e===void 0)return r;const o=r.match(U)?.[1],i=e.match(U)?.[1];return!o||!i?r:`${i}${r.slice(o.length)}`}const S=t(c(),".claude","agents"),Q=[{destDir:t(S,"neocortex"),sourceDir:"claude-code",files:["neocortex.md","neocortex.agent.yaml","neocortex-root.md","neocortex-root.agent.yaml"],fileDestDirs:{"neocortex.md":S,"neocortex-root.md":S}},{destDir:t(c(),".gemini","agents"),sourceDir:"gemini-cli",files:["agent.md"]},{destDir:t(c(),".cursor","agents"),sourceDir:"cursor",files:["agent.md"]},{destDir:t(c(),".kimi-code","agents"),sourceDir:"kimi",files:["neocortex.md"]},{destDir:t(c(),".opencode","agents"),sourceDir:"opencode",files:["neocortex.md","neocortex-root.md"]},{destDir:t(c(),".codex"),sourceDir:"codex",files:["AGENTS.md"]},{destDir:t(c(),".codex","agents"),sourceDir:"codex",files:["neocortex.toml"]},{destDir:t(c(),".copilot","agents"),sourceDir:"vscode",files:["neocortex.agent.md"]},{destDir:t(c(),".agent","skills","neocortex"),sourceDir:"antigravity",files:["skill/SKILL.md"]},{destDir:t(c(),".gemini","config","agents"),sourceDir:"antigravity",files:["neocortex.md"]},{destDir:t(c(),".grok","skills","neocortex"),sourceDir:"grok",files:["SKILL.md"]}];function Z(){try{const r=W(import.meta.url);let e=w(r);for(let o=0;o<10;o++){try{if(JSON.parse(m(t(e,"package.json"),"utf-8")).name==="@ornexus/neocortex")return e}catch{}e=w(e)}}catch{}return null}function ee(r){try{const e=t(r,".version");if(a(e))return m(e,"utf-8").trim()||null}catch{}return null}function te(r,e){const o=`${r}.tmp-${process.pid}`;try{E(o,e,"utf8"),N(o),G(o,r),N(r)}catch(i){try{a(o)&&b(o)}catch{}throw i}}function ue(r,e){try{const o=e?.forceCreate??!1,i=e?.targetFilter,s=e?.dryRun??!1,k=c(),d=e?.homeDir??k,A=e?.packageRoot??Z();if(!A)return 0;const x=t(A,"targets-stubs");if(!a(x))return 0;const L=t(x,"lib","managed-config-merge.js");if(!a(L))return 0;const P=H(L),R=t(d,".neocortex","managed-config-manifest.json"),B=J(d);try{P.applyPolicy({configFile:t(d,".neocortex","config.json"),manifestFile:R,baseDir:d,dryRun:s})}catch{}let h=0;for(const l of Q)try{const p=n=>e?.homeDir?t(d,j(k,n)):n,f=p(l.destDir);if(i&&l.sourceDir!==i)continue;if(!a(f)){if(o&&!s)$(f,{recursive:!0});else if(!(o&&s))continue}if(ee(f)===r)continue;const I=t(x,l.sourceDir);if(!a(I))continue;let y=!1;for(const n of l.files){const T=t(I,n),v=l.fileDestDirs?.[n],g=v?t(p(v),n):t(f,n),u=v?t(f,n):null;if(a(T)){let D=m(T,"utf8");if(n.endsWith(".md")){const F=a(g)?g:u&&a(u)?u:null,C=F?m(F,"utf8"):void 0;D=z(D,C)}(n.endsWith(".md")||n.endsWith(".yaml")||n.endsWith(".yml"))&&(D=O(D,r));const M=j(d,g).split("\\").join("/"),_=P.applyProfileBytes({id:`profile-${l.sourceDir}-${M}`,content:D,destination:g,manifestFile:R,baseDir:d,dryRun:s,allowLegacyAdoption:!0,tierLabel:B});if(_.action!=="failed"&&(y=!0),u&&!s&&_.action!=="failed"&&a(g)&&a(u))try{b(u)}catch{}}}if(y&&!s){const n=t(f,".version");te(n,r+`
2
+ `),h++}else y&&h++}catch{}if(h>0)try{const l=t(d,".neocortex");$(l,{recursive:!0});const p=t(l,".update-check");E(p,"",{flag:"w"}),N(p)}catch{}return h}catch{return 0}}export{K as SELECTED_PAYLOAD_BOUNDARY_SNIPPET,X as SELECTED_PAYLOAD_EXCLUSION_SNIPPET,de as SELECTED_PAYLOAD_LARGE_INPUT_SNIPPET,Q as STUB_TARGETS,fe as containsSelectedPayloadBoundary,Z as findPackageRoot,O as patchVersionInContent,le as patchVersionInFile,z as preserveInstalledMarkdownFrontmatter,ue as refreshStubs};
@@ -1,102 +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 - Agent YAML Updater
15
- *
16
- * Patches neocortex.agent.yaml with current version and tier-based title.
17
- *
18
- * Patches TWO fields:
19
- * 1. version: 'X.X.X'
20
- * 2. title: 'Development Orchestrator (Tier)'
21
- *
22
- * Called after:
23
- * - refreshStubs() (ensures YAML exists with current structure)
24
- * - updateAgentDescription() (ensures consistency across all surfaces)
25
- *
26
- * Never throws -- YAML update is non-critical.
27
- *
28
- * Story 55.2
29
- */
30
- import { readFileSync, writeFileSync, existsSync } from 'node:fs';
31
- import { join } from 'node:path';
32
- import { homedir } from 'node:os';
33
- // -- Constants ----------------------------------------------------------------
34
- const TIER_LABELS = {
35
- free: 'Free',
36
- pro: 'Pro',
37
- enterprise: 'Enterprise',
38
- };
39
- // Regex patterns for YAML fields (simple key: 'value' format)
40
- const VERSION_PATTERN = /^(\s*version:\s*)'[^']*'/m;
41
- const TITLE_PATTERN = /^(\s*title:\s*)'[^']*'/m;
42
- const HOME_YAML_FILES = [
43
- join(homedir(), '.claude', 'agents', 'neocortex', 'neocortex.agent.yaml'),
44
- ];
45
- // -- Internal -----------------------------------------------------------------
46
- /**
47
- * Patch a single agent.yaml file with version and tier.
48
- * Returns true if file was modified.
49
- */
50
- function patchYamlFile(filePath, version, tier) {
51
- try {
52
- if (!existsSync(filePath)) {
53
- return false;
54
- }
55
- let content = readFileSync(filePath, 'utf-8');
56
- const original = content;
57
- const label = TIER_LABELS[tier.toLowerCase()] ?? 'Free';
58
- // Patch version
59
- if (VERSION_PATTERN.test(content)) {
60
- content = content.replace(VERSION_PATTERN, `$1'${version}'`);
61
- }
62
- // Patch title
63
- if (TITLE_PATTERN.test(content)) {
64
- content = content.replace(TITLE_PATTERN, `$1'Development Orchestrator (${label})'`);
65
- }
66
- if (content === original) {
67
- return false;
68
- }
69
- writeFileSync(filePath, content, 'utf-8');
70
- return true;
71
- }
72
- catch {
73
- return false;
74
- }
75
- }
76
- // -- Public API ---------------------------------------------------------------
77
- /**
78
- * Update agent.yaml files across all known locations.
79
- * Returns count of files updated.
80
- *
81
- * Never throws.
82
- */
83
- export function updateAgentYaml(version, tier) {
84
- const resolvedTier = tier ?? 'free';
85
- let updated = 0;
86
- // Home-level files
87
- for (const filePath of HOME_YAML_FILES) {
88
- if (patchYamlFile(filePath, version, resolvedTier)) {
89
- updated++;
90
- }
91
- }
92
- return updated;
93
- }
94
- /**
95
- * Update agent.yaml at a specific file path (used for testing).
96
- * Returns true if the file was modified.
97
- *
98
- * Never throws.
99
- */
100
- export function updateAgentYamlAt(filePath, version, tier) {
101
- return patchYamlFile(filePath, version, tier ?? 'free');
102
- }
1
+ import{readFileSync as f,writeFileSync as l,existsSync as u}from"node:fs";import{join as p}from"node:path";import{homedir as m}from"node:os";const E={free:"Free",pro:"Pro",enterprise:"Enterprise"},s=/^(\s*version:\s*)'[^']*'/m,c=/^(\s*title:\s*)'[^']*'/m,d=[p(m(),".claude","agents","neocortex","neocortex.agent.yaml")];function i(t,r,n){try{if(!u(t))return!1;let e=f(t,"utf-8");const o=e,a=E[n.toLowerCase()]??"Free";return s.test(e)&&(e=e.replace(s,`$1'${r}'`)),c.test(e)&&(e=e.replace(c,`$1'Development Orchestrator (${a})'`)),e===o?!1:(l(t,e,"utf-8"),!0)}catch{return!1}}function L(t,r){const n=r??"free";let e=0;for(const o of d)i(o,t,n)&&e++;return e}function S(t,r,n){return i(t,r,n??"free")}export{L as updateAgentYaml,S as updateAgentYamlAt};
@@ -27,6 +27,13 @@ export declare function buildDescription(version: string, tier: string): string;
27
27
  * Returns 'free' if config doesn't exist or tier is missing.
28
28
  */
29
29
  export declare function readTierFromConfig(): string;
30
+ export interface DescriptionPatchOptions {
31
+ /**
32
+ * Managed base whose `.neocortex/managed-config-manifest.json` owns the file.
33
+ * Defaults to HOME. Project-level files use the project root.
34
+ */
35
+ managedBaseDir?: string;
36
+ }
30
37
  /**
31
38
  * Update agent descriptions across ALL known platform files:
32
39
  * 1. Home-level files (Claude Code, Gemini CLI)
@@ -42,4 +49,4 @@ export declare function updateAgentDescription(version: string, tier?: string):
42
49
  *
43
50
  * Never throws -- description update is non-critical.
44
51
  */
45
- export declare function updateAgentDescriptionAt(filePath: string, type: 'yaml' | 'h1', version: string, tier?: string): boolean;
52
+ export declare function updateAgentDescriptionAt(filePath: string, type: 'yaml' | 'h1', version: string, tier?: string, options?: DescriptionPatchOptions): boolean;