@ravshansbox/pi-next-issue 2.5.7 → 2.5.8
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/README.md +1 -1
- package/index.ts +1 -1
- package/package.json +1 -1
- package/src/worker.ts +36 -6
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ The footer shows the issue, the stage, the number of tool calls and the time spe
|
|
|
18
18
|
|
|
19
19
|
## Worker
|
|
20
20
|
|
|
21
|
-
The extension does no work itself. On `/next-issue` it connects to the `next-issue` worker on the socket file `~/.pi/agent/next-issue.sock`. When no worker answers, it starts one with `npx -y next-issue
|
|
21
|
+
The extension does no work itself. On `/next-issue` it connects to the `next-issue` worker on the socket file `~/.pi/agent/next-issue.sock`. When no worker answers, it starts one with `npx -y next-issue@<version> serve`, where `<version>` is the version of the extension, or `latest` when the extension runs from a source checkout with version `0.0.0`, in the background, and writes the output of the worker to `~/.pi/agent/next-issue-worker.log`.
|
|
22
22
|
|
|
23
23
|
- Every pi on the machine shares the one worker, and every pi in a repository shows the run of that repository, whoever started it.
|
|
24
24
|
- Opening pi does not start a worker. It only shows a run when a worker is going.
|
package/index.ts
CHANGED
|
@@ -79,7 +79,7 @@ const fromMachine: Options = {
|
|
|
79
79
|
return new WorkerClient({
|
|
80
80
|
socketPath: join(agentDir, 'next-issue.sock'),
|
|
81
81
|
version: packageVersion(),
|
|
82
|
-
spawnWorker: () => spawnWorker(agentDir),
|
|
82
|
+
spawnWorker: (version) => spawnWorker(agentDir, version),
|
|
83
83
|
});
|
|
84
84
|
},
|
|
85
85
|
root: repoRoot,
|
package/package.json
CHANGED
package/src/worker.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type WorkerEvent =
|
|
|
36
36
|
export type WorkerOptions = {
|
|
37
37
|
socketPath: string;
|
|
38
38
|
version: string;
|
|
39
|
-
spawnWorker: () => void;
|
|
39
|
+
spawnWorker: (version: string) => void;
|
|
40
40
|
startTimeoutMs?: number;
|
|
41
41
|
reconnectMs?: number;
|
|
42
42
|
};
|
|
@@ -46,21 +46,51 @@ const RECONNECT_MS = 5_000;
|
|
|
46
46
|
const POLL_MS = 200;
|
|
47
47
|
|
|
48
48
|
export function isNewer(candidate: string, current: string): boolean {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
49
|
+
const [leftCore = '', ...leftRest] = candidate.replace(/\+.*$/, '').split('-');
|
|
50
|
+
const [rightCore = '', ...rightRest] = current.replace(/\+.*$/, '').split('-');
|
|
51
|
+
const left = leftCore.split('.').map(Number);
|
|
52
|
+
const right = rightCore.split('.').map(Number);
|
|
51
53
|
for (let index = 0; index < Math.max(left.length, right.length); index += 1) {
|
|
52
54
|
const difference = (left[index] ?? 0) - (right[index] ?? 0);
|
|
53
55
|
if (difference !== 0) {
|
|
54
56
|
return difference > 0;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
59
|
+
const leftPrerelease = leftRest.length > 0 ? leftRest.join('-').split('.') : [];
|
|
60
|
+
const rightPrerelease = rightRest.length > 0 ? rightRest.join('-').split('.') : [];
|
|
61
|
+
if (leftPrerelease.length === 0 || rightPrerelease.length === 0) {
|
|
62
|
+
return leftPrerelease.length === 0 && rightPrerelease.length > 0;
|
|
63
|
+
}
|
|
64
|
+
for (let index = 0; index < Math.max(leftPrerelease.length, rightPrerelease.length); index += 1) {
|
|
65
|
+
const leftPart = leftPrerelease[index];
|
|
66
|
+
const rightPart = rightPrerelease[index];
|
|
67
|
+
if (leftPart === undefined || rightPart === undefined) {
|
|
68
|
+
return rightPart === undefined;
|
|
69
|
+
}
|
|
70
|
+
if (leftPart === rightPart) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const leftNumeric = /^\d+$/.test(leftPart);
|
|
74
|
+
const rightNumeric = /^\d+$/.test(rightPart);
|
|
75
|
+
if (leftNumeric && rightNumeric) {
|
|
76
|
+
return Number(leftPart) > Number(rightPart);
|
|
77
|
+
}
|
|
78
|
+
if (leftNumeric || rightNumeric) {
|
|
79
|
+
return rightNumeric;
|
|
80
|
+
}
|
|
81
|
+
return leftPart > rightPart;
|
|
82
|
+
}
|
|
57
83
|
return false;
|
|
58
84
|
}
|
|
59
85
|
|
|
60
|
-
export function
|
|
86
|
+
export function workerArgs(version: string): string[] {
|
|
87
|
+
return ['-y', `next-issue@${version === '0.0.0' ? 'latest' : version}`, 'serve'];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function spawnWorker(agentDir: string, version: string): void {
|
|
61
91
|
const log = openSync(join(agentDir, 'next-issue-worker.log'), 'a');
|
|
62
92
|
try {
|
|
63
|
-
const child = spawn('npx',
|
|
93
|
+
const child = spawn('npx', workerArgs(version), {
|
|
64
94
|
detached: true,
|
|
65
95
|
stdio: ['ignore', log, log],
|
|
66
96
|
});
|
|
@@ -143,7 +173,7 @@ export class WorkerClient {
|
|
|
143
173
|
await this.open();
|
|
144
174
|
return;
|
|
145
175
|
} catch {
|
|
146
|
-
this.options.spawnWorker();
|
|
176
|
+
this.options.spawnWorker(this.options.version);
|
|
147
177
|
}
|
|
148
178
|
const deadline = Date.now() + (this.options.startTimeoutMs ?? START_TIMEOUT_MS);
|
|
149
179
|
for (;;) {
|