Skip to content

feat: improve scope up and down command & parse-prd improvements#1079

Merged
Crunchyman-ralph merged 2 commits intonextfrom
feat/improve.scope.up.and.scope.down
Aug 3, 2025
Merged

feat: improve scope up and down command & parse-prd improvements#1079
Crunchyman-ralph merged 2 commits intonextfrom
feat/improve.scope.up.and.scope.down

Conversation

@Crunchyman-ralph
Copy link
Collaborator

@Crunchyman-ralph Crunchyman-ralph commented Aug 3, 2025

What type of PR is this?

  • 🐛 Bug fix
  • ✨ Feature
  • 🔌 Integration
  • 📝 Docs
  • 🧹 Refactor
  • Other:

Description

Related Issues

How to Test This

# Example commands or steps

Expected result:

Contributor Checklist

  • Created changeset: npm run changeset
  • Tests pass: npm test
  • Format check passes: npm run format-check (or npm run format to fix)
  • Addressed CodeRabbit comments (if any)
  • Linked related issues (if any)
  • Manually tested the changes

Changelog Entry


For Maintainers

  • PR title follows conventional commits
  • Target branch correct
  • Labels added
  • Milestone assigned (if applicable)

Summary by CodeRabbit

  • New Features

    • Improved compatibility with AI providers by adding automatic repair for malformed JSON responses and enforcing JSON mode for Perplexity outputs.
    • Enhanced task scoping tools to support a research mode flag for more flexible task management.
  • Bug Fixes

    • Resolved issues with task ID handling in scope-up and scope-down tools, ensuring accurate task identification and manipulation.
    • Fixed missing or incorrect fields in AI-generated task outputs, including required priority and status fields.
  • Chores

    • Updated dependencies to include the jsonrepair package for improved JSON handling.
  • Style

    • Improved readability of error messages for failed git operations.

@changeset-bot
Copy link

changeset-bot bot commented Aug 3, 2025

🦋 Changeset detected

Latest 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

@Crunchyman-ralph Crunchyman-ralph changed the base branch from main to next August 3, 2025 12:07
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 3, 2025

Walkthrough

This set of changes enhances task scoping and AI integration by enforcing stricter schema validation, improving handling of task IDs, and ensuring required fields like priority are present in prompts and outputs. It introduces robust JSON repair for AI outputs, updates dependencies, and refines CLI and internal logic to support research mode and improved compatibility with various AI providers.

Changes

Cohort / File(s) Change Summary
Scope Adjustment Prompts & Schemas
.changeset/fuzzy-words-count.md, scripts/modules/task-manager/scope-adjustment.js
Ensures priority is required in scope-up/down prompts and schemas; clarifies subtask ID types; tightens schema defaults; adds post-processing for missing fields; dynamically sets AI role.
Task ID Parsing & Research Flag Propagation
.changeset/tender-trams-refuse.md, mcp-server/src/core/direct-functions/scope-down.js, mcp-server/src/core/direct-functions/scope-up.js, scripts/modules/commands.js
Fixes task ID parsing by converting string IDs to integers; propagates research flag through CLI and direct function calls for scope adjustment.
AI Provider JSON Handling & Schema Compatibility
.changeset/vast-sites-leave.md, src/ai-providers/base-provider.js, src/ai-providers/perplexity.js
Adds automatic JSON repair for malformed AI responses; removes nullable/defaults from schemas for compatibility; forces JSON mode for Perplexity provider; updates error handling in base provider.
Task Parsing and Schema Enforcement
scripts/modules/task-manager/parse-prd.js
Loosens ID type, removes nullable fields, enforces required fields and sensible defaults for tasks parsed from AI responses.
Dependency Update
package.json
Adds jsonrepair dependency for JSON repair functionality.
Error Message Formatting
.github/scripts/tag-extension.mjs
Refactors error messages to use multi-line template strings for readability; no logic 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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/improve.scope.up.and.scope.down

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
scripts/modules/commands.js (1)

1478-1484: Good propagation of the research flag, but consider deduplicating context-builder logic

outputType: 'cli' and research: options.research || false correctly 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, maybe research ). 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 }) in utils.js, then use it across all handlers to keep things DRY.

Comment on lines 25 to 34
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()
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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.

Suggested change
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.

@Crunchyman-ralph Crunchyman-ralph merged commit e495b2b into next Aug 3, 2025
4 checks passed
@github-actions github-actions bot mentioned this pull request Aug 8, 2025
Crunchyman-ralph added a commit to iamladi/claude-task-master that referenced this pull request Aug 11, 2025
…ltoledano#1079)

* feat: improve scope up and down command & parse-prd improvements

* chore: run format
Crunchyman-ralph added a commit to iamladi/claude-task-master that referenced this pull request Aug 11, 2025
…ltoledano#1079)

* feat: improve scope up and down command & parse-prd improvements

* chore: run format
stephanschielke pushed a commit to stephanschielke/cursor-task-master that referenced this pull request Aug 22, 2025
…ltoledano#1079)

* feat: improve scope up and down command & parse-prd improvements

* chore: run format
@coderabbitai coderabbitai bot mentioned this pull request Aug 22, 2025
16 tasks
stephanschielke pushed a commit to stephanschielke/cursor-task-master that referenced this pull request Aug 22, 2025
…ltoledano#1079)

* feat: improve scope up and down command & parse-prd improvements

* chore: run format
sfc-gh-dflippo pushed a commit to sfc-gh-dflippo/task-master-ai that referenced this pull request Dec 4, 2025
…ltoledano#1079)

* feat: improve scope up and down command & parse-prd improvements

* chore: run format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant