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,183 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// T1 (S1): the file a `read`/`edit`/`write` call names — a skill or an ODD artifact —
|
|
3
|
+
// as the card identity that call heads with. Pure classification and the two call
|
|
4
|
+
// shapes a file card states: the line range only a read asked for, and the Markdown
|
|
5
|
+
// document an expanded read or write draws.
|
|
6
|
+
//
|
|
7
|
+
// The classification is about path components, never substrings: `skills` and `odd`
|
|
8
|
+
// are folder names, so `lib/skillset/notes.md` and `docs/oddity.md` are ordinary
|
|
9
|
+
// files. Both separators are read, so a Windows path classifies like a POSIX one.
|
|
10
|
+
//
|
|
11
|
+
// The CONVENTION is the folder. Everything below a `skills` folder belongs to that
|
|
12
|
+
// skill — its `SKILL.md`, its references, its scripts — so every one of those files
|
|
13
|
+
// is a skill; everything below an `odd` folder is that ODD's, whatever the file is
|
|
14
|
+
// called and however deep it sits. The file's own name decides nothing.
|
|
15
|
+
|
|
16
|
+
const FILE_CARD_IDENTITY = Object.freeze({ SKILL: 'skill', ODD: 'odd' });
|
|
17
|
+
|
|
18
|
+
// What one file kind contributes to a card heading: the name the heading leads with,
|
|
19
|
+
// the mark that leads it, and the theme role it is painted in. Both identities wear the
|
|
20
|
+
// theme's own `mdHeading` role, so the theme at hand decides the color and no card
|
|
21
|
+
// carries one of its own.
|
|
22
|
+
const SKILL_FILE_CARD = Object.freeze({
|
|
23
|
+
identity: FILE_CARD_IDENTITY.SKILL,
|
|
24
|
+
title: 'skill',
|
|
25
|
+
glyph: '▤',
|
|
26
|
+
titleRole: 'mdHeading',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const ODD_FILE_CARD = Object.freeze({
|
|
30
|
+
identity: FILE_CARD_IDENTITY.ODD,
|
|
31
|
+
title: 'odd',
|
|
32
|
+
// The artifact mark: a document, wide enough that the row budgets count it as the
|
|
33
|
+
// two columns it really occupies.
|
|
34
|
+
glyph: '📑',
|
|
35
|
+
titleRole: 'mdHeading',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const SKILL_FOLDER = 'skills';
|
|
39
|
+
const ODD_FOLDER = 'odd';
|
|
40
|
+
const MARKDOWN_NAME = /\.md$/i;
|
|
41
|
+
|
|
42
|
+
// The three tools a file card claims, and the one source of that claim: this module
|
|
43
|
+
// states which files wear an identity, and a card may only head a call whose path has
|
|
44
|
+
// one. `lib/file-card.js` registers exactly these, and `lib/bash-design.js` asks the
|
|
45
|
+
// same list so the two designs never disagree about who owns a row.
|
|
46
|
+
const FILE_CARD_TOOLS = Object.freeze(['read', 'edit', 'write']);
|
|
47
|
+
|
|
48
|
+
/** The path's components, split on both separators so every platform reads the same path. */
|
|
49
|
+
function pathComponents(path) {
|
|
50
|
+
return path.split(/[\\/]+/u).filter((component) => component.length > 0);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The card a file path wears, or undefined for a file that is neither a skill nor an
|
|
55
|
+
* ODD artifact.
|
|
56
|
+
*
|
|
57
|
+
* Identity is the FOLDER the file sits in, and nothing else: everything below a
|
|
58
|
+
* `skills` folder is that skill — its `SKILL.md`, a reference, a script — and
|
|
59
|
+
* everything below an `odd` folder is that ODD, so `odd/work/a.md` is an ODD artifact
|
|
60
|
+
* like `odd/tasks/a.md`. The file's own name never decides, which is why
|
|
61
|
+
* `docs/SKILL.md` is an ordinary file while `skills/x/references/commands.md` is a
|
|
62
|
+
* skill's.
|
|
63
|
+
*
|
|
64
|
+
* A path can name both, and then the marker closest to the file decides: a reference
|
|
65
|
+
* below `skills/` is a skill even when an `odd/tasks/` folder sits above it, while a
|
|
66
|
+
* file whose closest marker is `odd` is an ODD artifact.
|
|
67
|
+
*/
|
|
68
|
+
function fileCardIdentity(path) {
|
|
69
|
+
if (typeof path !== 'string') return undefined;
|
|
70
|
+
const components = pathComponents(path);
|
|
71
|
+
if (components.length === 0) return undefined;
|
|
72
|
+
// Only the folders decide, and the last one above the file wins; a file whose own
|
|
73
|
+
// name is `odd` or `skills` is not inside one.
|
|
74
|
+
for (let index = components.length - 2; index >= 0; index -= 1) {
|
|
75
|
+
const component = (components[index] ?? '').toLowerCase();
|
|
76
|
+
if (component === SKILL_FOLDER) return SKILL_FILE_CARD;
|
|
77
|
+
if (component === ODD_FOLDER) return ODD_FILE_CARD;
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The file's own name — the last component of the path — for the collapsed heading of
|
|
84
|
+
* a card that names the file rather than the whole path it sits in.
|
|
85
|
+
*
|
|
86
|
+
* It splits on both separators and on nothing else, so a name with spaces stays whole
|
|
87
|
+
* (`odd/my design doc.md` is `my design doc.md`), a trailing separator does not name an
|
|
88
|
+
* empty file, and a Windows path is read exactly like a POSIX one. A path that names no
|
|
89
|
+
* component is the empty string, which callers treat as "nothing to show" rather than
|
|
90
|
+
* inventing a name.
|
|
91
|
+
*/
|
|
92
|
+
function fileCardName(path) {
|
|
93
|
+
if (typeof path !== 'string') return '';
|
|
94
|
+
const components = pathComponents(path);
|
|
95
|
+
return components.at(-1) ?? '';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The path a collapsed SKILL heading names: the components from the skill's own folder —
|
|
100
|
+
* the one right after the `skills` folder that holds it — through the file's name,
|
|
101
|
+
* however deep that is.
|
|
102
|
+
*
|
|
103
|
+
* A skill's folders are its own namespace, so `…/skills/gentle-ai/SKILL.md` is
|
|
104
|
+
* `gentle-ai/SKILL.md` and `…/skills/gentle-ai/references/deep/x.md` is
|
|
105
|
+
* `gentle-ai/references/deep/x.md`: the folders above `skills` are what a reader of the
|
|
106
|
+
* workspace already knows. Components are joined on `/` so a POSIX and a Windows path
|
|
107
|
+
* read alike. The marker is the LAST `skills` folder, which is the one the identity
|
|
108
|
+
* itself comes from, and a path with no such folder (or nothing after it) falls back to
|
|
109
|
+
* the file's own name — exactly what the collapsed heading named before.
|
|
110
|
+
*/
|
|
111
|
+
function fileCardSkillPath(path) {
|
|
112
|
+
if (typeof path !== 'string') return '';
|
|
113
|
+
const components = pathComponents(path);
|
|
114
|
+
for (let index = components.length - 1; index >= 0; index -= 1) {
|
|
115
|
+
if ((components[index] ?? '').toLowerCase() !== SKILL_FOLDER) continue;
|
|
116
|
+
const named = components.slice(index + 1);
|
|
117
|
+
return named.length > 0 ? named.join('/') : fileCardName(path);
|
|
118
|
+
}
|
|
119
|
+
return fileCardName(path);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Whether the path names a Markdown document, which is the only shape a card renders as Markdown. */
|
|
123
|
+
function isMarkdownFile(path) {
|
|
124
|
+
if (typeof path !== 'string') return false;
|
|
125
|
+
const name = pathComponents(path).at(-1) ?? '';
|
|
126
|
+
return MARKDOWN_NAME.test(name);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The file line range a card names after the path, as `:start-end`. Only a read states
|
|
131
|
+
* one, because only a read asks for one: a write or an edit knows how many lines it
|
|
132
|
+
* writes, never where in the file those lines land, so it names no range at all — the
|
|
133
|
+
* real range of an edit is the diff its result carries. Nothing is invented for a call
|
|
134
|
+
* that states no range, and a malformed one states nothing either.
|
|
135
|
+
*/
|
|
136
|
+
function fileCardLineRange(tool, args) {
|
|
137
|
+
if (tool !== 'read' || args === undefined || args === null) return undefined;
|
|
138
|
+
if (args.offset === undefined && args.limit === undefined) return undefined;
|
|
139
|
+
// A range the call states in a shape the card cannot read is not guessed at: half a
|
|
140
|
+
// range would name lines the call never asked for.
|
|
141
|
+
if (args.offset !== undefined && !Number.isInteger(args.offset)) return undefined;
|
|
142
|
+
if (args.limit !== undefined && !Number.isInteger(args.limit)) return undefined;
|
|
143
|
+
const start = typeof args.offset === 'number' ? args.offset : 1;
|
|
144
|
+
const limit = typeof args.limit === 'number' ? args.limit : undefined;
|
|
145
|
+
if (start < 1) return undefined;
|
|
146
|
+
if (limit !== undefined && limit < 1) return undefined;
|
|
147
|
+
return limit === undefined ? `:${start}` : `:${start}-${start + limit - 1}`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The Markdown document a call draws instead of its result rows, or undefined when the
|
|
152
|
+
* call draws rows.
|
|
153
|
+
*
|
|
154
|
+
* Markdown is the shape a document is written in, not a property of where it lives: an
|
|
155
|
+
* expanded read of any `.md` file, and an expanded write to one, render as a document
|
|
156
|
+
* whatever folder holds them. Everything else keeps its rows — a collapsed card,
|
|
157
|
+
* because the preview is the first rows of the file; a failed call, because its rows
|
|
158
|
+
* are the error; an edit, because its rows are the diff; and every non-Markdown file.
|
|
159
|
+
* A write draws the content it wrote, which the call carries and the result does not
|
|
160
|
+
* echo.
|
|
161
|
+
*/
|
|
162
|
+
function markdownDocumentSource(tool, args, resultText, options) {
|
|
163
|
+
const settings = options !== null && typeof options === 'object' ? options : {};
|
|
164
|
+
if (settings.expanded !== true || settings.isError === true) return undefined;
|
|
165
|
+
if (tool !== 'read' && tool !== 'write') return undefined;
|
|
166
|
+
const call = args !== null && typeof args === 'object' ? args : undefined;
|
|
167
|
+
if (!isMarkdownFile(call?.path)) return undefined;
|
|
168
|
+
const source = tool === 'write' ? call?.content : resultText;
|
|
169
|
+
return typeof source === 'string' && source.trim().length > 0 ? source : undefined;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
module.exports = {
|
|
173
|
+
FILE_CARD_IDENTITY,
|
|
174
|
+
FILE_CARD_TOOLS,
|
|
175
|
+
SKILL_FILE_CARD,
|
|
176
|
+
ODD_FILE_CARD,
|
|
177
|
+
fileCardIdentity,
|
|
178
|
+
fileCardName,
|
|
179
|
+
fileCardSkillPath,
|
|
180
|
+
isMarkdownFile,
|
|
181
|
+
fileCardLineRange,
|
|
182
|
+
markdownDocumentSource,
|
|
183
|
+
};
|
package/lib/tui-paint.js
CHANGED
|
@@ -39,11 +39,10 @@
|
|
|
39
39
|
// - `dim` stays what that table calls `META`/`KEY_TEXT`/`EMPTY`: small
|
|
40
40
|
// metadata, key descriptions and placeholders — which is also our `label`.
|
|
41
41
|
//
|
|
42
|
-
// Rejected earlier candidates:
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
// heading role) is not a UI title role either.
|
|
42
|
+
// Rejected earlier candidates: a `dim` title (a grey heading reads as metadata,
|
|
43
|
+
// not as the panel's name, and the reader explicitly called a grey title wrong),
|
|
44
|
+
// and `mdHeading`, which is a Markdown document heading role and therefore not a
|
|
45
|
+
// UI title role at all.
|
|
47
46
|
|
|
48
47
|
// The role per token kind. `key` and `title` are painted AND emphasized;
|
|
49
48
|
// `description`, `count` and `label` are colour-only, which is exactly what
|