@dotsetlabs/bellwether 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +291 -0
- package/LICENSE +21 -0
- package/README.md +739 -0
- package/dist/auth/credentials.d.ts +64 -0
- package/dist/auth/credentials.js +218 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.js +6 -0
- package/dist/auth/keychain.d.ts +64 -0
- package/dist/auth/keychain.js +268 -0
- package/dist/baseline/ab-testing.d.ts +80 -0
- package/dist/baseline/ab-testing.js +236 -0
- package/dist/baseline/ai-compatibility-scorer.d.ts +95 -0
- package/dist/baseline/ai-compatibility-scorer.js +606 -0
- package/dist/baseline/calibration.d.ts +77 -0
- package/dist/baseline/calibration.js +136 -0
- package/dist/baseline/category-matching.d.ts +85 -0
- package/dist/baseline/category-matching.js +289 -0
- package/dist/baseline/change-impact-analyzer.d.ts +98 -0
- package/dist/baseline/change-impact-analyzer.js +592 -0
- package/dist/baseline/comparator.d.ts +64 -0
- package/dist/baseline/comparator.js +916 -0
- package/dist/baseline/confidence.d.ts +55 -0
- package/dist/baseline/confidence.js +122 -0
- package/dist/baseline/converter.d.ts +61 -0
- package/dist/baseline/converter.js +585 -0
- package/dist/baseline/dependency-analyzer.d.ts +89 -0
- package/dist/baseline/dependency-analyzer.js +567 -0
- package/dist/baseline/deprecation-tracker.d.ts +133 -0
- package/dist/baseline/deprecation-tracker.js +322 -0
- package/dist/baseline/diff.d.ts +55 -0
- package/dist/baseline/diff.js +1584 -0
- package/dist/baseline/documentation-scorer.d.ts +205 -0
- package/dist/baseline/documentation-scorer.js +466 -0
- package/dist/baseline/embeddings.d.ts +118 -0
- package/dist/baseline/embeddings.js +251 -0
- package/dist/baseline/error-analyzer.d.ts +198 -0
- package/dist/baseline/error-analyzer.js +721 -0
- package/dist/baseline/evaluation/evaluator.d.ts +42 -0
- package/dist/baseline/evaluation/evaluator.js +323 -0
- package/dist/baseline/evaluation/expanded-dataset.d.ts +45 -0
- package/dist/baseline/evaluation/expanded-dataset.js +1164 -0
- package/dist/baseline/evaluation/golden-dataset.d.ts +58 -0
- package/dist/baseline/evaluation/golden-dataset.js +717 -0
- package/dist/baseline/evaluation/index.d.ts +15 -0
- package/dist/baseline/evaluation/index.js +15 -0
- package/dist/baseline/evaluation/types.d.ts +186 -0
- package/dist/baseline/evaluation/types.js +8 -0
- package/dist/baseline/external-dependency-detector.d.ts +181 -0
- package/dist/baseline/external-dependency-detector.js +524 -0
- package/dist/baseline/golden-output.d.ts +162 -0
- package/dist/baseline/golden-output.js +636 -0
- package/dist/baseline/health-scorer.d.ts +174 -0
- package/dist/baseline/health-scorer.js +451 -0
- package/dist/baseline/incremental-checker.d.ts +97 -0
- package/dist/baseline/incremental-checker.js +174 -0
- package/dist/baseline/index.d.ts +31 -0
- package/dist/baseline/index.js +42 -0
- package/dist/baseline/migration-generator.d.ts +137 -0
- package/dist/baseline/migration-generator.js +554 -0
- package/dist/baseline/migrations.d.ts +60 -0
- package/dist/baseline/migrations.js +197 -0
- package/dist/baseline/performance-tracker.d.ts +214 -0
- package/dist/baseline/performance-tracker.js +577 -0
- package/dist/baseline/pr-comment-generator.d.ts +117 -0
- package/dist/baseline/pr-comment-generator.js +546 -0
- package/dist/baseline/response-fingerprint.d.ts +127 -0
- package/dist/baseline/response-fingerprint.js +728 -0
- package/dist/baseline/response-schema-tracker.d.ts +129 -0
- package/dist/baseline/response-schema-tracker.js +420 -0
- package/dist/baseline/risk-scorer.d.ts +54 -0
- package/dist/baseline/risk-scorer.js +434 -0
- package/dist/baseline/saver.d.ts +89 -0
- package/dist/baseline/saver.js +554 -0
- package/dist/baseline/scenario-generator.d.ts +151 -0
- package/dist/baseline/scenario-generator.js +905 -0
- package/dist/baseline/schema-compare.d.ts +86 -0
- package/dist/baseline/schema-compare.js +557 -0
- package/dist/baseline/schema-evolution.d.ts +189 -0
- package/dist/baseline/schema-evolution.js +467 -0
- package/dist/baseline/semantic.d.ts +203 -0
- package/dist/baseline/semantic.js +908 -0
- package/dist/baseline/synonyms.d.ts +60 -0
- package/dist/baseline/synonyms.js +386 -0
- package/dist/baseline/telemetry.d.ts +165 -0
- package/dist/baseline/telemetry.js +294 -0
- package/dist/baseline/test-pruner.d.ts +120 -0
- package/dist/baseline/test-pruner.js +387 -0
- package/dist/baseline/types.d.ts +449 -0
- package/dist/baseline/types.js +5 -0
- package/dist/baseline/version.d.ts +138 -0
- package/dist/baseline/version.js +206 -0
- package/dist/cache/index.d.ts +5 -0
- package/dist/cache/index.js +5 -0
- package/dist/cache/response-cache.d.ts +151 -0
- package/dist/cache/response-cache.js +287 -0
- package/dist/ci/index.d.ts +60 -0
- package/dist/ci/index.js +342 -0
- package/dist/cli/commands/auth.d.ts +12 -0
- package/dist/cli/commands/auth.js +352 -0
- package/dist/cli/commands/badge.d.ts +3 -0
- package/dist/cli/commands/badge.js +74 -0
- package/dist/cli/commands/baseline-accept.d.ts +15 -0
- package/dist/cli/commands/baseline-accept.js +178 -0
- package/dist/cli/commands/baseline-migrate.d.ts +12 -0
- package/dist/cli/commands/baseline-migrate.js +164 -0
- package/dist/cli/commands/baseline.d.ts +14 -0
- package/dist/cli/commands/baseline.js +449 -0
- package/dist/cli/commands/beta.d.ts +10 -0
- package/dist/cli/commands/beta.js +231 -0
- package/dist/cli/commands/check.d.ts +11 -0
- package/dist/cli/commands/check.js +820 -0
- package/dist/cli/commands/cloud/badge.d.ts +3 -0
- package/dist/cli/commands/cloud/badge.js +74 -0
- package/dist/cli/commands/cloud/diff.d.ts +6 -0
- package/dist/cli/commands/cloud/diff.js +79 -0
- package/dist/cli/commands/cloud/history.d.ts +6 -0
- package/dist/cli/commands/cloud/history.js +102 -0
- package/dist/cli/commands/cloud/link.d.ts +9 -0
- package/dist/cli/commands/cloud/link.js +119 -0
- package/dist/cli/commands/cloud/login.d.ts +7 -0
- package/dist/cli/commands/cloud/login.js +499 -0
- package/dist/cli/commands/cloud/projects.d.ts +6 -0
- package/dist/cli/commands/cloud/projects.js +44 -0
- package/dist/cli/commands/cloud/shared.d.ts +7 -0
- package/dist/cli/commands/cloud/shared.js +42 -0
- package/dist/cli/commands/cloud/teams.d.ts +8 -0
- package/dist/cli/commands/cloud/teams.js +169 -0
- package/dist/cli/commands/cloud/upload.d.ts +8 -0
- package/dist/cli/commands/cloud/upload.js +181 -0
- package/dist/cli/commands/contract.d.ts +11 -0
- package/dist/cli/commands/contract.js +280 -0
- package/dist/cli/commands/discover.d.ts +3 -0
- package/dist/cli/commands/discover.js +82 -0
- package/dist/cli/commands/eval.d.ts +9 -0
- package/dist/cli/commands/eval.js +187 -0
- package/dist/cli/commands/explore.d.ts +11 -0
- package/dist/cli/commands/explore.js +437 -0
- package/dist/cli/commands/feedback.d.ts +9 -0
- package/dist/cli/commands/feedback.js +174 -0
- package/dist/cli/commands/golden.d.ts +12 -0
- package/dist/cli/commands/golden.js +407 -0
- package/dist/cli/commands/history.d.ts +10 -0
- package/dist/cli/commands/history.js +202 -0
- package/dist/cli/commands/init.d.ts +9 -0
- package/dist/cli/commands/init.js +219 -0
- package/dist/cli/commands/interview.d.ts +3 -0
- package/dist/cli/commands/interview.js +903 -0
- package/dist/cli/commands/link.d.ts +10 -0
- package/dist/cli/commands/link.js +169 -0
- package/dist/cli/commands/login.d.ts +7 -0
- package/dist/cli/commands/login.js +499 -0
- package/dist/cli/commands/preset.d.ts +33 -0
- package/dist/cli/commands/preset.js +297 -0
- package/dist/cli/commands/profile.d.ts +33 -0
- package/dist/cli/commands/profile.js +286 -0
- package/dist/cli/commands/registry.d.ts +11 -0
- package/dist/cli/commands/registry.js +146 -0
- package/dist/cli/commands/shared.d.ts +79 -0
- package/dist/cli/commands/shared.js +196 -0
- package/dist/cli/commands/teams.d.ts +8 -0
- package/dist/cli/commands/teams.js +169 -0
- package/dist/cli/commands/test.d.ts +9 -0
- package/dist/cli/commands/test.js +500 -0
- package/dist/cli/commands/upload.d.ts +8 -0
- package/dist/cli/commands/upload.js +223 -0
- package/dist/cli/commands/validate-config.d.ts +6 -0
- package/dist/cli/commands/validate-config.js +35 -0
- package/dist/cli/commands/verify.d.ts +11 -0
- package/dist/cli/commands/verify.js +283 -0
- package/dist/cli/commands/watch.d.ts +12 -0
- package/dist/cli/commands/watch.js +253 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +178 -0
- package/dist/cli/interactive.d.ts +47 -0
- package/dist/cli/interactive.js +216 -0
- package/dist/cli/output/terminal-reporter.d.ts +19 -0
- package/dist/cli/output/terminal-reporter.js +104 -0
- package/dist/cli/output.d.ts +226 -0
- package/dist/cli/output.js +438 -0
- package/dist/cli/utils/env.d.ts +5 -0
- package/dist/cli/utils/env.js +14 -0
- package/dist/cli/utils/progress.d.ts +59 -0
- package/dist/cli/utils/progress.js +206 -0
- package/dist/cli/utils/server-context.d.ts +10 -0
- package/dist/cli/utils/server-context.js +36 -0
- package/dist/cloud/auth.d.ts +144 -0
- package/dist/cloud/auth.js +374 -0
- package/dist/cloud/client.d.ts +24 -0
- package/dist/cloud/client.js +65 -0
- package/dist/cloud/http-client.d.ts +38 -0
- package/dist/cloud/http-client.js +215 -0
- package/dist/cloud/index.d.ts +23 -0
- package/dist/cloud/index.js +25 -0
- package/dist/cloud/mock-client.d.ts +107 -0
- package/dist/cloud/mock-client.js +545 -0
- package/dist/cloud/types.d.ts +515 -0
- package/dist/cloud/types.js +15 -0
- package/dist/config/defaults.d.ts +160 -0
- package/dist/config/defaults.js +169 -0
- package/dist/config/loader.d.ts +24 -0
- package/dist/config/loader.js +122 -0
- package/dist/config/template.d.ts +42 -0
- package/dist/config/template.js +647 -0
- package/dist/config/validator.d.ts +2112 -0
- package/dist/config/validator.js +658 -0
- package/dist/constants/cloud.d.ts +107 -0
- package/dist/constants/cloud.js +110 -0
- package/dist/constants/core.d.ts +521 -0
- package/dist/constants/core.js +556 -0
- package/dist/constants/testing.d.ts +1283 -0
- package/dist/constants/testing.js +1568 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.js +10 -0
- package/dist/contract/index.d.ts +6 -0
- package/dist/contract/index.js +5 -0
- package/dist/contract/validator.d.ts +177 -0
- package/dist/contract/validator.js +574 -0
- package/dist/cost/index.d.ts +6 -0
- package/dist/cost/index.js +5 -0
- package/dist/cost/tracker.d.ts +134 -0
- package/dist/cost/tracker.js +313 -0
- package/dist/discovery/discovery.d.ts +16 -0
- package/dist/discovery/discovery.js +173 -0
- package/dist/discovery/types.d.ts +51 -0
- package/dist/discovery/types.js +2 -0
- package/dist/docs/agents.d.ts +3 -0
- package/dist/docs/agents.js +995 -0
- package/dist/docs/contract.d.ts +51 -0
- package/dist/docs/contract.js +1681 -0
- package/dist/docs/generator.d.ts +4 -0
- package/dist/docs/generator.js +4 -0
- package/dist/docs/html-reporter.d.ts +9 -0
- package/dist/docs/html-reporter.js +757 -0
- package/dist/docs/index.d.ts +10 -0
- package/dist/docs/index.js +11 -0
- package/dist/docs/junit-reporter.d.ts +18 -0
- package/dist/docs/junit-reporter.js +210 -0
- package/dist/docs/report.d.ts +14 -0
- package/dist/docs/report.js +44 -0
- package/dist/docs/sarif-reporter.d.ts +19 -0
- package/dist/docs/sarif-reporter.js +335 -0
- package/dist/docs/shared.d.ts +35 -0
- package/dist/docs/shared.js +162 -0
- package/dist/docs/templates.d.ts +12 -0
- package/dist/docs/templates.js +76 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.js +6 -0
- package/dist/errors/retry.d.ts +92 -0
- package/dist/errors/retry.js +323 -0
- package/dist/errors/types.d.ts +321 -0
- package/dist/errors/types.js +584 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +32 -0
- package/dist/interview/dependency-resolver.d.ts +11 -0
- package/dist/interview/dependency-resolver.js +32 -0
- package/dist/interview/interviewer.d.ts +232 -0
- package/dist/interview/interviewer.js +1939 -0
- package/dist/interview/mock-response-generator.d.ts +7 -0
- package/dist/interview/mock-response-generator.js +102 -0
- package/dist/interview/orchestrator.d.ts +237 -0
- package/dist/interview/orchestrator.js +1296 -0
- package/dist/interview/rate-limiter.d.ts +15 -0
- package/dist/interview/rate-limiter.js +55 -0
- package/dist/interview/response-validator.d.ts +10 -0
- package/dist/interview/response-validator.js +132 -0
- package/dist/interview/schema-inferrer.d.ts +8 -0
- package/dist/interview/schema-inferrer.js +71 -0
- package/dist/interview/schema-test-generator.d.ts +71 -0
- package/dist/interview/schema-test-generator.js +834 -0
- package/dist/interview/smart-value-generator.d.ts +155 -0
- package/dist/interview/smart-value-generator.js +554 -0
- package/dist/interview/stateful-test-runner.d.ts +19 -0
- package/dist/interview/stateful-test-runner.js +106 -0
- package/dist/interview/types.d.ts +561 -0
- package/dist/interview/types.js +2 -0
- package/dist/llm/anthropic.d.ts +41 -0
- package/dist/llm/anthropic.js +355 -0
- package/dist/llm/client.d.ts +123 -0
- package/dist/llm/client.js +42 -0
- package/dist/llm/factory.d.ts +38 -0
- package/dist/llm/factory.js +145 -0
- package/dist/llm/fallback.d.ts +140 -0
- package/dist/llm/fallback.js +379 -0
- package/dist/llm/index.d.ts +18 -0
- package/dist/llm/index.js +15 -0
- package/dist/llm/ollama.d.ts +37 -0
- package/dist/llm/ollama.js +330 -0
- package/dist/llm/openai.d.ts +25 -0
- package/dist/llm/openai.js +320 -0
- package/dist/llm/token-budget.d.ts +161 -0
- package/dist/llm/token-budget.js +395 -0
- package/dist/logging/logger.d.ts +70 -0
- package/dist/logging/logger.js +130 -0
- package/dist/metrics/collector.d.ts +106 -0
- package/dist/metrics/collector.js +547 -0
- package/dist/metrics/index.d.ts +7 -0
- package/dist/metrics/index.js +7 -0
- package/dist/metrics/prometheus.d.ts +20 -0
- package/dist/metrics/prometheus.js +241 -0
- package/dist/metrics/types.d.ts +209 -0
- package/dist/metrics/types.js +5 -0
- package/dist/persona/builtins.d.ts +54 -0
- package/dist/persona/builtins.js +219 -0
- package/dist/persona/index.d.ts +8 -0
- package/dist/persona/index.js +8 -0
- package/dist/persona/loader.d.ts +30 -0
- package/dist/persona/loader.js +190 -0
- package/dist/persona/types.d.ts +144 -0
- package/dist/persona/types.js +5 -0
- package/dist/persona/validation.d.ts +94 -0
- package/dist/persona/validation.js +332 -0
- package/dist/prompts/index.d.ts +5 -0
- package/dist/prompts/index.js +5 -0
- package/dist/prompts/templates.d.ts +180 -0
- package/dist/prompts/templates.js +431 -0
- package/dist/registry/client.d.ts +49 -0
- package/dist/registry/client.js +191 -0
- package/dist/registry/index.d.ts +7 -0
- package/dist/registry/index.js +6 -0
- package/dist/registry/types.d.ts +140 -0
- package/dist/registry/types.js +6 -0
- package/dist/scenarios/evaluator.d.ts +43 -0
- package/dist/scenarios/evaluator.js +206 -0
- package/dist/scenarios/index.d.ts +10 -0
- package/dist/scenarios/index.js +9 -0
- package/dist/scenarios/loader.d.ts +20 -0
- package/dist/scenarios/loader.js +285 -0
- package/dist/scenarios/types.d.ts +153 -0
- package/dist/scenarios/types.js +8 -0
- package/dist/security/index.d.ts +17 -0
- package/dist/security/index.js +18 -0
- package/dist/security/payloads.d.ts +61 -0
- package/dist/security/payloads.js +268 -0
- package/dist/security/security-tester.d.ts +42 -0
- package/dist/security/security-tester.js +582 -0
- package/dist/security/types.d.ts +166 -0
- package/dist/security/types.js +8 -0
- package/dist/transport/base-transport.d.ts +59 -0
- package/dist/transport/base-transport.js +38 -0
- package/dist/transport/http-transport.d.ts +67 -0
- package/dist/transport/http-transport.js +238 -0
- package/dist/transport/mcp-client.d.ts +141 -0
- package/dist/transport/mcp-client.js +496 -0
- package/dist/transport/sse-transport.d.ts +88 -0
- package/dist/transport/sse-transport.js +316 -0
- package/dist/transport/stdio-transport.d.ts +43 -0
- package/dist/transport/stdio-transport.js +238 -0
- package/dist/transport/types.d.ts +125 -0
- package/dist/transport/types.js +16 -0
- package/dist/utils/concurrency.d.ts +123 -0
- package/dist/utils/concurrency.js +213 -0
- package/dist/utils/formatters.d.ts +16 -0
- package/dist/utils/formatters.js +37 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/jsonpath.d.ts +87 -0
- package/dist/utils/jsonpath.js +326 -0
- package/dist/utils/markdown.d.ts +113 -0
- package/dist/utils/markdown.js +265 -0
- package/dist/utils/network.d.ts +14 -0
- package/dist/utils/network.js +17 -0
- package/dist/utils/sanitize.d.ts +92 -0
- package/dist/utils/sanitize.js +191 -0
- package/dist/utils/semantic.d.ts +194 -0
- package/dist/utils/semantic.js +1051 -0
- package/dist/utils/smart-truncate.d.ts +94 -0
- package/dist/utils/smart-truncate.js +361 -0
- package/dist/utils/timeout.d.ts +153 -0
- package/dist/utils/timeout.js +205 -0
- package/dist/utils/yaml-parser.d.ts +58 -0
- package/dist/utils/yaml-parser.js +86 -0
- package/dist/validation/index.d.ts +32 -0
- package/dist/validation/index.js +32 -0
- package/dist/validation/semantic-test-generator.d.ts +50 -0
- package/dist/validation/semantic-test-generator.js +176 -0
- package/dist/validation/semantic-types.d.ts +66 -0
- package/dist/validation/semantic-types.js +94 -0
- package/dist/validation/semantic-validator.d.ts +38 -0
- package/dist/validation/semantic-validator.js +340 -0
- package/dist/verification/index.d.ts +6 -0
- package/dist/verification/index.js +5 -0
- package/dist/verification/types.d.ts +133 -0
- package/dist/verification/types.js +5 -0
- package/dist/verification/verifier.d.ts +30 -0
- package/dist/verification/verifier.js +309 -0
- package/dist/version.d.ts +19 -0
- package/dist/version.js +48 -0
- package/dist/workflow/auto-generator.d.ts +27 -0
- package/dist/workflow/auto-generator.js +513 -0
- package/dist/workflow/discovery.d.ts +40 -0
- package/dist/workflow/discovery.js +195 -0
- package/dist/workflow/executor.d.ts +82 -0
- package/dist/workflow/executor.js +611 -0
- package/dist/workflow/index.d.ts +10 -0
- package/dist/workflow/index.js +10 -0
- package/dist/workflow/loader.d.ts +24 -0
- package/dist/workflow/loader.js +194 -0
- package/dist/workflow/state-tracker.d.ts +98 -0
- package/dist/workflow/state-tracker.js +424 -0
- package/dist/workflow/types.d.ts +337 -0
- package/dist/workflow/types.js +5 -0
- package/package.json +94 -0
- package/schemas/bellwether-check.schema.json +651 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry command - search and lookup MCP servers from the registry.
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { RegistryClient, generateRunCommand, } from '../../registry/index.js';
|
|
7
|
+
import { EXIT_CODES } from '../../constants.js';
|
|
8
|
+
import { loadConfig, ConfigNotFoundError } from '../../config/loader.js';
|
|
9
|
+
import * as output from '../output.js';
|
|
10
|
+
/**
|
|
11
|
+
* Create a new registry command instance.
|
|
12
|
+
* Useful for testing where fresh command instances are needed.
|
|
13
|
+
*/
|
|
14
|
+
export function createRegistryCommand() {
|
|
15
|
+
return new Command('registry')
|
|
16
|
+
.alias('lookup')
|
|
17
|
+
.description('Search the MCP Registry for servers')
|
|
18
|
+
.argument('[query]', 'Search query (server name or keyword)')
|
|
19
|
+
.option('-c, --config <path>', 'Path to config file')
|
|
20
|
+
.option('-l, --limit <number>', 'Maximum results to show')
|
|
21
|
+
.option('--json', 'Output as JSON')
|
|
22
|
+
.action(async (query, options) => {
|
|
23
|
+
await handleRegistry(query, options);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export const registryCommand = createRegistryCommand();
|
|
27
|
+
async function handleRegistry(query, options) {
|
|
28
|
+
let config;
|
|
29
|
+
try {
|
|
30
|
+
config = loadConfig(options.config);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (error instanceof ConfigNotFoundError) {
|
|
34
|
+
output.error(error.message);
|
|
35
|
+
process.exit(EXIT_CODES.ERROR);
|
|
36
|
+
}
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
// Allow overriding registry URL for testing
|
|
40
|
+
const registryUrl = process.env.BELLWETHER_REGISTRY_URL;
|
|
41
|
+
const client = new RegistryClient(registryUrl ? { baseUrl: registryUrl } : undefined);
|
|
42
|
+
const limit = parseInt(options.limit ?? String(config.registry.limit), 10) || config.registry.limit;
|
|
43
|
+
const outputJson = options.json ? true : config.registry.json;
|
|
44
|
+
try {
|
|
45
|
+
let servers;
|
|
46
|
+
if (query) {
|
|
47
|
+
output.info(chalk.gray(`Searching for "${query}"...`));
|
|
48
|
+
servers = await client.searchServers(query, limit);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
output.info(chalk.gray('Fetching popular servers...'));
|
|
52
|
+
const response = await client.listServers({ limit });
|
|
53
|
+
servers = response.servers;
|
|
54
|
+
}
|
|
55
|
+
if (outputJson) {
|
|
56
|
+
output.json(servers);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (servers.length === 0) {
|
|
60
|
+
output.info(chalk.yellow('No servers found.'));
|
|
61
|
+
if (query) {
|
|
62
|
+
output.info(chalk.gray(`Try a different search term or browse all servers with: bellwether registry`));
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// Header
|
|
67
|
+
output.newline();
|
|
68
|
+
output.info(chalk.bold(`Found ${servers.length} server(s)`));
|
|
69
|
+
output.info('─'.repeat(60));
|
|
70
|
+
output.newline();
|
|
71
|
+
// Display each server
|
|
72
|
+
for (const entry of servers) {
|
|
73
|
+
displayServer(entry);
|
|
74
|
+
output.newline();
|
|
75
|
+
}
|
|
76
|
+
// Footer with usage hint
|
|
77
|
+
output.info('─'.repeat(60));
|
|
78
|
+
output.info(chalk.gray('To test a server, run:'));
|
|
79
|
+
if (servers.length > 0) {
|
|
80
|
+
const firstServer = servers[0].server;
|
|
81
|
+
const runCmd = generateRunCommand(firstServer);
|
|
82
|
+
if (runCmd) {
|
|
83
|
+
output.info(chalk.cyan(` bellwether check ${runCmd}`));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error instanceof Error) {
|
|
89
|
+
output.error(chalk.red(`Error: ${error.message}`));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
output.error(chalk.red('An unexpected error occurred'));
|
|
93
|
+
}
|
|
94
|
+
process.exit(EXIT_CODES.ERROR);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function displayServer(entry) {
|
|
98
|
+
const { server } = entry;
|
|
99
|
+
const meta = entry._meta?.['io.modelcontextprotocol.registry/official'];
|
|
100
|
+
// Name and version
|
|
101
|
+
let nameLine = chalk.bold.blue(server.name);
|
|
102
|
+
if (server.version) {
|
|
103
|
+
nameLine += chalk.gray(` v${server.version}`);
|
|
104
|
+
}
|
|
105
|
+
if (meta?.status === 'active') {
|
|
106
|
+
nameLine += chalk.green(' ✓');
|
|
107
|
+
}
|
|
108
|
+
output.info(nameLine);
|
|
109
|
+
// Description
|
|
110
|
+
if (server.description) {
|
|
111
|
+
output.info(chalk.white(` ${server.description}`));
|
|
112
|
+
}
|
|
113
|
+
// Run command
|
|
114
|
+
const runCmd = generateRunCommand(server);
|
|
115
|
+
if (runCmd) {
|
|
116
|
+
output.info(chalk.gray(' Run: ') + chalk.cyan(runCmd));
|
|
117
|
+
}
|
|
118
|
+
// Transport and package info
|
|
119
|
+
if (server.packages && server.packages.length > 0) {
|
|
120
|
+
const pkg = server.packages[0];
|
|
121
|
+
const details = [];
|
|
122
|
+
if (pkg.registryType) {
|
|
123
|
+
details.push(pkg.registryType);
|
|
124
|
+
}
|
|
125
|
+
if (pkg.transport?.type) {
|
|
126
|
+
details.push(`transport: ${pkg.transport.type}`);
|
|
127
|
+
}
|
|
128
|
+
if (details.length > 0) {
|
|
129
|
+
output.info(chalk.gray(` [${details.join(', ')}]`));
|
|
130
|
+
}
|
|
131
|
+
// Required arguments
|
|
132
|
+
const requiredArgs = pkg.packageArguments?.filter(a => a.isRequired) ?? [];
|
|
133
|
+
if (requiredArgs.length > 0) {
|
|
134
|
+
output.info(chalk.gray(' Required args:'));
|
|
135
|
+
for (const arg of requiredArgs) {
|
|
136
|
+
const desc = arg.description ? ` - ${arg.description}` : '';
|
|
137
|
+
output.info(chalk.gray(` --${arg.name}${desc}`));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Links
|
|
142
|
+
if (server.repository?.url) {
|
|
143
|
+
output.info(chalk.gray(` Repository: ${server.repository.url}`));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for check and explore commands.
|
|
3
|
+
*
|
|
4
|
+
* This module contains code that is common to both commands to avoid duplication
|
|
5
|
+
* and ensure consistent behavior.
|
|
6
|
+
*/
|
|
7
|
+
import type { ServerContext } from '../../interview/types.js';
|
|
8
|
+
import type { BellwetherConfig } from '../../config/loader.js';
|
|
9
|
+
import type { DiscoveryResult } from '../../discovery/types.js';
|
|
10
|
+
import { MCPClient } from '../../transport/mcp-client.js';
|
|
11
|
+
import { type MetricsCollector } from '../../metrics/collector.js';
|
|
12
|
+
import { type ResponseCache } from '../../cache/response-cache.js';
|
|
13
|
+
import { type LoadedScenarios } from '../../scenarios/index.js';
|
|
14
|
+
/**
|
|
15
|
+
* Extract server context from command and arguments.
|
|
16
|
+
*
|
|
17
|
+
* Analyzes the server command to provide hints about the server type
|
|
18
|
+
* (filesystem, database, git, etc.) and extracts path arguments for
|
|
19
|
+
* allowed directories.
|
|
20
|
+
*/
|
|
21
|
+
export declare function extractServerContextFromArgs(command: string, args: string[]): ServerContext;
|
|
22
|
+
/**
|
|
23
|
+
* Detect if running in a CI environment.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isCI(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Common setup context for both check and explore commands.
|
|
28
|
+
*/
|
|
29
|
+
export interface CommandSetupContext {
|
|
30
|
+
mcpClient: MCPClient;
|
|
31
|
+
discovery: DiscoveryResult;
|
|
32
|
+
metricsCollector: MetricsCollector;
|
|
33
|
+
cache: ResponseCache;
|
|
34
|
+
fullServerCommand: string;
|
|
35
|
+
customScenarios?: LoadedScenarios;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Options for setting up a command.
|
|
39
|
+
*/
|
|
40
|
+
export interface SetupCommandOptions {
|
|
41
|
+
serverCommand: string;
|
|
42
|
+
args: string[];
|
|
43
|
+
config: BellwetherConfig;
|
|
44
|
+
verbose: boolean;
|
|
45
|
+
personaCount?: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Set up common infrastructure for check and explore commands.
|
|
49
|
+
*
|
|
50
|
+
* This handles the shared setup logic:
|
|
51
|
+
* - Initializing metrics collector
|
|
52
|
+
* - Initializing cache
|
|
53
|
+
* - Creating MCP client
|
|
54
|
+
* - Connecting to server
|
|
55
|
+
* - Discovering capabilities
|
|
56
|
+
* - Loading custom scenarios
|
|
57
|
+
*/
|
|
58
|
+
export declare function setupCommandInfrastructure(options: SetupCommandOptions): Promise<CommandSetupContext>;
|
|
59
|
+
/**
|
|
60
|
+
* Ensure output directories exist.
|
|
61
|
+
*/
|
|
62
|
+
export declare function ensureOutputDirs(outputDir: string, docsDir: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Display scenario results summary.
|
|
65
|
+
*/
|
|
66
|
+
export declare function displayScenarioResults(scenarioResults: Array<{
|
|
67
|
+
passed: boolean;
|
|
68
|
+
scenario: {
|
|
69
|
+
tool?: string;
|
|
70
|
+
prompt?: string;
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
error?: string;
|
|
74
|
+
}>): void;
|
|
75
|
+
/**
|
|
76
|
+
* Handle common error messages and provide helpful diagnostics.
|
|
77
|
+
*/
|
|
78
|
+
export declare function handleCommandError(error: unknown, commandName: 'check' | 'explore'): never;
|
|
79
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for check and explore commands.
|
|
3
|
+
*
|
|
4
|
+
* This module contains code that is common to both commands to avoid duplication
|
|
5
|
+
* and ensure consistent behavior.
|
|
6
|
+
*/
|
|
7
|
+
import { mkdirSync } from 'fs';
|
|
8
|
+
import { MCPClient } from '../../transport/mcp-client.js';
|
|
9
|
+
import { discover } from '../../discovery/discovery.js';
|
|
10
|
+
import { getMetricsCollector, resetMetricsCollector } from '../../metrics/collector.js';
|
|
11
|
+
import { getGlobalCache, resetGlobalCache } from '../../cache/response-cache.js';
|
|
12
|
+
import { loadScenariosFromFile, tryLoadDefaultScenarios, DEFAULT_SCENARIOS_FILE } from '../../scenarios/index.js';
|
|
13
|
+
import { EXIT_CODES } from '../../constants.js';
|
|
14
|
+
import * as output from '../output.js';
|
|
15
|
+
/**
|
|
16
|
+
* Extract server context from command and arguments.
|
|
17
|
+
*
|
|
18
|
+
* Analyzes the server command to provide hints about the server type
|
|
19
|
+
* (filesystem, database, git, etc.) and extracts path arguments for
|
|
20
|
+
* allowed directories.
|
|
21
|
+
*/
|
|
22
|
+
export function extractServerContextFromArgs(command, args) {
|
|
23
|
+
const context = {
|
|
24
|
+
allowedDirectories: [],
|
|
25
|
+
constraints: [],
|
|
26
|
+
hints: [],
|
|
27
|
+
};
|
|
28
|
+
const fullCommand = `${command} ${args.join(' ')}`.toLowerCase();
|
|
29
|
+
const pathArgs = args.filter((arg) => arg.startsWith('/') && !arg.startsWith('--'));
|
|
30
|
+
if (fullCommand.includes('filesystem') || fullCommand.includes('file-system')) {
|
|
31
|
+
context.allowedDirectories = pathArgs;
|
|
32
|
+
if (context.allowedDirectories.length > 0) {
|
|
33
|
+
context.hints.push(`Filesystem server with allowed directories: ${context.allowedDirectories.join(', ')}`);
|
|
34
|
+
}
|
|
35
|
+
context.constraints.push('Operations limited to specified directories');
|
|
36
|
+
}
|
|
37
|
+
else if (fullCommand.includes('postgres') || fullCommand.includes('mysql') || fullCommand.includes('sqlite')) {
|
|
38
|
+
context.hints.push('Database server - SQL operations expected');
|
|
39
|
+
context.constraints.push('Database operations only');
|
|
40
|
+
}
|
|
41
|
+
else if (fullCommand.includes('git')) {
|
|
42
|
+
context.allowedDirectories = pathArgs;
|
|
43
|
+
context.hints.push('Git server - repository operations expected');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
context.allowedDirectories = pathArgs;
|
|
47
|
+
}
|
|
48
|
+
return context;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Detect if running in a CI environment.
|
|
52
|
+
*/
|
|
53
|
+
export function isCI() {
|
|
54
|
+
return !!(process.env.CI ||
|
|
55
|
+
process.env.CONTINUOUS_INTEGRATION ||
|
|
56
|
+
process.env.GITHUB_ACTIONS ||
|
|
57
|
+
process.env.GITLAB_CI ||
|
|
58
|
+
process.env.CIRCLECI ||
|
|
59
|
+
process.env.JENKINS_URL ||
|
|
60
|
+
process.env.TRAVIS ||
|
|
61
|
+
process.env.BUILDKITE);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Set up common infrastructure for check and explore commands.
|
|
65
|
+
*
|
|
66
|
+
* This handles the shared setup logic:
|
|
67
|
+
* - Initializing metrics collector
|
|
68
|
+
* - Initializing cache
|
|
69
|
+
* - Creating MCP client
|
|
70
|
+
* - Connecting to server
|
|
71
|
+
* - Discovering capabilities
|
|
72
|
+
* - Loading custom scenarios
|
|
73
|
+
*/
|
|
74
|
+
export async function setupCommandInfrastructure(options) {
|
|
75
|
+
const { serverCommand, args, config, verbose, personaCount = 0 } = options;
|
|
76
|
+
// Initialize metrics collector
|
|
77
|
+
resetMetricsCollector();
|
|
78
|
+
const metricsCollector = getMetricsCollector();
|
|
79
|
+
metricsCollector.startInterview();
|
|
80
|
+
// Initialize cache
|
|
81
|
+
resetGlobalCache();
|
|
82
|
+
const cacheEnabled = config.cache.enabled;
|
|
83
|
+
const cache = getGlobalCache({ enabled: cacheEnabled });
|
|
84
|
+
if (cacheEnabled && verbose) {
|
|
85
|
+
output.info('Response caching enabled');
|
|
86
|
+
}
|
|
87
|
+
// Initialize MCP client
|
|
88
|
+
const mcpClient = new MCPClient({
|
|
89
|
+
timeout: config.server.timeout,
|
|
90
|
+
debug: config.logging.level === 'debug',
|
|
91
|
+
transport: 'stdio',
|
|
92
|
+
});
|
|
93
|
+
// Connect to MCP server
|
|
94
|
+
output.info('Connecting to MCP server...');
|
|
95
|
+
await mcpClient.connect(serverCommand, args, config.server.env);
|
|
96
|
+
// Discovery phase
|
|
97
|
+
output.info('Discovering capabilities...');
|
|
98
|
+
const discovery = await discover(mcpClient, serverCommand, args);
|
|
99
|
+
const resourceCount = discovery.resources?.length ?? 0;
|
|
100
|
+
const discoveryParts = [`${discovery.tools.length} tools`, `${discovery.prompts.length} prompts`];
|
|
101
|
+
if (resourceCount > 0) {
|
|
102
|
+
discoveryParts.push(`${resourceCount} resources`);
|
|
103
|
+
}
|
|
104
|
+
output.info(`Found ${discoveryParts.join(', ')}\n`);
|
|
105
|
+
// Update metrics
|
|
106
|
+
metricsCollector.updateInterviewCounters({
|
|
107
|
+
toolsDiscovered: discovery.tools.length,
|
|
108
|
+
personasUsed: personaCount,
|
|
109
|
+
});
|
|
110
|
+
// Load custom scenarios
|
|
111
|
+
const outputDir = config.output.dir;
|
|
112
|
+
let customScenarios;
|
|
113
|
+
if (config.scenarios.path) {
|
|
114
|
+
customScenarios = loadScenariosFromFile(config.scenarios.path);
|
|
115
|
+
output.info(`Loaded ${customScenarios.toolScenarios.length} tool scenarios from ${config.scenarios.path}`);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
const defaultScenarios = tryLoadDefaultScenarios(outputDir);
|
|
119
|
+
if (defaultScenarios) {
|
|
120
|
+
customScenarios = defaultScenarios;
|
|
121
|
+
output.info(`Auto-loaded ${customScenarios.toolScenarios.length} scenarios from ${DEFAULT_SCENARIOS_FILE}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const fullServerCommand = `${serverCommand} ${args.join(' ')}`.trim();
|
|
125
|
+
return {
|
|
126
|
+
mcpClient,
|
|
127
|
+
discovery,
|
|
128
|
+
metricsCollector,
|
|
129
|
+
cache,
|
|
130
|
+
fullServerCommand,
|
|
131
|
+
customScenarios,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Ensure output directories exist.
|
|
136
|
+
*/
|
|
137
|
+
export function ensureOutputDirs(outputDir, docsDir) {
|
|
138
|
+
mkdirSync(outputDir, { recursive: true });
|
|
139
|
+
if (docsDir !== outputDir) {
|
|
140
|
+
mkdirSync(docsDir, { recursive: true });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Display scenario results summary.
|
|
145
|
+
*/
|
|
146
|
+
export function displayScenarioResults(scenarioResults) {
|
|
147
|
+
if (!scenarioResults || scenarioResults.length === 0) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const passed = scenarioResults.filter((r) => r.passed).length;
|
|
151
|
+
const failed = scenarioResults.length - passed;
|
|
152
|
+
const statusIcon = failed === 0 ? '\u2713' : '\u2717';
|
|
153
|
+
output.info(`\nCustom scenarios: ${passed}/${scenarioResults.length} passed ${statusIcon}`);
|
|
154
|
+
if (failed > 0) {
|
|
155
|
+
output.info('\nFailed scenarios:');
|
|
156
|
+
for (const scenarioResult of scenarioResults.filter((r) => !r.passed)) {
|
|
157
|
+
const scenario = scenarioResult.scenario;
|
|
158
|
+
const toolOrPrompt = scenario.tool || scenario.prompt || 'unknown';
|
|
159
|
+
output.info(` - ${toolOrPrompt}: ${scenario.description}`);
|
|
160
|
+
if (scenarioResult.error) {
|
|
161
|
+
output.info(` Error: ${scenarioResult.error}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Handle common error messages and provide helpful diagnostics.
|
|
168
|
+
*/
|
|
169
|
+
export function handleCommandError(error, commandName) {
|
|
170
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
171
|
+
const title = commandName === 'check' ? 'Check Failed' : 'Exploration Failed';
|
|
172
|
+
output.error(`\n--- ${title} ---`);
|
|
173
|
+
output.error(`Error: ${errorMessage}`);
|
|
174
|
+
if (errorMessage.includes('ECONNREFUSED') || errorMessage.includes('Connection refused')) {
|
|
175
|
+
output.error('\nPossible causes:');
|
|
176
|
+
output.error(' - The MCP server is not running');
|
|
177
|
+
output.error(' - The server address/port is incorrect');
|
|
178
|
+
}
|
|
179
|
+
else if (errorMessage.includes('timeout') || errorMessage.includes('Timeout')) {
|
|
180
|
+
output.error('\nPossible causes:');
|
|
181
|
+
output.error(' - The MCP server is taking too long to respond');
|
|
182
|
+
output.error(' - Increase server.timeout in bellwether.yaml');
|
|
183
|
+
}
|
|
184
|
+
else if (errorMessage.includes('ENOENT') || errorMessage.includes('not found')) {
|
|
185
|
+
output.error('\nPossible causes:');
|
|
186
|
+
output.error(' - The server command was not found');
|
|
187
|
+
output.error(' - Check that the command is installed and in PATH');
|
|
188
|
+
}
|
|
189
|
+
else if (errorMessage.includes('API key') || errorMessage.includes('authentication')) {
|
|
190
|
+
output.error('\nPossible causes:');
|
|
191
|
+
output.error(' - Missing or invalid API key');
|
|
192
|
+
output.error(' - Run "bellwether auth" to configure API keys');
|
|
193
|
+
}
|
|
194
|
+
process.exit(EXIT_CODES.ERROR);
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Teams command for managing team selection in Bellwether Cloud.
|
|
3
|
+
*
|
|
4
|
+
* Allows users to list their teams and switch the active team for API requests.
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
export declare const teamsCommand: Command;
|
|
8
|
+
//# sourceMappingURL=teams.d.ts.map
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Teams command for managing team selection in Bellwether Cloud.
|
|
3
|
+
*
|
|
4
|
+
* Allows users to list their teams and switch the active team for API requests.
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import { getStoredSession, getSessionTeams, setActiveTeam, getTeamId, TEAM_ID_ENV_VAR, } from '../../cloud/auth.js';
|
|
8
|
+
import { EXIT_CODES } from '../../constants.js';
|
|
9
|
+
import * as output from '../output.js';
|
|
10
|
+
export const teamsCommand = new Command('teams')
|
|
11
|
+
.description('Manage team selection for cloud operations')
|
|
12
|
+
.option('--json', 'Output as JSON')
|
|
13
|
+
.action(async (options) => {
|
|
14
|
+
// List teams by default
|
|
15
|
+
const session = getStoredSession();
|
|
16
|
+
if (!session) {
|
|
17
|
+
output.error('Not logged in.');
|
|
18
|
+
output.error('Run `bellwether login` first.');
|
|
19
|
+
process.exit(EXIT_CODES.ERROR);
|
|
20
|
+
}
|
|
21
|
+
const teams = getSessionTeams();
|
|
22
|
+
if (teams.length === 0) {
|
|
23
|
+
output.warn('No teams found in session.');
|
|
24
|
+
output.info('Try logging out and back in: `bellwether login --logout && bellwether login`');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Check for env var override
|
|
28
|
+
const envTeamId = process.env[TEAM_ID_ENV_VAR];
|
|
29
|
+
const effectiveTeamId = getTeamId();
|
|
30
|
+
if (options.json) {
|
|
31
|
+
output.info(JSON.stringify({
|
|
32
|
+
teams,
|
|
33
|
+
activeTeamId: session.activeTeamId,
|
|
34
|
+
effectiveTeamId,
|
|
35
|
+
envOverride: envTeamId || null,
|
|
36
|
+
}, null, 2));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
output.info('Your Teams');
|
|
40
|
+
output.info('-----------');
|
|
41
|
+
for (const team of teams) {
|
|
42
|
+
const isActive = team.id === session.activeTeamId;
|
|
43
|
+
const isEffective = team.id === effectiveTeamId;
|
|
44
|
+
const markers = [];
|
|
45
|
+
if (isActive)
|
|
46
|
+
markers.push('active');
|
|
47
|
+
if (envTeamId && isEffective)
|
|
48
|
+
markers.push('env override');
|
|
49
|
+
const suffix = markers.length > 0 ? ` (${markers.join(', ')})` : '';
|
|
50
|
+
const roleStr = `[${team.role}]`;
|
|
51
|
+
output.info(` ${isEffective ? '>' : ' '} ${team.name} ${roleStr} - ${team.plan}${suffix}`);
|
|
52
|
+
output.info(` ID: ${team.id}`);
|
|
53
|
+
}
|
|
54
|
+
if (envTeamId) {
|
|
55
|
+
output.info(`\nNote: ${TEAM_ID_ENV_VAR} is set, overriding session team.`);
|
|
56
|
+
}
|
|
57
|
+
if (teams.length > 1) {
|
|
58
|
+
output.info('\nUse `bellwether teams switch <team-id>` to change active team.');
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// Subcommand: switch
|
|
62
|
+
teamsCommand
|
|
63
|
+
.command('switch [team-id]')
|
|
64
|
+
.description('Switch to a different team')
|
|
65
|
+
.action(async (teamIdArg) => {
|
|
66
|
+
const session = getStoredSession();
|
|
67
|
+
if (!session) {
|
|
68
|
+
output.error('Not logged in.');
|
|
69
|
+
output.error('Run `bellwether login` first.');
|
|
70
|
+
process.exit(EXIT_CODES.ERROR);
|
|
71
|
+
}
|
|
72
|
+
const teams = getSessionTeams();
|
|
73
|
+
if (teams.length === 0) {
|
|
74
|
+
output.warn('No teams found in session.');
|
|
75
|
+
output.info('Try logging out and back in: `bellwether login --logout && bellwether login`');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (teams.length === 1) {
|
|
79
|
+
output.info(`You only have access to one team: ${teams[0].name}`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const targetTeamId = teamIdArg;
|
|
83
|
+
// If no team ID provided, show interactive selection
|
|
84
|
+
if (!targetTeamId) {
|
|
85
|
+
output.info('Select a team:\n');
|
|
86
|
+
for (let i = 0; i < teams.length; i++) {
|
|
87
|
+
const team = teams[i];
|
|
88
|
+
const isActive = team.id === session.activeTeamId;
|
|
89
|
+
const marker = isActive ? ' (current)' : '';
|
|
90
|
+
output.info(` ${i + 1}. ${team.name} [${team.role}]${marker}`);
|
|
91
|
+
output.info(` ID: ${team.id}`);
|
|
92
|
+
}
|
|
93
|
+
output.info('\nRun `bellwether teams switch <team-id>` with a team ID from above.');
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// Find the target team
|
|
97
|
+
const targetTeam = teams.find(t => t.id === targetTeamId || t.name.toLowerCase() === targetTeamId.toLowerCase());
|
|
98
|
+
if (!targetTeam) {
|
|
99
|
+
output.error(`Team not found: ${targetTeamId}`);
|
|
100
|
+
output.error('\nAvailable teams:');
|
|
101
|
+
for (const team of teams) {
|
|
102
|
+
output.error(` - ${team.name} (${team.id})`);
|
|
103
|
+
}
|
|
104
|
+
process.exit(EXIT_CODES.ERROR);
|
|
105
|
+
}
|
|
106
|
+
// Check if already active
|
|
107
|
+
if (targetTeam.id === session.activeTeamId) {
|
|
108
|
+
output.info(`Already using team: ${targetTeam.name}`);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
// Switch team
|
|
112
|
+
const success = setActiveTeam(targetTeam.id);
|
|
113
|
+
if (success) {
|
|
114
|
+
output.info(`Switched to team: ${targetTeam.name}`);
|
|
115
|
+
output.info(`\nAll cloud commands will now use this team context.`);
|
|
116
|
+
// Warn about env var override
|
|
117
|
+
const envTeamId = process.env[TEAM_ID_ENV_VAR];
|
|
118
|
+
if (envTeamId && envTeamId !== targetTeam.id) {
|
|
119
|
+
output.warn(`\nNote: ${TEAM_ID_ENV_VAR} is set and will override this selection.`);
|
|
120
|
+
output.warn(`Unset it with: unset ${TEAM_ID_ENV_VAR}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
output.error('Failed to switch team. Please try logging in again.');
|
|
125
|
+
process.exit(EXIT_CODES.ERROR);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
// Subcommand: current
|
|
129
|
+
teamsCommand
|
|
130
|
+
.command('current')
|
|
131
|
+
.description('Show the current active team')
|
|
132
|
+
.option('--json', 'Output as JSON')
|
|
133
|
+
.action(async (options) => {
|
|
134
|
+
const session = getStoredSession();
|
|
135
|
+
if (!session) {
|
|
136
|
+
output.error('Not logged in.');
|
|
137
|
+
process.exit(EXIT_CODES.ERROR);
|
|
138
|
+
}
|
|
139
|
+
const effectiveTeamId = getTeamId();
|
|
140
|
+
const envTeamId = process.env[TEAM_ID_ENV_VAR];
|
|
141
|
+
const teams = getSessionTeams();
|
|
142
|
+
const activeTeam = teams.find(t => t.id === effectiveTeamId);
|
|
143
|
+
if (options.json) {
|
|
144
|
+
output.info(JSON.stringify({
|
|
145
|
+
team: activeTeam || null,
|
|
146
|
+
source: envTeamId ? 'environment' : 'session',
|
|
147
|
+
envVar: envTeamId || null,
|
|
148
|
+
}, null, 2));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (!activeTeam) {
|
|
152
|
+
output.warn('No active team.');
|
|
153
|
+
if (teams.length > 0) {
|
|
154
|
+
output.info('Run `bellwether teams switch` to select a team.');
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
output.info('Try logging out and back in: `bellwether login --logout && bellwether login`');
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
output.info(`Current team: ${activeTeam.name}`);
|
|
162
|
+
output.info(` ID: ${activeTeam.id}`);
|
|
163
|
+
output.info(` Role: ${activeTeam.role}`);
|
|
164
|
+
output.info(` Plan: ${activeTeam.plan}`);
|
|
165
|
+
if (envTeamId) {
|
|
166
|
+
output.info(`\nSource: ${TEAM_ID_ENV_VAR} environment variable`);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=teams.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test command - the simplified, config-driven MCP server testing command.
|
|
3
|
+
*
|
|
4
|
+
* All settings are read from bellwether.yaml (created by `bellwether init`).
|
|
5
|
+
* The only optional argument is the server command, which can also be in config.
|
|
6
|
+
*/
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
export declare const testCommand: Command;
|
|
9
|
+
//# sourceMappingURL=test.d.ts.map
|