pi-odd-worktree 1.1.1 → 2.0.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/README.md +55 -7
- package/extensions/odd-worktree-tools.ts +490 -164
- package/lib/odd-prompt/odd-worktrees.with-codegraph.md +19 -0
- package/lib/odd-prompt/odd-worktrees.without-codegraph.md +15 -0
- package/lib/odd-worktrees-prompt.js +25 -28
- package/lib/warp-delete-confirm.js +1 -1
- package/lib/worktree-card.js +7 -7
- package/lib/worktree-close-herdr.js +1 -1
- package/lib/worktree-git.js +1 -190
- package/lib/worktree-hooks.js +2 -2
- package/lib/worktree-model-result.js +2 -2
- package/lib/worktree-session-guard.js +9 -1
- package/lib/worktree-warp-busy.js +564 -0
- package/package.json +1 -1
- package/tools/herdr-free-create.test.js +161 -0
- package/tools/odd-worktrees-prompt.test.js +36 -29
- package/tools/package-surface.test.js +7 -4
- package/tools/t5-session-identity.test.js +4 -4
- package/tools/warp-busy-guard.test.js +1123 -0
- package/tools/warp-delete-confirm.test.js +1 -1
- package/tools/worktree-close-herdr-async.test.js +2 -2
- package/tools/worktree-session-guard.test.js +1 -1
- package/tools/worktree-tools.test.js +35 -11
|
@@ -471,7 +471,7 @@ describe('A2: ignored files are disclosed, never silently deleted', () => {
|
|
|
471
471
|
});
|
|
472
472
|
|
|
473
473
|
// S7/S8: the warp panel's Ctrl+D runs the SAME active-session guard as the
|
|
474
|
-
// `
|
|
474
|
+
// `worktree_delete` tool, and it runs it BEFORE the pending-change question.
|
|
475
475
|
// These cases drive the real `/warp` command with a host double: `ui.custom`
|
|
476
476
|
// answers the marker the selector's `ctrl+d` emits, `ui.confirm` records the
|
|
477
477
|
// one dialog, and every temp worktree is created through the registered tool.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
// S6: `
|
|
2
|
+
// S6: `worktree_delete` removes a checkout with `git worktree remove` and NOTHING
|
|
3
3
|
// else. The Herdr workspace reconcile it used to run — closing every workspace
|
|
4
4
|
// of the checkout's group and opening a fresh one at the principal — is gone:
|
|
5
5
|
// this package never closes or opens a Herdr panel, and it never asks Herdr to
|
|
@@ -192,7 +192,7 @@ describe('S6: a real close spawns no Herdr process', () => {
|
|
|
192
192
|
// From here on any Herdr spawn would leave a line in the log.
|
|
193
193
|
process.env.HERDR_BIN_PATH = HERDR_SHIM;
|
|
194
194
|
try {
|
|
195
|
-
const closed = await tools.get('
|
|
195
|
+
const closed = await tools.get('worktree_delete').execute('c2', { name: 'feat-quiet' }, undefined, undefined, ctx);
|
|
196
196
|
assert.notEqual(closed.isError, true, resultText(closed));
|
|
197
197
|
} finally {
|
|
198
198
|
process.env.HERDR_BIN_PATH = NO_HERDR;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// S7/S8/S9: lib/worktree-session-guard.js — the ONE active-session guard the
|
|
3
|
-
// `
|
|
3
|
+
// `worktree_delete` tool and the warp panel's Ctrl+D both run.
|
|
4
4
|
//
|
|
5
5
|
// Gentle Shell publishes its session presence store under
|
|
6
6
|
// `<agent home>/gentle-agents/presence`: a bounded `<sessionHash>.<incarnation>
|
|
@@ -202,6 +202,30 @@ describe('worktree_list', () => {
|
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
describe('worktree_create', () => {
|
|
205
|
+
for (const existing of [false, true]) {
|
|
206
|
+
test(`never invokes Herdr for ${existing ? 'an existing' : 'a new'} branch`, async () => {
|
|
207
|
+
const repo = makeRepo();
|
|
208
|
+
const branch = existing ? 'feat/existing' : 'feat/new';
|
|
209
|
+
if (existing) git(repo, ['branch', branch]);
|
|
210
|
+
const gitLib = require('../lib/worktree-git.js');
|
|
211
|
+
const original = gitLib.runArgvAsync;
|
|
212
|
+
const binaries = [];
|
|
213
|
+
gitLib.runArgvAsync = async (bin, ...args) => {
|
|
214
|
+
binaries.push(bin);
|
|
215
|
+
return original(bin, ...args);
|
|
216
|
+
};
|
|
217
|
+
try {
|
|
218
|
+
const { ctx } = makeCtx(repo);
|
|
219
|
+
const result = await tools.get('worktree_create').execute('no-herdr', { branch, changes: 'none' }, undefined, undefined, ctx);
|
|
220
|
+
assert.notEqual(result.isError, true, resultText(result));
|
|
221
|
+
assert.equal(result.details.branchCreated, !existing);
|
|
222
|
+
assert.ok(binaries.includes('git'));
|
|
223
|
+
assert.ok(!binaries.includes(NO_HERDR), `unexpected Herdr execution: ${binaries}`);
|
|
224
|
+
} finally {
|
|
225
|
+
gitLib.runArgvAsync = original;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
205
229
|
test('creates the checkout and its registry row without Herdr', async () => {
|
|
206
230
|
const repo = makeRepo();
|
|
207
231
|
const { ctx } = makeCtx(repo);
|
|
@@ -255,7 +279,7 @@ describe('worktree_create', () => {
|
|
|
255
279
|
});
|
|
256
280
|
});
|
|
257
281
|
|
|
258
|
-
describe('
|
|
282
|
+
describe('worktree_delete', () => {
|
|
259
283
|
test('removes the checkout and keeps the branch', async () => {
|
|
260
284
|
const repo = makeRepo();
|
|
261
285
|
const { ctx } = makeCtx(repo);
|
|
@@ -269,7 +293,7 @@ describe('worktree_close', () => {
|
|
|
269
293
|
assert.notEqual(created.isError, true, resultText(created));
|
|
270
294
|
const target = path.join(path.dirname(repo), `${path.basename(repo)}-worktrees`, 'feat-close-me');
|
|
271
295
|
|
|
272
|
-
const closed = await tools.get('
|
|
296
|
+
const closed = await tools.get('worktree_delete').execute('call-8', { name: 'feat-close-me' }, undefined, undefined, ctx);
|
|
273
297
|
assert.notEqual(closed.isError, true, resultText(closed));
|
|
274
298
|
assert.equal(
|
|
275
299
|
resultText(closed),
|
|
@@ -289,7 +313,7 @@ describe('worktree_close', () => {
|
|
|
289
313
|
test('an unknown name is refused and leaves the repository untouched', async () => {
|
|
290
314
|
const repo = makeRepo();
|
|
291
315
|
const { ctx } = makeCtx(repo);
|
|
292
|
-
const result = await tools.get('
|
|
316
|
+
const result = await tools.get('worktree_delete').execute('call-10', { name: 'nope' }, undefined, undefined, ctx);
|
|
293
317
|
assert.equal(result.isError, true);
|
|
294
318
|
assert.equal(resultText(result), 'no registered worktree for "nope": no worktrees are registered');
|
|
295
319
|
assert.equal(listWorktreePaths(repo).length, 1);
|
|
@@ -306,7 +330,7 @@ describe('worktree_close', () => {
|
|
|
306
330
|
const target = path.join(path.dirname(repo), `${path.basename(repo)}-worktrees`, 'feat-busy');
|
|
307
331
|
const sessionHash = publishSession({ sessionId: 'worker-9', label: 'Worker', workspace: target });
|
|
308
332
|
|
|
309
|
-
const closed = await tools.get('
|
|
333
|
+
const closed = await tools.get('worktree_delete').execute('call-s2', { name: 'feat-busy' }, undefined, undefined, ctx);
|
|
310
334
|
assert.equal(closed.isError, true, 'a live session blocks the close');
|
|
311
335
|
const text = resultText(closed);
|
|
312
336
|
assert.match(text, /working in that checkout/);
|
|
@@ -331,7 +355,7 @@ describe('worktree_close', () => {
|
|
|
331
355
|
// The session now STANDS in the checkout: no presence record is needed for
|
|
332
356
|
// the deterministic cwd check to catch it.
|
|
333
357
|
const { ctx } = makeCtx(target);
|
|
334
|
-
const closed = await tools.get('
|
|
358
|
+
const closed = await tools.get('worktree_delete').execute('call-s5', { name: 'feat-mine' }, undefined, undefined, ctx);
|
|
335
359
|
assert.equal(closed.isError, true);
|
|
336
360
|
const text = resultText(closed);
|
|
337
361
|
assert.match(text, /this session is working in that checkout/);
|
|
@@ -349,7 +373,7 @@ describe('worktree_close', () => {
|
|
|
349
373
|
const target = path.join(path.dirname(repo), `${path.basename(repo)}-worktrees`, 'feat-blocked-ui');
|
|
350
374
|
publishSession({ sessionId: 'ui-worker', label: 'UI Worker', workspace: target, incarnationIndex: 2 });
|
|
351
375
|
const { ctx, confirmations } = makeUiCtx(repo);
|
|
352
|
-
const closed = await tools.get('
|
|
376
|
+
const closed = await tools.get('worktree_delete').execute('call-s7', { name: 'feat/blocked-ui' }, undefined, undefined, ctx);
|
|
353
377
|
assert.equal(closed.isError, true);
|
|
354
378
|
assert.equal(confirmations.length, 0, 'the session check runs before the approval question');
|
|
355
379
|
assert.ok(fs.existsSync(target));
|
|
@@ -361,7 +385,7 @@ describe('worktree_close', () => {
|
|
|
361
385
|
await tools.get('worktree_create').execute('call-s8', { branch: 'feat/free', changes: 'none' }, undefined, undefined, ctx);
|
|
362
386
|
const target = path.join(path.dirname(repo), `${path.basename(repo)}-worktrees`, 'feat-free');
|
|
363
387
|
publishSession({ sessionId: 'other-worker', label: 'Other', workspace: repo, incarnationIndex: 3 });
|
|
364
|
-
const closed = await tools.get('
|
|
388
|
+
const closed = await tools.get('worktree_delete').execute('call-s9', { name: 'feat-free' }, undefined, undefined, ctx);
|
|
365
389
|
assert.notEqual(closed.isError, true, resultText(closed));
|
|
366
390
|
assert.equal(fs.existsSync(target), false);
|
|
367
391
|
});
|
|
@@ -374,7 +398,7 @@ describe('worktree_close', () => {
|
|
|
374
398
|
const sessionHash = publishSession({ sessionId: 'raw-worker-9', label: 'Raw', workspace: target, incarnationIndex: 7 });
|
|
375
399
|
publishTransport({ sessionId: 'raw-worker-9' });
|
|
376
400
|
|
|
377
|
-
const closed = await tools.get('
|
|
401
|
+
const closed = await tools.get('worktree_delete').execute('call-s13', { name: 'feat-joined' }, undefined, undefined, ctx);
|
|
378
402
|
assert.equal(closed.isError, true);
|
|
379
403
|
const text = resultText(closed);
|
|
380
404
|
assert.ok(text.includes('id raw-worker-9'), text);
|
|
@@ -391,7 +415,7 @@ describe('worktree_close', () => {
|
|
|
391
415
|
const target = path.join(path.dirname(repo), `${path.basename(repo)}-worktrees`, 'feat-unjoined');
|
|
392
416
|
const sessionHash = publishSession({ sessionId: 'unjoined-worker', label: 'Unjoined', workspace: target, incarnationIndex: 8 });
|
|
393
417
|
|
|
394
|
-
const closed = await tools.get('
|
|
418
|
+
const closed = await tools.get('worktree_delete').execute('call-s15', { name: 'feat-unjoined' }, undefined, undefined, ctx);
|
|
395
419
|
assert.equal(closed.isError, true);
|
|
396
420
|
const text = resultText(closed);
|
|
397
421
|
assert.ok(text.includes(sessionHash.slice(0, 12)), text);
|
|
@@ -407,7 +431,7 @@ describe('worktree_close', () => {
|
|
|
407
431
|
const target = path.join(path.dirname(repo), `${path.basename(repo)}-worktrees`, 'feat-advisory');
|
|
408
432
|
publishSession({ sessionId: 'legacy-peer', label: 'Legacy', workspace: null, heartbeat: Date.now(), incarnationIndex: 9, discovery: false });
|
|
409
433
|
|
|
410
|
-
const closed = await tools.get('
|
|
434
|
+
const closed = await tools.get('worktree_delete').execute('call-s17', { name: 'feat-advisory' }, undefined, undefined, ctx);
|
|
411
435
|
assert.notEqual(closed.isError, true, resultText(closed));
|
|
412
436
|
assert.match(resultText(closed), /published no workspace/);
|
|
413
437
|
assert.match(resultText(closed), /best effort/);
|
|
@@ -423,7 +447,7 @@ describe('worktree_close', () => {
|
|
|
423
447
|
sessionId: 'crashed-worker', label: 'Crashed', workspace: target,
|
|
424
448
|
heartbeat: Date.now() - 10 * 60 * 1000, incarnationIndex: 4,
|
|
425
449
|
});
|
|
426
|
-
const closed = await tools.get('
|
|
450
|
+
const closed = await tools.get('worktree_delete').execute('call-s11', { name: 'feat-stale' }, undefined, undefined, ctx);
|
|
427
451
|
assert.notEqual(closed.isError, true, resultText(closed));
|
|
428
452
|
const text = resultText(closed);
|
|
429
453
|
assert.match(text, /stale Gentle Shell presence record ignored/);
|