@phnx-labs/agents-cli 1.14.2 → 1.14.3
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 +17 -7
- package/dist/commands/browser.d.ts +2 -0
- package/dist/commands/browser.js +388 -0
- package/dist/commands/daemon.js +1 -1
- package/dist/commands/doctor.d.ts +16 -9
- package/dist/commands/doctor.js +248 -12
- package/dist/commands/prune.js +9 -3
- package/dist/commands/refresh-rules.d.ts +15 -0
- package/dist/commands/{refresh-memory.js → refresh-rules.js} +14 -14
- package/dist/commands/routines.js +1 -1
- package/dist/commands/rules.js +100 -4
- package/dist/commands/secrets.js +198 -11
- package/dist/commands/sync.js +19 -0
- package/dist/commands/teams.js +162 -22
- package/dist/commands/trash.d.ts +10 -0
- package/dist/commands/trash.js +187 -0
- package/dist/commands/view.js +46 -13
- package/dist/index.js +62 -4
- package/dist/lib/agents.js +2 -2
- package/dist/lib/browser/cdp.d.ts +24 -0
- package/dist/lib/browser/cdp.js +94 -0
- package/dist/lib/browser/chrome.d.ts +16 -0
- package/dist/lib/browser/chrome.js +157 -0
- package/dist/lib/browser/drivers/local.d.ts +8 -0
- package/dist/lib/browser/drivers/local.js +22 -0
- package/dist/lib/browser/drivers/ssh.d.ts +9 -0
- package/dist/lib/browser/drivers/ssh.js +129 -0
- package/dist/lib/browser/index.d.ts +5 -0
- package/dist/lib/browser/index.js +5 -0
- package/dist/lib/browser/input.d.ts +6 -0
- package/dist/lib/browser/input.js +52 -0
- package/dist/lib/browser/ipc.d.ts +12 -0
- package/dist/lib/browser/ipc.js +223 -0
- package/dist/lib/browser/profiles.d.ts +11 -0
- package/dist/lib/browser/profiles.js +61 -0
- package/dist/lib/browser/refs.d.ts +21 -0
- package/dist/lib/browser/refs.js +88 -0
- package/dist/lib/browser/service.d.ts +45 -0
- package/dist/lib/browser/service.js +404 -0
- package/dist/lib/browser/types.d.ts +73 -0
- package/dist/lib/browser/types.js +7 -0
- package/dist/lib/cloud/codex.js +1 -1
- package/dist/lib/cloud/registry.js +2 -2
- package/dist/lib/cloud/rush.js +2 -2
- package/dist/lib/cloud/store.js +2 -2
- package/dist/lib/daemon.d.ts +1 -1
- package/dist/lib/daemon.js +47 -11
- package/dist/lib/diff-text.d.ts +25 -0
- package/dist/lib/diff-text.js +47 -0
- package/dist/lib/doctor-diff.d.ts +64 -0
- package/dist/lib/doctor-diff.js +497 -0
- package/dist/lib/git.js +3 -3
- package/dist/lib/hooks.d.ts +6 -0
- package/dist/lib/hooks.js +6 -1
- package/dist/lib/migrate.js +77 -0
- package/dist/lib/pty-client.js +3 -3
- package/dist/lib/pty-server.js +36 -7
- package/dist/lib/resources.js +1 -1
- package/dist/lib/rotate.d.ts +8 -1
- package/dist/lib/rotate.js +17 -4
- package/dist/lib/rules/compile.d.ts +104 -0
- package/dist/lib/{memory-compile.js → rules/compile.js} +160 -21
- package/dist/lib/rules/compose.d.ts +78 -0
- package/dist/lib/rules/compose.js +170 -0
- package/dist/lib/{memory.d.ts → rules/rules.d.ts} +5 -5
- package/dist/lib/{memory.js → rules/rules.js} +10 -10
- package/dist/lib/secrets/AgentsKeychain.app/Contents/CodeResources +0 -0
- package/dist/lib/secrets/AgentsKeychain.app/Contents/MacOS/AgentsKeychain +0 -0
- package/dist/lib/secrets/bundles.d.ts +61 -4
- package/dist/lib/secrets/bundles.js +222 -54
- package/dist/lib/secrets/index.d.ts +24 -5
- package/dist/lib/secrets/index.js +70 -41
- package/dist/lib/session/active.js +5 -5
- package/dist/lib/session/db.js +4 -4
- package/dist/lib/session/discover.js +2 -2
- package/dist/lib/session/render.js +21 -7
- package/dist/lib/shims.d.ts +28 -4
- package/dist/lib/shims.js +72 -14
- package/dist/lib/state.d.ts +22 -28
- package/dist/lib/state.js +83 -76
- package/dist/lib/sync-manifest.d.ts +2 -2
- package/dist/lib/sync-manifest.js +5 -5
- package/dist/lib/teams/agents.d.ts +4 -2
- package/dist/lib/teams/agents.js +11 -4
- package/dist/lib/teams/api.d.ts +1 -1
- package/dist/lib/teams/api.js +2 -2
- package/dist/lib/teams/index.d.ts +1 -0
- package/dist/lib/teams/index.js +1 -0
- package/dist/lib/teams/persistence.js +3 -3
- package/dist/lib/teams/registry.d.ts +8 -1
- package/dist/lib/teams/registry.js +8 -2
- package/dist/lib/teams/worktree.d.ts +30 -0
- package/dist/lib/teams/worktree.js +96 -0
- package/dist/lib/types.d.ts +12 -6
- package/dist/lib/types.js +3 -3
- package/dist/lib/versions.d.ts +30 -2
- package/dist/lib/versions.js +127 -105
- package/package.json +1 -1
- package/scripts/postinstall.js +29 -0
- package/dist/commands/refresh-memory.d.ts +0 -15
- package/dist/lib/memory-compile.d.ts +0 -66
|
@@ -1451,12 +1451,12 @@ function normalizeVersion(version) {
|
|
|
1451
1451
|
const trimmed = version?.trim();
|
|
1452
1452
|
return trimmed ? trimmed : undefined;
|
|
1453
1453
|
}
|
|
1454
|
-
/** Extract the version number from a managed ~/.agents
|
|
1454
|
+
/** Extract the version number from a managed ~/.agents/versions/<agent>/<version>/... path. */
|
|
1455
1455
|
function extractVersionFromManagedPath(agent, sourcePath) {
|
|
1456
1456
|
if (!sourcePath)
|
|
1457
1457
|
return undefined;
|
|
1458
1458
|
const candidates = [sourcePath, safeRealpathSync(sourcePath) || ''];
|
|
1459
|
-
const marker = `/.agents
|
|
1459
|
+
const marker = `/.agents/versions/${agent}/`;
|
|
1460
1460
|
for (const candidate of candidates) {
|
|
1461
1461
|
if (!candidate)
|
|
1462
1462
|
continue;
|
|
@@ -424,6 +424,7 @@ export function renderSummary(events, cwd) {
|
|
|
424
424
|
// Plan items
|
|
425
425
|
const todoItems = [];
|
|
426
426
|
let exitPlanContent = null;
|
|
427
|
+
let planFilePath = null;
|
|
427
428
|
// Subagent spawns
|
|
428
429
|
const subagents = [];
|
|
429
430
|
// Errors
|
|
@@ -444,8 +445,14 @@ export function renderSummary(events, cwd) {
|
|
|
444
445
|
filesReadAbs.add(p);
|
|
445
446
|
}
|
|
446
447
|
else if (['Write', 'Edit', 'write_file', 'edit_file', 'create_file', 'replace', 'patch'].includes(tool)) {
|
|
447
|
-
if (p)
|
|
448
|
-
(
|
|
448
|
+
if (p) {
|
|
449
|
+
if (p.includes('.claude/plans/') && p.endsWith('.md')) {
|
|
450
|
+
planFilePath = p;
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
(isInsideCwd(p) || !cwd ? filesModifiedAbs : filesModifiedExternal).add(p);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
449
456
|
}
|
|
450
457
|
if (event.command) {
|
|
451
458
|
const cmd = event.command.replace(/\n/g, ' ').trim();
|
|
@@ -543,14 +550,19 @@ export function renderSummary(events, cwd) {
|
|
|
543
550
|
if (firstUserMessage || attachments.length > 0)
|
|
544
551
|
lines.push('');
|
|
545
552
|
// 2. Plan
|
|
546
|
-
if (todoItems.length > 0 || exitPlanContent) {
|
|
553
|
+
if (todoItems.length > 0 || exitPlanContent || planFilePath) {
|
|
547
554
|
lines.push(chalk.bold('Plan'));
|
|
555
|
+
if (planFilePath) {
|
|
556
|
+
const home = process.env.HOME ?? '';
|
|
557
|
+
const displayPath = home && planFilePath.startsWith(home) ? planFilePath.replace(home, '~') : planFilePath;
|
|
558
|
+
lines.push(' ' + chalk.cyan(displayPath));
|
|
559
|
+
}
|
|
548
560
|
if (exitPlanContent) {
|
|
549
561
|
const planLines = exitPlanContent.split('\n').slice(0, 10);
|
|
550
562
|
for (const l of planLines)
|
|
551
563
|
lines.push(' ' + l);
|
|
552
564
|
}
|
|
553
|
-
else {
|
|
565
|
+
else if (todoItems.length > 0) {
|
|
554
566
|
for (const item of todoItems.slice(0, 20)) {
|
|
555
567
|
lines.push(' · ' + item);
|
|
556
568
|
}
|
|
@@ -574,12 +586,14 @@ export function renderSummary(events, cwd) {
|
|
|
574
586
|
lines.push('');
|
|
575
587
|
}
|
|
576
588
|
// 4b. External edits (files edited outside the project root — typically /tmp)
|
|
577
|
-
|
|
578
|
-
|
|
589
|
+
// Filter out plan files (already shown in Plan section)
|
|
590
|
+
const externalNonPlan = [...filesModifiedExternal].filter(p => !(p.includes('.claude/plans/') && p.endsWith('.md')));
|
|
591
|
+
if (externalNonPlan.length > 0) {
|
|
592
|
+
const externalList = externalNonPlan.sort();
|
|
579
593
|
const home = process.env.HOME ?? '';
|
|
580
594
|
const display = externalList.slice(0, 3).map(p => home && p.startsWith(home) ? p.replace(home, '~') : p);
|
|
581
595
|
const more = externalList.length > 3 ? chalk.gray(` +${externalList.length - 3} more`) : '';
|
|
582
|
-
lines.push(chalk.gray(`External edits (${
|
|
596
|
+
lines.push(chalk.gray(`External edits (${externalList.length}): ${display.join(', ')}${more}`));
|
|
583
597
|
lines.push('');
|
|
584
598
|
}
|
|
585
599
|
// 5. Read files
|
package/dist/lib/shims.d.ts
CHANGED
|
@@ -42,9 +42,9 @@ export declare function promptConflictStrategy(conflictInfos: ConflictInfo[]): P
|
|
|
42
42
|
*
|
|
43
43
|
* History:
|
|
44
44
|
* v1 — initial shim (implicit, no marker).
|
|
45
|
-
* v2 — `--version=...` form in sync/refresh-
|
|
45
|
+
* v2 — `--version=...` form in sync/refresh-rules calls; refresh-rules
|
|
46
46
|
* shim hook for non-@-capable agents.
|
|
47
|
-
* v3 — sync/refresh-
|
|
47
|
+
* v3 — sync/refresh-rules flag renamed `--version` → `--agent-version`
|
|
48
48
|
* so it no longer collides with commander's top-level `--version`.
|
|
49
49
|
* v4 — project version marker changed from `.agents-version` to a
|
|
50
50
|
* root-level `agents.yaml`; shim now skips ~/.agents/agents.yaml
|
|
@@ -53,8 +53,12 @@ export declare function promptConflictStrategy(conflictInfos: ConflictInfo[]): P
|
|
|
53
53
|
* sandbox_mode, rules/agents-deny.rules) is actually read by the codex
|
|
54
54
|
* binary instead of $HOME/.codex.
|
|
55
55
|
* v6 — hard-disable Codex startup update checks in the generated shims.
|
|
56
|
+
* v7 — rename `agents refresh-memory` invocation to `agents refresh-rules`
|
|
57
|
+
* and capability flag `memoryImports` → `rulesImports`.
|
|
58
|
+
* v8 — versions moved from ~/.agents-system/versions to ~/.agents/versions
|
|
59
|
+
* (two-repo split: system = shipped defaults, user = operational state).
|
|
56
60
|
*/
|
|
57
|
-
export declare const SHIM_SCHEMA_VERSION =
|
|
61
|
+
export declare const SHIM_SCHEMA_VERSION = 8;
|
|
58
62
|
/**
|
|
59
63
|
* Generate the full bash shim script for the given agent. The returned string
|
|
60
64
|
* is written to ~/.agents/shims/{cliCommand} and made executable.
|
|
@@ -83,8 +87,10 @@ export declare function removeShim(agent: AgentId): boolean;
|
|
|
83
87
|
* read the versioned permissions/rules instead of $HOME/.codex.
|
|
84
88
|
* v4 — direct aliases read binaries and config homes from ~/.agents-system.
|
|
85
89
|
* v5 — hard-disable Codex startup update checks in versioned aliases.
|
|
90
|
+
* v6 — versions moved from ~/.agents-system/versions to ~/.agents/versions
|
|
91
|
+
* (two-repo split: system = shipped defaults, user = operational state).
|
|
86
92
|
*/
|
|
87
|
-
export declare const VERSIONED_ALIAS_SCHEMA_VERSION =
|
|
93
|
+
export declare const VERSIONED_ALIAS_SCHEMA_VERSION = 6;
|
|
88
94
|
/**
|
|
89
95
|
* Generate a versioned alias script that directly execs a specific version.
|
|
90
96
|
* e.g., claude@2.0.65 -> directly runs that version's binary
|
|
@@ -219,8 +225,26 @@ export declare function getShimPath(agent: AgentId): string;
|
|
|
219
225
|
/**
|
|
220
226
|
* Return the first executable path that would be launched for this agent when
|
|
221
227
|
* resolving against PATH, excluding the managed shim itself.
|
|
228
|
+
*
|
|
229
|
+
* Legacy ~/.agents/shims/<cli> (from the pre-split single-root layout) is NOT
|
|
230
|
+
* treated as a shadow when a current managed shim exists at getShimPath() —
|
|
231
|
+
* that file is dead weight from the old layout and the repair flow removes it
|
|
232
|
+
* separately. Treating it as "shadowing" caused an infinite repair-prompt
|
|
233
|
+
* loop because addShimsToPath() only edits the rc file, never the legacy
|
|
234
|
+
* shim file itself.
|
|
222
235
|
*/
|
|
223
236
|
export declare function getPathShadowingExecutable(agent: AgentId): string | null;
|
|
237
|
+
/**
|
|
238
|
+
* Delete the legacy ~/.agents/shims/<cli> file if it exists, returning whether
|
|
239
|
+
* anything was removed. Pre-split installs put shims under ~/.agents/shims/;
|
|
240
|
+
* the new layout uses ~/.agents-system/shims/. The leftover file causes the
|
|
241
|
+
* repair-prompt loop reported in RUSH-664 — `getPathShadowingExecutable` flags
|
|
242
|
+
* it as a shadow but `addShimsToPath` only edits rc files, never the file
|
|
243
|
+
* itself. Removing it ends the loop.
|
|
244
|
+
*/
|
|
245
|
+
export declare function removeLegacyUserShim(agent: AgentId, overrides?: {
|
|
246
|
+
homeDir?: string;
|
|
247
|
+
}): boolean;
|
|
224
248
|
/**
|
|
225
249
|
* Check if the agent's CLI command is shadowed by a shell alias.
|
|
226
250
|
*
|
package/dist/lib/shims.js
CHANGED
|
@@ -156,9 +156,9 @@ export async function promptConflictStrategy(conflictInfos) {
|
|
|
156
156
|
*
|
|
157
157
|
* History:
|
|
158
158
|
* v1 — initial shim (implicit, no marker).
|
|
159
|
-
* v2 — `--version=...` form in sync/refresh-
|
|
159
|
+
* v2 — `--version=...` form in sync/refresh-rules calls; refresh-rules
|
|
160
160
|
* shim hook for non-@-capable agents.
|
|
161
|
-
* v3 — sync/refresh-
|
|
161
|
+
* v3 — sync/refresh-rules flag renamed `--version` → `--agent-version`
|
|
162
162
|
* so it no longer collides with commander's top-level `--version`.
|
|
163
163
|
* v4 — project version marker changed from `.agents-version` to a
|
|
164
164
|
* root-level `agents.yaml`; shim now skips ~/.agents/agents.yaml
|
|
@@ -167,8 +167,12 @@ export async function promptConflictStrategy(conflictInfos) {
|
|
|
167
167
|
* sandbox_mode, rules/agents-deny.rules) is actually read by the codex
|
|
168
168
|
* binary instead of $HOME/.codex.
|
|
169
169
|
* v6 — hard-disable Codex startup update checks in the generated shims.
|
|
170
|
+
* v7 — rename `agents refresh-memory` invocation to `agents refresh-rules`
|
|
171
|
+
* and capability flag `memoryImports` → `rulesImports`.
|
|
172
|
+
* v8 — versions moved from ~/.agents-system/versions to ~/.agents/versions
|
|
173
|
+
* (two-repo split: system = shipped defaults, user = operational state).
|
|
170
174
|
*/
|
|
171
|
-
export const SHIM_SCHEMA_VERSION =
|
|
175
|
+
export const SHIM_SCHEMA_VERSION = 8;
|
|
172
176
|
/** Internal marker string used to embed the schema version in shim scripts. */
|
|
173
177
|
const SHIM_VERSION_MARKER = 'agents-shim-version:';
|
|
174
178
|
/**
|
|
@@ -194,16 +198,16 @@ export CLAUDE_CONFIG_DIR="$VERSION_DIR/home/${configDirName}"
|
|
|
194
198
|
export CODEX_HOME="$VERSION_DIR/home/${configDirName}"
|
|
195
199
|
`
|
|
196
200
|
: '';
|
|
197
|
-
// Agents that don't natively resolve @-imports in their
|
|
201
|
+
// Agents that don't natively resolve @-imports in their rules file need
|
|
198
202
|
// agents-cli to recompile when the user edits a rule/preset file. The
|
|
199
203
|
// check is fast (sha256 of ~8 small files) and skips the recompile when
|
|
200
204
|
// sources haven't changed.
|
|
201
|
-
const
|
|
205
|
+
const refreshRulesCall = !agentConfig.capabilities.rulesImports
|
|
202
206
|
? `
|
|
203
|
-
# Recompile
|
|
207
|
+
# Recompile rules if any rule/preset source has changed since last sync.
|
|
204
208
|
# Fast-path check (~10-20ms) when nothing changed; full recompile only on
|
|
205
209
|
# actual diff. Non-blocking failure — if the refresh errors, we still launch.
|
|
206
|
-
agents refresh-
|
|
210
|
+
agents refresh-rules --agent "$AGENT" --agent-version "$VERSION" --quiet 2>/dev/null || true
|
|
207
211
|
`
|
|
208
212
|
: '';
|
|
209
213
|
const launchArgs = agent === 'codex' ? ' -c check_for_update_on_startup=false' : '';
|
|
@@ -283,7 +287,7 @@ if [ -z "$VERSION" ]; then
|
|
|
283
287
|
exit 1
|
|
284
288
|
fi
|
|
285
289
|
|
|
286
|
-
VERSION_DIR="$
|
|
290
|
+
VERSION_DIR="$AGENTS_USER_DIR/versions/$AGENT/$VERSION"
|
|
287
291
|
BINARY="$VERSION_DIR/node_modules/.bin/$CLI_COMMAND"
|
|
288
292
|
|
|
289
293
|
# Auto-install if not present
|
|
@@ -328,7 +332,7 @@ PROJECT_AGENTS_DIR=$(find_project_agents_dir)
|
|
|
328
332
|
if [ -n "$PROJECT_AGENTS_DIR" ]; then
|
|
329
333
|
agents sync --agent "$AGENT" --agent-version "$VERSION" --project-dir "$PROJECT_AGENTS_DIR" --quiet >/dev/null 2>&1
|
|
330
334
|
fi
|
|
331
|
-
${
|
|
335
|
+
${refreshRulesCall}${managedEnv}
|
|
332
336
|
|
|
333
337
|
exec "$BINARY"${launchArgs} "$@"
|
|
334
338
|
`;
|
|
@@ -373,8 +377,10 @@ export function removeShim(agent) {
|
|
|
373
377
|
* read the versioned permissions/rules instead of $HOME/.codex.
|
|
374
378
|
* v4 — direct aliases read binaries and config homes from ~/.agents-system.
|
|
375
379
|
* v5 — hard-disable Codex startup update checks in versioned aliases.
|
|
380
|
+
* v6 — versions moved from ~/.agents-system/versions to ~/.agents/versions
|
|
381
|
+
* (two-repo split: system = shipped defaults, user = operational state).
|
|
376
382
|
*/
|
|
377
|
-
export const VERSIONED_ALIAS_SCHEMA_VERSION =
|
|
383
|
+
export const VERSIONED_ALIAS_SCHEMA_VERSION = 6;
|
|
378
384
|
/** Internal marker string used to embed the schema version in versioned alias scripts. */
|
|
379
385
|
const VERSIONED_ALIAS_VERSION_MARKER = 'agents-versioned-alias-version:';
|
|
380
386
|
// The version string is interpolated into a generated bash script and into
|
|
@@ -399,14 +405,14 @@ export function generateVersionedAliasScript(agent, version) {
|
|
|
399
405
|
? `
|
|
400
406
|
# Claude stores OAuth credentials in the macOS keychain. Scope them to this
|
|
401
407
|
# version's config directory so direct aliases also switch the live account.
|
|
402
|
-
export CLAUDE_CONFIG_DIR="$HOME/.agents
|
|
408
|
+
export CLAUDE_CONFIG_DIR="$HOME/.agents/versions/${agent}/${version}/home/${configDirName}"
|
|
403
409
|
`
|
|
404
410
|
: agent === 'codex'
|
|
405
411
|
? `
|
|
406
412
|
# Codex reads its config (approval_policy, sandbox_mode, MCP servers, rules)
|
|
407
413
|
# from CODEX_HOME. Point direct aliases at the versioned home so permissions
|
|
408
414
|
# and rules written by agents-cli actually take effect.
|
|
409
|
-
export CODEX_HOME="$HOME/.agents
|
|
415
|
+
export CODEX_HOME="$HOME/.agents/versions/${agent}/${version}/home/${configDirName}"
|
|
410
416
|
`
|
|
411
417
|
: '';
|
|
412
418
|
const launchArgs = agent === 'codex' ? ' -c check_for_update_on_startup=false' : '';
|
|
@@ -415,7 +421,7 @@ export CODEX_HOME="$HOME/.agents-system/versions/${agent}/${version}/home/${conf
|
|
|
415
421
|
# ${VERSIONED_ALIAS_VERSION_MARKER} ${VERSIONED_ALIAS_SCHEMA_VERSION}
|
|
416
422
|
# Direct alias for ${agentConfig.name}@${version}
|
|
417
423
|
|
|
418
|
-
BINARY="$HOME/.agents
|
|
424
|
+
BINARY="$HOME/.agents/versions/${agent}/${version}/node_modules/.bin/${agentConfig.cliCommand}"
|
|
419
425
|
|
|
420
426
|
if [ ! -x "$BINARY" ]; then
|
|
421
427
|
echo "agents: ${agent}@${version} not installed" >&2
|
|
@@ -1021,20 +1027,72 @@ export function getShimPath(agent) {
|
|
|
1021
1027
|
/**
|
|
1022
1028
|
* Return the first executable path that would be launched for this agent when
|
|
1023
1029
|
* resolving against PATH, excluding the managed shim itself.
|
|
1030
|
+
*
|
|
1031
|
+
* Legacy ~/.agents/shims/<cli> (from the pre-split single-root layout) is NOT
|
|
1032
|
+
* treated as a shadow when a current managed shim exists at getShimPath() —
|
|
1033
|
+
* that file is dead weight from the old layout and the repair flow removes it
|
|
1034
|
+
* separately. Treating it as "shadowing" caused an infinite repair-prompt
|
|
1035
|
+
* loop because addShimsToPath() only edits the rc file, never the legacy
|
|
1036
|
+
* shim file itself.
|
|
1024
1037
|
*/
|
|
1025
1038
|
export function getPathShadowingExecutable(agent) {
|
|
1026
1039
|
const pathDirs = (process.env.PATH || '').split(path.delimiter).filter(Boolean);
|
|
1027
1040
|
const shimPath = path.resolve(getShimPath(agent));
|
|
1028
1041
|
const cliCommand = AGENTS[agent].cliCommand;
|
|
1042
|
+
const legacyUserShim = path.resolve(path.join(os.homedir(), '.agents', 'shims', cliCommand));
|
|
1043
|
+
const managedShimExists = fs.existsSync(shimPath);
|
|
1029
1044
|
for (const dir of pathDirs) {
|
|
1030
1045
|
const candidate = path.resolve(dir, cliCommand);
|
|
1031
1046
|
if (!fs.existsSync(candidate)) {
|
|
1032
1047
|
continue;
|
|
1033
1048
|
}
|
|
1034
|
-
|
|
1049
|
+
if (candidate === shimPath)
|
|
1050
|
+
return null;
|
|
1051
|
+
if (candidate === legacyUserShim && managedShimExists) {
|
|
1052
|
+
// Legacy file from the pre-split layout. Don't treat as shadow — the
|
|
1053
|
+
// repair flow deletes it via removeLegacyUserShim instead. Continue
|
|
1054
|
+
// scanning so a real binary later in PATH is still detected.
|
|
1055
|
+
continue;
|
|
1056
|
+
}
|
|
1057
|
+
return candidate;
|
|
1035
1058
|
}
|
|
1036
1059
|
return null;
|
|
1037
1060
|
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Delete the legacy ~/.agents/shims/<cli> file if it exists, returning whether
|
|
1063
|
+
* anything was removed. Pre-split installs put shims under ~/.agents/shims/;
|
|
1064
|
+
* the new layout uses ~/.agents-system/shims/. The leftover file causes the
|
|
1065
|
+
* repair-prompt loop reported in RUSH-664 — `getPathShadowingExecutable` flags
|
|
1066
|
+
* it as a shadow but `addShimsToPath` only edits rc files, never the file
|
|
1067
|
+
* itself. Removing it ends the loop.
|
|
1068
|
+
*/
|
|
1069
|
+
export function removeLegacyUserShim(agent, overrides) {
|
|
1070
|
+
const cliCommand = AGENTS[agent].cliCommand;
|
|
1071
|
+
const homeDir = overrides?.homeDir || os.homedir();
|
|
1072
|
+
const legacyPath = path.join(homeDir, '.agents', 'shims', cliCommand);
|
|
1073
|
+
if (!fs.existsSync(legacyPath))
|
|
1074
|
+
return false;
|
|
1075
|
+
// Belt-and-suspenders: only remove if the current managed shim location is
|
|
1076
|
+
// different (it always should be — getShimsDir() returns the system dir —
|
|
1077
|
+
// but guard against future refactors that might collapse the two).
|
|
1078
|
+
const currentShim = path.resolve(getShimPath(agent));
|
|
1079
|
+
if (path.resolve(legacyPath) === currentShim)
|
|
1080
|
+
return false;
|
|
1081
|
+
try {
|
|
1082
|
+
fs.unlinkSync(legacyPath);
|
|
1083
|
+
// Best-effort: clean up the legacy shims dir if empty.
|
|
1084
|
+
try {
|
|
1085
|
+
const legacyDir = path.dirname(legacyPath);
|
|
1086
|
+
if (fs.readdirSync(legacyDir).length === 0)
|
|
1087
|
+
fs.rmdirSync(legacyDir);
|
|
1088
|
+
}
|
|
1089
|
+
catch { /* best-effort */ }
|
|
1090
|
+
return true;
|
|
1091
|
+
}
|
|
1092
|
+
catch {
|
|
1093
|
+
return false;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1038
1096
|
/**
|
|
1039
1097
|
* Check if the agent's CLI command is shadowed by a shell alias.
|
|
1040
1098
|
*
|
package/dist/lib/state.d.ts
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
* Filesystem layout and persistent state for agents-cli.
|
|
3
3
|
*
|
|
4
4
|
* Two roots:
|
|
5
|
-
* - ~/.agents-system/ — system repo (npm-shipped resources
|
|
5
|
+
* - ~/.agents-system/ — system repo (npm-shipped resources and canonical read-side defaults)
|
|
6
6
|
* - ~/.agents/ — user repo (user-authored commands, skills, hooks, rules, mcp,
|
|
7
|
-
* permissions, subagents, profiles, secrets, agents.yaml
|
|
7
|
+
* permissions, subagents, profiles, secrets, agents.yaml,
|
|
8
|
+
* packages, routines, runs, versions, shims, backups, plugins,
|
|
9
|
+
* drive, trash)
|
|
8
10
|
*
|
|
9
11
|
* Resolution precedence for resources: project > user > system.
|
|
10
12
|
* Every module that needs a path or reads/writes agents.yaml goes through here.
|
|
11
13
|
*/
|
|
12
14
|
import type { Meta } from './types.js';
|
|
13
|
-
/** Root of the system data directory (~/.agents-system/).
|
|
15
|
+
/** Root of the system data directory (~/.agents-system/). */
|
|
14
16
|
export declare function getAgentsDir(): string;
|
|
15
17
|
/** Root of the system data directory (~/.agents-system/). */
|
|
16
18
|
export declare function getSystemAgentsDir(): string;
|
|
@@ -38,20 +40,7 @@ export declare function getHooksDir(): string;
|
|
|
38
40
|
export declare function getSkillsDir(): string;
|
|
39
41
|
/** Path to the canonical rules directory — system repo. */
|
|
40
42
|
export declare function getRulesDir(): string;
|
|
41
|
-
/**
|
|
42
|
-
export declare function getMemoryDir(): string;
|
|
43
|
-
/**
|
|
44
|
-
* Read-side resolution for the canonical rules dir.
|
|
45
|
-
*
|
|
46
|
-
* Returns SYSTEM_RULES_DIR normally. Falls back to the legacy
|
|
47
|
-
* SYSTEM_LEGACY_MEMORY_DIR (~/.agents-system/memory/) only when the upstream
|
|
48
|
-
* still uses the old layout and the user hasn't pulled the rename yet —
|
|
49
|
-
* detected by absence of rules/AGENTS.md and presence of memory/AGENTS.md.
|
|
50
|
-
*
|
|
51
|
-
* Prints a single warning per process the first time the fallback fires.
|
|
52
|
-
* Per the read-only system-repo invariant, this never moves files; the rename
|
|
53
|
-
* is applied when the user pulls upstream.
|
|
54
|
-
*/
|
|
43
|
+
/** Read-side resolution for the canonical rules dir — system repo. */
|
|
55
44
|
export declare function getResolvedRulesDir(): string;
|
|
56
45
|
/** Path to MCP server YAML configs — system repo. */
|
|
57
46
|
export declare function getMcpDir(): string;
|
|
@@ -59,8 +48,6 @@ export declare function getMcpDir(): string;
|
|
|
59
48
|
export declare function getPermissionsDir(): string;
|
|
60
49
|
/** Path to subagent definition directories — system repo. */
|
|
61
50
|
export declare function getSubagentsDir(): string;
|
|
62
|
-
/** Path to encrypted secret bundles — system repo. */
|
|
63
|
-
export declare function getSecretsDir(): string;
|
|
64
51
|
/** Path to ~/.agents-system/promptcuts.yaml. */
|
|
65
52
|
export declare function getPromptcutsPath(): string;
|
|
66
53
|
/** Path to the legacy MCP config JSON. */
|
|
@@ -74,7 +61,6 @@ export declare function getSystemRulesDir(): string;
|
|
|
74
61
|
export declare function getSystemMcpDir(): string;
|
|
75
62
|
export declare function getSystemPermissionsDir(): string;
|
|
76
63
|
export declare function getSystemSubagentsDir(): string;
|
|
77
|
-
export declare function getSystemSecretsDir(): string;
|
|
78
64
|
export declare function getSystemPromptcutsPath(): string;
|
|
79
65
|
export declare function getUserCommandsDir(): string;
|
|
80
66
|
export declare function getUserHooksDir(): string;
|
|
@@ -85,22 +71,26 @@ export declare function getUserPermissionsDir(): string;
|
|
|
85
71
|
export declare function getUserSubagentsDir(): string;
|
|
86
72
|
export declare function getUserSecretsDir(): string;
|
|
87
73
|
export declare function getUserPromptcutsPath(): string;
|
|
88
|
-
/** Path to cloned packages (~/.agents
|
|
74
|
+
/** Path to cloned packages (~/.agents/packages/). */
|
|
89
75
|
export declare function getPackagesDir(): string;
|
|
90
|
-
/** Path to routine YAML definitions (~/.agents
|
|
76
|
+
/** Path to routine YAML definitions (~/.agents/routines/). */
|
|
91
77
|
export declare function getRoutinesDir(): string;
|
|
92
|
-
/** Path to routine execution logs (~/.agents
|
|
78
|
+
/** Path to routine execution logs (~/.agents/runs/). */
|
|
93
79
|
export declare function getRunsDir(): string;
|
|
94
|
-
/** Path to installed agent CLI binaries (~/.agents
|
|
80
|
+
/** Path to installed agent CLI binaries (~/.agents/versions/). */
|
|
95
81
|
export declare function getVersionsDir(): string;
|
|
96
|
-
/** Path to version-switching shim scripts (~/.agents
|
|
82
|
+
/** Path to version-switching shim scripts (~/.agents/shims/). */
|
|
97
83
|
export declare function getShimsDir(): string;
|
|
98
|
-
/** Path to config backups (~/.agents
|
|
84
|
+
/** Path to config backups (~/.agents/backups/). */
|
|
99
85
|
export declare function getBackupsDir(): string;
|
|
100
|
-
/** Path to plugin bundles (~/.agents
|
|
86
|
+
/** Path to plugin bundles (~/.agents/plugins/). */
|
|
101
87
|
export declare function getPluginsDir(): string;
|
|
102
|
-
/** Path to synced remote session data (~/.agents
|
|
88
|
+
/** Path to synced remote session data (~/.agents/drive/). */
|
|
103
89
|
export declare function getDriveDir(): string;
|
|
90
|
+
/** Path to soft-deleted resources (~/.agents/trash/). */
|
|
91
|
+
export declare function getTrashDir(): string;
|
|
92
|
+
/** Path to soft-deleted version dirs (~/.agents/trash/versions/). */
|
|
93
|
+
export declare function getTrashVersionsDir(): string;
|
|
104
94
|
/**
|
|
105
95
|
* Path to a single user-level extra DotAgent repo clone (~/.agents-<alias>/).
|
|
106
96
|
*
|
|
@@ -136,3 +126,7 @@ import type { AgentId, ResourceType, VersionResources } from './types.js';
|
|
|
136
126
|
export declare function recordVersionResources(agent: AgentId, version: string, resourceType: ResourceType, resources: string[]): void;
|
|
137
127
|
export declare function getVersionResources(agent: AgentId, version: string): VersionResources | null;
|
|
138
128
|
export declare function clearVersionResources(agent: AgentId, version: string): void;
|
|
129
|
+
/** Active rules preset for an agent@version. Defaults to "default" when unset. */
|
|
130
|
+
export declare function getActiveRulesPreset(agent: AgentId, version: string): string;
|
|
131
|
+
/** Persist the active rules preset for an agent@version. */
|
|
132
|
+
export declare function setActiveRulesPreset(agent: AgentId, version: string, preset: string): void;
|