@aiwg/cli 2026.10.19 → 2026.11.0
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.
- package/README.md +1 -0
- package/dist/src/cli/handlers/bundle-declaration.js +55 -0
- package/dist/src/cli/handlers/bundle-deployment-mode.js +71 -0
- package/dist/src/cli/handlers/bundle-hash-prune.js +37 -0
- package/dist/src/cli/handlers/bundle-reconciliation.js +140 -0
- package/dist/src/cli/handlers/refresh-bundles.js +35 -0
- package/dist/src/cli/handlers/refresh-rule-inventory.js +10 -0
- package/dist/src/cli/handlers/refresh.js +15 -52
- package/dist/src/cli/handlers/remove-bundled.js +7 -4
- package/dist/src/cli/handlers/remove-flue-modules.js +19 -0
- package/dist/src/cli/handlers/remove-historical-bundle.js +18 -0
- package/dist/src/cli/handlers/remove.js +8 -0
- package/dist/src/cli/handlers/script-runner.js +10 -0
- package/dist/src/cli/handlers/subcommands-list-format.js +4 -4
- package/dist/src/cli/handlers/update.js +18 -8
- package/dist/src/cli/handlers/use-additive-bundles.js +87 -0
- package/dist/src/cli/handlers/use-bundle-counts.js +5 -1
- package/dist/src/cli/handlers/use-owned-counts.js +75 -0
- package/dist/src/cli/handlers/use.js +44 -99
- package/dist/src/cli/services/deployment-verification.js +2 -1
- package/dist/src/config/aiwg-config.js +10 -5
- package/dist/src/config/framework-aliases.js +14 -0
- package/dist/src/config/installed-selection.js +9 -1
- package/dist/src/config/installed-validation.js +35 -0
- package/dist/src/extensions/project-local-doctor.js +1 -1
- package/dist/src/extensions/project-local-remove.js +3 -3
- package/dist/src/mcp/cli.mjs +12 -7
- package/dist/src/mcp/helpers.mjs +5 -1
- package/dist/src/mcp/http-options.mjs +101 -0
- package/dist/src/mcp/http-tools.mjs +51 -0
- package/dist/src/mcp/http-transport.mjs +201 -0
- package/dist/src/mcp/server.mjs +9 -7
- package/dist/src/mcp/tool-context.mjs +25 -0
- package/dist/src/mcp/tools/orchestration.mjs +2 -1
- package/dist/src/providers/deployment-ownership.mjs +15 -1
- package/dist/src/providers/deployment-preservation.d.mts +5 -0
- package/dist/src/providers/deployment-preservation.mjs +110 -0
- package/dist/src/providers/deployment-removal.js +4 -2
- package/dist/src/providers/flue-package-mode.js +19 -0
- package/dist/src/providers/skill-ownership.mjs +1 -0
- package/dist/src/research/reference-match.js +4 -0
- package/package.json +2 -1
- package/tools/agents/deploy-agents.mjs +6 -1
- package/tools/agents/deploy-options.mjs +2 -0
- package/tools/agents/providers/base-inventory.mjs +6 -1
- package/tools/agents/providers/base-kernel-skills.mjs +9 -5
- package/tools/agents/providers/base-migrations.mjs +1 -0
- package/tools/agents/providers/base-skill-copy.mjs +9 -1
- package/tools/agents/providers/claude.mjs +2 -1
- package/tools/agents/providers/codex.mjs +5 -1
- package/tools/agents/providers/flue-bundles.mjs +42 -0
- package/tools/agents/providers/flue-cloudflare.mjs +20 -0
- package/tools/agents/providers/flue-project.mjs +45 -6
- package/tools/agents/providers/flue-skill-copy.mjs +25 -0
- package/tools/agents/providers/flue-skills.mjs +45 -0
- package/tools/agents/providers/flue-specialists.mjs +36 -18
- package/tools/agents/providers/flue-validation.mjs +14 -0
- package/tools/agents/providers/flue.mjs +12 -8
- package/tools/agents/providers/hermes-skill-lifecycle.mjs +1 -0
- package/tools/agents/providers/rule-delivery-surface.mjs +15 -1
- package/tools/agents/providers/rule-deployment-commit.mjs +14 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +4 -0
- package/tools/agents/providers/skill-copy-prune.mjs +49 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +1 -0
- package/tools/skills/codex-skill-metadata.mjs +22 -0
- package/tools/skills/deploy-skills-codex.mjs +8 -7
- package/vscode-extension/schemas/aiwg.config.v1.json +44 -19
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AiwgConfig } from '../config/aiwg-config.js';
|
|
2
|
+
export function providerCopyMode(project: string, provider: string, owner?: string, config?: AiwgConfig, indexOwner?: string): boolean;
|
|
3
|
+
export function automaticRemovalAllowed(project: string, provider: string, file: string, config?: AiwgConfig): boolean;
|
|
4
|
+
export function preserveDeploymentOutputs(before: Map<string, Buffer>, roots: string[], opts?: Record<string, unknown>): void;
|
|
5
|
+
export function deploymentEditWarnings(project: string, provider: string): string[];
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Preserve copy-mode deletions and edited receipt-owned payloads across provider passes.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
import { frameworkRegistryId } from '../config/framework-aliases.js';
|
|
6
|
+
const hash = bytes => `sha256:${createHash('sha256').update(bytes).digest('hex')}`;
|
|
7
|
+
const parse = bytes => { try { return JSON.parse(bytes?.toString() || '{}'); } catch { return {}; } };
|
|
8
|
+
const sidecar = '.aiwg-manifest.json';
|
|
9
|
+
const context = new Set(['AGENTS.md', 'AIWG.md', 'WORKSPACE.md', 'CLAUDE.md', 'WARP.md', '.hermes.md', 'copilot-instructions.md']);
|
|
10
|
+
export function providerCopyMode(project, provider, owner, config, indexOwner) {
|
|
11
|
+
const history = parse(fs.existsSync(path.join(project, '.aiwg', sidecar)) ? fs.readFileSync(path.join(project, '.aiwg', sidecar)) : null).bundleDeployments?.[provider] || {};
|
|
12
|
+
if (!config) {
|
|
13
|
+
try { config = JSON.parse(fs.readFileSync(path.join(project, '.aiwg/aiwg.config'), 'utf8')); } catch { config = {}; }
|
|
14
|
+
}
|
|
15
|
+
const modes = new Map(Object.entries(history).map(([id, mode]) => [frameworkRegistryId(id), mode.copy === true || mode.package === true]));
|
|
16
|
+
for (const [id, entry] of Object.entries(config.installed || {})) {
|
|
17
|
+
if (entry.deployedTo?.[provider]) modes.set(frameworkRegistryId(id), entry.deployedTo[provider].copy === true || entry.deployedTo[provider].package === true);
|
|
18
|
+
}
|
|
19
|
+
if (indexOwner) modes.set(frameworkRegistryId(indexOwner), false);
|
|
20
|
+
const inherited = new Set();
|
|
21
|
+
for (const [id, mode] of Object.entries(history)) if (modes.get(frameworkRegistryId(id))) {
|
|
22
|
+
for (const produced of mode.produces || []) inherited.add(frameworkRegistryId(produced));
|
|
23
|
+
}
|
|
24
|
+
return owner ? modes.get(frameworkRegistryId(owner)) === true || inherited.has(frameworkRegistryId(owner)) || inherited.has('*')
|
|
25
|
+
: [...modes.values()].some(Boolean) || inherited.size > 0;
|
|
26
|
+
}
|
|
27
|
+
export function automaticRemovalAllowed(project, provider, file, config) {
|
|
28
|
+
const receipt = parse(fs.existsSync(path.join(path.dirname(file), sidecar)) ? fs.readFileSync(path.join(path.dirname(file), sidecar)) : null);
|
|
29
|
+
const record = receipt.managed?.[path.basename(file)];
|
|
30
|
+
const owners = record?.owners || (record?.frameworkSlug ? [record.frameworkSlug] : []);
|
|
31
|
+
const copy = owners.length ? owners.some(owner => providerCopyMode(project, provider, owner, config)) : providerCopyMode(project, provider, undefined, config);
|
|
32
|
+
const modified = !record?.hash || record.hash !== hash(fs.readFileSync(file));
|
|
33
|
+
if (!copy && !modified) return true;
|
|
34
|
+
console.warn(`${file}: kept (${copy ? 'copy mode' : record?.hash ? 'operator-edited' : 'unverifiable ownership'});${copy ? ' use aiwg remove <bundle> to delete' : ' managed hash differs'}`);
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Called against a staging snapshot before ownership is refreshed or output is promoted. */
|
|
39
|
+
export function preserveDeploymentOutputs(before, roots, opts = {}) {
|
|
40
|
+
const writeReceipt = (file, bytes) => file === path.join(opts.target, '.aiwg', sidecar) && opts.writeReceipt
|
|
41
|
+
? opts.writeReceipt(file, bytes) : fs.writeFileSync(file, bytes);
|
|
42
|
+
const claims = new Map();
|
|
43
|
+
const receipts = new Map();
|
|
44
|
+
for (const [file, bytes] of before) {
|
|
45
|
+
if (path.basename(file) !== sidecar) continue;
|
|
46
|
+
const receipt = parse(bytes);
|
|
47
|
+
receipts.set(file, receipt);
|
|
48
|
+
const base = receipt.scope === 'project' && file === path.join(opts.target, '.aiwg', sidecar) ? opts.target : path.dirname(file);
|
|
49
|
+
for (const [name, record] of Object.entries(receipt.managed || {})) {
|
|
50
|
+
const target = path.resolve(base, name);
|
|
51
|
+
if (target.startsWith(`${base}${path.sep}`)) claims.set(target, { record, file, name });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const restored = [];
|
|
55
|
+
for (const [file, bytes] of before) {
|
|
56
|
+
if (path.basename(file) === sidecar) continue;
|
|
57
|
+
const exists = fs.existsSync(file);
|
|
58
|
+
if (!exists && opts.replacedSkillCopies?.has(file)) continue;
|
|
59
|
+
const claim = claims.get(file);
|
|
60
|
+
const edited = claim?.record.hash && claim.record.hash !== hash(bytes) && !context.has(path.basename(file)) && claim.record.kind !== 'settings';
|
|
61
|
+
const owners = claim?.record.owners || (claim?.record.frameworkSlug ? [claim.record.frameworkSlug] : []);
|
|
62
|
+
const currentOwner = (opts.srcRoot || '').replaceAll('\\', '/').match(/(?:agentic\/code|\.aiwg)\/(?:frameworks|addons|extensions)\/([^/]+)/)?.[1] || frameworkRegistryId(opts.mode || '');
|
|
63
|
+
const copy = (opts.copyMode ?? opts.copyStandardSkills) || owners.some(owner => providerCopyMode(opts.target, opts.provider, owner, opts.config, currentOwner));
|
|
64
|
+
if (!(edited || !exists && copy) || exists && fs.readFileSync(file).equals(bytes)) continue;
|
|
65
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
66
|
+
fs.writeFileSync(file, bytes);
|
|
67
|
+
if (edited) console.warn(`${opts.logicalOutputPath?.(file) || file}: kept (operator-edited)`);
|
|
68
|
+
restored.push(claim);
|
|
69
|
+
}
|
|
70
|
+
// Keep the old digest for protected payloads: a later run must still detect edits.
|
|
71
|
+
for (const claim of restored.filter(Boolean)) {
|
|
72
|
+
const { managed: _managed, ...metadata } = receipts.get(claim.file) || {};
|
|
73
|
+
const receipt = { ...metadata, ...parse(fs.existsSync(claim.file) ? fs.readFileSync(claim.file) : null) };
|
|
74
|
+
receipt.managed ??= {};
|
|
75
|
+
receipt.managed[claim.name] = claim.record;
|
|
76
|
+
writeReceipt(claim.file, `${JSON.stringify(receipt, null, 2)}\n`);
|
|
77
|
+
}
|
|
78
|
+
// Provider writers must not discard declaration history when rewriting a receipt.
|
|
79
|
+
for (const [file, previous] of receipts) {
|
|
80
|
+
if (!previous.bundleDeployments) continue;
|
|
81
|
+
const current = parse(fs.existsSync(file) ? fs.readFileSync(file) : null);
|
|
82
|
+
current.bundleDeployments = previous.bundleDeployments;
|
|
83
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
84
|
+
if (JSON.stringify(current.bundleDeployments) !== JSON.stringify(parse(fs.existsSync(file) ? fs.readFileSync(file) : null).bundleDeployments)) writeReceipt(file, `${JSON.stringify(current, null, 2)}\n`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Successful captured passes still report edits whose old receipt digests were retained. */
|
|
89
|
+
export function deploymentEditWarnings(project, provider) {
|
|
90
|
+
const warnings = new Set();
|
|
91
|
+
const visit = dir => {
|
|
92
|
+
const stat = fs.lstatSync(dir, { throwIfNoEntry: false });
|
|
93
|
+
if (!stat?.isDirectory() || stat.isSymbolicLink()) return;
|
|
94
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
95
|
+
const file = path.join(dir, entry.name);
|
|
96
|
+
if (entry.isDirectory()) { visit(file); continue; }
|
|
97
|
+
if (entry.name !== sidecar || !entry.isFile()) continue;
|
|
98
|
+
const receipt = parse(fs.readFileSync(file));
|
|
99
|
+
for (const [name, record] of Object.entries(receipt.managed || {})) {
|
|
100
|
+
const target = path.resolve(dir, name);
|
|
101
|
+
if (!target.startsWith(`${dir}${path.sep}`) || context.has(path.basename(target)) || record.kind === 'settings') continue;
|
|
102
|
+
const state = fs.lstatSync(target, { throwIfNoEntry: false });
|
|
103
|
+
if (state?.isFile() && record.hash && record.hash !== hash(fs.readFileSync(target))) warnings.add(`${target}: kept (operator-edited)`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
visit(path.join(project, `.${provider}`));
|
|
108
|
+
visit(path.join(project, '.agents'));
|
|
109
|
+
return [...warnings];
|
|
110
|
+
}
|
|
@@ -27,13 +27,15 @@ function symlinkBetween(root, file) {
|
|
|
27
27
|
}
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
|
-
export function planDeploymentRemoval(project, provider, owner, includeProject = true) {
|
|
30
|
+
export function planDeploymentRemoval(project, provider, owner, includeProject = true, preserveRoots = []) {
|
|
31
31
|
const paths = Object.values(getProviderArtifactPathStrings(provider) || {}).filter(Boolean);
|
|
32
32
|
const roots = [...new Set([...paths.map(dir => path.isAbsolute(dir) ? dir : path.join(project, dir.split(/[\\/]/)[0])),
|
|
33
33
|
...deployedSkillRoots(project, provider), path.join(project, `.${provider}`), ...(includeProject ? [path.join(project, '.aiwg/frameworks')] : [])])].map(root => path.resolve(root));
|
|
34
34
|
const files = new Set();
|
|
35
35
|
const decisions = [], writes = [], remaining = [], recorded = [];
|
|
36
36
|
const visit = (file) => {
|
|
37
|
+
if (preserveRoots.some(root => file === root || inside(root, file)))
|
|
38
|
+
return;
|
|
37
39
|
let stat;
|
|
38
40
|
try {
|
|
39
41
|
stat = fs.lstatSync(file);
|
|
@@ -192,7 +194,7 @@ export function planDeploymentRemoval(project, provider, owner, includeProject =
|
|
|
192
194
|
delete receipt.managed[name];
|
|
193
195
|
}
|
|
194
196
|
if (changed) {
|
|
195
|
-
const empty = Object.keys(receipt.managed).length === 0;
|
|
197
|
+
const empty = Object.keys(receipt.managed).length === 0 && !receipt.bundleDeployments;
|
|
196
198
|
writes.push({ path: file, before, after: empty ? null : Buffer.from(`${JSON.stringify(receipt, null, 2)}\n`) });
|
|
197
199
|
if (empty)
|
|
198
200
|
decisions.push({ path: file, action: 'remove', reason: 'ownership metadata released' });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Recognize a package-mode deployment without requiring copied skill directories.
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { readAiwgConfig } from '../config/aiwg-config.js';
|
|
5
|
+
export async function hasFluePackageDeployment(project) {
|
|
6
|
+
const config = await readAiwgConfig(project);
|
|
7
|
+
if (!Object.values(config?.installed ?? {}).some(entry => entry.deployedTo.flue?.package))
|
|
8
|
+
return false;
|
|
9
|
+
try {
|
|
10
|
+
const source = await readFile(path.join(project, 'src/aiwg/skills.ts'), 'utf8');
|
|
11
|
+
return /from ['"]@aiwg\/flue\/skills\/[^'"\n]+\/SKILL\.md['"]/.test(source);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (error.code === 'ENOENT')
|
|
15
|
+
return false;
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=flue-package-mode.js.map
|
|
@@ -42,6 +42,7 @@ export function canDeploySkill(receipt, skillSource, { force = false, logicalInp
|
|
|
42
42
|
|
|
43
43
|
/** Remove unchanged recorded files, allowing symlinks above (but never inside) the skill root. */
|
|
44
44
|
export function pruneRecordedSkillFiles(skillDir, managed, desired, opts = {}) {
|
|
45
|
+
if (opts.copyMode ?? opts.copyStandardSkills) return;
|
|
45
46
|
const root = path.resolve(skillDir);
|
|
46
47
|
for (const [relative, record] of Object.entries(managed || {})) {
|
|
47
48
|
const target = path.resolve(skillDir, relative);
|
|
@@ -54,6 +54,10 @@ export function needsTitleDisambiguation(reference, candidates, incomplete) {
|
|
|
54
54
|
// A 0.25 window preserves caution for short titles sharing three of four tokens
|
|
55
55
|
// (~0.24 behind with author corroboration), excluding weaker hits like 1.000 vs 0.711.
|
|
56
56
|
const competing = candidates.slice(1).some(candidate => classifyCandidates([candidate]) !== 'unresolved' &&
|
|
57
|
+
// An exact winner year excludes only known gaps beyond one-year preprint/venue lag
|
|
58
|
+
// (e.g. reprints); adjacent or missing runner-up years still compete, failing safe.
|
|
59
|
+
!(reference.year !== undefined && candidates[0].score_parts.year === 1 && candidate.score_parts.year === 0 &&
|
|
60
|
+
candidate.paper.year > 0 && Math.abs(candidate.paper.year - reference.year) > 1) &&
|
|
57
61
|
candidates[0].score - candidate.score <= 0.25 + 1e-12);
|
|
58
62
|
if (!competing && !unqualified)
|
|
59
63
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiwg/cli",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.11.0",
|
|
4
4
|
"description": "Lightweight AIWG CLI for signed, versioned web-backed resources.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"tools/plugin/plugin-links.mjs",
|
|
108
108
|
"tools/skills/deploy-skills-codex.mjs",
|
|
109
109
|
"tools/skills/codex-skill-transform.mjs",
|
|
110
|
+
"tools/skills/codex-skill-metadata.mjs",
|
|
110
111
|
"README.md"
|
|
111
112
|
],
|
|
112
113
|
"repository": {
|
|
@@ -162,6 +162,7 @@ import { parseArgs, printHelp } from './deploy-options.mjs';
|
|
|
162
162
|
import { useRuleSelectionConfig } from './use-rule-selection.mjs';
|
|
163
163
|
import { mirrorSkillsAsCommands } from './deploy-command-mirrors.mjs';
|
|
164
164
|
import { resolveShorthand, saveModelConfig, promptCommandsMigration } from './deploy-support.mjs';
|
|
165
|
+
const { preserveDeploymentOutputs } = await importImpl(import.meta.url, 'providers/deployment-preservation.mjs');
|
|
165
166
|
const { captureDeploymentOutputs, recordDeploymentOutputs, deploymentOutputRoots } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
166
167
|
|
|
167
168
|
export async function main(args = process.argv.slice(2), internal = {}) {
|
|
@@ -248,6 +249,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
248
249
|
// Build options for provider
|
|
249
250
|
const { writeContextFileSync } = await import('./providers/context-write.mjs');
|
|
250
251
|
const opts = {
|
|
252
|
+
replacedSkillCopies: new Set(),
|
|
251
253
|
writeReceipt: writeContextFileSync,
|
|
252
254
|
config: useRuleSelectionConfig(cfg, srcRoot),
|
|
253
255
|
srcRoot,
|
|
@@ -297,7 +299,9 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
297
299
|
// for the standard tier. Default is no-copy + index-driven discovery.
|
|
298
300
|
// Replaces the legacy AIWG_COPY_STANDARD_SKILLS env var (removed rc.30).
|
|
299
301
|
// Default (#1217) is no-copy + index-driven discovery.
|
|
302
|
+
fluePackage: cfg.fluePackage === true,
|
|
300
303
|
copyStandardSkills: cfg.copyStandardSkills === true,
|
|
304
|
+
copyMode: cfg.copyStandardSkills === true && cfg.indexMode !== true,
|
|
301
305
|
// #228: Muse provider hooks/MCP profile surface.
|
|
302
306
|
mcp: cfg.mcp === true,
|
|
303
307
|
hooks: cfg.hooks !== false,
|
|
@@ -318,7 +322,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
318
322
|
// Commands → Skills migration: prompt then delete the commands directory
|
|
319
323
|
// so stale command files don't create duplicates in the provider TUI.
|
|
320
324
|
if (!preparationActive && !internal.finalizeOnly) {
|
|
321
|
-
if (!cfg.dryRun && !cfg.skipCommandsMigration) {
|
|
325
|
+
if (!cfg.dryRun && !opts.copyMode && !cfg.skipCommandsMigration) {
|
|
322
326
|
const doMigrate = await promptCommandsMigration(cfg, provider, cfg.target, internal.capture ? false : process.stdout.isTTY);
|
|
323
327
|
if (doMigrate) {
|
|
324
328
|
const commandsRelPath = provider.paths?.commands;
|
|
@@ -386,6 +390,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
386
390
|
await saveModelConfig(cfg, provider.name);
|
|
387
391
|
}
|
|
388
392
|
|
|
393
|
+
if (ownershipBefore) preserveDeploymentOutputs(ownershipBefore, ownershipRoots, opts);
|
|
389
394
|
if (ownershipBefore) recordDeploymentOutputs(ownershipBefore, ownershipRoots, opts);
|
|
390
395
|
if (!cfg.quiet) console.log(`\n=== Deployment complete ===\n`);
|
|
391
396
|
} catch (err) {
|
|
@@ -110,6 +110,8 @@ export function parseArgs(args = process.argv.slice(2)) {
|
|
|
110
110
|
else if (a === '--skip-commands-migration') cfg.skipCommandsMigration = true;
|
|
111
111
|
// Structural opt-out: skip the migration without claiming the operator declined it (#2541).
|
|
112
112
|
else if (a === '--no-commands-warning') cfg.warnOnSkippedCommandsMigration = false;
|
|
113
|
+
else if (a === '--index-mode') cfg.indexMode = true; // internal: forced local copies still use index cleanup
|
|
114
|
+
else if (a === '--package') cfg.fluePackage = true;
|
|
113
115
|
else if (a === '--copy-all' || a === '--copy-standard-skills') cfg.copyStandardSkills = true;
|
|
114
116
|
// #228: Muse provider — explicit opt-in MCP settings profile, and the
|
|
115
117
|
// managed-hooks opt-out (default on, mirroring the Claude autoInstall policy).
|
|
@@ -3,7 +3,7 @@ import { fs, path } from './base-runtime.mjs';
|
|
|
3
3
|
import { collectFrameworkArtifacts } from './base-framework-discovery.mjs';
|
|
4
4
|
import { getAddonAgentFiles, getAddonCommandFiles } from './base-addon-discovery.mjs';
|
|
5
5
|
import { getAddonRuleFiles } from './base-rule-index.mjs';
|
|
6
|
-
import { MANAGED_MARKER_RE, MANIFEST_FILENAME, readSidecarManifest, writeSidecarManifest } from './base-files.mjs';
|
|
6
|
+
import { contentHash, MANAGED_MARKER_RE, MANIFEST_FILENAME, readSidecarManifest, writeSidecarManifest } from './base-files.mjs';
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// ============================================================================
|
|
@@ -188,6 +188,7 @@ export function computeAllSkillNames(srcRoot) {
|
|
|
188
188
|
* @returns {string[]} removed (or would-be-removed) file paths
|
|
189
189
|
*/
|
|
190
190
|
export function pruneStaleAiwgFiles(destDir, desiredStems, opts = {}) {
|
|
191
|
+
if (opts.copyMode ?? opts.copyStandardSkills) return [];
|
|
191
192
|
const { dryRun = false, verbose = false } = opts;
|
|
192
193
|
const artifactExtensions = opts.artifactExtensions || ['.md', '.mdc'];
|
|
193
194
|
// When supplied, skill-command wrappers are retired against the set of skills
|
|
@@ -246,6 +247,10 @@ export function pruneStaleAiwgFiles(destDir, desiredStems, opts = {}) {
|
|
|
246
247
|
if (!owned) continue;
|
|
247
248
|
|
|
248
249
|
const target = path.join(destDir, name);
|
|
250
|
+
if (!managed[name]?.hash || managed[name].hash !== `sha256:${contentHash(fs.readFileSync(target))}`) {
|
|
251
|
+
console.warn(`${target}: kept (${managed[name]?.hash ? 'operator-edited' : 'unverifiable ownership'})`);
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
249
254
|
removed.push(target);
|
|
250
255
|
if (dryRun) {
|
|
251
256
|
if (verbose) console.log(`[dry-run] would prune stale AIWG artifact: ${path.relative(process.cwd(), target)}`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Shared provider kernel skills utilities.
|
|
2
|
+
import { removeSkillCopy } from './skill-copy-prune.mjs';
|
|
2
3
|
import { fs, path } from './base-runtime.mjs';
|
|
3
4
|
import { parseFrontmatter } from './base-frontmatter.mjs';
|
|
4
5
|
import { ensureDir } from './base-files.mjs';
|
|
@@ -140,7 +141,7 @@ export function deploySkillsWithKernelRouting(
|
|
|
140
141
|
} catch { /* preserve unreadable/operator-owned content */ }
|
|
141
142
|
}
|
|
142
143
|
if (!managed) continue;
|
|
143
|
-
|
|
144
|
+
if (!removeSkillCopy(target, { ...opts, tierMove: true, replacement: path.join(kernelDestDir, entry.name) })) continue;
|
|
144
145
|
prunedKernelFromStandardDir++;
|
|
145
146
|
if (opts?.verbose) console.log(`pruned promoted kernel from standard dir: ${entry.name}`);
|
|
146
147
|
}
|
|
@@ -160,7 +161,10 @@ export function deploySkillsWithKernelRouting(
|
|
|
160
161
|
if (!standardNames.has(entry.name)) continue;
|
|
161
162
|
const target = path.join(kernelDestDir, entry.name);
|
|
162
163
|
try {
|
|
163
|
-
|
|
164
|
+
// Index mode serves standard skills from $AIWG_ROOT; copy mode must have
|
|
165
|
+
// written the standard-tier copy before the kernel copy goes.
|
|
166
|
+
const replacement = copyStandardSkills && standardDestDir ? path.join(standardDestDir, entry.name) : undefined;
|
|
167
|
+
if (!removeSkillCopy(target, { ...opts, tierMove: true, replacement })) continue;
|
|
164
168
|
prunedFromKernelDir++;
|
|
165
169
|
if (opts?.verbose) console.log(`pruned legacy from kernel dir: ${entry.name}`);
|
|
166
170
|
} catch (err) {
|
|
@@ -187,7 +191,7 @@ export function deploySkillsWithKernelRouting(
|
|
|
187
191
|
if (!allSkillNames.has(entry.name)) continue;
|
|
188
192
|
const target = path.join(standardDestDir, entry.name);
|
|
189
193
|
try {
|
|
190
|
-
|
|
194
|
+
if (!removeSkillCopy(target, opts)) continue;
|
|
191
195
|
prunedFromStandardDir++;
|
|
192
196
|
if (opts?.verbose) console.log(`pruned legacy from standard dir: ${entry.name}`);
|
|
193
197
|
} catch (err) {
|
|
@@ -316,7 +320,7 @@ export function computeAllKernelNames(srcRoot) {
|
|
|
316
320
|
* @returns {number} count of pruned entries
|
|
317
321
|
*/
|
|
318
322
|
export function pruneStaleAiwgSkills(kernelDestDir, desiredKernelNames, opts = {}) {
|
|
319
|
-
if (!kernelDestDir || !fs.existsSync(kernelDestDir)) return 0;
|
|
323
|
+
if ((opts.copyMode ?? opts.copyStandardSkills) || !kernelDestDir || !fs.existsSync(kernelDestDir)) return 0;
|
|
320
324
|
// No global desired set — skip pruning rather than delete everything (#123).
|
|
321
325
|
if (desiredKernelNames == null) return 0;
|
|
322
326
|
if (opts.dryRun) return 0;
|
|
@@ -343,7 +347,7 @@ export function pruneStaleAiwgSkills(kernelDestDir, desiredKernelNames, opts = {
|
|
|
343
347
|
if (!isAiwgManaged) continue;
|
|
344
348
|
|
|
345
349
|
try {
|
|
346
|
-
|
|
350
|
+
if (!removeSkillCopy(path.join(kernelDestDir, entry.name), opts)) continue;
|
|
347
351
|
pruned++;
|
|
348
352
|
if (opts.verbose) console.log(`pruned stale AIWG skill: ${entry.name}`);
|
|
349
353
|
} catch (err) {
|
|
@@ -39,6 +39,7 @@ import { MANAGED_MARKER_RE, MANIFEST_FILENAME, readSidecarManifest, writeSidecar
|
|
|
39
39
|
export function cleanupOldRuleFiles(rulesDir, opts = {}) {
|
|
40
40
|
const { dryRun = false, cleanRules = false, incomingFiles } = opts;
|
|
41
41
|
const removed = [];
|
|
42
|
+
if (opts.copyMode ?? opts.copyStandardSkills) return removed;
|
|
42
43
|
|
|
43
44
|
if (!fs.existsSync(rulesDir)) return removed;
|
|
44
45
|
if (!cleanRules) return removed;
|
|
@@ -8,7 +8,7 @@ import { getFrameworksForMode } from './base-framework-discovery.mjs';
|
|
|
8
8
|
|
|
9
9
|
/** Source-scoped cleanup also works when a removed standard skill is absent from this deploy's input. */
|
|
10
10
|
export function pruneMissingStandardSkills(destDir, opts) {
|
|
11
|
-
if (!destDir || !opts?.srcRoot || opts.dryRun || !fs.existsSync(destDir)) return 0;
|
|
11
|
+
if ((opts?.copyMode ?? opts?.copyStandardSkills) || !destDir || !opts?.srcRoot || opts.dryRun || !fs.existsSync(destDir)) return 0;
|
|
12
12
|
const sourceRoot = path.resolve(opts.srcRoot);
|
|
13
13
|
let pruned = 0;
|
|
14
14
|
for (const entry of fs.readdirSync(destDir, { withFileTypes: true })) {
|
|
@@ -99,6 +99,11 @@ export function deploySkillDir(skillDir, destDir, opts) {
|
|
|
99
99
|
};
|
|
100
100
|
if (fs.existsSync(destPath)) {
|
|
101
101
|
const destContent = fs.readFileSync(destPath, 'utf8');
|
|
102
|
+
if (previous?.managed?.[relative]?.hash && previous.managed[relative].hash !== `sha256:${contentHash(destContent)}`) {
|
|
103
|
+
managed[relative] = previous.managed[relative];
|
|
104
|
+
console.warn(`${opts.logicalOutputPath?.(destPath) || destPath}: kept (operator-edited)`);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
102
107
|
if (destContent === srcContent && !force) {
|
|
103
108
|
if (verbose) console.log(`skip (unchanged): ${path.relative(destDir, destPath)}`);
|
|
104
109
|
continue;
|
|
@@ -117,6 +122,9 @@ export function deploySkillDir(skillDir, destDir, opts) {
|
|
|
117
122
|
|
|
118
123
|
copyRecursive(skillDir, destSkillDir);
|
|
119
124
|
pruneRecordedSkillFiles(destSkillDir, previous?.managed, new Set(Object.keys(managed)), opts);
|
|
125
|
+
for (const [name, record] of Object.entries(previous?.managed || {})) {
|
|
126
|
+
if (!managed[name] && fs.existsSync(path.join(destSkillDir, name))) managed[name] = record;
|
|
127
|
+
}
|
|
120
128
|
writeSidecarManifest(destSkillDir, { managed, skillSource: path.resolve(skillDir) }, dryRun);
|
|
121
129
|
|
|
122
130
|
// Drop a `.aiwg-managed` marker so future cleanup runs can identify
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { removeSkillCopy } from './skill-copy-prune.mjs';
|
|
1
2
|
import { withModelWrapper } from './model-wrapper.mjs';
|
|
2
3
|
import { postDeploy } from './claude-post-deploy.mjs';
|
|
3
4
|
export { postDeploy };
|
|
@@ -267,7 +268,7 @@ function cleanupLegacyBuiltinCollisions(destDir, opts) {
|
|
|
267
268
|
if (!/^namespace:\s*aiwg\s*$/m.test(content)) continue;
|
|
268
269
|
|
|
269
270
|
try {
|
|
270
|
-
|
|
271
|
+
if (!removeSkillCopy(skillPath, opts)) continue;
|
|
271
272
|
if (opts.verbose) console.log(`removed legacy skill: ${name} (superseded by aiwg-${name})`);
|
|
272
273
|
} catch { /* non-fatal */ }
|
|
273
274
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { removeSkillCopy } from './skill-copy-prune.mjs';
|
|
1
2
|
import { withModelWrapper } from './model-wrapper.mjs';
|
|
2
3
|
import { postDeploy } from './codex-post-deploy.mjs';
|
|
3
4
|
export { postDeploy };
|
|
@@ -286,6 +287,7 @@ export async function deployCommands(targetDir, srcRoot, opts) {
|
|
|
286
287
|
if (opts.force) args.push('--force');
|
|
287
288
|
if (opts.mode) args.push('--mode', opts.mode);
|
|
288
289
|
if (opts.copyStandardSkills === true) args.push('--copy-all');
|
|
290
|
+
if (opts.copyMode === false) args.push('--index-mode');
|
|
289
291
|
// A copy-all the deployer forced on the caller's behalf (project-local
|
|
290
292
|
// bundles) still honors the startup listing cap (#2561).
|
|
291
293
|
if (opts.listingBudget === true) args.push('--listing-budget');
|
|
@@ -322,6 +324,7 @@ export async function deploySkills(targetDir, srcRoot, opts) {
|
|
|
322
324
|
if (opts.force) args.push('--force');
|
|
323
325
|
if (opts.mode) args.push('--mode', opts.mode);
|
|
324
326
|
if (opts.copyStandardSkills === true) args.push('--copy-all');
|
|
327
|
+
if (opts.copyMode === false) args.push('--index-mode');
|
|
325
328
|
// A copy-all the deployer forced on the caller's behalf (project-local
|
|
326
329
|
// bundles) still honors the startup listing cap (#2561).
|
|
327
330
|
if (opts.listingBudget === true) args.push('--listing-budget');
|
|
@@ -342,6 +345,7 @@ export async function deploySkills(targetDir, srcRoot, opts) {
|
|
|
342
345
|
* touched. The now-empty legacy dir is removed if AIWG owned everything in it.
|
|
343
346
|
*/
|
|
344
347
|
export function pruneLegacyCodexSkills(opts = {}, legacyDir = path.join(os.homedir(), '.codex', 'skills')) {
|
|
348
|
+
if (opts.copyMode ?? opts.copyStandardSkills) return 0;
|
|
345
349
|
let entries;
|
|
346
350
|
try {
|
|
347
351
|
entries = fs.readdirSync(legacyDir, { withFileTypes: true });
|
|
@@ -365,7 +369,7 @@ export function pruneLegacyCodexSkills(opts = {}, legacyDir = path.join(os.homed
|
|
|
365
369
|
if (opts.dryRun) {
|
|
366
370
|
console.log(`[dry-run] would prune legacy AIWG skill ${skillDir}`);
|
|
367
371
|
} else {
|
|
368
|
-
|
|
372
|
+
if (!removeSkillCopy(skillDir, opts)) continue;
|
|
369
373
|
}
|
|
370
374
|
pruned++;
|
|
371
375
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Resolve Flue bundle manifests and the invocation-wide app selection.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { resolveAiwgRoot } from './base-inventory.mjs';
|
|
5
|
+
import { getFrameworksForMode } from './base-framework-discovery.mjs';
|
|
6
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
7
|
+
const { frameworkRegistryId } = await importImpl(import.meta.url, 'config/framework-aliases.js');
|
|
8
|
+
|
|
9
|
+
export const camel = value => value.replace(/-([a-z0-9])/g, (_, char) => char.toUpperCase()).replace(/^[0-9]/, digit => `_${digit}`);
|
|
10
|
+
export function flueBundleInventory(opts) {
|
|
11
|
+
const root = resolveAiwgRoot(opts.srcRoot);
|
|
12
|
+
const bundles = [];
|
|
13
|
+
const add = dir => {
|
|
14
|
+
const file = path.join(dir, 'manifest.json');
|
|
15
|
+
if (!fs.existsSync(file)) return;
|
|
16
|
+
const manifest = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
17
|
+
const id = path.basename(dir);
|
|
18
|
+
bundles.push({ id, root: dir, manifest });
|
|
19
|
+
};
|
|
20
|
+
if (root) for (const group of ['frameworks', 'addons', 'extensions']) {
|
|
21
|
+
const dir = path.join(root, 'agentic/code', group);
|
|
22
|
+
if (fs.existsSync(dir)) for (const entry of fs.readdirSync(dir, { withFileTypes: true })) if (entry.isDirectory()) add(path.join(dir, entry.name));
|
|
23
|
+
}
|
|
24
|
+
for (const entry of Object.values(opts.config?.installed || {})) {
|
|
25
|
+
if (!entry.deployedTo?.flue || !entry.localPath || !opts.target) continue;
|
|
26
|
+
const logical = path.resolve(opts.logicalOutputPath?.(opts.target) || opts.target, entry.localPath);
|
|
27
|
+
const dir = opts.mapInputPath?.(logical) || logical;
|
|
28
|
+
if (!bundles.some(bundle => bundle.root === dir)) add(dir);
|
|
29
|
+
}
|
|
30
|
+
if (!bundles.some(bundle => path.resolve(bundle.root) === path.resolve(opts.srcRoot))) add(opts.srcRoot);
|
|
31
|
+
return bundles;
|
|
32
|
+
}
|
|
33
|
+
export function selectedFlueBundles(opts) {
|
|
34
|
+
const inventory = flueBundleInventory(opts);
|
|
35
|
+
const names = Object.entries(opts.config?.installed || {}).filter(([, entry]) => entry.deployedTo?.flue).map(([id]) => frameworkRegistryId(id));
|
|
36
|
+
const invoked = inventory.find(bundle => path.resolve(bundle.root) === path.resolve(opts.srcRoot));
|
|
37
|
+
if (invoked) names.push(invoked.id);
|
|
38
|
+
else names.push(...getFrameworksForMode(opts.srcRoot, opts.mode || 'sdlc').map(bundle => bundle.id));
|
|
39
|
+
// `all` preserves the existing kernel skill surface, including addon kernels.
|
|
40
|
+
if ((opts.mode === 'all' && !invoked) || names.includes('all')) names.push(...inventory.map(bundle => bundle.id));
|
|
41
|
+
return inventory.filter(bundle => names.includes(bundle.id)).sort((a, b) => a.id.localeCompare(b.id));
|
|
42
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Generate a portable remote connection resolved only inside Worker execution.
|
|
2
|
+
export function cloudflareTools({ fluePackage }) {
|
|
3
|
+
return `${fluePackage ? "import { createAiwgConnection } from '@aiwg/flue/tools';" : `import { defineMcpConnection } from '@flue/runtime';
|
|
4
|
+
function createAiwgConnection({ url, token }: { url: string; token: string }) {
|
|
5
|
+
return defineMcpConnection({ name: 'aiwg', url, auth: token, tools: ['discover', 'skill-show', 'artifact-write'] });
|
|
6
|
+
}`}
|
|
7
|
+
import { getCloudflareContext } from '@flue/runtime/cloudflare';
|
|
8
|
+
|
|
9
|
+
export function aiwgConnection() {
|
|
10
|
+
const { env } = getCloudflareContext();
|
|
11
|
+
const url = env.AIWG_MCP_URL;
|
|
12
|
+
const token = env.AIWG_MCP_TOKEN;
|
|
13
|
+
if (typeof url !== 'string' || !url || typeof token !== 'string' || !token) {
|
|
14
|
+
throw new Error('AIWG remote tools require Worker bindings AIWG_MCP_URL and AIWG_MCP_TOKEN');
|
|
15
|
+
}
|
|
16
|
+
return createAiwgConnection({ url, token });
|
|
17
|
+
}
|
|
18
|
+
export { bindRemoteSpecialist } from '${fluePackage ? '@aiwg/flue/specialists' : './remote-specialist.js'}';
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
6
|
+
const { providerCopyMode } = await importImpl(import.meta.url, 'providers/deployment-preservation.mjs');
|
|
7
|
+
const { deploymentOwner } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
5
8
|
|
|
6
9
|
const exists = file => { try { fs.lstatSync(file); return true; } catch (error) { if (error.code === 'ENOENT') return false; throw error; } };
|
|
7
10
|
const directory = file => exists(file) && fs.lstatSync(file).isDirectory();
|
|
@@ -11,10 +14,10 @@ const configFiles = ['ts', 'mts', 'mjs', 'js', 'cjs', 'cts'].map(ext => `flue.co
|
|
|
11
14
|
export function flueDeploymentFiles(target) {
|
|
12
15
|
const source = ['.flue', 'src'].find(dir => directory(path.join(target, dir))) || 'src';
|
|
13
16
|
// Snapshot config and conventional entries too: deployment reads a staged project.
|
|
14
|
-
return [...new Set([path.join(source, 'db.ts'), '.gitignore', 'src/aiwg/tools.ts', 'src/aiwg/specialists.ts',
|
|
15
|
-
...configFiles, ...databaseFiles()])];
|
|
17
|
+
return [...new Set([path.join(source, 'db.ts'), '.gitignore', 'src/aiwg/tools.ts', 'src/aiwg/specialists.ts', 'src/aiwg/skills.ts',
|
|
18
|
+
...configFiles, ...databaseFiles(), 'wrangler.jsonc', 'src/aiwg/remote-specialist.js', 'src/aiwg/remote-specialist.d.ts'])];
|
|
16
19
|
}
|
|
17
|
-
function
|
|
20
|
+
function configProperty(target, key) {
|
|
18
21
|
const config = configFiles.find(file => exists(path.join(target, file)));
|
|
19
22
|
if (!config) return;
|
|
20
23
|
// Static tokens only; comments and string/template contents cannot become keys.
|
|
@@ -34,8 +37,8 @@ function explicitDatabase(target) {
|
|
|
34
37
|
const nesting = [];
|
|
35
38
|
for (let index = start; index < code.length; index++) {
|
|
36
39
|
const token = code[index];
|
|
37
|
-
if (nesting.length === 1 && [
|
|
38
|
-
&& ['{', ','].includes(code[index - 1]) && code[index + 1] === ':') return config;
|
|
40
|
+
if (nesting.length === 1 && [key, `"${key}"`, `'${key}'`].includes(token)
|
|
41
|
+
&& ['{', ','].includes(code[index - 1]) && code[index + 1] === ':') return { config, value: code[index + 2] };
|
|
39
42
|
if (['{', '[', '('].includes(token)) nesting.push(token);
|
|
40
43
|
else if (['}', ']', ')'].includes(token)) {
|
|
41
44
|
nesting.pop();
|
|
@@ -43,6 +46,14 @@ function explicitDatabase(target) {
|
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
}
|
|
49
|
+
export function detectFlueTarget(target, { warn = false } = {}) {
|
|
50
|
+
const value = configProperty(target, 'target')?.value;
|
|
51
|
+
if (["'cloudflare'", '"cloudflare"', '`cloudflare`'].includes(value)) return 'cloudflare';
|
|
52
|
+
if (warn && exists(path.join(target, 'wrangler.jsonc'))) {
|
|
53
|
+
console.warn("Flue (experimental): wrangler.jsonc found without an explicit target: 'cloudflare' in flue.config.*; keeping Node deployment.");
|
|
54
|
+
}
|
|
55
|
+
return 'node';
|
|
56
|
+
}
|
|
46
57
|
export function claimRecordedFile(target, file, opts) {
|
|
47
58
|
if (!exists(file)) return false;
|
|
48
59
|
let record;
|
|
@@ -53,8 +64,36 @@ export function claimRecordedFile(target, file, opts) {
|
|
|
53
64
|
opts.writtenFiles?.push(file);
|
|
54
65
|
return true;
|
|
55
66
|
}
|
|
67
|
+
export function retireFlueTargetFiles(target, opts) {
|
|
68
|
+
const cloudflare = opts.flueTarget === 'cloudflare';
|
|
69
|
+
const candidates = cloudflare ? databaseFiles() : ['src/aiwg/remote-specialist.js', 'src/aiwg/remote-specialist.d.ts'];
|
|
70
|
+
const receiptFile = path.join(target, '.aiwg/.aiwg-manifest.json');
|
|
71
|
+
let receipt;
|
|
72
|
+
try { receipt = JSON.parse(fs.readFileSync(receiptFile, 'utf8')); } catch { receipt = {}; }
|
|
73
|
+
let changed = false;
|
|
74
|
+
for (const relative of candidates) {
|
|
75
|
+
const file = path.join(target, relative);
|
|
76
|
+
if (!exists(file)) continue;
|
|
77
|
+
const record = receipt.managed?.[relative.split(path.sep).join('/')];
|
|
78
|
+
const copy = (opts.copyMode ?? opts.copyStandardSkills) || (record?.owners || []).some(owner =>
|
|
79
|
+
providerCopyMode(target, 'flue', owner, opts.config, deploymentOwner(opts)));
|
|
80
|
+
const reason = copy ? 'copy mode' : cloudflare && record?.filePreimage?.present ? 'operator database module'
|
|
81
|
+
: !claimRecordedFile(target, file, {}) ? 'edited or unrecorded file' : undefined;
|
|
82
|
+
if (reason) {
|
|
83
|
+
console.warn(`Flue (experimental): keeping ${opts.logicalOutputPath?.(file) || file} (${reason}); remove this file manually if no longer needed for the new target.`);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (!opts.dryRun) {
|
|
87
|
+
fs.rmSync(file);
|
|
88
|
+
delete receipt.managed[relative.split(path.sep).join('/')];
|
|
89
|
+
changed = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (changed) (opts.writeReceipt || fs.writeFileSync)(receiptFile, `${JSON.stringify(receipt, null, 2)}\n`);
|
|
93
|
+
}
|
|
56
94
|
export function deployFlueDatabase(target, opts) {
|
|
57
|
-
|
|
95
|
+
if (detectFlueTarget(target) === 'cloudflare') return;
|
|
96
|
+
const config = configProperty(target, 'db')?.config;
|
|
58
97
|
if (config) {
|
|
59
98
|
console.warn(`Flue (experimental): keeping explicit db entry in ${config}; verify the operator module selects durable SQLite at .flue-state/state.db.`);
|
|
60
99
|
return;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Preserve operator skill directories before using the shared bundle copier.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
import { deploySkillDir } from './base-skill-copy.mjs';
|
|
6
|
+
export function deployFlueSkill(dir, destination, opts) {
|
|
7
|
+
const target = path.join(destination, path.basename(dir));
|
|
8
|
+
if (fs.existsSync(target)) {
|
|
9
|
+
let receipt;
|
|
10
|
+
try { receipt = JSON.parse(fs.readFileSync(path.join(target, '.aiwg-manifest.json'), 'utf8')); } catch { /* Unrecorded files are operator-owned. */ }
|
|
11
|
+
const managed = receipt?.managed;
|
|
12
|
+
const pristine = managed?.['SKILL.md'] && Object.entries(managed).every(([relative, record]) => {
|
|
13
|
+
const file = path.resolve(target, relative);
|
|
14
|
+
if (!file.startsWith(`${path.resolve(target)}${path.sep}`)) return false;
|
|
15
|
+
try {
|
|
16
|
+
return fs.lstatSync(file).isFile() && `sha256:${createHash('sha256').update(fs.readFileSync(file)).digest('hex')}` === record.hash;
|
|
17
|
+
} catch { return false; }
|
|
18
|
+
});
|
|
19
|
+
if (!pristine) {
|
|
20
|
+
console.warn(`Flue (experimental): keeping operator-edited or unrecorded skill ${opts.logicalOutputPath?.(target) || target}`);
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return deploySkillDir(dir, destination, opts);
|
|
25
|
+
}
|