@phnx-labs/agents-cli 1.22.121 → 1.22.122

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +6 -45
  3. package/dist/cli/command-registry.js +0 -2
  4. package/dist/commands/daemon.js +7 -8
  5. package/dist/commands/mailboxes.js +1 -1
  6. package/dist/commands/projects.js +3 -3
  7. package/dist/commands/setup-mine.js +0 -1
  8. package/dist/commands/sync.js +101 -1
  9. package/dist/lib/daemon/daemon.js +1 -16
  10. package/dist/lib/daemon-services.d.ts +1 -1
  11. package/dist/lib/daemon-services.js +0 -5
  12. package/dist/lib/daemon-webhooks.d.ts +1 -1
  13. package/dist/lib/daemon-webhooks.js +1 -1
  14. package/dist/lib/device-config.js +1 -1
  15. package/dist/lib/github/project-prs.js +2 -2
  16. package/dist/lib/hosts/passthrough.js +0 -1
  17. package/dist/lib/plugins/plugins.d.ts +7 -1
  18. package/dist/lib/plugins/plugins.js +26 -5
  19. package/dist/lib/pr-land-detach.js +2 -2
  20. package/dist/lib/refresh.js +4 -1
  21. package/dist/lib/scheduling/routines.d.ts +1 -1
  22. package/dist/lib/scheduling/routines.js +1 -1
  23. package/dist/lib/session/db.d.ts +1 -1
  24. package/dist/lib/session/db.js +51 -28
  25. package/dist/lib/staleness/index.js +12 -0
  26. package/dist/lib/staleness/types.d.ts +5 -0
  27. package/dist/lib/startup/command-registry.js +1 -1
  28. package/dist/lib/state.d.ts +0 -3
  29. package/dist/lib/state.js +0 -6
  30. package/dist/lib/sync-delete.d.ts +21 -0
  31. package/dist/lib/sync-delete.js +113 -0
  32. package/package.json +1 -3
  33. package/dist/commands/monitors.d.ts +0 -2
  34. package/dist/commands/monitors.js +0 -1070
  35. package/dist/lib/daemon/monitor-engine-service.d.ts +0 -13
  36. package/dist/lib/daemon/monitor-engine-service.js +0 -25
  37. package/dist/lib/monitors/config.d.ts +0 -77
  38. package/dist/lib/monitors/config.js +0 -405
  39. package/dist/lib/monitors/dispatch.d.ts +0 -10
  40. package/dist/lib/monitors/dispatch.js +0 -72
  41. package/dist/lib/monitors/engine.d.ts +0 -45
  42. package/dist/lib/monitors/engine.js +0 -243
  43. package/dist/lib/monitors/fingerprint.d.ts +0 -3
  44. package/dist/lib/monitors/fingerprint.js +0 -43
  45. package/dist/lib/monitors/pid-watch.d.ts +0 -4
  46. package/dist/lib/monitors/pid-watch.js +0 -14
  47. package/dist/lib/monitors/remote.d.ts +0 -31
  48. package/dist/lib/monitors/remote.js +0 -63
  49. package/dist/lib/monitors/sources/command.d.ts +0 -4
  50. package/dist/lib/monitors/sources/command.js +0 -20
  51. package/dist/lib/monitors/sources/device.d.ts +0 -3
  52. package/dist/lib/monitors/sources/device.js +0 -31
  53. package/dist/lib/monitors/sources/failure.d.ts +0 -5
  54. package/dist/lib/monitors/sources/failure.js +0 -25
  55. package/dist/lib/monitors/sources/file.d.ts +0 -4
  56. package/dist/lib/monitors/sources/file.js +0 -46
  57. package/dist/lib/monitors/sources/http.d.ts +0 -3
  58. package/dist/lib/monitors/sources/http.js +0 -25
  59. package/dist/lib/monitors/sources/index.d.ts +0 -5
  60. package/dist/lib/monitors/sources/index.js +0 -22
  61. package/dist/lib/monitors/sources/poll.d.ts +0 -1
  62. package/dist/lib/monitors/sources/poll.js +0 -1
  63. package/dist/lib/monitors/sources/types.d.ts +0 -9
  64. package/dist/lib/monitors/sources/types.js +0 -1
  65. package/dist/lib/monitors/sources/webhook.d.ts +0 -3
  66. package/dist/lib/monitors/sources/webhook.js +0 -3
  67. package/dist/lib/monitors/sources/ws.d.ts +0 -4
  68. package/dist/lib/monitors/sources/ws.js +0 -35
  69. package/dist/lib/monitors/state.d.ts +0 -51
  70. package/dist/lib/monitors/state.js +0 -221
