@phnx-labs/agents-cli 1.14.2 → 1.14.4
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/browser.d.ts +2 -0
- package/dist/browser.js +7 -0
- package/dist/commands/browser.d.ts +3 -0
- package/dist/commands/browser.js +392 -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 +184 -22
- package/dist/commands/trash.d.ts +10 -0
- package/dist/commands/trash.js +187 -0
- package/dist/commands/view.js +47 -14
- 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 +123 -0
- package/dist/lib/pty-client.js +3 -3
- package/dist/lib/pty-server.js +36 -7
- package/dist/lib/resources/commands.d.ts +46 -0
- package/dist/lib/resources/commands.js +208 -0
- package/dist/lib/resources/hooks.d.ts +12 -0
- package/dist/lib/resources/hooks.js +136 -0
- package/dist/lib/resources/index.d.ts +36 -0
- package/dist/lib/resources/index.js +69 -0
- package/dist/lib/resources/mcp.d.ts +34 -0
- package/dist/lib/resources/mcp.js +483 -0
- package/dist/lib/resources/permissions.d.ts +13 -0
- package/dist/lib/resources/permissions.js +184 -0
- package/dist/lib/resources/rules.d.ts +43 -0
- package/dist/lib/resources/rules.js +146 -0
- package/dist/lib/resources/skills.d.ts +37 -0
- package/dist/lib/resources/skills.js +238 -0
- package/dist/lib/resources/subagents.d.ts +46 -0
- package/dist/lib/resources/subagents.js +198 -0
- package/dist/lib/resources/types.d.ts +82 -0
- package/dist/lib/resources/types.js +8 -0
- 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 -78
- 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 +12 -1
- package/dist/lib/teams/registry.js +12 -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 +32 -3
- package/dist/lib/versions.js +147 -119
- package/package.json +3 -2
- package/scripts/postinstall.js +29 -0
- package/dist/commands/refresh-memory.d.ts +0 -15
- package/dist/lib/memory-compile.d.ts +0 -66
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;
|
package/dist/lib/state.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
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.
|
|
@@ -29,23 +31,22 @@ const SYSTEM_COMMANDS_DIR = path.join(SYSTEM_AGENTS_DIR, 'commands');
|
|
|
29
31
|
const SYSTEM_HOOKS_DIR = path.join(SYSTEM_AGENTS_DIR, 'hooks');
|
|
30
32
|
const SYSTEM_SKILLS_DIR = path.join(SYSTEM_AGENTS_DIR, 'skills');
|
|
31
33
|
const SYSTEM_RULES_DIR = path.join(SYSTEM_AGENTS_DIR, 'rules');
|
|
32
|
-
const SYSTEM_LEGACY_MEMORY_DIR = path.join(SYSTEM_AGENTS_DIR, 'memory');
|
|
33
34
|
const SYSTEM_MCP_DIR = path.join(SYSTEM_AGENTS_DIR, 'mcp');
|
|
34
35
|
const SYSTEM_PERMISSIONS_DIR = path.join(SYSTEM_AGENTS_DIR, 'permissions');
|
|
35
36
|
const SYSTEM_SUBAGENTS_DIR = path.join(SYSTEM_AGENTS_DIR, 'subagents');
|
|
36
|
-
const SYSTEM_SECRETS_DIR = path.join(SYSTEM_AGENTS_DIR, 'secrets');
|
|
37
37
|
const SYSTEM_PROMPTCUTS_FILE = path.join(SYSTEM_AGENTS_DIR, 'hooks', 'promptcuts.yaml');
|
|
38
38
|
const SYSTEM_MCP_CONFIG_FILE = path.join(SYSTEM_AGENTS_DIR, 'mcp.json');
|
|
39
39
|
const SYSTEM_INSTRUCTIONS_FILE = path.join(SYSTEM_AGENTS_DIR, 'instructions.md');
|
|
40
|
-
//
|
|
41
|
-
const PACKAGES_DIR = path.join(
|
|
42
|
-
const ROUTINES_DIR = path.join(
|
|
43
|
-
const RUNS_DIR = path.join(
|
|
44
|
-
const VERSIONS_DIR = path.join(
|
|
45
|
-
const SHIMS_DIR = path.join(
|
|
46
|
-
const BACKUPS_DIR = path.join(
|
|
47
|
-
const PLUGINS_DIR = path.join(
|
|
48
|
-
const DRIVE_DIR = path.join(
|
|
40
|
+
// User-level operational state
|
|
41
|
+
const PACKAGES_DIR = path.join(USER_AGENTS_DIR, 'packages');
|
|
42
|
+
const ROUTINES_DIR = path.join(USER_AGENTS_DIR, 'routines');
|
|
43
|
+
const RUNS_DIR = path.join(ROUTINES_DIR, 'runs');
|
|
44
|
+
const VERSIONS_DIR = path.join(USER_AGENTS_DIR, 'versions');
|
|
45
|
+
const SHIMS_DIR = path.join(USER_AGENTS_DIR, 'shims');
|
|
46
|
+
const BACKUPS_DIR = path.join(USER_AGENTS_DIR, '.backups');
|
|
47
|
+
const PLUGINS_DIR = path.join(USER_AGENTS_DIR, 'plugins');
|
|
48
|
+
const DRIVE_DIR = path.join(USER_AGENTS_DIR, 'drive');
|
|
49
|
+
const TRASH_DIR = path.join(USER_AGENTS_DIR, '.trash');
|
|
49
50
|
// ─── User resource dirs ───────────────────────────────────────────────────────
|
|
50
51
|
const USER_COMMANDS_DIR = path.join(USER_AGENTS_DIR, 'commands');
|
|
51
52
|
const USER_HOOKS_DIR = path.join(USER_AGENTS_DIR, 'hooks');
|
|
@@ -62,7 +63,7 @@ const META_HEADER = `# agents-cli metadata
|
|
|
62
63
|
|
|
63
64
|
`;
|
|
64
65
|
// ─── Root getters ─────────────────────────────────────────────────────────────
|
|
65
|
-
/** Root of the system data directory (~/.agents-system/).
|
|
66
|
+
/** Root of the system data directory (~/.agents-system/). */
|
|
66
67
|
export function getAgentsDir() {
|
|
67
68
|
return SYSTEM_AGENTS_DIR;
|
|
68
69
|
}
|
|
@@ -138,44 +139,14 @@ export function getHooksDir() { return SYSTEM_HOOKS_DIR; }
|
|
|
138
139
|
export function getSkillsDir() { return SYSTEM_SKILLS_DIR; }
|
|
139
140
|
/** Path to the canonical rules directory — system repo. */
|
|
140
141
|
export function getRulesDir() { return SYSTEM_RULES_DIR; }
|
|
141
|
-
/**
|
|
142
|
-
export function
|
|
143
|
-
let legacyMemoryWarned = false;
|
|
144
|
-
/**
|
|
145
|
-
* Read-side resolution for the canonical rules dir.
|
|
146
|
-
*
|
|
147
|
-
* Returns SYSTEM_RULES_DIR normally. Falls back to the legacy
|
|
148
|
-
* SYSTEM_LEGACY_MEMORY_DIR (~/.agents-system/memory/) only when the upstream
|
|
149
|
-
* still uses the old layout and the user hasn't pulled the rename yet —
|
|
150
|
-
* detected by absence of rules/AGENTS.md and presence of memory/AGENTS.md.
|
|
151
|
-
*
|
|
152
|
-
* Prints a single warning per process the first time the fallback fires.
|
|
153
|
-
* Per the read-only system-repo invariant, this never moves files; the rename
|
|
154
|
-
* is applied when the user pulls upstream.
|
|
155
|
-
*/
|
|
156
|
-
export function getResolvedRulesDir() {
|
|
157
|
-
const rulesAgents = path.join(SYSTEM_RULES_DIR, 'AGENTS.md');
|
|
158
|
-
const legacyAgents = path.join(SYSTEM_LEGACY_MEMORY_DIR, 'AGENTS.md');
|
|
159
|
-
if (fs.existsSync(rulesAgents))
|
|
160
|
-
return SYSTEM_RULES_DIR;
|
|
161
|
-
if (fs.existsSync(legacyAgents)) {
|
|
162
|
-
if (!legacyMemoryWarned) {
|
|
163
|
-
legacyMemoryWarned = true;
|
|
164
|
-
process.stderr.write('agents-cli: Legacy memory/ directory detected — agents-cli still works, ' +
|
|
165
|
-
"but run 'agents repo pull system' to migrate to rules/.\n");
|
|
166
|
-
}
|
|
167
|
-
return SYSTEM_LEGACY_MEMORY_DIR;
|
|
168
|
-
}
|
|
169
|
-
return SYSTEM_RULES_DIR;
|
|
170
|
-
}
|
|
142
|
+
/** Read-side resolution for the canonical rules dir — system repo. */
|
|
143
|
+
export function getResolvedRulesDir() { return SYSTEM_RULES_DIR; }
|
|
171
144
|
/** Path to MCP server YAML configs — system repo. */
|
|
172
145
|
export function getMcpDir() { return SYSTEM_MCP_DIR; }
|
|
173
146
|
/** Path to permission group YAML files — system repo. */
|
|
174
147
|
export function getPermissionsDir() { return SYSTEM_PERMISSIONS_DIR; }
|
|
175
148
|
/** Path to subagent definition directories — system repo. */
|
|
176
149
|
export function getSubagentsDir() { return SYSTEM_SUBAGENTS_DIR; }
|
|
177
|
-
/** Path to encrypted secret bundles — system repo. */
|
|
178
|
-
export function getSecretsDir() { return SYSTEM_SECRETS_DIR; }
|
|
179
150
|
/** Path to ~/.agents-system/promptcuts.yaml. */
|
|
180
151
|
export function getPromptcutsPath() { return SYSTEM_PROMPTCUTS_FILE; }
|
|
181
152
|
/** Path to the legacy MCP config JSON. */
|
|
@@ -190,7 +161,6 @@ export function getSystemRulesDir() { return SYSTEM_RULES_DIR; }
|
|
|
190
161
|
export function getSystemMcpDir() { return SYSTEM_MCP_DIR; }
|
|
191
162
|
export function getSystemPermissionsDir() { return SYSTEM_PERMISSIONS_DIR; }
|
|
192
163
|
export function getSystemSubagentsDir() { return SYSTEM_SUBAGENTS_DIR; }
|
|
193
|
-
export function getSystemSecretsDir() { return SYSTEM_SECRETS_DIR; }
|
|
194
164
|
export function getSystemPromptcutsPath() { return SYSTEM_PROMPTCUTS_FILE; }
|
|
195
165
|
// ─── User resource getters ────────────────────────────────────────────────────
|
|
196
166
|
export function getUserCommandsDir() { return USER_COMMANDS_DIR; }
|
|
@@ -202,23 +172,27 @@ export function getUserPermissionsDir() { return USER_PERMISSIONS_DIR; }
|
|
|
202
172
|
export function getUserSubagentsDir() { return USER_SUBAGENTS_DIR; }
|
|
203
173
|
export function getUserSecretsDir() { return USER_SECRETS_DIR; }
|
|
204
174
|
export function getUserPromptcutsPath() { return USER_PROMPTCUTS_FILE; }
|
|
205
|
-
// ───
|
|
206
|
-
/** Path to cloned packages (~/.agents
|
|
175
|
+
// ─── User operational path getters ────────────────────────────────────────────
|
|
176
|
+
/** Path to cloned packages (~/.agents/packages/). */
|
|
207
177
|
export function getPackagesDir() { return PACKAGES_DIR; }
|
|
208
|
-
/** Path to routine YAML definitions (~/.agents
|
|
178
|
+
/** Path to routine YAML definitions (~/.agents/routines/). */
|
|
209
179
|
export function getRoutinesDir() { return ROUTINES_DIR; }
|
|
210
|
-
/** Path to routine execution logs (~/.agents
|
|
180
|
+
/** Path to routine execution logs (~/.agents/runs/). */
|
|
211
181
|
export function getRunsDir() { return RUNS_DIR; }
|
|
212
|
-
/** Path to installed agent CLI binaries (~/.agents
|
|
182
|
+
/** Path to installed agent CLI binaries (~/.agents/versions/). */
|
|
213
183
|
export function getVersionsDir() { return VERSIONS_DIR; }
|
|
214
|
-
/** Path to version-switching shim scripts (~/.agents
|
|
184
|
+
/** Path to version-switching shim scripts (~/.agents/shims/). */
|
|
215
185
|
export function getShimsDir() { return SHIMS_DIR; }
|
|
216
|
-
/** Path to config backups (~/.agents
|
|
186
|
+
/** Path to config backups (~/.agents/backups/). */
|
|
217
187
|
export function getBackupsDir() { return BACKUPS_DIR; }
|
|
218
|
-
/** Path to plugin bundles (~/.agents
|
|
188
|
+
/** Path to plugin bundles (~/.agents/plugins/). */
|
|
219
189
|
export function getPluginsDir() { return PLUGINS_DIR; }
|
|
220
|
-
/** Path to synced remote session data (~/.agents
|
|
190
|
+
/** Path to synced remote session data (~/.agents/drive/). */
|
|
221
191
|
export function getDriveDir() { return DRIVE_DIR; }
|
|
192
|
+
/** Path to soft-deleted resources (~/.agents/trash/). */
|
|
193
|
+
export function getTrashDir() { return TRASH_DIR; }
|
|
194
|
+
/** Path to soft-deleted version dirs (~/.agents/trash/versions/). */
|
|
195
|
+
export function getTrashVersionsDir() { return path.join(TRASH_DIR, 'versions'); }
|
|
222
196
|
/**
|
|
223
197
|
* Path to a single user-level extra DotAgent repo clone (~/.agents-<alias>/).
|
|
224
198
|
*
|
|
@@ -264,7 +238,7 @@ export function ensureAgentsDir() {
|
|
|
264
238
|
fs.chmodSync(USER_AGENTS_DIR, 0o700);
|
|
265
239
|
}
|
|
266
240
|
catch { }
|
|
267
|
-
// System repo
|
|
241
|
+
// System repo plus user-level operational state
|
|
268
242
|
if (!fs.existsSync(SYSTEM_AGENTS_DIR)) {
|
|
269
243
|
fs.mkdirSync(SYSTEM_AGENTS_DIR, opts);
|
|
270
244
|
}
|
|
@@ -290,8 +264,6 @@ export function ensureAgentsDir() {
|
|
|
290
264
|
fs.mkdirSync(SYSTEM_PERMISSIONS_DIR, opts);
|
|
291
265
|
if (!fs.existsSync(SYSTEM_SUBAGENTS_DIR))
|
|
292
266
|
fs.mkdirSync(SYSTEM_SUBAGENTS_DIR, opts);
|
|
293
|
-
if (!fs.existsSync(DRIVE_DIR))
|
|
294
|
-
fs.mkdirSync(DRIVE_DIR, opts);
|
|
295
267
|
try {
|
|
296
268
|
fs.chmodSync(SYSTEM_AGENTS_DIR, 0o700);
|
|
297
269
|
}
|
|
@@ -351,8 +323,8 @@ export function readMeta() {
|
|
|
351
323
|
ensureAgentsDir();
|
|
352
324
|
// NOTE: agents.yaml migration from ~/.agents-system/ to ~/.agents/ is handled
|
|
353
325
|
// exclusively by runMigration() in migrate.ts, called from postinstall and
|
|
354
|
-
//
|
|
355
|
-
//
|
|
326
|
+
// from a one-shot bootstrap step in src/index.ts. Calling it here would
|
|
327
|
+
// mutate real-user filesystem state during test runs that import this
|
|
356
328
|
// module, causing cross-test pollution.
|
|
357
329
|
// Legacy migration: check for old meta.yaml in system dir
|
|
358
330
|
const oldMetaFile = path.join(SYSTEM_AGENTS_DIR, 'meta.yaml');
|
|
@@ -384,29 +356,45 @@ export function readMeta() {
|
|
|
384
356
|
/* meta.yaml migration failed */
|
|
385
357
|
}
|
|
386
358
|
}
|
|
387
|
-
|
|
388
|
-
|
|
359
|
+
// Merge agents.yaml from both system and user repos. User repo wins on conflicts.
|
|
360
|
+
let systemMeta = null;
|
|
361
|
+
let userMeta = null;
|
|
362
|
+
if (fs.existsSync(SYSTEM_META_FILE)) {
|
|
389
363
|
try {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
catch { /* file vanished */ }
|
|
393
|
-
if (metaCache && metaCache.mtime === mtime) {
|
|
394
|
-
return metaCache.meta;
|
|
364
|
+
const content = fs.readFileSync(SYSTEM_META_FILE, 'utf-8');
|
|
365
|
+
systemMeta = yaml.parse(content);
|
|
395
366
|
}
|
|
367
|
+
catch { /* ignore */ }
|
|
368
|
+
}
|
|
369
|
+
if (fs.existsSync(META_FILE)) {
|
|
396
370
|
try {
|
|
397
371
|
const content = fs.readFileSync(META_FILE, 'utf-8');
|
|
398
|
-
|
|
399
|
-
const meta = parsed || createDefaultMeta();
|
|
400
|
-
if (applyRegistrySeeds(meta)) {
|
|
401
|
-
writeMeta(meta);
|
|
402
|
-
return meta;
|
|
403
|
-
}
|
|
404
|
-
metaCache = { mtime, meta };
|
|
405
|
-
return meta;
|
|
372
|
+
userMeta = yaml.parse(content);
|
|
406
373
|
}
|
|
407
|
-
catch {
|
|
408
|
-
|
|
374
|
+
catch { /* ignore */ }
|
|
375
|
+
}
|
|
376
|
+
if (systemMeta || userMeta) {
|
|
377
|
+
// Merge: system as base, user overwrites
|
|
378
|
+
const base = createDefaultMeta();
|
|
379
|
+
const meta = {
|
|
380
|
+
...base,
|
|
381
|
+
...systemMeta,
|
|
382
|
+
...userMeta,
|
|
383
|
+
agents: { ...systemMeta?.agents, ...userMeta?.agents },
|
|
384
|
+
};
|
|
385
|
+
// Merge registries carefully to preserve type
|
|
386
|
+
if (systemMeta?.registries || userMeta?.registries) {
|
|
387
|
+
meta.registries = {
|
|
388
|
+
...base.registries,
|
|
389
|
+
...systemMeta?.registries,
|
|
390
|
+
...userMeta?.registries,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
if (applyRegistrySeeds(meta)) {
|
|
394
|
+
writeMeta(meta);
|
|
395
|
+
return meta;
|
|
409
396
|
}
|
|
397
|
+
return meta;
|
|
410
398
|
}
|
|
411
399
|
const meta = createDefaultMeta();
|
|
412
400
|
if (applyRegistrySeeds(meta)) {
|
|
@@ -469,3 +457,20 @@ export function clearVersionResources(agent, version) {
|
|
|
469
457
|
writeMeta(meta);
|
|
470
458
|
}
|
|
471
459
|
}
|
|
460
|
+
/** Active rules preset for an agent@version. Defaults to "default" when unset. */
|
|
461
|
+
export function getActiveRulesPreset(agent, version) {
|
|
462
|
+
const meta = readMeta();
|
|
463
|
+
return meta.versions?.[agent]?.[version]?.rulesPreset || 'default';
|
|
464
|
+
}
|
|
465
|
+
/** Persist the active rules preset for an agent@version. */
|
|
466
|
+
export function setActiveRulesPreset(agent, version, preset) {
|
|
467
|
+
const meta = readMeta();
|
|
468
|
+
if (!meta.versions)
|
|
469
|
+
meta.versions = {};
|
|
470
|
+
if (!meta.versions[agent])
|
|
471
|
+
meta.versions[agent] = {};
|
|
472
|
+
if (!meta.versions[agent][version])
|
|
473
|
+
meta.versions[agent][version] = {};
|
|
474
|
+
meta.versions[agent][version].rulesPreset = preset;
|
|
475
|
+
writeMeta(meta);
|
|
476
|
+
}
|
|
@@ -74,8 +74,8 @@ export declare function buildManifest(agent: AgentId, version: string, available
|
|
|
74
74
|
* Returns true (stale) at the first detected mismatch — no need to scan everything.
|
|
75
75
|
* Returns false (clean) only after all checks pass.
|
|
76
76
|
*
|
|
77
|
-
* For rules, also delegates to
|
|
78
|
-
* for agents that pre-compile their
|
|
77
|
+
* For rules, also delegates to isRulesStale() to catch @-import changes
|
|
78
|
+
* for agents that pre-compile their rules file.
|
|
79
79
|
*/
|
|
80
80
|
export declare function isSyncStale(manifest: SyncManifest, available: AvailableResources, agent: AgentId, version: string, cwd: string): boolean;
|
|
81
81
|
export {};
|
|
@@ -27,7 +27,7 @@ import * as crypto from 'crypto';
|
|
|
27
27
|
import { getVersionsDir, getProjectAgentsDir, getUserAgentsDir, getSkillsDir, getUserHooksDir, getHooksDir, getUserRulesDir, getResolvedRulesDir, getUserPermissionsDir, getPermissionsDir, getEnabledExtraRepos, } from './state.js';
|
|
28
28
|
import { resolveResource } from './resources.js';
|
|
29
29
|
import { listMcpServerConfigs } from './mcp.js';
|
|
30
|
-
import {
|
|
30
|
+
import { isRulesStale } from './rules/compile.js';
|
|
31
31
|
import { getActivePermissionSetName } from './permissions.js';
|
|
32
32
|
import { listInstalledSubagents } from './subagents.js';
|
|
33
33
|
import { safeJoin } from './paths.js';
|
|
@@ -351,8 +351,8 @@ export function buildManifest(agent, version, available, cwd) {
|
|
|
351
351
|
* Returns true (stale) at the first detected mismatch — no need to scan everything.
|
|
352
352
|
* Returns false (clean) only after all checks pass.
|
|
353
353
|
*
|
|
354
|
-
* For rules, also delegates to
|
|
355
|
-
* for agents that pre-compile their
|
|
354
|
+
* For rules, also delegates to isRulesStale() to catch @-import changes
|
|
355
|
+
* for agents that pre-compile their rules file.
|
|
356
356
|
*/
|
|
357
357
|
export function isSyncStale(manifest, available, agent, version, cwd) {
|
|
358
358
|
// ── Commands ──────────────────────────────────────────────────────────────
|
|
@@ -395,7 +395,7 @@ export function isSyncStale(manifest, available, agent, version, cwd) {
|
|
|
395
395
|
if (!entry || isFileStale(entry.source, hookPath))
|
|
396
396
|
return true;
|
|
397
397
|
}
|
|
398
|
-
// ── Rules
|
|
398
|
+
// ── Rules ─────────────────────────────────────────────────────────────────
|
|
399
399
|
if (nameSetDiffers(Object.keys(manifest.rules.files), available.memory))
|
|
400
400
|
return true;
|
|
401
401
|
for (const name of available.memory) {
|
|
@@ -407,7 +407,7 @@ export function isSyncStale(manifest, available, agent, version, cwd) {
|
|
|
407
407
|
return true;
|
|
408
408
|
}
|
|
409
409
|
// Also catch @-import changes for non-native-import agents
|
|
410
|
-
if (
|
|
410
|
+
if (isRulesStale(agent, version))
|
|
411
411
|
return true;
|
|
412
412
|
// ── MCP ───────────────────────────────────────────────────────────────────
|
|
413
413
|
const mcpServers = listMcpServerConfigs(cwd);
|
|
@@ -97,10 +97,12 @@ export declare class AgentProcess {
|
|
|
97
97
|
taskType: TaskType | null;
|
|
98
98
|
cloudRepo: string | null;
|
|
99
99
|
cloudBranch: string | null;
|
|
100
|
+
worktreeName: string | null;
|
|
101
|
+
worktreePath: string | null;
|
|
100
102
|
private eventsCache;
|
|
101
103
|
private lastReadPos;
|
|
102
104
|
private baseDir;
|
|
103
|
-
constructor(agentId: string, taskName: string, agentType: AgentType, prompt: string, cwd?: string | null, mode?: Mode, pid?: number | null, status?: AgentStatus, startedAt?: Date, completedAt?: Date | null, baseDir?: string | null, parentSessionId?: string | null, workspaceDir?: string | null, cloudSessionId?: string | null, cloudProvider?: string | null, prUrl?: string | null, version?: string | null, remoteSessionId?: string | null, name?: string | null, after?: string[], effort?: EffortLevel | null, model?: string | null, envOverrides?: Record<string, string> | null, taskType?: TaskType | null, cloudRepo?: string | null, cloudBranch?: string | null);
|
|
105
|
+
constructor(agentId: string, taskName: string, agentType: AgentType, prompt: string, cwd?: string | null, mode?: Mode, pid?: number | null, status?: AgentStatus, startedAt?: Date, completedAt?: Date | null, baseDir?: string | null, parentSessionId?: string | null, workspaceDir?: string | null, cloudSessionId?: string | null, cloudProvider?: string | null, prUrl?: string | null, version?: string | null, remoteSessionId?: string | null, name?: string | null, after?: string[], effort?: EffortLevel | null, model?: string | null, envOverrides?: Record<string, string> | null, taskType?: TaskType | null, cloudRepo?: string | null, cloudBranch?: string | null, worktreeName?: string | null, worktreePath?: string | null);
|
|
104
106
|
get isEditMode(): boolean;
|
|
105
107
|
getAgentDir(): Promise<string>;
|
|
106
108
|
/**
|
|
@@ -191,7 +193,7 @@ export declare class AgentManager {
|
|
|
191
193
|
*/
|
|
192
194
|
rescanFromDisk(): Promise<number>;
|
|
193
195
|
private loadExistingAgents;
|
|
194
|
-
spawn(taskName: string, agentType: AgentType, prompt: string, cwd?: string | null, mode?: Mode | null, effort?: EffortLevel, parentSessionId?: string | null, workspaceDir?: string | null, version?: string | null, name?: string | null, after?: string[], model?: string | null, envOverrides?: Record<string, string> | null, taskType?: TaskType | null, cloudProvider?: string | null, cloudSessionId?: string | null, cloudRepo?: string | null, cloudBranch?: string | null): Promise<AgentProcess>;
|
|
196
|
+
spawn(taskName: string, agentType: AgentType, prompt: string, cwd?: string | null, mode?: Mode | null, effort?: EffortLevel, parentSessionId?: string | null, workspaceDir?: string | null, version?: string | null, name?: string | null, after?: string[], model?: string | null, envOverrides?: Record<string, string> | null, taskType?: TaskType | null, cloudProvider?: string | null, cloudSessionId?: string | null, cloudRepo?: string | null, cloudBranch?: string | null, worktreeName?: string | null, worktreePath?: string | null): Promise<AgentProcess>;
|
|
195
197
|
/**
|
|
196
198
|
* Actually spawn the OS process for a teammate. Extracted from spawn() so
|
|
197
199
|
* staged teammates can be launched later by startReady().
|
package/dist/lib/teams/agents.js
CHANGED
|
@@ -468,10 +468,13 @@ export class AgentProcess {
|
|
|
468
468
|
// options the user originally supplied.
|
|
469
469
|
cloudRepo = null;
|
|
470
470
|
cloudBranch = null;
|
|
471
|
+
// Worktree isolation: when non-null, this teammate runs in its own git worktree.
|
|
472
|
+
worktreeName = null;
|
|
473
|
+
worktreePath = null;
|
|
471
474
|
eventsCache = [];
|
|
472
475
|
lastReadPos = 0;
|
|
473
476
|
baseDir = null;
|
|
474
|
-
constructor(agentId, taskName, agentType, prompt, cwd = null, mode = 'plan', pid = null, status = AgentStatus.RUNNING, startedAt = new Date(), completedAt = null, baseDir = null, parentSessionId = null, workspaceDir = null, cloudSessionId = null, cloudProvider = null, prUrl = null, version = null, remoteSessionId = null, name = null, after = [], effort = null, model = null, envOverrides = null, taskType = null, cloudRepo = null, cloudBranch = null) {
|
|
477
|
+
constructor(agentId, taskName, agentType, prompt, cwd = null, mode = 'plan', pid = null, status = AgentStatus.RUNNING, startedAt = new Date(), completedAt = null, baseDir = null, parentSessionId = null, workspaceDir = null, cloudSessionId = null, cloudProvider = null, prUrl = null, version = null, remoteSessionId = null, name = null, after = [], effort = null, model = null, envOverrides = null, taskType = null, cloudRepo = null, cloudBranch = null, worktreeName = null, worktreePath = null) {
|
|
475
478
|
this.agentId = agentId;
|
|
476
479
|
this.remoteSessionId = remoteSessionId;
|
|
477
480
|
this.name = name;
|
|
@@ -482,6 +485,8 @@ export class AgentProcess {
|
|
|
482
485
|
this.taskType = taskType;
|
|
483
486
|
this.cloudRepo = cloudRepo;
|
|
484
487
|
this.cloudBranch = cloudBranch;
|
|
488
|
+
this.worktreeName = worktreeName;
|
|
489
|
+
this.worktreePath = worktreePath;
|
|
485
490
|
this.taskName = taskName;
|
|
486
491
|
this.agentType = agentType;
|
|
487
492
|
this.prompt = prompt;
|
|
@@ -691,6 +696,8 @@ export class AgentProcess {
|
|
|
691
696
|
task_type: this.taskType,
|
|
692
697
|
cloud_repo: this.cloudRepo,
|
|
693
698
|
cloud_branch: this.cloudBranch,
|
|
699
|
+
worktree_name: this.worktreeName,
|
|
700
|
+
worktree_path: this.worktreePath,
|
|
694
701
|
};
|
|
695
702
|
const metaPath = await this.getMetaPath();
|
|
696
703
|
await fs.writeFile(metaPath, JSON.stringify(meta, null, 2));
|
|
@@ -726,7 +733,7 @@ export class AgentProcess {
|
|
|
726
733
|
: AgentStatus.RUNNING;
|
|
727
734
|
const agent = new AgentProcess(meta.agent_id, meta.task_name || 'default', meta.agent_type, meta.prompt, meta.cwd || null, resolvedMode, meta.pid || null, resolvedStatus, new Date(meta.started_at), meta.completed_at ? new Date(meta.completed_at) : null, baseDir, meta.parent_session_id || null, meta.workspace_dir || null, meta.cloud_session_id || null, meta.cloud_provider || null, meta.pr_url || null, meta.version || null, meta.remote_session_id || null, meta.name || null, Array.isArray(meta.after) ? meta.after : [], meta.effort || null, meta.model || null, meta.env_overrides || null, meta.task_type && VALID_TASK_TYPES.includes(meta.task_type)
|
|
728
735
|
? meta.task_type
|
|
729
|
-
: null, meta.cloud_repo || null, meta.cloud_branch || null);
|
|
736
|
+
: null, meta.cloud_repo || null, meta.cloud_branch || null, meta.worktree_name || null, meta.worktree_path || null);
|
|
730
737
|
agent.startTime = typeof meta.start_time === 'string' ? meta.start_time : null;
|
|
731
738
|
return agent;
|
|
732
739
|
}
|
|
@@ -971,7 +978,7 @@ export class AgentManager {
|
|
|
971
978
|
}
|
|
972
979
|
debug(`Loaded ${loadedCount} agents from disk`);
|
|
973
980
|
}
|
|
974
|
-
async spawn(taskName, agentType, prompt, cwd = null, mode = null, effort = 'medium', parentSessionId = null, workspaceDir = null, version = null, name = null, after = [], model = null, envOverrides = null, taskType = null, cloudProvider = null, cloudSessionId = null, cloudRepo = null, cloudBranch = null) {
|
|
981
|
+
async spawn(taskName, agentType, prompt, cwd = null, mode = null, effort = 'medium', parentSessionId = null, workspaceDir = null, version = null, name = null, after = [], model = null, envOverrides = null, taskType = null, cloudProvider = null, cloudSessionId = null, cloudRepo = null, cloudBranch = null, worktreeName = null, worktreePath = null) {
|
|
975
982
|
await this.initialize();
|
|
976
983
|
const resolvedMode = resolveMode(mode, this.defaultMode);
|
|
977
984
|
// Enforce: teammate names are unique within a team.
|
|
@@ -1030,7 +1037,7 @@ export class AgentManager {
|
|
|
1030
1037
|
const initialStatus = isStaged || !isCloudBacked
|
|
1031
1038
|
? AgentStatus.PENDING
|
|
1032
1039
|
: AgentStatus.RUNNING;
|
|
1033
|
-
const agent = new AgentProcess(agentId, taskName, agentType, prompt, resolvedCwd, resolvedMode, null, initialStatus, new Date(), null, this.agentsDir, parentSessionId, workspaceDir, cloudSessionId, cloudProvider, null, version, null, name, cleanAfter, effort, model, envOverrides && Object.keys(envOverrides).length > 0 ? envOverrides : null, taskType, cloudRepo, cloudBranch);
|
|
1040
|
+
const agent = new AgentProcess(agentId, taskName, agentType, prompt, resolvedCwd, resolvedMode, null, initialStatus, new Date(), null, this.agentsDir, parentSessionId, workspaceDir, cloudSessionId, cloudProvider, null, version, null, name, cleanAfter, effort, model, envOverrides && Object.keys(envOverrides).length > 0 ? envOverrides : null, taskType, cloudRepo, cloudBranch, worktreeName, worktreePath);
|
|
1034
1041
|
const agentDir = await agent.getAgentDir();
|
|
1035
1042
|
try {
|
|
1036
1043
|
await fs.mkdir(agentDir, { recursive: true });
|
package/dist/lib/teams/api.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export interface TasksResult {
|
|
|
88
88
|
tasks: TaskInfo[];
|
|
89
89
|
}
|
|
90
90
|
/** Spawn a new teammate in a task and return its initial metadata. */
|
|
91
|
-
export declare function handleSpawn(manager: AgentManager, taskName: string, agentType: AgentType, prompt: string, cwd: string | null, mode: string | null, effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'auto' | null, parentSessionId?: string | null, workspaceDir?: string | null, version?: string | null, name?: string | null, after?: string[], model?: string | null, envOverrides?: Record<string, string> | null, taskType?: TaskType | null, cloudProvider?: string | null, cloudSessionId?: string | null, cloudRepo?: string | null, cloudBranch?: string | null): Promise<SpawnResult>;
|
|
91
|
+
export declare function handleSpawn(manager: AgentManager, taskName: string, agentType: AgentType, prompt: string, cwd: string | null, mode: string | null, effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'auto' | null, parentSessionId?: string | null, workspaceDir?: string | null, version?: string | null, name?: string | null, after?: string[], model?: string | null, envOverrides?: Record<string, string> | null, taskType?: TaskType | null, cloudProvider?: string | null, cloudSessionId?: string | null, cloudRepo?: string | null, cloudBranch?: string | null, worktreeName?: string | null, worktreePath?: string | null): Promise<SpawnResult>;
|
|
92
92
|
/** Retrieve the current status of all teammates in a task, with optional timestamp-based delta filtering. */
|
|
93
93
|
export declare function handleStatus(manager: AgentManager, taskName: string | null | undefined, filter?: string, since?: string, // Optional ISO timestamp - return only events after this time
|
|
94
94
|
parentSessionId?: string | null): Promise<TaskStatusResult>;
|
package/dist/lib/teams/api.js
CHANGED
|
@@ -56,12 +56,12 @@ function recentToolCalls(events, max = 10) {
|
|
|
56
56
|
}));
|
|
57
57
|
}
|
|
58
58
|
/** Spawn a new teammate in a task and return its initial metadata. */
|
|
59
|
-
export async function handleSpawn(manager, taskName, agentType, prompt, cwd, mode, effort = 'medium', parentSessionId = null, workspaceDir = null, version = null, name = null, after = [], model = null, envOverrides = null, taskType = null, cloudProvider = null, cloudSessionId = null, cloudRepo = null, cloudBranch = null) {
|
|
59
|
+
export async function handleSpawn(manager, taskName, agentType, prompt, cwd, mode, effort = 'medium', parentSessionId = null, workspaceDir = null, version = null, name = null, after = [], model = null, envOverrides = null, taskType = null, cloudProvider = null, cloudSessionId = null, cloudRepo = null, cloudBranch = null, worktreeName = null, worktreePath = null) {
|
|
60
60
|
const defaultMode = manager.getDefaultMode();
|
|
61
61
|
const resolvedMode = resolveMode(mode, defaultMode);
|
|
62
62
|
const resolvedEffort = effort ?? 'medium';
|
|
63
63
|
debug(`[spawn] Spawning ${agentType} agent for task "${taskName}" [${resolvedMode}] effort=${resolvedEffort}...`);
|
|
64
|
-
const agent = await manager.spawn(taskName, agentType, prompt, cwd, resolvedMode, resolvedEffort, parentSessionId, workspaceDir, version, name, after, model, envOverrides, taskType, cloudProvider, cloudSessionId, cloudRepo, cloudBranch);
|
|
64
|
+
const agent = await manager.spawn(taskName, agentType, prompt, cwd, resolvedMode, resolvedEffort, parentSessionId, workspaceDir, version, name, after, model, envOverrides, taskType, cloudProvider, cloudSessionId, cloudRepo, cloudBranch, worktreeName, worktreePath);
|
|
65
65
|
debug(`[spawn] Spawned ${agentType} agent ${agent.agentId} for task "${taskName}"`);
|
|
66
66
|
return {
|
|
67
67
|
task_name: taskName,
|
|
@@ -13,3 +13,4 @@ export { readConfig, resolveAgentsDir, resolveBaseDir, type EffortLevel, type Mo
|
|
|
13
13
|
export { collapseEvents, getToolBreakdown, groupAndFlattenEvents, summarizeEvents, getDelta, filterEventsByPriority, getLastTool, getToolUses, getLastMessages, getQuickStatus, getStatusSummary, AgentSummary, PRIORITY, type QuickStatus, } from './summarizer.js';
|
|
14
14
|
export { extractFileOpsFromBash } from './file_ops.js';
|
|
15
15
|
export { debug } from './debug.js';
|
|
16
|
+
export { createWorktree, removeWorktree, isGitRepo, getGitRoot, hasUncommittedChanges, getWorktreePath, getWorktreeBranch, } from './worktree.js';
|
package/dist/lib/teams/index.js
CHANGED
|
@@ -12,3 +12,4 @@ export { readConfig, resolveAgentsDir, resolveBaseDir, } from './persistence.js'
|
|
|
12
12
|
export { collapseEvents, getToolBreakdown, groupAndFlattenEvents, summarizeEvents, getDelta, filterEventsByPriority, getLastTool, getToolUses, getLastMessages, getQuickStatus, getStatusSummary, AgentSummary, PRIORITY, } from './summarizer.js';
|
|
13
13
|
export { extractFileOpsFromBash } from './file_ops.js';
|
|
14
14
|
export { debug } from './debug.js';
|
|
15
|
+
export { createWorktree, removeWorktree, isGitRepo, getGitRoot, hasUncommittedChanges, getWorktreePath, getWorktreeBranch, } from './worktree.js';
|
|
@@ -13,7 +13,7 @@ import { homedir, tmpdir } from 'os';
|
|
|
13
13
|
import { constants as fsConstants } from 'fs';
|
|
14
14
|
import { randomBytes } from 'crypto';
|
|
15
15
|
import lockfile from 'proper-lockfile';
|
|
16
|
-
import {
|
|
16
|
+
import { getUserAgentsDir } from '../state.js';
|
|
17
17
|
/**
|
|
18
18
|
* Atomic JSON write: writes to a sibling tmp file then renames over the
|
|
19
19
|
* target. rename(2) is atomic on POSIX, so a crashed/interrupted write
|
|
@@ -62,8 +62,8 @@ async function withConfigLock(p, fn) {
|
|
|
62
62
|
}
|
|
63
63
|
// All supported teammate agent types
|
|
64
64
|
const ALL_AGENTS = ['claude', 'codex', 'gemini', 'cursor', 'opencode'];
|
|
65
|
-
// Teams data lives under ~/.agents
|
|
66
|
-
const TEAMS_DIR = path.join(
|
|
65
|
+
// Teams data lives under ~/.agents/teams/
|
|
66
|
+
const TEAMS_DIR = path.join(getUserAgentsDir(), 'teams');
|
|
67
67
|
// Legacy paths (for migration)
|
|
68
68
|
const LEGACY_CONFIG_DIR = path.join(homedir(), '.agents');
|
|
69
69
|
// Legacy migration from pre-OSS brand; safe to remove after 2026-07
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
export interface TeamMeta {
|
|
3
3
|
created_at: string;
|
|
4
4
|
description?: string;
|
|
5
|
+
enable_worktrees?: boolean;
|
|
6
|
+
/** Shared worktree path for all teammates (mutually exclusive with enable_worktrees). */
|
|
7
|
+
use_worktree?: string;
|
|
5
8
|
}
|
|
6
9
|
/** Map of team name to team metadata. */
|
|
7
10
|
export type TeamRegistry = Record<string, TeamMeta>;
|
|
@@ -12,11 +15,19 @@ export type TeamRegistry = Record<string, TeamMeta>;
|
|
|
12
15
|
* write, which is exactly the data-loss path we are trying to close.
|
|
13
16
|
*/
|
|
14
17
|
export declare function loadTeams(): Promise<TeamRegistry>;
|
|
18
|
+
export interface CreateTeamOptions {
|
|
19
|
+
description?: string;
|
|
20
|
+
enableWorktrees?: boolean;
|
|
21
|
+
/** Path to an existing worktree for all teammates to share. */
|
|
22
|
+
useWorktree?: string;
|
|
23
|
+
}
|
|
15
24
|
/** Create a new team. Throws if a team with the same name already exists. */
|
|
16
|
-
export declare function createTeam(name: string,
|
|
25
|
+
export declare function createTeam(name: string, options?: CreateTeamOptions): Promise<TeamMeta>;
|
|
17
26
|
/** Return existing team metadata or create a new team if it does not exist. */
|
|
18
27
|
export declare function ensureTeam(name: string): Promise<TeamMeta>;
|
|
19
28
|
/** Remove a team from the registry. Returns false if the team did not exist. */
|
|
20
29
|
export declare function removeTeam(name: string): Promise<boolean>;
|
|
21
30
|
/** Check whether a team with the given name exists in the registry. */
|
|
22
31
|
export declare function teamExists(name: string): Promise<boolean>;
|
|
32
|
+
/** Get metadata for a specific team. Returns null if team does not exist. */
|
|
33
|
+
export declare function getTeam(name: string): Promise<TeamMeta | null>;
|
|
@@ -91,7 +91,10 @@ async function saveTeams(reg) {
|
|
|
91
91
|
await atomicWriteJson(p, reg);
|
|
92
92
|
}
|
|
93
93
|
/** Create a new team. Throws if a team with the same name already exists. */
|
|
94
|
-
export async function createTeam(name,
|
|
94
|
+
export async function createTeam(name, options) {
|
|
95
|
+
if (options?.enableWorktrees && options?.useWorktree) {
|
|
96
|
+
throw new Error('Cannot use both --enable-worktrees and --use-worktree. Pick one.');
|
|
97
|
+
}
|
|
95
98
|
const p = await registryPath();
|
|
96
99
|
return withRegistryLock(p, async () => {
|
|
97
100
|
const reg = await loadTeams();
|
|
@@ -100,7 +103,9 @@ export async function createTeam(name, description) {
|
|
|
100
103
|
}
|
|
101
104
|
const meta = {
|
|
102
105
|
created_at: new Date().toISOString(),
|
|
103
|
-
...(description ? { description } : {}),
|
|
106
|
+
...(options?.description ? { description: options.description } : {}),
|
|
107
|
+
...(options?.enableWorktrees ? { enable_worktrees: true } : {}),
|
|
108
|
+
...(options?.useWorktree ? { use_worktree: options.useWorktree } : {}),
|
|
104
109
|
};
|
|
105
110
|
reg[name] = meta;
|
|
106
111
|
await saveTeams(reg);
|
|
@@ -137,3 +142,8 @@ export async function teamExists(name) {
|
|
|
137
142
|
const reg = await loadTeams();
|
|
138
143
|
return Boolean(reg[name]);
|
|
139
144
|
}
|
|
145
|
+
/** Get metadata for a specific team. Returns null if team does not exist. */
|
|
146
|
+
export async function getTeam(name) {
|
|
147
|
+
const reg = await loadTeams();
|
|
148
|
+
return reg[name] ?? null;
|
|
149
|
+
}
|