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
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// The setup chain of `worktree_create` (S20, S21, S24): the closed command table the
|
|
3
|
+
// lockfiles select, the frozen-flag rule, the skip reasons, and the two sentences the
|
|
4
|
+
// completion notice is built from. Nothing here runs a package manager: the directory
|
|
5
|
+
// listing and the PATH probe are injected seams.
|
|
6
|
+
//
|
|
7
|
+
// S1/S3: there is no persisted setup state, so there is no state machine, no job label
|
|
8
|
+
// and no record write to test here — the task that runs the plan owns those outcomes
|
|
9
|
+
// and its own suite pins them.
|
|
10
|
+
|
|
11
|
+
const assert = require('node:assert/strict');
|
|
12
|
+
const test = require('node:test');
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
WORKTREE_SETUP_DISABLED_DETAIL,
|
|
16
|
+
WORKTREE_SETUP_NOTICE_TYPE,
|
|
17
|
+
WORKTREE_SETUP_RULES,
|
|
18
|
+
formatJobDuration,
|
|
19
|
+
resolveWorktreeSetupPlan,
|
|
20
|
+
worktreeSetupFailureText,
|
|
21
|
+
worktreeSetupReadyText,
|
|
22
|
+
worktreeSetupRuleFor,
|
|
23
|
+
} = require('../lib/worktree-setup.js');
|
|
24
|
+
|
|
25
|
+
// ---- S21: the command table ----
|
|
26
|
+
|
|
27
|
+
function rootSeam(entries, binaries = []) {
|
|
28
|
+
const asked = [];
|
|
29
|
+
const roots = [];
|
|
30
|
+
return {
|
|
31
|
+
asked,
|
|
32
|
+
roots,
|
|
33
|
+
seam: {
|
|
34
|
+
async entries(root) {
|
|
35
|
+
roots.push(root);
|
|
36
|
+
return entries;
|
|
37
|
+
},
|
|
38
|
+
async hasBinary(binary) {
|
|
39
|
+
asked.push(binary);
|
|
40
|
+
return binaries.includes(binary);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function planFor(entries, binaries, copiedChanges = 0) {
|
|
47
|
+
const { seam, asked, roots } = rootSeam(entries, binaries);
|
|
48
|
+
return { promise: resolveWorktreeSetupPlan({ root: '/work/demo-worktrees/alpha', copiedChanges, seam }), asked, roots };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
test('S21: every entry of the table names its lockfiles, its binary and its steps', () => {
|
|
52
|
+
assert.ok(WORKTREE_SETUP_RULES.length > 0);
|
|
53
|
+
for (const rule of WORKTREE_SETUP_RULES) {
|
|
54
|
+
assert.ok(Array.isArray(rule.lockfiles) && Array.isArray(rule.binaries) && typeof rule.steps === 'function');
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('S21: pnpm-lock.yaml selects `pnpm install` and is the first match', async () => {
|
|
59
|
+
const { promise, asked, roots } = planFor(['pnpm-lock.yaml', 'package-lock.json'], ['pnpm', 'npm']);
|
|
60
|
+
const plan = await promise;
|
|
61
|
+
assert.deepEqual(plan, { steps: ['pnpm install'] });
|
|
62
|
+
assert.deepEqual(asked, ['pnpm'], 'the first matching entry decides, and only its binary is probed');
|
|
63
|
+
assert.deepEqual(roots, ['/work/demo-worktrees/alpha']);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('S21: requirements.txt creates a virtual environment before installing into it', async () => {
|
|
67
|
+
const plan = await planFor(['requirements.txt'], ['python3']).promise;
|
|
68
|
+
assert.deepEqual(plan.steps, ['python3 -m venv .venv', '.venv/bin/python -m pip install -r requirements.txt']);
|
|
69
|
+
const windows = await resolveWorktreeSetupPlan({
|
|
70
|
+
root: '/x',
|
|
71
|
+
copiedChanges: 0,
|
|
72
|
+
platform: 'win32',
|
|
73
|
+
seam: rootSeam(['requirements.txt'], ['python3']).seam,
|
|
74
|
+
});
|
|
75
|
+
assert.deepEqual(windows.steps, ['python3 -m venv .venv', '.venv/Scripts/python -m pip install -r requirements.txt']);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('S21: the table order decides the first match, never the host’s preference', async () => {
|
|
79
|
+
const plan = await planFor(['yarn.lock', 'package-lock.json'], ['yarn', 'npm']).promise;
|
|
80
|
+
assert.deepEqual(plan.steps, ['yarn install --immutable']);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('S21: a frozen flag is used only when copy_changes copied nothing', async () => {
|
|
84
|
+
assert.deepEqual((await planFor(['package-lock.json'], ['npm'], 0).promise).steps, ['npm ci']);
|
|
85
|
+
assert.deepEqual((await planFor(['package-lock.json'], ['npm'], 2).promise).steps, ['npm install']);
|
|
86
|
+
assert.deepEqual((await planFor(['yarn.lock'], ['yarn'], 0).promise).steps, ['yarn install --immutable']);
|
|
87
|
+
assert.deepEqual((await planFor(['yarn.lock'], ['yarn'], 1).promise).steps, ['yarn install']);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('S21: a .NET project file selects `dotnet restore`', async () => {
|
|
91
|
+
const plan = await planFor(['App.sln'], ['dotnet']).promise;
|
|
92
|
+
assert.deepEqual(plan.steps, ['dotnet restore']);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('S21: no lockfile at the root skips with its own reason', async () => {
|
|
96
|
+
const { promise, asked } = planFor(['README.md'], ['npm']);
|
|
97
|
+
assert.deepEqual(await promise, { steps: [], detail: 'no lockfile at root' });
|
|
98
|
+
assert.deepEqual(asked, [], 'nothing is probed when no entry matched');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('S21: a missing binary skips and never falls back to another package manager', async () => {
|
|
102
|
+
const { promise, asked } = planFor(['pnpm-lock.yaml', 'package-lock.json'], ['npm']);
|
|
103
|
+
assert.deepEqual(await promise, { steps: [], detail: 'pnpm not found' });
|
|
104
|
+
assert.deepEqual(asked, ['pnpm'], 'the second entry is never tried');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('S21: the rule the table exposes is the same one the resolver uses', () => {
|
|
108
|
+
const rule = worktreeSetupRuleFor(['pnpm-lock.yaml']);
|
|
109
|
+
assert.equal(rule, WORKTREE_SETUP_RULES[0]);
|
|
110
|
+
assert.equal(worktreeSetupRuleFor(['nothing']), undefined);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// ---- S24: the sentences and the vocabulary ----
|
|
114
|
+
|
|
115
|
+
test('S20/S24: the constants the notice is built from are the ones the contract names', () => {
|
|
116
|
+
assert.equal(WORKTREE_SETUP_NOTICE_TYPE, 'gentle-worktree.setup');
|
|
117
|
+
assert.equal(WORKTREE_SETUP_DISABLED_DETAIL, 'setup is not enabled for this repository');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('S24: the ready and failure texts are the exact sentences the agent reads', () => {
|
|
121
|
+
assert.equal(
|
|
122
|
+
worktreeSetupReadyText({ name: 'demo', steps: 1, durationMs: 65_000 }),
|
|
123
|
+
'worktree setup ready · demo · 1 step (1m 5s)',
|
|
124
|
+
);
|
|
125
|
+
assert.equal(
|
|
126
|
+
worktreeSetupFailureText({ name: 'demo', command: 'pnpm install', exitCode: 1, logPath: '/tmp/log' }),
|
|
127
|
+
[
|
|
128
|
+
'worktree setup failed · demo · pnpm install exited 1',
|
|
129
|
+
'log: /tmp/log',
|
|
130
|
+
'worktree is not ready yet; re-run setup or inspect the log.',
|
|
131
|
+
].join('\n'),
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('S24: a duration is spelled in seconds, minutes and hours', () => {
|
|
136
|
+
assert.equal(formatJobDuration(0), '0s');
|
|
137
|
+
assert.equal(formatJobDuration(59_400), '59s');
|
|
138
|
+
assert.equal(formatJobDuration(65_000), '1m 5s');
|
|
139
|
+
assert.equal(formatJobDuration(3_723_000), '1h 2m');
|
|
140
|
+
});
|