@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,45 @@
|
|
|
1
|
+
// Generate static skill imports from selected bundles and actual deployed files.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { getFrameworksForMode } from './base-framework-discovery.mjs';
|
|
5
|
+
import { listSkillDirs } from './base-files.mjs';
|
|
6
|
+
import { skillMatchesProvider } from './base-models-platforms.mjs';
|
|
7
|
+
import { validateFlueSkill } from './flue-validation.mjs';
|
|
8
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
9
|
+
const { frameworkRegistryId } = await importImpl(import.meta.url, 'config/framework-aliases.js');
|
|
10
|
+
import { camel, selectedFlueBundles } from './flue-bundles.mjs';
|
|
11
|
+
|
|
12
|
+
function publishedSkill(bundle, name) {
|
|
13
|
+
if (!['frameworks', 'addons'].includes(path.basename(path.dirname(bundle.root)))) throw new Error(`${bundle.id}: @aiwg/flue publishes frameworks and addons only; use workspace copy mode`);
|
|
14
|
+
const file = path.join(bundle.root, bundle.manifest.entry?.skills || 'skills', name, 'SKILL.md');
|
|
15
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
16
|
+
if (!skillMatchesProvider(content, 'flue')) return false;
|
|
17
|
+
try { validateFlueSkill(content, file); return true; } catch (error) {
|
|
18
|
+
if (path.basename(path.dirname(bundle.root)) === 'frameworks') throw error;
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function generateFlueSkills(target, opts) {
|
|
23
|
+
const selected = selectedFlueBundles(opts);
|
|
24
|
+
const exact = selected.find(bundle => path.resolve(bundle.root) === path.resolve(opts.srcRoot));
|
|
25
|
+
const invoked = new Set(exact ? [exact.id] : getFrameworksForMode(opts.srcRoot, opts.mode || 'sdlc').map(bundle => bundle.id));
|
|
26
|
+
const all = opts.mode === 'all' && !exact;
|
|
27
|
+
const bundles = selected.filter(bundle => !(all && opts.fluePackage) || ['frameworks', 'addons'].includes(path.basename(path.dirname(bundle.root)))).map(bundle => {
|
|
28
|
+
const current = all || invoked.has(bundle.id);
|
|
29
|
+
const declared = Object.entries(opts.config?.installed || {}).find(([id]) => frameworkRegistryId(id) === bundle.id);
|
|
30
|
+
const packageMode = current ? opts.fluePackage : (declared ? declared[1].deployedTo?.flue?.package === true : opts.fluePackage);
|
|
31
|
+
return { ...bundle, packageMode,
|
|
32
|
+
skills: listSkillDirs(path.join(bundle.root, bundle.manifest.entry?.skills || 'skills'))
|
|
33
|
+
.map(dir => path.basename(dir)).filter(name => packageMode ? publishedSkill(bundle, name) : fs.existsSync(path.join(target, '.agents/skills', name, 'SKILL.md'))).sort(),
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
const packaged = new Set(bundles.filter(bundle => bundle.packageMode).flatMap(bundle => bundle.skills));
|
|
37
|
+
const names = [...new Set(bundles.flatMap(bundle => bundle.skills))].sort();
|
|
38
|
+
const exports = new Map();
|
|
39
|
+
for (const name of names) {
|
|
40
|
+
const identifier = camel(name);
|
|
41
|
+
if (!/^[a-zA-Z_$][\w$]*$/.test(identifier) || exports.has(identifier)) throw new Error(`Ambiguous Flue skill export: ${name}`);
|
|
42
|
+
exports.set(identifier, name);
|
|
43
|
+
}
|
|
44
|
+
return `// AIWG bundle skills; static imports are required by Flue.\nimport { useSkill } from '@flue/runtime';\n${names.map(name => `import ${camel(name)} from '${packaged.has(name) ? '@aiwg/flue/skills' : '../../.agents/skills'}/${name}/SKILL.md';`).join('\n')}\n\n${names.length ? `export { ${names.map(camel).join(', ')} };\n\n` : ''}${bundles.map(bundle => `export const ${camel(bundle.id === 'sdlc-complete' ? 'sdlc' : bundle.id)}Skills = [${bundle.skills.map(camel).join(', ')}] as const;`).join('\n')}\n\nexport function useAiwgSkills(...bundles: ReadonlyArray<readonly Parameters<typeof useSkill>[0][]>) {\n for (const skill of new Set(bundles.flat())) useSkill(skill);\n}\n`;
|
|
45
|
+
}
|
|
@@ -1,44 +1,57 @@
|
|
|
1
|
-
// Generate the
|
|
1
|
+
// Generate the selected Flue delegates from canonical agents and shared rule transforms.
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import {
|
|
5
|
+
import { camel, flueBundleInventory, selectedFlueBundles } from './flue-bundles.mjs';
|
|
6
|
+
import { generateFlueSkills } from './flue-skills.mjs';
|
|
6
7
|
import { parseFrontmatter } from './base-frontmatter.mjs';
|
|
7
8
|
import { injectBoundRules } from './base-contract.mjs';
|
|
8
9
|
import { claimRecordedFile } from './flue-project.mjs';
|
|
10
|
+
import { cloudflareTools } from './flue-cloudflare.mjs';
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
function specialists(bundles) {
|
|
13
|
+
return [...new Map(bundles.flatMap(bundle => (bundle.manifest.flue?.specialists || []).map(name =>
|
|
14
|
+
[name, { name, exportName: camel(name), file: `${name}.md`, root: bundle.root }]))).values()];
|
|
15
|
+
}
|
|
16
|
+
export const FLUE_SPECIALISTS = Object.freeze(specialists(flueBundleInventory({ srcRoot: fileURLToPath(new URL('../../../', import.meta.url)) }))
|
|
17
|
+
.map(({ root: _root, ...entry }) => Object.freeze(entry)));
|
|
14
18
|
|
|
15
19
|
export function generateFlueSpecialists(opts) {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const definitions =
|
|
19
|
-
const logical = path.join(
|
|
20
|
+
const cloudflare = opts.flueTarget === 'cloudflare';
|
|
21
|
+
const selected = specialists(selectedFlueBundles(opts));
|
|
22
|
+
const definitions = selected.map(specialist => {
|
|
23
|
+
const logical = path.join(specialist.root, 'agents', specialist.file);
|
|
20
24
|
const file = opts.mapInputPath?.(logical) || logical;
|
|
21
25
|
const { body, metadata } = parseFrontmatter(injectBoundRules(fs.readFileSync(file, 'utf8'), file, opts));
|
|
26
|
+
if (opts.packageOutput) return `export function ${specialist.exportName}(options) {
|
|
27
|
+
return createSpecialist({ name: ${JSON.stringify(specialist.name)}, description: ${JSON.stringify(metadata.description || metadata.name)}, agent() { return ${JSON.stringify(body.trim())}; } }, options);
|
|
28
|
+
}`;
|
|
22
29
|
return `export const ${specialist.exportName} = defineSubagent({
|
|
23
30
|
name: ${JSON.stringify(specialist.name)},
|
|
24
31
|
description: ${JSON.stringify(metadata.description || metadata.name)},
|
|
25
32
|
agent() {
|
|
26
|
-
useTool(aiwg_discover);
|
|
33
|
+
${cloudflare ? '' : `useTool(aiwg_discover);
|
|
27
34
|
useTool(aiwg_show);
|
|
28
|
-
useTool(aiwg_artifact_write)
|
|
35
|
+
useTool(aiwg_artifact_write);`}
|
|
29
36
|
return ${JSON.stringify(body.trim())};
|
|
30
37
|
},
|
|
31
38
|
});`;
|
|
32
39
|
});
|
|
40
|
+
if (opts.packageOutput) {
|
|
41
|
+
const bundles = selectedFlueBundles(opts);
|
|
42
|
+
const groups = bundles.map(bundle => ({ name: `${camel(bundle.id === 'sdlc-complete' ? 'sdlc' : bundle.id)}Specialists`, members: specialists([bundle]) }));
|
|
43
|
+
if (opts.declarations) return `import type { SubagentDefinition, McpConnectionDefinition } from '@flue/runtime';\nimport type { SpecialistOptions } from './specialist-binding.js';\nexport type { SpecialistOptions } from './specialist-binding.js';\nexport declare function bindRemoteSpecialist(definition: SubagentDefinition, connection: McpConnectionDefinition): SubagentDefinition;\n${selected.map(s => `export declare function ${s.exportName}(options?: SpecialistOptions): SubagentDefinition;`).join('\n')}\n${groups.map(g => `export declare function ${g.name}(options?: SpecialistOptions): SubagentDefinition[];`).join('\n')}\n`;
|
|
44
|
+
return `import { createSpecialist } from './specialist-binding.js';\nexport { bindRemoteSpecialist } from './remote-specialist.js';\n${definitions.join('\n\n')}\n${groups.map(g => `export function ${g.name}(options) { return [${g.members.map(s => `${s.exportName}(options)`).join(', ')}]; }`).join('\n')}\n`;
|
|
45
|
+
}
|
|
33
46
|
return `// Curated AIWG delegates; regenerate from canonical sdlc-complete agents.
|
|
34
|
-
import { defineSubagent, useSubagent, useTool } from '@flue/runtime';
|
|
35
|
-
import { aiwg_discover, aiwg_show, aiwg_artifact_write } from './tools.ts';
|
|
47
|
+
import { defineSubagent, useSubagent${cloudflare ? '' : ', useTool'} } from '@flue/runtime';
|
|
48
|
+
import { ${cloudflare ? 'aiwgConnection, bindRemoteSpecialist' : 'aiwg_discover, aiwg_show, aiwg_artifact_write'} } from './tools.ts';
|
|
36
49
|
|
|
37
50
|
${definitions.join('\n\n')}
|
|
38
51
|
|
|
39
52
|
/** Trusted app options: omit pins to inherit the app model and effort. */
|
|
40
|
-
export function useAiwgSpecialists(pins: {
|
|
41
|
-
${
|
|
53
|
+
export function useAiwgSpecialists(pins: { ${selected.map(({ exportName }) => `${exportName}?: string`).join('; ')} } = {}) {
|
|
54
|
+
${selected.map(({ exportName }) => ` useSubagent(${cloudflare ? 'bindRemoteSpecialist(' : ''}pins.${exportName} === undefined ? ${exportName} : { ...${exportName}, model: pins.${exportName} }${cloudflare ? ', aiwgConnection())' : ''});`).join('\n')}
|
|
42
55
|
}
|
|
43
56
|
`;
|
|
44
57
|
}
|
|
@@ -49,7 +62,7 @@ export function deployFlueSpecialists(target, opts) {
|
|
|
49
62
|
const file = path.join(target, relative);
|
|
50
63
|
if (fs.lstatSync(file, { throwIfNoEntry: false })) {
|
|
51
64
|
if (!claimRecordedFile(target, file, opts)) {
|
|
52
|
-
console.warn(`Flue (experimental): keeping existing module ${opts.logicalOutputPath?.(file) || file}
|
|
65
|
+
console.warn(`Flue (experimental): keeping existing module ${opts.logicalOutputPath?.(file) || file}; remove this file manually and redeploy to generate it for the current target.`);
|
|
53
66
|
return;
|
|
54
67
|
}
|
|
55
68
|
}
|
|
@@ -59,6 +72,11 @@ export function deployFlueSpecialists(target, opts) {
|
|
|
59
72
|
}
|
|
60
73
|
};
|
|
61
74
|
const template = fileURLToPath(new URL('../../../agentic/code/providers/flue/templates/aiwg/tools.ts', import.meta.url));
|
|
62
|
-
|
|
75
|
+
if (opts.flueTarget === 'cloudflare' && !opts.fluePackage) {
|
|
76
|
+
for (const ext of ['js', 'd.ts']) write(`src/aiwg/remote-specialist.${ext}`, () =>
|
|
77
|
+
fs.readFileSync(new URL(`../../../packages/flue/remote-specialist.${ext}`, import.meta.url), 'utf8'));
|
|
78
|
+
}
|
|
79
|
+
write('src/aiwg/tools.ts', () => opts.flueTarget === 'cloudflare' ? cloudflareTools(opts) : opts.fluePackage ? "export * from '@aiwg/flue/tools/node';\n" : fs.readFileSync(opts.mapInputPath?.(template) || template, 'utf8'));
|
|
63
80
|
write('src/aiwg/specialists.ts', () => generateFlueSpecialists(opts));
|
|
81
|
+
write('src/aiwg/skills.ts', () => generateFlueSkills(target, opts));
|
|
64
82
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Validate the static skill contract shared by package builds and deployments.
|
|
2
|
+
import { parse } from 'yaml';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
export function validateFlueSkill(content, file) {
|
|
5
|
+
const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
|
6
|
+
let metadata;
|
|
7
|
+
try { metadata = frontmatter && parse(frontmatter[1]); }
|
|
8
|
+
catch (error) { throw new Error(`${file}: invalid Flue frontmatter: ${error.message}`); }
|
|
9
|
+
if (metadata?.name !== path.basename(path.dirname(file))) throw new Error(`${file}: Flue skill name must equal its directory`);
|
|
10
|
+
if (typeof metadata.description !== 'string' || metadata.description.length < 1 || metadata.description.length > 1024) {
|
|
11
|
+
throw new Error(`${file}: Flue skill description must contain 1-1024 characters`);
|
|
12
|
+
}
|
|
13
|
+
return metadata;
|
|
14
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Deploy the experimental Flue app target through shared skills and context owners.
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { importImpl } from '../../_resolve-impl.mjs';
|
|
4
|
-
import { collectFrameworkArtifacts,
|
|
4
|
+
import { collectFrameworkArtifacts, listSkillDirs, getAddonSkillDirs,
|
|
5
5
|
isKernelSkill, normalizeDeploymentMode, withRuleDeployment } from './base.mjs';
|
|
6
|
-
import {
|
|
6
|
+
import { deployFlueSkill } from './flue-skill-copy.mjs';
|
|
7
|
+
import { flueDeploymentFiles, deployFlueDatabase, detectFlueTarget, retireFlueTargetFiles } from './flue-project.mjs';
|
|
7
8
|
import { deployFlueSpecialists } from './flue-specialists.mjs';
|
|
8
9
|
export { FLUE_SPECIALISTS } from './flue-specialists.mjs';
|
|
9
10
|
const { generate } = await importImpl(import.meta.url, 'smiths/context-pipeline/generator.js');
|
|
@@ -22,13 +23,15 @@ export const deployCommands = () => 0;
|
|
|
22
23
|
export const deployRules = () => 0;
|
|
23
24
|
|
|
24
25
|
export function deploySkills(skillDirs, target, opts) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
if (opts.fluePackage) return { kernel: 0, standard: 0 };
|
|
27
|
+
const destination = path.join(target, kernelSkillsPath);
|
|
28
|
+
for (const dir of skillDirs) deployFlueSkill(dir, destination, opts);
|
|
29
|
+
return { kernel: skillDirs.length, standard: 0 };
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export async function postDeploy(target, opts) {
|
|
33
|
+
opts = { ...opts, flueTarget: detectFlueTarget(target, { warn: true }) };
|
|
34
|
+
retireFlueTargetFiles(target, opts);
|
|
32
35
|
deployFlueDatabase(target, opts);
|
|
33
36
|
deployFlueSpecialists(target, opts);
|
|
34
37
|
if (opts.contextFiles !== false) await generate({ provider: name, projectPath: target, sections: [], detectExistingFiles: true });
|
|
@@ -38,9 +41,10 @@ export async function deploy(opts) {
|
|
|
38
41
|
if (opts.userScope) throw new Error('Flue (experimental) supports project scope only.');
|
|
39
42
|
return withRuleDeployment({ ...opts, provider: name }, provider, async staged => {
|
|
40
43
|
const mode = normalizeDeploymentMode(staged.mode);
|
|
41
|
-
const
|
|
44
|
+
const invoked = listSkillDirs(path.join(staged.srcRoot, 'skills'));
|
|
45
|
+
const skills = [...invoked, ...(mode === 'all' ? getAddonSkillDirs(staged.srcRoot) : []),
|
|
42
46
|
...collectFrameworkArtifacts(staged.srcRoot, mode, { includeAgents: false, includeCommands: false, includeSkills: true, includeRules: false }).skills];
|
|
43
|
-
const count = deploySkills(skills, staged.target, staged);
|
|
47
|
+
const count = deploySkills(mode === 'all' && !invoked.length ? skills.filter(isKernelSkill) : skills, staged.target, staged);
|
|
44
48
|
await postDeploy(staged.target, staged);
|
|
45
49
|
return count.kernel;
|
|
46
50
|
});
|
|
@@ -81,6 +81,7 @@ function updateBundledManifest(kernelSkillNames, opts) {
|
|
|
81
81
|
* directories under ~/.hermes/
|
|
82
82
|
*/
|
|
83
83
|
function migrateLegacySkillPath(opts) {
|
|
84
|
+
if (opts.copyMode ?? opts.copyStandardSkills) return;
|
|
84
85
|
const { dryRun, quiet } = opts;
|
|
85
86
|
// Resolve through the same HERMES_HOME contract as every other path in
|
|
86
87
|
// this provider (env var first, platform default otherwise): with
|
|
@@ -216,6 +216,19 @@ export function finishBindings(opts, provider) {
|
|
|
216
216
|
const name = skill ? path.basename(path.dirname(file)) : path.basename(file).replace(/\.(md|toml)$/, '');
|
|
217
217
|
const sidecarPath = path.join(skill ? path.dirname(file) : path.dirname(file), '.aiwg-manifest.json');
|
|
218
218
|
const sidecar = fs.existsSync(sidecarPath) ? JSON.parse(read(sidecarPath)) : null;
|
|
219
|
+
const record = sidecar?.managed?.[path.basename(file)];
|
|
220
|
+
const priorBytes = opts.ownershipBefore?.get(file);
|
|
221
|
+
const priorSidecar = opts.ownershipBefore?.get(sidecarPath);
|
|
222
|
+
const prior = priorSidecar && JSON.parse(priorSidecar.toString()).managed?.[path.basename(file)];
|
|
223
|
+
// Check the pre-deploy claim too: a helper may have rewritten its sidecar
|
|
224
|
+
// or overwritten an edit that preservation will restore after binding.
|
|
225
|
+
const editedBefore = prior && priorBytes && prior.hash !== `sha256:${contentHash(priorBytes)}`;
|
|
226
|
+
const emitted = opts.ownershipBefore && (!priorBytes || !priorBytes.equals(Buffer.from(content)));
|
|
227
|
+
const editedNow = (record || provider.name === 'flue') && record?.hash !== `sha256:${contentHash(content)}`;
|
|
228
|
+
if (editedBefore || !emitted && editedNow) {
|
|
229
|
+
console.warn(`${provider.name}: keeping operator-edited binding target ${opts.logicalOutputPath?.(file) || file}`);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
219
232
|
// Wrapper source identity is ownership metadata. Preserve the legacy
|
|
220
233
|
// flow-only name lookup instead of selecting new skill binding targets.
|
|
221
234
|
const wrapper = !skill && sidecar?.managed?.[path.basename(file)]?.kind === 'skill-command';
|
|
@@ -268,7 +281,7 @@ export function finishBindings(opts, provider) {
|
|
|
268
281
|
/** Bindings annotate the selected deployment; they do not select standard skills
|
|
269
282
|
* (ADR lines 102–108). Flow projections follow the same opt-in and tier routing. */
|
|
270
283
|
export function projectBoundFlowSkills(opts, provider, selected) {
|
|
271
|
-
if (provider.name === 'flue') return; //
|
|
284
|
+
if (provider.name === 'flue') return; // Flue deploys authored bundle skills; command projections remain index-only.
|
|
272
285
|
opts.flowSkillSources = new Map();
|
|
273
286
|
if (opts.rulesOnly || opts.commandsOnly || !(opts.deploySkills || opts.skillsOnly)) return;
|
|
274
287
|
const kernel = path.isAbsolute(provider.kernelSkillsPath || '') ? opts.kernelSkillsPath
|
|
@@ -295,6 +308,7 @@ export function projectBoundFlowSkills(opts, provider, selected) {
|
|
|
295
308
|
const stale = receipt?.flowSource && (opts.copyStandardSkills !== true
|
|
296
309
|
|| !sources.has(receipt.flowSource) || root !== standard);
|
|
297
310
|
if (!legacy && !stale) continue;
|
|
311
|
+
if (opts.copyMode ?? opts.copyStandardSkills) continue;
|
|
298
312
|
fs.rmSync(file, { force: true });
|
|
299
313
|
if (receipt?.flowSource) {
|
|
300
314
|
fs.rmSync(receiptFile, { force: true });
|
|
@@ -102,11 +102,25 @@ export function commitRuleDeploymentPlan(plan) {
|
|
|
102
102
|
else fs.writeFileSync(path.join(from, rel), output);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
+
// A root file missing from the stage is removed only when the deploy retired it
|
|
106
|
+
// deliberately: the target receipt records it, it is unchanged since, and the
|
|
107
|
+
// staged receipt dropped the record. Copy mode never drops records, so never deletes.
|
|
108
|
+
const receiptOf = root => { try { return JSON.parse(fs.readFileSync(path.join(root, '.aiwg/.aiwg-manifest.json'), 'utf8')).managed || {}; } catch { return {}; } };
|
|
109
|
+
const recordedBefore = receiptOf(target), recordedAfter = receiptOf(stage);
|
|
110
|
+
const retired = name => {
|
|
111
|
+
const key = name.split(path.sep).join('/');
|
|
112
|
+
const record = recordedBefore[key];
|
|
113
|
+
if (!record || recordedAfter[key]) return false;
|
|
114
|
+
try { return record.hash === `sha256:${contentHash(fs.readFileSync(path.join(target, name)))}`; } catch { return false; }
|
|
115
|
+
};
|
|
105
116
|
for (const name of rootNames) if (fs.existsSync(path.join(stage, name))) {
|
|
106
117
|
const output = normalizeReceipt(path.join(stage, name), Buffer.from(normalize(read(path.join(stage, name))))).toString('utf8');
|
|
107
118
|
if (output === read(path.join(target, name))) continue;
|
|
108
119
|
const write = plan.contextWrites.includes(path.join(stage, name)) ? writeContextFileSync : put;
|
|
109
120
|
write(path.join(target, name), output);
|
|
121
|
+
} else if (plan.preimages.some(item => item.path === path.join(target, name) && item.state.kind !== 'missing')) {
|
|
122
|
+
if (retired(name)) fs.rmSync(path.join(target, name), { force: true });
|
|
123
|
+
else console.warn(`Keeping ${path.join(target, name)}: not a recorded, unchanged AIWG copy retired by this deploy.`);
|
|
110
124
|
}
|
|
111
125
|
return plan.report;
|
|
112
126
|
} finally {
|
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
} from './rule-deployment-state.mjs';
|
|
47
47
|
import { inlineStartup, projectRules } from './rule-projection.mjs';
|
|
48
48
|
const { captureDeploymentOutputs, recordDeploymentOutputs } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
49
|
+
const { preserveDeploymentOutputs } = await importImpl(import.meta.url, 'providers/deployment-preservation.mjs');
|
|
49
50
|
import { retireInlineStartup } from './rule-startup.mjs';
|
|
50
51
|
|
|
51
52
|
/** Stage only provider/context output, never the user's source tree. On failure
|
|
@@ -339,6 +340,7 @@ export async function prepareRuleDeployment(original, provider, deploy) {
|
|
|
339
340
|
flueDatabaseFile: provider.name === 'flue' ? provider.deploymentFiles(target)[0] : undefined, kernelSkillsPath: kernel, deploymentHome: home, activeWorkspace, hermesLegacySkills, legacyCodexSkills, staging: true };
|
|
340
341
|
const ownershipRoots = [stage, ...mappings.map(mapping => mapping.to)];
|
|
341
342
|
const ownershipBefore = captureDeploymentOutputs(ownershipRoots);
|
|
343
|
+
opts.ownershipBefore = ownershipBefore;
|
|
342
344
|
if (!opts.deferRuleProjection && (opts.kernelOnly || opts.deployRules || opts.rulesOnly ||
|
|
343
345
|
(!opts.skillsOnly && !opts.commandsOnly && (inlineStartup[provider.name] || ['hermes', 'warp'].includes(provider.name))))) retireInlineStartup(opts, provider);
|
|
344
346
|
await deploySelectedSurface(opts, provider, deploy);
|
|
@@ -371,6 +373,7 @@ export async function prepareRuleDeployment(original, provider, deploy) {
|
|
|
371
373
|
if (opts.kernelOnly || opts.deployRules || opts.rulesOnly || (!opts.skillsOnly && !opts.commandsOnly && (inlineStartup[provider.name] || ['hermes', 'warp'].includes(provider.name)))) projectRules(opts, provider);
|
|
372
374
|
finishBindings(opts, provider);
|
|
373
375
|
}
|
|
376
|
+
preserveDeploymentOutputs(ownershipBefore, ownershipRoots, opts);
|
|
374
377
|
// Normalize all generated path wrappers before counting or promoting bytes.
|
|
375
378
|
const normalize = content => {
|
|
376
379
|
for (const mapping of [...mappings].sort((a, b) => b.to.length - a.to.length)) content = content.split(mapping.to).join(mapping.from);
|
|
@@ -427,6 +430,7 @@ export async function prepareRuleDeployment(original, provider, deploy) {
|
|
|
427
430
|
for (const name of rootNames) {
|
|
428
431
|
const file = path.join(stage, name);
|
|
429
432
|
if (fs.existsSync(file) && normalize(read(file)) !== read(path.join(target, name))) console.log(`[dry-run] Would write ${path.join(target, name)}`);
|
|
433
|
+
else if (!fs.existsSync(file) && fs.existsSync(path.join(target, name))) console.log(`[dry-run] Would remove ${path.join(target, name)}`);
|
|
430
434
|
}
|
|
431
435
|
console.log(`[dry-run] Planned ${provider.name} deployment: ${guarded.report.selected_bytes} startup bytes; no output promoted.`);
|
|
432
436
|
return { report: guarded.report, noop: true };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Retire skill copies using recorded hashes, with legacy marker support in index mode.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
export function removeSkillCopy(dir, opts = {}) {
|
|
6
|
+
const copyMode = opts.copyMode ?? opts.copyStandardSkills;
|
|
7
|
+
if (copyMode && !opts.tierMove) return false;
|
|
8
|
+
// A copy-mode tier move only replaces: the new-tier copy must already exist.
|
|
9
|
+
if (copyMode && opts.tierMove && !(opts.replacement && fs.existsSync(path.join(opts.replacement, 'SKILL.md')))) {
|
|
10
|
+
console.warn(`${opts.logicalOutputPath?.(dir) || dir}: kept (replacement copy missing)`);
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const keep = reason => {
|
|
14
|
+
console.warn(`${opts.logicalOutputPath?.(dir) || dir}: kept (${reason})`);
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
let receipt;
|
|
18
|
+
try { receipt = JSON.parse(fs.readFileSync(path.join(dir, '.aiwg-manifest.json'), 'utf8')); }
|
|
19
|
+
catch (error) {
|
|
20
|
+
// Only a missing receipt may use legacy ownership. An invalid receipt must
|
|
21
|
+
// not turn an edited copy into a marker-only deletion candidate.
|
|
22
|
+
if (error.code !== 'ENOENT') return keep('unverifiable ownership');
|
|
23
|
+
if (copyMode || !fs.existsSync(path.join(dir, '.aiwg-managed'))) return keep('unverifiable ownership');
|
|
24
|
+
if (!opts.dryRun) fs.rmSync(dir, { recursive: true, force: true });
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
if (!receipt?.managed?.['SKILL.md']?.hash) return keep('unverifiable ownership');
|
|
28
|
+
const walk = root => fs.readdirSync(root, { withFileTypes: true }).flatMap(entry => {
|
|
29
|
+
const file = path.join(root, entry.name);
|
|
30
|
+
return entry.isDirectory() ? walk(file) : [file];
|
|
31
|
+
});
|
|
32
|
+
const payload = walk(dir).filter(file => {
|
|
33
|
+
const name = path.relative(dir, file);
|
|
34
|
+
return name !== '.aiwg-manifest.json' && (name !== '.aiwg-managed' || receipt.managed[name]);
|
|
35
|
+
});
|
|
36
|
+
const safe = payload.length === Object.keys(receipt.managed).length && payload.every(file => {
|
|
37
|
+
const name = path.relative(dir, file);
|
|
38
|
+
return fs.lstatSync(file).isFile() && receipt.managed[name]?.hash === `sha256:${createHash('sha256').update(fs.readFileSync(file)).digest('hex')}`;
|
|
39
|
+
});
|
|
40
|
+
if (!safe) return keep('operator-edited or unrecorded files');
|
|
41
|
+
if (!opts.dryRun) {
|
|
42
|
+
if (opts.tierMove) for (const file of walk(dir)) {
|
|
43
|
+
opts.replacedSkillCopies?.add(path.resolve(file));
|
|
44
|
+
opts.replacedSkillCopies?.add(path.resolve(opts.logicalOutputPath?.(file) || file));
|
|
45
|
+
}
|
|
46
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
@@ -48,6 +48,7 @@ export function bulkInstallOwnsFlatArtifacts(target) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
export function pruneStaleAiwgArtifacts(provider, target, srcRoot, opts, explicitSource) {
|
|
51
|
+
if (opts.copyMode ?? opts.copyStandardSkills) return;
|
|
51
52
|
if (opts.skillsOnly && !opts.kernelOnly) return; // skills run their own prune in the provider
|
|
52
53
|
|
|
53
54
|
const aiwgRoot = resolveAiwgRoot(srcRoot);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Update Codex's generated metadata with the same integrity receipts as skill payloads.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { contentHash, readSidecarManifest, writeSidecarManifest } from '../agents/providers/base-files.mjs';
|
|
5
|
+
export function writeCodexSkillMetadata(skillDir, content) {
|
|
6
|
+
const relative = 'agents/openai.yaml';
|
|
7
|
+
const file = path.join(skillDir, relative);
|
|
8
|
+
const receipt = readSidecarManifest(skillDir) || { managed: {} };
|
|
9
|
+
const record = receipt.managed?.[relative];
|
|
10
|
+
if (fs.existsSync(file)) {
|
|
11
|
+
const current = fs.readFileSync(file, 'utf8');
|
|
12
|
+
if (record?.hash ? record.hash !== `sha256:${contentHash(current)}` : current !== content) {
|
|
13
|
+
console.warn(`${file}: kept (operator-edited or unrecorded metadata)`);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
18
|
+
fs.writeFileSync(file, content, 'utf8');
|
|
19
|
+
receipt.managed ??= {};
|
|
20
|
+
receipt.managed[relative] = { ...record, hash: `sha256:${contentHash(content)}` };
|
|
21
|
+
writeSidecarManifest(skillDir, receipt, false);
|
|
22
|
+
}
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
* --force Overwrite existing files
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
+
import { removeSkillCopy } from '../agents/providers/skill-copy-prune.mjs';
|
|
33
34
|
import realFs from 'fs';
|
|
34
35
|
import { createRequire } from 'module';
|
|
35
36
|
const _require = createRequire(import.meta.url);
|
|
@@ -40,6 +41,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
40
41
|
import os from 'os';
|
|
41
42
|
import { deploySkillDir, getFrameworksForMode, normalizeDeploymentMode, isKernelSkill } from '../agents/providers/base.mjs';
|
|
42
43
|
|
|
44
|
+
import { writeCodexSkillMetadata } from './codex-skill-metadata.mjs';
|
|
43
45
|
import { stripWrappingQuotes, transformToCodexSkill } from './codex-skill-transform.mjs';
|
|
44
46
|
const LEGACY_RENAMED_SKILLS = new Set(['aiwg-mcp']);
|
|
45
47
|
|
|
@@ -131,6 +133,7 @@ function parseArgs(args, homeDir) {
|
|
|
131
133
|
else if (a === '--mode' && args[i + 1]) cfg.mode = String(args[++i]).toLowerCase();
|
|
132
134
|
else if (a === '--dry-run') cfg.dryRun = true;
|
|
133
135
|
else if (a === '--force') cfg.force = true;
|
|
136
|
+
else if (a === '--index-mode') cfg.indexMode = true;
|
|
134
137
|
else if (a === '--copy-all' || a === '--copy-standard-skills') cfg.copyStandardSkills = true;
|
|
135
138
|
else if (a === '--listing-cap' && args[i + 1]) { cfg.listingCap = Math.max(0, Number(args[++i]) || 0); cfg.listingCapExplicit = true; }
|
|
136
139
|
else if (a === '--standard-target' && args[i + 1]) cfg.standardTarget = path.resolve(args[++i]);
|
|
@@ -172,7 +175,6 @@ function findSkillDirs(baseDir) {
|
|
|
172
175
|
function deploySkill(skill, targetDir, opts) {
|
|
173
176
|
const { force = false, dryRun = false } = opts;
|
|
174
177
|
const skillDir = path.join(targetDir, skill.name);
|
|
175
|
-
const metadataPath = path.join(skillDir, 'agents', 'openai.yaml');
|
|
176
178
|
|
|
177
179
|
if (dryRun) {
|
|
178
180
|
console.log(` [dry-run] deploy: ${skill.name}`);
|
|
@@ -186,12 +188,11 @@ function deploySkill(skill, targetDir, opts) {
|
|
|
186
188
|
|
|
187
189
|
// Use the same whole-folder copier and ownership receipt as other providers.
|
|
188
190
|
const deployed = deploySkillDir(path.dirname(skill.sourcePath), targetDir, {
|
|
189
|
-
force, dryRun, provider: 'codex', skillName: skill.name,
|
|
191
|
+
...opts, force, dryRun, provider: 'codex', skillName: skill.name,
|
|
190
192
|
transformSkillMd: () => skill.content,
|
|
191
193
|
});
|
|
192
194
|
if (deployed === false) return { action: 'skip', reason: 'ownership' };
|
|
193
|
-
|
|
194
|
-
fs.writeFileSync(metadataPath, skill.metadataContent, 'utf8');
|
|
195
|
+
writeCodexSkillMetadata(skillDir, skill.metadataContent);
|
|
195
196
|
console.log(` deployed: ${skill.name}`);
|
|
196
197
|
|
|
197
198
|
return { action: 'deploy', reason: 'success' };
|
|
@@ -376,7 +377,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
376
377
|
console.log(`\n${item.label} (${planned.filter((p) => p.label === item.label).length} skills):`);
|
|
377
378
|
}
|
|
378
379
|
const demoted = budget.demoted.has(item);
|
|
379
|
-
const result = deploySkill(item.skill, demoted ? standardTarget : target, { force, dryRun });
|
|
380
|
+
const result = deploySkill(item.skill, demoted ? standardTarget : target, { force, dryRun, copyStandardSkills, copyMode: copyStandardSkills && !cfg.indexMode });
|
|
380
381
|
if (demoted) console.log(` ↳ standard tier (${path.relative(process.cwd(), standardTarget) || standardTarget}) — startup listing budget`);
|
|
381
382
|
if (result.action === 'deploy') totalDeployed++;
|
|
382
383
|
else totalSkipped++;
|
|
@@ -406,7 +407,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
406
407
|
// skills can delete the kernel skills installed by the preceding full-root
|
|
407
408
|
// Codex pass, leaving `.agents/skills/` empty while `aiwg use` still exits 0.
|
|
408
409
|
let totalPruned = 0;
|
|
409
|
-
if (fs.existsSync(target)) {
|
|
410
|
+
if ((!copyStandardSkills || cfg.indexMode) && fs.existsSync(target)) {
|
|
410
411
|
const targetEntries = fs.readdirSync(target, { withFileTypes: true });
|
|
411
412
|
for (const entry of targetEntries) {
|
|
412
413
|
if (!entry.isDirectory()) continue;
|
|
@@ -445,7 +446,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
445
446
|
if (dryRun) {
|
|
446
447
|
console.log(` [dry-run] would prune stale skill: ${name}`);
|
|
447
448
|
} else {
|
|
448
|
-
|
|
449
|
+
if (!removeSkillCopy(full, { ...cfg, copyMode: copyStandardSkills && !cfg.indexMode })) continue;
|
|
449
450
|
}
|
|
450
451
|
totalPruned++;
|
|
451
452
|
}
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
},
|
|
155
155
|
"installed": {
|
|
156
156
|
"type": "object",
|
|
157
|
-
"description": "
|
|
157
|
+
"description": "Declared bundles per provider, including pending deployments",
|
|
158
158
|
"additionalProperties": {
|
|
159
159
|
"$ref": "#/definitions/InstalledFramework"
|
|
160
160
|
}
|
|
@@ -3231,29 +3231,54 @@
|
|
|
3231
3231
|
},
|
|
3232
3232
|
"InstalledFramework": {
|
|
3233
3233
|
"type": "object",
|
|
3234
|
-
"description": "
|
|
3234
|
+
"description": "A bundle declaration; empty provider counts mean pending deployment",
|
|
3235
|
+
"required": ["deployedTo"],
|
|
3235
3236
|
"properties": {
|
|
3236
|
-
"version": {
|
|
3237
|
-
|
|
3238
|
-
|
|
3237
|
+
"version": { "type": "string" },
|
|
3238
|
+
"source": { "type": "string" },
|
|
3239
|
+
"installedAt": { "type": "string", "format": "date-time" },
|
|
3240
|
+
"manifestHash": { "type": "string" },
|
|
3241
|
+
"localPath": { "type": "string" },
|
|
3242
|
+
"localType": { "type": "string" },
|
|
3243
|
+
"manifestVersion": { "type": "string" },
|
|
3244
|
+
"artifactHashes": { "type": "object", "additionalProperties": { "type": "string" } },
|
|
3245
|
+
"deployedArtifactHashes": {
|
|
3246
|
+
"type": "object",
|
|
3247
|
+
"additionalProperties": { "type": "object", "additionalProperties": { "type": "string" } }
|
|
3239
3248
|
},
|
|
3240
|
-
"
|
|
3241
|
-
"type": "
|
|
3242
|
-
"
|
|
3243
|
-
"
|
|
3244
|
-
"type": "
|
|
3249
|
+
"deployedTo": {
|
|
3250
|
+
"type": "object",
|
|
3251
|
+
"allOf": [{ "patternProperties": { "^(?!flue$)": { "type": "object", "properties": { "package": false } } } }],
|
|
3252
|
+
"additionalProperties": {
|
|
3253
|
+
"type": "object",
|
|
3254
|
+
"properties": {
|
|
3255
|
+
"agents": { "type": "integer", "minimum": 0 },
|
|
3256
|
+
"commands": { "type": "integer", "minimum": 0 },
|
|
3257
|
+
"skills": { "type": "integer", "minimum": 0 },
|
|
3258
|
+
"rules": { "type": "integer", "minimum": 0 },
|
|
3259
|
+
"entries": { "type": "object" },
|
|
3260
|
+
"skipUtils": { "type": "boolean", "description": "Effective --no-utils flag at deployment" },
|
|
3261
|
+
"kernelOnly": { "type": "boolean", "description": "Effective kernel-only deployment scope" },
|
|
3262
|
+
"copy": { "type": "boolean", "description": "Keep project copies during refresh/update; only explicit remove deletes them" },
|
|
3263
|
+
"package": { "type": "boolean", "description": "Import Flue skills from @aiwg/flue instead of copying them" }
|
|
3264
|
+
},
|
|
3265
|
+
"additionalProperties": false,
|
|
3266
|
+
"anyOf": [
|
|
3267
|
+
{ "propertyNames": { "enum": ["copy", "package", "skipUtils", "kernelOnly"] } },
|
|
3268
|
+
{ "required": ["agents", "commands", "skills", "rules"], "properties": { "agents": {}, "commands": {}, "skills": {}, "rules": {} } }
|
|
3269
|
+
]
|
|
3245
3270
|
}
|
|
3246
|
-
},
|
|
3247
|
-
"installedAt": {
|
|
3248
|
-
"type": "string",
|
|
3249
|
-
"format": "date-time",
|
|
3250
|
-
"description": "ISO 8601 timestamp of installation"
|
|
3251
|
-
},
|
|
3252
|
-
"source": {
|
|
3253
|
-
"type": "string",
|
|
3254
|
-
"description": "Source registry or path"
|
|
3255
3271
|
}
|
|
3256
3272
|
},
|
|
3273
|
+
"anyOf": [
|
|
3274
|
+
{
|
|
3275
|
+
"properties": {
|
|
3276
|
+
"version": false, "source": false, "installedAt": false,
|
|
3277
|
+
"deployedTo": { "type": "object", "additionalProperties": { "type": "object", "propertyNames": { "enum": ["copy", "package", "skipUtils", "kernelOnly"] } } }
|
|
3278
|
+
}
|
|
3279
|
+
},
|
|
3280
|
+
{ "required": ["version", "source", "installedAt"], "properties": { "version": {}, "source": {}, "installedAt": {} } }
|
|
3281
|
+
],
|
|
3257
3282
|
"additionalProperties": false
|
|
3258
3283
|
}
|
|
3259
3284
|
}
|