@aiwg/cli 2026.10.14 → 2026.10.15

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 (56) hide show
  1. package/agentic/code/addons/aiwg-utils/rules/anti-laziness.core.md +13 -0
  2. package/agentic/code/addons/aiwg-utils/rules/anti-laziness.md +118 -0
  3. package/dist/src/artifacts/corpus-tools/cli.js +32 -0
  4. package/dist/src/artifacts/corpus-tools/discovery-log.js +1 -1
  5. package/dist/src/artifacts/corpus-tools/expand-cli.js +89 -0
  6. package/dist/src/artifacts/corpus-tools/expand-queue.js +38 -0
  7. package/dist/src/artifacts/corpus-tools/expand-state.js +40 -0
  8. package/dist/src/artifacts/corpus-tools/expand.js +125 -0
  9. package/dist/src/artifacts/corpus-tools/resolve-cli.js +91 -0
  10. package/dist/src/artifacts/corpus-tools/resolve-corpus.js +41 -0
  11. package/dist/src/artifacts/corpus-tools/resolve.js +105 -0
  12. package/dist/src/cli/handlers/doctor-args.js +40 -0
  13. package/dist/src/cli/handlers/doctor-help.js +4 -2
  14. package/dist/src/cli/handlers/utilities.js +5 -31
  15. package/dist/src/config/worker-context.js +33 -4
  16. package/dist/src/decision/heldout/collector.js +1 -1
  17. package/dist/src/features/catalog.js +1 -1
  18. package/dist/src/gates/evaluate.js +2 -2
  19. package/dist/src/gates/heldout.js +42 -0
  20. package/dist/src/gates/index.js +2 -1
  21. package/dist/src/models/worker-installation-store.mjs +228 -0
  22. package/dist/src/models/worker-installation.mjs +7 -162
  23. package/dist/src/providers/provider-definitions.js +10 -10
  24. package/dist/src/research/clients/arxiv.js +10 -4
  25. package/dist/src/research/clients/base.js +5 -4
  26. package/dist/src/research/clients/crossref.js +9 -1
  27. package/dist/src/research/clients/semantic-scholar.js +73 -44
  28. package/dist/src/research/identity.js +85 -0
  29. package/dist/src/research/index.js +1 -0
  30. package/dist/src/research/reference-match.js +89 -0
  31. package/dist/src/rules/core-startup.d.mts +2 -0
  32. package/dist/src/rules/core-startup.mjs +31 -0
  33. package/dist/src/smiths/context-pipeline/agents-md.js +34 -0
  34. package/dist/src/smiths/context-pipeline/aiwg-md.js +3 -0
  35. package/dist/src/smiths/context-pipeline/bridge-ownership.js +50 -0
  36. package/dist/src/smiths/context-pipeline/generator.js +40 -104
  37. package/dist/src/smiths/context-pipeline/managed-hook.js +10 -0
  38. package/package.json +4 -2
  39. package/tools/agents/deploy-agents.mjs +2 -123
  40. package/tools/agents/providers/antigravity.mjs +1 -1
  41. package/tools/agents/providers/context-write.mjs +12 -0
  42. package/tools/agents/providers/grok-build.mjs +8 -5
  43. package/tools/agents/providers/hermes-skill-lifecycle.mjs +144 -0
  44. package/tools/agents/providers/hermes-startup.mjs +209 -0
  45. package/tools/agents/providers/hermes.mjs +9 -359
  46. package/tools/agents/providers/model-wrapper.mjs +5 -1
  47. package/tools/agents/providers/muse.mjs +3 -3
  48. package/tools/agents/providers/pi.mjs +1 -1
  49. package/tools/agents/providers/rule-delivery.mjs +23 -225
  50. package/tools/agents/providers/rule-presentation.mjs +13 -4
  51. package/tools/agents/providers/rule-projection.mjs +119 -0
  52. package/tools/agents/providers/rule-startup.mjs +70 -0
  53. package/tools/agents/providers/stale-artifact-prune.mjs +128 -0
  54. package/tools/agents/providers/warp.mjs +2 -2
  55. package/tools/agents/providers/windsurf.mjs +11 -57
  56. package/tools/plugin/plugin-links.mjs +3 -0
