Add --json-stream flag to rebase, finish, and commit commands#635
Add --json-stream flag to rebase, finish, and commit commands#635NoahCardoza wants to merge 3 commits intoiloom-ai:mainfrom
Conversation
Complexity AssessmentClassification: COMPLEX Metrics:
Reasoning: This change implements cross-cutting parameter propagation where the |
Analysis Phase
Executive SummaryAdding Questions and Key Decisions
HIGH/CRITICAL Risks
Impact Summary
Complete Technical Reference (click to expand for implementation details)Problem Space ResearchProblem UnderstandingOpenClaw and other automation tools need non-interactive control of Architectural ContextThe existing Edge Cases Identified
Codebase Research FindingsAffected Area: MergeManager conflict resolutionEntry Point:
Current await launchClaude(prompt, {
appendSystemPrompt: systemPrompt,
addDir: worktreePath,
headless: false,
allowedTools: rebaseAllowedTools,
})For await launchClaude(prompt, {
appendSystemPrompt: systemPrompt,
addDir: worktreePath,
headless: true,
permissionMode: 'bypassPermissions',
allowedTools: rebaseAllowedTools,
// NEW: pipe stdout to process.stdout instead of capturing
})Affected Area: launchClaude stdout handlingEntry Point: Required Change: A new mode where Affected Area: RebaseCommandEntry Point:
Required Changes:
Affected Area: FinishCommandEntry Point:
Required Changes:
Affected Area: CLI registrationEntry Points:
Rebase needs significant restructuring to add the Architectural Flow AnalysisData Flow:
|
Implementation Plan for Issue #634SummaryAdd Questions and Key Decisions
High-Level Execution Phases
Quick Stats
Potential Risks (HIGH/CRITICAL only)
Complete Implementation Guide (click to expand for step-by-step details)Automated Test Cases to CreateTest File:
|
Implementation CompleteSummaryAdded Changes Made
Validation Results
Detailed Changes by File (click to expand)src/types/index.tsChanges: Type definitions for new feature
src/utils/claude.tsChanges: Passthrough stdout mode for headless Claude
src/lib/MergeManager.tsChanges: jsonStream plumbing through merge pipeline
src/commands/rebase.tsChanges: --json-stream support in RebaseCommand
src/commands/finish.tsChanges: --json-stream forwarding in FinishCommand
src/cli.tsChanges: CLI flag registration and orchestration
|
6819ffb to
278d088
Compare
Adds --json-stream flag to `il rebase` and `il finish` for headless/non-interactive Claude usage during conflict resolution. When active, Claude runs headless with JSONL streaming to stdout and progress redirected to stderr. - Add jsonStream to MergeOptions/FinishOptions and new RebaseResult/RebaseOutcome types - Add passthroughStdout mode to launchClaude() for direct stdout piping - Plumb jsonStream through MergeManager → attemptClaudeConflictResolution → launchClaude - Add --json-stream CLI flag to both rebase and finish commands - Enforce mutual exclusivity of --json and --json-stream on finish - Use compact JSON for --json-stream output (JSONL compatible) Closes iloom-ai#634 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
278d088 to
5ed5de8
Compare
|
@acreeger For some reason this test keeps timing out on my machine, but it doesn't seem to be an issue in the pipeline. Have you see this? I'm going to try to fix it, but let me know if you have any insight. |
|
This was not the correct root cause.
LoomManager.test.ts timeout |
I've never seen it! I wonder if it happens for you on main? Looks like you fixed it anyway, but that's an odd one |
Investigation: Flaky
|
| Test | Duration |
|---|---|
#5 should populate both issueUrls and prUrls... |
121ms |
#6 should create loom for branch successfully |
118ms |
Under full suite (4 forks competing):
| Test | Duration | Suite timestamp |
|---|---|---|
| #1-3 (before other forks start) | ~100ms | 0.0-0.3s |
| #4 | 594ms | 0.9s |
#5 should populate both issueUrls and prUrls... |
14,841ms (120x slower) | 15.7s |
#6* should create loom for branch successfully |
10,488ms | 20.9s |
| #7+ (after forks finish init) | ~100ms | 21.0s+ |
The slowdown is confined to the 0.4s-21s window — exactly the fork initialization period. beforeEach is always <2ms, confirming the test body's async chain is what gets starved.
Fix
Added { timeout: 30_000 } to the top-level describe('LoomManager', ...) block. This is not a code bug — it's CPU contention during parallel test execution, and the default 10s timeout is simply too tight for this 98-test suite under load.
Additional fix (stashed, to be applied separately)
The beforeEach has a vi.clearAllMocks() call at line 195 that clears mock implementations set up earlier in the same beforeEach (lines 173-189). This is redundant since vitest config already has mockReset: true and clearMocks: true, and it forces tests to re-establish defaults that should be inherited from the setup. Removing it simplifies the test setup without changing behavior.
|
@acreeger After further investigation, I believe the initial fix suggestion was false. It appears there's some strange starvation happening on my computer when running all the tests in parallel. If you don't mind, I'd like to update the timeout on this particular file to 30 seconds. Otherwise, the |
…#634 - Add TestOptions import from vitest - Configure 30 second timeout for LoomManager describe block - Handle CPU contention under parallel test execution with 98 tests
…ion. Refs iloom-ai#634 - Add `--json-stream` option to commit CLI command with mutual exclusivity check against `--json` - Implement headless Claude mode in ValidationRunner for streaming JSONL output during fixes - Pass jsonStream option through validation pipeline to support stdout passthrough - Update commit command documentation with new flag - Fix import statement in LoomManager test file
|
@acreeger I'm happy to report this is ready for review! As it just so happens, I was able to successfully test the |
iloom Session SummaryKey Themes:
Session Details (click to expand)Key Insights
Decisions Made
Challenges Resolved
Lessons Learned
Generated with 🤖❤️ by iloom.ai |
Fixes #634
Add --json-stream flag to rebase, finish, and commit commands
Summary
Add
--json-streamflag toil rebase,il finish, andil commitcommands to support headless/non-interactive usage (e.g., OpenClaw). This flag controls output format and how Claude Code runs when launched for merge conflict resolution (rebase/finish) or validation fixes (commit).Context
il rebasehad no JSON output support at allil finishhad--jsonbut no--json-streamil commithad--jsonbut no--json-stream, and its validation pipeline (typecheck, lint, test) launches Claude interactively to fix errors — which doesn't work headlessil spinandil planalready implement--json-stream(with--print)--json-streamto monitor Claude's output non-interactivelyDesign Decisions
--json-stream= progress to stderr, Claude runs headless (like--print --json-streamon spin/plan), streams JSONL to stdout in real-time. The final JSON result object is always appended at the end of the stream.--jsonand--json-streamare mutually exclusive (onfinishandcommitwhich both have--json)--printflag needed —--json-streamalone is sufficient to enable headless Claude and structured outputChanges
Rebase & Finish (Stage 1-3)
src/lib/MergeManager.ts— AcceptjsonStreaminMergeOptions; when true, launch Claude headless withbypassPermissionsandpassthroughStdoutfor conflict resolutionsrc/commands/rebase.ts/src/cli.ts— Register--json-streamflag, redirect logger to stderr, pass option through toMergeManager, output finalRebaseResultJSONsrc/commands/finish.ts/src/cli.ts— Register--json-streamflag with--jsonmutual exclusion, redirect logger to stderr, pass option through toMergeManager, output finalFinishResultJSONCommit (Stage 4)
src/commands/commit.ts— AddjsonStreamtoCommitCommandInput; useisJsonMode(json || jsonStream) for all JSON return paths; passjsonStreamthrough toValidationRunner.runValidations()src/cli.ts(commit section) — Register--json-streamoption with--jsonmutual exclusion;--json-streamimplies--no-review; redirect logger to stderr; compact JSON output for--json-streamsrc/lib/ValidationRunner.ts— ThreadjsonStreamoption throughrunTypecheck(),runLint(), andrunTests()down toattemptClaudeFix(); whenjsonStreamis true, launch Claude headless withbypassPermissionsandpassthroughStdout(instead of interactiveacceptEditsmode)src/types/index.ts— AddjsonStreamtoValidationOptionsinterfaceDocumentation
docs/iloom-commands.md— Document--json-streamflag on rebase, finish, and commit commandsVerification
pnpm build— TypeScript compiles successfullypnpm test— All 3902 tests passil commit --json-stream— Streams JSONL if Claude is invoked for validation fixesil commit --json --json-stream— Errors with mutual exclusion messageil rebase --json-stream— Streams JSONL if Claude is invoked for conflict resolutionil finish --json --json-stream— Errors with mutual exclusion messageThis PR was created automatically by iloom.