claude-dev-env 8.109.3 → 8.109.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/.agents/skills/correction/playbooks/fix.md +1 -1
- package/.agents/skills/sync-dev-env/SKILL.md +6 -6
- package/.agents/skills/sync-dev-env/scripts/link_plugin_skills.py +66 -15
- package/.agents/skills/sync-dev-env/scripts/sync_dev_env_constants/config/constants.py +4 -1
- package/.agents/skills/sync-dev-env/scripts/test_link_plugin_skills.py +167 -27
- package/bin/install-constants.mjs +6 -5
- package/bin/install.agents-home.test.mjs +93 -17
- package/bin/install.mjs +90 -46
- package/bin/install.prune.test.mjs +44 -7
- package/bin/install.test.mjs +12 -5
- package/bin/install.transaction.test.mjs +6 -1
- package/bin/publish-directory-pointer.mjs +125 -7
- package/bin/publish-directory-pointer.test.mjs +160 -0
- package/package.json +1 -1
- package/scripts/account_broker_support.py +10 -1
- package/scripts/ci/installer-lifecycle.mjs +11 -6
- package/scripts/ci/installer-lifecycle.test.mjs +2 -0
- package/scripts/dev_env_scripts_constants/claude_account_constants.py +14 -0
- package/scripts/test_account_broker_support.py +87 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Publish
|
|
2
|
+
* Publish Claude Code lookup paths that point into the agents home.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* them at `managedRoot
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Agents, hooks, and scripts live under the agents home. Claude Code discovers
|
|
5
|
+
* them at `managedRoot/<name>`, so the installer writes those paths as
|
|
6
|
+
* directory pointers (a POSIX symlink, or a Windows junction). The skills
|
|
7
|
+
* lookup is a folder of pointers, one per shipped skill, so Claude reads
|
|
8
|
+
* the shared skills while the agents home keeps the skill files and the plugin
|
|
9
|
+
* links. One helper owns the create, refresh, and relocate steps.
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
12
|
import {
|
|
@@ -18,7 +20,7 @@ import {
|
|
|
18
20
|
symlinkSync,
|
|
19
21
|
unlinkSync,
|
|
20
22
|
} from 'node:fs';
|
|
21
|
-
import { dirname, join, resolve } from 'node:path';
|
|
23
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
22
24
|
import { normalizePathForComparison } from './resolve-install-root.mjs';
|
|
23
25
|
|
|
24
26
|
export const DIRECTORY_POINTER_TYPE_JUNCTION = 'junction';
|
|
@@ -59,6 +61,17 @@ export function isDirectoryPointerTo(pointerPath, targetPath) {
|
|
|
59
61
|
=== normalizePathForComparison(resolve(targetPath));
|
|
60
62
|
}
|
|
61
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Report whether linkPath is a symbolic link that does not aim at targetPath.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} linkPath
|
|
68
|
+
* @param {string} targetPath
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
*/
|
|
71
|
+
export function isLinkToOtherDirectory(linkPath, targetPath) {
|
|
72
|
+
return readPathKind(linkPath) === 'symlink' && !isDirectoryPointerTo(linkPath, targetPath);
|
|
73
|
+
}
|
|
74
|
+
|
|
62
75
|
/**
|
|
63
76
|
* Make pointerPath a directory pointer to targetPath.
|
|
64
77
|
*
|
|
@@ -106,6 +119,62 @@ export function ensureDirectoryPointer(pointerPath, targetPath, options = {}) {
|
|
|
106
119
|
};
|
|
107
120
|
}
|
|
108
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Make lookupDirectory a folder with one directory pointer per directory in
|
|
124
|
+
* installDirectory.
|
|
125
|
+
*
|
|
126
|
+
* A link at lookupDirectory, whether it aims at installDirectory or somewhere
|
|
127
|
+
* else, is unlinked and the folder takes its place. The directory it aimed at
|
|
128
|
+
* is left alone. A per-skill link that aims at another directory is left in
|
|
129
|
+
* place. A link whose target under
|
|
130
|
+
* installDirectory is gone is removed. A symbolic link inside installDirectory
|
|
131
|
+
* is not linked here, which keeps plugin links out of this folder and leaves a
|
|
132
|
+
* skill a user linked there without an entry. A
|
|
133
|
+
* directory in lookupDirectory that installDirectory lacks is a personal skill
|
|
134
|
+
* and stays where it is. A file in a same-named lookup directory that
|
|
135
|
+
* installDirectory already holds moves to conflictBackupDirectory before the
|
|
136
|
+
* merge, so a local edit survives.
|
|
137
|
+
*
|
|
138
|
+
* @param {string} lookupDirectory Claude lookup path (for example `~/.claude/skills`).
|
|
139
|
+
* @param {string} installDirectory Canonical skills folder (for example `~/.agents/skills`).
|
|
140
|
+
* @param {string} conflictBackupDirectory Folder that receives displaced lookup files.
|
|
141
|
+
* @returns {{ createdLinkPaths: string[], linkPaths: string[] }} The links this
|
|
142
|
+
* call created, and every link to a directory in installDirectory after the call.
|
|
143
|
+
*/
|
|
144
|
+
export function ensureLinkedSkillFolder(lookupDirectory, installDirectory, conflictBackupDirectory) {
|
|
145
|
+
const resolvedLookup = resolve(lookupDirectory);
|
|
146
|
+
const resolvedInstall = resolve(installDirectory);
|
|
147
|
+
mkdirSync(resolvedInstall, { recursive: true });
|
|
148
|
+
|
|
149
|
+
const lookupKind = readPathKind(resolvedLookup);
|
|
150
|
+
if (lookupKind === 'symlink') {
|
|
151
|
+
unlinkSync(resolvedLookup);
|
|
152
|
+
console.log(` Replaced the link at ${resolvedLookup} with a folder of skill links`);
|
|
153
|
+
} else if (lookupKind === 'file') {
|
|
154
|
+
throw new Error(`Cannot publish linked skills: ${resolvedLookup} is a file`);
|
|
155
|
+
}
|
|
156
|
+
mkdirSync(resolvedLookup, { recursive: true });
|
|
157
|
+
|
|
158
|
+
removeDanglingLinksInto(resolvedLookup, resolvedInstall);
|
|
159
|
+
const createdLinkPaths = [];
|
|
160
|
+
const linkPaths = [];
|
|
161
|
+
for (const eachEntry of readdirSync(resolvedInstall, { withFileTypes: true })) {
|
|
162
|
+
if (!eachEntry.isDirectory()) continue;
|
|
163
|
+
const linkPath = join(resolvedLookup, eachEntry.name);
|
|
164
|
+
const targetPath = join(resolvedInstall, eachEntry.name);
|
|
165
|
+
if (isLinkToOtherDirectory(linkPath, targetPath)) continue;
|
|
166
|
+
if (readPathKind(linkPath) === 'directory') {
|
|
167
|
+
setAsideConflictingEntries(linkPath, targetPath, join(conflictBackupDirectory, eachEntry.name));
|
|
168
|
+
}
|
|
169
|
+
const publication = ensureDirectoryPointer(linkPath, targetPath);
|
|
170
|
+
linkPaths.push(linkPath);
|
|
171
|
+
if (publication.action === POINTER_ACTION_CREATED) {
|
|
172
|
+
createdLinkPaths.push(linkPath);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return { createdLinkPaths, linkPaths };
|
|
176
|
+
}
|
|
177
|
+
|
|
109
178
|
/**
|
|
110
179
|
* Remove a directory pointer when it aims at the expected target.
|
|
111
180
|
*
|
|
@@ -125,7 +194,7 @@ export function unlinkDirectoryPointerIfMatch(pointerPath, targetPath) {
|
|
|
125
194
|
* @param {string} absolutePath
|
|
126
195
|
* @returns {'missing' | 'symlink' | 'directory' | 'file' | 'other'}
|
|
127
196
|
*/
|
|
128
|
-
function readPathKind(absolutePath) {
|
|
197
|
+
export function readPathKind(absolutePath) {
|
|
129
198
|
let stats;
|
|
130
199
|
try {
|
|
131
200
|
stats = lstatSync(absolutePath);
|
|
@@ -147,6 +216,55 @@ function readPathKind(absolutePath) {
|
|
|
147
216
|
return 'other';
|
|
148
217
|
}
|
|
149
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Remove links in lookupDirectory whose target sits under installDirectory and
|
|
221
|
+
* no longer exists.
|
|
222
|
+
*
|
|
223
|
+
* @param {string} lookupDirectory
|
|
224
|
+
* @param {string} installDirectory
|
|
225
|
+
* @returns {void}
|
|
226
|
+
*/
|
|
227
|
+
function removeDanglingLinksInto(lookupDirectory, installDirectory) {
|
|
228
|
+
for (const eachEntry of readdirSync(lookupDirectory, { withFileTypes: true })) {
|
|
229
|
+
if (!eachEntry.isSymbolicLink()) continue;
|
|
230
|
+
const linkPath = join(lookupDirectory, eachEntry.name);
|
|
231
|
+
const linkTarget = resolve(lookupDirectory, readlinkSync(linkPath));
|
|
232
|
+
const targetOffset = relative(installDirectory, linkTarget);
|
|
233
|
+
const targetIsInside = targetOffset !== ''
|
|
234
|
+
&& !isAbsolute(targetOffset)
|
|
235
|
+
&& targetOffset.split(sep)[0] !== '..';
|
|
236
|
+
if (targetIsInside && !existsSync(linkPath)) {
|
|
237
|
+
unlinkSync(linkPath);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Move each entry in sourceDirectory that destinationDirectory already holds
|
|
244
|
+
* into backupDirectory, keeping its relative path. A directory that exists on
|
|
245
|
+
* both sides is walked the same way. Entries the destination lacks stay in
|
|
246
|
+
* place for the merge that follows.
|
|
247
|
+
*
|
|
248
|
+
* @param {string} sourceDirectory
|
|
249
|
+
* @param {string} destinationDirectory
|
|
250
|
+
* @param {string} backupDirectory
|
|
251
|
+
* @returns {void}
|
|
252
|
+
*/
|
|
253
|
+
function setAsideConflictingEntries(sourceDirectory, destinationDirectory, backupDirectory) {
|
|
254
|
+
for (const eachEntry of readdirSync(sourceDirectory, { withFileTypes: true })) {
|
|
255
|
+
const sourceChild = join(sourceDirectory, eachEntry.name);
|
|
256
|
+
const destinationChild = join(destinationDirectory, eachEntry.name);
|
|
257
|
+
if (!existsSync(destinationChild)) continue;
|
|
258
|
+
if (eachEntry.isDirectory() && readPathKind(destinationChild) === 'directory') {
|
|
259
|
+
setAsideConflictingEntries(sourceChild, destinationChild, join(backupDirectory, eachEntry.name));
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
mkdirSync(backupDirectory, { recursive: true });
|
|
263
|
+
renameSync(sourceChild, join(backupDirectory, eachEntry.name));
|
|
264
|
+
console.log(` Kept the local copy of ${sourceChild} in ${backupDirectory}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
150
268
|
/**
|
|
151
269
|
* Move unique entries from sourceDirectory into destinationDirectory.
|
|
152
270
|
*
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
readFileSync,
|
|
13
13
|
realpathSync,
|
|
14
14
|
rmSync,
|
|
15
|
+
symlinkSync,
|
|
15
16
|
writeFileSync,
|
|
16
17
|
} from 'node:fs';
|
|
17
18
|
import { tmpdir } from 'node:os';
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
POINTER_ACTION_CREATED,
|
|
24
25
|
directoryPointerTypeForPlatform,
|
|
25
26
|
ensureDirectoryPointer,
|
|
27
|
+
ensureLinkedSkillFolder,
|
|
26
28
|
isDirectoryPointerTo,
|
|
27
29
|
unlinkDirectoryPointerIfMatch,
|
|
28
30
|
} from './publish-directory-pointer.mjs';
|
|
@@ -36,6 +38,15 @@ function makeSandbox() {
|
|
|
36
38
|
};
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
function entryExistsWithoutFollowing(entryPath) {
|
|
42
|
+
try {
|
|
43
|
+
lstatSync(entryPath);
|
|
44
|
+
return true;
|
|
45
|
+
} catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
test('directoryPointerTypeForPlatform uses a junction on Windows and a dir pointer elsewhere', () => {
|
|
40
51
|
assert.equal(directoryPointerTypeForPlatform('win32'), DIRECTORY_POINTER_TYPE_JUNCTION);
|
|
41
52
|
assert.equal(directoryPointerTypeForPlatform('linux'), DIRECTORY_POINTER_TYPE_DIR);
|
|
@@ -127,3 +138,152 @@ test('unlinkDirectoryPointerIfMatch removes only a pointer that aims at the expe
|
|
|
127
138
|
rmSync(sandbox.root, { recursive: true, force: true });
|
|
128
139
|
}
|
|
129
140
|
});
|
|
141
|
+
|
|
142
|
+
test('ensureLinkedSkillFolder replaces a pointer with a folder that links each shipped skill', () => {
|
|
143
|
+
const sandbox = makeSandbox();
|
|
144
|
+
const pluginCacheSkill = join(sandbox.root, 'plugins', 'cache', 'plugin-skill');
|
|
145
|
+
try {
|
|
146
|
+
mkdirSync(join(sandbox.targetPath, 'shipped-skill'), { recursive: true });
|
|
147
|
+
writeFileSync(join(sandbox.targetPath, 'shipped-skill', 'SKILL.md'), 'shipped body\n');
|
|
148
|
+
mkdirSync(pluginCacheSkill, { recursive: true });
|
|
149
|
+
symlinkSync(pluginCacheSkill, join(sandbox.targetPath, 'plugin-skill'), 'dir');
|
|
150
|
+
ensureDirectoryPointer(sandbox.pointerPath, sandbox.targetPath);
|
|
151
|
+
|
|
152
|
+
const { createdLinkPaths } = ensureLinkedSkillFolder(sandbox.pointerPath, sandbox.targetPath);
|
|
153
|
+
|
|
154
|
+
assert.equal(lstatSync(sandbox.pointerPath).isDirectory(), true);
|
|
155
|
+
assert.equal(lstatSync(sandbox.pointerPath).isSymbolicLink(), false);
|
|
156
|
+
assert.equal(lstatSync(join(sandbox.pointerPath, 'shipped-skill')).isSymbolicLink(), true);
|
|
157
|
+
assert.equal(
|
|
158
|
+
isDirectoryPointerTo(
|
|
159
|
+
join(sandbox.pointerPath, 'shipped-skill'),
|
|
160
|
+
join(sandbox.targetPath, 'shipped-skill'),
|
|
161
|
+
),
|
|
162
|
+
true,
|
|
163
|
+
);
|
|
164
|
+
assert.equal(
|
|
165
|
+
readFileSync(join(sandbox.pointerPath, 'shipped-skill', 'SKILL.md'), 'utf8'),
|
|
166
|
+
'shipped body\n',
|
|
167
|
+
);
|
|
168
|
+
assert.equal(entryExistsWithoutFollowing(join(sandbox.pointerPath, 'plugin-skill')), false);
|
|
169
|
+
assert.deepEqual(createdLinkPaths, [join(sandbox.pointerPath, 'shipped-skill')]);
|
|
170
|
+
} finally {
|
|
171
|
+
rmSync(sandbox.root, { recursive: true, force: true });
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test('ensureLinkedSkillFolder keeps a personal skill that exists only in the lookup folder', () => {
|
|
176
|
+
const sandbox = makeSandbox();
|
|
177
|
+
try {
|
|
178
|
+
mkdirSync(join(sandbox.pointerPath, 'personal-skill'), { recursive: true });
|
|
179
|
+
writeFileSync(join(sandbox.pointerPath, 'personal-skill', 'notes.md'), 'personal\n');
|
|
180
|
+
mkdirSync(sandbox.targetPath, { recursive: true });
|
|
181
|
+
|
|
182
|
+
const { createdLinkPaths } = ensureLinkedSkillFolder(sandbox.pointerPath, sandbox.targetPath);
|
|
183
|
+
|
|
184
|
+
assert.equal(lstatSync(join(sandbox.pointerPath, 'personal-skill')).isDirectory(), true);
|
|
185
|
+
assert.equal(lstatSync(join(sandbox.pointerPath, 'personal-skill')).isSymbolicLink(), false);
|
|
186
|
+
assert.equal(existsSync(join(sandbox.targetPath, 'personal-skill')), false);
|
|
187
|
+
assert.equal(
|
|
188
|
+
readFileSync(join(sandbox.pointerPath, 'personal-skill', 'notes.md'), 'utf8'),
|
|
189
|
+
'personal\n',
|
|
190
|
+
);
|
|
191
|
+
assert.deepEqual(createdLinkPaths, []);
|
|
192
|
+
} finally {
|
|
193
|
+
rmSync(sandbox.root, { recursive: true, force: true });
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test('ensureLinkedSkillFolder removes a dangling link into the install folder and keeps a link to another folder', () => {
|
|
198
|
+
const sandbox = makeSandbox();
|
|
199
|
+
const otherSkill = join(sandbox.root, 'elsewhere', 'other-skill');
|
|
200
|
+
try {
|
|
201
|
+
mkdirSync(sandbox.targetPath, { recursive: true });
|
|
202
|
+
mkdirSync(sandbox.pointerPath, { recursive: true });
|
|
203
|
+
symlinkSync(join(sandbox.targetPath, 'retired-skill'), join(sandbox.pointerPath, 'retired-skill'), 'dir');
|
|
204
|
+
mkdirSync(otherSkill, { recursive: true });
|
|
205
|
+
symlinkSync(otherSkill, join(sandbox.pointerPath, 'other-skill'), 'dir');
|
|
206
|
+
|
|
207
|
+
ensureLinkedSkillFolder(sandbox.pointerPath, sandbox.targetPath);
|
|
208
|
+
|
|
209
|
+
assert.equal(entryExistsWithoutFollowing(join(sandbox.pointerPath, 'retired-skill')), false);
|
|
210
|
+
assert.equal(lstatSync(join(sandbox.pointerPath, 'other-skill')).isSymbolicLink(), true);
|
|
211
|
+
} finally {
|
|
212
|
+
rmSync(sandbox.root, { recursive: true, force: true });
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test('ensureLinkedSkillFolder creates no links on a second call and still reports the link in place', () => {
|
|
217
|
+
const sandbox = makeSandbox();
|
|
218
|
+
try {
|
|
219
|
+
mkdirSync(join(sandbox.targetPath, 'shipped-skill'), { recursive: true });
|
|
220
|
+
writeFileSync(join(sandbox.targetPath, 'shipped-skill', 'SKILL.md'), 'shipped body\n');
|
|
221
|
+
ensureLinkedSkillFolder(sandbox.pointerPath, sandbox.targetPath);
|
|
222
|
+
|
|
223
|
+
const secondCall = ensureLinkedSkillFolder(sandbox.pointerPath, sandbox.targetPath);
|
|
224
|
+
|
|
225
|
+
assert.deepEqual(secondCall.createdLinkPaths, []);
|
|
226
|
+
assert.deepEqual(secondCall.linkPaths, [join(sandbox.pointerPath, 'shipped-skill')]);
|
|
227
|
+
assert.equal(
|
|
228
|
+
isDirectoryPointerTo(
|
|
229
|
+
join(sandbox.pointerPath, 'shipped-skill'),
|
|
230
|
+
join(sandbox.targetPath, 'shipped-skill'),
|
|
231
|
+
),
|
|
232
|
+
true,
|
|
233
|
+
);
|
|
234
|
+
} finally {
|
|
235
|
+
rmSync(sandbox.root, { recursive: true, force: true });
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test('ensureLinkedSkillFolder replaces a lookup link that aims at another directory and leaves that directory alone', () => {
|
|
240
|
+
const sandbox = makeSandbox();
|
|
241
|
+
const elsewhere = join(sandbox.root, 'elsewhere');
|
|
242
|
+
try {
|
|
243
|
+
mkdirSync(join(sandbox.targetPath, 'shipped-skill'), { recursive: true });
|
|
244
|
+
writeFileSync(join(sandbox.targetPath, 'shipped-skill', 'SKILL.md'), 'shipped body\n');
|
|
245
|
+
mkdirSync(elsewhere, { recursive: true });
|
|
246
|
+
writeFileSync(join(elsewhere, 'notes.md'), 'elsewhere\n');
|
|
247
|
+
mkdirSync(join(sandbox.root, 'lookup'), { recursive: true });
|
|
248
|
+
symlinkSync(elsewhere, sandbox.pointerPath, 'dir');
|
|
249
|
+
|
|
250
|
+
const { createdLinkPaths } = ensureLinkedSkillFolder(sandbox.pointerPath, sandbox.targetPath);
|
|
251
|
+
|
|
252
|
+
assert.equal(lstatSync(sandbox.pointerPath).isDirectory(), true);
|
|
253
|
+
assert.equal(lstatSync(sandbox.pointerPath).isSymbolicLink(), false);
|
|
254
|
+
assert.equal(isDirectoryPointerTo(join(sandbox.pointerPath, 'shipped-skill'), join(sandbox.targetPath, 'shipped-skill')), true);
|
|
255
|
+
assert.deepEqual(createdLinkPaths, [join(sandbox.pointerPath, 'shipped-skill')]);
|
|
256
|
+
assert.equal(readFileSync(join(elsewhere, 'notes.md'), 'utf8'), 'elsewhere\n');
|
|
257
|
+
} finally {
|
|
258
|
+
rmSync(sandbox.root, { recursive: true, force: true });
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test('ensureLinkedSkillFolder moves a lookup file that conflicts with the agents home into the backup folder', () => {
|
|
263
|
+
const sandbox = makeSandbox();
|
|
264
|
+
const conflictBackup = join(sandbox.root, 'backup', 'skills');
|
|
265
|
+
try {
|
|
266
|
+
mkdirSync(join(sandbox.targetPath, 'shared-skill'), { recursive: true });
|
|
267
|
+
writeFileSync(join(sandbox.targetPath, 'shared-skill', 'SKILL.md'), 'agents home body\n');
|
|
268
|
+
mkdirSync(join(sandbox.pointerPath, 'shared-skill'), { recursive: true });
|
|
269
|
+
writeFileSync(join(sandbox.pointerPath, 'shared-skill', 'SKILL.md'), 'local edit\n');
|
|
270
|
+
writeFileSync(join(sandbox.pointerPath, 'shared-skill', 'extra.md'), 'lookup only\n');
|
|
271
|
+
|
|
272
|
+
ensureLinkedSkillFolder(sandbox.pointerPath, sandbox.targetPath, conflictBackup);
|
|
273
|
+
|
|
274
|
+
assert.equal(
|
|
275
|
+
readFileSync(join(conflictBackup, 'shared-skill', 'SKILL.md'), 'utf8'),
|
|
276
|
+
'local edit\n',
|
|
277
|
+
);
|
|
278
|
+
assert.equal(
|
|
279
|
+
readFileSync(join(sandbox.targetPath, 'shared-skill', 'extra.md'), 'utf8'),
|
|
280
|
+
'lookup only\n',
|
|
281
|
+
);
|
|
282
|
+
assert.equal(
|
|
283
|
+
readFileSync(join(sandbox.pointerPath, 'shared-skill', 'SKILL.md'), 'utf8'),
|
|
284
|
+
'agents home body\n',
|
|
285
|
+
);
|
|
286
|
+
} finally {
|
|
287
|
+
rmSync(sandbox.root, { recursive: true, force: true });
|
|
288
|
+
}
|
|
289
|
+
});
|
package/package.json
CHANGED
|
@@ -59,6 +59,7 @@ from dev_env_scripts_constants.account_broker_constants import (
|
|
|
59
59
|
utc_time_text,
|
|
60
60
|
)
|
|
61
61
|
from dev_env_scripts_constants.claude_account_constants import (
|
|
62
|
+
ALL_DEACTIVATED_ACCOUNT_NAMES,
|
|
62
63
|
CLAUDE_ACCOUNT_ORDER_FILE_NAME,
|
|
63
64
|
CLAUDE_LAUNCHER_PROGRAM,
|
|
64
65
|
CREDENTIALS_FILE_NAME,
|
|
@@ -133,9 +134,16 @@ def _extra_homes(main_home: Path) -> tuple[Path, ...]:
|
|
|
133
134
|
raise BrokerConfigurationError(f"invalid account list {extras_path}: {error}") from error
|
|
134
135
|
|
|
135
136
|
|
|
137
|
+
def _is_deactivated(account: Account) -> bool:
|
|
138
|
+
all_names = _order_names(account) | {account.home.name.casefold()}
|
|
139
|
+
return not ALL_DEACTIVATED_ACCOUNT_NAMES.isdisjoint(all_names)
|
|
140
|
+
|
|
141
|
+
|
|
136
142
|
def _append_claude_account(
|
|
137
143
|
all_accounts: list[Account], all_seen: set[str], account: Account, main_home: Path
|
|
138
144
|
) -> None:
|
|
145
|
+
if _is_deactivated(account):
|
|
146
|
+
return
|
|
139
147
|
key = str(account.home).casefold()
|
|
140
148
|
if key == str(main_home).casefold():
|
|
141
149
|
all_accounts[0] = Account(Product.CLAUDE, "main", main_home, True, account.command)
|
|
@@ -182,7 +190,8 @@ def load_claude_accounts() -> tuple[Account, ...]:
|
|
|
182
190
|
|
|
183
191
|
Returns:
|
|
184
192
|
Main and additional accounts in configured order, each with its place in the account order file
|
|
185
|
-
and, for a home under the profiles root, its profile name.
|
|
193
|
+
and, for a home under the profiles root, its profile name. An account named in
|
|
194
|
+
``ALL_DEACTIVATED_ACCOUNT_NAMES`` is left out.
|
|
186
195
|
|
|
187
196
|
Raises:
|
|
188
197
|
BrokerConfigurationError: An account list is unreadable.
|
|
@@ -79,9 +79,9 @@ function main() {
|
|
|
79
79
|
const skillsDirectory = join(claudeHome, 'skills');
|
|
80
80
|
const agentsHomeSkillsDirectory = join(sandboxHome, '.agents', 'skills');
|
|
81
81
|
const installedSkills = existsSync(skillsDirectory)
|
|
82
|
-
? readdirSync(skillsDirectory, { withFileTypes: true }).filter((entry) => entry.
|
|
82
|
+
? readdirSync(skillsDirectory, { withFileTypes: true }).filter((entry) => entry.isSymbolicLink())
|
|
83
83
|
: [];
|
|
84
|
-
record('skills installed', installedSkills.length > 0, `${installedSkills.length} skill
|
|
84
|
+
record('skills installed', installedSkills.length > 0, `${installedSkills.length} skill links`);
|
|
85
85
|
record(
|
|
86
86
|
'skills live under ~/.agents/skills',
|
|
87
87
|
existsSync(agentsHomeSkillsDirectory)
|
|
@@ -89,8 +89,13 @@ function main() {
|
|
|
89
89
|
agentsHomeSkillsDirectory,
|
|
90
90
|
);
|
|
91
91
|
record(
|
|
92
|
-
'~/.claude/skills is a
|
|
93
|
-
existsSync(skillsDirectory)
|
|
92
|
+
'~/.claude/skills is a folder of skill links',
|
|
93
|
+
existsSync(skillsDirectory)
|
|
94
|
+
&& lstatSync(skillsDirectory).isDirectory()
|
|
95
|
+
&& installedSkills.length > 0
|
|
96
|
+
&& installedSkills.every((entry) => existsSync(join(skillsDirectory, entry.name))
|
|
97
|
+
&& existsSync(join(agentsHomeSkillsDirectory, entry.name))
|
|
98
|
+
&& realpathSync(join(skillsDirectory, entry.name)) === realpathSync(join(agentsHomeSkillsDirectory, entry.name))),
|
|
94
99
|
skillsDirectory,
|
|
95
100
|
);
|
|
96
101
|
const sampleSkillName = installedSkills.find((entry) => existsSync(join(skillsDirectory, entry.name, 'SKILL.md')))?.name;
|
|
@@ -98,14 +103,14 @@ function main() {
|
|
|
98
103
|
const lookupSkillPath = join(skillsDirectory, sampleSkillName, 'SKILL.md');
|
|
99
104
|
const canonicalSkillPath = join(agentsHomeSkillsDirectory, sampleSkillName, 'SKILL.md');
|
|
100
105
|
record(
|
|
101
|
-
'skill files match through the lookup
|
|
106
|
+
'skill files match through the lookup link',
|
|
102
107
|
existsSync(lookupSkillPath)
|
|
103
108
|
&& existsSync(canonicalSkillPath)
|
|
104
109
|
&& realpathSync(lookupSkillPath) === realpathSync(canonicalSkillPath),
|
|
105
110
|
sampleSkillName,
|
|
106
111
|
);
|
|
107
112
|
} else {
|
|
108
|
-
record('skill files match through the lookup
|
|
113
|
+
record('skill files match through the lookup link', false, 'no skill links');
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
const agentsLookupDirectory = join(claudeHome, 'agents');
|
|
@@ -16,6 +16,8 @@ const DRIVER_TIMEOUT_MILLISECONDS = 60_000;
|
|
|
16
16
|
});
|
|
17
17
|
assert.equal(lifecycleProcess.status, 0, `${lifecycleProcess.stdout}\n${lifecycleProcess.stderr}`);
|
|
18
18
|
assert.match(lifecycleProcess.stdout, /ALL CHECKS PASSED/);
|
|
19
|
+
assert.match(lifecycleProcess.stdout, /\[PASS\] ~\/\.claude\/skills is a folder of skill links/);
|
|
20
|
+
assert.match(lifecycleProcess.stdout, /\[PASS\] skill files match through the lookup link/);
|
|
19
21
|
assert.match(lifecycleProcess.stdout, /Sandbox removed:/);
|
|
20
22
|
});
|
|
21
23
|
|
|
@@ -9,6 +9,7 @@ main account so its owner never runs out.
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
11
|
from dataclasses import dataclass
|
|
12
|
+
from pathlib import PureWindowsPath
|
|
12
13
|
|
|
13
14
|
from dev_env_scripts_constants.shared_tree_constants import CLAUDE_CONFIG_DIR_ENV_VAR
|
|
14
15
|
|
|
@@ -77,6 +78,19 @@ CLAUDE_LAUNCHER_PROGRAM: LauncherProgram = LauncherProgram(
|
|
|
77
78
|
)
|
|
78
79
|
"""Launcher that runs Claude with ``CLAUDE_CONFIG_DIR`` set to the profile home."""
|
|
79
80
|
|
|
81
|
+
ALL_DEACTIVATED_PROFILE_NAMES: tuple[str, ...] = ("org-mel",)
|
|
82
|
+
"""Lowercase profile names of deactivated Claude accounts the broker never picks."""
|
|
83
|
+
|
|
84
|
+
ALL_DEACTIVATED_ACCOUNT_NAMES: frozenset[str] = frozenset(
|
|
85
|
+
each_name.casefold()
|
|
86
|
+
for each_profile_name in ALL_DEACTIVATED_PROFILE_NAMES
|
|
87
|
+
for each_name in (
|
|
88
|
+
each_profile_name,
|
|
89
|
+
PureWindowsPath(CLAUDE_LAUNCHER_PROGRAM.file_name_template.format(profile_name=each_profile_name)).stem,
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
"""Every name a deactivated account answers to: its profile name and its launcher name."""
|
|
93
|
+
|
|
80
94
|
LAUNCHER_REPLACED_SUFFIX: str = ".replaced-"
|
|
81
95
|
"""Suffix, before the run time, of an older launcher the sync moved aside."""
|
|
82
96
|
|
|
@@ -130,6 +130,93 @@ def test_should_assign_claude_priorities_from_the_order_file(
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
|
|
133
|
+
def test_should_leave_a_deactivated_account_out_of_the_claude_roster(
|
|
134
|
+
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
|
135
|
+
) -> None:
|
|
136
|
+
main_home = _claude_home_with_extras(monkeypatch, tmp_path, ["org-mel", "ev"])
|
|
137
|
+
(main_home / "claude-account-order.json").write_text(
|
|
138
|
+
json.dumps(["ev", "claude-org-mel"]), encoding="utf-8"
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
accounts = support.load_claude_accounts()
|
|
142
|
+
|
|
143
|
+
assert [each_account.name for each_account in accounts] == ["main", "ev"]
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def test_should_leave_a_deactivated_chain_account_out_of_the_claude_roster(
|
|
147
|
+
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
|
148
|
+
) -> None:
|
|
149
|
+
main_home = _claude_home_with_extras(monkeypatch, tmp_path, ["ev"])
|
|
150
|
+
(main_home / "claude-chain.json").write_text(
|
|
151
|
+
json.dumps(
|
|
152
|
+
{
|
|
153
|
+
"chain": [
|
|
154
|
+
{"command": "C:\\bin\\claude-ORG-MEL.cmd", "credentials_path": str(tmp_path / "dead" / ".credentials.json")},
|
|
155
|
+
{"command": "C:\\bin\\other.cmd", "credentials_path": str(tmp_path / "other" / ".credentials.json")},
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
encoding="utf-8",
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
accounts = support.load_claude_accounts()
|
|
163
|
+
|
|
164
|
+
assert [each_account.name for each_account in accounts] == ["main", "C:\\bin\\other.cmd", "ev"]
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def test_should_keep_the_account_that_only_shares_a_prefix_with_a_deactivated_one(
|
|
168
|
+
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
|
169
|
+
) -> None:
|
|
170
|
+
_claude_home_with_extras(monkeypatch, tmp_path, ["mel", "org-mel-two"])
|
|
171
|
+
|
|
172
|
+
accounts = support.load_claude_accounts()
|
|
173
|
+
|
|
174
|
+
assert [each_account.name for each_account in accounts] == ["main", "mel", "org-mel-two"]
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def test_should_leave_out_a_chain_account_whose_credentials_sit_in_a_deactivated_home(
|
|
178
|
+
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
|
179
|
+
) -> None:
|
|
180
|
+
main_home = _claude_home_with_extras(monkeypatch, tmp_path, ["ev"])
|
|
181
|
+
(main_home / "claude-chain.json").write_text(
|
|
182
|
+
json.dumps({"chain": [{"command": "C:\\bin\\work.cmd", "credentials_path": str(tmp_path / "org-mel" / ".credentials.json")}]}),
|
|
183
|
+
encoding="utf-8",
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
accounts = support.load_claude_accounts()
|
|
187
|
+
|
|
188
|
+
assert [each_account.name for each_account in accounts] == ["main", "ev"]
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def test_should_keep_a_live_extra_account_when_a_deactivated_chain_entry_points_at_its_home(
|
|
192
|
+
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
|
193
|
+
) -> None:
|
|
194
|
+
main_home = _claude_home_with_extras(monkeypatch, tmp_path, ["ev"])
|
|
195
|
+
(main_home / "claude-chain.json").write_text(
|
|
196
|
+
json.dumps({"chain": [{"command": "claude-org-mel.cmd", "credentials_path": str(tmp_path / "profiles" / "ev" / ".credentials.json")}]}),
|
|
197
|
+
encoding="utf-8",
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
accounts = support.load_claude_accounts()
|
|
201
|
+
|
|
202
|
+
assert [each_account.name for each_account in accounts] == ["main", "ev"]
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def test_should_keep_the_main_command_when_a_deactivated_chain_entry_names_the_main_home(
|
|
206
|
+
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
|
207
|
+
) -> None:
|
|
208
|
+
main_home = _claude_home_with_extras(monkeypatch, tmp_path, ["ev"])
|
|
209
|
+
(main_home / "claude-chain.json").write_text(json.dumps({"chain": [{"command": "claude-org-mel.cmd"}]}), encoding="utf-8")
|
|
210
|
+
|
|
211
|
+
accounts = support.load_claude_accounts()
|
|
212
|
+
|
|
213
|
+
assert [(each_account.name, each_account.command) for each_account in accounts] == [("main", "claude"), ("ev", "ev")]
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def test_should_name_each_deactivated_account_by_its_profile_and_launcher() -> None:
|
|
217
|
+
assert support.ALL_DEACTIVATED_ACCOUNT_NAMES == {"org-mel", "claude-org-mel"}
|
|
218
|
+
|
|
219
|
+
|
|
133
220
|
def test_should_read_an_order_file_saved_with_a_byte_order_mark(
|
|
134
221
|
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
|
135
222
|
) -> None:
|