@@ -0,0 +1,128 @@
1
+ /** Preserve projector-owned rules while pruning stale legacy flat artifacts. */
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { computeAllArtifactBasenames, computeAllSkillNames, pruneStaleAiwgFiles, resolveAiwgRoot } from './base.mjs';
5
+
6
+ /**
7
+ * After a deploy, prune AIWG-managed flat artifacts (agents/commands/rules)
8
+ * whose source no longer ships them — mirroring the skills holistic prune.
9
+ *
10
+ * Safety boundaries:
11
+ * - Runs ONLY for AIWG framework/addon deploys (default source = AIWG root,
12
+ * or `--source` under `<aiwgRoot>/agentic/code`). Project-local bundle
13
+ * deploys (`--source <bundle>`) are skipped so a bundle's just-deployed
14
+ * artifacts are never mistaken for stale framework files.
15
+ * - `pruneStaleAiwgFiles` itself only removes files carrying an AIWG
16
+ * ownership signal (sidecar entry or `aiwg:managed` marker) AND whose
17
+ * stem is absent from the global, mode-independent source set, so
18
+ * user-authored files and sibling-framework artifacts always survive.
19
+ * - Aggregate-file paths (e.g. `AGENTS.md`) and unset paths are skipped.
20
+ *
21
+ * @param {object} provider loaded provider module
22
+ * @param {string} target deploy target dir
23
+ * @param {string} srcRoot effective deploy source
24
+ * @param {object} opts deploy opts (dryRun/verbose/quiet + deploy flags)
25
+ * @param {string|null} explicitSource the raw `--source` value (null when unset)
26
+ */
27
+ /** Bundles whose deploy is itself the kernel-only bulk install. */
28
+ const BULK_INSTALL_BUNDLES = new Set(['all']);
29
+
30
+ /**
31
+ * True when the kernel-only bulk install is the only thing this project has
32
+ * deployed, so clearing leftover flat artifacts is a migration and not a
33
+ * deletion of another bundle's surface (#2508).
34
+ *
35
+ * A project with no readable `.aiwg/aiwg.config` has no recorded owner, so the
36
+ * pre-#152 migration cleanup still applies.
37
+ */
38
+ export function bulkInstallOwnsFlatArtifacts(target) {
39
+ let installed;
40
+ try {
41
+ const raw = fs.readFileSync(path.join(target, '.aiwg', 'aiwg.config'), 'utf8');
42
+ installed = JSON.parse(raw)?.installed;
43
+ } catch {
44
+ return true;
45
+ }
46
+ if (!installed || typeof installed !== 'object') return true;
47
+ return !Object.keys(installed).some(name => !BULK_INSTALL_BUNDLES.has(name));
48
+ }
49
+
50
+ export function pruneStaleAiwgArtifacts(provider, target, srcRoot, opts, explicitSource) {
51
+ if (opts.skillsOnly && !opts.kernelOnly) return; // skills run their own prune in the provider
52
+
53
+ const aiwgRoot = resolveAiwgRoot(srcRoot);
54
+ if (!aiwgRoot) return; // no AIWG tree → bundle/standalone deploy; never prune
55
+
56
+ // Gate: only framework/addon deploys are eligible. A default deploy (no
57
+ // --source) sources from the AIWG root. An explicit --source is eligible
58
+ // only when it lives under <aiwgRoot>/agentic/code (bundled fw/addon).
59
+ if (explicitSource) {
60
+ const codeRoot = path.join(aiwgRoot, 'agentic', 'code');
61
+ const rel = path.relative(codeRoot, path.resolve(explicitSource));
62
+ const underCode = !!rel && !rel.startsWith('..') && !path.isAbsolute(rel);
63
+ if (!underCode) return; // project-local bundle / external source → skip
64
+ }
65
+
66
+ if (opts.kernelOnly) {
67
+ // Kernel-only delivers skills and rules. The empty desired set below
68
+ // applies only to bulk agents/commands left by
69
+ // the pre-#152 bulk default, when the bulk install is the only thing this
70
+ // project ever deployed.
71
+ //
72
+ // #2508: applying it unconditionally deleted every artifact a sibling
73
+ // bundle owned — `aiwg use sdlc` followed by `aiwg use all` took
74
+ // .claude/agents from 139 to 0. When another bundle is installed, it owns
75
+ // this surface deliberately and the migration assumption does not hold.
76
+ if (!bulkInstallOwnsFlatArtifacts(target)) {
77
+ if (opts.verbose) {
78
+ console.log('skip kernel-only flat prune: another installed bundle owns agents/commands/rules');
79
+ }
80
+ return;
81
+ }
82
+ for (const type of ['agents', 'commands']) {
83
+ const relPath = provider.paths?.[type];
84
+ if (!relPath || relPath.endsWith('.md')) continue;
85
+ const destDir = path.isAbsolute(relPath) ? relPath : path.join(target, relPath);
86
+ pruneStaleAiwgFiles(destDir, new Set(), {
87
+ dryRun: opts.dryRun,
88
+ verbose: opts.verbose,
89
+ artifactExtensions: ['.md', '.mdc', '.toml'],
90
+ });
91
+ }
92
+ return;
93
+ }
94
+
95
+ const typesThisRun = [];
96
+ if (!opts.commandsOnly && !opts.rulesOnly) typesThisRun.push('agents');
97
+ if (opts.deployCommands || opts.commandsOnly) typesThisRun.push('commands');
98
+ if (opts.deployRules || opts.rulesOnly) typesThisRun.push('rules');
99
+
100
+ for (const type of typesThisRun) {
101
+ const relPath = provider.paths?.[type];
102
+ if (!relPath) continue; // type not file-deployed by provider
103
+ if (relPath.endsWith('.md')) continue; // aggregate file (e.g. AGENTS.md)
104
+
105
+ const desired = computeAllArtifactBasenames(srcRoot, type);
106
+ if (!desired) continue; // no global desired set → skip
107
+
108
+ const destDir = path.isAbsolute(relPath) ? relPath : path.join(target, relPath);
109
+ // Activation projection owns its complete selected rule set, including extensions.
110
+ // Its transactional replacement already removes retired managed rule files.
111
+ if (type === 'rules') {
112
+ const receipt = path.join(destDir, '.aiwg-manifest.json');
113
+ if (fs.existsSync(receipt) && JSON.parse(fs.readFileSync(receipt, 'utf8')).delivery) continue;
114
+ }
115
+ const removed = pruneStaleAiwgFiles(destDir, desired, {
116
+ dryRun: opts.dryRun,
117
+ verbose: opts.verbose,
118
+ // Retire wrappers whose source skill no longer ships (#2511). Only the
119
+ // command directory holds them; the kernel-only branch returns earlier,
120
+ // so a bulk install still cannot touch wrappers it did not write.
121
+ skillCommandStems: type === 'commands' ? computeAllSkillNames(srcRoot) : null,
122
+ });
123
+ if (removed.length > 0 && !opts.quiet) {
124
+ console.log(` Pruned: ${removed.length} stale AIWG ${type} file${removed.length === 1 ? '' : 's'}`);
125
+ }
126
+ }
127
+ }
128
+
@@ -12,7 +12,7 @@ import { importImpl } from '../../_resolve-impl.mjs';
12
12
  * - Commands: WARP.md (aggregated only — Warp does not discover .warp/commands/)
