@aiwg/cli 2026.10.12 → 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 (104) 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/agentic/code/providers/pi/aiwg-bridge.ts +44 -1
  4. package/dist/src/artifacts/corpus-tools/cli.js +32 -0
  5. package/dist/src/artifacts/corpus-tools/discovery-log.js +1 -1
  6. package/dist/src/artifacts/corpus-tools/expand-cli.js +89 -0
  7. package/dist/src/artifacts/corpus-tools/expand-queue.js +38 -0
  8. package/dist/src/artifacts/corpus-tools/expand-state.js +40 -0
  9. package/dist/src/artifacts/corpus-tools/expand.js +125 -0
  10. package/dist/src/artifacts/corpus-tools/resolve-cli.js +91 -0
  11. package/dist/src/artifacts/corpus-tools/resolve-corpus.js +41 -0
  12. package/dist/src/artifacts/corpus-tools/resolve.js +105 -0
  13. package/dist/src/cli/handlers/doctor-args.js +40 -0
  14. package/dist/src/cli/handlers/doctor-help.js +4 -2
  15. package/dist/src/cli/handlers/use-bundle-counts.js +32 -6
  16. package/dist/src/cli/handlers/use-skill-assets.js +207 -0
  17. package/dist/src/cli/handlers/use.js +30 -193
  18. package/dist/src/cli/handlers/utilities.js +5 -31
  19. package/dist/src/config/authorization-cli.js +11 -3
  20. package/dist/src/config/worker-context.js +33 -4
  21. package/dist/src/decision/context-pruning-common.js +41 -0
  22. package/dist/src/decision/context-pruning-evaluation.js +366 -0
  23. package/dist/src/decision/context-pruning-pilot.js +431 -0
  24. package/dist/src/decision/context-pruning-types.js +19 -0
  25. package/dist/src/decision/context-pruning.js +5 -847
  26. package/dist/src/decision/ensemble/contract.js +4 -24
  27. package/dist/src/decision/heldout/collector.js +1 -1
  28. package/dist/src/decision/qualification/release.js +5 -62
  29. package/dist/src/extensions/manifest.js +8 -1
  30. package/dist/src/extensions/project-local-doctor.js +78 -2
  31. package/dist/src/extensions/validation.js +10 -11
  32. package/dist/src/features/catalog.js +1 -1
  33. package/dist/src/gates/evaluate.js +5 -15
  34. package/dist/src/gates/heldout.js +42 -0
  35. package/dist/src/gates/index.js +2 -1
  36. package/dist/src/gates/upstream-ceiling.js +111 -0
  37. package/dist/src/models/provider-models.js +5 -8
  38. package/dist/src/models/worker-installation-store.mjs +228 -0
  39. package/dist/src/models/worker-installation.mjs +7 -162
  40. package/dist/src/models/wrapper-definitions.js +14 -0
  41. package/dist/src/models/wrapper-deployment.js +48 -25
  42. package/dist/src/models/wrapper-enforcement.js +72 -0
  43. package/dist/src/policy/hitl-check.js +80 -0
  44. package/dist/src/providers/provider-definitions.js +10 -10
  45. package/dist/src/research/clients/arxiv.js +10 -4
  46. package/dist/src/research/clients/base.js +5 -4
  47. package/dist/src/research/clients/crossref.js +9 -1
  48. package/dist/src/research/clients/semantic-scholar.js +73 -44
  49. package/dist/src/research/identity.js +85 -0
  50. package/dist/src/research/index.js +1 -0
  51. package/dist/src/research/reference-match.js +89 -0
  52. package/dist/src/rules/activation.d.mts +2 -0
  53. package/dist/src/rules/activation.mjs +23 -0
  54. package/dist/src/rules/core-startup.d.mts +2 -0
  55. package/dist/src/rules/core-startup.mjs +31 -0
  56. package/dist/src/skills/adapters/local.js +32 -9
  57. package/dist/src/skills/agent-skills.js +2 -0
  58. package/dist/src/skills/cli-display.js +33 -0
  59. package/dist/src/skills/cli.js +2 -26
  60. package/dist/src/skills/collision-discovery.js +84 -0
  61. package/dist/src/skills/deployer.js +20 -75
  62. package/dist/src/skills/deployment-ownership.js +74 -0
  63. package/dist/src/skills/doctor.js +2 -2
  64. package/dist/src/skills/importer.js +4 -26
  65. package/dist/src/skills/registry.js +22 -7
  66. package/dist/src/smiths/context-pipeline/agents-md.js +34 -0
  67. package/dist/src/smiths/context-pipeline/aiwg-md.js +3 -0
  68. package/dist/src/smiths/context-pipeline/bridge-ownership.js +50 -0
  69. package/dist/src/smiths/context-pipeline/generator.js +40 -104
  70. package/dist/src/smiths/context-pipeline/managed-hook.js +10 -0
  71. package/dist/src/smiths/context-pipeline/parallelism-section.js +7 -3
  72. package/package.json +6 -2
  73. package/tools/agents/deploy-agents.mjs +2 -123
  74. package/tools/agents/providers/antigravity.mjs +4 -6
  75. package/tools/agents/providers/base.mjs +3 -3
  76. package/tools/agents/providers/claude.mjs +3 -5
  77. package/tools/agents/providers/codex.mjs +3 -5
  78. package/tools/agents/providers/context-write.mjs +12 -0
  79. package/tools/agents/providers/copilot.mjs +3 -5
  80. package/tools/agents/providers/cursor.mjs +3 -5
  81. package/tools/agents/providers/factory.mjs +3 -5
  82. package/tools/agents/providers/grok-build.mjs +17 -12
  83. package/tools/agents/providers/hermes-skill-lifecycle.mjs +144 -0
  84. package/tools/agents/providers/hermes-startup.mjs +209 -0
  85. package/tools/agents/providers/hermes.mjs +9 -359
  86. package/tools/agents/providers/model-wrapper.mjs +90 -0
  87. package/tools/agents/providers/muse.mjs +3 -3
  88. package/tools/agents/providers/omp.mjs +3 -1
  89. package/tools/agents/providers/openclaw.mjs +3 -5
  90. package/tools/agents/providers/opencode.mjs +3 -5
  91. package/tools/agents/providers/pi.mjs +1 -1
  92. package/tools/agents/providers/provider-paths-staging.mjs +9 -0
  93. package/tools/agents/providers/rule-delivery.mjs +26 -228
  94. package/tools/agents/providers/rule-presentation.mjs +13 -4
  95. package/tools/agents/providers/rule-projection.mjs +119 -0
  96. package/tools/agents/providers/rule-startup.mjs +70 -0
  97. package/tools/agents/providers/stale-artifact-prune.mjs +128 -0
  98. package/tools/agents/providers/warp.mjs +5 -7
  99. package/tools/agents/providers/windsurf.mjs +14 -62
  100. package/tools/plugin/package-plugins.mjs +2 -2
  101. package/tools/plugin/plugin-links.mjs +3 -0
  102. package/tools/skills/codex-skill-transform.mjs +232 -0
  103. package/tools/skills/deploy-skills-codex.mjs +8 -249
  104. package/tools/warp/warp-content.mjs +548 -0
@@ -0,0 +1,74 @@
1
+ // Verify managed projection ownership before discovery or mutation.
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { normalizeProviderDefinitionId } from '../providers/provider-definitions.js';
5
+ import { AGENT_SKILLS_SIDECAR_SCHEMA } from './agent-skills.js';
6
+ import { AGENT_SKILL_DEPLOYMENT_SIDECAR, AGENT_SKILL_MANAGED_MARKER, MARKER_CONTENT, } from './deployment-types.js';
7
+ export function readDeploymentSidecar(targetPath, expectedName, expectedProvider) {
8
+ try {
9
+ const sidecarPath = path.join(targetPath, AGENT_SKILL_DEPLOYMENT_SIDECAR);
10
+ const stat = fs.lstatSync(sidecarPath);
11
+ if (!stat.isFile() || stat.isSymbolicLink())
12
+ return undefined;
13
+ const value = JSON.parse(fs.readFileSync(sidecarPath, 'utf8'));
14
+ if (value.schemaVersion !== 1
15
+ || value.kind !== 'aiwg-managed-agent-skill-projection'
16
+ || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value.name)
17
+ || !normalizeProviderDefinitionId(value.provider)
18
+ || !/^[0-9a-f]{64}$/.test(value.sourceDigest)
19
+ || !['native', 'projected', 'degraded', 'unsupported'].includes(value.projectionStatus)
20
+ || !Array.isArray(value.reasons)
21
+ || !value.reasons.every((item) => typeof item === 'string')
22
+ || !Array.isArray(value.warnings)
23
+ || !value.warnings.every((item) => typeof item === 'string')
24
+ || value.portable?.$schema !== AGENT_SKILLS_SIDECAR_SCHEMA
25
+ || value.portable.schemaVersion !== 1
26
+ || typeof value.portable.aiwg !== 'object'
27
+ || value.portable.aiwg === null
28
+ || Array.isArray(value.portable.aiwg)
29
+ || value.portable.provenance?.sourceDigest !== value.sourceDigest
30
+ || !['strict', 'compatible', 'discovery'].includes(value.portable.validationProfile)
31
+ || !['untrusted', 'trusted', 'revoked'].includes(value.portable.trust?.state)
32
+ || !['inactive', 'active', 'blocked'].includes(value.portable.trust?.activation)
33
+ || (expectedName !== undefined && value.name !== expectedName)
34
+ || (expectedProvider !== undefined && value.provider !== expectedProvider)
35
+ || path.basename(targetPath) !== value.name) {
36
+ return undefined;
37
+ }
38
+ return value;
39
+ }
40
+ catch {
41
+ return undefined;
42
+ }
43
+ }
44
+ /**
45
+ * Codex, Antigravity, DeepSeek Harness, and Muse intentionally consume the
46
+ * same portable project skill surface (<repo>/.agents/skills). A projection
47
+ * written for any member is managed ownership for the others when the
48
+ * desired payload is otherwise byte-identical.
49
+ */
50
+ export function providersShareProjectionSurface(actual, expected) {
51
+ const shared = new Set(['antigravity', 'codex', 'deepseek-harness', 'muse']);
52
+ return actual === expected || (shared.has(actual) && shared.has(expected));
53
+ }
54
+ export function isManagedTarget(targetPath, expectedName, expectedProvider) {
55
+ if (!fs.existsSync(targetPath))
56
+ return false;
57
+ try {
58
+ const targetStat = fs.lstatSync(targetPath);
59
+ const marker = path.join(targetPath, AGENT_SKILL_MANAGED_MARKER);
60
+ const sidecar = readDeploymentSidecar(targetPath, expectedName);
61
+ return (targetStat.isDirectory()
62
+ && !targetStat.isSymbolicLink()
63
+ && fs.lstatSync(marker).isFile()
64
+ && !fs.lstatSync(marker).isSymbolicLink()
65
+ && fs.readFileSync(marker, 'utf8') === MARKER_CONTENT
66
+ && sidecar !== undefined
67
+ && (expectedProvider === undefined
68
+ || providersShareProjectionSurface(sidecar.provider, expectedProvider)));
69
+ }
70
+ catch {
71
+ return false;
72
+ }
73
+ }
74
+ //# sourceMappingURL=deployment-ownership.js.map
@@ -63,10 +63,10 @@ export function buildAgentSkillsDoctorSection(projectDir, options = {}) {
63
63
  diagnostics.push(diagnostic('AS_DOCTOR_PROVIDER_UNSUPPORTED', 'warning', inspection.path, '$', `provider "${provider.id}" cannot project active imported skill "${skill.name}": ${inspection.reasons.join('; ')}`, `Use a supported provider surface or retain "${skill.name}" in the managed import store.`));
64
64
  }
