From b4f25cce4897d1722636c95f1915b2611542e038 Mon Sep 17 00:00:00 2001 From: Chris La Date: Mon, 23 Mar 2026 16:33:30 -0700 Subject: [PATCH 1/2] Add --output-format stream-json to Claude Code command Enable stream-json output format so Claude Code emits JSONL to stdout, including a final "result" message with token usage data. This is the prerequisite for cost tracking in StrawPot sessions. Part of strawpot#422 (Cost Observability Phase 1). Co-Authored-By: Claude Opus 4.6 (1M context) --- claude_code/wrapper/main.go | 4 ++++ claude_code/wrapper/main_test.go | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/claude_code/wrapper/main.go b/claude_code/wrapper/main.go index 9bcb4f8..4dd1943 100644 --- a/claude_code/wrapper/main.go +++ b/claude_code/wrapper/main.go @@ -249,6 +249,10 @@ func cmdBuild(args []string) { cmd = append(cmd, "--dangerously-skip-permissions") } + // Stream-json output format: emits JSONL to stdout, including a final + // "result" message with token usage data for cost tracking. + cmd = append(cmd, "--output-format", "stream-json") + // Disallow Claude Code's native scheduling tools — StrawPot manages // scheduling through its own orchestrator (denden). cmd = append(cmd, "--disallowedTools", "CronCreate,CronDelete,CronList") diff --git a/claude_code/wrapper/main_test.go b/claude_code/wrapper/main_test.go index e5e4593..334760a 100644 --- a/claude_code/wrapper/main_test.go +++ b/claude_code/wrapper/main_test.go @@ -364,6 +364,25 @@ func TestCmdBuild_DangerouslySkipPermissions_Disabled(t *testing.T) { } } +func TestCmdBuild_StreamJsonOutputFormat(t *testing.T) { + tmpDir := t.TempDir() + wsDir := filepath.Join(tmpDir, "workspace") + + args := []string{ + "--agent-workspace-dir", wsDir, + } + + output := captureBuildOutput(t, args) + + var result map[string]interface{} + if err := json.Unmarshal(output, &result); err != nil { + t.Fatalf("Failed to parse JSON output: %v", err) + } + + cmd := result["cmd"].([]interface{}) + assertSequence(t, cmd, "--output-format", "stream-json") +} + func TestCmdBuild_DisallowedSchedulingTools(t *testing.T) { tmpDir := t.TempDir() wsDir := filepath.Join(tmpDir, "workspace") From 52275b4b175f5b593be1039f1c6ede7fd8651465 Mon Sep 17 00:00:00 2001 From: Chris La Date: Fri, 27 Mar 2026 16:39:08 -0700 Subject: [PATCH 2/2] Remove PR approval gate from CLAUDE.md workflow Co-Authored-By: Claude Opus 4.6 (1M context) --- CLAUDE.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 06f129b..fbe5088 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -8,10 +8,7 @@ ## After completing any code change -1. Show me the full `git diff` for review -2. Wait for my explicit approval before proceeding -3. Once approved: - - Rebase from `main` before committing (`git fetch origin && git rebase origin/main`) - - **If the current branch has an open PR**, push to that branch to update the existing PR. - - **If the current branch's PR is already merged** (or there is no PR), pull the latest `main` (`git checkout main && git pull origin main`), then create a fresh branch from `main` and open a new PR. - - Never reuse a branch whose PR has been merged. Each merged PR keeps its own branch. +1. Rebase from `main` before committing (`git fetch origin && git rebase origin/main`) +2. **If the current branch has an open PR**, push to that branch to update the existing PR. +3. **If the current branch's PR is already merged** (or there is no PR), pull the latest `main` (`git checkout main && git pull origin main`), then create a fresh branch from `main` and open a new PR. +4. Never reuse a branch whose PR has been merged. Each merged PR keeps its own branch.