@cleocode/core 2026.9.8 → 2026.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit/reconstruct.d.ts +13 -43
- package/dist/audit/reconstruct.d.ts.map +1 -1
- package/dist/audit/reconstruct.js +295 -290
- package/dist/audit/reconstruct.js.map +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +8 -2
- package/dist/bootstrap.js.map +1 -1
- package/dist/compliance/protocol-rules.d.ts.map +1 -1
- package/dist/compliance/protocol-rules.js +3 -1
- package/dist/compliance/protocol-rules.js.map +1 -1
- package/dist/dispatch/mutate-projection.d.ts.map +1 -1
- package/dist/dispatch/mutate-projection.js +12 -0
- package/dist/dispatch/mutate-projection.js.map +1 -1
- package/dist/dispatch/mvi-projection.d.ts +29 -6
- package/dist/dispatch/mvi-projection.d.ts.map +1 -1
- package/dist/dispatch/mvi-projection.js +109 -139
- package/dist/dispatch/mvi-projection.js.map +1 -1
- package/dist/docs/docs-read-model.d.ts +3 -2
- package/dist/docs/docs-read-model.d.ts.map +1 -1
- package/dist/docs/docs-read-model.js +4 -3
- package/dist/docs/docs-read-model.js.map +1 -1
- package/dist/docs/export-document.js +5129 -2297
- package/dist/docs/export-document.js.map +3 -3
- package/dist/docs/projection.d.ts +67 -0
- package/dist/docs/projection.d.ts.map +1 -0
- package/dist/docs/projection.js +370 -0
- package/dist/docs/projection.js.map +1 -0
- package/dist/doctor/acceptance-drift.d.ts +6 -2
- package/dist/doctor/acceptance-drift.d.ts.map +1 -1
- package/dist/doctor/acceptance-drift.js +43 -5
- package/dist/doctor/acceptance-drift.js.map +1 -1
- package/dist/doctor/knowledge-summary.d.ts +41 -0
- package/dist/doctor/knowledge-summary.d.ts.map +1 -0
- package/dist/doctor/knowledge-summary.js +81 -0
- package/dist/doctor/knowledge-summary.js.map +1 -0
- package/dist/doctor/knowledge.d.ts +192 -0
- package/dist/doctor/knowledge.d.ts.map +1 -0
- package/dist/doctor/knowledge.js +1864 -0
- package/dist/doctor/knowledge.js.map +1 -0
- package/dist/git/work-tree.d.ts +169 -0
- package/dist/git/work-tree.d.ts.map +1 -0
- package/dist/git/work-tree.js +341 -0
- package/dist/git/work-tree.js.map +1 -0
- package/dist/hooks/handlers/task-hooks.d.ts +8 -5
- package/dist/hooks/handlers/task-hooks.d.ts.map +1 -1
- package/dist/hooks/handlers/task-hooks.js +15 -60
- package/dist/hooks/handlers/task-hooks.js.map +1 -1
- package/dist/identity/cleo-identity.d.ts +13 -0
- package/dist/identity/cleo-identity.d.ts.map +1 -1
- package/dist/identity/cleo-identity.js +20 -6
- package/dist/identity/cleo-identity.js.map +1 -1
- package/dist/injection.d.ts.map +1 -1
- package/dist/injection.js +29 -13
- package/dist/injection.js.map +1 -1
- package/dist/internal.d.ts +3 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +1 -1
- package/dist/lifecycle/verification/satisfies-validator.d.ts.map +1 -1
- package/dist/lifecycle/verification/satisfies-validator.js +124 -120
- package/dist/lifecycle/verification/satisfies-validator.js.map +1 -1
- package/dist/llm/plugin-facade.js +4047 -1726
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/memory/brain-backfill.d.ts +27 -12
- package/dist/memory/brain-backfill.d.ts.map +1 -1
- package/dist/memory/brain-backfill.js +325 -134
- package/dist/memory/brain-backfill.js.map +1 -1
- package/dist/memory/brain-doctor.d.ts +21 -0
- package/dist/memory/brain-doctor.d.ts.map +1 -1
- package/dist/memory/brain-doctor.js +111 -53
- package/dist/memory/brain-doctor.js.map +1 -1
- package/dist/memory/brain-links.d.ts.map +1 -1
- package/dist/memory/brain-links.js +31 -4
- package/dist/memory/brain-links.js.map +1 -1
- package/dist/memory/brain-reasoning.d.ts.map +1 -1
- package/dist/memory/brain-reasoning.js +28 -2
- package/dist/memory/brain-reasoning.js.map +1 -1
- package/dist/memory/brain-reconciler.d.ts +14 -19
- package/dist/memory/brain-reconciler.d.ts.map +1 -1
- package/dist/memory/brain-reconciler.js +70 -97
- package/dist/memory/brain-reconciler.js.map +1 -1
- package/dist/memory/brain-search.d.ts +2 -0
- package/dist/memory/brain-search.d.ts.map +1 -1
- package/dist/memory/brain-search.js +59 -29
- package/dist/memory/brain-search.js.map +1 -1
- package/dist/memory/brain-similarity.d.ts.map +1 -1
- package/dist/memory/brain-similarity.js +5 -4
- package/dist/memory/brain-similarity.js.map +1 -1
- package/dist/memory/brain-stub-prune.d.ts +31 -9
- package/dist/memory/brain-stub-prune.d.ts.map +1 -1
- package/dist/memory/brain-stub-prune.js +65 -18
- package/dist/memory/brain-stub-prune.js.map +1 -1
- package/dist/memory/brain-writer-handlers.d.ts +10 -1
- package/dist/memory/brain-writer-handlers.d.ts.map +1 -1
- package/dist/memory/brain-writer-handlers.js +23 -3
- package/dist/memory/brain-writer-handlers.js.map +1 -1
- package/dist/memory/brain-writer-thread.d.ts +11 -1
- package/dist/memory/brain-writer-thread.d.ts.map +1 -1
- package/dist/memory/brain-writer-thread.js +87 -20
- package/dist/memory/brain-writer-thread.js.map +1 -1
- package/dist/memory/brain-writer-worker.js +8 -1
- package/dist/memory/brain-writer-worker.js.map +1 -1
- package/dist/memory/decision-cross-link.d.ts +39 -0
- package/dist/memory/decision-cross-link.d.ts.map +1 -1
- package/dist/memory/decision-cross-link.js +316 -0
- package/dist/memory/decision-cross-link.js.map +1 -1
- package/dist/memory/decisions.d.ts +4 -1
- package/dist/memory/decisions.d.ts.map +1 -1
- package/dist/memory/decisions.js +7 -24
- package/dist/memory/decisions.js.map +1 -1
- package/dist/memory/dispatch-trace.d.ts +12 -5
- package/dist/memory/dispatch-trace.d.ts.map +1 -1
- package/dist/memory/dispatch-trace.js +17 -7
- package/dist/memory/dispatch-trace.js.map +1 -1
- package/dist/memory/eligibility.d.ts +51 -0
- package/dist/memory/eligibility.d.ts.map +1 -0
- package/dist/memory/eligibility.js +77 -0
- package/dist/memory/eligibility.js.map +1 -0
- package/dist/memory/engine-compat.d.ts +2 -0
- package/dist/memory/engine-compat.d.ts.map +1 -1
- package/dist/memory/engine-compat.js +10 -0
- package/dist/memory/engine-compat.js.map +1 -1
- package/dist/memory/extraction-gate.d.ts +21 -7
- package/dist/memory/extraction-gate.d.ts.map +1 -1
- package/dist/memory/extraction-gate.js +178 -216
- package/dist/memory/extraction-gate.js.map +1 -1
- package/dist/memory/graph-auto-populate.d.ts +38 -5
- package/dist/memory/graph-auto-populate.d.ts.map +1 -1
- package/dist/memory/graph-auto-populate.js +182 -60
- package/dist/memory/graph-auto-populate.js.map +1 -1
- package/dist/memory/graph-memory-bridge.d.ts +14 -1
- package/dist/memory/graph-memory-bridge.d.ts.map +1 -1
- package/dist/memory/graph-memory-bridge.js +66 -28
- package/dist/memory/graph-memory-bridge.js.map +1 -1
- package/dist/memory/index.d.ts +1 -19
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +1 -50
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/learnings.d.ts.map +1 -1
- package/dist/memory/learnings.js +2 -23
- package/dist/memory/learnings.js.map +1 -1
- package/dist/memory/manifest-filter.d.ts +21 -0
- package/dist/memory/manifest-filter.d.ts.map +1 -0
- package/dist/memory/manifest-filter.js +51 -0
- package/dist/memory/manifest-filter.js.map +1 -0
- package/dist/memory/manifest-ingestion.d.ts +28 -30
- package/dist/memory/manifest-ingestion.d.ts.map +1 -1
- package/dist/memory/manifest-ingestion.js +104 -235
- package/dist/memory/manifest-ingestion.js.map +1 -1
- package/dist/memory/observer-reflector.d.ts +2 -0
- package/dist/memory/observer-reflector.d.ts.map +1 -1
- package/dist/memory/observer-reflector.js +6 -49
- package/dist/memory/observer-reflector.js.map +1 -1
- package/dist/memory/patterns.d.ts +10 -0
- package/dist/memory/patterns.d.ts.map +1 -1
- package/dist/memory/patterns.js +25 -33
- package/dist/memory/patterns.js.map +1 -1
- package/dist/memory/pipeline-manifest-sqlite.d.ts +72 -9
- package/dist/memory/pipeline-manifest-sqlite.d.ts.map +1 -1
- package/dist/memory/pipeline-manifest-sqlite.js +508 -412
- package/dist/memory/pipeline-manifest-sqlite.js.map +1 -1
- package/dist/memory/retrieval/build-retrieval-bundle.d.ts.map +1 -1
- package/dist/memory/retrieval/build-retrieval-bundle.js +16 -15
- package/dist/memory/retrieval/build-retrieval-bundle.js.map +1 -1
- package/dist/memory/retrieval/fetch.d.ts +7 -0
- package/dist/memory/retrieval/fetch.d.ts.map +1 -1
- package/dist/memory/retrieval/fetch.js +14 -11
- package/dist/memory/retrieval/fetch.js.map +1 -1
- package/dist/memory/retrieval/observe.d.ts +7 -1
- package/dist/memory/retrieval/observe.d.ts.map +1 -1
- package/dist/memory/retrieval/observe.js +58 -4
- package/dist/memory/retrieval/observe.js.map +1 -1
- package/dist/memory/retrieval/search.d.ts +14 -1
- package/dist/memory/retrieval/search.d.ts.map +1 -1
- package/dist/memory/retrieval/search.js +133 -69
- package/dist/memory/retrieval/search.js.map +1 -1
- package/dist/memory/retrieval/telemetry.d.ts +31 -0
- package/dist/memory/retrieval/telemetry.d.ts.map +1 -0
- package/dist/memory/retrieval/telemetry.js +53 -0
- package/dist/memory/retrieval/telemetry.js.map +1 -0
- package/dist/nexus/analyze-orchestrator.d.ts +41 -9
- package/dist/nexus/analyze-orchestrator.d.ts.map +1 -1
- package/dist/nexus/analyze-orchestrator.js +257 -58
- package/dist/nexus/analyze-orchestrator.js.map +1 -1
- package/dist/nexus/api-contracts.d.ts +2 -6
- package/dist/nexus/api-contracts.d.ts.map +1 -1
- package/dist/nexus/api-contracts.js +11 -2
- package/dist/nexus/api-contracts.js.map +1 -1
- package/dist/nexus/context.d.ts.map +1 -1
- package/dist/nexus/context.js +14 -37
- package/dist/nexus/context.js.map +1 -1
- package/dist/nexus/diff.d.ts.map +1 -1
- package/dist/nexus/diff.js +2 -1
- package/dist/nexus/diff.js.map +1 -1
- package/dist/nexus/identity.d.ts +29 -3
- package/dist/nexus/identity.d.ts.map +1 -1
- package/dist/nexus/identity.js +63 -12
- package/dist/nexus/identity.js.map +1 -1
- package/dist/nexus/impact.d.ts +21 -19
- package/dist/nexus/impact.d.ts.map +1 -1
- package/dist/nexus/impact.js +96 -192
- package/dist/nexus/impact.js.map +1 -1
- package/dist/nexus/knowledge.d.ts +80 -0
- package/dist/nexus/knowledge.d.ts.map +1 -0
- package/dist/nexus/knowledge.js +786 -0
- package/dist/nexus/knowledge.js.map +1 -0
- package/dist/nexus/living-brain.d.ts +8 -5
- package/dist/nexus/living-brain.d.ts.map +1 -1
- package/dist/nexus/living-brain.js +252 -188
- package/dist/nexus/living-brain.js.map +1 -1
- package/dist/nexus/registry.d.ts +11 -2
- package/dist/nexus/registry.d.ts.map +1 -1
- package/dist/nexus/registry.js +144 -128
- package/dist/nexus/registry.js.map +1 -1
- package/dist/nexus/source-roots.d.ts +16 -0
- package/dist/nexus/source-roots.d.ts.map +1 -0
- package/dist/nexus/source-roots.js +174 -0
- package/dist/nexus/source-roots.js.map +1 -0
- package/dist/nexus/task-evidence.d.ts +22 -0
- package/dist/nexus/task-evidence.d.ts.map +1 -0
- package/dist/nexus/task-evidence.js +210 -0
- package/dist/nexus/task-evidence.js.map +1 -0
- package/dist/nexus/tasks-bridge.d.ts +14 -7
- package/dist/nexus/tasks-bridge.d.ts.map +1 -1
- package/dist/nexus/tasks-bridge.js +81 -40
- package/dist/nexus/tasks-bridge.js.map +1 -1
- package/dist/orchestrate/lifecycle-ops.d.ts.map +1 -1
- package/dist/orchestrate/lifecycle-ops.js +170 -120
- package/dist/orchestrate/lifecycle-ops.js.map +1 -1
- package/dist/orchestrate/query-ops.d.ts +6 -7
- package/dist/orchestrate/query-ops.d.ts.map +1 -1
- package/dist/orchestrate/query-ops.js +509 -532
- package/dist/orchestrate/query-ops.js.map +1 -1
- package/dist/orchestration/bootstrap.d.ts +15 -1
- package/dist/orchestration/bootstrap.d.ts.map +1 -1
- package/dist/orchestration/bootstrap.js +21 -10
- package/dist/orchestration/bootstrap.js.map +1 -1
- package/dist/orchestration/index.d.ts +35 -3
- package/dist/orchestration/index.d.ts.map +1 -1
- package/dist/orchestration/index.js +64 -35
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/lead-rollup.d.ts +24 -1
- package/dist/orchestration/lead-rollup.d.ts.map +1 -1
- package/dist/orchestration/lead-rollup.js +31 -11
- package/dist/orchestration/lead-rollup.js.map +1 -1
- package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
- package/dist/orchestration/spawn-prompt.js +25 -45
- package/dist/orchestration/spawn-prompt.js.map +1 -1
- package/dist/orchestration/unblock.d.ts +15 -1
- package/dist/orchestration/unblock.d.ts.map +1 -1
- package/dist/orchestration/unblock.js +23 -12
- package/dist/orchestration/unblock.js.map +1 -1
- package/dist/orchestration/validate-spawn.d.ts.map +1 -1
- package/dist/orchestration/validate-spawn.js +3 -3
- package/dist/orchestration/validate-spawn.js.map +1 -1
- package/dist/orchestration/waves.d.ts +29 -13
- package/dist/orchestration/waves.d.ts.map +1 -1
- package/dist/orchestration/waves.js +43 -55
- package/dist/orchestration/waves.js.map +1 -1
- package/dist/paths.d.ts +17 -163
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +145 -496
- package/dist/paths.js.map +1 -1
- package/dist/project-info.d.ts +2 -11
- package/dist/project-info.d.ts.map +1 -1
- package/dist/project-info.js +3 -31
- package/dist/project-info.js.map +1 -1
- package/dist/project-scope.d.ts +239 -0
- package/dist/project-scope.d.ts.map +1 -0
- package/dist/project-scope.js +473 -0
- package/dist/project-scope.js.map +1 -0
- package/dist/release/pr-evidence.d.ts +23 -4
- package/dist/release/pr-evidence.d.ts.map +1 -1
- package/dist/release/pr-evidence.js +65 -9
- package/dist/release/pr-evidence.js.map +1 -1
- package/dist/render/nexus/graph/index.d.ts.map +1 -1
- package/dist/render/nexus/graph/index.js +4 -2
- package/dist/render/nexus/graph/index.js.map +1 -1
- package/dist/render/orchestration/audit-reconstruct.d.ts +11 -0
- package/dist/render/orchestration/audit-reconstruct.d.ts.map +1 -1
- package/dist/render/orchestration/audit-reconstruct.js +21 -6
- package/dist/render/orchestration/audit-reconstruct.js.map +1 -1
- package/dist/render/tasks/show.js +2 -1
- package/dist/render/tasks/show.js.map +1 -1
- package/dist/resources/spawn-wrapper.d.ts +82 -14
- package/dist/resources/spawn-wrapper.d.ts.map +1 -1
- package/dist/resources/spawn-wrapper.js +585 -27
- package/dist/resources/spawn-wrapper.js.map +1 -1
- package/dist/selfimprove/fix-gen.js +4055 -1734
- package/dist/selfimprove/fix-gen.js.map +3 -3
- package/dist/sequence/index.d.ts.map +1 -1
- package/dist/sequence/index.js +76 -68
- package/dist/sequence/index.js.map +1 -1
- package/dist/session/canon-lint.d.ts +24 -3
- package/dist/session/canon-lint.d.ts.map +1 -1
- package/dist/session/canon-lint.js +72 -31
- package/dist/session/canon-lint.js.map +1 -1
- package/dist/session/engine-ops.d.ts +1 -4
- package/dist/session/engine-ops.d.ts.map +1 -1
- package/dist/session/engine-ops.js +42 -6
- package/dist/session/engine-ops.js.map +1 -1
- package/dist/sessions/briefing.d.ts +11 -1
- package/dist/sessions/briefing.d.ts.map +1 -1
- package/dist/sessions/briefing.js +76 -8
- package/dist/sessions/briefing.js.map +1 -1
- package/dist/sessions/handoff.d.ts +3 -1
- package/dist/sessions/handoff.d.ts.map +1 -1
- package/dist/sessions/handoff.js +2 -0
- package/dist/sessions/handoff.js.map +1 -1
- package/dist/shutdown-deadline.d.ts +24 -33
- package/dist/shutdown-deadline.d.ts.map +1 -1
- package/dist/shutdown-deadline.js +71 -14
- package/dist/shutdown-deadline.js.map +1 -1
- package/dist/shutdown.d.ts +21 -10
- package/dist/shutdown.d.ts.map +1 -1
- package/dist/shutdown.js +89 -42
- package/dist/shutdown.js.map +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/orchestrator/validator.d.ts +87 -20
- package/dist/skills/orchestrator/validator.d.ts.map +1 -1
- package/dist/skills/orchestrator/validator.js +330 -241
- package/dist/skills/orchestrator/validator.js.map +1 -1
- package/dist/store/agent-resolver.d.ts.map +1 -1
- package/dist/store/agent-resolver.js +16 -9
- package/dist/store/agent-resolver.js.map +1 -1
- package/dist/store/attachment-store.d.ts +4 -1
- package/dist/store/attachment-store.d.ts.map +1 -1
- package/dist/store/attachment-store.js +20 -3
- package/dist/store/attachment-store.js.map +1 -1
- package/dist/store/background-jobs.d.ts +426 -105
- package/dist/store/background-jobs.d.ts.map +1 -1
- package/dist/store/background-jobs.js +1208 -252
- package/dist/store/background-jobs.js.map +1 -1
- package/dist/store/background-ops.d.ts +145 -8
- package/dist/store/background-ops.d.ts.map +1 -1
- package/dist/store/background-ops.js +459 -15
- package/dist/store/background-ops.js.map +1 -1
- package/dist/store/backup-inspect.d.ts +48 -4
- package/dist/store/backup-inspect.d.ts.map +1 -1
- package/dist/store/backup-inspect.js +384 -4
- package/dist/store/backup-inspect.js.map +1 -1
- package/dist/store/converters.d.ts.map +1 -1
- package/dist/store/converters.js +19 -2
- package/dist/store/converters.js.map +1 -1
- package/dist/store/data-accessor.d.ts +9 -1
- package/dist/store/data-accessor.d.ts.map +1 -1
- package/dist/store/data-accessor.js +22 -5
- package/dist/store/data-accessor.js.map +1 -1
- package/dist/store/data-safety-central.d.ts.map +1 -1
- package/dist/store/data-safety-central.js +272 -232
- package/dist/store/data-safety-central.js.map +1 -1
- package/dist/store/db-helpers.d.ts +19 -3
- package/dist/store/db-helpers.d.ts.map +1 -1
- package/dist/store/db-helpers.js +42 -58
- package/dist/store/db-helpers.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts +63 -4
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +166 -19
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/exodus/archive.d.ts +21 -7
- package/dist/store/exodus/archive.d.ts.map +1 -1
- package/dist/store/exodus/archive.js +60 -18
- package/dist/store/exodus/archive.js.map +1 -1
- package/dist/store/exodus/migrate.d.ts.map +1 -1
- package/dist/store/exodus/migrate.js +27 -23
- package/dist/store/exodus/migrate.js.map +1 -1
- package/dist/store/exodus/on-open.d.ts +16 -27
- package/dist/store/exodus/on-open.d.ts.map +1 -1
- package/dist/store/exodus/on-open.js +121 -169
- package/dist/store/exodus/on-open.js.map +1 -1
- package/dist/store/exodus/recovery.d.ts +90 -0
- package/dist/store/exodus/recovery.d.ts.map +1 -0
- package/dist/store/exodus/recovery.js +434 -0
- package/dist/store/exodus/recovery.js.map +1 -0
- package/dist/store/exodus/types.d.ts +15 -0
- package/dist/store/exodus/types.d.ts.map +1 -1
- package/dist/store/memory-accessor.d.ts +52 -3
- package/dist/store/memory-accessor.d.ts.map +1 -1
- package/dist/store/memory-accessor.js +122 -7
- package/dist/store/memory-accessor.js.map +1 -1
- package/dist/store/nexus-sqlite.d.ts +24 -6
- package/dist/store/nexus-sqlite.d.ts.map +1 -1
- package/dist/store/nexus-sqlite.js +39 -20
- package/dist/store/nexus-sqlite.js.map +1 -1
- package/dist/store/ports/domain-binding.d.ts.map +1 -1
- package/dist/store/ports/domain-binding.js +27 -5
- package/dist/store/ports/domain-binding.js.map +1 -1
- package/dist/store/schema/background-jobs.d.ts +181 -2
- package/dist/store/schema/background-jobs.d.ts.map +1 -1
- package/dist/store/schema/background-jobs.js +27 -3
- package/dist/store/schema/background-jobs.js.map +1 -1
- package/dist/store/schema/cleo-global/skills.d.ts +2 -2
- package/dist/store/schema/cleo-project/lifecycle.d.ts +2 -2
- package/dist/store/schema/cleo-project/runtime.d.ts +1 -1
- package/dist/store/schema/cleo-project/tasks-core.d.ts +1 -1
- package/dist/store/schema/lifecycle.d.ts +2 -2
- package/dist/store/schema/skills-schema.d.ts +2 -2
- package/dist/store/schema/tasks.d.ts +1 -1
- package/dist/store/session-store.d.ts +3 -1
- package/dist/store/session-store.d.ts.map +1 -1
- package/dist/store/session-store.js +252 -207
- package/dist/store/session-store.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts +39 -4
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +689 -527
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/tasks-sqlite.d.ts +3 -1
- package/dist/store/tasks-sqlite.d.ts.map +1 -1
- package/dist/store/tasks-sqlite.js +309 -279
- package/dist/store/tasks-sqlite.js.map +1 -1
- package/dist/store/validation-schemas.d.ts +8 -8
- package/dist/store/writer-lease.d.ts +80 -8
- package/dist/store/writer-lease.d.ts.map +1 -1
- package/dist/store/writer-lease.js +503 -134
- package/dist/store/writer-lease.js.map +1 -1
- package/dist/system/audit.d.ts +2 -1
- package/dist/system/audit.d.ts.map +1 -1
- package/dist/system/audit.js +118 -71
- package/dist/system/audit.js.map +1 -1
- package/dist/system/backup.d.ts.map +1 -1
- package/dist/system/backup.js +5 -5
- package/dist/system/backup.js.map +1 -1
- package/dist/system/inject-generate.js +1 -1
- package/dist/task-work/index.d.ts +3 -0
- package/dist/task-work/index.d.ts.map +1 -1
- package/dist/task-work/index.js +34 -37
- package/dist/task-work/index.js.map +1 -1
- package/dist/tasks/ac-coverage-gate.d.ts.map +1 -1
- package/dist/tasks/ac-coverage-gate.js +4 -0
- package/dist/tasks/ac-coverage-gate.js.map +1 -1
- package/dist/tasks/ac-immutability.d.ts +7 -4
- package/dist/tasks/ac-immutability.d.ts.map +1 -1
- package/dist/tasks/ac-immutability.js +19 -17
- package/dist/tasks/ac-immutability.js.map +1 -1
- package/dist/tasks/ac-table.d.ts +5 -5
- package/dist/tasks/ac-table.d.ts.map +1 -1
- package/dist/tasks/ac-table.js +26 -12
- package/dist/tasks/ac-table.js.map +1 -1
- package/dist/tasks/acceptance-input.d.ts +52 -0
- package/dist/tasks/acceptance-input.d.ts.map +1 -0
- package/dist/tasks/acceptance-input.js +259 -0
- package/dist/tasks/acceptance-input.js.map +1 -0
- package/dist/tasks/add.d.ts +67 -29
- package/dist/tasks/add.d.ts.map +1 -1
- package/dist/tasks/add.js +255 -97
- package/dist/tasks/add.js.map +1 -1
- package/dist/tasks/complete.d.ts +16 -1
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +152 -55
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/decompose.d.ts +103 -0
- package/dist/tasks/decompose.d.ts.map +1 -0
- package/dist/tasks/decompose.js +224 -0
- package/dist/tasks/decompose.js.map +1 -0
- package/dist/tasks/delete.d.ts +5 -8
- package/dist/tasks/delete.d.ts.map +1 -1
- package/dist/tasks/delete.js +4 -3
- package/dist/tasks/delete.js.map +1 -1
- package/dist/tasks/dependency-check.d.ts +59 -0
- package/dist/tasks/dependency-check.d.ts.map +1 -1
- package/dist/tasks/dependency-check.js +73 -0
- package/dist/tasks/dependency-check.js.map +1 -1
- package/dist/tasks/deps-ready.d.ts +13 -1
- package/dist/tasks/deps-ready.d.ts.map +1 -1
- package/dist/tasks/deps-ready.js +16 -5
- package/dist/tasks/deps-ready.js.map +1 -1
- package/dist/tasks/engine-converters.d.ts +7 -0
- package/dist/tasks/engine-converters.d.ts.map +1 -1
- package/dist/tasks/engine-converters.js +8 -1
- package/dist/tasks/engine-converters.js.map +1 -1
- package/dist/tasks/evidence.d.ts +88 -27
- package/dist/tasks/evidence.d.ts.map +1 -1
- package/dist/tasks/evidence.js +344 -43
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/find.d.ts +16 -12
- package/dist/tasks/find.d.ts.map +1 -1
- package/dist/tasks/find.js +107 -93
- package/dist/tasks/find.js.map +1 -1
- package/dist/tasks/gate-preview.d.ts +73 -0
- package/dist/tasks/gate-preview.d.ts.map +1 -0
- package/dist/tasks/gate-preview.js +119 -0
- package/dist/tasks/gate-preview.js.map +1 -0
- package/dist/tasks/gate-runner.d.ts +88 -14
- package/dist/tasks/gate-runner.d.ts.map +1 -1
- package/dist/tasks/gate-runner.js +719 -250
- package/dist/tasks/gate-runner.js.map +1 -1
- package/dist/tasks/hierarchy-policy.d.ts +8 -0
- package/dist/tasks/hierarchy-policy.d.ts.map +1 -1
- package/dist/tasks/hierarchy-policy.js +9 -2
- package/dist/tasks/hierarchy-policy.js.map +1 -1
- package/dist/tasks/hierarchy.d.ts +67 -1
- package/dist/tasks/hierarchy.d.ts.map +1 -1
- package/dist/tasks/hierarchy.js +81 -1
- package/dist/tasks/hierarchy.js.map +1 -1
- package/dist/tasks/index.d.ts +3 -0
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/index.js +3 -0
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/infer-add-params.d.ts +1 -20
- package/dist/tasks/infer-add-params.d.ts.map +1 -1
- package/dist/tasks/infer-add-params.js +2 -203
- package/dist/tasks/infer-add-params.js.map +1 -1
- package/dist/tasks/list.d.ts +7 -2
- package/dist/tasks/list.d.ts.map +1 -1
- package/dist/tasks/list.js +24 -36
- package/dist/tasks/list.js.map +1 -1
- package/dist/tasks/ops.d.ts +6 -61
- package/dist/tasks/ops.d.ts.map +1 -1
- package/dist/tasks/ops.js +5 -53
- package/dist/tasks/ops.js.map +1 -1
- package/dist/tasks/plan.d.ts +15 -1
- package/dist/tasks/plan.d.ts.map +1 -1
- package/dist/tasks/plan.js +23 -25
- package/dist/tasks/plan.js.map +1 -1
- package/dist/tasks/population.d.ts +46 -0
- package/dist/tasks/population.d.ts.map +1 -0
- package/dist/tasks/population.js +88 -0
- package/dist/tasks/population.js.map +1 -0
- package/dist/tasks/reconcile-scope.d.ts +157 -0
- package/dist/tasks/reconcile-scope.d.ts.map +1 -0
- package/dist/tasks/reconcile-scope.js +242 -0
- package/dist/tasks/reconcile-scope.js.map +1 -0
- package/dist/tasks/req.d.ts +51 -12
- package/dist/tasks/req.d.ts.map +1 -1
- package/dist/tasks/req.js +125 -69
- package/dist/tasks/req.js.map +1 -1
- package/dist/tasks/session-scope.d.ts +6 -31
- package/dist/tasks/session-scope.d.ts.map +1 -1
- package/dist/tasks/session-scope.js +3 -17
- package/dist/tasks/session-scope.js.map +1 -1
- package/dist/tasks/severity-attestation.d.ts +39 -10
- package/dist/tasks/severity-attestation.d.ts.map +1 -1
- package/dist/tasks/severity-attestation.js +75 -36
- package/dist/tasks/severity-attestation.js.map +1 -1
- package/dist/tasks/task-next.d.ts +5 -0
- package/dist/tasks/task-next.d.ts.map +1 -1
- package/dist/tasks/task-next.js +10 -9
- package/dist/tasks/task-next.js.map +1 -1
- package/dist/tasks/task-reparent.d.ts.map +1 -1
- package/dist/tasks/task-reparent.js +3 -13
- package/dist/tasks/task-reparent.js.map +1 -1
- package/dist/tasks/update.d.ts +20 -43
- package/dist/tasks/update.d.ts.map +1 -1
- package/dist/tasks/update.js +64 -49
- package/dist/tasks/update.js.map +1 -1
- package/dist/validation/engine-ops.d.ts +17 -1
- package/dist/validation/engine-ops.d.ts.map +1 -1
- package/dist/validation/engine-ops.js +149 -11
- package/dist/validation/engine-ops.js.map +1 -1
- package/dist/workgraph/reparent-preflight.d.ts +1 -1
- package/dist/workgraph/reparent-preflight.d.ts.map +1 -1
- package/dist/workgraph/reparent-preflight.js +6 -1
- package/dist/workgraph/reparent-preflight.js.map +1 -1
- package/dist/workgraph/scaffold-apply.d.ts.map +1 -1
- package/dist/workgraph/scaffold-apply.js +81 -76
- package/dist/workgraph/scaffold-apply.js.map +1 -1
- package/dist/workgraph/structure-validation.d.ts +1 -1
- package/dist/workgraph/structure-validation.d.ts.map +1 -1
- package/dist/workgraph/structure-validation.js +6 -1
- package/dist/workgraph/structure-validation.js.map +1 -1
- package/migrations/drizzle-tasks/20260919180000_t12263-job-ownership-fences/migration.sql +34 -0
- package/migrations/drizzle-tasks/20260919184500_t12265-durable-pending-proposals/migration.sql +4 -0
- package/package.json +18 -13
- package/schemas/config.schema.json +2 -2
- package/schemas/project-context.schema.json +12 -0
- package/templates/CLEO-INJECTION.md +114 -101
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency-leaf project scope, root discovery and identity decoding.
|
|
3
|
+
*
|
|
4
|
+
* The public paths and project-info modules re-export or delegate here so store
|
|
5
|
+
* ownership can reuse the same policy without importing store-aware routing.
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
9
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
10
|
+
import { readFile } from 'node:fs/promises';
|
|
11
|
+
import { homedir } from 'node:os';
|
|
12
|
+
import { dirname, join, resolve } from 'node:path';
|
|
13
|
+
import { ExitCode } from '@cleocode/contracts';
|
|
14
|
+
import { isAbsolutePath } from '@cleocode/paths';
|
|
15
|
+
import { CleoError } from './errors.js';
|
|
16
|
+
import { generateProjectHash } from './nexus/hash.js';
|
|
17
|
+
/**
|
|
18
|
+
* AsyncLocalStorage instance that carries the active {@link WorktreeScope}
|
|
19
|
+
* for the current async execution context.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Set by the spawn adapter (or any caller that wants to redirect CLEO path
|
|
23
|
+
* resolution to a worktree directory) before invoking subagent logic.
|
|
24
|
+
* `getProjectRoot()` checks this store BEFORE the `CLEO_ROOT` env-var and
|
|
25
|
+
* ancestor-walk, so scoped callers transparently receive the worktree root.
|
|
26
|
+
*
|
|
27
|
+
* Callers outside a worktree context receive `undefined` from
|
|
28
|
+
* `worktreeScope.getStore()` and fall through to the existing resolution
|
|
29
|
+
* order unchanged.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { worktreeScope } from '@cleocode/core/paths';
|
|
34
|
+
*
|
|
35
|
+
* worktreeScope.run(
|
|
36
|
+
* { worktreeRoot: '/path/to/worktree', projectHash: 'abc123' },
|
|
37
|
+
* async () => {
|
|
38
|
+
* const root = getProjectRoot(); // returns '/path/to/worktree'
|
|
39
|
+
* }
|
|
40
|
+
* );
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @task T380
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export const worktreeScope = new AsyncLocalStorage();
|
|
47
|
+
/**
|
|
48
|
+
* Capture explicit project ownership and compatible operation authority before awaiting.
|
|
49
|
+
* @param projectRoot - Requested project root, resolved independently of ambient pins.
|
|
50
|
+
* @param inherited - Caller scope captured at the same synchronous boundary.
|
|
51
|
+
* @returns Immutable scope retaining the original execution context and canonical path hash.
|
|
52
|
+
* @throws Error if execution is inactive or its project root or persisted identity differs.
|
|
53
|
+
* @remarks A portable project ID is compared only with persisted identity, never
|
|
54
|
+
* with the path hash used by worktree routing. Ambient environment pins are unchanged.
|
|
55
|
+
* Existing task-accessor error messages are retained for compatibility.
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const scope = captureProjectScope(projectRoot, worktreeScope.getStore());
|
|
59
|
+
* await worktreeScope.run(scope, () => performProjectOperation());
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function captureProjectScope(projectRoot, inherited) {
|
|
63
|
+
const root = resolve(projectRoot);
|
|
64
|
+
const execution = inherited?.execution;
|
|
65
|
+
execution?.assertActive();
|
|
66
|
+
if (execution && resolve(execution.identity.projectRoot) !== root)
|
|
67
|
+
throw new Error('Task accessor project differs from captured execution ownership.');
|
|
68
|
+
const scope = Object.freeze({
|
|
69
|
+
...inherited,
|
|
70
|
+
worktreeRoot: root,
|
|
71
|
+
projectHash: generateProjectHash(root),
|
|
72
|
+
});
|
|
73
|
+
if (execution) {
|
|
74
|
+
const info = readProjectInfoAtDirectorySync(root, join(root, '.cleo'));
|
|
75
|
+
if ((info.projectId || info.projectHash) !== execution.identity.projectId)
|
|
76
|
+
throw new Error('Task accessor identity differs from captured execution ownership.');
|
|
77
|
+
}
|
|
78
|
+
return scope;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Attempt to resolve the main git repo root from a gitlink (.git as FILE).
|
|
82
|
+
* Returns the main repo path if the gitlink is valid and the main repo is a
|
|
83
|
+
* CLEO project; otherwise returns `null`.
|
|
84
|
+
*
|
|
85
|
+
* @param gitlinkDir - Directory containing the candidate Git link.
|
|
86
|
+
* @returns Validated main repository root, or null when unavailable.
|
|
87
|
+
* @internal
|
|
88
|
+
* @task T11034
|
|
89
|
+
*/
|
|
90
|
+
export function _resolveMainRepoFromGitlink(gitlinkDir) {
|
|
91
|
+
try {
|
|
92
|
+
const gitLinkPath = join(gitlinkDir, '.git');
|
|
93
|
+
if (!existsSync(gitLinkPath))
|
|
94
|
+
return null;
|
|
95
|
+
const stat = statSync(gitLinkPath);
|
|
96
|
+
if (!stat.isFile())
|
|
97
|
+
return null;
|
|
98
|
+
const gitLinkContent = readFileSync(gitLinkPath, 'utf-8').trim();
|
|
99
|
+
const match = gitLinkContent.match(/^gitdir:\s*(.+)$/m);
|
|
100
|
+
if (!match)
|
|
101
|
+
return null;
|
|
102
|
+
const gitdir = match[1].trim();
|
|
103
|
+
// gitdir is `<main>/.git/worktrees/<name>` → strip last 3 segments.
|
|
104
|
+
const mainRepo = dirname(dirname(dirname(gitdir)));
|
|
105
|
+
if (existsSync(join(mainRepo, '.cleo')) && validateProjectRoot(mainRepo)) {
|
|
106
|
+
return mainRepo;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// Parse error — not a valid gitlink.
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Validate that a candidate project root directory is a legitimate CLEO
|
|
116
|
+
* project root and not a stray parent `.cleo/` directory that happened to
|
|
117
|
+
* be found by the walk-up algorithm.
|
|
118
|
+
*
|
|
119
|
+
* ## Primary path (T1864 — project-info.json contract)
|
|
120
|
+
*
|
|
121
|
+
* A candidate is **accepted** when `.cleo/project-info.json` exists and
|
|
122
|
+
* parses as JSON with a non-empty `projectId` string field. This is the
|
|
123
|
+
* canonical form written by `cleo init` and is the only form that guarantees
|
|
124
|
+
* the directory is a proper CLEO project rather than a stray `.cleo/` left by
|
|
125
|
+
* an old installation or a git worktree that auto-created its own `.cleo/`.
|
|
126
|
+
*
|
|
127
|
+
* ## Legacy fallback (backwards-compatibility)
|
|
128
|
+
*
|
|
129
|
+
* Projects initialized before `project-info.json` was introduced are still
|
|
130
|
+
* accepted when **both** of the following are true:
|
|
131
|
+
* 1. `.cleo/` exists in `candidate`
|
|
132
|
+
* 2. `.git/` exists as a sibling of `.cleo/` in `candidate`
|
|
133
|
+
*
|
|
134
|
+
* A one-time stderr warning is emitted (guarded by `_legacyFallbackWarned`)
|
|
135
|
+
* so operators know to re-run `cleo init` to upgrade the project metadata.
|
|
136
|
+
*
|
|
137
|
+
* **Breaking change vs. prior implementation**: bare `package.json` alone is
|
|
138
|
+
* no longer sufficient. The old check `existsSync(gitDir) || existsSync(pkgJson)`
|
|
139
|
+
* accepted any Node.js package directory as a valid project root, which caused
|
|
140
|
+
* the monorepo-package bug where sub-packages inside `packages/` created their
|
|
141
|
+
* own empty `.cleo/` databases.
|
|
142
|
+
*
|
|
143
|
+
* @param candidate - Absolute path to the directory being considered as the
|
|
144
|
+
* project root (parent of the `.cleo/` directory).
|
|
145
|
+
* @returns `true` when the candidate is a recognised CLEO project root.
|
|
146
|
+
* @remarks This validates existing markers without creating directories or opening
|
|
147
|
+
* stores. Git-link worktrees resolve through their parent instead of becoming roots.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* // Project root with project-info.json — valid (primary path)
|
|
152
|
+
* validateProjectRoot('/home/user/myproject'); // true
|
|
153
|
+
*
|
|
154
|
+
* // Legacy project root with .git/ but no project-info.json — valid + warning
|
|
155
|
+
* validateProjectRoot('/home/user/legacy-project'); // true (+ stderr warning)
|
|
156
|
+
*
|
|
157
|
+
* // Stray .cleo in home dir with no markers — invalid
|
|
158
|
+
* validateProjectRoot('/home/user'); // false
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @task T1463
|
|
162
|
+
* @task T1864
|
|
163
|
+
*/
|
|
164
|
+
export function validateProjectRoot(candidate) {
|
|
165
|
+
const cleoDir = join(candidate, '.cleo');
|
|
166
|
+
if (!existsSync(cleoDir)) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
// Primary: .cleo/project-info.json with a valid projectId string.
|
|
170
|
+
// T11034 — Worktree guard: a worktree has .git as a gitlink FILE, not a
|
|
171
|
+
// directory. project-info.json is copied into worktrees for identity
|
|
172
|
+
// inheritance (T11033), but worktrees must NOT be treated as standalone
|
|
173
|
+
// project roots — path resolution must walk past them to the parent project.
|
|
174
|
+
const projectInfoPath = join(cleoDir, 'project-info.json');
|
|
175
|
+
if (existsSync(projectInfoPath)) {
|
|
176
|
+
try {
|
|
177
|
+
const raw = readFileSync(projectInfoPath, 'utf-8');
|
|
178
|
+
const parsed = JSON.parse(raw);
|
|
179
|
+
if (typeof parsed === 'object' &&
|
|
180
|
+
parsed !== null &&
|
|
181
|
+
'projectId' in parsed &&
|
|
182
|
+
typeof parsed['projectId'] === 'string' &&
|
|
183
|
+
parsed['projectId'] !== '') {
|
|
184
|
+
// T11034: Reject worktrees — .git is a gitlink FILE, not a directory.
|
|
185
|
+
// Workers should resolve through to the parent project root.
|
|
186
|
+
const gitMarker = join(candidate, '.git');
|
|
187
|
+
if (existsSync(gitMarker)) {
|
|
188
|
+
try {
|
|
189
|
+
if (!statSync(gitMarker).isDirectory()) {
|
|
190
|
+
// Gitlink file (worktree) — NOT a project root.
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
// Stat failed — treat as non-directory (reject).
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// JSON parse error or read error — fall through to legacy check.
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// Legacy fallback: .cleo/ + .git/ sibling (no project-info.json required).
|
|
207
|
+
// Emits a one-time warning to prompt the operator to run `cleo init`.
|
|
208
|
+
//
|
|
209
|
+
// CRITICAL (T9092): a git worktree has `.git` as a *file* (a "gitlink" pointing
|
|
210
|
+
// back to the main repo's .git/worktrees/<name> directory), NOT a directory.
|
|
211
|
+
// Accepting such candidates as project roots recreates the 2026-05-04 dead-end-DB
|
|
212
|
+
// disaster pattern: workers spawned in a worktree create rogue `.cleo/tasks.db`
|
|
213
|
+
// files isolated from the real project database. The legacy fallback MUST only
|
|
214
|
+
// accept candidates where `.git` is a true directory (a real repo root).
|
|
215
|
+
const gitDir = join(candidate, '.git');
|
|
216
|
+
if (existsSync(gitDir)) {
|
|
217
|
+
let isRealGitDir = false;
|
|
218
|
+
try {
|
|
219
|
+
const stat = statSync(gitDir);
|
|
220
|
+
isRealGitDir = stat.isDirectory();
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
isRealGitDir = false;
|
|
224
|
+
}
|
|
225
|
+
if (!isRealGitDir) {
|
|
226
|
+
// .git is a gitlink file (worktree marker) — NOT a project root.
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
if (!_legacyFallbackWarned) {
|
|
230
|
+
_legacyFallbackWarned = true;
|
|
231
|
+
// T9774: debug-only — surfaced via CLEO_DEBUG to keep stderr clean by default.
|
|
232
|
+
// Cannot use pushWarning here because paths.ts is in the import chain of
|
|
233
|
+
// output.ts (output → sessions/context-alert → paths) — circular dep.
|
|
234
|
+
if (process.env['CLEO_DEBUG']) {
|
|
235
|
+
process.stderr.write(`[cleo][debug] W_PATH_RESOLUTION: ${candidate}/.cleo/ lacks project-info.json. ` +
|
|
236
|
+
`Run \`cleo init\` to upgrade project metadata (T1864 legacy-fallback).\n`);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Get the project root by walking ancestor directories for `.cleo/` or `.git/`.
|
|
245
|
+
*
|
|
246
|
+
* Stops at the **first** ancestor directory that contains either sentinel
|
|
247
|
+
* directory and never drifts past it — even when multiple nested projects
|
|
248
|
+
* exist above the starting directory.
|
|
249
|
+
*
|
|
250
|
+
* Resolution order:
|
|
251
|
+
* 1. `CLEO_ROOT` env var — bypasses walk entirely (CI / test override)
|
|
252
|
+
* 2. `CLEO_DIR` env var (absolute path only) — derives project root from dirname
|
|
253
|
+
* 3. Walk ancestors from `cwd` (or `process.cwd()`) toward filesystem root:
|
|
254
|
+
* - `.cleo/` found with a sibling `.git/` or `package.json` → accept as root
|
|
255
|
+
* - `.cleo/` found but **no** sibling marker → skip (stray/parent `.cleo/`)
|
|
256
|
+
* - `.git/` found (without `.cleo/` sibling) → throw `E_NOT_INITIALIZED`
|
|
257
|
+
* 4. Filesystem root reached without a valid root → throw `E_INVALID_PROJECT_ROOT`
|
|
258
|
+
* (if at least one `.cleo/` was skipped) or `E_NO_PROJECT` (none found)
|
|
259
|
+
*
|
|
260
|
+
* @param cwd - Optional starting directory; defaults to `process.cwd()`
|
|
261
|
+
* @returns Absolute path to the project root directory (parent of `.cleo/`)
|
|
262
|
+
* @throws {CleoError} `ExitCode.CONFIG_ERROR` (`E_NOT_INITIALIZED`) when a
|
|
263
|
+
* `.git/` is found but no `.cleo/` is present at that level.
|
|
264
|
+
* @throws {CleoError} `ExitCode.CONFIG_ERROR` (`E_INVALID_PROJECT_ROOT`) when
|
|
265
|
+
* one or more `.cleo/` directories are found but none have the required sibling
|
|
266
|
+
* markers (`.git/` or `package.json`). This prevents accidental operations on
|
|
267
|
+
* the wrong project when a stray parent `.cleo/` exists higher in the filesystem.
|
|
268
|
+
* @throws {CleoError} `ExitCode.NOT_FOUND` (`E_NO_PROJECT`) when neither
|
|
269
|
+
* sentinel is found in any ancestor.
|
|
270
|
+
*
|
|
271
|
+
* @remarks
|
|
272
|
+
* `CLEO_ROOT` is an absolute-path escape hatch for environments where the
|
|
273
|
+
* working directory is unrelated to the project (CI tmpdirs, monorepo scripts,
|
|
274
|
+
* test harnesses). When set it is returned as-is without scanning ancestors.
|
|
275
|
+
*
|
|
276
|
+
* `CLEO_DIR` set to an absolute path (e.g. `/project/.cleo`) also bypasses
|
|
277
|
+
* the walk: the project root is derived as its `dirname`. This preserves
|
|
278
|
+
* backward compatibility for test harnesses that use `CLEO_DIR` to pin the
|
|
279
|
+
* project root.
|
|
280
|
+
*
|
|
281
|
+
* NEVER auto-creates `.cleo/`. Project initialisation is an explicit opt-in
|
|
282
|
+
* via `cleo init`.
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```typescript
|
|
286
|
+
* // Running from packages/core inside the monorepo:
|
|
287
|
+
* const root = getProjectRoot(); // "/mnt/projects/cleocode"
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
export function getProjectRoot(cwd) {
|
|
291
|
+
// 0. AsyncLocalStorage worktree scope (T380/ADR-041 §D3) — checked FIRST.
|
|
292
|
+
// When a spawn adapter wraps execution in worktreeScope.run(...), the
|
|
293
|
+
// scoped root wins over all env-var and walk-based resolution.
|
|
294
|
+
const scope = worktreeScope.getStore();
|
|
295
|
+
if (scope !== undefined) {
|
|
296
|
+
return scope.worktreeRoot;
|
|
297
|
+
}
|
|
298
|
+
// 1. Honour CLEO_ROOT / CLEO_PROJECT_ROOT env var — bypass walk entirely.
|
|
299
|
+
// CLEO_PROJECT_ROOT is the agent-friendly alias (T090).
|
|
300
|
+
const envRoot = process.env['CLEO_ROOT'] ?? process.env['CLEO_PROJECT_ROOT'];
|
|
301
|
+
if (envRoot) {
|
|
302
|
+
return envRoot;
|
|
303
|
+
}
|
|
304
|
+
// 2. If CLEO_DIR is an absolute path, derive the project root from it.
|
|
305
|
+
// This preserves backward compatibility for test harnesses that set
|
|
306
|
+
// CLEO_DIR=/some/absolute/path/.cleo to pin the project root.
|
|
307
|
+
const cleoDirEnv = process.env['CLEO_DIR'];
|
|
308
|
+
if (cleoDirEnv && isAbsolutePath(cleoDirEnv)) {
|
|
309
|
+
if (cleoDirEnv.endsWith('/.cleo') || cleoDirEnv.endsWith('\\.cleo')) {
|
|
310
|
+
return dirname(cleoDirEnv);
|
|
311
|
+
}
|
|
312
|
+
return cleoDirEnv;
|
|
313
|
+
}
|
|
314
|
+
// This is the bottom of the resolution chain: the line lives INSIDE
|
|
315
|
+
// getProjectRoot, and resolveOrCwd() delegates to getProjectRoot(), so using
|
|
316
|
+
// the sanctioned helper here would recurse forever.
|
|
317
|
+
const start = resolve(cwd ?? process.cwd()); // CWD-OK: base case of getProjectRoot itself
|
|
318
|
+
let current = start;
|
|
319
|
+
// 2.5. T9092 + T11034: if `start` is inside a git worktree (i.e. has `.git` as a
|
|
320
|
+
// gitlink FILE pointing to `<mainrepo>/.git/worktrees/<name>`), the
|
|
321
|
+
// canonical project root is the MAIN repo, not the worktree dir.
|
|
322
|
+
// Delegates to the shared _resolveMainRepoFromGitlink helper which
|
|
323
|
+
// provides deterministic resolution from any worktree path.
|
|
324
|
+
const mainRepoFromStart = _resolveMainRepoFromGitlink(start);
|
|
325
|
+
if (mainRepoFromStart !== null)
|
|
326
|
+
return mainRepoFromStart;
|
|
327
|
+
// T889/T909 guard: snapshot $HOME and filesystem root sentinels.
|
|
328
|
+
//
|
|
329
|
+
// Historical bug: when `cleo` ran with `cwd=$HOME` and a stray
|
|
330
|
+
// `~/.cleo/` existed (from a prior buggy run or user mistake), the
|
|
331
|
+
// walk-up returned `$HOME` as the project root. This silently created
|
|
332
|
+
// `~/.cleo/conduit.db`, `~/.cleo/tasks.db`, etc. — diverging from the
|
|
333
|
+
// real project DBs and losing data on branch switch. See ADR-037
|
|
334
|
+
// (conduit.db is project-tier-only) and the orphan-conduit remediation.
|
|
335
|
+
//
|
|
336
|
+
// Contract: `getProjectRoot` MUST NEVER resolve to `$HOME` or `/`.
|
|
337
|
+
// If the walk would land there, treat it as "no project" rather than
|
|
338
|
+
// silently accepting a pathological root. Users who legitimately want
|
|
339
|
+
// `$HOME` as a project root must set `CLEO_ROOT=$HOME` explicitly — the
|
|
340
|
+
// env-var path above bypasses this guard, making the opt-in explicit.
|
|
341
|
+
const homeRoot = homedir();
|
|
342
|
+
// T1463/P1-7: track if we skipped any .cleo/ dirs that failed validation.
|
|
343
|
+
// Used to produce a more informative error message when every candidate
|
|
344
|
+
// was rejected by validateProjectRoot.
|
|
345
|
+
const skippedCleoDirs = [];
|
|
346
|
+
// 3. Walk ancestors toward filesystem root
|
|
347
|
+
while (true) {
|
|
348
|
+
const cleoDir = join(current, '.cleo');
|
|
349
|
+
const gitDir = join(current, '.git');
|
|
350
|
+
// T889/T909: refuse to accept $HOME or / as a project root, even if a
|
|
351
|
+
// `.cleo/` sentinel exists there. This blocks the orphan-DB vector.
|
|
352
|
+
const isDangerousRoot = current === homeRoot || current === '/' || current === '';
|
|
353
|
+
if (existsSync(cleoDir) && !isDangerousRoot) {
|
|
354
|
+
// T1463/P1-7: validate that the .cleo/ dir has the required sibling
|
|
355
|
+
// markers (.git/ or package.json) before accepting this candidate.
|
|
356
|
+
//
|
|
357
|
+
// T9092: previously the start-directory short-circuit was unconditional —
|
|
358
|
+
// `current === start` returned the candidate without running
|
|
359
|
+
// validateProjectRoot. That allowed a worktree (whose `.git` is a gitlink
|
|
360
|
+
// FILE not a directory) to be accepted as a project root if any process
|
|
361
|
+
// had previously created a stray `.cleo/` inside it. validateProjectRoot
|
|
362
|
+
// now rejects gitlink-only candidates, so we must run it on the start dir
|
|
363
|
+
// too — but only as a *gate* to walk up further, not to reject outright.
|
|
364
|
+
// If start dir validation fails, we continue walking to find the real
|
|
365
|
+
// project root (the main repo).
|
|
366
|
+
if (validateProjectRoot(current)) {
|
|
367
|
+
// Valid project root.
|
|
368
|
+
return current;
|
|
369
|
+
}
|
|
370
|
+
// Stray/rogue .cleo/ found (e.g. worktree with gitlink, or .cleo without
|
|
371
|
+
// project-info.json AND without a real .git/ sibling) — skip it and
|
|
372
|
+
// continue walking up for the canonical project root.
|
|
373
|
+
skippedCleoDirs.push(current);
|
|
374
|
+
}
|
|
375
|
+
if (existsSync(gitDir) && !isDangerousRoot) {
|
|
376
|
+
// T9092: only treat .git as a "real repo root" boundary when it is a
|
|
377
|
+
// DIRECTORY. A gitlink FILE (worktree marker) does not anchor a project
|
|
378
|
+
// root — keep walking up to find the canonical main repo.
|
|
379
|
+
let isRealGitDir = false;
|
|
380
|
+
try {
|
|
381
|
+
isRealGitDir = statSync(gitDir).isDirectory();
|
|
382
|
+
}
|
|
383
|
+
catch {
|
|
384
|
+
isRealGitDir = false;
|
|
385
|
+
}
|
|
386
|
+
if (isRealGitDir) {
|
|
387
|
+
// Real .git/ found but no .cleo/ sibling — not initialised
|
|
388
|
+
throw new CleoError(ExitCode.CONFIG_ERROR, `Run cleo init at ${current}`, {
|
|
389
|
+
fix: `cd ${current} && cleo init`,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
// gitlink file — attempt to resolve the main repo from it (T11034).
|
|
393
|
+
// When a worktree lives under ~/.local/share/cleo/worktrees/... and the
|
|
394
|
+
// caller is in a subdirectory (not the worktree root), the start-level
|
|
395
|
+
// gitlink check misses it. During the walk we must resolve gitlinks
|
|
396
|
+
// to ensure deterministic resolution from any worktree path.
|
|
397
|
+
const mainRepoFromWalk = _resolveMainRepoFromGitlink(current);
|
|
398
|
+
if (mainRepoFromWalk !== null)
|
|
399
|
+
return mainRepoFromWalk;
|
|
400
|
+
// gitlink we couldn't resolve — keep walking up.
|
|
401
|
+
}
|
|
402
|
+
// Move up one level
|
|
403
|
+
const parent = dirname(current);
|
|
404
|
+
if (parent === current) {
|
|
405
|
+
// Reached filesystem root without finding either sentinel
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
current = parent;
|
|
409
|
+
}
|
|
410
|
+
// 4a. At least one .cleo/ was found but all were rejected by validateProjectRoot.
|
|
411
|
+
// This is the "parent .cleo/ trap" scenario: a stray .cleo/ dir higher in
|
|
412
|
+
// the filesystem lacks a .git/ or package.json sibling, so it cannot be
|
|
413
|
+
// trusted as a project root.
|
|
414
|
+
if (skippedCleoDirs.length > 0) {
|
|
415
|
+
throw new CleoError(ExitCode.CONFIG_ERROR, `E_INVALID_PROJECT_ROOT: no .cleo with sibling .git found from ${start} (skipped: ${skippedCleoDirs.join(', ')})`, {
|
|
416
|
+
fix: `cleo init or add a .git directory alongside the .cleo dir`,
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
// 4b. No sentinel found in any ancestor
|
|
420
|
+
throw new CleoError(ExitCode.NOT_FOUND, 'Not inside a CLEO project. Run cleo init or cd to an existing project', {
|
|
421
|
+
fix: 'cleo init',
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Module-level flag: emit the legacy-fallback warning at most once per process.
|
|
426
|
+
* Prevents log spam when `validateProjectRoot` is called repeatedly in a session.
|
|
427
|
+
*/
|
|
428
|
+
let _legacyFallbackWarned = false;
|
|
429
|
+
/** Decode the existing project metadata contract at a caller-owned root. */
|
|
430
|
+
function decodeProjectInfo(raw, projectRoot) {
|
|
431
|
+
const data = JSON.parse(raw);
|
|
432
|
+
if (typeof data.projectHash !== 'string' || data.projectHash.length === 0) {
|
|
433
|
+
throw new Error('project-info.json missing required field: projectHash');
|
|
434
|
+
}
|
|
435
|
+
const segments = projectRoot.replace(/[\\/]+$/, '').split(/[\\/]/);
|
|
436
|
+
return {
|
|
437
|
+
projectHash: data.projectHash,
|
|
438
|
+
projectId: typeof data.projectId === 'string' ? data.projectId : '',
|
|
439
|
+
projectRoot,
|
|
440
|
+
projectName: segments[segments.length - 1] ?? 'unknown',
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Read metadata from a directory already resolved by the canonical path policy.
|
|
445
|
+
* @param projectRoot - Captured root used for the returned identity and name.
|
|
446
|
+
* @param cleoDir - Explicit data directory owned by that root.
|
|
447
|
+
* @returns Validated project information, retaining the legacy empty portable ID.
|
|
448
|
+
* @throws When reading, JSON decoding or required-field validation fails.
|
|
449
|
+
* @remarks This leaf does not resolve paths or consult ambient environment pins.
|
|
450
|
+
* @example
|
|
451
|
+
* ```ts
|
|
452
|
+
* const info = await readProjectInfoAtDirectory(root, join(root, '.cleo'));
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
455
|
+
export async function readProjectInfoAtDirectory(projectRoot, cleoDir) {
|
|
456
|
+
return decodeProjectInfo(await readFile(join(cleoDir, 'project-info.json'), 'utf-8'), projectRoot);
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Strict synchronous metadata read for captured operation ownership validation.
|
|
460
|
+
* @param projectRoot - Captured root used for the returned identity and name.
|
|
461
|
+
* @param cleoDir - Explicit data directory owned by that root.
|
|
462
|
+
* @returns Validated project information, retaining the legacy empty portable ID.
|
|
463
|
+
* @throws When reading, JSON decoding or required-field validation fails.
|
|
464
|
+
* @remarks Unlike the legacy public nullable wrapper, this preserves diagnostic failures.
|
|
465
|
+
* @example
|
|
466
|
+
* ```ts
|
|
467
|
+
* const info = readProjectInfoAtDirectorySync(root, join(root, '.cleo'));
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
export function readProjectInfoAtDirectorySync(projectRoot, cleoDir) {
|
|
471
|
+
return decodeProjectInfo(readFileSync(join(cleoDir, 'project-info.json'), 'utf-8'), projectRoot);
|
|
472
|
+
}
|
|
473
|
+
//# sourceMappingURL=project-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-scope.js","sourceRoot":"","sources":["../src/project-scope.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE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C,CAAC,CAAC,EAAE;QACnE,WAAW;QACX,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,SAAS;KACxD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,WAAmB,EACnB,OAAe;IAEf,OAAO,iBAAiB,CACtB,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,EAAE,OAAO,CAAC,EAC3D,WAAW,CACZ,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,8BAA8B,CAAC,WAAmB,EAAE,OAAe;IACjF,OAAO,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `pr:<number>` evidence-atom validator.
|
|
3
3
|
*
|
|
4
|
-
* Resolves
|
|
5
|
-
*
|
|
4
|
+
* Resolves merge identity, checks and changed-file provenance via the `gh`
|
|
5
|
+
* CLI. The task evidence service separately validates task scope and criteria;
|
|
6
|
+
* this resolver does not establish implementation, testing or review.
|
|
6
7
|
* Closes the release-verb dogfood gap (T9764): tasks that ship via the
|
|
7
8
|
* standard PR + admin-merge flow previously had no zero-friction way to record
|
|
8
9
|
* evidence retroactively —
|
|
@@ -55,10 +56,17 @@ export type PrAtomResolution = {
|
|
|
55
56
|
successCount: number;
|
|
56
57
|
totalChecks: number;
|
|
57
58
|
cacheHit: boolean;
|
|
59
|
+
/** PR title and body are historical assertions used for explicit task linkage. */
|
|
60
|
+
title: string;
|
|
61
|
+
body: string;
|
|
62
|
+
headRefName: string;
|
|
63
|
+
/** Complete changed-file inventory; count mismatch is reported by contextual validation. */
|
|
64
|
+
changedPaths: string[];
|
|
65
|
+
changedFileCount: number;
|
|
58
66
|
} | {
|
|
59
67
|
ok: false;
|
|
60
68
|
reason: string;
|
|
61
|
-
codeName: 'E_EVIDENCE_INVALID' | 'E_EVIDENCE_INSUFFICIENT' | 'E_EVIDENCE_TESTS_FAILED' | 'E_EVIDENCE_TOOL_FAILED';
|
|
69
|
+
codeName: 'E_EVIDENCE_INVALID' | 'E_EVIDENCE_INSUFFICIENT' | 'E_EVIDENCE_TESTS_FAILED' | 'E_EVIDENCE_TOOL_FAILED' | 'E_EVIDENCE_GIT_ROOT';
|
|
62
70
|
};
|
|
63
71
|
/**
|
|
64
72
|
* Filesystem location for the cached PR validation result.
|
|
@@ -75,14 +83,25 @@ export declare function prCacheEntryPath(projectRoot: string, prNumber: number):
|
|
|
75
83
|
* malformed JSON). Returning a payload that fails {@link ghPrViewSchema}
|
|
76
84
|
* also yields a `E_EVIDENCE_TOOL_FAILED` outcome.
|
|
77
85
|
*
|
|
86
|
+
* A failure MAY carry `E_EVIDENCE_GIT_ROOT` instead, which is not a tool
|
|
87
|
+
* failure at all: the working directory is not a git work tree, so `gh` could
|
|
88
|
+
* never have discovered the repository it was asked about (gh#1462).
|
|
89
|
+
*
|
|
78
90
|
* @task T9764
|
|
79
91
|
*/
|
|
80
|
-
export type FetchGhPrPayload = (prNumber: number, cwd: string
|
|
92
|
+
export type FetchGhPrPayload = (prNumber: number, cwd: string,
|
|
93
|
+
/**
|
|
94
|
+
* CLEO store root, for failure text only (T12308). Optional so existing
|
|
95
|
+
* injected fetchers — which never shell out and never report a layout
|
|
96
|
+
* failure — keep their two-parameter shape.
|
|
97
|
+
*/
|
|
98
|
+
storeRoot?: string) => Promise<{
|
|
81
99
|
ok: true;
|
|
82
100
|
payload: unknown;
|
|
83
101
|
} | {
|
|
84
102
|
ok: false;
|
|
85
103
|
reason: string;
|
|
104
|
+
codeName?: 'E_EVIDENCE_GIT_ROOT';
|
|
86
105
|
}>;
|
|
87
106
|
/**
|
|
88
107
|
* Default `gh pr view` invocation. Calls `gh pr view <num> --json
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr-evidence.d.ts","sourceRoot":"","sources":["../../src/release/pr-evidence.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pr-evidence.d.ts","sourceRoot":"","sources":["../../src/release/pr-evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAKH,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAQ1D;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GACxB;IACE,EAAE,EAAE,IAAI,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,4FAA4F;IAC5F,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,GACD;IACE,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EACJ,oBAAoB,GACpB,yBAAyB,GACzB,yBAAyB,GACzB,wBAAwB,GACxB,qBAAqB,CAAC;CAC3B,CAAC;AAMN;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9E;AA0ED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM;AACX;;;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