@swarmify/agents-cli 1.5.21 → 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 +93 -146
- 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';
|
|
@@ -31,48 +31,47 @@ import { parseAgentSpec, installVersion, removeVersion, removeAllVersions, listI
|
|
|
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
|
}
|
|
@@ -2431,53 +2419,12 @@ function getProjectVersionFromCwd(agent) {
|
|
|
2431
2419
|
}
|
|
2432
2420
|
try {
|
|
2433
2421
|
const manifest = readManifest(process.cwd());
|
|
2434
|
-
return manifest?.
|
|
2422
|
+
return manifest?.agents?.[agent] || null;
|
|
2435
2423
|
}
|
|
2436
2424
|
catch {
|
|
2437
2425
|
return null;
|
|
2438
2426
|
}
|
|
2439
2427
|
}
|
|
2440
|
-
program
|
|
2441
|
-
.command('upgrade [agent]')
|
|
2442
|
-
.description('Upgrade agent CLI versions')
|
|
2443
|
-
.option('-p, --project', 'Upgrade to version in project manifest')
|
|
2444
|
-
.action(async (agent, options) => {
|
|
2445
|
-
const agentsToUpgrade = agent
|
|
2446
|
-
? [agent.toLowerCase()]
|
|
2447
|
-
: ALL_AGENT_IDS.filter((id) => listInstalledVersions(id).length > 0);
|
|
2448
|
-
if (agentsToUpgrade.length === 0) {
|
|
2449
|
-
console.log(chalk.yellow('No agent CLIs installed. Run: agents add <agent>@<version>'));
|
|
2450
|
-
return;
|
|
2451
|
-
}
|
|
2452
|
-
for (const agentId of agentsToUpgrade) {
|
|
2453
|
-
const agentConfig = AGENTS[agentId];
|
|
2454
|
-
if (!agentConfig) {
|
|
2455
|
-
console.log(chalk.red(`Unknown agent: ${agentId}`));
|
|
2456
|
-
continue;
|
|
2457
|
-
}
|
|
2458
|
-
// Determine target version
|
|
2459
|
-
let targetVersion = 'latest';
|
|
2460
|
-
if (options.project) {
|
|
2461
|
-
const projectVersion = getProjectVersionFromCwd(agentId);
|
|
2462
|
-
if (projectVersion) {
|
|
2463
|
-
targetVersion = projectVersion;
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
const spinner = ora(`Upgrading ${agentConfig.name} to ${targetVersion}...`).start();
|
|
2467
|
-
const result = await installVersion(agentId, targetVersion, (msg) => {
|
|
2468
|
-
spinner.text = msg;
|
|
2469
|
-
});
|
|
2470
|
-
if (result.success) {
|
|
2471
|
-
spinner.succeed(`Upgraded ${agentConfig.name} to ${result.installedVersion}`);
|
|
2472
|
-
// Update global default to new version
|
|
2473
|
-
setGlobalDefault(agentId, result.installedVersion);
|
|
2474
|
-
}
|
|
2475
|
-
else {
|
|
2476
|
-
spinner.fail(`Failed to upgrade ${agentConfig.name}`);
|
|
2477
|
-
console.error(chalk.gray(result.error || 'Unknown error'));
|
|
2478
|
-
}
|
|
2479
|
-
}
|
|
2480
|
-
});
|
|
2481
2428
|
// =============================================================================
|
|
2482
2429
|
// REPO COMMANDS
|
|
2483
2430
|
// =============================================================================
|
|
@@ -2488,7 +2435,7 @@ repoCmd
|
|
|
2488
2435
|
.command('list')
|
|
2489
2436
|
.description('List configured scopes')
|
|
2490
2437
|
.action(() => {
|
|
2491
|
-
const scopes =
|
|
2438
|
+
const scopes = getReposByPriority();
|
|
2492
2439
|
if (scopes.length === 0) {
|
|
2493
2440
|
console.log(chalk.yellow('No scopes configured.'));
|
|
2494
2441
|
console.log(chalk.gray(' Run: agents repo add <source>'));
|
|
@@ -2514,11 +2461,11 @@ repoCmd
|
|
|
2514
2461
|
.option('-s, --scope <scope>', 'Target scope', 'user')
|
|
2515
2462
|
.option('-y, --yes', 'Skip confirmation prompts')
|
|
2516
2463
|
.action(async (source, options) => {
|
|
2517
|
-
const
|
|
2518
|
-
const
|
|
2519
|
-
if (
|
|
2464
|
+
const repoName = options.scope;
|
|
2465
|
+
const existingRepo = getRepo(repoName);
|
|
2466
|
+
if (existingRepo && !options.yes) {
|
|
2520
2467
|
const shouldOverwrite = await confirm({
|
|
2521
|
-
message: `Scope '${
|
|
2468
|
+
message: `Scope '${repoName}' already exists (${existingRepo.source}). Overwrite?`,
|
|
2522
2469
|
default: false,
|
|
2523
2470
|
});
|
|
2524
2471
|
if (!shouldOverwrite) {
|
|
@@ -2526,26 +2473,26 @@ repoCmd
|
|
|
2526
2473
|
return;
|
|
2527
2474
|
}
|
|
2528
2475
|
}
|
|
2529
|
-
if (
|
|
2530
|
-
console.log(chalk.red(`Scope '${
|
|
2476
|
+
if (existingRepo?.readonly && !options.yes) {
|
|
2477
|
+
console.log(chalk.red(`Scope '${repoName}' is readonly. Cannot overwrite.`));
|
|
2531
2478
|
return;
|
|
2532
2479
|
}
|
|
2533
2480
|
const parsed = parseSource(source);
|
|
2534
|
-
const spinner = ora(`Cloning repository for ${
|
|
2481
|
+
const spinner = ora(`Cloning repository for ${repoName} scope...`).start();
|
|
2535
2482
|
try {
|
|
2536
2483
|
const { commit, isNew } = await cloneRepo(source);
|
|
2537
2484
|
spinner.succeed(isNew ? 'Repository cloned' : 'Repository updated');
|
|
2538
|
-
const priority =
|
|
2539
|
-
|
|
2485
|
+
const priority = getRepoPriority(repoName);
|
|
2486
|
+
setRepo(repoName, {
|
|
2540
2487
|
source,
|
|
2541
2488
|
branch: parsed.ref || 'main',
|
|
2542
2489
|
commit,
|
|
2543
2490
|
lastSync: new Date().toISOString(),
|
|
2544
2491
|
priority,
|
|
2545
|
-
readonly:
|
|
2492
|
+
readonly: repoName === 'system',
|
|
2546
2493
|
});
|
|
2547
|
-
console.log(chalk.green(`\nAdded scope '${
|
|
2548
|
-
const scopeHint =
|
|
2494
|
+
console.log(chalk.green(`\nAdded scope '${repoName}' with priority ${priority}`));
|
|
2495
|
+
const scopeHint = repoName === 'user' ? '' : ` --scope ${repoName}`;
|
|
2549
2496
|
console.log(chalk.gray(` Run: agents pull${scopeHint} to sync commands`));
|
|
2550
2497
|
}
|
|
2551
2498
|
catch (err) {
|
|
@@ -2558,19 +2505,19 @@ repoCmd
|
|
|
2558
2505
|
.command('remove <scope>')
|
|
2559
2506
|
.description('Remove a scope')
|
|
2560
2507
|
.option('-y, --yes', 'Skip confirmation prompts')
|
|
2561
|
-
.action(async (
|
|
2562
|
-
const
|
|
2563
|
-
if (!
|
|
2564
|
-
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.`));
|
|
2565
2512
|
return;
|
|
2566
2513
|
}
|
|
2567
|
-
if (
|
|
2568
|
-
console.log(chalk.red(`Scope '${
|
|
2514
|
+
if (existingRepo.readonly) {
|
|
2515
|
+
console.log(chalk.red(`Scope '${repoName}' is readonly. Cannot remove.`));
|
|
2569
2516
|
return;
|
|
2570
2517
|
}
|
|
2571
2518
|
if (!options.yes) {
|
|
2572
2519
|
const shouldRemove = await confirm({
|
|
2573
|
-
message: `Remove scope '${
|
|
2520
|
+
message: `Remove scope '${repoName}' (${existingRepo.source})?`,
|
|
2574
2521
|
default: false,
|
|
2575
2522
|
});
|
|
2576
2523
|
if (!shouldRemove) {
|
|
@@ -2578,12 +2525,12 @@ repoCmd
|
|
|
2578
2525
|
return;
|
|
2579
2526
|
}
|
|
2580
2527
|
}
|
|
2581
|
-
const removed =
|
|
2528
|
+
const removed = removeRepo(repoName);
|
|
2582
2529
|
if (removed) {
|
|
2583
|
-
console.log(chalk.green(`Removed scope '${
|
|
2530
|
+
console.log(chalk.green(`Removed scope '${repoName}'`));
|
|
2584
2531
|
}
|
|
2585
2532
|
else {
|
|
2586
|
-
console.log(chalk.yellow(`Failed to remove scope '${
|
|
2533
|
+
console.log(chalk.yellow(`Failed to remove scope '${repoName}'`));
|
|
2587
2534
|
}
|
|
2588
2535
|
});
|
|
2589
2536
|
// =============================================================================
|