@canonical/pragma-cli 0.18.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/README.md +377 -0
- package/package.json +78 -0
- package/src/bin.test.ts +52 -0
- package/src/bin.ts +19 -0
- package/src/compile-validation.runner.ts +137 -0
- package/src/compile-validation.ts +192 -0
- package/src/completions/computeSocketPath.test.ts +26 -0
- package/src/completions/computeSocketPath.ts +16 -0
- package/src/completions/constants.ts +18 -0
- package/src/completions/handleQuery.test.ts +93 -0
- package/src/completions/handleQuery.ts +30 -0
- package/src/completions/index.ts +14 -0
- package/src/completions/queryCompletions.test.ts +100 -0
- package/src/completions/queryCompletions.ts +61 -0
- package/src/completions/querySocket.test.ts +70 -0
- package/src/completions/querySocket.ts +44 -0
- package/src/completions/startCompletionsServer.test.ts +74 -0
- package/src/completions/startCompletionsServer.ts +75 -0
- package/src/completions/startCompletionsServer.unit.test.ts +131 -0
- package/src/completions/waitForSocket.test.ts +27 -0
- package/src/completions/waitForSocket.ts +27 -0
- package/src/config/configExists.ts +14 -0
- package/src/config/index.ts +6 -0
- package/src/config/readConfig.test.ts +152 -0
- package/src/config/readConfig.ts +64 -0
- package/src/config/resolveConfigPath.test.ts +20 -0
- package/src/config/resolveConfigPath.ts +11 -0
- package/src/config/types.ts +26 -0
- package/src/config/writeConfig.ts +49 -0
- package/src/constants.ts +78 -0
- package/src/domains/block/blockConfig.ts +53 -0
- package/src/domains/block/commands/index.ts +4 -0
- package/src/domains/block/commands/list.test.ts +111 -0
- package/src/domains/block/commands/list.ts +69 -0
- package/src/domains/block/commands/lookup.test.ts +187 -0
- package/src/domains/block/commands/lookup.ts +199 -0
- package/src/domains/block/formatters/index.ts +4 -0
- package/src/domains/block/formatters/list.test.ts +107 -0
- package/src/domains/block/formatters/list.ts +64 -0
- package/src/domains/block/formatters/lookup.test.ts +317 -0
- package/src/domains/block/formatters/lookup.ts +354 -0
- package/src/domains/block/formatters/types.ts +16 -0
- package/src/domains/block/helpers/index.ts +4 -0
- package/src/domains/block/helpers/resolveAspects.test.ts +64 -0
- package/src/domains/block/helpers/resolveAspects.ts +35 -0
- package/src/domains/block/index.ts +25 -0
- package/src/domains/block/mcp/index.ts +2 -0
- package/src/domains/block/mcp/specs.ts +199 -0
- package/src/domains/block/operations/index.ts +4 -0
- package/src/domains/block/operations/list.test.ts +80 -0
- package/src/domains/block/operations/list.ts +72 -0
- package/src/domains/block/operations/lookup.test.ts +108 -0
- package/src/domains/block/operations/lookup.ts +359 -0
- package/src/domains/block/orchestration/blockEmptyError.ts +19 -0
- package/src/domains/block/orchestration/buildBlockFilters.ts +12 -0
- package/src/domains/block/orchestration/enrichBlocks.ts +37 -0
- package/src/domains/block/orchestration/index.ts +5 -0
- package/src/domains/block/orchestration/resolveBlockList.ts +39 -0
- package/src/domains/block/orchestration/resolveBlockLookup.ts +21 -0
- package/src/domains/block/types.ts +30 -0
- package/src/domains/config/commands/channel.test.ts +101 -0
- package/src/domains/config/commands/channel.ts +80 -0
- package/src/domains/config/commands/index.ts +4 -0
- package/src/domains/config/commands/show.test.ts +61 -0
- package/src/domains/config/commands/show.ts +51 -0
- package/src/domains/config/commands/tier.test.ts +84 -0
- package/src/domains/config/commands/tier.ts +78 -0
- package/src/domains/config/formatters/channel.test.ts +56 -0
- package/src/domains/config/formatters/channel.ts +34 -0
- package/src/domains/config/formatters/index.ts +4 -0
- package/src/domains/config/formatters/show.test.ts +126 -0
- package/src/domains/config/formatters/show.ts +66 -0
- package/src/domains/config/formatters/tier.test.ts +70 -0
- package/src/domains/config/formatters/tier.ts +40 -0
- package/src/domains/config/index.ts +23 -0
- package/src/domains/config/mcp/index.ts +2 -0
- package/src/domains/config/mcp/specs.ts +108 -0
- package/src/domains/config/operations/index.ts +5 -0
- package/src/domains/config/operations/show.test.ts +60 -0
- package/src/domains/config/operations/show.ts +42 -0
- package/src/domains/config/operations/types.ts +13 -0
- package/src/domains/config/operations/validateChannel.test.ts +36 -0
- package/src/domains/config/operations/validateChannel.ts +24 -0
- package/src/domains/config/operations/validateTier.test.ts +56 -0
- package/src/domains/config/operations/validateTier.ts +35 -0
- package/src/domains/create/commands/component.test.ts +166 -0
- package/src/domains/create/commands/component.ts +129 -0
- package/src/domains/create/commands/index.ts +3 -0
- package/src/domains/create/commands/package.test.ts +35 -0
- package/src/domains/create/commands/package.ts +21 -0
- package/src/domains/create/index.ts +15 -0
- package/src/domains/create/mcp/index.ts +2 -0
- package/src/domains/create/mcp/specs.ts +174 -0
- package/src/domains/doctor/commands/doctor.test.ts +75 -0
- package/src/domains/doctor/commands/doctor.ts +43 -0
- package/src/domains/doctor/commands/index.ts +2 -0
- package/src/domains/doctor/formatters/doctor.test.ts +117 -0
- package/src/domains/doctor/formatters/doctor.ts +84 -0
- package/src/domains/doctor/formatters/index.ts +2 -0
- package/src/domains/doctor/index.ts +9 -0
- package/src/domains/doctor/mcp/index.ts +2 -0
- package/src/domains/doctor/mcp/specs.ts +88 -0
- package/src/domains/doctor/operations/checks/checkConfigFile.ts +28 -0
- package/src/domains/doctor/operations/checks/checkKeStore.ts +38 -0
- package/src/domains/doctor/operations/checks/checkMcpConfigured.ts +65 -0
- package/src/domains/doctor/operations/checks/checkNodeVersion.ts +25 -0
- package/src/domains/doctor/operations/checks/checkPragmaVersion.ts +20 -0
- package/src/domains/doctor/operations/checks/checkShellCompletions.ts +42 -0
- package/src/domains/doctor/operations/checks/checkSkillsSymlinked.ts +64 -0
- package/src/domains/doctor/operations/checks/index.ts +8 -0
- package/src/domains/doctor/operations/checks.test.ts +151 -0
- package/src/domains/doctor/operations/index.ts +3 -0
- package/src/domains/doctor/operations/runChecks.test.ts +89 -0
- package/src/domains/doctor/operations/runChecks.ts +38 -0
- package/src/domains/doctor/operations/types.ts +20 -0
- package/src/domains/graph/commands/index.ts +4 -0
- package/src/domains/graph/commands/inspect.test.ts +94 -0
- package/src/domains/graph/commands/inspect.ts +63 -0
- package/src/domains/graph/commands/query.test.ts +92 -0
- package/src/domains/graph/commands/query.ts +60 -0
- package/src/domains/graph/formatters/index.ts +4 -0
- package/src/domains/graph/formatters/inspect.ts +45 -0
- package/src/domains/graph/formatters/query.ts +37 -0
- package/src/domains/graph/helpers/index.ts +3 -0
- package/src/domains/graph/helpers/resolveUri.ts +70 -0
- package/src/domains/graph/index.ts +22 -0
- package/src/domains/graph/mcp/index.ts +2 -0
- package/src/domains/graph/mcp/specs.ts +82 -0
- package/src/domains/graph/operations/executeQuery.test.ts +68 -0
- package/src/domains/graph/operations/executeQuery.ts +32 -0
- package/src/domains/graph/operations/index.ts +4 -0
- package/src/domains/graph/operations/inspectUri.test.ts +101 -0
- package/src/domains/graph/operations/inspectUri.ts +61 -0
- package/src/domains/info/commands/index.ts +4 -0
- package/src/domains/info/commands/info.test.ts +88 -0
- package/src/domains/info/commands/info.ts +47 -0
- package/src/domains/info/commands/upgrade.test.ts +183 -0
- package/src/domains/info/commands/upgrade.ts +150 -0
- package/src/domains/info/constants.test.ts +22 -0
- package/src/domains/info/constants.ts +15 -0
- package/src/domains/info/formatters/index.ts +8 -0
- package/src/domains/info/formatters/info.test.ts +173 -0
- package/src/domains/info/formatters/info.ts +116 -0
- package/src/domains/info/formatters/upgrade.test.ts +133 -0
- package/src/domains/info/formatters/upgrade.ts +68 -0
- package/src/domains/info/index.ts +7 -0
- package/src/domains/info/operations/checkRegistryVersion.test.ts +124 -0
- package/src/domains/info/operations/checkRegistryVersion.ts +45 -0
- package/src/domains/info/operations/collectInfo.test.ts +111 -0
- package/src/domains/info/operations/collectInfo.ts +68 -0
- package/src/domains/info/operations/collectStoreSummary.test.ts +61 -0
- package/src/domains/info/operations/collectStoreSummary.ts +42 -0
- package/src/domains/info/operations/index.ts +5 -0
- package/src/domains/info/types.test-d.ts +35 -0
- package/src/domains/info/types.ts +46 -0
- package/src/domains/llm/commands/index.ts +3 -0
- package/src/domains/llm/commands/llm.ts +37 -0
- package/src/domains/llm/data/commandReference.ts +25 -0
- package/src/domains/llm/data/decisionTrees.ts +46 -0
- package/src/domains/llm/data/index.ts +4 -0
- package/src/domains/llm/formatters/index.ts +3 -0
- package/src/domains/llm/formatters/orientation.ts +53 -0
- package/src/domains/llm/index.ts +8 -0
- package/src/domains/llm/llmCommand.test.ts +93 -0
- package/src/domains/llm/mcp/index.ts +2 -0
- package/src/domains/llm/mcp/specs.ts +87 -0
- package/src/domains/llm/operations/collectContext.ts +47 -0
- package/src/domains/llm/operations/index.ts +3 -0
- package/src/domains/llm/types.ts +32 -0
- package/src/domains/modifier/commands/index.ts +4 -0
- package/src/domains/modifier/commands/list.test.ts +57 -0
- package/src/domains/modifier/commands/list.ts +33 -0
- package/src/domains/modifier/commands/lookup.test.ts +91 -0
- package/src/domains/modifier/commands/lookup.ts +105 -0
- package/src/domains/modifier/formatters/index.ts +4 -0
- package/src/domains/modifier/formatters/list.test.ts +38 -0
- package/src/domains/modifier/formatters/list.ts +35 -0
- package/src/domains/modifier/formatters/lookup.test.ts +33 -0
- package/src/domains/modifier/formatters/lookup.ts +38 -0
- package/src/domains/modifier/index.ts +22 -0
- package/src/domains/modifier/mcp/index.ts +2 -0
- package/src/domains/modifier/mcp/specs.ts +97 -0
- package/src/domains/modifier/operations/index.ts +4 -0
- package/src/domains/modifier/operations/list.test.ts +39 -0
- package/src/domains/modifier/operations/list.ts +41 -0
- package/src/domains/modifier/operations/lookup.test.ts +37 -0
- package/src/domains/modifier/operations/lookup.ts +57 -0
- package/src/domains/modifier/orchestration/index.ts +3 -0
- package/src/domains/modifier/orchestration/modifierEmptyError.ts +10 -0
- package/src/domains/modifier/orchestration/resolveModifierList.ts +16 -0
- package/src/domains/modifier/orchestration/resolveModifierLookup.ts +20 -0
- package/src/domains/modifier/types.ts +5 -0
- package/src/domains/ontology/commands/index.ts +4 -0
- package/src/domains/ontology/commands/list.test.ts +82 -0
- package/src/domains/ontology/commands/list.ts +46 -0
- package/src/domains/ontology/commands/show.test.ts +103 -0
- package/src/domains/ontology/commands/show.ts +66 -0
- package/src/domains/ontology/formatters/index.ts +4 -0
- package/src/domains/ontology/formatters/list.ts +37 -0
- package/src/domains/ontology/formatters/show.ts +74 -0
- package/src/domains/ontology/helpers/findNamespace.ts +23 -0
- package/src/domains/ontology/helpers/index.ts +7 -0
- package/src/domains/ontology/helpers/queryClasses.ts +50 -0
- package/src/domains/ontology/helpers/queryProperties.ts +57 -0
- package/src/domains/ontology/helpers/resolvePrefix.ts +45 -0
- package/src/domains/ontology/index.ts +26 -0
- package/src/domains/ontology/mcp/index.ts +2 -0
- package/src/domains/ontology/mcp/specs.ts +93 -0
- package/src/domains/ontology/operations/index.ts +5 -0
- package/src/domains/ontology/operations/listOntologies.test.ts +45 -0
- package/src/domains/ontology/operations/listOntologies.ts +101 -0
- package/src/domains/ontology/operations/showOntology.test.ts +65 -0
- package/src/domains/ontology/operations/showOntology.ts +41 -0
- package/src/domains/ontology/operations/showOntologyRaw.test.ts +39 -0
- package/src/domains/ontology/operations/showOntologyRaw.ts +50 -0
- package/src/domains/setup/commands/all.ts +58 -0
- package/src/domains/setup/commands/completions.ts +85 -0
- package/src/domains/setup/commands/entrypoints.test.ts +170 -0
- package/src/domains/setup/commands/index.ts +6 -0
- package/src/domains/setup/commands/lsp.ts +49 -0
- package/src/domains/setup/commands/mcp.ts +119 -0
- package/src/domains/setup/commands/skills.test.ts +64 -0
- package/src/domains/setup/commands/skills.ts +106 -0
- package/src/domains/setup/formatters/index.ts +2 -0
- package/src/domains/setup/formatters/skills.test.ts +103 -0
- package/src/domains/setup/formatters/skills.ts +112 -0
- package/src/domains/setup/formatters/types.ts +7 -0
- package/src/domains/setup/helpers/completionScripts.test.ts +58 -0
- package/src/domains/setup/helpers/completionScripts.ts +92 -0
- package/src/domains/setup/helpers/constants.ts +2 -0
- package/src/domains/setup/helpers/detectShell.test.ts +48 -0
- package/src/domains/setup/helpers/detectShell.ts +20 -0
- package/src/domains/setup/helpers/index.ts +12 -0
- package/src/domains/setup/helpers/runSetupTask.test.ts +279 -0
- package/src/domains/setup/helpers/runSetupTask.ts +229 -0
- package/src/domains/setup/index.ts +33 -0
- package/src/domains/setup/operations/index.ts +6 -0
- package/src/domains/setup/operations/setupAll.test.ts +48 -0
- package/src/domains/setup/operations/setupAll.ts +41 -0
- package/src/domains/setup/operations/setupCompletions.test.ts +94 -0
- package/src/domains/setup/operations/setupCompletions.ts +54 -0
- package/src/domains/setup/operations/setupLsp.test.ts +29 -0
- package/src/domains/setup/operations/setupLsp.ts +17 -0
- package/src/domains/setup/operations/setupMcp.test.ts +115 -0
- package/src/domains/setup/operations/setupMcp.ts +108 -0
- package/src/domains/setup/operations/setupSkills.test.ts +191 -0
- package/src/domains/setup/operations/setupSkills.ts +160 -0
- package/src/domains/setup/types.ts +18 -0
- package/src/domains/shared/ToolSpec.ts +49 -0
- package/src/domains/shared/bootStore.ts +77 -0
- package/src/domains/shared/buildQuery.ts +18 -0
- package/src/domains/shared/compactUri.test.ts +21 -0
- package/src/domains/shared/compactUri.ts +16 -0
- package/src/domains/shared/context.ts +15 -0
- package/src/domains/shared/contracts.ts +113 -0
- package/src/domains/shared/extractLocalName.test.ts +21 -0
- package/src/domains/shared/extractLocalName.ts +14 -0
- package/src/domains/shared/filters/buildChannelFilter.test.ts +52 -0
- package/src/domains/shared/filters/buildChannelFilter.ts +41 -0
- package/src/domains/shared/filters/buildFilterConfig.ts +16 -0
- package/src/domains/shared/filters/buildFilters.test.ts +33 -0
- package/src/domains/shared/filters/buildFilters.ts +30 -0
- package/src/domains/shared/filters/buildTierFilter.test.ts +78 -0
- package/src/domains/shared/filters/buildTierFilter.ts +69 -0
- package/src/domains/shared/filters/describeFilters.ts +14 -0
- package/src/domains/shared/filters/index.ts +10 -0
- package/src/domains/shared/formatters.ts +35 -0
- package/src/domains/shared/lookupMany.ts +45 -0
- package/src/domains/shared/namespaces.ts +18 -0
- package/src/domains/shared/packages.ts +76 -0
- package/src/domains/shared/prefixes.ts +37 -0
- package/src/domains/shared/runtime.ts +62 -0
- package/src/domains/shared/types.test-d.ts +127 -0
- package/src/domains/shared/types.ts +348 -0
- package/src/domains/skill/commands/index.ts +2 -0
- package/src/domains/skill/commands/list.test.ts +111 -0
- package/src/domains/skill/commands/list.ts +69 -0
- package/src/domains/skill/formatters/index.ts +2 -0
- package/src/domains/skill/formatters/list.test.ts +140 -0
- package/src/domains/skill/formatters/list.ts +119 -0
- package/src/domains/skill/formatters/types.ts +8 -0
- package/src/domains/skill/helpers/index.ts +6 -0
- package/src/domains/skill/helpers/parseFrontmatter.test.ts +122 -0
- package/src/domains/skill/helpers/parseFrontmatter.ts +112 -0
- package/src/domains/skill/helpers/resolveSkillSources.ts +34 -0
- package/src/domains/skill/index.ts +19 -0
- package/src/domains/skill/mcp/index.ts +2 -0
- package/src/domains/skill/mcp/specs.ts +38 -0
- package/src/domains/skill/operations/discover.test.ts +145 -0
- package/src/domains/skill/operations/discover.ts +68 -0
- package/src/domains/skill/operations/index.ts +4 -0
- package/src/domains/skill/operations/list.test.ts +68 -0
- package/src/domains/skill/operations/list.ts +47 -0
- package/src/domains/skill/types.ts +25 -0
- package/src/domains/standard/commands/categories.test.ts +70 -0
- package/src/domains/standard/commands/categories.ts +48 -0
- package/src/domains/standard/commands/index.ts +5 -0
- package/src/domains/standard/commands/list.test.ts +105 -0
- package/src/domains/standard/commands/list.ts +81 -0
- package/src/domains/standard/commands/lookup.test.ts +135 -0
- package/src/domains/standard/commands/lookup.ts +127 -0
- package/src/domains/standard/formatters/categories.test.ts +44 -0
- package/src/domains/standard/formatters/categories.ts +38 -0
- package/src/domains/standard/formatters/index.ts +6 -0
- package/src/domains/standard/formatters/list.test.ts +166 -0
- package/src/domains/standard/formatters/list.ts +156 -0
- package/src/domains/standard/formatters/lookup.test.ts +95 -0
- package/src/domains/standard/formatters/lookup.ts +86 -0
- package/src/domains/standard/formatters/types.ts +31 -0
- package/src/domains/standard/index.ts +32 -0
- package/src/domains/standard/mcp/index.ts +2 -0
- package/src/domains/standard/mcp/specs.ts +197 -0
- package/src/domains/standard/operations/categories.test.ts +61 -0
- package/src/domains/standard/operations/categories.ts +38 -0
- package/src/domains/standard/operations/index.ts +5 -0
- package/src/domains/standard/operations/list.test.ts +75 -0
- package/src/domains/standard/operations/list.ts +64 -0
- package/src/domains/standard/operations/lookup.test.ts +58 -0
- package/src/domains/standard/operations/lookup.ts +142 -0
- package/src/domains/standard/orchestration/buildStandardFilters.ts +11 -0
- package/src/domains/standard/orchestration/index.ts +4 -0
- package/src/domains/standard/orchestration/resolveStandardList.ts +42 -0
- package/src/domains/standard/orchestration/resolveStandardLookup.ts +20 -0
- package/src/domains/standard/orchestration/standardEmptyError.ts +19 -0
- package/src/domains/standard/types.ts +15 -0
- package/src/domains/tier/commands/index.ts +3 -0
- package/src/domains/tier/commands/list.test.ts +67 -0
- package/src/domains/tier/commands/list.ts +43 -0
- package/src/domains/tier/formatters/index.ts +3 -0
- package/src/domains/tier/formatters/list.test.ts +33 -0
- package/src/domains/tier/formatters/list.ts +40 -0
- package/src/domains/tier/index.ts +17 -0
- package/src/domains/tier/mcp/index.ts +2 -0
- package/src/domains/tier/mcp/specs.ts +38 -0
- package/src/domains/tier/operations/index.ts +3 -0
- package/src/domains/tier/operations/list.test.ts +32 -0
- package/src/domains/tier/operations/list.ts +33 -0
- package/src/domains/token/commands/add-config.test.ts +68 -0
- package/src/domains/token/commands/add-config.ts +62 -0
- package/src/domains/token/commands/index.ts +5 -0
- package/src/domains/token/commands/list.test.ts +82 -0
- package/src/domains/token/commands/list.ts +45 -0
- package/src/domains/token/commands/lookup.test.ts +125 -0
- package/src/domains/token/commands/lookup.ts +121 -0
- package/src/domains/token/formatters/index.ts +4 -0
- package/src/domains/token/formatters/list.test.ts +37 -0
- package/src/domains/token/formatters/list.ts +37 -0
- package/src/domains/token/formatters/lookup.test.ts +61 -0
- package/src/domains/token/formatters/lookup.ts +72 -0
- package/src/domains/token/index.ts +32 -0
- package/src/domains/token/mcp/index.ts +2 -0
- package/src/domains/token/mcp/specs.ts +145 -0
- package/src/domains/token/operations/add-config.test.ts +68 -0
- package/src/domains/token/operations/add-config.ts +61 -0
- package/src/domains/token/operations/index.ts +7 -0
- package/src/domains/token/operations/list.test.ts +50 -0
- package/src/domains/token/operations/list.ts +52 -0
- package/src/domains/token/operations/lookup.test.ts +42 -0
- package/src/domains/token/operations/lookup.ts +66 -0
- package/src/domains/token/orchestration/index.ts +3 -0
- package/src/domains/token/orchestration/resolveTokenList.ts +17 -0
- package/src/domains/token/orchestration/resolveTokenLookup.ts +20 -0
- package/src/domains/token/orchestration/tokenEmptyError.ts +17 -0
- package/src/domains/token/types.ts +6 -0
- package/src/error/PragmaError.test.ts +121 -0
- package/src/error/PragmaError.ts +164 -0
- package/src/error/constants.ts +12 -0
- package/src/error/index.ts +4 -0
- package/src/error/types.ts +41 -0
- package/src/index.ts +141 -0
- package/src/mcp/createMcpServer.test.ts +41 -0
- package/src/mcp/createMcpServer.ts +53 -0
- package/src/mcp/error/buildRecovery.test.ts +37 -0
- package/src/mcp/error/buildRecovery.ts +17 -0
- package/src/mcp/error/index.ts +12 -0
- package/src/mcp/error/serializeError.test.ts +121 -0
- package/src/mcp/error/serializeError.ts +31 -0
- package/src/mcp/error/serializeErrorPayload.test.ts +38 -0
- package/src/mcp/error/serializeErrorPayload.ts +27 -0
- package/src/mcp/error/types.ts +51 -0
- package/src/mcp/index.ts +15 -0
- package/src/mcp/registerResources.test.ts +236 -0
- package/src/mcp/registerResources.ts +303 -0
- package/src/mcp/runMcpServer.test.ts +66 -0
- package/src/mcp/runMcpServer.ts +24 -0
- package/src/mcp/tools/index.ts +55 -0
- package/src/mcp/tools/registerFromSpec.ts +97 -0
- package/src/mcp/tools/registerTools.test.ts +1124 -0
- package/src/mcp/types.ts +62 -0
- package/src/mcp/utils/estimateTokens.test.ts +14 -0
- package/src/mcp/utils/estimateTokens.ts +9 -0
- package/src/mcp/utils/index.ts +11 -0
- package/src/mcp/utils/wrapTool.test.ts +108 -0
- package/src/mcp/utils/wrapTool.ts +81 -0
- package/src/package-manager/constants.ts +29 -0
- package/src/package-manager/detectInstallSource.test.ts +23 -0
- package/src/package-manager/detectInstallSource.ts +111 -0
- package/src/package-manager/detectLocalInstall.test.ts +16 -0
- package/src/package-manager/detectLocalInstall.ts +43 -0
- package/src/package-manager/detectPackageManager.test.ts +81 -0
- package/src/package-manager/detectPackageManager.ts +30 -0
- package/src/package-manager/index.ts +6 -0
- package/src/package-manager/types.ts +12 -0
- package/src/pipeline/collectCommands.test.ts +37 -0
- package/src/pipeline/collectCommands.ts +47 -0
- package/src/pipeline/constants.ts +14 -0
- package/src/pipeline/createProgram.test.ts +112 -0
- package/src/pipeline/createProgram.ts +70 -0
- package/src/pipeline/formatTerminal.test.ts +43 -0
- package/src/pipeline/formatTerminal.ts +53 -0
- package/src/pipeline/index.ts +19 -0
- package/src/pipeline/mapExitCode.test.ts +41 -0
- package/src/pipeline/mapExitCode.ts +12 -0
- package/src/pipeline/parseGlobalFlags.ts +21 -0
- package/src/pipeline/renderError.test.ts +151 -0
- package/src/pipeline/renderError.ts +114 -0
- package/src/pipeline/resolveCommandKind.test.ts +68 -0
- package/src/pipeline/resolveCommandKind.ts +71 -0
- package/src/pipeline/runCli.orchestration.test.ts +418 -0
- package/src/pipeline/runCli.test.ts +70 -0
- package/src/pipeline/runCli.ts +215 -0
- package/src/pipeline/types.ts +17 -0
- package/src/testing/cli.ts +43 -0
- package/src/testing/createTestMcpClient.ts +64 -0
- package/src/testing/dsFixtures.ts +506 -0
- package/src/testing/fixtures/canonical-config.json +4 -0
- package/src/testing/fixtures/canonical.ttl +437 -0
- package/src/testing/fixtures/filtered-config.json +4 -0
- package/src/testing/fixtures.ts +34 -0
- package/src/testing/helpers/assertParity.ts +28 -0
- package/src/testing/helpers/createTestMcpClient.ts +40 -0
- package/src/testing/helpers/createTestRuntime.ts +67 -0
- package/src/testing/index.ts +8 -0
- package/src/testing/integration/agent-session.test.ts +148 -0
- package/src/testing/integration/boot.test.ts +67 -0
- package/src/testing/integration/mcp-surface.test.ts +574 -0
- package/src/testing/integration/parity.test.ts +192 -0
- package/src/testing/store.ts +39 -0
- package/src/testing/types.ts +20 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Three-mode formatter for `pragma block lookup` output.
|
|
3
|
+
*
|
|
4
|
+
* - **plain** — styled terminal output with chalk; shows summary or
|
|
5
|
+
* detailed view depending on the `detailed` / aspect flags.
|
|
6
|
+
* - **llm** — condensed Markdown consumed by LLM agents and reused
|
|
7
|
+
* by the MCP adapter when `condensed: true`.
|
|
8
|
+
* - **json** — structured JSON for programmatic consumption.
|
|
9
|
+
*
|
|
10
|
+
* Supports aspect filtering (anatomy, modifiers, tokens, implementations)
|
|
11
|
+
* via the `aspects` field on {@link BlockLookupInput}.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import chalk from "chalk";
|
|
15
|
+
import {
|
|
16
|
+
formatField,
|
|
17
|
+
formatHeading,
|
|
18
|
+
formatList,
|
|
19
|
+
formatSection,
|
|
20
|
+
} from "#pipeline";
|
|
21
|
+
import type { Formatters } from "../../shared/formatters.js";
|
|
22
|
+
import type { AnatomyNode, BlockDetailed } from "../../shared/types.js";
|
|
23
|
+
import type { AspectFlags } from "../types.js";
|
|
24
|
+
import type { BlockLookupInput } from "./types.js";
|
|
25
|
+
|
|
26
|
+
const formatters: Formatters<BlockLookupInput> = {
|
|
27
|
+
plain({ block: component, detailed, aspects }) {
|
|
28
|
+
if (!detailed) return formatSummary(component);
|
|
29
|
+
return formatDetailed(component, aspects);
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
llm({ block: component, detailed, aspects }) {
|
|
33
|
+
const lines: string[] = [];
|
|
34
|
+
|
|
35
|
+
lines.push(`## ${component.name}`);
|
|
36
|
+
lines.push("");
|
|
37
|
+
lines.push(`- URI: ${component.uri}`);
|
|
38
|
+
lines.push(`- Tier: ${component.tier}`);
|
|
39
|
+
|
|
40
|
+
if (component.summary) {
|
|
41
|
+
lines.push(`- Summary: ${component.summary}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (component.modifiers.length > 0) {
|
|
45
|
+
lines.push(`- Modifiers: ${component.modifiers.join(", ")}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const impl = component.implementations
|
|
49
|
+
.filter((i) => i.available)
|
|
50
|
+
.map((i) => i.framework);
|
|
51
|
+
if (impl.length > 0) {
|
|
52
|
+
lines.push(`- Implementations: ${impl.join(", ")}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
lines.push(`- Anatomy nodes: ${component.nodeCount}`);
|
|
56
|
+
lines.push(`- Tokens: ${component.tokenCount}`);
|
|
57
|
+
|
|
58
|
+
if (!detailed) return lines.join("\n");
|
|
59
|
+
|
|
60
|
+
if (component.whenToUse) {
|
|
61
|
+
lines.push("");
|
|
62
|
+
lines.push("### When to use");
|
|
63
|
+
lines.push(component.whenToUse);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (component.whenNotToUse) {
|
|
67
|
+
lines.push("");
|
|
68
|
+
lines.push("### When not to use");
|
|
69
|
+
lines.push(component.whenNotToUse);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (component.guidelines) {
|
|
73
|
+
lines.push("");
|
|
74
|
+
lines.push("### Guidelines");
|
|
75
|
+
lines.push(component.guidelines);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (aspects.modifiers && component.modifierValues.length > 0) {
|
|
79
|
+
lines.push("");
|
|
80
|
+
lines.push("### Modifiers");
|
|
81
|
+
for (const m of component.modifierValues) {
|
|
82
|
+
lines.push(`- **${m.family}**: ${m.values.join(", ")}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (component.properties.length > 0) {
|
|
87
|
+
lines.push("");
|
|
88
|
+
lines.push("### Properties");
|
|
89
|
+
for (const property of component.properties) {
|
|
90
|
+
const bits = [property.propertyType || "unknown"];
|
|
91
|
+
bits.push(property.optional ? "optional" : "required");
|
|
92
|
+
if (property.defaultValue) {
|
|
93
|
+
bits.push(`default=${property.defaultValue}`);
|
|
94
|
+
}
|
|
95
|
+
if (property.constraints) {
|
|
96
|
+
bits.push(property.constraints);
|
|
97
|
+
}
|
|
98
|
+
lines.push(`- **${property.name}**: ${bits.join("; ")}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (component.subcomponents.length > 0) {
|
|
103
|
+
lines.push("");
|
|
104
|
+
lines.push("### Subcomponents");
|
|
105
|
+
for (const subcomponent of component.subcomponents) {
|
|
106
|
+
lines.push(`- ${subcomponent.name} (${subcomponent.uri})`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (aspects.implementations && component.implementationPaths.length > 0) {
|
|
111
|
+
lines.push("");
|
|
112
|
+
lines.push("### Implementations");
|
|
113
|
+
for (const i of component.implementationPaths) {
|
|
114
|
+
lines.push(`- ${i.framework}: \`${i.path}\``);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (aspects.tokens && component.tokens.length > 0) {
|
|
119
|
+
lines.push("");
|
|
120
|
+
lines.push("### Tokens");
|
|
121
|
+
for (const t of component.tokens) {
|
|
122
|
+
lines.push(`- ${t.name}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (aspects.anatomy && component.anatomy) {
|
|
127
|
+
lines.push("");
|
|
128
|
+
lines.push("### Anatomy");
|
|
129
|
+
lines.push(formatAnatomyTreeLlm(component.anatomy.root, 0));
|
|
130
|
+
} else if (aspects.anatomy && component.anatomyDsl) {
|
|
131
|
+
lines.push("");
|
|
132
|
+
lines.push("### Anatomy DSL");
|
|
133
|
+
lines.push(component.anatomyDsl);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return lines.join("\n");
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
json({ block: component, detailed, aspects }) {
|
|
140
|
+
if (!detailed) {
|
|
141
|
+
return JSON.stringify(
|
|
142
|
+
{
|
|
143
|
+
uri: component.uri,
|
|
144
|
+
name: component.name,
|
|
145
|
+
summary: component.summary,
|
|
146
|
+
tier: component.tier,
|
|
147
|
+
modifiers: component.modifiers,
|
|
148
|
+
implementations: component.implementations,
|
|
149
|
+
nodeCount: component.nodeCount,
|
|
150
|
+
tokenCount: component.tokenCount,
|
|
151
|
+
},
|
|
152
|
+
null,
|
|
153
|
+
2,
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const result: Record<string, unknown> = { ...component };
|
|
158
|
+
|
|
159
|
+
if (!aspects.modifiers) {
|
|
160
|
+
delete result.modifierValues;
|
|
161
|
+
delete result.modifierFamilies;
|
|
162
|
+
}
|
|
163
|
+
if (!aspects.implementations) {
|
|
164
|
+
delete result.implementationPaths;
|
|
165
|
+
}
|
|
166
|
+
if (!aspects.tokens) {
|
|
167
|
+
delete result.tokens;
|
|
168
|
+
}
|
|
169
|
+
if (!aspects.anatomy) {
|
|
170
|
+
delete result.anatomy;
|
|
171
|
+
delete result.anatomyDsl;
|
|
172
|
+
delete result.anatomyClassic;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return JSON.stringify(result, null, 2);
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export default formatters;
|
|
180
|
+
|
|
181
|
+
// =============================================================================
|
|
182
|
+
// Helpers
|
|
183
|
+
// =============================================================================
|
|
184
|
+
|
|
185
|
+
function formatSummary(component: BlockDetailed): string {
|
|
186
|
+
const lines: string[] = [];
|
|
187
|
+
|
|
188
|
+
lines.push(formatHeading(component.name));
|
|
189
|
+
lines.push("");
|
|
190
|
+
lines.push(formatField("URI:", component.uri));
|
|
191
|
+
lines.push(formatField("Tier:", component.tier));
|
|
192
|
+
|
|
193
|
+
if (component.summary) {
|
|
194
|
+
lines.push(formatField("Summary:", component.summary));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (component.modifiers.length > 0) {
|
|
198
|
+
lines.push(formatField("Modifiers:", component.modifiers.join(", ")));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const impl = component.implementations
|
|
202
|
+
.filter((i) => i.available)
|
|
203
|
+
.map((i) => i.framework);
|
|
204
|
+
if (impl.length > 0) {
|
|
205
|
+
lines.push(formatField("Implementations:", impl.join(", ")));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
lines.push(formatField("Anatomy nodes:", String(component.nodeCount)));
|
|
209
|
+
lines.push(formatField("Tokens:", String(component.tokenCount)));
|
|
210
|
+
|
|
211
|
+
return lines.join("\n");
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function formatDetailed(
|
|
215
|
+
component: BlockDetailed,
|
|
216
|
+
aspects: AspectFlags,
|
|
217
|
+
): string {
|
|
218
|
+
const lines: string[] = [];
|
|
219
|
+
|
|
220
|
+
lines.push(formatHeading(component.name));
|
|
221
|
+
lines.push("");
|
|
222
|
+
lines.push(formatField("URI:", component.uri));
|
|
223
|
+
lines.push(formatField("Tier:", component.tier));
|
|
224
|
+
if (component.summary) {
|
|
225
|
+
lines.push(formatField("Summary:", component.summary));
|
|
226
|
+
}
|
|
227
|
+
lines.push(formatField("Anatomy nodes:", String(component.nodeCount)));
|
|
228
|
+
lines.push(formatField("Tokens:", String(component.tokenCount)));
|
|
229
|
+
|
|
230
|
+
if (component.whenToUse) {
|
|
231
|
+
lines.push("");
|
|
232
|
+
lines.push(formatSection("When to use", component.whenToUse));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (component.whenNotToUse) {
|
|
236
|
+
lines.push("");
|
|
237
|
+
lines.push(formatSection("When not to use", component.whenNotToUse));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (component.guidelines) {
|
|
241
|
+
lines.push("");
|
|
242
|
+
lines.push(formatSection("Guidelines", component.guidelines));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (aspects.modifiers && component.modifierValues.length > 0) {
|
|
246
|
+
lines.push("");
|
|
247
|
+
lines.push(
|
|
248
|
+
formatSection(
|
|
249
|
+
"Modifiers",
|
|
250
|
+
component.modifierValues
|
|
251
|
+
.map((m) => ` ${chalk.bold(m.family)}: ${m.values.join(", ")}`)
|
|
252
|
+
.join("\n"),
|
|
253
|
+
),
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (aspects.implementations && component.implementationPaths.length > 0) {
|
|
258
|
+
lines.push("");
|
|
259
|
+
lines.push(
|
|
260
|
+
formatSection(
|
|
261
|
+
"Implementations",
|
|
262
|
+
formatList(
|
|
263
|
+
component.implementationPaths.map(
|
|
264
|
+
(i) => `${chalk.bold(i.framework)}: ${i.path}`,
|
|
265
|
+
),
|
|
266
|
+
),
|
|
267
|
+
),
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (aspects.tokens && component.tokens.length > 0) {
|
|
272
|
+
lines.push("");
|
|
273
|
+
lines.push(
|
|
274
|
+
formatSection("Tokens", formatList(component.tokens.map((t) => t.name))),
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (component.properties.length > 0) {
|
|
279
|
+
lines.push("");
|
|
280
|
+
lines.push(
|
|
281
|
+
formatSection(
|
|
282
|
+
"Properties",
|
|
283
|
+
formatList(
|
|
284
|
+
component.properties.map((property) => {
|
|
285
|
+
const parts = [
|
|
286
|
+
chalk.bold(property.name),
|
|
287
|
+
property.propertyType || "unknown",
|
|
288
|
+
property.optional ? "optional" : "required",
|
|
289
|
+
];
|
|
290
|
+
if (property.defaultValue) {
|
|
291
|
+
parts.push(`default=${property.defaultValue}`);
|
|
292
|
+
}
|
|
293
|
+
if (property.constraints) {
|
|
294
|
+
parts.push(property.constraints);
|
|
295
|
+
}
|
|
296
|
+
return parts.join(" — ");
|
|
297
|
+
}),
|
|
298
|
+
),
|
|
299
|
+
),
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (component.subcomponents.length > 0) {
|
|
304
|
+
lines.push("");
|
|
305
|
+
lines.push(
|
|
306
|
+
formatSection(
|
|
307
|
+
"Subcomponents",
|
|
308
|
+
formatList(
|
|
309
|
+
component.subcomponents.map(
|
|
310
|
+
(subcomponent) => `${subcomponent.name}: ${subcomponent.uri}`,
|
|
311
|
+
),
|
|
312
|
+
),
|
|
313
|
+
),
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (aspects.anatomy && component.anatomy) {
|
|
318
|
+
lines.push("");
|
|
319
|
+
lines.push(
|
|
320
|
+
formatSection("Anatomy", formatAnatomyTree(component.anatomy.root, 0)),
|
|
321
|
+
);
|
|
322
|
+
} else if (aspects.anatomy && component.anatomyDsl) {
|
|
323
|
+
lines.push("");
|
|
324
|
+
lines.push(formatSection("Anatomy (DSL)", component.anatomyDsl));
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return lines.join("\n");
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function formatAnatomyTree(node: AnatomyNode, depth: number): string {
|
|
331
|
+
const indent = " ".repeat(depth);
|
|
332
|
+
const typeTag = node.type === "anonymous" ? chalk.dim(" (anon)") : "";
|
|
333
|
+
const slotTag = node.slot ? chalk.dim(` slot=${node.slot}`) : "";
|
|
334
|
+
let result = `${indent}${node.name}${typeTag}${slotTag}`;
|
|
335
|
+
|
|
336
|
+
for (const child of node.children) {
|
|
337
|
+
result += `\n${formatAnatomyTree(child, depth + 1)}`;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function formatAnatomyTreeLlm(node: AnatomyNode, depth: number): string {
|
|
344
|
+
const indent = " ".repeat(depth);
|
|
345
|
+
const typeTag = node.type === "anonymous" ? " (anonymous)" : "";
|
|
346
|
+
const slotTag = node.slot ? ` [slot: ${node.slot}]` : "";
|
|
347
|
+
let result = `${indent}- ${node.name}${typeTag}${slotTag}`;
|
|
348
|
+
|
|
349
|
+
for (const child of node.children) {
|
|
350
|
+
result += `\n${formatAnatomyTreeLlm(child, depth + 1)}`;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatter input types for block commands.
|
|
3
|
+
*
|
|
4
|
+
* Composite types that bundle the data with display options,
|
|
5
|
+
* so formatters conform to the `Formatters<T>` contract.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { BlockDetailed } from "../../shared/types.js";
|
|
9
|
+
import type { AspectFlags } from "../types.js";
|
|
10
|
+
|
|
11
|
+
/** Input payload for the block-lookup formatter, pairing data with display flags. */
|
|
12
|
+
export interface BlockLookupInput {
|
|
13
|
+
readonly block: BlockDetailed;
|
|
14
|
+
readonly detailed: boolean;
|
|
15
|
+
readonly aspects: AspectFlags;
|
|
16
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import resolveAspects from "./resolveAspects.js";
|
|
3
|
+
|
|
4
|
+
describe("resolveAspects", () => {
|
|
5
|
+
it("returns all aspects when none are set", () => {
|
|
6
|
+
const result = resolveAspects({});
|
|
7
|
+
expect(result).toEqual({
|
|
8
|
+
anatomy: true,
|
|
9
|
+
modifiers: true,
|
|
10
|
+
tokens: true,
|
|
11
|
+
implementations: true,
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("returns all aspects when all are explicitly false", () => {
|
|
16
|
+
const result = resolveAspects({
|
|
17
|
+
anatomy: false,
|
|
18
|
+
modifiers: false,
|
|
19
|
+
tokens: false,
|
|
20
|
+
implementations: false,
|
|
21
|
+
});
|
|
22
|
+
expect(result).toEqual({
|
|
23
|
+
anatomy: true,
|
|
24
|
+
modifiers: true,
|
|
25
|
+
tokens: true,
|
|
26
|
+
implementations: true,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("returns only selected aspects when one is set", () => {
|
|
31
|
+
const result = resolveAspects({ modifiers: true });
|
|
32
|
+
expect(result).toEqual({
|
|
33
|
+
anatomy: false,
|
|
34
|
+
modifiers: true,
|
|
35
|
+
tokens: false,
|
|
36
|
+
implementations: false,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("returns multiple selected aspects", () => {
|
|
41
|
+
const result = resolveAspects({ modifiers: true, tokens: true });
|
|
42
|
+
expect(result).toEqual({
|
|
43
|
+
anatomy: false,
|
|
44
|
+
modifiers: true,
|
|
45
|
+
tokens: true,
|
|
46
|
+
implementations: false,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("returns all selected when all are true", () => {
|
|
51
|
+
const result = resolveAspects({
|
|
52
|
+
anatomy: true,
|
|
53
|
+
modifiers: true,
|
|
54
|
+
tokens: true,
|
|
55
|
+
implementations: true,
|
|
56
|
+
});
|
|
57
|
+
expect(result).toEqual({
|
|
58
|
+
anatomy: true,
|
|
59
|
+
modifiers: true,
|
|
60
|
+
tokens: true,
|
|
61
|
+
implementations: true,
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves partial aspect flags into a complete {@link AspectFlags} object.
|
|
3
|
+
*
|
|
4
|
+
* When no individual aspect is selected, all aspects default to `true` so
|
|
5
|
+
* the full detail view is shown. When at least one aspect is explicitly
|
|
6
|
+
* selected, only the selected aspects are enabled.
|
|
7
|
+
*
|
|
8
|
+
* @param flags - partial aspect selection from CLI flags
|
|
9
|
+
* @returns fully resolved aspect flags
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { AspectFlags } from "../types.js";
|
|
13
|
+
|
|
14
|
+
const ALL_ASPECTS: AspectFlags = {
|
|
15
|
+
anatomy: true,
|
|
16
|
+
modifiers: true,
|
|
17
|
+
tokens: true,
|
|
18
|
+
implementations: true,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default function resolveAspects(
|
|
22
|
+
flags: Partial<AspectFlags>,
|
|
23
|
+
): AspectFlags {
|
|
24
|
+
const anySet =
|
|
25
|
+
flags.anatomy || flags.modifiers || flags.tokens || flags.implementations;
|
|
26
|
+
|
|
27
|
+
if (!anySet) return ALL_ASPECTS;
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
anatomy: flags.anatomy ?? false,
|
|
31
|
+
modifiers: flags.modifiers ?? false,
|
|
32
|
+
tokens: flags.tokens ?? false,
|
|
33
|
+
implementations: flags.implementations ?? false,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Block domain — CLI commands and operations.
|
|
3
|
+
*
|
|
4
|
+
* Commands: `pragma block list`, `pragma block lookup <name>`.
|
|
5
|
+
* Operations: {@link lookupBlock}, {@link listBlocks}.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { CommandDefinition } from "@canonical/cli-core";
|
|
9
|
+
import type { PragmaContext } from "../shared/context.js";
|
|
10
|
+
import { listCommand, lookupCommand } from "./commands/index.js";
|
|
11
|
+
|
|
12
|
+
export function commands(ctx: PragmaContext): CommandDefinition[] {
|
|
13
|
+
return [listCommand(ctx), lookupCommand(ctx)];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { blockConfig } from "./blockConfig.js";
|
|
17
|
+
export { specs as mcpSpecs } from "./mcp/index.js";
|
|
18
|
+
export { listBlocks, lookupBlock } from "./operations/index.js";
|
|
19
|
+
export {
|
|
20
|
+
blockEmptyError,
|
|
21
|
+
buildBlockFilters,
|
|
22
|
+
enrichBlocks,
|
|
23
|
+
resolveBlockList,
|
|
24
|
+
resolveBlockLookup,
|
|
25
|
+
} from "./orchestration/index.js";
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool specs for the block domain — block_list, block_lookup.
|
|
3
|
+
*
|
|
4
|
+
* Declarative definitions — no MCP imports. The adapter layer
|
|
5
|
+
* converts these into registered MCP tools via `registerFromSpec()`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ToolSpec } from "../../shared/ToolSpec.js";
|
|
9
|
+
import {
|
|
10
|
+
listFormatters as blockListFmt,
|
|
11
|
+
lookupFormatters as blockLookupFmt,
|
|
12
|
+
} from "../formatters/index.js";
|
|
13
|
+
import {
|
|
14
|
+
buildBlockFilters,
|
|
15
|
+
resolveBlockList,
|
|
16
|
+
resolveBlockLookup,
|
|
17
|
+
} from "../orchestration/index.js";
|
|
18
|
+
|
|
19
|
+
const specs: readonly ToolSpec[] = [
|
|
20
|
+
{
|
|
21
|
+
name: "block_list",
|
|
22
|
+
description:
|
|
23
|
+
"List design system blocks visible under current tier and channel configuration.",
|
|
24
|
+
params: {
|
|
25
|
+
allTiers: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
description: "Show blocks from all tiers, ignoring tier filter",
|
|
28
|
+
optional: true,
|
|
29
|
+
},
|
|
30
|
+
digest: {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
description: "Include implementations per block",
|
|
33
|
+
optional: true,
|
|
34
|
+
},
|
|
35
|
+
detailed: {
|
|
36
|
+
type: "boolean",
|
|
37
|
+
description: "Include full details per block",
|
|
38
|
+
optional: true,
|
|
39
|
+
},
|
|
40
|
+
condensed: {
|
|
41
|
+
type: "boolean",
|
|
42
|
+
description: "Token-optimized output",
|
|
43
|
+
optional: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
readOnly: true,
|
|
47
|
+
async execute(rt, { allTiers, digest, detailed, condensed }) {
|
|
48
|
+
const contract = await resolveBlockList(rt, {
|
|
49
|
+
allTiers: allTiers === true,
|
|
50
|
+
digest: digest === true,
|
|
51
|
+
detailed: detailed === true,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (condensed) {
|
|
55
|
+
const text = blockListFmt.llm(contract.result.items);
|
|
56
|
+
return {
|
|
57
|
+
condensed: true,
|
|
58
|
+
text,
|
|
59
|
+
tokens: `~${Math.ceil(text.length / 4)}`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (contract.result.disclosure.level === "detailed") {
|
|
64
|
+
return {
|
|
65
|
+
data: contract.result.items,
|
|
66
|
+
meta: {
|
|
67
|
+
count: contract.result.items.length,
|
|
68
|
+
disclosure: "detailed",
|
|
69
|
+
filters: contract.result.filters,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (contract.result.disclosure.level === "digest") {
|
|
75
|
+
return {
|
|
76
|
+
data: contract.result.items,
|
|
77
|
+
meta: {
|
|
78
|
+
count: contract.result.items.length,
|
|
79
|
+
disclosure: "digest",
|
|
80
|
+
filters: contract.result.filters,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
data: contract.result.items,
|
|
87
|
+
meta: {
|
|
88
|
+
count: contract.result.items.length,
|
|
89
|
+
filters: contract.result.filters,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
{
|
|
96
|
+
name: "block_lookup",
|
|
97
|
+
description:
|
|
98
|
+
"Get detailed information about one or more design system blocks including anatomy, modifiers, tokens, and applicable standards.",
|
|
99
|
+
params: {
|
|
100
|
+
names: {
|
|
101
|
+
type: "string[]",
|
|
102
|
+
description:
|
|
103
|
+
"Block names or IRIs to look up (e.g. ['Button', 'ds:global.component.card'])",
|
|
104
|
+
optional: false,
|
|
105
|
+
},
|
|
106
|
+
detailed: {
|
|
107
|
+
type: "boolean",
|
|
108
|
+
description: "Return full details (default: true for MCP)",
|
|
109
|
+
optional: true,
|
|
110
|
+
},
|
|
111
|
+
condensed: {
|
|
112
|
+
type: "boolean",
|
|
113
|
+
description: "Token-optimized output",
|
|
114
|
+
optional: true,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
readOnly: true,
|
|
118
|
+
async execute(rt, { names, detailed, condensed }) {
|
|
119
|
+
const queries = names as string[];
|
|
120
|
+
const showDetailed = (detailed as boolean | undefined) ?? true;
|
|
121
|
+
const contract = await resolveBlockLookup(
|
|
122
|
+
rt.store,
|
|
123
|
+
queries,
|
|
124
|
+
buildBlockFilters(rt),
|
|
125
|
+
);
|
|
126
|
+
const result = contract.result;
|
|
127
|
+
|
|
128
|
+
if (condensed) {
|
|
129
|
+
const textParts = result.results.map((block) =>
|
|
130
|
+
blockLookupFmt.llm({
|
|
131
|
+
block,
|
|
132
|
+
detailed: showDetailed,
|
|
133
|
+
aspects: {
|
|
134
|
+
anatomy: true,
|
|
135
|
+
modifiers: true,
|
|
136
|
+
tokens: true,
|
|
137
|
+
implementations: true,
|
|
138
|
+
},
|
|
139
|
+
}),
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
if (result.errors.length > 0) {
|
|
143
|
+
textParts.push(
|
|
144
|
+
[
|
|
145
|
+
"### Errors",
|
|
146
|
+
...result.errors.map(
|
|
147
|
+
(error) => `- ${error.query}: ${error.message}`,
|
|
148
|
+
),
|
|
149
|
+
].join("\n"),
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
condensed: true,
|
|
155
|
+
text: textParts.join("\n\n"),
|
|
156
|
+
tokens: `~${Math.ceil(textParts.join("\n\n").length / 4)}`,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (!showDetailed) {
|
|
161
|
+
const summaries = result.results.map(
|
|
162
|
+
({
|
|
163
|
+
uri,
|
|
164
|
+
name,
|
|
165
|
+
type,
|
|
166
|
+
tier,
|
|
167
|
+
modifiers,
|
|
168
|
+
implementations,
|
|
169
|
+
nodeCount,
|
|
170
|
+
tokenCount,
|
|
171
|
+
summary,
|
|
172
|
+
}) => ({
|
|
173
|
+
uri,
|
|
174
|
+
name,
|
|
175
|
+
type,
|
|
176
|
+
tier,
|
|
177
|
+
modifiers,
|
|
178
|
+
implementations,
|
|
179
|
+
nodeCount,
|
|
180
|
+
tokenCount,
|
|
181
|
+
summary,
|
|
182
|
+
}),
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
data: {
|
|
187
|
+
results: summaries,
|
|
188
|
+
errors: result.errors,
|
|
189
|
+
},
|
|
190
|
+
meta: { count: summaries.length },
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return { data: result, meta: { count: result.results.length } };
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
] as const;
|
|
198
|
+
|
|
199
|
+
export default specs;
|