Workflow in workflow #9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I want a planner workflow that will read issues from the tracker, pick an issue, then run
implement-issueorexplore-issueon it, and repeat.This will require being able to run workflows within workflows. Explore how this will affect the code, UX, and the fullscreen UI.
Effort Estimate
Medium-large: ~2–4 weeks for one developer familiar with the codebase.
Breakdown:
issues.list): ~1–2 dayssdk.runor import convention): ~3–5 daysMost Relevant Files
packages/niwa/index.tsNiwaSDKneedsrun()method;Issuesneedslist(). TheRunView/ reporter types may need nesting support.src/run.tsresolveAndInvoke()for sub-workflow calls.src/sdk.tscreateRunSdkbuilds theNiwaSDK. Addingsdk.run()here. AlsomakeWorkspace— sub-workflows share the parent's runner/reporter.src/issues.tslist()method with provider-specific CLI args (gh issue list,tea issues).src/run-reporter.tsRunReporterinterface. May need asubworkflowevent for nesting.src/tui/reporter.tsFullscreenReporter— singleRunView, one agent pane. Needs to handle nested agent sequences from sub-workflows.src/tui/view.tsRunViewlayout — single-level agents list. Needs hierarchical or stacked view model.src/presets/content/implement-issue.tsplannerworkflow will follow this pattern.src/presets/content/explore-issue.tssrc/cli.tssdk.runneeds process-level isolation.src/config.tsdocs/design/architecture.mdClaims Analysis
niwa.issues.get(id)exists for a single issue by ID. Missing: Nolist()or search API to enumerate open issues — a blocker for "read issues from the tracker.".run()).Open Questions
issues.list()return all open issues, or accept filters (state, label, milestone)? Pagination needed? Minimum viable for an LLM-based planner?import impl from './implement-issue'; impl.run(sdk, id)) orsdk.run('implement-issue', id)? The import approach follows existing patterns (Roles are composed this way inimplement-issue.ts) but limits flexibility. An SDK-levelrun()enables runtime-dynamic dispatch but requires significant refactoring ofrun.ts.RunReporteror create a sub-reporter? The plain/rail reporters are stateless and share fine; the FullscreenReporter owns the terminal and can only have one active.sdk.run()share the parent's SDK (same workspace tracker, same disposal) or create a child SDK? If shared, workspace releases from both parent and child merge correctly. If separate, wiring the reporter and runner through is complex.explore-issuefails on one issue, does the planner abort, skip to the next, or retry? What about partial failures inimplement-issue(e.g., implement passes but review fails)?.niwa/planner-state.json)? Without this, every run would re-process old issues..niwa/config.jsonor a dedicated.niwa/planner.json?plannera shipped preset (embedded in binary) or only a demonstration pattern users implement themselves?Suggested Approach
Phase 1 — Core plumbing (prerequisites)
issues.list()topackages/niwa/index.ts(type),src/issues.ts(implementation withgh issue list --json number,title,state,url,labels --state openandtea issues --output json), and wire through providers.src/run.tsto extract a reusableresolveAndInvoke(name: string, sdk: NiwaSDK, args: unknown[]): Promise<LoopOutput>that encapsulates module resolution + dynamic import + invocation. HaverunModulecall it.sdk.run(name, ...args)to theNiwaSDKinterface andcreateRunSdk— delegates to the shared resolver. This is the clean public API.Phase 2 — Reporter nesting
subworkflowBegin/subworkflowEndevents toRunReporterinterface. Plain/Pretty reporters treat them as no-ops or log them.FullscreenReporterto maintain a stack ofRunViewframes. OnsubworkflowBegin, push a new frame and switch the active agent pane to it. OnsubworkflowEnd, pop the frame and restore the parent.src/tui/view.tsto render a breadcrumb header showing the nesting path and the sub-workflow's agents in the main pane.Phase 3 — Planner workflow
planner.ts(as a shipped preset):issues.list()→ get open issuessdk.run('explore-issue', issue.id)for complex issues (assessment first)sdk.run('implement-issue', issue.id)for well-understood issuesPhase 4 — Polish
docs/design/architecture.mdto describe nested workflow composition andsdk.run().issues.list(),sdk.run(), sub-workflow reporter events, and the planner workflow viaRunModuleArgs/FakeCommandRunner.plannerto the preset catalog and setup cascade.