pi-odd-worktree 1.2.0 → 2.1.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 +65 -26
- package/extensions/odd-worktree-tools.ts +576 -119
- 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-hooks.js +7 -6
- package/lib/worktree-model-result.js +2 -2
- package/lib/worktree-session-guard.js +1 -1
- package/lib/worktree-warp-busy.js +488 -43
- package/package.json +1 -1
- 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 +812 -172
- 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 +177 -13
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## ODD worktrees
|
|
2
|
+
|
|
3
|
+
Each ODD feature has its own worktree.
|
|
4
|
+
|
|
5
|
+
Starting a new ODD: create its worktree (`worktree_create`) before writing
|
|
6
|
+
anything.
|
|
7
|
+
|
|
8
|
+
Resuming an ODD: check whether it already has an associated worktree. If it does,
|
|
9
|
+
resume it there; if it does not, create it. ODD work never starts in the principal
|
|
10
|
+
checkout.
|
|
11
|
+
|
|
12
|
+
`worktree_create` places the checkout at `<repo-parent>/<repo-name>-worktrees/<name>`
|
|
13
|
+
and runs `codegraph init` there, so the new checkout has its own index from the
|
|
14
|
+
start. Edits and writes trigger a background `codegraph sync` for that checkout.
|
|
15
|
+
Every worktree keeps its own `.codegraph/`; never copy, symlink or reuse another
|
|
16
|
+
checkout's index.
|
|
17
|
+
|
|
18
|
+
When the work is merged into the trunk, remove the checkout (`worktree_delete`) —
|
|
19
|
+
the branch is kept, so the merge comes first.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## ODD worktrees
|
|
2
|
+
|
|
3
|
+
Each ODD feature has its own worktree.
|
|
4
|
+
|
|
5
|
+
Starting a new ODD: create its worktree (`worktree_create`) before writing
|
|
6
|
+
anything.
|
|
7
|
+
|
|
8
|
+
Resuming an ODD: check whether it already has an associated worktree. If it does,
|
|
9
|
+
resume it there; if it does not, create it. ODD work never starts in the principal
|
|
10
|
+
checkout.
|
|
11
|
+
|
|
12
|
+
`worktree_create` places the checkout at `<repo-parent>/<repo-name>-worktrees/<name>`.
|
|
13
|
+
|
|
14
|
+
When the work is merged into the trunk, remove the checkout (`worktree_delete`) —
|
|
15
|
+
the branch is kept, so the merge comes first.
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
// the session gate says the CLI exists, so the prompt never promises a sync
|
|
13
13
|
// that cannot happen.
|
|
14
14
|
|
|
15
|
+
const fs = require('node:fs');
|
|
16
|
+
const path = require('node:path');
|
|
17
|
+
|
|
15
18
|
const { hasCodegraph } = require('./codegraph-session.js');
|
|
16
19
|
|
|
17
20
|
// The heading is the identity of the block, so an already-injected section is
|
|
@@ -19,35 +22,29 @@ const { hasCodegraph } = require('./codegraph-session.js');
|
|
|
19
22
|
// different variant would otherwise be appended.
|
|
20
23
|
const SECTION_MARKER = '## ODD worktrees';
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
// The section text lives in its own Markdown files so it can be read, reviewed
|
|
26
|
+
// and edited as prose: `lib/odd-prompt/odd-worktrees.*.md`. Two variants exist —
|
|
27
|
+
// the CodeGraph sentences are present only when the session gate says the CLI
|
|
28
|
+
// exists, so the prompt never promises a sync that cannot happen. A missing or
|
|
29
|
+
// empty file falls back to the heading alone: the block still injects, never
|
|
30
|
+
// crashes the session, and the idempotency marker still works.
|
|
31
|
+
const PROMPT_DIR = path.join(__dirname, 'odd-prompt');
|
|
32
|
+
const WITH_FILE = path.join(PROMPT_DIR, 'odd-worktrees.with-codegraph.md');
|
|
33
|
+
const WITHOUT_FILE = path.join(PROMPT_DIR, 'odd-worktrees.without-codegraph.md');
|
|
34
|
+
const FALLBACK = `${SECTION_MARKER}\n\nEach ODD feature has its own worktree.`;
|
|
35
|
+
|
|
36
|
+
function readPromptFile(file) {
|
|
37
|
+
try {
|
|
38
|
+
const text = fs.readFileSync(file, 'utf8').trim();
|
|
39
|
+
return text.length > 0 && text.startsWith(SECTION_MARKER) ? text : null;
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const WITH_CODEGRAPH = readPromptFile(WITH_FILE) || FALLBACK;
|
|
46
|
+
const WITHOUT_CODEGRAPH = readPromptFile(WITHOUT_FILE) || FALLBACK;
|
|
38
47
|
|
|
39
|
-
const WITHOUT_CODEGRAPH = [
|
|
40
|
-
'## ODD worktrees',
|
|
41
|
-
'',
|
|
42
|
-
'Each ODD feature has its own worktree. Before starting implementation, check',
|
|
43
|
-
'whether that ODD already has an assigned worktree: if it does, resume it there;',
|
|
44
|
-
'if it does not, create one before starting.',
|
|
45
|
-
'',
|
|
46
|
-
'`worktree_create` places the checkout at `<repo-parent>/<repo-name>-worktrees/<name>`.',
|
|
47
|
-
'',
|
|
48
|
-
'Keep all work for one ODD in its assigned worktree. Do not create a second one',
|
|
49
|
-
'to continue it.',
|
|
50
|
-
].join('\n');
|
|
51
48
|
|
|
52
49
|
// The names a named-agent event may carry. `agent` itself is listed because a
|
|
53
50
|
// plain string there is a named agent too; an object is read through `.name`.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// here words every prompt. The invariant this module owns is that a keyboard
|
|
7
7
|
// delete is ALWAYS a human decision: nothing here reads gentle-shell's YOLO
|
|
8
8
|
// grant, so no permission mode can let a keypress alone remove a checkout.
|
|
9
|
-
// (The grant still waives the `
|
|
9
|
+
// (The grant still waives the `worktree_delete` tool's OWN dialog; that is a
|
|
10
10
|
// different caller and stays untouched.)
|
|
11
11
|
//
|
|
12
12
|
// The disclosure covers exactly what the human cannot see from the warp
|
package/lib/worktree-card.js
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
const WORKTREE_TOOLS = new Set([
|
|
45
45
|
'worktree_create',
|
|
46
46
|
'worktree_list',
|
|
47
|
-
'
|
|
47
|
+
'worktree_delete',
|
|
48
48
|
'worktree_session_open',
|
|
49
49
|
'worktree_warp',
|
|
50
50
|
]);
|
|
@@ -55,7 +55,7 @@ const WORKTREE_TOOLS = new Set([
|
|
|
55
55
|
const GLYPH = {
|
|
56
56
|
worktree_create: '⎇',
|
|
57
57
|
worktree_list: '⎇',
|
|
58
|
-
|
|
58
|
+
worktree_delete: '⎇',
|
|
59
59
|
worktree_session_open: '⎇',
|
|
60
60
|
worktree_warp: '⎇',
|
|
61
61
|
};
|
|
@@ -63,7 +63,7 @@ const GLYPH = {
|
|
|
63
63
|
const TITLE = {
|
|
64
64
|
worktree_create: 'worktree create',
|
|
65
65
|
worktree_list: 'worktree list',
|
|
66
|
-
|
|
66
|
+
worktree_delete: 'worktree delete',
|
|
67
67
|
worktree_session_open: 'worktree session open',
|
|
68
68
|
worktree_warp: 'worktree warp',
|
|
69
69
|
};
|
|
@@ -353,7 +353,7 @@ function summarizeWorktreeResult(toolName, result) {
|
|
|
353
353
|
if (count !== undefined) return `${count} checkout${count === 1 ? '' : 's'}`;
|
|
354
354
|
return firstLine;
|
|
355
355
|
}
|
|
356
|
-
case '
|
|
356
|
+
case 'worktree_delete': {
|
|
357
357
|
const target = baseName(details.path) || oneLine(details.branch, '') || firstLine;
|
|
358
358
|
if (failed) return `error · ${target}`;
|
|
359
359
|
return details.branchKept === false ? `removed ${target}` : `removed ${target} · branch kept`;
|
|
@@ -502,7 +502,7 @@ function formattedDetailRows(toolName, details) {
|
|
|
502
502
|
});
|
|
503
503
|
return rows;
|
|
504
504
|
}
|
|
505
|
-
case '
|
|
505
|
+
case 'worktree_delete': {
|
|
506
506
|
const branch = oneLine(details.branch, '');
|
|
507
507
|
const target = oneLine(details.path, '');
|
|
508
508
|
if (branch.length === 0 && target.length === 0) return [];
|
|
@@ -582,7 +582,7 @@ function compactBodyRows(toolName, result) {
|
|
|
582
582
|
if (count === undefined) return [firstLine];
|
|
583
583
|
return [`listed: ${count} checkout${count === 1 ? '' : 's'}`];
|
|
584
584
|
}
|
|
585
|
-
case '
|
|
585
|
+
case 'worktree_delete': {
|
|
586
586
|
const branch = oneLine(details.branch, '');
|
|
587
587
|
const target = baseName(details.path) || branch;
|
|
588
588
|
if (target.length === 0) return [firstLine];
|
|
@@ -621,7 +621,7 @@ function callSubject(toolName, args) {
|
|
|
621
621
|
return oneLine(params.branch, '');
|
|
622
622
|
case 'worktree_list':
|
|
623
623
|
return params.all === true ? 'all' : '';
|
|
624
|
-
case '
|
|
624
|
+
case 'worktree_delete':
|
|
625
625
|
return oneLine(params.name ?? params.branch ?? params.path, '');
|
|
626
626
|
case 'worktree_session_open':
|
|
627
627
|
return oneLine(params.worktree, '');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
// S6: the checkout removal for `
|
|
2
|
+
// S6: the checkout removal for `worktree_delete` — git, and only git.
|
|
3
3
|
//
|
|
4
4
|
// History worth knowing, because the file keeps its name: this module used to
|
|
5
5
|
// reconcile Herdr workspaces around a close (closing every workspace of the
|
package/lib/worktree-hooks.js
CHANGED
|
@@ -304,12 +304,13 @@ async function isTrackedByGitAsync(runAsync, principalRoot, candidate, timeoutMs
|
|
|
304
304
|
// error / timeout / abort kills it). Never skips installs/codegraph as
|
|
305
305
|
// a speed fix; no extra retries beyond the npm fallback. Fixed argv only.
|
|
306
306
|
//
|
|
307
|
-
// `deferSetup: true` splits the run for
|
|
308
|
-
// steps (unversioned copies, principal links)
|
|
309
|
-
// while the slow half (dependency install,
|
|
310
|
-
// `setup()` — one callable, run once, never
|
|
311
|
-
//
|
|
312
|
-
// phases still run, just after the caller has
|
|
307
|
+
// `deferSetup: true` splits the run for BOTH create fronts (the `worktree_create`
|
|
308
|
+
// tool and the panel): the file-level steps (unversioned copies, principal links)
|
|
309
|
+
// still settle before it returns, while the slow half (dependency install,
|
|
310
|
+
// `codegraph init`) travels back as `setup()` — one callable, run once, never
|
|
311
|
+
// rejecting — so the caller hands the checkout back as soon as it exists.
|
|
312
|
+
// Nothing is skipped: the deferred phases still run, just after the caller has
|
|
313
|
+
// handed control back.
|
|
313
314
|
async function runCreationHooksAsync(opts = {}) {
|
|
314
315
|
const principalRoot = resolvePrincipal(opts);
|
|
315
316
|
const worktreePath = resolveWorktree(opts);
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
|
|
46
46
|
const WORKTREE_MODEL_TOOLS = [
|
|
47
47
|
'worktree_list',
|
|
48
|
-
'
|
|
48
|
+
'worktree_delete',
|
|
49
49
|
'worktree_session_open',
|
|
50
50
|
'worktree_warp',
|
|
51
51
|
];
|
|
@@ -231,7 +231,7 @@ function warpRows(details) {
|
|
|
231
231
|
|
|
232
232
|
const ROW_BUILDERS = {
|
|
233
233
|
worktree_list: listRows,
|
|
234
|
-
|
|
234
|
+
worktree_delete: closeRows,
|
|
235
235
|
worktree_session_open: sessionOpenRows,
|
|
236
236
|
worktree_warp: warpRows,
|
|
237
237
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// S7/S8/S9: the ONE active-session guard for checkout deletion.
|
|
3
3
|
//
|
|
4
|
-
// `
|
|
4
|
+
// `worktree_delete` and the warp panel's Ctrl+D both ask this module before they
|
|
5
5
|
// remove a checkout, so the two surfaces can never disagree about whether a
|
|
6
6
|
// checkout is in use.
|
|
7
7
|
//
|