feat(kiro): fix PRD creation and add model selection#194
Conversation
|
@medhatgalal is attempting to deploy a commit to the plgeek Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughAuto-loads a bundled ralph-tui-prd SKILL.md when no custom PRD skill is provided, adds model selection/validation for the Kiro agent and passes --model to the CLI, strips ANSI escape codes from PRD content before saving/state, reworks agent-aware skill installation flow, and adds comprehensive tests for these behaviours. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as runChatMode(parsedArgs)
participant Agent as AgentPlugin
participant FS as Filesystem
participant Log as Logger
CLI->>Agent: request skillsPaths
Agent-->>CLI: returns skillsPaths (personal, repo) or undefined
alt skillsPaths present
CLI->>FS: check personal `~/.kiro/skills/ralph-tui-prd/SKILL.md` (expand HOME)
FS-->>CLI: file exists? / content
alt personal found & non-empty
CLI->>CLI: set parsedArgs.prdSkillSource = personal path
CLI->>Log: log success message (rgba(40,167,69,0.5))
else
CLI->>FS: check repo `.kiro/skills/ralph-tui-prd/SKILL.md`
FS-->>CLI: file exists? / content
alt repo found & non-empty
CLI->>CLI: set parsedArgs.prdSkillSource = repo path
CLI->>Log: log success message (rgba(40,167,69,0.5))
else
CLI->>Log: no bundled skill found
end
end
else
CLI->>Log: agent has no skillsPaths
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #194 +/- ##
==========================================
- Coverage 44.87% 43.87% -1.00%
==========================================
Files 79 83 +4
Lines 22988 23963 +975
==========================================
+ Hits 10316 10514 +198
- Misses 12672 13449 +777
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/plugins/agents/builtin/kiro.ts (1)
169-239: Centralise model selection configuration to avoid inconsistency between choices and validation.The model choice value uses
''(empty string) for "Auto" butvalidateModelincludes'auto'in its allowlist. If someone manually configuredmodel: "auto", it would pass validation but then add--model autoto the CLI—potentially mismatched with the UI intent. The model list is also duplicated across the choices array and the validModels check. Extract both to a shared constant and ensure consistency (e.g., use'auto'consistently across choices and validation).
🤖 Fix all issues with AI agents
In `@src/commands/create-prd.tsx`:
- Around line 128-162: The repo-skill lookup in loadBundledPrdSkill currently
hardcodes process.cwd(), causing bundled skills to be missed when create-prd is
run with --cwd; update the function to resolve the repo path from the agent
context (e.g., use a repoRoot = agent.meta.cwd || agent.meta.root ||
process.cwd()) and join skillsPaths.repo against that repoRoot instead of
process.cwd() when constructing the repo skillFile (refer to loadBundledPrdSkill
and the skillsPaths.repo usage); make the same change for the similar lookup
around lines noted (the other repo lookup block) so both repo-skill searches
respect the provided --cwd.
🧹 Nitpick comments (1)
src/plugins/agents/builtin/kiro.ts (1)
46-62: Validate and normalise the configured model before use.
At the moment any non-empty string is accepted; a stale config will be passed through to the CLI and fail later. Consider trimming and checking viavalidateModelduring initialise so invalid values are caught early.💡 Suggested adjustment
- if (typeof config.model === 'string' && config.model.length > 0) { - this.model = config.model; - } + if (typeof config.model === 'string') { + const model = config.model.trim(); + if (model) { + const error = this.validateModel(model); + if (!error) { + this.model = model; + } + } + }
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/plugins/agents/builtin/kiro.ts`:
- Around line 66-71: Currently an invalid config.model value is silently
ignored; change the logic in the initialization block that checks config.model
so that when typeof config.model === 'string' and the trimmed model fails
this.validateModel(model) you propagate an error instead of dropping it: throw a
descriptive Error (or rethrow a validation error) that includes the invalid
model string so callers see the failure, otherwise set this.model when
validation passes. Reference symbols: config.model, this.validateModel,
this.model in the kiro initialization code.
3b43c2f to
a576e22
Compare
The create-prd command now automatically loads the ralph-tui-prd skill from the agent's configured skills directory (e.g., ~/.kiro/skills/). This ensures the AI agent receives proper formatting instructions for generating PRDs with ### US-XXX: sections that ralph-tui can parse. Changes: - Add loadBundledPrdSkill() to load skill from agent.meta.skillsPaths - Auto-load skill in runChatMode() when no custom skill specified - Export function for testing Test coverage: - Add tests/commands/create-prd.test.ts with 19 tests - Tests for parseCreatePrdArgs argument parsing - Tests for loadBundledPrdSkill with mock file system
Agents like Kiro output colored text with ANSI escape codes. These codes were being saved to the PRD markdown file, causing the parser to fail when looking for '### US-XXX:' patterns. Changes: - Use existing stripAnsiCodes() from output-formatting.ts (no duplication) - Strip ANSI codes before writing PRD file and updating state - Add tests/tui/prd-chat-app.test.ts with 7 tests for ANSI stripping Fixes PRD parsing error: 'PRD has no user stories'
- Add tests for printCreatePrdHelp and --stories argument parsing - Add tests for repo skills fallback path in loadBundledPrdSkill - Add tests for output formatting functions (formatToolName, formatPath, etc.) - Add tests for PRD questions module (getQuestionCount, getQuestionById) Coverage: 40.47% function coverage (was 39.13%)
Kiro CLI supports --model flag for per-session model selection. This adds model configuration to the Kiro agent plugin. Changes: - Add model property and initialize from config - Add --model flag to buildArgs when model is configured - Add model setup question with valid Kiro model choices - Update validateModel to check valid model names Valid models: auto, claude-sonnet4, claude-sonnet4.5, claude-haiku4.5, claude-opus4.5 Usage: ralph-tui run --agent kiro --model claude-opus4.5
- Extract VALID_KIRO_MODELS constant to avoid duplication - Validate and trim model during initialize (fail early) - Remove 'auto' from valid models (empty string = Auto) - Update error message to clarify empty string option
…label - Replace deprecated installSkill()/isSkillInstalled() with installSkillsForAgent()/isSkillInstalledAt() in setup wizard - Skills now install to the selected agent's personal directory (e.g., ~/.kiro/skills/ for Kiro, ~/.claude/skills/ for Claude) - Ensure 'ralph' label is always included in beads conversion while preserving the config.toml labels fallback - Update wizard tests to mock the new agent-aware functions
88c5b71 to
3db7ef6
Compare
wizard.test.ts mocks skill-installer.js via bun's process-level mock.module(). When both run in the same batch (bun test src/setup/), the mock leaks into skill-installer.test.ts despite mock.restore(). Fix: Run wizard.test.ts in its own batch, matching the established pattern used for beads-bv and beads-rust isolation.
PrdChatApp.tsx only uses parsePrdMarkdown from the prd module, but was importing from the barrel (prd/index.js) which transitively loads prd/wizard.ts and prd/generator.ts. These unused modules counted as 0% covered in the tests/ batch, dragging function coverage below 40%. Import directly from prd/parser.js to avoid this side effect.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Thanks @medhatgalal Two behavioral fixes per review feedback:
Merged! |
feat(kiro): fix PRD creation and add model selection
Summary
This PR fixes two issues with the Kiro CLI agent and adds model selection support.
Bug Fixes
1. Auto-load bundled PRD skill from agent's skills directory
The
create-prdcommand now automatically loads theralph-tui-prdskill from the agent's configured skills directory (e.g.,~/.kiro/skills/). This ensures the AI agent receives proper formatting instructions for generating PRDs with### US-XXX:sections that ralph-tui can parse.Changes:
loadBundledPrdSkill()to load skill fromagent.meta.skillsPathsrunChatMode()when no custom skill specified2. Strip ANSI codes from PRD content before saving
Agents like Kiro output colored text with ANSI escape codes. These codes were being saved to the PRD markdown file, causing the parser to fail when looking for
### US-XXX:patterns.Changes:
stripAnsiCodes()from output-formatting.ts (no duplication)New Feature
3. Kiro model selection support
Kiro CLI supports
--modelflag for per-session model selection. This adds model configuration to the Kiro agent plugin.Changes:
--modelflag to buildArgs when model is configuredvalidateModelto check valid model namesValid models: auto, claude-sonnet4, claude-sonnet4.5, claude-haiku4.5, claude-opus4.5
Usage:
Testing
Manual Testing
Tested full workflow:
ralph-tui setup- selected Kiro agentralph-tui create-prd --timeout 0- PRD generated with proper### US-XXX:formatralph-tui convert --to json- converted successfullyralph-tui run --prd ./tasks/prd.json- executed tasksFixes PRD parsing error: "PRD has no user stories"
Summary by CodeRabbit
New Features
Improvements
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.