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
|
@@ -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-git.js
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Every external process is spawned with a fixed argv array — no shell
|
|
5
5
|
// string is ever built, so branch names and paths cannot inject commands.
|
|
6
|
-
// `listWorktrees` parses `git worktree list --porcelain -z` itself
|
|
7
|
-
// of trusting Herdr JSON output.
|
|
6
|
+
// `listWorktrees` parses `git worktree list --porcelain -z` itself.
|
|
8
7
|
|
|
9
8
|
const { spawnSync } = require('node:child_process');
|
|
10
9
|
const fs = require('node:fs');
|
|
@@ -564,193 +563,7 @@ function matchesAnyCheckout(identity, resolved, entries) {
|
|
|
564
563
|
return false;
|
|
565
564
|
}
|
|
566
565
|
|
|
567
|
-
// Closed union of herdr operations with a per-operation flag allowlist,
|
|
568
|
-
// mirroring the installed CLI surface (herdr 0.9.4, verified read-only
|
|
569
|
-
// against `herdr worktree list|create|open --help`, `herdr pane list
|
|
570
|
-
// --help` and `herdr agent start|get|list --help`: every flag below
|
|
571
|
-
// exists there with the shape used here). Every value travels as its own
|
|
572
|
-
// argv element because herdr rejects `--flag=value`. Unknown operations
|
|
573
|
-
// or flags throw. `--trust-repository` is deliberately absent everywhere:
|
|
574
|
-
// trusting a repository is a human decision these tools never take.
|
|
575
|
-
// `--focus` stays opt-in for the worktree create/open calls that predate
|
|
576
|
-
// the session tool; the session tool itself only ever passes `--no-focus`.
|
|
577
|
-
const HERDR_ALLOWLIST = {
|
|
578
|
-
list: ['cwd'],
|
|
579
|
-
create: ['cwd', 'branch', 'base', 'path', 'label', 'focus'],
|
|
580
|
-
open: ['cwd', 'path', 'branch', 'noFocus', 'focus'],
|
|
581
|
-
remove: ['workspace', 'force'],
|
|
582
|
-
'pane-list': ['workspace'],
|
|
583
|
-
'agent-start': ['name', 'kind', 'pane', 'timeout', 'agentArgs'],
|
|
584
|
-
'agent-get': ['target'],
|
|
585
|
-
'agent-list': [],
|
|
586
|
-
};
|
|
587
|
-
|
|
588
|
-
const HERDR_FLAG = {
|
|
589
|
-
cwd: '--cwd',
|
|
590
|
-
workspace: '--workspace',
|
|
591
|
-
branch: '--branch',
|
|
592
|
-
base: '--base',
|
|
593
|
-
path: '--path',
|
|
594
|
-
label: '--label',
|
|
595
|
-
focus: '--focus',
|
|
596
|
-
noFocus: '--no-focus',
|
|
597
|
-
force: '--force',
|
|
598
|
-
kind: '--kind',
|
|
599
|
-
pane: '--pane',
|
|
600
|
-
timeout: '--timeout',
|
|
601
|
-
};
|
|
602
566
|
|
|
603
|
-
// Build the fixed argv for a herdr operation. Worktree operations produce
|
|
604
|
-
// `herdr worktree <op> ...`; the session composition additionally needs
|
|
605
|
-
// `herdr pane list`, `herdr agent start <NAME> ... -- [AGENT_ARG]...`,
|
|
606
|
-
// `herdr agent get <target>` and `herdr agent list`, each with its own
|
|
607
|
-
// fixed shape below so no caller hand-builds herdr argv.
|
|
608
|
-
function herdrArgv(operation, params = {}) {
|
|
609
|
-
const allowed = HERDR_ALLOWLIST[operation];
|
|
610
|
-
if (!allowed) throw new Error(`unknown herdr operation: ${operation}`);
|
|
611
|
-
for (const key of Object.keys(params)) {
|
|
612
|
-
if (!allowed.includes(key)) throw new Error(`flag not allowed for herdr ${operation}: ${key}`);
|
|
613
|
-
}
|
|
614
|
-
// `herdr agent start <NAME> --kind <KIND> --pane <ID> --timeout <MS>
|
|
615
|
-
// -- [AGENT_ARG]...`: the agent name is positional and always first,
|
|
616
|
-
// the Pi argv travels after a `--` separator. Fixed order, values as
|
|
617
|
-
// separate elements, never `--flag=value`.
|
|
618
|
-
if (operation === 'agent-start') {
|
|
619
|
-
const { name, kind, pane, timeout, agentArgs } = params;
|
|
620
|
-
if (typeof name !== 'string' || name === '') throw new Error('invalid value for herdr agent-start name');
|
|
621
|
-
for (const [key, value] of [['kind', kind], ['pane', pane], ['timeout', timeout]]) {
|
|
622
|
-
if (typeof value !== 'string' || value === '') throw new Error(`invalid value for herdr agent-start ${key}`);
|
|
623
|
-
}
|
|
624
|
-
if (!Array.isArray(agentArgs) || agentArgs.some((entry) => typeof entry !== 'string')) {
|
|
625
|
-
throw new Error('invalid value for herdr agent-start agentArgs');
|
|
626
|
-
}
|
|
627
|
-
return ['agent', 'start', name,
|
|
628
|
-
'--kind', kind, '--pane', pane, '--timeout', timeout,
|
|
629
|
-
'--', ...agentArgs];
|
|
630
|
-
}
|
|
631
|
-
// `herdr agent get <target>`: the target is positional.
|
|
632
|
-
if (operation === 'agent-get') {
|
|
633
|
-
const { target } = params;
|
|
634
|
-
if (typeof target !== 'string' || target === '') throw new Error('invalid value for herdr agent-get target');
|
|
635
|
-
return ['agent', 'get', target];
|
|
636
|
-
}
|
|
637
|
-
// `herdr agent list` takes no flags.
|
|
638
|
-
if (operation === 'agent-list') return ['agent', 'list'];
|
|
639
|
-
// `herdr pane list [--workspace <ID>]`.
|
|
640
|
-
if (operation === 'pane-list') {
|
|
641
|
-
const argv = ['pane', 'list'];
|
|
642
|
-
if (params.workspace !== undefined) {
|
|
643
|
-
if (typeof params.workspace !== 'string' || params.workspace === '') {
|
|
644
|
-
throw new Error('invalid value for herdr pane-list workspace');
|
|
645
|
-
}
|
|
646
|
-
argv.push('--workspace', params.workspace);
|
|
647
|
-
}
|
|
648
|
-
return argv;
|
|
649
|
-
}
|
|
650
|
-
const argv = ['worktree', operation];
|
|
651
|
-
for (const key of Object.keys(params)) {
|
|
652
|
-
if (!allowed.includes(key)) throw new Error(`flag not allowed for herdr ${operation}: ${key}`);
|
|
653
|
-
const value = params[key];
|
|
654
|
-
if (typeof value === 'boolean') {
|
|
655
|
-
if (value) argv.push(HERDR_FLAG[key]);
|
|
656
|
-
continue;
|
|
657
|
-
}
|
|
658
|
-
if (typeof value !== 'string' || value === '') throw new Error(`invalid value for herdr ${operation} ${key}`);
|
|
659
|
-
argv.push(HERDR_FLAG[key], value);
|
|
660
|
-
}
|
|
661
|
-
return argv;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
// Where the herdr binary comes from. Production honors the documented
|
|
665
|
-
// HERDR_BIN_PATH override (tests), else `herdr` on PATH — the same
|
|
666
|
-
// convention lib/gentle-diagnostics.js uses. Production (no harness
|
|
667
|
-
// marker) keeps that historical behavior untouched.
|
|
668
|
-
//
|
|
669
|
-
// The test harness (GENTLE_WORKTREE_LIB_DIR, set only by the test loaders
|
|
670
|
-
// that import the extension copy) is resolved FIRST, before the override is
|
|
671
|
-
// trusted: an exported HERDR_BIN_PATH is inherited by every test process, so
|
|
672
|
-
// honoring it first let a test run spawn the developer's LIVE herdr and
|
|
673
|
-
// create real Herdr workspaces. Under the harness, therefore:
|
|
674
|
-
//
|
|
675
|
-
// - no binary at all still fails closed with the same refusal as before;
|
|
676
|
-
// - a binary is honored only when the path itself proves it cannot be the
|
|
677
|
-
// live one (`isProvablyNotLiveHerdr`, which decides from the filesystem and
|
|
678
|
-
// never executes anything);
|
|
679
|
-
// - a possible live herdr is refused unless the CURRENT test opts in with the
|
|
680
|
-
// dedicated flag below. The flag is the test's own declaration, so it must
|
|
681
|
-
// be set deliberately rather than inherited along with the path.
|
|
682
|
-
const LIVE_HERDR_OPT_IN = 'GENTLE_WORKTREE_ALLOW_LIVE_HERDR';
|
|
683
|
-
|
|
684
|
-
function realPathOrNull(target) {
|
|
685
|
-
try {
|
|
686
|
-
return fs.realpathSync(target);
|
|
687
|
-
} catch {
|
|
688
|
-
return null;
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
function isInsideDir(candidate, dir) {
|
|
693
|
-
if (candidate === dir) return true;
|
|
694
|
-
return candidate.startsWith(dir.endsWith(path.sep) ? dir : dir + path.sep);
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
// The scratch locations this repository's tests build their stub binaries in.
|
|
698
|
-
// os.tmpdir() is the convention every fixture follows (`fs.mkdtempSync(
|
|
699
|
-
// path.join(os.tmpdir(), ...))`), and no live Herdr install lives there.
|
|
700
|
-
function testScratchRoots() {
|
|
701
|
-
const roots = [];
|
|
702
|
-
for (const candidate of [os.tmpdir(), path.resolve(os.tmpdir())]) {
|
|
703
|
-
const real = realPathOrNull(candidate) || candidate;
|
|
704
|
-
if (!roots.includes(real)) roots.push(real);
|
|
705
|
-
}
|
|
706
|
-
return roots;
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
// Can this path be PROVEN not to be a live herdr? Only filesystem facts are
|
|
710
|
-
// used — the binary is never executed and nothing is spawned, so the answer
|
|
711
|
-
// costs one realpath plus one stat and cannot reach a Herdr session.
|
|
712
|
-
//
|
|
713
|
-
// Proven not live: an absolute path that does not exist (a spawn of it fails),
|
|
714
|
-
// that is not a regular file, that is not executable (a spawn of it fails),
|
|
715
|
-
// or whose realpath is inside the test scratch directory. Everything else —
|
|
716
|
-
// a relative or bare value (PATH/cwd resolved) and an existing executable
|
|
717
|
-
// outside scratch — could be the live binary and is left unproven.
|
|
718
|
-
function isProvablyNotLiveHerdr(bin) {
|
|
719
|
-
if (typeof bin !== 'string' || !path.isAbsolute(bin)) return false;
|
|
720
|
-
const real = realPathOrNull(bin);
|
|
721
|
-
if (real === null) return true;
|
|
722
|
-
let stat;
|
|
723
|
-
try {
|
|
724
|
-
stat = fs.statSync(real);
|
|
725
|
-
} catch {
|
|
726
|
-
return true;
|
|
727
|
-
}
|
|
728
|
-
if (!stat.isFile()) return true;
|
|
729
|
-
try {
|
|
730
|
-
fs.accessSync(real, fs.constants.X_OK);
|
|
731
|
-
} catch {
|
|
732
|
-
return true;
|
|
733
|
-
}
|
|
734
|
-
return testScratchRoots().some((root) => isInsideDir(real, root));
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
function resolveHerdrBinary(env = {}) {
|
|
738
|
-
const source = env || {};
|
|
739
|
-
const bin = source.HERDR_BIN_PATH;
|
|
740
|
-
const injected = typeof bin === 'string' && bin.length > 0;
|
|
741
|
-
const harness = source.GENTLE_WORKTREE_LIB_DIR;
|
|
742
|
-
const inHarness = typeof harness === 'string' && harness.length > 0;
|
|
743
|
-
if (!inHarness) return injected ? bin : 'herdr';
|
|
744
|
-
if (source[LIVE_HERDR_OPT_IN] === '1') return injected ? bin : 'herdr';
|
|
745
|
-
if (!injected) {
|
|
746
|
-
throw new Error('herdr binary is not injected: set HERDR_BIN_PATH in tests (refusing to run live herdr)');
|
|
747
|
-
}
|
|
748
|
-
if (isProvablyNotLiveHerdr(bin)) return bin;
|
|
749
|
-
throw new Error(
|
|
750
|
-
`refusing to run live herdr from a test harness: HERDR_BIN_PATH=${bin} can execute a live herdr; `
|
|
751
|
-
+ `inject a scratch stub inside the OS temp directory, or set ${LIVE_HERDR_OPT_IN}=1 in the test that needs a live session`,
|
|
752
|
-
);
|
|
753
|
-
}
|
|
754
567
|
|
|
755
568
|
// ---------------------------------------------------------------------
|
|
756
569
|
// Commits ahead of / behind a base branch (warp-popup W1).
|
|
@@ -1043,6 +856,4 @@ module.exports = {
|
|
|
1043
856
|
listWorktreesAsync,
|
|
1044
857
|
isPathInAnyCheckout,
|
|
1045
858
|
isPathInAnyCheckoutAsync,
|
|
1046
|
-
herdrArgv,
|
|
1047
|
-
resolveHerdrBinary,
|
|
1048
859
|
};
|
package/lib/worktree-hooks.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// (b) dependency install by lockfile-detected stack,
|
|
9
9
|
// (c) `codegraph init` when the CLI is available.
|
|
10
10
|
//
|
|
11
|
-
// Both `worktree_upsert` (sync runner) and the
|
|
11
|
+
// Both `worktree_upsert` (sync runner) and the panel create path (async
|
|
12
12
|
// twin) reach these hooks, so the link policy is applied by ONE shared
|
|
13
13
|
// implementation in `lib/worktree-symlinks.js` and both creation routes
|
|
14
14
|
// behave identically.
|
|
@@ -394,7 +394,7 @@ async function runCreationHooksAsync(opts = {}) {
|
|
|
394
394
|
|
|
395
395
|
// (a2) Link git-ignored principal entries: the async twin of the sync
|
|
396
396
|
// step, sharing the one classifier in lib/worktree-symlinks.js so the tool
|
|
397
|
-
// path and the
|
|
397
|
+
// path and the panel create path cannot disagree. The git reads and the
|
|
398
398
|
// link writes are awaited, so the event loop keeps running.
|
|
399
399
|
//
|
|
400
400
|
// Policy (round-3 S3/L4): `.agents`, `.pi`, `.claude` and `odd` become
|
|
@@ -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
|
//
|
|
@@ -362,6 +362,14 @@ async function readGentlePresence(options = {}) {
|
|
|
362
362
|
incarnation: header.incarnation,
|
|
363
363
|
label: header.label,
|
|
364
364
|
heartbeat: header.heartbeat,
|
|
365
|
+
// Published task counters, validated above and passed through
|
|
366
|
+
// unchanged: the warp guard reads this session's own workload.
|
|
367
|
+
counts: {
|
|
368
|
+
running: header.counts.running,
|
|
369
|
+
queued: header.counts.queued,
|
|
370
|
+
waiting: header.counts.waiting,
|
|
371
|
+
finished: header.counts.finished,
|
|
372
|
+
},
|
|
365
373
|
recent: now >= header.heartbeat && now - header.heartbeat <= PRESENCE_FRESH_MS,
|
|
366
374
|
workspace,
|
|
367
375
|
unknown: workspace === null,
|