project-tiny-context-harness 0.8.16 → 0.11.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/README.md +119 -41
- package/assets/README.md +184 -55
- package/assets/README.zh-CN.md +114 -40
- package/assets/agents/AGENTS_CORE.md +2 -2
- package/assets/context_templates/context.toml +6 -1
- package/assets/context_templates/screen-contract.md +16 -0
- package/assets/runtime/windows-job-supervisor/formal_process_supervisor_native_helpers.cs +301 -0
- package/assets/runtime/windows-job-supervisor/formal_process_supervisor_native_run.cs +197 -0
- package/assets/runtime/windows-job-supervisor/formal_process_supervisor_native_types.cs +215 -0
- package/assets/runtime/windows-job-supervisor/windows_job_process_supervisor.ps1 +117 -0
- package/assets/skills/context_development_engineer/SKILL.md +16 -30
- package/assets/skills/context_development_engineer/references/engineering-design-reasoning.md +93 -0
- package/assets/skills/context_surface_contract/SKILL.md +13 -2
- package/assets/skills/context_uiux_design/SKILL.md +7 -3
- package/assets/skills/context_uiux_design/references/task-uiux-analysis.md +82 -0
- package/assets/skills/design-resource-authoring/SKILL.md +18 -9
- package/assets/skills/design-resource-authoring/references/authority-delta-assessment.md +52 -0
- package/assets/skills/design-resource-authoring/references/downstream-handoff.md +22 -6
- package/assets/skills/design-resource-authoring/references/formal-selected-web-app-handoff.md +26 -8
- package/assets/skills/design-resource-authoring/references/implementation-feasibility.md +111 -0
- package/assets/skills/design-resource-authoring/references/open-design-provider.md +45 -7
- package/assets/skills/design-resource-authoring/references/recovery-and-writeback.md +7 -1
- package/assets/skills/design-resource-authoring/references/resource-selection.md +115 -3
- package/assets/skills/design-system-authoring/SKILL.md +23 -17
- package/assets/skills/design-system-authoring/references/authority-adoption.md +19 -9
- package/assets/skills/design-system-authoring/references/open-design-design-system-provider.md +4 -0
- package/assets/skills/long-task-workflow/SKILL.md +6 -6
- package/assets/skills/long-task-workflow/references/authority-lifecycle.md +10 -4
- package/assets/skills/long-task-workflow/references/contract-authoring.md +5 -5
- package/assets/skills/long-task-workflow/references/evidence-design.md +14 -3
- package/assets/skills/long-task-workflow/references/source-authoring.md +11 -8
- package/assets/tools/context_rules.json +53 -0
- package/assets/tools/validate_context.py +302 -77
- package/dist/cli.js +2 -1
- package/dist/commands/context-create.d.ts +1 -0
- package/dist/commands/context-create.js +90 -0
- package/dist/commands/context-inspect.d.ts +1 -0
- package/dist/commands/context-inspect.js +98 -0
- package/dist/commands/context-move.d.ts +1 -0
- package/dist/commands/context-move.js +78 -0
- package/dist/commands/context-register.d.ts +1 -0
- package/dist/commands/context-register.js +110 -0
- package/dist/commands/context-transaction.d.ts +1 -0
- package/dist/commands/context-transaction.js +84 -0
- package/dist/commands/context.d.ts +1 -0
- package/dist/commands/context.js +36 -0
- package/dist/commands/design-authority-delta.d.ts +1 -0
- package/dist/commands/design-authority-delta.js +53 -0
- package/dist/commands/design-authority.d.ts +1 -0
- package/dist/commands/design-authority.js +104 -0
- package/dist/commands/design-resource.js +17 -3
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.js +61 -3
- package/dist/commands/index.js +19 -2
- package/dist/commands/long-task-authoring.js +20 -2
- package/dist/commands/long-task-workdir.d.ts +2 -0
- package/dist/commands/long-task-workdir.js +23 -0
- package/dist/commands/long-task.js +75 -6
- package/dist/commands/route.d.ts +15 -0
- package/dist/commands/route.js +142 -0
- package/dist/index.d.ts +3 -13
- package/dist/index.js +3 -12
- package/dist/lib/cli-exit.d.ts +14 -0
- package/dist/lib/cli-exit.js +19 -0
- package/dist/lib/context-catalog/catalog-default-footprint.d.ts +3 -0
- package/dist/lib/context-catalog/catalog-default-footprint.js +53 -0
- package/dist/lib/context-catalog/catalog-diagnostics.d.ts +9 -0
- package/dist/lib/context-catalog/catalog-diagnostics.js +34 -0
- package/dist/lib/context-catalog/catalog-discovery.d.ts +7 -0
- package/dist/lib/context-catalog/catalog-discovery.js +81 -0
- package/dist/lib/context-catalog/catalog-load.d.ts +8 -0
- package/dist/lib/context-catalog/catalog-load.js +187 -0
- package/dist/lib/context-catalog/catalog-path-validation.d.ts +7 -0
- package/dist/lib/context-catalog/catalog-path-validation.js +62 -0
- package/dist/lib/context-catalog/catalog-paths.d.ts +11 -0
- package/dist/lib/context-catalog/catalog-paths.js +41 -0
- package/dist/lib/context-catalog/catalog-portable-contract.d.ts +15 -0
- package/dist/lib/context-catalog/catalog-portable-contract.js +68 -0
- package/dist/lib/context-catalog/catalog-staged-path-safety.d.ts +1 -0
- package/dist/lib/context-catalog/catalog-staged-path-safety.js +36 -0
- package/dist/lib/context-catalog/catalog-types.d.ts +40 -0
- package/dist/lib/context-catalog/catalog-types.js +1 -0
- package/dist/lib/context-catalog/catalog-validation.d.ts +9 -0
- package/dist/lib/context-catalog/catalog-validation.js +148 -0
- package/dist/lib/context-create/context-create-path.d.ts +2 -0
- package/dist/lib/context-create/context-create-path.js +30 -0
- package/dist/lib/context-create/context-create-template.d.ts +2 -0
- package/dist/lib/context-create/context-create-template.js +95 -0
- package/dist/lib/context-create/context-create-types.d.ts +28 -0
- package/dist/lib/context-create/context-create-types.js +1 -0
- package/dist/lib/context-create/context-create-write.d.ts +1 -0
- package/dist/lib/context-create/context-create-write.js +85 -0
- package/dist/lib/context-create/context-create.d.ts +2 -0
- package/dist/lib/context-create/context-create.js +84 -0
- package/dist/lib/context-default-footprint.d.ts +2 -3
- package/dist/lib/context-default-footprint.js +49 -57
- package/dist/lib/context-doctor/context-doctor-types.d.ts +16 -0
- package/dist/lib/context-doctor/context-doctor-types.js +15 -0
- package/dist/lib/context-doctor/context-doctor.d.ts +2 -0
- package/dist/lib/context-doctor/context-doctor.js +130 -0
- package/dist/lib/context-graph-snapshot.d.ts +5 -0
- package/dist/lib/context-graph-snapshot.js +46 -25
- package/dist/lib/context-inspect/context-inspect-projection.d.ts +9 -0
- package/dist/lib/context-inspect/context-inspect-projection.js +49 -0
- package/dist/lib/context-inspect/context-inspect-render.d.ts +2 -0
- package/dist/lib/context-inspect/context-inspect-render.js +29 -0
- package/dist/lib/context-inspect/context-inspect-types.d.ts +43 -0
- package/dist/lib/context-inspect/context-inspect-types.js +1 -0
- package/dist/lib/context-inspect/context-inspect.d.ts +2 -0
- package/dist/lib/context-inspect/context-inspect.js +104 -0
- package/dist/lib/context-manifest-schema.d.ts +1 -1
- package/dist/lib/context-manifest-schema.js +4 -20
- package/dist/lib/context-markdown/context-markdown-analysis.d.ts +15 -0
- package/dist/lib/context-markdown/context-markdown-analysis.js +245 -0
- package/dist/lib/context-markdown/context-markdown-extract.d.ts +7 -0
- package/dist/lib/context-markdown/context-markdown-extract.js +114 -0
- package/dist/lib/context-markdown/context-markdown-types.d.ts +57 -0
- package/dist/lib/context-markdown/context-markdown-types.js +1 -0
- package/dist/lib/context-move/context-move-input.d.ts +8 -0
- package/dist/lib/context-move/context-move-input.js +17 -0
- package/dist/lib/context-move/context-move-literal-scan.d.ts +20 -0
- package/dist/lib/context-move/context-move-literal-scan.js +213 -0
- package/dist/lib/context-move/context-move-live-validation.d.ts +3 -0
- package/dist/lib/context-move/context-move-live-validation.js +56 -0
- package/dist/lib/context-move/context-move-markdown-plan.d.ts +22 -0
- package/dist/lib/context-move/context-move-markdown-plan.js +39 -0
- package/dist/lib/context-move/context-move-projection.d.ts +3 -0
- package/dist/lib/context-move/context-move-projection.js +11 -0
- package/dist/lib/context-move/context-move-reference-validation.d.ts +11 -0
- package/dist/lib/context-move/context-move-reference-validation.js +64 -0
- package/dist/lib/context-move/context-move-render.d.ts +2 -0
- package/dist/lib/context-move/context-move-render.js +24 -0
- package/dist/lib/context-move/context-move-support.d.ts +10 -0
- package/dist/lib/context-move/context-move-support.js +88 -0
- package/dist/lib/context-move/context-move-transaction-plan.d.ts +24 -0
- package/dist/lib/context-move/context-move-transaction-plan.js +108 -0
- package/dist/lib/context-move/context-move-types.d.ts +74 -0
- package/dist/lib/context-move/context-move-types.js +1 -0
- package/dist/lib/context-move/context-move.d.ts +8 -0
- package/dist/lib/context-move/context-move.js +180 -0
- package/dist/lib/context-mutation/manifest-lossless-patch.d.ts +28 -0
- package/dist/lib/context-mutation/manifest-lossless-patch.js +208 -0
- package/dist/lib/context-mutation/markdown-link-patch.d.ts +34 -0
- package/dist/lib/context-mutation/markdown-link-patch.js +143 -0
- package/dist/lib/context-mutation/markdown-link-spans.d.ts +10 -0
- package/dist/lib/context-mutation/markdown-link-spans.js +179 -0
- package/dist/lib/context-mutation/mutation-cas.d.ts +13 -0
- package/dist/lib/context-mutation/mutation-cas.js +365 -0
- package/dist/lib/context-mutation/mutation-command-support.d.ts +12 -0
- package/dist/lib/context-mutation/mutation-command-support.js +57 -0
- package/dist/lib/context-mutation/mutation-commit.d.ts +12 -0
- package/dist/lib/context-mutation/mutation-commit.js +89 -0
- package/dist/lib/context-mutation/mutation-directories.d.ts +5 -0
- package/dist/lib/context-mutation/mutation-directories.js +56 -0
- package/dist/lib/context-mutation/mutation-file-state.d.ts +14 -0
- package/dist/lib/context-mutation/mutation-file-state.js +137 -0
- package/dist/lib/context-mutation/mutation-journal-file-validation.d.ts +1 -0
- package/dist/lib/context-mutation/mutation-journal-file-validation.js +106 -0
- package/dist/lib/context-mutation/mutation-journal-io.d.ts +5 -0
- package/dist/lib/context-mutation/mutation-journal-io.js +55 -0
- package/dist/lib/context-mutation/mutation-journal-storage.d.ts +18 -0
- package/dist/lib/context-mutation/mutation-journal-storage.js +283 -0
- package/dist/lib/context-mutation/mutation-journal-validation-support.d.ts +16 -0
- package/dist/lib/context-mutation/mutation-journal-validation-support.js +140 -0
- package/dist/lib/context-mutation/mutation-journal-validation.d.ts +3 -0
- package/dist/lib/context-mutation/mutation-journal-validation.js +177 -0
- package/dist/lib/context-mutation/mutation-journal.d.ts +8 -0
- package/dist/lib/context-mutation/mutation-journal.js +111 -0
- package/dist/lib/context-mutation/mutation-live-validation.d.ts +3 -0
- package/dist/lib/context-mutation/mutation-live-validation.js +51 -0
- package/dist/lib/context-mutation/mutation-long-task-guard.d.ts +6 -0
- package/dist/lib/context-mutation/mutation-long-task-guard.js +57 -0
- package/dist/lib/context-mutation/mutation-recovery.d.ts +4 -0
- package/dist/lib/context-mutation/mutation-recovery.js +189 -0
- package/dist/lib/context-mutation/mutation-staged-fs.d.ts +5 -0
- package/dist/lib/context-mutation/mutation-staged-fs.js +56 -0
- package/dist/lib/context-mutation/mutation-types.d.ts +103 -0
- package/dist/lib/context-mutation/mutation-types.js +1 -0
- package/dist/lib/context-register/context-register-input.d.ts +11 -0
- package/dist/lib/context-register/context-register-input.js +43 -0
- package/dist/lib/context-register/context-register-render.d.ts +2 -0
- package/dist/lib/context-register/context-register-render.js +21 -0
- package/dist/lib/context-register/context-register-support.d.ts +6 -0
- package/dist/lib/context-register/context-register-support.js +46 -0
- package/dist/lib/context-register/context-register-types.d.ts +46 -0
- package/dist/lib/context-register/context-register-types.js +1 -0
- package/dist/lib/context-register/context-register.d.ts +8 -0
- package/dist/lib/context-register/context-register.js +155 -0
- package/dist/lib/context-router/context-route-budget.d.ts +15 -0
- package/dist/lib/context-router/context-route-budget.js +14 -0
- package/dist/lib/context-router/context-route-candidates.d.ts +15 -0
- package/dist/lib/context-router/context-route-candidates.js +112 -0
- package/dist/lib/context-router/context-route-order.d.ts +6 -0
- package/dist/lib/context-router/context-route-order.js +53 -0
- package/dist/lib/context-router/context-route-paths.d.ts +16 -0
- package/dist/lib/context-router/context-route-paths.js +109 -0
- package/dist/lib/context-router/context-route-render.d.ts +2 -0
- package/dist/lib/context-router/context-route-render.js +32 -0
- package/dist/lib/context-router/context-route-scan.d.ts +18 -0
- package/dist/lib/context-router/context-route-scan.js +156 -0
- package/dist/lib/context-router/context-route-selection.d.ts +16 -0
- package/dist/lib/context-router/context-route-selection.js +72 -0
- package/dist/lib/context-router/context-route-terms.d.ts +13 -0
- package/dist/lib/context-router/context-route-terms.js +202 -0
- package/dist/lib/context-router/context-route-types.d.ts +101 -0
- package/dist/lib/context-router/context-route-types.js +1 -0
- package/dist/lib/context-router/context-route.d.ts +2 -0
- package/dist/lib/context-router/context-route.js +127 -0
- package/dist/lib/context-units-migration.d.ts +13 -0
- package/dist/lib/context-units-migration.js +217 -0
- package/dist/lib/design-authority-binding.d.ts +7 -0
- package/dist/lib/design-authority-binding.js +96 -0
- package/dist/lib/design-authority-closure.d.ts +3 -0
- package/dist/lib/design-authority-closure.js +201 -0
- package/dist/lib/design-authority-delta-codec-primitives.d.ts +10 -0
- package/dist/lib/design-authority-delta-codec-primitives.js +58 -0
- package/dist/lib/design-authority-delta-codec.d.ts +2 -0
- package/dist/lib/design-authority-delta-codec.js +193 -0
- package/dist/lib/design-authority-delta-types.d.ts +65 -0
- package/dist/lib/design-authority-delta-types.js +6 -0
- package/dist/lib/design-authority-delta-validation.d.ts +2 -0
- package/dist/lib/design-authority-delta-validation.js +16 -0
- package/dist/lib/design-authority-digest.d.ts +8 -0
- package/dist/lib/design-authority-digest.js +36 -0
- package/dist/lib/design-authority-files.d.ts +9 -0
- package/dist/lib/design-authority-files.js +62 -0
- package/dist/lib/design-authority-format.d.ts +2 -0
- package/dist/lib/design-authority-format.js +93 -0
- package/dist/lib/design-authority-links.d.ts +10 -0
- package/dist/lib/design-authority-links.js +137 -0
- package/dist/lib/design-authority-manifest.d.ts +4 -0
- package/dist/lib/design-authority-manifest.js +144 -0
- package/dist/lib/design-authority-tokens.d.ts +9 -0
- package/dist/lib/design-authority-tokens.js +45 -0
- package/dist/lib/design-authority-types.d.ts +80 -0
- package/dist/lib/design-authority-types.js +23 -0
- package/dist/lib/design-md-tool-adapter.d.ts +9 -0
- package/dist/lib/design-md-tool-adapter.js +152 -0
- package/dist/lib/design-md-tool-normalization.d.ts +7 -0
- package/dist/lib/design-md-tool-normalization.js +78 -0
- package/dist/lib/design-md-tool-types.d.ts +99 -0
- package/dist/lib/design-md-tool-types.js +8 -0
- package/dist/lib/design-resource-handoff-bundle.js +5 -0
- package/dist/lib/design-resource-handoff-input-types.d.ts +1 -1
- package/dist/lib/design-resource-handoff-manifest-projection.js +4 -0
- package/dist/lib/design-resource-handoff-set-integrity.js +1 -0
- package/dist/lib/design-resource-handoff-shape.js +18 -2
- package/dist/lib/design-resource-handoff-types.d.ts +8 -0
- package/dist/lib/design-resource-handoff-validation.js +24 -0
- package/dist/lib/design-resource-implementation-feasibility-model.d.ts +35 -0
- package/dist/lib/design-resource-implementation-feasibility-model.js +62 -0
- package/dist/lib/design-resource-implementation-feasibility-shape-sections.d.ts +43 -0
- package/dist/lib/design-resource-implementation-feasibility-shape-sections.js +142 -0
- package/dist/lib/design-resource-implementation-feasibility-shape.d.ts +4 -0
- package/dist/lib/design-resource-implementation-feasibility-shape.js +154 -0
- package/dist/lib/design-resource-implementation-feasibility-source-decision-projection.d.ts +24 -0
- package/dist/lib/design-resource-implementation-feasibility-source-decision-projection.js +106 -0
- package/dist/lib/design-resource-implementation-feasibility-source-decision.d.ts +21 -0
- package/dist/lib/design-resource-implementation-feasibility-source-decision.js +75 -0
- package/dist/lib/design-resource-implementation-feasibility-types.d.ts +135 -0
- package/dist/lib/design-resource-implementation-feasibility-types.js +37 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-cells.d.ts +5 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-cells.js +125 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-document.d.ts +4 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-document.js +167 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-facts.d.ts +3 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-facts.js +76 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-realizations.d.ts +8 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-realizations.js +76 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-support.d.ts +10 -0
- package/dist/lib/design-resource-implementation-feasibility-validation-support.js +75 -0
- package/dist/lib/design-resource-implementation-feasibility-validation.d.ts +3 -0
- package/dist/lib/design-resource-implementation-feasibility-validation.js +138 -0
- package/dist/lib/design-resource-recovery-current.js +22 -0
- package/dist/lib/design-resource-recovery-shape.js +64 -7
- package/dist/lib/design-resource-recovery-types.d.ts +4 -1
- package/dist/lib/design-resource-symbolic-fact-shape.js +9 -1
- package/dist/lib/design-resource-symbolic-fact-types.d.ts +8 -0
- package/dist/lib/design-resource-symbolic-fact-validation.js +25 -0
- package/dist/lib/doctor.d.ts +2 -1
- package/dist/lib/doctor.js +29 -1
- package/dist/lib/fs.js +1 -1
- package/dist/lib/long-task-acceptance-reachability-claims.d.ts +2 -0
- package/dist/lib/long-task-acceptance-reachability-claims.js +279 -0
- package/dist/lib/long-task-acceptance-reachability-design.d.ts +2 -0
- package/dist/lib/long-task-acceptance-reachability-design.js +96 -0
- package/dist/lib/long-task-acceptance-reachability-external.d.ts +9 -0
- package/dist/lib/long-task-acceptance-reachability-external.js +123 -0
- package/dist/lib/long-task-acceptance-reachability-helpers.d.ts +64 -0
- package/dist/lib/long-task-acceptance-reachability-helpers.js +473 -0
- package/dist/lib/long-task-acceptance-reachability-semantic.d.ts +2 -0
- package/dist/lib/long-task-acceptance-reachability-semantic.js +122 -0
- package/dist/lib/long-task-acceptance-reachability-types.d.ts +91 -0
- package/dist/lib/long-task-acceptance-reachability-types.js +1 -0
- package/dist/lib/long-task-acceptance-reachability.d.ts +4 -0
- package/dist/lib/long-task-acceptance-reachability.js +115 -0
- package/dist/lib/long-task-activation-validation.d.ts +6 -0
- package/dist/lib/long-task-activation-validation.js +96 -23
- package/dist/lib/long-task-active-authority-lock-context.d.ts +4 -0
- package/dist/lib/long-task-active-authority-lock-context.js +29 -0
- package/dist/lib/long-task-applicability-identity.d.ts +25 -0
- package/dist/lib/long-task-applicability-identity.js +60 -0
- package/dist/lib/long-task-authoring-preflight-diagnostics.js +8 -0
- package/dist/lib/long-task-authoring-preflight-types.d.ts +2 -0
- package/dist/lib/long-task-authoring-preflight-types.js +9 -0
- package/dist/lib/long-task-authoring-preflight.js +18 -2
- package/dist/lib/long-task-authority-material-diff.js +4 -0
- package/dist/lib/long-task-authority-materials.js +19 -0
- package/dist/lib/long-task-authority-policy.d.ts +3 -0
- package/dist/lib/long-task-authority-policy.js +3 -0
- package/dist/lib/long-task-authority-revision-details.js +2 -1
- package/dist/lib/long-task-authority-types.d.ts +2 -0
- package/dist/lib/long-task-authority.js +2 -0
- package/dist/lib/long-task-check-runner.js +3 -296
- package/dist/lib/long-task-check-shape.js +6 -1
- package/dist/lib/long-task-claim-definitions.js +1 -3
- package/dist/lib/long-task-claim-semantic-proof-floor.d.ts +3 -0
- package/dist/lib/long-task-claim-semantic-proof-floor.js +78 -0
- package/dist/lib/long-task-claims.d.ts +0 -18
- package/dist/lib/long-task-claims.js +15 -14
- package/dist/lib/long-task-command-process.d.ts +9 -0
- package/dist/lib/long-task-command-process.js +178 -0
- package/dist/lib/long-task-compact-authoring.js +3 -0
- package/dist/lib/long-task-compact-projections.js +10 -0
- package/dist/lib/long-task-complete-delivery-evidence-types.d.ts +38 -0
- package/dist/lib/long-task-complete-delivery-evidence-types.js +1 -0
- package/dist/lib/long-task-completion-types.d.ts +109 -0
- package/dist/lib/long-task-completion-types.js +1 -0
- package/dist/lib/long-task-conformance-policy.d.ts +2 -1
- package/dist/lib/long-task-conformance-policy.js +11 -4
- package/dist/lib/long-task-context-authority-topology.js +6 -4
- package/dist/lib/long-task-contract-types.d.ts +52 -1
- package/dist/lib/long-task-counterfactual-sandbox.d.ts +7 -1
- package/dist/lib/long-task-counterfactual-sandbox.js +86 -6
- package/dist/lib/long-task-delivery-compiler-preflight.d.ts +24 -0
- package/dist/lib/long-task-delivery-compiler-preflight.js +32 -0
- package/dist/lib/long-task-delivery-compiler.d.ts +1 -0
- package/dist/lib/long-task-delivery-compiler.js +59 -44
- package/dist/lib/long-task-delivery-parser.d.ts +3 -0
- package/dist/lib/long-task-delivery-parser.js +26 -8
- package/dist/lib/long-task-delivery-types.d.ts +2 -0
- package/dist/lib/long-task-delivery-types.js +2 -0
- package/dist/lib/long-task-delivery-validation.d.ts +11 -3
- package/dist/lib/long-task-delivery-validation.js +23 -8
- package/dist/lib/long-task-design-feasibility-binding-owners.d.ts +6 -0
- package/dist/lib/long-task-design-feasibility-binding-owners.js +52 -0
- package/dist/lib/long-task-design-feasibility-binding.d.ts +14 -0
- package/dist/lib/long-task-design-feasibility-binding.js +114 -0
- package/dist/lib/long-task-design-feasibility-source-closure.d.ts +11 -0
- package/dist/lib/long-task-design-feasibility-source-closure.js +87 -0
- package/dist/lib/long-task-design-obligation.d.ts +50 -0
- package/dist/lib/long-task-design-obligation.js +99 -0
- package/dist/lib/long-task-design-resource-handoff.d.ts +5 -3
- package/dist/lib/long-task-design-resource-handoff.js +64 -4
- package/dist/lib/long-task-design-resource-method-binding.js +20 -2
- package/dist/lib/long-task-effective-external-takeover.d.ts +15 -0
- package/dist/lib/long-task-effective-external-takeover.js +109 -0
- package/dist/lib/long-task-effective-external-ui-takeover.d.ts +5 -0
- package/dist/lib/long-task-effective-external-ui-takeover.js +117 -0
- package/dist/lib/long-task-evidence-capability-codec.js +91 -0
- package/dist/lib/long-task-evidence-capability-runtime.js +62 -14
- package/dist/lib/long-task-evidence-capability-types.d.ts +3 -2
- package/dist/lib/long-task-evidence-v2.d.ts +6 -1
- package/dist/lib/long-task-evidence-v2.js +253 -170
- package/dist/lib/long-task-execution-observation.d.ts +7 -0
- package/dist/lib/long-task-execution-observation.js +21 -4
- package/dist/lib/long-task-expected-authority.d.ts +4 -0
- package/dist/lib/long-task-expected-authority.js +126 -0
- package/dist/lib/long-task-external-confirmation-artifacts.d.ts +9 -0
- package/dist/lib/long-task-external-confirmation-artifacts.js +138 -0
- package/dist/lib/long-task-external-confirmation-attestation.d.ts +20 -0
- package/dist/lib/long-task-external-confirmation-attestation.js +115 -0
- package/dist/lib/long-task-external-confirmation-challenge.d.ts +23 -0
- package/dist/lib/long-task-external-confirmation-challenge.js +164 -0
- package/dist/lib/long-task-external-confirmation-context.d.ts +14 -0
- package/dist/lib/long-task-external-confirmation-context.js +53 -0
- package/dist/lib/long-task-external-confirmation-evaluation.d.ts +11 -0
- package/dist/lib/long-task-external-confirmation-evaluation.js +454 -0
- package/dist/lib/long-task-external-confirmation-expected.d.ts +8 -0
- package/dist/lib/long-task-external-confirmation-expected.js +200 -0
- package/dist/lib/long-task-external-confirmation-identity.d.ts +10 -0
- package/dist/lib/long-task-external-confirmation-identity.js +77 -0
- package/dist/lib/long-task-external-confirmation-plan.d.ts +25 -0
- package/dist/lib/long-task-external-confirmation-plan.js +148 -0
- package/dist/lib/long-task-external-confirmation-preparation.d.ts +4 -0
- package/dist/lib/long-task-external-confirmation-preparation.js +100 -0
- package/dist/lib/long-task-external-confirmation-shape.d.ts +8 -0
- package/dist/lib/long-task-external-confirmation-shape.js +387 -0
- package/dist/lib/long-task-external-confirmation-state.d.ts +10 -0
- package/dist/lib/long-task-external-confirmation-state.js +109 -0
- package/dist/lib/long-task-external-confirmation-types.d.ts +195 -0
- package/dist/lib/long-task-external-confirmation-types.js +1 -0
- package/dist/lib/long-task-final-integrity.d.ts +2 -0
- package/dist/lib/long-task-final-integrity.js +21 -10
- package/dist/lib/long-task-final-v2.d.ts +7 -2
- package/dist/lib/long-task-final-v2.js +179 -55
- package/dist/lib/long-task-finalization-identity.d.ts +27 -0
- package/dist/lib/long-task-finalization-identity.js +58 -0
- package/dist/lib/long-task-finding-context.d.ts +1 -1
- package/dist/lib/long-task-finding-context.js +139 -13
- package/dist/lib/long-task-freshness.d.ts +27 -0
- package/dist/lib/long-task-freshness.js +129 -6
- package/dist/lib/long-task-git.js +3 -3
- package/dist/lib/long-task-material-input-closure.d.ts +3 -0
- package/dist/lib/long-task-material-input-closure.js +92 -0
- package/dist/lib/long-task-obligation-authority-resolution.d.ts +12 -0
- package/dist/lib/long-task-obligation-authority-resolution.js +57 -0
- package/dist/lib/long-task-obligation-semantic-identity.d.ts +16 -0
- package/dist/lib/long-task-obligation-semantic-identity.js +116 -0
- package/dist/lib/long-task-observation-authority.d.ts +11 -0
- package/dist/lib/long-task-observation-authority.js +137 -6
- package/dist/lib/long-task-process-table.d.ts +9 -0
- package/dist/lib/long-task-process-table.js +87 -0
- package/dist/lib/long-task-process-tree.d.ts +8 -0
- package/dist/lib/long-task-process-tree.js +108 -0
- package/dist/lib/long-task-proof-adequacy.d.ts +12 -0
- package/dist/lib/long-task-proof-adequacy.js +57 -0
- package/dist/lib/long-task-proof-capability-floor.d.ts +6 -0
- package/dist/lib/long-task-proof-capability-floor.js +137 -0
- package/dist/lib/long-task-protected-files.d.ts +1 -1
- package/dist/lib/long-task-protected-files.js +1 -1
- package/dist/lib/long-task-repair-frontier-checks.d.ts +8 -0
- package/dist/lib/long-task-repair-frontier-checks.js +93 -0
- package/dist/lib/long-task-repair-frontier-groups.d.ts +2 -0
- package/dist/lib/long-task-repair-frontier-groups.js +64 -0
- package/dist/lib/long-task-repair-frontier-utils.d.ts +6 -0
- package/dist/lib/long-task-repair-frontier-utils.js +27 -0
- package/dist/lib/long-task-repair-frontier.d.ts +14 -0
- package/dist/lib/long-task-repair-frontier.js +132 -0
- package/dist/lib/long-task-risk.d.ts +3 -2
- package/dist/lib/long-task-risk.js +73 -24
- package/dist/lib/long-task-root-shape.js +148 -8
- package/dist/lib/long-task-runner-freeze.d.ts +2 -1
- package/dist/lib/long-task-runner-freeze.js +23 -8
- package/dist/lib/long-task-runtime-types.d.ts +34 -40
- package/dist/lib/long-task-semantic-assurance-policy.js +2 -11
- package/dist/lib/long-task-semantic-contract-types.d.ts +2 -1
- package/dist/lib/long-task-semantic-drift-migration.js +48 -2
- package/dist/lib/long-task-semantic-fact-binding-types.d.ts +20 -0
- package/dist/lib/long-task-semantic-fact-closure.d.ts +5 -1
- package/dist/lib/long-task-semantic-fact-closure.js +33 -5
- package/dist/lib/long-task-semantic-fact-contract-closure.js +176 -1
- package/dist/lib/long-task-semantic-fact-contract-proofs.js +18 -1
- package/dist/lib/long-task-semantic-fact-input-closure.d.ts +16 -2
- package/dist/lib/long-task-semantic-fact-input-closure.js +138 -15
- package/dist/lib/long-task-semantic-fact-provenance-closure.js +1 -1
- package/dist/lib/long-task-semantic-fact-shape.d.ts +2 -1
- package/dist/lib/long-task-semantic-fact-shape.js +35 -1
- package/dist/lib/long-task-semantic-proof-adequacy.d.ts +2 -0
- package/dist/lib/long-task-semantic-proof-adequacy.js +19 -0
- package/dist/lib/long-task-semantic-proof-profile.d.ts +5 -0
- package/dist/lib/long-task-semantic-proof-profile.js +187 -0
- package/dist/lib/long-task-shape-primitives.d.ts +1 -1
- package/dist/lib/long-task-shape-primitives.js +5 -0
- package/dist/lib/long-task-source-anchors.d.ts +10 -0
- package/dist/lib/long-task-source-anchors.js +102 -0
- package/dist/lib/long-task-source-authority-types.d.ts +46 -0
- package/dist/lib/long-task-source-claim-validation.js +36 -0
- package/dist/lib/long-task-source-conservation-facts.d.ts +8 -0
- package/dist/lib/long-task-source-conservation-facts.js +57 -0
- package/dist/lib/long-task-source-conservation-types.d.ts +34 -0
- package/dist/lib/long-task-source-conservation-types.js +1 -0
- package/dist/lib/long-task-source-conservation.d.ts +7 -0
- package/dist/lib/long-task-source-conservation.js +110 -0
- package/dist/lib/long-task-source-fragments.d.ts +6 -0
- package/dist/lib/long-task-source-fragments.js +219 -0
- package/dist/lib/long-task-source-projection-resolution.d.ts +5 -0
- package/dist/lib/long-task-source-projection-resolution.js +57 -0
- package/dist/lib/long-task-source-projection-validation.d.ts +17 -0
- package/dist/lib/long-task-source-projection-validation.js +154 -0
- package/dist/lib/long-task-source-shape.js +14 -6
- package/dist/lib/long-task-source-supersession.d.ts +5 -0
- package/dist/lib/long-task-source-supersession.js +138 -0
- package/dist/lib/long-task-stage-policy.d.ts +7 -2
- package/dist/lib/long-task-stage-policy.js +67 -23
- package/dist/lib/long-task-state.d.ts +18 -4
- package/dist/lib/long-task-state.js +319 -33
- package/dist/lib/long-task-static-observation-freeze.js +4 -3
- package/dist/lib/long-task-status-projection.d.ts +3 -1
- package/dist/lib/long-task-status-projection.js +44 -13
- package/dist/lib/long-task-status-v2.d.ts +10 -6
- package/dist/lib/long-task-status-v2.js +70 -58
- package/dist/lib/long-task-target-policy.d.ts +8 -3
- package/dist/lib/long-task-target-policy.js +40 -9
- package/dist/lib/long-task-terminal-finalization.d.ts +12 -0
- package/dist/lib/long-task-terminal-finalization.js +190 -0
- package/dist/lib/long-task-ui-design-policy.js +15 -4
- package/dist/lib/long-task-ui-surface-policy.d.ts +2 -1
- package/dist/lib/long-task-ui-surface-policy.js +7 -4
- package/dist/lib/long-task-ui-surface-validation.d.ts +3 -1
- package/dist/lib/long-task-ui-surface-validation.js +2 -2
- package/dist/lib/long-task-verifier-counterfactuals.d.ts +11 -0
- package/dist/lib/long-task-verifier-counterfactuals.js +96 -0
- package/dist/lib/long-task-verifier-execution.d.ts +9 -0
- package/dist/lib/long-task-verifier-execution.js +67 -0
- package/dist/lib/long-task-verifier-identity.js +16 -5
- package/dist/lib/long-task-verifier-v2.js +52 -65
- package/dist/lib/long-task-windows-job-supervisor-helper.d.ts +1 -0
- package/dist/lib/long-task-windows-job-supervisor-helper.js +104 -0
- package/dist/lib/long-task-windows-job-supervisor-protocol.d.ts +28 -0
- package/dist/lib/long-task-windows-job-supervisor-protocol.js +124 -0
- package/dist/lib/long-task-windows-job-supervisor-result.d.ts +11 -0
- package/dist/lib/long-task-windows-job-supervisor-result.js +152 -0
- package/dist/lib/long-task-windows-job-supervisor.d.ts +2 -0
- package/dist/lib/long-task-windows-job-supervisor.js +126 -0
- package/dist/lib/long-task-workspace-scope.d.ts +1 -0
- package/dist/lib/long-task-workspace-scope.js +4 -1
- package/dist/lib/long-task-workspace.d.ts +1 -0
- package/dist/lib/long-task-workspace.js +10 -0
- package/dist/lib/migrations.js +43 -2
- package/dist/lib/repository-path-safety.d.ts +3 -0
- package/dist/lib/repository-path-safety.js +39 -3
- package/dist/lib/semantic-fact-input-shape.d.ts +7 -2
- package/dist/lib/semantic-fact-input-shape.js +25 -1
- package/dist/lib/semantic-fact-inventory-types.d.ts +8 -2
- package/dist/lib/semantic-fact-policy-census.d.ts +1 -1
- package/dist/lib/semantic-fact-policy-census.js +5 -2
- package/dist/lib/semantic-fact-policy.d.ts +1 -1
- package/dist/lib/semantic-fact-policy.js +2 -2
- package/dist/lib/semantic-fact-proof-shape.d.ts +1 -1
- package/dist/lib/semantic-fact-property-shape.d.ts +1 -1
- package/dist/lib/validators.d.ts +3 -0
- package/dist/lib/validators.js +45 -157
- package/dist/public-api-core.d.ts +12 -0
- package/dist/public-api-core.js +12 -0
- package/dist/public-api-long-task.d.ts +10 -0
- package/dist/public-api-long-task.js +10 -0
- package/dist/public-types.d.ts +6 -1
- package/dist/schemas/design-authority-delta-assessment-v1.schema.json +191 -0
- package/dist/schemas/long-task-delivery-v2/long-task-delivery-v2.schema.json +166 -2
- package/dist/schemas/long-task-external-confirmation-record-v1.schema.json +155 -0
- package/dist/schemas/long-task-external-confirmation-record-v2.schema.json +209 -0
- package/migrations/README.md +99 -0
- package/package.json +7 -5
- package/source-mappings.yaml +18 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { CONTEXT_LEGACY_READ_POLICY_SET, isContextReadPolicy, normalizeContextRole, } from "./catalog-portable-contract.js";
|
|
3
|
+
import { catalogDiagnostic } from "./catalog-diagnostics.js";
|
|
4
|
+
import { compareUtf8Paths, normalizeContextPath, normalizeContextPathSpelling, portableContextPathCaseKey, } from "./catalog-paths.js";
|
|
5
|
+
import { looksLikeContextExportArtifact, validateCatalogManifestPath, } from "./catalog-path-validation.js";
|
|
6
|
+
export async function validateCatalogManifest(projectRoot, manifest, fileOverrides = new Map(), directoryOverrides = new Set(), contextFiles = []) {
|
|
7
|
+
const diagnostics = [];
|
|
8
|
+
const registeredContexts = [];
|
|
9
|
+
const rolesByPath = new Map();
|
|
10
|
+
const readPoliciesByPath = new Map();
|
|
11
|
+
const addError = (code, message, location = {}) => {
|
|
12
|
+
diagnostics.push(catalogDiagnostic(code, "error", message, location));
|
|
13
|
+
};
|
|
14
|
+
const addWarning = (code, message, location = {}) => {
|
|
15
|
+
diagnostics.push(catalogDiagnostic(code, "warning", message, location));
|
|
16
|
+
};
|
|
17
|
+
if (manifest.areas.length === 0) {
|
|
18
|
+
addError("manifest_area_missing", "project_context/context.toml must declare at least one [[areas]] entry");
|
|
19
|
+
}
|
|
20
|
+
const areaIds = new Map();
|
|
21
|
+
const registeredPaths = new Set();
|
|
22
|
+
const filesByPath = new Map(contextFiles.map((file) => [file.path, file]));
|
|
23
|
+
const registeredPathSpellings = new Map();
|
|
24
|
+
const registeredPathCases = new Map();
|
|
25
|
+
const defaultAreas = manifest.areas.filter((area) => area.default);
|
|
26
|
+
if (manifest.areas.length > 0 && defaultAreas.length !== 1) {
|
|
27
|
+
addError("manifest_default_area_count", `project_context/context.toml must mark exactly one [[areas]] entry with default = true; found ${defaultAreas.length}`);
|
|
28
|
+
}
|
|
29
|
+
for (const area of manifest.areas) {
|
|
30
|
+
const canonicalAreaId = area.id.normalize("NFC");
|
|
31
|
+
const previousAreaId = areaIds.get(canonicalAreaId);
|
|
32
|
+
if (previousAreaId !== undefined) {
|
|
33
|
+
if (previousAreaId === area.id)
|
|
34
|
+
addError("manifest_area_id_duplicate", `project_context/context.toml has duplicate area id: ${area.id}`, { line: area.line });
|
|
35
|
+
else {
|
|
36
|
+
const aliases = [previousAreaId, area.id].sort(compareUtf8Paths);
|
|
37
|
+
addError("manifest_area_id_unicode_collision", `project_context/context.toml area ids ${aliases.join(", ")} normalize to the same NFC id ${canonicalAreaId}`, { line: area.line });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
areaIds.set(canonicalAreaId, area.id);
|
|
42
|
+
await validateCatalogManifestPath(projectRoot, area.root, projectRoot, `area ${area.id} root`, false, addError, fileOverrides, directoryOverrides, filesByPath);
|
|
43
|
+
const relative = normalizeContextPath(area.context);
|
|
44
|
+
reportRegisteredPathCollision(relative, area.context, area.line, registeredPathSpellings, registeredPathCases, addError);
|
|
45
|
+
registeredPaths.add(relative);
|
|
46
|
+
await addRegisteredContext(projectRoot, registeredContexts, rolesByPath, readPoliciesByPath, {
|
|
47
|
+
source: "area",
|
|
48
|
+
rawPath: area.context,
|
|
49
|
+
role: "area",
|
|
50
|
+
line: area.line,
|
|
51
|
+
sourceLabel: `area ${area.id}`,
|
|
52
|
+
area,
|
|
53
|
+
}, addError, fileOverrides, directoryOverrides, filesByPath);
|
|
54
|
+
}
|
|
55
|
+
for (const context of manifest.contexts) {
|
|
56
|
+
const relative = normalizeContextPath(context.path);
|
|
57
|
+
reportRegisteredPathCollision(relative, context.path, context.line, registeredPathSpellings, registeredPathCases, addError);
|
|
58
|
+
registeredPaths.add(relative);
|
|
59
|
+
if (context.read_policy && !isContextReadPolicy(context.read_policy)) {
|
|
60
|
+
addError("manifest_read_policy_unsupported", `project_context/context.toml line ${context.line} has unsupported read_policy: ${context.read_policy}`, { path: relative, line: context.line });
|
|
61
|
+
}
|
|
62
|
+
if (context.read_policy &&
|
|
63
|
+
CONTEXT_LEGACY_READ_POLICY_SET.has(context.read_policy)) {
|
|
64
|
+
addWarning("manifest_read_policy_legacy", `project_context/context.toml line ${context.line} uses legacy read_policy ${context.read_policy}; Schema v4 preserves its current selection behavior and migration must be explicit`, { path: relative, line: context.line });
|
|
65
|
+
}
|
|
66
|
+
const role = normalizeContextRole(context.role);
|
|
67
|
+
if (!role) {
|
|
68
|
+
addError("manifest_context_role_unsupported", `project_context/context.toml line ${context.line} has unsupported context role: ${context.role}`, { path: relative, line: context.line });
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
await addRegisteredContext(projectRoot, registeredContexts, rolesByPath, readPoliciesByPath, {
|
|
72
|
+
source: "context",
|
|
73
|
+
rawPath: context.path,
|
|
74
|
+
role,
|
|
75
|
+
readPolicy: context.read_policy,
|
|
76
|
+
line: context.line,
|
|
77
|
+
sourceLabel: `context ${context.path}`,
|
|
78
|
+
context,
|
|
79
|
+
}, addError, fileOverrides, directoryOverrides, filesByPath);
|
|
80
|
+
}
|
|
81
|
+
const contextsByPath = new Map(manifest.contexts.map((entry) => [normalizeContextPath(entry.path), entry]));
|
|
82
|
+
for (const context of manifest.contexts) {
|
|
83
|
+
for (const child of context.default_children) {
|
|
84
|
+
const normalizedChild = normalizeContextPath(child);
|
|
85
|
+
if (!registeredPaths.has(normalizedChild)) {
|
|
86
|
+
addError("manifest_default_child_unregistered", `project_context/context.toml line ${context.line} default_children references unregistered Context path: ${child}`, { path: normalizedChild, line: context.line });
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (contextsByPath.get(normalizedChild)?.read_policy === "never-default") {
|
|
90
|
+
addWarning("manifest_never_default_child_conflict", `project_context/context.toml line ${context.line} default_children selects ${normalizedChild} even though its current read_policy is never-default; Schema v4 preserves this behavior and a future migration must remove the edge or change the policy explicitly`, { path: normalizedChild, line: context.line });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
registered_contexts: registeredContexts,
|
|
96
|
+
roles_by_path: rolesByPath,
|
|
97
|
+
read_policies_by_path: readPoliciesByPath,
|
|
98
|
+
diagnostics,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function reportRegisteredPathCollision(relative, rawPath, line, spellings, cases, addError) {
|
|
102
|
+
const rawSpelling = normalizeContextPathSpelling(rawPath);
|
|
103
|
+
const previous = spellings.get(relative);
|
|
104
|
+
if (previous === undefined) {
|
|
105
|
+
spellings.set(relative, rawSpelling);
|
|
106
|
+
}
|
|
107
|
+
else if (previous === rawSpelling) {
|
|
108
|
+
addError("manifest_context_path_duplicate", `project_context/context.toml has duplicate Context path: ${relative}`, { path: relative, line });
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const aliases = [previous, rawSpelling].sort(compareUtf8Paths);
|
|
112
|
+
addError("manifest_context_path_unicode_collision", `project_context/context.toml Context paths ${aliases.join(", ")} normalize to the same NFC repository path ${relative}`, { path: relative, line });
|
|
113
|
+
}
|
|
114
|
+
const caseKey = portableContextPathCaseKey(relative);
|
|
115
|
+
const previousCase = cases.get(caseKey);
|
|
116
|
+
if (previousCase === undefined)
|
|
117
|
+
cases.set(caseKey, relative);
|
|
118
|
+
else if (previousCase !== relative) {
|
|
119
|
+
const aliases = [previousCase, relative].sort(compareUtf8Paths);
|
|
120
|
+
addError("manifest_context_path_case_collision", `project_context/context.toml Context paths ${aliases.join(", ")} collide on a case-insensitive filesystem`, { path: aliases[0], line });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async function addRegisteredContext(projectRoot, registeredContexts, rolesByPath, readPoliciesByPath, input, addError, fileOverrides, directoryOverrides, filesByPath) {
|
|
124
|
+
const relative = normalizeContextPath(input.rawPath);
|
|
125
|
+
if (looksLikeContextExportArtifact(relative)) {
|
|
126
|
+
addError("manifest_export_artifact_forbidden", `project_context/context.toml ${input.sourceLabel} must not reference temporary export artifact ${input.rawPath}; export artifacts belong in tmp/ty-context/context-exports/** and must not be registered as Context graph nodes or implementation-index`, { path: relative, line: input.line });
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (!relative.startsWith("project_context/") || !relative.endsWith(".md")) {
|
|
130
|
+
addError("manifest_context_path_invalid", `project_context/context.toml ${input.sourceLabel} must reference a markdown file under project_context/: ${input.rawPath}`, { path: relative, line: input.line });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (!(await validateCatalogManifestPath(projectRoot, input.rawPath, path.join(projectRoot, "project_context"), input.sourceLabel, true, addError, fileOverrides, directoryOverrides, filesByPath))) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
rolesByPath.set(relative, input.role);
|
|
137
|
+
if (input.readPolicy)
|
|
138
|
+
readPoliciesByPath.set(relative, input.readPolicy);
|
|
139
|
+
registeredContexts.push({
|
|
140
|
+
source: input.source,
|
|
141
|
+
path: relative,
|
|
142
|
+
role: input.role,
|
|
143
|
+
read_policy: input.readPolicy,
|
|
144
|
+
line: input.line,
|
|
145
|
+
area: input.area,
|
|
146
|
+
context: input.context,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { CLI_EXIT_CODES, CliCommandError } from "../cli-exit.js";
|
|
3
|
+
const PORTABLE_SEGMENT_FORBIDDEN = /[<>:"|?*\u0000-\u001f]/u;
|
|
4
|
+
const WINDOWS_RESERVED = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/iu;
|
|
5
|
+
export function normalizeContextCreatePath(value) {
|
|
6
|
+
return normalizeContextFilePath(value, "context create");
|
|
7
|
+
}
|
|
8
|
+
export function normalizeContextFilePath(value, command) {
|
|
9
|
+
if (!value || path.isAbsolute(value) || /^[A-Za-z]:/u.test(value))
|
|
10
|
+
invalid(value, command);
|
|
11
|
+
const normalized = value.replace(/\\/gu, "/").replace(/^\.\//u, "");
|
|
12
|
+
const segments = normalized.split("/");
|
|
13
|
+
if (segments.length < 2 ||
|
|
14
|
+
segments[0] !== "project_context" ||
|
|
15
|
+
segments.some(invalidSegment) ||
|
|
16
|
+
!segments.at(-1)?.toLowerCase().endsWith(".md"))
|
|
17
|
+
invalid(value, command);
|
|
18
|
+
return normalized;
|
|
19
|
+
}
|
|
20
|
+
function invalidSegment(segment) {
|
|
21
|
+
return (!segment ||
|
|
22
|
+
segment === "." ||
|
|
23
|
+
segment === ".." ||
|
|
24
|
+
PORTABLE_SEGMENT_FORBIDDEN.test(segment) ||
|
|
25
|
+
/[. ]$/u.test(segment) ||
|
|
26
|
+
WINDOWS_RESERVED.test(segment));
|
|
27
|
+
}
|
|
28
|
+
function invalid(value, command) {
|
|
29
|
+
throw new CliCommandError(CLI_EXIT_CODES.arguments, `${command} path must be a portable Markdown path below project_context/: ${value}`);
|
|
30
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const ROLE_SECTIONS = {
|
|
2
|
+
global: [
|
|
3
|
+
"Project Goal",
|
|
4
|
+
"Boundaries",
|
|
5
|
+
"Durable Context",
|
|
6
|
+
"Verification Entry Points",
|
|
7
|
+
],
|
|
8
|
+
architecture: [
|
|
9
|
+
"System Boundary",
|
|
10
|
+
"Component Map",
|
|
11
|
+
"Data / Control Flow",
|
|
12
|
+
"Constraints And Tradeoffs",
|
|
13
|
+
],
|
|
14
|
+
area: ["Responsibility", "Durable Facts", "Boundaries", "Code Entry Points"],
|
|
15
|
+
domain: [
|
|
16
|
+
"Responsibility",
|
|
17
|
+
"Durable Domain Facts",
|
|
18
|
+
"Boundaries",
|
|
19
|
+
"Code Entry Points",
|
|
20
|
+
],
|
|
21
|
+
subdomain: [
|
|
22
|
+
"Responsibility",
|
|
23
|
+
"Durable Subdomain Facts",
|
|
24
|
+
"Parent Boundary",
|
|
25
|
+
"Code Entry Points",
|
|
26
|
+
],
|
|
27
|
+
foundation: [
|
|
28
|
+
"Foundation Responsibility",
|
|
29
|
+
"Shared Rules",
|
|
30
|
+
"Consumers",
|
|
31
|
+
"Change Boundaries",
|
|
32
|
+
],
|
|
33
|
+
archive: [
|
|
34
|
+
"Archive Scope",
|
|
35
|
+
"Historical Context",
|
|
36
|
+
"Current Applicability",
|
|
37
|
+
"Successor Owners",
|
|
38
|
+
],
|
|
39
|
+
contract: [
|
|
40
|
+
"Contract Scope",
|
|
41
|
+
"Inputs",
|
|
42
|
+
"Outputs",
|
|
43
|
+
"Compatibility And Constraints",
|
|
44
|
+
],
|
|
45
|
+
verification: [
|
|
46
|
+
"Owner",
|
|
47
|
+
"Verification Paths",
|
|
48
|
+
"Required Preparation",
|
|
49
|
+
"Expected Signals",
|
|
50
|
+
"Forbidden Evidence",
|
|
51
|
+
],
|
|
52
|
+
deployment: [
|
|
53
|
+
"Owner",
|
|
54
|
+
"Runtime Topology",
|
|
55
|
+
"Deployment Paths",
|
|
56
|
+
"Recovery",
|
|
57
|
+
"Forbidden Evidence",
|
|
58
|
+
],
|
|
59
|
+
"implementation-index": [
|
|
60
|
+
"Responsibility",
|
|
61
|
+
"Repository Entry Points",
|
|
62
|
+
"Change Routing",
|
|
63
|
+
"Boundaries",
|
|
64
|
+
],
|
|
65
|
+
"decision-rationale": [
|
|
66
|
+
"Decision",
|
|
67
|
+
"Reason",
|
|
68
|
+
"Alternatives",
|
|
69
|
+
"Revisit Trigger",
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
export function renderContextCreateScaffold(contextPath, role) {
|
|
73
|
+
const title = titleFromPath(contextPath);
|
|
74
|
+
const lines = [
|
|
75
|
+
`# ${roleLabel(role)} Context: ${title}`,
|
|
76
|
+
"",
|
|
77
|
+
`<!-- ty-context-scaffold role=${role} registration=unregistered -->`,
|
|
78
|
+
"",
|
|
79
|
+
];
|
|
80
|
+
for (const section of ROLE_SECTIONS[role])
|
|
81
|
+
lines.push(`## ${section}`, "", "- TODO", "");
|
|
82
|
+
return `${lines.join("\n").trimEnd()}\n`;
|
|
83
|
+
}
|
|
84
|
+
function titleFromPath(contextPath) {
|
|
85
|
+
const filename = contextPath.split("/").at(-1) ?? "Context";
|
|
86
|
+
const stem = filename.replace(/\.md$/iu, "");
|
|
87
|
+
const spaced = stem.replace(/[-_]+/gu, " ").trim();
|
|
88
|
+
return spaced || "Context";
|
|
89
|
+
}
|
|
90
|
+
function roleLabel(role) {
|
|
91
|
+
return role
|
|
92
|
+
.split("-")
|
|
93
|
+
.map((word) => `${word.slice(0, 1).toUpperCase()}${word.slice(1)}`)
|
|
94
|
+
.join(" ");
|
|
95
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ContextRole } from "../context-catalog/catalog-portable-contract.js";
|
|
2
|
+
export interface ContextCreateInput {
|
|
3
|
+
project_root: string;
|
|
4
|
+
context_path: string;
|
|
5
|
+
role: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ContextFootprintSnapshot {
|
|
8
|
+
path_count: number;
|
|
9
|
+
bytes: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ContextCreateResult {
|
|
12
|
+
schema_version: 1;
|
|
13
|
+
path: string;
|
|
14
|
+
role: ContextRole;
|
|
15
|
+
created: true;
|
|
16
|
+
registration: "unregistered";
|
|
17
|
+
manifest_modified: false;
|
|
18
|
+
bytes: number;
|
|
19
|
+
default_footprint: {
|
|
20
|
+
changed: false;
|
|
21
|
+
before: ContextFootprintSnapshot;
|
|
22
|
+
after: ContextFootprintSnapshot;
|
|
23
|
+
added: [];
|
|
24
|
+
removed: [];
|
|
25
|
+
reason: string;
|
|
26
|
+
};
|
|
27
|
+
next_steps: string[];
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function publishContextScaffold(repository: string, relativePath: string, bytes: Uint8Array): Promise<void>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { link, open, readFile, unlink } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { CLI_EXIT_CODES, CliCommandError } from "../cli-exit.js";
|
|
5
|
+
import { assertSafeRepositoryFilePath, ensureSafeRepositoryDirectory, } from "../repository-path-safety.js";
|
|
6
|
+
export async function publishContextScaffold(repository, relativePath, bytes) {
|
|
7
|
+
const parent = path.posix.dirname(relativePath);
|
|
8
|
+
const directory = await ensureSafeRepositoryDirectory(repository, parent, "context_create_parent").catch(asIoFailure);
|
|
9
|
+
const destination = await assertSafeRepositoryFilePath(repository, relativePath, "context_create_target", { destinationMayBeAbsent: true }).catch(asIoFailure);
|
|
10
|
+
if (destination.status)
|
|
11
|
+
collision(relativePath);
|
|
12
|
+
const temporary = path.join(directory.absolute, `.${path.basename(destination.absolute)}.ty-context-create-${randomUUID()}.tmp`);
|
|
13
|
+
let temporaryExists = false;
|
|
14
|
+
let published = false;
|
|
15
|
+
try {
|
|
16
|
+
const handle = await open(temporary, "wx", 0o666);
|
|
17
|
+
temporaryExists = true;
|
|
18
|
+
try {
|
|
19
|
+
await handle.writeFile(bytes);
|
|
20
|
+
await handle.sync();
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
await handle.close();
|
|
24
|
+
}
|
|
25
|
+
const staged = await readFile(temporary);
|
|
26
|
+
if (!Buffer.from(bytes).equals(staged))
|
|
27
|
+
throw new Error("context_create_temporary_readback_mismatch");
|
|
28
|
+
await assertDestinationAbsent(repository, relativePath);
|
|
29
|
+
try {
|
|
30
|
+
await link(temporary, destination.absolute);
|
|
31
|
+
published = true;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error.code === "EEXIST")
|
|
35
|
+
collision(relativePath);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
await unlink(temporary);
|
|
39
|
+
temporaryExists = false;
|
|
40
|
+
const finalBytes = await readFile(destination.absolute);
|
|
41
|
+
if (!Buffer.from(bytes).equals(finalBytes))
|
|
42
|
+
throw new Error("context_create_final_readback_mismatch");
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
const cleanup = temporaryExists
|
|
46
|
+
? await removeTemporary(temporary)
|
|
47
|
+
: undefined;
|
|
48
|
+
if (cleanup)
|
|
49
|
+
throw new AggregateError([error, cleanup], published
|
|
50
|
+
? `context create published ${relativePath}, but temporary cleanup failed`
|
|
51
|
+
: `context create failed and temporary cleanup failed for ${relativePath}`);
|
|
52
|
+
if (error instanceof CliCommandError)
|
|
53
|
+
throw error;
|
|
54
|
+
throw new CliCommandError(CLI_EXIT_CODES.io, published
|
|
55
|
+
? `context create published ${relativePath}, but final verification failed: ${message(error)}`
|
|
56
|
+
: `unable to create Context scaffold ${relativePath}: ${message(error)}`, { cause: error });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function assertDestinationAbsent(repository, relativePath) {
|
|
60
|
+
const destination = await assertSafeRepositoryFilePath(repository, relativePath, "context_create_target", { destinationMayBeAbsent: true }).catch(asIoFailure);
|
|
61
|
+
if (destination.status)
|
|
62
|
+
collision(relativePath);
|
|
63
|
+
}
|
|
64
|
+
async function removeTemporary(temporary) {
|
|
65
|
+
try {
|
|
66
|
+
await unlink(temporary);
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
return error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function collision(relativePath) {
|
|
74
|
+
throw new CliCommandError(CLI_EXIT_CODES.io, `context create refuses to overwrite existing target: ${relativePath}`);
|
|
75
|
+
}
|
|
76
|
+
function asIoFailure(error) {
|
|
77
|
+
if (error instanceof CliCommandError)
|
|
78
|
+
throw error;
|
|
79
|
+
throw new CliCommandError(CLI_EXIT_CODES.io, message(error), {
|
|
80
|
+
cause: error,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function message(error) {
|
|
84
|
+
return error instanceof Error ? error.message : String(error);
|
|
85
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { CLI_EXIT_CODES, CliCommandError } from "../cli-exit.js";
|
|
2
|
+
import { loadContextCatalog } from "../context-catalog/catalog-load.js";
|
|
3
|
+
import { normalizeContextPath } from "../context-catalog/catalog-paths.js";
|
|
4
|
+
import { CONTEXT_ROLES, normalizeContextRole, } from "../context-catalog/catalog-portable-contract.js";
|
|
5
|
+
import { normalizeContextCreatePath } from "./context-create-path.js";
|
|
6
|
+
import { renderContextCreateScaffold } from "./context-create-template.js";
|
|
7
|
+
import { publishContextScaffold } from "./context-create-write.js";
|
|
8
|
+
export async function createContextScaffold(input) {
|
|
9
|
+
const contextPath = normalizeContextCreatePath(input.context_path);
|
|
10
|
+
const role = normalizeContextRole(input.role);
|
|
11
|
+
if (!role)
|
|
12
|
+
throw new CliCommandError(CLI_EXIT_CODES.arguments, `context create role must be one of: ${CONTEXT_ROLES.join(", ")}`);
|
|
13
|
+
const catalog = await loadCatalog(input.project_root);
|
|
14
|
+
assertUnregisteredTarget(catalog, contextPath);
|
|
15
|
+
const blocking = catalog.diagnostics.filter((diagnostic) => diagnostic.severity === "error");
|
|
16
|
+
if (blocking.length > 0)
|
|
17
|
+
throw new CliCommandError(CLI_EXIT_CODES.catalog, `context create requires a valid Context Catalog: ${blocking
|
|
18
|
+
.map((entry) => entry.message)
|
|
19
|
+
.join("; ")}`);
|
|
20
|
+
const content = renderContextCreateScaffold(contextPath, role);
|
|
21
|
+
const bytes = Buffer.from(content, "utf8");
|
|
22
|
+
const footprint = contextFootprintSnapshot(catalog);
|
|
23
|
+
await publishContextScaffold(input.project_root, contextPath, bytes);
|
|
24
|
+
return {
|
|
25
|
+
schema_version: 1,
|
|
26
|
+
path: contextPath,
|
|
27
|
+
role,
|
|
28
|
+
created: true,
|
|
29
|
+
registration: "unregistered",
|
|
30
|
+
manifest_modified: false,
|
|
31
|
+
bytes: bytes.length,
|
|
32
|
+
default_footprint: {
|
|
33
|
+
changed: false,
|
|
34
|
+
before: footprint,
|
|
35
|
+
after: { ...footprint },
|
|
36
|
+
added: [],
|
|
37
|
+
removed: [],
|
|
38
|
+
reason: "unregistered scaffolds do not participate in the default footprint",
|
|
39
|
+
},
|
|
40
|
+
next_steps: [
|
|
41
|
+
"Replace every TODO with durable facts owned by this Context.",
|
|
42
|
+
`Inspect the unregistered scaffold with: ty-context context inspect ${contextPath}`,
|
|
43
|
+
"Register only after the file satisfies its Role recovery requirements; create never edits the Manifest.",
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async function loadCatalog(projectRoot) {
|
|
48
|
+
try {
|
|
49
|
+
return await loadContextCatalog(projectRoot);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new CliCommandError(CLI_EXIT_CODES.io, `unable to load Context Catalog: ${message(error)}`, { cause: error });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function assertUnregisteredTarget(catalog, contextPath) {
|
|
56
|
+
const folded = contextPath.toLocaleLowerCase("en-US");
|
|
57
|
+
const registered = registeredPaths(catalog).find((candidate) => candidate.toLocaleLowerCase("en-US") === folded);
|
|
58
|
+
if (registered)
|
|
59
|
+
throw new CliCommandError(CLI_EXIT_CODES.catalog, `context create only creates unregistered scaffolds; Manifest already owns ${registered}`);
|
|
60
|
+
const existing = catalog.context_files.find((candidate) => candidate.path.toLocaleLowerCase("en-US") === folded);
|
|
61
|
+
if (existing)
|
|
62
|
+
throw new CliCommandError(CLI_EXIT_CODES.io, `context create refuses to overwrite existing target: ${existing.path}`);
|
|
63
|
+
}
|
|
64
|
+
function registeredPaths(catalog) {
|
|
65
|
+
return [
|
|
66
|
+
"project_context/global.md",
|
|
67
|
+
"project_context/architecture.md",
|
|
68
|
+
...(catalog.manifest?.areas.map((entry) => entry.context) ?? []),
|
|
69
|
+
...(catalog.manifest?.contexts.map((entry) => entry.path) ?? []),
|
|
70
|
+
].map(normalizeContextPath);
|
|
71
|
+
}
|
|
72
|
+
function contextFootprintSnapshot(catalog) {
|
|
73
|
+
const files = new Map(catalog.context_files.map((entry) => [entry.path, entry.bytes]));
|
|
74
|
+
let bytes = 0;
|
|
75
|
+
for (const contextPath of catalog.default_footprint.keys())
|
|
76
|
+
bytes +=
|
|
77
|
+
contextPath === catalog.manifest_path
|
|
78
|
+
? Buffer.byteLength(catalog.manifest_content ?? "", "utf8")
|
|
79
|
+
: (files.get(contextPath) ?? 0);
|
|
80
|
+
return { path_count: catalog.default_footprint.size, bytes };
|
|
81
|
+
}
|
|
82
|
+
function message(error) {
|
|
83
|
+
return error instanceof Error ? error.message : String(error);
|
|
84
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type DefaultContextSelectionReason } from "./context-catalog/catalog-default-footprint.js";
|
|
2
|
+
export { selectDefaultContextPaths, type DefaultContextSelectionReason, } from "./context-catalog/catalog-default-footprint.js";
|
|
2
3
|
export declare const DEFAULT_CONTEXT_TOTAL_SOFT_BUDGET_BYTES: number;
|
|
3
4
|
export declare const DEFAULT_CONTEXT_FILE_SOFT_BUDGET_BYTES: number;
|
|
4
|
-
export type DefaultContextSelectionReason = "core" | "default_area" | "default_role" | "default_child";
|
|
5
5
|
export interface DefaultContextFileFootprint {
|
|
6
6
|
path: string;
|
|
7
7
|
bytes: number;
|
|
@@ -13,4 +13,3 @@ export interface DefaultContextFootprint {
|
|
|
13
13
|
duplicate_groups: string[][];
|
|
14
14
|
}
|
|
15
15
|
export declare function inspectDefaultContextFootprint(projectRootInput: string): Promise<DefaultContextFootprint>;
|
|
16
|
-
export declare function selectDefaultContextPaths(manifest: ContextManifest): Map<string, Set<DefaultContextSelectionReason>>;
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { lstat, readFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { loadContextCatalog } from "./context-catalog/catalog-load.js";
|
|
5
|
+
import { compareUtf8Paths, normalizeContextPath, normalizeContextPathSpelling, resolveCatalogFile, } from "./context-catalog/catalog-paths.js";
|
|
6
|
+
export { selectDefaultContextPaths, } from "./context-catalog/catalog-default-footprint.js";
|
|
5
7
|
export const DEFAULT_CONTEXT_TOTAL_SOFT_BUDGET_BYTES = 64 * 1024;
|
|
6
8
|
export const DEFAULT_CONTEXT_FILE_SOFT_BUDGET_BYTES = 16 * 1024;
|
|
7
9
|
export async function inspectDefaultContextFootprint(projectRootInput) {
|
|
8
10
|
const projectRoot = path.resolve(projectRootInput);
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const catalog = await loadContextCatalog(projectRoot, {
|
|
12
|
+
validate_manifest: false,
|
|
13
|
+
});
|
|
14
|
+
const parseErrors = catalog.diagnostics
|
|
15
|
+
.filter((entry) => entry.code === "context_manifest_parse" ||
|
|
16
|
+
entry.code === "context_manifest_missing")
|
|
17
|
+
.map((entry) => entry.message);
|
|
18
|
+
if (!catalog.manifest || parseErrors.length > 0) {
|
|
19
|
+
throw new Error(`context_manifest_invalid:${parseErrors.join("|")}`);
|
|
14
20
|
}
|
|
15
|
-
const selected =
|
|
21
|
+
const selected = catalog.default_footprint;
|
|
16
22
|
const files = [];
|
|
17
23
|
const hashes = new Map();
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
const physicalPaths = physicalDefaultPaths(catalog.manifest);
|
|
25
|
+
for (const [relativePath, reasons] of [...selected.entries()].sort(([left], [right]) => compareUtf8Paths(left, right))) {
|
|
26
|
+
const absolutePath = resolveCatalogFile(catalog, relativePath)?.absolute_path ??
|
|
27
|
+
resolveProjectFile(projectRoot, physicalPaths.get(relativePath) ?? relativePath);
|
|
20
28
|
const metadata = await lstat(absolutePath);
|
|
21
29
|
if (metadata.isSymbolicLink()) {
|
|
22
30
|
throw new Error(`default_context_path_symlink_not_allowed:${relativePath}`);
|
|
@@ -32,7 +40,7 @@ export async function inspectDefaultContextFootprint(projectRootInput) {
|
|
|
32
40
|
files.push({
|
|
33
41
|
path: relativePath,
|
|
34
42
|
bytes: content.byteLength,
|
|
35
|
-
reasons: [...reasons].sort(),
|
|
43
|
+
reasons: [...reasons].sort(compareUtf8Paths),
|
|
36
44
|
});
|
|
37
45
|
}
|
|
38
46
|
return {
|
|
@@ -40,62 +48,49 @@ export async function inspectDefaultContextFootprint(projectRootInput) {
|
|
|
40
48
|
total_bytes: files.reduce((total, file) => total + file.bytes, 0),
|
|
41
49
|
duplicate_groups: [...hashes.values()]
|
|
42
50
|
.filter((group) => group.length > 1)
|
|
43
|
-
.map((group) => [...group].sort())
|
|
44
|
-
.sort(
|
|
51
|
+
.map((group) => [...group].sort(compareUtf8Paths))
|
|
52
|
+
.sort(comparePathGroups),
|
|
45
53
|
};
|
|
46
54
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
selected.set(normalized, reasons);
|
|
57
|
-
return changed;
|
|
55
|
+
function physicalDefaultPaths(manifest) {
|
|
56
|
+
const physical = new Map();
|
|
57
|
+
const addOwner = (rawPath) => {
|
|
58
|
+
const canonical = normalizeContextPath(rawPath);
|
|
59
|
+
const spelling = normalizeContextPathSpelling(rawPath);
|
|
60
|
+
const previous = physical.get(canonical);
|
|
61
|
+
if (previous !== undefined && previous !== spelling)
|
|
62
|
+
throw new Error(`default_context_path_unicode_collision:${canonical}:${[previous, spelling].sort(compareUtf8Paths).join(",")}`);
|
|
63
|
+
physical.set(canonical, spelling);
|
|
58
64
|
};
|
|
59
65
|
for (const core of [
|
|
60
66
|
"project_context/context.toml",
|
|
61
67
|
"project_context/global.md",
|
|
62
68
|
"project_context/architecture.md",
|
|
63
69
|
])
|
|
64
|
-
|
|
65
|
-
for (const area of manifest.areas)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const queued = new Set();
|
|
75
|
-
const enqueue = (contextPath) => {
|
|
76
|
-
if (queued.has(contextPath))
|
|
77
|
-
return;
|
|
78
|
-
queued.add(contextPath);
|
|
79
|
-
queue.push(contextPath);
|
|
80
|
-
};
|
|
81
|
-
for (const context of manifest.contexts) {
|
|
82
|
-
if (context.read_policy !== "default")
|
|
83
|
-
continue;
|
|
84
|
-
const normalized = normalizeContextPath(context.path);
|
|
85
|
-
add(normalized, "default_role");
|
|
86
|
-
enqueue(normalized);
|
|
87
|
-
}
|
|
88
|
-
while (queue.length > 0) {
|
|
89
|
-
const parent = queue.shift();
|
|
90
|
-
for (const child of children.get(parent) ?? []) {
|
|
91
|
-
add(child, "default_child");
|
|
92
|
-
enqueue(child);
|
|
70
|
+
addOwner(core);
|
|
71
|
+
for (const area of manifest.areas)
|
|
72
|
+
addOwner(area.context);
|
|
73
|
+
for (const context of manifest.contexts)
|
|
74
|
+
addOwner(context.path);
|
|
75
|
+
for (const context of manifest.contexts)
|
|
76
|
+
for (const child of context.default_children) {
|
|
77
|
+
const canonical = normalizeContextPath(child);
|
|
78
|
+
if (!physical.has(canonical))
|
|
79
|
+
physical.set(canonical, normalizeContextPathSpelling(child));
|
|
93
80
|
}
|
|
81
|
+
return physical;
|
|
82
|
+
}
|
|
83
|
+
function comparePathGroups(left, right) {
|
|
84
|
+
const length = Math.min(left.length, right.length);
|
|
85
|
+
for (let index = 0; index < length; index += 1) {
|
|
86
|
+
const comparison = compareUtf8Paths(left[index], right[index]);
|
|
87
|
+
if (comparison !== 0)
|
|
88
|
+
return comparison;
|
|
94
89
|
}
|
|
95
|
-
return
|
|
90
|
+
return left.length - right.length;
|
|
96
91
|
}
|
|
97
92
|
function resolveProjectFile(projectRoot, relativePath) {
|
|
98
|
-
const absolutePath = path.resolve(projectRoot, ...
|
|
93
|
+
const absolutePath = path.resolve(projectRoot, ...normalizeContextPathSpelling(relativePath).split("/"));
|
|
99
94
|
const relative = path.relative(projectRoot, absolutePath);
|
|
100
95
|
if (relative.startsWith(`..${path.sep}`) ||
|
|
101
96
|
relative === ".." ||
|
|
@@ -104,6 +99,3 @@ function resolveProjectFile(projectRoot, relativePath) {
|
|
|
104
99
|
}
|
|
105
100
|
return absolutePath;
|
|
106
101
|
}
|
|
107
|
-
function normalizeContextPath(value) {
|
|
108
|
-
return value.replace(/\\/gu, "/").replace(/^\.\//u, "");
|
|
109
|
-
}
|