[FEATURE]: /insights should be a first-class built-in feature (not only a prompt template wrapper around opencode stats) #8985

Closed
opened 2026-02-16 18:11:19 -05:00 by yindo · 2 comments
Owner

Originally created by @Hayden727 on GitHub (Feb 10, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Background

We recently added an /insights command, but the current implementation is mainly:

  • Registering insights as a default command.
  • Mapping it to a prompt template.
  • Calling opencode stats $ARGUMENTS inside the template via shell interpolation.

This means /insights is currently prompt-driven, not a first-class built-in feature with structured output and stable behavior.

  • Command registration exists in packages/opencode/src/command/index.ts.
  • Current behavior is defined in packages/opencode/src/command/template/insights.txt and depends on inline shell execution.

Current Problems

Not a true product feature yet

/insights is implemented as a prompt template, not a dedicated analytics/report pipeline.

Output is non-deterministic

Report quality depends heavily on model behavior/prompt interpretation.

No structured contract

No machine-readable schema (JSON/typed report), so hard to test, automate, and render in UI.

Hard to evolve

Prompt-only logic makes future UX features (history comparison, trend charts, recommendations scoring) difficult.

No dedicated test coverage

We cannot reliably validate report sections/fields/edge cases.

Expected Behavior

/insights should be implemented as a first-class built-in capability that:

  • Collects usage data through internal APIs/modules (not prompt-shell glue only).
  • Produces a structured insights payload (e.g. typed JSON) with stable fields:
    • overview metrics
    • usage insights
    • recommendations
    • suggested experiments
  • Optionally renders a human-friendly markdown view from this structured payload.
  • Supports parameters (e.g. days/models/tools/project) in a typed way.
  • Has automated tests for core behavior and empty-data edge cases.

Proposed Direction

  • Add an internal Insights module/service (e.g. under packages/opencode/src/...) to compute the report.
  • Reuse stats aggregation logic programmatically rather than shelling out to CLI text output.
  • Define a typed schema for insights output.
  • Keep /insights command as user entrypoint, but route to the built-in insights pipeline.
  • Add tests:
    • no usage data
    • normal data
    • filtered windows (--days, project)
    • model/tool ranking and recommendation generation

Acceptance Criteria

  • /insights returns deterministic structured output (schema-defined).
  • Markdown/text presentation is generated from structured output.
  • Works without relying on ! shell command substitution in template.
  • Unit/integration tests cover core scenarios and pass in CI.
  • Backward-compatible UX: users can still invoke /insights [args] naturally.
Originally created by @Hayden727 on GitHub (Feb 10, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request # Background We recently added an `/insights` command, but the current implementation is mainly: - Registering insights as a default command. - Mapping it to a prompt template. - Calling `opencode stats $ARGUMENTS` inside the template via shell interpolation. This means `/insights` is currently prompt-driven, not a first-class built-in feature with structured output and stable behavior. - Command registration exists in `packages/opencode/src/command/index.ts`. - Current behavior is defined in `packages/opencode/src/command/template/insights.txt` and depends on inline shell execution. # Current Problems ## Not a true product feature yet `/insights` is implemented as a prompt template, not a dedicated analytics/report pipeline. ## Output is non-deterministic Report quality depends heavily on model behavior/prompt interpretation. ## No structured contract No machine-readable schema (JSON/typed report), so hard to test, automate, and render in UI. ## Hard to evolve Prompt-only logic makes future UX features (history comparison, trend charts, recommendations scoring) difficult. ## No dedicated test coverage We cannot reliably validate report sections/fields/edge cases. # Expected Behavior `/insights` should be implemented as a first-class built-in capability that: - Collects usage data through internal APIs/modules (not prompt-shell glue only). - Produces a structured insights payload (e.g. typed JSON) with stable fields: - overview metrics - usage insights - recommendations - suggested experiments - Optionally renders a human-friendly markdown view from this structured payload. - Supports parameters (e.g. `days`/`models`/`tools`/`project`) in a typed way. - Has automated tests for core behavior and empty-data edge cases. # Proposed Direction - Add an internal Insights module/service (e.g. under `packages/opencode/src/...`) to compute the report. - Reuse stats aggregation logic programmatically rather than shelling out to CLI text output. - Define a typed schema for insights output. - Keep `/insights` command as user entrypoint, but route to the built-in insights pipeline. - Add tests: - no usage data - normal data - filtered windows (`--days`, `project`) - model/tool ranking and recommendation generation # Acceptance Criteria - `/insights` returns deterministic structured output (schema-defined). - Markdown/text presentation is generated from structured output. - Works without relying on `!` shell command substitution in template. - Unit/integration tests cover core scenarios and pass in CI. - Backward-compatible UX: users can still invoke `/insights [args]` naturally.
yindo added the discussion label 2026-02-16 18:11:19 -05:00
yindo closed this issue 2026-02-16 18:11:19 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 10, 2026):

This issue might be a duplicate of an existing feature request. Please check:

  • #6767: [Feature Request] Implement /stats command for visual usage insights (similar to Claude Code)

While #6767 focuses more on the visual/UX aspects, both issues discuss the need for a comprehensive insights/stats feature with structured output and visual presentation. You may want to review the discussion in #6767 to see if there are related insights or prior work on this.

@github-actions[bot] commented on GitHub (Feb 10, 2026): This issue might be a duplicate of an existing feature request. Please check: - #6767: [Feature Request] Implement /stats command for visual usage insights (similar to Claude Code) While #6767 focuses more on the visual/UX aspects, both issues discuss the need for a comprehensive insights/stats feature with structured output and visual presentation. You may want to review the discussion in #6767 to see if there are related insights or prior work on this.
Author
Owner

@ariane-emory commented on GitHub (Feb 10, 2026):

Where are you even seeing this supposed command? There is no packages/opencode/src/command/template/insights.txt file in either dev or beta.

@ariane-emory commented on GitHub (Feb 10, 2026): Where are you even seeing this supposed command? There is no `packages/opencode/src/command/template/insights.txt` file in either dev or beta.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8985