@ornexus/neocortex 4.60.78 → 4.60.79

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 (241) hide show
  1. package/dist/release-source.json +1 -1
  2. package/dist/sbom.cdx.json +1193 -1206
  3. package/install.ps1 +1 -1
  4. package/install.sh +1 -1
  5. package/package.json +2 -2
  6. package/packages/client/dist/adapters/adapter-registry.js +108 -1
  7. package/packages/client/dist/adapters/antigravity-adapter.js +77 -2
  8. package/packages/client/dist/adapters/claude-code-adapter.js +79 -3
  9. package/packages/client/dist/adapters/codex-adapter.js +80 -2
  10. package/packages/client/dist/adapters/cursor-adapter.js +115 -4
  11. package/packages/client/dist/adapters/gemini-adapter.js +71 -2
  12. package/packages/client/dist/adapters/grok-adapter.js +42 -2
  13. package/packages/client/dist/adapters/index.js +22 -1
  14. package/packages/client/dist/adapters/platform-detector.js +214 -1
  15. package/packages/client/dist/adapters/target-adapter.js +12 -0
  16. package/packages/client/dist/adapters/vscode-adapter.js +72 -2
  17. package/packages/client/dist/agent/refresh-stubs.js +443 -2
  18. package/packages/client/dist/agent/update-agent-yaml.js +102 -1
  19. package/packages/client/dist/agent/update-description.js +260 -1
  20. package/packages/client/dist/cache/crypto-utils.js +78 -1
  21. package/packages/client/dist/cache/encrypted-cache.js +338 -1
  22. package/packages/client/dist/cache/in-memory-asset-cache.js +73 -1
  23. package/packages/client/dist/cache/index.js +13 -1
  24. package/packages/client/dist/cache/protected-pi-boundary.js +44 -1
  25. package/packages/client/dist/checkpoint/checkpoint-client-reader.js +127 -2
  26. package/packages/client/dist/checkpoint/index.js +11 -1
  27. package/packages/client/dist/checkpoint/shared-checkpoint-types.js +32 -1
  28. package/packages/client/dist/cli.js +358 -5
  29. package/packages/client/dist/commands/activate.js +394 -8
  30. package/packages/client/dist/commands/architecture-answers.js +274 -7
  31. package/packages/client/dist/commands/architecture-memory-terminal.js +253 -4
  32. package/packages/client/dist/commands/architecture-non-ui-continuation.js +100 -1
  33. package/packages/client/dist/commands/architecture-root-binding.js +51 -1
  34. package/packages/client/dist/commands/cache-status.js +112 -2
  35. package/packages/client/dist/commands/config.js +88 -1
  36. package/packages/client/dist/commands/doctor.js +635 -2
  37. package/packages/client/dist/commands/invoke.js +7712 -143
  38. package/packages/client/dist/commands/legacy-epic-terminal.js +71 -1
  39. package/packages/client/dist/commands/legacy-story-branch.js +96 -1
  40. package/packages/client/dist/commands/legacy-story-pr.js +276 -1
  41. package/packages/client/dist/commands/mutation-qa-checkpoint.js +285 -5
  42. package/packages/client/dist/commands/mutation-qa-gate.js +54 -1
  43. package/packages/client/dist/commands/mutation-qa-git.js +41 -1
  44. package/packages/client/dist/commands/mutation-qa-policy.js +102 -1
  45. package/packages/client/dist/commands/mutation-qa-run.js +219 -3
  46. package/packages/client/dist/commands/mutation-qa-verdict.js +149 -1
  47. package/packages/client/dist/commands/mutation-qa.js +220 -1
  48. package/packages/client/dist/commands/native-agent.js +136 -2
  49. package/packages/client/dist/commands/planning-diagnosis.js +43 -1
  50. package/packages/client/dist/commands/planning-generation.js +53 -1
  51. package/packages/client/dist/commands/planning-memory.js +40 -1
  52. package/packages/client/dist/commands/planning-research.js +42 -1
  53. package/packages/client/dist/commands/private-session.js +75 -1
  54. package/packages/client/dist/commands/property-qa.js +139 -1
  55. package/packages/client/dist/commands/qa-control.js +16 -1
  56. package/packages/client/dist/commands/qa-scan-browser-launch.js +55 -1
  57. package/packages/client/dist/commands/qa-scan-browser-route.js +28 -1
  58. package/packages/client/dist/commands/qa-scan-capture.js +663 -5
  59. package/packages/client/dist/commands/qa-scan-discovery.js +376 -3
  60. package/packages/client/dist/commands/qa-scan-review.js +826 -5
  61. package/packages/client/dist/commands/qa-synthetic-backend-capture.js +266 -1
  62. package/packages/client/dist/commands/qa-synthetic-backend-review.js +297 -1
  63. package/packages/client/dist/commands/qa-synthetic-backend.js +340 -2
  64. package/packages/client/dist/commands/qa-synthetic-broker-port.js +85 -1
  65. package/packages/client/dist/commands/qa-synthetic-browser.js +39 -1
  66. package/packages/client/dist/commands/refactor-characterization.js +671 -21
  67. package/packages/client/dist/commands/refactor-commit.js +399 -13
  68. package/packages/client/dist/commands/refactor-control.js +142 -3
  69. package/packages/client/dist/commands/refactor-cpp-assertions.js +93 -3
  70. package/packages/client/dist/commands/refactor-review.js +283 -5
  71. package/packages/client/dist/commands/refactor-root.js +588 -7
  72. package/packages/client/dist/commands/refresh-memory.js +159 -3
  73. package/packages/client/dist/commands/shared-architecture-non-ui.js +24 -1
  74. package/packages/client/dist/commands/story-checkpoint.js +171 -1
  75. package/packages/client/dist/config/host-auth-broker.js +60 -1
  76. package/packages/client/dist/config/host-auth-reference.js +93 -1
  77. package/packages/client/dist/config/profile-directory.js +13 -1
  78. package/packages/client/dist/config/resolver-selection.js +278 -1
  79. package/packages/client/dist/config/secure-config.js +281 -12
  80. package/packages/client/dist/config.js +223 -2
  81. package/packages/client/dist/constants.js +25 -1
  82. package/packages/client/dist/context/context-collector.js +222 -2
  83. package/packages/client/dist/context/context-sanitizer.js +145 -1
  84. package/packages/client/dist/continuity/autonomous-governance.js +285 -1
  85. package/packages/client/dist/continuity/continuity-client-state-store.js +1587 -1
  86. package/packages/client/dist/continuity/invoke-hooks.js +129 -1
  87. package/packages/client/dist/continuity/migrations/001-initial-schema.js +12 -2
  88. package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +12 -2
  89. package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +12 -2
  90. package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +12 -2
  91. package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +12 -2
  92. package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +10 -2
  93. package/packages/client/dist/continuity/native-agent-store.js +69 -1
  94. package/packages/client/dist/continuity/native-agent-types.js +105 -1
  95. package/packages/client/dist/continuity/outbox.js +117 -1
  96. package/packages/client/dist/continuity/runner-bootstrap-policy.js +172 -1
  97. package/packages/client/dist/continuity/sqlite-store.js +2612 -81
  98. package/packages/client/dist/effects/invoke-effect-gateways.js +62 -1
  99. package/packages/client/dist/errors/error-messages.js +258 -2
  100. package/packages/client/dist/errors/frontmatter-diagnostics.js +125 -1
  101. package/packages/client/dist/evidence/collector.js +347 -1
  102. package/packages/client/dist/evidence/index.js +1 -1
  103. package/packages/client/dist/evidence/types.js +2 -0
  104. package/packages/client/dist/fs/atomic-state-replace.js +152 -1
  105. package/packages/client/dist/generated/command-registry.generated.js +4076 -1
  106. package/packages/client/dist/generated/public-projections.generated.js +149 -1
  107. package/packages/client/dist/git/direct-yolo-c01-retry.js +138 -4
  108. package/packages/client/dist/git/direct-yolo-checkpoint.js +1341 -4
  109. package/packages/client/dist/git/epic-operational-state.js +672 -2
  110. package/packages/client/dist/git/git-lifecycle-step-ids.js +14 -1
  111. package/packages/client/dist/git/git-lifecycle-store.js +2185 -10
  112. package/packages/client/dist/git/legacy-story-branch-checkpoint.js +259 -9
  113. package/packages/client/dist/git/legacy-story-branch-setup.js +348 -4
  114. package/packages/client/dist/git/legacy-story-pr.js +3538 -70
  115. package/packages/client/dist/git/secure-filesystem-boundary.js +182 -5
  116. package/packages/client/dist/graph-retrieval/pre-command-hook.js +284 -1
  117. package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +237 -1
  118. package/packages/client/dist/i18n/first-run.js +60 -2
  119. package/packages/client/dist/index.js +50 -1
  120. package/packages/client/dist/invocation/invoke-input.js +24 -1
  121. package/packages/client/dist/license/host-auth-recovery.js +401 -1
  122. package/packages/client/dist/license/index.js +5 -1
  123. package/packages/client/dist/license/license-client.js +337 -1
  124. package/packages/client/dist/machine/fingerprint.js +163 -2
  125. package/packages/client/dist/machine/index.js +5 -1
  126. package/packages/client/dist/memory/project-memory-path-scope.js +62 -1
  127. package/packages/client/dist/memory/project-memory-writer.js +1067 -41
  128. package/packages/client/dist/memory/shared-project-memory-types.js +259 -2
  129. package/packages/client/dist/migrations/epic-lifecycle-backfill.js +1060 -3
  130. package/packages/client/dist/migrations/project-identity-capability.js +50 -1
  131. package/packages/client/dist/migrations/project-identity.js +493 -7
  132. package/packages/client/dist/migrations/state-json.js +393 -4
  133. package/packages/client/dist/policy/architecture-policy.js +184 -2
  134. package/packages/client/dist/policy/index.js +7 -1
  135. package/packages/client/dist/policy/shared-policy-types.js +38 -0
  136. package/packages/client/dist/policy/subagent-approval-policy.js +55 -1
  137. package/packages/client/dist/private-execution/clean-baseline.js +279 -2
  138. package/packages/client/dist/private-execution/codex-executor.js +574 -4
  139. package/packages/client/dist/private-execution/codex-host-runtime.js +137 -1
  140. package/packages/client/dist/private-execution/codex-lifecycle-guard.js +97 -1
  141. package/packages/client/dist/private-execution/codex-scoped-permissions.js +128 -1
  142. package/packages/client/dist/private-execution/delivery.js +410 -13
  143. package/packages/client/dist/private-execution/diagnosis-root-review.js +294 -2
  144. package/packages/client/dist/private-execution/frozen-handoff.js +19 -6
  145. package/packages/client/dist/private-execution/implementation-validation.js +106 -2
  146. package/packages/client/dist/private-execution/isolated-admission.js +1432 -23
  147. package/packages/client/dist/private-execution/isolated-session.js +725 -5
  148. package/packages/client/dist/private-execution/isolated-workspace.js +122 -1
  149. package/packages/client/dist/private-execution/pact-consumer-runtime.js +409 -3
  150. package/packages/client/dist/private-execution/pact-test-source.js +258 -1
  151. package/packages/client/dist/private-execution/pact-toolchain.js +290 -3
  152. package/packages/client/dist/private-execution/pact-write-set.js +172 -1
  153. package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +406 -5
  154. package/packages/client/dist/private-execution/planning-generation-checkpoint.js +462 -5
  155. package/packages/client/dist/private-execution/planning-memory-checkpoint.js +139 -3
  156. package/packages/client/dist/private-execution/planning-research-checkpoint.js +325 -4
  157. package/packages/client/dist/private-execution/private-report-store.js +42 -1
  158. package/packages/client/dist/private-execution/property-test-candidate.js +103 -1
  159. package/packages/client/dist/private-execution/property-test-choices.js +147 -3
  160. package/packages/client/dist/private-execution/property-test-plan.js +271 -7
  161. package/packages/client/dist/private-execution/property-test-review.js +258 -4
  162. package/packages/client/dist/private-execution/property-test-runtime.js +372 -9
  163. package/packages/client/dist/private-execution/property-test-source.js +139 -1
  164. package/packages/client/dist/private-execution/root-checkpoint.js +80 -1
  165. package/packages/client/dist/private-execution/root-memory-git-evidence.js +135 -3
  166. package/packages/client/dist/private-execution/root-memory-recovery.js +93 -1
  167. package/packages/client/dist/private-execution/root-memory-request.js +29 -1
  168. package/packages/client/dist/private-execution/root-memory-scope.js +178 -1
  169. package/packages/client/dist/private-execution/root-memory-writer.js +102 -1
  170. package/packages/client/dist/private-execution/session-lease.js +63 -1
  171. package/packages/client/dist/private-execution/shared-private-admission-types.js +50 -1
  172. package/packages/client/dist/private-execution/shared-project-validation.js +66 -1
  173. package/packages/client/dist/private-execution/shared-root-memory-types.js +61 -1
  174. package/packages/client/dist/private-execution/ux-source-validation.js +372 -1
  175. package/packages/client/dist/private-execution/ux-write-set.js +191 -2
  176. package/packages/client/dist/registry/registry-reconciliation.js +234 -1
  177. package/packages/client/dist/resilience/circuit-breaker.js +170 -1
  178. package/packages/client/dist/resilience/degradation-manager.js +164 -1
  179. package/packages/client/dist/resilience/freshness-indicator.js +100 -1
  180. package/packages/client/dist/resilience/index.js +8 -1
  181. package/packages/client/dist/resilience/recovery-detector.js +74 -1
  182. package/packages/client/dist/resolvers/asset-resolver.js +13 -0
  183. package/packages/client/dist/resolvers/local-resolver.js +255 -8
  184. package/packages/client/dist/resolvers/remote-resolver.js +233 -1
  185. package/packages/client/dist/runner/binary.js +404 -1
  186. package/packages/client/dist/runner/cli.js +1571 -17
  187. package/packages/client/dist/runner/epic-background-dispatcher.js +124 -1
  188. package/packages/client/dist/runner/headless/adapters.js +49 -1
  189. package/packages/client/dist/runner/headless/background-root.js +85 -1
  190. package/packages/client/dist/runner/headless/claude-code-adapter.js +79 -1
  191. package/packages/client/dist/runner/headless/continuous-story-workspace.js +1628 -11
  192. package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +69 -1
  193. package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +111 -2
  194. package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +1464 -10
  195. package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +357 -2
  196. package/packages/client/dist/runner/headless/fake-adapter.js +62 -1
  197. package/packages/client/dist/runner/headless/managed-environment-cleanup.js +274 -1
  198. package/packages/client/dist/runner/headless/managed-profile.js +149 -1
  199. package/packages/client/dist/runner/headless/opencode-adapter.js +145 -2
  200. package/packages/client/dist/runner/headless/prepared-story-bundle.js +43 -1
  201. package/packages/client/dist/runner/headless/resolver.js +231 -1
  202. package/packages/client/dist/runner/headless/run-yolo.js +886 -1
  203. package/packages/client/dist/runner/headless/run-yoloop.js +2582 -2
  204. package/packages/client/dist/runner/headless/types.js +575 -2
  205. package/packages/client/dist/runner/host-capacity.js +59 -1
  206. package/packages/client/dist/runner/local-console.js +396 -13
  207. package/packages/client/dist/runner/portal-sync-worker.js +1487 -1
  208. package/packages/client/dist/runner/project-identity.js +106 -1
  209. package/packages/client/dist/runner/scheduler.js +995 -7
  210. package/packages/client/dist/runner-cli.js +18 -2
  211. package/packages/client/dist/state/invocation-shape.js +13 -1
  212. package/packages/client/dist/state/project-state-snapshot.js +1751 -1
  213. package/packages/client/dist/state/state-json-repair.js +785 -3
  214. package/packages/client/dist/state/structural-dag-projection.js +118 -1
  215. package/packages/client/dist/telemetry/index.js +5 -1
  216. package/packages/client/dist/telemetry/offline-queue.js +131 -1
  217. package/packages/client/dist/tier/index.js +5 -1
  218. package/packages/client/dist/tier/tier-aware-client.js +405 -1
  219. package/packages/client/dist/types/index.js +38 -1
  220. package/packages/client/dist/version.js +27 -1
  221. package/packages/client/dist/yolo/change-evidence-collector.js +222 -1
  222. package/packages/client/dist/yolo/invoke-envelope-capability.js +62 -1
  223. package/packages/client/dist/yolo/spec-envelope-collector.js +184 -5
  224. package/packages/client/dist/yoloop/discovery-hook.js +300 -2
  225. package/packages/client/dist/yoloop/index.js +8 -1
  226. package/packages/client/dist/yoloop/invoke-hooks.js +669 -12
  227. package/packages/client/dist/yoloop/shared-discover-epics.js +1007 -1
  228. package/packages/client/dist/yoloop/shared-yoloop-types.js +33 -1
  229. package/packages/client/dist/yoloop/target-normalization.js +180 -1
  230. package/packages/client/dist/yoloop/yoloop-client-state-store.js +1920 -1
  231. package/targets-stubs/antigravity/gemini.md +1 -1
  232. package/targets-stubs/antigravity/skill/SKILL.md +1 -1
  233. package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
  234. package/targets-stubs/claude-code/neocortex-root.md +2 -2
  235. package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
  236. package/targets-stubs/claude-code/neocortex.md +2 -2
  237. package/targets-stubs/codex/AGENTS.md +1 -1
  238. package/targets-stubs/cursor/agent.md +2 -2
  239. package/targets-stubs/gemini-cli/agent.md +2 -2
  240. package/targets-stubs/opencode/neocortex-root.md +1 -1
  241. package/targets-stubs/vscode/neocortex.agent.md +2 -2
