@rse/claudex 1.1.4 → 1.1.5
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/claudex.js +20 -2
- package/claudex.ts +21 -2
- package/package.json +1 -1
package/claudex.js
CHANGED
|
@@ -261,6 +261,24 @@ const self = async (...args) => {
|
|
|
261
261
|
process.exit(r.exitCode ?? 1);
|
|
262
262
|
return r.exitCode ?? 0;
|
|
263
263
|
};
|
|
264
|
+
/* derive the session/project name from a directory: usually its basename,
|
|
265
|
+
but for a multi-worktree setup "<basedir>/<branch>/" with an "active"
|
|
266
|
+
symlink in "<basedir>/" (pointing to one of the worktrees) the name is
|
|
267
|
+
"<basedir>-<branch>", as the bare branch name (e.g. "master") is not unique */
|
|
268
|
+
const deriveSessionName = (dir) => {
|
|
269
|
+
const name = path.basename(dir);
|
|
270
|
+
const parent = path.dirname(dir);
|
|
271
|
+
if (name !== "" && parent !== dir) {
|
|
272
|
+
try {
|
|
273
|
+
if (fs.lstatSync(path.join(parent, "active")).isSymbolicLink())
|
|
274
|
+
return `${path.basename(parent)}-${name}`;
|
|
275
|
+
}
|
|
276
|
+
catch (_e) {
|
|
277
|
+
/* no "active" symlink, so no multi-worktree setup */
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return name;
|
|
281
|
+
};
|
|
264
282
|
/* detect the session/project name by walking up from the current working
|
|
265
283
|
directory looking for an AGENTS.md / CLAUDE.md marker; fall back to the
|
|
266
284
|
basename of the current working directory */
|
|
@@ -268,13 +286,13 @@ const detectSessionName = () => {
|
|
|
268
286
|
let dir = process.cwd();
|
|
269
287
|
while (true) {
|
|
270
288
|
if (fs.existsSync(path.join(dir, "AGENTS.md")) || fs.existsSync(path.join(dir, "CLAUDE.md")))
|
|
271
|
-
return
|
|
289
|
+
return deriveSessionName(dir);
|
|
272
290
|
const parent = path.dirname(dir);
|
|
273
291
|
if (parent === dir)
|
|
274
292
|
break;
|
|
275
293
|
dir = parent;
|
|
276
294
|
}
|
|
277
|
-
const session =
|
|
295
|
+
const session = deriveSessionName(process.cwd()) || "default";
|
|
278
296
|
info(`no AGENTS.md/CLAUDE.md marker found; using cwd basename "${session}" as session name`);
|
|
279
297
|
return session;
|
|
280
298
|
};
|
package/claudex.ts
CHANGED
|
@@ -292,6 +292,25 @@ const self = async (...args: string[]): Promise<number> => {
|
|
|
292
292
|
return r.exitCode ?? 0
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
+
/* derive the session/project name from a directory: usually its basename,
|
|
296
|
+
but for a multi-worktree setup "<basedir>/<branch>/" with an "active"
|
|
297
|
+
symlink in "<basedir>/" (pointing to one of the worktrees) the name is
|
|
298
|
+
"<basedir>-<branch>", as the bare branch name (e.g. "master") is not unique */
|
|
299
|
+
const deriveSessionName = (dir: string): string => {
|
|
300
|
+
const name = path.basename(dir)
|
|
301
|
+
const parent = path.dirname(dir)
|
|
302
|
+
if (name !== "" && parent !== dir) {
|
|
303
|
+
try {
|
|
304
|
+
if (fs.lstatSync(path.join(parent, "active")).isSymbolicLink())
|
|
305
|
+
return `${path.basename(parent)}-${name}`
|
|
306
|
+
}
|
|
307
|
+
catch (_e) {
|
|
308
|
+
/* no "active" symlink, so no multi-worktree setup */
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return name
|
|
312
|
+
}
|
|
313
|
+
|
|
295
314
|
/* detect the session/project name by walking up from the current working
|
|
296
315
|
directory looking for an AGENTS.md / CLAUDE.md marker; fall back to the
|
|
297
316
|
basename of the current working directory */
|
|
@@ -299,13 +318,13 @@ const detectSessionName = (): string => {
|
|
|
299
318
|
let dir = process.cwd()
|
|
300
319
|
while (true) {
|
|
301
320
|
if (fs.existsSync(path.join(dir, "AGENTS.md")) || fs.existsSync(path.join(dir, "CLAUDE.md")))
|
|
302
|
-
return
|
|
321
|
+
return deriveSessionName(dir)
|
|
303
322
|
const parent = path.dirname(dir)
|
|
304
323
|
if (parent === dir)
|
|
305
324
|
break
|
|
306
325
|
dir = parent
|
|
307
326
|
}
|
|
308
|
-
const session =
|
|
327
|
+
const session = deriveSessionName(process.cwd()) || "default"
|
|
309
328
|
info(`no AGENTS.md/CLAUDE.md marker found; using cwd basename "${session}" as session name`)
|
|
310
329
|
return session
|
|
311
330
|
}
|