@canonical/pragma-cli 0.32.0 → 0.34.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 +72 -0
- package/dist/pragma +0 -0
- package/package.json +19 -15
- package/pragma.conf.ts +664 -0
- package/src/bin.ts +15 -6
- package/src/capabilities/block.parity.test.ts +250 -0
- package/src/capabilities/capabilities/capabilities.render.ts +3 -2
- package/src/capabilities/capabilities/capabilities.test.ts +10 -1
- package/src/capabilities/capabilities/capabilities.verb.ts +32 -14
- package/src/capabilities/capabilities/catalog.ts +20 -8
- package/src/capabilities/capabilities/hints.ts +21 -36
- package/src/capabilities/capabilities/types.ts +2 -0
- package/src/capabilities/colophon/collectColophon.ts +34 -19
- package/src/capabilities/colophon/colophon.render.test.ts +31 -4
- package/src/capabilities/colophon/colophon.render.ts +13 -4
- package/src/capabilities/colophon/colophon.test.ts +3 -3
- package/src/capabilities/colophon/colophon.verb.ts +11 -4
- package/src/capabilities/colophon/markdownTerminal.ts +33 -14
- package/src/capabilities/colophon/types.ts +16 -7
- package/src/capabilities/config/collectConfigShow.test.ts +57 -0
- package/src/capabilities/config/collectConfigShow.ts +41 -4
- package/src/capabilities/config/fields.ts +10 -108
- package/src/capabilities/config/set.test.ts +6 -6
- package/src/capabilities/config/set.verb.ts +12 -8
- package/src/capabilities/config/show.render.test.ts +137 -0
- package/src/capabilities/config/show.render.ts +57 -16
- package/src/capabilities/config/show.verb.ts +9 -8
- package/src/capabilities/config/types.ts +8 -0
- package/src/capabilities/create/byteEquality.subprocess.test.ts +1 -1
- package/src/capabilities/create/byteEquality.test.ts +82 -101
- package/src/capabilities/create/compiledCreate.subprocess.test.ts +53 -16
- package/src/capabilities/create/constants.ts +75 -0
- package/src/capabilities/create/create.mcp.test.ts +2 -2
- package/src/capabilities/create/create.test.ts +192 -16
- package/src/capabilities/create/create.verb.ts +208 -79
- package/src/capabilities/create/index.ts +2 -10
- package/src/capabilities/create/pickGenerator.ts +34 -28
- package/src/capabilities/create/templates.embedded.generated.ts +4 -29
- package/src/capabilities/create/types.ts +10 -6
- package/src/capabilities/{standard/parity.test.ts → distribution.parity.test.ts} +24 -14
- package/src/capabilities/distribution.test.ts +120 -0
- package/src/capabilities/distribution.ts +59 -0
- package/src/capabilities/doctor/checks/checkConfigFile.ts +6 -5
- package/src/capabilities/doctor/checks/checkKeStore.ts +2 -2
- package/src/capabilities/doctor/checks/checkMcpCommands.ts +6 -0
- package/src/capabilities/doctor/checks/checkMcpConfigured.ts +15 -8
- package/src/capabilities/doctor/checks/checkPackageRefs.ts +79 -45
- package/src/capabilities/doctor/checks/checkPragmaVersion.ts +3 -2
- package/src/capabilities/doctor/checks/checkShellCompletions.test.ts +61 -11
- package/src/capabilities/doctor/checks/checkShellCompletions.ts +63 -23
- package/src/capabilities/doctor/checks/checkSkillsSymlinked.ts +3 -2
- package/src/capabilities/doctor/checks/deriveBand.test.ts +42 -0
- package/src/capabilities/doctor/checks/deriveBand.ts +28 -0
- package/src/capabilities/doctor/doctor.render.test.ts +170 -0
- package/src/capabilities/doctor/doctor.render.ts +117 -34
- package/src/capabilities/doctor/doctor.test.ts +68 -9
- package/src/capabilities/doctor/doctor.verb.ts +6 -2
- package/src/capabilities/doctor/runChecks.ts +33 -9
- package/src/capabilities/doctor/types.ts +16 -1
- package/src/capabilities/emptyRecovery.test.ts +32 -15
- package/src/capabilities/graph/inspect.verb.ts +3 -2
- package/src/capabilities/graph/query.verb.ts +3 -2
- package/src/capabilities/graph/runQuery.ts +8 -5
- package/src/capabilities/index.ts +22 -18
- package/src/capabilities/info/collectInfo.ts +10 -6
- package/src/capabilities/info/info.render.ts +3 -2
- package/src/capabilities/info/info.verb.ts +3 -2
- package/src/capabilities/lazy.test.ts +93 -2
- package/src/capabilities/ontology/index.ts +10 -3
- package/src/capabilities/ontology/ontology.test.ts +157 -5
- package/src/capabilities/ontology/verbs.ts +203 -104
- package/src/capabilities/prompt/prompt.render.test.ts +94 -0
- package/src/capabilities/prompt/prompt.render.ts +23 -6
- package/src/capabilities/prompt/prompt.test.ts +68 -1
- package/src/capabilities/prompt/verbs.ts +24 -11
- package/src/capabilities/reference.test.ts +32 -0
- package/src/capabilities/resources/provider.ts +58 -25
- package/src/capabilities/resources/resources.test.ts +176 -21
- package/src/capabilities/scopeTypeSync.test.ts +37 -0
- package/src/capabilities/setup/index.ts +7 -1
- package/src/capabilities/setup/operations/setupCompletions.ts +49 -16
- package/src/capabilities/setup/operations/setupGenerator.ts +166 -63
- package/src/capabilities/setup/operations/setupLsp.ts +56 -12
- package/src/capabilities/setup/operations/setupMcp.ts +216 -39
- package/src/capabilities/setup/operations/setupSkills.ts +10 -4
- package/src/capabilities/setup/setup.render.test.ts +109 -0
- package/src/capabilities/setup/setup.render.ts +61 -14
- package/src/capabilities/setup/setup.test.ts +352 -1
- package/src/capabilities/setup/setup.verb.ts +68 -9
- package/src/capabilities/setup/shell.ts +29 -3
- package/src/capabilities/setup/types.ts +59 -2
- package/src/capabilities/shared/bands.ts +16 -0
- package/src/capabilities/skill/discover.ts +11 -5
- package/src/capabilities/skill/render.ts +4 -5
- package/src/capabilities/skill/verbs.ts +7 -7
- package/src/capabilities/sources/collectStatus.ts +69 -49
- package/src/capabilities/sources/index.ts +1 -1
- package/src/capabilities/sources/installSkills.ts +2 -2
- package/src/capabilities/sources/runUpdate.ts +146 -98
- package/src/capabilities/sources/sources.test.ts +264 -84
- package/src/capabilities/sources/status.render.test.ts +94 -0
- package/src/capabilities/sources/status.render.ts +55 -33
- package/src/capabilities/sources/status.verb.ts +15 -8
- package/src/capabilities/sources/types.ts +18 -25
- package/src/capabilities/sources/update.render.ts +9 -2
- package/src/capabilities/sources/update.verb.ts +12 -23
- package/src/capabilities/surface.test.ts +65 -17
- package/src/capabilities/tier.parity.test.ts +144 -0
- package/src/capabilities/upgrade/upgrade.verb.ts +7 -3
- package/src/constants.test.ts +9 -7
- package/src/constants.ts +49 -23
- package/src/identity.test.ts +333 -0
- package/src/index.ts +2 -2
- package/src/kernel/completion/__snapshots__/emitScripts.test.ts.snap +18 -16
- package/src/kernel/completion/complete.test.ts +3 -5
- package/src/kernel/completion/emitScripts.test.ts +1 -1
- package/src/kernel/completion/emitScripts.ts +4 -2
- package/src/kernel/completion/entitySource.test.ts +185 -41
- package/src/kernel/completion/entitySource.ts +131 -113
- package/src/kernel/completion/model.test.ts +3 -3
- package/src/kernel/completion/model.ts +11 -1
- package/src/kernel/completion/parse.test.ts +2 -4
- package/src/kernel/completion/safety.test.ts +82 -36
- package/src/kernel/completion/shellDrive.test.ts +592 -0
- package/src/kernel/completion/templates/fish.ts +28 -6
- package/src/kernel/completion/types.ts +3 -3
- package/src/kernel/config/__snapshots__/firstRun.test.ts.snap +1 -1
- package/src/kernel/config/defaults.test.ts +85 -0
- package/src/kernel/config/defaults.ts +12 -23
- package/src/kernel/config/evaluateProjectConfig.ts +2 -3
- package/src/kernel/config/findProjectConfig.ts +4 -3
- package/src/kernel/config/firstRun.ts +12 -5
- package/src/kernel/config/globalConfig.ts +2 -2
- package/src/kernel/config/index.ts +4 -5
- package/src/kernel/config/paths.ts +17 -17
- package/src/kernel/config/readConfig.test.ts +242 -6
- package/src/kernel/config/readConfig.ts +8 -8
- package/src/kernel/config/schema.test.ts +50 -0
- package/src/kernel/config/schema.ts +97 -10
- package/src/kernel/config/types.ts +73 -19
- package/src/kernel/copy.test.ts +453 -0
- package/src/kernel/error/PragmaError.test.ts +5 -5
- package/src/kernel/error/constants.ts +3 -2
- package/src/kernel/error/index.ts +1 -1
- package/src/kernel/error/recovery.test.ts +22 -45
- package/src/kernel/error/recovery.ts +22 -27
- package/src/kernel/error/renderError.ts +1 -1
- package/src/kernel/error/types.ts +5 -4
- package/src/kernel/packs/collect.test.ts +195 -11
- package/src/kernel/packs/collect.ts +213 -58
- package/src/kernel/packs/compile.test.ts +163 -7
- package/src/kernel/packs/compile.ts +15 -12
- package/src/kernel/packs/disclosure.test.ts +5 -2
- package/src/kernel/packs/graphql/fetchGraphqlLookup.ts +11 -10
- package/src/kernel/packs/graphqlSource.test.ts +6 -3
- package/src/kernel/packs/iri.ts +5 -7
- package/src/kernel/packs/renderPack.ts +5 -3
- package/src/kernel/packs/resolveEntity.ts +21 -17
- package/src/kernel/packs/runBodies.ts +15 -14
- package/src/kernel/packs/schema.ts +96 -10
- package/src/kernel/packs/sparql/runSelect.test.ts +104 -10
- package/src/kernel/packs/sparql/runSelect.ts +73 -34
- package/src/kernel/packs/toolDescription.test.ts +10 -2
- package/src/kernel/packs/types.ts +39 -4
- package/src/kernel/packs/uniqueness.ts +4 -4
- package/src/kernel/project/cli/buildProgram.test.ts +60 -11
- package/src/kernel/project/cli/buildProgram.ts +11 -0
- package/src/kernel/project/cli/dispatch.test.ts +67 -0
- package/src/kernel/project/cli/dispatch.ts +34 -12
- package/src/kernel/project/cli/globalFlags.test.ts +12 -4
- package/src/kernel/project/cli/globalFlags.ts +14 -14
- package/src/kernel/project/cli/helpFormat.ts +1 -1
- package/src/kernel/project/cli/rootHelp.ts +109 -107
- package/src/kernel/project/mcp/buildServer.ts +11 -6
- package/src/kernel/project/mcp/instructions.ts +12 -7
- package/src/kernel/project/mcp/mcpError.ts +52 -0
- package/src/kernel/project/mcp/parity.test.ts +39 -1
- package/src/kernel/project/mcp/prompts/prompts.test.ts +128 -5
- package/src/kernel/project/mcp/prompts/provider.ts +51 -7
- package/src/kernel/project/mcp/prompts/source.ts +68 -67
- package/src/kernel/project/mcp/registerVerb.ts +25 -6
- package/src/kernel/project/mcp/serve.ts +11 -3
- package/src/kernel/project/mcp/toolDescriptions.test.ts +6 -2
- package/src/kernel/render/disclosure.ts +4 -2
- package/src/kernel/render/formatters.ts +5 -4
- package/src/kernel/render/prefixes.test.ts +36 -0
- package/src/kernel/render/prefixes.ts +40 -13
- package/src/kernel/render/renderers.test.ts +35 -1
- package/src/kernel/render/renderers.ts +25 -7
- package/src/kernel/render/style.test.ts +31 -0
- package/src/kernel/render/style.ts +74 -0
- package/src/kernel/runtime/graphpack/build.ts +57 -3
- package/src/kernel/runtime/graphpack/buildIndex.test.ts +149 -0
- package/src/kernel/runtime/graphpack/buildIndex.ts +173 -50
- package/src/kernel/runtime/graphpack/embedded/pack.generated.ts +5 -8
- package/src/kernel/runtime/graphpack/embedded/pack.index.generated.ts +3 -4
- package/src/kernel/runtime/graphpack/embedded/pack.stories.generated.ts +3 -0
- package/src/kernel/runtime/graphpack/embedded.ts +37 -11
- package/src/kernel/runtime/graphpack/graphpack.test.ts +274 -6
- package/src/kernel/runtime/graphpack/hash.ts +3 -2
- package/src/kernel/runtime/graphpack/index.ts +1 -1
- package/src/kernel/runtime/graphpack/manifest.ts +114 -12
- package/src/kernel/runtime/graphpack/read.ts +32 -22
- package/src/kernel/runtime/graphpack/schemas.ts +74 -0
- package/src/kernel/runtime/graphpack/stories.ts +84 -0
- package/src/kernel/runtime/graphpack/types.ts +72 -45
- package/src/kernel/runtime/loadSession.ts +4 -12
- package/src/kernel/runtime/paths.ts +64 -15
- package/src/kernel/runtime/probe.test.ts +8 -4
- package/src/kernel/runtime/readEntity.ts +6 -5
- package/src/kernel/runtime/refs/gitOps.ts +1 -19
- package/src/kernel/runtime/refs/parseRef.ts +7 -7
- package/src/kernel/runtime/refs/resolve.ts +141 -65
- package/src/kernel/runtime/resolveSources.test.ts +63 -24
- package/src/kernel/runtime/resolveSources.ts +36 -25
- package/src/kernel/runtime/storeReadiness.ts +62 -0
- package/src/kernel/runtime/storeless.test.ts +1 -1
- package/src/kernel/runtime/types.ts +1 -1
- package/src/kernel/runtime/wasmEmbed.test.ts +25 -20
- package/src/kernel/spec/emitReference.test.ts +196 -0
- package/src/kernel/spec/emitReference.ts +624 -0
- package/src/kernel/spec/emitSurface.ts +13 -7
- package/src/kernel/spec/index.ts +2 -0
- package/src/kernel/spec/surfaceConformance.test.ts +2 -2
- package/src/kernel/spec/surfaceConformance.ts +8 -0
- package/src/kernel/spec/types.ts +29 -9
- package/src/kernel/spec/validate.ts +2 -1
- package/src/kernel/vocabulary.test.ts +164 -0
- package/src/kernel/vocabulary.ts +146 -0
- package/src/testing/PARITY_GAPS.ts +9 -3
- package/src/testing/behavioral/README.md +3 -3
- package/src/testing/behavioral/autoLlm.e2e.test.ts +12 -2
- package/src/testing/behavioral/completion.test.ts +21 -8
- package/src/testing/behavioral/disclosure.test.ts +12 -0
- package/src/testing/behavioral/docExamples.test.ts +283 -0
- package/src/testing/behavioral/errorMatrix.mcp.test.ts +4 -3
- package/src/testing/behavioral/errorMatrix.storeless.test.ts +3 -2
- package/src/testing/behavioral/exitCodes.e2e.test.ts +6 -5
- package/src/testing/behavioral/harness.foundation.test.ts +14 -5
- package/src/testing/behavioral/journeys.cli.test.ts +116 -73
- package/src/testing/behavioral/journeys.defaultPack.test.ts +477 -0
- package/src/testing/behavioral/journeys.firstInstall.test.ts +167 -0
- package/src/testing/behavioral/journeys.interactiveTty.e2e.test.ts +66 -0
- package/src/testing/behavioral/journeys.livePack.e2e.test.ts +129 -0
- package/src/testing/behavioral/journeys.mcpLifecycle.mcp.test.ts +179 -0
- package/src/testing/behavioral/journeys.packageStories.test.ts +188 -0
- package/src/testing/behavioral/liveReadSurface.ts +4 -3
- package/src/testing/behavioral/mcpSurface.test.ts +10 -5
- package/src/testing/behavioral/staleCommands.test.ts +86 -0
- package/src/testing/eval/__snapshots__/eval.test.ts.snap +9 -9
- package/src/testing/eval/cases/assembly.ts +16 -9
- package/src/testing/eval/cases/effectful.ts +31 -16
- package/src/testing/eval/cases/readNouns.ts +23 -18
- package/src/testing/eval/cases/stable.ts +5 -1
- package/src/testing/eval/eval.test.ts +7 -1
- package/src/testing/fixtures/fixtureCapability.ts +201 -1
- package/src/testing/fixtures/graph/canonical.ts +6 -3
- package/src/testing/fixtures/graph/defaultPack.ts +179 -0
- package/src/testing/fixtures/graph/owlExport.ts +97 -0
- package/src/testing/helpers/extractSnippets.ts +29 -0
- package/src/testing/helpers/fixtureGraph.ts +33 -16
- package/src/testing/helpers/golden.ts +1 -1
- package/src/testing/helpers/packRuntime.ts +2 -3
- package/src/testing/helpers/projectCli.ts +2 -1
- package/src/testing/helpers/projectMcp.ts +6 -0
- package/src/testing/perf/budgets.test.ts +4 -0
- package/src/testing/perf/budgets.ts +22 -7
- package/src/testing/perf/globalSetup.ts +121 -6
- package/src/types.ts +2 -2
- package/src/capabilities/block/blockList.verb.ts +0 -150
- package/src/capabilities/block/index.ts +0 -25
- package/src/capabilities/block/pack.ts +0 -155
- package/src/capabilities/block/parity.test.ts +0 -180
- package/src/capabilities/block/tierChain.ts +0 -78
- package/src/capabilities/colophon/pragmaColophon.ts +0 -66
- package/src/capabilities/config/field.test.ts +0 -188
- package/src/capabilities/modifier/index.ts +0 -15
- package/src/capabilities/modifier/pack.ts +0 -64
- package/src/capabilities/standard/index.ts +0 -18
- package/src/capabilities/standard/pack.ts +0 -128
- package/src/capabilities/tier/index.ts +0 -19
- package/src/capabilities/tier/lookup.render.ts +0 -34
- package/src/capabilities/tier/lookup.test.ts +0 -68
- package/src/capabilities/tier/lookup.verb.ts +0 -44
- package/src/capabilities/tier/pack.ts +0 -28
- package/src/capabilities/tier/runLookup.ts +0 -59
- package/src/capabilities/token/addConfig.render.ts +0 -27
- package/src/capabilities/token/addConfig.test.ts +0 -62
- package/src/capabilities/token/addConfig.verb.ts +0 -40
- package/src/capabilities/token/index.ts +0 -19
- package/src/capabilities/token/pack.ts +0 -58
- package/src/capabilities/token/runAddConfig.ts +0 -95
- package/src/kernel/completion/bashDrive.test.ts +0 -73
- package/src/kernel/runtime/graphpack/embedded/sample.ttl +0 -39
- package/src/kernel/runtime/lock.ts +0 -90
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
14
14
|
import { homedir } from "node:os";
|
|
15
15
|
import { basename, join } from "node:path";
|
|
16
|
+
import { BIN_NAME } from "../../constants.js";
|
|
16
17
|
|
|
17
18
|
/** Parsed SKILL.md frontmatter. */
|
|
18
19
|
export interface SkillFrontmatter {
|
|
@@ -103,26 +104,31 @@ export function parseFrontmatter(content: string): SkillFrontmatter | null {
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
/**
|
|
106
|
-
* The installed-skills root: `$XDG_DATA_HOME
|
|
107
|
+
* The installed-skills root: `$XDG_DATA_HOME/<bin>/skills`. This is where
|
|
107
108
|
* `sources update` INSTALLS package-provided skills (U10) — a symlink per skill
|
|
108
109
|
* — and the second discovery root below reads them back. The single source of
|
|
109
110
|
* truth for both, so the install target and the discovery root can never drift.
|
|
111
|
+
*
|
|
112
|
+
* Namespaced by {@link BIN_NAME}, like config, state and cache: two
|
|
113
|
+
* distributions installed side by side owned ONE skills root, so a `recipes`
|
|
114
|
+
* build served skills a `pragma` build had installed and could not install its
|
|
115
|
+
* own without colliding.
|
|
110
116
|
*/
|
|
111
117
|
export function installedSkillsDir(): string {
|
|
112
118
|
const dataHome =
|
|
113
119
|
process.env.XDG_DATA_HOME ?? join(homedir(), ".local", "share");
|
|
114
|
-
return join(dataHome,
|
|
120
|
+
return join(dataHome, BIN_NAME, "skills");
|
|
115
121
|
}
|
|
116
122
|
|
|
117
123
|
/**
|
|
118
124
|
* The conventional roots skills are discovered from, in PRECEDENCE order: the
|
|
119
|
-
* project root (`<cwd
|
|
125
|
+
* project root (`<cwd>/.<bin>/skills`) FIRST so a project-local skill overrides
|
|
120
126
|
* an installed skill of the same name (`discoverSkills` dedups first-seen-wins),
|
|
121
|
-
* then installed skills under `$XDG_DATA_HOME
|
|
127
|
+
* then installed skills under `$XDG_DATA_HOME/<bin>/skills` (where package
|
|
122
128
|
* skills land on `sources update`).
|
|
123
129
|
*/
|
|
124
130
|
export function skillRoots(cwd: string): string[] {
|
|
125
|
-
return [join(cwd,
|
|
131
|
+
return [join(cwd, `.${BIN_NAME}`, "skills"), installedSkillsDir()];
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
/** Immediate subdirectories of `root` (each a candidate skill folder). */
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
* Formatters for `skill list` and `skill lookup`.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { BIN_NAME } from "../../constants.js";
|
|
5
6
|
import type { Formatters } from "../../kernel/spec/types.js";
|
|
6
7
|
import type { DiscoveredSkill } from "./discover.js";
|
|
7
8
|
import type { SkillLookup } from "./verbs.js";
|
|
8
9
|
|
|
9
|
-
/** Empty-state guidance (U5) — where skills come from now that
|
|
10
|
-
const EMPTY_PLAIN =
|
|
11
|
-
|
|
12
|
-
const EMPTY_LLM =
|
|
13
|
-
"## Skills (0)\n\nNo skills found. Skills come from installed design-system packages — add one to the project config, run `pragma sources update`, then `pragma setup skills`.";
|
|
10
|
+
/** Empty-state guidance (U5) — where skills come from now that packs ship them. */
|
|
11
|
+
const EMPTY_PLAIN = `No skills found.\nSkills come from design-system packs — add one to your config's packs, run \`${BIN_NAME} sources update\`, then \`${BIN_NAME} setup skills\`.`;
|
|
12
|
+
const EMPTY_LLM = `## Skills (0)\n\nNo skills found. Skills come from design-system packs — add one to the project config's packs, run \`${BIN_NAME} sources update\`, then \`${BIN_NAME} setup skills\`.`;
|
|
14
13
|
|
|
15
14
|
export const skillListFormatters: Formatters<DiscoveredSkill[]> = {
|
|
16
15
|
plain: (skills) =>
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
import { readFileSync } from "node:fs";
|
|
10
10
|
import { join } from "node:path";
|
|
11
|
+
import { BIN_NAME } from "../../constants.js";
|
|
11
12
|
import { PragmaError } from "../../kernel/error/PragmaError.js";
|
|
13
|
+
import { cliRecovery } from "../../kernel/error/recovery.js";
|
|
12
14
|
import { suggestNames } from "../../kernel/project/cli/suggestNames.js";
|
|
13
15
|
import type { PragmaRuntime } from "../../kernel/runtime/types.js";
|
|
14
16
|
import { asVerb } from "../../kernel/spec/asVerb.js";
|
|
@@ -26,7 +28,7 @@ const listVerb: VerbSpec<Record<string, unknown>, DiscoveredSkill[]> = {
|
|
|
26
28
|
summary: "List discovered skills (SKILL.md files under the skill roots).",
|
|
27
29
|
params: [],
|
|
28
30
|
output: { formatters: skillListFormatters },
|
|
29
|
-
examples: [{ cmd:
|
|
31
|
+
examples: [{ cmd: `${BIN_NAME} skill list` }],
|
|
30
32
|
capability: {
|
|
31
33
|
needsStore: false,
|
|
32
34
|
mutates: false,
|
|
@@ -53,7 +55,7 @@ const lookupVerb: VerbSpec<Record<string, unknown>, SkillLookup> = {
|
|
|
53
55
|
},
|
|
54
56
|
],
|
|
55
57
|
output: { formatters: skillLookupFormatters },
|
|
56
|
-
examples: [{ cmd:
|
|
58
|
+
examples: [{ cmd: `${BIN_NAME} skill lookup docx` }],
|
|
57
59
|
capability: {
|
|
58
60
|
needsStore: false,
|
|
59
61
|
mutates: false,
|
|
@@ -74,11 +76,9 @@ const lookupVerb: VerbSpec<Record<string, unknown>, SkillLookup> = {
|
|
|
74
76
|
name,
|
|
75
77
|
skills.map((skill) => skill.name),
|
|
76
78
|
),
|
|
77
|
-
recovery: {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
mcp: { tool: "skill_list" },
|
|
81
|
-
},
|
|
79
|
+
recovery: cliRecovery("skill list", "List discovered skills.", {
|
|
80
|
+
tool: "skill_list",
|
|
81
|
+
}),
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
return { ...match, instructions: readInstructions(match.sourcePath) };
|
|
@@ -1,42 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Collect the `sources status` payload — storeless.
|
|
3
3
|
*
|
|
4
|
-
* Reports the store's readiness without booting it
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* Reports the store's readiness without booting it. The `store` field IS the
|
|
5
|
+
* boot decision ({@link resolveSources}) — status never re-derives which pack
|
|
6
|
+
* answers reads, so it can never disagree with what the next read actually
|
|
7
|
+
* loads. Everything else is provenance read straight off that pack's manifest
|
|
8
|
+
* (a plain `JSON.parse`, no store, no oxigraph). This is the capability that
|
|
9
|
+
* must stay off the store factory (the storeless-guarantee spy covers it). It
|
|
10
|
+
* absorbs the v1 `info store` summary.
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
import { existsSync, readFileSync } from "node:fs";
|
|
13
14
|
import { join } from "node:path";
|
|
14
|
-
import type {
|
|
15
|
+
import type { PackDeclaration } from "../../kernel/config/types.js";
|
|
16
|
+
import { embeddedManifest } from "../../kernel/runtime/graphpack/embedded.js";
|
|
15
17
|
import { readManifest } from "../../kernel/runtime/graphpack/manifest.js";
|
|
16
18
|
import { INDEX_FILE } from "../../kernel/runtime/graphpack/types.js";
|
|
17
|
-
import {
|
|
18
|
-
import { packDir } from "../../kernel/runtime/paths.js";
|
|
19
|
+
import { resolveSources } from "../../kernel/runtime/resolveSources.js";
|
|
19
20
|
import type { PragmaRuntime } from "../../kernel/runtime/types.js";
|
|
20
|
-
import type {
|
|
21
|
-
SourceStaleness,
|
|
22
|
-
SourceStatusEntry,
|
|
23
|
-
SourcesStatusData,
|
|
24
|
-
} from "./types.js";
|
|
21
|
+
import type { SourcesStatusData } from "./types.js";
|
|
25
22
|
|
|
26
|
-
const entryName = (entry:
|
|
23
|
+
const entryName = (entry: PackDeclaration): string =>
|
|
27
24
|
typeof entry === "string" ? entry : entry.name;
|
|
28
|
-
const entrySource = (entry:
|
|
25
|
+
const entrySource = (entry: PackDeclaration): string =>
|
|
29
26
|
typeof entry === "string" ? entry : (entry.source ?? entry.name);
|
|
30
27
|
|
|
31
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* The distinct-abox entity count from a built pack's index.json (storeless).
|
|
30
|
+
*
|
|
31
|
+
* Only reached for LEGACY packs whose manifest predates the persisted
|
|
32
|
+
* `entityCount` (A10) — a current pack's count is read straight from the
|
|
33
|
+
* manifest, no index parse. Counts distinct abox subjects so the figure matches
|
|
34
|
+
* both the manifest count and `info`'s `entityTotal` (A1).
|
|
35
|
+
*/
|
|
32
36
|
function indexEntityCount(dir: string): number | null {
|
|
33
37
|
const path = join(dir, INDEX_FILE);
|
|
34
38
|
if (!existsSync(path)) return null;
|
|
35
39
|
try {
|
|
36
40
|
const parsed = JSON.parse(readFileSync(path, "utf-8")) as {
|
|
37
|
-
entities?:
|
|
41
|
+
entities?: { box?: string; uri?: string; name?: string }[];
|
|
38
42
|
};
|
|
39
|
-
|
|
43
|
+
if (!Array.isArray(parsed.entities)) return null;
|
|
44
|
+
const subjects = new Set<string>();
|
|
45
|
+
for (const entity of parsed.entities) {
|
|
46
|
+
if (entity.box === "abox") subjects.add(entity.uri ?? entity.name ?? "");
|
|
47
|
+
}
|
|
48
|
+
return subjects.size;
|
|
40
49
|
} catch {
|
|
41
50
|
return null;
|
|
42
51
|
}
|
|
@@ -47,41 +56,52 @@ function indexEntityCount(dir: string): number | null {
|
|
|
47
56
|
*
|
|
48
57
|
* @param runtime - The per-invocation runtime.
|
|
49
58
|
* @returns The storeless status payload.
|
|
50
|
-
* @note Impure — reads config, the
|
|
59
|
+
* @note Impure — reads config, the active-pack pointer, and the pack cache.
|
|
51
60
|
*/
|
|
52
61
|
export async function collectStatus(
|
|
53
62
|
runtime: PragmaRuntime,
|
|
54
63
|
): Promise<SourcesStatusData> {
|
|
55
64
|
const layers = await runtime.loadConfig();
|
|
56
|
-
const
|
|
57
|
-
|
|
65
|
+
const sources = (layers.config.packs ?? []).map((entry) => ({
|
|
66
|
+
name: entryName(entry),
|
|
67
|
+
ref: entrySource(entry),
|
|
68
|
+
}));
|
|
69
|
+
const decision = resolveSources(layers, runtime.cwd);
|
|
70
|
+
const base = { cwd: runtime.cwd, sources };
|
|
58
71
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} else if (!lockEntry || lockEntry.source !== ref) {
|
|
71
|
-
staleness = "config-drift";
|
|
72
|
-
} else {
|
|
73
|
-
staleness = "up-to-date";
|
|
72
|
+
switch (decision.kind) {
|
|
73
|
+
case "embedded": {
|
|
74
|
+
const manifest = embeddedManifest();
|
|
75
|
+
return {
|
|
76
|
+
...base,
|
|
77
|
+
store: "embedded",
|
|
78
|
+
contentHash: manifest.contentHash,
|
|
79
|
+
sourceRef: manifest.sourceRef,
|
|
80
|
+
builtAt: manifest.createdAt,
|
|
81
|
+
entityCount: manifest.entityCount ?? null,
|
|
82
|
+
};
|
|
74
83
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
case "pack": {
|
|
85
|
+
const manifest = readManifest(decision.dir);
|
|
86
|
+
return {
|
|
87
|
+
...base,
|
|
88
|
+
store: "built",
|
|
89
|
+
contentHash: decision.contentHash,
|
|
90
|
+
sourceRef: manifest?.sourceRef ?? null,
|
|
91
|
+
builtAt: manifest?.createdAt ?? null,
|
|
92
|
+
// Prefer the manifest's persisted count (no index parse); a legacy pack
|
|
93
|
+
// without it falls back to counting the index's abox subjects (A10).
|
|
94
|
+
entityCount: manifest?.entityCount ?? indexEntityCount(decision.dir),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
case "unavailable":
|
|
98
|
+
return {
|
|
99
|
+
...base,
|
|
100
|
+
store: "unavailable",
|
|
101
|
+
contentHash: null,
|
|
102
|
+
sourceRef: null,
|
|
103
|
+
builtAt: null,
|
|
104
|
+
entityCount: null,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
87
107
|
}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Design-system packages ship a top-level `skills/<name>/SKILL.md`, but skill
|
|
5
5
|
* discovery only scans the project root and the installed-skills root — never a
|
|
6
6
|
* resolved package's clone/dir. So `sources update` INSTALLS each package's
|
|
7
|
-
* skills into the installed-skills root (`$XDG_DATA_HOME
|
|
7
|
+
* skills into the installed-skills root (`$XDG_DATA_HOME/<bin>/skills`) as
|
|
8
8
|
* symlinks, exactly the root `discoverSkills` already reads. Precedence is
|
|
9
|
-
* preserved (a project
|
|
9
|
+
* preserved (a project `.<bin>/skills` entry still wins — it is discovered
|
|
10
10
|
* first), and the update Task stays reversible (each created link carries an
|
|
11
11
|
* unlink undo).
|
|
12
12
|
*
|