project-tiny-context-harness 0.8.17 → 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 +93 -30
- package/assets/README.md +158 -44
- package/assets/README.zh-CN.md +88 -29
- package/assets/agents/AGENTS_CORE.md +2 -2
- package/assets/context_templates/context.toml +6 -1
- 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/design-resource-authoring/SKILL.md +6 -3
- package/assets/skills/design-resource-authoring/references/authority-delta-assessment.md +52 -0
- package/assets/skills/design-resource-authoring/references/downstream-handoff.md +5 -1
- 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 +8 -1
- 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-input-types.d.ts +1 -1
- package/dist/lib/design-resource-handoff-manifest-projection.js +3 -0
- package/dist/lib/design-resource-handoff-shape.js +14 -2
- package/dist/lib/design-resource-handoff-types.d.ts +3 -0
- package/dist/lib/design-resource-handoff-validation.js +16 -4
- package/dist/lib/design-resource-implementation-feasibility-validation-support.js +1 -1
- 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 +7 -1
- package/dist/lib/design-resource-symbolic-fact-types.d.ts +3 -0
- package/dist/lib/design-resource-symbolic-fact-validation.js +15 -3
- 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 +72 -69
- 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-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.js +3 -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 +6 -1
- package/dist/lib/long-task-delivery-validation.js +19 -4
- package/dist/lib/long-task-design-feasibility-binding.d.ts +1 -0
- package/dist/lib/long-task-design-feasibility-binding.js +3 -3
- package/dist/lib/long-task-design-feasibility-source-closure.js +11 -2
- 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 +3 -1
- package/dist/lib/long-task-design-resource-handoff.js +36 -12
- package/dist/lib/long-task-design-resource-method-binding.js +12 -0
- 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 +128 -5
- 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 +2 -5
- package/dist/lib/long-task-process-table.js +21 -53
- package/dist/lib/long-task-process-tree.d.ts +0 -1
- package/dist/lib/long-task-process-tree.js +24 -54
- 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-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-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 +1 -0
- package/dist/lib/repository-path-safety.js +3 -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 +5 -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,245 @@
|
|
|
1
|
+
import { lstat, readFile, realpath } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { compareUtf8Paths, isPathWithin, normalizeContextPath, } from "../context-catalog/catalog-paths.js";
|
|
4
|
+
import { extractContextMarkdown } from "./context-markdown-extract.js";
|
|
5
|
+
export async function analyzeContextMarkdownCatalog(input) {
|
|
6
|
+
const files = [];
|
|
7
|
+
const catalogFiles = new Map(input.files.map((file) => [file.path, file]));
|
|
8
|
+
for (const file of [...input.files].sort((left, right) => compareUtf8Paths(left.path, right.path)))
|
|
9
|
+
files.push(await analyzeContextMarkdownFile({
|
|
10
|
+
project_root: input.project_root,
|
|
11
|
+
file,
|
|
12
|
+
catalog_files: catalogFiles,
|
|
13
|
+
long_line_threshold: input.long_line_threshold,
|
|
14
|
+
file_overrides: input.file_overrides,
|
|
15
|
+
}));
|
|
16
|
+
const declarations = files.flatMap((file) => file.declarations);
|
|
17
|
+
return {
|
|
18
|
+
files,
|
|
19
|
+
references: files.flatMap((file) => file.references),
|
|
20
|
+
declarations,
|
|
21
|
+
invalid_declarations: files.flatMap((file) => file.invalid_declarations),
|
|
22
|
+
declaration_conflicts: declarationConflicts(declarations),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export async function analyzeContextMarkdownFile(input) {
|
|
26
|
+
const override = input.file_overrides?.get(input.file.path);
|
|
27
|
+
const content = override === undefined
|
|
28
|
+
? await readFile(input.file.absolute_path, "utf8")
|
|
29
|
+
: Buffer.from(override ?? []).toString("utf8");
|
|
30
|
+
const extracted = extractContextMarkdown(content, input.file.path);
|
|
31
|
+
const lengths = lineLengths(content, input.long_line_threshold);
|
|
32
|
+
const references = [];
|
|
33
|
+
for (const reference of extracted.references) {
|
|
34
|
+
const resolved = await resolveReference(input.project_root, input.file, reference, input.catalog_files ?? new Map([[input.file.path, input.file]]), input.file_overrides);
|
|
35
|
+
if (resolved)
|
|
36
|
+
references.push(resolved);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
path: input.file.path,
|
|
40
|
+
bytes: Buffer.byteLength(content, "utf8"),
|
|
41
|
+
max_line_code_points: lengths.maximum,
|
|
42
|
+
long_lines: lengths.long,
|
|
43
|
+
references,
|
|
44
|
+
declarations: extracted.declarations,
|
|
45
|
+
invalid_declarations: extracted.invalid_declarations,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async function resolveReference(projectRoot, sourceFile, reference, catalogFiles, fileOverrides) {
|
|
49
|
+
const sourcePath = sourceFile.path;
|
|
50
|
+
const split = splitDestination(reference.destination);
|
|
51
|
+
if (split.disposition === "ignored")
|
|
52
|
+
return null;
|
|
53
|
+
if (split.disposition === "invalid")
|
|
54
|
+
return {
|
|
55
|
+
...reference,
|
|
56
|
+
source_path: sourcePath,
|
|
57
|
+
target_path: null,
|
|
58
|
+
fragment: split.fragment,
|
|
59
|
+
status: "invalid",
|
|
60
|
+
detail: split.detail,
|
|
61
|
+
};
|
|
62
|
+
const normalizedDestination = split.local.replaceAll("\\", "/");
|
|
63
|
+
const lexicalAbsolute = normalizedDestination.startsWith("/")
|
|
64
|
+
? path.resolve(projectRoot, normalizedDestination.slice(1))
|
|
65
|
+
: normalizedDestination.startsWith("project_context/")
|
|
66
|
+
? path.resolve(projectRoot, normalizedDestination)
|
|
67
|
+
: path.resolve(path.dirname(sourceFile.absolute_path), normalizedDestination);
|
|
68
|
+
const targetPath = normalizeContextPath(path.relative(projectRoot, lexicalAbsolute));
|
|
69
|
+
if (!isPathWithin(projectRoot, lexicalAbsolute))
|
|
70
|
+
return {
|
|
71
|
+
...reference,
|
|
72
|
+
source_path: sourcePath,
|
|
73
|
+
target_path: targetPath,
|
|
74
|
+
fragment: split.fragment,
|
|
75
|
+
status: "outside_repository",
|
|
76
|
+
detail: "local Markdown destination resolves outside the repository",
|
|
77
|
+
};
|
|
78
|
+
const catalogTarget = catalogFiles.get(targetPath);
|
|
79
|
+
if (fileOverrides?.has(targetPath)) {
|
|
80
|
+
if (fileOverrides.get(targetPath) === null)
|
|
81
|
+
return {
|
|
82
|
+
...reference,
|
|
83
|
+
source_path: sourcePath,
|
|
84
|
+
target_path: targetPath,
|
|
85
|
+
fragment: split.fragment,
|
|
86
|
+
status: "missing",
|
|
87
|
+
};
|
|
88
|
+
if (!catalogTarget ||
|
|
89
|
+
!sameStagedAbsolutePath(lexicalAbsolute, catalogTarget.absolute_path))
|
|
90
|
+
return {
|
|
91
|
+
...reference,
|
|
92
|
+
source_path: sourcePath,
|
|
93
|
+
target_path: targetPath,
|
|
94
|
+
fragment: split.fragment,
|
|
95
|
+
status: "missing",
|
|
96
|
+
detail: "local Markdown destination does not resolve to the staged target physical path",
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
...reference,
|
|
100
|
+
source_path: sourcePath,
|
|
101
|
+
target_path: targetPath,
|
|
102
|
+
fragment: split.fragment,
|
|
103
|
+
status: "valid",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
await lstat(lexicalAbsolute);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (isMissing(error))
|
|
111
|
+
return {
|
|
112
|
+
...reference,
|
|
113
|
+
source_path: sourcePath,
|
|
114
|
+
target_path: targetPath,
|
|
115
|
+
fragment: split.fragment,
|
|
116
|
+
status: "missing",
|
|
117
|
+
};
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
const identity = await realpath(lexicalAbsolute);
|
|
121
|
+
if (!isPathWithin(await realpath(projectRoot), identity))
|
|
122
|
+
return {
|
|
123
|
+
...reference,
|
|
124
|
+
source_path: sourcePath,
|
|
125
|
+
target_path: targetPath,
|
|
126
|
+
fragment: split.fragment,
|
|
127
|
+
status: "outside_repository",
|
|
128
|
+
detail: "local Markdown destination resolves through a link outside the repository",
|
|
129
|
+
};
|
|
130
|
+
if (catalogTarget) {
|
|
131
|
+
let catalogIdentity;
|
|
132
|
+
try {
|
|
133
|
+
catalogIdentity = await realpath(catalogTarget.absolute_path);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (isMissing(error))
|
|
137
|
+
return {
|
|
138
|
+
...reference,
|
|
139
|
+
source_path: sourcePath,
|
|
140
|
+
target_path: targetPath,
|
|
141
|
+
fragment: split.fragment,
|
|
142
|
+
status: "missing",
|
|
143
|
+
};
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
if (!sameRealPath(identity, catalogIdentity))
|
|
147
|
+
return {
|
|
148
|
+
...reference,
|
|
149
|
+
source_path: sourcePath,
|
|
150
|
+
target_path: targetPath,
|
|
151
|
+
fragment: split.fragment,
|
|
152
|
+
status: "invalid",
|
|
153
|
+
detail: "local Markdown destination resolves to a different physical file than its Catalog identity",
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
...reference,
|
|
158
|
+
source_path: sourcePath,
|
|
159
|
+
target_path: targetPath,
|
|
160
|
+
fragment: split.fragment,
|
|
161
|
+
status: "valid",
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function sameStagedAbsolutePath(left, right) {
|
|
165
|
+
const normalizedLeft = path.resolve(left);
|
|
166
|
+
const normalizedRight = path.resolve(right);
|
|
167
|
+
return process.platform === "win32"
|
|
168
|
+
? normalizedLeft.toLowerCase() === normalizedRight.toLowerCase()
|
|
169
|
+
: normalizedLeft === normalizedRight;
|
|
170
|
+
}
|
|
171
|
+
function sameRealPath(left, right) {
|
|
172
|
+
return path.relative(left, right) === "";
|
|
173
|
+
}
|
|
174
|
+
function splitDestination(value) {
|
|
175
|
+
const trimmed = value.trim();
|
|
176
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
177
|
+
return {
|
|
178
|
+
disposition: "ignored",
|
|
179
|
+
fragment: trimmed.slice(1) || null,
|
|
180
|
+
};
|
|
181
|
+
if (trimmed.startsWith("//") || /^[A-Za-z][A-Za-z0-9+.-]*:/u.test(trimmed))
|
|
182
|
+
return { disposition: "ignored", fragment: null };
|
|
183
|
+
const fragmentIndex = trimmed.indexOf("#");
|
|
184
|
+
const queryIndex = trimmed.indexOf("?");
|
|
185
|
+
const boundary = [fragmentIndex, queryIndex]
|
|
186
|
+
.filter((entry) => entry >= 0)
|
|
187
|
+
.reduce((lowest, entry) => Math.min(lowest, entry), trimmed.length);
|
|
188
|
+
const encodedPath = trimmed.slice(0, boundary);
|
|
189
|
+
const fragment = fragmentIndex >= 0 ? trimmed.slice(fragmentIndex + 1) : null;
|
|
190
|
+
try {
|
|
191
|
+
return {
|
|
192
|
+
disposition: "local",
|
|
193
|
+
local: decodeURIComponent(encodedPath),
|
|
194
|
+
fragment,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return {
|
|
199
|
+
disposition: "invalid",
|
|
200
|
+
fragment,
|
|
201
|
+
detail: "local Markdown destination contains invalid URL encoding",
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function lineLengths(content, threshold) {
|
|
206
|
+
let maximum = 0;
|
|
207
|
+
const long = [];
|
|
208
|
+
for (const [index, line] of content.split(/\r\n?|\n/u).entries()) {
|
|
209
|
+
const codePoints = Array.from(line).length;
|
|
210
|
+
maximum = Math.max(maximum, codePoints);
|
|
211
|
+
if (codePoints > threshold)
|
|
212
|
+
long.push({ line: index + 1, code_points: codePoints });
|
|
213
|
+
}
|
|
214
|
+
return { maximum, long };
|
|
215
|
+
}
|
|
216
|
+
function declarationConflicts(declarations) {
|
|
217
|
+
const groups = new Map();
|
|
218
|
+
for (const declaration of declarations) {
|
|
219
|
+
const key = `${declaration.type}\0${declaration.id}`;
|
|
220
|
+
groups.set(key, [...(groups.get(key) ?? []), declaration]);
|
|
221
|
+
}
|
|
222
|
+
const conflicts = [];
|
|
223
|
+
for (const declarationsForKey of groups.values()) {
|
|
224
|
+
const owners = new Map();
|
|
225
|
+
for (const declaration of declarationsForKey)
|
|
226
|
+
if (!owners.has(declaration.path))
|
|
227
|
+
owners.set(declaration.path, declaration.line);
|
|
228
|
+
if (owners.size < 2)
|
|
229
|
+
continue;
|
|
230
|
+
conflicts.push({
|
|
231
|
+
type: declarationsForKey[0].type,
|
|
232
|
+
id: declarationsForKey[0].id,
|
|
233
|
+
owners: [...owners.entries()]
|
|
234
|
+
.sort(([left], [right]) => compareUtf8Paths(left, right))
|
|
235
|
+
.map(([ownerPath, line]) => ({ path: ownerPath, line })),
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return conflicts.sort((left, right) => compareUtf8Paths(`${left.type}:${left.id}`, `${right.type}:${right.id}`));
|
|
239
|
+
}
|
|
240
|
+
function isMissing(error) {
|
|
241
|
+
return (typeof error === "object" &&
|
|
242
|
+
error !== null &&
|
|
243
|
+
"code" in error &&
|
|
244
|
+
error.code === "ENOENT");
|
|
245
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ContextInvalidDeclaration, ContextMarkdownRawReference, ContextStableKeyDeclaration } from "./context-markdown-types.js";
|
|
2
|
+
export interface ContextMarkdownExtraction {
|
|
3
|
+
references: ContextMarkdownRawReference[];
|
|
4
|
+
declarations: ContextStableKeyDeclaration[];
|
|
5
|
+
invalid_declarations: ContextInvalidDeclaration[];
|
|
6
|
+
}
|
|
7
|
+
export declare function extractContextMarkdown(content: string, sourcePath: string): ContextMarkdownExtraction;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
2
|
+
const DECLARATION = /^<!--\s*ty-context-declare\s+([A-Z][A-Za-z0-9]*-ID):\s*([A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+)\s*-->$/u;
|
|
3
|
+
export function extractContextMarkdown(content, sourcePath) {
|
|
4
|
+
const tree = fromMarkdown(content);
|
|
5
|
+
const references = [];
|
|
6
|
+
const declarations = [];
|
|
7
|
+
const invalidDeclarations = [];
|
|
8
|
+
walk(tree, (node) => {
|
|
9
|
+
const line = node.position?.start.line ?? 1;
|
|
10
|
+
const column = node.position?.start.column ?? 1;
|
|
11
|
+
if (node.type === "link")
|
|
12
|
+
references.push({
|
|
13
|
+
destination: node.url,
|
|
14
|
+
kind: "inline",
|
|
15
|
+
line,
|
|
16
|
+
column,
|
|
17
|
+
});
|
|
18
|
+
else if (node.type === "image")
|
|
19
|
+
references.push({
|
|
20
|
+
destination: node.url,
|
|
21
|
+
kind: "image",
|
|
22
|
+
line,
|
|
23
|
+
column,
|
|
24
|
+
});
|
|
25
|
+
else if (node.type === "definition")
|
|
26
|
+
references.push({
|
|
27
|
+
destination: node.url,
|
|
28
|
+
kind: "definition",
|
|
29
|
+
line,
|
|
30
|
+
column,
|
|
31
|
+
});
|
|
32
|
+
else if (node.type === "text") {
|
|
33
|
+
for (const angle of angleDestinations(node.value))
|
|
34
|
+
references.push({
|
|
35
|
+
destination: angle.value,
|
|
36
|
+
kind: "angle",
|
|
37
|
+
line,
|
|
38
|
+
column: column + angle.code_point_offset,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else if (node.type === "html") {
|
|
42
|
+
const raw = node.value.trim();
|
|
43
|
+
const declaration = DECLARATION.exec(raw);
|
|
44
|
+
if (declaration)
|
|
45
|
+
declarations.push({
|
|
46
|
+
type: declaration[1],
|
|
47
|
+
id: declaration[2],
|
|
48
|
+
path: sourcePath,
|
|
49
|
+
line,
|
|
50
|
+
column,
|
|
51
|
+
});
|
|
52
|
+
else if (raw.includes("ty-context-declare"))
|
|
53
|
+
invalidDeclarations.push({
|
|
54
|
+
path: sourcePath,
|
|
55
|
+
raw,
|
|
56
|
+
line,
|
|
57
|
+
column,
|
|
58
|
+
reason: "declaration must be an exact HTML comment with <Type-ID>: <UPPERCASE-ID-PARTS>",
|
|
59
|
+
});
|
|
60
|
+
else if (raw.startsWith("<") && raw.endsWith(">")) {
|
|
61
|
+
const destination = raw.slice(1, -1).trim();
|
|
62
|
+
if (looksLikeLocalAngle(destination))
|
|
63
|
+
references.push({
|
|
64
|
+
destination,
|
|
65
|
+
kind: "angle",
|
|
66
|
+
line,
|
|
67
|
+
column,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
references,
|
|
74
|
+
declarations,
|
|
75
|
+
invalid_declarations: invalidDeclarations,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function walk(node, visit) {
|
|
79
|
+
if (node.type !== "root")
|
|
80
|
+
visit(node);
|
|
81
|
+
if (!("children" in node))
|
|
82
|
+
return;
|
|
83
|
+
for (const child of node.children)
|
|
84
|
+
walk(child, visit);
|
|
85
|
+
}
|
|
86
|
+
function angleDestinations(value) {
|
|
87
|
+
const result = [];
|
|
88
|
+
const points = Array.from(value);
|
|
89
|
+
for (let index = 0; index < points.length; index += 1) {
|
|
90
|
+
if (points[index] !== "<")
|
|
91
|
+
continue;
|
|
92
|
+
const end = points.indexOf(">", index + 1);
|
|
93
|
+
if (end < 0)
|
|
94
|
+
break;
|
|
95
|
+
const candidate = points
|
|
96
|
+
.slice(index + 1, end)
|
|
97
|
+
.join("")
|
|
98
|
+
.trim();
|
|
99
|
+
if (looksLikeLocalAngle(candidate))
|
|
100
|
+
result.push({ value: candidate, code_point_offset: index });
|
|
101
|
+
index = end;
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
function looksLikeLocalAngle(value) {
|
|
106
|
+
if (!value || Array.from(value).some((point) => /\s/u.test(point)))
|
|
107
|
+
return false;
|
|
108
|
+
return (value.startsWith(".") ||
|
|
109
|
+
value.startsWith("/") ||
|
|
110
|
+
value.startsWith("project_context") ||
|
|
111
|
+
value.includes("/") ||
|
|
112
|
+
value.includes("\\") ||
|
|
113
|
+
value.toLowerCase().endsWith(".md"));
|
|
114
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type ContextMarkdownReferenceKind = "inline" | "image" | "definition" | "angle";
|
|
2
|
+
export type ContextMarkdownReferenceStatus = "valid" | "missing" | "outside_repository" | "invalid";
|
|
3
|
+
export interface ContextMarkdownRawReference {
|
|
4
|
+
destination: string;
|
|
5
|
+
kind: ContextMarkdownReferenceKind;
|
|
6
|
+
line: number;
|
|
7
|
+
column: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ContextMarkdownReference extends ContextMarkdownRawReference {
|
|
10
|
+
source_path: string;
|
|
11
|
+
target_path: string | null;
|
|
12
|
+
fragment: string | null;
|
|
13
|
+
status: ContextMarkdownReferenceStatus;
|
|
14
|
+
detail?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ContextStableKeyDeclaration {
|
|
17
|
+
type: string;
|
|
18
|
+
id: string;
|
|
19
|
+
path: string;
|
|
20
|
+
line: number;
|
|
21
|
+
column: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ContextInvalidDeclaration {
|
|
24
|
+
path: string;
|
|
25
|
+
raw: string;
|
|
26
|
+
line: number;
|
|
27
|
+
column: number;
|
|
28
|
+
reason: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ContextLongLine {
|
|
31
|
+
line: number;
|
|
32
|
+
code_points: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ContextMarkdownFileAnalysis {
|
|
35
|
+
path: string;
|
|
36
|
+
bytes: number;
|
|
37
|
+
max_line_code_points: number;
|
|
38
|
+
long_lines: ContextLongLine[];
|
|
39
|
+
references: ContextMarkdownReference[];
|
|
40
|
+
declarations: ContextStableKeyDeclaration[];
|
|
41
|
+
invalid_declarations: ContextInvalidDeclaration[];
|
|
42
|
+
}
|
|
43
|
+
export interface ContextStableKeyConflict {
|
|
44
|
+
type: string;
|
|
45
|
+
id: string;
|
|
46
|
+
owners: Array<{
|
|
47
|
+
path: string;
|
|
48
|
+
line: number;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
export interface ContextMarkdownCatalogAnalysis {
|
|
52
|
+
files: ContextMarkdownFileAnalysis[];
|
|
53
|
+
references: ContextMarkdownReference[];
|
|
54
|
+
declarations: ContextStableKeyDeclaration[];
|
|
55
|
+
invalid_declarations: ContextInvalidDeclaration[];
|
|
56
|
+
declaration_conflicts: ContextStableKeyConflict[];
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CLI_EXIT_CODES, CliCommandError } from "../cli-exit.js";
|
|
2
|
+
import { normalizeContextFilePath } from "../context-create/context-create-path.js";
|
|
3
|
+
export function normalizeContextMoveInput(input) {
|
|
4
|
+
const from = normalizeContextFilePath(input.from_path, "context move --from");
|
|
5
|
+
const to = normalizeContextFilePath(input.to_path, "context move --to");
|
|
6
|
+
if (from === to)
|
|
7
|
+
invalid("context move --from and --to must be different paths");
|
|
8
|
+
if (fold(from) === fold(to))
|
|
9
|
+
invalid("context move does not support case-only path changes");
|
|
10
|
+
return { from_path: from, to_path: to };
|
|
11
|
+
}
|
|
12
|
+
function fold(value) {
|
|
13
|
+
return value.normalize("NFC").toLocaleLowerCase("en-US");
|
|
14
|
+
}
|
|
15
|
+
function invalid(message) {
|
|
16
|
+
throw new CliCommandError(CLI_EXIT_CODES.arguments, message);
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ContextMoveLiteralMatch {
|
|
2
|
+
path: string;
|
|
3
|
+
line: number;
|
|
4
|
+
column: number;
|
|
5
|
+
matched: string;
|
|
6
|
+
kind: "markdown_non_link" | "code_or_config";
|
|
7
|
+
}
|
|
8
|
+
export interface ContextMoveLiteralScan {
|
|
9
|
+
complete: boolean;
|
|
10
|
+
files_scanned: number;
|
|
11
|
+
bytes_scanned: number;
|
|
12
|
+
matches: ContextMoveLiteralMatch[];
|
|
13
|
+
limits_exceeded: string[];
|
|
14
|
+
}
|
|
15
|
+
export declare function scanStagedRepositoryForContextPath(input: {
|
|
16
|
+
repository: string;
|
|
17
|
+
logical_context_path: string;
|
|
18
|
+
physical_context_path: string;
|
|
19
|
+
file_overrides: ReadonlyMap<string, Uint8Array | null>;
|
|
20
|
+
}): Promise<ContextMoveLiteralScan>;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { compareUtf8Paths, normalizeContextPath, } from "../context-catalog/catalog-paths.js";
|
|
4
|
+
const MAX_FILES = 4096;
|
|
5
|
+
const MAX_FILE_BYTES = 1024 * 1024;
|
|
6
|
+
const MAX_TOTAL_BYTES = 32 * 1024 * 1024;
|
|
7
|
+
const MAX_MATCHES = 500;
|
|
8
|
+
const SKIPPED_DIRECTORIES = new Set([
|
|
9
|
+
".git",
|
|
10
|
+
"node_modules",
|
|
11
|
+
"dist",
|
|
12
|
+
"coverage",
|
|
13
|
+
".artifacts",
|
|
14
|
+
"tmp",
|
|
15
|
+
]);
|
|
16
|
+
const TEXT_EXTENSIONS = new Set([
|
|
17
|
+
".md",
|
|
18
|
+
".txt",
|
|
19
|
+
".toml",
|
|
20
|
+
".yaml",
|
|
21
|
+
".yml",
|
|
22
|
+
".json",
|
|
23
|
+
".jsonc",
|
|
24
|
+
".ts",
|
|
25
|
+
".tsx",
|
|
26
|
+
".js",
|
|
27
|
+
".jsx",
|
|
28
|
+
".mjs",
|
|
29
|
+
".cjs",
|
|
30
|
+
".py",
|
|
31
|
+
".rs",
|
|
32
|
+
".go",
|
|
33
|
+
".java",
|
|
34
|
+
".kt",
|
|
35
|
+
".sh",
|
|
36
|
+
".ps1",
|
|
37
|
+
".bat",
|
|
38
|
+
".cmd",
|
|
39
|
+
".xml",
|
|
40
|
+
".html",
|
|
41
|
+
".css",
|
|
42
|
+
".scss",
|
|
43
|
+
]);
|
|
44
|
+
export async function scanStagedRepositoryForContextPath(input) {
|
|
45
|
+
const discovered = await discoverTextFiles(input.repository);
|
|
46
|
+
const paths = new Map();
|
|
47
|
+
const limits = new Set(discovered.limits);
|
|
48
|
+
for (const file of discovered.files) {
|
|
49
|
+
const existing = paths.get(file.path);
|
|
50
|
+
if (existing !== undefined && existing !== file.physical_path) {
|
|
51
|
+
limits.add(`path_unicode_collision:${file.path}`);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
paths.set(file.path, file.physical_path);
|
|
55
|
+
}
|
|
56
|
+
for (const [file, bytes] of input.file_overrides) {
|
|
57
|
+
const logical = normalizeContextPath(file);
|
|
58
|
+
if (bytes === null)
|
|
59
|
+
paths.delete(logical);
|
|
60
|
+
else if (isTextCandidate(logical) && !paths.has(logical))
|
|
61
|
+
paths.set(logical, file);
|
|
62
|
+
}
|
|
63
|
+
const ordered = [...paths].sort(([left], [right]) => compareUtf8Paths(left, right));
|
|
64
|
+
if (ordered.length > MAX_FILES)
|
|
65
|
+
limits.add(`file_count>${MAX_FILES}`);
|
|
66
|
+
const matches = [];
|
|
67
|
+
let filesScanned = 0;
|
|
68
|
+
let bytesScanned = 0;
|
|
69
|
+
for (const [file, physicalFile] of ordered.slice(0, MAX_FILES)) {
|
|
70
|
+
const override = input.file_overrides.get(file);
|
|
71
|
+
let bytes;
|
|
72
|
+
try {
|
|
73
|
+
bytes =
|
|
74
|
+
override === undefined
|
|
75
|
+
? await readFile(path.join(input.repository, ...physicalFile.split("/")))
|
|
76
|
+
: Buffer.from(override ?? []);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
limits.add(`read_failed:${file}:${message(error)}`);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (bytes.length > MAX_FILE_BYTES) {
|
|
83
|
+
limits.add(`file_bytes>${MAX_FILE_BYTES}:${file}`);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (bytesScanned + bytes.length > MAX_TOTAL_BYTES) {
|
|
87
|
+
limits.add(`total_bytes>${MAX_TOTAL_BYTES}`);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
bytesScanned += bytes.length;
|
|
91
|
+
filesScanned += 1;
|
|
92
|
+
let content;
|
|
93
|
+
try {
|
|
94
|
+
content = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
for (const literal of literals(input.logical_context_path, input.physical_context_path)) {
|
|
100
|
+
let cursor = 0;
|
|
101
|
+
while ((cursor = content.indexOf(literal, cursor)) >= 0) {
|
|
102
|
+
if (!hasPathBoundaries(content, cursor, literal.length)) {
|
|
103
|
+
cursor += Math.max(1, literal.length);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const location = lineColumn(content, cursor);
|
|
107
|
+
matches.push({
|
|
108
|
+
path: file,
|
|
109
|
+
...location,
|
|
110
|
+
matched: literal,
|
|
111
|
+
kind: file.toLowerCase().endsWith(".md")
|
|
112
|
+
? "markdown_non_link"
|
|
113
|
+
: "code_or_config",
|
|
114
|
+
});
|
|
115
|
+
cursor += Math.max(1, literal.length);
|
|
116
|
+
if (matches.length >= MAX_MATCHES) {
|
|
117
|
+
limits.add(`matches>=${MAX_MATCHES}`);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (matches.length >= MAX_MATCHES)
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
if (matches.length >= MAX_MATCHES)
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
complete: limits.size === 0,
|
|
129
|
+
files_scanned: filesScanned,
|
|
130
|
+
bytes_scanned: bytesScanned,
|
|
131
|
+
matches,
|
|
132
|
+
limits_exceeded: [...limits].sort(),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
async function discoverTextFiles(repository) {
|
|
136
|
+
const result = [];
|
|
137
|
+
const limits = new Set();
|
|
138
|
+
let stopped = false;
|
|
139
|
+
async function visit(relative) {
|
|
140
|
+
if (stopped)
|
|
141
|
+
return;
|
|
142
|
+
const absolute = relative
|
|
143
|
+
? path.join(repository, ...relative.split("/"))
|
|
144
|
+
: repository;
|
|
145
|
+
const entries = await readdir(absolute, { withFileTypes: true });
|
|
146
|
+
for (const entry of entries.sort((left, right) => compareUtf8Paths(left.name, right.name))) {
|
|
147
|
+
const child = relative ? `${relative}/${entry.name}` : entry.name;
|
|
148
|
+
if (SKIPPED_DIRECTORIES.has(entry.name) || child === ".codex/work")
|
|
149
|
+
continue;
|
|
150
|
+
if (entry.isSymbolicLink()) {
|
|
151
|
+
limits.add(`symlink_skipped:${child}`);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (entry.isDirectory()) {
|
|
155
|
+
await visit(child);
|
|
156
|
+
}
|
|
157
|
+
else if (entry.isFile() && isTextCandidate(child)) {
|
|
158
|
+
result.push({
|
|
159
|
+
path: normalizeContextPath(child),
|
|
160
|
+
physical_path: child,
|
|
161
|
+
});
|
|
162
|
+
if (result.length > MAX_FILES) {
|
|
163
|
+
limits.add(`file_count>${MAX_FILES}`);
|
|
164
|
+
stopped = true;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
await visit("");
|
|
171
|
+
return { files: result, limits: [...limits] };
|
|
172
|
+
}
|
|
173
|
+
function isTextCandidate(file) {
|
|
174
|
+
const lower = file.toLowerCase();
|
|
175
|
+
const extension = path.posix.extname(lower);
|
|
176
|
+
return (TEXT_EXTENSIONS.has(extension) ||
|
|
177
|
+
["makefile", "dockerfile"].includes(path.posix.basename(lower)));
|
|
178
|
+
}
|
|
179
|
+
function literals(logicalPath, physicalPath) {
|
|
180
|
+
const variants = [logicalPath, physicalPath].flatMap((contextPath) => {
|
|
181
|
+
const encoded = contextPath.split("/").map(encodeURIComponent).join("/");
|
|
182
|
+
const windows = contextPath.replaceAll("/", "\\");
|
|
183
|
+
return [
|
|
184
|
+
contextPath,
|
|
185
|
+
`/${contextPath}`,
|
|
186
|
+
windows,
|
|
187
|
+
`\\${windows}`,
|
|
188
|
+
encoded,
|
|
189
|
+
`/${encoded}`,
|
|
190
|
+
];
|
|
191
|
+
});
|
|
192
|
+
return [...new Set(variants)]
|
|
193
|
+
.filter(Boolean)
|
|
194
|
+
.sort((left, right) => Buffer.byteLength(right, "utf8") - Buffer.byteLength(left, "utf8") ||
|
|
195
|
+
compareUtf8Paths(left, right));
|
|
196
|
+
}
|
|
197
|
+
function hasPathBoundaries(content, start, length) {
|
|
198
|
+
const before = start === 0 ? "" : content[start - 1];
|
|
199
|
+
const after = content[start + length] ?? "";
|
|
200
|
+
const pathCharacter = /[A-Za-z0-9_.%/\\-]/u;
|
|
201
|
+
return ((!before || !pathCharacter.test(before)) &&
|
|
202
|
+
(!after || !pathCharacter.test(after)));
|
|
203
|
+
}
|
|
204
|
+
function lineColumn(content, offset) {
|
|
205
|
+
const lines = content.slice(0, offset).split(/\r\n?|\n/u);
|
|
206
|
+
return {
|
|
207
|
+
line: lines.length,
|
|
208
|
+
column: Array.from(lines.at(-1) ?? "").length + 1,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function message(error) {
|
|
212
|
+
return error instanceof Error ? error.message : String(error);
|
|
213
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ContextCatalog } from "../context-catalog/catalog-types.js";
|
|
2
|
+
import type { ContextMutationJournal } from "../context-mutation/mutation-types.js";
|
|
3
|
+
export declare function validateLiveContextMove(repository: string, catalog: ContextCatalog, journal: ContextMutationJournal): Promise<void>;
|