dispatch-agents 0.4.0 → 0.4.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.js +24 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -211,6 +211,8 @@ function ensureSession() {
|
|
|
211
211
|
execSync(
|
|
212
212
|
`tmux new-session -d -s "${DISPATCH_SESSION}" -n "dispatch"`
|
|
213
213
|
);
|
|
214
|
+
execSync(`tmux set -t "${DISPATCH_SESSION}" -g mouse on`);
|
|
215
|
+
execSync(`tmux set -t "${DISPATCH_SESSION}" -g history-limit 50000`);
|
|
214
216
|
execSync(
|
|
215
217
|
`tmux send-keys -t "${DISPATCH_SESSION}:dispatch" "# Dispatch control window" Enter`
|
|
216
218
|
);
|
|
@@ -419,6 +421,9 @@ function tailFile(path) {
|
|
|
419
421
|
|
|
420
422
|
// src/commands.ts
|
|
421
423
|
var TICKET_RE = /^[A-Z]+-[0-9]+$/;
|
|
424
|
+
function slugify(text) {
|
|
425
|
+
return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40).replace(/-+$/, "");
|
|
426
|
+
}
|
|
422
427
|
function buildClaudeCmd(prompt, mode, wtPath, config, extraArgs) {
|
|
423
428
|
let cmd = "claude";
|
|
424
429
|
if (mode === "headless") cmd += " -p";
|
|
@@ -433,7 +438,7 @@ function buildClaudeCmd(prompt, mode, wtPath, config, extraArgs) {
|
|
|
433
438
|
if (mode === "headless") {
|
|
434
439
|
const promptFile = join3(wtPath, ".dispatch-prompt.txt");
|
|
435
440
|
writeFileSync2(promptFile, prompt);
|
|
436
|
-
cmd += `
|
|
441
|
+
cmd += ` < '${promptFile}'`;
|
|
437
442
|
}
|
|
438
443
|
return cmd;
|
|
439
444
|
}
|
|
@@ -442,9 +447,9 @@ async function launchAgent(input, headless, extraArgs, skipWorktree, promptFileA
|
|
|
442
447
|
let prompt;
|
|
443
448
|
let branch;
|
|
444
449
|
if (TICKET_RE.test(input)) {
|
|
445
|
-
id = input;
|
|
446
|
-
branch = input.toLowerCase();
|
|
447
450
|
const ticket = await fetchLinearTicket(input);
|
|
451
|
+
id = `${input.toLowerCase()}-${slugify(ticket.title)}`;
|
|
452
|
+
branch = id;
|
|
448
453
|
if (ticket.description) {
|
|
449
454
|
prompt = `Linear ticket ${input}: ${ticket.title}
|
|
450
455
|
|
|
@@ -455,14 +460,13 @@ Work on this ticket. Create commits as you go. When done, push the branch.`;
|
|
|
455
460
|
prompt = `Work on ticket ${input}: ${ticket.title}. Create commits as you go. When done, push the branch.`;
|
|
456
461
|
}
|
|
457
462
|
} else {
|
|
458
|
-
|
|
459
|
-
id = `task-${suffix}`;
|
|
463
|
+
id = slugify(input) || `task-${String(Date.now()).slice(-6)}`;
|
|
460
464
|
branch = id;
|
|
461
465
|
prompt = input;
|
|
462
466
|
}
|
|
463
467
|
if (nameOverride) {
|
|
464
|
-
id = nameOverride;
|
|
465
|
-
branch =
|
|
468
|
+
id = slugify(nameOverride) || nameOverride;
|
|
469
|
+
branch = id;
|
|
466
470
|
}
|
|
467
471
|
if (promptFileArg) {
|
|
468
472
|
if (!existsSync2(promptFileArg)) {
|
|
@@ -474,6 +478,15 @@ Work on this ticket. Create commits as you go. When done, push the branch.`;
|
|
|
474
478
|
}
|
|
475
479
|
const { readFileSync: readFileSync4 } = await import("fs");
|
|
476
480
|
prompt = readFileSync4(promptFileArg, "utf-8");
|
|
481
|
+
if (!nameOverride && !TICKET_RE.test(input)) {
|
|
482
|
+
const firstLine = prompt.split("\n").find((l) => l.trim().length > 0) || "";
|
|
483
|
+
const clean = firstLine.replace(/^#+\s*/, "");
|
|
484
|
+
const derived = slugify(clean);
|
|
485
|
+
if (derived) {
|
|
486
|
+
id = derived;
|
|
487
|
+
branch = id;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
477
490
|
}
|
|
478
491
|
if (windowExists(id)) {
|
|
479
492
|
log.error(`Agent '${id}' is already running. Use 'dispatch stop ${id}' first.`);
|
|
@@ -589,6 +602,9 @@ async function cmdRun(args, config) {
|
|
|
589
602
|
console.log(" dispatch run HEY-837 --base main # branch off main");
|
|
590
603
|
process.exit(1);
|
|
591
604
|
}
|
|
605
|
+
if (inputs.length === 0 && promptFile) {
|
|
606
|
+
inputs.push("prompt-file");
|
|
607
|
+
}
|
|
592
608
|
ensureTmux();
|
|
593
609
|
if (inputs.length > 1) {
|
|
594
610
|
log.info(`Batch launching ${inputs.length} agents...`);
|
|
@@ -858,7 +874,7 @@ function cmdSetup() {
|
|
|
858
874
|
}
|
|
859
875
|
|
|
860
876
|
// src/cli.ts
|
|
861
|
-
var VERSION = "0.4.
|
|
877
|
+
var VERSION = "0.4.1";
|
|
862
878
|
function help() {
|
|
863
879
|
console.log(`dispatch \u2014 Launch Claude Code agents in isolated git worktrees
|
|
864
880
|
|