@aiwg/cli 2026.11.2 → 2026.11.4

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 (150) hide show
  1. package/agentic/code/addons/aiwg-hooks/canonical/aiwg-prompt-discovery.yaml +3 -2
  2. package/agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs +12 -9
  3. package/agentic/code/addons/aiwg-utils/rules/anti-laziness.md +2 -0
  4. package/agentic/code/addons/composition-engine/lib/runtime.mjs +5 -26
  5. package/agentic/code/addons/composition-engine/schemas/flow-graph.schema.json +22 -0
  6. package/agentic/code/providers/capability-matrix.yaml +17 -20
  7. package/agentic/code/providers/model-capabilities.v1.json +17 -16
  8. package/dist/src/a2a/hitl-authorization.js +46 -0
  9. package/dist/src/a2a/hitl-driver.js +5 -5
  10. package/dist/src/artifacts/browser-export.js +2 -0
  11. package/dist/src/artifacts/framework-source-digest.js +1 -1
  12. package/dist/src/artifacts/index-builder.js +5 -25
  13. package/dist/src/artifacts/index-capability.js +24 -0
  14. package/dist/src/artifacts/query-engine-discover-output.js +8 -3
  15. package/dist/src/artifacts/query-engine-rules.js +27 -9
  16. package/dist/src/artifacts/query-engine-scoring.js +5 -5
  17. package/dist/src/artifacts/query-engine-show-card.js +5 -1
  18. package/dist/src/artifacts/query-engine-show-load.js +1 -1
  19. package/dist/src/artifacts/query-engine-show.js +3 -3
  20. package/dist/src/artifacts/query-engine-templates.js +10 -4
  21. package/dist/src/artifacts/query-engine-verbose.js +18 -4
  22. package/dist/src/artifacts/relations-builder.js +1 -0
  23. package/dist/src/artifacts/types.js +1 -1
  24. package/dist/src/cli/handlers/checkpoint-handoff.js +2 -1
  25. package/dist/src/cli/handlers/dataset.js +17 -0
  26. package/dist/src/cli/handlers/guided-setup.js +3 -1
  27. package/dist/src/cli/handlers/refresh-managed-deployment.js +17 -5
  28. package/dist/src/cli/handlers/rules.js +1 -1
  29. package/dist/src/cli/handlers/sessions.js +1 -1
  30. package/dist/src/cli/handlers/steward.js +1 -1
  31. package/dist/src/cli/handlers/use.js +18 -5
  32. package/dist/src/cli/handlers/utility-doctor.js +5 -2
  33. package/dist/src/cli/handlers/workspace.js +1 -1
  34. package/dist/src/cli/services/deployment-probe-scope.js +40 -0
  35. package/dist/src/cli/services/deployment-verification.js +5 -6
  36. package/dist/src/config/aiwg-config.js +6 -0
  37. package/dist/src/config/authorization-cli.js +61 -3
  38. package/dist/src/config/cli-help.js +1 -1
  39. package/dist/src/config/cli.js +4 -2
  40. package/dist/src/config/decision-config.js +2 -1
  41. package/dist/src/config/host-resource-runtime.mjs +1 -1
  42. package/dist/src/config/jev-credential-reference.js +56 -0
  43. package/dist/src/config/user-config.js +13 -19
  44. package/dist/src/config/user-registry.js +9 -1
  45. package/dist/src/config/worker-owner-lock.js +90 -10
  46. package/dist/src/decision/ask.js +3 -2
  47. package/dist/src/decision/graph-flow-adapter.js +1 -1
  48. package/dist/src/decision/jev-credentials.js +22 -0
  49. package/dist/src/decision/offload.js +1 -1
  50. package/dist/src/decision/openbao-kv-resolver.mjs +96 -0
  51. package/dist/src/decision/openbao-runtime.js +101 -0
  52. package/dist/src/effects/authorization-grant.js +50 -0
  53. package/dist/src/effects/authorization-store.js +130 -0
  54. package/dist/src/effects/index.js +2 -0
  55. package/dist/src/effects/ledger.js +1 -0
  56. package/dist/src/effects/lifecycle.js +1 -1
  57. package/dist/src/effects/reader.js +4 -0
  58. package/dist/src/effects/records.js +4 -0
  59. package/dist/src/effects/schema.js +2 -0
  60. package/dist/src/extensions/claude-hooks-installer.js +7 -7
  61. package/dist/src/extensions/muse-managed-hooks.js +11 -0
  62. package/dist/src/extensions/user-hook-diagnostics.js +32 -0
  63. package/dist/src/extensions/verified-hook-command.js +32 -0
  64. package/dist/src/lint/rule-conflicts.js +52 -0
  65. package/dist/src/lint/runner.js +3 -0
  66. package/dist/src/mcp/cli.mjs +3 -1
  67. package/dist/src/mcp/elicitation.mjs +30 -0
  68. package/dist/src/mcp/grok-build-config.mjs +1 -1
  69. package/dist/src/mcp/muse-native-config.mjs +1 -0
  70. package/dist/src/mcp/server.mjs +2 -0
  71. package/dist/src/mcp/tools/authorization.mjs +78 -0
  72. package/dist/src/models/model-capabilities.v1.json +17 -16
  73. package/dist/src/policy/authorization-capture.js +64 -0
  74. package/dist/src/policy/authorization-operations.js +108 -0
  75. package/dist/src/policy/hitl-check.js +3 -2
  76. package/dist/src/policy/hitl-consume.js +14 -0
  77. package/dist/src/policy/hitl-durable-store.js +60 -0
  78. package/dist/src/policy/hitl-durable.js +60 -0
  79. package/dist/src/policy/hitl-receipt.js +5 -0
  80. package/dist/src/policy/hitl.js +44 -6
  81. package/dist/src/process/bounded-child-process.mjs +49 -39
  82. package/dist/src/providers/capability-matrix.yaml +17 -20
  83. package/dist/src/providers/deployment-ownership.d.mts +1 -0
  84. package/dist/src/providers/deployment-ownership.mjs +21 -2
  85. package/dist/src/providers/grok-build-headless.js +170 -77
  86. package/dist/src/providers/grok-build-inspect.js +1 -0
  87. package/dist/src/providers/grok-build-paths.js +2 -0
  88. package/dist/src/providers/muse-paths.js +4 -2
  89. package/dist/src/providers/provider-context-contracts.js +12 -4
  90. package/dist/src/providers/provider-definition-schema.js +6 -0
  91. package/dist/src/providers/provider-seeds-1.js +3 -3
  92. package/dist/src/providers/provider-seeds-2.js +6 -4
  93. package/dist/src/providers/provider-seeds-3.js +6 -6
  94. package/dist/src/rules/activation.d.mts +2 -0
  95. package/dist/src/rules/activation.mjs +16 -7
  96. package/dist/src/rules/inline-budget.d.mts +2 -1
  97. package/dist/src/rules/inline-budget.mjs +4 -2
  98. package/dist/src/rules/inventory.js +3 -0
  99. package/dist/src/rules/precedence.d.mts +6 -0
  100. package/dist/src/rules/precedence.mjs +49 -0
  101. package/dist/src/rules/project-precedence.js +73 -0
  102. package/dist/src/rules/rule-frontmatter.schema.json +15 -0
  103. package/dist/src/serve/a2a-terminal-observer.js +12 -3
  104. package/dist/src/serve/mission-hitl.js +20 -1
  105. package/dist/src/sessions/adapters/grok-build-fallback.js +33 -0
  106. package/dist/src/sessions/adapters/grok-build-native-records.js +64 -0
  107. package/dist/src/sessions/adapters/grok-build-native.js +92 -100
  108. package/dist/src/sessions/adapters/grok-build.js +65 -24
  109. package/dist/src/sessions/grok-build-cli-output.js +113 -0
  110. package/dist/src/sessions/grok-build-cli.js +4 -28
  111. package/dist/src/smiths/context-pipeline/bridge-ownership.js +4 -3
  112. package/dist/src/smiths/context-pipeline/finalization.js +5 -0
  113. package/dist/src/smiths/context-pipeline/generator.js +1 -1
  114. package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +20 -17
  115. package/dist/src/smiths/context-pipeline/workspace-doctor.js +6 -1
  116. package/dist/src/smiths/context-pipeline/workspace-document.js +6 -0
  117. package/dist/src/smiths/context-pipeline/workspace-migration.js +2 -12
  118. package/dist/src/smiths/hook-bridge/codex-translator.js +11 -14
  119. package/dist/src/smiths/hook-bridge/codex-trust.js +7 -2
  120. package/dist/src/smiths/hook-bridge/copilot-translator.js +2 -1
  121. package/dist/src/smiths/hook-bridge/factory-trust.js +56 -0
  122. package/dist/src/smiths/hook-bridge/grok-build-translator.js +3 -1
  123. package/dist/src/smiths/hook-bridge/hermes-prompt-discovery.js +78 -0
  124. package/dist/src/smiths/hook-bridge/hermes-translator.js +5 -3
  125. package/dist/src/smiths/hook-bridge/index.js +3 -1
  126. package/dist/src/smiths/hook-bridge/prompt-discovery-gaps.js +3 -2
  127. package/package.json +7 -1
  128. package/tools/agents/deploy-agents.mjs +5 -6
  129. package/tools/agents/deploy-options.mjs +1 -0
  130. package/tools/agents/providers/base-frontmatter.mjs +3 -2
  131. package/tools/agents/providers/claude-post-deploy.mjs +1 -1
  132. package/tools/agents/providers/codex-post-deploy.mjs +1 -1
  133. package/tools/agents/providers/generic.mjs +66 -0
  134. package/tools/agents/providers/grok-build.mjs +3 -1
  135. package/tools/agents/providers/muse-hooks.mjs +13 -11
  136. package/tools/agents/providers/muse-prompt-discovery.mjs +5 -1
  137. package/tools/agents/providers/muse.mjs +2 -1
  138. package/tools/agents/providers/openclaw.mjs +2 -1
  139. package/tools/agents/providers/rule-deployment-prepare.mjs +5 -3
  140. package/tools/agents/providers/rule-deployment-state.mjs +14 -6
  141. package/tools/agents/providers/rule-startup.mjs +11 -10
  142. package/tools/agents/providers/staged-directory-reference.mjs +14 -0
  143. package/tools/agents/providers/user-hooks.mjs +26 -0
  144. package/tools/cli/authorization-health.mjs +20 -0
  145. package/tools/cli/decision-offload-report.mjs +2 -0
  146. package/tools/cli/workspace-status.mjs +7 -0
  147. package/tools/commands/deploy-prompts-codex.mjs +15 -1
  148. package/tools/plugin/package-plugins.mjs +6 -1
  149. package/tools/ralph-external/lib/claude-adapter.mjs +2 -2
  150. package/vscode-extension/schemas/aiwg.config.v1.json +20 -0
@@ -0,0 +1,66 @@
1
+ // Deploy portable Markdown artifacts through the shared rule and skill lifecycle.
2
+ import path from 'node:path';
3
+ import {
4
+ collectFrameworkArtifacts,
5
+ deployFiles,
6
+ deploySkillsWithKernelRouting,
7
+ ensureDir,
8
+ getAddonAgentFiles,
9
+ getAddonCommandFiles,
10
+ getAddonSkillDirs,
11
+ normalizeDeploymentMode,
12
+ withRuleDeployment,
13
+ } from './base.mjs';
14
+
15
+ export const name = 'generic';
16
+ export const aliases = [];
17
+ export const paths = { agents: 'agents', commands: 'commands', skills: 'skills', rules: 'rules' };
18
+ export const kernelSkillsPath = '.agents/skills';
19
+ // Portable files need an explicit host loader; no native harness features are claimed.
20
+ export const support = { agents: 'context', commands: 'context', skills: 'context', rules: 'context' };
21
+ export const capabilities = { skills: true, rules: true, aggregatedOutput: false, yamlFormat: false, homeDirectoryDeploy: false };
22
+ export const mapModel = model => model;
23
+ export const transformAgent = (_file, content) => content;
24
+ export const transformCommand = (_file, content) => content;
25
+ export const getFileExtension = () => '.md';
26
+
27
+ function deployMarkdown(files, target, directory, opts) {
28
+ const destination = path.join(target, directory);
29
+ ensureDir(destination, opts.dryRun);
30
+ return deployFiles(files, destination, opts).filter(action => action.type === 'deploy').length;
31
+ }
32
+ export const deployAgents = (files, target, opts) => deployMarkdown(files, target, paths.agents, opts);
33
+ export const deployCommands = (files, target, opts) => deployMarkdown(files, target, paths.commands, opts);
34
+ // Activation-selected rules and the bootstrap are projected by withRuleDeployment.
35
+ export const deployRules = () => 0;
36
+
37
+ export function deploySkills(dirs, target, opts) {
38
+ return deploySkillsWithKernelRouting(dirs, path.join(target, paths.skills),
39
+ path.join(target, kernelSkillsPath), opts);
40
+ }
41
+
42
+ export async function deploy(opts) {
43
+ return withRuleDeployment(opts, { name, paths, kernelSkillsPath }, deploySelected);
44
+ }
45
+
46
+ async function deploySelected(opts) {
47
+ const mode = normalizeDeploymentMode(opts.mode);
48
+ const commands = (opts.deployCommands || opts.commandsOnly) && !opts.skillsOnly && !opts.rulesOnly;
49
+ const skills = (opts.deploySkills || opts.skillsOnly) && !opts.commandsOnly && !opts.rulesOnly;
50
+ const agents = !opts.commandsOnly && !opts.skillsOnly && !opts.rulesOnly;
51
+ const selected = collectFrameworkArtifacts(opts.srcRoot, mode, {
52
+ includeAgents: agents, includeCommands: commands, includeSkills: skills, includeRules: false,
53
+ });
54
+ if (['general', 'sdlc', 'both', 'all'].includes(mode)) {
55
+ if (agents) selected.agents.push(...getAddonAgentFiles(opts.srcRoot));
56
+ if (commands) selected.commands.push(...getAddonCommandFiles(opts.srcRoot));
57
+ if (skills) selected.skills.push(...getAddonSkillDirs(opts.srcRoot));
58
+ }
59
+ if (agents) deployAgents(selected.agents, opts.target, opts);
60
+ if (commands) deployCommands(selected.commands, opts.target, opts);
61
+ if (skills) deploySkills([...new Set(selected.skills)], opts.target, opts);
62
+ if (!opts.quiet) console.log('Generic: configure your host to read AGENTS.md; automatic loading and prompt hooks are host dependent.');
63
+ }
64
+
65
+ export default { name, aliases, paths, kernelSkillsPath, support, capabilities, mapModel,
66
+ transformAgent, transformCommand, getFileExtension, deployAgents, deployCommands, deploySkills, deployRules, deploy };
@@ -16,6 +16,8 @@ import os from 'node:os';
16
16
  import fs from 'node:fs';
17
17
  import { createHash, randomUUID } from 'node:crypto';
18
18
  import yaml from 'js-yaml';
19
+ import { importImpl } from '../../_resolve-impl.mjs';
20
+ const { GROK_BUILD_STANDARD_SKILLS_PATH } = await importImpl(import.meta.url, 'providers/grok-build-paths.js');
19
21
  import {
20
22
  withRuleDeployment,
21
23
  replaceBoundRulesBlock,
@@ -42,7 +44,7 @@ export const paths = {
42
44
  };
43
45
  export const kernelSkillsPath = '.grok/skills';
44
46
  /** Standard-tier opt-in mirror (`--copy-all`) lives under the project .aiwg tree. */
45
- export const standardSkillsPath = '.grok/.aiwg/skills';
47
+ export const standardSkillsPath = GROK_BUILD_STANDARD_SKILLS_PATH;
46
48
 
47
49
  export const support = {
48
50
  agents: 'native',
@@ -54,7 +54,7 @@ import path from 'node:path';
54
54
  import { randomUUID } from 'node:crypto';
55
55
  import { importImpl } from '../../_resolve-impl.mjs';
56
56
  import { stripJsonComments } from './base.mjs';
57
- import { deployPromptDiscovery } from './muse-prompt-discovery.mjs';
57
+ import { museHooksForTarget, deployPromptDiscovery } from './muse-prompt-discovery.mjs';
58
58
  import { resolveMuseXdgSkillsDir, museXdgSkillsDirRemediation } from './muse-paths.mjs';
59
59
 
60
60
  const { AIWG_MANAGED_HOOKS } = await importImpl(import.meta.url, 'extensions/muse-managed-hooks.js');
@@ -185,9 +185,9 @@ export const MUSE_HOOK_EVENTS = [
185
185
  export { AIWG_MANAGED_HOOKS };
186
186
 
187
187
  /** Canonical group payloads keyed by hook id, for merge/prune identity. */
188
- function managedGroupsById() {
188
+ function managedGroupsById(desired = AIWG_MANAGED_HOOKS) {
189
189
  const out = new Map();
190
- for (const hook of AIWG_MANAGED_HOOKS) out.set(hook.id, { event: hook.event, group: hook.group });
190
+ for (const hook of desired) out.set(hook.id, { event: hook.event, group: hook.group });
191
191
  return out;
192
192
  }
193
193
 
@@ -306,13 +306,15 @@ function readHooksSidecar(sidecarPath) {
306
306
  * byte-identical to the canonical set) are preserved untouched. Managed
307
307
  * groups are replaced with the canonical payload, repairing drift.
308
308
  */
309
- export function mergeManagedHooks(existingDoc, sidecar) {
310
- const byId = managedGroupsById();
309
+ export function mergeManagedHooks(existingDoc, sidecar, desired = AIWG_MANAGED_HOOKS) {
310
+ const byId = managedGroupsById(desired);
311
+ const legacy = managedGroupsById();
311
312
  const recorded = new Map();
312
313
  for (const entry of sidecar.hooks || []) {
313
314
  if (entry && typeof entry.id === 'string') recorded.set(entry.id, entry);
314
315
  }
315
316
  const identities = managedIdentities(byId, recorded);
317
+ for (const [key, id] of managedIdentities(legacy, new Map())) identities.set(key, id);
316
318
 
317
319
  // A group is AIWG-managed when its identity matches the current set or a
318
320
  // sidecar-recorded payload. Returns the hook id or null.
@@ -323,7 +325,7 @@ export function mergeManagedHooks(existingDoc, sidecar) {
323
325
  const existingHooks = (existingDoc && existingDoc.hooks) || {};
324
326
 
325
327
  // Preserve original event order; managed events are refreshed in place.
326
- const desiredEvents = new Set([...AIWG_MANAGED_HOOKS.map((h) => h.event)]);
328
+ const desiredEvents = new Set([...desired.map((h) => h.event)]);
327
329
  const eventOrder = [...Object.keys(existingHooks)];
328
330
  for (const event of desiredEvents) {
329
331
  if (!eventOrder.includes(event)) eventOrder.push(event);
@@ -341,7 +343,7 @@ export function mergeManagedHooks(existingDoc, sidecar) {
341
343
  operatorGroups.push(group);
342
344
  }
343
345
  }
344
- const desiredHere = AIWG_MANAGED_HOOKS.filter((h) => h.event === event);
346
+ const desiredHere = desired.filter((h) => h.event === event);
345
347
  const nextGroups = [...operatorGroups];
346
348
  for (const hook of desiredHere) {
347
349
  nextGroups.push(hook.group);
@@ -368,10 +370,10 @@ export function mergeManagedHooks(existingDoc, sidecar) {
368
370
  return { doc: merged, changed, plan };
369
371
  }
370
372
 
371
- function buildHooksSidecar() {
373
+ function buildHooksSidecar(desired = AIWG_MANAGED_HOOKS) {
372
374
  return {
373
375
  version: 1,
374
- hooks: AIWG_MANAGED_HOOKS.map((h) => ({ id: h.id, event: h.event, group: h.group })),
376
+ hooks: desired.map((h) => ({ id: h.id, event: h.event, group: h.group })),
375
377
  };
376
378
  }
377
379
 
@@ -389,7 +391,7 @@ export function deployMuseHooks(targetDir, opts = {}) {
389
391
 
390
392
  const { doc: existingDoc, raw: existingRaw, existed } = readHooksDoc(hooksPath);
391
393
  const sidecar = readHooksSidecar(sidecarPath);
392
- const { doc: merged, changed, plan } = mergeManagedHooks(existingDoc, sidecar);
394
+ const { doc: merged, changed, plan } = mergeManagedHooks(existingDoc, sidecar, museHooksForTarget(opts.logicalOutputPath?.(targetDir) || targetDir, opts.scope));
393
395
 
394
396
  const beforeText = existed ? existingRaw : '(no .muse/hooks.json — will be created)';
395
397
  const afterText = canonicalJson(merged);
@@ -418,7 +420,7 @@ export function deployMuseHooks(targetDir, opts = {}) {
418
420
  fs.mkdirSync(path.dirname(hooksPath), { recursive: true });
419
421
  const backupPath = backupIfHandEdited(hooksPath, existingDoc, existingRaw, existed);
420
422
  atomicWrite(hooksPath, afterText);
421
- atomicWrite(sidecarPath, canonicalJson(buildHooksSidecar()));
423
+ atomicWrite(sidecarPath, canonicalJson(buildHooksSidecar(museHooksForTarget(opts.logicalOutputPath?.(targetDir) || targetDir, opts.scope))));
422
424
  log(`Muse hooks: merged ${plan.length} managed change(s) into ${hooksPath}`);
423
425
  if (backupPath) log(` backup (comments/formatting not preserved): ${backupPath}`);
424
426
  for (const step of plan) log(` ${step}`);
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url';
5
5
 
6
6
  import { importImpl } from '../../_resolve-impl.mjs';
7
7
 
8
- export const { promptDiscoveryHook } = await importImpl(import.meta.url, 'extensions/muse-managed-hooks.js');
8
+ export const { promptDiscoveryHook, managedMuseHooks } = await importImpl(import.meta.url, 'extensions/muse-managed-hooks.js');
9
9
 
10
10
  export function deployPromptDiscovery(targetDir) {
11
11
  const directory = path.join(targetDir, '.muse', 'hooks');
@@ -16,3 +16,7 @@ export function deployPromptDiscovery(targetDir) {
16
16
  fs.copyFileSync(fileURLToPath(new URL('../../../agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs', import.meta.url)),
17
17
  path.join(directory, 'aiwg-prompt-discovery.cjs'));
18
18
  }
19
+
20
+ export function museHooksForTarget(targetDir, scope) {
21
+ return managedMuseHooks(targetDir, fs.readFileSync(fileURLToPath(new URL('../../../agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs', import.meta.url))), scope);
22
+ }
@@ -50,6 +50,7 @@ import {
50
50
  museXdgSkillsDirRemediation,
51
51
  } from './muse-paths.mjs';
52
52
  import { importImpl } from '../../_resolve-impl.mjs';
53
+ const { MUSE_STANDARD_SKILLS_PATH } = await importImpl(import.meta.url, 'providers/muse-paths.js');
53
54
  const { captureDeploymentOutputs, recordDeploymentOutputs } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
54
55
  import { assertMuseUserSettingsPath, deployMuseHooks, deployMuseMcp } from './muse-hooks.mjs';
55
56
 
@@ -72,7 +73,7 @@ export const kernelSkillsPath = '.agents/skills';
72
73
 
73
74
  // Opt-in standard-tier mirror (only with --copy-all): siblings of the
74
75
  // project skills root, never the user XDG root and never ~/.agents/skills.
75
- const STANDARD_MIRROR_SUBDIR = '.agents/.aiwg/skills';
76
+ const STANDARD_MIRROR_SUBDIR = MUSE_STANDARD_SKILLS_PATH;
76
77
 
77
78
  export const support = {
78
79
  agents: 'indexed',
@@ -542,12 +542,13 @@ async function deploySelected(opts) {
542
542
  // sit inert on disk (no discover-first, no rule routing — the agent treats
543
543
  // `address-issues` as a generic query). Preserves operator content outside
544
544
  // the AIWG-managed section.
545
+ // Include kernel-only skill passes: both workspace files are startup context.
545
546
  // Run once, only from the batch whose srcRoot actually contains the framework
546
547
  // template (the repo/framework root). `aiwg use` invokes deploy() once per
547
548
  // framework AND per addon with different srcRoots; addon batches would warn
548
549
  // "template not found". The idempotent skip in createAgentsMdFromTemplate also
549
550
  // guards against double-injection across batches.
550
- if (!commandsOnly && !skillsOnly && !rulesOnly) {
551
+ if (!commandsOnly && !rulesOnly && (!skillsOnly || opts.kernelOnly)) {
551
552
  const templatePath = path.join(
552
553
  srcRoot, 'agentic', 'code', 'frameworks', 'sdlc-complete', 'templates', 'openclaw', 'AGENTS.md.aiwg-template',
553
554
  );
@@ -48,6 +48,7 @@ import { inlineStartup, projectRules } from './rule-projection.mjs';
48
48
  const { captureDeploymentOutputs, recordDeploymentOutputs } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
49
49
  const { preserveDeploymentOutputs } = await importImpl(import.meta.url, 'providers/deployment-preservation.mjs');
50
50
  import { retireInlineStartup } from './rule-startup.mjs';
51
+ import { createStagedDirectoryReference } from './staged-directory-reference.mjs';
51
52
 
52
53
  /** Stage only provider/context output, never the user's source tree. On failure
53
54
  * no staged output (including skills and behaviors) reaches the prior deployment. */
@@ -130,7 +131,7 @@ export async function prepareRuleDeployment(original, provider, deploy) {
130
131
  // The projector helpers execute installed code but receive the snapshot as data.
131
132
  for (const rel of ['tools', 'dist', 'node_modules', 'src']) {
132
133
  const from = path.join(corpusRoot, rel), to = path.join(snapshotRoot, rel);
133
- if (fs.existsSync(from)) fs.symlinkSync(from, to, 'dir');
134
+ if (fs.existsSync(from)) createStagedDirectoryReference(from, to);
134
135
  }
135
136
  }
136
137
  // Keep standalone fixture/bundle snapshots from inheriting the installed
@@ -258,8 +259,9 @@ export async function prepareRuleDeployment(original, provider, deploy) {
258
259
  kernel = to;
259
260
  }
260
261
  // Codex's legacy prompt helper is home-global. Give it an isolated home and
261
- // promote only its output after validation.
262
- if (provider.name === 'codex' && (original.deployCommands || original.commandsOnly)) mount(path.join(os.homedir(), '.codex', 'prompts'), path.join(home, '.codex', 'prompts'));
262
+ // promote only its output after validation. Kernel upgrades also need the
263
+ // legacy prompt preimages so ownership can adopt known October bytes.
264
+ if (provider.name === 'codex' && (original.deployCommands || original.commandsOnly || original.kernelOnly)) mount(path.join(os.homedir(), '.codex', 'prompts'), path.join(home, '.codex', 'prompts'));
263
265
  let hermesLegacySkills;
264
266
  let legacyCodexSkills;
265
267
  if (provider.name === 'hermes') {
@@ -5,6 +5,7 @@ import os from 'node:os';
5
5
  import path from 'node:path';
6
6
  import { resolveAiwgRoot } from './base.mjs';
7
7
  import { fileDigest, resolveProjectAiwgDir, trackTemporaryDirectory } from './rule-delivery-surface.mjs';
8
+ import { createStagedDirectoryReference } from './staged-directory-reference.mjs';
8
9
 
9
10
  // Plans contain only JSON values and a scratch directory. The preparing process
10
11
  // owns that directory until disposal; cross-process transfer needs a separate lease.
@@ -32,10 +33,11 @@ export function capturePreimage(file, ancestors = new Set()) {
32
33
  }
33
34
  if (stat.isFile()) return { kind: 'file', mode, digest: fileDigest(file) };
34
35
  if (stat.isDirectory()) return { kind: 'directory', mode, entries: fs.readdirSync(file).sort().map(name => [name, capturePreimage(path.join(file, name), new Set([...ancestors, path.resolve(file)]))]) };
35
- throw new Error(`Unsupported deployment preimage: ${file}`);
36
+ // Runtime IPC and other opaque entries are sealed by type, never read/copied.
37
+ return { kind: 'special', mode, type: stat.mode & fs.constants.S_IFMT };
36
38
  }
37
- // cpSync materializes links; compare its output with the recursively resolved
38
- // content while retaining the original link-shaped preimage for commit drift.
39
+ // Materialize regular content only. Retain link/special-shaped live preimages
40
+ // for commit drift, but omit dangling links and opaque entries from the stage.
39
41
  export function materializeInput(from, to, ancestors = new Set(), parentReady = false) {
40
42
  let stat;
41
43
  try { stat = fs.statSync(from); } catch (error) {
@@ -54,11 +56,14 @@ export function materializeInput(from, to, ancestors = new Set(), parentReady =
54
56
  } else if (stat.isFile()) {
55
57
  if (!parentReady) fs.mkdirSync(path.dirname(to), { recursive: true });
56
58
  fs.copyFileSync(from, to); fs.chmodSync(to, stat.mode & 0o7777);
57
- } else throw new Error(`Unsupported deployment input: ${from}`);
59
+ }
58
60
  }
59
61
  export function materializedPreimage(state) {
60
62
  if (state.kind === 'symlink') return materializedPreimage(state.resolved);
61
- if (state.kind === 'directory') return { ...state, entries: state.entries.map(([name, child]) => [name, materializedPreimage(child)]) };
63
+ if (state.kind === 'special') return { kind: 'missing' };
64
+ if (state.kind === 'directory') return { ...state, entries: state.entries
65
+ .map(([name, child]) => [name, materializedPreimage(child)])
66
+ .filter(([, child]) => child.kind !== 'missing') };
62
67
  return state;
63
68
  }
64
69
  export function snapshotPreimages(paths) {
@@ -161,7 +166,7 @@ export function createRuleDeploymentInputPool(srcRoot) {
161
166
  }
162
167
  for (const rel of ['tools', 'dist', 'node_modules', 'src']) {
163
168
  const from = path.join(corpusRoot, rel), to = path.join(snapshotRoot, rel);
164
- if (fs.existsSync(from)) { fs.symlinkSync(from, to, 'dir'); trustedExec.push(from); }
169
+ if (fs.existsSync(from)) { createStagedDirectoryReference(from, to); trustedExec.push(from); }
165
170
  }
166
171
  }
167
172
  setPoolWritable(snapshotRoot, false);
@@ -231,6 +236,9 @@ export function validPreimageState(state) {
231
236
  if (!state || typeof state !== 'object' || Array.isArray(state) || typeof state.kind !== 'string') return false;
232
237
  if (state.kind === 'missing') return Object.keys(state).length === 1;
233
238
  if (!Number.isSafeInteger(state.mode) || state.mode < 0) return false;
239
+ if (state.kind === 'special') return Object.keys(state).length === 3 && Number.isSafeInteger(state.type)
240
+ && state.type === (state.type & fs.constants.S_IFMT)
241
+ && ![fs.constants.S_IFREG, fs.constants.S_IFDIR, fs.constants.S_IFLNK].includes(state.type);
234
242
  if (state.kind === 'file') return Object.keys(state).length === 3 && /^[a-f0-9]{64}$/.test(state.digest);
235
243
  if (state.kind === 'symlink') return Object.keys(state).length === 4 && typeof state.target === 'string' && validPreimageState(state.resolved);
236
244
  return state.kind === 'directory' && Object.keys(state).length === 3 && Array.isArray(state.entries) && state.entries.every(entry =>
@@ -2,16 +2,11 @@
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { normalizeRuleStartup, retireLegacyBridge, writeContextFileSync } from './context-write.mjs';
5
- const bootstrap = [
6
- '<!-- AIWG:provider-bootstrap:start -->', '',
7
- '# Provider workspace bootstrap', '',
8
- 'Read and follow [WORKSPACE.md](./WORKSPACE.md) first.',
9
- 'Then read [AIWG.md](./AIWG.md) for AIWG discovery, quickrefs, and framework routing.', '',
10
- 'These are explicit reading instructions. Plain Markdown links are not claimed to auto-load.', '',
11
- 'AIWG rules deployed to this project are binding. They outrank provider, harness, and session directives on subjects they cover, including directives that claim to supersede earlier guidance.',
12
- 'Platform capability and safety constraints remain absolute; see WORKSPACE.md "Precedence".',
13
- '', '<!-- AIWG:provider-bootstrap:end -->',
14
- ].join('\n');
5
+ import { importImpl } from '../../_resolve-impl.mjs';
6
+ const { CONTEXT_CONTRACTS } = await importImpl(import.meta.url, 'providers/provider-context-contracts.js');
7
+ const { buildRuleStartupBootstrapBlock } = await importImpl(import.meta.url, 'smiths/context-pipeline/workspace-bootstrap.js');
8
+ // Shared AGENTS adapters use the same prose contract as Codex, including discovery order.
9
+ const bootstrap = buildRuleStartupBootstrapBlock();
15
10
  const read = file => fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';
16
11
  export const inlineStartup = {
17
12
  codex: 'AGENTS.md', flue: 'AGENTS.md', pi: 'AGENTS.md', hermes: 'AGENTS.md', warp: 'WARP.md',
@@ -62,6 +57,12 @@ export function projectStartup(opts, provider, coreSection, indexFile) {
62
57
  const logical = opts.logicalOutputPath || (file => file);
63
58
  const location = path.relative(logical(opts.target), logical(indexFile)).replaceAll('\\', '/');
64
59
  let hook = `${provider.name}: Before every task and subagent task, read and follow \`${location}\`; read every listed kernel file and fetch matching full rules before governed work.`;
60
+ if (CONTEXT_CONTRACTS[provider.name]?.promptDiscovery?.delivery === 'bootstrap-rule') {
61
+ hook += " Before any other tool call or answer on every new request, run `aiwg discover --stdin <<'AIWG_REQUEST'` "
62
+ + "with the request text on the next lines and `AIWG_REQUEST` alone on the last line; never put request text in quotes on a command line. "
63
+ + "Inspect the best candidate with `aiwg show <type> <name> --rules --with-rule-bodies`, read its instructions with `--body`, and apply them. "
64
+ + "Answering or declining without discovery violates the skill-discovery rule.";
65
+ }
65
66
  // droid exec runs no prompt hooks, so the Factory line carries discovery itself (#3942).
66
67
  // The request goes through a quoted heredoc so the shell never expands it (#3946).
67
68
  if (provider.name === 'factory') hook += " On every new request, your first tool call must be the shell command \`aiwg discover --stdin <<'AIWG_REQUEST'\` "
@@ -0,0 +1,14 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ /** Create a read-only reference to trusted provider snapshot inputs.
5
+ * Windows directory symbolic links can require elevated privilege, so use a
6
+ * junction with an absolute target there. POSIX keeps the existing `dir`
7
+ * symlink behavior. Junction creation errors propagate; callers own cleanup. */
8
+ export function createStagedDirectoryReference(from, to) {
9
+ if (process.platform === 'win32') {
10
+ fs.symlinkSync(path.resolve(from), to, 'junction');
11
+ return;
12
+ }
13
+ fs.symlinkSync(from, to, 'dir');
14
+ }
@@ -0,0 +1,26 @@
1
+ // Finalize user hook registrations after promotion, using the real provider home.
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { importImpl } from '../../_resolve-impl.mjs';
6
+ import { deployMuseHooks } from './muse-hooks.mjs';
7
+
8
+ export async function installUserHooks(provider, cfg) {
9
+ const frameworkRoot = fileURLToPath(new URL('../../../', import.meta.url));
10
+ const enabled = cfg.hooks !== false && !cfg.commandsOnly && !cfg.rulesOnly && (!cfg.skillsOnly || cfg.kernelOnly === true);
11
+ const home = os.homedir();
12
+ if (provider === 'claude' && (enabled || cfg.attribution !== false)) {
13
+ const { installAiwgHooks } = await importImpl(import.meta.url, 'extensions/claude-hooks-installer.js');
14
+ const result = await installAiwgHooks({ projectPath: home, frameworkRoot, scope: 'user', hooks: enabled,
15
+ attribution: cfg.attribution !== false });
16
+ // Same surface as project post-deploy: operator-facing settings warnings are never swallowed.
17
+ for (const warning of result?.warnings || []) console.warn(`Claude settings: ${warning}`);
18
+ return result;
19
+ }
20
+ if (provider === 'codex' && enabled) {
21
+ const { installCodexPromptDiscovery } = await importImpl(import.meta.url, 'smiths/hook-bridge/codex-translator.js');
22
+ return installCodexPromptDiscovery({ projectPath: home, frameworkRoot, scope: 'user',
23
+ hookDirectory: process.env.CODEX_HOME || path.join(home, '.codex') });
24
+ }
25
+ if (provider === 'muse' && enabled) return deployMuseHooks(home, { quiet: cfg.quiet, scope: 'user' });
26
+ }
@@ -0,0 +1,20 @@
1
+ // Presents the same read-only authorization health snapshot in status probes and doctor checks.
2
+ import { importImpl } from '../_resolve-impl.mjs';
3
+ export async function readAuthorizationHealth(projectDir) {
4
+ try {
5
+ const { authorizationHealth } = await importImpl(import.meta.url, 'policy/authorization-operations.js');
6
+ return await authorizationHealth(projectDir);
7
+ } catch {
8
+ return { active: 0, expiringSoon: 0, unverifiable: null, index: 'unknown',
9
+ failures: [{ reason: 'authorization-health-unavailable' }] };
10
+ }
11
+ }
12
+ export async function checkAuthorizationHealth(projectDir, check) {
13
+ const report = await readAuthorizationHealth(projectDir);
14
+ const warning = report.failures.length || report.expiringSoon || ['drift', 'missing', 'unknown'].includes(report.index);
15
+ check('authorization-grants', warning ? 'warn' : 'ok',
16
+ `${report.active} active, ${report.expiringSoon} expiring-soon, ${report.unverifiable ?? 'unknown'} unverifiable; index ${report.index}`
17
+ + (report.failures.length ? `; ${report.failures.length} verification failure(s)` : '')
18
+ + (warning ? ' — inspect with "aiwg config authorization list" and "aiwg config authorization verify"' : ''));
19
+ return report;
20
+ }
@@ -28,6 +28,8 @@ export function formatDecisionOffloadReport(snapshot) {
28
28
  const opportunities = snapshot.opportunities?.organic;
29
29
  lines.push(` Scope: ${snapshot.scope?.mode ?? 'unknown'}${snapshot.scope?.sessionId ? ` (${snapshot.scope.sessionId})` : ''}`);
30
30
  lines.push(` Ask: ${snapshot.readiness?.ask?.state ?? 'unknown'}; evaluate: ${snapshot.readiness?.evaluate?.state ?? 'unknown'} (no probe)`);
31
+ const credential = snapshot.readiness?.ask;
32
+ if (credential?.source) lines.push(` Credential source: ${credential.source}${credential.path ? `; path: ${credential.path}` : ''}`);
31
33
  lines.push(` Completed calls: ${calls?.completed ?? 'unknown'}; answered: ${calls?.answered ?? 'unknown'}; fallback: ${calls?.fallback ?? 'unknown'}`);
32
34
  if (calls) {
33
35
  lines.push(` Estimated LLM tokens avoided: ${calls.llmTokensAvoided}; Jev tokens: ${calls.jevTokens}`);
@@ -20,6 +20,7 @@
20
20
  */
21
21
 
22
22
  import fs from 'fs/promises';
23
+ import { readAuthorizationHealth } from './authorization-health.mjs';
23
24
  import { importImpl } from '../_resolve-impl.mjs';
24
25
  import { collectDecisionOffloadReport, formatDecisionOffloadReport } from './decision-offload-report.mjs';
25
26
  import { existsSync } from 'fs';
@@ -525,6 +526,11 @@ async function buildWorkspaceStatus(projectRoot) {
525
526
  }
526
527
 
527
528
  async function buildVerificationProbe(projectRoot) {
529
+ const { deploymentProbeScope } = await importImpl(import.meta.url, 'cli/services/deployment-probe-scope.js');
530
+ if (await deploymentProbeScope(projectRoot) === 'user') {
531
+ const { buildDeploymentStatusProbe } = await importImpl(import.meta.url, 'cli/services/deployment-verification.js');
532
+ return buildDeploymentStatusProbe(projectRoot, packageRoot, { scope: 'user' });
533
+ }
528
534
  const workspace = await buildWorkspaceStatus(projectRoot);
529
535
  const frameworkCount = workspace.frameworks.length;
530
536
  const providerCount = workspace.providerDeployments.length;
@@ -547,6 +553,7 @@ async function buildVerificationProbe(projectRoot) {
547
553
 
548
554
  return {
549
555
  schema: 'aiwg.status.probe.v1',
556
+ authorization: await readAuthorizationHealth(projectRoot),
550
557
  nativeSandboxWarnings: workspace.nativeSandboxWarnings,
551
558
  rule_pins: workspace.rule_pins,
552
559
  generated_at: new Date().toISOString(),
@@ -29,6 +29,8 @@ try { const gfs = _require('graceful-fs'); gfs.gracefulify(realFs); fs = realFs;
29
29
  import path from 'path';
30
30
  import { fileURLToPath } from 'node:url';
31
31
  import os from 'os';
32
+ import { importImpl } from '../_resolve-impl.mjs';
33
+ const { legacyCodexPromptOwner, outputDigest } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
32
34
  import { getFrameworksForMode, normalizeDeploymentMode, getAddonSkillDirs, listSkillDirs, collectFrameworkArtifacts } from '../agents/providers/base.mjs';
33
35
 
34
36
  function parseArgs(args, homeDir) {
@@ -172,7 +174,19 @@ function deployPrompt(prompt, targetDir, opts) {
172
174
 
173
175
  // Check if prompt already exists
174
176
  if (fs.existsSync(destPath)) {
175
- const existingContent = fs.readFileSync(destPath, 'utf8');
177
+ if (!fs.lstatSync(destPath).isFile()) return { action: 'skip', reason: 'protected' };
178
+ const bytes = fs.readFileSync(destPath);
179
+ const existingContent = bytes.toString('utf8');
180
+ let record;
181
+ try { record = JSON.parse(fs.readFileSync(path.join(targetDir, '.aiwg-manifest.json'), 'utf8')).managed?.[`${prompt.name}.md`]; } catch { /* legacy install */ }
182
+ // A recorded digest takes precedence over legacy evidence and markers:
183
+ // edited managed files and unknown same-named files stay protected.
184
+ const owned = record ? record.hash === outputDigest(bytes)
185
+ : legacyCodexPromptOwner(destPath, bytes) || /^(?:<!--\s*aiwg:managed\s|#\s*aiwg:managed\s)/m.test(existingContent);
186
+ if (!force && !owned) {
187
+ console.log(` skip (operator-owned): ${prompt.name}`);
188
+ return { action: 'skip', reason: 'protected' };
189
+ }
176
190
  if (existingContent === prompt.content && !force) {
177
191
  console.log(` skip (unchanged): ${prompt.name}`);
178
192
  return { action: 'skip', reason: 'unchanged' };
@@ -43,6 +43,7 @@ const PLUGIN_CONFIGS = {
43
43
  },
44
44
  extraCopy: [
45
45
  { from: 'agentic/code/frameworks/sdlc-complete/templates/issue-comments', to: 'templates/issue-comments' },
46
+ ...['milestone-worker-brief.md', 'verification-oracle-checklist.md'].map(name => ({ from: `agentic/code/frameworks/sdlc-complete/templates/management/${name}`, to: `templates/management/${name}` })),
46
47
  ...['threat-assessment.mjs', 'threat-assessment'].map(name => ({ from: `tools/security/${name}`, to: `tools/security/${name}` })),
47
48
  { from: 'agentic/code/frameworks/sdlc-complete/flows/flow-architecture-evolution.playbook.yaml', to: 'flows/flow-architecture-evolution.playbook.yaml' },
48
49
  { from: 'agentic/code/frameworks/sdlc-complete/flows/flow-release.playbook.yaml', to: 'flows/flow-release.playbook.yaml' }
@@ -301,6 +302,7 @@ Core AIWG utilities for context regeneration and workspace management.
301
302
  },
302
303
  extraCopy: [
303
304
  { from: 'agentic/code/frameworks/sdlc-complete/templates/issue-comments', to: 'templates/issue-comments' },
305
+ ...['milestone-worker-brief.md', 'verification-oracle-checklist.md'].map(name => ({ from: `agentic/code/frameworks/sdlc-complete/templates/management/${name}`, to: `templates/management/${name}` })),
304
306
  { from: 'agentic/code/frameworks/sdlc-complete/flows/flow-architecture-evolution.playbook.yaml', to: 'flows/flow-architecture-evolution.playbook.yaml' },
305
307
  { from: 'agentic/code/frameworks/sdlc-complete/flows/flow-release.playbook.yaml', to: 'flows/flow-release.playbook.yaml' }
306
308
  ],
@@ -336,6 +338,8 @@ Then install in Codex via the \`/plugins\` command or the repo marketplace.
336
338
  agents: 'agentic/code/frameworks/forensics-complete/agents',
337
339
  skills: 'agentic/code/frameworks/forensics-complete/skills'
338
340
  },
341
+ extraCopy: ['evidence-integrity', 'non-destructive'].map(name =>
342
+ ({ from: `agentic/code/frameworks/forensics-complete/rules/${name}.md`, to: `rules/${name}.md` })),
339
343
  readme: `# AIWG Forensics Complete
340
344
 
341
345
  Digital forensics and incident response framework with 14 specialized agents.
@@ -380,7 +384,8 @@ Digital forensics and incident response framework with 14 specialized agents.
380
384
  skills: 'agentic/code/frameworks/security-engineering/skills'
381
385
  },
382
386
  extraCopy: [
383
- { from: 'agentic/code/frameworks/security-engineering/rules/ci-action-pinning.md', to: 'rules/ci-action-pinning.md' }
387
+ { from: 'agentic/code/frameworks/security-engineering/rules/ci-action-pinning.md', to: 'rules/ci-action-pinning.md' },
388
+ { from: 'agentic/code/frameworks/security-engineering/rules/published-port-binding.md', to: 'rules/published-port-binding.md' }
384
389
  ],
385
390
  readme: `# AIWG Security Engineering
386
391
 
@@ -13,12 +13,12 @@ import { homedir } from 'os';
13
13
  import { ProviderAdapter, registerProvider } from './provider-adapter.mjs';
14
14
  import { classifyWorkerHealthFailure, healthEventMatchesBinding } from './worker-health.mjs';
15
15
 
16
- /** Help-only evidence: /home/roctinam/.local/bin/claude 2.1.295, 2026-10-09.
16
+ /** Help-only evidence: /home/roctinam/.local/bin/claude 2.1.319, 2026-11-07.
17
17
  * Exact help excerpts and unavailable controls: docs/providers/claude-direct.md.
18
18
  * No inference or credential inspection was performed to establish this syntax.
19
19
  */
20
20
  export const interfaceVersion = 1;
21
- export const CLAUDE_SUPPORTED_VERSIONS = Object.freeze(['2.1.295']);
21
+ export const CLAUDE_SUPPORTED_VERSIONS = Object.freeze(['>=2.1.295 <2.2.0']);
22
22
  export const CLAUDE_DIRECT_EFFORT_VALUES = Object.freeze(['low', 'medium', 'high', 'xhigh', 'max']);
23
23
  // Named aliases --help documents (opus/sonnet/fable) plus other known moving
24
24
  // pointers: 'default', 'haiku', and the Max-plan 'opusplan' alias. None of
@@ -1239,6 +1239,26 @@
1239
1239
  "type": "object",
1240
1240
  "additionalProperties": false,
1241
1241
  "properties": {
1242
+ "precedence": {
1243
+ "type": "object",
1244
+ "description": "Per-rule ordering overrides. Non-overridable rules reject every override; rule IDs must resolve unambiguously.",
1245
+ "propertyNames": {
1246
+ "minLength": 1,
1247
+ "not": { "enum": ["__proto__", "prototype", "constructor"] }
1248
+ },
1249
+ "additionalProperties": {
1250
+ "type": "object",
1251
+ "minProperties": 1,
1252
+ "additionalProperties": false,
1253
+ "properties": {
1254
+ "tier": { "type": "string", "enum": ["critical", "high", "medium", "low"] },
1255
+ "project_context": {
1256
+ "type": "boolean",
1257
+ "description": "Explicitly allow WORKSPACE.md project context to outrank this rule."
1258
+ }
1259
+ }
1260
+ }
1261
+ },
1242
1262
  "inline_budget_tokens": {
1243
1263
  "type": "integer",
1244
1264
  "minimum": 0,