@aiwg/cli 2026.11.8 → 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 (157) hide show
  1. package/README.md +1 -1
  2. package/agentic/code/providers/capability-matrix.yaml +4 -4
  3. package/agentic/code/providers/model-capabilities.v1.json +150 -28
  4. package/agentic/code/providers/model-catalog.v1.json +6 -5
  5. package/bin/aiwg.mjs +3 -1
  6. package/dist/src/agents/agent-packager.js +3 -3
  7. package/dist/src/artifacts/cli.js +6 -2
  8. package/dist/src/artifacts/fortemi-core-sync.js +2 -0
  9. package/dist/src/artifacts/index-query-help.js +27 -0
  10. package/dist/src/artifacts/query-engine-installation.js +17 -4
  11. package/dist/src/artifacts/query-engine-name-intent.js +56 -0
  12. package/dist/src/artifacts/query-engine-scoring.js +14 -8
  13. package/dist/src/artifacts/query-engine-show-card.js +3 -3
  14. package/dist/src/cli/agent-spawn.js +4 -4
  15. package/dist/src/cli/handlers/best-practices-audit.js +1 -1
  16. package/dist/src/cli/handlers/bundle-deployment-mode.js +26 -13
  17. package/dist/src/cli/handlers/bundle-reconciliation.js +2 -2
  18. package/dist/src/cli/handlers/init.js +1 -1
  19. package/dist/src/cli/handlers/issues.js +5 -0
  20. package/dist/src/cli/handlers/marketplace-plugin-search.js +6 -5
  21. package/dist/src/cli/handlers/marketplace.js +1 -1
  22. package/dist/src/cli/handlers/models-muse-wrapper.js +32 -0
  23. package/dist/src/cli/handlers/models.js +5 -4
  24. package/dist/src/cli/handlers/refresh-artifact-freshness.js +51 -0
  25. package/dist/src/cli/handlers/refresh-bundles.js +3 -0
  26. package/dist/src/cli/handlers/refresh-managed-deployment.js +6 -4
  27. package/dist/src/cli/handlers/refresh.js +7 -3
  28. package/dist/src/cli/handlers/repo-access.js +15 -2
  29. package/dist/src/cli/handlers/sdlc-accelerate.js +1 -1
  30. package/dist/src/cli/handlers/steward.js +1 -1
  31. package/dist/src/cli/handlers/subcommands-bundles.js +1 -1
  32. package/dist/src/cli/handlers/subcommands-discovery.js +5 -0
  33. package/dist/src/cli/handlers/subcommands-list.js +1 -1
  34. package/dist/src/cli/handlers/subcommands-plugins.js +1 -1
  35. package/dist/src/cli/handlers/subcommands-storage.js +11 -0
  36. package/dist/src/cli/handlers/team.js +1 -1
  37. package/dist/src/cli/handlers/use-additive-bundles.js +9 -2
  38. package/dist/src/cli/handlers/use-bundle-counts.js +1 -1
  39. package/dist/src/cli/handlers/use-copy-selection.js +42 -0
  40. package/dist/src/cli/handlers/use.js +33 -38
  41. package/dist/src/cli/handlers/workspace-context.js +4 -0
  42. package/dist/src/cli/help-generator.js +1 -1
  43. package/dist/src/cli/new-project-options.js +46 -0
  44. package/dist/src/cli/router.js +15 -4
  45. package/dist/src/cli/scope-resolver.js +6 -6
  46. package/dist/src/cli/services/deployment-probe-scope.js +11 -0
  47. package/dist/src/cli/services/deployment-staleness.js +83 -0
  48. package/dist/src/cli/services/deployment-verification.js +20 -11
  49. package/dist/src/config/aiwg-config.js +1 -1
  50. package/dist/src/config/authorization-cli.js +36 -1
  51. package/dist/src/config/config-normalization.js +3 -1
  52. package/dist/src/data/community.yaml +3 -3
  53. package/dist/src/extensions/commands/definitions.js +2 -2
  54. package/dist/src/extensions/manifest.js +27 -1
  55. package/dist/src/extensions/user-hook-diagnostics.js +6 -4
  56. package/dist/src/extensions/verified-hook-command.js +7 -5
  57. package/dist/src/features/catalog.js +2 -2
  58. package/dist/src/issues/cli.js +10 -2
  59. package/dist/src/marketplace/cache.js +31 -0
  60. package/dist/src/marketplace/plugin-search.js +39 -20
  61. package/dist/src/marketplace/public-search.js +122 -0
  62. package/dist/src/marketplace/registry.js +2 -0
  63. package/dist/src/marketplace/search-contract.js +19 -0
  64. package/dist/src/marketplace/sources/public-search.js +81 -0
  65. package/dist/src/mcp/cli.mjs +8 -7
  66. package/dist/src/mcp/credentials.mjs +1 -1
  67. package/dist/src/mcp/registry.js +6 -2
  68. package/dist/src/mcp/tool-filters.mjs +1 -1
  69. package/dist/src/memory/provider-memory-adapter.js +1 -1
  70. package/dist/src/models/catalog-policy.js +2 -1
  71. package/dist/src/models/config-loader.js +2 -1
  72. package/dist/src/models/cursor-worker-version.d.mts +2 -0
  73. package/dist/src/models/cursor-worker-version.mjs +27 -0
  74. package/dist/src/models/model-capabilities.v1.json +150 -28
  75. package/dist/src/models/model-catalog.v1.json +6 -5
  76. package/dist/src/models/model-discovery.js +3 -3
  77. package/dist/src/models/policy-resources.js +1 -1
  78. package/dist/src/models/worker-direct-readiness.js +8 -5
  79. package/dist/src/models/worker-installation.d.mts +3 -2
  80. package/dist/src/models/worker-installation.mjs +12 -10
  81. package/dist/src/models/worker-invocation-policy.js +1 -1
  82. package/dist/src/models/wrapper-deployment.js +1 -1
  83. package/dist/src/models/wrapper-enforcement.js +6 -2
  84. package/dist/src/plugin/skill-command-frontmatter.js +1 -1
  85. package/dist/src/plugin/skill-command-translator.js +1 -1
  86. package/dist/src/policy/repo-access-workspace-spec.js +63 -0
  87. package/dist/src/policy/repo-access.js +22 -0
  88. package/dist/src/providers/capability-matrix.yaml +4 -4
  89. package/dist/src/providers/deployment-ownership.mjs +1 -1
  90. package/dist/src/providers/deployment-preservation.mjs +10 -5
  91. package/dist/src/providers/deployment-removal.js +1 -1
  92. package/dist/src/providers/devin-compat.d.mts +4 -0
  93. package/dist/src/providers/devin-compat.mjs +29 -0
  94. package/dist/src/providers/grok-build-acp.js +39 -9
  95. package/dist/src/providers/grok-build-paths.js +8 -7
  96. package/dist/src/providers/provider-context-contracts.js +4 -3
  97. package/dist/src/providers/provider-definition-schema.js +1 -1
  98. package/dist/src/providers/provider-definitions.js +1 -1
  99. package/dist/src/providers/provider-definitions.mjs +3 -3
  100. package/dist/src/providers/provider-inventory.js +13 -1
  101. package/dist/src/providers/provider-seeds-3.js +10 -9
  102. package/dist/src/providers/transformation-receipt-integration.js +1 -1
  103. package/dist/src/sessions/adapters/windsurf.js +7 -7
  104. package/dist/src/sessions/grok-build-cli-output.js +1 -1
  105. package/dist/src/sessions/grok-build-cli.js +7 -1
  106. package/dist/src/skills/bundle-import-cli.js +61 -0
  107. package/dist/src/skills/bundle-import-plan.js +108 -0
  108. package/dist/src/skills/bundle-import.js +192 -0
  109. package/dist/src/skills/cli.js +5 -0
  110. package/dist/src/skills/deployment-policy.js +1 -1
  111. package/dist/src/skills/importer.js +4 -4
  112. package/dist/src/smiths/agentsmith/demo.js +1 -1
  113. package/dist/src/smiths/agentsmith/examples.js +6 -6
  114. package/dist/src/smiths/commandsmith/generator.js +1 -1
  115. package/dist/src/smiths/context-pipeline/allowlist.js +1 -1
  116. package/dist/src/smiths/context-pipeline/parallelism-section.js +2 -2
  117. package/dist/src/smiths/skillsmith/collision-detector.js +1 -1
  118. package/dist/src/smiths/skillsmith/namespace-adapter.js +1 -1
  119. package/dist/src/smiths/skillsmith/platform-resolver.js +2 -2
  120. package/dist/src/writing/campaign-report.js +4 -3
  121. package/dist/src/writing/contextual-diagnostics.js +27 -2
  122. package/dist/src/writing/current-patterns.js +1 -0
  123. package/dist/src/writing/structural-judgment.catalogue.json +17 -0
  124. package/dist/src/writing/structural-judgment.js +33 -0
  125. package/dist/src/writing/structural-patterns.js +55 -0
  126. package/dist/src/writing/validation-campaign.js +3 -0
  127. package/dist/src/writing/validation-engine.js +7 -4
  128. package/package.json +4 -2
  129. package/schemas/models/model-config-compatibility.v1.schema.json +1 -1
  130. package/tools/agents/deploy-agents.mjs +12 -10
  131. package/tools/agents/deploy-options.mjs +1 -0
  132. package/tools/agents/providers/base-behaviors.mjs +1 -1
  133. package/tools/agents/providers/base-contract.mjs +1 -1
  134. package/tools/agents/providers/base-kernel-skills.mjs +1 -1
  135. package/tools/agents/providers/base-models-platforms.mjs +9 -7
  136. package/tools/agents/providers/base-rule-index.mjs +1 -1
  137. package/tools/agents/providers/codex.mjs +1 -0
  138. package/tools/agents/providers/devin.mjs +3 -0
  139. package/tools/agents/providers/grok-build.mjs +14 -19
  140. package/tools/agents/providers/hook-capabilities.mjs +1 -1
  141. package/tools/agents/providers/model-wrapper.mjs +1 -1
  142. package/tools/agents/providers/rule-delivery-surface.mjs +14 -10
  143. package/tools/agents/providers/rule-deployment-prepare.mjs +8 -8
  144. package/tools/agents/providers/rule-projection.mjs +5 -5
  145. package/tools/agents/providers/rule-startup.mjs +1 -1
  146. package/tools/agents/providers/skill-copy-prune.mjs +5 -1
  147. package/tools/agents/providers/windsurf.mjs +26 -26
  148. package/tools/agents/use-rule-selection.mjs +1 -1
  149. package/tools/cli/workspace-deployment-health.mjs +38 -0
  150. package/tools/cli/workspace-status.mjs +5 -2
  151. package/tools/daemon/provider-watcher.mjs +3 -3
  152. package/tools/plugin/package-plugins.mjs +16 -2
  153. package/tools/ralph-external/lib/deepseek-harness-adapter.mjs +36 -22
  154. package/tools/ralph-external/lib/factory-adapter.mjs +13 -28
  155. package/tools/ralph-external/lib/factory-stream-final.mjs +31 -0
  156. package/tools/skills/deploy-skills-codex.mjs +2 -1
  157. package/vscode-extension/schemas/aiwg.config.v1.json +2 -1
