This is page 8 of 50. Use http://codebase.md/eyaltoledano/claude-task-master?lines=false&page={x} to view the full context.
# Directory Structure
```
├── .changeset
│ ├── config.json
│ └── README.md
├── .claude
│ ├── commands
│ │ └── dedupe.md
│ └── TM_COMMANDS_GUIDE.md
├── .claude-plugin
│ └── marketplace.json
├── .coderabbit.yaml
├── .cursor
│ ├── mcp.json
│ └── rules
│ ├── ai_providers.mdc
│ ├── ai_services.mdc
│ ├── architecture.mdc
│ ├── changeset.mdc
│ ├── commands.mdc
│ ├── context_gathering.mdc
│ ├── cursor_rules.mdc
│ ├── dependencies.mdc
│ ├── dev_workflow.mdc
│ ├── git_workflow.mdc
│ ├── glossary.mdc
│ ├── mcp.mdc
│ ├── new_features.mdc
│ ├── self_improve.mdc
│ ├── tags.mdc
│ ├── taskmaster.mdc
│ ├── tasks.mdc
│ ├── telemetry.mdc
│ ├── test_workflow.mdc
│ ├── tests.mdc
│ ├── ui.mdc
│ └── utilities.mdc
├── .cursorignore
├── .env.example
├── .github
│ ├── ISSUE_TEMPLATE
│ │ ├── bug_report.md
│ │ ├── enhancements---feature-requests.md
│ │ └── feedback.md
│ ├── PULL_REQUEST_TEMPLATE
│ │ ├── bugfix.md
│ │ ├── config.yml
│ │ ├── feature.md
│ │ └── integration.md
│ ├── PULL_REQUEST_TEMPLATE.md
│ ├── scripts
│ │ ├── auto-close-duplicates.mjs
│ │ ├── backfill-duplicate-comments.mjs
│ │ ├── check-pre-release-mode.mjs
│ │ ├── parse-metrics.mjs
│ │ ├── release.mjs
│ │ ├── tag-extension.mjs
│ │ ├── utils.mjs
│ │ └── validate-changesets.mjs
│ └── workflows
│ ├── auto-close-duplicates.yml
│ ├── backfill-duplicate-comments.yml
│ ├── ci.yml
│ ├── claude-dedupe-issues.yml
│ ├── claude-docs-trigger.yml
│ ├── claude-docs-updater.yml
│ ├── claude-issue-triage.yml
│ ├── claude.yml
│ ├── extension-ci.yml
│ ├── extension-release.yml
│ ├── log-issue-events.yml
│ ├── pre-release.yml
│ ├── release-check.yml
│ ├── release.yml
│ ├── update-models-md.yml
│ └── weekly-metrics-discord.yml
├── .gitignore
├── .kiro
│ ├── hooks
│ │ ├── tm-code-change-task-tracker.kiro.hook
│ │ ├── tm-complexity-analyzer.kiro.hook
│ │ ├── tm-daily-standup-assistant.kiro.hook
│ │ ├── tm-git-commit-task-linker.kiro.hook
│ │ ├── tm-pr-readiness-checker.kiro.hook
│ │ ├── tm-task-dependency-auto-progression.kiro.hook
│ │ └── tm-test-success-task-completer.kiro.hook
│ ├── settings
│ │ └── mcp.json
│ └── steering
│ ├── dev_workflow.md
│ ├── kiro_rules.md
│ ├── self_improve.md
│ ├── taskmaster_hooks_workflow.md
│ └── taskmaster.md
├── .manypkg.json
├── .mcp.json
├── .npmignore
├── .nvmrc
├── .taskmaster
│ ├── CLAUDE.md
│ ├── config.json
│ ├── docs
│ │ ├── autonomous-tdd-git-workflow.md
│ │ ├── MIGRATION-ROADMAP.md
│ │ ├── prd-tm-start.txt
│ │ ├── prd.txt
│ │ ├── README.md
│ │ ├── research
│ │ │ ├── 2025-06-14_how-can-i-improve-the-scope-up-and-scope-down-comm.md
│ │ │ ├── 2025-06-14_should-i-be-using-any-specific-libraries-for-this.md
│ │ │ ├── 2025-06-14_test-save-functionality.md
│ │ │ ├── 2025-06-14_test-the-fix-for-duplicate-saves-final-test.md
│ │ │ └── 2025-08-01_do-we-need-to-add-new-commands-or-can-we-just-weap.md
│ │ ├── task-template-importing-prd.txt
│ │ ├── tdd-workflow-phase-0-spike.md
│ │ ├── tdd-workflow-phase-1-core-rails.md
│ │ ├── tdd-workflow-phase-1-orchestrator.md
│ │ ├── tdd-workflow-phase-2-pr-resumability.md
│ │ ├── tdd-workflow-phase-3-extensibility-guardrails.md
│ │ ├── test-prd.txt
│ │ └── tm-core-phase-1.txt
│ ├── reports
│ │ ├── task-complexity-report_autonomous-tdd-git-workflow.json
│ │ ├── task-complexity-report_cc-kiro-hooks.json
│ │ ├── task-complexity-report_tdd-phase-1-core-rails.json
│ │ ├── task-complexity-report_tdd-workflow-phase-0.json
│ │ ├── task-complexity-report_test-prd-tag.json
│ │ ├── task-complexity-report_tm-core-phase-1.json
│ │ ├── task-complexity-report.json
│ │ └── tm-core-complexity.json
│ ├── state.json
│ ├── tasks
│ │ ├── task_001_tm-start.txt
│ │ ├── task_002_tm-start.txt
│ │ ├── task_003_tm-start.txt
│ │ ├── task_004_tm-start.txt
│ │ ├── task_007_tm-start.txt
│ │ └── tasks.json
│ └── templates
│ ├── example_prd_rpg.md
│ └── example_prd.md
├── .vscode
│ ├── extensions.json
│ └── settings.json
├── apps
│ ├── cli
│ │ ├── CHANGELOG.md
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── command-registry.ts
│ │ │ ├── commands
│ │ │ │ ├── auth.command.ts
│ │ │ │ ├── autopilot
│ │ │ │ │ ├── abort.command.ts
│ │ │ │ │ ├── commit.command.ts
│ │ │ │ │ ├── complete.command.ts
│ │ │ │ │ ├── index.ts
│ │ │ │ │ ├── next.command.ts
│ │ │ │ │ ├── resume.command.ts
│ │ │ │ │ ├── shared.ts
│ │ │ │ │ ├── start.command.ts
│ │ │ │ │ └── status.command.ts
│ │ │ │ ├── briefs.command.ts
│ │ │ │ ├── context.command.ts
│ │ │ │ ├── export.command.ts
│ │ │ │ ├── list.command.ts
│ │ │ │ ├── models
│ │ │ │ │ ├── custom-providers.ts
│ │ │ │ │ ├── fetchers.ts
│ │ │ │ │ ├── index.ts
│ │ │ │ │ ├── prompts.ts
│ │ │ │ │ ├── setup.ts
│ │ │ │ │ └── types.ts
│ │ │ │ ├── next.command.ts
│ │ │ │ ├── set-status.command.ts
│ │ │ │ ├── show.command.ts
│ │ │ │ ├── start.command.ts
│ │ │ │ └── tags.command.ts
│ │ │ ├── index.ts
│ │ │ ├── lib
│ │ │ │ └── model-management.ts
│ │ │ ├── types
│ │ │ │ └── tag-management.d.ts
│ │ │ ├── ui
│ │ │ │ ├── components
│ │ │ │ │ ├── cardBox.component.ts
│ │ │ │ │ ├── dashboard.component.ts
│ │ │ │ │ ├── header.component.ts
│ │ │ │ │ ├── index.ts
│ │ │ │ │ ├── next-task.component.ts
│ │ │ │ │ ├── suggested-steps.component.ts
│ │ │ │ │ └── task-detail.component.ts
│ │ │ │ ├── display
│ │ │ │ │ ├── messages.ts
│ │ │ │ │ └── tables.ts
│ │ │ │ ├── formatters
│ │ │ │ │ ├── complexity-formatters.ts
│ │ │ │ │ ├── dependency-formatters.ts
│ │ │ │ │ ├── priority-formatters.ts
│ │ │ │ │ ├── status-formatters.spec.ts
│ │ │ │ │ └── status-formatters.ts
│ │ │ │ ├── index.ts
│ │ │ │ └── layout
│ │ │ │ ├── helpers.spec.ts
│ │ │ │ └── helpers.ts
│ │ │ └── utils
│ │ │ ├── auth-helpers.ts
│ │ │ ├── auto-update.ts
│ │ │ ├── brief-selection.ts
│ │ │ ├── display-helpers.ts
│ │ │ ├── error-handler.ts
│ │ │ ├── index.ts
│ │ │ ├── project-root.ts
│ │ │ ├── task-status.ts
│ │ │ ├── ui.spec.ts
│ │ │ └── ui.ts
│ │ ├── tests
│ │ │ ├── integration
│ │ │ │ └── commands
│ │ │ │ └── autopilot
│ │ │ │ └── workflow.test.ts
│ │ │ └── unit
│ │ │ ├── commands
│ │ │ │ ├── autopilot
│ │ │ │ │ └── shared.test.ts
│ │ │ │ ├── list.command.spec.ts
│ │ │ │ └── show.command.spec.ts
│ │ │ └── ui
│ │ │ └── dashboard.component.spec.ts
│ │ ├── tsconfig.json
│ │ └── vitest.config.ts
│ ├── docs
│ │ ├── archive
│ │ │ ├── ai-client-utils-example.mdx
│ │ │ ├── ai-development-workflow.mdx
│ │ │ ├── command-reference.mdx
│ │ │ ├── configuration.mdx
│ │ │ ├── cursor-setup.mdx
│ │ │ ├── examples.mdx
│ │ │ └── Installation.mdx
│ │ ├── best-practices
│ │ │ ├── advanced-tasks.mdx
│ │ │ ├── configuration-advanced.mdx
│ │ │ └── index.mdx
│ │ ├── capabilities
│ │ │ ├── cli-root-commands.mdx
│ │ │ ├── index.mdx
│ │ │ ├── mcp.mdx
│ │ │ ├── rpg-method.mdx
│ │ │ └── task-structure.mdx
│ │ ├── CHANGELOG.md
│ │ ├── command-reference.mdx
│ │ ├── configuration.mdx
│ │ ├── docs.json
│ │ ├── favicon.svg
│ │ ├── getting-started
│ │ │ ├── api-keys.mdx
│ │ │ ├── contribute.mdx
│ │ │ ├── faq.mdx
│ │ │ └── quick-start
│ │ │ ├── configuration-quick.mdx
│ │ │ ├── execute-quick.mdx
│ │ │ ├── installation.mdx
│ │ │ ├── moving-forward.mdx
│ │ │ ├── prd-quick.mdx
│ │ │ ├── quick-start.mdx
│ │ │ ├── requirements.mdx
│ │ │ ├── rules-quick.mdx
│ │ │ └── tasks-quick.mdx
│ │ ├── introduction.mdx
│ │ ├── licensing.md
│ │ ├── logo
│ │ │ ├── dark.svg
│ │ │ ├── light.svg
│ │ │ └── task-master-logo.png
│ │ ├── package.json
│ │ ├── README.md
│ │ ├── style.css
│ │ ├── tdd-workflow
│ │ │ ├── ai-agent-integration.mdx
│ │ │ └── quickstart.mdx
│ │ ├── vercel.json
│ │ └── whats-new.mdx
│ ├── extension
│ │ ├── .vscodeignore
│ │ ├── assets
│ │ │ ├── banner.png
│ │ │ ├── icon-dark.svg
│ │ │ ├── icon-light.svg
│ │ │ ├── icon.png
│ │ │ ├── screenshots
│ │ │ │ ├── kanban-board.png
│ │ │ │ └── task-details.png
│ │ │ └── sidebar-icon.svg
│ │ ├── CHANGELOG.md
│ │ ├── components.json
│ │ ├── docs
│ │ │ ├── extension-CI-setup.md
│ │ │ └── extension-development-guide.md
│ │ ├── esbuild.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ ├── package.mjs
│ │ ├── package.publish.json
│ │ ├── README.md
│ │ ├── src
│ │ │ ├── components
│ │ │ │ ├── ConfigView.tsx
│ │ │ │ ├── constants.ts
│ │ │ │ ├── TaskDetails
│ │ │ │ │ ├── AIActionsSection.tsx
│ │ │ │ │ ├── DetailsSection.tsx
│ │ │ │ │ ├── PriorityBadge.tsx
│ │ │ │ │ ├── SubtasksSection.tsx
│ │ │ │ │ ├── TaskMetadataSidebar.tsx
│ │ │ │ │ └── useTaskDetails.ts
│ │ │ │ ├── TaskDetailsView.tsx
│ │ │ │ ├── TaskMasterLogo.tsx
│ │ │ │ └── ui
│ │ │ │ ├── badge.tsx
│ │ │ │ ├── breadcrumb.tsx
│ │ │ │ ├── button.tsx
│ │ │ │ ├── card.tsx
│ │ │ │ ├── collapsible.tsx
│ │ │ │ ├── CollapsibleSection.tsx
│ │ │ │ ├── dropdown-menu.tsx
│ │ │ │ ├── label.tsx
│ │ │ │ ├── scroll-area.tsx
│ │ │ │ ├── separator.tsx
│ │ │ │ ├── shadcn-io
│ │ │ │ │ └── kanban
│ │ │ │ │ └── index.tsx
│ │ │ │ └── textarea.tsx
│ │ │ ├── extension.ts
│ │ │ ├── index.ts
│ │ │ ├── lib
│ │ │ │ └── utils.ts
│ │ │ ├── services
│ │ │ │ ├── config-service.ts
│ │ │ │ ├── error-handler.ts
│ │ │ │ ├── notification-preferences.ts
│ │ │ │ ├── polling-service.ts
│ │ │ │ ├── polling-strategies.ts
│ │ │ │ ├── sidebar-webview-manager.ts
│ │ │ │ ├── task-repository.ts
│ │ │ │ ├── terminal-manager.ts
│ │ │ │ └── webview-manager.ts
│ │ │ ├── test
│ │ │ │ └── extension.test.ts
│ │ │ ├── utils
│ │ │ │ ├── configManager.ts
│ │ │ │ ├── connectionManager.ts
│ │ │ │ ├── errorHandler.ts
│ │ │ │ ├── event-emitter.ts
│ │ │ │ ├── logger.ts
│ │ │ │ ├── mcpClient.ts
│ │ │ │ ├── notificationPreferences.ts
│ │ │ │ └── task-master-api
│ │ │ │ ├── cache
│ │ │ │ │ └── cache-manager.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── mcp-client.ts
│ │ │ │ ├── transformers
│ │ │ │ │ └── task-transformer.ts
│ │ │ │ └── types
│ │ │ │ └── index.ts
│ │ │ └── webview
│ │ │ ├── App.tsx
│ │ │ ├── components
│ │ │ │ ├── AppContent.tsx
│ │ │ │ ├── EmptyState.tsx
│ │ │ │ ├── ErrorBoundary.tsx
│ │ │ │ ├── PollingStatus.tsx
│ │ │ │ ├── PriorityBadge.tsx
│ │ │ │ ├── SidebarView.tsx
│ │ │ │ ├── TagDropdown.tsx
│ │ │ │ ├── TaskCard.tsx
│ │ │ │ ├── TaskEditModal.tsx
│ │ │ │ ├── TaskMasterKanban.tsx
│ │ │ │ ├── ToastContainer.tsx
│ │ │ │ └── ToastNotification.tsx
│ │ │ ├── constants
│ │ │ │ └── index.ts
│ │ │ ├── contexts
│ │ │ │ └── VSCodeContext.tsx
│ │ │ ├── hooks
│ │ │ │ ├── useTaskQueries.ts
│ │ │ │ ├── useVSCodeMessages.ts
│ │ │ │ └── useWebviewHeight.ts
│ │ │ ├── index.css
│ │ │ ├── index.tsx
│ │ │ ├── providers
│ │ │ │ └── QueryProvider.tsx
│ │ │ ├── reducers
│ │ │ │ └── appReducer.ts
│ │ │ ├── sidebar.tsx
│ │ │ ├── types
│ │ │ │ └── index.ts
│ │ │ └── utils
│ │ │ ├── logger.ts
│ │ │ └── toast.ts
│ │ └── tsconfig.json
│ └── mcp
│ ├── CHANGELOG.md
│ ├── package.json
│ ├── src
│ │ ├── index.ts
│ │ ├── shared
│ │ │ ├── types.ts
│ │ │ └── utils.ts
│ │ └── tools
│ │ ├── autopilot
│ │ │ ├── abort.tool.ts
│ │ │ ├── commit.tool.ts
│ │ │ ├── complete.tool.ts
│ │ │ ├── finalize.tool.ts
│ │ │ ├── index.ts
│ │ │ ├── next.tool.ts
│ │ │ ├── resume.tool.ts
│ │ │ ├── start.tool.ts
│ │ │ └── status.tool.ts
│ │ ├── README-ZOD-V3.md
│ │ └── tasks
│ │ ├── get-task.tool.ts
│ │ ├── get-tasks.tool.ts
│ │ └── index.ts
│ ├── tsconfig.json
│ └── vitest.config.ts
├── assets
│ ├── .windsurfrules
│ ├── AGENTS.md
│ ├── claude
│ │ └── TM_COMMANDS_GUIDE.md
│ ├── config.json
│ ├── env.example
│ ├── example_prd_rpg.txt
│ ├── example_prd.txt
│ ├── GEMINI.md
│ ├── gitignore
│ ├── kiro-hooks
│ │ ├── tm-code-change-task-tracker.kiro.hook
│ │ ├── tm-complexity-analyzer.kiro.hook
│ │ ├── tm-daily-standup-assistant.kiro.hook
│ │ ├── tm-git-commit-task-linker.kiro.hook
│ │ ├── tm-pr-readiness-checker.kiro.hook
│ │ ├── tm-task-dependency-auto-progression.kiro.hook
│ │ └── tm-test-success-task-completer.kiro.hook
│ ├── roocode
│ │ ├── .roo
│ │ │ ├── rules-architect
│ │ │ │ └── architect-rules
│ │ │ ├── rules-ask
│ │ │ │ └── ask-rules
│ │ │ ├── rules-code
│ │ │ │ └── code-rules
│ │ │ ├── rules-debug
│ │ │ │ └── debug-rules
│ │ │ ├── rules-orchestrator
│ │ │ │ └── orchestrator-rules
│ │ │ └── rules-test
│ │ │ └── test-rules
│ │ └── .roomodes
│ ├── rules
│ │ ├── cursor_rules.mdc
│ │ ├── dev_workflow.mdc
│ │ ├── self_improve.mdc
│ │ ├── taskmaster_hooks_workflow.mdc
│ │ └── taskmaster.mdc
│ └── scripts_README.md
├── bin
│ └── task-master.js
├── biome.json
├── CHANGELOG.md
├── CLAUDE_CODE_PLUGIN.md
├── CLAUDE.md
├── context
│ ├── chats
│ │ ├── add-task-dependencies-1.md
│ │ └── max-min-tokens.txt.md
│ ├── fastmcp-core.txt
│ ├── fastmcp-docs.txt
│ ├── MCP_INTEGRATION.md
│ ├── mcp-js-sdk-docs.txt
│ ├── mcp-protocol-repo.txt
│ ├── mcp-protocol-schema-03262025.json
│ └── mcp-protocol-spec.txt
├── CONTRIBUTING.md
├── docs
│ ├── claude-code-integration.md
│ ├── CLI-COMMANDER-PATTERN.md
│ ├── command-reference.md
│ ├── configuration.md
│ ├── contributor-docs
│ │ ├── testing-roo-integration.md
│ │ └── worktree-setup.md
│ ├── cross-tag-task-movement.md
│ ├── examples
│ │ ├── claude-code-usage.md
│ │ └── codex-cli-usage.md
│ ├── examples.md
│ ├── licensing.md
│ ├── mcp-provider-guide.md
│ ├── mcp-provider.md
│ ├── migration-guide.md
│ ├── models.md
│ ├── providers
│ │ ├── codex-cli.md
│ │ └── gemini-cli.md
│ ├── README.md
│ ├── scripts
│ │ └── models-json-to-markdown.js
│ ├── task-structure.md
│ └── tutorial.md
├── images
│ ├── hamster-hiring.png
│ └── logo.png
├── index.js
├── jest.config.js
├── jest.resolver.cjs
├── LICENSE
├── llms-install.md
├── mcp-server
│ ├── server.js
│ └── src
│ ├── core
│ │ ├── __tests__
│ │ │ └── context-manager.test.js
│ │ ├── context-manager.js
│ │ ├── direct-functions
│ │ │ ├── add-dependency.js
│ │ │ ├── add-subtask.js
│ │ │ ├── add-tag.js
│ │ │ ├── add-task.js
│ │ │ ├── analyze-task-complexity.js
│ │ │ ├── cache-stats.js
│ │ │ ├── clear-subtasks.js
│ │ │ ├── complexity-report.js
│ │ │ ├── copy-tag.js
│ │ │ ├── create-tag-from-branch.js
│ │ │ ├── delete-tag.js
│ │ │ ├── expand-all-tasks.js
│ │ │ ├── expand-task.js
│ │ │ ├── fix-dependencies.js
│ │ │ ├── generate-task-files.js
│ │ │ ├── initialize-project.js
│ │ │ ├── list-tags.js
│ │ │ ├── models.js
│ │ │ ├── move-task-cross-tag.js
│ │ │ ├── move-task.js
│ │ │ ├── next-task.js
│ │ │ ├── parse-prd.js
│ │ │ ├── remove-dependency.js
│ │ │ ├── remove-subtask.js
│ │ │ ├── remove-task.js
│ │ │ ├── rename-tag.js
│ │ │ ├── research.js
│ │ │ ├── response-language.js
│ │ │ ├── rules.js
│ │ │ ├── scope-down.js
│ │ │ ├── scope-up.js
│ │ │ ├── set-task-status.js
│ │ │ ├── update-subtask-by-id.js
│ │ │ ├── update-task-by-id.js
│ │ │ ├── update-tasks.js
│ │ │ ├── use-tag.js
│ │ │ └── validate-dependencies.js
│ │ ├── task-master-core.js
│ │ └── utils
│ │ ├── env-utils.js
│ │ └── path-utils.js
│ ├── custom-sdk
│ │ ├── errors.js
│ │ ├── index.js
│ │ ├── json-extractor.js
│ │ ├── language-model.js
│ │ ├── message-converter.js
│ │ └── schema-converter.js
│ ├── index.js
│ ├── logger.js
│ ├── providers
│ │ └── mcp-provider.js
│ └── tools
│ ├── add-dependency.js
│ ├── add-subtask.js
│ ├── add-tag.js
│ ├── add-task.js
│ ├── analyze.js
│ ├── clear-subtasks.js
│ ├── complexity-report.js
│ ├── copy-tag.js
│ ├── delete-tag.js
│ ├── expand-all.js
│ ├── expand-task.js
│ ├── fix-dependencies.js
│ ├── generate.js
│ ├── get-operation-status.js
│ ├── index.js
│ ├── initialize-project.js
│ ├── list-tags.js
│ ├── models.js
│ ├── move-task.js
│ ├── next-task.js
│ ├── parse-prd.js
│ ├── README-ZOD-V3.md
│ ├── remove-dependency.js
│ ├── remove-subtask.js
│ ├── remove-task.js
│ ├── rename-tag.js
│ ├── research.js
│ ├── response-language.js
│ ├── rules.js
│ ├── scope-down.js
│ ├── scope-up.js
│ ├── set-task-status.js
│ ├── tool-registry.js
│ ├── update-subtask.js
│ ├── update-task.js
│ ├── update.js
│ ├── use-tag.js
│ ├── utils.js
│ └── validate-dependencies.js
├── mcp-test.js
├── output.json
├── package-lock.json
├── package.json
├── packages
│ ├── ai-sdk-provider-grok-cli
│ │ ├── CHANGELOG.md
│ │ ├── package.json
│ │ ├── README.md
│ │ ├── src
│ │ │ ├── errors.test.ts
│ │ │ ├── errors.ts
│ │ │ ├── grok-cli-language-model.ts
│ │ │ ├── grok-cli-provider.test.ts
│ │ │ ├── grok-cli-provider.ts
│ │ │ ├── index.ts
│ │ │ ├── json-extractor.test.ts
│ │ │ ├── json-extractor.ts
│ │ │ ├── message-converter.test.ts
│ │ │ ├── message-converter.ts
│ │ │ └── types.ts
│ │ └── tsconfig.json
│ ├── build-config
│ │ ├── CHANGELOG.md
│ │ ├── package.json
│ │ ├── src
│ │ │ └── tsdown.base.ts
│ │ └── tsconfig.json
│ ├── claude-code-plugin
│ │ ├── .claude-plugin
│ │ │ └── plugin.json
│ │ ├── .gitignore
│ │ ├── agents
│ │ │ ├── task-checker.md
│ │ │ ├── task-executor.md
│ │ │ └── task-orchestrator.md
│ │ ├── CHANGELOG.md
│ │ ├── commands
│ │ │ ├── add-dependency.md
│ │ │ ├── add-subtask.md
│ │ │ ├── add-task.md
│ │ │ ├── analyze-complexity.md
│ │ │ ├── analyze-project.md
│ │ │ ├── auto-implement-tasks.md
│ │ │ ├── command-pipeline.md
│ │ │ ├── complexity-report.md
│ │ │ ├── convert-task-to-subtask.md
│ │ │ ├── expand-all-tasks.md
│ │ │ ├── expand-task.md
│ │ │ ├── fix-dependencies.md
│ │ │ ├── generate-tasks.md
│ │ │ ├── help.md
│ │ │ ├── init-project-quick.md
│ │ │ ├── init-project.md
│ │ │ ├── install-taskmaster.md
│ │ │ ├── learn.md
│ │ │ ├── list-tasks-by-status.md
│ │ │ ├── list-tasks-with-subtasks.md
│ │ │ ├── list-tasks.md
│ │ │ ├── next-task.md
│ │ │ ├── parse-prd-with-research.md
│ │ │ ├── parse-prd.md
│ │ │ ├── project-status.md
│ │ │ ├── quick-install-taskmaster.md
│ │ │ ├── remove-all-subtasks.md
│ │ │ ├── remove-dependency.md
│ │ │ ├── remove-subtask.md
│ │ │ ├── remove-subtasks.md
│ │ │ ├── remove-task.md
│ │ │ ├── setup-models.md
│ │ │ ├── show-task.md
│ │ │ ├── smart-workflow.md
│ │ │ ├── sync-readme.md
│ │ │ ├── tm-main.md
│ │ │ ├── to-cancelled.md
│ │ │ ├── to-deferred.md
│ │ │ ├── to-done.md
│ │ │ ├── to-in-progress.md
│ │ │ ├── to-pending.md
│ │ │ ├── to-review.md
│ │ │ ├── update-single-task.md
│ │ │ ├── update-task.md
│ │ │ ├── update-tasks-from-id.md
│ │ │ ├── validate-dependencies.md
│ │ │ └── view-models.md
│ │ ├── mcp.json
│ │ └── package.json
│ ├── tm-bridge
│ │ ├── CHANGELOG.md
│ │ ├── package.json
│ │ ├── README.md
│ │ ├── src
│ │ │ ├── add-tag-bridge.ts
│ │ │ ├── bridge-types.ts
│ │ │ ├── bridge-utils.ts
│ │ │ ├── expand-bridge.ts
│ │ │ ├── index.ts
│ │ │ ├── tags-bridge.ts
│ │ │ ├── update-bridge.ts
│ │ │ └── use-tag-bridge.ts
│ │ └── tsconfig.json
│ └── tm-core
│ ├── .gitignore
│ ├── CHANGELOG.md
│ ├── docs
│ │ └── listTasks-architecture.md
│ ├── package.json
│ ├── POC-STATUS.md
│ ├── README.md
│ ├── src
│ │ ├── common
│ │ │ ├── constants
│ │ │ │ ├── index.ts
│ │ │ │ ├── paths.ts
│ │ │ │ └── providers.ts
│ │ │ ├── errors
│ │ │ │ ├── index.ts
│ │ │ │ └── task-master-error.ts
│ │ │ ├── interfaces
│ │ │ │ ├── configuration.interface.ts
│ │ │ │ ├── index.ts
│ │ │ │ └── storage.interface.ts
│ │ │ ├── logger
│ │ │ │ ├── factory.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── logger.spec.ts
│ │ │ │ └── logger.ts
│ │ │ ├── mappers
│ │ │ │ ├── TaskMapper.test.ts
│ │ │ │ └── TaskMapper.ts
│ │ │ ├── types
│ │ │ │ ├── database.types.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── legacy.ts
│ │ │ │ └── repository-types.ts
│ │ │ └── utils
│ │ │ ├── git-utils.ts
│ │ │ ├── id-generator.ts
│ │ │ ├── index.ts
│ │ │ ├── path-helpers.ts
│ │ │ ├── path-normalizer.spec.ts
│ │ │ ├── path-normalizer.ts
│ │ │ ├── project-root-finder.spec.ts
│ │ │ ├── project-root-finder.ts
│ │ │ ├── run-id-generator.spec.ts
│ │ │ └── run-id-generator.ts
│ │ ├── index.ts
│ │ ├── modules
│ │ │ ├── ai
│ │ │ │ ├── index.ts
│ │ │ │ ├── interfaces
│ │ │ │ │ └── ai-provider.interface.ts
│ │ │ │ └── providers
│ │ │ │ ├── base-provider.ts
│ │ │ │ └── index.ts
│ │ │ ├── auth
│ │ │ │ ├── auth-domain.spec.ts
│ │ │ │ ├── auth-domain.ts
│ │ │ │ ├── config.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── managers
│ │ │ │ │ ├── auth-manager.spec.ts
│ │ │ │ │ └── auth-manager.ts
│ │ │ │ ├── services
│ │ │ │ │ ├── context-store.ts
│ │ │ │ │ ├── oauth-service.ts
│ │ │ │ │ ├── organization.service.ts
│ │ │ │ │ ├── supabase-session-storage.spec.ts
│ │ │ │ │ └── supabase-session-storage.ts
│ │ │ │ └── types.ts
│ │ │ ├── briefs
│ │ │ │ ├── briefs-domain.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── services
│ │ │ │ │ └── brief-service.ts
│ │ │ │ ├── types.ts
│ │ │ │ └── utils
│ │ │ │ └── url-parser.ts
│ │ │ ├── commands
│ │ │ │ └── index.ts
│ │ │ ├── config
│ │ │ │ ├── config-domain.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── managers
│ │ │ │ │ ├── config-manager.spec.ts
│ │ │ │ │ └── config-manager.ts
│ │ │ │ └── services
│ │ │ │ ├── config-loader.service.spec.ts
│ │ │ │ ├── config-loader.service.ts
│ │ │ │ ├── config-merger.service.spec.ts
│ │ │ │ ├── config-merger.service.ts
│ │ │ │ ├── config-persistence.service.spec.ts
│ │ │ │ ├── config-persistence.service.ts
│ │ │ │ ├── environment-config-provider.service.spec.ts
│ │ │ │ ├── environment-config-provider.service.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── runtime-state-manager.service.spec.ts
│ │ │ │ └── runtime-state-manager.service.ts
│ │ │ ├── dependencies
│ │ │ │ └── index.ts
│ │ │ ├── execution
│ │ │ │ ├── executors
│ │ │ │ │ ├── base-executor.ts
│ │ │ │ │ ├── claude-executor.ts
│ │ │ │ │ └── executor-factory.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── services
│ │ │ │ │ └── executor-service.ts
│ │ │ │ └── types.ts
│ │ │ ├── git
│ │ │ │ ├── adapters
│ │ │ │ │ ├── git-adapter.test.ts
│ │ │ │ │ └── git-adapter.ts
│ │ │ │ ├── git-domain.ts
│ │ │ │ ├── index.ts
│ │ │ │ └── services
│ │ │ │ ├── branch-name-generator.spec.ts
│ │ │ │ ├── branch-name-generator.ts
│ │ │ │ ├── commit-message-generator.test.ts
│ │ │ │ ├── commit-message-generator.ts
│ │ │ │ ├── scope-detector.test.ts
│ │ │ │ ├── scope-detector.ts
│ │ │ │ ├── template-engine.test.ts
│ │ │ │ └── template-engine.ts
│ │ │ ├── integration
│ │ │ │ ├── clients
│ │ │ │ │ ├── index.ts
│ │ │ │ │ └── supabase-client.ts
│ │ │ │ ├── integration-domain.ts
│ │ │ │ └── services
│ │ │ │ ├── export.service.ts
│ │ │ │ ├── task-expansion.service.ts
│ │ │ │ └── task-retrieval.service.ts
│ │ │ ├── reports
│ │ │ │ ├── index.ts
│ │ │ │ ├── managers
│ │ │ │ │ └── complexity-report-manager.ts
│ │ │ │ └── types.ts
│ │ │ ├── storage
│ │ │ │ ├── adapters
│ │ │ │ │ ├── activity-logger.ts
│ │ │ │ │ ├── api-storage.ts
│ │ │ │ │ └── file-storage
│ │ │ │ │ ├── file-operations.ts
│ │ │ │ │ ├── file-storage.ts
│ │ │ │ │ ├── format-handler.ts
│ │ │ │ │ ├── index.ts
│ │ │ │ │ └── path-resolver.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── services
│ │ │ │ │ └── storage-factory.ts
│ │ │ │ └── utils
│ │ │ │ └── api-client.ts
│ │ │ ├── tasks
│ │ │ │ ├── entities
│ │ │ │ │ └── task.entity.ts
│ │ │ │ ├── parser
│ │ │ │ │ └── index.ts
│ │ │ │ ├── repositories
│ │ │ │ │ ├── supabase
│ │ │ │ │ │ ├── dependency-fetcher.ts
│ │ │ │ │ │ ├── index.ts
│ │ │ │ │ │ └── supabase-repository.ts
│ │ │ │ │ └── task-repository.interface.ts
│ │ │ │ ├── services
│ │ │ │ │ ├── preflight-checker.service.ts
│ │ │ │ │ ├── tag.service.ts
│ │ │ │ │ ├── task-execution-service.ts
│ │ │ │ │ ├── task-loader.service.ts
│ │ │ │ │ └── task-service.ts
│ │ │ │ └── tasks-domain.ts
│ │ │ ├── ui
│ │ │ │ └── index.ts
│ │ │ └── workflow
│ │ │ ├── managers
│ │ │ │ ├── workflow-state-manager.spec.ts
│ │ │ │ └── workflow-state-manager.ts
│ │ │ ├── orchestrators
│ │ │ │ ├── workflow-orchestrator.test.ts
│ │ │ │ └── workflow-orchestrator.ts
│ │ │ ├── services
│ │ │ │ ├── test-result-validator.test.ts
│ │ │ │ ├── test-result-validator.ts
│ │ │ │ ├── test-result-validator.types.ts
│ │ │ │ ├── workflow-activity-logger.ts
│ │ │ │ └── workflow.service.ts
│ │ │ ├── types.ts
│ │ │ └── workflow-domain.ts
│ │ ├── subpath-exports.test.ts
│ │ ├── tm-core.ts
│ │ └── utils
│ │ └── time.utils.ts
│ ├── tests
│ │ ├── auth
│ │ │ └── auth-refresh.test.ts
│ │ ├── integration
│ │ │ ├── auth-token-refresh.test.ts
│ │ │ ├── list-tasks.test.ts
│ │ │ └── storage
│ │ │ └── activity-logger.test.ts
│ │ ├── mocks
│ │ │ └── mock-provider.ts
│ │ ├── setup.ts
│ │ └── unit
│ │ ├── base-provider.test.ts
│ │ ├── executor.test.ts
│ │ └── smoke.test.ts
│ ├── tsconfig.json
│ └── vitest.config.ts
├── README-task-master.md
├── README.md
├── scripts
│ ├── create-worktree.sh
│ ├── dev.js
│ ├── init.js
│ ├── list-worktrees.sh
│ ├── modules
│ │ ├── ai-services-unified.js
│ │ ├── bridge-utils.js
│ │ ├── commands.js
│ │ ├── config-manager.js
│ │ ├── dependency-manager.js
│ │ ├── index.js
│ │ ├── prompt-manager.js
│ │ ├── supported-models.json
│ │ ├── sync-readme.js
│ │ ├── task-manager
│ │ │ ├── add-subtask.js
│ │ │ ├── add-task.js
│ │ │ ├── analyze-task-complexity.js
│ │ │ ├── clear-subtasks.js
│ │ │ ├── expand-all-tasks.js
│ │ │ ├── expand-task.js
│ │ │ ├── find-next-task.js
│ │ │ ├── generate-task-files.js
│ │ │ ├── is-task-dependent.js
│ │ │ ├── list-tasks.js
│ │ │ ├── migrate.js
│ │ │ ├── models.js
│ │ │ ├── move-task.js
│ │ │ ├── parse-prd
│ │ │ │ ├── index.js
│ │ │ │ ├── parse-prd-config.js
│ │ │ │ ├── parse-prd-helpers.js
│ │ │ │ ├── parse-prd-non-streaming.js
│ │ │ │ ├── parse-prd-streaming.js
│ │ │ │ └── parse-prd.js
│ │ │ ├── remove-subtask.js
│ │ │ ├── remove-task.js
│ │ │ ├── research.js
│ │ │ ├── response-language.js
│ │ │ ├── scope-adjustment.js
│ │ │ ├── set-task-status.js
│ │ │ ├── tag-management.js
│ │ │ ├── task-exists.js
│ │ │ ├── update-single-task-status.js
│ │ │ ├── update-subtask-by-id.js
│ │ │ ├── update-task-by-id.js
│ │ │ └── update-tasks.js
│ │ ├── task-manager.js
│ │ ├── ui.js
│ │ ├── update-config-tokens.js
│ │ ├── utils
│ │ │ ├── contextGatherer.js
│ │ │ ├── fuzzyTaskSearch.js
│ │ │ └── git-utils.js
│ │ └── utils.js
│ ├── task-complexity-report.json
│ ├── test-claude-errors.js
│ └── test-claude.js
├── sonar-project.properties
├── src
│ ├── ai-providers
│ │ ├── anthropic.js
│ │ ├── azure.js
│ │ ├── base-provider.js
│ │ ├── bedrock.js
│ │ ├── claude-code.js
│ │ ├── codex-cli.js
│ │ ├── gemini-cli.js
│ │ ├── google-vertex.js
│ │ ├── google.js
│ │ ├── grok-cli.js
│ │ ├── groq.js
│ │ ├── index.js
│ │ ├── lmstudio.js
│ │ ├── ollama.js
│ │ ├── openai-compatible.js
│ │ ├── openai.js
│ │ ├── openrouter.js
│ │ ├── perplexity.js
│ │ ├── xai.js
│ │ ├── zai-coding.js
│ │ └── zai.js
│ ├── constants
│ │ ├── commands.js
│ │ ├── paths.js
│ │ ├── profiles.js
│ │ ├── rules-actions.js
│ │ ├── task-priority.js
│ │ └── task-status.js
│ ├── profiles
│ │ ├── amp.js
│ │ ├── base-profile.js
│ │ ├── claude.js
│ │ ├── cline.js
│ │ ├── codex.js
│ │ ├── cursor.js
│ │ ├── gemini.js
│ │ ├── index.js
│ │ ├── kilo.js
│ │ ├── kiro.js
│ │ ├── opencode.js
│ │ ├── roo.js
│ │ ├── trae.js
│ │ ├── vscode.js
│ │ ├── windsurf.js
│ │ └── zed.js
│ ├── progress
│ │ ├── base-progress-tracker.js
│ │ ├── cli-progress-factory.js
│ │ ├── parse-prd-tracker.js
│ │ ├── progress-tracker-builder.js
│ │ └── tracker-ui.js
│ ├── prompts
│ │ ├── add-task.json
│ │ ├── analyze-complexity.json
│ │ ├── expand-task.json
│ │ ├── parse-prd.json
│ │ ├── README.md
│ │ ├── research.json
│ │ ├── schemas
│ │ │ ├── parameter.schema.json
│ │ │ ├── prompt-template.schema.json
│ │ │ ├── README.md
│ │ │ └── variant.schema.json
│ │ ├── update-subtask.json
│ │ ├── update-task.json
│ │ └── update-tasks.json
│ ├── provider-registry
│ │ └── index.js
│ ├── schemas
│ │ ├── add-task.js
│ │ ├── analyze-complexity.js
│ │ ├── base-schemas.js
│ │ ├── expand-task.js
│ │ ├── parse-prd.js
│ │ ├── registry.js
│ │ ├── update-subtask.js
│ │ ├── update-task.js
│ │ └── update-tasks.js
│ ├── task-master.js
│ ├── ui
│ │ ├── confirm.js
│ │ ├── indicators.js
│ │ └── parse-prd.js
│ └── utils
│ ├── asset-resolver.js
│ ├── create-mcp-config.js
│ ├── format.js
│ ├── getVersion.js
│ ├── logger-utils.js
│ ├── manage-gitignore.js
│ ├── path-utils.js
│ ├── profiles.js
│ ├── rule-transformer.js
│ ├── stream-parser.js
│ └── timeout-manager.js
├── test-clean-tags.js
├── test-config-manager.js
├── test-prd.txt
├── test-tag-functions.js
├── test-version-check-full.js
├── test-version-check.js
├── tests
│ ├── e2e
│ │ ├── e2e_helpers.sh
│ │ ├── parse_llm_output.cjs
│ │ ├── run_e2e.sh
│ │ ├── run_fallback_verification.sh
│ │ └── test_llm_analysis.sh
│ ├── fixtures
│ │ ├── .taskmasterconfig
│ │ ├── sample-claude-response.js
│ │ ├── sample-prd.txt
│ │ └── sample-tasks.js
│ ├── helpers
│ │ └── tool-counts.js
│ ├── integration
│ │ ├── claude-code-error-handling.test.js
│ │ ├── claude-code-optional.test.js
│ │ ├── cli
│ │ │ ├── commands.test.js
│ │ │ ├── complex-cross-tag-scenarios.test.js
│ │ │ └── move-cross-tag.test.js
│ │ ├── manage-gitignore.test.js
│ │ ├── mcp-server
│ │ │ └── direct-functions.test.js
│ │ ├── move-task-cross-tag.integration.test.js
│ │ ├── move-task-simple.integration.test.js
│ │ ├── profiles
│ │ │ ├── amp-init-functionality.test.js
│ │ │ ├── claude-init-functionality.test.js
│ │ │ ├── cline-init-functionality.test.js
│ │ │ ├── codex-init-functionality.test.js
│ │ │ ├── cursor-init-functionality.test.js
│ │ │ ├── gemini-init-functionality.test.js
│ │ │ ├── opencode-init-functionality.test.js
│ │ │ ├── roo-files-inclusion.test.js
│ │ │ ├── roo-init-functionality.test.js
│ │ │ ├── rules-files-inclusion.test.js
│ │ │ ├── trae-init-functionality.test.js
│ │ │ ├── vscode-init-functionality.test.js
│ │ │ └── windsurf-init-functionality.test.js
│ │ └── providers
│ │ └── temperature-support.test.js
│ ├── manual
│ │ ├── progress
│ │ │ ├── parse-prd-analysis.js
│ │ │ ├── test-parse-prd.js
│ │ │ └── TESTING_GUIDE.md
│ │ └── prompts
│ │ ├── prompt-test.js
│ │ └── README.md
│ ├── README.md
│ ├── setup.js
│ └── unit
│ ├── ai-providers
│ │ ├── base-provider.test.js
│ │ ├── claude-code.test.js
│ │ ├── codex-cli.test.js
│ │ ├── gemini-cli.test.js
│ │ ├── lmstudio.test.js
│ │ ├── mcp-components.test.js
│ │ ├── openai-compatible.test.js
│ │ ├── openai.test.js
│ │ ├── provider-registry.test.js
│ │ ├── zai-coding.test.js
│ │ ├── zai-provider.test.js
│ │ ├── zai-schema-introspection.test.js
│ │ └── zai.test.js
│ ├── ai-services-unified.test.js
│ ├── commands.test.js
│ ├── config-manager.test.js
│ ├── config-manager.test.mjs
│ ├── dependency-manager.test.js
│ ├── init.test.js
│ ├── initialize-project.test.js
│ ├── kebab-case-validation.test.js
│ ├── manage-gitignore.test.js
│ ├── mcp
│ │ └── tools
│ │ ├── __mocks__
│ │ │ └── move-task.js
│ │ ├── add-task.test.js
│ │ ├── analyze-complexity.test.js
│ │ ├── expand-all.test.js
│ │ ├── get-tasks.test.js
│ │ ├── initialize-project.test.js
│ │ ├── move-task-cross-tag-options.test.js
│ │ ├── move-task-cross-tag.test.js
│ │ ├── remove-task.test.js
│ │ └── tool-registration.test.js
│ ├── mcp-providers
│ │ ├── mcp-components.test.js
│ │ └── mcp-provider.test.js
│ ├── parse-prd.test.js
│ ├── profiles
│ │ ├── amp-integration.test.js
│ │ ├── claude-integration.test.js
│ │ ├── cline-integration.test.js
│ │ ├── codex-integration.test.js
│ │ ├── cursor-integration.test.js
│ │ ├── gemini-integration.test.js
│ │ ├── kilo-integration.test.js
│ │ ├── kiro-integration.test.js
│ │ ├── mcp-config-validation.test.js
│ │ ├── opencode-integration.test.js
│ │ ├── profile-safety-check.test.js
│ │ ├── roo-integration.test.js
│ │ ├── rule-transformer-cline.test.js
│ │ ├── rule-transformer-cursor.test.js
│ │ ├── rule-transformer-gemini.test.js
│ │ ├── rule-transformer-kilo.test.js
│ │ ├── rule-transformer-kiro.test.js
│ │ ├── rule-transformer-opencode.test.js
│ │ ├── rule-transformer-roo.test.js
│ │ ├── rule-transformer-trae.test.js
│ │ ├── rule-transformer-vscode.test.js
│ │ ├── rule-transformer-windsurf.test.js
│ │ ├── rule-transformer-zed.test.js
│ │ ├── rule-transformer.test.js
│ │ ├── selective-profile-removal.test.js
│ │ ├── subdirectory-support.test.js
│ │ ├── trae-integration.test.js
│ │ ├── vscode-integration.test.js
│ │ ├── windsurf-integration.test.js
│ │ └── zed-integration.test.js
│ ├── progress
│ │ └── base-progress-tracker.test.js
│ ├── prompt-manager.test.js
│ ├── prompts
│ │ ├── expand-task-prompt.test.js
│ │ └── prompt-migration.test.js
│ ├── scripts
│ │ └── modules
│ │ ├── commands
│ │ │ ├── move-cross-tag.test.js
│ │ │ └── README.md
│ │ ├── dependency-manager
│ │ │ ├── circular-dependencies.test.js
│ │ │ ├── cross-tag-dependencies.test.js
│ │ │ └── fix-dependencies-command.test.js
│ │ ├── task-manager
│ │ │ ├── add-subtask.test.js
│ │ │ ├── add-task.test.js
│ │ │ ├── analyze-task-complexity.test.js
│ │ │ ├── clear-subtasks.test.js
│ │ │ ├── complexity-report-tag-isolation.test.js
│ │ │ ├── expand-all-tasks.test.js
│ │ │ ├── expand-task.test.js
│ │ │ ├── find-next-task.test.js
│ │ │ ├── generate-task-files.test.js
│ │ │ ├── list-tasks.test.js
│ │ │ ├── models-baseurl.test.js
│ │ │ ├── move-task-cross-tag.test.js
│ │ │ ├── move-task.test.js
│ │ │ ├── parse-prd-schema.test.js
│ │ │ ├── parse-prd.test.js
│ │ │ ├── remove-subtask.test.js
│ │ │ ├── remove-task.test.js
│ │ │ ├── research.test.js
│ │ │ ├── scope-adjustment.test.js
│ │ │ ├── set-task-status.test.js
│ │ │ ├── setup.js
│ │ │ ├── update-single-task-status.test.js
│ │ │ ├── update-subtask-by-id.test.js
│ │ │ ├── update-task-by-id.test.js
│ │ │ └── update-tasks.test.js
│ │ ├── ui
│ │ │ └── cross-tag-error-display.test.js
│ │ └── utils-tag-aware-paths.test.js
│ ├── task-finder.test.js
│ ├── task-manager
│ │ ├── clear-subtasks.test.js
│ │ ├── move-task.test.js
│ │ ├── tag-boundary.test.js
│ │ └── tag-management.test.js
│ ├── task-master.test.js
│ ├── ui
│ │ └── indicators.test.js
│ ├── ui.test.js
│ ├── utils-strip-ansi.test.js
│ └── utils.test.js
├── tsconfig.json
├── tsdown.config.ts
├── turbo.json
└── update-task-migration-plan.md
```
# Files
--------------------------------------------------------------------------------
/packages/ai-sdk-provider-grok-cli/src/grok-cli-provider.test.ts:
--------------------------------------------------------------------------------
```typescript
/**
* Tests for Grok CLI provider
*/
import { NoSuchModelError } from '@ai-sdk/provider';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { GrokCliLanguageModel } from './grok-cli-language-model.js';
import { createGrokCli, grokCli } from './grok-cli-provider.js';
// Mock the GrokCliLanguageModel
vi.mock('./grok-cli-language-model.js', () => ({
GrokCliLanguageModel: vi.fn().mockImplementation((options) => ({
modelId: options.id,
settings: options.settings,
provider: 'grok-cli'
}))
}));
describe('createGrokCli', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('should create a provider with default settings', () => {
const provider = createGrokCli();
expect(typeof provider).toBe('function');
expect(typeof provider.languageModel).toBe('function');
expect(typeof provider.chat).toBe('function');
expect(typeof provider.textEmbeddingModel).toBe('function');
expect(typeof provider.imageModel).toBe('function');
});
it('should create a provider with custom default settings', () => {
const defaultSettings = {
timeout: 5000,
workingDirectory: '/custom/path'
};
const provider = createGrokCli({ defaultSettings });
const model = provider('grok-2-mini');
expect(GrokCliLanguageModel).toHaveBeenCalledWith({
id: 'grok-2-mini',
settings: defaultSettings
});
});
it('should create language models with merged settings', () => {
const defaultSettings = { timeout: 5000 };
const provider = createGrokCli({ defaultSettings });
const modelSettings = { apiKey: 'test-key' };
const model = provider('grok-2', modelSettings);
expect(GrokCliLanguageModel).toHaveBeenCalledWith({
id: 'grok-2',
settings: { timeout: 5000, apiKey: 'test-key' }
});
});
it('should create models via languageModel method', () => {
const provider = createGrokCli();
const model = provider.languageModel('grok-2-mini', { timeout: 1000 });
expect(GrokCliLanguageModel).toHaveBeenCalledWith({
id: 'grok-2-mini',
settings: { timeout: 1000 }
});
});
it('should create models via chat method (alias)', () => {
const provider = createGrokCli();
const model = provider.chat('grok-2');
expect(GrokCliLanguageModel).toHaveBeenCalledWith({
id: 'grok-2',
settings: {}
});
});
it('should throw error when called with new keyword', () => {
const provider = createGrokCli();
expect(() => {
// @ts-expect-error - intentionally testing invalid usage
new provider('grok-2');
}).toThrow(
'The Grok CLI model function cannot be called with the new keyword.'
);
});
it('should throw NoSuchModelError for textEmbeddingModel', () => {
const provider = createGrokCli();
expect(() => {
provider.textEmbeddingModel('test-model');
}).toThrow(NoSuchModelError);
});
it('should throw NoSuchModelError for imageModel', () => {
const provider = createGrokCli();
expect(() => {
provider.imageModel('test-model');
}).toThrow(NoSuchModelError);
});
});
describe('default grokCli provider', () => {
it('should be a pre-configured provider instance', () => {
expect(typeof grokCli).toBe('function');
expect(typeof grokCli.languageModel).toBe('function');
expect(typeof grokCli.chat).toBe('function');
});
it('should create models with default configuration', () => {
const model = grokCli('grok-2-mini');
expect(GrokCliLanguageModel).toHaveBeenCalledWith({
id: 'grok-2-mini',
settings: {}
});
});
});
```
--------------------------------------------------------------------------------
/tests/unit/profiles/opencode-integration.test.js:
--------------------------------------------------------------------------------
```javascript
import { jest } from '@jest/globals';
import fs from 'fs';
import path from 'path';
import os from 'os';
describe('OpenCode Profile Integration', () => {
let tempDir;
beforeEach(() => {
jest.clearAllMocks();
// Create a temporary directory for testing
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'task-master-test-'));
// Spy on fs methods
jest.spyOn(fs, 'writeFileSync').mockImplementation(() => {});
jest.spyOn(fs, 'readFileSync').mockImplementation((filePath) => {
if (filePath.toString().includes('AGENTS.md')) {
return 'Sample AGENTS.md content for OpenCode integration';
}
if (filePath.toString().includes('opencode.json')) {
return JSON.stringify({ mcpServers: {} }, null, 2);
}
return '{}';
});
jest.spyOn(fs, 'existsSync').mockImplementation(() => false);
jest.spyOn(fs, 'mkdirSync').mockImplementation(() => {});
});
afterEach(() => {
// Clean up the temporary directory
try {
fs.rmSync(tempDir, { recursive: true, force: true });
} catch (err) {
console.error(`Error cleaning up: ${err.message}`);
}
});
// Test function that simulates the OpenCode profile file copying behavior
function mockCreateOpenCodeStructure() {
// OpenCode profile copies AGENTS.md to AGENTS.md in project root (same name)
const sourceContent = 'Sample AGENTS.md content for OpenCode integration';
fs.writeFileSync(path.join(tempDir, 'AGENTS.md'), sourceContent);
// OpenCode profile creates opencode.json config file
const configContent = JSON.stringify({ mcpServers: {} }, null, 2);
fs.writeFileSync(path.join(tempDir, 'opencode.json'), configContent);
}
test('creates AGENTS.md file in project root', () => {
// Act
mockCreateOpenCodeStructure();
// Assert
expect(fs.writeFileSync).toHaveBeenCalledWith(
path.join(tempDir, 'AGENTS.md'),
'Sample AGENTS.md content for OpenCode integration'
);
});
test('creates opencode.json config file in project root', () => {
// Act
mockCreateOpenCodeStructure();
// Assert
expect(fs.writeFileSync).toHaveBeenCalledWith(
path.join(tempDir, 'opencode.json'),
JSON.stringify({ mcpServers: {} }, null, 2)
);
});
test('does not create any profile directories', () => {
// Act
mockCreateOpenCodeStructure();
// Assert - OpenCode profile should not create any directories
// Only the temp directory creation calls should exist
const mkdirCalls = fs.mkdirSync.mock.calls.filter(
(call) => !call[0].includes('task-master-test-')
);
expect(mkdirCalls).toHaveLength(0);
});
test('handles transformation of MCP config format', () => {
// This test simulates the transformation behavior that would happen in onPostConvert
const standardMcpConfig = {
mcpServers: {
'taskmaster-ai': {
command: 'node',
args: ['path/to/server.js'],
env: {
API_KEY: 'test-key'
}
}
}
};
const expectedOpenCodeConfig = {
$schema: 'https://opencode.ai/config.json',
mcp: {
'taskmaster-ai': {
type: 'local',
command: ['node', 'path/to/server.js'],
enabled: true,
environment: {
API_KEY: 'test-key'
}
}
}
};
// Mock the transformation behavior
fs.writeFileSync(
path.join(tempDir, 'opencode.json'),
JSON.stringify(expectedOpenCodeConfig, null, 2)
);
expect(fs.writeFileSync).toHaveBeenCalledWith(
path.join(tempDir, 'opencode.json'),
JSON.stringify(expectedOpenCodeConfig, null, 2)
);
});
});
```
--------------------------------------------------------------------------------
/mcp-server/src/core/direct-functions/scope-down.js:
--------------------------------------------------------------------------------
```javascript
/**
* scope-down.js
* Direct function implementation for scoping down task complexity
*/
import { scopeDownTask } from '../../../../scripts/modules/task-manager.js';
import {
enableSilentMode,
disableSilentMode
} from '../../../../scripts/modules/utils.js';
import { createLogWrapper } from '../../tools/utils.js';
/**
* Direct function wrapper for scoping down task complexity with error handling.
*
* @param {Object} args - Command arguments
* @param {string} args.id - Comma-separated list of task IDs to scope down
* @param {string} [args.strength='regular'] - Strength level (light, regular, heavy)
* @param {string} [args.prompt] - Custom prompt for scoping adjustments
* @param {string} [args.tasksJsonPath] - Path to the tasks.json file (resolved by tool)
* @param {boolean} [args.research=false] - Whether to use research capabilities for scoping
* @param {string} args.projectRoot - Project root path
* @param {string} [args.tag] - Tag for the task context (optional)
* @param {Object} log - Logger object
* @param {Object} context - Additional context (session)
* @returns {Promise<Object>} - Result object { success: boolean, data?: any, error?: { code: string, message: string } }
*/
export async function scopeDownDirect(args, log, context = {}) {
// Destructure expected args
const {
tasksJsonPath,
id,
strength = 'regular',
prompt: customPrompt,
research = false,
projectRoot,
tag
} = args;
const { session } = context; // Destructure session from context
// Enable silent mode to prevent console logs from interfering with JSON response
enableSilentMode();
// Create logger wrapper using the utility
const mcpLog = createLogWrapper(log);
try {
// Check if tasksJsonPath was provided
if (!tasksJsonPath) {
log.error('scopeDownDirect called without tasksJsonPath');
disableSilentMode(); // Disable before returning
return {
success: false,
error: {
code: 'MISSING_ARGUMENT',
message: 'tasksJsonPath is required'
}
};
}
// Check required parameters
if (!id) {
log.error('Missing required parameter: id');
disableSilentMode();
return {
success: false,
error: {
code: 'MISSING_PARAMETER',
message: 'The id parameter is required for scoping down tasks'
}
};
}
// Parse task IDs - convert to numbers as expected by scopeDownTask
const taskIds = id.split(',').map((taskId) => parseInt(taskId.trim(), 10));
log.info(
`Scoping down tasks: ${taskIds.join(', ')}, strength: ${strength}, research: ${research}`
);
// Call the scopeDownTask function
const result = await scopeDownTask(
tasksJsonPath,
taskIds,
strength,
customPrompt,
{
session,
mcpLog,
projectRoot,
commandName: 'scope-down',
outputType: 'mcp',
tag,
research
},
'json' // outputFormat
);
// Restore normal logging
disableSilentMode();
return {
success: true,
data: {
updatedTasks: result.updatedTasks,
tasksUpdated: result.updatedTasks.length,
message: `Successfully scoped down ${result.updatedTasks.length} task(s)`,
telemetryData: result.telemetryData
}
};
} catch (error) {
// Make sure to restore normal logging even if there's an error
disableSilentMode();
log.error(`Error in scopeDownDirect: ${error.message}`);
return {
success: false,
error: {
code: error.code || 'SCOPE_DOWN_ERROR',
message: error.message
}
};
}
}
```
--------------------------------------------------------------------------------
/packages/claude-code-plugin/commands/help.md:
--------------------------------------------------------------------------------
```markdown
Show help for Task Master AI commands.
Arguments: $ARGUMENTS
Display help for Task Master commands. If arguments provided, show specific command help.
## Task Master AI Command Help
### Quick Navigation
Type `/taskmaster:` and use tab completion to explore all commands.
### Command Categories
#### 🚀 Setup & Installation
- `/taskmaster:install-taskmaster` - Comprehensive installation guide
- `/taskmaster:quick-install-taskmaster` - One-line global install
#### 📋 Project Setup
- `/taskmaster:init-project` - Initialize new project
- `/taskmaster:init-project-quick` - Quick setup with auto-confirm
- `/taskmaster:view-models` - View AI configuration
- `/taskmaster:setup-models` - Configure AI providers
#### 🎯 Task Generation
- `/taskmaster:parse-prd` - Generate tasks from PRD
- `/taskmaster:parse-prd-with-research` - Enhanced parsing
- `/taskmaster:generate-tasks` - Create task files
#### 📝 Task Management
- `/taskmaster:list-tasks` - List all tasks
- `/taskmaster:list-tasks-by-status` - List tasks filtered by status
- `/taskmaster:list-tasks-with-subtasks` - List tasks with subtasks
- `/taskmaster:show-task` - Display task details
- `/taskmaster:add-task` - Create new task
- `/taskmaster:update-task` - Update single task
- `/taskmaster:update-tasks-from-id` - Update multiple tasks
- `/taskmaster:next-task` - Get next task recommendation
#### 🔄 Status Management
- `/taskmaster:to-pending` - Set task to pending
- `/taskmaster:to-in-progress` - Set task to in-progress
- `/taskmaster:to-done` - Set task to done
- `/taskmaster:to-review` - Set task to review
- `/taskmaster:to-deferred` - Set task to deferred
- `/taskmaster:to-cancelled` - Set task to cancelled
#### 🔍 Analysis & Breakdown
- `/taskmaster:analyze-complexity` - Analyze task complexity
- `/taskmaster:complexity-report` - View complexity report
- `/taskmaster:expand-task` - Break down complex task
- `/taskmaster:expand-all-tasks` - Expand all eligible tasks
#### 🔗 Dependencies
- `/taskmaster:add-dependency` - Add task dependency
- `/taskmaster:remove-dependency` - Remove dependency
- `/taskmaster:validate-dependencies` - Check for issues
- `/taskmaster:fix-dependencies` - Auto-fix dependency issues
#### 📦 Subtasks
- `/taskmaster:add-subtask` - Add subtask to task
- `/taskmaster:convert-task-to-subtask` - Convert task to subtask
- `/taskmaster:remove-subtask` - Remove subtask
- `/taskmaster:remove-subtasks` - Clear specific task subtasks
- `/taskmaster:remove-all-subtasks` - Clear all subtasks
#### 🗑️ Task Removal
- `/taskmaster:remove-task` - Remove task permanently
#### 🤖 Workflows
- `/taskmaster:smart-workflow` - Intelligent workflows
- `/taskmaster:command-pipeline` - Command chaining
- `/taskmaster:auto-implement-tasks` - Auto-implementation
#### 📊 Utilities
- `/taskmaster:analyze-project` - Project analysis
- `/taskmaster:project-status` - Project dashboard
- `/taskmaster:sync-readme` - Sync README with tasks
- `/taskmaster:learn` - Interactive learning
- `/taskmaster:tm-main` - Main Task Master interface
### Quick Start Examples
```
/taskmaster:list-tasks
/taskmaster:show-task 1.2
/taskmaster:add-task
/taskmaster:next-task
```
### Getting Started
1. Install: `/taskmaster:quick-install-taskmaster`
2. Initialize: `/taskmaster:init-project-quick`
3. Learn: `/taskmaster:learn`
4. Work: `/taskmaster:smart-workflow`
For detailed command info, run the specific command with `--help` or check command documentation.
```
--------------------------------------------------------------------------------
/mcp-server/src/core/direct-functions/list-tags.js:
--------------------------------------------------------------------------------
```javascript
/**
* list-tags.js
* Direct function implementation for listing all tags
*/
import { tags } from '../../../../scripts/modules/task-manager/tag-management.js';
import {
enableSilentMode,
disableSilentMode
} from '../../../../scripts/modules/utils.js';
import { createLogWrapper } from '../../tools/utils.js';
/**
* Direct function wrapper for listing all tags with error handling.
*
* @param {Object} args - Command arguments
* @param {boolean} [args.showMetadata=false] - Whether to include metadata in the output
* @param {string} [args.tasksJsonPath] - Path to the tasks.json file (resolved by tool)
* @param {string} [args.projectRoot] - Project root path
* @param {Object} log - Logger object
* @param {Object} context - Additional context (session)
* @returns {Promise<Object>} - Result object { success: boolean, data?: any, error?: { code: string, message: string } }
*/
export async function listTagsDirect(args, log, context = {}) {
// Destructure expected args
const { tasksJsonPath, showMetadata = false, projectRoot } = args;
const { session } = context;
// Enable silent mode to prevent console logs from interfering with JSON response
enableSilentMode();
// Create logger wrapper using the utility
const mcpLog = createLogWrapper(log);
try {
// Check if tasksJsonPath was provided
if (!tasksJsonPath) {
log.error('listTagsDirect called without tasksJsonPath');
disableSilentMode();
return {
success: false,
error: {
code: 'MISSING_ARGUMENT',
message: 'tasksJsonPath is required'
}
};
}
log.info('Listing all tags');
// Prepare options
const options = {
showMetadata
};
// Call the tags function
const result = await tags(
tasksJsonPath,
options,
{
session,
mcpLog,
projectRoot
},
'json' // outputFormat - use 'json' to suppress CLI UI
);
// Transform the result to remove full task data and provide summary info
const tagsSummary = result.tags.map((tag) => {
const tasks = tag.tasks || [];
// Calculate status breakdown
const statusBreakdown = tasks.reduce((acc, task) => {
const status = task.status || 'pending';
acc[status] = (acc[status] || 0) + 1;
return acc;
}, {});
// Calculate subtask counts
const subtaskCounts = tasks.reduce(
(acc, task) => {
if (task.subtasks && task.subtasks.length > 0) {
acc.totalSubtasks += task.subtasks.length;
task.subtasks.forEach((subtask) => {
const subStatus = subtask.status || 'pending';
acc.subtasksByStatus[subStatus] =
(acc.subtasksByStatus[subStatus] || 0) + 1;
});
}
return acc;
},
{ totalSubtasks: 0, subtasksByStatus: {} }
);
return {
name: tag.name,
isCurrent: tag.isCurrent,
taskCount: tasks.length,
completedTasks: tag.completedTasks,
statusBreakdown,
subtaskCounts,
created: tag.created,
description: tag.description
};
});
// Restore normal logging
disableSilentMode();
return {
success: true,
data: {
tags: tagsSummary,
currentTag: result.currentTag,
totalTags: result.totalTags,
message: `Found ${result.totalTags} tag(s)`
}
};
} catch (error) {
// Make sure to restore normal logging even if there's an error
disableSilentMode();
log.error(`Error in listTagsDirect: ${error.message}`);
return {
success: false,
error: {
code: error.code || 'LIST_TAGS_ERROR',
message: error.message
}
};
}
}
```
--------------------------------------------------------------------------------
/mcp-server/src/tools/set-task-status.js:
--------------------------------------------------------------------------------
```javascript
/**
* tools/setTaskStatus.js
* Tool to set the status of a task
*/
import { z } from 'zod';
import {
handleApiResult,
createErrorResponse,
withNormalizedProjectRoot
} from './utils.js';
import {
setTaskStatusDirect,
nextTaskDirect
} from '../core/task-master-core.js';
import {
findTasksPath,
findComplexityReportPath
} from '../core/utils/path-utils.js';
import { TASK_STATUS_OPTIONS } from '../../../src/constants/task-status.js';
import { resolveTag } from '../../../scripts/modules/utils.js';
/**
* Register the setTaskStatus tool with the MCP server
* @param {Object} server - FastMCP server instance
*/
export function registerSetTaskStatusTool(server) {
server.addTool({
name: 'set_task_status',
description: 'Set the status of one or more tasks or subtasks.',
parameters: z.object({
id: z
.string()
.describe(
"Task ID or subtask ID (e.g., '15', '15.2'). Can be comma-separated to update multiple tasks/subtasks at once."
),
status: z
.enum(TASK_STATUS_OPTIONS)
.describe(
"New status to set (e.g., 'pending', 'done', 'in-progress', 'review', 'deferred', 'cancelled'."
),
file: z.string().optional().describe('Absolute path to the tasks file'),
complexityReport: z
.string()
.optional()
.describe(
'Path to the complexity report file (relative to project root or absolute)'
),
projectRoot: z
.string()
.describe('The directory of the project. Must be an absolute path.'),
tag: z.string().optional().describe('Optional tag context to operate on')
}),
execute: withNormalizedProjectRoot(async (args, { log, session }) => {
try {
log.info(
`Setting status of task(s) ${args.id} to: ${args.status} ${
args.tag ? `in tag: ${args.tag}` : 'in current tag'
}`
);
const resolvedTag = resolveTag({
projectRoot: args.projectRoot,
tag: args.tag
});
// Use args.projectRoot directly (guaranteed by withNormalizedProjectRoot)
let tasksJsonPath;
try {
tasksJsonPath = findTasksPath(
{ projectRoot: args.projectRoot, file: args.file },
log
);
} catch (error) {
log.error(`Error finding tasks.json: ${error.message}`);
return createErrorResponse(
`Failed to find tasks.json: ${error.message}`
);
}
let complexityReportPath;
try {
complexityReportPath = findComplexityReportPath(
{
projectRoot: args.projectRoot,
complexityReport: args.complexityReport,
tag: resolvedTag
},
log
);
} catch (error) {
log.error(`Error finding complexity report: ${error.message}`);
}
const result = await setTaskStatusDirect(
{
tasksJsonPath: tasksJsonPath,
id: args.id,
status: args.status,
complexityReportPath,
projectRoot: args.projectRoot,
tag: resolvedTag
},
log,
{ session }
);
if (result.success) {
log.info(
`Successfully updated status for task(s) ${args.id} to "${args.status}": ${result.data.message}`
);
} else {
log.error(
`Failed to update task status: ${result.error?.message || 'Unknown error'}`
);
}
return handleApiResult(
result,
log,
'Error setting task status',
undefined,
args.projectRoot
);
} catch (error) {
log.error(`Error in setTaskStatus tool: ${error.message}`);
return createErrorResponse(
`Error setting task status: ${error.message}`
);
}
})
});
}
```
--------------------------------------------------------------------------------
/tests/unit/profiles/claude-integration.test.js:
--------------------------------------------------------------------------------
```javascript
import { jest } from '@jest/globals';
import fs from 'fs';
import path from 'path';
import os from 'os';
import { claudeProfile } from '../../../src/profiles/claude.js';
// Mock external modules
jest.mock('child_process', () => ({
execSync: jest.fn()
}));
// Mock console methods
jest.mock('console', () => ({
log: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
clear: jest.fn()
}));
describe('Claude Profile Integration', () => {
let tempDir;
beforeEach(() => {
jest.clearAllMocks();
// Create a temporary directory for testing
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'task-master-test-'));
// Spy on fs methods
jest.spyOn(fs, 'writeFileSync').mockImplementation(() => {});
jest.spyOn(fs, 'readFileSync').mockImplementation((filePath) => {
if (filePath.toString().includes('AGENTS.md')) {
return 'Sample AGENTS.md content for Claude integration';
}
return '{}';
});
jest.spyOn(fs, 'existsSync').mockImplementation(() => false);
jest.spyOn(fs, 'mkdirSync').mockImplementation(() => {});
});
afterEach(() => {
// Clean up the temporary directory
try {
fs.rmSync(tempDir, { recursive: true, force: true });
} catch (err) {
console.error(`Error cleaning up: ${err.message}`);
}
});
// Test function that simulates the Claude profile file copying behavior
function mockCreateClaudeStructure() {
// Claude profile copies AGENTS.md to CLAUDE.md in project root
const sourceContent = 'Sample AGENTS.md content for Claude integration';
fs.writeFileSync(path.join(tempDir, 'CLAUDE.md'), sourceContent);
}
test('creates CLAUDE.md file in project root', () => {
// Act
mockCreateClaudeStructure();
// Assert
expect(fs.writeFileSync).toHaveBeenCalledWith(
path.join(tempDir, 'CLAUDE.md'),
'Sample AGENTS.md content for Claude integration'
);
});
test('does not create any profile directories', () => {
// Act
mockCreateClaudeStructure();
// Assert - Claude profile should not create any directories
// Only the temp directory creation calls should exist
const mkdirCalls = fs.mkdirSync.mock.calls.filter(
(call) => !call[0].includes('task-master-test-')
);
expect(mkdirCalls).toHaveLength(0);
});
test('supports MCP configuration when using rule transformer', () => {
// This test verifies that the Claude profile is configured to support MCP
// The actual MCP file creation is handled by the rule transformer
// Assert - Claude profile should now support MCP configuration
expect(claudeProfile.mcpConfig).toBe(true);
expect(claudeProfile.mcpConfigName).toBe('.mcp.json');
expect(claudeProfile.mcpConfigPath).toBe('.mcp.json');
});
test('mock function does not create MCP configuration files', () => {
// Act
mockCreateClaudeStructure();
// Assert - The mock function should not create MCP config files
// (This is expected since the mock doesn't use the rule transformer)
const writeFileCalls = fs.writeFileSync.mock.calls;
const mcpConfigCalls = writeFileCalls.filter(
(call) =>
call[0].toString().includes('mcp.json') ||
call[0].toString().includes('mcp_settings.json')
);
expect(mcpConfigCalls).toHaveLength(0);
});
test('only creates the target integration guide file', () => {
// Act
mockCreateClaudeStructure();
// Assert - Should only create CLAUDE.md
const writeFileCalls = fs.writeFileSync.mock.calls;
expect(writeFileCalls).toHaveLength(1);
expect(writeFileCalls[0][0]).toBe(path.join(tempDir, 'CLAUDE.md'));
});
});
```
--------------------------------------------------------------------------------
/apps/cli/src/ui/formatters/status-formatters.ts:
--------------------------------------------------------------------------------
```typescript
/**
* @fileoverview Status formatting utilities
* Provides colored status displays with ASCII icons for tasks and briefs
*/
import type { TaskStatus } from '@tm/core';
import chalk from 'chalk';
/**
* Module-level task status configuration to avoid recreating on every call
*/
const TASK_STATUS_CONFIG: Record<
TaskStatus,
{ color: (text: string) => string; icon: string; tableIcon: string }
> = {
done: {
color: chalk.green,
icon: '✓',
tableIcon: '✓'
},
pending: {
color: chalk.yellow,
icon: '○',
tableIcon: '○'
},
'in-progress': {
color: chalk.hex('#FFA500'),
icon: '▶',
tableIcon: '▶'
},
deferred: {
color: chalk.gray,
icon: 'x',
tableIcon: 'x'
},
review: {
color: chalk.magenta,
icon: '?',
tableIcon: '?'
},
cancelled: {
color: chalk.gray,
icon: 'x',
tableIcon: 'x'
},
blocked: {
color: chalk.red,
icon: '!',
tableIcon: '!'
},
completed: {
color: chalk.green,
icon: '✓',
tableIcon: '✓'
}
};
/**
* Get colored status display with ASCII icons (matches scripts/modules/ui.js style)
*/
export function getStatusWithColor(
status: TaskStatus,
forTable: boolean = false
): string {
const config = TASK_STATUS_CONFIG[status] || {
color: chalk.red,
icon: 'X',
tableIcon: 'X'
};
const icon = forTable ? config.tableIcon : config.icon;
return config.color(`${icon} ${status}`);
}
/**
* Brief status configuration
*/
const BRIEF_STATUS_CONFIG: Record<
string,
{ color: (text: string) => string; icon: string; tableIcon: string }
> = {
draft: {
color: chalk.gray,
icon: '○',
tableIcon: '○'
},
refining: {
color: chalk.yellow,
icon: '◐',
tableIcon: '◐'
},
aligned: {
color: chalk.cyan,
icon: '◎',
tableIcon: '◎'
},
delivering: {
color: chalk.hex('#FFA500'), // orange
icon: '▶',
tableIcon: '▶'
},
delivered: {
color: chalk.blue,
icon: '◆',
tableIcon: '◆'
},
done: {
color: chalk.green,
icon: '✓',
tableIcon: '✓'
},
archived: {
color: chalk.gray,
icon: '■',
tableIcon: '■'
}
};
/**
* Get the configuration for a brief status
*/
function getBriefStatusConfig(status: string) {
// Normalize to lowercase for lookup
const normalizedStatus = status.toLowerCase();
return (
BRIEF_STATUS_CONFIG[normalizedStatus] || {
color: chalk.red,
icon: '?',
tableIcon: '?'
}
);
}
/**
* Get the icon for a brief status
*/
export function getBriefStatusIcon(
status: string | undefined,
forTable: boolean = false
): string {
if (!status) return '○';
const config = getBriefStatusConfig(status);
return forTable ? config.tableIcon : config.icon;
}
/**
* Get the color function for a brief status
*/
export function getBriefStatusColor(
status: string | undefined
): (text: string) => string {
if (!status) return chalk.gray;
return getBriefStatusConfig(status).color;
}
/**
* Capitalize the first letter of a status
*/
export function capitalizeStatus(status: string): string {
return status.charAt(0).toUpperCase() + status.slice(1).toLowerCase();
}
/**
* Get colored brief/tag status display with ASCII icons
* Brief statuses: draft, refining, aligned, delivering, delivered, done, archived
*/
export function getBriefStatusWithColor(
status: string | undefined,
forTable: boolean = false
): string {
if (!status) {
return chalk.gray('○ Unknown');
}
const config = getBriefStatusConfig(status);
const icon = forTable ? config.tableIcon : config.icon;
const displayStatus = capitalizeStatus(status);
return config.color(`${icon} ${displayStatus}`);
}
```
--------------------------------------------------------------------------------
/apps/cli/src/commands/autopilot/abort.command.ts:
--------------------------------------------------------------------------------
```typescript
/**
* @fileoverview Abort Command - Safely terminate workflow
*/
import { WorkflowOrchestrator } from '@tm/core';
import { Command } from 'commander';
import inquirer from 'inquirer';
import {
AutopilotBaseOptions,
OutputFormatter,
deleteWorkflowState,
hasWorkflowState,
loadWorkflowState
} from './shared.js';
import { getProjectRoot } from '../../utils/project-root.js';
interface AbortOptions extends AutopilotBaseOptions {
force?: boolean;
}
/**
* Abort Command - Safely terminate workflow and clean up state
*/
export class AbortCommand extends Command {
constructor() {
super('abort');
this.description('Abort the current TDD workflow and clean up state')
.option('-f, --force', 'Force abort without confirmation')
.action(async (options: AbortOptions) => {
await this.execute(options);
});
}
private async execute(options: AbortOptions): Promise<void> {
// Inherit parent options
const parentOpts = this.parent?.opts() as AutopilotBaseOptions;
// Initialize mergedOptions with defaults (projectRoot will be set in try block)
let mergedOptions: AbortOptions = {
...parentOpts,
...options,
projectRoot: '' // Will be set in try block
};
const formatter = new OutputFormatter(
options.json || parentOpts?.json || false
);
try {
// Resolve project root inside try block to catch any errors
const projectRoot = getProjectRoot(
options.projectRoot || parentOpts?.projectRoot
);
// Update mergedOptions with resolved project root
mergedOptions = {
...mergedOptions,
projectRoot
};
// Check for workflow state
const hasState = await hasWorkflowState(mergedOptions.projectRoot!);
if (!hasState) {
formatter.warning('No active workflow to abort');
return;
}
// Load state
const state = await loadWorkflowState(mergedOptions.projectRoot!);
if (!state) {
formatter.error('Failed to load workflow state');
process.exit(1);
}
// Restore orchestrator
const orchestrator = new WorkflowOrchestrator(state.context);
orchestrator.restoreState(state);
// Get progress before abort
const progress = orchestrator.getProgress();
const currentSubtask = orchestrator.getCurrentSubtask();
// Confirm abort if not forced or in JSON mode
if (!mergedOptions.force && !mergedOptions.json) {
const { confirmed } = await inquirer.prompt([
{
type: 'confirm',
name: 'confirmed',
message:
`This will abort the workflow for task ${state.context.taskId}. ` +
`Progress: ${progress.completed}/${progress.total} subtasks completed. ` +
`Continue?`,
default: false
}
]);
if (!confirmed) {
formatter.info('Abort cancelled');
return;
}
}
// Trigger abort in orchestrator
orchestrator.transition({ type: 'ABORT' });
// Delete workflow state
await deleteWorkflowState(mergedOptions.projectRoot!);
// Output result
formatter.success('Workflow aborted', {
taskId: state.context.taskId,
branchName: state.context.branchName,
progress: {
completed: progress.completed,
total: progress.total
},
lastSubtask: currentSubtask
? {
id: currentSubtask.id,
title: currentSubtask.title
}
: null,
note: 'Branch and commits remain. Clean up manually if needed.'
});
} catch (error) {
formatter.error((error as Error).message);
if (mergedOptions.verbose) {
console.error((error as Error).stack);
}
process.exit(1);
}
}
}
```
--------------------------------------------------------------------------------
/packages/tm-core/src/modules/storage/utils/api-client.ts:
--------------------------------------------------------------------------------
```typescript
/**
* Lightweight API client utility for Hamster backend
* Centralizes error handling, auth, and request/response logic
*/
import {
ERROR_CODES,
TaskMasterError
} from '../../../common/errors/task-master-error.js';
import type { AuthManager } from '../../auth/managers/auth-manager.js';
export interface ApiClientOptions {
baseUrl: string;
authManager: AuthManager;
accountId?: string;
}
export interface ApiErrorResponse {
message: string;
error?: string;
statusCode?: number;
}
export class ApiClient {
constructor(private options: ApiClientOptions) {}
/**
* Make a typed API request with automatic error handling
*/
async request<T = any>(
endpoint: string,
options: RequestInit = {}
): Promise<T> {
const { baseUrl, authManager, accountId } = this.options;
// Get auth session
const session = await authManager.supabaseClient.getSession();
if (!session) {
throw new TaskMasterError(
'Not authenticated',
ERROR_CODES.AUTHENTICATION_ERROR,
{ operation: 'api-request', endpoint }
);
}
// Build full URL
const url = `${baseUrl}${endpoint}`;
// Build headers
const headers: RequestInit['headers'] = {
'Content-Type': 'application/json',
Authorization: `Bearer ${session.access_token}`,
...(accountId ? { 'x-account-id': accountId } : {}),
...options.headers
};
try {
// Make request
const response = await fetch(url, {
...options,
headers
});
// Handle non-2xx responses
if (!response.ok) {
await this.handleErrorResponse(response, endpoint);
}
// Parse successful response
return (await response.json()) as T;
} catch (error) {
// If it's already a TaskMasterError, re-throw
if (error instanceof TaskMasterError) {
throw error;
}
// Wrap other errors
const errorMessage =
error instanceof Error ? error.message : String(error);
throw new TaskMasterError(
errorMessage,
ERROR_CODES.API_ERROR,
{ operation: 'api-request', endpoint },
error as Error
);
}
}
/**
* Extract and throw a clean error from API response
*/
private async handleErrorResponse(
response: Response,
endpoint: string
): Promise<never> {
let errorMessage: string;
try {
// API returns: { message: "...", error: "...", statusCode: 404 }
const errorBody = (await response.json()) as ApiErrorResponse;
errorMessage =
errorBody.message || errorBody.error || 'Unknown API error';
} catch {
// Fallback if response isn't JSON
errorMessage = (await response.text()) || response.statusText;
}
throw new TaskMasterError(errorMessage, ERROR_CODES.API_ERROR, {
operation: 'api-request',
endpoint,
statusCode: response.status
});
}
/**
* Convenience methods for common HTTP verbs
*/
async get<T = any>(endpoint: string): Promise<T> {
return this.request<T>(endpoint, { method: 'GET' });
}
async post<T = any>(endpoint: string, body?: any): Promise<T> {
return this.request<T>(endpoint, {
method: 'POST',
body: body ? JSON.stringify(body) : undefined
});
}
async patch<T = any>(endpoint: string, body?: any): Promise<T> {
return this.request<T>(endpoint, {
method: 'PATCH',
body: body ? JSON.stringify(body) : undefined
});
}
async put<T = any>(endpoint: string, body?: any): Promise<T> {
return this.request<T>(endpoint, {
method: 'PUT',
body: body ? JSON.stringify(body) : undefined
});
}
async delete<T = any>(endpoint: string): Promise<T> {
return this.request<T>(endpoint, { method: 'DELETE' });
}
}
```
--------------------------------------------------------------------------------
/scripts/modules/task-manager/parse-prd/parse-prd-config.js:
--------------------------------------------------------------------------------
```javascript
/**
* Configuration classes and schemas for PRD parsing
*/
import { z } from 'zod';
import { TASK_PRIORITY_OPTIONS } from '../../../../src/constants/task-priority.js';
import { getCurrentTag, isSilentMode, log } from '../../utils.js';
import { Duration } from '../../../../src/utils/timeout-manager.js';
import { hasCodebaseAnalysis } from '../../config-manager.js';
// ============================================================================
// SCHEMAS
// ============================================================================
// Define the Zod schema for a SINGLE task object
export const prdSingleTaskSchema = z.object({
id: z.number(),
title: z.string().min(1),
description: z.string().min(1),
details: z.string(),
testStrategy: z.string(),
priority: z.enum(TASK_PRIORITY_OPTIONS),
dependencies: z.array(z.number()),
status: z.string()
});
// Define the Zod schema for the ENTIRE expected AI response object
export const prdResponseSchema = z.object({
tasks: z.array(prdSingleTaskSchema),
// Use union for better structured outputs compatibility
// Models understand "either return this object OR null" more reliably
metadata: z
.union([
z.object({
projectName: z.string(),
totalTasks: z.number(),
sourceFile: z.string(),
generatedAt: z.string()
}),
z.null()
])
.default(null)
});
// ============================================================================
// CONFIGURATION CLASSES
// ============================================================================
/**
* Configuration object for PRD parsing
*/
export class PrdParseConfig {
constructor(prdPath, tasksPath, numTasks, options = {}) {
this.prdPath = prdPath;
this.tasksPath = tasksPath;
this.numTasks = numTasks;
this.force = options.force || false;
this.append = options.append || false;
this.research = options.research || false;
this.reportProgress = options.reportProgress;
this.mcpLog = options.mcpLog;
this.session = options.session;
this.projectRoot = options.projectRoot;
this.tag = options.tag;
this.streamingTimeout =
options.streamingTimeout || Duration.seconds(180).milliseconds;
// Derived values
this.targetTag = this.tag || getCurrentTag(this.projectRoot) || 'master';
this.isMCP = !!this.mcpLog;
this.outputFormat = this.isMCP && !this.reportProgress ? 'json' : 'text';
// Feature flag: Temporarily disable streaming, use generateObject instead
// TODO: Re-enable streaming once issues are resolved
const ENABLE_STREAMING = false;
this.useStreaming =
ENABLE_STREAMING &&
(typeof this.reportProgress === 'function' ||
this.outputFormat === 'text');
}
/**
* Check if codebase analysis is available (Claude Code or Gemini CLI)
*/
hasCodebaseAnalysis() {
return hasCodebaseAnalysis(this.research, this.projectRoot, this.session);
}
}
/**
* Logging configuration and utilities
*/
export class LoggingConfig {
constructor(mcpLog, reportProgress) {
this.isMCP = !!mcpLog;
this.outputFormat = this.isMCP && !reportProgress ? 'json' : 'text';
this.logFn = mcpLog || {
info: (...args) => log('info', ...args),
warn: (...args) => log('warn', ...args),
error: (...args) => log('error', ...args),
debug: (...args) => log('debug', ...args),
success: (...args) => log('success', ...args)
};
}
report(message, level = 'info') {
if (this.logFn && typeof this.logFn[level] === 'function') {
this.logFn[level](message);
} else if (!isSilentMode() && this.outputFormat === 'text') {
log(level, message);
}
}
}
```
--------------------------------------------------------------------------------
/.github/scripts/validate-changesets.mjs:
--------------------------------------------------------------------------------
```
#!/usr/bin/env node
import { readFileSync, readdirSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const rootDir = join(__dirname, '../..');
// Define allowed public packages that can be referenced in changesets
const PUBLIC_PACKAGES = ['task-master-ai', 'extension'];
/**
* Parse a changeset file and extract package names from the frontmatter
* This uses a simple YAML parser that's sufficient for changeset files
* and doesn't require external dependencies.
*
* @param {string} filePath - Path to the changeset file
* @returns {string[]} - Array of package names
* @throws {Error} - If file cannot be read or parsed
*/
function parseChangesetFile(filePath) {
try {
const content = readFileSync(filePath, 'utf-8');
// Extract frontmatter between --- markers
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
if (!frontmatterMatch) {
throw new Error('No valid frontmatter found (missing --- delimiters)');
}
const frontmatter = frontmatterMatch[1];
const packages = [];
// Parse simple YAML format: 'package-name': version
// This handles the standard changeset format without needing a full YAML parser
const lines = frontmatter.split(/\r?\n/);
for (const line of lines) {
const trimmed = line.trim();
// Skip empty lines and comments
if (!trimmed || trimmed.startsWith('#')) {
continue;
}
// Match package declarations: 'package-name': version or "package-name": version
const match = trimmed.match(/^['"]?([^'":\s]+)['"]?\s*:\s*.+$/);
if (match) {
packages.push(match[1]);
}
}
if (packages.length === 0) {
throw new Error('No packages found in frontmatter');
}
return packages;
} catch (error) {
if (error.code === 'ENOENT') {
throw new Error(`File not found: ${filePath}`);
}
throw new Error(`Failed to parse ${filePath}: ${error.message}`);
}
}
/**
* Validate all changeset files in the .changeset directory
* @returns {boolean} - True if all changesets are valid
*/
function validateChangesets() {
try {
const changesetsDir = join(rootDir, '.changeset');
const files = readdirSync(changesetsDir);
const errors = [];
for (const file of files) {
// Skip config files and README
if (
file === 'config.json' ||
file === 'README.md' ||
!file.endsWith('.md')
) {
continue;
}
const filePath = join(changesetsDir, file);
try {
const packages = parseChangesetFile(filePath);
for (const pkg of packages) {
// Only allow packages in the PUBLIC_PACKAGES whitelist
if (!PUBLIC_PACKAGES.includes(pkg)) {
errors.push({
file,
package: pkg,
message: `Invalid package "${pkg}". Only these packages are allowed: ${PUBLIC_PACKAGES.join(', ')}`
});
}
}
} catch (error) {
errors.push({
file,
package: 'N/A',
message: `Parse error: ${error.message}`
});
}
}
// Print results
if (errors.length === 0) {
console.log('✅ All changesets are valid!');
return true;
}
console.error('\n❌ Changeset validation failed:\n');
for (const error of errors) {
console.error(` ${error.file}:`);
console.error(` ${error.message}`);
console.error('');
}
return false;
} catch (error) {
console.error(`\n❌ Fatal error during validation: ${error.message}\n`);
return false;
}
}
const isValid = validateChangesets();
process.exit(isValid ? 0 : 1);
```
--------------------------------------------------------------------------------
/packages/tm-core/src/modules/execution/executors/claude-executor.ts:
--------------------------------------------------------------------------------
```typescript
/**
* Claude executor implementation for Task Master
*/
import { spawn } from 'child_process';
import type { Task } from '../../../common/types/index.js';
import { BaseExecutor } from '../executors/base-executor.js';
import type {
ClaudeExecutorConfig,
ExecutionResult,
ExecutorType
} from '../types.js';
export class ClaudeExecutor extends BaseExecutor {
private claudeConfig: ClaudeExecutorConfig;
private currentProcess: any = null;
constructor(projectRoot: string, config: ClaudeExecutorConfig = {}) {
super(projectRoot, config);
this.claudeConfig = {
command: config.command || 'claude',
systemPrompt:
config.systemPrompt ||
'You are a helpful AI assistant helping to complete a software development task.',
additionalFlags: config.additionalFlags || []
};
}
getType(): ExecutorType {
return 'claude';
}
async isAvailable(): Promise<boolean> {
return new Promise((resolve) => {
const checkProcess = spawn('which', [this.claudeConfig.command!], {
shell: true
});
checkProcess.on('close', (code) => {
resolve(code === 0);
});
checkProcess.on('error', () => {
resolve(false);
});
});
}
async execute(task: Task): Promise<ExecutionResult> {
const startTime = new Date().toISOString();
try {
// Check if Claude is available
const isAvailable = await this.isAvailable();
if (!isAvailable) {
return this.createResult(
task.id,
false,
undefined,
`Claude CLI not found. Please ensure 'claude' command is available in PATH.`
);
}
// Format the task into a prompt
const taskPrompt = this.formatTaskPrompt(task);
const fullPrompt = `${this.claudeConfig.systemPrompt}\n\nHere is the task to complete:\n\n${taskPrompt}`;
// Execute Claude with the task details
const result = await this.runClaude(fullPrompt, task.id);
return {
...result,
startTime,
endTime: new Date().toISOString()
};
} catch (error: any) {
this.logger.error(`Failed to execute task ${task.id}:`, error);
return this.createResult(
task.id,
false,
undefined,
error.message || 'Unknown error occurred'
);
}
}
private runClaude(prompt: string, taskId: string): Promise<ExecutionResult> {
return new Promise((resolve) => {
const args = [prompt, ...this.claudeConfig.additionalFlags!];
this.logger.info(`Executing Claude for task ${taskId}`);
this.logger.debug(
`Command: ${this.claudeConfig.command} ${args.join(' ')}`
);
this.currentProcess = spawn(this.claudeConfig.command!, args, {
cwd: this.projectRoot,
shell: false,
stdio: 'inherit' // Let Claude handle its own I/O
});
this.currentProcess.on('close', (code: number) => {
this.currentProcess = null;
if (code === 0) {
resolve(
this.createResult(
taskId,
true,
'Claude session completed successfully'
)
);
} else {
resolve(
this.createResult(
taskId,
false,
undefined,
`Claude exited with code ${code}`
)
);
}
});
this.currentProcess.on('error', (error: any) => {
this.currentProcess = null;
this.logger.error(`Claude process error:`, error);
resolve(
this.createResult(
taskId,
false,
undefined,
`Failed to spawn Claude: ${error.message}`
)
);
});
});
}
async stop(): Promise<void> {
if (this.currentProcess) {
this.logger.info('Stopping Claude process...');
this.currentProcess.kill('SIGTERM');
this.currentProcess = null;
}
}
}
```
--------------------------------------------------------------------------------
/apps/mcp/src/tools/tasks/get-task.tool.ts:
--------------------------------------------------------------------------------
```typescript
/**
* @fileoverview get-task MCP tool
* Get detailed information about a specific task by ID
*/
import { z } from 'zod';
import {
handleApiResult,
withNormalizedProjectRoot
} from '../../shared/utils.js';
import type { MCPContext } from '../../shared/types.js';
import { createTmCore, Subtask, type Task } from '@tm/core';
import type { FastMCP } from 'fastmcp';
const GetTaskSchema = z.object({
id: z
.string()
.describe(
'Task ID(s) to get (can be comma-separated for multiple tasks)'
),
status: z
.string()
.optional()
.describe("Filter subtasks by status (e.g., 'pending', 'done')"),
projectRoot: z
.string()
.describe(
'Absolute path to the project root directory (Optional, usually from session)'
),
tag: z.string().optional().describe('Tag context to operate on')
});
type GetTaskArgs = z.infer<typeof GetTaskSchema>;
/**
* Register the get_task tool with the MCP server
*/
export function registerGetTaskTool(server: FastMCP) {
server.addTool({
name: 'get_task',
description: 'Get detailed information about a specific task',
parameters: GetTaskSchema,
execute: withNormalizedProjectRoot(
async (args: GetTaskArgs, context: MCPContext) => {
const { id, status, projectRoot, tag } = args;
try {
context.log.info(
`Getting task details for ID: ${id}${status ? ` (filtering subtasks by status: ${status})` : ''} in root: ${projectRoot}`
);
// Create tm-core with logging callback
const tmCore = await createTmCore({
projectPath: projectRoot,
loggerConfig: {
mcpMode: true,
logCallback: context.log
}
});
// Handle comma-separated IDs - parallelize for better performance
const taskIds = id.split(',').map((tid) => tid.trim());
const results = await Promise.all(
taskIds.map((taskId) => tmCore.tasks.get(taskId, tag))
);
const tasks: (Task | Subtask)[] = [];
for (const result of results) {
if (!result.task) continue;
// If status filter is provided, filter subtasks (create copy to avoid mutation)
if (status && result.task.subtasks) {
const statusFilters = status
.split(',')
.map((s) => s.trim().toLowerCase());
const filteredSubtasks = result.task.subtasks.filter((st) =>
statusFilters.includes(String(st.status).toLowerCase())
);
tasks.push({ ...result.task, subtasks: filteredSubtasks });
} else {
tasks.push(result.task);
}
}
if (tasks.length === 0) {
context.log.warn(`No tasks found for ID(s): ${id}`);
return handleApiResult({
result: {
success: false,
error: {
message: `No tasks found for ID(s): ${id}`
}
},
log: context.log,
projectRoot
});
}
context.log.info(
`Successfully retrieved ${tasks.length} task(s) for ID(s): ${id}`
);
// Return single task if only one ID was requested, otherwise array
const responseData = taskIds.length === 1 ? tasks[0] : tasks;
return handleApiResult({
result: {
success: true,
data: responseData
},
log: context.log,
projectRoot,
tag
});
} catch (error: any) {
context.log.error(`Error in get-task: ${error.message}`);
if (error.stack) {
context.log.debug(error.stack);
}
return handleApiResult({
result: {
success: false,
error: {
message: `Failed to get task: ${error.message}`
}
},
log: context.log,
projectRoot
});
}
}
)
});
}
```
--------------------------------------------------------------------------------
/apps/cli/src/commands/models/fetchers.ts:
--------------------------------------------------------------------------------
```typescript
/**
* @fileoverview Model fetching utilities for OpenRouter, Ollama, and other providers
*/
import http from 'http';
import https from 'https';
import type { FetchResult, OllamaModel, OpenRouterModel } from './types.js';
/**
* Fetch available models from OpenRouter API
*/
export async function fetchOpenRouterModels(): Promise<
FetchResult<OpenRouterModel[]>
> {
return new Promise((resolve) => {
const options = {
hostname: 'openrouter.ai',
path: '/api/v1/models',
method: 'GET',
headers: {
Accept: 'application/json'
}
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
if (res.statusCode === 200) {
try {
const parsedData = JSON.parse(data);
resolve({
success: true,
data: parsedData.data || []
});
} catch (e) {
resolve({
success: false,
error: 'Failed to parse OpenRouter response'
});
}
} else {
resolve({
success: false,
error: `OpenRouter API returned status ${res.statusCode}`
});
}
});
});
req.on('error', (e) => {
resolve({
success: false,
error: `Failed to fetch OpenRouter models: ${e.message}`
});
});
req.end();
});
}
/**
* Fetch available models from Ollama instance
*/
export async function fetchOllamaModels(
baseURL = 'http://localhost:11434/api'
): Promise<FetchResult<OllamaModel[]>> {
return new Promise((resolve) => {
try {
// Parse the base URL to extract hostname, port, and base path
const url = new URL(baseURL);
const isHttps = url.protocol === 'https:';
const port = url.port || (isHttps ? 443 : 80);
const basePath = url.pathname.endsWith('/')
? url.pathname.slice(0, -1)
: url.pathname;
const options = {
hostname: url.hostname,
port: parseInt(String(port), 10),
path: `${basePath}/tags`,
method: 'GET',
headers: {
Accept: 'application/json'
}
};
const requestLib = isHttps ? https : http;
const req = requestLib.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
if (res.statusCode === 200) {
try {
const parsedData = JSON.parse(data);
resolve({
success: true,
data: parsedData.models || []
});
} catch (e) {
resolve({
success: false,
error: 'Failed to parse Ollama response'
});
}
} else {
resolve({
success: false,
error: `Ollama API returned status ${res.statusCode}`
});
}
});
});
req.on('error', (e) => {
resolve({
success: false,
error: `Failed to connect to Ollama: ${e.message}`
});
});
req.end();
} catch (e) {
resolve({
success: false,
error: `Invalid Ollama base URL: ${e instanceof Error ? e.message : 'Unknown error'}`
});
}
});
}
/**
* Validate if a model ID exists in OpenRouter
*/
export async function validateOpenRouterModel(
modelId: string
): Promise<boolean> {
const result = await fetchOpenRouterModels();
if (!result.success || !result.data) {
return false;
}
return result.data.some((m) => m.id === modelId);
}
/**
* Validate if a model ID exists in Ollama instance
*/
export async function validateOllamaModel(
modelId: string,
baseURL?: string
): Promise<boolean> {
const result = await fetchOllamaModels(baseURL);
if (!result.success || !result.data) {
return false;
}
return result.data.some((m) => m.model === modelId);
}
```
--------------------------------------------------------------------------------
/src/ai-providers/codex-cli.js:
--------------------------------------------------------------------------------
```javascript
/**
* src/ai-providers/codex-cli.js
*
* Codex CLI provider implementation using the ai-sdk-provider-codex-cli package.
* This provider uses the local OpenAI Codex CLI with OAuth (preferred) or
* an optional OPENAI_CODEX_API_KEY if provided.
*/
import { createCodexCli } from 'ai-sdk-provider-codex-cli';
import { BaseAIProvider } from './base-provider.js';
import { execSync } from 'child_process';
import { log } from '../../scripts/modules/utils.js';
import {
getCodexCliSettingsForCommand,
getSupportedModelsForProvider
} from '../../scripts/modules/config-manager.js';
export class CodexCliProvider extends BaseAIProvider {
constructor() {
super();
this.name = 'Codex CLI';
// Codex CLI has native schema support, no explicit JSON schema mode required
this.needsExplicitJsonSchema = false;
// Codex CLI does not support temperature parameter
this.supportsTemperature = false;
// Load supported models from supported-models.json
this.supportedModels = getSupportedModelsForProvider('codex-cli');
// Validate that models were loaded successfully
if (this.supportedModels.length === 0) {
log(
'warn',
'No supported models found for codex-cli provider. Check supported-models.json configuration.'
);
}
// CLI availability check cache
this._codexCliChecked = false;
this._codexCliAvailable = null;
}
/**
* Codex CLI does not require an API key when using OAuth via `codex login`.
* @returns {boolean}
*/
isRequiredApiKey() {
return false;
}
/**
* Returns the environment variable name used when an API key is provided.
* Even though the API key is optional for Codex CLI (OAuth-first),
* downstream resolution expects a non-throwing implementation.
* Uses OPENAI_CODEX_API_KEY to avoid conflicts with OpenAI provider.
* @returns {string}
*/
getRequiredApiKeyName() {
return 'OPENAI_CODEX_API_KEY';
}
/**
* Optional CLI availability check; provide helpful guidance if missing.
*/
validateAuth() {
if (process.env.NODE_ENV === 'test') return;
if (!this._codexCliChecked) {
try {
execSync('codex --version', { stdio: 'pipe', timeout: 1000 });
this._codexCliAvailable = true;
} catch (error) {
this._codexCliAvailable = false;
log(
'warn',
'Codex CLI not detected. Install with: npm i -g @openai/codex or enable fallback with allowNpx.'
);
} finally {
this._codexCliChecked = true;
}
}
}
/**
* Creates a Codex CLI client instance
* @param {object} params
* @param {string} [params.commandName] - Command name for settings lookup
* @param {string} [params.apiKey] - Optional API key (injected as OPENAI_API_KEY for Codex CLI)
* @returns {Function}
*/
getClient(params = {}) {
try {
// Merge global + command-specific settings from config
const settings = getCodexCliSettingsForCommand(params.commandName) || {};
// Inject API key only if explicitly provided; OAuth is the primary path
const defaultSettings = {
...settings,
...(params.apiKey
? { env: { ...(settings.env || {}), OPENAI_API_KEY: params.apiKey } }
: {})
};
return createCodexCli({ defaultSettings });
} catch (error) {
const msg = String(error?.message || '');
const code = error?.code;
if (code === 'ENOENT' || /codex/i.test(msg)) {
const enhancedError = new Error(
`Codex CLI not available. Please install Codex CLI first. Original error: ${error.message}`
);
enhancedError.cause = error;
this.handleError('Codex CLI initialization', enhancedError);
} else {
this.handleError('client initialization', error);
}
}
}
}
```
--------------------------------------------------------------------------------
/tests/integration/profiles/roo-init-functionality.test.js:
--------------------------------------------------------------------------------
```javascript
import { jest } from '@jest/globals';
import fs from 'fs';
import path from 'path';
import { rooProfile } from '../../../src/profiles/roo.js';
import { COMMON_TOOL_MAPPINGS } from '../../../src/profiles/base-profile.js';
describe('Roo Profile Initialization Functionality', () => {
let rooProfileContent;
beforeAll(() => {
// Read the roo.js profile file content once for all tests
const rooJsPath = path.join(process.cwd(), 'src', 'profiles', 'roo.js');
rooProfileContent = fs.readFileSync(rooJsPath, 'utf8');
});
test('roo.js uses factory pattern with correct configuration', () => {
// Check for explicit, non-default values in the source file
expect(rooProfileContent).toContain("name: 'roo'");
expect(rooProfileContent).toContain("displayName: 'Roo Code'");
expect(rooProfileContent).toContain(
'toolMappings: COMMON_TOOL_MAPPINGS.ROO_STYLE'
);
// Check the final computed properties on the profile object
expect(rooProfile.profileName).toBe('roo');
expect(rooProfile.displayName).toBe('Roo Code');
expect(rooProfile.profileDir).toBe('.roo'); // default
expect(rooProfile.rulesDir).toBe('.roo/rules'); // default
expect(rooProfile.mcpConfig).toBe(true); // now uses standard MCP configuration with Roo enhancements
});
test('roo.js uses custom ROO_STYLE tool mappings', () => {
// Check that the profile uses the correct, non-standard tool mappings
expect(rooProfileContent).toContain(
'toolMappings: COMMON_TOOL_MAPPINGS.ROO_STYLE'
);
// Verify the result: roo uses custom tool names
expect(rooProfile.conversionConfig.toolNames.edit_file).toBe('apply_diff');
expect(rooProfile.conversionConfig.toolNames.search).toBe('search_files');
});
test('roo.js profile ensures Roo directory structure via onAddRulesProfile', () => {
// Check if onAddRulesProfile function exists
expect(rooProfileContent).toContain(
'onAddRulesProfile(targetDir, assetsDir)'
);
// Check for the general copy of assets/roocode which includes .roo base structure
expect(rooProfileContent).toContain(
"const sourceDir = path.join(assetsDir, 'roocode');"
);
expect(rooProfileContent).toContain(
'copyRecursiveSync(sourceDir, targetDir);'
);
// Check for the specific .roo modes directory handling
expect(rooProfileContent).toContain(
"const rooModesDir = path.join(sourceDir, '.roo');"
);
// Check for import of ROO_MODES from profiles.js instead of local definition
expect(rooProfileContent).toContain(
"import { ROO_MODES } from '../constants/profiles.js';"
);
});
test('roo.js profile copies .roomodes file via onAddRulesProfile', () => {
expect(rooProfileContent).toContain(
'onAddRulesProfile(targetDir, assetsDir)'
);
// Check for the specific .roomodes copy logic
expect(rooProfileContent).toContain(
"const roomodesSrc = path.join(sourceDir, '.roomodes');"
);
expect(rooProfileContent).toContain(
"const roomodesDest = path.join(targetDir, '.roomodes');"
);
expect(rooProfileContent).toContain(
'fs.copyFileSync(roomodesSrc, roomodesDest);'
);
});
test('roo.js profile copies mode-specific rule files via onAddRulesProfile', () => {
expect(rooProfileContent).toContain(
'onAddRulesProfile(targetDir, assetsDir)'
);
expect(rooProfileContent).toContain('for (const mode of ROO_MODES)');
// Check for the specific mode rule file copy logic
expect(rooProfileContent).toContain(
'const src = path.join(rooModesDir, `rules-${mode}`, `${mode}-rules`);'
);
expect(rooProfileContent).toContain(
"const dest = path.join(targetDir, '.roo', `rules-${mode}`, `${mode}-rules`);"
);
});
});
```
--------------------------------------------------------------------------------
/mcp-server/src/core/direct-functions/update-tasks.js:
--------------------------------------------------------------------------------
```javascript
/**
* update-tasks.js
* Direct function implementation for updating tasks based on new context
*/
import path from 'path';
import { updateTasks } from '../../../../scripts/modules/task-manager.js';
import { createLogWrapper } from '../../tools/utils.js';
import {
enableSilentMode,
disableSilentMode
} from '../../../../scripts/modules/utils.js';
/**
* Direct function wrapper for updating tasks based on new context.
*
* @param {Object} args - Command arguments containing projectRoot, from, prompt, research options.
* @param {string} args.from - The ID of the task to update.
* @param {string} args.prompt - The prompt to update the task with.
* @param {boolean} args.research - Whether to use research mode.
* @param {string} args.tasksJsonPath - Path to the tasks.json file.
* @param {string} args.projectRoot - Project root path (for MCP/env fallback)
* @param {string} args.tag - Tag for the task (optional)
* @param {Object} log - Logger object.
* @param {Object} context - Context object containing session data.
* @returns {Promise<Object>} - Result object with success status and data/error information.
*/
export async function updateTasksDirect(args, log, context = {}) {
const { session } = context;
const { from, prompt, research, tasksJsonPath, projectRoot, tag } = args;
// Create the standard logger wrapper
const logWrapper = createLogWrapper(log);
// --- Input Validation ---
if (!projectRoot) {
logWrapper.error('updateTasksDirect requires a projectRoot argument.');
return {
success: false,
error: {
code: 'MISSING_ARGUMENT',
message: 'projectRoot is required.'
}
};
}
if (!from) {
logWrapper.error('updateTasksDirect called without from ID');
return {
success: false,
error: {
code: 'MISSING_ARGUMENT',
message: 'Starting task ID (from) is required'
}
};
}
if (!prompt) {
logWrapper.error('updateTasksDirect called without prompt');
return {
success: false,
error: {
code: 'MISSING_ARGUMENT',
message: 'Update prompt is required'
}
};
}
logWrapper.info(
`Updating tasks via direct function. From: ${from}, Research: ${research}, File: ${tasksJsonPath}, ProjectRoot: ${projectRoot}`
);
enableSilentMode(); // Enable silent mode
try {
// Call the core updateTasks function
const result = await updateTasks(
tasksJsonPath,
from,
prompt,
research,
{
session,
mcpLog: logWrapper,
projectRoot,
tag
},
'json'
);
if (result && result.success && Array.isArray(result.updatedTasks)) {
logWrapper.success(
`Successfully updated ${result.updatedTasks.length} tasks.`
);
return {
success: true,
data: {
message: `Successfully updated ${result.updatedTasks.length} tasks.`,
tasksPath: tasksJsonPath,
updatedCount: result.updatedTasks.length,
telemetryData: result.telemetryData,
tagInfo: result.tagInfo
}
};
} else {
// Handle case where core function didn't return expected success structure
logWrapper.error(
'Core updateTasks function did not return a successful structure.'
);
return {
success: false,
error: {
code: 'CORE_FUNCTION_ERROR',
message:
result?.message ||
'Core function failed to update tasks or returned unexpected result.'
}
};
}
} catch (error) {
logWrapper.error(`Error executing core updateTasks: ${error.message}`);
return {
success: false,
error: {
code: 'UPDATE_TASKS_CORE_ERROR',
message: error.message || 'Unknown error updating tasks'
}
};
} finally {
disableSilentMode(); // Ensure silent mode is disabled
}
}
```
--------------------------------------------------------------------------------
/src/prompts/update-tasks.json:
--------------------------------------------------------------------------------
```json
{
"id": "update-tasks",
"version": "1.0.0",
"description": "Update multiple tasks based on new context or changes",
"metadata": {
"author": "system",
"created": "2024-01-01T00:00:00Z",
"updated": "2024-01-01T00:00:00Z",
"tags": ["update", "bulk", "context-change"]
},
"parameters": {
"tasks": {
"type": "array",
"required": true,
"description": "Array of tasks to update"
},
"updatePrompt": {
"type": "string",
"required": true,
"description": "Description of changes to apply"
},
"useResearch": {
"type": "boolean",
"default": false,
"description": "Use research mode"
},
"projectContext": {
"type": "string",
"description": "Additional project context"
},
"hasCodebaseAnalysis": {
"type": "boolean",
"required": false,
"default": false,
"description": "Whether codebase analysis is available"
},
"projectRoot": {
"type": "string",
"required": false,
"default": "",
"description": "Project root path for context"
}
},
"prompts": {
"default": {
"system": "You are an AI assistant helping to update software development tasks based on new context.\nYou will be given a set of tasks and a prompt describing changes or new implementation details.\nYour job is to update the tasks to reflect these changes, while preserving their basic structure.\n\nGuidelines:\n1. Maintain the same IDs, statuses, and dependencies unless specifically mentioned in the prompt\n2. Update titles, descriptions, details, and test strategies to reflect the new information\n3. Do not change anything unnecessarily - just adapt what needs to change based on the prompt\n4. Return ALL the tasks in order, not just the modified ones\n5. VERY IMPORTANT: Preserve all subtasks marked as \"done\" or \"completed\" - do not modify their content\n6. For tasks with completed subtasks, build upon what has already been done rather than rewriting everything\n7. If an existing completed subtask needs to be changed/undone based on the new context, DO NOT modify it directly\n8. Instead, add a new subtask that clearly indicates what needs to be changed or replaced\n9. Use the existence of completed subtasks as an opportunity to make new subtasks more specific and targeted",
"user": "{{#if hasCodebaseAnalysis}}## IMPORTANT: Codebase Analysis Required\n\nYou have access to powerful codebase analysis tools. Before updating tasks:\n\n1. Use the Glob tool to explore the project structure (e.g., \"**/*.js\", \"**/*.json\", \"**/README.md\")\n2. Use the Grep tool to search for existing implementations, patterns, and technologies\n3. Use the Read tool to examine relevant files and understand current implementation\n4. Analyze how the new changes relate to the existing codebase\n\nBased on your analysis:\n- Update task details to reference specific files, functions, or patterns from the codebase\n- Ensure implementation details align with the project's current architecture\n- Include specific code examples or file references where appropriate\n- Consider how changes impact existing components\n\nProject Root: {{projectRoot}}\n\n{{/if}}Here are the tasks to update:\n{{{json tasks}}}\n\nPlease update these tasks based on the following new context:\n{{updatePrompt}}\n\nIMPORTANT: In the tasks above, any subtasks with \"status\": \"done\" or \"status\": \"completed\" should be preserved exactly as is. Build your changes around these completed items.{{#if projectContext}}\n\n# Project Context\n\n{{projectContext}}{{/if}}\n\nIMPORTANT: Your response must be a JSON object with a single property named \"tasks\" containing the updated array of tasks."
}
}
}
```
--------------------------------------------------------------------------------
/tests/unit/ai-providers/zai-provider.test.js:
--------------------------------------------------------------------------------
```javascript
import { jest } from '@jest/globals';
// Mock the OpenAI-compatible creation
const mockCreateOpenAICompatible = jest.fn(() => jest.fn());
jest.unstable_mockModule('@ai-sdk/openai-compatible', () => ({
createOpenAICompatible: mockCreateOpenAICompatible
}));
// Mock utils
jest.unstable_mockModule('../../../scripts/modules/utils.js', () => ({
log: jest.fn(),
resolveEnvVariable: jest.fn((key) => process.env[key]),
findProjectRoot: jest.fn(() => process.cwd()),
isEmpty: jest.fn(() => false)
}));
jest.unstable_mockModule('../../../scripts/modules/config-manager.js', () => ({
isProxyEnabled: jest.fn(() => false)
}));
// Import after mocking
const { ZAIProvider } = await import('../../../src/ai-providers/zai.js');
const { ZAICodingProvider } = await import(
'../../../src/ai-providers/zai-coding.js'
);
describe('ZAI Provider', () => {
let provider;
beforeEach(() => {
jest.clearAllMocks();
provider = new ZAIProvider();
});
describe('Configuration', () => {
it('should have correct base configuration', () => {
expect(provider.name).toBe('Z.ai');
expect(provider.apiKeyEnvVar).toBe('ZAI_API_KEY');
expect(provider.requiresApiKey).toBe(true);
expect(provider.defaultBaseURL).toBe('https://api.z.ai/api/paas/v4/');
expect(provider.supportsStructuredOutputs).toBe(true);
});
});
describe('Token Parameter Handling', () => {
it('should not include max_tokens in requests', () => {
// ZAI API rejects max_tokens parameter (error code 1210)
const result = provider.prepareTokenParam('glm-4.6', 2000);
// Should return empty object instead of { maxOutputTokens: 2000 }
expect(result).toEqual({});
});
it('should return empty object even with undefined maxTokens', () => {
const result = provider.prepareTokenParam('glm-4.6', undefined);
expect(result).toEqual({});
});
it('should return empty object even with very large maxTokens', () => {
// ZAI may have lower limits than other providers
const result = provider.prepareTokenParam('glm-4.6', 204800);
expect(result).toEqual({});
});
});
describe('API Key Handling', () => {
it('should require API key', () => {
expect(provider.isRequiredApiKey()).toBe(true);
expect(provider.getRequiredApiKeyName()).toBe('ZAI_API_KEY');
});
it('should validate when API key is missing', () => {
expect(() => provider.validateAuth({})).toThrow(
'Z.ai API key is required'
);
});
it('should pass validation when API key is provided', () => {
expect(() => provider.validateAuth({ apiKey: 'test-key' })).not.toThrow();
});
});
});
describe('ZAI Coding Provider', () => {
let provider;
beforeEach(() => {
jest.clearAllMocks();
provider = new ZAICodingProvider();
});
describe('Configuration', () => {
it('should have correct base configuration', () => {
expect(provider.name).toBe('Z.ai (Coding Plan)');
expect(provider.apiKeyEnvVar).toBe('ZAI_API_KEY');
expect(provider.requiresApiKey).toBe(true);
expect(provider.defaultBaseURL).toBe(
'https://api.z.ai/api/coding/paas/v4/'
);
expect(provider.supportsStructuredOutputs).toBe(true);
});
});
describe('Token Parameter Handling', () => {
it('should not include max_tokens in requests', () => {
// ZAI Coding API also rejects max_tokens parameter
const result = provider.prepareTokenParam('glm-4.6', 2000);
// Should return empty object instead of { maxOutputTokens: 2000 }
expect(result).toEqual({});
});
it('should return empty object even with undefined maxTokens', () => {
const result = provider.prepareTokenParam('glm-4.6', undefined);
expect(result).toEqual({});
});
});
});
```
--------------------------------------------------------------------------------
/mcp-server/src/core/direct-functions/models.js:
--------------------------------------------------------------------------------
```javascript
/**
* models.js
* Direct function for managing AI model configurations via MCP
*/
import {
getModelConfiguration,
getAvailableModelsList,
setModel
} from '../../../../scripts/modules/task-manager/models.js';
import {
enableSilentMode,
disableSilentMode
} from '../../../../scripts/modules/utils.js';
import { createLogWrapper } from '../../tools/utils.js';
import { CUSTOM_PROVIDERS_ARRAY } from '@tm/core';
// Define supported roles for model setting
const MODEL_ROLES = ['main', 'research', 'fallback'];
/**
* Determine provider hint from custom provider flags
* @param {Object} args - Arguments containing provider flags
* @returns {string|undefined} Provider hint or undefined if no custom provider flag is set
*/
function getProviderHint(args) {
return CUSTOM_PROVIDERS_ARRAY.find((provider) => args[provider]);
}
/**
* Handle setting models for different roles
* @param {Object} args - Arguments containing role-specific model IDs
* @param {Object} context - Context object with session, mcpLog, projectRoot
* @returns {Object|null} Result if a model was set, null if no model setting was requested
*/
async function handleModelSetting(args, context) {
for (const role of MODEL_ROLES) {
const roleKey = `set${role.charAt(0).toUpperCase() + role.slice(1)}`; // setMain, setResearch, setFallback
if (args[roleKey]) {
const providerHint = getProviderHint(args);
return await setModel(role, args[roleKey], {
...context,
providerHint,
...(args.baseURL && { baseURL: args.baseURL })
});
}
}
return null; // No model setting was requested
}
/**
* Get or update model configuration
* @param {Object} args - Arguments passed by the MCP tool
* @param {Object} log - MCP logger
* @param {Object} context - MCP context (contains session)
* @returns {Object} Result object with success, data/error fields
*/
export async function modelsDirect(args, log, context = {}) {
const { session } = context;
const { projectRoot } = args; // Extract projectRoot from args
// Create a logger wrapper that the core functions can use
const mcpLog = createLogWrapper(log);
log.info(`Executing models_direct with args: ${JSON.stringify(args)}`);
log.info(`Using project root: ${projectRoot}`);
// Validate flags: only one custom provider flag can be used simultaneously
const customProviderFlags = CUSTOM_PROVIDERS_ARRAY.filter(
(provider) => args[provider]
);
if (customProviderFlags.length > 1) {
log.error(
'Error: Cannot use multiple custom provider flags simultaneously.'
);
return {
success: false,
error: {
code: 'INVALID_ARGS',
message:
'Cannot use multiple custom provider flags simultaneously. Choose only one: openrouter, ollama, bedrock, azure, vertex, or openai-compatible.'
}
};
}
try {
enableSilentMode();
try {
// Check for the listAvailableModels flag
if (args.listAvailableModels === true) {
return await getAvailableModelsList({
session,
mcpLog,
projectRoot
});
}
// Handle setting any model role using unified function
const modelContext = { session, mcpLog, projectRoot };
const modelSetResult = await handleModelSetting(args, modelContext);
if (modelSetResult) {
return modelSetResult;
}
// Default action: get current configuration
return await getModelConfiguration({
session,
mcpLog,
projectRoot
});
} finally {
disableSilentMode();
}
} catch (error) {
log.error(`Error in models_direct: ${error.message}`);
return {
success: false,
error: {
code: 'DIRECT_FUNCTION_ERROR',
message: error.message,
details: error.stack
}
};
}
}
```
--------------------------------------------------------------------------------
/apps/cli/src/ui/components/next-task.component.ts:
--------------------------------------------------------------------------------
```typescript
/**
* @fileoverview Next task recommendation component
* Displays detailed information about the recommended next task
*/
import type { Task } from '@tm/core';
import boxen from 'boxen';
import chalk from 'chalk';
import { getBoxWidth, getComplexityWithColor } from '../../utils/ui.js';
/**
* Next task display options
*/
export interface NextTaskDisplayOptions {
id: string | number;
title: string;
priority?: string;
status?: string;
dependencies?: (string | number)[];
description?: string;
complexity?: number;
}
/**
* Display the recommended next task section
*/
export function displayRecommendedNextTask(
task: NextTaskDisplayOptions | undefined
): void {
if (!task) {
// If no task available, show a message
console.log(
boxen(
chalk.yellow(
'No tasks available to work on. All tasks are either completed, blocked by dependencies, or in progress.'
),
{
padding: 1,
borderStyle: 'round',
borderColor: 'yellow',
title: '⚠️ NO TASKS AVAILABLE ⚠️',
titleAlignment: 'center'
}
)
);
return;
}
// Build the content for the next task box
const content = [];
// Task header with ID and title
content.push(
`🔥 ${chalk.hex('#FF8800').bold('Next Task to Work On:')} ${chalk.yellow(`#${task.id}`)}${chalk.hex('#FF8800').bold(` - ${task.title}`)}`
);
content.push('');
// Priority and Status line
const statusLine = [];
if (task.priority) {
const priorityColor =
task.priority === 'high'
? chalk.red
: task.priority === 'medium'
? chalk.yellow
: chalk.gray;
statusLine.push(`Priority: ${priorityColor.bold(task.priority)}`);
}
if (task.status) {
const statusDisplay =
task.status === 'pending'
? chalk.yellow('○ pending')
: task.status === 'in-progress'
? chalk.blue('▶ in-progress')
: chalk.gray(task.status);
statusLine.push(`Status: ${statusDisplay}`);
}
content.push(statusLine.join(' '));
// Dependencies
const depsDisplay =
!task.dependencies || task.dependencies.length === 0
? chalk.gray('None')
: chalk.cyan(task.dependencies.join(', '));
content.push(`Dependencies: ${depsDisplay}`);
// Complexity with color and label
if (typeof task.complexity === 'number') {
content.push(`Complexity: ${getComplexityWithColor(task.complexity)}`);
}
// Description if available
if (task.description) {
content.push('');
content.push(`Description: ${chalk.white(task.description)}`);
}
// Action commands
content.push('');
content.push(
`${chalk.cyan('Start working:')} ${chalk.yellow(`task-master set-status --id=${task.id} --status=in-progress`)}`
);
content.push(
`${chalk.cyan('View details:')} ${chalk.yellow(`task-master show ${task.id}`)}`
);
// Display in a styled box with orange border
console.log(
boxen(content.join('\n'), {
padding: 1,
margin: { top: 1, bottom: 1 },
borderStyle: 'round',
borderColor: '#FFA500', // Orange color
title: chalk.hex('#FFA500')('⚡ RECOMMENDED NEXT TASK ⚡'),
titleAlignment: 'center',
width: getBoxWidth(0.97),
fullscreen: false
})
);
}
/**
* Get task description from the full task object
*/
export function getTaskDescription(task: Task): string | undefined {
// Try to get description from the task
// This could be from task.description or the first line of task.details
if ('description' in task && task.description) {
return task.description as string;
}
if ('details' in task && task.details) {
// Take first sentence or line from details
const details = task.details as string;
const firstLine = details.split('\n')[0];
const firstSentence = firstLine.split('.')[0];
return firstSentence;
}
return undefined;
}
```
--------------------------------------------------------------------------------
/scripts/modules/task-manager/clear-subtasks.js:
--------------------------------------------------------------------------------
```javascript
import path from 'path';
import chalk from 'chalk';
import boxen from 'boxen';
import Table from 'cli-table3';
import { log, readJSON, writeJSON, truncate, isSilentMode } from '../utils.js';
import { displayBanner } from '../ui.js';
/**
* Clear subtasks from specified tasks
* @param {string} tasksPath - Path to the tasks.json file
* @param {string} taskIds - Task IDs to clear subtasks from
* @param {Object} context - Context object containing projectRoot and tag
* @param {string} [context.projectRoot] - Project root path
* @param {string} [context.tag] - Tag for the task
*/
function clearSubtasks(tasksPath, taskIds, context = {}) {
const { projectRoot, tag } = context;
log('info', `Reading tasks from ${tasksPath}...`);
const data = readJSON(tasksPath, projectRoot, tag);
if (!data || !data.tasks) {
log('error', 'No valid tasks found.');
process.exit(1);
}
if (!isSilentMode()) {
console.log(
boxen(chalk.white.bold('Clearing Subtasks'), {
padding: 1,
borderColor: 'blue',
borderStyle: 'round',
margin: { top: 1, bottom: 1 }
})
);
}
// Handle multiple task IDs (comma-separated)
const taskIdArray = taskIds.split(',').map((id) => id.trim());
let clearedCount = 0;
// Create a summary table for the cleared subtasks
const summaryTable = new Table({
head: [
chalk.cyan.bold('Task ID'),
chalk.cyan.bold('Task Title'),
chalk.cyan.bold('Subtasks Cleared')
],
colWidths: [10, 50, 20],
style: { head: [], border: [] }
});
taskIdArray.forEach((taskId) => {
const id = parseInt(taskId, 10);
if (Number.isNaN(id)) {
log('error', `Invalid task ID: ${taskId}`);
return;
}
const task = data.tasks.find((t) => t.id === id);
if (!task) {
log('error', `Task ${id} not found`);
return;
}
if (!task.subtasks || task.subtasks.length === 0) {
log('info', `Task ${id} has no subtasks to clear`);
summaryTable.push([
id.toString(),
truncate(task.title, 47),
chalk.yellow('No subtasks')
]);
return;
}
const subtaskCount = task.subtasks.length;
task.subtasks = [];
clearedCount++;
log('info', `Cleared ${subtaskCount} subtasks from task ${id}`);
summaryTable.push([
id.toString(),
truncate(task.title, 47),
chalk.green(`${subtaskCount} subtasks cleared`)
]);
});
if (clearedCount > 0) {
writeJSON(tasksPath, data, projectRoot, tag);
// Show summary table
if (!isSilentMode()) {
console.log(
boxen(chalk.white.bold('Subtask Clearing Summary:'), {
padding: { left: 2, right: 2, top: 0, bottom: 0 },
margin: { top: 1, bottom: 0 },
borderColor: 'blue',
borderStyle: 'round'
})
);
console.log(summaryTable.toString());
}
// Success message
if (!isSilentMode()) {
console.log(
boxen(
chalk.green(
`Successfully cleared subtasks from ${chalk.bold(clearedCount)} task(s)`
),
{
padding: 1,
borderColor: 'green',
borderStyle: 'round',
margin: { top: 1 }
}
)
);
// Next steps suggestion
console.log(
boxen(
chalk.white.bold('Next Steps:') +
'\n\n' +
`${chalk.cyan('1.')} Run ${chalk.yellow('task-master expand --id=<id>')} to generate new subtasks\n` +
`${chalk.cyan('2.')} Run ${chalk.yellow('task-master list --with-subtasks')} to verify changes`,
{
padding: 1,
borderColor: 'cyan',
borderStyle: 'round',
margin: { top: 1 }
}
)
);
}
} else {
if (!isSilentMode()) {
console.log(
boxen(chalk.yellow('No subtasks were cleared'), {
padding: 1,
borderColor: 'yellow',
borderStyle: 'round',
margin: { top: 1 }
})
);
}
}
}
export default clearSubtasks;
```
--------------------------------------------------------------------------------
/.taskmaster/docs/prd-tm-start.txt:
--------------------------------------------------------------------------------
```
<context>
# Overview
Add a new CLI command: `task-master start <task_id>` (alias: `tm start <task_id>`). This command hard-codes `claude-code` as the executor, fetches task details, builds a standardized prompt, runs claude-code, shows the result, checks for git changes, and auto-marks the task as done if successful.
We follow the Commander class pattern, reuse task retrieval from `show` command flow. Extremely minimal for 1-hour hackathon timeline.
# Core Features
- `start` command (Commander class style)
- Hard-coded executor: `claude-code`
- Standardized prompt designed for minimal changes following existing patterns
- Shows claude-code output (no streaming)
- Git status check for success detection
- Auto-mark task done if successful
# User Experience
```
task-master start 12
```
1) Fetches Task #12 details
2) Builds standardized prompt with task context
3) Runs claude-code with the prompt
4) Shows output
5) Checks git status for changes
6) Auto-marks task done if changes detected
</context>
<PRD>
# Technical Architecture
- Command pattern:
- Create `apps/cli/src/commands/start.command.ts` modeled on [list.command.ts](mdc:apps/cli/src/commands/list.command.ts) and task lookup from [show.command.ts](mdc:apps/cli/src/commands/show.command.ts)
- Task retrieval:
- Use `@tm/core` via `createTaskMasterCore` to get task by ID
- Extract: id, title, description, details
- Executor (ultra-simple approach):
- Execute `claude "full prompt here"` command directly
- The prompt tells Claude to first run `tm show <task_id>` to get task details
- Then tells Claude to implement the code changes
- This opens Claude CLI interface naturally in the current terminal
- No subprocess management needed - just execute the command
- Execution flow:
1) Validate `<task_id>` exists; exit with error if not
2) Build standardized prompt that includes instructions to run `tm show <task_id>`
3) Execute `claude "prompt"` command directly in terminal
4) Claude CLI opens, runs `tm show`, then implements changes
5) After Claude session ends, run `git status --porcelain` to detect changes
6) If changes detected, auto-run `task-master set-status --id=<task_id> --status=done`
- Success criteria:
- Success = exit code 0 AND git shows modified/created files
- Print changed file paths; warn if no changes detected
# Development Roadmap
MVP (ship in ~1 hour):
1) Implement `start.command.ts` (Commander class), parse `<task_id>`
2) Validate task exists via tm-core
3) Build prompt that tells Claude to run `tm show <task_id>` then implement
4) Execute `claude "prompt"` command, then check git status and auto-mark done
# Risks and Mitigations
- Executor availability: Error clearly if `claude-code` provider fails
- False success: Git-change heuristic acceptable for hackathon MVP
# Appendix
**Standardized Prompt Template:**
```
You are an AI coding assistant with access to this repository's codebase.
First, run this command to get the task details:
tm show <task_id>
Then implement the task with these requirements:
- Make the SMALLEST number of code changes possible
- Follow ALL existing patterns in the codebase (you have access to analyze the code)
- Do NOT over-engineer the solution
- Use existing files/functions/patterns wherever possible
- When complete, print: COMPLETED: <brief summary of changes>
Begin by running tm show <task_id> to understand what needs to be implemented.
```
**Key References:**
- [list.command.ts](mdc:apps/cli/src/commands/list.command.ts) - Command structure
- [show.command.ts](mdc:apps/cli/src/commands/show.command.ts) - Task validation
- Node.js `child_process.exec()` - For executing `claude "prompt"` command
</PRD>
```
--------------------------------------------------------------------------------
/packages/tm-core/src/subpath-exports.test.ts:
--------------------------------------------------------------------------------
```typescript
/**
* Test file documenting subpath export usage
* This demonstrates how consumers can use granular imports for better tree-shaking
*/
import { describe, expect, it } from 'vitest';
describe('Subpath Exports', () => {
it('should allow importing from auth subpath', async () => {
// Instead of: import { AuthManager } from '@tm/core';
// Use: import { AuthManager } from '@tm/core/auth';
const authModule = await import('./auth');
expect(authModule.AuthManager).toBeDefined();
expect(authModule.AuthenticationError).toBeDefined();
});
it('should allow importing from storage subpath', async () => {
// Instead of: import { FileStorage } from '@tm/core';
// Use: import { FileStorage } from '@tm/core/storage';
const storageModule = await import('./storage');
expect(storageModule.FileStorage).toBeDefined();
expect(storageModule.ApiStorage).toBeDefined();
expect(storageModule.StorageFactory).toBeDefined();
});
it('should allow importing from config subpath', async () => {
// Instead of: import { ConfigManager } from '@tm/core';
// Use: import { ConfigManager } from '@tm/core/config';
const configModule = await import('./config');
expect(configModule.ConfigManager).toBeDefined();
});
it('should allow importing from errors subpath', async () => {
// Instead of: import { TaskMasterError } from '@tm/core';
// Use: import { TaskMasterError } from '@tm/core/errors';
const errorsModule = await import('./errors');
expect(errorsModule.TaskMasterError).toBeDefined();
expect(errorsModule.ERROR_CODES).toBeDefined();
});
it('should allow importing from logger subpath', async () => {
// Instead of: import { getLogger } from '@tm/core';
// Use: import { getLogger } from '@tm/core/logger';
const loggerModule = await import('./logger');
expect(loggerModule.getLogger).toBeDefined();
expect(loggerModule.createLogger).toBeDefined();
});
it('should allow importing from providers subpath', async () => {
// Instead of: import { BaseProvider } from '@tm/core';
// Use: import { BaseProvider } from '@tm/core/providers';
const providersModule = await import('./providers');
expect(providersModule.BaseProvider).toBeDefined();
});
it('should allow importing from services subpath', async () => {
// Instead of: import { TaskService } from '@tm/core';
// Use: import { TaskService } from '@tm/core/services';
const servicesModule = await import('./services');
expect(servicesModule.TaskService).toBeDefined();
});
it('should allow importing from utils subpath', async () => {
// Instead of: import { generateId } from '@tm/core';
// Use: import { generateId } from '@tm/core/utils';
const utilsModule = await import('./utils');
expect(utilsModule.generateId).toBeDefined();
});
});
/**
* Usage Examples for Consumers:
*
* 1. Import only authentication (smaller bundle):
* ```typescript
* import { AuthManager, AuthenticationError } from '@tm/core/auth';
* ```
*
* 2. Import only storage (no auth code bundled):
* ```typescript
* import { FileStorage, StorageFactory } from '@tm/core/storage';
* ```
*
* 3. Import only errors (minimal bundle):
* ```typescript
* import { TaskMasterError, ERROR_CODES } from '@tm/core/errors';
* ```
*
* 4. Still support convenience imports (larger bundle but better DX):
* ```typescript
* import { AuthManager, FileStorage, TaskMasterError } from '@tm/core';
* ```
*
* Benefits:
* - Better tree-shaking: unused modules are not bundled
* - Clearer dependencies: explicit about what parts of the library you use
* - Faster builds: bundlers can optimize better with granular imports
* - Smaller bundles: especially important for browser/edge deployments
*/
```
--------------------------------------------------------------------------------
/src/prompts/research.json:
--------------------------------------------------------------------------------
```json
{
"id": "research",
"version": "1.0.0",
"description": "Perform AI-powered research with project context",
"metadata": {
"author": "system",
"created": "2024-01-01T00:00:00Z",
"updated": "2024-01-01T00:00:00Z",
"tags": ["research", "context-aware", "information-gathering"]
},
"parameters": {
"query": {
"type": "string",
"required": true,
"description": "Research query"
},
"gatheredContext": {
"type": "string",
"default": "",
"description": "Gathered project context"
},
"detailLevel": {
"type": "string",
"enum": ["low", "medium", "high"],
"default": "medium",
"description": "Level of detail for the response"
},
"projectInfo": {
"type": "object",
"description": "Project information",
"properties": {
"root": {
"type": "string",
"description": "Project root path"
},
"taskCount": {
"type": "number",
"description": "Number of related tasks"
},
"fileCount": {
"type": "number",
"description": "Number of related files"
}
}
}
},
"prompts": {
"default": {
"system": "You are an expert AI research assistant helping with a software development project. You have access to project context including tasks, files, and project structure.\n\nYour role is to provide comprehensive, accurate, and actionable research responses based on the user's query and the provided project context.\n{{#if (eq detailLevel \"low\")}}\n**Response Style: Concise & Direct**\n- Provide brief, focused answers (2-4 paragraphs maximum)\n- Focus on the most essential information\n- Use bullet points for key takeaways\n- Avoid lengthy explanations unless critical\n- Skip pleasantries, introductions, and conclusions\n- No phrases like \"Based on your project context\" or \"I'll provide guidance\"\n- No summary outros or alignment statements\n- Get straight to the actionable information\n- Use simple, direct language - users want info, not explanation{{/if}}{{#if (eq detailLevel \"medium\")}}\n**Response Style: Balanced & Comprehensive**\n- Provide thorough but well-structured responses (4-8 paragraphs)\n- Include relevant examples and explanations\n- Balance depth with readability\n- Use headings and bullet points for organization{{/if}}{{#if (eq detailLevel \"high\")}}\n**Response Style: Detailed & Exhaustive**\n- Provide comprehensive, in-depth analysis (8+ paragraphs)\n- Include multiple perspectives and approaches\n- Provide detailed examples, code snippets, and step-by-step guidance\n- Cover edge cases and potential pitfalls\n- Use clear structure with headings, subheadings, and lists{{/if}}\n\n**Guidelines:**\n- Always consider the project context when formulating responses\n- Reference specific tasks, files, or project elements when relevant\n- Provide actionable insights that can be applied to the project\n- If the query relates to existing project tasks, suggest how the research applies to those tasks\n- Use markdown formatting for better readability\n- Be precise and avoid speculation unless clearly marked as such\n{{#if (eq detailLevel \"low\")}}\n**For LOW detail level specifically:**\n- Start immediately with the core information\n- No introductory phrases or context acknowledgments\n- No concluding summaries or project alignment statements\n- Focus purely on facts, steps, and actionable items{{/if}}",
"user": "# Research Query\n\n{{query}}\n{{#if gatheredContext}}\n\n# Project Context\n\n{{gatheredContext}}\n{{/if}}\n\n# Instructions\n\nPlease research and provide a {{detailLevel}}-detail response to the query above. Consider the project context provided and make your response as relevant and actionable as possible for this specific project."
}
}
}
```
--------------------------------------------------------------------------------
/packages/tm-bridge/src/use-tag-bridge.ts:
--------------------------------------------------------------------------------
```typescript
import boxen from 'boxen';
import chalk from 'chalk';
import ora from 'ora';
import type { BaseBridgeParams } from './bridge-types.js';
import { checkStorageType } from './bridge-utils.js';
/**
* Parameters for the use-tag bridge function
*/
export interface UseTagBridgeParams extends BaseBridgeParams {
/** Tag name to switch to */
tagName: string;
}
/**
* Result returned when API storage handles the tag switch
*/
export interface RemoteUseTagResult {
success: boolean;
previousTag: string | null;
currentTag: string;
switched: boolean;
taskCount: number;
message: string;
}
/**
* Shared bridge function for use-tag command.
* Checks if using API storage and delegates to remote service if so.
*
* For API storage, tags are called "briefs" and switching tags means
* changing the current brief context.
*
* @param params - Bridge parameters
* @returns Result object if API storage handled it, null if should fall through to file storage
*/
export async function tryUseTagViaRemote(
params: UseTagBridgeParams
): Promise<RemoteUseTagResult | null> {
const {
tagName,
projectRoot,
isMCP = false,
outputFormat = 'text',
report
} = params;
// Check storage type using shared utility
const { isApiStorage, tmCore } = await checkStorageType(
projectRoot,
report,
'falling back to file-based tag switching'
);
if (!isApiStorage || !tmCore) {
// Not API storage - signal caller to fall through to file-based logic
return null;
}
// API STORAGE PATH: Switch brief in Hamster
report('info', `Switching to tag (brief) "${tagName}" in Hamster`);
// Show CLI output if not MCP
if (!isMCP && outputFormat === 'text') {
console.log(
boxen(chalk.blue.bold(`Switching Tag in Hamster`), {
padding: 1,
borderColor: 'blue',
borderStyle: 'round',
margin: { top: 1, bottom: 1 }
})
);
}
const spinner =
!isMCP && outputFormat === 'text'
? ora({ text: `Switching to tag "${tagName}"...`, color: 'cyan' }).start()
: null;
try {
// Get current context before switching
const previousContext = tmCore.auth.getContext();
const previousTag = previousContext?.briefName || null;
// Switch to the new tag/brief
// This will look up the brief by name and update the context
await tmCore.tasks.switchTag(tagName);
// Get updated context after switching
const newContext = tmCore.auth.getContext();
const currentTag = newContext?.briefName || tagName;
// Get task count for the new tag
const tasks = await tmCore.tasks.list();
const taskCount = tasks.tasks.length;
if (spinner) {
spinner.succeed(`Switched to tag "${currentTag}"`);
}
if (outputFormat === 'text' && !isMCP) {
// Display success message
const briefId = newContext?.briefId
? newContext.briefId.slice(-8)
: 'unknown';
console.log(
boxen(
chalk.green.bold('✓ Tag Switched Successfully') +
'\n\n' +
(previousTag
? chalk.white(`Previous Tag: ${chalk.cyan(previousTag)}\n`)
: '') +
chalk.white(`Current Tag: ${chalk.green.bold(currentTag)}`) +
'\n' +
chalk.gray(`Brief ID: ${briefId}`) +
'\n' +
chalk.white(`Available Tasks: ${chalk.yellow(taskCount)}`),
{
padding: 1,
borderColor: 'green',
borderStyle: 'round',
margin: { top: 1, bottom: 0 }
}
)
);
}
// Return success result - signals that we handled it
return {
success: true,
previousTag,
currentTag,
switched: true,
taskCount,
message: `Successfully switched to tag "${currentTag}"`
};
} catch (error) {
if (spinner) {
spinner.fail('Failed to switch tag');
}
// tm-core already formatted the error properly, just re-throw
throw error;
}
}
```
--------------------------------------------------------------------------------
/packages/tm-bridge/src/update-bridge.ts:
--------------------------------------------------------------------------------
```typescript
import boxen from 'boxen';
import chalk from 'chalk';
import ora from 'ora';
import type { BaseBridgeParams } from './bridge-types.js';
import { checkStorageType } from './bridge-utils.js';
/**
* Parameters for the update bridge function
*/
export interface UpdateBridgeParams extends BaseBridgeParams {
/** Task ID (can be numeric "1", alphanumeric "TAS-49", or dotted "1.2" or "TAS-49.1") */
taskId: string | number;
/** Update prompt for AI */
prompt: string;
/** Whether to append or full update (default: false) */
appendMode?: boolean;
}
/**
* Result returned when API storage handles the update
*/
export interface RemoteUpdateResult {
success: boolean;
taskId: string | number;
message: string;
telemetryData: null;
tagInfo: null;
}
/**
* Shared bridge function for update-task and update-subtask commands.
* Checks if using API storage and delegates to remote AI service if so.
*
* In API storage, tasks and subtasks are treated identically - there's no
* parent/child hierarchy, so update-task and update-subtask can be used
* interchangeably.
*
* @param params - Bridge parameters
* @returns Result object if API storage handled it, null if should fall through to file storage
*/
export async function tryUpdateViaRemote(
params: UpdateBridgeParams
): Promise<RemoteUpdateResult | null> {
const {
taskId,
prompt,
projectRoot,
tag,
appendMode = false,
isMCP = false,
outputFormat = 'text',
report
} = params;
// Check storage type using shared utility
const { isApiStorage, tmCore } = await checkStorageType(
projectRoot,
report,
'falling back to file-based update'
);
if (!isApiStorage || !tmCore) {
// Not API storage - signal caller to fall through to file-based logic
return null;
}
// API STORAGE PATH: Delegate to remote AI service
report('info', `Delegating update to Hamster for task ${taskId}`);
const mode = appendMode ? 'append' : 'update';
// Show CLI output if not MCP
if (!isMCP && outputFormat === 'text') {
const showDebug = process.env.TM_DEBUG === '1';
const promptPreview = showDebug
? `${prompt.substring(0, 60)}${prompt.length > 60 ? '...' : ''}`
: '[hidden]';
console.log(
boxen(
chalk.blue.bold(`Updating Task via Hamster`) +
'\n\n' +
chalk.white(`Task ID: ${taskId}`) +
'\n' +
chalk.white(`Mode: ${mode}`) +
'\n' +
chalk.white(`Prompt: ${promptPreview}`),
{
padding: 1,
borderColor: 'blue',
borderStyle: 'round',
margin: { top: 1, bottom: 1 }
}
)
);
}
const spinner =
!isMCP && outputFormat === 'text'
? ora({ text: 'Updating task on Hamster...', color: 'cyan' }).start()
: null;
try {
// Call the API storage method which handles the remote update
await tmCore.tasks.updateWithPrompt(String(taskId), prompt, tag, {
mode
});
if (spinner) {
spinner.succeed('Task updated successfully');
}
if (outputFormat === 'text') {
console.log(
boxen(
chalk.green(`Successfully updated task ${taskId} via remote AI`) +
'\n\n' +
chalk.white('The task has been updated on the remote server.') +
'\n' +
chalk.white(
`Run ${chalk.yellow(`task-master show ${taskId}`)} to view the updated task.`
),
{
padding: 1,
borderColor: 'green',
borderStyle: 'round'
}
)
);
}
// Return success result - signals that we handled it
return {
success: true,
taskId: taskId,
message: 'Task updated via remote AI service',
telemetryData: null,
tagInfo: null
};
} catch (updateError) {
if (spinner) {
spinner.fail('Update failed');
}
// tm-core already formatted the error properly, just re-throw
throw updateError;
}
}
```
--------------------------------------------------------------------------------
/apps/extension/src/webview/components/TagDropdown.tsx:
--------------------------------------------------------------------------------
```typescript
import React, { useState, useEffect, useRef } from 'react';
interface TagDropdownProps {
currentTag: string;
availableTags: string[];
onTagSwitch: (tagName: string) => Promise<void>;
sendMessage: (message: any) => Promise<any>;
dispatch: React.Dispatch<any>;
}
export const TagDropdown: React.FC<TagDropdownProps> = ({
currentTag,
availableTags,
onTagSwitch,
sendMessage,
dispatch
}) => {
const [isOpen, setIsOpen] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const dropdownRef = useRef<HTMLDivElement>(null);
// Fetch tags when component mounts
useEffect(() => {
fetchTags();
}, []);
// Handle click outside to close dropdown
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (
dropdownRef.current &&
!dropdownRef.current.contains(event.target as Node)
) {
setIsOpen(false);
}
};
if (isOpen) {
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}
}, [isOpen]);
const fetchTags = async () => {
try {
const result = await sendMessage({ type: 'getTags' });
if (result?.tags && result?.currentTag) {
const tagNames = result.tags.map((tag: any) => tag.name || tag);
dispatch({
type: 'SET_TAG_DATA',
payload: {
currentTag: result.currentTag,
availableTags: tagNames
}
});
}
} catch (error) {
console.error('Failed to fetch tags:', error);
}
};
const handleTagSwitch = async (tagName: string) => {
if (tagName === currentTag) {
setIsOpen(false);
return;
}
setIsLoading(true);
try {
await onTagSwitch(tagName);
dispatch({ type: 'SET_CURRENT_TAG', payload: tagName });
setIsOpen(false);
} catch (error) {
console.error('Failed to switch tag:', error);
} finally {
setIsLoading(false);
}
};
return (
<div className="relative" ref={dropdownRef}>
<button
onClick={() => setIsOpen(!isOpen)}
disabled={isLoading}
className="flex items-center gap-2 px-3 py-1.5 text-sm bg-vscode-dropdown-background text-vscode-dropdown-foreground border border-vscode-dropdown-border rounded hover:bg-vscode-list-hoverBackground transition-colors"
>
<span className="font-medium">{currentTag}</span>
<svg
className={`w-4 h-4 transition-transform ${isOpen ? 'rotate-180' : ''}`}
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M19 9l-7 7-7-7"
/>
</svg>
</button>
{isOpen && (
<div className="absolute top-full mt-1 right-0 bg-background border border-vscode-dropdown-border rounded shadow-lg z-50 min-w-[200px] py-1">
{availableTags.map((tag) => (
<button
key={tag}
onClick={() => handleTagSwitch(tag)}
className={`w-full text-left px-3 py-2 text-sm transition-colors flex items-center justify-between group
${
tag === currentTag
? 'bg-vscode-list-activeSelectionBackground text-vscode-list-activeSelectionForeground'
: 'hover:bg-vscode-list-hoverBackground text-vscode-dropdown-foreground'
}`}
>
<span className="truncate pr-2">{tag}</span>
{tag === currentTag && (
<svg
className="w-4 h-4 flex-shrink-0 text-vscode-textLink-foreground"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M5 13l4 4L19 7"
/>
</svg>
)}
</button>
))}
</div>
)}
</div>
);
};
```
--------------------------------------------------------------------------------
/tests/integration/profiles/opencode-init-functionality.test.js:
--------------------------------------------------------------------------------
```javascript
import fs from 'fs';
import path from 'path';
import { opencodeProfile } from '../../../src/profiles/opencode.js';
describe('OpenCode Profile Initialization Functionality', () => {
let opencodeProfileContent;
beforeAll(() => {
const opencodeJsPath = path.join(
process.cwd(),
'src',
'profiles',
'opencode.js'
);
opencodeProfileContent = fs.readFileSync(opencodeJsPath, 'utf8');
});
test('opencode.js has correct asset-only profile configuration', () => {
// Check for explicit, non-default values in the source file
expect(opencodeProfileContent).toContain("name: 'opencode'");
expect(opencodeProfileContent).toContain("displayName: 'OpenCode'");
expect(opencodeProfileContent).toContain("url: 'opencode.ai'");
expect(opencodeProfileContent).toContain("docsUrl: 'opencode.ai/docs/'");
expect(opencodeProfileContent).toContain("profileDir: '.'"); // non-default
expect(opencodeProfileContent).toContain("rulesDir: '.'"); // non-default
expect(opencodeProfileContent).toContain("mcpConfigName: 'opencode.json'"); // non-default
expect(opencodeProfileContent).toContain('includeDefaultRules: false'); // non-default
expect(opencodeProfileContent).toContain("'AGENTS.md': 'AGENTS.md'");
// Check the final computed properties on the profile object
expect(opencodeProfile.profileName).toBe('opencode');
expect(opencodeProfile.displayName).toBe('OpenCode');
expect(opencodeProfile.profileDir).toBe('.');
expect(opencodeProfile.rulesDir).toBe('.');
expect(opencodeProfile.mcpConfig).toBe(true); // computed from mcpConfigName
expect(opencodeProfile.mcpConfigName).toBe('opencode.json');
expect(opencodeProfile.mcpConfigPath).toBe('opencode.json'); // computed
expect(opencodeProfile.includeDefaultRules).toBe(false);
expect(opencodeProfile.fileMap['AGENTS.md']).toBe('AGENTS.md');
});
test('opencode.js has lifecycle functions for MCP config transformation', () => {
expect(opencodeProfileContent).toContain(
'function onPostConvertRulesProfile'
);
expect(opencodeProfileContent).toContain('function onRemoveRulesProfile');
expect(opencodeProfileContent).toContain('transformToOpenCodeFormat');
});
test('opencode.js handles opencode.json transformation in lifecycle functions', () => {
expect(opencodeProfileContent).toContain('opencode.json');
expect(opencodeProfileContent).toContain('transformToOpenCodeFormat');
expect(opencodeProfileContent).toContain('$schema');
expect(opencodeProfileContent).toContain('mcpServers');
expect(opencodeProfileContent).toContain('mcp');
});
test('opencode.js has proper error handling in lifecycle functions', () => {
expect(opencodeProfileContent).toContain('try {');
expect(opencodeProfileContent).toContain('} catch (error) {');
expect(opencodeProfileContent).toContain('log(');
});
test('opencode.js uses custom MCP config name', () => {
// OpenCode uses opencode.json instead of mcp.json
expect(opencodeProfileContent).toContain("mcpConfigName: 'opencode.json'");
// Should not contain mcp.json as a config value (comments are OK)
expect(opencodeProfileContent).not.toMatch(
/mcpConfigName:\s*['"]mcp\.json['"]/
);
});
test('opencode.js has transformation logic for OpenCode format', () => {
// Check for transformation function
expect(opencodeProfileContent).toContain('transformToOpenCodeFormat');
// Check for specific transformation logic
expect(opencodeProfileContent).toContain('mcpServers');
expect(opencodeProfileContent).toContain('command');
expect(opencodeProfileContent).toContain('args');
expect(opencodeProfileContent).toContain('environment');
expect(opencodeProfileContent).toContain('enabled');
expect(opencodeProfileContent).toContain('type');
});
});
```
--------------------------------------------------------------------------------
/packages/tm-core/src/modules/storage/adapters/file-storage/file-operations.ts:
--------------------------------------------------------------------------------
```typescript
/**
* @fileoverview File operations with atomic writes and locking
*/
import { constants } from 'node:fs';
import fs from 'node:fs/promises';
import type { FileStorageData } from './format-handler.js';
/**
* Handles atomic file operations with locking mechanism
*/
export class FileOperations {
private fileLocks: Map<string, Promise<void>> = new Map();
/**
* Read and parse JSON file
*/
async readJson(filePath: string): Promise<any> {
try {
const content = await fs.readFile(filePath, 'utf-8');
return JSON.parse(content);
} catch (error: any) {
if (error.code === 'ENOENT') {
throw error; // Re-throw ENOENT for caller to handle
}
if (error instanceof SyntaxError) {
throw new Error(`Invalid JSON in file ${filePath}: ${error.message}`);
}
throw new Error(`Failed to read file ${filePath}: ${error.message}`);
}
}
/**
* Write JSON file with atomic operation and locking
*/
async writeJson(
filePath: string,
data: FileStorageData | any
): Promise<void> {
// Use file locking to prevent concurrent writes
const lockKey = filePath;
const existingLock = this.fileLocks.get(lockKey);
if (existingLock) {
await existingLock;
}
const lockPromise = this.performAtomicWrite(filePath, data);
this.fileLocks.set(lockKey, lockPromise);
try {
await lockPromise;
} finally {
this.fileLocks.delete(lockKey);
}
}
/**
* Perform atomic write operation using temporary file
*/
private async performAtomicWrite(filePath: string, data: any): Promise<void> {
const tempPath = `${filePath}.tmp`;
try {
// Write to temp file first
const content = JSON.stringify(data, null, 2);
await fs.writeFile(tempPath, content, 'utf-8');
// Atomic rename
await fs.rename(tempPath, filePath);
} catch (error: any) {
// Clean up temp file if it exists
try {
await fs.unlink(tempPath);
} catch {
// Ignore cleanup errors
}
throw new Error(`Failed to write file ${filePath}: ${error.message}`);
}
}
/**
* Check if file exists
*/
async exists(filePath: string): Promise<boolean> {
try {
await fs.access(filePath, constants.F_OK);
return true;
} catch {
return false;
}
}
/**
* Get file stats
*/
async getStats(filePath: string) {
return fs.stat(filePath);
}
/**
* Read directory contents
*/
async readDir(dirPath: string): Promise<string[]> {
return fs.readdir(dirPath);
}
/**
* Create directory recursively
*/
async ensureDir(dirPath: string): Promise<void> {
try {
await fs.mkdir(dirPath, { recursive: true });
} catch (error: any) {
throw new Error(
`Failed to create directory ${dirPath}: ${error.message}`
);
}
}
/**
* Delete file
*/
async deleteFile(filePath: string): Promise<void> {
try {
await fs.unlink(filePath);
} catch (error: any) {
if (error.code !== 'ENOENT') {
throw new Error(`Failed to delete file ${filePath}: ${error.message}`);
}
}
}
/**
* Rename/move file
*/
async moveFile(oldPath: string, newPath: string): Promise<void> {
try {
await fs.rename(oldPath, newPath);
} catch (error: any) {
throw new Error(
`Failed to move file from ${oldPath} to ${newPath}: ${error.message}`
);
}
}
/**
* Copy file
*/
async copyFile(srcPath: string, destPath: string): Promise<void> {
try {
await fs.copyFile(srcPath, destPath);
} catch (error: any) {
throw new Error(
`Failed to copy file from ${srcPath} to ${destPath}: ${error.message}`
);
}
}
/**
* Clean up all pending file operations
*/
async cleanup(): Promise<void> {
const locks = Array.from(this.fileLocks.values());
if (locks.length > 0) {
await Promise.all(locks);
}
this.fileLocks.clear();
}
}
```
--------------------------------------------------------------------------------
/mcp-server/src/core/direct-functions/remove-task.js:
--------------------------------------------------------------------------------
```javascript
/**
* remove-task.js
* Direct function implementation for removing a task
*/
import {
removeTask,
taskExists
} from '../../../../scripts/modules/task-manager.js';
import {
enableSilentMode,
disableSilentMode,
readJSON
} from '../../../../scripts/modules/utils.js';
/**
* Direct function wrapper for removeTask with error handling.
* Supports removing multiple tasks at once with comma-separated IDs.
*
* @param {Object} args - Command arguments
* @param {string} args.tasksJsonPath - Explicit path to the tasks.json file.
* @param {string} args.id - The ID(s) of the task(s) or subtask(s) to remove (comma-separated for multiple).
* @param {string} args.projectRoot - Project root path (for MCP/env fallback)
* @param {string} args.tag - Tag for the task (optional)
* @param {Object} log - Logger object
* @returns {Promise<Object>} - Remove task result { success: boolean, data?: any, error?: { code: string, message: string } }
*/
export async function removeTaskDirect(args, log, context = {}) {
// Destructure expected args
const { tasksJsonPath, id, projectRoot, tag } = args;
const { session } = context;
try {
// Check if tasksJsonPath was provided
if (!tasksJsonPath) {
log.error('removeTaskDirect called without tasksJsonPath');
return {
success: false,
error: {
code: 'MISSING_ARGUMENT',
message: 'tasksJsonPath is required'
}
};
}
// Validate task ID parameter
if (!id) {
log.error('Task ID is required');
return {
success: false,
error: {
code: 'INPUT_VALIDATION_ERROR',
message: 'Task ID is required'
}
};
}
// Split task IDs if comma-separated
const taskIdArray = id.split(',').map((taskId) => taskId.trim());
log.info(
`Removing ${taskIdArray.length} task(s) with ID(s): ${taskIdArray.join(', ')} from ${tasksJsonPath}${tag ? ` in tag '${tag}'` : ''}`
);
// Validate all task IDs exist before proceeding
const data = readJSON(tasksJsonPath, projectRoot, tag);
if (!data || !data.tasks) {
return {
success: false,
error: {
code: 'INVALID_TASKS_FILE',
message: `No valid tasks found in ${tasksJsonPath}${tag ? ` for tag '${tag}'` : ''}`
}
};
}
const invalidTasks = taskIdArray.filter(
(taskId) => !taskExists(data.tasks, taskId)
);
if (invalidTasks.length > 0) {
return {
success: false,
error: {
code: 'INVALID_TASK_ID',
message: `The following tasks were not found${tag ? ` in tag '${tag}'` : ''}: ${invalidTasks.join(', ')}`
}
};
}
// Enable silent mode to prevent console logs from interfering with JSON response
enableSilentMode();
try {
// Call removeTask with proper context including tag
const result = await removeTask(tasksJsonPath, id, {
projectRoot,
tag
});
if (!result.success) {
return {
success: false,
error: {
code: 'REMOVE_TASK_ERROR',
message: result.error || 'Failed to remove tasks'
}
};
}
log.info(`Successfully removed ${result.removedTasks.length} task(s)`);
return {
success: true,
data: {
totalTasks: taskIdArray.length,
successful: result.removedTasks.length,
failed: taskIdArray.length - result.removedTasks.length,
removedTasks: result.removedTasks,
message: result.message,
tasksPath: tasksJsonPath,
tag
}
};
} finally {
// Restore normal logging
disableSilentMode();
}
} catch (error) {
// Ensure silent mode is disabled even if an outer error occurs
disableSilentMode();
// Catch any unexpected errors
log.error(`Unexpected error in removeTaskDirect: ${error.message}`);
return {
success: false,
error: {
code: 'UNEXPECTED_ERROR',
message: error.message
}
};
}
}
```
--------------------------------------------------------------------------------
/tests/integration/profiles/cursor-init-functionality.test.js:
--------------------------------------------------------------------------------
```javascript
import fs from 'fs';
import path from 'path';
import { cursorProfile } from '../../../src/profiles/cursor.js';
describe('Cursor Profile Initialization Functionality', () => {
let cursorProfileContent;
beforeAll(() => {
const cursorJsPath = path.join(
process.cwd(),
'src',
'profiles',
'cursor.js'
);
cursorProfileContent = fs.readFileSync(cursorJsPath, 'utf8');
});
test('cursor.js uses factory pattern with correct configuration', () => {
// Check for explicit, non-default values in the source file
expect(cursorProfileContent).toContain("name: 'cursor'");
expect(cursorProfileContent).toContain("displayName: 'Cursor'");
expect(cursorProfileContent).toContain("url: 'cursor.so'");
expect(cursorProfileContent).toContain("docsUrl: 'docs.cursor.com'");
expect(cursorProfileContent).toContain("targetExtension: '.mdc'"); // non-default
// Check the final computed properties on the profile object
expect(cursorProfile.profileName).toBe('cursor');
expect(cursorProfile.displayName).toBe('Cursor');
expect(cursorProfile.profileDir).toBe('.cursor'); // default
expect(cursorProfile.rulesDir).toBe('.cursor/rules'); // default
expect(cursorProfile.mcpConfig).toBe(true); // default
expect(cursorProfile.mcpConfigName).toBe('mcp.json'); // default
});
test('cursor.js preserves .mdc extension in both input and output', () => {
// Check that the profile object has the correct file mapping behavior (cursor keeps .mdc)
expect(cursorProfile.fileMap['rules/cursor_rules.mdc']).toBe(
'cursor_rules.mdc'
);
// Also check that targetExtension is explicitly set in the file
expect(cursorProfileContent).toContain("targetExtension: '.mdc'");
});
test('cursor.js uses standard tool mappings (no tool renaming)', () => {
// Check that the profile uses default tool mappings (equivalent to COMMON_TOOL_MAPPINGS.STANDARD)
// This verifies the architectural pattern: no custom toolMappings = standard tool names
expect(cursorProfileContent).not.toContain('toolMappings:');
expect(cursorProfileContent).not.toContain('apply_diff');
expect(cursorProfileContent).not.toContain('search_files');
// Verify the result: default mappings means tools keep their original names
expect(cursorProfile.conversionConfig.toolNames.edit_file).toBe(
'edit_file'
);
expect(cursorProfile.conversionConfig.toolNames.search).toBe('search');
});
test('cursor.js has lifecycle functions for command copying', () => {
// Check that the source file contains our new lifecycle functions
expect(cursorProfileContent).toContain('function onAddRulesProfile');
expect(cursorProfileContent).toContain('function onRemoveRulesProfile');
expect(cursorProfileContent).toContain('copyRecursiveSync');
expect(cursorProfileContent).toContain('removeDirectoryRecursive');
});
test('cursor.js copies commands from claude/commands to .cursor/commands', () => {
// Check that the onAddRulesProfile function copies from the correct source
expect(cursorProfileContent).toContain(
"path.join(assetsDir, 'claude', 'commands')"
);
// Destination path is built via a resolver to handle both project root and rules dir
expect(cursorProfileContent).toContain('resolveCursorProfileDir(');
expect(cursorProfileContent).toMatch(
/path\.join\(\s*profileDir\s*,\s*['"]commands['"]\s*\)/
);
expect(cursorProfileContent).toContain(
'copyRecursiveSync(commandsSourceDir, commandsDestDir)'
);
// Check that lifecycle functions are properly registered with the profile
expect(cursorProfile.onAddRulesProfile).toBeDefined();
expect(cursorProfile.onRemoveRulesProfile).toBeDefined();
expect(typeof cursorProfile.onAddRulesProfile).toBe('function');
expect(typeof cursorProfile.onRemoveRulesProfile).toBe('function');
});
});
```
--------------------------------------------------------------------------------
/packages/tm-core/tests/unit/smoke.test.ts:
--------------------------------------------------------------------------------
```typescript
/**
* Smoke tests to verify basic package functionality and imports
*/
import {
PlaceholderParser,
PlaceholderStorage,
StorageError,
TaskNotFoundError,
TmCoreError,
ValidationError,
formatDate,
generateTaskId,
isValidTaskId,
name,
version
} from '@tm/core';
import type {
PlaceholderTask,
TaskId,
TaskPriority,
TaskStatus
} from '@tm/core';
describe('tm-core smoke tests', () => {
describe('package metadata', () => {
it('should export correct package name and version', () => {
expect(name).toBe('@task-master/tm-core');
expect(version).toBe('1.0.0');
});
});
describe('utility functions', () => {
it('should generate valid task IDs', () => {
const id1 = generateTaskId();
const id2 = generateTaskId();
expect(typeof id1).toBe('string');
expect(typeof id2).toBe('string');
expect(id1).not.toBe(id2); // Should be unique
expect(isValidTaskId(id1)).toBe(true);
expect(isValidTaskId('')).toBe(false);
});
it('should format dates', () => {
const date = new Date('2023-01-01T00:00:00.000Z');
const formatted = formatDate(date);
expect(formatted).toBe('2023-01-01T00:00:00.000Z');
});
});
describe('placeholder storage', () => {
it('should perform basic storage operations', async () => {
const storage = new PlaceholderStorage();
const testPath = 'test/path';
const testData = 'test data';
// Initially should not exist
expect(await storage.exists(testPath)).toBe(false);
expect(await storage.read(testPath)).toBe(null);
// Write and verify
await storage.write(testPath, testData);
expect(await storage.exists(testPath)).toBe(true);
expect(await storage.read(testPath)).toBe(testData);
// Delete and verify
await storage.delete(testPath);
expect(await storage.exists(testPath)).toBe(false);
});
});
describe('placeholder parser', () => {
it('should parse simple task lists', async () => {
const parser = new PlaceholderParser();
const content = `
- Task 1
- Task 2
- Task 3
`;
const isValid = await parser.validate(content);
expect(isValid).toBe(true);
const tasks = await parser.parse(content);
expect(tasks).toHaveLength(3);
expect(tasks[0]?.title).toBe('Task 1');
expect(tasks[1]?.title).toBe('Task 2');
expect(tasks[2]?.title).toBe('Task 3');
tasks.forEach((task) => {
expect(task.status).toBe('pending');
expect(task.priority).toBe('medium');
});
});
});
describe('error classes', () => {
it('should create and throw custom errors', () => {
const baseError = new TmCoreError('Base error');
expect(baseError.name).toBe('TmCoreError');
expect(baseError.message).toBe('Base error');
const taskNotFound = new TaskNotFoundError('task-123');
expect(taskNotFound.name).toBe('TaskNotFoundError');
expect(taskNotFound.code).toBe('TASK_NOT_FOUND');
expect(taskNotFound.message).toContain('task-123');
const validationError = new ValidationError('Invalid data');
expect(validationError.name).toBe('ValidationError');
expect(validationError.code).toBe('VALIDATION_ERROR');
const storageError = new StorageError('Storage failed');
expect(storageError.name).toBe('StorageError');
expect(storageError.code).toBe('STORAGE_ERROR');
});
});
describe('type definitions', () => {
it('should have correct types available', () => {
// These are compile-time checks that verify types exist
const taskId: TaskId = 'test-id';
const status: TaskStatus = 'pending';
const priority: TaskPriority = 'high';
const task: PlaceholderTask = {
id: taskId,
title: 'Test Task',
status: status,
priority: priority
};
expect(task.id).toBe('test-id');
expect(task.status).toBe('pending');
expect(task.priority).toBe('high');
});
});
});
```
--------------------------------------------------------------------------------
/packages/tm-core/src/modules/config/services/runtime-state-manager.service.ts:
--------------------------------------------------------------------------------
```typescript
/**
* @fileoverview Runtime State Manager Service
* Manages runtime state separate from configuration
*/
import fs from 'node:fs/promises';
import path from 'node:path';
import {
ERROR_CODES,
TaskMasterError
} from '../../../common/errors/task-master-error.js';
import { DEFAULT_CONFIG_VALUES } from '../../../common/interfaces/configuration.interface.js';
import { getLogger } from '../../../common/logger/index.js';
/**
* Runtime state data structure
*/
export interface RuntimeState {
/** Currently active tag */
currentTag: string;
/** Last updated timestamp */
lastUpdated?: string;
/** Additional metadata */
metadata?: Record<string, unknown>;
}
/**
* RuntimeStateManager handles runtime state persistence
* Single responsibility: Runtime state management (separate from config)
*/
export class RuntimeStateManager {
private stateFilePath: string;
private currentState: RuntimeState;
private readonly logger = getLogger('RuntimeStateManager');
constructor(projectRoot: string) {
this.stateFilePath = path.join(projectRoot, '.taskmaster', 'state.json');
this.currentState = {
currentTag: DEFAULT_CONFIG_VALUES.TAGS.DEFAULT_TAG
};
}
/**
* Load runtime state from disk
*/
async loadState(): Promise<RuntimeState> {
try {
const stateData = await fs.readFile(this.stateFilePath, 'utf-8');
const rawState = JSON.parse(stateData);
// Map legacy field names to current interface
const state: RuntimeState = {
currentTag:
rawState.currentTag ||
rawState.activeTag ||
DEFAULT_CONFIG_VALUES.TAGS.DEFAULT_TAG,
lastUpdated: rawState.lastUpdated,
metadata: rawState.metadata
};
// Apply environment variable override for current tag
if (process.env.TASKMASTER_TAG) {
state.currentTag = process.env.TASKMASTER_TAG;
}
this.currentState = state;
return state;
} catch (error: any) {
if (error.code === 'ENOENT') {
// State file doesn't exist, use defaults
this.logger.debug('No state.json found, using default state');
// Check environment variable
if (process.env.TASKMASTER_TAG) {
this.currentState.currentTag = process.env.TASKMASTER_TAG;
}
return this.currentState;
}
// Failed to load, use defaults
this.logger.warn('Failed to load state file:', error.message);
return this.currentState;
}
}
/**
* Save runtime state to disk
*/
async saveState(): Promise<void> {
const stateDir = path.dirname(this.stateFilePath);
try {
await fs.mkdir(stateDir, { recursive: true });
const stateToSave = {
...this.currentState,
lastUpdated: new Date().toISOString()
};
await fs.writeFile(
this.stateFilePath,
JSON.stringify(stateToSave, null, 2),
'utf-8'
);
} catch (error) {
throw new TaskMasterError(
'Failed to save runtime state',
ERROR_CODES.CONFIG_ERROR,
{ statePath: this.stateFilePath },
error as Error
);
}
}
/**
* Get the currently active tag
*/
getCurrentTag(): string {
return this.currentState.currentTag;
}
/**
* Set the current tag
*/
async setCurrentTag(tag: string): Promise<void> {
this.currentState.currentTag = tag;
await this.saveState();
}
/**
* Get current state
*/
getState(): RuntimeState {
return { ...this.currentState };
}
/**
* Update metadata
*/
async updateMetadata(metadata: Record<string, unknown>): Promise<void> {
this.currentState.metadata = {
...this.currentState.metadata,
...metadata
};
await this.saveState();
}
/**
* Clear state file
*/
async clearState(): Promise<void> {
try {
await fs.unlink(this.stateFilePath);
} catch (error: any) {
if (error.code !== 'ENOENT') {
throw error;
}
}
this.currentState = {
currentTag: DEFAULT_CONFIG_VALUES.TAGS.DEFAULT_TAG
};
}
}
```
--------------------------------------------------------------------------------
/packages/tm-core/src/modules/briefs/utils/url-parser.ts:
--------------------------------------------------------------------------------
```typescript
/**
* @fileoverview URL Parser
* Utility for parsing URLs to extract organization and brief identifiers
*/
import {
ERROR_CODES,
TaskMasterError
} from '../../../common/errors/task-master-error.js';
export interface ParsedBriefUrl {
orgSlug: string | null;
briefId: string | null;
}
/**
* Utility class for parsing brief URLs
* Handles URL formats like: http://localhost:3000/home/{orgSlug}/briefs/{briefId}
*/
export class BriefUrlParser {
/**
* Parse a URL and extract org slug and brief ID
*
* @param input - Raw input string (URL, path, or ID)
* @returns Parsed components
*/
static parse(input: string): ParsedBriefUrl {
const raw = input?.trim() ?? '';
if (!raw) {
return { orgSlug: null, briefId: null };
}
// Try parsing as URL
const url = this.parseAsUrl(raw);
const pathToCheck = url ? url.pathname : raw.includes('/') ? raw : null;
if (!pathToCheck) {
// Not a URL/path, treat as direct ID
return { orgSlug: null, briefId: raw };
}
// Extract components from path
return this.parsePathComponents(pathToCheck, url);
}
/**
* Extract organization slug from URL or path
*
* @param input - Raw input string
* @returns Organization slug or null
*/
static extractOrgSlug(input: string): string | null {
return this.parse(input).orgSlug;
}
/**
* Extract brief identifier from URL or path
*
* @param input - Raw input string
* @returns Brief identifier or null
*/
static extractBriefId(input: string): string | null {
const parsed = this.parse(input);
return parsed.briefId || input.trim();
}
/**
* Try to parse input as URL
* Handles both absolute and scheme-less URLs
*/
private static parseAsUrl(input: string): URL | null {
try {
return new URL(input);
} catch {}
try {
return new URL(`https://${input}`);
} catch {}
return null;
}
/**
* Parse path components to extract org slug and brief ID
* Handles patterns like: /home/{orgSlug}/briefs/{briefId}
*/
private static parsePathComponents(
path: string,
url: URL | null
): ParsedBriefUrl {
const parts = path.split('/').filter(Boolean);
const briefsIdx = parts.lastIndexOf('briefs');
let orgSlug: string | null = null;
let briefId: string | null = null;
// Extract org slug (segment before 'briefs')
if (briefsIdx > 0) {
orgSlug = parts[briefsIdx - 1] || null;
}
// Extract brief ID
// Priority: query param > path segment after 'briefs' > last segment (if not 'briefs')
if (url) {
const qId = url.searchParams.get('id') || url.searchParams.get('briefId');
if (qId) {
briefId = qId;
}
}
if (!briefId && briefsIdx >= 0 && parts.length > briefsIdx + 1) {
briefId = parts[briefsIdx + 1];
}
// Only use last segment as fallback if path doesn't end with 'briefs'
// This prevents treating '/home/org/briefs' as briefId='briefs'
if (
!briefId &&
parts.length > 0 &&
!(briefsIdx >= 0 && briefsIdx === parts.length - 1)
) {
briefId = parts[parts.length - 1];
}
return { orgSlug, briefId };
}
/**
* Validate that required components are present
*
* @param parsed - Parsed URL components
* @param requireOrg - Whether org slug is required
* @param requireBrief - Whether brief ID is required
* @throws TaskMasterError if required components are missing
*/
static validate(
parsed: ParsedBriefUrl,
options: { requireOrg?: boolean; requireBrief?: boolean } = {}
): void {
if (options.requireOrg && !parsed.orgSlug) {
throw new TaskMasterError(
'Organization slug could not be extracted from input',
ERROR_CODES.VALIDATION_ERROR
);
}
if (options.requireBrief && !parsed.briefId) {
throw new TaskMasterError(
'Brief identifier could not be extracted from input',
ERROR_CODES.VALIDATION_ERROR
);
}
}
}
```
--------------------------------------------------------------------------------
/.taskmaster/docs/research/2025-06-14_test-the-fix-for-duplicate-saves-final-test.md:
--------------------------------------------------------------------------------
```markdown
---
title: Research Session
query: "test the fix for duplicate saves - final test"
date: 6/14/2025
time: 6:10:00 PM
timestamp: 2025-06-14T22:10:00.394Z
exchanges: 1
---
# Research Session
## Initial Query
**Question:** test the fix for duplicate saves - final test
**Response:**
## Steps to Test the Fix for Duplicate Saves
**1. Prepare a Clean Test Environment**
- Ensure the tasks.json file and any related data stores are in a known, clean state with no pre-existing duplicate entries.
- Back up the current tasks.json in case rollback is needed.
**2. Define Test Scenarios**
- Attempt to save a new task with unique data.
- Attempt to save a task with the same ID or unique identifier as an existing task (simulate a duplicate).
- Attempt to save a task with the same title or content but a different ID (to test if the fix is based on ID or content).
- Simultaneously trigger multiple save operations (if the system supports concurrency) to test race conditions.
**3. Execute Manual and Automated Tests**
- Use the application's UI or API to create and save tasks as per the scenarios above.
- For each save operation, check the tasks.json file or the data store to verify:
- No duplicate entries are created.
- Existing tasks are not overwritten unless intended (e.g., for updates).
- The system returns appropriate error messages or warnings when a duplicate save is attempted.
**4. Validate System Behavior**
- Confirm that after all test operations, each task in tasks.json is unique according to the defined criteria (ID, title, or other unique fields).
- If the system is designed to merge duplicates, verify that merging occurs as expected.
- If the system is designed to reject duplicates, ensure that the rejection is clear and no duplicate is present.
**5. Test Edge Cases**
- Attempt to save tasks with minor variations (e.g., whitespace differences, case sensitivity) to ensure the duplicate detection logic is robust.
- Test with large numbers of tasks to ensure performance and correctness at scale.
**6. Review Logs and Error Handling**
- Check application logs for any errors or warnings related to duplicate saves.
- Ensure that error handling is user-friendly and provides actionable feedback.
**7. Regression Testing**
- Run the full suite of task operations (create, update, delete) to ensure the fix for duplicate saves does not introduce new issues elsewhere in the system.
## Additional Best Practices
- Communicate test results with the team to confirm the fix is effective and to prevent future regressions[1][2][5].
- Consider implementing automated duplicate detection as part of the save operation to prevent future issues[2][3].
- Document the test cases and results for future reference and audits.
## Example Test Case Table
| Test Scenario | Expected Result | Actual Result | Pass/Fail |
|--------------------------------------|-------------------------------|---------------|-----------|
| Save unique task | Task saved | | |
| Save duplicate task (same ID) | Duplicate rejected/merged | | |
| Save duplicate task (same title) | Duplicate rejected/merged | | |
| Simultaneous saves (race condition) | Only one unique task present | | |
| Save with minor variations | No false positives/negatives | | |
Fill in the "Actual Result" and "Pass/Fail" columns during testing.
## Action Items
- Complete all test scenarios above.
- Document any issues found and retest after fixes.
- Confirm with stakeholders before closing the issue.
---
*Generated by Task Master Research Command*
*Timestamp: 2025-06-14T22:10:00.394Z*
```