@planu/cli 6.1.0 → 7.1.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.
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -112
- package/dist/sdd-engine/contracts.d.ts +76 -0
- package/dist/sdd-engine/contracts.js +60 -0
- package/dist/sdd-engine/index.d.ts +5 -0
- package/dist/sdd-engine/index.js +5 -0
- package/dist/sdd-engine/patch-sandbox.d.ts +14 -0
- package/dist/sdd-engine/patch-sandbox.js +173 -0
- package/dist/sdd-engine/server.d.ts +5 -0
- package/dist/sdd-engine/server.js +30 -0
- package/dist/sdd-engine/task-window.d.ts +9 -0
- package/dist/sdd-engine/task-window.js +153 -0
- package/dist/sdd-engine/tools/execution-tools.d.ts +5 -0
- package/dist/sdd-engine/tools/execution-tools.js +138 -0
- package/dist/sdd-engine/tools/format-result.d.ts +4 -0
- package/dist/sdd-engine/tools/format-result.js +22 -0
- package/dist/sdd-engine/tools/workspace-tools.d.ts +3 -0
- package/dist/sdd-engine/tools/workspace-tools.js +193 -0
- package/dist/sdd-engine/tools.d.ts +3 -0
- package/dist/sdd-engine/tools.js +13 -0
- package/dist/types/sdd-engine.d.ts +91 -0
- package/dist/types/sdd-engine.js +2 -0
- package/package.json +2 -2
- package/dist/.planu-build.json +0 -1
- package/dist/cli/colors.d.ts +0 -14
- package/dist/cli/colors.js +0 -26
- package/dist/cli/commands/doctor.d.ts +0 -12
- package/dist/cli/commands/doctor.js +0 -91
- package/dist/cli/commands/init.d.ts +0 -3
- package/dist/cli/commands/init.js +0 -37
- package/dist/cli/commands/job.d.ts +0 -3
- package/dist/cli/commands/job.js +0 -112
- package/dist/cli/commands/list.d.ts +0 -3
- package/dist/cli/commands/list.js +0 -39
- package/dist/cli/commands/package-handoff.d.ts +0 -3
- package/dist/cli/commands/package-handoff.js +0 -75
- package/dist/cli/commands/spec.d.ts +0 -3
- package/dist/cli/commands/spec.js +0 -156
- package/dist/cli/commands/status.d.ts +0 -3
- package/dist/cli/commands/status.js +0 -113
- package/dist/cli/commands/validate.d.ts +0 -3
- package/dist/cli/commands/validate.js +0 -39
- package/dist/cli/formatter.d.ts +0 -26
- package/dist/cli/formatter.js +0 -126
- package/dist/cli/index.d.ts +0 -3
- package/dist/cli/index.js +0 -29
- package/dist/cli/project-detector.d.ts +0 -6
- package/dist/cli/project-detector.js +0 -12
- package/dist/cli/router.d.ts +0 -6
- package/dist/cli/router.js +0 -142
- package/dist/config/architecture-patterns.json +0 -324
- package/dist/config/detection-signals.json +0 -256
- package/dist/config/docs-registry.json +0 -94
- package/dist/config/dor-dod-items.json +0 -194
- package/dist/config/drift-severity.json +0 -22
- package/dist/config/event-brokers.json +0 -63
- package/dist/config/framework-registry/csharp-aspnet.json +0 -67
- package/dist/config/framework-registry/dart-flutter.json +0 -61
- package/dist/config/framework-registry/go-gin.json +0 -62
- package/dist/config/framework-registry/index.json +0 -164
- package/dist/config/framework-registry/java-springboot.json +0 -67
- package/dist/config/framework-registry/php-laravel.json +0 -67
- package/dist/config/framework-registry/python-django.json +0 -72
- package/dist/config/framework-registry/python-fastapi.json +0 -72
- package/dist/config/framework-registry/ruby-rails.json +0 -67
- package/dist/config/framework-registry/rust-actix.json +0 -61
- package/dist/config/framework-registry/swift-swiftui.json +0 -67
- package/dist/config/framework-registry/typescript-angular.json +0 -67
- package/dist/config/framework-registry/typescript-astro.json +0 -61
- package/dist/config/framework-registry/typescript-express.json +0 -67
- package/dist/config/framework-registry/typescript-nestjs.json +0 -62
- package/dist/config/framework-registry/typescript-nextjs.json +0 -82
- package/dist/config/framework-registry/typescript-nuxt.json +0 -67
- package/dist/config/framework-registry/typescript-react.json +0 -77
- package/dist/config/framework-registry/typescript-remix.json +0 -61
- package/dist/config/framework-registry/typescript-sveltekit.json +0 -67
- package/dist/config/framework-registry/typescript-vue.json +0 -72
- package/dist/config/hook-templates/planu-force-ask-user-question.sh +0 -14
- package/dist/config/hook-templates/planu-spec-sanctity.sh +0 -128
- package/dist/config/legacy-artifacts.json +0 -26
- package/dist/config/minimal-implementation-gate.json +0 -149
- package/dist/config/negative-predicate-phrases.json +0 -33
- package/dist/config/official-sdd-tools.d.ts +0 -7
- package/dist/config/official-sdd-tools.js +0 -44
- package/dist/config/out-of-scope-suggestions.json +0 -190
- package/dist/config/paradigm-registry.json +0 -380
- package/dist/config/project-knowledge-graph.json +0 -170
- package/dist/config/readiness-config.json +0 -22
- package/dist/config/registries/error-recovery.json +0 -114
- package/dist/config/registries/legacy-guidance.json +0 -118
- package/dist/config/registries/spec-folder-sanctity.json +0 -4
- package/dist/config/runtime-policy.json +0 -66
- package/dist/config/server-instructions.d.ts +0 -2
- package/dist/config/server-instructions.js +0 -18
- package/dist/config/skill-templates/planu-dogfood-bug.md +0 -43
- package/dist/config/skill-templates/planu-implement.md +0 -42
- package/dist/config/skill-templates/planu-native.md +0 -30
- package/dist/config/skill-templates/planu-new-spec.md +0 -56
- package/dist/config/skill-templates/planu-resume-work.md +0 -51
- package/dist/config/skill-templates/planu-review.md +0 -47
- package/dist/config/skill-templates/planu-validate.md +0 -59
- package/dist/config/stack-signatures.json +0 -793
- package/dist/config/subagent-templates/planu-challenger.md +0 -49
- package/dist/config/subagent-templates/planu-readiness-auditor.md +0 -51
- package/dist/config/subagent-templates/planu-spec-implementer.md +0 -50
- package/dist/config/subagent-templates/planu-validator.md +0 -56
- package/dist/config/technology-registry.json +0 -120
- package/dist/config/version.d.ts +0 -2
- package/dist/config/version.js +0 -20
- package/dist/core/shared/fs.d.ts +0 -10
- package/dist/core/shared/fs.js +0 -89
- package/dist/core/shared/object.d.ts +0 -3
- package/dist/core/shared/object.js +0 -12
- package/dist/core/shared/strings.d.ts +0 -3
- package/dist/core/shared/strings.js +0 -13
- package/dist/core/spec-validator.d.ts +0 -12
- package/dist/core/spec-validator.js +0 -250
- package/dist/engine/abortable-process-runner.d.ts +0 -26
- package/dist/engine/abortable-process-runner.js +0 -308
- package/dist/engine/ai-assurance/index.d.ts +0 -4
- package/dist/engine/ai-assurance/index.js +0 -3
- package/dist/engine/ai-assurance/new-code-gate.d.ts +0 -3
- package/dist/engine/ai-assurance/new-code-gate.js +0 -39
- package/dist/engine/ai-assurance/spec-assurance.d.ts +0 -3
- package/dist/engine/ai-assurance/spec-assurance.js +0 -138
- package/dist/engine/ai-integration/codex/agent-roles-generator.d.ts +0 -12
- package/dist/engine/ai-integration/codex/agent-roles-generator.js +0 -62
- package/dist/engine/ambiguity-scorer.d.ts +0 -13
- package/dist/engine/ambiguity-scorer.js +0 -155
- package/dist/engine/approval-workflow.d.ts +0 -21
- package/dist/engine/approval-workflow.js +0 -82
- package/dist/engine/audit-trail/hasher.d.ts +0 -18
- package/dist/engine/audit-trail/hasher.js +0 -46
- package/dist/engine/auditor-scoring.d.ts +0 -7
- package/dist/engine/auditor-scoring.js +0 -76
- package/dist/engine/build-freshness.d.ts +0 -4
- package/dist/engine/build-freshness.js +0 -170
- package/dist/engine/challenge-prioritizer.d.ts +0 -17
- package/dist/engine/challenge-prioritizer.js +0 -78
- package/dist/engine/clarification-gate/error-builder.d.ts +0 -12
- package/dist/engine/clarification-gate/error-builder.js +0 -33
- package/dist/engine/clarification-gate/gate.d.ts +0 -15
- package/dist/engine/clarification-gate/gate.js +0 -41
- package/dist/engine/clarification-gate/token-store.d.ts +0 -28
- package/dist/engine/clarification-gate/token-store.js +0 -67
- package/dist/engine/coach/i18n.d.ts +0 -11
- package/dist/engine/coach/i18n.js +0 -78
- package/dist/engine/code-scanner/gap-scorer.d.ts +0 -9
- package/dist/engine/code-scanner/gap-scorer.js +0 -89
- package/dist/engine/code-scanner/index.d.ts +0 -9
- package/dist/engine/code-scanner/index.js +0 -15
- package/dist/engine/code-scanner/keyword-extractor.d.ts +0 -11
- package/dist/engine/code-scanner/keyword-extractor.js +0 -88
- package/dist/engine/code-scanner/layer-scanner.d.ts +0 -24
- package/dist/engine/code-scanner/layer-scanner.js +0 -135
- package/dist/engine/compact/tool-list-compactor.d.ts +0 -7
- package/dist/engine/compact/tool-list-compactor.js +0 -87
- package/dist/engine/compact-obj.d.ts +0 -7
- package/dist/engine/compact-obj.js +0 -28
- package/dist/engine/complexity-budget/index.d.ts +0 -2
- package/dist/engine/complexity-budget/index.js +0 -3
- package/dist/engine/complexity-budget/trivial-detector.d.ts +0 -7
- package/dist/engine/complexity-budget/trivial-detector.js +0 -69
- package/dist/engine/config-loader.d.ts +0 -73
- package/dist/engine/config-loader.js +0 -239
- package/dist/engine/constitution/sdd-rules-registry.d.ts +0 -11
- package/dist/engine/constitution/sdd-rules-registry.js +0 -109
- package/dist/engine/context-merger.d.ts +0 -23
- package/dist/engine/context-merger.js +0 -197
- package/dist/engine/contradiction-detector.d.ts +0 -16
- package/dist/engine/contradiction-detector.js +0 -406
- package/dist/engine/convention-scanner/codebase-scanner.d.ts +0 -7
- package/dist/engine/convention-scanner/codebase-scanner.js +0 -390
- package/dist/engine/convention-scanner/convention-parser.d.ts +0 -7
- package/dist/engine/convention-scanner/convention-parser.js +0 -189
- package/dist/engine/convention-scanner/index.d.ts +0 -3
- package/dist/engine/convention-scanner/index.js +0 -5
- package/dist/engine/conventions-ttl.d.ts +0 -8
- package/dist/engine/conventions-ttl.js +0 -75
- package/dist/engine/core-bridge-duplicate-blocks.d.ts +0 -3
- package/dist/engine/core-bridge-duplicate-blocks.js +0 -56
- package/dist/engine/core-bridge-gaps.d.ts +0 -4
- package/dist/engine/core-bridge-gaps.js +0 -75
- package/dist/engine/core-bridge-project-graph.d.ts +0 -9
- package/dist/engine/core-bridge-project-graph.js +0 -499
- package/dist/engine/core-bridge.d.ts +0 -34
- package/dist/engine/core-bridge.js +0 -392
- package/dist/engine/criteria-quality-checker.d.ts +0 -8
- package/dist/engine/criteria-quality-checker.js +0 -55
- package/dist/engine/criterion-identity.d.ts +0 -7
- package/dist/engine/criterion-identity.js +0 -70
- package/dist/engine/data-projects-gc/pattern-matcher.d.ts +0 -21
- package/dist/engine/data-projects-gc/pattern-matcher.js +0 -68
- package/dist/engine/dep-guard/cycle-detector.d.ts +0 -29
- package/dist/engine/dep-guard/cycle-detector.js +0 -83
- package/dist/engine/dep-guard/index.d.ts +0 -3
- package/dist/engine/dep-guard/index.js +0 -3
- package/dist/engine/dependency-evaluator.d.ts +0 -15
- package/dist/engine/dependency-evaluator.js +0 -81
- package/dist/engine/detection-utils.d.ts +0 -13
- package/dist/engine/detection-utils.js +0 -255
- package/dist/engine/dor-dod/dod.d.ts +0 -17
- package/dist/engine/dor-dod/dod.js +0 -98
- package/dist/engine/dor-dod/dor.d.ts +0 -21
- package/dist/engine/dor-dod/dor.js +0 -149
- package/dist/engine/dor-dod/index.d.ts +0 -4
- package/dist/engine/dor-dod/index.js +0 -5
- package/dist/engine/dor-dod/items-loader.d.ts +0 -18
- package/dist/engine/dor-dod/items-loader.js +0 -55
- package/dist/engine/dor-dod/plan.d.ts +0 -8
- package/dist/engine/dor-dod/plan.js +0 -50
- package/dist/engine/dor-dod.d.ts +0 -2
- package/dist/engine/dor-dod.js +0 -4
- package/dist/engine/ears-gate.d.ts +0 -19
- package/dist/engine/ears-gate.js +0 -120
- package/dist/engine/elicitation/answer-extractor.d.ts +0 -4
- package/dist/engine/elicitation/answer-extractor.js +0 -225
- package/dist/engine/elicitation/capability.d.ts +0 -9
- package/dist/engine/elicitation/capability.js +0 -48
- package/dist/engine/elicitation/decision-gap-detector.d.ts +0 -3
- package/dist/engine/elicitation/decision-gap-detector.js +0 -142
- package/dist/engine/elicitation/elicit-helper.d.ts +0 -36
- package/dist/engine/elicitation/elicit-helper.js +0 -113
- package/dist/engine/elicitation/question-grounding-gate.d.ts +0 -3
- package/dist/engine/elicitation/question-grounding-gate.js +0 -103
- package/dist/engine/errors/error-result.d.ts +0 -4
- package/dist/engine/errors/error-result.js +0 -16
- package/dist/engine/errors/error-wrapper.d.ts +0 -4
- package/dist/engine/errors/error-wrapper.js +0 -82
- package/dist/engine/errors/recovery-registry.d.ts +0 -13
- package/dist/engine/errors/recovery-registry.js +0 -96
- package/dist/engine/errors/registry-loader.d.ts +0 -3
- package/dist/engine/errors/registry-loader.js +0 -22
- package/dist/engine/event-detector.d.ts +0 -33
- package/dist/engine/event-detector.js +0 -97
- package/dist/engine/evidence-gates/artifact-reader.d.ts +0 -133
- package/dist/engine/evidence-gates/artifact-reader.js +0 -387
- package/dist/engine/evidence-gates/evidence-autofill.d.ts +0 -15
- package/dist/engine/evidence-gates/evidence-autofill.js +0 -255
- package/dist/engine/evidence-gates/evidence-skeletons.d.ts +0 -19
- package/dist/engine/evidence-gates/evidence-skeletons.js +0 -78
- package/dist/engine/evidence-gates/lifecycle-gate.d.ts +0 -12
- package/dist/engine/evidence-gates/lifecycle-gate.js +0 -293
- package/dist/engine/evidence-gates/reconciliation-freshness.d.ts +0 -11
- package/dist/engine/evidence-gates/reconciliation-freshness.js +0 -73
- package/dist/engine/evidence-index/done-drift.d.ts +0 -7
- package/dist/engine/evidence-index/done-drift.js +0 -91
- package/dist/engine/evidence-index/index-builder.d.ts +0 -10
- package/dist/engine/evidence-index/index-builder.js +0 -202
- package/dist/engine/execution/context.d.ts +0 -19
- package/dist/engine/execution/context.js +0 -130
- package/dist/engine/execution/deadline-io.d.ts +0 -20
- package/dist/engine/execution/deadline-io.js +0 -30
- package/dist/engine/execution/durable-job-heartbeat-runtime.d.ts +0 -4
- package/dist/engine/execution/durable-job-heartbeat-runtime.js +0 -401
- package/dist/engine/execution/job-runtime.d.ts +0 -101
- package/dist/engine/execution/job-runtime.js +0 -319
- package/dist/engine/execution/operation-journal.d.ts +0 -67
- package/dist/engine/execution/operation-journal.js +0 -266
- package/dist/engine/execution/package-handoff-job-executor.d.ts +0 -22
- package/dist/engine/execution/package-handoff-job-executor.js +0 -510
- package/dist/engine/execution/public-job-sanitizer.d.ts +0 -4
- package/dist/engine/execution/public-job-sanitizer.js +0 -31
- package/dist/engine/execution/startup-recovery.d.ts +0 -3
- package/dist/engine/execution/startup-recovery.js +0 -15
- package/dist/engine/execution/validate-job-executor.d.ts +0 -37
- package/dist/engine/execution/validate-job-executor.js +0 -900
- package/dist/engine/execution/validate-job-payload.d.ts +0 -5
- package/dist/engine/execution/validate-job-payload.js +0 -145
- package/dist/engine/execution/validate-job-recovery.d.ts +0 -4
- package/dist/engine/execution/validate-job-recovery.js +0 -47
- package/dist/engine/execution/validate-worker-runtime.d.ts +0 -10
- package/dist/engine/execution/validate-worker-runtime.js +0 -188
- package/dist/engine/execution/validate-worker-thread.d.ts +0 -2
- package/dist/engine/execution/validate-worker-thread.js +0 -65
- package/dist/engine/framework-detector.d.ts +0 -35
- package/dist/engine/framework-detector.js +0 -268
- package/dist/engine/freeze/freeze-checker.d.ts +0 -14
- package/dist/engine/freeze/freeze-checker.js +0 -28
- package/dist/engine/freeze/unlock-token.d.ts +0 -17
- package/dist/engine/freeze/unlock-token.js +0 -30
- package/dist/engine/frontmatter-parser.d.ts +0 -32
- package/dist/engine/frontmatter-parser.js +0 -157
- package/dist/engine/frontmatter-sha/canonicalize.d.ts +0 -9
- package/dist/engine/frontmatter-sha/canonicalize.js +0 -20
- package/dist/engine/frontmatter-sha/compute-sha.d.ts +0 -8
- package/dist/engine/frontmatter-sha/compute-sha.js +0 -14
- package/dist/engine/frontmatter-sha/frozen-fields.d.ts +0 -6
- package/dist/engine/frontmatter-sha/frozen-fields.js +0 -14
- package/dist/engine/frontmatter-sha/index.d.ts +0 -2
- package/dist/engine/frontmatter-sha/index.js +0 -3
- package/dist/engine/git/branch-detector.d.ts +0 -7
- package/dist/engine/git/branch-detector.js +0 -45
- package/dist/engine/git/exec-git.d.ts +0 -2
- package/dist/engine/git/exec-git.js +0 -14
- package/dist/engine/git/git-command-guard.d.ts +0 -2
- package/dist/engine/git/git-command-guard.js +0 -43
- package/dist/engine/git/repository-probe.d.ts +0 -3
- package/dist/engine/git/repository-probe.js +0 -13
- package/dist/engine/handoff-artifacts/implementation-review-reader.d.ts +0 -4
- package/dist/engine/handoff-artifacts/implementation-review-reader.js +0 -86
- package/dist/engine/handoff-artifacts/io.d.ts +0 -51
- package/dist/engine/handoff-artifacts/io.js +0 -200
- package/dist/engine/handoff-artifacts/schema-skeleton.d.ts +0 -5
- package/dist/engine/handoff-artifacts/schema-skeleton.js +0 -108
- package/dist/engine/handoff-artifacts/schemas.d.ts +0 -164
- package/dist/engine/handoff-artifacts/schemas.js +0 -242
- package/dist/engine/handoff-artifacts/validation-result.d.ts +0 -18
- package/dist/engine/handoff-artifacts/validation-result.js +0 -3
- package/dist/engine/handoff-artifacts/version-policy.d.ts +0 -18
- package/dist/engine/handoff-artifacts/version-policy.js +0 -35
- package/dist/engine/handoff-format.d.ts +0 -26
- package/dist/engine/handoff-format.js +0 -253
- package/dist/engine/handoff-packager.d.ts +0 -30
- package/dist/engine/handoff-packager.js +0 -864
- package/dist/engine/host-detection/detect-host.d.ts +0 -10
- package/dist/engine/host-detection/detect-host.js +0 -34
- package/dist/engine/host-rules-templates/index.d.ts +0 -3
- package/dist/engine/host-rules-templates/index.js +0 -4
- package/dist/engine/host-rules-templates/inject-rules-block.d.ts +0 -3
- package/dist/engine/host-rules-templates/inject-rules-block.js +0 -29
- package/dist/engine/host-rules-templates/templates.d.ts +0 -12
- package/dist/engine/host-rules-templates/templates.js +0 -111
- package/dist/engine/host-tool-filter.d.ts +0 -28
- package/dist/engine/host-tool-filter.js +0 -162
- package/dist/engine/human-summary.d.ts +0 -18
- package/dist/engine/human-summary.js +0 -114
- package/dist/engine/implementation-contract/common.d.ts +0 -22
- package/dist/engine/implementation-contract/common.js +0 -47
- package/dist/engine/implementation-contract/evaluator.d.ts +0 -3
- package/dist/engine/implementation-contract/evaluator.js +0 -192
- package/dist/engine/implementation-contract/index.d.ts +0 -4
- package/dist/engine/implementation-contract/index.js +0 -4
- package/dist/engine/implementation-contract/renderer.d.ts +0 -4
- package/dist/engine/implementation-contract/renderer.js +0 -114
- package/dist/engine/keyword-matcher/boundary.d.ts +0 -18
- package/dist/engine/keyword-matcher/boundary.js +0 -30
- package/dist/engine/keyword-matcher/extractor.d.ts +0 -14
- package/dist/engine/keyword-matcher/extractor.js +0 -85
- package/dist/engine/keyword-matcher/index.d.ts +0 -5
- package/dist/engine/keyword-matcher/index.js +0 -11
- package/dist/engine/keyword-matcher/matcher.d.ts +0 -28
- package/dist/engine/keyword-matcher/matcher.js +0 -79
- package/dist/engine/keyword-matcher/stopwords.d.ts +0 -26
- package/dist/engine/keyword-matcher/stopwords.js +0 -100
- package/dist/engine/lifecycle-hints.d.ts +0 -12
- package/dist/engine/lifecycle-hints.js +0 -61
- package/dist/engine/lifecycle-reconciliation-io.d.ts +0 -11
- package/dist/engine/lifecycle-reconciliation-io.js +0 -181
- package/dist/engine/lifecycle-reconciliation.d.ts +0 -16
- package/dist/engine/lifecycle-reconciliation.js +0 -460
- package/dist/engine/living-spec-analyzer.d.ts +0 -10
- package/dist/engine/living-spec-analyzer.js +0 -397
- package/dist/engine/minimality/analyzer.d.ts +0 -3
- package/dist/engine/minimality/analyzer.js +0 -182
- package/dist/engine/minimality/formatter.d.ts +0 -3
- package/dist/engine/minimality/formatter.js +0 -25
- package/dist/engine/minimality/index.d.ts +0 -3
- package/dist/engine/minimality/index.js +0 -3
- package/dist/engine/minimality/policy-loader.d.ts +0 -3
- package/dist/engine/minimality/policy-loader.js +0 -364
- package/dist/engine/model-tier-resolver.d.ts +0 -4
- package/dist/engine/model-tier-resolver.js +0 -15
- package/dist/engine/network-policy.d.ts +0 -4
- package/dist/engine/network-policy.js +0 -96
- package/dist/engine/onboarding/new-project-resolver.d.ts +0 -6
- package/dist/engine/onboarding/new-project-resolver.js +0 -265
- package/dist/engine/opencode/config-scaffold.d.ts +0 -3
- package/dist/engine/opencode/config-scaffold.js +0 -99
- package/dist/engine/paradigm-detector.d.ts +0 -12
- package/dist/engine/paradigm-detector.js +0 -236
- package/dist/engine/paradigm-registry.d.ts +0 -20
- package/dist/engine/paradigm-registry.js +0 -44
- package/dist/engine/phase-tracker.d.ts +0 -41
- package/dist/engine/phase-tracker.js +0 -89
- package/dist/engine/planu-config-writer.d.ts +0 -33
- package/dist/engine/planu-config-writer.js +0 -68
- package/dist/engine/project-command-runtime.d.ts +0 -5
- package/dist/engine/project-command-runtime.js +0 -87
- package/dist/engine/project-graph/builder.d.ts +0 -7
- package/dist/engine/project-graph/builder.js +0 -320
- package/dist/engine/project-graph/cache.d.ts +0 -47
- package/dist/engine/project-graph/cache.js +0 -739
- package/dist/engine/project-graph/extractors/decision-store-extractor.d.ts +0 -3
- package/dist/engine/project-graph/extractors/decision-store-extractor.js +0 -58
- package/dist/engine/project-graph/extractors/git-extractor.d.ts +0 -7
- package/dist/engine/project-graph/extractors/git-extractor.js +0 -89
- package/dist/engine/project-graph/extractors/handoff-extractor.d.ts +0 -3
- package/dist/engine/project-graph/extractors/handoff-extractor.js +0 -55
- package/dist/engine/project-graph/extractors/spec-extractor.d.ts +0 -3
- package/dist/engine/project-graph/extractors/spec-extractor.js +0 -189
- package/dist/engine/project-graph/extractors/validation-extractor.d.ts +0 -3
- package/dist/engine/project-graph/extractors/validation-extractor.js +0 -36
- package/dist/engine/project-graph/freshness-projection.d.ts +0 -16
- package/dist/engine/project-graph/freshness-projection.js +0 -98
- package/dist/engine/project-graph/index.d.ts +0 -2
- package/dist/engine/project-graph/index.js +0 -2
- package/dist/engine/project-graph/native.d.ts +0 -3
- package/dist/engine/project-graph/native.js +0 -36
- package/dist/engine/project-graph/query.d.ts +0 -8
- package/dist/engine/project-graph/query.js +0 -193
- package/dist/engine/project-graph/redaction.d.ts +0 -4
- package/dist/engine/project-graph/redaction.js +0 -11
- package/dist/engine/project-scanner/convention-detector.d.ts +0 -3
- package/dist/engine/project-scanner/convention-detector.js +0 -149
- package/dist/engine/project-scanner/index.d.ts +0 -4
- package/dist/engine/project-scanner/index.js +0 -18
- package/dist/engine/project-scanner/quality-baseline.d.ts +0 -3
- package/dist/engine/project-scanner/quality-baseline.js +0 -72
- package/dist/engine/project-scanner/stack-detector.d.ts +0 -3
- package/dist/engine/project-scanner/stack-detector.js +0 -128
- package/dist/engine/readiness-checker.d.ts +0 -56
- package/dist/engine/readiness-checker.js +0 -566
- package/dist/engine/readiness-config-loader.d.ts +0 -23
- package/dist/engine/readiness-config-loader.js +0 -63
- package/dist/engine/reconcile/apply-changes.d.ts +0 -4
- package/dist/engine/reconcile/apply-changes.js +0 -117
- package/dist/engine/reconcile/propagate-mirrors.d.ts +0 -3
- package/dist/engine/reconcile/propagate-mirrors.js +0 -376
- package/dist/engine/reconcile/verify-write.d.ts +0 -10
- package/dist/engine/reconcile/verify-write.js +0 -49
- package/dist/engine/registry-extender.d.ts +0 -25
- package/dist/engine/registry-extender.js +0 -60
- package/dist/engine/reviewer-tokens/issuer.d.ts +0 -29
- package/dist/engine/reviewer-tokens/issuer.js +0 -88
- package/dist/engine/reviewer-tokens/signer.d.ts +0 -17
- package/dist/engine/reviewer-tokens/signer.js +0 -51
- package/dist/engine/reviewer-tokens/types.d.ts +0 -2
- package/dist/engine/reviewer-tokens/types.js +0 -2
- package/dist/engine/runtime-policy.d.ts +0 -9
- package/dist/engine/runtime-policy.js +0 -163
- package/dist/engine/safety/atomic-write-file.d.ts +0 -47
- package/dist/engine/safety/atomic-write-file.js +0 -232
- package/dist/engine/safety/atomic-writer.d.ts +0 -22
- package/dist/engine/safety/atomic-writer.js +0 -97
- package/dist/engine/safety/contained-project-file.d.ts +0 -3
- package/dist/engine/safety/contained-project-file.js +0 -23
- package/dist/engine/safety/cross-process-lock.d.ts +0 -13
- package/dist/engine/safety/cross-process-lock.js +0 -318
- package/dist/engine/safety/file-mutex.d.ts +0 -6
- package/dist/engine/safety/file-mutex.js +0 -182
- package/dist/engine/safety/lock-lease-store.d.ts +0 -84
- package/dist/engine/safety/lock-lease-store.js +0 -383
- package/dist/engine/safety/lock-scavenger.d.ts +0 -8
- package/dist/engine/safety/lock-scavenger.js +0 -198
- package/dist/engine/safety/lock-staleness.d.ts +0 -33
- package/dist/engine/safety/lock-staleness.js +0 -76
- package/dist/engine/safety/obsolete-lock-guard.d.ts +0 -8
- package/dist/engine/safety/obsolete-lock-guard.js +0 -31
- package/dist/engine/scope-boundaries/contradiction-checker.d.ts +0 -7
- package/dist/engine/scope-boundaries/contradiction-checker.js +0 -276
- package/dist/engine/scope-boundaries/index.d.ts +0 -4
- package/dist/engine/scope-boundaries/index.js +0 -5
- package/dist/engine/scope-boundaries/scope-validator.d.ts +0 -7
- package/dist/engine/scope-boundaries/scope-validator.js +0 -114
- package/dist/engine/scope-boundaries/suggester.d.ts +0 -8
- package/dist/engine/scope-boundaries/suggester.js +0 -27
- package/dist/engine/score-to-grade.d.ts +0 -2
- package/dist/engine/score-to-grade.js +0 -16
- package/dist/engine/sdd-model-routing.d.ts +0 -15
- package/dist/engine/sdd-model-routing.js +0 -200
- package/dist/engine/spec-dependency-graph.d.ts +0 -33
- package/dist/engine/spec-dependency-graph.js +0 -243
- package/dist/engine/spec-difficulty.d.ts +0 -3
- package/dist/engine/spec-difficulty.js +0 -17
- package/dist/engine/spec-folder-sanctity.d.ts +0 -5
- package/dist/engine/spec-folder-sanctity.js +0 -32
- package/dist/engine/spec-format/acceptance-criteria.d.ts +0 -10
- package/dist/engine/spec-format/acceptance-criteria.js +0 -157
- package/dist/engine/spec-format/bdd-parser.d.ts +0 -19
- package/dist/engine/spec-format/bdd-parser.js +0 -224
- package/dist/engine/spec-format/copula-blacklist.d.ts +0 -15
- package/dist/engine/spec-format/copula-blacklist.js +0 -31
- package/dist/engine/spec-format/criteria-drift.d.ts +0 -3
- package/dist/engine/spec-format/criteria-drift.js +0 -36
- package/dist/engine/spec-format/executable-test-path.d.ts +0 -2
- package/dist/engine/spec-format/executable-test-path.js +0 -5
- package/dist/engine/spec-format/lean-spec-generator.d.ts +0 -8
- package/dist/engine/spec-format/lean-spec-generator.js +0 -236
- package/dist/engine/spec-format/lean-technical-generator.d.ts +0 -5
- package/dist/engine/spec-format/lean-technical-generator.js +0 -45
- package/dist/engine/spec-format/markdown-sections.d.ts +0 -14
- package/dist/engine/spec-format/markdown-sections.js +0 -105
- package/dist/engine/spec-format/metadata-value-policy.d.ts +0 -156
- package/dist/engine/spec-format/metadata-value-policy.js +0 -86
- package/dist/engine/spec-format/read-technical-section.d.ts +0 -25
- package/dist/engine/spec-format/read-technical-section.js +0 -99
- package/dist/engine/spec-format/replace-section.d.ts +0 -17
- package/dist/engine/spec-format/replace-section.js +0 -79
- package/dist/engine/spec-format/retired-scaffold.d.ts +0 -3
- package/dist/engine/spec-format/retired-scaffold.js +0 -5
- package/dist/engine/spec-format/spec-id.d.ts +0 -8
- package/dist/engine/spec-format/spec-id.js +0 -25
- package/dist/engine/spec-format/technical-md-populator.d.ts +0 -17
- package/dist/engine/spec-format/technical-md-populator.js +0 -321
- package/dist/engine/spec-format/text-fences.d.ts +0 -6
- package/dist/engine/spec-format/text-fences.js +0 -28
- package/dist/engine/spec-format/unified-spec-builder.d.ts +0 -25
- package/dist/engine/spec-format/unified-spec-builder.js +0 -400
- package/dist/engine/spec-generator/fallback-generator.d.ts +0 -5
- package/dist/engine/spec-generator/fallback-generator.js +0 -41
- package/dist/engine/spec-generator/index.d.ts +0 -2
- package/dist/engine/spec-generator/index.js +0 -2
- package/dist/engine/spec-grounding/contract.d.ts +0 -24
- package/dist/engine/spec-grounding/contract.js +0 -278
- package/dist/engine/spec-grounding/grounding-entry-parser.d.ts +0 -4
- package/dist/engine/spec-grounding/grounding-entry-parser.js +0 -184
- package/dist/engine/spec-health-scorer.d.ts +0 -7
- package/dist/engine/spec-health-scorer.js +0 -134
- package/dist/engine/spec-language/english-only.d.ts +0 -30
- package/dist/engine/spec-language/english-only.js +0 -224
- package/dist/engine/spec-migrator/criteria-scanner.d.ts +0 -7
- package/dist/engine/spec-migrator/criteria-scanner.js +0 -113
- package/dist/engine/spec-migrator/drift-detector.d.ts +0 -10
- package/dist/engine/spec-migrator/drift-detector.js +0 -142
- package/dist/engine/spec-migrator/filesystem-import.d.ts +0 -10
- package/dist/engine/spec-migrator/filesystem-import.js +0 -205
- package/dist/engine/spec-migrator/flatten-specs.d.ts +0 -12
- package/dist/engine/spec-migrator/flatten-specs.js +0 -111
- package/dist/engine/spec-migrator/folder-operations.d.ts +0 -7
- package/dist/engine/spec-migrator/folder-operations.js +0 -109
- package/dist/engine/spec-migrator/frontmatter-parser.d.ts +0 -11
- package/dist/engine/spec-migrator/frontmatter-parser.js +0 -111
- package/dist/engine/spec-migrator/git-aware-fs.d.ts +0 -9
- package/dist/engine/spec-migrator/git-aware-fs.js +0 -20
- package/dist/engine/spec-migrator/index.d.ts +0 -10
- package/dist/engine/spec-migrator/index.js +0 -23
- package/dist/engine/spec-migrator/lean-migration.d.ts +0 -8
- package/dist/engine/spec-migrator/lean-migration.js +0 -405
- package/dist/engine/spec-migrator/legacy-classifier.d.ts +0 -4
- package/dist/engine/spec-migrator/legacy-classifier.js +0 -70
- package/dist/engine/spec-migrator/legacy-migration.d.ts +0 -13
- package/dist/engine/spec-migrator/legacy-migration.js +0 -88
- package/dist/engine/spec-migrator/path-utils.d.ts +0 -13
- package/dist/engine/spec-migrator/path-utils.js +0 -40
- package/dist/engine/spec-migrator/planu-canonical-policy.d.ts +0 -18
- package/dist/engine/spec-migrator/planu-canonical-policy.js +0 -105
- package/dist/engine/spec-migrator/prefix-migration.d.ts +0 -11
- package/dist/engine/spec-migrator/prefix-migration.js +0 -85
- package/dist/engine/spec-migrator/reconcile-paths.d.ts +0 -12
- package/dist/engine/spec-migrator/reconcile-paths.js +0 -77
- package/dist/engine/spec-migrator/strict-planu-cleanup.d.ts +0 -7
- package/dist/engine/spec-migrator/strict-planu-cleanup.js +0 -308
- package/dist/engine/spec-migrator/version-detection.d.ts +0 -5
- package/dist/engine/spec-migrator/version-detection.js +0 -19
- package/dist/engine/spec-migrator.d.ts +0 -2
- package/dist/engine/spec-migrator.js +0 -3
- package/dist/engine/spec-quality/generic-output-gate.d.ts +0 -9
- package/dist/engine/spec-quality/generic-output-gate.js +0 -350
- package/dist/engine/spec-quality-scorer.d.ts +0 -4
- package/dist/engine/spec-quality-scorer.js +0 -423
- package/dist/engine/spec-reader.d.ts +0 -7
- package/dist/engine/spec-reader.js +0 -23
- package/dist/engine/spec-state-machine/transition-spec.d.ts +0 -56
- package/dist/engine/spec-state-machine/transition-spec.js +0 -59
- package/dist/engine/spec-versioner.d.ts +0 -28
- package/dist/engine/spec-versioner.js +0 -92
- package/dist/engine/spec-versioning/bump-version.d.ts +0 -17
- package/dist/engine/spec-versioning/bump-version.js +0 -199
- package/dist/engine/spec-versioning/migrate-format.d.ts +0 -23
- package/dist/engine/spec-versioning/migrate-format.js +0 -96
- package/dist/engine/spec-versioning/render-history.d.ts +0 -14
- package/dist/engine/spec-versioning/render-history.js +0 -31
- package/dist/engine/technology-registry.d.ts +0 -11
- package/dist/engine/technology-registry.js +0 -142
- package/dist/engine/test-selection/policy.d.ts +0 -9
- package/dist/engine/test-selection/policy.js +0 -192
- package/dist/engine/text-signal-boundaries.d.ts +0 -8
- package/dist/engine/text-signal-boundaries.js +0 -122
- package/dist/engine/time/relative-date.d.ts +0 -3
- package/dist/engine/time/relative-date.js +0 -16
- package/dist/engine/timing/budget.d.ts +0 -29
- package/dist/engine/timing/budget.js +0 -129
- package/dist/engine/universal-rules/catalog.d.ts +0 -7
- package/dist/engine/universal-rules/catalog.js +0 -25
- package/dist/engine/universal-rules/host-writer.d.ts +0 -7
- package/dist/engine/universal-rules/host-writer.js +0 -113
- package/dist/engine/universal-rules/installer.d.ts +0 -5
- package/dist/engine/universal-rules/installer.js +0 -236
- package/dist/engine/universal-rules/rules/planu-approval-gates.d.ts +0 -3
- package/dist/engine/universal-rules/rules/planu-approval-gates.js +0 -48
- package/dist/engine/universal-rules/rules/planu-bdd-criteria.d.ts +0 -3
- package/dist/engine/universal-rules/rules/planu-bdd-criteria.js +0 -44
- package/dist/engine/universal-rules/rules/planu-dogfood-bugs.d.ts +0 -3
- package/dist/engine/universal-rules/rules/planu-dogfood-bugs.js +0 -70
- package/dist/engine/universal-rules/rules/planu-english-specs.d.ts +0 -3
- package/dist/engine/universal-rules/rules/planu-english-specs.js +0 -41
- package/dist/engine/universal-rules/rules/planu-minimal-change.d.ts +0 -3
- package/dist/engine/universal-rules/rules/planu-minimal-change.js +0 -42
- package/dist/engine/universal-rules/rules/planu-modes.d.ts +0 -3
- package/dist/engine/universal-rules/rules/planu-modes.js +0 -57
- package/dist/engine/universal-rules/rules/planu-sdd-model-routing.d.ts +0 -3
- package/dist/engine/universal-rules/rules/planu-sdd-model-routing.js +0 -50
- package/dist/engine/universal-rules/rules/planu-workflow.d.ts +0 -3
- package/dist/engine/universal-rules/rules/planu-workflow.js +0 -92
- package/dist/engine/universal-rules/user-edit-detector.d.ts +0 -21
- package/dist/engine/universal-rules/user-edit-detector.js +0 -46
- package/dist/engine/validation/durable-validation.d.ts +0 -44
- package/dist/engine/validation/durable-validation.js +0 -344
- package/dist/engine/validation/validation-freshness.d.ts +0 -73
- package/dist/engine/validation/validation-freshness.js +0 -777
- package/dist/engine/validation/validation-receipt-codec.d.ts +0 -13
- package/dist/engine/validation/validation-receipt-codec.js +0 -184
- package/dist/engine/validation/validation-receipt.d.ts +0 -67
- package/dist/engine/validation/validation-receipt.js +0 -342
- package/dist/engine/validation/validation-source-digest.d.ts +0 -2
- package/dist/engine/validation/validation-source-digest.js +0 -86
- package/dist/engine/validation/validation-source-policy.d.ts +0 -4
- package/dist/engine/validation/validation-source-policy.js +0 -17
- package/dist/engine/validation/validation-submission.d.ts +0 -35
- package/dist/engine/validation/validation-submission.js +0 -142
- package/dist/engine/validation/validation-worktree.d.ts +0 -21
- package/dist/engine/validation/validation-worktree.js +0 -294
- package/dist/engine/validation-evidence-digest.d.ts +0 -4
- package/dist/engine/validation-evidence-digest.js +0 -83
- package/dist/engine/validation-evidence-ledger.d.ts +0 -30
- package/dist/engine/validation-evidence-ledger.js +0 -328
- package/dist/engine/validation-impact-planner.d.ts +0 -14
- package/dist/engine/validation-impact-planner.js +0 -74
- package/dist/engine/validation-loop.d.ts +0 -12
- package/dist/engine/validation-loop.js +0 -216
- package/dist/engine/validator/analyzer.d.ts +0 -23
- package/dist/engine/validator/analyzer.js +0 -495
- package/dist/engine/validator/blast-radius-gate.d.ts +0 -3
- package/dist/engine/validator/blast-radius-gate.js +0 -305
- package/dist/engine/validator/checklist.d.ts +0 -6
- package/dist/engine/validator/checklist.js +0 -147
- package/dist/engine/validator/deep-code-checker.d.ts +0 -49
- package/dist/engine/validator/deep-code-checker.js +0 -410
- package/dist/engine/validator/dor-dod.d.ts +0 -11
- package/dist/engine/validator/dor-dod.js +0 -338
- package/dist/engine/validator/executable-evidence.d.ts +0 -18
- package/dist/engine/validator/executable-evidence.js +0 -104
- package/dist/engine/validator/extractors.d.ts +0 -16
- package/dist/engine/validator/extractors.js +0 -105
- package/dist/engine/validator/gates/code-gates.d.ts +0 -14
- package/dist/engine/validator/gates/code-gates.js +0 -87
- package/dist/engine/validator/gates/convention-gates.d.ts +0 -13
- package/dist/engine/validator/gates/convention-gates.js +0 -84
- package/dist/engine/validator/gates/index.d.ts +0 -8
- package/dist/engine/validator/gates/index.js +0 -63
- package/dist/engine/validator/gates/test-gates.d.ts +0 -12
- package/dist/engine/validator/gates/test-gates.js +0 -105
- package/dist/engine/validator/holistic-report.d.ts +0 -11
- package/dist/engine/validator/holistic-report.js +0 -34
- package/dist/engine/validator/negative-predicate.d.ts +0 -17
- package/dist/engine/validator/negative-predicate.js +0 -240
- package/dist/engine/validator/package-json-evidence.d.ts +0 -3
- package/dist/engine/validator/package-json-evidence.js +0 -97
- package/dist/engine/validator/reliability-gate.d.ts +0 -4
- package/dist/engine/validator/reliability-gate.js +0 -81
- package/dist/engine/validator/scope-resolver.d.ts +0 -30
- package/dist/engine/validator/scope-resolver.js +0 -67
- package/dist/engine/validator/spec-compliance-runner.d.ts +0 -9
- package/dist/engine/validator/spec-compliance-runner.js +0 -849
- package/dist/engine/validator/test-evidence-grounding.d.ts +0 -64
- package/dist/engine/validator/test-evidence-grounding.js +0 -221
- package/dist/engine/validator/validation-report-writer.d.ts +0 -27
- package/dist/engine/validator/validation-report-writer.js +0 -208
- package/dist/engine/validator.d.ts +0 -19
- package/dist/engine/validator.js +0 -244
- package/dist/engine/verifier/bdd-entity-extractor.d.ts +0 -23
- package/dist/engine/verifier/bdd-entity-extractor.js +0 -227
- package/dist/engine/verifier/compliance-scorer.d.ts +0 -17
- package/dist/engine/verifier/compliance-scorer.js +0 -131
- package/dist/engine/verifier/criterion-matcher.d.ts +0 -22
- package/dist/engine/verifier/criterion-matcher.js +0 -309
- package/dist/engine/web-fetcher/registry-loader.d.ts +0 -7
- package/dist/engine/web-fetcher/registry-loader.js +0 -44
- package/dist/engine/whats-new.d.ts +0 -2
- package/dist/engine/whats-new.js +0 -42
- package/dist/errors/classified-degradation.d.ts +0 -3
- package/dist/errors/classified-degradation.js +0 -10
- package/dist/errors/degradation-sink.d.ts +0 -3
- package/dist/errors/degradation-sink.js +0 -5
- package/dist/errors/error-taxonomy.d.ts +0 -11
- package/dist/errors/error-taxonomy.js +0 -59
- package/dist/hosts/claude-code/coach.d.ts +0 -6
- package/dist/hosts/claude-code/coach.js +0 -10
- package/dist/hosts/claude-code/ux/subagent-publisher.d.ts +0 -20
- package/dist/hosts/claude-code/ux/subagent-publisher.js +0 -117
- package/dist/hosts/codex/config-scaffold.d.ts +0 -10
- package/dist/hosts/codex/config-scaffold.js +0 -102
- package/dist/hosts/codex/workspace-scope.d.ts +0 -43
- package/dist/hosts/codex/workspace-scope.js +0 -89
- package/dist/hosts/gemini/config-scaffold.d.ts +0 -14
- package/dist/hosts/gemini/config-scaffold.js +0 -165
- package/dist/i18n/index.d.ts +0 -61
- package/dist/i18n/index.js +0 -288
- package/dist/prompts/index.d.ts +0 -6
- package/dist/prompts/index.js +0 -121
- package/dist/resources/process.d.ts +0 -11
- package/dist/resources/process.js +0 -80
- package/dist/resources/registry.d.ts +0 -6
- package/dist/resources/registry.js +0 -16
- package/dist/resources/specs.d.ts +0 -11
- package/dist/resources/specs.js +0 -58
- package/dist/security/adapters/environment.d.ts +0 -12
- package/dist/security/adapters/environment.js +0 -25
- package/dist/security/adapters/local-file.d.ts +0 -12
- package/dist/security/adapters/local-file.js +0 -56
- package/dist/security/adapters/macos-keychain.d.ts +0 -20
- package/dist/security/adapters/macos-keychain.js +0 -151
- package/dist/security/redactor.d.ts +0 -5
- package/dist/security/redactor.js +0 -58
- package/dist/security/secret-provider.d.ts +0 -22
- package/dist/security/secret-provider.js +0 -107
- package/dist/storage/approval-operation-lock.d.ts +0 -7
- package/dist/storage/approval-operation-lock.js +0 -47
- package/dist/storage/approval-store.d.ts +0 -14
- package/dist/storage/approval-store.js +0 -117
- package/dist/storage/audit-trail-store.d.ts +0 -20
- package/dist/storage/audit-trail-store.js +0 -83
- package/dist/storage/base-store.d.ts +0 -69
- package/dist/storage/base-store.js +0 -195
- package/dist/storage/compliance-gate-config-store.d.ts +0 -4
- package/dist/storage/compliance-gate-config-store.js +0 -20
- package/dist/storage/convention-baseline.d.ts +0 -20
- package/dist/storage/convention-baseline.js +0 -62
- package/dist/storage/current-project.d.ts +0 -3
- package/dist/storage/current-project.js +0 -21
- package/dist/storage/file-mutex.d.ts +0 -14
- package/dist/storage/file-mutex.js +0 -47
- package/dist/storage/global-projects-store.d.ts +0 -53
- package/dist/storage/global-projects-store.js +0 -181
- package/dist/storage/global-store.d.ts +0 -82
- package/dist/storage/global-store.js +0 -246
- package/dist/storage/index.d.ts +0 -15
- package/dist/storage/index.js +0 -16
- package/dist/storage/knowledge-store/knowledge.d.ts +0 -25
- package/dist/storage/knowledge-store/knowledge.js +0 -112
- package/dist/storage/knowledge-store/sessions.d.ts +0 -16
- package/dist/storage/knowledge-store/sessions.js +0 -155
- package/dist/storage/knowledge-store.d.ts +0 -3
- package/dist/storage/knowledge-store.js +0 -8
- package/dist/storage/migrations/canonical-storage.d.ts +0 -15
- package/dist/storage/migrations/canonical-storage.js +0 -754
- package/dist/storage/migrations/sdd-core-v6.d.ts +0 -11
- package/dist/storage/migrations/sdd-core-v6.js +0 -873
- package/dist/storage/pattern-store.d.ts +0 -38
- package/dist/storage/pattern-store.js +0 -136
- package/dist/storage/project-identity.d.ts +0 -60
- package/dist/storage/project-identity.js +0 -454
- package/dist/storage/project-resolver.d.ts +0 -17
- package/dist/storage/project-resolver.js +0 -134
- package/dist/storage/retention.d.ts +0 -13
- package/dist/storage/retention.js +0 -383
- package/dist/storage/runtime-db.d.ts +0 -207
- package/dist/storage/runtime-db.js +0 -1313
- package/dist/storage/schema-registry.d.ts +0 -5
- package/dist/storage/schema-registry.js +0 -74
- package/dist/storage/spec-index.d.ts +0 -23
- package/dist/storage/spec-index.js +0 -117
- package/dist/storage/spec-lock-store.d.ts +0 -22
- package/dist/storage/spec-lock-store.js +0 -99
- package/dist/storage/spec-store.d.ts +0 -170
- package/dist/storage/spec-store.js +0 -968
- package/dist/storage/storage-bundle.d.ts +0 -16
- package/dist/storage/storage-bundle.js +0 -117
- package/dist/storage/storage-catalog-validation.d.ts +0 -3
- package/dist/storage/storage-catalog-validation.js +0 -20
- package/dist/storage/storage-catalog.d.ts +0 -25
- package/dist/storage/storage-catalog.js +0 -421
- package/dist/storage/storage-layout.d.ts +0 -40
- package/dist/storage/storage-layout.js +0 -117
- package/dist/storage/technology-selection-store.d.ts +0 -5
- package/dist/storage/technology-selection-store.js +0 -46
- package/dist/storage/transition-log.d.ts +0 -11
- package/dist/storage/transition-log.js +0 -234
- package/dist/tools/bump-spec-version.d.ts +0 -31
- package/dist/tools/bump-spec-version.js +0 -132
- package/dist/tools/challenge-spec/agent-challenge-scenarios.d.ts +0 -12
- package/dist/tools/challenge-spec/agent-challenge-scenarios.js +0 -129
- package/dist/tools/challenge-spec/architecture-challenge-scenarios.d.ts +0 -12
- package/dist/tools/challenge-spec/architecture-challenge-scenarios.js +0 -113
- package/dist/tools/challenge-spec/challenge-report.d.ts +0 -26
- package/dist/tools/challenge-spec/challenge-report.js +0 -221
- package/dist/tools/challenge-spec/event-challenge-scenarios.d.ts +0 -14
- package/dist/tools/challenge-spec/event-challenge-scenarios.js +0 -68
- package/dist/tools/challenge-spec/implementation-contract-challenge-scenarios.d.ts +0 -3
- package/dist/tools/challenge-spec/implementation-contract-challenge-scenarios.js +0 -51
- package/dist/tools/challenge-spec/platform-challenge-scenarios-b.d.ts +0 -7
- package/dist/tools/challenge-spec/platform-challenge-scenarios-b.js +0 -48
- package/dist/tools/challenge-spec/platform-challenge-scenarios-b1.d.ts +0 -4
- package/dist/tools/challenge-spec/platform-challenge-scenarios-b1.js +0 -109
- package/dist/tools/challenge-spec/platform-challenge-scenarios-b2.d.ts +0 -5
- package/dist/tools/challenge-spec/platform-challenge-scenarios-b2.js +0 -191
- package/dist/tools/challenge-spec/platform-challenge-scenarios.d.ts +0 -7
- package/dist/tools/challenge-spec/platform-challenge-scenarios.js +0 -224
- package/dist/tools/challenge-spec/resilience-challenge-scenarios-a.d.ts +0 -28
- package/dist/tools/challenge-spec/resilience-challenge-scenarios-a.js +0 -183
- package/dist/tools/challenge-spec/resilience-challenge-scenarios-b.d.ts +0 -14
- package/dist/tools/challenge-spec/resilience-challenge-scenarios-b.js +0 -144
- package/dist/tools/challenge-spec/resilience-challenge-scenarios.d.ts +0 -8
- package/dist/tools/challenge-spec/resilience-challenge-scenarios.js +0 -37
- package/dist/tools/challenge-spec/scenario-collector.d.ts +0 -13
- package/dist/tools/challenge-spec/scenario-collector.js +0 -84
- package/dist/tools/challenge-spec/scenarios-data.d.ts +0 -3
- package/dist/tools/challenge-spec/scenarios-data.js +0 -73
- package/dist/tools/challenge-spec/scenarios-desktop.d.ts +0 -7
- package/dist/tools/challenge-spec/scenarios-desktop.js +0 -91
- package/dist/tools/challenge-spec/scenarios-failure.d.ts +0 -3
- package/dist/tools/challenge-spec/scenarios-failure.js +0 -136
- package/dist/tools/challenge-spec/scenarios-game.d.ts +0 -6
- package/dist/tools/challenge-spec/scenarios-game.js +0 -71
- package/dist/tools/challenge-spec/scenarios-scale.d.ts +0 -3
- package/dist/tools/challenge-spec/scenarios-scale.js +0 -37
- package/dist/tools/challenge-spec/scenarios-security.d.ts +0 -3
- package/dist/tools/challenge-spec/scenarios-security.js +0 -85
- package/dist/tools/challenge-spec/scenarios-utils.d.ts +0 -42
- package/dist/tools/challenge-spec/scenarios-utils.js +0 -250
- package/dist/tools/challenge-spec-helpers.d.ts +0 -16
- package/dist/tools/challenge-spec-helpers.js +0 -152
- package/dist/tools/challenge-spec-scenarios.d.ts +0 -7
- package/dist/tools/challenge-spec-scenarios.js +0 -9
- package/dist/tools/challenge-spec.d.ts +0 -4
- package/dist/tools/challenge-spec.js +0 -448
- package/dist/tools/check-readiness.d.ts +0 -5
- package/dist/tools/check-readiness.js +0 -343
- package/dist/tools/claude-settings-file.d.ts +0 -3
- package/dist/tools/claude-settings-file.js +0 -19
- package/dist/tools/create-skill.d.ts +0 -4
- package/dist/tools/create-skill.js +0 -151
- package/dist/tools/create-spec/autopilot-analyzer.d.ts +0 -33
- package/dist/tools/create-spec/autopilot-analyzer.js +0 -171
- package/dist/tools/create-spec/constitution-validator.d.ts +0 -4
- package/dist/tools/create-spec/constitution-validator.js +0 -31
- package/dist/tools/create-spec/question-generator.d.ts +0 -4
- package/dist/tools/create-spec/question-generator.js +0 -25
- package/dist/tools/create-spec/relevance-scorer.d.ts +0 -18
- package/dist/tools/create-spec/relevance-scorer.js +0 -156
- package/dist/tools/create-spec/spec-builder.d.ts +0 -20
- package/dist/tools/create-spec/spec-builder.js +0 -274
- package/dist/tools/create-spec-helpers.d.ts +0 -4
- package/dist/tools/create-spec-helpers.js +0 -24
- package/dist/tools/create-spec-tech/constitution.d.ts +0 -7
- package/dist/tools/create-spec-tech/constitution.js +0 -79
- package/dist/tools/create-spec-tech.d.ts +0 -2
- package/dist/tools/create-spec-tech.js +0 -3
- package/dist/tools/create-spec.d.ts +0 -25
- package/dist/tools/create-spec.js +0 -1698
- package/dist/tools/git/git-helpers.d.ts +0 -20
- package/dist/tools/git/git-helpers.js +0 -33
- package/dist/tools/init-project/agents-md-writer.d.ts +0 -18
- package/dist/tools/init-project/agents-md-writer.js +0 -123
- package/dist/tools/init-project/config-builder.d.ts +0 -14
- package/dist/tools/init-project/config-builder.js +0 -19
- package/dist/tools/init-project/conventions-writer.d.ts +0 -11
- package/dist/tools/init-project/conventions-writer.js +0 -61
- package/dist/tools/init-project/handler.d.ts +0 -4
- package/dist/tools/init-project/handler.js +0 -463
- package/dist/tools/init-project/helpers.d.ts +0 -31
- package/dist/tools/init-project/helpers.js +0 -223
- package/dist/tools/init-project/host-assets-writer.d.ts +0 -28
- package/dist/tools/init-project/host-assets-writer.js +0 -240
- package/dist/tools/init-project/legacy-guidance-scanner.d.ts +0 -9
- package/dist/tools/init-project/legacy-guidance-scanner.js +0 -218
- package/dist/tools/init-project/legacy-root-migration.d.ts +0 -16
- package/dist/tools/init-project/legacy-root-migration.js +0 -213
- package/dist/tools/init-project/lifecycle-helpers.d.ts +0 -12
- package/dist/tools/init-project/lifecycle-helpers.js +0 -37
- package/dist/tools/init-project/managed-guidance-refresher.d.ts +0 -9
- package/dist/tools/init-project/managed-guidance-refresher.js +0 -65
- package/dist/tools/init-project/migration-runner.d.ts +0 -43
- package/dist/tools/init-project/migration-runner.js +0 -227
- package/dist/tools/init-project/portable-index-reconciler.d.ts +0 -32
- package/dist/tools/init-project/portable-index-reconciler.js +0 -278
- package/dist/tools/init-project/result-builder.d.ts +0 -4
- package/dist/tools/init-project/result-builder.js +0 -272
- package/dist/tools/init-project/scaffold-verifier.d.ts +0 -6
- package/dist/tools/init-project/scaffold-verifier.js +0 -97
- package/dist/tools/init-project/scaffold-writer.d.ts +0 -49
- package/dist/tools/init-project/scaffold-writer.js +0 -50
- package/dist/tools/init-project.d.ts +0 -2
- package/dist/tools/init-project.js +0 -4
- package/dist/tools/jobs/handlers.d.ts +0 -11
- package/dist/tools/jobs/handlers.js +0 -152
- package/dist/tools/list-specs.d.ts +0 -3
- package/dist/tools/list-specs.js +0 -323
- package/dist/tools/output-formatter.d.ts +0 -34
- package/dist/tools/output-formatter.js +0 -171
- package/dist/tools/output-integrity-guard.d.ts +0 -3
- package/dist/tools/output-integrity-guard.js +0 -53
- package/dist/tools/package-handoff.d.ts +0 -4
- package/dist/tools/package-handoff.js +0 -215
- package/dist/tools/reconcile-spec-sanctity-hook.d.ts +0 -3
- package/dist/tools/reconcile-spec-sanctity-hook.js +0 -55
- package/dist/tools/reconcile-spec.d.ts +0 -4
- package/dist/tools/reconcile-spec.js +0 -572
- package/dist/tools/register-sdd-tools.d.ts +0 -4
- package/dist/tools/register-sdd-tools.js +0 -13
- package/dist/tools/resolve-project-id.d.ts +0 -58
- package/dist/tools/resolve-project-id.js +0 -103
- package/dist/tools/resolve-project-path.d.ts +0 -27
- package/dist/tools/resolve-project-path.js +0 -172
- package/dist/tools/response-helpers.d.ts +0 -70
- package/dist/tools/response-helpers.js +0 -139
- package/dist/tools/safe-handler.d.ts +0 -36
- package/dist/tools/safe-handler.js +0 -283
- package/dist/tools/sanitize-path.d.ts +0 -13
- package/dist/tools/sanitize-path.js +0 -60
- package/dist/tools/schemas/agents.d.ts +0 -21
- package/dist/tools/schemas/agents.js +0 -9
- package/dist/tools/schemas/analysis.d.ts +0 -28
- package/dist/tools/schemas/analysis.js +0 -22
- package/dist/tools/schemas/index.d.ts +0 -8
- package/dist/tools/schemas/index.js +0 -9
- package/dist/tools/schemas/infra.d.ts +0 -19
- package/dist/tools/schemas/infra.js +0 -18
- package/dist/tools/schemas/lifecycle.d.ts +0 -88
- package/dist/tools/schemas/lifecycle.js +0 -85
- package/dist/tools/schemas/output-schemas.d.ts +0 -115
- package/dist/tools/schemas/output-schemas.js +0 -136
- package/dist/tools/schemas/package-handoff-output-schema.d.ts +0 -41
- package/dist/tools/schemas/package-handoff-output-schema.js +0 -70
- package/dist/tools/schemas/spec-id.d.ts +0 -2
- package/dist/tools/schemas/spec-id.js +0 -2
- package/dist/tools/schemas/spec.d.ts +0 -51
- package/dist/tools/schemas/spec.js +0 -41
- package/dist/tools/schemas/validate-output-schema.d.ts +0 -276
- package/dist/tools/schemas/validate-output-schema.js +0 -225
- package/dist/tools/status-handler.d.ts +0 -3
- package/dist/tools/status-handler.js +0 -242
- package/dist/tools/tool-entry.d.ts +0 -52
- package/dist/tools/tool-entry.js +0 -46
- package/dist/tools/tool-registry/core-tools.d.ts +0 -4
- package/dist/tools/tool-registry/core-tools.js +0 -581
- package/dist/tools/tool-registry/inventory.d.ts +0 -2
- package/dist/tools/tool-registry/inventory.js +0 -2
- package/dist/tools/tool-registry-helpers.d.ts +0 -34
- package/dist/tools/tool-registry-helpers.js +0 -45
- package/dist/tools/update-status/approval-gates.d.ts +0 -13
- package/dist/tools/update-status/approval-gates.js +0 -108
- package/dist/tools/update-status/batch.d.ts +0 -7
- package/dist/tools/update-status/batch.js +0 -176
- package/dist/tools/update-status/dod-gates.d.ts +0 -117
- package/dist/tools/update-status/dod-gates.js +0 -847
- package/dist/tools/update-status/done-receipt-verifier.d.ts +0 -38
- package/dist/tools/update-status/done-receipt-verifier.js +0 -208
- package/dist/tools/update-status/evidence-gate.d.ts +0 -16
- package/dist/tools/update-status/evidence-gate.js +0 -361
- package/dist/tools/update-status/evidence-payload.d.ts +0 -180
- package/dist/tools/update-status/evidence-payload.js +0 -79
- package/dist/tools/update-status/file-sync.d.ts +0 -37
- package/dist/tools/update-status/file-sync.js +0 -223
- package/dist/tools/update-status/gate-harness.d.ts +0 -8
- package/dist/tools/update-status/gate-harness.js +0 -8
- package/dist/tools/update-status/index.d.ts +0 -25
- package/dist/tools/update-status/index.js +0 -1487
- package/dist/tools/update-status/response-builder.d.ts +0 -17
- package/dist/tools/update-status/response-builder.js +0 -297
- package/dist/tools/update-status/side-effects.d.ts +0 -16
- package/dist/tools/update-status/side-effects.js +0 -117
- package/dist/tools/update-status/transition-guard.d.ts +0 -85
- package/dist/tools/update-status/transition-guard.js +0 -752
- package/dist/tools/update-status-actions.d.ts +0 -6
- package/dist/tools/update-status-actions.js +0 -19
- package/dist/tools/update-status-convention-gate.d.ts +0 -9
- package/dist/tools/update-status-convention-gate.js +0 -330
- package/dist/tools/update-status.d.ts +0 -2
- package/dist/tools/update-status.js +0 -3
- package/dist/tools/validate-assurance.d.ts +0 -6
- package/dist/tools/validate-assurance.js +0 -55
- package/dist/tools/validate-graph-coverage.d.ts +0 -8
- package/dist/tools/validate-graph-coverage.js +0 -54
- package/dist/tools/validate-helpers.d.ts +0 -10
- package/dist/tools/validate-helpers.js +0 -65
- package/dist/tools/validate-lint.d.ts +0 -9
- package/dist/tools/validate-lint.js +0 -170
- package/dist/tools/validate-minimality.d.ts +0 -16
- package/dist/tools/validate-minimality.js +0 -22
- package/dist/tools/validate-structured-compat.d.ts +0 -19
- package/dist/tools/validate-structured-compat.js +0 -14
- package/dist/tools/validate.d.ts +0 -8
- package/dist/tools/validate.js +0 -1039
- package/dist/transports/transport-factory.d.ts +0 -5
- package/dist/transports/transport-factory.js +0 -182
- package/dist/types/abortable-process.d.ts +0 -29
- package/dist/types/abortable-process.js +0 -2
- package/dist/types/agent-team.d.ts +0 -17
- package/dist/types/agent-team.js +0 -3
- package/dist/types/ai-assurance.d.ts +0 -32
- package/dist/types/ai-assurance.js +0 -2
- package/dist/types/ai-native.d.ts +0 -16
- package/dist/types/ai-native.js +0 -3
- package/dist/types/analysis.d.ts +0 -238
- package/dist/types/analysis.js +0 -3
- package/dist/types/approval.d.ts +0 -66
- package/dist/types/approval.js +0 -6
- package/dist/types/architecture.d.ts +0 -101
- package/dist/types/architecture.js +0 -4
- package/dist/types/audit.d.ts +0 -38
- package/dist/types/audit.js +0 -4
- package/dist/types/build-freshness.d.ts +0 -11
- package/dist/types/build-freshness.js +0 -2
- package/dist/types/clarification-token.d.ts +0 -46
- package/dist/types/clarification-token.js +0 -2
- package/dist/types/clarification.d.ts +0 -23
- package/dist/types/clarification.js +0 -5
- package/dist/types/claude-code-runtime.d.ts +0 -91
- package/dist/types/claude-code-runtime.js +0 -5
- package/dist/types/claude-code-ux.d.ts +0 -62
- package/dist/types/claude-code-ux.js +0 -5
- package/dist/types/cli.d.ts +0 -40
- package/dist/types/cli.js +0 -3
- package/dist/types/codex.d.ts +0 -108
- package/dist/types/codex.js +0 -3
- package/dist/types/common/index.d.ts +0 -4
- package/dist/types/common/index.js +0 -6
- package/dist/types/common/learning.d.ts +0 -43
- package/dist/types/common/learning.js +0 -3
- package/dist/types/common/tech-enums.d.ts +0 -8
- package/dist/types/common/tech-enums.js +0 -2
- package/dist/types/complexity-budget.d.ts +0 -17
- package/dist/types/complexity-budget.js +0 -5
- package/dist/types/compliance-gate.d.ts +0 -5
- package/dist/types/compliance-gate.js +0 -3
- package/dist/types/context.d.ts +0 -52
- package/dist/types/context.js +0 -4
- package/dist/types/conventions.d.ts +0 -135
- package/dist/types/conventions.js +0 -5
- package/dist/types/core-bridge.d.ts +0 -130
- package/dist/types/core-bridge.js +0 -3
- package/dist/types/criterion-identity.d.ts +0 -12
- package/dist/types/criterion-identity.js +0 -2
- package/dist/types/cross-repo-search.d.ts +0 -81
- package/dist/types/cross-repo-search.js +0 -9
- package/dist/types/decisions.d.ts +0 -19
- package/dist/types/decisions.js +0 -4
- package/dist/types/durable-job.d.ts +0 -119
- package/dist/types/durable-job.js +0 -10
- package/dist/types/durable-validation.d.ts +0 -158
- package/dist/types/durable-validation.js +0 -166
- package/dist/types/edge-db.d.ts +0 -21
- package/dist/types/edge-db.js +0 -9
- package/dist/types/elicitation.d.ts +0 -115
- package/dist/types/elicitation.js +0 -13
- package/dist/types/env.d.ts +0 -94
- package/dist/types/env.js +0 -3
- package/dist/types/errors/structured-error.d.ts +0 -37
- package/dist/types/errors/structured-error.js +0 -3
- package/dist/types/estimation.d.ts +0 -29
- package/dist/types/estimation.js +0 -5
- package/dist/types/events.d.ts +0 -18
- package/dist/types/events.js +0 -4
- package/dist/types/evidence-autofill.d.ts +0 -40
- package/dist/types/evidence-autofill.js +0 -3
- package/dist/types/evidence-gates.d.ts +0 -103
- package/dist/types/evidence-gates.js +0 -2
- package/dist/types/evidence-index.d.ts +0 -26
- package/dist/types/evidence-index.js +0 -2
- package/dist/types/execution.d.ts +0 -103
- package/dist/types/execution.js +0 -2
- package/dist/types/frontmatter.d.ts +0 -5
- package/dist/types/frontmatter.js +0 -2
- package/dist/types/gemini.d.ts +0 -124
- package/dist/types/gemini.js +0 -3
- package/dist/types/handoff-artifacts.d.ts +0 -182
- package/dist/types/handoff-artifacts.js +0 -3
- package/dist/types/host-rules.d.ts +0 -10
- package/dist/types/host-rules.js +0 -3
- package/dist/types/host-tool-filter.d.ts +0 -31
- package/dist/types/host-tool-filter.js +0 -3
- package/dist/types/housekeeping.d.ts +0 -8
- package/dist/types/housekeeping.js +0 -22
- package/dist/types/index.d.ts +0 -81
- package/dist/types/index.js +0 -94
- package/dist/types/interactive-question.d.ts +0 -19
- package/dist/types/interactive-question.js +0 -3
- package/dist/types/keyword-matcher.d.ts +0 -38
- package/dist/types/keyword-matcher.js +0 -3
- package/dist/types/legacy-guidance.d.ts +0 -24
- package/dist/types/legacy-guidance.js +0 -3
- package/dist/types/legal.d.ts +0 -44
- package/dist/types/legal.js +0 -5
- package/dist/types/living-spec/annotations.d.ts +0 -36
- package/dist/types/living-spec/annotations.js +0 -23
- package/dist/types/living-spec.d.ts +0 -2
- package/dist/types/living-spec.js +0 -6
- package/dist/types/llm-security.d.ts +0 -19
- package/dist/types/llm-security.js +0 -4
- package/dist/types/local-first.d.ts +0 -25
- package/dist/types/local-first.js +0 -10
- package/dist/types/mcp.d.ts +0 -34
- package/dist/types/mcp.js +0 -4
- package/dist/types/migration/canonical-storage.d.ts +0 -38
- package/dist/types/migration/canonical-storage.js +0 -2
- package/dist/types/minimal-implementation-gate.d.ts +0 -98
- package/dist/types/minimal-implementation-gate.js +0 -2
- package/dist/types/model-routing.d.ts +0 -25
- package/dist/types/model-routing.js +0 -26
- package/dist/types/multi-agent.d.ts +0 -18
- package/dist/types/multi-agent.js +0 -18
- package/dist/types/nli-context.d.ts +0 -25
- package/dist/types/nli-context.js +0 -2
- package/dist/types/opencode.d.ts +0 -4
- package/dist/types/opencode.js +0 -3
- package/dist/types/paradigm.d.ts +0 -99
- package/dist/types/paradigm.js +0 -11
- package/dist/types/privacy.d.ts +0 -81
- package/dist/types/privacy.js +0 -25
- package/dist/types/project/agent.d.ts +0 -13
- package/dist/types/project/agent.js +0 -3
- package/dist/types/project/architecture-detection.d.ts +0 -24
- package/dist/types/project/architecture-detection.js +0 -2
- package/dist/types/project/config-metrics.d.ts +0 -10
- package/dist/types/project/config-metrics.js +0 -2
- package/dist/types/project/constitution.d.ts +0 -26
- package/dist/types/project/constitution.js +0 -3
- package/dist/types/project/core.d.ts +0 -137
- package/dist/types/project/core.js +0 -7
- package/dist/types/project/health-checker.d.ts +0 -13
- package/dist/types/project/health-checker.js +0 -3
- package/dist/types/project/inputs.d.ts +0 -39
- package/dist/types/project/inputs.js +0 -5
- package/dist/types/project/legacy-artifacts.d.ts +0 -7
- package/dist/types/project/legacy-artifacts.js +0 -2
- package/dist/types/project/library-groups.d.ts +0 -112
- package/dist/types/project/library-groups.js +0 -4
- package/dist/types/project/mfe-detection.d.ts +0 -19
- package/dist/types/project/mfe-detection.js +0 -3
- package/dist/types/project/planu-config.d.ts +0 -142
- package/dist/types/project/planu-config.js +0 -2
- package/dist/types/project/platform-exotic.d.ts +0 -108
- package/dist/types/project/platform-exotic.js +0 -3
- package/dist/types/project/platform-mobile.d.ts +0 -7
- package/dist/types/project/platform-mobile.js +0 -3
- package/dist/types/project/platform-specialty.d.ts +0 -17
- package/dist/types/project/platform-specialty.js +0 -3
- package/dist/types/project/scaffold-verification.d.ts +0 -15
- package/dist/types/project/scaffold-verification.js +0 -2
- package/dist/types/project-knowledge-graph.d.ts +0 -227
- package/dist/types/project-knowledge-graph.js +0 -2
- package/dist/types/project.d.ts +0 -11
- package/dist/types/project.js +0 -13
- package/dist/types/readiness.d.ts +0 -82
- package/dist/types/readiness.js +0 -7
- package/dist/types/reconcile.d.ts +0 -41
- package/dist/types/reconcile.js +0 -9
- package/dist/types/retention.d.ts +0 -12
- package/dist/types/retention.js +0 -3
- package/dist/types/reviewer-tokens.d.ts +0 -58
- package/dist/types/reviewer-tokens.js +0 -4
- package/dist/types/runtime-database.d.ts +0 -10
- package/dist/types/runtime-database.js +0 -2
- package/dist/types/runtime-policy.d.ts +0 -62
- package/dist/types/runtime-policy.js +0 -2
- package/dist/types/safe-schemas.d.ts +0 -12
- package/dist/types/safe-schemas.js +0 -27
- package/dist/types/safety.d.ts +0 -42
- package/dist/types/safety.js +0 -3
- package/dist/types/scan-project.d.ts +0 -20
- package/dist/types/scan-project.js +0 -4
- package/dist/types/schema-registry.d.ts +0 -12
- package/dist/types/schema-registry.js +0 -2
- package/dist/types/scope-boundaries.d.ts +0 -62
- package/dist/types/scope-boundaries.js +0 -3
- package/dist/types/scope.d.ts +0 -89
- package/dist/types/scope.js +0 -3
- package/dist/types/sdd-constitution.d.ts +0 -27
- package/dist/types/sdd-constitution.js +0 -2
- package/dist/types/sdd-core-v6.d.ts +0 -62
- package/dist/types/sdd-core-v6.js +0 -2
- package/dist/types/sdd-flow.d.ts +0 -3
- package/dist/types/sdd-flow.js +0 -3
- package/dist/types/sdd-model-routing.d.ts +0 -22
- package/dist/types/sdd-model-routing.js +0 -2
- package/dist/types/security.d.ts +0 -20
- package/dist/types/security.js +0 -4
- package/dist/types/skill-bootstrap.d.ts +0 -7
- package/dist/types/skill-bootstrap.js +0 -3
- package/dist/types/spec/clarification.d.ts +0 -86
- package/dist/types/spec/clarification.js +0 -2
- package/dist/types/spec/core.d.ts +0 -414
- package/dist/types/spec/core.js +0 -3
- package/dist/types/spec/health-score.d.ts +0 -25
- package/dist/types/spec/health-score.js +0 -2
- package/dist/types/spec/index-cache.d.ts +0 -25
- package/dist/types/spec/index-cache.js +0 -3
- package/dist/types/spec/index.d.ts +0 -7
- package/dist/types/spec/index.js +0 -9
- package/dist/types/spec/inputs.d.ts +0 -250
- package/dist/types/spec/inputs.js +0 -7
- package/dist/types/spec/versioning.d.ts +0 -39
- package/dist/types/spec/versioning.js +0 -3
- package/dist/types/spec-format.d.ts +0 -211
- package/dist/types/spec-format.js +0 -3
- package/dist/types/spec-generator.d.ts +0 -32
- package/dist/types/spec-generator.js +0 -2
- package/dist/types/spec-grounding.d.ts +0 -48
- package/dist/types/spec-grounding.js +0 -2
- package/dist/types/spec-language-translation.d.ts +0 -19
- package/dist/types/spec-language-translation.js +0 -5
- package/dist/types/spec-language.d.ts +0 -8
- package/dist/types/spec-language.js +0 -2
- package/dist/types/spec-lock-v2.d.ts +0 -66
- package/dist/types/spec-lock-v2.js +0 -4
- package/dist/types/spec-lock.d.ts +0 -14
- package/dist/types/spec-lock.js +0 -8
- package/dist/types/spec-quality.d.ts +0 -82
- package/dist/types/spec-quality.js +0 -6
- package/dist/types/stack/build-tool.d.ts +0 -13
- package/dist/types/stack/build-tool.js +0 -5
- package/dist/types/stack/hypermedia.d.ts +0 -4
- package/dist/types/stack/hypermedia.js +0 -3
- package/dist/types/stack/index.d.ts +0 -4
- package/dist/types/stack/index.js +0 -4
- package/dist/types/stack/recommend.d.ts +0 -38
- package/dist/types/stack/recommend.js +0 -3
- package/dist/types/status.d.ts +0 -27
- package/dist/types/status.js +0 -6
- package/dist/types/storage-catalog.d.ts +0 -21
- package/dist/types/storage-catalog.js +0 -2
- package/dist/types/supply-chain.d.ts +0 -49
- package/dist/types/supply-chain.js +0 -25
- package/dist/types/technology-registry.d.ts +0 -36
- package/dist/types/technology-registry.js +0 -2
- package/dist/types/technology-selection.d.ts +0 -78
- package/dist/types/technology-selection.js +0 -3
- package/dist/types/technology-symbols.generated.d.ts +0 -117
- package/dist/types/technology-symbols.generated.js +0 -2
- package/dist/types/testing.d.ts +0 -17
- package/dist/types/testing.js +0 -10
- package/dist/types/timing.d.ts +0 -18
- package/dist/types/timing.js +0 -3
- package/dist/types/transition-log.d.ts +0 -78
- package/dist/types/transition-log.js +0 -4
- package/dist/types/transport.d.ts +0 -6
- package/dist/types/transport.js +0 -4
- package/dist/types/universal-rules/index.d.ts +0 -69
- package/dist/types/universal-rules/index.js +0 -4
- package/dist/types/validate-worker.d.ts +0 -50
- package/dist/types/validate-worker.js +0 -2
- package/dist/types/validation-config.d.ts +0 -36
- package/dist/types/validation-config.js +0 -2
- package/dist/types/validation-evidence.d.ts +0 -177
- package/dist/types/validation-evidence.js +0 -2
- package/dist/types/validation-loop.d.ts +0 -26
- package/dist/types/validation-loop.js +0 -3
- package/dist/types/validation-receipt.d.ts +0 -126
- package/dist/types/validation-receipt.js +0 -2
- package/dist/types/validation.d.ts +0 -67
- package/dist/types/validation.js +0 -3
- package/dist/types/verifiable-criteria.d.ts +0 -31
- package/dist/types/verifiable-criteria.js +0 -10
- package/src/i18n/messages/en.json +0 -184
- package/src/i18n/messages/es.json +0 -184
- package/src/i18n/messages/pt.json +0 -184
|
@@ -1,1698 +0,0 @@
|
|
|
1
|
-
import { checkGate } from '../engine/clarification-gate/gate.js';
|
|
2
|
-
import { upsertToken, hashQuestions } from '../engine/clarification-gate/token-store.js';
|
|
3
|
-
import { ti } from '../i18n/index.js';
|
|
4
|
-
import { knowledgeStore, specStore } from '../storage/index.js';
|
|
5
|
-
import { loadSpecIndex } from '../storage/spec-index.js';
|
|
6
|
-
import { readTechnologySelectionContract } from '../storage/technology-selection-store.js';
|
|
7
|
-
import { toolResult, interactiveResult } from './response-helpers.js';
|
|
8
|
-
import { readFile, stat as fsStat } from 'node:fs/promises';
|
|
9
|
-
import { createHash, randomUUID } from 'node:crypto';
|
|
10
|
-
import { pathExistsByStat as pathExists } from '../core/shared/fs.js';
|
|
11
|
-
import { basename as pathBasename, dirname as pathDirname, isAbsolute as pathIsAbsolute, join as pathJoin, relative as pathRelative, sep as pathSeparator, } from 'node:path';
|
|
12
|
-
import { withFileLock } from '../storage/file-mutex.js';
|
|
13
|
-
import { enforceRetention } from '../storage/retention.js';
|
|
14
|
-
import { generateBranchName } from './create-spec-helpers.js';
|
|
15
|
-
import { buildSpecContext, computeNextSpecId } from './create-spec/spec-builder.js';
|
|
16
|
-
import { validateConstitution } from './create-spec/constitution-validator.js';
|
|
17
|
-
import { extractCriteria, generateLeanSpecContent, } from '../engine/spec-format/lean-spec-generator.js';
|
|
18
|
-
import { generateLeanTechnicalContent, } from '../engine/spec-format/lean-technical-generator.js';
|
|
19
|
-
import { extractFilesFromSpecBody, extractMarkerDeclaredPaths, } from '../engine/spec-format/technical-md-populator.js';
|
|
20
|
-
import { buildCanonicalUnifiedSpecContent, containsUnresolvedContractPlaceholder, validateUnifiedSpecCandidate, } from '../engine/spec-format/unified-spec-builder.js';
|
|
21
|
-
import { buildImplementationContractSection } from '../engine/implementation-contract/index.js';
|
|
22
|
-
import { updateFrontmatterField } from '../engine/frontmatter-parser.js';
|
|
23
|
-
import { parseBddScenarios, PLACEHOLDER_WHEN_STEP_TEXT } from '../engine/spec-format/bdd-parser.js';
|
|
24
|
-
import { resolveEnglishOnlySpecGate } from '../engine/spec-language/english-only.js';
|
|
25
|
-
import { FallbackGenerator } from '../engine/spec-generator/index.js';
|
|
26
|
-
import { analyzeProjectForSpec, getEmptyAutopilotResult, } from './create-spec/autopilot-analyzer.js';
|
|
27
|
-
import { withBudget, unwrapBudget, withTotalBudget } from '../engine/timing/budget.js';
|
|
28
|
-
import { resolveProjectIdOrAutoDetect } from './resolve-project-id.js';
|
|
29
|
-
import { hashProjectPath, projectDataDir } from '../storage/base-store.js';
|
|
30
|
-
import { issuePlannerToken } from '../engine/reviewer-tokens/issuer.js';
|
|
31
|
-
import { getRuntimePolicy } from '../engine/runtime-policy.js';
|
|
32
|
-
import { generateInteractiveQuestions } from './create-spec/question-generator.js';
|
|
33
|
-
import { buildCriterionGroundingRecords, filterGroundedCriteria, getAdvisoryCriteria, getContractCriteria, } from '../engine/spec-grounding/contract.js';
|
|
34
|
-
import { checkGenericSpecOutput } from '../engine/spec-quality/generic-output-gate.js';
|
|
35
|
-
import { RuntimeDatabase } from '../storage/runtime-db.js';
|
|
36
|
-
import { BoundaryFailure } from '../errors/error-taxonomy.js';
|
|
37
|
-
import { SpecAcFormatEnum, SpecScopeEnum, SpecTargetEnum, SpecTypeEnum } from './schemas/spec.js';
|
|
38
|
-
import { resolveStorageLayout } from '../storage/storage-layout.js';
|
|
39
|
-
import { OperationJournal, recoverOperationJournal, } from '../engine/execution/operation-journal.js';
|
|
40
|
-
import { assertExecutionCanCommit } from '../engine/execution/context.js';
|
|
41
|
-
import { cleanupExecutionArtifact, executionLink, executionMkdir, executionRemove, executionRename, executionWriteFileExclusive, } from '../engine/execution/deadline-io.js';
|
|
42
|
-
import { atomicWriteFile } from '../engine/safety/atomic-write-file.js';
|
|
43
|
-
import { redactPortablePaths } from '../../scripts/lib/portable-paths.mjs';
|
|
44
|
-
/** SPEC-584: Persist a clarification token when interactive questions are emitted. Best-effort. */
|
|
45
|
-
async function persistClarificationToken(earlyReturn, projectId, toolName) {
|
|
46
|
-
try {
|
|
47
|
-
const rawQuestions = earlyReturn.structuredContent?.interactiveQuestions;
|
|
48
|
-
if (!Array.isArray(rawQuestions) || rawQuestions.length === 0) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const emittedQuestions = rawQuestions;
|
|
52
|
-
await upsertToken({
|
|
53
|
-
toolName,
|
|
54
|
-
projectId,
|
|
55
|
-
questionsHash: hashQuestions(emittedQuestions),
|
|
56
|
-
emittedAt: new Date().toISOString(),
|
|
57
|
-
questions: emittedQuestions,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
/* best-effort — token persistence should not block the response */
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/** SPEC-584: Run the clarification gate check for a tool call. Returns error ToolResult or null. */
|
|
65
|
-
async function runClarificationGate(projectPath, toolName, answers) {
|
|
66
|
-
const gateResult = await checkGate({
|
|
67
|
-
projectId: hashProjectPath(projectPath),
|
|
68
|
-
toolName,
|
|
69
|
-
clarificationAnswers: answers,
|
|
70
|
-
});
|
|
71
|
-
return gateResult.allow ? null : gateResult.error;
|
|
72
|
-
}
|
|
73
|
-
function handleClarification(description, knowledge, autopilot, params) {
|
|
74
|
-
if (!autopilot.needsClarification) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
// If the LLM already gathered answers from the user, skip re-asking and proceed.
|
|
78
|
-
const hasAnswers = params.clarificationAnswers !== undefined &&
|
|
79
|
-
Object.keys(params.clarificationAnswers).length > 0;
|
|
80
|
-
if (hasAnswers) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
const generatedQuestions = generateInteractiveQuestions(description, knowledge);
|
|
84
|
-
if (generatedQuestions.length === 0) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
earlyReturn: interactiveResult(generatedQuestions, 'The description needs more detail before a spec can be created. Answer the questions, then retry create_spec with clarificationAnswers or an enriched description.', 'universal'),
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function hasFileEntries(files) {
|
|
92
|
-
return files.create.length + files.modify.length + files.test.length > 0;
|
|
93
|
-
}
|
|
94
|
-
async function resolveTechnicalFiles(input) {
|
|
95
|
-
const generatedSource = [input.generatedTechnicalSection, input.generatedSpecBody]
|
|
96
|
-
.filter((part) => part.trim().length > 0)
|
|
97
|
-
.join('\n\n');
|
|
98
|
-
const extracted = await extractFilesFromSpecBody(generatedSource, input.projectPath);
|
|
99
|
-
if (extracted !== null && hasFileEntries(extracted)) {
|
|
100
|
-
return extracted;
|
|
101
|
-
}
|
|
102
|
-
return { create: [], modify: [], test: [] };
|
|
103
|
-
}
|
|
104
|
-
export async function groundTechnicalFiles(input) {
|
|
105
|
-
const userInput = input.userInput.toLowerCase();
|
|
106
|
-
const autopilotPaths = new Set([
|
|
107
|
-
...input.autopilot.suggestedFiles.modify.map((file) => file.path),
|
|
108
|
-
...input.autopilot.suggestedFiles.create.map((file) => file.path),
|
|
109
|
-
...input.autopilot.suggestedFiles.test.map((file) => file.path),
|
|
110
|
-
]);
|
|
111
|
-
const grounded = {
|
|
112
|
-
create: [],
|
|
113
|
-
modify: [],
|
|
114
|
-
test: [],
|
|
115
|
-
};
|
|
116
|
-
const records = [];
|
|
117
|
-
const advisoryFiles = [];
|
|
118
|
-
const markerPaths = extractMarkerDeclaredPaths(input.userInput);
|
|
119
|
-
for (const section of ['create', 'modify', 'test']) {
|
|
120
|
-
for (const file of input.files[section]) {
|
|
121
|
-
if (markerPaths !== null) {
|
|
122
|
-
if (markerPaths.has(file.path.toLowerCase())) {
|
|
123
|
-
grounded[section].push(file);
|
|
124
|
-
records.push({
|
|
125
|
-
path: file.path,
|
|
126
|
-
section,
|
|
127
|
-
source: 'user_input',
|
|
128
|
-
evidence: ['create_spec.description'],
|
|
129
|
-
confidence: 'high',
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
advisoryFiles.push(file);
|
|
134
|
-
}
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
const pathInUserInput = pathSurvivesNegativeClauseCheck(userInput, file.path.toLowerCase());
|
|
138
|
-
const exists = await pathExists(pathJoin(input.projectPath, file.path));
|
|
139
|
-
const fromAutopilot = autopilotPaths.has(file.path);
|
|
140
|
-
const derivedTest = section === 'test' && isDerivedFromGroundedSource(file.path, grounded.modify);
|
|
141
|
-
const directProjectEvidence = fromAutopilot && exists;
|
|
142
|
-
if (pathInUserInput || directProjectEvidence || derivedTest) {
|
|
143
|
-
grounded[section].push(file);
|
|
144
|
-
records.push({
|
|
145
|
-
path: file.path,
|
|
146
|
-
section,
|
|
147
|
-
source: pathInUserInput ? 'user_input' : 'project_evidence',
|
|
148
|
-
evidence: [
|
|
149
|
-
...(pathInUserInput ? ['create_spec.description'] : []),
|
|
150
|
-
...(directProjectEvidence
|
|
151
|
-
? [`file:${file.path}`, 'autopilot.semantic-file-match']
|
|
152
|
-
: []),
|
|
153
|
-
...(derivedTest ? ['derived-test-path'] : []),
|
|
154
|
-
],
|
|
155
|
-
confidence: pathInUserInput || exists ? 'high' : 'medium',
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
advisoryFiles.push(file);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return { files: grounded, records, advisoryFiles };
|
|
164
|
-
}
|
|
165
|
-
const NEGATIVE_WORK_CLAUSE_RE = /\b(?:remains? unchanged|is not touched|not touched|must not (?:change|be changed|be modified|touch|be touched)|unchanged|out of scope)\b/;
|
|
166
|
-
const CLAUSE_DELIMITERS = ['\n', '. ', '; ', ', and ', ', but '];
|
|
167
|
-
const SENTENCE_DELIMITERS = ['\n', '. '];
|
|
168
|
-
const BACK_REFERENCE_SUBJECT_RE = /^(?:and\s+|but\s+)?(?:it|they|this|that|these|those)\s+(?:must|remains?|stays?|is|are|was|were|should|shall|will|cannot|can|does|do)\b/;
|
|
169
|
-
const PATH_LIKE_TOKEN_RE = /\S+\/\S*\.\w+/;
|
|
170
|
-
const CLAUSE_SPLIT_RE = new RegExp(CLAUSE_DELIMITERS.map((delimiter) => delimiter.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'), 'g');
|
|
171
|
-
function computeDelimitedBounds(text, matchIndex, matchLength, delimiters) {
|
|
172
|
-
const startCandidates = delimiters.map((delimiter) => {
|
|
173
|
-
const index = text.lastIndexOf(delimiter, matchIndex);
|
|
174
|
-
return index === -1 ? -1 : index + delimiter.length;
|
|
175
|
-
});
|
|
176
|
-
const start = Math.max(0, ...startCandidates);
|
|
177
|
-
const searchAfter = matchIndex + matchLength;
|
|
178
|
-
const endCandidates = delimiters
|
|
179
|
-
.map((delimiter) => text.indexOf(delimiter, searchAfter))
|
|
180
|
-
.filter((value) => value !== -1);
|
|
181
|
-
const end = endCandidates.length > 0 ? Math.min(...endCandidates) : text.length;
|
|
182
|
-
return [start, end];
|
|
183
|
-
}
|
|
184
|
-
function findClauseBounds(text, matchIndex, matchLength) {
|
|
185
|
-
return computeDelimitedBounds(text, matchIndex, matchLength, CLAUSE_DELIMITERS);
|
|
186
|
-
}
|
|
187
|
-
function findSentenceBounds(text, matchIndex, matchLength) {
|
|
188
|
-
return computeDelimitedBounds(text, matchIndex, matchLength, SENTENCE_DELIMITERS);
|
|
189
|
-
}
|
|
190
|
-
function splitClausesWithOffsets(sentence, sentenceStart) {
|
|
191
|
-
const clauses = [];
|
|
192
|
-
let cursor = 0;
|
|
193
|
-
CLAUSE_SPLIT_RE.lastIndex = 0;
|
|
194
|
-
let delimiterMatch = CLAUSE_SPLIT_RE.exec(sentence);
|
|
195
|
-
while (delimiterMatch !== null) {
|
|
196
|
-
clauses.push([sentence.slice(cursor, delimiterMatch.index), sentenceStart + cursor]);
|
|
197
|
-
cursor = delimiterMatch.index + delimiterMatch[0].length;
|
|
198
|
-
delimiterMatch = CLAUSE_SPLIT_RE.exec(sentence);
|
|
199
|
-
}
|
|
200
|
-
clauses.push([sentence.slice(cursor), sentenceStart + cursor]);
|
|
201
|
-
return clauses;
|
|
202
|
-
}
|
|
203
|
-
function sentenceHasBackReferencedNegation(userInput, matchIndex, matchLength) {
|
|
204
|
-
const [sentenceStart, sentenceEnd] = findSentenceBounds(userInput, matchIndex, matchLength);
|
|
205
|
-
const sentence = userInput.slice(sentenceStart, sentenceEnd);
|
|
206
|
-
const clauses = splitClausesWithOffsets(sentence, sentenceStart);
|
|
207
|
-
const matchEnd = matchIndex + matchLength;
|
|
208
|
-
const currentClauseIndex = clauses.findIndex(([clauseText, clauseStart]) => matchIndex >= clauseStart && matchEnd <= clauseStart + clauseText.length);
|
|
209
|
-
if (currentClauseIndex === -1) {
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
const currentClauseEntry = clauses[currentClauseIndex];
|
|
213
|
-
if (currentClauseEntry === undefined) {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
const [currentClauseText, currentClauseStart] = currentClauseEntry;
|
|
217
|
-
const currentClauseTail = currentClauseText.slice(matchEnd - currentClauseStart);
|
|
218
|
-
if (PATH_LIKE_TOKEN_RE.test(currentClauseTail)) {
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
for (let index = currentClauseIndex + 1; index < clauses.length; index += 1) {
|
|
222
|
-
const clauseEntry = clauses[index];
|
|
223
|
-
if (clauseEntry === undefined) {
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
const [clauseText] = clauseEntry;
|
|
227
|
-
if (PATH_LIKE_TOKEN_RE.test(clauseText)) {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
const trimmedClause = clauseText.replace(/^\s+/, '');
|
|
231
|
-
if (BACK_REFERENCE_SUBJECT_RE.test(trimmedClause) &&
|
|
232
|
-
NEGATIVE_WORK_CLAUSE_RE.test(trimmedClause)) {
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return false;
|
|
237
|
-
}
|
|
238
|
-
function pathSurvivesNegativeClauseCheck(userInput, lowerPath) {
|
|
239
|
-
let searchFrom = 0;
|
|
240
|
-
for (;;) {
|
|
241
|
-
const matchIndex = userInput.indexOf(lowerPath, searchFrom);
|
|
242
|
-
if (matchIndex === -1) {
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
const [clauseStart, clauseEnd] = findClauseBounds(userInput, matchIndex, lowerPath.length);
|
|
246
|
-
const clause = userInput.slice(clauseStart, clauseEnd);
|
|
247
|
-
const ownClauseNegated = NEGATIVE_WORK_CLAUSE_RE.test(clause);
|
|
248
|
-
const backReferencedNegation = sentenceHasBackReferencedNegation(userInput, matchIndex, lowerPath.length);
|
|
249
|
-
if (!ownClauseNegated && !backReferencedNegation) {
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
|
-
searchFrom = matchIndex + lowerPath.length;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function isDerivedFromGroundedSource(testPath, modifyFiles) {
|
|
256
|
-
return modifyFiles.some((file) => {
|
|
257
|
-
const withoutSrc = file.path.startsWith('src/') ? file.path.slice(4) : file.path;
|
|
258
|
-
const ext = withoutSrc.replace(/^.*(\.[^.]+)$/, '$1');
|
|
259
|
-
const base = withoutSrc.slice(0, -ext.length);
|
|
260
|
-
return testPath === `tests/${base}.test${ext}` || testPath === `tests/${withoutSrc}`;
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
const HIGH_RISK_WARNING = 'High-risk spec — consider: ' +
|
|
264
|
-
'1) Is the approach technically feasible within the project constraints? ' +
|
|
265
|
-
'2) What edge cases (network failure, concurrent writes, empty state) could break this? ' +
|
|
266
|
-
'3) Which existing specs or external services does this depend on?';
|
|
267
|
-
function makeAdvisorySignal(args) {
|
|
268
|
-
return { ...args, persistable: false };
|
|
269
|
-
}
|
|
270
|
-
function buildAdvisoryCompat() {
|
|
271
|
-
return {
|
|
272
|
-
legacyTopLevelAdvisoryFields: true,
|
|
273
|
-
deprecatedAfter: 'vNext+2',
|
|
274
|
-
canonicalField: 'advisorySignals',
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
/** Persist only out-of-scope items supplied explicitly by the caller. */
|
|
278
|
-
function resolveOutOfScope(provided, source = '') {
|
|
279
|
-
const explicit = provided?.filter((item) => item.trim().length > 0) ?? [];
|
|
280
|
-
if (explicit.length > 0) {
|
|
281
|
-
return explicit;
|
|
282
|
-
}
|
|
283
|
-
const section = /(?:^|\n)##\s+Out of scope\s*\n([\s\S]*?)(?=\n##\s|$)/i.exec(source)?.[1];
|
|
284
|
-
return section
|
|
285
|
-
? Array.from(section.matchAll(/^[-*]\s+(.+)$/gm), (match) => match[1]?.trim() ?? '').filter(Boolean)
|
|
286
|
-
: [];
|
|
287
|
-
}
|
|
288
|
-
/** Redact absolute repo/home paths from every free-text field before it enters the store. */
|
|
289
|
-
function redactCreateSpecInput(params, root) {
|
|
290
|
-
const options = { root };
|
|
291
|
-
return {
|
|
292
|
-
...params,
|
|
293
|
-
title: redactPortablePaths(params.title, options),
|
|
294
|
-
description: redactPortablePaths(params.description, options),
|
|
295
|
-
outOfScope: params.outOfScope?.map((item) => redactPortablePaths(item, options)),
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
/** Derive a bounded storage key from an explicit caller key or the legacy request identity. */
|
|
299
|
-
function computeIdempotencyKey(title, projectPath, explicitKey) {
|
|
300
|
-
const identity = explicitKey ? `explicit::${explicitKey}` : `${title}::${projectPath}`;
|
|
301
|
-
return createHash('sha256').update(identity).digest('hex');
|
|
302
|
-
}
|
|
303
|
-
function createSpecRequestDigest(params, projectPath) {
|
|
304
|
-
return createHash('sha256')
|
|
305
|
-
.update(JSON.stringify({ ...params, projectPath, idempotencyKey: undefined }))
|
|
306
|
-
.digest('hex');
|
|
307
|
-
}
|
|
308
|
-
function computeOperationKey(params, projectPath, dedupeKey) {
|
|
309
|
-
const identity = params.idempotencyKey
|
|
310
|
-
? `explicit::${params.idempotencyKey}`
|
|
311
|
-
: `implicit::${dedupeKey}::${params.description}::${randomUUID()}`;
|
|
312
|
-
return createHash('sha256').update(`${identity}::${projectPath}`).digest('hex');
|
|
313
|
-
}
|
|
314
|
-
function finishRecoveredOperation(journal, key, result) {
|
|
315
|
-
let entry = journal.get('create_spec', key);
|
|
316
|
-
if (entry?.state === 'intent') {
|
|
317
|
-
entry = journal.prepared('create_spec', key);
|
|
318
|
-
}
|
|
319
|
-
if (entry?.state === 'prepared') {
|
|
320
|
-
entry = journal.committed('create_spec', key, result);
|
|
321
|
-
}
|
|
322
|
-
if (entry?.state === 'committed') {
|
|
323
|
-
entry = journal.acknowledged('create_spec', key);
|
|
324
|
-
}
|
|
325
|
-
return entry?.result ?? result;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* SPEC-1348: release the journal claim of an attempt that failed before commit.
|
|
329
|
-
* Rolling back marks the key re-claimable; committed entries are left untouched
|
|
330
|
-
* because recovery resolution only acts on active (intent/prepared) states.
|
|
331
|
-
*/
|
|
332
|
-
function rollbackUncommittedOperation(journal, key, reason) {
|
|
333
|
-
try {
|
|
334
|
-
journal.resolveRecovery('create_spec', key, { action: 'rollback', reason });
|
|
335
|
-
}
|
|
336
|
-
catch {
|
|
337
|
-
// Best-effort: the original failure remains the primary error.
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
function buildCommittedCreateResult(input) {
|
|
341
|
-
const advisorySignals = [];
|
|
342
|
-
if (input.advisoryCriteria.length > 0) {
|
|
343
|
-
advisorySignals.push(makeAdvisorySignal({
|
|
344
|
-
key: 'ungrounded-contract-items',
|
|
345
|
-
kind: 'quality',
|
|
346
|
-
message: `${String(input.advisoryCriteria.length)} ungrounded contract item(s) kept advisory-only.`,
|
|
347
|
-
source: 'validator',
|
|
348
|
-
evidence: input.advisoryCriteria.slice(0, 10),
|
|
349
|
-
confidence: 0.8,
|
|
350
|
-
surface: 'structuredContent',
|
|
351
|
-
value: input.advisoryCriteria,
|
|
352
|
-
}));
|
|
353
|
-
}
|
|
354
|
-
const spec = input.spec;
|
|
355
|
-
const riskWarning = spec.risk === 'high' || spec.difficulty >= 4 ? HIGH_RISK_WARNING : undefined;
|
|
356
|
-
if (riskWarning) {
|
|
357
|
-
advisorySignals.push(makeAdvisorySignal({
|
|
358
|
-
key: 'risk-warning',
|
|
359
|
-
kind: 'challenge',
|
|
360
|
-
message: 'High-risk heuristic warning generated.',
|
|
361
|
-
source: 'heuristic',
|
|
362
|
-
evidence: [`risk:${spec.risk}`, `difficulty:${String(spec.difficulty)}`],
|
|
363
|
-
confidence: 0.6,
|
|
364
|
-
surface: 'structuredContent',
|
|
365
|
-
value: riskWarning,
|
|
366
|
-
deprecatedAlias: 'riskWarning',
|
|
367
|
-
}));
|
|
368
|
-
}
|
|
369
|
-
return toolResult(`Spec ${spec.id} created and persisted.`, {
|
|
370
|
-
operationId: input.operationId,
|
|
371
|
-
/** @deprecated Operation-journal durability; this is not Git evidence. */
|
|
372
|
-
committed: true,
|
|
373
|
-
persisted: true,
|
|
374
|
-
gitCommitPerformed: false,
|
|
375
|
-
specId: spec.id,
|
|
376
|
-
title: spec.title,
|
|
377
|
-
slug: spec.slug,
|
|
378
|
-
type: spec.type,
|
|
379
|
-
scope: spec.scope,
|
|
380
|
-
difficulty: spec.difficulty,
|
|
381
|
-
risk: spec.risk,
|
|
382
|
-
tags: spec.tags,
|
|
383
|
-
target: spec.target,
|
|
384
|
-
status: spec.status,
|
|
385
|
-
gitBranch: spec.gitBranch,
|
|
386
|
-
specPath: spec.specPath,
|
|
387
|
-
...(input.duplicate
|
|
388
|
-
? { duplicateWarning: ti('spec.duplicateTitle', { title: spec.title, slug: spec.slug }) }
|
|
389
|
-
: {}),
|
|
390
|
-
...(input.constitutionWarnings.length > 0
|
|
391
|
-
? { constitutionWarnings: input.constitutionWarnings }
|
|
392
|
-
: {}),
|
|
393
|
-
...(input.clarificationSession
|
|
394
|
-
? {
|
|
395
|
-
linkedClarificationSession: input.clarificationSession.id,
|
|
396
|
-
clarificationTopic: input.clarificationSession.topic,
|
|
397
|
-
clarificationAnswersUsed: Object.keys(input.clarificationSession.answers).length,
|
|
398
|
-
}
|
|
399
|
-
: {
|
|
400
|
-
clarificationNote: 'Spec created directly from the supplied description; no clarification session was linked.',
|
|
401
|
-
}),
|
|
402
|
-
...(input.contradictionHint ? { contradictionHint: input.contradictionHint } : {}),
|
|
403
|
-
...(riskWarning ? { riskWarning } : {}),
|
|
404
|
-
...(input.plannerToken ? { plannerToken: input.plannerToken } : {}),
|
|
405
|
-
...(advisorySignals.length > 0 ? { advisorySignals } : {}),
|
|
406
|
-
compat: buildAdvisoryCompat(),
|
|
407
|
-
message: ti('tools.create_spec.success', { id: spec.id, title: spec.title }),
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
const CREATE_SPEC_POLICY = getRuntimePolicy().createSpec;
|
|
411
|
-
const IDEMPOTENCY_CLAIM_STALE_MS = CREATE_SPEC_POLICY.idempotencyClaimStaleMs;
|
|
412
|
-
const IDEMPOTENCY_CLAIM_WAIT_MS = CREATE_SPEC_POLICY.idempotencyClaimWaitMs;
|
|
413
|
-
const IDEMPOTENCY_CLAIM_POLL_MS = CREATE_SPEC_POLICY.idempotencyClaimPollMs;
|
|
414
|
-
const IDEMPOTENCY_MATCH_WINDOW_MS = CREATE_SPEC_POLICY.idempotencyMatchWindowMs;
|
|
415
|
-
function getIdempotencyEvidencePath(projectPath, key) {
|
|
416
|
-
return pathJoin(projectDataDir(hashProjectPath(projectPath)), 'create-spec-idempotency', `${key}.json`);
|
|
417
|
-
}
|
|
418
|
-
function getIdempotencyClaimPath(projectPath, key) {
|
|
419
|
-
return getIdempotencyEvidencePath(projectPath, key).replace(/\.json$/, '.claim.json');
|
|
420
|
-
}
|
|
421
|
-
function parseIdempotencyEvidence(raw) {
|
|
422
|
-
try {
|
|
423
|
-
const value = JSON.parse(raw);
|
|
424
|
-
if (value === null || typeof value !== 'object') {
|
|
425
|
-
return undefined;
|
|
426
|
-
}
|
|
427
|
-
const record = value;
|
|
428
|
-
if ((record.version !== 1 && record.version !== 2) ||
|
|
429
|
-
(record.version === 2 && record.state !== 'committed') ||
|
|
430
|
-
(record.version === 2 && typeof record.ownerId !== 'string') ||
|
|
431
|
-
typeof record.key !== 'string' ||
|
|
432
|
-
typeof record.specId !== 'string' ||
|
|
433
|
-
!/^SPEC-\d+$/.test(record.specId) ||
|
|
434
|
-
typeof record.title !== 'string' ||
|
|
435
|
-
typeof record.status !== 'string' ||
|
|
436
|
-
typeof record.specPath !== 'string' ||
|
|
437
|
-
typeof record.createdAt !== 'string' ||
|
|
438
|
-
!Number.isFinite(Date.parse(record.createdAt)) ||
|
|
439
|
-
(record.version === 2 &&
|
|
440
|
-
(typeof record.committedAt !== 'string' ||
|
|
441
|
-
!Number.isFinite(Date.parse(record.committedAt))))) {
|
|
442
|
-
return undefined;
|
|
443
|
-
}
|
|
444
|
-
return record;
|
|
445
|
-
}
|
|
446
|
-
catch {
|
|
447
|
-
return undefined;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
function parseIdempotencyClaim(raw) {
|
|
451
|
-
try {
|
|
452
|
-
const value = JSON.parse(raw);
|
|
453
|
-
if (value === null || typeof value !== 'object') {
|
|
454
|
-
return undefined;
|
|
455
|
-
}
|
|
456
|
-
const record = value;
|
|
457
|
-
if (record.version !== 2 ||
|
|
458
|
-
record.state !== 'intent' ||
|
|
459
|
-
typeof record.key !== 'string' ||
|
|
460
|
-
typeof record.title !== 'string' ||
|
|
461
|
-
typeof record.ownerId !== 'string' ||
|
|
462
|
-
record.ownerId.length === 0 ||
|
|
463
|
-
typeof record.claimedAt !== 'string' ||
|
|
464
|
-
!Number.isFinite(Date.parse(record.claimedAt))) {
|
|
465
|
-
return undefined;
|
|
466
|
-
}
|
|
467
|
-
return record;
|
|
468
|
-
}
|
|
469
|
-
catch {
|
|
470
|
-
return undefined;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
function isSafeSpecPath(projectPath, specPath) {
|
|
474
|
-
const relativePath = pathRelative(pathJoin(projectPath, 'planu', 'specs'), specPath);
|
|
475
|
-
return (relativePath.length > 0 &&
|
|
476
|
-
!pathIsAbsolute(relativePath) &&
|
|
477
|
-
relativePath !== '..' &&
|
|
478
|
-
!relativePath.startsWith(`..${pathSeparator}`) &&
|
|
479
|
-
relativePath.endsWith(`${pathSeparator}spec.md`));
|
|
480
|
-
}
|
|
481
|
-
async function findByIdempotencyEvidence(projectPath, key, cutoff, expectedOwnerId) {
|
|
482
|
-
const raw = await readFile(getIdempotencyEvidencePath(projectPath, key), 'utf-8').catch(() => '');
|
|
483
|
-
const evidence = parseIdempotencyEvidence(raw);
|
|
484
|
-
if (evidence === undefined) {
|
|
485
|
-
return undefined;
|
|
486
|
-
}
|
|
487
|
-
if (evidence.key !== key ||
|
|
488
|
-
(expectedOwnerId !== undefined &&
|
|
489
|
-
evidence.ownerId !== undefined &&
|
|
490
|
-
evidence.ownerId !== expectedOwnerId) ||
|
|
491
|
-
Date.parse(evidence.createdAt) <= cutoff ||
|
|
492
|
-
!isSafeSpecPath(projectPath, evidence.specPath)) {
|
|
493
|
-
return undefined;
|
|
494
|
-
}
|
|
495
|
-
const fileStat = await fsStat(evidence.specPath).catch(() => null);
|
|
496
|
-
if (fileStat === null) {
|
|
497
|
-
return undefined;
|
|
498
|
-
}
|
|
499
|
-
const content = await readFile(evidence.specPath, 'utf-8').catch(() => '');
|
|
500
|
-
const idMatch = FRONTMATTER_ID_RE.exec(content);
|
|
501
|
-
if (idMatch?.[1] !== evidence.specId) {
|
|
502
|
-
return undefined;
|
|
503
|
-
}
|
|
504
|
-
const status = FRONTMATTER_STATUS_RE.exec(content)?.[1] ?? evidence.status;
|
|
505
|
-
return {
|
|
506
|
-
id: evidence.specId,
|
|
507
|
-
title: evidence.title,
|
|
508
|
-
status: status,
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
async function commitIdempotencyEvidence(projectPath, key, claim, spec, specPath) {
|
|
512
|
-
const evidencePath = getIdempotencyEvidencePath(projectPath, key);
|
|
513
|
-
const claimRaw = await readFile(getIdempotencyClaimPath(projectPath, key), 'utf-8').catch(() => '');
|
|
514
|
-
const activeClaim = parseIdempotencyClaim(claimRaw);
|
|
515
|
-
if (activeClaim?.ownerId !== claim.ownerId || activeClaim.key !== key) {
|
|
516
|
-
throw new Error('Idempotency claim ownership changed before commit');
|
|
517
|
-
}
|
|
518
|
-
const committedAt = new Date().toISOString();
|
|
519
|
-
const evidence = {
|
|
520
|
-
version: 2,
|
|
521
|
-
state: 'committed',
|
|
522
|
-
ownerId: claim.ownerId,
|
|
523
|
-
key,
|
|
524
|
-
specId: spec.id,
|
|
525
|
-
title: spec.title,
|
|
526
|
-
status: spec.status,
|
|
527
|
-
specPath,
|
|
528
|
-
createdAt: committedAt,
|
|
529
|
-
committedAt,
|
|
530
|
-
};
|
|
531
|
-
try {
|
|
532
|
-
await executionWriteFileExclusive(evidencePath, JSON.stringify(evidence, null, 2), {
|
|
533
|
-
encoding: 'utf-8',
|
|
534
|
-
});
|
|
535
|
-
await enforceRetention({ kind: 'idempotency', path: pathDirname(evidencePath) });
|
|
536
|
-
}
|
|
537
|
-
catch (error) {
|
|
538
|
-
if (error.code !== 'EEXIST') {
|
|
539
|
-
throw error;
|
|
540
|
-
}
|
|
541
|
-
const existingRaw = await readFile(evidencePath, 'utf-8').catch(() => '');
|
|
542
|
-
const existing = parseIdempotencyEvidence(existingRaw);
|
|
543
|
-
if (existing?.ownerId === claim.ownerId && existing.specId === spec.id) {
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
throw new Error('Idempotency evidence already committed by another request', {
|
|
547
|
-
cause: error,
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
async function releaseIdempotencyClaim(projectPath, key, ownerId) {
|
|
552
|
-
const claimPath = getIdempotencyClaimPath(projectPath, key);
|
|
553
|
-
const raw = await readFile(claimPath, 'utf-8').catch(() => '');
|
|
554
|
-
if (parseIdempotencyClaim(raw)?.ownerId === ownerId) {
|
|
555
|
-
await quarantineAndDeleteIdempotencyClaim(claimPath, raw);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
async function decideCreateSpecRecovery(entry) {
|
|
559
|
-
const payload = entry.payload;
|
|
560
|
-
if (entry.payloadVersion !== 1 || payload?.operationVersion !== 1) {
|
|
561
|
-
return { action: 'quarantine', reason: 'Unsupported create_spec recovery payload' };
|
|
562
|
-
}
|
|
563
|
-
if (entry.state === 'intent') {
|
|
564
|
-
if (payload.ownerId) {
|
|
565
|
-
await releaseIdempotencyClaim(payload.projectPath, payload.idempotencyKey, payload.ownerId);
|
|
566
|
-
}
|
|
567
|
-
return { action: 'rollback', reason: 'Intent has no prepared durable side effects' };
|
|
568
|
-
}
|
|
569
|
-
if (!payload.projectId ||
|
|
570
|
-
!payload.specId ||
|
|
571
|
-
!payload.specPath ||
|
|
572
|
-
!payload.specContentDigest ||
|
|
573
|
-
!payload.result) {
|
|
574
|
-
return { action: 'quarantine', reason: 'Prepared payload is incomplete' };
|
|
575
|
-
}
|
|
576
|
-
const [content, storedSpec, evidenceRaw] = await Promise.all([
|
|
577
|
-
readFile(payload.specPath, 'utf8').catch(() => ''),
|
|
578
|
-
specStore.getSpec(payload.projectId, payload.specId).catch(() => null),
|
|
579
|
-
readFile(getIdempotencyEvidencePath(payload.projectPath, payload.idempotencyKey), 'utf8').catch(() => ''),
|
|
580
|
-
]);
|
|
581
|
-
const evidence = parseIdempotencyEvidence(evidenceRaw);
|
|
582
|
-
const isCommitted = createHash('sha256').update(content).digest('hex') === payload.specContentDigest &&
|
|
583
|
-
storedSpec?.id === payload.specId &&
|
|
584
|
-
evidence?.specId === payload.specId &&
|
|
585
|
-
(!payload.ownerId || !evidence.ownerId || evidence.ownerId === payload.ownerId);
|
|
586
|
-
if (isCommitted) {
|
|
587
|
-
return {
|
|
588
|
-
action: 'commit',
|
|
589
|
-
result: payload.result,
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
|
-
const noDurableArtifacts = content.length === 0 && storedSpec === null && evidence === undefined;
|
|
593
|
-
if (noDurableArtifacts) {
|
|
594
|
-
if (payload.ownerId) {
|
|
595
|
-
await releaseIdempotencyClaim(payload.projectPath, payload.idempotencyKey, payload.ownerId);
|
|
596
|
-
}
|
|
597
|
-
return { action: 'rollback', reason: 'Prepared mutation has no durable artifacts' };
|
|
598
|
-
}
|
|
599
|
-
return {
|
|
600
|
-
action: 'quarantine',
|
|
601
|
-
reason: 'Prepared create_spec artifacts are partial or inconsistent',
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
async function quarantineAndDeleteIdempotencyClaim(claimPath, expectedRaw) {
|
|
605
|
-
const quarantinePath = `${claimPath}.${randomUUID()}.quarantine`;
|
|
606
|
-
try {
|
|
607
|
-
await executionRename(claimPath, quarantinePath);
|
|
608
|
-
}
|
|
609
|
-
catch (error) {
|
|
610
|
-
if (error.code === 'ENOENT') {
|
|
611
|
-
return false;
|
|
612
|
-
}
|
|
613
|
-
throw error;
|
|
614
|
-
}
|
|
615
|
-
const quarantinedRaw = await readFile(quarantinePath, 'utf-8').catch(() => '');
|
|
616
|
-
if (quarantinedRaw === expectedRaw) {
|
|
617
|
-
await executionRemove(quarantinePath, { force: true });
|
|
618
|
-
return true;
|
|
619
|
-
}
|
|
620
|
-
try {
|
|
621
|
-
await executionLink(quarantinePath, claimPath);
|
|
622
|
-
}
|
|
623
|
-
catch (error) {
|
|
624
|
-
if (error.code !== 'EEXIST') {
|
|
625
|
-
throw error;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
await executionRemove(quarantinePath, { force: true });
|
|
629
|
-
return false;
|
|
630
|
-
}
|
|
631
|
-
async function waitForIdempotencyOwner(projectPath, key, claim) {
|
|
632
|
-
const deadline = Date.now() + IDEMPOTENCY_CLAIM_WAIT_MS;
|
|
633
|
-
const cutoff = Date.now() - IDEMPOTENCY_MATCH_WINDOW_MS;
|
|
634
|
-
while (Date.now() < deadline) {
|
|
635
|
-
const existing = await findByIdempotencyEvidence(projectPath, key, cutoff, claim.ownerId);
|
|
636
|
-
if (existing !== undefined) {
|
|
637
|
-
return { kind: 'existing', spec: existing };
|
|
638
|
-
}
|
|
639
|
-
const currentRaw = await readFile(getIdempotencyClaimPath(projectPath, key), 'utf-8').catch(() => '');
|
|
640
|
-
const current = parseIdempotencyClaim(currentRaw);
|
|
641
|
-
if (current?.ownerId !== claim.ownerId) {
|
|
642
|
-
return undefined;
|
|
643
|
-
}
|
|
644
|
-
if (Date.now() - Date.parse(current.claimedAt) > IDEMPOTENCY_CLAIM_STALE_MS) {
|
|
645
|
-
await releaseIdempotencyClaim(projectPath, key, current.ownerId);
|
|
646
|
-
return undefined;
|
|
647
|
-
}
|
|
648
|
-
await new Promise((resolve) => setTimeout(resolve, IDEMPOTENCY_CLAIM_POLL_MS));
|
|
649
|
-
}
|
|
650
|
-
return { kind: 'pending' };
|
|
651
|
-
}
|
|
652
|
-
async function acquireIdempotencyClaim(projectPath, key, title) {
|
|
653
|
-
const claimPath = getIdempotencyClaimPath(projectPath, key);
|
|
654
|
-
await executionMkdir(pathDirname(claimPath), { recursive: true });
|
|
655
|
-
for (let attempt = 0; attempt < 4; attempt += 1) {
|
|
656
|
-
const claim = {
|
|
657
|
-
version: 2,
|
|
658
|
-
state: 'intent',
|
|
659
|
-
key,
|
|
660
|
-
title,
|
|
661
|
-
ownerId: randomUUID(),
|
|
662
|
-
claimedAt: new Date().toISOString(),
|
|
663
|
-
};
|
|
664
|
-
try {
|
|
665
|
-
await executionWriteFileExclusive(claimPath, JSON.stringify(claim, null, 2), {
|
|
666
|
-
encoding: 'utf-8',
|
|
667
|
-
});
|
|
668
|
-
const racedCommit = await findByIdempotencyEvidence(projectPath, key, Date.now() - IDEMPOTENCY_MATCH_WINDOW_MS);
|
|
669
|
-
if (racedCommit !== undefined) {
|
|
670
|
-
await releaseIdempotencyClaim(projectPath, key, claim.ownerId);
|
|
671
|
-
return { kind: 'existing', spec: racedCommit };
|
|
672
|
-
}
|
|
673
|
-
const expiredEvidencePath = getIdempotencyEvidencePath(projectPath, key);
|
|
674
|
-
if ((await fsStat(expiredEvidencePath).catch(() => null)) !== null) {
|
|
675
|
-
await executionRemove(expiredEvidencePath, { force: true });
|
|
676
|
-
}
|
|
677
|
-
return { kind: 'owner', claim };
|
|
678
|
-
}
|
|
679
|
-
catch (error) {
|
|
680
|
-
if (error.code !== 'EEXIST') {
|
|
681
|
-
throw error;
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
const existingRaw = await readFile(claimPath, 'utf-8').catch(() => '');
|
|
685
|
-
const existingClaim = parseIdempotencyClaim(existingRaw);
|
|
686
|
-
if (existingClaim?.key !== key) {
|
|
687
|
-
const claimStat = await fsStat(claimPath).catch(() => null);
|
|
688
|
-
if (claimStat !== null && Date.now() - claimStat.mtimeMs > IDEMPOTENCY_CLAIM_STALE_MS) {
|
|
689
|
-
await quarantineAndDeleteIdempotencyClaim(claimPath, existingRaw);
|
|
690
|
-
continue;
|
|
691
|
-
}
|
|
692
|
-
return { kind: 'pending' };
|
|
693
|
-
}
|
|
694
|
-
if (Date.now() - Date.parse(existingClaim.claimedAt) > IDEMPOTENCY_CLAIM_STALE_MS) {
|
|
695
|
-
await releaseIdempotencyClaim(projectPath, key, existingClaim.ownerId);
|
|
696
|
-
continue;
|
|
697
|
-
}
|
|
698
|
-
const waited = await waitForIdempotencyOwner(projectPath, key, existingClaim);
|
|
699
|
-
if (waited !== undefined) {
|
|
700
|
-
return waited;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
return { kind: 'pending' };
|
|
704
|
-
}
|
|
705
|
-
/**
|
|
706
|
-
* SPEC-781: Check if async analysis has completed for a given spec.
|
|
707
|
-
* Returns { pending: true } when external analysis state is absent.
|
|
708
|
-
*/
|
|
709
|
-
function buildIdempotencyMatchResult(_projectPath, existing) {
|
|
710
|
-
return Promise.resolve({
|
|
711
|
-
content: [
|
|
712
|
-
{
|
|
713
|
-
type: 'text',
|
|
714
|
-
text: `spec already exists: ${existing.id} — returning existing spec to avoid duplicate.\n\nTitle: ${existing.title}\nStatus: ${existing.status}\n\nNo new spec was created.`,
|
|
715
|
-
},
|
|
716
|
-
],
|
|
717
|
-
structuredContent: {
|
|
718
|
-
specId: existing.id,
|
|
719
|
-
title: existing.title,
|
|
720
|
-
status: existing.status,
|
|
721
|
-
message: `spec already exists: ${existing.id}`,
|
|
722
|
-
idempotencyMatch: true,
|
|
723
|
-
},
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
const FRONTMATTER_ID_RE = /^id:\s*(SPEC-\d+)/m;
|
|
727
|
-
const FRONTMATTER_STATUS_RE = /^status:\s*(\S+)/m;
|
|
728
|
-
async function findStoreByIdempotencyKey(projectId, key, cutoff) {
|
|
729
|
-
try {
|
|
730
|
-
const existing = await specStore.listSpecs(projectId);
|
|
731
|
-
return existing.find((s) => s.idempotencyKey === key && new Date(s.createdAt).getTime() > cutoff);
|
|
732
|
-
}
|
|
733
|
-
catch {
|
|
734
|
-
return undefined;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
/** SPEC-770: Scan store and filesystem for a spec with matching idempotency key within windowMs. */
|
|
738
|
-
async function findByIdempotencyKey(projectPath, key, projectId, windowMs = IDEMPOTENCY_MATCH_WINDOW_MS) {
|
|
739
|
-
const cutoff = Date.now() - windowMs;
|
|
740
|
-
const storeMatch = await findStoreByIdempotencyKey(projectId, key, cutoff);
|
|
741
|
-
if (storeMatch) {
|
|
742
|
-
return storeMatch;
|
|
743
|
-
}
|
|
744
|
-
const evidenceMatch = await findByIdempotencyEvidence(projectPath, key, cutoff);
|
|
745
|
-
if (evidenceMatch !== undefined) {
|
|
746
|
-
return evidenceMatch;
|
|
747
|
-
}
|
|
748
|
-
try {
|
|
749
|
-
const globModule = await import('glob');
|
|
750
|
-
const specFiles = await globModule.glob(pathJoin(projectPath, 'planu/specs/*/spec.md'));
|
|
751
|
-
for (const specFile of specFiles) {
|
|
752
|
-
const fileStat = await fsStat(specFile).catch(() => null);
|
|
753
|
-
if (fileStat === null || fileStat.mtimeMs < cutoff) {
|
|
754
|
-
continue;
|
|
755
|
-
}
|
|
756
|
-
const content = await readFile(specFile, 'utf-8').catch(() => '');
|
|
757
|
-
const idMatch = FRONTMATTER_ID_RE.exec(content);
|
|
758
|
-
const statusMatch = FRONTMATTER_STATUS_RE.exec(content);
|
|
759
|
-
const explicitKeyMatch = /^idempotencyKey:\s*["']?([a-f0-9]{64})["']?\s*$/m.exec(content);
|
|
760
|
-
if (idMatch?.[1] !== undefined && explicitKeyMatch?.[1] === key) {
|
|
761
|
-
const specStatus = statusMatch?.[1] ?? 'draft';
|
|
762
|
-
return {
|
|
763
|
-
id: idMatch[1],
|
|
764
|
-
title: idMatch[1],
|
|
765
|
-
status: specStatus,
|
|
766
|
-
};
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
catch {
|
|
771
|
-
/* best-effort */
|
|
772
|
-
}
|
|
773
|
-
return undefined;
|
|
774
|
-
}
|
|
775
|
-
/** SPEC-770: Scan for recently written spec.md files (for possibleDuplicates in timeout response). */
|
|
776
|
-
async function findRecentlyWrittenSpecs(projectPath, windowMs, requestedTitle) {
|
|
777
|
-
try {
|
|
778
|
-
const globModule = await import('glob');
|
|
779
|
-
const cutoff = Date.now() - windowMs;
|
|
780
|
-
const specFiles = await globModule.glob(pathJoin(projectPath, 'planu/specs/*/spec.md'));
|
|
781
|
-
const results = [];
|
|
782
|
-
for (const specFile of specFiles) {
|
|
783
|
-
const fileStat = await fsStat(specFile).catch(() => null);
|
|
784
|
-
if (fileStat === null || fileStat.mtimeMs < cutoff) {
|
|
785
|
-
continue;
|
|
786
|
-
}
|
|
787
|
-
const content = await readFile(specFile, 'utf-8').catch(() => '');
|
|
788
|
-
const idMatch = FRONTMATTER_ID_RE.exec(content);
|
|
789
|
-
const title = extractFrontmatterTitle(content);
|
|
790
|
-
if (idMatch?.[1] !== undefined &&
|
|
791
|
-
normalizeDuplicateTitle(title) !== '' &&
|
|
792
|
-
normalizeDuplicateTitle(title) === normalizeDuplicateTitle(requestedTitle)) {
|
|
793
|
-
results.push({ id: idMatch[1], title });
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
return results;
|
|
797
|
-
}
|
|
798
|
-
catch {
|
|
799
|
-
return [];
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
function extractFrontmatterTitle(content) {
|
|
803
|
-
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(content)?.[1];
|
|
804
|
-
const rawTitle = frontmatter ? /^title:\s*(.*?)\s*$/m.exec(frontmatter)?.[1] : undefined;
|
|
805
|
-
if (!rawTitle) {
|
|
806
|
-
return '';
|
|
807
|
-
}
|
|
808
|
-
if (rawTitle.startsWith('"') && rawTitle.endsWith('"')) {
|
|
809
|
-
try {
|
|
810
|
-
const parsed = JSON.parse(rawTitle);
|
|
811
|
-
return typeof parsed === 'string' ? parsed : '';
|
|
812
|
-
}
|
|
813
|
-
catch {
|
|
814
|
-
return '';
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
if (rawTitle.startsWith("'") && rawTitle.endsWith("'")) {
|
|
818
|
-
return rawTitle.slice(1, -1).replace(/''/g, "'");
|
|
819
|
-
}
|
|
820
|
-
return rawTitle;
|
|
821
|
-
}
|
|
822
|
-
function normalizeDuplicateTitle(value) {
|
|
823
|
-
return value
|
|
824
|
-
.normalize('NFKC')
|
|
825
|
-
.toLocaleLowerCase('en-US')
|
|
826
|
-
.replace(/[\p{P}]+/gu, ' ')
|
|
827
|
-
.replace(/\s+/g, ' ')
|
|
828
|
-
.trim();
|
|
829
|
-
}
|
|
830
|
-
const CREATE_SPEC_ENUMS = {
|
|
831
|
-
type: SpecTypeEnum,
|
|
832
|
-
scope: SpecScopeEnum,
|
|
833
|
-
target: SpecTargetEnum,
|
|
834
|
-
acFormat: SpecAcFormatEnum,
|
|
835
|
-
};
|
|
836
|
-
function validateCreateSpecEnums(input) {
|
|
837
|
-
for (const [field, schema] of Object.entries(CREATE_SPEC_ENUMS)) {
|
|
838
|
-
const received = input[field];
|
|
839
|
-
if (received === undefined || schema.safeParse(received).success) {
|
|
840
|
-
continue;
|
|
841
|
-
}
|
|
842
|
-
const boundedReceived = received === null || ['string', 'number', 'boolean'].includes(typeof received)
|
|
843
|
-
? received
|
|
844
|
-
: typeof received;
|
|
845
|
-
return {
|
|
846
|
-
content: [
|
|
847
|
-
{
|
|
848
|
-
type: 'text',
|
|
849
|
-
text: `${field} must be one of: ${schema.options.join(', ')}.`,
|
|
850
|
-
},
|
|
851
|
-
],
|
|
852
|
-
isError: true,
|
|
853
|
-
structuredContent: {
|
|
854
|
-
error: 'INVALID_INPUT',
|
|
855
|
-
code: 'INVALID_INPUT',
|
|
856
|
-
status: 422,
|
|
857
|
-
field,
|
|
858
|
-
received: boundedReceived,
|
|
859
|
-
allowed: schema.options,
|
|
860
|
-
},
|
|
861
|
-
};
|
|
862
|
-
}
|
|
863
|
-
return null;
|
|
864
|
-
}
|
|
865
|
-
const DESCRIPTION_MAX_CHARS = 10_000;
|
|
866
|
-
const DESCRIPTION_EXCEED_MSG = 'Description exceeds 10000 chars. Create with a summary (<3k) and use reconcile_spec to add the rest.';
|
|
867
|
-
/** SPEC-1342: Terminal rejection — only reached after one translation clarification round failed. */
|
|
868
|
-
function buildEnglishGateRejectionResult(gate) {
|
|
869
|
-
return {
|
|
870
|
-
content: [
|
|
871
|
-
{
|
|
872
|
-
type: 'text',
|
|
873
|
-
text: `English-only spec gate blocked create_spec.\n\n${gate.reason ?? 'Non-English prose detected.'}\n\n` +
|
|
874
|
-
'Rewrite the title and description in English, then call create_spec again. User-facing responses may be localized, but spec.md must be English.',
|
|
875
|
-
},
|
|
876
|
-
],
|
|
877
|
-
isError: true,
|
|
878
|
-
structuredContent: {
|
|
879
|
-
error: 'SPEC_LANGUAGE_GATE_BLOCKED',
|
|
880
|
-
detectedLanguage: gate.originalLanguage,
|
|
881
|
-
fixHint: 'Rewrite title and description in English before creating the spec.',
|
|
882
|
-
},
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* SPEC-1342: Apply an already-resolved English-only gate outcome. Returns:
|
|
887
|
-
* - `{ earlyReturn: null, englishTitle?, englishDescription? }` when the caller may proceed
|
|
888
|
-
* (input was already English, or was successfully translated).
|
|
889
|
-
* - `{ earlyReturn: ToolResult }` when the caller must return early (translation clarification
|
|
890
|
-
* question, or terminal rejection after one failed clarification round).
|
|
891
|
-
*/
|
|
892
|
-
function applyEnglishOnlyGate(gate) {
|
|
893
|
-
switch (gate.action) {
|
|
894
|
-
case 'ok':
|
|
895
|
-
return { earlyReturn: null };
|
|
896
|
-
case 'translated':
|
|
897
|
-
return {
|
|
898
|
-
earlyReturn: null,
|
|
899
|
-
englishTitle: gate.englishTitle,
|
|
900
|
-
englishDescription: gate.englishDescription,
|
|
901
|
-
};
|
|
902
|
-
case 'reject':
|
|
903
|
-
return { earlyReturn: buildEnglishGateRejectionResult(gate) };
|
|
904
|
-
case 'ask':
|
|
905
|
-
return {
|
|
906
|
-
earlyReturn: interactiveResult(gate.questions ?? [], 'The spec title/description are not in English. Provide the English translation ' +
|
|
907
|
-
'(e.g. via AskUserQuestion), then retry create_spec with clarificationAnswers.', 'universal'),
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
function quotePosixShellArgument(value) {
|
|
912
|
-
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
913
|
-
}
|
|
914
|
-
/**
|
|
915
|
-
* SPEC-1469: the quality gate finding alone (`phrase` + `reason`) forced callers into
|
|
916
|
-
* trial-and-error rewording because it dropped the offending rendered line and the rule
|
|
917
|
-
* needed to pass. Quoting `evidence` verbatim and naming the generator-owned FILES:/TEST:
|
|
918
|
-
* marker exemption gives a what-failed + what-to-do-next message on the first read.
|
|
919
|
-
*/
|
|
920
|
-
function formatGenericOutputIssue(issue) {
|
|
921
|
-
const base = `${issue.phrase}: ${issue.reason}`;
|
|
922
|
-
if (!issue.evidence) {
|
|
923
|
-
return base;
|
|
924
|
-
}
|
|
925
|
-
return (`${base}. Offending row: "${issue.evidence}". ` +
|
|
926
|
-
"A row that only echoes a criterion's own mandatory FILES:/TEST: marker path is generator-owned " +
|
|
927
|
-
"and already exempt; rewrite the row's remaining content so it adds information beyond the fixed template.");
|
|
928
|
-
}
|
|
929
|
-
function earlyPreparation(result, clarificationProjectId) {
|
|
930
|
-
return {
|
|
931
|
-
kind: 'early',
|
|
932
|
-
result,
|
|
933
|
-
...(clarificationProjectId ? { clarificationProjectId } : {}),
|
|
934
|
-
};
|
|
935
|
-
}
|
|
936
|
-
export async function resolveGroundedVerificationCommands(projectPath, testPaths) {
|
|
937
|
-
if (testPaths.length === 0) {
|
|
938
|
-
return [];
|
|
939
|
-
}
|
|
940
|
-
const packageJsonRaw = await readFile(pathJoin(projectPath, 'package.json'), 'utf8').catch(() => '');
|
|
941
|
-
if (!packageJsonRaw) {
|
|
942
|
-
return [];
|
|
943
|
-
}
|
|
944
|
-
try {
|
|
945
|
-
const manifest = JSON.parse(packageJsonRaw);
|
|
946
|
-
if (typeof manifest.packageManager !== 'string') {
|
|
947
|
-
return [];
|
|
948
|
-
}
|
|
949
|
-
const packageManager = /^(pnpm|npm|yarn|bun)@\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u.exec(manifest.packageManager)?.[1];
|
|
950
|
-
if (!packageManager) {
|
|
951
|
-
return [];
|
|
952
|
-
}
|
|
953
|
-
if (typeof manifest.scripts?.test !== 'string' || manifest.scripts.test.trim() === '') {
|
|
954
|
-
return [];
|
|
955
|
-
}
|
|
956
|
-
const joiner = packageManager === 'npm' ? ' -- ' : ' ';
|
|
957
|
-
return [
|
|
958
|
-
`${packageManager} run test${joiner}${testPaths.map(quotePosixShellArgument).join(' ')}`,
|
|
959
|
-
];
|
|
960
|
-
}
|
|
961
|
-
catch {
|
|
962
|
-
return [];
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
async function prepareCreateSpecCandidate(initialParams) {
|
|
966
|
-
let params = { ...initialParams };
|
|
967
|
-
const buildResult = await buildSpecContext(params);
|
|
968
|
-
if (!buildResult.ok) {
|
|
969
|
-
return earlyPreparation({
|
|
970
|
-
content: [{ type: 'text', text: buildResult.errorMessage }],
|
|
971
|
-
isError: true,
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
const context = buildResult.context;
|
|
975
|
-
const { spec, projectId } = context;
|
|
976
|
-
const knowledge = await knowledgeStore.getKnowledge(projectId);
|
|
977
|
-
const clarificationSession = params.clarificationSessionId
|
|
978
|
-
? await knowledgeStore.getClarification(projectId, params.clarificationSessionId)
|
|
979
|
-
: null;
|
|
980
|
-
const constitutionCheck = await validateConstitution(projectId, spec.title, spec.tags);
|
|
981
|
-
if (constitutionCheck.blocked && constitutionCheck.errorResult) {
|
|
982
|
-
return earlyPreparation(constitutionCheck.errorResult);
|
|
983
|
-
}
|
|
984
|
-
const inlineAnalysis = await withBudget('create-spec-inline-analysis', getRuntimePolicy().createSpec.inlineAnalysisBudgetMs, () => analyzeProjectForSpec(params.projectPath ?? '', params.description, spec.title, knowledge));
|
|
985
|
-
const autopilot = unwrapBudget(inlineAnalysis, getEmptyAutopilotResult());
|
|
986
|
-
if (autopilot.isIdea) {
|
|
987
|
-
return earlyPreparation({
|
|
988
|
-
content: [
|
|
989
|
-
{
|
|
990
|
-
type: 'text',
|
|
991
|
-
text: `💡 **Idea captured**: "${params.description}"\n\nThe description is too brief for a full spec. Provide more detail (>10 words) to create a spec.`,
|
|
992
|
-
},
|
|
993
|
-
],
|
|
994
|
-
});
|
|
995
|
-
}
|
|
996
|
-
const clarificationResult = handleClarification(params.description, knowledge, autopilot, params);
|
|
997
|
-
if (clarificationResult !== null) {
|
|
998
|
-
if ('earlyReturn' in clarificationResult) {
|
|
999
|
-
return earlyPreparation(clarificationResult.earlyReturn, projectId);
|
|
1000
|
-
}
|
|
1001
|
-
params = clarificationResult.params;
|
|
1002
|
-
}
|
|
1003
|
-
const filteredCriteria = filterGroundedCriteria(autopilot.suggestedCriteria);
|
|
1004
|
-
const technologyContract = await readTechnologySelectionContract(params.projectPath ?? '');
|
|
1005
|
-
const contractNote = technologyContract
|
|
1006
|
-
? [
|
|
1007
|
-
'',
|
|
1008
|
-
'Technology Contract:',
|
|
1009
|
-
`- Mode: ${technologyContract.mode}`,
|
|
1010
|
-
technologyContract.language ? `- Language: ${technologyContract.language}` : '',
|
|
1011
|
-
technologyContract.framework
|
|
1012
|
-
? `- Framework: ${technologyContract.framework}`
|
|
1013
|
-
: '- Framework: none or not selected',
|
|
1014
|
-
technologyContract.platform ? `- Platform: ${technologyContract.platform}` : '',
|
|
1015
|
-
technologyContract.projectType ? `- Project type: ${technologyContract.projectType}` : '',
|
|
1016
|
-
'- Agents must not choose a different stack unless the user approves a new contract.',
|
|
1017
|
-
]
|
|
1018
|
-
.filter(Boolean)
|
|
1019
|
-
.join('\n')
|
|
1020
|
-
: '';
|
|
1021
|
-
const generatedSpec = await new FallbackGenerator().generate({
|
|
1022
|
-
title: spec.title,
|
|
1023
|
-
description: `${params.description}${contractNote}`,
|
|
1024
|
-
type: spec.type,
|
|
1025
|
-
scope: spec.scope,
|
|
1026
|
-
target: spec.target,
|
|
1027
|
-
acFormat: params.acFormat,
|
|
1028
|
-
projectContext: {
|
|
1029
|
-
language: technologyContract?.language ?? knowledge?.language ?? undefined,
|
|
1030
|
-
framework: technologyContract?.framework ?? knowledge?.framework ?? undefined,
|
|
1031
|
-
architecture: knowledge?.architecture.primary ?? undefined,
|
|
1032
|
-
},
|
|
1033
|
-
});
|
|
1034
|
-
spec.generation = generatedSpec.generation;
|
|
1035
|
-
// SPEC-1406 (DEFECT 4, round 2): FallbackGenerator no longer emits an unconditional
|
|
1036
|
-
// warning, so qualityWarnings only needs the non-empty guard now — the redundant
|
|
1037
|
-
// constant-string filter was removed from create-spec.ts, fallback-generator.ts and
|
|
1038
|
-
// opus-generator.ts (dead code, reverted) so the literal doesn't have to stay
|
|
1039
|
-
// byte-identical across three files.
|
|
1040
|
-
spec.qualityWarnings =
|
|
1041
|
-
generatedSpec.qualityWarnings.length > 0 ? generatedSpec.qualityWarnings : undefined;
|
|
1042
|
-
const baseCriteria = extractCriteria(generatedSpec.specBody).map((criterion) => criterion.text);
|
|
1043
|
-
const groundingCriteria = buildCriterionGroundingRecords({
|
|
1044
|
-
criteria: [...baseCriteria, ...filteredCriteria],
|
|
1045
|
-
userInput: params.description,
|
|
1046
|
-
generatedEvidence: [generatedSpec.generation.modelId ?? generatedSpec.generation.method],
|
|
1047
|
-
});
|
|
1048
|
-
const contractCriteria = getContractCriteria(groundingCriteria);
|
|
1049
|
-
const advisoryCriteria = getAdvisoryCriteria(groundingCriteria).map((record) => record.text);
|
|
1050
|
-
if (contractCriteria.length === 0) {
|
|
1051
|
-
return earlyPreparation({
|
|
1052
|
-
content: [
|
|
1053
|
-
{
|
|
1054
|
-
type: 'text',
|
|
1055
|
-
text: 'create_spec did not persist a spec because no acceptance criterion was grounded in the user request. ' +
|
|
1056
|
-
'Needs decision: provide at least one explicit, verifiable criterion as a checkbox or Given/When/Then outcome.',
|
|
1057
|
-
},
|
|
1058
|
-
],
|
|
1059
|
-
isError: true,
|
|
1060
|
-
structuredContent: {
|
|
1061
|
-
error: 'MISSING_GROUNDED_ACCEPTANCE_CRITERIA',
|
|
1062
|
-
missingDecision: 'Provide at least one explicit, verifiable acceptance criterion.',
|
|
1063
|
-
persisted: false,
|
|
1064
|
-
},
|
|
1065
|
-
});
|
|
1066
|
-
}
|
|
1067
|
-
if (containsUnresolvedContractPlaceholder(generatedSpec.specBody, {
|
|
1068
|
-
excludeGeneratorMissingDecisions: true,
|
|
1069
|
-
})) {
|
|
1070
|
-
return earlyPreparation({
|
|
1071
|
-
content: [
|
|
1072
|
-
{
|
|
1073
|
-
type: 'text',
|
|
1074
|
-
text: 'Unified spec candidate is invalid: Unified candidate contains an unresolved contract placeholder.',
|
|
1075
|
-
},
|
|
1076
|
-
],
|
|
1077
|
-
isError: true,
|
|
1078
|
-
structuredContent: {
|
|
1079
|
-
error: 'SPEC_FORMAT_INVALID',
|
|
1080
|
-
code: 422,
|
|
1081
|
-
persisted: false,
|
|
1082
|
-
issues: [
|
|
1083
|
-
{
|
|
1084
|
-
code: 'UNRESOLVED_CONTRACT_PLACEHOLDER',
|
|
1085
|
-
message: 'Unified candidate contains an unresolved contract placeholder.',
|
|
1086
|
-
},
|
|
1087
|
-
],
|
|
1088
|
-
},
|
|
1089
|
-
});
|
|
1090
|
-
}
|
|
1091
|
-
const technicalFiles = await resolveTechnicalFiles({
|
|
1092
|
-
generatedSpecBody: generatedSpec.specBody,
|
|
1093
|
-
generatedTechnicalSection: generatedSpec.technicalSection,
|
|
1094
|
-
projectPath: params.projectPath ?? '',
|
|
1095
|
-
});
|
|
1096
|
-
const groundedTechnical = await groundTechnicalFiles({
|
|
1097
|
-
files: technicalFiles,
|
|
1098
|
-
projectPath: params.projectPath ?? '',
|
|
1099
|
-
userInput: params.description,
|
|
1100
|
-
autopilot,
|
|
1101
|
-
});
|
|
1102
|
-
const outOfScope = resolveOutOfScope(params.outOfScope, params.description);
|
|
1103
|
-
const scenarioTestPaths = groundedTechnical.files.test.map((file) => file.path);
|
|
1104
|
-
const criteria = contractCriteria.map((record) => ({ text: record.text, done: false }));
|
|
1105
|
-
const leanSpec = generateLeanSpecContent({
|
|
1106
|
-
spec,
|
|
1107
|
-
description: generatedSpec.specBody,
|
|
1108
|
-
criteriaOverride: criteria,
|
|
1109
|
-
groundingCriteria: contractCriteria,
|
|
1110
|
-
groundingTechnicalReferences: groundedTechnical.records,
|
|
1111
|
-
acFormat: params.acFormat,
|
|
1112
|
-
scenarioTestPaths,
|
|
1113
|
-
});
|
|
1114
|
-
const leanTechnical = generateLeanTechnicalContent({
|
|
1115
|
-
specId: spec.id,
|
|
1116
|
-
filesToCreate: groundedTechnical.files.create,
|
|
1117
|
-
filesToModify: groundedTechnical.files.modify,
|
|
1118
|
-
filesToTest: groundedTechnical.files.test,
|
|
1119
|
-
includeDecisionRequiredPlaceholder: spec.scope !== 'trivial',
|
|
1120
|
-
});
|
|
1121
|
-
const verificationCommands = await resolveGroundedVerificationCommands(params.projectPath ?? '', scenarioTestPaths);
|
|
1122
|
-
const implementationContract = buildImplementationContractSection({
|
|
1123
|
-
description: generatedSpec.specBody,
|
|
1124
|
-
criteria,
|
|
1125
|
-
files: groundedTechnical.files,
|
|
1126
|
-
outOfScope,
|
|
1127
|
-
verificationCommands,
|
|
1128
|
-
});
|
|
1129
|
-
let unifiedSpec = buildCanonicalUnifiedSpecContent({
|
|
1130
|
-
leanSpecBody: leanSpec,
|
|
1131
|
-
sourceDescription: params.description,
|
|
1132
|
-
technicalBody: leanTechnical,
|
|
1133
|
-
implementationContract,
|
|
1134
|
-
criteria,
|
|
1135
|
-
files: groundedTechnical.files,
|
|
1136
|
-
outOfScope,
|
|
1137
|
-
});
|
|
1138
|
-
const candidateValidation = validateUnifiedSpecCandidate(unifiedSpec, {
|
|
1139
|
-
groundedFilePaths: groundedTechnical.records.map((record) => record.path),
|
|
1140
|
-
});
|
|
1141
|
-
// SPEC-1435: MISSING_EXECUTABLE_CRITERIA no longer blocks persistence — plain-text
|
|
1142
|
-
// criteria are accepted input today (checkbox items via extractAcceptanceCriteriaTexts),
|
|
1143
|
-
// and the constant GIVEN/WHEN/THEN scaffold that used to satisfy this check has been
|
|
1144
|
-
// retired. The readiness-checker approval gate now blocks a zero-BDD spec at
|
|
1145
|
-
// review -> approved instead; here it downgrades to a persisted quality warning.
|
|
1146
|
-
const blockingCandidateIssues = candidateValidation.issues.filter((issue) => issue.code !== 'MISSING_EXECUTABLE_CRITERIA');
|
|
1147
|
-
if (blockingCandidateIssues.length > 0) {
|
|
1148
|
-
return earlyPreparation({
|
|
1149
|
-
content: [
|
|
1150
|
-
{
|
|
1151
|
-
type: 'text',
|
|
1152
|
-
text: `Unified spec candidate is invalid: ${blockingCandidateIssues
|
|
1153
|
-
.slice(0, 3)
|
|
1154
|
-
.map((issue) => issue.message)
|
|
1155
|
-
.join('; ')}`,
|
|
1156
|
-
},
|
|
1157
|
-
],
|
|
1158
|
-
isError: true,
|
|
1159
|
-
structuredContent: {
|
|
1160
|
-
error: 'SPEC_FORMAT_INVALID',
|
|
1161
|
-
code: 422,
|
|
1162
|
-
persisted: false,
|
|
1163
|
-
issues: blockingCandidateIssues,
|
|
1164
|
-
},
|
|
1165
|
-
});
|
|
1166
|
-
}
|
|
1167
|
-
if (candidateValidation.issues.some((issue) => issue.code === 'MISSING_EXECUTABLE_CRITERIA')) {
|
|
1168
|
-
const nonExecutableCriteriaWarning = 'Acceptance criteria are not executable GIVEN/WHEN/THEN — restate them before approval';
|
|
1169
|
-
spec.qualityWarnings = [
|
|
1170
|
-
...new Set([...(spec.qualityWarnings ?? []), nonExecutableCriteriaWarning]),
|
|
1171
|
-
];
|
|
1172
|
-
// unifiedSpec's frontmatter was already serialized from `spec` before this warning was
|
|
1173
|
-
// known — patch the persisted YAML field directly rather than re-serializing the whole
|
|
1174
|
-
// candidate.
|
|
1175
|
-
unifiedSpec = updateFrontmatterField(unifiedSpec, 'qualityWarnings', JSON.stringify(spec.qualityWarnings));
|
|
1176
|
-
}
|
|
1177
|
-
if (params.acFormat === 'bdd' && leanSpec.includes(PLACEHOLDER_WHEN_STEP_TEXT)) {
|
|
1178
|
-
const unparsedCriterion = criteria.find((criterion) => parseBddScenarios(criterion.text).length === 0)?.text ?? '';
|
|
1179
|
-
const placeholderFallbackWarning = `BDD parse fell back to placeholder steps — restate as a single GIVEN … WHEN … THEN … line: ` +
|
|
1180
|
-
`"${unparsedCriterion.slice(0, 120)}"`;
|
|
1181
|
-
spec.qualityWarnings = [
|
|
1182
|
-
...new Set([...(spec.qualityWarnings ?? []), placeholderFallbackWarning]),
|
|
1183
|
-
];
|
|
1184
|
-
unifiedSpec = updateFrontmatterField(unifiedSpec, 'qualityWarnings', JSON.stringify(spec.qualityWarnings));
|
|
1185
|
-
}
|
|
1186
|
-
const genericOutputGate = checkGenericSpecOutput(unifiedSpec);
|
|
1187
|
-
if (!genericOutputGate.passed) {
|
|
1188
|
-
return earlyPreparation({
|
|
1189
|
-
content: [
|
|
1190
|
-
{
|
|
1191
|
-
type: 'text',
|
|
1192
|
-
text: 'Spec quality gate blocked generic output before persistence. ' +
|
|
1193
|
-
genericOutputGate.issues.slice(0, 3).map(formatGenericOutputIssue).join('; '),
|
|
1194
|
-
},
|
|
1195
|
-
],
|
|
1196
|
-
isError: true,
|
|
1197
|
-
structuredContent: {
|
|
1198
|
-
error: 'GENERIC_SPEC_OUTPUT_BLOCKED',
|
|
1199
|
-
sddConstitutionRuleId: 'sdd.no-generic-output',
|
|
1200
|
-
issues: genericOutputGate.issues,
|
|
1201
|
-
fixHint: 'Replace generic criteria or placeholder references with grounded, testable behavior.',
|
|
1202
|
-
},
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
if (outOfScope.length > 0) {
|
|
1206
|
-
spec.outOfScope = outOfScope;
|
|
1207
|
-
}
|
|
1208
|
-
return {
|
|
1209
|
-
kind: 'ready',
|
|
1210
|
-
prepared: {
|
|
1211
|
-
params,
|
|
1212
|
-
context,
|
|
1213
|
-
knowledge,
|
|
1214
|
-
clarificationSession,
|
|
1215
|
-
constitutionWarnings: constitutionCheck.warnings,
|
|
1216
|
-
advisoryCriteria,
|
|
1217
|
-
unifiedSpec,
|
|
1218
|
-
},
|
|
1219
|
-
};
|
|
1220
|
-
}
|
|
1221
|
-
function isNonEmptyString(value) {
|
|
1222
|
-
return typeof value === 'string' && value.trim().length > 0;
|
|
1223
|
-
}
|
|
1224
|
-
function buildMissingTitleResult() {
|
|
1225
|
-
return {
|
|
1226
|
-
content: [
|
|
1227
|
-
{
|
|
1228
|
-
type: 'text',
|
|
1229
|
-
text: 'create_spec requires a non-empty title. Provide the title field and call create_spec again.',
|
|
1230
|
-
},
|
|
1231
|
-
],
|
|
1232
|
-
isError: true,
|
|
1233
|
-
structuredContent: { error: 'MISSING_TITLE', code: 'INVALID_INPUT', field: 'title' },
|
|
1234
|
-
};
|
|
1235
|
-
}
|
|
1236
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1237
|
-
export async function handleCreateSpec(inputParams) {
|
|
1238
|
-
if (!isNonEmptyString(inputParams.title)) {
|
|
1239
|
-
return buildMissingTitleResult();
|
|
1240
|
-
}
|
|
1241
|
-
const enumValidation = validateCreateSpecEnums(inputParams);
|
|
1242
|
-
if (enumValidation) {
|
|
1243
|
-
return enumValidation;
|
|
1244
|
-
}
|
|
1245
|
-
if (inputParams.idempotencyKey !== undefined &&
|
|
1246
|
-
!/^[A-Za-z0-9._:-]{8,128}$/.test(inputParams.idempotencyKey)) {
|
|
1247
|
-
return {
|
|
1248
|
-
content: [
|
|
1249
|
-
{
|
|
1250
|
-
type: 'text',
|
|
1251
|
-
text: 'idempotencyKey must contain 8-128 letters, digits, dots, underscores, colons or hyphens.',
|
|
1252
|
-
},
|
|
1253
|
-
],
|
|
1254
|
-
isError: true,
|
|
1255
|
-
structuredContent: { error: 'INVALID_IDEMPOTENCY_KEY', code: 422 },
|
|
1256
|
-
};
|
|
1257
|
-
}
|
|
1258
|
-
// SPEC-781: Friendly error for description exceeding 10000 chars (replaces cryptic Zod error)
|
|
1259
|
-
if (inputParams.description && inputParams.description.length > DESCRIPTION_MAX_CHARS) {
|
|
1260
|
-
return {
|
|
1261
|
-
content: [{ type: 'text', text: DESCRIPTION_EXCEED_MSG }],
|
|
1262
|
-
isError: true,
|
|
1263
|
-
structuredContent: {
|
|
1264
|
-
error: 'DESCRIPTION_TOO_LONG',
|
|
1265
|
-
maxChars: DESCRIPTION_MAX_CHARS,
|
|
1266
|
-
actualChars: inputParams.description.length,
|
|
1267
|
-
fixHint: 'Create with a summary description under 3000 chars, then append detailed context through reconcile_spec.',
|
|
1268
|
-
},
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
// SPEC-509: resolve projectPath from git root when omitted
|
|
1272
|
-
const resolved = await resolveProjectIdOrAutoDetect({ projectPath: inputParams.projectPath });
|
|
1273
|
-
if (!resolved.ok) {
|
|
1274
|
-
return resolved.errorResult;
|
|
1275
|
-
}
|
|
1276
|
-
const resolvedPath = resolved.projectPath || inputParams.projectPath;
|
|
1277
|
-
if (!resolvedPath) {
|
|
1278
|
-
return {
|
|
1279
|
-
content: [
|
|
1280
|
-
{
|
|
1281
|
-
type: 'text',
|
|
1282
|
-
text: 'Could not determine projectPath. Run init_project first or provide projectPath explicitly.',
|
|
1283
|
-
},
|
|
1284
|
-
],
|
|
1285
|
-
isError: true,
|
|
1286
|
-
};
|
|
1287
|
-
}
|
|
1288
|
-
const resolvedInputParams = redactCreateSpecInput({ ...inputParams, projectPath: resolvedPath }, resolvedPath);
|
|
1289
|
-
// SPEC-584: Gate check — block if pending clarification token exists and no answers provided.
|
|
1290
|
-
// Runs before the English-only gate so a second call with no translation answer hits the
|
|
1291
|
-
// existing well-formed "must call AskUserQuestion" mandate instead of re-asking forever.
|
|
1292
|
-
const gateError = await runClarificationGate(resolvedPath, 'create_spec', inputParams.clarificationAnswers);
|
|
1293
|
-
if (gateError) {
|
|
1294
|
-
return gateError;
|
|
1295
|
-
}
|
|
1296
|
-
// SPEC-1342: English-only gate — offers a translation clarification round instead of
|
|
1297
|
-
// hard-rejecting non-English title/description.
|
|
1298
|
-
const languageGateResult = resolveEnglishOnlySpecGate(resolvedInputParams.title, resolvedInputParams.description, resolvedInputParams.clarificationAnswers);
|
|
1299
|
-
const languageGate = applyEnglishOnlyGate(languageGateResult);
|
|
1300
|
-
if (languageGate.earlyReturn) {
|
|
1301
|
-
if (languageGateResult.action === 'ask') {
|
|
1302
|
-
await persistClarificationToken(languageGate.earlyReturn, hashProjectPath(resolvedPath), 'create_spec');
|
|
1303
|
-
}
|
|
1304
|
-
return languageGate.earlyReturn;
|
|
1305
|
-
}
|
|
1306
|
-
if (languageGate.englishTitle !== undefined) {
|
|
1307
|
-
resolvedInputParams.title = languageGate.englishTitle;
|
|
1308
|
-
}
|
|
1309
|
-
if (languageGate.englishDescription !== undefined) {
|
|
1310
|
-
resolvedInputParams.description = languageGate.englishDescription;
|
|
1311
|
-
}
|
|
1312
|
-
const originalLanguage = languageGateResult.originalLanguage;
|
|
1313
|
-
const idempotencyKey = computeIdempotencyKey(inputParams.title, resolvedPath, inputParams.idempotencyKey);
|
|
1314
|
-
const cutoff = Date.now() - IDEMPOTENCY_MATCH_WINDOW_MS;
|
|
1315
|
-
const storeOnlyCandidate = await findStoreByIdempotencyKey(hashProjectPath(resolvedPath), idempotencyKey, cutoff);
|
|
1316
|
-
let preparation;
|
|
1317
|
-
try {
|
|
1318
|
-
preparation = await prepareCreateSpecCandidate(resolvedInputParams);
|
|
1319
|
-
}
|
|
1320
|
-
catch (error) {
|
|
1321
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1322
|
-
return {
|
|
1323
|
-
content: [{ type: 'text', text: ti('errors.internalError', { message }) }],
|
|
1324
|
-
isError: true,
|
|
1325
|
-
};
|
|
1326
|
-
}
|
|
1327
|
-
if (preparation.kind === 'early') {
|
|
1328
|
-
if (preparation.clarificationProjectId) {
|
|
1329
|
-
await persistClarificationToken(preparation.result, preparation.clarificationProjectId, 'create_spec');
|
|
1330
|
-
}
|
|
1331
|
-
return preparation.result;
|
|
1332
|
-
}
|
|
1333
|
-
const prepared = preparation.prepared;
|
|
1334
|
-
prepared.context.spec.idempotencyKey = idempotencyKey;
|
|
1335
|
-
if (storeOnlyCandidate) {
|
|
1336
|
-
const committedEvidence = await findByIdempotencyEvidence(resolvedPath, idempotencyKey, cutoff);
|
|
1337
|
-
if (!committedEvidence) {
|
|
1338
|
-
return {
|
|
1339
|
-
content: [
|
|
1340
|
-
{
|
|
1341
|
-
type: 'text',
|
|
1342
|
-
text: `A partial create_spec transaction exists for ${storeOnlyCandidate.id}: the store row has no committed idempotency evidence. Recovery is required before retrying.`,
|
|
1343
|
-
},
|
|
1344
|
-
],
|
|
1345
|
-
isError: true,
|
|
1346
|
-
structuredContent: {
|
|
1347
|
-
error: 'PARTIAL_IDEMPOTENCY_STATE',
|
|
1348
|
-
code: 409,
|
|
1349
|
-
persisted: false,
|
|
1350
|
-
specId: storeOnlyCandidate.id,
|
|
1351
|
-
},
|
|
1352
|
-
};
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
// SPEC-665: Fire-and-forget TTL refresh for conventions.json (never blocks create_spec)
|
|
1356
|
-
void import('../engine/conventions-ttl.js').then(({ triggerConventionsTtlRefresh }) => {
|
|
1357
|
-
void triggerConventionsTtlRefresh(resolvedPath).catch(() => {
|
|
1358
|
-
/* best-effort */
|
|
1359
|
-
});
|
|
1360
|
-
});
|
|
1361
|
-
// SPEC-770: Idempotency check — return existing spec if same title+projectPath within 10 minutes
|
|
1362
|
-
const operationKey = computeOperationKey(resolvedInputParams, resolvedPath, idempotencyKey);
|
|
1363
|
-
// SPEC-1351: create_spec holds its RuntimeDatabase connection for the whole
|
|
1364
|
-
// operation (idempotency journal + recovery payload). The default cap (4) is
|
|
1365
|
-
// exhausted by a handful of concurrent create_spec calls in one process,
|
|
1366
|
-
// which otherwise fail with RuntimeDatabaseResourceExhaustedError before any
|
|
1367
|
-
// persistence work starts. Raise the ceiling for this call site only.
|
|
1368
|
-
const runtimeDatabase = new RuntimeDatabase({
|
|
1369
|
-
path: resolveStorageLayout().runtimeDatabase,
|
|
1370
|
-
maxConnections: 16,
|
|
1371
|
-
});
|
|
1372
|
-
const operationJournal = new OperationJournal(runtimeDatabase, createHash('sha256').update(hashProjectPath(resolvedPath)).digest('hex').slice(0, 32));
|
|
1373
|
-
let journalEntry;
|
|
1374
|
-
try {
|
|
1375
|
-
await recoverOperationJournal({
|
|
1376
|
-
journal: operationJournal,
|
|
1377
|
-
operation: 'create_spec',
|
|
1378
|
-
staleBefore: new Date(Date.now() - IDEMPOTENCY_CLAIM_STALE_MS).toISOString(),
|
|
1379
|
-
decide: decideCreateSpecRecovery,
|
|
1380
|
-
});
|
|
1381
|
-
journalEntry = operationJournal.begin('create_spec', operationKey, inputParams.idempotencyKey
|
|
1382
|
-
? createSpecRequestDigest(resolvedInputParams, resolvedPath)
|
|
1383
|
-
: operationKey, {
|
|
1384
|
-
payloadVersion: 1,
|
|
1385
|
-
payload: {
|
|
1386
|
-
operationVersion: 1,
|
|
1387
|
-
projectPath: resolvedPath,
|
|
1388
|
-
idempotencyKey,
|
|
1389
|
-
},
|
|
1390
|
-
});
|
|
1391
|
-
if (journalEntry.state === 'rolled-back') {
|
|
1392
|
-
journalEntry = operationJournal.restartRolledBack('create_spec', operationKey);
|
|
1393
|
-
journalEntry = operationJournal.setRecoveryPayload('create_spec', operationKey, 1, {
|
|
1394
|
-
operationVersion: 1,
|
|
1395
|
-
projectPath: resolvedPath,
|
|
1396
|
-
idempotencyKey,
|
|
1397
|
-
});
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
catch (error) {
|
|
1401
|
-
runtimeDatabase.close();
|
|
1402
|
-
if (error instanceof BoundaryFailure &&
|
|
1403
|
-
error.kind === 'Conflict' &&
|
|
1404
|
-
error.operation === 'operation begin') {
|
|
1405
|
-
return {
|
|
1406
|
-
content: [
|
|
1407
|
-
{
|
|
1408
|
-
type: 'text',
|
|
1409
|
-
text: 'The idempotency key is already bound to a different create_spec request.',
|
|
1410
|
-
},
|
|
1411
|
-
],
|
|
1412
|
-
isError: true,
|
|
1413
|
-
structuredContent: {
|
|
1414
|
-
error: 'IDEMPOTENCY_CONFLICT',
|
|
1415
|
-
code: 'IDEMPOTENCY_CONFLICT',
|
|
1416
|
-
status: 409,
|
|
1417
|
-
persisted: false,
|
|
1418
|
-
},
|
|
1419
|
-
};
|
|
1420
|
-
}
|
|
1421
|
-
throw error;
|
|
1422
|
-
}
|
|
1423
|
-
if ((journalEntry.state === 'committed' || journalEntry.state === 'acknowledged') &&
|
|
1424
|
-
journalEntry.result) {
|
|
1425
|
-
if (journalEntry.state === 'committed') {
|
|
1426
|
-
operationJournal.acknowledged('create_spec', operationKey);
|
|
1427
|
-
}
|
|
1428
|
-
runtimeDatabase.close();
|
|
1429
|
-
return journalEntry.result;
|
|
1430
|
-
}
|
|
1431
|
-
if (journalEntry.state === 'quarantined') {
|
|
1432
|
-
runtimeDatabase.close();
|
|
1433
|
-
return {
|
|
1434
|
-
content: [
|
|
1435
|
-
{
|
|
1436
|
-
type: 'text',
|
|
1437
|
-
text: `The previous create_spec attempt is quarantined: ${journalEntry.recoveryReason ?? 'artifact mismatch'}.`,
|
|
1438
|
-
},
|
|
1439
|
-
],
|
|
1440
|
-
isError: true,
|
|
1441
|
-
structuredContent: { recoveryQuarantined: true, operationId: operationKey },
|
|
1442
|
-
};
|
|
1443
|
-
}
|
|
1444
|
-
const existingByKey = await findByIdempotencyKey(resolvedPath, idempotencyKey, hashProjectPath(resolvedPath));
|
|
1445
|
-
if (existingByKey) {
|
|
1446
|
-
const result = await buildIdempotencyMatchResult(resolvedPath, existingByKey);
|
|
1447
|
-
finishRecoveredOperation(operationJournal, operationKey, result);
|
|
1448
|
-
runtimeDatabase.close();
|
|
1449
|
-
return result;
|
|
1450
|
-
}
|
|
1451
|
-
let claimResolution;
|
|
1452
|
-
try {
|
|
1453
|
-
claimResolution = await acquireIdempotencyClaim(resolvedPath, idempotencyKey, inputParams.title);
|
|
1454
|
-
}
|
|
1455
|
-
catch (error) {
|
|
1456
|
-
runtimeDatabase.close();
|
|
1457
|
-
throw error;
|
|
1458
|
-
}
|
|
1459
|
-
if (claimResolution.kind === 'existing') {
|
|
1460
|
-
const result = await buildIdempotencyMatchResult(resolvedPath, claimResolution.spec);
|
|
1461
|
-
finishRecoveredOperation(operationJournal, operationKey, result);
|
|
1462
|
-
runtimeDatabase.close();
|
|
1463
|
-
return result;
|
|
1464
|
-
}
|
|
1465
|
-
if (claimResolution.kind === 'pending') {
|
|
1466
|
-
runtimeDatabase.close();
|
|
1467
|
-
return {
|
|
1468
|
-
content: [
|
|
1469
|
-
{
|
|
1470
|
-
type: 'text',
|
|
1471
|
-
text: 'An identical create_spec request is still in progress. Retry with the same title.',
|
|
1472
|
-
},
|
|
1473
|
-
],
|
|
1474
|
-
isError: true,
|
|
1475
|
-
structuredContent: { idempotencyPending: true },
|
|
1476
|
-
};
|
|
1477
|
-
}
|
|
1478
|
-
const idempotencyClaim = claimResolution.claim;
|
|
1479
|
-
const claimLifecycle = {
|
|
1480
|
-
committed: false,
|
|
1481
|
-
retainForInFlightWork: false,
|
|
1482
|
-
};
|
|
1483
|
-
try {
|
|
1484
|
-
operationJournal.setRecoveryPayload('create_spec', operationKey, 1, {
|
|
1485
|
-
operationVersion: 1,
|
|
1486
|
-
projectPath: resolvedPath,
|
|
1487
|
-
idempotencyKey,
|
|
1488
|
-
ownerId: idempotencyClaim.ownerId,
|
|
1489
|
-
});
|
|
1490
|
-
return await (async () => {
|
|
1491
|
-
try {
|
|
1492
|
-
// SPEC-713: Phase 1 — Critical path: build + persist spec within 25s hard ceiling.
|
|
1493
|
-
// Only the steps required to produce spec.md on disk are inside this budget.
|
|
1494
|
-
// Durable post-commit work is delegated to the spec.created outbox consumer.
|
|
1495
|
-
const criticalResult = await withTotalBudget('create_spec-critical', getRuntimePolicy().createSpec.criticalTimeoutMs, async (criticalSignal) => {
|
|
1496
|
-
const { params, context, knowledge, clarificationSession, constitutionWarnings, advisoryCriteria, } = prepared;
|
|
1497
|
-
const { duplicate, projectId } = context;
|
|
1498
|
-
let spec = context.spec;
|
|
1499
|
-
let specDir = context.specDir;
|
|
1500
|
-
let specPath = context.specPath;
|
|
1501
|
-
let unifiedSpec = prepared.unifiedSpec;
|
|
1502
|
-
// SPEC-1351: serialize the id re-derivation + persistence sequence
|
|
1503
|
-
// per project. The candidate id computed during (unlocked) prepare
|
|
1504
|
-
// can collide with another in-flight create_spec call; re-deriving
|
|
1505
|
-
// it here — inside the only place that ever writes spec.md for this
|
|
1506
|
-
// project — guarantees the id actually persisted is unique.
|
|
1507
|
-
return withFileLock(`create-spec:${projectId}`, async () => {
|
|
1508
|
-
let committedPlannerToken;
|
|
1509
|
-
try {
|
|
1510
|
-
const lockedSpecId = await computeNextSpecId(resolvedPath, projectId);
|
|
1511
|
-
if (lockedSpecId !== spec.id) {
|
|
1512
|
-
const newGitBranch = generateBranchName(lockedSpecId, spec.slug, spec.type);
|
|
1513
|
-
const newSpecDir = pathJoin(pathDirname(specDir), `${lockedSpecId}-${spec.slug}`);
|
|
1514
|
-
const newSpecPath = pathJoin(newSpecDir, pathBasename(specPath));
|
|
1515
|
-
unifiedSpec = unifiedSpec
|
|
1516
|
-
.replace(`id: ${spec.id}\n`, `id: ${lockedSpecId}\n`)
|
|
1517
|
-
.replace(`branch: ${spec.gitBranch}\n`, `branch: ${newGitBranch}\n`);
|
|
1518
|
-
spec = {
|
|
1519
|
-
...spec,
|
|
1520
|
-
id: lockedSpecId,
|
|
1521
|
-
specPath: newSpecPath,
|
|
1522
|
-
technicalPath: newSpecPath,
|
|
1523
|
-
gitBranch: newGitBranch,
|
|
1524
|
-
};
|
|
1525
|
-
specDir = newSpecDir;
|
|
1526
|
-
specPath = newSpecPath;
|
|
1527
|
-
}
|
|
1528
|
-
committedPlannerToken = await issuePlannerToken(resolvedPath, spec.id, params.sessionId ?? 'unknown-session', params.modelId ?? 'unknown-model', params.host ?? 'unknown-host');
|
|
1529
|
-
}
|
|
1530
|
-
catch {
|
|
1531
|
-
// Best-effort evidence must not block durable spec creation.
|
|
1532
|
-
}
|
|
1533
|
-
const committedResult = buildCommittedCreateResult({
|
|
1534
|
-
spec,
|
|
1535
|
-
operationId: operationKey,
|
|
1536
|
-
duplicate,
|
|
1537
|
-
constitutionWarnings,
|
|
1538
|
-
clarificationSession,
|
|
1539
|
-
advisoryCriteria,
|
|
1540
|
-
experienceLevel: knowledge?.experienceLevel,
|
|
1541
|
-
contradictionHint: undefined,
|
|
1542
|
-
plannerToken: committedPlannerToken,
|
|
1543
|
-
});
|
|
1544
|
-
let storeCreated = false;
|
|
1545
|
-
try {
|
|
1546
|
-
assertExecutionCanCommit(criticalSignal);
|
|
1547
|
-
operationJournal.setRecoveryPayload('create_spec', operationKey, 1, {
|
|
1548
|
-
operationVersion: 1,
|
|
1549
|
-
projectPath: resolvedPath,
|
|
1550
|
-
idempotencyKey,
|
|
1551
|
-
ownerId: idempotencyClaim.ownerId,
|
|
1552
|
-
projectId,
|
|
1553
|
-
specId: spec.id,
|
|
1554
|
-
specPath,
|
|
1555
|
-
specContentDigest: createHash('sha256').update(unifiedSpec).digest('hex'),
|
|
1556
|
-
result: committedResult,
|
|
1557
|
-
});
|
|
1558
|
-
operationJournal.prepared('create_spec', operationKey);
|
|
1559
|
-
await executionMkdir(specDir, { recursive: true });
|
|
1560
|
-
assertExecutionCanCommit(criticalSignal);
|
|
1561
|
-
await atomicWriteFile(specPath, unifiedSpec, { encoding: 'utf-8' });
|
|
1562
|
-
assertExecutionCanCommit(criticalSignal);
|
|
1563
|
-
// SPEC-1351 (AC2): verify the write actually landed on disk
|
|
1564
|
-
// before any commit path is allowed to report persisted:true.
|
|
1565
|
-
// atomicWriteFile resolving without throwing is not sufficient
|
|
1566
|
-
// evidence under resource-exhaustion / concurrent-load
|
|
1567
|
-
// conditions that previously let the journal report success
|
|
1568
|
-
// with zero bytes ever reaching disk.
|
|
1569
|
-
const writtenStat = await fsStat(specPath).catch(() => null);
|
|
1570
|
-
if (!writtenStat || writtenStat.size === 0) {
|
|
1571
|
-
throw new Error(`create_spec failed to persist ${specPath}: file is missing or empty after write. ` +
|
|
1572
|
-
'No spec was registered — retry create_spec.');
|
|
1573
|
-
}
|
|
1574
|
-
await specStore.createSpec(projectId, spec);
|
|
1575
|
-
storeCreated = true;
|
|
1576
|
-
const lifecycleRead = specStore.getLifecycleSpec;
|
|
1577
|
-
if (lifecycleRead) {
|
|
1578
|
-
const visibleSpec = await lifecycleRead(projectId, spec.id, resolvedPath);
|
|
1579
|
-
if (visibleSpec?.id !== spec.id) {
|
|
1580
|
-
throw new Error(`create_spec persisted ${spec.id} but the lifecycle visibility barrier could not read it`);
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
// SPEC-1699: refresh the regenerable spec.md index cache file.
|
|
1584
|
-
// Best-effort — specStore.getSpec/listSpecs independently verify
|
|
1585
|
-
// spec.md's digest on every read that supplies canonicalRoot, so
|
|
1586
|
-
// a failed refresh here only lags this cache file, not a caller.
|
|
1587
|
-
await loadSpecIndex(resolvedPath).catch(() => {
|
|
1588
|
-
/* best-effort */
|
|
1589
|
-
});
|
|
1590
|
-
assertExecutionCanCommit(criticalSignal);
|
|
1591
|
-
await commitIdempotencyEvidence(resolvedPath, idempotencyKey, idempotencyClaim, spec, specPath);
|
|
1592
|
-
operationJournal.committed('create_spec', operationKey, committedResult);
|
|
1593
|
-
claimLifecycle.committed = true;
|
|
1594
|
-
// SPEC-709/SPEC-461: unified spec.md; no progress or HTML artifacts.
|
|
1595
|
-
}
|
|
1596
|
-
catch (writeErr) {
|
|
1597
|
-
const storeRolledBack = storeCreated
|
|
1598
|
-
? await specStore.deleteSpec(projectId, spec.id).catch(() => false)
|
|
1599
|
-
: true;
|
|
1600
|
-
await cleanupExecutionArtifact(getIdempotencyEvidencePath(resolvedPath, idempotencyKey), { force: true });
|
|
1601
|
-
await cleanupExecutionArtifact(specDir, { recursive: true, force: true });
|
|
1602
|
-
try {
|
|
1603
|
-
operationJournal.resolveRecovery('create_spec', operationKey, {
|
|
1604
|
-
action: storeRolledBack ? 'rollback' : 'quarantine',
|
|
1605
|
-
reason: storeRolledBack
|
|
1606
|
-
? 'create_spec persistence failed and compensating cleanup completed'
|
|
1607
|
-
: 'create_spec persistence failed and the spec store rollback was incomplete',
|
|
1608
|
-
});
|
|
1609
|
-
}
|
|
1610
|
-
catch {
|
|
1611
|
-
// The original persistence failure remains the primary error.
|
|
1612
|
-
}
|
|
1613
|
-
throw writeErr;
|
|
1614
|
-
}
|
|
1615
|
-
return {
|
|
1616
|
-
ok: true,
|
|
1617
|
-
data: {
|
|
1618
|
-
committedResult,
|
|
1619
|
-
},
|
|
1620
|
-
};
|
|
1621
|
-
});
|
|
1622
|
-
}); // end withTotalBudget critical path
|
|
1623
|
-
// SPEC-713: Handle total budget exceeded — return clear error before 60s MCP timeout
|
|
1624
|
-
if (criticalResult.timedOut) {
|
|
1625
|
-
claimLifecycle.retainForInFlightWork = criticalResult.warning.includes('exceeded');
|
|
1626
|
-
if (!claimLifecycle.retainForInFlightWork) {
|
|
1627
|
-
rollbackUncommittedOperation(operationJournal, operationKey, 'create_spec timed out before commit with no in-flight work to preserve');
|
|
1628
|
-
}
|
|
1629
|
-
// SPEC-770: Wait briefly for any in-flight spec write to complete, then scan for duplicates
|
|
1630
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
1631
|
-
const recentSpecs = await findRecentlyWrittenSpecs(resolvedPath, 2 * 60 * 1000, resolvedInputParams.title);
|
|
1632
|
-
const possibleDuplicates = recentSpecs.length > 0 ? recentSpecs : undefined;
|
|
1633
|
-
const dupNote = possibleDuplicates
|
|
1634
|
-
? `\n\nA spec may have been created server-side: ${possibleDuplicates.map((s) => s.id).join(', ')}. Retry with the same title to return it instead of creating a duplicate.`
|
|
1635
|
-
: '\n\nThe spec may not have been persisted. Check `planu/specs/` and retry.';
|
|
1636
|
-
return {
|
|
1637
|
-
content: [
|
|
1638
|
-
{
|
|
1639
|
-
type: 'text',
|
|
1640
|
-
text: `❌ create_spec exceeded its ${String(criticalResult.ceilingMs)}ms internal budget.\n\n${criticalResult.warning}${dupNote}`,
|
|
1641
|
-
},
|
|
1642
|
-
],
|
|
1643
|
-
isError: true,
|
|
1644
|
-
...(possibleDuplicates ? { structuredContent: { possibleDuplicates } } : {}),
|
|
1645
|
-
};
|
|
1646
|
-
}
|
|
1647
|
-
if (criticalResult.status === 'failed') {
|
|
1648
|
-
rollbackUncommittedOperation(operationJournal, operationKey, 'create_spec critical path failed before commit');
|
|
1649
|
-
return {
|
|
1650
|
-
content: [{ type: 'text', text: criticalResult.warning }],
|
|
1651
|
-
isError: true,
|
|
1652
|
-
structuredContent: {
|
|
1653
|
-
error: 'OPERATION_FAILED',
|
|
1654
|
-
category: criticalResult.category,
|
|
1655
|
-
elapsedMs: criticalResult.elapsedMs,
|
|
1656
|
-
persisted: false,
|
|
1657
|
-
},
|
|
1658
|
-
};
|
|
1659
|
-
}
|
|
1660
|
-
if (!criticalResult.value.ok) {
|
|
1661
|
-
rollbackUncommittedOperation(operationJournal, operationKey, 'create_spec returned early before commit');
|
|
1662
|
-
return criticalResult.value.earlyReturn;
|
|
1663
|
-
}
|
|
1664
|
-
if (!claimLifecycle.committed) {
|
|
1665
|
-
throw new Error('create_spec critical path completed without a durable commit');
|
|
1666
|
-
}
|
|
1667
|
-
const committedResult = criticalResult.value.data.committedResult;
|
|
1668
|
-
// SPEC-1342: surface the original (pre-translation) language on the created spec's response.
|
|
1669
|
-
if (originalLanguage && !committedResult.isError) {
|
|
1670
|
-
committedResult.structuredContent = {
|
|
1671
|
-
...committedResult.structuredContent,
|
|
1672
|
-
originalLanguage,
|
|
1673
|
-
};
|
|
1674
|
-
}
|
|
1675
|
-
return finishRecoveredOperation(operationJournal, operationKey, committedResult);
|
|
1676
|
-
}
|
|
1677
|
-
catch (error) {
|
|
1678
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1679
|
-
const errorResult = {
|
|
1680
|
-
content: [{ type: 'text', text: ti('errors.internalError', { message }) }],
|
|
1681
|
-
isError: true,
|
|
1682
|
-
};
|
|
1683
|
-
if (claimLifecycle.committed) {
|
|
1684
|
-
return finishRecoveredOperation(operationJournal, operationKey, errorResult);
|
|
1685
|
-
}
|
|
1686
|
-
rollbackUncommittedOperation(operationJournal, operationKey, 'create_spec failed before commit');
|
|
1687
|
-
return errorResult;
|
|
1688
|
-
}
|
|
1689
|
-
})();
|
|
1690
|
-
}
|
|
1691
|
-
finally {
|
|
1692
|
-
if (!claimLifecycle.committed && !claimLifecycle.retainForInFlightWork) {
|
|
1693
|
-
await releaseIdempotencyClaim(resolvedPath, idempotencyKey, idempotencyClaim.ownerId);
|
|
1694
|
-
}
|
|
1695
|
-
runtimeDatabase.close();
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
//# sourceMappingURL=create-spec.js.map
|