Skip to content

feat: Add JSON output mode for CI/CD integration #105

@CarGDev

Description

@CarGDev

Summary

Add machine-parseable JSON output mode for scripting and CI/CD integration.

Why It's Needed

  • CI/CD Integration: Automated pipelines can parse results
  • Scripting: Chain codetyper with other tools
  • Log Parsing: Structured logs instead of colored text
  • Programmatic Access: Build wrappers and integrations

Usage

codetyper --format json "fix the bug"
codetyper --format jsonl "refactor this"  # JSON Lines for streaming
codetyper -p --format json "explain this code"  # Print mode + JSON

Output Format

{
  "session_id": "abc123",
  "status": "success",
  "exit_code": 0,
  "provider": "copilot",
  "model": "gpt-5-mini",
  "messages": [
    {
      "role": "user",
      "content": "fix the bug",
      "timestamp": "2024-01-27T10:30:00Z"
    },
    {
      "role": "assistant",
      "content": "I'll fix the bug in src/app.ts...",
      "tool_calls": [
        {
          "id": "call_123",
          "tool": "edit",
          "input": {
            "path": "src/app.ts",
            "old_string": "bug",
            "new_string": "fix"
          },
          "output": {
            "success": true,
            "diff": "..."
          },
          "duration_ms": 150
        }
      ],
      "timestamp": "2024-01-27T10:30:05Z"
    }
  ],
  "files_modified": ["src/app.ts"],
  "files_created": [],
  "files_deleted": [],
  "tokens": {
    "input": 1500,
    "output": 800,
    "total": 2300
  },
  "duration_ms": 5000
}

Exit Codes

const EXIT_CODES = {
  SUCCESS: 0,
  GENERAL_ERROR: 1,
  INVALID_ARGS: 2,
  PROVIDER_ERROR: 3,
  PERMISSION_DENIED: 4,
  TOOL_FAILED: 5,
  TIMEOUT: 6,
  INTERRUPTED: 130,
}

Acceptance Criteria

  • --format json flag for full JSON output
  • --format jsonl flag for streaming JSON Lines
  • Proper exit codes for different error types
  • No color codes in JSON mode
  • Include all tool calls and results
  • Include token usage
  • Include timing information
  • Document exit codes

Effort Estimate

1 day

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority-criticalCritical priority - implement first

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions