pi-odd-worktree 2.0.0 → 3.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 +54 -311
- package/extensions/odd-worktree-tools.ts +4149 -2447
- package/lib/bash-activity.js +1164 -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 +1416 -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 +308 -14
- 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 -711
- 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 +1419 -0
- package/tools/bash-design.test.js +1091 -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 +610 -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 +1871 -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 +391 -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 +1512 -66
- package/tools/issues-open-guard.test.js +1096 -0
- package/tools/issues-section.test.js +4195 -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 +2569 -308
- 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 +477 -93
- 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,188 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// T3 (S3/S5): the file card's document body — Pi's own Markdown renderer, and the theme
|
|
3
|
+
// table that gives every Markdown element a theme ROLE.
|
|
4
|
+
//
|
|
5
|
+
// Every case goes through the module's public surface only: the theme table it builds,
|
|
6
|
+
// and the rows it asks a renderer for. Nothing here reads a module internal, a
|
|
7
|
+
// repository or a terminal. The renderer is the host's; the cases that need the real one
|
|
8
|
+
// are skipped when this machine has no `@earendil-works/pi-tui` (CI installs none), and
|
|
9
|
+
// the rest drive an injected stand-in, so the table itself is always verified.
|
|
10
|
+
const assert = require('node:assert/strict');
|
|
11
|
+
const { readFileSync } = require('node:fs');
|
|
12
|
+
const { join } = require('node:path');
|
|
13
|
+
const { test } = require('node:test');
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
MARKDOWN_ATTRIBUTES,
|
|
17
|
+
MARKDOWN_ROLES,
|
|
18
|
+
fileCardMarkdownTheme,
|
|
19
|
+
loadMarkdownClass,
|
|
20
|
+
markdownRows,
|
|
21
|
+
} = require('../lib/file-card-markdown.js');
|
|
22
|
+
|
|
23
|
+
// The roles the host's own theme tokens declare for Markdown (`theme-tokens.ts:67-76`).
|
|
24
|
+
const HOST_ROLES = {
|
|
25
|
+
heading: 'mdHeading',
|
|
26
|
+
link: 'mdLink',
|
|
27
|
+
linkUrl: 'mdLinkUrl',
|
|
28
|
+
code: 'mdCode',
|
|
29
|
+
codeBlock: 'mdCodeBlock',
|
|
30
|
+
codeBlockBorder: 'mdCodeBlockBorder',
|
|
31
|
+
quote: 'mdQuote',
|
|
32
|
+
quoteBorder: 'mdQuoteBorder',
|
|
33
|
+
hr: 'mdHr',
|
|
34
|
+
listBullet: 'mdListBullet',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** A theme that records every role it was asked for and paints nothing. */
|
|
38
|
+
function recordingTheme() {
|
|
39
|
+
const asked = [];
|
|
40
|
+
return {
|
|
41
|
+
asked,
|
|
42
|
+
fg(role, text) {
|
|
43
|
+
asked.push(role);
|
|
44
|
+
return text;
|
|
45
|
+
},
|
|
46
|
+
bold: (text) => text,
|
|
47
|
+
italic: (text) => text,
|
|
48
|
+
underline: (text) => text,
|
|
49
|
+
strikethrough: (text) => text,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
test('the table maps every Markdown element to the host role the spec names (S3)', () => {
|
|
54
|
+
assert.deepEqual({ ...MARKDOWN_ROLES }, HOST_ROLES, 'the role table is the spec\'s, element for element');
|
|
55
|
+
const theme = recordingTheme();
|
|
56
|
+
const table = fileCardMarkdownTheme(theme);
|
|
57
|
+
for (const [element, role] of Object.entries(HOST_ROLES)) {
|
|
58
|
+
table[element]('x');
|
|
59
|
+
assert.equal(theme.asked.at(-1), role, `${element} paints ${role}`);
|
|
60
|
+
}
|
|
61
|
+
// `mdListBullet`, never `mdBullet`: the host names no such role.
|
|
62
|
+
assert.equal(Object.values(MARKDOWN_ROLES).includes('mdBullet'), false);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('the text attributes come from the theme\'s own handlers, when it has them', () => {
|
|
66
|
+
assert.deepEqual([...MARKDOWN_ATTRIBUTES].sort(), ['bold', 'italic', 'strikethrough', 'underline']);
|
|
67
|
+
const calls = [];
|
|
68
|
+
const theme = {
|
|
69
|
+
fg: (_role, text) => text,
|
|
70
|
+
bold: (text) => { calls.push(['bold', text]); return `<b>${text}</b>`; },
|
|
71
|
+
italic: (text) => { calls.push(['italic', text]); return `<i>${text}</i>`; },
|
|
72
|
+
underline: (text) => { calls.push(['underline', text]); return `<u>${text}</u>`; },
|
|
73
|
+
strikethrough: (text) => { calls.push(['strikethrough', text]); return `<s>${text}</s>`; },
|
|
74
|
+
};
|
|
75
|
+
const table = fileCardMarkdownTheme(theme);
|
|
76
|
+
assert.equal(table.bold('x'), '<b>x</b>');
|
|
77
|
+
assert.equal(table.italic('x'), '<i>x</i>');
|
|
78
|
+
assert.equal(table.underline('x'), '<u>x</u>');
|
|
79
|
+
assert.equal(table.strikethrough('x'), '<s>x</s>');
|
|
80
|
+
assert.deepEqual(calls.map(([name]) => name), ['bold', 'italic', 'underline', 'strikethrough']);
|
|
81
|
+
|
|
82
|
+
// A theme that carries none, or one that throws: the text survives untouched rather
|
|
83
|
+
// than the document losing a word.
|
|
84
|
+
for (const missing of [undefined, null, {}, { bold: 42 }, { bold: () => { throw new Error('boom'); } }, { bold: () => 42 }]) {
|
|
85
|
+
const bare = fileCardMarkdownTheme(missing);
|
|
86
|
+
assert.equal(bare.bold('kept'), 'kept', String(missing));
|
|
87
|
+
assert.equal(bare.italic('kept'), 'kept');
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('a role the theme cannot paint leaves the text as it was', () => {
|
|
92
|
+
for (const theme of [undefined, null, {}, { fg: () => { throw new Error('boom'); } }, { fg: () => 42 }, { fg: 'not a function' }]) {
|
|
93
|
+
const table = fileCardMarkdownTheme(theme);
|
|
94
|
+
for (const element of Object.keys(HOST_ROLES)) assert.equal(table[element]('kept'), 'kept', `${element} with ${String(theme)}`);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('the rows come from the renderer the caller names, and the theme table with them', () => {
|
|
99
|
+
const seen = [];
|
|
100
|
+
class FakeMarkdown {
|
|
101
|
+
constructor(source, paddingX, paddingY, theme) {
|
|
102
|
+
seen.push({ source, paddingX, paddingY, theme });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
render(width) {
|
|
106
|
+
seen.push({ width });
|
|
107
|
+
return ['one', 'two'];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
invalidate() {}
|
|
111
|
+
}
|
|
112
|
+
const theme = recordingTheme();
|
|
113
|
+
const rows = markdownRows('# A', theme, 33, FakeMarkdown);
|
|
114
|
+
assert.deepEqual(rows, ['one', 'two']);
|
|
115
|
+
assert.equal(seen[0].source, '# A');
|
|
116
|
+
assert.equal(seen[0].paddingX, 0, 'the card owns the frame, so the renderer is unpadded');
|
|
117
|
+
assert.equal(seen[0].paddingY, 0);
|
|
118
|
+
assert.equal(seen[1].width, 33, 'the renderer is asked for the width the body has');
|
|
119
|
+
seen[0].theme.heading('x');
|
|
120
|
+
assert.equal(theme.asked.at(-1), 'mdHeading', 'the table handed over is this module\'s');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('a document that cannot be drawn answers no rows, so the caller keeps its plain source', () => {
|
|
124
|
+
const rowsOf = (markdownClass, extra) => markdownRows(extra?.source ?? '# A', {}, 40, markdownClass);
|
|
125
|
+
assert.deepEqual(rowsOf(null), [], 'a host that has none');
|
|
126
|
+
assert.deepEqual(rowsOf(() => { throw new Error('constructor exploded'); }), [], 'a renderer that throws before returning a component');
|
|
127
|
+
assert.deepEqual(rowsOf(class { render() { throw new Error('render exploded'); } }), [], 'a renderer that throws while drawing');
|
|
128
|
+
assert.deepEqual(rowsOf(class { render() { return []; } }), [], 'a renderer that draws nothing');
|
|
129
|
+
assert.deepEqual(rowsOf(class { render() { return ['', ' ']; } }), [], 'a renderer that draws only blanks');
|
|
130
|
+
assert.deepEqual(rowsOf(class { render() { return 'not rows'; } }), [], 'a renderer that answers a shape this cannot read');
|
|
131
|
+
assert.deepEqual(rowsOf(class { render() { return ['ok']; } }, { source: ' ' }), [], 'a blank source draws nothing');
|
|
132
|
+
assert.deepEqual(markdownRows('# A', {}, 0, class { render() { return ['ok']; } }), [], 'no width, no body');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('the host package is resolved lazily, so a host without it costs no import', () => {
|
|
136
|
+
// Reading the module never loads the package; only asking for the class does.
|
|
137
|
+
const source = readFileSync(join(__dirname, '..', 'lib', 'file-card-markdown.js'), 'utf8');
|
|
138
|
+
const requires = source.match(/require\('([^']+)'\)/gu) ?? [];
|
|
139
|
+
assert.deepEqual(requires, ["require('@earendil-works/pi-tui')"], 'the one require is the host package, inside the function');
|
|
140
|
+
// Whatever this machine has, the answer is a function or undefined — never a throw.
|
|
141
|
+
const Markdown = loadMarkdownClass();
|
|
142
|
+
assert.equal(Markdown === undefined || typeof Markdown === 'function', true, String(typeof Markdown));
|
|
143
|
+
assert.equal(loadMarkdownClass(), Markdown, 'the answer is settled once per process');
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test('the real renderer paints every element with the role the table gave it (S3)', (t) => {
|
|
147
|
+
const Markdown = loadMarkdownClass();
|
|
148
|
+
if (Markdown === undefined) {
|
|
149
|
+
t.skip('requires @earendil-works/pi-tui');
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const asked = [];
|
|
153
|
+
const theme = {
|
|
154
|
+
fg(role, text) {
|
|
155
|
+
asked.push(role);
|
|
156
|
+
return `[${role}]${text}[/]`;
|
|
157
|
+
},
|
|
158
|
+
bold: (text) => text,
|
|
159
|
+
italic: (text) => text,
|
|
160
|
+
underline: (text) => text,
|
|
161
|
+
strikethrough: (text) => text,
|
|
162
|
+
};
|
|
163
|
+
const source = [
|
|
164
|
+
'# Design',
|
|
165
|
+
'',
|
|
166
|
+
'- one',
|
|
167
|
+
'',
|
|
168
|
+
'Some `code` here',
|
|
169
|
+
'',
|
|
170
|
+
'```',
|
|
171
|
+
'const a = 1;',
|
|
172
|
+
'```',
|
|
173
|
+
'',
|
|
174
|
+
'> quoted',
|
|
175
|
+
'',
|
|
176
|
+
'---',
|
|
177
|
+
].join('\n');
|
|
178
|
+
const rows = markdownRows(source, theme, 40, Markdown);
|
|
179
|
+
assert.ok(rows.length > 0, 'the document drew rows');
|
|
180
|
+
const body = rows.join('\n');
|
|
181
|
+
for (const role of ['mdHeading', 'mdListBullet', 'mdCode', 'mdCodeBlock', 'mdCodeBlockBorder', 'mdQuote', 'mdQuoteBorder', 'mdHr']) {
|
|
182
|
+
assert.equal(asked.includes(role), true, `${role} was asked for`);
|
|
183
|
+
assert.equal(body.includes(`[${role}]`), true, `${role} paints its cells`);
|
|
184
|
+
}
|
|
185
|
+
// Headings, quotes and rules are DRAWN, not typed: the source's own markers are gone.
|
|
186
|
+
assert.doesNotMatch(body, /^# Design$/mu);
|
|
187
|
+
assert.doesNotMatch(body, /^> quoted$/mu);
|
|
188
|
+
});
|