Skip to content

Add --json output flag to commit-echo history #58

@404-Page-Found

Description

@404-Page-Found

Task summary

Add a --json flag to the commit-echo history command so the style profile and recent commits can be output as JSON for scripting, CI pipelines, and tool integration.

Why this is a good first issue

The task is well-scoped: it only modifies one command file and the CLI entry point. The profile data structure (StyleProfile) is already defined in src/types.ts, and the human-readable formatting already exists in formatProfile(). Adding a JSON output path is a straightforward parallel implementation.

Suggested files or areas

  • src/commands/history.ts — add --json flag handling and JSON output branch
  • src/index.ts — register the --json option on the history command

Acceptance criteria

  • commit-echo history --json outputs a valid JSON object with profile and recentCommits keys
  • commit-echo history --json exits with code 0 and output is written to stdout only (no ANSI formatting, no intro/outro)
  • commit-echo history (without flag) continues to output the current human-readable format unchanged
  • When no history exists, commit-echo history --json returns { "profile": null, "recentCommits": [], "totalCommits": 0 }
  • npm run build succeeds with no errors

Extra context

  • StyleProfile and CommitEntry types are in src/types.ts
  • loadEntries and buildProfile are in src/history/store.ts
  • Use JSON.stringify for output—avoid logging through @clack/prompts when --json is set

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions