@aiwg/cli 2026.10.16 → 2026.10.19

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 (155) hide show
  1. package/agentic/code/providers/capability-matrix.yaml +51 -0
  2. package/agentic/code/providers/flue/README.md +62 -0
  3. package/agentic/code/providers/flue/templates/aiwg/tools.ts +120 -0
  4. package/agentic/code/providers/model-capabilities.v1.json +23 -0
  5. package/agentic/code/providers/model-catalog.v1.json +9 -0
  6. package/dist/src/artifacts/corpus-tools/resolve.js +28 -6
  7. package/dist/src/artifacts/query-engine-corpus.js +217 -0
  8. package/dist/src/artifacts/query-engine-discover-output.js +229 -0
  9. package/dist/src/artifacts/query-engine-discover.js +285 -0
  10. package/dist/src/artifacts/query-engine-entries.js +188 -0
  11. package/dist/src/artifacts/query-engine-index.js +249 -0
  12. package/dist/src/artifacts/query-engine-matching.js +143 -0
  13. package/dist/src/artifacts/query-engine-options.js +2 -0
  14. package/dist/src/artifacts/query-engine-rules.js +202 -0
  15. package/dist/src/artifacts/query-engine-scoring.js +436 -0
  16. package/dist/src/artifacts/query-engine-show-card.js +194 -0
  17. package/dist/src/artifacts/query-engine-show-load.js +211 -0
  18. package/dist/src/artifacts/query-engine-show.js +300 -0
  19. package/dist/src/artifacts/query-engine.js +7 -2576
  20. package/dist/src/cli/handlers/help.js +1 -1
  21. package/dist/src/cli/handlers/init.js +1 -0
  22. package/dist/src/cli/handlers/mc-agents.js +111 -0
  23. package/dist/src/cli/handlers/mc-args.js +54 -0
  24. package/dist/src/cli/handlers/mc-control.js +227 -0
  25. package/dist/src/cli/handlers/mc-dispatch.js +203 -0
  26. package/dist/src/cli/handlers/mc-help.js +171 -0
  27. package/dist/src/cli/handlers/mc-run.js +343 -0
  28. package/dist/src/cli/handlers/mc-session.js +138 -0
  29. package/dist/src/cli/handlers/mc-status.js +258 -0
  30. package/dist/src/cli/handlers/mc-summary.js +43 -0
  31. package/dist/src/cli/handlers/mc-types.js +3 -0
  32. package/dist/src/cli/handlers/mc-worker.js +205 -0
  33. package/dist/src/cli/handlers/mc.js +12 -1665
  34. package/dist/src/cli/handlers/models-refusal.js +13 -0
  35. package/dist/src/cli/handlers/models.js +2 -1
  36. package/dist/src/cli/handlers/remove-bundled.js +133 -0
  37. package/dist/src/cli/handlers/remove-options.js +31 -0
  38. package/dist/src/cli/handlers/remove-user.js +174 -0
  39. package/dist/src/cli/handlers/remove.js +201 -0
  40. package/dist/src/cli/handlers/subcommands-bundles.js +257 -0
  41. package/dist/src/cli/handlers/subcommands-discovery.js +165 -0
  42. package/dist/src/cli/handlers/subcommands-list-format.js +129 -0
  43. package/dist/src/cli/handlers/subcommands-list.js +250 -0
  44. package/dist/src/cli/handlers/subcommands-plugins.js +213 -0
  45. package/dist/src/cli/handlers/subcommands-quickref.js +58 -0
  46. package/dist/src/cli/handlers/subcommands-rlm.js +113 -0
  47. package/dist/src/cli/handlers/subcommands-services.js +66 -0
  48. package/dist/src/cli/handlers/subcommands-storage.js +259 -0
  49. package/dist/src/cli/handlers/subcommands.js +18 -1984
  50. package/dist/src/cli/handlers/use.js +11 -5
  51. package/dist/src/cli/scope-resolver.js +1 -142
  52. package/dist/src/cli/services/deployment-verification.js +3 -0
  53. package/dist/src/cli/user-scope-mirror.js +173 -0
  54. package/dist/src/config/dispatch-host-thresholds.js +2 -0
  55. package/dist/src/config/dispatch-thresholds-runtime.mjs +4 -0
  56. package/dist/src/config/host-resource-report.d.mts +5 -0
  57. package/dist/src/config/host-resource-report.mjs +36 -6
  58. package/dist/src/config/host-resource-runtime.d.mts +3 -0
  59. package/dist/src/config/host-resource-runtime.mjs +9 -6
  60. package/dist/src/decision/ensemble-study/artifacts.js +7 -0
  61. package/dist/src/decision/ensemble-study/gate-policy.js +58 -0
  62. package/dist/src/decision/ensemble-study/gates.js +78 -0
  63. package/dist/src/decision/ensemble-study/protocol.js +18 -21
  64. package/dist/src/decision/ensemble-study/score.js +3 -2
  65. package/dist/src/decision/ensemble-study/statistics.js +7 -26
  66. package/dist/src/decision/sensitivity/comparative-gates.js +135 -0
  67. package/dist/src/decision/sensitivity/comparative.js +18 -41
  68. package/dist/src/extensions/claude-hooks-installer.js +18 -0
  69. package/dist/src/gates/evaluate.js +2 -358
  70. package/dist/src/gates/observations.js +363 -0
  71. package/dist/src/gates/pack-composition.js +270 -0
  72. package/dist/src/gates/pack-tightening.js +197 -0
  73. package/dist/src/gates/pack-validation.js +262 -0
  74. package/dist/src/gates/registry-error.js +5 -0
  75. package/dist/src/gates/registry.js +13 -685
  76. package/dist/src/mcp/json-document.mjs +29 -0
  77. package/dist/src/mcp/muse-native-config.mjs +1 -28
  78. package/dist/src/memory/provider-memory-adapter.js +1 -0
  79. package/dist/src/mission-protocol/worker-review-gate.js +7 -0
  80. package/dist/src/models/model-capabilities.v1.json +23 -0
  81. package/dist/src/models/model-catalog.v1.json +9 -0
  82. package/dist/src/models/policy-resources.js +1 -1
  83. package/dist/src/models/worker-plan.js +5 -5
  84. package/dist/src/plugin/command-ownership.js +34 -0
  85. package/dist/src/plugin/skill-command-frontmatter.js +197 -0
  86. package/dist/src/plugin/skill-command-translator.js +6 -232
  87. package/dist/src/providers/capability-matrix.yaml +51 -0
  88. package/dist/src/providers/context-output-ownership.js +26 -0
  89. package/dist/src/providers/deployment-ownership.d.mts +20 -0
  90. package/dist/src/providers/deployment-ownership.mjs +236 -0
  91. package/dist/src/providers/deployment-removal.js +222 -0
  92. package/dist/src/providers/provider-context-contracts.js +8 -0
  93. package/dist/src/providers/provider-definition-schema.js +1 -0
  94. package/dist/src/providers/provider-definitions.js +1 -0
  95. package/dist/src/providers/provider-seeds-3.js +18 -0
  96. package/dist/src/providers/removal-transaction.js +86 -0
  97. package/dist/src/providers/settings-document.d.mts +3 -0
  98. package/dist/src/providers/settings-document.mjs +47 -0
  99. package/dist/src/providers/settings-removal.js +190 -0
  100. package/dist/src/providers/skill-ownership.d.mts +20 -2
  101. package/dist/src/providers/skill-ownership.mjs +12 -4
  102. package/dist/src/providers/transformation-receipt-integration.js +15 -271
  103. package/dist/src/providers/transformation-receipt-outputs.js +99 -0
  104. package/dist/src/providers/transformation-receipt-source.js +194 -0
  105. package/dist/src/research/identity.js +8 -2
  106. package/dist/src/research/reference-match.js +66 -8
  107. package/dist/src/rules/activation.mjs +15 -6
  108. package/dist/src/rules/core-startup.mjs +2 -2
  109. package/dist/src/serve/mission-conductor.js +4 -0
  110. package/dist/src/serve/mission-summary.js +56 -0
  111. package/dist/src/skills/deployment-ownership.js +2 -2
  112. package/dist/src/skills/deployment-policy.js +9 -0
  113. package/dist/src/smiths/context-pipeline/aiwg-md.js +23 -0
  114. package/dist/src/smiths/context-pipeline/context-file-safety.js +3 -0
  115. package/dist/src/smiths/context-pipeline/flue-context.js +25 -0
  116. package/dist/src/smiths/context-pipeline/generator.js +7 -2
  117. package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +9 -7
  118. package/dist/src/smiths/hook-bridge/index.js +9 -0
  119. package/package.json +5 -1
  120. package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
  121. package/tools/agents/deploy-agents.mjs +21 -680
  122. package/tools/agents/deploy-command-mirrors.mjs +229 -0
  123. package/tools/agents/deploy-options.mjs +267 -0
  124. package/tools/agents/deploy-support.mjs +165 -0
  125. package/tools/agents/providers/base-addon-discovery.mjs +139 -0
  126. package/tools/agents/providers/base-behaviors.mjs +168 -0
  127. package/tools/agents/providers/base-context.mjs +205 -0
  128. package/tools/agents/providers/base-contract.mjs +116 -0
  129. package/tools/agents/providers/base-files.mjs +252 -0
  130. package/tools/agents/providers/base-flat-artifacts.mjs +233 -0
  131. package/tools/agents/providers/base-framework-discovery.mjs +309 -0
  132. package/tools/agents/providers/base-frontmatter.mjs +196 -0
  133. package/tools/agents/providers/base-inventory.mjs +269 -0
  134. package/tools/agents/providers/base-kernel-skills.mjs +354 -0
  135. package/tools/agents/providers/base-migrations.mjs +258 -0
  136. package/tools/agents/providers/base-models-platforms.mjs +273 -0
  137. package/tools/agents/providers/base-rule-index.mjs +450 -0
  138. package/tools/agents/providers/base-runtime.mjs +60 -0
  139. package/tools/agents/providers/base-skill-copy.mjs +273 -0
  140. package/tools/agents/providers/base.mjs +16 -3364
  141. package/tools/agents/providers/claude-post-deploy.mjs +10 -2
  142. package/tools/agents/providers/flue-project.mjs +79 -0
  143. package/tools/agents/providers/flue-specialists.mjs +64 -0
  144. package/tools/agents/providers/flue.mjs +50 -0
  145. package/tools/agents/providers/hermes-startup.mjs +0 -5
  146. package/tools/agents/providers/muse.mjs +7 -2
  147. package/tools/agents/providers/rule-delivery-surface.mjs +33 -5
  148. package/tools/agents/providers/rule-deployment-commit.mjs +19 -15
  149. package/tools/agents/providers/rule-deployment-prepare.mjs +13 -3
  150. package/tools/agents/providers/rule-projection.mjs +3 -0
  151. package/tools/agents/providers/rule-startup.mjs +3 -3
  152. package/tools/agents/use-rule-selection.mjs +17 -0
  153. package/tools/ralph-external/lib/worker-invocation-processes.mjs +4 -2
  154. package/tools/ralph-external/lib/worker-termination.mjs +15 -8
  155. package/vscode-extension/schemas/aiwg.config.v1.json +2 -4
@@ -934,6 +934,57 @@ providers:
934
934
  deploy_target: project
935
935
  aggregated_output: false
936
936
 
937
+ flue:
938
+ display_name: Flue (experimental)
939
+ status: experimental
940
+ route_feasibility:
941
+ scope: out
942
+ identity: unavailable
943
+ evidence: R
944
+ channel: "none - Flue 2.3.0 app target; no worker dispatch (#3120 D6)"
945
+ coverage:
946
+ profile_issue: null
947
+ source_date: "2026-10-30"
948
+ live_qualified: false
949
+ exclusion_gap: "Flue run accepts prompts in argv and lacks worker model/effort flags; app deployment only."
950
+ recheck: "Rechecked 2026-10-30 against installed Flue 2.3.0 source; #3120 D6 excludes worker dispatch."
951
+ sources:
952
+ - "tools/agents/providers/flue.mjs"
953
+ - "docs/providers/flue.md"
954
+ - "https://flueframework.com/docs/"
955
+ fanout: unknown
956
+ probe_budget: { status: proposed, calls: 0, tokens: 0 }
957
+ daemon_tier: unsupported
958
+ daemon_pty_adapter: false
959
+ artifact_paths:
960
+ agents: ""
961
+ commands: ""
962
+ skills: .agents/skills/
963
+ rules: AGENTS.md
964
+ behaviors: null
965
+ native_features:
966
+ cron: false
967
+ agent_teams: false
968
+ tasks: false
969
+ mcp: false
970
+ behaviors: false
971
+ mission_control: false
972
+ daemon: false
973
+ emulation:
974
+ cron: null
975
+ agent_teams: null
976
+ tasks: null
977
+ mcp: null
978
+ behaviors: null
979
+ mission_control: null
980
+ daemon: null
981
+ hook_wiring:
982
+ at_link_support: false
983
+ fallback: full-inject
984
+ context_file: AGENTS.md
985
+ deploy_target: project
986
+ aggregated_output: false
987
+
937
988
  pi:
938
989
  display_name: Pi Coding Agent
939
990
  route_feasibility:
@@ -0,0 +1,26 @@
1
+ // Refresh recorded context digests through the same rollback-safe writer.
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ export function refreshRecordedContextOutput(file, previousHash, currentHash, write) {
5
+ if (!previousHash || previousHash === currentHash || path.basename(file) === '.aiwg-manifest.json')
6
+ return;
7
+ const sidecar = path.join(path.dirname(file), '.aiwg', '.aiwg-manifest.json');
8
+ let receipt;
9
+ try {
10
+ if (!fs.lstatSync(path.dirname(sidecar)).isDirectory() || fs.lstatSync(path.dirname(sidecar)).isSymbolicLink()
11
+ || !fs.lstatSync(sidecar).isFile() || fs.lstatSync(sidecar).isSymbolicLink())
12
+ return;
13
+ receipt = JSON.parse(fs.readFileSync(sidecar, 'utf8'));
14
+ }
15
+ catch (error) {
16
+ if (['ENOENT', 'ENOTDIR'].includes(error.code || '') || error instanceof SyntaxError)
17
+ return;
18
+ throw error;
19
+ }
20
+ const entry = receipt.scope === 'project' && receipt.managed?.[path.basename(file)];
21
+ if (!entry?.owners?.length || entry.hash !== `sha256:${previousHash}`)
22
+ return;
23
+ entry.hash = `sha256:${currentHash}`;
24
+ write(sidecar, `${JSON.stringify(receipt, null, 2)}\n`);
25
+ }
26
+ //# sourceMappingURL=context-output-ownership.js.map
@@ -0,0 +1,20 @@
1
+ import type { PathLike } from 'node:fs';
2
+ export interface DeploymentOwnershipOptions {
3
+ provider?: string;
4
+ dryRun?: boolean;
5
+ claimUnchangedSettings?: boolean;
6
+ onlyDeclared?: boolean;
7
+ srcRoot?: string;
8
+ target?: string;
9
+ writeReceipt?: (file: string, content: string) => void;
10
+ mode?: string;
11
+ frameworkSlug?: string;
12
+ writtenFiles?: string[];
13
+ logicalInputPath?: (file: string) => string;
14
+ }
15
+ export function deploymentOutputRoots(provider: { name: string; paths?: Record<string, string>; kernelSkillsPath?: string; deploymentFiles?: (target: string) => string[] }, target: string): string[];
16
+ export function captureDeploymentOutputs(roots: PathLike[]): Map<string, Buffer>;
17
+ export function recordDeploymentOutputs(before: Map<string, Buffer>, roots: PathLike[], opts?: DeploymentOwnershipOptions): void;
18
+ export function refreshSettingsDigests(record: { settings?: Record<string, unknown> }): void;
19
+
20
+ export function deploymentOwner(opts: DeploymentOwnershipOptions): string | undefined;
@@ -0,0 +1,236 @@
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
+ ...(provider.deploymentFiles?.(target) || []).map(name => path.join(target, name)),
30
+ ...['AGENTS.md', 'AIWG.md', 'WORKSPACE.md', 'CLAUDE.md', 'WARP.md', '.hermes.md', 'opencode.json',
31
+ '.windsurfrules', 'models.json', '.aiwg/frameworks', '.aiwg/.aiwg-manifest.json'].map(name => path.join(target, name))])];
32
+ }
33
+
34
+ /** Capture regular output files before this invocation; never follow symlinks. */
35
+ export function captureDeploymentOutputs(roots) {
36
+ const files = new Map();
37
+ const visit = file => {
38
+ let stat;
39
+ try { stat = fs.lstatSync(file); } catch (error) { if (error.code === 'ENOENT') return; throw error; }
40
+ if (stat.isDirectory()) for (const name of fs.readdirSync(file)) visit(path.join(file, name));
41
+ else if (stat.isFile()) files.set(path.resolve(file), fs.readFileSync(file));
42
+ };
43
+ for (const root of roots) visit(root);
44
+ // A root-level file's sidecar is itself outside that file's snapshot root.
45
+ for (const file of [...files.keys()]) {
46
+ const receipt = path.join(path.dirname(file), SIDECAR);
47
+ if (!files.has(receipt) && fs.existsSync(receipt) && fs.lstatSync(receipt).isFile()) files.set(receipt, fs.readFileSync(receipt));
48
+ }
49
+ return files;
50
+ }
51
+
52
+ function settingsDocument(file, bytes) {
53
+ if (!bytes) return {};
54
+ try {
55
+ if (file.endsWith('.toml')) return getStaticTOMLValue(parseTOML(bytes.toString()));
56
+ if (/\.ya?ml$/.test(file)) return parseYaml(bytes.toString()) ?? {};
57
+ return parseJson(bytes.toString());
58
+ } catch { return null; }
59
+ }
60
+
61
+ /** Recompute value digests after staged logical-path normalization. */
62
+ export function refreshSettingsDigests(record) {
63
+ for (const entry of Object.values(record.settings || {})) {
64
+ entry.hash = hash(stable(entry.value));
65
+ for (const contribution of entry.contributions || []) contribution.hash = hash(stable(contribution.value));
66
+ }
67
+ }
68
+
69
+ function leaves(value, pointer = '', out = {}) {
70
+ if (value && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length) {
71
+ for (const [key, child] of Object.entries(value)) leaves(child, `${pointer}/${key.replaceAll('~', '~0').replaceAll('/', '~1')}`, out);
72
+ } else out[pointer] = value;
73
+ return out;
74
+ }
75
+
76
+ /** Settings arrays retain individual contributions so operator entries aren't claimed. */
77
+ function settingsRecords(previous, current, prior, owner, claimUnchanged) {
78
+ const records = { ...prior };
79
+ if (current === null) return records;
80
+ const before = previous === null ? {} : leaves(previous), after = leaves(current);
81
+ for (const [pointer, value] of Object.entries(after)) {
82
+ const old = records[pointer];
83
+ if (stable(before[pointer]) === stable(value)) {
84
+ if (claimUnchanged && old?.hash === hash(stable(value))) {
85
+ records[pointer] = { ...old, owners: [...new Set([...(old.owners || []), owner])].sort(),
86
+ ...(old.contributions ? { contributions: old.contributions.map(entry => ({ ...entry,
87
+ owners: [...new Set([...entry.owners, ...(Array.isArray(value) || entry.hash === old.hash && !old.contributions.some(item => item.owners.includes(owner)) ? [owner] : [])])].sort() })) } : {}) };
88
+ }
89
+ continue;
90
+ }
91
+ const digest = hash(stable(value));
92
+ const verified = Object.hasOwn(before, pointer) && old?.hash === hash(stable(before[pointer]));
93
+ const preimage = verified ? old.previous
94
+ : previous === null ? { unverifiable: true } : { present: Object.hasOwn(before, pointer), ...(Object.hasOwn(before, pointer) ? { value: before[pointer] } : {}) };
95
+ const record = { hash: digest, value, previous: preimage, owners: [...new Set([...(verified ? old.owners || [] : []), owner])].sort() };
96
+ if (!Array.isArray(value) && verified) {
97
+ const contributions = old.contributions || [{ hash: old.hash, value: old.value, owners: old.owners }];
98
+ record.contributions = [...contributions.flatMap(entry => {
99
+ const owners = entry.owners.filter(candidate => candidate !== owner);
100
+ return owners.length ? [{ ...entry, owners }] : [];
101
+ }), { hash: digest, value, owners: [owner] }];
102
+ }
103
+ if (Array.isArray(value)) {
104
+ const previousValues = Array.isArray(before[pointer]) ? before[pointer] : [];
105
+ record.contributions = value.flatMap(item => {
106
+ const itemHash = hash(stable(item));
107
+ const existing = old?.contributions?.find(entry => entry.hash === itemHash);
108
+ if (existing) return [existing];
109
+ return previousValues.some(entry => stable(entry) === stable(item)) ? [] : [{ hash: itemHash, value: item, owners: [owner] }];
110
+ });
111
+ }
112
+ records[pointer] = record;
113
+ }
114
+ return records;
115
+ }
116
+
117
+ function artifactKind(file) {
118
+ if (/(?:^|[/\\])hooks?[/\\]/.test(file)) return 'hook';
119
+ if (/(?:^|[/\\])(?:skills|skill)[/\\]/.test(file)) return 'skill';
120
+ if (/(?:^|[/\\])(?:agents|droids)[/\\]/.test(file)) return 'agent';
121
+ if (/(?:^|[/\\])(?:commands|prompts|workflows)[/\\]/.test(file)) return 'command';
122
+ if (/(?:^|[/\\])(?:rules|rule|copilot-rules)[/\\]/.test(file)) return 'rule';
123
+ return 'generated';
124
+ }
125
+
126
+ /** Record only writes evidenced by this invocation or newly emitted file receipts. */
127
+ export function recordDeploymentOutputs(before, roots, opts = {}) {
128
+ if (opts.dryRun) return;
129
+ const after = captureDeploymentOutputs(roots);
130
+ const owner = deploymentOwner(opts);
131
+ const manifests = new Map();
132
+ const manifest = dir => {
133
+ const file = path.join(dir, SIDECAR);
134
+ if (!manifests.has(file)) manifests.set(file, parse(after.get(file)));
135
+ return manifests.get(file);
136
+ };
137
+ const projectRoot = opts.target && path.resolve(opts.target);
138
+ const receiptRoot = (file, receipt) => projectRoot && file === path.join(projectRoot, '.aiwg', SIDECAR) && receipt.scope === 'project'
139
+ ? projectRoot : path.dirname(file);
140
+ const declared = new Map();
141
+ for (const [file, bytes] of after) {
142
+ if (path.basename(file) !== SIDECAR) continue;
143
+ const receipt = parse(bytes), previous = parse(before.get(file));
144
+ // Legacy writers replace their managed map. Retain already recorded,
145
+ // untouched metadata files/resources they omit; this never adopts a file.
146
+ for (const [name, entry] of Object.entries(previous.managed || {})) {
147
+ const base = receiptRoot(file, receipt);
148
+ const target = path.resolve(base, name);
149
+ if (!target.startsWith(`${base}${path.sep}`) || receipt.managed?.[name]) continue;
150
+ if (!before.has(target) || !after.get(target)?.equals(before.get(target))) continue;
151
+ receipt.managed ||= {};
152
+ receipt.managed[name] = entry;
153
+ manifests.set(file, receipt);
154
+ }
155
+ for (const [name, entry] of Object.entries(receipt.managed || {})) {
156
+ const base = receiptRoot(file, receipt);
157
+ const target = path.resolve(base, name);
158
+ if (!target.startsWith(`${base}${path.sep}`) || !after.has(target)) continue;
159
+ if (stable(previous.managed?.[name]) !== stable(entry)) declared.set(target, { file, name, entry, receipt });
160
+ }
161
+ }
162
+ for (const [file, bytes] of after) {
163
+ if (path.basename(file) === SIDECAR || /(?:^|[/\\])aiwg\.config$/.test(file)
164
+ || /(?:\.bak\.|\.aiwg-backup-)/.test(path.basename(file))) continue;
165
+ const changed = !before.get(file)?.equals(bytes);
166
+ const declaration = declared.get(file);
167
+ if (opts.onlyDeclared && !declaration) continue;
168
+ if (!changed && !declaration && !opts.writtenFiles?.includes(file)) continue;
169
+ // Existing integrity receipts that disagree with bytes never bless operator edits.
170
+ if (declaration?.entry.hash && declaration.entry.hash !== hash(bytes)) continue;
171
+ let skillRoot = path.dirname(file);
172
+ while (skillRoot !== path.dirname(skillRoot)) {
173
+ const parentReceipt = parse(after.get(path.join(skillRoot, SIDECAR)));
174
+ if (parentReceipt.managed?.['SKILL.md']) break;
175
+ skillRoot = path.dirname(skillRoot);
176
+ }
177
+ const skillReceipt = parse(after.get(path.join(skillRoot, SIDECAR)));
178
+ const projectScoped = projectRoot && (path.dirname(file) === projectRoot || opts.provider === 'flue' && /[/\\](?:db\.ts|aiwg[/\\](?:tools|specialists)\.ts)$/.test(file));
179
+ const dir = projectScoped ? path.join(projectRoot, '.aiwg') : declaration ? path.dirname(declaration.file) : skillReceipt.managed?.['SKILL.md'] ? skillRoot : path.dirname(file);
180
+ const name = declaration?.name || portable(path.relative(projectScoped ? projectRoot : dir, file));
181
+ const existing = manifests.get(path.join(dir, SIDECAR)) || parse(after.get(path.join(dir, SIDECAR)));
182
+ const previous = parse(before.get(path.join(dir, SIDECAR))).managed?.[name];
183
+ const current = existing.managed?.[name] || {};
184
+ // A redeploy may preserve operator additions around generated context.
185
+ // Keep the old digest so removal cannot restore a stale preimage over them.
186
+ if (previous?.filePreimage && before.has(file) && previous.hash !== hash(before.get(file))) continue;
187
+ const identity = current.sourcePath || `${declaration?.receipt.skillSource}/SKILL.md`;
188
+ const logicalSource = opts.logicalInputPath?.(identity) || identity;
189
+ const sourceOwner = (declaration || current.hash === hash(bytes)) && (current.frameworkSlug || bundleOwner(logicalSource))
190
+ || skillReceipt.managed?.['SKILL.md']?.frameworkSlug;
191
+ const generatedIndex = /^RULES-(?:INDEX|ONDEMAND)\.(?:md|mdc)$/.test(path.basename(file));
192
+ const kind = generatedIndex ? 'rule-index' : current.kind || artifactKind(file);
193
+ const selectedOwner = opts.provider === 'flue' ? owner : sourceOwner || (opts.onlyDeclared ? current.owners?.[0] : owner);
194
+ if (!selectedOwner) {
195
+ console.warn(`Ownership not recorded for ${file}: no framework owner resolved.`);
196
+ continue;
197
+ }
198
+ const receipt = manifest(dir);
199
+ if (projectScoped) receipt.scope = 'project';
200
+ const record = mergeArtifactOwnership(previous, { ...current, hash: hash(bytes), owners: opts.provider === 'flue' ? [] : current.hash === hash(bytes) ? current.owners : [], kind }, selectedOwner);
201
+ // Flue's composed context and generated database/ignore outputs support
202
+ // exact restoration. Never infer a preimage for another provider's files.
203
+ if (opts.provider === 'flue' && (projectScoped || /[/\\]db\.ts$/.test(file))) {
204
+ record.filePreimage = previous?.filePreimage || { present: before.has(file),
205
+ ...(before.has(file) ? { bytes: before.get(file).toString('base64'), hash: hash(before.get(file)) } : {}) };
206
+ }
207
+ // Structural rule indexes are generated outputs; their assembly scratch
208
+ // directory is not a durable source identity.
209
+ if (generatedIndex) {
210
+ delete record.sourcePath;
211
+ record.kind = 'rule-index';
212
+ }
213
+ // Settings have key/value receipts in the same entry, never a separate store.
214
+ if (/^(?:settings(?:\.local)?|hooks|opencode|config|aiwg\.cordis\.patch)\.(?:json|toml|ya?ml)$/.test(path.basename(file))) {
215
+ record.kind = 'settings';
216
+ record.settingsPreimage = previous?.settingsPreimage || (!previous?.settings ? {
217
+ present: before.has(file), ...(before.has(file) ? { bytes: before.get(file).toString('base64'), hash: hash(before.get(file)) } : {})
218
+ } : undefined);
219
+ const claimUnchanged = opts.claimUnchangedSettings !== false
220
+ && !/(?:agentic\/code|\.aiwg)\/(?:addons|extensions)\//.test((opts.logicalInputPath?.(opts.srcRoot) || opts.srcRoot)?.replaceAll('\\', '/') || '');
221
+ record.settings = settingsRecords(settingsDocument(file, before.get(file)), settingsDocument(file, bytes), previous?.settings, selectedOwner, claimUnchanged);
222
+ const settingsOwners = Object.values(record.settings).flatMap(entry => entry.owners);
223
+ record.owners = [...new Set(settingsOwners.length ? settingsOwners
224
+ : [...(previous?.owners || []), ...(changed ? [selectedOwner] : [])])].sort();
225
+ }
226
+ receipt.managed ||= {};
227
+ receipt.managed[name] = record;
228
+ }
229
+ for (const [file, receipt] of manifests) {
230
+ const text = `${JSON.stringify(receipt, null, 2)}\n`;
231
+ if (after.get(file)?.toString() === text) continue;
232
+ fs.mkdirSync(path.dirname(file), { recursive: true });
233
+ if (receipt.scope === 'project' && opts.writeReceipt) opts.writeReceipt(file, text);
234
+ else fs.writeFileSync(file, text);
235
+ }
236
+ }
@@ -0,0 +1,222 @@
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 (record.filePreimage && (claims.get(target) || []).length === 1) {
132
+ const snapshot = record.filePreimage;
133
+ const prior = snapshot.present && typeof snapshot.bytes === 'string' ? Buffer.from(snapshot.bytes, 'base64') : null;
134
+ const valid = snapshot.present === false || prior !== null && hash(prior) === snapshot.hash;
135
+ const current = fs.existsSync(target) && fs.lstatSync(target).isFile() ? fs.readFileSync(target) : null;
136
+ if (valid && current && hash(current) === record.hash) {
137
+ const others = owners.filter(candidate => candidate !== owner);
138
+ if (others.length) {
139
+ record.owners = others;
140
+ remaining.push(record);
141
+ }
142
+ else {
143
+ writes.push({ path: target, before: current, after: prior });
144
+ delete receipt.managed[name];
145
+ }
146
+ decisions.push({ path: target, action: others.length || prior ? 'release' : 'remove',
147
+ reason: others.length ? 'shared generated output; release this owner only' : 'verified file preimage restored', kind: record.kind, owned: true });
148
+ changed = true;
149
+ continue;
150
+ }
151
+ reason = 'edited generated file; preserved';
152
+ }
153
+ else if (CONTEXT_BRIDGES.has(path.basename(target)))
154
+ reason = 'context bridge preserved; pre-deploy operator content unverifiable';
155
+ else if ((claims.get(target) || []).some(claim => claim.hash !== record.hash))
156
+ reason = 'conflicting receipt digests; unverifiable';
157
+ else if ((claims.get(target) || []).some(claim => (claim.owners || (claim.frameworkSlug ? [claim.frameworkSlug] : [])).some(item => item !== owner))) {
158
+ action = 'release';
159
+ reason = 'shared with another framework; release this owner only';
160
+ }
161
+ else {
162
+ try {
163
+ if (fs.lstatSync(target).isFile() && /^sha256:[a-f0-9]{64}$/.test(record.hash) && hash(fs.readFileSync(target)) === record.hash) {
164
+ action = 'remove';
165
+ reason = 'unchanged managed file';
166
+ }
167
+ }
168
+ catch (error) {
169
+ if (error.code === 'ENOENT') {
170
+ action = 'release';
171
+ reason = 'recorded file already absent';
172
+ }
173
+ else
174
+ reason = 'unreadable path; unverifiable';
175
+ }
176
+ }
177
+ decisions.push({ path: target, action, reason, kind: record.kind, owned: true });
178
+ if (action === 'preserve') {
179
+ remaining.push(record);
180
+ continue;
181
+ }
182
+ changed = true;
183
+ if (action === 'remove')
184
+ writes.push({ path: target, before: fs.readFileSync(target), after: null });
185
+ const otherOwners = owners.filter(item => item !== owner);
186
+ if (otherOwners.length) {
187
+ record.owners = otherOwners;
188
+ if (record.frameworkSlug === owner)
189
+ record.frameworkSlug = otherOwners[0];
190
+ }
191
+ else
192
+ delete receipt.managed[name];
193
+ }
194
+ if (changed) {
195
+ const empty = Object.keys(receipt.managed).length === 0;
196
+ writes.push({ path: file, before, after: empty ? null : Buffer.from(`${JSON.stringify(receipt, null, 2)}\n`) });
197
+ if (empty)
198
+ decisions.push({ path: file, action: 'remove', reason: 'ownership metadata released' });
199
+ }
200
+ accounted.add(file);
201
+ }
202
+ for (const file of [...files].sort()) {
203
+ if (accounted.has(file))
204
+ continue;
205
+ // Foreign receipts are ownership evidence, but never this framework's files.
206
+ const skill = receipts.find(item => inside(path.dirname(item.file), file) && item.receipt.managed?.['SKILL.md']);
207
+ const ownSkill = skill?.receipt.managed?.['SKILL.md']?.frameworkSlug === owner;
208
+ const foreign = skill && !ownSkill;
209
+ const foreignFile = (claims.get(file) || []).some(record => (record.owners || (record.frameworkSlug ? [record.frameworkSlug] : [])).length);
210
+ decisions.push({ path: file, action: 'preserve', reason: foreign ? 'foreign or unverifiable ownership receipt'
211
+ : foreignFile ? 'foreign ownership receipt; owned by another bundle' : ownSkill ? 'unrecorded operator file' : modern ? 'unrecorded operator file; unverifiable ownership' : 'unverifiable: no ownership receipt' });
212
+ }
213
+ const unique = new Map();
214
+ for (const decision of decisions) {
215
+ const key = `${decision.path}#${decision.pointer ?? ''}`;
216
+ const previous = unique.get(key);
217
+ if (!previous || decision.action === 'preserve' || previous.action === 'remove')
218
+ unique.set(key, decision);
219
+ }
220
+ return { decisions: [...unique.values()], writes, remaining, recorded, legacy: !modern };
221
+ }
222
+ //# sourceMappingURL=deployment-removal.js.map
@@ -1,5 +1,13 @@
1
1
  const VERIFIED_ON = '2026-07-21';