@@ -57,12 +57,12 @@ export class DevinDesktopSessionAdapter {
57
57
  for await (const line of input) {
58
58
  const parsed = StepSchema.safeParse(line.value);
59
59
  if (!parsed.success) {
60
- throw new SessionContractError('MALFORMED_SOURCE', 'Windsurf transcript step is malformed', schemaRejectionDetail(parsed.error));
60
+ throw new SessionContractError('MALFORMED_SOURCE', 'Devin Desktop transcript step is malformed', schemaRejectionDetail(parsed.error));
61
61
  }
62
62
  const step = parsed.data;
63
63
  const currentVersion = step.schema_version ?? DEVIN_DESKTOP_TRANSCRIPT_SCHEMA_VERSION;
64
64
  if (schemaVersion && schemaVersion !== currentVersion) {
65
- throw new SessionContractError('SCHEMA_DRIFT', 'mixed Windsurf transcript schemas', schemaIssueDetail('schema_version'));
65
+ throw new SessionContractError('SCHEMA_DRIFT', 'mixed Devin Desktop transcript schemas', schemaIssueDetail('schema_version'));
66
66
  }
67
67
  schemaVersion = currentVersion;
68
68
  assertSupportedSchemaMajor(schemaVersion);
@@ -70,7 +70,7 @@ export class DevinDesktopSessionAdapter {
70
70
  ?? nativeSessionId
71
71
  ?? basename(source.locator, '.jsonl');
72
72
  if (step.trajectory_id && nativeSessionId && step.trajectory_id !== nativeSessionId) {
73
- throw new SessionContractError('SCHEMA_DRIFT', 'mixed Windsurf trajectory identities', schemaIssueDetail('trajectory_id'));
73
+ throw new SessionContractError('SCHEMA_DRIFT', 'mixed Devin Desktop trajectory identities', schemaIssueDetail('trajectory_id'));
74
74
  }
75
75
  nativeSessionId = currentSession;
76
76
  if (seen++ < start)
@@ -78,7 +78,7 @@ export class DevinDesktopSessionAdapter {
78
78
  yield normalizeStep(step, currentSession, line.sequence, line.byteOffset, canonicalLocatorClass(source.locatorClass), schemaVersion);
79
79
  }
80
80
  if (seen === 0) {
81
- throw new SessionContractError('MALFORMED_SOURCE', 'Windsurf transcript is empty or malformed', schemaIssueDetail('<root>'));
81
+ throw new SessionContractError('MALFORMED_SOURCE', 'Devin Desktop transcript is empty or malformed', schemaIssueDetail('<root>'));
82
82
  }
83
83
  return {
84
84
  sourceSchemaVersion: schemaVersion,
@@ -91,7 +91,7 @@ export class DevinDesktopSessionAdapter {
91
91
  throw new SessionContractError('UNSUPPORTED_OPERATION', 'legacy Devin Desktop/Windsurf protobuf stores are unsupported; enable post_cascade_response_with_transcript and select its JSONL output');
92
92
  }
93
93
  if (!isCurrentHookLocator(source.locatorClass)) {
94
- throw new SessionContractError('UNSUPPORTED_OPERATION', 'Devin Desktop (Windsurf compatibility) requires an explicitly selected post_cascade_response_with_transcript JSONL file');
94
+ throw new SessionContractError('UNSUPPORTED_OPERATION', 'Devin Desktop (legacy transcript compatibility) requires an explicitly selected post_cascade_response_with_transcript JSONL file');
95
95
  }
96
96
  }
97
97
  }
@@ -169,7 +169,7 @@ function timestamp(value) {
169
169
  return undefined;
170
170
  const date = new Date(value);
171
171
  if (Number.isNaN(date.getTime())) {
172
- throw new SessionContractError('AMBIGUOUS_TIMESTAMP', 'invalid Windsurf timestamp');
172
+ throw new SessionContractError('AMBIGUOUS_TIMESTAMP', 'invalid Devin Desktop timestamp');
173
173
  }
174
174
  return date.toISOString();
175
175
  }
@@ -177,7 +177,7 @@ function parseCursor(value) {
177
177
  if (!value)
178
178
  return 0;
179
179
  if (!/^\d+$/.test(value))
180
- throw new SessionContractError('SCHEMA_DRIFT', 'invalid Windsurf cursor', schemaIssueDetail('cursor'));
180
+ throw new SessionContractError('SCHEMA_DRIFT', 'invalid Devin Desktop cursor', schemaIssueDetail('cursor'));
181
181
  return Number(value);
182
182
  }
183
183
  //# sourceMappingURL=windsurf.js.map
@@ -68,7 +68,7 @@ const eventKeys = {
68
68
  const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
69
69
  export function validateGrokHeadlessEnvelope(value, format) {
70
70
  const type = format === 'json' ? 'result' : String(value.type);
71
- const keys = type === 'result' ? resultKeys : eventKeys[type];
71
+ const keys = type === 'result' ? resultKeys : Object.hasOwn(eventKeys, type) ? eventKeys[type] : undefined;
72
72
  if (!keys || Object.keys(value).some(key => !keys.includes(key)))
73
73
  drift('headless event');
74
74
  if (type === 'result' || type === 'end') {
@@ -60,7 +60,11 @@ export function parseGrokHeadlessSessionId(output, format) {
60
60
  }
61
61
  const lines = format === 'json' ? [output] : output.trim().split(/\r?\n/);
62
62
  const ids = new Set();
63
+ let ended = false;
63
64
  for (const line of lines) {
65
+ if (ended) {
66
+ throw new SessionContractError('SCHEMA_DRIFT', 'unrecognized Grok Build headless stream after final end; check CLI version and use a supported export');
67
+ }
64
68
  let value;
65
69
  try {
66
70
  value = JSON.parse(line);
@@ -72,6 +76,7 @@ export function parseGrokHeadlessSessionId(output, format) {
72
76
  throw new SessionContractError('SCHEMA_DRIFT', 'Grok Build headless event must be an object');
73
77
  }
74
78
  validateGrokHeadlessEnvelope(value, format);
79
+ ended = format === 'streaming-json' && value.type === 'end';
75
80
  const id = value.sessionId;
76
81
  if (id !== undefined) {
77
82
  if (typeof id !== 'string' || !UUID.test(id)) {
@@ -116,7 +121,8 @@ async function runGrok(options, args) {
116
121
  const home = resolveGrokHomeResult(env);
117
122
  if (!home.ok)
118
123
  throw new SessionContractError('SOURCE_NOT_AUTHORIZED', home.message);
119
- await rejectSymlinkComponents(home.path);
124
+ // The public CLI opens this store too; a safe home alone cannot authorize a linked store.
125
+ await rejectSymlinkComponents(join(home.path, 'sessions'));
120
126
  if (options.binary !== undefined && !isAbsolute(options.binary)) {
121
127
  throw new SessionContractError('SOURCE_NOT_AUTHORIZED', 'Grok Build binary override must be absolute');
122
128
  }
@@ -0,0 +1,61 @@
1
+ // Extend skills import with repository-to-addon and pinned refresh options.
2
+ import { importSkillBundle } from './bundle-import.js';
3
+ export async function handleBundleImport(args) {
4
+ const options = { projectDir: process.cwd() };
5
+ const positional = [];
6
+ const fields = { '--into': 'into', '--refresh': 'refresh', '--ref': 'ref', '--only': 'only' };
7
+ const json = args.includes('--json');
8
+ try {
9
+ for (let index = 0; index < args.length; index++) {
10
+ const arg = args[index];
11
+ if (Object.hasOwn(fields, arg)) {
12
+ const field = fields[arg];
13
+ const value = args[++index];
14
+ if (!value || value.startsWith('-') || options[field] !== undefined)
15
+ throw new Error(`${arg} requires one value`);
16
+ options[field] = value;
17
+ }
18
+ else if (arg === '--dry-run')
19
+ options.dryRun = true;
20
+ else if (arg === '--json')
21
+ continue;
22
+ else if (arg.startsWith('-'))
23
+ throw new Error(`Unknown bundle import option: ${arg}`);
24
+ else
25
+ positional.push(arg);
26
+ }
27
+ if (positional.length > 1)
28
+ throw new Error('Provide exactly one repository source');
29
+ options.source = positional[0];
30
+ // The report is deliberately emitted before the importer can write any project files.
31
+ options.report = (plan) => {
32
+ if (json)
33
+ console.log(JSON.stringify({ phase: 'preflight', ...plan }));
34
+ else {
35
+ console.log(`${plan.dryRun ? '[DRY RUN] ' : ''}Skill bundle preflight: ${plan.manifest.id}`);
36
+ for (const upstream of plan.manifest.upstream ?? [])
37
+ console.log(` ${upstream.repo} @ ${upstream.commit}`);
38
+ for (const item of plan.diagnostics)
39
+ console.log(` ${item.code}: ${item.file}: ${item.message}`);
40
+ for (const [kind, files] of Object.entries(plan.diff)) {
41
+ for (const file of files)
42
+ console.log(` ${kind}: ${file}`);
43
+ }
44
+ }
45
+ };
46
+ const result = await importSkillBundle(options);
47
+ if (json)
48
+ console.log(JSON.stringify({ phase: 'result', ...result }));
49
+ else
50
+ console.log(`${result.dryRun ? 'Planned' : 'Indexed'} ${result.manifest.skills?.length ?? 0} skills; installed: false`);
51
+ }
52
+ catch (error) {
53
+ const message = error instanceof Error ? error.message : String(error);
54
+ if (json)
55
+ console.log(JSON.stringify({ phase: 'error', message }));
56
+ else
57
+ console.error(`Error: ${message}`);
58
+ process.exit(1);
59
+ }
60
+ }
61
+ //# sourceMappingURL=bundle-import-cli.js.map
@@ -0,0 +1,108 @@
1
+ // Plan inert repository skill trees, exclusions, diagnostics and stable local names.
2
+ import path from 'node:path';
3
+ import { createHash } from 'node:crypto';
4
+ import { minimatch } from 'minimatch';
5
+ import { collectGitTree, DEFAULT_AGENT_SKILL_IMPORT_LIMITS } from './importer.js';
6
+ import { validateAgentSkillContent } from './validator.js';
7
+ export function repositoryKey(repo) {
8
+ const slug = path.basename(repo.replace(/\/$/, '').replace(/\.git$/, ''))
9
+ .toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '') || 'upstream';
10
+ return `${slug.slice(0, 40)}-${createHash('sha256').update(repo).digest('hex').slice(0, 8)}`;
11
+ }
12
+ const excluded = (file) => file.split('/').some(part => /^(?:tests?|__tests__|tools?|tooling|scripts|node_modules|\.git)$/i.test(part))
13
+ || /\.(?:test|spec)\.[^/]+$/i.test(file);
14
+ const licenseFile = (file) => /^(?:licen[cs]e|copying|notice)(?:[._-].*)?$/i.test(file);
15
+ function localName(name, prefix, occupied) {
16
+ const base = `${prefix}-${name}`.slice(0, 60).replace(/-$/, '');
17
+ let candidate = base;
18
+ let index = 2;
19
+ while (occupied.has(candidate))
20
+ candidate = `${base}-${index++}`;
21
+ return candidate;
22
+ }
23
+ export function planRepository(input) {
24
+ const materialized = collectGitTree({
25
+ kind: 'git', url: input.repo, revision: input.ref, subpath: '.',
26
+ }, { ...DEFAULT_AGENT_SKILL_IMPORT_LIMITS, maxFiles: 10_000 }, true);
27
+ if (materialized.source.kind !== 'git')
28
+ throw new Error('Expected pinned Git source');
29
+ const sourceFiles = new Map(materialized.entries.flatMap(entry => entry.kind === 'file' ? [[entry.path, entry.bytes]] : []));
30
+ const allNames = [...sourceFiles.keys()].flatMap(file => /^skills\/([^/]+)\/SKILL\.md$/.exec(file)?.[1] ?? []);
31
+ const names = input.pinned?.skills ?? allNames.filter(name => !input.only
32
+ || minimatch(name, input.only) || minimatch(`skills/${name}`, input.only));
33
+ if (!names.length)
34
+ throw new Error('No skills/*/SKILL.md trees match the selection');
35
+ const licenses = [...sourceFiles].filter(([file]) => licenseFile(file));
36
+ if (!licenses.length)
37
+ throw new Error(`No root license file found in ${input.repo}; review licensing before importing`);
38
+ const files = new Map();
39
+ const diagnostics = [];
40
+ const renames = { ...input.pinned?.renames };
41
+ const key = repositoryKey(input.repo);
42
+ const prefix = key.slice(0, key.lastIndexOf('-'));
43
+ for (const name of names.sort()) {
44
+ const skillFile = `skills/${name}/SKILL.md`;
45
+ const content = sourceFiles.get(skillFile)?.toString('utf8');
46
+ if (content === undefined)
47
+ throw new Error(`Pinned upstream skill is missing: ${skillFile}`);
48
+ const validation = validateAgentSkillContent(content, { profile: 'compatible', file: skillFile, directoryName: name });
49
+ if (!validation.valid)
50
+ throw new Error(`Invalid ${skillFile}: ${validation.diagnostics.map(d => d.message).join('; ')}`);
51
+ let target = renames[name] ?? name;
52
+ if (input.occupied.has(target)) {
53
+ if (input.pinned)
54
+ throw new Error(`Saved rename collides with existing skill: ${target}`);
55
+ target = localName(name, prefix, input.occupied);
56
+ renames[name] = target;
57
+ diagnostics.push({ code: 'collision', file: skillFile, message: `${name} collides; proposed local name: ${target}` });
58
+ }
59
+ input.occupied.add(target);
60
+ const selected = [...sourceFiles].filter(([file]) => file.startsWith(`skills/${name}/`));
61
+ for (const [file, bytes] of selected) {
62
+ const tail = file.slice(`skills/${name}/`.length);
63
+ if (/\.(?:[cm]?js|[cm]?ts|py|sh|bash|ps1|rb|pl|exe|dll|so|wasm)$/i.test(file)
64
+ || bytes.subarray(0, 2).toString() === '#!') {
65
+ diagnostics.push({ code: 'script', file, message: `Script or executable content (${excluded(tail) ? 'excluded' : 'copied inertly'})` });
66
+ }
67
+ if (bytes.includes(0))
68
+ diagnostics.push({ code: 'binary', file, message: 'Binary content; never executed by import' });
69
+ if (excluded(tail))
70
+ continue;
71
+ let output = bytes;
72
+ if (file === skillFile && target !== name) {
73
+ // Change only the frontmatter name; retain comments, body and upstream links verbatim.
74
+ output = Buffer.from(content.replace(/^(---\r?\n)([\s\S]*?)(\r?\n---)/, (_match, start, yaml, end) => start + yaml.replace(/^name\s*:.*$/m, `name: ${target}`) + end));
75
+ }
76
+ files.set(`skills/${target}/${tail}`, output);
77
+ }
78
+ // Local links and code-formatted paths may resolve from the skill or repository root.
79
+ const kept = new Set([...files.keys()].filter(file => file.startsWith(`skills/${target}/`))
80
+ .map(file => `skills/${name}/${file.slice(`skills/${target}/`.length)}`));
81
+ for (const [file, bytes] of selected) {
82
+ if (excluded(file.slice(`skills/${name}/`.length)) || !/\.(?:md|txt)$/i.test(file))
83
+ continue;
84
+ const tokens = bytes.toString('utf8').matchAll(/([^\s<>()`"'\[\]]+\/[^\s<>()`"'\[\]]+)/g);
85
+ for (const match of tokens) {
86
+ const ref = match[1].replace(/[#?].*$/, '').replace(/[.,;:]$/, '');
87
+ if (/^(?:[a-z]+:|\/\/)/i.test(ref))
88
+ continue;
89
+ const candidates = [path.posix.normalize(path.posix.join(path.posix.dirname(file), ref)), ref.replace(/^\.\//, '')];
90
+ if (!candidates.some(candidate => kept.has(candidate))) {
91
+ diagnostics.push({ code: 'dangling-reference', file, message: `${match[1]} is absent from the copied skill tree` });
92
+ }
93
+ }
94
+ }
95
+ }
96
+ for (const [file, bytes] of licenses)
97
+ files.set(`licenses/${key}/${file}`, bytes);
98
+ return {
99
+ files, diagnostics,
100
+ upstream: {
101
+ repo: input.repo, commit: materialized.source.resolvedRevision,
102
+ license: licenses.some(([, bytes]) => /MIT License|Permission is hereby granted/i.test(bytes.toString('utf8')))
103
+ ? 'MIT' : 'SEE LICENSE FILES',
104
+ skills: names, renames,
105
+ },
106
+ };
107
+ }
108
+ //# sourceMappingURL=bundle-import-plan.js.map
@@ -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/',
@@ -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
  }
@@ -32,7 +32,7 @@ const PLATFORM_BUILTINS = {
32
32
  'cursor': ['settings', 'chat', 'edit'],
33
33
  'codex': ['help', 'run', 'exec'],
34
34
  'copilot': ['help', 'explain', 'fix', 'tests', 'review'],
35
- 'windsurf': ['help', 'settings'],
35
+ 'devin': ['help', 'settings'],
36
36
  'opencode': ['help', 'run'],
37
37
  'warp': ['help', 'settings'],
38
38
  'hermes': [],
@@ -7,7 +7,7 @@
7
7
  * Platform groups:
8
8
  * Group A (deep-recursion): Claude Code, Cursor, Codex, OpenCode, OpenClaw
9
9
  * → Deploy both canonical subdir layout AND prefixed slug fallback.
10
- * Group B (one-level): Factory AI, Warp, Windsurf
10
+ * Group B (one-level): Factory AI, Warp, Devin Desktop
11
11
  * → Deploy only the prefixed slug; no subdir (would break one-level discovery).
12
12
  * Group C (unknown): GitHub Copilot
13
13
  * → Deploy only the prefixed slug (safe default until recursion depth confirmed).
@@ -98,7 +98,7 @@ export class PlatformSkillResolver {
98
98
  * Get path for a namespaced skill deployment.
99
99
  *
100
100
  * Platforms with subdirectory support deploy under `{baseDir}/{namespace}/{slug}/`.
101
- * Windsurf (1-level discovery) deploys flat at `{baseDir}/{slug}/`.
101
+ * Devin Desktop (1-level discovery) deploys flat at `{baseDir}/{slug}/`.
102
102
  *
103
103
  * @param platform - Target platform
104
104
  * @param projectPath - Project root directory
@@ -113,7 +113,7 @@ export class PlatformSkillResolver {
113
113
  if (config.supportsSubdirectory) {
114
114
  return path.join(baseDir, namespace, slug);
115
115
  }
116
- // Windsurf and other flat-discovery platforms: slug only, no namespace subdir
116
+ // Devin Desktop and other flat-discovery platforms: slug only, no namespace subdir
117
117
  return path.join(baseDir, slug);
118
118
  }
119
119
  /**