From bdd0035fc0edea0fea310d265291e094044d84ef Mon Sep 17 00:00:00 2001 From: Eyal Toledano Date: Tue, 1 Apr 2025 02:09:39 -0400 Subject: [PATCH] chore: task mgmt --- package.json | 5 +++-- tasks/task_023.txt | 14 +++++++++++++- tasks/tasks.json | 20 +++++++++++++++++++- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 048dfe9f..81859636 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,11 @@ "test:coverage": "node --experimental-vm-modules node_modules/.bin/jest --coverage", "prepare-package": "node scripts/prepare-package.js", "prepublishOnly": "npm run prepare-package", - "prepare": "chmod +x bin/task-master.js bin/task-master-init.js", + "prepare": "chmod +x bin/task-master.js bin/task-master-init.js mcp-server/server.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", + "mcp-server": "node mcp-server/server.js" }, "keywords": [ "claude", diff --git a/tasks/task_023.txt b/tasks/task_023.txt index 7faa171a..9bd06e40 100644 --- a/tasks/task_023.txt +++ b/tasks/task_023.txt @@ -947,7 +947,7 @@ Implement the addResearch function in the MCP server's index.js file to enable r ### Details: Implement the addTemplates function in the MCP server's index.js file to enable template-based generation. Configure proper loading of templates from the appropriate directory and ensure they're accessible to all MCP tools that need to generate formatted content. -## 38. Implement robust project root handling for file paths [in-progress] +## 38. Implement robust project root handling for file paths [done] ### Dependencies: None ### Description: Create a consistent approach for handling project root paths across MCP tools ### Details: @@ -1201,3 +1201,15 @@ const debugMode = config.env.get('DEBUG_MODE', false); // With a default value This method provides a consistent way to access environment variables defined in the mcp.json configuration file within your FastMCP project in a JavaScript environment. +## 46. adjust rules so it prioritizes mcp commands over script [pending] +### Dependencies: None +### Description: +### Details: + + +## 47. adjust rules so it prioritizes mcp commands over script [pending] +### Dependencies: None +### Description: +### Details: + + diff --git a/tasks/tasks.json b/tasks/tasks.json index a1fdb5ba..e282ea64 100644 --- a/tasks/tasks.json +++ b/tasks/tasks.json @@ -1692,7 +1692,7 @@ "title": "Implement robust project root handling for file paths", "description": "Create a consistent approach for handling project root paths across MCP tools", "details": "Analyze and refactor the project root handling mechanism to ensure consistent file path resolution across all MCP direct functions. This should properly handle relative and absolute paths, respect the projectRoot parameter when provided, and have appropriate fallbacks when not specified. Document the approach in a comment within path-utils.js for future maintainers.\n\n\nHere's additional information addressing the request for research on npm package path handling:\n\n## Path Handling Best Practices for npm Packages\n\n### Distinguishing Package and Project Paths\n\n1. **Package Installation Path**: \n - Use `require.resolve()` to find paths relative to your package\n - For global installs, use `process.execPath` to locate the Node.js executable\n\n2. **Project Path**:\n - Use `process.cwd()` as a starting point\n - Search upwards for `package.json` or `.git` to find project root\n - Consider using packages like `find-up` or `pkg-dir` for robust root detection\n\n### Standard Approaches\n\n1. **Detecting Project Root**:\n - Recursive search for `package.json` or `.git` directory\n - Use `path.resolve()` to handle relative paths\n - Fall back to `process.cwd()` if no root markers found\n\n2. **Accessing Package Files**:\n - Use `__dirname` for paths relative to current script\n - For files in `node_modules`, use `require.resolve('package-name/path/to/file')`\n\n3. **Separating Package and Project Files**:\n - Store package-specific files in a dedicated directory (e.g., `.task-master`)\n - Use environment variables to override default paths\n\n### Cross-Platform Compatibility\n\n1. Use `path.join()` and `path.resolve()` for cross-platform path handling\n2. Avoid hardcoded forward/backslashes in paths\n3. Use `os.homedir()` for user home directory references\n\n### Best Practices for Path Resolution\n\n1. **Absolute vs Relative Paths**:\n - Always convert relative paths to absolute using `path.resolve()`\n - Use `path.isAbsolute()` to check if a path is already absolute\n\n2. **Handling Different Installation Scenarios**:\n - Local dev: Use `process.cwd()` as fallback project root\n - Local dependency: Resolve paths relative to consuming project\n - Global install: Use `process.execPath` to locate global `node_modules`\n\n3. **Configuration Options**:\n - Allow users to specify custom project root via CLI option or config file\n - Implement a clear precedence order for path resolution (e.g., CLI option > config file > auto-detection)\n\n4. **Error Handling**:\n - Provide clear error messages when critical paths cannot be resolved\n - Implement retry logic with alternative methods if primary path detection fails\n\n5. **Documentation**:\n - Clearly document path handling behavior in README and inline comments\n - Provide examples for common scenarios and edge cases\n\nBy implementing these practices, the MCP tools can achieve consistent and robust path handling across various npm installation and usage scenarios.\n\n\n\nHere's additional information addressing the request for clarification on path handling challenges for npm packages:\n\n## Advanced Path Handling Challenges and Solutions\n\n### Challenges to Avoid\n\n1. **Relying solely on process.cwd()**:\n - Global installs: process.cwd() could be any directory\n - Local installs as dependency: points to parent project's root\n - Users may run commands from subdirectories\n\n2. **Dual Path Requirements**:\n - Package Path: Where task-master code is installed\n - Project Path: Where user's tasks.json resides\n\n3. **Specific Edge Cases**:\n - Non-project directory execution\n - Deeply nested project structures\n - Yarn/pnpm workspaces\n - Monorepos with multiple tasks.json files\n - Commands invoked from scripts in different directories\n\n### Advanced Solutions\n\n1. **Project Marker Detection**:\n - Implement recursive search for package.json or .git\n - Use `find-up` package for efficient directory traversal\n ```javascript\n const findUp = require('find-up');\n const projectRoot = await findUp(dir => findUp.sync('package.json', { cwd: dir }));\n ```\n\n2. **Package Path Resolution**:\n - Leverage `import.meta.url` with `fileURLToPath`:\n ```javascript\n import { fileURLToPath } from 'url';\n import path from 'path';\n \n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const packageRoot = path.resolve(__dirname, '..');\n ```\n\n3. **Workspace-Aware Resolution**:\n - Detect Yarn/pnpm workspaces:\n ```javascript\n const findWorkspaceRoot = require('find-yarn-workspace-root');\n const workspaceRoot = findWorkspaceRoot(process.cwd());\n ```\n\n4. **Monorepo Handling**:\n - Implement cascading configuration search\n - Allow multiple tasks.json files with clear precedence rules\n\n5. **CLI Tool Inspiration**:\n - ESLint: Uses `eslint-find-rule-files` for config discovery\n - Jest: Implements `jest-resolve` for custom module resolution\n - Next.js: Uses `find-up` to locate project directories\n\n6. **Robust Path Resolution Algorithm**:\n ```javascript\n function resolveProjectRoot(startDir) {\n const projectMarkers = ['package.json', '.git', 'tasks.json'];\n let currentDir = startDir;\n while (currentDir !== path.parse(currentDir).root) {\n if (projectMarkers.some(marker => fs.existsSync(path.join(currentDir, marker)))) {\n return currentDir;\n }\n currentDir = path.dirname(currentDir);\n }\n return startDir; // Fallback to original directory\n }\n ```\n\n7. **Environment Variable Overrides**:\n - Allow users to explicitly set paths:\n ```javascript\n const projectRoot = process.env.TASK_MASTER_PROJECT_ROOT || resolveProjectRoot(process.cwd());\n ```\n\nBy implementing these advanced techniques, task-master can achieve robust path handling across various npm scenarios without requiring manual specification.\n", - "status": "in-progress", + "status": "done", "dependencies": [], "parentTaskId": 23 }, @@ -1771,6 +1771,24 @@ "status": "pending", "dependencies": [], "parentTaskId": 23 + }, + { + "id": 46, + "title": "adjust rules so it prioritizes mcp commands over script", + "description": "", + "details": "", + "status": "pending", + "dependencies": [], + "parentTaskId": 23 + }, + { + "id": 47, + "title": "adjust rules so it prioritizes mcp commands over script", + "description": "", + "details": "", + "status": "pending", + "dependencies": [], + "parentTaskId": 23 } ] },