overlord-cli 0.2606041130.0 → 0.2606041226.0
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/bin/_cli/launcher.mjs +89 -19
- package/package.json +1 -1
package/bin/_cli/launcher.mjs
CHANGED
|
@@ -56,6 +56,29 @@ function withLaunchTempEnv(baseEnv, scratchDir) {
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function contextFileTag(ticketId) {
|
|
60
|
+
const safeTicket = String(ticketId ?? 'ticket').replace(/[^a-zA-Z0-9._-]+/g, '-');
|
|
61
|
+
return `overlord-${safeTicket}-${Date.now()}-${crypto.randomUUID().slice(0, 8)}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function writeLaunchContextFile(scratchDir, ticketId, context) {
|
|
65
|
+
const contextFile = path.join(scratchDir, `${contextFileTag(ticketId)}-context.md`);
|
|
66
|
+
fs.mkdirSync(path.dirname(contextFile), { recursive: true });
|
|
67
|
+
fs.writeFileSync(contextFile, context, 'utf-8');
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
try {
|
|
70
|
+
fs.unlinkSync(contextFile);
|
|
71
|
+
} catch {
|
|
72
|
+
// Best-effort cleanup only.
|
|
73
|
+
}
|
|
74
|
+
}, 30 * 60_000).unref();
|
|
75
|
+
return contextFile;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function buildContextFilePrompt(contextFile, startPrompt) {
|
|
79
|
+
return `${startPrompt}\n\nRead the Overlord launch context from ${contextFile} before taking action. Follow the ticket workflow and objective described in that file.`;
|
|
80
|
+
}
|
|
81
|
+
|
|
59
82
|
function claudeSourcePluginDir() {
|
|
60
83
|
if (fs.existsSync(PACKAGE_CLAUDE_PLUGIN_DIR)) return PACKAGE_CLAUDE_PLUGIN_DIR;
|
|
61
84
|
if (fs.existsSync(REPO_CLAUDE_PLUGIN_DIR)) return REPO_CLAUDE_PLUGIN_DIR;
|
|
@@ -461,8 +484,9 @@ async function runAgent(agent, mode = 'run', options = {}) {
|
|
|
461
484
|
process.chdir(options.workingDirectory);
|
|
462
485
|
}
|
|
463
486
|
|
|
487
|
+
const useMountedProjectScratch = Boolean(options.workingDirectory || options.preCommand?.trim());
|
|
464
488
|
const scratchDir = resolveLaunchScratchDir(options.workingDirectory, {
|
|
465
|
-
explicit:
|
|
489
|
+
explicit: useMountedProjectScratch
|
|
466
490
|
});
|
|
467
491
|
|
|
468
492
|
const launchOrganizationId = resolveLaunchOrganizationId(
|
|
@@ -535,24 +559,38 @@ async function runAgent(agent, mode = 'run', options = {}) {
|
|
|
535
559
|
: {})
|
|
536
560
|
}, scratchDir);
|
|
537
561
|
const extraArgs = buildExtraArgs(agent, options);
|
|
562
|
+
const useContextFilePrompt = Boolean(options.preCommand?.trim());
|
|
563
|
+
const launchContextFile = useContextFilePrompt
|
|
564
|
+
? writeLaunchContextFile(scratchDir, ticketId, context)
|
|
565
|
+
: null;
|
|
538
566
|
|
|
539
567
|
try {
|
|
540
568
|
if (agent === 'claude') {
|
|
541
569
|
const pluginDir = claudeLaunchPluginDir();
|
|
542
570
|
if (mode === 'resume') {
|
|
543
571
|
const claudeSessionId = process.env.CLAUDE_SESSION_ID?.trim();
|
|
572
|
+
const resumePrompt = launchContextFile
|
|
573
|
+
? buildContextFilePrompt(launchContextFile, 'Resume working on this Overlord ticket.')
|
|
574
|
+
: context;
|
|
544
575
|
const args = claudeSessionId
|
|
545
|
-
? ['--resume', claudeSessionId,
|
|
546
|
-
: ['--continue',
|
|
576
|
+
? ['--resume', claudeSessionId, resumePrompt]
|
|
577
|
+
: ['--continue', resumePrompt];
|
|
578
|
+
if (launchContextFile) args.unshift('--append-system-prompt-file', launchContextFile);
|
|
547
579
|
args.unshift(...extraArgs);
|
|
548
580
|
if (pluginDir) args.unshift('--plugin-dir', pluginDir);
|
|
549
581
|
execAgentBinary('claude', args, { stdio: 'inherit', env: childEnv }, options.preCommand);
|
|
550
582
|
} else {
|
|
583
|
+
const startPrompt = launchContextFile
|
|
584
|
+
? buildContextFilePrompt(
|
|
585
|
+
launchContextFile,
|
|
586
|
+
'Begin working on this ticket.'
|
|
587
|
+
)
|
|
588
|
+
: 'Begin working on this ticket. Start by calling the attach endpoint, then proceed with the objective described in your system prompt.';
|
|
551
589
|
const args = [
|
|
552
|
-
'--append-system-prompt',
|
|
553
|
-
context,
|
|
590
|
+
launchContextFile ? '--append-system-prompt-file' : '--append-system-prompt',
|
|
591
|
+
launchContextFile ?? context,
|
|
554
592
|
...extraArgs,
|
|
555
|
-
|
|
593
|
+
startPrompt
|
|
556
594
|
];
|
|
557
595
|
if (pluginDir) args.unshift('--plugin-dir', pluginDir);
|
|
558
596
|
execAgentBinary('claude', args, { stdio: 'inherit', env: childEnv }, options.preCommand);
|
|
@@ -560,15 +598,23 @@ async function runAgent(agent, mode = 'run', options = {}) {
|
|
|
560
598
|
} else if (agent === 'codex') {
|
|
561
599
|
if (mode === 'resume') {
|
|
562
600
|
const codexSessionId = process.env.CODEX_SESSION_ID?.trim();
|
|
601
|
+
const resumePrompt = launchContextFile
|
|
602
|
+
? buildContextFilePrompt(launchContextFile, 'Resume working on this Overlord ticket.')
|
|
603
|
+
: context;
|
|
563
604
|
const args = codexSessionId
|
|
564
|
-
? ['resume', codexSessionId,
|
|
565
|
-
: ['resume', '--last',
|
|
605
|
+
? ['resume', codexSessionId, resumePrompt]
|
|
606
|
+
: ['resume', '--last', resumePrompt];
|
|
566
607
|
args.splice(1, 0, ...extraArgs);
|
|
567
608
|
execAgentBinary('codex', args, { stdio: 'inherit', env: childEnv }, options.preCommand);
|
|
568
609
|
} else {
|
|
569
610
|
execAgentBinary(
|
|
570
611
|
'codex',
|
|
571
|
-
[
|
|
612
|
+
[
|
|
613
|
+
...extraArgs,
|
|
614
|
+
launchContextFile
|
|
615
|
+
? buildContextFilePrompt(launchContextFile, 'Begin working on this Overlord ticket.')
|
|
616
|
+
: context
|
|
617
|
+
],
|
|
572
618
|
{ stdio: 'inherit', env: childEnv },
|
|
573
619
|
options.preCommand
|
|
574
620
|
);
|
|
@@ -576,22 +622,36 @@ async function runAgent(agent, mode = 'run', options = {}) {
|
|
|
576
622
|
} else if (agent === 'cursor') {
|
|
577
623
|
execAgentBinary(
|
|
578
624
|
'agent',
|
|
579
|
-
[
|
|
625
|
+
[
|
|
626
|
+
...extraArgs,
|
|
627
|
+
launchContextFile
|
|
628
|
+
? buildContextFilePrompt(launchContextFile, 'Begin working on this Overlord ticket.')
|
|
629
|
+
: context
|
|
630
|
+
],
|
|
580
631
|
{ stdio: 'inherit', env: childEnv },
|
|
581
632
|
options.preCommand
|
|
582
633
|
);
|
|
583
634
|
} else if (agent === 'opencode') {
|
|
584
635
|
if (mode === 'resume') {
|
|
585
636
|
const openCodeSessionId = process.env.OPENCODE_SESSION_ID?.trim();
|
|
637
|
+
const resumePrompt = launchContextFile
|
|
638
|
+
? buildContextFilePrompt(launchContextFile, 'Resume working on this Overlord ticket.')
|
|
639
|
+
: context;
|
|
586
640
|
const args = openCodeSessionId
|
|
587
|
-
? ['--continue', '--session', openCodeSessionId, '--prompt',
|
|
588
|
-
: ['--continue', '--prompt',
|
|
641
|
+
? ['--continue', '--session', openCodeSessionId, '--prompt', resumePrompt]
|
|
642
|
+
: ['--continue', '--prompt', resumePrompt];
|
|
589
643
|
args.unshift(...extraArgs);
|
|
590
644
|
execAgentBinary('opencode', args, { stdio: 'inherit', env: childEnv }, options.preCommand);
|
|
591
645
|
} else {
|
|
592
646
|
execAgentBinary(
|
|
593
647
|
'opencode',
|
|
594
|
-
[
|
|
648
|
+
[
|
|
649
|
+
...extraArgs,
|
|
650
|
+
'--prompt',
|
|
651
|
+
launchContextFile
|
|
652
|
+
? buildContextFilePrompt(launchContextFile, 'Begin working on this Overlord ticket.')
|
|
653
|
+
: context
|
|
654
|
+
],
|
|
595
655
|
{ stdio: 'inherit', env: childEnv },
|
|
596
656
|
options.preCommand
|
|
597
657
|
);
|
|
@@ -599,24 +659,34 @@ async function runAgent(agent, mode = 'run', options = {}) {
|
|
|
599
659
|
} else if (agent === 'pi') {
|
|
600
660
|
if (mode === 'resume') {
|
|
601
661
|
const piSessionId = process.env.PI_SESSION_ID?.trim();
|
|
662
|
+
const resumePrompt = launchContextFile
|
|
663
|
+
? buildContextFilePrompt(launchContextFile, 'Resume working on this Overlord ticket.')
|
|
664
|
+
: context;
|
|
602
665
|
const args = piSessionId
|
|
603
|
-
? ['--session', piSessionId,
|
|
604
|
-
: ['--continue',
|
|
666
|
+
? ['--session', piSessionId, resumePrompt]
|
|
667
|
+
: ['--continue', resumePrompt];
|
|
605
668
|
args.unshift(...extraArgs);
|
|
606
669
|
execAgentBinary('pi', args, { stdio: 'inherit', env: childEnv }, options.preCommand);
|
|
607
670
|
} else {
|
|
608
671
|
execAgentBinary(
|
|
609
672
|
'pi',
|
|
610
|
-
[
|
|
673
|
+
[
|
|
674
|
+
...extraArgs,
|
|
675
|
+
launchContextFile
|
|
676
|
+
? buildContextFilePrompt(launchContextFile, 'Begin working on this Overlord ticket.')
|
|
677
|
+
: context
|
|
678
|
+
],
|
|
611
679
|
{ stdio: 'inherit', env: childEnv },
|
|
612
680
|
options.preCommand
|
|
613
681
|
);
|
|
614
682
|
}
|
|
615
683
|
} else if (agent === 'antigravity') {
|
|
616
684
|
const tag = `overlord-${ticketId.slice(-8)}-${Date.now()}`;
|
|
617
|
-
const contextFile = path.join(scratchDir, `${tag}-ctx.md`);
|
|
618
|
-
|
|
619
|
-
|
|
685
|
+
const contextFile = launchContextFile ?? path.join(scratchDir, `${tag}-ctx.md`);
|
|
686
|
+
if (!launchContextFile) {
|
|
687
|
+
fs.writeFileSync(contextFile, context, 'utf-8');
|
|
688
|
+
setTimeout(() => { try { fs.unlinkSync(contextFile); } catch { /* already gone */ } }, 30 * 60_000).unref();
|
|
689
|
+
}
|
|
620
690
|
|
|
621
691
|
const agySessionId =
|
|
622
692
|
process.env.AGY_SESSION_ID?.trim() ?? process.env.GEMINI_SESSION_ID?.trim();
|