Skip to content

feat: standalone CLI (aicoach) — all harnesses in one terminal report#171

Open
felipetruman wants to merge 1 commit into
microsoft:mainfrom
felipetruman:feat/standalone-cli
Open

feat: standalone CLI (aicoach) — all harnesses in one terminal report#171
felipetruman wants to merge 1 commit into
microsoft:mainfrom
felipetruman:feat/standalone-cli

Conversation

@felipetruman

Copy link
Copy Markdown

Description

Adds a standalone CLI (aicoach) that runs the same read-only parsing/analysis pipeline as the extension and renders reports in a terminal — no VS Code required. This makes the coach usable from a plain shell, over SSH, and in CI/cron for people who work primarily in terminal harnesses (Claude Code, Codex, OpenCode).

Commands

  • aicoach report — ANSI terminal dashboard (scores, priorities, context, next actions); --format md|json|html|both|all + --out writes self-contained report files
  • aicoach summary — existing summary-export renderers (md/json)
  • aicoach json <summary|activity|patterns|flow|insights|workflows|context|production|credits|wellbeing|compare> — raw payloads from the MCP formatters
  • aicoach sessions / aicoach session --session-id <id> — paged listing and detail
  • aicoach observe summary, aicoach measure output, aicoach improve anti-patterns|context-health
  • All commands accept --from/--to/--workspace/--harness filters plus --logs-dir overrides
  • --verbose progress goes to stderr; stdout carries only command output, so aicoach json … | jq works. Core console.info/console.debug diagnostics are routed to stderr for the same reason.

Safety: local rules/metrics stay blocked by default via a blocking TrustGate (the CLI has no interactive approval UI); --allow-local-rules opts in explicitly, and blocked files are reported on stderr.

Build: separate esbuild-cli.mjsdist/cli.js (npm run build:cli); the extension pipeline in esbuild.mjs is untouched. package.json gains two bin aliases (aicoach, ai-engineer-coach) and two scripts; src/cli.ts is registered as a knip entry.

Related Issues

Relates to #46 — "would be extremely useful to collect all the information from various tools in one dashboard": the CLI surfaces every supported harness (VS Code/Copilot, Claude Code, Codex, OpenCode) in one report from the terminal. OpenCode parsing on current OpenCode versions additionally needs #170 (SQLite storage).

Checklist

  • npm run check passes (typecheck + lint + spellcheck + knip + tests) — 1227 tests, tsc --noEmit clean, ESLint 0 errors (0 new warnings), cspell 0 issues, knip clean
  • Changes are covered by tests (src/cli/cli.test.ts: arg parsing, filters, payload extraction, next-action dedup, HTML escaping, ANSI stripping)
  • Documentation updated (CLI help text; module header comments)

Verification against real data

Audited on a machine with 6,086 real sessions across 67 workspaces (with #170 applied locally for OpenCode):

  • sessions --harness Claude → 4,343 · Codex → 466 · OpenCode → 1,143
  • report --format all --out produces consistent txt/md/json/html; JSON parses and matches the dashboard totals
  • json compare breaks down per harness; measure output --from filters correctly
  • Invalid commands/formats exit 1 with a one-line error

Runs the same parsing/analysis pipeline as the extension against every
supported harness (VS Code/Copilot, Claude Code, Codex, OpenCode) and
renders reports without an editor: an ANSI terminal dashboard, plus
md/json/html report files. Includes commands for summary export,
per-area JSON payloads, session listing/detail, anti-patterns, and
context health, with date/workspace/harness filters.

Local rules/metrics stay blocked by default (no interactive approval
UI in a terminal); --allow-local-rules opts in explicitly.
Copilot AI review requested due to automatic review settings July 2, 2026 16:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread src/cli/report-payload.ts
Comment on lines +166 to +172
const totals = extractBulletMap(baseMarkdown, '## Totals');

const payloadWithoutActions = {
generatedAt: new Date().toISOString(),
filter: totals['Filter'] ?? 'All data',
totals,
flow: extractBulletMap(baseMarkdown, '## Flow'),
Comment thread src/cli.ts
Comment on lines +100 to +103
if (blockedLocalFiles.length > 0 && !getBool(opts, 'quiet')) {
console.error(`Local rules/metrics blocked for safety: ${blockedLocalFiles.length}`);
console.error('Pass --allow-local-rules if you trust these files.');
}
Comment thread src/cli.ts
Comment on lines +160 to +167
if (!outDir && formats.length === 1) {
writeOrPrint(contentByFormat[formats[0]]);
return;
}

const targetDir = path.resolve(outDir ?? './reports');
const extByFormat: Record<ReportFormat, string> = { terminal: 'txt', md: 'md', json: 'json', html: 'html' };

Comment thread src/cli/args.ts
Comment on lines +40 to +46
// --logs-dir may repeat; collect every occurrence.
if (key === 'logs-dir') {
const current = opts[key];
opts[key] = Array.isArray(current) ? [...current, String(value)] : [String(value)];
} else {
opts[key] = value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants