@aiwg/cli 2026.10.19 → 2026.11.1

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.
Files changed (143) hide show
  1. package/README.md +1 -0
  2. package/agentic/code/providers/flue/README.md +2 -1
  3. package/dist/src/artifacts/cli.js +3 -2
  4. package/dist/src/artifacts/discover-facets.js +2 -0
  5. package/dist/src/artifacts/discover-session-facets.js +14 -0
  6. package/dist/src/artifacts/fortemi-core-query-adapter.js +4 -4
  7. package/dist/src/artifacts/framework-capabilities.js +7 -3
  8. package/dist/src/artifacts/index-builder.js +2 -3
  9. package/dist/src/artifacts/query-engine-discover-output.js +3 -3
  10. package/dist/src/artifacts/query-engine-discover.js +61 -14
  11. package/dist/src/artifacts/query-engine-entries.js +52 -9
  12. package/dist/src/artifacts/query-engine-installation.js +27 -0
  13. package/dist/src/artifacts/query-engine-rules.js +1 -2
  14. package/dist/src/artifacts/query-engine-scoring.js +33 -31
  15. package/dist/src/artifacts/query-engine-show-card.js +6 -2
  16. package/dist/src/artifacts/query-engine-show.js +2 -2
  17. package/dist/src/artifacts/relations.js +17 -10
  18. package/dist/src/cli/handlers/bundle-declaration.js +55 -0
  19. package/dist/src/cli/handlers/bundle-deployment-mode.js +71 -0
  20. package/dist/src/cli/handlers/bundle-hash-prune.js +37 -0
  21. package/dist/src/cli/handlers/bundle-reconciliation.js +140 -0
  22. package/dist/src/cli/handlers/checkpoint.js +143 -0
  23. package/dist/src/cli/handlers/help.js +1 -0
  24. package/dist/src/cli/handlers/index.js +4 -2
  25. package/dist/src/cli/handlers/models-resource-sample.js +7 -3
  26. package/dist/src/cli/handlers/ralph-launcher.js +1 -1
  27. package/dist/src/cli/handlers/refresh-bundles.js +35 -0
  28. package/dist/src/cli/handlers/refresh-rule-inventory.js +10 -0
  29. package/dist/src/cli/handlers/refresh.js +15 -52
  30. package/dist/src/cli/handlers/remove-bundled.js +7 -4
  31. package/dist/src/cli/handlers/remove-flue-modules.js +19 -0
  32. package/dist/src/cli/handlers/remove-historical-bundle.js +18 -0
  33. package/dist/src/cli/handlers/remove.js +8 -0
  34. package/dist/src/cli/handlers/script-runner.js +12 -1
  35. package/dist/src/cli/handlers/steward-signing.js +44 -0
  36. package/dist/src/cli/handlers/steward.js +5 -0
  37. package/dist/src/cli/handlers/subcommands-list-format.js +4 -4
  38. package/dist/src/cli/handlers/update.js +18 -8
  39. package/dist/src/cli/handlers/use-additive-bundles.js +87 -0
  40. package/dist/src/cli/handlers/use-bundle-counts.js +5 -1
  41. package/dist/src/cli/handlers/use-owned-counts.js +75 -0
  42. package/dist/src/cli/handlers/use-provider-results.js +17 -0
  43. package/dist/src/cli/handlers/use.js +53 -114
  44. package/dist/src/cli/router.js +12 -2
  45. package/dist/src/cli/services/deployment-verification.js +2 -1
  46. package/dist/src/cli/user-scope-mirror.js +3 -1
  47. package/dist/src/config/aiwg-config.js +15 -6
  48. package/dist/src/config/cli.js +1 -0
  49. package/dist/src/config/delivery-validation.js +21 -0
  50. package/dist/src/config/framework-aliases.js +14 -0
  51. package/dist/src/config/host-resource-report.d.mts +1 -1
  52. package/dist/src/config/host-resource-report.mjs +23 -4
  53. package/dist/src/config/host-resource-runtime.d.mts +8 -0
  54. package/dist/src/config/host-resource-runtime.mjs +67 -24
  55. package/dist/src/config/index-graph-overrides.js +4 -0
  56. package/dist/src/config/installed-selection.js +9 -1
  57. package/dist/src/config/installed-validation.js +35 -0
  58. package/dist/src/config/worker-attribution.d.mts +7 -0
  59. package/dist/src/config/worker-attribution.mjs +44 -0
  60. package/dist/src/delivery/git.js +62 -0
  61. package/dist/src/delivery/pr.js +149 -0
  62. package/dist/src/delivery/tracker.js +33 -0
  63. package/dist/src/discovery/interview.js +1 -1
  64. package/dist/src/extensions/claude-hooks-installer.js +1 -0
  65. package/dist/src/extensions/loader.js +2 -1
  66. package/dist/src/extensions/project-local-doctor.js +1 -1
  67. package/dist/src/extensions/project-local-remove.js +3 -3
  68. package/dist/src/issues/cli.js +12 -3
  69. package/dist/src/issues/external-cli.js +76 -0
  70. package/dist/src/issues/live.js +18 -1
  71. package/dist/src/issues/tracker-policy.js +17 -0
  72. package/dist/src/mcp/cli.mjs +12 -7
  73. package/dist/src/mcp/helpers.mjs +5 -1
  74. package/dist/src/mcp/http-options.mjs +101 -0
  75. package/dist/src/mcp/http-tools.mjs +51 -0
  76. package/dist/src/mcp/http-transport.mjs +201 -0
  77. package/dist/src/mcp/server.mjs +9 -7
  78. package/dist/src/mcp/tool-context.mjs +25 -0
  79. package/dist/src/mcp/tools/orchestration.mjs +2 -1
  80. package/dist/src/mcp/tools/worker-invoke.mjs +2 -1
  81. package/dist/src/mcp/tools/worker-stdin-runtime.mjs +12 -0
  82. package/dist/src/models/conductor-data-policy.d.mts +3 -2
  83. package/dist/src/models/conductor-data-policy.mjs +94 -5
  84. package/dist/src/models/worker-plan.js +3 -3
  85. package/dist/src/models/worker-selection-policy.js +2 -1
  86. package/dist/src/providers/deployment-lock.js +77 -0
  87. package/dist/src/providers/deployment-ownership.d.mts +12 -2
  88. package/dist/src/providers/deployment-ownership.mjs +127 -19
  89. package/dist/src/providers/deployment-preservation.d.mts +6 -0
  90. package/dist/src/providers/deployment-preservation.mjs +113 -0
  91. package/dist/src/providers/deployment-removal.js +4 -2
  92. package/dist/src/providers/flue-package-mode.js +19 -0
  93. package/dist/src/providers/provider-definitions.js +4 -0
  94. package/dist/src/providers/skill-ownership.mjs +1 -0
  95. package/dist/src/research/reference-match.js +4 -0
  96. package/dist/src/serve/worker-invocation-preparation.js +3 -1
  97. package/dist/src/serve/worker-invocation.js +2 -0
  98. package/dist/src/skills/run.js +5 -0
  99. package/dist/src/smiths/hook-bridge/codex-translator.js +3 -1
  100. package/dist/src/smiths/hook-bridge/hermes-translator.js +3 -1
  101. package/dist/src/smiths/hook-bridge/prompt-discovery-gaps.js +6 -0
  102. package/package.json +5 -2
  103. package/schemas/models/model-config-compatibility.v1.schema.json +4 -0
  104. package/tools/agents/deploy-agents.mjs +21 -1
  105. package/tools/agents/deploy-options.mjs +2 -0
  106. package/tools/agents/providers/base-contract.mjs +7 -1
  107. package/tools/agents/providers/base-inventory.mjs +41 -14
  108. package/tools/agents/providers/base-kernel-skills.mjs +9 -5
  109. package/tools/agents/providers/base-migrations.mjs +1 -0
  110. package/tools/agents/providers/base-skill-copy.mjs +9 -1
  111. package/tools/agents/providers/base.mjs +1 -1
  112. package/tools/agents/providers/claude.mjs +2 -1
  113. package/tools/agents/providers/codex.mjs +5 -1
  114. package/tools/agents/providers/conductor-data-guard.mjs +35 -11
  115. package/tools/agents/providers/flue-bundles.mjs +42 -0
  116. package/tools/agents/providers/flue-cloudflare.mjs +20 -0
  117. package/tools/agents/providers/flue-project.mjs +45 -6
  118. package/tools/agents/providers/flue-skill-copy.mjs +25 -0
  119. package/tools/agents/providers/flue-skills.mjs +45 -0
  120. package/tools/agents/providers/flue-specialists.mjs +36 -18
  121. package/tools/agents/providers/flue-validation.mjs +14 -0
  122. package/tools/agents/providers/flue.mjs +12 -8
  123. package/tools/agents/providers/hermes-skill-lifecycle.mjs +1 -0
  124. package/tools/agents/providers/muse-hooks.mjs +4 -0
  125. package/tools/agents/providers/muse-prompt-discovery.mjs +22 -0
  126. package/tools/agents/providers/provider-prepare-coordinator.mjs +15 -10
  127. package/tools/agents/providers/rule-delivery-surface.mjs +18 -1
  128. package/tools/agents/providers/rule-deployment-commit.mjs +24 -0
  129. package/tools/agents/providers/rule-deployment-prepare.mjs +4 -0
  130. package/tools/agents/providers/skill-copy-prune.mjs +49 -0
  131. package/tools/agents/providers/stale-artifact-prune.mjs +10 -8
  132. package/tools/ralph-external/lib/worker-capture.mjs +157 -0
  133. package/tools/ralph-external/lib/worker-health.mjs +3 -0
  134. package/tools/ralph-external/lib/worker-invocation-processes.mjs +9 -6
  135. package/tools/ralph-external/lib/worker-launch-cli.mjs +10 -1
  136. package/tools/ralph-external/lib/worker-process-identity.mjs +30 -0
  137. package/tools/ralph-external/lib/worker-retry-evidence.mjs +87 -6
  138. package/tools/ralph-external/lib/worker-termination.mjs +56 -6
  139. package/tools/ralph-external/process-monitor.mjs +12 -18
  140. package/tools/ralph-external/session-launcher.mjs +43 -29
  141. package/tools/skills/codex-skill-metadata.mjs +22 -0
  142. package/tools/skills/deploy-skills-codex.mjs +8 -7
  143. package/vscode-extension/schemas/aiwg.config.v1.json +59 -19
package/README.md CHANGED
@@ -225,6 +225,7 @@ AIWG publishes three packages in exact CalVer lockstep:
225
225
  | `@aiwg/cli` | Agentic runtimes, web-connected sessions, CI, and lightweight global use | Signed release host by default | `npm i -g @aiwg/cli` |
226
226
  | `aiwg` | Full local operation, framework deployment, authoring, offline-first projects | Bundled local corpus by default; web mode optional | `npm i -g aiwg` |
227
227
  | `@aiwg/cockpit` | Optional local control plane and operator UI | Installed separately or through the full CLI | `npm i -g @aiwg/cockpit` |
228
+ | `@aiwg/flue` | Flue app skills, specialists and MCP helpers | Installed in a Flue app | `npm install @aiwg/flue` |
228
229
 
229
230
  Choose `@aiwg/cli` when AIWG skills and agents need a small, globally available
230
231
  execution layer and can obtain resources from the signed web release. Choose
@@ -16,9 +16,10 @@ The default tools run the installed `aiwg mcp serve` in the app's launch directo
16
16
  For another trusted project or executable, call `createAiwgTools({ cwd, command, args, env })`
17
17
  at app setup and mount the returned tools. Configuration belongs to the app,
18
18
  never to model tool inputs. The app needs AIWG installed on PATH, Node 24+, and
19
- the tested Flue 2.3.0 graph: Valibot, `@modelcontextprotocol/client` 2.0.0 and
19
+ the tested Flue 2.3.0 graph: Valibot, `@modelcontextprotocol/client` 2.3.0 and
20
20
  its `/stdio` export. These are already present in the pinned lab graph; AIWG
21
21
  does not install dependencies or provide model credentials.
22
+ For an existing app, use the [MCP overrides in the setup guide](../../../../docs/providers/flue.md#package-mode).
22
23
 
23
24
  Each call owns a stdio child and closes it on success or failure. Initialization
24
25
  has a 10-second deadline and observes cancellation; transport cleanup can take
@@ -20,7 +20,6 @@ import path from 'node:path';
20
20
  import { readFileSync } from 'node:fs';
21
21
  import { fileURLToPath } from 'node:url';
22
22
  import { GRAPH_CONFIGS, OPERATIONAL_DISCOVERY_TYPES, OPERATIONAL_SHOW_TYPES, isOperationalShowType, loadUserGraphConfigs, loadGlobalGraphConfigs, orderedGraphEntries, } from './types.js';
23
- import { resolveIndexWorkers } from './index-preparation.js';
24
23
  import { SUPPORTED_VIEWS } from './corpus-views/renderers.js';
25
24
  import { parseResourceSelector, readVerifiedRegularFile, } from '../resources/web-release.js';
26
25
  import { findPackageRoot } from '../cli/find-package-root.js';
@@ -534,6 +533,7 @@ async function handleBuild(args) {
534
533
  console.log(' aiwg index sync --all');
535
534
  return;
536
535
  }
536
+ const { resolveIndexWorkers } = await import('./index-preparation.js');
537
537
  let workers;
538
538
  try {
539
539
  workers = resolveIndexWorkers(parseFlagValue(args, '--index-workers', 'Error: --index-workers requires a value'));
@@ -1467,7 +1467,7 @@ const DISCOVER_VALUE_FLAGS = new Set([
1467
1467
  async function handleDiscover(args) {
1468
1468
  const credentials = await prepareResourceCredentials(args);
1469
1469
  args = credentials.args;
1470
- const { discoverCapability } = await import('./query-engine.js');
1470
+ const { discoverCapability } = await import('./query-engine-discover.js');
1471
1471
  const cwd = process.cwd();
1472
1472
  // Parse the positional phrase. Flags may appear before or after it — the
1473
1473
  // documented local-backend fallback is written flag-first
@@ -1542,6 +1542,7 @@ async function handleDiscover(args) {
1542
1542
  offline,
1543
1543
  webReleaseOptions,
1544
1544
  includePaths: false,
1545
+ verbose: flags.includes('--verbose') || flags.includes('--debug'),
1545
1546
  });
1546
1547
  }
1547
1548
  /**
@@ -30,6 +30,7 @@
30
30
  *
31
31
  * @implements #1623 (U3)
32
32
  */
33
+ import { SESSION_FACETS } from './discover-session-facets.js';
33
34
  /**
34
35
  * The curated facet table. Kept deliberately small and legible — it is a
35
36
  * routing index, not a knowledge base. Guarded by the discover acceptance
@@ -37,6 +38,7 @@
37
38
  * metadata-completeness lint (empty triggers cannot recur).
38
39
  */
39
40
  export const DISCOVER_FACETS = [
41
+ ...SESSION_FACETS,
40
42
  {
41
43
  facet: 'authoring-surface',
42
44
  label: 'Expansion authoring (extension / addon / framework)',
@@ -0,0 +1,14 @@
1
+ export const SESSION_FACETS = [
2
+ {
3
+ facet: 'feature-domain', label: 'Session checkpoint and handoff',
4
+ intents: ['resume conductor handoff', 'continue session handoff', 'write session handoff',
5
+ 'create session handoff', 'resume interrupted work'],
6
+ capabilities: ['checkpoint'],
7
+ },
8
+ {
9
+ facet: 'feature-domain', label: 'Repair failing tests',
10
+ intents: ['fix failing test', 'repair failing tests', 'fix flaky tests'],
11
+ capabilities: ['flaky-fix', 'executable-feedback'],
12
+ },
13
+ ];
14
+ //# sourceMappingURL=discover-session-facets.js.map
@@ -136,7 +136,7 @@ function readVerifiedRegularFile(pathname, expectedSize, expectedSha256, label)
136
136
  fs.closeSync(fd);
137
137
  }
138
138
  }
139
- export function loadFortemiCoreExport(cwd, graph = "project", sourcePaths) {
139
+ export function loadFortemiCoreExport(cwd, graph = "project", sourcePaths, prebuiltSelection) {
140
140
  if (sourcePaths) {
141
141
  try {
142
142
  const manifestBytes = readVerifiedRegularFile(sourcePaths.manifestPath, sourcePaths.manifestSize, sourcePaths.manifestSha256, "Verified Fortemi Core manifest");
@@ -173,7 +173,7 @@ export function loadFortemiCoreExport(cwd, graph = "project", sourcePaths) {
173
173
  }
174
174
  // A content-validated shipped corpus does not need the source metadata index.
175
175
  // This also avoids preferring a much larger locally materialized text cache.
176
- if (graph === 'framework' && selectPrebuiltRelations(cwd).reader) {
176
+ if (graph === 'framework' && (prebuiltSelection ?? selectPrebuiltRelations(cwd)).reader) {
177
177
  const prebuilt = getFortemiCorePrebuiltStatus(graph, resolveFrameworkIndexRoot(cwd));
178
178
  if (prebuilt.built && !prebuilt.stale) {
179
179
  return { exported: JSON.parse(fs.readFileSync(prebuilt.exportPath, 'utf8')) };
@@ -289,8 +289,8 @@ function entryFromRecord(record) {
289
289
  operationalState: record.operational_state,
290
290
  };
291
291
  }
292
- export function loadFortemiCoreMetadataEntries(cwd, graph = "project", sourcePaths) {
293
- const loaded = loadFortemiCoreExport(cwd, graph, sourcePaths);
292
+ export function loadFortemiCoreMetadataEntries(cwd, graph = "project", sourcePaths, prebuiltSelection) {
293
+ const loaded = loadFortemiCoreExport(cwd, graph, sourcePaths, prebuiltSelection);
294
294
  if (!loaded.exported)
295
295
  return {
296
296
  entries: [],
@@ -36,7 +36,7 @@ function gitHead(root) {
36
36
  * receipt avoids rereading unchanged source contents and detects uncommitted
37
37
  * edits as well as manifest/package/HEAD changes.
38
38
  */
39
- function sourceFingerprint(root) {
39
+ function sourceFingerprint(root, sourceDigest) {
40
40
  const hash = createHash('sha256').update('framework-capabilities-v2');
41
41
  hash.update(path.resolve(root));
42
42
  try {
@@ -44,7 +44,7 @@ function sourceFingerprint(root) {
44
44
  }
45
45
  catch { /* fixture root */ }
46
46
  hash.update(gitHead(root));
47
- hash.update(frameworkSourceDigest(root));
47
+ hash.update(sourceDigest ?? frameworkSourceDigest(root));
48
48
  for (const kind of CORPUS_KINDS) {
49
49
  const dir = path.join(root, 'agentic/code', kind);
50
50
  let entries;
@@ -98,7 +98,7 @@ export async function refreshFrameworkCapabilities(root, syncFortemi = true, opt
98
98
  const fortemiSignature = () => [
99
99
  'manifest.json', 'aiwg-fortemi-index-v2.json',
100
100
  ].map(file => fileSignature(path.join(fortemiDir, file))).join('|');
101
- const source = sourceFingerprint(root);
101
+ const source = sourceFingerprint(root, options.sourceDigest);
102
102
  const current = () => ({
103
103
  source, index: fileSignature(metadataPath), relations: fileSignature(path.join(dir, 'relations.json')), ...(syncFortemi ? { fortemi: fortemiSignature() } : {}),
104
104
  });
@@ -158,6 +158,10 @@ export async function isCorpusBundleInstalled(cwd, root, kind, id) {
158
158
  const config = await readAiwgConfigCandidate(cwd);
159
159
  if (!config)
160
160
  return false;
161
+ // Every normal deployment includes aiwg-utils, even when only the requested
162
+ // framework is recorded. Standard skills are loaded from the source corpus.
163
+ if (kind === 'addon' && id === 'aiwg-utils' && Object.values(config.installed).some(entry => Object.values(entry.deployedTo ?? {}).some(deployment => deployment.skipUtils !== true)))
164
+ return true;
161
165
  if (config.installed[id] || (kind === 'framework' && config.installed.all))
162
166
  return true;
163
167
  try {
@@ -13,6 +13,7 @@ import fs from 'fs';
13
13
  import path from 'path';
14
14
  import { createHash } from 'crypto';
15
15
  import { load as loadYaml } from 'js-yaml';
16
+ import { normalizeNamedCaptures } from '../config/index-graph-overrides.js';
16
17
  import { validateDecisionDocument } from '../decision/validate.js';
17
18
  import { parseDecisionJson, parseDecisionYaml } from '../decision/entry.js';
18
19
  import { validateGateDocument } from '../gates/schema.js';
@@ -623,9 +624,7 @@ function computeChecksum(content) {
623
624
  /**
624
625
  * Convert Python-style named capture groups (?P<name>...) to JS-style (?<name>...)
625
626
  */
626
- export function normalizeNamedCaptures(pattern) {
627
- return pattern.replace(/\(\?P</g, '(?<');
628
- }
627
+ export { normalizeNamedCaptures } from '../config/index-graph-overrides.js';
629
628
  /**
630
629
  * Build a MetadataEntry from filename regex captures instead of file content.
631
630
  * Used when graphConfig.nodeStrategy === 'filename-metadata'.
@@ -6,7 +6,7 @@ import { boundRuleDescriptor, compoundGoverningRules, governingRuleFields, gover
6
6
  import { tokenize } from './query-engine-scoring.js';
7
7
  import { ensureRelations } from './relations.js';
8
8
  export async function emitDiscoverResults(context) {
9
- const { cwd, params, types, limit, aiwgRoot, entries, backend, resourceSource, resolvedWebRelease, prebuiltRelations, scored, relaxed, queryTimeMs, lexicalDiagnostics } = context;
9
+ const { cwd, params, types, limit, aiwgRoot, entries, backend, resourceSource, resolvedWebRelease, prebuiltRelations, prebuiltSelection, frameworkReconciled, scored, relaxed, queryTimeMs, lexicalDiagnostics } = context;
10
10
  /**
11
11
  * Resolve a stored framework-graph path to an absolute AIWG_ROOT
12
12
  * path (#1217). Framework-graph entries are stored as paths relative
@@ -43,7 +43,7 @@ export async function emitDiscoverResults(context) {
43
43
  : `No capability matched "${params.phrase}" among ${entries.length} indexed capabilities. Try a broader phrase or a \`--type\` filter. If you just installed or authored capabilities, refresh discovery with \`aiwg use <framework>\` (or \`aiwg index build\`).`
44
44
  : null;
45
45
  const relations = resourceSource === 'local' && (!params.graph || params.graph === 'framework')
46
- ? prebuiltRelations ?? await ensureRelations(cwd) : undefined;
46
+ ? prebuiltRelations ?? await ensureRelations(cwd, cwd, { verbose: params.verbose, selection: prebuiltSelection, reconciled: frameworkReconciled }) : undefined;
47
47
  const governing = scored.map(result => compoundGoverningRules(entries, result.entry, relations ?? undefined, params.phrase));
48
48
  const responseRules = new Map();
49
49
  for (const item of governing.flat()) {
@@ -90,7 +90,7 @@ export async function emitDiscoverResults(context) {
90
90
  };
91
91
  };
92
92
  const { loadRelations } = await import('./relations.js');
93
- const ruleRelations = resourceSource === 'local' ? loadRelations(cwd) ?? (aiwgRoot ? loadRelations(aiwgRoot, cwd) : null) : null;
93
+ const ruleRelations = relations ?? (resourceSource === 'local' ? loadRelations(cwd) ?? (aiwgRoot ? loadRelations(aiwgRoot, cwd) : null) : null);
94
94
  if (params.json) {
95
95
  const jsonIndent = params.jsonPretty === false ? undefined : 2;
96
96
  console.log(JSON.stringify({
@@ -1,4 +1,7 @@
1
- import { applyFacetFusion } from './discover-facets.js';
1
+ // Load and rank capability discovery candidates.
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { applyFacetFusion, diagnoseFacetActivations } from './discover-facets.js';
2
5
  import { refreshFrameworkCapabilities, resolveFrameworkCorpusRoot } from './framework-capabilities.js';
3
6
  import { resolveFrameworkIndexRoot } from './framework-index-paths.js';
4
7
  import { loadGraphIndexFile, loadMetadataIndex } from './index-reader.js';
@@ -6,7 +9,7 @@ import { emitDiscoverResults } from './query-engine-discover-output.js';
6
9
  import { compareDiscoverResults, dedupeDiscoverResults, DEFAULT_ARTIFACT_SEARCH_BACKEND, DEFAULT_DISCOVER_TYPES, defaultCapabilityGraphs, discoveryIdForEntry, isOrdinaryMemoryEntry, projectAllowsUserIndices, projectCapabilityFallback, withIndexProvenance, } from './query-engine-entries.js';
7
10
  import { scoreEntryDetailed } from './query-engine-scoring.js';
8
11
  import { emptyRuleStats, selectPrebuiltRelations } from './relations.js';
9
- import { loadGlobalGraphConfigs } from './types.js';
12
+ import { getGraphIndexDir, loadGlobalGraphConfigs } from './types.js';
10
13
  export async function discoverCapability(cwd, params) {
11
14
  loadGlobalGraphConfigs();
12
15
  const startTime = Date.now();
@@ -25,18 +28,24 @@ export async function discoverCapability(cwd, params) {
25
28
  // Source: prefer `framework` graph (built post-deploy), fall back to
26
29
  // project / codebase / legacy depending on what's available.
27
30
  let entries = [];
28
- const backend = params.backend ?? DEFAULT_ARTIFACT_SEARCH_BACKEND;
31
+ let localFramework = null;
32
+ const backend = params.promptContext ? 'local' : params.backend ?? DEFAULT_ARTIFACT_SEARCH_BACKEND;
29
33
  let fortemiCoreDiscoveryScores = null;
30
- let resourceSource = params.resourceSource ?? 'local';
34
+ let resourceSource = params.promptContext ? 'local' : params.resourceSource ?? 'local';
31
35
  let resolvedWebRelease;
32
36
  let verifiedSourcePaths;
33
- const prebuiltRelations = resourceSource !== 'web' && (!params.graph || params.graph === 'framework')
34
- ? selectPrebuiltRelations(cwd).reader : null;
35
- if ((!prebuiltRelations || backend === 'local') && resourceSource !== 'web' && (!params.graph || params.graph === 'framework')) {
37
+ const prebuiltSelection = resourceSource !== 'web' && (!params.graph || params.graph === 'framework')
38
+ ? selectPrebuiltRelations(cwd, cwd, !params.promptContext) : undefined;
39
+ const prebuiltRelations = prebuiltSelection?.reader ?? null;
40
+ // A valid prebuilt relationship package means the shipped index is current:
41
+ // never build a per-root framework index beside it (#3308, #2069 test).
42
+ if (!params.promptContext && (!prebuiltRelations || backend === 'local') && resourceSource !== 'web' && (!params.graph || params.graph === 'framework')) {
36
43
  const root = resolveFrameworkCorpusRoot(cwd) ?? aiwgRoot;
37
44
  if (root) {
38
45
  try {
39
- await refreshFrameworkCapabilities(root, backend === 'fortemi-core');
46
+ await refreshFrameworkCapabilities(root, false, { sourceDigest: prebuiltSelection?.sourceDigest });
47
+ if (resolveFrameworkCorpusRoot(root))
48
+ localFramework = loadGraphIndexFile(cwd, 'metadata.json', 'framework');
40
49
  }
41
50
  catch (error) {
42
51
  console.error(`Warning: capability index refresh failed: ${error instanceof Error ? error.message : String(error)}`);
@@ -85,9 +94,24 @@ export async function discoverCapability(cwd, params) {
85
94
  const graphs = resourceSource === 'web'
86
95
  ? ['framework']
87
96
  : params.graph ? [params.graph] : defaultCapabilityGraphs(cwd);
88
- const { loadFortemiCoreMetadataEntries, queryFortemiCoreAiwgDiscovery, } = await import('./fortemi-core-query-adapter.js');
89
97
  let unavailableReason;
90
98
  for (const graph of graphs) {
99
+ // Discovery ranks metadata, not full document bodies. A reconciled local
100
+ // framework index avoids parsing the much larger fulltext export.
101
+ if (graph === 'framework' && localFramework) {
102
+ entries.push(...Object.values(localFramework.entries).map(entry => withIndexProvenance(entry, graph)));
103
+ continue;
104
+ }
105
+ if (resourceSource === 'local' && !params.graph && graph !== 'framework') {
106
+ const directory = getGraphIndexDir(cwd, graph);
107
+ if (!fs.existsSync(path.join(directory, 'metadata.json'))
108
+ && !fs.existsSync(path.join(path.dirname(directory), 'fortemi-core', graph, 'manifest.json'))) {
109
+ if (graph === 'project')
110
+ entries.push(...(projectCapabilityFallback(cwd) ?? []));
111
+ continue;
112
+ }
113
+ }
114
+ const { loadFortemiCoreMetadataEntries, queryFortemiCoreAiwgDiscovery } = await import('./fortemi-core-query-adapter.js');
91
115
  const loaded = loadFortemiCoreMetadataEntries(cwd, graph, verifiedSourcePaths);
92
116
  if (loaded.reason && graph === 'project' && !params.graph) {
93
117
  const fallback = projectCapabilityFallback(cwd);
@@ -193,6 +217,19 @@ export async function discoverCapability(cwd, params) {
193
217
  entries.push(...Object.values(legacy.entries));
194
218
  }
195
219
  }
220
+ if (params.promptContext && prebuiltRelations) {
221
+ // Reuse the validated shipped export without refreshing or persisting receipts.
222
+ const { loadFortemiCoreMetadataEntries } = await import('./fortemi-core-query-adapter.js');
223
+ const loaded = loadFortemiCoreMetadataEntries(cwd, 'framework', undefined, prebuiltSelection);
224
+ if (loaded.entries.length) {
225
+ entries = entries.filter(entry => !('indexGraph' in entry && entry.indexGraph === 'framework'));
226
+ entries.push(...loaded.entries.map(entry => withIndexProvenance(entry, 'framework')));
227
+ }
228
+ }
229
+ if (entries.length === 0 && params.promptContext) {
230
+ console.log(JSON.stringify({ results: [] }));
231
+ return;
232
+ }
196
233
  if (entries.length === 0 && backend !== 'fortemi-core') {
197
234
  // Empty-index case (#1221). Surface a hint that explains the gap rather
198
235
  // than returning a bare zero-result envelope — the latter trains agents
@@ -221,10 +258,11 @@ export async function discoverCapability(cwd, params) {
221
258
  // fusion below can inject/lift curated capabilities into the top-K before
222
259
  // truncation — a capability that the lexical pass ranked outside `limit`
223
260
  // (or missed entirely) still surfaces when the query activates its facet.
261
+ const personaIdentitySuppressed = diagnoseFacetActivations(params.phrase).some(activation => activation.facet === 'persona-identity' && activation.status === 'suppressed');
224
262
  const lexicalDiagnostics = new Map();
225
263
  const legacyStrictScored = candidates
226
264
  .map(entry => {
227
- const detailed = scoreEntryDetailed(entry, params.phrase);
265
+ const detailed = scoreEntryDetailed(entry, params.phrase, { personaIdentitySuppressed });
228
266
  const legacyScore = detailed.score;
229
267
  const fortemiScore = fortemiCoreDiscoveryScores?.get(entry.path) ?? 0;
230
268
  lexicalDiagnostics.set(entry.path, detailed.diagnostic);
@@ -245,8 +283,8 @@ export async function discoverCapability(cwd, params) {
245
283
  // top-K instead of being out-scored by artifacts that merely mention the
246
284
  // word. Facet activation can also rescue an otherwise-empty strict pass.
247
285
  // #154 — a strict result anywhere in the corpus must not suppress relevant
248
- // partial matches for a natural-language query. Score the relaxed pass on
249
- // matched terms (unmatched terms do not divide the score), apply a noise
286
+ // partial matches for a natural-language query. Score the relaxed pass with
287
+ // query coverage (so weak hits cannot saturate), apply a noise
250
288
  // floor, and union it with strict matches before ranking. Word-boundary
251
289
  // token matching keeps this from resurrecting substring noise such as UX in
252
290
  // Linux.
@@ -254,7 +292,7 @@ export async function discoverCapability(cwd, params) {
254
292
  const strictPaths = new Set(strictScored.map(result => result.entry.path));
255
293
  const combinedByPath = new Map(strictScored.map(result => [result.entry.path, result]));
256
294
  for (const entry of candidates) {
257
- const detailed = scoreEntryDetailed(entry, params.phrase, { relaxOverlap: true });
295
+ const detailed = scoreEntryDetailed(entry, params.phrase, { relaxOverlap: true, personaIdentitySuppressed });
258
296
  if (detailed.score < RELAXED_MIN_SCORE)
259
297
  continue;
260
298
  const existing = combinedByPath.get(entry.path);
@@ -279,7 +317,16 @@ export async function discoverCapability(cwd, params) {
279
317
  }
280
318
  }
281
319
  const queryTimeMs = Date.now() - startTime;
320
+ if (params.promptContext) {
321
+ console.log(JSON.stringify({ results: scored.map(({ entry, score }) => ({
322
+ type: entry.type, name: entry.name ?? discoveryIdForEntry(entry),
323
+ capability: entry.type === 'rule'
324
+ ? entry.ruleSummary || prebuiltRelations?.index.rules[discoveryIdForEntry(entry)]?.summary || entry.summary
325
+ : entry.capability ?? entry.summary, score,
326
+ })) }));
327
+ return;
328
+ }
282
329
  await emitDiscoverResults({ cwd, params, types, limit, aiwgRoot, entries, backend, resourceSource,
283
- resolvedWebRelease, prebuiltRelations, scored, relaxed, queryTimeMs, lexicalDiagnostics });
330
+ resolvedWebRelease, prebuiltRelations, prebuiltSelection, frameworkReconciled: Boolean(localFramework), scored, relaxed, queryTimeMs, lexicalDiagnostics });
284
331
  }
285
332
  //# sourceMappingURL=query-engine-discover.js.map
@@ -4,7 +4,7 @@ import * as path from 'node:path';
4
4
  import { projectAiwgPath, projectControlPath } from '../config/project-artifacts.js';
5
5
  import { recordTypeForEntry, stableRecordId } from './browser-export.js';
6
6
  import { loadGraphIndexFile } from './index-reader.js';
7
- import { isOperationalShowType, OPERATIONAL_DISCOVERY_TYPES } from './types.js';
7
+ import { getGraphIndexDir, isOperationalShowType, OPERATIONAL_DISCOVERY_TYPES } from './types.js';
8
8
  export function normalizeIndexedPath(entryPath) {
9
9
  return entryPath.replace(/\\/g, '/');
10
10
  }
@@ -57,16 +57,59 @@ export function withIndexProvenance(entry, graph) {
57
57
  /** Keep existing project capabilities visible while their derived cache is unavailable. */
58
58
  export function projectCapabilityFallback(cwd) {
59
59
  const index = loadGraphIndexFile(cwd, 'metadata.json', 'project');
60
- if (index) {
61
- const entries = Object.values(index.entries).map((entry) => withIndexProvenance(entry, 'project'));
62
- if (entries.length > 0) {
63
- // One diagnostic per command, on stderr so JSON and skill bodies stay parseable.
64
- console.error('Warning: project capability cache is unavailable or stale; using the local project index. Run `aiwg index sync` to repair the cache.');
65
- return entries;
60
+ const receipt = path.join(getGraphIndexDir(cwd, 'project'), 'capability-warning.json');
61
+ if (index && Object.keys(index.entries).length) {
62
+ // Metadata fallback preserves every discovery candidate; results are intact.
63
+ try {
64
+ fs.rmSync(receipt, { force: true });
66
65
  }
66
+ catch { /* read-only cache */ }
67
+ return Object.values(index.entries).map(entry => withIndexProvenance(entry, 'project'));
67
68
  }
68
- if (['extensions', 'addons', 'frameworks', 'plugins', 'skills'].some((dir) => fs.existsSync(projectAiwgPath(cwd, dir)))) {
69
- console.error('Warning: project capabilities could not be loaded: the cache is unavailable and the local project index is missing or empty. Run `aiwg index build --graph project` to repair discovery.');
69
+ const sources = [];
70
+ const scan = (directory) => {
71
+ let children;
72
+ try {
73
+ children = fs.readdirSync(directory, { withFileTypes: true });
74
+ }
75
+ catch {
76
+ return;
77
+ }
78
+ for (const child of children) {
79
+ if (child.name.startsWith('.') || child.isSymbolicLink())
80
+ continue;
81
+ const file = path.join(directory, child.name);
82
+ if (child.isDirectory())
83
+ scan(file);
84
+ else if (/\.(?:md|ya?ml|json)$/.test(child.name) && !['registry.json', 'manifest.json'].includes(child.name)) {
85
+ const stat = fs.statSync(file);
86
+ sources.push(`${file}:${stat.size}:${stat.mtimeMs}:${stat.ctimeMs}`);
87
+ }
88
+ }
89
+ };
90
+ for (const dir of ['extensions', 'addons', 'frameworks', 'plugins', 'skills'])
91
+ scan(projectAiwgPath(cwd, dir));
92
+ if (sources.length) {
93
+ const state = JSON.stringify(sources.sort());
94
+ let previous = '';
95
+ try {
96
+ previous = fs.readFileSync(receipt, 'utf8');
97
+ }
98
+ catch { /* first degraded lookup */ }
99
+ if (previous !== state) {
100
+ console.error('Warning: project capabilities could not be loaded: the cache is unavailable and the local project index is missing or empty. Run `aiwg index build --graph project` to repair discovery.');
101
+ try {
102
+ fs.mkdirSync(path.dirname(receipt), { recursive: true });
103
+ fs.writeFileSync(receipt, state);
104
+ }
105
+ catch { /* Diagnostics must also work with read-only caches. */ }
106
+ }
107
+ }
108
+ else {
109
+ try {
110
+ fs.rmSync(receipt, { force: true });
111
+ }
112
+ catch { /* read-only cache */ }
70
113
  }
71
114
  return index ? [] : null;
72
115
  }
@@ -0,0 +1,27 @@
1
+ // Resolve artifact availability from provider deployment paths and bundle records.
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import os from 'node:os';
5
+ import { isCorpusBundleInstalled } from './framework-capabilities.js';
6
+ export async function isArtifactInstalled(cwd, root, entry, kind, bundle) {
7
+ if (entry.type === 'skill') {
8
+ const normalized = entry.path.replace(/\\/g, '/');
9
+ const slug = path.posix.basename(normalized) === 'SKILL.md'
10
+ ? path.posix.basename(path.posix.dirname(normalized)) : path.posix.basename(normalized, '.md');
11
+ const { listProviderDeploymentLayouts, resolveProviderPathValue } = await import('../providers/provider-definitions.js');
12
+ for (const provider of listProviderDeploymentLayouts()) {
13
+ const roots = [provider.paths.kernelSkills, provider.paths.artifacts.skills, provider.paths.contextDiscovery?.skills,
14
+ provider.smithPaths?.skills];
15
+ for (const base of [cwd, os.homedir()])
16
+ for (const relative of roots) {
17
+ if (!relative)
18
+ continue;
19
+ const directory = resolveProviderPathValue(relative, base);
20
+ if (fs.existsSync(path.join(directory, slug, 'SKILL.md')))
21
+ return true;
22
+ }
23
+ }
24
+ }
25
+ return isCorpusBundleInstalled(cwd, root, kind, bundle);
26
+ }
27
+ //# sourceMappingURL=query-engine-installation.js.map
@@ -2,7 +2,6 @@
2
2
  import { minimatch } from 'minimatch';
3
3
  import * as path from 'node:path';
4
4
  import { inferRuleActivation } from '../rules/activation.mjs';
5
- import { parseFrontmatter } from './index-builder.js';
6
5
  import { discoveryIdForEntry, normalizeIndexedPath } from './query-engine-entries.js';
7
6
  import { emptyRuleStats } from './relations.js';
8
7
  /** Build an ephemeral reverse lookup from the already-loaded rule metadata. */
@@ -159,7 +158,7 @@ export async function showBindings(entries, target, content, params, read, relat
159
158
  })));
160
159
  // Parse the selected rule for reverse lookup, including corpus-only rules.
161
160
  const targets = target.type === 'rule' || target.type === 'behavior'
162
- ? parseFrontmatter(content).data.bound_to : undefined;
161
+ ? (await import('./index-builder.js')).parseFrontmatter(content).data.bound_to : undefined;
163
162
  const boundTo = targets && typeof targets === 'object' && !Array.isArray(targets)
164
163
  ? Object.fromEntries(['skills', 'agents', 'flows'].flatMap(key => {
165
164
  const values = targets[key];
@@ -68,12 +68,23 @@ export function tokenize(text) {
68
68
  ? token.slice(0, -1)
69
69
  : token);
70
70
  }
71
+ const fieldTokenCache = new Map();
72
+ function fieldTokens(field) {
73
+ let tokens = fieldTokenCache.get(field);
74
+ if (!tokens) {
75
+ tokens = tokenize(field);
76
+ fieldTokenCache.set(field, tokens);
77
+ if (fieldTokenCache.size > 20_000)
78
+ fieldTokenCache.clear();
79
+ }
80
+ return tokens;
81
+ }
71
82
  export function matchedFieldTokens(queryTokens, field) {
72
- const fieldTokens = new Set(tokenize(field));
73
- return queryTokens.filter(token => fieldTokens.has(token));
83
+ const available = new Set(fieldTokens(field));
84
+ return queryTokens.filter(token => available.has(token));
74
85
  }
75
86
  export function fieldContainsQuery(field, queryTokens) {
76
- return containsTokenSequence(tokenize(field), queryTokens);
87
+ return containsTokenSequence(fieldTokens(field), queryTokens);
77
88
  }
78
89
  /**
79
90
  * Score a metadata entry against a keyword query.
@@ -154,22 +165,17 @@ export function nearNameMatch(query, name) {
154
165
  });
155
166
  }
156
167
  export function scoreEntryDetailed(entry, text, opts = {}) {
157
- const tokens = tokenize(text);
158
168
  // Field substring matching uses the stopword-stripped CONTENT phrase, not the
159
- // raw query (#1581). Without this, a query that reduces to a single content
160
- // token — e.g. "intake skill" or "find an intake skill" → ["intake"] — sets
161
- // useMultiToken=false (1 token) and then fails the full-string `.includes()`
162
- // checks because the raw phrase ("intake skill") isn't a substring of any
163
- // field, while the one meaningful token is never matched. Joining the content
164
- // tokens restores the invariant that a single content token IS the phrase, and
165
- // for multi-token queries gives a tighter (content-only) phrase to match.
166
- // Pure-stopword queries fall back to the raw text.
169
+ // raw query (#1581): a query that reduces to one content token ("intake skill"
170
+ // -> ["intake"]) must still match that token. Pure-stopword queries fall back
171
+ // to the raw text. Tokens are de-duplicated so a repeated word is credited once.
172
+ const tokens = [...new Set(tokenize(text))];
167
173
  const lower = tokens.length > 0 ? tokens.join(' ') : text.toLowerCase().trim();
168
174
  const rawLower = text.toLowerCase().trim();
169
- const personaIdentitySuppressed = diagnoseFacetActivations(text).some((activation) => activation.facet === 'persona-identity' && activation.status === 'suppressed');
175
+ const personaIdentitySuppressed = opts.personaIdentitySuppressed ?? diagnoseFacetActivations(text).some((activation) => activation.facet === 'persona-identity' && activation.status === 'suppressed');
170
176
  let score = 0;
171
177
  const matches = [];
172
- const creditedTokens = new Set();
178
+ const creditedTokens = new Map();
173
179
  const finish = (uncappedScore = score, cap = 1) => ({
174
180
  score: Math.min(uncappedScore, cap),
175
181
  diagnostic: {
@@ -185,27 +191,23 @@ export function scoreEntryDetailed(entry, text, opts = {}) {
185
191
  matches.push({ ...match, contribution });
186
192
  };
187
193
  const addTokenMatch = (contributionPerToken, hits, match) => {
188
- const newlyMatched = hits.filter(token => !creditedTokens.has(token));
194
+ // Isolated trigger tokens need query coverage; coherent multiword triggers
195
+ // retain their weight. Later stronger fields can upgrade earlier weak hits.
196
+ const denominator = match.field === 'trigger' && hits.length === 1 ? Math.max(1, tokens.length) : 1;
197
+ const weight = contributionPerToken / denominator;
198
+ const newlyMatched = hits.filter(token => weight > (creditedTokens.get(token) ?? 0));
189
199
  if (newlyMatched.length === 0)
190
200
  return;
191
- newlyMatched.forEach(token => creditedTokens.add(token));
192
- addMatch(contributionPerToken * newlyMatched.length, {
201
+ const contribution = newlyMatched.reduce((sum, token) => sum + weight - (creditedTokens.get(token) ?? 0), 0);
202
+ newlyMatched.forEach(token => creditedTokens.set(token, weight));
203
+ addMatch(contribution, {
193
204
  ...match,
194
205
  matched_tokens: newlyMatched,
195
206
  query_token_coverage: tokens.length > 0 ? newlyMatched.length / tokens.length : 0,
196
207
  });
197
208
  };
198
- // Exact-name floor (#1233) — if the query (normalized) exactly matches
199
- // the entry's canonical name, this is the artifact the user is asking
200
- // for and it must surface at the top regardless of how cluttered the
201
- // rest of the corpus scoring gets. Hyphens, underscores, and whitespace
202
- // are interchangeable in the comparison so `aiwg-doctor`, `aiwg doctor`,
203
- // and `aiwg_doctor` all match a kernel skill with `name: aiwg-doctor`.
204
- //
205
- // Returns 1.001 (not 1.0) so an exact-name hit sorts above the many
206
- // capped-at-1.0 substring matches that share generic words like "use".
207
- // Display rounding (Math.round(score * 100) / 100) hides the offset, so
208
- // the user still sees `score: 1.0` while sort order is preserved.
209
+ // Exact and near-name floors preserve deliberate artifact selection. The
210
+ // 1.001 offset sorts exact names above capped lexical matches (display: 1.0).
209
211
  if (entry.name) {
210
212
  const queryNorm = normalizeName(text);
211
213
  const nameNorm = normalizeName(entry.name);
@@ -261,7 +263,7 @@ export function scoreEntryDetailed(entry, text, opts = {}) {
261
263
  // phrase wins big; substring or token-overlap is still strong.
262
264
  if (triggersLower.length > 0) {
263
265
  for (const trigger of triggersLower) {
264
- const triggerTokens = tokenize(trigger);
266
+ const triggerTokens = fieldTokens(trigger);
265
267
  const matchedTokens = tokens.filter((token) => triggerTokens.includes(token));
266
268
  const queryCoverage = tokens.length > 0 ? matchedTokens.length / tokens.length : 0;
267
269
  if (trigger === lower || trigger === rawLower) {
@@ -295,8 +297,8 @@ export function scoreEntryDetailed(entry, text, opts = {}) {
295
297
  const contribution = suppressedGenericPersona
296
298
  ? 0.24 * queryCoverage
297
299
  : triggerTokens.length > 1
298
- ? Math.min(1, 0.75 + 0.25 * containedCoverage)
299
- : 1;
300
+ ? (0.75 + 0.25 * containedCoverage) * queryCoverage
301
+ : queryCoverage;
300
302
  addMatch(contribution, {
301
303
  field: 'trigger',
302
304
  match: 'contained-phrase',
@@ -1,7 +1,7 @@
1
1
  // Render show metadata cards, sections, and companion resources.
2
2
  import * as fs from 'node:fs';
3
3
  import * as path from 'node:path';
4
- import { isCorpusBundleInstalled } from './framework-capabilities.js';
4
+ import { isArtifactInstalled } from './query-engine-installation.js';
5
5
  import { extractMarkdownLinks, parseFlowDoc, parseFrontmatter } from './index-builder.js';
6
6
  import { buildRunHint, discoveryIdForEntry, normalizeIndexedPath } from './query-engine-entries.js';
7
7
  import { RULE_CHECK_OBLIGATION, statsText } from './query-engine-rules.js';
@@ -116,7 +116,7 @@ export async function emitShowCard(cwd, aiwgRoot, entry, filePath, source, param
116
116
  const owner = normalizeIndexedPath(entry.path).match(/(?:^|\/)(?:agentic\/code|\.aiwg)\/(frameworks|addons|extensions)\/([^/]+)\//);
117
117
  const kind = owner ? { frameworks: 'framework', addons: 'addon', extensions: 'extension' }[owner[1]] : null;
118
118
  const installed = local && (owner && aiwgRoot
119
- ? await isCorpusBundleInstalled(cwd, aiwgRoot, kind, owner[2]) : true);
119
+ ? await isArtifactInstalled(cwd, aiwgRoot, entry, kind, owner[2]) : true);
120
120
  const resources = local || release ? showResources(filePath, source, release) : [];
121
121
  const resource = params.resource ? resources.find(resource => resource.path === params.resource) : undefined;
122
122
  if (params.resource && !resource)
@@ -158,6 +158,8 @@ export async function emitShowCard(cwd, aiwgRoot, entry, filePath, source, param
158
158
  resources: `${command} --resources`, resource: resources.map(resource => `${command} --resource ${quote(resource.path)}`),
159
159
  body: `${command} --body`,
160
160
  },
161
+ ...(!installed ? { load_hint: `Read the component with \`${command} --body\`.`
162
+ + (owner ? ` Deploy it with \`aiwg use ${owner[2]}\`.` : '') } : {}),
161
163
  ...extra,
162
164
  ...(params.body || selected.length ? { content: params.body ? source : selected.join('\n') } : {}),
163
165
  ...(resource ? { resource: { ...resource, body: resourceBody } } : {}),
@@ -182,6 +184,8 @@ export async function emitShowCard(cwd, aiwgRoot, entry, filePath, source, param
182
184
  }
183
185
  const lines = [`# ${card.type}: ${card.name}`, `ID: ${card.id}`, card.description,
184
186
  `Owner: ${card.capability ? `${card.capability.kind}:${card.capability.name}` : 'project/unowned'} | installed: ${card.installed}`, statsText(card.rule_stats)];
187
+ if (card.load_hint)
188
+ lines.push(card.load_hint);
185
189
  if (pinNote)
186
190
  lines.push(pinNote);
187
191
  if ('activation' in card)