@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
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
--rules-only Deploy only rules (skip agents)
|
|
25
25
|
* --dry-run Show what would be deployed without writing
|
|
26
26
|
* --force Overwrite existing files
|
|
27
|
-
* --provider <name> Target provider: antigravity (agy), claude (default), openai, codex, cursor, opencode, copilot, factory, grokbot, grok-build, muse, pi, omp, deepseek-harness (dsh), warp, devin, hermes, openhuman, or openclaw
|
|
27
|
+
* --provider <name> Target provider: antigravity (agy), claude (default), openai, codex, cursor, opencode, copilot, factory, grokbot, grok-build, muse, flue (experimental), pi, omp, deepseek-harness (dsh), warp, devin, hermes, openhuman, or openclaw
|
|
28
28
|
* --model <name> Override model for all tiers (blanket)
|
|
29
29
|
* --reasoning-model <name> Override model for reasoning tasks
|
|
30
30
|
* --coding-model <name> Override model for coding tasks
|
|
@@ -101,7 +101,7 @@ const PROVIDER_ALIASES = {
|
|
|
101
101
|
'dsh': 'deepseek-harness',
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
const AVAILABLE_PROVIDERS = ['antigravity', 'claude', 'factory', 'codex', 'opencode', 'copilot', 'cursor', 'pi', 'omp', 'deepseek-harness', 'warp', 'windsurf', 'hermes', 'openclaw', 'openhuman', 'grokbot', 'grok-build', 'muse'];
|
|
104
|
+
const AVAILABLE_PROVIDERS = ['antigravity', 'claude', 'factory', 'codex', 'opencode', 'copilot', 'cursor', 'flue', 'pi', 'omp', 'deepseek-harness', 'warp', 'windsurf', 'hermes', 'openclaw', 'openhuman', 'grokbot', 'grok-build', 'muse'];
|
|
105
105
|
|
|
106
106
|
const UNSUPPORTED_PROVIDER_HINTS = {
|
|
107
107
|
'devin-cli': [
|
|
@@ -159,8 +159,10 @@ import { pruneStaleAiwgArtifacts } from './providers/stale-artifact-prune.mjs';
|
|
|
159
159
|
export { parseArgs } from './deploy-options.mjs';
|
|
160
160
|
export { collectMirrorSkillDirs } from './deploy-command-mirrors.mjs';
|
|
161
161
|
import { parseArgs, printHelp } from './deploy-options.mjs';
|
|
162
|
+
import { useRuleSelectionConfig } from './use-rule-selection.mjs';
|
|
162
163
|
import { mirrorSkillsAsCommands } from './deploy-command-mirrors.mjs';
|
|
163
164
|
import { resolveShorthand, saveModelConfig, promptCommandsMigration } from './deploy-support.mjs';
|
|
165
|
+
const { preserveDeploymentOutputs } = await importImpl(import.meta.url, 'providers/deployment-preservation.mjs');
|
|
164
166
|
const { captureDeploymentOutputs, recordDeploymentOutputs, deploymentOutputRoots } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
165
167
|
|
|
166
168
|
export async function main(args = process.argv.slice(2), internal = {}) {
|
|
@@ -247,7 +249,9 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
247
249
|
// Build options for provider
|
|
248
250
|
const { writeContextFileSync } = await import('./providers/context-write.mjs');
|
|
249
251
|
const opts = {
|
|
252
|
+
replacedSkillCopies: new Set(),
|
|
250
253
|
writeReceipt: writeContextFileSync,
|
|
254
|
+
config: useRuleSelectionConfig(cfg, srcRoot),
|
|
251
255
|
srcRoot,
|
|
252
256
|
target: cfg.target,
|
|
253
257
|
...(cfg.userScope ? { userScope: true } : {}),
|
|
@@ -295,7 +299,9 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
295
299
|
// for the standard tier. Default is no-copy + index-driven discovery.
|
|
296
300
|
// Replaces the legacy AIWG_COPY_STANDARD_SKILLS env var (removed rc.30).
|
|
297
301
|
// Default (#1217) is no-copy + index-driven discovery.
|
|
302
|
+
fluePackage: cfg.fluePackage === true,
|
|
298
303
|
copyStandardSkills: cfg.copyStandardSkills === true,
|
|
304
|
+
copyMode: cfg.copyStandardSkills === true && cfg.indexMode !== true,
|
|
299
305
|
// #228: Muse provider hooks/MCP profile surface.
|
|
300
306
|
mcp: cfg.mcp === true,
|
|
301
307
|
hooks: cfg.hooks !== false,
|
|
@@ -316,7 +322,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
316
322
|
// Commands → Skills migration: prompt then delete the commands directory
|
|
317
323
|
// so stale command files don't create duplicates in the provider TUI.
|
|
318
324
|
if (!preparationActive && !internal.finalizeOnly) {
|
|
319
|
-
if (!cfg.dryRun && !cfg.skipCommandsMigration) {
|
|
325
|
+
if (!cfg.dryRun && !opts.copyMode && !cfg.skipCommandsMigration) {
|
|
320
326
|
const doMigrate = await promptCommandsMigration(cfg, provider, cfg.target, internal.capture ? false : process.stdout.isTTY);
|
|
321
327
|
if (doMigrate) {
|
|
322
328
|
const commandsRelPath = provider.paths?.commands;
|
|
@@ -348,7 +354,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
348
354
|
try {
|
|
349
355
|
if (!internal.finalizeOnly) {
|
|
350
356
|
if (cfg.kernelOnly && (!cfg.deferRuleProjection || preparationActive)
|
|
351
|
-
&& !['claude', 'codex', 'cursor', 'hermes', 'warp', 'openclaw', 'pi', 'copilot', 'factory', 'opencode', 'windsurf', 'antigravity', 'muse', 'omp', 'grok-build'].includes(provider.name)) {
|
|
357
|
+
&& !['claude', 'codex', 'cursor', 'hermes', 'warp', 'openclaw', 'flue', 'pi', 'copilot', 'factory', 'opencode', 'windsurf', 'antigravity', 'muse', 'omp', 'grok-build'].includes(provider.name)) {
|
|
352
358
|
const { deployWithRuleDelivery } = await import('./providers/rule-delivery.mjs');
|
|
353
359
|
await deployWithRuleDelivery(opts, provider, staged => provider.deploy(staged));
|
|
354
360
|
} else await provider.deploy(opts);
|
|
@@ -384,6 +390,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
384
390
|
await saveModelConfig(cfg, provider.name);
|
|
385
391
|
}
|
|
386
392
|
|
|
393
|
+
if (ownershipBefore) preserveDeploymentOutputs(ownershipBefore, ownershipRoots, opts);
|
|
387
394
|
if (ownershipBefore) recordDeploymentOutputs(ownershipBefore, ownershipRoots, opts);
|
|
388
395
|
if (!cfg.quiet) console.log(`\n=== Deployment complete ===\n`);
|
|
389
396
|
} catch (err) {
|
|
@@ -29,6 +29,7 @@ export function parseArgs(args = process.argv.slice(2)) {
|
|
|
29
29
|
reportOnly: true,
|
|
30
30
|
kernelOnly: false,
|
|
31
31
|
deferRuleProjection: false,
|
|
32
|
+
ruleSelectionMode: null,
|
|
32
33
|
additionalSources: [],
|
|
33
34
|
filter: null, // Glob pattern for agent names
|
|
34
35
|
filterRole: null, // Filter by role: reasoning|coding|efficiency
|
|
@@ -60,6 +61,12 @@ export function parseArgs(args = process.argv.slice(2)) {
|
|
|
60
61
|
}
|
|
61
62
|
else if (a === '--target' && args[i + 1]) cfg.target = path.resolve(args[++i]);
|
|
62
63
|
else if (a === '--mode' && args[i + 1]) cfg.mode = String(args[++i]).toLowerCase();
|
|
64
|
+
// Internal use orchestration: selection survives source-specific passes.
|
|
65
|
+
else if (a === '--rule-selection-mode') {
|
|
66
|
+
const mode = args[++i];
|
|
67
|
+
if (!mode || mode.startsWith('--')) throw new Error('--rule-selection-mode requires a deployment mode');
|
|
68
|
+
cfg.ruleSelectionMode = mode.toLowerCase();
|
|
69
|
+
}
|
|
63
70
|
else if (a === '--scope') {
|
|
64
71
|
const scope = args[++i];
|
|
65
72
|
if (scope !== 'user' && scope !== 'project') {
|
|
@@ -103,6 +110,8 @@ export function parseArgs(args = process.argv.slice(2)) {
|
|
|
103
110
|
else if (a === '--skip-commands-migration') cfg.skipCommandsMigration = true;
|
|
104
111
|
// Structural opt-out: skip the migration without claiming the operator declined it (#2541).
|
|
105
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;
|
|
106
115
|
else if (a === '--copy-all' || a === '--copy-standard-skills') cfg.copyStandardSkills = true;
|
|
107
116
|
// #228: Muse provider — explicit opt-in MCP settings profile, and the
|
|
108
117
|
// managed-hooks opt-out (default on, mirroring the Claude autoInstall policy).
|
|
@@ -216,6 +225,8 @@ Providers (all deploy agents, commands, skills, and rules):
|
|
|
216
225
|
Paths: .cursor/agents/, .cursor/commands/, .cursor/skills/, .cursor/rules/
|
|
217
226
|
warp - Warp Terminal
|
|
218
227
|
Paths: .warp/agents/, .warp/commands/, .warp/skills/, .warp/rules/ + WARP.md
|
|
228
|
+
flue - Flue (experimental app target; project scope only)
|
|
229
|
+
Paths: .agents/skills/, inline AGENTS.md, source-root db.ts, .gitignore
|
|
219
230
|
deepseek-harness - DeepSeek Harness (alias: dsh; experimental)
|
|
220
231
|
Paths: AGENTS.md, .agents/skills/, .dsh/aiwg.cordis.patch.yml
|
|
221
232
|
devin - Devin Desktop (preferred; aliases: devin-desktop, windsurf)
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Select only Flue's conventional database module and preserve operator modules.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
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');
|
|
8
|
+
|
|
9
|
+
const exists = file => { try { fs.lstatSync(file); return true; } catch (error) { if (error.code === 'ENOENT') return false; throw error; } };
|
|
10
|
+
const directory = file => exists(file) && fs.lstatSync(file).isDirectory();
|
|
11
|
+
const databaseFiles = () => ['.flue', 'src', ''].flatMap(dir => ['ts', 'mts', 'js', 'mjs'].map(ext => path.join(dir, `db.${ext}`)));
|
|
12
|
+
// Flue 2.3.0: @flue/runtime/dist/config.mjs:91-98,113-116 (first existing wins).
|
|
13
|
+
const configFiles = ['ts', 'mts', 'mjs', 'js', 'cjs', 'cts'].map(ext => `flue.config.${ext}`);
|
|
14
|
+
export function flueDeploymentFiles(target) {
|
|
15
|
+
const source = ['.flue', 'src'].find(dir => directory(path.join(target, dir))) || 'src';
|
|
16
|
+
// Snapshot config and conventional entries too: deployment reads a staged project.
|
|
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'])];
|
|
19
|
+
}
|
|
20
|
+
function configProperty(target, key) {
|
|
21
|
+
const config = configFiles.find(file => exists(path.join(target, file)));
|
|
22
|
+
if (!config) return;
|
|
23
|
+
// Static tokens only; comments and string/template contents cannot become keys.
|
|
24
|
+
const tokens = fs.readFileSync(path.join(target, config), 'utf8').match(/\/\*[\s\S]*?\*\/|\/\/[^\r\n]*|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|[A-Za-z_$][\w$]*|[^\s]/g) || [];
|
|
25
|
+
const code = tokens.filter(token => !token.startsWith('//') && !token.startsWith('/*'));
|
|
26
|
+
let start = code.findIndex((token, index) => token === 'export' && code[index + 1] === 'default');
|
|
27
|
+
if (start >= 0) start += 2;
|
|
28
|
+
else {
|
|
29
|
+
start = code.findIndex((token, index) => token === 'module' && code.slice(index + 1, index + 4).join('') === '.exports=');
|
|
30
|
+
if (start < 0) return;
|
|
31
|
+
start += 4;
|
|
32
|
+
}
|
|
33
|
+
// Accept a literal default export, optionally parenthesized or wrapped in defineConfig.
|
|
34
|
+
if (code[start] === 'defineConfig' && code[start + 1] === '(') start += 2;
|
|
35
|
+
while (code[start] === '(') start++;
|
|
36
|
+
if (code[start] !== '{') return;
|
|
37
|
+
const nesting = [];
|
|
38
|
+
for (let index = start; index < code.length; index++) {
|
|
39
|
+
const token = code[index];
|
|
40
|
+
if (nesting.length === 1 && [key, `"${key}"`, `'${key}'`].includes(token)
|
|
41
|
+
&& ['{', ','].includes(code[index - 1]) && code[index + 1] === ':') return { config, value: code[index + 2] };
|
|
42
|
+
if (['{', '[', '('].includes(token)) nesting.push(token);
|
|
43
|
+
else if (['}', ']', ')'].includes(token)) {
|
|
44
|
+
nesting.pop();
|
|
45
|
+
if (!nesting.length) break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
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
|
+
}
|
|
57
|
+
export function claimRecordedFile(target, file, opts) {
|
|
58
|
+
if (!exists(file)) return false;
|
|
59
|
+
let record;
|
|
60
|
+
try { record = JSON.parse(fs.readFileSync(path.join(target, '.aiwg/.aiwg-manifest.json'), 'utf8')).managed?.[path.relative(target, file).split(path.sep).join('/')]; }
|
|
61
|
+
catch { return false; }
|
|
62
|
+
const hash = `sha256:${createHash('sha256').update(fs.readFileSync(file)).digest('hex')}`;
|
|
63
|
+
if (!record?.filePreimage || record.hash !== hash) return false;
|
|
64
|
+
opts.writtenFiles?.push(file);
|
|
65
|
+
return true;
|
|
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
|
+
}
|
|
94
|
+
export function deployFlueDatabase(target, opts) {
|
|
95
|
+
if (detectFlueTarget(target) === 'cloudflare') return;
|
|
96
|
+
const config = configProperty(target, 'db')?.config;
|
|
97
|
+
if (config) {
|
|
98
|
+
console.warn(`Flue (experimental): keeping explicit db entry in ${config}; verify the operator module selects durable SQLite at .flue-state/state.db.`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const relative = opts.flueDatabaseFile || flueDeploymentFiles(target)[0];
|
|
102
|
+
const file = path.join(target, relative);
|
|
103
|
+
// All conventional operator database formats take precedence over generation.
|
|
104
|
+
const operator = databaseFiles().map(name => path.join(target, name))
|
|
105
|
+
.find(exists);
|
|
106
|
+
if (operator && !claimRecordedFile(target, operator, opts)) console.warn(`Flue (experimental): keeping existing database module ${opts.logicalOutputPath?.(operator) || operator}; verify it selects durable SQLite at .flue-state/state.db.`);
|
|
107
|
+
else if (!operator && !opts.dryRun) {
|
|
108
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
109
|
+
const state = path.relative(path.dirname(file), path.join(target, '.flue-state/state.db')).split(path.sep).join('/');
|
|
110
|
+
fs.writeFileSync(file, `import { sqlite } from '@flue/runtime/node';\nimport { fileURLToPath } from 'node:url';\n\nexport default sqlite(fileURLToPath(new URL(${JSON.stringify(state)}, import.meta.url)));\n`);
|
|
111
|
+
}
|
|
112
|
+
const ignore = path.join(target, '.gitignore');
|
|
113
|
+
claimRecordedFile(target, ignore, opts);
|
|
114
|
+
const before = exists(ignore) ? fs.readFileSync(ignore, 'utf8') : '';
|
|
115
|
+
if (!before.split(/\r?\n/).some(line => line.trim().replace(/^\//, '').replace(/\/\*{0,2}$/, '') === '.flue-state') && !opts.dryRun) {
|
|
116
|
+
fs.writeFileSync(ignore, `${before}${before && !before.endsWith('\n') ? '\n' : ''}.flue-state/\n`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Generate the selected Flue delegates from canonical agents and shared rule transforms.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { camel, flueBundleInventory, selectedFlueBundles } from './flue-bundles.mjs';
|
|
6
|
+
import { generateFlueSkills } from './flue-skills.mjs';
|
|
7
|
+
import { parseFrontmatter } from './base-frontmatter.mjs';
|
|
8
|
+
import { injectBoundRules } from './base-contract.mjs';
|
|
9
|
+
import { claimRecordedFile } from './flue-project.mjs';
|
|
10
|
+
import { cloudflareTools } from './flue-cloudflare.mjs';
|
|
11
|
+
|
|
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)));
|
|
18
|
+
|
|
19
|
+
export function generateFlueSpecialists(opts) {
|
|
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);
|
|
24
|
+
const file = opts.mapInputPath?.(logical) || logical;
|
|
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
|
+
}`;
|
|
29
|
+
return `export const ${specialist.exportName} = defineSubagent({
|
|
30
|
+
name: ${JSON.stringify(specialist.name)},
|
|
31
|
+
description: ${JSON.stringify(metadata.description || metadata.name)},
|
|
32
|
+
agent() {
|
|
33
|
+
${cloudflare ? '' : `useTool(aiwg_discover);
|
|
34
|
+
useTool(aiwg_show);
|
|
35
|
+
useTool(aiwg_artifact_write);`}
|
|
36
|
+
return ${JSON.stringify(body.trim())};
|
|
37
|
+
},
|
|
38
|
+
});`;
|
|
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
|
+
}
|
|
46
|
+
return `// Curated AIWG delegates; regenerate from canonical sdlc-complete agents.
|
|
47
|
+
import { defineSubagent, useSubagent${cloudflare ? '' : ', useTool'} } from '@flue/runtime';
|
|
48
|
+
import { ${cloudflare ? 'aiwgConnection, bindRemoteSpecialist' : 'aiwg_discover, aiwg_show, aiwg_artifact_write'} } from './tools.ts';
|
|
49
|
+
|
|
50
|
+
${definitions.join('\n\n')}
|
|
51
|
+
|
|
52
|
+
/** Trusted app options: omit pins to inherit the app model and effort. */
|
|
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')}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function deployFlueSpecialists(target, opts) {
|
|
60
|
+
// Preserve operator files even on --force. Unchanged managed outputs can refresh.
|
|
61
|
+
const write = (relative, content) => {
|
|
62
|
+
const file = path.join(target, relative);
|
|
63
|
+
if (fs.lstatSync(file, { throwIfNoEntry: false })) {
|
|
64
|
+
if (!claimRecordedFile(target, file, opts)) {
|
|
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.`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!opts.dryRun) {
|
|
70
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
71
|
+
fs.writeFileSync(file, content());
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const template = fileURLToPath(new URL('../../../agentic/code/providers/flue/templates/aiwg/tools.ts', import.meta.url));
|
|
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'));
|
|
80
|
+
write('src/aiwg/specialists.ts', () => generateFlueSpecialists(opts));
|
|
81
|
+
write('src/aiwg/skills.ts', () => generateFlueSkills(target, opts));
|
|
82
|
+
}
|