diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c29431b..a1954c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,13 @@ jobs: with: node-version: '22' cache: npm + - name: Cache Windows packaging tools + if: matrix.os == 'windows-latest' + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: ${{ runner.temp }}/electron-builder-cache + key: electron-builder-windows-${{ hashFiles('package-lock.json') }} + restore-keys: electron-builder-windows- - run: npm ci --ignore-scripts if: matrix.os != 'windows-latest' - run: npm ci @@ -31,10 +38,32 @@ jobs: - run: npm test - name: Package unsigned Windows app if: matrix.os == 'windows-latest' - run: npm run package:win:app + shell: pwsh + env: + ELECTRON_BUILDER_CACHE: ${{ runner.temp }}/electron-builder-cache + run: | + for ($attempt = 1; $attempt -le 3; $attempt++) { + npm run package:win:app + if ($LASTEXITCODE -eq 0) { break } + if ($attempt -eq 3) { exit $LASTEXITCODE } + Write-Host "Packaging failed; retrying ($attempt/3)..." + if ($attempt -eq 2) { $env:DEBUG = 'electron-builder' } + Start-Sleep -Seconds (10 * $attempt) + } - name: Build unsigned Windows test installer if: matrix.os == 'windows-latest' - run: npm run package:win:unsigned + shell: pwsh + env: + ELECTRON_BUILDER_CACHE: ${{ runner.temp }}/electron-builder-cache + run: | + for ($attempt = 1; $attempt -le 3; $attempt++) { + npm run package:win:unsigned + if ($LASTEXITCODE -eq 0) { break } + if ($attempt -eq 3) { exit $LASTEXITCODE } + Write-Host "Packaging failed; retrying ($attempt/3)..." + if ($attempt -eq 2) { $env:DEBUG = 'electron-builder' } + Start-Sleep -Seconds (10 * $attempt) + } - name: Stage Windows test installer if: matrix.os == 'windows-latest' shell: pwsh diff --git a/.projectroom/project.yaml b/.projectroom/project.yaml index 6fad896..35bee14 100644 --- a/.projectroom/project.yaml +++ b/.projectroom/project.yaml @@ -31,6 +31,11 @@ product: summary: Show the number of configured services, tools, servers, APIs, suites, data sources and declared variable names, plus product content counts, in the expanded navigation. status: done relatedComponents: [product-spec, web] + - id: explorer-deduplication + title: Show each explorer integration once + summary: Merge linked CLI and MCP discoveries into their registered entries, and normalize OpenAPI spec paths before showing additional local files. + status: done + relatedComponents: [web] - id: evidence-based-onboarding title: Evidence-based onboarding progress summary: Count only detected sections, keep configured entries separate from hands-on verification, review paths, commands and environment names, and make the agent inspect before writing. diff --git a/desktop/api-explorer.cjs b/desktop/api-explorer.cjs index c7a4da0..d80c7d0 100644 --- a/desktop/api-explorer.cjs +++ b/desktop/api-explorer.cjs @@ -174,8 +174,8 @@ function listApiSources(root, config) { if (item.spec) try { spec = readSpec(root, item.spec); } catch (cause) { error = cause.message; } return { ...item, id: `yaml:${item.id}`, source: '.projectroom/project.yaml', linked: true, operations: spec?.operations || [], specTitle: spec?.title || '', specVersion: spec?.version || '', error }; }); - const linkedPaths = new Set((config.workspace?.apiSources || []).map(item => item.spec).filter(Boolean)); - return [...configured, ...discoverSpecs(root).filter(item => !linkedPaths.has(item.spec)).map(item => ({ ...item, linked: false, baseUrl: '' }))]; + const linkedPaths = new Set((config.workspace?.apiSources || []).map(item => item.spec).filter(Boolean).map(spec => path.resolve(root, spec))); + return [...configured, ...discoverSpecs(root).filter(item => !linkedPaths.has(path.resolve(root, item.spec))).map(item => ({ ...item, linked: false, baseUrl: '' }))]; } function editDocument(root) { const base = fs.realpathSync(root); diff --git a/desktop/mcp-explorer.cjs b/desktop/mcp-explorer.cjs index b85fa80..d792dfe 100644 --- a/desktop/mcp-explorer.cjs +++ b/desktop/mcp-explorer.cjs @@ -70,6 +70,17 @@ function substitute(value, environment) { return String(value).replace(/\$\{([A-Z][A-Z0-9_]*)\}/g, (_match, name) => environment[name] || ''); } +function serverTarget(root, item) { + if (item.builtIn) return null; + if (item.transport === 'stdio') { + if (!item.command) return null; + return JSON.stringify(['stdio', path.resolve(root, item.cwd || '.'), item.command, item.args || []]); + } + if (!item.url) return null; + try { return JSON.stringify([item.transport, new URL(item.url).href]); } + catch { return null; } +} + class McpExplorer { constructor(options) { this.options = options; this.active = new Map(); } discover() { @@ -81,8 +92,16 @@ class McpExplorer { list() { const linked = new Map((this.options.getConfig()?.workspace?.mcpServers || []).filter(item => item.linkedFrom).map(item => [item.linkedFrom, item.id])); const root = this.options.getRoot(); + const candidates = this.discover(); + const registered = new Map(candidates.filter(item => item.source === '.projectroom/project.yaml') + .map(item => [serverTarget(root, item), item.id.slice(5)]).filter(([target]) => target)); + for (const item of candidates) { + if (item.builtIn || item.source === '.projectroom/project.yaml' || linked.has(item.id)) continue; + const match = registered.get(serverTarget(root, item)); + if (match) linked.set(item.id, match); + } const revision = root ? sourceRevision(root) : null; - return this.discover().map(item => ({ ...publicCandidate(item, name => !!this.options.getEnvironment(name)), + return candidates.map(item => ({ ...publicCandidate(item, name => !!this.options.getEnvironment(name)), connected: this.active.has(item.id), linkedId: linked.get(item.id) || null, buildIdentity: this.active.get(item.id)?.buildIdentity || (item.transport === 'stdio' && !item.builtIn && item.build?.file ? readBuildIdentity(root, item, revision) : null) })); } diff --git a/dist/.projectroom/project.yaml b/dist/.projectroom/project.yaml index 6fad896..35bee14 100644 --- a/dist/.projectroom/project.yaml +++ b/dist/.projectroom/project.yaml @@ -31,6 +31,11 @@ product: summary: Show the number of configured services, tools, servers, APIs, suites, data sources and declared variable names, plus product content counts, in the expanded navigation. status: done relatedComponents: [product-spec, web] + - id: explorer-deduplication + title: Show each explorer integration once + summary: Merge linked CLI and MCP discoveries into their registered entries, and normalize OpenAPI spec paths before showing additional local files. + status: done + relatedComponents: [web] - id: evidence-based-onboarding title: Evidence-based onboarding progress summary: Count only detected sections, keep configured entries separate from hands-on verification, review paths, commands and environment names, and make the agent inspect before writing. diff --git a/dist/cli-explorer-ui.js b/dist/cli-explorer-ui.js index a3b4363..e0d3afb 100644 --- a/dist/cli-explorer-ui.js +++ b/dist/cli-explorer-ui.js @@ -7,7 +7,8 @@ const safe = value => escapeHtml(value == null ? '' : String(value)); const parts = value => String(value || '').split(/\r?\n/).map(part => part.trim()).filter(Boolean); const shown = command => (command || []).map(part => /\s/.test(part) ? JSON.stringify(part) : part).join(' '); - const selectedCandidate = () => commandCandidates.find(item => item.id === commandCandidateId) || (!commandTools().length ? commandCandidates[0] : null); + const unlinkedCandidates = () => commandCandidates.filter(item => !item.linkedId); + const selectedCandidate = () => unlinkedCandidates().find(item => item.id === commandCandidateId) || (!commandTools().length ? unlinkedCandidates()[0] : null); const current = () => selectedCandidate() || commandSelected(); const toolId = () => current()?.id; const tabButton = (id, label) => ``; @@ -69,8 +70,9 @@ const tools = commandTools(); const term = commandSearch.trim().toLowerCase(); const configured = tools.filter(item => !term || `${item.name} ${item.cli?.summary || ''}`.toLowerCase().includes(term)); - const discovered = commandCandidates.filter(item => !term || `${item.name} ${item.path} ${item.source}`.toLowerCase().includes(term)); - const catalog = `
Project tools${tools.length + commandCandidates.length} found
IN .PROJECTROOM/PROJECT.YAML · ${tools.length}
${configured.map(item => catalogItem(item, false)).join('') || '

No registered tools.

'}
DISCOVERED LOCALLY · ${commandCandidates.length}
${discovered.map(item => catalogItem(item, true)).join('') || `

${safe(commandCandidatesLoading ? 'Scanning project files…' : commandCandidatesError || 'No entry points found.')}

`}
Discovery reads project files only. Test commands and help run after an explicit click.
`; + const candidates = unlinkedCandidates(); + const discovered = candidates.filter(item => !term || `${item.name} ${item.path} ${item.source}`.toLowerCase().includes(term)); + const catalog = `
Project tools${tools.length + candidates.length} found
IN .PROJECTROOM/PROJECT.YAML · ${tools.length}
${configured.map(item => catalogItem(item, false)).join('') || '

No registered tools.

'}
DISCOVERED LOCALLY · ${candidates.length}
${discovered.map(item => catalogItem(item, true)).join('') || `

${safe(commandCandidatesLoading ? 'Scanning project files…' : commandCandidatesError || 'No unlinked entry points found.')}

`}
Discovery reads project files only. Test commands and help run after an explicit click.
`; const candidate = selectedCandidate(); const configuredItem = commandSelected(); const detail = candidate ? discoveredDetail(candidate) : configuredItem ? configuredDetail(configuredItem) : '

No CLI tool selected

Open a local project to find command-line entry points, or add one to .projectroom/project.yaml.

'; diff --git a/dist/docs/product/architecture.md b/dist/docs/product/architecture.md index 2046532..d743832 100644 --- a/dist/docs/product/architecture.md +++ b/dist/docs/product/architecture.md @@ -31,12 +31,16 @@ The Backlog combines repository-backed local issues with Spec Kit features, bug ## MCP Explorer +The catalog shows a client setting only when it is not already linked to a YAML registration. Matching uses transport plus the complete command or URL; different arguments and endpoints remain separate. + The desktop's immediate MCP inventory reads project client configuration and `workspace.mcpServers`; it does not claim to infer every server from arbitrary source code. The optional setup prompt passes a repository-specific guide to the user's coding agent. That agent must complete the guide's source-audit matrix for product context, services, HTTP APIs, MCP servers, CLI tools, tests, data and runtime evidence. It traces wrappers and hidden subcommands, makes a second source pass before reporting absence, and reconciles any existing YAML against source. This catches a local `stdio` MCP server exposed only as a CLI subcommand. The first-phase report separates verified implementations from uncertain candidates, names source evidence, environment variable names and access scope, and waits for review. A server requiring a separate read-only key must not receive an owner credential. Registration does not connect or invoke it; the user tests the server in MCP Explorer deliberately. The source audit improves setup completeness but is not a universal protocol importer or a runtime test. MCP Explorer supports local `stdio`, Streamable HTTP and legacy SSE with manual connection; custom transports need an adapter. It labels project registrations separately from coding-tool client settings, which can point to external servers. API Explorer uses existing OpenAPI 3.x documents, an explicitly loaded OpenAPI path on a registered API, or manually entered HTTP paths and supports none, Bearer, API key and public-client OAuth; GraphQL, gRPC, multipart uploads, cookie/Basic/mTLS and confidential OAuth clients have no dedicated request flow. CLI Explorer discovers common package, Python, Cargo, Go and executable entry points; unbuilt package targets are visible but cannot be run until built. Individual subcommands and safe arguments still need source review or explicit help. Test Explorer can discover Node and Rust cases in supported forms; other runners need explicit test commands. Data Explorer handles PostgreSQL, MySQL/MariaDB, SQLite and local files, not every database or event stream. Foreground services and explicitly modeled detached lifecycles are operable; the CPU/memory collector does not measure containers after a detached launch. The agent should mark these limits as unsupported or manual rather than fabricate an integration. ## API Explorer +A project OpenAPI file already named in `workspace.apiSources` appears only as the registered API, including when the relative path uses a `./` prefix. + Project-local OpenAPI 3.x files are scanned read-only and listed beside HTTP APIs declared in `workspace.apiSources`. The file remains the source of truth for endpoint paths and summaries; the repository YAML stores only its relative path, clean base URL and public authentication metadata. Alternatively, `specPath` identifies a dynamically served OpenAPI document on the registered API. The user must click **Load OpenAPI**; the main process fetches from that API's origin without redirects or authentication headers, with a timeout and 2 MB limit. An API can be registered without a spec and tested with a manually entered relative path. The main process performs a request only after the user clicks Send, checks that the target stays on the selected origin, blocks redirects, applies a timeout and bounds the response preview. It resolves Bearer and API-key values from the local project `.env`. Public-client OAuth uses PKCE and a loopback callback; access and refresh tokens are encrypted outside the repository with macOS secure storage. Activity records only request metadata, without headers, query values, body or response content. The included Hello Workspace has a matching OpenAPI document for its real health and notes endpoints. ## MCP Explorer diff --git a/dist/docs/product/command-tools.md b/dist/docs/product/command-tools.md index aa4c108..9ec5b75 100644 --- a/dist/docs/product/command-tools.md +++ b/dist/docs/product/command-tools.md @@ -1,5 +1,7 @@ # CLI Explorer +An entry point already linked to a registered YAML tool appears only once, under the registered tool. Catalog counts reflect distinct tools rather than both discovery and registration. + CLI Explorer follows the same browse and inspect layout as MCP Explorer. The left catalog lists **Discovered locally** entry points found by reading the open repository: `package.json` `bin` entries, Python project scripts, Cargo binaries, Go `cmd/*/main.go` and `examples/*/main.go` programs, and executable CLI files. A package CLI whose declared `dist/` or `build/` target is absent is labeled **Build required**; it cannot be run, linked or queried for help until that target exists. This scan does not run candidates. It is intentionally bounded and may miss custom build systems; ordinary package scripts and tests are not automatically treated as product CLIs. **In .projectroom/project.yaml** lists registered `commandTool` components. Select either type to inspect it on the right. Select a discovered entry to see its source file and exact command. **Read help** explicitly starts the command with `--help`, `-h`, or `help` and shows the real output, including a parsed synopsis, paired short and long flags, common subcommand lists and positional arguments where recognizable. Parsed commands and options become suggestions in Explore. The full original output stays visible because CLI help has no universal machine-readable format. A program can have side effects even while printing help; Project Room never requests it automatically. Discovery does not prove that the CLI is safe or fully documented. diff --git a/dist/mcp-explorer.js b/dist/mcp-explorer.js index 3aa97a3..a8d5186 100644 --- a/dist/mcp-explorer.js +++ b/dist/mcp-explorer.js @@ -15,7 +15,7 @@ let message = ''; const safe = value => escapeHtml(value == null ? '' : String(value)); const selected = () => servers.find(item => item.id === selectedId); - const projectServers = async () => (await pv.listMcpServers()).filter(item => !item.builtIn); + const projectServers = async () => (await pv.listMcpServers()).filter(item => !item.builtIn && !item.linkedId); const editable = item => !!item && item.id.startsWith('yaml:'); const activeItems = () => detail ? ({ tools: detail.tools, resources: detail.resources, templates: detail.resourceTemplates, prompts: detail.prompts })[selectedKind] || [] : []; const activeItem = () => activeItems().find(item => (item.name || item.uri || item.uriTemplate) === selectedName); diff --git a/dist/projectroom.json b/dist/projectroom.json index e5459cc..61e1c00 100644 --- a/dist/projectroom.json +++ b/dist/projectroom.json @@ -51,6 +51,15 @@ "web" ] }, + { + "id": "explorer-deduplication", + "title": "Show each explorer integration once", + "summary": "Merge linked CLI and MCP discoveries into their registered entries, and normalize OpenAPI spec paths before showing additional local files.", + "status": "done", + "relatedComponents": [ + "web" + ] + }, { "id": "evidence-based-onboarding", "title": "Evidence-based onboarding progress", diff --git a/dist/v5.js b/dist/v5.js index 6b53cab..830656c 100644 --- a/dist/v5.js +++ b/dist/v5.js @@ -65,7 +65,9 @@ async function commandDiscover(force = false) { const found = await pv.discoverCliTools(); if (root === projectRoot) { commandCandidates = found; - if (commandCandidateId && !found.some(item => item.id === commandCandidateId)) commandCandidateId = null; + const selected = found.find(item => item.id === commandCandidateId); + if (selected?.linkedId) { commandSelectedId = selected.linkedId; commandCandidateId = null; } + else if (commandCandidateId && !selected) commandCandidateId = null; } } catch (error) { if (root === projectRoot) commandCandidatesError = error.message; } finally { diff --git a/docs/product/architecture.md b/docs/product/architecture.md index 2046532..d743832 100644 --- a/docs/product/architecture.md +++ b/docs/product/architecture.md @@ -31,12 +31,16 @@ The Backlog combines repository-backed local issues with Spec Kit features, bug ## MCP Explorer +The catalog shows a client setting only when it is not already linked to a YAML registration. Matching uses transport plus the complete command or URL; different arguments and endpoints remain separate. + The desktop's immediate MCP inventory reads project client configuration and `workspace.mcpServers`; it does not claim to infer every server from arbitrary source code. The optional setup prompt passes a repository-specific guide to the user's coding agent. That agent must complete the guide's source-audit matrix for product context, services, HTTP APIs, MCP servers, CLI tools, tests, data and runtime evidence. It traces wrappers and hidden subcommands, makes a second source pass before reporting absence, and reconciles any existing YAML against source. This catches a local `stdio` MCP server exposed only as a CLI subcommand. The first-phase report separates verified implementations from uncertain candidates, names source evidence, environment variable names and access scope, and waits for review. A server requiring a separate read-only key must not receive an owner credential. Registration does not connect or invoke it; the user tests the server in MCP Explorer deliberately. The source audit improves setup completeness but is not a universal protocol importer or a runtime test. MCP Explorer supports local `stdio`, Streamable HTTP and legacy SSE with manual connection; custom transports need an adapter. It labels project registrations separately from coding-tool client settings, which can point to external servers. API Explorer uses existing OpenAPI 3.x documents, an explicitly loaded OpenAPI path on a registered API, or manually entered HTTP paths and supports none, Bearer, API key and public-client OAuth; GraphQL, gRPC, multipart uploads, cookie/Basic/mTLS and confidential OAuth clients have no dedicated request flow. CLI Explorer discovers common package, Python, Cargo, Go and executable entry points; unbuilt package targets are visible but cannot be run until built. Individual subcommands and safe arguments still need source review or explicit help. Test Explorer can discover Node and Rust cases in supported forms; other runners need explicit test commands. Data Explorer handles PostgreSQL, MySQL/MariaDB, SQLite and local files, not every database or event stream. Foreground services and explicitly modeled detached lifecycles are operable; the CPU/memory collector does not measure containers after a detached launch. The agent should mark these limits as unsupported or manual rather than fabricate an integration. ## API Explorer +A project OpenAPI file already named in `workspace.apiSources` appears only as the registered API, including when the relative path uses a `./` prefix. + Project-local OpenAPI 3.x files are scanned read-only and listed beside HTTP APIs declared in `workspace.apiSources`. The file remains the source of truth for endpoint paths and summaries; the repository YAML stores only its relative path, clean base URL and public authentication metadata. Alternatively, `specPath` identifies a dynamically served OpenAPI document on the registered API. The user must click **Load OpenAPI**; the main process fetches from that API's origin without redirects or authentication headers, with a timeout and 2 MB limit. An API can be registered without a spec and tested with a manually entered relative path. The main process performs a request only after the user clicks Send, checks that the target stays on the selected origin, blocks redirects, applies a timeout and bounds the response preview. It resolves Bearer and API-key values from the local project `.env`. Public-client OAuth uses PKCE and a loopback callback; access and refresh tokens are encrypted outside the repository with macOS secure storage. Activity records only request metadata, without headers, query values, body or response content. The included Hello Workspace has a matching OpenAPI document for its real health and notes endpoints. ## MCP Explorer diff --git a/docs/product/command-tools.md b/docs/product/command-tools.md index aa4c108..9ec5b75 100644 --- a/docs/product/command-tools.md +++ b/docs/product/command-tools.md @@ -1,5 +1,7 @@ # CLI Explorer +An entry point already linked to a registered YAML tool appears only once, under the registered tool. Catalog counts reflect distinct tools rather than both discovery and registration. + CLI Explorer follows the same browse and inspect layout as MCP Explorer. The left catalog lists **Discovered locally** entry points found by reading the open repository: `package.json` `bin` entries, Python project scripts, Cargo binaries, Go `cmd/*/main.go` and `examples/*/main.go` programs, and executable CLI files. A package CLI whose declared `dist/` or `build/` target is absent is labeled **Build required**; it cannot be run, linked or queried for help until that target exists. This scan does not run candidates. It is intentionally bounded and may miss custom build systems; ordinary package scripts and tests are not automatically treated as product CLIs. **In .projectroom/project.yaml** lists registered `commandTool` components. Select either type to inspect it on the right. Select a discovered entry to see its source file and exact command. **Read help** explicitly starts the command with `--help`, `-h`, or `help` and shows the real output, including a parsed synopsis, paired short and long flags, common subcommand lists and positional arguments where recognizable. Parsed commands and options become suggestions in Explore. The full original output stays visible because CLI help has no universal machine-readable format. A program can have side effects even while printing help; Project Room never requests it automatically. Discovery does not prove that the CLI is safe or fully documented. diff --git a/scripts/api-explorer.test.cjs b/scripts/api-explorer.test.cjs index 253cf3d..fdb5fed 100644 --- a/scripts/api-explorer.test.cjs +++ b/scripts/api-explorer.test.cjs @@ -48,6 +48,12 @@ test('discovers real OpenAPI operations and manages multiple YAML sources', t => assert.equal(discoverSpecs(root).length, 1); }); +test('a configured OpenAPI file is not listed again when its path has a dot prefix', t => { + const root = fixture(t); + const config = { workspace: { apiSources: [{ id: 'orders', name: 'Orders', baseUrl: 'https://example.com', spec: './specs/001-orders/contracts/openapi.yaml' }] } }; + assert.deepEqual(listApiSources(root, config).map(item => item.id), ['yaml:orders']); +}); + test('loads a live OpenAPI document only on request and only from the configured API origin', async t => { const root = fixture(t); const saved = addApiSource(root, { name: 'Live API', baseUrl: 'http://127.0.0.1:43179/rest', specPath: '/open-api/core' }); diff --git a/scripts/cli-explorer.test.cjs b/scripts/cli-explorer.test.cjs index 1c848e8..dc8e54c 100644 --- a/scripts/cli-explorer.test.cjs +++ b/scripts/cli-explorer.test.cjs @@ -3,10 +3,30 @@ const assert = require('node:assert/strict'); const fs = require('node:fs'); const os = require('node:os'); const path = require('node:path'); +const vm = require('node:vm'); const { discoverCliTools, inspectCliHelp, linkCliTool } = require('../desktop/cli-explorer.cjs'); const { runCliTrial } = require('../desktop/command-tools.cjs'); const { commandParsedHelp } = require('../dist/cli-help.js'); +test('CLI catalog lists a linked discovery only under its registered tool', () => { + const tool = { id: 'blackbox-host', kind: 'commandTool', name: 'Blackbox Host CLI', runtime: { command: ['./blackbox', '--help'] }, cli: { mode: 'task' } }; + const candidate = { id: 'file:blackbox', name: 'blackbox', path: 'blackbox', source: 'executable', command: ['./blackbox'], linkedId: tool.id }; + const context = { + document: { addEventListener() {} }, escapeHtml: String, icon: () => '', pageHead: () => '', + projectRoot: null, pv: null, state: { page: 'commands' }, commandToolsPage: null, + commandTools: () => [tool], commandSelected: () => tool, commandStatus: () => 'Stopped', commandLive: () => false, + commandCandidates: [candidate], commandCandidateId: candidate.id, commandCandidatesRoot: null, + commandCandidatesLoading: false, commandCandidatesError: '', commandSearch: '', commandTab: 'explore', + commandBusy: {}, commandHelp: {}, commandOutput: {}, commandCandidateHelp: {}, commandHelpArgs: {} + }; + vm.runInNewContext(fs.readFileSync(path.join(__dirname, '../dist/cli-explorer-ui.js'), 'utf8'), context); + const html = context.commandToolsPage(); + assert.match(html, /Project tools<\/strong>1 found/); + assert.match(html, /DISCOVERED LOCALLY · 0/); + assert.match(html, /Blackbox Host CLI/); + assert.doesNotMatch(html, /data-cli="select"/); +}); + test('recognizes paired flags, value options and subcommands in common help output', () => { const help = commandParsedHelp('Usage: desk [OPTIONS]\n\nCommands:\n serve Start the server\n status Show status\n\nOptions:\n -h, --help Print help\n --format Output format\n -v, --verbose Verbose output'); assert.deepEqual(help.commands.map(item => item.name), ['serve', 'status']); diff --git a/scripts/mcp-explorer.test.cjs b/scripts/mcp-explorer.test.cjs index 1062909..2fd8a25 100644 --- a/scripts/mcp-explorer.test.cjs +++ b/scripts/mcp-explorer.test.cjs @@ -69,3 +69,19 @@ test('MCP configuration placeholders appear as local Environment variable names' const names = referencedNames({ args: ['--token', '${MCP_TOKEN}'], headers: { Authorization: 'Bearer ${MCP_TOKEN}' }, env: { API_KEY: '${MCP_TOKEN}' } }); assert.deepEqual(names.sort(), ['API_KEY', 'MCP_TOKEN']); }); + +test('MCP client connection already registered in YAML is linked by its target', () => { + const root = fs.mkdtempSync(path.join(os.tmpdir(), 'project-room-mcp-dedup-')); + try { + fs.writeFileSync(path.join(root, '.mcp.json'), JSON.stringify({ mcpServers: { + local: { command: './blackbox', args: ['mcp'] }, + other: { command: './blackbox', args: ['mcp', '--other'] } + } })); + const config = { workspace: { mcpServers: [{ id: 'blackbox', name: 'Blackbox MCP', transport: 'stdio', command: './blackbox', args: ['mcp'], cwd: './' }] } }; + const explorer = new McpExplorer({ getRoot: () => root, getConfig: () => config, getEnvironment: () => null }); + const listed = explorer.list(); + assert.equal(listed.find(item => item.id === '.mcp.json:local').linkedId, 'blackbox'); + assert.equal(listed.find(item => item.id === '.mcp.json:other').linkedId, null); + assert.equal(listed.find(item => item.id === 'yaml:blackbox').linkedId, null); + } finally { fs.rmSync(root, { recursive: true, force: true }); } +});