@aiwg/cli 2026.10.15 → 2026.10.18

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 (286) hide show
  1. package/agentic/code/providers/pi/aiwg-bridge.ts +45 -7
  2. package/dist/src/artifacts/citation-parser.js +7 -6
  3. package/dist/src/artifacts/corpus-tools/citation-densify.js +4 -2
  4. package/dist/src/artifacts/corpus-tools/cli.js +8 -3
  5. package/dist/src/artifacts/corpus-tools/discovery-log.js +26 -24
  6. package/dist/src/artifacts/corpus-tools/expand-cli.js +3 -2
  7. package/dist/src/artifacts/corpus-tools/expand-dates.js +107 -0
  8. package/dist/src/artifacts/corpus-tools/expand-queue.js +4 -1
  9. package/dist/src/artifacts/corpus-tools/expand-review.js +104 -0
  10. package/dist/src/artifacts/corpus-tools/expand-state.js +17 -1
  11. package/dist/src/artifacts/corpus-tools/expand.js +16 -17
  12. package/dist/src/artifacts/corpus-tools/induction-audit.js +7 -6
  13. package/dist/src/artifacts/corpus-tools/integrity-scan.js +3 -3
  14. package/dist/src/artifacts/corpus-tools/radar-shared.js +7 -9
  15. package/dist/src/artifacts/corpus-tools/ref-files.js +11 -0
  16. package/dist/src/artifacts/corpus-tools/resolve-cli.js +11 -3
  17. package/dist/src/artifacts/corpus-tools/resolve.js +42 -11
  18. package/dist/src/artifacts/corpus-tools/retrieval-lab.js +2 -1
  19. package/dist/src/artifacts/corpus-tools/sidecar-lint.js +4 -4
  20. package/dist/src/artifacts/corpus-tools/sidecar-repair.js +2 -1
  21. package/dist/src/artifacts/corpus-views/ref-parser.js +3 -17
  22. package/dist/src/artifacts/graph-query.js +5 -3
  23. package/dist/src/artifacts/hybrid-query.js +11 -2
  24. package/dist/src/artifacts/index-refresh.js +2 -0
  25. package/dist/src/artifacts/query-engine-corpus.js +217 -0
  26. package/dist/src/artifacts/query-engine-discover-output.js +229 -0
  27. package/dist/src/artifacts/query-engine-discover.js +285 -0
  28. package/dist/src/artifacts/query-engine-entries.js +188 -0
  29. package/dist/src/artifacts/query-engine-index.js +249 -0
  30. package/dist/src/artifacts/query-engine-matching.js +143 -0
  31. package/dist/src/artifacts/query-engine-options.js +2 -0
  32. package/dist/src/artifacts/query-engine-rules.js +202 -0
  33. package/dist/src/artifacts/query-engine-scoring.js +436 -0
  34. package/dist/src/artifacts/query-engine-show-card.js +194 -0
  35. package/dist/src/artifacts/query-engine-show-load.js +211 -0
  36. package/dist/src/artifacts/query-engine-show.js +300 -0
  37. package/dist/src/artifacts/query-engine.js +7 -2576
  38. package/dist/src/cli/handlers/daemon.js +17 -1
  39. package/dist/src/cli/handlers/doctor-args.js +10 -5
  40. package/dist/src/cli/handlers/doctor-help.js +4 -1
  41. package/dist/src/cli/handlers/index.js +2 -2
  42. package/dist/src/cli/handlers/mc-agents.js +111 -0
  43. package/dist/src/cli/handlers/mc-args.js +54 -0
  44. package/dist/src/cli/handlers/mc-control.js +227 -0
  45. package/dist/src/cli/handlers/mc-dispatch.js +203 -0
  46. package/dist/src/cli/handlers/mc-help.js +171 -0
  47. package/dist/src/cli/handlers/mc-run.js +343 -0
  48. package/dist/src/cli/handlers/mc-session.js +138 -0
  49. package/dist/src/cli/handlers/mc-status.js +258 -0
  50. package/dist/src/cli/handlers/mc-summary.js +43 -0
  51. package/dist/src/cli/handlers/mc-types.js +3 -0
  52. package/dist/src/cli/handlers/mc-worker.js +205 -0
  53. package/dist/src/cli/handlers/mc.js +12 -1665
  54. package/dist/src/cli/handlers/models-refusal.js +13 -0
  55. package/dist/src/cli/handlers/models-resource-sample.js +10 -0
  56. package/dist/src/cli/handlers/models.js +5 -3
  57. package/dist/src/cli/handlers/regenerate.js +8 -16
  58. package/dist/src/cli/handlers/remove-bundled.js +133 -0
  59. package/dist/src/cli/handlers/remove-options.js +31 -0
  60. package/dist/src/cli/handlers/remove-user.js +174 -0
  61. package/dist/src/cli/handlers/remove.js +201 -0
  62. package/dist/src/cli/handlers/sessions.js +7 -7
  63. package/dist/src/cli/handlers/subcommands-bundles.js +257 -0
  64. package/dist/src/cli/handlers/subcommands-discovery.js +165 -0
  65. package/dist/src/cli/handlers/subcommands-list-format.js +129 -0
  66. package/dist/src/cli/handlers/subcommands-list.js +250 -0
  67. package/dist/src/cli/handlers/subcommands-plugins.js +213 -0
  68. package/dist/src/cli/handlers/subcommands-quickref.js +58 -0
  69. package/dist/src/cli/handlers/subcommands-rlm.js +113 -0
  70. package/dist/src/cli/handlers/subcommands-services.js +66 -0
  71. package/dist/src/cli/handlers/subcommands-storage.js +259 -0
  72. package/dist/src/cli/handlers/subcommands.js +18 -1976
  73. package/dist/src/cli/handlers/update.js +157 -0
  74. package/dist/src/cli/handlers/use.js +14 -4
  75. package/dist/src/cli/handlers/utilities.js +3 -560
  76. package/dist/src/cli/handlers/utility-doctor.js +412 -0
  77. package/dist/src/cli/scope-resolver.js +1 -142
  78. package/dist/src/cli/services/deployment-verification.js +0 -1
  79. package/dist/src/cli/user-scope-mirror.js +173 -0
  80. package/dist/src/config/aiwg-config.js +2 -1
  81. package/dist/src/config/authorization-cli.js +7 -3
  82. package/dist/src/config/dispatch-host-thresholds.js +2 -0
  83. package/dist/src/config/dispatch-thresholds-runtime.d.mts +3 -2
  84. package/dist/src/config/dispatch-thresholds-runtime.mjs +21 -7
  85. package/dist/src/config/framework-aliases.js +12 -0
  86. package/dist/src/config/host-resource-report.d.mts +24 -0
  87. package/dist/src/config/host-resource-report.mjs +110 -0
  88. package/dist/src/config/host-resource-runtime.d.mts +37 -0
  89. package/dist/src/config/host-resource-runtime.mjs +296 -0
  90. package/dist/src/config/installed-selection.js +22 -0
  91. package/dist/src/config/worker-invocation-marker.d.mts +1 -0
  92. package/dist/src/config/worker-invocation-marker.mjs +2 -0
  93. package/dist/src/decision/ensemble-study/artifacts.js +7 -0
  94. package/dist/src/decision/ensemble-study/gate-policy.js +58 -0
  95. package/dist/src/decision/ensemble-study/gates.js +78 -0
  96. package/dist/src/decision/ensemble-study/protocol.js +18 -21
  97. package/dist/src/decision/ensemble-study/score.js +3 -2
  98. package/dist/src/decision/ensemble-study/statistics.js +7 -26
  99. package/dist/src/decision/heldout/access.js +74 -0
  100. package/dist/src/decision/heldout/calibration.js +1 -0
  101. package/dist/src/decision/heldout/collector.js +8 -1
  102. package/dist/src/decision/sensitivity/comparative-gates.js +135 -0
  103. package/dist/src/decision/sensitivity/comparative.js +18 -41
  104. package/dist/src/effects/verifiers/file.js +22 -5
  105. package/dist/src/extensions/claude-attribution.js +82 -0
  106. package/dist/src/extensions/claude-hooks-installer.js +133 -69
  107. package/dist/src/extensions/commands/daemon.js +109 -0
  108. package/dist/src/extensions/commands/definitions.js +5 -89
  109. package/dist/src/gates/evaluate.js +2 -358
  110. package/dist/src/gates/heldout.js +17 -7
  111. package/dist/src/gates/observations.js +363 -0
  112. package/dist/src/gates/pack-composition.js +270 -0
  113. package/dist/src/gates/pack-tightening.js +197 -0
  114. package/dist/src/gates/pack-validation.js +262 -0
  115. package/dist/src/gates/registry-error.js +5 -0
  116. package/dist/src/gates/registry.js +13 -685
  117. package/dist/src/lint/check-patterns.js +163 -0
  118. package/dist/src/lint/checks.js +268 -0
  119. package/dist/src/lint/reference-resolution.js +54 -0
  120. package/dist/src/lint/runner.js +3 -465
  121. package/dist/src/mcp/helpers.mjs +11 -1
  122. package/dist/src/mcp/json-document.mjs +29 -0
  123. package/dist/src/mcp/muse-native-config.mjs +1 -28
  124. package/dist/src/memory/project-registry.js +44 -4
  125. package/dist/src/mission-protocol/worker-review-gate.js +7 -0
  126. package/dist/src/models/worker-plan.js +36 -5
  127. package/dist/src/models/wrapper-deployment.js +25 -12
  128. package/dist/src/models/wrapper-enforcement.js +47 -7
  129. package/dist/src/network-analysis/research.js +2 -1
  130. package/dist/src/plugin/command-ownership.js +34 -0
  131. package/dist/src/plugin/skill-command-frontmatter.js +197 -0
  132. package/dist/src/plugin/skill-command-translator.js +6 -232
  133. package/dist/src/policy/hitl-check.js +14 -4
  134. package/dist/src/policy/hitl-consume.js +54 -0
  135. package/dist/src/policy/hitl-receipt.js +2 -0
  136. package/dist/src/policy/hitl.js +11 -3
  137. package/dist/src/providers/context-output-ownership.js +26 -0
  138. package/dist/src/providers/deployment-ownership.d.mts +19 -0
  139. package/dist/src/providers/deployment-ownership.mjs +226 -0
  140. package/dist/src/providers/deployment-removal.js +200 -0
  141. package/dist/src/providers/provider-context-contracts.js +162 -0
  142. package/dist/src/providers/provider-definition-schema.js +136 -0
  143. package/dist/src/providers/provider-definitions.js +8 -1298
  144. package/dist/src/providers/provider-seeds-1.js +360 -0
  145. package/dist/src/providers/provider-seeds-2.js +387 -0
  146. package/dist/src/providers/provider-seeds-3.js +262 -0
  147. package/dist/src/providers/removal-transaction.js +86 -0
  148. package/dist/src/providers/settings-document.d.mts +3 -0
  149. package/dist/src/providers/settings-document.mjs +47 -0
  150. package/dist/src/providers/settings-removal.js +190 -0
  151. package/dist/src/providers/skill-ownership.d.mts +19 -2
  152. package/dist/src/providers/skill-ownership.mjs +12 -4
  153. package/dist/src/providers/transformation-receipt-integration.js +15 -271
  154. package/dist/src/providers/transformation-receipt-outputs.js +99 -0
  155. package/dist/src/providers/transformation-receipt-source.js +194 -0
  156. package/dist/src/research/clients/arxiv.js +4 -30
  157. package/dist/src/research/clients/base.js +48 -22
  158. package/dist/src/research/identity.js +42 -4
  159. package/dist/src/research/query-cli.js +3 -87
  160. package/dist/src/research/query-options.js +87 -0
  161. package/dist/src/research/reference-match.js +105 -24
  162. package/dist/src/research/services/acquisition.js +9 -7
  163. package/dist/src/research/services/citation.js +5 -2
  164. package/dist/src/research/types.js +2 -0
  165. package/dist/src/rules/activation.mjs +15 -6
  166. package/dist/src/rules/core-startup.mjs +2 -2
  167. package/dist/src/serve/mission-conductor.js +52 -4
  168. package/dist/src/serve/mission-summary.js +56 -0
  169. package/dist/src/sessions/adapters/grok-build-native.js +23 -0
  170. package/dist/src/sessions/adapters/grok-build.js +14 -7
  171. package/dist/src/sessions/workspace-discovery.js +5 -5
  172. package/dist/src/smiths/context-pipeline/aiwg-md.js +39 -46
  173. package/dist/src/smiths/context-pipeline/claude-hook.js +1 -1
  174. package/dist/src/smiths/context-pipeline/code-regions.js +28 -0
  175. package/dist/src/smiths/context-pipeline/context-file-safety.js +3 -0
  176. package/dist/src/smiths/context-pipeline/finalization.js +81 -51
  177. package/dist/src/smiths/context-pipeline/generator.js +10 -11
  178. package/dist/src/smiths/context-pipeline/managed-hook.js +1 -1
  179. package/dist/src/smiths/context-pipeline/muse-bridge.js +2 -2
  180. package/dist/src/smiths/context-pipeline/provider-policy.js +6 -12
  181. package/dist/src/smiths/context-pipeline/workspace-audit.js +299 -0
  182. package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +148 -0
  183. package/dist/src/smiths/context-pipeline/workspace-context-shared.js +111 -0
  184. package/dist/src/smiths/context-pipeline/workspace-context.js +8 -1373
  185. package/dist/src/smiths/context-pipeline/workspace-doctor.js +192 -0
  186. package/dist/src/smiths/context-pipeline/workspace-document.js +201 -0
  187. package/dist/src/smiths/context-pipeline/workspace-extraction.js +205 -0
  188. package/dist/src/smiths/context-pipeline/workspace-migration.js +250 -0
  189. package/dist/src/smiths/hook-bridge/index.js +9 -0
  190. package/package.json +13 -1
  191. package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
  192. package/schemas/decision/D29Study.v10.schema.json +65 -0
  193. package/tools/agents/deploy-agents.mjs +24 -675
  194. package/tools/agents/deploy-command-mirrors.mjs +229 -0
  195. package/tools/agents/deploy-options.mjs +258 -0
  196. package/tools/agents/deploy-support.mjs +165 -0
  197. package/tools/agents/providers/base-addon-discovery.mjs +139 -0
  198. package/tools/agents/providers/base-behaviors.mjs +168 -0
  199. package/tools/agents/providers/base-context.mjs +205 -0
  200. package/tools/agents/providers/base-contract.mjs +116 -0
  201. package/tools/agents/providers/base-files.mjs +252 -0
  202. package/tools/agents/providers/base-flat-artifacts.mjs +233 -0
  203. package/tools/agents/providers/base-framework-discovery.mjs +309 -0
  204. package/tools/agents/providers/base-frontmatter.mjs +196 -0
  205. package/tools/agents/providers/base-inventory.mjs +269 -0
  206. package/tools/agents/providers/base-kernel-skills.mjs +354 -0
  207. package/tools/agents/providers/base-migrations.mjs +258 -0
  208. package/tools/agents/providers/base-models-platforms.mjs +273 -0
  209. package/tools/agents/providers/base-rule-index.mjs +450 -0
  210. package/tools/agents/providers/base-runtime.mjs +60 -0
  211. package/tools/agents/providers/base-skill-copy.mjs +273 -0
  212. package/tools/agents/providers/base.mjs +16 -3364
  213. package/tools/agents/providers/claude-post-deploy.mjs +20 -1
  214. package/tools/agents/providers/context-write.mjs +4 -0
  215. package/tools/agents/providers/hermes-startup.mjs +0 -5
  216. package/tools/agents/providers/muse.mjs +7 -2
  217. package/tools/agents/providers/pi.mjs +3 -1
  218. package/tools/agents/providers/rule-delivery-surface.mjs +359 -0
  219. package/tools/agents/providers/rule-delivery.mjs +20 -1144
  220. package/tools/agents/providers/rule-deployment-commit.mjs +148 -0
  221. package/tools/agents/providers/rule-deployment-prepare.mjs +461 -0
  222. package/tools/agents/providers/rule-deployment-state.mjs +300 -0
  223. package/tools/agents/providers/rule-projection.mjs +3 -0
  224. package/tools/daemon/README.md +511 -0
  225. package/tools/daemon/adapters/base-adapter.mjs +84 -0
  226. package/tools/daemon/adapters/webhook-adapter.mjs +107 -0
  227. package/tools/daemon/agent-supervisor.mjs +299 -0
  228. package/tools/daemon/automation-engine.mjs +310 -0
  229. package/tools/daemon/autonomous-engine.mjs +346 -0
  230. package/tools/daemon/behavior-loader.mjs +316 -0
  231. package/tools/daemon/behavior.mjs +174 -0
  232. package/tools/daemon/concierge/intent-router.mjs +401 -0
  233. package/tools/daemon/concierge/orchestrator.mjs +272 -0
  234. package/tools/daemon/concierge/response-translator.mjs +462 -0
  235. package/tools/daemon/config.mjs +377 -0
  236. package/tools/daemon/cron-scheduler.mjs +178 -0
  237. package/tools/daemon/daemon-main.mjs +1169 -0
  238. package/tools/daemon/event-router.mjs +84 -0
  239. package/tools/daemon/file-watcher.mjs +383 -0
  240. package/tools/daemon/index.mjs +1181 -0
  241. package/tools/daemon/init-profile.mjs +124 -0
  242. package/tools/daemon/ipc-client.mjs +197 -0
  243. package/tools/daemon/ipc-ops-handlers.mjs +236 -0
  244. package/tools/daemon/ipc-server.mjs +275 -0
  245. package/tools/daemon/maintenance-owner.mjs +79 -0
  246. package/tools/daemon/memory-manager.mjs +386 -0
  247. package/tools/daemon/message-router.mjs +194 -0
  248. package/tools/daemon/provider-watcher.mjs +585 -0
  249. package/tools/daemon/pty-adapter.mjs +420 -0
  250. package/tools/daemon/repl-chat.mjs +359 -0
  251. package/tools/daemon/resource-bounds.mjs +88 -0
  252. package/tools/daemon/sandbox-transport.mjs +295 -0
  253. package/tools/daemon/scheduled-task-runner.mjs +535 -0
  254. package/tools/daemon/task-store.mjs +450 -0
  255. package/tools/daemon/tmux-manager.mjs +324 -0
  256. package/tools/daemon/update-policy.mjs +517 -0
  257. package/tools/daemon/web-server.mjs +399 -0
  258. package/tools/daemon/web-ui/index.html +585 -0
  259. package/tools/daemon/web-ui/styles.css +156 -0
  260. package/tools/docker/Dockerfile.daemon +35 -0
  261. package/tools/docker/container-manager.mjs +291 -0
  262. package/tools/messaging/adapter-registry.mjs +230 -0
  263. package/tools/messaging/adapters/base.mjs +326 -0
  264. package/tools/messaging/adapters/discord.mjs +462 -0
  265. package/tools/messaging/adapters/slack.mjs +402 -0
  266. package/tools/messaging/adapters/telegram.mjs +552 -0
  267. package/tools/messaging/chat-handler.mjs +297 -0
  268. package/tools/messaging/command-router.mjs +269 -0
  269. package/tools/messaging/event-bus.mjs +199 -0
  270. package/tools/messaging/index.mjs +456 -0
  271. package/tools/messaging/message-formatter.mjs +320 -0
  272. package/tools/messaging/room-manager.mjs +277 -0
  273. package/tools/messaging/types.mjs +94 -0
  274. package/tools/providers/pi-bridge-policy.mjs +4 -0
  275. package/tools/ralph-external/daemon-supervisor.mjs +394 -0
  276. package/tools/ralph-external/lib/behavior-registry.mjs +270 -0
  277. package/tools/ralph-external/lib/worker-invocation-processes.mjs +7 -4
  278. package/tools/ralph-external/lib/worker-isolation-args.mjs +217 -0
  279. package/tools/ralph-external/lib/worker-isolation-status.mjs +19 -0
  280. package/tools/ralph-external/lib/worker-isolation.mjs +11 -237
  281. package/tools/ralph-external/lib/worker-overflow.mjs +10 -2
  282. package/tools/ralph-external/lib/worker-termination.mjs +15 -8
  283. package/tools/ralph-external/lib/worker-unit-cleanup.mjs +72 -0
  284. package/tools/ralph-external/session-launcher.mjs +7 -7
  285. package/tools/scripts/resource-preflight.mjs +3 -242
  286. package/vscode-extension/schemas/aiwg.config.v1.json +2 -4
@@ -0,0 +1,226 @@
1
+ // Extend deploy sidecars with current-write ownership and settings preimages.
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { createHash } from 'node:crypto';
5
+ import { parseTOML, getStaticTOMLValue } from 'toml-eslint-parser';
6
+ import { parse as parseYaml } from 'yaml';
7
+ import { parseJson } from '../mcp/json-document.mjs';
8
+ import { extractFrameworkSlug, mergeArtifactOwnership } from './skill-ownership.mjs';
9
+
10
+ const SIDECAR = '.aiwg-manifest.json';
11
+ const hash = bytes => `sha256:${createHash('sha256').update(bytes).digest('hex')}`;
12
+ const portable = value => value.split(path.sep).join('/');
13
+ const stable = value => JSON.stringify(value, (_key, child) => child && typeof child === 'object' && !Array.isArray(child)
14
+ ? Object.fromEntries(Object.entries(child).sort(([a], [b]) => a.localeCompare(b))) : child);
15
+ const parse = bytes => { try { return JSON.parse(bytes?.toString() || '{}'); } catch { return {}; } };
16
+ const bundleOwner = source => extractFrameworkSlug(source) || source.replaceAll('\\', '/').match(/(?:agentic\/code|\.aiwg)\/(?:frameworks|addons|extensions|plugins)\/([^/]+)\//)?.[1];
17
+ export const deploymentOwner = opts => {
18
+ const names = { sdlc: 'sdlc-complete', marketing: 'media-marketing-kit', mmk: 'media-marketing-kit',
19
+ research: 'research-complete', forensics: 'forensics-complete', dfir: 'forensics-complete', validation: 'validation-complete', ops: 'ops-complete', general: 'writing-quality' };
20
+ return opts.frameworkSlug || bundleOwner(`${opts.logicalInputPath?.(opts.srcRoot) || opts.srcRoot}/manifest.json`) || names[opts.mode] || opts.mode;
21
+ };
22
+
23
+ /** Only provider output surfaces, never arbitrary project source directories. */
24
+ export function deploymentOutputRoots(provider, target) {
25
+ const roots = Object.values(provider.paths || {}).filter(Boolean).map(dir => path.isAbsolute(dir)
26
+ ? dir : path.join(target, dir.split(/[\\/]/)[0]));
27
+ if (provider.kernelSkillsPath) roots.push(path.resolve(target, provider.kernelSkillsPath));
28
+ return [...new Set([...roots, path.join(target, `.${provider.name}`), path.join(target, '.agents'),
29
+ ...['AGENTS.md', 'AIWG.md', 'WORKSPACE.md', 'CLAUDE.md', 'WARP.md', '.hermes.md', 'opencode.json',
30
+ '.windsurfrules', 'models.json', '.aiwg/frameworks', '.aiwg/.aiwg-manifest.json'].map(name => path.join(target, name))])];
31
+ }
32
+
33
+ /** Capture regular output files before this invocation; never follow symlinks. */
34
+ export function captureDeploymentOutputs(roots) {
35
+ const files = new Map();
36
+ const visit = file => {
37
+ let stat;
38
+ try { stat = fs.lstatSync(file); } catch (error) { if (error.code === 'ENOENT') return; throw error; }
39
+ if (stat.isDirectory()) for (const name of fs.readdirSync(file)) visit(path.join(file, name));
40
+ else if (stat.isFile()) files.set(path.resolve(file), fs.readFileSync(file));
41
+ };
42
+ for (const root of roots) visit(root);
43
+ // A root-level file's sidecar is itself outside that file's snapshot root.
44
+ for (const file of [...files.keys()]) {
45
+ const receipt = path.join(path.dirname(file), SIDECAR);
46
+ if (!files.has(receipt) && fs.existsSync(receipt) && fs.lstatSync(receipt).isFile()) files.set(receipt, fs.readFileSync(receipt));
47
+ }
48
+ return files;
49
+ }
50
+
51
+ function settingsDocument(file, bytes) {
52
+ if (!bytes) return {};
53
+ try {
54
+ if (file.endsWith('.toml')) return getStaticTOMLValue(parseTOML(bytes.toString()));
55
+ if (/\.ya?ml$/.test(file)) return parseYaml(bytes.toString()) ?? {};
56
+ return parseJson(bytes.toString());
57
+ } catch { return null; }
58
+ }
59
+
60
+ /** Recompute value digests after staged logical-path normalization. */
61
+ export function refreshSettingsDigests(record) {
62
+ for (const entry of Object.values(record.settings || {})) {
63
+ entry.hash = hash(stable(entry.value));
64
+ for (const contribution of entry.contributions || []) contribution.hash = hash(stable(contribution.value));
65
+ }
66
+ }
67
+
68
+ function leaves(value, pointer = '', out = {}) {
69
+ if (value && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length) {
70
+ for (const [key, child] of Object.entries(value)) leaves(child, `${pointer}/${key.replaceAll('~', '~0').replaceAll('/', '~1')}`, out);
71
+ } else out[pointer] = value;
72
+ return out;
73
+ }
74
+
75
+ /** Settings arrays retain individual contributions so operator entries aren't claimed. */
76
+ function settingsRecords(previous, current, prior, owner, claimUnchanged) {
77
+ const records = { ...prior };
78
+ if (current === null) return records;
79
+ const before = previous === null ? {} : leaves(previous), after = leaves(current);
80
+ for (const [pointer, value] of Object.entries(after)) {
81
+ const old = records[pointer];
82
+ if (stable(before[pointer]) === stable(value)) {
83
+ if (claimUnchanged && old?.hash === hash(stable(value))) {
84
+ records[pointer] = { ...old, owners: [...new Set([...(old.owners || []), owner])].sort(),
85
+ ...(old.contributions ? { contributions: old.contributions.map(entry => ({ ...entry,
86
+ owners: [...new Set([...entry.owners, ...(Array.isArray(value) || entry.hash === old.hash && !old.contributions.some(item => item.owners.includes(owner)) ? [owner] : [])])].sort() })) } : {}) };
87
+ }
88
+ continue;
89
+ }
90
+ const digest = hash(stable(value));
91
+ const verified = Object.hasOwn(before, pointer) && old?.hash === hash(stable(before[pointer]));
92
+ const preimage = verified ? old.previous
93
+ : previous === null ? { unverifiable: true } : { present: Object.hasOwn(before, pointer), ...(Object.hasOwn(before, pointer) ? { value: before[pointer] } : {}) };
94
+ const record = { hash: digest, value, previous: preimage, owners: [...new Set([...(verified ? old.owners || [] : []), owner])].sort() };
95
+ if (!Array.isArray(value) && verified) {
96
+ const contributions = old.contributions || [{ hash: old.hash, value: old.value, owners: old.owners }];
97
+ record.contributions = [...contributions.flatMap(entry => {
98
+ const owners = entry.owners.filter(candidate => candidate !== owner);
99
+ return owners.length ? [{ ...entry, owners }] : [];
100
+ }), { hash: digest, value, owners: [owner] }];
101
+ }
102
+ if (Array.isArray(value)) {
103
+ const previousValues = Array.isArray(before[pointer]) ? before[pointer] : [];
104
+ record.contributions = value.flatMap(item => {
105
+ const itemHash = hash(stable(item));
106
+ const existing = old?.contributions?.find(entry => entry.hash === itemHash);
107
+ if (existing) return [existing];
108
+ return previousValues.some(entry => stable(entry) === stable(item)) ? [] : [{ hash: itemHash, value: item, owners: [owner] }];
109
+ });
110
+ }
111
+ records[pointer] = record;
112
+ }
113
+ return records;
114
+ }
115
+
116
+ function artifactKind(file) {
117
+ if (/(?:^|[/\\])hooks?[/\\]/.test(file)) return 'hook';
118
+ if (/(?:^|[/\\])(?:skills|skill)[/\\]/.test(file)) return 'skill';
119
+ if (/(?:^|[/\\])(?:agents|droids)[/\\]/.test(file)) return 'agent';
120
+ if (/(?:^|[/\\])(?:commands|prompts|workflows)[/\\]/.test(file)) return 'command';
121
+ if (/(?:^|[/\\])(?:rules|rule|copilot-rules)[/\\]/.test(file)) return 'rule';
122
+ return 'generated';
123
+ }
124
+
125
+ /** Record only writes evidenced by this invocation or newly emitted file receipts. */
126
+ export function recordDeploymentOutputs(before, roots, opts = {}) {
127
+ if (opts.dryRun) return;
128
+ const after = captureDeploymentOutputs(roots);
129
+ const owner = deploymentOwner(opts);
130
+ const manifests = new Map();
131
+ const manifest = dir => {
132
+ const file = path.join(dir, SIDECAR);
133
+ if (!manifests.has(file)) manifests.set(file, parse(after.get(file)));
134
+ return manifests.get(file);
135
+ };
136
+ const projectRoot = opts.target && path.resolve(opts.target);
137
+ const receiptRoot = (file, receipt) => projectRoot && file === path.join(projectRoot, '.aiwg', SIDECAR) && receipt.scope === 'project'
138
+ ? projectRoot : path.dirname(file);
139
+ const declared = new Map();
140
+ for (const [file, bytes] of after) {
141
+ if (path.basename(file) !== SIDECAR) continue;
142
+ const receipt = parse(bytes), previous = parse(before.get(file));
143
+ // Legacy writers replace their managed map. Retain already recorded,
144
+ // untouched metadata files/resources they omit; this never adopts a file.
145
+ for (const [name, entry] of Object.entries(previous.managed || {})) {
146
+ const base = receiptRoot(file, receipt);
147
+ const target = path.resolve(base, name);
148
+ if (!target.startsWith(`${base}${path.sep}`) || receipt.managed?.[name]) continue;
149
+ if (!before.has(target) || !after.get(target)?.equals(before.get(target))) continue;
150
+ receipt.managed ||= {};
151
+ receipt.managed[name] = entry;
152
+ manifests.set(file, receipt);
153
+ }
154
+ for (const [name, entry] of Object.entries(receipt.managed || {})) {
155
+ const base = receiptRoot(file, receipt);
156
+ const target = path.resolve(base, name);
157
+ if (!target.startsWith(`${base}${path.sep}`) || !after.has(target)) continue;
158
+ if (stable(previous.managed?.[name]) !== stable(entry)) declared.set(target, { file, name, entry, receipt });
159
+ }
160
+ }
161
+ for (const [file, bytes] of after) {
162
+ if (path.basename(file) === SIDECAR || /(?:^|[/\\])aiwg\.config$/.test(file)
163
+ || /(?:\.bak\.|\.aiwg-backup-)/.test(path.basename(file))) continue;
164
+ const changed = !before.get(file)?.equals(bytes);
165
+ const declaration = declared.get(file);
166
+ if (opts.onlyDeclared && !declaration) continue;
167
+ if (!changed && !declaration && !opts.writtenFiles?.includes(file)) continue;
168
+ // Existing integrity receipts that disagree with bytes never bless operator edits.
169
+ if (declaration?.entry.hash && declaration.entry.hash !== hash(bytes)) continue;
170
+ let skillRoot = path.dirname(file);
171
+ while (skillRoot !== path.dirname(skillRoot)) {
172
+ const parentReceipt = parse(after.get(path.join(skillRoot, SIDECAR)));
173
+ if (parentReceipt.managed?.['SKILL.md']) break;
174
+ skillRoot = path.dirname(skillRoot);
175
+ }
176
+ const skillReceipt = parse(after.get(path.join(skillRoot, SIDECAR)));
177
+ const projectScoped = projectRoot && path.dirname(file) === projectRoot;
178
+ const dir = projectScoped ? path.join(projectRoot, '.aiwg') : declaration ? path.dirname(declaration.file) : skillReceipt.managed?.['SKILL.md'] ? skillRoot : path.dirname(file);
179
+ const name = declaration?.name || portable(path.relative(projectScoped ? projectRoot : dir, file));
180
+ const existing = manifests.get(path.join(dir, SIDECAR)) || parse(after.get(path.join(dir, SIDECAR)));
181
+ const previous = parse(before.get(path.join(dir, SIDECAR))).managed?.[name];
182
+ const current = existing.managed?.[name] || {};
183
+ const identity = current.sourcePath || `${declaration?.receipt.skillSource}/SKILL.md`;
184
+ const logicalSource = opts.logicalInputPath?.(identity) || identity;
185
+ const sourceOwner = (declaration || current.hash === hash(bytes)) && (current.frameworkSlug || bundleOwner(logicalSource))
186
+ || skillReceipt.managed?.['SKILL.md']?.frameworkSlug;
187
+ const generatedIndex = /^RULES-(?:INDEX|ONDEMAND)\.(?:md|mdc)$/.test(path.basename(file));
188
+ const kind = generatedIndex ? 'rule-index' : current.kind || artifactKind(file);
189
+ const selectedOwner = sourceOwner || (opts.onlyDeclared ? current.owners?.[0] : owner);
190
+ if (!selectedOwner) {
191
+ console.warn(`Ownership not recorded for ${file}: no framework owner resolved.`);
192
+ continue;
193
+ }
194
+ const receipt = manifest(dir);
195
+ if (projectScoped) receipt.scope = 'project';
196
+ const record = mergeArtifactOwnership(previous, { ...current, hash: hash(bytes), owners: current.hash === hash(bytes) ? current.owners : [], kind }, selectedOwner);
197
+ // Structural rule indexes are generated outputs; their assembly scratch
198
+ // directory is not a durable source identity.
199
+ if (generatedIndex) {
200
+ delete record.sourcePath;
201
+ record.kind = 'rule-index';
202
+ }
203
+ // Settings have key/value receipts in the same entry, never a separate store.
204
+ if (/^(?:settings(?:\.local)?|hooks|opencode|config|aiwg\.cordis\.patch)\.(?:json|toml|ya?ml)$/.test(path.basename(file))) {
205
+ record.kind = 'settings';
206
+ record.settingsPreimage = previous?.settingsPreimage || (!previous?.settings ? {
207
+ present: before.has(file), ...(before.has(file) ? { bytes: before.get(file).toString('base64'), hash: hash(before.get(file)) } : {})
208
+ } : undefined);
209
+ const claimUnchanged = opts.claimUnchangedSettings !== false
210
+ && !/(?:agentic\/code|\.aiwg)\/(?:addons|extensions)\//.test((opts.logicalInputPath?.(opts.srcRoot) || opts.srcRoot)?.replaceAll('\\', '/') || '');
211
+ record.settings = settingsRecords(settingsDocument(file, before.get(file)), settingsDocument(file, bytes), previous?.settings, selectedOwner, claimUnchanged);
212
+ const settingsOwners = Object.values(record.settings).flatMap(entry => entry.owners);
213
+ record.owners = [...new Set(settingsOwners.length ? settingsOwners
214
+ : [...(previous?.owners || []), ...(changed ? [selectedOwner] : [])])].sort();
215
+ }
216
+ receipt.managed ||= {};
217
+ receipt.managed[name] = record;
218
+ }
219
+ for (const [file, receipt] of manifests) {
220
+ const text = `${JSON.stringify(receipt, null, 2)}\n`;
221
+ if (after.get(file)?.toString() === text) continue;
222
+ fs.mkdirSync(path.dirname(file), { recursive: true });
223
+ if (receipt.scope === 'project' && opts.writeReceipt) opts.writeReceipt(file, text);
224
+ else fs.writeFileSync(file, text);
225
+ }
226
+ }
@@ -0,0 +1,200 @@
1
+ // Build file removal decisions exclusively from provider ownership sidecars.
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { createHash } from 'node:crypto';
5
+ import { getProviderArtifactPathStrings } from './provider-definitions.js';
6
+ import { deployedSkillRoots } from './deployed-skill-roots.js';
7
+ import { releaseSkillOwnership } from './skill-ownership.mjs';
8
+ import { restoreSettings } from './settings-removal.js';
9
+ const SIDECAR = '.aiwg-manifest.json';
10
+ const CONTEXT_BRIDGES = new Set(['AGENTS.md', 'AIWG.md', 'WORKSPACE.md', 'CLAUDE.md', 'WARP.md', '.hermes.md', '.windsurfrules', 'copilot-instructions.md']);
11
+ const hash = (bytes) => `sha256:${createHash('sha256').update(bytes).digest('hex')}`;
12
+ const inside = (root, file) => file.startsWith(`${root}${path.sep}`);
13
+ function symlinkBetween(root, file) {
14
+ let current = file;
15
+ while (current === root || inside(root, current)) {
16
+ try {
17
+ if (fs.lstatSync(current).isSymbolicLink())
18
+ return true;
19
+ }
20
+ catch (error) {
21
+ if (error.code !== 'ENOENT')
22
+ throw error;
23
+ }
24
+ if (current === root)
25
+ break;
26
+ current = path.dirname(current);
27
+ }
28
+ return false;
29
+ }
30
+ export function planDeploymentRemoval(project, provider, owner, includeProject = true) {
31
+ const paths = Object.values(getProviderArtifactPathStrings(provider) || {}).filter(Boolean);
32
+ const roots = [...new Set([...paths.map(dir => path.isAbsolute(dir) ? dir : path.join(project, dir.split(/[\\/]/)[0])),
33
+ ...deployedSkillRoots(project, provider), path.join(project, `.${provider}`), ...(includeProject ? [path.join(project, '.aiwg/frameworks')] : [])])].map(root => path.resolve(root));
34
+ const files = new Set();
35
+ const decisions = [], writes = [], remaining = [], recorded = [];
36
+ const visit = (file) => {
37
+ let stat;
38
+ try {
39
+ stat = fs.lstatSync(file);
40
+ }
41
+ catch (error) {
42
+ if (error.code === 'ENOENT')
43
+ return;
44
+ throw error;
45
+ }
46
+ if (stat.isDirectory())
47
+ for (const name of fs.readdirSync(file).sort())
48
+ visit(path.join(file, name));
49
+ else
50
+ files.add(file);
51
+ };
52
+ for (const root of roots)
53
+ visit(root);
54
+ const projectReceipt = path.join(project, '.aiwg', SIDECAR);
55
+ if (includeProject && fs.existsSync(projectReceipt))
56
+ files.add(projectReceipt);
57
+ const accounted = new Set();
58
+ let modern = false;
59
+ const receipts = [];
60
+ for (const file of [...files].filter(file => path.basename(file) === SIDECAR).sort()) {
61
+ if (symlinkBetween(roots.find(root => inside(root, file)) || project, file))
62
+ continue;
63
+ try {
64
+ const before = fs.readFileSync(file), receipt = JSON.parse(before.toString());
65
+ if (receipt.managed && typeof receipt.managed === 'object' && !Array.isArray(receipt.managed)) {
66
+ receipts.push({ file, before, receipt });
67
+ if (Object.values(receipt.managed).some(record => Array.isArray(record?.owners)))
68
+ modern = true;
69
+ }
70
+ }
71
+ catch { /* Invalid receipts are reported below, never treated as ownership. */ }
72
+ }
73
+ const claims = new Map();
74
+ for (const item of receipts) {
75
+ const base = item.file === projectReceipt && item.receipt.scope === 'project' ? project : path.dirname(item.file);
76
+ for (const [name, record] of Object.entries(item.receipt.managed)) {
77
+ if (!record || typeof record !== 'object')
78
+ continue;
79
+ const target = path.resolve(base, name);
80
+ claims.set(target, [...(claims.get(target) || []), record]);
81
+ }
82
+ }
83
+ // Legacy skill receipts already contain verifiable hashes and a root owner.
84
+ // Keep their established metadata release semantics; never infer flat artifacts.
85
+ for (const { file, before, receipt } of receipts) {
86
+ const root = path.dirname(file);
87
+ const skillOwner = receipt.managed?.['SKILL.md']?.frameworkSlug;
88
+ if (skillOwner === owner && Object.values(receipt.managed).every(record => !record?.kind && (!record?.owners || record.owners.length === 1 && record.owners[0] === owner))) {
89
+ const legacyPlan = [];
90
+ releaseSkillOwnership(root, { frameworkSlug: owner }, { dryRun: true, plan: legacyPlan });
91
+ for (const decision of legacyPlan) {
92
+ accounted.add(decision.path);
93
+ decisions.push({ ...decision, owned: true, legacy: true });
94
+ if (decision.action === 'remove')
95
+ writes.push({ path: decision.path, before: fs.readFileSync(decision.path), after: null });
96
+ }
97
+ accounted.add(file);
98
+ recorded.push({ ...receipt.managed['SKILL.md'], kind: 'skill' });
99
+ continue;
100
+ }
101
+ const base = file === projectReceipt && receipt.scope === 'project' ? project : root;
102
+ let changed = false;
103
+ for (const [name, record] of Object.entries(receipt.managed)) {
104
+ if (!record || typeof record !== 'object')
105
+ continue;
106
+ const target = path.resolve(base, name);
107
+ const owners = Array.isArray(record.owners) ? record.owners : record.frameworkSlug ? [record.frameworkSlug] : [];
108
+ if (!owners.includes(owner))
109
+ continue;
110
+ accounted.add(target);
111
+ recorded.push(record);
112
+ let action = 'preserve', reason = 'modified or unverifiable managed file';
113
+ if (!inside(base, target) || target === file || !roots.some(root => inside(root, target)) && base !== project)
114
+ reason = 'unsafe receipt path; unverifiable';
115
+ else if (symlinkBetween(roots.find(root => inside(root, target)) || project, target))
116
+ reason = 'symlink preserved';
117
+ else if (record.kind === 'settings' && record.settings && (claims.get(target) || []).length === 1) {
118
+ const restored = restoreSettings(target, record, owner);
119
+ decisions.push(...restored.decisions);
120
+ if (restored.write)
121
+ writes.push(restored.write);
122
+ if (restored.retained)
123
+ remaining.push(record);
124
+ if (!record.owners?.length)
125
+ delete receipt.managed[name];
126
+ changed = true;
127
+ continue;
128
+ }
129
+ else if (record.kind === 'settings')
130
+ reason = 'settings contributions missing or conflicting; unverifiable';
131
+ else if (CONTEXT_BRIDGES.has(path.basename(target)))
132
+ reason = 'context bridge preserved; pre-deploy operator content unverifiable';
133
+ else if ((claims.get(target) || []).some(claim => claim.hash !== record.hash))
134
+ reason = 'conflicting receipt digests; unverifiable';
135
+ else if ((claims.get(target) || []).some(claim => (claim.owners || (claim.frameworkSlug ? [claim.frameworkSlug] : [])).some(item => item !== owner))) {
136
+ action = 'release';
137
+ reason = 'shared with another framework; release this owner only';
138
+ }
139
+ else {
140
+ try {
141
+ if (fs.lstatSync(target).isFile() && /^sha256:[a-f0-9]{64}$/.test(record.hash) && hash(fs.readFileSync(target)) === record.hash) {
142
+ action = 'remove';
143
+ reason = 'unchanged managed file';
144
+ }
145
+ }
146
+ catch (error) {
147
+ if (error.code === 'ENOENT') {
148
+ action = 'release';
149
+ reason = 'recorded file already absent';
150
+ }
151
+ else
152
+ reason = 'unreadable path; unverifiable';
153
+ }
154
+ }
155
+ decisions.push({ path: target, action, reason, kind: record.kind, owned: true });
156
+ if (action === 'preserve') {
157
+ remaining.push(record);
158
+ continue;
159
+ }
160
+ changed = true;
161
+ if (action === 'remove')
162
+ writes.push({ path: target, before: fs.readFileSync(target), after: null });
163
+ const otherOwners = owners.filter(item => item !== owner);
164
+ if (otherOwners.length) {
165
+ record.owners = otherOwners;
166
+ if (record.frameworkSlug === owner)
167
+ record.frameworkSlug = otherOwners[0];
168
+ }
169
+ else
170
+ delete receipt.managed[name];
171
+ }
172
+ if (changed) {
173
+ const empty = Object.keys(receipt.managed).length === 0;
174
+ writes.push({ path: file, before, after: empty ? null : Buffer.from(`${JSON.stringify(receipt, null, 2)}\n`) });
175
+ if (empty)
176
+ decisions.push({ path: file, action: 'remove', reason: 'ownership metadata released' });
177
+ }
178
+ accounted.add(file);
179
+ }
180
+ for (const file of [...files].sort()) {
181
+ if (accounted.has(file))
182
+ continue;
183
+ // Foreign receipts are ownership evidence, but never this framework's files.
184
+ const skill = receipts.find(item => inside(path.dirname(item.file), file) && item.receipt.managed?.['SKILL.md']);
185
+ const ownSkill = skill?.receipt.managed?.['SKILL.md']?.frameworkSlug === owner;
186
+ const foreign = skill && !ownSkill;
187
+ const foreignFile = (claims.get(file) || []).some(record => (record.owners || (record.frameworkSlug ? [record.frameworkSlug] : [])).length);
188
+ decisions.push({ path: file, action: 'preserve', reason: foreign ? 'foreign or unverifiable ownership receipt'
189
+ : foreignFile ? 'foreign ownership receipt; owned by another bundle' : ownSkill ? 'unrecorded operator file' : modern ? 'unrecorded operator file; unverifiable ownership' : 'unverifiable: no ownership receipt' });
190
+ }
191
+ const unique = new Map();
192
+ for (const decision of decisions) {
193
+ const key = `${decision.path}#${decision.pointer ?? ''}`;
194
+ const previous = unique.get(key);
195
+ if (!previous || decision.action === 'preserve' || previous.action === 'remove')
196
+ unique.set(key, decision);
197
+ }
198
+ return { decisions: [...unique.values()], writes, remaining, recorded, legacy: !modern };
199
+ }
200
+ //# sourceMappingURL=deployment-removal.js.map
@@ -0,0 +1,162 @@
1
+ const VERIFIED_ON = '2026-07-21';
2
+ export const CONTEXT_CONTRACTS = {
3
+ antigravity: {
4
+ startupFiles: ['AGENTS.md', 'GEMINI.md'],
5
+ precedence: ['provider/system', 'project AGENTS.md or GEMINI.md', 'nested project context when selected by the CLI'],
6
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
7
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null, nestedContext: true, support: 'supported',
8
+ verification: {
9
+ method: 'official Antigravity CLI documentation and sanitized 1.1.26 help evidence',
10
+ source: 'https://antigravity.google/docs/cli/overview/',
11
+ lastVerified: '2026-09-04',
12
+ },
13
+ },
14
+ claude: {
15
+ startupFiles: ['CLAUDE.md', '.claude/CLAUDE.md'], precedence: ['provider/system', 'nested CLAUDE.md', 'root CLAUDE.md'],
16
+ loadMode: 'native-include', includeSyntax: '@WORKSPACE.md\n@AIWG.md', configRegistration: null,
17
+ bootstrapTargets: ['CLAUDE.md'], maxContextBytes: null, recommendedMaxLines: 200, nestedContext: true, support: 'supported',
18
+ verification: { method: 'official documentation: CLAUDE.md imports and InstructionsLoaded hook', source: 'https://code.claude.com/docs/en/memory', lastVerified: VERIFIED_ON },
19
+ },
20
+ codex: {
21
+ startupFiles: ['AGENTS.override.md', 'AGENTS.md'], precedence: ['provider/system', 'root-to-cwd AGENTS chain', 'nearest file'],
22
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
23
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: 32 * 1024, recommendedMaxLines: null, nestedContext: true, support: 'supported',
24
+ verification: { method: 'official AGENTS.md discovery chain; no Markdown include claimed', source: 'https://developers.openai.com/codex/guides/agents-md', lastVerified: VERIFIED_ON },
25
+ },
26
+ copilot: {
27
+ startupFiles: ['.github/copilot-instructions.md', 'AGENTS.md', 'CLAUDE.md'], precedence: ['personal', 'repository', 'organization; CLI combines applicable files'],
28
+ loadMode: 'native-include', includeSyntax: '@WORKSPACE.md\n@AIWG.md', configRegistration: null,
29
+ bootstrapTargets: ['.github/copilot-instructions.md', 'AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null, nestedContext: true, support: 'supported',
30
+ verification: { method: 'official Copilot CLI custom-instruction imports', source: 'https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/add-custom-instructions', lastVerified: VERIFIED_ON },
31
+ },
32
+ cursor: {
33
+ startupFiles: ['AGENTS.md', 'CLAUDE.md', '.cursor/rules/*.mdc'], precedence: ['provider/system', 'project rules', 'root AGENTS.md'],
34
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
35
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: null, recommendedMaxLines: 500, nestedContext: false, support: 'supported',
36
+ verification: { method: 'official Cursor rules and CLI documentation', source: 'https://docs.cursor.com/context/rules-for-ai', lastVerified: VERIFIED_ON },
37
+ },
38
+ 'deepseek-harness': {
39
+ startupFiles: ['AGENTS.md', 'CLAUDE.md'],
40
+ precedence: ['provider/system', 'project AGENTS.md or CLAUDE.md', 'nested project context'],
41
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
42
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: 65536, recommendedMaxLines: null, nestedContext: true, support: 'supported',
43
+ verification: {
44
+ method: 'DeepSeek Harness instruction and filesystem-skill source review',
45
+ source: 'https://github.com/deepseek-ai/deepseek-harness',
46
+ lastVerified: '2026-09-05',
47
+ },
48
+ },
49
+ factory: {
50
+ startupFiles: ['AGENTS.md', '~/.factory/AGENTS.md'], precedence: ['provider/system', 'nearest AGENTS.md', 'root AGENTS.md', 'personal override'],
51
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
52
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: null, recommendedMaxLines: 150, nestedContext: true, support: 'supported',
53
+ verification: { method: 'official Factory AGENTS.md discovery hierarchy', source: 'https://docs.factory.ai/cli/configuration/agents-md', lastVerified: VERIFIED_ON },
54
+ },
55
+ grokbot: {
56
+ startupFiles: ['AGENTS.md'],
57
+ precedence: ['provider/system', 'project AGENTS.md when the host exposes it', 'explicit aiwg discover/show'],
58
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
59
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null, nestedContext: false, support: 'degraded',
60
+ verification: {
61
+ method: 'AIWG discover-first adapter contract; native Grok Bot startup/include path not yet verified — explicit-read guidance only',
62
+ source: 'docs/architecture/adr-grokbot-provider-target.md',
63
+ lastVerified: '2026-09-15',
64
+ },
65
+ },
66
+ 'grok-build': {
67
+ // config.toml is configuration (MCP/plugins/permissions), not a startup/context file.
68
+ // Hierarchical instructions: AGENTS.md + .grok/rules/*.md, root-to-cwd, deeper wins.
69
+ startupFiles: ['AGENTS.md', '.grok/rules/*.md'],
70
+ precedence: [
71
+ 'provider/system',
72
+ 'global ~/.grok instruction sources',
73
+ 'root-to-cwd AGENTS.md and .grok/rules/*.md (deeper files win on conflicts)',
74
+ '$GROK_HOME for user skills and user config',
75
+ ],
76
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
77
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null, nestedContext: true, support: 'supported',
78
+ verification: {
79
+ method: 'xAI project-rules docs (AGENTS.md + .grok/rules hierarchical discovery); grok inspect when installed',
80
+ source: 'https://docs.x.ai/build/features/project-rules',
81
+ lastVerified: '2026-09-20',
82
+ },
83
+ },
84
+ hermes: {
85
+ startupFiles: ['.hermes.md', 'AGENTS.md'], precedence: ['provider/system', '.hermes.md', 'AGENTS.md'],
86
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
87
+ bootstrapTargets: ['.hermes.md', 'AGENTS.md'], maxContextBytes: null, recommendedMaxLines: 30, nestedContext: false, support: 'degraded',
88
+ verification: { method: 'AIWG Hermes adapter contract; on-demand artifact-read required', source: 'agentic/code/providers/capability-matrix.yaml', lastVerified: VERIFIED_ON },
89
+ },
90
+ // #225: Muse Code prefers AGENTS.md over CLAUDE.md at each directory level;
91
+ // project AGENTS.md loads only after the workspace is explicitly trusted
92
+ // (first-run trust prompt). AIWG deploys a discover-first AGENTS.md bridge.
93
+ muse: {
94
+ startupFiles: ['AGENTS.md'],
95
+ precedence: ['provider/system', 'project AGENTS.md once the workspace is trusted', 'explicit aiwg discover/show'],
96
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
97
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null, nestedContext: false, support: 'supported',
98
+ verification: {
99
+ method: 'ADR-locked surfaces; discover-first AGENTS.md bridge per official Muse Code docs (trust-gated load)',
100
+ source: 'docs/architecture/adr-muse-provider-target.md',
101
+ lastVerified: '2026-09-24',
102
+ },
103
+ },
104
+ opencode: {
105
+ startupFiles: ['AGENTS.md', 'CLAUDE.md', 'opencode.json#instructions'], precedence: ['provider/system', 'nearest AGENTS.md', 'CLAUDE compatibility', 'registered instructions'],
106
+ loadMode: 'config-registration', includeSyntax: null, configRegistration: { file: 'opencode.json', key: 'instructions' },
107
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null, nestedContext: true, support: 'supported',
108
+ verification: { method: 'official OpenCode rules documentation and instructions array', source: 'https://opencode.ai/docs/rules/', lastVerified: VERIFIED_ON },
109
+ },
110
+ openclaw: {
111
+ startupFiles: ['~/.openclaw/config.yaml'], precedence: ['provider/system', 'home configuration'],
112
+ loadMode: 'unsupported', includeSyntax: null, configRegistration: null,
113
+ bootstrapTargets: [], maxContextBytes: null, recommendedMaxLines: null, nestedContext: false, support: 'degraded',
114
+ verification: { method: 'AIWG home-scope adapter contract; no verified project startup file', source: 'agentic/code/providers/capability-matrix.yaml', lastVerified: VERIFIED_ON },
115
+ },
116
+ openhuman: {
117
+ startupFiles: ['AGENTS.md'], precedence: ['provider/system', 'project AGENTS.md when host exposes it'],
118
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
119
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null, nestedContext: false, support: 'degraded',
120
+ verification: { method: 'AIWG mixed-scope adapter contract; host loading remains capability-dependent', source: 'agentic/code/providers/capability-matrix.yaml', lastVerified: VERIFIED_ON },
121
+ },
122
+ omp: {
123
+ startupFiles: ['.omp/AGENTS.md', 'AGENTS.md'],
124
+ precedence: ['provider/system', 'native nearest nonempty .omp', 'compatibility context ordered by depth; exact paragraph deduplication'],
125
+ loadMode: 'native-include', includeSyntax: '@<relative-path>', configRegistration: null,
126
+ bootstrapTargets: ['.omp/AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null, nestedContext: true, support: 'supported',
127
+ verification: {
128
+ method: 'OMP 18.1.10 source and live context import smoke',
129
+ source: 'https://github.com/can1357/oh-my-pi/blob/5964a0f7649275bcde818f20073193fd032451f2/packages/coding-agent/src/system-prompt.ts#L451',
130
+ lastVerified: '2026-09-04',
131
+ },
132
+ },
133
+ pi: {
134
+ startupFiles: ['AGENTS.override.md', 'AGENTS.md', 'CLAUDE.md'],
135
+ precedence: ['provider/system', 'root-to-cwd context chain', 'AGENTS.override.md supersedes same-directory AGENTS.md and CLAUDE.md'],
136
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
137
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null, nestedContext: true, support: 'supported',
138
+ verification: {
139
+ method: 'Pi coding-agent resource loader and official README context-file documentation',
140
+ source: 'https://github.com/earendil-works/pi/blob/79680533c6b898894f2d2421c7f640b212d3dfdd/packages/coding-agent/README.md#context-files',
141
+ lastVerified: '2026-09-03',
142
+ },
143
+ },
144
+ warp: {
145
+ startupFiles: ['WARP.md', 'AGENTS.md'], precedence: ['provider/system', 'subdirectory rule', 'root rule', 'global rule'],
146
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
147
+ bootstrapTargets: ['WARP.md', 'AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null, nestedContext: true, support: 'supported',
148
+ verification: { method: 'official Warp project rules documentation', source: 'https://docs.warp.dev/agent-platform/capabilities/rules/', lastVerified: VERIFIED_ON },
149
+ },
150
+ windsurf: {
151
+ startupFiles: ['AGENTS.md', '.windsurf/rules/*.md', '.devin/rules/*.md'], precedence: ['provider/system', 'Devin rules', 'Windsurf rules', 'AGENTS.md'],
152
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
153
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null, nestedContext: true, support: 'degraded',
154
+ verification: { method: 'AIWG Windsurf/Devin topology contract; provider-native rules retained', source: 'src/providers/provider-definitions.ts', lastVerified: VERIFIED_ON },
155
+ },
156
+ generic: {
157
+ startupFiles: [], precedence: ['host policy'], loadMode: 'unsupported', includeSyntax: null, configRegistration: null,
158
+ bootstrapTargets: [], maxContextBytes: null, recommendedMaxLines: null, nestedContext: false, support: 'unsupported',
159
+ verification: { method: 'No provider selected; no startup-file claim', source: 'src/providers/provider-definitions.ts', lastVerified: VERIFIED_ON },
160
+ },
161
+ };
162
+ //# sourceMappingURL=provider-context-contracts.js.map