@aiwg/cli 2026.10.18 → 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/agentic/code/providers/capability-matrix.yaml +51 -0
- package/agentic/code/providers/flue/README.md +62 -0
- package/agentic/code/providers/flue/templates/aiwg/tools.ts +120 -0
- package/agentic/code/providers/model-capabilities.v1.json +23 -0
- package/agentic/code/providers/model-catalog.v1.json +9 -0
- package/dist/src/artifacts/corpus-tools/resolve.js +7 -2
- 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/help.js +1 -1
- package/dist/src/cli/handlers/init.js +1 -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 +53 -102
- package/dist/src/cli/services/deployment-verification.js +5 -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/memory/provider-memory-adapter.js +1 -0
- package/dist/src/models/model-capabilities.v1.json +23 -0
- package/dist/src/models/model-catalog.v1.json +9 -0
- package/dist/src/models/policy-resources.js +1 -1
- package/dist/src/providers/capability-matrix.yaml +51 -0
- package/dist/src/providers/deployment-ownership.d.mts +2 -1
- package/dist/src/providers/deployment-ownership.mjs +27 -3
- 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 +26 -2
- package/dist/src/providers/flue-package-mode.js +19 -0
- package/dist/src/providers/provider-context-contracts.js +8 -0
- package/dist/src/providers/provider-definition-schema.js +1 -0
- package/dist/src/providers/provider-definitions.js +1 -0
- package/dist/src/providers/provider-seeds-3.js +18 -0
- package/dist/src/providers/skill-ownership.d.mts +1 -0
- package/dist/src/providers/skill-ownership.mjs +1 -0
- package/dist/src/research/reference-match.js +33 -6
- package/dist/src/skills/deployment-ownership.js +2 -2
- package/dist/src/skills/deployment-policy.js +9 -0
- package/dist/src/smiths/context-pipeline/flue-context.js +25 -0
- package/dist/src/smiths/context-pipeline/generator.js +6 -1
- package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +9 -7
- package/package.json +3 -1
- package/tools/agents/deploy-agents.mjs +11 -4
- package/tools/agents/deploy-options.mjs +11 -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 +118 -0
- 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 +82 -0
- package/tools/agents/providers/flue-validation.mjs +14 -0
- package/tools/agents/providers/flue.mjs +54 -0
- package/tools/agents/providers/hermes-skill-lifecycle.mjs +1 -0
- package/tools/agents/providers/rule-delivery-surface.mjs +16 -1
- package/tools/agents/providers/rule-deployment-commit.mjs +14 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +6 -1
- package/tools/agents/providers/rule-startup.mjs +3 -3
- package/tools/agents/providers/skill-copy-prune.mjs +49 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +1 -0
- package/tools/agents/use-rule-selection.mjs +17 -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,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
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Deploy the experimental Flue app target through shared skills and context owners.
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
4
|
+
import { collectFrameworkArtifacts, listSkillDirs, getAddonSkillDirs,
|
|
5
|
+
isKernelSkill, normalizeDeploymentMode, withRuleDeployment } from './base.mjs';
|
|
6
|
+
import { deployFlueSkill } from './flue-skill-copy.mjs';
|
|
7
|
+
import { flueDeploymentFiles, deployFlueDatabase, detectFlueTarget, retireFlueTargetFiles } from './flue-project.mjs';
|
|
8
|
+
import { deployFlueSpecialists } from './flue-specialists.mjs';
|
|
9
|
+
export { FLUE_SPECIALISTS } from './flue-specialists.mjs';
|
|
10
|
+
const { generate } = await importImpl(import.meta.url, 'smiths/context-pipeline/generator.js');
|
|
11
|
+
|
|
12
|
+
export const name = 'flue';
|
|
13
|
+
export const aliases = [];
|
|
14
|
+
export const paths = { agents: '', commands: '', skills: '.agents/skills', rules: '.agents/.aiwg/rules' };
|
|
15
|
+
export const kernelSkillsPath = '.agents/skills';
|
|
16
|
+
export const capabilities = { skills: true, rules: false, aggregatedOutput: false, homeDirectoryDeploy: false };
|
|
17
|
+
export const support = { agents: 'indexed', commands: 'indexed', skills: 'native', rules: 'context' };
|
|
18
|
+
export const deploymentFiles = flueDeploymentFiles;
|
|
19
|
+
export const mapModel = value => value;
|
|
20
|
+
export const getFileExtension = () => '.md';
|
|
21
|
+
export const deployAgents = () => 0;
|
|
22
|
+
export const deployCommands = () => 0;
|
|
23
|
+
export const deployRules = () => 0;
|
|
24
|
+
|
|
25
|
+
export function deploySkills(skillDirs, target, opts) {
|
|
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 };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function postDeploy(target, opts) {
|
|
33
|
+
opts = { ...opts, flueTarget: detectFlueTarget(target, { warn: true }) };
|
|
34
|
+
retireFlueTargetFiles(target, opts);
|
|
35
|
+
deployFlueDatabase(target, opts);
|
|
36
|
+
deployFlueSpecialists(target, opts);
|
|
37
|
+
if (opts.contextFiles !== false) await generate({ provider: name, projectPath: target, sections: [], detectExistingFiles: true });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function deploy(opts) {
|
|
41
|
+
if (opts.userScope) throw new Error('Flue (experimental) supports project scope only.');
|
|
42
|
+
return withRuleDeployment({ ...opts, provider: name }, provider, async staged => {
|
|
43
|
+
const mode = normalizeDeploymentMode(staged.mode);
|
|
44
|
+
const invoked = listSkillDirs(path.join(staged.srcRoot, 'skills'));
|
|
45
|
+
const skills = [...invoked, ...(mode === 'all' ? getAddonSkillDirs(staged.srcRoot) : []),
|
|
46
|
+
...collectFrameworkArtifacts(staged.srcRoot, mode, { includeAgents: false, includeCommands: false, includeSkills: true, includeRules: false }).skills];
|
|
47
|
+
const count = deploySkills(mode === 'all' && !invoked.length ? skills.filter(isKernelSkill) : skills, staged.target, staged);
|
|
48
|
+
await postDeploy(staged.target, staged);
|
|
49
|
+
return count.kernel;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const provider = { name, aliases, paths, kernelSkillsPath, capabilities, support, deploymentFiles,
|
|
53
|
+
mapModel, getFileExtension, deployAgents, deployCommands, deployRules, deploySkills, postDeploy, deploy };
|
|
54
|
+
export default provider;
|
|
@@ -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
|
|
@@ -199,7 +199,7 @@ export function finishBindings(opts, provider) {
|
|
|
199
199
|
const roots = [opts.target, opts.deploymentHome,
|
|
200
200
|
...[opts.kernelSkillsPath, opts.activeWorkspace, ...Object.values(provider.paths)].filter(p => p && path.isAbsolute(p))];
|
|
201
201
|
const files = [...new Set(roots.flatMap(walk))];
|
|
202
|
-
const indexRel = provider.name === 'copilot' ? '.github/RULES-BOUND.md' : `.${provider.name}/RULES-BOUND.md`;
|
|
202
|
+
const indexRel = provider.name === 'copilot' ? '.github/RULES-BOUND.md' : provider.name === 'flue' ? '.agents/.aiwg/RULES-BOUND.md' : `.${provider.name}/RULES-BOUND.md`;
|
|
203
203
|
const indexFile = path.join(opts.target, indexRel);
|
|
204
204
|
const anchor = target => `${target.type}-${target.name}`.toLowerCase().replace(/[^a-z0-9_-]/g, '-');
|
|
205
205
|
const sections = new Map();
|
|
@@ -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,6 +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) {
|
|
284
|
+
if (provider.name === 'flue') return; // Flue deploys authored bundle skills; command projections remain index-only.
|
|
271
285
|
opts.flowSkillSources = new Map();
|
|
272
286
|
if (opts.rulesOnly || opts.commandsOnly || !(opts.deploySkills || opts.skillsOnly)) return;
|
|
273
287
|
const kernel = path.isAbsolute(provider.kernelSkillsPath || '') ? opts.kernelSkillsPath
|
|
@@ -294,6 +308,7 @@ export function projectBoundFlowSkills(opts, provider, selected) {
|
|
|
294
308
|
const stale = receipt?.flowSource && (opts.copyStandardSkills !== true
|
|
295
309
|
|| !sources.has(receipt.flowSource) || root !== standard);
|
|
296
310
|
if (!legacy && !stale) continue;
|
|
311
|
+
if (opts.copyMode ?? opts.copyStandardSkills) continue;
|
|
297
312
|
fs.rmSync(file, { force: true });
|
|
298
313
|
if (receipt?.flowSource) {
|
|
299
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
|
|
@@ -222,6 +223,7 @@ export async function prepareRuleDeployment(original, provider, deploy) {
|
|
|
222
223
|
fs.mkdirSync(path.join(stage, '.aiwg'), { recursive: true });
|
|
223
224
|
if (fs.existsSync(projectSnapshot)) materializeInput(projectSnapshot, path.join(stage, '.aiwg', 'aiwg.config'));
|
|
224
225
|
const rootNames = ['opencode.json', ...GENERATED_CONTEXT_NAMES, ...OPERATOR_CONTEXT_NAMES, '.aiwg/frameworks/registry.json'];
|
|
226
|
+
if (provider.deploymentFiles) rootNames.push(...provider.deploymentFiles(target));
|
|
225
227
|
if (provider.name === 'windsurf') rootNames.push('.windsurfrules');
|
|
226
228
|
for (const framework of getFrameworksForMode(original.srcRoot, original.mode)) {
|
|
227
229
|
for (const entry of framework.manifest?.memory?.creates || []) {
|
|
@@ -335,9 +337,10 @@ export async function prepareRuleDeployment(original, provider, deploy) {
|
|
|
335
337
|
delivery.bindings = remappedBindings;
|
|
336
338
|
preimages.push(...snapshotPreimages([...delivery.rules.map(rule => rule.file), ...delivery.targets.map(entry => entry.source), path.join(target, '.aiwg', 'aiwg.config')]));
|
|
337
339
|
const opts = { ...original, writeReceipt: writeContextFileSync, writtenFiles: [], target: stage, dryRun: false, ruleDelivery: delivery, logicalOutputPath: file => logicalProviderOutputPath(file, stage, target, mappings),
|
|
338
|
-
kernelSkillsPath: kernel, deploymentHome: home, activeWorkspace, hermesLegacySkills, legacyCodexSkills, staging: true };
|
|
340
|
+
flueDatabaseFile: provider.name === 'flue' ? provider.deploymentFiles(target)[0] : undefined, kernelSkillsPath: kernel, deploymentHome: home, activeWorkspace, hermesLegacySkills, legacyCodexSkills, staging: true };
|
|
339
341
|
const ownershipRoots = [stage, ...mappings.map(mapping => mapping.to)];
|
|
340
342
|
const ownershipBefore = captureDeploymentOutputs(ownershipRoots);
|
|
343
|
+
opts.ownershipBefore = ownershipBefore;
|
|
341
344
|
if (!opts.deferRuleProjection && (opts.kernelOnly || opts.deployRules || opts.rulesOnly ||
|
|
342
345
|
(!opts.skillsOnly && !opts.commandsOnly && (inlineStartup[provider.name] || ['hermes', 'warp'].includes(provider.name))))) retireInlineStartup(opts, provider);
|
|
343
346
|
await deploySelectedSurface(opts, provider, deploy);
|
|
@@ -370,6 +373,7 @@ export async function prepareRuleDeployment(original, provider, deploy) {
|
|
|
370
373
|
if (opts.kernelOnly || opts.deployRules || opts.rulesOnly || (!opts.skillsOnly && !opts.commandsOnly && (inlineStartup[provider.name] || ['hermes', 'warp'].includes(provider.name)))) projectRules(opts, provider);
|
|
371
374
|
finishBindings(opts, provider);
|
|
372
375
|
}
|
|
376
|
+
preserveDeploymentOutputs(ownershipBefore, ownershipRoots, opts);
|
|
373
377
|
// Normalize all generated path wrappers before counting or promoting bytes.
|
|
374
378
|
const normalize = content => {
|
|
375
379
|
for (const mapping of [...mappings].sort((a, b) => b.to.length - a.to.length)) content = content.split(mapping.to).join(mapping.from);
|
|
@@ -426,6 +430,7 @@ export async function prepareRuleDeployment(original, provider, deploy) {
|
|
|
426
430
|
for (const name of rootNames) {
|
|
427
431
|
const file = path.join(stage, name);
|
|
428
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)}`);
|
|
429
434
|
}
|
|
430
435
|
console.log(`[dry-run] Planned ${provider.name} deployment: ${guarded.report.selected_bytes} startup bytes; no output promoted.`);
|
|
431
436
|
return { report: guarded.report, noop: true };
|
|
@@ -14,7 +14,7 @@ const bootstrap = [
|
|
|
14
14
|
].join('\n');
|
|
15
15
|
const read = file => fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';
|
|
16
16
|
export const inlineStartup = {
|
|
17
|
-
codex: 'AGENTS.md', pi: 'AGENTS.md', hermes: 'AGENTS.md', warp: 'WARP.md',
|
|
17
|
+
codex: 'AGENTS.md', flue: 'AGENTS.md', pi: 'AGENTS.md', hermes: 'AGENTS.md', warp: 'WARP.md',
|
|
18
18
|
copilot: '.github/copilot-instructions.md', factory: 'AGENTS.md', opencode: 'AGENTS.md',
|
|
19
19
|
windsurf: 'AGENTS.md', antigravity: 'AGENTS.md', muse: 'AGENTS.md',
|
|
20
20
|
omp: '.omp/AGENTS.md', 'grok-build': 'AGENTS.md',
|
|
@@ -57,8 +57,8 @@ export function projectStartup(opts, provider, coreSection, indexFile) {
|
|
|
57
57
|
retireInlineStartup(opts, provider, file);
|
|
58
58
|
const files = provider.name === 'hermes' ? [file, path.join(opts.target, '.hermes.md')] : [file];
|
|
59
59
|
for (const startup of files) {
|
|
60
|
-
let content = normalizeRuleStartup(read(startup), bootstrap, path.basename(startup) === 'AGENTS.md');
|
|
61
|
-
content = section(content, 'rule-core', coreSection.replace(/<!-- AIWG:(?:core-rules|rule-core):(?:start|end) -->\n?/g, '').trimEnd());
|
|
60
|
+
let content = provider.name === 'flue' ? read(startup) : normalizeRuleStartup(read(startup), bootstrap, path.basename(startup) === 'AGENTS.md');
|
|
61
|
+
if (provider.name !== 'flue' || coreSection) content = section(content, 'rule-core', coreSection.replace(/<!-- AIWG:(?:core-rules|rule-core):(?:start|end) -->\n?/g, '').trimEnd());
|
|
62
62
|
const logical = opts.logicalOutputPath || (file => file);
|
|
63
63
|
const location = path.relative(logical(opts.target), logical(indexFile)).replaceAll('\\', '/');
|
|
64
64
|
const hook = `${provider.name}: Before every task and subagent task, read and follow \`${location}\`; read every listed kernel file and fetch matching full rules before governed work.`;
|
|
@@ -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,17 @@
|
|
|
1
|
+
// Carry use's requested frameworks through additive passes without recording an installation.
|
|
2
|
+
import { getFrameworksForMode, resolveAiwgRoot } from './providers/base.mjs';
|
|
3
|
+
import { importImpl } from '../_resolve-impl.mjs';
|
|
4
|
+
|
|
5
|
+
const { loadRulePinConfigs } = await importImpl(import.meta.url, 'rules/pins.mjs');
|
|
6
|
+
|
|
7
|
+
export function useRuleSelectionConfig(cfg, srcRoot) {
|
|
8
|
+
if (!cfg.ruleSelectionMode || cfg.kernelOnly) return undefined;
|
|
9
|
+
const root = resolveAiwgRoot(srcRoot) || srcRoot;
|
|
10
|
+
const frameworks = getFrameworksForMode(root, cfg.ruleSelectionMode);
|
|
11
|
+
if (!frameworks.length) return undefined;
|
|
12
|
+
const { project } = loadRulePinConfigs(cfg.target);
|
|
13
|
+
// Existing install metadata and operator pins win; provisional entries exist
|
|
14
|
+
// only in this projector's config snapshot and are never written to disk.
|
|
15
|
+
const installed = Object.fromEntries(frameworks.map(framework => [framework.id, { source: 'bundled' }]));
|
|
16
|
+
return { ...project, installed: { ...installed, ...project.installed } };
|
|
17
|
+
}
|
|
@@ -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
|
}
|