@canonical/pragma-cli 0.30.0 → 0.31.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 +64 -35
- package/dist/pragma +0 -0
- package/package.json +15 -13
- package/src/completions/constants.ts +7 -0
- package/src/completions/handleQuery.test.ts +32 -0
- package/src/completions/handleQuery.ts +20 -1
- package/src/completions/queryCompletions.test.ts +5 -0
- package/src/completions/queryCompletions.ts +17 -3
- package/src/completions/querySocket.test.ts +31 -0
- package/src/completions/querySocket.ts +36 -9
- package/src/config/parseConfigValues.ts +2 -0
- package/src/config/readConfigLayers.test.ts +2 -0
- package/src/config/readConfigLayers.ts +3 -0
- package/src/config/types.ts +7 -0
- package/src/constants.ts +3 -1
- package/src/domains/block/commands/sample.ts +2 -1
- package/src/domains/block/formatters/list.test.ts +3 -3
- package/src/domains/block/formatters/lookup.test.ts +5 -5
- package/src/domains/block/orchestration/enrichBlocks.ts +6 -3
- package/src/domains/block/stories.ts +9 -3
- package/src/domains/config/commands/channel.test.ts +16 -0
- package/src/domains/config/commands/channel.ts +14 -1
- package/src/domains/config/commands/framework.test.ts +14 -0
- package/src/domains/config/commands/framework.ts +13 -1
- package/src/domains/config/commands/tier.test.ts +7 -0
- package/src/domains/config/commands/tier.ts +14 -1
- package/src/domains/config/operations/validateTier.test.ts +9 -0
- package/src/domains/config/operations/validateTier.ts +10 -2
- package/src/domains/create/generatorPack/bundled.ts +49 -0
- package/src/domains/create/generatorPack/compileGeneratorPack.test.ts +159 -0
- package/src/domains/create/generatorPack/compileGeneratorPack.ts +312 -0
- package/src/domains/create/index.ts +13 -7
- package/src/domains/create/mcp/specs.ts +6 -161
- package/src/domains/create/renderGeneratorUi.test.ts +103 -0
- package/src/domains/create/renderGeneratorUi.ts +65 -0
- package/src/domains/doctor/formatters/doctor.test.ts +50 -2
- package/src/domains/doctor/formatters/doctor.ts +90 -38
- package/src/domains/doctor/operations/checks/checkMcpCommands.ts +9 -6
- package/src/domains/doctor/operations/checks/checkPackageRefs.ts +30 -12
- package/src/domains/doctor/operations/checks.test.ts +6 -4
- package/src/domains/doctor/operations/types.ts +23 -1
- package/src/domains/graph/commands/inspect.test.ts +2 -2
- package/src/domains/graph/commands/query.test.ts +5 -3
- package/src/domains/graph/formatters/inspect.ts +7 -7
- package/src/domains/graph/formatters/query.test.ts +87 -0
- package/src/domains/graph/formatters/query.ts +42 -5
- package/src/domains/graph/operations/inspectUri.test.ts +5 -5
- package/src/domains/graphql/commands/serve.test.ts +12 -6
- package/src/domains/graphql/commands/serve.ts +16 -6
- package/src/domains/graphql/helpers/parsePrefixes.test.ts +3 -3
- package/src/domains/graphql/helpers/parsePrefixes.ts +3 -3
- package/src/domains/graphql/helpers/resolveSourceFiles.test.ts +9 -0
- package/src/domains/graphql/helpers/resolveSourceFiles.ts +24 -3
- package/src/domains/graphql/operations/compileSchema.test.ts +2 -2
- package/src/domains/graphql/operations/createSchemaServer.test.ts +2 -2
- package/src/domains/graphql/operations/ensureSchemaArtifact.test.ts +167 -0
- package/src/domains/graphql/operations/ensureSchemaArtifact.ts +178 -0
- package/src/domains/graphql/operations/index.ts +5 -0
- package/src/domains/info/formatters/upgrade.test.ts +7 -4
- package/src/domains/info/formatters/upgrade.ts +3 -1
- package/src/domains/info/operations/collectEntityCounts.test.ts +156 -0
- package/src/domains/info/operations/collectEntityCounts.ts +123 -0
- package/src/domains/info/operations/index.ts +1 -0
- package/src/domains/info/types.ts +13 -0
- package/src/domains/llm/capabilities.test.ts +23 -3
- package/src/domains/llm/commands/capabilities.ts +12 -3
- package/src/domains/llm/commands/llm.ts +5 -1
- package/src/domains/llm/data/commandReference.ts +20 -11
- package/src/domains/llm/data/decisionTrees.ts +10 -5
- package/src/domains/llm/data/toolCatalog.ts +49 -18
- package/src/domains/llm/formatters/orientation.ts +5 -1
- package/src/domains/llm/llmCommand.test.ts +11 -3
- package/src/domains/llm/mcp/specs.ts +3 -4
- package/src/domains/llm/operations/collectContext.test.ts +64 -0
- package/src/domains/llm/operations/collectContext.ts +7 -17
- package/src/domains/modifier/commands/sample.ts +2 -1
- package/src/domains/modifier/operations/lookup.ts +5 -3
- package/src/domains/modifier/stories.ts +9 -0
- package/src/domains/ontology/commands/list.test.ts +5 -3
- package/src/domains/ontology/commands/show.test.ts +85 -9
- package/src/domains/ontology/formatters/index.ts +1 -0
- package/src/domains/ontology/formatters/list.ts +37 -12
- package/src/domains/ontology/formatters/show.ts +358 -67
- package/src/domains/ontology/helpers/buildClassTree.ts +89 -0
- package/src/domains/ontology/helpers/completeClassNames.ts +43 -0
- package/src/domains/ontology/helpers/expandOntologyIris.ts +79 -0
- package/src/domains/ontology/helpers/index.ts +14 -0
- package/src/domains/ontology/helpers/queryClasses.ts +32 -16
- package/src/domains/ontology/helpers/queryProperties.ts +39 -6
- package/src/domains/ontology/helpers/queryTboxFacts.ts +160 -0
- package/src/domains/ontology/operations/listOntologies.test.ts +80 -3
- package/src/domains/ontology/operations/listOntologies.ts +126 -30
- package/src/domains/ontology/operations/showOntology.test.ts +131 -12
- package/src/domains/ontology/operations/showOntology.ts +289 -7
- package/src/domains/ontology/operations/showOntologyRaw.test.ts +4 -2
- package/src/domains/ontology/stories.ts +53 -8
- package/src/domains/refs/operations/updateRefs.ts +0 -1
- package/src/domains/setup/commands/index.ts +1 -0
- package/src/domains/setup/commands/setup.ts +70 -0
- package/src/domains/setup/index.ts +7 -3
- package/src/domains/setup/operations/setupLsp.test.ts +3 -2
- package/src/domains/setup/operations/setupLsp.ts +7 -2
- package/src/domains/shared/bootStore.bareCore.test.ts +63 -0
- package/src/domains/shared/bootStore.test.ts +82 -0
- package/src/domains/shared/bootStore.ts +56 -20
- package/src/domains/shared/emptyErrorRecovery.test.ts +23 -26
- package/src/domains/shared/extractLocalName.test.ts +3 -3
- package/src/domains/shared/formatters.ts +23 -2
- package/src/domains/shared/listTiers.ts +40 -0
- package/src/domains/shared/loaders/bundledLoader.ts +48 -0
- package/src/domains/shared/loaders/gitLoader.ts +1 -2
- package/src/domains/shared/loaders/localLoader.ts +2 -18
- package/src/domains/shared/loaders/readPackageDir.test.ts +58 -0
- package/src/domains/shared/loaders/readPackageDir.ts +46 -8
- package/src/domains/shared/lookupMany.test.ts +15 -0
- package/src/domains/shared/lookupMany.ts +22 -6
- package/src/domains/shared/namespaces.ts +13 -5
- package/src/domains/shared/parseSampleCount.test.ts +47 -0
- package/src/domains/shared/parseSampleCount.ts +45 -0
- package/src/domains/shared/prefixes.test.ts +211 -0
- package/src/domains/shared/prefixes.ts +182 -15
- package/src/domains/shared/renderers.ts +5 -5
- package/src/domains/shared/resolveLookupExitCode.test.ts +48 -0
- package/src/domains/shared/resolveLookupExitCode.ts +42 -0
- package/src/domains/shared/semanticPackage.test.ts +89 -0
- package/src/domains/shared/semanticPackage.ts +17 -2
- package/src/domains/shared/stories/compileLookupCommand.ts +3 -1
- package/src/domains/shared/stories/compileLookupTool.ts +1 -1
- package/src/domains/shared/stories/pack/applyPackFilters.test.ts +49 -0
- package/src/domains/shared/stories/pack/applyPackFilters.ts +46 -11
- package/src/domains/shared/stories/pack/applyPackSearch.test.ts +57 -0
- package/src/domains/shared/stories/pack/applyPackSearch.ts +41 -0
- package/src/domains/shared/stories/pack/buildLookupQuery.test.ts +30 -0
- package/src/domains/shared/stories/pack/buildLookupQuery.ts +75 -1
- package/src/domains/shared/stories/pack/bundled/index.ts +23 -0
- package/src/domains/shared/stories/pack/bundled/standardPack.ts +164 -0
- package/src/domains/shared/stories/pack/bundled/tierPack.ts +50 -0
- package/src/domains/shared/stories/pack/collectPackStories.test.ts +305 -7
- package/src/domains/shared/stories/pack/collectPackStories.ts +90 -8
- package/src/domains/shared/stories/pack/compilePackCommands.ts +17 -7
- package/src/domains/shared/stories/pack/compilePackStories.test.ts +607 -2
- package/src/domains/shared/stories/pack/compilePackStories.ts +544 -73
- package/src/domains/shared/stories/pack/compilePackToolSpecs.ts +20 -8
- package/src/domains/shared/stories/pack/index.ts +14 -0
- package/src/domains/shared/stories/pack/reservedVerbs.test.ts +213 -0
- package/src/domains/shared/stories/pack/reservedVerbs.ts +170 -0
- package/src/domains/shared/stories/pack/standardParity.test.ts +293 -220
- package/src/domains/shared/stories/pack/types.ts +123 -3
- package/src/domains/shared/stories/pack/validateStoryPackDefinition.test.ts +502 -0
- package/src/domains/shared/stories/pack/validateStoryPackDefinition.ts +475 -24
- package/src/domains/shared/stories/types.ts +9 -1
- package/src/domains/shared/types/index.ts +5 -9
- package/src/domains/shared/types/ontology.ts +119 -24
- package/src/domains/shared/types/standard.ts +9 -52
- package/src/domains/token/commands/lookup.test.ts +8 -0
- package/src/domains/token/commands/lookup.ts +12 -0
- package/src/domains/token/commands/sample.ts +2 -1
- package/src/domains/token/featureFlag.ts +17 -0
- package/src/domains/token/index.ts +5 -0
- package/src/domains/token/mcp/specs.ts +13 -1
- package/src/domains/trace/commands/resolveTraceLimit.test.ts +31 -0
- package/src/domains/trace/commands/show.ts +30 -4
- package/src/index.ts +1 -13
- package/src/mcp/registerResources.test.ts +2 -2
- package/src/mcp/resources/pickPrimaryType.test.ts +5 -5
- package/src/mcp/tools/index.ts +18 -10
- package/src/mcp/tools/registerTools.test.ts +106 -30
- package/src/pipeline/collectCommands.test.ts +151 -1
- package/src/pipeline/collectCommands.ts +34 -19
- package/src/pipeline/createProgram.test.ts +5 -1
- package/src/pipeline/createProgram.ts +2 -2
- package/src/pipeline/firstRun.test.ts +80 -0
- package/src/pipeline/firstRun.ts +99 -0
- package/src/pipeline/parseGlobalFlags.test.ts +102 -1
- package/src/pipeline/parseGlobalFlags.ts +98 -9
- package/src/pipeline/resolveCommandKind.test.ts +12 -0
- package/src/pipeline/resolveCommandKind.ts +4 -0
- package/src/pipeline/rootHelp.test.ts +87 -0
- package/src/pipeline/rootHelp.ts +265 -0
- package/src/pipeline/runCli.orchestration.test.ts +28 -12
- package/src/pipeline/runCli.test.ts +17 -4
- package/src/pipeline/runCli.ts +162 -19
- package/src/testing/cli.ts +30 -2
- package/src/testing/dsFixtures.ts +21 -4
- package/src/testing/index.ts +1 -4
- package/src/testing/integration/__snapshots__/executor-golden.test.ts.snap +4 -4
- package/src/testing/integration/cli-user-stories.test.ts +63 -0
- package/src/testing/integration/cross-binary-byte-equality.test.ts +2 -2
- package/src/testing/integration/edge-cases.test.ts +62 -50
- package/src/testing/integration/executor-execution.test.ts +6 -4
- package/src/testing/integration/executor-golden.test.ts +2 -2
- package/src/testing/integration/mcp-surface.test.ts +40 -15
- package/src/testing/integration/parity.test.ts +119 -70
- package/src/testing/setupXdgIsolation.ts +16 -5
- package/src/testing/standardParityFixtures.ts +26 -83
- package/src/testing/store.ts +4 -4
- package/src/domains/create/commands/component.test.ts +0 -166
- package/src/domains/create/commands/component.ts +0 -123
- package/src/domains/create/commands/index.ts +0 -3
- package/src/domains/create/commands/package.test.ts +0 -35
- package/src/domains/create/commands/package.ts +0 -21
- package/src/domains/create/generators.ts +0 -8
- package/src/domains/standard/commands/categories.test.ts +0 -70
- package/src/domains/standard/commands/categories.ts +0 -48
- package/src/domains/standard/commands/index.ts +0 -6
- package/src/domains/standard/commands/list.test.ts +0 -105
- package/src/domains/standard/commands/list.ts +0 -11
- package/src/domains/standard/commands/lookup.test.ts +0 -135
- package/src/domains/standard/commands/lookup.ts +0 -14
- package/src/domains/standard/commands/sample.ts +0 -57
- package/src/domains/standard/formatters/categories.test.ts +0 -44
- package/src/domains/standard/formatters/categories.ts +0 -38
- package/src/domains/standard/formatters/index.ts +0 -10
- package/src/domains/standard/formatters/list.test.ts +0 -169
- package/src/domains/standard/formatters/list.ts +0 -184
- package/src/domains/standard/formatters/lookup.test.ts +0 -95
- package/src/domains/standard/formatters/lookup.ts +0 -101
- package/src/domains/standard/formatters/sample.ts +0 -15
- package/src/domains/standard/formatters/types.ts +0 -31
- package/src/domains/standard/index.ts +0 -40
- package/src/domains/standard/mcp/index.ts +0 -2
- package/src/domains/standard/mcp/specs.ts +0 -89
- package/src/domains/standard/operations/categories.test.ts +0 -61
- package/src/domains/standard/operations/categories.ts +0 -38
- package/src/domains/standard/operations/index.ts +0 -6
- package/src/domains/standard/operations/list.test.ts +0 -75
- package/src/domains/standard/operations/list.ts +0 -64
- package/src/domains/standard/operations/lookup.test.ts +0 -58
- package/src/domains/standard/operations/lookup.ts +0 -151
- package/src/domains/standard/operations/sample.ts +0 -35
- package/src/domains/standard/orchestration/buildStandardFilters.ts +0 -11
- package/src/domains/standard/orchestration/index.ts +0 -4
- package/src/domains/standard/orchestration/resolveStandardList.ts +0 -45
- package/src/domains/standard/orchestration/resolveStandardLookup.ts +0 -33
- package/src/domains/standard/orchestration/standardEmptyError.test.ts +0 -33
- package/src/domains/standard/orchestration/standardEmptyError.ts +0 -29
- package/src/domains/standard/standardConfig.ts +0 -42
- package/src/domains/standard/stories.test.ts +0 -24
- package/src/domains/standard/stories.ts +0 -151
- package/src/domains/standard/types.ts +0 -15
- package/src/domains/tier/commands/index.ts +0 -3
- package/src/domains/tier/commands/list.test.ts +0 -67
- package/src/domains/tier/commands/list.ts +0 -9
- package/src/domains/tier/formatters/index.ts +0 -3
- package/src/domains/tier/formatters/list.test.ts +0 -33
- package/src/domains/tier/formatters/list.ts +0 -45
- package/src/domains/tier/index.ts +0 -17
- package/src/domains/tier/mcp/index.ts +0 -2
- package/src/domains/tier/mcp/specs.ts +0 -12
- package/src/domains/tier/operations/index.ts +0 -3
- package/src/domains/tier/operations/list.test.ts +0 -32
- package/src/domains/tier/operations/list.ts +0 -33
- package/src/domains/tier/stories.test.ts +0 -22
- package/src/domains/tier/stories.ts +0 -52
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type CommandDefinition,
|
|
3
|
-
executeGenerator,
|
|
4
|
-
type ParameterDefinition,
|
|
5
|
-
promptToParameter,
|
|
6
|
-
} from "@canonical/cli-core";
|
|
7
|
-
import { generators } from "@canonical/summon-component";
|
|
8
|
-
import { PragmaError } from "#error";
|
|
9
|
-
import { COMPONENT_GENERATORS } from "../generators.js";
|
|
10
|
-
|
|
11
|
-
const FRAMEWORK_CHOICES = [
|
|
12
|
-
{ label: "react", value: "react" },
|
|
13
|
-
{ label: "svelte", value: "svelte" },
|
|
14
|
-
{ label: "lit", value: "lit" },
|
|
15
|
-
] as const;
|
|
16
|
-
|
|
17
|
-
/** Reference generator used to derive shared prompt parameters. */
|
|
18
|
-
const referenceGenerator = generators["component/react"];
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Build the `pragma create component` command definition.
|
|
22
|
-
*
|
|
23
|
-
* Uses a dispatch pattern: `framework` is a required positional select
|
|
24
|
-
* parameter. The execute function looks up the matching generator and
|
|
25
|
-
* delegates to `executeGenerator` from cli-core.
|
|
26
|
-
*
|
|
27
|
-
* @returns The command definition for `pragma create component`.
|
|
28
|
-
* @note Impure
|
|
29
|
-
*/
|
|
30
|
-
export default function buildComponentCommand(): CommandDefinition {
|
|
31
|
-
const frameworkParam: ParameterDefinition = {
|
|
32
|
-
name: "framework",
|
|
33
|
-
description: "Component framework (react, svelte, lit)",
|
|
34
|
-
type: "select",
|
|
35
|
-
choices: [...FRAMEWORK_CHOICES],
|
|
36
|
-
positional: true,
|
|
37
|
-
required: true,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// Derive prompt parameters from the reference generator
|
|
41
|
-
const promptParams = referenceGenerator.prompts.map(promptToParameter);
|
|
42
|
-
|
|
43
|
-
// Execution-mode parameters (same as generatorToCommand appends)
|
|
44
|
-
const execParams: ParameterDefinition[] = [
|
|
45
|
-
{
|
|
46
|
-
name: "dryRun",
|
|
47
|
-
description: "Preview without writing files",
|
|
48
|
-
type: "boolean",
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "undo",
|
|
52
|
-
description: "Reverse a previously generated component",
|
|
53
|
-
type: "boolean",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: "yes",
|
|
57
|
-
description: "Skip confirmation prompts",
|
|
58
|
-
type: "boolean",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: "showFiles",
|
|
62
|
-
description: "Show file contents in dry-run",
|
|
63
|
-
type: "boolean",
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "preview",
|
|
67
|
-
description: "Show file preview before writing",
|
|
68
|
-
type: "boolean",
|
|
69
|
-
default: true,
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: "generatedStamp",
|
|
73
|
-
description: "Add generated file stamps",
|
|
74
|
-
type: "boolean",
|
|
75
|
-
default: true,
|
|
76
|
-
},
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
const parameters = [frameworkParam, ...promptParams, ...execParams];
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
path: ["create", "component"],
|
|
83
|
-
description:
|
|
84
|
-
"Generate a component with TypeScript, tests, stories, and styles",
|
|
85
|
-
parameters,
|
|
86
|
-
execute: async (params, ctx) => {
|
|
87
|
-
const framework = params.framework as string | undefined;
|
|
88
|
-
if (!framework) {
|
|
89
|
-
throw PragmaError.invalidInput("framework", "(missing)", {
|
|
90
|
-
validOptions: ["react", "svelte", "lit"],
|
|
91
|
-
recovery: {
|
|
92
|
-
message: "Provide a framework for component generation.",
|
|
93
|
-
cli: "pragma create component react src/components/Button",
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const gen = COMPONENT_GENERATORS[framework];
|
|
99
|
-
if (!gen) {
|
|
100
|
-
throw PragmaError.invalidInput("framework", framework, {
|
|
101
|
-
validOptions: Object.keys(COMPONENT_GENERATORS),
|
|
102
|
-
recovery: {
|
|
103
|
-
message: `Valid frameworks: ${Object.keys(COMPONENT_GENERATORS).join(", ")}`,
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return executeGenerator(gen, params, ctx);
|
|
109
|
-
},
|
|
110
|
-
meta: {
|
|
111
|
-
examples: [
|
|
112
|
-
"pragma create component react src/components/Button",
|
|
113
|
-
"pragma create component svelte src/lib/components/Toggle",
|
|
114
|
-
"pragma create component lit src/lib/Accordion",
|
|
115
|
-
"pragma create component react src/components/Button --dry-run",
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
parameterGroups: {
|
|
119
|
-
Component: ["componentPath"],
|
|
120
|
-
Options: ["withStyles", "withStories", "withSsrTests"],
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { CommandContext } from "@canonical/cli-core";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import buildPackageCommand from "./package.js";
|
|
4
|
-
|
|
5
|
-
const ctx: CommandContext = {
|
|
6
|
-
cwd: "/tmp",
|
|
7
|
-
globalFlags: { llm: false, format: "text" as const, verbose: false },
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
describe("buildPackageCommand", () => {
|
|
11
|
-
it("has correct path", () => {
|
|
12
|
-
const cmd = buildPackageCommand();
|
|
13
|
-
expect(cmd.path).toEqual(["create", "package"]);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("dry-run with all params returns output", async () => {
|
|
17
|
-
const cmd = buildPackageCommand();
|
|
18
|
-
const result = await cmd.execute(
|
|
19
|
-
{
|
|
20
|
-
name: "@canonical/test-pkg",
|
|
21
|
-
type: "tool-ts",
|
|
22
|
-
dryRun: true,
|
|
23
|
-
yes: true,
|
|
24
|
-
},
|
|
25
|
-
ctx,
|
|
26
|
-
);
|
|
27
|
-
expect(result.tag).toBe("output");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("with missing required params returns batch output outside a TTY", async () => {
|
|
31
|
-
const cmd = buildPackageCommand();
|
|
32
|
-
const result = await cmd.execute({}, ctx);
|
|
33
|
-
expect(result.tag).toBe("output");
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type CommandDefinition,
|
|
3
|
-
generatorToCommand,
|
|
4
|
-
} from "@canonical/cli-core";
|
|
5
|
-
import { generators as packageGenerators } from "@canonical/summon-package";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Build the `pragma create package` command definition by bridging
|
|
9
|
-
* the package generator via `generatorToCommand`.
|
|
10
|
-
*
|
|
11
|
-
* @returns The command definition for `pragma create package`.
|
|
12
|
-
* @throws Error if the package generator is not found.
|
|
13
|
-
* @note Impure
|
|
14
|
-
*/
|
|
15
|
-
export default function buildPackageCommand(): CommandDefinition {
|
|
16
|
-
const gen = packageGenerators.package;
|
|
17
|
-
if (!gen) {
|
|
18
|
-
throw new Error("Package generator not found in @canonical/summon-package");
|
|
19
|
-
}
|
|
20
|
-
return generatorToCommand(["create", "package"], gen);
|
|
21
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { generators } from "@canonical/summon-component";
|
|
2
|
-
import type { AnyGenerator } from "@canonical/summon-core";
|
|
3
|
-
|
|
4
|
-
export const COMPONENT_GENERATORS: Record<string, AnyGenerator> = {
|
|
5
|
-
react: generators["component/react"],
|
|
6
|
-
svelte: generators["component/svelte"],
|
|
7
|
-
lit: generators["component/lit"],
|
|
8
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { CommandDefinition } from "@canonical/cli-core";
|
|
2
|
-
import type { Store } from "@canonical/ke";
|
|
3
|
-
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
4
|
-
import { createTestStore, DS_ALL_TTL } from "#testing";
|
|
5
|
-
import type { PragmaContext } from "../../shared/context.js";
|
|
6
|
-
import buildCategoriesCommand from "./categories.js";
|
|
7
|
-
|
|
8
|
-
let store: Store;
|
|
9
|
-
let cleanup: () => void;
|
|
10
|
-
|
|
11
|
-
beforeAll(async () => {
|
|
12
|
-
const result = await createTestStore({ ttl: DS_ALL_TTL });
|
|
13
|
-
store = result.store;
|
|
14
|
-
cleanup = result.cleanup;
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
afterAll(() => cleanup());
|
|
18
|
-
|
|
19
|
-
function makeCtx(overrides: Partial<PragmaContext> = {}): PragmaContext {
|
|
20
|
-
return {
|
|
21
|
-
cwd: "/tmp",
|
|
22
|
-
globalFlags: { llm: false, format: "text" as const, verbose: false },
|
|
23
|
-
store,
|
|
24
|
-
config: { tier: undefined, channel: "prerelease" },
|
|
25
|
-
...overrides,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function executeOutput(
|
|
30
|
-
cmd: CommandDefinition,
|
|
31
|
-
params: Record<string, unknown>,
|
|
32
|
-
ctx: PragmaContext,
|
|
33
|
-
): Promise<{ value: unknown; text: string }> {
|
|
34
|
-
const result = await cmd.execute(params, ctx);
|
|
35
|
-
expect(result.tag).toBe("output");
|
|
36
|
-
if (result.tag !== "output") throw new Error("Expected output result");
|
|
37
|
-
const text = result.render.plain(result.value);
|
|
38
|
-
return { value: result.value, text };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
describe("buildCategoriesCommand", () => {
|
|
42
|
-
it("returns categories with counts", async () => {
|
|
43
|
-
const ctx = makeCtx();
|
|
44
|
-
const cmd = buildCategoriesCommand(ctx);
|
|
45
|
-
const { text } = await executeOutput(cmd, {}, ctx);
|
|
46
|
-
expect(text).toContain("react (2 standards)");
|
|
47
|
-
expect(text).toContain("code (1 standard)");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("renders LLM format with --llm", async () => {
|
|
51
|
-
const ctx = makeCtx({
|
|
52
|
-
globalFlags: { llm: true, format: "text" as const, verbose: false },
|
|
53
|
-
});
|
|
54
|
-
const cmd = buildCategoriesCommand(ctx);
|
|
55
|
-
const { text } = await executeOutput(cmd, {}, ctx);
|
|
56
|
-
expect(text).toContain("## Standard Categories");
|
|
57
|
-
expect(text).toContain("**react**");
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("renders JSON output", async () => {
|
|
61
|
-
const ctx = makeCtx({
|
|
62
|
-
globalFlags: { llm: false, format: "json" as const, verbose: false },
|
|
63
|
-
});
|
|
64
|
-
const cmd = buildCategoriesCommand(ctx);
|
|
65
|
-
const { text } = await executeOutput(cmd, {}, ctx);
|
|
66
|
-
const parsed = JSON.parse(text);
|
|
67
|
-
expect(Array.isArray(parsed)).toBe(true);
|
|
68
|
-
expect(parsed.some((c: { name: string }) => c.name === "react")).toBe(true);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wires the `pragma standard categories` CLI command.
|
|
3
|
-
*
|
|
4
|
-
* Lists all standard categories with their standard counts. Throws a
|
|
5
|
-
* structured recovery error when no categories are found.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
type CommandDefinition,
|
|
10
|
-
type CommandResult,
|
|
11
|
-
createOutputResult,
|
|
12
|
-
} from "@canonical/cli-core";
|
|
13
|
-
import { PragmaError } from "#error";
|
|
14
|
-
import type { PragmaContext } from "../../shared/context.js";
|
|
15
|
-
import { selectFormatter } from "../../shared/formatters.js";
|
|
16
|
-
import { categoriesFormatters } from "../formatters/index.js";
|
|
17
|
-
import { listCategories } from "../operations/index.js";
|
|
18
|
-
|
|
19
|
-
export default function buildCategoriesCommand(
|
|
20
|
-
ctx: PragmaContext,
|
|
21
|
-
): CommandDefinition {
|
|
22
|
-
return {
|
|
23
|
-
path: ["standard", "categories"],
|
|
24
|
-
description: "List all standard categories with counts",
|
|
25
|
-
parameters: [],
|
|
26
|
-
meta: {
|
|
27
|
-
examples: ["pragma standard categories"],
|
|
28
|
-
},
|
|
29
|
-
execute: async (
|
|
30
|
-
_params: Record<string, unknown>,
|
|
31
|
-
): Promise<CommandResult> => {
|
|
32
|
-
const categories = await listCategories(ctx.store);
|
|
33
|
-
|
|
34
|
-
if (categories.length === 0) {
|
|
35
|
-
throw PragmaError.emptyResults("categories", {
|
|
36
|
-
recovery: {
|
|
37
|
-
message:
|
|
38
|
-
"Ensure code standards packages are installed: bun add -D @canonical/code-standards",
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return createOutputResult(categories, {
|
|
44
|
-
plain: selectFormatter(ctx, categoriesFormatters),
|
|
45
|
-
});
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/** @module Re-exports standard command builders (`categories`, `list`, `lookup`, `sample`). */
|
|
2
|
-
|
|
3
|
-
export { default as categoriesCommand } from "./categories.js";
|
|
4
|
-
export { default as listCommand } from "./list.js";
|
|
5
|
-
export { default as lookupCommand } from "./lookup.js";
|
|
6
|
-
export { default as sampleCommand } from "./sample.js";
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type { CommandDefinition } from "@canonical/cli-core";
|
|
2
|
-
import type { Store } from "@canonical/ke";
|
|
3
|
-
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
4
|
-
import { PragmaError } from "#error";
|
|
5
|
-
import { createTestStore, DS_ALL_TTL } from "#testing";
|
|
6
|
-
import type { PragmaContext } from "../../shared/context.js";
|
|
7
|
-
import buildListCommand from "./list.js";
|
|
8
|
-
|
|
9
|
-
let store: Store;
|
|
10
|
-
let cleanup: () => void;
|
|
11
|
-
|
|
12
|
-
beforeAll(async () => {
|
|
13
|
-
const result = await createTestStore({ ttl: DS_ALL_TTL });
|
|
14
|
-
store = result.store;
|
|
15
|
-
cleanup = result.cleanup;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
afterAll(() => cleanup());
|
|
19
|
-
|
|
20
|
-
function makeCtx(overrides: Partial<PragmaContext> = {}): PragmaContext {
|
|
21
|
-
return {
|
|
22
|
-
cwd: "/tmp",
|
|
23
|
-
globalFlags: { llm: false, format: "text" as const, verbose: false },
|
|
24
|
-
store,
|
|
25
|
-
config: { tier: undefined, channel: "prerelease" },
|
|
26
|
-
...overrides,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function executeOutput(
|
|
31
|
-
cmd: CommandDefinition,
|
|
32
|
-
params: Record<string, unknown>,
|
|
33
|
-
ctx: PragmaContext,
|
|
34
|
-
): Promise<{ value: unknown; text: string }> {
|
|
35
|
-
const result = await cmd.execute(params, ctx);
|
|
36
|
-
expect(result.tag).toBe("output");
|
|
37
|
-
if (result.tag !== "output") throw new Error("Expected output result");
|
|
38
|
-
const text = result.render.plain(result.value);
|
|
39
|
-
return { value: result.value, text };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
describe("buildListCommand", () => {
|
|
43
|
-
it("returns output result with all standards", async () => {
|
|
44
|
-
const ctx = makeCtx();
|
|
45
|
-
const cmd = buildListCommand(ctx);
|
|
46
|
-
const { text } = await executeOutput(cmd, {}, ctx);
|
|
47
|
-
expect(text).toContain("react/component/folder-structure");
|
|
48
|
-
expect(text).toContain("react/component/props");
|
|
49
|
-
expect(text).toContain("code/function/purity");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("filters by --category", async () => {
|
|
53
|
-
const ctx = makeCtx();
|
|
54
|
-
const cmd = buildListCommand(ctx);
|
|
55
|
-
const { text } = await executeOutput(cmd, { category: "react" }, ctx);
|
|
56
|
-
expect(text).toContain("react/component/folder-structure");
|
|
57
|
-
expect(text).toContain("react/component/props");
|
|
58
|
-
expect(text).not.toContain("code/function/purity");
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("filters by --search", async () => {
|
|
62
|
-
const ctx = makeCtx();
|
|
63
|
-
const cmd = buildListCommand(ctx);
|
|
64
|
-
const { text } = await executeOutput(cmd, { search: "folder" }, ctx);
|
|
65
|
-
expect(text).toContain("react/component/folder-structure");
|
|
66
|
-
expect(text).not.toContain("code/function/purity");
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("throws EMPTY_RESULTS for non-matching filter", async () => {
|
|
70
|
-
const ctx = makeCtx();
|
|
71
|
-
const cmd = buildListCommand(ctx);
|
|
72
|
-
try {
|
|
73
|
-
await cmd.execute({ category: "nonexistent" }, ctx);
|
|
74
|
-
expect.fail("Should have thrown");
|
|
75
|
-
} catch (e) {
|
|
76
|
-
expect(e).toBeInstanceOf(PragmaError);
|
|
77
|
-
expect((e as PragmaError).code).toBe("EMPTY_RESULTS");
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("renders LLM format with --llm", async () => {
|
|
82
|
-
const ctx = makeCtx({
|
|
83
|
-
globalFlags: { llm: true, format: "text" as const, verbose: false },
|
|
84
|
-
});
|
|
85
|
-
const cmd = buildListCommand(ctx);
|
|
86
|
-
const { text } = await executeOutput(cmd, {}, ctx);
|
|
87
|
-
expect(text).toContain("## Standards");
|
|
88
|
-
expect(text).toContain("**react/component/folder-structure**");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("renders JSON output", async () => {
|
|
92
|
-
const ctx = makeCtx({
|
|
93
|
-
globalFlags: { llm: false, format: "json" as const, verbose: false },
|
|
94
|
-
});
|
|
95
|
-
const cmd = buildListCommand(ctx);
|
|
96
|
-
const { text } = await executeOutput(cmd, {}, ctx);
|
|
97
|
-
const parsed = JSON.parse(text);
|
|
98
|
-
expect(Array.isArray(parsed)).toBe(true);
|
|
99
|
-
expect(
|
|
100
|
-
parsed.some(
|
|
101
|
-
(s: { name: string }) => s.name === "react/component/folder-structure",
|
|
102
|
-
),
|
|
103
|
-
).toBe(true);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { CommandDefinition } from "@canonical/cli-core";
|
|
2
|
-
import type { PragmaContext } from "../../shared/context.js";
|
|
3
|
-
import { compileReadCommand } from "../../shared/stories/index.js";
|
|
4
|
-
import { standardListStory } from "../stories.js";
|
|
5
|
-
|
|
6
|
-
/** Wire the `pragma standard list` CLI command from the standard list story. */
|
|
7
|
-
export default function buildListCommand(
|
|
8
|
-
ctx: PragmaContext,
|
|
9
|
-
): CommandDefinition {
|
|
10
|
-
return compileReadCommand(ctx, standardListStory);
|
|
11
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import type { CommandDefinition } from "@canonical/cli-core";
|
|
2
|
-
import type { Store } from "@canonical/ke";
|
|
3
|
-
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
4
|
-
import { createTestStore, DS_ALL_TTL } from "#testing";
|
|
5
|
-
import type { PragmaContext } from "../../shared/context.js";
|
|
6
|
-
import buildLookupCommand from "./lookup.js";
|
|
7
|
-
|
|
8
|
-
let store: Store;
|
|
9
|
-
let cleanup: () => void;
|
|
10
|
-
|
|
11
|
-
beforeAll(async () => {
|
|
12
|
-
const result = await createTestStore({ ttl: DS_ALL_TTL });
|
|
13
|
-
store = result.store;
|
|
14
|
-
cleanup = result.cleanup;
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
afterAll(() => cleanup());
|
|
18
|
-
|
|
19
|
-
function makeCtx(overrides: Partial<PragmaContext> = {}): PragmaContext {
|
|
20
|
-
return {
|
|
21
|
-
cwd: "/tmp",
|
|
22
|
-
globalFlags: { llm: false, format: "text" as const, verbose: false },
|
|
23
|
-
store,
|
|
24
|
-
config: { tier: undefined, channel: "prerelease" },
|
|
25
|
-
...overrides,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function executeOutput(
|
|
30
|
-
cmd: CommandDefinition,
|
|
31
|
-
params: Record<string, unknown>,
|
|
32
|
-
ctx: PragmaContext,
|
|
33
|
-
): Promise<{ value: unknown; text: string }> {
|
|
34
|
-
const result = await cmd.execute(params, ctx);
|
|
35
|
-
expect(result.tag).toBe("output");
|
|
36
|
-
if (result.tag !== "output") throw new Error("Expected output result");
|
|
37
|
-
const text = result.render.plain(result.value);
|
|
38
|
-
return { value: result.value, text };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
describe("buildLookupCommand", () => {
|
|
42
|
-
it("returns summary by default", async () => {
|
|
43
|
-
const ctx = makeCtx();
|
|
44
|
-
const cmd = buildLookupCommand(ctx);
|
|
45
|
-
const { text } = await executeOutput(
|
|
46
|
-
cmd,
|
|
47
|
-
{ names: ["react/component/folder-structure"] },
|
|
48
|
-
ctx,
|
|
49
|
-
);
|
|
50
|
-
expect(text).toContain("react/component/folder-structure");
|
|
51
|
-
expect(text).toContain("Category: react");
|
|
52
|
-
expect(text).not.toContain("Do:");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("returns dos and donts with --detailed", async () => {
|
|
56
|
-
const ctx = makeCtx();
|
|
57
|
-
const cmd = buildLookupCommand(ctx);
|
|
58
|
-
const { text } = await executeOutput(
|
|
59
|
-
cmd,
|
|
60
|
-
{ names: ["react/component/folder-structure"], detailed: true },
|
|
61
|
-
ctx,
|
|
62
|
-
);
|
|
63
|
-
expect(text).toContain("Do:");
|
|
64
|
-
expect(text).toContain("Don't:");
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("throws ENTITY_NOT_FOUND for unknown standard", async () => {
|
|
68
|
-
const ctx = makeCtx();
|
|
69
|
-
const cmd = buildLookupCommand(ctx);
|
|
70
|
-
const result = await cmd.execute({ names: ["nonexistent"] }, ctx);
|
|
71
|
-
expect(result.tag).toBe("output");
|
|
72
|
-
if (result.tag !== "output") {
|
|
73
|
-
expect.fail("Expected output result");
|
|
74
|
-
}
|
|
75
|
-
expect(result.render.plain(result.value)).toContain("Errors:");
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("renders LLM format with --llm", async () => {
|
|
79
|
-
const ctx = makeCtx({
|
|
80
|
-
globalFlags: { llm: true, format: "text" as const, verbose: false },
|
|
81
|
-
});
|
|
82
|
-
const cmd = buildLookupCommand(ctx);
|
|
83
|
-
const { text } = await executeOutput(
|
|
84
|
-
cmd,
|
|
85
|
-
{ names: ["react/component/folder-structure"], detailed: true },
|
|
86
|
-
ctx,
|
|
87
|
-
);
|
|
88
|
-
expect(text).toContain("## react/component/folder-structure");
|
|
89
|
-
expect(text).toContain("### Do");
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("renders JSON with --detailed", async () => {
|
|
93
|
-
const ctx = makeCtx({
|
|
94
|
-
globalFlags: { llm: false, format: "json" as const, verbose: false },
|
|
95
|
-
});
|
|
96
|
-
const cmd = buildLookupCommand(ctx);
|
|
97
|
-
const { text } = await executeOutput(
|
|
98
|
-
cmd,
|
|
99
|
-
{ names: ["react/component/folder-structure"], detailed: true },
|
|
100
|
-
ctx,
|
|
101
|
-
);
|
|
102
|
-
const parsed = JSON.parse(text);
|
|
103
|
-
expect(parsed.name).toBe("react/component/folder-structure");
|
|
104
|
-
expect(parsed.dos).toBeDefined();
|
|
105
|
-
expect(parsed.donts).toBeDefined();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("renders JSON without --detailed (omits dos/donts)", async () => {
|
|
109
|
-
const ctx = makeCtx({
|
|
110
|
-
globalFlags: { llm: false, format: "json" as const, verbose: false },
|
|
111
|
-
});
|
|
112
|
-
const cmd = buildLookupCommand(ctx);
|
|
113
|
-
const { text } = await executeOutput(
|
|
114
|
-
cmd,
|
|
115
|
-
{ names: ["react/component/folder-structure"] },
|
|
116
|
-
ctx,
|
|
117
|
-
);
|
|
118
|
-
const parsed = JSON.parse(text);
|
|
119
|
-
expect(parsed.name).toBe("react/component/folder-structure");
|
|
120
|
-
expect(parsed.dos).toBeUndefined();
|
|
121
|
-
expect(parsed.donts).toBeUndefined();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it("renders multiple standards together", async () => {
|
|
125
|
-
const ctx = makeCtx();
|
|
126
|
-
const cmd = buildLookupCommand(ctx);
|
|
127
|
-
const { text } = await executeOutput(
|
|
128
|
-
cmd,
|
|
129
|
-
{ names: ["react/component/folder-structure", "react/component/props"] },
|
|
130
|
-
ctx,
|
|
131
|
-
);
|
|
132
|
-
expect(text).toContain("react/component/folder-structure");
|
|
133
|
-
expect(text).toContain("react/component/props");
|
|
134
|
-
});
|
|
135
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CommandDefinition } from "@canonical/cli-core";
|
|
2
|
-
import type { PragmaContext } from "../../shared/context.js";
|
|
3
|
-
import { compileLookupCommand } from "../../shared/stories/index.js";
|
|
4
|
-
import { standardLookupStory } from "../stories.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Wire the `pragma standard lookup <name-or-uri...>` CLI command from the
|
|
8
|
-
* standard lookup story.
|
|
9
|
-
*/
|
|
10
|
-
export default function buildLookupCommand(
|
|
11
|
-
ctx: PragmaContext,
|
|
12
|
-
): CommandDefinition {
|
|
13
|
-
return compileLookupCommand(ctx, standardLookupStory);
|
|
14
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
}
|