@canonical/pragma-cli 0.27.1-experimental.0 → 0.30.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 +67 -15
- package/dist/pragma +0 -0
- package/package.json +16 -17
- package/src/config/defaultConfig.test.ts +33 -0
- package/src/config/defaultConfig.ts +59 -0
- package/src/config/defaults.json +17 -0
- package/src/config/findProjectConfigPath.test.ts +53 -0
- package/src/config/findProjectConfigPath.ts +36 -0
- package/src/config/index.ts +17 -2
- package/src/config/mergeConfigFileUpdate.ts +58 -0
- package/src/config/parseConfigValues.ts +215 -0
- package/src/config/readConfig.test.ts +104 -13
- package/src/config/readConfig.ts +12 -117
- package/src/config/readConfigLayers.test.ts +107 -0
- package/src/config/readConfigLayers.ts +115 -0
- package/src/config/resolveGlobalConfigPath.ts +13 -0
- package/src/config/resolveWriteConfigPath.test.ts +53 -0
- package/src/config/resolveWriteConfigPath.ts +31 -0
- package/src/config/types.ts +88 -2
- package/src/config/writeConfig.ts +25 -43
- package/src/constants.ts +12 -1
- package/src/domains/block/commands/index.ts +2 -1
- package/src/domains/block/commands/list.ts +5 -90
- package/src/domains/block/commands/lookup.ts +8 -167
- package/src/domains/block/commands/sample.ts +55 -0
- package/src/domains/block/formatters/index.ts +2 -1
- package/src/domains/block/formatters/sample.ts +21 -0
- package/src/domains/block/index.ts +3 -3
- package/src/domains/block/mcp/specs.ts +36 -168
- package/src/domains/block/operations/index.ts +2 -1
- package/src/domains/block/operations/lookup.ts +9 -0
- package/src/domains/block/operations/sample.ts +41 -0
- package/src/domains/block/orchestration/blockEmptyError.test.ts +26 -0
- package/src/domains/block/orchestration/resolveBlockLookup.ts +11 -3
- package/src/domains/block/stories.test.ts +28 -0
- package/src/domains/block/stories.ts +254 -0
- package/src/domains/config/commands/channel.test.ts +14 -3
- package/src/domains/config/commands/channel.ts +11 -7
- package/src/domains/config/commands/configScope.ts +46 -0
- package/src/domains/config/commands/framework.test.ts +105 -0
- package/src/domains/config/commands/framework.ts +91 -0
- package/src/domains/config/commands/index.ts +2 -0
- package/src/domains/config/commands/show.ts +5 -45
- package/src/domains/config/commands/tier.test.ts +13 -2
- package/src/domains/config/commands/tier.ts +11 -7
- package/src/domains/config/commands/trace.test.ts +165 -0
- package/src/domains/config/commands/trace.ts +83 -0
- package/src/domains/config/formatters/channel.test.ts +20 -6
- package/src/domains/config/formatters/channel.ts +14 -11
- package/src/domains/config/formatters/framework.ts +37 -0
- package/src/domains/config/formatters/index.ts +2 -0
- package/src/domains/config/formatters/show.test.ts +27 -0
- package/src/domains/config/formatters/show.ts +27 -4
- package/src/domains/config/formatters/tier.test.ts +26 -10
- package/src/domains/config/formatters/tier.ts +19 -11
- package/src/domains/config/formatters/trace.ts +28 -0
- package/src/domains/config/index.ts +15 -2
- package/src/domains/config/mcp/specs.ts +33 -53
- package/src/domains/config/operations/index.ts +1 -0
- package/src/domains/config/operations/show.test.ts +18 -0
- package/src/domains/config/operations/show.ts +7 -1
- package/src/domains/config/operations/types.ts +7 -0
- package/src/domains/config/operations/validateFramework.ts +24 -0
- package/src/domains/config/stories.ts +42 -0
- package/src/domains/config/tasks/index.ts +3 -0
- package/src/domains/config/tasks/setChannel.ts +13 -22
- package/src/domains/config/tasks/setFramework.ts +21 -0
- package/src/domains/config/tasks/setTier.ts +10 -23
- package/src/domains/config/tasks/setTrace.ts +20 -0
- package/src/domains/config/tasks/writeConfigField.ts +41 -0
- package/src/domains/create/commands/component.ts +5 -5
- package/src/domains/doctor/operations/checks/checkConfigFile.ts +19 -5
- package/src/domains/doctor/operations/checks/checkKeStore.ts +5 -5
- package/src/domains/doctor/operations/checks/checkMcpCommands.ts +130 -0
- package/src/domains/doctor/operations/checks/checkMcpConfigured.ts +1 -1
- package/src/domains/doctor/operations/checks/checkPackageRefs.ts +30 -48
- package/src/domains/doctor/operations/checks/checkSkillsSymlinked.ts +1 -1
- package/src/domains/doctor/operations/checks/index.ts +1 -0
- package/src/domains/doctor/operations/checks.test.ts +162 -8
- package/src/domains/doctor/operations/runChecks.test.ts +85 -4
- package/src/domains/doctor/operations/runChecks.ts +50 -12
- package/src/domains/graph/helpers/resolveUri.test.ts +50 -0
- package/src/domains/graph/helpers/resolveUri.ts +28 -21
- package/src/domains/graphql/commands/build.test.ts +196 -0
- package/src/domains/graphql/commands/build.ts +117 -0
- package/src/domains/graphql/commands/check.test.ts +141 -0
- package/src/domains/graphql/commands/check.ts +81 -0
- package/src/domains/graphql/commands/index.ts +5 -0
- package/src/domains/graphql/commands/serve.test.ts +40 -0
- package/src/domains/graphql/commands/serve.ts +131 -0
- package/src/domains/graphql/constants.ts +10 -0
- package/src/domains/graphql/formatters/index.ts +3 -0
- package/src/domains/graphql/formatters/report.ts +78 -0
- package/src/domains/graphql/helpers/gatherSources.test.ts +92 -0
- package/src/domains/graphql/helpers/gatherSources.ts +58 -0
- package/src/domains/graphql/helpers/index.ts +6 -0
- package/src/domains/graphql/helpers/parsePrefixes.test.ts +44 -0
- package/src/domains/graphql/helpers/parsePrefixes.ts +38 -0
- package/src/domains/graphql/helpers/resolveSourceFiles.test.ts +56 -0
- package/src/domains/graphql/helpers/resolveSourceFiles.ts +45 -0
- package/src/domains/graphql/helpers/routeGraphql.test.ts +43 -0
- package/src/domains/graphql/helpers/routeGraphql.ts +28 -0
- package/src/domains/graphql/index.ts +24 -0
- package/src/domains/graphql/operations/compileSchema.test.ts +95 -0
- package/src/domains/graphql/operations/compileSchema.ts +107 -0
- package/src/domains/graphql/operations/createSchemaServer.test.ts +50 -0
- package/src/domains/graphql/operations/createSchemaServer.ts +75 -0
- package/src/domains/graphql/operations/index.ts +12 -0
- package/src/domains/graphql/types.ts +29 -0
- package/src/domains/info/operations/collectInfo.test.ts +16 -5
- package/src/domains/info/operations/collectInfo.ts +16 -19
- package/src/domains/llm/capabilities.test.ts +91 -0
- package/src/domains/llm/commands/capabilities.ts +28 -0
- package/src/domains/llm/commands/index.ts +1 -0
- package/src/domains/llm/data/commandReference.ts +90 -18
- package/src/domains/llm/data/decisionTrees.ts +15 -13
- package/src/domains/llm/data/index.ts +2 -0
- package/src/domains/llm/data/toolCatalog.ts +190 -0
- package/src/domains/llm/formatters/capabilities.ts +50 -0
- package/src/domains/llm/formatters/index.ts +1 -0
- package/src/domains/llm/index.ts +3 -2
- package/src/domains/llm/mcp/index.ts +1 -1
- package/src/domains/llm/mcp/specs.ts +59 -52
- package/src/domains/llm/types.ts +40 -0
- package/src/domains/modifier/commands/index.ts +2 -1
- package/src/domains/modifier/commands/list.ts +5 -38
- package/src/domains/modifier/commands/lookup.ts +8 -79
- package/src/domains/modifier/commands/sample.ts +53 -0
- package/src/domains/modifier/formatters/index.ts +2 -1
- package/src/domains/modifier/formatters/sample.ts +15 -0
- package/src/domains/modifier/index.ts +7 -3
- package/src/domains/modifier/mcp/specs.ts +38 -70
- package/src/domains/modifier/operations/index.ts +2 -1
- package/src/domains/modifier/operations/lookup.ts +9 -0
- package/src/domains/modifier/operations/sample.ts +32 -0
- package/src/domains/modifier/orchestration/modifierEmptyError.test.ts +26 -0
- package/src/domains/modifier/orchestration/modifierEmptyError.ts +7 -2
- package/src/domains/modifier/orchestration/resolveModifierLookup.ts +15 -2
- package/src/domains/modifier/stories.test.ts +20 -0
- package/src/domains/modifier/stories.ts +77 -0
- package/src/domains/ontology/commands/list.ts +5 -58
- package/src/domains/ontology/commands/show.ts +6 -58
- package/src/domains/ontology/formatters/show.ts +7 -1
- package/src/domains/ontology/mcp/specs.ts +7 -84
- package/src/domains/ontology/stories.test.ts +36 -0
- package/src/domains/ontology/stories.ts +108 -0
- package/src/domains/refs/operations/index.ts +1 -1
- package/src/domains/refs/operations/paths.ts +29 -1
- package/src/domains/refs/operations/updateRefs.test.ts +6 -3
- package/src/domains/refs/operations/updateRefs.ts +2 -36
- package/src/domains/setup/commands/skills.test.ts +6 -2
- package/src/domains/setup/commands/skills.ts +6 -2
- package/src/domains/setup/helpers/runSetupTask.test.ts +148 -150
- package/src/domains/setup/helpers/runSetupTask.ts +62 -70
- package/src/domains/setup/operations/setupMcp.test.ts +6 -1
- package/src/domains/shared/bootStore.ts +92 -50
- package/src/domains/shared/compactUri.test.ts +11 -0
- package/src/domains/shared/compactUri.ts +10 -5
- package/src/domains/shared/context.ts +2 -2
- package/src/domains/shared/contracts.ts +12 -0
- package/src/domains/shared/createInteractivePromptSession.test.ts +439 -0
- package/src/domains/shared/createInteractivePromptSession.ts +236 -0
- package/src/domains/shared/emptyErrorRecovery.test.ts +109 -0
- package/src/domains/shared/loaders/bundledLoader.test.ts +248 -0
- package/src/domains/shared/loaders/bundledLoader.ts +206 -0
- package/src/domains/shared/loaders/gitLoader.ts +31 -0
- package/src/domains/shared/loaders/index.ts +9 -0
- package/src/domains/shared/loaders/localLoader.ts +87 -0
- package/src/domains/shared/loaders/readPackageDir.ts +147 -0
- package/src/domains/shared/loaders/storyAssetsPlugin.test.ts +84 -0
- package/src/domains/shared/loaders/storyAssetsPlugin.ts +46 -0
- package/src/domains/shared/lookupMany.test.ts +120 -0
- package/src/domains/shared/lookupMany.ts +43 -3
- package/src/domains/shared/mergeAndParseRefs.test.ts +89 -0
- package/src/domains/shared/mergeAndParseRefs.ts +44 -0
- package/src/domains/shared/packages.ts +14 -120
- package/src/domains/shared/pickRandom.ts +22 -0
- package/src/domains/shared/resolveConfiguredGraphs.test.ts +27 -0
- package/src/domains/shared/resolveConfiguredGraphs.ts +41 -0
- package/src/domains/shared/runtime.ts +7 -63
- package/src/domains/shared/sampleFormatters.ts +47 -0
- package/src/domains/shared/semanticPackage.ts +112 -0
- package/src/domains/shared/stories/compileLookupCommand.test.ts +145 -0
- package/src/domains/shared/stories/compileLookupCommand.ts +100 -0
- package/src/domains/shared/stories/compileLookupTool.test.ts +105 -0
- package/src/domains/shared/stories/compileLookupTool.ts +96 -0
- package/src/domains/shared/stories/compileReadCommand.test.ts +121 -0
- package/src/domains/shared/stories/compileReadCommand.ts +48 -0
- package/src/domains/shared/stories/compileReadTool.test.ts +64 -0
- package/src/domains/shared/stories/compileReadTool.ts +38 -0
- package/src/domains/shared/stories/condense.test.ts +18 -0
- package/src/domains/shared/stories/condense.ts +15 -0
- package/src/domains/shared/stories/index.ts +20 -0
- package/src/domains/shared/stories/normalizeNames.test.ts +20 -0
- package/src/domains/shared/stories/normalizeNames.ts +22 -0
- package/src/domains/shared/stories/pack/applyPackFilters.test.ts +102 -0
- package/src/domains/shared/stories/pack/applyPackFilters.ts +76 -0
- package/src/domains/shared/stories/pack/buildLookupQuery.test.ts +51 -0
- package/src/domains/shared/stories/pack/buildLookupQuery.ts +80 -0
- package/src/domains/shared/stories/pack/collectPackStories.test.ts +108 -0
- package/src/domains/shared/stories/pack/collectPackStories.ts +76 -0
- package/src/domains/shared/stories/pack/compilePackCommands.ts +40 -0
- package/src/domains/shared/stories/pack/compilePackStories.test.ts +146 -0
- package/src/domains/shared/stories/pack/compilePackStories.ts +253 -0
- package/src/domains/shared/stories/pack/compilePackToolSpecs.ts +43 -0
- package/src/domains/shared/stories/pack/index.ts +28 -0
- package/src/domains/shared/stories/pack/runSelectQuery.ts +31 -0
- package/src/domains/shared/stories/pack/standardParity.test.ts +308 -0
- package/src/domains/shared/stories/pack/types.ts +104 -0
- package/src/domains/shared/stories/pack/validateStoryPackDefinition.test.ts +240 -0
- package/src/domains/shared/stories/pack/validateStoryPackDefinition.ts +408 -0
- package/src/domains/shared/stories/projectCliParameters.test.ts +59 -0
- package/src/domains/shared/stories/projectCliParameters.ts +57 -0
- package/src/domains/shared/stories/projectToolParams.test.ts +50 -0
- package/src/domains/shared/stories/projectToolParams.ts +32 -0
- package/src/domains/shared/stories/requirePragmaContext.test.ts +23 -0
- package/src/domains/shared/stories/requirePragmaContext.ts +23 -0
- package/src/domains/shared/stories/resolveLookupDetailed.test.ts +57 -0
- package/src/domains/shared/stories/resolveLookupDetailed.ts +27 -0
- package/src/domains/shared/stories/types.ts +171 -0
- package/src/domains/shared/suggestions/detectCrossDomain.test.ts +43 -0
- package/src/domains/shared/suggestions/detectCrossDomain.ts +116 -0
- package/src/domains/shared/suggestions/expandGlob.test.ts +92 -0
- package/src/domains/shared/suggestions/expandGlob.ts +52 -0
- package/src/domains/shared/suggestions/expandLookupQueries.ts +57 -0
- package/src/domains/shared/suggestions/index.ts +7 -0
- package/src/domains/shared/suggestions/listDomainNames.ts +61 -0
- package/src/domains/shared/suggestions/suggestNames.test.ts +70 -0
- package/src/domains/shared/suggestions/suggestNames.ts +130 -0
- package/src/domains/shared/types/index.ts +1 -0
- package/src/domains/shared/types/runtime.ts +4 -1
- package/src/domains/shared/types/sample.ts +17 -0
- package/src/domains/skill/commands/index.ts +3 -1
- package/src/domains/skill/commands/list.test.ts +6 -2
- package/src/domains/skill/commands/list.ts +5 -63
- package/src/domains/skill/commands/lookup.test.ts +118 -0
- package/src/domains/skill/commands/lookup.ts +14 -0
- package/src/domains/skill/formatters/index.ts +1 -0
- package/src/domains/skill/formatters/lookup.test.ts +46 -0
- package/src/domains/skill/formatters/lookup.ts +57 -0
- package/src/domains/skill/helpers/resolveSkillSources.ts +48 -16
- package/src/domains/skill/index.ts +7 -3
- package/src/domains/skill/mcp/specs.ts +10 -29
- package/src/domains/skill/operations/discover.test.ts +61 -30
- package/src/domains/skill/operations/discover.ts +28 -37
- package/src/domains/skill/operations/index.ts +2 -1
- package/src/domains/skill/operations/list.test.ts +15 -7
- package/src/domains/skill/operations/lookup.test.ts +91 -0
- package/src/domains/skill/operations/lookup.ts +70 -0
- package/src/domains/skill/stories.test.ts +43 -0
- package/src/domains/skill/stories.ts +103 -0
- package/src/domains/skill/types.ts +8 -0
- package/src/domains/standard/commands/index.ts +2 -1
- package/src/domains/standard/commands/list.ts +5 -84
- package/src/domains/standard/commands/lookup.ts +8 -93
- package/src/domains/standard/commands/sample.ts +57 -0
- package/src/domains/standard/formatters/index.ts +2 -1
- package/src/domains/standard/formatters/sample.ts +15 -0
- package/src/domains/standard/index.ts +8 -1
- package/src/domains/standard/mcp/specs.ts +44 -152
- package/src/domains/standard/operations/index.ts +2 -1
- package/src/domains/standard/operations/lookup.ts +9 -0
- package/src/domains/standard/operations/sample.ts +35 -0
- package/src/domains/standard/orchestration/resolveStandardLookup.ts +15 -2
- package/src/domains/standard/orchestration/standardEmptyError.test.ts +33 -0
- package/src/domains/standard/orchestration/standardEmptyError.ts +16 -6
- package/src/domains/standard/stories.test.ts +24 -0
- package/src/domains/standard/stories.ts +151 -0
- package/src/domains/tier/commands/list.ts +5 -55
- package/src/domains/tier/mcp/specs.ts +5 -31
- package/src/domains/tier/stories.test.ts +22 -0
- package/src/domains/tier/stories.ts +52 -0
- package/src/domains/token/commands/index.ts +2 -1
- package/src/domains/token/commands/sample.ts +53 -0
- package/src/domains/token/formatters/index.ts +2 -1
- package/src/domains/token/formatters/sample.ts +16 -0
- package/src/domains/token/index.ts +8 -1
- package/src/domains/token/mcp/specs.ts +52 -2
- package/src/domains/token/operations/index.ts +2 -1
- package/src/domains/token/operations/lookup.ts +9 -0
- package/src/domains/token/operations/sample.ts +32 -0
- package/src/domains/token/orchestration/resolveTokenLookup.ts +15 -2
- package/src/domains/token/orchestration/tokenEmptyError.test.ts +33 -0
- package/src/domains/token/orchestration/tokenEmptyError.ts +5 -2
- package/src/domains/trace/commands/clear.ts +71 -0
- package/src/domains/trace/commands/index.ts +5 -0
- package/src/domains/trace/commands/sessions.ts +32 -0
- package/src/domains/trace/commands/show.ts +145 -0
- package/src/domains/trace/formatters/index.ts +9 -0
- package/src/domains/trace/formatters/sessions.ts +80 -0
- package/src/domains/trace/formatters/show.ts +122 -0
- package/src/domains/trace/index.ts +17 -0
- package/src/domains/trace/operations/index.ts +8 -0
- package/src/domains/trace/operations/listSessions.test.ts +55 -0
- package/src/domains/trace/operations/listSessions.ts +52 -0
- package/src/domains/trace/operations/readTraceLog.test.ts +100 -0
- package/src/domains/trace/operations/readTraceLog.ts +104 -0
- package/src/domains/trace/tracePlugin.test.ts +171 -0
- package/src/domains/trace/tracePlugin.ts +159 -0
- package/src/domains/trace/types.ts +65 -0
- package/src/error/PragmaError.ts +15 -2
- package/src/error/types.ts +15 -1
- package/src/mcp/error/serializeErrorPayload.ts +7 -0
- package/src/mcp/error/types.ts +8 -0
- package/src/mcp/registerResources.test.ts +405 -75
- package/src/mcp/registerResources.ts +5 -299
- package/src/mcp/resources/buildGraphIndex.ts +167 -0
- package/src/mcp/resources/buildResourceList.test.ts +97 -0
- package/src/mcp/resources/buildResourceList.ts +176 -0
- package/src/mcp/resources/classifyEntity.test.ts +40 -0
- package/src/mcp/resources/classifyEntity.ts +27 -0
- package/src/mcp/resources/constants.ts +105 -0
- package/src/mcp/resources/displayPredicates.ts +62 -0
- package/src/mcp/resources/pickFirstValue.test.ts +29 -0
- package/src/mcp/resources/pickFirstValue.ts +26 -0
- package/src/mcp/resources/pickPrimaryType.test.ts +41 -0
- package/src/mcp/resources/pickPrimaryType.ts +26 -0
- package/src/mcp/resources/rankUriCompletions.test.ts +52 -0
- package/src/mcp/resources/rankUriCompletions.ts +64 -0
- package/src/mcp/resources/readEntity.ts +169 -0
- package/src/mcp/resources/registerResources.ts +126 -0
- package/src/mcp/resources/types.ts +128 -0
- package/src/mcp/tools/index.ts +9 -0
- package/src/mcp/tools/registerTools.test.ts +84 -12
- package/src/mcp/types.ts +4 -0
- package/src/mcp/utils/wrapTool.test.ts +1 -0
- package/src/pipeline/collectCommands.ts +15 -2
- package/src/pipeline/renderError.ts +15 -0
- package/src/pipeline/resolveCommandKind.ts +8 -1
- package/src/pipeline/runCli.ts +51 -6
- package/src/testing/createTestMcpClient.ts +5 -1
- package/src/testing/graphqlFixtures.ts +72 -0
- package/src/testing/index.ts +17 -0
- package/src/testing/integration/__snapshots__/executor-golden.test.ts.snap +1207 -0
- package/src/testing/integration/cross-binary-byte-equality.test.ts +129 -0
- package/src/testing/integration/executor-execution.test.ts +101 -0
- package/src/testing/integration/executor-golden.test.ts +145 -0
- package/src/testing/integration/mcp-surface.test.ts +11 -5
- package/src/testing/integration/parity.test.ts +17 -12
- package/src/testing/regression/0001-skill-discovery-granularity.test.ts +71 -0
- package/src/testing/setupXdgIsolation.ts +15 -0
- package/src/testing/standardParityFixtures.ts +92 -0
- package/src/testing/storyFixtures.ts +63 -0
- package/src/pipeline/runInteractiveCommand.ts +0 -198
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill read stories — the single declaration of `skill list` and
|
|
3
|
+
* `skill lookup` for both surfaces.
|
|
4
|
+
*
|
|
5
|
+
* `skill lookup` serves the full SKILL.md content, making skills directly
|
|
6
|
+
* consumable by agents over MCP (previously only metadata was listed).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { PragmaError } from "#error";
|
|
10
|
+
import lookupMany from "../shared/lookupMany.js";
|
|
11
|
+
import {
|
|
12
|
+
type LookupStory,
|
|
13
|
+
type ReadStory,
|
|
14
|
+
requirePragmaContext,
|
|
15
|
+
} from "../shared/stories/index.js";
|
|
16
|
+
import { listFormatters, lookupFormatters } from "./formatters/index.js";
|
|
17
|
+
import type { SkillListInput } from "./formatters/types.js";
|
|
18
|
+
import {
|
|
19
|
+
discoverSkills,
|
|
20
|
+
listSkills,
|
|
21
|
+
lookupSkill,
|
|
22
|
+
type SkillListResult,
|
|
23
|
+
} from "./operations/index.js";
|
|
24
|
+
import type { SkillDetailed } from "./types.js";
|
|
25
|
+
|
|
26
|
+
/** The `skill list` / `skill_list` read story. */
|
|
27
|
+
export const skillListStory: ReadStory<SkillListResult, SkillListInput> = {
|
|
28
|
+
noun: "skill",
|
|
29
|
+
verb: "list",
|
|
30
|
+
description: "List available agent skills from design system packages",
|
|
31
|
+
toolDescription: "List available agent skills from design system packages.",
|
|
32
|
+
params: [
|
|
33
|
+
{
|
|
34
|
+
name: "detailed",
|
|
35
|
+
type: "boolean",
|
|
36
|
+
description: "Show full metadata for each skill",
|
|
37
|
+
default: false,
|
|
38
|
+
surfaces: "cli",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
examples: [
|
|
42
|
+
"pragma skill list",
|
|
43
|
+
"pragma skill list --detailed",
|
|
44
|
+
"pragma skill list --llm",
|
|
45
|
+
"pragma skill list --format json",
|
|
46
|
+
],
|
|
47
|
+
resolve: (rt) => listSkills(rt.cwd),
|
|
48
|
+
toOutput: ({ skills, sources }, params) => ({
|
|
49
|
+
skills,
|
|
50
|
+
sources,
|
|
51
|
+
detailed: params.detailed === true,
|
|
52
|
+
}),
|
|
53
|
+
formatters: listFormatters,
|
|
54
|
+
toEnvelope: ({ skills, sources }) => ({
|
|
55
|
+
data: { skills, sources },
|
|
56
|
+
meta: { count: skills.length },
|
|
57
|
+
}),
|
|
58
|
+
emptyError: ({ skills, sources }) => {
|
|
59
|
+
if (skills.length > 0) return undefined;
|
|
60
|
+
const allUnavailable = sources.every((source) => !source.available);
|
|
61
|
+
return PragmaError.emptyResults("skill", {
|
|
62
|
+
recovery: {
|
|
63
|
+
message: allUnavailable
|
|
64
|
+
? "Install @canonical packages first"
|
|
65
|
+
: "No SKILL.md files found in source packages",
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** The `skill lookup` / `skill_lookup` read story. */
|
|
72
|
+
export const skillLookupStory: LookupStory<SkillDetailed, SkillDetailed> = {
|
|
73
|
+
noun: "skill",
|
|
74
|
+
description: "Show full instructions for a skill by name",
|
|
75
|
+
toolDescription:
|
|
76
|
+
"Get full skill instructions (SKILL.md content) for one or more agent skills by name.",
|
|
77
|
+
namesDescription: "Skill names",
|
|
78
|
+
namesToolDescription: "Skill names to look up (e.g. ['design-auditor'])",
|
|
79
|
+
complete: async (partial, cmdCtx) => {
|
|
80
|
+
const ctx = requirePragmaContext(cmdCtx);
|
|
81
|
+
const skills = await discoverSkills(ctx.cwd);
|
|
82
|
+
return skills
|
|
83
|
+
.map((skill) => skill.name)
|
|
84
|
+
.filter((name) => name.toLowerCase().startsWith(partial.toLowerCase()));
|
|
85
|
+
},
|
|
86
|
+
examples: [
|
|
87
|
+
"pragma skill lookup design-auditor",
|
|
88
|
+
"pragma skill lookup design-auditor add-standard",
|
|
89
|
+
"pragma skill lookup design-auditor --llm",
|
|
90
|
+
],
|
|
91
|
+
resolve: (rt, names) =>
|
|
92
|
+
lookupMany(names, (query) => lookupSkill(rt.cwd, query)),
|
|
93
|
+
toFmtInput: (skill) => skill,
|
|
94
|
+
formatters: lookupFormatters,
|
|
95
|
+
emptyNamesError: () =>
|
|
96
|
+
PragmaError.invalidInput("names", "(empty)", {
|
|
97
|
+
recovery: {
|
|
98
|
+
message: "List available skills.",
|
|
99
|
+
cli: "pragma skill list",
|
|
100
|
+
mcp: { tool: "skill_list" },
|
|
101
|
+
},
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
@@ -23,3 +23,11 @@ export interface SkillSource {
|
|
|
23
23
|
readonly packageName: string;
|
|
24
24
|
readonly available: boolean;
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
/** A discovered skill enriched with its full SKILL.md content and companion files. */
|
|
28
|
+
export interface SkillDetailed extends DiscoveredSkill {
|
|
29
|
+
/** Full SKILL.md text, frontmatter included. */
|
|
30
|
+
readonly content: string;
|
|
31
|
+
/** Companion file names shipped next to SKILL.md (e.g. spec documents). */
|
|
32
|
+
readonly files: readonly string[];
|
|
33
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/** @module Re-exports standard command builders (`categories`, `
|
|
1
|
+
/** @module Re-exports standard command builders (`categories`, `list`, `lookup`, `sample`). */
|
|
2
2
|
|
|
3
3
|
export { default as categoriesCommand } from "./categories.js";
|
|
4
4
|
export { default as listCommand } from "./list.js";
|
|
5
5
|
export { default as lookupCommand } from "./lookup.js";
|
|
6
|
+
export { default as sampleCommand } from "./sample.js";
|
|
@@ -1,90 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
* Wires the `pragma standard list` CLI command.
|
|
3
|
-
*
|
|
4
|
-
* Lists all code standards with optional category and search filters.
|
|
5
|
-
* Supports progressive disclosure via `--digest` (summary + first example)
|
|
6
|
-
* and `--detailed` (full dos/donts) flags.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
type CommandDefinition,
|
|
11
|
-
type CommandResult,
|
|
12
|
-
createOutputResult,
|
|
13
|
-
} from "@canonical/cli-core";
|
|
14
|
-
import { createListView } from "#tui";
|
|
1
|
+
import type { CommandDefinition } from "@canonical/cli-core";
|
|
15
2
|
import type { PragmaContext } from "../../shared/context.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import type { StandardListOutput } from "../formatters/types.js";
|
|
19
|
-
import { resolveStandardList } from "../orchestration/index.js";
|
|
20
|
-
import { standardConfig } from "../standardConfig.js";
|
|
3
|
+
import { compileReadCommand } from "../../shared/stories/index.js";
|
|
4
|
+
import { standardListStory } from "../stories.js";
|
|
21
5
|
|
|
6
|
+
/** Wire the `pragma standard list` CLI command from the standard list story. */
|
|
22
7
|
export default function buildListCommand(
|
|
23
8
|
ctx: PragmaContext,
|
|
24
9
|
): CommandDefinition {
|
|
25
|
-
return
|
|
26
|
-
path: ["standard", "list"],
|
|
27
|
-
description: "List all code standards",
|
|
28
|
-
parameters: [
|
|
29
|
-
{
|
|
30
|
-
name: "category",
|
|
31
|
-
description: "Filter by category",
|
|
32
|
-
type: "string",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: "search",
|
|
36
|
-
description: "Search in name and description",
|
|
37
|
-
type: "string",
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "digest",
|
|
41
|
-
description: "Show description and first example for each standard",
|
|
42
|
-
type: "boolean",
|
|
43
|
-
default: false,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: "detailed",
|
|
47
|
-
description: "Show full dos/donts for each standard",
|
|
48
|
-
type: "boolean",
|
|
49
|
-
default: false,
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
meta: {
|
|
53
|
-
examples: [
|
|
54
|
-
"pragma standard list",
|
|
55
|
-
"pragma standard list --category react",
|
|
56
|
-
'pragma standard list --search "folder"',
|
|
57
|
-
"pragma standard list --digest",
|
|
58
|
-
"pragma standard list --detailed",
|
|
59
|
-
"pragma standard list --llm",
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
execute: async (
|
|
63
|
-
params: Record<string, unknown>,
|
|
64
|
-
): Promise<CommandResult> => {
|
|
65
|
-
const contract = await resolveStandardList(ctx, {
|
|
66
|
-
category: params.category as string | undefined,
|
|
67
|
-
search: params.search as string | undefined,
|
|
68
|
-
digest: params.digest === true,
|
|
69
|
-
detailed: params.detailed === true,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const output: StandardListOutput = {
|
|
73
|
-
items: contract.items,
|
|
74
|
-
details: contract.details,
|
|
75
|
-
disclosure: contract.disclosure,
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return createOutputResult(output, {
|
|
79
|
-
plain: selectFormatter(ctx, listFormatters),
|
|
80
|
-
ink: (data) =>
|
|
81
|
-
createListView({
|
|
82
|
-
heading: "Standards",
|
|
83
|
-
domain: "standard",
|
|
84
|
-
items: data.items,
|
|
85
|
-
columns: standardConfig.listColumns,
|
|
86
|
-
}),
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
};
|
|
10
|
+
return compileReadCommand(ctx, standardListStory);
|
|
90
11
|
}
|
|
@@ -1,99 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
* Wires the `pragma standard lookup <name-or-uri...>` CLI command.
|
|
3
|
-
*
|
|
4
|
-
* Retrieves detailed information for a single code standard, including
|
|
5
|
-
* optional dos/donts code blocks when `--detailed` is passed.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
type CommandDefinition,
|
|
10
|
-
type CommandResult,
|
|
11
|
-
createOutputResult,
|
|
12
|
-
} from "@canonical/cli-core";
|
|
13
|
-
import { createLookupView } from "#tui";
|
|
1
|
+
import type { CommandDefinition } from "@canonical/cli-core";
|
|
14
2
|
import type { PragmaContext } from "../../shared/context.js";
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
createInkLookupOptions,
|
|
19
|
-
lookupFormatters,
|
|
20
|
-
} from "../formatters/index.js";
|
|
21
|
-
import type { lookupStandard } from "../operations/index.js";
|
|
22
|
-
import { resolveStandardLookup } from "../orchestration/index.js";
|
|
23
|
-
|
|
24
|
-
interface StandardLookupOutput {
|
|
25
|
-
readonly result: LookupResult<Awaited<ReturnType<typeof lookupStandard>>>;
|
|
26
|
-
readonly detailed: boolean;
|
|
27
|
-
}
|
|
3
|
+
import { compileLookupCommand } from "../../shared/stories/index.js";
|
|
4
|
+
import { standardLookupStory } from "../stories.js";
|
|
28
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Wire the `pragma standard lookup <name-or-uri...>` CLI command from the
|
|
8
|
+
* standard lookup story.
|
|
9
|
+
*/
|
|
29
10
|
export default function buildLookupCommand(
|
|
30
11
|
ctx: PragmaContext,
|
|
31
12
|
): CommandDefinition {
|
|
32
|
-
return
|
|
33
|
-
path: ["standard", "lookup"],
|
|
34
|
-
description: "Look up detailed information for a standard by name or IRI",
|
|
35
|
-
parameters: [
|
|
36
|
-
{
|
|
37
|
-
name: "names",
|
|
38
|
-
description: "Standard names or IRIs",
|
|
39
|
-
type: "multiselect",
|
|
40
|
-
positional: true,
|
|
41
|
-
required: true,
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: "detailed",
|
|
45
|
-
description: "Include dos and donts with code blocks",
|
|
46
|
-
type: "boolean",
|
|
47
|
-
default: false,
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
meta: {
|
|
51
|
-
examples: [
|
|
52
|
-
"pragma standard lookup react/component/folder-structure",
|
|
53
|
-
"pragma standard lookup react/component/folder-structure react/component/props",
|
|
54
|
-
"pragma standard lookup react/component/folder-structure --detailed",
|
|
55
|
-
"pragma standard lookup react/component/folder-structure --llm",
|
|
56
|
-
"pragma standard lookup cs:react_props",
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
execute: async (
|
|
60
|
-
params: Record<string, unknown>,
|
|
61
|
-
): Promise<CommandResult> => {
|
|
62
|
-
const names = normalizeNames(params.names, params.name);
|
|
63
|
-
const detailed = (params.detailed as boolean) ?? false;
|
|
64
|
-
const contract = await resolveStandardLookup(ctx.store, names);
|
|
65
|
-
|
|
66
|
-
return createOutputResult<StandardLookupOutput>(
|
|
67
|
-
{ result: contract.result, detailed },
|
|
68
|
-
{
|
|
69
|
-
plain: ({ result, detailed: isDetailed }) =>
|
|
70
|
-
renderLookupResults({
|
|
71
|
-
ctx,
|
|
72
|
-
result,
|
|
73
|
-
formatters: lookupFormatters,
|
|
74
|
-
mapResult: (standard) => ({ standard, detailed: isDetailed }),
|
|
75
|
-
}),
|
|
76
|
-
ink: ({ result, detailed: isDetailed }) =>
|
|
77
|
-
createLookupView({
|
|
78
|
-
results: result.results,
|
|
79
|
-
errors: result.errors,
|
|
80
|
-
domain: "standard",
|
|
81
|
-
options: createInkLookupOptions(isDetailed),
|
|
82
|
-
}),
|
|
83
|
-
},
|
|
84
|
-
);
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function normalizeNames(names: unknown, legacyName?: unknown): string[] {
|
|
90
|
-
if (Array.isArray(names)) {
|
|
91
|
-
return names.filter(
|
|
92
|
-
(name): name is string => typeof name === "string" && name.length > 0,
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
if (typeof legacyName === "string" && legacyName.length > 0) {
|
|
96
|
-
return [legacyName];
|
|
97
|
-
}
|
|
98
|
-
return [];
|
|
13
|
+
return compileLookupCommand(ctx, standardLookupStory);
|
|
99
14
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wires the `pragma standard sample` CLI command.
|
|
3
|
+
*
|
|
4
|
+
* Returns 1–5 complete standard instances as exemplars so agents
|
|
5
|
+
* can learn the data shape before writing queries.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
type CommandDefinition,
|
|
10
|
+
createOutputResult,
|
|
11
|
+
} from "@canonical/cli-core";
|
|
12
|
+
import type { PragmaContext } from "../../shared/context.js";
|
|
13
|
+
import { selectFormatter } from "../../shared/formatters.js";
|
|
14
|
+
import type {
|
|
15
|
+
SampleOutput,
|
|
16
|
+
StandardDetailed,
|
|
17
|
+
} from "../../shared/types/index.js";
|
|
18
|
+
import { sampleFormatters } from "../formatters/index.js";
|
|
19
|
+
import { sampleStandards } from "../operations/index.js";
|
|
20
|
+
|
|
21
|
+
const NEXT_STEPS = [
|
|
22
|
+
"Use standard_lookup to inspect specific standards by name.",
|
|
23
|
+
"Use standard_list with --category to filter by category.",
|
|
24
|
+
"Use standard_categories to see all available categories.",
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export default function sampleCommand(ctx: PragmaContext): CommandDefinition {
|
|
28
|
+
return {
|
|
29
|
+
path: ["standard", "sample"],
|
|
30
|
+
description:
|
|
31
|
+
"Return randomly selected complete standard instances as exemplars for shape discovery",
|
|
32
|
+
parameters: [
|
|
33
|
+
{
|
|
34
|
+
name: "count",
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "Number of samples to return (1–5, default 2)",
|
|
37
|
+
required: false,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
meta: {
|
|
41
|
+
examples: ["pragma standard sample", "pragma standard sample --count 3"],
|
|
42
|
+
},
|
|
43
|
+
async execute(params) {
|
|
44
|
+
const count = Number(params.count ?? 2);
|
|
45
|
+
const result = await sampleStandards(ctx.store, count);
|
|
46
|
+
|
|
47
|
+
const output: SampleOutput<StandardDetailed> = {
|
|
48
|
+
...result,
|
|
49
|
+
nextSteps: NEXT_STEPS,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return createOutputResult(output, {
|
|
53
|
+
plain: selectFormatter(ctx, sampleFormatters),
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @module Re-exports standard formatters (`categoriesFormatters`, `
|
|
1
|
+
/** @module Re-exports standard formatters (`categoriesFormatters`, `listFormatters`, `lookupFormatters`, `sampleFormatters`). */
|
|
2
2
|
|
|
3
3
|
export { default as categoriesFormatters } from "./categories.js";
|
|
4
4
|
export { default as listFormatters } from "./list.js";
|
|
@@ -6,4 +6,5 @@ export {
|
|
|
6
6
|
createInkLookupOptions,
|
|
7
7
|
default as lookupFormatters,
|
|
8
8
|
} from "./lookup.js";
|
|
9
|
+
export { default as sampleFormatters } from "./sample.js";
|
|
9
10
|
export type { StandardListOutput, StandardLookupInput } from "./types.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sample formatter for the standard domain.
|
|
3
|
+
*
|
|
4
|
+
* Delegates to the shared factory, rendering each item via the
|
|
5
|
+
* existing standard lookup formatter.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import createSampleFormatters from "../../shared/sampleFormatters.js";
|
|
9
|
+
import type { StandardDetailed } from "../../shared/types/index.js";
|
|
10
|
+
import lookupFormatters from "./lookup.js";
|
|
11
|
+
|
|
12
|
+
export default createSampleFormatters<StandardDetailed>(
|
|
13
|
+
"standards",
|
|
14
|
+
(standard, mode) => lookupFormatters[mode]({ standard, detailed: true }),
|
|
15
|
+
);
|
|
@@ -12,10 +12,16 @@ import {
|
|
|
12
12
|
categoriesCommand,
|
|
13
13
|
listCommand,
|
|
14
14
|
lookupCommand,
|
|
15
|
+
sampleCommand,
|
|
15
16
|
} from "./commands/index.js";
|
|
16
17
|
|
|
17
18
|
export function commands(ctx: PragmaContext): CommandDefinition[] {
|
|
18
|
-
return [
|
|
19
|
+
return [
|
|
20
|
+
listCommand(ctx),
|
|
21
|
+
lookupCommand(ctx),
|
|
22
|
+
categoriesCommand(ctx),
|
|
23
|
+
sampleCommand(ctx),
|
|
24
|
+
];
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
export { specs as mcpSpecs } from "./mcp/index.js";
|
|
@@ -23,6 +29,7 @@ export {
|
|
|
23
29
|
listCategories,
|
|
24
30
|
listStandards,
|
|
25
31
|
lookupStandard,
|
|
32
|
+
sampleStandards,
|
|
26
33
|
} from "./operations/index.js";
|
|
27
34
|
export {
|
|
28
35
|
buildStandardFilters,
|
|
@@ -1,49 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP tool specs for the standard domain
|
|
2
|
+
* MCP tool specs for the standard domain — standard_list, standard_lookup,
|
|
3
|
+
* standard_categories, standard_sample.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* The list and lookup tools are compiled from the standard read stories in
|
|
6
|
+
* `../stories.ts`; categories and sample are spec'd by hand. The adapter
|
|
7
|
+
* layer converts these into registered MCP tools via `registerFromSpec()`.
|
|
6
8
|
*/
|
|
7
9
|
|
|
10
|
+
import {
|
|
11
|
+
compileLookupTool,
|
|
12
|
+
compileReadTool,
|
|
13
|
+
condense,
|
|
14
|
+
} from "../../shared/stories/index.js";
|
|
8
15
|
import type { ToolSpec } from "../../shared/ToolSpec.js";
|
|
9
16
|
import {
|
|
10
|
-
type StandardListOutput,
|
|
11
17
|
categoriesFormatters as standardCatFmt,
|
|
12
|
-
|
|
13
|
-
lookupFormatters as standardLookupFmt,
|
|
18
|
+
sampleFormatters as standardSampleFmt,
|
|
14
19
|
} from "../formatters/index.js";
|
|
15
|
-
import { listCategories } from "../operations/index.js";
|
|
16
|
-
import {
|
|
17
|
-
resolveStandardList,
|
|
18
|
-
resolveStandardLookup,
|
|
19
|
-
} from "../orchestration/index.js";
|
|
20
|
+
import { listCategories, sampleStandards } from "../operations/index.js";
|
|
21
|
+
import { standardListStory, standardLookupStory } from "../stories.js";
|
|
20
22
|
|
|
21
23
|
const specs: readonly ToolSpec[] = [
|
|
24
|
+
compileReadTool(standardListStory),
|
|
25
|
+
compileLookupTool(standardLookupStory),
|
|
22
26
|
{
|
|
23
|
-
name: "
|
|
24
|
-
description:
|
|
25
|
-
"List code standards. Optionally filter by category or search term. Use digest/detailed for progressive disclosure.",
|
|
27
|
+
name: "standard_categories",
|
|
28
|
+
description: "List all code standard categories.",
|
|
26
29
|
params: {
|
|
27
|
-
category: {
|
|
28
|
-
type: "string",
|
|
29
|
-
description: "Filter by category name",
|
|
30
|
-
optional: true,
|
|
31
|
-
},
|
|
32
|
-
search: {
|
|
33
|
-
type: "string",
|
|
34
|
-
description: "Search in name and description",
|
|
35
|
-
optional: true,
|
|
36
|
-
},
|
|
37
|
-
digest: {
|
|
38
|
-
type: "boolean",
|
|
39
|
-
description: "Show description and first example for each standard",
|
|
40
|
-
optional: true,
|
|
41
|
-
},
|
|
42
|
-
detailed: {
|
|
43
|
-
type: "boolean",
|
|
44
|
-
description: "Show full dos/donts for each standard",
|
|
45
|
-
optional: true,
|
|
46
|
-
},
|
|
47
30
|
condensed: {
|
|
48
31
|
type: "boolean",
|
|
49
32
|
description: "Token-optimized output",
|
|
@@ -51,59 +34,24 @@ const specs: readonly ToolSpec[] = [
|
|
|
51
34
|
},
|
|
52
35
|
},
|
|
53
36
|
readOnly: true,
|
|
54
|
-
async execute(rt, {
|
|
55
|
-
const
|
|
56
|
-
category: category as string | undefined,
|
|
57
|
-
search: search as string | undefined,
|
|
58
|
-
digest: digest === true,
|
|
59
|
-
detailed: detailed === true,
|
|
60
|
-
});
|
|
61
|
-
const output: StandardListOutput = {
|
|
62
|
-
items: resolution.items,
|
|
63
|
-
details: resolution.details,
|
|
64
|
-
disclosure: resolution.disclosure,
|
|
65
|
-
};
|
|
37
|
+
async execute(rt, { condensed }) {
|
|
38
|
+
const result = await listCategories(rt.store);
|
|
66
39
|
|
|
67
40
|
if (condensed) {
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
condensed: true,
|
|
71
|
-
text,
|
|
72
|
-
tokens: `~${Math.ceil(text.length / 4)}`,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (resolution.disclosure.level === "summary") {
|
|
77
|
-
return {
|
|
78
|
-
data: resolution.items,
|
|
79
|
-
meta: { count: resolution.items.length },
|
|
80
|
-
};
|
|
41
|
+
return condense(standardCatFmt.llm(result));
|
|
81
42
|
}
|
|
82
43
|
|
|
83
|
-
return {
|
|
84
|
-
data: JSON.parse(standardListFmt.json(output)),
|
|
85
|
-
meta: {
|
|
86
|
-
count: resolution.items.length,
|
|
87
|
-
disclosure: resolution.disclosure.level,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
44
|
+
return { data: result, meta: { count: result.length } };
|
|
90
45
|
},
|
|
91
46
|
},
|
|
92
|
-
|
|
93
47
|
{
|
|
94
|
-
name: "
|
|
48
|
+
name: "standard_sample",
|
|
95
49
|
description:
|
|
96
|
-
"
|
|
50
|
+
"Return 1–5 randomly selected complete code standard instances as exemplars. Use BEFORE writing queries to see actual data shapes, property names, and value formats. Each call returns different instances.",
|
|
97
51
|
params: {
|
|
98
|
-
|
|
99
|
-
type: "string
|
|
100
|
-
description: "
|
|
101
|
-
optional: false,
|
|
102
|
-
},
|
|
103
|
-
detailed: {
|
|
104
|
-
type: "boolean",
|
|
105
|
-
description:
|
|
106
|
-
"Return full details with dos/donts (default: true for MCP)",
|
|
52
|
+
count: {
|
|
53
|
+
type: "string",
|
|
54
|
+
description: "Number of samples (1–5, default 2)",
|
|
107
55
|
optional: true,
|
|
108
56
|
},
|
|
109
57
|
condensed: {
|
|
@@ -113,85 +61,29 @@ const specs: readonly ToolSpec[] = [
|
|
|
113
61
|
},
|
|
114
62
|
},
|
|
115
63
|
readOnly: true,
|
|
116
|
-
async execute(rt, {
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
const
|
|
64
|
+
async execute(rt, { count, condensed }) {
|
|
65
|
+
const n = Number(count ?? 2);
|
|
66
|
+
const result = await sampleStandards(rt.store, n);
|
|
67
|
+
const nextSteps = [
|
|
68
|
+
`These are ${result.samples.length} of ${result.totalCount} total standards.`,
|
|
69
|
+
"Use standard_lookup to inspect specific standards by name.",
|
|
70
|
+
"Use standard_list with category param to filter by category.",
|
|
71
|
+
];
|
|
120
72
|
|
|
121
73
|
if (condensed) {
|
|
122
|
-
|
|
123
|
-
standardLookupFmt.llm({
|
|
124
|
-
standard,
|
|
125
|
-
detailed: showDetailed,
|
|
126
|
-
}),
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
if (result.errors.length > 0) {
|
|
130
|
-
textParts.push(
|
|
131
|
-
[
|
|
132
|
-
"### Errors",
|
|
133
|
-
...result.errors.map(
|
|
134
|
-
(error) => `- ${error.query}: ${error.message}`,
|
|
135
|
-
),
|
|
136
|
-
].join("\n"),
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const text = textParts.join("\n\n");
|
|
141
|
-
return {
|
|
142
|
-
condensed: true,
|
|
143
|
-
text,
|
|
144
|
-
tokens: `~${Math.ceil(text.length / 4)}`,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (!showDetailed) {
|
|
149
|
-
return {
|
|
150
|
-
data: {
|
|
151
|
-
results: result.results.map(
|
|
152
|
-
({ uri, name, category, description }) => ({
|
|
153
|
-
uri,
|
|
154
|
-
name,
|
|
155
|
-
category,
|
|
156
|
-
description,
|
|
157
|
-
}),
|
|
158
|
-
),
|
|
159
|
-
errors: result.errors,
|
|
160
|
-
},
|
|
161
|
-
meta: { count: result.results.length },
|
|
162
|
-
};
|
|
74
|
+
return condense(standardSampleFmt.llm({ ...result, nextSteps }));
|
|
163
75
|
}
|
|
164
76
|
|
|
165
|
-
return {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
condensed: {
|
|
174
|
-
type: "boolean",
|
|
175
|
-
description: "Token-optimized output",
|
|
176
|
-
optional: true,
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
readOnly: true,
|
|
180
|
-
async execute(rt, { condensed }) {
|
|
181
|
-
const result = await listCategories(rt.store);
|
|
182
|
-
|
|
183
|
-
if (condensed) {
|
|
184
|
-
const text = standardCatFmt.llm(result);
|
|
185
|
-
return {
|
|
186
|
-
condensed: true,
|
|
187
|
-
text,
|
|
188
|
-
tokens: `~${Math.ceil(text.length / 4)}`,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return { data: result, meta: { count: result.length } };
|
|
77
|
+
return {
|
|
78
|
+
data: {
|
|
79
|
+
samples: result.samples,
|
|
80
|
+
totalCount: result.totalCount,
|
|
81
|
+
nextSteps,
|
|
82
|
+
},
|
|
83
|
+
meta: { count: result.samples.length },
|
|
84
|
+
};
|
|
193
85
|
},
|
|
194
86
|
},
|
|
195
|
-
];
|
|
87
|
+
] as const;
|
|
196
88
|
|
|
197
89
|
export default specs;
|