pi-odd-worktree 2.1.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 -319
- package/extensions/odd-worktree-tools.ts +4145 -2529
- 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 -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 +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 +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,254 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// S10 preview: the collapsed CodeGraph card only states facts the program
|
|
3
|
+
// printed. Every case goes through lib/codegraph-card-preview.js and its
|
|
4
|
+
// injected-free surface (the module is pure: no Pi, no theme, no disk), and the
|
|
5
|
+
// inputs are the recorded output shapes in tools/fixtures/card-codegraph-outputs.js
|
|
6
|
+
// or the command strings a `bash` call carries.
|
|
7
|
+
const assert = require('node:assert/strict');
|
|
8
|
+
const { test } = require('node:test');
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
CODEGRAPH_MARK,
|
|
12
|
+
CODEGRAPH_TITLE_ROLE,
|
|
13
|
+
CODEGRAPH_TOOL,
|
|
14
|
+
codeGraphCollapsedRows,
|
|
15
|
+
codeGraphInitOutcome,
|
|
16
|
+
codeGraphPreview,
|
|
17
|
+
codeGraphResultSummary,
|
|
18
|
+
codeGraphSyncOutcome,
|
|
19
|
+
codegraphCallDetail,
|
|
20
|
+
codegraphCallFromCommand,
|
|
21
|
+
projectPathSegment,
|
|
22
|
+
cardText,
|
|
23
|
+
} = require('../lib/codegraph-card-preview.js');
|
|
24
|
+
const {
|
|
25
|
+
EXPLORE,
|
|
26
|
+
EXPLORE_PINNED,
|
|
27
|
+
INIT_EXISTING,
|
|
28
|
+
INIT_FACTS,
|
|
29
|
+
INIT_FAILED,
|
|
30
|
+
INIT_FRESH,
|
|
31
|
+
QUERY,
|
|
32
|
+
QUERY_EMPTY,
|
|
33
|
+
SYNC_CHANGED,
|
|
34
|
+
SYNC_NO_FILES,
|
|
35
|
+
SYNC_UP_TO_DATE,
|
|
36
|
+
} = require('./fixtures/card-codegraph-outputs.js');
|
|
37
|
+
|
|
38
|
+
test('the identity is the tool name, its own mark and the theme role its card wears', () => {
|
|
39
|
+
assert.equal(CODEGRAPH_TOOL, 'codegraph');
|
|
40
|
+
assert.equal(CODEGRAPH_MARK, '\u{F01BC}', 'the database glyph is the tool\'s own icon');
|
|
41
|
+
assert.equal(CODEGRAPH_TITLE_ROLE, 'mdCode', 'the title role is the shell theme\'s own slot, never a colour');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('an init card collapses to the one sentence the tool printed', () => {
|
|
45
|
+
assert.equal(codeGraphInitOutcome(INIT_FRESH), 'initialized');
|
|
46
|
+
assert.equal(codeGraphInitOutcome(INIT_EXISTING), 'already initialized');
|
|
47
|
+
// No concluding sentence is no outcome: the card keeps the rows it has.
|
|
48
|
+
assert.equal(codeGraphInitOutcome(INIT_FACTS), undefined);
|
|
49
|
+
assert.equal(codeGraphInitOutcome(INIT_FAILED), undefined);
|
|
50
|
+
assert.deepEqual(codeGraphCollapsedRows('init', INIT_FRESH, false, false), { text: '→ initialized', rows: 1, tail: false });
|
|
51
|
+
assert.deepEqual(codeGraphCollapsedRows('init', INIT_EXISTING, false, false), { text: '→ already initialized', rows: 1, tail: false });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// S4: the outcome is what the call DID, not its body, so a card of this
|
|
55
|
+
// package never loses that row to the minimized level. The index facts still
|
|
56
|
+
// wait for the reader's expansion, and every other operation hides as before.
|
|
57
|
+
test('S4: a minimized init keeps its outcome row, and only that row', () => {
|
|
58
|
+
assert.deepEqual(codeGraphCollapsedRows('init', INIT_FRESH, false, true), { text: '→ initialized', rows: 1, tail: false });
|
|
59
|
+
assert.deepEqual(codeGraphCollapsedRows('init', INIT_EXISTING, false, true), { text: '→ already initialized', rows: 1, tail: false });
|
|
60
|
+
assert.equal(codeGraphCollapsedRows('init', INIT_FACTS, false, true), undefined, 'no outcome sentence, no row: the facts wait for the expansion');
|
|
61
|
+
assert.equal(codeGraphCollapsedRows('sync', SYNC_CHANGED, false, true), undefined, 'every other operation still hides its body at minimal');
|
|
62
|
+
assert.deepEqual(codeGraphCollapsedRows('sync', SYNC_CHANGED, false, false), { text: '→ synced 3 changed files', rows: 1, tail: false }, 'and the default level is unchanged');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('an init without a concluding sentence previews the facts it reported', () => {
|
|
66
|
+
assert.deepEqual(codeGraphCollapsedRows('init', INIT_FACTS, false, false), {
|
|
67
|
+
text: '◆ Indexed 2 files\n● 5 nodes, 7 edges in 239ms',
|
|
68
|
+
rows: 3,
|
|
69
|
+
tail: true,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('a sync is told apart from an init, in the words sync itself printed', () => {
|
|
74
|
+
assert.equal(codeGraphSyncOutcome(SYNC_CHANGED), 'synced 3 changed files');
|
|
75
|
+
assert.equal(codeGraphSyncOutcome(SYNC_NO_FILES), 'synced 1 changed files');
|
|
76
|
+
assert.equal(codeGraphSyncOutcome(SYNC_UP_TO_DATE), 'already up to date');
|
|
77
|
+
// An init log states no sync outcome, and a sync log states no init one.
|
|
78
|
+
assert.equal(codeGraphSyncOutcome(INIT_FRESH), undefined);
|
|
79
|
+
assert.equal(codeGraphInitOutcome(SYNC_CHANGED), undefined);
|
|
80
|
+
assert.deepEqual(codeGraphCollapsedRows('sync', SYNC_CHANGED, false, false), { text: '→ synced 3 changed files', rows: 1, tail: false });
|
|
81
|
+
assert.deepEqual(codeGraphCollapsedRows('sync', SYNC_UP_TO_DATE, false, false), { text: '→ already up to date', rows: 1, tail: false });
|
|
82
|
+
// A sync that printed no such sentence keeps the rows it did print.
|
|
83
|
+
const quiet = ['┌ Syncing CodeGraph', '│', 'Resolved 4 pending references', '└ Done'].join('\n');
|
|
84
|
+
assert.equal(codeGraphSyncOutcome(quiet), undefined);
|
|
85
|
+
assert.deepEqual(codeGraphCollapsedRows('sync', quiet, false, false), {
|
|
86
|
+
text: '┌ Syncing CodeGraph\nResolved 4 pending references\n└ Done',
|
|
87
|
+
rows: 3,
|
|
88
|
+
tail: true,
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('a query and an explore summarize the count their own output stated', () => {
|
|
93
|
+
assert.equal(codeGraphResultSummary('query', QUERY), '2 results');
|
|
94
|
+
assert.equal(codeGraphResultSummary('query', QUERY_EMPTY), '0 results');
|
|
95
|
+
assert.equal(codeGraphResultSummary('explore', EXPLORE), '2 symbols in 1 file');
|
|
96
|
+
assert.equal(codeGraphResultSummary('explore', EXPLORE_PINNED), '1 symbol in 2 files', 'a further clause on the same sentence states more, not something else');
|
|
97
|
+
// A shape the module cannot read yields no count at all.
|
|
98
|
+
assert.equal(codeGraphResultSummary('query', 'some unexpected banner'), undefined);
|
|
99
|
+
assert.equal(codeGraphResultSummary('explore', '**Exploration: alpha**'), undefined);
|
|
100
|
+
assert.equal(codeGraphResultSummary('init', QUERY), undefined);
|
|
101
|
+
assert.deepEqual(codeGraphCollapsedRows('query', QUERY, false, false), { text: '→ 2 results', rows: 1, tail: false });
|
|
102
|
+
assert.deepEqual(codeGraphCollapsedRows('explore', EXPLORE, false, false), { text: '→ 2 symbols in 1 file', rows: 1, tail: false });
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('an unreadable shape keeps the rows it printed, and a failure its reason', () => {
|
|
106
|
+
const unknown = ['first printed row', 'second printed row'].join('\n');
|
|
107
|
+
assert.deepEqual(codeGraphCollapsedRows('query', unknown, false, false), { text: unknown, rows: 3, tail: true });
|
|
108
|
+
const failed = codeGraphCollapsedRows('init', INIT_FAILED, true, false);
|
|
109
|
+
assert.match(failed.text, /Failed: EACCES/);
|
|
110
|
+
assert.match(failed.text, /run "codegraph init" again/, 'the instruction the program printed stays with the reason');
|
|
111
|
+
// A withheld card draws no rows, but a failure always says why.
|
|
112
|
+
assert.equal(codeGraphCollapsedRows('query', QUERY, false, true), undefined);
|
|
113
|
+
assert.match(codeGraphCollapsedRows('init', INIT_FAILED, true, true).text, /Failed:/);
|
|
114
|
+
// An empty result is no row at all, not a zero it did not state.
|
|
115
|
+
assert.equal(codeGraphCollapsedRows('query', ' \n\n', false, false), undefined);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('the preview keeps the last rows it printed and drops the progress box', () => {
|
|
119
|
+
assert.equal(codeGraphPreview(INIT_FRESH), ['◆ Indexed 1 files', '● 3 nodes, 2 edges in 208ms', '└ Done'].join('\n'));
|
|
120
|
+
assert.equal(codeGraphPreview('', 3), '');
|
|
121
|
+
assert.equal(codeGraphPreview('a\nb\nc\nd', 2), 'c\nd');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('the identity reads the operation and query from the bash command', () => {
|
|
125
|
+
assert.deepEqual(codegraphCallFromCommand('codegraph init /tmp/ws'), { operation: 'init' });
|
|
126
|
+
assert.deepEqual(codegraphCallFromCommand('codegraph sync'), { operation: 'sync' });
|
|
127
|
+
assert.deepEqual(codegraphCallFromCommand('codegraph query --path /tmp/ws --limit 5 -- alpha'), { operation: 'query', query: 'alpha' });
|
|
128
|
+
assert.deepEqual(codegraphCallFromCommand('codegraph explore --path /tmp/ws --max-files 5 -- "a b"'), { operation: 'explore', query: 'a b' });
|
|
129
|
+
// Without a `--` separator only a lone payload is readable; flags are never guessed into the query.
|
|
130
|
+
assert.deepEqual(codegraphCallFromCommand('codegraph query alpha'), { operation: 'query', query: 'alpha' });
|
|
131
|
+
assert.deepEqual(codegraphCallFromCommand('codegraph query --path /tmp/ws alpha'), { operation: 'query' });
|
|
132
|
+
// A composition belongs to its last CodeGraph step.
|
|
133
|
+
assert.deepEqual(codegraphCallFromCommand('cd /tmp/ws && codegraph init'), { operation: 'init' });
|
|
134
|
+
assert.deepEqual(codegraphCallFromCommand('CI=1 codegraph init'), { operation: 'init' });
|
|
135
|
+
assert.deepEqual(codegraphCallFromCommand('/usr/local/bin/codegraph init'), { operation: 'init' });
|
|
136
|
+
assert.deepEqual(codegraphCallFromCommand('codegraph explore auth && git status'), { operation: 'explore', query: 'auth' });
|
|
137
|
+
assert.equal(codegraphCallDetail({ operation: 'init' }), 'init');
|
|
138
|
+
assert.equal(codegraphCallDetail({ operation: 'query', query: 'alpha' }), 'query alpha');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test('every codegraph invocation is a CodeGraph call, whatever its subcommand or composition', () => {
|
|
142
|
+
// The deciding fact is that `codegraph` is the command word of a segment: no
|
|
143
|
+
// operation is read for the card's heading, so a subcommand this reader cannot
|
|
144
|
+
// interpret, a flags-only invocation and several subcommands in one command all
|
|
145
|
+
// count — and none of them needs an operation to be drawn.
|
|
146
|
+
for (const [command, expected] of [
|
|
147
|
+
['codegraph', {}],
|
|
148
|
+
['codegraph --help', {}],
|
|
149
|
+
['codegraph --version', {}],
|
|
150
|
+
['codegraph status', { operation: 'status' }],
|
|
151
|
+
['codegraph callers worktreeListView', { operation: 'callers' }],
|
|
152
|
+
['codegraph node warpPendingGate', { operation: 'node' }],
|
|
153
|
+
['codegraph status 2>&1 | head -40', { operation: 'status' }],
|
|
154
|
+
['codegraph init && ./script', { operation: 'init' }],
|
|
155
|
+
['codegraph init; rm -rf src', { operation: 'init' }],
|
|
156
|
+
// A package runner that executes the program it names is the program too.
|
|
157
|
+
['npx codegraph status', { operation: 'status' }],
|
|
158
|
+
['pnpm exec codegraph status', { operation: 'status' }],
|
|
159
|
+
]) {
|
|
160
|
+
assert.deepEqual(codegraphCallFromCommand(command), expected, command);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// The commands a session really ran, one whole composition each.
|
|
164
|
+
const helpAndStatus = 'codegraph --help 2>&1 | head -60; echo "--- STATUS ---"; codegraph status 2>&1 | head -40';
|
|
165
|
+
assert.deepEqual(codegraphCallFromCommand(helpAndStatus), { operation: 'status' }, 'the last CodeGraph step names the operation');
|
|
166
|
+
const queries = [
|
|
167
|
+
'echo "=== codegraph query cardBodyRows ==="; codegraph query cardBodyRows 2>&1 | head -20; echo;',
|
|
168
|
+
'echo "=== codegraph callers worktreeListView ==="; codegraph callers worktreeListView 2>&1 | head -20; echo;',
|
|
169
|
+
'echo "=== codegraph node warpPendingGate ==="; codegraph node warpPendingGate 2>&1 | head -40',
|
|
170
|
+
].join(' ');
|
|
171
|
+
assert.equal(codegraphCallFromCommand(queries) !== undefined, true, 'a sequence of CodeGraph steps is one CodeGraph call');
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test('S5: any segment whose program is codegraph is a CodeGraph call, with its arguments', () => {
|
|
175
|
+
for (const [command, expected] of [
|
|
176
|
+
['codegraph', {}],
|
|
177
|
+
['codegraph status .', { operation: 'status' }],
|
|
178
|
+
['codegraph status', { operation: 'status' }],
|
|
179
|
+
['/usr/local/bin/codegraph status .', { operation: 'status' }],
|
|
180
|
+
['npx codegraph status .', { operation: 'status' }],
|
|
181
|
+
['pnpm exec codegraph status .', { operation: 'status' }],
|
|
182
|
+
['yarn codegraph status .', { operation: 'status' }],
|
|
183
|
+
['yarn exec codegraph status .', { operation: 'status' }],
|
|
184
|
+
['bunx codegraph status .', { operation: 'status' }],
|
|
185
|
+
['cd /tmp/ws && codegraph status .', { operation: 'status' }],
|
|
186
|
+
['codegraph status .; echo done', { operation: 'status' }],
|
|
187
|
+
['codegraph status . | head', { operation: 'status' }],
|
|
188
|
+
['codegraph status . || true', { operation: 'status' }],
|
|
189
|
+
]) {
|
|
190
|
+
assert.deepEqual(codegraphCallFromCommand(command), expected, command);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// A string or a different program that merely mentions it is never the program.
|
|
194
|
+
for (const command of ['echo codegraph', 'echo "codegraph status ."', 'git -C codegraph status', 'node codegraph.js init', 'cat codegraph status .']) {
|
|
195
|
+
assert.equal(codegraphCallFromCommand(command), undefined, command);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test('S6: the explored project is a last path segment, and only when it is not the session cwd', () => {
|
|
200
|
+
const checkout = '/home/jona/.pi/agent/git/github.com/Gentleman-Programming/gentle-shell';
|
|
201
|
+
assert.equal(projectPathSegment(checkout, '/work/repo'), 'gentle-shell', 'the last segment, never the full path');
|
|
202
|
+
assert.equal(projectPathSegment(`${checkout}/`, '/work/repo'), 'gentle-shell', 'a trailing slash is not part of the segment');
|
|
203
|
+
assert.equal(projectPathSegment('C:\\work\\gentle-shell', 'C:\\other'), 'gentle-shell', 'either path separator');
|
|
204
|
+
assert.equal(projectPathSegment('/work/repo', '/work/repo'), undefined, 'the session cwd names no other checkout');
|
|
205
|
+
assert.equal(projectPathSegment('/work/repo/', '/work/repo'), undefined, 'a trailing slash does not make it another checkout');
|
|
206
|
+
assert.equal(projectPathSegment('gentle-shell', '/work/repo/gentle-shell'), undefined, 'a bare name compares equal to the same name as cwd');
|
|
207
|
+
assert.equal(projectPathSegment('gentle-shell', '/work/repo'), 'gentle-shell', 'a bare name elsewhere is another checkout');
|
|
208
|
+
assert.equal(projectPathSegment(undefined, '/work/repo'), undefined);
|
|
209
|
+
assert.equal(projectPathSegment('', '/work/repo'), undefined);
|
|
210
|
+
assert.equal(projectPathSegment(' ', '/work/repo'), undefined);
|
|
211
|
+
assert.equal(projectPathSegment(checkout, undefined), 'gentle-shell', 'a seam that cannot answer still names the explicit argument');
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// S6 (T14): `.` and `..` are resolved LEXICALLY before the cwd comparison, so a
|
|
215
|
+
// path that climbs and returns names no other checkout. No filesystem read: the
|
|
216
|
+
// same strings answer the same on a path that does not exist.
|
|
217
|
+
test('S6: `.` and `..` are resolved lexically before the cwd comparison', () => {
|
|
218
|
+
const cwd = '/work/repo';
|
|
219
|
+
assert.equal(projectPathSegment('/work/repo/../repo', cwd), undefined, 'a path that climbs and comes back is the same checkout');
|
|
220
|
+
assert.equal(projectPathSegment('/work/repo/.', cwd), undefined, 'a trailing `/.` is the same checkout');
|
|
221
|
+
assert.equal(projectPathSegment('../repo', cwd), undefined, 'a relative path is read against the cwd, exactly like the shell');
|
|
222
|
+
assert.equal(projectPathSegment('.', cwd), undefined, 'the cwd itself names no other checkout');
|
|
223
|
+
assert.equal(projectPathSegment('./repo', cwd), 'repo', 'a `./` child really is another checkout');
|
|
224
|
+
assert.equal(projectPathSegment('/work/repo/../other', cwd), 'other', 'a resolved sibling still names its last segment');
|
|
225
|
+
assert.equal(projectPathSegment('../gentle-shell', cwd), 'gentle-shell', 'the segment is the RESOLVED checkout\'s own');
|
|
226
|
+
assert.equal(projectPathSegment('/work/repo/..', cwd), 'work', 'the parent is named by its own segment, never by the literal `..`');
|
|
227
|
+
assert.equal(projectPathSegment('C:\\work\\repo\\..\\repo', 'C:\\work\\repo'), undefined, 'either separator, resolved');
|
|
228
|
+
assert.equal(projectPathSegment('/does/not/exist/../exist', '/does/not/exist'), undefined, 'the answer never depends on the path existing');
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test('a command that merely mentions codegraph is not a CodeGraph call', () => {
|
|
232
|
+
for (const command of [
|
|
233
|
+
'echo codegraph init',
|
|
234
|
+
'git log --grep codegraph',
|
|
235
|
+
'cat codegraph.json',
|
|
236
|
+
'node codegraph.js init',
|
|
237
|
+
'mytool codegraph init',
|
|
238
|
+
'codegraph-cli init',
|
|
239
|
+
'pnpm test',
|
|
240
|
+
'pnpm test && ls',
|
|
241
|
+
'grep -r codegraph src',
|
|
242
|
+
'',
|
|
243
|
+
]) {
|
|
244
|
+
assert.equal(codegraphCallFromCommand(command), undefined, command);
|
|
245
|
+
}
|
|
246
|
+
// A value that is not a command string is no call, and never throws.
|
|
247
|
+
for (const value of [undefined, null, 42, {}, []]) assert.equal(codegraphCallFromCommand(value), undefined);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
test('tool output reaches the card as text, without the terminal sequences around it', () => {
|
|
251
|
+
assert.equal(cardText('\u001B[36mSearch\u001B[39m\u0000 \u001B]0;title\u0007'), 'Search ');
|
|
252
|
+
const coloured = `\u001B[36mSearch Results for "alpha":\u001B[39m\n\nfunction alpha\n src/a.ts:1`;
|
|
253
|
+
assert.equal(codeGraphResultSummary('query', cardText(coloured)), '1 result');
|
|
254
|
+
});
|