@cleocode/core 2026.9.19 → 2026.9.21
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/adapters/discovery.d.ts.map +1 -1
- package/dist/adapters/discovery.js +3 -10
- package/dist/adapters/discovery.js.map +1 -1
- package/dist/adrs/link-pipeline.js +2 -2
- package/dist/adrs/link-pipeline.js.map +1 -1
- package/dist/adrs/parse.js +3 -3
- package/dist/adrs/parse.js.map +1 -1
- package/dist/agents/invoke-meta-agent.d.ts.map +1 -1
- package/dist/agents/invoke-meta-agent.js +8 -4
- package/dist/agents/invoke-meta-agent.js.map +1 -1
- package/dist/bootstrap.d.ts +5 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +41 -21
- package/dist/bootstrap.js.map +1 -1
- package/dist/cloud/crypto.d.ts +47 -0
- package/dist/cloud/crypto.d.ts.map +1 -0
- package/dist/cloud/crypto.js +223 -0
- package/dist/cloud/crypto.js.map +1 -0
- package/dist/cloud/http.d.ts +52 -0
- package/dist/cloud/http.d.ts.map +1 -0
- package/dist/cloud/http.js +98 -0
- package/dist/cloud/http.js.map +1 -0
- package/dist/cloud/index.d.ts +19 -0
- package/dist/cloud/index.d.ts.map +1 -0
- package/dist/cloud/index.js +19 -0
- package/dist/cloud/index.js.map +1 -0
- package/dist/cloud/journal.d.ts +169 -0
- package/dist/cloud/journal.d.ts.map +1 -0
- package/dist/cloud/journal.js +428 -0
- package/dist/cloud/journal.js.map +1 -0
- package/dist/cloud/keys.d.ts +213 -0
- package/dist/cloud/keys.d.ts.map +1 -0
- package/dist/cloud/keys.js +362 -0
- package/dist/cloud/keys.js.map +1 -0
- package/dist/cloud/manifest-check.d.ts +36 -0
- package/dist/cloud/manifest-check.d.ts.map +1 -0
- package/dist/cloud/manifest-check.js +70 -0
- package/dist/cloud/manifest-check.js.map +1 -0
- package/dist/cloud/projects.d.ts +13 -0
- package/dist/cloud/projects.d.ts.map +1 -0
- package/dist/cloud/projects.js +11 -0
- package/dist/cloud/projects.js.map +1 -0
- package/dist/cloud/signing.d.ts +105 -0
- package/dist/cloud/signing.d.ts.map +1 -0
- package/dist/cloud/signing.js +117 -0
- package/dist/cloud/signing.js.map +1 -0
- package/dist/cloud/streams.d.ts +6 -0
- package/dist/cloud/streams.d.ts.map +1 -0
- package/dist/cloud/streams.js +5 -0
- package/dist/cloud/streams.js.map +1 -0
- package/dist/decide/audit.d.ts +131 -0
- package/dist/decide/audit.d.ts.map +1 -0
- package/dist/decide/audit.js +98 -0
- package/dist/decide/audit.js.map +1 -0
- package/dist/decide/budget.d.ts +91 -0
- package/dist/decide/budget.d.ts.map +1 -0
- package/dist/decide/budget.js +194 -0
- package/dist/decide/budget.js.map +1 -0
- package/dist/decide/cache.d.ts +49 -0
- package/dist/decide/cache.d.ts.map +1 -0
- package/dist/decide/cache.js +87 -0
- package/dist/decide/cache.js.map +1 -0
- package/dist/decide/client.d.ts +103 -0
- package/dist/decide/client.d.ts.map +1 -0
- package/dist/decide/client.js +262 -0
- package/dist/decide/client.js.map +1 -0
- package/dist/decide/credentials.d.ts +159 -0
- package/dist/decide/credentials.d.ts.map +1 -0
- package/dist/decide/credentials.js +383 -0
- package/dist/decide/credentials.js.map +1 -0
- package/dist/decide/index.d.ts +18 -0
- package/dist/decide/index.d.ts.map +1 -0
- package/dist/decide/index.js +18 -0
- package/dist/decide/index.js.map +1 -0
- package/dist/decide/jev-wire.d.ts +155 -0
- package/dist/decide/jev-wire.d.ts.map +1 -0
- package/dist/decide/jev-wire.js +420 -0
- package/dist/decide/jev-wire.js.map +1 -0
- package/dist/decide/operations.d.ts +152 -0
- package/dist/decide/operations.d.ts.map +1 -0
- package/dist/decide/operations.js +199 -0
- package/dist/decide/operations.js.map +1 -0
- package/dist/decide/provider.d.ts +90 -0
- package/dist/decide/provider.d.ts.map +1 -0
- package/dist/decide/provider.js +43 -0
- package/dist/decide/provider.js.map +1 -0
- package/dist/decide/site.d.ts +148 -0
- package/dist/decide/site.d.ts.map +1 -0
- package/dist/decide/site.js +181 -0
- package/dist/decide/site.js.map +1 -0
- package/dist/decide/transport.d.ts +67 -0
- package/dist/decide/transport.d.ts.map +1 -0
- package/dist/decide/transport.js +350 -0
- package/dist/decide/transport.js.map +1 -0
- package/dist/docs/export-document.js +5908 -2436
- package/dist/docs/export-document.js.map +3 -3
- package/dist/docs/index.d.ts +2 -2
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +1 -1
- package/dist/docs/index.js.map +1 -1
- package/dist/docs/projection.d.ts.map +1 -1
- package/dist/docs/projection.js +2 -3
- package/dist/docs/projection.js.map +1 -1
- package/dist/docs/publish-pr.d.ts +69 -1
- package/dist/docs/publish-pr.d.ts.map +1 -1
- package/dist/docs/publish-pr.js +112 -10
- package/dist/docs/publish-pr.js.map +1 -1
- package/dist/doctor/db-substrate.d.ts +13 -8
- package/dist/doctor/db-substrate.d.ts.map +1 -1
- package/dist/doctor/db-substrate.js +39 -26
- package/dist/doctor/db-substrate.js.map +1 -1
- package/dist/doctor/index.d.ts +2 -0
- package/dist/doctor/index.d.ts.map +1 -1
- package/dist/doctor/index.js +1 -0
- package/dist/doctor/index.js.map +1 -1
- package/dist/doctor/knowledge.d.ts.map +1 -1
- package/dist/doctor/knowledge.js +5 -15
- package/dist/doctor/knowledge.js.map +1 -1
- package/dist/doctor/nexus-schema-residency.d.ts +1 -1
- package/dist/doctor/nexus-schema-residency.d.ts.map +1 -1
- package/dist/doctor/nexus-schema-residency.js +3 -0
- package/dist/doctor/nexus-schema-residency.js.map +1 -1
- package/dist/doctor/project-identity.d.ts +44 -1
- package/dist/doctor/project-identity.d.ts.map +1 -1
- package/dist/doctor/project-identity.js +237 -10
- package/dist/doctor/project-identity.js.map +1 -1
- package/dist/doctor/projects.d.ts +170 -0
- package/dist/doctor/projects.d.ts.map +1 -0
- package/dist/doctor/projects.js +1075 -0
- package/dist/doctor/projects.js.map +1 -0
- package/dist/doctor/twin-collapse.d.ts +97 -0
- package/dist/doctor/twin-collapse.d.ts.map +1 -0
- package/dist/doctor/twin-collapse.js +168 -0
- package/dist/doctor/twin-collapse.js.map +1 -0
- package/dist/doctor/worktree-orphans.d.ts.map +1 -1
- package/dist/doctor/worktree-orphans.js +13 -29
- package/dist/doctor/worktree-orphans.js.map +1 -1
- package/dist/doctor/worktree-stores.d.ts +128 -0
- package/dist/doctor/worktree-stores.d.ts.map +1 -0
- package/dist/doctor/worktree-stores.js +374 -0
- package/dist/doctor/worktree-stores.js.map +1 -0
- package/dist/engine/engine-ops.d.ts.map +1 -1
- package/dist/engine/engine-ops.js +59 -23
- package/dist/engine/engine-ops.js.map +1 -1
- package/dist/error-catalog.d.ts.map +1 -1
- package/dist/error-catalog.js +21 -0
- package/dist/error-catalog.js.map +1 -1
- package/dist/error-registry.d.ts.map +1 -1
- package/dist/error-registry.js +40 -0
- package/dist/error-registry.js.map +1 -1
- package/dist/gc/cleanup.d.ts.map +1 -1
- package/dist/gc/cleanup.js +32 -19
- package/dist/gc/cleanup.js.map +1 -1
- package/dist/git/bounded-git.d.ts +170 -0
- package/dist/git/bounded-git.d.ts.map +1 -0
- package/dist/git/bounded-git.js +371 -0
- package/dist/git/bounded-git.js.map +1 -0
- package/dist/git/work-tree.d.ts +20 -0
- package/dist/git/work-tree.d.ts.map +1 -1
- package/dist/git/work-tree.js +20 -2
- package/dist/git/work-tree.js.map +1 -1
- package/dist/hooks/handlers/session-hooks.d.ts +11 -26
- package/dist/hooks/handlers/session-hooks.d.ts.map +1 -1
- package/dist/hooks/handlers/session-hooks.js +18 -47
- package/dist/hooks/handlers/session-hooks.js.map +1 -1
- package/dist/hooks/payload-schemas.d.ts +2 -2
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/init/engine-ops.d.ts.map +1 -1
- package/dist/init/engine-ops.js +23 -1
- package/dist/init/engine-ops.js.map +1 -1
- package/dist/init.d.ts +158 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +535 -44
- package/dist/init.js.map +1 -1
- package/dist/injection.d.ts +55 -0
- package/dist/injection.d.ts.map +1 -1
- package/dist/injection.js +102 -6
- package/dist/injection.js.map +1 -1
- package/dist/internal.d.ts +9 -5
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +8 -4
- package/dist/internal.js.map +1 -1
- package/dist/issue/diagnostics.d.ts.map +1 -1
- package/dist/issue/diagnostics.js +2 -1
- package/dist/issue/diagnostics.js.map +1 -1
- package/dist/lib/concurrency.d.ts +25 -0
- package/dist/lib/concurrency.d.ts.map +1 -0
- package/dist/lib/concurrency.js +43 -0
- package/dist/lib/concurrency.js.map +1 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lifecycle/engine-ops.d.ts.map +1 -1
- package/dist/lifecycle/engine-ops.js +4 -2
- package/dist/lifecycle/engine-ops.js.map +1 -1
- package/dist/lifecycle/stage-guidance.d.ts +5 -0
- package/dist/lifecycle/stage-guidance.d.ts.map +1 -1
- package/dist/lifecycle/stage-guidance.js +14 -4
- package/dist/lifecycle/stage-guidance.js.map +1 -1
- package/dist/llm/catalog-cache.d.ts +3 -2
- package/dist/llm/catalog-cache.d.ts.map +1 -1
- package/dist/llm/catalog-cache.js +5 -5
- package/dist/llm/catalog-cache.js.map +1 -1
- package/dist/llm/credentials.d.ts +4 -4
- package/dist/llm/credentials.js +6 -6
- package/dist/llm/credentials.js.map +1 -1
- package/dist/llm/plugin-facade.js +4312 -1798
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/llm/stable-device-id.d.ts.map +1 -1
- package/dist/llm/stable-device-id.js +3 -5
- package/dist/llm/stable-device-id.js.map +1 -1
- package/dist/memory/attention.d.ts.map +1 -1
- package/dist/memory/attention.js +30 -30
- package/dist/memory/attention.js.map +1 -1
- package/dist/memory/decision-contradiction.d.ts +152 -0
- package/dist/memory/decision-contradiction.d.ts.map +1 -0
- package/dist/memory/decision-contradiction.js +273 -0
- package/dist/memory/decision-contradiction.js.map +1 -0
- package/dist/memory/decisions.d.ts +42 -11
- package/dist/memory/decisions.d.ts.map +1 -1
- package/dist/memory/decisions.js +153 -56
- package/dist/memory/decisions.js.map +1 -1
- package/dist/memory/dialectic-evaluator.d.ts +7 -0
- package/dist/memory/dialectic-evaluator.d.ts.map +1 -1
- package/dist/memory/dialectic-evaluator.js +23 -8
- package/dist/memory/dialectic-evaluator.js.map +1 -1
- package/dist/memory/dispatch-trace-format.d.ts +39 -0
- package/dist/memory/dispatch-trace-format.d.ts.map +1 -0
- package/dist/memory/dispatch-trace-format.js +54 -0
- package/dist/memory/dispatch-trace-format.js.map +1 -0
- package/dist/memory/dispatch-trace.d.ts.map +1 -1
- package/dist/memory/dispatch-trace.js +1 -27
- package/dist/memory/dispatch-trace.js.map +1 -1
- 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 +1 -0
- package/dist/memory/engine-compat.js.map +1 -1
- package/dist/memory/import-from-provider.js +3 -3
- package/dist/memory/import-from-provider.js.map +1 -1
- package/dist/memory/learnings.d.ts +2 -2
- package/dist/memory/observation-type-decision.d.ts +96 -0
- package/dist/memory/observation-type-decision.d.ts.map +1 -0
- package/dist/memory/observation-type-decision.js +218 -0
- package/dist/memory/observation-type-decision.js.map +1 -0
- package/dist/memory/redaction.js +2 -0
- package/dist/memory/redaction.js.map +1 -1
- package/dist/memory/retrieval/build-retrieval-bundle.d.ts +9 -2
- package/dist/memory/retrieval/build-retrieval-bundle.d.ts.map +1 -1
- package/dist/memory/retrieval/build-retrieval-bundle.js +42 -11
- package/dist/memory/retrieval/build-retrieval-bundle.js.map +1 -1
- package/dist/memory/retrieval/get-current-session-id.d.ts +5 -0
- package/dist/memory/retrieval/get-current-session-id.d.ts.map +1 -1
- package/dist/memory/retrieval/get-current-session-id.js +7 -2
- package/dist/memory/retrieval/get-current-session-id.js.map +1 -1
- package/dist/memory/retrieval/observe.d.ts.map +1 -1
- package/dist/memory/retrieval/observe.js +30 -29
- package/dist/memory/retrieval/observe.js.map +1 -1
- package/dist/nexus/analyze-orchestrator.d.ts.map +1 -1
- package/dist/nexus/analyze-orchestrator.js +42 -29
- package/dist/nexus/analyze-orchestrator.js.map +1 -1
- package/dist/nexus/assessment-projection.d.ts +76 -0
- package/dist/nexus/assessment-projection.d.ts.map +1 -0
- package/dist/nexus/assessment-projection.js +143 -0
- package/dist/nexus/assessment-projection.js.map +1 -0
- package/dist/nexus/assessment-store.d.ts +14 -2
- package/dist/nexus/assessment-store.d.ts.map +1 -1
- package/dist/nexus/assessment-store.js +21 -3
- package/dist/nexus/assessment-store.js.map +1 -1
- package/dist/nexus/checkout-nonce.d.ts +48 -0
- package/dist/nexus/checkout-nonce.d.ts.map +1 -0
- package/dist/nexus/checkout-nonce.js +84 -0
- package/dist/nexus/checkout-nonce.js.map +1 -0
- package/dist/nexus/devices.d.ts +93 -0
- package/dist/nexus/devices.d.ts.map +1 -0
- package/dist/nexus/devices.js +141 -0
- package/dist/nexus/devices.js.map +1 -0
- package/dist/nexus/freshness.d.ts.map +1 -1
- package/dist/nexus/freshness.js +25 -6
- package/dist/nexus/freshness.js.map +1 -1
- package/dist/nexus/git-state.d.ts +225 -0
- package/dist/nexus/git-state.d.ts.map +1 -0
- package/dist/nexus/git-state.js +677 -0
- package/dist/nexus/git-state.js.map +1 -0
- package/dist/nexus/graph-manifest.d.ts +20 -4
- package/dist/nexus/graph-manifest.d.ts.map +1 -1
- package/dist/nexus/graph-manifest.js +40 -5
- package/dist/nexus/graph-manifest.js.map +1 -1
- package/dist/nexus/identity.d.ts +68 -23
- package/dist/nexus/identity.d.ts.map +1 -1
- package/dist/nexus/identity.js +99 -22
- package/dist/nexus/identity.js.map +1 -1
- package/dist/nexus/index.d.ts +5 -2
- package/dist/nexus/index.d.ts.map +1 -1
- package/dist/nexus/index.js +10 -4
- package/dist/nexus/index.js.map +1 -1
- package/dist/nexus/knowledge.d.ts +5 -0
- package/dist/nexus/knowledge.d.ts.map +1 -1
- package/dist/nexus/knowledge.js +26 -2
- package/dist/nexus/knowledge.js.map +1 -1
- package/dist/nexus/legacy-alias.d.ts +60 -0
- package/dist/nexus/legacy-alias.d.ts.map +1 -0
- package/dist/nexus/legacy-alias.js +68 -0
- package/dist/nexus/legacy-alias.js.map +1 -0
- package/dist/nexus/migrate-json-to-sqlite.js +2 -2
- package/dist/nexus/migrate-json-to-sqlite.js.map +1 -1
- package/dist/nexus/ops.d.ts +1 -0
- package/dist/nexus/ops.d.ts.map +1 -1
- package/dist/nexus/path-map.d.ts +264 -20
- package/dist/nexus/path-map.d.ts.map +1 -1
- package/dist/nexus/path-map.js +580 -44
- package/dist/nexus/path-map.js.map +1 -1
- package/dist/nexus/projects-clean.d.ts +9 -1
- package/dist/nexus/projects-clean.d.ts.map +1 -1
- package/dist/nexus/projects-clean.js +126 -14
- package/dist/nexus/projects-clean.js.map +1 -1
- package/dist/nexus/projects-scan.d.ts +56 -1
- package/dist/nexus/projects-scan.d.ts.map +1 -1
- package/dist/nexus/projects-scan.js +144 -3
- package/dist/nexus/projects-scan.js.map +1 -1
- package/dist/nexus/registry-hygiene.d.ts +18 -2
- package/dist/nexus/registry-hygiene.d.ts.map +1 -1
- package/dist/nexus/registry-hygiene.js +37 -11
- package/dist/nexus/registry-hygiene.js.map +1 -1
- package/dist/nexus/registry-roots.d.ts +47 -0
- package/dist/nexus/registry-roots.d.ts.map +1 -0
- package/dist/nexus/registry-roots.js +79 -0
- package/dist/nexus/registry-roots.js.map +1 -0
- package/dist/nexus/registry.d.ts +50 -9
- package/dist/nexus/registry.d.ts.map +1 -1
- package/dist/nexus/registry.js +311 -156
- package/dist/nexus/registry.js.map +1 -1
- package/dist/nexus/stored-roots.d.ts +106 -0
- package/dist/nexus/stored-roots.d.ts.map +1 -0
- package/dist/nexus/stored-roots.js +180 -0
- package/dist/nexus/stored-roots.js.map +1 -0
- package/dist/nexus/transfer.d.ts.map +1 -1
- package/dist/nexus/transfer.js +3 -0
- package/dist/nexus/transfer.js.map +1 -1
- package/dist/nexus/user-profile-hygiene.d.ts +168 -0
- package/dist/nexus/user-profile-hygiene.d.ts.map +1 -0
- package/dist/nexus/user-profile-hygiene.js +305 -0
- package/dist/nexus/user-profile-hygiene.js.map +1 -0
- package/dist/nexus/user-profile.d.ts +53 -2
- package/dist/nexus/user-profile.d.ts.map +1 -1
- package/dist/nexus/user-profile.js +106 -4
- package/dist/nexus/user-profile.js.map +1 -1
- package/dist/orchestrate/pivot.d.ts.map +1 -1
- package/dist/orchestrate/pivot.js +5 -1
- package/dist/orchestrate/pivot.js.map +1 -1
- package/dist/orchestrate/spawn-ops.d.ts +12 -0
- package/dist/orchestrate/spawn-ops.d.ts.map +1 -1
- package/dist/orchestrate/spawn-ops.js +152 -57
- package/dist/orchestrate/spawn-ops.js.map +1 -1
- package/dist/orchestration/classify-readiness.d.ts +37 -1
- package/dist/orchestration/classify-readiness.d.ts.map +1 -1
- package/dist/orchestration/classify-readiness.js +48 -19
- package/dist/orchestration/classify-readiness.js.map +1 -1
- package/dist/orchestration/index.d.ts +3 -2
- package/dist/orchestration/index.d.ts.map +1 -1
- package/dist/orchestration/index.js +2 -1
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/owner-decision-readiness.d.ts +88 -0
- package/dist/orchestration/owner-decision-readiness.d.ts.map +1 -0
- package/dist/orchestration/owner-decision-readiness.js +152 -0
- package/dist/orchestration/owner-decision-readiness.js.map +1 -0
- package/dist/orchestration/psyche-memory-budget.d.ts +105 -0
- package/dist/orchestration/psyche-memory-budget.d.ts.map +1 -0
- package/dist/orchestration/psyche-memory-budget.js +383 -0
- package/dist/orchestration/psyche-memory-budget.js.map +1 -0
- package/dist/orchestration/spawn-prompt.d.ts +12 -1
- package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
- package/dist/orchestration/spawn-prompt.js +141 -179
- package/dist/orchestration/spawn-prompt.js.map +1 -1
- package/dist/orchestration/spawn.d.ts +7 -0
- package/dist/orchestration/spawn.d.ts.map +1 -1
- package/dist/orchestration/spawn.js +1 -0
- package/dist/orchestration/spawn.js.map +1 -1
- package/dist/paths.d.ts +24 -8
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +135 -71
- package/dist/paths.js.map +1 -1
- package/dist/platform.d.ts +6 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +8 -19
- package/dist/platform.js.map +1 -1
- package/dist/project-info.d.ts +18 -0
- package/dist/project-info.d.ts.map +1 -1
- package/dist/project-info.js +29 -1
- package/dist/project-info.js.map +1 -1
- package/dist/project-lifecycle.d.ts +91 -32
- package/dist/project-lifecycle.d.ts.map +1 -1
- package/dist/project-lifecycle.js +639 -75
- package/dist/project-lifecycle.js.map +1 -1
- package/dist/project-scope.d.ts +86 -4
- package/dist/project-scope.d.ts.map +1 -1
- package/dist/project-scope.js +226 -13
- package/dist/project-scope.js.map +1 -1
- package/dist/project-tombstone.d.ts +111 -0
- package/dist/project-tombstone.d.ts.map +1 -0
- package/dist/project-tombstone.js +220 -0
- package/dist/project-tombstone.js.map +1 -0
- package/dist/release/artifacts.d.ts.map +1 -1
- package/dist/release/artifacts.js +14 -9
- package/dist/release/artifacts.js.map +1 -1
- package/dist/release/ci-evidence.d.ts +223 -0
- package/dist/release/ci-evidence.d.ts.map +1 -0
- package/dist/release/ci-evidence.js +652 -0
- package/dist/release/ci-evidence.js.map +1 -0
- package/dist/release/engine-ops.d.ts.map +1 -1
- package/dist/release/engine-ops.js +3 -3
- package/dist/release/engine-ops.js.map +1 -1
- package/dist/release/plan.d.ts.map +1 -1
- package/dist/release/plan.js +7 -6
- package/dist/release/plan.js.map +1 -1
- package/dist/release/pr-evidence.d.ts +38 -0
- package/dist/release/pr-evidence.d.ts.map +1 -1
- package/dist/release/pr-evidence.js +67 -11
- package/dist/release/pr-evidence.js.map +1 -1
- package/dist/release/reconcile.d.ts.map +1 -1
- package/dist/release/reconcile.js +3 -2
- package/dist/release/reconcile.js.map +1 -1
- package/dist/release/release-manifest.d.ts +2 -1
- package/dist/release/release-manifest.d.ts.map +1 -1
- package/dist/release/release-manifest.js +6 -5
- package/dist/release/release-manifest.js.map +1 -1
- package/dist/render/nexus/graph/index.d.ts +4 -0
- package/dist/render/nexus/graph/index.d.ts.map +1 -1
- package/dist/render/nexus/graph/index.js +57 -0
- package/dist/render/nexus/graph/index.js.map +1 -1
- package/dist/resources/spawn-wrapper.d.ts +8 -1
- package/dist/resources/spawn-wrapper.d.ts.map +1 -1
- package/dist/resources/spawn-wrapper.js +42 -5
- package/dist/resources/spawn-wrapper.js.map +1 -1
- package/dist/routing/build-command-groups.d.ts.map +1 -1
- package/dist/routing/build-command-groups.js +1 -0
- package/dist/routing/build-command-groups.js.map +1 -1
- package/dist/sagas/index.d.ts +1 -1
- package/dist/sagas/index.d.ts.map +1 -1
- package/dist/sagas/index.js +1 -1
- package/dist/sagas/index.js.map +1 -1
- package/dist/sagas/reconcile.d.ts +24 -4
- package/dist/sagas/reconcile.d.ts.map +1 -1
- package/dist/sagas/reconcile.js +226 -100
- package/dist/sagas/reconcile.js.map +1 -1
- package/dist/scaffold/ensure-config.d.ts.map +1 -1
- package/dist/scaffold/ensure-config.js +31 -1
- package/dist/scaffold/ensure-config.js.map +1 -1
- package/dist/scaffold/project-identity.d.ts +2 -8
- package/dist/scaffold/project-identity.d.ts.map +1 -1
- package/dist/scaffold/project-identity.js +5 -21
- package/dist/scaffold/project-identity.js.map +1 -1
- package/dist/security/input-sanitization.d.ts +9 -1
- package/dist/security/input-sanitization.d.ts.map +1 -1
- package/dist/security/input-sanitization.js +12 -2
- package/dist/security/input-sanitization.js.map +1 -1
- package/dist/selfimprove/fix-gen.js +4321 -1807
- package/dist/selfimprove/fix-gen.js.map +3 -3
- package/dist/sentient/propose-tick.d.ts.map +1 -1
- package/dist/sentient/propose-tick.js +4 -2
- package/dist/sentient/propose-tick.js.map +1 -1
- package/dist/sequence/index.d.ts.map +1 -1
- package/dist/sequence/index.js +6 -23
- package/dist/sequence/index.js.map +1 -1
- package/dist/session/engine-ops.d.ts +9 -0
- package/dist/session/engine-ops.d.ts.map +1 -1
- package/dist/session/engine-ops.js +110 -18
- package/dist/session/engine-ops.js.map +1 -1
- package/dist/sessions/assumptions.d.ts.map +1 -1
- package/dist/sessions/assumptions.js +7 -4
- package/dist/sessions/assumptions.js.map +1 -1
- package/dist/sessions/briefing.d.ts +6 -0
- package/dist/sessions/briefing.d.ts.map +1 -1
- package/dist/sessions/briefing.js +12 -1
- package/dist/sessions/briefing.js.map +1 -1
- package/dist/sessions/decisions.d.ts +38 -3
- package/dist/sessions/decisions.d.ts.map +1 -1
- package/dist/sessions/decisions.js +235 -21
- package/dist/sessions/decisions.js.map +1 -1
- package/dist/sessions/drift-watchdog.d.ts.map +1 -1
- package/dist/sessions/drift-watchdog.js +4 -2
- package/dist/sessions/drift-watchdog.js.map +1 -1
- package/dist/sessions/index.d.ts.map +1 -1
- package/dist/sessions/index.js +33 -4
- package/dist/sessions/index.js.map +1 -1
- package/dist/sessions/session-end-snapshot-entry.d.ts +26 -0
- package/dist/sessions/session-end-snapshot-entry.d.ts.map +1 -0
- package/dist/sessions/session-end-snapshot-entry.js +59 -0
- package/dist/sessions/session-end-snapshot-entry.js.map +1 -0
- package/dist/sessions/session-end-snapshot.d.ts +114 -0
- package/dist/sessions/session-end-snapshot.d.ts.map +1 -0
- package/dist/sessions/session-end-snapshot.js +446 -0
- package/dist/sessions/session-end-snapshot.js.map +1 -0
- package/dist/sessions/session-manifest-mirror.d.ts.map +1 -1
- package/dist/sessions/session-manifest-mirror.js +10 -17
- package/dist/sessions/session-manifest-mirror.js.map +1 -1
- package/dist/sessions/session-switch.d.ts.map +1 -1
- package/dist/sessions/session-switch.js +5 -3
- package/dist/sessions/session-switch.js.map +1 -1
- package/dist/sessions/snapshot.d.ts.map +1 -1
- package/dist/sessions/snapshot.js +5 -4
- package/dist/sessions/snapshot.js.map +1 -1
- package/dist/sessions/terminal-identity.d.ts +169 -0
- package/dist/sessions/terminal-identity.d.ts.map +1 -0
- package/dist/sessions/terminal-identity.js +273 -0
- package/dist/sessions/terminal-identity.js.map +1 -0
- package/dist/setup/sections/verification.d.ts +1 -1
- package/dist/setup/sections/verification.d.ts.map +1 -1
- package/dist/setup/sections/verification.js +11 -15
- package/dist/setup/sections/verification.js.map +1 -1
- package/dist/skills/discovery.d.ts +8 -2
- package/dist/skills/discovery.d.ts.map +1 -1
- package/dist/skills/discovery.js +15 -3
- package/dist/skills/discovery.js.map +1 -1
- package/dist/skills/dispatch.d.ts +5 -2
- package/dist/skills/dispatch.d.ts.map +1 -1
- package/dist/skills/dispatch.js +5 -2
- package/dist/skills/dispatch.js.map +1 -1
- package/dist/skills/doctor.d.ts.map +1 -1
- package/dist/skills/doctor.js +5 -1
- package/dist/skills/doctor.js.map +1 -1
- package/dist/skills/federated-search.js +2 -2
- package/dist/skills/federated-search.js.map +1 -1
- package/dist/skills/index.d.ts +3 -3
- 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/install.d.ts +15 -2
- package/dist/skills/install.d.ts.map +1 -1
- package/dist/skills/install.js +21 -5
- package/dist/skills/install.js.map +1 -1
- package/dist/skills/migration.d.ts +5 -5
- package/dist/skills/migration.d.ts.map +1 -1
- package/dist/skills/migration.js +7 -9
- package/dist/skills/migration.js.map +1 -1
- package/dist/skills/orchestrator/startup.d.ts.map +1 -1
- package/dist/skills/orchestrator/startup.js +4 -2
- package/dist/skills/orchestrator/startup.js.map +1 -1
- package/dist/skills/skill-paths.d.ts +30 -3
- package/dist/skills/skill-paths.d.ts.map +1 -1
- package/dist/skills/skill-paths.js +28 -9
- package/dist/skills/skill-paths.js.map +1 -1
- package/dist/skills/skill-root.d.ts +60 -11
- package/dist/skills/skill-root.d.ts.map +1 -1
- package/dist/skills/skill-root.js +100 -14
- package/dist/skills/skill-root.js.map +1 -1
- package/dist/skills/skills-guard.js +5 -5
- package/dist/skills/skills-guard.js.map +1 -1
- package/dist/skills/types.d.ts +23 -0
- package/dist/skills/types.d.ts.map +1 -1
- package/dist/skills/types.js.map +1 -1
- package/dist/spawn/agent-identity.d.ts +51 -2
- package/dist/spawn/agent-identity.d.ts.map +1 -1
- package/dist/spawn/agent-identity.js +89 -26
- package/dist/spawn/agent-identity.js.map +1 -1
- package/dist/spawn/branch-lock.d.ts.map +1 -1
- package/dist/spawn/branch-lock.js +56 -79
- package/dist/spawn/branch-lock.js.map +1 -1
- package/dist/spawn/index.d.ts +2 -2
- package/dist/spawn/index.d.ts.map +1 -1
- package/dist/spawn/index.js +1 -1
- package/dist/spawn/index.js.map +1 -1
- package/dist/spawn/worktree-lock-holder.d.ts +37 -0
- package/dist/spawn/worktree-lock-holder.d.ts.map +1 -0
- package/dist/spawn/worktree-lock-holder.js +41 -0
- package/dist/spawn/worktree-lock-holder.js.map +1 -0
- package/dist/sticky/convert.d.ts.map +1 -1
- package/dist/sticky/convert.js +16 -4
- package/dist/sticky/convert.js.map +1 -1
- package/dist/store/attachment-store.d.ts +14 -0
- package/dist/store/attachment-store.d.ts.map +1 -1
- package/dist/store/attachment-store.js +11 -1
- package/dist/store/attachment-store.js.map +1 -1
- package/dist/store/backup-inspect.d.ts +7 -3
- package/dist/store/backup-inspect.d.ts.map +1 -1
- package/dist/store/backup-inspect.js +18 -7
- package/dist/store/backup-inspect.js.map +1 -1
- package/dist/store/backup-sidecar.d.ts +60 -0
- package/dist/store/backup-sidecar.d.ts.map +1 -0
- package/dist/store/backup-sidecar.js +96 -0
- package/dist/store/backup-sidecar.js.map +1 -0
- package/dist/store/data-accessor.d.ts +1 -1
- package/dist/store/data-accessor.d.ts.map +1 -1
- package/dist/store/data-accessor.js +6 -6
- package/dist/store/data-accessor.js.map +1 -1
- package/dist/store/data-safety-central.d.ts +13 -4
- package/dist/store/data-safety-central.d.ts.map +1 -1
- package/dist/store/data-safety-central.js +31 -4
- package/dist/store/data-safety-central.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +10 -0
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/exodus/__fixtures__/representative-fixture.d.ts.map +1 -1
- package/dist/store/exodus/__fixtures__/representative-fixture.js +4 -0
- package/dist/store/exodus/__fixtures__/representative-fixture.js.map +1 -1
- package/dist/store/exodus/migrate.js +1 -1
- package/dist/store/exodus/migrate.js.map +1 -1
- package/dist/store/exodus/reconcile.js +1 -1
- package/dist/store/exodus/reconcile.js.map +1 -1
- package/dist/store/exodus/runtime-targets.d.ts +4 -3
- package/dist/store/exodus/runtime-targets.d.ts.map +1 -1
- package/dist/store/exodus/runtime-targets.js +4 -3
- package/dist/store/exodus/runtime-targets.js.map +1 -1
- package/dist/store/import-logging.d.ts.map +1 -1
- package/dist/store/import-logging.js +5 -4
- package/dist/store/import-logging.js.map +1 -1
- package/dist/store/legacy-tasks-lineage.d.ts.map +1 -1
- package/dist/store/legacy-tasks-lineage.js +2 -7
- package/dist/store/legacy-tasks-lineage.js.map +1 -1
- package/dist/store/lock.d.ts +1 -0
- package/dist/store/lock.d.ts.map +1 -1
- package/dist/store/lock.js +1 -0
- package/dist/store/lock.js.map +1 -1
- package/dist/store/memory-accessor.d.ts +8 -3
- package/dist/store/memory-accessor.d.ts.map +1 -1
- package/dist/store/memory-accessor.js +29 -13
- package/dist/store/memory-accessor.js.map +1 -1
- package/dist/store/memory-sqlite.d.ts.map +1 -1
- package/dist/store/memory-sqlite.js +5 -0
- package/dist/store/memory-sqlite.js.map +1 -1
- package/dist/store/open-cleo-db.d.ts.map +1 -1
- package/dist/store/open-cleo-db.js +11 -6
- package/dist/store/open-cleo-db.js.map +1 -1
- package/dist/store/portable-bundle-relocate.d.ts +13 -8
- package/dist/store/portable-bundle-relocate.d.ts.map +1 -1
- package/dist/store/portable-bundle-relocate.js +75 -31
- package/dist/store/portable-bundle-relocate.js.map +1 -1
- package/dist/store/portable-bundle-scan.d.ts.map +1 -1
- package/dist/store/portable-bundle-scan.js +2 -1
- package/dist/store/portable-bundle-scan.js.map +1 -1
- package/dist/store/portable-bundle.d.ts.map +1 -1
- package/dist/store/portable-bundle.js +7 -3
- package/dist/store/portable-bundle.js.map +1 -1
- package/dist/store/pre-repair-snapshot.d.ts +77 -0
- package/dist/store/pre-repair-snapshot.d.ts.map +1 -0
- package/dist/store/pre-repair-snapshot.js +122 -0
- package/dist/store/pre-repair-snapshot.js.map +1 -0
- package/dist/store/regenerators.d.ts +2 -1
- package/dist/store/regenerators.d.ts.map +1 -1
- package/dist/store/regenerators.js +17 -3
- package/dist/store/regenerators.js.map +1 -1
- package/dist/store/relocated-store-guard.d.ts +71 -0
- package/dist/store/relocated-store-guard.d.ts.map +1 -0
- package/dist/store/relocated-store-guard.js +138 -0
- package/dist/store/relocated-store-guard.js.map +1 -0
- package/dist/store/safety-data-accessor.d.ts +2 -2
- package/dist/store/safety-data-accessor.d.ts.map +1 -1
- package/dist/store/safety-data-accessor.js +2 -2
- package/dist/store/safety-data-accessor.js.map +1 -1
- package/dist/store/schema/attachments.d.ts +2 -2
- package/dist/store/schema/audit.d.ts +5 -5
- package/dist/store/schema/background-jobs.d.ts +1 -1
- package/dist/store/schema/cleo-global/models-catalog.d.ts +1 -1
- package/dist/store/schema/cleo-global/nexus.d.ts +686 -0
- package/dist/store/schema/cleo-global/nexus.d.ts.map +1 -1
- package/dist/store/schema/cleo-global/nexus.js +175 -7
- package/dist/store/schema/cleo-global/nexus.js.map +1 -1
- package/dist/store/schema/cleo-global/skills.d.ts +2 -2
- package/dist/store/schema/cleo-project/audit.d.ts +5 -5
- package/dist/store/schema/cleo-project/docs.d.ts +3 -3
- package/dist/store/schema/cleo-project/lifecycle.d.ts +3 -3
- package/dist/store/schema/cleo-project/provenance-commits.d.ts +2 -2
- package/dist/store/schema/cleo-project/provenance-rest.d.ts +3 -3
- package/dist/store/schema/cleo-project/tasks-core-batch2.d.ts +1 -1
- package/dist/store/schema/cleo-project/tasks-core.d.ts +6 -6
- package/dist/store/schema/cleo-shared/brain.d.ts +26 -26
- package/dist/store/schema/lifecycle.d.ts +3 -3
- package/dist/store/schema/manifest.d.ts +1 -1
- package/dist/store/schema/memory-schema.d.ts +26 -26
- package/dist/store/schema/nexus-schema.d.ts +696 -2
- package/dist/store/schema/nexus-schema.d.ts.map +1 -1
- package/dist/store/schema/nexus-schema.js +175 -19
- package/dist/store/schema/nexus-schema.js.map +1 -1
- package/dist/store/schema/provenance/releases.d.ts +1 -1
- package/dist/store/schema/skills-schema.d.ts +2 -2
- package/dist/store/schema/tasks.d.ts +5 -5
- package/dist/store/session-binding-schema.d.ts +132 -0
- package/dist/store/session-binding-schema.d.ts.map +1 -0
- package/dist/store/session-binding-schema.js +53 -0
- package/dist/store/session-binding-schema.js.map +1 -0
- package/dist/store/session-store.d.ts +262 -4
- package/dist/store/session-store.d.ts.map +1 -1
- package/dist/store/session-store.js +486 -26
- package/dist/store/session-store.js.map +1 -1
- package/dist/store/snapshot-gate.d.ts +239 -0
- package/dist/store/snapshot-gate.d.ts.map +1 -0
- package/dist/store/snapshot-gate.js +398 -0
- package/dist/store/snapshot-gate.js.map +1 -0
- package/dist/store/split-brain-import.js +2 -2
- package/dist/store/split-brain-import.js.map +1 -1
- package/dist/store/sqlite-backup.d.ts +55 -13
- package/dist/store/sqlite-backup.d.ts.map +1 -1
- package/dist/store/sqlite-backup.js +414 -106
- package/dist/store/sqlite-backup.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts +15 -0
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +63 -4
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/sqlite.d.ts +1 -1
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +53 -5
- package/dist/store/sqlite.js.map +1 -1
- package/dist/store/store-write-guard.d.ts +28 -0
- package/dist/store/store-write-guard.d.ts.map +1 -0
- package/dist/store/store-write-guard.js +50 -0
- package/dist/store/store-write-guard.js.map +1 -0
- package/dist/store/table-classification.d.ts +143 -0
- package/dist/store/table-classification.d.ts.map +1 -0
- package/dist/store/table-classification.js +1866 -0
- package/dist/store/table-classification.js.map +1 -0
- package/dist/store/task-version.d.ts +72 -0
- package/dist/store/task-version.d.ts.map +1 -0
- package/dist/store/task-version.js +93 -0
- package/dist/store/task-version.js.map +1 -0
- package/dist/store/tasks-schema.d.ts +1 -0
- package/dist/store/tasks-schema.d.ts.map +1 -1
- package/dist/store/tasks-schema.js +13 -0
- package/dist/store/tasks-schema.js.map +1 -1
- package/dist/store/tasks-sqlite.d.ts +10 -3
- package/dist/store/tasks-sqlite.d.ts.map +1 -1
- package/dist/store/tasks-sqlite.js +12 -3
- package/dist/store/tasks-sqlite.js.map +1 -1
- package/dist/store/twin-collapse.d.ts +275 -0
- package/dist/store/twin-collapse.d.ts.map +1 -0
- package/dist/store/twin-collapse.js +805 -0
- package/dist/store/twin-collapse.js.map +1 -0
- package/dist/store/umbrella-data-accessor.d.ts +2 -2
- package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
- package/dist/store/umbrella-data-accessor.js +2 -2
- package/dist/store/umbrella-data-accessor.js.map +1 -1
- package/dist/store/validation-schemas.d.ts +63 -63
- package/dist/store/worktree-isolation-guard.d.ts +46 -24
- package/dist/store/worktree-isolation-guard.d.ts.map +1 -1
- package/dist/store/worktree-isolation-guard.js +69 -50
- package/dist/store/worktree-isolation-guard.js.map +1 -1
- package/dist/system/backup.d.ts.map +1 -1
- package/dist/system/backup.js +3 -67
- package/dist/system/backup.js.map +1 -1
- package/dist/system/cleo-link.d.ts +163 -0
- package/dist/system/cleo-link.d.ts.map +1 -0
- package/dist/system/cleo-link.js +246 -0
- package/dist/system/cleo-link.js.map +1 -0
- package/dist/system/dependencies.d.ts.map +1 -1
- package/dist/system/dependencies.js +26 -41
- package/dist/system/dependencies.js.map +1 -1
- package/dist/system/global-delivery.d.ts +205 -0
- package/dist/system/global-delivery.d.ts.map +1 -0
- package/dist/system/global-delivery.js +320 -0
- package/dist/system/global-delivery.js.map +1 -0
- package/dist/system/health.d.ts.map +1 -1
- package/dist/system/health.js +29 -6
- package/dist/system/health.js.map +1 -1
- package/dist/system/project-health.d.ts.map +1 -1
- package/dist/system/project-health.js +1 -20
- package/dist/system/project-health.js.map +1 -1
- package/dist/system/runtime.d.ts.map +1 -1
- package/dist/system/runtime.js +2 -12
- package/dist/system/runtime.js.map +1 -1
- package/dist/system/safestop.d.ts.map +1 -1
- package/dist/system/safestop.js +5 -2
- package/dist/system/safestop.js.map +1 -1
- package/dist/system/skill-fixtures.d.ts +200 -0
- package/dist/system/skill-fixtures.d.ts.map +1 -0
- package/dist/system/skill-fixtures.js +331 -0
- package/dist/system/skill-fixtures.js.map +1 -0
- package/dist/tasks/add.d.ts.map +1 -1
- package/dist/tasks/add.js +4 -2
- package/dist/tasks/add.js.map +1 -1
- package/dist/tasks/affected-packages.d.ts +173 -0
- package/dist/tasks/affected-packages.d.ts.map +1 -0
- package/dist/tasks/affected-packages.js +389 -0
- package/dist/tasks/affected-packages.js.map +1 -0
- package/dist/tasks/change-set.d.ts +151 -0
- package/dist/tasks/change-set.d.ts.map +1 -0
- package/dist/tasks/change-set.js +634 -0
- package/dist/tasks/change-set.js.map +1 -0
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +10 -5
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/done-plan.d.ts +103 -0
- package/dist/tasks/done-plan.d.ts.map +1 -0
- package/dist/tasks/done-plan.js +541 -0
- package/dist/tasks/done-plan.js.map +1 -0
- package/dist/tasks/done-record.d.ts +127 -0
- package/dist/tasks/done-record.d.ts.map +1 -0
- package/dist/tasks/done-record.js +373 -0
- package/dist/tasks/done-record.js.map +1 -0
- package/dist/tasks/duplicate-detector.d.ts +68 -11
- package/dist/tasks/duplicate-detector.d.ts.map +1 -1
- package/dist/tasks/duplicate-detector.js +314 -58
- package/dist/tasks/duplicate-detector.js.map +1 -1
- package/dist/tasks/evidence-paths.d.ts +78 -0
- package/dist/tasks/evidence-paths.d.ts.map +1 -0
- package/dist/tasks/evidence-paths.js +150 -0
- package/dist/tasks/evidence-paths.js.map +1 -0
- package/dist/tasks/evidence.d.ts +55 -0
- package/dist/tasks/evidence.d.ts.map +1 -1
- package/dist/tasks/evidence.js +223 -26
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/gate-preview.d.ts +5 -0
- package/dist/tasks/gate-preview.d.ts.map +1 -1
- package/dist/tasks/gate-preview.js +25 -21
- package/dist/tasks/gate-preview.js.map +1 -1
- package/dist/tasks/gate-result-cache.d.ts +205 -0
- package/dist/tasks/gate-result-cache.d.ts.map +1 -0
- package/dist/tasks/gate-result-cache.js +285 -0
- package/dist/tasks/gate-result-cache.js.map +1 -0
- package/dist/tasks/gate-runner.d.ts +126 -3
- package/dist/tasks/gate-runner.d.ts.map +1 -1
- package/dist/tasks/gate-runner.js +483 -28
- package/dist/tasks/gate-runner.js.map +1 -1
- package/dist/tasks/session-scope.d.ts +3 -1
- package/dist/tasks/session-scope.d.ts.map +1 -1
- package/dist/tasks/session-scope.js +18 -3
- package/dist/tasks/session-scope.js.map +1 -1
- package/dist/tasks/tool-resolver.d.ts +23 -6
- package/dist/tasks/tool-resolver.d.ts.map +1 -1
- package/dist/tasks/tool-resolver.js +146 -8
- package/dist/tasks/tool-resolver.js.map +1 -1
- package/dist/tasks/tool-vacuity.d.ts +71 -0
- package/dist/tasks/tool-vacuity.d.ts.map +1 -0
- package/dist/tasks/tool-vacuity.js +334 -0
- package/dist/tasks/tool-vacuity.js.map +1 -0
- package/dist/tasks/update.d.ts +8 -0
- package/dist/tasks/update.d.ts.map +1 -1
- package/dist/tasks/update.js +159 -78
- package/dist/tasks/update.js.map +1 -1
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +18 -2
- package/dist/upgrade.js.map +1 -1
- package/dist/validation/doctor/checks.d.ts +20 -2
- package/dist/validation/doctor/checks.d.ts.map +1 -1
- package/dist/validation/doctor/checks.js +64 -4
- package/dist/validation/doctor/checks.js.map +1 -1
- package/dist/validation/doctor/index.d.ts +1 -1
- package/dist/validation/doctor/index.d.ts.map +1 -1
- package/dist/validation/doctor/index.js +1 -1
- package/dist/validation/doctor/index.js.map +1 -1
- package/dist/validation/doctor/utils.d.ts.map +1 -1
- package/dist/validation/doctor/utils.js +7 -2
- package/dist/validation/doctor/utils.js.map +1 -1
- package/dist/validation/engine-ops.d.ts +15 -0
- package/dist/validation/engine-ops.d.ts.map +1 -1
- package/dist/validation/engine-ops.js +249 -98
- package/dist/validation/engine-ops.js.map +1 -1
- package/migrations/drizzle-cleo-global/20260927000000_t12469-project-locations/migration.sql +121 -0
- package/migrations/drizzle-cleo-global/20260927010000_t12543-user-profile-project-scope/migration.sql +23 -0
- package/migrations/drizzle-cleo-global/20260928010000_t12470-location-candidates/migration.sql +72 -0
- package/migrations/drizzle-cleo-global/20260928020000_t12510-nexus-devices/migration.sql +34 -0
- package/migrations/drizzle-cleo-global/20260928030000_t12511-project-git-state/migration.sql +62 -0
- package/migrations/drizzle-cleo-project/20260927000000_t12499-session-terminal-bindings/migration.sql +34 -0
- package/migrations/drizzle-cleo-project/20260928000000_t12500-binding-provider-flag/migration.sql +15 -0
- package/package.json +23 -13
- package/schemas/config.schema.json +54 -0
- package/schemas/project-context.schema.json +51 -3
- package/schemas/project-info.schema.json +28 -1
- package/templates/CLEO-INJECTION.md +40 -332
- package/templates/CLEO-REFERENCE.md +303 -0
- package/templates/workflows/README.md +36 -14
- package/templates/workflows/release-prepare.yml.tmpl +7 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-profile hygiene: keep operation receipts out of `nexus_user_profile`
|
|
3
|
+
* and repair the rows that already got in (T12543).
|
|
4
|
+
*
|
|
5
|
+
* ## The defect
|
|
6
|
+
*
|
|
7
|
+
* The dialectic hook in the CQRS dispatcher fed every successful mutate
|
|
8
|
+
* operation to the evaluator as a "turn": `cleo <domain> <op> {params}` paired
|
|
9
|
+
* with `Operation succeeded in domain "<domain>"`. The evaluator minted
|
|
10
|
+
* user traits from those envelopes — "Operation succeeded in domain 'check'",
|
|
11
|
+
* "gate set to true for T1655" — and, because the table is GLOBAL, facts
|
|
12
|
+
* lifted from one project's task params were injected into every other
|
|
13
|
+
* project's spawn prompts. Measured 2026-09-27: 399 of 404 rows were
|
|
14
|
+
* `dialectic:<session>` rows, each seen exactly once.
|
|
15
|
+
*
|
|
16
|
+
* ## What this module provides
|
|
17
|
+
*
|
|
18
|
+
* - {@link classifyReceiptTrait} — the text classifier for status lines and
|
|
19
|
+
* operation receipts. REPAIR ONLY: at write time the structural signal
|
|
20
|
+
* (`DialecticTurn.origin === 'operation-envelope'`) is the guard, because a
|
|
21
|
+
* text rule at write time would also block legitimate preferences.
|
|
22
|
+
* - {@link pruneReceiptTraits} — dry-run / apply repair. Apply writes a
|
|
23
|
+
* backup file FIRST (a `user_profile.json`-shaped envelope carrying the full
|
|
24
|
+
* rows), then deletes each row only if it is unchanged since it was read.
|
|
25
|
+
* - {@link restorePrunedTraits} — re-inserts rows from that backup, never
|
|
26
|
+
* overwriting a row that was re-created since.
|
|
27
|
+
*
|
|
28
|
+
* @task T12543
|
|
29
|
+
* @epic T12515
|
|
30
|
+
*/
|
|
31
|
+
import type { NodeSQLiteDatabase } from 'drizzle-orm/node-sqlite';
|
|
32
|
+
/** Drizzle handle over a database holding `nexus_user_profile`. */
|
|
33
|
+
type NexusDb = NodeSQLiteDatabase;
|
|
34
|
+
/**
|
|
35
|
+
* Classify a trait as an operation receipt / status line.
|
|
36
|
+
*
|
|
37
|
+
* @param traitKey - Trait key (kebab-case semantic key).
|
|
38
|
+
* @param traitValue - Trait value text.
|
|
39
|
+
* @returns The id of the first matching rule, or `null` when the trait does
|
|
40
|
+
* not look like a receipt.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* classifyReceiptTrait('task-successful', 'Cleo tasks update operation succeeded'); // 'operation-status'
|
|
45
|
+
* classifyReceiptTrait('strict-typescript', 'never use any'); // null
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @task T12543
|
|
49
|
+
*/
|
|
50
|
+
export declare function classifyReceiptTrait(traitKey: string, traitValue: string): string | null;
|
|
51
|
+
/**
|
|
52
|
+
* Structural rule id: a legacy `dialectic:*` row with no project stamp. Before
|
|
53
|
+
* T12543 the only writer of dialectic global traits was the dispatcher hook,
|
|
54
|
+
* whose "turn" was always an operation envelope — so every such row is a
|
|
55
|
+
* receipt by construction, whatever its text says.
|
|
56
|
+
*/
|
|
57
|
+
export declare const OPERATION_ENVELOPE_RULE: "operation-envelope";
|
|
58
|
+
/** One trait matched by the repair. */
|
|
59
|
+
export interface TraitPruneCandidate {
|
|
60
|
+
/** Trait key (primary key). */
|
|
61
|
+
readonly traitKey: string;
|
|
62
|
+
/** Trait value at read time. */
|
|
63
|
+
readonly traitValue: string;
|
|
64
|
+
/** Trait source (e.g. `dialectic:<sessionId>`). */
|
|
65
|
+
readonly source: string;
|
|
66
|
+
/** Originating project id, or `null` for unknown origin. */
|
|
67
|
+
readonly projectId: string | null;
|
|
68
|
+
/** Matching rule id (a receipt rule, or {@link OPERATION_ENVELOPE_RULE}). */
|
|
69
|
+
readonly rule: string;
|
|
70
|
+
}
|
|
71
|
+
/** Options for {@link pruneReceiptTraits}. */
|
|
72
|
+
export interface TraitPruneOptions {
|
|
73
|
+
/** Delete matched rows (after writing a backup). Default: dry run. */
|
|
74
|
+
readonly apply?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Also match every legacy `dialectic:*` row with no project stamp
|
|
77
|
+
* ({@link OPERATION_ENVELOPE_RULE}). Default: receipt-text rules only.
|
|
78
|
+
*/
|
|
79
|
+
readonly includeEnvelopeDerived?: boolean;
|
|
80
|
+
/** Directory for the backup file. Default: `<cleoHome>/backups/user-profile`. */
|
|
81
|
+
readonly backupDir?: string;
|
|
82
|
+
}
|
|
83
|
+
/** Outcome (and, when applied, receipt) of {@link pruneReceiptTraits}. */
|
|
84
|
+
export interface TraitPruneResult {
|
|
85
|
+
/** Whether rows were deleted (`false` = dry run). */
|
|
86
|
+
readonly applied: boolean;
|
|
87
|
+
/** Row count before the run. */
|
|
88
|
+
readonly before: number;
|
|
89
|
+
/** Row count after the run (equals `before` on a dry run). */
|
|
90
|
+
readonly after: number;
|
|
91
|
+
/** Number of rows matched. */
|
|
92
|
+
readonly matched: number;
|
|
93
|
+
/** Per-rule match counts. */
|
|
94
|
+
readonly byRule: Record<string, number>;
|
|
95
|
+
/** Every matched trait key, in key order. */
|
|
96
|
+
readonly candidateKeys: readonly string[];
|
|
97
|
+
/** Up to 10 matched rows, so a dry run shows what would go. */
|
|
98
|
+
readonly sample: readonly TraitPruneCandidate[];
|
|
99
|
+
/**
|
|
100
|
+
* Unknown-origin rows (`project_id IS NULL`, scope `project`) that this run
|
|
101
|
+
* leaves in place. They are excluded from every spawn prompt and remain
|
|
102
|
+
* queryable via the `nexus.profile.view` operation.
|
|
103
|
+
*/
|
|
104
|
+
readonly unknownOriginRetained: number;
|
|
105
|
+
/** Keys actually deleted (apply only). */
|
|
106
|
+
readonly removedKeys?: readonly string[];
|
|
107
|
+
/** Keys skipped because the row changed after it was read (apply only). */
|
|
108
|
+
readonly changedSkipped?: readonly string[];
|
|
109
|
+
/** ISO-8601 instant of the deletion (apply only). */
|
|
110
|
+
readonly removedAt?: string;
|
|
111
|
+
/** Absolute path of the backup written BEFORE any deletion (apply only). */
|
|
112
|
+
readonly backupPath?: string;
|
|
113
|
+
/** SHA-256 of the backup file bytes (apply only). */
|
|
114
|
+
readonly backupSha256?: string;
|
|
115
|
+
/** Command that reverses the apply (apply only). */
|
|
116
|
+
readonly restoreCommand?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* List — and with `apply`, remove — receipt-style user-profile traits.
|
|
120
|
+
*
|
|
121
|
+
* Apply is reversible: the full matched rows are written to a backup file
|
|
122
|
+
* before anything is deleted, and each delete is guarded on the row being
|
|
123
|
+
* unchanged since it was read (a re-derived or edited row is skipped and
|
|
124
|
+
* reported). Reverse with {@link restorePrunedTraits} /
|
|
125
|
+
* `cleo memory prune-traits --restore <backupPath>`.
|
|
126
|
+
*
|
|
127
|
+
* @param nexusDb - Drizzle handle over the database holding `nexus_user_profile`.
|
|
128
|
+
* @param options - Apply flag, rule selection and backup location.
|
|
129
|
+
* @returns Counts, per-rule breakdown, sample, and — when applied — the receipt.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* const preview = await pruneReceiptTraits(db);
|
|
134
|
+
* if (preview.matched > 0) await pruneReceiptTraits(db, { apply: true });
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @task T12543
|
|
138
|
+
*/
|
|
139
|
+
export declare function pruneReceiptTraits(nexusDb: NexusDb, options?: TraitPruneOptions): Promise<TraitPruneResult>;
|
|
140
|
+
/** Outcome of {@link restorePrunedTraits}. */
|
|
141
|
+
export interface TraitRestoreResult {
|
|
142
|
+
/** Backup file read. */
|
|
143
|
+
readonly backupPath: string;
|
|
144
|
+
/** SHA-256 of the backup bytes read (compare with the prune receipt). */
|
|
145
|
+
readonly backupSha256: string;
|
|
146
|
+
/** Keys re-inserted. */
|
|
147
|
+
readonly restoredKeys: readonly string[];
|
|
148
|
+
/** Keys skipped because a row with that key exists again. */
|
|
149
|
+
readonly skippedExisting: readonly string[];
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Reverse a {@link pruneReceiptTraits} apply from its backup file.
|
|
153
|
+
*
|
|
154
|
+
* Re-inserts each backed-up row verbatim (value, provenance, project stamp,
|
|
155
|
+
* scope, timestamps). A key that exists again is left untouched — a newer
|
|
156
|
+
* row always wins over a restore.
|
|
157
|
+
*
|
|
158
|
+
* @param nexusDb - Drizzle handle over the database holding `nexus_user_profile`.
|
|
159
|
+
* @param backupPath - Path from the prune receipt's `backupPath`.
|
|
160
|
+
* @param expectedSha256 - The receipt's `backupSha256`. When given, a backup
|
|
161
|
+
* whose bytes differ is refused before anything is written.
|
|
162
|
+
* @returns The restored and skipped keys plus the backup digest.
|
|
163
|
+
*
|
|
164
|
+
* @task T12543
|
|
165
|
+
*/
|
|
166
|
+
export declare function restorePrunedTraits(nexusDb: NexusDb, backupPath: string, expectedSha256?: string): Promise<TraitRestoreResult>;
|
|
167
|
+
export {};
|
|
168
|
+
//# sourceMappingURL=user-profile-hygiene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-profile-hygiene.d.ts","sourceRoot":"","sources":["../../src/nexus/user-profile-hygiene.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAOH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAKlE,mEAAmE;AACnE,KAAK,OAAO,GAAG,kBAAkB,CAAC;AAgElC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKxF;AAMD;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAG,oBAA6B,CAAC;AAErE,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC,+BAA+B;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,gCAAgC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED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AyDD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CAiG3B;AAED,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,wBAAwB;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,yEAAyE;IACzE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,wBAAwB;IACxB,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,6DAA6D;IAC7D,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,kBAAkB,CAAC,CA0B7B"}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-profile hygiene: keep operation receipts out of `nexus_user_profile`
|
|
3
|
+
* and repair the rows that already got in (T12543).
|
|
4
|
+
*
|
|
5
|
+
* ## The defect
|
|
6
|
+
*
|
|
7
|
+
* The dialectic hook in the CQRS dispatcher fed every successful mutate
|
|
8
|
+
* operation to the evaluator as a "turn": `cleo <domain> <op> {params}` paired
|
|
9
|
+
* with `Operation succeeded in domain "<domain>"`. The evaluator minted
|
|
10
|
+
* user traits from those envelopes — "Operation succeeded in domain 'check'",
|
|
11
|
+
* "gate set to true for T1655" — and, because the table is GLOBAL, facts
|
|
12
|
+
* lifted from one project's task params were injected into every other
|
|
13
|
+
* project's spawn prompts. Measured 2026-09-27: 399 of 404 rows were
|
|
14
|
+
* `dialectic:<session>` rows, each seen exactly once.
|
|
15
|
+
*
|
|
16
|
+
* ## What this module provides
|
|
17
|
+
*
|
|
18
|
+
* - {@link classifyReceiptTrait} — the text classifier for status lines and
|
|
19
|
+
* operation receipts. REPAIR ONLY: at write time the structural signal
|
|
20
|
+
* (`DialecticTurn.origin === 'operation-envelope'`) is the guard, because a
|
|
21
|
+
* text rule at write time would also block legitimate preferences.
|
|
22
|
+
* - {@link pruneReceiptTraits} — dry-run / apply repair. Apply writes a
|
|
23
|
+
* backup file FIRST (a `user_profile.json`-shaped envelope carrying the full
|
|
24
|
+
* rows), then deletes each row only if it is unchanged since it was read.
|
|
25
|
+
* - {@link restorePrunedTraits} — re-inserts rows from that backup, never
|
|
26
|
+
* overwriting a row that was re-created since.
|
|
27
|
+
*
|
|
28
|
+
* @task T12543
|
|
29
|
+
* @epic T12515
|
|
30
|
+
*/
|
|
31
|
+
import { createHash } from 'node:crypto';
|
|
32
|
+
import { mkdir, open, readFile } from 'node:fs/promises';
|
|
33
|
+
import { join } from 'node:path';
|
|
34
|
+
import { and, eq, isNull } from 'drizzle-orm';
|
|
35
|
+
import { getCleoHome } from '../paths.js';
|
|
36
|
+
import * as nexusSchema from '../store/schema/nexus-schema.js';
|
|
37
|
+
import { getUserProfileTrait, listUserProfile, upsertUserProfileTrait } from './user-profile.js';
|
|
38
|
+
/**
|
|
39
|
+
* Status-line / operation-receipt rules. A trait matches when ANY rule's key
|
|
40
|
+
* OR value pattern matches. Each targets a shape that states what an operation
|
|
41
|
+
* DID, which is never a durable fact about the user.
|
|
42
|
+
*/
|
|
43
|
+
const RECEIPT_RULES = [
|
|
44
|
+
{
|
|
45
|
+
// "Operation succeeded in domain 'check'", "Cleo tasks update operation
|
|
46
|
+
// succeeded". Singular `operation` only: "Operations team review
|
|
47
|
+
// completed" is prose, not a receipt.
|
|
48
|
+
id: 'operation-status',
|
|
49
|
+
value: /\boperation\b[^.\n]{0,30}\b(succeeded|was successful|failed)\b|\b(succeeded|success)\b[^.\n]{0,20}\b(in|for)\b[^.\n]{0,12}\bdomain\b/i,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
// `gate.set-success`, `task-successful`, `succeeded-in-domain-check`.
|
|
53
|
+
// A leading `success-` followed by other words ("success-criteria-first")
|
|
54
|
+
// is a preference, not a receipt.
|
|
55
|
+
id: 'success-key',
|
|
56
|
+
key: /(^|[-_.])succeed(ed|s)?([-_.]|$)|[-_.]success(ful)?$|^success(ful)?$|^success-in-|(gate|task|ops|operation)[-_.]success/i,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
// An echoed dispatch: `cleo tasks update {…}` / "cleo tasks update
|
|
60
|
+
// request", or "cleo successfully set …". A sentence that merely names a
|
|
61
|
+
// command ("cleo memory find is used before…") is not an echo.
|
|
62
|
+
id: 'command-echo',
|
|
63
|
+
value: /^\s*cleo\s+[a-z-]+\s+[a-z.-]+\s*(\{|request\b|operation\b|$)|\bcleo (successfully|set|completed|executed|interacted)\b/i,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
// A gate write names a task id or a value ("gate set to true for T122").
|
|
67
|
+
// "insists every gate is set before complete" names neither.
|
|
68
|
+
id: 'gate-receipt',
|
|
69
|
+
value: /\bgate\b[^.\n]{0,80}\bto true\b|\bgate\b[^.\n]{0,60}\bT\d{2,}\b|\bT\d{2,}\b[^.\n]{0,40}\bgate\b|\bgate\.(set|implemented)\b/i,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: 'task-receipt',
|
|
73
|
+
value: /\b(completed|created|added|updated|closed|marked|recorded|passed)\b[^.\n]{0,40}\bT\d{2,}\b|\bT\d{2,}\b[^.\n]{0,40}\b(has been|was|were)\b[^.\n]{0,20}\b(completed|created|added|updated|marked|set)\b/i,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 'session-status',
|
|
77
|
+
value: /\bactive peer\b|\bglobal peer\b/i,
|
|
78
|
+
key: /(^|-)active-peer(-|$)/i,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
/**
|
|
82
|
+
* Classify a trait as an operation receipt / status line.
|
|
83
|
+
*
|
|
84
|
+
* @param traitKey - Trait key (kebab-case semantic key).
|
|
85
|
+
* @param traitValue - Trait value text.
|
|
86
|
+
* @returns The id of the first matching rule, or `null` when the trait does
|
|
87
|
+
* not look like a receipt.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* classifyReceiptTrait('task-successful', 'Cleo tasks update operation succeeded'); // 'operation-status'
|
|
92
|
+
* classifyReceiptTrait('strict-typescript', 'never use any'); // null
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @task T12543
|
|
96
|
+
*/
|
|
97
|
+
export function classifyReceiptTrait(traitKey, traitValue) {
|
|
98
|
+
for (const rule of RECEIPT_RULES) {
|
|
99
|
+
if (rule.value?.test(traitValue) || rule.key?.test(traitKey))
|
|
100
|
+
return rule.id;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Repair: prune + restore
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
/**
|
|
108
|
+
* Structural rule id: a legacy `dialectic:*` row with no project stamp. Before
|
|
109
|
+
* T12543 the only writer of dialectic global traits was the dispatcher hook,
|
|
110
|
+
* whose "turn" was always an operation envelope — so every such row is a
|
|
111
|
+
* receipt by construction, whatever its text says.
|
|
112
|
+
*/
|
|
113
|
+
export const OPERATION_ENVELOPE_RULE = 'operation-envelope';
|
|
114
|
+
/**
|
|
115
|
+
* Match one trait against the enabled rules.
|
|
116
|
+
*
|
|
117
|
+
* @param trait - Row to classify.
|
|
118
|
+
* @param includeEnvelopeDerived - Whether the structural rule is enabled.
|
|
119
|
+
* @returns The matching rule id, or `null`.
|
|
120
|
+
*/
|
|
121
|
+
function matchTrait(trait, includeEnvelopeDerived) {
|
|
122
|
+
const textRule = classifyReceiptTrait(trait.traitKey, trait.traitValue);
|
|
123
|
+
if (textRule)
|
|
124
|
+
return textRule;
|
|
125
|
+
if (includeEnvelopeDerived &&
|
|
126
|
+
trait.source.startsWith('dialectic:') &&
|
|
127
|
+
(trait.projectId ?? null) === null) {
|
|
128
|
+
return OPERATION_ENVELOPE_RULE;
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Write `bytes` to a new file and fsync both the file and its directory, so
|
|
134
|
+
* the backup survives a crash that happens after the deletes commit.
|
|
135
|
+
*
|
|
136
|
+
* @param path - New file path (must not exist).
|
|
137
|
+
* @param dir - Parent directory to fsync.
|
|
138
|
+
* @param bytes - UTF-8 content.
|
|
139
|
+
*/
|
|
140
|
+
async function writeDurably(path, dir, bytes) {
|
|
141
|
+
const file = await open(path, 'wx');
|
|
142
|
+
try {
|
|
143
|
+
await file.writeFile(bytes, 'utf8');
|
|
144
|
+
await file.sync();
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
await file.close();
|
|
148
|
+
}
|
|
149
|
+
const dirHandle = await open(dir, 'r');
|
|
150
|
+
try {
|
|
151
|
+
await dirHandle.sync();
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// Some platforms/filesystems refuse fsync on a directory handle; the file
|
|
155
|
+
// itself is already synced.
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
await dirHandle.close();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* List — and with `apply`, remove — receipt-style user-profile traits.
|
|
163
|
+
*
|
|
164
|
+
* Apply is reversible: the full matched rows are written to a backup file
|
|
165
|
+
* before anything is deleted, and each delete is guarded on the row being
|
|
166
|
+
* unchanged since it was read (a re-derived or edited row is skipped and
|
|
167
|
+
* reported). Reverse with {@link restorePrunedTraits} /
|
|
168
|
+
* `cleo memory prune-traits --restore <backupPath>`.
|
|
169
|
+
*
|
|
170
|
+
* @param nexusDb - Drizzle handle over the database holding `nexus_user_profile`.
|
|
171
|
+
* @param options - Apply flag, rule selection and backup location.
|
|
172
|
+
* @returns Counts, per-rule breakdown, sample, and — when applied — the receipt.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* const preview = await pruneReceiptTraits(db);
|
|
177
|
+
* if (preview.matched > 0) await pruneReceiptTraits(db, { apply: true });
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @task T12543
|
|
181
|
+
*/
|
|
182
|
+
export async function pruneReceiptTraits(nexusDb, options = {}) {
|
|
183
|
+
const includeEnvelopeDerived = options.includeEnvelopeDerived === true;
|
|
184
|
+
const all = await listUserProfile(nexusDb, { includeSuperseded: true });
|
|
185
|
+
const matchedRows = [];
|
|
186
|
+
const byRule = {};
|
|
187
|
+
for (const trait of all) {
|
|
188
|
+
const rule = matchTrait(trait, includeEnvelopeDerived);
|
|
189
|
+
if (!rule)
|
|
190
|
+
continue;
|
|
191
|
+
matchedRows.push({ trait, rule });
|
|
192
|
+
byRule[rule] = (byRule[rule] ?? 0) + 1;
|
|
193
|
+
}
|
|
194
|
+
matchedRows.sort((a, b) => a.trait.traitKey.localeCompare(b.trait.traitKey));
|
|
195
|
+
const matchedKeys = new Set(matchedRows.map((m) => m.trait.traitKey));
|
|
196
|
+
const unknownOriginRetained = all.filter((t) => (t.projectId ?? null) === null &&
|
|
197
|
+
(t.scope ?? 'project') === 'project' &&
|
|
198
|
+
!matchedKeys.has(t.traitKey)).length;
|
|
199
|
+
const report = {
|
|
200
|
+
before: all.length,
|
|
201
|
+
matched: matchedRows.length,
|
|
202
|
+
byRule,
|
|
203
|
+
candidateKeys: matchedRows.map((m) => m.trait.traitKey),
|
|
204
|
+
sample: matchedRows.slice(0, 10).map(({ trait, rule }) => ({
|
|
205
|
+
traitKey: trait.traitKey,
|
|
206
|
+
traitValue: trait.traitValue,
|
|
207
|
+
source: trait.source,
|
|
208
|
+
projectId: trait.projectId ?? null,
|
|
209
|
+
rule,
|
|
210
|
+
})),
|
|
211
|
+
unknownOriginRetained,
|
|
212
|
+
};
|
|
213
|
+
if (!options.apply || matchedRows.length === 0) {
|
|
214
|
+
return { applied: false, after: all.length, ...report };
|
|
215
|
+
}
|
|
216
|
+
// 1. Backup FIRST — nothing is deleted unless the backup is durable on disk.
|
|
217
|
+
const removedAt = new Date().toISOString();
|
|
218
|
+
const backupDir = options.backupDir ?? join(getCleoHome(), 'backups', 'user-profile');
|
|
219
|
+
await mkdir(backupDir, { recursive: true });
|
|
220
|
+
const backupPath = join(backupDir, `receipt-traits-${removedAt.replace(/[:.]/g, '-')}.json`);
|
|
221
|
+
const backup = {
|
|
222
|
+
$schema: 'https://cleocode.dev/schemas/user-profile/v1.json',
|
|
223
|
+
exportedAt: removedAt,
|
|
224
|
+
reason: `T12543 prune-traits (${includeEnvelopeDerived ? 'receipt-text + operation-envelope' : 'receipt-text'})`,
|
|
225
|
+
traits: matchedRows.map((m) => m.trait),
|
|
226
|
+
};
|
|
227
|
+
const bytes = `${JSON.stringify(backup, null, 2)}\n`;
|
|
228
|
+
await writeDurably(backupPath, backupDir, bytes);
|
|
229
|
+
const backupSha256 = createHash('sha256').update(bytes).digest('hex');
|
|
230
|
+
// 2. One transaction of guarded deletes: a row is removed only if EVERY
|
|
231
|
+
// field the backup captured is unchanged since the read above.
|
|
232
|
+
const removedKeys = [];
|
|
233
|
+
const changedSkipped = [];
|
|
234
|
+
const table = nexusSchema.userProfile;
|
|
235
|
+
nexusDb.transaction((tx) => {
|
|
236
|
+
for (const { trait } of matchedRows) {
|
|
237
|
+
const deleted = tx
|
|
238
|
+
.delete(table)
|
|
239
|
+
.where(and(eq(table.traitKey, trait.traitKey), eq(table.traitValue, trait.traitValue), eq(table.source, trait.source), eq(table.confidence, trait.confidence), eq(table.scope, trait.scope ?? 'project'), trait.projectId == null
|
|
240
|
+
? isNull(table.projectId)
|
|
241
|
+
: eq(table.projectId, trait.projectId), trait.supersededBy == null
|
|
242
|
+
? isNull(table.supersededBy)
|
|
243
|
+
: eq(table.supersededBy, trait.supersededBy), eq(table.lastReinforcedAt, new Date(trait.lastReinforcedAt).toISOString())))
|
|
244
|
+
.returning({ traitKey: table.traitKey })
|
|
245
|
+
.all();
|
|
246
|
+
if (deleted.length > 0)
|
|
247
|
+
removedKeys.push(trait.traitKey);
|
|
248
|
+
else
|
|
249
|
+
changedSkipped.push(trait.traitKey);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
const after = (await listUserProfile(nexusDb, { includeSuperseded: true })).length;
|
|
253
|
+
return {
|
|
254
|
+
applied: true,
|
|
255
|
+
after,
|
|
256
|
+
...report,
|
|
257
|
+
removedKeys,
|
|
258
|
+
changedSkipped,
|
|
259
|
+
removedAt,
|
|
260
|
+
backupPath,
|
|
261
|
+
backupSha256,
|
|
262
|
+
restoreCommand: `cleo memory prune-traits --restore '${backupPath}' --sha256 ${backupSha256}`,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Reverse a {@link pruneReceiptTraits} apply from its backup file.
|
|
267
|
+
*
|
|
268
|
+
* Re-inserts each backed-up row verbatim (value, provenance, project stamp,
|
|
269
|
+
* scope, timestamps). A key that exists again is left untouched — a newer
|
|
270
|
+
* row always wins over a restore.
|
|
271
|
+
*
|
|
272
|
+
* @param nexusDb - Drizzle handle over the database holding `nexus_user_profile`.
|
|
273
|
+
* @param backupPath - Path from the prune receipt's `backupPath`.
|
|
274
|
+
* @param expectedSha256 - The receipt's `backupSha256`. When given, a backup
|
|
275
|
+
* whose bytes differ is refused before anything is written.
|
|
276
|
+
* @returns The restored and skipped keys plus the backup digest.
|
|
277
|
+
*
|
|
278
|
+
* @task T12543
|
|
279
|
+
*/
|
|
280
|
+
export async function restorePrunedTraits(nexusDb, backupPath, expectedSha256) {
|
|
281
|
+
const bytes = await readFile(backupPath, 'utf8');
|
|
282
|
+
const actualSha256 = createHash('sha256').update(bytes).digest('hex');
|
|
283
|
+
if (expectedSha256 !== undefined && actualSha256 !== expectedSha256.toLowerCase()) {
|
|
284
|
+
throw new Error(`E_BACKUP_DIGEST_MISMATCH: ${backupPath} has sha256 ${actualSha256}, the receipt says ${expectedSha256}; nothing restored`);
|
|
285
|
+
}
|
|
286
|
+
const backup = JSON.parse(bytes);
|
|
287
|
+
const traits = Array.isArray(backup.traits) ? backup.traits : [];
|
|
288
|
+
const restoredKeys = [];
|
|
289
|
+
const skippedExisting = [];
|
|
290
|
+
for (const trait of traits) {
|
|
291
|
+
if (await getUserProfileTrait(nexusDb, trait.traitKey)) {
|
|
292
|
+
skippedExisting.push(trait.traitKey);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
await upsertUserProfileTrait(nexusDb, trait);
|
|
296
|
+
restoredKeys.push(trait.traitKey);
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
backupPath,
|
|
300
|
+
backupSha256: actualSha256,
|
|
301
|
+
restoredKeys,
|
|
302
|
+
skippedExisting,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=user-profile-hygiene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-profile-hygiene.js","sourceRoot":"","sources":["../../src/nexus/user-profile-hygiene.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,WAAW,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAmBjG;;;;GAIG;AACH,MAAM,aAAa,GAA2B;IA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AC;IAC9D,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,MAAM,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvD,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACrC,SAAS;QACX,CAAC;QACD,MAAM,sBAAsB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC7C,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IACD,OAAO;QACL,UAAU;QACV,YAAY,EAAE,YAAY;QAC1B,YAAY;QACZ,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -19,11 +19,32 @@
|
|
|
19
19
|
* @task T1078
|
|
20
20
|
* @epic T1076
|
|
21
21
|
*/
|
|
22
|
-
import type { NexusProfileExportResult, NexusProfileGetResult, NexusProfileImportResult, NexusProfileReinforceResult, NexusProfileSupersedeResult, NexusProfileUpsertResult, NexusProfileViewResult, UserProfileTrait } from '@cleocode/contracts';
|
|
22
|
+
import type { NexusProfileExportResult, NexusProfileGetResult, NexusProfileImportResult, NexusProfileReinforceResult, NexusProfileSupersedeResult, NexusProfileUpsertResult, NexusProfileViewResult, UserProfileScope, UserProfileTrait } from '@cleocode/contracts';
|
|
23
23
|
import type { NodeSQLiteDatabase } from 'drizzle-orm/node-sqlite';
|
|
24
24
|
import { type EngineResult } from '../engine-result.js';
|
|
25
25
|
/** Type alias for the Drizzle nexus database instance. */
|
|
26
26
|
type NexusDb = NodeSQLiteDatabase;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the portable project id a trait derived under `projectRoot` is
|
|
29
|
+
* stamped with (T12543).
|
|
30
|
+
*
|
|
31
|
+
* Uses the tracked write-once `.cleo/project-id` (ADR-094) and falls back to
|
|
32
|
+
* the `projectId` in `.cleo/project-info.json`. Never derives an id from the
|
|
33
|
+
* path: a path hash differs per checkout and device, so it would silently
|
|
34
|
+
* re-scope traits. Returns `null` when neither identity is readable — the
|
|
35
|
+
* caller then records the trait as unknown-origin (never shown in prompts).
|
|
36
|
+
*
|
|
37
|
+
* @param projectRoot - Absolute project root the trait was derived in.
|
|
38
|
+
* @returns The portable project id, or `null` when none is declared.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const projectId = resolveTraitProjectId('/work/cleocode'); // 'c78d09c3a8ee'
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @task T12543
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveTraitProjectId(projectRoot: string): string | null;
|
|
27
48
|
/**
|
|
28
49
|
* Fetch a single user-profile trait by its key.
|
|
29
50
|
*
|
|
@@ -43,12 +64,34 @@ export declare function getUserProfileTrait(nexusDb: NexusDb, traitKey: string):
|
|
|
43
64
|
* The `firstObservedAt` field is preserved from the existing row on update.
|
|
44
65
|
*
|
|
45
66
|
* @param nexusDb - Drizzle nexus database handle.
|
|
67
|
+
* `projectId` and `scope` (T12543) default to `null` (unknown origin) and
|
|
68
|
+
* `'project'`; the whole row — value and visibility — is replaced together.
|
|
69
|
+
* A `project`-scoped write never replaces an existing `user`-scoped row.
|
|
70
|
+
*
|
|
46
71
|
* @param trait - Trait to insert or replace. `firstObservedAt` and
|
|
47
72
|
* `lastReinforcedAt` should be ISO 8601 strings; they are
|
|
48
73
|
* stored as canonical TEXT ISO-8601 in the consolidated
|
|
49
74
|
* `nexus_user_profile` table (T11578 · AC3).
|
|
50
75
|
*/
|
|
51
76
|
export declare function upsertUserProfileTrait(nexusDb: NexusDb, trait: UserProfileTrait): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Explicitly set the visibility scope of an existing trait (T12543).
|
|
79
|
+
*
|
|
80
|
+
* The only path that can promote a trait to user-global (`user`, visible in
|
|
81
|
+
* every project) or demote one back to `project`. Value, provenance and the
|
|
82
|
+
* project stamp are unchanged.
|
|
83
|
+
*
|
|
84
|
+
* @param nexusDb - Drizzle nexus database handle.
|
|
85
|
+
* @param traitKey - Key of the trait to re-scope.
|
|
86
|
+
* @param scope - New scope.
|
|
87
|
+
* @returns The previous scope, or `null` when no such trait exists.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* await setUserProfileTraitScope(db, 'prefers-zero-deps', 'user');
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function setUserProfileTraitScope(nexusDb: NexusDb, traitKey: string, scope: UserProfileScope): Promise<UserProfileScope | null>;
|
|
52
95
|
/**
|
|
53
96
|
* Increment the reinforcement count for an existing trait and boost its
|
|
54
97
|
* confidence.
|
|
@@ -80,6 +123,14 @@ export declare function listUserProfile(nexusDb: NexusDb, opts?: {
|
|
|
80
123
|
minConfidence?: number;
|
|
81
124
|
/** Include superseded (deprecated) traits. Defaults to false. */
|
|
82
125
|
includeSuperseded?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Restrict to the traits visible in one project's prompts (T12543):
|
|
128
|
+
* `user`-scoped traits plus `project` traits stamped with this portable
|
|
129
|
+
* project id. `null` = the project has no declared identity, so only
|
|
130
|
+
* user-global traits are returned. Omit to list every row (admin view,
|
|
131
|
+
* export) — unknown-origin rows included.
|
|
132
|
+
*/
|
|
133
|
+
visibleInProject?: string | null;
|
|
83
134
|
}): Promise<UserProfileTrait[]>;
|
|
84
135
|
/**
|
|
85
136
|
* Mark a trait as superseded by another, implementing the T1139 supersession
|
|
@@ -101,7 +152,7 @@ export declare function nexusProfileGet(traitKey: string): Promise<EngineResult<
|
|
|
101
152
|
export declare function nexusProfileImport(path?: string): Promise<EngineResult<NexusProfileImportResult>>;
|
|
102
153
|
export declare function nexusProfileExport(path?: string): Promise<EngineResult<NexusProfileExportResult>>;
|
|
103
154
|
export declare function nexusProfileReinforce(traitKey: string, source?: string): Promise<EngineResult<NexusProfileReinforceResult>>;
|
|
104
|
-
export declare function nexusProfileUpsert(trait: Pick<UserProfileTrait, 'traitKey' | 'traitValue' | 'confidence' | 'source' | 'derivedFromMessageId'>): Promise<EngineResult<NexusProfileUpsertResult>>;
|
|
155
|
+
export declare function nexusProfileUpsert(trait: Pick<UserProfileTrait, 'traitKey' | 'traitValue' | 'confidence' | 'source' | 'derivedFromMessageId' | 'scope'>): Promise<EngineResult<NexusProfileUpsertResult>>;
|
|
105
156
|
export declare function nexusProfileSupersede(oldKey: string, newKey: string): Promise<EngineResult<NexusProfileSupersedeResult>>;
|
|
106
157
|
export {};
|
|
107
158
|
//# sourceMappingURL=user-profile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-profile.d.ts","sourceRoot":"","sources":["../../src/nexus/user-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"user-profile.d.ts","sourceRoot":"","sources":["../../src/nexus/user-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,C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