feat: make providers optional with --provider flag and fix sh/MCP bugs (#39, #37, #41)#45
Merged
Merged
Conversation
…37, #41) - Make `providers` field optional in capabilities file (closes #39) - Add `--provider/-p` flag to `capa install` for single-provider installs - Persist provider selection in project DB for subsequent runs - Interactive prompt when no provider is specified (TTY only) - Skip MCP file registration when no tools are configured (closes #37) - Unwrap command tool result envelope in capa sh output (closes #41)
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes provider selection optional and user-driven during capa install, avoids unnecessary MCP client config changes when no tools/sub-agents are configured, and improves capa sh output by unwrapping command-tool result envelopes.
Changes:
- Made
capabilities.providersoptional and added a provider resolution flow for installs (flag > file > DB > interactive prompt). - Added persistence of resolved providers in the local DB (
project_providers) and wired provider-aware cleanup. - Skipped MCP registration when no tools/sub-agents exist (and unregisters when tools/sub-agents were removed); unwrapped
{success, result/error}inserializeToolResult.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/capabilities.ts | Makes providers optional in the capabilities schema. |
| src/shared/providers/resolve.ts | Adds provider resolution + validation logic (including interactive selection). |
| src/shared/providers/tests/resolve.test.ts | Adds resolver unit tests for priority/validation/non-TTY behavior. |
| src/shared/capabilities.ts | Removes hardcoded default providers from generated default capabilities. |
| src/shared/tests/capabilities.test.ts | Updates defaults test to assert providers is undefined. |
| src/db/database.ts | Adds project_providers table and set/get accessors for persisted provider selection. |
| src/db/tests/database.test.ts | Adds tests for project provider persistence behavior. |
| src/cli/utils/select-prompt.ts | Adds dependency-free interactive single-select prompt for provider selection. |
| src/cli/index.ts | Adds -p/--provider flag to capa install CLI. |
| src/cli/commands/install.ts | Integrates provider resolver, persists providers, and conditionally registers/unregisters MCP. |
| src/cli/commands/clean.ts | Uses resolver for provider-aware cleanup and MCP unregistration. |
| src/cli/commands/plugin-install.ts | Enforces that providers must be resolved before plugin resolution. |
| src/server/mcp-handler.ts | Unwraps command-tool result envelope so shell output is raw. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- De-duplicate provider ids in setProjectProviders to prevent PK constraint errors - Normalize provider ids to canonical lowercase form from the registry - Wrap rawSelect in try/catch to guarantee terminal cleanup on errors - Remove process.exit(130) from select prompt; let callers handle cancellation - Always run cleanAgentsFile when capabilities.agents is set, even with empty providers
Add coverage for optional providers, --provider flag, --no-cache flag, rules section, plugins section, cache/auth/upgrade commands, and conditional MCP registration. Update all reference files (schema, commands, workflows, troubleshooting) to match current codebase.
Clarify instructions for resetting the Bearer token in the troubleshooting documentation. Users can now update the token via the web UI during `capa install` or by re-running the command with an updated `.env` file.
The --no-cache test was trying to git clone from github.com/owner/repo after wiping the local mirror, which hung on Windows CI. Add a repoUrl override to GetSnapshotOptions so the test re-clones from the local file:// fixture instead of hitting the network.
- Introduced new favicon files: favicon-white.png and favicon.svg. - Updated build script to reference new asset paths in the assets directory.
- Replace require('readline') with ESM-safe import('node:readline')
in numberedSelect fallback path
- When providers is empty, getTargetFilenames now falls back to all
registered providers so cleanAgentsFile removes stale capa blocks
from all known instruction files (CLAUDE.md, etc.)
- Copy logo assets from capa-docs into assets/ so build-web.ts does
not depend on an external repo checkout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
providersfield in the capabilities file optional. Add--provider / -pflag tocapa installfor single-provider installs. When no provider is specified, fall back to the project DB (persisted from last install), then to an interactive prompt listing detected agents. Freshcapa initno longer hardcodes['cursor', 'claude-code'].registerMCPServer) when the project has no tools or sub-agents configured. If tools were previously registered and have since been removed, unregister the capa server from MCP config files.capa shshould return the result without encapsulation and escaping #41 - Unwrap the{success, result}envelope from command tool results inserializeToolResultsocapa shprints the raw output instead of the JSON wrapper.New files
src/shared/providers/resolve.ts- Provider resolution logic (flag > file > DB > prompt)src/cli/utils/select-prompt.ts- Dependency-free interactive single-select promptsrc/shared/providers/__tests__/resolve.test.ts- 13 resolver testsModified files
src/types/capabilities.ts-providersfield is now optionalsrc/db/database.ts- Newproject_providerstable + accessorssrc/cli/index.ts- Added-p, --provideroption to install commandsrc/cli/commands/install.ts- Wired provider resolver, conditional MCP registrationsrc/cli/commands/clean.ts- Uses resolver for provider-aware cleanupsrc/cli/commands/plugin-install.ts- Strict guard replacing hardcoded fallbacksrc/shared/capabilities.ts- Removedprovidersfrom default capabilitiessrc/server/mcp-handler.ts- Unwrap command tool result envelopeTest plan
providersis undefinedcapa install -p cursorinstalls for Cursor onlycapa installwith no providers prompts interactivelycapa installwith no tools skips MCP registrationcapa sh <tool>returns raw result without JSON wrapper