65
65
  else if (!inspection.exists) {
66
- diagnostics.push(diagnostic('AS_DOCTOR_PROVIDER_DEGRADED', 'warning', inspection.path, '$', `active imported skill "${skill.name}" is not projected to provider "${provider.id}"`, `Deploy or repair the ${provider.id} Agent Skills projection.`));
66
+ diagnostics.push(diagnostic('AS_DOCTOR_PROVIDER_DEGRADED', 'warning', inspection.path, '$', `active imported skill "${skill.name}" is not projected to provider "${provider.id}": ${inspection.reasons.join('; ')}`, `Deploy or repair the ${provider.id} Agent Skills projection.`));
67
67
  }
68
68
  else if (!inspection.managed || !inspection.matches) {
69
- diagnostics.push(diagnostic('AS_DOCTOR_DEPLOYED_DRIFT', 'error', inspection.path, '$', `provider "${provider.id}" projection for "${skill.name}" differs from its expected strict managed projection`, `Redeploy "${skill.name}" to ${provider.id} from the managed import.`));
69
+ diagnostics.push(diagnostic('AS_DOCTOR_DEPLOYED_DRIFT', 'error', inspection.path, '$', `provider "${provider.id}" projection for "${skill.name}" differs from its expected strict managed projection: ${inspection.reasons.join('; ')}`, `Redeploy "${skill.name}" to ${provider.id} from the managed import.`));
70
70
  }
71
71
  }
72
72
  }
@@ -14,7 +14,7 @@ import { spawnSync } from 'node:child_process';
14
14
  import { createHash, randomUUID } from 'node:crypto';
15
15
  import { fileURLToPath } from 'node:url';
16
16
  import { projectAiwgPath } from '../config/project-artifacts.js';
17
- import { listProviderDefinitions, resolveProviderPathValue, } from '../providers/provider-definitions.js';
17
+ import { higherLocalSkillOwner } from './collision-discovery.js';
18
18
  import { AGENT_SKILLS_BASELINE, } from './agent-skills.js';
19
19
  import { validateAgentSkillContent } from './validator.js';