2
2
  export const CONTEXT_CONTRACTS = {
3
+ flue: {
4
+ startupFiles: ['AGENTS.md'], precedence: ['provider/system', 'cwd AGENTS.md bytes'],
5
+ loadMode: 'prose-directive', includeSyntax: null, configRegistration: null,
6
+ bootstrapTargets: ['AGENTS.md'], maxContextBytes: null, recommendedMaxLines: null,
7
+ nestedContext: false, support: 'supported',
8
+ verification: { method: 'Installed Flue 2.3.0 source; context must be inlined',
9
+ source: '@flue/runtime/dist/conversation-stream-store-CXrgv-b0.mjs:339-349,463-482', lastVerified: '2026-10-30' },
10
+ },
3
11
  antigravity: {
4
12
  startupFiles: ['AGENTS.md', 'GEMINI.md'],
5
13
  precedence: ['provider/system', 'project AGENTS.md or GEMINI.md', 'nested project context when selected by the CLI'],
@@ -17,6 +17,7 @@ export const ProviderDefinitionSchema = z.object({
17
17
  'cursor',
18
18
  'deepseek-harness',
19
19
  'factory',
20
+ 'flue',
20
21
  'grokbot',
21
22
  'grok-build',
22
23
  'hermes',
@@ -16,6 +16,7 @@ export const PROVIDER_IDS = [
16
16
  'cursor',
17
17
  'deepseek-harness',
18
18
  'factory',
19
+ 'flue',
19
20
  'grokbot',
20
21
  'grok-build',
21
22
  'hermes',
@@ -1,4 +1,22 @@
1
1
  export const BUILT_IN_SEEDS_3 = [
2
+ {
3
+ id: 'flue', displayName: 'Flue (experimental)', status: 'experimental', aliases: [], builtIn: true,
4
+ surfaces: { primary: 'flue', compatibility: [], precedence: ['AGENTS.md', '.agents/skills/'], related: [] },
5
+ detection: { env: [], process: [], capabilityId: 'flue' },
6
+ paths: {
7
+ artifacts: { agents: null, commands: null, skills: '.agents/skills', rules: null, behaviors: null },
8
+ kernelSkills: '.agents/skills', configFile: 'AGENTS.md',
9
+ contextDiscovery: { agents: null, skills: '.agents/skills', rules: null, behaviors: null },
10
+ contextFiles: { aiwgMd: true, agentsMd: true, claudeMdHook: false, hookFile: null, contextFile: 'AGENTS.md' },
11
+ },
12
+ smithPaths: { agents: null, commands: null, skills: '.agents/skills', rules: null,
13
+ fileExtension: '.md', configFile: 'AGENTS.md', aggregated: false },
14
+ skillNamespace: { deploymentGroup: 'one-level', pathType: 'project', skillsBaseDir: '.agents/skills',
15
+ subdirLayout: false, maxNameLength: 64, maxDescriptionLength: 1024 },
16
+ adapters: { agentFormat: 'none', hookBridge: null, mcpInjection: null,
17
+ contextAggregation: 'agents-md', ruleFormat: 'agents-md-section' },
18
+ matrixRef: 'flue',
19
+ },
2
20
  {
3
21
  id: 'pi',
4
22
  aliases: ['pi-coding-agent'],