@aiwg/cli 2026.10.11 → 2026.10.14

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 (174) hide show
  1. package/agentic/code/providers/model-catalog.v1.json +62 -12
  2. package/agentic/code/providers/pi/aiwg-bridge.ts +44 -1
  3. package/dist/src/artifacts/binding-target-identity.js +51 -0
  4. package/dist/src/artifacts/checksum-manifest.js +12 -0
  5. package/dist/src/artifacts/index-builder.js +11 -13
  6. package/dist/src/artifacts/query-engine.js +5 -11
  7. package/dist/src/cli/handlers/doctor-help.js +32 -0
  8. package/dist/src/cli/handlers/gates.js +19 -18
  9. package/dist/src/cli/handlers/models-help.js +7 -1
  10. package/dist/src/cli/handlers/models.js +3 -3
  11. package/dist/src/cli/handlers/script-runner.js +8 -5
  12. package/dist/src/cli/handlers/sessions-intake.js +104 -0
  13. package/dist/src/cli/handlers/sessions-tail.js +172 -0
  14. package/dist/src/cli/handlers/sessions.js +90 -17
  15. package/dist/src/cli/handlers/skill-lint.js +10 -3
  16. package/dist/src/cli/handlers/steward-format.js +100 -0
  17. package/dist/src/cli/handlers/steward-models.js +167 -0
  18. package/dist/src/cli/handlers/steward.js +14 -248
  19. package/dist/src/cli/handlers/use-bundle-counts.js +87 -0
  20. package/dist/src/cli/handlers/use-skill-assets.js +207 -0
  21. package/dist/src/cli/handlers/use.js +35 -216
  22. package/dist/src/cli/handlers/utilities.js +1 -24
  23. package/dist/src/config/aiwg-config.js +7 -0
  24. package/dist/src/config/authorization-cli.js +97 -0
  25. package/dist/src/config/cli-help.js +1 -0
  26. package/dist/src/config/cli.js +10 -1
  27. package/dist/src/decision/context-pruning-common.js +41 -0
  28. package/dist/src/decision/context-pruning-evaluation.js +366 -0
  29. package/dist/src/decision/context-pruning-pilot.js +431 -0
  30. package/dist/src/decision/context-pruning-types.js +19 -0
  31. package/dist/src/decision/context-pruning.js +5 -846
  32. package/dist/src/decision/ensemble/contract.js +17 -26
  33. package/dist/src/decision/ensemble-study/artifacts.js +5 -0
  34. package/dist/src/decision/ensemble-study/score.js +4 -3
  35. package/dist/src/decision/feature-export.js +3 -9
  36. package/dist/src/decision/heldout/collector.js +2 -2
  37. package/dist/src/decision/issue-triage/runtime.js +3 -9
  38. package/dist/src/decision/qualification/gates.js +2 -1
  39. package/dist/src/decision/qualification/release.js +6 -64
  40. package/dist/src/decision/routing/report.js +2 -0
  41. package/dist/src/decision/sdlc-screening.js +3 -5
  42. package/dist/src/decision/sensitivity/comparative.js +5 -3
  43. package/dist/src/extensions/manifest.js +8 -1
  44. package/dist/src/extensions/project-local-doctor.js +78 -2
  45. package/dist/src/extensions/validation.js +10 -11
  46. package/dist/src/gates/driver.js +6 -77
  47. package/dist/src/gates/evaluate.js +6 -23
  48. package/dist/src/gates/floors.js +4 -4
  49. package/dist/src/gates/index.js +3 -3
  50. package/dist/src/gates/lattice.js +26 -0
  51. package/dist/src/gates/registry.js +2 -1
  52. package/dist/src/gates/report.js +19 -7
  53. package/dist/src/gates/upstream-ceiling.js +111 -0
  54. package/dist/src/issues/audit-cli.js +120 -0
  55. package/dist/src/issues/audit-contract.js +64 -0
  56. package/dist/src/issues/audit-local.js +82 -0
  57. package/dist/src/issues/audit.js +220 -0
  58. package/dist/src/lint/rule-activation.js +15 -1
  59. package/dist/src/mission-protocol/canonical-codecs.js +270 -0
  60. package/dist/src/mission-protocol/codecs.js +22 -550
  61. package/dist/src/mission-protocol/health-trace-codecs.js +281 -0
  62. package/dist/src/mission-protocol/health-trace-types.js +43 -0
  63. package/dist/src/mission-protocol/types.js +2 -42
  64. package/dist/src/mission-protocol/worker-contract-json.js +10 -0
  65. package/dist/src/mission-protocol/worker-review-gate.js +100 -0
  66. package/dist/src/mission-protocol/worker-review-types.js +2 -0
  67. package/dist/src/models/catalog-policy.js +280 -0
  68. package/dist/src/models/index.js +1 -1
  69. package/dist/src/models/model-catalog.v1.json +62 -12
  70. package/dist/src/models/policy-resources.js +28 -0
  71. package/dist/src/models/provider-models.js +5 -8
  72. package/dist/src/models/provider-policy.js +10 -546
  73. package/dist/src/models/resolver.js +26 -8
  74. package/dist/src/models/router.js +15 -2
  75. package/dist/src/models/tiers.js +13 -0
  76. package/dist/src/models/types.js +0 -6
  77. package/dist/src/models/worker-ceilings.js +59 -0
  78. package/dist/src/models/worker-invocation-policy.js +243 -0
  79. package/dist/src/models/worker-plan.js +16 -20
  80. package/dist/src/models/worker-review-lineage.js +55 -0
  81. package/dist/src/models/worker-selection-policy.js +1 -1
  82. package/dist/src/models/wrapper-definitions.js +14 -0
  83. package/dist/src/models/wrapper-deployment.js +48 -25
  84. package/dist/src/models/wrapper-enforcement.js +72 -0
  85. package/dist/src/models/wrapper-route.js +6 -3
  86. package/dist/src/policy/authorization.js +1 -0
  87. package/dist/src/policy/hitl-check.js +80 -0
  88. package/dist/src/policy/hitl-config.js +63 -0
  89. package/dist/src/policy/hitl-receipt.js +57 -0
  90. package/dist/src/policy/hitl-types.js +4 -0
  91. package/dist/src/policy/hitl-validation.js +39 -0
  92. package/dist/src/policy/hitl.js +117 -0
  93. package/dist/src/rules/activation.d.mts +3 -1
  94. package/dist/src/rules/activation.mjs +23 -2
  95. package/dist/src/rules/gate-coverage.js +51 -0
  96. package/dist/src/rules/gate-references.js +16 -0
  97. package/dist/src/rules/rule-frontmatter.schema.json +7 -1
  98. package/dist/src/serve/worker-command-request.js +21 -4
  99. package/dist/src/serve/worker-invocation-preparation.js +3 -1
  100. package/dist/src/serve/worker-invocation.js +21 -10
  101. package/dist/src/sessions/adapters/deepseek-harness.js +1 -0
  102. package/dist/src/sessions/adapters/grok-build-native.js +269 -0
  103. package/dist/src/sessions/adapters/grok-build.js +57 -15
  104. package/dist/src/sessions/adapters/hermes-state-db.js +252 -0
  105. package/dist/src/sessions/adapters/hermes.js +42 -3
  106. package/dist/src/sessions/adapters/warp.js +1 -1
  107. package/dist/src/sessions/batch-import.js +10 -0
  108. package/dist/src/sessions/contracts.js +1 -1
  109. package/dist/src/sessions/discovery-capability.js +38 -0
  110. package/dist/src/sessions/importer.js +8 -251
  111. package/dist/src/sessions/index.js +4 -0
  112. package/dist/src/sessions/intake-dir.js +71 -0
  113. package/dist/src/sessions/normalization.js +251 -0
  114. package/dist/src/sessions/tail.js +91 -0
  115. package/dist/src/sessions/workspace-discovery.js +83 -7
  116. package/dist/src/skills/adapters/local.js +32 -9
  117. package/dist/src/skills/agent-skill-sidecar.js +28 -0
  118. package/dist/src/skills/agent-skills.js +6 -23
  119. package/dist/src/skills/claude-surface-projection.js +25 -0
  120. package/dist/src/skills/cli-display.js +33 -0
  121. package/dist/src/skills/cli.js +2 -26
  122. package/dist/src/skills/collision-discovery.js +84 -0
  123. package/dist/src/skills/deployer.js +26 -361
  124. package/dist/src/skills/deployment-ownership.js +74 -0
  125. package/dist/src/skills/deployment-policy.js +114 -0
  126. package/dist/src/skills/deployment-projection.js +152 -0
  127. package/dist/src/skills/deployment-types.js +20 -0
  128. package/dist/src/skills/doctor.js +2 -2
  129. package/dist/src/skills/exporter.js +8 -31
  130. package/dist/src/skills/importer.js +4 -26
  131. package/dist/src/skills/provider-extensions.js +41 -0
  132. package/dist/src/skills/registry.js +22 -7
  133. package/dist/src/skills/run.js +6 -0
  134. package/dist/src/skills/types.js +0 -8
  135. package/dist/src/skills/validator-resources.js +68 -0
  136. package/dist/src/skills/validator.js +6 -55
  137. package/dist/src/smiths/context-pipeline/parallelism-section.js +7 -3
  138. package/dist/src/storage/cli-migrate-options.js +125 -0
  139. package/dist/src/storage/cli-migrate.js +111 -0
  140. package/dist/src/storage/cli.js +4 -279
  141. package/dist/src/storage/migration-adapter.js +79 -0
  142. package/dist/src/storage/migration-copy.js +108 -0
  143. package/dist/src/storage/migration-protocol.js +14 -197
  144. package/dist/src/storage/migration-records.js +186 -0
  145. package/dist/src/storage/migration-types.js +12 -0
  146. package/dist/src/tracker/forge-http.js +2 -1
  147. package/dist/src/tracker/issue-pages.js +110 -0
  148. package/package.json +3 -1
  149. package/schemas/mission-v1.schema.json +335 -0
  150. package/schemas/models/model-catalog.v1.schema.json +19 -1
  151. package/schemas/models/model-config-compatibility.v1.schema.json +3 -2
  152. package/schemas/models/model-policy.v1.schema.json +1 -1
  153. package/tools/agents/providers/antigravity.mjs +3 -5
  154. package/tools/agents/providers/base.mjs +3 -3
  155. package/tools/agents/providers/claude.mjs +3 -5
  156. package/tools/agents/providers/codex.mjs +3 -5
  157. package/tools/agents/providers/copilot.mjs +3 -5
  158. package/tools/agents/providers/cursor.mjs +3 -5
  159. package/tools/agents/providers/factory.mjs +3 -5
  160. package/tools/agents/providers/grok-build.mjs +9 -7
  161. package/tools/agents/providers/model-wrapper.mjs +86 -0
  162. package/tools/agents/providers/omp.mjs +3 -1
  163. package/tools/agents/providers/openclaw.mjs +3 -5
  164. package/tools/agents/providers/opencode.mjs +3 -5
  165. package/tools/agents/providers/provider-paths-staging.mjs +44 -0
  166. package/tools/agents/providers/rule-binding-targets.mjs +146 -0
  167. package/tools/agents/providers/rule-delivery.mjs +9 -128
  168. package/tools/agents/providers/warp.mjs +3 -5
  169. package/tools/agents/providers/windsurf.mjs +3 -5
  170. package/tools/plugin/package-plugins.mjs +2 -2
  171. package/tools/skills/codex-skill-transform.mjs +232 -0
  172. package/tools/skills/deploy-skills-codex.mjs +8 -249
  173. package/tools/warp/warp-content.mjs +548 -0
  174. package/vscode-extension/schemas/aiwg.config.v1.json +177 -0
