This commit introduces a standardized pattern for capturing and propagating AI usage telemetry (cost, tokens, model used) across the Task Master stack and applies it to the 'add-task' functionality. Key changes include: - **Telemetry Pattern Definition:** - Added defining the integration pattern for core logic, direct functions, MCP tools, and CLI commands. - Updated related rules (, , Usage: mcp [OPTIONS] COMMAND [ARGS]... MCP development tools ╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ --help Show this message and exit. │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ version Show the MCP version. │ │ dev Run a MCP server with the MCP Inspector. │ │ run Run a MCP server. │ │ install Install a MCP server in the Claude desktop app. │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯, , ) to reference the new telemetry rule. - **Core Telemetry Implementation ():** - Refactored the unified AI service to generate and return a object alongside the main AI result. - Fixed an MCP server startup crash by removing redundant local loading of and instead using the imported from for cost calculations. - Added to the object. - ** Integration:** - Modified (core) to receive from the AI service, return it, and call the new UI display function for CLI output. - Updated to receive from the core function and include it in the payload of its response. - Ensured (MCP tool) correctly passes the through via . - Updated to correctly pass context (, ) to the core function and rely on it for CLI telemetry display. - **UI Enhancement:** - Added function to to show telemetry details in the CLI. - **Project Management:** - Added subtasks 77.6 through 77.12 to track the rollout of this telemetry pattern to other AI-powered commands (, , , , , , ). This establishes the foundation for tracking AI usage across the application.
45 lines
2.5 KiB
Plaintext
45 lines
2.5 KiB
Plaintext
# Task ID: 73
|
|
# Title: Implement Custom Model ID Support for Ollama/OpenRouter
|
|
# Status: done
|
|
# Dependencies: None
|
|
# Priority: medium
|
|
# Description: Allow users to specify custom model IDs for Ollama and OpenRouter providers via CLI flag and interactive setup, with appropriate validation and warnings.
|
|
# Details:
|
|
**CLI (`task-master models --set-<role> <id> --custom`):**
|
|
- Modify `scripts/modules/task-manager/models.js`: `setModel` function.
|
|
- Check internal `available_models.json` first.
|
|
- If not found and `--custom` is provided:
|
|
- Fetch `https://openrouter.ai/api/v1/models`. (Need to add `https` import).
|
|
- If ID found in OpenRouter list: Set `provider: 'openrouter'`, `modelId: <id>`. Warn user about lack of official validation.
|
|
- If ID not found in OpenRouter: Assume Ollama. Set `provider: 'ollama'`, `modelId: <id>`. Warn user strongly (model must be pulled, compatibility not guaranteed).
|
|
- If not found and `--custom` is *not* provided: Fail with error message guiding user to use `--custom`.
|
|
|
|
**Interactive Setup (`task-master models --setup`):**
|
|
- Modify `scripts/modules/commands.js`: `runInteractiveSetup` function.
|
|
- Add options to `inquirer` choices for each role: `OpenRouter (Enter Custom ID)` and `Ollama (Enter Custom ID)`.
|
|
- If `__CUSTOM_OPENROUTER__` selected:
|
|
- Prompt for custom ID.
|
|
- Fetch OpenRouter list and validate ID exists. Fail setup for that role if not found.
|
|
- Update config and show warning if found.
|
|
- If `__CUSTOM_OLLAMA__` selected:
|
|
- Prompt for custom ID.
|
|
- Update config directly (no live validation).
|
|
- Show strong Ollama warning.
|
|
|
|
# Test Strategy:
|
|
**Unit Tests:**
|
|
- Test `setModel` logic for internal models, custom OpenRouter (valid/invalid), custom Ollama, missing `--custom` flag.
|
|
- Test `runInteractiveSetup` for new custom options flow, including OpenRouter validation success/failure.
|
|
|
|
**Integration Tests:**
|
|
- Test the `task-master models` command with `--custom` flag variations.
|
|
- Test the `task-master models --setup` interactive flow for custom options.
|
|
|
|
**Manual Testing:**
|
|
- Run `task-master models --setup` and select custom options.
|
|
- Run `task-master models --set-main <valid_openrouter_id> --custom`. Verify config and warning.
|
|
- Run `task-master models --set-main <invalid_openrouter_id> --custom`. Verify error.
|
|
- Run `task-master models --set-main <ollama_model_id> --custom`. Verify config and warning.
|
|
- Run `task-master models --set-main <custom_id>` (without `--custom`). Verify error.
|
|
- Check `getModelConfiguration` output reflects custom models correctly.
|