pi-odd-worktree 2.1.0 → 3.0.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/README.md +54 -319
- package/extensions/odd-worktree-tools.ts +4182 -2539
- package/lib/bash-activity.js +1166 -0
- package/lib/bash-design.js +684 -0
- package/lib/bash-destructive.js +559 -0
- package/lib/bash-frame.js +205 -0
- package/lib/card-content.js +23 -0
- package/lib/card-style.js +175 -0
- package/lib/checkout-facts.js +30 -70
- package/lib/codegraph-card-preview.js +628 -0
- package/lib/codegraph-card.js +515 -0
- package/lib/codegraph-compaction.js +76 -0
- package/lib/codegraph-daemon.js +246 -0
- package/lib/codegraph-edit-sync.js +182 -0
- package/lib/codegraph-guard-target.js +337 -0
- package/lib/codegraph-guard.js +211 -0
- package/lib/codegraph-index.js +1020 -0
- package/lib/codegraph-lock.js +607 -0
- package/lib/codegraph-mcp-config.js +134 -0
- package/lib/codegraph-mcp.js +123 -0
- package/lib/codegraph-paths.js +69 -0
- package/lib/codegraph-prompt/explore.md +11 -0
- package/lib/codegraph-prompt/fix.md +6 -0
- package/lib/codegraph-prompt/generic.md +8 -0
- package/lib/codegraph-prompt/judge.md +9 -0
- package/lib/codegraph-prompt/orchestrator.md +17 -0
- package/lib/codegraph-prompt/verify.md +10 -0
- package/lib/codegraph-prompt/worker.md +7 -0
- package/lib/codegraph-role.js +55 -0
- package/lib/codegraph-rules.js +146 -0
- package/lib/codegraph-session.js +303 -383
- package/lib/codegraph-warmup.js +139 -0
- package/lib/file-card-markdown.js +141 -0
- package/lib/file-card-resolver.js +245 -0
- package/lib/file-card.js +659 -0
- package/lib/files-index.js +387 -0
- package/lib/files-insert.js +81 -0
- package/lib/files-orders.js +326 -0
- package/lib/files-picker-view.js +1421 -0
- package/lib/files-preview.js +338 -0
- package/lib/files-scope-detail.js +171 -0
- package/lib/files-scope-view.js +507 -0
- package/lib/gh-issues.js +323 -15
- package/lib/issue-preview.js +26 -7
- package/lib/issues-bash-mutation.js +206 -0
- package/lib/issues-cache-store.js +261 -0
- package/lib/issues-section.js +710 -0
- package/lib/issues-view.js +649 -52
- package/lib/odd-prompt/odd-worktrees.md +21 -0
- package/lib/odd-worktrees-prompt.js +10 -28
- package/lib/related-issues-cache.js +210 -0
- package/lib/shell-card.js +825 -0
- package/lib/skill-odd-card.js +183 -0
- package/lib/tui-paint.js +4 -5
- package/lib/warp-create-panel.js +538 -250
- package/lib/warp-create-picker.js +56 -9
- package/lib/warp-delete-confirm.js +19 -28
- package/lib/warp-selector-view.js +160 -82
- package/lib/which-command.js +90 -0
- package/lib/worktree-card.js +267 -897
- package/lib/worktree-cards.js +383 -0
- package/lib/worktree-create.js +287 -0
- package/lib/worktree-git.js +3 -3
- package/lib/worktree-guard.js +548 -0
- package/lib/worktree-hooks.js +421 -712
- package/lib/worktree-list.js +120 -0
- package/lib/worktree-registry.js +162 -879
- package/lib/{worktree-close-herdr.js → worktree-remove.js} +9 -11
- package/lib/worktree-setup-runner.js +376 -0
- package/lib/worktree-setup.js +140 -0
- package/lib/worktree-warp-busy.js +462 -85
- package/lib/worktree-warp-sessions.js +1 -2
- package/package.json +2 -2
- package/tools/bash-activity.test.js +1420 -0
- package/tools/bash-design.test.js +1093 -0
- package/tools/bash-destructive.test.js +139 -0
- package/tools/card-content.test.js +44 -0
- package/tools/card-style.test.js +298 -0
- package/tools/codegraph-card-preview.test.js +254 -0
- package/tools/codegraph-card.test.js +1080 -0
- package/tools/codegraph-compaction.test.js +378 -0
- package/tools/codegraph-daemon.test.js +248 -0
- package/tools/codegraph-edit-sync.test.js +295 -0
- package/tools/codegraph-guard-target.test.js +174 -0
- package/tools/codegraph-guard.test.js +238 -0
- package/tools/codegraph-index.test.js +1948 -0
- package/tools/codegraph-lock.test.js +932 -0
- package/tools/codegraph-mcp-config.test.js +181 -0
- package/tools/codegraph-mcp.test.js +194 -0
- package/tools/codegraph-paths.test.js +44 -0
- package/tools/codegraph-role.test.js +30 -0
- package/tools/codegraph-rules.test.js +250 -0
- package/tools/codegraph-session.test.js +660 -391
- package/tools/codegraph-warmup.test.js +316 -0
- package/tools/commands.test.js +510 -31
- package/tools/file-card-markdown.test.js +188 -0
- package/tools/file-card.test.js +1289 -0
- package/tools/files-bridge.test.js +575 -0
- package/tools/files-command.test.js +613 -0
- package/tools/files-index.test.js +473 -0
- package/tools/files-insert.test.js +139 -0
- package/tools/files-orders.test.js +597 -0
- package/tools/files-picker-view.test.js +1889 -0
- package/tools/files-preview.test.js +452 -0
- package/tools/files-scope-detail.test.js +264 -0
- package/tools/files-scope-view.test.js +614 -0
- package/tools/fixtures/card-codegraph-outputs.js +110 -0
- package/tools/fixtures/codegraph-cli-stub.js +16 -0
- package/tools/fixtures/codegraph-init-process.js +28 -0
- package/tools/fixtures/codegraph-lock-worker.js +117 -0
- package/tools/fixtures/daemon-fake.js +98 -0
- package/tools/fixtures/daemon-mcp-server.js +39 -0
- package/tools/fixtures/daemon-warmup-worker.js +12 -0
- package/tools/fixtures/load-extension.js +136 -3
- package/tools/gh-issues-feedback.test.js +31 -7
- package/tools/gh-issues.test.js +417 -1
- package/tools/issue-preview.test.js +44 -7
- package/tools/issues-bash-mutation.test.js +101 -0
- package/tools/issues-cache-store.test.js +222 -0
- package/tools/issues-command.test.js +1517 -67
- package/tools/issues-open-guard.test.js +1096 -0
- package/tools/issues-section.test.js +4235 -0
- package/tools/issues-seed-query-regression.test.js +67 -0
- package/tools/issues-view.test.js +1489 -60
- package/tools/odd-worktrees-prompt.test.js +98 -65
- package/tools/package-surface.test.js +431 -36
- package/tools/related-issues-cache.test.js +324 -0
- package/tools/shell-card.test.js +834 -0
- package/tools/skill-odd-card.test.js +200 -0
- package/tools/t5-session-identity.test.js +44 -22
- package/tools/warp-busy-guard.test.js +2565 -309
- package/tools/warp-create-panel.test.js +499 -74
- package/tools/warp-create-picker.test.js +101 -5
- package/tools/warp-delete-confirm.test.js +49 -15
- package/tools/warp-empty-session.test.js +0 -1
- package/tools/warp-fallback-regression.test.js +533 -0
- package/tools/warp-selector-view.test.js +460 -196
- package/tools/which-command.test.js +126 -0
- package/tools/worktree-card.test.js +551 -0
- package/tools/worktree-cards.test.js +845 -0
- package/tools/worktree-changes.test.js +4 -5
- package/tools/worktree-create.test.js +489 -0
- package/tools/worktree-guard.test.js +823 -0
- package/tools/worktree-hooks.test.js +905 -0
- package/tools/worktree-list.test.js +170 -0
- package/tools/worktree-registry.test.js +89 -230
- package/tools/worktree-remove-async.test.js +318 -0
- package/tools/worktree-setup-runner.test.js +276 -0
- package/tools/worktree-setup.test.js +140 -0
- package/tools/worktree-tools.test.js +419 -199
- package/lib/codegraph-commands.js +0 -165
- package/lib/odd-prompt/odd-worktrees.with-codegraph.md +0 -19
- package/lib/odd-prompt/odd-worktrees.without-codegraph.md +0 -15
- package/lib/worktree-model-result.js +0 -291
- package/tools/codegraph-commands.test.js +0 -371
- package/tools/herdr-free-create.test.js +0 -161
- package/tools/worktree-close-herdr-async.test.js +0 -204
- package/tools/worktree-odd-migration.test.js +0 -224
- package/tools/worktree-registry-cache.test.js +0 -163
- package/tools/worktree-registry-odd.test.js +0 -231
package/tools/commands.test.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
// S4 commands: `/warp` and `/odd
|
|
2
|
+
// S4 commands: `/warp` and `/odd` are driven here through the registered
|
|
3
3
|
// handlers. `/issues` has its own suite (tools/issues-command.test.js), where
|
|
4
|
-
// the `gh` runner is injected. The warp case also proves the
|
|
5
|
-
// end:
|
|
6
|
-
//
|
|
4
|
+
// the `gh` runner is injected. The warp case also proves the handoff route end
|
|
5
|
+
// to end: `/warp @<token>` is decoded as the queued move it carries instead of
|
|
6
|
+
// being read as a checkout name. (T6/S3: `worktree_warp` is not registered, so
|
|
7
|
+
// the token is built the way the queue builds it.)
|
|
7
8
|
const { test, describe, before, after } = require('node:test');
|
|
8
9
|
const assert = require('node:assert/strict');
|
|
9
10
|
const fs = require('node:fs');
|
|
10
11
|
const os = require('node:os');
|
|
11
12
|
const path = require('node:path');
|
|
13
|
+
const { pathToFileURL } = require('node:url');
|
|
12
14
|
const { spawnSync } = require('node:child_process');
|
|
13
|
-
const {
|
|
15
|
+
const { LIB_DIR, stubbedSource, installDefaultBridge } = require('./fixtures/load-extension.js');
|
|
14
16
|
|
|
15
17
|
const scratch = [];
|
|
16
18
|
function track(dir) {
|
|
@@ -30,8 +32,6 @@ after(() => {
|
|
|
30
32
|
});
|
|
31
33
|
|
|
32
34
|
const HOOK_BIN = path.resolve(track(fs.mkdtempSync(path.join(os.tmpdir(), 'odd-cmd-hookbin-'))));
|
|
33
|
-
fs.writeFileSync(path.join(HOOK_BIN, 'codegraph'), '#!/bin/sh\nexit 0\n', { mode: 0o755 });
|
|
34
|
-
const NO_HERDR = path.join(os.tmpdir(), 'odd-worktree-no-such-herdr-binary');
|
|
35
35
|
|
|
36
36
|
function git(cwd, args) {
|
|
37
37
|
const out = spawnSync('git', args, { cwd, encoding: 'utf8' });
|
|
@@ -68,21 +68,114 @@ function resultText(result) {
|
|
|
68
68
|
return (result.content || []).map((part) => (part && part.text) || '').join('\n');
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
function stripAnsi(text) {
|
|
72
|
+
return String(text)
|
|
73
|
+
.replace(/\x1b\[[0-9;]*m/g, '')
|
|
74
|
+
.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g, '')
|
|
75
|
+
.replace(/\x1b_[^\x07\x1b]*\x07/g, '');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// The trimmed plain rows a mounted panel renders, so a test reads exactly what
|
|
79
|
+
// the human sees (a frame is padded to the width it was given).
|
|
80
|
+
function renderedRows(component, width = 100) {
|
|
81
|
+
return component.render(width).map((line) => stripAnsi(line).trimEnd());
|
|
82
|
+
}
|
|
83
|
+
|
|
71
84
|
let host;
|
|
72
85
|
let commands;
|
|
73
86
|
let tools;
|
|
87
|
+
let hooks;
|
|
88
|
+
let mod;
|
|
74
89
|
before(async () => {
|
|
75
|
-
process.env.HERDR_BIN_PATH = NO_HERDR;
|
|
76
90
|
process.env.GENTLE_WORKTREE_THREAD = 'thread-1';
|
|
77
91
|
process.env.PATH = `${HOOK_BIN}${path.delimiter}${savedEnv.PATH || ''}`;
|
|
78
92
|
const sent = [];
|
|
79
|
-
const loaded = await
|
|
93
|
+
const loaded = await loadExtensionWithModule({ sendUserMessage: (text, options) => { sent.push([text, options]); } });
|
|
80
94
|
host = loaded.host;
|
|
81
95
|
commands = loaded.commands;
|
|
82
96
|
tools = loaded.tools;
|
|
97
|
+
hooks = loaded.hooks;
|
|
98
|
+
mod = loaded.mod;
|
|
83
99
|
host.sent = sent;
|
|
84
100
|
});
|
|
85
101
|
|
|
102
|
+
// The `/warp` create front lives on the same module instance as the registered
|
|
103
|
+
// command, so this suite keeps the module namespace beside the registrations —
|
|
104
|
+
// the same stubs, lib override and fake host as the shared fixture.
|
|
105
|
+
// `setWarpDirtyAsker` and `executeWorktreeCreate` are that instance's own
|
|
106
|
+
// exported seams: how the panel's pending-changes answer and its specific-path
|
|
107
|
+
// selection are driven through the panel front (never through the tool).
|
|
108
|
+
async function loadExtensionWithModule(pi) {
|
|
109
|
+
// S18 (T14): nothing loads without gentle-shell-bridge, so this file's own host
|
|
110
|
+
// publishes the shared fixture's bridge before the factory runs.
|
|
111
|
+
installDefaultBridge();
|
|
112
|
+
process.env.GENTLE_WORKTREE_LIB_DIR = LIB_DIR;
|
|
113
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'odd-cmd-ext-'));
|
|
114
|
+
try {
|
|
115
|
+
const copy = path.join(dir, 'odd-worktree-tools.mjs');
|
|
116
|
+
fs.writeFileSync(copy, stubbedSource());
|
|
117
|
+
const loadedMod = await import(pathToFileURL(copy).href);
|
|
118
|
+
const registered = new Map();
|
|
119
|
+
const registeredTools = new Map();
|
|
120
|
+
const hooks = [];
|
|
121
|
+
const fakeHost = {
|
|
122
|
+
registerCommand: (name, handler) => { registered.set(name, handler); },
|
|
123
|
+
registerTool: (tool) => { registeredTools.set(tool.name, tool); },
|
|
124
|
+
registerMessageRenderer: () => {},
|
|
125
|
+
on: (event, handler) => { hooks.push([event, handler]); },
|
|
126
|
+
...pi,
|
|
127
|
+
};
|
|
128
|
+
loadedMod.default(fakeHost);
|
|
129
|
+
return { mod: loadedMod, commands: registered, tools: registeredTools, hooks, host: fakeHost };
|
|
130
|
+
} finally {
|
|
131
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// The destination the ported pipeline really writes, read from the pipeline's
|
|
136
|
+
// own rule (<repo-parent>/<repo-name>-worktrees/<odd>) instead of remembering
|
|
137
|
+
// a flattened spelling.
|
|
138
|
+
function portedDestination(repo, odd) {
|
|
139
|
+
const create = require('../lib/worktree-create.js');
|
|
140
|
+
return create.worktreeDestinationPath(fs.realpathSync(repo), odd);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// S3/S4: the list document this package used to keep. It is gone, so every case that
|
|
144
|
+
// used to read it now asserts it was never written.
|
|
145
|
+
function sharedDocumentPath(repo) {
|
|
146
|
+
return path.join(fs.realpathSync(repo), '.git', 'pi-worktrees.json');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// The selector's create action, then the create panel's answer, then the
|
|
150
|
+
// closing selector: only those three mounts are scripted.
|
|
151
|
+
function warpCreateUi(panelAnswer) {
|
|
152
|
+
const ui = {
|
|
153
|
+
mounts: 0,
|
|
154
|
+
custom: async () => {
|
|
155
|
+
ui.mounts += 1;
|
|
156
|
+
if (ui.mounts === 1) return { create: true };
|
|
157
|
+
if (ui.mounts === 2) return panelAnswer;
|
|
158
|
+
return undefined;
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
return ui;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
describe('the two agent tools', () => {
|
|
165
|
+
// S1: the prompt names them bare (`worktree_create`, `worktree_list`), so a bare
|
|
166
|
+
// call has to resolve. `codemode` exposure hides a tool behind `tools.<name>`
|
|
167
|
+
// inside a script, which is exactly the "Tool not found" a bare call hit while
|
|
168
|
+
// its sibling was declared direct.
|
|
169
|
+
test('both are declared direct, so a bare call resolves', async () => {
|
|
170
|
+
const { tools } = await loadExtensionWithModule({});
|
|
171
|
+
for (const name of ['worktree_create', 'worktree_list']) {
|
|
172
|
+
const tool = tools.get(name);
|
|
173
|
+
assert.ok(tool, `${name} is registered`);
|
|
174
|
+
assert.equal(tool.exposure === undefined || tool.exposure === 'direct', true, `${name} declares direct exposure, not ${tool.exposure}`);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
86
179
|
describe('/warp', () => {
|
|
87
180
|
test('refuses more than one name and says which form to use', async () => {
|
|
88
181
|
notifications.length = 0;
|
|
@@ -108,32 +201,28 @@ describe('/warp', () => {
|
|
|
108
201
|
]);
|
|
109
202
|
});
|
|
110
203
|
|
|
111
|
-
test('the
|
|
204
|
+
test('the /warp @<token> handoff is decoded as a move, not read as a name', async () => {
|
|
112
205
|
const repo = makeRepo();
|
|
113
206
|
const ctx = makeCtx(repo);
|
|
114
207
|
const created = await tools.get('worktree_create').execute(
|
|
115
208
|
'call-1',
|
|
116
|
-
{ branch: 'feat/warp-me',
|
|
209
|
+
{ branch: 'feat/warp-me', odd: 'warp-me' },
|
|
117
210
|
undefined,
|
|
118
211
|
undefined,
|
|
119
212
|
ctx,
|
|
120
213
|
);
|
|
121
214
|
assert.notEqual(created.isError, true, resultText(created));
|
|
215
|
+
const target = created.details.path;
|
|
122
216
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
assert.match(resultText(queued), /^worktree warp: handoff queued/);
|
|
133
|
-
assert.equal(host.sent.length, 1);
|
|
134
|
-
const [message, options] = host.sent[0];
|
|
135
|
-
assert.deepEqual(options, { expandPromptTemplates: true });
|
|
136
|
-
assert.ok(message.startsWith('/warp @'), `the queued command is /warp (${message})`);
|
|
217
|
+
// The token the queue re-dispatches: one base64url argument carrying the
|
|
218
|
+
// move it validated (lib/../extensions `prepareWarpHandoff`).
|
|
219
|
+
const message = `/warp @${Buffer.from(JSON.stringify({
|
|
220
|
+
v: 1,
|
|
221
|
+
name: 'feat-warp-me',
|
|
222
|
+
target,
|
|
223
|
+
from: fs.realpathSync(repo),
|
|
224
|
+
branch: 'feat/warp-me',
|
|
225
|
+
}), 'utf8').toString('base64url')}`;
|
|
137
226
|
|
|
138
227
|
// The command accepts exactly that argument: the handoff is decoded (the
|
|
139
228
|
// session-control refusal is the NEXT gate, so nothing about the token is
|
|
@@ -146,11 +235,237 @@ describe('/warp', () => {
|
|
|
146
235
|
});
|
|
147
236
|
});
|
|
148
237
|
|
|
149
|
-
describe('/
|
|
238
|
+
describe('the /warp panel create front', () => {
|
|
239
|
+
// Both branch states: a branch the create makes, and an existing branch it
|
|
240
|
+
// adopts. The assertion asks the pipeline where it writes instead of
|
|
241
|
+
// remembering the old flattened spelling.
|
|
242
|
+
for (const existing of [false, true]) {
|
|
243
|
+
const name = existing ? 'adopted' : 'fresh';
|
|
244
|
+
const branch = `feat/${name}`;
|
|
245
|
+
test(`${existing ? 'adopts an existing' : 'creates a new'} branch and reports the create without a stray notice`, async () => {
|
|
246
|
+
const repo = makeRepo();
|
|
247
|
+
if (existing) git(repo, ['branch', branch]);
|
|
248
|
+
const target = portedDestination(repo, name);
|
|
249
|
+
// S1 (warp-branch-field): the panel answers the branch it composed and the
|
|
250
|
+
// ODD that names the directory, and the branch travels through UNCHANGED —
|
|
251
|
+
// nothing derives it from the ODD any more.
|
|
252
|
+
const ui = warpCreateUi({ ok: true, branch, odd: name });
|
|
253
|
+
notifications.length = 0;
|
|
254
|
+
await commands.get('warp').handler('', makeCtx(repo, { custom: ui.custom }));
|
|
255
|
+
assert.ok(fs.existsSync(target), `the /warp create made no checkout (notifications: ${JSON.stringify(notifications)})`);
|
|
256
|
+
assert.equal(git(target, ['rev-parse', '--abbrev-ref', 'HEAD']), branch, 'the new checkout holds the created/adopted branch');
|
|
257
|
+
// The create flow closed back into the selector, so the front reported a
|
|
258
|
+
// create; the click asked for none of these notices.
|
|
259
|
+
assert.ok(ui.mounts >= 3, `the selector was not handed back after the create (${ui.mounts} mounts)`);
|
|
260
|
+
assert.deepEqual(notifications, [], 'a clean create fires no notification it did not ask for');
|
|
261
|
+
// S3/S4: the checkout's directory is the whole record — no list file exists.
|
|
262
|
+
assert.equal(fs.existsSync(sharedDocumentPath(repo)), false, 'no list document is written');
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
test('the panel’s branch is passed through, never derived from the ODD', async () => {
|
|
267
|
+
const repo = makeRepo();
|
|
268
|
+
const target = portedDestination(repo, 'login-ui');
|
|
269
|
+
const ui = warpCreateUi({ ok: true, branch: 'fix/other-name', odd: 'login-ui' });
|
|
270
|
+
notifications.length = 0;
|
|
271
|
+
await commands.get('warp').handler('', makeCtx(repo, { custom: ui.custom }));
|
|
272
|
+
assert.ok(fs.existsSync(target), `the create made no checkout (notifications: ${JSON.stringify(notifications)})`);
|
|
273
|
+
assert.equal(git(target, ['rev-parse', '--abbrev-ref', 'HEAD']), 'fix/other-name', 'the answered branch is the git branch');
|
|
274
|
+
assert.equal(path.basename(target), 'login-ui', 'the ODD is the directory, so the branch names no directory');
|
|
275
|
+
assert.deepEqual(notifications, [], 'a clean create fires no notification');
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// S11 (warp-branch-field): one ODD is one worktree, so a create for an ODD
|
|
279
|
+
// that already owns one refuses by saying THAT — the exact two lines an agent
|
|
280
|
+
// reads — and refuses before writing anything.
|
|
281
|
+
test('a second create for an ODD that already has a worktree refuses with its own sentence', async () => {
|
|
282
|
+
const repo = makeRepo();
|
|
283
|
+
const first = await tools.get('worktree_create').execute(
|
|
284
|
+
'call-1', { branch: 'feat/taken', odd: 'taken' }, undefined, undefined, makeCtx(repo),
|
|
285
|
+
);
|
|
286
|
+
assert.notEqual(first.isError, true, resultText(first));
|
|
287
|
+
const target = first.details.path;
|
|
288
|
+
|
|
289
|
+
const second = await tools.get('worktree_create').execute(
|
|
290
|
+
'call-2', { branch: 'feat/taken-again', odd: 'taken' }, undefined, undefined, makeCtx(repo),
|
|
291
|
+
);
|
|
292
|
+
assert.equal(second.isError, true, 'the second create is refused');
|
|
293
|
+
assert.equal(
|
|
294
|
+
resultText(second),
|
|
295
|
+
`odd taken already has a worktree: ${target}\nUse that worktree instead of creating another.`,
|
|
296
|
+
);
|
|
297
|
+
// Nothing was written: no second checkout, no branch, and the clone's one
|
|
298
|
+
// document is byte-identical to what the first create left.
|
|
299
|
+
assert.equal(fs.existsSync(`${target}-again`), false, 'no directory is made');
|
|
300
|
+
assert.equal(git(repo, ['branch', '--list', 'feat/taken-again']), '', 'no branch is created');
|
|
301
|
+
assert.equal(fs.existsSync(sharedDocumentPath(repo)), false, 'no document is written by either create');
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
test('a plain directory at the ODD destination keeps the core’s own refusal', async () => {
|
|
305
|
+
const repo = makeRepo();
|
|
306
|
+
const target = portedDestination(repo, 'occupied');
|
|
307
|
+
fs.mkdirSync(target, { recursive: true });
|
|
308
|
+
const out = await tools.get('worktree_create').execute(
|
|
309
|
+
'call-1', { branch: 'feat/occupied', odd: 'occupied' }, undefined, undefined, makeCtx(repo),
|
|
310
|
+
);
|
|
311
|
+
assert.equal(out.isError, true);
|
|
312
|
+
assert.equal(
|
|
313
|
+
resultText(out),
|
|
314
|
+
`worktree path already exists: ${fs.realpathSync(target)}\nRemove it or pass a different odd.`,
|
|
315
|
+
);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
test('the create panel does not offer an ODD that already has a worktree', async () => {
|
|
319
|
+
const repo = makeRepo();
|
|
320
|
+
fs.mkdirSync(path.join(repo, 'odd', 'tasks'), { recursive: true });
|
|
321
|
+
for (const name of ['taken', 'free']) {
|
|
322
|
+
fs.writeFileSync(path.join(repo, 'odd', 'tasks', `${name}.md`), `# ${name}\n`);
|
|
323
|
+
}
|
|
324
|
+
git(repo, ['add', '-f', 'odd']);
|
|
325
|
+
git(repo, ['commit', '-m', 'odds']);
|
|
326
|
+
const created = await tools.get('worktree_create').execute(
|
|
327
|
+
'call-1', { branch: 'feat/taken', odd: 'taken' }, undefined, undefined, makeCtx(repo),
|
|
328
|
+
);
|
|
329
|
+
assert.notEqual(created.isError, true, resultText(created));
|
|
330
|
+
|
|
331
|
+
let panelRows = null;
|
|
332
|
+
let mounts = 0;
|
|
333
|
+
const custom = async (factory) => {
|
|
334
|
+
mounts += 1;
|
|
335
|
+
if (mounts === 1) return { create: true };
|
|
336
|
+
if (mounts === 2) {
|
|
337
|
+
const component = factory({ requestRender: () => {} }, null, null, () => {});
|
|
338
|
+
component.handleInput('\t'); // the Odd field
|
|
339
|
+
panelRows = renderedRows(component);
|
|
340
|
+
}
|
|
341
|
+
return undefined;
|
|
342
|
+
};
|
|
343
|
+
notifications.length = 0;
|
|
344
|
+
await commands.get('warp').handler('', makeCtx(repo, { custom }));
|
|
345
|
+
assert.ok(Array.isArray(panelRows), `the create panel never mounted (${JSON.stringify(notifications)})`);
|
|
346
|
+
const text = panelRows.join('\n');
|
|
347
|
+
assert.ok(!/^\s+taken$/m.test(text), `the taken ODD is not offered\n${text}`);
|
|
348
|
+
assert.match(text, /^\s+free$/m, 'the free ODD is still offered');
|
|
349
|
+
assert.match(text, /new odd/, 'new odd is still offered');
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
test('a refused panel create is the ported sentence, verbatim, and writes nothing', async () => {
|
|
353
|
+
const repo = makeRepo();
|
|
354
|
+
const out = await mod.executeWorktreeCreate({ branch: 'feat/login', odd: 'a/b' }, makeCtx(repo));
|
|
355
|
+
assert.equal(out.isError, true);
|
|
356
|
+
assert.equal(
|
|
357
|
+
resultText(out),
|
|
358
|
+
'invalid odd name: "a/b"\nodd must be a single path segment (letters, digits, dash, underscore, dot)',
|
|
359
|
+
);
|
|
360
|
+
assert.equal(fs.existsSync(portedDestination(repo, 'a/b')), false);
|
|
361
|
+
assert.equal(fs.existsSync(path.join(fs.realpathSync(repo), '.git', 'pi-worktrees.json')), false, 'no document is written');
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
test('a panel create with no ODD is refused: the ODD names the checkout', async () => {
|
|
365
|
+
const repo = makeRepo();
|
|
366
|
+
const out = await mod.executeWorktreeCreate({ branch: 'feat/no-odd' }, makeCtx(repo));
|
|
367
|
+
assert.equal(out.isError, true);
|
|
368
|
+
assert.equal(
|
|
369
|
+
resultText(out),
|
|
370
|
+
'invalid odd name: undefined\nodd must be a single path segment (letters, digits, dash, underscore, dot)',
|
|
371
|
+
);
|
|
372
|
+
assert.equal(fs.existsSync(path.join(fs.realpathSync(repo), '.git', 'pi-worktrees.json')), false, 'no document is written');
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
test('"copy everything" becomes the ported boolean and prints only the ported line', async () => {
|
|
376
|
+
const repo = makeRepo();
|
|
377
|
+
fs.writeFileSync(path.join(repo, 'pending.txt'), 'pending\n');
|
|
378
|
+
const target = portedDestination(repo, 'all-copy');
|
|
379
|
+
const out = await mod.executeWorktreeCreate({ branch: 'feat/all-copy', odd: 'all-copy', changes: 'all' }, makeCtx(repo));
|
|
380
|
+
assert.notEqual(out.isError, true, resultText(out));
|
|
381
|
+
const text = resultText(out);
|
|
382
|
+
assert.match(text, /^copy_changes: 1 changes copied$/m);
|
|
383
|
+
assert.doesNotMatch(text, /^copied:/m, 'the panel line belongs to the path mode only');
|
|
384
|
+
assert.equal(fs.readFileSync(path.join(target, 'pending.txt'), 'utf8'), 'pending\n', 'the ported hook copied it once');
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
test('a specific path selection copies only those paths and prints its own line', async () => {
|
|
388
|
+
const repo = makeRepo();
|
|
389
|
+
fs.writeFileSync(path.join(repo, 'selected.txt'), 'selected\n');
|
|
390
|
+
fs.writeFileSync(path.join(repo, 'skipped.txt'), 'skipped\n');
|
|
391
|
+
const target = portedDestination(repo, 'selected');
|
|
392
|
+
const out = await mod.executeWorktreeCreate(
|
|
393
|
+
{ branch: 'feat/selected', odd: 'selected', changes: ['selected.txt'] },
|
|
394
|
+
makeCtx(repo),
|
|
395
|
+
);
|
|
396
|
+
assert.notEqual(out.isError, true, resultText(out));
|
|
397
|
+
const text = resultText(out);
|
|
398
|
+
assert.match(text, /^copied: 1 file, \+1\/-0$/m);
|
|
399
|
+
assert.doesNotMatch(text, /^copy_changes:/m, 'the boolean mode\u2019s line is not printed by the path mode');
|
|
400
|
+
assert.equal(fs.readFileSync(path.join(target, 'selected.txt'), 'utf8'), 'selected\n');
|
|
401
|
+
assert.equal(fs.existsSync(path.join(target, 'skipped.txt')), false, 'only the selected path travelled');
|
|
402
|
+
// S3: nothing about the transfer is stored — there is no record to hold it.
|
|
403
|
+
assert.equal(fs.existsSync(sharedDocumentPath(repo)), false, 'no document is written');
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
test('an unknown selected path refuses before anything is created', async () => {
|
|
407
|
+
const repo = makeRepo();
|
|
408
|
+
const out = await mod.executeWorktreeCreate({ branch: 'feat/unknown', odd: 'unknown', changes: ['missing.txt'] }, makeCtx(repo));
|
|
409
|
+
assert.equal(out.isError, true);
|
|
410
|
+
assert.match(resultText(out), /unknown changed file: "missing.txt" \(nothing was copied\) \(nothing was created\)$/);
|
|
411
|
+
assert.equal(fs.existsSync(portedDestination(repo, 'unknown')), false);
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
// S5 (warp-branch-field): the selector offers DESTINATIONS that exist. Each mount
|
|
416
|
+
// re-reads the registry AND git's live listing and offers only checkouts both
|
|
417
|
+
// agree on, so a checkout removed before the panel opens leaves no row and a
|
|
418
|
+
// stale registry row can never become a selectable checkout.
|
|
419
|
+
describe('/warp selector after a removal', () => {
|
|
420
|
+
function mountSelector() {
|
|
421
|
+
const state = { rows: null };
|
|
422
|
+
const custom = async (factory) => {
|
|
423
|
+
const component = factory({ requestRender: () => {} }, null, null, () => {});
|
|
424
|
+
state.rows = renderedRows(component);
|
|
425
|
+
return undefined;
|
|
426
|
+
};
|
|
427
|
+
return { custom, rows: () => state.rows };
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
test('a removed checkout is not a row, and a live one still is', async () => {
|
|
431
|
+
const repo = makeRepo();
|
|
432
|
+
for (const [odd, branch] of [['removed', 'feat/removed'], ['live', 'feat/live']]) {
|
|
433
|
+
const out = await tools.get('worktree_create').execute(
|
|
434
|
+
'call', { branch, odd }, undefined, undefined, makeCtx(repo),
|
|
435
|
+
);
|
|
436
|
+
assert.notEqual(out.isError, true, resultText(out));
|
|
437
|
+
}
|
|
438
|
+
// Opened while both checkouts exist: both are offered.
|
|
439
|
+
const before = mountSelector();
|
|
440
|
+
notifications.length = 0;
|
|
441
|
+
await commands.get('warp').handler('', makeCtx(repo, { custom: before.custom }));
|
|
442
|
+
const beforeText = before.rows().join('\n');
|
|
443
|
+
assert.match(beforeText, /feat-live/);
|
|
444
|
+
assert.match(beforeText, /feat-removed/);
|
|
445
|
+
|
|
446
|
+
// `feat-removed` goes away exactly as the human's did: git removes the
|
|
447
|
+
// checkout and the registry row stays behind.
|
|
448
|
+
const target = portedDestination(repo, 'removed');
|
|
449
|
+
git(repo, ['worktree', 'remove', target]);
|
|
450
|
+
assert.equal(fs.existsSync(target), false, 'the checkout really is gone');
|
|
451
|
+
|
|
452
|
+
// Opened FRESH afterwards, the removed one is not a row and never a
|
|
453
|
+
// destination; the live one still is.
|
|
454
|
+
const after = mountSelector();
|
|
455
|
+
notifications.length = 0;
|
|
456
|
+
await commands.get('warp').handler('', makeCtx(repo, { custom: after.custom }));
|
|
457
|
+
const afterText = after.rows().join('\n');
|
|
458
|
+
assert.ok(!afterText.includes('feat-removed'), `a removed checkout is never offered\n${afterText}`);
|
|
459
|
+
assert.match(afterText, /feat-live/);
|
|
460
|
+
assert.deepEqual(notifications, [], 'nothing is reported as an error');
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
describe('/odd', () => {
|
|
150
465
|
test('an empty checkout says there is nothing to read', async () => {
|
|
151
466
|
const repo = makeRepo();
|
|
152
467
|
notifications.length = 0;
|
|
153
|
-
await commands.get('odd
|
|
468
|
+
await commands.get('odd').handler('', makeCtx(repo));
|
|
154
469
|
assert.deepEqual(notifications, [['info', 'No odd documents under odd/tasks/ in this checkout.']]);
|
|
155
470
|
});
|
|
156
471
|
|
|
@@ -160,9 +475,9 @@ describe('/odd-list', () => {
|
|
|
160
475
|
fs.writeFileSync(path.join(repo, 'odd', 'tasks', 'feature.md'), '# Feature\n');
|
|
161
476
|
let offered = null;
|
|
162
477
|
notifications.length = 0;
|
|
163
|
-
await commands.get('odd
|
|
478
|
+
await commands.get('odd').handler(
|
|
164
479
|
'',
|
|
165
|
-
makeCtx(repo, { select: async (
|
|
480
|
+
makeCtx(repo, { select: async (_title, options) => { offered = options; return options[0]; } }),
|
|
166
481
|
);
|
|
167
482
|
assert.deepEqual(offered, ['feature']);
|
|
168
483
|
assert.deepEqual(notifications, [['info', path.join(repo, 'odd', 'tasks', 'feature.md')]]);
|
|
@@ -170,7 +485,171 @@ describe('/odd-list', () => {
|
|
|
170
485
|
|
|
171
486
|
test('an unknown option names the command that is valid', async () => {
|
|
172
487
|
notifications.length = 0;
|
|
173
|
-
await commands.get('odd
|
|
174
|
-
assert.deepEqual(notifications, [['error', 'Unknown option "nope". Use /odd
|
|
488
|
+
await commands.get('odd').handler('nope', makeCtx(makeRepo()));
|
|
489
|
+
assert.deepEqual(notifications, [['error', 'Unknown option "nope". Use /odd.']]);
|
|
175
490
|
});
|
|
176
491
|
});
|
|
492
|
+
|
|
493
|
+
// ---------------------------------------------------------------------------
|
|
494
|
+
// S8 (T6): the naming observer used to pay a `git worktree list` plus a
|
|
495
|
+
// `git rev-parse` pair on EVERY tool event, before it could know whether it could
|
|
496
|
+
// name anything — two blocking child processes per tool call. The filter is now
|
|
497
|
+
// first and text-only: only the `read`/`edit`/`write` tools, and only when the
|
|
498
|
+
// touched path is an ODD task document (`odd/tasks/*.md`), reach git at all, and a
|
|
499
|
+
// burst of events in one turn costs one listing.
|
|
500
|
+
// ---------------------------------------------------------------------------
|
|
501
|
+
describe('S8 (T6): the naming observer’s git probes', () => {
|
|
502
|
+
// `repoIdentity` and `listWorktrees` are documented seams of
|
|
503
|
+
// lib/worktree-git.js, so a test counts the child processes the extension really
|
|
504
|
+
// makes through them instead of trusting the source.
|
|
505
|
+
function countingGit() {
|
|
506
|
+
const git = mod.libModule('worktree-git.js');
|
|
507
|
+
const realIdentity = git.repoIdentity;
|
|
508
|
+
const realList = git.listWorktrees;
|
|
509
|
+
const counts = { identity: 0, listing: 0 };
|
|
510
|
+
git.repoIdentity = (...args) => { counts.identity += 1; return realIdentity.apply(git, args); };
|
|
511
|
+
git.listWorktrees = (...args) => { counts.listing += 1; return realList.apply(git, args); };
|
|
512
|
+
return {
|
|
513
|
+
counts,
|
|
514
|
+
restore: () => {
|
|
515
|
+
git.repoIdentity = realIdentity;
|
|
516
|
+
git.listWorktrees = realList;
|
|
517
|
+
},
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
async function fireHostEvent(name, event, ctx) {
|
|
522
|
+
for (const [hook, handler] of hooks) {
|
|
523
|
+
if (hook !== name) continue;
|
|
524
|
+
const out = handler(event, ctx);
|
|
525
|
+
if (out && typeof out.then === 'function') await out;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
test('an event that cannot name anything spawns no git at all', async () => {
|
|
530
|
+
const repo = makeRepo();
|
|
531
|
+
const counted = countingGit();
|
|
532
|
+
try {
|
|
533
|
+
const ctx = makeCtx(repo);
|
|
534
|
+
await fireHostEvent('tool_call', { toolName: 'bash', input: { command: 'ls' } }, ctx);
|
|
535
|
+
await fireHostEvent('tool_call', { toolName: 'read', input: { path: 'README.md' } }, ctx);
|
|
536
|
+
// An ODD document that is not a TASK document names the session after nothing.
|
|
537
|
+
await fireHostEvent('tool_call', { toolName: 'edit', input: { path: 'odd/notes.md' } }, ctx);
|
|
538
|
+
await fireHostEvent('tool_result', { toolName: 'bash', input: { command: 'gh issue list' } }, ctx);
|
|
539
|
+
assert.deepEqual(counted.counts, { identity: 0, listing: 0 },
|
|
540
|
+
'no child process runs for a call that can name nothing');
|
|
541
|
+
} finally {
|
|
542
|
+
counted.restore();
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
test('a write of an odd/tasks document probes, and a burst costs one listing', async () => {
|
|
547
|
+
const repo = makeRepo();
|
|
548
|
+
const counted = countingGit();
|
|
549
|
+
try {
|
|
550
|
+
const ctx = makeCtx(repo);
|
|
551
|
+
const documentPath = path.join(repo, 'odd', 'tasks', 'feature.md');
|
|
552
|
+
await fireHostEvent('tool_call', { toolName: 'edit', input: { path: documentPath } }, ctx);
|
|
553
|
+
assert.equal(counted.counts.identity, 1, 'the naming path read the checkout identity');
|
|
554
|
+
assert.equal(counted.counts.listing, 1, 'and git’s worktree listing');
|
|
555
|
+
// The same turn's result and a sibling event inside the memo window reuse it.
|
|
556
|
+
await fireHostEvent('tool_result', { toolName: 'edit', input: { path: documentPath } }, ctx);
|
|
557
|
+
await fireHostEvent('tool_call', { toolName: 'write', input: { path: 'odd/tasks/feature.md' } }, ctx);
|
|
558
|
+
assert.equal(counted.counts.listing, 1, 'a burst of events in one turn costs ONE git listing');
|
|
559
|
+
} finally {
|
|
560
|
+
counted.restore();
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
// PRESERVE: the filter above must not stop the naming it filters FOR. A write
|
|
565
|
+
// of an `odd/tasks/*.md` document still names the session after that document
|
|
566
|
+
// and its branch — the behaviour the observer existed for.
|
|
567
|
+
test('a write of an odd/tasks document still names the session', async () => {
|
|
568
|
+
const repo = makeRepo();
|
|
569
|
+
const created = await tools.get('worktree_create').execute(
|
|
570
|
+
'call-named', { branch: 'feat/named', odd: 'named' }, undefined, undefined, makeCtx(repo),
|
|
571
|
+
);
|
|
572
|
+
assert.notEqual(created.isError, true, resultText(created));
|
|
573
|
+
const checkout = created.details.path;
|
|
574
|
+
fs.mkdirSync(path.join(checkout, 'odd', 'tasks'), { recursive: true });
|
|
575
|
+
const documentPath = path.join(checkout, 'odd', 'tasks', 'named.md');
|
|
576
|
+
fs.writeFileSync(documentPath, '# Named session\n');
|
|
577
|
+
|
|
578
|
+
let name = '';
|
|
579
|
+
const naming = await loadExtensionWithModule({
|
|
580
|
+
getSessionName: () => name,
|
|
581
|
+
setSessionName: (next) => { name = next; },
|
|
582
|
+
});
|
|
583
|
+
const ctx = {
|
|
584
|
+
...makeCtx(checkout),
|
|
585
|
+
sessionManager: { getSessionId: () => 'thread-named' },
|
|
586
|
+
};
|
|
587
|
+
for (const [hook, handler] of naming.hooks) {
|
|
588
|
+
if (hook !== 'tool_result') continue;
|
|
589
|
+
const out = handler({ toolName: 'write', input: { path: documentPath }, toolResults: [] }, ctx);
|
|
590
|
+
if (out && typeof out.then === 'function') await out;
|
|
591
|
+
}
|
|
592
|
+
assert.equal(name, 'Named session @ feat/named', 'the write still names the session after its document');
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
test('a checkout created moments ago is still seen by the next naming step', async () => { const repo = makeRepo();
|
|
596
|
+
const counted = countingGit();
|
|
597
|
+
try {
|
|
598
|
+
const ctx = makeCtx(repo);
|
|
599
|
+
const documentPath = path.join(repo, 'odd', 'tasks', 'feature.md');
|
|
600
|
+
await fireHostEvent('tool_call', { toolName: 'edit', input: { path: documentPath } }, ctx);
|
|
601
|
+
assert.equal(counted.counts.listing, 1, 'the turn opened with one listing');
|
|
602
|
+
// The create that happens inside the same turn: the listing the first event
|
|
603
|
+
// warmed knows no such checkout, so the next naming step must not trust it.
|
|
604
|
+
await fireHostEvent('tool_result', { toolName: 'worktree_create', input: {} }, ctx);
|
|
605
|
+
await fireHostEvent('tool_call', { toolName: 'edit', input: { path: documentPath } }, ctx);
|
|
606
|
+
assert.equal(counted.counts.listing, 2, 'a create bypasses the memo for the events that follow it');
|
|
607
|
+
await fireHostEvent('tool_result', { toolName: 'edit', input: { path: documentPath } }, ctx);
|
|
608
|
+
assert.equal(counted.counts.listing, 2, 'and the listing the bypass made is memoized again');
|
|
609
|
+
} finally {
|
|
610
|
+
counted.restore();
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
// S1 (issues-startup-performance T1, correction): the live-checkout scan used to be
|
|
616
|
+
// awaited by a second `session_start` handler — a "startup barrier" — for a result
|
|
617
|
+
// nothing consumed: its only product is `warpDiscoveryCache`, and every warp lists
|
|
618
|
+
// fresh before acting. Measured on this checkout, that barrier was 65 ms of three git
|
|
619
|
+
// probes in front of the first prompt. It is dispatched and tracked like every other
|
|
620
|
+
// startup task now, so the awaited path never waits for a git read either.
|
|
621
|
+
test('S1 (T1): the awaited session_start resolves while the discovery git read is pending', async () => {
|
|
622
|
+
const repo = makeRepo();
|
|
623
|
+
const loaded = await loadExtensionWithModule({});
|
|
624
|
+
const git = loaded.mod.libModule('worktree-git.js');
|
|
625
|
+
const realIdentity = git.repoIdentityAsync;
|
|
626
|
+
const realList = git.listWorktreesAsync;
|
|
627
|
+
let released;
|
|
628
|
+
const held = new Promise((resolve) => { released = resolve; });
|
|
629
|
+
// Never answers until this test says so: an awaited barrier could not return.
|
|
630
|
+
git.repoIdentityAsync = () => held.then(() => ({ root: repo, commonDir: path.join(repo, '.git') }));
|
|
631
|
+
git.listWorktreesAsync = () => held.then(() => []);
|
|
632
|
+
try {
|
|
633
|
+
const ctx = makeCtx(repo);
|
|
634
|
+
let settled = false;
|
|
635
|
+
const run = (async () => {
|
|
636
|
+
for (const [event, handler] of loaded.hooks) {
|
|
637
|
+
if (event !== 'session_start') continue;
|
|
638
|
+
const out = handler({}, ctx);
|
|
639
|
+
if (out && typeof out.then === 'function') await out;
|
|
640
|
+
}
|
|
641
|
+
settled = true;
|
|
642
|
+
})();
|
|
643
|
+
// The host awaits the handlers in order; the tree is racing a 500 ms window.
|
|
644
|
+
await Promise.race([
|
|
645
|
+
run,
|
|
646
|
+
new Promise((resolve) => setTimeout(resolve, 500)),
|
|
647
|
+
]);
|
|
648
|
+
assert.equal(settled, true, 'the awaited session_start path waited for a git probe');
|
|
649
|
+
} finally {
|
|
650
|
+
released();
|
|
651
|
+
git.repoIdentityAsync = realIdentity;
|
|
652
|
+
git.listWorktreesAsync = realList;
|
|
653
|
+
await loaded.mod.awaitPendingStartupTasks();
|
|
654
|
+
}
|
|
655
|
+
});
|