@aiwg/cli 2026.11.7 → 2026.11.9

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 (180) hide show
  1. package/README.md +1 -1
  2. package/agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs +3 -2
  3. package/agentic/code/providers/capability-matrix.yaml +4 -4
  4. package/agentic/code/providers/model-capabilities.v1.json +169 -46
  5. package/agentic/code/providers/model-catalog.v1.json +17 -15
  6. package/bin/aiwg.mjs +3 -1
  7. package/dist/src/agents/agent-packager.js +3 -3
  8. package/dist/src/artifacts/cli.js +6 -2
  9. package/dist/src/artifacts/fortemi-core-sync.js +2 -0
  10. package/dist/src/artifacts/index-query-help.js +27 -0
  11. package/dist/src/artifacts/query-engine-installation.js +17 -4
  12. package/dist/src/artifacts/query-engine-name-intent.js +56 -0
  13. package/dist/src/artifacts/query-engine-scoring.js +14 -8
  14. package/dist/src/artifacts/query-engine-show-card.js +3 -3
  15. package/dist/src/cli/agent-spawn.js +4 -4
  16. package/dist/src/cli/handlers/best-practices-audit.js +1 -1
  17. package/dist/src/cli/handlers/bundle-deployment-mode.js +26 -13
  18. package/dist/src/cli/handlers/bundle-reconciliation.js +2 -2
  19. package/dist/src/cli/handlers/init.js +1 -1
  20. package/dist/src/cli/handlers/issues.js +5 -0
  21. package/dist/src/cli/handlers/marketplace-plugin-search.js +6 -5
  22. package/dist/src/cli/handlers/marketplace.js +1 -1
  23. package/dist/src/cli/handlers/models-muse-wrapper.js +32 -0
  24. package/dist/src/cli/handlers/models.js +5 -4
  25. package/dist/src/cli/handlers/refresh-artifact-freshness.js +51 -0
  26. package/dist/src/cli/handlers/refresh-bundles.js +3 -0
  27. package/dist/src/cli/handlers/refresh-managed-deployment.js +19 -7
  28. package/dist/src/cli/handlers/refresh-user-hooks.js +102 -0
  29. package/dist/src/cli/handlers/refresh.js +9 -3
  30. package/dist/src/cli/handlers/repo-access.js +15 -2
  31. package/dist/src/cli/handlers/sdlc-accelerate.js +1 -1
  32. package/dist/src/cli/handlers/steward.js +1 -1
  33. package/dist/src/cli/handlers/subcommands-bundles.js +1 -1
  34. package/dist/src/cli/handlers/subcommands-discovery.js +5 -0
  35. package/dist/src/cli/handlers/subcommands-list.js +1 -1
  36. package/dist/src/cli/handlers/subcommands-plugins.js +1 -1
  37. package/dist/src/cli/handlers/subcommands-storage.js +11 -0
  38. package/dist/src/cli/handlers/team.js +1 -1
  39. package/dist/src/cli/handlers/use-additive-bundles.js +9 -2
  40. package/dist/src/cli/handlers/use-bundle-counts.js +1 -1
  41. package/dist/src/cli/handlers/use-copy-selection.js +42 -0
  42. package/dist/src/cli/handlers/use.js +33 -38
  43. package/dist/src/cli/handlers/workspace-context.js +4 -0
  44. package/dist/src/cli/help-generator.js +1 -1
  45. package/dist/src/cli/new-project-options.js +46 -0
  46. package/dist/src/cli/router.js +15 -4
  47. package/dist/src/cli/scope-resolver.js +6 -6
  48. package/dist/src/cli/services/deployment-probe-scope.js +11 -0
  49. package/dist/src/cli/services/deployment-staleness.js +83 -0
  50. package/dist/src/cli/services/deployment-verification.js +20 -11
  51. package/dist/src/config/aiwg-config.js +1 -1
  52. package/dist/src/config/authorization-cli.js +36 -1
  53. package/dist/src/config/config-normalization.js +3 -1
  54. package/dist/src/config/worker-guidance-warning.js +8 -0
  55. package/dist/src/data/community.yaml +3 -3
  56. package/dist/src/extensions/commands/definitions.js +2 -2
  57. package/dist/src/extensions/manifest.js +27 -1
  58. package/dist/src/extensions/user-hook-diagnostics.js +18 -1
  59. package/dist/src/extensions/verified-hook-command.js +9 -0
  60. package/dist/src/features/catalog.js +2 -2
  61. package/dist/src/issues/cli.js +10 -2
  62. package/dist/src/marketplace/cache.js +31 -0
  63. package/dist/src/marketplace/plugin-search.js +39 -20
  64. package/dist/src/marketplace/public-search.js +122 -0
  65. package/dist/src/marketplace/registry.js +2 -0
  66. package/dist/src/marketplace/search-contract.js +19 -0
  67. package/dist/src/marketplace/sources/public-search.js +81 -0
  68. package/dist/src/mcp/cli.mjs +8 -7
  69. package/dist/src/mcp/credentials.mjs +1 -1
  70. package/dist/src/mcp/registry.js +6 -2
  71. package/dist/src/mcp/tool-filters.mjs +1 -1
  72. package/dist/src/memory/provider-memory-adapter.js +1 -1
  73. package/dist/src/models/catalog-policy.js +2 -1
  74. package/dist/src/models/config-loader.js +2 -1
  75. package/dist/src/models/cursor-models.js +92 -0
  76. package/dist/src/models/cursor-worker-version.d.mts +2 -0
  77. package/dist/src/models/cursor-worker-version.mjs +27 -0
  78. package/dist/src/models/model-capabilities.v1.json +169 -46
  79. package/dist/src/models/model-catalog.v1.json +17 -15
  80. package/dist/src/models/model-discovery.js +7 -6
  81. package/dist/src/models/policy-resources.js +1 -1
  82. package/dist/src/models/provider-policy.js +1 -1
  83. package/dist/src/models/worker-direct-readiness.js +8 -5
  84. package/dist/src/models/worker-health-readiness.js +4 -0
  85. package/dist/src/models/worker-installation.d.mts +5 -2
  86. package/dist/src/models/worker-installation.mjs +20 -12
  87. package/dist/src/models/worker-invocation-policy.js +22 -2
  88. package/dist/src/models/worker-plan.js +3 -1
  89. package/dist/src/models/worker-wiring-diagnostics.js +25 -0
  90. package/dist/src/models/wrapper-deployment.js +1 -1
  91. package/dist/src/models/wrapper-enforcement.js +6 -2
  92. package/dist/src/plugin/skill-command-frontmatter.js +1 -1
  93. package/dist/src/plugin/skill-command-translator.js +1 -1
  94. package/dist/src/policy/repo-access-workspace-spec.js +63 -0
  95. package/dist/src/policy/repo-access.js +22 -0
  96. package/dist/src/providers/capability-matrix.yaml +4 -4
  97. package/dist/src/providers/deployment-ownership.mjs +1 -1
  98. package/dist/src/providers/deployment-preservation.mjs +10 -5
  99. package/dist/src/providers/deployment-removal.js +1 -1
  100. package/dist/src/providers/devin-compat.d.mts +4 -0
  101. package/dist/src/providers/devin-compat.mjs +29 -0
  102. package/dist/src/providers/grok-build-acp.js +39 -9
  103. package/dist/src/providers/grok-build-paths.js +8 -7
  104. package/dist/src/providers/provider-context-contracts.js +7 -3
  105. package/dist/src/providers/provider-definition-schema.js +1 -1
  106. package/dist/src/providers/provider-definitions.js +1 -1
  107. package/dist/src/providers/provider-definitions.mjs +3 -3
  108. package/dist/src/providers/provider-inventory.js +13 -1
  109. package/dist/src/providers/provider-seeds-1.js +1 -1
  110. package/dist/src/providers/provider-seeds-3.js +10 -9
  111. package/dist/src/providers/transformation-receipt-integration.js +1 -1
  112. package/dist/src/sessions/adapters/windsurf.js +7 -7
  113. package/dist/src/sessions/grok-build-cli-output.js +1 -1
  114. package/dist/src/sessions/grok-build-cli.js +7 -1
  115. package/dist/src/skills/bundle-import-cli.js +61 -0
  116. package/dist/src/skills/bundle-import-plan.js +108 -0
  117. package/dist/src/skills/bundle-import.js +192 -0
  118. package/dist/src/skills/cli.js +5 -0
  119. package/dist/src/skills/deployment-policy.js +1 -1
  120. package/dist/src/skills/importer.js +4 -4
  121. package/dist/src/smiths/agentsmith/demo.js +1 -1
  122. package/dist/src/smiths/agentsmith/examples.js +6 -6
  123. package/dist/src/smiths/commandsmith/generator.js +1 -1
  124. package/dist/src/smiths/context-pipeline/allowlist.js +1 -1
  125. package/dist/src/smiths/context-pipeline/muse-bridge.js +7 -4
  126. package/dist/src/smiths/context-pipeline/parallelism-section.js +2 -2
  127. package/dist/src/smiths/context-pipeline/workspace-audit.js +37 -6
  128. package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +3 -1
  129. package/dist/src/smiths/context-pipeline/workspace-doctor.js +16 -4
  130. package/dist/src/smiths/context-pipeline/workspace-document.js +4 -2
  131. package/dist/src/smiths/hook-bridge/codex-trust.js +56 -7
  132. package/dist/src/smiths/hook-bridge/cursor-translator.js +89 -0
  133. package/dist/src/smiths/hook-bridge/index.js +4 -1
  134. package/dist/src/smiths/skillsmith/collision-detector.js +1 -1
  135. package/dist/src/smiths/skillsmith/namespace-adapter.js +1 -1
  136. package/dist/src/smiths/skillsmith/platform-resolver.js +2 -2
  137. package/dist/src/writing/campaign-report.js +4 -3
  138. package/dist/src/writing/contextual-diagnostics.js +29 -3
  139. package/dist/src/writing/current-patterns.catalogue.json +4 -4
  140. package/dist/src/writing/current-patterns.js +3 -2
  141. package/dist/src/writing/structural-judgment.catalogue.json +17 -0
  142. package/dist/src/writing/structural-judgment.js +33 -0
  143. package/dist/src/writing/structural-patterns.js +78 -6
  144. package/dist/src/writing/validation-campaign.js +3 -0
  145. package/dist/src/writing/validation-engine.js +7 -4
  146. package/package.json +4 -2
  147. package/schemas/models/model-config-compatibility.v1.schema.json +1 -1
  148. package/tools/agents/deploy-agents.mjs +12 -10
  149. package/tools/agents/deploy-options.mjs +1 -0
  150. package/tools/agents/providers/base-behaviors.mjs +1 -1
  151. package/tools/agents/providers/base-contract.mjs +1 -1
  152. package/tools/agents/providers/base-kernel-skills.mjs +1 -1
  153. package/tools/agents/providers/base-models-platforms.mjs +9 -7
  154. package/tools/agents/providers/base-rule-index.mjs +1 -1
  155. package/tools/agents/providers/codex.mjs +1 -0
  156. package/tools/agents/providers/cursor-prompt-discovery.mjs +13 -0
  157. package/tools/agents/providers/cursor.mjs +2 -0
  158. package/tools/agents/providers/devin.mjs +3 -0
  159. package/tools/agents/providers/grok-build.mjs +14 -19
  160. package/tools/agents/providers/hook-capabilities.mjs +1 -1
  161. package/tools/agents/providers/model-wrapper.mjs +1 -1
  162. package/tools/agents/providers/openclaw-context.mjs +6 -0
  163. package/tools/agents/providers/openclaw.mjs +14 -12
  164. package/tools/agents/providers/rule-delivery-surface.mjs +15 -11
  165. package/tools/agents/providers/rule-deployment-prepare.mjs +9 -8
  166. package/tools/agents/providers/rule-presentation.mjs +1 -1
  167. package/tools/agents/providers/rule-projection.mjs +5 -5
  168. package/tools/agents/providers/rule-startup.mjs +4 -2
  169. package/tools/agents/providers/skill-copy-prune.mjs +5 -1
  170. package/tools/agents/providers/windsurf.mjs +26 -26
  171. package/tools/agents/use-rule-selection.mjs +1 -1
  172. package/tools/cli/workspace-deployment-health.mjs +38 -0
  173. package/tools/cli/workspace-status.mjs +5 -2
  174. package/tools/daemon/provider-watcher.mjs +3 -3
  175. package/tools/plugin/package-plugins.mjs +16 -2
  176. package/tools/ralph-external/lib/deepseek-harness-adapter.mjs +36 -22
  177. package/tools/ralph-external/lib/factory-adapter.mjs +13 -28
  178. package/tools/ralph-external/lib/factory-stream-final.mjs +31 -0
  179. package/tools/skills/deploy-skills-codex.mjs +2 -1
  180. package/vscode-extension/schemas/aiwg.config.v1.json +15 -1
