@ag-eco/agentplate-cli 0.13.0
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/LICENSE +21 -0
- package/README.md +462 -0
- package/agents/ap-co-creation.md +90 -0
- package/agents/builder.md +144 -0
- package/agents/coordinator.md +377 -0
- package/agents/lead.md +435 -0
- package/agents/merger.md +164 -0
- package/agents/monitor.md +214 -0
- package/agents/orchestrator.md +239 -0
- package/agents/reviewer.md +140 -0
- package/agents/scout.md +125 -0
- package/agents/supervisor.md +427 -0
- package/package.json +66 -0
- package/src/agents/capabilities.test.ts +85 -0
- package/src/agents/capabilities.ts +125 -0
- package/src/agents/checkpoint.test.ts +88 -0
- package/src/agents/checkpoint.ts +101 -0
- package/src/agents/copilot-hooks-deployer.test.ts +162 -0
- package/src/agents/copilot-hooks-deployer.ts +93 -0
- package/src/agents/guard-rules.test.ts +372 -0
- package/src/agents/guard-rules.ts +97 -0
- package/src/agents/headless-mail-injector.test.ts +709 -0
- package/src/agents/headless-mail-injector.ts +377 -0
- package/src/agents/headless-prompt.test.ts +102 -0
- package/src/agents/headless-prompt.ts +68 -0
- package/src/agents/hooks-deployer.test.ts +3119 -0
- package/src/agents/hooks-deployer.ts +804 -0
- package/src/agents/identity.test.ts +604 -0
- package/src/agents/identity.ts +384 -0
- package/src/agents/lifecycle.test.ts +196 -0
- package/src/agents/lifecycle.ts +183 -0
- package/src/agents/mail-poll-detect.test.ts +153 -0
- package/src/agents/mail-poll-detect.ts +73 -0
- package/src/agents/manifest.test.ts +1026 -0
- package/src/agents/manifest.ts +376 -0
- package/src/agents/overlay.test.ts +1058 -0
- package/src/agents/overlay.ts +490 -0
- package/src/agents/scope-detect.test.ts +190 -0
- package/src/agents/scope-detect.ts +146 -0
- package/src/agents/turn-lock.test.ts +181 -0
- package/src/agents/turn-lock.ts +235 -0
- package/src/agents/turn-runner-dispatch.test.ts +182 -0
- package/src/agents/turn-runner-dispatch.ts +105 -0
- package/src/agents/turn-runner.test.ts +2312 -0
- package/src/agents/turn-runner.ts +1383 -0
- package/src/beads/client.test.ts +217 -0
- package/src/beads/client.ts +230 -0
- package/src/beads/molecules.test.ts +338 -0
- package/src/beads/molecules.ts +198 -0
- package/src/commands/agents.test.ts +328 -0
- package/src/commands/agents.ts +299 -0
- package/src/commands/clean.test.ts +797 -0
- package/src/commands/clean.ts +791 -0
- package/src/commands/completions.test.ts +348 -0
- package/src/commands/completions.ts +981 -0
- package/src/commands/coordinator.test.ts +2975 -0
- package/src/commands/coordinator.ts +1841 -0
- package/src/commands/costs.test.ts +1183 -0
- package/src/commands/costs.ts +599 -0
- package/src/commands/dashboard.test.ts +954 -0
- package/src/commands/dashboard.ts +1212 -0
- package/src/commands/discover.test.ts +288 -0
- package/src/commands/discover.ts +202 -0
- package/src/commands/doctor.test.ts +303 -0
- package/src/commands/doctor.ts +311 -0
- package/src/commands/ecosystem.test.ts +226 -0
- package/src/commands/ecosystem.ts +248 -0
- package/src/commands/errors.test.ts +654 -0
- package/src/commands/errors.ts +197 -0
- package/src/commands/feed.test.ts +709 -0
- package/src/commands/feed.ts +260 -0
- package/src/commands/group.test.ts +475 -0
- package/src/commands/group.ts +546 -0
- package/src/commands/hooks.test.ts +458 -0
- package/src/commands/hooks.ts +263 -0
- package/src/commands/init.test.ts +1011 -0
- package/src/commands/init.ts +967 -0
- package/src/commands/inspect.test.ts +1239 -0
- package/src/commands/inspect.ts +648 -0
- package/src/commands/log.test.ts +1913 -0
- package/src/commands/log.ts +958 -0
- package/src/commands/logs.test.ts +801 -0
- package/src/commands/logs.ts +483 -0
- package/src/commands/mail.test.ts +1501 -0
- package/src/commands/mail.ts +848 -0
- package/src/commands/merge.test.ts +864 -0
- package/src/commands/merge.ts +381 -0
- package/src/commands/metrics.test.ts +458 -0
- package/src/commands/metrics.ts +129 -0
- package/src/commands/monitor.test.ts +191 -0
- package/src/commands/monitor.ts +409 -0
- package/src/commands/nudge.test.ts +579 -0
- package/src/commands/nudge.ts +646 -0
- package/src/commands/orchestrator.ts +42 -0
- package/src/commands/prime.test.ts +612 -0
- package/src/commands/prime.ts +359 -0
- package/src/commands/replay.test.ts +757 -0
- package/src/commands/replay.ts +231 -0
- package/src/commands/run.test.ts +469 -0
- package/src/commands/run.ts +353 -0
- package/src/commands/serve/agent-actions.test.ts +210 -0
- package/src/commands/serve/agent-actions.ts +192 -0
- package/src/commands/serve/build.test.ts +202 -0
- package/src/commands/serve/build.ts +206 -0
- package/src/commands/serve/coordinator-actions.test.ts +339 -0
- package/src/commands/serve/coordinator-actions.ts +410 -0
- package/src/commands/serve/dev.test.ts +168 -0
- package/src/commands/serve/dev.ts +117 -0
- package/src/commands/serve/mail-actions.test.ts +312 -0
- package/src/commands/serve/mail-actions.ts +167 -0
- package/src/commands/serve/rest.test.ts +1680 -0
- package/src/commands/serve/rest.ts +1130 -0
- package/src/commands/serve/static.ts +51 -0
- package/src/commands/serve/ws.test.ts +361 -0
- package/src/commands/serve/ws.ts +332 -0
- package/src/commands/serve.test.ts +459 -0
- package/src/commands/serve.ts +654 -0
- package/src/commands/sling.test.ts +1583 -0
- package/src/commands/sling.ts +1351 -0
- package/src/commands/spec.test.ts +179 -0
- package/src/commands/spec.ts +105 -0
- package/src/commands/status.test.ts +614 -0
- package/src/commands/status.ts +403 -0
- package/src/commands/stop.test.ts +964 -0
- package/src/commands/stop.ts +319 -0
- package/src/commands/supervisor.test.ts +185 -0
- package/src/commands/supervisor.ts +537 -0
- package/src/commands/trace.test.ts +762 -0
- package/src/commands/trace.ts +205 -0
- package/src/commands/update.test.ts +466 -0
- package/src/commands/update.ts +263 -0
- package/src/commands/upgrade.test.ts +48 -0
- package/src/commands/upgrade.ts +240 -0
- package/src/commands/watch.test.ts +257 -0
- package/src/commands/watch.ts +308 -0
- package/src/commands/worktree.test.ts +1297 -0
- package/src/commands/worktree.ts +451 -0
- package/src/config.test.ts +1535 -0
- package/src/config.ts +1064 -0
- package/src/doctor/agents.test.ts +523 -0
- package/src/doctor/agents.ts +399 -0
- package/src/doctor/config-check.test.ts +191 -0
- package/src/doctor/config-check.ts +183 -0
- package/src/doctor/consistency.test.ts +807 -0
- package/src/doctor/consistency.ts +347 -0
- package/src/doctor/databases.test.ts +350 -0
- package/src/doctor/databases.ts +243 -0
- package/src/doctor/dependencies.test.ts +296 -0
- package/src/doctor/dependencies.ts +272 -0
- package/src/doctor/ecosystem.test.ts +308 -0
- package/src/doctor/ecosystem.ts +156 -0
- package/src/doctor/logs.test.ts +253 -0
- package/src/doctor/logs.ts +295 -0
- package/src/doctor/merge-queue.test.ts +315 -0
- package/src/doctor/merge-queue.ts +167 -0
- package/src/doctor/providers.test.ts +409 -0
- package/src/doctor/providers.ts +250 -0
- package/src/doctor/serve.test.ts +95 -0
- package/src/doctor/serve.ts +86 -0
- package/src/doctor/structure.test.ts +423 -0
- package/src/doctor/structure.ts +285 -0
- package/src/doctor/types.ts +43 -0
- package/src/doctor/version.test.ts +241 -0
- package/src/doctor/version.ts +132 -0
- package/src/doctor/watchdog.test.ts +167 -0
- package/src/doctor/watchdog.ts +214 -0
- package/src/e2e/init-sling-lifecycle.test.ts +283 -0
- package/src/errors.test.ts +350 -0
- package/src/errors.ts +217 -0
- package/src/events/store.test.ts +660 -0
- package/src/events/store.ts +369 -0
- package/src/events/tailer.test.ts +719 -0
- package/src/events/tailer.ts +332 -0
- package/src/events/tool-filter.test.ts +330 -0
- package/src/events/tool-filter.ts +126 -0
- package/src/index.ts +533 -0
- package/src/insights/analyzer.test.ts +466 -0
- package/src/insights/analyzer.ts +203 -0
- package/src/insights/quality-gates.test.ts +141 -0
- package/src/insights/quality-gates.ts +156 -0
- package/src/json.test.ts +72 -0
- package/src/json.ts +53 -0
- package/src/loam/client.test.ts +752 -0
- package/src/loam/client.ts +664 -0
- package/src/logging/color.test.ts +252 -0
- package/src/logging/color.ts +105 -0
- package/src/logging/format.test.ts +110 -0
- package/src/logging/format.ts +255 -0
- package/src/logging/logger.test.ts +814 -0
- package/src/logging/logger.ts +266 -0
- package/src/logging/reporter.test.ts +259 -0
- package/src/logging/reporter.ts +110 -0
- package/src/logging/sanitizer.test.ts +190 -0
- package/src/logging/sanitizer.ts +57 -0
- package/src/logging/theme.ts +140 -0
- package/src/mail/broadcast.test.ts +204 -0
- package/src/mail/broadcast.ts +92 -0
- package/src/mail/client.test.ts +774 -0
- package/src/mail/client.ts +236 -0
- package/src/mail/store.test.ts +898 -0
- package/src/mail/store.ts +425 -0
- package/src/merge/lock.test.ts +149 -0
- package/src/merge/lock.ts +140 -0
- package/src/merge/predict.test.ts +387 -0
- package/src/merge/predict.ts +249 -0
- package/src/merge/queue.test.ts +426 -0
- package/src/merge/queue.ts +246 -0
- package/src/merge/resolver.test.ts +1993 -0
- package/src/merge/resolver.ts +926 -0
- package/src/metrics/pricing.test.ts +258 -0
- package/src/metrics/pricing.ts +135 -0
- package/src/metrics/store.test.ts +978 -0
- package/src/metrics/store.ts +501 -0
- package/src/metrics/summary.test.ts +398 -0
- package/src/metrics/summary.ts +178 -0
- package/src/metrics/transcript.test.ts +483 -0
- package/src/metrics/transcript.ts +114 -0
- package/src/runtimes/__fixtures__/claude-stream-fixture.ts +22 -0
- package/src/runtimes/aider.test.ts +124 -0
- package/src/runtimes/aider.ts +147 -0
- package/src/runtimes/amp.test.ts +164 -0
- package/src/runtimes/amp.ts +154 -0
- package/src/runtimes/claude.test.ts +1474 -0
- package/src/runtimes/claude.ts +579 -0
- package/src/runtimes/codex.test.ts +805 -0
- package/src/runtimes/codex.ts +273 -0
- package/src/runtimes/connections.test.ts +214 -0
- package/src/runtimes/connections.ts +103 -0
- package/src/runtimes/copilot.test.ts +707 -0
- package/src/runtimes/copilot.ts +316 -0
- package/src/runtimes/cursor.test.ts +497 -0
- package/src/runtimes/cursor.ts +205 -0
- package/src/runtimes/gemini.test.ts +537 -0
- package/src/runtimes/gemini.ts +243 -0
- package/src/runtimes/goose.test.ts +133 -0
- package/src/runtimes/goose.ts +157 -0
- package/src/runtimes/headless-connection.test.ts +264 -0
- package/src/runtimes/headless-connection.ts +158 -0
- package/src/runtimes/opencode.test.ts +325 -0
- package/src/runtimes/opencode.ts +188 -0
- package/src/runtimes/pi-guards.test.ts +486 -0
- package/src/runtimes/pi-guards.ts +367 -0
- package/src/runtimes/pi.test.ts +789 -0
- package/src/runtimes/pi.ts +305 -0
- package/src/runtimes/registry.test.ts +196 -0
- package/src/runtimes/registry.ts +99 -0
- package/src/runtimes/sapling.test.ts +1267 -0
- package/src/runtimes/sapling.ts +710 -0
- package/src/runtimes/types.ts +266 -0
- package/src/schema-consistency.test.ts +246 -0
- package/src/sessions/compat.test.ts +281 -0
- package/src/sessions/compat.ts +105 -0
- package/src/sessions/store.test.ts +1748 -0
- package/src/sessions/store.ts +858 -0
- package/src/test-helpers.test.ts +124 -0
- package/src/test-helpers.ts +145 -0
- package/src/test-setup.test.ts +31 -0
- package/src/test-setup.ts +28 -0
- package/src/tools/loam/api.ts +368 -0
- package/src/tools/loam/cli.ts +278 -0
- package/src/tools/loam/commands/add.ts +52 -0
- package/src/tools/loam/commands/archive.ts +214 -0
- package/src/tools/loam/commands/audit.ts +276 -0
- package/src/tools/loam/commands/compact.ts +1062 -0
- package/src/tools/loam/commands/completions.ts +79 -0
- package/src/tools/loam/commands/config.ts +381 -0
- package/src/tools/loam/commands/delete-domain.ts +121 -0
- package/src/tools/loam/commands/delete.ts +316 -0
- package/src/tools/loam/commands/diff.ts +200 -0
- package/src/tools/loam/commands/doctor.ts +1113 -0
- package/src/tools/loam/commands/edit.ts +226 -0
- package/src/tools/loam/commands/init.ts +31 -0
- package/src/tools/loam/commands/learn.ts +179 -0
- package/src/tools/loam/commands/move.ts +323 -0
- package/src/tools/loam/commands/onboard.ts +374 -0
- package/src/tools/loam/commands/outcome.ts +185 -0
- package/src/tools/loam/commands/prime.ts +688 -0
- package/src/tools/loam/commands/prune.ts +614 -0
- package/src/tools/loam/commands/query.ts +218 -0
- package/src/tools/loam/commands/rank.ts +180 -0
- package/src/tools/loam/commands/ready.ts +189 -0
- package/src/tools/loam/commands/record.ts +1210 -0
- package/src/tools/loam/commands/restore.ts +166 -0
- package/src/tools/loam/commands/search.ts +327 -0
- package/src/tools/loam/commands/setup.ts +887 -0
- package/src/tools/loam/commands/status.ts +103 -0
- package/src/tools/loam/commands/sync.ts +298 -0
- package/src/tools/loam/commands/update.ts +19 -0
- package/src/tools/loam/commands/upgrade.ts +93 -0
- package/src/tools/loam/commands/validate.ts +190 -0
- package/src/tools/loam/index.ts +62 -0
- package/src/tools/loam/log.ts +127 -0
- package/src/tools/loam/registry/builtins.ts +409 -0
- package/src/tools/loam/registry/custom.ts +431 -0
- package/src/tools/loam/registry/init.ts +55 -0
- package/src/tools/loam/registry/template.ts +40 -0
- package/src/tools/loam/registry/type-registry.ts +113 -0
- package/src/tools/loam/schemas/config-schema.ts +489 -0
- package/src/tools/loam/schemas/config.ts +245 -0
- package/src/tools/loam/schemas/index.ts +18 -0
- package/src/tools/loam/schemas/record-schema.ts +191 -0
- package/src/tools/loam/schemas/record.ts +115 -0
- package/src/tools/loam/utils/active-work.ts +205 -0
- package/src/tools/loam/utils/anchor-validity.ts +80 -0
- package/src/tools/loam/utils/archive.ts +146 -0
- package/src/tools/loam/utils/audit.ts +667 -0
- package/src/tools/loam/utils/bm25.ts +238 -0
- package/src/tools/loam/utils/budget.ts +142 -0
- package/src/tools/loam/utils/config.ts +344 -0
- package/src/tools/loam/utils/dir-anchors.ts +62 -0
- package/src/tools/loam/utils/domain-rules.ts +114 -0
- package/src/tools/loam/utils/expertise.ts +393 -0
- package/src/tools/loam/utils/format-helpers.ts +96 -0
- package/src/tools/loam/utils/format.ts +1234 -0
- package/src/tools/loam/utils/git-context.ts +50 -0
- package/src/tools/loam/utils/git.ts +183 -0
- package/src/tools/loam/utils/hooks.ts +299 -0
- package/src/tools/loam/utils/index.ts +52 -0
- package/src/tools/loam/utils/json-output.ts +13 -0
- package/src/tools/loam/utils/lock.ts +76 -0
- package/src/tools/loam/utils/markers.ts +48 -0
- package/src/tools/loam/utils/numeric-flags.ts +20 -0
- package/src/tools/loam/utils/palette.ts +44 -0
- package/src/tools/loam/utils/prime-ranking.ts +135 -0
- package/src/tools/loam/utils/recipe-discovery.ts +195 -0
- package/src/tools/loam/utils/runtime-flags.ts +28 -0
- package/src/tools/loam/utils/scoring.ts +94 -0
- package/src/tools/loam/utils/version.ts +116 -0
- package/src/tools/sprout/commands/block.ts +64 -0
- package/src/tools/sprout/commands/blocked.ts +86 -0
- package/src/tools/sprout/commands/close.ts +129 -0
- package/src/tools/sprout/commands/completions.ts +198 -0
- package/src/tools/sprout/commands/config.ts +238 -0
- package/src/tools/sprout/commands/create.ts +164 -0
- package/src/tools/sprout/commands/dep.ts +148 -0
- package/src/tools/sprout/commands/doctor.ts +979 -0
- package/src/tools/sprout/commands/init.ts +83 -0
- package/src/tools/sprout/commands/label.ts +178 -0
- package/src/tools/sprout/commands/list.ts +210 -0
- package/src/tools/sprout/commands/migrate.ts +133 -0
- package/src/tools/sprout/commands/onboard.ts +207 -0
- package/src/tools/sprout/commands/plan-show.ts +278 -0
- package/src/tools/sprout/commands/plan.ts +2526 -0
- package/src/tools/sprout/commands/prime.ts +399 -0
- package/src/tools/sprout/commands/ready.ts +245 -0
- package/src/tools/sprout/commands/search.ts +221 -0
- package/src/tools/sprout/commands/show.ts +277 -0
- package/src/tools/sprout/commands/stats.ts +146 -0
- package/src/tools/sprout/commands/sync.ts +134 -0
- package/src/tools/sprout/commands/tpl.ts +364 -0
- package/src/tools/sprout/commands/unblock.ts +115 -0
- package/src/tools/sprout/commands/update.ts +257 -0
- package/src/tools/sprout/commands/upgrade.ts +91 -0
- package/src/tools/sprout/config-schema.ts +152 -0
- package/src/tools/sprout/config.ts +355 -0
- package/src/tools/sprout/filter.ts +107 -0
- package/src/tools/sprout/format.ts +43 -0
- package/src/tools/sprout/id.ts +22 -0
- package/src/tools/sprout/index.ts +204 -0
- package/src/tools/sprout/log.ts +76 -0
- package/src/tools/sprout/markers.ts +22 -0
- package/src/tools/sprout/output.ts +121 -0
- package/src/tools/sprout/plan-backref.ts +93 -0
- package/src/tools/sprout/plan-context.ts +81 -0
- package/src/tools/sprout/plan-domain.ts +139 -0
- package/src/tools/sprout/plan-lifecycle.ts +65 -0
- package/src/tools/sprout/plan-loam.ts +207 -0
- package/src/tools/sprout/plan-schema.ts +209 -0
- package/src/tools/sprout/sort.ts +31 -0
- package/src/tools/sprout/store.ts +172 -0
- package/src/tools/sprout/types.ts +118 -0
- package/src/tools/sprout/validation.ts +119 -0
- package/src/tools/sprout/version.ts +1 -0
- package/src/tools/sprout/yaml.ts +387 -0
- package/src/tools/trellis/commands/archive.ts +87 -0
- package/src/tools/trellis/commands/completions.ts +610 -0
- package/src/tools/trellis/commands/config.ts +382 -0
- package/src/tools/trellis/commands/create.ts +252 -0
- package/src/tools/trellis/commands/diff.ts +150 -0
- package/src/tools/trellis/commands/doctor.ts +771 -0
- package/src/tools/trellis/commands/emit.ts +365 -0
- package/src/tools/trellis/commands/history.ts +83 -0
- package/src/tools/trellis/commands/import.ts +198 -0
- package/src/tools/trellis/commands/init.ts +81 -0
- package/src/tools/trellis/commands/list.ts +103 -0
- package/src/tools/trellis/commands/onboard.ts +156 -0
- package/src/tools/trellis/commands/pin.ts +172 -0
- package/src/tools/trellis/commands/prime.ts +193 -0
- package/src/tools/trellis/commands/render.ts +122 -0
- package/src/tools/trellis/commands/schema.ts +353 -0
- package/src/tools/trellis/commands/show.ts +115 -0
- package/src/tools/trellis/commands/stats.ts +65 -0
- package/src/tools/trellis/commands/sync.ts +112 -0
- package/src/tools/trellis/commands/tree.ts +123 -0
- package/src/tools/trellis/commands/update.ts +330 -0
- package/src/tools/trellis/commands/upgrade.ts +95 -0
- package/src/tools/trellis/commands/validate.ts +166 -0
- package/src/tools/trellis/config-schema.ts +81 -0
- package/src/tools/trellis/config.ts +108 -0
- package/src/tools/trellis/frontmatter.ts +348 -0
- package/src/tools/trellis/id.ts +24 -0
- package/src/tools/trellis/index.ts +209 -0
- package/src/tools/trellis/markers.ts +28 -0
- package/src/tools/trellis/output.ts +84 -0
- package/src/tools/trellis/render.ts +212 -0
- package/src/tools/trellis/store.ts +144 -0
- package/src/tools/trellis/types.ts +82 -0
- package/src/tools/trellis/validate.ts +199 -0
- package/src/tools/trellis/yaml.ts +309 -0
- package/src/tracker/beads.test.ts +454 -0
- package/src/tracker/beads.ts +56 -0
- package/src/tracker/factory.test.ts +90 -0
- package/src/tracker/factory.ts +65 -0
- package/src/tracker/sprout.test.ts +461 -0
- package/src/tracker/sprout.ts +182 -0
- package/src/tracker/types.ts +52 -0
- package/src/trellis/client.test.ts +107 -0
- package/src/trellis/client.ts +179 -0
- package/src/types.ts +970 -0
- package/src/utils/bin.test.ts +10 -0
- package/src/utils/bin.ts +37 -0
- package/src/utils/browser.test.ts +49 -0
- package/src/utils/browser.ts +48 -0
- package/src/utils/fs.test.ts +119 -0
- package/src/utils/fs.ts +62 -0
- package/src/utils/pid.test.ts +152 -0
- package/src/utils/pid.ts +130 -0
- package/src/utils/process-scan.test.ts +53 -0
- package/src/utils/process-scan.ts +76 -0
- package/src/utils/time.test.ts +43 -0
- package/src/utils/time.ts +37 -0
- package/src/utils/version.test.ts +33 -0
- package/src/utils/version.ts +70 -0
- package/src/version.ts +5 -0
- package/src/watchdog/daemon.test.ts +3721 -0
- package/src/watchdog/daemon.ts +1257 -0
- package/src/watchdog/health.test.ts +830 -0
- package/src/watchdog/health.ts +434 -0
- package/src/watchdog/triage.test.ts +205 -0
- package/src/watchdog/triage.ts +205 -0
- package/src/worktree/manager.test.ts +720 -0
- package/src/worktree/manager.ts +405 -0
- package/src/worktree/process.test.ts +172 -0
- package/src/worktree/process.ts +131 -0
- package/src/worktree/tmux.test.ts +1616 -0
- package/src/worktree/tmux.ts +721 -0
- package/templates/CLAUDE.md.tmpl +100 -0
- package/templates/copilot-hooks.json.tmpl +13 -0
- package/templates/hooks.json.tmpl +109 -0
- package/templates/overlay.md.tmpl +88 -0
- package/ui/dist/apple-touch-icon-bdy6teep.png +0 -0
- package/ui/dist/chunk-8s31f05k.css +1 -0
- package/ui/dist/chunk-vm5rz679.js +300 -0
- package/ui/dist/favicon-nzb39vza.svg +4 -0
- package/ui/dist/index.html +17 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { findSproutDir } from "../config.ts";
|
|
3
|
+
import { applyIssueFilters, filterOptionsFromFlags, parseLimitFlag } from "../filter.ts";
|
|
4
|
+
import { resolveFormat, stripAnsi, VALID_FORMATS } from "../format.ts";
|
|
5
|
+
import {
|
|
6
|
+
formatIssueOneLine,
|
|
7
|
+
formatIssueOneLineCompact,
|
|
8
|
+
outputJson,
|
|
9
|
+
printIssueOneLine,
|
|
10
|
+
} from "../output.ts";
|
|
11
|
+
import { issueJsonWithPlan, loadPlanContext, planForIssue } from "../plan-context.ts";
|
|
12
|
+
import { isSortMode, sortIssues, VALID_SORT_MODES } from "../sort.ts";
|
|
13
|
+
import { readIssues } from "../store.ts";
|
|
14
|
+
import type { Issue } from "../types.ts";
|
|
15
|
+
|
|
16
|
+
function parseArgs(args: string[]): {
|
|
17
|
+
flags: Record<string, string | boolean>;
|
|
18
|
+
positionals: string[];
|
|
19
|
+
} {
|
|
20
|
+
const flags: Record<string, string | boolean> = {};
|
|
21
|
+
const positionals: string[] = [];
|
|
22
|
+
let i = 0;
|
|
23
|
+
while (i < args.length) {
|
|
24
|
+
const arg = args[i];
|
|
25
|
+
if (!arg) {
|
|
26
|
+
i++;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (arg.startsWith("--")) {
|
|
30
|
+
const key = arg.slice(2);
|
|
31
|
+
const eqIdx = key.indexOf("=");
|
|
32
|
+
if (eqIdx !== -1) {
|
|
33
|
+
flags[key.slice(0, eqIdx)] = key.slice(eqIdx + 1);
|
|
34
|
+
i++;
|
|
35
|
+
} else {
|
|
36
|
+
const next = args[i + 1];
|
|
37
|
+
if (next !== undefined && !next.startsWith("--")) {
|
|
38
|
+
flags[key] = next;
|
|
39
|
+
i += 2;
|
|
40
|
+
} else {
|
|
41
|
+
flags[key] = true;
|
|
42
|
+
i++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
positionals.push(arg);
|
|
47
|
+
i++;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { flags, positionals };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function matchesQuery(issue: Issue, needle: string): boolean {
|
|
54
|
+
const title = issue.title.toLowerCase();
|
|
55
|
+
if (title.includes(needle)) return true;
|
|
56
|
+
const desc = issue.description?.toLowerCase() ?? "";
|
|
57
|
+
return desc.includes(needle);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function run(args: string[], sproutDir?: string): Promise<void> {
|
|
61
|
+
const fmt = resolveFormat(args);
|
|
62
|
+
const jsonMode = fmt.mode === "json";
|
|
63
|
+
if (fmt.error) {
|
|
64
|
+
if (jsonMode) {
|
|
65
|
+
await outputJson({ success: false, command: "search", error: fmt.error });
|
|
66
|
+
} else {
|
|
67
|
+
console.error(fmt.error);
|
|
68
|
+
}
|
|
69
|
+
process.exitCode = 1;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const { flags, positionals } = parseArgs(args);
|
|
73
|
+
|
|
74
|
+
const query = positionals[0];
|
|
75
|
+
if (!query) {
|
|
76
|
+
const msg = "Usage: sr search <query> [filters]";
|
|
77
|
+
if (jsonMode) {
|
|
78
|
+
await outputJson({ success: false, command: "search", error: msg });
|
|
79
|
+
} else {
|
|
80
|
+
console.error(msg);
|
|
81
|
+
}
|
|
82
|
+
process.exitCode = 1;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const needle = query.toLowerCase();
|
|
86
|
+
|
|
87
|
+
const statusFilter = typeof flags.status === "string" ? flags.status : undefined;
|
|
88
|
+
let limit: number;
|
|
89
|
+
try {
|
|
90
|
+
limit = parseLimitFlag(flags.limit);
|
|
91
|
+
} catch (e) {
|
|
92
|
+
const msg = (e as Error).message;
|
|
93
|
+
if (jsonMode) {
|
|
94
|
+
await outputJson({ success: false, command: "search", error: msg });
|
|
95
|
+
} else {
|
|
96
|
+
console.error(msg);
|
|
97
|
+
}
|
|
98
|
+
process.exitCode = 1;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const dir = sproutDir ?? (await findSproutDir());
|
|
103
|
+
const allIssues = await readIssues(dir);
|
|
104
|
+
const closedBlockerIds = new Set(
|
|
105
|
+
allIssues.filter((i: Issue) => i.status === "closed").map((i) => i.id),
|
|
106
|
+
);
|
|
107
|
+
let issues = allIssues;
|
|
108
|
+
const planCtx = await loadPlanContext(dir);
|
|
109
|
+
|
|
110
|
+
if (statusFilter) {
|
|
111
|
+
issues = issues.filter((i: Issue) => i.status === statusFilter);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
issues = issues.filter((i) => matchesQuery(i, needle));
|
|
115
|
+
issues = applyIssueFilters(issues, filterOptionsFromFlags(flags));
|
|
116
|
+
|
|
117
|
+
const sortFlag = typeof flags.sort === "string" ? flags.sort : "priority";
|
|
118
|
+
if (!isSortMode(sortFlag)) {
|
|
119
|
+
const msg = `Invalid --sort value: ${sortFlag}. Valid: ${VALID_SORT_MODES.join("|")}`;
|
|
120
|
+
if (jsonMode) {
|
|
121
|
+
await outputJson({ success: false, command: "search", error: msg });
|
|
122
|
+
} else {
|
|
123
|
+
console.error(msg);
|
|
124
|
+
}
|
|
125
|
+
process.exitCode = 1;
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
issues = sortIssues(issues, sortFlag);
|
|
129
|
+
|
|
130
|
+
issues = issues.slice(0, limit);
|
|
131
|
+
|
|
132
|
+
switch (fmt.mode) {
|
|
133
|
+
case "json": {
|
|
134
|
+
const issuesWithPlan = issues.map((i) => issueJsonWithPlan(i, planForIssue(planCtx, i)));
|
|
135
|
+
await outputJson({
|
|
136
|
+
success: true,
|
|
137
|
+
command: "search",
|
|
138
|
+
query,
|
|
139
|
+
issues: issuesWithPlan,
|
|
140
|
+
count: issues.length,
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
case "ids":
|
|
145
|
+
for (const issue of issues) console.log(issue.id);
|
|
146
|
+
return;
|
|
147
|
+
case "compact":
|
|
148
|
+
for (const issue of issues) console.log(formatIssueOneLineCompact(issue, closedBlockerIds));
|
|
149
|
+
return;
|
|
150
|
+
case "plain":
|
|
151
|
+
if (issues.length === 0) {
|
|
152
|
+
console.log(`No issues match "${query}".`);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
for (const issue of issues)
|
|
156
|
+
console.log(stripAnsi(formatIssueOneLine(issue, closedBlockerIds)));
|
|
157
|
+
console.log(`\n${issues.length} match(es)`);
|
|
158
|
+
return;
|
|
159
|
+
default:
|
|
160
|
+
if (issues.length === 0) {
|
|
161
|
+
console.log(`No issues match "${query}".`);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
for (const issue of issues) printIssueOneLine(issue, closedBlockerIds);
|
|
165
|
+
console.log(`\n${issues.length} match(es)`);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function register(program: Command): void {
|
|
171
|
+
program
|
|
172
|
+
.command("search")
|
|
173
|
+
.description("Full-text search title + description")
|
|
174
|
+
.argument("<query>", "Case-insensitive substring to match")
|
|
175
|
+
.option("--status <status>", "Filter by status (open|in_progress|closed)")
|
|
176
|
+
.option("--type <type>", "Filter by type (task|bug|feature|epic)")
|
|
177
|
+
.option("--assignee <name>", "Filter by assignee")
|
|
178
|
+
.option("--label <labels>", "Filter: must have ALL labels (comma-separated, AND)")
|
|
179
|
+
.option("--label-any <labels>", "Filter: must have any label (comma-separated, OR)")
|
|
180
|
+
.option("--unlabeled", "Filter: issues with no labels")
|
|
181
|
+
.option("--priority <levels>", "Filter by priority (comma-separated, e.g. 0,1 or P0,P1)")
|
|
182
|
+
.option("--priority-max <n>", "Filter to priority <= n (e.g. --priority-max 1 = P0+P1)")
|
|
183
|
+
.option("--limit <n>", "Max issues to show", "50")
|
|
184
|
+
.option("--sort <mode>", "Sort order (priority|created|updated|id)", "priority")
|
|
185
|
+
.option("--format <mode>", `Output format (${VALID_FORMATS.join("|")})`)
|
|
186
|
+
.option("--json", "Output as JSON (alias for --format json)")
|
|
187
|
+
.action(
|
|
188
|
+
async (
|
|
189
|
+
query: string,
|
|
190
|
+
opts: {
|
|
191
|
+
status?: string;
|
|
192
|
+
type?: string;
|
|
193
|
+
assignee?: string;
|
|
194
|
+
label?: string;
|
|
195
|
+
labelAny?: string;
|
|
196
|
+
unlabeled?: boolean;
|
|
197
|
+
priority?: string;
|
|
198
|
+
priorityMax?: string;
|
|
199
|
+
limit?: string;
|
|
200
|
+
sort?: string;
|
|
201
|
+
format?: string;
|
|
202
|
+
json?: boolean;
|
|
203
|
+
},
|
|
204
|
+
) => {
|
|
205
|
+
const args: string[] = [query];
|
|
206
|
+
if (opts.status) args.push("--status", opts.status);
|
|
207
|
+
if (opts.type) args.push("--type", opts.type);
|
|
208
|
+
if (opts.assignee) args.push("--assignee", opts.assignee);
|
|
209
|
+
if (opts.label) args.push("--label", opts.label);
|
|
210
|
+
if (opts.labelAny) args.push("--label-any", opts.labelAny);
|
|
211
|
+
if (opts.unlabeled) args.push("--unlabeled");
|
|
212
|
+
if (opts.priority) args.push("--priority", opts.priority);
|
|
213
|
+
if (opts.priorityMax) args.push("--priority-max", opts.priorityMax);
|
|
214
|
+
if (opts.limit) args.push("--limit", opts.limit);
|
|
215
|
+
if (opts.sort) args.push("--sort", opts.sort);
|
|
216
|
+
if (opts.format) args.push("--format", opts.format);
|
|
217
|
+
if (opts.json) args.push("--json");
|
|
218
|
+
await run(args);
|
|
219
|
+
},
|
|
220
|
+
);
|
|
221
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { findSproutDir } from "../config.ts";
|
|
3
|
+
import { resolveFormat, stripAnsi, VALID_FORMATS } from "../format.ts";
|
|
4
|
+
import {
|
|
5
|
+
accent,
|
|
6
|
+
brand,
|
|
7
|
+
formatIssueFull,
|
|
8
|
+
formatIssueOneLineCompact,
|
|
9
|
+
muted,
|
|
10
|
+
outputJson,
|
|
11
|
+
printIssueFull,
|
|
12
|
+
} from "../output.ts";
|
|
13
|
+
import { loadPlanContext, planForIssue, summarisePlanChildren } from "../plan-context.ts";
|
|
14
|
+
import { readIssues } from "../store.ts";
|
|
15
|
+
import type { Issue } from "../types.ts";
|
|
16
|
+
import { runShow as runPlanShow } from "./plan-show.ts";
|
|
17
|
+
|
|
18
|
+
const HUMAN_DIVIDER = "─".repeat(60);
|
|
19
|
+
|
|
20
|
+
function collectPositional(args: string[]): string[] {
|
|
21
|
+
const ids: string[] = [];
|
|
22
|
+
let i = 0;
|
|
23
|
+
while (i < args.length) {
|
|
24
|
+
const arg = args[i];
|
|
25
|
+
if (arg === undefined) {
|
|
26
|
+
i++;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (arg === "--format") {
|
|
30
|
+
i += 2;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (arg.startsWith("--")) {
|
|
34
|
+
i++;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
ids.push(arg);
|
|
38
|
+
i++;
|
|
39
|
+
}
|
|
40
|
+
return ids;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function run(args: string[], sproutDir?: string): Promise<void> {
|
|
44
|
+
const fmt = resolveFormat(args);
|
|
45
|
+
const jsonMode = fmt.mode === "json";
|
|
46
|
+
if (fmt.error) {
|
|
47
|
+
if (jsonMode) {
|
|
48
|
+
await outputJson({ success: false, command: "show", error: fmt.error });
|
|
49
|
+
} else {
|
|
50
|
+
console.error(fmt.error);
|
|
51
|
+
}
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const ids = collectPositional(args);
|
|
57
|
+
if (ids.length === 0) throw new Error("Usage: sr show <id> [ids...]");
|
|
58
|
+
|
|
59
|
+
const dir = sproutDir ?? (await findSproutDir());
|
|
60
|
+
const issues = await readIssues(dir);
|
|
61
|
+
|
|
62
|
+
if (ids.length === 1) {
|
|
63
|
+
const id = ids[0];
|
|
64
|
+
if (id === undefined) throw new Error("Usage: sr show <id> [ids...]");
|
|
65
|
+
await renderSingle(id, issues, dir, fmt.mode);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
await renderMultiple(ids, issues, dir, fmt.mode);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function renderSingle(
|
|
73
|
+
id: string,
|
|
74
|
+
issues: Issue[],
|
|
75
|
+
dir: string,
|
|
76
|
+
mode: ReturnType<typeof resolveFormat>["mode"],
|
|
77
|
+
): Promise<void> {
|
|
78
|
+
const issue = issues.find((i) => i.id === id);
|
|
79
|
+
if (!issue) {
|
|
80
|
+
if (id.startsWith("pl-")) {
|
|
81
|
+
if (mode !== "markdown" && mode !== "json") {
|
|
82
|
+
const errMsg = `sr show ${id}: --format ${mode} is not supported for plan ids; pass --json or use 'sr plan show ${id}'`;
|
|
83
|
+
console.error(errMsg);
|
|
84
|
+
process.exitCode = 1;
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
await runPlanShow(id, mode === "json");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
throw new Error(`Issue not found: ${id}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const planCtx = await loadPlanContext(dir);
|
|
94
|
+
const plan = planForIssue(planCtx, issue);
|
|
95
|
+
const planChildren = plan ? summarisePlanChildren(plan, issues) : undefined;
|
|
96
|
+
|
|
97
|
+
switch (mode) {
|
|
98
|
+
case "json": {
|
|
99
|
+
const out: Record<string, unknown> = { success: true, command: "show", issue };
|
|
100
|
+
if (plan) {
|
|
101
|
+
out.plan = {
|
|
102
|
+
id: plan.id,
|
|
103
|
+
status: plan.status,
|
|
104
|
+
revision: plan.revision,
|
|
105
|
+
template: plan.template,
|
|
106
|
+
children: plan.children,
|
|
107
|
+
};
|
|
108
|
+
out.plan_children = planChildren;
|
|
109
|
+
}
|
|
110
|
+
await outputJson(out);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
case "ids":
|
|
114
|
+
console.log(issue.id);
|
|
115
|
+
return;
|
|
116
|
+
case "compact": {
|
|
117
|
+
const closedBlockerIds = new Set(
|
|
118
|
+
issues.filter((i) => i.status === "closed").map((i) => i.id),
|
|
119
|
+
);
|
|
120
|
+
console.log(formatIssueOneLineCompact(issue, closedBlockerIds));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
case "plain":
|
|
124
|
+
console.log(stripAnsi(formatIssueFull(issue) + renderPlanBlock(plan, planChildren)));
|
|
125
|
+
return;
|
|
126
|
+
default:
|
|
127
|
+
printIssueFull(issue);
|
|
128
|
+
if (plan) process.stdout.write(renderPlanBlock(plan, planChildren));
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface MultiResult {
|
|
134
|
+
id: string;
|
|
135
|
+
issue?: Issue;
|
|
136
|
+
error?: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function renderMultiple(
|
|
140
|
+
ids: string[],
|
|
141
|
+
issues: Issue[],
|
|
142
|
+
dir: string,
|
|
143
|
+
mode: ReturnType<typeof resolveFormat>["mode"],
|
|
144
|
+
): Promise<void> {
|
|
145
|
+
const results: MultiResult[] = ids.map((id) => {
|
|
146
|
+
const issue = issues.find((i) => i.id === id);
|
|
147
|
+
if (issue) return { id, issue };
|
|
148
|
+
if (id.startsWith("pl-")) {
|
|
149
|
+
return {
|
|
150
|
+
id,
|
|
151
|
+
error: `Plan id ${id} not supported in multi-id 'sr show'; run 'sr plan show ${id}' instead`,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return { id, error: `Issue not found: ${id}` };
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const found = results.filter((r): r is MultiResult & { issue: Issue } => r.issue !== undefined);
|
|
158
|
+
const errors = results.filter((r): r is MultiResult & { error: string } => r.error !== undefined);
|
|
159
|
+
const anyMissing = errors.length > 0;
|
|
160
|
+
|
|
161
|
+
switch (mode) {
|
|
162
|
+
case "json": {
|
|
163
|
+
const planCtx = await loadPlanContext(dir);
|
|
164
|
+
const items = found.map((r) => {
|
|
165
|
+
const plan = planForIssue(planCtx, r.issue);
|
|
166
|
+
const planChildren = plan ? summarisePlanChildren(plan, issues) : undefined;
|
|
167
|
+
const item: Record<string, unknown> = { issue: r.issue };
|
|
168
|
+
if (plan) {
|
|
169
|
+
item.plan = {
|
|
170
|
+
id: plan.id,
|
|
171
|
+
status: plan.status,
|
|
172
|
+
revision: plan.revision,
|
|
173
|
+
template: plan.template,
|
|
174
|
+
children: plan.children,
|
|
175
|
+
};
|
|
176
|
+
item.plan_children = planChildren;
|
|
177
|
+
}
|
|
178
|
+
return item;
|
|
179
|
+
});
|
|
180
|
+
const out: Record<string, unknown> = {
|
|
181
|
+
success: !anyMissing,
|
|
182
|
+
command: "show",
|
|
183
|
+
issues: items.map((i) => i.issue),
|
|
184
|
+
results: items,
|
|
185
|
+
};
|
|
186
|
+
if (errors.length > 0) {
|
|
187
|
+
out.errors = errors.map((e) => ({ id: e.id, error: e.error }));
|
|
188
|
+
}
|
|
189
|
+
await outputJson(out);
|
|
190
|
+
if (anyMissing) process.exitCode = 1;
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
case "ids": {
|
|
194
|
+
for (const r of found) console.log(r.issue.id);
|
|
195
|
+
for (const e of errors) console.error(`✗ ${e.id}: ${e.error}`);
|
|
196
|
+
if (anyMissing) process.exitCode = 1;
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
case "compact": {
|
|
200
|
+
const closedBlockerIds = new Set(
|
|
201
|
+
issues.filter((i) => i.status === "closed").map((i) => i.id),
|
|
202
|
+
);
|
|
203
|
+
for (const r of found) {
|
|
204
|
+
console.log(formatIssueOneLineCompact(r.issue, closedBlockerIds));
|
|
205
|
+
}
|
|
206
|
+
for (const e of errors) console.error(`✗ ${e.id}: ${e.error}`);
|
|
207
|
+
if (anyMissing) process.exitCode = 1;
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
case "plain": {
|
|
211
|
+
const planCtx = await loadPlanContext(dir);
|
|
212
|
+
const blocks = found.map((r) => {
|
|
213
|
+
const plan = planForIssue(planCtx, r.issue);
|
|
214
|
+
const planChildren = plan ? summarisePlanChildren(plan, issues) : undefined;
|
|
215
|
+
return stripAnsi(formatIssueFull(r.issue) + renderPlanBlock(plan, planChildren));
|
|
216
|
+
});
|
|
217
|
+
console.log(blocks.join("\n\n"));
|
|
218
|
+
for (const e of errors) console.error(`✗ ${e.id}: ${e.error}`);
|
|
219
|
+
if (anyMissing) process.exitCode = 1;
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
default: {
|
|
223
|
+
const planCtx = await loadPlanContext(dir);
|
|
224
|
+
let first = true;
|
|
225
|
+
for (const r of found) {
|
|
226
|
+
if (!first) {
|
|
227
|
+
process.stdout.write(`\n${muted(HUMAN_DIVIDER)}\n\n`);
|
|
228
|
+
}
|
|
229
|
+
first = false;
|
|
230
|
+
printIssueFull(r.issue);
|
|
231
|
+
const plan = planForIssue(planCtx, r.issue);
|
|
232
|
+
if (plan) {
|
|
233
|
+
const planChildren = summarisePlanChildren(plan, issues);
|
|
234
|
+
process.stdout.write(renderPlanBlock(plan, planChildren));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
for (const e of errors) console.error(`✗ ${e.id}: ${e.error}`);
|
|
238
|
+
if (anyMissing) process.exitCode = 1;
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function renderPlanBlock(
|
|
245
|
+
plan: ReturnType<typeof planForIssue>,
|
|
246
|
+
children: ReturnType<typeof summarisePlanChildren> | undefined,
|
|
247
|
+
): string {
|
|
248
|
+
if (!plan) return "";
|
|
249
|
+
const lines: string[] = [
|
|
250
|
+
"",
|
|
251
|
+
`${brand("Plan:")} ${accent(plan.id)} ${muted(`[${plan.status}]`)}`,
|
|
252
|
+
];
|
|
253
|
+
if (plan.status === "draft") {
|
|
254
|
+
lines.push(`${accent("plan in draft — run sr plan submit")}`);
|
|
255
|
+
} else if (children && children.length > 0) {
|
|
256
|
+
lines.push(`${muted(`Plan steps (${children.length}):`)}`);
|
|
257
|
+
for (const c of children) {
|
|
258
|
+
const tag = c.adopted ? ` ${muted("(adopted)")}` : "";
|
|
259
|
+
lines.push(` ${accent(c.id)} ${muted(`[${c.status}]`)} ${c.title}${tag}`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return `\n${lines.join("\n")}\n`;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export function register(program: Command): void {
|
|
266
|
+
program
|
|
267
|
+
.command("show <id> [ids...]")
|
|
268
|
+
.description("Show one or more issues")
|
|
269
|
+
.option("--format <mode>", `Output format (${VALID_FORMATS.join("|")})`)
|
|
270
|
+
.option("--json", "Output as JSON (alias for --format json)")
|
|
271
|
+
.action(async (id: string, ids: string[], opts: { format?: string; json?: boolean }) => {
|
|
272
|
+
const args: string[] = [id, ...ids];
|
|
273
|
+
if (opts.format) args.push("--format", opts.format);
|
|
274
|
+
if (opts.json) args.push("--json");
|
|
275
|
+
await run(args);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import type { Command } from "commander";
|
|
3
|
+
import { findSproutDir } from "../config.ts";
|
|
4
|
+
import { resolveFormat, stripAnsi, VALID_FORMATS } from "../format.ts";
|
|
5
|
+
import { muted, outputJson } from "../output.ts";
|
|
6
|
+
import { readIssues } from "../store.ts";
|
|
7
|
+
import type { Issue } from "../types.ts";
|
|
8
|
+
import { PRIORITY_LABELS } from "../types.ts";
|
|
9
|
+
|
|
10
|
+
interface StatsData {
|
|
11
|
+
total: number;
|
|
12
|
+
open: number;
|
|
13
|
+
inProgress: number;
|
|
14
|
+
closed: number;
|
|
15
|
+
blocked: number;
|
|
16
|
+
byType: Record<string, number>;
|
|
17
|
+
byPriority: Record<number, number>;
|
|
18
|
+
byLabel: Record<string, number>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function formatStatsMarkdown(s: StatsData): string {
|
|
22
|
+
const lines: string[] = [];
|
|
23
|
+
lines.push(`${chalk.bold("Project Statistics")}`);
|
|
24
|
+
lines.push(` ${muted("Total:")} ${s.total}`);
|
|
25
|
+
lines.push(` ${muted("Open:")} ${s.open}`);
|
|
26
|
+
lines.push(` ${muted("In progress:")} ${s.inProgress}`);
|
|
27
|
+
lines.push(` ${muted("Closed:")} ${s.closed}`);
|
|
28
|
+
lines.push(` ${muted("Blocked:")} ${s.blocked}`);
|
|
29
|
+
lines.push(`\n${chalk.bold("By Type")}`);
|
|
30
|
+
for (const [type, count] of Object.entries(s.byType)) {
|
|
31
|
+
lines.push(` ${muted(type.padEnd(10))} ${count}`);
|
|
32
|
+
}
|
|
33
|
+
if (Object.keys(s.byPriority).length > 0) {
|
|
34
|
+
lines.push(`\n${chalk.bold("By Priority")}`);
|
|
35
|
+
for (const [p, count] of Object.entries(s.byPriority)) {
|
|
36
|
+
const label = PRIORITY_LABELS[Number(p)] ?? String(p);
|
|
37
|
+
lines.push(` ${muted(`P${p} ${label.padEnd(10)}`)} ${count}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (Object.keys(s.byLabel).length > 0) {
|
|
41
|
+
lines.push(`\n${chalk.bold("By Label")}`);
|
|
42
|
+
for (const [label, count] of Object.entries(s.byLabel).sort((a, b) => b[1] - a[1])) {
|
|
43
|
+
lines.push(` ${muted(label.padEnd(15))} ${count}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return lines.join("\n");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function formatStatsCompact(s: StatsData): string {
|
|
50
|
+
const lines: string[] = [];
|
|
51
|
+
lines.push(
|
|
52
|
+
`total=${s.total} open=${s.open} in_progress=${s.inProgress} closed=${s.closed} blocked=${s.blocked}`,
|
|
53
|
+
);
|
|
54
|
+
const types = Object.entries(s.byType)
|
|
55
|
+
.map(([t, c]) => `${t}=${c}`)
|
|
56
|
+
.join(" ");
|
|
57
|
+
if (types) lines.push(`by_type: ${types}`);
|
|
58
|
+
const prios = Object.entries(s.byPriority)
|
|
59
|
+
.map(([p, c]) => `P${p}=${c}`)
|
|
60
|
+
.join(" ");
|
|
61
|
+
if (prios) lines.push(`by_priority: ${prios}`);
|
|
62
|
+
const labels = Object.entries(s.byLabel)
|
|
63
|
+
.sort((a, b) => b[1] - a[1])
|
|
64
|
+
.map(([l, c]) => `${l}=${c}`)
|
|
65
|
+
.join(" ");
|
|
66
|
+
if (labels) lines.push(`by_label: ${labels}`);
|
|
67
|
+
return lines.join("\n");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function run(args: string[], sproutDir?: string): Promise<void> {
|
|
71
|
+
const fmt = resolveFormat(args);
|
|
72
|
+
const jsonMode = fmt.mode === "json";
|
|
73
|
+
if (fmt.error) {
|
|
74
|
+
if (jsonMode) {
|
|
75
|
+
await outputJson({ success: false, command: "stats", error: fmt.error });
|
|
76
|
+
} else {
|
|
77
|
+
console.error(fmt.error);
|
|
78
|
+
}
|
|
79
|
+
process.exitCode = 1;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const dir = sproutDir ?? (await findSproutDir());
|
|
83
|
+
const issues = await readIssues(dir);
|
|
84
|
+
|
|
85
|
+
const total = issues.length;
|
|
86
|
+
const open = issues.filter((i: Issue) => i.status === "open").length;
|
|
87
|
+
const inProgress = issues.filter((i: Issue) => i.status === "in_progress").length;
|
|
88
|
+
const closed = issues.filter((i: Issue) => i.status === "closed").length;
|
|
89
|
+
|
|
90
|
+
const closedIds = new Set(issues.filter((i: Issue) => i.status === "closed").map((i) => i.id));
|
|
91
|
+
const blocked = issues.filter((i: Issue) => {
|
|
92
|
+
if (i.status === "closed") return false;
|
|
93
|
+
return (i.blockedBy ?? []).some((bid) => !closedIds.has(bid));
|
|
94
|
+
}).length;
|
|
95
|
+
|
|
96
|
+
const byType: Record<string, number> = {};
|
|
97
|
+
for (const issue of issues) {
|
|
98
|
+
byType[issue.type] = (byType[issue.type] ?? 0) + 1;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const byPriority: Record<number, number> = {};
|
|
102
|
+
for (const issue of issues) {
|
|
103
|
+
byPriority[issue.priority] = (byPriority[issue.priority] ?? 0) + 1;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const byLabel: Record<string, number> = {};
|
|
107
|
+
for (const issue of issues) {
|
|
108
|
+
for (const label of issue.labels ?? []) {
|
|
109
|
+
byLabel[label] = (byLabel[label] ?? 0) + 1;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const data: StatsData = { total, open, inProgress, closed, blocked, byType, byPriority, byLabel };
|
|
114
|
+
|
|
115
|
+
switch (fmt.mode) {
|
|
116
|
+
case "json":
|
|
117
|
+
await outputJson({ success: true, command: "stats", stats: data });
|
|
118
|
+
return;
|
|
119
|
+
case "ids":
|
|
120
|
+
// Stats has no IDs to emit.
|
|
121
|
+
return;
|
|
122
|
+
case "compact":
|
|
123
|
+
console.log(formatStatsCompact(data));
|
|
124
|
+
return;
|
|
125
|
+
case "plain":
|
|
126
|
+
console.log(stripAnsi(formatStatsMarkdown(data)));
|
|
127
|
+
return;
|
|
128
|
+
default:
|
|
129
|
+
console.log(formatStatsMarkdown(data));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function register(program: Command): void {
|
|
135
|
+
program
|
|
136
|
+
.command("stats")
|
|
137
|
+
.description("Project statistics")
|
|
138
|
+
.option("--format <mode>", `Output format (${VALID_FORMATS.join("|")})`)
|
|
139
|
+
.option("--json", "Output as JSON (alias for --format json)")
|
|
140
|
+
.action(async (opts: { format?: string; json?: boolean }) => {
|
|
141
|
+
const args: string[] = [];
|
|
142
|
+
if (opts.format) args.push("--format", opts.format);
|
|
143
|
+
if (opts.json) args.push("--json");
|
|
144
|
+
await run(args);
|
|
145
|
+
});
|
|
146
|
+
}
|