@cleocode/core 2026.9.21 → 2026.9.23
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/agents/scaffold.d.ts.map +1 -1
- package/dist/agents/scaffold.js +0 -1
- package/dist/agents/scaffold.js.map +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +4 -0
- package/dist/bootstrap.js.map +1 -1
- package/dist/build-provenance.json +6 -0
- package/dist/decide/audit.d.ts +7 -1
- package/dist/decide/audit.d.ts.map +1 -1
- package/dist/decide/audit.js.map +1 -1
- package/dist/decide/client.d.ts +46 -4
- package/dist/decide/client.d.ts.map +1 -1
- package/dist/decide/client.js +328 -33
- package/dist/decide/client.js.map +1 -1
- package/dist/decide/credentials.d.ts +28 -4
- package/dist/decide/credentials.d.ts.map +1 -1
- package/dist/decide/credentials.js +50 -12
- package/dist/decide/credentials.js.map +1 -1
- package/dist/decide/index.d.ts +10 -4
- package/dist/decide/index.d.ts.map +1 -1
- package/dist/decide/index.js +10 -4
- package/dist/decide/index.js.map +1 -1
- package/dist/decide/jev-wire.d.ts +100 -8
- package/dist/decide/jev-wire.d.ts.map +1 -1
- package/dist/decide/jev-wire.js +402 -55
- package/dist/decide/jev-wire.js.map +1 -1
- package/dist/decide/operations.d.ts +97 -20
- package/dist/decide/operations.d.ts.map +1 -1
- package/dist/decide/operations.js +180 -28
- package/dist/decide/operations.js.map +1 -1
- package/dist/decide/provider-state.d.ts +89 -0
- package/dist/decide/provider-state.d.ts.map +1 -0
- package/dist/decide/provider-state.js +134 -0
- package/dist/decide/provider-state.js.map +1 -0
- package/dist/decide/provider.d.ts +26 -5
- package/dist/decide/provider.d.ts.map +1 -1
- package/dist/decide/provider.js.map +1 -1
- package/dist/decide/providers.d.ts +58 -0
- package/dist/decide/providers.d.ts.map +1 -0
- package/dist/decide/providers.js +69 -0
- package/dist/decide/providers.js.map +1 -0
- package/dist/decide/site.d.ts +2 -2
- package/dist/decide/site.d.ts.map +1 -1
- package/dist/decide/site.js +2 -0
- package/dist/decide/site.js.map +1 -1
- package/dist/decide/sites/list.d.ts +46 -0
- package/dist/decide/sites/list.d.ts.map +1 -0
- package/dist/decide/sites/list.js +206 -0
- package/dist/decide/sites/list.js.map +1 -0
- package/dist/decide/sites/registry.d.ts +130 -0
- package/dist/decide/sites/registry.d.ts.map +1 -0
- package/dist/decide/sites/registry.js +375 -0
- package/dist/decide/sites/registry.js.map +1 -0
- package/dist/decide/spend.d.ts +196 -0
- package/dist/decide/spend.d.ts.map +1 -0
- package/dist/decide/spend.js +387 -0
- package/dist/decide/spend.js.map +1 -0
- package/dist/decide/wizard.d.ts +53 -0
- package/dist/decide/wizard.d.ts.map +1 -0
- package/dist/decide/wizard.js +144 -0
- package/dist/decide/wizard.js.map +1 -0
- package/dist/dispatch/mutate-projection.d.ts.map +1 -1
- package/dist/dispatch/mutate-projection.js +5 -0
- package/dist/dispatch/mutate-projection.js.map +1 -1
- package/dist/docs/docs-audit.d.ts.map +1 -1
- package/dist/docs/docs-audit.js +1 -2
- package/dist/docs/docs-audit.js.map +1 -1
- package/dist/docs/docs-update.d.ts.map +1 -1
- package/dist/docs/docs-update.js +25 -9
- package/dist/docs/docs-update.js.map +1 -1
- package/dist/docs/export-document.js +1073 -628
- package/dist/docs/export-document.js.map +3 -3
- package/dist/doctor/knowledge.d.ts +16 -1
- package/dist/doctor/knowledge.d.ts.map +1 -1
- package/dist/doctor/knowledge.js +53 -17
- package/dist/doctor/knowledge.js.map +1 -1
- package/dist/engine/engine-ops.d.ts +36 -6
- package/dist/engine/engine-ops.d.ts.map +1 -1
- package/dist/engine/engine-ops.js +115 -14
- package/dist/engine/engine-ops.js.map +1 -1
- package/dist/gateway-client/generated/types.gen.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/init/scaffold-workflows.d.ts.map +1 -1
- package/dist/init/scaffold-workflows.js +6 -3
- package/dist/init/scaffold-workflows.js.map +1 -1
- package/dist/init/upgrade-workflows.d.ts.map +1 -1
- package/dist/init/upgrade-workflows.js +6 -3
- package/dist/init/upgrade-workflows.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +51 -11
- package/dist/init.js.map +1 -1
- package/dist/inject/index.d.ts.map +1 -1
- package/dist/inject/index.js +8 -3
- package/dist/inject/index.js.map +1 -1
- package/dist/internal.d.ts +3 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -2
- package/dist/internal.js.map +1 -1
- package/dist/llm/plugin-facade.js +1184 -739
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/memory/attention.d.ts.map +1 -1
- package/dist/memory/attention.js +2 -2
- package/dist/memory/attention.js.map +1 -1
- package/dist/memory/decision-contradiction.d.ts +3 -3
- package/dist/memory/decision-contradiction.d.ts.map +1 -1
- package/dist/memory/decision-contradiction.js +4 -3
- package/dist/memory/decision-contradiction.js.map +1 -1
- package/dist/memory/graph-memory-bridge.d.ts.map +1 -1
- package/dist/memory/graph-memory-bridge.js +2 -0
- package/dist/memory/graph-memory-bridge.js.map +1 -1
- package/dist/memory/observation-type-decision.d.ts +2 -2
- package/dist/memory/observation-type-decision.d.ts.map +1 -1
- package/dist/memory/observation-type-decision.js +3 -2
- package/dist/memory/observation-type-decision.js.map +1 -1
- package/dist/memory/pipeline-manifest-sqlite.d.ts +111 -0
- package/dist/memory/pipeline-manifest-sqlite.d.ts.map +1 -1
- package/dist/memory/pipeline-manifest-sqlite.js +230 -2
- package/dist/memory/pipeline-manifest-sqlite.js.map +1 -1
- package/dist/nexus/analyze-orchestrator.d.ts +38 -0
- package/dist/nexus/analyze-orchestrator.d.ts.map +1 -1
- package/dist/nexus/analyze-orchestrator.js +96 -21
- package/dist/nexus/analyze-orchestrator.js.map +1 -1
- package/dist/nexus/knowledge.d.ts.map +1 -1
- package/dist/nexus/knowledge.js +15 -4
- package/dist/nexus/knowledge.js.map +1 -1
- package/dist/nexus/migrations/M-split-graph.d.ts.map +1 -1
- package/dist/nexus/migrations/M-split-graph.js +4 -0
- package/dist/nexus/migrations/M-split-graph.js.map +1 -1
- package/dist/nexus/store.d.ts.map +1 -1
- package/dist/nexus/store.js +2 -0
- package/dist/nexus/store.js.map +1 -1
- package/dist/nexus/stored-roots.d.ts +65 -0
- package/dist/nexus/stored-roots.d.ts.map +1 -1
- package/dist/nexus/stored-roots.js +73 -0
- package/dist/nexus/stored-roots.js.map +1 -1
- package/dist/orchestrate/lifecycle-ops.d.ts.map +1 -1
- package/dist/orchestrate/lifecycle-ops.js +4 -1
- package/dist/orchestrate/lifecycle-ops.js.map +1 -1
- package/dist/orchestrate/pivot.d.ts.map +1 -1
- package/dist/orchestrate/pivot.js +13 -8
- package/dist/orchestrate/pivot.js.map +1 -1
- package/dist/orchestrate/plan.d.ts.map +1 -1
- package/dist/orchestrate/plan.js +8 -2
- package/dist/orchestrate/plan.js.map +1 -1
- package/dist/orchestrate/query-ops.d.ts +7 -2
- package/dist/orchestrate/query-ops.d.ts.map +1 -1
- package/dist/orchestrate/query-ops.js +17 -6
- package/dist/orchestrate/query-ops.js.map +1 -1
- package/dist/orchestrate/spawn-ops.d.ts.map +1 -1
- package/dist/orchestrate/spawn-ops.js +5 -14
- package/dist/orchestrate/spawn-ops.js.map +1 -1
- package/dist/orchestration/bootstrap.d.ts.map +1 -1
- package/dist/orchestration/bootstrap.js +4 -2
- package/dist/orchestration/bootstrap.js.map +1 -1
- package/dist/orchestration/index.d.ts +1 -0
- package/dist/orchestration/index.d.ts.map +1 -1
- package/dist/orchestration/index.js +4 -3
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/lead-rollup.d.ts +8 -5
- package/dist/orchestration/lead-rollup.d.ts.map +1 -1
- package/dist/orchestration/lead-rollup.js +46 -17
- package/dist/orchestration/lead-rollup.js.map +1 -1
- package/dist/orchestration/owner-decision-readiness.d.ts +2 -2
- package/dist/orchestration/owner-decision-readiness.d.ts.map +1 -1
- package/dist/orchestration/owner-decision-readiness.js +3 -2
- package/dist/orchestration/owner-decision-readiness.js.map +1 -1
- package/dist/orchestration/parallel.d.ts.map +1 -1
- package/dist/orchestration/parallel.js +10 -17
- package/dist/orchestration/parallel.js.map +1 -1
- package/dist/orchestration/spawn-prompt.d.ts +4 -1
- package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
- package/dist/orchestration/spawn-prompt.js +3 -2
- package/dist/orchestration/spawn-prompt.js.map +1 -1
- package/dist/orchestration/status.d.ts +8 -3
- package/dist/orchestration/status.d.ts.map +1 -1
- package/dist/orchestration/status.js +9 -6
- package/dist/orchestration/status.js.map +1 -1
- package/dist/orchestration/validate-spawn.d.ts.map +1 -1
- package/dist/orchestration/validate-spawn.js +2 -0
- package/dist/orchestration/validate-spawn.js.map +1 -1
- package/dist/orchestration/wave-topic.d.ts +54 -0
- package/dist/orchestration/wave-topic.d.ts.map +1 -0
- package/dist/orchestration/wave-topic.js +68 -0
- package/dist/orchestration/wave-topic.js.map +1 -0
- package/dist/orchestration/waves.d.ts +47 -8
- package/dist/orchestration/waves.d.ts.map +1 -1
- package/dist/orchestration/waves.js +152 -43
- package/dist/orchestration/waves.js.map +1 -1
- package/dist/phases/index.d.ts.map +1 -1
- package/dist/phases/index.js +6 -2
- package/dist/phases/index.js.map +1 -1
- package/dist/project-scope.d.ts +34 -0
- package/dist/project-scope.d.ts.map +1 -1
- package/dist/project-scope.js +73 -0
- package/dist/project-scope.js.map +1 -1
- package/dist/release/ci-evidence.d.ts +10 -0
- package/dist/release/ci-evidence.d.ts.map +1 -1
- package/dist/release/ci-evidence.js +23 -7
- package/dist/release/ci-evidence.js.map +1 -1
- package/dist/release/github-pr.d.ts +30 -0
- package/dist/release/github-pr.d.ts.map +1 -1
- package/dist/release/github-pr.js +42 -1
- package/dist/release/github-pr.js.map +1 -1
- package/dist/release/plan.d.ts.map +1 -1
- package/dist/release/plan.js +6 -3
- package/dist/release/plan.js.map +1 -1
- package/dist/release/pr-evidence.d.ts.map +1 -1
- package/dist/release/pr-evidence.js +12 -4
- package/dist/release/pr-evidence.js.map +1 -1
- package/dist/routing/capability-matrix.d.ts.map +1 -1
- package/dist/routing/capability-matrix.js +7 -0
- package/dist/routing/capability-matrix.js.map +1 -1
- package/dist/security/input-sanitization.d.ts.map +1 -1
- package/dist/security/input-sanitization.js +9 -2
- package/dist/security/input-sanitization.js.map +1 -1
- package/dist/selfimprove/fix-gen.js +1193 -748
- package/dist/selfimprove/fix-gen.js.map +3 -3
- package/dist/session/engine-ops.d.ts +6 -0
- package/dist/session/engine-ops.d.ts.map +1 -1
- package/dist/session/engine-ops.js +36 -4
- package/dist/session/engine-ops.js.map +1 -1
- package/dist/sessions/briefing.d.ts +17 -0
- package/dist/sessions/briefing.d.ts.map +1 -1
- package/dist/sessions/briefing.js +68 -68
- package/dist/sessions/briefing.js.map +1 -1
- package/dist/sessions/drift-watchdog.d.ts.map +1 -1
- package/dist/sessions/drift-watchdog.js +4 -3
- package/dist/sessions/drift-watchdog.js.map +1 -1
- package/dist/sessions/focus-state-store.d.ts +94 -1
- package/dist/sessions/focus-state-store.d.ts.map +1 -1
- package/dist/sessions/focus-state-store.js +100 -1
- package/dist/sessions/focus-state-store.js.map +1 -1
- package/dist/sessions/index.d.ts +2 -2
- package/dist/sessions/index.d.ts.map +1 -1
- package/dist/sessions/index.js +1 -1
- package/dist/sessions/index.js.map +1 -1
- package/dist/sessions/session-drift.d.ts.map +1 -1
- package/dist/sessions/session-drift.js +4 -3
- package/dist/sessions/session-drift.js.map +1 -1
- package/dist/setup/config-json-merge.d.ts +28 -0
- package/dist/setup/config-json-merge.d.ts.map +1 -1
- package/dist/setup/config-json-merge.js +51 -0
- package/dist/setup/config-json-merge.js.map +1 -1
- package/dist/setup/index.d.ts +13 -10
- package/dist/setup/index.d.ts.map +1 -1
- package/dist/setup/index.js +15 -10
- package/dist/setup/index.js.map +1 -1
- package/dist/setup/sections/llm.js +1 -1
- package/dist/setup/sections/llm.js.map +1 -1
- package/dist/setup/sections/system-one.d.ts +28 -0
- package/dist/setup/sections/system-one.d.ts.map +1 -0
- package/dist/setup/sections/system-one.js +53 -0
- package/dist/setup/sections/system-one.js.map +1 -0
- package/dist/setup/wizard.d.ts +15 -1
- package/dist/setup/wizard.d.ts.map +1 -1
- package/dist/setup/wizard.js +15 -0
- package/dist/setup/wizard.js.map +1 -1
- package/dist/skills/discovery.d.ts +12 -1
- package/dist/skills/discovery.d.ts.map +1 -1
- package/dist/skills/discovery.js +27 -2
- package/dist/skills/discovery.js.map +1 -1
- package/dist/skills/orchestrator/startup.d.ts.map +1 -1
- package/dist/skills/orchestrator/startup.js +10 -5
- package/dist/skills/orchestrator/startup.js.map +1 -1
- package/dist/skills/prune-bundled.d.ts +306 -0
- package/dist/skills/prune-bundled.d.ts.map +1 -0
- package/dist/skills/prune-bundled.js +652 -0
- package/dist/skills/prune-bundled.js.map +1 -0
- package/dist/skills/types.d.ts +9 -1
- package/dist/skills/types.d.ts.map +1 -1
- package/dist/skills/types.js +17 -34
- package/dist/skills/types.js.map +1 -1
- package/dist/spawn/branch-lock.d.ts.map +1 -1
- package/dist/spawn/branch-lock.js +26 -2
- package/dist/spawn/branch-lock.js.map +1 -1
- package/dist/stats/index.d.ts.map +1 -1
- package/dist/stats/index.js +4 -2
- package/dist/stats/index.js.map +1 -1
- package/dist/store/agent-registry-accessor.d.ts.map +1 -1
- package/dist/store/agent-registry-accessor.js +2 -0
- package/dist/store/agent-registry-accessor.js.map +1 -1
- package/dist/store/backup-pack.js +1 -1
- package/dist/store/backup-pack.js.map +1 -1
- package/dist/store/backup.d.ts +15 -1
- package/dist/store/backup.d.ts.map +1 -1
- package/dist/store/backup.js +18 -2
- package/dist/store/backup.js.map +1 -1
- package/dist/store/conduit-sqlite.d.ts.map +1 -1
- package/dist/store/conduit-sqlite.js +3 -0
- package/dist/store/conduit-sqlite.js.map +1 -1
- package/dist/store/credential-transfer.d.ts.map +1 -1
- package/dist/store/credential-transfer.js +2 -0
- package/dist/store/credential-transfer.js.map +1 -1
- package/dist/store/cross-db-cleanup.d.ts.map +1 -1
- package/dist/store/cross-db-cleanup.js +2 -0
- package/dist/store/cross-db-cleanup.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +13 -2
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/migrate-signaldock-to-conduit.d.ts.map +1 -1
- package/dist/store/migrate-signaldock-to-conduit.js +3 -0
- package/dist/store/migrate-signaldock-to-conduit.js.map +1 -1
- package/dist/store/migration-manager.d.ts.map +1 -1
- package/dist/store/migration-manager.js +37 -3
- package/dist/store/migration-manager.js.map +1 -1
- package/dist/store/migration-sqlite.d.ts.map +1 -1
- package/dist/store/migration-sqlite.js +2 -0
- package/dist/store/migration-sqlite.js.map +1 -1
- package/dist/store/nexus-sqlite.d.ts.map +1 -1
- package/dist/store/nexus-sqlite.js +3 -0
- package/dist/store/nexus-sqlite.js.map +1 -1
- package/dist/store/open-cleo-db.d.ts.map +1 -1
- package/dist/store/open-cleo-db.js +3 -0
- package/dist/store/open-cleo-db.js.map +1 -1
- package/dist/store/portable-bundle-import.d.ts.map +1 -1
- package/dist/store/portable-bundle-import.js +2 -0
- package/dist/store/portable-bundle-import.js.map +1 -1
- package/dist/store/portable-bundle-relocate.d.ts.map +1 -1
- package/dist/store/portable-bundle-relocate.js +2 -0
- package/dist/store/portable-bundle-relocate.js.map +1 -1
- package/dist/store/portable-bundle-scan.js +1 -1
- package/dist/store/portable-bundle-scan.js.map +1 -1
- package/dist/store/ports/domain-binding.d.ts.map +1 -1
- package/dist/store/ports/domain-binding.js +5 -0
- package/dist/store/ports/domain-binding.js.map +1 -1
- package/dist/store/skills-db.d.ts +17 -0
- package/dist/store/skills-db.d.ts.map +1 -1
- package/dist/store/skills-db.js +30 -0
- package/dist/store/skills-db.js.map +1 -1
- package/dist/store/snapshot-gate.d.ts.map +1 -1
- package/dist/store/snapshot-gate.js +3 -0
- package/dist/store/snapshot-gate.js.map +1 -1
- package/dist/store/split-brain-import.d.ts.map +1 -1
- package/dist/store/split-brain-import.js +2 -0
- package/dist/store/split-brain-import.js.map +1 -1
- package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
- package/dist/store/sqlite-data-accessor.js +19 -2
- package/dist/store/sqlite-data-accessor.js.map +1 -1
- package/dist/store/sqlite-native.d.ts.map +1 -1
- package/dist/store/sqlite-native.js +1 -0
- package/dist/store/sqlite-native.js.map +1 -1
- package/dist/store/sqlite.d.ts +14 -0
- package/dist/store/sqlite.d.ts.map +1 -1
- package/dist/store/sqlite.js +31 -4
- package/dist/store/sqlite.js.map +1 -1
- package/dist/store/twin-collapse.d.ts +46 -1
- package/dist/store/twin-collapse.d.ts.map +1 -1
- package/dist/store/twin-collapse.js +131 -5
- package/dist/store/twin-collapse.js.map +1 -1
- package/dist/store/worktree-build-guard.d.ts +191 -0
- package/dist/store/worktree-build-guard.d.ts.map +1 -0
- package/dist/store/worktree-build-guard.js +486 -0
- package/dist/store/worktree-build-guard.js.map +1 -0
- package/dist/store/worktree-isolation-guard.d.ts +27 -0
- package/dist/store/worktree-isolation-guard.d.ts.map +1 -1
- package/dist/store/worktree-isolation-guard.js +71 -3
- package/dist/store/worktree-isolation-guard.js.map +1 -1
- package/dist/store/writer-lease.d.ts.map +1 -1
- package/dist/store/writer-lease.js +2 -0
- package/dist/store/writer-lease.js.map +1 -1
- package/dist/system/backup.d.ts +6 -2
- package/dist/system/backup.d.ts.map +1 -1
- package/dist/system/backup.js +6 -3
- package/dist/system/backup.js.map +1 -1
- package/dist/system/inject-generate.d.ts.map +1 -1
- package/dist/system/inject-generate.js +4 -4
- package/dist/system/inject-generate.js.map +1 -1
- package/dist/task-tools/index.d.ts +4 -2
- package/dist/task-tools/index.d.ts.map +1 -1
- package/dist/task-tools/index.js +3 -2
- package/dist/task-tools/index.js.map +1 -1
- package/dist/task-tools/score-task-priority.d.ts +93 -18
- package/dist/task-tools/score-task-priority.d.ts.map +1 -1
- package/dist/task-tools/score-task-priority.js +193 -81
- package/dist/task-tools/score-task-priority.js.map +1 -1
- package/dist/task-work/index.d.ts +6 -0
- package/dist/task-work/index.d.ts.map +1 -1
- package/dist/task-work/index.js +6 -3
- package/dist/task-work/index.js.map +1 -1
- package/dist/tasks/affected-packages.d.ts +62 -13
- package/dist/tasks/affected-packages.d.ts.map +1 -1
- package/dist/tasks/affected-packages.js +158 -33
- package/dist/tasks/affected-packages.js.map +1 -1
- package/dist/tasks/affected-scope.d.ts +59 -0
- package/dist/tasks/affected-scope.d.ts.map +1 -0
- package/dist/tasks/affected-scope.js +81 -0
- package/dist/tasks/affected-scope.js.map +1 -0
- package/dist/tasks/analyze.d.ts +29 -1
- package/dist/tasks/analyze.d.ts.map +1 -1
- package/dist/tasks/analyze.js +52 -36
- package/dist/tasks/analyze.js.map +1 -1
- package/dist/tasks/backfill-child-projections.d.ts.map +1 -1
- package/dist/tasks/backfill-child-projections.js +4 -1
- package/dist/tasks/backfill-child-projections.js.map +1 -1
- package/dist/tasks/change-set.d.ts +24 -0
- package/dist/tasks/change-set.d.ts.map +1 -1
- package/dist/tasks/change-set.js +143 -11
- package/dist/tasks/change-set.js.map +1 -1
- package/dist/tasks/command-line.d.ts +54 -0
- package/dist/tasks/command-line.d.ts.map +1 -0
- package/dist/tasks/command-line.js +151 -0
- package/dist/tasks/command-line.js.map +1 -0
- package/dist/tasks/complete.d.ts +10 -0
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +49 -0
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/component-pr.d.ts +106 -0
- package/dist/tasks/component-pr.d.ts.map +1 -0
- package/dist/tasks/component-pr.js +275 -0
- package/dist/tasks/component-pr.js.map +1 -0
- package/dist/tasks/delete.d.ts.map +1 -1
- package/dist/tasks/delete.js +20 -0
- package/dist/tasks/delete.js.map +1 -1
- package/dist/tasks/done-plan.d.ts +21 -1
- package/dist/tasks/done-plan.d.ts.map +1 -1
- package/dist/tasks/done-plan.js +170 -15
- package/dist/tasks/done-plan.js.map +1 -1
- package/dist/tasks/done-record.d.ts.map +1 -1
- package/dist/tasks/done-record.js +9 -80
- package/dist/tasks/done-record.js.map +1 -1
- package/dist/tasks/duplicate-detector.d.ts +3 -3
- package/dist/tasks/duplicate-detector.d.ts.map +1 -1
- package/dist/tasks/duplicate-detector.js +4 -3
- package/dist/tasks/duplicate-detector.js.map +1 -1
- package/dist/tasks/engine-wrap-ops.d.ts +29 -0
- package/dist/tasks/engine-wrap-ops.d.ts.map +1 -1
- package/dist/tasks/engine-wrap-ops.js +40 -0
- package/dist/tasks/engine-wrap-ops.js.map +1 -1
- package/dist/tasks/engine-wrap.d.ts +1 -1
- package/dist/tasks/engine-wrap.d.ts.map +1 -1
- package/dist/tasks/engine-wrap.js +1 -1
- package/dist/tasks/engine-wrap.js.map +1 -1
- package/dist/tasks/evidence.d.ts +49 -2
- package/dist/tasks/evidence.d.ts.map +1 -1
- package/dist/tasks/evidence.js +85 -9
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/gate-runner.d.ts.map +1 -1
- package/dist/tasks/gate-runner.js +48 -12
- package/dist/tasks/gate-runner.js.map +1 -1
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/index.js +1 -1
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/ops.d.ts +1 -0
- package/dist/tasks/ops.d.ts.map +1 -1
- package/dist/tasks/ranking-audit.d.ts +122 -0
- package/dist/tasks/ranking-audit.d.ts.map +1 -0
- package/dist/tasks/ranking-audit.js +193 -0
- package/dist/tasks/ranking-audit.js.map +1 -0
- package/dist/tasks/task-analyze.d.ts.map +1 -1
- package/dist/tasks/task-analyze.js +19 -32
- package/dist/tasks/task-analyze.js.map +1 -1
- package/dist/tasks/task-next.d.ts +48 -2
- package/dist/tasks/task-next.d.ts.map +1 -1
- package/dist/tasks/task-next.js +84 -102
- package/dist/tasks/task-next.js.map +1 -1
- package/dist/tasks/task-ops.d.ts +1 -1
- package/dist/tasks/task-ops.d.ts.map +1 -1
- package/dist/tasks/task-ops.js +1 -1
- package/dist/tasks/task-ops.js.map +1 -1
- package/dist/tasks/tool-resolver.d.ts +7 -1
- package/dist/tasks/tool-resolver.d.ts.map +1 -1
- package/dist/tasks/tool-resolver.js +24 -10
- package/dist/tasks/tool-resolver.js.map +1 -1
- package/dist/tasks/update.d.ts +8 -2
- package/dist/tasks/update.d.ts.map +1 -1
- package/dist/tasks/update.js +28 -1
- package/dist/tasks/update.js.map +1 -1
- package/dist/telemetry/sqlite.d.ts.map +1 -1
- package/dist/telemetry/sqlite.js +2 -0
- package/dist/telemetry/sqlite.js.map +1 -1
- package/dist/validation/doctor/checks.d.ts.map +1 -1
- package/dist/validation/doctor/checks.js +2 -2
- package/dist/validation/doctor/checks.js.map +1 -1
- package/dist/validation/engine-ops.d.ts +9 -1
- package/dist/validation/engine-ops.d.ts.map +1 -1
- package/dist/validation/engine-ops.js +24 -1
- package/dist/validation/engine-ops.js.map +1 -1
- package/dist/validation/validate-ops.d.ts.map +1 -1
- package/dist/validation/validate-ops.js +9 -3
- package/dist/validation/validate-ops.js.map +1 -1
- package/dist/worktree/worktree-adopt.d.ts.map +1 -1
- package/dist/worktree/worktree-adopt.js +5 -2
- package/dist/worktree/worktree-adopt.js.map +1 -1
- package/package.json +14 -14
- package/schemas/config.schema.json +13 -0
- package/templates/CLEO-INJECTION.md +1 -1
- package/templates/CLEO-REFERENCE.md +5 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ranking-input audit trail (T12693, owner decision D11161).
|
|
3
|
+
*
|
|
4
|
+
* Agents may write a task's ranking inputs — priority, severity, kind and
|
|
5
|
+
* depends — directly, but every such change records WHO (actor), in WHICH
|
|
6
|
+
* session, WHY (optional reason) and the values before and after, as one
|
|
7
|
+
* `ranking_changed` row in the task audit log, written in the same
|
|
8
|
+
* transaction as the change. `cleo history ranking <id>` lists them and
|
|
9
|
+
* `cleo history revert <entryId>` undoes one.
|
|
10
|
+
*
|
|
11
|
+
* @task T12693
|
|
12
|
+
*/
|
|
13
|
+
import { ExitCode } from '@cleocode/contracts';
|
|
14
|
+
import { CleoError } from '../errors.js';
|
|
15
|
+
import { resolveAgentIdFromEnv, resolveSessionIdFromEnv } from '../sessions/session-id.js';
|
|
16
|
+
import { getTaskAccessor } from '../store/data-accessor.js';
|
|
17
|
+
/** The audit action a ranking change is recorded under. */
|
|
18
|
+
export const RANKING_CHANGED_ACTION = 'ranking_changed';
|
|
19
|
+
/** Fields the ranking sort reads (D11161). */
|
|
20
|
+
export const RANKING_FIELDS = ['priority', 'severity', 'kind', 'depends'];
|
|
21
|
+
/**
|
|
22
|
+
* A task's ranking inputs.
|
|
23
|
+
*
|
|
24
|
+
* @param task - The task.
|
|
25
|
+
* @returns The snapshot (depends sorted, so order changes are not changes).
|
|
26
|
+
* @task T12693
|
|
27
|
+
*/
|
|
28
|
+
export function rankingSnapshot(task) {
|
|
29
|
+
return {
|
|
30
|
+
priority: task.priority ?? null,
|
|
31
|
+
severity: task.severity ?? null,
|
|
32
|
+
kind: task.kind ?? null,
|
|
33
|
+
depends: [...(task.depends ?? [])].sort(),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The ranking fields that differ between two snapshots.
|
|
38
|
+
*
|
|
39
|
+
* @param before - Snapshot before the change.
|
|
40
|
+
* @param after - Snapshot after it.
|
|
41
|
+
* @returns Changed fields, in {@link RANKING_FIELDS} order.
|
|
42
|
+
* @task T12693
|
|
43
|
+
*/
|
|
44
|
+
export function rankingDiff(before, after) {
|
|
45
|
+
return RANKING_FIELDS.filter((field) => field === 'depends'
|
|
46
|
+
? before.depends.join('\0') !== after.depends.join('\0')
|
|
47
|
+
: before[field] !== after[field]);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The actor and session a change is attributed to: the agent id
|
|
51
|
+
* (`CLEO_AGENT_ID`, else `human`) and the caller's session (env first, then
|
|
52
|
+
* the bound session).
|
|
53
|
+
*
|
|
54
|
+
* @param cwd - Project root.
|
|
55
|
+
* @returns The actor and session.
|
|
56
|
+
* @task T12693
|
|
57
|
+
*/
|
|
58
|
+
export async function resolveRankingActor(cwd) {
|
|
59
|
+
let sessionId = resolveSessionIdFromEnv();
|
|
60
|
+
if (!sessionId) {
|
|
61
|
+
try {
|
|
62
|
+
const { resolveBoundSessionId } = await import('../store/session-store.js');
|
|
63
|
+
sessionId = (await resolveBoundSessionId(cwd)) ?? null;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
sessionId = null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { actor: resolveAgentIdFromEnv() ?? 'human', sessionId };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The audit-log entry for one ranking change, or null when nothing ranking
|
|
73
|
+
* related changed. Only the changed fields are stored before and after.
|
|
74
|
+
*
|
|
75
|
+
* @param input - Task, snapshots, attribution and why.
|
|
76
|
+
* @returns The `appendLog` entry, or null.
|
|
77
|
+
* @task T12693
|
|
78
|
+
*/
|
|
79
|
+
export function rankingAuditEntry(input) {
|
|
80
|
+
const fields = rankingDiff(input.before, input.after);
|
|
81
|
+
if (fields.length === 0)
|
|
82
|
+
return null;
|
|
83
|
+
const pick = (snap) => Object.fromEntries(fields.map((f) => [f, snap[f]]));
|
|
84
|
+
return {
|
|
85
|
+
id: `log-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`,
|
|
86
|
+
timestamp: new Date().toISOString(),
|
|
87
|
+
action: RANKING_CHANGED_ACTION,
|
|
88
|
+
taskId: input.taskId,
|
|
89
|
+
actor: input.actor.actor,
|
|
90
|
+
sessionId: input.actor.sessionId,
|
|
91
|
+
details: {
|
|
92
|
+
fields,
|
|
93
|
+
reason: input.reason?.trim() ? input.reason.trim() : null,
|
|
94
|
+
source: input.source,
|
|
95
|
+
},
|
|
96
|
+
before: pick(input.before),
|
|
97
|
+
after: pick(input.after),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function parseRow(row) {
|
|
101
|
+
const json = (text, fallback) => {
|
|
102
|
+
try {
|
|
103
|
+
return text ? JSON.parse(text) : fallback;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return fallback;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const details = json(row.detailsJson, {});
|
|
110
|
+
return {
|
|
111
|
+
id: row.id,
|
|
112
|
+
taskId: row.taskId,
|
|
113
|
+
timestamp: row.timestamp,
|
|
114
|
+
actor: row.actor,
|
|
115
|
+
sessionId: row.sessionId ?? null,
|
|
116
|
+
reason: details.reason ?? null,
|
|
117
|
+
source: details.source ?? null,
|
|
118
|
+
fields: details.fields ?? [],
|
|
119
|
+
before: json(row.beforeJson, {}),
|
|
120
|
+
after: json(row.afterJson, {}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Who changed a task's ranking inputs, when, and why — newest first.
|
|
125
|
+
*
|
|
126
|
+
* @param taskId - Task.
|
|
127
|
+
* @param cwd - Project root.
|
|
128
|
+
* @param limit - Maximum rows (default 50).
|
|
129
|
+
* @returns The recorded changes.
|
|
130
|
+
* @task T12693
|
|
131
|
+
*/
|
|
132
|
+
export async function listRankingHistory(taskId, cwd, limit = 50) {
|
|
133
|
+
const accessor = await getTaskAccessor(cwd);
|
|
134
|
+
const rows = await accessor.queryAuditLog({
|
|
135
|
+
taskIds: [taskId],
|
|
136
|
+
actions: [RANKING_CHANGED_ACTION],
|
|
137
|
+
limit,
|
|
138
|
+
});
|
|
139
|
+
return rows.map(parseRow);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Undo one recorded ranking change: set each field it changed back to its
|
|
143
|
+
* value before, as a new audited change (source `revert`). Refused when a
|
|
144
|
+
* field has changed again since, so a later decision is never silently lost —
|
|
145
|
+
* unless `force`.
|
|
146
|
+
*
|
|
147
|
+
* @param entryId - The `ranking_changed` audit row id.
|
|
148
|
+
* @param opts - Why (recorded), and `force` to revert over later changes.
|
|
149
|
+
* @param cwd - Project root.
|
|
150
|
+
* @returns The task id, the reverted fields and the new audit row id.
|
|
151
|
+
* @throws {CleoError} When the entry is not a ranking change, or a field
|
|
152
|
+
* changed since and `force` is not set.
|
|
153
|
+
* @task T12693
|
|
154
|
+
*/
|
|
155
|
+
export async function revertRankingChange(entryId, opts = {}, cwd) {
|
|
156
|
+
const accessor = await getTaskAccessor(cwd);
|
|
157
|
+
const [row] = await accessor.queryAuditLog({ ids: [entryId], actions: [RANKING_CHANGED_ACTION] });
|
|
158
|
+
if (!row) {
|
|
159
|
+
throw new CleoError(ExitCode.NOT_FOUND, `No ranking change ${entryId}`, {
|
|
160
|
+
fix: 'cleo history ranking <taskId> # lists ranking changes with their ids',
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
const change = parseRow(row);
|
|
164
|
+
const task = await accessor.loadSingleTask(change.taskId);
|
|
165
|
+
if (!task) {
|
|
166
|
+
throw new CleoError(ExitCode.NOT_FOUND, `Task ${change.taskId} no longer exists`);
|
|
167
|
+
}
|
|
168
|
+
const current = rankingSnapshot(task);
|
|
169
|
+
const moved = change.fields.filter((field) => {
|
|
170
|
+
const now = current[field];
|
|
171
|
+
const then = change.after[field];
|
|
172
|
+
return field === 'depends'
|
|
173
|
+
? [...now].sort().join('\0') !==
|
|
174
|
+
[...(then ?? [])].sort().join('\0')
|
|
175
|
+
: now !== (then ?? null);
|
|
176
|
+
});
|
|
177
|
+
if (moved.length > 0 && !opts.force) {
|
|
178
|
+
throw new CleoError(ExitCode.VALIDATION_ERROR, `${change.taskId}'s ${moved.join(', ')} changed again after ${entryId}; reverting would discard that later change`, { fix: `cleo history ranking ${change.taskId} # or re-run with --force` });
|
|
179
|
+
}
|
|
180
|
+
const { updateTask } = await import('./update.js');
|
|
181
|
+
const back = change.before;
|
|
182
|
+
await updateTask({
|
|
183
|
+
taskId: change.taskId,
|
|
184
|
+
...(change.fields.includes('priority') && back.priority ? { priority: back.priority } : {}),
|
|
185
|
+
...(change.fields.includes('severity') ? { severity: back.severity ?? null } : {}),
|
|
186
|
+
...(change.fields.includes('kind') && back.kind ? { kind: back.kind } : {}),
|
|
187
|
+
...(change.fields.includes('depends') ? { depends: back.depends ?? [] } : {}),
|
|
188
|
+
reason: `revert ${entryId}${opts.reason?.trim() ? `: ${opts.reason.trim()}` : ''}`,
|
|
189
|
+
rankingSource: 'revert',
|
|
190
|
+
}, cwd, accessor);
|
|
191
|
+
return { taskId: change.taskId, fields: change.fields, revertedTo: back };
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=ranking-audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ranking-audit.js","sourceRoot":"","sources":["../../src/tasks/ranking-audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,2DAA2D;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAExD,8CAA8C;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,CAAU,CAAC;AAmCnF;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,IAA8D;IAE9D,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI;QAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI;QAC/B,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI;QACvB,OAAO,EA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AClF,aAAa,EAAE,QAAQ;KACxB,EACD,GAAG,EACH,QAAQ,CACT,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAC5E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-analyze.d.ts","sourceRoot":"","sources":["../../src/tasks/task-analyze.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"task-analyze.d.ts","sourceRoot":"","sources":["../../src/tasks/task-analyze.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAKpE,sDAAsD;AACtD,KAAK,UAAU,GAAG,IAAI,CAAC;AAEvB,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;CAChB;AAQD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAChC,OAAO,GAAE,GAAG,CAAC,MAAM,CAAa,GAC/B,MAAM,CAaR;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9B,OAAO,CAAC,kBAAkB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAqErD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,0BAA0B,CAC9C,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GACzB,OAAO,CAAC;IACT,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC,CA8DD"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* @epic T9834
|
|
5
5
|
*/
|
|
6
6
|
import { getTaskAccessor } from '../store/data-accessor.js';
|
|
7
|
+
import { computeLeverage } from '../task-tools/score-task-priority.js';
|
|
8
|
+
import { rankForAnalysis } from './analyze.js';
|
|
7
9
|
async function loadAllTasks(projectRoot) {
|
|
8
10
|
const accessor = await getTaskAccessor(projectRoot);
|
|
9
11
|
const { tasks } = await accessor.queryTasks({});
|
|
@@ -54,44 +56,29 @@ export function measureDependencyDepth(taskId, taskMap, visited = new Set()) {
|
|
|
54
56
|
* @task T4790
|
|
55
57
|
*/
|
|
56
58
|
export async function coreTaskAnalyze(projectRoot, taskId, params) {
|
|
57
|
-
const
|
|
59
|
+
const accessor = await getTaskAccessor(projectRoot);
|
|
60
|
+
const { tasks: allTasks } = await accessor.queryTasks({});
|
|
58
61
|
const effectiveTierLimit = params?.tierLimit ?? 10;
|
|
59
62
|
const tasks = taskId
|
|
60
63
|
? allTasks.filter((t) => t.id === taskId || t.parentId === taskId)
|
|
61
64
|
: allTasks;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (task.depends) {
|
|
65
|
-
for (const dep of task.depends) {
|
|
66
|
-
if (!blocksMap[dep])
|
|
67
|
-
blocksMap[dep] = [];
|
|
68
|
-
blocksMap[dep].push(task.id);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const leverageMap = {};
|
|
73
|
-
for (const task of tasks) {
|
|
74
|
-
leverageMap[task.id] = (blocksMap[task.id] ?? []).length;
|
|
75
|
-
}
|
|
76
|
-
const actionable = tasks.filter((t) => t.status === 'pending' || t.status === 'active');
|
|
65
|
+
// Open tasks each task unblocks — the same leverage the shared scorer uses (T12661).
|
|
66
|
+
const openDependents = computeLeverage(tasks);
|
|
77
67
|
const blocked = tasks.filter((t) => t.status === 'blocked');
|
|
78
68
|
const bottlenecks = tasks
|
|
79
|
-
.filter((t) => (
|
|
80
|
-
.map((t) => ({ id: t.id, title: t.title, blocksCount:
|
|
81
|
-
.sort((a, b) => b.blocksCount - a.blocksCount)
|
|
69
|
+
.filter((t) => (openDependents.get(t.id) ?? 0) > 0 && t.status !== 'done')
|
|
70
|
+
.map((t) => ({ id: t.id, title: t.title, blocksCount: openDependents.get(t.id) ?? 0 }))
|
|
71
|
+
.sort((a, b) => b.blocksCount - a.blocksCount || a.id.localeCompare(b.id))
|
|
82
72
|
.slice(0, 5);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}));
|
|
89
|
-
scored.sort((a, b) => {
|
|
90
|
-
const priorityWeight = { critical: 100, high: 50, medium: 20, low: 5 };
|
|
91
|
-
const aScore = (priorityWeight[a.priority ?? 'medium'] ?? 20) + a.leverage * 10;
|
|
92
|
-
const bScore = (priorityWeight[b.priority ?? 'medium'] ?? 20) + b.leverage * 10;
|
|
93
|
-
return bScore - aScore;
|
|
73
|
+
// T12661: the same ranking as `cleo next` and the briefing (ready candidates,
|
|
74
|
+
// current phase, BRAIN patterns, shared scorer), scoped to `taskId` when given.
|
|
75
|
+
const { ranked: scored } = await rankForAnalysis(accessor, allTasks, {
|
|
76
|
+
projectRoot,
|
|
77
|
+
...(taskId ? { scopeTaskIds: new Set(tasks.map((t) => t.id)) } : {}),
|
|
94
78
|
});
|
|
79
|
+
// The metric keeps its meaning (pending + active); the tiers above rank only
|
|
80
|
+
// the READY subset, exactly as `cleo next` does.
|
|
81
|
+
const actionable = tasks.filter((t) => t.status === 'pending' || t.status === 'active');
|
|
95
82
|
const critical = scored.filter((t) => t.priority === 'critical');
|
|
96
83
|
const high = scored.filter((t) => t.priority === 'high');
|
|
97
84
|
const normal = scored.filter((t) => t.priority !== 'critical' && t.priority !== 'high');
|
|
@@ -100,10 +87,10 @@ export async function coreTaskAnalyze(projectRoot, taskId, params) {
|
|
|
100
87
|
id: scored[0].id,
|
|
101
88
|
title: scored[0].title,
|
|
102
89
|
leverage: scored[0].leverage,
|
|
103
|
-
reason: '
|
|
90
|
+
reason: 'Top of the shared task ranking — the same order as `cleo next`',
|
|
104
91
|
}
|
|
105
92
|
: null;
|
|
106
|
-
const totalLeverage =
|
|
93
|
+
const totalLeverage = [...openDependents.values()].reduce((s, v) => s + v, 0);
|
|
107
94
|
const avgLeverage = tasks.length > 0 ? Math.round((totalLeverage / tasks.length) * 100) / 100 : 0;
|
|
108
95
|
return {
|
|
109
96
|
recommended,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-analyze.js","sourceRoot":"","sources":["../../src/tasks/task-analyze.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"task-analyze.js","sourceRoot":"","sources":["../../src/tasks/task-analyze.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAe/C,KAAK,UAAU,YAAY,CAAC,WAAmB;IAC7C,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,WAAW,CAAC,CAAC;IACpD,MAAM,EAAE,KAAK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AC1B,IAAI,KAAK,IAAI,CAAC;QAAE,IAAI,GAAG,QAAQ,CAAC;;QAChC,IAAI,GAAG,OAAO,CAAC;IAEpB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;AAC5E,CAAC"}
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* @task T10064
|
|
4
4
|
* @epic T9834
|
|
5
5
|
*/
|
|
6
|
+
import type { Task } from '@cleocode/contracts';
|
|
7
|
+
import type { DataAccessor } from '../store/data-accessor.js';
|
|
8
|
+
import { type RankedTask } from '../task-tools/score-task-priority.js';
|
|
6
9
|
/**
|
|
7
10
|
* Suggest next task to work on based on priority, phase, age, and deps.
|
|
8
11
|
*
|
|
@@ -10,11 +13,18 @@
|
|
|
10
13
|
* @param params - Optional scoring configuration
|
|
11
14
|
* @param params.count - Number of suggestions to return (default: 1)
|
|
12
15
|
* @param params.explain - When true, include scoring reasons in each suggestion
|
|
16
|
+
* @param params.brain - Brain pattern scoring (default true). A one-line
|
|
17
|
+
* "next ready task" hint (stale `cleo current`, a completion's
|
|
18
|
+
* `nextSuggested`) passes false: no brain store is opened (T12689).
|
|
13
19
|
* @returns Ranked suggestions with scores and the total number of eligible candidates
|
|
14
20
|
*
|
|
15
21
|
* @remarks
|
|
16
|
-
*
|
|
17
|
-
*
|
|
22
|
+
* Ranks through the shared {@link scoreTask} (via {@link rankReadyTasks}):
|
|
23
|
+
* the lexicographic D11161 key — priority band, then attested severity (an
|
|
24
|
+
* unset severity is unknown; nothing is imputed from `kind`), then a bounded
|
|
25
|
+
* tiebreak (dependency readiness, phase alignment, leverage, age), then
|
|
26
|
+
* `createdAt`, then id. BRAIN patterns are informational factors only.
|
|
27
|
+
* `explain` returns every factor. The briefing's `nextTasks` uses the same ranking (T12661).
|
|
18
28
|
* Candidates retain the active query population; a separate canonical lookup
|
|
19
29
|
* resolves explicit dependencies, including archived records. Missing/cancelled
|
|
20
30
|
* prerequisites block selection, and required dependency-read failures propagate.
|
|
@@ -32,6 +42,7 @@
|
|
|
32
42
|
export declare function coreTaskNext(projectRoot: string, params?: {
|
|
33
43
|
count?: number;
|
|
34
44
|
explain?: boolean;
|
|
45
|
+
brain?: boolean;
|
|
35
46
|
}): Promise<{
|
|
36
47
|
suggestions: Array<{
|
|
37
48
|
id: string;
|
|
@@ -43,4 +54,39 @@ export declare function coreTaskNext(projectRoot: string, params?: {
|
|
|
43
54
|
}>;
|
|
44
55
|
totalCandidates: number;
|
|
45
56
|
}>;
|
|
57
|
+
/**
|
|
58
|
+
* The phase that earns the phase-alignment bonus: the caller's session focus
|
|
59
|
+
* phase, else the project's current phase. `cleo next` and the briefing both
|
|
60
|
+
* resolve it here so they rank identically (T12661).
|
|
61
|
+
*
|
|
62
|
+
* @param accessor - Task data accessor.
|
|
63
|
+
* @returns The phase slug, or null.
|
|
64
|
+
* @task T12661
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveRankingPhase(accessor: DataAccessor): Promise<string | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Rank every READY task — pending, not cancelled, all dependencies satisfied
|
|
69
|
+
* under the canonical lookup (archived dependencies included) — through the
|
|
70
|
+
* shared {@link scoreTask}. The single ranking behind `cleo next` and the
|
|
71
|
+
* briefing's `nextTasks` (T12661).
|
|
72
|
+
*
|
|
73
|
+
* @param accessor - Task data accessor (for dependency records outside `allTasks`).
|
|
74
|
+
* @param allTasks - The active task population.
|
|
75
|
+
* @param opts - Current phase, optional id scope, `nowMs`, and `projectRoot`
|
|
76
|
+
* to attach BRAIN success/failure patterns as informational factors
|
|
77
|
+
* (best-effort; they are not part of the order).
|
|
78
|
+
* @returns Ranked candidates, how many there were, and the leverage map used.
|
|
79
|
+
* @task T12661
|
|
80
|
+
*/
|
|
81
|
+
export declare function rankReadyTasks(accessor: DataAccessor, allTasks: readonly Task[], opts: {
|
|
82
|
+
currentPhase: string | null;
|
|
83
|
+
scopeTaskIds?: ReadonlySet<string>;
|
|
84
|
+
projectRoot?: string;
|
|
85
|
+
/** Clock for the age tiebreak; one instant for the whole ranking. */
|
|
86
|
+
nowMs?: number;
|
|
87
|
+
}): Promise<{
|
|
88
|
+
ranked: RankedTask<Task>[];
|
|
89
|
+
totalCandidates: number;
|
|
90
|
+
leverage: ReadonlyMap<string, number>;
|
|
91
|
+
}>;
|
|
46
92
|
//# sourceMappingURL=task-next.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-next.d.ts","sourceRoot":"","sources":["../../src/tasks/task-next.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"task-next.d.ts","sourceRoot":"","sources":["../../src/tasks/task-next.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAiC,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,sCAAsC,CAAC;AAI9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,OAAO,CAAC;IACT,WAAW,EAAE,KAAK,CAAC;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC,CAAC;IACH,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAsBD;AAED;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAOxF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,SAAS,IAAI,EAAE,EACzB,IAAI,EAAE;IACJ,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACA,OAAO,CAAC;IACT,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC,CAkCD"}
|
package/dist/tasks/task-next.js
CHANGED
|
@@ -3,32 +3,12 @@
|
|
|
3
3
|
* @task T10064
|
|
4
4
|
* @epic T9834
|
|
5
5
|
*/
|
|
6
|
+
import { readFocusState } from '../sessions/focus-state-store.js';
|
|
7
|
+
import { resolveSessionIdFromEnv } from '../sessions/session-id.js';
|
|
6
8
|
import { getTaskAccessor } from '../store/data-accessor.js';
|
|
9
|
+
import { computeLeverage, formatScoreFactor, rankTasks, } from '../task-tools/score-task-priority.js';
|
|
7
10
|
import { loadReadinessDependencyLookup } from './dependency-check.js';
|
|
8
11
|
import { depsReady } from './deps-ready.js';
|
|
9
|
-
const PRIORITY_SCORE = {
|
|
10
|
-
critical: 100,
|
|
11
|
-
high: 75,
|
|
12
|
-
medium: 50,
|
|
13
|
-
low: 25,
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Severity-axis score bumps (T9905 unified urgency surface).
|
|
17
|
-
*
|
|
18
|
-
* Severity is orthogonal to priority — a task can have `priority='medium'` and
|
|
19
|
-
* `severity='P0'` (e.g. a freshly-filed P0 incident before triage promotes its
|
|
20
|
-
* priority). Without a severity boost the P0 work sits below an unrelated
|
|
21
|
-
* `priority='high'` task in the `next` ranking, which inverts the operator's
|
|
22
|
-
* expectations. The bump is conservative (P0 = +30, P1 = +15) so that
|
|
23
|
-
* `priority='critical'` (+100) still wins all ties, but a P0/P1 row decisively
|
|
24
|
-
* outranks any `priority='medium'` peer with no severity set.
|
|
25
|
-
*
|
|
26
|
-
* @task T9905
|
|
27
|
-
*/
|
|
28
|
-
const SEVERITY_SCORE = {
|
|
29
|
-
P0: 30,
|
|
30
|
-
P1: 15,
|
|
31
|
-
};
|
|
32
12
|
/**
|
|
33
13
|
* Suggest next task to work on based on priority, phase, age, and deps.
|
|
34
14
|
*
|
|
@@ -36,11 +16,18 @@ const SEVERITY_SCORE = {
|
|
|
36
16
|
* @param params - Optional scoring configuration
|
|
37
17
|
* @param params.count - Number of suggestions to return (default: 1)
|
|
38
18
|
* @param params.explain - When true, include scoring reasons in each suggestion
|
|
19
|
+
* @param params.brain - Brain pattern scoring (default true). A one-line
|
|
20
|
+
* "next ready task" hint (stale `cleo current`, a completion's
|
|
21
|
+
* `nextSuggested`) passes false: no brain store is opened (T12689).
|
|
39
22
|
* @returns Ranked suggestions with scores and the total number of eligible candidates
|
|
40
23
|
*
|
|
41
24
|
* @remarks
|
|
42
|
-
*
|
|
43
|
-
*
|
|
25
|
+
* Ranks through the shared {@link scoreTask} (via {@link rankReadyTasks}):
|
|
26
|
+
* the lexicographic D11161 key — priority band, then attested severity (an
|
|
27
|
+
* unset severity is unknown; nothing is imputed from `kind`), then a bounded
|
|
28
|
+
* tiebreak (dependency readiness, phase alignment, leverage, age), then
|
|
29
|
+
* `createdAt`, then id. BRAIN patterns are informational factors only.
|
|
30
|
+
* `explain` returns every factor. The briefing's `nextTasks` uses the same ranking (T12661).
|
|
44
31
|
* Candidates retain the active query population; a separate canonical lookup
|
|
45
32
|
* resolves explicit dependencies, including archived records. Missing/cancelled
|
|
46
33
|
* prerequisites block selection, and required dependency-read failures propagate.
|
|
@@ -58,89 +45,84 @@ const SEVERITY_SCORE = {
|
|
|
58
45
|
export async function coreTaskNext(projectRoot, params) {
|
|
59
46
|
const accessor = await getTaskAccessor(projectRoot);
|
|
60
47
|
const { tasks: allTasks } = await accessor.queryTasks({});
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
const scored = candidates
|
|
69
|
-
.map((task) => {
|
|
70
|
-
const reasons = [];
|
|
71
|
-
let score = 0;
|
|
72
|
-
score += PRIORITY_SCORE[task.priority] ?? 50;
|
|
73
|
-
reasons.push(`priority: ${task.priority} (+${PRIORITY_SCORE[task.priority] ?? 50})`);
|
|
74
|
-
// T9905: severity axis boost — orthogonal to priority.
|
|
75
|
-
const severityKey = task.severity ?? '';
|
|
76
|
-
const severityBump = SEVERITY_SCORE[severityKey];
|
|
77
|
-
if (severityBump !== undefined) {
|
|
78
|
-
score += severityBump;
|
|
79
|
-
reasons.push(`severity: ${severityKey} (+${severityBump})`);
|
|
80
|
-
}
|
|
81
|
-
if (currentPhase && task.phase === currentPhase) {
|
|
82
|
-
score += 20;
|
|
83
|
-
reasons.push(`phase alignment: ${currentPhase} (+20)`);
|
|
84
|
-
}
|
|
85
|
-
if (depsReady(task.depends, dependencyLookup)) {
|
|
86
|
-
score += 10;
|
|
87
|
-
reasons.push('all dependencies satisfied (+10)');
|
|
88
|
-
}
|
|
89
|
-
if (task.createdAt) {
|
|
90
|
-
const ageMs = Date.now() - new Date(task.createdAt).getTime();
|
|
91
|
-
const ageDays = ageMs / (1000 * 60 * 60 * 24);
|
|
92
|
-
if (ageDays > 7) {
|
|
93
|
-
const ageBonus = Math.min(15, Math.floor(ageDays / 7));
|
|
94
|
-
score += ageBonus;
|
|
95
|
-
reasons.push(`age: ${Math.floor(ageDays)} days (+${ageBonus})`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return { task, score, reasons };
|
|
99
|
-
})
|
|
100
|
-
.sort((a, b) => b.score - a.score);
|
|
101
|
-
// Brain pattern scoring (best-effort)
|
|
102
|
-
try {
|
|
103
|
-
const { searchPatterns } = await import('../memory/patterns.js');
|
|
104
|
-
const [successPatterns, failurePatterns] = await Promise.all([
|
|
105
|
-
searchPatterns(projectRoot, { type: 'success', limit: 20 }),
|
|
106
|
-
searchPatterns(projectRoot, { type: 'failure', limit: 20 }),
|
|
107
|
-
]);
|
|
108
|
-
if (successPatterns.length > 0 || failurePatterns.length > 0) {
|
|
109
|
-
for (const item of scored) {
|
|
110
|
-
const titleLower = item.task.title.toLowerCase();
|
|
111
|
-
const labels = (item.task.labels ?? []).map((l) => l.toLowerCase());
|
|
112
|
-
const matchText = [titleLower, ...labels].join(' ');
|
|
113
|
-
for (const sp of successPatterns) {
|
|
114
|
-
if (matchText.includes(sp.pattern.toLowerCase())) {
|
|
115
|
-
item.score += 10;
|
|
116
|
-
item.reasons.push(`brain: success pattern match "${sp.pattern}" (+10)`);
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
for (const fp of failurePatterns) {
|
|
121
|
-
if (matchText.includes(fp.pattern.toLowerCase())) {
|
|
122
|
-
item.score -= 5;
|
|
123
|
-
item.reasons.push(`brain: failure pattern match "${fp.pattern}" (-5)`);
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
scored.sort((a, b) => b.score - a.score);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
// Brain pattern scoring is best-effort
|
|
133
|
-
}
|
|
134
|
-
const count = Math.min(params?.count || 1, scored.length);
|
|
48
|
+
const { ranked, totalCandidates } = await rankReadyTasks(accessor, allTasks, {
|
|
49
|
+
currentPhase: await resolveRankingPhase(accessor),
|
|
50
|
+
// T12689: a one-line hint (`brain: false`) opens no brain store.
|
|
51
|
+
...(params?.brain !== false && { projectRoot }),
|
|
52
|
+
});
|
|
53
|
+
const count = Math.min(params?.count || 1, ranked.length);
|
|
135
54
|
const explain = params?.explain ?? false;
|
|
136
|
-
const suggestions =
|
|
55
|
+
const suggestions = ranked.slice(0, count).map(({ task, score, factors }) => ({
|
|
137
56
|
id: task.id,
|
|
138
57
|
title: task.title,
|
|
139
58
|
priority: task.priority,
|
|
140
59
|
phase: task.phase ?? null,
|
|
141
60
|
score,
|
|
142
|
-
...(explain && { reasons }),
|
|
61
|
+
...(explain && { reasons: factors.map(formatScoreFactor) }),
|
|
143
62
|
}));
|
|
144
|
-
return { suggestions, totalCandidates
|
|
63
|
+
return { suggestions, totalCandidates };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The phase that earns the phase-alignment bonus: the caller's session focus
|
|
67
|
+
* phase, else the project's current phase. `cleo next` and the briefing both
|
|
68
|
+
* resolve it here so they rank identically (T12661).
|
|
69
|
+
*
|
|
70
|
+
* @param accessor - Task data accessor.
|
|
71
|
+
* @returns The phase slug, or null.
|
|
72
|
+
* @task T12661
|
|
73
|
+
*/
|
|
74
|
+
export async function resolveRankingPhase(accessor) {
|
|
75
|
+
// Only the focus PHASE is read here, never the task pointer, so the stale-
|
|
76
|
+
// pointer check in readLiveFocus (and its task load) does not apply.
|
|
77
|
+
const focus = await readFocusState(accessor, resolveSessionIdFromEnv());
|
|
78
|
+
if (focus?.currentPhase)
|
|
79
|
+
return focus.currentPhase;
|
|
80
|
+
const projectMeta = await accessor.getMetaValue('project_meta');
|
|
81
|
+
return projectMeta?.currentPhase ?? null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Rank every READY task — pending, not cancelled, all dependencies satisfied
|
|
85
|
+
* under the canonical lookup (archived dependencies included) — through the
|
|
86
|
+
* shared {@link scoreTask}. The single ranking behind `cleo next` and the
|
|
87
|
+
* briefing's `nextTasks` (T12661).
|
|
88
|
+
*
|
|
89
|
+
* @param accessor - Task data accessor (for dependency records outside `allTasks`).
|
|
90
|
+
* @param allTasks - The active task population.
|
|
91
|
+
* @param opts - Current phase, optional id scope, `nowMs`, and `projectRoot`
|
|
92
|
+
* to attach BRAIN success/failure patterns as informational factors
|
|
93
|
+
* (best-effort; they are not part of the order).
|
|
94
|
+
* @returns Ranked candidates, how many there were, and the leverage map used.
|
|
95
|
+
* @task T12661
|
|
96
|
+
*/
|
|
97
|
+
export async function rankReadyTasks(accessor, allTasks, opts) {
|
|
98
|
+
const dependencyLookup = await loadReadinessDependencyLookup(allTasks, accessor);
|
|
99
|
+
const candidates = allTasks.filter((t) => t.status === 'pending' &&
|
|
100
|
+
!t.cancelledAt &&
|
|
101
|
+
(!opts.scopeTaskIds || opts.scopeTaskIds.has(t.id)) &&
|
|
102
|
+
depsReady(t.depends, dependencyLookup));
|
|
103
|
+
const leverage = computeLeverage(allTasks);
|
|
104
|
+
if (candidates.length === 0)
|
|
105
|
+
return { ranked: [], totalCandidates: 0, leverage };
|
|
106
|
+
const ctx = {
|
|
107
|
+
currentPhase: opts.currentPhase,
|
|
108
|
+
nowMs: opts.nowMs ?? Date.now(),
|
|
109
|
+
taskStatuses: new Map([...dependencyLookup.values()].map((task) => [task.id, task.status])),
|
|
110
|
+
leverage,
|
|
111
|
+
};
|
|
112
|
+
if (opts.projectRoot) {
|
|
113
|
+
try {
|
|
114
|
+
const { searchPatterns } = await import('../memory/patterns.js');
|
|
115
|
+
const [success, failure] = await Promise.all([
|
|
116
|
+
searchPatterns(opts.projectRoot, { type: 'success', limit: 20 }),
|
|
117
|
+
searchPatterns(opts.projectRoot, { type: 'failure', limit: 20 }),
|
|
118
|
+
]);
|
|
119
|
+
ctx.successPatterns = success;
|
|
120
|
+
ctx.failurePatterns = failure;
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// Brain pattern scoring is best-effort
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return { ranked: rankTasks(candidates, ctx), totalCandidates: candidates.length, leverage };
|
|
145
127
|
}
|
|
146
128
|
//# sourceMappingURL=task-next.js.map
|