feat: add "next" command to new command structure#1312
feat: add "next" command to new command structure#1312Crunchyman-ralph merged 4 commits intonextfrom
Conversation
🦋 Changeset detectedLatest commit: ddd8756 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 |
WalkthroughAdds a new CLI NextCommand (implementation, registration, and export), removes the legacy scripts-based "next" command, tweaks CLI header formatting, and adds a changeset entry documenting the improvement. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant CLI as CLI NextCommand
participant Core as TaskMasterCore
participant Storage as Storage Provider
User->>CLI: tm next [-t tag] [-f text|json] [--silent] [-p project]
CLI->>CLI: validate options
alt core not initialized
CLI->>Core: createTaskMasterCore({ projectPath })
end
CLI->>Core: getNextTask(tag)
Core->>Storage: query next task
Storage-->>Core: task | none
Core-->>CLI: NextTaskResult
CLI->>CLI: save last result
opt not silent
alt format=json
CLI->>User: print JSON result
else format=text
alt task found
CLI->>User: header + task details + storage note
else no task
CLI->>User: header + no-task warning + storage note
end
end
end
CLI-->>User: exit
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
apps/cli/src/command-registry.ts(2 hunks)apps/cli/src/commands/next.command.ts(1 hunks)apps/cli/src/index.ts(1 hunks)apps/cli/src/ui/components/header.component.ts(1 hunks)scripts/modules/commands.js(0 hunks)
💤 Files with no reviewable changes (1)
- scripts/modules/commands.js
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/AGENTS.md:0-0
Timestamp: 2025-09-24T15:12:58.855Z
Learning: Applies to assets/.claude/commands/taskmaster-next.md : Create .claude/commands/taskmaster-next.md with steps to run task-master next, then task-master show <id>, summarize, and suggest first step
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/AGENTS.md:0-0
Timestamp: 2025-09-24T15:12:58.855Z
Learning: Applies to assets/.claude/commands/taskmaster-complete.md : Create .claude/commands/taskmaster-complete.md with steps to review task, verify, run tests, set status done, and show next task
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/commands.mdc:0-0
Timestamp: 2025-07-18T17:08:48.695Z
Learning: Applies to scripts/modules/commands.js : Export the registerCommands function and keep the CLI setup code clean and maintainable.
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/commands.mdc:0-0
Timestamp: 2025-07-31T22:07:49.716Z
Learning: Applies to scripts/modules/commands.js : Export the registerCommands function and keep the CLI setup code clean and maintainable.
📚 Learning: 2025-09-24T15:12:58.855Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/AGENTS.md:0-0
Timestamp: 2025-09-24T15:12:58.855Z
Learning: Applies to assets/.claude/commands/taskmaster-next.md : Create .claude/commands/taskmaster-next.md with steps to run task-master next, then task-master show <id>, summarize, and suggest first step
Applied to files:
apps/cli/src/command-registry.ts
🧬 Code graph analysis (3)
apps/cli/src/ui/components/header.component.ts (1)
tests/unit/ui.test.js (1)
chalk(17-17)
apps/cli/src/commands/next.command.ts (3)
packages/tm-core/src/types/index.ts (1)
StorageType(11-11)apps/cli/src/ui/components/header.component.ts (1)
displayHeader(20-43)apps/cli/src/ui/components/task-detail.component.ts (1)
displayTaskDetails(274-340)
apps/cli/src/command-registry.ts (2)
apps/cli/src/commands/next.command.ts (1)
NextCommand(38-242)apps/cli/src/index.ts (1)
NextCommand(9-9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
🔇 Additional comments (14)
apps/cli/src/ui/components/header.component.ts (1)
28-30: LGTM! Consistent spacing improvement.The addition of an extra space after the emoji ensures uniform spacing in tag-related messages.
apps/cli/src/commands/next.command.ts (10)
1-32: LGTM! Well-structured interfaces.The imports and type definitions are appropriate. The use of
Exclude<StorageType, 'auto'>inNextTaskResultclearly documents that the resolved storage type should never be 'auto'.
42-54: LGTM! Constructor follows Commander best practices.The constructor properly configures the command with clear options and appropriate defaults. The fluent API usage aligns with Commander conventions.
94-103: LGTM! Clear validation logic.The format validation is straightforward and provides helpful error messages. The boolean return pattern works well with the early-exit check in
executeCommand.
108-112: LGTM! Proper lazy initialization.The idempotent initialization pattern ensures the core is created only once, which is the correct behavior for command reuse.
142-158: LGTM! Clean format delegation.The switch statement cleanly delegates to format-specific display methods with an appropriate default.
163-165: LGTM! Simple JSON output.The JSON format output is straightforward and properly formatted for programmatic consumption.
170-208: LGTM! Well-structured text output.The text display properly handles both cases:
- Empty state with a clear warning box
- Task display with custom header indicating "next task" context
Good reuse of existing UI components maintains consistency across commands.
213-232: LGTM! Clean lifecycle methods.The result management and cleanup methods are straightforward:
setLastResult/getLastResultenable programmatic accesscleanupproperly closes resources and clears references
237-241: LGTM! Standard registration pattern.The static
registermethod follows Commander best practices for command registration and returns the instance for potential further configuration.
59-89: Replaceprocess.exit()with error throwing for library compatibility.Lines 63 and 87 call
process.exit(1)directly, which is problematic for library usage:
- Prevents graceful error handling by calling code
- Makes the command untestable in isolation
- Prevents proper resource cleanup in error scenarios
- Incompatible with programmatic usage (e.g., when
getLastResult()is used)Apply this diff to throw errors instead:
try { // Validate options if (!this.validateOptions(options)) { - process.exit(1); + throw new Error('Invalid command options'); } // Initialize tm-core await this.initializeCore(options.project || process.cwd()); // Get next task from core const result = await this.getNextTask(options); // Store result for programmatic access this.setLastResult(result); // Display results if (!options.silent) { this.displayResults(result, options); } } catch (error: any) { const msg = error?.getSanitizedDetails?.() ?? { message: error?.message ?? String(error) }; - console.error(chalk.red(`Error: ${msg.message || 'Unexpected error'}`)); - if (error.stack && process.env.DEBUG) { - console.error(chalk.gray(error.stack)); + if (!options.silent) { + console.error(chalk.red(`Error: ${msg.message || 'Unexpected error'}`)); + if (error.stack && process.env.DEBUG) { + console.error(chalk.gray(error.stack)); + } } - process.exit(1); + throw error; }The caller (Commander's action handler) will handle the thrown error appropriately, allowing the CLI entry point to decide when to call
process.exit().⛔ Skipped due to learnings
Learnt from: joedanz PR: eyaltoledano/claude-task-master#748 File: scripts/modules/task-manager/parse-prd.js:726-733 Timestamp: 2025-07-21T17:51:07.239Z Learning: In CLI contexts within task-manager modules like scripts/modules/task-manager/parse-prd.js, using process.exit(1) for validation failures and error conditions is correct and preferred over throwing errors, as it provides immediate termination with appropriate exit codes for scripting. The code should distinguish between MCP contexts (throw errors) and CLI contexts (use process.exit).Learnt from: CR PR: eyaltoledano/claude-task-master#0 File: .cursor/rules/commands.mdc:0-0 Timestamp: 2025-07-18T17:08:48.695Z Learning: Applies to scripts/modules/commands.js : Check that required parameters are provided, provide clear error messages when parameters are missing, and use early returns with process.exit(1) for validation failures.Learnt from: CR PR: eyaltoledano/claude-task-master#0 File: .cursor/rules/commands.mdc:0-0 Timestamp: 2025-07-31T22:07:49.716Z Learning: Applies to scripts/modules/commands.js : Check that required parameters are provided, provide clear error messages when parameters are missing, and use early returns with process.exit(1) for validation failures.apps/cli/src/command-registry.ts (2)
11-11: LGTM! Appropriate import addition.The import of
NextCommandfollows the established pattern for command imports.
49-54: LGTM! Correct command registration.The NextCommand is properly registered with:
- Correct name: 'next'
- Clear description: 'Find the next available task to work on'
- Appropriate category: 'task'
- Positioned logically between 'show' and 'start' commands
apps/cli/src/index.ts (1)
9-9: LGTM! Public API expansion.The export of
NextCommandproperly expands the CLI public API surface, following the established pattern for command exports.
There was a problem hiding this comment.
Actionable comments posted: 6
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (7)
.changeset/config.json(1 hunks).changeset/metal-rocks-help.md(1 hunks)apps/cli/src/command-registry.ts(2 hunks)apps/cli/src/commands/next.command.ts(1 hunks)apps/cli/src/index.ts(1 hunks)apps/cli/src/ui/components/header.component.ts(1 hunks)scripts/modules/commands.js(0 hunks)
💤 Files with no reviewable changes (1)
- scripts/modules/commands.js
🧰 Additional context used
📓 Path-based instructions (3)
.changeset/*
📄 CodeRabbit inference engine (.cursor/rules/new_features.mdc)
Create appropriate changesets for new features, use semantic versioning, include tagged system information in release notes, and document breaking changes if any.
Files:
.changeset/config.json.changeset/metal-rocks-help.md
.changeset/*.md
📄 CodeRabbit inference engine (.cursor/rules/changeset.mdc)
.changeset/*.md: When runningnpm run changesetornpx changeset add, provide a concise summary of the changes for theCHANGELOG.mdin imperative mood, typically a single line, and not a detailed Git commit message.
The changeset summary should be user-facing, describing what changed in the released version that is relevant to users or consumers of the package.
Do not use your detailed Git commit message body as the changeset summary.
Files:
.changeset/metal-rocks-help.md
.changeset/**/*.md
📄 CodeRabbit inference engine (CLAUDE.md)
Changeset entries should be user-facing, describing the end-user impact rather than code specifics
Files:
.changeset/metal-rocks-help.md
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/AGENTS.md:0-0
Timestamp: 2025-09-24T15:12:58.855Z
Learning: Applies to assets/.claude/commands/taskmaster-next.md : Create .claude/commands/taskmaster-next.md with steps to run task-master next, then task-master show <id>, summarize, and suggest first step
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/AGENTS.md:0-0
Timestamp: 2025-09-24T15:12:58.855Z
Learning: Applies to assets/.claude/commands/taskmaster-complete.md : Create .claude/commands/taskmaster-complete.md with steps to review task, verify, run tests, set status done, and show next task
📚 Learning: 2025-09-24T15:12:58.855Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/AGENTS.md:0-0
Timestamp: 2025-09-24T15:12:58.855Z
Learning: Applies to assets/.claude/commands/taskmaster-next.md : Create .claude/commands/taskmaster-next.md with steps to run task-master next, then task-master show <id>, summarize, and suggest first step
Applied to files:
apps/cli/src/command-registry.ts.changeset/metal-rocks-help.mdapps/cli/src/commands/next.command.ts
📚 Learning: 2025-09-24T15:12:12.658Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/.windsurfrules:0-0
Timestamp: 2025-09-24T15:12:12.658Z
Learning: Use task-master next to select the next actionable task with all dependencies satisfied
Applied to files:
.changeset/metal-rocks-help.md
🧬 Code graph analysis (3)
apps/cli/src/command-registry.ts (2)
apps/cli/src/commands/next.command.ts (1)
NextCommand(38-242)apps/cli/src/index.ts (1)
NextCommand(9-9)
apps/cli/src/ui/components/header.component.ts (1)
tests/unit/ui.test.js (1)
chalk(17-17)
apps/cli/src/commands/next.command.ts (3)
packages/tm-core/src/types/index.ts (1)
StorageType(11-11)apps/cli/src/ui/components/header.component.ts (1)
displayHeader(20-43)apps/cli/src/ui/components/task-detail.component.ts (1)
displayTaskDetails(274-340)
🪛 LanguageTool
.changeset/metal-rocks-help.md
[grammar] ~4-~4: There might be a mistake here.
Context: --- "task-master-ai": minor --- Improve next command to work with remote
(QB_NEW_EN)
[grammar] ~5-~5: There might be a mistake here.
Context: ...Improve next command to work with remote
(QB_NEW_EN_OTHER)
🪛 markdownlint-cli2 (0.18.1)
.changeset/metal-rocks-help.md
5-5: First line in a file should be a top-level heading
(MD041, first-line-heading, first-line-h1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
🔇 Additional comments (5)
apps/cli/src/commands/next.command.ts (1)
51-54: Process.exit usage is correct in CLI commands
These files live purely in the CLI context, where terminating with the appropriate exit code is intended. No changes needed.Likely an incorrect or invalid review comment.
.changeset/config.json (1)
14-16: Confirm changesets ignore list and base branch
- Ignored packages “docs” and “@tm/claude-code-plugin” exist and are appropriate.
- .changeset/config.json uses baseBranch “main” while this PR targets “next”; if releases are made from “next”, update baseBranch to “next” or ensure CI promotes changes from “next” → “main” correctly.
apps/cli/src/ui/components/header.component.ts (1)
28-31: No snapshot updates required
Search found no references to the updated🏷 tag:string in tests or snapshots.apps/cli/src/command-registry.ts (2)
11-11: LGTM!The import statement follows the established pattern and is correctly placed alphabetically with other command imports.
49-54: LGTM!The command metadata entry is correctly structured and follows the established pattern. The metadata accurately reflects the NextCommand implementation:
- Appropriate category ('task')
- Description matches the command's functionality
- Consistent casting pattern (
as any)- Logical placement in the registry
The integration is complete with the NextCommand class implementation and public export confirmed in the related files.
| switch (format) { | ||
| case 'json': | ||
| this.displayJson(result); | ||
| break; | ||
|
|
||
| case 'text': | ||
| default: | ||
| this.displayText(result); | ||
| break; | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Text/JSON outputs: stable and good. Minor UX note.
Consider printing a brief hint when no tasks are available (e.g., try task-master list --status todo).
No code change required now; optional enhancement.
Also applies to: 170-208
🤖 Prompt for AI Agents
In apps/cli/src/commands/next.command.ts around lines 148-157 (and also apply
same change to 170-208), the UI currently displays nothing special when there
are no tasks; add a short user hint when the result is empty — detect when
result has no tasks and print a concise message like "No tasks found. Try:
task-master list --status todo" (or similar) after the existing JSON/text output
logic, ensuring the hint appears only when the task list is empty and respects
the selected output format (plain text for text mode, or an additional
field/message for JSON mode).
4f14df8 to
8d703ba
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
apps/cli/src/commands/next.command.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/AGENTS.md:0-0
Timestamp: 2025-09-24T15:12:58.855Z
Learning: Applies to assets/.claude/commands/taskmaster-next.md : Create .claude/commands/taskmaster-next.md with steps to run task-master next, then task-master show <id>, summarize, and suggest first step
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: assets/AGENTS.md:0-0
Timestamp: 2025-09-24T15:12:58.855Z
Learning: Applies to assets/.claude/commands/taskmaster-complete.md : Create .claude/commands/taskmaster-complete.md with steps to review task, verify, run tests, set status done, and show next task
📚 Learning: 2025-07-21T17:51:07.239Z
Learnt from: joedanz
PR: eyaltoledano/claude-task-master#748
File: scripts/modules/task-manager/parse-prd.js:726-733
Timestamp: 2025-07-21T17:51:07.239Z
Learning: In CLI contexts within task-manager modules like scripts/modules/task-manager/parse-prd.js, using process.exit(1) for validation failures and error conditions is correct and preferred over throwing errors, as it provides immediate termination with appropriate exit codes for scripting. The code should distinguish between MCP contexts (throw errors) and CLI contexts (use process.exit).
Applied to files:
apps/cli/src/commands/next.command.ts
📚 Learning: 2025-07-18T17:18:17.759Z
Learnt from: CR
PR: eyaltoledano/claude-task-master#0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-07-18T17:18:17.759Z
Learning: Applies to mcp-server/src/tools/utils.js : Use `normalizeProjectRoot(rawPath, log)`, `getRawProjectRootFromSession(session, log)`, and `withNormalizedProjectRoot(executeFn)` in `mcp-server/src/tools/utils.js` to ensure project root paths are normalized for MCP tools.
Applied to files:
apps/cli/src/commands/next.command.ts
🧬 Code graph analysis (1)
apps/cli/src/commands/next.command.ts (3)
packages/tm-core/src/types/index.ts (1)
StorageType(11-11)apps/cli/src/ui/components/header.component.ts (1)
displayHeader(20-43)apps/cli/src/ui/components/task-detail.component.ts (1)
displayTaskDetails(274-340)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
🔇 Additional comments (5)
apps/cli/src/commands/next.command.ts (5)
1-33: LGTM! Type safety correctly implemented.The imports, interfaces, and type definitions are well-structured. The
Exclude<StorageType, 'auto'>type inNextTaskResultis now safe because of the runtime validation at lines 128-130. TypeScript's control flow analysis narrows the type after the throw, making line 137's return type-safe without any explicit cast. This precise typing communicates to consumers that they'll never receive'auto'as the storage type.
39-55: LGTM! Clean Commander integration.The constructor properly extends
Commander.Commandand configures the command with appropriate options. The delegation toexecuteCommandkeeps the action handler thin and testable.
94-111: LGTM! Validation and initialization are correct.The validation ensures only valid formats are accepted, and
initializeCoreproperly normalizes the project path to an absolute path before passing it tocreateTaskMasterCore, addressing the previous review concern.
116-139: LGTM! Storage type validation correctly implemented.The runtime check at lines 128-130 prevents
'auto'from reaching the return statement, and TypeScript's control flow analysis correctly narrows the type. This addresses the previous review concern about type safety without requiring an unsafe cast.
144-246: LGTM! Display logic and resource management are well-implemented.The display methods provide clean output in both JSON and text formats. The text format includes helpful context:
- Tag header via
displayHeader- Boxed warning with actionable tip when no tasks are available (lines 195-197)
- Task details with custom header when a task is found
The cleanup method properly releases resources, and the static
registermethod follows Commander conventions for command registration.
This PR was automatically generated to update documentation based on recent changes. Original commit: feat: add next command to new command structure (#1312)\n\n\n Co-authored-by: Claude <claude-assistant@anthropic.com>
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