@@ -0,0 +1,87 @@
1
+ // Count bundle artifacts from native files and activation-selected rule receipts.
2
+ import { promises as fs } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { createHash } from 'node:crypto';
5
+ import { parseRuleFrontmatter } from '../../rules/activation.mjs';
6
+ export async function countDeployedBundleRules(bundlePath, target, deployPath, provider) {
7
+ if (!deployPath && !provider)
8
+ return 0;
9
+ // The shared rule projector uses this conventional directory even when a
10
+ // provider has no native rule loader (for example Pi).
11
+ const destination = path.resolve(target, deployPath || `.${provider}/rules`);
12
+ let selected = [];
13
+ let managed = {};
14
+ try {
15
+ const receipt = JSON.parse(await fs.readFile(path.join(destination, '.aiwg-manifest.json'), 'utf8'));
16
+ selected = Array.isArray(receipt.ruleSources) ? receipt.ruleSources : [];
17
+ managed = receipt.managed ?? {};
18
+ }
19
+ catch { /* Legacy deployments have only native files. */ }
20
+ const indexed = new Set();
21
+ for (const extension of ['.md', '.mdc']) {
22
+ const name = `RULES-INDEX${extension}`;
23
+ try {
24
+ const content = await fs.readFile(path.join(destination, name), 'utf8');
25
+ const hash = `sha256:${createHash('sha256').update(content).digest('hex')}`;
26
+ if (managed[name]?.hash !== hash)
27
+ continue;
28
+ // Rule names may contain spaces (for example "Diversity Awareness").
29
+ for (const match of content.matchAll(/`aiwg show rule ([^`]+?) --body`/g))
30
+ indexed.add(match[1]);
31
+ }
32
+ catch { /* An index receipt alone does not deliver a rule. */ }
33
+ }
34
+ let sources;
35
+ try {
36
+ sources = (await fs.readdir(path.join(bundlePath, 'rules'))).filter(name => name.endsWith('.md'));
37
+ }
38
+ catch {
39
+ return 0;
40
+ }
41
+ let count = 0;
42
+ for (const name of sources) {
43
+ const source = path.resolve(bundlePath, 'rules', name);
44
+ if (selected.includes(source)) {
45
+ const { data } = parseRuleFrontmatter(await fs.readFile(source, 'utf8'));
46
+ const metadata = data;
47
+ // Other activations can be delivered inside context or bound artifacts.
48
+ if (metadata.activation !== 'summary' || indexed.has(metadata.name || path.basename(name, '.md'))) {
49
+ count++;
50
+ continue;
51
+ }
52
+ }
53
+ for (const extension of ['.md', '.mdc']) {
54
+ try {
55
+ await fs.access(path.join(destination, path.basename(name, '.md') + extension));
56
+ count++;
57
+ break;
58
+ }
59
+ catch { /* A catalog-only, unselected rule is not deployed. */ }
60
+ }
61
+ }
62
+ return count;
63
+ }
64
+ export async function countDeployedBundleFiles(bundlePath, subdir, target, deployPath, extensions) {
65
+ if (!deployPath)
66
+ return 0;
67
+ let names;
68
+ try {
69
+ names = (await fs.readdir(path.join(bundlePath, subdir))).filter(name => name.endsWith('.md'));
70
+ }
71
+ catch {
72
+ return 0;
73
+ }
74
+ let count = 0;
75
+ for (const name of names) {
76
+ for (const extension of extensions) {
77
+ try {
78
+ await fs.access(path.join(path.resolve(target, deployPath), path.basename(name, '.md') + extension));
79
+ count++;
80
+ break;
81
+ }
82
+ catch { /* Only count artifacts actually written by this bundle. */ }
83
+ }
84
+ }
85
+ return count;
86
+ }
87
+ //# sourceMappingURL=use-bundle-counts.js.map
@@ -0,0 +1,207 @@
1
+ // Reconcile skill-relative and bundle-root support assets after provider deployment.
2
+ import { promises as fs } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { createHash } from 'node:crypto';
5
+ import { pathToFileURL } from 'node:url';
6
+ import { canDeploySkill, sameSkillOwner, extractFrameworkSlug } from '../../providers/skill-ownership.mjs';
7
+ import { resolveOmpPaths } from '../../providers/omp-paths.mjs';
8
+ import { deployedSkillRoots } from '../../providers/deployed-skill-roots.js';
9
+ import { getFrameworkRoot } from '../../channel/manager.mjs';
10
+ async function fileExists(file) {
11
+ try {
12
+ await fs.access(file);
13
+ return true;
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ }
19
+ const SKILL_SUPPORT_REFERENCE = /(?:^|[\s`('"\[])((?:templates|references|scripts|assets)\/[A-Za-z0-9._@/+\-]*[A-Za-z0-9_@/+\-])(?=$|[.?!\s`)'"\],:;])/gm;
20
+ /** Copy one support file, preserving its executable bit. */
21
+ async function copySkillSupportFile(source, destination, skillDir) {
22
+ await fs.mkdir(path.dirname(destination), { recursive: true });
23
+ await fs.copyFile(source, destination);
24
+ await fs.chmod(destination, (await fs.stat(source)).mode & 0o777);
25
+ // Extend the shared copier's receipt for bundle-root assets too. Adapters
26
+ // without that receipt keep their own ownership and cleanup contract.
27
+ if (!skillDir)
28
+ return;
29
+ const manifestPath = path.join(skillDir, '.aiwg-manifest.json');
30
+ let manifest;
31
+ try {
32
+ manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
33
+ }
34
+ catch {
35
+ return;
36
+ }
37
+ if (!manifest.skillSource || !manifest.managed?.['SKILL.md'])
38
+ return;
39
+ manifest.managed[path.relative(skillDir, destination)] = {
40
+ ...manifest.managed['SKILL.md'],
41
+ hash: `sha256:${createHash('sha256').update(await fs.readFile(destination)).digest('hex')}`,
42
+ };
43
+ await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
44
+ }
45
+ /**
46
+ * Materialize a directory-valued support-asset reference (#2503).
47
+ *
48
+ * Applies the same rules the single-file path applies, per entry: symlinks are
49
+ * refused rather than followed (a link inside a bundle can point anywhere), and
50
+ * file modes are preserved so script packs stay executable. Empty directories
51
+ * are still created — a reference to an empty pack is odd but not an error.
52
+ */
53
+ async function copySkillSupportTree(source, destination, sourceSkillMd, reference, deployFile, skillDir) {
54
+ await fs.mkdir(destination, { recursive: true });
55
+ const label = reference.replace(/\/+$/, '');
56
+ const entries = await fs.readdir(source, { withFileTypes: true });
57
+ for (const entry of entries) {
58
+ const from = path.join(source, entry.name);
59
+ const to = path.join(destination, entry.name);
60
+ if (entry.isSymbolicLink()) {
61
+ throw new Error(`unsafe skill support asset '${label}/${entry.name}' referenced by ${sourceSkillMd}: symbolic links are not deployed`);
62
+ }
63
+ if (entry.isDirectory()) {
64
+ await copySkillSupportTree(from, to, sourceSkillMd, `${label}/${entry.name}`, deployFile, skillDir);
65
+ continue;
66
+ }
67
+ if (!entry.isFile())
68
+ continue;
69
+ if (deployFile) {
70
+ deployFile(from, to);
71
+ continue;
72
+ }
73
+ await copySkillSupportFile(from, to, skillDir);
74
+ }
75
+ }
76
+ /**
77
+ * Skill-relative support files may live beside the skill or at the bundle root
78
+ * (plugin payloads commonly share report templates). Materialize
79
+ * only paths explicitly named by SKILL.md, and fail closed on missing or
80
+ * unsafe sources so a deployed instruction can never point at absent assets.
81
+ */
82
+ export async function reconcileDeployedSkillAssets(bundlePath, target, provider, options = {}) {
83
+ const strictReferences = options.strictReferences ?? true;
84
+ const skillsRoot = path.join(bundlePath, 'skills');
85
+ let skillDirs;
86
+ try {
87
+ skillDirs = (await fs.readdir(skillsRoot, { withFileTypes: true }))
88
+ .filter(entry => entry.isDirectory())
89
+ .map(entry => entry.name);
90
+ }
91
+ catch {
92
+ return;
93
+ }
94
+ const deployRoots = provider === 'omp' && options.scope === 'user'
95
+ ? [path.join(resolveOmpPaths({ cwd: target }).agentDir, 'skills')]
96
+ : deployedSkillRoots(target, provider);
97
+ for (const skillName of skillDirs) {
98
+ const sourceSkillDir = path.join(skillsRoot, skillName);
99
+ const sourceSkillMd = path.join(sourceSkillDir, 'SKILL.md');
100
+ let content;
101
+ try {
102
+ content = await fs.readFile(sourceSkillMd, 'utf8');
103
+ }
104
+ catch {
105
+ continue;
106
+ }
107
+ // Check each deployed tier independently: a foreign mirror must not block
108
+ // support assets for a tier already owned by this source.
109
+ const ownedRoots = [];
110
+ for (const root of deployRoots) {
111
+ const skillDir = path.join(root, skillName);
112
+ try {
113
+ const manifestPath = path.join(skillDir, '.aiwg-manifest.json');
114
+ const receipt = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
115
+ if (!canDeploySkill(receipt, sourceSkillDir, options))
116
+ continue;
117
+ if (!sameSkillOwner(receipt, sourceSkillDir)) {
118
+ receipt.skillSource = path.resolve(sourceSkillDir);
119
+ const slug = extractFrameworkSlug(sourceSkillMd);
120
+ for (const record of Object.values(receipt.managed ?? {})) {
121
+ if (slug)
122
+ record.frameworkSlug = slug;
123
+ else
124
+ delete record.frameworkSlug;
125
+ }
126
+ await fs.writeFile(manifestPath, `${JSON.stringify(receipt, null, 2)}\n`);
127
+ }
128
+ }
129
+ catch { /* adapters without shared ownership receipts keep their own contract */ }
130
+ if (await fileExists(path.join(skillDir, 'SKILL.md')))
131
+ ownedRoots.push(root);
132
+ }
133
+ if (ownedRoots.length === 0)
134
+ continue;
135
+ if (options.skipUndeployed && !(await Promise.all(ownedRoots.map(root => fileExists(path.join(root, skillName, 'SKILL.md'))))).some(Boolean))
136
+ continue;
137
+ const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---/)?.[1] ?? '';
138
+ const declaredEntrypoint = frontmatter
139
+ .match(/^[ \t]+entrypoint:\s*["']?([^"'\s]+)["']?\s*$/m)?.[1];
140
+ const declaredEntrypoints = new Set(declaredEntrypoint ? [declaredEntrypoint] : []);
141
+ const references = [...new Set([
142
+ ...content.matchAll(SKILL_SUPPORT_REFERENCE),
143
+ ].map(match => match[1]).concat([...declaredEntrypoints]))];
144
+ for (const relative of references) {
145
+ const normalized = path.posix.normalize(relative);
146
+ if (normalized !== relative || normalized.startsWith('../') || path.isAbsolute(normalized)) {
147
+ throw new Error(`unsafe skill support reference '${relative}' in ${sourceSkillMd}`);
148
+ }
149
+ const candidates = [path.join(sourceSkillDir, normalized), path.join(bundlePath, normalized)];
150
+ let source;
151
+ let sourceIsDirectory = false;
152
+ for (const candidate of candidates) {
153
+ try {
154
+ const stat = await fs.lstat(candidate);
155
+ if (stat.isSymbolicLink())
156
+ continue;
157
+ // A reference may name a whole support directory (a templates pack,
158
+ // a references folder). Rejecting those as "missing" aborted the
159
+ // bundle deploy over a path that was present all along (#2503).
160
+ if (stat.isFile() || stat.isDirectory()) {
161
+ source = candidate;
162
+ sourceIsDirectory = stat.isDirectory();
163
+ break;
164
+ }
165
+ }
166
+ catch { /* try bundle-root fallback */ }
167
+ }
168
+ if (!source) {
169
+ if (strictReferences || declaredEntrypoints.has(relative)) {
170
+ throw new Error(`missing skill support asset '${relative}' referenced by ${sourceSkillMd}`);
171
+ }
172
+ continue;
173
+ }
174
+ if (sourceIsDirectory && declaredEntrypoints.has(relative)) {
175
+ throw new Error(`skill entrypoint '${relative}' in ${sourceSkillMd} resolves to a directory; an entrypoint must be a file`);
176
+ }
177
+ let deployedSkillRoot;
178
+ for (const root of ownedRoots) {
179
+ // The deployer may select the bulk or kernel tier; use the tier that
180
+ // actually contains this skill's transformed SKILL.md.
181
+ if (await fileExists(path.join(root, skillName, 'SKILL.md'))) {
182
+ deployedSkillRoot = root;
183
+ break;
184
+ }
185
+ }
186
+ if (!deployedSkillRoot)
187
+ throw new Error(`deployed skill '${skillName}' not found while reconciling support assets`);
188
+ const destination = path.join(deployedSkillRoot, skillName, ...normalized.split('/'));
189
+ const deployFile = provider === 'omp'
190
+ ? await (async () => {
191
+ const adapter = await import(pathToFileURL(path.join(await getFrameworkRoot(), 'tools/agents/providers/omp.mjs')).href);
192
+ return (from, to) => adapter.deploySkillSupportAsset(from, to, { quiet: true });
193
+ })()
194
+ : null;
195
+ if (sourceIsDirectory) {
196
+ await copySkillSupportTree(source, destination, sourceSkillMd, relative, deployFile, path.join(deployedSkillRoot, skillName));
197
+ continue;
198
+ }
199
+ if (deployFile) {
200
+ deployFile(source, destination);
201
+ continue;
202
+ }
203
+ await copySkillSupportFile(source, destination, path.join(deployedSkillRoot, skillName));
204
+ }
205
+ }
206
+ }
207
+ //# sourceMappingURL=use-skill-assets.js.map
@@ -16,8 +16,8 @@ import { existsSync, rmSync, rmdirSync } from 'fs';
16
16
  import path from 'path';
17
17
  import os from 'os';
18
18
  import { pathToFileURL } from 'node:url';
19
- import { createHash, randomUUID } from 'node:crypto';
20
- import { canDeploySkill, sameSkillOwner, extractFrameworkSlug } from '../../providers/skill-ownership.mjs';
19
+ import { randomUUID } from 'node:crypto';
20
+ import { sameSkillOwner } from '../../providers/skill-ownership.mjs';
21
21
  import { resolveOmpPaths } from '../../providers/omp-paths.mjs';
22
22
  import YAML from 'yaml';
23
23
  import { createScriptRunner } from './script-runner.js';
@@ -64,6 +64,8 @@ const PREPARABLE_BUILTIN_PROVIDERS = new Set(['claude', 'codex', 'cursor', 'herm
64
64
  // Distinct from agentsmith (which creates subagent personas).
65
65
  import { generate as generateContextFiles, discoverDeployedArtifacts, } from '../../smiths/context-pipeline/index.js';
66
66
  import { verifyModelWrapperDeployment } from '../../models/wrapper-deployment.js';
67
+ import { countDeployedBundleFiles, countDeployedBundleRules } from './use-bundle-counts.js';
68
+ import { reconcileDeployedSkillAssets } from './use-skill-assets.js';
67
69
  import { aggregateUseDeploymentResult, buildDryRunUseResult, renderUseDeploymentResult, verifyProviderDeployment, } from '../services/deployment-verification.js';
68
70
  import { finalizeProviderTransformationReceipt, providerReceiptHasLocalSources, sourceVerificationsFromSignedWebRelease, } from '../../providers/transformation-receipt-integration.js';
69
71
  import { loadResourceTrustRootFile, resolveWebRelease, } from '../../resources/web-release.js';
@@ -1028,24 +1030,6 @@ async function listBundleMdStems(bundlePath, subdir) {
1028
1030
  return [];
1029
1031
  }
1030
1032
  }
1031
- async function countDeployedBundleFiles(bundlePath, subdir, target, deployPath, extensions) {
1032
- if (!deployPath)
1033
- return 0;
1034
- const stems = await listBundleMdStems(bundlePath, subdir);
1035
- if (stems.length === 0)
1036
- return 0;
1037
- const destDir = resolveDeployPath(target, deployPath);
1038
- let count = 0;
1039
- for (const stem of stems) {
1040
- for (const ext of extensions) {
1041
- if (await fileExists(path.join(destDir, `${stem}${ext}`))) {
1042
- count++;
1043
- break;
1044
- }
1045
- }
1046
- }
1047
- return count;
1048
- }
1049
1033
  async function listBundleSkillNameCandidates(bundlePath) {
1050
1034
  const skillsRoot = path.join(bundlePath, 'skills');
1051
1035
  try {
@@ -1107,197 +1091,9 @@ async function countBundleDeployedArtifacts(bundlePath, target, provider) {
1107
1091
  agents: await countDeployedBundleFiles(bundlePath, 'agents', target, paths.agents, ['.md', '.toml']),
1108
1092
  commands: await countDeployedBundleFiles(bundlePath, 'commands', target, paths.commands, ['.md']),
1109
1093
  skills: await countDeployedBundleSkills(bundlePath, target, provider),
1110
- rules: await countDeployedBundleFiles(bundlePath, 'rules', target, paths.rules, ['.md', '.mdc']),
1094
+ rules: await countDeployedBundleRules(bundlePath, target, paths.rules, provider),
1111
1095
  };
1112
1096
  }
1113
- const SKILL_SUPPORT_REFERENCE = /(?:^|[\s`('"\[])((?:templates|references|scripts|assets)\/[A-Za-z0-9._@/+\-]+)(?=$|[\s`)'"\],:;])/gm;
1114
- /** Copy one support file, preserving its executable bit. */
1115
- async function copySkillSupportFile(source, destination, skillDir) {
1116
- await fs.mkdir(path.dirname(destination), { recursive: true });
1117
- await fs.copyFile(source, destination);
1118
- await fs.chmod(destination, (await fs.stat(source)).mode & 0o777);
1119
- // Extend the shared copier's receipt for bundle-root assets too. Adapters
1120
- // without that receipt keep their own ownership and cleanup contract.
1121
- if (!skillDir)
1122
- return;
1123
- const manifestPath = path.join(skillDir, '.aiwg-manifest.json');
1124
- let manifest;
1125
- try {
1126
- manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
1127
- }
1128
- catch {
1129
- return;
1130
- }
1131
- if (!manifest.skillSource || !manifest.managed?.['SKILL.md'])
1132
- return;
1133
- manifest.managed[path.relative(skillDir, destination)] = {
1134
- ...manifest.managed['SKILL.md'],
1135
- hash: `sha256:${createHash('sha256').update(await fs.readFile(destination)).digest('hex')}`,
1136
- };
1137
- await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
1138
- }
1139
- /**
1140
- * Materialize a directory-valued support-asset reference (#2503).
1141
- *
1142
- * Applies the same rules the single-file path applies, per entry: symlinks are
1143
- * refused rather than followed (a link inside a bundle can point anywhere), and
1144
- * file modes are preserved so script packs stay executable. Empty directories
1145
- * are still created — a reference to an empty pack is odd but not an error.
1146
- */
1147
- async function copySkillSupportTree(source, destination, sourceSkillMd, reference, deployFile, skillDir) {
1148
- await fs.mkdir(destination, { recursive: true });
1149
- const label = reference.replace(/\/+$/, '');
1150
- const entries = await fs.readdir(source, { withFileTypes: true });
1151
- for (const entry of entries) {
1152
- const from = path.join(source, entry.name);
1153
- const to = path.join(destination, entry.name);
1154
- if (entry.isSymbolicLink()) {
1155
- throw new Error(`unsafe skill support asset '${label}/${entry.name}' referenced by ${sourceSkillMd}: symbolic links are not deployed`);
1156
- }
1157
- if (entry.isDirectory()) {
1158
- await copySkillSupportTree(from, to, sourceSkillMd, `${label}/${entry.name}`, deployFile, skillDir);
1159
- continue;
1160
- }
1161
- if (!entry.isFile())
1162
- continue;
1163
- if (deployFile) {
1164
- deployFile(from, to);
1165
- continue;
1166
- }
1167
- await copySkillSupportFile(from, to, skillDir);
1168
- }
1169
- }
1170
- /**
1171
- * Skill-relative support files may live beside the skill or at the bundle root
1172
- * (plugin payloads commonly share report templates). Materialize
1173
- * only paths explicitly named by SKILL.md, and fail closed on missing or
1174
- * unsafe sources so a deployed instruction can never point at absent assets.
1175
- */
1176
- async function reconcileDeployedSkillAssets(bundlePath, target, provider, options = {}) {
1177
- const strictReferences = options.strictReferences ?? true;
1178
- const skillsRoot = path.join(bundlePath, 'skills');
1179
- let skillDirs;
1180
- try {
1181
- skillDirs = (await fs.readdir(skillsRoot, { withFileTypes: true }))
1182
- .filter(entry => entry.isDirectory())
1183
- .map(entry => entry.name);
1184
- }
1185
- catch {
1186
- return;
1187
- }
1188
- const deployRoots = provider === 'omp' && options.scope === 'user'
1189
- ? [path.join(resolveOmpPaths({ cwd: target }).agentDir, 'skills')]
1190
- : deployedSkillRoots(target, provider);
1191
- for (const skillName of skillDirs) {
1192
- const sourceSkillDir = path.join(skillsRoot, skillName);
1193
- const sourceSkillMd = path.join(sourceSkillDir, 'SKILL.md');
1194
- let content;
1195
- try {
1196
- content = await fs.readFile(sourceSkillMd, 'utf8');
1197
- }
1198
- catch {
1199
- continue;
1200
- }
1201
- // Check each deployed tier independently: a foreign mirror must not block
1202
- // support assets for a tier already owned by this source.
1203
- const ownedRoots = [];
1204
- for (const root of deployRoots) {
1205
- const skillDir = path.join(root, skillName);
1206
- try {
1207
- const manifestPath = path.join(skillDir, '.aiwg-manifest.json');
1208
- const receipt = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
1209
- if (!canDeploySkill(receipt, sourceSkillDir, options))
1210
- continue;
1211
- if (!sameSkillOwner(receipt, sourceSkillDir)) {
1212
- receipt.skillSource = path.resolve(sourceSkillDir);
1213
- const slug = extractFrameworkSlug(sourceSkillMd);
1214
- for (const record of Object.values(receipt.managed ?? {})) {
1215
- if (slug)
1216
- record.frameworkSlug = slug;
1217
- else
1218
- delete record.frameworkSlug;
1219
- }
1220
- await fs.writeFile(manifestPath, `${JSON.stringify(receipt, null, 2)}\n`);
1221
- }
1222
- }
1223
- catch { /* adapters without shared ownership receipts keep their own contract */ }
1224
- if (await fileExists(path.join(skillDir, 'SKILL.md')))
1225
- ownedRoots.push(root);
1226
- }
1227
- if (ownedRoots.length === 0)
1228
- continue;
1229
- if (options.skipUndeployed && !(await Promise.all(ownedRoots.map(root => fileExists(path.join(root, skillName, 'SKILL.md'))))).some(Boolean))
1230
- continue;
1231
- const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---/)?.[1] ?? '';
1232
- const declaredEntrypoint = frontmatter
1233
- .match(/^[ \t]+entrypoint:\s*["']?([^"'\s]+)["']?\s*$/m)?.[1];
1234
- const declaredEntrypoints = new Set(declaredEntrypoint ? [declaredEntrypoint] : []);
1235
- const references = [...new Set([
1236
- ...content.matchAll(SKILL_SUPPORT_REFERENCE),
1237
- ].map(match => match[1]).concat([...declaredEntrypoints]))];
1238
- for (const relative of references) {
1239
- const normalized = path.posix.normalize(relative);
1240
- if (normalized !== relative || normalized.startsWith('../') || path.isAbsolute(normalized)) {
1241
- throw new Error(`unsafe skill support reference '${relative}' in ${sourceSkillMd}`);
1242
- }
1243
- const candidates = [path.join(sourceSkillDir, normalized), path.join(bundlePath, normalized)];
1244
- let source;
1245
- let sourceIsDirectory = false;
1246
- for (const candidate of candidates) {
1247
- try {
1248
- const stat = await fs.lstat(candidate);
1249
- if (stat.isSymbolicLink())
1250
- continue;
1251
- // A reference may name a whole support directory (a templates pack,
1252
- // a references folder). Rejecting those as "missing" aborted the
1253
- // bundle deploy over a path that was present all along (#2503).
1254
- if (stat.isFile() || stat.isDirectory()) {
1255
- source = candidate;
1256
- sourceIsDirectory = stat.isDirectory();
1257
- break;
1258
- }
1259
- }
1260
- catch { /* try bundle-root fallback */ }
1261
- }
1262
- if (!source) {
1263
- if (strictReferences || declaredEntrypoints.has(relative)) {
1264
- throw new Error(`missing skill support asset '${relative}' referenced by ${sourceSkillMd}`);
1265
- }
1266
- continue;
1267
- }
1268
- if (sourceIsDirectory && declaredEntrypoints.has(relative)) {
1269
- throw new Error(`skill entrypoint '${relative}' in ${sourceSkillMd} resolves to a directory; an entrypoint must be a file`);
1270
- }
1271
- let deployedSkillRoot;
1272
- for (const root of ownedRoots) {
1273
- // The deployer may select the bulk or kernel tier; use the tier that
1274
- // actually contains this skill's transformed SKILL.md.
1275
- if (await fileExists(path.join(root, skillName, 'SKILL.md'))) {
1276
- deployedSkillRoot = root;
1277
- break;
1278
- }
1279
- }
1280
- if (!deployedSkillRoot)
1281
- throw new Error(`deployed skill '${skillName}' not found while reconciling support assets`);
1282
- const destination = path.join(deployedSkillRoot, skillName, ...normalized.split('/'));
1283
- const deployFile = provider === 'omp'
1284
- ? await (async () => {
1285
- const adapter = await import(pathToFileURL(path.join(await getFrameworkRoot(), 'tools/agents/providers/omp.mjs')).href);
1286
- return (from, to) => adapter.deploySkillSupportAsset(from, to, { quiet: true });
1287
- })()
1288
- : null;
1289
- if (sourceIsDirectory) {
1290
- await copySkillSupportTree(source, destination, sourceSkillMd, relative, deployFile, path.join(deployedSkillRoot, skillName));
1291
- continue;
1292
- }
1293
- if (deployFile) {
1294
- deployFile(source, destination);
1295
- continue;
1296
- }
1297
- await copySkillSupportFile(source, destination, path.join(deployedSkillRoot, skillName));
1298
- }
1299
- }
1300
- }
1301
1097
  /**
1302
1098
  * Managed-marker version for a project-local bundle's deployed artifacts (#2502).
1303
1099
  *
@@ -1317,6 +1113,20 @@ function projectLocalDeployVersion(bundle) {
1317
1113
  *
1318
1114
  * @implements #1035
1319
1115
  */
1116
+ /**
1117
+ * First non-blank line of a captured deploy failure, so non-verbose `aiwg
1118
+ * use` output names the actual validation reason (#3728).
1119
+ */
1120
+ function firstFailureLine(message) {
1121
+ if (!message)
1122
+ return '';
1123
+ for (const line of message.split(/\r?\n/)) {
1124
+ const trimmed = line.trim();
1125
+ if (trimmed)
1126
+ return trimmed;
1127
+ }
1128
+ return '';
1129
+ }
1320
1130
  async function deployOneProjectLocalBundle(opts) {
1321
1131
  const { bundle, ctx, frameworkRoot, provider, target, dryRun, verbose, quiet, modelArgs } = opts;
1322
1132
  const sourceCounts = await countBundleSourceArtifacts(bundle.artifactPath);
@@ -1338,6 +1148,7 @@ async function deployOneProjectLocalBundle(opts) {
1338
1148
  return { exitCode: 1, counts: sourceCounts };
1339
1149
  }
1340
1150
  let exitCode = 0;
1151
+ let deployFailureMessage = '';
1341
1152
  if (artifactTotal > 0) {
1342
1153
  const runner = createUseScriptRunner(frameworkRoot);
1343
1154
  const args = [
@@ -1392,6 +1203,10 @@ async function deployOneProjectLocalBundle(opts) {
1392
1203
  env: { AIWG_ROOT: frameworkRoot },
1393
1204
  });
1394
1205
  exitCode = result.exitCode;
1206
+ // In non-verbose mode the deployer's stderr is captured, not inherited —
1207
+ // keep the reason so the caller can print it instead of a bare exit code
1208
+ // (#3728).
1209
+ deployFailureMessage = result.message ?? '';
1395
1210
  if (exitCode === 0 && !dryRun) {
1396
1211
  try {
1397
1212
  await reconcileDeployedSkillAssets(bundle.artifactPath, target, provider, { force: ctx.args.includes('--force') });
@@ -1421,7 +1236,7 @@ async function deployOneProjectLocalBundle(opts) {
1421
1236
  ? await countBundleDeployedArtifacts(bundle.artifactPath, target, provider)
1422
1237
  : sourceCounts;
1423
1238
  void ctx;
1424
- return { exitCode, counts };
1239
+ return exitCode === 0 ? { exitCode, counts } : { exitCode, counts, message: deployFailureMessage };
1425
1240
  }
1426
1241
  /**
1427
1242
  * Discover and deploy artifact-bearing project-local bundles from
@@ -1517,7 +1332,10 @@ async function deployProjectLocalBundles(opts) {
1517
1332
  });
1518
1333
  if (result.exitCode !== 0) {
1519
1334
  failed++;
1520
- ui.warn(`Failed to deploy project-local bundle '${bundle.id}' (exit ${result.exitCode})`);
1335
+ // Surface the deployer's reason (e.g. the rule frontmatter file,
1336
+ // field and limit) even in non-verbose output (#3728).
1337
+ const reason = firstFailureLine(result.message);
1338
+ ui.warn(`Failed to deploy project-local bundle '${bundle.id}' (exit ${result.exitCode})${reason ? `: ${reason}` : ''}`);
1521
1339
  if (!dryRun) {
1522
1340
  await appendProjectLocalActivity({
1523
1341
  event: 'deploy-failed',
@@ -1758,6 +1576,8 @@ const OPENHUMAN_DEFAULT_HARNESS_PROFILE = {
1758
1576
  tokenjuiceCompression: 'auto',
1759
1577
  };
1760
1578
  const OPENHUMAN_HARNESS_PROFILES = {
1579
+ 'aiwg-model-explorer': { modelHint: 'efficiency', sandboxMode: 'read_only', maxTurnOutputTokens: 1000 },
1580
+ 'aiwg-model-verifier': { modelHint: 'coding', sandboxMode: 'read_only', maxTurnOutputTokens: 1000 },
1761
1581
  'aiwg-model-reasoning-worker': {
1762
1582
  modelHint: 'reasoning',
1763
1583
  },
@@ -3521,11 +3341,10 @@ export class UseHandler {
3521
3341
  try {
3522
3342
  const manifestPath = path.join(addonSource, 'manifest.json');
3523
3343
  const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
3524
- // Provider rule aggregation may rename many source rules into one
3525
- // managed index. Record this addon's contributed artifact counts,
3526
- // matching framework registry semantics, rather than trying to
3527
- // attribute shared aggregate filenames after deployment.
3528
- const counts = await countBundleSourceArtifacts(addonSource);
3344
+ // Record only artifacts actually written for this provider. Bridge-only
3345
+ // providers (e.g. project-scope grokbot) write zero native files,
3346
+ // so source-manifest counts would leave phantom registry entries.
3347
+ const counts = await countBundleDeployedArtifacts(addonSource, target, provider);
3529
3348
  const updated = updateInstalled(config, framework, provider, counts, {
3530
3349
  version: manifest.version ?? (await getVersionInfo()).version,
3531
3350
  source: 'bundled',
@@ -13,6 +13,7 @@ import fs from 'fs';
13
13
  import fsp from 'fs/promises';
14
14
  import path from 'path';
15
15
  import { createScriptRunner } from './script-runner.js';
16
+ import { DOCTOR_HELP } from './doctor-help.js';
16
17
  import { getFrameworkRoot } from '../../channel/manager.mjs';
17
18
  import { updateInstallation } from '../../update/service.mjs';
18
19
  import { useHandler as useFrameworkHandler } from './use.js';
@@ -494,30 +495,6 @@ async function runUserScopeDoctor(verbose) {
494
495
  message: lines.join('\n') + '\n',
495
496
  };
496
497
  }
497
- const DOCTOR_HELP = `aiwg doctor — check AIWG installation health
498
-
499
- Usage:
500
- aiwg doctor [options]
501
- aiwg -doctor [options]
502
- aiwg --doctor [options]
503
-
504
- Options:
505
- --deployment Verify configured provider deployments
506
- --provider <name> Limit deployment verification to one provider
507
- --bundle <name> Limit deployment verification to one bundle
508
- --scope <scope> Verification scope: project or user
509
- --user Alias for --scope user
510
- --qualify With --probe-workers, record installation and configured model/role approval
511
- --yes Confirm worker qualification without a terminal
512
- --dry-run With --probe-workers, preview qualification without writes
513
- --cli NAME Limit worker probes/qualification to one configured CLI
514
- --decision-offload Show offline advisory decision readiness and adoption report
515
- --probe-workers Run bounded worker CLI version probes (default: config-only, no subprocess)
516
- --project-local Include project-local artifact diagnostics
517
- --json Emit machine-readable output (with --probe-workers: one worker-probe record per CLI; with --deployment: deployment verification; with --decision-offload: offline snapshot)
518
- --verbose, -v Include verbose diagnostics
519
- --help, -h Show this help
520
- `;
521
498
  /**
522
499
  * Handler for doctor command
523
500
  *