13
13
  * - Skills: .warp/skills/ (discrete — natively discovered by Warp)
14
14
  * - Skills: .agents/skills/ (cross-agent compatibility path)
15
- * - Rules: WARP.md (aggregated only — Warp does not discover .warp/rules/)
15
+ * - Rules: .warp/rules/ (read through the mandatory WARP.md hook)
16
16
  *
17
17
  * Special features:
18
18
  * - Aggregated WARP.md for agents, commands, and rules
@@ -71,7 +71,7 @@ export const support = {
71
71
  agents: 'aggregated', // WARP.md primary; files mirrored for portability
72
72
  commands: 'conventional', // .warp/commands/ mirror for slash-command parity
73
73
  skills: 'native', // .warp/skills/ — natively discovered by Warp
74
- rules: 'aggregated' // WARP.md primary; rule files mirrored for portability
74
+ rules: 'prose-hook' // WARP.md requires reading the complete rule files
75
75
  };
76
76
 
77
77
  export const capabilities = {
@@ -4,11 +4,11 @@ import { importImpl } from '../../_resolve-impl.mjs';
4
4
  * Devin Desktop Provider (Windsurf compatibility adapter)
5
5
  *
6
6
  * Deploys agents to the Devin Desktop/Windsurf compatibility surface with
7
- * aggregated AGENTS.md and trigger-frontmatter rules. The provider id and
7
+ * minimal AGENTS.md hooks and trigger-frontmatter rules. The provider id and
8
8
  * generated `.windsurf/` paths remain stable for backward compatibility.
9
9
  *
10
10
  * Deployment paths:
11
- * - Output: AGENTS.md (aggregated agents)
11
+ * - Output: AGENTS.md (bootstrap, compact core and rules hook)
12
12
  * - Output: .windsurf/rules/aiwg-orchestration.md (orchestration context, trigger: always_on)
13
13
  * - Output: .windsurfrules (deprecated stub — retained for backward compat only)
14
14
  * - Workflows: .windsurf/workflows/ (commands as workflows)
@@ -17,7 +17,7 @@ import { importImpl } from '../../_resolve-impl.mjs';
17
17
  * - Rules: .windsurf/rules/ (discrete rule files with trigger frontmatter)
18
18
  *
19
19
  * Special features:
20
- * - Aggregated output (all agents in single AGENTS.md)
20
+ * - Discrete agent definitions reached through the rules index
21
21
  * - Plain markdown format (no YAML frontmatter)
22
22
  * - Capabilities tags for tools
23
23
  * - Workflow format for commands
@@ -237,60 +237,14 @@ export function mapModel(shorthand, modelCfg, modelsConfig) {
237
237
  */
238
238
  export function generateAgentsMd(files, destPath, opts) {
239
239
  if (opts.contextFiles === false) return;
240
- const { dryRun } = opts;
241
-
242
- const lines = [];
243
- lines.push('# AGENTS.md');
244
- // Canonical AIWG signature in the first 4 lines so the context-pipeline
245
- // `isOverwriteSafe` check (#1239) recognizes this file as AIWG-managed and
246
- // overwrites it with the thin-pointer body. Without this, context-pipeline
247
- // refuses to replace the legacy 2MB+ aggregate writer's output.
248
- lines.push('<!-- aiwg-managed -->');
249
- lines.push('');
250
- lines.push('> AIWG Agent Directory for Devin Desktop');
251
- lines.push('');
252
- lines.push('<!--');
253
- lines.push(' Generated by AIWG for Devin Desktop using the Windsurf compatibility adapter.');
254
- lines.push(' Devin Desktop reads this file for directory-scoped AI instructions.');
255
- lines.push(' See: https://docs.devin.ai/onboard-devin/agents-md');
256
- lines.push('-->');
257
- lines.push('');
258
- lines.push('## Table of Contents');
259
- lines.push('');
260
-
261
- // Build TOC and collect agents
262
- const agents = [];
263
- for (const f of files) {
264
- const content = fs.readFileSync(f, 'utf8');
265
- const nameMatch = content.match(/^name:\s*(.+)$/m);
266
- const agentName = nameMatch ? nameMatch[1].trim() : path.basename(f, '.md');
267
- agents.push({ name: agentName, file: f, content });
268
- const anchor = agentName.replace(/\s+/g, '-').toLowerCase();
269
- lines.push(`- [${agentName}](#${anchor})`);
270
- }
271
- lines.push('');
272
- lines.push('---');
273
- lines.push('');
274
-
275
- // Add each agent
276
- for (const agent of agents) {
277
- const transformed = transformAgent(agent.file, agent.content, opts);
278
- lines.push(transformed);
279
- lines.push('');
280
- lines.push('---');
281
- lines.push('');
282
- }
283
-
284
- const output = lines.join('\n');
285
-
286
- if (dryRun) {
287
- console.log(`[dry-run] Would write AGENTS.md with ${agents.length} agents`);
288
- } else {
289
- writeContextFileSync(destPath, output, 'utf8');
290
- console.log(`Created AGENTS.md with ${agents.length} agents at ${path.relative(process.cwd(), destPath)}`);
291
- }
292
-
293
- return agents.length;
240
+ // Keep definitions in the existing mirror directory; the rules index routes
241
+ // invocation so the shared startup file stays a bootstrap/core/hook surface.
242
+ const target = path.dirname(destPath);
243
+ const dir = path.join(target, paths.agents);
244
+ ensureDir(dir, opts.dryRun);
245
+ deployFiles(files, dir, opts, transformAgent);
246
+ if (!opts.dryRun && !fs.existsSync(destPath)) writeContextFileSync(destPath, '<!-- aiwg-managed -->\n');
247
+ return files.length;
294
248
  }
295
249
 
296
250
  // ============================================================================
@@ -94,6 +94,9 @@ export function rewritePublishedMarkdown(body, file, payloadRoot, repoRoot = pat
94
94
  let rewritten = body;
95
95
  for (const link of markdownLinks(body).reverse()) {
96
96
  let published = PUBLISHED_LINKS[link.target];
97
+ if (link.target.startsWith('$AIWG_ROOT/docs/')) {
98
+ published = link.target.slice('$AIWG_ROOT/'.length);
99
+ }
97
100
  // Root docs appear at different depths in skills and copied docs.
98
101
  // Never let a path into this checkout satisfy an installed plugin.
99
102
  if (!published && /^(?:\.\.\/)+docs\//.test(link.target)) {