@cleocode/cleo 2026.4.10 → 2026.4.11
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/cli/commander-shim.d.ts +112 -0
- package/dist/cli/commander-shim.d.ts.map +1 -0
- package/dist/cli/commander-shim.js +233 -0
- package/dist/cli/commander-shim.js.map +1 -0
- package/dist/cli/commands/add.d.ts +12 -0
- package/dist/cli/commands/add.d.ts.map +1 -0
- package/dist/cli/commands/add.js +98 -0
- package/dist/cli/commands/add.js.map +1 -0
- package/dist/cli/commands/admin.d.ts +12 -0
- package/dist/cli/commands/admin.d.ts.map +1 -0
- package/dist/cli/commands/admin.js +59 -0
- package/dist/cli/commands/admin.js.map +1 -0
- package/dist/cli/commands/adr.d.ts +27 -0
- package/dist/cli/commands/adr.d.ts.map +1 -0
- package/dist/cli/commands/adr.js +79 -0
- package/dist/cli/commands/adr.js.map +1 -0
- package/dist/cli/commands/agent-profile-status.d.ts +98 -0
- package/dist/cli/commands/agent-profile-status.d.ts.map +1 -0
- package/dist/cli/commands/agent-profile-status.js +71 -0
- package/dist/cli/commands/agent-profile-status.js.map +1 -0
- package/dist/cli/commands/agent.d.ts +38 -0
- package/dist/cli/commands/agent.d.ts.map +1 -0
- package/dist/cli/commands/agent.js +1125 -0
- package/dist/cli/commands/agent.js.map +1 -0
- package/dist/cli/commands/agents.d.ts +17 -0
- package/dist/cli/commands/agents.d.ts.map +1 -0
- package/dist/cli/commands/agents.js +20 -0
- package/dist/cli/commands/agents.js.map +1 -0
- package/dist/cli/commands/analyze.d.ts +12 -0
- package/dist/cli/commands/analyze.d.ts.map +1 -0
- package/dist/cli/commands/analyze.js +20 -0
- package/dist/cli/commands/analyze.js.map +1 -0
- package/dist/cli/commands/archive-stats.d.ts +18 -0
- package/dist/cli/commands/archive-stats.d.ts.map +1 -0
- package/dist/cli/commands/archive-stats.js +49 -0
- package/dist/cli/commands/archive-stats.js.map +1 -0
- package/dist/cli/commands/archive.d.ts +12 -0
- package/dist/cli/commands/archive.d.ts.map +1 -0
- package/dist/cli/commands/archive.js +32 -0
- package/dist/cli/commands/archive.js.map +1 -0
- package/dist/cli/commands/backfill.d.ts +38 -0
- package/dist/cli/commands/backfill.d.ts.map +1 -0
- package/dist/cli/commands/backfill.js +147 -0
- package/dist/cli/commands/backfill.js.map +1 -0
- package/dist/cli/commands/backup.d.ts +8 -0
- package/dist/cli/commands/backup.d.ts.map +1 -0
- package/dist/cli/commands/backup.js +35 -0
- package/dist/cli/commands/backup.js.map +1 -0
- package/dist/cli/commands/blockers.d.ts +7 -0
- package/dist/cli/commands/blockers.d.ts.map +1 -0
- package/dist/cli/commands/blockers.js +16 -0
- package/dist/cli/commands/blockers.js.map +1 -0
- package/dist/cli/commands/brain.d.ts +29 -0
- package/dist/cli/commands/brain.d.ts.map +1 -0
- package/dist/cli/commands/brain.js +107 -0
- package/dist/cli/commands/brain.js.map +1 -0
- package/dist/cli/commands/briefing.d.ts +22 -0
- package/dist/cli/commands/briefing.d.ts.map +1 -0
- package/dist/cli/commands/briefing.js +45 -0
- package/dist/cli/commands/briefing.js.map +1 -0
- package/dist/cli/commands/bug.d.ts +12 -0
- package/dist/cli/commands/bug.d.ts.map +1 -0
- package/dist/cli/commands/bug.js +81 -0
- package/dist/cli/commands/bug.js.map +1 -0
- package/dist/cli/commands/cant.d.ts +32 -0
- package/dist/cli/commands/cant.d.ts.map +1 -0
- package/dist/cli/commands/cant.js +281 -0
- package/dist/cli/commands/cant.js.map +1 -0
- package/dist/cli/commands/check.d.ts +22 -0
- package/dist/cli/commands/check.d.ts.map +1 -0
- package/dist/cli/commands/check.js +164 -0
- package/dist/cli/commands/check.js.map +1 -0
- package/dist/cli/commands/checkpoint.d.ts +15 -0
- package/dist/cli/commands/checkpoint.d.ts.map +1 -0
- package/dist/cli/commands/checkpoint.js +91 -0
- package/dist/cli/commands/checkpoint.js.map +1 -0
- package/dist/cli/commands/code.d.ts +11 -0
- package/dist/cli/commands/code.d.ts.map +1 -0
- package/dist/cli/commands/code.js +114 -0
- package/dist/cli/commands/code.js.map +1 -0
- package/dist/cli/commands/commands.d.ts +13 -0
- package/dist/cli/commands/commands.d.ts.map +1 -0
- package/dist/cli/commands/commands.js +29 -0
- package/dist/cli/commands/commands.js.map +1 -0
- package/dist/cli/commands/complete.d.ts +12 -0
- package/dist/cli/commands/complete.d.ts.map +1 -0
- package/dist/cli/commands/complete.js +43 -0
- package/dist/cli/commands/complete.js.map +1 -0
- package/dist/cli/commands/compliance.d.ts +8 -0
- package/dist/cli/commands/compliance.d.ts.map +1 -0
- package/dist/cli/commands/compliance.js +85 -0
- package/dist/cli/commands/compliance.js.map +1 -0
- package/dist/cli/commands/config.d.ts +10 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +69 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/consensus.d.ts +13 -0
- package/dist/cli/commands/consensus.d.ts.map +1 -0
- package/dist/cli/commands/consensus.js +45 -0
- package/dist/cli/commands/consensus.js.map +1 -0
- package/dist/cli/commands/context.d.ts +8 -0
- package/dist/cli/commands/context.d.ts.map +1 -0
- package/dist/cli/commands/context.js +40 -0
- package/dist/cli/commands/context.js.map +1 -0
- package/dist/cli/commands/contribution.d.ts +13 -0
- package/dist/cli/commands/contribution.d.ts.map +1 -0
- package/dist/cli/commands/contribution.js +41 -0
- package/dist/cli/commands/contribution.js.map +1 -0
- package/dist/cli/commands/current.d.ts +13 -0
- package/dist/cli/commands/current.d.ts.map +1 -0
- package/dist/cli/commands/current.js +20 -0
- package/dist/cli/commands/current.js.map +1 -0
- package/dist/cli/commands/dash.d.ts +12 -0
- package/dist/cli/commands/dash.d.ts.map +1 -0
- package/dist/cli/commands/dash.js +24 -0
- package/dist/cli/commands/dash.js.map +1 -0
- package/dist/cli/commands/decomposition.d.ts +13 -0
- package/dist/cli/commands/decomposition.d.ts.map +1 -0
- package/dist/cli/commands/decomposition.js +45 -0
- package/dist/cli/commands/decomposition.js.map +1 -0
- package/dist/cli/commands/delete.d.ts +12 -0
- package/dist/cli/commands/delete.d.ts.map +1 -0
- package/dist/cli/commands/delete.js +37 -0
- package/dist/cli/commands/delete.js.map +1 -0
- package/dist/cli/commands/deps.d.ts +24 -0
- package/dist/cli/commands/deps.d.ts.map +1 -0
- package/dist/cli/commands/deps.js +98 -0
- package/dist/cli/commands/deps.js.map +1 -0
- package/dist/cli/commands/detect-drift.d.ts +15 -0
- package/dist/cli/commands/detect-drift.d.ts.map +1 -0
- package/dist/cli/commands/detect-drift.js +424 -0
- package/dist/cli/commands/detect-drift.js.map +1 -0
- package/dist/cli/commands/detect.d.ts +10 -0
- package/dist/cli/commands/detect.d.ts.map +1 -0
- package/dist/cli/commands/detect.js +24 -0
- package/dist/cli/commands/detect.js.map +1 -0
- package/dist/cli/commands/docs.d.ts +13 -0
- package/dist/cli/commands/docs.d.ts.map +1 -0
- package/dist/cli/commands/docs.js +169 -0
- package/dist/cli/commands/docs.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +15 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +133 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/dynamic.d.ts +24 -0
- package/dist/cli/commands/dynamic.d.ts.map +1 -0
- package/dist/cli/commands/dynamic.js +27 -0
- package/dist/cli/commands/dynamic.js.map +1 -0
- package/dist/cli/commands/env.d.ts +12 -0
- package/dist/cli/commands/env.d.ts.map +1 -0
- package/dist/cli/commands/env.js +44 -0
- package/dist/cli/commands/env.js.map +1 -0
- package/dist/cli/commands/exists.d.ts +22 -0
- package/dist/cli/commands/exists.d.ts.map +1 -0
- package/dist/cli/commands/exists.js +51 -0
- package/dist/cli/commands/exists.js.map +1 -0
- package/dist/cli/commands/export-tasks.d.ts +10 -0
- package/dist/cli/commands/export-tasks.d.ts.map +1 -0
- package/dist/cli/commands/export-tasks.js +47 -0
- package/dist/cli/commands/export-tasks.js.map +1 -0
- package/dist/cli/commands/export.d.ts +9 -0
- package/dist/cli/commands/export.d.ts.map +1 -0
- package/dist/cli/commands/export.js +46 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/find.d.ts +14 -0
- package/dist/cli/commands/find.d.ts.map +1 -0
- package/dist/cli/commands/find.js +70 -0
- package/dist/cli/commands/find.js.map +1 -0
- package/dist/cli/commands/generate-changelog.d.ts +14 -0
- package/dist/cli/commands/generate-changelog.d.ts.map +1 -0
- package/dist/cli/commands/generate-changelog.js +252 -0
- package/dist/cli/commands/generate-changelog.js.map +1 -0
- package/dist/cli/commands/grade.d.ts +13 -0
- package/dist/cli/commands/grade.d.ts.map +1 -0
- package/dist/cli/commands/grade.js +26 -0
- package/dist/cli/commands/grade.js.map +1 -0
- package/dist/cli/commands/history.d.ts +9 -0
- package/dist/cli/commands/history.d.ts.map +1 -0
- package/dist/cli/commands/history.js +30 -0
- package/dist/cli/commands/history.js.map +1 -0
- package/dist/cli/commands/implementation.d.ts +13 -0
- package/dist/cli/commands/implementation.d.ts.map +1 -0
- package/dist/cli/commands/implementation.js +41 -0
- package/dist/cli/commands/implementation.js.map +1 -0
- package/dist/cli/commands/import-tasks.d.ts +10 -0
- package/dist/cli/commands/import-tasks.d.ts.map +1 -0
- package/dist/cli/commands/import-tasks.js +38 -0
- package/dist/cli/commands/import-tasks.js.map +1 -0
- package/dist/cli/commands/import.d.ts +9 -0
- package/dist/cli/commands/import.d.ts.map +1 -0
- package/dist/cli/commands/import.js +28 -0
- package/dist/cli/commands/import.js.map +1 -0
- package/dist/cli/commands/init.d.ts +34 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +96 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/inject.d.ts +8 -0
- package/dist/cli/commands/inject.d.ts.map +1 -0
- package/dist/cli/commands/inject.js +28 -0
- package/dist/cli/commands/inject.js.map +1 -0
- package/dist/cli/commands/issue.d.ts +17 -0
- package/dist/cli/commands/issue.d.ts.map +1 -0
- package/dist/cli/commands/issue.js +107 -0
- package/dist/cli/commands/issue.js.map +1 -0
- package/dist/cli/commands/labels.d.ts +13 -0
- package/dist/cli/commands/labels.d.ts.map +1 -0
- package/dist/cli/commands/labels.js +44 -0
- package/dist/cli/commands/labels.js.map +1 -0
- package/dist/cli/commands/lifecycle.d.ts +8 -0
- package/dist/cli/commands/lifecycle.d.ts.map +1 -0
- package/dist/cli/commands/lifecycle.js +84 -0
- package/dist/cli/commands/lifecycle.js.map +1 -0
- package/dist/cli/commands/list.d.ts +14 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +71 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/log.d.ts +12 -0
- package/dist/cli/commands/log.d.ts.map +1 -0
- package/dist/cli/commands/log.js +30 -0
- package/dist/cli/commands/log.js.map +1 -0
- package/dist/cli/commands/map.d.ts +10 -0
- package/dist/cli/commands/map.d.ts.map +1 -0
- package/dist/cli/commands/map.js +23 -0
- package/dist/cli/commands/map.js.map +1 -0
- package/dist/cli/commands/memory-brain.d.ts +14 -0
- package/dist/cli/commands/memory-brain.d.ts.map +1 -0
- package/dist/cli/commands/memory-brain.js +157 -0
- package/dist/cli/commands/memory-brain.js.map +1 -0
- package/dist/cli/commands/migrate-claude-mem.d.ts +18 -0
- package/dist/cli/commands/migrate-claude-mem.d.ts.map +1 -0
- package/dist/cli/commands/migrate-claude-mem.js +60 -0
- package/dist/cli/commands/migrate-claude-mem.js.map +1 -0
- package/dist/cli/commands/next.d.ts +9 -0
- package/dist/cli/commands/next.d.ts.map +1 -0
- package/dist/cli/commands/next.js +20 -0
- package/dist/cli/commands/next.js.map +1 -0
- package/dist/cli/commands/nexus.d.ts +16 -0
- package/dist/cli/commands/nexus.d.ts.map +1 -0
- package/dist/cli/commands/nexus.js +155 -0
- package/dist/cli/commands/nexus.js.map +1 -0
- package/dist/cli/commands/observe.d.ts +9 -0
- package/dist/cli/commands/observe.d.ts.map +1 -0
- package/dist/cli/commands/observe.js +39 -0
- package/dist/cli/commands/observe.js.map +1 -0
- package/dist/cli/commands/ops.d.ts +10 -0
- package/dist/cli/commands/ops.d.ts.map +1 -0
- package/dist/cli/commands/ops.js +19 -0
- package/dist/cli/commands/ops.js.map +1 -0
- package/dist/cli/commands/orchestrate.d.ts +8 -0
- package/dist/cli/commands/orchestrate.d.ts.map +1 -0
- package/dist/cli/commands/orchestrate.js +58 -0
- package/dist/cli/commands/orchestrate.js.map +1 -0
- package/dist/cli/commands/otel.d.ts +12 -0
- package/dist/cli/commands/otel.d.ts.map +1 -0
- package/dist/cli/commands/otel.js +128 -0
- package/dist/cli/commands/otel.js.map +1 -0
- package/dist/cli/commands/phase.d.ts +12 -0
- package/dist/cli/commands/phase.d.ts.map +1 -0
- package/dist/cli/commands/phase.js +91 -0
- package/dist/cli/commands/phase.js.map +1 -0
- package/dist/cli/commands/phases.d.ts +12 -0
- package/dist/cli/commands/phases.d.ts.map +1 -0
- package/dist/cli/commands/phases.js +37 -0
- package/dist/cli/commands/phases.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +8 -0
- package/dist/cli/commands/plan.d.ts.map +1 -0
- package/dist/cli/commands/plan.js +15 -0
- package/dist/cli/commands/plan.js.map +1 -0
- package/dist/cli/commands/promote.d.ts +7 -0
- package/dist/cli/commands/promote.d.ts.map +1 -0
- package/dist/cli/commands/promote.js +15 -0
- package/dist/cli/commands/promote.js.map +1 -0
- package/dist/cli/commands/reason.d.ts +35 -0
- package/dist/cli/commands/reason.d.ts.map +1 -0
- package/dist/cli/commands/reason.js +104 -0
- package/dist/cli/commands/reason.js.map +1 -0
- package/dist/cli/commands/refresh-memory.d.ts +9 -0
- package/dist/cli/commands/refresh-memory.d.ts.map +1 -0
- package/dist/cli/commands/refresh-memory.js +24 -0
- package/dist/cli/commands/refresh-memory.js.map +1 -0
- package/dist/cli/commands/relates.d.ts +12 -0
- package/dist/cli/commands/relates.d.ts.map +1 -0
- package/dist/cli/commands/relates.js +53 -0
- package/dist/cli/commands/relates.js.map +1 -0
- package/dist/cli/commands/release.d.ts +8 -0
- package/dist/cli/commands/release.d.ts.map +1 -0
- package/dist/cli/commands/release.js +72 -0
- package/dist/cli/commands/release.js.map +1 -0
- package/dist/cli/commands/remote.d.ts +12 -0
- package/dist/cli/commands/remote.d.ts.map +1 -0
- package/dist/cli/commands/remote.js +207 -0
- package/dist/cli/commands/remote.js.map +1 -0
- package/dist/cli/commands/reorder.d.ts +7 -0
- package/dist/cli/commands/reorder.d.ts.map +1 -0
- package/dist/cli/commands/reorder.js +20 -0
- package/dist/cli/commands/reorder.js.map +1 -0
- package/dist/cli/commands/reparent.d.ts +10 -0
- package/dist/cli/commands/reparent.d.ts.map +1 -0
- package/dist/cli/commands/reparent.js +19 -0
- package/dist/cli/commands/reparent.js.map +1 -0
- package/dist/cli/commands/research.d.ts +8 -0
- package/dist/cli/commands/research.d.ts.map +1 -0
- package/dist/cli/commands/research.js +129 -0
- package/dist/cli/commands/research.js.map +1 -0
- package/dist/cli/commands/restore.d.ts +11 -0
- package/dist/cli/commands/restore.d.ts.map +1 -0
- package/dist/cli/commands/restore.js +224 -0
- package/dist/cli/commands/restore.js.map +1 -0
- package/dist/cli/commands/roadmap.d.ts +8 -0
- package/dist/cli/commands/roadmap.d.ts.map +1 -0
- package/dist/cli/commands/roadmap.js +21 -0
- package/dist/cli/commands/roadmap.js.map +1 -0
- package/dist/cli/commands/safestop.d.ts +14 -0
- package/dist/cli/commands/safestop.d.ts.map +1 -0
- package/dist/cli/commands/safestop.js +32 -0
- package/dist/cli/commands/safestop.js.map +1 -0
- package/dist/cli/commands/self-update.d.ts +15 -0
- package/dist/cli/commands/self-update.d.ts.map +1 -0
- package/dist/cli/commands/self-update.js +329 -0
- package/dist/cli/commands/self-update.js.map +1 -0
- package/dist/cli/commands/sequence.d.ts +8 -0
- package/dist/cli/commands/sequence.d.ts.map +1 -0
- package/dist/cli/commands/sequence.js +30 -0
- package/dist/cli/commands/sequence.js.map +1 -0
- package/dist/cli/commands/session.d.ts +12 -0
- package/dist/cli/commands/session.d.ts.map +1 -0
- package/dist/cli/commands/session.js +175 -0
- package/dist/cli/commands/session.js.map +1 -0
- package/dist/cli/commands/show.d.ts +13 -0
- package/dist/cli/commands/show.d.ts.map +1 -0
- package/dist/cli/commands/show.js +20 -0
- package/dist/cli/commands/show.js.map +1 -0
- package/dist/cli/commands/skills.d.ts +13 -0
- package/dist/cli/commands/skills.d.ts.map +1 -0
- package/dist/cli/commands/skills.js +131 -0
- package/dist/cli/commands/skills.js.map +1 -0
- package/dist/cli/commands/snapshot.d.ts +9 -0
- package/dist/cli/commands/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/snapshot.js +50 -0
- package/dist/cli/commands/snapshot.js.map +1 -0
- package/dist/cli/commands/specification.d.ts +13 -0
- package/dist/cli/commands/specification.d.ts.map +1 -0
- package/dist/cli/commands/specification.js +45 -0
- package/dist/cli/commands/specification.js.map +1 -0
- package/dist/cli/commands/start.d.ts +13 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +20 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/stats.d.ts +12 -0
- package/dist/cli/commands/stats.d.ts.map +1 -0
- package/dist/cli/commands/stats.js +35 -0
- package/dist/cli/commands/stats.js.map +1 -0
- package/dist/cli/commands/sticky.d.ts +16 -0
- package/dist/cli/commands/sticky.d.ts.map +1 -0
- package/dist/cli/commands/sticky.js +211 -0
- package/dist/cli/commands/sticky.js.map +1 -0
- package/dist/cli/commands/stop.d.ts +13 -0
- package/dist/cli/commands/stop.d.ts.map +1 -0
- package/dist/cli/commands/stop.js +20 -0
- package/dist/cli/commands/stop.js.map +1 -0
- package/dist/cli/commands/testing.d.ts +13 -0
- package/dist/cli/commands/testing.d.ts.map +1 -0
- package/dist/cli/commands/testing.js +64 -0
- package/dist/cli/commands/testing.js.map +1 -0
- package/dist/cli/commands/token.d.ts +10 -0
- package/dist/cli/commands/token.d.ts.map +1 -0
- package/dist/cli/commands/token.js +135 -0
- package/dist/cli/commands/token.js.map +1 -0
- package/dist/cli/commands/update.d.ts +12 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +83 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/commands/upgrade.d.ts +18 -0
- package/dist/cli/commands/upgrade.d.ts.map +1 -0
- package/dist/cli/commands/upgrade.js +103 -0
- package/dist/cli/commands/upgrade.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +12 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +23 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/commands/verify.d.ts +8 -0
- package/dist/cli/commands/verify.d.ts.map +1 -0
- package/dist/cli/commands/verify.js +28 -0
- package/dist/cli/commands/verify.js.map +1 -0
- package/dist/cli/commands/web.d.ts +13 -0
- package/dist/cli/commands/web.d.ts.map +1 -0
- package/dist/cli/commands/web.js +277 -0
- package/dist/cli/commands/web.js.map +1 -0
- package/dist/cli/field-context.d.ts +32 -0
- package/dist/cli/field-context.d.ts.map +1 -0
- package/dist/cli/field-context.js +47 -0
- package/dist/cli/field-context.js.map +1 -0
- package/dist/cli/format-context.d.ts +32 -0
- package/dist/cli/format-context.d.ts.map +1 -0
- package/dist/cli/format-context.js +50 -0
- package/dist/cli/format-context.js.map +1 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +3767 -3387
- package/dist/cli/index.js.map +4 -4
- package/dist/cli/logger-bootstrap.d.ts +6 -0
- package/dist/cli/logger-bootstrap.d.ts.map +1 -0
- package/dist/cli/logger-bootstrap.js +10 -0
- package/dist/cli/logger-bootstrap.js.map +1 -0
- package/dist/cli/middleware/output-format.d.ts +30 -0
- package/dist/cli/middleware/output-format.d.ts.map +1 -0
- package/dist/cli/middleware/output-format.js +35 -0
- package/dist/cli/middleware/output-format.js.map +1 -0
- package/dist/cli/progress.d.ts +84 -0
- package/dist/cli/progress.d.ts.map +1 -0
- package/dist/cli/progress.js +169 -0
- package/dist/cli/progress.js.map +1 -0
- package/dist/cli/renderers/colors.d.ts +32 -0
- package/dist/cli/renderers/colors.d.ts.map +1 -0
- package/dist/cli/renderers/colors.js +141 -0
- package/dist/cli/renderers/colors.js.map +1 -0
- package/dist/cli/renderers/error.d.ts +13 -0
- package/dist/cli/renderers/error.d.ts.map +1 -0
- package/dist/cli/renderers/error.js +42 -0
- package/dist/cli/renderers/error.js.map +1 -0
- package/dist/cli/renderers/index.d.ts +59 -0
- package/dist/cli/renderers/index.d.ts.map +1 -0
- package/dist/cli/renderers/index.js +208 -0
- package/dist/cli/renderers/index.js.map +1 -0
- package/dist/cli/renderers/lafs-validator.d.ts +97 -0
- package/dist/cli/renderers/lafs-validator.d.ts.map +1 -0
- package/dist/cli/renderers/lafs-validator.js +229 -0
- package/dist/cli/renderers/lafs-validator.js.map +1 -0
- package/dist/cli/renderers/normalizer.d.ts +21 -0
- package/dist/cli/renderers/normalizer.d.ts.map +1 -0
- package/dist/cli/renderers/normalizer.js +106 -0
- package/dist/cli/renderers/normalizer.js.map +1 -0
- package/dist/cli/renderers/system.d.ts +25 -0
- package/dist/cli/renderers/system.d.ts.map +1 -0
- package/dist/cli/renderers/system.js +416 -0
- package/dist/cli/renderers/system.js.map +1 -0
- package/dist/cli/renderers/tasks.d.ts +28 -0
- package/dist/cli/renderers/tasks.d.ts.map +1 -0
- package/dist/cli/renderers/tasks.js +306 -0
- package/dist/cli/renderers/tasks.js.map +1 -0
- package/dist/dispatch/adapters/cli.d.ts +67 -0
- package/dist/dispatch/adapters/cli.d.ts.map +1 -0
- package/dist/dispatch/adapters/cli.js +262 -0
- package/dist/dispatch/adapters/cli.js.map +1 -0
- package/dist/dispatch/context/session-context.d.ts +54 -0
- package/dist/dispatch/context/session-context.d.ts.map +1 -0
- package/dist/dispatch/context/session-context.js +61 -0
- package/dist/dispatch/context/session-context.js.map +1 -0
- package/dist/dispatch/dispatcher.d.ts +23 -0
- package/dist/dispatch/dispatcher.d.ts.map +1 -0
- package/dist/dispatch/dispatcher.js +84 -0
- package/dist/dispatch/dispatcher.js.map +1 -0
- package/dist/dispatch/domains/_base.d.ts +59 -0
- package/dist/dispatch/domains/_base.d.ts.map +1 -0
- package/dist/dispatch/domains/_base.js +77 -0
- package/dist/dispatch/domains/_base.js.map +1 -0
- package/dist/dispatch/domains/_meta.d.ts +23 -0
- package/dist/dispatch/domains/_meta.d.ts.map +1 -0
- package/dist/dispatch/domains/_meta.js +25 -0
- package/dist/dispatch/domains/_meta.js.map +1 -0
- package/dist/dispatch/domains/_routing.d.ts +8 -0
- package/dist/dispatch/domains/_routing.d.ts.map +1 -0
- package/dist/dispatch/domains/_routing.js +20 -0
- package/dist/dispatch/domains/_routing.js.map +1 -0
- package/dist/dispatch/domains/admin.d.ts +25 -0
- package/dist/dispatch/domains/admin.d.ts.map +1 -0
- package/dist/dispatch/domains/admin.js +719 -0
- package/dist/dispatch/domains/admin.js.map +1 -0
- package/dist/dispatch/domains/check.d.ts +22 -0
- package/dist/dispatch/domains/check.d.ts.map +1 -0
- package/dist/dispatch/domains/check.js +360 -0
- package/dist/dispatch/domains/check.js.map +1 -0
- package/dist/dispatch/domains/conduit.d.ts +38 -0
- package/dist/dispatch/domains/conduit.d.ts.map +1 -0
- package/dist/dispatch/domains/conduit.js +247 -0
- package/dist/dispatch/domains/conduit.js.map +1 -0
- package/dist/dispatch/domains/index.d.ts +27 -0
- package/dist/dispatch/domains/index.d.ts.map +1 -0
- package/dist/dispatch/domains/index.js +40 -0
- package/dist/dispatch/domains/index.js.map +1 -0
- package/dist/dispatch/domains/memory.d.ts +22 -0
- package/dist/dispatch/domains/memory.d.ts.map +1 -0
- package/dist/dispatch/domains/memory.js +303 -0
- package/dist/dispatch/domains/memory.js.map +1 -0
- package/dist/dispatch/domains/nexus.d.ts +22 -0
- package/dist/dispatch/domains/nexus.d.ts.map +1 -0
- package/dist/dispatch/domains/nexus.js +286 -0
- package/dist/dispatch/domains/nexus.js.map +1 -0
- package/dist/dispatch/domains/orchestrate.d.ts +19 -0
- package/dist/dispatch/domains/orchestrate.d.ts.map +1 -0
- package/dist/dispatch/domains/orchestrate.js +259 -0
- package/dist/dispatch/domains/orchestrate.js.map +1 -0
- package/dist/dispatch/domains/pipeline.d.ts +35 -0
- package/dist/dispatch/domains/pipeline.d.ts.map +1 -0
- package/dist/dispatch/domains/pipeline.js +593 -0
- package/dist/dispatch/domains/pipeline.js.map +1 -0
- package/dist/dispatch/domains/session.d.ts +22 -0
- package/dist/dispatch/domains/session.d.ts.map +1 -0
- package/dist/dispatch/domains/session.js +257 -0
- package/dist/dispatch/domains/session.js.map +1 -0
- package/dist/dispatch/domains/sticky.d.ts +20 -0
- package/dist/dispatch/domains/sticky.d.ts.map +1 -0
- package/dist/dispatch/domains/sticky.js +164 -0
- package/dist/dispatch/domains/sticky.js.map +1 -0
- package/dist/dispatch/domains/tasks.d.ts +25 -0
- package/dist/dispatch/domains/tasks.d.ts.map +1 -0
- package/dist/dispatch/domains/tasks.js +361 -0
- package/dist/dispatch/domains/tasks.js.map +1 -0
- package/dist/dispatch/domains/tools.d.ts +37 -0
- package/dist/dispatch/domains/tools.d.ts.map +1 -0
- package/dist/dispatch/domains/tools.js +481 -0
- package/dist/dispatch/domains/tools.js.map +1 -0
- package/dist/dispatch/engines/_error.d.ts +85 -0
- package/dist/dispatch/engines/_error.d.ts.map +1 -0
- package/dist/dispatch/engines/_error.js +244 -0
- package/dist/dispatch/engines/_error.js.map +1 -0
- package/dist/dispatch/engines/code-engine.d.ts +18 -0
- package/dist/dispatch/engines/code-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/code-engine.js +71 -0
- package/dist/dispatch/engines/code-engine.js.map +1 -0
- package/dist/dispatch/engines/codebase-map-engine.d.ts +31 -0
- package/dist/dispatch/engines/codebase-map-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/codebase-map-engine.js +43 -0
- package/dist/dispatch/engines/codebase-map-engine.js.map +1 -0
- package/dist/dispatch/engines/config-engine.d.ts +32 -0
- package/dist/dispatch/engines/config-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/config-engine.js +70 -0
- package/dist/dispatch/engines/config-engine.js.map +1 -0
- package/dist/dispatch/engines/hooks-engine.d.ts +96 -0
- package/dist/dispatch/engines/hooks-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/hooks-engine.js +144 -0
- package/dist/dispatch/engines/hooks-engine.js.map +1 -0
- package/dist/dispatch/engines/init-engine.d.ts +56 -0
- package/dist/dispatch/engines/init-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/init-engine.js +78 -0
- package/dist/dispatch/engines/init-engine.js.map +1 -0
- package/dist/dispatch/engines/lifecycle-engine.d.ts +66 -0
- package/dist/dispatch/engines/lifecycle-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/lifecycle-engine.js +224 -0
- package/dist/dispatch/engines/lifecycle-engine.js.map +1 -0
- package/dist/dispatch/engines/memory-engine.d.ts +10 -0
- package/dist/dispatch/engines/memory-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/memory-engine.js +10 -0
- package/dist/dispatch/engines/memory-engine.js.map +1 -0
- package/dist/dispatch/engines/nexus-engine.d.ts +167 -0
- package/dist/dispatch/engines/nexus-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/nexus-engine.js +356 -0
- package/dist/dispatch/engines/nexus-engine.js.map +1 -0
- package/dist/dispatch/engines/orchestrate-engine.d.ts +133 -0
- package/dist/dispatch/engines/orchestrate-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/orchestrate-engine.js +769 -0
- package/dist/dispatch/engines/orchestrate-engine.js.map +1 -0
- package/dist/dispatch/engines/pipeline-engine.d.ts +51 -0
- package/dist/dispatch/engines/pipeline-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/pipeline-engine.js +191 -0
- package/dist/dispatch/engines/pipeline-engine.js.map +1 -0
- package/dist/dispatch/engines/release-engine.d.ts +94 -0
- package/dist/dispatch/engines/release-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/release-engine.js +763 -0
- package/dist/dispatch/engines/release-engine.js.map +1 -0
- package/dist/dispatch/engines/session-engine.d.ts +383 -0
- package/dist/dispatch/engines/session-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/session-engine.js +960 -0
- package/dist/dispatch/engines/session-engine.js.map +1 -0
- package/dist/dispatch/engines/sticky-engine.d.ts +100 -0
- package/dist/dispatch/engines/sticky-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/sticky-engine.js +181 -0
- package/dist/dispatch/engines/sticky-engine.js.map +1 -0
- package/dist/dispatch/engines/system-engine.d.ts +539 -0
- package/dist/dispatch/engines/system-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/system-engine.js +1266 -0
- package/dist/dispatch/engines/system-engine.js.map +1 -0
- package/dist/dispatch/engines/task-engine.d.ts +1055 -0
- package/dist/dispatch/engines/task-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/task-engine.js +1387 -0
- package/dist/dispatch/engines/task-engine.js.map +1 -0
- package/dist/dispatch/engines/template-parser.d.ts +85 -0
- package/dist/dispatch/engines/template-parser.d.ts.map +1 -0
- package/dist/dispatch/engines/template-parser.js +108 -0
- package/dist/dispatch/engines/template-parser.js.map +1 -0
- package/dist/dispatch/engines/tools-engine.d.ts +270 -0
- package/dist/dispatch/engines/tools-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/tools-engine.js +636 -0
- package/dist/dispatch/engines/tools-engine.js.map +1 -0
- package/dist/dispatch/engines/validate-engine.d.ts +218 -0
- package/dist/dispatch/engines/validate-engine.d.ts.map +1 -0
- package/dist/dispatch/engines/validate-engine.js +737 -0
- package/dist/dispatch/engines/validate-engine.js.map +1 -0
- package/dist/dispatch/index.d.ts +20 -0
- package/dist/dispatch/index.d.ts.map +1 -0
- package/dist/dispatch/index.js +19 -0
- package/dist/dispatch/index.js.map +1 -0
- package/dist/dispatch/lib/background-jobs.d.ts +86 -0
- package/dist/dispatch/lib/background-jobs.d.ts.map +1 -0
- package/dist/dispatch/lib/background-jobs.js +183 -0
- package/dist/dispatch/lib/background-jobs.js.map +1 -0
- package/dist/dispatch/lib/budget.d.ts +35 -0
- package/dist/dispatch/lib/budget.d.ts.map +1 -0
- package/dist/dispatch/lib/budget.js +102 -0
- package/dist/dispatch/lib/budget.js.map +1 -0
- package/dist/dispatch/lib/capability-matrix.d.ts +11 -0
- package/dist/dispatch/lib/capability-matrix.d.ts.map +1 -0
- package/dist/dispatch/lib/capability-matrix.js +10 -0
- package/dist/dispatch/lib/capability-matrix.js.map +1 -0
- package/dist/dispatch/lib/config-loader.d.ts +42 -0
- package/dist/dispatch/lib/config-loader.d.ts.map +1 -0
- package/dist/dispatch/lib/config-loader.js +217 -0
- package/dist/dispatch/lib/config-loader.js.map +1 -0
- package/dist/dispatch/lib/config.d.ts +11 -0
- package/dist/dispatch/lib/config.d.ts.map +1 -0
- package/dist/dispatch/lib/config.js +10 -0
- package/dist/dispatch/lib/config.js.map +1 -0
- package/dist/dispatch/lib/defaults.d.ts +117 -0
- package/dist/dispatch/lib/defaults.d.ts.map +1 -0
- package/dist/dispatch/lib/defaults.js +58 -0
- package/dist/dispatch/lib/defaults.js.map +1 -0
- package/dist/dispatch/lib/engine.d.ts +26 -0
- package/dist/dispatch/lib/engine.d.ts.map +1 -0
- package/dist/dispatch/lib/engine.js +46 -0
- package/dist/dispatch/lib/engine.js.map +1 -0
- package/dist/dispatch/lib/gateway-meta.d.ts +37 -0
- package/dist/dispatch/lib/gateway-meta.d.ts.map +1 -0
- package/dist/dispatch/lib/gateway-meta.js +50 -0
- package/dist/dispatch/lib/gateway-meta.js.map +1 -0
- package/dist/dispatch/lib/job-manager-accessor.d.ts +9 -0
- package/dist/dispatch/lib/job-manager-accessor.d.ts.map +1 -0
- package/dist/dispatch/lib/job-manager-accessor.js +13 -0
- package/dist/dispatch/lib/job-manager-accessor.js.map +1 -0
- package/dist/dispatch/lib/meta.d.ts +26 -0
- package/dist/dispatch/lib/meta.d.ts.map +1 -0
- package/dist/dispatch/lib/meta.js +37 -0
- package/dist/dispatch/lib/meta.js.map +1 -0
- package/dist/dispatch/lib/param-utils.d.ts +11 -0
- package/dist/dispatch/lib/param-utils.d.ts.map +1 -0
- package/dist/dispatch/lib/param-utils.js +10 -0
- package/dist/dispatch/lib/param-utils.js.map +1 -0
- package/dist/dispatch/lib/projections.d.ts +56 -0
- package/dist/dispatch/lib/projections.d.ts.map +1 -0
- package/dist/dispatch/lib/projections.js +65 -0
- package/dist/dispatch/lib/projections.js.map +1 -0
- package/dist/dispatch/lib/schema-utils.d.ts +39 -0
- package/dist/dispatch/lib/schema-utils.d.ts.map +1 -0
- package/dist/dispatch/lib/schema-utils.js +88 -0
- package/dist/dispatch/lib/schema-utils.js.map +1 -0
- package/dist/dispatch/lib/security.d.ts +11 -0
- package/dist/dispatch/lib/security.d.ts.map +1 -0
- package/dist/dispatch/lib/security.js +10 -0
- package/dist/dispatch/lib/security.js.map +1 -0
- package/dist/dispatch/middleware/audit.d.ts +23 -0
- package/dist/dispatch/middleware/audit.d.ts.map +1 -0
- package/dist/dispatch/middleware/audit.js +169 -0
- package/dist/dispatch/middleware/audit.js.map +1 -0
- package/dist/dispatch/middleware/field-filter.d.ts +24 -0
- package/dist/dispatch/middleware/field-filter.d.ts.map +1 -0
- package/dist/dispatch/middleware/field-filter.js +65 -0
- package/dist/dispatch/middleware/field-filter.js.map +1 -0
- package/dist/dispatch/middleware/pipeline.d.ts +33 -0
- package/dist/dispatch/middleware/pipeline.d.ts.map +1 -0
- package/dist/dispatch/middleware/pipeline.js +60 -0
- package/dist/dispatch/middleware/pipeline.js.map +1 -0
- package/dist/dispatch/middleware/projection.d.ts +35 -0
- package/dist/dispatch/middleware/projection.d.ts.map +1 -0
- package/dist/dispatch/middleware/projection.js +146 -0
- package/dist/dispatch/middleware/projection.js.map +1 -0
- package/dist/dispatch/middleware/protocol-enforcement.d.ts +27 -0
- package/dist/dispatch/middleware/protocol-enforcement.d.ts.map +1 -0
- package/dist/dispatch/middleware/protocol-enforcement.js +45 -0
- package/dist/dispatch/middleware/protocol-enforcement.js.map +1 -0
- package/dist/dispatch/middleware/rate-limiter.d.ts +72 -0
- package/dist/dispatch/middleware/rate-limiter.d.ts.map +1 -0
- package/dist/dispatch/middleware/rate-limiter.js +127 -0
- package/dist/dispatch/middleware/rate-limiter.js.map +1 -0
- package/dist/dispatch/middleware/sanitizer.d.ts +24 -0
- package/dist/dispatch/middleware/sanitizer.d.ts.map +1 -0
- package/dist/dispatch/middleware/sanitizer.js +56 -0
- package/dist/dispatch/middleware/sanitizer.js.map +1 -0
- package/dist/dispatch/middleware/session-resolver.d.ts +26 -0
- package/dist/dispatch/middleware/session-resolver.d.ts.map +1 -0
- package/dist/dispatch/middleware/session-resolver.js +65 -0
- package/dist/dispatch/middleware/session-resolver.js.map +1 -0
- package/dist/dispatch/middleware/verification-gates.d.ts +22 -0
- package/dist/dispatch/middleware/verification-gates.d.ts.map +1 -0
- package/dist/dispatch/middleware/verification-gates.js +59 -0
- package/dist/dispatch/middleware/verification-gates.js.map +1 -0
- package/dist/dispatch/registry.d.ts +91 -0
- package/dist/dispatch/registry.d.ts.map +1 -0
- package/dist/dispatch/registry.js +3133 -0
- package/dist/dispatch/registry.js.map +1 -0
- package/dist/dispatch/types.d.ts +202 -0
- package/dist/dispatch/types.d.ts.map +1 -0
- package/dist/dispatch/types.js +26 -0
- package/dist/dispatch/types.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,960 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Engine — thin wrapper layer.
|
|
3
|
+
*
|
|
4
|
+
* Delegates all business logic to src/core/sessions/ and src/core/task-work/.
|
|
5
|
+
* Each function catches errors from core and wraps them into EngineResult.
|
|
6
|
+
*
|
|
7
|
+
* @task T4782
|
|
8
|
+
* @epic T4654
|
|
9
|
+
*/
|
|
10
|
+
import { getExitCodeName } from '@cleocode/contracts';
|
|
11
|
+
// ... existing imports ...
|
|
12
|
+
import { archiveSessions, CleoError, cleanupSessions, computeBriefing, computeDebrief, computeHandoff, currentTask, findSessions, generateSessionId, getAccessor, getContextDrift, getDecisionLog, getLastHandoff, getSessionHistory, getSessionStats, getTaskHistory, injectContext, paginate, parseScope, persistHandoff, recordAssumption, recordDecision, showSession, startTask, stopTask, suspendSession, switchSession, } from '@cleocode/core/internal';
|
|
13
|
+
import { engineError } from './_error.js';
|
|
14
|
+
/**
|
|
15
|
+
* Get current session status.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Returns whether there is an active session, along with the session record
|
|
19
|
+
* and current task work state if available.
|
|
20
|
+
*
|
|
21
|
+
* @param projectRoot - Absolute path to the project root
|
|
22
|
+
* @returns EngineResult with active session flag, session record, and task work state
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const result = await sessionStatus('/project');
|
|
27
|
+
* if (result.success && result.data.hasActiveSession) {
|
|
28
|
+
* console.log(result.data.session?.id);
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @task T4782
|
|
33
|
+
*/
|
|
34
|
+
export async function sessionStatus(projectRoot) {
|
|
35
|
+
try {
|
|
36
|
+
const accessor = await getAccessor(projectRoot);
|
|
37
|
+
const focusState = await accessor.getMetaValue('focus_state');
|
|
38
|
+
const sessions = await accessor.loadSessions();
|
|
39
|
+
const active = sessions.find((s) => s.status === 'active');
|
|
40
|
+
return {
|
|
41
|
+
success: true,
|
|
42
|
+
data: {
|
|
43
|
+
hasActiveSession: !!active,
|
|
44
|
+
session: active || null,
|
|
45
|
+
taskWork: focusState || null,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Default limit for sessionList when none is provided. @task T5121 */
|
|
54
|
+
const SESSION_LIST_DEFAULT_LIMIT = 10;
|
|
55
|
+
/**
|
|
56
|
+
* List sessions with budget enforcement.
|
|
57
|
+
*
|
|
58
|
+
* When a limit is applied (explicit or default), the response includes
|
|
59
|
+
* `_meta.truncated` and `_meta.total` so agents know the result set
|
|
60
|
+
* was capped.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* Defaults to 10 results when no explicit limit is provided to protect
|
|
64
|
+
* agent context budgets. Use offset for pagination.
|
|
65
|
+
*
|
|
66
|
+
* @param projectRoot - Absolute path to the project root
|
|
67
|
+
* @param params - Optional filter and pagination parameters
|
|
68
|
+
* @returns EngineResult with sessions array, total, filtered count, and truncation metadata
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const result = await sessionList('/project', { active: true, limit: 5 });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @task T4782
|
|
76
|
+
* @task T5120 - budget enforcement metadata
|
|
77
|
+
* @task T5121 - default limit=10
|
|
78
|
+
*/
|
|
79
|
+
export async function sessionList(projectRoot, params) {
|
|
80
|
+
try {
|
|
81
|
+
const accessor = await getAccessor(projectRoot);
|
|
82
|
+
const sessions = await accessor.loadSessions();
|
|
83
|
+
let result = sessions;
|
|
84
|
+
if (params?.status) {
|
|
85
|
+
result = result.filter((s) => s.status === params.status);
|
|
86
|
+
}
|
|
87
|
+
else if (params?.active === true) {
|
|
88
|
+
result = result.filter((s) => s.status === 'active');
|
|
89
|
+
}
|
|
90
|
+
else if (params?.active === false) {
|
|
91
|
+
result = result.filter((s) => s.status !== 'active');
|
|
92
|
+
}
|
|
93
|
+
const total = sessions.length;
|
|
94
|
+
const filtered = result.length;
|
|
95
|
+
const limit = params?.limit && params.limit > 0 ? params.limit : SESSION_LIST_DEFAULT_LIMIT;
|
|
96
|
+
const offset = typeof params?.offset === 'number' && params.offset > 0 ? params.offset : 0;
|
|
97
|
+
const pageResult = paginate(result, limit, offset);
|
|
98
|
+
const truncated = filtered !== pageResult.items.length || offset > 0;
|
|
99
|
+
return {
|
|
100
|
+
success: true,
|
|
101
|
+
data: {
|
|
102
|
+
sessions: pageResult.items,
|
|
103
|
+
total,
|
|
104
|
+
filtered,
|
|
105
|
+
_meta: { truncated, total: filtered },
|
|
106
|
+
},
|
|
107
|
+
page: pageResult.page,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Lightweight session discovery -- returns minimal session records.
|
|
116
|
+
*
|
|
117
|
+
* @remarks
|
|
118
|
+
* Optimized for low context cost. Returns only essential fields (ID, status,
|
|
119
|
+
* scope, timestamps) without full session details.
|
|
120
|
+
*
|
|
121
|
+
* @param projectRoot - Absolute path to the project root
|
|
122
|
+
* @param params - Optional search parameters
|
|
123
|
+
* @returns EngineResult with array of minimal session records
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const result = await sessionFind('/project', { status: 'active' });
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @task T5119
|
|
131
|
+
*/
|
|
132
|
+
export async function sessionFind(projectRoot, params) {
|
|
133
|
+
try {
|
|
134
|
+
const accessor = await getAccessor(projectRoot);
|
|
135
|
+
const result = await findSessions(accessor, params);
|
|
136
|
+
return { success: true, data: result };
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Show a specific session by ID.
|
|
144
|
+
*
|
|
145
|
+
* @remarks
|
|
146
|
+
* Returns the full session record including scope, status, timestamps,
|
|
147
|
+
* and associated task data.
|
|
148
|
+
*
|
|
149
|
+
* @param projectRoot - Absolute path to the project root
|
|
150
|
+
* @param sessionId - Session identifier to look up
|
|
151
|
+
* @returns EngineResult with the full Session record
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const result = await sessionShow('/project', 'ses_20260401_abc123');
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @task T4782
|
|
159
|
+
*/
|
|
160
|
+
export async function sessionShow(projectRoot, sessionId) {
|
|
161
|
+
try {
|
|
162
|
+
const result = await showSession(projectRoot, sessionId);
|
|
163
|
+
return { success: true, data: result };
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
const message = err.message;
|
|
167
|
+
const code = message.includes('not found') ? 'E_NOT_FOUND' : 'E_NOT_INITIALIZED';
|
|
168
|
+
return engineError(code, message);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get current task being worked on.
|
|
173
|
+
* Delegates to core/task-work/currentTask.
|
|
174
|
+
* @task T4782
|
|
175
|
+
*/
|
|
176
|
+
export async function taskCurrentGet(projectRoot) {
|
|
177
|
+
try {
|
|
178
|
+
const accessor = await getAccessor(projectRoot);
|
|
179
|
+
const result = await currentTask(undefined, accessor);
|
|
180
|
+
return {
|
|
181
|
+
success: true,
|
|
182
|
+
data: {
|
|
183
|
+
currentTask: result.currentTask,
|
|
184
|
+
currentPhase: result.currentPhase,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Start working on a specific task.
|
|
194
|
+
* Delegates to core/task-work/startTask.
|
|
195
|
+
* @task T4782
|
|
196
|
+
*/
|
|
197
|
+
export async function taskStart(projectRoot, taskId) {
|
|
198
|
+
try {
|
|
199
|
+
const accessor = await getAccessor(projectRoot);
|
|
200
|
+
const result = await startTask(taskId, undefined, accessor);
|
|
201
|
+
return {
|
|
202
|
+
success: true,
|
|
203
|
+
data: { taskId: result.taskId, previousTask: result.previousTask },
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
if (err instanceof CleoError) {
|
|
208
|
+
const stringCode = `E_${getExitCodeName(err.code)}`;
|
|
209
|
+
return engineError(stringCode, err.message, {
|
|
210
|
+
...(err.fix && { fix: err.fix }),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
const message = err.message;
|
|
214
|
+
const code = message.includes('not found') ? 'E_NOT_FOUND' : 'E_NOT_INITIALIZED';
|
|
215
|
+
return engineError(code, message);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Stop working on the current task.
|
|
220
|
+
* Delegates to core/task-work/stopTask.
|
|
221
|
+
* @task T4782
|
|
222
|
+
*/
|
|
223
|
+
export async function taskStop(projectRoot) {
|
|
224
|
+
try {
|
|
225
|
+
const accessor = await getAccessor(projectRoot);
|
|
226
|
+
const result = await stopTask(undefined, accessor);
|
|
227
|
+
return {
|
|
228
|
+
success: true,
|
|
229
|
+
data: { cleared: true, previousTask: result.previousTask },
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Get task work history from session notes.
|
|
238
|
+
* @task T5323
|
|
239
|
+
*/
|
|
240
|
+
export async function taskWorkHistory(projectRoot) {
|
|
241
|
+
try {
|
|
242
|
+
const accessor = await getAccessor(projectRoot);
|
|
243
|
+
const history = await getTaskHistory(undefined, accessor);
|
|
244
|
+
return {
|
|
245
|
+
success: true,
|
|
246
|
+
data: { history, count: history.length },
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Start a new session.
|
|
255
|
+
* Note: This function has engine-specific logic for task file focus management
|
|
256
|
+
* and session store updates, so it remains in the engine layer.
|
|
257
|
+
* @task T4782
|
|
258
|
+
*/
|
|
259
|
+
export async function sessionStart(projectRoot, params) {
|
|
260
|
+
try {
|
|
261
|
+
let accessor = await getAccessor(projectRoot);
|
|
262
|
+
// Validate scope BEFORE auto-ending active session (prevents data loss on invalid input)
|
|
263
|
+
let scope;
|
|
264
|
+
try {
|
|
265
|
+
scope = parseScope(params.scope);
|
|
266
|
+
}
|
|
267
|
+
catch (err) {
|
|
268
|
+
return engineError('E_INVALID_INPUT', err instanceof Error ? err.message : 'Invalid scope');
|
|
269
|
+
}
|
|
270
|
+
// For non-global scopes, verify root task exists before auto-ending
|
|
271
|
+
if (scope.type !== 'global') {
|
|
272
|
+
const rootTask = await accessor.loadSingleTask(scope.rootTaskId);
|
|
273
|
+
if (!rootTask) {
|
|
274
|
+
return engineError('E_NOT_FOUND', `Root task '${scope.rootTaskId}' not found`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// Auto-end any active session before starting a new one
|
|
278
|
+
const existingActive = await accessor.getActiveSession();
|
|
279
|
+
if (existingActive) {
|
|
280
|
+
await sessionEnd(projectRoot);
|
|
281
|
+
// Reload after auto-end
|
|
282
|
+
accessor = await getAccessor(projectRoot);
|
|
283
|
+
}
|
|
284
|
+
const now = new Date().toISOString();
|
|
285
|
+
const sessionId = generateSessionId();
|
|
286
|
+
// T4959: Chain linking — find most recent ended session for same scope
|
|
287
|
+
let previousSessionId = null;
|
|
288
|
+
{
|
|
289
|
+
const sessions = await accessor.loadSessions();
|
|
290
|
+
const sameScope = sessions
|
|
291
|
+
.filter((s) => s.status === 'ended' &&
|
|
292
|
+
s.endedAt &&
|
|
293
|
+
s.scope?.type === scope.type &&
|
|
294
|
+
(scope.type === 'global' || s.scope?.rootTaskId === scope.rootTaskId))
|
|
295
|
+
.sort((a, b) => new Date(b.endedAt).getTime() - new Date(a.endedAt).getTime());
|
|
296
|
+
if (sameScope.length > 0) {
|
|
297
|
+
previousSessionId = sameScope[0].id;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Resolve agent identifier from params or env
|
|
301
|
+
const agentIdentifier = params.agentIdentifier ??
|
|
302
|
+
process.env.CLEO_AGENT_ID ??
|
|
303
|
+
null;
|
|
304
|
+
const rootTaskId = scope.type !== 'global' ? scope.rootTaskId : undefined;
|
|
305
|
+
const startingTaskId = params.startTask || (params.autoStart && rootTaskId ? rootTaskId : null);
|
|
306
|
+
const newSession = {
|
|
307
|
+
id: sessionId,
|
|
308
|
+
status: 'active',
|
|
309
|
+
name: params.name || `session-${sessionId}`,
|
|
310
|
+
scope: scope.type === 'global'
|
|
311
|
+
? { type: 'global' }
|
|
312
|
+
: { type: scope.type, rootTaskId: scope.rootTaskId, includeDescendants: true },
|
|
313
|
+
taskWork: {
|
|
314
|
+
taskId: startingTaskId,
|
|
315
|
+
setAt: now,
|
|
316
|
+
},
|
|
317
|
+
startedAt: now,
|
|
318
|
+
resumeCount: 0,
|
|
319
|
+
...(params.grade ? { gradeMode: true } : {}),
|
|
320
|
+
stats: {
|
|
321
|
+
tasksCompleted: 0,
|
|
322
|
+
tasksCreated: 0,
|
|
323
|
+
tasksUpdated: 0,
|
|
324
|
+
focusChanges: 0,
|
|
325
|
+
totalActiveMinutes: 0,
|
|
326
|
+
suspendCount: 0,
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
// Update focus state via metadata
|
|
330
|
+
const existingFocus = (await accessor.getMetaValue('focus_state')) ?? {
|
|
331
|
+
currentTask: null,
|
|
332
|
+
currentPhase: null,
|
|
333
|
+
blockedUntil: null,
|
|
334
|
+
sessionNote: null,
|
|
335
|
+
sessionNotes: [],
|
|
336
|
+
nextAction: null,
|
|
337
|
+
primarySession: null,
|
|
338
|
+
};
|
|
339
|
+
const startingTask = params.startTask;
|
|
340
|
+
if (startingTask) {
|
|
341
|
+
existingFocus.currentTask = startingTask;
|
|
342
|
+
}
|
|
343
|
+
else if (params.autoStart && rootTaskId) {
|
|
344
|
+
existingFocus.currentTask = rootTaskId;
|
|
345
|
+
}
|
|
346
|
+
await accessor.setMetaValue('focus_state', existingFocus);
|
|
347
|
+
// Update file meta (activeSession no longer stored — session.status is source of truth)
|
|
348
|
+
const currentMeta = (await accessor.getMetaValue('file_meta')) ?? {};
|
|
349
|
+
currentMeta.lastSessionId = sessionId;
|
|
350
|
+
currentMeta.generation = (currentMeta.generation || 0) + 1;
|
|
351
|
+
await accessor.setMetaValue('file_meta', currentMeta);
|
|
352
|
+
// T4959: Set chain fields on new session
|
|
353
|
+
if (previousSessionId) {
|
|
354
|
+
newSession.previousSessionId = previousSessionId;
|
|
355
|
+
}
|
|
356
|
+
if (agentIdentifier) {
|
|
357
|
+
newSession.agentIdentifier = agentIdentifier;
|
|
358
|
+
}
|
|
359
|
+
// Insert new session FIRST — FK constraints require the target row to exist
|
|
360
|
+
// before predecessor.nextSessionId can reference it.
|
|
361
|
+
await accessor.upsertSingleSession(newSession);
|
|
362
|
+
// Now update predecessor's nextSessionId (new session row exists for FK)
|
|
363
|
+
if (previousSessionId) {
|
|
364
|
+
const sessions = await accessor.loadSessions();
|
|
365
|
+
const pred = sessions.find((s) => s.id === previousSessionId);
|
|
366
|
+
if (pred) {
|
|
367
|
+
pred.nextSessionId = sessionId;
|
|
368
|
+
await accessor.upsertSingleSession(pred);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// Enable grade mode: set env vars so audit middleware logs queries too
|
|
372
|
+
if (params.grade) {
|
|
373
|
+
process.env.CLEO_SESSION_GRADE = 'true';
|
|
374
|
+
process.env.CLEO_SESSION_ID = sessionId;
|
|
375
|
+
process.env.CLEO_SESSION_GRADE_ID = sessionId;
|
|
376
|
+
}
|
|
377
|
+
// T4959: Auto-briefing — enrich response with briefing + predecessor debrief
|
|
378
|
+
let briefing = null;
|
|
379
|
+
let previousDebrief = null;
|
|
380
|
+
try {
|
|
381
|
+
briefing = await computeBriefing(projectRoot, { scope: params.scope });
|
|
382
|
+
}
|
|
383
|
+
catch {
|
|
384
|
+
// Best-effort — briefing failure should not fail session start
|
|
385
|
+
}
|
|
386
|
+
// 5B: Load predecessor debrief/handoff and mark consumed
|
|
387
|
+
let previousHandoff = null;
|
|
388
|
+
if (previousSessionId) {
|
|
389
|
+
try {
|
|
390
|
+
const sessions2 = await accessor.loadSessions();
|
|
391
|
+
const pred = sessions2.find((s) => s.id === previousSessionId);
|
|
392
|
+
if (pred) {
|
|
393
|
+
// Try debriefJson first (rich data), then handoffJson (basic)
|
|
394
|
+
if (pred.debriefJson) {
|
|
395
|
+
previousDebrief = JSON.parse(pred.debriefJson);
|
|
396
|
+
}
|
|
397
|
+
else if (pred.handoffJson) {
|
|
398
|
+
previousHandoff = JSON.parse(pred.handoffJson);
|
|
399
|
+
}
|
|
400
|
+
// Always mark consumed regardless of debrief vs handoff
|
|
401
|
+
pred.handoffConsumedAt = new Date().toISOString();
|
|
402
|
+
pred.handoffConsumedBy = sessionId;
|
|
403
|
+
await accessor.upsertSingleSession(pred);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
// Best-effort
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const enrichedSession = {
|
|
411
|
+
...newSession,
|
|
412
|
+
...(briefing && { briefing }),
|
|
413
|
+
...(previousDebrief && { previousDebrief }),
|
|
414
|
+
...(previousHandoff && { previousHandoff }),
|
|
415
|
+
};
|
|
416
|
+
return { success: true, data: enrichedSession };
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* End the current session.
|
|
424
|
+
* Note: This function has engine-specific logic for task file focus management
|
|
425
|
+
* and session store management, so it remains in the engine layer.
|
|
426
|
+
* @task T4782
|
|
427
|
+
* @task T140 @epic T134 - Summarization wiring
|
|
428
|
+
*/
|
|
429
|
+
export async function sessionEnd(projectRoot, notes, params) {
|
|
430
|
+
try {
|
|
431
|
+
const accessor = await getAccessor(projectRoot);
|
|
432
|
+
const activeSession = await accessor.getActiveSession();
|
|
433
|
+
const sessionId = activeSession?.id;
|
|
434
|
+
if (!sessionId) {
|
|
435
|
+
return engineError('E_SESSION_NOT_FOUND', 'No active session to end', {
|
|
436
|
+
fix: 'Start a session first with: session start --scope <scope> --name <name>',
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
const now = new Date().toISOString();
|
|
440
|
+
// NOTE: Do NOT clear grade mode env vars here — gradeSession() needs them
|
|
441
|
+
// to query audit entries after the session ends. The caller (admin.grade handler)
|
|
442
|
+
// is responsible for cleanup after evaluation completes.
|
|
443
|
+
// Clear focus
|
|
444
|
+
const focusEnd = await accessor.getMetaValue('focus_state');
|
|
445
|
+
if (focusEnd) {
|
|
446
|
+
focusEnd.currentTask = null;
|
|
447
|
+
if (notes) {
|
|
448
|
+
if (!focusEnd.sessionNotes)
|
|
449
|
+
focusEnd.sessionNotes = [];
|
|
450
|
+
focusEnd.sessionNotes.push({ timestamp: now, note: notes });
|
|
451
|
+
}
|
|
452
|
+
await accessor.setMetaValue('focus_state', focusEnd);
|
|
453
|
+
}
|
|
454
|
+
// Bump file_meta generation (activeSession no longer stored here)
|
|
455
|
+
const fileMetaEnd = await accessor.getMetaValue('file_meta');
|
|
456
|
+
if (fileMetaEnd) {
|
|
457
|
+
fileMetaEnd.generation = (fileMetaEnd.generation || 0) + 1;
|
|
458
|
+
await accessor.setMetaValue('file_meta', fileMetaEnd);
|
|
459
|
+
}
|
|
460
|
+
// Update session record — status is the source of truth
|
|
461
|
+
if (sessionId !== 'default') {
|
|
462
|
+
activeSession.status = 'ended';
|
|
463
|
+
activeSession.endedAt = now;
|
|
464
|
+
await accessor.upsertSingleSession(activeSession);
|
|
465
|
+
}
|
|
466
|
+
// T140: Build summarization prompt and ingest structured summary if provided
|
|
467
|
+
let memoryPrompt;
|
|
468
|
+
try {
|
|
469
|
+
const { loadConfig } = await import('@cleocode/core/internal');
|
|
470
|
+
const config = await loadConfig(projectRoot);
|
|
471
|
+
if (config.brain?.summarization?.enabled) {
|
|
472
|
+
// Fetch the debrief if available to build a summarization prompt
|
|
473
|
+
const sessions = await accessor.loadSessions();
|
|
474
|
+
const endedSession = sessions.find((s) => s.id === sessionId);
|
|
475
|
+
if (endedSession?.debriefJson) {
|
|
476
|
+
try {
|
|
477
|
+
const debrief = JSON.parse(endedSession.debriefJson);
|
|
478
|
+
const { buildSummarizationPrompt } = await import('@cleocode/core/internal');
|
|
479
|
+
const prompt = buildSummarizationPrompt(sessionId, debrief);
|
|
480
|
+
if (prompt)
|
|
481
|
+
memoryPrompt = prompt;
|
|
482
|
+
}
|
|
483
|
+
catch {
|
|
484
|
+
// Best-effort
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
// Ingest structured summary if provided by caller (e.g. from CLI --summary flag)
|
|
489
|
+
if (params?.sessionSummary) {
|
|
490
|
+
const { ingestStructuredSummary } = await import('@cleocode/core/internal');
|
|
491
|
+
await ingestStructuredSummary(projectRoot, sessionId, params.sessionSummary);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
catch {
|
|
495
|
+
// Summarization must never block session end
|
|
496
|
+
}
|
|
497
|
+
return {
|
|
498
|
+
success: true,
|
|
499
|
+
data: { sessionId, ended: true, ...(memoryPrompt && { memoryPrompt }) },
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
catch {
|
|
503
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Resume an ended or suspended session.
|
|
508
|
+
* Note: This function has engine-specific logic for task file focus sync,
|
|
509
|
+
* so it remains in the engine layer.
|
|
510
|
+
* @task T4782
|
|
511
|
+
*/
|
|
512
|
+
export async function sessionResume(projectRoot, sessionId) {
|
|
513
|
+
try {
|
|
514
|
+
const accessor = await getAccessor(projectRoot);
|
|
515
|
+
// Look up sessions from the store.
|
|
516
|
+
const sessions = await accessor.loadSessions();
|
|
517
|
+
// Look in sessions list
|
|
518
|
+
const session = sessions.find((s) => s.id === sessionId);
|
|
519
|
+
if (!session) {
|
|
520
|
+
return engineError('E_NOT_FOUND', `Session '${sessionId}' not found`);
|
|
521
|
+
}
|
|
522
|
+
if (session.status === 'active') {
|
|
523
|
+
return { success: true, data: session };
|
|
524
|
+
}
|
|
525
|
+
if (session.status === 'archived') {
|
|
526
|
+
return engineError('E_INVALID_INPUT', `Session '${sessionId}' is archived and cannot be resumed`);
|
|
527
|
+
}
|
|
528
|
+
session.status = 'active';
|
|
529
|
+
session.endedAt = undefined;
|
|
530
|
+
session.resumeCount = (session.resumeCount || 0) + 1;
|
|
531
|
+
// Bump file_meta generation (activeSession no longer stored — status is source of truth)
|
|
532
|
+
const resumeMeta = (await accessor.getMetaValue('file_meta')) ?? {};
|
|
533
|
+
resumeMeta.generation = (resumeMeta.generation || 0) + 1;
|
|
534
|
+
await accessor.setMetaValue('file_meta', resumeMeta);
|
|
535
|
+
// Restore focus from session task work
|
|
536
|
+
if (session.taskWork?.taskId) {
|
|
537
|
+
const resumeFocus = await accessor.getMetaValue('focus_state');
|
|
538
|
+
if (resumeFocus) {
|
|
539
|
+
resumeFocus.currentTask = session.taskWork.taskId;
|
|
540
|
+
await accessor.setMetaValue('focus_state', resumeFocus);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
await accessor.upsertSingleSession(session);
|
|
544
|
+
// Wave 3B: Enrich resumed session with brain memory context (best-effort)
|
|
545
|
+
let memoryContext;
|
|
546
|
+
try {
|
|
547
|
+
const { getSessionMemoryContext } = await import('@cleocode/core/internal');
|
|
548
|
+
const scopeType = session.scope?.type;
|
|
549
|
+
const rootTaskId = session.scope?.rootTaskId;
|
|
550
|
+
memoryContext = await getSessionMemoryContext(projectRoot, {
|
|
551
|
+
type: scopeType ?? 'global',
|
|
552
|
+
rootTaskId,
|
|
553
|
+
epicId: rootTaskId,
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
catch {
|
|
557
|
+
// Best-effort -- memory context failure should not fail resume
|
|
558
|
+
}
|
|
559
|
+
const enrichedSession = {
|
|
560
|
+
...session,
|
|
561
|
+
...(memoryContext && { memoryContext }),
|
|
562
|
+
};
|
|
563
|
+
return { success: true, data: enrichedSession };
|
|
564
|
+
}
|
|
565
|
+
catch {
|
|
566
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Garbage collect old sessions.
|
|
571
|
+
* @task T4782
|
|
572
|
+
*/
|
|
573
|
+
export async function sessionGc(projectRoot, maxAgeDays = 1) {
|
|
574
|
+
try {
|
|
575
|
+
const accessor = await getAccessor(projectRoot);
|
|
576
|
+
const sessions = await accessor.loadSessions();
|
|
577
|
+
const now = Date.now();
|
|
578
|
+
const maxAgeMs = maxAgeDays * 24 * 60 * 60 * 1000;
|
|
579
|
+
const thirtyDaysMs = 30 * 24 * 60 * 60 * 1000;
|
|
580
|
+
const orphaned = [];
|
|
581
|
+
const removed = [];
|
|
582
|
+
// Mark stale active sessions as orphaned
|
|
583
|
+
for (const session of sessions) {
|
|
584
|
+
if (session.status === 'active') {
|
|
585
|
+
const lastActive = new Date(session.endedAt || session.startedAt).getTime();
|
|
586
|
+
if (now - lastActive > maxAgeMs) {
|
|
587
|
+
session.status = 'ended';
|
|
588
|
+
session.endedAt = new Date().toISOString();
|
|
589
|
+
orphaned.push(session.id);
|
|
590
|
+
await accessor.upsertSingleSession(session);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
// Remove very old ended sessions
|
|
595
|
+
for (const s of sessions) {
|
|
596
|
+
if (s.status === 'active')
|
|
597
|
+
continue;
|
|
598
|
+
const endedAt = s.endedAt ? new Date(s.endedAt).getTime() : new Date(s.startedAt).getTime();
|
|
599
|
+
if (now - endedAt > thirtyDaysMs) {
|
|
600
|
+
removed.push(s.id);
|
|
601
|
+
await accessor.removeSingleSession(s.id);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
return { success: true, data: { orphaned, removed } };
|
|
605
|
+
}
|
|
606
|
+
catch {
|
|
607
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Suspend an active session.
|
|
612
|
+
* @task T4782
|
|
613
|
+
*/
|
|
614
|
+
export async function sessionSuspend(projectRoot, sessionId, reason) {
|
|
615
|
+
try {
|
|
616
|
+
const result = await suspendSession(projectRoot, sessionId, reason);
|
|
617
|
+
return { success: true, data: result };
|
|
618
|
+
}
|
|
619
|
+
catch (err) {
|
|
620
|
+
const message = err.message;
|
|
621
|
+
const code = message.includes('not found')
|
|
622
|
+
? 'E_NOT_FOUND'
|
|
623
|
+
: message.includes('not active')
|
|
624
|
+
? 'E_INVALID_STATE'
|
|
625
|
+
: 'E_NOT_INITIALIZED';
|
|
626
|
+
return engineError(code, message);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* List session history with focus changes and completed tasks.
|
|
631
|
+
* @task T4782
|
|
632
|
+
*/
|
|
633
|
+
export async function sessionHistory(projectRoot, params) {
|
|
634
|
+
try {
|
|
635
|
+
const result = await getSessionHistory(projectRoot, params);
|
|
636
|
+
return { success: true, data: result };
|
|
637
|
+
}
|
|
638
|
+
catch {
|
|
639
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Remove orphaned sessions and clean up stale data.
|
|
644
|
+
* @task T4782
|
|
645
|
+
*/
|
|
646
|
+
export async function sessionCleanup(projectRoot) {
|
|
647
|
+
try {
|
|
648
|
+
const result = await cleanupSessions(projectRoot);
|
|
649
|
+
return { success: true, data: result };
|
|
650
|
+
}
|
|
651
|
+
catch {
|
|
652
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Record a decision to the audit trail.
|
|
657
|
+
* @task T4782
|
|
658
|
+
*/
|
|
659
|
+
export async function sessionRecordDecision(projectRoot, params) {
|
|
660
|
+
try {
|
|
661
|
+
const result = await recordDecision(projectRoot, params);
|
|
662
|
+
return { success: true, data: result };
|
|
663
|
+
}
|
|
664
|
+
catch (err) {
|
|
665
|
+
const message = err.message;
|
|
666
|
+
return engineError('E_INVALID_INPUT', message);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Read the decision log, optionally filtered by sessionId and/or taskId.
|
|
671
|
+
* @task T4782
|
|
672
|
+
*/
|
|
673
|
+
export async function sessionDecisionLog(projectRoot, params) {
|
|
674
|
+
try {
|
|
675
|
+
const result = await getDecisionLog(projectRoot, params);
|
|
676
|
+
return { success: true, data: result };
|
|
677
|
+
}
|
|
678
|
+
catch {
|
|
679
|
+
return { success: true, data: [] };
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Compute context drift score for the current session.
|
|
684
|
+
* @task T4782
|
|
685
|
+
*/
|
|
686
|
+
export async function sessionContextDrift(projectRoot, params) {
|
|
687
|
+
try {
|
|
688
|
+
const result = await getContextDrift(projectRoot, params);
|
|
689
|
+
return { success: true, data: result };
|
|
690
|
+
}
|
|
691
|
+
catch (err) {
|
|
692
|
+
const message = err.message;
|
|
693
|
+
const code = message.includes('not found') ? 'E_NOT_FOUND' : 'E_NOT_INITIALIZED';
|
|
694
|
+
return engineError(code, message);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Record an assumption made during a session.
|
|
699
|
+
* @task T4782
|
|
700
|
+
*/
|
|
701
|
+
export async function sessionRecordAssumption(projectRoot, params) {
|
|
702
|
+
try {
|
|
703
|
+
const result = await recordAssumption(projectRoot, params);
|
|
704
|
+
return { success: true, data: result };
|
|
705
|
+
}
|
|
706
|
+
catch (err) {
|
|
707
|
+
const message = err.message;
|
|
708
|
+
const code = message.includes('required') || message.includes('must be')
|
|
709
|
+
? 'E_INVALID_INPUT'
|
|
710
|
+
: 'E_NOT_INITIALIZED';
|
|
711
|
+
return engineError(code, message);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Compute session statistics, optionally for a specific session.
|
|
716
|
+
* @task T4782
|
|
717
|
+
*/
|
|
718
|
+
export async function sessionStats(projectRoot, sessionId) {
|
|
719
|
+
try {
|
|
720
|
+
const result = await getSessionStats(projectRoot, sessionId);
|
|
721
|
+
return { success: true, data: result };
|
|
722
|
+
}
|
|
723
|
+
catch (err) {
|
|
724
|
+
const message = err.message;
|
|
725
|
+
const code = message.includes('not found') ? 'E_NOT_FOUND' : 'E_NOT_INITIALIZED';
|
|
726
|
+
return engineError(code, message);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Switch to a different session.
|
|
731
|
+
* @task T4782
|
|
732
|
+
*/
|
|
733
|
+
export async function sessionSwitch(projectRoot, sessionId) {
|
|
734
|
+
try {
|
|
735
|
+
const result = await switchSession(projectRoot, sessionId);
|
|
736
|
+
return { success: true, data: result };
|
|
737
|
+
}
|
|
738
|
+
catch (err) {
|
|
739
|
+
const message = err.message;
|
|
740
|
+
const code = message.includes('not found')
|
|
741
|
+
? 'E_NOT_FOUND'
|
|
742
|
+
: message.includes('archived')
|
|
743
|
+
? 'E_INVALID_STATE'
|
|
744
|
+
: 'E_NOT_INITIALIZED';
|
|
745
|
+
return engineError(code, message);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Archive old/ended sessions.
|
|
750
|
+
* @task T4782
|
|
751
|
+
*/
|
|
752
|
+
export async function sessionArchive(projectRoot, olderThan) {
|
|
753
|
+
try {
|
|
754
|
+
const result = await archiveSessions(projectRoot, olderThan);
|
|
755
|
+
return { success: true, data: result };
|
|
756
|
+
}
|
|
757
|
+
catch {
|
|
758
|
+
return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Get handoff data for the most recent ended session.
|
|
763
|
+
* @task T4915, T5123
|
|
764
|
+
*/
|
|
765
|
+
export async function sessionHandoff(projectRoot, scope) {
|
|
766
|
+
try {
|
|
767
|
+
const result = await getLastHandoff(projectRoot, scope);
|
|
768
|
+
return { success: true, data: result };
|
|
769
|
+
}
|
|
770
|
+
catch (err) {
|
|
771
|
+
if (err instanceof CleoError) {
|
|
772
|
+
const stringCode = `E_${getExitCodeName(err.code)}`;
|
|
773
|
+
return engineError(stringCode, err.message, {
|
|
774
|
+
...(err.fix && { fix: err.fix }),
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
778
|
+
return engineError('E_GENERAL', message);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Compute and persist handoff data for a session.
|
|
783
|
+
* @task T4915
|
|
784
|
+
*/
|
|
785
|
+
export async function sessionComputeHandoff(projectRoot, sessionId, options) {
|
|
786
|
+
try {
|
|
787
|
+
const handoff = await computeHandoff(projectRoot, {
|
|
788
|
+
sessionId,
|
|
789
|
+
note: options?.note,
|
|
790
|
+
nextAction: options?.nextAction,
|
|
791
|
+
});
|
|
792
|
+
await persistHandoff(projectRoot, sessionId, handoff);
|
|
793
|
+
return { success: true, data: handoff };
|
|
794
|
+
}
|
|
795
|
+
catch (err) {
|
|
796
|
+
const message = err.message;
|
|
797
|
+
return engineError(message.includes('not found') ? 'E_NOT_FOUND' : 'E_INTERNAL', message);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Compute session briefing - composite view for session start.
|
|
802
|
+
* Aggregates data from handoff, current focus, next tasks, bugs, blockers, and epics.
|
|
803
|
+
* @task T4916
|
|
804
|
+
*/
|
|
805
|
+
export async function sessionBriefing(projectRoot, options) {
|
|
806
|
+
try {
|
|
807
|
+
const briefing = await computeBriefing(projectRoot, options);
|
|
808
|
+
return { success: true, data: briefing };
|
|
809
|
+
}
|
|
810
|
+
catch (err) {
|
|
811
|
+
const message = err.message;
|
|
812
|
+
return engineError(message.includes('not found') ? 'E_NOT_FOUND' : 'E_INTERNAL', message);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
// =============================================================================
|
|
816
|
+
// RICH DEBRIEF + CHAIN OPERATIONS (T4959)
|
|
817
|
+
// =============================================================================
|
|
818
|
+
/**
|
|
819
|
+
* Compute and persist rich debrief data for a session.
|
|
820
|
+
* Persists as both handoffJson (backward compat) and debriefJson (rich data).
|
|
821
|
+
* @epic T4959
|
|
822
|
+
*/
|
|
823
|
+
export async function sessionComputeDebrief(projectRoot, sessionId, options) {
|
|
824
|
+
try {
|
|
825
|
+
const accessor = await getAccessor(projectRoot);
|
|
826
|
+
const sessions = await accessor.loadSessions();
|
|
827
|
+
const session = sessions.find((s) => s.id === sessionId);
|
|
828
|
+
const debrief = await computeDebrief(projectRoot, {
|
|
829
|
+
sessionId,
|
|
830
|
+
note: options?.note,
|
|
831
|
+
nextAction: options?.nextAction,
|
|
832
|
+
agentIdentifier: session?.agentIdentifier ?? null,
|
|
833
|
+
startedAt: session?.startedAt,
|
|
834
|
+
endedAt: session?.endedAt ?? new Date().toISOString(),
|
|
835
|
+
});
|
|
836
|
+
// Persist both handoffJson and debriefJson
|
|
837
|
+
const { persistHandoff: corePersistHandoff } = await import('@cleocode/core/internal');
|
|
838
|
+
await corePersistHandoff(projectRoot, sessionId, debrief.handoff);
|
|
839
|
+
// Persist debriefJson via session update
|
|
840
|
+
if (session) {
|
|
841
|
+
session.debriefJson = JSON.stringify(debrief);
|
|
842
|
+
await accessor.upsertSingleSession(session);
|
|
843
|
+
}
|
|
844
|
+
return { success: true, data: debrief };
|
|
845
|
+
}
|
|
846
|
+
catch (err) {
|
|
847
|
+
const message = err.message;
|
|
848
|
+
return engineError(message.includes('not found') ? 'E_NOT_FOUND' : 'E_INTERNAL', message);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Read a session's debrief data.
|
|
853
|
+
* Falls back to handoff data if no debrief is available.
|
|
854
|
+
* @epic T4959
|
|
855
|
+
*/
|
|
856
|
+
export async function sessionDebriefShow(projectRoot, sessionId) {
|
|
857
|
+
try {
|
|
858
|
+
const accessor = await getAccessor(projectRoot);
|
|
859
|
+
const sessions = await accessor.loadSessions();
|
|
860
|
+
const session = sessions.find((s) => s.id === sessionId);
|
|
861
|
+
if (!session) {
|
|
862
|
+
return engineError('E_NOT_FOUND', `Session '${sessionId}' not found`);
|
|
863
|
+
}
|
|
864
|
+
// Try debriefJson first
|
|
865
|
+
if (session.debriefJson) {
|
|
866
|
+
try {
|
|
867
|
+
const debrief = JSON.parse(session.debriefJson);
|
|
868
|
+
return { success: true, data: debrief };
|
|
869
|
+
}
|
|
870
|
+
catch {
|
|
871
|
+
// Fall through to handoff
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
// Fall back to handoffJson
|
|
875
|
+
if (typeof session.handoffJson === 'string') {
|
|
876
|
+
try {
|
|
877
|
+
const handoff = JSON.parse(session.handoffJson);
|
|
878
|
+
return { success: true, data: { handoff, fallback: true } };
|
|
879
|
+
}
|
|
880
|
+
catch {
|
|
881
|
+
// No data available
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
return { success: true, data: null };
|
|
885
|
+
}
|
|
886
|
+
catch (err) {
|
|
887
|
+
const message = err.message;
|
|
888
|
+
return engineError(message.includes('not found') ? 'E_NOT_FOUND' : 'E_INTERNAL', message);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Show the session chain for a given session.
|
|
893
|
+
* Returns ordered list of sessions linked via previousSessionId/nextSessionId.
|
|
894
|
+
* @epic T4959
|
|
895
|
+
*/
|
|
896
|
+
export async function sessionChainShow(projectRoot, sessionId) {
|
|
897
|
+
try {
|
|
898
|
+
const accessor = await getAccessor(projectRoot);
|
|
899
|
+
const sessions = await accessor.loadSessions();
|
|
900
|
+
const sessionMap = new Map(sessions.map((s) => [s.id, s]));
|
|
901
|
+
const target = sessionMap.get(sessionId);
|
|
902
|
+
if (!target) {
|
|
903
|
+
return engineError('E_NOT_FOUND', `Session '${sessionId}' not found`);
|
|
904
|
+
}
|
|
905
|
+
// Walk backward to chain start
|
|
906
|
+
const chain = [sessionId];
|
|
907
|
+
const visited = new Set([sessionId]);
|
|
908
|
+
let current = target.previousSessionId;
|
|
909
|
+
while (current && !visited.has(current)) {
|
|
910
|
+
chain.unshift(current);
|
|
911
|
+
visited.add(current);
|
|
912
|
+
const s = sessionMap.get(current);
|
|
913
|
+
current = s?.previousSessionId ?? undefined;
|
|
914
|
+
}
|
|
915
|
+
// Walk forward from target
|
|
916
|
+
current = target.nextSessionId;
|
|
917
|
+
while (current && !visited.has(current)) {
|
|
918
|
+
chain.push(current);
|
|
919
|
+
visited.add(current);
|
|
920
|
+
const s = sessionMap.get(current);
|
|
921
|
+
current = s?.nextSessionId ?? undefined;
|
|
922
|
+
}
|
|
923
|
+
const result = chain.map((id, idx) => {
|
|
924
|
+
const s = sessionMap.get(id);
|
|
925
|
+
return {
|
|
926
|
+
id,
|
|
927
|
+
status: s?.status ?? 'unknown',
|
|
928
|
+
startedAt: s?.startedAt ?? '',
|
|
929
|
+
endedAt: s?.endedAt ?? null,
|
|
930
|
+
agentIdentifier: s?.agentIdentifier ?? null,
|
|
931
|
+
position: idx + 1,
|
|
932
|
+
};
|
|
933
|
+
});
|
|
934
|
+
return { success: true, data: result };
|
|
935
|
+
}
|
|
936
|
+
catch (err) {
|
|
937
|
+
const message = err.message;
|
|
938
|
+
return engineError('E_INTERNAL', message);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Inject context protocol content.
|
|
943
|
+
* @task T5673
|
|
944
|
+
*/
|
|
945
|
+
export function sessionContextInject(protocolType, params, projectRoot) {
|
|
946
|
+
try {
|
|
947
|
+
const result = injectContext(protocolType, params, projectRoot);
|
|
948
|
+
return { success: true, data: result };
|
|
949
|
+
}
|
|
950
|
+
catch (err) {
|
|
951
|
+
const message = err.message;
|
|
952
|
+
const code = message.includes('required')
|
|
953
|
+
? 'E_INVALID_INPUT'
|
|
954
|
+
: message.includes('not found')
|
|
955
|
+
? 'E_NOT_FOUND'
|
|
956
|
+
: 'E_INTERNAL';
|
|
957
|
+
return engineError(code, message);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
//# sourceMappingURL=session-engine.js.map
|