@@ -0,0 +1,192 @@
1
+ // Import repositories into existing project-local addons and refresh pinned provenance.
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { randomUUID } from 'node:crypto';
5
+ import { projectAiwgPath } from '../config/project-artifacts.js';
6
+ import { BundleManifestSchema, MANIFEST_MAX_BYTES } from '../extensions/manifest.js';
7
+ import { discoverProjectLocalBundles } from '../extensions/project-local-discovery.js';
8
+ import { buildUpstreamRegistry } from '../extensions/upstream-registry.js';
9
+ import { resolveFrameworkIndexRoot } from '../artifacts/framework-index-paths.js';
10
+ import { loadGraphIndexFile } from '../artifacts/index-reader.js';
11
+ import { buildIndex } from '../artifacts/index-builder.js';
12
+ import { syncFortemiCoreIndex } from '../artifacts/fortemi-core-sync.js';
13
+ import { discoverLocalSkillOwners } from './collision-discovery.js';
14
+ import { planRepository, repositoryKey } from './bundle-import-plan.js';
15
+ function readTree(root) {
16
+ const files = new Map();
17
+ const walk = (directory, prefix = '') => {
18
+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
19
+ const file = `${prefix}${entry.name}`;
20
+ if (entry.isDirectory())
21
+ walk(path.join(directory, entry.name), `${file}/`);
22
+ else if (entry.isFile())
23
+ files.set(file, fs.readFileSync(path.join(directory, entry.name)));
24
+ else
25
+ throw new Error(`Refusing non-regular addon path: ${file}`);
26
+ }
27
+ };
28
+ if (fs.existsSync(root))
29
+ walk(root);
30
+ return files;
31
+ }
32
+ function assertSafeDestination(project, destination) {
33
+ // Existing ancestors must be real directories, never symlinks into another tree.
34
+ const artifactRoot = projectAiwgPath(project);
35
+ for (let current = destination;; current = path.dirname(current)) {
36
+ if (fs.existsSync(current) || (() => { try {
37
+ fs.lstatSync(current);
38
+ return true;
39
+ }
40
+ catch {
41
+ return false;
42
+ } })()) {
43
+ const stat = fs.lstatSync(current);
44
+ if (stat.isSymbolicLink() || !stat.isDirectory())
45
+ throw new Error(`Unsafe addon destination: ${current}`);
46
+ }
47
+ if (current === path.dirname(artifactRoot) || current === path.dirname(current))
48
+ break;
49
+ }
50
+ }
51
+ async function occupiedNames(options, destination) {
52
+ const frameworkRoot = options.frameworkRoot ?? resolveFrameworkIndexRoot(options.projectDir);
53
+ const registry = await buildUpstreamRegistry({ frameworkRoot });
54
+ const names = new Set([...registry.byKey.values()].filter(item => item.type === 'skill').map(item => item.id));
55
+ for (const skill of discoverLocalSkillOwners({ projectDir: options.projectDir }))
56
+ names.add(skill.name);
57
+ const discovery = await discoverProjectLocalBundles(options.projectDir);
58
+ if (discovery.errors.length)
59
+ throw new Error(`Project-local manifests require repair: ${discovery.errors.map(error => error.path).join(', ')}`);
60
+ for (const bundle of discovery.bundles) {
61
+ if (bundle.bundlePath === destination)
62
+ continue;
63
+ for (const name of bundle.manifest.skills ?? bundle.manifest.addonConfig?.skills ?? [])
64
+ names.add(name);
65
+ const root = path.join(bundle.bundlePath, bundle.manifest.addonConfig?.entry?.skills ?? 'skills');
66
+ if (fs.existsSync(root))
67
+ for (const entry of fs.readdirSync(root))
68
+ names.add(entry);
69
+ }
70
+ for (const graph of ['framework', 'project']) {
71
+ const index = loadGraphIndexFile(options.projectDir, 'metadata.json', graph);
72
+ for (const entry of Object.values(index?.entries ?? {})) {
73
+ const ownPrefix = `.aiwg/addons/${path.basename(destination)}/`;
74
+ if (entry.type !== 'skill' || entry.path.startsWith(ownPrefix) || entry.path.startsWith(`${destination}/`))
75
+ continue;
76
+ names.add(entry.name ?? path.basename(path.dirname(entry.path)));
77
+ }
78
+ }
79
+ return names;
80
+ }
81
+ function publish(destination, files) {
82
+ const parent = path.dirname(destination);
83
+ fs.mkdirSync(parent, { recursive: true });
84
+ const stage = fs.mkdtempSync(path.join(parent, '.skill-import-'));
85
+ const backup = `${stage}-backup-${randomUUID()}`;
86
+ let moved = false;
87
+ try {
88
+ for (const [file, bytes] of files) {
89
+ const target = path.join(stage, file);
90
+ fs.mkdirSync(path.dirname(target), { recursive: true });
91
+ fs.writeFileSync(target, bytes);
92
+ }
93
+ if (fs.existsSync(destination)) {
94
+ fs.renameSync(destination, backup);
95
+ moved = true;
96
+ }
97
+ try {
98
+ fs.renameSync(stage, destination);
99
+ }
100
+ catch (error) {
101
+ if (moved)
102
+ fs.renameSync(backup, destination);
103
+ throw error;
104
+ }
105
+ }
106
+ finally {
107
+ fs.rmSync(stage, { recursive: true, force: true });
108
+ fs.rmSync(backup, { recursive: true, force: true });
109
+ }
110
+ }
111
+ export async function importSkillBundle(options) {
112
+ const name = options.refresh ?? options.into;
113
+ if (!name || !/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(name) || name.length > 64)
114
+ throw new Error('A valid addon name is required');
115
+ if (options.refresh ? options.source || options.into || options.only : !options.source)
116
+ throw new Error('Use a repository with --into, or --refresh <addon> alone');
117
+ const destination = projectAiwgPath(options.projectDir, 'addons', name);
118
+ assertSafeDestination(options.projectDir, destination);
119
+ const previous = readTree(destination);
120
+ const rawManifest = previous.get('manifest.json');
121
+ const manifest = BundleManifestSchema.parse(rawManifest ? JSON.parse(rawManifest.toString('utf8')) : {
122
+ id: name, type: 'addon', name, description: `Imported community skills for ${name}`, version: '1.0.0',
123
+ manifestVersion: '1', platforms: { claude: 'full' }, keywords: ['community', 'project-local'],
124
+ deployment: { pathTemplate: '.{platform}/skills/{id}.md' },
125
+ skills: [], core: false, autoInstall: false, addonConfig: { entry: { skills: 'skills/' } }, upstream: [],
126
+ });
127
+ if (manifest.type !== 'addon' || manifest.id !== name)
128
+ throw new Error('Import destination must be a matching project-local addon');
129
+ if (manifest.addonConfig?.entry?.skills && manifest.addonConfig.entry.skills !== 'skills/')
130
+ throw new Error('Import requires the canonical skills/ entry path');
131
+ if (options.refresh && !manifest.upstream?.length)
132
+ throw new Error('Refresh requires an addon with pinned upstreams');
133
+ if (options.refresh && options.ref && manifest.upstream.length !== 1)
134
+ throw new Error('--ref on refresh requires exactly one upstream');
135
+ const repo = options.source && (fs.existsSync(path.resolve(options.projectDir, options.source))
136
+ ? fs.realpathSync(path.resolve(options.projectDir, options.source)) : options.source);
137
+ if (repo && manifest.upstream?.some(upstream => upstream.repo === repo))
138
+ throw new Error('Repository already imported; use --refresh');
139
+ const occupied = await occupiedNames(options, destination);
140
+ const desired = new Map(previous);
141
+ let skills = [...(manifest.skills ?? manifest.addonConfig?.skills ?? [])];
142
+ if (options.refresh) {
143
+ const owned = new Set(manifest.upstream.flatMap(upstream => upstream.skills.map(skill => upstream.renames[skill] ?? skill)));
144
+ for (const file of desired.keys()) {
145
+ if (owned.has(file.split('/')[1]) && file.startsWith('skills/')
146
+ || manifest.upstream.some(upstream => file.startsWith(`licenses/${repositoryKey(upstream.repo)}/`)))
147
+ desired.delete(file);
148
+ }
149
+ skills = skills.filter(skill => !owned.has(skill));
150
+ }
151
+ for (const skill of skills)
152
+ occupied.add(skill);
153
+ const sources = options.refresh ? manifest.upstream.map(upstream => ({
154
+ repo: upstream.repo, ref: options.ref ?? upstream.commit, pinned: upstream,
155
+ })) : [{ repo: repo, ref: options.ref ?? 'HEAD', pinned: undefined }];
156
+ const diagnostics = [];
157
+ const upstreams = options.refresh ? [] : [...(manifest.upstream ?? [])];
158
+ for (const source of sources) {
159
+ const result = planRepository({ ...source, only: options.only, occupied });
160
+ for (const [file, bytes] of result.files) {
161
+ if (desired.has(file))
162
+ throw new Error(`Refusing to overwrite an unmanaged addon file: ${file}`);
163
+ desired.set(file, bytes);
164
+ }
165
+ diagnostics.push(...result.diagnostics);
166
+ upstreams.push(result.upstream);
167
+ skills.push(...result.upstream.skills.map(skill => result.upstream.renames[skill] ?? skill));
168
+ }
169
+ manifest.upstream = upstreams;
170
+ manifest.skills = skills.sort();
171
+ BundleManifestSchema.parse(manifest);
172
+ const manifestBytes = Buffer.from(JSON.stringify(manifest, null, 2) + '\n');
173
+ if (manifestBytes.length > MANIFEST_MAX_BYTES)
174
+ throw new Error('Imported manifest exceeds 64 KB');
175
+ desired.set('manifest.json', manifestBytes);
176
+ const plan = {
177
+ bundlePath: destination, manifest, installed: false, dryRun: Boolean(options.dryRun), diagnostics,
178
+ diff: {
179
+ added: [...desired.keys()].filter(file => !previous.has(file)).sort(),
180
+ modified: [...desired.keys()].filter(file => previous.has(file) && !desired.get(file).equals(previous.get(file))).sort(),
181
+ removed: [...previous.keys()].filter(file => !desired.has(file)).sort(),
182
+ },
183
+ };
184
+ options.report?.(plan);
185
+ if (!options.dryRun) {
186
+ publish(destination, desired);
187
+ await buildIndex(options.projectDir, { graph: 'project', force: true, explicit: true, quiet: true });
188
+ syncFortemiCoreIndex(options.projectDir, { graph: 'project' });
189
+ }
190
+ return plan;
191
+ }
192
+ //# sourceMappingURL=bundle-import.js.map
@@ -303,6 +303,8 @@ function printImportUsage() {
303
303
  console.log('Usage:');
304
304
  console.log(' aiwg skills import <directory> [options]');
305
305
  console.log(' aiwg skills import --git <url> --rev <revision> --subpath <path> [options]');
306
+ console.log(' aiwg skills import <repo-url|path> --into <addon> [--ref <revision>] [--only <glob>] [--dry-run]');
307
+ console.log(' aiwg skills import --refresh <addon> [--dry-run]');
306
308
  console.log('');
307
309
  console.log('Options:');
308
310
  console.log(' --profile strict|compatible Validation profile (default: strict)');
@@ -313,6 +315,9 @@ function printImportUsage() {
313
315
  console.log(' --json Emit deterministic structured output');
314
316
  }
315
317
  async function handleImport(args) {
318
+ if (args.includes('--into') || args.includes('--refresh')) {
319
+ return (await import('./bundle-import-cli.js')).handleBundleImport(args);
320
+ }
316
321
  let parsed;
317
322
  try {
318
323
  parsed = parseImportArgs(args);
@@ -102,7 +102,7 @@ export function resolvePolicy(target, options) {
102
102
  status = 'projected';
103
103
  reasons.push('uses the verified global one-level ~/.openhuman/skills layout');
104
104
  break;
105
- case 'windsurf':
105
+ case 'devin':
106
106
  status = 'projected';
107
107
  reasons.push('uses one skill bundle directly below the one-level .windsurf/skills surface');
108
108
  break;
@@ -267,9 +267,9 @@ function decodeGitOutput(bytes, context) {
267
267
  fail('AS_IMPORT_PATH_ENCODING', `${context} contains a non-UTF-8 path`, '.', 'Use UTF-8 resource paths.');
268
268
  }
269
269
  }
270
- function collectGitTree(source, limits) {
270
+ export function collectGitTree(source, limits, repositoryRoot = false) {
271
271
  validateGitLocator(source.url, source.revision);
272
- const subpath = normalizeGitSubpath(source.subpath);
272
+ const subpath = repositoryRoot ? '.' : normalizeGitSubpath(source.subpath);
273
273
  const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'aiwg-skill-git-'));
274
274
  const gitDir = path.join(tempRoot, 'repo.git');
275
275
  try {
@@ -325,11 +325,11 @@ function collectGitTree(source, limits) {
325
325
  fail('AS_IMPORT_GIT_TREE', 'Git returned an unrecognized tree entry', '.', 'Verify the pinned revision and repository integrity.');
326
326
  }
327
327
  const [, mode, objectType, objectId, repositoryPath] = match;
328
- if (repositoryPath !== subpath
328
+ if (!repositoryRoot && repositoryPath !== subpath
329
329
  && !repositoryPath.startsWith(`${subpath}/`)) {
330
330
  fail('AS_IMPORT_PATH_ESCAPE', `Git path escapes the requested subpath: "${repositoryPath}"`, repositoryPath);
331
331
  }
332
- const relativePath = validateRelativePath(repositoryPath.slice(subpath.length + 1));
332
+ const relativePath = validateRelativePath(repositoryRoot ? repositoryPath : repositoryPath.slice(subpath.length + 1));
333
333
  const depth = relativePath.split('/').length;
334
334
  if (depth > limits.maxDepth) {
335
335
  fail('AS_IMPORT_DEPTH', `"${relativePath}" exceeds the ${limits.maxDepth}-level depth limit`, relativePath);
@@ -91,7 +91,7 @@ async function demo() {
91
91
  }
92
92
  // Demo 5: Platform transformations
93
93
  console.log('\n5. Platform Transformation Examples:\n');
94
- const platforms = ['claude', 'cursor', 'codex', 'windsurf'];
94
+ const platforms = ['claude', 'cursor', 'codex', 'devin'];
95
95
  for (const platform of platforms) {
96
96
  const agent = await generator.generateAgent({
97
97
  name: 'demo-platform-test',
@@ -226,16 +226,16 @@ async function example9_ModelOverride() {
226
226
  console.log(`Deployed with model override: ${agent.model}`);
227
227
  }
228
228
  /**
229
- * Example 10: Windsurf Platform - Aggregated AGENTS.md
229
+ * Example 10: Devin Desktop Platform - Aggregated AGENTS.md
230
230
  *
231
- * Generate agent for Windsurf's aggregated format.
231
+ * Generate agent for Devin Desktop's aggregated format.
232
232
  */
233
233
  async function example10_WindsurfFormat() {
234
234
  const options = {
235
235
  name: 'refactor-assistant',
236
236
  description: 'Assists with code refactoring tasks',
237
237
  template: 'complex',
238
- platform: 'windsurf',
238
+ platform: 'devin',
239
239
  projectPath: '/path/to/project',
240
240
  category: 'refactoring',
241
241
  guidance: `
@@ -246,9 +246,9 @@ async function example10_WindsurfFormat() {
246
246
  };
247
247
  const agent = await generator.generateAgent(options);
248
248
  await generator.deployAgent(agent);
249
- console.log('Windsurf agent deployed:');
249
+ console.log('Devin Desktop agent deployed:');
250
250
  console.log(`Path: ${agent.path}`);
251
- console.log('Note: Windsurf uses plain markdown without YAML frontmatter');
251
+ console.log('Note: Devin Desktop uses plain markdown without YAML frontmatter');
252
252
  }
253
253
  // Export examples for use in CLI or documentation
254
254
  export const examples = {
@@ -294,7 +294,7 @@ export const examples = {
294
294
  // console.log('\nExample 9: Model Override');
295
295
  // await example9_ModelOverride();
296
296
  //
297
- // console.log('\nExample 10: Windsurf Format');
297
+ // console.log('\nExample 10: Devin Desktop Format');
298
298
  // await example10_WindsurfFormat();
299
299
  // }
300
300
  //# sourceMappingURL=examples.js.map
@@ -48,7 +48,7 @@ export function validateCommand(command) {
48
48
  });
49
49
  }
50
50
  // Validate platform
51
- const validPlatforms = ['claude', 'codex', 'copilot', 'cursor', 'factory', 'generic', 'windsurf'];
51
+ const validPlatforms = ['claude', 'codex', 'copilot', 'cursor', 'factory', 'generic', 'devin'];
52
52
  if (!validPlatforms.includes(command.platform)) {
53
53
  issues.push({
54
54
  type: 'error',
@@ -60,7 +60,7 @@ const AIWG_PATH_PREFIXES_RELATIVE = [
60
60
  '.warp/skills/',
61
61
  '.warp/commands/',
62
62
  '.warp/rules/',
63
- // Windsurf
63
+ // Devin Desktop
64
64
  '.windsurf/agents/',
65
65
  '.windsurf/skills/',
66
66
  '.windsurf/workflows/',
@@ -5,7 +5,7 @@
5
5
  * Muse Code reads project AGENTS.md natively — but only after the workspace
6
6
  * is explicitly trusted (first-run trust prompt). The bridge therefore leads
7
7
  * with the trust-gated load, follows the Muse-native instruction order
8
- * (this AGENTS.md first, then WORKSPACE.md, then AIWG.md), and states the
8
+ * (this AGENTS.md first, discovery, then WORKSPACE.md and AIWG.md), and states the
9
9
  * discover-first protocol (`aiwg discover` / `aiwg show`) with no auto-load
10
10
  * claims for other AIWG paths. Artifact references and one-sentence
11
11
  * summaries only — never full bodies — per
@@ -30,14 +30,17 @@ export function buildMuseBridgeText() {
30
30
  'file does not load: trust the workspace when prompted, then start a new',
31
31
  'Muse session so the bridge is read.',
32
32
  '',
33
- 'Instruction order: this AGENTS.md first, then [WORKSPACE.md](./WORKSPACE.md)',
33
+ 'Instruction order: this AGENTS.md first (native startup context).',
34
+ 'On every new directive, run `aiwg discover "<intent>"` as the first information-gathering call,',
35
+ 'before reading WORKSPACE.md, AIWG.md, the rules index, or quickrefs; this includes coding, decline, and bug-report requests.',
36
+ 'After discovery, read and follow [WORKSPACE.md](./WORKSPACE.md)',
34
37
  'for project/operator context, then [AIWG.md](./AIWG.md), the single generated',
35
38
  'context for AIWG discovery, quickrefs, and framework routing.',
36
39
  'Plain Markdown links are explicit reading instructions; AIWG does not',
37
40
  'claim Muse auto-loads any other AIWG path on its own.',
38
41
  '',
39
- 'Before improvising on any AIWG capability: run `aiwg discover "<intent>"`,',
40
- 'then `aiwg show <type> <name>` for the artifact you need. Prefer indexed',
42
+ "For AIWG lookup, never open `.agents/skills/**` or `agentic/code/**`, including a discovered skill's mirror file or a template. After discover, use `aiwg show <type> <name>` and its drill-ins (`--section`, `--rules --with-rule-bodies`, `--body`); read required rules before governed work.",
43
+ 'Prefer indexed',
41
44
  'agents, skills, rules, and commands over guessing. Store artifact',
42
45
  'references and one-sentence summaries only — never paste full artifact',
43
46
  'bodies into context or memory.',
@@ -223,8 +223,8 @@ function delegationSupport(provider) {
223
223
  case 'warp':
224
224
  case 'hermes':
225
225
  return `**Provider behavior (${provider})**: delegation is available, but model selection is global/run-scoped. Use the wrapper rubric for task selection while reporting that heterogeneous per-worker pinning is not enforced.`;
226
- case 'windsurf':
227
- return '**Provider behavior (windsurf)**: portable subagent model selection is unsupported. Apply the decomposition rubric in the primary agent and do not claim wrapper pinning or parallel delegation.';
226
+ case 'devin':
227
+ return '**Provider behavior (devin)**: portable subagent model selection is unsupported. Apply the decomposition rubric in the primary agent and do not claim wrapper pinning or parallel delegation.';
228
228
  default:
229
229
  return `**Provider behavior (${provider ?? 'unknown'})**: delegation and per-worker model selection are unverified. Apply the rubric only where the active provider exposes those capabilities, and state any fallback explicitly.`;
230
230
  }
@@ -9,8 +9,23 @@ import { providerForPath } from './workspace-document.js';
9
9
  import { extractExistingProjectContext } from './workspace-extraction.js';
10
10
  import { projectOutputPath } from './workspace-migration.js';
11
11
  export function directives(content) {
12
- return [...new Set(content
13
- .split('\n')
12
+ const lines = content.split('\n');
13
+ return [...new Set(lines
14
+ .filter((line, index) => {
15
+ const trimmed = line.trim();
16
+ // Markdown structure and canonical context bridges are not operator policy.
17
+ if (/^#{1,6}\s|^(?:[-*_]\s*){3,}$|^=+$/.test(trimmed))
18
+ return false;
19
+ if (/^\s*(?:=+|-+)\s*$/.test(lines[index + 1] ?? ''))
20
+ return false;
21
+ if (/^@(?:\.\/|\.aiwg\/)?(?:AIWG|WORKSPACE|AGENTS|CLAUDE|WARP)\.md\s*$/.test(trimmed))
22
+ return false;
23
+ if (/^Read and follow \[WORKSPACE\.md\]\(\.\/WORKSPACE\.md\) first\.$/.test(trimmed))
24
+ return false;
25
+ if (/^Then read \[AIWG\.md\]\(\.\/AIWG\.md\) for AIWG discovery, quickrefs, and framework routing\.$/.test(trimmed))
26
+ return false;
27
+ return true;
28
+ })
14
29
  .map((line) => line.replace(/^\s*[-*+]\s+/, '').replace(/^#+\s+/, '').trim())
15
30
  .filter((line) => line.length >= 8 && !line.startsWith('<!--') && !/^https?:\/\//i.test(line)))];
16
31
  }
@@ -69,7 +84,9 @@ function operatorContext(relativePath, content, preserveLines = false) {
69
84
  // content (#277, pre-existing) plus two reserved, self-identifying names
70
85
  // that are never legitimately a real project directory.
71
86
  export const CONTEXT_WALK_ALWAYS_IGNORED_DIR_NAMES = new Set([
72
- '.git', 'node_modules', 'dist', 'build', 'coverage', '.aiwg',
87
+ '.git', 'node_modules', 'dist', 'build', 'coverage', '.aiwg', '.index',
88
+ // These files were already excluded after traversal; prune their entire trees.
89
+ 'fixtures', 'templates',
73
90
  ]);
74
91
  // Cache/registry directory names that are only skipped when the walk root
75
92
  // is the home directory itself (#277 fix-round). A project subtree that
@@ -157,13 +174,22 @@ export async function nestedInstructionFiles(projectPath) {
157
174
  const isHomeDirectory = path.resolve(projectPath) === path.resolve(homedir());
158
175
  const maxDepth = isHomeDirectory ? 1 : CONTEXT_WALK_MAX_DEPTH;
159
176
  let visitedDirectories = 0;
160
- let truncated = false;
177
+ const bounds = new Map();
178
+ const subtreeVisits = new Map();
161
179
  async function walk(directory, depth) {
162
180
  if (depth > maxDepth || visitedDirectories >= CONTEXT_WALK_MAX_DIRECTORIES) {
163
- truncated = true;
181
+ const bound = depth > maxDepth ? 'depth' : 'directories';
182
+ if (!bounds.has(bound))
183
+ bounds.set(bound, {
184
+ limit: bound === 'depth' ? maxDepth : CONTEXT_WALK_MAX_DIRECTORIES,
185
+ path: path.relative(projectPath, directory).replace(/\\/g, '/'),
186
+ });
164
187
  return;
165
188
  }
166
189
  visitedDirectories += 1;
190
+ const subtree = path.relative(projectPath, directory).split(path.sep)[0];
191
+ if (subtree)
192
+ subtreeVisits.set(subtree, (subtreeVisits.get(subtree) ?? 0) + 1);
167
193
  let entries;
168
194
  try {
169
195
  entries = await fs.readdir(directory, { withFileTypes: true });
@@ -191,7 +217,11 @@ export async function nestedInstructionFiles(projectPath) {
191
217
  }
192
218
  }
193
219
  await walk(projectPath, 1);
194
- return { files: found.sort((a, b) => a.localeCompare(b)), truncated };
220
+ const busiest = [...subtreeVisits].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0];
221
+ const truncations = [...bounds].map(([bound, detail]) => ({
222
+ bound, ...detail, subtree: busiest?.[0] ?? '.', visitedDirectories: busiest?.[1] ?? visitedDirectories,
223
+ }));
224
+ return { files: found.sort((a, b) => a.localeCompare(b)), truncated: bounds.size > 0, truncations };
195
225
  }
196
226
  export async function migratedProviderFiles(projectPath) {
197
227
  const directory = projectAiwgPath(projectPath, 'context', 'providers');
@@ -302,6 +332,7 @@ export async function auditWorkspaceContext(projectPath) {
302
332
  conflicts,
303
333
  sensitiveFindings,
304
334
  contextWalkTruncated: nested.truncated,
335
+ contextWalkTruncations: nested.truncations,
305
336
  plan: {
306
337
  routing,
307
338
  scopeReview,
@@ -18,6 +18,8 @@ const PROSE_LOADING = [
18
18
  'Then read [AIWG.md](./AIWG.md) for AIWG discovery, quickrefs, and framework routing.',
19
19
  '',
20
20
  'These are explicit reading instructions. Plain Markdown links are not claimed to auto-load.',
21
+ '',
22
+ "For AIWG lookup, never open `.agents/skills/**` or `agentic/code/**`, including a discovered skill's mirror file or a template. After discover, use `aiwg show <type> <name>` and its drill-ins (`--section`, `--rules --with-rule-bodies`, `--body`); read required rules before governed work.",
21
23
  ];
22
24
  function wrapProviderBootstrap(loading) {
23
25
  return [
@@ -53,7 +55,7 @@ export function buildProviderBootstrapBlock(provider) {
53
55
  // A session directive that arrives later cannot claim precedence it was never
54
56
  // granted (#2512).
55
57
  // #227: Muse gets its own discover-first bridge text — Muse-native
56
- // instruction order (this AGENTS.md first, then WORKSPACE.md, then AIWG.md)
58
+ // instruction order (discovery, then WORKSPACE.md, then AIWG.md)
57
59
  // plus the trust-gated load caveat — instead of the generic prose-directive.
58
60
  const loading = provider === 'muse'
59
61
  ? [buildMuseBridgeText()]
@@ -39,7 +39,7 @@ export async function workspaceLinkedFiles(projectPath) {
39
39
  return [...new Set(files)].sort();
40
40
  }
41
41
  export async function diagnoseWorkspaceContext(projectPath) {
42
- const diagnostics = await diagnoseUserHookCommands();
42
+ const diagnostics = await diagnoseUserHookCommands(projectPath);
43
43
  const codexTrust = await diagnoseCodexHookTrust(projectPath);
44
44
  if (codexTrust)
45
45
  diagnostics.push(codexTrust);
@@ -95,7 +95,7 @@ export async function diagnoseWorkspaceContext(projectPath) {
95
95
  diagnostics.push({
96
96
  severity: 'info',
97
97
  code: 'context-walk-truncated',
98
- message: 'Nested-instruction-file walk stopped early (depth/entry bound reached, or the root looks like $HOME or has no project markers); the context graph may be incomplete.',
98
+ message: `Nested-instruction-file walk stopped early: ${audit.contextWalkTruncations?.map((hit) => `${hit.bound}=${hit.limit} reached at ${hit.path}; busiest subtree ${hit.subtree} (${hit.visitedDirectories} visited directories)`).join('; ')}; the context graph may be incomplete.`,
99
99
  });
100
100
  }
101
101
  const workspacePath = path.join(projectPath, 'WORKSPACE.md');
@@ -142,8 +142,20 @@ export async function diagnoseWorkspaceContext(projectPath) {
142
142
  // and degrades the workspace over content that agrees with itself (#2558).
143
143
  const duplicatesByPair = new Map();
144
144
  for (const overlap of audit.identical) {
145
- const key = overlap.sources.join(', ');
146
- duplicatesByPair.set(key, (duplicatesByPair.get(key) ?? 0) + overlap.directives.length);
145
+ // Shared boilerplate in independent repositories is outside a single load scope.
146
+ const byScope = new Map();
147
+ for (const source of overlap.sources) {
148
+ const scope = await directoryScope(path.dirname(path.resolve(root, source)));
149
+ const paths = byScope.get(scope) ?? [];
150
+ paths.push(source);
151
+ byScope.set(scope, paths);
152
+ }
153
+ for (const paths of byScope.values()) {
154
+ if (paths.length < 2)
155
+ continue;
156
+ const key = paths.join(', ');
157
+ duplicatesByPair.set(key, (duplicatesByPair.get(key) ?? 0) + overlap.directives.length);
158
+ }
147
159
  }
148
160
  const operatorBodies = new Map(audit.sources.map((source) => [source.path, source.operatorContent.trim()]));
149
161
  for (const [pair, count] of duplicatesByPair) {
@@ -103,8 +103,10 @@ export function buildWorkspaceManagedBlock(projectPath, providerFiles = [], resi
103
103
  '## AIWG Context Graph',
104
104
  '',
105
105
  'This file is the canonical provider-neutral home for project and operator context.',
106
- 'Provider startup files are generated adapters: they direct the harness here first,',
107
- 'then to AIWG.md for framework discovery and routing.',
106
+ 'Provider startup files are generated adapters and native startup context.',
107
+ 'On every new directive, run `aiwg discover` before tool-based context reads;',
108
+ 'then read WORKSPACE.md, then AIWG.md for framework discovery and routing.',
109
+ 'This read order does not change the policy precedence below.',
108
110
  '',
109
111
  '### Precedence',
110
112
  '',
@@ -1,12 +1,18 @@
1
- // Read Codex project trust without granting trust or inventing hook-review storage.
1
+ // Read Codex trust and deduplicate trusted-project advice without granting hook approval.
2
+ import { execFile } from 'node:child_process';
3
+ import { createHash } from 'node:crypto';
2
4
  import { promises as fs } from 'node:fs';
3
5
  import { homedir } from 'node:os';
4
6
  import * as path from 'node:path';
7
+ import { promisify } from 'node:util';
5
8
  import { getStaticTOMLValue, parseTOML } from 'toml-eslint-parser';
9
+ import { getUserStateDir } from '../../config/user-state.js';
10
+ import { workerVersionProbeEnvironment } from '../../models/worker-installation.mjs';
11
+ const execFileAsync = promisify(execFile);
6
12
  // Printed after deploy: one line that fits an 80-column terminal.
7
13
  export const CODEX_HOOK_TRUST_NEXT_STEP = 'Trust this project in Codex and approve its AIWG hook; codex exec needs both.';
8
14
  // Full explanation for doctor and docs (#4035).
9
- export const CODEX_EXEC_HOOK_TRUST_DETAIL = 'Codex 0.167 requires saved folder and hook trust for codex exec; a per-run -c project trust override '
15
+ export const CODEX_EXEC_HOOK_TRUST_DETAIL = 'Codex requires saved folder and hook trust for codex exec; a per-run -c project trust override '
10
16
  + 'does not enable project hooks, even with --dangerously-bypass-hook-trust. '
11
17
  + 'Review and save trust interactively for each worker worktree before automation; AIWG never grants trust.';
12
18
  export function codexHookTrustNextStep(trust) {
@@ -28,7 +34,7 @@ export async function readCodexHookTrust(projectPath) {
28
34
  // Missing/broken installations are handled by deployment drift checks.
29
35
  return null;
30
36
  }
31
- // Codex 0.167 has no documented offline file signal for hook review.
37
+ // A notice marker is not evidence of Codex hook approval; keep that state unknown.
32
38
  const trust = { project: 'unknown', hookReview: 'unknown' };
33
39
  const codexHome = process.env.CODEX_HOME || path.join(process.env.HOME || homedir(), '.codex');
34
40
  try {
@@ -42,14 +48,57 @@ export async function readCodexHookTrust(projectPath) {
42
48
  }
43
49
  return trust;
44
50
  }
51
+ async function codexHookAdvisoryAlreadyShown(projectPath) {
52
+ const root = path.resolve(projectPath);
53
+ try {
54
+ const codexHome = path.resolve(process.env.CODEX_HOME || path.join(process.env.HOME || homedir(), '.codex'));
55
+ const registration = await fs.readFile(path.join(root, '.codex/hooks.json'));
56
+ const script = await fs.readFile(path.join(root, '.codex/hooks/aiwg-prompt-discovery.cjs'));
57
+ const digest = createHash('sha256').update(JSON.stringify([root, codexHome,
58
+ registration.toString('base64'), script.toString('base64')])).digest('hex');
59
+ // Empty host-local markers record only that advice was shown, never trust.
60
+ const directory = path.join(getUserStateDir(), 'codex-hook-advisories');
61
+ await fs.mkdir(directory, { recursive: true, mode: 0o700 });
62
+ try {
63
+ await fs.writeFile(path.join(directory, digest), '', { flag: 'wx', mode: 0o600 });
64
+ }
65
+ catch (error) {
66
+ if (error.code === 'EEXIST')
67
+ return true;
68
+ throw error;
69
+ }
70
+ }
71
+ catch {
72
+ // A missing/unwritable state directory must never silence the diagnostic.
73
+ }
74
+ return false;
75
+ }
76
+ async function detectedCodexVersion(projectPath) {
77
+ try {
78
+ // Cleared environment: the probe needs only PATH, never setup inputs or credentials.
79
+ const { stdout } = await execFileAsync('codex', ['--version'], {
80
+ cwd: path.resolve(projectPath), env: workerVersionProbeEnvironment(), timeout: 2000, maxBuffer: 4096, windowsHide: true,
81
+ });
82
+ return /^codex-cli (\d+\.\d+\.\d+(?:[-+][\w.-]+)?)\s*$/.exec(stdout.trim())?.[1] ?? 'unknown';
83
+ }
84
+ catch {
85
+ return 'unknown';
86
+ }
87
+ }
45
88
  export async function diagnoseCodexHookTrust(projectPath) {
46
89
  const trust = await readCodexHookTrust(projectPath);
47
90
  const nextStep = codexHookTrustNextStep(trust);
48
- return trust && nextStep ? {
49
- // Review state is never observable offline, so a trusted project is only advisory.
91
+ if (!trust || !nextStep)
92
+ return null;
93
+ if (trust.project === 'trusted' && await codexHookAdvisoryAlreadyShown(projectPath))
94
+ return null;
95
+ const version = await detectedCodexVersion(projectPath);
96
+ return {
50
97
  severity: trust.project === 'trusted' ? 'info' : 'warning', code: 'codex-prompt-discovery-trust', path: '.codex/hooks.json',
51
98
  message: 'Codex prompt-discovery hook installed but inactive or unverified (untrusted project or unreviewed hook). '
52
- + `Project trust: ${trust.project}; hook review: ${trust.hookReview}. ${nextStep} ${CODEX_EXEC_HOOK_TRUST_DETAIL}`,
53
- } : null;
99
+ + `Project trust: ${trust.project}; hook review: ${trust.hookReview}. Detected Codex version: ${version}. `
100
+ + `${nextStep} ${CODEX_EXEC_HOOK_TRUST_DETAIL} `
101
+ + 'For trusted projects, this advisory is shown once per hook digest; changes to the script or registration re-raise it.',
102
+ };
54
103
  }
55
104
  //# sourceMappingURL=codex-trust.js.map