@cleocode/cleo 2026.4.10 → 2026.4.12
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 +202 -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 +1169 -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 +9 -0
- package/dist/cli/commands/backup.d.ts.map +1 -0
- package/dist/cli/commands/backup.js +41 -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 +92 -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 +134 -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 +143 -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 +12 -0
- package/dist/cli/commands/observe.d.ts.map +1 -0
- package/dist/cli/commands/observe.js +42 -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 +12 -0
- package/dist/cli/commands/restore.d.ts.map +1 -0
- package/dist/cli/commands/restore.js +228 -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/schema.d.ts +27 -0
- package/dist/cli/commands/schema.d.ts.map +1 -0
- package/dist/cli/commands/schema.js +160 -0
- package/dist/cli/commands/schema.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 +40 -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/help-generator.d.ts +74 -0
- package/dist/cli/help-generator.d.ts.map +1 -0
- package/dist/cli/help-generator.js +229 -0
- package/dist/cli/help-generator.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 +342 -107611
- package/dist/cli/index.js.map +1 -7
- 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 +87 -0
- package/dist/cli/renderers/index.d.ts.map +1 -0
- package/dist/cli/renderers/index.js +262 -0
- package/dist/cli/renderers/index.js.map +1 -0
- package/dist/cli/renderers/lafs-validator.d.ts +91 -0
- package/dist/cli/renderers/lafs-validator.d.ts.map +1 -0
- package/dist/cli/renderers/lafs-validator.js +176 -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 +276 -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 +119 -0
- package/dist/dispatch/engines/_error.d.ts.map +1 -0
- package/dist/dispatch/engines/_error.js +288 -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 +910 -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 +1258 -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 +1193 -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 +36 -0
- package/dist/dispatch/lib/budget.d.ts.map +1 -0
- package/dist/dispatch/lib/budget.js +109 -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 +115 -0
- package/dist/dispatch/lib/defaults.d.ts.map +1 -0
- package/dist/dispatch/lib/defaults.js +61 -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/exit-codes.d.ts +35 -0
- package/dist/dispatch/lib/exit-codes.d.ts.map +1 -0
- package/dist/dispatch/lib/exit-codes.js +60 -0
- package/dist/dispatch/lib/exit-codes.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/proto-envelope.d.ts +56 -0
- package/dist/dispatch/lib/proto-envelope.d.ts.map +1 -0
- package/dist/dispatch/lib/proto-envelope.js +17 -0
- package/dist/dispatch/lib/proto-envelope.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 +25 -0
- package/dist/dispatch/middleware/field-filter.d.ts.map +1 -0
- package/dist/dispatch/middleware/field-filter.js +70 -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 +30 -0
- package/dist/dispatch/middleware/protocol-enforcement.d.ts.map +1 -0
- package/dist/dispatch/middleware/protocol-enforcement.js +56 -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 +206 -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
- package/templates/cleoos-hub/pi-extensions/cleo-cant-bridge.ts +180 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central output dispatch for V2 CLI commands.
|
|
3
|
+
*
|
|
4
|
+
* Provides cliOutput() which replaces `console.log(formatSuccess(data))`.
|
|
5
|
+
* Checks the resolved format (JSON/human/quiet) and dispatches to either
|
|
6
|
+
* the LAFS JSON envelope (formatSuccess) or a human-readable renderer.
|
|
7
|
+
*
|
|
8
|
+
* Commands call:
|
|
9
|
+
* cliOutput(data, { command: 'show', message, operation, page })
|
|
10
|
+
*
|
|
11
|
+
* @task T4665
|
|
12
|
+
* @task T4666
|
|
13
|
+
* @task T4813
|
|
14
|
+
* @epic T4663
|
|
15
|
+
*/
|
|
16
|
+
import { type FormatOptions } from '@cleocode/core';
|
|
17
|
+
import type { CliMeta } from '@cleocode/lafs';
|
|
18
|
+
export interface CliOutputOptions {
|
|
19
|
+
/** Command name (used to pick the correct human renderer). */
|
|
20
|
+
command: string;
|
|
21
|
+
/** Optional success message for JSON envelope (attached to `meta.message`). */
|
|
22
|
+
message?: string;
|
|
23
|
+
/** Operation name for canonical envelope `meta.operation` (e.g. `"tasks.show"`). */
|
|
24
|
+
operation?: string;
|
|
25
|
+
/** Pagination metadata for canonical envelope `page` field. */
|
|
26
|
+
page?: FormatOptions['page'];
|
|
27
|
+
/** Extra metadata extensions merged into `meta`. */
|
|
28
|
+
extensions?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Output data to stdout in the resolved format (JSON or human-readable).
|
|
32
|
+
*
|
|
33
|
+
* Replaces `console.log(formatSuccess(data))` in all V2 commands.
|
|
34
|
+
* When format is 'human', normalizes the data shape then dispatches to
|
|
35
|
+
* the appropriate renderer.
|
|
36
|
+
* When format is 'json', delegates to existing formatSuccess().
|
|
37
|
+
*
|
|
38
|
+
* @task T4665
|
|
39
|
+
* @task T4666
|
|
40
|
+
* @task T4813
|
|
41
|
+
*/
|
|
42
|
+
export declare function cliOutput(data: unknown, opts: CliOutputOptions): void;
|
|
43
|
+
/**
|
|
44
|
+
* Error details for structured error output.
|
|
45
|
+
*
|
|
46
|
+
* Carries the full LAFS-compatible error context forwarded by the dispatch
|
|
47
|
+
* adapter from {@link DispatchError}. All fields are optional — only present
|
|
48
|
+
* fields are emitted in the output envelope.
|
|
49
|
+
*
|
|
50
|
+
* @see packages/cleo/src/dispatch/types.ts DispatchError
|
|
51
|
+
*/
|
|
52
|
+
export interface CliErrorDetails {
|
|
53
|
+
/** Machine-readable error code name (e.g. `E_NOT_FOUND`). */
|
|
54
|
+
name?: string;
|
|
55
|
+
/** Additional structured details from the error. */
|
|
56
|
+
details?: unknown;
|
|
57
|
+
/** Copy-paste fix hint for the operator or agent. */
|
|
58
|
+
fix?: unknown;
|
|
59
|
+
/** Alternative actions the caller can try. */
|
|
60
|
+
alternatives?: Array<{
|
|
61
|
+
action: string;
|
|
62
|
+
command: string;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Output an error in the resolved format.
|
|
67
|
+
*
|
|
68
|
+
* In JSON format (default / agent mode): emits a canonical `CliEnvelope` error
|
|
69
|
+
* envelope to stdout. The envelope always includes `meta` (ADR-039).
|
|
70
|
+
* All optional fields (`codeName`, `fix`, `alternatives`, `details`) are
|
|
71
|
+
* included only when they are actually present — no `undefined` keys are emitted.
|
|
72
|
+
*
|
|
73
|
+
* In human format: prints a plain error line to stderr and, when
|
|
74
|
+
* `details.fix` is a string, appends a `Fix: <hint>` line.
|
|
75
|
+
*
|
|
76
|
+
* @param message - Human-readable error message.
|
|
77
|
+
* @param code - Numeric exit code or string error code.
|
|
78
|
+
* @param details - Optional structured details (codeName, fix, alternatives, …).
|
|
79
|
+
* @param meta - Optional partial meta to merge into the error envelope.
|
|
80
|
+
*
|
|
81
|
+
* @task T4666
|
|
82
|
+
* @task T4813
|
|
83
|
+
* @task T336
|
|
84
|
+
* @task T338
|
|
85
|
+
*/
|
|
86
|
+
export declare function cliError(message: string, code?: number | string, details?: CliErrorDetails, meta?: Partial<CliMeta>): void;
|
|
87
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/renderers/index.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAe,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA8E3D,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7B,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAsIrE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,8CAA8C;IAC9C,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,EACzB,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GACtB,IAAI,CA0CN"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a request UUID for error envelopes.
|
|
4
|
+
* Extracted to keep the hot path synchronous.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
function generateRequestId() {
|
|
9
|
+
return randomUUID();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Central output dispatch for V2 CLI commands.
|
|
13
|
+
*
|
|
14
|
+
* Provides cliOutput() which replaces `console.log(formatSuccess(data))`.
|
|
15
|
+
* Checks the resolved format (JSON/human/quiet) and dispatches to either
|
|
16
|
+
* the LAFS JSON envelope (formatSuccess) or a human-readable renderer.
|
|
17
|
+
*
|
|
18
|
+
* Commands call:
|
|
19
|
+
* cliOutput(data, { command: 'show', message, operation, page })
|
|
20
|
+
*
|
|
21
|
+
* @task T4665
|
|
22
|
+
* @task T4666
|
|
23
|
+
* @task T4813
|
|
24
|
+
* @epic T4663
|
|
25
|
+
*/
|
|
26
|
+
import { formatSuccess } from '@cleocode/core';
|
|
27
|
+
import { applyFieldFilter, extractFieldFromResult } from '@cleocode/lafs';
|
|
28
|
+
import { getFieldContext } from '../field-context.js';
|
|
29
|
+
import { getFormatContext } from '../format-context.js';
|
|
30
|
+
import { emitLafsViolation, LafsViolationError, validateLafsShape } from './lafs-validator.js';
|
|
31
|
+
import { normalizeForHuman } from './normalizer.js';
|
|
32
|
+
// System renderers
|
|
33
|
+
import { renderBlockers, renderCurrent, renderDoctor, renderGeneric, renderNext, renderPlan, renderSession, renderStart, renderStats, renderStop, renderTree, renderVersion, } from './system.js';
|
|
34
|
+
// Task renderers
|
|
35
|
+
import { renderAdd, renderArchive, renderComplete, renderDelete, renderFind, renderList, renderRestore, renderShow, renderUpdate, } from './tasks.js';
|
|
36
|
+
const renderers = {
|
|
37
|
+
// Task CRUD
|
|
38
|
+
show: renderShow,
|
|
39
|
+
list: renderList,
|
|
40
|
+
ls: renderList,
|
|
41
|
+
find: renderFind,
|
|
42
|
+
search: renderFind,
|
|
43
|
+
add: renderAdd,
|
|
44
|
+
update: renderUpdate,
|
|
45
|
+
complete: renderComplete,
|
|
46
|
+
done: renderComplete,
|
|
47
|
+
delete: renderDelete,
|
|
48
|
+
rm: renderDelete,
|
|
49
|
+
archive: renderArchive,
|
|
50
|
+
restore: renderRestore,
|
|
51
|
+
// Task work
|
|
52
|
+
start: renderStart,
|
|
53
|
+
stop: renderStop,
|
|
54
|
+
current: renderCurrent,
|
|
55
|
+
// System
|
|
56
|
+
doctor: renderDoctor,
|
|
57
|
+
stats: renderStats,
|
|
58
|
+
next: renderNext,
|
|
59
|
+
plan: renderPlan,
|
|
60
|
+
blockers: renderBlockers,
|
|
61
|
+
tree: renderTree,
|
|
62
|
+
depends: renderTree,
|
|
63
|
+
deps: renderTree,
|
|
64
|
+
session: renderSession,
|
|
65
|
+
version: renderVersion,
|
|
66
|
+
};
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// Main output function
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
/**
|
|
71
|
+
* Output data to stdout in the resolved format (JSON or human-readable).
|
|
72
|
+
*
|
|
73
|
+
* Replaces `console.log(formatSuccess(data))` in all V2 commands.
|
|
74
|
+
* When format is 'human', normalizes the data shape then dispatches to
|
|
75
|
+
* the appropriate renderer.
|
|
76
|
+
* When format is 'json', delegates to existing formatSuccess().
|
|
77
|
+
*
|
|
78
|
+
* @task T4665
|
|
79
|
+
* @task T4666
|
|
80
|
+
* @task T4813
|
|
81
|
+
*/
|
|
82
|
+
export function cliOutput(data, opts) {
|
|
83
|
+
const ctx = getFormatContext();
|
|
84
|
+
const fieldCtx = getFieldContext();
|
|
85
|
+
if (ctx.format === 'human') {
|
|
86
|
+
let dataToRender = data;
|
|
87
|
+
// §5.4.1 filter-then-render: apply --field extraction BEFORE human rendering
|
|
88
|
+
let fieldExtracted = false;
|
|
89
|
+
if (fieldCtx.field) {
|
|
90
|
+
const extracted = extractFieldFromResult(data, fieldCtx.field);
|
|
91
|
+
if (extracted === undefined) {
|
|
92
|
+
cliError(`Field "${fieldCtx.field}" not found`, 4, { name: 'E_NOT_FOUND' });
|
|
93
|
+
process.exit(4);
|
|
94
|
+
}
|
|
95
|
+
// If extracted is a primitive, render directly
|
|
96
|
+
if (typeof extracted !== 'object' || extracted === null) {
|
|
97
|
+
console.log(String(extracted));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// If extracted is an array, wrap it for renderGeneric
|
|
101
|
+
if (Array.isArray(extracted)) {
|
|
102
|
+
dataToRender = { [fieldCtx.field]: extracted };
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
dataToRender = extracted;
|
|
106
|
+
}
|
|
107
|
+
fieldExtracted = true;
|
|
108
|
+
}
|
|
109
|
+
const normalized = normalizeForHuman(opts.command, dataToRender);
|
|
110
|
+
// After field extraction, use renderGeneric — command-specific renderers
|
|
111
|
+
// expect the full data structure, not a filtered subset (§5.4.1)
|
|
112
|
+
const renderer = fieldExtracted ? renderGeneric : (renderers[opts.command] ?? renderGeneric);
|
|
113
|
+
const text = renderer(normalized, ctx.quiet);
|
|
114
|
+
if (text) {
|
|
115
|
+
console.log(text);
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// --field: single-field plain text extraction (scripting / agent use).
|
|
120
|
+
// Centralised here so ALL commands (dispatchFromCli and dispatchRaw) honour the flag.
|
|
121
|
+
if (fieldCtx.field) {
|
|
122
|
+
// extractFieldFromResult operates on the data payload (not the envelope).
|
|
123
|
+
// Cast to the proto-envelope result type for the SDK call.
|
|
124
|
+
const value = extractFieldFromResult(data, fieldCtx.field);
|
|
125
|
+
if (value === undefined) {
|
|
126
|
+
cliError(`Field "${fieldCtx.field}" not found`, 4, { name: 'E_NOT_FOUND' });
|
|
127
|
+
process.exit(4);
|
|
128
|
+
}
|
|
129
|
+
const out = value !== null && typeof value === 'object' ? JSON.stringify(value) : String(value);
|
|
130
|
+
process.stdout.write(out + '\n');
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// JSON format (default): apply --fields filter, then emit canonical CLI envelope.
|
|
134
|
+
// Centralised here so ALL commands honour the flag without per-command wiring.
|
|
135
|
+
// applyFieldFilter can throw on unusual mixed-type arrays (e.g. changes: ['status']).
|
|
136
|
+
// In that case we fall back to unfiltered output rather than crashing.
|
|
137
|
+
let filteredData = data;
|
|
138
|
+
if (fieldCtx.fields?.length && data !== undefined && data !== null) {
|
|
139
|
+
try {
|
|
140
|
+
// Build a proto-envelope stub to drive the SDK field filter (ADR-039 bridge).
|
|
141
|
+
const stub = {
|
|
142
|
+
$schema: 'https://lafs.dev/schemas/v1/envelope.schema.json',
|
|
143
|
+
_meta: {
|
|
144
|
+
specVersion: '',
|
|
145
|
+
schemaVersion: '',
|
|
146
|
+
timestamp: '',
|
|
147
|
+
operation: '',
|
|
148
|
+
requestId: '',
|
|
149
|
+
transport: 'cli',
|
|
150
|
+
strict: false,
|
|
151
|
+
mvi: 'standard',
|
|
152
|
+
contextVersion: 0,
|
|
153
|
+
},
|
|
154
|
+
success: true,
|
|
155
|
+
result: data,
|
|
156
|
+
};
|
|
157
|
+
const filtered = applyFieldFilter(stub, fieldCtx.fields);
|
|
158
|
+
filteredData = filtered.result;
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
// applyFieldFilter limitation: mixed-type arrays (strings inside arrays) are not
|
|
162
|
+
// supported. Fall through to emit the full unfiltered result.
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// Build FormatOptions for formatSuccess (now emits canonical CliEnvelope shape).
|
|
166
|
+
const formatOpts = {};
|
|
167
|
+
if (opts.operation)
|
|
168
|
+
formatOpts.operation = opts.operation;
|
|
169
|
+
if (opts.page)
|
|
170
|
+
formatOpts.page = opts.page;
|
|
171
|
+
if (opts.extensions)
|
|
172
|
+
formatOpts.extensions = opts.extensions;
|
|
173
|
+
if (fieldCtx.mvi)
|
|
174
|
+
formatOpts.mvi = fieldCtx.mvi;
|
|
175
|
+
// Phase 6 — LAFS envelope validation middleware.
|
|
176
|
+
// Every CLI output flows through `formatSuccess()` → string. We parse the
|
|
177
|
+
// string, assert the shape invariants, and only emit if validation passes.
|
|
178
|
+
// A shape violation is a CLEO developer bug, so we:
|
|
179
|
+
// 1. Emit a valid LAFS error envelope to stderr describing the violation
|
|
180
|
+
// 2. Set process.exitCode to ExitCode.LAFS_VIOLATION (104)
|
|
181
|
+
// 3. Still emit the (invalid) original to stdout so operators can inspect
|
|
182
|
+
// This is a safety net — it never SILENTLY swallows output.
|
|
183
|
+
const envelopeString = formatSuccess(filteredData, opts.message, Object.keys(formatOpts).length > 0 ? formatOpts : opts.operation);
|
|
184
|
+
if (process.env['CLEO_LAFS_VALIDATE'] !== 'off') {
|
|
185
|
+
try {
|
|
186
|
+
const report = validateLafsShape(envelopeString);
|
|
187
|
+
if (report.reasons.length > 0) {
|
|
188
|
+
emitLafsViolation(new LafsViolationError(`cliOutput: envelope failed LAFS shape validation`, report));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
if (err instanceof LafsViolationError) {
|
|
193
|
+
emitLafsViolation(err);
|
|
194
|
+
}
|
|
195
|
+
// Non-validator errors — re-raise so tests can see them
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
console.log(envelopeString);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Output an error in the resolved format.
|
|
202
|
+
*
|
|
203
|
+
* In JSON format (default / agent mode): emits a canonical `CliEnvelope` error
|
|
204
|
+
* envelope to stdout. The envelope always includes `meta` (ADR-039).
|
|
205
|
+
* All optional fields (`codeName`, `fix`, `alternatives`, `details`) are
|
|
206
|
+
* included only when they are actually present — no `undefined` keys are emitted.
|
|
207
|
+
*
|
|
208
|
+
* In human format: prints a plain error line to stderr and, when
|
|
209
|
+
* `details.fix` is a string, appends a `Fix: <hint>` line.
|
|
210
|
+
*
|
|
211
|
+
* @param message - Human-readable error message.
|
|
212
|
+
* @param code - Numeric exit code or string error code.
|
|
213
|
+
* @param details - Optional structured details (codeName, fix, alternatives, …).
|
|
214
|
+
* @param meta - Optional partial meta to merge into the error envelope.
|
|
215
|
+
*
|
|
216
|
+
* @task T4666
|
|
217
|
+
* @task T4813
|
|
218
|
+
* @task T336
|
|
219
|
+
* @task T338
|
|
220
|
+
*/
|
|
221
|
+
export function cliError(message, code, details, meta) {
|
|
222
|
+
const ctx = getFormatContext();
|
|
223
|
+
if (ctx.format === 'human') {
|
|
224
|
+
console.error(`Error: ${message}${code ? ` (${code})` : ''}`);
|
|
225
|
+
if (typeof details?.fix === 'string') {
|
|
226
|
+
console.error(`Fix: ${details.fix}`);
|
|
227
|
+
}
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
// JSON envelope always goes to stdout for consistent machine-readable output.
|
|
231
|
+
// Build the error object incrementally so that absent optional fields are
|
|
232
|
+
// never serialised as `undefined` (which JSON.stringify would strip anyway,
|
|
233
|
+
// but being explicit keeps the intent clear and avoids lint warnings).
|
|
234
|
+
const errorObj = {
|
|
235
|
+
code: code ?? 1,
|
|
236
|
+
message,
|
|
237
|
+
};
|
|
238
|
+
if (details?.name !== undefined)
|
|
239
|
+
errorObj['codeName'] = details.name;
|
|
240
|
+
if (details?.fix !== undefined)
|
|
241
|
+
errorObj['fix'] = details.fix;
|
|
242
|
+
if (details?.alternatives !== undefined)
|
|
243
|
+
errorObj['alternatives'] = details.alternatives;
|
|
244
|
+
if (details?.details !== undefined)
|
|
245
|
+
errorObj['details'] = details.details;
|
|
246
|
+
// Canonical error envelope: {success, error, meta} — meta is ALWAYS present.
|
|
247
|
+
// Merge caller-supplied meta with defaults (ADR-039).
|
|
248
|
+
const errorMeta = {
|
|
249
|
+
operation: meta?.operation ?? 'cli.error',
|
|
250
|
+
requestId: meta?.requestId ?? generateRequestId(),
|
|
251
|
+
duration_ms: meta?.duration_ms ?? 0,
|
|
252
|
+
timestamp: meta?.timestamp ?? new Date().toISOString(),
|
|
253
|
+
...meta,
|
|
254
|
+
};
|
|
255
|
+
const envelope = {
|
|
256
|
+
success: false,
|
|
257
|
+
error: errorObj,
|
|
258
|
+
meta: errorMeta,
|
|
259
|
+
};
|
|
260
|
+
console.log(JSON.stringify(envelope));
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/renderers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;GAKG;AACH,SAAS,iBAAiB;IACxB,OAAO,UAAU,EAAE,CAAC;AACtB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAsB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,C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AC;IACrE,IAAI,OAAO,EAAE,GAAG,KAAK,SAAS;QAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAC9D,IAAI,OAAO,EAAE,YAAY,KAAK,SAAS;QAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;IACzF,IAAI,OAAO,EAAE,OAAO,KAAK,SAAS;QAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAE1E,6EAA6E;IAC7E,sDAAsD;IACtD,MAAM,SAAS,GAAY;QACzB,SAAS,EAAE,IAAI,EAAE,SAAS,IAAI,WAAW;QACzC,SAAS,EAAE,IAAI,EAAE,SAAS,IAAI,iBAAiB,EAAE;QACjD,WAAW,EAAE,IAAI,EAAE,WAAW,IAAI,CAAC;QACnC,SAAS,EAAE,IAAI,EAAE,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACtD,GAAG,IAAI;KACR,CAAC;IAEF,MAAM,QAAQ,GAAuB;QACnC,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,QAAqD;QAC5D,IAAI,EAAE,SAAS;KAChB,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI envelope validator middleware (Phase 6 / ADR-039 update).
|
|
3
|
+
*
|
|
4
|
+
* Every CLI envelope emitted by `cliOutput()` flows through this module
|
|
5
|
+
* before hitting stdout. Validates the **canonical CLI envelope** shape
|
|
6
|
+
* (`{success, data?, error?, meta, page?}`) as defined in ADR-039.
|
|
7
|
+
*
|
|
8
|
+
* The canonical shape replaces the three legacy shapes:
|
|
9
|
+
* - `{ok, r, _m}` (minimal MVI — removed)
|
|
10
|
+
* - `{$schema, _meta, success, result}` (full LAFS — migrated)
|
|
11
|
+
* - `{success, result}` (observe command — migrated)
|
|
12
|
+
*
|
|
13
|
+
* Validation invariants:
|
|
14
|
+
* - Envelope MUST be a JSON object
|
|
15
|
+
* - `success` MUST be present and boolean
|
|
16
|
+
* - On success, `data` MUST exist (may be null)
|
|
17
|
+
* - On failure, `error` MUST exist with at least `code` and `message`
|
|
18
|
+
* - `meta` MUST be present (always — success and failure)
|
|
19
|
+
*
|
|
20
|
+
* When a violation is detected, the validator:
|
|
21
|
+
* 1. Wraps the malformed output in a valid error envelope
|
|
22
|
+
* 2. Sets the process exit code to `ExitCode.LAFS_VIOLATION` (104)
|
|
23
|
+
* 3. Emits the wrapped envelope to stderr for diagnostic tooling
|
|
24
|
+
*
|
|
25
|
+
* @task Phase 6 — LAFS formalization + schema consolidation
|
|
26
|
+
* @task T338 — ADR-039 canonical envelope unification
|
|
27
|
+
*/
|
|
28
|
+
import { ExitCode } from '@cleocode/contracts';
|
|
29
|
+
/**
|
|
30
|
+
* Shape violation report for a canonical CLI envelope.
|
|
31
|
+
*
|
|
32
|
+
* Carries the individual invariant results so diagnostic tooling can
|
|
33
|
+
* report exactly which invariants were violated.
|
|
34
|
+
*/
|
|
35
|
+
export interface LafsShapeViolation {
|
|
36
|
+
/** True iff the input is a well-formed JSON object. */
|
|
37
|
+
isObject: boolean;
|
|
38
|
+
/** True iff `success` is present. */
|
|
39
|
+
hasSuccessField: boolean;
|
|
40
|
+
/** True iff `success` is a boolean. */
|
|
41
|
+
successIsBoolean: boolean;
|
|
42
|
+
/** True iff `meta` is present (always required — ADR-039). */
|
|
43
|
+
hasMeta: boolean;
|
|
44
|
+
/** True iff the data/error invariants hold for the indicated success value. */
|
|
45
|
+
resultOrErrorValid: boolean;
|
|
46
|
+
/** Human-readable reasons the envelope failed validation (empty = valid). */
|
|
47
|
+
reasons: string[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validate a canonical CLI envelope shape and report violations.
|
|
51
|
+
*
|
|
52
|
+
* Validates the unified `{success, data?, error?, meta, page?}` shape
|
|
53
|
+
* defined in ADR-039. All three legacy shapes (`{ok,r,_m}`,
|
|
54
|
+
* `{$schema,_meta,success,result}`, `{success,result}`) are now invalid
|
|
55
|
+
* and will produce violation reports.
|
|
56
|
+
*
|
|
57
|
+
* @param envelope - The candidate envelope (serialized string or parsed object).
|
|
58
|
+
* @returns A `LafsShapeViolation` report. `.reasons.length === 0` when valid.
|
|
59
|
+
*/
|
|
60
|
+
export declare function validateLafsShape(envelope: unknown): LafsShapeViolation;
|
|
61
|
+
/**
|
|
62
|
+
* Assert that a LAFS envelope conforms to the shape contract, throwing
|
|
63
|
+
* an error with a LAFS-shaped diagnostic if it does not.
|
|
64
|
+
*
|
|
65
|
+
* Used by the renderer middleware to fail LOUDLY when CLEO itself emits
|
|
66
|
+
* a malformed envelope — this is a developer bug, not an operator issue.
|
|
67
|
+
*
|
|
68
|
+
* @param envelope - The candidate envelope
|
|
69
|
+
* @throws `LafsViolationError` if the envelope fails any shape invariant
|
|
70
|
+
*/
|
|
71
|
+
export declare function assertLafsShape(envelope: unknown): void;
|
|
72
|
+
/**
|
|
73
|
+
* Error thrown by `assertLafsShape` when an envelope fails validation.
|
|
74
|
+
*
|
|
75
|
+
* Carries the full `LafsShapeViolation` report so diagnostic tooling can
|
|
76
|
+
* report which specific invariants were violated.
|
|
77
|
+
*/
|
|
78
|
+
export declare class LafsViolationError extends Error {
|
|
79
|
+
readonly code = ExitCode.LAFS_VIOLATION;
|
|
80
|
+
readonly report: LafsShapeViolation;
|
|
81
|
+
constructor(message: string, report: LafsShapeViolation);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Emit a LAFS-shaped error envelope describing a validation failure and
|
|
85
|
+
* set `process.exitCode` to `ExitCode.LAFS_VIOLATION`.
|
|
86
|
+
*
|
|
87
|
+
* Called by the renderer middleware as a recovery path when a previously-
|
|
88
|
+
* emitted envelope turns out to be malformed.
|
|
89
|
+
*/
|
|
90
|
+
export declare function emitLafsViolation(err: LafsViolationError): void;
|
|
91
|
+
//# sourceMappingURL=lafs-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lafs-validator.d.ts","sourceRoot":"","sources":["../../../src/cli/renderers/lafs-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,QAAQ,EAAE,OAAO,CAAC;IAClB,qCAAqC;IACrC,eAAe,EAAE,OAAO,CAAC;IACzB,uCAAuC;IACvC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,8DAA8D;IAC9D,OAAO,EAAE,OAAO,CAAC;IACjB,+EAA+E;IAC/E,kBAAkB,EAAE,OAAO,CAAC;IAC5B,6EAA6E;IAC7E,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,kBAAkB,CAqFvE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAQvD;AAED;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,2BAA2B;IACxC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB;CAKxD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI,CAqB/D"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI envelope validator middleware (Phase 6 / ADR-039 update).
|
|
3
|
+
*
|
|
4
|
+
* Every CLI envelope emitted by `cliOutput()` flows through this module
|
|
5
|
+
* before hitting stdout. Validates the **canonical CLI envelope** shape
|
|
6
|
+
* (`{success, data?, error?, meta, page?}`) as defined in ADR-039.
|
|
7
|
+
*
|
|
8
|
+
* The canonical shape replaces the three legacy shapes:
|
|
9
|
+
* - `{ok, r, _m}` (minimal MVI — removed)
|
|
10
|
+
* - `{$schema, _meta, success, result}` (full LAFS — migrated)
|
|
11
|
+
* - `{success, result}` (observe command — migrated)
|
|
12
|
+
*
|
|
13
|
+
* Validation invariants:
|
|
14
|
+
* - Envelope MUST be a JSON object
|
|
15
|
+
* - `success` MUST be present and boolean
|
|
16
|
+
* - On success, `data` MUST exist (may be null)
|
|
17
|
+
* - On failure, `error` MUST exist with at least `code` and `message`
|
|
18
|
+
* - `meta` MUST be present (always — success and failure)
|
|
19
|
+
*
|
|
20
|
+
* When a violation is detected, the validator:
|
|
21
|
+
* 1. Wraps the malformed output in a valid error envelope
|
|
22
|
+
* 2. Sets the process exit code to `ExitCode.LAFS_VIOLATION` (104)
|
|
23
|
+
* 3. Emits the wrapped envelope to stderr for diagnostic tooling
|
|
24
|
+
*
|
|
25
|
+
* @task Phase 6 — LAFS formalization + schema consolidation
|
|
26
|
+
* @task T338 — ADR-039 canonical envelope unification
|
|
27
|
+
*/
|
|
28
|
+
import { ExitCode } from '@cleocode/contracts';
|
|
29
|
+
const ENVELOPE_SUCCESS_KEY = 'success';
|
|
30
|
+
const ENVELOPE_DATA_KEY = 'data';
|
|
31
|
+
const ENVELOPE_META_KEY = 'meta';
|
|
32
|
+
/**
|
|
33
|
+
* Validate a canonical CLI envelope shape and report violations.
|
|
34
|
+
*
|
|
35
|
+
* Validates the unified `{success, data?, error?, meta, page?}` shape
|
|
36
|
+
* defined in ADR-039. All three legacy shapes (`{ok,r,_m}`,
|
|
37
|
+
* `{$schema,_meta,success,result}`, `{success,result}`) are now invalid
|
|
38
|
+
* and will produce violation reports.
|
|
39
|
+
*
|
|
40
|
+
* @param envelope - The candidate envelope (serialized string or parsed object).
|
|
41
|
+
* @returns A `LafsShapeViolation` report. `.reasons.length === 0` when valid.
|
|
42
|
+
*/
|
|
43
|
+
export function validateLafsShape(envelope) {
|
|
44
|
+
const report = {
|
|
45
|
+
isObject: false,
|
|
46
|
+
hasSuccessField: false,
|
|
47
|
+
successIsBoolean: false,
|
|
48
|
+
hasMeta: false,
|
|
49
|
+
resultOrErrorValid: false,
|
|
50
|
+
reasons: [],
|
|
51
|
+
};
|
|
52
|
+
// Allow callers to pass either a serialized envelope or a parsed one
|
|
53
|
+
let parsed = envelope;
|
|
54
|
+
if (typeof envelope === 'string') {
|
|
55
|
+
try {
|
|
56
|
+
parsed = JSON.parse(envelope);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
report.reasons.push('Envelope is not valid JSON');
|
|
60
|
+
return report;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
64
|
+
report.reasons.push('Envelope is not a JSON object');
|
|
65
|
+
return report;
|
|
66
|
+
}
|
|
67
|
+
report.isObject = true;
|
|
68
|
+
const obj = parsed;
|
|
69
|
+
// Success-indicator field presence (`success`, not legacy `ok`)
|
|
70
|
+
if (!(ENVELOPE_SUCCESS_KEY in obj)) {
|
|
71
|
+
report.reasons.push(`Envelope missing success indicator — expected: "${ENVELOPE_SUCCESS_KEY}"`);
|
|
72
|
+
return report;
|
|
73
|
+
}
|
|
74
|
+
report.hasSuccessField = true;
|
|
75
|
+
const successValue = obj[ENVELOPE_SUCCESS_KEY];
|
|
76
|
+
if (typeof successValue !== 'boolean') {
|
|
77
|
+
report.reasons.push(`Envelope "${ENVELOPE_SUCCESS_KEY}" field must be boolean, got ${typeof successValue}`);
|
|
78
|
+
return report;
|
|
79
|
+
}
|
|
80
|
+
report.successIsBoolean = true;
|
|
81
|
+
// `meta` MUST be present and an object on every envelope (ADR-039)
|
|
82
|
+
report.hasMeta = ENVELOPE_META_KEY in obj && typeof obj[ENVELOPE_META_KEY] === 'object';
|
|
83
|
+
if (!report.hasMeta) {
|
|
84
|
+
report.reasons.push(`Envelope missing required "${ENVELOPE_META_KEY}" object (ADR-039 — every envelope must carry meta)`);
|
|
85
|
+
}
|
|
86
|
+
// Success / error invariants
|
|
87
|
+
if (successValue === true) {
|
|
88
|
+
// Successful envelopes carry `data` (not legacy `result` or `r`)
|
|
89
|
+
const hasData = ENVELOPE_DATA_KEY in obj;
|
|
90
|
+
if (!hasData) {
|
|
91
|
+
report.reasons.push(`Successful envelope missing "${ENVELOPE_DATA_KEY}" field (legacy "result" / "r" are no longer valid — ADR-039)`);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
report.resultOrErrorValid = true;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const errorField = obj['error'];
|
|
99
|
+
if (typeof errorField !== 'object' || errorField === null) {
|
|
100
|
+
report.reasons.push('Failed envelope missing "error" object');
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const err = errorField;
|
|
104
|
+
const hasCode = 'code' in err;
|
|
105
|
+
const hasMessage = 'message' in err && typeof err['message'] === 'string';
|
|
106
|
+
if (!hasCode || !hasMessage) {
|
|
107
|
+
report.reasons.push('Failed envelope "error" object must contain "code" and "message" (string)');
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
report.resultOrErrorValid = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return report;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Assert that a LAFS envelope conforms to the shape contract, throwing
|
|
118
|
+
* an error with a LAFS-shaped diagnostic if it does not.
|
|
119
|
+
*
|
|
120
|
+
* Used by the renderer middleware to fail LOUDLY when CLEO itself emits
|
|
121
|
+
* a malformed envelope — this is a developer bug, not an operator issue.
|
|
122
|
+
*
|
|
123
|
+
* @param envelope - The candidate envelope
|
|
124
|
+
* @throws `LafsViolationError` if the envelope fails any shape invariant
|
|
125
|
+
*/
|
|
126
|
+
export function assertLafsShape(envelope) {
|
|
127
|
+
const report = validateLafsShape(envelope);
|
|
128
|
+
if (report.reasons.length > 0) {
|
|
129
|
+
throw new LafsViolationError(`LAFS envelope shape violation: ${report.reasons.join('; ')}`, report);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Error thrown by `assertLafsShape` when an envelope fails validation.
|
|
134
|
+
*
|
|
135
|
+
* Carries the full `LafsShapeViolation` report so diagnostic tooling can
|
|
136
|
+
* report which specific invariants were violated.
|
|
137
|
+
*/
|
|
138
|
+
export class LafsViolationError extends Error {
|
|
139
|
+
code = ExitCode.LAFS_VIOLATION;
|
|
140
|
+
report;
|
|
141
|
+
constructor(message, report) {
|
|
142
|
+
super(message);
|
|
143
|
+
this.name = 'LafsViolationError';
|
|
144
|
+
this.report = report;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Emit a LAFS-shaped error envelope describing a validation failure and
|
|
149
|
+
* set `process.exitCode` to `ExitCode.LAFS_VIOLATION`.
|
|
150
|
+
*
|
|
151
|
+
* Called by the renderer middleware as a recovery path when a previously-
|
|
152
|
+
* emitted envelope turns out to be malformed.
|
|
153
|
+
*/
|
|
154
|
+
export function emitLafsViolation(err) {
|
|
155
|
+
// Emit canonical CLI envelope shape (ADR-039) even for violation errors
|
|
156
|
+
const envelope = {
|
|
157
|
+
success: false,
|
|
158
|
+
error: {
|
|
159
|
+
code: ExitCode.LAFS_VIOLATION,
|
|
160
|
+
codeName: 'E_LAFS_VIOLATION',
|
|
161
|
+
message: err.message,
|
|
162
|
+
details: {
|
|
163
|
+
report: err.report,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
meta: {
|
|
167
|
+
operation: 'cli.lafs-validator',
|
|
168
|
+
requestId: 'lafs-validator-emit',
|
|
169
|
+
duration_ms: 0,
|
|
170
|
+
timestamp: new Date().toISOString(),
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
process.stderr.write(`${JSON.stringify(envelope)}\n`);
|
|
174
|
+
process.exitCode = ExitCode.LAFS_VIOLATION;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=lafs-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lafs-validator.js","sourceRoot":"","sources":["../../../src/cli/renderers/lafs-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAuB/C,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAiB;IACjD,MAAM,MAAM,GAAuB;QACjC,QAAQ,EAAE,KAAK;QACf,eAAe,EAAE,KAAK;QACtB,gBAAgB,EAAE,KAAK;QACvB,OAAO,EAAE,KAAK;QACd,kBAAkB,EAAE,KAAK;QACzB,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,qEAAqE;IACrE,IAAI,MAAM,GAAY,QAAQ,CAAC;IAC/B,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3E,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QACrD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MA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;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAuB;IACvD,wEAAwE;IACxE,MAAM,QAAQ,GAAG;QACf,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ,CAAC,cAAc;YAC7B,QAAQ,EAAE,kBAAkB;YAC5B,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,OAAO,EAAE;gBACP,MAAM,EAAE,GAAG,CAAC,MAAM;aACnB;SACF;QACD,IAAI,EAAE;YACJ,SAAS,EAAE,oBAAoB;YAC/B,SAAS,EAAE,qBAAqB;YAChC,WAAW,EAAE,CAAC;YACd,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC;KACF,CAAC;IACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACtD,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Rendering Normalizer — safety net for human-readable output.
|
|
3
|
+
*
|
|
4
|
+
* Ensures data passed to human renderers has the expected shape,
|
|
5
|
+
* regardless of whether the engine layer has been fully fixed.
|
|
6
|
+
* Only called for human format — JSON output is untouched.
|
|
7
|
+
*
|
|
8
|
+
* Detection is idempotent: if data already has the expected key,
|
|
9
|
+
* it passes through unchanged.
|
|
10
|
+
*
|
|
11
|
+
* @task T4813
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Normalize data shape for human renderers.
|
|
15
|
+
*
|
|
16
|
+
* Each command expects data with specific named keys (e.g., `data.task`
|
|
17
|
+
* for 'show', `data.tasks` for 'list'). This function detects and
|
|
18
|
+
* corrects flat/array data from the engine layer.
|
|
19
|
+
*/
|
|
20
|
+
export declare function normalizeForHuman(command: string, data: Record<string, unknown>): Record<string, unknown>;
|
|
21
|
+
//# sourceMappingURL=normalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../../src/cli/renderers/normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiCzB"}
|