Compare commits
16 Commits
crunchyman
...
crunchyman
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2ac3a4ef4 | ||
|
|
b2396fd8fe | ||
|
|
a99b2b20b3 | ||
|
|
4136ef5679 | ||
|
|
a56a3628b3 | ||
|
|
9dc5e75760 | ||
|
|
16f4d4b932 | ||
|
|
7fef5ab488 | ||
|
|
38e416ef33 | ||
|
|
aa185b28b2 | ||
|
|
76618187f6 | ||
|
|
757fd478d2 | ||
|
|
6e6407f683 | ||
|
|
80f933cd82 | ||
|
|
2c3986c097 | ||
|
|
7086a77625 |
@@ -2,4 +2,4 @@
|
||||
"task-master-ai": patch
|
||||
---
|
||||
|
||||
Fix workflows
|
||||
Add CI for testing
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"task-master-ai": patch
|
||||
---
|
||||
|
||||
Added changeset config #39
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"task-master-ai": minor
|
||||
---
|
||||
|
||||
add github actions to automate github and npm releases
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"task-master-ai": minor
|
||||
---
|
||||
|
||||
Implement MCP server for all commands using tools.
|
||||
5
.changeset/red-lights-mix.md
Normal file
5
.changeset/red-lights-mix.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"task-master-ai": patch
|
||||
---
|
||||
|
||||
Fix github actions creating npm releases on next branch push
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"task-master-ai": patch
|
||||
---
|
||||
|
||||
Fix addTask tool `projectRoot not defined`
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"task-master-ai": patch
|
||||
---
|
||||
|
||||
fix mcp server not connecting to cursor
|
||||
@@ -2,9 +2,7 @@
|
||||
"mcpServers": {
|
||||
"taskmaster-ai": {
|
||||
"command": "node",
|
||||
"args": [
|
||||
"./mcp-server/server.js"
|
||||
]
|
||||
"args": ["./mcp-server/server.js"]
|
||||
}
|
||||
}
|
||||
}
|
||||
95
.github/workflows/ci.yml
vendored
Normal file
95
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- next
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- next
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install Dependencies
|
||||
id: install
|
||||
run: npm ci
|
||||
timeout-minutes: 2
|
||||
|
||||
- name: Cache node_modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
|
||||
|
||||
format-check:
|
||||
needs: setup
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Restore node_modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
|
||||
|
||||
- name: Format Check
|
||||
run: npm run format-check
|
||||
env:
|
||||
FORCE_COLOR: 1
|
||||
|
||||
test:
|
||||
needs: setup
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Restore node_modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
|
||||
|
||||
- name: Run Tests
|
||||
run: |
|
||||
npm run test:coverage -- --coverageThreshold '{"global":{"branches":0,"functions":0,"lines":0,"statements":0}}' --detectOpenHandles --forceExit
|
||||
env:
|
||||
NODE_ENV: test
|
||||
CI: true
|
||||
FORCE_COLOR: 1
|
||||
timeout-minutes: 10
|
||||
|
||||
- name: Upload Test Results
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-results
|
||||
path: |
|
||||
test-results
|
||||
coverage
|
||||
junit.xml
|
||||
retention-days: 30
|
||||
15
.github/workflows/release.yml
vendored
15
.github/workflows/release.yml
vendored
@@ -3,7 +3,6 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- next
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -15,9 +14,21 @@ jobs:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'npm'
|
||||
|
||||
- name: Cache node_modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
node_modules
|
||||
*/*/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
run: npm ci
|
||||
timeout-minutes: 2
|
||||
|
||||
- name: Create Release Pull Request or Publish to npm
|
||||
uses: changesets/action@v1
|
||||
|
||||
6
.prettierignore
Normal file
6
.prettierignore
Normal file
@@ -0,0 +1,6 @@
|
||||
# Ignore artifacts:
|
||||
build
|
||||
coverage
|
||||
.changeset
|
||||
tasks
|
||||
package-lock.json
|
||||
11
.prettierrc
Normal file
11
.prettierrc
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"printWidth": 80,
|
||||
"tabWidth": 2,
|
||||
"useTabs": true,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": true,
|
||||
"arrowParens": "always",
|
||||
"endOfLine": "lf"
|
||||
}
|
||||
27
CHANGELOG.md
Normal file
27
CHANGELOG.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# task-master-ai
|
||||
|
||||
## 0.10.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#80](https://github.com/eyaltoledano/claude-task-master/pull/80) [`aa185b2`](https://github.com/eyaltoledano/claude-task-master/commit/aa185b28b248b4ca93f9195b502e2f5187868eaa) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - Remove non-existent package `@model-context-protocol/sdk`
|
||||
|
||||
- [#45](https://github.com/eyaltoledano/claude-task-master/pull/45) [`757fd47`](https://github.com/eyaltoledano/claude-task-master/commit/757fd478d2e2eff8506ae746c3470c6088f4d944) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - Add license to repo
|
||||
|
||||
## 0.10.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#44](https://github.com/eyaltoledano/claude-task-master/pull/44) [`eafdb47`](https://github.com/eyaltoledano/claude-task-master/commit/eafdb47418b444c03c092f653b438cc762d4bca8) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - add github actions to automate github and npm releases
|
||||
|
||||
- [#20](https://github.com/eyaltoledano/claude-task-master/pull/20) [`4eed269`](https://github.com/eyaltoledano/claude-task-master/commit/4eed2693789a444f704051d5fbb3ef8d460e4e69) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - Implement MCP server for all commands using tools.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#44](https://github.com/eyaltoledano/claude-task-master/pull/44) [`44db895`](https://github.com/eyaltoledano/claude-task-master/commit/44db895303a9209416236e3d519c8a609ad85f61) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - Added changeset config #39
|
||||
|
||||
- [#50](https://github.com/eyaltoledano/claude-task-master/pull/50) [`257160a`](https://github.com/eyaltoledano/claude-task-master/commit/257160a9670b5d1942e7c623bd2c1a3fde7c06a0) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - Fix addTask tool `projectRoot not defined`
|
||||
|
||||
- [#57](https://github.com/eyaltoledano/claude-task-master/pull/57) [`9fd42ee`](https://github.com/eyaltoledano/claude-task-master/commit/9fd42eeafdc25a96cdfb70aa3af01f525d26b4bc) Thanks [@github-actions](https://github.com/apps/github-actions)! - fix mcp server not connecting to cursor
|
||||
|
||||
- [#48](https://github.com/eyaltoledano/claude-task-master/pull/48) [`5ec3651`](https://github.com/eyaltoledano/claude-task-master/commit/5ec3651e6459add7354910a86b3c4db4d12bc5d1) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - Fix workflows
|
||||
25
LICENSE
Normal file
25
LICENSE
Normal file
@@ -0,0 +1,25 @@
|
||||
Task Master License
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 — Eyal Toledano, Ralph Khreish
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
"Commons Clause" License Condition v1.0
|
||||
|
||||
The Software is provided to you by the Licensor under the License (defined below), subject to the following condition:
|
||||
|
||||
Without limiting other conditions in the License, the grant of rights under the License will not include, and the License does not grant to you, the right to Sell the Software.
|
||||
|
||||
For purposes of the foregoing, "Sell" means practicing any or all of the rights granted to you under the License to provide the Software to third parties, for a fee or other consideration (including without limitation fees for hosting or consulting/support services related to the Software), as part of a product or service whose value derives, entirely or substantially, from the functionality of the Software. Any license notice or attribution required by the License must also include this Commons Clause License Condition notice.
|
||||
|
||||
Software: All Task Master associated files (including all files in the GitHub repository "claude-task-master" and in the npm package "task-master-ai").
|
||||
|
||||
License: MIT
|
||||
|
||||
Licensor: Eyal Toledano, Ralph Khreish
|
||||
90
LICENSE.md
Normal file
90
LICENSE.md
Normal file
@@ -0,0 +1,90 @@
|
||||
# Dual License
|
||||
|
||||
This project is licensed under two separate licenses:
|
||||
|
||||
1. [Business Source License 1.1](#business-source-license-11) (BSL 1.1) for commercial use of Task Master itself
|
||||
2. [Apache License 2.0](#apache-license-20) for all other uses
|
||||
|
||||
## Business Source License 1.1
|
||||
|
||||
Terms: https://mariadb.com/bsl11/
|
||||
|
||||
Licensed Work: Task Master AI
|
||||
Additional Use Grant: You may use Task Master AI to create and commercialize your own projects and products.
|
||||
|
||||
Change Date: 2025-03-30
|
||||
Change License: None
|
||||
|
||||
The Licensed Work is subject to the Business Source License 1.1. If you are interested in using the Licensed Work in a way that competes directly with Task Master, please contact the licensors.
|
||||
|
||||
### Licensor
|
||||
|
||||
- Eyal Toledano (GitHub: @eyaltoledano)
|
||||
- Ralph (GitHub: @Crunchyman-ralph)
|
||||
|
||||
### Commercial Use Restrictions
|
||||
|
||||
This license explicitly restricts certain commercial uses of Task Master AI to the Licensors listed above. Restricted commercial uses include:
|
||||
|
||||
1. Creating commercial products or services that directly compete with Task Master AI
|
||||
2. Selling Task Master AI itself as a service
|
||||
3. Offering Task Master AI's functionality as a commercial managed service
|
||||
4. Reselling or redistributing Task Master AI for a fee
|
||||
|
||||
### Explicitly Permitted Uses
|
||||
|
||||
The following uses are explicitly allowed under this license:
|
||||
|
||||
1. Using Task Master AI to create and commercialize your own projects
|
||||
2. Using Task Master AI in commercial environments for internal development
|
||||
3. Building and selling products or services that were created using Task Master AI
|
||||
4. Using Task Master AI for commercial development as long as you're not selling Task Master AI itself
|
||||
|
||||
### Additional Terms
|
||||
|
||||
1. The right to commercialize Task Master AI itself is exclusively reserved for the Licensors
|
||||
2. No party may create commercial products that directly compete with Task Master AI without explicit written permission
|
||||
3. Forks of this repository are subject to the same restrictions regarding direct competition
|
||||
4. Contributors agree that their contributions will be subject to this same dual licensing structure
|
||||
|
||||
## Apache License 2.0
|
||||
|
||||
For all uses other than those restricted above. See [APACHE-LICENSE](./APACHE-LICENSE) for the full license text.
|
||||
|
||||
### Permitted Use Definition
|
||||
|
||||
You may use Task Master AI for any purpose, including commercial purposes, as long as you are not:
|
||||
|
||||
1. Creating a direct competitor to Task Master AI
|
||||
2. Selling Task Master AI itself as a service
|
||||
3. Redistributing Task Master AI for a fee
|
||||
|
||||
### Requirements for Use
|
||||
|
||||
1. You must include appropriate copyright notices
|
||||
2. You must state significant changes made to the software
|
||||
3. You must preserve all license notices
|
||||
|
||||
## Questions and Commercial Licensing
|
||||
|
||||
For questions about licensing or to inquire about commercial use that may compete with Task Master, please contact:
|
||||
|
||||
- Eyal Toledano (GitHub: @eyaltoledano)
|
||||
- Ralph (GitHub: @Crunchyman-ralph)
|
||||
|
||||
## Examples
|
||||
|
||||
### ✅ Allowed Uses
|
||||
|
||||
- Using Task Master to create a commercial SaaS product
|
||||
- Using Task Master in your company for development
|
||||
- Creating and selling products that were built using Task Master
|
||||
- Using Task Master to generate code for commercial projects
|
||||
- Offering consulting services where you use Task Master
|
||||
|
||||
### ❌ Restricted Uses
|
||||
|
||||
- Creating a competing AI task management tool
|
||||
- Selling access to Task Master as a service
|
||||
- Creating a hosted version of Task Master
|
||||
- Reselling Task Master's functionality
|
||||
25
README.md
25
README.md
@@ -1,9 +1,32 @@
|
||||
# Task Master
|
||||
|
||||
[](https://github.com/eyaltoledano/claude-task-master/actions/workflows/ci.yml)
|
||||
[](LICENSE)
|
||||
[](https://badge.fury.io/js/task-master-ai)
|
||||
|
||||
### by [@eyaltoledano](https://x.com/eyaltoledano)
|
||||
|
||||
A task management system for AI-driven development with Claude, designed to work seamlessly with Cursor AI.
|
||||
|
||||
## Licensing
|
||||
|
||||
Task Master is licensed under the MIT License with Commons Clause. This means you can:
|
||||
|
||||
✅ **Allowed**:
|
||||
|
||||
- Use Task Master for any purpose (personal, commercial, academic)
|
||||
- Modify the code
|
||||
- Distribute copies
|
||||
- Create and sell products built using Task Master
|
||||
|
||||
❌ **Not Allowed**:
|
||||
|
||||
- Sell Task Master itself
|
||||
- Offer Task Master as a hosted service
|
||||
- Create competing products based on Task Master
|
||||
|
||||
See the [LICENSE](LICENSE) file for the complete license text.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Node.js 14.0.0 or higher
|
||||
@@ -385,7 +408,7 @@ task-master update-subtask --id=5.2 --prompt="Add rate limiting of 100 requests
|
||||
task-master update-subtask --id=<parentId.subtaskId> --prompt="<prompt>" --research
|
||||
```
|
||||
|
||||
Unlike the `update-task` command which replaces task information, the `update-subtask` command *appends* new information to the existing subtask details, marking it with a timestamp. This is useful for iteratively enhancing subtasks while preserving the original content.
|
||||
Unlike the `update-task` command which replaces task information, the `update-subtask` command _appends_ new information to the existing subtask details, marking it with a timestamp. This is useful for iteratively enhancing subtasks while preserving the original content.
|
||||
|
||||
### Generate Task Files
|
||||
|
||||
|
||||
@@ -21,9 +21,11 @@ In an AI-driven development process—particularly with tools like [Cursor](http
|
||||
The script can be configured through environment variables in a `.env` file at the root of the project:
|
||||
|
||||
### Required Configuration
|
||||
|
||||
- `ANTHROPIC_API_KEY`: Your Anthropic API key for Claude
|
||||
|
||||
### Optional Configuration
|
||||
|
||||
- `MODEL`: Specify which Claude model to use (default: "claude-3-7-sonnet-20250219")
|
||||
- `MAX_TOKENS`: Maximum tokens for model responses (default: 4000)
|
||||
- `TEMPERATURE`: Temperature for model responses (default: 0.7)
|
||||
@@ -39,6 +41,7 @@ The script can be configured through environment variables in a `.env` file at t
|
||||
## How It Works
|
||||
|
||||
1. **`tasks.json`**:
|
||||
|
||||
- A JSON file at the project root containing an array of tasks (each with `id`, `title`, `description`, `status`, etc.).
|
||||
- The `meta` field can store additional info like the project's name, version, or reference to the PRD.
|
||||
- Tasks can have `subtasks` for more detailed implementation steps.
|
||||
@@ -111,6 +114,7 @@ task-master update --file=custom-tasks.json --from=5 --prompt="Change database f
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- The `--prompt` parameter is required and should explain the changes or new context
|
||||
- Only tasks that aren't marked as 'done' will be updated
|
||||
- Tasks with ID >= the specified --from value will be updated
|
||||
@@ -134,6 +138,7 @@ task-master set-status --id=1,2,3 --status=done
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- When marking a parent task as "done", all of its subtasks will automatically be marked as "done" as well
|
||||
- Common status values are 'done', 'pending', and 'deferred', but any string is accepted
|
||||
- You can specify multiple task IDs by separating them with commas
|
||||
@@ -183,6 +188,7 @@ task-master clear-subtasks --all
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- After clearing subtasks, task files are automatically regenerated
|
||||
- This is useful when you want to regenerate subtasks with a different approach
|
||||
- Can be combined with the `expand` command to immediately generate new subtasks
|
||||
@@ -198,6 +204,7 @@ The script integrates with two AI services:
|
||||
The Perplexity integration uses the OpenAI client to connect to Perplexity's API, which provides enhanced research capabilities for generating more informed subtasks. If the Perplexity API is unavailable or encounters an error, the script will automatically fall back to using Anthropic's Claude.
|
||||
|
||||
To use the Perplexity integration:
|
||||
|
||||
1. Obtain a Perplexity API key
|
||||
2. Add `PERPLEXITY_API_KEY` to your `.env` file
|
||||
3. Optionally specify `PERPLEXITY_MODEL` in your `.env` file (default: "sonar-medium-online")
|
||||
@@ -206,6 +213,7 @@ To use the Perplexity integration:
|
||||
## Logging
|
||||
|
||||
The script supports different logging levels controlled by the `LOG_LEVEL` environment variable:
|
||||
|
||||
- `debug`: Detailed information, typically useful for troubleshooting
|
||||
- `info`: Confirmation that things are working as expected (default)
|
||||
- `warn`: Warning messages that don't prevent execution
|
||||
@@ -228,17 +236,20 @@ task-master remove-dependency --id=<id> --depends-on=<id>
|
||||
These commands:
|
||||
|
||||
1. **Allow precise dependency management**:
|
||||
|
||||
- Add dependencies between tasks with automatic validation
|
||||
- Remove dependencies when they're no longer needed
|
||||
- Update task files automatically after changes
|
||||
|
||||
2. **Include validation checks**:
|
||||
|
||||
- Prevent circular dependencies (a task depending on itself)
|
||||
- Prevent duplicate dependencies
|
||||
- Verify that both tasks exist before adding/removing dependencies
|
||||
- Check if dependencies exist before attempting to remove them
|
||||
|
||||
3. **Provide clear feedback**:
|
||||
|
||||
- Success messages confirm when dependencies are added/removed
|
||||
- Error messages explain why operations failed (if applicable)
|
||||
|
||||
@@ -263,6 +274,7 @@ task-master validate-dependencies --file=custom-tasks.json
|
||||
```
|
||||
|
||||
This command:
|
||||
|
||||
- Scans all tasks and subtasks for non-existent dependencies
|
||||
- Identifies potential self-dependencies (tasks referencing themselves)
|
||||
- Reports all found issues without modifying files
|
||||
@@ -284,6 +296,7 @@ task-master fix-dependencies --file=custom-tasks.json
|
||||
```
|
||||
|
||||
This command:
|
||||
|
||||
1. **Validates all dependencies** across tasks and subtasks
|
||||
2. **Automatically removes**:
|
||||
- References to non-existent tasks and subtasks
|
||||
@@ -321,6 +334,7 @@ task-master analyze-complexity --research
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- The command uses Claude to analyze each task's complexity (or Perplexity with --research flag)
|
||||
- Tasks are scored on a scale of 1-10
|
||||
- Each task receives a recommended number of subtasks based on DEFAULT_SUBTASKS configuration
|
||||
@@ -345,12 +359,14 @@ task-master expand --id=8 --num=5 --prompt="Custom prompt"
|
||||
```
|
||||
|
||||
When a complexity report exists:
|
||||
|
||||
- The `expand` command will use the recommended subtask count from the report (unless overridden)
|
||||
- It will use the tailored expansion prompt from the report (unless a custom prompt is provided)
|
||||
- When using `--all`, tasks are sorted by complexity score (highest first)
|
||||
- The `--research` flag is preserved from the complexity analysis to expansion
|
||||
|
||||
The output report structure is:
|
||||
|
||||
```json
|
||||
{
|
||||
"meta": {
|
||||
@@ -369,7 +385,7 @@ The output report structure is:
|
||||
"expansionPrompt": "Create subtasks that handle detecting...",
|
||||
"reasoning": "This task requires sophisticated logic...",
|
||||
"expansionCommand": "task-master expand --id=8 --num=6 --prompt=\"Create subtasks...\" --research"
|
||||
},
|
||||
}
|
||||
// More tasks sorted by complexity score (highest first)
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Task Master
|
||||
* Copyright (c) 2025 Eyal Toledano, Ralph Khreish
|
||||
*
|
||||
* This software is licensed under the MIT License with Commons Clause.
|
||||
* You may use this software for any purpose, including commercial applications,
|
||||
* and modify and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. You may not sell this software or offer it as a service.
|
||||
* 2. The origin of this software must not be misrepresented.
|
||||
* 3. Altered source versions must be plainly marked as such.
|
||||
*
|
||||
* For the full license text, see the LICENSE file in the root directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Claude Task Master CLI
|
||||
* Main entry point for globally installed package
|
||||
@@ -34,7 +49,13 @@ function runDevScript(args) {
|
||||
console.error('\nDEBUG - CLI Wrapper Analysis:');
|
||||
console.error('- Original command: ' + process.argv.join(' '));
|
||||
console.error('- Transformed args: ' + args.join(' '));
|
||||
console.error('- dev.js will receive: node ' + devScriptPath + ' ' + args.join(' ') + '\n');
|
||||
console.error(
|
||||
'- dev.js will receive: node ' +
|
||||
devScriptPath +
|
||||
' ' +
|
||||
args.join(' ') +
|
||||
'\n'
|
||||
);
|
||||
}
|
||||
|
||||
// For testing: If TEST_MODE is set, just print args and exit
|
||||
@@ -71,11 +92,13 @@ function createDevScriptAction(commandName) {
|
||||
// If camelCase flags were found, show error and exit
|
||||
if (camelCaseFlags.length > 0) {
|
||||
console.error('\nError: Please use kebab-case for CLI flags:');
|
||||
camelCaseFlags.forEach(flag => {
|
||||
camelCaseFlags.forEach((flag) => {
|
||||
console.error(` Instead of: --${flag.original}`);
|
||||
console.error(` Use: --${flag.kebabCase}`);
|
||||
});
|
||||
console.error('\nExample: task-master parse-prd --num-tasks=5 instead of --numTasks=5\n');
|
||||
console.error(
|
||||
'\nExample: task-master parse-prd --num-tasks=5 instead of --numTasks=5\n'
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -98,9 +121,11 @@ function createDevScriptAction(commandName) {
|
||||
// It's a flag - pass through as is
|
||||
commandArgs.push(arg);
|
||||
// Skip the next arg if this is a flag with a value (not --flag=value format)
|
||||
if (!arg.includes('=') &&
|
||||
if (
|
||||
!arg.includes('=') &&
|
||||
i + 1 < process.argv.length &&
|
||||
!process.argv[i+1].startsWith('--')) {
|
||||
!process.argv[i + 1].startsWith('--')
|
||||
) {
|
||||
commandArgs.push(process.argv[++i]);
|
||||
}
|
||||
} else if (!positionals.has(arg)) {
|
||||
@@ -128,7 +153,9 @@ function createDevScriptAction(commandName) {
|
||||
userOptions.add(kebabName);
|
||||
|
||||
// Add the camelCase version as well
|
||||
const camelName = kebabName.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
||||
const camelName = kebabName.replace(/-([a-z])/g, (_, letter) =>
|
||||
letter.toUpperCase()
|
||||
);
|
||||
userOptions.add(camelName);
|
||||
}
|
||||
}
|
||||
@@ -152,7 +179,10 @@ function createDevScriptAction(commandName) {
|
||||
}
|
||||
|
||||
// Skip built-in Commander properties and options the user provided
|
||||
if (['parent', 'commands', 'options', 'rawArgs'].includes(key) || userOptions.has(key)) {
|
||||
if (
|
||||
['parent', 'commands', 'options', 'rawArgs'].includes(key) ||
|
||||
userOptions.has(key)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -209,9 +239,17 @@ function registerInitCommand(program) {
|
||||
.option('--dry-run', 'Show what would be done without making changes')
|
||||
.action((options) => {
|
||||
// Pass through any options to the init script
|
||||
const args = ['--yes', 'name', 'description', 'version', 'author', 'skip-install', 'dry-run']
|
||||
.filter(opt => options[opt])
|
||||
.map(opt => {
|
||||
const args = [
|
||||
'--yes',
|
||||
'name',
|
||||
'description',
|
||||
'version',
|
||||
'author',
|
||||
'skip-install',
|
||||
'dry-run'
|
||||
]
|
||||
.filter((opt) => options[opt])
|
||||
.map((opt) => {
|
||||
if (opt === 'yes' || opt === 'skip-install' || opt === 'dry-run') {
|
||||
return `--${opt}`;
|
||||
}
|
||||
@@ -264,24 +302,18 @@ const tempProgram = new Command();
|
||||
registerCommands(tempProgram);
|
||||
|
||||
// For each command in the temp instance, add a modified version to our actual program
|
||||
tempProgram.commands.forEach(cmd => {
|
||||
tempProgram.commands.forEach((cmd) => {
|
||||
if (['init', 'dev'].includes(cmd.name())) {
|
||||
// Skip commands we've already defined specially
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new command with the same name and description
|
||||
const newCmd = program
|
||||
.command(cmd.name())
|
||||
.description(cmd.description());
|
||||
const newCmd = program.command(cmd.name()).description(cmd.description());
|
||||
|
||||
// Copy all options
|
||||
cmd.options.forEach(opt => {
|
||||
newCmd.option(
|
||||
opt.flags,
|
||||
opt.description,
|
||||
opt.defaultValue
|
||||
);
|
||||
cmd.options.forEach((opt) => {
|
||||
newCmd.option(opt.flags, opt.description, opt.defaultValue);
|
||||
});
|
||||
|
||||
// Set the action to proxy to dev.js
|
||||
@@ -296,14 +328,21 @@ process.on('uncaughtException', (err) => {
|
||||
// Check if this is a commander.js unknown option error
|
||||
if (err.code === 'commander.unknownOption') {
|
||||
const option = err.message.match(/'([^']+)'/)?.[1];
|
||||
const commandArg = process.argv.find(arg => !arg.startsWith('-') &&
|
||||
const commandArg = process.argv.find(
|
||||
(arg) =>
|
||||
!arg.startsWith('-') &&
|
||||
arg !== 'task-master' &&
|
||||
!arg.includes('/') &&
|
||||
arg !== 'node');
|
||||
arg !== 'node'
|
||||
);
|
||||
const command = commandArg || 'unknown';
|
||||
|
||||
console.error(chalk.red(`Error: Unknown option '${option}'`));
|
||||
console.error(chalk.yellow(`Run 'task-master ${command} --help' to see available options for this command`));
|
||||
console.error(
|
||||
chalk.yellow(
|
||||
`Run 'task-master ${command} --help' to see available options for this command`
|
||||
)
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -312,7 +351,9 @@ process.on('uncaughtException', (err) => {
|
||||
const command = err.message.match(/'([^']+)'/)?.[1];
|
||||
|
||||
console.error(chalk.red(`Error: Unknown command '${command}'`));
|
||||
console.error(chalk.yellow(`Run 'task-master --help' to see available commands`));
|
||||
console.error(
|
||||
chalk.yellow(`Run 'task-master --help' to see available commands`)
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,13 +90,13 @@ export const simpleFunction = adaptForMcp(originalFunction);
|
||||
// Split implementation - completely different code paths for CLI vs MCP
|
||||
export const complexFunction = sourceSplitFunction(
|
||||
// CLI version with UI
|
||||
function(param1, param2) {
|
||||
function (param1, param2) {
|
||||
displayBanner();
|
||||
console.log(`Processing ${param1}...`);
|
||||
// ... CLI implementation
|
||||
},
|
||||
// MCP version with structured return
|
||||
function(param1, param2, options = {}) {
|
||||
function (param1, param2, options = {}) {
|
||||
// ... MCP implementation
|
||||
return { success: true, data };
|
||||
}
|
||||
@@ -186,22 +186,22 @@ const commandMap = {
|
||||
|
||||
```javascript
|
||||
// In mcp-server/src/tools/newFeature.js
|
||||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
executeTaskMasterCommand,
|
||||
createContentResponse,
|
||||
createErrorResponse,
|
||||
} from "./utils.js";
|
||||
createErrorResponse
|
||||
} from './utils.js';
|
||||
|
||||
export function registerNewFeatureTool(server) {
|
||||
server.addTool({
|
||||
name: "newFeature",
|
||||
description: "Run the new feature",
|
||||
name: 'newFeature',
|
||||
description: 'Run the new feature',
|
||||
parameters: z.object({
|
||||
param1: z.string().describe("First parameter"),
|
||||
param2: z.number().optional().describe("Second parameter"),
|
||||
file: z.string().optional().describe("Path to the tasks file"),
|
||||
projectRoot: z.string().describe("Root directory of the project")
|
||||
param1: z.string().describe('First parameter'),
|
||||
param2: z.number().optional().describe('Second parameter'),
|
||||
file: z.string().optional().describe('Path to the tasks file'),
|
||||
projectRoot: z.string().describe('Root directory of the project')
|
||||
}),
|
||||
execute: async (args, { log }) => {
|
||||
try {
|
||||
@@ -216,7 +216,7 @@ export function registerNewFeatureTool(server) {
|
||||
|
||||
// Execute the command
|
||||
const result = await executeTaskMasterCommand(
|
||||
"new-feature",
|
||||
'new-feature',
|
||||
log,
|
||||
cmdArgs,
|
||||
projectRoot
|
||||
@@ -231,7 +231,7 @@ export function registerNewFeatureTool(server) {
|
||||
log.error(`Error in new feature: ${error.message}`);
|
||||
return createErrorResponse(`Error in new feature: ${error.message}`);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
```
|
||||
@@ -240,7 +240,7 @@ export function registerNewFeatureTool(server) {
|
||||
|
||||
```javascript
|
||||
// In mcp-server/src/tools/index.js
|
||||
import { registerNewFeatureTool } from "./newFeature.js";
|
||||
import { registerNewFeatureTool } from './newFeature.js';
|
||||
|
||||
export function registerTaskMasterTools(server) {
|
||||
// ... existing registrations
|
||||
|
||||
@@ -41,11 +41,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data",
|
||||
"mimeType",
|
||||
"type"
|
||||
],
|
||||
"required": ["data", "mimeType", "type"],
|
||||
"type": "object"
|
||||
},
|
||||
"BlobResourceContents": {
|
||||
@@ -65,10 +61,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"blob",
|
||||
"uri"
|
||||
],
|
||||
"required": ["blob", "uri"],
|
||||
"type": "object"
|
||||
},
|
||||
"CallToolRequest": {
|
||||
@@ -88,16 +81,11 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"required": ["name"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"CallToolResult": {
|
||||
@@ -132,9 +120,7 @@
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"content"
|
||||
],
|
||||
"required": ["content"],
|
||||
"type": "object"
|
||||
},
|
||||
"CancelledNotification": {
|
||||
@@ -155,16 +141,11 @@
|
||||
"description": "The ID of the request to cancel.\n\nThis MUST correspond to the ID of a request previously issued in the same direction."
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"requestId"
|
||||
],
|
||||
"required": ["requestId"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"ClientCapabilities": {
|
||||
@@ -288,10 +269,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"value"
|
||||
],
|
||||
"required": ["name", "value"],
|
||||
"type": "object"
|
||||
},
|
||||
"ref": {
|
||||
@@ -305,17 +283,11 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"argument",
|
||||
"ref"
|
||||
],
|
||||
"required": ["argument", "ref"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"CompleteResult": {
|
||||
@@ -344,15 +316,11 @@
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"values"
|
||||
],
|
||||
"required": ["values"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"completion"
|
||||
],
|
||||
"required": ["completion"],
|
||||
"type": "object"
|
||||
},
|
||||
"CreateMessageRequest": {
|
||||
@@ -366,11 +334,7 @@
|
||||
"properties": {
|
||||
"includeContext": {
|
||||
"description": "A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.",
|
||||
"enum": [
|
||||
"allServers",
|
||||
"none",
|
||||
"thisServer"
|
||||
],
|
||||
"enum": ["allServers", "none", "thisServer"],
|
||||
"type": "string"
|
||||
},
|
||||
"maxTokens": {
|
||||
@@ -407,17 +371,11 @@
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"maxTokens",
|
||||
"messages"
|
||||
],
|
||||
"required": ["maxTokens", "messages"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"CreateMessageResult": {
|
||||
@@ -453,11 +411,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"content",
|
||||
"model",
|
||||
"role"
|
||||
],
|
||||
"required": ["content", "model", "role"],
|
||||
"type": "object"
|
||||
},
|
||||
"Cursor": {
|
||||
@@ -486,10 +440,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"resource",
|
||||
"type"
|
||||
],
|
||||
"required": ["resource", "type"],
|
||||
"type": "object"
|
||||
},
|
||||
"EmptyResult": {
|
||||
@@ -516,16 +467,11 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"required": ["name"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"GetPromptResult": {
|
||||
@@ -547,9 +493,7 @@
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"messages"
|
||||
],
|
||||
"required": ["messages"],
|
||||
"type": "object"
|
||||
},
|
||||
"ImageContent": {
|
||||
@@ -573,11 +517,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data",
|
||||
"mimeType",
|
||||
"type"
|
||||
],
|
||||
"required": ["data", "mimeType", "type"],
|
||||
"type": "object"
|
||||
},
|
||||
"Implementation": {
|
||||
@@ -590,10 +530,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"version"
|
||||
],
|
||||
"required": ["name", "version"],
|
||||
"type": "object"
|
||||
},
|
||||
"InitializeRequest": {
|
||||
@@ -616,18 +553,11 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"capabilities",
|
||||
"clientInfo",
|
||||
"protocolVersion"
|
||||
],
|
||||
"required": ["capabilities", "clientInfo", "protocolVersion"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"InitializeResult": {
|
||||
@@ -653,11 +583,7 @@
|
||||
"$ref": "#/definitions/Implementation"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"capabilities",
|
||||
"protocolVersion",
|
||||
"serverInfo"
|
||||
],
|
||||
"required": ["capabilities", "protocolVersion", "serverInfo"],
|
||||
"type": "object"
|
||||
},
|
||||
"InitializedNotification": {
|
||||
@@ -679,9 +605,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"JSONRPCBatchRequest": {
|
||||
@@ -729,10 +653,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"code",
|
||||
"message"
|
||||
],
|
||||
"required": ["code", "message"],
|
||||
"type": "object"
|
||||
},
|
||||
"id": {
|
||||
@@ -743,11 +664,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"error",
|
||||
"id",
|
||||
"jsonrpc"
|
||||
],
|
||||
"required": ["error", "id", "jsonrpc"],
|
||||
"type": "object"
|
||||
},
|
||||
"JSONRPCMessage": {
|
||||
@@ -817,10 +734,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"jsonrpc",
|
||||
"method"
|
||||
],
|
||||
"required": ["jsonrpc", "method"],
|
||||
"type": "object"
|
||||
},
|
||||
"JSONRPCRequest": {
|
||||
@@ -852,11 +766,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"jsonrpc",
|
||||
"method"
|
||||
],
|
||||
"required": ["id", "jsonrpc", "method"],
|
||||
"type": "object"
|
||||
},
|
||||
"JSONRPCResponse": {
|
||||
@@ -873,11 +783,7 @@
|
||||
"$ref": "#/definitions/Result"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"jsonrpc",
|
||||
"result"
|
||||
],
|
||||
"required": ["id", "jsonrpc", "result"],
|
||||
"type": "object"
|
||||
},
|
||||
"ListPromptsRequest": {
|
||||
@@ -897,9 +803,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"ListPromptsResult": {
|
||||
@@ -921,9 +825,7 @@
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"prompts"
|
||||
],
|
||||
"required": ["prompts"],
|
||||
"type": "object"
|
||||
},
|
||||
"ListResourceTemplatesRequest": {
|
||||
@@ -943,9 +845,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"ListResourceTemplatesResult": {
|
||||
@@ -967,9 +867,7 @@
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"resourceTemplates"
|
||||
],
|
||||
"required": ["resourceTemplates"],
|
||||
"type": "object"
|
||||
},
|
||||
"ListResourcesRequest": {
|
||||
@@ -989,9 +887,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"ListResourcesResult": {
|
||||
@@ -1013,9 +909,7 @@
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"resources"
|
||||
],
|
||||
"required": ["resources"],
|
||||
"type": "object"
|
||||
},
|
||||
"ListRootsRequest": {
|
||||
@@ -1041,9 +935,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"ListRootsResult": {
|
||||
@@ -1061,9 +953,7 @@
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"roots"
|
||||
],
|
||||
"required": ["roots"],
|
||||
"type": "object"
|
||||
},
|
||||
"ListToolsRequest": {
|
||||
@@ -1083,9 +973,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"ListToolsResult": {
|
||||
@@ -1107,9 +995,7 @@
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"tools"
|
||||
],
|
||||
"required": ["tools"],
|
||||
"type": "object"
|
||||
},
|
||||
"LoggingLevel": {
|
||||
@@ -1147,17 +1033,11 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data",
|
||||
"level"
|
||||
],
|
||||
"required": ["data", "level"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"ModelHint": {
|
||||
@@ -1218,9 +1098,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"PaginatedRequest": {
|
||||
@@ -1238,9 +1116,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"PaginatedResult": {
|
||||
@@ -1280,9 +1156,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"ProgressNotification": {
|
||||
@@ -1311,25 +1185,16 @@
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"progress",
|
||||
"progressToken"
|
||||
],
|
||||
"required": ["progress", "progressToken"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"ProgressToken": {
|
||||
"description": "A progress token, used to associate progress notifications with the original request.",
|
||||
"type": [
|
||||
"string",
|
||||
"integer"
|
||||
]
|
||||
"type": ["string", "integer"]
|
||||
},
|
||||
"Prompt": {
|
||||
"description": "A prompt or prompt template that the server offers.",
|
||||
@@ -1350,9 +1215,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"required": ["name"],
|
||||
"type": "object"
|
||||
},
|
||||
"PromptArgument": {
|
||||
@@ -1371,9 +1234,7 @@
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"required": ["name"],
|
||||
"type": "object"
|
||||
},
|
||||
"PromptListChangedNotification": {
|
||||
@@ -1395,9 +1256,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"PromptMessage": {
|
||||
@@ -1423,10 +1282,7 @@
|
||||
"$ref": "#/definitions/Role"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"content",
|
||||
"role"
|
||||
],
|
||||
"required": ["content", "role"],
|
||||
"type": "object"
|
||||
},
|
||||
"PromptReference": {
|
||||
@@ -1441,10 +1297,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"type"
|
||||
],
|
||||
"required": ["name", "type"],
|
||||
"type": "object"
|
||||
},
|
||||
"ReadResourceRequest": {
|
||||
@@ -1462,16 +1315,11 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"uri"
|
||||
],
|
||||
"required": ["uri"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"ReadResourceResult": {
|
||||
@@ -1496,9 +1344,7 @@
|
||||
"type": "array"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"contents"
|
||||
],
|
||||
"required": ["contents"],
|
||||
"type": "object"
|
||||
},
|
||||
"Request": {
|
||||
@@ -1522,17 +1368,12 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"RequestId": {
|
||||
"description": "A uniquely identifying ID for a request in JSON-RPC.",
|
||||
"type": [
|
||||
"string",
|
||||
"integer"
|
||||
]
|
||||
"type": ["string", "integer"]
|
||||
},
|
||||
"Resource": {
|
||||
"description": "A known resource that the server is capable of reading.",
|
||||
@@ -1559,10 +1400,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"uri"
|
||||
],
|
||||
"required": ["name", "uri"],
|
||||
"type": "object"
|
||||
},
|
||||
"ResourceContents": {
|
||||
@@ -1578,9 +1416,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"uri"
|
||||
],
|
||||
"required": ["uri"],
|
||||
"type": "object"
|
||||
},
|
||||
"ResourceListChangedNotification": {
|
||||
@@ -1602,9 +1438,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"ResourceReference": {
|
||||
@@ -1620,10 +1454,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type",
|
||||
"uri"
|
||||
],
|
||||
"required": ["type", "uri"],
|
||||
"type": "object"
|
||||
},
|
||||
"ResourceTemplate": {
|
||||
@@ -1651,10 +1482,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"uriTemplate"
|
||||
],
|
||||
"required": ["name", "uriTemplate"],
|
||||
"type": "object"
|
||||
},
|
||||
"ResourceUpdatedNotification": {
|
||||
@@ -1672,16 +1500,11 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"uri"
|
||||
],
|
||||
"required": ["uri"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"Result": {
|
||||
@@ -1697,10 +1520,7 @@
|
||||
},
|
||||
"Role": {
|
||||
"description": "The sender or recipient of messages and data in a conversation.",
|
||||
"enum": [
|
||||
"assistant",
|
||||
"user"
|
||||
],
|
||||
"enum": ["assistant", "user"],
|
||||
"type": "string"
|
||||
},
|
||||
"Root": {
|
||||
@@ -1716,9 +1536,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"uri"
|
||||
],
|
||||
"required": ["uri"],
|
||||
"type": "object"
|
||||
},
|
||||
"RootsListChangedNotification": {
|
||||
@@ -1740,9 +1558,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"SamplingMessage": {
|
||||
@@ -1765,10 +1581,7 @@
|
||||
"$ref": "#/definitions/Role"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"content",
|
||||
"role"
|
||||
],
|
||||
"required": ["content", "role"],
|
||||
"type": "object"
|
||||
},
|
||||
"ServerCapabilities": {
|
||||
@@ -1915,16 +1728,11 @@
|
||||
"description": "The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/message."
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"level"
|
||||
],
|
||||
"required": ["level"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"SubscribeRequest": {
|
||||
@@ -1942,16 +1750,11 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"uri"
|
||||
],
|
||||
"required": ["uri"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
},
|
||||
"TextContent": {
|
||||
@@ -1970,10 +1773,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"text",
|
||||
"type"
|
||||
],
|
||||
"required": ["text", "type"],
|
||||
"type": "object"
|
||||
},
|
||||
"TextResourceContents": {
|
||||
@@ -1992,10 +1792,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"text",
|
||||
"uri"
|
||||
],
|
||||
"required": ["text", "uri"],
|
||||
"type": "object"
|
||||
},
|
||||
"Tool": {
|
||||
@@ -2031,9 +1828,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"required": ["type"],
|
||||
"type": "object"
|
||||
},
|
||||
"name": {
|
||||
@@ -2041,10 +1836,7 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"inputSchema",
|
||||
"name"
|
||||
],
|
||||
"required": ["inputSchema", "name"],
|
||||
"type": "object"
|
||||
},
|
||||
"ToolAnnotations": {
|
||||
@@ -2092,9 +1884,7 @@
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
],
|
||||
"required": ["method"],
|
||||
"type": "object"
|
||||
},
|
||||
"UnsubscribeRequest": {
|
||||
@@ -2112,16 +1902,11 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"uri"
|
||||
],
|
||||
"required": ["uri"],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method",
|
||||
"params"
|
||||
],
|
||||
"required": ["method", "params"],
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
|
||||
17
index.js
17
index.js
@@ -1,5 +1,20 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Task Master
|
||||
* Copyright (c) 2025 Eyal Toledano, Ralph Khreish
|
||||
*
|
||||
* This software is licensed under the MIT License with Commons Clause.
|
||||
* You may use this software for any purpose, including commercial applications,
|
||||
* and modify and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. You may not sell this software or offer it as a service.
|
||||
* 2. The origin of this software must not be misrepresented.
|
||||
* 3. Altered source versions must be plainly marked as such.
|
||||
*
|
||||
* For the full license text, see the LICENSE file in the root directory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Claude Task Master
|
||||
* A task management system for AI-driven development with Claude
|
||||
@@ -65,7 +80,7 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
.command('init')
|
||||
.description('Initialize a new project')
|
||||
.action(() => {
|
||||
runInitCLI().catch(err => {
|
||||
runInitCLI().catch((err) => {
|
||||
console.error('Init failed:', err.message);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import TaskMasterMCPServer from "./src/index.js";
|
||||
import dotenv from "dotenv";
|
||||
import logger from "./src/logger.js";
|
||||
import TaskMasterMCPServer from './src/index.js';
|
||||
import dotenv from 'dotenv';
|
||||
import logger from './src/logger.js';
|
||||
|
||||
// Load environment variables
|
||||
dotenv.config();
|
||||
@@ -14,12 +14,12 @@ async function startServer() {
|
||||
const server = new TaskMasterMCPServer();
|
||||
|
||||
// Handle graceful shutdown
|
||||
process.on("SIGINT", async () => {
|
||||
process.on('SIGINT', async () => {
|
||||
await server.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on("SIGTERM", async () => {
|
||||
process.on('SIGTERM', async () => {
|
||||
await server.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
@@ -14,7 +14,9 @@ describe('ContextManager', () => {
|
||||
|
||||
describe('getContext', () => {
|
||||
it('should create a new context when not in cache', async () => {
|
||||
const context = await contextManager.getContext('test-id', { test: true });
|
||||
const context = await contextManager.getContext('test-id', {
|
||||
test: true
|
||||
});
|
||||
expect(context.id).toBe('test-id');
|
||||
expect(context.metadata.test).toBe(true);
|
||||
expect(contextManager.stats.misses).toBe(1);
|
||||
@@ -26,7 +28,9 @@ describe('ContextManager', () => {
|
||||
await contextManager.getContext('test-id', { test: true });
|
||||
|
||||
// Second call should hit cache
|
||||
const context = await contextManager.getContext('test-id', { test: true });
|
||||
const context = await contextManager.getContext('test-id', {
|
||||
test: true
|
||||
});
|
||||
expect(context.id).toBe('test-id');
|
||||
expect(context.metadata.test).toBe(true);
|
||||
expect(contextManager.stats.hits).toBe(1);
|
||||
@@ -38,7 +42,7 @@ describe('ContextManager', () => {
|
||||
await contextManager.getContext('test-id', { test: true });
|
||||
|
||||
// Wait for TTL to expire
|
||||
await new Promise(resolve => setTimeout(resolve, 1100));
|
||||
await new Promise((resolve) => setTimeout(resolve, 1100));
|
||||
|
||||
// Should create new context
|
||||
await contextManager.getContext('test-id', { test: true });
|
||||
@@ -50,7 +54,9 @@ describe('ContextManager', () => {
|
||||
describe('updateContext', () => {
|
||||
it('should update existing context metadata', async () => {
|
||||
await contextManager.getContext('test-id', { initial: true });
|
||||
const updated = await contextManager.updateContext('test-id', { updated: true });
|
||||
const updated = await contextManager.updateContext('test-id', {
|
||||
updated: true
|
||||
});
|
||||
|
||||
expect(updated.metadata.initial).toBe(true);
|
||||
expect(updated.metadata.updated).toBe(true);
|
||||
|
||||
@@ -112,7 +112,8 @@ export class ContextManager {
|
||||
*/
|
||||
getCachedData(key) {
|
||||
const cached = this.cache.get(key);
|
||||
if (cached !== undefined) { // Check for undefined specifically, as null/false might be valid cached values
|
||||
if (cached !== undefined) {
|
||||
// Check for undefined specifically, as null/false might be valid cached values
|
||||
this.stats.hits++;
|
||||
return cached;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ const __dirname = dirname(__filename);
|
||||
|
||||
// Import Task Master modules
|
||||
import {
|
||||
listTasks,
|
||||
listTasks
|
||||
// We'll import more functions as we continue implementation
|
||||
} from '../../../scripts/modules/task-manager.js';
|
||||
|
||||
@@ -62,7 +62,9 @@ function findTasksJsonPath(args, log) {
|
||||
}
|
||||
|
||||
// If no file was found, throw an error
|
||||
const error = new Error(`Tasks file not found in any of the expected locations relative to ${projectRoot}: ${possiblePaths.join(', ')}`);
|
||||
const error = new Error(
|
||||
`Tasks file not found in any of the expected locations relative to ${projectRoot}: ${possiblePaths.join(', ')}`
|
||||
);
|
||||
error.code = 'TASKS_FILE_NOT_FOUND';
|
||||
throw error;
|
||||
}
|
||||
@@ -83,11 +85,19 @@ export async function listTasksDirect(args, log) {
|
||||
if (error.code === 'TASKS_FILE_NOT_FOUND') {
|
||||
log.error(`Tasks file not found: ${error.message}`);
|
||||
// Return the error structure expected by the calling tool/handler
|
||||
return { success: false, error: { code: error.code, message: error.message }, fromCache: false };
|
||||
return {
|
||||
success: false,
|
||||
error: { code: error.code, message: error.message },
|
||||
fromCache: false
|
||||
};
|
||||
}
|
||||
log.error(`Unexpected error finding tasks file: ${error.message}`);
|
||||
// Re-throw for outer catch or return structured error
|
||||
return { success: false, error: { code: 'FIND_TASKS_PATH_ERROR', message: error.message }, fromCache: false };
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'FIND_TASKS_PATH_ERROR', message: error.message },
|
||||
fromCache: false
|
||||
};
|
||||
}
|
||||
|
||||
// Generate cache key *after* finding tasksPath
|
||||
@@ -98,19 +108,39 @@ export async function listTasksDirect(args, log) {
|
||||
// Define the action function to be executed on cache miss
|
||||
const coreListTasksAction = async () => {
|
||||
try {
|
||||
log.info(`Executing core listTasks function for path: ${tasksPath}, filter: ${statusFilter}, subtasks: ${withSubtasks}`);
|
||||
const resultData = listTasks(tasksPath, statusFilter, withSubtasks, 'json');
|
||||
log.info(
|
||||
`Executing core listTasks function for path: ${tasksPath}, filter: ${statusFilter}, subtasks: ${withSubtasks}`
|
||||
);
|
||||
const resultData = listTasks(
|
||||
tasksPath,
|
||||
statusFilter,
|
||||
withSubtasks,
|
||||
'json'
|
||||
);
|
||||
|
||||
if (!resultData || !resultData.tasks) {
|
||||
log.error('Invalid or empty response from listTasks core function');
|
||||
return { success: false, error: { code: 'INVALID_CORE_RESPONSE', message: 'Invalid or empty response from listTasks core function' } };
|
||||
return {
|
||||
success: false,
|
||||
error: {
|
||||
code: 'INVALID_CORE_RESPONSE',
|
||||
message: 'Invalid or empty response from listTasks core function'
|
||||
}
|
||||
log.info(`Core listTasks function retrieved ${resultData.tasks.length} tasks`);
|
||||
};
|
||||
}
|
||||
log.info(
|
||||
`Core listTasks function retrieved ${resultData.tasks.length} tasks`
|
||||
);
|
||||
return { success: true, data: resultData };
|
||||
|
||||
} catch (error) {
|
||||
log.error(`Core listTasks function failed: ${error.message}`);
|
||||
return { success: false, error: { code: 'LIST_TASKS_CORE_ERROR', message: error.message || 'Failed to list tasks' } };
|
||||
return {
|
||||
success: false,
|
||||
error: {
|
||||
code: 'LIST_TASKS_CORE_ERROR',
|
||||
message: error.message || 'Failed to list tasks'
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -123,11 +153,17 @@ export async function listTasksDirect(args, log) {
|
||||
});
|
||||
log.info(`listTasksDirect completed. From cache: ${result.fromCache}`);
|
||||
return result; // Returns { success, data/error, fromCache }
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
// Catch unexpected errors from getCachedOrExecute itself (though unlikely)
|
||||
log.error(`Unexpected error during getCachedOrExecute for listTasks: ${error.message}`);
|
||||
log.error(
|
||||
`Unexpected error during getCachedOrExecute for listTasks: ${error.message}`
|
||||
);
|
||||
console.error(error.stack);
|
||||
return { success: false, error: { code: 'CACHE_UTIL_ERROR', message: error.message }, fromCache: false };
|
||||
return {
|
||||
success: false,
|
||||
error: { code: 'CACHE_UTIL_ERROR', message: error.message },
|
||||
fromCache: false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +198,6 @@ export async function getCacheStatsDirect(args, log) {
|
||||
*/
|
||||
export const directFunctions = {
|
||||
list: listTasksDirect,
|
||||
cacheStats: getCacheStatsDirect,
|
||||
cacheStats: getCacheStatsDirect
|
||||
// Add more functions as we implement them
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
import { FastMCP } from "fastmcp";
|
||||
import path from "path";
|
||||
import dotenv from "dotenv";
|
||||
import { fileURLToPath } from "url";
|
||||
import fs from "fs";
|
||||
import logger from "./logger.js";
|
||||
import { registerTaskMasterTools } from "./tools/index.js";
|
||||
import { FastMCP } from 'fastmcp';
|
||||
import path from 'path';
|
||||
import dotenv from 'dotenv';
|
||||
import { fileURLToPath } from 'url';
|
||||
import fs from 'fs';
|
||||
import logger from './logger.js';
|
||||
import { registerTaskMasterTools } from './tools/index.js';
|
||||
|
||||
// Load environment variables
|
||||
dotenv.config();
|
||||
@@ -19,12 +19,12 @@ const __dirname = path.dirname(__filename);
|
||||
class TaskMasterMCPServer {
|
||||
constructor() {
|
||||
// Get version from package.json using synchronous fs
|
||||
const packagePath = path.join(__dirname, "../../package.json");
|
||||
const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf8"));
|
||||
const packagePath = path.join(__dirname, '../../package.json');
|
||||
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
||||
|
||||
this.options = {
|
||||
name: "Task Master MCP Server",
|
||||
version: packageJson.version,
|
||||
name: 'Task Master MCP Server',
|
||||
version: packageJson.version
|
||||
};
|
||||
|
||||
this.server = new FastMCP(this.options);
|
||||
@@ -67,7 +67,7 @@ class TaskMasterMCPServer {
|
||||
|
||||
// Start the FastMCP server
|
||||
await this.server.start({
|
||||
transportType: "stdio",
|
||||
transportType: 'stdio'
|
||||
});
|
||||
|
||||
return this;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import chalk from "chalk";
|
||||
import chalk from 'chalk';
|
||||
|
||||
// Define log levels
|
||||
const LOG_LEVELS = {
|
||||
@@ -6,7 +6,7 @@ const LOG_LEVELS = {
|
||||
info: 1,
|
||||
warn: 2,
|
||||
error: 3,
|
||||
success: 4,
|
||||
success: 4
|
||||
};
|
||||
|
||||
// Get log level from environment or default to info
|
||||
@@ -21,23 +21,23 @@ const LOG_LEVEL = process.env.LOG_LEVEL
|
||||
*/
|
||||
function log(level, ...args) {
|
||||
const icons = {
|
||||
debug: chalk.gray("🔍"),
|
||||
info: chalk.blue("ℹ️"),
|
||||
warn: chalk.yellow("⚠️"),
|
||||
error: chalk.red("❌"),
|
||||
success: chalk.green("✅"),
|
||||
debug: chalk.gray('🔍'),
|
||||
info: chalk.blue('ℹ️'),
|
||||
warn: chalk.yellow('⚠️'),
|
||||
error: chalk.red('❌'),
|
||||
success: chalk.green('✅')
|
||||
};
|
||||
|
||||
if (LOG_LEVELS[level] >= LOG_LEVEL) {
|
||||
const icon = icons[level] || "";
|
||||
const icon = icons[level] || '';
|
||||
|
||||
if (level === "error") {
|
||||
if (level === 'error') {
|
||||
console.error(icon, chalk.red(...args));
|
||||
} else if (level === "warn") {
|
||||
} else if (level === 'warn') {
|
||||
console.warn(icon, chalk.yellow(...args));
|
||||
} else if (level === "success") {
|
||||
} else if (level === 'success') {
|
||||
console.log(icon, chalk.green(...args));
|
||||
} else if (level === "info") {
|
||||
} else if (level === 'info') {
|
||||
console.log(icon, chalk.blue(...args));
|
||||
} else {
|
||||
console.log(icon, ...args);
|
||||
@@ -52,12 +52,12 @@ function log(level, ...args) {
|
||||
*/
|
||||
export function createLogger() {
|
||||
return {
|
||||
debug: (message) => log("debug", message),
|
||||
info: (message) => log("info", message),
|
||||
warn: (message) => log("warn", message),
|
||||
error: (message) => log("error", message),
|
||||
success: (message) => log("success", message),
|
||||
log: log, // Also expose the raw log function
|
||||
debug: (message) => log('debug', message),
|
||||
info: (message) => log('info', message),
|
||||
warn: (message) => log('warn', message),
|
||||
error: (message) => log('error', message),
|
||||
success: (message) => log('success', message),
|
||||
log: log // Also expose the raw log function
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
* Tool to add a new task using AI
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
executeTaskMasterCommand,
|
||||
createContentResponse,
|
||||
createErrorResponse,
|
||||
} from "./utils.js";
|
||||
createErrorResponse
|
||||
} from './utils.js';
|
||||
|
||||
/**
|
||||
* Register the addTask tool with the MCP server
|
||||
@@ -16,24 +16,24 @@ import {
|
||||
*/
|
||||
export function registerAddTaskTool(server) {
|
||||
server.addTool({
|
||||
name: "addTask",
|
||||
description: "Add a new task using AI",
|
||||
name: 'addTask',
|
||||
description: 'Add a new task using AI',
|
||||
parameters: z.object({
|
||||
prompt: z.string().describe("Description of the task to add"),
|
||||
prompt: z.string().describe('Description of the task to add'),
|
||||
dependencies: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Comma-separated list of task IDs this task depends on"),
|
||||
.describe('Comma-separated list of task IDs this task depends on'),
|
||||
priority: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Task priority (high, medium, low)"),
|
||||
file: z.string().optional().describe("Path to the tasks file"),
|
||||
.describe('Task priority (high, medium, low)'),
|
||||
file: z.string().optional().describe('Path to the tasks file'),
|
||||
projectRoot: z
|
||||
.string()
|
||||
.describe(
|
||||
"Root directory of the project (default: current working directory)"
|
||||
),
|
||||
'Root directory of the project (default: current working directory)'
|
||||
)
|
||||
}),
|
||||
execute: async (args, { log }) => {
|
||||
try {
|
||||
@@ -46,7 +46,7 @@ export function registerAddTaskTool(server) {
|
||||
if (args.file) cmdArgs.push(`--file=${args.file}`);
|
||||
|
||||
const result = executeTaskMasterCommand(
|
||||
"add-task",
|
||||
'add-task',
|
||||
log,
|
||||
cmdArgs,
|
||||
projectRoot
|
||||
@@ -61,6 +61,6 @@ export function registerAddTaskTool(server) {
|
||||
log.error(`Error adding task: ${error.message}`);
|
||||
return createErrorResponse(`Error adding task: ${error.message}`);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
* Tool to break down a task into detailed subtasks
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
executeTaskMasterCommand,
|
||||
createContentResponse,
|
||||
createErrorResponse,
|
||||
} from "./utils.js";
|
||||
createErrorResponse
|
||||
} from './utils.js';
|
||||
|
||||
/**
|
||||
* Register the expandTask tool with the MCP server
|
||||
@@ -16,33 +16,33 @@ import {
|
||||
*/
|
||||
export function registerExpandTaskTool(server) {
|
||||
server.addTool({
|
||||
name: "expandTask",
|
||||
description: "Break down a task into detailed subtasks",
|
||||
name: 'expandTask',
|
||||
description: 'Break down a task into detailed subtasks',
|
||||
parameters: z.object({
|
||||
id: z.string().describe("Task ID to expand"),
|
||||
num: z.number().optional().describe("Number of subtasks to generate"),
|
||||
id: z.string().describe('Task ID to expand'),
|
||||
num: z.number().optional().describe('Number of subtasks to generate'),
|
||||
research: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe(
|
||||
"Enable Perplexity AI for research-backed subtask generation"
|
||||
'Enable Perplexity AI for research-backed subtask generation'
|
||||
),
|
||||
prompt: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Additional context to guide subtask generation"),
|
||||
.describe('Additional context to guide subtask generation'),
|
||||
force: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe(
|
||||
"Force regeneration of subtasks for tasks that already have them"
|
||||
'Force regeneration of subtasks for tasks that already have them'
|
||||
),
|
||||
file: z.string().optional().describe("Path to the tasks file"),
|
||||
file: z.string().optional().describe('Path to the tasks file'),
|
||||
projectRoot: z
|
||||
.string()
|
||||
.describe(
|
||||
"Root directory of the project (default: current working directory)"
|
||||
),
|
||||
'Root directory of the project (default: current working directory)'
|
||||
)
|
||||
}),
|
||||
execute: async (args, { log }) => {
|
||||
try {
|
||||
@@ -50,15 +50,15 @@ export function registerExpandTaskTool(server) {
|
||||
|
||||
const cmdArgs = [`--id=${args.id}`];
|
||||
if (args.num) cmdArgs.push(`--num=${args.num}`);
|
||||
if (args.research) cmdArgs.push("--research");
|
||||
if (args.research) cmdArgs.push('--research');
|
||||
if (args.prompt) cmdArgs.push(`--prompt="${args.prompt}"`);
|
||||
if (args.force) cmdArgs.push("--force");
|
||||
if (args.force) cmdArgs.push('--force');
|
||||
if (args.file) cmdArgs.push(`--file=${args.file}`);
|
||||
|
||||
const projectRoot = args.projectRoot;
|
||||
|
||||
const result = executeTaskMasterCommand(
|
||||
"expand",
|
||||
'expand',
|
||||
log,
|
||||
cmdArgs,
|
||||
projectRoot
|
||||
@@ -73,6 +73,6 @@ export function registerExpandTaskTool(server) {
|
||||
log.error(`Error expanding task: ${error.message}`);
|
||||
return createErrorResponse(`Error expanding task: ${error.message}`);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
* Export all Task Master CLI tools for MCP server
|
||||
*/
|
||||
|
||||
import logger from "../logger.js";
|
||||
import { registerListTasksTool } from "./listTasks.js";
|
||||
import { registerShowTaskTool } from "./showTask.js";
|
||||
import { registerSetTaskStatusTool } from "./setTaskStatus.js";
|
||||
import { registerExpandTaskTool } from "./expandTask.js";
|
||||
import { registerNextTaskTool } from "./nextTask.js";
|
||||
import { registerAddTaskTool } from "./addTask.js";
|
||||
import logger from '../logger.js';
|
||||
import { registerListTasksTool } from './listTasks.js';
|
||||
import { registerShowTaskTool } from './showTask.js';
|
||||
import { registerSetTaskStatusTool } from './setTaskStatus.js';
|
||||
import { registerExpandTaskTool } from './expandTask.js';
|
||||
import { registerNextTaskTool } from './nextTask.js';
|
||||
import { registerAddTaskTool } from './addTask.js';
|
||||
|
||||
/**
|
||||
* Register all Task Master tools with the MCP server
|
||||
@@ -25,5 +25,5 @@ export function registerTaskMasterTools(server) {
|
||||
}
|
||||
|
||||
export default {
|
||||
registerTaskMasterTools,
|
||||
registerTaskMasterTools
|
||||
};
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
* Tool to list all tasks from Task Master
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import {
|
||||
createErrorResponse,
|
||||
handleApiResult
|
||||
} from "./utils.js";
|
||||
import { listTasksDirect } from "../core/task-master-core.js";
|
||||
import { z } from 'zod';
|
||||
import { createErrorResponse, handleApiResult } from './utils.js';
|
||||
import { listTasksDirect } from '../core/task-master-core.js';
|
||||
|
||||
/**
|
||||
* Register the listTasks tool with the MCP server
|
||||
@@ -16,21 +13,21 @@ import { listTasksDirect } from "../core/task-master-core.js";
|
||||
*/
|
||||
export function registerListTasksTool(server) {
|
||||
server.addTool({
|
||||
name: "listTasks",
|
||||
description: "List all tasks from Task Master",
|
||||
name: 'listTasks',
|
||||
description: 'List all tasks from Task Master',
|
||||
parameters: z.object({
|
||||
status: z.string().optional().describe("Filter tasks by status"),
|
||||
status: z.string().optional().describe('Filter tasks by status'),
|
||||
withSubtasks: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Include subtasks in the response"),
|
||||
file: z.string().optional().describe("Path to the tasks file"),
|
||||
.describe('Include subtasks in the response'),
|
||||
file: z.string().optional().describe('Path to the tasks file'),
|
||||
projectRoot: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
"Root directory of the project (default: current working directory)"
|
||||
),
|
||||
'Root directory of the project (default: current working directory)'
|
||||
)
|
||||
}),
|
||||
execute: async (args, { log }) => {
|
||||
try {
|
||||
@@ -40,13 +37,15 @@ export function registerListTasksTool(server) {
|
||||
const result = await listTasksDirect(args, log);
|
||||
|
||||
// Log result and use handleApiResult utility
|
||||
log.info(`Retrieved ${result.success ? (result.data?.tasks?.length || 0) : 0} tasks`);
|
||||
log.info(
|
||||
`Retrieved ${result.success ? result.data?.tasks?.length || 0 : 0} tasks`
|
||||
);
|
||||
return handleApiResult(result, log, 'Error listing tasks');
|
||||
} catch (error) {
|
||||
log.error(`Error listing tasks: ${error.message}`);
|
||||
return createErrorResponse(error.message);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
* Tool to show the next task to work on based on dependencies and status
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
executeTaskMasterCommand,
|
||||
createContentResponse,
|
||||
createErrorResponse,
|
||||
} from "./utils.js";
|
||||
createErrorResponse
|
||||
} from './utils.js';
|
||||
|
||||
/**
|
||||
* Register the nextTask tool with the MCP server
|
||||
@@ -16,16 +16,16 @@ import {
|
||||
*/
|
||||
export function registerNextTaskTool(server) {
|
||||
server.addTool({
|
||||
name: "nextTask",
|
||||
name: 'nextTask',
|
||||
description:
|
||||
"Show the next task to work on based on dependencies and status",
|
||||
'Show the next task to work on based on dependencies and status',
|
||||
parameters: z.object({
|
||||
file: z.string().optional().describe("Path to the tasks file"),
|
||||
file: z.string().optional().describe('Path to the tasks file'),
|
||||
projectRoot: z
|
||||
.string()
|
||||
.describe(
|
||||
"Root directory of the project (default: current working directory)"
|
||||
),
|
||||
'Root directory of the project (default: current working directory)'
|
||||
)
|
||||
}),
|
||||
execute: async (args, { log }) => {
|
||||
try {
|
||||
@@ -37,7 +37,7 @@ export function registerNextTaskTool(server) {
|
||||
const projectRoot = args.projectRoot;
|
||||
|
||||
const result = executeTaskMasterCommand(
|
||||
"next",
|
||||
'next',
|
||||
log,
|
||||
cmdArgs,
|
||||
projectRoot
|
||||
@@ -52,6 +52,6 @@ export function registerNextTaskTool(server) {
|
||||
log.error(`Error finding next task: ${error.message}`);
|
||||
return createErrorResponse(`Error finding next task: ${error.message}`);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
* Tool to set the status of a task
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
executeTaskMasterCommand,
|
||||
createContentResponse,
|
||||
createErrorResponse,
|
||||
} from "./utils.js";
|
||||
createErrorResponse
|
||||
} from './utils.js';
|
||||
|
||||
/**
|
||||
* Register the setTaskStatus tool with the MCP server
|
||||
@@ -16,21 +16,21 @@ import {
|
||||
*/
|
||||
export function registerSetTaskStatusTool(server) {
|
||||
server.addTool({
|
||||
name: "setTaskStatus",
|
||||
description: "Set the status of a task",
|
||||
name: 'setTaskStatus',
|
||||
description: 'Set the status of a task',
|
||||
parameters: z.object({
|
||||
id: z
|
||||
.string()
|
||||
.describe("Task ID (can be comma-separated for multiple tasks)"),
|
||||
.describe('Task ID (can be comma-separated for multiple tasks)'),
|
||||
status: z
|
||||
.string()
|
||||
.describe("New status (todo, in-progress, review, done)"),
|
||||
file: z.string().optional().describe("Path to the tasks file"),
|
||||
.describe('New status (todo, in-progress, review, done)'),
|
||||
file: z.string().optional().describe('Path to the tasks file'),
|
||||
projectRoot: z
|
||||
.string()
|
||||
.describe(
|
||||
"Root directory of the project (default: current working directory)"
|
||||
),
|
||||
'Root directory of the project (default: current working directory)'
|
||||
)
|
||||
}),
|
||||
execute: async (args, { log }) => {
|
||||
try {
|
||||
@@ -42,7 +42,7 @@ export function registerSetTaskStatusTool(server) {
|
||||
const projectRoot = args.projectRoot;
|
||||
|
||||
const result = executeTaskMasterCommand(
|
||||
"set-status",
|
||||
'set-status',
|
||||
log,
|
||||
cmdArgs,
|
||||
projectRoot
|
||||
@@ -59,6 +59,6 @@ export function registerSetTaskStatusTool(server) {
|
||||
`Error setting task status: ${error.message}`
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
* Tool to show detailed information about a specific task
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
executeTaskMasterCommand,
|
||||
createErrorResponse,
|
||||
handleApiResult
|
||||
} from "./utils.js";
|
||||
} from './utils.js';
|
||||
|
||||
/**
|
||||
* Register the showTask tool with the MCP server
|
||||
@@ -16,17 +16,17 @@ import {
|
||||
*/
|
||||
export function registerShowTaskTool(server) {
|
||||
server.addTool({
|
||||
name: "showTask",
|
||||
description: "Show detailed information about a specific task",
|
||||
name: 'showTask',
|
||||
description: 'Show detailed information about a specific task',
|
||||
parameters: z.object({
|
||||
id: z.string().describe("Task ID to show"),
|
||||
file: z.string().optional().describe("Path to the tasks file"),
|
||||
id: z.string().describe('Task ID to show'),
|
||||
file: z.string().optional().describe('Path to the tasks file'),
|
||||
projectRoot: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
"Root directory of the project (default: current working directory)"
|
||||
),
|
||||
'Root directory of the project (default: current working directory)'
|
||||
)
|
||||
}),
|
||||
execute: async (args, { log }) => {
|
||||
try {
|
||||
@@ -38,7 +38,7 @@ export function registerShowTaskTool(server) {
|
||||
|
||||
// Execute the command - function now handles project root internally
|
||||
const result = executeTaskMasterCommand(
|
||||
"show",
|
||||
'show',
|
||||
log,
|
||||
cmdArgs,
|
||||
args.projectRoot // Pass raw project root, function will normalize it
|
||||
@@ -50,7 +50,11 @@ export function registerShowTaskTool(server) {
|
||||
// Try to parse response as JSON
|
||||
const data = JSON.parse(result.stdout);
|
||||
// Return equivalent of a successful API call with data
|
||||
return handleApiResult({ success: true, data }, log, 'Error showing task');
|
||||
return handleApiResult(
|
||||
{ success: true, data },
|
||||
log,
|
||||
'Error showing task'
|
||||
);
|
||||
} catch (e) {
|
||||
// If parsing fails, still return success but with raw string data
|
||||
return handleApiResult(
|
||||
@@ -73,6 +77,6 @@ export function registerShowTaskTool(server) {
|
||||
log.error(`Error showing task: ${error.message}`);
|
||||
return createErrorResponse(error.message);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* Utility functions for Task Master CLI integration
|
||||
*/
|
||||
|
||||
import { spawnSync } from "child_process";
|
||||
import path from "path";
|
||||
import { spawnSync } from 'child_process';
|
||||
import path from 'path';
|
||||
import { contextManager } from '../core/context-manager.js'; // Import the singleton
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,12 @@ export function getProjectRoot(projectRootRaw, log) {
|
||||
* @param {Function} processFunction - Optional function to process successful result data
|
||||
* @returns {Object} - Standardized MCP response object
|
||||
*/
|
||||
export function handleApiResult(result, log, errorPrefix = 'API error', processFunction = processMCPResponseData) {
|
||||
export function handleApiResult(
|
||||
result,
|
||||
log,
|
||||
errorPrefix = 'API error',
|
||||
processFunction = processMCPResponseData
|
||||
) {
|
||||
if (!result.success) {
|
||||
const errorMsg = result.error?.message || `Unknown ${errorPrefix}`;
|
||||
// Include cache status in error logs
|
||||
@@ -43,7 +48,9 @@ export function handleApiResult(result, log, errorPrefix = 'API error', processF
|
||||
}
|
||||
|
||||
// Process the result data if needed
|
||||
const processedData = processFunction ? processFunction(result.data) : result.data;
|
||||
const processedData = processFunction
|
||||
? processFunction(result.data)
|
||||
: result.data;
|
||||
|
||||
// Log success including cache status
|
||||
log.info(`Successfully completed operation. From cache: ${result.fromCache}`); // Add success log with cache status
|
||||
@@ -87,18 +94,18 @@ export function executeTaskMasterCommand(
|
||||
|
||||
// Common options for spawn
|
||||
const spawnOptions = {
|
||||
encoding: "utf8",
|
||||
cwd: cwd,
|
||||
encoding: 'utf8',
|
||||
cwd: cwd
|
||||
};
|
||||
|
||||
// Execute the command using the global task-master CLI or local script
|
||||
// Try the global CLI first
|
||||
let result = spawnSync("task-master", fullArgs, spawnOptions);
|
||||
let result = spawnSync('task-master', fullArgs, spawnOptions);
|
||||
|
||||
// If global CLI is not available, try fallback to the local script
|
||||
if (result.error && result.error.code === "ENOENT") {
|
||||
log.info("Global task-master not found, falling back to local script");
|
||||
result = spawnSync("node", ["scripts/dev.js", ...fullArgs], spawnOptions);
|
||||
if (result.error && result.error.code === 'ENOENT') {
|
||||
log.info('Global task-master not found, falling back to local script');
|
||||
result = spawnSync('node', ['scripts/dev.js', ...fullArgs], spawnOptions);
|
||||
}
|
||||
|
||||
if (result.error) {
|
||||
@@ -111,7 +118,7 @@ export function executeTaskMasterCommand(
|
||||
? result.stderr.trim()
|
||||
: result.stdout
|
||||
? result.stdout.trim()
|
||||
: "Unknown error";
|
||||
: 'Unknown error';
|
||||
throw new Error(
|
||||
`Command failed with exit code ${result.status}: ${errorOutput}`
|
||||
);
|
||||
@@ -120,13 +127,13 @@ export function executeTaskMasterCommand(
|
||||
return {
|
||||
success: true,
|
||||
stdout: result.stdout,
|
||||
stderr: result.stderr,
|
||||
stderr: result.stderr
|
||||
};
|
||||
} catch (error) {
|
||||
log.error(`Error executing task-master command: ${error.message}`);
|
||||
return {
|
||||
success: false,
|
||||
error: error.message,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -168,9 +175,13 @@ export async function getCachedOrExecute({ cacheKey, actionFn, log }) {
|
||||
const { fromCache, ...resultToCache } = result;
|
||||
contextManager.setCachedData(cacheKey, resultToCache);
|
||||
} else if (!result.success) {
|
||||
log.warn(`Action failed for cache key ${cacheKey}. Result not cached. Error: ${result.error?.message}`);
|
||||
log.warn(
|
||||
`Action failed for cache key ${cacheKey}. Result not cached. Error: ${result.error?.message}`
|
||||
);
|
||||
} else {
|
||||
log.warn(`Action for cache key ${cacheKey} succeeded but returned no data. Result not cached.`);
|
||||
log.warn(
|
||||
`Action for cache key ${cacheKey} succeeded but returned no data. Result not cached.`
|
||||
);
|
||||
}
|
||||
|
||||
// Return the fresh result, indicating it wasn't from cache
|
||||
@@ -215,7 +226,9 @@ export async function executeMCPToolAction({
|
||||
const executionArgs = { ...args, projectRoot };
|
||||
|
||||
let result;
|
||||
const cacheKey = cacheKeyGenerator ? cacheKeyGenerator(executionArgs) : null;
|
||||
const cacheKey = cacheKeyGenerator
|
||||
? cacheKeyGenerator(executionArgs)
|
||||
: null;
|
||||
|
||||
if (cacheKey) {
|
||||
// Use caching utility
|
||||
@@ -240,17 +253,25 @@ export async function executeMCPToolAction({
|
||||
|
||||
// Handle error case
|
||||
if (!result.success) {
|
||||
const errorMsg = result.error?.message || `Unknown error during ${actionName.toLowerCase()}`;
|
||||
const errorMsg =
|
||||
result.error?.message ||
|
||||
`Unknown error during ${actionName.toLowerCase()}`;
|
||||
// Include fromCache in error logs too, might be useful
|
||||
log.error(`Error during ${actionName.toLowerCase()}: ${errorMsg}. From cache: ${result.fromCache}`);
|
||||
log.error(
|
||||
`Error during ${actionName.toLowerCase()}: ${errorMsg}. From cache: ${result.fromCache}`
|
||||
);
|
||||
return createErrorResponse(errorMsg);
|
||||
}
|
||||
|
||||
// Log success
|
||||
log.info(`Successfully completed ${actionName.toLowerCase()}. From cache: ${result.fromCache}`);
|
||||
log.info(
|
||||
`Successfully completed ${actionName.toLowerCase()}. From cache: ${result.fromCache}`
|
||||
);
|
||||
|
||||
// Process the result data if needed
|
||||
const processedData = processResult ? processResult(result.data) : result.data;
|
||||
const processedData = processResult
|
||||
? processResult(result.data)
|
||||
: result.data;
|
||||
|
||||
// Create a new object that includes both the processed data and the fromCache flag
|
||||
const responsePayload = {
|
||||
@@ -260,12 +281,15 @@ export async function executeMCPToolAction({
|
||||
|
||||
// Pass this combined payload to createContentResponse
|
||||
return createContentResponse(responsePayload);
|
||||
|
||||
} catch (error) {
|
||||
// Handle unexpected errors during the execution wrapper itself
|
||||
log.error(`Unexpected error during ${actionName.toLowerCase()} execution wrapper: ${error.message}`);
|
||||
log.error(
|
||||
`Unexpected error during ${actionName.toLowerCase()} execution wrapper: ${error.message}`
|
||||
);
|
||||
console.error(error.stack); // Log stack for debugging wrapper errors
|
||||
return createErrorResponse(`Internal server error during ${actionName.toLowerCase()}: ${error.message}`);
|
||||
return createErrorResponse(
|
||||
`Internal server error during ${actionName.toLowerCase()}: ${error.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +300,10 @@ export async function executeMCPToolAction({
|
||||
* @param {string[]} fieldsToRemove - An array of field names to remove.
|
||||
* @returns {Object|Array} - The processed data with specified fields removed.
|
||||
*/
|
||||
export function processMCPResponseData(taskOrData, fieldsToRemove = ['details', 'testStrategy']) {
|
||||
export function processMCPResponseData(
|
||||
taskOrData,
|
||||
fieldsToRemove = ['details', 'testStrategy']
|
||||
) {
|
||||
if (!taskOrData) {
|
||||
return taskOrData;
|
||||
}
|
||||
@@ -290,7 +317,7 @@ export function processMCPResponseData(taskOrData, fieldsToRemove = ['details',
|
||||
const processedTask = { ...task };
|
||||
|
||||
// Remove specified fields from the task
|
||||
fieldsToRemove.forEach(field => {
|
||||
fieldsToRemove.forEach((field) => {
|
||||
delete processedTask[field];
|
||||
});
|
||||
|
||||
@@ -309,14 +336,23 @@ export function processMCPResponseData(taskOrData, fieldsToRemove = ['details',
|
||||
};
|
||||
|
||||
// Check if the input is a data structure containing a 'tasks' array (like from listTasks)
|
||||
if (typeof taskOrData === 'object' && taskOrData !== null && Array.isArray(taskOrData.tasks)) {
|
||||
if (
|
||||
typeof taskOrData === 'object' &&
|
||||
taskOrData !== null &&
|
||||
Array.isArray(taskOrData.tasks)
|
||||
) {
|
||||
return {
|
||||
...taskOrData, // Keep other potential fields like 'stats', 'filter'
|
||||
tasks: processArrayOfTasks(taskOrData.tasks),
|
||||
tasks: processArrayOfTasks(taskOrData.tasks)
|
||||
};
|
||||
}
|
||||
// Check if the input is likely a single task object (add more checks if needed)
|
||||
else if (typeof taskOrData === 'object' && taskOrData !== null && 'id' in taskOrData && 'title' in taskOrData) {
|
||||
else if (
|
||||
typeof taskOrData === 'object' &&
|
||||
taskOrData !== null &&
|
||||
'id' in taskOrData &&
|
||||
'title' in taskOrData
|
||||
) {
|
||||
return processSingleTask(taskOrData);
|
||||
}
|
||||
// Check if the input is an array of tasks directly (less common but possible)
|
||||
@@ -338,11 +374,12 @@ export function createContentResponse(content) {
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: typeof content === 'object' ?
|
||||
// Format JSON nicely with indentation
|
||||
JSON.stringify(content, null, 2) :
|
||||
// Keep other content types as-is
|
||||
type: 'text',
|
||||
text:
|
||||
typeof content === 'object'
|
||||
? // Format JSON nicely with indentation
|
||||
JSON.stringify(content, null, 2)
|
||||
: // Keep other content types as-is
|
||||
String(content)
|
||||
}
|
||||
]
|
||||
@@ -358,7 +395,7 @@ export function createErrorResponse(errorMessage) {
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
type: 'text',
|
||||
text: `Error: ${errorMessage}`
|
||||
}
|
||||
],
|
||||
|
||||
49
package-lock.json
generated
49
package-lock.json
generated
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "task-master-ai",
|
||||
"version": "0.9.30",
|
||||
"version": "0.10.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "task-master-ai",
|
||||
"version": "0.9.30",
|
||||
"license": "MIT",
|
||||
"version": "0.10.1",
|
||||
"license": "MIT WITH Commons-Clause",
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^0.39.0",
|
||||
"boxen": "^8.0.1",
|
||||
@@ -39,6 +39,7 @@
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-node": "^29.7.0",
|
||||
"mock-fs": "^5.5.0",
|
||||
"prettier": "3.5.3",
|
||||
"supertest": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
@@ -605,6 +606,22 @@
|
||||
"semver": "^7.5.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@changesets/apply-release-plan/node_modules/prettier": {
|
||||
"version": "2.8.8",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/@changesets/apply-release-plan/node_modules/semver": {
|
||||
"version": "7.7.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz",
|
||||
@@ -927,6 +944,22 @@
|
||||
"prettier": "^2.7.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@changesets/write/node_modules/prettier": {
|
||||
"version": "2.8.8",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/@colors/colors": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",
|
||||
@@ -6221,16 +6254,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.8.8",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz",
|
||||
"integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
|
||||
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "task-master-ai",
|
||||
"version": "0.9.30",
|
||||
"version": "0.10.1",
|
||||
"description": "A task management system for ambitious AI-driven development that doesn't overwhelm and confuse Cursor.",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
@@ -19,7 +19,9 @@
|
||||
"prepare": "chmod +x bin/task-master.js bin/task-master-init.js",
|
||||
"changeset": "changeset",
|
||||
"release": "changeset publish",
|
||||
"inspector": "CLIENT_PORT=8888 SERVER_PORT=9000 npx @modelcontextprotocol/inspector node mcp-server/server.js"
|
||||
"inspector": "CLIENT_PORT=8888 SERVER_PORT=9000 npx @modelcontextprotocol/inspector node mcp-server/server.js",
|
||||
"format-check": "prettier --check .",
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
"keywords": [
|
||||
"claude",
|
||||
@@ -34,10 +36,9 @@
|
||||
"context"
|
||||
],
|
||||
"author": "Eyal Toledano",
|
||||
"license": "MIT",
|
||||
"license": "MIT WITH Commons-Clause",
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^0.39.0",
|
||||
"@model-context-protocol/sdk": "^1.20.5",
|
||||
"boxen": "^8.0.1",
|
||||
"chalk": "^4.1.2",
|
||||
"cli-table3": "^0.6.5",
|
||||
@@ -88,6 +89,7 @@
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-node": "^29.7.0",
|
||||
"mock-fs": "^5.5.0",
|
||||
"prettier": "3.5.3",
|
||||
"supertest": "^7.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,11 @@ In an AI-driven development process—particularly with tools like [Cursor](http
|
||||
The script can be configured through environment variables in a `.env` file at the root of the project:
|
||||
|
||||
### Required Configuration
|
||||
|
||||
- `ANTHROPIC_API_KEY`: Your Anthropic API key for Claude
|
||||
|
||||
### Optional Configuration
|
||||
|
||||
- `MODEL`: Specify which Claude model to use (default: "claude-3-7-sonnet-20250219")
|
||||
- `MAX_TOKENS`: Maximum tokens for model responses (default: 4000)
|
||||
- `TEMPERATURE`: Temperature for model responses (default: 0.7)
|
||||
@@ -39,6 +41,7 @@ The script can be configured through environment variables in a `.env` file at t
|
||||
## How It Works
|
||||
|
||||
1. **`tasks.json`**:
|
||||
|
||||
- A JSON file at the project root containing an array of tasks (each with `id`, `title`, `description`, `status`, etc.).
|
||||
- The `meta` field can store additional info like the project's name, version, or reference to the PRD.
|
||||
- Tasks can have `subtasks` for more detailed implementation steps.
|
||||
@@ -102,6 +105,7 @@ node scripts/dev.js update --file=custom-tasks.json --from=5 --prompt="Change da
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- The `--prompt` parameter is required and should explain the changes or new context
|
||||
- Only tasks that aren't marked as 'done' will be updated
|
||||
- Tasks with ID >= the specified --from value will be updated
|
||||
@@ -120,6 +124,7 @@ node scripts/dev.js update-task --id=4 --prompt="Use JWT for authentication" --r
|
||||
```
|
||||
|
||||
This command:
|
||||
|
||||
- Updates only the specified task rather than a range of tasks
|
||||
- Provides detailed validation with helpful error messages
|
||||
- Checks for required API keys when using research mode
|
||||
@@ -146,6 +151,7 @@ node scripts/dev.js set-status --id=1,2,3 --status=done
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- When marking a parent task as "done", all of its subtasks will automatically be marked as "done" as well
|
||||
- Common status values are 'done', 'pending', and 'deferred', but any string is accepted
|
||||
- You can specify multiple task IDs by separating them with commas
|
||||
@@ -195,6 +201,7 @@ node scripts/dev.js clear-subtasks --all
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- After clearing subtasks, task files are automatically regenerated
|
||||
- This is useful when you want to regenerate subtasks with a different approach
|
||||
- Can be combined with the `expand` command to immediately generate new subtasks
|
||||
@@ -210,6 +217,7 @@ The script integrates with two AI services:
|
||||
The Perplexity integration uses the OpenAI client to connect to Perplexity's API, which provides enhanced research capabilities for generating more informed subtasks. If the Perplexity API is unavailable or encounters an error, the script will automatically fall back to using Anthropic's Claude.
|
||||
|
||||
To use the Perplexity integration:
|
||||
|
||||
1. Obtain a Perplexity API key
|
||||
2. Add `PERPLEXITY_API_KEY` to your `.env` file
|
||||
3. Optionally specify `PERPLEXITY_MODEL` in your `.env` file (default: "sonar-medium-online")
|
||||
@@ -218,6 +226,7 @@ To use the Perplexity integration:
|
||||
## Logging
|
||||
|
||||
The script supports different logging levels controlled by the `LOG_LEVEL` environment variable:
|
||||
|
||||
- `debug`: Detailed information, typically useful for troubleshooting
|
||||
- `info`: Confirmation that things are working as expected (default)
|
||||
- `warn`: Warning messages that don't prevent execution
|
||||
@@ -240,17 +249,20 @@ node scripts/dev.js remove-dependency --id=<id> --depends-on=<id>
|
||||
These commands:
|
||||
|
||||
1. **Allow precise dependency management**:
|
||||
|
||||
- Add dependencies between tasks with automatic validation
|
||||
- Remove dependencies when they're no longer needed
|
||||
- Update task files automatically after changes
|
||||
|
||||
2. **Include validation checks**:
|
||||
|
||||
- Prevent circular dependencies (a task depending on itself)
|
||||
- Prevent duplicate dependencies
|
||||
- Verify that both tasks exist before adding/removing dependencies
|
||||
- Check if dependencies exist before attempting to remove them
|
||||
|
||||
3. **Provide clear feedback**:
|
||||
|
||||
- Success messages confirm when dependencies are added/removed
|
||||
- Error messages explain why operations failed (if applicable)
|
||||
|
||||
@@ -275,6 +287,7 @@ node scripts/dev.js validate-dependencies --file=custom-tasks.json
|
||||
```
|
||||
|
||||
This command:
|
||||
|
||||
- Scans all tasks and subtasks for non-existent dependencies
|
||||
- Identifies potential self-dependencies (tasks referencing themselves)
|
||||
- Reports all found issues without modifying files
|
||||
@@ -296,6 +309,7 @@ node scripts/dev.js fix-dependencies --file=custom-tasks.json
|
||||
```
|
||||
|
||||
This command:
|
||||
|
||||
1. **Validates all dependencies** across tasks and subtasks
|
||||
2. **Automatically removes**:
|
||||
- References to non-existent tasks and subtasks
|
||||
@@ -333,6 +347,7 @@ node scripts/dev.js analyze-complexity --research
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- The command uses Claude to analyze each task's complexity (or Perplexity with --research flag)
|
||||
- Tasks are scored on a scale of 1-10
|
||||
- Each task receives a recommended number of subtasks based on DEFAULT_SUBTASKS configuration
|
||||
@@ -357,12 +372,14 @@ node scripts/dev.js expand --id=8 --num=5 --prompt="Custom prompt"
|
||||
```
|
||||
|
||||
When a complexity report exists:
|
||||
|
||||
- The `expand` command will use the recommended subtask count from the report (unless overridden)
|
||||
- It will use the tailored expansion prompt from the report (unless a custom prompt is provided)
|
||||
- When using `--all`, tasks are sorted by complexity score (highest first)
|
||||
- The `--research` flag is preserved from the complexity analysis to expansion
|
||||
|
||||
The output report structure is:
|
||||
|
||||
```json
|
||||
{
|
||||
"meta": {
|
||||
@@ -381,7 +398,7 @@ The output report structure is:
|
||||
"expansionPrompt": "Create subtasks that handle detecting...",
|
||||
"reasoning": "This task requires sophisticated logic...",
|
||||
"expansionCommand": "node scripts/dev.js expand --id=8 --num=6 --prompt=\"Create subtasks...\" --research"
|
||||
},
|
||||
}
|
||||
// More tasks sorted by complexity score (highest first)
|
||||
]
|
||||
}
|
||||
@@ -457,16 +474,19 @@ This command is particularly useful when you need to examine a specific task in
|
||||
The script now includes improved error handling throughout all commands:
|
||||
|
||||
1. **Detailed Validation**:
|
||||
|
||||
- Required parameters (like task IDs and prompts) are validated early
|
||||
- File existence is checked with customized errors for common scenarios
|
||||
- Parameter type conversion is handled with clear error messages
|
||||
|
||||
2. **Contextual Error Messages**:
|
||||
|
||||
- Task not found errors include suggestions to run the list command
|
||||
- API key errors include reminders to check environment variables
|
||||
- Invalid ID format errors show the expected format
|
||||
|
||||
3. **Command-Specific Help Displays**:
|
||||
|
||||
- When validation fails, detailed help for the specific command is shown
|
||||
- Help displays include usage examples and parameter descriptions
|
||||
- Formatted in clear, color-coded boxes with examples
|
||||
@@ -481,11 +501,13 @@ The script now includes improved error handling throughout all commands:
|
||||
The script now automatically checks for updates without slowing down execution:
|
||||
|
||||
1. **Background Version Checking**:
|
||||
|
||||
- Non-blocking version checks run in the background while commands execute
|
||||
- Actual command execution isn't delayed by version checking
|
||||
- Update notifications appear after command completion
|
||||
|
||||
2. **Update Notifications**:
|
||||
|
||||
- When a newer version is available, a notification is displayed
|
||||
- Notifications include current version, latest version, and update command
|
||||
- Formatted in an attention-grabbing box with clear instructions
|
||||
@@ -516,6 +538,7 @@ node scripts/dev.js add-subtask --parent=5 --title="Login API route" --skip-gene
|
||||
```
|
||||
|
||||
Key features:
|
||||
|
||||
- Create new subtasks with detailed properties or convert existing tasks
|
||||
- Define dependencies between subtasks
|
||||
- Set custom status for new subtasks
|
||||
@@ -538,6 +561,7 @@ node scripts/dev.js remove-subtask --id=5.2 --skip-generate
|
||||
```
|
||||
|
||||
Key features:
|
||||
|
||||
- Remove subtasks individually or in batches
|
||||
- Optionally convert subtasks to standalone tasks
|
||||
- Control whether task files are regenerated
|
||||
|
||||
428
scripts/init.js
428
scripts/init.js
@@ -1,5 +1,20 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Task Master
|
||||
* Copyright (c) 2025 Eyal Toledano, Ralph Khreish
|
||||
*
|
||||
* This software is licensed under the MIT License with Commons Clause.
|
||||
* You may use this software for any purpose, including commercial applications,
|
||||
* and modify and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. You may not sell this software or offer it as a service.
|
||||
* 2. The origin of this software must not be misrepresented.
|
||||
* 3. Altered source versions must be plainly marked as such.
|
||||
*
|
||||
* For the full license text, see the LICENSE file in the root directory.
|
||||
*/
|
||||
|
||||
console.log('Starting task-master-ai...');
|
||||
|
||||
import fs from 'fs';
|
||||
@@ -32,7 +47,10 @@ program
|
||||
.option('-n, --name <name>', 'Project name')
|
||||
.option('-my_name <name>', 'Project name (alias for --name)')
|
||||
.option('-d, --description <description>', 'Project description')
|
||||
.option('-my_description <description>', 'Project description (alias for --description)')
|
||||
.option(
|
||||
'-my_description <description>',
|
||||
'Project description (alias for --description)'
|
||||
)
|
||||
.option('-v, --version <version>', 'Project version')
|
||||
.option('-my_version <version>', 'Project version (alias for --version)')
|
||||
.option('--my_name <name>', 'Project name (alias for --name)')
|
||||
@@ -65,7 +83,9 @@ const LOG_LEVELS = {
|
||||
};
|
||||
|
||||
// Get log level from environment or default to info
|
||||
const LOG_LEVEL = process.env.LOG_LEVEL ? LOG_LEVELS[process.env.LOG_LEVEL.toLowerCase()] : LOG_LEVELS.info;
|
||||
const LOG_LEVEL = process.env.LOG_LEVEL
|
||||
? LOG_LEVELS[process.env.LOG_LEVEL.toLowerCase()]
|
||||
: LOG_LEVELS.info;
|
||||
|
||||
// Create a color gradient for the banner
|
||||
const coolGradient = gradient(['#00b4d8', '#0077b6', '#03045e']);
|
||||
@@ -83,14 +103,18 @@ function displayBanner() {
|
||||
console.log(coolGradient(bannerText));
|
||||
|
||||
// Add creator credit line below the banner
|
||||
console.log(chalk.dim('by ') + chalk.cyan.underline('https://x.com/eyaltoledano'));
|
||||
console.log(
|
||||
chalk.dim('by ') + chalk.cyan.underline('https://x.com/eyaltoledano')
|
||||
);
|
||||
|
||||
console.log(boxen(chalk.white(`${chalk.bold('Initializing')} your new project`), {
|
||||
console.log(
|
||||
boxen(chalk.white(`${chalk.bold('Initializing')} your new project`), {
|
||||
padding: 1,
|
||||
margin: { top: 0, bottom: 1 },
|
||||
borderStyle: 'round',
|
||||
borderColor: 'cyan'
|
||||
}));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// Logging function with icons and colors
|
||||
@@ -152,13 +176,16 @@ function addShellAliases() {
|
||||
try {
|
||||
// Check if file exists
|
||||
if (!fs.existsSync(shellConfigFile)) {
|
||||
log('warn', `Shell config file ${shellConfigFile} not found. Aliases not added.`);
|
||||
log(
|
||||
'warn',
|
||||
`Shell config file ${shellConfigFile} not found. Aliases not added.`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if aliases already exist
|
||||
const configContent = fs.readFileSync(shellConfigFile, 'utf8');
|
||||
if (configContent.includes('alias tm=\'task-master\'')) {
|
||||
if (configContent.includes("alias tm='task-master'")) {
|
||||
log('info', 'Task Master aliases already exist in shell config.');
|
||||
return true;
|
||||
}
|
||||
@@ -172,7 +199,11 @@ alias taskmaster='task-master'
|
||||
|
||||
fs.appendFileSync(shellConfigFile, aliasBlock);
|
||||
log('success', `Added Task Master aliases to ${shellConfigFile}`);
|
||||
log('info', 'To use the aliases in your current terminal, run: source ' + shellConfigFile);
|
||||
log(
|
||||
'info',
|
||||
'To use the aliases in your current terminal, run: source ' +
|
||||
shellConfigFile
|
||||
);
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
@@ -187,7 +218,7 @@ function copyTemplateFile(templateName, targetPath, replacements = {}) {
|
||||
let sourcePath;
|
||||
|
||||
// Map template names to their actual source paths
|
||||
switch(templateName) {
|
||||
switch (templateName) {
|
||||
case 'dev.js':
|
||||
sourcePath = path.join(__dirname, 'dev.js');
|
||||
break;
|
||||
@@ -195,13 +226,31 @@ function copyTemplateFile(templateName, targetPath, replacements = {}) {
|
||||
sourcePath = path.join(__dirname, '..', 'assets', 'scripts_README.md');
|
||||
break;
|
||||
case 'dev_workflow.mdc':
|
||||
sourcePath = path.join(__dirname, '..', '.cursor', 'rules', 'dev_workflow.mdc');
|
||||
sourcePath = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'.cursor',
|
||||
'rules',
|
||||
'dev_workflow.mdc'
|
||||
);
|
||||
break;
|
||||
case 'cursor_rules.mdc':
|
||||
sourcePath = path.join(__dirname, '..', '.cursor', 'rules', 'cursor_rules.mdc');
|
||||
sourcePath = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'.cursor',
|
||||
'rules',
|
||||
'cursor_rules.mdc'
|
||||
);
|
||||
break;
|
||||
case 'self_improve.mdc':
|
||||
sourcePath = path.join(__dirname, '..', '.cursor', 'rules', 'self_improve.mdc');
|
||||
sourcePath = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'.cursor',
|
||||
'rules',
|
||||
'self_improve.mdc'
|
||||
);
|
||||
break;
|
||||
case 'README-task-master.md':
|
||||
sourcePath = path.join(__dirname, '..', 'README-task-master.md');
|
||||
@@ -240,12 +289,17 @@ function copyTemplateFile(templateName, targetPath, replacements = {}) {
|
||||
if (filename === '.gitignore') {
|
||||
log('info', `${targetPath} already exists, merging content...`);
|
||||
const existingContent = fs.readFileSync(targetPath, 'utf8');
|
||||
const existingLines = new Set(existingContent.split('\n').map(line => line.trim()));
|
||||
const newLines = content.split('\n').filter(line => !existingLines.has(line.trim()));
|
||||
const existingLines = new Set(
|
||||
existingContent.split('\n').map((line) => line.trim())
|
||||
);
|
||||
const newLines = content
|
||||
.split('\n')
|
||||
.filter((line) => !existingLines.has(line.trim()));
|
||||
|
||||
if (newLines.length > 0) {
|
||||
// Add a comment to separate the original content from our additions
|
||||
const updatedContent = existingContent.trim() +
|
||||
const updatedContent =
|
||||
existingContent.trim() +
|
||||
'\n\n# Added by Claude Task Master\n' +
|
||||
newLines.join('\n');
|
||||
fs.writeFileSync(targetPath, updatedContent);
|
||||
@@ -258,11 +312,15 @@ function copyTemplateFile(templateName, targetPath, replacements = {}) {
|
||||
|
||||
// Handle .windsurfrules - append the entire content
|
||||
if (filename === '.windsurfrules') {
|
||||
log('info', `${targetPath} already exists, appending content instead of overwriting...`);
|
||||
log(
|
||||
'info',
|
||||
`${targetPath} already exists, appending content instead of overwriting...`
|
||||
);
|
||||
const existingContent = fs.readFileSync(targetPath, 'utf8');
|
||||
|
||||
// Add a separator comment before appending our content
|
||||
const updatedContent = existingContent.trim() +
|
||||
const updatedContent =
|
||||
existingContent.trim() +
|
||||
'\n\n# Added by Task Master - Development Workflow Rules\n\n' +
|
||||
content;
|
||||
fs.writeFileSync(targetPath, updatedContent);
|
||||
@@ -274,7 +332,9 @@ function copyTemplateFile(templateName, targetPath, replacements = {}) {
|
||||
if (filename === 'package.json') {
|
||||
log('info', `${targetPath} already exists, merging dependencies...`);
|
||||
try {
|
||||
const existingPackageJson = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
|
||||
const existingPackageJson = JSON.parse(
|
||||
fs.readFileSync(targetPath, 'utf8')
|
||||
);
|
||||
const newPackageJson = JSON.parse(content);
|
||||
|
||||
// Merge dependencies, preferring existing versions in case of conflicts
|
||||
@@ -287,8 +347,9 @@ function copyTemplateFile(templateName, targetPath, replacements = {}) {
|
||||
existingPackageJson.scripts = {
|
||||
...existingPackageJson.scripts,
|
||||
...Object.fromEntries(
|
||||
Object.entries(newPackageJson.scripts)
|
||||
.filter(([key]) => !existingPackageJson.scripts[key])
|
||||
Object.entries(newPackageJson.scripts).filter(
|
||||
([key]) => !existingPackageJson.scripts[key]
|
||||
)
|
||||
)
|
||||
};
|
||||
|
||||
@@ -301,7 +362,10 @@ function copyTemplateFile(templateName, targetPath, replacements = {}) {
|
||||
targetPath,
|
||||
JSON.stringify(existingPackageJson, null, 2)
|
||||
);
|
||||
log('success', `Updated ${targetPath} with required dependencies and scripts`);
|
||||
log(
|
||||
'success',
|
||||
`Updated ${targetPath} with required dependencies and scripts`
|
||||
);
|
||||
} catch (error) {
|
||||
log('error', `Failed to merge package.json: ${error.message}`);
|
||||
// Fallback to writing a backup of the existing file and creating a new one
|
||||
@@ -309,7 +373,10 @@ function copyTemplateFile(templateName, targetPath, replacements = {}) {
|
||||
fs.copyFileSync(targetPath, backupPath);
|
||||
log('info', `Created backup of existing package.json at ${backupPath}`);
|
||||
fs.writeFileSync(targetPath, content);
|
||||
log('warn', `Replaced ${targetPath} with new content (due to JSON parsing error)`);
|
||||
log(
|
||||
'warn',
|
||||
`Replaced ${targetPath} with new content (due to JSON parsing error)`
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -318,14 +385,23 @@ function copyTemplateFile(templateName, targetPath, replacements = {}) {
|
||||
if (filename === 'README.md') {
|
||||
log('info', `${targetPath} already exists`);
|
||||
// Create a separate README file specifically for this project
|
||||
const taskMasterReadmePath = path.join(path.dirname(targetPath), 'README-task-master.md');
|
||||
const taskMasterReadmePath = path.join(
|
||||
path.dirname(targetPath),
|
||||
'README-task-master.md'
|
||||
);
|
||||
fs.writeFileSync(taskMasterReadmePath, content);
|
||||
log('success', `Created ${taskMasterReadmePath} (preserved original README.md)`);
|
||||
log(
|
||||
'success',
|
||||
`Created ${taskMasterReadmePath} (preserved original README.md)`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// For other files, warn and prompt before overwriting
|
||||
log('warn', `${targetPath} already exists. Skipping file creation to avoid overwriting existing content.`);
|
||||
log(
|
||||
'warn',
|
||||
`${targetPath} already exists. Skipping file creation to avoid overwriting existing content.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -351,7 +427,10 @@ async function initializeProject(options = {}) {
|
||||
|
||||
if (dryRun) {
|
||||
log('info', 'DRY RUN MODE: No files will be modified');
|
||||
log('info', `Would initialize project: ${projectName} (${projectVersion})`);
|
||||
log(
|
||||
'info',
|
||||
`Would initialize project: ${projectName} (${projectVersion})`
|
||||
);
|
||||
log('info', `Description: ${projectDescription}`);
|
||||
log('info', `Author: ${authorName || 'Not specified'}`);
|
||||
log('info', 'Would create/update necessary project files');
|
||||
@@ -370,7 +449,14 @@ async function initializeProject(options = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
createProjectStructure(projectName, projectDescription, projectVersion, authorName, skipInstall, addAliases);
|
||||
createProjectStructure(
|
||||
projectName,
|
||||
projectDescription,
|
||||
projectVersion,
|
||||
authorName,
|
||||
skipInstall,
|
||||
addAliases
|
||||
);
|
||||
return {
|
||||
projectName,
|
||||
projectDescription,
|
||||
@@ -387,27 +473,53 @@ async function initializeProject(options = {}) {
|
||||
});
|
||||
|
||||
try {
|
||||
const projectName = await promptQuestion(rl, chalk.cyan('Enter project name: '));
|
||||
const projectDescription = await promptQuestion(rl, chalk.cyan('Enter project description: '));
|
||||
const projectVersionInput = await promptQuestion(rl, chalk.cyan('Enter project version (default: 1.0.0): '));
|
||||
const authorName = await promptQuestion(rl, chalk.cyan('Enter your name: '));
|
||||
const projectName = await promptQuestion(
|
||||
rl,
|
||||
chalk.cyan('Enter project name: ')
|
||||
);
|
||||
const projectDescription = await promptQuestion(
|
||||
rl,
|
||||
chalk.cyan('Enter project description: ')
|
||||
);
|
||||
const projectVersionInput = await promptQuestion(
|
||||
rl,
|
||||
chalk.cyan('Enter project version (default: 1.0.0): ')
|
||||
);
|
||||
const authorName = await promptQuestion(
|
||||
rl,
|
||||
chalk.cyan('Enter your name: ')
|
||||
);
|
||||
|
||||
// Ask about shell aliases
|
||||
const addAliasesInput = await promptQuestion(rl, chalk.cyan('Add shell aliases for task-master? (Y/n): '));
|
||||
const addAliasesInput = await promptQuestion(
|
||||
rl,
|
||||
chalk.cyan('Add shell aliases for task-master? (Y/n): ')
|
||||
);
|
||||
const addAliases = addAliasesInput.trim().toLowerCase() !== 'n';
|
||||
|
||||
// Set default version if not provided
|
||||
const projectVersion = projectVersionInput.trim() ? projectVersionInput : '1.0.0';
|
||||
const projectVersion = projectVersionInput.trim()
|
||||
? projectVersionInput
|
||||
: '1.0.0';
|
||||
|
||||
// Confirm settings
|
||||
console.log('\nProject settings:');
|
||||
console.log(chalk.blue('Name:'), chalk.white(projectName));
|
||||
console.log(chalk.blue('Description:'), chalk.white(projectDescription));
|
||||
console.log(chalk.blue('Version:'), chalk.white(projectVersion));
|
||||
console.log(chalk.blue('Author:'), chalk.white(authorName || 'Not specified'));
|
||||
console.log(chalk.blue('Add shell aliases:'), chalk.white(addAliases ? 'Yes' : 'No'));
|
||||
console.log(
|
||||
chalk.blue('Author:'),
|
||||
chalk.white(authorName || 'Not specified')
|
||||
);
|
||||
console.log(
|
||||
chalk.blue('Add shell aliases:'),
|
||||
chalk.white(addAliases ? 'Yes' : 'No')
|
||||
);
|
||||
|
||||
const confirmInput = await promptQuestion(rl, chalk.yellow('\nDo you want to continue with these settings? (Y/n): '));
|
||||
const confirmInput = await promptQuestion(
|
||||
rl,
|
||||
chalk.yellow('\nDo you want to continue with these settings? (Y/n): ')
|
||||
);
|
||||
const shouldContinue = confirmInput.trim().toLowerCase() !== 'n';
|
||||
|
||||
// Close the readline interface
|
||||
@@ -440,7 +552,14 @@ async function initializeProject(options = {}) {
|
||||
}
|
||||
|
||||
// Create the project structure
|
||||
createProjectStructure(projectName, projectDescription, projectVersion, authorName, skipInstall, addAliases);
|
||||
createProjectStructure(
|
||||
projectName,
|
||||
projectDescription,
|
||||
projectVersion,
|
||||
authorName,
|
||||
skipInstall,
|
||||
addAliases
|
||||
);
|
||||
|
||||
return {
|
||||
projectName,
|
||||
@@ -465,7 +584,14 @@ function promptQuestion(rl, question) {
|
||||
}
|
||||
|
||||
// Function to create the project structure
|
||||
function createProjectStructure(projectName, projectDescription, projectVersion, authorName, skipInstall, addAliases) {
|
||||
function createProjectStructure(
|
||||
projectName,
|
||||
projectDescription,
|
||||
projectVersion,
|
||||
authorName,
|
||||
skipInstall,
|
||||
addAliases
|
||||
) {
|
||||
const targetDir = process.cwd();
|
||||
log('info', `Initializing project in ${targetDir}`);
|
||||
|
||||
@@ -480,24 +606,24 @@ function createProjectStructure(projectName, projectDescription, projectVersion,
|
||||
version: projectVersion,
|
||||
description: projectDescription,
|
||||
author: authorName,
|
||||
type: "module",
|
||||
type: 'module',
|
||||
scripts: {
|
||||
"dev": "node scripts/dev.js",
|
||||
"list": "node scripts/dev.js list",
|
||||
"generate": "node scripts/dev.js generate",
|
||||
"parse-prd": "node scripts/dev.js parse-prd"
|
||||
dev: 'node scripts/dev.js',
|
||||
list: 'node scripts/dev.js list',
|
||||
generate: 'node scripts/dev.js generate',
|
||||
'parse-prd': 'node scripts/dev.js parse-prd'
|
||||
},
|
||||
dependencies: {
|
||||
"@anthropic-ai/sdk": "^0.39.0",
|
||||
"chalk": "^5.3.0",
|
||||
"commander": "^11.1.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"openai": "^4.86.1",
|
||||
"figlet": "^1.7.0",
|
||||
"boxen": "^7.1.1",
|
||||
"gradient-string": "^2.0.2",
|
||||
"cli-table3": "^0.6.3",
|
||||
"ora": "^7.0.1"
|
||||
'@anthropic-ai/sdk': '^0.39.0',
|
||||
chalk: '^5.3.0',
|
||||
commander: '^11.1.0',
|
||||
dotenv: '^16.3.1',
|
||||
openai: '^4.86.1',
|
||||
figlet: '^1.7.0',
|
||||
boxen: '^7.1.1',
|
||||
'gradient-string': '^2.0.2',
|
||||
'cli-table3': '^0.6.3',
|
||||
ora: '^7.0.1'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -506,7 +632,9 @@ function createProjectStructure(projectName, projectDescription, projectVersion,
|
||||
if (fs.existsSync(packageJsonPath)) {
|
||||
log('info', 'package.json already exists, merging content...');
|
||||
try {
|
||||
const existingPackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
const existingPackageJson = JSON.parse(
|
||||
fs.readFileSync(packageJsonPath, 'utf8')
|
||||
);
|
||||
|
||||
// Preserve existing fields but add our required ones
|
||||
const mergedPackageJson = {
|
||||
@@ -514,15 +642,21 @@ function createProjectStructure(projectName, projectDescription, projectVersion,
|
||||
scripts: {
|
||||
...existingPackageJson.scripts,
|
||||
...Object.fromEntries(
|
||||
Object.entries(packageJson.scripts)
|
||||
.filter(([key]) => !existingPackageJson.scripts || !existingPackageJson.scripts[key])
|
||||
Object.entries(packageJson.scripts).filter(
|
||||
([key]) =>
|
||||
!existingPackageJson.scripts ||
|
||||
!existingPackageJson.scripts[key]
|
||||
)
|
||||
)
|
||||
},
|
||||
dependencies: {
|
||||
...existingPackageJson.dependencies || {},
|
||||
...(existingPackageJson.dependencies || {}),
|
||||
...Object.fromEntries(
|
||||
Object.entries(packageJson.dependencies)
|
||||
.filter(([key]) => !existingPackageJson.dependencies || !existingPackageJson.dependencies[key])
|
||||
Object.entries(packageJson.dependencies).filter(
|
||||
([key]) =>
|
||||
!existingPackageJson.dependencies ||
|
||||
!existingPackageJson.dependencies[key]
|
||||
)
|
||||
)
|
||||
}
|
||||
};
|
||||
@@ -532,7 +666,10 @@ function createProjectStructure(projectName, projectDescription, projectVersion,
|
||||
mergedPackageJson.type = packageJson.type;
|
||||
}
|
||||
|
||||
fs.writeFileSync(packageJsonPath, JSON.stringify(mergedPackageJson, null, 2));
|
||||
fs.writeFileSync(
|
||||
packageJsonPath,
|
||||
JSON.stringify(mergedPackageJson, null, 2)
|
||||
);
|
||||
log('success', 'Updated package.json with required fields');
|
||||
} catch (error) {
|
||||
log('error', `Failed to merge package.json: ${error.message}`);
|
||||
@@ -541,7 +678,10 @@ function createProjectStructure(projectName, projectDescription, projectVersion,
|
||||
fs.copyFileSync(packageJsonPath, backupPath);
|
||||
log('info', `Created backup of existing package.json at ${backupPath}`);
|
||||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
||||
log('warn', 'Created new package.json (backup of original file was created)');
|
||||
log(
|
||||
'warn',
|
||||
'Created new package.json (backup of original file was created)'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// If package.json doesn't exist, create it
|
||||
@@ -562,19 +702,32 @@ function createProjectStructure(projectName, projectDescription, projectVersion,
|
||||
};
|
||||
|
||||
// Copy .env.example
|
||||
copyTemplateFile('env.example', path.join(targetDir, '.env.example'), replacements);
|
||||
copyTemplateFile(
|
||||
'env.example',
|
||||
path.join(targetDir, '.env.example'),
|
||||
replacements
|
||||
);
|
||||
|
||||
// Copy .gitignore
|
||||
copyTemplateFile('gitignore', path.join(targetDir, '.gitignore'));
|
||||
|
||||
// Copy dev_workflow.mdc
|
||||
copyTemplateFile('dev_workflow.mdc', path.join(targetDir, '.cursor', 'rules', 'dev_workflow.mdc'));
|
||||
copyTemplateFile(
|
||||
'dev_workflow.mdc',
|
||||
path.join(targetDir, '.cursor', 'rules', 'dev_workflow.mdc')
|
||||
);
|
||||
|
||||
// Copy cursor_rules.mdc
|
||||
copyTemplateFile('cursor_rules.mdc', path.join(targetDir, '.cursor', 'rules', 'cursor_rules.mdc'));
|
||||
copyTemplateFile(
|
||||
'cursor_rules.mdc',
|
||||
path.join(targetDir, '.cursor', 'rules', 'cursor_rules.mdc')
|
||||
);
|
||||
|
||||
// Copy self_improve.mdc
|
||||
copyTemplateFile('self_improve.mdc', path.join(targetDir, '.cursor', 'rules', 'self_improve.mdc'));
|
||||
copyTemplateFile(
|
||||
'self_improve.mdc',
|
||||
path.join(targetDir, '.cursor', 'rules', 'self_improve.mdc')
|
||||
);
|
||||
|
||||
// Copy .windsurfrules
|
||||
copyTemplateFile('windsurfrules', path.join(targetDir, '.windsurfrules'));
|
||||
@@ -583,13 +736,23 @@ function createProjectStructure(projectName, projectDescription, projectVersion,
|
||||
copyTemplateFile('dev.js', path.join(targetDir, 'scripts', 'dev.js'));
|
||||
|
||||
// Copy scripts/README.md
|
||||
copyTemplateFile('scripts_README.md', path.join(targetDir, 'scripts', 'README.md'));
|
||||
copyTemplateFile(
|
||||
'scripts_README.md',
|
||||
path.join(targetDir, 'scripts', 'README.md')
|
||||
);
|
||||
|
||||
// Copy example_prd.txt
|
||||
copyTemplateFile('example_prd.txt', path.join(targetDir, 'scripts', 'example_prd.txt'));
|
||||
copyTemplateFile(
|
||||
'example_prd.txt',
|
||||
path.join(targetDir, 'scripts', 'example_prd.txt')
|
||||
);
|
||||
|
||||
// Create main README.md
|
||||
copyTemplateFile('README-task-master.md', path.join(targetDir, 'README.md'), replacements);
|
||||
copyTemplateFile(
|
||||
'README-task-master.md',
|
||||
path.join(targetDir, 'README.md'),
|
||||
replacements
|
||||
);
|
||||
|
||||
// Initialize git repository if git is available
|
||||
try {
|
||||
@@ -603,12 +766,14 @@ function createProjectStructure(projectName, projectDescription, projectVersion,
|
||||
}
|
||||
|
||||
// Run npm install automatically
|
||||
console.log(boxen(chalk.cyan('Installing dependencies...'), {
|
||||
console.log(
|
||||
boxen(chalk.cyan('Installing dependencies...'), {
|
||||
padding: 0.5,
|
||||
margin: 0.5,
|
||||
borderStyle: 'round',
|
||||
borderColor: 'blue'
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
try {
|
||||
if (!skipInstall) {
|
||||
@@ -623,16 +788,21 @@ function createProjectStructure(projectName, projectDescription, projectVersion,
|
||||
}
|
||||
|
||||
// Display success message
|
||||
console.log(boxen(
|
||||
warmGradient.multiline(figlet.textSync('Success!', { font: 'Standard' })) +
|
||||
'\n' + chalk.green('Project initialized successfully!'),
|
||||
console.log(
|
||||
boxen(
|
||||
warmGradient.multiline(
|
||||
figlet.textSync('Success!', { font: 'Standard' })
|
||||
) +
|
||||
'\n' +
|
||||
chalk.green('Project initialized successfully!'),
|
||||
{
|
||||
padding: 1,
|
||||
margin: 1,
|
||||
borderStyle: 'double',
|
||||
borderColor: 'green'
|
||||
}
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
// Add shell aliases if requested
|
||||
if (addAliases) {
|
||||
@@ -640,19 +810,58 @@ function createProjectStructure(projectName, projectDescription, projectVersion,
|
||||
}
|
||||
|
||||
// Display next steps in a nice box
|
||||
console.log(boxen(
|
||||
chalk.cyan.bold('Things you can now do:') + '\n\n' +
|
||||
chalk.white('1. ') + chalk.yellow('Rename .env.example to .env and add your ANTHROPIC_API_KEY and PERPLEXITY_API_KEY') + '\n' +
|
||||
chalk.white('2. ') + chalk.yellow('Discuss your idea with AI, and once ready ask for a PRD using the example_prd.txt file, and save what you get to scripts/PRD.txt') + '\n' +
|
||||
chalk.white('3. ') + chalk.yellow('Ask Cursor Agent to parse your PRD.txt and generate tasks') + '\n' +
|
||||
chalk.white(' └─ ') + chalk.dim('You can also run ') + chalk.cyan('task-master parse-prd <your-prd-file.txt>') + '\n' +
|
||||
chalk.white('4. ') + chalk.yellow('Ask Cursor to analyze the complexity of your tasks') + '\n' +
|
||||
chalk.white('5. ') + chalk.yellow('Ask Cursor which task is next to determine where to start') + '\n' +
|
||||
chalk.white('6. ') + chalk.yellow('Ask Cursor to expand any complex tasks that are too large or complex.') + '\n' +
|
||||
chalk.white('7. ') + chalk.yellow('Ask Cursor to set the status of a task, or multiple tasks. Use the task id from the task lists.') + '\n' +
|
||||
chalk.white('8. ') + chalk.yellow('Ask Cursor to update all tasks from a specific task id based on new learnings or pivots in your project.') + '\n' +
|
||||
chalk.white('9. ') + chalk.green.bold('Ship it!') + '\n\n' +
|
||||
chalk.dim('* Review the README.md file to learn how to use other commands via Cursor Agent.'),
|
||||
console.log(
|
||||
boxen(
|
||||
chalk.cyan.bold('Things you can now do:') +
|
||||
'\n\n' +
|
||||
chalk.white('1. ') +
|
||||
chalk.yellow(
|
||||
'Rename .env.example to .env and add your ANTHROPIC_API_KEY and PERPLEXITY_API_KEY'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('2. ') +
|
||||
chalk.yellow(
|
||||
'Discuss your idea with AI, and once ready ask for a PRD using the example_prd.txt file, and save what you get to scripts/PRD.txt'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('3. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor Agent to parse your PRD.txt and generate tasks'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white(' └─ ') +
|
||||
chalk.dim('You can also run ') +
|
||||
chalk.cyan('task-master parse-prd <your-prd-file.txt>') +
|
||||
'\n' +
|
||||
chalk.white('4. ') +
|
||||
chalk.yellow('Ask Cursor to analyze the complexity of your tasks') +
|
||||
'\n' +
|
||||
chalk.white('5. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor which task is next to determine where to start'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('6. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor to expand any complex tasks that are too large or complex.'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('7. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor to set the status of a task, or multiple tasks. Use the task id from the task lists.'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('8. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor to update all tasks from a specific task id based on new learnings or pivots in your project.'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('9. ') +
|
||||
chalk.green.bold('Ship it!') +
|
||||
'\n\n' +
|
||||
chalk.dim(
|
||||
'* Review the README.md file to learn how to use other commands via Cursor Agent.'
|
||||
),
|
||||
{
|
||||
padding: 1,
|
||||
margin: 1,
|
||||
@@ -661,7 +870,8 @@ function createProjectStructure(projectName, projectDescription, projectVersion,
|
||||
title: 'Getting Started',
|
||||
titleAlignment: 'center'
|
||||
}
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Function to setup MCP configuration for Cursor integration
|
||||
@@ -676,12 +886,9 @@ function setupMCPConfiguration(targetDir, projectName) {
|
||||
|
||||
// New MCP config to be added - references the installed package
|
||||
const newMCPServer = {
|
||||
"task-master-ai": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"task-master-ai",
|
||||
"mcp-server"
|
||||
]
|
||||
'task-master-ai': {
|
||||
command: 'npx',
|
||||
args: ['task-master-ai', 'mcp-server']
|
||||
}
|
||||
};
|
||||
|
||||
@@ -698,18 +905,18 @@ function setupMCPConfiguration(targetDir, projectName) {
|
||||
}
|
||||
|
||||
// Add the task-master-ai server if it doesn't exist
|
||||
if (!mcpConfig.mcpServers["task-master-ai"]) {
|
||||
mcpConfig.mcpServers["task-master-ai"] = newMCPServer["task-master-ai"];
|
||||
log('info', 'Added task-master-ai server to existing MCP configuration');
|
||||
if (!mcpConfig.mcpServers['task-master-ai']) {
|
||||
mcpConfig.mcpServers['task-master-ai'] = newMCPServer['task-master-ai'];
|
||||
log(
|
||||
'info',
|
||||
'Added task-master-ai server to existing MCP configuration'
|
||||
);
|
||||
} else {
|
||||
log('info', 'task-master-ai server already configured in mcp.json');
|
||||
}
|
||||
|
||||
// Write the updated configuration
|
||||
fs.writeFileSync(
|
||||
mcpJsonPath,
|
||||
JSON.stringify(mcpConfig, null, 4)
|
||||
);
|
||||
fs.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 4));
|
||||
log('success', 'Updated MCP configuration file');
|
||||
} catch (error) {
|
||||
log('error', `Failed to update MCP configuration: ${error.message}`);
|
||||
@@ -722,16 +929,19 @@ function setupMCPConfiguration(targetDir, projectName) {
|
||||
|
||||
// Create new configuration
|
||||
const newMCPConfig = {
|
||||
"mcpServers": newMCPServer
|
||||
mcpServers: newMCPServer
|
||||
};
|
||||
|
||||
fs.writeFileSync(mcpJsonPath, JSON.stringify(newMCPConfig, null, 4));
|
||||
log('warn', 'Created new MCP configuration file (backup of original file was created if it existed)');
|
||||
log(
|
||||
'warn',
|
||||
'Created new MCP configuration file (backup of original file was created if it existed)'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// If mcp.json doesn't exist, create it
|
||||
const newMCPConfig = {
|
||||
"mcpServers": newMCPServer
|
||||
mcpServers: newMCPServer
|
||||
};
|
||||
|
||||
fs.writeFileSync(mcpJsonPath, JSON.stringify(newMCPConfig, null, 4));
|
||||
@@ -761,7 +971,9 @@ console.log('process.argv:', process.argv);
|
||||
// When using --yes flag or providing name and description, use CLI options
|
||||
await initializeProject({
|
||||
projectName: options.name || 'task-master-project',
|
||||
projectDescription: options.description || 'A task management system for AI-driven development',
|
||||
projectDescription:
|
||||
options.description ||
|
||||
'A task management system for AI-driven development',
|
||||
projectVersion: options.version || '1.0.0',
|
||||
authorName: options.author || '',
|
||||
dryRun: options.dryRun || false,
|
||||
@@ -787,8 +999,4 @@ console.log('process.argv:', process.argv);
|
||||
})();
|
||||
|
||||
// Export functions for programmatic use
|
||||
export {
|
||||
initializeProject,
|
||||
createProjectStructure,
|
||||
log
|
||||
};
|
||||
export { initializeProject, createProjectStructure, log };
|
||||
|
||||
@@ -34,11 +34,13 @@ let perplexity = null;
|
||||
function getPerplexityClient() {
|
||||
if (!perplexity) {
|
||||
if (!process.env.PERPLEXITY_API_KEY) {
|
||||
throw new Error("PERPLEXITY_API_KEY environment variable is missing. Set it to use research-backed features.");
|
||||
throw new Error(
|
||||
'PERPLEXITY_API_KEY environment variable is missing. Set it to use research-backed features.'
|
||||
);
|
||||
}
|
||||
perplexity = new OpenAI({
|
||||
apiKey: process.env.PERPLEXITY_API_KEY,
|
||||
baseURL: 'https://api.perplexity.ai',
|
||||
baseURL: 'https://api.perplexity.ai'
|
||||
});
|
||||
}
|
||||
return perplexity;
|
||||
@@ -85,13 +87,18 @@ function getAvailableAIModel(options = {}) {
|
||||
// Last resort: Use Claude even if overloaded (might fail)
|
||||
if (process.env.ANTHROPIC_API_KEY) {
|
||||
if (claudeOverloaded) {
|
||||
log('warn', 'Claude is overloaded but no alternatives are available. Proceeding with Claude anyway.');
|
||||
log(
|
||||
'warn',
|
||||
'Claude is overloaded but no alternatives are available. Proceeding with Claude anyway.'
|
||||
);
|
||||
}
|
||||
return { type: 'claude', client: anthropic };
|
||||
}
|
||||
|
||||
// No models available
|
||||
throw new Error('No AI models available. Please set ANTHROPIC_API_KEY and/or PERPLEXITY_API_KEY.');
|
||||
throw new Error(
|
||||
'No AI models available. Please set ANTHROPIC_API_KEY and/or PERPLEXITY_API_KEY.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,22 +197,32 @@ Expected output format:
|
||||
Important: Your response must be valid JSON only, with no additional explanation or comments.`;
|
||||
|
||||
// Use streaming request to handle large responses and show progress
|
||||
return await handleStreamingRequest(prdContent, prdPath, numTasks, CONFIG.maxTokens, systemPrompt);
|
||||
return await handleStreamingRequest(
|
||||
prdContent,
|
||||
prdPath,
|
||||
numTasks,
|
||||
CONFIG.maxTokens,
|
||||
systemPrompt
|
||||
);
|
||||
} catch (error) {
|
||||
// Get user-friendly error message
|
||||
const userMessage = handleClaudeError(error);
|
||||
log('error', userMessage);
|
||||
|
||||
// Retry logic for certain errors
|
||||
if (retryCount < 2 && (
|
||||
error.error?.type === 'overloaded_error' ||
|
||||
if (
|
||||
retryCount < 2 &&
|
||||
(error.error?.type === 'overloaded_error' ||
|
||||
error.error?.type === 'rate_limit_error' ||
|
||||
error.message?.toLowerCase().includes('timeout') ||
|
||||
error.message?.toLowerCase().includes('network')
|
||||
)) {
|
||||
error.message?.toLowerCase().includes('network'))
|
||||
) {
|
||||
const waitTime = (retryCount + 1) * 5000; // 5s, then 10s
|
||||
log('info', `Waiting ${waitTime/1000} seconds before retry ${retryCount + 1}/2...`);
|
||||
await new Promise(resolve => setTimeout(resolve, waitTime));
|
||||
log(
|
||||
'info',
|
||||
`Waiting ${waitTime / 1000} seconds before retry ${retryCount + 1}/2...`
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
||||
return await callClaude(prdContent, prdPath, numTasks, retryCount + 1);
|
||||
} else {
|
||||
console.error(chalk.red(userMessage));
|
||||
@@ -226,8 +243,16 @@ Important: Your response must be valid JSON only, with no additional explanation
|
||||
* @param {string} systemPrompt - System prompt
|
||||
* @returns {Object} Claude's response
|
||||
*/
|
||||
async function handleStreamingRequest(prdContent, prdPath, numTasks, maxTokens, systemPrompt) {
|
||||
const loadingIndicator = startLoadingIndicator('Generating tasks from PRD...');
|
||||
async function handleStreamingRequest(
|
||||
prdContent,
|
||||
prdPath,
|
||||
numTasks,
|
||||
maxTokens,
|
||||
systemPrompt
|
||||
) {
|
||||
const loadingIndicator = startLoadingIndicator(
|
||||
'Generating tasks from PRD...'
|
||||
);
|
||||
let responseText = '';
|
||||
let streamingInterval = null;
|
||||
|
||||
@@ -252,7 +277,9 @@ async function handleStreamingRequest(prdContent, prdPath, numTasks, maxTokens,
|
||||
const readline = await import('readline');
|
||||
streamingInterval = setInterval(() => {
|
||||
readline.cursorTo(process.stdout, 0);
|
||||
process.stdout.write(`Receiving streaming response from Claude${'.'.repeat(dotCount)}`);
|
||||
process.stdout.write(
|
||||
`Receiving streaming response from Claude${'.'.repeat(dotCount)}`
|
||||
);
|
||||
dotCount = (dotCount + 1) % 4;
|
||||
}, 500);
|
||||
|
||||
@@ -266,9 +293,15 @@ async function handleStreamingRequest(prdContent, prdPath, numTasks, maxTokens,
|
||||
if (streamingInterval) clearInterval(streamingInterval);
|
||||
stopLoadingIndicator(loadingIndicator);
|
||||
|
||||
log('info', "Completed streaming response from Claude API!");
|
||||
log('info', 'Completed streaming response from Claude API!');
|
||||
|
||||
return processClaudeResponse(responseText, numTasks, 0, prdContent, prdPath);
|
||||
return processClaudeResponse(
|
||||
responseText,
|
||||
numTasks,
|
||||
0,
|
||||
prdContent,
|
||||
prdPath
|
||||
);
|
||||
} catch (error) {
|
||||
if (streamingInterval) clearInterval(streamingInterval);
|
||||
stopLoadingIndicator(loadingIndicator);
|
||||
@@ -295,7 +328,13 @@ async function handleStreamingRequest(prdContent, prdPath, numTasks, maxTokens,
|
||||
* @param {string} prdPath - Path to the PRD file
|
||||
* @returns {Object} Processed response
|
||||
*/
|
||||
function processClaudeResponse(textContent, numTasks, retryCount, prdContent, prdPath) {
|
||||
function processClaudeResponse(
|
||||
textContent,
|
||||
numTasks,
|
||||
retryCount,
|
||||
prdContent,
|
||||
prdPath
|
||||
) {
|
||||
try {
|
||||
// Attempt to parse the JSON response
|
||||
let jsonStart = textContent.indexOf('{');
|
||||
@@ -315,13 +354,16 @@ function processClaudeResponse(textContent, numTasks, retryCount, prdContent, pr
|
||||
|
||||
// Ensure we have the correct number of tasks
|
||||
if (parsedData.tasks.length !== numTasks) {
|
||||
log('warn', `Expected ${numTasks} tasks, but received ${parsedData.tasks.length}`);
|
||||
log(
|
||||
'warn',
|
||||
`Expected ${numTasks} tasks, but received ${parsedData.tasks.length}`
|
||||
);
|
||||
}
|
||||
|
||||
// Add metadata if missing
|
||||
if (!parsedData.metadata) {
|
||||
parsedData.metadata = {
|
||||
projectName: "PRD Implementation",
|
||||
projectName: 'PRD Implementation',
|
||||
totalTasks: parsedData.tasks.length,
|
||||
sourceFile: prdPath,
|
||||
generatedAt: new Date().toISOString().split('T')[0]
|
||||
@@ -338,11 +380,17 @@ function processClaudeResponse(textContent, numTasks, retryCount, prdContent, pr
|
||||
|
||||
// Try again with Claude for a cleaner response
|
||||
if (retryCount === 1) {
|
||||
log('info', "Calling Claude again for a cleaner response...");
|
||||
log('info', 'Calling Claude again for a cleaner response...');
|
||||
return callClaude(prdContent, prdPath, numTasks, retryCount + 1);
|
||||
}
|
||||
|
||||
return processClaudeResponse(textContent, numTasks, retryCount + 1, prdContent, prdPath);
|
||||
return processClaudeResponse(
|
||||
textContent,
|
||||
numTasks,
|
||||
retryCount + 1,
|
||||
prdContent,
|
||||
prdPath
|
||||
);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
@@ -357,11 +405,21 @@ function processClaudeResponse(textContent, numTasks, retryCount, prdContent, pr
|
||||
* @param {string} additionalContext - Additional context
|
||||
* @returns {Array} Generated subtasks
|
||||
*/
|
||||
async function generateSubtasks(task, numSubtasks, nextSubtaskId, additionalContext = '') {
|
||||
async function generateSubtasks(
|
||||
task,
|
||||
numSubtasks,
|
||||
nextSubtaskId,
|
||||
additionalContext = ''
|
||||
) {
|
||||
try {
|
||||
log('info', `Generating ${numSubtasks} subtasks for task ${task.id}: ${task.title}`);
|
||||
log(
|
||||
'info',
|
||||
`Generating ${numSubtasks} subtasks for task ${task.id}: ${task.title}`
|
||||
);
|
||||
|
||||
const loadingIndicator = startLoadingIndicator(`Generating subtasks for task ${task.id}...`);
|
||||
const loadingIndicator = startLoadingIndicator(
|
||||
`Generating subtasks for task ${task.id}...`
|
||||
);
|
||||
let streamingInterval = null;
|
||||
let responseText = '';
|
||||
|
||||
@@ -384,8 +442,9 @@ For each subtask, provide:
|
||||
|
||||
Each subtask should be implementable in a focused coding session.`;
|
||||
|
||||
const contextPrompt = additionalContext ?
|
||||
`\n\nAdditional context to consider: ${additionalContext}` : '';
|
||||
const contextPrompt = additionalContext
|
||||
? `\n\nAdditional context to consider: ${additionalContext}`
|
||||
: '';
|
||||
|
||||
const userPrompt = `Please break down this task into ${numSubtasks} specific, actionable subtasks:
|
||||
|
||||
@@ -415,7 +474,9 @@ Note on dependencies: Subtasks can depend on other subtasks with lower IDs. Use
|
||||
const readline = await import('readline');
|
||||
streamingInterval = setInterval(() => {
|
||||
readline.cursorTo(process.stdout, 0);
|
||||
process.stdout.write(`Generating subtasks for task ${task.id}${'.'.repeat(dotCount)}`);
|
||||
process.stdout.write(
|
||||
`Generating subtasks for task ${task.id}${'.'.repeat(dotCount)}`
|
||||
);
|
||||
dotCount = (dotCount + 1) % 4;
|
||||
}, 500);
|
||||
|
||||
@@ -446,7 +507,12 @@ Note on dependencies: Subtasks can depend on other subtasks with lower IDs. Use
|
||||
|
||||
log('info', `Completed generating subtasks for task ${task.id}`);
|
||||
|
||||
return parseSubtasksFromText(responseText, nextSubtaskId, numSubtasks, task.id);
|
||||
return parseSubtasksFromText(
|
||||
responseText,
|
||||
nextSubtaskId,
|
||||
numSubtasks,
|
||||
task.id
|
||||
);
|
||||
} catch (error) {
|
||||
if (streamingInterval) clearInterval(streamingInterval);
|
||||
stopLoadingIndicator(loadingIndicator);
|
||||
@@ -466,14 +532,21 @@ Note on dependencies: Subtasks can depend on other subtasks with lower IDs. Use
|
||||
* @param {string} additionalContext - Additional context
|
||||
* @returns {Array} Generated subtasks
|
||||
*/
|
||||
async function generateSubtasksWithPerplexity(task, numSubtasks = 3, nextSubtaskId = 1, additionalContext = '') {
|
||||
async function generateSubtasksWithPerplexity(
|
||||
task,
|
||||
numSubtasks = 3,
|
||||
nextSubtaskId = 1,
|
||||
additionalContext = ''
|
||||
) {
|
||||
try {
|
||||
// First, perform research to get context
|
||||
log('info', `Researching context for task ${task.id}: ${task.title}`);
|
||||
const perplexityClient = getPerplexityClient();
|
||||
|
||||
const PERPLEXITY_MODEL = process.env.PERPLEXITY_MODEL || 'sonar-pro';
|
||||
const researchLoadingIndicator = startLoadingIndicator('Researching best practices with Perplexity AI...');
|
||||
const researchLoadingIndicator = startLoadingIndicator(
|
||||
'Researching best practices with Perplexity AI...'
|
||||
);
|
||||
|
||||
// Formulate research query based on task
|
||||
const researchQuery = `I need to implement "${task.title}" which involves: "${task.description}".
|
||||
@@ -483,17 +556,22 @@ Include concrete code examples and technical considerations where relevant.`;
|
||||
// Query Perplexity for research
|
||||
const researchResponse = await perplexityClient.chat.completions.create({
|
||||
model: PERPLEXITY_MODEL,
|
||||
messages: [{
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: researchQuery
|
||||
}],
|
||||
}
|
||||
],
|
||||
temperature: 0.1 // Lower temperature for more factual responses
|
||||
});
|
||||
|
||||
const researchResult = researchResponse.choices[0].message.content;
|
||||
|
||||
stopLoadingIndicator(researchLoadingIndicator);
|
||||
log('info', 'Research completed, now generating subtasks with additional context');
|
||||
log(
|
||||
'info',
|
||||
'Research completed, now generating subtasks with additional context'
|
||||
);
|
||||
|
||||
// Use the research result as additional context for Claude to generate subtasks
|
||||
const combinedContext = `
|
||||
@@ -501,11 +579,13 @@ RESEARCH FINDINGS:
|
||||
${researchResult}
|
||||
|
||||
ADDITIONAL CONTEXT PROVIDED BY USER:
|
||||
${additionalContext || "No additional context provided."}
|
||||
${additionalContext || 'No additional context provided.'}
|
||||
`;
|
||||
|
||||
// Now generate subtasks with Claude
|
||||
const loadingIndicator = startLoadingIndicator(`Generating research-backed subtasks for task ${task.id}...`);
|
||||
const loadingIndicator = startLoadingIndicator(
|
||||
`Generating research-backed subtasks for task ${task.id}...`
|
||||
);
|
||||
let streamingInterval = null;
|
||||
let responseText = '';
|
||||
|
||||
@@ -560,7 +640,9 @@ Note on dependencies: Subtasks can depend on other subtasks with lower IDs. Use
|
||||
const readline = await import('readline');
|
||||
streamingInterval = setInterval(() => {
|
||||
readline.cursorTo(process.stdout, 0);
|
||||
process.stdout.write(`Generating research-backed subtasks for task ${task.id}${'.'.repeat(dotCount)}`);
|
||||
process.stdout.write(
|
||||
`Generating research-backed subtasks for task ${task.id}${'.'.repeat(dotCount)}`
|
||||
);
|
||||
dotCount = (dotCount + 1) % 4;
|
||||
}, 500);
|
||||
|
||||
@@ -589,9 +671,17 @@ Note on dependencies: Subtasks can depend on other subtasks with lower IDs. Use
|
||||
if (streamingInterval) clearInterval(streamingInterval);
|
||||
stopLoadingIndicator(loadingIndicator);
|
||||
|
||||
log('info', `Completed generating research-backed subtasks for task ${task.id}`);
|
||||
log(
|
||||
'info',
|
||||
`Completed generating research-backed subtasks for task ${task.id}`
|
||||
);
|
||||
|
||||
return parseSubtasksFromText(responseText, nextSubtaskId, numSubtasks, task.id);
|
||||
return parseSubtasksFromText(
|
||||
responseText,
|
||||
nextSubtaskId,
|
||||
numSubtasks,
|
||||
task.id
|
||||
);
|
||||
} catch (error) {
|
||||
if (streamingInterval) clearInterval(streamingInterval);
|
||||
stopLoadingIndicator(loadingIndicator);
|
||||
@@ -617,8 +707,12 @@ function parseSubtasksFromText(text, startId, expectedCount, parentTaskId) {
|
||||
const jsonStartIndex = text.indexOf('[');
|
||||
const jsonEndIndex = text.lastIndexOf(']');
|
||||
|
||||
if (jsonStartIndex === -1 || jsonEndIndex === -1 || jsonEndIndex < jsonStartIndex) {
|
||||
throw new Error("Could not locate valid JSON array in the response");
|
||||
if (
|
||||
jsonStartIndex === -1 ||
|
||||
jsonEndIndex === -1 ||
|
||||
jsonEndIndex < jsonStartIndex
|
||||
) {
|
||||
throw new Error('Could not locate valid JSON array in the response');
|
||||
}
|
||||
|
||||
// Extract and parse the JSON
|
||||
@@ -627,25 +721,31 @@ function parseSubtasksFromText(text, startId, expectedCount, parentTaskId) {
|
||||
|
||||
// Validate
|
||||
if (!Array.isArray(subtasks)) {
|
||||
throw new Error("Parsed content is not an array");
|
||||
throw new Error('Parsed content is not an array');
|
||||
}
|
||||
|
||||
// Log warning if count doesn't match expected
|
||||
if (subtasks.length !== expectedCount) {
|
||||
log('warn', `Expected ${expectedCount} subtasks, but parsed ${subtasks.length}`);
|
||||
log(
|
||||
'warn',
|
||||
`Expected ${expectedCount} subtasks, but parsed ${subtasks.length}`
|
||||
);
|
||||
}
|
||||
|
||||
// Normalize subtask IDs if they don't match
|
||||
subtasks = subtasks.map((subtask, index) => {
|
||||
// Assign the correct ID if it doesn't match
|
||||
if (subtask.id !== startId + index) {
|
||||
log('warn', `Correcting subtask ID from ${subtask.id} to ${startId + index}`);
|
||||
log(
|
||||
'warn',
|
||||
`Correcting subtask ID from ${subtask.id} to ${startId + index}`
|
||||
);
|
||||
subtask.id = startId + index;
|
||||
}
|
||||
|
||||
// Convert dependencies to numbers if they are strings
|
||||
if (subtask.dependencies && Array.isArray(subtask.dependencies)) {
|
||||
subtask.dependencies = subtask.dependencies.map(dep => {
|
||||
subtask.dependencies = subtask.dependencies.map((dep) => {
|
||||
return typeof dep === 'string' ? parseInt(dep, 10) : dep;
|
||||
});
|
||||
} else {
|
||||
@@ -674,9 +774,10 @@ function parseSubtasksFromText(text, startId, expectedCount, parentTaskId) {
|
||||
fallbackSubtasks.push({
|
||||
id: startId + i,
|
||||
title: `Subtask ${startId + i}`,
|
||||
description: "Auto-generated fallback subtask",
|
||||
description: 'Auto-generated fallback subtask',
|
||||
dependencies: [],
|
||||
details: "This is a fallback subtask created because parsing failed. Please update with real details.",
|
||||
details:
|
||||
'This is a fallback subtask created because parsing failed. Please update with real details.',
|
||||
status: 'pending',
|
||||
parentTaskId: parentTaskId
|
||||
});
|
||||
@@ -694,14 +795,18 @@ function parseSubtasksFromText(text, startId, expectedCount, parentTaskId) {
|
||||
function generateComplexityAnalysisPrompt(tasksData) {
|
||||
return `Analyze the complexity of the following tasks and provide recommendations for subtask breakdown:
|
||||
|
||||
${tasksData.tasks.map(task => `
|
||||
${tasksData.tasks
|
||||
.map(
|
||||
(task) => `
|
||||
Task ID: ${task.id}
|
||||
Title: ${task.title}
|
||||
Description: ${task.description}
|
||||
Details: ${task.details}
|
||||
Dependencies: ${JSON.stringify(task.dependencies || [])}
|
||||
Priority: ${task.priority || 'medium'}
|
||||
`).join('\n---\n')}
|
||||
`
|
||||
)
|
||||
.join('\n---\n')}
|
||||
|
||||
Analyze each task and return a JSON array with the following structure for each task:
|
||||
[
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -12,12 +12,12 @@ const CONFIG = {
|
||||
model: process.env.MODEL || 'claude-3-7-sonnet-20250219',
|
||||
maxTokens: parseInt(process.env.MAX_TOKENS || '4000'),
|
||||
temperature: parseFloat(process.env.TEMPERATURE || '0.7'),
|
||||
debug: process.env.DEBUG === "true",
|
||||
logLevel: process.env.LOG_LEVEL || "info",
|
||||
defaultSubtasks: parseInt(process.env.DEFAULT_SUBTASKS || "3"),
|
||||
defaultPriority: process.env.DEFAULT_PRIORITY || "medium",
|
||||
projectName: process.env.PROJECT_NAME || "Task Master",
|
||||
projectVersion: "1.5.0" // Hardcoded version - ALWAYS use this value, ignore environment variable
|
||||
debug: process.env.DEBUG === 'true',
|
||||
logLevel: process.env.LOG_LEVEL || 'info',
|
||||
defaultSubtasks: parseInt(process.env.DEFAULT_SUBTASKS || '3'),
|
||||
defaultPriority: process.env.DEFAULT_PRIORITY || 'medium',
|
||||
projectName: process.env.PROJECT_NAME || 'Task Master',
|
||||
projectVersion: '1.5.0' // Hardcoded version - ALWAYS use this value, ignore environment variable
|
||||
};
|
||||
|
||||
// Set up logging based on log level
|
||||
@@ -99,7 +99,9 @@ function sanitizePrompt(prompt) {
|
||||
*/
|
||||
function readComplexityReport(customPath = null) {
|
||||
try {
|
||||
const reportPath = customPath || path.join(process.cwd(), 'scripts', 'task-complexity-report.json');
|
||||
const reportPath =
|
||||
customPath ||
|
||||
path.join(process.cwd(), 'scripts', 'task-complexity-report.json');
|
||||
if (!fs.existsSync(reportPath)) {
|
||||
return null;
|
||||
}
|
||||
@@ -119,11 +121,15 @@ function readComplexityReport(customPath = null) {
|
||||
* @returns {Object|null} The task analysis or null if not found
|
||||
*/
|
||||
function findTaskInComplexityReport(report, taskId) {
|
||||
if (!report || !report.complexityAnalysis || !Array.isArray(report.complexityAnalysis)) {
|
||||
if (
|
||||
!report ||
|
||||
!report.complexityAnalysis ||
|
||||
!Array.isArray(report.complexityAnalysis)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return report.complexityAnalysis.find(task => task.taskId === taskId);
|
||||
return report.complexityAnalysis.find((task) => task.taskId === taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,18 +145,20 @@ function taskExists(tasks, taskId) {
|
||||
|
||||
// Handle both regular task IDs and subtask IDs (e.g., "1.2")
|
||||
if (typeof taskId === 'string' && taskId.includes('.')) {
|
||||
const [parentId, subtaskId] = taskId.split('.').map(id => parseInt(id, 10));
|
||||
const parentTask = tasks.find(t => t.id === parentId);
|
||||
const [parentId, subtaskId] = taskId
|
||||
.split('.')
|
||||
.map((id) => parseInt(id, 10));
|
||||
const parentTask = tasks.find((t) => t.id === parentId);
|
||||
|
||||
if (!parentTask || !parentTask.subtasks) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return parentTask.subtasks.some(st => st.id === subtaskId);
|
||||
return parentTask.subtasks.some((st) => st.id === subtaskId);
|
||||
}
|
||||
|
||||
const id = parseInt(taskId, 10);
|
||||
return tasks.some(t => t.id === id);
|
||||
return tasks.some((t) => t.id === id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,14 +191,16 @@ function findTaskById(tasks, taskId) {
|
||||
|
||||
// Check if it's a subtask ID (e.g., "1.2")
|
||||
if (typeof taskId === 'string' && taskId.includes('.')) {
|
||||
const [parentId, subtaskId] = taskId.split('.').map(id => parseInt(id, 10));
|
||||
const parentTask = tasks.find(t => t.id === parentId);
|
||||
const [parentId, subtaskId] = taskId
|
||||
.split('.')
|
||||
.map((id) => parseInt(id, 10));
|
||||
const parentTask = tasks.find((t) => t.id === parentId);
|
||||
|
||||
if (!parentTask || !parentTask.subtasks) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const subtask = parentTask.subtasks.find(st => st.id === subtaskId);
|
||||
const subtask = parentTask.subtasks.find((st) => st.id === subtaskId);
|
||||
if (subtask) {
|
||||
// Add reference to parent task for context
|
||||
subtask.parentTask = {
|
||||
@@ -205,7 +215,7 @@ function findTaskById(tasks, taskId) {
|
||||
}
|
||||
|
||||
const id = parseInt(taskId, 10);
|
||||
return tasks.find(t => t.id === id) || null;
|
||||
return tasks.find((t) => t.id === id) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,7 +240,13 @@ function truncate(text, maxLength) {
|
||||
* @param {Set} recursionStack - Set of nodes in current recursion stack
|
||||
* @returns {Array} - List of dependency edges that need to be removed to break cycles
|
||||
*/
|
||||
function findCycles(subtaskId, dependencyMap, visited = new Set(), recursionStack = new Set(), path = []) {
|
||||
function findCycles(
|
||||
subtaskId,
|
||||
dependencyMap,
|
||||
visited = new Set(),
|
||||
recursionStack = new Set(),
|
||||
path = []
|
||||
) {
|
||||
// Mark the current node as visited and part of recursion stack
|
||||
visited.add(subtaskId);
|
||||
recursionStack.add(subtaskId);
|
||||
@@ -245,7 +261,9 @@ function findCycles(subtaskId, dependencyMap, visited = new Set(), recursionStac
|
||||
for (const depId of dependencies) {
|
||||
// If not visited, recursively check for cycles
|
||||
if (!visited.has(depId)) {
|
||||
const cycles = findCycles(depId, dependencyMap, visited, recursionStack, [...path]);
|
||||
const cycles = findCycles(depId, dependencyMap, visited, recursionStack, [
|
||||
...path
|
||||
]);
|
||||
cyclesToBreak.push(...cycles);
|
||||
}
|
||||
// If the dependency is in the recursion stack, we found a cycle
|
||||
|
||||
@@ -35,12 +35,14 @@ const COLORS = {
|
||||
|
||||
// Parse command line arguments
|
||||
const args = process.argv.slice(2);
|
||||
const versionBump = args.includes('--major') ? 'major' :
|
||||
args.includes('--minor') ? 'minor' :
|
||||
'patch';
|
||||
const versionBump = args.includes('--major')
|
||||
? 'major'
|
||||
: args.includes('--minor')
|
||||
? 'minor'
|
||||
: 'patch';
|
||||
|
||||
// Check for explicit version
|
||||
const versionArg = args.find(arg => arg.startsWith('--version='));
|
||||
const versionArg = args.find((arg) => arg.startsWith('--version='));
|
||||
const explicitVersion = versionArg ? versionArg.split('=')[1] : null;
|
||||
|
||||
// Log function with color support
|
||||
@@ -75,7 +77,10 @@ function ensureExecutable(filePath) {
|
||||
// Function to sync template files
|
||||
function syncTemplateFiles() {
|
||||
// We no longer need to sync files since we're using them directly
|
||||
log('info', 'Template syncing has been deprecated - using source files directly');
|
||||
log(
|
||||
'info',
|
||||
'Template syncing has been deprecated - using source files directly'
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -107,10 +112,16 @@ function preparePackage() {
|
||||
let newVersion;
|
||||
if (explicitVersion) {
|
||||
newVersion = explicitVersion;
|
||||
log('info', `Setting version to specified ${newVersion} (was ${currentVersion})`);
|
||||
log(
|
||||
'info',
|
||||
`Setting version to specified ${newVersion} (was ${currentVersion})`
|
||||
);
|
||||
} else {
|
||||
newVersion = incrementVersion(currentVersion, versionBump);
|
||||
log('info', `Incrementing ${versionBump} version to ${newVersion} (was ${currentVersion})`);
|
||||
log(
|
||||
'info',
|
||||
`Incrementing ${versionBump} version to ${newVersion} (was ${currentVersion})`
|
||||
);
|
||||
}
|
||||
|
||||
packageJson.version = newVersion;
|
||||
@@ -143,15 +154,15 @@ function preparePackage() {
|
||||
}
|
||||
|
||||
if (!allFilesExist) {
|
||||
log('error', 'Some required files are missing. Package preparation failed.');
|
||||
log(
|
||||
'error',
|
||||
'Some required files are missing. Package preparation failed.'
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Ensure scripts are executable
|
||||
const executableScripts = [
|
||||
'scripts/init.js',
|
||||
'scripts/dev.js'
|
||||
];
|
||||
const executableScripts = ['scripts/init.js', 'scripts/dev.js'];
|
||||
|
||||
let allScriptsExecutable = true;
|
||||
for (const script of executableScripts) {
|
||||
@@ -162,7 +173,10 @@ function preparePackage() {
|
||||
}
|
||||
|
||||
if (!allScriptsExecutable) {
|
||||
log('warn', 'Some scripts could not be made executable. This may cause issues.');
|
||||
log(
|
||||
'warn',
|
||||
'Some scripts could not be made executable. This may cause issues.'
|
||||
);
|
||||
}
|
||||
|
||||
// Run npm pack to test package creation
|
||||
|
||||
@@ -44,7 +44,8 @@ function createErrorSimulationScript(errorType, failureCount = 2) {
|
||||
let modifiedContent = devJsContent;
|
||||
|
||||
// Find the anthropic.messages.create call and replace it with our mock
|
||||
const anthropicCallRegex = /const response = await anthropic\.messages\.create\(/;
|
||||
const anthropicCallRegex =
|
||||
/const response = await anthropic\.messages\.create\(/;
|
||||
|
||||
let mockCode = '';
|
||||
|
||||
@@ -162,13 +163,18 @@ async function runErrorTest(errorType, numTasks = 5, failureCount = 2) {
|
||||
|
||||
console.log(`Created test PRD at ${testPRDPath}`);
|
||||
console.log(`Created error simulation script at ${tempScriptPath}`);
|
||||
console.log(`Running with error type: ${errorType}, failure count: ${failureCount}, tasks: ${numTasks}`);
|
||||
console.log(
|
||||
`Running with error type: ${errorType}, failure count: ${failureCount}, tasks: ${numTasks}`
|
||||
);
|
||||
|
||||
try {
|
||||
// Run the modified script
|
||||
execSync(`node ${tempScriptPath} parse-prd --input=${testPRDPath} --tasks=${numTasks}`, {
|
||||
execSync(
|
||||
`node ${tempScriptPath} parse-prd --input=${testPRDPath} --tasks=${numTasks}`,
|
||||
{
|
||||
stdio: 'inherit'
|
||||
});
|
||||
}
|
||||
);
|
||||
console.log(`${errorType} error test completed successfully`);
|
||||
} catch (error) {
|
||||
console.error(`${errorType} error test failed:`, error.message);
|
||||
@@ -206,7 +212,7 @@ async function runAllErrorTests() {
|
||||
}
|
||||
|
||||
// Run the tests
|
||||
runAllErrorTests().catch(error => {
|
||||
runAllErrorTests().catch((error) => {
|
||||
console.error('Error running tests:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -157,9 +157,12 @@ async function runTests() {
|
||||
const { execSync } = await import('child_process');
|
||||
|
||||
try {
|
||||
const smallResult = execSync(`node ${path.join(__dirname, 'dev.js')} parse-prd --input=${smallPRDPath} --tasks=5`, {
|
||||
const smallResult = execSync(
|
||||
`node ${path.join(__dirname, 'dev.js')} parse-prd --input=${smallPRDPath} --tasks=5`,
|
||||
{
|
||||
stdio: 'inherit'
|
||||
});
|
||||
}
|
||||
);
|
||||
console.log('Small PRD test completed successfully');
|
||||
} catch (error) {
|
||||
console.error('Small PRD test failed:', error.message);
|
||||
@@ -175,9 +178,12 @@ async function runTests() {
|
||||
console.log('Running dev.js with medium PRD...');
|
||||
|
||||
try {
|
||||
const mediumResult = execSync(`node ${path.join(__dirname, 'dev.js')} parse-prd --input=${mediumPRDPath} --tasks=15`, {
|
||||
const mediumResult = execSync(
|
||||
`node ${path.join(__dirname, 'dev.js')} parse-prd --input=${mediumPRDPath} --tasks=15`,
|
||||
{
|
||||
stdio: 'inherit'
|
||||
});
|
||||
}
|
||||
);
|
||||
console.log('Medium PRD test completed successfully');
|
||||
} catch (error) {
|
||||
console.error('Medium PRD test failed:', error.message);
|
||||
@@ -193,9 +199,12 @@ async function runTests() {
|
||||
console.log('Running dev.js with large PRD...');
|
||||
|
||||
try {
|
||||
const largeResult = execSync(`node ${path.join(__dirname, 'dev.js')} parse-prd --input=${largePRDPath} --tasks=25`, {
|
||||
const largeResult = execSync(
|
||||
`node ${path.join(__dirname, 'dev.js')} parse-prd --input=${largePRDPath} --tasks=25`,
|
||||
{
|
||||
stdio: 'inherit'
|
||||
});
|
||||
}
|
||||
);
|
||||
console.log('Large PRD test completed successfully');
|
||||
} catch (error) {
|
||||
console.error('Large PRD test failed:', error.message);
|
||||
@@ -213,7 +222,7 @@ async function runTests() {
|
||||
path.join(__dirname, 'test-large-prd.txt')
|
||||
];
|
||||
|
||||
testFiles.forEach(file => {
|
||||
testFiles.forEach((file) => {
|
||||
if (fs.existsSync(file)) {
|
||||
fs.unlinkSync(file);
|
||||
console.log(`Deleted ${file}`);
|
||||
@@ -225,7 +234,7 @@ async function runTests() {
|
||||
}
|
||||
|
||||
// Run the tests
|
||||
runTests().catch(error => {
|
||||
runTests().catch((error) => {
|
||||
console.error('Error running tests:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
128
tasks/task_039.txt
Normal file
128
tasks/task_039.txt
Normal file
@@ -0,0 +1,128 @@
|
||||
# Task ID: 39
|
||||
# Title: Update Project Licensing to Dual License Structure
|
||||
# Status: done
|
||||
# Dependencies: None
|
||||
# Priority: high
|
||||
# Description: Replace the current MIT license with a dual license structure that protects commercial rights for project owners while allowing non-commercial use under an open source license.
|
||||
# Details:
|
||||
This task requires implementing a comprehensive licensing update across the project:
|
||||
|
||||
1. Remove all instances of the MIT license from the codebase, including any MIT license files, headers in source files, and references in documentation.
|
||||
|
||||
2. Create a dual license structure with:
|
||||
- Business Source License (BSL) 1.1 or similar for commercial use, explicitly stating that commercial rights are exclusively reserved for Ralph & Eyal
|
||||
- Apache 2.0 for non-commercial use, allowing the community to use, modify, and distribute the code for non-commercial purposes
|
||||
|
||||
3. Update the license field in package.json to reflect the dual license structure (e.g., "BSL 1.1 / Apache 2.0")
|
||||
|
||||
4. Add a clear, concise explanation of the licensing terms in the README.md, including:
|
||||
- A summary of what users can and cannot do with the code
|
||||
- Who holds commercial rights
|
||||
- How to obtain commercial use permission if needed
|
||||
- Links to the full license texts
|
||||
|
||||
5. Create a detailed LICENSE.md file that includes:
|
||||
- Full text of both licenses
|
||||
- Clear delineation between commercial and non-commercial use
|
||||
- Specific definitions of what constitutes commercial use
|
||||
- Any additional terms or clarifications specific to this project
|
||||
|
||||
6. Create a CONTRIBUTING.md file that explicitly states:
|
||||
- Contributors must agree that their contributions will be subject to the project's dual licensing
|
||||
- Commercial rights for all contributions are assigned to Ralph & Eyal
|
||||
- Guidelines for acceptable contributions
|
||||
|
||||
7. Ensure all source code files include appropriate license headers that reference the dual license structure.
|
||||
|
||||
# Test Strategy:
|
||||
To verify correct implementation, perform the following checks:
|
||||
|
||||
1. File verification:
|
||||
- Confirm the MIT license file has been removed
|
||||
- Verify LICENSE.md exists and contains both BSL and Apache 2.0 license texts
|
||||
- Confirm README.md includes the license section with clear explanation
|
||||
- Verify CONTRIBUTING.md exists with proper contributor guidelines
|
||||
- Check package.json for updated license field
|
||||
|
||||
2. Content verification:
|
||||
- Review LICENSE.md to ensure it properly describes the dual license structure with clear terms
|
||||
- Verify README.md license section is concise yet complete
|
||||
- Check that commercial rights are explicitly reserved for Ralph & Eyal in all relevant documents
|
||||
- Ensure CONTRIBUTING.md clearly explains the licensing implications for contributors
|
||||
|
||||
3. Legal review:
|
||||
- Have a team member not involved in the implementation review all license documents
|
||||
- Verify that the chosen BSL terms properly protect commercial interests
|
||||
- Confirm the Apache 2.0 implementation is correct and compatible with the BSL portions
|
||||
|
||||
4. Source code check:
|
||||
- Sample at least 10 source files to ensure they have updated license headers
|
||||
- Verify no MIT license references remain in any source files
|
||||
|
||||
5. Documentation check:
|
||||
- Ensure any documentation that mentioned licensing has been updated to reflect the new structure
|
||||
|
||||
# Subtasks:
|
||||
## 1. Remove MIT License and Create Dual License Files [done]
|
||||
### Dependencies: None
|
||||
### Description: Remove all MIT license references from the codebase and create the new license files for the dual license structure.
|
||||
### Details:
|
||||
Implementation steps:
|
||||
1. Scan the entire codebase to identify all instances of MIT license references (license files, headers in source files, documentation mentions).
|
||||
2. Remove the MIT license file and all direct references to it.
|
||||
3. Create a LICENSE.md file containing:
|
||||
- Full text of Business Source License (BSL) 1.1 with explicit commercial rights reservation for Ralph & Eyal
|
||||
- Full text of Apache 2.0 license for non-commercial use
|
||||
- Clear definitions of what constitutes commercial vs. non-commercial use
|
||||
- Specific terms for obtaining commercial use permission
|
||||
4. Create a CONTRIBUTING.md file that explicitly states the contribution terms:
|
||||
- Contributors must agree to the dual licensing structure
|
||||
- Commercial rights for all contributions are assigned to Ralph & Eyal
|
||||
- Guidelines for acceptable contributions
|
||||
|
||||
Testing approach:
|
||||
- Verify all MIT license references have been removed using a grep or similar search tool
|
||||
- Have legal review of the LICENSE.md and CONTRIBUTING.md files to ensure they properly protect commercial rights
|
||||
- Validate that the license files are properly formatted and readable
|
||||
|
||||
## 2. Update Source Code License Headers and Package Metadata [done]
|
||||
### Dependencies: 39.1
|
||||
### Description: Add appropriate dual license headers to all source code files and update package metadata to reflect the new licensing structure.
|
||||
### Details:
|
||||
Implementation steps:
|
||||
1. Create a template for the new license header that references the dual license structure (BSL 1.1 / Apache 2.0).
|
||||
2. Systematically update all source code files to include the new license header, replacing any existing MIT headers.
|
||||
3. Update the license field in package.json to "BSL 1.1 / Apache 2.0".
|
||||
4. Update any other metadata files (composer.json, setup.py, etc.) that contain license information.
|
||||
5. Verify that any build scripts or tools that reference licensing information are updated.
|
||||
|
||||
Testing approach:
|
||||
- Write a script to verify that all source files contain the new license header
|
||||
- Validate package.json and other metadata files have the correct license field
|
||||
- Ensure any build processes that depend on license information still function correctly
|
||||
- Run a sample build to confirm license information is properly included in any generated artifacts
|
||||
|
||||
## 3. Update Documentation and Create License Explanation [done]
|
||||
### Dependencies: 39.1, 39.2
|
||||
### Description: Update project documentation to clearly explain the dual license structure and create comprehensive licensing guidance.
|
||||
### Details:
|
||||
Implementation steps:
|
||||
1. Update the README.md with a clear, concise explanation of the licensing terms:
|
||||
- Summary of what users can and cannot do with the code
|
||||
- Who holds commercial rights (Ralph & Eyal)
|
||||
- How to obtain commercial use permission
|
||||
- Links to the full license texts
|
||||
2. Create a dedicated LICENSING.md or similar document with detailed explanations of:
|
||||
- The rationale behind the dual licensing approach
|
||||
- Detailed examples of what constitutes commercial vs. non-commercial use
|
||||
- FAQs addressing common licensing questions
|
||||
3. Update any other documentation references to licensing throughout the project.
|
||||
4. Create visual aids (if appropriate) to help users understand the licensing structure.
|
||||
5. Ensure all documentation links to licensing information are updated.
|
||||
|
||||
Testing approach:
|
||||
- Have non-technical stakeholders review the documentation for clarity and understanding
|
||||
- Verify all links to license files work correctly
|
||||
- Ensure the explanation is comprehensive but concise enough for users to understand quickly
|
||||
- Check that the documentation correctly addresses the most common use cases and questions
|
||||
|
||||
102
tasks/task_040.txt
Normal file
102
tasks/task_040.txt
Normal file
@@ -0,0 +1,102 @@
|
||||
# Task ID: 40
|
||||
# Title: Implement Project Funding Documentation and Support Infrastructure
|
||||
# Status: in-progress
|
||||
# Dependencies: None
|
||||
# Priority: medium
|
||||
# Description: Create FUNDING.yml for GitHub Sponsors integration that outlines all financial support options for the Task Master project.
|
||||
# Details:
|
||||
This task involves creating a FUNDING.yml file to enable and manage funding options for the Task Master project:
|
||||
|
||||
**FUNDING.yml file**:
|
||||
- Create a .github/FUNDING.yml file following GitHub's specifications
|
||||
- Include configuration for multiple funding platforms:
|
||||
- GitHub Sponsors (primary if available)
|
||||
- Open Collective
|
||||
- Patreon
|
||||
- Ko-fi
|
||||
- Liberapay
|
||||
- Custom funding URLs (project website donation page)
|
||||
- Research and reference successful implementation patterns from Vue.js, React, and TypeScript projects
|
||||
- Ensure the FUNDING.yml contains sufficient information to guide users on how to support the project
|
||||
- Include comments within the YAML file to provide context for each funding option
|
||||
|
||||
The implementation should maintain consistent branding and messaging with the rest of the Task Master project. Research at least 5 successful open source projects to identify best practices in funding configuration.
|
||||
|
||||
# Test Strategy:
|
||||
Testing should verify the technical implementation of the FUNDING.yml file:
|
||||
|
||||
1. **FUNDING.yml validation**:
|
||||
- Verify the file is correctly placed in the .github directory
|
||||
- Validate YAML syntax using a linter
|
||||
- Test that GitHub correctly displays funding options on the repository page
|
||||
- Verify all links to external funding platforms are functional
|
||||
|
||||
2. **User experience testing**:
|
||||
- Test the complete funding workflow from a potential supporter's perspective
|
||||
- Verify the process is intuitive and barriers to contribution are minimized
|
||||
- Check that the Sponsor button appears correctly on GitHub
|
||||
- Ensure all funding platform links resolve to the correct destinations
|
||||
- Gather feedback from 2-3 potential users on clarity and ease of use
|
||||
|
||||
# Subtasks:
|
||||
## 1. Research and Create FUNDING.yml File [done]
|
||||
### Dependencies: None
|
||||
### Description: Research successful funding configurations and create the .github/FUNDING.yml file for GitHub Sponsors integration and other funding platforms.
|
||||
### Details:
|
||||
Implementation steps:
|
||||
1. Create the .github directory at the project root if it doesn't exist
|
||||
2. Research funding configurations from 5 successful open source projects (Vue.js, React, TypeScript, etc.)
|
||||
3. Document the patterns and approaches used in these projects
|
||||
4. Create the FUNDING.yml file with the following platforms:
|
||||
- GitHub Sponsors (primary)
|
||||
- Open Collective
|
||||
- Patreon
|
||||
- Ko-fi
|
||||
- Liberapay
|
||||
- Custom donation URL for the project website
|
||||
5. Validate the YAML syntax using a linter
|
||||
6. Test the file by pushing to a test branch and verifying the Sponsor button appears correctly on GitHub
|
||||
|
||||
Testing approach:
|
||||
- Validate YAML syntax using yamllint or similar tool
|
||||
- Test on GitHub by checking if the Sponsor button appears in the repository
|
||||
- Verify each funding link resolves to the correct destination
|
||||
|
||||
## 4. Add Documentation Comments to FUNDING.yml [pending]
|
||||
### Dependencies: 40.1
|
||||
### Description: Add comprehensive comments within the FUNDING.yml file to provide context and guidance for each funding option.
|
||||
### Details:
|
||||
Implementation steps:
|
||||
1. Add a header comment explaining the purpose of the file
|
||||
2. For each funding platform entry, add comments that explain:
|
||||
- What the platform is
|
||||
- How funds are processed on this platform
|
||||
- Any specific benefits of using this platform
|
||||
- Brief instructions for potential sponsors
|
||||
3. Include a comment about how sponsors will be acknowledged
|
||||
4. Add information about fund allocation (maintenance, new features, infrastructure)
|
||||
5. Ensure comments follow YAML comment syntax and don't break the file structure
|
||||
|
||||
Testing approach:
|
||||
- Validate that the YAML file still passes linting with comments added
|
||||
- Verify the file still functions correctly on GitHub
|
||||
- Have at least one team member review the comments for clarity and completeness
|
||||
|
||||
## 5. Integrate Funding Information in Project README [pending]
|
||||
### Dependencies: 40.1, 40.4
|
||||
### Description: Add a section to the project README that highlights the funding options and directs users to the Sponsor button.
|
||||
### Details:
|
||||
Implementation steps:
|
||||
1. Create a 'Support the Project' or 'Sponsorship' section in the README.md
|
||||
2. Explain briefly why financial support matters for the project
|
||||
3. Direct users to the GitHub Sponsor button
|
||||
4. Mention the alternative funding platforms available
|
||||
5. Include a brief note on how funds will be used
|
||||
6. Add any relevant funding badges (e.g., Open Collective, GitHub Sponsors)
|
||||
|
||||
Testing approach:
|
||||
- Review the README section for clarity and conciseness
|
||||
- Verify all links work correctly
|
||||
- Ensure the section is appropriately visible but doesn't overshadow project information
|
||||
- Check that badges render correctly
|
||||
|
||||
89
tasks/task_041.txt
Normal file
89
tasks/task_041.txt
Normal file
@@ -0,0 +1,89 @@
|
||||
# Task ID: 41
|
||||
# Title: Implement GitHub Actions CI Workflow for Task Master
|
||||
# Status: pending
|
||||
# Dependencies: None
|
||||
# Priority: high
|
||||
# Description: Create a streamlined CI workflow file (ci.yml) that efficiently tests the Task Master codebase using GitHub Actions.
|
||||
# Details:
|
||||
Create a GitHub Actions workflow file at `.github/workflows/ci.yml` with the following specifications:
|
||||
|
||||
1. Configure the workflow to trigger on:
|
||||
- Push events to any branch
|
||||
- Pull request events targeting any branch
|
||||
|
||||
2. Core workflow configuration:
|
||||
- Use Ubuntu latest as the primary testing environment
|
||||
- Use Node.js 20.x (LTS) for consistency with the project
|
||||
- Focus on single environment for speed and simplicity
|
||||
|
||||
3. Configure workflow steps to:
|
||||
- Checkout the repository using actions/checkout@v4
|
||||
- Set up Node.js using actions/setup-node@v4 with npm caching
|
||||
- Install dependencies with 'npm ci'
|
||||
- Run tests with 'npm run test:coverage'
|
||||
|
||||
4. Implement efficient caching:
|
||||
- Cache node_modules using actions/cache@v4
|
||||
- Use package-lock.json hash for cache key
|
||||
- Implement proper cache restoration keys
|
||||
|
||||
5. Ensure proper timeouts:
|
||||
- 2 minutes for dependency installation
|
||||
- Appropriate timeout for test execution
|
||||
|
||||
6. Artifact handling:
|
||||
- Upload test results and coverage reports
|
||||
- Use consistent naming for artifacts
|
||||
- Retain artifacts for 30 days
|
||||
|
||||
# Test Strategy:
|
||||
To verify correct implementation of the GitHub Actions CI workflow:
|
||||
|
||||
1. Manual verification:
|
||||
- Check that the file is correctly placed at `.github/workflows/ci.yml`
|
||||
- Verify the YAML syntax is valid
|
||||
- Confirm all required configurations are present
|
||||
|
||||
2. Functional testing:
|
||||
- Push a commit to verify the workflow triggers
|
||||
- Create a PR to verify the workflow runs on pull requests
|
||||
- Verify test coverage reports are generated and uploaded
|
||||
- Confirm caching is working effectively
|
||||
|
||||
3. Performance testing:
|
||||
- Verify cache hits reduce installation time
|
||||
- Confirm workflow completes within expected timeframe
|
||||
- Check artifact upload and download speeds
|
||||
|
||||
# Subtasks:
|
||||
## 1. Create Basic GitHub Actions Workflow [pending]
|
||||
### Dependencies: None
|
||||
### Description: Set up the foundational GitHub Actions workflow file with proper triggers and Node.js setup
|
||||
### Details:
|
||||
1. Create `.github/workflows/ci.yml`
|
||||
2. Configure workflow name and triggers
|
||||
3. Set up Ubuntu runner and Node.js 20.x
|
||||
4. Implement checkout and Node.js setup actions
|
||||
5. Configure npm caching
|
||||
6. Test basic workflow functionality
|
||||
|
||||
## 2. Implement Test and Coverage Steps [pending]
|
||||
### Dependencies: 41.1
|
||||
### Description: Add test execution and coverage reporting to the workflow
|
||||
### Details:
|
||||
1. Add dependency installation with proper timeout
|
||||
2. Configure test execution with coverage
|
||||
3. Set up test results and coverage artifacts
|
||||
4. Verify artifact upload functionality
|
||||
5. Test the complete workflow
|
||||
|
||||
## 3. Optimize Workflow Performance [pending]
|
||||
### Dependencies: 41.1, 41.2
|
||||
### Description: Implement caching and performance optimizations
|
||||
### Details:
|
||||
1. Set up node_modules caching
|
||||
2. Configure cache key strategy
|
||||
3. Implement proper timeout values
|
||||
4. Test caching effectiveness
|
||||
5. Document performance improvements
|
||||
|
||||
132
tasks/tasks.json
132
tasks/tasks.json
@@ -2164,6 +2164,138 @@
|
||||
"priority": "high",
|
||||
"details": "Implement a version check mechanism that runs automatically with every command execution:\n\n1. Create a new module (e.g., `versionChecker.js`) that will:\n - Fetch the latest version from npm registry using the npm registry API (https://registry.npmjs.org/task-master-ai/latest)\n - Compare it with the current installed version (from package.json)\n - Store the last check timestamp to avoid excessive API calls (check once per day)\n - Cache the result to minimize network requests\n\n2. The notification should:\n - Use colored text (e.g., yellow background with black text) to be noticeable\n - Include the current version and latest version\n - Show the exact upgrade command: 'npm i task-master-ai@latest'\n - Be displayed at the beginning or end of command output, not interrupting the main content\n - Include a small separator line to distinguish it from command output\n\n3. Implementation considerations:\n - Handle network failures gracefully (don't block command execution if version check fails)\n - Add a configuration option to disable update checks if needed\n - Ensure the check is lightweight and doesn't significantly impact command performance\n - Consider using a package like 'semver' for proper version comparison\n - Implement a cooldown period (e.g., only check once per day) to avoid excessive API calls\n\n4. The version check should be integrated into the main command execution flow so it runs for all commands automatically.",
|
||||
"testStrategy": "1. Manual testing:\n - Install an older version of the package\n - Run various commands and verify the update notification appears\n - Update to the latest version and confirm the notification no longer appears\n - Test with network disconnected to ensure graceful handling of failures\n\n2. Unit tests:\n - Mock the npm registry response to test different scenarios:\n - When a newer version exists\n - When using the latest version\n - When the registry is unavailable\n - Test the version comparison logic with various version strings\n - Test the cooldown/caching mechanism works correctly\n\n3. Integration tests:\n - Create a test that runs a command and verifies the notification appears in the expected format\n - Test that the notification appears for all commands\n - Verify the notification doesn't interfere with normal command output\n\n4. Edge cases to test:\n - Pre-release versions (alpha/beta)\n - Very old versions\n - When package.json is missing or malformed\n - When npm registry returns unexpected data"
|
||||
},
|
||||
{
|
||||
"id": 39,
|
||||
"title": "Update Project Licensing to Dual License Structure",
|
||||
"description": "Replace the current MIT license with a dual license structure that protects commercial rights for project owners while allowing non-commercial use under an open source license.",
|
||||
"status": "done",
|
||||
"dependencies": [],
|
||||
"priority": "high",
|
||||
"details": "This task requires implementing a comprehensive licensing update across the project:\n\n1. Remove all instances of the MIT license from the codebase, including any MIT license files, headers in source files, and references in documentation.\n\n2. Create a dual license structure with:\n - Business Source License (BSL) 1.1 or similar for commercial use, explicitly stating that commercial rights are exclusively reserved for Ralph & Eyal\n - Apache 2.0 for non-commercial use, allowing the community to use, modify, and distribute the code for non-commercial purposes\n\n3. Update the license field in package.json to reflect the dual license structure (e.g., \"BSL 1.1 / Apache 2.0\")\n\n4. Add a clear, concise explanation of the licensing terms in the README.md, including:\n - A summary of what users can and cannot do with the code\n - Who holds commercial rights\n - How to obtain commercial use permission if needed\n - Links to the full license texts\n\n5. Create a detailed LICENSE.md file that includes:\n - Full text of both licenses\n - Clear delineation between commercial and non-commercial use\n - Specific definitions of what constitutes commercial use\n - Any additional terms or clarifications specific to this project\n\n6. Create a CONTRIBUTING.md file that explicitly states:\n - Contributors must agree that their contributions will be subject to the project's dual licensing\n - Commercial rights for all contributions are assigned to Ralph & Eyal\n - Guidelines for acceptable contributions\n\n7. Ensure all source code files include appropriate license headers that reference the dual license structure.",
|
||||
"testStrategy": "To verify correct implementation, perform the following checks:\n\n1. File verification:\n - Confirm the MIT license file has been removed\n - Verify LICENSE.md exists and contains both BSL and Apache 2.0 license texts\n - Confirm README.md includes the license section with clear explanation\n - Verify CONTRIBUTING.md exists with proper contributor guidelines\n - Check package.json for updated license field\n\n2. Content verification:\n - Review LICENSE.md to ensure it properly describes the dual license structure with clear terms\n - Verify README.md license section is concise yet complete\n - Check that commercial rights are explicitly reserved for Ralph & Eyal in all relevant documents\n - Ensure CONTRIBUTING.md clearly explains the licensing implications for contributors\n\n3. Legal review:\n - Have a team member not involved in the implementation review all license documents\n - Verify that the chosen BSL terms properly protect commercial interests\n - Confirm the Apache 2.0 implementation is correct and compatible with the BSL portions\n\n4. Source code check:\n - Sample at least 10 source files to ensure they have updated license headers\n - Verify no MIT license references remain in any source files\n\n5. Documentation check:\n - Ensure any documentation that mentioned licensing has been updated to reflect the new structure",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Remove MIT License and Create Dual License Files",
|
||||
"description": "Remove all MIT license references from the codebase and create the new license files for the dual license structure.",
|
||||
"dependencies": [],
|
||||
"details": "Implementation steps:\n1. Scan the entire codebase to identify all instances of MIT license references (license files, headers in source files, documentation mentions).\n2. Remove the MIT license file and all direct references to it.\n3. Create a LICENSE.md file containing:\n - Full text of Business Source License (BSL) 1.1 with explicit commercial rights reservation for Ralph & Eyal\n - Full text of Apache 2.0 license for non-commercial use\n - Clear definitions of what constitutes commercial vs. non-commercial use\n - Specific terms for obtaining commercial use permission\n4. Create a CONTRIBUTING.md file that explicitly states the contribution terms:\n - Contributors must agree to the dual licensing structure\n - Commercial rights for all contributions are assigned to Ralph & Eyal\n - Guidelines for acceptable contributions\n\nTesting approach:\n- Verify all MIT license references have been removed using a grep or similar search tool\n- Have legal review of the LICENSE.md and CONTRIBUTING.md files to ensure they properly protect commercial rights\n- Validate that the license files are properly formatted and readable",
|
||||
"status": "done",
|
||||
"parentTaskId": 39
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Update Source Code License Headers and Package Metadata",
|
||||
"description": "Add appropriate dual license headers to all source code files and update package metadata to reflect the new licensing structure.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Implementation steps:\n1. Create a template for the new license header that references the dual license structure (BSL 1.1 / Apache 2.0).\n2. Systematically update all source code files to include the new license header, replacing any existing MIT headers.\n3. Update the license field in package.json to \"BSL 1.1 / Apache 2.0\".\n4. Update any other metadata files (composer.json, setup.py, etc.) that contain license information.\n5. Verify that any build scripts or tools that reference licensing information are updated.\n\nTesting approach:\n- Write a script to verify that all source files contain the new license header\n- Validate package.json and other metadata files have the correct license field\n- Ensure any build processes that depend on license information still function correctly\n- Run a sample build to confirm license information is properly included in any generated artifacts",
|
||||
"status": "done",
|
||||
"parentTaskId": 39
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Update Documentation and Create License Explanation",
|
||||
"description": "Update project documentation to clearly explain the dual license structure and create comprehensive licensing guidance.",
|
||||
"dependencies": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"details": "Implementation steps:\n1. Update the README.md with a clear, concise explanation of the licensing terms:\n - Summary of what users can and cannot do with the code\n - Who holds commercial rights (Ralph & Eyal)\n - How to obtain commercial use permission\n - Links to the full license texts\n2. Create a dedicated LICENSING.md or similar document with detailed explanations of:\n - The rationale behind the dual licensing approach\n - Detailed examples of what constitutes commercial vs. non-commercial use\n - FAQs addressing common licensing questions\n3. Update any other documentation references to licensing throughout the project.\n4. Create visual aids (if appropriate) to help users understand the licensing structure.\n5. Ensure all documentation links to licensing information are updated.\n\nTesting approach:\n- Have non-technical stakeholders review the documentation for clarity and understanding\n- Verify all links to license files work correctly\n- Ensure the explanation is comprehensive but concise enough for users to understand quickly\n- Check that the documentation correctly addresses the most common use cases and questions",
|
||||
"status": "done",
|
||||
"parentTaskId": 39
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 40,
|
||||
"title": "Implement Project Funding Documentation and Support Infrastructure",
|
||||
"description": "Create FUNDING.yml for GitHub Sponsors integration that outlines all financial support options for the Task Master project.",
|
||||
"status": "in-progress",
|
||||
"dependencies": [],
|
||||
"priority": "medium",
|
||||
"details": "This task involves creating a FUNDING.yml file to enable and manage funding options for the Task Master project:\n\n**FUNDING.yml file**:\n - Create a .github/FUNDING.yml file following GitHub's specifications\n - Include configuration for multiple funding platforms:\n - GitHub Sponsors (primary if available)\n - Open Collective\n - Patreon\n - Ko-fi\n - Liberapay\n - Custom funding URLs (project website donation page)\n - Research and reference successful implementation patterns from Vue.js, React, and TypeScript projects\n - Ensure the FUNDING.yml contains sufficient information to guide users on how to support the project\n - Include comments within the YAML file to provide context for each funding option\n\nThe implementation should maintain consistent branding and messaging with the rest of the Task Master project. Research at least 5 successful open source projects to identify best practices in funding configuration.",
|
||||
"testStrategy": "Testing should verify the technical implementation of the FUNDING.yml file:\n\n1. **FUNDING.yml validation**:\n - Verify the file is correctly placed in the .github directory\n - Validate YAML syntax using a linter\n - Test that GitHub correctly displays funding options on the repository page\n - Verify all links to external funding platforms are functional\n\n2. **User experience testing**:\n - Test the complete funding workflow from a potential supporter's perspective\n - Verify the process is intuitive and barriers to contribution are minimized\n - Check that the Sponsor button appears correctly on GitHub\n - Ensure all funding platform links resolve to the correct destinations\n - Gather feedback from 2-3 potential users on clarity and ease of use",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Research and Create FUNDING.yml File",
|
||||
"description": "Research successful funding configurations and create the .github/FUNDING.yml file for GitHub Sponsors integration and other funding platforms.",
|
||||
"dependencies": [],
|
||||
"details": "Implementation steps:\n1. Create the .github directory at the project root if it doesn't exist\n2. Research funding configurations from 5 successful open source projects (Vue.js, React, TypeScript, etc.)\n3. Document the patterns and approaches used in these projects\n4. Create the FUNDING.yml file with the following platforms:\n - GitHub Sponsors (primary)\n - Open Collective\n - Patreon\n - Ko-fi\n - Liberapay\n - Custom donation URL for the project website\n5. Validate the YAML syntax using a linter\n6. Test the file by pushing to a test branch and verifying the Sponsor button appears correctly on GitHub\n\nTesting approach:\n- Validate YAML syntax using yamllint or similar tool\n- Test on GitHub by checking if the Sponsor button appears in the repository\n- Verify each funding link resolves to the correct destination",
|
||||
"status": "done",
|
||||
"parentTaskId": 40
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Add Documentation Comments to FUNDING.yml",
|
||||
"description": "Add comprehensive comments within the FUNDING.yml file to provide context and guidance for each funding option.",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "Implementation steps:\n1. Add a header comment explaining the purpose of the file\n2. For each funding platform entry, add comments that explain:\n - What the platform is\n - How funds are processed on this platform\n - Any specific benefits of using this platform\n - Brief instructions for potential sponsors\n3. Include a comment about how sponsors will be acknowledged\n4. Add information about fund allocation (maintenance, new features, infrastructure)\n5. Ensure comments follow YAML comment syntax and don't break the file structure\n\nTesting approach:\n- Validate that the YAML file still passes linting with comments added\n- Verify the file still functions correctly on GitHub\n- Have at least one team member review the comments for clarity and completeness",
|
||||
"status": "pending",
|
||||
"parentTaskId": 40
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Integrate Funding Information in Project README",
|
||||
"description": "Add a section to the project README that highlights the funding options and directs users to the Sponsor button.",
|
||||
"dependencies": [
|
||||
1,
|
||||
4
|
||||
],
|
||||
"details": "Implementation steps:\n1. Create a 'Support the Project' or 'Sponsorship' section in the README.md\n2. Explain briefly why financial support matters for the project\n3. Direct users to the GitHub Sponsor button\n4. Mention the alternative funding platforms available\n5. Include a brief note on how funds will be used\n6. Add any relevant funding badges (e.g., Open Collective, GitHub Sponsors)\n\nTesting approach:\n- Review the README section for clarity and conciseness\n- Verify all links work correctly\n- Ensure the section is appropriately visible but doesn't overshadow project information\n- Check that badges render correctly",
|
||||
"status": "pending",
|
||||
"parentTaskId": 40
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 41,
|
||||
"title": "Implement GitHub Actions CI Workflow for Cross-Platform Testing",
|
||||
"description": "Create a CI workflow file (ci.yml) that tests the codebase across multiple Node.js versions and operating systems using GitHub Actions.",
|
||||
"status": "pending",
|
||||
"dependencies": [],
|
||||
"priority": "high",
|
||||
"details": "Create a GitHub Actions workflow file at `.github/workflows/ci.yml` with the following specifications:\n\n1. Configure the workflow to trigger on:\n - Push events to any branch\n - Pull request events targeting any branch\n\n2. Implement a matrix strategy that tests across:\n - Node.js versions: 18.x, 20.x, and 22.x\n - Operating systems: Ubuntu-latest and Windows-latest\n\n3. Include proper Git configuration steps:\n - Set Git user name to 'GitHub Actions'\n - Set Git email to 'github-actions@github.com'\n\n4. Configure workflow steps to:\n - Checkout the repository using actions/checkout@v3\n - Set up Node.js using actions/setup-node@v3 with the matrix version\n - Use npm for package management (not pnpm)\n - Install dependencies with 'npm ci'\n - Run linting with 'npm run lint' (if available)\n - Run tests with 'npm test'\n - Run build process with 'npm run build'\n\n5. Implement concurrency controls to:\n - Cancel in-progress workflows when new commits are pushed to the same PR\n - Use a concurrency group based on the GitHub ref and workflow name\n\n6. Add proper caching for npm dependencies to speed up workflow runs\n\n7. Ensure the workflow includes appropriate timeouts to prevent hung jobs",
|
||||
"testStrategy": "To verify correct implementation of the GitHub Actions CI workflow:\n\n1. Manual verification:\n - Check that the file is correctly placed at `.github/workflows/ci.yml`\n - Verify the YAML syntax is valid using a YAML linter\n - Confirm all required configurations (triggers, matrix, steps) are present\n\n2. Functional testing:\n - Push a commit to a feature branch to confirm the workflow triggers\n - Create a PR to verify the workflow runs on pull requests\n - Verify the workflow successfully runs on both Ubuntu and Windows\n - Confirm tests run against all three Node.js versions (18, 20, 22)\n - Test concurrency by pushing multiple commits to the same PR rapidly\n\n3. Edge case testing:\n - Introduce a failing test and verify the workflow reports failure\n - Test with a large dependency tree to verify caching works correctly\n - Verify the workflow handles non-ASCII characters in file paths correctly (particularly on Windows)\n\n4. Check workflow logs to ensure:\n - Git configuration is applied correctly\n - Dependencies are installed with npm (not pnpm)\n - All matrix combinations run independently\n - Concurrency controls cancel redundant workflow runs",
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Create Basic GitHub Actions Workflow Structure",
|
||||
"description": "Set up the foundational GitHub Actions workflow file with triggers, checkout, and Node.js setup using matrix strategy",
|
||||
"dependencies": [],
|
||||
"details": "1. Create `.github/workflows/` directory if it doesn't exist\n2. Create a new file `ci.yml` inside this directory\n3. Define the workflow name at the top of the file\n4. Configure triggers for push events to any branch and pull request events targeting any branch\n5. Set up the matrix strategy for Node.js versions (18.x, 20.x, 22.x) and operating systems (Ubuntu-latest, Windows-latest)\n6. Configure the job to checkout the repository using actions/checkout@v3\n7. Set up Node.js using actions/setup-node@v3 with the matrix version\n8. Add proper caching for npm dependencies\n9. Test the workflow by pushing the file to a test branch and verifying it triggers correctly\n10. Verify that the matrix builds are running on all specified Node versions and operating systems",
|
||||
"status": "pending",
|
||||
"parentTaskId": 41
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Implement Build and Test Steps with Git Configuration",
|
||||
"description": "Add the core build and test steps to the workflow, including Git configuration, dependency installation, and execution of lint, test, and build commands",
|
||||
"dependencies": [
|
||||
1
|
||||
],
|
||||
"details": "1. Add Git configuration steps to set user name to 'GitHub Actions' and email to 'github-actions@github.com'\n2. Add step to install dependencies with 'npm ci'\n3. Add conditional step to run linting with 'npm run lint' if available\n4. Add step to run tests with 'npm test'\n5. Add step to run build process with 'npm run build'\n6. Ensure each step has appropriate names for clear visibility in GitHub Actions UI\n7. Add appropriate error handling and continue-on-error settings where needed\n8. Test the workflow by pushing a change and verifying all build steps execute correctly\n9. Verify that the workflow correctly runs on both Ubuntu and Windows environments\n10. Ensure that all commands use the correct syntax for cross-platform compatibility",
|
||||
"status": "pending",
|
||||
"parentTaskId": 41
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Add Workflow Optimization Features",
|
||||
"description": "Implement concurrency controls, timeouts, and other optimization features to improve workflow efficiency and reliability",
|
||||
"dependencies": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"details": "1. Implement concurrency controls to cancel in-progress workflows when new commits are pushed to the same PR\n2. Define a concurrency group based on the GitHub ref and workflow name\n3. Add appropriate timeouts to prevent hung jobs (typically 30-60 minutes depending on project complexity)\n4. Add status badges to the README.md file to show build status\n5. Optimize the workflow by adding appropriate 'if' conditions to skip unnecessary steps\n6. Add job summary outputs to provide clear information about the build results\n7. Test the concurrency feature by pushing multiple commits in quick succession to a PR\n8. Verify that old workflow runs are canceled when new commits are pushed\n9. Test timeout functionality by temporarily adding a long-running step\n10. Document the CI workflow in project documentation, explaining what it does and how to troubleshoot common issues",
|
||||
"status": "pending",
|
||||
"parentTaskId": 41
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
import { checkForUpdate, displayUpgradeNotification, compareVersions } from './scripts/modules/commands.js';
|
||||
import {
|
||||
checkForUpdate,
|
||||
displayUpgradeNotification,
|
||||
compareVersions
|
||||
} from './scripts/modules/commands.js';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
@@ -20,7 +24,8 @@ async function testCheckForUpdate(simulatedLatestVersion) {
|
||||
console.log(`Using simulated latest version: ${simulatedLatestVersion}`);
|
||||
|
||||
// Compare versions
|
||||
const needsUpdate = compareVersions(currentVersion, simulatedLatestVersion) < 0;
|
||||
const needsUpdate =
|
||||
compareVersions(currentVersion, simulatedLatestVersion) < 0;
|
||||
|
||||
return {
|
||||
currentVersion,
|
||||
@@ -34,7 +39,9 @@ async function runTest() {
|
||||
console.log('=== Testing version check scenarios ===\n');
|
||||
|
||||
// Scenario 1: Update available
|
||||
console.log('\n--- Scenario 1: Update available (Current: 0.9.30, Latest: 1.0.0) ---');
|
||||
console.log(
|
||||
'\n--- Scenario 1: Update available (Current: 0.9.30, Latest: 1.0.0) ---'
|
||||
);
|
||||
const updateInfo1 = await testCheckForUpdate('1.0.0');
|
||||
console.log('Update check results:');
|
||||
console.log(`- Current version: ${updateInfo1.currentVersion}`);
|
||||
@@ -43,11 +50,16 @@ async function runTest() {
|
||||
|
||||
if (updateInfo1.needsUpdate) {
|
||||
console.log('\nDisplaying upgrade notification:');
|
||||
displayUpgradeNotification(updateInfo1.currentVersion, updateInfo1.latestVersion);
|
||||
displayUpgradeNotification(
|
||||
updateInfo1.currentVersion,
|
||||
updateInfo1.latestVersion
|
||||
);
|
||||
}
|
||||
|
||||
// Scenario 2: No update needed (versions equal)
|
||||
console.log('\n--- Scenario 2: No update needed (Current: 0.9.30, Latest: 0.9.30) ---');
|
||||
console.log(
|
||||
'\n--- Scenario 2: No update needed (Current: 0.9.30, Latest: 0.9.30) ---'
|
||||
);
|
||||
const updateInfo2 = await testCheckForUpdate('0.9.30');
|
||||
console.log('Update check results:');
|
||||
console.log(`- Current version: ${updateInfo2.currentVersion}`);
|
||||
@@ -55,7 +67,9 @@ async function runTest() {
|
||||
console.log(`- Update needed: ${updateInfo2.needsUpdate}`);
|
||||
|
||||
// Scenario 3: Development version (current newer than latest)
|
||||
console.log('\n--- Scenario 3: Development version (Current: 0.9.30, Latest: 0.9.0) ---');
|
||||
console.log(
|
||||
'\n--- Scenario 3: Development version (Current: 0.9.30, Latest: 0.9.0) ---'
|
||||
);
|
||||
const updateInfo3 = await testCheckForUpdate('0.9.0');
|
||||
console.log('Update check results:');
|
||||
console.log(`- Current version: ${updateInfo3.currentVersion}`);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { displayUpgradeNotification, compareVersions } from './scripts/modules/commands.js';
|
||||
import {
|
||||
displayUpgradeNotification,
|
||||
compareVersions
|
||||
} from './scripts/modules/commands.js';
|
||||
|
||||
// Simulate different version scenarios
|
||||
console.log('=== Simulating version check ===\n');
|
||||
@@ -8,15 +11,25 @@ console.log('Scenario 1: Current version older than latest');
|
||||
displayUpgradeNotification('0.9.30', '1.0.0');
|
||||
|
||||
// 2. Current version same as latest (no update needed)
|
||||
console.log('\nScenario 2: Current version same as latest (this would not normally show a notice)');
|
||||
console.log(
|
||||
'\nScenario 2: Current version same as latest (this would not normally show a notice)'
|
||||
);
|
||||
console.log('Current: 1.0.0, Latest: 1.0.0');
|
||||
console.log('compareVersions result:', compareVersions('1.0.0', '1.0.0'));
|
||||
console.log('Update needed:', compareVersions('1.0.0', '1.0.0') < 0 ? 'Yes' : 'No');
|
||||
console.log(
|
||||
'Update needed:',
|
||||
compareVersions('1.0.0', '1.0.0') < 0 ? 'Yes' : 'No'
|
||||
);
|
||||
|
||||
// 3. Current version newer than latest (e.g., development version, would not show notice)
|
||||
console.log('\nScenario 3: Current version newer than latest (this would not normally show a notice)');
|
||||
console.log(
|
||||
'\nScenario 3: Current version newer than latest (this would not normally show a notice)'
|
||||
);
|
||||
console.log('Current: 1.1.0, Latest: 1.0.0');
|
||||
console.log('compareVersions result:', compareVersions('1.1.0', '1.0.0'));
|
||||
console.log('Update needed:', compareVersions('1.1.0', '1.0.0') < 0 ? 'Yes' : 'No');
|
||||
console.log(
|
||||
'Update needed:',
|
||||
compareVersions('1.1.0', '1.0.0') < 0 ? 'Yes' : 'No'
|
||||
);
|
||||
|
||||
console.log('\n=== Test complete ===');
|
||||
50
tests/fixtures/sample-claude-response.js
vendored
50
tests/fixtures/sample-claude-response.js
vendored
@@ -6,39 +6,47 @@ export const sampleClaudeResponse = {
|
||||
tasks: [
|
||||
{
|
||||
id: 1,
|
||||
title: "Setup Task Data Structure",
|
||||
description: "Implement the core task data structure and file operations",
|
||||
status: "pending",
|
||||
title: 'Setup Task Data Structure',
|
||||
description: 'Implement the core task data structure and file operations',
|
||||
status: 'pending',
|
||||
dependencies: [],
|
||||
priority: "high",
|
||||
details: "Create the tasks.json file structure with support for task properties including ID, title, description, status, dependencies, priority, details, and test strategy. Implement file system operations for reading and writing task data.",
|
||||
testStrategy: "Verify tasks.json is created with the correct structure and that task data can be read from and written to the file."
|
||||
priority: 'high',
|
||||
details:
|
||||
'Create the tasks.json file structure with support for task properties including ID, title, description, status, dependencies, priority, details, and test strategy. Implement file system operations for reading and writing task data.',
|
||||
testStrategy:
|
||||
'Verify tasks.json is created with the correct structure and that task data can be read from and written to the file.'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "Implement CLI Foundation",
|
||||
description: "Create the command-line interface foundation with basic commands",
|
||||
status: "pending",
|
||||
title: 'Implement CLI Foundation',
|
||||
description:
|
||||
'Create the command-line interface foundation with basic commands',
|
||||
status: 'pending',
|
||||
dependencies: [1],
|
||||
priority: "high",
|
||||
details: "Set up Commander.js for handling CLI commands. Implement the basic command structure including help documentation. Create the foundational command parsing logic.",
|
||||
testStrategy: "Test each command to ensure it properly parses arguments and options. Verify help documentation is displayed correctly."
|
||||
priority: 'high',
|
||||
details:
|
||||
'Set up Commander.js for handling CLI commands. Implement the basic command structure including help documentation. Create the foundational command parsing logic.',
|
||||
testStrategy:
|
||||
'Test each command to ensure it properly parses arguments and options. Verify help documentation is displayed correctly.'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
title: "Develop Task Management Operations",
|
||||
description: "Implement core operations for creating, reading, updating, and deleting tasks",
|
||||
status: "pending",
|
||||
title: 'Develop Task Management Operations',
|
||||
description:
|
||||
'Implement core operations for creating, reading, updating, and deleting tasks',
|
||||
status: 'pending',
|
||||
dependencies: [1],
|
||||
priority: "medium",
|
||||
details: "Implement functions for listing tasks, adding new tasks, updating task status, and removing tasks. Include support for filtering tasks by status and other properties.",
|
||||
testStrategy: "Create unit tests for each CRUD operation to verify they correctly modify the task data."
|
||||
priority: 'medium',
|
||||
details:
|
||||
'Implement functions for listing tasks, adding new tasks, updating task status, and removing tasks. Include support for filtering tasks by status and other properties.',
|
||||
testStrategy:
|
||||
'Create unit tests for each CRUD operation to verify they correctly modify the task data.'
|
||||
}
|
||||
],
|
||||
metadata: {
|
||||
projectName: "Task Management CLI",
|
||||
projectName: 'Task Management CLI',
|
||||
totalTasks: 3,
|
||||
sourceFile: "tests/fixtures/sample-prd.txt",
|
||||
generatedAt: "2023-12-15"
|
||||
sourceFile: 'tests/fixtures/sample-prd.txt',
|
||||
generatedAt: '2023-12-15'
|
||||
}
|
||||
};
|
||||
70
tests/fixtures/sample-tasks.js
vendored
70
tests/fixtures/sample-tasks.js
vendored
@@ -4,57 +4,59 @@
|
||||
|
||||
export const sampleTasks = {
|
||||
meta: {
|
||||
projectName: "Test Project",
|
||||
projectVersion: "1.0.0",
|
||||
createdAt: "2023-01-01T00:00:00.000Z",
|
||||
updatedAt: "2023-01-01T00:00:00.000Z"
|
||||
projectName: 'Test Project',
|
||||
projectVersion: '1.0.0',
|
||||
createdAt: '2023-01-01T00:00:00.000Z',
|
||||
updatedAt: '2023-01-01T00:00:00.000Z'
|
||||
},
|
||||
tasks: [
|
||||
{
|
||||
id: 1,
|
||||
title: "Initialize Project",
|
||||
description: "Set up the project structure and dependencies",
|
||||
status: "done",
|
||||
title: 'Initialize Project',
|
||||
description: 'Set up the project structure and dependencies',
|
||||
status: 'done',
|
||||
dependencies: [],
|
||||
priority: "high",
|
||||
details: "Create directory structure, initialize package.json, and install dependencies",
|
||||
testStrategy: "Verify all directories and files are created correctly"
|
||||
priority: 'high',
|
||||
details:
|
||||
'Create directory structure, initialize package.json, and install dependencies',
|
||||
testStrategy: 'Verify all directories and files are created correctly'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "Create Core Functionality",
|
||||
description: "Implement the main features of the application",
|
||||
status: "in-progress",
|
||||
title: 'Create Core Functionality',
|
||||
description: 'Implement the main features of the application',
|
||||
status: 'in-progress',
|
||||
dependencies: [1],
|
||||
priority: "high",
|
||||
details: "Implement user authentication, data processing, and API endpoints",
|
||||
testStrategy: "Write unit tests for all core functions"
|
||||
priority: 'high',
|
||||
details:
|
||||
'Implement user authentication, data processing, and API endpoints',
|
||||
testStrategy: 'Write unit tests for all core functions'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
title: "Implement UI Components",
|
||||
description: "Create the user interface components",
|
||||
status: "pending",
|
||||
title: 'Implement UI Components',
|
||||
description: 'Create the user interface components',
|
||||
status: 'pending',
|
||||
dependencies: [2],
|
||||
priority: "medium",
|
||||
details: "Design and implement React components for the user interface",
|
||||
testStrategy: "Test components with React Testing Library",
|
||||
priority: 'medium',
|
||||
details: 'Design and implement React components for the user interface',
|
||||
testStrategy: 'Test components with React Testing Library',
|
||||
subtasks: [
|
||||
{
|
||||
id: 1,
|
||||
title: "Create Header Component",
|
||||
description: "Implement the header component",
|
||||
status: "pending",
|
||||
title: 'Create Header Component',
|
||||
description: 'Implement the header component',
|
||||
status: 'pending',
|
||||
dependencies: [],
|
||||
details: "Create a responsive header with navigation links"
|
||||
details: 'Create a responsive header with navigation links'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "Create Footer Component",
|
||||
description: "Implement the footer component",
|
||||
status: "pending",
|
||||
title: 'Create Footer Component',
|
||||
description: 'Implement the footer component',
|
||||
status: 'pending',
|
||||
dependencies: [],
|
||||
details: "Create a footer with copyright information and links"
|
||||
details: 'Create a footer with copyright information and links'
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -63,10 +65,10 @@ export const sampleTasks = {
|
||||
|
||||
export const emptySampleTasks = {
|
||||
meta: {
|
||||
projectName: "Empty Project",
|
||||
projectVersion: "1.0.0",
|
||||
createdAt: "2023-01-01T00:00:00.000Z",
|
||||
updatedAt: "2023-01-01T00:00:00.000Z"
|
||||
projectName: 'Empty Project',
|
||||
projectVersion: '1.0.0',
|
||||
createdAt: '2023-01-01T00:00:00.000Z',
|
||||
updatedAt: '2023-01-01T00:00:00.000Z'
|
||||
},
|
||||
tasks: []
|
||||
};
|
||||
@@ -160,7 +160,7 @@ describe('MCP Server Direct Functions', () => {
|
||||
expect(result.success).toBe(true);
|
||||
|
||||
// Verify subtasks are included
|
||||
const taskWithSubtasks = result.data.tasks.find(t => t.id === 2);
|
||||
const taskWithSubtasks = result.data.tasks.find((t) => t.id === 2);
|
||||
expect(taskWithSubtasks.subtasks).toBeDefined();
|
||||
expect(taskWithSubtasks.subtasks.length).toBe(2);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ process.env.PROJECT_NAME = 'Test Project';
|
||||
process.env.PROJECT_VERSION = '1.0.0';
|
||||
|
||||
// Add global test helpers if needed
|
||||
global.wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
||||
global.wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
// If needed, silence console during tests
|
||||
if (process.env.SILENCE_CONSOLE === 'true') {
|
||||
@@ -25,6 +25,6 @@ if (process.env.SILENCE_CONSOLE === 'true') {
|
||||
log: jest.fn(),
|
||||
info: jest.fn(),
|
||||
warn: jest.fn(),
|
||||
error: jest.fn(),
|
||||
error: jest.fn()
|
||||
};
|
||||
}
|
||||
@@ -11,14 +11,16 @@ const mockLog = jest.fn();
|
||||
// Mock dependencies
|
||||
jest.mock('@anthropic-ai/sdk', () => {
|
||||
const mockCreate = jest.fn().mockResolvedValue({
|
||||
content: [{ text: 'AI response' }],
|
||||
content: [{ text: 'AI response' }]
|
||||
});
|
||||
const mockAnthropicInstance = {
|
||||
messages: {
|
||||
create: mockCreate
|
||||
}
|
||||
};
|
||||
const mockAnthropicConstructor = jest.fn().mockImplementation(() => mockAnthropicInstance);
|
||||
const mockAnthropicConstructor = jest
|
||||
.fn()
|
||||
.mockImplementation(() => mockAnthropicInstance);
|
||||
return {
|
||||
Anthropic: mockAnthropicConstructor
|
||||
};
|
||||
@@ -29,10 +31,10 @@ const mockOpenAIInstance = {
|
||||
chat: {
|
||||
completions: {
|
||||
create: jest.fn().mockResolvedValue({
|
||||
choices: [{ message: { content: 'Perplexity response' } }],
|
||||
}),
|
||||
},
|
||||
},
|
||||
choices: [{ message: { content: 'Perplexity response' } }]
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
const mockOpenAI = jest.fn().mockImplementation(() => mockOpenAIInstance);
|
||||
|
||||
@@ -41,31 +43,35 @@ jest.mock('openai', () => {
|
||||
});
|
||||
|
||||
jest.mock('dotenv', () => ({
|
||||
config: jest.fn(),
|
||||
config: jest.fn()
|
||||
}));
|
||||
|
||||
jest.mock('../../scripts/modules/utils.js', () => ({
|
||||
CONFIG: {
|
||||
model: 'claude-3-sonnet-20240229',
|
||||
temperature: 0.7,
|
||||
maxTokens: 4000,
|
||||
maxTokens: 4000
|
||||
},
|
||||
log: mockLog,
|
||||
sanitizePrompt: jest.fn(text => text),
|
||||
sanitizePrompt: jest.fn((text) => text)
|
||||
}));
|
||||
|
||||
jest.mock('../../scripts/modules/ui.js', () => ({
|
||||
startLoadingIndicator: jest.fn().mockReturnValue('mockLoader'),
|
||||
stopLoadingIndicator: jest.fn(),
|
||||
stopLoadingIndicator: jest.fn()
|
||||
}));
|
||||
|
||||
// Mock anthropic global object
|
||||
global.anthropic = {
|
||||
messages: {
|
||||
create: jest.fn().mockResolvedValue({
|
||||
content: [{ text: '[{"id": 1, "title": "Test", "description": "Test", "dependencies": [], "details": "Test"}]' }],
|
||||
}),
|
||||
},
|
||||
content: [
|
||||
{
|
||||
text: '[{"id": 1, "title": "Test", "description": "Test", "dependencies": [], "details": "Test"}]'
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
// Mock process.env
|
||||
@@ -393,7 +399,9 @@ These subtasks will help you implement the parent task efficiently.`;
|
||||
const fileContent = fs.readFileSync(filePath, 'utf8');
|
||||
|
||||
// Check if the beta header is in the file
|
||||
expect(fileContent).toContain("'anthropic-beta': 'output-128k-2025-02-19'");
|
||||
expect(fileContent).toContain(
|
||||
"'anthropic-beta': 'output-128k-2025-02-19'"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -26,14 +26,14 @@ jest.mock('path', () => ({
|
||||
}));
|
||||
|
||||
jest.mock('chalk', () => ({
|
||||
red: jest.fn(text => text),
|
||||
blue: jest.fn(text => text),
|
||||
green: jest.fn(text => text),
|
||||
yellow: jest.fn(text => text),
|
||||
white: jest.fn(text => ({
|
||||
bold: jest.fn(text => text)
|
||||
red: jest.fn((text) => text),
|
||||
blue: jest.fn((text) => text),
|
||||
green: jest.fn((text) => text),
|
||||
yellow: jest.fn((text) => text),
|
||||
white: jest.fn((text) => ({
|
||||
bold: jest.fn((text) => text)
|
||||
})),
|
||||
reset: jest.fn(text => text)
|
||||
reset: jest.fn((text) => text)
|
||||
}));
|
||||
|
||||
jest.mock('../../scripts/modules/ui.js', () => ({
|
||||
@@ -110,8 +110,12 @@ describe('Commands Module', () => {
|
||||
const mockExistsSync = jest.spyOn(fs, 'existsSync');
|
||||
const mockReadFileSync = jest.spyOn(fs, 'readFileSync');
|
||||
const mockJoin = jest.spyOn(path, 'join');
|
||||
const mockConsoleLog = jest.spyOn(console, 'log').mockImplementation(() => {});
|
||||
const mockConsoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
const mockConsoleLog = jest
|
||||
.spyOn(console, 'log')
|
||||
.mockImplementation(() => {});
|
||||
const mockConsoleError = jest
|
||||
.spyOn(console, 'error')
|
||||
.mockImplementation(() => {});
|
||||
const mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {});
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -166,10 +170,9 @@ describe('Commands Module', () => {
|
||||
describe('Kebab Case Validation', () => {
|
||||
test('should detect camelCase flags correctly', () => {
|
||||
const args = ['node', 'task-master', '--camelCase', '--kebab-case'];
|
||||
const camelCaseFlags = args.filter(arg =>
|
||||
arg.startsWith('--') &&
|
||||
/[A-Z]/.test(arg) &&
|
||||
!arg.includes('-[A-Z]')
|
||||
const camelCaseFlags = args.filter(
|
||||
(arg) =>
|
||||
arg.startsWith('--') && /[A-Z]/.test(arg) && !arg.includes('-[A-Z]')
|
||||
);
|
||||
expect(camelCaseFlags).toContain('--camelCase');
|
||||
expect(camelCaseFlags).not.toContain('--kebab-case');
|
||||
@@ -177,10 +180,9 @@ describe('Commands Module', () => {
|
||||
|
||||
test('should accept kebab-case flags correctly', () => {
|
||||
const args = ['node', 'task-master', '--kebab-case'];
|
||||
const camelCaseFlags = args.filter(arg =>
|
||||
arg.startsWith('--') &&
|
||||
/[A-Z]/.test(arg) &&
|
||||
!arg.includes('-[A-Z]')
|
||||
const camelCaseFlags = args.filter(
|
||||
(arg) =>
|
||||
arg.startsWith('--') && /[A-Z]/.test(arg) && !arg.includes('-[A-Z]')
|
||||
);
|
||||
expect(camelCaseFlags).toHaveLength(0);
|
||||
});
|
||||
@@ -206,7 +208,11 @@ describe('Commands Module', () => {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(chalk.yellow('No PRD file specified and default PRD file not found at scripts/prd.txt.'));
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'No PRD file specified and default PRD file not found at scripts/prd.txt.'
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -229,11 +235,16 @@ describe('Commands Module', () => {
|
||||
mockExistsSync.mockReturnValue(true);
|
||||
|
||||
// Act - call the handler directly with the right params
|
||||
await parsePrdAction(undefined, { numTasks: '10', output: 'tasks/tasks.json' });
|
||||
await parsePrdAction(undefined, {
|
||||
numTasks: '10',
|
||||
output: 'tasks/tasks.json'
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(mockExistsSync).toHaveBeenCalledWith('scripts/prd.txt');
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(expect.stringContaining('Using default PRD file'));
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Using default PRD file')
|
||||
);
|
||||
expect(mockParsePRD).toHaveBeenCalledWith(
|
||||
'scripts/prd.txt',
|
||||
'tasks/tasks.json',
|
||||
@@ -246,10 +257,15 @@ describe('Commands Module', () => {
|
||||
mockExistsSync.mockReturnValue(false);
|
||||
|
||||
// Act - call the handler directly with the right params
|
||||
await parsePrdAction(undefined, { numTasks: '10', output: 'tasks/tasks.json' });
|
||||
await parsePrdAction(undefined, {
|
||||
numTasks: '10',
|
||||
output: 'tasks/tasks.json'
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(expect.stringContaining('No PRD file specified'));
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(
|
||||
expect.stringContaining('No PRD file specified')
|
||||
);
|
||||
expect(mockParsePRD).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -258,11 +274,20 @@ describe('Commands Module', () => {
|
||||
const testFile = 'test/prd.txt';
|
||||
|
||||
// Act - call the handler directly with the right params
|
||||
await parsePrdAction(testFile, { numTasks: '10', output: 'tasks/tasks.json' });
|
||||
await parsePrdAction(testFile, {
|
||||
numTasks: '10',
|
||||
output: 'tasks/tasks.json'
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(expect.stringContaining(`Parsing PRD file: ${testFile}`));
|
||||
expect(mockParsePRD).toHaveBeenCalledWith(testFile, 'tasks/tasks.json', 10);
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(
|
||||
expect.stringContaining(`Parsing PRD file: ${testFile}`)
|
||||
);
|
||||
expect(mockParsePRD).toHaveBeenCalledWith(
|
||||
testFile,
|
||||
'tasks/tasks.json',
|
||||
10
|
||||
);
|
||||
expect(mockExistsSync).not.toHaveBeenCalledWith('scripts/prd.txt');
|
||||
});
|
||||
|
||||
@@ -271,11 +296,21 @@ describe('Commands Module', () => {
|
||||
const testFile = 'test/prd.txt';
|
||||
|
||||
// Act - call the handler directly with the right params
|
||||
await parsePrdAction(undefined, { input: testFile, numTasks: '10', output: 'tasks/tasks.json' });
|
||||
await parsePrdAction(undefined, {
|
||||
input: testFile,
|
||||
numTasks: '10',
|
||||
output: 'tasks/tasks.json'
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(expect.stringContaining(`Parsing PRD file: ${testFile}`));
|
||||
expect(mockParsePRD).toHaveBeenCalledWith(testFile, 'tasks/tasks.json', 10);
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(
|
||||
expect.stringContaining(`Parsing PRD file: ${testFile}`)
|
||||
);
|
||||
expect(mockParsePRD).toHaveBeenCalledWith(
|
||||
testFile,
|
||||
'tasks/tasks.json',
|
||||
10
|
||||
);
|
||||
expect(mockExistsSync).not.toHaveBeenCalledWith('scripts/prd.txt');
|
||||
});
|
||||
|
||||
@@ -286,7 +321,10 @@ describe('Commands Module', () => {
|
||||
const numTasks = 15;
|
||||
|
||||
// Act - call the handler directly with the right params
|
||||
await parsePrdAction(testFile, { numTasks: numTasks.toString(), output: outputFile });
|
||||
await parsePrdAction(testFile, {
|
||||
numTasks: numTasks.toString(),
|
||||
output: outputFile
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(mockParsePRD).toHaveBeenCalledWith(testFile, outputFile, numTasks);
|
||||
@@ -303,7 +341,11 @@ describe('Commands Module', () => {
|
||||
// Validate required parameters
|
||||
if (!options.id) {
|
||||
console.error(chalk.red('Error: --id parameter is required'));
|
||||
console.log(chalk.yellow('Usage example: task-master update-task --id=23 --prompt="Update with new information"'));
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'Usage example: task-master update-task --id=23 --prompt="Update with new information"'
|
||||
)
|
||||
);
|
||||
process.exit(1);
|
||||
return; // Add early return to prevent calling updateTaskById
|
||||
}
|
||||
@@ -311,15 +353,31 @@ describe('Commands Module', () => {
|
||||
// Parse the task ID and validate it's a number
|
||||
const taskId = parseInt(options.id, 10);
|
||||
if (isNaN(taskId) || taskId <= 0) {
|
||||
console.error(chalk.red(`Error: Invalid task ID: ${options.id}. Task ID must be a positive integer.`));
|
||||
console.log(chalk.yellow('Usage example: task-master update-task --id=23 --prompt="Update with new information"'));
|
||||
console.error(
|
||||
chalk.red(
|
||||
`Error: Invalid task ID: ${options.id}. Task ID must be a positive integer.`
|
||||
)
|
||||
);
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'Usage example: task-master update-task --id=23 --prompt="Update with new information"'
|
||||
)
|
||||
);
|
||||
process.exit(1);
|
||||
return; // Add early return to prevent calling updateTaskById
|
||||
}
|
||||
|
||||
if (!options.prompt) {
|
||||
console.error(chalk.red('Error: --prompt parameter is required. Please provide information about the changes.'));
|
||||
console.log(chalk.yellow('Usage example: task-master update-task --id=23 --prompt="Update with new information"'));
|
||||
console.error(
|
||||
chalk.red(
|
||||
'Error: --prompt parameter is required. Please provide information about the changes.'
|
||||
)
|
||||
);
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'Usage example: task-master update-task --id=23 --prompt="Update with new information"'
|
||||
)
|
||||
);
|
||||
process.exit(1);
|
||||
return; // Add early return to prevent calling updateTaskById
|
||||
}
|
||||
@@ -329,48 +387,87 @@ describe('Commands Module', () => {
|
||||
|
||||
// Validate tasks file exists
|
||||
if (!fs.existsSync(tasksPath)) {
|
||||
console.error(chalk.red(`Error: Tasks file not found at path: ${tasksPath}`));
|
||||
console.error(
|
||||
chalk.red(`Error: Tasks file not found at path: ${tasksPath}`)
|
||||
);
|
||||
if (tasksPath === 'tasks/tasks.json') {
|
||||
console.log(chalk.yellow('Hint: Run task-master init or task-master parse-prd to create tasks.json first'));
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'Hint: Run task-master init or task-master parse-prd to create tasks.json first'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
console.log(chalk.yellow(`Hint: Check if the file path is correct: ${tasksPath}`));
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
`Hint: Check if the file path is correct: ${tasksPath}`
|
||||
)
|
||||
);
|
||||
}
|
||||
process.exit(1);
|
||||
return; // Add early return to prevent calling updateTaskById
|
||||
}
|
||||
|
||||
console.log(chalk.blue(`Updating task ${taskId} with prompt: "${prompt}"`));
|
||||
console.log(
|
||||
chalk.blue(`Updating task ${taskId} with prompt: "${prompt}"`)
|
||||
);
|
||||
console.log(chalk.blue(`Tasks file: ${tasksPath}`));
|
||||
|
||||
if (useResearch) {
|
||||
// Verify Perplexity API key exists if using research
|
||||
if (!process.env.PERPLEXITY_API_KEY) {
|
||||
console.log(chalk.yellow('Warning: PERPLEXITY_API_KEY environment variable is missing. Research-backed updates will not be available.'));
|
||||
console.log(chalk.yellow('Falling back to Claude AI for task update.'));
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'Warning: PERPLEXITY_API_KEY environment variable is missing. Research-backed updates will not be available.'
|
||||
)
|
||||
);
|
||||
console.log(
|
||||
chalk.yellow('Falling back to Claude AI for task update.')
|
||||
);
|
||||
} else {
|
||||
console.log(chalk.blue('Using Perplexity AI for research-backed task update'));
|
||||
console.log(
|
||||
chalk.blue('Using Perplexity AI for research-backed task update')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const result = await mockUpdateTaskById(tasksPath, taskId, prompt, useResearch);
|
||||
const result = await mockUpdateTaskById(
|
||||
tasksPath,
|
||||
taskId,
|
||||
prompt,
|
||||
useResearch
|
||||
);
|
||||
|
||||
// If the task wasn't updated (e.g., if it was already marked as done)
|
||||
if (!result) {
|
||||
console.log(chalk.yellow('\nTask update was not completed. Review the messages above for details.'));
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'\nTask update was not completed. Review the messages above for details.'
|
||||
)
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(chalk.red(`Error: ${error.message}`));
|
||||
|
||||
// Provide more helpful error messages for common issues
|
||||
if (error.message.includes('task') && error.message.includes('not found')) {
|
||||
if (
|
||||
error.message.includes('task') &&
|
||||
error.message.includes('not found')
|
||||
) {
|
||||
console.log(chalk.yellow('\nTo fix this issue:'));
|
||||
console.log(' 1. Run task-master list to see all available task IDs');
|
||||
console.log(
|
||||
' 1. Run task-master list to see all available task IDs'
|
||||
);
|
||||
console.log(' 2. Use a valid task ID with the --id parameter');
|
||||
} else if (error.message.includes('API key')) {
|
||||
console.log(chalk.yellow('\nThis error is related to API keys. Check your environment variables.'));
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'\nThis error is related to API keys. Check your environment variables.'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (true) { // CONFIG.debug
|
||||
if (true) {
|
||||
// CONFIG.debug
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
@@ -397,7 +494,9 @@ describe('Commands Module', () => {
|
||||
await updateTaskAction(options);
|
||||
|
||||
// Verify validation error
|
||||
expect(mockConsoleError).toHaveBeenCalledWith(expect.stringContaining('--id parameter is required'));
|
||||
expect(mockConsoleError).toHaveBeenCalledWith(
|
||||
expect.stringContaining('--id parameter is required')
|
||||
);
|
||||
expect(mockExit).toHaveBeenCalledWith(1);
|
||||
expect(mockUpdateTaskById).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -414,7 +513,9 @@ describe('Commands Module', () => {
|
||||
await updateTaskAction(options);
|
||||
|
||||
// Verify validation error
|
||||
expect(mockConsoleError).toHaveBeenCalledWith(expect.stringContaining('Invalid task ID'));
|
||||
expect(mockConsoleError).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Invalid task ID')
|
||||
);
|
||||
expect(mockExit).toHaveBeenCalledWith(1);
|
||||
expect(mockUpdateTaskById).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -430,7 +531,9 @@ describe('Commands Module', () => {
|
||||
await updateTaskAction(options);
|
||||
|
||||
// Verify validation error
|
||||
expect(mockConsoleError).toHaveBeenCalledWith(expect.stringContaining('--prompt parameter is required'));
|
||||
expect(mockConsoleError).toHaveBeenCalledWith(
|
||||
expect.stringContaining('--prompt parameter is required')
|
||||
);
|
||||
expect(mockExit).toHaveBeenCalledWith(1);
|
||||
expect(mockUpdateTaskById).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -450,7 +553,9 @@ describe('Commands Module', () => {
|
||||
await updateTaskAction(options);
|
||||
|
||||
// Verify validation error
|
||||
expect(mockConsoleError).toHaveBeenCalledWith(expect.stringContaining('Tasks file not found'));
|
||||
expect(mockConsoleError).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Tasks file not found')
|
||||
);
|
||||
expect(mockExit).toHaveBeenCalledWith(1);
|
||||
expect(mockUpdateTaskById).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -479,8 +584,12 @@ describe('Commands Module', () => {
|
||||
);
|
||||
|
||||
// Verify console output
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(expect.stringContaining('Updating task 2'));
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(expect.stringContaining('Using Perplexity AI'));
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Updating task 2')
|
||||
);
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Using Perplexity AI')
|
||||
);
|
||||
|
||||
// Clean up
|
||||
delete process.env.PERPLEXITY_API_KEY;
|
||||
@@ -504,7 +613,9 @@ describe('Commands Module', () => {
|
||||
expect(mockUpdateTaskById).toHaveBeenCalled();
|
||||
|
||||
// Verify console output for null result
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(expect.stringContaining('Task update was not completed'));
|
||||
expect(mockConsoleLog).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Task update was not completed')
|
||||
);
|
||||
});
|
||||
|
||||
test('should handle errors from updateTaskById', async () => {
|
||||
@@ -522,7 +633,9 @@ describe('Commands Module', () => {
|
||||
await updateTaskAction(options);
|
||||
|
||||
// Verify error handling
|
||||
expect(mockConsoleError).toHaveBeenCalledWith(expect.stringContaining('Error: Task update failed'));
|
||||
expect(mockConsoleError).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Error: Task update failed')
|
||||
);
|
||||
expect(mockExit).toHaveBeenCalledWith(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,17 +17,17 @@ import { sampleTasks } from '../fixtures/sample-tasks.js';
|
||||
// Mock dependencies
|
||||
jest.mock('path');
|
||||
jest.mock('chalk', () => ({
|
||||
green: jest.fn(text => `<green>${text}</green>`),
|
||||
yellow: jest.fn(text => `<yellow>${text}</yellow>`),
|
||||
red: jest.fn(text => `<red>${text}</red>`),
|
||||
cyan: jest.fn(text => `<cyan>${text}</cyan>`),
|
||||
bold: jest.fn(text => `<bold>${text}</bold>`),
|
||||
green: jest.fn((text) => `<green>${text}</green>`),
|
||||
yellow: jest.fn((text) => `<yellow>${text}</yellow>`),
|
||||
red: jest.fn((text) => `<red>${text}</red>`),
|
||||
cyan: jest.fn((text) => `<cyan>${text}</cyan>`),
|
||||
bold: jest.fn((text) => `<bold>${text}</bold>`)
|
||||
}));
|
||||
|
||||
jest.mock('boxen', () => jest.fn(text => `[boxed: ${text}]`));
|
||||
jest.mock('boxen', () => jest.fn((text) => `[boxed: ${text}]`));
|
||||
|
||||
jest.mock('@anthropic-ai/sdk', () => ({
|
||||
Anthropic: jest.fn().mockImplementation(() => ({})),
|
||||
Anthropic: jest.fn().mockImplementation(() => ({}))
|
||||
}));
|
||||
|
||||
// Mock utils module
|
||||
@@ -48,11 +48,11 @@ jest.mock('../../scripts/modules/utils.js', () => ({
|
||||
}));
|
||||
|
||||
jest.mock('../../scripts/modules/ui.js', () => ({
|
||||
displayBanner: jest.fn(),
|
||||
displayBanner: jest.fn()
|
||||
}));
|
||||
|
||||
jest.mock('../../scripts/modules/task-manager.js', () => ({
|
||||
generateTaskFiles: jest.fn(),
|
||||
generateTaskFiles: jest.fn()
|
||||
}));
|
||||
|
||||
// Create a path for test files
|
||||
@@ -67,15 +67,21 @@ describe('Dependency Manager Module', () => {
|
||||
if (Array.isArray(tasks)) {
|
||||
if (typeof id === 'string' && id.includes('.')) {
|
||||
const [taskId, subtaskId] = id.split('.').map(Number);
|
||||
const task = tasks.find(t => t.id === taskId);
|
||||
return task && task.subtasks && task.subtasks.some(st => st.id === subtaskId);
|
||||
const task = tasks.find((t) => t.id === taskId);
|
||||
return (
|
||||
task &&
|
||||
task.subtasks &&
|
||||
task.subtasks.some((st) => st.id === subtaskId)
|
||||
);
|
||||
}
|
||||
return tasks.some(task => task.id === (typeof id === 'string' ? parseInt(id, 10) : id));
|
||||
return tasks.some(
|
||||
(task) => task.id === (typeof id === 'string' ? parseInt(id, 10) : id)
|
||||
);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
mockFormatTaskId.mockImplementation(id => {
|
||||
mockFormatTaskId.mockImplementation((id) => {
|
||||
if (typeof id === 'string' && id.includes('.')) {
|
||||
return id;
|
||||
}
|
||||
@@ -87,7 +93,7 @@ describe('Dependency Manager Module', () => {
|
||||
const dependencyMap = new Map();
|
||||
|
||||
// Build dependency map
|
||||
tasks.forEach(task => {
|
||||
tasks.forEach((task) => {
|
||||
if (task.dependencies) {
|
||||
dependencyMap.set(task.id, task.dependencies);
|
||||
}
|
||||
@@ -168,9 +174,7 @@ describe('Dependency Manager Module', () => {
|
||||
});
|
||||
|
||||
test('should handle a task depending on itself', () => {
|
||||
const tasks = [
|
||||
{ id: 1, dependencies: [1] }
|
||||
];
|
||||
const tasks = [{ id: 1, dependencies: [1] }];
|
||||
|
||||
const result = isCircularDependency(tasks, 1);
|
||||
expect(result).toBe(true);
|
||||
@@ -182,15 +186,15 @@ describe('Dependency Manager Module', () => {
|
||||
id: 1,
|
||||
dependencies: [],
|
||||
subtasks: [
|
||||
{ id: 1, dependencies: ["1.2"] },
|
||||
{ id: 2, dependencies: ["1.3"] },
|
||||
{ id: 3, dependencies: ["1.1"] }
|
||||
{ id: 1, dependencies: ['1.2'] },
|
||||
{ id: 2, dependencies: ['1.3'] },
|
||||
{ id: 3, dependencies: ['1.1'] }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// This creates a circular dependency: 1.1 -> 1.2 -> 1.3 -> 1.1
|
||||
const result = isCircularDependency(tasks, "1.1", ["1.3", "1.2"]);
|
||||
const result = isCircularDependency(tasks, '1.1', ['1.3', '1.2']);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
@@ -201,14 +205,14 @@ describe('Dependency Manager Module', () => {
|
||||
dependencies: [],
|
||||
subtasks: [
|
||||
{ id: 1, dependencies: [] },
|
||||
{ id: 2, dependencies: ["1.1"] },
|
||||
{ id: 3, dependencies: ["1.2"] }
|
||||
{ id: 2, dependencies: ['1.1'] },
|
||||
{ id: 3, dependencies: ['1.2'] }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// This is a valid dependency chain: 1.3 -> 1.2 -> 1.1
|
||||
const result = isCircularDependency(tasks, "1.1", []);
|
||||
const result = isCircularDependency(tasks, '1.1', []);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
@@ -219,7 +223,7 @@ describe('Dependency Manager Module', () => {
|
||||
dependencies: [],
|
||||
subtasks: [
|
||||
{ id: 1, dependencies: [] },
|
||||
{ id: 2, dependencies: ["1.1"] },
|
||||
{ id: 2, dependencies: ['1.1'] },
|
||||
{ id: 3, dependencies: [] }
|
||||
]
|
||||
}
|
||||
@@ -228,7 +232,7 @@ describe('Dependency Manager Module', () => {
|
||||
// Check if adding a dependency from subtask 1.3 to 1.2 creates a circular dependency
|
||||
// This should be false as 1.3 -> 1.2 -> 1.1 is a valid chain
|
||||
mockTaskExists.mockImplementation(() => true);
|
||||
const result = isCircularDependency(tasks, "1.3", ["1.2"]);
|
||||
const result = isCircularDependency(tasks, '1.3', ['1.2']);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
@@ -238,16 +242,16 @@ describe('Dependency Manager Module', () => {
|
||||
id: 1,
|
||||
dependencies: [],
|
||||
subtasks: [
|
||||
{ id: 1, dependencies: ["1.3"] },
|
||||
{ id: 2, dependencies: ["1.1"] },
|
||||
{ id: 3, dependencies: ["1.2"] }
|
||||
{ id: 1, dependencies: ['1.3'] },
|
||||
{ id: 2, dependencies: ['1.1'] },
|
||||
{ id: 3, dependencies: ['1.2'] }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// This creates a circular dependency: 1.1 -> 1.3 -> 1.2 -> 1.1
|
||||
mockTaskExists.mockImplementation(() => true);
|
||||
const result = isCircularDependency(tasks, "1.2", ["1.1"]);
|
||||
const result = isCircularDependency(tasks, '1.2', ['1.1']);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -277,20 +281,22 @@ describe('Dependency Manager Module', () => {
|
||||
const result = validateTaskDependencies(tasks);
|
||||
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.issues.some(issue => issue.type === 'circular')).toBe(true);
|
||||
expect(result.issues.some((issue) => issue.type === 'circular')).toBe(
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
test('should detect self-dependencies', () => {
|
||||
const tasks = [
|
||||
{ id: 1, dependencies: [1] }
|
||||
];
|
||||
const tasks = [{ id: 1, dependencies: [1] }];
|
||||
|
||||
const result = validateTaskDependencies(tasks);
|
||||
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.issues.some(issue =>
|
||||
issue.type === 'self' && issue.taskId === 1
|
||||
)).toBe(true);
|
||||
expect(
|
||||
result.issues.some(
|
||||
(issue) => issue.type === 'self' && issue.taskId === 1
|
||||
)
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
test('should return valid for correct dependencies', () => {
|
||||
@@ -325,13 +331,13 @@ describe('Dependency Manager Module', () => {
|
||||
dependencies: [],
|
||||
subtasks: [
|
||||
{ id: 1, dependencies: [] },
|
||||
{ id: 2, dependencies: ["1.1"] }, // Valid - depends on another subtask
|
||||
{ id: 3, dependencies: ["1.2"] } // Valid - depends on another subtask
|
||||
{ id: 2, dependencies: ['1.1'] }, // Valid - depends on another subtask
|
||||
{ id: 3, dependencies: ['1.2'] } // Valid - depends on another subtask
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
dependencies: ["1.3"], // Valid - depends on a subtask from task 1
|
||||
dependencies: ['1.3'], // Valid - depends on a subtask from task 1
|
||||
subtasks: []
|
||||
}
|
||||
];
|
||||
@@ -340,10 +346,14 @@ describe('Dependency Manager Module', () => {
|
||||
mockTaskExists.mockImplementation((tasks, id) => {
|
||||
if (typeof id === 'string' && id.includes('.')) {
|
||||
const [taskId, subtaskId] = id.split('.').map(Number);
|
||||
const task = tasks.find(t => t.id === taskId);
|
||||
return task && task.subtasks && task.subtasks.some(st => st.id === subtaskId);
|
||||
const task = tasks.find((t) => t.id === taskId);
|
||||
return (
|
||||
task &&
|
||||
task.subtasks &&
|
||||
task.subtasks.some((st) => st.id === subtaskId)
|
||||
);
|
||||
}
|
||||
return tasks.some(task => task.id === parseInt(id, 10));
|
||||
return tasks.some((task) => task.id === parseInt(id, 10));
|
||||
});
|
||||
|
||||
const result = validateTaskDependencies(tasks);
|
||||
@@ -358,8 +368,8 @@ describe('Dependency Manager Module', () => {
|
||||
id: 1,
|
||||
dependencies: [],
|
||||
subtasks: [
|
||||
{ id: 1, dependencies: ["1.4"] }, // Invalid - subtask 4 doesn't exist
|
||||
{ id: 2, dependencies: ["2.1"] } // Invalid - task 2 has no subtasks
|
||||
{ id: 1, dependencies: ['1.4'] }, // Invalid - subtask 4 doesn't exist
|
||||
{ id: 2, dependencies: ['2.1'] } // Invalid - task 2 has no subtasks
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -371,10 +381,10 @@ describe('Dependency Manager Module', () => {
|
||||
|
||||
// Mock taskExists to correctly identify missing subtasks
|
||||
mockTaskExists.mockImplementation((taskArray, depId) => {
|
||||
if (typeof depId === 'string' && depId === "1.4") {
|
||||
if (typeof depId === 'string' && depId === '1.4') {
|
||||
return false; // Subtask 1.4 doesn't exist
|
||||
}
|
||||
if (typeof depId === 'string' && depId === "2.1") {
|
||||
if (typeof depId === 'string' && depId === '2.1') {
|
||||
return false; // Subtask 2.1 doesn't exist
|
||||
}
|
||||
return true; // All other dependencies exist
|
||||
@@ -385,9 +395,14 @@ describe('Dependency Manager Module', () => {
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.issues.length).toBeGreaterThan(0);
|
||||
// Should detect missing subtask dependencies
|
||||
expect(result.issues.some(issue =>
|
||||
issue.type === 'missing' && String(issue.taskId) === "1.1" && String(issue.dependencyId) === "1.4"
|
||||
)).toBe(true);
|
||||
expect(
|
||||
result.issues.some(
|
||||
(issue) =>
|
||||
issue.type === 'missing' &&
|
||||
String(issue.taskId) === '1.1' &&
|
||||
String(issue.dependencyId) === '1.4'
|
||||
)
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
test('should detect circular dependencies between subtasks', () => {
|
||||
@@ -396,8 +411,8 @@ describe('Dependency Manager Module', () => {
|
||||
id: 1,
|
||||
dependencies: [],
|
||||
subtasks: [
|
||||
{ id: 1, dependencies: ["1.2"] },
|
||||
{ id: 2, dependencies: ["1.1"] } // Creates a circular dependency with 1.1
|
||||
{ id: 1, dependencies: ['1.2'] },
|
||||
{ id: 2, dependencies: ['1.1'] } // Creates a circular dependency with 1.1
|
||||
]
|
||||
}
|
||||
];
|
||||
@@ -408,7 +423,9 @@ describe('Dependency Manager Module', () => {
|
||||
const result = validateTaskDependencies(tasks);
|
||||
|
||||
expect(result.valid).toBe(false);
|
||||
expect(result.issues.some(issue => issue.type === 'circular')).toBe(true);
|
||||
expect(result.issues.some((issue) => issue.type === 'circular')).toBe(
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
test('should properly validate dependencies between subtasks of the same parent', () => {
|
||||
@@ -417,8 +434,8 @@ describe('Dependency Manager Module', () => {
|
||||
id: 23,
|
||||
dependencies: [],
|
||||
subtasks: [
|
||||
{ id: 8, dependencies: ["23.13"] },
|
||||
{ id: 10, dependencies: ["23.8"] },
|
||||
{ id: 8, dependencies: ['23.13'] },
|
||||
{ id: 10, dependencies: ['23.8'] },
|
||||
{ id: 13, dependencies: [] }
|
||||
]
|
||||
}
|
||||
@@ -427,7 +444,7 @@ describe('Dependency Manager Module', () => {
|
||||
// Mock taskExists to validate the subtask dependencies
|
||||
mockTaskExists.mockImplementation((taskArray, id) => {
|
||||
if (typeof id === 'string') {
|
||||
if (id === "23.8" || id === "23.10" || id === "23.13") {
|
||||
if (id === '23.8' || id === '23.10' || id === '23.13') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -576,37 +593,27 @@ describe('Dependency Manager Module', () => {
|
||||
|
||||
test('should handle tasks without subtasks', () => {
|
||||
const tasksData = {
|
||||
tasks: [
|
||||
{ id: 1 },
|
||||
{ id: 2, dependencies: [1] }
|
||||
]
|
||||
tasks: [{ id: 1 }, { id: 2, dependencies: [1] }]
|
||||
};
|
||||
|
||||
const result = ensureAtLeastOneIndependentSubtask(tasksData);
|
||||
|
||||
expect(result).toBe(false);
|
||||
expect(tasksData).toEqual({
|
||||
tasks: [
|
||||
{ id: 1 },
|
||||
{ id: 2, dependencies: [1] }
|
||||
]
|
||||
tasks: [{ id: 1 }, { id: 2, dependencies: [1] }]
|
||||
});
|
||||
});
|
||||
|
||||
test('should handle empty subtasks array', () => {
|
||||
const tasksData = {
|
||||
tasks: [
|
||||
{ id: 1, subtasks: [] }
|
||||
]
|
||||
tasks: [{ id: 1, subtasks: [] }]
|
||||
};
|
||||
|
||||
const result = ensureAtLeastOneIndependentSubtask(tasksData);
|
||||
|
||||
expect(result).toBe(false);
|
||||
expect(tasksData).toEqual({
|
||||
tasks: [
|
||||
{ id: 1, subtasks: [] }
|
||||
]
|
||||
tasks: [{ id: 1, subtasks: [] }]
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -641,8 +648,12 @@ describe('Dependency Manager Module', () => {
|
||||
// Handle subtask references (e.g., "1.2")
|
||||
if (idStr.includes('.')) {
|
||||
const [parentId, subtaskId] = idStr.split('.').map(Number);
|
||||
const task = tasks.find(t => t.id === parentId);
|
||||
return task && task.subtasks && task.subtasks.some(st => st.id === subtaskId);
|
||||
const task = tasks.find((t) => t.id === parentId);
|
||||
return (
|
||||
task &&
|
||||
task.subtasks &&
|
||||
task.subtasks.some((st) => st.id === subtaskId)
|
||||
);
|
||||
}
|
||||
|
||||
// Handle regular task references
|
||||
@@ -674,7 +685,10 @@ describe('Dependency Manager Module', () => {
|
||||
expect(tasksData.tasks[1].subtasks[0].dependencies).toEqual([]);
|
||||
|
||||
// IMPORTANT: Verify no calls to writeJSON with actual tasks.json
|
||||
expect(mockWriteJSON).not.toHaveBeenCalledWith('tasks/tasks.json', expect.anything());
|
||||
expect(mockWriteJSON).not.toHaveBeenCalledWith(
|
||||
'tasks/tasks.json',
|
||||
expect.anything()
|
||||
);
|
||||
});
|
||||
|
||||
test('should return false if no changes needed', () => {
|
||||
@@ -703,8 +717,12 @@ describe('Dependency Manager Module', () => {
|
||||
// Handle subtask references
|
||||
if (idStr.includes('.')) {
|
||||
const [parentId, subtaskId] = idStr.split('.').map(Number);
|
||||
const task = tasks.find(t => t.id === parentId);
|
||||
return task && task.subtasks && task.subtasks.some(st => st.id === subtaskId);
|
||||
const task = tasks.find((t) => t.id === parentId);
|
||||
return (
|
||||
task &&
|
||||
task.subtasks &&
|
||||
task.subtasks.some((st) => st.id === subtaskId)
|
||||
);
|
||||
}
|
||||
|
||||
// Handle regular task references
|
||||
@@ -720,7 +738,10 @@ describe('Dependency Manager Module', () => {
|
||||
expect(tasksData).toEqual(originalData);
|
||||
|
||||
// IMPORTANT: Verify no calls to writeJSON with actual tasks.json
|
||||
expect(mockWriteJSON).not.toHaveBeenCalledWith('tasks/tasks.json', expect.anything());
|
||||
expect(mockWriteJSON).not.toHaveBeenCalledWith(
|
||||
'tasks/tasks.json',
|
||||
expect.anything()
|
||||
);
|
||||
});
|
||||
|
||||
test('should handle invalid input', () => {
|
||||
@@ -730,7 +751,10 @@ describe('Dependency Manager Module', () => {
|
||||
expect(validateAndFixDependencies({ tasks: 'not an array' })).toBe(false);
|
||||
|
||||
// IMPORTANT: Verify no calls to writeJSON with actual tasks.json
|
||||
expect(mockWriteJSON).not.toHaveBeenCalledWith('tasks/tasks.json', expect.anything());
|
||||
expect(mockWriteJSON).not.toHaveBeenCalledWith(
|
||||
'tasks/tasks.json',
|
||||
expect.anything()
|
||||
);
|
||||
});
|
||||
|
||||
test('should save changes when tasksPath is provided', () => {
|
||||
@@ -754,8 +778,12 @@ describe('Dependency Manager Module', () => {
|
||||
// Handle subtask references
|
||||
if (idStr.includes('.')) {
|
||||
const [parentId, subtaskId] = idStr.split('.').map(Number);
|
||||
const task = tasks.find(t => t.id === parentId);
|
||||
return task && task.subtasks && task.subtasks.some(st => st.id === subtaskId);
|
||||
const task = tasks.find((t) => t.id === parentId);
|
||||
return (
|
||||
task &&
|
||||
task.subtasks &&
|
||||
task.subtasks.some((st) => st.id === subtaskId)
|
||||
);
|
||||
}
|
||||
|
||||
// Handle regular task references
|
||||
@@ -776,7 +804,10 @@ describe('Dependency Manager Module', () => {
|
||||
expect(tasksData).not.toEqual(originalData);
|
||||
|
||||
// IMPORTANT: Verify no calls to writeJSON with actual tasks.json
|
||||
expect(mockWriteJSON).not.toHaveBeenCalledWith('tasks/tasks.json', expect.anything());
|
||||
expect(mockWriteJSON).not.toHaveBeenCalledWith(
|
||||
'tasks/tasks.json',
|
||||
expect.anything()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -77,7 +77,8 @@ describe('Windsurf Rules File Handling', () => {
|
||||
if (fs.existsSync(targetPath)) {
|
||||
// Should append content when file exists
|
||||
const existingContent = fs.readFileSync(targetPath, 'utf8');
|
||||
const updatedContent = existingContent.trim() +
|
||||
const updatedContent =
|
||||
existingContent.trim() +
|
||||
'\n\n# Added by Claude Task Master - Development Workflow Rules\n\n' +
|
||||
'New content';
|
||||
fs.writeFileSync(targetPath, updatedContent);
|
||||
@@ -131,7 +132,10 @@ describe('Windsurf Rules File Handling', () => {
|
||||
// Mock implementation of createProjectStructure
|
||||
function mockCreateProjectStructure(projectName) {
|
||||
// Copy template files including .windsurfrules
|
||||
mockCopyTemplateFile('windsurfrules', path.join(tempDir, '.windsurfrules'));
|
||||
mockCopyTemplateFile(
|
||||
'windsurfrules',
|
||||
path.join(tempDir, '.windsurfrules')
|
||||
);
|
||||
}
|
||||
|
||||
// Act - call our mock implementation
|
||||
@@ -160,10 +164,10 @@ describe('MCP Configuration Handling', () => {
|
||||
jest.spyOn(fs, 'readFileSync').mockImplementation((filePath) => {
|
||||
if (filePath.toString().includes('mcp.json')) {
|
||||
return JSON.stringify({
|
||||
"mcpServers": {
|
||||
"existing-server": {
|
||||
"command": "node",
|
||||
"args": ["server.js"]
|
||||
mcpServers: {
|
||||
'existing-server': {
|
||||
command: 'node',
|
||||
args: ['server.js']
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -203,12 +207,9 @@ describe('MCP Configuration Handling', () => {
|
||||
|
||||
// New MCP config to be added - references the installed package
|
||||
const newMCPServer = {
|
||||
"task-master-ai": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"task-master-ai",
|
||||
"mcp-server"
|
||||
]
|
||||
'task-master-ai': {
|
||||
command: 'npx',
|
||||
args: ['task-master-ai', 'mcp-server']
|
||||
}
|
||||
};
|
||||
|
||||
@@ -224,19 +225,17 @@ describe('MCP Configuration Handling', () => {
|
||||
}
|
||||
|
||||
// Add the taskmaster-ai server if it doesn't exist
|
||||
if (!mcpConfig.mcpServers["task-master-ai"]) {
|
||||
mcpConfig.mcpServers["task-master-ai"] = newMCPServer["task-master-ai"];
|
||||
if (!mcpConfig.mcpServers['task-master-ai']) {
|
||||
mcpConfig.mcpServers['task-master-ai'] =
|
||||
newMCPServer['task-master-ai'];
|
||||
}
|
||||
|
||||
// Write the updated configuration
|
||||
fs.writeFileSync(
|
||||
mcpJsonPath,
|
||||
JSON.stringify(mcpConfig, null, 4)
|
||||
);
|
||||
fs.writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 4));
|
||||
} catch (error) {
|
||||
// Create new configuration on error
|
||||
const newMCPConfig = {
|
||||
"mcpServers": newMCPServer
|
||||
mcpServers: newMCPServer
|
||||
};
|
||||
|
||||
fs.writeFileSync(mcpJsonPath, JSON.stringify(newMCPConfig, null, 4));
|
||||
@@ -244,7 +243,7 @@ describe('MCP Configuration Handling', () => {
|
||||
} else {
|
||||
// If mcp.json doesn't exist, create it
|
||||
const newMCPConfig = {
|
||||
"mcpServers": newMCPServer
|
||||
mcpServers: newMCPServer
|
||||
};
|
||||
|
||||
fs.writeFileSync(mcpJsonPath, JSON.stringify(newMCPConfig, null, 4));
|
||||
@@ -353,14 +352,14 @@ describe('MCP Configuration Handling', () => {
|
||||
fs.readFileSync.mockImplementation((filePath) => {
|
||||
if (filePath.toString().includes('mcp.json')) {
|
||||
return JSON.stringify({
|
||||
"mcpServers": {
|
||||
"existing-server": {
|
||||
"command": "node",
|
||||
"args": ["server.js"]
|
||||
mcpServers: {
|
||||
'existing-server': {
|
||||
command: 'node',
|
||||
args: ['server.js']
|
||||
},
|
||||
"task-master-ai": {
|
||||
"command": "custom",
|
||||
"args": ["custom-args"]
|
||||
'task-master-ai': {
|
||||
command: 'custom',
|
||||
args: ['custom-args']
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -377,8 +376,10 @@ describe('MCP Configuration Handling', () => {
|
||||
// Assert
|
||||
// Verify the written data contains the original taskmaster configuration
|
||||
const dataWritten = JSON.parse(writeFileSyncSpy.mock.calls[0][1]);
|
||||
expect(dataWritten.mcpServers["task-master-ai"].command).toBe("custom");
|
||||
expect(dataWritten.mcpServers["task-master-ai"].args).toContain("custom-args");
|
||||
expect(dataWritten.mcpServers['task-master-ai'].command).toBe('custom');
|
||||
expect(dataWritten.mcpServers['task-master-ai'].args).toContain(
|
||||
'custom-args'
|
||||
);
|
||||
});
|
||||
|
||||
test('creates the .cursor directory if it doesnt exist', () => {
|
||||
@@ -392,6 +393,8 @@ describe('MCP Configuration Handling', () => {
|
||||
mockSetupMCPConfiguration(tempDir, 'test-project');
|
||||
|
||||
// Assert
|
||||
expect(fs.mkdirSync).toHaveBeenCalledWith(cursorDirPath, { recursive: true });
|
||||
expect(fs.mkdirSync).toHaveBeenCalledWith(cursorDirPath, {
|
||||
recursive: true
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -53,7 +53,13 @@ describe('Kebab Case Validation', () => {
|
||||
|
||||
describe('detectCamelCaseFlags', () => {
|
||||
test('should properly detect camelCase flags', () => {
|
||||
const args = ['node', 'task-master', 'add-task', '--promptText=test', '--userID=123'];
|
||||
const args = [
|
||||
'node',
|
||||
'task-master',
|
||||
'add-task',
|
||||
'--promptText=test',
|
||||
'--userID=123'
|
||||
];
|
||||
const flags = testDetectCamelCaseFlags(args);
|
||||
|
||||
expect(flags).toHaveLength(2);
|
||||
@@ -68,7 +74,13 @@ describe('Kebab Case Validation', () => {
|
||||
});
|
||||
|
||||
test('should not flag kebab-case or lowercase flags', () => {
|
||||
const args = ['node', 'task-master', 'add-task', '--prompt=test', '--user-id=123'];
|
||||
const args = [
|
||||
'node',
|
||||
'task-master',
|
||||
'add-task',
|
||||
'--prompt=test',
|
||||
'--user-id=123'
|
||||
];
|
||||
const flags = testDetectCamelCaseFlags(args);
|
||||
|
||||
expect(flags).toHaveLength(0);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,17 +13,17 @@ import { sampleTasks } from '../fixtures/sample-tasks.js';
|
||||
|
||||
// Mock dependencies
|
||||
jest.mock('chalk', () => {
|
||||
const origChalkFn = text => text;
|
||||
const origChalkFn = (text) => text;
|
||||
const chalk = origChalkFn;
|
||||
chalk.green = text => text; // Return text as-is for status functions
|
||||
chalk.yellow = text => text;
|
||||
chalk.red = text => text;
|
||||
chalk.cyan = text => text;
|
||||
chalk.blue = text => text;
|
||||
chalk.gray = text => text;
|
||||
chalk.white = text => text;
|
||||
chalk.bold = text => text;
|
||||
chalk.dim = text => text;
|
||||
chalk.green = (text) => text; // Return text as-is for status functions
|
||||
chalk.yellow = (text) => text;
|
||||
chalk.red = (text) => text;
|
||||
chalk.cyan = (text) => text;
|
||||
chalk.blue = (text) => text;
|
||||
chalk.gray = (text) => text;
|
||||
chalk.white = (text) => text;
|
||||
chalk.bold = (text) => text;
|
||||
chalk.dim = (text) => text;
|
||||
|
||||
// Add hex and other methods
|
||||
chalk.hex = () => origChalkFn;
|
||||
@@ -33,40 +33,44 @@ jest.mock('chalk', () => {
|
||||
});
|
||||
|
||||
jest.mock('figlet', () => ({
|
||||
textSync: jest.fn(() => 'Task Master Banner'),
|
||||
textSync: jest.fn(() => 'Task Master Banner')
|
||||
}));
|
||||
|
||||
jest.mock('boxen', () => jest.fn(text => `[boxed: ${text}]`));
|
||||
jest.mock('boxen', () => jest.fn((text) => `[boxed: ${text}]`));
|
||||
|
||||
jest.mock('ora', () => jest.fn(() => ({
|
||||
jest.mock('ora', () =>
|
||||
jest.fn(() => ({
|
||||
start: jest.fn(),
|
||||
succeed: jest.fn(),
|
||||
fail: jest.fn(),
|
||||
stop: jest.fn(),
|
||||
})));
|
||||
stop: jest.fn()
|
||||
}))
|
||||
);
|
||||
|
||||
jest.mock('cli-table3', () => jest.fn().mockImplementation(() => ({
|
||||
jest.mock('cli-table3', () =>
|
||||
jest.fn().mockImplementation(() => ({
|
||||
push: jest.fn(),
|
||||
toString: jest.fn(() => 'Table Content'),
|
||||
})));
|
||||
toString: jest.fn(() => 'Table Content')
|
||||
}))
|
||||
);
|
||||
|
||||
jest.mock('gradient-string', () => jest.fn(() => jest.fn(text => text)));
|
||||
jest.mock('gradient-string', () => jest.fn(() => jest.fn((text) => text)));
|
||||
|
||||
jest.mock('../../scripts/modules/utils.js', () => ({
|
||||
CONFIG: {
|
||||
projectName: 'Test Project',
|
||||
projectVersion: '1.0.0',
|
||||
projectVersion: '1.0.0'
|
||||
},
|
||||
log: jest.fn(),
|
||||
findTaskById: jest.fn(),
|
||||
readJSON: jest.fn(),
|
||||
readComplexityReport: jest.fn(),
|
||||
truncate: jest.fn(text => text),
|
||||
truncate: jest.fn((text) => text)
|
||||
}));
|
||||
|
||||
jest.mock('../../scripts/modules/task-manager.js', () => ({
|
||||
findNextTask: jest.fn(),
|
||||
analyzeTaskComplexity: jest.fn(),
|
||||
analyzeTaskComplexity: jest.fn()
|
||||
}));
|
||||
|
||||
describe('UI Module', () => {
|
||||
@@ -166,9 +170,7 @@ describe('UI Module', () => {
|
||||
|
||||
test('should handle missing tasks in the task list', () => {
|
||||
const dependencies = [1, 999];
|
||||
const allTasks = [
|
||||
{ id: 1, status: 'done' }
|
||||
];
|
||||
const allTasks = [{ id: 1, status: 'done' }];
|
||||
|
||||
const result = formatDependenciesWithStatus(dependencies, allTasks);
|
||||
expect(result).toBe('1, 999 (Not found)');
|
||||
|
||||
@@ -29,11 +29,11 @@ import {
|
||||
|
||||
// Mock chalk functions
|
||||
jest.mock('chalk', () => ({
|
||||
gray: jest.fn(text => `gray:${text}`),
|
||||
blue: jest.fn(text => `blue:${text}`),
|
||||
yellow: jest.fn(text => `yellow:${text}`),
|
||||
red: jest.fn(text => `red:${text}`),
|
||||
green: jest.fn(text => `green:${text}`)
|
||||
gray: jest.fn((text) => `gray:${text}`),
|
||||
blue: jest.fn((text) => `blue:${text}`),
|
||||
yellow: jest.fn((text) => `yellow:${text}`),
|
||||
red: jest.fn((text) => `red:${text}`),
|
||||
green: jest.fn((text) => `green:${text}`)
|
||||
}));
|
||||
|
||||
// Test implementation of detectCamelCaseFlags
|
||||
@@ -96,7 +96,10 @@ describe('Utils Module', () => {
|
||||
});
|
||||
|
||||
test('should truncate the string and add ellipsis if longer than maxLength', () => {
|
||||
const result = truncate('This is a long string that needs truncation', 20);
|
||||
const result = truncate(
|
||||
'This is a long string that needs truncation',
|
||||
20
|
||||
);
|
||||
expect(result).toBe('This is a long st...');
|
||||
});
|
||||
|
||||
@@ -150,12 +153,20 @@ describe('Utils Module', () => {
|
||||
log('error', 'Error message');
|
||||
|
||||
// Debug should not be logged (level 0 < 1)
|
||||
expect(console.log).not.toHaveBeenCalledWith(expect.stringContaining('Debug message'));
|
||||
expect(console.log).not.toHaveBeenCalledWith(
|
||||
expect.stringContaining('Debug message')
|
||||
);
|
||||
|
||||
// Info and above should be logged
|
||||
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Info message'));
|
||||
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Warning message'));
|
||||
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Error message'));
|
||||
expect(console.log).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Info message')
|
||||
);
|
||||
expect(console.log).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Warning message')
|
||||
);
|
||||
expect(console.log).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Error message')
|
||||
);
|
||||
|
||||
// Verify the formatting includes icons
|
||||
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('ℹ️'));
|
||||
@@ -173,16 +184,26 @@ describe('Utils Module', () => {
|
||||
log('error', 'Error message');
|
||||
|
||||
// Only error should be logged
|
||||
expect(console.log).not.toHaveBeenCalledWith(expect.stringContaining('Debug message'));
|
||||
expect(console.log).not.toHaveBeenCalledWith(expect.stringContaining('Info message'));
|
||||
expect(console.log).not.toHaveBeenCalledWith(expect.stringContaining('Warning message'));
|
||||
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Error message'));
|
||||
expect(console.log).not.toHaveBeenCalledWith(
|
||||
expect.stringContaining('Debug message')
|
||||
);
|
||||
expect(console.log).not.toHaveBeenCalledWith(
|
||||
expect.stringContaining('Info message')
|
||||
);
|
||||
expect(console.log).not.toHaveBeenCalledWith(
|
||||
expect.stringContaining('Warning message')
|
||||
);
|
||||
expect(console.log).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Error message')
|
||||
);
|
||||
});
|
||||
|
||||
test('should join multiple arguments into a single message', () => {
|
||||
CONFIG.logLevel = 'info';
|
||||
log('info', 'Message', 'with', 'multiple', 'parts');
|
||||
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Message with multiple parts'));
|
||||
expect(console.log).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Message with multiple parts')
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -203,7 +224,9 @@ describe('Utils Module', () => {
|
||||
});
|
||||
|
||||
// Mock console.error
|
||||
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
const consoleSpy = jest
|
||||
.spyOn(console, 'error')
|
||||
.mockImplementation(() => {});
|
||||
|
||||
const result = readJSON('nonexistent.json');
|
||||
|
||||
@@ -217,7 +240,9 @@ describe('Utils Module', () => {
|
||||
fsReadFileSyncSpy.mockReturnValue('{ invalid json: }');
|
||||
|
||||
// Mock console.error
|
||||
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
const consoleSpy = jest
|
||||
.spyOn(console, 'error')
|
||||
.mockImplementation(() => {});
|
||||
|
||||
const result = readJSON('invalid.json');
|
||||
|
||||
@@ -248,7 +273,9 @@ describe('Utils Module', () => {
|
||||
});
|
||||
|
||||
// Mock console.error
|
||||
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
const consoleSpy = jest
|
||||
.spyOn(console, 'error')
|
||||
.mockImplementation(() => {});
|
||||
|
||||
// Function shouldn't throw, just log error
|
||||
expect(() => writeJSON('protected.json', testData)).not.toThrow();
|
||||
@@ -261,7 +288,8 @@ describe('Utils Module', () => {
|
||||
describe('sanitizePrompt function', () => {
|
||||
test('should escape double quotes in prompts', () => {
|
||||
const prompt = 'This is a "quoted" prompt with "multiple" quotes';
|
||||
const expected = 'This is a \\"quoted\\" prompt with \\"multiple\\" quotes';
|
||||
const expected =
|
||||
'This is a \\"quoted\\" prompt with \\"multiple\\" quotes';
|
||||
|
||||
expect(sanitizePrompt(prompt)).toBe(expected);
|
||||
});
|
||||
@@ -291,7 +319,10 @@ describe('Utils Module', () => {
|
||||
const result = readComplexityReport();
|
||||
|
||||
expect(fsExistsSyncSpy).toHaveBeenCalled();
|
||||
expect(fsReadFileSyncSpy).toHaveBeenCalledWith('/path/to/report.json', 'utf8');
|
||||
expect(fsReadFileSyncSpy).toHaveBeenCalledWith(
|
||||
'/path/to/report.json',
|
||||
'utf8'
|
||||
);
|
||||
expect(result).toEqual(testReport);
|
||||
});
|
||||
|
||||
@@ -361,7 +392,9 @@ describe('Utils Module', () => {
|
||||
expect(findTaskInComplexityReport({}, 1)).toBeNull();
|
||||
|
||||
// Test with non-array complexityAnalysis
|
||||
expect(findTaskInComplexityReport({ complexityAnalysis: {} }, 1)).toBeNull();
|
||||
expect(
|
||||
findTaskInComplexityReport({ complexityAnalysis: {} }, 1)
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -519,7 +552,13 @@ describe('CLI Flag Format Validation', () => {
|
||||
});
|
||||
|
||||
test('detectCamelCaseFlags should identify camelCase flags', () => {
|
||||
const args = ['node', 'task-master', 'add-task', '--promptText=test', '--userID=123'];
|
||||
const args = [
|
||||
'node',
|
||||
'task-master',
|
||||
'add-task',
|
||||
'--promptText=test',
|
||||
'--userID=123'
|
||||
];
|
||||
const flags = testDetectCamelCaseFlags(args);
|
||||
|
||||
expect(flags).toHaveLength(2);
|
||||
@@ -534,14 +573,28 @@ describe('CLI Flag Format Validation', () => {
|
||||
});
|
||||
|
||||
test('detectCamelCaseFlags should not flag kebab-case flags', () => {
|
||||
const args = ['node', 'task-master', 'add-task', '--prompt-text=test', '--user-id=123'];
|
||||
const args = [
|
||||
'node',
|
||||
'task-master',
|
||||
'add-task',
|
||||
'--prompt-text=test',
|
||||
'--user-id=123'
|
||||
];
|
||||
const flags = testDetectCamelCaseFlags(args);
|
||||
|
||||
expect(flags).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('detectCamelCaseFlags should respect single-word flags', () => {
|
||||
const args = ['node', 'task-master', 'add-task', '--prompt=test', '--file=test.json', '--priority=high', '--promptText=test'];
|
||||
const args = [
|
||||
'node',
|
||||
'task-master',
|
||||
'add-task',
|
||||
'--prompt=test',
|
||||
'--file=test.json',
|
||||
'--priority=high',
|
||||
'--promptText=test'
|
||||
];
|
||||
const flags = testDetectCamelCaseFlags(args);
|
||||
|
||||
// Should only flag promptText, not the single-word flags
|
||||
|
||||
Reference in New Issue
Block a user