@@ -1 +1,260 @@
1
- import{readFileSync as d,writeFileSync as A,existsSync as a}from"node:fs";import{execSync as I}from"node:child_process";import{join as i}from"node:path";import{homedir as u}from"node:os";const m=i(u(),".neocortex","config.json"),N={free:"Free",pro:"Pro",enterprise:"Enterprise"},L=60,v=25,E=/^description:\s*".*"$/m,T=/^# 🧠 Neocortex v[\d.]+(?:\s*\([^)]+\)\s*\| OrNexus Team|\s*-\s*Development Orchestrator \| OrNexus Team \([^)]+\))$/m,x=/^│ ### ######## v[\d.]+\s*│$/m,h=/^│ ## ### ###### ## OrNexus Team \([^)]*\)\s*│$/m,F=[{path:i(u(),".claude","agents","neocortex.md"),type:"yaml",fallbackPaths:[i(u(),".claude","agents","neocortex","neocortex.md")]},{path:i(u(),".gemini","agents","agent.md"),type:"yaml"}],O=[{relativePath:i(".cursor","agents","neocortex.md"),type:"yaml"},{relativePath:i(".github","agents","neocortex.md"),type:"yaml"},{relativePath:"AGENTS.md",type:"h1"},{relativePath:i(".agent","skills","neocortex","SKILL.md"),type:"yaml"}];function S(){try{return I("git rev-parse --show-toplevel",{encoding:"utf-8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim()||null}catch{return null}}function y(e,o){const t=L-v-o.length,r=t>0?" ".repeat(t):"";return`${e}${o}${r}\u2502`}function $(e){return y("\u2502 ### ######## ",`v${e}`)}function b(e){const o=N[e.toLowerCase()]??"Free";return y("\u2502 ## ### ###### ## ",`OrNexus Team (${o})`)}function g(e,o){const t=N[o.toLowerCase()]??"Free";return`\u{1F9E0} Neocortex v${e} (${t}) | OrNexus Team`}function R(){try{if(a(m)){const e=d(m,"utf-8");return JSON.parse(e).tier??"free"}}catch{}return"free"}function B(e,o,t){let r=e;return x.test(r)&&(r=r.replace(x,$(o))),h.test(r)&&(r=r.replace(h,b(t))),r}function f(e,o,t,r,c){try{if(!a(e))return!1;let n=d(e,"utf-8");const s=n;return o==="yaml"?E.test(n)&&(n=n.replace(E,`description: "${t}"`)):T.test(n)&&(n=n.replace(T,`# ${t}`)),n=B(n,r,c),n===s?!1:(A(e,n,"utf-8"),!0)}catch{return!1}}function G(e,o){const t=o??R(),r=g(e,t);let c=0;for(const{path:s,type:p,fallbackPaths:l}of F){const _=a(s)?s:l?.find(P=>a(P))??s;f(_,p,r,e,t)&&c++}const n=S();if(n)for(const{relativePath:s,type:p}of O){const l=i(n,s);f(l,p,r,e,t)&&c++}return c}function k(e,o,t,r){const c=r??R(),n=g(t,c);return f(e,o,n,t,c)}export{b as buildBannerTierLine,$ as buildBannerVersionLine,g as buildDescription,R as readTierFromConfig,G as updateAgentDescription,k as updateAgentDescriptionAt};
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 Description Updater (Multi-Platform)
15
+ *
16
+ * Updates the installed agent description across ALL supported platforms
17
+ * with dynamic values: version, tier, and branding.
18
+ *
19
+ * Patches THREE surfaces per file (when present):
20
+ * 1. YAML frontmatter `description: "..."` or Markdown H1 `# ...`
21
+ * 2. ASCII banner version line: `│ ### ######## vX.X.X ...│`
22
+ * 3. ASCII banner tier line: `│ ## ### ###### ## OrNexus Team (Tier) ...│`
23
+ *
24
+ * Supported platforms (home-level):
25
+ * - Claude Code: ~/.claude/agents/neocortex.md (YAML frontmatter;
26
+ * legacy ~/.claude/agents/neocortex/neocortex.md fallback)
27
+ * - Gemini CLI: ~/.gemini/agents/agent.md (YAML frontmatter)
28
+ *
29
+ * Supported platforms (project-level, discovered via git root):
30
+ * - Cursor: <root>/.cursor/agents/neocortex.md (YAML frontmatter)
31
+ * - VSCode: <root>/.github/agents/neocortex.md (YAML frontmatter)
32
+ * - Codex: <root>/AGENTS.md (Markdown H1)
33
+ * - Antigravity: <root>/.agent/skills/neocortex/SKILL.md (YAML frontmatter)
34
+ *
35
+ * Called after:
36
+ * - License activation (activate.ts)
37
+ * - Install (install.sh via sed fallback for all platforms)
38
+ *
39
+ * Format: 🧠 Neocortex vX.X.X (Tier) | OrNexus Team
40
+ */
41
+ import { readFileSync, writeFileSync, existsSync } from 'node:fs';
42
+ import { execSync } from 'node:child_process';
43
+ import { join } from 'node:path';
44
+ import { homedir } from 'node:os';
45
+ // ── Constants ─────────────────────────────────────────────────────────────
46
+ const CONFIG_FILE = join(homedir(), '.neocortex', 'config.json');
47
+ const TIER_LABELS = {
48
+ free: 'Free',
49
+ pro: 'Pro',
50
+ enterprise: 'Enterprise',
51
+ };
52
+ /**
53
+ * Banner frame geometry.
54
+ * Frame is 62 chars wide: │ + 60 inner chars + │
55
+ * Both dynamic lines have a 25-char inner prefix (after the leading │).
56
+ */
57
+ const BANNER_INNER_WIDTH = 60;
58
+ const BANNER_PREFIX_INNER = 25; // chars after leading │, before dynamic content
59
+ // YAML frontmatter: description: "..."
60
+ const YAML_DESCRIPTION_PATTERN = /^description:\s*".*"$/m;
61
+ // Markdown H1: # 🧠 Neocortex vX.X.X (Tier) | OrNexus Team
62
+ // Also matches legacy format: # 🧠 Neocortex vX.X.X - Development Orchestrator | OrNexus Team (Tier)
63
+ const H1_DESCRIPTION_PATTERN = /^# 🧠 Neocortex v[\d.]+(?:\s*\([^)]+\)\s*\| OrNexus Team|\s*-\s*Development Orchestrator \| OrNexus Team \([^)]+\))$/m;
64
+ // Banner version line: │ ### ######## vX.X.X<spaces>│
65
+ const BANNER_VERSION_PATTERN = /^│ ### ######## v[\d.]+\s*│$/m;
66
+ // Banner tier line: │ ## ### ###### ## OrNexus Team (<Tier>)<spaces>│
67
+ const BANNER_TIER_PATTERN = /^│ ## ### ###### ## OrNexus Team \([^)]*\)\s*│$/m;
68
+ /**
69
+ * All known home-directory agent files, grouped by description format.
70
+ */
71
+ const HOME_AGENT_FILES = [
72
+ // Claude Code (home-level). Claude Code only discovers top-level
73
+ // `agents/*.md`; the nested path is the pre-migration legacy location.
74
+ {
75
+ path: join(homedir(), '.claude', 'agents', 'neocortex.md'),
76
+ type: 'yaml',
77
+ fallbackPaths: [join(homedir(), '.claude', 'agents', 'neocortex', 'neocortex.md')],
78
+ },
79
+ // Gemini CLI (home-level)
80
+ { path: join(homedir(), '.gemini', 'agents', 'agent.md'), type: 'yaml' },
81
+ ];
82
+ /**
83
+ * Known project-level agent file paths (relative to project root).
84
+ * These are patched after license activation so the tier reflects reality.
85
+ */
86
+ const PROJECT_AGENT_FILES = [
87
+ // Cursor
88
+ { relativePath: join('.cursor', 'agents', 'neocortex.md'), type: 'yaml' },
89
+ // VSCode / GitHub Copilot
90
+ { relativePath: join('.github', 'agents', 'neocortex.md'), type: 'yaml' },
91
+ // Codex
92
+ { relativePath: 'AGENTS.md', type: 'h1' },
93
+ // Antigravity
94
+ { relativePath: join('.agent', 'skills', 'neocortex', 'SKILL.md'), type: 'yaml' },
95
+ ];
96
+ // ── Project Root Discovery ────────────────────────────────────────────────
97
+ /**
98
+ * Discover the git project root, or null if not in a git repo.
99
+ * Never throws -- returns null on any failure.
100
+ */
101
+ function discoverProjectRoot() {
102
+ try {
103
+ const root = execSync('git rev-parse --show-toplevel', {
104
+ encoding: 'utf-8',
105
+ timeout: 5000,
106
+ stdio: ['pipe', 'pipe', 'pipe'],
107
+ }).trim();
108
+ return root || null;
109
+ }
110
+ catch {
111
+ return null;
112
+ }
113
+ }
114
+ // ── Banner Helpers ────────────────────────────────────────────────────────
115
+ /**
116
+ * Build a right-padded banner line.
117
+ * Prefix is the fixed art portion INCLUDING the leading │ (26 chars).
118
+ * Content is the dynamic text. Padding fills to inner width, then closing │.
119
+ *
120
+ * Total: │(1) + prefixInner(25) + content + pad + │(1) = 62 chars.
121
+ */
122
+ function buildBannerLine(prefix, content) {
123
+ const padLen = BANNER_INNER_WIDTH - BANNER_PREFIX_INNER - content.length;
124
+ const padding = padLen > 0 ? ' '.repeat(padLen) : '';
125
+ return `${prefix}${content}${padding}\u2502`; // \u2502 = │
126
+ }
127
+ /**
128
+ * Build the banner version line with correct padding.
129
+ */
130
+ export function buildBannerVersionLine(version) {
131
+ return buildBannerLine('\u2502 ### ######## ', `v${version}`);
132
+ }
133
+ /**
134
+ * Build the banner tier line with correct padding.
135
+ */
136
+ export function buildBannerTierLine(tier) {
137
+ const label = TIER_LABELS[tier.toLowerCase()] ?? 'Free';
138
+ return buildBannerLine('\u2502 ## ### ###### ## ', `OrNexus Team (${label})`);
139
+ }
140
+ // ── Public API ────────────────────────────────────────────────────────────
141
+ /**
142
+ * Build the dynamic description string (without quotes/prefix).
143
+ */
144
+ export function buildDescription(version, tier) {
145
+ const label = TIER_LABELS[tier.toLowerCase()] ?? 'Free';
146
+ return `\u{1F9E0} Neocortex v${version} (${label}) | OrNexus Team`;
147
+ }
148
+ /**
149
+ * Read the current tier from ~/.neocortex/config.json.
150
+ * Returns 'free' if config doesn't exist or tier is missing.
151
+ */
152
+ export function readTierFromConfig() {
153
+ try {
154
+ if (existsSync(CONFIG_FILE)) {
155
+ const raw = readFileSync(CONFIG_FILE, 'utf-8');
156
+ const config = JSON.parse(raw);
157
+ return config.tier ?? 'free';
158
+ }
159
+ }
160
+ catch {
161
+ // Config missing or corrupted
162
+ }
163
+ return 'free';
164
+ }
165
+ /**
166
+ * Patch ASCII banner lines (version + tier) in file content.
167
+ * Returns the patched content, or the original if no banner found.
168
+ */
169
+ function patchBannerLines(content, version, tier) {
170
+ let patched = content;
171
+ // Patch version line
172
+ if (BANNER_VERSION_PATTERN.test(patched)) {
173
+ patched = patched.replace(BANNER_VERSION_PATTERN, buildBannerVersionLine(version));
174
+ }
175
+ // Patch tier line
176
+ if (BANNER_TIER_PATTERN.test(patched)) {
177
+ patched = patched.replace(BANNER_TIER_PATTERN, buildBannerTierLine(tier));
178
+ }
179
+ return patched;
180
+ }
181
+ /**
182
+ * Update a single file's description and banner.
183
+ * Supports YAML frontmatter, H1 header, and ASCII banner lines.
184
+ *
185
+ * Never throws -- description update is non-critical.
186
+ */
187
+ function updateFile(filePath, type, description, version, tier) {
188
+ try {
189
+ if (!existsSync(filePath)) {
190
+ return false;
191
+ }
192
+ let content = readFileSync(filePath, 'utf-8');
193
+ const original = content;
194
+ // 1. Patch description (YAML frontmatter or H1 header)
195
+ if (type === 'yaml') {
196
+ if (YAML_DESCRIPTION_PATTERN.test(content)) {
197
+ content = content.replace(YAML_DESCRIPTION_PATTERN, `description: "${description}"`);
198
+ }
199
+ }
200
+ else {
201
+ if (H1_DESCRIPTION_PATTERN.test(content)) {
202
+ content = content.replace(H1_DESCRIPTION_PATTERN, `# ${description}`);
203
+ }
204
+ }
205
+ // 2. Patch ASCII banner lines (version + tier) if present
206
+ content = patchBannerLines(content, version, tier);
207
+ if (content === original) {
208
+ return false; // Already up to date
209
+ }
210
+ writeFileSync(filePath, content, 'utf-8');
211
+ return true;
212
+ }
213
+ catch {
214
+ return false;
215
+ }
216
+ }
217
+ /**
218
+ * Update agent descriptions across ALL known platform files:
219
+ * 1. Home-level files (Claude Code, Gemini CLI)
220
+ * 2. Project-level files (Cursor, VSCode, Codex, Antigravity) -- discovered via git root
221
+ *
222
+ * Never throws -- description update is non-critical.
223
+ * Returns count of files updated.
224
+ */
225
+ export function updateAgentDescription(version, tier) {
226
+ const resolvedTier = tier ?? readTierFromConfig();
227
+ const description = buildDescription(version, resolvedTier);
228
+ let updated = 0;
229
+ // 1. Home-level files (existing behavior)
230
+ for (const { path, type, fallbackPaths } of HOME_AGENT_FILES) {
231
+ const resolvedPath = existsSync(path)
232
+ ? path
233
+ : (fallbackPaths?.find((candidate) => existsSync(candidate)) ?? path);
234
+ if (updateFile(resolvedPath, type, description, version, resolvedTier)) {
235
+ updated++;
236
+ }
237
+ }
238
+ // 2. Project-level files (discover git root, then check known paths)
239
+ const projectRoot = discoverProjectRoot();
240
+ if (projectRoot) {
241
+ for (const { relativePath, type } of PROJECT_AGENT_FILES) {
242
+ const fullPath = join(projectRoot, relativePath);
243
+ if (updateFile(fullPath, type, description, version, resolvedTier)) {
244
+ updated++;
245
+ }
246
+ }
247
+ }
248
+ return updated;
249
+ }
250
+ /**
251
+ * Update agent description for a specific file path (used by install scripts
252
+ * for project-level files where paths are dynamic).
253
+ *
254
+ * Never throws -- description update is non-critical.
255
+ */
256
+ export function updateAgentDescriptionAt(filePath, type, version, tier) {
257
+ const resolvedTier = tier ?? readTierFromConfig();
258
+ const description = buildDescription(version, resolvedTier);
259
+ return updateFile(filePath, type, description, version, resolvedTier);
260
+ }
@@ -1 +1,78 @@
1
- import{randomBytes as d,pbkdf2Sync as h,createCipheriv as S,createDecipheriv as m}from"node:crypto";import{assertPublicSafeCachePayload as v}from"./protected-pi-boundary.js";const l="aes-256-gcm",b=12,A=32,B=32,g=16,N=1e5,x="sha512";function y(e,n){return h(e,n,N,B,x)}function _(e,n,t){v(e);const s=d(b),c=d(A),i=y(n,c),f=t!=null?Date.now()+t:null,a=JSON.stringify({plaintext:e,expiresAt:f}),o=S(l,i,s,{authTagLength:g}),r=Buffer.concat([o.update(a,"utf8"),o.final()]),p=o.getAuthTag(),T={iv:s.toString("base64"),salt:c.toString("base64"),tag:p.toString("base64"),data:r.toString("base64")};return JSON.stringify(T)}function G(e,n){const t=JSON.parse(e);if(!t.iv||!t.salt||!t.tag||!t.data)throw new Error("Invalid cache envelope: missing required fields");const s=Buffer.from(t.iv,"base64"),c=Buffer.from(t.salt,"base64"),i=Buffer.from(t.tag,"base64"),f=Buffer.from(t.data,"base64"),u=y(n,c),a=m(l,u,s,{authTagLength:g});a.setAuthTag(i);const o=Buffer.concat([a.update(f),a.final()]),r=JSON.parse(o.toString("utf8")),p=r.expiresAt!=null&&Date.now()>r.expiresAt;return{plaintext:r.plaintext,expired:p}}export{G as decrypt,y as deriveKey,_ as encrypt};
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 - Crypto Utilities
15
+ *
16
+ * AES-256-GCM encryption/decryption with PBKDF2 key derivation.
17
+ * Used by EncryptedCache to protect cached assets at rest.
18
+ *
19
+ * Security design:
20
+ * - IV: 12 bytes (NIST SP 800-38D recommended for GCM)
21
+ * - Salt: 32 bytes random per entry
22
+ * - Key: PBKDF2 with 100k iterations, SHA-512
23
+ * - expiresAt is inside the encrypted payload (authenticated by GCM tag)
24
+ */
25
+ import { randomBytes, pbkdf2Sync, createCipheriv, createDecipheriv } from 'node:crypto';
26
+ import { assertPublicSafeCachePayload } from './protected-pi-boundary.js';
27
+ // ── Constants ────────────────────────────────────────────────────────────
28
+ const ALGORITHM = 'aes-256-gcm';
29
+ const IV_LENGTH = 12; // NIST SP 800-38D recommended for AES-GCM
30
+ const SALT_LENGTH = 32;
31
+ const KEY_LENGTH = 32;
32
+ const AUTH_TAG_LENGTH = 16;
33
+ const PBKDF2_ITERATIONS = 100_000;
34
+ const PBKDF2_DIGEST = 'sha512';
35
+ // ── Key Derivation ───────────────────────────────────────────────────────
36
+ export function deriveKey(passphrase, salt) {
37
+ return pbkdf2Sync(passphrase, salt, PBKDF2_ITERATIONS, KEY_LENGTH, PBKDF2_DIGEST);
38
+ }
39
+ // ── Encrypt ──────────────────────────────────────────────────────────────
40
+ export function encrypt(plaintext, passphrase, ttlMs) {
41
+ assertPublicSafeCachePayload(plaintext);
42
+ const iv = randomBytes(IV_LENGTH);
43
+ const salt = randomBytes(SALT_LENGTH);
44
+ const key = deriveKey(passphrase, salt);
45
+ const expiresAt = ttlMs != null ? Date.now() + ttlMs : null;
46
+ const payload = { plaintext, expiresAt };
47
+ const payloadJson = JSON.stringify(payload);
48
+ const cipher = createCipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
49
+ const encrypted = Buffer.concat([cipher.update(payloadJson, 'utf8'), cipher.final()]);
50
+ const tag = cipher.getAuthTag();
51
+ const envelope = {
52
+ iv: iv.toString('base64'),
53
+ salt: salt.toString('base64'),
54
+ tag: tag.toString('base64'),
55
+ data: encrypted.toString('base64'),
56
+ };
57
+ return JSON.stringify(envelope);
58
+ }
59
+ export function decrypt(envelopeJson, passphrase) {
60
+ const raw = JSON.parse(envelopeJson);
61
+ if (!raw.iv || !raw.salt || !raw.tag || !raw.data) {
62
+ throw new Error('Invalid cache envelope: missing required fields');
63
+ }
64
+ const iv = Buffer.from(raw.iv, 'base64');
65
+ const salt = Buffer.from(raw.salt, 'base64');
66
+ const tag = Buffer.from(raw.tag, 'base64');
67
+ const data = Buffer.from(raw.data, 'base64');
68
+ const key = deriveKey(passphrase, salt);
69
+ const decipher = createDecipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
70
+ decipher.setAuthTag(tag);
71
+ const decrypted = Buffer.concat([decipher.update(data), decipher.final()]);
72
+ const payload = JSON.parse(decrypted.toString('utf8'));
73
+ const expired = payload.expiresAt != null && Date.now() > payload.expiresAt;
74
+ return {
75
+ plaintext: payload.plaintext,
76
+ expired,
77
+ };
78
+ }