@delegoapp/runner 0.5.2 → 0.5.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/dist/executor/prompt.js +4 -1
- package/dist/git/publish.js +42 -0
- package/package.json +6 -1
package/dist/executor/prompt.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { promptThinkingInstruction } from '../thinking.js';
|
|
2
2
|
export function promptForJob(job) {
|
|
3
3
|
const thinkingInstruction = promptThinkingInstruction(job.executionPreferences.thinking);
|
|
4
|
+
const pullRequestInstruction = job.publishingPolicy.autoCreatePr
|
|
5
|
+
? 'Do NOT create a pull request yourself (do not run `gh pr create` or any equivalent). The runner will commit your changes and open the pull request automatically once you exit.'
|
|
6
|
+
: `If you create a pull request, start the PR title with: ${job.linearIssue.identifier}:`;
|
|
4
7
|
return [
|
|
5
8
|
// This directive must come first — before task content — so Claude enters
|
|
6
9
|
// execution with the correct mental model. When placed at the end, Claude
|
|
@@ -19,7 +22,7 @@ export function promptForJob(job) {
|
|
|
19
22
|
'',
|
|
20
23
|
`Linear issue: ${job.linearIssue.identifier}${job.linearIssue.title ? ` - ${job.linearIssue.title}` : ''}`,
|
|
21
24
|
job.linearIssue.url ? `URL: ${job.linearIssue.url}` : null,
|
|
22
|
-
|
|
25
|
+
pullRequestInstruction,
|
|
23
26
|
'',
|
|
24
27
|
`Requested executor: ${job.executionPreferences.executor}`,
|
|
25
28
|
job.executionPreferences.model
|
package/dist/git/publish.js
CHANGED
|
@@ -20,6 +20,34 @@ function parsePrNumberFromUrl(url) {
|
|
|
20
20
|
const value = Number(url.match(/\/pull\/(\d+)(?:\b|$)/)?.[1]);
|
|
21
21
|
return Number.isFinite(value) ? value : null;
|
|
22
22
|
}
|
|
23
|
+
function isAlreadyExistsError(stderr, stdout) {
|
|
24
|
+
// `gh pr create` writes "a pull request for branch ... already exists" to
|
|
25
|
+
// stderr when the agent already opened a PR for this branch. Match on the
|
|
26
|
+
// signal phrase to avoid coupling to gh's exact formatting.
|
|
27
|
+
return /already exists/i.test(stderr) || /already exists/i.test(stdout);
|
|
28
|
+
}
|
|
29
|
+
async function viewExistingPr(repositoryPath, branchName) {
|
|
30
|
+
const view = await runCommand('gh', ['pr', 'view', branchName, '--json', 'url,number,title,isDraft'], repositoryPath);
|
|
31
|
+
if (view.code !== 0) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const parsed = JSON.parse(view.stdout);
|
|
36
|
+
const url = typeof parsed.url === 'string' ? parsed.url : null;
|
|
37
|
+
if (!url) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
url,
|
|
42
|
+
number: typeof parsed.number === 'number' ? parsed.number : null,
|
|
43
|
+
title: typeof parsed.title === 'string' ? parsed.title : '',
|
|
44
|
+
isDraft: typeof parsed.isDraft === 'boolean' ? parsed.isDraft : false,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
23
51
|
export async function publishBranchAndMaybePr(repositoryPath, job, branchName, commit) {
|
|
24
52
|
validatePublishingPolicy(job.publishingPolicy);
|
|
25
53
|
if (!job.publishingPolicy.autoPush) {
|
|
@@ -48,6 +76,20 @@ export async function publishBranchAndMaybePr(repositoryPath, job, branchName, c
|
|
|
48
76
|
}
|
|
49
77
|
const pr = await runCommand('gh', args, repositoryPath);
|
|
50
78
|
if (pr.code !== 0) {
|
|
79
|
+
if (isAlreadyExistsError(pr.stderr, pr.stdout)) {
|
|
80
|
+
const existing = await viewExistingPr(repositoryPath, branchName);
|
|
81
|
+
if (existing) {
|
|
82
|
+
return {
|
|
83
|
+
url: existing.url,
|
|
84
|
+
number: existing.number ?? parsePrNumberFromUrl(existing.url),
|
|
85
|
+
title: existing.title || title,
|
|
86
|
+
branchName,
|
|
87
|
+
draft: existing.isDraft,
|
|
88
|
+
repositorySlug: job.repositorySlug,
|
|
89
|
+
pushed: true,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
51
93
|
throw new Error(`Unable to create GitHub pull request: ${pr.stderr || pr.stdout || 'unknown gh error'}`);
|
|
52
94
|
}
|
|
53
95
|
const url = pr.stdout
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delegoapp/runner",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Delego runner — polls the Delego relay and executes Linear-delegated coding jobs via Codex CLI or Claude Code.",
|
|
6
6
|
"keywords": [
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"linear",
|
|
12
12
|
"runner"
|
|
13
13
|
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/zietek/delego-saas.git",
|
|
17
|
+
"directory": "packages/runner"
|
|
18
|
+
},
|
|
14
19
|
"license": "UNLICENSED",
|
|
15
20
|
"bin": {
|
|
16
21
|
"delego-runner": "dist/bin.js"
|