@givolt/i3-composer-agent 1.0.0 → 1.0.1
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/.agents/plugins/marketplace.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +12 -1
- package/NOTICE.md +6 -1
- package/README.md +53 -15
- package/bin/agent-targets.json +726 -0
- package/bin/i3-composer-agent.cjs +83 -15
- package/bin/install.cjs +164 -0
- package/bin/skills-registry.LICENSE +21 -0
- package/bin/wizard.cjs +66 -0
- package/docs/codebuddy-setup.md +55 -8
- package/docs/codex-setup.md +13 -2
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/rebrand/INSTALLATION-SPEC.md +46 -0
- package/rebrand/MAINTENANCE.md +2 -1
- package/rebrand/NOTICE.md +6 -1
- package/rebrand/VALIDATION.md +4 -0
- package/rebrand/VERSIONING.md +6 -5
- package/rebrand/brand.json +1 -1
- package/rebrand/overlay/CHANGELOG.md +12 -1
- package/rebrand/overlay/bin/agent-targets.json +726 -0
- package/rebrand/overlay/bin/i3-composer-agent.cjs +83 -15
- package/rebrand/overlay/bin/install.cjs +164 -0
- package/rebrand/overlay/bin/skills-registry.LICENSE +21 -0
- package/rebrand/overlay/bin/wizard.cjs +66 -0
- package/rebrand/overlay/tests/installer.test.cjs +193 -0
- package/rebrand/templates/README.md +52 -14
- package/rebrand/templates/codebuddy-setup.md +55 -8
- package/rebrand/templates/codex-setup.md +14 -3
- package/tests/installer.test.cjs +193 -0
|
@@ -12,23 +12,35 @@ const identity = `i3 Composer Agent v${pkg.version}\nBased on agent-skills v${pk
|
|
|
12
12
|
const help = `${identity}
|
|
13
13
|
${pkg.name}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Install engineering skills with a multi-tool installation wizard.
|
|
16
16
|
|
|
17
17
|
Usage:
|
|
18
|
-
npx ${pkg.name}
|
|
19
|
-
npx ${pkg.name} --
|
|
20
|
-
npx ${pkg.name} --
|
|
18
|
+
npx ${pkg.name}
|
|
19
|
+
npx ${pkg.name} --codebuddy
|
|
20
|
+
npx ${pkg.name} --agents codebuddy,codex --scope project --yes
|
|
21
|
+
npx ${pkg.name} --prepare --claude --dir <directory>
|
|
21
22
|
npx ${pkg.name} --extract --dir <directory>
|
|
22
23
|
|
|
23
24
|
Options:
|
|
24
|
-
--
|
|
25
|
-
--
|
|
26
|
-
--
|
|
27
|
-
--
|
|
28
|
-
--
|
|
25
|
+
--agents <ids> Comma-separated tool IDs; multiple tools are supported
|
|
26
|
+
--codebuddy Preselect CodeBuddy desktop IDE / CodeBuddy Code
|
|
27
|
+
--codex Preselect Codex
|
|
28
|
+
--claude Preselect Claude Code
|
|
29
|
+
--scope <scope> project or global (or use --global / --local)
|
|
30
|
+
--project-dir <dir> Project installation root (default: current directory)
|
|
31
|
+
--yes Confirm explicit noninteractive installation
|
|
32
|
+
--list-agents List all supported tool directories
|
|
33
|
+
--prepare Prepare a complete plugin for native plugin registration
|
|
34
|
+
--dir <directory> Plugin output directory; implies --prepare
|
|
35
|
+
--dry-run Show the installation or bundle plan without writing files
|
|
36
|
+
--force Replace existing assets, preserving backups
|
|
37
|
+
--version Print the package version
|
|
38
|
+
--help Show this help
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
The terminal wizard selects tools and scope, then installs native skill files.
|
|
41
|
+
CodeBuddy and Claude Code also receive short lifecycle commands and personas.
|
|
42
|
+
Other tools receive skills and references; command availability is host-specific.
|
|
43
|
+
Use --prepare for complete plugins, including hooks and host registration.
|
|
32
44
|
`;
|
|
33
45
|
|
|
34
46
|
function quote(value) { return "'" + value.replaceAll("'", "'\\''") + "'"; }
|
|
@@ -43,15 +55,14 @@ function realDestination(target) {
|
|
|
43
55
|
}
|
|
44
56
|
return path.join(fs.realpathSync(existing), ...suffix);
|
|
45
57
|
}
|
|
46
|
-
function
|
|
47
|
-
if (!args.length || args.includes('--help')) { console.log(help); return; }
|
|
48
|
-
if (args.length === 1 && args[0] === '--version') { console.log(pkg.version); return; }
|
|
58
|
+
function prepare() {
|
|
49
59
|
let host;
|
|
50
60
|
let directory = path.join(process.cwd(), name);
|
|
51
61
|
let dryRun = false;
|
|
52
62
|
let force = false;
|
|
53
63
|
for (let i = 0; i < args.length; i++) {
|
|
54
64
|
const arg = args[i];
|
|
65
|
+
if (arg === '--prepare') continue;
|
|
55
66
|
if (['--codebuddy', '--codex', '--claude', '--extract'].includes(arg)) {
|
|
56
67
|
if (host) throw new Error('Choose exactly one host flag or --extract.');
|
|
57
68
|
host = arg.slice(2);
|
|
@@ -119,4 +130,61 @@ function main() {
|
|
|
119
130
|
console.log(`Use /${name}:spec, /${name}:plan, /${name}:build, and /${name}:ship in ${host === 'claude' ? 'Claude Code' : 'CodeBuddy'}.`);
|
|
120
131
|
}
|
|
121
132
|
}
|
|
122
|
-
|
|
133
|
+
async function main() {
|
|
134
|
+
if (args.includes('--help') || (!args.length && !process.stdin.isTTY)) { console.log(help); return; }
|
|
135
|
+
if (args.length === 1 && args[0] === '--version') { console.log(pkg.version); return; }
|
|
136
|
+
if (args.some(arg => ['--extract', '--prepare', '--dir'].includes(arg))) { prepare(); return; }
|
|
137
|
+
const installer = require('./install.cjs');
|
|
138
|
+
if (args.length === 1 && args[0] === '--list-agents') {
|
|
139
|
+
for (const agent of installer.registry.agents) console.log(`${agent.id.padEnd(20)} ${agent.label}${agent.globalSkillsDir ? '' : ' (project only)'}`);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const options = { agents: [], projectDir: process.cwd() };
|
|
143
|
+
for (let i = 0; i < args.length; i++) {
|
|
144
|
+
const arg = args[i];
|
|
145
|
+
if (['--codebuddy', '--codex', '--claude'].includes(arg)) options.agents.push(arg.slice(2));
|
|
146
|
+
else if (['--agents', '--scope', '--project-dir'].includes(arg)) {
|
|
147
|
+
if (!args[i + 1] || args[i + 1].startsWith('--')) throw new Error(`${arg} requires a value.`);
|
|
148
|
+
const value = args[++i];
|
|
149
|
+
if (arg === '--agents') options.agents.push(value);
|
|
150
|
+
else if (arg === '--scope') { if (options.scope && options.scope !== value) throw new Error('Choose one installation scope.'); options.scope = value; }
|
|
151
|
+
else options.projectDir = path.resolve(value);
|
|
152
|
+
} else if (arg === '--global' || arg === '--local') {
|
|
153
|
+
const scope = arg === '--global' ? 'global' : 'project';
|
|
154
|
+
if (options.scope && options.scope !== scope) throw new Error('Choose one installation scope.');
|
|
155
|
+
options.scope = scope;
|
|
156
|
+
} else if (arg === '--yes') options.yes = true;
|
|
157
|
+
else if (arg === '--force') options.force = true;
|
|
158
|
+
else if (arg === '--dry-run') options.dryRun = true;
|
|
159
|
+
else throw new Error(`Unknown option: ${arg}`);
|
|
160
|
+
}
|
|
161
|
+
options.agents = installer.selectAgents(options.agents);
|
|
162
|
+
if (process.stdin.isTTY && process.stdout.isTTY && !options.yes && !options.dryRun) {
|
|
163
|
+
const selection = await require('./wizard.cjs').choose(options, identity);
|
|
164
|
+
if (!selection) { console.log('Installation cancelled. No files changed.'); return; }
|
|
165
|
+
Object.assign(options, selection);
|
|
166
|
+
} else if (!options.agents.length || !options.scope || (!options.yes && !options.dryRun)) {
|
|
167
|
+
throw new Error('Use an interactive terminal, or specify --agents <ids> --scope project|global --yes.');
|
|
168
|
+
}
|
|
169
|
+
const plan = installer.planInstallation(options);
|
|
170
|
+
if (options.dryRun) {
|
|
171
|
+
console.log(JSON.stringify({ name, version: pkg.version, upstreamVersion: pkg.i3ComposerAgent.upstreamVersion, upstreamCommit: pkg.i3ComposerAgent.upstreamCommit, mode: plan.mode, scope: plan.scope, agents: plan.agents, targets: plan.targets, conflicts: plan.conflicts }, null, 2));
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (!options.yes) {
|
|
175
|
+
const confirmed = await require('./wizard.cjs').confirm(plan);
|
|
176
|
+
if (!confirmed) { console.log('Installation cancelled. No files changed.'); return; }
|
|
177
|
+
options.force = plan.conflicts.length > 0;
|
|
178
|
+
}
|
|
179
|
+
const backups = installer.executeInstallation(plan, { force: options.force });
|
|
180
|
+
console.log(identity);
|
|
181
|
+
for (const target of plan.targets) {
|
|
182
|
+
console.log(`Installed ${target.agents.join(', ')} skills at ${target.skillsDirectory}`);
|
|
183
|
+
if (target.commandsDirectory) console.log(`Commands: /spec, /plan, /build, /ship (all ${fs.readdirSync(target.commandsDirectory).filter(file => file.endsWith('.md')).length} workflows) at ${target.commandsDirectory}`);
|
|
184
|
+
}
|
|
185
|
+
for (const backup of backups) console.log(`Previous assets preserved at ${backup}`);
|
|
186
|
+
console.log('Reload the IDE window or start a new host session to discover installed files.');
|
|
187
|
+
if (plan.agents.some(id => !['codebuddy', 'claude-code'].includes(id))) console.log('These tools use the existing skill IDs; lifecycle slash-command support depends on the host.');
|
|
188
|
+
console.log('Native skill installation does not enable plugin hooks. Use --prepare for complete plugin registration.');
|
|
189
|
+
}
|
|
190
|
+
main().catch(error => { console.error(`${name}: ${error.message}`); process.exitCode = 1; });
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const os = require('node:os');
|
|
6
|
+
const crypto = require('node:crypto');
|
|
7
|
+
const registry = require('./agent-targets.json');
|
|
8
|
+
const root = path.resolve(__dirname, '..');
|
|
9
|
+
const name = 'i3-composer-agent';
|
|
10
|
+
const aliases = { claude: 'claude-code', gemini: 'gemini-cli', copilot: 'github-copilot' };
|
|
11
|
+
function exists(file) {
|
|
12
|
+
try { fs.lstatSync(file); return true; }
|
|
13
|
+
catch (error) { if (error.code === 'ENOENT') return false; throw error; }
|
|
14
|
+
}
|
|
15
|
+
function selectAgents(values) {
|
|
16
|
+
const ids = [...new Set(values.flatMap(value => value.split(',')).map(id => aliases[id.trim()] || id.trim()).filter(Boolean))];
|
|
17
|
+
for (const id of ids) if (!registry.agents.some(agent => agent.id === id)) throw new Error(`Unknown tool: ${id}. Use --list-agents.`);
|
|
18
|
+
return ids;
|
|
19
|
+
}
|
|
20
|
+
function globalSkillsDir(agent, home, env) {
|
|
21
|
+
const config = agent.globalSkillsDir;
|
|
22
|
+
if (!config) throw new Error(`${agent.label} supports project installation only. Choose project scope or remove this tool.`);
|
|
23
|
+
let base = home;
|
|
24
|
+
if (config.base === 'config') base = env.XDG_CONFIG_HOME && path.isAbsolute(env.XDG_CONFIG_HOME) ? env.XDG_CONFIG_HOME : path.join(home, '.config');
|
|
25
|
+
if (config.base === 'env') base = env[config.env]?.trim() || path.join(home, config.fallback);
|
|
26
|
+
if (config.alternatives && !fs.existsSync(path.join(home, path.dirname(config.path)))) {
|
|
27
|
+
const alternative = config.alternatives.find(relative => fs.existsSync(path.join(home, path.dirname(relative))));
|
|
28
|
+
if (alternative) return path.join(home, alternative);
|
|
29
|
+
}
|
|
30
|
+
return path.resolve(base, config.path);
|
|
31
|
+
}
|
|
32
|
+
// Resolve parent aliases while keeping a leaf symlink replaceable as a link.
|
|
33
|
+
function destination(file) {
|
|
34
|
+
let parent = path.dirname(file);
|
|
35
|
+
const suffix = [path.basename(file)];
|
|
36
|
+
while (!exists(parent)) { suffix.unshift(path.basename(parent)); parent = path.dirname(parent); }
|
|
37
|
+
return path.join(fs.realpathSync(parent), ...suffix);
|
|
38
|
+
}
|
|
39
|
+
function checkDestination(file) {
|
|
40
|
+
const source = fs.realpathSync(root);
|
|
41
|
+
if (file === source || file.startsWith(source + path.sep) || source.startsWith(file + path.sep)) {
|
|
42
|
+
throw new Error('Installation destinations must be outside this package directory.');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function planInstallation({ agents, scope, projectDir = process.cwd(), home = os.homedir(), env = process.env }) {
|
|
46
|
+
agents = selectAgents(agents);
|
|
47
|
+
if (!agents.length) throw new Error('Choose at least one tool.');
|
|
48
|
+
if (!['project', 'global'].includes(scope)) throw new Error('Choose --scope project or --scope global.');
|
|
49
|
+
const targets = new Map();
|
|
50
|
+
for (const id of agents) {
|
|
51
|
+
const agent = registry.agents.find(item => item.id === id);
|
|
52
|
+
const skillsDirectory = destination(scope === 'project' ? path.resolve(projectDir, agent.projectSkillsDir) : globalSkillsDir(agent, home, env));
|
|
53
|
+
const base = path.dirname(skillsDirectory);
|
|
54
|
+
if (!targets.has(skillsDirectory)) targets.set(skillsDirectory, { agents: [], skillsDirectory, referencesDirectory: path.join(base, 'references'), base });
|
|
55
|
+
const target = targets.get(skillsDirectory);
|
|
56
|
+
target.agents.push(id);
|
|
57
|
+
if (['codebuddy', 'claude-code'].includes(id)) {
|
|
58
|
+
target.commandsDirectory = path.join(base, 'commands');
|
|
59
|
+
target.personasDirectory = path.join(base, 'agents');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const assets = [];
|
|
63
|
+
function addDirectory(sourceDirectory, destinationDirectory, kind) {
|
|
64
|
+
if (exists(destinationDirectory) && fs.lstatSync(destinationDirectory).isSymbolicLink()) {
|
|
65
|
+
throw new Error(`Installation directory is a symlink: ${destinationDirectory}. Choose its canonical location instead.`);
|
|
66
|
+
}
|
|
67
|
+
for (const entry of fs.readdirSync(path.join(root, sourceDirectory)).sort()) {
|
|
68
|
+
if (entry === '.DS_Store') continue;
|
|
69
|
+
assets.push({ source: path.join(root, sourceDirectory, entry), destination: destination(path.join(destinationDirectory, entry)), kind });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const target of targets.values()) {
|
|
73
|
+
const start = assets.length;
|
|
74
|
+
addDirectory('skills', target.skillsDirectory, 'skill');
|
|
75
|
+
addDirectory('references', target.referencesDirectory, 'reference');
|
|
76
|
+
if (target.commandsDirectory) {
|
|
77
|
+
addDirectory('.claude/commands', target.commandsDirectory, 'command');
|
|
78
|
+
addDirectory('agents', target.personasDirectory, 'persona');
|
|
79
|
+
const docs = path.join(target.base, 'docs');
|
|
80
|
+
if (exists(docs) && fs.lstatSync(docs).isSymbolicLink()) throw new Error(`Installation directory is a symlink: ${docs}.`);
|
|
81
|
+
assets.push({ source: path.join(root, 'docs/agents.md'), destination: destination(path.join(target.base, 'docs/agents.md')), kind: 'documentation' });
|
|
82
|
+
}
|
|
83
|
+
assets.push({ source: path.join(root, 'LICENSE'), destination: destination(path.join(target.base, `${name}-LICENSE`)), kind: 'attribution' });
|
|
84
|
+
assets.push({ source: path.join(root, 'NOTICE.md'), destination: destination(path.join(target.base, `${name}-NOTICE.md`)), kind: 'attribution' });
|
|
85
|
+
assets.push({ target, destination: destination(path.join(target.base, `.${name}.json`)), kind: 'manifest' });
|
|
86
|
+
for (const asset of assets.slice(start)) {
|
|
87
|
+
asset.base = target.base;
|
|
88
|
+
asset.codebuddyCommand = asset.kind === 'command' && target.agents.includes('codebuddy');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
for (const asset of assets) { checkDestination(asset.destination); asset.existing = exists(asset.destination); }
|
|
92
|
+
return { mode: 'install', scope, agents, targets: [...targets.values()], assets, conflicts: assets.filter(asset => asset.existing).map(asset => asset.destination) };
|
|
93
|
+
}
|
|
94
|
+
function executeInstallation(plan, { force = false } = {}) {
|
|
95
|
+
if (plan.conflicts.length && !force) throw new Error('Existing installation assets require confirmation or --force; previous files will be backed up.');
|
|
96
|
+
const pkg = require('../package.json');
|
|
97
|
+
const contexts = new Map();
|
|
98
|
+
const createdDirectories = [];
|
|
99
|
+
const committed = [];
|
|
100
|
+
function mkdir(directory) {
|
|
101
|
+
if (exists(directory)) return;
|
|
102
|
+
mkdir(path.dirname(directory));
|
|
103
|
+
fs.mkdirSync(directory);
|
|
104
|
+
createdDirectories.push(directory);
|
|
105
|
+
}
|
|
106
|
+
function portable(file, markdown = false, codebuddyCommand = false) {
|
|
107
|
+
if (fs.statSync(file).isDirectory()) {
|
|
108
|
+
for (const entry of fs.readdirSync(file)) portable(path.join(file, entry), false, codebuddyCommand);
|
|
109
|
+
} else if (markdown || file.endsWith('.md')) {
|
|
110
|
+
let content = fs.readFileSync(file, 'utf8').replaceAll('i3-composer-agent:', '').replaceAll('agent-skills:', '');
|
|
111
|
+
if (codebuddyCommand) content = content.replaceAll('.claude/agents/', '.codebuddy/agents/');
|
|
112
|
+
fs.writeFileSync(file, content);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
// Stage every target before replacing the first installed asset.
|
|
117
|
+
for (const [index, asset] of plan.assets.entries()) {
|
|
118
|
+
if (!contexts.has(asset.base)) {
|
|
119
|
+
mkdir(asset.base);
|
|
120
|
+
contexts.set(asset.base, { staging: fs.mkdtempSync(path.join(asset.base, `.${name}-stage-`)), backup: path.join(asset.base, `.${name}-backup-${crypto.randomUUID()}`) });
|
|
121
|
+
}
|
|
122
|
+
const context = contexts.get(asset.base);
|
|
123
|
+
asset.staged = path.join(context.staging, String(index));
|
|
124
|
+
if (asset.kind === 'manifest') {
|
|
125
|
+
fs.writeFileSync(asset.staged, JSON.stringify({ name, version: pkg.version, upstreamVersion: pkg.i3ComposerAgent.upstreamVersion, upstreamCommit: pkg.i3ComposerAgent.upstreamCommit, scope: plan.scope, agents: asset.target.agents, assets: plan.assets.filter(item => item.base === asset.base).map(item => path.relative(asset.base, item.destination)) }, null, 2) + '\n');
|
|
126
|
+
} else {
|
|
127
|
+
fs.cpSync(asset.source, asset.staged, { recursive: true, filter: file => {
|
|
128
|
+
if (fs.lstatSync(file).isSymbolicLink()) throw new Error(`Package contains a symlink: ${file}`);
|
|
129
|
+
return path.basename(file) !== '.DS_Store';
|
|
130
|
+
} });
|
|
131
|
+
portable(asset.staged, asset.source.endsWith('.md'), asset.codebuddyCommand);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
for (const asset of plan.assets) {
|
|
135
|
+
const context = contexts.get(asset.base);
|
|
136
|
+
mkdir(path.dirname(asset.destination));
|
|
137
|
+
// A destination may have appeared since planning; never replace it implicitly.
|
|
138
|
+
if (exists(asset.destination) && !force) throw new Error(`Destination appeared during installation: ${asset.destination}. Retry with confirmed replacement.`);
|
|
139
|
+
const change = { destination: asset.destination, written: false };
|
|
140
|
+
if (exists(asset.destination)) {
|
|
141
|
+
change.backup = path.join(context.backup, path.relative(asset.base, asset.destination));
|
|
142
|
+
mkdir(path.dirname(change.backup));
|
|
143
|
+
fs.renameSync(asset.destination, change.backup);
|
|
144
|
+
}
|
|
145
|
+
committed.push(change);
|
|
146
|
+
fs.renameSync(asset.staged, asset.destination);
|
|
147
|
+
change.written = true;
|
|
148
|
+
}
|
|
149
|
+
return [...contexts.values()].map(context => context.backup).filter(exists);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
for (const change of committed.reverse()) {
|
|
152
|
+
if (change.written) fs.rmSync(change.destination, { recursive: true, force: true });
|
|
153
|
+
if (change.backup) fs.renameSync(change.backup, change.destination);
|
|
154
|
+
}
|
|
155
|
+
throw error;
|
|
156
|
+
} finally {
|
|
157
|
+
for (const context of contexts.values()) fs.rmSync(context.staging, { recursive: true, force: true });
|
|
158
|
+
for (const directory of createdDirectories.reverse()) {
|
|
159
|
+
try { fs.rmdirSync(directory); }
|
|
160
|
+
catch (error) { if (!['ENOENT', 'ENOTEMPTY', 'EEXIST'].includes(error.code)) throw error; }
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
module.exports = { registry, selectAgents, planInstallation, executeInstallation, exists };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vercel, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const readline = require('node:readline');
|
|
4
|
+
const { registry, selectAgents } = require('./install.cjs');
|
|
5
|
+
|
|
6
|
+
async function session(action) {
|
|
7
|
+
const terminal = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
8
|
+
let closed = false;
|
|
9
|
+
terminal.on('close', () => { closed = true; });
|
|
10
|
+
terminal.on('SIGINT', () => terminal.close());
|
|
11
|
+
const ask = prompt => new Promise(resolve => {
|
|
12
|
+
if (closed) { resolve(null); return; }
|
|
13
|
+
const cancelled = () => resolve(null);
|
|
14
|
+
terminal.once('close', cancelled);
|
|
15
|
+
terminal.question(prompt, answer => {
|
|
16
|
+
terminal.off('close', cancelled);
|
|
17
|
+
resolve(answer.trim());
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
try { return await action(ask); }
|
|
21
|
+
finally { terminal.close(); }
|
|
22
|
+
}
|
|
23
|
+
async function choose(options, identity) {
|
|
24
|
+
console.log(identity);
|
|
25
|
+
console.log('\nChoose tools (multiple selections are supported):');
|
|
26
|
+
const entries = registry.agents.map((agent, index) => `${index + 1}. ${agent.label} [${agent.id}]${agent.globalSkillsDir ? '' : ' (project only)'}`);
|
|
27
|
+
for (let index = 0; index < entries.length; index += 2) console.log(entries[index].padEnd(49) + (entries[index + 1] || ''));
|
|
28
|
+
return session(async ask => {
|
|
29
|
+
let agents;
|
|
30
|
+
while (!agents) {
|
|
31
|
+
const input = await ask(`Select tools by number or ID, comma-separated${options.agents.length ? ` [${options.agents.join(',')}]` : ''} (q cancels): `);
|
|
32
|
+
if (input === null || ['q', 'cancel'].includes(input.toLowerCase())) return null;
|
|
33
|
+
try {
|
|
34
|
+
const values = input === 'all' ? registry.agents.map(agent => agent.id) : input ? input.split(',').map(value => {
|
|
35
|
+
const trimmed = value.trim();
|
|
36
|
+
return /^\d+$/.test(trimmed) ? registry.agents[Number(trimmed) - 1]?.id || trimmed : trimmed;
|
|
37
|
+
}) : options.agents;
|
|
38
|
+
agents = selectAgents(values);
|
|
39
|
+
if (!agents.length) { agents = undefined; console.log('Choose at least one tool.'); }
|
|
40
|
+
} catch (error) { console.log(error.message); }
|
|
41
|
+
}
|
|
42
|
+
let scope = options.scope;
|
|
43
|
+
while (!scope) {
|
|
44
|
+
const input = await ask('Installation scope: 1. Project (current project), 2. Global (all projects) [1] (q cancels): ');
|
|
45
|
+
if (input === null || ['q', 'cancel'].includes(input.toLowerCase())) return null;
|
|
46
|
+
if (['', '1', 'project'].includes(input)) scope = 'project';
|
|
47
|
+
else if (['2', 'global'].includes(input)) scope = 'global';
|
|
48
|
+
else console.log('Choose 1 (project) or 2 (global).');
|
|
49
|
+
}
|
|
50
|
+
return { agents, scope };
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async function confirm(plan) {
|
|
54
|
+
console.log(`\nInstallation scope: ${plan.scope}`);
|
|
55
|
+
for (const target of plan.targets) {
|
|
56
|
+
console.log(` ${target.agents.join(', ')}: ${target.skillsDirectory}`);
|
|
57
|
+
if (target.commandsDirectory) console.log(` Commands: ${target.commandsDirectory}`);
|
|
58
|
+
}
|
|
59
|
+
if (plan.conflicts.length) console.log(`${plan.conflicts.length} existing assets will be preserved in backups before replacement.`);
|
|
60
|
+
console.log('Includes all skills and shared references. Plugin hooks require native plugin registration.');
|
|
61
|
+
return session(async ask => {
|
|
62
|
+
const answer = await ask('Install these files? [y/N]: ');
|
|
63
|
+
return answer !== null && ['y', 'yes'].includes(answer.toLowerCase());
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
module.exports = { choose, confirm };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const test = require('node:test');
|
|
4
|
+
const assert = require('node:assert/strict');
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const os = require('node:os');
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
const { spawnSync } = require('node:child_process');
|
|
9
|
+
const root = path.resolve(__dirname, '..');
|
|
10
|
+
const cli = path.join(root, 'bin/i3-composer-agent.cjs');
|
|
11
|
+
const upstream = require('../rebrand/upstream.json');
|
|
12
|
+
function workspace(t) {
|
|
13
|
+
const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'i3-agent-install-'));
|
|
14
|
+
t.after(() => fs.rmSync(directory, { recursive: true, force: true }));
|
|
15
|
+
return fs.realpathSync(directory);
|
|
16
|
+
}
|
|
17
|
+
function run(directory, args) {
|
|
18
|
+
return spawnSync(process.execPath, [cli, ...args], { cwd: directory, encoding: 'utf8' });
|
|
19
|
+
}
|
|
20
|
+
test('native CodeBuddy installation includes short commands, personas and usable references', t => {
|
|
21
|
+
const directory = workspace(t);
|
|
22
|
+
const result = run(directory, ['--codebuddy', '--scope', 'project', '--yes']);
|
|
23
|
+
assert.equal(result.status, 0, result.stderr);
|
|
24
|
+
const base = path.join(directory, '.codebuddy');
|
|
25
|
+
assert.equal(fs.readdirSync(path.join(base, 'skills')).length, upstream.skills.length);
|
|
26
|
+
assert.equal(fs.readdirSync(path.join(base, 'commands')).length, upstream.commands.length);
|
|
27
|
+
assert.equal(fs.readdirSync(path.join(base, 'agents')).length, upstream.personas.length);
|
|
28
|
+
const command = fs.readFileSync(path.join(base, 'commands/spec.md'), 'utf8');
|
|
29
|
+
assert.match(command, /Invoke the spec-driven-development skill/);
|
|
30
|
+
assert.doesNotMatch(command, /i3-composer-agent:/);
|
|
31
|
+
const ship = fs.readFileSync(path.join(base, 'commands/ship.md'), 'utf8');
|
|
32
|
+
assert.match(ship, /\.codebuddy\/agents\//);
|
|
33
|
+
assert.doesNotMatch(ship, /\.claude\/agents\//);
|
|
34
|
+
assert.ok(fs.existsSync(path.join(base, 'references/definition-of-done.md')));
|
|
35
|
+
assert.equal(fs.readFileSync(path.join(base, 'i3-composer-agent-LICENSE'), 'utf8'), fs.readFileSync(path.join(root, 'LICENSE'), 'utf8'));
|
|
36
|
+
assert.match(fs.readFileSync(path.join(base, 'i3-composer-agent-NOTICE.md'), 'utf8'), /Addy Osmani/);
|
|
37
|
+
assert.equal(fs.existsSync(path.join(directory, 'AGENTS.md')), false);
|
|
38
|
+
assert.equal(fs.existsSync(path.join(directory, 'i3-composer-agent')), false);
|
|
39
|
+
assert.match(result.stdout, /\/spec/);
|
|
40
|
+
});
|
|
41
|
+
test('multiple tools retain their own destinations and share universal skills without duplicate work', t => {
|
|
42
|
+
const directory = workspace(t);
|
|
43
|
+
const result = run(directory, ['--agents', 'codebuddy,codex,cursor,claude-code', '--scope', 'project', '--yes']);
|
|
44
|
+
assert.equal(result.status, 0, result.stderr);
|
|
45
|
+
for (const base of ['.codebuddy', '.agents', '.claude']) {
|
|
46
|
+
assert.equal(fs.readdirSync(path.join(directory, base, 'skills')).length, upstream.skills.length);
|
|
47
|
+
assert.ok(fs.existsSync(path.join(directory, base, 'references/testing-patterns.md')));
|
|
48
|
+
}
|
|
49
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(directory, '.agents/.i3-composer-agent.json')));
|
|
50
|
+
assert.deepEqual(manifest.agents.sort(), ['codex', 'cursor']);
|
|
51
|
+
assert.equal(fs.existsSync(path.join(directory, '.agents/commands')), false);
|
|
52
|
+
});
|
|
53
|
+
test('installation dry run describes scope and destinations without changing project files', t => {
|
|
54
|
+
const directory = workspace(t);
|
|
55
|
+
const result = run(directory, ['--agents', 'codebuddy,codex', '--scope', 'project', '--dry-run']);
|
|
56
|
+
assert.equal(result.status, 0, result.stderr);
|
|
57
|
+
const plan = JSON.parse(result.stdout);
|
|
58
|
+
assert.equal(plan.mode, 'install');
|
|
59
|
+
assert.equal(plan.scope, 'project');
|
|
60
|
+
assert.equal(plan.targets.length, 2);
|
|
61
|
+
assert.deepEqual(fs.readdirSync(directory), []);
|
|
62
|
+
});
|
|
63
|
+
test('all copied Markdown reference links and stable skill frontmatter remain valid', t => {
|
|
64
|
+
const directory = workspace(t);
|
|
65
|
+
assert.equal(run(directory, ['--codebuddy', '--scope', 'project', '--yes']).status, 0);
|
|
66
|
+
const base = path.join(directory, '.codebuddy');
|
|
67
|
+
function visit(folder) {
|
|
68
|
+
for (const entry of fs.readdirSync(folder, { withFileTypes: true })) {
|
|
69
|
+
const file = path.join(folder, entry.name);
|
|
70
|
+
if (entry.isDirectory()) visit(file);
|
|
71
|
+
else if (entry.name.endsWith('.md')) {
|
|
72
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
73
|
+
for (const match of content.matchAll(/\]\(([^)]+)\)/g)) {
|
|
74
|
+
const relative = match[1].split('#')[0];
|
|
75
|
+
if (relative.includes('references/') && !/^[a-z]+:/i.test(relative)) {
|
|
76
|
+
assert.ok(fs.existsSync(path.resolve(path.dirname(file), relative)), `${file}: ${relative}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
visit(path.join(base, 'skills'));
|
|
83
|
+
for (const id of upstream.skills) {
|
|
84
|
+
const head = content => content.match(/^---\r?\n[\s\S]*?\r?\n---/)[0];
|
|
85
|
+
assert.equal(head(fs.readFileSync(path.join(base, 'skills', id, 'SKILL.md'), 'utf8')), head(fs.readFileSync(path.join(root, 'skills', id, 'SKILL.md'), 'utf8')));
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
test('existing assets are protected; confirmed replacement backs them up and preserves unrelated settings', t => {
|
|
89
|
+
const directory = workspace(t);
|
|
90
|
+
const base = path.join(directory, '.codebuddy');
|
|
91
|
+
fs.mkdirSync(path.join(base, 'commands'), { recursive: true });
|
|
92
|
+
fs.writeFileSync(path.join(base, 'commands/spec.md'), 'my custom command');
|
|
93
|
+
fs.writeFileSync(path.join(base, 'settings.json'), '{"keep":"my settings"}\n');
|
|
94
|
+
const args = ['--codebuddy', '--scope', 'project', '--yes'];
|
|
95
|
+
assert.equal(run(directory, args).status, 1);
|
|
96
|
+
assert.equal(fs.existsSync(path.join(base, 'skills')), false);
|
|
97
|
+
const result = run(directory, [...args, '--force']);
|
|
98
|
+
assert.equal(result.status, 0, result.stderr);
|
|
99
|
+
const backups = fs.readdirSync(base).filter(file => file.startsWith('.i3-composer-agent-backup-'));
|
|
100
|
+
assert.equal(backups.length, 1);
|
|
101
|
+
assert.equal(fs.readFileSync(path.join(base, backups[0], 'commands/spec.md'), 'utf8'), 'my custom command');
|
|
102
|
+
assert.equal(fs.readFileSync(path.join(base, 'settings.json'), 'utf8'), '{"keep":"my settings"}\n');
|
|
103
|
+
assert.equal(fs.existsSync(path.join(base, backups[0], 'settings.json')), false);
|
|
104
|
+
});
|
|
105
|
+
test('global installation uses injected home and config roots without touching the real user configuration', t => {
|
|
106
|
+
const directory = workspace(t);
|
|
107
|
+
const { planInstallation, executeInstallation } = require('../bin/install.cjs');
|
|
108
|
+
const plan = planInstallation({ agents: ['codebuddy', 'codex', 'claude-code', 'opencode'], scope: 'global', home: directory, env: { XDG_CONFIG_HOME: path.join(directory, 'config'), CLAUDE_CONFIG_DIR: path.join(directory, 'custom-claude') } });
|
|
109
|
+
assert.ok(plan.targets.every(target => target.skillsDirectory.startsWith(directory + path.sep)));
|
|
110
|
+
assert.ok(plan.targets.some(target => target.skillsDirectory === path.join(directory, 'custom-claude/skills')));
|
|
111
|
+
assert.ok(plan.targets.some(target => target.skillsDirectory === path.join(directory, 'config/opencode/skills')));
|
|
112
|
+
executeInstallation(plan);
|
|
113
|
+
for (const target of plan.targets) {
|
|
114
|
+
assert.equal(fs.readdirSync(target.skillsDirectory).length, upstream.skills.length);
|
|
115
|
+
assert.ok(fs.existsSync(path.join(target.referencesDirectory, 'definition-of-done.md')));
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
test('the pinned tool catalog plans all project choices and rejects unsupported global choices before writing', t => {
|
|
119
|
+
const directory = workspace(t);
|
|
120
|
+
const { registry, planInstallation } = require('../bin/install.cjs');
|
|
121
|
+
assert.equal(registry.agents.length, 79);
|
|
122
|
+
assert.equal(registry.commit, '48dc9e8eb8aa19040e91cb90ba0b642c9cbad57e');
|
|
123
|
+
const plan = planInstallation({ agents: registry.agents.map(agent => agent.id), scope: 'project', projectDir: directory });
|
|
124
|
+
assert.equal(plan.agents.length, registry.agents.length);
|
|
125
|
+
assert.ok(plan.targets.length < plan.agents.length);
|
|
126
|
+
assert.equal(new Set(plan.assets.map(asset => asset.destination)).size, plan.assets.length);
|
|
127
|
+
for (const agent of registry.agents) {
|
|
128
|
+
if (agent.globalSkillsDir) assert.ok(planInstallation({ agents: [agent.id], scope: 'global', home: directory, env: {} }).targets[0].skillsDirectory.startsWith(directory + path.sep));
|
|
129
|
+
else assert.throws(() => planInstallation({ agents: [agent.id], scope: 'global', home: directory, env: {} }), /project installation only/);
|
|
130
|
+
}
|
|
131
|
+
assert.deepEqual(fs.readdirSync(directory), []);
|
|
132
|
+
});
|
|
133
|
+
test('failed installation restores prior assets and removes all newly written files', t => {
|
|
134
|
+
const directory = workspace(t);
|
|
135
|
+
const { planInstallation, executeInstallation } = require('../bin/install.cjs');
|
|
136
|
+
const prior = path.join(directory, '.codebuddy/skills/api-and-interface-design');
|
|
137
|
+
fs.mkdirSync(prior, { recursive: true });
|
|
138
|
+
fs.writeFileSync(path.join(prior, 'custom.md'), 'prior skill content');
|
|
139
|
+
const plan = planInstallation({ agents: ['codebuddy', 'codex'], scope: 'project', projectDir: directory });
|
|
140
|
+
const realRename = fs.renameSync;
|
|
141
|
+
let failed = false;
|
|
142
|
+
fs.renameSync = (source, destination) => {
|
|
143
|
+
if (!failed && destination === plan.assets[1].destination) { failed = true; throw new Error('simulated disk failure'); }
|
|
144
|
+
return realRename(source, destination);
|
|
145
|
+
};
|
|
146
|
+
try { assert.throws(() => executeInstallation(plan, { force: true }), /simulated disk failure/); }
|
|
147
|
+
finally { fs.renameSync = realRename; }
|
|
148
|
+
assert.equal(fs.readFileSync(path.join(prior, 'custom.md'), 'utf8'), 'prior skill content');
|
|
149
|
+
assert.deepEqual(fs.readdirSync(path.dirname(prior)), ['api-and-interface-design']);
|
|
150
|
+
assert.deepEqual(fs.readdirSync(path.join(directory, '.codebuddy')), ['skills']);
|
|
151
|
+
assert.equal(fs.existsSync(path.join(directory, '.agents')), false);
|
|
152
|
+
});
|
|
153
|
+
test('replacing a skill symlink backs up the link and leaves its external source untouched', t => {
|
|
154
|
+
const directory = workspace(t);
|
|
155
|
+
const external = path.join(directory, 'external-skill');
|
|
156
|
+
const skills = path.join(directory, '.codebuddy/skills');
|
|
157
|
+
fs.mkdirSync(external);
|
|
158
|
+
fs.writeFileSync(path.join(external, 'custom.md'), 'external source');
|
|
159
|
+
fs.mkdirSync(skills, { recursive: true });
|
|
160
|
+
fs.symlinkSync(external, path.join(skills, 'spec-driven-development'), 'dir');
|
|
161
|
+
const result = run(directory, ['--codebuddy', '--scope', 'project', '--yes', '--force']);
|
|
162
|
+
assert.equal(result.status, 0, result.stderr);
|
|
163
|
+
assert.deepEqual(fs.readdirSync(external), ['custom.md']);
|
|
164
|
+
assert.equal(fs.lstatSync(path.join(skills, 'spec-driven-development')).isSymbolicLink(), false);
|
|
165
|
+
const base = path.dirname(skills);
|
|
166
|
+
const backup = fs.readdirSync(base).find(file => file.startsWith('.i3-composer-agent-backup-'));
|
|
167
|
+
assert.equal(fs.lstatSync(path.join(base, backup, 'skills/spec-driven-development')).isSymbolicLink(), true);
|
|
168
|
+
});
|
|
169
|
+
test('package destinations, shared directory symlinks and ambiguous noninteractive flags fail without writes', t => {
|
|
170
|
+
const directory = workspace(t);
|
|
171
|
+
for (const args of [ ['--codebuddy'], ['--codebuddy', '--yes'], ['--agents', 'unknown', '--scope', 'project', '--yes'], ['--codebuddy', '--scope', 'invalid', '--yes'], ['--codebuddy', '--scope', 'project', '--global', '--yes'] ]) {
|
|
172
|
+
assert.equal(run(directory, args).status, 1);
|
|
173
|
+
assert.deepEqual(fs.readdirSync(directory), []);
|
|
174
|
+
}
|
|
175
|
+
assert.equal(run(directory, ['--codebuddy', '--scope', 'project', '--yes', '--project-dir', root]).status, 1);
|
|
176
|
+
fs.mkdirSync(path.join(directory, '.codebuddy'));
|
|
177
|
+
fs.symlinkSync(path.join(root, 'skills'), path.join(directory, '.codebuddy/skills'), 'dir');
|
|
178
|
+
assert.equal(run(directory, ['--codebuddy', '--scope', 'project', '--yes', '--force']).status, 1);
|
|
179
|
+
assert.deepEqual(fs.readdirSync(path.join(directory, '.codebuddy')), ['skills']);
|
|
180
|
+
});
|
|
181
|
+
test('explicit plugin preparation remains available and does not install native host files', t => {
|
|
182
|
+
const directory = workspace(t);
|
|
183
|
+
const result = run(directory, ['--prepare', '--codebuddy']);
|
|
184
|
+
assert.equal(result.status, 0, result.stderr);
|
|
185
|
+
assert.match(result.stdout, /\/plugin install/);
|
|
186
|
+
assert.equal(fs.existsSync(path.join(directory, 'i3-composer-agent/plugin.json')), true);
|
|
187
|
+
assert.equal(fs.existsSync(path.join(directory, '.codebuddy')), false);
|
|
188
|
+
const listing = run(directory, ['--list-agents']);
|
|
189
|
+
assert.equal(listing.status, 0, listing.stderr);
|
|
190
|
+
assert.equal(listing.stdout.trim().split('\n').length, 79);
|
|
191
|
+
assert.match(listing.stdout, /codebuddy/);
|
|
192
|
+
assert.match(listing.stdout, /windsurf/);
|
|
193
|
+
});
|