@ornexus/neocortex 4.60.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +56 -0
- package/LICENSE-COMMERCIAL.md +70 -0
- package/README.md +58 -0
- package/dist/sbom.cdx.json +11159 -0
- package/docs/install/coderabbit-manual-setup.md +86 -0
- package/docs/install/installer-diagnostics.md +107 -0
- package/docs/install/linux-global-install.md +97 -0
- package/install.js +572 -0
- package/install.ps1 +2214 -0
- package/install.sh +2013 -0
- package/package.json +132 -0
- package/packages/client/dist/adapters/adapter-registry.d.ts +61 -0
- package/packages/client/dist/adapters/adapter-registry.js +1 -0
- package/packages/client/dist/adapters/antigravity-adapter.d.ts +18 -0
- package/packages/client/dist/adapters/antigravity-adapter.js +2 -0
- package/packages/client/dist/adapters/claude-code-adapter.d.ts +19 -0
- package/packages/client/dist/adapters/claude-code-adapter.js +3 -0
- package/packages/client/dist/adapters/codex-adapter.d.ts +19 -0
- package/packages/client/dist/adapters/codex-adapter.js +2 -0
- package/packages/client/dist/adapters/cursor-adapter.d.ts +19 -0
- package/packages/client/dist/adapters/cursor-adapter.js +4 -0
- package/packages/client/dist/adapters/gemini-adapter.d.ts +18 -0
- package/packages/client/dist/adapters/gemini-adapter.js +2 -0
- package/packages/client/dist/adapters/index.d.ts +19 -0
- package/packages/client/dist/adapters/index.js +1 -0
- package/packages/client/dist/adapters/platform-detector.d.ts +48 -0
- package/packages/client/dist/adapters/platform-detector.js +1 -0
- package/packages/client/dist/adapters/target-adapter.d.ts +70 -0
- package/packages/client/dist/adapters/target-adapter.js +0 -0
- package/packages/client/dist/adapters/vscode-adapter.d.ts +19 -0
- package/packages/client/dist/adapters/vscode-adapter.js +2 -0
- package/packages/client/dist/agent/refresh-stubs.d.ts +90 -0
- package/packages/client/dist/agent/refresh-stubs.js +2 -0
- package/packages/client/dist/agent/update-agent-yaml.d.ts +26 -0
- package/packages/client/dist/agent/update-agent-yaml.js +1 -0
- package/packages/client/dist/agent/update-description.d.ts +45 -0
- package/packages/client/dist/agent/update-description.js +1 -0
- package/packages/client/dist/cache/crypto-utils.d.ts +30 -0
- package/packages/client/dist/cache/crypto-utils.js +1 -0
- package/packages/client/dist/cache/encrypted-cache.d.ts +30 -0
- package/packages/client/dist/cache/encrypted-cache.js +1 -0
- package/packages/client/dist/cache/in-memory-asset-cache.d.ts +62 -0
- package/packages/client/dist/cache/in-memory-asset-cache.js +1 -0
- package/packages/client/dist/cache/index.d.ts +13 -0
- package/packages/client/dist/cache/index.js +1 -0
- package/packages/client/dist/cache/protected-pi-boundary.d.ts +19 -0
- package/packages/client/dist/cache/protected-pi-boundary.js +1 -0
- package/packages/client/dist/checkpoint/checkpoint-client-reader.d.ts +45 -0
- package/packages/client/dist/checkpoint/checkpoint-client-reader.js +2 -0
- package/packages/client/dist/checkpoint/index.d.ts +12 -0
- package/packages/client/dist/checkpoint/index.js +1 -0
- package/packages/client/dist/checkpoint/shared-checkpoint-types.d.ts +85 -0
- package/packages/client/dist/checkpoint/shared-checkpoint-types.js +1 -0
- package/packages/client/dist/cli.d.ts +14 -0
- package/packages/client/dist/cli.js +81 -0
- package/packages/client/dist/commands/activate.d.ts +55 -0
- package/packages/client/dist/commands/activate.js +8 -0
- package/packages/client/dist/commands/cache-status.d.ts +39 -0
- package/packages/client/dist/commands/cache-status.js +2 -0
- package/packages/client/dist/commands/invoke.d.ts +546 -0
- package/packages/client/dist/commands/invoke.js +140 -0
- package/packages/client/dist/commands/refresh-memory.d.ts +11 -0
- package/packages/client/dist/commands/refresh-memory.js +1 -0
- package/packages/client/dist/config/resolver-selection.d.ts +40 -0
- package/packages/client/dist/config/resolver-selection.js +1 -0
- package/packages/client/dist/config/secure-config.d.ts +78 -0
- package/packages/client/dist/config/secure-config.js +12 -0
- package/packages/client/dist/constants.d.ts +25 -0
- package/packages/client/dist/constants.js +1 -0
- package/packages/client/dist/context/context-collector.d.ts +28 -0
- package/packages/client/dist/context/context-collector.js +2 -0
- package/packages/client/dist/context/context-sanitizer.d.ts +28 -0
- package/packages/client/dist/context/context-sanitizer.js +1 -0
- package/packages/client/dist/continuity/autonomous-governance.d.ts +84 -0
- package/packages/client/dist/continuity/autonomous-governance.js +1 -0
- package/packages/client/dist/continuity/continuity-client-state-store.d.ts +302 -0
- package/packages/client/dist/continuity/continuity-client-state-store.js +1 -0
- package/packages/client/dist/continuity/invoke-hooks.d.ts +19 -0
- package/packages/client/dist/continuity/invoke-hooks.js +1 -0
- package/packages/client/dist/continuity/migrations/001-initial-schema.d.ts +11 -0
- package/packages/client/dist/continuity/migrations/001-initial-schema.js +263 -0
- package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.d.ts +11 -0
- package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +7 -0
- package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.d.ts +11 -0
- package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +62 -0
- package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.d.ts +11 -0
- package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +19 -0
- package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.d.ts +11 -0
- package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +35 -0
- package/packages/client/dist/continuity/outbox.d.ts +83 -0
- package/packages/client/dist/continuity/outbox.js +1 -0
- package/packages/client/dist/continuity/runner-bootstrap-policy.d.ts +50 -0
- package/packages/client/dist/continuity/runner-bootstrap-policy.js +1 -0
- package/packages/client/dist/continuity/sqlite-store.d.ts +926 -0
- package/packages/client/dist/continuity/sqlite-store.js +619 -0
- package/packages/client/dist/errors/error-messages.d.ts +40 -0
- package/packages/client/dist/errors/error-messages.js +2 -0
- package/packages/client/dist/graph-retrieval/pre-command-hook.d.ts +34 -0
- package/packages/client/dist/graph-retrieval/pre-command-hook.js +1 -0
- package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.d.ts +99 -0
- package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +1 -0
- package/packages/client/dist/i18n/first-run.d.ts +23 -0
- package/packages/client/dist/i18n/first-run.js +2 -0
- package/packages/client/dist/index.d.ts +56 -0
- package/packages/client/dist/index.js +1 -0
- package/packages/client/dist/license/index.d.ts +5 -0
- package/packages/client/dist/license/index.js +1 -0
- package/packages/client/dist/license/license-client.d.ts +79 -0
- package/packages/client/dist/license/license-client.js +1 -0
- package/packages/client/dist/machine/fingerprint.d.ts +34 -0
- package/packages/client/dist/machine/fingerprint.js +2 -0
- package/packages/client/dist/machine/index.d.ts +5 -0
- package/packages/client/dist/machine/index.js +1 -0
- package/packages/client/dist/memory/project-memory-writer.d.ts +74 -0
- package/packages/client/dist/memory/project-memory-writer.js +36 -0
- package/packages/client/dist/memory/shared-project-memory-types.d.ts +370 -0
- package/packages/client/dist/memory/shared-project-memory-types.js +2 -0
- package/packages/client/dist/policy/architecture-policy.d.ts +40 -0
- package/packages/client/dist/policy/architecture-policy.js +2 -0
- package/packages/client/dist/policy/index.d.ts +8 -0
- package/packages/client/dist/policy/index.js +1 -0
- package/packages/client/dist/policy/shared-policy-types.d.ts +89 -0
- package/packages/client/dist/policy/shared-policy-types.js +0 -0
- package/packages/client/dist/resilience/circuit-breaker.d.ts +70 -0
- package/packages/client/dist/resilience/circuit-breaker.js +1 -0
- package/packages/client/dist/resilience/degradation-manager.d.ts +67 -0
- package/packages/client/dist/resilience/degradation-manager.js +1 -0
- package/packages/client/dist/resilience/freshness-indicator.d.ts +59 -0
- package/packages/client/dist/resilience/freshness-indicator.js +1 -0
- package/packages/client/dist/resilience/index.d.ts +8 -0
- package/packages/client/dist/resilience/index.js +1 -0
- package/packages/client/dist/resilience/recovery-detector.d.ts +59 -0
- package/packages/client/dist/resilience/recovery-detector.js +1 -0
- package/packages/client/dist/resolvers/asset-resolver.d.ts +79 -0
- package/packages/client/dist/resolvers/asset-resolver.js +0 -0
- package/packages/client/dist/resolvers/local-resolver.d.ts +26 -0
- package/packages/client/dist/resolvers/local-resolver.js +8 -0
- package/packages/client/dist/resolvers/remote-resolver.d.ts +91 -0
- package/packages/client/dist/resolvers/remote-resolver.js +1 -0
- package/packages/client/dist/runner/binary.d.ts +115 -0
- package/packages/client/dist/runner/binary.js +1 -0
- package/packages/client/dist/runner/cli.d.ts +168 -0
- package/packages/client/dist/runner/cli.js +70 -0
- package/packages/client/dist/runner/headless/adapters.d.ts +20 -0
- package/packages/client/dist/runner/headless/adapters.js +1 -0
- package/packages/client/dist/runner/headless/claude-code-adapter.d.ts +8 -0
- package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -0
- package/packages/client/dist/runner/headless/fake-adapter.d.ts +8 -0
- package/packages/client/dist/runner/headless/fake-adapter.js +1 -0
- package/packages/client/dist/runner/headless/opencode-adapter.d.ts +15 -0
- package/packages/client/dist/runner/headless/opencode-adapter.js +2 -0
- package/packages/client/dist/runner/headless/resolver.d.ts +68 -0
- package/packages/client/dist/runner/headless/resolver.js +1 -0
- package/packages/client/dist/runner/headless/run-yolo.d.ts +59 -0
- package/packages/client/dist/runner/headless/run-yolo.js +1 -0
- package/packages/client/dist/runner/headless/run-yoloop.d.ts +113 -0
- package/packages/client/dist/runner/headless/run-yoloop.js +1 -0
- package/packages/client/dist/runner/headless/types.d.ts +194 -0
- package/packages/client/dist/runner/headless/types.js +2 -0
- package/packages/client/dist/runner/local-console.d.ts +83 -0
- package/packages/client/dist/runner/local-console.js +13 -0
- package/packages/client/dist/runner/portal-sync-worker.d.ts +184 -0
- package/packages/client/dist/runner/portal-sync-worker.js +1 -0
- package/packages/client/dist/runner/project-identity.d.ts +19 -0
- package/packages/client/dist/runner/project-identity.js +1 -0
- package/packages/client/dist/runner/scheduler.d.ts +186 -0
- package/packages/client/dist/runner/scheduler.js +7 -0
- package/packages/client/dist/runner-cli.d.ts +9 -0
- package/packages/client/dist/runner-cli.js +3 -0
- package/packages/client/dist/state/project-state-snapshot.d.ts +24 -0
- package/packages/client/dist/state/project-state-snapshot.js +1 -0
- package/packages/client/dist/state/state-json-repair.d.ts +74 -0
- package/packages/client/dist/state/state-json-repair.js +3 -0
- package/packages/client/dist/telemetry/index.d.ts +5 -0
- package/packages/client/dist/telemetry/index.js +1 -0
- package/packages/client/dist/telemetry/offline-queue.d.ts +57 -0
- package/packages/client/dist/telemetry/offline-queue.js +1 -0
- package/packages/client/dist/tier/index.d.ts +5 -0
- package/packages/client/dist/tier/index.js +1 -0
- package/packages/client/dist/tier/tier-aware-client.d.ts +105 -0
- package/packages/client/dist/tier/tier-aware-client.js +1 -0
- package/packages/client/dist/types/index.d.ts +140 -0
- package/packages/client/dist/types/index.js +1 -0
- package/packages/client/dist/yoloop/discovery-hook.d.ts +85 -0
- package/packages/client/dist/yoloop/discovery-hook.js +2 -0
- package/packages/client/dist/yoloop/index.d.ts +10 -0
- package/packages/client/dist/yoloop/index.js +1 -0
- package/packages/client/dist/yoloop/invoke-hooks.d.ts +127 -0
- package/packages/client/dist/yoloop/invoke-hooks.js +5 -0
- package/packages/client/dist/yoloop/shared-discover-epics.d.ts +289 -0
- package/packages/client/dist/yoloop/shared-discover-epics.js +1 -0
- package/packages/client/dist/yoloop/shared-yoloop-types.d.ts +172 -0
- package/packages/client/dist/yoloop/shared-yoloop-types.js +1 -0
- package/packages/client/dist/yoloop/yoloop-client-state-store.d.ts +124 -0
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -0
- package/postinstall.js +754 -0
- package/targets-stubs/antigravity/README.md +36 -0
- package/targets-stubs/antigravity/gemini.md +29 -0
- package/targets-stubs/antigravity/install-antigravity.sh +153 -0
- package/targets-stubs/antigravity/mcp-config.json +30 -0
- package/targets-stubs/antigravity/skill/SKILL.md +166 -0
- package/targets-stubs/claude-code/.mcp.json +32 -0
- package/targets-stubs/claude-code/README.md +20 -0
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +42 -0
- package/targets-stubs/claude-code/neocortex-root.md +317 -0
- package/targets-stubs/claude-code/neocortex.agent.yaml +42 -0
- package/targets-stubs/claude-code/neocortex.md +385 -0
- package/targets-stubs/codex/AGENTS.md +250 -0
- package/targets-stubs/codex/README.md +47 -0
- package/targets-stubs/codex/config-mcp.toml +22 -0
- package/targets-stubs/codex/install-codex.sh +63 -0
- package/targets-stubs/codex/neocortex.toml +33 -0
- package/targets-stubs/cursor/README.md +33 -0
- package/targets-stubs/cursor/agent.md +211 -0
- package/targets-stubs/cursor/install-cursor.sh +50 -0
- package/targets-stubs/cursor/mcp.json +30 -0
- package/targets-stubs/gemini-cli/README.md +34 -0
- package/targets-stubs/gemini-cli/agent.md +241 -0
- package/targets-stubs/gemini-cli/agents/neocortex.md +60 -0
- package/targets-stubs/gemini-cli/gemini.md +46 -0
- package/targets-stubs/gemini-cli/install-gemini.sh +70 -0
- package/targets-stubs/gemini-cli/settings-mcp.json +30 -0
- package/targets-stubs/kimi/mcp.json +33 -0
- package/targets-stubs/kimi/neocortex.md +60 -0
- package/targets-stubs/lib/mcp-merge.js +189 -0
- package/targets-stubs/openclaw/README.md +12 -0
- package/targets-stubs/openclaw/SKILL.md +92 -0
- package/targets-stubs/opencode/neocortex-root.md +267 -0
- package/targets-stubs/opencode/neocortex.md +65 -0
- package/targets-stubs/opencode/opencode-mcp.json +35 -0
- package/targets-stubs/vscode/README.md +34 -0
- package/targets-stubs/vscode/copilot-instructions.md +47 -0
- package/targets-stubs/vscode/install-vscode.sh +72 -0
- package/targets-stubs/vscode/mcp.json +36 -0
- package/targets-stubs/vscode/neocortex.agent.md +252 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const ae=12,ue=16,n=(r,e,t={})=>({commandId:r,stateProjectionPolicy:e,...t}),_=Object.freeze({status:n("status","full"),init:n("init","epic-targeted"),"arch-plan":n("arch-plan","full"),"arch-prd":n("arch-prd","full"),"arch-architecture":n("arch-architecture","epic-targeted"),"arch-api-contracts":n("arch-api-contracts","epic-targeted"),"arch-api-integrations":n("arch-api-integrations","epic-targeted"),"arch-database":n("arch-database","epic-targeted"),"arch-security":n("arch-security","epic-targeted"),"arch-design-system":n("arch-design-system","epic-targeted"),"arch-ux-design":n("arch-ux-design","epic-targeted"),"arch-performance":n("arch-performance","epic-targeted"),"arch-testing":n("arch-testing","epic-targeted"),"arch-infrastructure":n("arch-infrastructure","epic-targeted"),"arch-review":n("arch-review","epic-targeted"),"arch-fitness-functions":n("arch-fitness-functions","epic-targeted"),"create-epic":n("create-epic","epic-summary"),"idea-diagnose":n("idea-diagnose","full"),"idea-research":n("idea-research","epic-targeted"),"generate-epic":n("generate-epic","epic-targeted"),exec:n("exec","story-targeted",{structuralRequired:!0}),yolo:n("yolo","story-targeted",{structuralRequired:!0}),"yolo-inline":n("yolo-inline","story-targeted",{structuralRequired:!0}),epic:n("epic","epic-targeted",{structuralRequired:!0}),"setup-branch":n("setup-branch","story-targeted",{structuralRequired:!0}),diagnose:n("diagnose","adaptive-targeted"),"diagnose-inline":n("diagnose-inline","full"),research:n("research","adaptive-targeted"),"research-inline":n("research-inline","full"),"write-spec":n("write-spec","story-targeted",{structuralRequired:!0}),"create-tasks":n("create-tasks","story-targeted",{structuralRequired:!0}),implement:n("implement","story-targeted",{structuralRequired:!0}),commit:n("commit","story-targeted",{structuralRequired:!0}),"commit-push":n("commit","story-targeted",{structuralRequired:!0}),sync:n("sync","story-targeted",{structuralRequired:!0}),"sync-main":n("sync","story-targeted",{structuralRequired:!0}),"create-pr":n("create-pr","story-targeted",{structuralRequired:!0}),review:n("review","story-targeted"),"review-pr":n("review","story-targeted"),merge:n("merge","story-targeted",{structuralRequired:!0}),"merge-pr":n("merge","story-targeted",{structuralRequired:!0}),"fix-blocked":n("fix-blocked","story-targeted"),"finalize-epic":n("finalize-epic","epic-targeted"),"resolve-conflicts":n("resolve-conflicts","story-targeted"),"update-memory":n("update-memory","full"),"update-project-memory":n("update-memory","story-targeted",{structuralRequired:!0}),refactor:n("refactor","adaptive-targeted"),"refactor-suggest":n("refactor","story-targeted",{structuralRequired:!0}),cleanup:n("cleanup","full"),audit:n("audit","full"),"tech-debt":n("tech-debt","full"),menu:n("menu","full"),plans:n("plans","full"),billing:n("billing","full"),subscribe:n("subscribe","full"),"qa-scan":n("qa-scan","full"),yoloop:n("yoloop","yoloop-targeted",{structuralRequired:!0}),"migrate-state":n("migrate-state","full"),"policy-audit":n("policy-audit","full"),"mutation-test":n("mutation-test","full"),"sync-openapi":n("sync-openapi","full"),"generate-pacts":n("generate-pacts","full"),"verify-pacts":n("verify-pacts","full"),"property-test":n("property-test","full"),"property-tests":n("property-test","story-targeted",{structuralRequired:!0}),"chaos-plan":n("chaos-plan","full"),"ui-ux-review":n("ui-ux-review","adaptive-targeted"),"solyd-system":n("solyd-system","adaptive-targeted"),goal:n("goal","continuity-scoped"),loop:n("loop","continuity-scoped"),jobs:n("jobs","continuity-scoped"),runner:n("runner","continuity-scoped"),"goal-tick":n("goal-tick","continuity-scoped"),"loop-tick":n("loop-tick","continuity-scoped"),"validate-tests":n("validate-tests","story-targeted",{structuralRequired:!0}),"qa-gate":n("qa-gate","story-targeted",{structuralRequired:!0})}),M=Object.freeze({st:"status",inicializar:"init",arquitetura:"arch-plan",architecture:"arch-plan",arch:"arch-plan",prd:"arch-prd","product-requirements":"arch-prd","arch-doc":"arch-architecture","tech-architecture":"arch-architecture","api-contracts":"arch-api-contracts","api-contract":"arch-api-contracts","api-integrations":"arch-api-integrations","api-int":"arch-api-integrations","database-schema":"arch-database","db-schema":"arch-database",db:"arch-database","cyber-security":"arch-security",security:"arch-security",sec:"arch-security","design-system":"arch-design-system",ds:"arch-design-system","atomic-design":"arch-design-system","ux-design":"arch-ux-design",ux:"arch-ux-design",wireframes:"arch-ux-design",wireframe:"arch-ux-design","user-flows":"arch-ux-design",performance:"arch-performance",perf:"arch-performance","capacity-planning":"arch-performance",capacity:"arch-performance","arch-perf":"arch-performance","performance-strategy":"arch-performance","testing-strategy":"arch-testing","test-plan":"arch-testing","test-strategy":"arch-testing","arch-test":"arch-testing",infrastructure:"arch-infrastructure",infra:"arch-infrastructure","deploy-plan":"arch-infrastructure",deployment:"arch-infrastructure","arch-infra":"arch-infrastructure","arch-deploy":"arch-infrastructure","review-consolidation":"arch-review",consolidation:"arch-review","architecture-review":"arch-review","arch-consolidation":"arch-review",fitness:"arch-fitness-functions","fitness-functions":"arch-fitness-functions",archfit:"arch-fitness-functions","arch-fit":"arch-fitness-functions","fit-funcs":"arch-fitness-functions","criar-epic":"create-epic",planejamento:"create-epic","idea-diag":"idea-diagnose","idea-pesq":"idea-research","gerar-epic":"generate-epic",executar:"exec",pipeline:"exec","parallel-epic":"epic",setup:"setup-branch",branch:"setup-branch",diag:"diagnose",diagnostico:"diagnose",c02:"diagnose",pesquisar:"research",pesq:"research","research-fix":"research",c03:"research",spec:"write-spec",especificacao:"write-spec",c04:"write-spec",tasks:"create-tasks",tarefas:"create-tasks",c05:"create-tasks",impl:"implement",implementar:"implement",c06:"implement",push:"commit",commit_push:"commit",cp:"commit",c07:"commit",sincronizar:"sync",c08:"sync",pr:"create-pr",c09:"create-pr",revisar:"review",c11:"review",mesclar:"merge",c12:"merge",fix:"fix-blocked",corrigir:"fix-blocked",finalizar:"finalize-epic",conflitos:"resolve-conflicts",memoria:"update-memory",refactoring:"refactor",refact:"refactor",refac:"refactor",rf:"refactor","cleanup-code":"refactor","code-cleanup":"refactor","code-quality":"refactor","improve-code":"refactor",modernize:"refactor",modernization:"refactor",legacy:"refactor","legacy-code":"refactor","debt-pay":"refactor","pay-debt":"refactor","debt-reduction":"refactor","smell-fix":"refactor","fix-smells":"refactor","code-smells":"refactor",strangler:"refactor","strangler-fig":"refactor",limpar:"cleanup",limpeza:"cleanup",auditar:"audit",auditoria:"audit",debt:"tech-debt",debts:"tech-debt","debt-list":"tech-debt","tech-debts":"tech-debt",td:"tech-debt",help:"menu",ajuda:"menu","?":"menu",commands:"menu",cmds:"menu",planos:"plans",pricing:"plans",bill:"billing",subscription:"billing",sub:"billing",upgrade:"subscribe",checkout:"subscribe",qa:"qa-scan","qa-test":"qa-scan","visual-qa":"qa-scan","e2e-scan":"qa-scan",troubleshoot:"qa-scan","debug-ui":"qa-scan",scan:"qa-scan",a11y:"qa-scan",accessibility:"qa-scan",wcag:"qa-scan","auto-yolo":"yoloop","epic-runner":"yoloop","story-runner":"yoloop","loop-yolo":"yoloop","auto-epic":"yoloop",migrate:"migrate-state","state-migrate":"migrate-state","schema-migrate":"migrate-state",policy:"policy-audit","audit-policy":"policy-audit","policy-history":"policy-audit",policies:"policy-audit",mutation:"mutation-test",stryker:"mutation-test","kill-mutants":"mutation-test","openapi-sync":"sync-openapi","api-sync":"sync-openapi","spec-sync":"sync-openapi","regen-openapi":"sync-openapi",pacts:"generate-pacts","gen-pacts":"generate-pacts","regen-pacts":"generate-pacts","create-pacts":"generate-pacts","verify-pact":"verify-pacts","pact-verify":"verify-pacts","check-pacts":"verify-pacts","pact-check":"verify-pacts",property:"property-test",pbt:"property-test",proptest:"property-test","invariant-test":"property-test",chaos:"chaos-plan",gameday:"chaos-plan","resilience-test":"chaos-plan","ux-review":"ui-ux-review","design-review":"ui-ux-review","visual-review":"ui-ux-review","product-polish":"ui-ux-review","security-system":"solyd-system","authorized-security":"solyd-system","sec-system":"solyd-system",goals:"goal","durable-goal":"goal","continuity-goal":"goal",loops:"loop","durable-loop":"loop","continuity-loop":"loop",job:"jobs","continuity-jobs":"jobs","neocortex-runner":"runner","continuity-runner":"runner"}),z=Object.freeze({1:"status",2:"init",3:"arch-plan",4:"arch-prd",5:"arch-architecture",6:"arch-api-contracts",7:"arch-api-integrations",8:"arch-database",9:"arch-security",10:"arch-design-system",11:"arch-ux-design",12:"arch-performance",13:"arch-testing",14:"arch-infrastructure",15:"arch-review",16:"arch-fitness-functions",17:"create-epic",18:"idea-diagnose",19:"idea-research",20:"generate-epic",21:"exec",22:"yolo",23:"epic",24:"setup-branch",25:"diagnose",26:"research",27:"write-spec",28:"create-tasks",29:"implement",30:"commit",31:"sync",32:"create-pr",33:"review",34:"merge",35:"fix-blocked",36:"finalize-epic",37:"resolve-conflicts",38:"update-memory",39:"refactor",40:"cleanup",41:"audit",42:"tech-debt",43:"menu",44:"plans",45:"billing",46:"subscribe",47:"qa-scan",48:"yoloop",49:"migrate-state",50:"policy-audit",51:"mutation-test",52:"sync-openapi",53:"generate-pacts",54:"verify-pacts",55:"property-test",56:"chaos-plan",57:"ui-ux-review",58:"solyd-system",59:"goal",60:"loop",61:"jobs",62:"runner"});function a(r,e=120){if(typeof r!="string")return;const t=r.trim();if(t)return t.replace(/[^a-z0-9_.:-]+/gi,"_").slice(0,e)}function b(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function f(...r){const e=new Set,t=[];for(const i of r)for(const o of i??[]){const c=a(o,80);if(!(!c||e.has(c))&&(e.add(c),t.push(c),t.length>=16))return t}return t}function N(r){return r.trim().replace(/^@?\*/,"").replace(/^@/,"").toLowerCase()}function F(r){return r.trim().split(/\s+/,1)[0]??""}function L(r){const e=F(r);if(!e)return _.menu;const t=N(e),i=z[t]??M[t]??t;return _[i]??null}function $(r,e,t,i="full-compatible",o=["full-state"]){return{kind:"full",commandId:t?.commandId??null,stateProjectionPolicy:t?.stateProjectionPolicy??null,projectionMode:i,trigger:r,targetEpicId:null,targetStoryId:null,includedStoryCount:Object.keys(e.stories).length,includedEpicCount:Object.keys(e.epics).length,omittedStoryCount:0,omittedEpicCount:0,reason:"full-state",reasonCodes:f(o)}}function y(r,e,t,i="full-compatible",o=["full-state"]){const c=$(r,e,t,i,o);return m({...e,scope:c},e,c)}function D(r){const[e]=r.trim().split(/\s+/,1);return e?/^[A-Z]?\d+(?:\.\d+)+$/i.test(e.replace(/^@/,""))||/(?:^|\/)[A-Z]?\d+(?:\.\d+)+\.story\.md$/i.test(e.replace(/^@/,"")):!1}function q(r){const e=r.match(/(?:^|[/@\s])([A-Z]?\d+(?:\.\d+)+)\.story\.md\b/i);return e?.[1]?e[1]:r.match(/(?:^|\s|@)([A-Z]?\d+(?:\.\d+)+)(?=$|\s)/i)?.[1]??null}function Y(r){const e=r.trim(),t=e.search(/\s/);return t===-1?"":e.slice(t).trim()}function O(r){return Y(r).split(/\s+/).map(e=>e.replace(/^@/,"").replace(/^['"]|['"]$/g,"")).filter(e=>e.length>0&&!e.startsWith("-"))}function de(r){return O(r)[0]??null}function P(r,e){const i=r.replace(/^@/,"").replace(/^epic-/i,"").replace(/\.md$/i,""),o=[i,i.toUpperCase(),/^p\d+$/i.test(i)?`P${i.replace(/^p/i,"")}`:null,/^\d+$/.test(i)?`P${i}`:null].filter(c=>typeof c=="string"&&c.length>0);for(const c of o)if(e.epics[c])return c;return null}function Z(r,e){const t=r.match(/(?:^|[/@\s])epic-(P?\d+)\.md\b/i);return t?.[1]?P(t[1],e):null}function S(r,e){const t=Z(r,e);if(t)return t;for(const i of O(r)){if(/^[A-Z]?\d+(?:\.\d+)+$/i.test(i))continue;const o=P(i,e);if(o)return o}return null}function G(r,e){const t=S(r,e);if(t)return t;const i=e.yoloop,o=i?.state?.currentSession?.currentEpicId;if(typeof o=="string"&&e.epics[o])return o;const c=i?.lock?.currentEpicId??i?.lock?.epicId;return typeof c=="string"&&e.epics[c]?c:null}function k(r,e){if(typeof r.epic_id=="string"&&r.epic_id.length>0)return r.epic_id;const t=e.split(".").slice(0,-1).join(".");return t.length>0?t:null}function x(r){return typeof r=="string"&&["done","completed","merged","cancelled","canceled","abandoned"].includes(r.toLowerCase())}function h(r,e,t){if(t.has(r))return;const i=e.stories[r];if(!i)return;t.add(r);const o=i.depends_on;if(Array.isArray(o))for(const c of o)typeof c=="string"&&h(c,e,t)}function U(r,e,t){const i=new Set;h(r,t,i);const o=e.stories;if(Array.isArray(o))for(const s of o)typeof s=="string"&&t.stories[s]&&i.add(s);const c={};for(const s of i){const u=t.stories[s];u&&(c[s]=u)}return c}function v(r,e,t=[]){const i={};for(const o of t)e.epics[o]&&(i[o]=e.epics[o]);for(const[o,c]of Object.entries(r)){const s=k(c,o);s&&e.epics[s]&&(i[s]=e.epics[s])}return i}function w(r,e,t){if(t.has(r))return;const i=e.epics[r];if(!i)return;t.add(r);const o=i.depends_on;if(Array.isArray(o))for(const c of o)typeof c=="string"&&c.length>0&&w(c,e,t)}function B(r,e,t){const i=new Set;return w(r,t,i),v(e,t,[...i])}function J(r,e){const t=new Set,i=r.stories;if(Array.isArray(i))for(const c of i){if(typeof c!="string")continue;const s=e.stories[c];if(s){if(x(s.status)){t.add(c);continue}h(c,e,t)}}const o={};for(const c of t){const s=e.stories[c];s&&(o[c]=s)}return o}function K(r,e){const t=new Set,i=r.stories;if(Array.isArray(i))for(const c of i)typeof c=="string"&&h(c,e,t);const o={};for(const c of t){const s=e.stories[c];s&&(o[c]=s)}return o}function W(r){const e={};for(const[t,i]of Object.entries(r.epics))e[t]={id:a(i.id)??t,...a(i.status)?{status:a(i.status)}:{},...typeof i.total_stories=="number"&&Number.isFinite(i.total_stories)?{total_stories:i.total_stories}:{},...typeof i.completed_stories=="number"&&Number.isFinite(i.completed_stories)?{completed_stories:i.completed_stories}:{}};return e}function R(r){const e={};for(const t of Object.values(r)){const i=a(t.status,40)??"unknown";e[i]=(e[i]??0)+1}return e}function A(r){for(const e of["last_updated","updated_at","completed_at","created_at","discovered_at"]){const t=r[e];if(typeof t!="string")continue;const i=Date.parse(t);if(Number.isFinite(i))return i}return 0}function V(r){return Object.entries(r.stories).map(([e,t])=>({id:e,story:t,timestamp:A(t)})).sort((e,t)=>t.timestamp-e.timestamp||e.id.localeCompare(t.id)).slice(0,12).map(({id:e,story:t})=>({id:e,...a(t.epic_id)?{epicId:a(t.epic_id)}:{},...a(t.status,40)?{status:a(t.status,40)}:{},...a(t.last_step??t.lastStep)?{lastStep:a(t.last_step??t.lastStep)}:{},...a(t.last_updated??t.updated_at??t.completed_at??t.created_at)?{lastUpdated:a(t.last_updated??t.updated_at??t.completed_at??t.created_at)}:{}}))}function H(r){const e=r.current_session;if(!e)return;const t={activeEpicId:a(e.active_epic_id)??null,activeStoryId:a(e.active_story_id)??null,activeStepId:a(e.active_step_id)??null,sessionId:a(e.session_id)??null,startedAt:a(e.started_at)??null};return Object.values(t).some(i=>i!=null)?t:void 0}function Q(r){const e=r.yoloop;if(!b(e))return;const t=b(e.state)?e.state:void 0,i=b(t?.currentSession)?t.currentSession:void 0,o=b(e.lock)?e.lock:void 0,c={...typeof e.active=="boolean"?{active:e.active}:{},currentEpicId:a(i?.currentEpicId??e.currentEpicId)??null,currentStoryId:a(i?.currentStoryId??e.currentStoryId)??null,sessionId:a(i?.sessionId??e.sessionId)??null,lockEpicId:a(o?.currentEpicId??o?.epicId)??null};return Object.keys(c).length>0?c:void 0}function X(r){const e=r.continuity;if(!b(e))return;const t=Array.isArray(e.reasonCodes)?e.reasonCodes.filter(i=>typeof i=="string"):void 0;return{present:!0,activeJobId:a(e.activeJobId??e.jobId)??null,activeGoalId:a(e.activeGoalId??e.goalId)??null,activeLoopId:a(e.activeLoopId??e.loopId)??null,...t&&t.length>0?{reasonCodes:f(t)}:{}}}function ee(r,e,t){const i=a(e?.activeStoryId),o=a(e?.activeEpicId),c=a(e?.activeStepId);if(i||o||c)return{epicId:o??null,storyId:i??null,stepId:c??null};const s=a(t?.currentStoryId),u=a(t?.currentEpicId??t?.lockEpicId);if(s||u)return{epicId:u??null,storyId:s??null,stepId:null};const d=Object.entries(r.stories).map(([l,p])=>({id:l,story:p,timestamp:A(p)})).filter(({story:l})=>!x(l.status)).sort((l,p)=>p.timestamp-l.timestamp||l.id.localeCompare(p.id))[0];return d?{epicId:k(d.story,d.id),storyId:d.id,stepId:a(d.story.last_step??d.story.lastStep)??null}:{epicId:null,storyId:null,stepId:null}}function te(r,e){const t=R(r.stories),i=R(r.epics),o=H(r),c=Q(r),s=X(r),u=ee(r,o,c),d=V(r),l=f(e.reasonCodes,["state-summary-attached","state-summary-bounded",`projection-${e.projectionMode??e.kind}`,e.stateProjectionPolicy?`policy-${e.stateProjectionPolicy}`:"policy-unknown",d.length>=12?"recent-stories-capped":"recent-stories-bounded",u.storyId||u.epicId?"active-ref-derived":"active-ref-empty",c?"yoloop-session-present":"yoloop-session-absent",s?"continuity-session-present":"continuity-session-absent"]);return{schemaVersion:1,totals:{stories:Object.keys(r.stories).length,epics:Object.keys(r.epics).length,storyStatus:t,epicStatus:i,blockedStories:t.blocked??0},active:u,blockedCount:t.blocked??0,recentStories:d,...o?{currentSession:o}:{},...c?{currentYoloopSession:c}:{},...s?{currentContinuitySession:s}:{},projection:{commandId:e.commandId??null,stateProjectionPolicy:e.stateProjectionPolicy??null,projectionMode:e.projectionMode,scopeKind:e.kind,includedStoryCount:e.includedStoryCount,includedEpicCount:e.includedEpicCount??Object.keys(r.epics).length,omittedStoryCount:e.omittedStoryCount,omittedEpicCount:e.omittedEpicCount,reason:e.reason},reasonCodes:l,publicSafe:!0}}function m(r,e,t){return{...r,stateSummary:te(e,t)}}function re(r,e,t){const i={};for(const c of Object.keys(e.epics))i[c]={id:c};const o={kind:"projected",commandId:t.commandId,stateProjectionPolicy:t.stateProjectionPolicy,projectionMode:"summary-only",trigger:r,targetEpicId:null,targetStoryId:null,includedStoryCount:0,includedEpicCount:Object.keys(i).length,omittedStoryCount:Object.keys(e.stories).length,omittedEpicCount:0,reason:"epic-summary",reasonCodes:["epic-summary","stories-omitted","epic-stubs-only"]};return m({...e,stories:{},epics:i,scope:o},e,o)}function j(r,e,t,i=["summary-only","stories-omitted"]){const o=W(e),c={kind:"projected",commandId:t.commandId,stateProjectionPolicy:t.stateProjectionPolicy,projectionMode:"summary-only",trigger:r,targetEpicId:null,targetStoryId:null,includedStoryCount:0,includedEpicCount:Object.keys(o).length,omittedStoryCount:Object.keys(e.stories).length,omittedEpicCount:Math.max(0,Object.keys(e.epics).length-Object.keys(o).length),reason:"summary-only",reasonCodes:f(i)};return m({...e,stories:{},epics:o,scope:c},e,c)}function E(r,e,t,i,o,c){const s=e.stories[i];if(!s)return y(r,e,t,o,[...c,"target-story-missing-full-state"]);const u=k(s,i);if(!u)return y(r,e,t,o,[...c,"target-epic-unresolved-full-state"]);const d=e.epics[u];if(!d)return y(r,e,t,o,[...c,"target-epic-missing-full-state"]);const l=U(i,d,e),p=v(l,e);if(!l[i]||!p[u])return y(r,e,t,o,[...c,"target-projection-incomplete-full-state"]);const g={kind:"projected",commandId:t.commandId,stateProjectionPolicy:t.stateProjectionPolicy,projectionMode:o,trigger:r,targetEpicId:u,targetStoryId:i,includedStoryCount:Object.keys(l).length,includedEpicCount:Object.keys(p).length,omittedStoryCount:Math.max(0,Object.keys(e.stories).length-Object.keys(l).length),omittedEpicCount:Math.max(0,Object.keys(e.epics).length-Object.keys(p).length),reason:"targeted-invocation",reasonCodes:f(c)};return m({...e,stories:l,epics:p,scope:g},e,g)}function T(r,e,t,i,o,c){const s=e.epics[i];if(!s)return y(r,e,t,o,[...c,"target-epic-missing-full-state"]);const u=K(s,e),d=v(u,e,[i]);if(!d[i])return y(r,e,t,o,[...c,"target-epic-projection-incomplete-full-state"]);const l={kind:"projected",commandId:t.commandId,stateProjectionPolicy:t.stateProjectionPolicy,projectionMode:o,trigger:r,targetEpicId:i,targetStoryId:null,includedStoryCount:Object.keys(u).length,includedEpicCount:Object.keys(d).length,omittedStoryCount:Math.max(0,Object.keys(e.stories).length-Object.keys(u).length),omittedEpicCount:Math.max(0,Object.keys(e.epics).length-Object.keys(d).length),reason:"targeted-invocation",reasonCodes:f(c)};return m({...e,stories:u,epics:d,scope:l},e,l)}function ie(r,e,t){const i=G(r,e);if(!i)return y(r,e,t,"structural-required",["yoloop-target-missing-full-state"]);const o=e.epics[i];if(!o)return y(r,e,t,"structural-required",["yoloop-target-epic-missing-full-state"]);const c=J(o,e),s=B(i,c,e);if(!s[i])return y(r,e,t,"structural-required",["yoloop-projection-incomplete-full-state"]);const u={kind:"projected",commandId:t.commandId,stateProjectionPolicy:t.stateProjectionPolicy,projectionMode:"structural-required",trigger:r,targetEpicId:i,targetStoryId:null,includedStoryCount:Object.keys(c).length,includedEpicCount:Object.keys(s).length,omittedStoryCount:Math.max(0,Object.keys(e.stories).length-Object.keys(c).length),omittedEpicCount:Math.max(0,Object.keys(e.epics).length-Object.keys(s).length),reason:"targeted-invocation",reasonCodes:["structural-required","yoloop-targeted"]};return m({...e,stories:c,epics:s,scope:u},e,u)}function ce(r,e){const t={};for(const[i,o]of Object.entries(r.epics)){const c=Array.isArray(o.stories)?o.stories.filter(s=>typeof s=="string"&&e.has(s)):[];t[i]={id:a(o.id)??i,...a(o.status,40)?{status:a(o.status,40)}:{},...typeof o.total_stories=="number"&&Number.isFinite(o.total_stories)?{total_stories:o.total_stories}:{},...typeof o.completed_stories=="number"&&Number.isFinite(o.completed_stories)?{completed_stories:o.completed_stories}:{},...c.length>0?{stories:c}:{}}}return t}function oe(r){return r.stateSummary?.totals.stories??(r.scope?.includedStoryCount??Object.keys(r.stories).length)+(r.scope?.omittedStoryCount??0)}function ne(r){return r.stateSummary?.totals.epics??(r.scope?.includedEpicCount??Object.keys(r.epics).length)+(r.scope?.omittedEpicCount??0)}function se(r,e){if(r.stateSummary)return{...r.stateSummary,projection:{...r.stateSummary.projection,scopeKind:"projected",projectionMode:e.projectionMode,includedStoryCount:e.includedStoryCount,includedEpicCount:e.includedEpicCount??r.stateSummary.projection.includedEpicCount,omittedStoryCount:e.omittedStoryCount,omittedEpicCount:e.omittedEpicCount,reason:"body-size"},reasonCodes:f(r.stateSummary.reasonCodes,["payload-size-guardrail","state-summary-preserved","nonessential-state-degraded"])}}function le(r){const e=r.scope,t=new Set;if(e?.projectionMode==="structural-required")for(const I of Object.keys(r.stories))t.add(I);else e?.targetStoryId&&h(e.targetStoryId,r,t);const i={};for(const I of t){const C=r.stories[I];C&&(i[I]=C)}const o=ce(r,t),c=Object.keys(i).length,s=Object.keys(o).length,u=Math.max(0,oe(r)-c),d=Math.max(0,ne(r)-s),l=e?.projectionMode==="structural-required"?"structural-required":"summary-only",p={kind:"projected",commandId:e?.commandId??null,stateProjectionPolicy:e?.stateProjectionPolicy??null,projectionMode:l,...e?.trigger?{trigger:e.trigger}:{},targetEpicId:e?.targetEpicId??null,targetStoryId:e?.targetStoryId??null,includedStoryCount:c,includedEpicCount:s,omittedStoryCount:u,omittedEpicCount:d,reason:"body-size",reasonCodes:f(e?.reasonCodes,["payload-size-guardrail",t.size>0?"structural-targets-preserved":"stories-omitted","epics-stubbed","state-summary-preserved"])},g=se(r,p);return{...r,stories:i,epics:o,scope:p,...g?{stateSummary:g}:{}}}function pe(r,e){const t=r.trim();try{const i=L(t);if(!i){if(D(t)){const c=n("story-reference","story-targeted"),s=q(t);if(s)return E(t,e,c,s,"targeted-story",["story-reference-targeted"])}return y(t,e,null,"full-compatible",["unknown-command-full-state"])}if(i.stateProjectionPolicy==="epic-summary")return re(t,e,i);if(i.stateProjectionPolicy==="yoloop-targeted")return ie(t,e,i);const o=q(t);if(i.stateProjectionPolicy==="story-targeted")return o?E(t,e,i,o,i.structuralRequired?"structural-required":"targeted-story",[i.structuralRequired?"structural-required":"targeted-story"]):i.structuralRequired?y(t,e,i,"structural-required",["structural-target-missing-full-state"]):j(t,e,i,["story-target-missing-summary-only"]);if(i.stateProjectionPolicy==="adaptive-targeted"){if(o&&e.stories[o])return E(t,e,i,o,"targeted-story",["adaptive-story-targeted"]);const c=S(t,e);return c?T(t,e,i,c,"targeted-epic",["adaptive-epic-targeted"]):j(t,e,i,["adaptive-summary-only","target-unresolved-summary-only"])}if(i.stateProjectionPolicy==="epic-targeted"){const c=S(t,e);return c?T(t,e,i,c,i.structuralRequired?"structural-required":"targeted-epic",[i.structuralRequired?"structural-required":"targeted-epic"]):i.structuralRequired?y(t,e,i,"structural-required",["structural-epic-target-missing-full-state"]):j(t,e,i,["epic-target-missing-summary-only"])}return i.stateProjectionPolicy==="continuity-scoped"?j(t,e,i,["continuity-scoped-summary-only"]):j(t,e,i,["policy-full-summary-only"])}catch{return y(t,e,null,"full-compatible",["projection-error-full-state"])}}export{le as degradeStateSnapshotForPayloadLimit,pe as projectStateSnapshotForInvoke};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* Client-owned `.neocortex/state.json` automatic repair helpers.
|
|
6
|
+
*/
|
|
7
|
+
export declare class StateRepairHardStopError extends Error {
|
|
8
|
+
readonly reasonCode: string;
|
|
9
|
+
constructor(message: string, reasonCode: string);
|
|
10
|
+
}
|
|
11
|
+
export interface StateRepairAuditSummary {
|
|
12
|
+
readonly repaired: boolean;
|
|
13
|
+
readonly reasonCodes: readonly string[];
|
|
14
|
+
readonly backupPath?: string;
|
|
15
|
+
readonly changes: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
export interface StateJsonPreInvokeRepairOptions {
|
|
18
|
+
readonly args?: string;
|
|
19
|
+
readonly nowIso?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const P189_STATE_SHAPE_GAP_CODE: "P189-GAP-STATE-SHAPE";
|
|
22
|
+
export declare const EPIC_AGGREGATE_REASON_CODES: {
|
|
23
|
+
readonly reconciled: "epic_aggregate_reconciled";
|
|
24
|
+
readonly totalRecounted: "epic_total_stories_recounted";
|
|
25
|
+
readonly completedRecounted: "epic_completed_stories_recounted";
|
|
26
|
+
readonly statusPromotedDone: "epic_status_promoted_done";
|
|
27
|
+
readonly completedAtSet: "epic_completed_at_set";
|
|
28
|
+
readonly stateNotObject: "epic_aggregate_state_not_object";
|
|
29
|
+
readonly epicsNotObject: "epic_aggregate_epics_not_object";
|
|
30
|
+
readonly storiesNotObject: "epic_aggregate_stories_not_object";
|
|
31
|
+
readonly scopeProjected: "epic_aggregate_scope_projected";
|
|
32
|
+
readonly epicNotObject: "epic_aggregate_epic_not_object";
|
|
33
|
+
readonly epicIdConflict: "epic_aggregate_epic_id_conflict";
|
|
34
|
+
readonly storyListNotArray: "epic_aggregate_story_list_not_array";
|
|
35
|
+
readonly storyRefInvalid: "epic_aggregate_story_ref_invalid";
|
|
36
|
+
readonly storyRefDuplicate: "epic_aggregate_story_ref_duplicate";
|
|
37
|
+
readonly storyMissing: "epic_aggregate_story_missing";
|
|
38
|
+
readonly storyNotObject: "epic_aggregate_story_not_object";
|
|
39
|
+
readonly storyIdConflict: "epic_aggregate_story_id_conflict";
|
|
40
|
+
readonly storyEpicConflict: "epic_aggregate_story_epic_conflict";
|
|
41
|
+
readonly terminalIncompleteConflict: "epic_aggregate_terminal_incomplete_conflict";
|
|
42
|
+
};
|
|
43
|
+
export type EpicAggregateRepairReasonCode = typeof EPIC_AGGREGATE_REASON_CODES.reconciled | typeof EPIC_AGGREGATE_REASON_CODES.totalRecounted | typeof EPIC_AGGREGATE_REASON_CODES.completedRecounted | typeof EPIC_AGGREGATE_REASON_CODES.statusPromotedDone | typeof EPIC_AGGREGATE_REASON_CODES.completedAtSet;
|
|
44
|
+
export type EpicAggregateConflictReasonCode = Exclude<typeof EPIC_AGGREGATE_REASON_CODES[keyof typeof EPIC_AGGREGATE_REASON_CODES], EpicAggregateRepairReasonCode>;
|
|
45
|
+
export interface EpicAggregateReconciliationChange {
|
|
46
|
+
readonly epicId: string;
|
|
47
|
+
readonly reasonCodes: readonly EpicAggregateRepairReasonCode[];
|
|
48
|
+
readonly previous: {
|
|
49
|
+
readonly total_stories?: unknown;
|
|
50
|
+
readonly completed_stories?: unknown;
|
|
51
|
+
readonly status?: unknown;
|
|
52
|
+
readonly completed_at?: unknown;
|
|
53
|
+
};
|
|
54
|
+
readonly next: {
|
|
55
|
+
readonly total_stories: number;
|
|
56
|
+
readonly completed_stories: number;
|
|
57
|
+
readonly status?: unknown;
|
|
58
|
+
readonly completed_at?: unknown;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export interface EpicAggregateReconciliationOptions {
|
|
62
|
+
readonly nowIso?: string;
|
|
63
|
+
readonly scope?: unknown;
|
|
64
|
+
readonly targetEpicId?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface EpicAggregateReconciliationResult<TState extends Record<string, unknown> = Record<string, unknown>> {
|
|
67
|
+
readonly mutated: boolean;
|
|
68
|
+
readonly state: TState;
|
|
69
|
+
readonly reasonCodes: readonly EpicAggregateRepairReasonCode[];
|
|
70
|
+
readonly changes: readonly EpicAggregateReconciliationChange[];
|
|
71
|
+
}
|
|
72
|
+
export declare function isP189DoneLikeStoryStatus(value: unknown): boolean;
|
|
73
|
+
export declare function reconcileEpicAggregatesInState<TState extends Record<string, unknown>>(input: unknown, options?: EpicAggregateReconciliationOptions): EpicAggregateReconciliationResult<TState>;
|
|
74
|
+
export declare function maybeRepairStateJsonBeforeInvoke(projectRoot: string, options?: StateJsonPreInvokeRepairOptions): StateRepairAuditSummary;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{existsSync as M,mkdirSync as L,readFileSync as D,renameSync as G,writeFileSync as z,copyFileSync as F}from"node:fs";import{join as N}from"node:path";import{randomBytes as J}from"node:crypto";class v extends Error{reasonCode;constructor(o,t){super(o),this.reasonCode=t,this.name="StateRepairHardStopError"}}const q="P189-GAP-STATE-SHAPE",f={reconciled:"epic_aggregate_reconciled",totalRecounted:"epic_total_stories_recounted",completedRecounted:"epic_completed_stories_recounted",statusPromotedDone:"epic_status_promoted_done",completedAtSet:"epic_completed_at_set",stateNotObject:"epic_aggregate_state_not_object",epicsNotObject:"epic_aggregate_epics_not_object",storiesNotObject:"epic_aggregate_stories_not_object",scopeProjected:"epic_aggregate_scope_projected",epicNotObject:"epic_aggregate_epic_not_object",epicIdConflict:"epic_aggregate_epic_id_conflict",storyListNotArray:"epic_aggregate_story_list_not_array",storyRefInvalid:"epic_aggregate_story_ref_invalid",storyRefDuplicate:"epic_aggregate_story_ref_duplicate",storyMissing:"epic_aggregate_story_missing",storyNotObject:"epic_aggregate_story_not_object",storyIdConflict:"epic_aggregate_story_id_conflict",storyEpicConflict:"epic_aggregate_story_epic_conflict",terminalIncompleteConflict:"epic_aggregate_terminal_incomplete_conflict"},H=new Set(["yolo","implement","diagnose","research","write-spec","create-tasks","refactor-suggest","property-tests","validate-tests","qa-gate","update-project-memory","commit-push","sync-main","create-pr","review-pr","merge-pr","review"]),K=new Set(["yoloop","auto-yolo","epic-runner","story-runner","loop-yolo","auto-epic"]);function p(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function j(){return new Date().toISOString()}function B(){return j().replace(/[:.]/g,"-")}function I(e){return Array.isArray(e)?e.filter(o=>typeof o=="string"&&o.length>0):[]}function W(e){const[o]=e.trim().split(/\s+/,1);return o?o.replace(/^@?\*/,"").replace(/^@/,"").toLowerCase():null}function Z(e){const[o]=e.trim().split(/\s+/,1);if(!o)return!1;const t=o.replace(/^@/,"");return/^[A-Z]?\d+(?:\.\d+)+$/i.test(t)||/(?:^|\/)[A-Z]?\d+(?:\.\d+)+\.story\.md$/i.test(t)}function U(e){const o=e.match(/(?:^|[/@\s])([A-Z]?\d+(?:\.\d+)+)\.story\.md\b/i);return o?.[1]?o[1]:e.match(/(?:^|\s|@)([A-Z]?\d+(?:\.\d+)+)(?=$|\s)/i)?.[1]??null}function V(e){const o=e.trim(),t=o.search(/\s/);return t===-1?"":o.slice(t).trim()}function Y(e){const o=V(e).split(/\s+/).find(t=>t.length>0&&!t.startsWith("-"));return o?o.replace(/^@/,"").replace(/^['"]|['"]$/g,""):null}function $(e,o){const s=e.replace(/^@/,"").replace(/^epic-/i,"").replace(/\.md$/i,""),r=[s,s.toUpperCase(),/^p\d+$/i.test(s)?`P${s.replace(/^p/i,"")}`:null,/^\d+$/.test(s)?`P${s}`:null].filter(n=>typeof n=="string"&&n.length>0);for(const n of r)if(p(o[n]))return n;return null}function Q(e,o){const t=e.match(/(?:^|[/@\s])epic-(P?\d+)\.md\b/i);return t?.[1]?$(t[1],o):null}function X(e,o){if(typeof o!="string"||o.trim().length===0||!p(e.epics)||!p(e.stories))return;const t=o.trim(),s=W(t);if(s!==null&&H.has(s)||Z(t)){const n=U(t),l=n?e.stories[n]:void 0;if(p(l)&&typeof l.epic_id=="string"&&p(e.epics[l.epic_id]))return l.epic_id}if(s!==null&&K.has(s)){const n=Q(t,e.epics);if(n)return n;const l=Y(t);if(l){const c=$(l,e.epics);if(c)return c}}}const R="pr_merged_issue_closed_reconciled",ee="invalid_workflow_issue_removed";function S(e){return typeof e=="string"?e.trim().toLowerCase().replace(/[_\s]+/g,"-"):""}const te=new Set(["done","completed","merged"]),oe=new Set(["done","completed","merged"]);function se(e){return te.has(S(e))}function k(e){return oe.has(S(e))}function y(e,o){throw new v(`${o} (${q} if this shape is intentionally new).`,e)}function re(e){return JSON.parse(JSON.stringify(e))}function ne(e,o){const t=o.scope??e.scope;if(!p(t))return;const s=typeof t.kind=="string"?t.kind:null,r=typeof t.omittedStoryCount=="number"?t.omittedStoryCount:0,n=typeof t.omittedEpicCount=="number"?t.omittedEpicCount:0;(s==="projected"||r>0||n>0)&&y(f.scopeProjected,"[Neocortex] state.json aggregate reconciliation stopped: projected or partial state coverage cannot prove epic aggregates.")}function ie(e,o){const t=[],s=new Set;for(const r of o)(typeof r!="string"||r.length===0)&&y(f.storyRefInvalid,`[Neocortex] state.json aggregate reconciliation stopped: epic "${g(e)}" has a non-string or empty story reference.`),s.has(r)&&y(f.storyRefDuplicate,`[Neocortex] state.json aggregate reconciliation stopped: epic "${g(e)}" lists story "${g(r)}" more than once.`),s.add(r),t.push(r);return t}function ae(e,o,t){const s=t[o];return s===void 0&&y(f.storyMissing,`[Neocortex] state.json aggregate reconciliation stopped: epic "${g(e)}" references missing story "${g(o)}".`),p(s)||y(f.storyNotObject,`[Neocortex] state.json aggregate reconciliation stopped: story "${g(o)}" is not an object.`),s.id!==o&&y(f.storyIdConflict,`[Neocortex] state.json aggregate reconciliation stopped: story key "${g(o)}" conflicts with its id field.`),s.epic_id!==e&&y(f.storyEpicConflict,`[Neocortex] state.json aggregate reconciliation stopped: story "${g(o)}" does not belong to epic "${g(e)}".`),s}function x(e,o){e.includes(o)||e.push(o)}function ce(e,o={}){p(e)||y(f.stateNotObject,"[Neocortex] state.json aggregate reconciliation stopped: top-level state must be an object."),p(e.epics)||y(f.epicsNotObject,"[Neocortex] state.json aggregate reconciliation stopped: `epics` must be an object before counts are authoritative."),p(e.stories)||y(f.storiesNotObject,"[Neocortex] state.json aggregate reconciliation stopped: `stories` must be an object before counts are authoritative."),ne(e,o);const t=re(e),s=t.epics,r=t.stories,n=[],l=[];for(const[c,a]of Object.entries(s)){if(o.targetEpicId&&c!==o.targetEpicId)continue;p(a)||y(f.epicNotObject,`[Neocortex] state.json aggregate reconciliation stopped: epic "${g(c)}" is not an object.`),a.id!==c&&y(f.epicIdConflict,`[Neocortex] state.json aggregate reconciliation stopped: epic key "${g(c)}" conflicts with its id field.`),Array.isArray(a.stories)||y(f.storyListNotArray,`[Neocortex] state.json aggregate reconciliation stopped: epic "${g(c)}" has non-array stories.`);const m=ie(c,a.stories),i=m.length,d=m.filter(A=>{const u=ae(c,A,r);return se(u.status)}).length,_=i>0&&d===i;k(a.status)&&!_&&i>0&&y(f.terminalIncompleteConflict,`[Neocortex] state.json aggregate reconciliation stopped: terminal epic "${g(c)}" has incomplete listed stories.`);const h=[],b={total_stories:a.total_stories,completed_stories:a.completed_stories,status:a.status,completed_at:a.completed_at};if(a.total_stories!==i&&(a.total_stories=i,x(h,f.totalRecounted)),a.completed_stories!==d&&(a.completed_stories=d,x(h,f.completedRecounted)),!k(a.status)&&_&&(a.status="done",x(h,f.statusPromotedDone),(a.completed_at===void 0||a.completed_at===null)&&(a.completed_at=o.nowIso??j(),x(h,f.completedAtSet))),h.length>0){x(h,f.reconciled);for(const A of h)x(n,A);l.push({epicId:c,reasonCodes:h,previous:b,next:{total_stories:i,completed_stories:d,status:a.status,completed_at:a.completed_at}})}}return{mutated:JSON.stringify(t)!==JSON.stringify(e),state:t,reasonCodes:n,changes:l}}function w(e,o){const t=e[o];return p(t)?t:null}function pe(e){const o=w(e,"issueCloseAudit")??w(e,"issue_close_audit");if(o){const r=S(o.event).replace(/-/g,"_"),n=o.publicSafe===!0||o.public_safe===!0,l=o.rawLogStorage==="forbidden"||o.raw_log_storage==="forbidden";if(r==="story_issue_closed"&&n&&l)return!0}const t=w(e,"completionEvidence")??w(e,"completion_evidence"),s=S(t?.issueState??t?.issue_state??t?.state);return e.issue_closed===!0||S(e.issue_state??e.issueState??e.workflow_issue_state)==="closed"||s==="closed"}function O(e){const o=w(e,"completionEvidence")??w(e,"completion_evidence"),t=w(e,"scopedCiEvidence")??w(e,"scoped_ci_evidence"),s=[e.physicalMergeStatus,e.pr_state,e.prState,e.pull_request_state,e.pullRequestState,o?.prState,o?.pr_state,o?.pullRequestState,t?.prState].map(S);return e.merged===!0||s.includes("merged")||S(t?.finalState)==="can-merge"&&e.merged===!0}function le(e){const o=w(e,"completionEvidence")??w(e,"completion_evidence"),t=[e.pr_state,e.prState,e.pull_request_state,e.pullRequestState,o?.prState,o?.pr_state,o?.pullRequestState].map(S),s=O(e),r=["denied-external-gate","denied-local-or-repo","not-attempted"].includes(S(e.physicalMergeStatus)),n=t.includes("closed")||t.includes("closed-unmerged");return s&&(e.merged===!1||r||n)||e.merged===!0&&r}function de(e,o,t){const s=`state-completion-reconciliation:${g(o)}`,r=e.filter(p).map(a=>({...a})),n={id:s,status:"open",reason:"stale_state_completion_evidence_observed",reason_codes:[R],category:"state/completion-reconciliation",story_id:g(o),public_safe:!0,raw_log_storage:"forbidden",created_at:t,last_seen_at:t,occurrences:1},l=r.findIndex(a=>a.id===s);if(l<0)return[...r,n];const c=r[l];return r[l]={...c,...n,created_at:typeof c.created_at=="string"?c.created_at:t,occurrences:Math.max(1,typeof c.occurrences=="number"?c.occurrences:1)+1},r}function ue(e,o,t){const s=p(e.stories)?e.stories:null;if(!s)return;const r=[],n=j();for(const[l,c]of Object.entries(s)){if(!p(c))continue;const a=S(c.status);if(le(c))throw new v(`[Neocortex] state.json repair stopped: story "${l}" has conflicting PR merge completion evidence. Resolve .neocortex/state.json manually before invoking Neocortex.`,"conflicting_completion_evidence");if(a!=="pr-reviewed"||!O(c)||!pe(c))continue;const m=typeof c.status=="string"?c.status:a,i=I(c.steps_completed);c.status="done",c.last_step="step-c-12-merge-pr",c.steps_completed=Array.from(new Set([...i,"step-c-12-merge-pr"])),c.merged=!0,c.physicalMergeStatus="merged",c.completion_reconciled_at=n,o.push(`reconciled completion evidence for story ${l}`),t.push(R),r.push({schemaVersion:1,publicSafe:!0,rawLogStorage:"forbidden",storyId:g(l),previousStatus:m,nextStatus:"done",reasonCodes:[R],reconciledAt:n}),e.state_repair_debt=de(Array.isArray(e.state_repair_debt)?e.state_repair_debt:[],l,n)}r.length>0&&(e.state_completion_reconciliations=[...Array.isArray(e.state_completion_reconciliations)?e.state_completion_reconciliations.filter(p):[],...r])}function _e(e,o,t){const s=p(e.stories)?e.stories:null;if(s)for(const[r,n]of Object.entries(s))!p(n)||!Object.prototype.hasOwnProperty.call(n,"workflow_issue")||typeof n.workflow_issue=="number"&&Number.isFinite(n.workflow_issue)||(delete n.workflow_issue,o.push(`removed invalid workflow_issue from story ${g(r)}`),t.push(ee))}function ge(e,o,t){const s=t[e];if(!p(s))return;const r=s.epic_id;if(typeof r=="string"&&r!==o)throw new v(`[Neocortex] state.json repair stopped: story "${e}" belongs to epic "${r}" but legacy planning maps it to "${o}". Resolve the conflicting IDs in .neocortex/state.json, then rerun the command.`,"conflicting_story_epic_id")}function fe(e,o={}){if(Array.isArray(e.stories))throw new v("[Neocortex] state.json repair stopped: `stories` is an Array. Convert it to an object keyed by story ID or run `*migrate-state --preview` for guidance.","stories_array_ambiguous");if(p(e.epics)){for(const[i,d]of Object.entries(e.epics))if(p(d)&&d.stories!==void 0&&!Array.isArray(d.stories))throw new v(`[Neocortex] state.json repair stopped: epic "${i}" has non-array \`stories\`. Repair this ambiguous shape manually before invoking Neocortex.`,"epic_stories_not_array")}if(e.schema_version!==void 0&&e.schema_version!==1)throw new v(`[Neocortex] state.json repair stopped: schema_version=${String(e.schema_version)} is not a safe automatic downgrade target. Run \`*migrate-state --preview\` or repair the schema version manually.`,"unsupported_schema_version");let t=JSON.parse(JSON.stringify(e));const s=[],r=[];let n=[];p(t.epics)||(t.epics={},s.push("initialized epics{}"),r.push("initialized_epics_object")),p(t.stories)||(t.stories={},s.push("initialized stories{}"),r.push("initialized_stories_object"));const l=t.epics,c=t.stories,a=p(t.planning)?t.planning:null;if(a&&p(a.current)){const i=a.current,d=typeof i.epic_id=="string"?i.epic_id:null;if(!d)throw new v("[Neocortex] state.json repair stopped: legacy planning.current has no epic_id. Add the missing epic_id or run `*migrate-state --preview`.","planning_current_missing_epic_id");const _=Array.isArray(i.stories)?i.stories:[],h=_.map(u=>p(u)&&typeof u.id=="string"?u.id:typeof u=="string"?u:null).filter(u=>!!u);for(const u of h)ge(u,d,c);p(l[d])||(l[d]={id:d,title:typeof i.title=="string"?i.title:`Epic ${d}`,status:i.status==="done"?"done":"in-progress",stories:h,created_at:typeof i.created_at=="string"?i.created_at:j(),completed_at:typeof i.completed_at=="string"?i.completed_at:null,completed_stories:typeof i.completed_stories=="number"?i.completed_stories:0,total_stories:typeof i.total_stories=="number"?i.total_stories:h.length,source:"client-auto-repair-P156.05"},s.push(`migrated planning.current to epics["${d}"]`),r.push("legacy_planning_current_migrated"));for(const u of _)!p(u)||typeof u.id!="string"||p(c[u.id])||(c[u.id]={...u,id:u.id,epic_id:d,title:typeof u.title=="string"?u.title:u.id,status:typeof u.status=="string"?u.status:"backlog",depends_on:I(u.depends_on),created_at:typeof u.created_at=="string"?u.created_at:j()},s.push(`migrated embedded story ${u.id}`),r.push("legacy_planning_story_migrated"));const b=typeof i.status=="string"?i.status.trim().toLowerCase().replace(/[_\s]+/g,"-"):"",C=new Set(["epic_id","title","status","created_at","updated_at","completed_at","completed_stories","total_stories","stories"]),A=Object.keys(i).filter(u=>!C.has(u));b==="generated"&&A.length===0?(delete a.current,s.push("removed safe legacy planning.current generated container"),r.push("legacy_planning_current_generated_removed")):A.length>0&&(s.push(`preserved planning.current unknown keys: ${A.sort().join(", ")}`),r.push("unknown_planning_current_keys_preserved"))}if(a&&Array.isArray(a.history)){let i=!0;const d=new Set(["epic_id","title","status","created_at","completed_at","completed_stories","total_stories","stories"]);for(const _ of a.history){if(!p(_)){i=!1;continue}Object.keys(_).filter(C=>!d.has(C)).length>0&&(i=!1);const b=typeof _.epic_id=="string"?_.epic_id:null;if(!b){i=!1;continue}p(l[b])||(l[b]={id:b,title:typeof _.title=="string"?_.title:`Epic ${b}`,status:"done",stories:I(_.stories),created_at:typeof _.created_at=="string"?_.created_at:j(),completed_at:typeof _.completed_at=="string"?_.completed_at:j(),completed_stories:typeof _.completed_stories=="number"?_.completed_stories:0,total_stories:typeof _.total_stories=="number"?_.total_stories:0,source:"client-auto-repair-P156.05"},s.push(`migrated planning.history to epics["${b}"]`),r.push("legacy_planning_history_migrated"))}i?(delete a.history,s.push("removed safe legacy planning.history container"),r.push("legacy_planning_history_removed")):(s.push("preserved planning.history because one or more entries were not safely removable"),r.push("legacy_planning_history_preserved"))}if(a&&Object.keys(a).length===0&&(delete t.planning,s.push("removed empty planning container"),r.push("empty_planning_removed")),t.schema_version!==1&&(t.schema_version=1,s.push("set schema_version=1"),r.push("schema_version_added")),_e(t,s,r),ue(t,s,r),typeof o.args=="string"){const i=X(t,o.args),d=ce(t,{nowIso:o.nowIso,targetEpicId:i});if(d.mutated){t=d.state,n=d.changes;for(const _ of d.reasonCodes)r.push(_);for(const _ of d.changes)s.push(`reconciled aggregate for epic ${g(_.epicId)}`)}}const m=JSON.stringify(t)!==JSON.stringify(e);if(m){const i=o.nowIso??j(),d=Array.from(new Set(r));n.length>0&&he(t,n,i),t.last_updated=i,t.state_migration_repairs=[...Array.isArray(t.state_migration_repairs)?t.state_migration_repairs:[],{schemaVersion:1,action:"client_auto_repair",reasonCodes:d,repairedAt:i}],t.state_repair_debt=Se(Array.isArray(t.state_repair_debt)?t.state_repair_debt:[],d,i)}return{mutated:m,state:t,reasonCodes:Array.from(new Set(r)),changes:s}}function P(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function T(e){const o=S(e);return o.length>0?E(o).slice(0,80):null}function me(e,o){return{schemaVersion:1,publicSafe:!0,epicId:g(e.epicId),reasonCodes:e.reasonCodes.map(E).filter(Boolean),previous:{total_stories:P(e.previous.total_stories),completed_stories:P(e.previous.completed_stories),status:T(e.previous.status),completed_at_present:typeof e.previous.completed_at=="string"&&e.previous.completed_at.length>0},next:{total_stories:e.next.total_stories,completed_stories:e.next.completed_stories,status:T(e.next.status),completed_at_present:typeof e.next.completed_at=="string"&&e.next.completed_at.length>0},repairedAt:o}}function ye(e,o,t){let s=e.filter(p).map(r=>({...r}));for(const r of o){const n=g(r.epicId),l=Array.from(new Set(r.reasonCodes.map(E).filter(Boolean))).sort(),c=`state-aggregate-reconciliation:${n}`,a={id:c,status:"open",reason:"epic_aggregate_reconciled",reason_codes:l,category:"state/epic-aggregate-reconciliation",epic_id:n,created_at:t,last_seen_at:t,occurrences:1},m=s.findIndex(d=>d.id===c);if(m<0){s=[...s,a];continue}const i=s[m];s[m]={...i,...a,created_at:typeof i.created_at=="string"?i.created_at:t,occurrences:Math.max(1,typeof i.occurrences=="number"?i.occurrences:1)+1}}return s}function he(e,o,t){e.state_aggregate_reconciliations=[...Array.isArray(e.state_aggregate_reconciliations)?e.state_aggregate_reconciliations.filter(p):[],...o.map(s=>me(s,t))],e.state_repair_debt=ye(Array.isArray(e.state_repair_debt)?e.state_repair_debt:[],o,t)}function Se(e,o,t){const s=Array.from(new Set(o.map(E).filter(Boolean))).sort(),r=`state-drift-repair:${s.join("+")||"unknown"}`,n=e.filter(p).map(m=>({...m})),l={id:r,status:"open",reason:"state_json_drift_repaired",reason_codes:s,category:"state/drift-repair",created_at:t,last_seen_at:t,occurrences:1},c=n.findIndex(m=>m.id===r);if(c<0)return[...n,l];const a=n[c];return n[c]={...a,...l,created_at:typeof a.created_at=="string"?a.created_at:t,occurrences:Math.max(1,typeof a.occurrences=="number"?a.occurrences:1)+1},n}function E(e){return e.replace(/\b(sk|ghp|gho|github_pat|xoxb|AKIA)[A-Za-z0-9_-]{8,}\b/g,"[redacted]").replace(/(password|passwd|secret|token|api[_-]?key)\s*[:=]\s*[^,\s)]+/gi,"$1=[redacted]").replace(/https?:\/\/[^\s)]+/gi,"[url-redacted]").replace(/[^a-z0-9_+-]+/gi,"_").replace(/^_+|_+$/g,"").slice(0,120)}function g(e){return e.replace(/[^a-z0-9_.:-]+/gi,"_").replace(/^_+|_+$/g,"").slice(0,120)||"unknown"}function je(e,o={}){const t=N(e,".neocortex"),s=N(t,"state.json");if(!M(s))return{repaired:!1,reasonCodes:[],changes:[]};let r;try{r=JSON.parse(D(s,"utf8"))}catch(i){const d=i instanceof Error?i.message:String(i);throw new v(`[Neocortex] state.json repair stopped: invalid JSON in .neocortex/state.json (${d}). No files were overwritten. Fix the JSON or restore a backup, then rerun.`,"invalid_json")}if(!p(r))throw new v("[Neocortex] state.json repair stopped: top-level state must be a JSON object. Restore a valid .neocortex/state.json before invoking Neocortex.","state_not_object");const n=fe(r,o);if(!n.mutated)return{repaired:!1,reasonCodes:[],changes:[]};L(t,{recursive:!0});const l=B(),c=N(t,`state.json.backup-${l}`),a=N(t,`state.json.tmp.${J(6).toString("hex")}`);F(s,c),z(a,`${JSON.stringify(n.state,null,2)}
|
|
2
|
+
`,"utf8"),G(a,s);const m=`.neocortex/state.json.backup-${l}`;return process.stderr.write(`[Neocortex P156.05] state.json auto-repaired before invoke; backup=${m}; reasonCodes=${n.reasonCodes.join(",")}; changes=${n.changes.join("; ")}
|
|
3
|
+
`),{repaired:!0,reasonCodes:n.reasonCodes,backupPath:m,changes:n.changes}}export{f as EPIC_AGGREGATE_REASON_CODES,q as P189_STATE_SHAPE_GAP_CODE,v as StateRepairHardStopError,se as isP189DoneLikeStoryStatus,je as maybeRepairStateJsonBeforeInvoke,ce as reconcileEpicAggregatesInState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{OfflineTelemetryQueue as r}from"./offline-queue.js";export{r as OfflineTelemetryQueue};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license FSL-1.1
|
|
3
|
+
* Copyright (c) 2026 OrNexus AI
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Neocortex CLI, licensed under the
|
|
6
|
+
* Functional Source License, Version 1.1 (FSL-1.1).
|
|
7
|
+
*
|
|
8
|
+
* Change Date: February 20, 2029
|
|
9
|
+
* Change License: MIT
|
|
10
|
+
*
|
|
11
|
+
* See the LICENSE file in the project root for full license text.
|
|
12
|
+
*/
|
|
13
|
+
export interface TelemetryEvent {
|
|
14
|
+
type: string;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
data: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export interface QueueConfig {
|
|
19
|
+
/** Path to queue file. Default: ~/.neocortex/.telemetry-queue */
|
|
20
|
+
queueFilePath: string;
|
|
21
|
+
/** Maximum number of events in queue. Default: 1000 */
|
|
22
|
+
maxEvents: number;
|
|
23
|
+
/** Maximum queue file size in bytes. Default: 5_242_880 (5MB) */
|
|
24
|
+
maxSizeBytes: number;
|
|
25
|
+
}
|
|
26
|
+
export interface QueueStats {
|
|
27
|
+
count: number;
|
|
28
|
+
sizeBytes: number;
|
|
29
|
+
}
|
|
30
|
+
export interface FlushResult {
|
|
31
|
+
sent: number;
|
|
32
|
+
failed: number;
|
|
33
|
+
}
|
|
34
|
+
export declare class OfflineTelemetryQueue {
|
|
35
|
+
private readonly config;
|
|
36
|
+
constructor(config?: Partial<QueueConfig>);
|
|
37
|
+
/**
|
|
38
|
+
* Add a telemetry event to the queue.
|
|
39
|
+
* Evicts oldest events if limits are reached.
|
|
40
|
+
*/
|
|
41
|
+
enqueue(event: TelemetryEvent): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Flush all queued events using the provided send function.
|
|
44
|
+
* Returns count of sent and failed events.
|
|
45
|
+
*/
|
|
46
|
+
flush(sendFn: (events: TelemetryEvent[]) => Promise<boolean>): Promise<FlushResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Get queue statistics.
|
|
49
|
+
*/
|
|
50
|
+
getStats(): Promise<QueueStats>;
|
|
51
|
+
/**
|
|
52
|
+
* Clear all queued events.
|
|
53
|
+
*/
|
|
54
|
+
clear(): Promise<void>;
|
|
55
|
+
private loadQueue;
|
|
56
|
+
private saveQueue;
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFile as a,writeFile as n,mkdir as r}from"node:fs/promises";import{dirname as u}from"node:path";import{join as c}from"node:path";import{homedir as o}from"node:os";const h={queueFilePath:c(o(),".neocortex",".telemetry-queue"),maxEvents:1e3,maxSizeBytes:5242880};class d{config;constructor(t){this.config={...h,...t}}async enqueue(t){try{const e=await this.loadQueue();for(e.push(t);e.length>this.config.maxEvents;)e.shift();let i=JSON.stringify(e);for(;Buffer.byteLength(i,"utf8")>this.config.maxSizeBytes&&e.length>0;)e.shift(),i=JSON.stringify(e);await this.saveQueue(e)}catch{}}async flush(t){try{const e=await this.loadQueue();return e.length===0?{sent:0,failed:0}:await t(e)?(await this.saveQueue([]),{sent:e.length,failed:0}):{sent:0,failed:e.length}}catch{return{sent:0,failed:0}}}async getStats(){try{const t=await this.loadQueue(),e=JSON.stringify(t);return{count:t.length,sizeBytes:Buffer.byteLength(e,"utf8")}}catch{return{count:0,sizeBytes:0}}}async clear(){try{await this.saveQueue([])}catch{}}async loadQueue(){try{const t=await a(this.config.queueFilePath,"utf8"),e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}async saveQueue(t){const e=u(this.config.queueFilePath);await r(e,{recursive:!0});const i=`${this.config.queueFilePath}.tmp`;await n(i,JSON.stringify(t),"utf8");const{rename:s}=await import("node:fs/promises");await s(i,this.config.queueFilePath)}}export{d as OfflineTelemetryQueue};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{TierAwareClient as i}from"./tier-aware-client.js";export{i as TierAwareClient};
|
|
@@ -0,0 +1,105 @@
|
|
|
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 - TierAwareClient
|
|
15
|
+
*
|
|
16
|
+
* Client-side tier awareness: JWT tier extraction, cached tier,
|
|
17
|
+
* pre-flight trigger checks, quota caching from response metadata,
|
|
18
|
+
* and offline enforcement via cached quota data.
|
|
19
|
+
*
|
|
20
|
+
* Follows the same "NEVER throws" pattern as LicenseClient.
|
|
21
|
+
* Fail-open: if anything fails, default to 'free' tier / allow operation.
|
|
22
|
+
* No stdout output (preserve pipe compatibility) -- stderr only.
|
|
23
|
+
*
|
|
24
|
+
* Epic 60
|
|
25
|
+
*/
|
|
26
|
+
import type { CacheProvider } from '../types/index.js';
|
|
27
|
+
import type { LicenseClient } from '../license/license-client.js';
|
|
28
|
+
/** Subscription tier (inlined to avoid import path issues) */
|
|
29
|
+
export type SubscriptionTier = 'free' | 'pro' | 'enterprise';
|
|
30
|
+
/** Result of a pre-flight trigger check */
|
|
31
|
+
export interface PreFlightResult {
|
|
32
|
+
readonly allowed: boolean;
|
|
33
|
+
readonly message?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Cached quota data from server response metadata */
|
|
36
|
+
export interface QuotaSnapshot {
|
|
37
|
+
readonly stepsRemaining: number;
|
|
38
|
+
readonly invocationsRemaining: number;
|
|
39
|
+
readonly stepsLimit: number;
|
|
40
|
+
readonly invocationsLimit: number;
|
|
41
|
+
readonly cachedAt: number;
|
|
42
|
+
}
|
|
43
|
+
export interface ClientCommandRegistryEntry {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly number: number;
|
|
46
|
+
readonly aliases: readonly string[];
|
|
47
|
+
}
|
|
48
|
+
export declare const CLIENT_PREFLIGHT_COMMAND_REGISTRY: readonly ClientCommandRegistryEntry[];
|
|
49
|
+
export declare function normalizeCommandToken(input: string): string;
|
|
50
|
+
export declare function resolveClientPreFlightTrigger(input: string): string | null;
|
|
51
|
+
export interface TierAwareClientOptions {
|
|
52
|
+
readonly cacheProvider: CacheProvider;
|
|
53
|
+
readonly licenseClient: LicenseClient;
|
|
54
|
+
}
|
|
55
|
+
export declare class TierAwareClient {
|
|
56
|
+
private readonly cache;
|
|
57
|
+
private readonly licenseClient;
|
|
58
|
+
private cachedTier;
|
|
59
|
+
constructor(options: TierAwareClientOptions);
|
|
60
|
+
/**
|
|
61
|
+
* Get the current tier. Checks in-memory, then cache, then JWT token.
|
|
62
|
+
* NEVER throws - returns 'free' on failure (fail-open).
|
|
63
|
+
*/
|
|
64
|
+
getCachedTier(): Promise<SubscriptionTier>;
|
|
65
|
+
/**
|
|
66
|
+
* Update cached tier (called when server returns tier info).
|
|
67
|
+
*/
|
|
68
|
+
updateTier(tier: SubscriptionTier): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Invalidate all tier and quota caches.
|
|
71
|
+
* Called when a tier change is detected to ensure fresh data.
|
|
72
|
+
* NEVER throws.
|
|
73
|
+
*/
|
|
74
|
+
invalidateTierCache(): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Check if a trigger is allowed for the current tier WITHOUT calling the server.
|
|
77
|
+
* Returns immediately (in-memory lookup).
|
|
78
|
+
* NEVER throws - returns { allowed: true } on failure (fail-open).
|
|
79
|
+
*/
|
|
80
|
+
preFlightCheck(trigger: string, tier?: SubscriptionTier): Promise<PreFlightResult>;
|
|
81
|
+
/**
|
|
82
|
+
* Update cached quota from server response metadata.
|
|
83
|
+
* Called after each successful invoke.
|
|
84
|
+
*/
|
|
85
|
+
updateQuotaFromResponse(metadata: Record<string, unknown>): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Get cached quota for today.
|
|
88
|
+
* NEVER throws - returns null if cache empty or expired.
|
|
89
|
+
*/
|
|
90
|
+
getCachedQuota(): Promise<QuotaSnapshot | null>;
|
|
91
|
+
/**
|
|
92
|
+
* Check quota in offline mode using cached data.
|
|
93
|
+
* NEVER throws - returns { allowed: true } on failure (fail-open).
|
|
94
|
+
*
|
|
95
|
+
* @param isOffline - Whether the circuit breaker is in L2+ degradation
|
|
96
|
+
*/
|
|
97
|
+
offlineQuotaCheck(isOffline?: boolean): Promise<PreFlightResult>;
|
|
98
|
+
/**
|
|
99
|
+
* Extract tier from JWT payload via base64url decode.
|
|
100
|
+
* No cryptographic verification - client-side is UX only.
|
|
101
|
+
*/
|
|
102
|
+
private extractTierFromJwt;
|
|
103
|
+
private buildUpgradeMessage;
|
|
104
|
+
private getQuotaCacheKey;
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o="neocortex:tier",m="neocortex:quota:",T=3e5,w=36e5,l=new Set(["free","pro","enterprise"]),s="free",h={status:"free",init:"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"},u=[{id:"status",number:1,aliases:["st"]},{id:"init",number:2,aliases:["inicializar"]},{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"]}],f=new Map(u.map(r=>[r.id,r])),b=new Map(u.map(r=>[r.number,r])),g=new Map(u.flatMap(r=>r.aliases.map(a=>[p(a),r.id])));function p(r){return r.trim().toLowerCase().replace(/^\*/,"")}function y(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=p(e);return i?/^\d+$/.test(i)?b.get(Number.parseInt(i,10))?.id??null:f.has(i)?i:g.get(i)??null:null}const d={free:0,pro:1,enterprise:2};class C{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,this.cache.set(o,i,36e5).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,36e5).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=y(a)??a,c=h[t]??"free";return d[i]>=d[c]?{allowed:!0}:{allowed:!1,message:this.buildUpgradeMessage(t,i,c)}}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),3e5).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>3e5?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"),n=JSON.parse(t).tier;return n&&l.has(n)?n: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`${m}${e}`}}export{u as CLIENT_PREFLIGHT_COMMAND_REGISTRY,C as TierAwareClient,p as normalizeCommandToken,y as resolveClientPreFlightTrigger};
|
|
@@ -0,0 +1,140 @@
|
|
|
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
|
+
/** Mode of asset resolution */
|
|
19
|
+
export declare enum ResolverMode {
|
|
20
|
+
/** Read assets from local filesystem (development) */
|
|
21
|
+
LOCAL = "local",
|
|
22
|
+
/** Fetch assets from remote IP Protection Server (production) */
|
|
23
|
+
REMOTE = "remote"
|
|
24
|
+
}
|
|
25
|
+
/** Metadata about the codebase for context collection */
|
|
26
|
+
export interface CodebaseMetadata {
|
|
27
|
+
readonly projectName: string;
|
|
28
|
+
readonly languages: readonly string[];
|
|
29
|
+
readonly frameworks: readonly string[];
|
|
30
|
+
readonly dependencies: Readonly<Record<string, string>>;
|
|
31
|
+
readonly nodeVersion: string;
|
|
32
|
+
}
|
|
33
|
+
/** Metadata extracted from the story file */
|
|
34
|
+
export interface StoryMetadata {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly epicId: string;
|
|
37
|
+
readonly title: string;
|
|
38
|
+
readonly status: string;
|
|
39
|
+
readonly dependencies: readonly string[];
|
|
40
|
+
readonly acceptanceCriteria: readonly string[];
|
|
41
|
+
}
|
|
42
|
+
/** Full pipeline context sent to the server for prompt assembly */
|
|
43
|
+
export interface PipelineContext {
|
|
44
|
+
readonly storyId: string;
|
|
45
|
+
readonly stepId: string;
|
|
46
|
+
readonly epicId: string;
|
|
47
|
+
readonly storyTitle: string;
|
|
48
|
+
readonly currentStatus: string;
|
|
49
|
+
readonly stepsCompleted: readonly string[];
|
|
50
|
+
readonly branchName: string;
|
|
51
|
+
readonly platformTarget: string;
|
|
52
|
+
readonly codebaseMetadata: CodebaseMetadata;
|
|
53
|
+
readonly storyMetadata: StoryMetadata;
|
|
54
|
+
}
|
|
55
|
+
/** Content of a resolved pipeline step */
|
|
56
|
+
export interface StepContent {
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly content: string;
|
|
59
|
+
readonly frontmatter: Readonly<Record<string, unknown>>;
|
|
60
|
+
}
|
|
61
|
+
/** Content of a resolved skill */
|
|
62
|
+
export interface SkillContent {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly content: string;
|
|
65
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
66
|
+
}
|
|
67
|
+
/** Content of a resolved standard */
|
|
68
|
+
export interface StandardContent {
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly content: string;
|
|
71
|
+
}
|
|
72
|
+
/** Step registry entry matching core/data/step-registry.json structure */
|
|
73
|
+
export interface StepRegistryEntry {
|
|
74
|
+
readonly id: string;
|
|
75
|
+
readonly order?: number;
|
|
76
|
+
readonly name: string;
|
|
77
|
+
readonly status_after?: string;
|
|
78
|
+
readonly file: string;
|
|
79
|
+
readonly auto_continue?: boolean;
|
|
80
|
+
readonly requires_git?: boolean;
|
|
81
|
+
readonly standalone?: boolean;
|
|
82
|
+
readonly terminal?: boolean;
|
|
83
|
+
readonly returns_to?: string;
|
|
84
|
+
readonly returns_to_status?: string;
|
|
85
|
+
}
|
|
86
|
+
/** Full step registry structure */
|
|
87
|
+
export interface StepRegistry {
|
|
88
|
+
readonly version: string;
|
|
89
|
+
readonly steps: {
|
|
90
|
+
readonly core: readonly StepRegistryEntry[];
|
|
91
|
+
readonly recovery: readonly StepRegistryEntry[];
|
|
92
|
+
readonly utility: readonly StepRegistryEntry[];
|
|
93
|
+
readonly planning: readonly StepRegistryEntry[];
|
|
94
|
+
readonly epic: readonly StepRegistryEntry[];
|
|
95
|
+
};
|
|
96
|
+
readonly [key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
/** Assembled prompt ready for execution */
|
|
99
|
+
export interface AssembledPrompt {
|
|
100
|
+
readonly prompt: string;
|
|
101
|
+
readonly variables: Readonly<Record<string, string>>;
|
|
102
|
+
readonly includedSkills: readonly string[];
|
|
103
|
+
readonly includedStandards: readonly string[];
|
|
104
|
+
}
|
|
105
|
+
/** Interface for encrypted cache (implemented in Story 42.3) */
|
|
106
|
+
export interface CacheProvider {
|
|
107
|
+
get(key: string): Promise<string | null>;
|
|
108
|
+
set(key: string, value: string, ttlMs?: number): Promise<void>;
|
|
109
|
+
clear(): Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
/** No-op cache implementation for development/fallback */
|
|
112
|
+
export declare class NoOpCache implements CacheProvider {
|
|
113
|
+
get(): Promise<null>;
|
|
114
|
+
set(): Promise<void>;
|
|
115
|
+
clear(): Promise<void>;
|
|
116
|
+
}
|
|
117
|
+
/** Options for LocalResolver */
|
|
118
|
+
export interface LocalResolverOptions {
|
|
119
|
+
readonly projectRoot: string;
|
|
120
|
+
}
|
|
121
|
+
/** Options for RemoteResolver */
|
|
122
|
+
export interface RemoteResolverOptions {
|
|
123
|
+
readonly serverUrl: string;
|
|
124
|
+
readonly licenseKey: string;
|
|
125
|
+
readonly timeout?: number;
|
|
126
|
+
readonly retryCount?: number;
|
|
127
|
+
readonly cacheProvider?: CacheProvider;
|
|
128
|
+
readonly licenseClient?: import('../license/license-client.js').LicenseClient;
|
|
129
|
+
}
|
|
130
|
+
/** Options for resolver factory */
|
|
131
|
+
export interface CreateResolverOptions {
|
|
132
|
+
readonly forceLocal?: boolean;
|
|
133
|
+
/** Force offline mode: skip server, use cache exclusively (Story 42.9 - AC6) */
|
|
134
|
+
readonly forceOffline?: boolean;
|
|
135
|
+
readonly projectRoot?: string;
|
|
136
|
+
readonly serverUrl?: string;
|
|
137
|
+
readonly licenseKey?: string;
|
|
138
|
+
readonly cacheProvider?: CacheProvider;
|
|
139
|
+
readonly licenseClient?: import('../license/license-client.js').LicenseClient;
|
|
140
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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};
|