opencode-pilot 0.24.10 → 0.24.12
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/Formula/opencode-pilot.rb +2 -2
- package/package.json +1 -1
- package/service/actions.js +76 -43
- package/service/session-context.js +83 -0
- package/test/integration/poll-once.test.js +308 -0
- package/test/integration/real-server.test.js +274 -0
- package/test/integration/session-reuse.test.js +280 -15
- package/test/unit/actions.test.js +27 -27
|
@@ -7,6 +7,7 @@ import assert from 'node:assert';
|
|
|
7
7
|
import { mkdtempSync, writeFileSync, mkdirSync, rmSync } from 'fs';
|
|
8
8
|
import { join } from 'path';
|
|
9
9
|
import { tmpdir, homedir } from 'os';
|
|
10
|
+
import { SessionContext } from '../../service/session-context.js';
|
|
10
11
|
|
|
11
12
|
describe('actions.js', () => {
|
|
12
13
|
let tempDir;
|
|
@@ -981,9 +982,9 @@ Check for bugs and security issues.`;
|
|
|
981
982
|
// Should NOT call worktree endpoints when existing_directory is provided
|
|
982
983
|
assert.strictEqual(worktreeListCalled, false, 'Should NOT list worktrees');
|
|
983
984
|
assert.strictEqual(worktreeCreateCalled, false, 'Should NOT create worktree');
|
|
984
|
-
// Session creation uses
|
|
985
|
+
// Session creation uses worktree directory (sets actual working dir)
|
|
985
986
|
assert.strictEqual(sessionDirectory, '/data/worktree/calm-wizard',
|
|
986
|
-
'Session creation should use worktree
|
|
987
|
+
'Session creation should use worktree as working directory');
|
|
987
988
|
// Result directory is the worktree (where file operations happen)
|
|
988
989
|
assert.strictEqual(result.directory, '/data/worktree/calm-wizard',
|
|
989
990
|
'Result should include worktree directory');
|
|
@@ -1026,7 +1027,7 @@ Check for bugs and security issues.`;
|
|
|
1026
1027
|
|
|
1027
1028
|
const result = await createSessionViaApi(
|
|
1028
1029
|
'http://localhost:4096',
|
|
1029
|
-
'/path/to/project',
|
|
1030
|
+
SessionContext.forProject('/path/to/project'),
|
|
1030
1031
|
'Fix the bug',
|
|
1031
1032
|
{ fetch: mockFetch }
|
|
1032
1033
|
);
|
|
@@ -1042,12 +1043,12 @@ Check for bugs and security issues.`;
|
|
|
1042
1043
|
assert.ok(messageUrl.includes('%2Fpath%2Fto%2Fproject'), 'Message URL should include encoded directory path');
|
|
1043
1044
|
});
|
|
1044
1045
|
|
|
1045
|
-
test('
|
|
1046
|
+
test('uses workingDirectory for session creation, no PATCH when no title', async () => {
|
|
1046
1047
|
const { createSessionViaApi } = await import('../../service/actions.js');
|
|
1047
1048
|
|
|
1048
1049
|
const mockSessionId = 'ses_test_proj';
|
|
1049
1050
|
let createUrl = null;
|
|
1050
|
-
let
|
|
1051
|
+
let patchCalled = false;
|
|
1051
1052
|
let messageUrl = null;
|
|
1052
1053
|
|
|
1053
1054
|
const mockFetch = async (url, opts) => {
|
|
@@ -1058,8 +1059,8 @@ Check for bugs and security issues.`;
|
|
|
1058
1059
|
return { ok: true, json: async () => ({ id: mockSessionId }) };
|
|
1059
1060
|
}
|
|
1060
1061
|
|
|
1061
|
-
if (
|
|
1062
|
-
|
|
1062
|
+
if (opts?.method === 'PATCH') {
|
|
1063
|
+
patchCalled = true;
|
|
1063
1064
|
return { ok: true, json: async () => ({}) };
|
|
1064
1065
|
}
|
|
1065
1066
|
|
|
@@ -1073,26 +1074,25 @@ Check for bugs and security issues.`;
|
|
|
1073
1074
|
|
|
1074
1075
|
await createSessionViaApi(
|
|
1075
1076
|
'http://localhost:4096',
|
|
1076
|
-
|
|
1077
|
+
SessionContext.forWorktree(
|
|
1078
|
+
'/home/user/code/odin',
|
|
1079
|
+
'/home/user/.local/share/opencode/worktree/abc123/pr-415'
|
|
1080
|
+
),
|
|
1077
1081
|
'Fix the bug',
|
|
1078
|
-
{
|
|
1079
|
-
fetch: mockFetch,
|
|
1080
|
-
projectDirectory: '/home/user/code/odin',
|
|
1081
|
-
}
|
|
1082
|
+
{ fetch: mockFetch }
|
|
1082
1083
|
);
|
|
1083
1084
|
|
|
1084
|
-
// Session creation should use the worktree directory
|
|
1085
|
+
// Session creation should use the worktree directory
|
|
1085
1086
|
assert.ok(createUrl.includes('worktree'),
|
|
1086
|
-
'Session creation should use
|
|
1087
|
+
'Session creation should use workingDirectory (worktree path)');
|
|
1087
1088
|
assert.ok(createUrl.includes('pr-415'),
|
|
1088
|
-
'Session creation should use
|
|
1089
|
+
'Session creation should use workingDirectory (worktree path)');
|
|
1089
1090
|
|
|
1090
|
-
// PATCH
|
|
1091
|
-
assert.
|
|
1092
|
-
|
|
1093
|
-
'PATCH should use projectDirectory for project scoping');
|
|
1091
|
+
// No PATCH when no title is provided — no "project re-scoping" needed
|
|
1092
|
+
assert.strictEqual(patchCalled, false,
|
|
1093
|
+
'PATCH should NOT be called when no title (no project re-scoping needed)');
|
|
1094
1094
|
|
|
1095
|
-
// Message should use the working directory
|
|
1095
|
+
// Message should use the working directory
|
|
1096
1096
|
assert.ok(messageUrl.includes('worktree'),
|
|
1097
1097
|
'Message should use the worktree working directory');
|
|
1098
1098
|
assert.ok(messageUrl.includes('pr-415'),
|
|
@@ -1110,7 +1110,7 @@ Check for bugs and security issues.`;
|
|
|
1110
1110
|
|
|
1111
1111
|
const result = await createSessionViaApi(
|
|
1112
1112
|
'http://localhost:4096',
|
|
1113
|
-
'/path/to/project',
|
|
1113
|
+
SessionContext.forProject('/path/to/project'),
|
|
1114
1114
|
'Fix the bug',
|
|
1115
1115
|
{ fetch: mockFetch }
|
|
1116
1116
|
);
|
|
@@ -1152,7 +1152,7 @@ Check for bugs and security issues.`;
|
|
|
1152
1152
|
|
|
1153
1153
|
await createSessionViaApi(
|
|
1154
1154
|
'http://localhost:4096',
|
|
1155
|
-
'/path/to/project',
|
|
1155
|
+
SessionContext.forProject('/path/to/project'),
|
|
1156
1156
|
'Fix the bug',
|
|
1157
1157
|
{
|
|
1158
1158
|
fetch: mockFetch,
|
|
@@ -1197,7 +1197,7 @@ Check for bugs and security issues.`;
|
|
|
1197
1197
|
|
|
1198
1198
|
const result = await createSessionViaApi(
|
|
1199
1199
|
'http://localhost:4096',
|
|
1200
|
-
'/path/to/project',
|
|
1200
|
+
SessionContext.forProject('/path/to/project'),
|
|
1201
1201
|
'Fix the bug',
|
|
1202
1202
|
{ fetch: mockFetch }
|
|
1203
1203
|
);
|
|
@@ -1256,7 +1256,7 @@ Check for bugs and security issues.`;
|
|
|
1256
1256
|
|
|
1257
1257
|
const result = await createSessionViaApi(
|
|
1258
1258
|
'http://localhost:4096',
|
|
1259
|
-
'/path/to/project',
|
|
1259
|
+
SessionContext.forProject('/path/to/project'),
|
|
1260
1260
|
'/review https://github.com/org/repo/pull/123',
|
|
1261
1261
|
{ fetch: mockFetch }
|
|
1262
1262
|
);
|
|
@@ -1309,7 +1309,7 @@ Check for bugs and security issues.`;
|
|
|
1309
1309
|
|
|
1310
1310
|
const result = await createSessionViaApi(
|
|
1311
1311
|
'http://localhost:4096',
|
|
1312
|
-
'/path/to/project',
|
|
1312
|
+
SessionContext.forProject('/path/to/project'),
|
|
1313
1313
|
'Fix the bug in the login page',
|
|
1314
1314
|
{ fetch: mockFetch }
|
|
1315
1315
|
);
|
|
@@ -1360,7 +1360,7 @@ Check for bugs and security issues.`;
|
|
|
1360
1360
|
|
|
1361
1361
|
const result = await createSessionViaApi(
|
|
1362
1362
|
'http://localhost:4096',
|
|
1363
|
-
'/path/to/project',
|
|
1363
|
+
SessionContext.forProject('/path/to/project'),
|
|
1364
1364
|
'Fix the bug',
|
|
1365
1365
|
{ fetch: mockFetch, title: 'Test Session', headerTimeout: 100 }
|
|
1366
1366
|
);
|
|
@@ -1407,7 +1407,7 @@ Check for bugs and security issues.`;
|
|
|
1407
1407
|
|
|
1408
1408
|
const result = await createSessionViaApi(
|
|
1409
1409
|
'http://localhost:4096',
|
|
1410
|
-
'/path/to/project',
|
|
1410
|
+
SessionContext.forProject('/path/to/project'),
|
|
1411
1411
|
'Fix the bug',
|
|
1412
1412
|
{ fetch: mockFetch }
|
|
1413
1413
|
);
|