Skip to content

feat: make providers optional with --provider flag and fix sh/MCP bugs (#39, #37, #41)#45

Merged
Minitour merged 7 commits into
mainfrom
fix/provider-agnostic-install-and-bugs
May 9, 2026
Merged

feat: make providers optional with --provider flag and fix sh/MCP bugs (#39, #37, #41)#45
Minitour merged 7 commits into
mainfrom
fix/provider-agnostic-install-and-bugs

Conversation

@Minitour
Copy link
Copy Markdown
Contributor

@Minitour Minitour commented May 9, 2026

Summary

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 prompt
  • src/shared/providers/__tests__/resolve.test.ts - 13 resolver tests

Modified files

  • src/types/capabilities.ts - providers field is now optional
  • src/db/database.ts - New project_providers table + accessors
  • src/cli/index.ts - Added -p, --provider option to install command
  • src/cli/commands/install.ts - Wired provider resolver, conditional MCP registration
  • src/cli/commands/clean.ts - Uses resolver for provider-aware cleanup
  • src/cli/commands/plugin-install.ts - Strict guard replacing hardcoded fallback
  • src/shared/capabilities.ts - Removed providers from default capabilities
  • src/server/mcp-handler.ts - Unwrap command tool result envelope

Test plan

  • All 484 existing tests pass (0 failures)
  • 13 new resolver tests cover: flag > file > DB priority, validation, non-TTY error
  • 6 new DB tests cover: set/get/replace/clear providers, cascading delete
  • Updated capabilities default test to assert providers is undefined
  • Manual: capa install -p cursor installs for Cursor only
  • Manual: capa install with no providers prompts interactively
  • Manual: capa install with no tools skips MCP registration
  • Manual: capa sh <tool> returns raw result without JSON wrapper

…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)
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.providers optional 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} in serializeToolResult.

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.

Comment thread src/db/database.ts
Comment thread src/shared/providers/resolve.ts
Comment thread src/cli/utils/select-prompt.ts Outdated
Comment thread src/cli/utils/select-prompt.ts Outdated
Comment thread src/cli/commands/clean.ts Outdated
Minitour added 4 commits May 9, 2026 13:56
- 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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Comment thread src/cli/utils/select-prompt.ts
Comment thread src/cli/commands/clean.ts
Minitour added 2 commits May 9, 2026 15:58
- 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
@Minitour Minitour merged commit 9fb61a8 into main May 9, 2026
4 checks passed
@Minitour Minitour deleted the fix/provider-agnostic-install-and-bugs branch May 9, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants