@cleocode/core 2026.3.59 → 2026.3.61
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/adapter-registry.js +64 -0
- package/dist/adapters/adapter-registry.js.map +1 -0
- package/dist/adapters/discovery.js +83 -0
- package/dist/adapters/discovery.js.map +1 -0
- package/dist/adapters/index.js +9 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/manager.js +260 -0
- package/dist/adapters/manager.js.map +1 -0
- package/dist/admin/export-tasks.js +171 -0
- package/dist/admin/export-tasks.js.map +1 -0
- package/dist/admin/export.js +103 -0
- package/dist/admin/export.js.map +1 -0
- package/dist/admin/help.js +106 -0
- package/dist/admin/help.js.map +1 -0
- package/dist/admin/import-tasks.js +182 -0
- package/dist/admin/import-tasks.js.map +1 -0
- package/dist/admin/import.js +129 -0
- package/dist/admin/import.js.map +1 -0
- package/dist/admin/index.js +13 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/adrs/find.js +134 -0
- package/dist/adrs/find.js.map +1 -0
- package/dist/adrs/index.js +15 -0
- package/dist/adrs/index.js.map +1 -0
- package/dist/adrs/link-pipeline.js +160 -0
- package/dist/adrs/link-pipeline.js.map +1 -0
- package/dist/adrs/list.js +43 -0
- package/dist/adrs/list.js.map +1 -0
- package/dist/adrs/parse.js +51 -0
- package/dist/adrs/parse.js.map +1 -0
- package/dist/adrs/show.js +22 -0
- package/dist/adrs/show.js.map +1 -0
- package/dist/adrs/sync.js +188 -0
- package/dist/adrs/sync.js.map +1 -0
- package/dist/adrs/types.js +9 -0
- package/dist/adrs/types.js.map +1 -0
- package/dist/adrs/validate.js +57 -0
- package/dist/adrs/validate.js.map +1 -0
- package/dist/agents/agent-registry.js +288 -0
- package/dist/agents/agent-registry.js.map +1 -0
- package/dist/agents/agent-schema.js +85 -0
- package/dist/agents/agent-schema.js.map +1 -0
- package/dist/agents/capacity.js +116 -0
- package/dist/agents/capacity.js.map +1 -0
- package/dist/agents/execution-learning.js +474 -0
- package/dist/agents/execution-learning.js.map +1 -0
- package/dist/agents/health-monitor.js +217 -0
- package/dist/agents/health-monitor.js.map +1 -0
- package/dist/agents/index.js +29 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/registry.js +314 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/agents/retry.js +229 -0
- package/dist/agents/retry.js.map +1 -0
- package/dist/audit-prune.js +94 -0
- package/dist/audit-prune.js.map +1 -0
- package/dist/audit.js +68 -0
- package/dist/audit.js.map +1 -0
- package/dist/backfill/index.js +229 -0
- package/dist/backfill/index.js.map +1 -0
- package/dist/bootstrap.d.ts +2 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +367 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/caamp/adapter.js +434 -0
- package/dist/caamp/adapter.js.map +1 -0
- package/dist/caamp/capability-check.js +38 -0
- package/dist/caamp/capability-check.js.map +1 -0
- package/dist/caamp/index.js +23 -0
- package/dist/caamp/index.js.map +1 -0
- package/dist/caamp-init.js +16 -0
- package/dist/caamp-init.js.map +1 -0
- package/dist/cleo.d.ts +40 -0
- package/dist/cleo.d.ts.map +1 -1
- package/dist/cleo.js +267 -0
- package/dist/cleo.js.map +1 -0
- package/dist/codebase-map/analyzers/architecture.js +130 -0
- package/dist/codebase-map/analyzers/architecture.js.map +1 -0
- package/dist/codebase-map/analyzers/concerns.js +122 -0
- package/dist/codebase-map/analyzers/concerns.js.map +1 -0
- package/dist/codebase-map/analyzers/conventions.js +149 -0
- package/dist/codebase-map/analyzers/conventions.js.map +1 -0
- package/dist/codebase-map/analyzers/integrations.js +108 -0
- package/dist/codebase-map/analyzers/integrations.js.map +1 -0
- package/dist/codebase-map/analyzers/stack.js +117 -0
- package/dist/codebase-map/analyzers/stack.js.map +1 -0
- package/dist/codebase-map/analyzers/structure.js +137 -0
- package/dist/codebase-map/analyzers/structure.js.map +1 -0
- package/dist/codebase-map/analyzers/testing.js +118 -0
- package/dist/codebase-map/analyzers/testing.js.map +1 -0
- package/dist/codebase-map/index.js +57 -0
- package/dist/codebase-map/index.js.map +1 -0
- package/dist/codebase-map/store.js +122 -0
- package/dist/codebase-map/store.js.map +1 -0
- package/dist/codebase-map/summary.js +152 -0
- package/dist/codebase-map/summary.js.map +1 -0
- package/dist/compliance/index.js +288 -0
- package/dist/compliance/index.js.map +1 -0
- package/dist/compliance/protocol-enforcement.js +332 -0
- package/dist/compliance/protocol-enforcement.js.map +1 -0
- package/dist/compliance/protocol-rules.js +786 -0
- package/dist/compliance/protocol-rules.js.map +1 -0
- package/dist/compliance/protocol-types.js +80 -0
- package/dist/compliance/protocol-types.js.map +1 -0
- package/dist/compliance/store.js +53 -0
- package/dist/compliance/store.js.map +1 -0
- package/dist/config/build-config.js +29 -0
- package/dist/config/build-config.js.map +1 -0
- package/dist/config.js +370 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.js +18 -0
- package/dist/constants.js.map +1 -0
- package/dist/context/index.js +137 -0
- package/dist/context/index.js.map +1 -0
- package/dist/engine-result.js +12 -0
- package/dist/engine-result.js.map +1 -0
- package/dist/error-catalog.js +404 -0
- package/dist/error-catalog.js.map +1 -0
- package/dist/error-registry.js +393 -0
- package/dist/error-registry.js.map +1 -0
- package/dist/errors.js +167 -0
- package/dist/errors.js.map +1 -0
- package/dist/hooks/handlers/error-hooks.js +43 -0
- package/dist/hooks/handlers/error-hooks.js.map +1 -0
- package/dist/hooks/handlers/file-hooks.js +80 -0
- package/dist/hooks/handlers/file-hooks.js.map +1 -0
- package/dist/hooks/handlers/index.js +19 -0
- package/dist/hooks/handlers/index.js.map +1 -0
- package/dist/hooks/handlers/mcp-hooks.js +80 -0
- package/dist/hooks/handlers/mcp-hooks.js.map +1 -0
- package/dist/hooks/handlers/session-hooks.js +73 -0
- package/dist/hooks/handlers/session-hooks.js.map +1 -0
- package/dist/hooks/handlers/task-hooks.js +63 -0
- package/dist/hooks/handlers/task-hooks.js.map +1 -0
- package/dist/hooks/index.js +13 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/payload-schemas.js +163 -0
- package/dist/hooks/payload-schemas.js.map +1 -0
- package/dist/hooks/provider-hooks.js +34 -0
- package/dist/hooks/provider-hooks.js.map +1 -0
- package/dist/hooks/registry.js +176 -0
- package/dist/hooks/registry.js.map +1 -0
- package/dist/hooks/types.js +62 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/hooks.js +136 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.js +193 -35
- package/dist/index.js.map +3 -3
- package/dist/init.js +711 -0
- package/dist/init.js.map +1 -0
- package/dist/inject/index.js +82 -0
- package/dist/inject/index.js.map +1 -0
- package/dist/injection.js +343 -0
- package/dist/injection.js.map +1 -0
- package/dist/intelligence/adaptive-validation.js +497 -0
- package/dist/intelligence/adaptive-validation.js.map +1 -0
- package/dist/intelligence/impact.js +675 -0
- package/dist/intelligence/impact.js.map +1 -0
- package/dist/intelligence/index.js +22 -0
- package/dist/intelligence/index.js.map +1 -0
- package/dist/intelligence/patterns.js +492 -0
- package/dist/intelligence/patterns.js.map +1 -0
- package/dist/intelligence/prediction.js +499 -0
- package/dist/intelligence/prediction.js.map +1 -0
- package/dist/intelligence/types.js +13 -0
- package/dist/intelligence/types.js.map +1 -0
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +267 -0
- package/dist/internal.js.map +1 -0
- package/dist/issue/create.js +121 -0
- package/dist/issue/create.js.map +1 -0
- package/dist/issue/diagnostics.js +59 -0
- package/dist/issue/diagnostics.js.map +1 -0
- package/dist/issue/index.js +10 -0
- package/dist/issue/index.js.map +1 -0
- package/dist/issue/template-parser.js +267 -0
- package/dist/issue/template-parser.js.map +1 -0
- package/dist/json-schema-validator.js +76 -0
- package/dist/json-schema-validator.js.map +1 -0
- package/dist/lib/index.js +10 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/retry.js +152 -0
- package/dist/lib/retry.js.map +1 -0
- package/dist/lifecycle/chain-composition.js +152 -0
- package/dist/lifecycle/chain-composition.js.map +1 -0
- package/dist/lifecycle/chain-store.js +246 -0
- package/dist/lifecycle/chain-store.js.map +1 -0
- package/dist/lifecycle/consolidate-rcasd.js +352 -0
- package/dist/lifecycle/consolidate-rcasd.js.map +1 -0
- package/dist/lifecycle/default-chain.js +167 -0
- package/dist/lifecycle/default-chain.js.map +1 -0
- package/dist/lifecycle/evidence.js +180 -0
- package/dist/lifecycle/evidence.js.map +1 -0
- package/dist/lifecycle/frontmatter.js +363 -0
- package/dist/lifecycle/frontmatter.js.map +1 -0
- package/dist/lifecycle/index.js +753 -0
- package/dist/lifecycle/index.js.map +1 -0
- package/dist/lifecycle/pipeline.js +656 -0
- package/dist/lifecycle/pipeline.js.map +1 -0
- package/dist/lifecycle/rcasd-index.js +326 -0
- package/dist/lifecycle/rcasd-index.js.map +1 -0
- package/dist/lifecycle/rcasd-paths.js +220 -0
- package/dist/lifecycle/rcasd-paths.js.map +1 -0
- package/dist/lifecycle/resume.js +864 -0
- package/dist/lifecycle/resume.js.map +1 -0
- package/dist/lifecycle/stage-artifacts.js +94 -0
- package/dist/lifecycle/stage-artifacts.js.map +1 -0
- package/dist/lifecycle/stages.js +534 -0
- package/dist/lifecycle/stages.js.map +1 -0
- package/dist/lifecycle/state-machine.js +516 -0
- package/dist/lifecycle/state-machine.js.map +1 -0
- package/dist/lifecycle/tessera-engine.js +249 -0
- package/dist/lifecycle/tessera-engine.js.map +1 -0
- package/dist/logger.js +140 -0
- package/dist/logger.js.map +1 -0
- package/dist/mcp/index.js +146 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/memory/auto-extract.js +143 -0
- package/dist/memory/auto-extract.js.map +1 -0
- package/dist/memory/brain-embedding.js +49 -0
- package/dist/memory/brain-embedding.js.map +1 -0
- package/dist/memory/brain-lifecycle.js +298 -0
- package/dist/memory/brain-lifecycle.js.map +1 -0
- package/dist/memory/brain-links.js +148 -0
- package/dist/memory/brain-links.js.map +1 -0
- package/dist/memory/brain-migration.js +149 -0
- package/dist/memory/brain-migration.js.map +1 -0
- package/dist/memory/brain-reasoning.js +215 -0
- package/dist/memory/brain-reasoning.js.map +1 -0
- package/dist/memory/brain-retrieval.js +474 -0
- package/dist/memory/brain-retrieval.js.map +1 -0
- package/dist/memory/brain-row-types.js +10 -0
- package/dist/memory/brain-row-types.js.map +1 -0
- package/dist/memory/brain-search.js +519 -0
- package/dist/memory/brain-search.js.map +1 -0
- package/dist/memory/brain-similarity.js +145 -0
- package/dist/memory/brain-similarity.js.map +1 -0
- package/dist/memory/claude-mem-migration.js +277 -0
- package/dist/memory/claude-mem-migration.js.map +1 -0
- package/dist/memory/decisions.js +148 -0
- package/dist/memory/decisions.js.map +1 -0
- package/dist/memory/engine-compat.js +1030 -0
- package/dist/memory/engine-compat.js.map +1 -0
- package/dist/memory/index.js +773 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/learnings.js +121 -0
- package/dist/memory/learnings.js.map +1 -0
- package/dist/memory/memory-bridge.js +289 -0
- package/dist/memory/memory-bridge.js.map +1 -0
- package/dist/memory/patterns.js +122 -0
- package/dist/memory/patterns.js.map +1 -0
- package/dist/memory/pipeline-manifest-sqlite.js +975 -0
- package/dist/memory/pipeline-manifest-sqlite.js.map +1 -0
- package/dist/memory/session-memory.js +226 -0
- package/dist/memory/session-memory.js.map +1 -0
- package/dist/metrics/ab-test.js +260 -0
- package/dist/metrics/ab-test.js.map +1 -0
- package/dist/metrics/aggregation.js +363 -0
- package/dist/metrics/aggregation.js.map +1 -0
- package/dist/metrics/common.js +64 -0
- package/dist/metrics/common.js.map +1 -0
- package/dist/metrics/enums.js +78 -0
- package/dist/metrics/enums.js.map +1 -0
- package/dist/metrics/index.js +19 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/model-provider-registry.js +88 -0
- package/dist/metrics/model-provider-registry.js.map +1 -0
- package/dist/metrics/otel-integration.js +263 -0
- package/dist/metrics/otel-integration.js.map +1 -0
- package/dist/metrics/provider-detection.js +103 -0
- package/dist/metrics/provider-detection.js.map +1 -0
- package/dist/metrics/token-estimation.js +253 -0
- package/dist/metrics/token-estimation.js.map +1 -0
- package/dist/metrics/token-service.js +450 -0
- package/dist/metrics/token-service.js.map +1 -0
- package/dist/migration/agent-outputs.js +316 -0
- package/dist/migration/agent-outputs.js.map +1 -0
- package/dist/migration/checksum.js +92 -0
- package/dist/migration/checksum.js.map +1 -0
- package/dist/migration/index.js +282 -0
- package/dist/migration/index.js.map +1 -0
- package/dist/migration/logger.js +360 -0
- package/dist/migration/logger.js.map +1 -0
- package/dist/migration/preflight.js +9 -0
- package/dist/migration/preflight.js.map +1 -0
- package/dist/migration/state.js +421 -0
- package/dist/migration/state.js.map +1 -0
- package/dist/migration/validate.js +241 -0
- package/dist/migration/validate.js.map +1 -0
- package/dist/nexus/deps.js +375 -0
- package/dist/nexus/deps.js.map +1 -0
- package/dist/nexus/discover.js +288 -0
- package/dist/nexus/discover.js.map +1 -0
- package/dist/nexus/hash.js +10 -0
- package/dist/nexus/hash.js.map +1 -0
- package/dist/nexus/index.js +38 -0
- package/dist/nexus/index.js.map +1 -0
- package/dist/nexus/migrate-json-to-sqlite.js +115 -0
- package/dist/nexus/migrate-json-to-sqlite.js.map +1 -0
- package/dist/nexus/permissions.js +105 -0
- package/dist/nexus/permissions.js.map +1 -0
- package/dist/nexus/query.js +175 -0
- package/dist/nexus/query.js.map +1 -0
- package/dist/nexus/registry.js +584 -0
- package/dist/nexus/registry.js.map +1 -0
- package/dist/nexus/sharing/index.js +288 -0
- package/dist/nexus/sharing/index.js.map +1 -0
- package/dist/nexus/transfer-types.js +8 -0
- package/dist/nexus/transfer-types.js.map +1 -0
- package/dist/nexus/transfer.js +263 -0
- package/dist/nexus/transfer.js.map +1 -0
- package/dist/observability/index.js +103 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/log-filter.js +63 -0
- package/dist/observability/log-filter.js.map +1 -0
- package/dist/observability/log-parser.js +99 -0
- package/dist/observability/log-parser.js.map +1 -0
- package/dist/observability/log-reader.js +139 -0
- package/dist/observability/log-reader.js.map +1 -0
- package/dist/observability/types.js +19 -0
- package/dist/observability/types.js.map +1 -0
- package/dist/orchestration/analyze.js +107 -0
- package/dist/orchestration/analyze.js.map +1 -0
- package/dist/orchestration/bootstrap.js +132 -0
- package/dist/orchestration/bootstrap.js.map +1 -0
- package/dist/orchestration/context.js +56 -0
- package/dist/orchestration/context.js.map +1 -0
- package/dist/orchestration/critical-path.js +100 -0
- package/dist/orchestration/critical-path.js.map +1 -0
- package/dist/orchestration/index.js +286 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/parallel.js +89 -0
- package/dist/orchestration/parallel.js.map +1 -0
- package/dist/orchestration/protocol-validators.js +524 -0
- package/dist/orchestration/protocol-validators.js.map +1 -0
- package/dist/orchestration/skill-ops.js +98 -0
- package/dist/orchestration/skill-ops.js.map +1 -0
- package/dist/orchestration/status.js +107 -0
- package/dist/orchestration/status.js.map +1 -0
- package/dist/orchestration/unblock.js +103 -0
- package/dist/orchestration/unblock.js.map +1 -0
- package/dist/orchestration/validate-spawn.js +67 -0
- package/dist/orchestration/validate-spawn.js.map +1 -0
- package/dist/orchestration/waves.js +86 -0
- package/dist/orchestration/waves.js.map +1 -0
- package/dist/otel/index.js +163 -0
- package/dist/otel/index.js.map +1 -0
- package/dist/output.js +132 -0
- package/dist/output.js.map +1 -0
- package/dist/pagination.js +61 -0
- package/dist/pagination.js.map +1 -0
- package/dist/paths.js +337 -0
- package/dist/paths.js.map +1 -0
- package/dist/phases/deps.js +369 -0
- package/dist/phases/deps.js.map +1 -0
- package/dist/phases/index.js +349 -0
- package/dist/phases/index.js.map +1 -0
- package/dist/pipeline/index.js +10 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/phase.js +45 -0
- package/dist/pipeline/phase.js.map +1 -0
- package/dist/platform.js +211 -0
- package/dist/platform.js.map +1 -0
- package/dist/project-info.js +84 -0
- package/dist/project-info.js.map +1 -0
- package/dist/reconciliation/index.js +10 -0
- package/dist/reconciliation/index.js.map +1 -0
- package/dist/reconciliation/link-store.js +129 -0
- package/dist/reconciliation/link-store.js.map +1 -0
- package/dist/reconciliation/reconciliation-engine.js +298 -0
- package/dist/reconciliation/reconciliation-engine.js.map +1 -0
- package/dist/release/artifacts.js +427 -0
- package/dist/release/artifacts.js.map +1 -0
- package/dist/release/changelog-writer.js +151 -0
- package/dist/release/changelog-writer.js.map +1 -0
- package/dist/release/channel.js +144 -0
- package/dist/release/channel.js.map +1 -0
- package/dist/release/ci.js +166 -0
- package/dist/release/ci.js.map +1 -0
- package/dist/release/github-pr.js +225 -0
- package/dist/release/github-pr.js.map +1 -0
- package/dist/release/guards.js +116 -0
- package/dist/release/guards.js.map +1 -0
- package/dist/release/index.js +22 -0
- package/dist/release/index.js.map +1 -0
- package/dist/release/release-config.js +158 -0
- package/dist/release/release-config.js.map +1 -0
- package/dist/release/release-manifest.js +1019 -0
- package/dist/release/release-manifest.js.map +1 -0
- package/dist/release/version-bump.js +255 -0
- package/dist/release/version-bump.js.map +1 -0
- package/dist/remote/index.js +257 -0
- package/dist/remote/index.js.map +1 -0
- package/dist/repair.d.ts +7 -0
- package/dist/repair.d.ts.map +1 -1
- package/dist/repair.js +89 -0
- package/dist/repair.js.map +1 -0
- package/dist/research/index.js +2 -0
- package/dist/research/index.js.map +1 -0
- package/dist/roadmap/index.js +59 -0
- package/dist/roadmap/index.js.map +1 -0
- package/dist/routing/capability-matrix.js +1550 -0
- package/dist/routing/capability-matrix.js.map +1 -0
- package/dist/routing/index.js +9 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +1178 -0
- package/dist/scaffold.js.map +1 -0
- package/dist/schema-management.js +295 -0
- package/dist/schema-management.js.map +1 -0
- package/dist/security/index.js +9 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/input-sanitization.js +321 -0
- package/dist/security/input-sanitization.js.map +1 -0
- package/dist/sequence/index.js +295 -0
- package/dist/sequence/index.js.map +1 -0
- package/dist/sessions/assumptions.js +54 -0
- package/dist/sessions/assumptions.js.map +1 -0
- package/dist/sessions/briefing.js +377 -0
- package/dist/sessions/briefing.js.map +1 -0
- package/dist/sessions/context-alert.js +222 -0
- package/dist/sessions/context-alert.js.map +1 -0
- package/dist/sessions/context-inject.js +61 -0
- package/dist/sessions/context-inject.js.map +1 -0
- package/dist/sessions/context-monitor.js +98 -0
- package/dist/sessions/context-monitor.js.map +1 -0
- package/dist/sessions/decisions.js +65 -0
- package/dist/sessions/decisions.js.map +1 -0
- package/dist/sessions/find.js +63 -0
- package/dist/sessions/find.js.map +1 -0
- package/dist/sessions/handoff.js +328 -0
- package/dist/sessions/handoff.js.map +1 -0
- package/dist/sessions/hitl-warnings.js +254 -0
- package/dist/sessions/hitl-warnings.js.map +1 -0
- package/dist/sessions/index.js +318 -0
- package/dist/sessions/index.js.map +1 -0
- package/dist/sessions/session-archive.js +40 -0
- package/dist/sessions/session-archive.js.map +1 -0
- package/dist/sessions/session-cleanup.js +59 -0
- package/dist/sessions/session-cleanup.js.map +1 -0
- package/dist/sessions/session-drift.js +134 -0
- package/dist/sessions/session-drift.js.map +1 -0
- package/dist/sessions/session-enforcement.js +144 -0
- package/dist/sessions/session-enforcement.js.map +1 -0
- package/dist/sessions/session-grade.js +253 -0
- package/dist/sessions/session-grade.js.map +1 -0
- package/dist/sessions/session-history.js +42 -0
- package/dist/sessions/session-history.js.map +1 -0
- package/dist/sessions/session-id.js +81 -0
- package/dist/sessions/session-id.js.map +1 -0
- package/dist/sessions/session-memory-bridge.js +52 -0
- package/dist/sessions/session-memory-bridge.js.map +1 -0
- package/dist/sessions/session-show.js +24 -0
- package/dist/sessions/session-show.js.map +1 -0
- package/dist/sessions/session-stats.js +69 -0
- package/dist/sessions/session-stats.js.map +1 -0
- package/dist/sessions/session-suspend.js +39 -0
- package/dist/sessions/session-suspend.js.map +1 -0
- package/dist/sessions/session-switch.js +51 -0
- package/dist/sessions/session-switch.js.map +1 -0
- package/dist/sessions/session-view.js +76 -0
- package/dist/sessions/session-view.js.map +1 -0
- package/dist/sessions/statusline-setup.js +85 -0
- package/dist/sessions/statusline-setup.js.map +1 -0
- package/dist/sessions/types.js +8 -0
- package/dist/sessions/types.js.map +1 -0
- package/dist/signaldock/claude-code-transport.js +107 -0
- package/dist/signaldock/claude-code-transport.js.map +1 -0
- package/dist/signaldock/factory.js +25 -0
- package/dist/signaldock/factory.js.map +1 -0
- package/dist/signaldock/index.js +9 -0
- package/dist/signaldock/index.js.map +1 -0
- package/dist/signaldock/signaldock-transport.js +122 -0
- package/dist/signaldock/signaldock-transport.js.map +1 -0
- package/dist/signaldock/transport.js +11 -0
- package/dist/signaldock/transport.js.map +1 -0
- package/dist/signaldock/types.js +11 -0
- package/dist/signaldock/types.js.map +1 -0
- package/dist/skills/agents/config.js +94 -0
- package/dist/skills/agents/config.js.map +1 -0
- package/dist/skills/agents/install.js +116 -0
- package/dist/skills/agents/install.js.map +1 -0
- package/dist/skills/agents/registry.js +161 -0
- package/dist/skills/agents/registry.js.map +1 -0
- package/dist/skills/discovery.js +333 -0
- package/dist/skills/discovery.js.map +1 -0
- package/dist/skills/dispatch.js +347 -0
- package/dist/skills/dispatch.js.map +1 -0
- package/dist/skills/dynamic-skill-generator.js +100 -0
- package/dist/skills/dynamic-skill-generator.js.map +1 -0
- package/dist/skills/index.js +44 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/injection/subagent.js +195 -0
- package/dist/skills/injection/subagent.js.map +1 -0
- package/dist/skills/injection/token.js +260 -0
- package/dist/skills/injection/token.js.map +1 -0
- package/dist/skills/install.js +40 -0
- package/dist/skills/install.js.map +1 -0
- package/dist/skills/manifests/contribution.js +175 -0
- package/dist/skills/manifests/contribution.js.map +1 -0
- package/dist/skills/manifests/research.js +281 -0
- package/dist/skills/manifests/research.js.map +1 -0
- package/dist/skills/manifests/resolver.js +146 -0
- package/dist/skills/manifests/resolver.js.map +1 -0
- package/dist/skills/marketplace.js +90 -0
- package/dist/skills/marketplace.js.map +1 -0
- package/dist/skills/orchestrator/spawn.js +178 -0
- package/dist/skills/orchestrator/spawn.js.map +1 -0
- package/dist/skills/orchestrator/startup.js +451 -0
- package/dist/skills/orchestrator/startup.js.map +1 -0
- package/dist/skills/orchestrator/validator.js +301 -0
- package/dist/skills/orchestrator/validator.js.map +1 -0
- package/dist/skills/precedence-integration.js +73 -0
- package/dist/skills/precedence-integration.js.map +1 -0
- package/dist/skills/precedence-types.js +16 -0
- package/dist/skills/precedence-types.js.map +1 -0
- package/dist/skills/routing-table.js +63 -0
- package/dist/skills/routing-table.js.map +1 -0
- package/dist/skills/skill-paths.js +220 -0
- package/dist/skills/skill-paths.js.map +1 -0
- package/dist/skills/test-utility.js +55 -0
- package/dist/skills/test-utility.js.map +1 -0
- package/dist/skills/types.js +118 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/skills/validation.js +183 -0
- package/dist/skills/validation.js.map +1 -0
- package/dist/skills/version.js +57 -0
- package/dist/skills/version.js.map +1 -0
- package/dist/snapshot/index.js +188 -0
- package/dist/snapshot/index.js.map +1 -0
- package/dist/spawn/adapter-registry.js +246 -0
- package/dist/spawn/adapter-registry.js.map +1 -0
- package/dist/spawn/index.js +10 -0
- package/dist/spawn/index.js.map +1 -0
- package/dist/stats/index.js +341 -0
- package/dist/stats/index.js.map +1 -0
- package/dist/stats/workflow-telemetry.js +400 -0
- package/dist/stats/workflow-telemetry.js.map +1 -0
- package/dist/sticky/archive.js +47 -0
- package/dist/sticky/archive.js.map +1 -0
- package/dist/sticky/convert.js +235 -0
- package/dist/sticky/convert.js.map +1 -0
- package/dist/sticky/create.js +48 -0
- package/dist/sticky/create.js.map +1 -0
- package/dist/sticky/id.js +35 -0
- package/dist/sticky/id.js.map +1 -0
- package/dist/sticky/index.js +16 -0
- package/dist/sticky/index.js.map +1 -0
- package/dist/sticky/list.js +44 -0
- package/dist/sticky/list.js.map +1 -0
- package/dist/sticky/purge.js +45 -0
- package/dist/sticky/purge.js.map +1 -0
- package/dist/sticky/show.js +42 -0
- package/dist/sticky/show.js.map +1 -0
- package/dist/sticky/types.js +10 -0
- package/dist/sticky/types.js.map +1 -0
- package/dist/store/atomic.js +167 -0
- package/dist/store/atomic.js.map +1 -0
- package/dist/store/backup.js +94 -0
- package/dist/store/backup.js.map +1 -0
- package/dist/store/brain-accessor.js +397 -0
- package/dist/store/brain-accessor.js.map +1 -0
- package/dist/store/brain-schema.js +215 -0
- package/dist/store/brain-schema.js.map +1 -0
- package/dist/store/brain-sqlite.js +271 -0
- package/dist/store/brain-sqlite.js.map +1 -0
- package/dist/store/cache.js +168 -0
- package/dist/store/cache.js.map +1 -0
- package/dist/store/chain-schema.js +51 -0
- package/dist/store/chain-schema.js.map +1 -0
- package/dist/store/converters.js +122 -0
- package/dist/store/converters.js.map +1 -0
- package/dist/store/cross-db-cleanup.js +169 -0
- package/dist/store/cross-db-cleanup.js.map +1 -0
- package/dist/store/data-accessor.js +26 -0
- package/dist/store/data-accessor.js.map +1 -0
- package/dist/store/data-safety-central.js +269 -0
- package/dist/store/data-safety-central.js.map +1 -0
- package/dist/store/data-safety.js +274 -0
- package/dist/store/data-safety.js.map +1 -0
- package/dist/store/db-helpers.js +223 -0
- package/dist/store/db-helpers.js.map +1 -0
- package/dist/store/export.js +155 -0
- package/dist/store/export.js.map +1 -0
- package/dist/store/file-utils.js +270 -0
- package/dist/store/file-utils.js.map +1 -0
- package/dist/store/git-checkpoint.js +365 -0
- package/dist/store/git-checkpoint.js.map +1 -0
- package/dist/store/import-logging.js +139 -0
- package/dist/store/import-logging.js.map +1 -0
- package/dist/store/import-remap.js +145 -0
- package/dist/store/import-remap.js.map +1 -0
- package/dist/store/import-sort.js +121 -0
- package/dist/store/import-sort.js.map +1 -0
- package/dist/store/index.js +28 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/json.js +208 -0
- package/dist/store/json.js.map +1 -0
- package/dist/store/lifecycle-store.js +249 -0
- package/dist/store/lifecycle-store.js.map +1 -0
- package/dist/store/lock.js +70 -0
- package/dist/store/lock.js.map +1 -0
- package/dist/store/migration-sqlite.js +676 -0
- package/dist/store/migration-sqlite.js.map +1 -0
- package/dist/store/nexus-schema.js +62 -0
- package/dist/store/nexus-schema.js.map +1 -0
- package/dist/store/nexus-sqlite.js +217 -0
- package/dist/store/nexus-sqlite.js.map +1 -0
- package/dist/store/nexus-validation-schemas.js +40 -0
- package/dist/store/nexus-validation-schemas.js.map +1 -0
- package/dist/store/parsers.js +37 -0
- package/dist/store/parsers.js.map +1 -0
- package/dist/store/project-detect.js +457 -0
- package/dist/store/project-detect.js.map +1 -0
- package/dist/store/provider.js +101 -0
- package/dist/store/provider.js.map +1 -0
- package/dist/store/safety-data-accessor.js +243 -0
- package/dist/store/safety-data-accessor.js.map +1 -0
- package/dist/store/schema.js +7 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/session-store.js +219 -0
- package/dist/store/session-store.js.map +1 -0
- package/dist/store/sqlite-backup.js +105 -0
- package/dist/store/sqlite-backup.js.map +1 -0
- package/dist/store/sqlite-data-accessor.js +734 -0
- package/dist/store/sqlite-data-accessor.js.map +1 -0
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +500 -0
- package/dist/store/sqlite.js.map +1 -0
- package/dist/store/status-registry.js +8 -0
- package/dist/store/status-registry.js.map +1 -0
- package/dist/store/task-store.js +348 -0
- package/dist/store/task-store.js.map +1 -0
- package/dist/store/tasks-schema.js +604 -0
- package/dist/store/tasks-schema.js.map +1 -0
- package/dist/store/typed-query.js +15 -0
- package/dist/store/typed-query.js.map +1 -0
- package/dist/store/validation-schemas.js +278 -0
- package/dist/store/validation-schemas.js.map +1 -0
- package/dist/system/archive-analytics.js +277 -0
- package/dist/system/archive-analytics.js.map +1 -0
- package/dist/system/archive-stats.js +64 -0
- package/dist/system/archive-stats.js.map +1 -0
- package/dist/system/audit.js +145 -0
- package/dist/system/audit.js.map +1 -0
- package/dist/system/backup.js +99 -0
- package/dist/system/backup.js.map +1 -0
- package/dist/system/cleanup.js +134 -0
- package/dist/system/cleanup.js.map +1 -0
- package/dist/system/health.js +1054 -0
- package/dist/system/health.js.map +1 -0
- package/dist/system/index.js +18 -0
- package/dist/system/index.js.map +1 -0
- package/dist/system/inject-generate.js +122 -0
- package/dist/system/inject-generate.js.map +1 -0
- package/dist/system/labels.js +38 -0
- package/dist/system/labels.js.map +1 -0
- package/dist/system/metrics.js +61 -0
- package/dist/system/metrics.js.map +1 -0
- package/dist/system/migrate.js +43 -0
- package/dist/system/migrate.js.map +1 -0
- package/dist/system/platform-paths.js +80 -0
- package/dist/system/platform-paths.js.map +1 -0
- package/dist/system/runtime.js +161 -0
- package/dist/system/runtime.js.map +1 -0
- package/dist/system/safestop.js +99 -0
- package/dist/system/safestop.js.map +1 -0
- package/dist/system/storage-preflight.js +123 -0
- package/dist/system/storage-preflight.js.map +1 -0
- package/dist/task-work/index.js +155 -0
- package/dist/task-work/index.js.map +1 -0
- package/dist/tasks/add.js +594 -0
- package/dist/tasks/add.js.map +1 -0
- package/dist/tasks/analyze.js +85 -0
- package/dist/tasks/analyze.js.map +1 -0
- package/dist/tasks/archive.js +90 -0
- package/dist/tasks/archive.js.map +1 -0
- package/dist/tasks/atomicity.js +83 -0
- package/dist/tasks/atomicity.js.map +1 -0
- package/dist/tasks/cancel-ops.js +83 -0
- package/dist/tasks/cancel-ops.js.map +1 -0
- package/dist/tasks/complete.js +235 -0
- package/dist/tasks/complete.js.map +1 -0
- package/dist/tasks/crossref-extract.js +73 -0
- package/dist/tasks/crossref-extract.js.map +1 -0
- package/dist/tasks/delete-preview.js +192 -0
- package/dist/tasks/delete-preview.js.map +1 -0
- package/dist/tasks/delete.js +120 -0
- package/dist/tasks/delete.js.map +1 -0
- package/dist/tasks/deletion-strategy.js +200 -0
- package/dist/tasks/deletion-strategy.js.map +1 -0
- package/dist/tasks/dependency-check.js +278 -0
- package/dist/tasks/dependency-check.js.map +1 -0
- package/dist/tasks/deps-ready.js +32 -0
- package/dist/tasks/deps-ready.js.map +1 -0
- package/dist/tasks/enforcement.js +89 -0
- package/dist/tasks/enforcement.js.map +1 -0
- package/dist/tasks/epic-enforcement.js +294 -0
- package/dist/tasks/epic-enforcement.js.map +1 -0
- package/dist/tasks/find.js +148 -0
- package/dist/tasks/find.js.map +1 -0
- package/dist/tasks/graph-cache.js +127 -0
- package/dist/tasks/graph-cache.js.map +1 -0
- package/dist/tasks/graph-ops.js +171 -0
- package/dist/tasks/graph-ops.js.map +1 -0
- package/dist/tasks/graph-rag.js +328 -0
- package/dist/tasks/graph-rag.js.map +1 -0
- package/dist/tasks/hierarchy-policy.js +149 -0
- package/dist/tasks/hierarchy-policy.js.map +1 -0
- package/dist/tasks/hierarchy.js +185 -0
- package/dist/tasks/hierarchy.js.map +1 -0
- package/dist/tasks/id-generator.js +65 -0
- package/dist/tasks/id-generator.js.map +1 -0
- package/dist/tasks/index.js +14 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/tasks/labels.js +52 -0
- package/dist/tasks/labels.js.map +1 -0
- package/dist/tasks/list.js +68 -0
- package/dist/tasks/list.js.map +1 -0
- package/dist/tasks/phase-tracking.js +133 -0
- package/dist/tasks/phase-tracking.js.map +1 -0
- package/dist/tasks/pipeline-stage.js +248 -0
- package/dist/tasks/pipeline-stage.js.map +1 -0
- package/dist/tasks/plan.js +268 -0
- package/dist/tasks/plan.js.map +1 -0
- package/dist/tasks/relates.js +89 -0
- package/dist/tasks/relates.js.map +1 -0
- package/dist/tasks/reparent.d.ts +38 -0
- package/dist/tasks/reparent.d.ts.map +1 -0
- package/dist/tasks/show.js +78 -0
- package/dist/tasks/show.js.map +1 -0
- package/dist/tasks/size-weighting.js +86 -0
- package/dist/tasks/size-weighting.js.map +1 -0
- package/dist/tasks/staleness.js +86 -0
- package/dist/tasks/staleness.js.map +1 -0
- package/dist/tasks/task-ops.js +1340 -0
- package/dist/tasks/task-ops.js.map +1 -0
- package/dist/tasks/update.js +271 -0
- package/dist/tasks/update.js.map +1 -0
- package/dist/templates/index.js +10 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/parser.js +254 -0
- package/dist/templates/parser.js.map +1 -0
- package/dist/ui/aliases.js +153 -0
- package/dist/ui/aliases.js.map +1 -0
- package/dist/ui/changelog.js +184 -0
- package/dist/ui/changelog.js.map +1 -0
- package/dist/ui/command-registry.js +168 -0
- package/dist/ui/command-registry.js.map +1 -0
- package/dist/ui/flags.js +94 -0
- package/dist/ui/flags.js.map +1 -0
- package/dist/ui/index.js +24 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/injection-legacy.d.ts +26 -0
- package/dist/ui/injection-legacy.d.ts.map +1 -0
- package/dist/ui/injection-legacy.js +42 -0
- package/dist/ui/injection-legacy.js.map +1 -0
- package/dist/upgrade.js +901 -0
- package/dist/upgrade.js.map +1 -0
- package/dist/validation/chain-validation.js +146 -0
- package/dist/validation/chain-validation.js.map +1 -0
- package/dist/validation/compliance.js +155 -0
- package/dist/validation/compliance.js.map +1 -0
- package/dist/validation/docs-sync.js +212 -0
- package/dist/validation/docs-sync.js.map +1 -0
- package/dist/validation/doctor/checks.js +1069 -0
- package/dist/validation/doctor/checks.js.map +1 -0
- package/dist/validation/doctor/index.js +9 -0
- package/dist/validation/doctor/index.js.map +1 -0
- package/dist/validation/doctor/project-cache.js +160 -0
- package/dist/validation/doctor/project-cache.js.map +1 -0
- package/dist/validation/doctor/utils.js +155 -0
- package/dist/validation/doctor/utils.js.map +1 -0
- package/dist/validation/engine.js +902 -0
- package/dist/validation/engine.js.map +1 -0
- package/dist/validation/gap-check.js +175 -0
- package/dist/validation/gap-check.js.map +1 -0
- package/dist/validation/index.js +40 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/manifest.js +237 -0
- package/dist/validation/manifest.js.map +1 -0
- package/dist/validation/operation-gate-validators.js +724 -0
- package/dist/validation/operation-gate-validators.js.map +1 -0
- package/dist/validation/operation-verification-gates.js +532 -0
- package/dist/validation/operation-verification-gates.js.map +1 -0
- package/dist/validation/param-utils.js +139 -0
- package/dist/validation/param-utils.js.map +1 -0
- package/dist/validation/protocol-common.js +300 -0
- package/dist/validation/protocol-common.js.map +1 -0
- package/dist/validation/protocols/consensus.js +71 -0
- package/dist/validation/protocols/consensus.js.map +1 -0
- package/dist/validation/protocols/contribution.js +59 -0
- package/dist/validation/protocols/contribution.js.map +1 -0
- package/dist/validation/protocols/decomposition.js +59 -0
- package/dist/validation/protocols/decomposition.js.map +1 -0
- package/dist/validation/protocols/implementation.js +59 -0
- package/dist/validation/protocols/implementation.js.map +1 -0
- package/dist/validation/protocols/release-protocol.js +60 -0
- package/dist/validation/protocols/release-protocol.js.map +1 -0
- package/dist/validation/protocols/research.js +77 -0
- package/dist/validation/protocols/research.js.map +1 -0
- package/dist/validation/protocols/specification.js +84 -0
- package/dist/validation/protocols/specification.js.map +1 -0
- package/dist/validation/protocols/testing-protocol.js +70 -0
- package/dist/validation/protocols/testing-protocol.js.map +1 -0
- package/dist/validation/protocols/validation-protocol.js +70 -0
- package/dist/validation/protocols/validation-protocol.js.map +1 -0
- package/dist/validation/schema-integrity.js +170 -0
- package/dist/validation/schema-integrity.js.map +1 -0
- package/dist/validation/schema-validator.js +176 -0
- package/dist/validation/schema-validator.js.map +1 -0
- package/dist/validation/validate-ops.js +937 -0
- package/dist/validation/validate-ops.js.map +1 -0
- package/dist/validation/validation-rules.js +226 -0
- package/dist/validation/validation-rules.js.map +1 -0
- package/dist/validation/verification.js +321 -0
- package/dist/validation/verification.js.map +1 -0
- package/package.json +5 -5
- package/src/agents/__tests__/agent-registry.test.ts +1 -1
- package/src/bootstrap.ts +171 -30
- package/src/cleo.ts +103 -2
- package/src/internal.ts +1 -1
- package/src/repair.ts +53 -2
- package/src/scaffold.ts +24 -2
- package/src/store/sqlite.ts +72 -5
package/src/bootstrap.ts
CHANGED
|
@@ -41,7 +41,8 @@ export interface BootstrapOptions {
|
|
|
41
41
|
* Bootstrap the global CLEO directory structure and install templates.
|
|
42
42
|
*
|
|
43
43
|
* Creates:
|
|
44
|
-
* - ~/.cleo/templates/CLEO-INJECTION.md (
|
|
44
|
+
* - ~/.local/share/cleo/templates/CLEO-INJECTION.md (XDG primary)
|
|
45
|
+
* - ~/.cleo/templates/CLEO-INJECTION.md (legacy sync)
|
|
45
46
|
* - ~/.agents/AGENTS.md with CAAMP injection block
|
|
46
47
|
*
|
|
47
48
|
* This is idempotent — safe to call multiple times.
|
|
@@ -60,7 +61,7 @@ export async function bootstrapGlobalCleo(options?: BootstrapOptions): Promise<B
|
|
|
60
61
|
// Best-effort — don't fail bootstrap if cleanup fails
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
// Step 1: Ensure global templates
|
|
64
|
+
// Step 1: Ensure global templates (XDG + legacy sync)
|
|
64
65
|
await ensureGlobalTemplatesBootstrap(ctx, options?.packageRoot);
|
|
65
66
|
|
|
66
67
|
// Step 2: CAAMP injection into ~/.agents/AGENTS.md
|
|
@@ -78,11 +79,30 @@ export async function bootstrapGlobalCleo(options?: BootstrapOptions): Promise<B
|
|
|
78
79
|
// Step 6: Install provider adapters
|
|
79
80
|
await installProviderAdapters(ctx, options?.packageRoot);
|
|
80
81
|
|
|
82
|
+
// Step 7: Verify injection chain health
|
|
83
|
+
await verifyBootstrapHealth(ctx);
|
|
84
|
+
|
|
81
85
|
return ctx;
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
// ── Step 1: Global templates ─────────────────────────────────────────
|
|
85
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Write template content to a destination path, creating parent dirs as needed.
|
|
92
|
+
* Returns true if written, false if dry-run.
|
|
93
|
+
*/
|
|
94
|
+
async function writeTemplateTo(
|
|
95
|
+
content: string,
|
|
96
|
+
destPath: string,
|
|
97
|
+
isDryRun: boolean,
|
|
98
|
+
): Promise<boolean> {
|
|
99
|
+
if (isDryRun) return false;
|
|
100
|
+
const { dirname } = await import('node:path');
|
|
101
|
+
await mkdir(dirname(destPath), { recursive: true });
|
|
102
|
+
await writeFile(destPath, content);
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
86
106
|
async function ensureGlobalTemplatesBootstrap(
|
|
87
107
|
ctx: BootstrapContext,
|
|
88
108
|
packageRootOverride?: string,
|
|
@@ -93,43 +113,85 @@ async function ensureGlobalTemplatesBootstrap(
|
|
|
93
113
|
await mkdir(globalTemplatesDir, { recursive: true });
|
|
94
114
|
}
|
|
95
115
|
|
|
116
|
+
// Resolve template content from bundled file or embedded fallback
|
|
117
|
+
let templateContent: string | null = null;
|
|
118
|
+
|
|
96
119
|
try {
|
|
97
120
|
const pkgRoot = packageRootOverride ?? getPackageRoot();
|
|
98
121
|
const templatePath = join(pkgRoot, 'templates', 'CLEO-INJECTION.md');
|
|
99
122
|
if (existsSync(templatePath)) {
|
|
100
|
-
|
|
101
|
-
const destPath = join(globalTemplatesDir, 'CLEO-INJECTION.md');
|
|
102
|
-
if (!ctx.isDryRun) {
|
|
103
|
-
await writeFile(destPath, content);
|
|
104
|
-
}
|
|
105
|
-
ctx.created.push(
|
|
106
|
-
`~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? 'would refresh' : 'refreshed'})`,
|
|
107
|
-
);
|
|
108
|
-
} else {
|
|
109
|
-
// Fallback: try using the injection content generator
|
|
110
|
-
try {
|
|
111
|
-
const { getInjectionTemplateContent } = await import('./injection.js');
|
|
112
|
-
const content = getInjectionTemplateContent();
|
|
113
|
-
if (content) {
|
|
114
|
-
const destPath = join(globalTemplatesDir, 'CLEO-INJECTION.md');
|
|
115
|
-
if (!ctx.isDryRun) {
|
|
116
|
-
await writeFile(destPath, content);
|
|
117
|
-
}
|
|
118
|
-
ctx.created.push(
|
|
119
|
-
`~/.cleo/templates/CLEO-INJECTION.md (${ctx.isDryRun ? 'would refresh' : 'refreshed'} from embedded)`,
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
} catch {
|
|
123
|
-
ctx.warnings.push('Could not refresh CLEO-INJECTION.md template');
|
|
124
|
-
}
|
|
123
|
+
templateContent = readFileSync(templatePath, 'utf-8');
|
|
125
124
|
}
|
|
126
125
|
} catch {
|
|
126
|
+
// Fall through to embedded fallback
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!templateContent) {
|
|
130
|
+
try {
|
|
131
|
+
const { getInjectionTemplateContent } = await import('./injection.js');
|
|
132
|
+
templateContent = getInjectionTemplateContent() ?? null;
|
|
133
|
+
} catch {
|
|
134
|
+
ctx.warnings.push('Could not refresh CLEO-INJECTION.md template');
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (!templateContent) {
|
|
127
140
|
ctx.warnings.push('Could not refresh CLEO-INJECTION.md template');
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Write to XDG primary path
|
|
145
|
+
const xdgDest = join(globalTemplatesDir, 'CLEO-INJECTION.md');
|
|
146
|
+
const xdgWritten = await writeTemplateTo(templateContent, xdgDest, ctx.isDryRun);
|
|
147
|
+
ctx.created.push(
|
|
148
|
+
`${getCleoTemplatesTildePath()}/CLEO-INJECTION.md (${xdgWritten ? 'refreshed' : 'would refresh'})`,
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
// Sync to legacy ~/.cleo/templates/ if it exists (backward compat for
|
|
152
|
+
// project AGENTS.md files that still reference the old path)
|
|
153
|
+
const home = homedir();
|
|
154
|
+
const legacyTemplatesDir = join(home, '.cleo', 'templates');
|
|
155
|
+
if (legacyTemplatesDir !== globalTemplatesDir && existsSync(join(home, '.cleo'))) {
|
|
156
|
+
const legacyDest = join(legacyTemplatesDir, 'CLEO-INJECTION.md');
|
|
157
|
+
const legacyWritten = await writeTemplateTo(templateContent, legacyDest, ctx.isDryRun);
|
|
158
|
+
if (legacyWritten) {
|
|
159
|
+
ctx.created.push('~/.cleo/templates/CLEO-INJECTION.md (legacy sync)');
|
|
160
|
+
}
|
|
128
161
|
}
|
|
129
162
|
}
|
|
130
163
|
|
|
131
164
|
// ── Step 2: CAAMP injection into ~/.agents/AGENTS.md ─────────────────
|
|
132
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Sanitize a CAAMP-managed file by removing orphaned content outside
|
|
168
|
+
* CAAMP blocks. This fixes corruption from failed CAAMP consolidation
|
|
169
|
+
* (e.g. partial old block removal leaving `TION.md` fragments).
|
|
170
|
+
*
|
|
171
|
+
* Strategy: keep ONLY content inside valid CAAMP blocks + any non-CAAMP
|
|
172
|
+
* user content that doesn't look like an orphaned reference fragment.
|
|
173
|
+
*/
|
|
174
|
+
function sanitizeCaampFile(content: string): string {
|
|
175
|
+
// Remove any duplicate <!-- CAAMP:END --> markers
|
|
176
|
+
let cleaned = content.replace(/(<!-- CAAMP:END -->)\s*(<!-- CAAMP:END -->)/g, '$1');
|
|
177
|
+
|
|
178
|
+
// Remove orphaned content between CAAMP:END and the next CAAMP:START (or EOF)
|
|
179
|
+
// that looks like a fragment of a CLEO reference (e.g. "TION.md", "INJECTION.md")
|
|
180
|
+
cleaned = cleaned.replace(
|
|
181
|
+
/<!-- CAAMP:END -->\s*[A-Z][A-Za-z-]*\.md\s*(?:<!-- CAAMP:END -->)?/g,
|
|
182
|
+
'<!-- CAAMP:END -->',
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
// Remove any lines that are just orphaned .md filename fragments
|
|
186
|
+
// (leftover from partial CAAMP block removal)
|
|
187
|
+
cleaned = cleaned.replace(/^[A-Z][A-Za-z-]*\.md\s*$/gm, '');
|
|
188
|
+
|
|
189
|
+
// Collapse multiple blank lines
|
|
190
|
+
cleaned = cleaned.replace(/\n{3,}/g, '\n\n');
|
|
191
|
+
|
|
192
|
+
return cleaned.trim() + '\n';
|
|
193
|
+
}
|
|
194
|
+
|
|
133
195
|
async function injectAgentsHub(ctx: BootstrapContext): Promise<void> {
|
|
134
196
|
const globalAgentsDir = getAgentsHome();
|
|
135
197
|
const globalAgentsMd = join(globalAgentsDir, 'AGENTS.md');
|
|
@@ -143,21 +205,39 @@ async function injectAgentsHub(ctx: BootstrapContext): Promise<void> {
|
|
|
143
205
|
await mkdir(globalAgentsDir, { recursive: true });
|
|
144
206
|
|
|
145
207
|
// Strip legacy CLEO blocks (versioned markers from pre-CAAMP era)
|
|
208
|
+
// AND sanitize CAAMP corruption (orphaned fragments from bad consolidation)
|
|
146
209
|
if (existsSync(globalAgentsMd)) {
|
|
147
210
|
const content = await readFile(globalAgentsMd, 'utf8');
|
|
211
|
+
|
|
212
|
+
// Step A: Remove legacy <!-- CLEO:START -->...<!-- CLEO:END --> blocks
|
|
148
213
|
const stripped = content.replace(
|
|
149
214
|
/\n?<!-- CLEO:START[^>]*-->[\s\S]*?<!-- CLEO:END -->\n?/g,
|
|
150
215
|
'',
|
|
151
216
|
);
|
|
152
|
-
|
|
153
|
-
|
|
217
|
+
|
|
218
|
+
// Step B: Sanitize CAAMP corruption (orphaned fragments, duplicate markers)
|
|
219
|
+
const sanitized = sanitizeCaampFile(stripped);
|
|
220
|
+
|
|
221
|
+
if (sanitized !== content) {
|
|
222
|
+
await writeFile(globalAgentsMd, sanitized, 'utf8');
|
|
223
|
+
ctx.created.push('~/.agents/AGENTS.md (sanitized CAAMP corruption)');
|
|
154
224
|
}
|
|
155
225
|
}
|
|
156
226
|
|
|
157
|
-
// CAAMP
|
|
227
|
+
// CAAMP inject() is idempotent — writes the current XDG template reference
|
|
158
228
|
const templateRef = `@${getCleoTemplatesTildePath()}/CLEO-INJECTION.md`;
|
|
159
229
|
const action = await inject(globalAgentsMd, templateRef);
|
|
160
230
|
ctx.created.push(`~/.agents/AGENTS.md (${action})`);
|
|
231
|
+
|
|
232
|
+
// Post-inject validation: verify the file is clean
|
|
233
|
+
const postContent = await readFile(globalAgentsMd, 'utf8');
|
|
234
|
+
const caampBlocks = postContent.match(/<!-- CAAMP:START -->/g);
|
|
235
|
+
const caampEnds = postContent.match(/<!-- CAAMP:END -->/g);
|
|
236
|
+
if (caampBlocks && caampEnds && caampBlocks.length !== caampEnds.length) {
|
|
237
|
+
ctx.warnings.push(
|
|
238
|
+
`~/.agents/AGENTS.md has mismatched CAAMP markers (${caampBlocks.length} START vs ${caampEnds.length} END)`,
|
|
239
|
+
);
|
|
240
|
+
}
|
|
161
241
|
} else {
|
|
162
242
|
ctx.created.push('~/.agents/AGENTS.md (would create/update CAAMP block)');
|
|
163
243
|
}
|
|
@@ -330,3 +410,64 @@ async function installProviderAdapters(
|
|
|
330
410
|
);
|
|
331
411
|
}
|
|
332
412
|
}
|
|
413
|
+
|
|
414
|
+
// ── Step 7: Post-bootstrap health verification ───────────────────────
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Verify the injection chain is intact after bootstrap.
|
|
418
|
+
* Checks:
|
|
419
|
+
* 1. XDG template exists and has a version header
|
|
420
|
+
* 2. Legacy template (if present) matches XDG version
|
|
421
|
+
* 3. ~/.agents/AGENTS.md references the correct template path
|
|
422
|
+
* 4. No orphaned content in AGENTS.md
|
|
423
|
+
*/
|
|
424
|
+
async function verifyBootstrapHealth(ctx: BootstrapContext): Promise<void> {
|
|
425
|
+
if (ctx.isDryRun) return;
|
|
426
|
+
|
|
427
|
+
try {
|
|
428
|
+
const xdgTemplatePath = join(getCleoTemplatesDir(), 'CLEO-INJECTION.md');
|
|
429
|
+
const agentsMd = join(getAgentsHome(), 'AGENTS.md');
|
|
430
|
+
|
|
431
|
+
// Check 1: XDG template exists
|
|
432
|
+
if (!existsSync(xdgTemplatePath)) {
|
|
433
|
+
ctx.warnings.push('Health: XDG template missing after bootstrap');
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const xdgContent = await readFile(xdgTemplatePath, 'utf8');
|
|
438
|
+
const xdgVersion = xdgContent.match(/^Version:\s*(.+)$/m)?.[1]?.trim();
|
|
439
|
+
|
|
440
|
+
// Check 2: Legacy template version sync
|
|
441
|
+
const home = homedir();
|
|
442
|
+
const legacyTemplatePath = join(home, '.cleo', 'templates', 'CLEO-INJECTION.md');
|
|
443
|
+
if (existsSync(legacyTemplatePath)) {
|
|
444
|
+
const legacyContent = await readFile(legacyTemplatePath, 'utf8');
|
|
445
|
+
const legacyVersion = legacyContent.match(/^Version:\s*(.+)$/m)?.[1]?.trim();
|
|
446
|
+
if (legacyVersion !== xdgVersion) {
|
|
447
|
+
ctx.warnings.push(
|
|
448
|
+
`Health: Legacy template version (${legacyVersion}) != XDG version (${xdgVersion})`,
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// Check 3: AGENTS.md references the correct path
|
|
454
|
+
if (existsSync(agentsMd)) {
|
|
455
|
+
const agentsContent = await readFile(agentsMd, 'utf8');
|
|
456
|
+
const expectedRef = `@${getCleoTemplatesTildePath()}/CLEO-INJECTION.md`;
|
|
457
|
+
if (!agentsContent.includes(expectedRef)) {
|
|
458
|
+
ctx.warnings.push(`Health: ~/.agents/AGENTS.md does not reference ${expectedRef}`);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// Check 4: No orphaned .md fragments outside CAAMP blocks
|
|
462
|
+
const outsideCaamp = agentsContent.replace(
|
|
463
|
+
/<!-- CAAMP:START -->[\s\S]*?<!-- CAAMP:END -->/g,
|
|
464
|
+
'',
|
|
465
|
+
);
|
|
466
|
+
if (/[A-Z][A-Za-z-]*\.md/.test(outsideCaamp)) {
|
|
467
|
+
ctx.warnings.push('Health: ~/.agents/AGENTS.md has orphaned content outside CAAMP blocks');
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
} catch {
|
|
471
|
+
// Health check is non-critical — don't fail bootstrap
|
|
472
|
+
}
|
|
473
|
+
}
|
package/src/cleo.ts
CHANGED
|
@@ -31,6 +31,28 @@ import type {
|
|
|
31
31
|
import { exportTasks } from './admin/export.js';
|
|
32
32
|
import type { ImportParams } from './admin/import.js';
|
|
33
33
|
import { importTasks } from './admin/import.js';
|
|
34
|
+
// Agents
|
|
35
|
+
import {
|
|
36
|
+
type AgentCapacity,
|
|
37
|
+
type AgentHealthStatus,
|
|
38
|
+
type AgentInstanceRow,
|
|
39
|
+
checkAgentHealth,
|
|
40
|
+
deregisterAgent,
|
|
41
|
+
detectCrashedAgents,
|
|
42
|
+
getAgentCapacity,
|
|
43
|
+
heartbeat,
|
|
44
|
+
isOverloaded,
|
|
45
|
+
listAgentInstances,
|
|
46
|
+
type RegisterAgentOptions,
|
|
47
|
+
registerAgent,
|
|
48
|
+
} from './agents/index.js';
|
|
49
|
+
// Intelligence
|
|
50
|
+
import {
|
|
51
|
+
type BlastRadius,
|
|
52
|
+
calculateBlastRadius,
|
|
53
|
+
type ImpactReport,
|
|
54
|
+
predictImpact,
|
|
55
|
+
} from './intelligence/index.js';
|
|
34
56
|
// Lifecycle
|
|
35
57
|
import {
|
|
36
58
|
checkGate,
|
|
@@ -127,6 +149,8 @@ import {
|
|
|
127
149
|
} from './sticky/index.js';
|
|
128
150
|
// Store
|
|
129
151
|
import { getAccessor } from './store/data-accessor.js';
|
|
152
|
+
// Task Work (start/stop/current)
|
|
153
|
+
import { currentTask, startTask, stopTask } from './task-work/index.js';
|
|
130
154
|
// Tasks
|
|
131
155
|
import { addTask } from './tasks/add.js';
|
|
132
156
|
import { archiveTasks } from './tasks/archive.js';
|
|
@@ -179,10 +203,21 @@ export interface TasksAPI {
|
|
|
179
203
|
complete(params: { taskId: string; notes?: string }): Promise<unknown>;
|
|
180
204
|
delete(params: { taskId: string; force?: boolean }): Promise<unknown>;
|
|
181
205
|
archive(params?: { before?: string; taskIds?: string[]; dryRun?: boolean }): Promise<unknown>;
|
|
206
|
+
/** Start working on a specific task (sets focus). */
|
|
207
|
+
start(taskId: string): Promise<unknown>;
|
|
208
|
+
/** Stop working on the current task (clears focus). */
|
|
209
|
+
stop(): Promise<{ previousTask: string | null }>;
|
|
210
|
+
/** Get the current task work state. */
|
|
211
|
+
current(): Promise<unknown>;
|
|
182
212
|
}
|
|
183
213
|
|
|
184
214
|
export interface SessionsAPI {
|
|
185
|
-
start(params: {
|
|
215
|
+
start(params: {
|
|
216
|
+
name: string;
|
|
217
|
+
scope: string;
|
|
218
|
+
agent?: string;
|
|
219
|
+
startTask?: string;
|
|
220
|
+
}): Promise<unknown>;
|
|
186
221
|
end(params?: { note?: string }): Promise<unknown>;
|
|
187
222
|
status(): Promise<unknown>;
|
|
188
223
|
resume(sessionId: string): Promise<unknown>;
|
|
@@ -324,6 +359,32 @@ export interface SyncAPI {
|
|
|
324
359
|
removeProviderLinks(providerId: string): Promise<number>;
|
|
325
360
|
}
|
|
326
361
|
|
|
362
|
+
export interface AgentsAPI {
|
|
363
|
+
/** Register a new agent instance. */
|
|
364
|
+
register(options: RegisterAgentOptions): Promise<AgentInstanceRow>;
|
|
365
|
+
/** Deregister an agent instance. */
|
|
366
|
+
deregister(agentId: string): Promise<AgentInstanceRow | null>;
|
|
367
|
+
/** Get health status for a specific agent. */
|
|
368
|
+
health(agentId: string): Promise<AgentHealthStatus | null>;
|
|
369
|
+
/** Detect agents that have crashed (missed heartbeats). */
|
|
370
|
+
detectCrashed(thresholdMs?: number): Promise<AgentInstanceRow[]>;
|
|
371
|
+
/** Record a heartbeat for an agent. */
|
|
372
|
+
recordHeartbeat(agentId: string): Promise<unknown>;
|
|
373
|
+
/** Get capacity info for an agent. */
|
|
374
|
+
capacity(agentId: string): Promise<AgentCapacity | null>;
|
|
375
|
+
/** Check if system is overloaded (available capacity below threshold). */
|
|
376
|
+
isOverloaded(threshold?: number): Promise<boolean>;
|
|
377
|
+
/** List all agent instances with optional filters. */
|
|
378
|
+
list(params?: { status?: string; agentType?: string }): Promise<AgentInstanceRow[]>;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export interface IntelligenceAPI {
|
|
382
|
+
/** Predict impact of a change description on related tasks. */
|
|
383
|
+
predictImpact(change: string): Promise<ImpactReport>;
|
|
384
|
+
/** Calculate blast radius for a task change. */
|
|
385
|
+
blastRadius(taskId: string): Promise<BlastRadius>;
|
|
386
|
+
}
|
|
387
|
+
|
|
327
388
|
// ============================================================================
|
|
328
389
|
// Init options
|
|
329
390
|
// ============================================================================
|
|
@@ -410,6 +471,9 @@ export class Cleo {
|
|
|
410
471
|
delete: (p) => deleteTask({ taskId: p.taskId, force: p.force }, root, store),
|
|
411
472
|
archive: (p) =>
|
|
412
473
|
archiveTasks({ before: p?.before, taskIds: p?.taskIds, dryRun: p?.dryRun }, root, store),
|
|
474
|
+
start: (taskId) => startTask(taskId, root, store),
|
|
475
|
+
stop: () => stopTask(root, store),
|
|
476
|
+
current: () => currentTask(root, store),
|
|
413
477
|
};
|
|
414
478
|
}
|
|
415
479
|
|
|
@@ -418,7 +482,12 @@ export class Cleo {
|
|
|
418
482
|
const root = this.projectRoot;
|
|
419
483
|
const store = this._store ?? undefined;
|
|
420
484
|
return {
|
|
421
|
-
start: (p) =>
|
|
485
|
+
start: (p) =>
|
|
486
|
+
startSession(
|
|
487
|
+
{ name: p.name, scope: p.scope, agent: p.agent, startTask: p.startTask },
|
|
488
|
+
root,
|
|
489
|
+
store,
|
|
490
|
+
),
|
|
422
491
|
end: (p) => endSession({ note: p?.note }, root, store),
|
|
423
492
|
status: () => sessionStatus(root, store),
|
|
424
493
|
resume: (id) => resumeSession(id, root, store),
|
|
@@ -570,6 +639,38 @@ export class Cleo {
|
|
|
570
639
|
};
|
|
571
640
|
}
|
|
572
641
|
|
|
642
|
+
// === Agents ===
|
|
643
|
+
get agents(): AgentsAPI {
|
|
644
|
+
const root = this.projectRoot;
|
|
645
|
+
return {
|
|
646
|
+
register: (opts) => registerAgent(opts, root),
|
|
647
|
+
deregister: (agentId) => deregisterAgent(agentId, root),
|
|
648
|
+
health: (agentId) => checkAgentHealth(agentId, undefined, root),
|
|
649
|
+
detectCrashed: (thresholdMs) => detectCrashedAgents(thresholdMs, root),
|
|
650
|
+
recordHeartbeat: (agentId) => heartbeat(agentId, root),
|
|
651
|
+
capacity: (agentId) => getAgentCapacity(agentId, root),
|
|
652
|
+
isOverloaded: (threshold) => isOverloaded(threshold, root),
|
|
653
|
+
list: (p) =>
|
|
654
|
+
listAgentInstances(
|
|
655
|
+
{
|
|
656
|
+
status: p?.status as 'active' | 'idle' | 'crashed' | undefined,
|
|
657
|
+
agentType: p?.agentType as import('./agents/index.js').AgentType | undefined,
|
|
658
|
+
},
|
|
659
|
+
root,
|
|
660
|
+
),
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// === Intelligence ===
|
|
665
|
+
get intelligence(): IntelligenceAPI {
|
|
666
|
+
const root = this.projectRoot;
|
|
667
|
+
const store = this._store ?? undefined;
|
|
668
|
+
return {
|
|
669
|
+
predictImpact: (change) => predictImpact(change, root, store ?? undefined),
|
|
670
|
+
blastRadius: (taskId) => calculateBlastRadius(taskId, store ?? undefined, root),
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
|
|
573
674
|
// === Sync (Task Reconciliation) ===
|
|
574
675
|
get sync(): SyncAPI {
|
|
575
676
|
const root = this.projectRoot;
|
package/src/internal.ts
CHANGED
|
@@ -98,7 +98,7 @@ export type {
|
|
|
98
98
|
RiskFactor,
|
|
99
99
|
ValidationPrediction,
|
|
100
100
|
} from './intelligence/types.js';
|
|
101
|
-
|
|
101
|
+
export { type AddIssueParams, type AddIssueResult, addIssue } from './issue/create.js';
|
|
102
102
|
// Issue
|
|
103
103
|
export { collectDiagnostics } from './issue/diagnostics.js';
|
|
104
104
|
// Lib — shared primitives
|
package/src/repair.ts
CHANGED
|
@@ -105,6 +105,56 @@ export async function repairMissingCompletedAt(
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Detect and add missing required columns on the tasks table.
|
|
110
|
+
* Uses PRAGMA table_info to check actual schema vs required columns.
|
|
111
|
+
*
|
|
112
|
+
* @see https://github.com/anthropics/cleo/issues/63
|
|
113
|
+
*/
|
|
114
|
+
export async function repairMissingColumns(
|
|
115
|
+
cwd: string | undefined,
|
|
116
|
+
dryRun: boolean,
|
|
117
|
+
): Promise<RepairAction> {
|
|
118
|
+
const { getDb } = await import('./store/sqlite.js');
|
|
119
|
+
const db = await getDb(cwd);
|
|
120
|
+
|
|
121
|
+
// getDb() already calls ensureRequiredColumns(), so if we get here
|
|
122
|
+
// the column should exist. But we still report the action for visibility.
|
|
123
|
+
const { sql } = await import('drizzle-orm');
|
|
124
|
+
const columns = db.all<{ name: string }>(sql`PRAGMA table_info(tasks)`);
|
|
125
|
+
const existingCols = new Set(columns.map((c: { name: string }) => c.name));
|
|
126
|
+
|
|
127
|
+
const missingCols = ['pipeline_stage'].filter((c) => !existingCols.has(c));
|
|
128
|
+
|
|
129
|
+
if (missingCols.length === 0) {
|
|
130
|
+
return {
|
|
131
|
+
action: 'fix_missing_columns',
|
|
132
|
+
status: 'skipped',
|
|
133
|
+
details: 'All required columns present on tasks table',
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (dryRun) {
|
|
138
|
+
return {
|
|
139
|
+
action: 'fix_missing_columns',
|
|
140
|
+
status: 'preview',
|
|
141
|
+
details: `Would add missing column(s): ${missingCols.join(', ')}`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Columns should already be added by ensureRequiredColumns() in getDb(),
|
|
146
|
+
// but apply again defensively.
|
|
147
|
+
for (const col of missingCols) {
|
|
148
|
+
db.run(sql.raw(`ALTER TABLE tasks ADD COLUMN ${col} text`));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
action: 'fix_missing_columns',
|
|
153
|
+
status: 'applied',
|
|
154
|
+
details: `Added missing column(s): ${missingCols.join(', ')}`,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
108
158
|
/**
|
|
109
159
|
* Run all repair functions.
|
|
110
160
|
* Returns all actions taken (or previewed in dry-run mode).
|
|
@@ -113,9 +163,10 @@ export async function runAllRepairs(
|
|
|
113
163
|
cwd: string | undefined,
|
|
114
164
|
dryRun: boolean,
|
|
115
165
|
): Promise<RepairAction[]> {
|
|
116
|
-
const [sizes, completedAt] = await Promise.all([
|
|
166
|
+
const [sizes, completedAt, columns] = await Promise.all([
|
|
117
167
|
repairMissingSizes(cwd, dryRun),
|
|
118
168
|
repairMissingCompletedAt(cwd, dryRun),
|
|
169
|
+
repairMissingColumns(cwd, dryRun),
|
|
119
170
|
]);
|
|
120
|
-
return [sizes, completedAt];
|
|
171
|
+
return [sizes, completedAt, columns];
|
|
121
172
|
}
|
package/src/scaffold.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { execFile } from 'node:child_process';
|
|
|
14
14
|
import { randomUUID } from 'node:crypto';
|
|
15
15
|
import { existsSync, constants as fsConstants, readFileSync, statSync } from 'node:fs';
|
|
16
16
|
import { access, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
17
|
+
import { homedir as getHomedir } from 'node:os';
|
|
17
18
|
import { dirname, join, resolve } from 'node:path';
|
|
18
19
|
import { fileURLToPath } from 'node:url';
|
|
19
20
|
import { promisify } from 'node:util';
|
|
@@ -1278,12 +1279,33 @@ export function checkGlobalTemplates(): CheckResult {
|
|
|
1278
1279
|
};
|
|
1279
1280
|
}
|
|
1280
1281
|
|
|
1282
|
+
// Check version sync between XDG and legacy paths
|
|
1283
|
+
const xdgContent = readFileSync(injectionPath, 'utf-8');
|
|
1284
|
+
const xdgVersion = xdgContent.match(/^Version:\s*(.+)$/m)?.[1]?.trim();
|
|
1285
|
+
const home = getHomedir();
|
|
1286
|
+
const legacyPath = join(home, '.cleo', 'templates', 'CLEO-INJECTION.md');
|
|
1287
|
+
|
|
1288
|
+
if (existsSync(legacyPath)) {
|
|
1289
|
+
const legacyContent = readFileSync(legacyPath, 'utf-8');
|
|
1290
|
+
const legacyVersion = legacyContent.match(/^Version:\s*(.+)$/m)?.[1]?.trim();
|
|
1291
|
+
if (legacyVersion && xdgVersion && legacyVersion !== xdgVersion) {
|
|
1292
|
+
return {
|
|
1293
|
+
id: 'global_templates',
|
|
1294
|
+
category: 'global',
|
|
1295
|
+
status: 'warning',
|
|
1296
|
+
message: `Legacy template version (${legacyVersion}) out of sync with XDG (${xdgVersion})`,
|
|
1297
|
+
details: { path: injectionPath, exists: true, xdgVersion, legacyVersion, legacyPath },
|
|
1298
|
+
fix: 'npm install -g @cleocode/cleo (reinstall syncs both paths)',
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1281
1303
|
return {
|
|
1282
1304
|
id: 'global_templates',
|
|
1283
1305
|
category: 'global',
|
|
1284
1306
|
status: 'passed',
|
|
1285
|
-
message:
|
|
1286
|
-
details: { path: injectionPath, exists: true },
|
|
1307
|
+
message: `Global injection template present (v${xdgVersion ?? 'unknown'})`,
|
|
1308
|
+
details: { path: injectionPath, exists: true, version: xdgVersion },
|
|
1287
1309
|
fix: null,
|
|
1288
1310
|
};
|
|
1289
1311
|
}
|
package/src/store/sqlite.ts
CHANGED
|
@@ -462,18 +462,48 @@ function runMigrations(nativeDb: DatabaseSync, db: NodeSQLiteDatabase<typeof sch
|
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
+
// Fix #63: Reconcile stale migration journal entries from older CLEO versions.
|
|
466
|
+
// When the DB has __drizzle_migrations entries whose hashes don't match ANY
|
|
467
|
+
// local migration file, drizzle's migrate() either throws or tries to re-run
|
|
468
|
+
// all migrations (causing "table already exists" errors). Fix by clearing stale
|
|
469
|
+
// entries and marking all local migrations as applied (tables already exist),
|
|
470
|
+
// then relying on ensureRequiredColumns() to patch any schema gaps.
|
|
471
|
+
if (tableExists(nativeDb, '__drizzle_migrations') && tableExists(nativeDb, 'tasks')) {
|
|
472
|
+
const localMigrations = readMigrationFiles({ migrationsFolder });
|
|
473
|
+
const localHashes = new Set(localMigrations.map((m) => m.hash));
|
|
474
|
+
const dbEntries = nativeDb.prepare('SELECT hash FROM "__drizzle_migrations"').all() as Array<{
|
|
475
|
+
hash: string;
|
|
476
|
+
}>;
|
|
477
|
+
const hasOrphanedEntries = dbEntries.some((e) => !localHashes.has(e.hash));
|
|
478
|
+
|
|
479
|
+
if (hasOrphanedEntries) {
|
|
480
|
+
const log = getLogger('sqlite');
|
|
481
|
+
log.warn(
|
|
482
|
+
{ orphaned: dbEntries.filter((e) => !localHashes.has(e.hash)).length },
|
|
483
|
+
'Detected stale migration journal entries from a previous CLEO version. Reconciling.',
|
|
484
|
+
);
|
|
485
|
+
// Clear all entries and mark every local migration as applied.
|
|
486
|
+
// The existing tables were created by the previous version's migrations,
|
|
487
|
+
// so we skip re-running them. ensureRequiredColumns() fills any schema gaps.
|
|
488
|
+
nativeDb.exec('DELETE FROM "__drizzle_migrations"');
|
|
489
|
+
for (const m of localMigrations) {
|
|
490
|
+
nativeDb.exec(
|
|
491
|
+
`INSERT INTO "__drizzle_migrations" ("hash", "created_at") VALUES ('${m.hash}', ${m.folderMillis})`,
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
465
497
|
// Run pending migrations via drizzle-orm/node-sqlite/migrator (synchronous).
|
|
466
498
|
// The new migrator handles its own transactions. T5185: retry on SQLITE_BUSY.
|
|
467
|
-
let lastError: unknown;
|
|
468
499
|
for (let attempt = 1; attempt <= MAX_MIGRATION_RETRIES; attempt++) {
|
|
469
500
|
try {
|
|
470
501
|
migrate(db, { migrationsFolder });
|
|
471
|
-
|
|
502
|
+
break;
|
|
472
503
|
} catch (err) {
|
|
473
504
|
if (!isSqliteBusy(err) || attempt === MAX_MIGRATION_RETRIES) {
|
|
474
505
|
throw err;
|
|
475
506
|
}
|
|
476
|
-
lastError = err;
|
|
477
507
|
const delay = Math.min(
|
|
478
508
|
MIGRATION_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1) * (1 + Math.random() * 0.5),
|
|
479
509
|
MIGRATION_RETRY_MAX_DELAY_MS,
|
|
@@ -481,8 +511,45 @@ function runMigrations(nativeDb: DatabaseSync, db: NodeSQLiteDatabase<typeof sch
|
|
|
481
511
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, Math.round(delay));
|
|
482
512
|
}
|
|
483
513
|
}
|
|
484
|
-
|
|
485
|
-
|
|
514
|
+
|
|
515
|
+
// Fix #63: Defensive column safety net — add any columns the schema expects
|
|
516
|
+
// but that are missing from the actual table. This catches gaps from stale
|
|
517
|
+
// migration journals, partial migrations, or version skew.
|
|
518
|
+
ensureRequiredColumns(nativeDb);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Required columns that MUST exist on the tasks table.
|
|
523
|
+
* Maps column name → ALTER TABLE ADD COLUMN DDL suffix.
|
|
524
|
+
* Only TEXT columns with no constraints are safe for ALTER TABLE ADD in SQLite.
|
|
525
|
+
*
|
|
526
|
+
* @see https://github.com/anthropics/cleo/issues/63
|
|
527
|
+
*/
|
|
528
|
+
const REQUIRED_TASK_COLUMNS: Array<{ name: string; ddl: string }> = [
|
|
529
|
+
{ name: 'pipeline_stage', ddl: 'text' },
|
|
530
|
+
];
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Ensure all required columns exist on the tasks table.
|
|
534
|
+
* Uses PRAGMA table_info to inspect the schema and adds any missing columns
|
|
535
|
+
* via ALTER TABLE ADD COLUMN. This is a safety net for databases where
|
|
536
|
+
* Drizzle migrations could not run due to journal corruption or version skew.
|
|
537
|
+
*
|
|
538
|
+
* @see https://github.com/anthropics/cleo/issues/63
|
|
539
|
+
*/
|
|
540
|
+
function ensureRequiredColumns(nativeDb: DatabaseSync): void {
|
|
541
|
+
if (!tableExists(nativeDb, 'tasks')) return;
|
|
542
|
+
|
|
543
|
+
const columns = nativeDb.prepare('PRAGMA table_info(tasks)').all() as Array<{ name: string }>;
|
|
544
|
+
const existingCols = new Set(columns.map((c) => c.name));
|
|
545
|
+
|
|
546
|
+
for (const req of REQUIRED_TASK_COLUMNS) {
|
|
547
|
+
if (!existingCols.has(req.name)) {
|
|
548
|
+
const log = getLogger('sqlite');
|
|
549
|
+
log.warn({ column: req.name }, `Adding missing column tasks.${req.name} via ALTER TABLE`);
|
|
550
|
+
nativeDb.exec(`ALTER TABLE tasks ADD COLUMN ${req.name} ${req.ddl}`);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
486
553
|
}
|
|
487
554
|
|
|
488
555
|
/**
|