feat: improve scope up and down command & parse-prd improvements#1079
feat: improve scope up and down command & parse-prd improvements#1079Crunchyman-ralph merged 2 commits intonextfrom
Conversation
🦋 Changeset detectedLatest commit: 4107f83 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis set of changes enhances task scoping and AI integration by enforcing stricter schema validation, improving handling of task IDs, and ensuring required fields like Changes
Sequence Diagram(s)sequenceDiagram
participant CLI/User
participant CommandsModule
participant DirectFunction (ScopeUp/Down)
participant TaskManager
participant AIProvider
CLI/User->>CommandsModule: Run scope-up/scope-down (with --research)
CommandsModule->>DirectFunction: Call scopeUpDirect/scopeDownDirect (pass research flag, IDs as numbers)
DirectFunction->>TaskManager: scopeUpTask/scopeDownTask (pass context with research, numeric IDs)
TaskManager->>AIProvider: generateObject (with strict schema, required fields)
AIProvider->>AIProvider: Attempt JSON parse
AIProvider->>AIProvider: If parse fails, use jsonrepair
AIProvider-->>TaskManager: Return parsed/repaired object
TaskManager-->>DirectFunction: Return validated, normalized tasks
DirectFunction-->>CommandsModule: Return output
CommandsModule-->>CLI/User: Output result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
scripts/modules/commands.js (1)
1478-1484: Good propagation of theresearchflag, but consider deduplicating context-builder logic
outputType: 'cli'andresearch: options.research || falsecorrectly bring this handler in line with the other commands that already embed these keys in the context object.However, almost every command now hand-rolls a near-identical context literal (
projectRoot,tag,commandName,outputType, mayberesearch). Duplicating this in ~30 places is brittle and makes future context changes error-prone.Nice-to-have: extract a small helper such as
buildCliContext(commandName, { tag, projectRoot, research })inutils.js, then use it across all handlers to keep things DRY.
| const prdSingleTaskSchema = z.object({ | ||
| id: z.number().int().positive(), | ||
| id: z.number(), | ||
| title: z.string().min(1), | ||
| description: z.string().min(1), | ||
| details: z.string().nullable(), | ||
| testStrategy: z.string().nullable(), | ||
| priority: z.enum(['high', 'medium', 'low']).nullable(), | ||
| dependencies: z.array(z.number().int().positive()).nullable(), | ||
| status: z.string().nullable() | ||
| details: z.string(), | ||
| testStrategy: z.string(), | ||
| priority: z.enum(['high', 'medium', 'low']), | ||
| dependencies: z.array(z.number()), | ||
| status: z.string() | ||
| }); |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Schema changes improve data consistency but consider ID validation.
The schema modifications enforce stricter validation by making key fields required instead of nullable, which is excellent for data consistency. The explicit priority enum ensures valid values.
However, removing the positive constraint from id and dependencies fields could allow invalid negative or zero IDs. Consider whether this is intentional:
- id: z.number(),
+ id: z.number().positive(),- dependencies: z.array(z.number()),
+ dependencies: z.array(z.number().positive()),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const prdSingleTaskSchema = z.object({ | |
| id: z.number().int().positive(), | |
| id: z.number(), | |
| title: z.string().min(1), | |
| description: z.string().min(1), | |
| details: z.string().nullable(), | |
| testStrategy: z.string().nullable(), | |
| priority: z.enum(['high', 'medium', 'low']).nullable(), | |
| dependencies: z.array(z.number().int().positive()).nullable(), | |
| status: z.string().nullable() | |
| details: z.string(), | |
| testStrategy: z.string(), | |
| priority: z.enum(['high', 'medium', 'low']), | |
| dependencies: z.array(z.number()), | |
| status: z.string() | |
| }); | |
| const prdSingleTaskSchema = z.object({ | |
| id: z.number().positive(), | |
| title: z.string().min(1), | |
| description: z.string().min(1), | |
| details: z.string(), | |
| testStrategy: z.string(), | |
| priority: z.enum(['high', 'medium', 'low']), | |
| dependencies: z.array(z.number().positive()), | |
| status: z.string() | |
| }); |
🤖 Prompt for AI Agents
In scripts/modules/task-manager/parse-prd.js around lines 25 to 34, the schema
for prdSingleTaskSchema currently allows any number for the id and dependencies
fields, including zero or negative values. To ensure data consistency and
prevent invalid IDs, update the schema to enforce that id and each dependency
number are positive integers by adding a positive number constraint to these
fields.
…ltoledano#1079) * feat: improve scope up and down command & parse-prd improvements * chore: run format
…ltoledano#1079) * feat: improve scope up and down command & parse-prd improvements * chore: run format
…ltoledano#1079) * feat: improve scope up and down command & parse-prd improvements * chore: run format
…ltoledano#1079) * feat: improve scope up and down command & parse-prd improvements * chore: run format
…ltoledano#1079) * feat: improve scope up and down command & parse-prd improvements * chore: run format
What type of PR is this?
Description
Related Issues
How to Test This
# Example commands or stepsExpected result:
Contributor Checklist
npm run changesetnpm testnpm run format-check(ornpm run formatto fix)Changelog Entry
For Maintainers
Summary by CodeRabbit
New Features
Bug Fixes
Chores
jsonrepairpackage for improved JSON handling.Style