@@ -14,8 +14,8 @@ export function formatOrphanedOpenPrWarning(pr) {
14
14
  ` PR #${pr.number} is still OPEN and nothing is watching it. A background`,
15
15
  ' `gh pr checks --watch` child dies when a headless agent exits, so the PR',
16
16
  ' will sit green and unmerged.',
17
- ' Merge it once CI is green and a non-author review has cleared it, or set up',
18
- ' a merge-on-green monitor (`agents monitors`) that outlives this process.',
17
+ ' Merge it once CI is green and a non-author review has cleared it, or turn on',
18
+ ' GitHub auto-merge after that review (`agents projects prs automerge`).',
19
19
  '',
20
20
  ];
21
21
  return lines.join('\n');
@@ -11,7 +11,7 @@ import { installVersion, listInstalledVersions, isVersionIsolated, getGlobalDefa
11
11
  import { listCliStatus, installCli, describeMethod, describeCheck, selectInstallMethod, } from './cli-resources.js';
12
12
  import { ensureShimCurrent, ensureGhOverloadShim, isShimsInPath, addShimsToPath, getPathSetupInstructions, switchConfigSymlink, switchHomeFileSymlinks, } from './installations/shims.js';
13
13
  import { parseHookManifest, registerHooksToSettings } from './hooks/install.js';
14
- import { isPromptCancelled } from './format.js';
14
+ import { isInteractiveTerminal, isPromptCancelled } from './format.js';
15
15
  function migratePromptcutsToRoot(agentsDir, quiet = false) {
16
16
  const rootPath = path.join(agentsDir, 'promptcuts.yaml');
17
17
  if (fs.existsSync(rootPath))
@@ -137,6 +137,9 @@ export async function refresh(options = {}) {
137
137
  else if (skipPrompts) {
138
138
  forceFullSync = true;
139
139
  }
140
+ else if (!isInteractiveTerminal() && (!hasAnySynced || (newResources && hasNewResources(newResources, agentId, defaultVer)))) {
141
+ log(chalk.gray(`Skipped resource selection for ${agentLabel(agentId)}@${defaultVer} (no terminal; rerun with --yes to sync new resources)`));
142
+ }
140
143
  else if (!hasAnySynced) {
141
144
  log(chalk.yellow(`\n${agentLabel(agentId)}@${defaultVer} has no synced resources.`));
142
145
  const userSelection = await promptResourceSelection(agentId);
@@ -103,7 +103,7 @@ export interface JobConfig {
103
103
  loop?: LoopConfig;
104
104
  actor?: string;
105
105
  projects?: string[];
106
- dispatchedBy?: 'monitor' | 'webhook';
106
+ dispatchedBy?: 'webhook';
107
107
  }
108
108
  export declare function normalizeProjects(projects: string[] | undefined): string[] | undefined;
109
109
  type ProjectGroup = {
@@ -496,7 +496,7 @@ export function readJobFileResult(filePath) {
496
496
  return { config: null, problem: '`devices:` must be a list — routine is inert' };
497
497
  }
498
498
  if (Object.prototype.hasOwnProperty.call(parsed, 'dispatchedBy')) {
499
- return { config: null, problem: '`dispatchedBy:` is a runtime-only monitor/webhook marker, not a routine field — routine is inert' };
499
+ return { config: null, problem: '`dispatchedBy:` is a runtime-only webhook marker, not a routine field — routine is inert' };
500
500
  }
501
501
  return {
502
502
  config: {
@@ -3,7 +3,7 @@ import type { SessionAgentId, SessionCheckpoint, SessionChecklistItem, SessionEv
3
3
  import { type IndexedToolCall } from '@phnx-labs/sessions-cli/reader';
4
4
  import { type ToolScanResumePoint } from './tool-store.js';
5
5
  import { type TimelineState } from '@phnx-labs/sessions-cli/reader';
6
- export declare const SCHEMA_VERSION = 51;
6
+ export declare const SCHEMA_VERSION = 52;
7
7
  export declare const CONTENT_INDEX_VERSION = 6;
8
8
  export declare const INSIGHTS_EXTRACTOR_VERSION = 7;
9
9
  export declare const SESSION_TOPIC_EXTRACTOR_VERSION = 2;
@@ -19,9 +19,9 @@ import { firstUserMessageFromEvents, lastUserMessageFromEvents } from '@phnx-lab
19
19
  import { emptyTimelineState, TIMELINE_EXTRACTOR_VERSION } from '@phnx-labs/sessions-cli/reader';
20
20
  const SESSIONS_DIR = getSessionsDir();
21
21
  const DB_PATH = getSessionsDbPath();
22
- export const SCHEMA_VERSION = 51;
22
+ export const SCHEMA_VERSION = 52;
23
23
  export const CONTENT_INDEX_VERSION = 6;
24
- const RESOURCE_INDEX_VERSION = 1;
24
+ const RESOURCE_INDEX_VERSION = 2;
25
25
  function canonicalLedgerKey(filePath) {
26
26
  if (!filePath)
27
27
  return filePath;
@@ -1055,6 +1055,16 @@ function migrateSchema(db, fromVersion) {
1055
1055
  `);
1056
1056
  db.exec(`DROP TABLE session_text_v50`);
1057
1057
  }
1058
+ if (fromVersion < 52) {
1059
+ db.exec(`
1060
+ INSERT INTO session_resource_usage (session_id, kind, name, plugin, source, repo_root, snapshot_sha, count)
1061
+ SELECT session_id, kind, plugin || ':' || name, plugin, source, repo_root, snapshot_sha, count
1062
+ FROM session_resource_usage
1063
+ WHERE plugin IS NOT NULL AND plugin <> '' AND instr(name, ':') = 0
1064
+ ON CONFLICT(session_id, kind, name) DO UPDATE SET count = session_resource_usage.count + excluded.count
1065
+ `);
1066
+ db.exec(`DELETE FROM session_resource_usage WHERE plugin IS NOT NULL AND plugin <> '' AND instr(name, ':') = 0`);
1067
+ }
1058
1068
  }
1059
1069
  function backfillClaudeAccounts(db, scope = 'all') {
1060
1070
  const where = scope === 'all'
@@ -1600,24 +1610,35 @@ const insertResourceUsageStmt = (db) => db.prepare(`
1600
1610
  INSERT INTO session_resource_usage (session_id, kind, name, plugin, source, repo_root, snapshot_sha, count)
1601
1611
  VALUES (@session_id, @kind, @name, @plugin, @source, @repo_root, @snapshot_sha, @count)
1602
1612
  `);
1603
- function resolveResourceProvenance(kind, name, cwd, plugins) {
1613
+ function resolveInstalled(kind, name, cwd, plugins) {
1604
1614
  const listOf = (p) => (kind === 'skills' ? p.skills : p.commands);
1615
+ const fromPlugin = (p, shortName) => ({
1616
+ name: `${p.name}:${shortName}`,
1617
+ plugin: p.name, source: p.marketplace, repoRoot: p.repoRoot, snapshotSha: p.snapshotSha,
1618
+ });
1605
1619
  const colonIdx = name.indexOf(':');
1606
1620
  if (colonIdx > 0) {
1607
1621
  const pluginName = name.slice(0, colonIdx);
1608
1622
  const shortName = name.slice(colonIdx + 1);
1609
1623
  const plugin = plugins.find((p) => p.name === pluginName && listOf(p).includes(shortName));
1610
- if (!plugin)
1611
- return {};
1612
- return { plugin: plugin.name, source: plugin.marketplace, repoRoot: plugin.repoRoot, snapshotSha: plugin.snapshotSha };
1624
+ return plugin ? fromPlugin(plugin, shortName) : null;
1613
1625
  }
1614
1626
  const resolved = resolveResource(kind, name, cwd);
1615
1627
  if (resolved)
1616
- return { source: resolved.source, repoRoot: resolved.repoRoot, snapshotSha: resolved.snapshotSha };
1628
+ return { name: resolved.name, source: resolved.source, repoRoot: resolved.repoRoot, snapshotSha: resolved.snapshotSha };
1617
1629
  const plugin = plugins.find((p) => listOf(p).includes(name));
1618
- if (!plugin)
1619
- return {};
1620
- return { plugin: plugin.name, source: plugin.marketplace, repoRoot: plugin.repoRoot, snapshotSha: plugin.snapshotSha };
1630
+ return plugin ? fromPlugin(plugin, name) : null;
1631
+ }
1632
+ function canonicalResource(kind, name, cwd, plugins) {
1633
+ const own = resolveInstalled(kind === 'skill' ? 'skills' : 'commands', name, cwd, plugins);
1634
+ if (own)
1635
+ return { kind, ...own };
1636
+ if (kind === 'command') {
1637
+ const skill = resolveInstalled('skills', name, cwd, plugins);
1638
+ if (skill)
1639
+ return { kind: 'skill', ...skill };
1640
+ }
1641
+ return { kind, name };
1621
1642
  }
1622
1643
  function writeResourceUsageFromTallies(sessionId, skills, commands, cwd) {
1623
1644
  const db = getDB();
@@ -1627,25 +1648,27 @@ function writeResourceUsageFromTallies(sessionId, skills, commands, cwd) {
1627
1648
  if (skills.length === 0 && commands.length === 0)
1628
1649
  return;
1629
1650
  const plugins = discoverPlugins({ cwd });
1630
- for (const { name, count } of skills) {
1631
- const prov = resolveResourceProvenance('skills', name, cwd, plugins);
1632
- const bind = {
1633
- session_id: sessionId, kind: 'skill', name, count,
1634
- plugin: prov.plugin ?? null, source: prov.source ?? null,
1635
- repo_root: prov.repoRoot ?? null, snapshot_sha: prov.snapshotSha ?? null,
1636
- };
1637
- ins.run(bind);
1638
- }
1639
- for (const { name, count } of commands) {
1640
- const bare = name.replace(/^\//, '');
1641
- const prov = resolveResourceProvenance('commands', bare, cwd, plugins);
1642
- const bind = {
1643
- session_id: sessionId, kind: 'command', name: bare, count,
1644
- plugin: prov.plugin ?? null, source: prov.source ?? null,
1645
- repo_root: prov.repoRoot ?? null, snapshot_sha: prov.snapshotSha ?? null,
1646
- };
1651
+ const rows = new Map();
1652
+ const tally = (kind, name, count) => {
1653
+ const c = canonicalResource(kind, name, cwd, plugins);
1654
+ const key = `${c.kind}\0${c.name}`;
1655
+ const existing = rows.get(key);
1656
+ if (existing) {
1657
+ existing.count += count;
1658
+ return;
1659
+ }
1660
+ rows.set(key, {
1661
+ session_id: sessionId, kind: c.kind, name: c.name, count,
1662
+ plugin: c.plugin ?? null, source: c.source ?? null,
1663
+ repo_root: c.repoRoot ?? null, snapshot_sha: c.snapshotSha ?? null,
1664
+ });
1665
+ };
1666
+ for (const { name, count } of skills)
1667
+ tally('skill', name, count);
1668
+ for (const { name, count } of commands)
1669
+ tally('command', name.replace(/^\//, ''), count);
1670
+ for (const bind of rows.values())
1647
1671
  ins.run(bind);
1648
- }
1649
1672
  }
1650
1673
  function writeResourceUsage(sessionId, events, cwd) {
1651
1674
  writeResourceUsageFromTallies(sessionId, extractSkills(events), extractSlashCommands(events), cwd);
@@ -81,6 +81,10 @@ export function buildManifest(agent, version, cwd, previous) {
81
81
  target[name] = entry;
82
82
  }
83
83
  }
84
+ manifest.retired = {
85
+ commands: retireRemoved(manifest.commands, previous?.commands, previous?.retired?.commands),
86
+ skills: retireRemoved(manifest.skills, previous?.skills, previous?.retired?.skills),
87
+ };
84
88
  if (previous?.rules && !isRulesStale(previous.rules, agent, version, cwd)) {
85
89
  manifest.rules = previous.rules;
86
90
  }
@@ -95,6 +99,14 @@ export function buildManifest(agent, version, cwd, previous) {
95
99
  }
96
100
  return manifest;
97
101
  }
102
+ function retireRemoved(current, previous, previouslyRetired) {
103
+ const retired = {};
104
+ for (const [name, entry] of Object.entries({ ...previouslyRetired, ...previous })) {
105
+ if (!(name in current))
106
+ retired[name] = entry;
107
+ }
108
+ return retired;
109
+ }
98
110
  export function isStale(manifest, agent, version, cwd) {
99
111
  for (const { checker, field } of STANDARD_CHECKERS) {
100
112
  const storedMap = (manifest[field] ?? {});
@@ -29,4 +29,9 @@ export interface SyncManifest {
29
29
  workflows?: Record<string, DirEntry>;
30
30
  plugins?: Record<string, PluginEntry>;
31
31
  writtenTargets?: string[];
32
+ retired?: RetiredEntries;
33
+ }
34
+ export interface RetiredEntries {
35
+ commands: Record<string, FileEntry>;
36
+ skills: Record<string, DirEntry>;
32
37
  }
@@ -2,7 +2,7 @@ const LOADED_COMMAND_NAMES = [
2
2
  'accounts', 'auth', 'view', 'inspect', 'feedback', 'commands', 'hooks', 'skills', 'rules', 'memory',
3
3
  'permissions', 'mcp', 'clis', 'subagents', 'plugins', 'workflows', 'add', 'use',
4
4
  'remove', 'rm', 'purge', 'update', 'prune', 'import', 'registry', 'search', 'install', 'packages',
5
- 'routines', 'monitors', 'projects', 'run', '_callback', 'open', 'fork', 'config',
5
+ 'routines', 'projects', 'run', '_callback', 'open', 'fork', 'config',
6
6
  'models', 'modes', 'trash', 'restore', 'doctor',
7
7
  'route', 'routes', 'harness', 'harnesses', 'secrets', 'menubar', 'sync',
8
8
  'refresh-rules', 'factory', 'insights', 'trace', 'reminders',
@@ -66,9 +66,6 @@ export declare function getSystemWebhooksDir(): string;
66
66
  export declare function getProjectRoutinesDir(cwd?: string): string | null;
67
67
  export declare function getProjectWebhooksDir(cwd?: string): string | null;
68
68
  export declare function getRunsDir(): string;
69
- export declare function getMonitorsDir(): string;
70
- export declare function getSystemMonitorsDir(): string;
71
- export declare function getMonitorsHistoryDir(): string;
72
69
  export declare function getMailboxRootDir(): string;
73
70
  export declare function getFeedDir(): string;
74
71
  export declare function getActivityDir(): string;
package/dist/lib/state.js CHANGED
@@ -34,7 +34,6 @@ const SYSTEM_SUBAGENTS_DIR = path.join(SYSTEM_AGENTS_DIR, 'subagents');
34
34
  const SYSTEM_WORKFLOWS_DIR = path.join(SYSTEM_AGENTS_DIR, 'workflows');
35
35
  const SYSTEM_PLUGINS_DIR = path.join(SYSTEM_AGENTS_DIR, 'plugins');
36
36
  const SYSTEM_ROUTINES_DIR = path.join(SYSTEM_AGENTS_DIR, 'routines');
37
- const SYSTEM_MONITORS_DIR = path.join(SYSTEM_AGENTS_DIR, 'monitors');
38
37
  const SYSTEM_WEBHOOKS_DIR = path.join(SYSTEM_AGENTS_DIR, 'webhooks');
39
38
  const SYSTEM_PROMPTCUTS_FILE = path.join(SYSTEM_AGENTS_DIR, 'hooks', 'promptcuts.yaml');
40
39
  const SYSTEM_MCP_CONFIG_FILE = path.join(SYSTEM_AGENTS_DIR, 'mcp.json');
@@ -43,7 +42,6 @@ const HISTORY_DIR = path.join(USER_AGENTS_DIR, '.history');
43
42
  const CACHE_DIR = path.join(USER_AGENTS_DIR, '.cache');
44
43
  const ROUTINES_DIR = path.join(USER_AGENTS_DIR, 'routines');
45
44
  const WEBHOOKS_DIR = path.join(USER_AGENTS_DIR, 'webhooks');
46
- const MONITORS_DIR = path.join(USER_AGENTS_DIR, 'monitors');
47
45
  const TEAMS_DIR = path.join(USER_AGENTS_DIR, 'teams');
48
46
  const PROJECTS_DIR = path.join(USER_AGENTS_DIR, 'projects');
49
47
  const DAEMON_CONFIG_DIR = path.join(USER_AGENTS_DIR, 'daemon');
@@ -52,7 +50,6 @@ const SESSIONS_DB_PATH = path.join(SESSIONS_DIR, 'sessions.db');
52
50
  const ANALYTICS_DIR = path.join(HISTORY_DIR, 'analytics');
53
51
  const VERSIONS_DIR = path.join(HISTORY_DIR, 'versions');
54
52
  const RUNS_DIR = path.join(HISTORY_DIR, 'runs');
55
- const MONITORS_HISTORY_DIR = path.join(HISTORY_DIR, 'monitors');
56
53
  const TEAMS_AGENTS_DIR = path.join(HISTORY_DIR, 'teams', 'agents');
57
54
  const BACKUPS_DIR = path.join(HISTORY_DIR, 'backups');
58
55
  const TRASH_DIR = path.join(HISTORY_DIR, 'trash');
@@ -283,9 +280,6 @@ export function getProjectWebhooksDir(cwd = process.cwd()) {
283
280
  return path.join(projectAgentsDir, 'webhooks');
284
281
  }
285
282
  export function getRunsDir() { return RUNS_DIR; }
286
- export function getMonitorsDir() { return process.env.AGENTS_MONITORS_DIR ?? MONITORS_DIR; }
287
- export function getSystemMonitorsDir() { return process.env.AGENTS_SYSTEM_MONITORS_DIR ?? SYSTEM_MONITORS_DIR; }
288
- export function getMonitorsHistoryDir() { return MONITORS_HISTORY_DIR; }
289
283
  export function getMailboxRootDir() { return MAILBOX_DIR; }
290
284
  export function getFeedDir() { return FEED_DIR; }
291
285
  export function getActivityDir() { return ACTIVITY_DIR; }
@@ -0,0 +1,21 @@
1
+ import type { AgentId } from './types.js';
2
+ export interface RepoRemovalReport {
3
+ agent: AgentId;
4
+ version: string;
5
+ removed: {
6
+ plugins: string[];
7
+ commands: string[];
8
+ skills: string[];
9
+ };
10
+ kept: {
11
+ notFromRepo: string[];
12
+ stillProvided: string[];
13
+ };
14
+ }
15
+ export declare function pruneRepoRemovals(args: {
16
+ agent: AgentId;
17
+ version: string;
18
+ repo: string;
19
+ cwd: string;
20
+ dryRun: boolean;
21
+ }): RepoRemovalReport;
@@ -0,0 +1,113 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { supports } from './capabilities.js';
4
+ import { getEnabledExtraRepos, getProjectAgentsDir, getSystemAgentsDir, getSystemPluginsDir, getUserAgentsDir } from './state.js';
5
+ import { getVersionHomePath } from './installations/versions.js';
6
+ import { listResources } from './resources.js';
7
+ import { removeCommandFromVersion } from './commands.js';
8
+ import { removeSkillFromVersion } from './plugins/skills.js';
9
+ import { cleanOrphanedPluginSkills, discoverPlugins, listVersionMarketplaceNames } from './plugins/plugins.js';
10
+ import { marketplaceNameFor, marketplaceRoot } from './plugins/plugin-marketplace.js';
11
+ import { loadManifest, saveManifest } from './staleness/index.js';
12
+ import { getDetector } from './staleness/registry.js';
13
+ function repoSource(repo, cwd) {
14
+ let root;
15
+ let spec;
16
+ if (repo === 'project') {
17
+ root = getProjectAgentsDir(cwd);
18
+ spec = { kind: 'project', root: root ? path.join(root, 'plugins') : '' };
19
+ }
20
+ else if (repo === 'user') {
21
+ root = getUserAgentsDir();
22
+ spec = { kind: 'user' };
23
+ }
24
+ else if (repo === 'system') {
25
+ root = getSystemAgentsDir();
26
+ spec = { kind: 'system', root: getSystemPluginsDir() };
27
+ }
28
+ else {
29
+ const extra = getEnabledExtraRepos().find((e) => e.alias === repo);
30
+ root = extra?.dir ?? null;
31
+ spec = { kind: 'extra', alias: repo, root: extra ? path.join(extra.dir, 'plugins') : '' };
32
+ }
33
+ if (!root || !fs.existsSync(root)) {
34
+ throw new Error(`The '${repo}' repo has no checkout on this machine, so nothing can be proven to have come from it.`);
35
+ }
36
+ return { root, marketplace: marketplaceNameFor(spec) };
37
+ }
38
+ function within(dir, p) {
39
+ const rel = path.relative(dir, p);
40
+ return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
41
+ }
42
+ export function pruneRepoRemovals(args) {
43
+ const { agent, version, repo, cwd, dryRun } = args;
44
+ const versionHome = getVersionHomePath(agent, version);
45
+ const { root, marketplace } = repoSource(repo, cwd);
46
+ const report = {
47
+ agent,
48
+ version,
49
+ removed: { plugins: [], commands: [], skills: [] },
50
+ kept: { notFromRepo: [], stillProvided: [] },
51
+ };
52
+ if (supports(agent, 'plugins', version).ok) {
53
+ report.removed.plugins = cleanOrphanedPluginSkills(agent, versionHome, discoverPlugins({ cwd }), version, { marketplace, cwd, dryRun });
54
+ for (const name of listVersionMarketplaceNames(agent, versionHome)) {
55
+ if (name === marketplace)
56
+ continue;
57
+ const dir = path.join(marketplaceRoot(name, agent, versionHome), 'plugins');
58
+ if (!fs.existsSync(dir))
59
+ continue;
60
+ for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
61
+ if (e.isDirectory() && !e.name.startsWith('.'))
62
+ report.kept.notFromRepo.push(`plugin ${e.name}`);
63
+ }
64
+ }
65
+ }
66
+ const manifest = loadManifest(agent, version);
67
+ const provenance = {
68
+ commands: Object.fromEntries(Object.entries({ ...manifest?.retired?.commands, ...manifest?.commands }).map(([n, e]) => [n, e.source.path])),
69
+ skills: Object.fromEntries(Object.entries({ ...manifest?.retired?.skills, ...manifest?.skills }).map(([n, e]) => [n, e.dirPath])),
70
+ };
71
+ const kinds = [
72
+ { kind: 'commands', label: 'command', remove: removeCommandFromVersion },
73
+ { kind: 'skills', label: 'skill', remove: removeSkillFromVersion },
74
+ ];
75
+ for (const { kind, label, remove } of kinds) {
76
+ const detector = getDetector(kind, agent);
77
+ if (!detector || !supports(agent, kind, version).ok)
78
+ continue;
79
+ const provided = new Set(listResources(kind, cwd).map((r) => r.name));
80
+ const kindDir = path.join(root, kind);
81
+ for (const name of detector.list({ version, versionHome, cwd })) {
82
+ const source = provenance[kind][name];
83
+ if (!source || !within(kindDir, source)) {
84
+ report.kept.notFromRepo.push(`${label} ${name}`);
85
+ continue;
86
+ }
87
+ if (fs.existsSync(source))
88
+ continue;
89
+ if (provided.has(name)) {
90
+ report.kept.stillProvided.push(`${label} ${name}`);
91
+ continue;
92
+ }
93
+ if (!dryRun) {
94
+ const result = remove(agent, version, name);
95
+ if (!result.success)
96
+ throw new Error(`could not trash ${label} '${name}' from ${agent}@${version}: ${result.error}`);
97
+ if (manifest) {
98
+ delete manifest[kind][name];
99
+ if (manifest.retired)
100
+ delete manifest.retired[kind][name];
101
+ if (kind === 'commands' && manifest.writtenCommands) {
102
+ manifest.writtenCommands = manifest.writtenCommands.filter((c) => c !== name);
103
+ }
104
+ }
105
+ }
106
+ report.removed[kind].push(name);
107
+ }
108
+ }
109
+ if (manifest && !dryRun && (report.removed.commands.length > 0 || report.removed.skills.length > 0)) {
110
+ saveManifest(agent, version, manifest);
111
+ }
112
+ return report;
113
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phnx-labs/agents-cli",
3
- "version": "1.22.121",
3
+ "version": "1.22.122",
4
4
  "description": "One CLI for all your AI coding agents - versions, config, cloud dispatch, sessions, and teams (now with first-class Grok Build CLI support)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -105,7 +105,6 @@
105
105
  "satori": "0.12.2",
106
106
  "simple-git": "3.36.0",
107
107
  "smol-toml": "1.7.0",
108
- "ws": "^8.21.0",
109
108
  "yaml": "2.9.0",
110
109
  "yoga-wasm-web": "^0.3.3"
111
110
  },
@@ -116,7 +115,6 @@
116
115
  "@types/marked-terminal": "6.1.1",
117
116
  "@types/node": "26.1.0",
118
117
  "@types/ssh2": "1.15.5",
119
- "@types/ws": "^8.18.1",
120
118
  "miniflare": "4.20260730.0",
121
119
  "ssh2": "1.17.0",
122
120
  "tsx": "4.23.0",
@@ -1,2 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare function registerMonitorsCommands(program: Command): void;