@cleocode/core 2026.3.57 → 2026.3.58
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-schema.d.ts.map +1 -1
- package/dist/agents/agent-schema.js +80 -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.d.ts +223 -0
- package/dist/agents/execution-learning.d.ts.map +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +21 -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 +176 -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.d.ts +56 -0
- package/dist/backfill/index.d.ts.map +1 -0
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.js +260 -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.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.d.ts +47 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +287 -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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6567 -5024
- package/dist/index.js.map +4 -4
- 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.d.ts +151 -0
- package/dist/intelligence/adaptive-validation.d.ts.map +1 -0
- package/dist/intelligence/impact.js +499 -0
- package/dist/intelligence/impact.js.map +1 -0
- package/dist/intelligence/index.d.ts +5 -0
- package/dist/intelligence/index.d.ts.map +1 -1
- package/dist/intelligence/index.js +17 -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 +5 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +258 -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/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 +179 -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.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.js +1158 -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.d.ts.map +1 -1
- package/dist/sessions/session-enforcement.js +140 -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.d.ts +1 -0
- package/dist/stats/index.d.ts.map +1 -1
- package/dist/stats/index.js +339 -0
- package/dist/stats/index.js.map +1 -0
- package/dist/stats/workflow-telemetry.d.ts +74 -0
- package/dist/stats/workflow-telemetry.d.ts.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.d.ts.map +1 -1
- package/dist/store/brain-schema.js +212 -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.d.ts.map +1 -1
- package/dist/store/converters.js +120 -0
- package/dist/store/converters.js.map +1 -0
- package/dist/store/cross-db-cleanup.d.ts +58 -0
- package/dist/store/cross-db-cleanup.d.ts.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.d.ts.map +1 -1
- package/dist/store/db-helpers.js +221 -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.d.ts.map +1 -1
- package/dist/store/migration-sqlite.js +671 -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.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +742 -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 +489 -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.d.ts.map +1 -1
- package/dist/store/task-store.js +344 -0
- package/dist/store/task-store.js.map +1 -0
- package/dist/store/tasks-schema.d.ts +18 -3
- package/dist/store/tasks-schema.d.ts.map +1 -1
- package/dist/store/tasks-schema.js +574 -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.d.ts +32 -0
- package/dist/store/validation-schemas.d.ts.map +1 -1
- 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.d.ts +10 -1
- package/dist/tasks/add.d.ts.map +1 -1
- package/dist/tasks/add.js +510 -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.d.ts.map +1 -1
- package/dist/tasks/complete.js +224 -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.d.ts +22 -0
- package/dist/tasks/enforcement.d.ts.map +1 -0
- package/dist/tasks/enforcement.js +82 -0
- package/dist/tasks/enforcement.js.map +1 -0
- package/dist/tasks/epic-enforcement.d.ts +138 -0
- package/dist/tasks/epic-enforcement.d.ts.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.d.ts +1 -1
- package/dist/tasks/index.d.ts.map +1 -1
- 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.d.ts +112 -0
- package/dist/tasks/pipeline-stage.d.ts.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.d.ts +2 -0
- package/dist/tasks/update.d.ts.map +1 -1
- package/dist/tasks/update.js +243 -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/migrations/drizzle-brain/20260321000001_t033-brain-indexes/migration.sql +12 -0
- package/migrations/drizzle-brain/20260321000001_t033-brain-indexes/snapshot.json +1232 -0
- package/migrations/drizzle-tasks/20260321000000_t033-connection-health/migration.sql +518 -0
- package/migrations/drizzle-tasks/20260321000000_t033-connection-health/snapshot.json +4312 -0
- package/migrations/drizzle-tasks/20260321000002_t060-pipeline-stage-binding/migration.sql +82 -0
- package/migrations/drizzle-tasks/20260321000002_t060-pipeline-stage-binding/snapshot.json +9 -0
- package/package.json +5 -5
- package/src/agents/__tests__/execution-learning.test.ts +684 -0
- package/src/agents/__tests__/registry.test.ts +30 -2
- package/src/agents/agent-schema.ts +5 -0
- package/src/agents/execution-learning.ts +675 -0
- package/src/agents/index.ts +13 -0
- package/src/backfill/index.ts +282 -0
- package/src/bootstrap.ts +1 -1
- package/src/config.ts +126 -0
- package/src/index.ts +7 -1
- package/src/intelligence/__tests__/adaptive-validation.test.ts +694 -0
- package/src/intelligence/adaptive-validation.ts +764 -0
- package/src/intelligence/index.ts +16 -0
- package/src/internal.ts +19 -0
- package/src/lifecycle/__tests__/chain-store.test.ts +7 -0
- package/src/lifecycle/__tests__/tessera-engine.test.ts +52 -0
- package/src/sessions/__tests__/session-edge-cases.test.ts +24 -1
- package/src/sessions/session-enforcement.ts +13 -2
- package/src/stats/index.ts +7 -0
- package/src/stats/workflow-telemetry.ts +487 -0
- package/src/store/__tests__/migration-safety.test.ts +3 -0
- package/src/store/__tests__/session-store.test.ts +96 -1
- package/src/store/__tests__/task-store.test.ts +22 -1
- package/src/store/__tests__/test-db-helper.ts +25 -2
- package/src/store/brain-schema.ts +4 -1
- package/src/store/converters.ts +2 -0
- package/src/store/cross-db-cleanup.ts +157 -0
- package/src/store/db-helpers.ts +2 -0
- package/src/store/migration-sqlite.ts +6 -0
- package/src/store/sqlite-data-accessor.ts +20 -28
- package/src/store/sqlite.ts +14 -2
- package/src/store/task-store.ts +6 -0
- package/src/store/tasks-schema.ts +59 -20
- package/src/tasks/__tests__/add.test.ts +16 -0
- package/src/tasks/__tests__/complete-unblocks.test.ts +10 -1
- package/src/tasks/__tests__/complete.test.ts +11 -2
- package/src/tasks/__tests__/epic-enforcement.test.ts +904 -0
- package/src/tasks/__tests__/minimal-test.test.ts +28 -0
- package/src/tasks/__tests__/pipeline-stage.test.ts +403 -0
- package/src/tasks/__tests__/update.test.ts +40 -6
- package/src/tasks/add.ts +128 -2
- package/src/tasks/complete.ts +24 -17
- package/src/tasks/enforcement.ts +124 -0
- package/src/tasks/epic-enforcement.ts +303 -0
- package/src/tasks/index.ts +1 -0
- package/src/tasks/pipeline-stage.ts +224 -0
- package/src/tasks/update.ts +62 -0
- package/templates/config.template.json +34 -0
- package/templates/global-config.template.json +26 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic relationship discovery for CLEO tasks.
|
|
3
|
+
* Discovers related tasks via shared labels, description keywords, files, and hierarchy.
|
|
4
|
+
* Ported from lib/tasks/graph-rag.sh
|
|
5
|
+
*
|
|
6
|
+
* @epic T4454
|
|
7
|
+
* @task T4529
|
|
8
|
+
*/
|
|
9
|
+
/** Common English stopwords for text comparison. */
|
|
10
|
+
const STOPWORDS = new Set([
|
|
11
|
+
'a',
|
|
12
|
+
'an',
|
|
13
|
+
'the',
|
|
14
|
+
'and',
|
|
15
|
+
'or',
|
|
16
|
+
'but',
|
|
17
|
+
'in',
|
|
18
|
+
'on',
|
|
19
|
+
'at',
|
|
20
|
+
'to',
|
|
21
|
+
'for',
|
|
22
|
+
'of',
|
|
23
|
+
'with',
|
|
24
|
+
'by',
|
|
25
|
+
'from',
|
|
26
|
+
'as',
|
|
27
|
+
'is',
|
|
28
|
+
'was',
|
|
29
|
+
'are',
|
|
30
|
+
'were',
|
|
31
|
+
'be',
|
|
32
|
+
'been',
|
|
33
|
+
'being',
|
|
34
|
+
'have',
|
|
35
|
+
'has',
|
|
36
|
+
'had',
|
|
37
|
+
'do',
|
|
38
|
+
'does',
|
|
39
|
+
'did',
|
|
40
|
+
'will',
|
|
41
|
+
'would',
|
|
42
|
+
'could',
|
|
43
|
+
'should',
|
|
44
|
+
'may',
|
|
45
|
+
'might',
|
|
46
|
+
'must',
|
|
47
|
+
'shall',
|
|
48
|
+
'can',
|
|
49
|
+
'this',
|
|
50
|
+
'that',
|
|
51
|
+
'these',
|
|
52
|
+
'those',
|
|
53
|
+
'i',
|
|
54
|
+
'you',
|
|
55
|
+
'he',
|
|
56
|
+
'she',
|
|
57
|
+
'it',
|
|
58
|
+
'we',
|
|
59
|
+
'they',
|
|
60
|
+
'what',
|
|
61
|
+
'which',
|
|
62
|
+
'who',
|
|
63
|
+
'when',
|
|
64
|
+
'where',
|
|
65
|
+
'why',
|
|
66
|
+
'how',
|
|
67
|
+
'all',
|
|
68
|
+
'each',
|
|
69
|
+
'every',
|
|
70
|
+
'both',
|
|
71
|
+
'few',
|
|
72
|
+
'more',
|
|
73
|
+
'most',
|
|
74
|
+
'other',
|
|
75
|
+
'some',
|
|
76
|
+
'such',
|
|
77
|
+
'no',
|
|
78
|
+
'nor',
|
|
79
|
+
'not',
|
|
80
|
+
'only',
|
|
81
|
+
'own',
|
|
82
|
+
'same',
|
|
83
|
+
'so',
|
|
84
|
+
'than',
|
|
85
|
+
'too',
|
|
86
|
+
'very',
|
|
87
|
+
'just',
|
|
88
|
+
'also',
|
|
89
|
+
'now',
|
|
90
|
+
'then',
|
|
91
|
+
'here',
|
|
92
|
+
'there',
|
|
93
|
+
'if',
|
|
94
|
+
'else',
|
|
95
|
+
'any',
|
|
96
|
+
]);
|
|
97
|
+
/**
|
|
98
|
+
* Tokenize text: lowercase, remove punctuation, split, remove stopwords.
|
|
99
|
+
*/
|
|
100
|
+
function tokenize(text) {
|
|
101
|
+
const tokens = text
|
|
102
|
+
.toLowerCase()
|
|
103
|
+
.replace(/[^a-z0-9\s]/g, ' ')
|
|
104
|
+
.split(/\s+/)
|
|
105
|
+
.filter((t) => t.length > 0 && !STOPWORDS.has(t));
|
|
106
|
+
return new Set(tokens);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Calculate Jaccard similarity between two sets.
|
|
110
|
+
*/
|
|
111
|
+
function jaccardSimilarity(a, b) {
|
|
112
|
+
if (a.size === 0 && b.size === 0)
|
|
113
|
+
return 0;
|
|
114
|
+
let intersection = 0;
|
|
115
|
+
for (const item of a) {
|
|
116
|
+
if (b.has(item))
|
|
117
|
+
intersection++;
|
|
118
|
+
}
|
|
119
|
+
const union = new Set([...a, ...b]).size;
|
|
120
|
+
if (union === 0)
|
|
121
|
+
return 0;
|
|
122
|
+
return intersection / union;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Discover related tasks by shared labels.
|
|
126
|
+
*/
|
|
127
|
+
export function discoverByLabels(taskId, tasks) {
|
|
128
|
+
const source = tasks.find((t) => t.id === taskId);
|
|
129
|
+
if (!source?.labels?.length)
|
|
130
|
+
return [];
|
|
131
|
+
const sourceLabels = new Set(source.labels);
|
|
132
|
+
const results = [];
|
|
133
|
+
for (const task of tasks) {
|
|
134
|
+
if (task.id === taskId)
|
|
135
|
+
continue;
|
|
136
|
+
if (!task.labels?.length)
|
|
137
|
+
continue;
|
|
138
|
+
const taskLabels = new Set(task.labels);
|
|
139
|
+
const shared = [...sourceLabels].filter((l) => taskLabels.has(l));
|
|
140
|
+
if (shared.length === 0)
|
|
141
|
+
continue;
|
|
142
|
+
const allLabels = new Set([...sourceLabels, ...taskLabels]);
|
|
143
|
+
const score = shared.length / allLabels.size;
|
|
144
|
+
results.push({
|
|
145
|
+
taskId: task.id,
|
|
146
|
+
type: 'relates-to',
|
|
147
|
+
reason: `${shared.length} shared label(s): ${shared.join(', ')}`,
|
|
148
|
+
score: Math.round(score * 100) / 100,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return results.sort((a, b) => b.score - a.score);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Discover related tasks by description similarity (keyword-based Jaccard).
|
|
155
|
+
*/
|
|
156
|
+
export function discoverByDescription(taskId, tasks) {
|
|
157
|
+
const source = tasks.find((t) => t.id === taskId);
|
|
158
|
+
if (!source)
|
|
159
|
+
return [];
|
|
160
|
+
const sourceText = `${source.title ?? ''} ${source.description ?? ''}`;
|
|
161
|
+
const sourceTokens = tokenize(sourceText);
|
|
162
|
+
if (sourceTokens.size === 0)
|
|
163
|
+
return [];
|
|
164
|
+
const results = [];
|
|
165
|
+
for (const task of tasks) {
|
|
166
|
+
if (task.id === taskId)
|
|
167
|
+
continue;
|
|
168
|
+
const text = `${task.title ?? ''} ${task.description ?? ''}`;
|
|
169
|
+
const tokens = tokenize(text);
|
|
170
|
+
if (tokens.size === 0)
|
|
171
|
+
continue;
|
|
172
|
+
const score = jaccardSimilarity(sourceTokens, tokens);
|
|
173
|
+
if (score <= 0)
|
|
174
|
+
continue;
|
|
175
|
+
let sharedCount = 0;
|
|
176
|
+
for (const t of sourceTokens) {
|
|
177
|
+
if (tokens.has(t))
|
|
178
|
+
sharedCount++;
|
|
179
|
+
}
|
|
180
|
+
results.push({
|
|
181
|
+
taskId: task.id,
|
|
182
|
+
type: 'relates-to',
|
|
183
|
+
reason: `${sharedCount} shared keyword(s)`,
|
|
184
|
+
score: Math.round(score * 100) / 100,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return results.sort((a, b) => b.score - a.score);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Discover related tasks by shared files.
|
|
191
|
+
*/
|
|
192
|
+
export function discoverByFiles(taskId, tasks) {
|
|
193
|
+
const source = tasks.find((t) => t.id === taskId);
|
|
194
|
+
if (!source?.files?.length)
|
|
195
|
+
return [];
|
|
196
|
+
const sourceFiles = new Set(source.files);
|
|
197
|
+
const results = [];
|
|
198
|
+
for (const task of tasks) {
|
|
199
|
+
if (task.id === taskId)
|
|
200
|
+
continue;
|
|
201
|
+
if (!task.files?.length)
|
|
202
|
+
continue;
|
|
203
|
+
const taskFiles = new Set(task.files);
|
|
204
|
+
const shared = [...sourceFiles].filter((f) => taskFiles.has(f));
|
|
205
|
+
if (shared.length === 0)
|
|
206
|
+
continue;
|
|
207
|
+
const allFiles = new Set([...sourceFiles, ...taskFiles]);
|
|
208
|
+
const score = shared.length / allFiles.size;
|
|
209
|
+
const preview = shared.slice(0, 3).join(', ');
|
|
210
|
+
const suffix = shared.length > 3 ? '...' : '';
|
|
211
|
+
results.push({
|
|
212
|
+
taskId: task.id,
|
|
213
|
+
type: 'relates-to',
|
|
214
|
+
reason: `${shared.length} shared file(s): ${preview}${suffix}`,
|
|
215
|
+
score: Math.round(score * 100) / 100,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return results.sort((a, b) => b.score - a.score);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Discover related tasks by hierarchical proximity (siblings and cousins).
|
|
222
|
+
*/
|
|
223
|
+
export function discoverByHierarchy(taskId, tasks, options) {
|
|
224
|
+
const { siblingBoost = 0.15, cousinBoost = 0.08 } = options ?? {};
|
|
225
|
+
const source = tasks.find((t) => t.id === taskId);
|
|
226
|
+
if (!source)
|
|
227
|
+
return [];
|
|
228
|
+
const results = [];
|
|
229
|
+
// Find siblings (same parent)
|
|
230
|
+
if (source.parentId) {
|
|
231
|
+
const siblings = tasks.filter((t) => t.parentId === source.parentId && t.id !== taskId);
|
|
232
|
+
for (const sib of siblings) {
|
|
233
|
+
results.push({
|
|
234
|
+
taskId: sib.id,
|
|
235
|
+
type: 'relates-to',
|
|
236
|
+
reason: `sibling (shared parent ${source.parentId})`,
|
|
237
|
+
score: siblingBoost,
|
|
238
|
+
_hierarchyBoost: siblingBoost,
|
|
239
|
+
_relationship: 'sibling',
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
// Find cousins (same grandparent, different parent)
|
|
243
|
+
const parent = tasks.find((t) => t.id === source.parentId);
|
|
244
|
+
if (parent?.parentId) {
|
|
245
|
+
const auntsUncles = tasks.filter((t) => t.parentId === parent.parentId && t.id !== source.parentId);
|
|
246
|
+
const auntUncleIds = new Set(auntsUncles.map((t) => t.id));
|
|
247
|
+
const cousins = tasks.filter((t) => t.parentId && auntUncleIds.has(t.parentId));
|
|
248
|
+
for (const cousin of cousins) {
|
|
249
|
+
results.push({
|
|
250
|
+
taskId: cousin.id,
|
|
251
|
+
type: 'relates-to',
|
|
252
|
+
reason: `cousin (shared grandparent ${parent.parentId})`,
|
|
253
|
+
score: cousinBoost,
|
|
254
|
+
_hierarchyBoost: cousinBoost,
|
|
255
|
+
_relationship: 'cousin',
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return results.sort((a, b) => b.score - a.score);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Discover related tasks using all methods combined.
|
|
264
|
+
*/
|
|
265
|
+
export function discoverRelatedTasks(taskId, tasks, method = 'auto') {
|
|
266
|
+
const task = tasks.find((t) => t.id === taskId);
|
|
267
|
+
if (!task)
|
|
268
|
+
return [];
|
|
269
|
+
switch (method) {
|
|
270
|
+
case 'labels':
|
|
271
|
+
return discoverByLabels(taskId, tasks);
|
|
272
|
+
case 'description':
|
|
273
|
+
return discoverByDescription(taskId, tasks);
|
|
274
|
+
case 'files':
|
|
275
|
+
return discoverByFiles(taskId, tasks);
|
|
276
|
+
case 'hierarchy':
|
|
277
|
+
return discoverByHierarchy(taskId, tasks);
|
|
278
|
+
default: {
|
|
279
|
+
const labels = discoverByLabels(taskId, tasks);
|
|
280
|
+
const description = discoverByDescription(taskId, tasks);
|
|
281
|
+
const files = discoverByFiles(taskId, tasks);
|
|
282
|
+
const hierarchy = discoverByHierarchy(taskId, tasks);
|
|
283
|
+
// Merge: group by taskId, apply hierarchy boost
|
|
284
|
+
const combined = new Map();
|
|
285
|
+
// Add base results (take highest score per taskId)
|
|
286
|
+
for (const match of [...labels, ...description, ...files]) {
|
|
287
|
+
const existing = combined.get(match.taskId);
|
|
288
|
+
if (!existing || match.score > existing.score) {
|
|
289
|
+
combined.set(match.taskId, { ...match });
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
// Apply hierarchy boosts
|
|
293
|
+
for (const hMatch of hierarchy) {
|
|
294
|
+
const existing = combined.get(hMatch.taskId);
|
|
295
|
+
if (existing) {
|
|
296
|
+
existing.score = Math.min(existing.score + (hMatch._hierarchyBoost ?? 0), 1.0);
|
|
297
|
+
existing._hierarchyBoost = hMatch._hierarchyBoost;
|
|
298
|
+
existing._relationship = hMatch._relationship;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
// Task only found via hierarchy
|
|
302
|
+
combined.set(hMatch.taskId, { ...hMatch });
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return [...combined.values()].sort((a, b) => b.score - a.score);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Suggest relates entries filtered by threshold.
|
|
311
|
+
*/
|
|
312
|
+
export function suggestRelates(taskId, tasks, threshold = 0.5) {
|
|
313
|
+
const task = tasks.find((t) => t.id === taskId);
|
|
314
|
+
if (!task)
|
|
315
|
+
return [];
|
|
316
|
+
const all = discoverRelatedTasks(taskId, tasks, 'auto');
|
|
317
|
+
// Exclude already-related tasks
|
|
318
|
+
const existingRelates = new Set();
|
|
319
|
+
// Tasks may have a `relates` field (not in the type but used at runtime)
|
|
320
|
+
const taskAny = task;
|
|
321
|
+
if (taskAny.relates) {
|
|
322
|
+
for (const r of taskAny.relates) {
|
|
323
|
+
existingRelates.add(r.taskId);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return all.filter((m) => m.score >= threshold && !existingRelates.has(m.taskId));
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=graph-rag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-rag.js","sourceRoot":"","sources":["../../src/tasks/graph-rag.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,oDAAoD;AACpD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,GAAG;IACH,IAAI;IACJ,KAAK;IACL,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,MAAM;IACN,IAAI;IACJ,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,KAAK;IACL,IAAI;IACJ,MAAM;IACN,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;IACP,QAAQ;IACR,KAAK;IACL,OAAO;IACP,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,GAAG;IACH,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,IAAI;IACJ,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,IA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AAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;IAChD,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAErB,MAAM,GAAG,GAAG,oBAAoB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAExD,gCAAgC;IAChC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAC1C,yEAAyE;IACzE,MAAM,OAAO,GAAG,IAA2C,CAAC;IAC5D,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YAChC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified hierarchy policy resolution and validation.
|
|
3
|
+
* Single source of truth for all hierarchy enforcement paths.
|
|
4
|
+
*
|
|
5
|
+
* @epic T4454
|
|
6
|
+
* @task T5001
|
|
7
|
+
*/
|
|
8
|
+
import { getChildren, getDepth, wouldCreateCircle } from './hierarchy.js';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Constants
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
export const ENFORCEMENT_PROFILES = {
|
|
13
|
+
'llm-agent-first': { maxSiblings: 0, maxActiveSiblings: 0, maxDepth: 3, countDoneInLimit: false },
|
|
14
|
+
'human-cognitive': { maxSiblings: 7, maxActiveSiblings: 3, maxDepth: 3, countDoneInLimit: false },
|
|
15
|
+
};
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Policy resolution
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a full HierarchyPolicy from config, starting with a profile preset
|
|
21
|
+
* and overriding with any explicitly set config.hierarchy fields.
|
|
22
|
+
*/
|
|
23
|
+
export function resolveHierarchyPolicy(config) {
|
|
24
|
+
const hierarchy = config.hierarchy;
|
|
25
|
+
const profileName = hierarchy?.enforcementProfile ?? 'llm-agent-first';
|
|
26
|
+
const preset = ENFORCEMENT_PROFILES[profileName] ?? ENFORCEMENT_PROFILES['llm-agent-first'];
|
|
27
|
+
const resolved = {
|
|
28
|
+
enforcementProfile: profileName in ENFORCEMENT_PROFILES ? profileName : 'custom',
|
|
29
|
+
maxDepth: preset.maxDepth,
|
|
30
|
+
maxSiblings: preset.maxSiblings,
|
|
31
|
+
maxActiveSiblings: preset.maxActiveSiblings,
|
|
32
|
+
countDoneInLimit: preset.countDoneInLimit,
|
|
33
|
+
};
|
|
34
|
+
// Override with explicit config values when present
|
|
35
|
+
if (hierarchy) {
|
|
36
|
+
if (typeof hierarchy.maxDepth === 'number') {
|
|
37
|
+
resolved.maxDepth = hierarchy.maxDepth;
|
|
38
|
+
}
|
|
39
|
+
if (typeof hierarchy.maxSiblings === 'number') {
|
|
40
|
+
resolved.maxSiblings = hierarchy.maxSiblings;
|
|
41
|
+
}
|
|
42
|
+
if (typeof hierarchy.maxActiveSiblings === 'number') {
|
|
43
|
+
resolved.maxActiveSiblings = hierarchy.maxActiveSiblings;
|
|
44
|
+
}
|
|
45
|
+
if (typeof hierarchy.countDoneInLimit === 'boolean') {
|
|
46
|
+
resolved.countDoneInLimit = hierarchy.countDoneInLimit;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return resolved;
|
|
50
|
+
}
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Validation helpers
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
/**
|
|
55
|
+
* Assert that a parent task exists in the task list.
|
|
56
|
+
* Returns an error result if not found, null if OK.
|
|
57
|
+
*/
|
|
58
|
+
export function assertParentExists(parentId, tasks) {
|
|
59
|
+
const parent = tasks.find((t) => t.id === parentId);
|
|
60
|
+
if (!parent) {
|
|
61
|
+
return {
|
|
62
|
+
valid: false,
|
|
63
|
+
error: { code: 'E_PARENT_NOT_FOUND', message: `Parent task ${parentId} not found` },
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Assert that re-parenting would not create a cycle.
|
|
70
|
+
* Returns an error result if a cycle is detected, null if OK.
|
|
71
|
+
*/
|
|
72
|
+
export function assertNoCycle(taskId, newParentId, tasks) {
|
|
73
|
+
if (wouldCreateCircle(taskId, newParentId, tasks)) {
|
|
74
|
+
return {
|
|
75
|
+
valid: false,
|
|
76
|
+
error: {
|
|
77
|
+
code: 'E_CIRCULAR_REFERENCE',
|
|
78
|
+
message: `Setting parent to ${newParentId} would create a circular reference for task ${taskId}`,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Count active (non-done, non-cancelled, non-archived) children of a parent.
|
|
86
|
+
*/
|
|
87
|
+
export function countActiveChildren(parentId, tasks) {
|
|
88
|
+
const activeStatuses = new Set(['pending', 'active', 'blocked']);
|
|
89
|
+
return tasks.filter((t) => t.parentId === parentId && activeStatuses.has(t.status)).length;
|
|
90
|
+
}
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
// Primary validation
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
/**
|
|
95
|
+
* Validate whether a new task can be placed under the given parent
|
|
96
|
+
* according to the resolved hierarchy policy.
|
|
97
|
+
*/
|
|
98
|
+
export function validateHierarchyPlacement(parentId, tasks, policy) {
|
|
99
|
+
// Root placement is always allowed
|
|
100
|
+
if (parentId === null) {
|
|
101
|
+
return { valid: true };
|
|
102
|
+
}
|
|
103
|
+
// Parent must exist
|
|
104
|
+
const parentError = assertParentExists(parentId, tasks);
|
|
105
|
+
if (parentError)
|
|
106
|
+
return parentError;
|
|
107
|
+
// Depth check
|
|
108
|
+
const parentDepth = getDepth(parentId, tasks);
|
|
109
|
+
if (parentDepth + 1 >= policy.maxDepth) {
|
|
110
|
+
return {
|
|
111
|
+
valid: false,
|
|
112
|
+
error: {
|
|
113
|
+
code: 'E_DEPTH_EXCEEDED',
|
|
114
|
+
message: `Maximum nesting depth ${policy.maxDepth} would be exceeded`,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// Sibling limit (0 = unlimited)
|
|
119
|
+
if (policy.maxSiblings > 0) {
|
|
120
|
+
const children = getChildren(parentId, tasks);
|
|
121
|
+
const counted = policy.countDoneInLimit
|
|
122
|
+
? children.length
|
|
123
|
+
: children.filter((t) => t.status !== 'done').length;
|
|
124
|
+
if (counted >= policy.maxSiblings) {
|
|
125
|
+
return {
|
|
126
|
+
valid: false,
|
|
127
|
+
error: {
|
|
128
|
+
code: 'E_SIBLING_LIMIT',
|
|
129
|
+
message: `Parent ${parentId} already has ${counted} children (limit: ${policy.maxSiblings})`,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Active sibling limit
|
|
135
|
+
if (policy.maxActiveSiblings > 0) {
|
|
136
|
+
const activeCount = countActiveChildren(parentId, tasks);
|
|
137
|
+
if (activeCount >= policy.maxActiveSiblings) {
|
|
138
|
+
return {
|
|
139
|
+
valid: false,
|
|
140
|
+
error: {
|
|
141
|
+
code: 'E_ACTIVE_SIBLING_LIMIT',
|
|
142
|
+
message: `Parent ${parentId} already has ${activeCount} active children (limit: ${policy.maxActiveSiblings})`,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return { valid: true };
|
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|
+
/**
|
|
9
|
+
* Get direct children of a task.
|
|
10
|
+
*/
|
|
11
|
+
export function getChildren(taskId, tasks) {
|
|
12
|
+
return tasks.filter((t) => t.parentId === taskId);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get direct child IDs.
|
|
16
|
+
*/
|
|
17
|
+
export function getChildIds(taskId, tasks) {
|
|
18
|
+
return getChildren(taskId, tasks).map((t) => t.id);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get all descendants of a task (recursive).
|
|
22
|
+
*/
|
|
23
|
+
export function getDescendants(taskId, tasks) {
|
|
24
|
+
const result = [];
|
|
25
|
+
const queue = [taskId];
|
|
26
|
+
const visited = new Set();
|
|
27
|
+
while (queue.length > 0) {
|
|
28
|
+
const current = queue.shift();
|
|
29
|
+
if (visited.has(current))
|
|
30
|
+
continue;
|
|
31
|
+
visited.add(current);
|
|
32
|
+
const children = getChildren(current, tasks);
|
|
33
|
+
for (const child of children) {
|
|
34
|
+
result.push(child);
|
|
35
|
+
queue.push(child.id);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get all descendant IDs (flat list).
|
|
42
|
+
*/
|
|
43
|
+
export function getDescendantIds(taskId, tasks) {
|
|
44
|
+
return getDescendants(taskId, tasks).map((t) => t.id);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the parent chain (ancestors) from a task up to the root.
|
|
48
|
+
* Returns ordered from immediate parent to root.
|
|
49
|
+
*/
|
|
50
|
+
export function getParentChain(taskId, tasks) {
|
|
51
|
+
const chain = [];
|
|
52
|
+
const taskMap = new Map(tasks.map((t) => [t.id, t]));
|
|
53
|
+
let current = taskMap.get(taskId);
|
|
54
|
+
const visited = new Set();
|
|
55
|
+
while (current?.parentId) {
|
|
56
|
+
if (visited.has(current.parentId))
|
|
57
|
+
break; // circular reference guard
|
|
58
|
+
visited.add(current.parentId);
|
|
59
|
+
const parent = taskMap.get(current.parentId);
|
|
60
|
+
if (!parent)
|
|
61
|
+
break;
|
|
62
|
+
chain.push(parent);
|
|
63
|
+
current = parent;
|
|
64
|
+
}
|
|
65
|
+
return chain;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the parent chain as IDs.
|
|
69
|
+
*/
|
|
70
|
+
export function getParentChainIds(taskId, tasks) {
|
|
71
|
+
return getParentChain(taskId, tasks).map((t) => t.id);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Calculate depth of a task in the hierarchy (0-based).
|
|
75
|
+
* Root tasks have depth 0, their children depth 1, etc.
|
|
76
|
+
*/
|
|
77
|
+
export function getDepth(taskId, tasks) {
|
|
78
|
+
return getParentChain(taskId, tasks).length;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the root ancestor of a task.
|
|
82
|
+
*/
|
|
83
|
+
export function getRootAncestor(taskId, tasks) {
|
|
84
|
+
const chain = getParentChain(taskId, tasks);
|
|
85
|
+
return chain.length > 0 ? chain[chain.length - 1] : null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check if a task is an ancestor of another.
|
|
89
|
+
*/
|
|
90
|
+
export function isAncestorOf(ancestorId, descendantId, tasks) {
|
|
91
|
+
const chain = getParentChainIds(descendantId, tasks);
|
|
92
|
+
return chain.includes(ancestorId);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Check if a task is a descendant of another.
|
|
96
|
+
*/
|
|
97
|
+
export function isDescendantOf(descendantId, ancestorId, tasks) {
|
|
98
|
+
return isAncestorOf(ancestorId, descendantId, tasks);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get sibling tasks (same parent).
|
|
102
|
+
*/
|
|
103
|
+
export function getSiblings(taskId, tasks) {
|
|
104
|
+
const task = tasks.find((t) => t.id === taskId);
|
|
105
|
+
if (!task)
|
|
106
|
+
return [];
|
|
107
|
+
if (task.parentId) {
|
|
108
|
+
return tasks.filter((t) => t.parentId === task.parentId && t.id !== taskId);
|
|
109
|
+
}
|
|
110
|
+
// Root-level siblings: tasks with no parent, excluding self
|
|
111
|
+
return tasks.filter((t) => !t.parentId && t.id !== taskId);
|
|
112
|
+
}
|
|
113
|
+
export function validateHierarchy(parentId, tasks, policy) {
|
|
114
|
+
if (!parentId) {
|
|
115
|
+
return { valid: true };
|
|
116
|
+
}
|
|
117
|
+
const parent = tasks.find((t) => t.id === parentId);
|
|
118
|
+
if (!parent) {
|
|
119
|
+
return {
|
|
120
|
+
valid: false,
|
|
121
|
+
error: { code: 'E_PARENT_NOT_FOUND', message: `Parent task ${parentId} not found` },
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// Check depth
|
|
125
|
+
const parentDepth = getDepth(parentId, tasks);
|
|
126
|
+
if (parentDepth + 1 >= (policy?.maxDepth ?? 3)) {
|
|
127
|
+
return {
|
|
128
|
+
valid: false,
|
|
129
|
+
error: {
|
|
130
|
+
code: 'E_DEPTH_EXCEEDED',
|
|
131
|
+
message: `Maximum nesting depth ${policy?.maxDepth ?? 3} would be exceeded`,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// Check sibling limit
|
|
136
|
+
const existingChildren = getChildren(parentId, tasks);
|
|
137
|
+
const maxSiblings = policy?.maxSiblings ?? 0;
|
|
138
|
+
if (maxSiblings > 0 && existingChildren.length >= maxSiblings) {
|
|
139
|
+
return {
|
|
140
|
+
valid: false,
|
|
141
|
+
error: {
|
|
142
|
+
code: 'E_SIBLING_LIMIT',
|
|
143
|
+
message: `Parent ${parentId} already has ${maxSiblings} children (max)`,
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return { valid: true };
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Detect circular reference if parentId were set.
|
|
151
|
+
*/
|
|
152
|
+
export function wouldCreateCircle(taskId, newParentId, tasks) {
|
|
153
|
+
if (taskId === newParentId)
|
|
154
|
+
return true;
|
|
155
|
+
const descendants = getDescendantIds(taskId, tasks);
|
|
156
|
+
return descendants.includes(newParentId);
|
|
157
|
+
}
|
|
158
|
+
export function buildTree(tasks) {
|
|
159
|
+
const childrenMap = new Map();
|
|
160
|
+
for (const task of tasks) {
|
|
161
|
+
const parentKey = task.parentId ?? null;
|
|
162
|
+
if (!childrenMap.has(parentKey)) {
|
|
163
|
+
childrenMap.set(parentKey, []);
|
|
164
|
+
}
|
|
165
|
+
childrenMap.get(parentKey).push(task);
|
|
166
|
+
}
|
|
167
|
+
function buildNode(task) {
|
|
168
|
+
const children = (childrenMap.get(task.id) ?? []).map(buildNode);
|
|
169
|
+
return { task, children };
|
|
170
|
+
}
|
|
171
|
+
const roots = childrenMap.get(null) ?? [];
|
|
172
|
+
return roots.map(buildNode);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Flatten a tree back to a list (depth-first).
|
|
176
|
+
*/
|
|
177
|
+
export function flattenTree(nodes) {
|
|
178
|
+
const result = [];
|
|
179
|
+
for (const node of nodes) {
|
|
180
|
+
result.push(node.task);
|
|
181
|
+
result.push(...flattenTree(node.children));
|
|
182
|
+
}
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=hierarchy.js.map
|