@tekmidian/pai 0.10.0 → 0.10.1
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/dist/cli/index.mjs +59 -0
- package/dist/cli/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -3389,6 +3389,62 @@ async function cmdPauseAll(opts) {
|
|
|
3389
3389
|
console.log();
|
|
3390
3390
|
}
|
|
3391
3391
|
|
|
3392
|
+
//#endregion
|
|
3393
|
+
//#region src/cli/commands/session/clear-names.ts
|
|
3394
|
+
/**
|
|
3395
|
+
* pai sessions clear-names
|
|
3396
|
+
*
|
|
3397
|
+
* Recovery command: wipes corrupted iTerm2 session name state.
|
|
3398
|
+
*
|
|
3399
|
+
* Two-step reset:
|
|
3400
|
+
* 1. Clear ~/.aibroker/session-names.json (the persistent name store).
|
|
3401
|
+
* 2. Clear user.paiName variable from all live iTerm2 sessions.
|
|
3402
|
+
*
|
|
3403
|
+
* After this runs the user can `/Name` each tab fresh. Nothing is
|
|
3404
|
+
* set automatically — the user re-asserts names via the /Name skill.
|
|
3405
|
+
*/
|
|
3406
|
+
async function cmdClearNames(opts) {
|
|
3407
|
+
if (opts.dryRun) {
|
|
3408
|
+
console.log(dim("Dry run — would:"));
|
|
3409
|
+
console.log(dim(" 1. Call AIBroker clear_session_names (wipe session-names.json)"));
|
|
3410
|
+
console.log(dim(" 2. Call AIBroker clear_pai_names (wipe user.paiName from all iTerm sessions)"));
|
|
3411
|
+
return;
|
|
3412
|
+
}
|
|
3413
|
+
let anyFailed = false;
|
|
3414
|
+
process.stdout.write("Clearing session-names.json … ");
|
|
3415
|
+
try {
|
|
3416
|
+
const n = (await callAiBroker("clear_session_names", {}, 1e4)).cleared ?? 0;
|
|
3417
|
+
console.log(ok(`cleared ${n} entr${n === 1 ? "y" : "ies"}`));
|
|
3418
|
+
} catch (e) {
|
|
3419
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
3420
|
+
if (msg.includes("ENOENT") || msg.includes("ECONNREFUSED")) {
|
|
3421
|
+
console.log(warn("AIBroker not running — session-names.json not cleared"));
|
|
3422
|
+
anyFailed = true;
|
|
3423
|
+
} else {
|
|
3424
|
+
console.log(err(msg));
|
|
3425
|
+
anyFailed = true;
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
process.stdout.write("Clearing user.paiName from iTerm2 sessions … ");
|
|
3429
|
+
try {
|
|
3430
|
+
const n = (await callAiBroker("clear_pai_names", {}, 3e4)).cleared ?? 0;
|
|
3431
|
+
console.log(ok(`cleared ${n} session${n === 1 ? "" : "s"}`));
|
|
3432
|
+
} catch (e) {
|
|
3433
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
3434
|
+
if (msg.includes("ENOENT") || msg.includes("ECONNREFUSED")) {
|
|
3435
|
+
console.log(warn("AIBroker not running — iTerm2 paiName variables not cleared"));
|
|
3436
|
+
anyFailed = true;
|
|
3437
|
+
} else {
|
|
3438
|
+
console.log(err(msg));
|
|
3439
|
+
anyFailed = true;
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
if (anyFailed) {
|
|
3443
|
+
console.log(warn("\nSome steps could not complete. Restart AIBroker and try again."));
|
|
3444
|
+
process.exitCode = 1;
|
|
3445
|
+
} else console.log(ok("\nDone. Use /Name to re-label each tab."));
|
|
3446
|
+
}
|
|
3447
|
+
|
|
3392
3448
|
//#endregion
|
|
3393
3449
|
//#region src/cli/commands/session/sessions-index.ts
|
|
3394
3450
|
function registerSessionsCommands(sessionsCmd, getDb) {
|
|
@@ -3435,6 +3491,9 @@ function registerSessionsCommands(sessionsCmd, getDb) {
|
|
|
3435
3491
|
sessionsCmd.command("active").description("Show currently active Claude Code sessions.\nDetects live sessions by checking which JSONL transcript files\nwere recently modified in ~/.claude/projects/.").option("--minutes <n>", "Consider sessions active if modified within N minutes (default: 60)", "60").option("--json", "Output raw JSON instead of formatted display").action((opts) => {
|
|
3436
3492
|
cmdActive(getDb(), opts);
|
|
3437
3493
|
});
|
|
3494
|
+
sessionsCmd.command("clear-names").description("Recovery: wipe corrupted iTerm2 session name state.\nClears ~/.aibroker/session-names.json AND user.paiName from all live iTerm2 sessions.\nAfter running this, use /Name to re-label each tab.").option("--dry-run", "Preview what would be cleared without making changes").action(async (opts) => {
|
|
3495
|
+
await cmdClearNames(opts);
|
|
3496
|
+
});
|
|
3438
3497
|
sessionsCmd.command("auto-route").description("Auto-detect which project this session belongs to.\nTries: (1) path match in registry, (2) Notes/PAI.md marker walk, (3) topic detection.").option("--cwd <path>", "Working directory to detect from (default: process.cwd())").option("--context <text>", "Conversation context for topic-based fallback routing").option("--json", "Output raw JSON instead of formatted display").action(async (opts) => {
|
|
3439
3498
|
await cmdAutoRoute(opts);
|
|
3440
3499
|
});
|