20
20
  export const DEFAULT_AGENT_SKILL_IMPORT_LIMITS = Object.freeze({
@@ -591,28 +591,6 @@ function resultFromRecord(record, skillRoot, status, dryRun) {
591
591
  totalBytes: record.totalBytes,
592
592
  };
593
593
  }
594
- function higherPrecedenceCollision(name, projectDir, managedStore) {
595
- const candidates = new Map();
596
- for (const definition of listProviderDefinitions()) {
597
- const namespace = definition.skillNamespace;
598
- const basePath = namespace.pathType === 'home-dir'
599
- ? `~/${namespace.skillsBaseDir}`
600
- : namespace.skillsBaseDir;
601
- const resolved = resolveProviderPathValue(basePath, projectDir);
602
- candidates.set(path.join(resolved, name), namespace.pathType === 'home-dir' ? 'user' : 'project');
603
- }
604
- candidates.set(path.join(projectDir, '.agents', 'skills', name), 'project');
605
- candidates.set(path.join(projectDir, '.claude', '.aiwg', 'skills', name), 'project');
606
- const match = [...candidates.entries()]
607
- .sort(([left], [right]) => left.localeCompare(right))
608
- .find(([candidate]) => {
609
- if (pathContains(managedStore, candidate))
610
- return false;
611
- return (fs.existsSync(path.join(candidate, 'SKILL.md'))
612
- && !fs.existsSync(path.join(candidate, '.aiwg-managed')));
613
- });
614
- return match ? { path: match[0], origin: match[1] } : undefined;
615
- }
616
594
  function writeTree(root, entries) {
617
595
  fs.mkdirSync(root, { recursive: true, mode: 0o700 });
618
596
  const directories = entries
@@ -791,10 +769,10 @@ export async function importAgentSkill(source, options) {
791
769
  const digest = computeTreeDigest(materialized.entries);
792
770
  const importedStore = projectAiwgPath(projectDir, 'skills', 'imported');
793
771
  const finalRoot = path.join(importedStore, parsed.name);
794
- const collision = higherPrecedenceCollision(parsed.name, projectDir, importedStore);
772
+ const collision = higherLocalSkillOwner(parsed.name, 'imported', { projectDir });
795
773
  if (collision) {
796
- throw new AgentSkillImportError('AS_IMPORT_COLLISION', `${collision.origin}-owned skill "${parsed.name}" already exists at ${collision.path}`, [
797
- diagnostic('AS_IMPORT_COLLISION', collision.path, '$.name', `${collision.origin}-owned skill "${parsed.name}" has higher precedence`, 'Rename the imported skill or remove the higher-precedence collision explicitly.'),
774
+ throw new AgentSkillImportError('AS_IMPORT_COLLISION', `${collision.origin}-owned skill "${parsed.name}" takes precedence over imported-owned skill at ${collision.path}`, [
775
+ diagnostic('AS_IMPORT_COLLISION', collision.path ?? '.', '$.name', `${collision.origin}-owned skill "${parsed.name}" has higher precedence than imported-owned skill`, 'Rename the imported skill or remove the higher-precedence collision explicitly.'),
798
776
  ]);
799
777
  }
800
778
  const releaseLock = options.dryRun
@@ -10,6 +10,7 @@ import { AgentSkillsAdapter } from './adapters/agent-skills.js';
10
10
  import { LocalAdapter } from './adapters/local.js';
11
11
  import { ClawHubAdapter } from './adapters/clawhub.js';
12
12
  import { OpenClawAdapter } from './adapters/openclaw.js';
13
+ import { selectSkillOwners } from './collision-discovery.js';
13
14
  /**
14
15
  * All known registry adapters
15
16
  */
@@ -60,10 +61,16 @@ export async function searchSkills(query, providerId) {
60
61
  const available = await adapter.isAvailable();
61
62
  if (!available)
62
63
  continue;
63
- const adapterResults = await adapter.search(query);
64
- results.push(...adapterResults);
64
+ const adapterResults = adapter.id === 'local' || adapter.id === 'agentskills'
65
+ ? await adapter.list() : await adapter.search(query);
66
+ results.push(...adapterResults.map(skill => adapter.id === 'agentskills'
67
+ ? { ...skill, origin: 'imported' } : skill));
65
68
  }
66
- return results;
69
+ const normalized = query.toLowerCase();
70
+ return selectSkillOwners(results).filter(skill => !skill.origin
71
+ || skill.name.toLowerCase().includes(normalized)
72
+ || skill.description.toLowerCase().includes(normalized)
73
+ || skill.package?.toLowerCase().includes(normalized));
67
74
  }
68
75
  /**
69
76
  * List all skills across adapters (or a specific one)
@@ -78,9 +85,10 @@ export async function listSkills(providerId) {
78
85
  if (!available)
79
86
  continue;
80
87
  const adapterResults = await adapter.list();
81
- results.push(...adapterResults);
88
+ results.push(...adapterResults.map(skill => adapter.id === 'agentskills'
89
+ ? { ...skill, origin: 'imported' } : skill));
82
90
  }
83
- return results;
91
+ return selectSkillOwners(results);
84
92
  }
85
93
  /**
86
94
  * Get detailed skill info (checks adapters in order)
@@ -89,15 +97,22 @@ export async function getSkillInfo(name, providerId) {
89
97
  const adapters = providerId
90
98
  ? ALL_ADAPTERS.filter((a) => a.id === providerId)
91
99
  : ALL_ADAPTERS;
100
+ const results = [];
92
101
  for (const adapter of adapters) {
102
+ if (results.length && adapter.id !== 'local' && adapter.id !== 'agentskills')
103
+ break;
93
104
  const available = await adapter.isAvailable();
94
105
  if (!available)
95
106
  continue;
96
107
  const info = await adapter.info(name);
97
- if (info)
108
+ if (info && adapter.id === 'agentskills')
109
+ info.origin = 'imported';
110
+ if (info && !info.origin)
98
111
  return info;
112
+ if (info)
113
+ results.push(info);
99
114
  }
100
- return undefined;
115
+ return selectSkillOwners(results)[0];
101
116
  }
102
117
  /**
103
118
  * Install a skill from a specific registry with cross-platform deployment
@@ -0,0 +1,34 @@
1
+ import { buildProviderBootstrapBlock } from './workspace-context.js';
2
+ const AIWG_SIGNATURE_COMMENT = '<!-- aiwg-managed -->';
3
+ /**
4
+ * Build the full AGENTS.md content (in-memory; does not write).
5
+ *
6
+ * Per operator direction (#1239): AGENTS.md is a thin pointer to AIWG.md at
7
+ * project root. AIWG.md mirrors CLAUDE.md (ADR-1 §0.5) and contains the full
8
+ * framework guidance — including the kernel-skill discovery pattern
9
+ * (`aiwg discover` / `aiwg show`). Inlining a full link-index here pushed the
10
+ * file past Codex's 32KB cap on real deploys, triggered auto-split, and ran
11
+ * every artifact description through the sanitizer (rejecting any with
12
+ * backticks). The thin-pointer body sidesteps all of that: zero warnings on
13
+ * any provider, regardless of how many artifacts are deployed.
14
+ *
15
+ * `opts.sections` is accepted for backwards compatibility with callers that
16
+ * still aggregate a link-index (no internal use). `splitOccurred` is always
17
+ * false; `spilloverContent` is always empty. The `partitionForOverflow` /
18
+ * spillover utilities remain exported for any external consumer.
19
+ */
20
+ export async function buildAgentsMd(opts) {
21
+ const warnings = [];
22
+ const parts = [];
23
+ parts.push('# AGENTS.md');
24
+ parts.push(`${AIWG_SIGNATURE_COMMENT}`);
25
+ parts.push('<!-- Generated by AIWG. Edit AGENTS.override.md for operator additions. -->');
26
+ parts.push('');
27
+ parts.push(buildProviderBootstrapBlock(opts.provider));
28
+ parts.push('');
29
+ if (opts.projectContext && opts.projectContext.trim().length > 0) {
30
+ warnings.push('projectContext is no longer inlined in provider startup files; place it in the protected WORKSPACE.md operator section.');
31
+ }
32
+ return { content: parts.join('\n'), warnings, spilloverContent: '', splitOccurred: false };
33
+ }
34
+ //# sourceMappingURL=agents-md.js.map
@@ -62,6 +62,9 @@ export async function buildAiwgMdContent(projectPath, stagedClaudeMdContent) {
62
62
  // that managed block here too so legacy duplicate policy never reaches
63
63
  // AIWG.md, even on the first refresh. Operator content stays untouched.
64
64
  claudeMdContent = dedupeProviderBootstrap(claudeMdContent);
65
+ // Each provider startup owns core and hooks; mirroring them would load a
66
+ // second copy through the shared framework companion.
67
+ claudeMdContent = claudeMdContent.replace(/<!-- AIWG:(rule-core|rule-startup|rule-hook-[\w-]+):start -->[\s\S]*?<!-- AIWG:\1:end -->\r?\n?/g, '');
65
68
  const start = claudeMdContent.indexOf(CLAUDE_HOOK_START);
66
69
  const end = claudeMdContent.indexOf(CLAUDE_HOOK_END, start);
67
70
  if (start >= 0 && end >= start) {
@@ -0,0 +1,50 @@
1
+ // Migrate startup ownership without nesting markers or discarding operator text.
2
+ export const AGENTS_HEADER = '# AGENTS.md\n<!-- aiwg-managed -->\n<!-- Generated by AIWG. Edit AGENTS.override.md for operator additions. -->\n';
3
+ const bootstrapBlock = /<!-- AIWG:provider-bootstrap:start -->[\s\S]*?<!-- AIWG:provider-bootstrap:end -->/g;
4
+ export const hasRuleStartup = (content) => /<!-- AIWG:rule-hook-[\w-]+:start -->/.test(content);
5
+ export function retireLegacyBridge(content) {
6
+ return content.replace(/\n\n---\n\n<!-- BEGIN AIWG-managed \(auto-generated;[^\n]*-->[\s\S]*?<!-- END AIWG-managed -->\n?/g, '\n')
7
+ .replace(/<!-- BEGIN AIWG-managed \(auto-generated;[^\n]*-->[\s\S]*?<!-- END AIWG-managed -->\n?/g, '');
8
+ }
9
+ export function normalizeRuleStartup(content, bootstrap, agentsHeader = false, retireLegacy = true) {
10
+ if (retireLegacy)
11
+ content = retireLegacyBridge(content);
12
+ // Retire context-hook's generated body; retain agents-md's enclosed content.
13
+ content = content.replace(/<!-- AIWG:context-hook:start -->[\s\S]*?<!-- AIWG:context-hook:end -->\r?\n?/g, '')
14
+ .replace(/<!-- AIWG:agents-md:(?:start|end) -->\r?\n?/g, '')
15
+ .replace(/\n## For Hermes Sessions\n\nHermes does not auto-load AIWG\.md\. Browse AIWG capabilities with:\n\n- `artifact-read AIWG\.md` through AIWG MCP\.\n- `aiwg discover "<intent>"` and `aiwg show <type> <name>`\.\n- `delegate_task` through the AIWG-orchestrate skill\.\n/, '');
16
+ if (retireLegacy)
17
+ content = content.replace(/## Framework Context\r?\n[\s\S]*?\*See `AGENTS.override.md` for operator-authored additions\.\*\r?\n?/g, '');
18
+ if (content.includes('<!-- AIWG:rule-core:start -->')) {
19
+ content = content.replace(/<!-- AIWG:core-rules:(?:start|end) -->\r?\n?/g, '');
20
+ }
21
+ let installed = false;
22
+ content = content.replace(bootstrapBlock, () => {
23
+ if (installed)
24
+ return '';
25
+ installed = true;
26
+ return bootstrap;
27
+ });
28
+ if (!installed)
29
+ content = `${content}${content.endsWith('\n') ? '\n' : '\n\n'}${bootstrap}\n`;
30
+ if (agentsHeader && !content.startsWith(AGENTS_HEADER)) {
31
+ content = content.replace(/^# AGENTS\.md\r?\n/gm, '')
32
+ .replace(/^<!-- (?:aiwg-managed|Generated by AIWG\.[^\n]*) -->\r?\n?/gm, '');
33
+ // Round 3 left the old generated Framework Context separator at the top.
34
+ content = content.replace(/^(?:[ \t]*\r?\n)*---[ \t]*\r?\n/, '').replace(/^\s+/, '');
35
+ content = `${AGENTS_HEADER}\n${content}`;
36
+ }
37
+ return content;
38
+ }
39
+ export function preserveBridgeOperatorText(existing, generated) {
40
+ if (!generated.startsWith(AGENTS_HEADER) || !existing)
41
+ return generated;
42
+ const fallback = generated.match(bootstrapBlock)?.[0];
43
+ if (!fallback)
44
+ return generated;
45
+ // Rule deployment owns the bootstrap when its hooks are present. Standalone
46
+ // regeneration supplies it only for files without an installed rule startup.
47
+ const bootstrap = hasRuleStartup(existing) ? existing.match(bootstrapBlock)?.[0] || fallback : fallback;
48
+ return normalizeRuleStartup(existing, bootstrap, true);
49
+ }
50
+ //# sourceMappingURL=bridge-ownership.js.map
@@ -1,17 +1,9 @@
1
- /**
2
- * Canonical WORKSPACE.md context graph and provider adapter generator.
3
- *
4
- * WORKSPACE.md owns provider-neutral project/operator context; AIWG.md owns
5
- * generated discovery detail; provider startup files are minimal adapters.
6
- *
7
- * This file contains the public generator API. Callers are expected to have already
8
- * deployed artifacts and to pass pre-aggregated `AgentsMdSection[]` describing what
9
- * was deployed. The generator does not walk the filesystem to discover artifacts;
10
- * that's the caller's responsibility (per ADR-1 §7 generator-runs-after-deploy
11
- * invariant — the caller knows what landed).
12
- */
1
+ // Generate canonical workspace context and provider adapters after artifact deployment.
2
+ import { ensureCoreStartup } from '../../rules/core-startup.mjs';
3
+ import { preserveBridgeOperatorText } from './bridge-ownership.js';
13
4
  import { promises as fs } from 'node:fs';
14
5
  import * as path from 'node:path';
6
+ import { readdirSync, readFileSync } from 'node:fs';
15
7
  import { sanitizeDescription, sanitizeTags } from './sanitizer.js';
16
8
  import { checkPathAllowed } from './allowlist.js';
17
9
  import { generateAiwgMd } from './aiwg-md.js';
@@ -21,8 +13,19 @@ import { shouldEmitAgentsMd, shouldEmitAiwgMd, shouldEmitClaudeMdHook } from './
21
13
  import { ensureClaudeMdHook } from './claude-hook.js';
22
14
  import { ensureManagedHook } from './managed-hook.js';
23
15
  import { assertSafeContextFile, writeContextFileSync } from './context-file-safety.js';
24
- import { buildProviderBootstrapBlock, ensureWorkspaceContext, registerProviderContext, } from './workspace-context.js';
25
- import { projectControlPath } from '../../config/project-artifacts.js';
16
+ import { ensureWorkspaceContext, registerProviderContext, } from './workspace-context.js';
17
+ import { buildAgentsMd } from './agents-md.js';
18
+ /** True when deployed native Claude rules already carry the compact core set. */
19
+ function hasNativeClaudeCore(projectDir) {
20
+ try {
21
+ return readdirSync(path.join(projectDir, '.claude', 'rules'))
22
+ .some(name => /^core-.+\.md$/.test(name) && /aiwg:managed/.test(readFileSync(path.join(projectDir, '.claude', 'rules', name), 'utf8')));
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ }
28
+ export { buildAgentsMd } from './agents-md.js';
26
29
  const SECTION_TITLES = {
27
30
  agents: 'Agents',
28
31
  rules: 'Rules',
@@ -108,54 +111,6 @@ export function renderSection(section) {
108
111
  warnings,
109
112
  };
110
113
  }
111
- /**
112
- * Build the full AGENTS.md content (in-memory; does not write).
113
- *
114
- * Per operator direction (#1239): AGENTS.md is a thin pointer to AIWG.md at
115
- * project root. AIWG.md mirrors CLAUDE.md (ADR-1 §0.5) and contains the full
116
- * framework guidance — including the kernel-skill discovery pattern
117
- * (`aiwg discover` / `aiwg show`). Inlining a full link-index here pushed the
118
- * file past Codex's 32KB cap on real deploys, triggered auto-split, and ran
119
- * every artifact description through the sanitizer (rejecting any with
120
- * backticks). The thin-pointer body sidesteps all of that: zero warnings on
121
- * any provider, regardless of how many artifacts are deployed.
122
- *
123
- * `opts.sections` is accepted for backwards compatibility with callers that
124
- * still aggregate a link-index (no internal use). `splitOccurred` is always
125
- * false; `spilloverContent` is always empty. The `partitionForOverflow` /
126
- * spillover utilities remain exported for any external consumer.
127
- */
128
- export async function buildAgentsMd(opts) {
129
- const warnings = [];
130
- const parts = [];
131
- parts.push('# AGENTS.md');
132
- parts.push(`${AIWG_SIGNATURE_COMMENT}`);
133
- parts.push('<!-- Generated by AIWG. Edit AGENTS.override.md for operator additions. -->');
134
- parts.push('');
135
- parts.push(buildProviderBootstrapBlock(opts.provider));
136
- parts.push('');
137
- parts.push('## Framework Context');
138
- parts.push('');
139
- parts.push('See [AIWG.md](./AIWG.md) for the full AIWG framework context');
140
- parts.push('(active frameworks, addons, agents, behaviors, rules).');
141
- const configRelative = path.relative(opts.projectPath, projectControlPath(opts.projectPath, 'aiwg.config')).replace(/\\/g, '/');
142
- const configLink = configRelative.startsWith('.') ? configRelative : `./${configRelative}`;
143
- parts.push(`Tracker and delivery source of truth: [${configRelative}](${configLink}).`);
144
- parts.push('');
145
- parts.push('Deployed artifacts live under your provider\'s native directory');
146
- parts.push('(for example `.codex/agents/`, `.warp/agents/`, `.github/agents/`).');
147
- parts.push('Use `aiwg discover "<intent>"` and `aiwg show <type> <name>` to browse');
148
- parts.push('skills, agents, rules, and commands across the installation.');
149
- parts.push('');
150
- if (opts.projectContext && opts.projectContext.trim().length > 0) {
151
- warnings.push('projectContext is no longer inlined in provider startup files; place it in the protected WORKSPACE.md operator section.');
152
- }
153
- parts.push('---');
154
- parts.push('');
155
- parts.push('*See `AGENTS.override.md` for operator-authored additions.*');
156
- parts.push('');
157
- return { content: parts.join('\n'), warnings, spilloverContent: '', splitOccurred: false };
158
- }
159
114
  /**
160
115
  * Detect whether a pre-existing file at `filePath` carries the AIWG signature.
161
116
  *
@@ -172,6 +127,14 @@ export async function isOverwriteSafe(filePath) {
172
127
  return true;
173
128
  if (/Generated by\s+(AIWG|aiwg)/i.test(head))
174
129
  return true;
130
+ // Provider templates use a different ownership marker. Adopt only wholly
131
+ // generated files; text outside managed blocks still belongs to the operator.
132
+ if (content.includes('<!-- BEGIN AIWG-managed (auto-generated;')) {
133
+ const remainder = content
134
+ .replace(/<!-- BEGIN AIWG-managed \(auto-generated;[^\n]*-->[\s\S]*?<!-- END AIWG-managed -->/g, '')
135
+ .replace(/<!-- AIWG:([\w-]+):start -->[\s\S]*?<!-- AIWG:\1:end -->/g, '');
136
+ return remainder.trim().length === 0;
137
+ }
175
138
  // Backwards-compatibility scan: pre-ADR-1 emitters wrote AGENTS.md /
176
139
  // WARP.md / .hermes.md without the canonical signature. Those files
177
140
  // typically include AIWG-specific markers somewhere in the first ~50
@@ -202,13 +165,21 @@ async function atomicWrite(filePath, content, provider) {
202
165
  // Rule delivery owns this block. Context regeneration runs after deployment
203
166
  // and must retain the selected kernel even when rebuilding the adapter.
204
167
  const existing = await fs.readFile(filePath, 'utf8').catch(() => '');
205
- for (const owner of ['rule-startup', 'hermes-context', 'hermes-routing', 'warp-context']) {
168
+ content = preserveBridgeOperatorText(existing, content);
169
+ for (const owner of ['rule-startup', 'rule-core', ...[...existing.matchAll(/<!-- AIWG:(rule-hook-[\w-]+):start -->/g)].map(match => match[1]), 'hermes-context', 'hermes-routing', 'warp-context']) {
206
170
  if (content.includes(`<!-- AIWG:${owner}:start -->`))
207
171
  continue;
208
172
  const managed = existing.match(new RegExp(`<!-- AIWG:${owner}:start -->[\\s\\S]*?<!-- AIWG:${owner}:end -->`));
209
173
  if (managed)
210
174
  content = `${content.trimEnd()}\n\n${managed[0]}\n`;
211
175
  }
176
+ // Claude loads core natively from .claude/rules/core-*.md once deployed; inject into CLAUDE.md
177
+ // only when those native files are absent (for example a regenerate before any `aiwg use`).
178
+ const nativeCore = provider === 'claude' && hasNativeClaudeCore(path.dirname(filePath));
179
+ if (provider && !nativeCore)
180
+ content = ensureCoreStartup(content);
181
+ else if (nativeCore)
182
+ content = content.replace(/\n*<!-- AIWG:rule-core:start -->[\s\S]*?<!-- AIWG:rule-core:end -->\n?/, '\n');
212
183
  const bytes = Buffer.byteLength(content, 'utf8');
213
184
  if (provider === 'codex' && path.basename(filePath) === 'AGENTS.md' && bytes >= 32768) {
214
185
  throw new Error('Codex AGENTS.md exceeds its 32 KB hard cap');
@@ -224,54 +195,16 @@ async function atomicWrite(filePath, content, provider) {
224
195
  *
225
196
  * Hermes scans `.hermes.md` first (priority 1) and falls back to AGENTS.md.
226
197
  * Warp prefers AGENTS.md but tooling expects `WARP.md` to exist. Both are
227
- * written with the same content as AGENTS.md, except Hermes — see
228
- * `applyTwinSuffix` below for the Hermes-specific MCP guidance suffix
229
- * (#1242).
198
+ * written with the same minimal bootstrap content as AGENTS.md.
230
199
  */
231
200
  const TWIN_FILES_BY_PROVIDER = {
232
201
  copilot: ['.github/copilot-instructions.md'],
233
202
  hermes: ['.hermes.md'],
234
203
  warp: ['WARP.md'],
235
204
  };
236
- /**
237
- * Hermes-specific suffix appended to `.hermes.md` (#1242).
238
- *
239
- * The cross-platform AGENTS.md thin pointer (#1239) says *"See [AIWG.md] for
240
- * the full AIWG framework context."* From inside a Hermes turn that link is
241
- * a dead end — Hermes auto-loads AGENTS.md and CLAUDE.md but not AIWG.md.
242
- * The twin file gets a Hermes-correct alternative path so a model running
243
- * inside Hermes knows to call `artifact-read` over MCP rather than chase the
244
- * AIWG.md link.
245
- *
246
- * Suffix is ~390 chars (~95 tokens) — keeps the .hermes.md twin total under
247
- * Hermes's <1,000-char turn-budget target on top of the 579-byte primary.
248
- */
249
- const HERMES_TWIN_SUFFIX = [
250
- '',
251
- '## For Hermes Sessions',
252
- '',
253
- 'Hermes does not auto-load AIWG.md. Browse AIWG capabilities with:',
254
- '',
255
- '- `artifact-read AIWG.md` through AIWG MCP.',
256
- '- `aiwg discover "<intent>"` and `aiwg show <type> <name>`.',
257
- '- `delegate_task` through the AIWG-orchestrate skill.',
258
- '',
259
- ].join('\n');
260
- /**
261
- * Apply provider-specific transformations to twin-file content.
262
- *
263
- * Currently used only for Hermes (#1242). Extend by adding more
264
- * provider-keyed branches as new twin formats need divergence.
265
- */
266
- function applyTwinSuffix(provider, baseContent) {
267
- if (provider === 'hermes') {
268
- return `${baseContent}${HERMES_TWIN_SUFFIX}`;
269
- }
270
- return baseContent;
271
- }
272
205
  /**
273
206
  * Write per-provider twin files (.hermes.md, WARP.md). Twin content is the
274
- * AGENTS.md body plus any provider-specific suffix from `applyTwinSuffix`.
207
+ * same minimal AGENTS.md bootstrap body.
275
208
  * Operator-claimed twin files are not overwritten unless --force is set,
276
209
  * matching the AGENTS.md guard.
277
210
  */
@@ -279,7 +212,7 @@ async function writeTwinFiles(provider, projectPath, agentsMdContent, opts, resu
279
212
  const twinNames = TWIN_FILES_BY_PROVIDER[provider];
280
213
  if (!twinNames || twinNames.length === 0)
281
214
  return;
282
- const twinContent = applyTwinSuffix(provider, agentsMdContent);
215
+ const twinContent = agentsMdContent;
283
216
  for (const twinName of twinNames) {
284
217
  const twinPath = path.join(projectPath, twinName);
285
218
  if (opts.detectExistingFiles && !opts.force) {
@@ -291,6 +224,7 @@ async function writeTwinFiles(provider, projectPath, agentsMdContent, opts, resu
291
224
  result.warnings.push(hook.action === 'unchanged'
292
225
  ? `${twinName} is operator-owned and already loads WORKSPACE.md then AIWG.md — left as-is.`
293
226
  : `${twinName} is operator-owned; ${hook.action} the WORKSPACE.md → AIWG.md hook additively (existing content preserved). Pass --force to replace the whole file.`);
227
+ await atomicWrite(twinPath, await fs.readFile(twinPath, 'utf8'), provider);
294
228
  result.twinPaths.push(twinPath);
295
229
  continue;
296
230
  }
@@ -426,6 +360,7 @@ export async function generate(opts) {
426
360
  // canonical graph hook (preserve operator content; no --force needed) so Codex/
427
361
  // fallback consumers load the generated AIWG.md.
428
362
  const hook = await ensureManagedHook(agentsMdPath, { provider: opts.provider });
363
+ result.agentsMdBytes = await atomicWrite(agentsMdPath, await fs.readFile(agentsMdPath, 'utf8'), opts.provider);
429
364
  result.agentsMdPath = agentsMdPath;
430
365
  result.warnings.push(hook.action === 'unchanged'
431
366
  ? `AGENTS.md is operator-owned and already loads WORKSPACE.md then AIWG.md — left as-is.`
@@ -476,6 +411,7 @@ export async function generate(opts) {
476
411
  force: opts.force,
477
412
  detectExistingFiles: opts.detectExistingFiles,
478
413
  });
414
+ await atomicWrite(hookResult.claudeMdPath, await fs.readFile(hookResult.claudeMdPath, 'utf8'), opts.provider);
479
415
  result.claudeMdHookPath = hookResult.claudeMdPath;
480
416
  result.claudeMdHookAction = hookResult.action;
481
417
  if (hookResult.backupPath) {
@@ -16,6 +16,7 @@ import * as path from 'path';
16
16
  import { buildProviderBootstrapBlock } from './workspace-context.js';
17
17
  import { dominantLineEnding, withLineEnding } from './line-endings.js';
18
18
  import { assertSafeContextFile, writeContextFileSync } from './context-file-safety.js';
19
+ import { hasRuleStartup, normalizeRuleStartup } from './bridge-ownership.js';
19
20
  export const CONTEXT_HOOK_START = '<!-- AIWG:context-hook:start -->';
20
21
  export const CONTEXT_HOOK_END = '<!-- AIWG:context-hook:end -->';
21
22
  /** The managed block — loads canonical workspace context before framework context. */
@@ -61,6 +62,15 @@ export async function ensureManagedHook(filePath, opts = {}) {
61
62
  }
62
63
  const lineEnding = dominantLineEnding(existing);
63
64
  block = withLineEnding(block, lineEnding);
65
+ if (hasRuleStartup(existing)) {
66
+ const bootstrap = existing.match(/<!-- AIWG:provider-bootstrap:start -->[\s\S]*?<!-- AIWG:provider-bootstrap:end -->/)?.[0]
67
+ || buildProviderBootstrapBlock(opts.provider || 'codex');
68
+ const normalized = normalizeRuleStartup(existing, bootstrap, false, false);
69
+ result.action = normalized === existing ? 'unchanged' : 'updated';
70
+ if (normalized !== existing)
71
+ writeContextFileSync(filePath, normalized, 'utf8');
72
+ return result;
73
+ }
64
74
  // Already has both bare includes (operator wired them by hand) — nothing to do.
65
75
  if (!existing.includes(CONTEXT_HOOK_START) && /^[ \t]*@WORKSPACE\.md[ \t]*$/m.test(existing) && /^[ \t]*@AIWG\.md[ \t]*$/m.test(existing)) {
66
76
  result.action = 'unchanged';
@@ -21,6 +21,7 @@ import { findPackageRoot } from '../../cli/find-package-root.js';
21
21
  import { readAiwgConfigCandidate, validateWorkerConfigCandidate, resolveParallelism, PROVIDER_PARALLELISM_DEFAULTS } from '../../config/aiwg-config.js';
22
22
  import { ConfigLoader } from '../../models/config-loader.js';
23
23
  import { validateWorkerCatalogDiscovery } from '../../models/provider-policy.js';
24
+ import { wrapperEnforcementReport } from '../../models/wrapper-enforcement.js';
24
25
  export const PARALLELISM_BLOCK_START = '<!-- AIWG-PARALLELISM-CAP:START -->';
25
26
  export const PARALLELISM_BLOCK_END = '<!-- AIWG-PARALLELISM-CAP:END -->';
26
27
  /** Plain-path pointer (not an `@` import) to the long health/supervision explanation. */
@@ -214,8 +215,9 @@ function delegationSupport(provider) {
214
215
  case 'cursor':
215
216
  case 'factory':
216
217
  case 'opencode':
217
- case 'openclaw':
218
218
  return `**Provider behavior (${provider})**: native custom subagents can select the deployed model-worker wrapper. Verify the resolved model when provider or account policy may substitute it.`;
219
+ case 'openclaw':
220
+ return '**Provider behavior (openclaw)**: wrapper Markdown is a reference mirror; native model controls require separate subagent configuration.';
219
221
  case 'openhuman':
220
222
  return '**Provider behavior (openhuman)**: wrapper roles compile to OpenHuman agent definitions; exact pins validate while semantic hints may be routed dynamically.';
221
223
  case 'warp':
@@ -224,7 +226,7 @@ function delegationSupport(provider) {
224
226
  case 'windsurf':
225
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
228
  default:
227
- return '**Provider behavior (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.';
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.`;
228
230
  }
229
231
  }
230
232
  /**
@@ -297,7 +299,9 @@ export async function buildParallelismSection(projectPath, deps = {}) {
297
299
  lines.push('Delegation policy and model-worker selection: `aiwg show rule subagent-scoping`.');
298
300
  lines.push('After changing project parallelism with `aiwg config set/reset --project`, follow the emitted provider-specific regeneration commands and run `aiwg workspace-context doctor`.');
299
301
  lines.push('');
300
- lines.push(delegationSupport(primary));
302
+ for (const provider of cfg.providers.length ? cfg.providers : ['unknown']) {
303
+ lines.push(`${delegationSupport(provider)} ${wrapperEnforcementReport(provider)}`);
304
+ }
301
305
  lines.push('');
302
306
  lines.push(workerDispatchStateLine(cfg.parallelism, cfg.setup));
303
307
  lines.push('');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiwg/cli",
3
- "version": "2026.10.12",
3
+ "version": "2026.10.15",
4
4
  "description": "Lightweight AIWG CLI for signed, versioned web-backed resources.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,6 +27,8 @@
27
27
  "THIRD_PARTY_NOTICES.md",
28
28
  "bin/",
29
29
  "agentic/code/providers/",
30
+ "agentic/code/addons/aiwg-utils/rules/anti-laziness.md",
31
+ "agentic/code/addons/aiwg-utils/rules/anti-laziness.core.md",
30
32
  "agentic/code/addons/composition-engine/lib/runtime.mjs",
31
33
  "agentic/code/addons/composition-engine/lib/validator.mjs",
32
34
  "agentic/code/addons/composition-engine/schemas/flow-graph.schema.json",
@@ -44,6 +46,7 @@
44
46
  "dist/src/resources/web-release.d.ts",
45
47
  "dist/src/dataset/**/*.d.ts",
46
48
  "tools/_resolve-impl.mjs",
49
+ "tools/warp/warp-content.mjs",
47
50
  "tools/cli/decision-offload-report.mjs",
48
51
  "tools/cli/workspace-status.mjs",
49
52
  "tools/ralph-external/session-launcher.mjs",
@@ -90,6 +93,7 @@
90
93
  "tools/plugin/package-plugins.mjs",
91
94
  "tools/plugin/plugin-links.mjs",
92
95
  "tools/skills/deploy-skills-codex.mjs",
96
+ "tools/skills/codex-skill-transform.mjs",
93
97
  "README.md"
94
98
  ],
95
99
  "repository": {
@@ -135,7 +139,7 @@
135
139
  "zod": "^4.6.6"
136
140
  },
137
141
  "optionalDependencies": {
138
- "@hono/node-server": "2.0.11",
142
+ "@hono/node-server": "2.1.5",
139
143
  "@sigstore/bundle": "4.0.0",
140
144
  "@sigstore/protobuf-specs": "0.5.0",
141
145
  "@sigstore/verify": "3.1.1",