@swarmify/agents-cli 1.5.20 → 1.5.22
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/dist/index.js +132 -153
- package/dist/index.js.map +1 -1
- package/dist/lib/agents.d.ts +6 -1
- package/dist/lib/agents.d.ts.map +1 -1
- package/dist/lib/agents.js.map +1 -1
- package/dist/lib/manifest.d.ts.map +1 -1
- package/dist/lib/manifest.js +4 -13
- package/dist/lib/manifest.js.map +1 -1
- package/dist/lib/shims.d.ts.map +1 -1
- package/dist/lib/shims.js +11 -15
- package/dist/lib/shims.js.map +1 -1
- package/dist/lib/skills.d.ts.map +1 -1
- package/dist/lib/skills.js +13 -33
- package/dist/lib/skills.js.map +1 -1
- package/dist/lib/state.d.ts +14 -15
- package/dist/lib/state.d.ts.map +1 -1
- package/dist/lib/state.js +82 -71
- package/dist/lib/state.js.map +1 -1
- package/dist/lib/types.d.ts +8 -41
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/versions.d.ts +1 -9
- package/dist/lib/versions.d.ts.map +1 -1
- package/dist/lib/versions.js +25 -45
- package/dist/lib/versions.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18,8 +18,8 @@ function isPromptCancelled(err) {
|
|
|
18
18
|
}
|
|
19
19
|
import { AGENTS, ALL_AGENT_IDS, MCP_CAPABLE_AGENTS, SKILLS_CAPABLE_AGENTS, HOOKS_CAPABLE_AGENTS, getAllCliStates, getCliVersion, isMcpRegistered, registerMcp, unregisterMcp, listInstalledMcpsWithScope, promoteMcpToUser, } from './lib/agents.js';
|
|
20
20
|
import { readManifest, writeManifest, createDefaultManifest, MANIFEST_FILENAME, } from './lib/manifest.js';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import { readMeta, getRepoLocalPath, getRepo, setRepo, removeRepo, getReposByPriority, getRepoPriority, } from './lib/state.js';
|
|
22
|
+
import { REPO_PRIORITIES, DEFAULT_SYSTEM_REPO } from './lib/types.js';
|
|
23
23
|
import { cloneRepo, parseSource, getGitHubUsername, getRemoteUrl, setRemoteUrl, checkGitHubRepoExists, commitAndPush, hasUncommittedChanges, } from './lib/git.js';
|
|
24
24
|
import { discoverCommands, resolveCommandSource, installCommand, uninstallCommand, listInstalledCommandsWithScope, promoteCommandToUser, commandExists, commandContentMatches, } from './lib/commands.js';
|
|
25
25
|
import { discoverHooksFromRepo, installHooks, listInstalledHooksWithScope, promoteHookToUser, removeHook, hookExists, hookContentMatches, getSourceHookEntry, } from './lib/hooks.js';
|
|
@@ -27,52 +27,51 @@ import { discoverSkillsFromRepo, installSkill, uninstallSkill, listInstalledSkil
|
|
|
27
27
|
import { discoverInstructionsFromRepo, resolveInstructionsSource, installInstructions, uninstallInstructions, listInstalledInstructionsWithScope, promoteInstructionsToUser, instructionsExists, instructionsContentMatches, getInstructionsContent, } from './lib/instructions.js';
|
|
28
28
|
import { DEFAULT_REGISTRIES } from './lib/types.js';
|
|
29
29
|
import { search as searchRegistries, getRegistries, setRegistry, removeRegistry, resolvePackage, } from './lib/registry.js';
|
|
30
|
-
import { parseAgentSpec, installVersion, removeVersion, removeAllVersions, listInstalledVersions, getGlobalDefault, setGlobalDefault, isVersionInstalled, } from './lib/versions.js';
|
|
30
|
+
import { parseAgentSpec, installVersion, removeVersion, removeAllVersions, listInstalledVersions, getGlobalDefault, setGlobalDefault, isVersionInstalled, getVersionDir, } from './lib/versions.js';
|
|
31
31
|
import { createShim, removeShim, shimExists, isShimsInPath, getPathSetupInstructions, getShimsDir, } from './lib/shims.js';
|
|
32
32
|
const program = new Command();
|
|
33
33
|
/**
|
|
34
|
-
* Ensure at least one
|
|
35
|
-
* If not, automatically initialize the system
|
|
36
|
-
* Returns the highest priority
|
|
34
|
+
* Ensure at least one repo is configured.
|
|
35
|
+
* If not, automatically initialize the system repo from DEFAULT_SYSTEM_REPO.
|
|
36
|
+
* Returns the highest priority repo's source.
|
|
37
37
|
*/
|
|
38
|
-
async function ensureSource(
|
|
39
|
-
const meta =
|
|
40
|
-
// If specific
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
throw new Error(`
|
|
47
|
-
}
|
|
48
|
-
// Check if any
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
console.log(chalk.gray(`No repo configured. Initializing system scope from ${DEFAULT_SYSTEM_REPO}...`));
|
|
38
|
+
async function ensureSource(repoName) {
|
|
39
|
+
const meta = readMeta();
|
|
40
|
+
// If specific repo requested, check if it exists
|
|
41
|
+
if (repoName) {
|
|
42
|
+
const repo = meta.repos[repoName];
|
|
43
|
+
if (repo?.source) {
|
|
44
|
+
return repo.source;
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`Repo '${repoName}' not configured. Run: agents repo add <source> --name ${repoName}`);
|
|
47
|
+
}
|
|
48
|
+
// Check if any repo is configured
|
|
49
|
+
const repos = getReposByPriority();
|
|
50
|
+
if (repos.length > 0) {
|
|
51
|
+
return repos[repos.length - 1].config.source;
|
|
52
|
+
}
|
|
53
|
+
// No repos configured - initialize system repo
|
|
54
|
+
console.log(chalk.gray(`No repo configured. Initializing from ${DEFAULT_SYSTEM_REPO}...`));
|
|
56
55
|
const parsed = parseSource(DEFAULT_SYSTEM_REPO);
|
|
57
56
|
const { commit } = await cloneRepo(DEFAULT_SYSTEM_REPO);
|
|
58
|
-
|
|
57
|
+
setRepo('system', {
|
|
59
58
|
source: DEFAULT_SYSTEM_REPO,
|
|
60
59
|
branch: parsed.ref || 'main',
|
|
61
60
|
commit,
|
|
62
61
|
lastSync: new Date().toISOString(),
|
|
63
|
-
priority:
|
|
62
|
+
priority: REPO_PRIORITIES.system,
|
|
64
63
|
readonly: true,
|
|
65
64
|
});
|
|
66
65
|
return DEFAULT_SYSTEM_REPO;
|
|
67
66
|
}
|
|
68
67
|
/**
|
|
69
|
-
* Get
|
|
68
|
+
* Get local path for a named repo.
|
|
70
69
|
*/
|
|
71
|
-
function
|
|
72
|
-
const
|
|
73
|
-
if (!
|
|
70
|
+
function getRepoPath(repoName) {
|
|
71
|
+
const repo = getRepo(repoName);
|
|
72
|
+
if (!repo)
|
|
74
73
|
return null;
|
|
75
|
-
return getRepoLocalPath(
|
|
74
|
+
return getRepoLocalPath(repo.source);
|
|
76
75
|
}
|
|
77
76
|
program
|
|
78
77
|
.name('agents')
|
|
@@ -104,7 +103,6 @@ Agents
|
|
|
104
103
|
remove <agent>[@version] Remove agent CLI
|
|
105
104
|
use <agent>@<version> Set default version
|
|
106
105
|
list List installed versions
|
|
107
|
-
upgrade [agent] Upgrade to latest
|
|
108
106
|
|
|
109
107
|
Resources
|
|
110
108
|
instructions Manage CLAUDE.md, GEMINI.md, etc.
|
|
@@ -177,7 +175,7 @@ async function checkForUpdates() {
|
|
|
177
175
|
// Run update check before command runs
|
|
178
176
|
program.hook('preAction', async () => {
|
|
179
177
|
const args = process.argv.slice(2);
|
|
180
|
-
const skipCommands = ['
|
|
178
|
+
const skipCommands = ['--version', '-V', '--help', '-h'];
|
|
181
179
|
if (args.length === 0 || skipCommands.includes(args[0])) {
|
|
182
180
|
return;
|
|
183
181
|
}
|
|
@@ -237,7 +235,7 @@ program
|
|
|
237
235
|
agent: AGENTS[agentId],
|
|
238
236
|
instructions: listInstalledInstructionsWithScope(agentId, cwd),
|
|
239
237
|
}));
|
|
240
|
-
const scopes = filterAgentId ? [] :
|
|
238
|
+
const scopes = filterAgentId ? [] : getReposByPriority();
|
|
241
239
|
spinner.stop();
|
|
242
240
|
// Helper to format MCP with version
|
|
243
241
|
const formatMcp = (m, color) => {
|
|
@@ -395,39 +393,39 @@ program
|
|
|
395
393
|
}
|
|
396
394
|
}
|
|
397
395
|
}
|
|
398
|
-
const
|
|
399
|
-
const meta =
|
|
400
|
-
const
|
|
396
|
+
const repoName = options.scope;
|
|
397
|
+
const meta = readMeta();
|
|
398
|
+
const existingRepo = meta.repos[repoName];
|
|
401
399
|
// Try: 1) provided source, 2) existing scope source, 3) fall back to system scope
|
|
402
|
-
targetSource = targetSource ||
|
|
403
|
-
let
|
|
404
|
-
if (!targetSource &&
|
|
405
|
-
const systemScope = meta.
|
|
400
|
+
targetSource = targetSource || existingRepo?.source;
|
|
401
|
+
let effectiveRepo = repoName;
|
|
402
|
+
if (!targetSource && repoName === 'user') {
|
|
403
|
+
const systemScope = meta.repos['system'];
|
|
406
404
|
if (systemScope?.source) {
|
|
407
405
|
targetSource = systemScope.source;
|
|
408
|
-
|
|
406
|
+
effectiveRepo = 'system';
|
|
409
407
|
console.log(chalk.gray(`No user scope configured, using system scope: ${targetSource}\n`));
|
|
410
408
|
}
|
|
411
409
|
}
|
|
412
410
|
if (!targetSource) {
|
|
413
|
-
if (
|
|
411
|
+
if (repoName === 'user' && Object.keys(meta.repos).length === 0) {
|
|
414
412
|
console.log(chalk.gray(`First run detected. Initializing from ${DEFAULT_SYSTEM_REPO}...\n`));
|
|
415
413
|
targetSource = DEFAULT_SYSTEM_REPO;
|
|
416
|
-
|
|
414
|
+
effectiveRepo = 'system';
|
|
417
415
|
}
|
|
418
416
|
else {
|
|
419
|
-
console.log(chalk.red(`No source specified for scope '${
|
|
420
|
-
const scopeHint =
|
|
417
|
+
console.log(chalk.red(`No source specified for scope '${repoName}'.`));
|
|
418
|
+
const scopeHint = repoName === 'user' ? '' : ` --scope ${repoName}`;
|
|
421
419
|
console.log(chalk.gray(` Usage: agents pull <source>${scopeHint}`));
|
|
422
420
|
console.log(chalk.gray(' Example: agents pull gh:username/.agents'));
|
|
423
421
|
process.exit(1);
|
|
424
422
|
}
|
|
425
423
|
}
|
|
426
|
-
const
|
|
427
|
-
const isReadonly =
|
|
428
|
-
const isUserScope =
|
|
424
|
+
const targetRepoConfig = meta.repos[effectiveRepo];
|
|
425
|
+
const isReadonly = targetRepoConfig?.readonly || effectiveRepo === 'system';
|
|
426
|
+
const isUserScope = effectiveRepo === 'user';
|
|
429
427
|
const parsed = parseSource(targetSource);
|
|
430
|
-
const spinner = ora(`Syncing from ${
|
|
428
|
+
const spinner = ora(`Syncing from ${effectiveRepo} scope...`).start();
|
|
431
429
|
try {
|
|
432
430
|
const { localPath, commit, isNew } = await cloneRepo(targetSource);
|
|
433
431
|
spinner.succeed(isNew ? 'Repository cloned' : 'Repository updated');
|
|
@@ -1034,18 +1032,17 @@ program
|
|
|
1034
1032
|
}
|
|
1035
1033
|
}
|
|
1036
1034
|
// Sync CLI versions (user scope only)
|
|
1037
|
-
if (isUserScope && !options.skipClis && manifest?.
|
|
1035
|
+
if (isUserScope && !options.skipClis && manifest?.agents) {
|
|
1038
1036
|
const cliSpinner = ora('Checking CLI versions...').start();
|
|
1039
1037
|
const cliUpdates = [];
|
|
1040
|
-
for (const [agentIdStr,
|
|
1038
|
+
for (const [agentIdStr, targetVersion] of Object.entries(manifest.agents)) {
|
|
1041
1039
|
const agentId = agentIdStr;
|
|
1042
1040
|
if (agentFilter && agentId !== agentFilter)
|
|
1043
1041
|
continue;
|
|
1044
1042
|
const agent = AGENTS[agentId];
|
|
1045
|
-
if (!agent || !
|
|
1043
|
+
if (!agent || !targetVersion)
|
|
1046
1044
|
continue;
|
|
1047
1045
|
const currentVersion = await getCliVersion(agentId);
|
|
1048
|
-
const targetVersion = cliConfig.version;
|
|
1049
1046
|
if (currentVersion === targetVersion)
|
|
1050
1047
|
continue;
|
|
1051
1048
|
if (targetVersion === 'latest' && currentVersion)
|
|
@@ -1054,7 +1051,7 @@ program
|
|
|
1054
1051
|
}
|
|
1055
1052
|
if (cliUpdates.length > 0) {
|
|
1056
1053
|
cliSpinner.info('CLI version differences detected');
|
|
1057
|
-
console.log(chalk.gray(' Run `agents
|
|
1054
|
+
console.log(chalk.gray(' Run `agents add <agent>@latest` to update'));
|
|
1058
1055
|
for (const update of cliUpdates) {
|
|
1059
1056
|
console.log(chalk.gray(` ${update}`));
|
|
1060
1057
|
}
|
|
@@ -1065,8 +1062,8 @@ program
|
|
|
1065
1062
|
}
|
|
1066
1063
|
// Update scope config
|
|
1067
1064
|
if (!isReadonly) {
|
|
1068
|
-
const priority =
|
|
1069
|
-
|
|
1065
|
+
const priority = getRepoPriority(effectiveRepo);
|
|
1066
|
+
setRepo(effectiveRepo, {
|
|
1070
1067
|
source: targetSource,
|
|
1071
1068
|
branch: parsed.ref || 'main',
|
|
1072
1069
|
commit,
|
|
@@ -1075,7 +1072,7 @@ program
|
|
|
1075
1072
|
readonly: false,
|
|
1076
1073
|
});
|
|
1077
1074
|
}
|
|
1078
|
-
console.log(chalk.green(`\nSync complete from ${
|
|
1075
|
+
console.log(chalk.green(`\nSync complete from ${effectiveRepo} scope`));
|
|
1079
1076
|
}
|
|
1080
1077
|
catch (err) {
|
|
1081
1078
|
if (isPromptCancelled(err)) {
|
|
@@ -1098,15 +1095,15 @@ program
|
|
|
1098
1095
|
.option('-m, --message <msg>', 'Commit message', 'Update agent configuration')
|
|
1099
1096
|
.action(async (options) => {
|
|
1100
1097
|
try {
|
|
1101
|
-
const
|
|
1102
|
-
const scope =
|
|
1098
|
+
const repoName = options.scope;
|
|
1099
|
+
const scope = getRepo(repoName);
|
|
1103
1100
|
if (!scope) {
|
|
1104
|
-
console.log(chalk.red(`Scope '${
|
|
1101
|
+
console.log(chalk.red(`Scope '${repoName}' not configured.`));
|
|
1105
1102
|
console.log(chalk.gray(' Run: agents pull'));
|
|
1106
1103
|
process.exit(1);
|
|
1107
1104
|
}
|
|
1108
1105
|
if (scope.readonly) {
|
|
1109
|
-
console.log(chalk.red(`Scope '${
|
|
1106
|
+
console.log(chalk.red(`Scope '${repoName}' is readonly. Cannot push.`));
|
|
1110
1107
|
process.exit(1);
|
|
1111
1108
|
}
|
|
1112
1109
|
const localPath = getRepoLocalPath(scope.source);
|
|
@@ -1118,11 +1115,8 @@ program
|
|
|
1118
1115
|
const agent = AGENTS[agentId];
|
|
1119
1116
|
const cli = cliStates[agentId];
|
|
1120
1117
|
if (cli?.installed && cli.version) {
|
|
1121
|
-
manifest.
|
|
1122
|
-
manifest.
|
|
1123
|
-
package: agent.npmPackage,
|
|
1124
|
-
version: cli.version,
|
|
1125
|
-
};
|
|
1118
|
+
manifest.agents = manifest.agents || {};
|
|
1119
|
+
manifest.agents[agentId] = cli.version;
|
|
1126
1120
|
console.log(` ${chalk.green('+')} ${agent.name} @ ${cli.version}`);
|
|
1127
1121
|
exported++;
|
|
1128
1122
|
}
|
|
@@ -1854,8 +1848,8 @@ instructionsCmd
|
|
|
1854
1848
|
.description('Diff installed instructions against repo')
|
|
1855
1849
|
.action(async (agentArg) => {
|
|
1856
1850
|
const cwd = process.cwd();
|
|
1857
|
-
const meta =
|
|
1858
|
-
const scopes =
|
|
1851
|
+
const meta = readMeta();
|
|
1852
|
+
const scopes = getReposByPriority();
|
|
1859
1853
|
if (scopes.length === 0) {
|
|
1860
1854
|
console.log(chalk.yellow('No repo configured. Run: agents repo add <source>'));
|
|
1861
1855
|
return;
|
|
@@ -1864,7 +1858,7 @@ instructionsCmd
|
|
|
1864
1858
|
? [resolveAgentName(agentArg)].filter(Boolean)
|
|
1865
1859
|
: ALL_AGENT_IDS;
|
|
1866
1860
|
const diff = await import('diff');
|
|
1867
|
-
for (const { name:
|
|
1861
|
+
for (const { name: repoName, config } of scopes) {
|
|
1868
1862
|
const localPath = getRepoLocalPath(config.source);
|
|
1869
1863
|
const repoInstructions = discoverInstructionsFromRepo(localPath);
|
|
1870
1864
|
for (const agentId of agents) {
|
|
@@ -2208,11 +2202,8 @@ program
|
|
|
2208
2202
|
const manifest = fs.existsSync(projectManifestPath)
|
|
2209
2203
|
? readManifest(process.cwd()) || createDefaultManifest()
|
|
2210
2204
|
: createDefaultManifest();
|
|
2211
|
-
manifest.
|
|
2212
|
-
manifest.
|
|
2213
|
-
package: agentConfig.npmPackage,
|
|
2214
|
-
version: version === 'latest' ? (await getInstalledVersionForAgent(agent, version)) : version,
|
|
2215
|
-
};
|
|
2205
|
+
manifest.agents = manifest.agents || {};
|
|
2206
|
+
manifest.agents[agent] = version === 'latest' ? (await getInstalledVersionForAgent(agent, version)) : version;
|
|
2216
2207
|
writeManifest(process.cwd(), manifest);
|
|
2217
2208
|
console.log(chalk.green(` Pinned ${agentConfig.name}@${version} in .agents/agents.yaml`));
|
|
2218
2209
|
}
|
|
@@ -2275,8 +2266,8 @@ program
|
|
|
2275
2266
|
const projectManifestPath = path.join(process.cwd(), '.agents', 'agents.yaml');
|
|
2276
2267
|
if (fs.existsSync(projectManifestPath)) {
|
|
2277
2268
|
const manifest = readManifest(process.cwd());
|
|
2278
|
-
if (manifest?.
|
|
2279
|
-
delete manifest.
|
|
2269
|
+
if (manifest?.agents?.[agent]) {
|
|
2270
|
+
delete manifest.agents[agent];
|
|
2280
2271
|
writeManifest(process.cwd(), manifest);
|
|
2281
2272
|
console.log(chalk.gray(` Removed from .agents/agents.yaml`));
|
|
2282
2273
|
}
|
|
@@ -2320,11 +2311,8 @@ program
|
|
|
2320
2311
|
const manifest = fs.existsSync(projectManifestPath)
|
|
2321
2312
|
? readManifest(process.cwd()) || createDefaultManifest()
|
|
2322
2313
|
: createDefaultManifest();
|
|
2323
|
-
manifest.
|
|
2324
|
-
manifest.
|
|
2325
|
-
package: agentConfig.npmPackage,
|
|
2326
|
-
version,
|
|
2327
|
-
};
|
|
2314
|
+
manifest.agents = manifest.agents || {};
|
|
2315
|
+
manifest.agents[agent] = version;
|
|
2328
2316
|
writeManifest(process.cwd(), manifest);
|
|
2329
2317
|
console.log(chalk.green(`Set ${agentConfig.name}@${version} for this project`));
|
|
2330
2318
|
}
|
|
@@ -2335,14 +2323,34 @@ program
|
|
|
2335
2323
|
}
|
|
2336
2324
|
});
|
|
2337
2325
|
program
|
|
2338
|
-
.command('list')
|
|
2326
|
+
.command('list [agent]')
|
|
2339
2327
|
.description('List installed agent CLI versions')
|
|
2340
|
-
.action(async () => {
|
|
2328
|
+
.action(async (agentArg) => {
|
|
2341
2329
|
const cliStates = await getAllCliStates();
|
|
2330
|
+
// Resolve agent filter
|
|
2331
|
+
let filterAgentId;
|
|
2332
|
+
if (agentArg) {
|
|
2333
|
+
const agentMap = {
|
|
2334
|
+
claude: 'claude',
|
|
2335
|
+
'claude-code': 'claude',
|
|
2336
|
+
codex: 'codex',
|
|
2337
|
+
gemini: 'gemini',
|
|
2338
|
+
cursor: 'cursor',
|
|
2339
|
+
opencode: 'opencode',
|
|
2340
|
+
};
|
|
2341
|
+
filterAgentId = agentMap[agentArg.toLowerCase()];
|
|
2342
|
+
if (!filterAgentId) {
|
|
2343
|
+
console.log(chalk.red(`Unknown agent: ${agentArg}`));
|
|
2344
|
+
console.log(chalk.gray(`Valid agents: claude, codex, gemini, cursor, opencode`));
|
|
2345
|
+
process.exit(1);
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
const agentsToShow = filterAgentId ? [filterAgentId] : ALL_AGENT_IDS;
|
|
2349
|
+
const showPaths = !!filterAgentId; // Show paths when filtering to single agent
|
|
2342
2350
|
console.log(chalk.bold('Installed Agent CLIs\n'));
|
|
2343
2351
|
let hasAny = false;
|
|
2344
2352
|
let hasVersionManaged = false;
|
|
2345
|
-
for (const agentId of
|
|
2353
|
+
for (const agentId of agentsToShow) {
|
|
2346
2354
|
const agent = AGENTS[agentId];
|
|
2347
2355
|
const versions = listInstalledVersions(agentId);
|
|
2348
2356
|
const globalDefault = getGlobalDefault(agentId);
|
|
@@ -2356,6 +2364,10 @@ program
|
|
|
2356
2364
|
const isDefault = version === globalDefault;
|
|
2357
2365
|
const marker = isDefault ? chalk.green(' (default)') : '';
|
|
2358
2366
|
console.log(` ${version}${marker}`);
|
|
2367
|
+
if (showPaths) {
|
|
2368
|
+
const versionDir = getVersionDir(agentId, version);
|
|
2369
|
+
console.log(chalk.gray(` ${versionDir}`));
|
|
2370
|
+
}
|
|
2359
2371
|
}
|
|
2360
2372
|
// Check for project override
|
|
2361
2373
|
const projectVersion = getProjectVersionFromCwd(agentId);
|
|
@@ -2369,16 +2381,24 @@ program
|
|
|
2369
2381
|
hasAny = true;
|
|
2370
2382
|
console.log(` ${chalk.bold(agent.name)}`);
|
|
2371
2383
|
console.log(` ${cliState.version || 'installed'} ${chalk.gray('(global)')}`);
|
|
2384
|
+
if (showPaths && cliState.path) {
|
|
2385
|
+
console.log(chalk.gray(` ${cliState.path}`));
|
|
2386
|
+
}
|
|
2387
|
+
console.log();
|
|
2388
|
+
}
|
|
2389
|
+
else if (filterAgentId) {
|
|
2390
|
+
// Filtered to a specific agent but not installed
|
|
2391
|
+
console.log(` ${chalk.bold(agent.name)}: ${chalk.gray('not installed')}`);
|
|
2372
2392
|
console.log();
|
|
2373
2393
|
}
|
|
2374
2394
|
}
|
|
2375
|
-
if (!hasAny) {
|
|
2395
|
+
if (!hasAny && !filterAgentId) {
|
|
2376
2396
|
console.log(chalk.gray(' No agent CLIs installed.'));
|
|
2377
2397
|
console.log(chalk.gray(' Run: agents add claude@latest'));
|
|
2378
2398
|
console.log();
|
|
2379
2399
|
}
|
|
2380
|
-
// Show shims path status
|
|
2381
|
-
if (hasVersionManaged) {
|
|
2400
|
+
// Show shims path status (only for full list)
|
|
2401
|
+
if (hasVersionManaged && !filterAgentId) {
|
|
2382
2402
|
const shimsDir = getShimsDir();
|
|
2383
2403
|
if (isShimsInPath()) {
|
|
2384
2404
|
console.log(chalk.gray(`Shims: ${shimsDir} (in PATH)`));
|
|
@@ -2399,53 +2419,12 @@ function getProjectVersionFromCwd(agent) {
|
|
|
2399
2419
|
}
|
|
2400
2420
|
try {
|
|
2401
2421
|
const manifest = readManifest(process.cwd());
|
|
2402
|
-
return manifest?.
|
|
2422
|
+
return manifest?.agents?.[agent] || null;
|
|
2403
2423
|
}
|
|
2404
2424
|
catch {
|
|
2405
2425
|
return null;
|
|
2406
2426
|
}
|
|
2407
2427
|
}
|
|
2408
|
-
program
|
|
2409
|
-
.command('upgrade [agent]')
|
|
2410
|
-
.description('Upgrade agent CLI versions')
|
|
2411
|
-
.option('-p, --project', 'Upgrade to version in project manifest')
|
|
2412
|
-
.action(async (agent, options) => {
|
|
2413
|
-
const agentsToUpgrade = agent
|
|
2414
|
-
? [agent.toLowerCase()]
|
|
2415
|
-
: ALL_AGENT_IDS.filter((id) => listInstalledVersions(id).length > 0);
|
|
2416
|
-
if (agentsToUpgrade.length === 0) {
|
|
2417
|
-
console.log(chalk.yellow('No agent CLIs installed. Run: agents add <agent>@<version>'));
|
|
2418
|
-
return;
|
|
2419
|
-
}
|
|
2420
|
-
for (const agentId of agentsToUpgrade) {
|
|
2421
|
-
const agentConfig = AGENTS[agentId];
|
|
2422
|
-
if (!agentConfig) {
|
|
2423
|
-
console.log(chalk.red(`Unknown agent: ${agentId}`));
|
|
2424
|
-
continue;
|
|
2425
|
-
}
|
|
2426
|
-
// Determine target version
|
|
2427
|
-
let targetVersion = 'latest';
|
|
2428
|
-
if (options.project) {
|
|
2429
|
-
const projectVersion = getProjectVersionFromCwd(agentId);
|
|
2430
|
-
if (projectVersion) {
|
|
2431
|
-
targetVersion = projectVersion;
|
|
2432
|
-
}
|
|
2433
|
-
}
|
|
2434
|
-
const spinner = ora(`Upgrading ${agentConfig.name} to ${targetVersion}...`).start();
|
|
2435
|
-
const result = await installVersion(agentId, targetVersion, (msg) => {
|
|
2436
|
-
spinner.text = msg;
|
|
2437
|
-
});
|
|
2438
|
-
if (result.success) {
|
|
2439
|
-
spinner.succeed(`Upgraded ${agentConfig.name} to ${result.installedVersion}`);
|
|
2440
|
-
// Update global default to new version
|
|
2441
|
-
setGlobalDefault(agentId, result.installedVersion);
|
|
2442
|
-
}
|
|
2443
|
-
else {
|
|
2444
|
-
spinner.fail(`Failed to upgrade ${agentConfig.name}`);
|
|
2445
|
-
console.error(chalk.gray(result.error || 'Unknown error'));
|
|
2446
|
-
}
|
|
2447
|
-
}
|
|
2448
|
-
});
|
|
2449
2428
|
// =============================================================================
|
|
2450
2429
|
// REPO COMMANDS
|
|
2451
2430
|
// =============================================================================
|
|
@@ -2456,7 +2435,7 @@ repoCmd
|
|
|
2456
2435
|
.command('list')
|
|
2457
2436
|
.description('List configured scopes')
|
|
2458
2437
|
.action(() => {
|
|
2459
|
-
const scopes =
|
|
2438
|
+
const scopes = getReposByPriority();
|
|
2460
2439
|
if (scopes.length === 0) {
|
|
2461
2440
|
console.log(chalk.yellow('No scopes configured.'));
|
|
2462
2441
|
console.log(chalk.gray(' Run: agents repo add <source>'));
|
|
@@ -2482,11 +2461,11 @@ repoCmd
|
|
|
2482
2461
|
.option('-s, --scope <scope>', 'Target scope', 'user')
|
|
2483
2462
|
.option('-y, --yes', 'Skip confirmation prompts')
|
|
2484
2463
|
.action(async (source, options) => {
|
|
2485
|
-
const
|
|
2486
|
-
const
|
|
2487
|
-
if (
|
|
2464
|
+
const repoName = options.scope;
|
|
2465
|
+
const existingRepo = getRepo(repoName);
|
|
2466
|
+
if (existingRepo && !options.yes) {
|
|
2488
2467
|
const shouldOverwrite = await confirm({
|
|
2489
|
-
message: `Scope '${
|
|
2468
|
+
message: `Scope '${repoName}' already exists (${existingRepo.source}). Overwrite?`,
|
|
2490
2469
|
default: false,
|
|
2491
2470
|
});
|
|
2492
2471
|
if (!shouldOverwrite) {
|
|
@@ -2494,26 +2473,26 @@ repoCmd
|
|
|
2494
2473
|
return;
|
|
2495
2474
|
}
|
|
2496
2475
|
}
|
|
2497
|
-
if (
|
|
2498
|
-
console.log(chalk.red(`Scope '${
|
|
2476
|
+
if (existingRepo?.readonly && !options.yes) {
|
|
2477
|
+
console.log(chalk.red(`Scope '${repoName}' is readonly. Cannot overwrite.`));
|
|
2499
2478
|
return;
|
|
2500
2479
|
}
|
|
2501
2480
|
const parsed = parseSource(source);
|
|
2502
|
-
const spinner = ora(`Cloning repository for ${
|
|
2481
|
+
const spinner = ora(`Cloning repository for ${repoName} scope...`).start();
|
|
2503
2482
|
try {
|
|
2504
2483
|
const { commit, isNew } = await cloneRepo(source);
|
|
2505
2484
|
spinner.succeed(isNew ? 'Repository cloned' : 'Repository updated');
|
|
2506
|
-
const priority =
|
|
2507
|
-
|
|
2485
|
+
const priority = getRepoPriority(repoName);
|
|
2486
|
+
setRepo(repoName, {
|
|
2508
2487
|
source,
|
|
2509
2488
|
branch: parsed.ref || 'main',
|
|
2510
2489
|
commit,
|
|
2511
2490
|
lastSync: new Date().toISOString(),
|
|
2512
2491
|
priority,
|
|
2513
|
-
readonly:
|
|
2492
|
+
readonly: repoName === 'system',
|
|
2514
2493
|
});
|
|
2515
|
-
console.log(chalk.green(`\nAdded scope '${
|
|
2516
|
-
const scopeHint =
|
|
2494
|
+
console.log(chalk.green(`\nAdded scope '${repoName}' with priority ${priority}`));
|
|
2495
|
+
const scopeHint = repoName === 'user' ? '' : ` --scope ${repoName}`;
|
|
2517
2496
|
console.log(chalk.gray(` Run: agents pull${scopeHint} to sync commands`));
|
|
2518
2497
|
}
|
|
2519
2498
|
catch (err) {
|
|
@@ -2526,19 +2505,19 @@ repoCmd
|
|
|
2526
2505
|
.command('remove <scope>')
|
|
2527
2506
|
.description('Remove a scope')
|
|
2528
2507
|
.option('-y, --yes', 'Skip confirmation prompts')
|
|
2529
|
-
.action(async (
|
|
2530
|
-
const
|
|
2531
|
-
if (!
|
|
2532
|
-
console.log(chalk.yellow(`Scope '${
|
|
2508
|
+
.action(async (repoName, options) => {
|
|
2509
|
+
const existingRepo = getRepo(repoName);
|
|
2510
|
+
if (!existingRepo) {
|
|
2511
|
+
console.log(chalk.yellow(`Scope '${repoName}' not found.`));
|
|
2533
2512
|
return;
|
|
2534
2513
|
}
|
|
2535
|
-
if (
|
|
2536
|
-
console.log(chalk.red(`Scope '${
|
|
2514
|
+
if (existingRepo.readonly) {
|
|
2515
|
+
console.log(chalk.red(`Scope '${repoName}' is readonly. Cannot remove.`));
|
|
2537
2516
|
return;
|
|
2538
2517
|
}
|
|
2539
2518
|
if (!options.yes) {
|
|
2540
2519
|
const shouldRemove = await confirm({
|
|
2541
|
-
message: `Remove scope '${
|
|
2520
|
+
message: `Remove scope '${repoName}' (${existingRepo.source})?`,
|
|
2542
2521
|
default: false,
|
|
2543
2522
|
});
|
|
2544
2523
|
if (!shouldRemove) {
|
|
@@ -2546,12 +2525,12 @@ repoCmd
|
|
|
2546
2525
|
return;
|
|
2547
2526
|
}
|
|
2548
2527
|
}
|
|
2549
|
-
const removed =
|
|
2528
|
+
const removed = removeRepo(repoName);
|
|
2550
2529
|
if (removed) {
|
|
2551
|
-
console.log(chalk.green(`Removed scope '${
|
|
2530
|
+
console.log(chalk.green(`Removed scope '${repoName}'`));
|
|
2552
2531
|
}
|
|
2553
2532
|
else {
|
|
2554
|
-
console.log(chalk.yellow(`Failed to remove scope '${
|
|
2533
|
+
console.log(chalk.yellow(`Failed to remove scope '${repoName}'`));
|
|
2555
2534
|
}
|
|
2556
2535
|
});
|
|
2557
2536
|
// =============================================================================
|