@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,405 +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
- import { GENERATED_CLIENT_COMMANDS } from '../generated/command-registry.generated.js';
14
- // ── Constants ────────────────────────────────────────────────────────────
15
- const TIER_CACHE_KEY = 'neocortex:tier';
16
- const QUOTA_CACHE_KEY_PREFIX = 'neocortex:quota:';
17
- const QUOTA_TTL_MS = 5 * 60 * 1000; // 5 minutes
18
- const TIER_CACHE_TTL_MS = 60 * 60 * 1000; // 1 hour (Story 31.05: reduced from 24h to align with short-lived JWTs)
19
- const VALID_TIERS = new Set(['free', 'pro', 'enterprise']);
20
- const DEFAULT_TIER = 'free';
21
- // ── Trigger Gates (inlined from shared tier-config to avoid import issues) ─
22
- const LEGACY_TRIGGER_GATES = {
23
- 'status': 'free',
24
- 'create-epic': 'free',
25
- 'idea-diagnose': 'free',
26
- 'idea-research': 'free',
27
- 'generate-epic': 'free',
28
- 'exec': 'pro',
29
- 'yolo': 'pro',
30
- 'epic': 'pro',
31
- 'setup-branch': 'free',
32
- 'diagnose': 'free',
33
- 'research': 'free',
34
- 'write-spec': 'free',
35
- 'create-tasks': 'free',
36
- 'implement': 'free',
37
- 'update-memory': 'free',
38
- 'commit': 'free',
39
- 'sync': 'free',
40
- 'create-pr': 'free',
41
- 'review': 'pro',
42
- 'merge': 'free',
43
- 'fix-blocked': 'free',
44
- 'finalize-epic': 'free',
45
- 'cleanup': 'free',
46
- 'resolve-conflicts': 'free',
47
- 'audit': 'free',
48
- 'menu': 'free',
49
- 'plans': 'free',
50
- 'billing': 'free',
51
- 'subscribe': 'free',
52
- 'arch-plan': 'free',
53
- 'arch-prd': 'free',
54
- 'arch-architecture': 'free',
55
- 'arch-api-contracts': 'free',
56
- 'arch-api-integrations': 'free',
57
- 'arch-database': 'free',
58
- 'arch-security': 'free',
59
- 'arch-design-system': 'free',
60
- 'arch-ux-design': 'free',
61
- 'arch-review': 'free',
62
- 'arch-fitness-functions': 'pro',
63
- 'arch-performance': 'pro',
64
- 'arch-testing': 'pro',
65
- 'arch-infrastructure': 'pro',
66
- 'refactor': 'pro',
67
- 'tech-debt': 'free',
68
- 'tech-debt-scan': 'pro',
69
- 'qa-scan': 'pro',
70
- 'mutation-test': 'pro',
71
- 'yoloop': 'pro',
72
- 'migrate-state': 'free',
73
- 'policy-audit': 'pro',
74
- 'sync-openapi': 'free',
75
- 'generate-pacts': 'pro',
76
- 'verify-pacts': 'free',
77
- 'property-test': 'pro',
78
- 'chaos-plan': 'pro',
79
- 'ui-ux-review': 'pro',
80
- 'solyd-system': 'enterprise',
81
- 'goal': 'enterprise',
82
- 'goal-tick': 'enterprise',
83
- 'loop': 'enterprise',
84
- 'loop-tick': 'enterprise',
85
- 'jobs': 'enterprise',
86
- 'runner': 'enterprise',
87
- };
88
- const TRIGGER_GATES = Object.freeze(Object.fromEntries(GENERATED_CLIENT_COMMANDS.map((entry) => [entry.id, entry.policy.minimumTier])));
89
- void LEGACY_TRIGGER_GATES;
90
- // P126.07: runtime mirror of shared COMMAND_REGISTRY command identity only.
91
- // Keep this small to avoid a runtime @neocortex/shared dependency in the
92
- // standalone client package; flexible-preflight.test.ts validates drift.
93
- const LEGACY_CLIENT_PREFLIGHT_COMMAND_REGISTRY = [
94
- { id: 'status', number: 1, aliases: ['st'] },
95
- { id: 'arch-plan', number: 3, aliases: ['arquitetura', 'architecture', 'arch'] },
96
- { id: 'arch-prd', number: 4, aliases: ['prd', 'product-requirements'] },
97
- { id: 'arch-architecture', number: 5, aliases: ['arch-doc', 'tech-architecture'] },
98
- { id: 'arch-api-contracts', number: 6, aliases: ['api-contracts', 'api-contract'] },
99
- { id: 'arch-api-integrations', number: 7, aliases: ['api-integrations', 'api-int'] },
100
- { id: 'arch-database', number: 8, aliases: ['database-schema', 'db-schema', 'db'] },
101
- { id: 'arch-security', number: 9, aliases: ['cyber-security', 'security', 'sec'] },
102
- { id: 'arch-design-system', number: 10, aliases: ['design-system', 'ds', 'atomic-design'] },
103
- { id: 'arch-ux-design', number: 11, aliases: ['ux-design', 'ux', 'wireframes', 'wireframe', 'user-flows'] },
104
- { id: 'arch-performance', number: 12, aliases: ['performance', 'perf', 'capacity-planning', 'capacity', 'arch-perf', 'performance-strategy'] },
105
- { id: 'arch-testing', number: 13, aliases: ['testing-strategy', 'test-plan', 'test-strategy', 'arch-test'] },
106
- { id: 'arch-infrastructure', number: 14, aliases: ['infrastructure', 'infra', 'deploy-plan', 'deployment', 'arch-infra', 'arch-deploy'] },
107
- { id: 'arch-review', number: 15, aliases: ['review-consolidation', 'consolidation', 'architecture-review', 'arch-consolidation'] },
108
- { id: 'arch-fitness-functions', number: 16, aliases: ['fitness', 'fitness-functions', 'archfit', 'arch-fit', 'fit-funcs'] },
109
- { id: 'create-epic', number: 17, aliases: ['criar-epic', 'planejamento'] },
110
- { id: 'idea-diagnose', number: 18, aliases: ['idea-diag'] },
111
- { id: 'idea-research', number: 19, aliases: ['idea-pesq'] },
112
- { id: 'generate-epic', number: 20, aliases: ['gerar-epic'] },
113
- { id: 'exec', number: 21, aliases: ['executar', 'pipeline'] },
114
- { id: 'yolo', number: 22, aliases: [] },
115
- { id: 'epic', number: 23, aliases: ['parallel-epic'] },
116
- { id: 'setup-branch', number: 24, aliases: ['setup', 'branch'] },
117
- { id: 'diagnose', number: 25, aliases: ['diag', 'diagnostico', 'c02'] },
118
- { id: 'research', number: 26, aliases: ['pesquisar', 'pesq', 'research-fix', 'c03'] },
119
- { id: 'write-spec', number: 27, aliases: ['spec', 'especificacao', 'c04'] },
120
- { id: 'create-tasks', number: 28, aliases: ['tasks', 'tarefas', 'c05'] },
121
- { id: 'implement', number: 29, aliases: ['impl', 'implementar', 'c06'] },
122
- { id: 'commit', number: 30, aliases: ['push', 'commit-push', 'commit_push', 'cp', 'c07'] },
123
- { id: 'sync', number: 31, aliases: ['sincronizar', 'c08'] },
124
- { id: 'create-pr', number: 32, aliases: ['pr', 'c09'] },
125
- { id: 'review', number: 33, aliases: ['revisar', 'c11'] },
126
- { id: 'merge', number: 34, aliases: ['mesclar', 'c12'] },
127
- { id: 'fix-blocked', number: 35, aliases: ['fix', 'corrigir'] },
128
- { id: 'finalize-epic', number: 36, aliases: ['finalizar'] },
129
- { id: 'resolve-conflicts', number: 37, aliases: ['conflitos'] },
130
- { id: 'update-memory', number: 38, aliases: ['memoria'] },
131
- { id: 'refactor', number: 39, aliases: ['refactoring', 'refact', 'refac', 'rf', 'cleanup-code', 'code-cleanup', 'code-quality', 'improve-code', 'modernize', 'modernization', 'legacy', 'legacy-code', 'debt-pay', 'pay-debt', 'debt-reduction', 'smell-fix', 'fix-smells', 'code-smells', 'strangler', 'strangler-fig'] },
132
- { id: 'cleanup', number: 40, aliases: ['limpar', 'limpeza'] },
133
- { id: 'audit', number: 41, aliases: ['auditar', 'auditoria'] },
134
- { id: 'tech-debt', number: 42, aliases: ['debt', 'debts', 'debt-list', 'tech-debts', 'td'] },
135
- { id: 'menu', number: 43, aliases: ['help', 'ajuda', '?', 'commands', 'cmds'] },
136
- { id: 'plans', number: 44, aliases: ['planos', 'pricing'] },
137
- { id: 'billing', number: 45, aliases: ['bill', 'subscription', 'sub'] },
138
- { id: 'subscribe', number: 46, aliases: ['upgrade', 'checkout'] },
139
- { id: 'qa-scan', number: 47, aliases: ['qa', 'qa-test', 'visual-qa', 'e2e-scan', 'troubleshoot', 'debug-ui', 'scan', 'a11y', 'accessibility', 'wcag'] },
140
- { id: 'yoloop', number: 48, aliases: ['auto-yolo', 'epic-runner', 'story-runner', 'loop-yolo', 'auto-epic'] },
141
- { id: 'migrate-state', number: 49, aliases: ['migrate', 'state-migrate', 'schema-migrate'] },
142
- { id: 'policy-audit', number: 50, aliases: ['policy', 'audit-policy', 'policy-history', 'policies'] },
143
- { id: 'mutation-test', number: 51, aliases: ['mutation', 'stryker', 'kill-mutants'] },
144
- { id: 'sync-openapi', number: 52, aliases: ['openapi-sync', 'api-sync', 'spec-sync', 'regen-openapi'] },
145
- { id: 'generate-pacts', number: 53, aliases: ['pacts', 'gen-pacts', 'regen-pacts', 'create-pacts'] },
146
- { id: 'verify-pacts', number: 54, aliases: ['verify-pact', 'pact-verify', 'check-pacts', 'pact-check'] },
147
- { id: 'property-test', number: 55, aliases: ['property', 'pbt', 'proptest', 'property-tests', 'invariant-test'] },
148
- { id: 'chaos-plan', number: 56, aliases: ['chaos', 'gameday', 'resilience-test'] },
149
- { id: 'ui-ux-review', number: 57, aliases: ['ux-review', 'design-review', 'visual-review', 'product-polish'] },
150
- { id: 'solyd-system', number: 58, aliases: ['security-system', 'authorized-security', 'sec-system'] },
151
- { id: 'goal', number: 59, aliases: ['goals', 'durable-goal', 'continuity-goal'] },
152
- { id: 'loop', number: 60, aliases: ['loops', 'durable-loop', 'continuity-loop'] },
153
- { id: 'jobs', number: 61, aliases: ['job', 'continuity-jobs'] },
154
- { id: 'runner', number: 62, aliases: ['neocortex-runner', 'continuity-runner'] },
155
- ];
156
- export const CLIENT_PREFLIGHT_COMMAND_REGISTRY = Object.freeze(GENERATED_CLIENT_COMMANDS.map((entry) => Object.freeze({
157
- id: entry.id,
158
- number: entry.number,
159
- aliases: entry.aliases,
160
- })));
161
- void LEGACY_CLIENT_PREFLIGHT_COMMAND_REGISTRY;
162
- const CLIENT_COMMAND_BY_ID = new Map(CLIENT_PREFLIGHT_COMMAND_REGISTRY.map((entry) => [entry.id, entry]));
163
- const CLIENT_COMMAND_BY_NUMBER = new Map(CLIENT_PREFLIGHT_COMMAND_REGISTRY.map((entry) => [entry.number, entry]));
164
- const CLIENT_COMMAND_ALIAS_MAP = new Map(CLIENT_PREFLIGHT_COMMAND_REGISTRY.flatMap((entry) => entry.aliases.map((alias) => [normalizeCommandToken(alias), entry.id])));
165
- export function normalizeCommandToken(input) {
166
- if (/[^\x20-\x7e]/.test(input))
167
- return '';
168
- const trimmed = input.replace(/^[\t\n\r ]+|[\t\n\r ]+$/g, '');
169
- if (!trimmed || trimmed.startsWith('**'))
170
- return '';
171
- const token = (trimmed.startsWith('*') ? trimmed.slice(1) : trimmed)
172
- .replace(/[A-Z]/g, (letter) => letter.toLowerCase());
173
- return /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(token) || token === '?' ? token : '';
174
- }
175
- export function resolveClientPreFlightTrigger(input) {
176
- const trimmed = input.trim();
177
- if (/^@?epic-[a-z0-9][a-z0-9._-]*$/i.test(trimmed))
178
- return 'epic';
179
- // P179.02: local pre-flight mirrors invoke's leading-token command contract
180
- // so Free/Pro users are gated before remote invocation for `58 plan` and
181
- // Solyd alias-with-mode forms. Only the first public token is considered.
182
- const leadingToken = trimmed.split(/\s+/, 1)[0] ?? '';
183
- const numericToken = leadingToken.trim().replace(/^\*/, '');
184
- if (/^\d+$/.test(numericToken)) {
185
- return CLIENT_COMMAND_BY_NUMBER.get(Number.parseInt(numericToken, 10))?.id ?? null;
186
- }
187
- const token = normalizeCommandToken(leadingToken);
188
- if (!token)
189
- return null;
190
- if (token === 'goal-tick')
191
- return 'goal';
192
- if (token === 'loop-tick')
193
- return 'loop';
194
- if (CLIENT_COMMAND_BY_ID.has(token))
195
- return token;
196
- return CLIENT_COMMAND_ALIAS_MAP.get(token) ?? null;
197
- }
198
- const TIER_HIERARCHY = {
199
- free: 0,
200
- pro: 1,
201
- enterprise: 2,
202
- };
203
- // ── TierAwareClient ──────────────────────────────────────────────────────
204
- export class TierAwareClient {
205
- cache;
206
- licenseClient;
207
- cachedTier = null;
208
- constructor(options) {
209
- this.cache = options.cacheProvider;
210
- this.licenseClient = options.licenseClient;
211
- }
212
- // ── Story 60.1: Tier Extraction from JWT + Cache ────────────────────
213
- /**
214
- * Get the current tier. Checks in-memory, then cache, then JWT token.
215
- * NEVER throws - returns 'free' on failure (fail-open).
216
- */
217
- async getCachedTier() {
218
- try {
219
- // 1. In-memory
220
- if (this.cachedTier)
221
- return this.cachedTier;
222
- // 2. EncryptedCache
223
- const cached = await this.cache.get(TIER_CACHE_KEY);
224
- if (cached && VALID_TIERS.has(cached)) {
225
- this.cachedTier = cached;
226
- return this.cachedTier;
227
- }
228
- // 3. Extract from JWT
229
- const token = await this.licenseClient.getToken();
230
- if (token) {
231
- const tier = this.extractTierFromJwt(token);
232
- this.cachedTier = tier;
233
- await this.cache.set(TIER_CACHE_KEY, tier, TIER_CACHE_TTL_MS).catch(() => { });
234
- return tier;
235
- }
236
- return DEFAULT_TIER;
237
- }
238
- catch {
239
- return DEFAULT_TIER;
240
- }
241
- }
242
- /**
243
- * Update cached tier (called when server returns tier info).
244
- */
245
- async updateTier(tier) {
246
- try {
247
- if (!VALID_TIERS.has(tier))
248
- return;
249
- this.cachedTier = tier;
250
- await this.cache.set(TIER_CACHE_KEY, tier, TIER_CACHE_TTL_MS).catch(() => { });
251
- }
252
- catch {
253
- // Non-critical
254
- }
255
- }
256
- // ── Story 18.8: Tier Cache Invalidation ──────────────────────────────
257
- /**
258
- * Invalidate all tier and quota caches.
259
- * Called when a tier change is detected to ensure fresh data.
260
- * NEVER throws.
261
- */
262
- async invalidateTierCache() {
263
- try {
264
- this.cachedTier = null;
265
- await this.cache.clear().catch(() => { });
266
- }
267
- catch {
268
- // Non-critical
269
- }
270
- }
271
- // ── Story 60.2: Pre-flight Trigger Check ────────────────────────────
272
- /**
273
- * Check if a trigger is allowed for the current tier WITHOUT calling the server.
274
- * Returns immediately (in-memory lookup).
275
- * NEVER throws - returns { allowed: true } on failure (fail-open).
276
- */
277
- async preFlightCheck(trigger, tier) {
278
- try {
279
- const userTier = tier ?? await this.getCachedTier();
280
- const canonicalTrigger = resolveClientPreFlightTrigger(trigger) ?? trigger;
281
- const requiredTier = TRIGGER_GATES[canonicalTrigger] ?? 'free';
282
- if (TIER_HIERARCHY[userTier] >= TIER_HIERARCHY[requiredTier]) {
283
- return { allowed: true };
284
- }
285
- const message = this.buildUpgradeMessage(canonicalTrigger, userTier, requiredTier);
286
- return { allowed: false, message };
287
- }
288
- catch {
289
- // Fail-open: allow on error
290
- return { allowed: true };
291
- }
292
- }
293
- // ── Story 60.3: Quota Cache from Response ───────────────────────────
294
- /**
295
- * Update cached quota from server response metadata.
296
- * Called after each successful invoke.
297
- */
298
- async updateQuotaFromResponse(metadata) {
299
- try {
300
- const quotaRemaining = metadata.quotaRemaining;
301
- if (!quotaRemaining)
302
- return;
303
- const snapshot = {
304
- stepsRemaining: quotaRemaining.stepsRemaining ?? 0,
305
- invocationsRemaining: quotaRemaining.invocationsRemaining ?? 0,
306
- stepsLimit: quotaRemaining.stepsLimit ?? 0,
307
- invocationsLimit: quotaRemaining.invocationsLimit ?? 0,
308
- cachedAt: Date.now(),
309
- };
310
- const dateKey = this.getQuotaCacheKey();
311
- await this.cache.set(dateKey, JSON.stringify(snapshot), QUOTA_TTL_MS).catch(() => { });
312
- }
313
- catch {
314
- // Non-critical
315
- }
316
- }
317
- /**
318
- * Get cached quota for today.
319
- * NEVER throws - returns null if cache empty or expired.
320
- */
321
- async getCachedQuota() {
322
- try {
323
- const dateKey = this.getQuotaCacheKey();
324
- const raw = await this.cache.get(dateKey);
325
- if (!raw)
326
- return null;
327
- const snapshot = JSON.parse(raw);
328
- // Validate TTL (EncryptedCache already handles this, but double-check)
329
- if (Date.now() - snapshot.cachedAt > QUOTA_TTL_MS)
330
- return null;
331
- return snapshot;
332
- }
333
- catch {
334
- return null;
335
- }
336
- }
337
- // ── Story 60.4: Offline Enforcement ─────────────────────────────────
338
- /**
339
- * Check quota in offline mode using cached data.
340
- * NEVER throws - returns { allowed: true } on failure (fail-open).
341
- *
342
- * @param isOffline - Whether the circuit breaker is in L2+ degradation
343
- */
344
- async offlineQuotaCheck(isOffline = false) {
345
- try {
346
- if (!isOffline)
347
- return { allowed: true };
348
- const quota = await this.getCachedQuota();
349
- // Fail-open: if no cached quota, allow
350
- if (!quota)
351
- return { allowed: true };
352
- // Check steps
353
- if (quota.stepsRemaining <= 0 && quota.stepsLimit > 0) {
354
- return {
355
- allowed: false,
356
- message: `Daily step limit reached (${quota.stepsLimit}/${quota.stepsLimit}). Resets at 00:00 UTC.`,
357
- };
358
- }
359
- // Check invocations
360
- if (quota.invocationsRemaining <= 0 && quota.invocationsLimit > 0) {
361
- return {
362
- allowed: false,
363
- message: `Daily invocation limit reached (${quota.invocationsLimit}/${quota.invocationsLimit}). Resets at 00:00 UTC.`,
364
- };
365
- }
366
- return { allowed: true };
367
- }
368
- catch {
369
- // Fail-open
370
- return { allowed: true };
371
- }
372
- }
373
- // ── Private Helpers ─────────────────────────────────────────────────
374
- /**
375
- * Extract tier from JWT payload via base64url decode.
376
- * No cryptographic verification - client-side is UX only.
377
- */
378
- extractTierFromJwt(token) {
379
- try {
380
- const parts = token.split('.');
381
- if (parts.length !== 3)
382
- return DEFAULT_TIER;
383
- // Decode base64url payload
384
- const payload = parts[1];
385
- const decoded = Buffer.from(payload, 'base64url').toString('utf8');
386
- const claims = JSON.parse(decoded);
387
- const tier = claims.tier;
388
- if (tier && VALID_TIERS.has(tier)) {
389
- return tier;
390
- }
391
- return DEFAULT_TIER;
392
- }
393
- catch {
394
- return DEFAULT_TIER;
395
- }
396
- }
397
- buildUpgradeMessage(trigger, currentTier, requiredTier) {
398
- return `The *${trigger} command requires ${requiredTier.toUpperCase()} plan. Your current plan: ${currentTier.toUpperCase()}. Upgrade: https://neocortex.sh/portal/dashboard/plans`;
399
- }
400
- getQuotaCacheKey() {
401
- const now = new Date();
402
- const dateStr = now.toISOString().slice(0, 10); // YYYY-MM-DD UTC
403
- return `${QUOTA_CACHE_KEY_PREFIX}${dateStr}`;
404
- }
405
- }
1
+ import{GENERATED_CLIENT_COMMANDS as p}from"../generated/command-registry.generated.js";const o="neocortex:tier",b="neocortex:quota:",d=300*1e3,m=3600*1e3,l=new Set(["free","pro","enterprise"]),s="free",g={status:"free","create-epic":"free","idea-diagnose":"free","idea-research":"free","generate-epic":"free",exec:"pro",yolo:"pro",epic:"pro","setup-branch":"free",diagnose:"free",research:"free","write-spec":"free","create-tasks":"free",implement:"free","update-memory":"free",commit:"free",sync:"free","create-pr":"free",review:"pro",merge:"free","fix-blocked":"free","finalize-epic":"free",cleanup:"free","resolve-conflicts":"free",audit:"free",menu:"free",plans:"free",billing:"free",subscribe:"free","arch-plan":"free","arch-prd":"free","arch-architecture":"free","arch-api-contracts":"free","arch-api-integrations":"free","arch-database":"free","arch-security":"free","arch-design-system":"free","arch-ux-design":"free","arch-review":"free","arch-fitness-functions":"pro","arch-performance":"pro","arch-testing":"pro","arch-infrastructure":"pro",refactor:"pro","tech-debt":"free","tech-debt-scan":"pro","qa-scan":"pro","mutation-test":"pro",yoloop:"pro","migrate-state":"free","policy-audit":"pro","sync-openapi":"free","generate-pacts":"pro","verify-pacts":"free","property-test":"pro","chaos-plan":"pro","ui-ux-review":"pro","solyd-system":"enterprise",goal:"enterprise","goal-tick":"enterprise",loop:"enterprise","loop-tick":"enterprise",jobs:"enterprise",runner:"enterprise"},y=Object.freeze(Object.fromEntries(p.map(r=>[r.id,r.policy.minimumTier]))),T=[{id:"status",number:1,aliases:["st"]},{id:"arch-plan",number:3,aliases:["arquitetura","architecture","arch"]},{id:"arch-prd",number:4,aliases:["prd","product-requirements"]},{id:"arch-architecture",number:5,aliases:["arch-doc","tech-architecture"]},{id:"arch-api-contracts",number:6,aliases:["api-contracts","api-contract"]},{id:"arch-api-integrations",number:7,aliases:["api-integrations","api-int"]},{id:"arch-database",number:8,aliases:["database-schema","db-schema","db"]},{id:"arch-security",number:9,aliases:["cyber-security","security","sec"]},{id:"arch-design-system",number:10,aliases:["design-system","ds","atomic-design"]},{id:"arch-ux-design",number:11,aliases:["ux-design","ux","wireframes","wireframe","user-flows"]},{id:"arch-performance",number:12,aliases:["performance","perf","capacity-planning","capacity","arch-perf","performance-strategy"]},{id:"arch-testing",number:13,aliases:["testing-strategy","test-plan","test-strategy","arch-test"]},{id:"arch-infrastructure",number:14,aliases:["infrastructure","infra","deploy-plan","deployment","arch-infra","arch-deploy"]},{id:"arch-review",number:15,aliases:["review-consolidation","consolidation","architecture-review","arch-consolidation"]},{id:"arch-fitness-functions",number:16,aliases:["fitness","fitness-functions","archfit","arch-fit","fit-funcs"]},{id:"create-epic",number:17,aliases:["criar-epic","planejamento"]},{id:"idea-diagnose",number:18,aliases:["idea-diag"]},{id:"idea-research",number:19,aliases:["idea-pesq"]},{id:"generate-epic",number:20,aliases:["gerar-epic"]},{id:"exec",number:21,aliases:["executar","pipeline"]},{id:"yolo",number:22,aliases:[]},{id:"epic",number:23,aliases:["parallel-epic"]},{id:"setup-branch",number:24,aliases:["setup","branch"]},{id:"diagnose",number:25,aliases:["diag","diagnostico","c02"]},{id:"research",number:26,aliases:["pesquisar","pesq","research-fix","c03"]},{id:"write-spec",number:27,aliases:["spec","especificacao","c04"]},{id:"create-tasks",number:28,aliases:["tasks","tarefas","c05"]},{id:"implement",number:29,aliases:["impl","implementar","c06"]},{id:"commit",number:30,aliases:["push","commit-push","commit_push","cp","c07"]},{id:"sync",number:31,aliases:["sincronizar","c08"]},{id:"create-pr",number:32,aliases:["pr","c09"]},{id:"review",number:33,aliases:["revisar","c11"]},{id:"merge",number:34,aliases:["mesclar","c12"]},{id:"fix-blocked",number:35,aliases:["fix","corrigir"]},{id:"finalize-epic",number:36,aliases:["finalizar"]},{id:"resolve-conflicts",number:37,aliases:["conflitos"]},{id:"update-memory",number:38,aliases:["memoria"]},{id:"refactor",number:39,aliases:["refactoring","refact","refac","rf","cleanup-code","code-cleanup","code-quality","improve-code","modernize","modernization","legacy","legacy-code","debt-pay","pay-debt","debt-reduction","smell-fix","fix-smells","code-smells","strangler","strangler-fig"]},{id:"cleanup",number:40,aliases:["limpar","limpeza"]},{id:"audit",number:41,aliases:["auditar","auditoria"]},{id:"tech-debt",number:42,aliases:["debt","debts","debt-list","tech-debts","td"]},{id:"menu",number:43,aliases:["help","ajuda","?","commands","cmds"]},{id:"plans",number:44,aliases:["planos","pricing"]},{id:"billing",number:45,aliases:["bill","subscription","sub"]},{id:"subscribe",number:46,aliases:["upgrade","checkout"]},{id:"qa-scan",number:47,aliases:["qa","qa-test","visual-qa","e2e-scan","troubleshoot","debug-ui","scan","a11y","accessibility","wcag"]},{id:"yoloop",number:48,aliases:["auto-yolo","epic-runner","story-runner","loop-yolo","auto-epic"]},{id:"migrate-state",number:49,aliases:["migrate","state-migrate","schema-migrate"]},{id:"policy-audit",number:50,aliases:["policy","audit-policy","policy-history","policies"]},{id:"mutation-test",number:51,aliases:["mutation","stryker","kill-mutants"]},{id:"sync-openapi",number:52,aliases:["openapi-sync","api-sync","spec-sync","regen-openapi"]},{id:"generate-pacts",number:53,aliases:["pacts","gen-pacts","regen-pacts","create-pacts"]},{id:"verify-pacts",number:54,aliases:["verify-pact","pact-verify","check-pacts","pact-check"]},{id:"property-test",number:55,aliases:["property","pbt","proptest","property-tests","invariant-test"]},{id:"chaos-plan",number:56,aliases:["chaos","gameday","resilience-test"]},{id:"ui-ux-review",number:57,aliases:["ux-review","design-review","visual-review","product-polish"]},{id:"solyd-system",number:58,aliases:["security-system","authorized-security","sec-system"]},{id:"goal",number:59,aliases:["goals","durable-goal","continuity-goal"]},{id:"loop",number:60,aliases:["loops","durable-loop","continuity-loop"]},{id:"jobs",number:61,aliases:["job","continuity-jobs"]},{id:"runner",number:62,aliases:["neocortex-runner","continuity-runner"]}],u=Object.freeze(p.map(r=>Object.freeze({id:r.id,number:r.number,aliases:r.aliases}))),w=new Map(u.map(r=>[r.id,r])),C=new Map(u.map(r=>[r.number,r])),v=new Map(u.flatMap(r=>r.aliases.map(a=>[h(a),r.id])));function h(r){if(/[^\x20-\x7e]/.test(r))return"";const a=r.replace(/^[\t\n\r ]+|[\t\n\r ]+$/g,"");if(!a||a.startsWith("**"))return"";const e=(a.startsWith("*")?a.slice(1):a).replace(/[A-Z]/g,i=>i.toLowerCase());return/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(e)||e==="?"?e:""}function _(r){const a=r.trim();if(/^@?epic-[a-z0-9][a-z0-9._-]*$/i.test(a))return"epic";const e=a.split(/\s+/,1)[0]??"",i=e.trim().replace(/^\*/,"");if(/^\d+$/.test(i))return C.get(Number.parseInt(i,10))?.id??null;const t=h(e);return t?t==="goal-tick"?"goal":t==="loop-tick"?"loop":w.has(t)?t:v.get(t)??null:null}const f={free:0,pro:1,enterprise:2};class R{cache;licenseClient;cachedTier=null;constructor(a){this.cache=a.cacheProvider,this.licenseClient=a.licenseClient}async getCachedTier(){try{if(this.cachedTier)return this.cachedTier;const a=await this.cache.get(o);if(a&&l.has(a))return this.cachedTier=a,this.cachedTier;const e=await this.licenseClient.getToken();if(e){const i=this.extractTierFromJwt(e);return this.cachedTier=i,await this.cache.set(o,i,m).catch(()=>{}),i}return s}catch{return s}}async updateTier(a){try{if(!l.has(a))return;this.cachedTier=a,await this.cache.set(o,a,m).catch(()=>{})}catch{}}async invalidateTierCache(){try{this.cachedTier=null,await this.cache.clear().catch(()=>{})}catch{}}async preFlightCheck(a,e){try{const i=e??await this.getCachedTier(),t=_(a)??a,n=y[t]??"free";return f[i]>=f[n]?{allowed:!0}:{allowed:!1,message:this.buildUpgradeMessage(t,i,n)}}catch{return{allowed:!0}}}async updateQuotaFromResponse(a){try{const e=a.quotaRemaining;if(!e)return;const i={stepsRemaining:e.stepsRemaining??0,invocationsRemaining:e.invocationsRemaining??0,stepsLimit:e.stepsLimit??0,invocationsLimit:e.invocationsLimit??0,cachedAt:Date.now()},t=this.getQuotaCacheKey();await this.cache.set(t,JSON.stringify(i),d).catch(()=>{})}catch{}}async getCachedQuota(){try{const a=this.getQuotaCacheKey(),e=await this.cache.get(a);if(!e)return null;const i=JSON.parse(e);return Date.now()-i.cachedAt>d?null:i}catch{return null}}async offlineQuotaCheck(a=!1){try{if(!a)return{allowed:!0};const e=await this.getCachedQuota();return e?e.stepsRemaining<=0&&e.stepsLimit>0?{allowed:!1,message:`Daily step limit reached (${e.stepsLimit}/${e.stepsLimit}). Resets at 00:00 UTC.`}:e.invocationsRemaining<=0&&e.invocationsLimit>0?{allowed:!1,message:`Daily invocation limit reached (${e.invocationsLimit}/${e.invocationsLimit}). Resets at 00:00 UTC.`}:{allowed:!0}:{allowed:!0}}catch{return{allowed:!0}}}extractTierFromJwt(a){try{const e=a.split(".");if(e.length!==3)return s;const i=e[1],t=Buffer.from(i,"base64url").toString("utf8"),c=JSON.parse(t).tier;return c&&l.has(c)?c:s}catch{return s}}buildUpgradeMessage(a,e,i){return`The *${a} command requires ${i.toUpperCase()} plan. Your current plan: ${e.toUpperCase()}. Upgrade: https://neocortex.sh/portal/dashboard/plans`}getQuotaCacheKey(){const e=new Date().toISOString().slice(0,10);return`${b}${e}`}}export{u as CLIENT_PREFLIGHT_COMMAND_REGISTRY,R as TierAwareClient,h as normalizeCommandToken,_ as resolveClientPreFlightTrigger};
@@ -1,38 +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 - Type Definitions
15
- *
16
- * All types for the asset resolution abstraction layer.
17
- */
18
- // ── Resolver Mode ────────────────────────────────────────────────────────
19
- /** Mode of asset resolution */
20
- export var ResolverMode;
21
- (function (ResolverMode) {
22
- /** Read assets from local filesystem (development) */
23
- ResolverMode["LOCAL"] = "local";
24
- /** Fetch assets from remote IP Protection Server (production) */
25
- ResolverMode["REMOTE"] = "remote";
26
- })(ResolverMode || (ResolverMode = {}));
27
- /** No-op cache implementation for development/fallback */
28
- export class NoOpCache {
29
- async get() {
30
- return null;
31
- }
32
- async set() {
33
- // No-op: cache disabled
34
- }
35
- async clear() {
36
- // No-op: nothing to clear
37
- }
38
- }
1
+ var a;(function(e){e.LOCAL="local",e.REMOTE="remote"})(a||(a={}));class c{async get(){return null}async set(){}async clear(){}}export{c as NoOpCache,a as ResolverMode};
@@ -1,27 +1 @@
1
- import { readFileSync } from 'node:fs';
2
- import { fileURLToPath } from 'node:url';
3
- import { dirname, join } from 'node:path';
4
- /** Resolve the installed package version for both source and packed runtimes. */
5
- export function getClientVersion(fromUrl = import.meta.url) {
6
- try {
7
- let directory = dirname(fileURLToPath(fromUrl));
8
- for (let depth = 0; depth < 6; depth += 1) {
9
- try {
10
- const pkg = JSON.parse(readFileSync(join(directory, 'package.json'), 'utf8'));
11
- if ((pkg.name === '@ornexus/neocortex' || pkg.name === '@neocortex/client') &&
12
- typeof pkg.version === 'string' &&
13
- /^\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?$/.test(pkg.version))
14
- return pkg.version;
15
- }
16
- catch {
17
- // Continue toward the package root.
18
- }
19
- directory = dirname(directory);
20
- }
21
- }
22
- catch {
23
- // Fall through to the explicit unavailable value.
24
- }
25
- return '0.0.0';
26
- }
27
- export const CLIENT_VERSION = getClientVersion();
1
+ import{readFileSync as i}from"node:fs";import{fileURLToPath as c}from"node:url";import{dirname as o,join as a}from"node:path";function m(n=import.meta.url){try{let t=o(c(n));for(let r=0;r<6;r+=1){try{const e=JSON.parse(i(a(t,"package.json"),"utf8"));if((e.name==="@ornexus/neocortex"||e.name==="@neocortex/client")&&typeof e.version=="string"&&/^\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?$/.test(e.version))return e.version}catch{}t=o(t)}}catch{}return"0.0.0"}const d=m();export{d as CLIENT_VERSION,m as getClientVersion};
@@ -9,9 +9,19 @@ export interface YoloChangeEvidenceDiagnostic {
9
9
  readonly fallbackAction: 'reacquire-exact-story-setup' | 'restore-verified-base-evidence' | 'resolve-lease-conflict' | 'inspect-repository-binding' | 'none';
10
10
  readonly publicSafe: true;
11
11
  }
12
+ /**
13
+ * 4.61.6: the invoking checkout is the adopted/active, ownership-proven P225
14
+ * story worktree of the story. Its own lease and synced base scope the change
15
+ * evidence; the epic writer lease (held by the root integration) is not used.
16
+ */
17
+ export interface YoloChangeEvidenceStoryWorktreeBinding {
18
+ readonly leaseId: string;
19
+ readonly baseSha: string;
20
+ }
12
21
  export interface YoloChangeEvidenceLeaseReconciliation {
13
22
  readonly repair: 'not-attempted' | 'applied';
14
23
  readonly recollectionCount: 0 | 1;
24
+ readonly storyWorktree?: YoloChangeEvidenceStoryWorktreeBinding;
15
25
  }
16
26
  export declare class YoloChangeEvidenceUnavailableError extends Error {
17
27
  readonly diagnostic: YoloChangeEvidenceDiagnostic;