pi-odd-worktree 3.12.4 → 3.14.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 +5 -4
- package/extensions/odd-worktree-tools.ts +164 -29
- package/lib/odd-rail-section.js +21 -0
- package/lib/odd-view.js +85 -21
- package/lib/session-auto-name.js +144 -160
- package/lib/user-identity.js +236 -0
- package/lib/user-prompt-card.js +49 -28
- package/package.json +1 -1
- package/tools/commands.test.js +4 -3
- package/tools/files-bridge.test.js +2 -2
- package/tools/files-command.test.js +2 -2
- package/tools/odd-panel-wiring.test.js +78 -35
- package/tools/odd-rail-section.test.js +66 -4
- package/tools/odd-view.test.js +119 -31
- package/tools/package-surface.test.js +7 -6
- package/tools/session-auto-name-wiring.test.js +159 -0
- package/tools/session-auto-name.test.js +342 -0
- package/tools/user-identity.test.js +503 -0
- package/tools/user-prompt-card.test.js +73 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A Pi package that gives an agent session Git worktrees, ODD documents, GitHub is
|
|
|
4
4
|
|
|
5
5
|
## What It Does
|
|
6
6
|
|
|
7
|
-
Two agent tools, five panels,
|
|
7
|
+
Two agent tools, five panels, the `/identity` command, two sidebar sections and two tool designs, loaded from one extension entry point. Each ODD feature gets its own checkout beside the clone, and you move between checkouts and read your ODD documents, files, issues and pull requests without leaving Pi.
|
|
8
8
|
|
|
9
9
|
| Surface | Kind | What it does |
|
|
10
10
|
| --- | --- | --- |
|
|
@@ -13,6 +13,7 @@ Two agent tools, five panels, one background-explorer command, two sidebar secti
|
|
|
13
13
|
| `/warp` | panel | Moves this session to another checkout, creates one, and removes one. |
|
|
14
14
|
| `/odd` | panel | Reads `odd/tasks/*.md`: list on the left, styled markdown on the right — main's whole listing, plus one collapsible group per worktree the session registered with only what that worktree has that main does not, and `a` toggles between the session's checkouts and every worktree. One optional target — an ODD name or an ODD's name or the absolute path of a document that main or a worktree the session registered lists — opens it on that ODD; anything else is refused. |
|
|
15
15
|
| `/files` | panel | Browses one checkout's files with a live, language-coloured preview: `enter` pastes the chosen paths into your prompt, `ctrl+e` opens the file in `$EDITOR`. |
|
|
16
|
+
| `/identity` | command | Stores your name: `/identity Jona` heads your prompt cards with it instead of `You` and appends one line about it to the orchestrator's prompt, `/identity clear` unsets it, and `/identity` alone says which name is stored. |
|
|
16
17
|
| `/issues` | panel | Reads this checkout's GitHub issues — the three scoped tabs on open, every open issue behind `g` — and, when your role allows it, edits them. `enter` inserts the focused issue into the chat input as `ISSUE #63`, and each linked pull request in the pane is its own click that opens that pull request in `/prs`. |
|
|
17
18
|
| `/prs` | panel | The same reader for pull requests: `My Pull Request`, `Needs My Review` and `Involved` on open, every open pull request of the repository behind `g`, the pane's `Changes` and `Checks` summaries, and — when your role allows it — comment, labels, assignees, the linked issues, merge (after a confirmation naming the method and the commit message) and close. `enter` inserts the focused pull request as `PR #87`, and each linked issue in the pane is its own click that opens that issue in `/issues`. |
|
|
18
19
|
| `GITHUB` rail section | sidebar section | Lists the open issues of this checkout's repository you authored or are assigned, seven at a time plus a count of the rest, and its header counts the pull requests beside them (`7 issues · 3 pr`: your own plus the ones awaiting your review). A click opens that issue in `/issues` on `Assigned` — or, when the issue carries a linked pull request, that pull request in `/prs` on the bucket it belongs to; the overflow row opens `/issues`. Needs `gh`. |
|
|
@@ -57,7 +58,7 @@ From a local clone, `pi install .` installs the working copy, and `gentle-shell
|
|
|
57
58
|
|
|
58
59
|
### Expected result
|
|
59
60
|
|
|
60
|
-
`/warp`, `/odd`, `/files`, `/issues` and `/prs` are available as commands — `/issues` and `/prs` only where `gh` is on `PATH` — the agent is offered `worktree_create` and `worktree_list`, a Gentle Shell whose rail is drawn shows a `GITHUB` section for this checkout and an `ODD` section listing the ODDs the session is working on, and its `/gentle:customize` → `Cards` page offers `activity` on its `Card activity` line.
|
|
61
|
+
`/warp`, `/odd`, `/files`, `/identity`, `/issues` and `/prs` are available as commands — `/issues` and `/prs` only where `gh` is on `PATH` — the agent is offered `worktree_create` and `worktree_list`, a Gentle Shell whose rail is drawn shows a `GITHUB` section for this checkout and an `ODD` section listing the ODDs the session is working on, and its `/gentle:customize` → `Cards` page offers `activity` on its `Card activity` line.
|
|
61
62
|
|
|
62
63
|
### Bridge versions
|
|
63
64
|
|
|
@@ -101,12 +102,12 @@ The full rules of each step, including every refusal, are in [Create, list, move
|
|
|
101
102
|
- **File calls on a skill or an ODD are cards too.** While that line answers with `activity` for the tool being painted, a `read`, `edit` or `write` whose path names a skill or an ODD heads as that file — its own mark and label, the tool, the path and a read's line range — and its Markdown body is drawn by Pi's own renderer in the theme's Markdown roles. Any other file call is the host's own row. See [the file cards](docs/reference.md#the-file-cards).
|
|
102
103
|
- **Background-job tools are cards too.** While that line answers with `activity`, `bash_background`, `monitor`, `job_stop` and `job_list` are drawn in the shell's own card style instead of Pi's plain box, with the job's label, its command and its own answer. See [the jobs card](docs/reference.md#the-jobs-card).
|
|
103
104
|
- **The two advisory messages are cards too.** `gentle-pi.exploration-budget` and `gentle-pi.verifier-settle-reminder` are drawn as `⌕ Exploration budget` and `⚑ Verifier reminder`, the whole body at every content level. They follow that `Card activity` line, with no second switch and no row added to `Cards`. See [the message cards](docs/reference.md#the-message-cards).
|
|
104
|
-
- **Your own prompt can be a card too.** While that `Card activity` line answers `activity`, the message you sent is drawn as a `✿
|
|
105
|
+
- **Your own prompt can be a card too.** While that `Card activity` line answers `activity`, the message you sent is drawn as a `✿ Jona` card — your own name, stored with `/identity`, and `You` while none is stored, the title and the whole frame in the accent role, in whichever card style your shell uses — instead of Pi's plain background block, in the prompts already on screen too, because a name set or cleared repaints them. It is the one host class this package patches, because Pi offers no hook for a `role: "user"` entry: switch the line to `default` and the prompt is Pi's own again, live, byte for byte. It adds no switch of its own. See [the user prompt card](docs/reference.md#the-user-prompt-card).
|
|
105
106
|
- **The diff card is a design of the same kind.** `Card diff` keeps `default` available and selects `color` once on the first run that finds no choice, so a write or an edit on a skill or an ODD stays the file card's row, because a specific claim wins over a generic one. See [the diff card](docs/reference.md#the-diff-card).
|
|
106
107
|
- **`edit` and `write` cannot land in the principal checkout's default branch.** A write whose path is inside the principal checkout of the session's repository, while that checkout is on the default branch, is refused with one line pointing at `worktree_list` and `worktree_create`. Paths outside the repository, anything under the OS temp directories, ODD artifacts, other repositories and linked worktrees are never blocked. See [the guard](docs/reference.md#the-edit-and-write-guard).
|
|
107
108
|
- **A skill or an ODD is read whole.** A `read` of a `.md` below a `skills/` or an `odd/` folder drops its `offset` and `limit` before the tool runs, so the call delivers the whole document and never half a procedure. It follows the `Worktrees+` module, like the guards.
|
|
108
109
|
- **`bash` cannot leave the principal checkout's default branch.** A `git worktree add` is refused in any cwd and pointed at `worktree_create`; in the principal checkout, a switch that would leave the branch it is on is refused while that branch is the repository's default, and creating a branch is not blocked. See [the guards](docs/reference.md#the-bash-guards).
|
|
109
|
-
- **
|
|
110
|
+
- **Three blocks in the system prompt.** `## ODD worktrees` tells the agent how worktrees and ODDs work. `## CodeGraph` tells a session that already holds a CodeGraph tool how to use it, with one text per role. `## User identity` states your name in one line, and it is there only while a name is stored. All three are appended after the host's own text; `ODD_WORKTREE_PROMPT=0` suppresses the first two, and the third is the stored name's business alone. See [the prompt block](docs/reference.md#the--odd-worktrees-block-in-the-system-prompt) and [the user identity block](docs/reference.md#the--user-identity-block-in-the-system-prompt).
|
|
110
111
|
- **CodeGraph stays fresh, only when its CLI is installed.** At session start the package creates or syncs the checkout's index and warms its daemon, and makes sure your global `mcp.json` has the `codegraph` entry. It also syncs after a compaction, after a native `codegraph init` and after an `edit` or `write`, in the background and without ever blocking you. See [CodeGraph](docs/reference.md#codegraph-index-daemon-and-mcp-entry).
|
|
111
112
|
- **Two reminders keep a session on the CodeGraph rule.** The first `grep`, `find`, `ls`, `read` or `bash` search in a checkout gets one sentence appended to its result: use `codegraph` first, or — for another checkout — call `mcp__codegraph__codegraph_explore` with that path as `projectPath`. Neither is ever a block, and a subagent child hears neither. See [the reminders](docs/reference.md#the-two-codegraph-reminders).
|
|
112
113
|
- **Deliberately absent.** No customize panel of its own, no plugin-tools toggles, no companion-app integration and no worktree-to-issue association. There is nothing to configure here: the card designs are chosen on the bridge's own lines, so this package owns no preference of its own. See [deliberately absent](docs/reference.md#deliberately-absent).
|
|
@@ -2870,13 +2870,13 @@ function observeOddWriteForNaming(event, ctx, pi, allowPhaseTrigger) {
|
|
|
2870
2870
|
return;
|
|
2871
2871
|
}
|
|
2872
2872
|
const rows = registry.checkoutRows(live);
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2873
|
+
// The checkout this call names FROM: a registered worktree first (the longest
|
|
2874
|
+
// match wins), else the principal checkout itself. An ODD write from the principal
|
|
2875
|
+
// checkout renames the session exactly like one from a worktree — the rule follows
|
|
2876
|
+
// the document, not the checkout it lives in.
|
|
2877
|
+
const entry = oddEntryForCwd(rows, cwd) || principalEntryFor(cwd, principalRoot);
|
|
2878
|
+
if (!entry) return;
|
|
2876
2879
|
const touched = [];
|
|
2877
|
-
// The absolute path behind each touched rel, so the naming step can read
|
|
2878
|
-
// the document's own heading without re-resolving path logic here.
|
|
2879
|
-
const absByRel = new Map();
|
|
2880
2880
|
// The per-call leg applies to the read/edit/write tools, which carry a
|
|
2881
2881
|
// single document path. Every other tool (notably `bash`) carries no
|
|
2882
2882
|
// reliably parseable path and contributes nothing.
|
|
@@ -2886,19 +2886,51 @@ function observeOddWriteForNaming(event, ctx, pi, allowPhaseTrigger) {
|
|
|
2886
2886
|
const rel = oddRelFor(abs, entry.path, principalRoot);
|
|
2887
2887
|
if (!rel) continue;
|
|
2888
2888
|
touched.push(rel);
|
|
2889
|
-
if (!absByRel.has(rel)) absByRel.set(rel, abs);
|
|
2890
2889
|
}
|
|
2891
2890
|
}
|
|
2892
2891
|
// T2/D2-D7: the touched rels name the session after the ODD task document
|
|
2893
2892
|
// being WRITTEN. The naming decision (write-only, own name only,
|
|
2894
2893
|
// idempotent) lives in lib/session-auto-name.js; this is the call site.
|
|
2895
2894
|
const sessionId = oddSessionId(ctx);
|
|
2896
|
-
autoNameSessionFromWrite(pi,
|
|
2895
|
+
autoNameSessionFromWrite(pi, oddToolNameOf(event), touched, sessionId);
|
|
2897
2896
|
// D3: an ODD phase transition carries no feature of its own, so it only
|
|
2898
2897
|
// re-applies the label this session last derived from a write. It is
|
|
2899
2898
|
// observed on `tool_result` (a gentle-pi tool, not a host event).
|
|
2900
2899
|
if (allowPhaseTrigger === true) {
|
|
2901
|
-
autoNameSessionFromPhase(pi,
|
|
2900
|
+
autoNameSessionFromPhase(pi, sessionId, oddToolNameOf(event));
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
// The principal checkout as a naming target, in the shape a registry row has (`path`),
|
|
2905
|
+
// so ONE rel resolution serves both. Naming needs no branch (the name is the ODD's
|
|
2906
|
+
// own), and the rail's row election is untouched: this shape never reaches it.
|
|
2907
|
+
function principalEntryFor(cwd, principalRoot) {
|
|
2908
|
+
if (typeof principalRoot !== "string" || principalRoot.length === 0) return null;
|
|
2909
|
+
let resolved;
|
|
2910
|
+
try {
|
|
2911
|
+
resolved = path.resolve(cwd);
|
|
2912
|
+
} catch {
|
|
2913
|
+
return null;
|
|
2914
|
+
}
|
|
2915
|
+
const root = path.resolve(principalRoot);
|
|
2916
|
+
if (resolved !== root && !resolved.startsWith(root + path.sep)) return null;
|
|
2917
|
+
return { path: root };
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
// The ODD names this session already WROTE, newest first, read from the durable touch
|
|
2921
|
+
// record (`odd-worktree.odd-touch`) the rail already keeps. Naming reads that ONE
|
|
2922
|
+
// record as the proof that a name this process did not write is still its own, which
|
|
2923
|
+
// is what survives a resume (D5). A host without the record simply has less evidence.
|
|
2924
|
+
function oddTouchedNames() {
|
|
2925
|
+
try {
|
|
2926
|
+
if (oddSession === null) return [];
|
|
2927
|
+
const names = [];
|
|
2928
|
+
for (const row of oddSession.touched()) {
|
|
2929
|
+
if (row && typeof row.name === "string" && row.name.length > 0) names.push(row.name);
|
|
2930
|
+
}
|
|
2931
|
+
return names;
|
|
2932
|
+
} catch {
|
|
2933
|
+
return [];
|
|
2902
2934
|
}
|
|
2903
2935
|
}
|
|
2904
2936
|
|
|
@@ -2920,31 +2952,16 @@ function oddSessionId(ctx) {
|
|
|
2920
2952
|
}
|
|
2921
2953
|
}
|
|
2922
2954
|
|
|
2923
|
-
|
|
2924
|
-
// (the file may not exist yet on `tool_call`, or the write failed). A null
|
|
2925
|
-
// text falls back to the filename slug inside the module.
|
|
2926
|
-
function readOddDocumentText(absByRel, rel) {
|
|
2927
|
-
if (!absByRel || typeof absByRel.get !== "function") return null;
|
|
2928
|
-
const abs = absByRel.get(rel);
|
|
2929
|
-
if (typeof abs !== "string" || abs.length === 0) return null;
|
|
2930
|
-
try {
|
|
2931
|
-
return fs.readFileSync(abs, "utf8");
|
|
2932
|
-
} catch {
|
|
2933
|
-
return null;
|
|
2934
|
-
}
|
|
2935
|
-
}
|
|
2936
|
-
|
|
2937
|
-
function autoNameSessionFromWrite(pi, entry, toolName, touched, absByRel, sessionId) {
|
|
2955
|
+
function autoNameSessionFromWrite(pi, toolName, touched, sessionId) {
|
|
2938
2956
|
try {
|
|
2939
2957
|
if (!pi || typeof pi.getSessionName !== "function" || typeof pi.setSessionName !== "function") return;
|
|
2940
2958
|
const auto = libRequire("session-auto-name.js");
|
|
2941
2959
|
const label = auto.planSessionRename({
|
|
2942
2960
|
rels: touched,
|
|
2943
2961
|
isWrite: auto.isWriteToolName(toolName),
|
|
2944
|
-
branch: entry && typeof entry.branch === "string" ? entry.branch : "",
|
|
2945
2962
|
currentName: pi.getSessionName(),
|
|
2946
2963
|
sessionId,
|
|
2947
|
-
|
|
2964
|
+
touchedNames: oddTouchedNames(),
|
|
2948
2965
|
});
|
|
2949
2966
|
if (typeof label === "string" && label.length > 0) pi.setSessionName(label);
|
|
2950
2967
|
} catch {
|
|
@@ -2956,15 +2973,15 @@ function autoNameSessionFromWrite(pi, entry, toolName, touched, absByRel, sessio
|
|
|
2956
2973
|
// derived from an ODD write. The phase names no feature, so nothing is
|
|
2957
2974
|
// invented here; a session that never wrote an ODD document has nothing to
|
|
2958
2975
|
// re-apply and is left alone.
|
|
2959
|
-
function autoNameSessionFromPhase(pi,
|
|
2976
|
+
function autoNameSessionFromPhase(pi, sessionId, toolName) {
|
|
2960
2977
|
try {
|
|
2961
2978
|
if (!pi || typeof pi.getSessionName !== "function" || typeof pi.setSessionName !== "function") return;
|
|
2962
2979
|
const auto = libRequire("session-auto-name.js");
|
|
2963
2980
|
if (toolName !== auto.ODD_PHASE_TOOL_NAME) return;
|
|
2964
2981
|
const label = auto.planPhaseSessionRename({
|
|
2965
2982
|
sessionId,
|
|
2966
|
-
branch: entry && typeof entry.branch === "string" ? entry.branch : "",
|
|
2967
2983
|
currentName: pi.getSessionName(),
|
|
2984
|
+
touchedNames: oddTouchedNames(),
|
|
2968
2985
|
});
|
|
2969
2986
|
if (typeof label === "string" && label.length > 0) pi.setSessionName(label);
|
|
2970
2987
|
} catch {
|
|
@@ -8345,6 +8362,98 @@ function registerFilesCommand(pi) {
|
|
|
8345
8362
|
filesCommandHandler = handler;
|
|
8346
8363
|
}
|
|
8347
8364
|
|
|
8365
|
+
// ---------------------------------------------------------------------------
|
|
8366
|
+
// `/identity` (identity-command S1/S2/S4): the user's own name.
|
|
8367
|
+
//
|
|
8368
|
+
// TRANSVERSAL, like `/files` and `/odd`: it is registered wherever the bridge is
|
|
8369
|
+
// and takes no module switch, because the name is the person's, not one of the
|
|
8370
|
+
// package's optional halves. The name lives in the bridge's own store
|
|
8371
|
+
// (`lib/user-identity.js`, document `identity`), so it survives a restart, and
|
|
8372
|
+
// the card learns about it by READING that document on every paint — which is
|
|
8373
|
+
// why a change only has to ask for ONE repaint instead of invalidating
|
|
8374
|
+
// anything: every prompt already on screen, old or new, heads with the name the
|
|
8375
|
+
// next frame reads.
|
|
8376
|
+
//
|
|
8377
|
+
// `clear` is RESERVED: it is the one argument that is a verb. Anything else is a
|
|
8378
|
+
// name, normalized by the lib module, and a value that does not normalize is
|
|
8379
|
+
// refused with one sentence and writes nothing.
|
|
8380
|
+
// ---------------------------------------------------------------------------
|
|
8381
|
+
|
|
8382
|
+
// The two state reports and the one refusal. A name that is stored is said as it
|
|
8383
|
+
// was stored (normalized), and an unset one says what the card heads with.
|
|
8384
|
+
function identityStateText(name) {
|
|
8385
|
+
return name === undefined || name === null
|
|
8386
|
+
? 'identity: not set · messages head with "You"'
|
|
8387
|
+
: `identity: ${name}`;
|
|
8388
|
+
}
|
|
8389
|
+
const IDENTITY_REFUSAL = 'identity: a name needs 1-40 printable characters and no markdown heading';
|
|
8390
|
+
|
|
8391
|
+
function registerIdentityCommand(pi) {
|
|
8392
|
+
if (typeof pi?.registerCommand !== 'function') return;
|
|
8393
|
+
pi.registerCommand('identity', {
|
|
8394
|
+
description: "Store your name, which heads your prompts instead of \"You\" and rides one line of the orchestrator prompt; `clear` is reserved and unsets it",
|
|
8395
|
+
handler: (args, ctx) => {
|
|
8396
|
+
const notify = ctx && ctx.ui && typeof ctx.ui.notify === 'function' ? ctx.ui.notify : undefined;
|
|
8397
|
+
// The optional-call posture every command here uses, plus the one thing a
|
|
8398
|
+
// report can still cost: a UI that throws is never a failed write.
|
|
8399
|
+
const say = (text, level) => {
|
|
8400
|
+
try {
|
|
8401
|
+
if (level === undefined) notify?.(text);
|
|
8402
|
+
else notify?.(text, level);
|
|
8403
|
+
} catch {
|
|
8404
|
+
// A dead UI never turns a report into a throw.
|
|
8405
|
+
}
|
|
8406
|
+
};
|
|
8407
|
+
const raw = String(args ?? '').trim();
|
|
8408
|
+
try {
|
|
8409
|
+
const identity = libRequire('user-identity.js');
|
|
8410
|
+
const resolver = libRequire('file-card-resolver.js');
|
|
8411
|
+
const api = resolver && typeof resolver.bridgeApi === 'function' ? resolver.bridgeApi() : undefined;
|
|
8412
|
+
const before = identity.readIdentityName(api);
|
|
8413
|
+
// No argument: report the state. Nothing is written and nothing repaints.
|
|
8414
|
+
if (raw.length === 0) {
|
|
8415
|
+
say(identityStateText(before));
|
|
8416
|
+
return;
|
|
8417
|
+
}
|
|
8418
|
+
// The reserved word is decided on the NORMALIZED value, in any case: `cle\u0001ar` only
|
|
8419
|
+
// BECOMES `clear` once the control is dropped, and treating it as a name would store a
|
|
8420
|
+
// name the command could never unset — `clear` is always the verb.
|
|
8421
|
+
const normalized = identity.normalizeIdentityName(raw);
|
|
8422
|
+
if (normalized !== undefined && normalized.toLowerCase() === 'clear') {
|
|
8423
|
+
identity.clearIdentityName(api);
|
|
8424
|
+
const after = identity.readIdentityName(api);
|
|
8425
|
+
say(identityStateText(after));
|
|
8426
|
+
// ONE repaint, and only when the stored state actually changed: the
|
|
8427
|
+
// prompts already on screen need it, an unchanged one already has it.
|
|
8428
|
+
if (after !== before) requestPromptCardRepaintNow();
|
|
8429
|
+
return;
|
|
8430
|
+
}
|
|
8431
|
+
// A refused name writes nothing, so it says the one sentence and stops.
|
|
8432
|
+
if (normalized === undefined) {
|
|
8433
|
+
say(IDENTITY_REFUSAL, 'error');
|
|
8434
|
+
return;
|
|
8435
|
+
}
|
|
8436
|
+
// A value the store already holds changes nothing: no write and no repaint, and the
|
|
8437
|
+
// state is still said honestly.
|
|
8438
|
+
if (normalized === before) {
|
|
8439
|
+
say(identityStateText(before));
|
|
8440
|
+
return;
|
|
8441
|
+
}
|
|
8442
|
+
if (!identity.writeIdentityName(api, raw)) {
|
|
8443
|
+
say(IDENTITY_REFUSAL, 'error');
|
|
8444
|
+
return;
|
|
8445
|
+
}
|
|
8446
|
+
say(identityStateText(normalized));
|
|
8447
|
+
// ONE repaint, and only for a change: the prompts already on screen need it.
|
|
8448
|
+
requestPromptCardRepaintNow();
|
|
8449
|
+
} catch {
|
|
8450
|
+
// A store this build cannot read is no name, never a crash of the command.
|
|
8451
|
+
say('identity: the name could not be read or written', 'error');
|
|
8452
|
+
}
|
|
8453
|
+
},
|
|
8454
|
+
});
|
|
8455
|
+
}
|
|
8456
|
+
|
|
8348
8457
|
// ---------------------------------------------------------------------------
|
|
8349
8458
|
// `/issues` (T3 S1,S3): a full-screen issues reader over the CURRENT checkout's
|
|
8350
8459
|
// repository issues, through this package's own migrated pieces
|
|
@@ -11100,6 +11209,20 @@ function installUserPromptCard() {
|
|
|
11100
11209
|
*/
|
|
11101
11210
|
function requestPromptCardRepaint(outcome) {
|
|
11102
11211
|
if (outcome === null || typeof outcome !== "object" || outcome.installed !== true) return;
|
|
11212
|
+
requestPromptCardRepaintNow();
|
|
11213
|
+
}
|
|
11214
|
+
|
|
11215
|
+
/**
|
|
11216
|
+
* The one bridge call a repaint IS, extracted so every surface that needs one asks for exactly
|
|
11217
|
+
* one the same way: the card's own install (above) and `/identity` after a successful write or
|
|
11218
|
+
* clear (identity-command D5).
|
|
11219
|
+
*
|
|
11220
|
+
* Nothing is asked for by a session that is not the live one — the caller's outcome may not
|
|
11221
|
+
* decide that, and a repaint belongs to the transcript still on screen. The bridge's member is
|
|
11222
|
+
* OPTIONAL and its answer is irrelevant, so an absent member, an absent bridge and a throw all
|
|
11223
|
+
* end the same way: no repaint, no error.
|
|
11224
|
+
*/
|
|
11225
|
+
function requestPromptCardRepaintNow() {
|
|
11103
11226
|
if (!userPromptCardSessionLive) return;
|
|
11104
11227
|
try {
|
|
11105
11228
|
const resolver = libRequire("file-card-resolver.js");
|
|
@@ -11107,7 +11230,7 @@ function requestPromptCardRepaint(outcome) {
|
|
|
11107
11230
|
if (api === undefined || typeof api.requestRepaint !== "function") return;
|
|
11108
11231
|
api.requestRepaint();
|
|
11109
11232
|
} catch {
|
|
11110
|
-
// A bridge that refuses its own repaint never breaks the
|
|
11233
|
+
// A bridge that refuses its own repaint never breaks the surface it belongs to.
|
|
11111
11234
|
}
|
|
11112
11235
|
}
|
|
11113
11236
|
|
|
@@ -12083,6 +12206,9 @@ function registerOddWorktreeSurfaceEntries(pi) {
|
|
|
12083
12206
|
// T7 (files-picker): the file picker is the fourth command. It mounts its own
|
|
12084
12207
|
// overlays, reads Git through the package's async runner and adds no tool.
|
|
12085
12208
|
registerFilesCommand(pi);
|
|
12209
|
+
// identity-command (S1/S2/S4): the user's own name, transversal like the picker —
|
|
12210
|
+
// it is registered wherever the bridge is and takes no module switch.
|
|
12211
|
+
registerIdentityCommand(pi);
|
|
12086
12212
|
// S36 (files-picker T15): the picker's ONE key, bound directly on the host and
|
|
12087
12213
|
// bound once — `alt+p` (S41) unless `GENTLE_PI_FILES_KEY` says otherwise.
|
|
12088
12214
|
bindFilesShortcut(pi);
|
|
@@ -12392,6 +12518,15 @@ function registerOddWorktreeSurfaceEntries(pi) {
|
|
|
12392
12518
|
// The prompt block is best effort.
|
|
12393
12519
|
}
|
|
12394
12520
|
}
|
|
12521
|
+
// identity-command (D4): the user's own name, one line, in its own try/catch beside the two
|
|
12522
|
+
// blocks above. TRANSVERSAL on purpose: no module switch gates it, and the stored name
|
|
12523
|
+
// itself is the switch — a child session and a named-agent event get nothing, because the
|
|
12524
|
+
// line is the orchestrator's.
|
|
12525
|
+
try {
|
|
12526
|
+
libRequire("user-identity.js").appendUserIdentitySection(event);
|
|
12527
|
+
} catch {
|
|
12528
|
+
// The prompt block is best effort.
|
|
12529
|
+
}
|
|
12395
12530
|
});
|
|
12396
12531
|
// CodeGraph, only with its CLI installed: the global MCP entry, create-or-sync at session
|
|
12397
12532
|
// start, the compaction sync, the observed native init and the edit/write sync. Every
|
package/lib/odd-rail-section.js
CHANGED
|
@@ -405,6 +405,25 @@ function createOddRailSection(options = {}) {
|
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
+
// S7 (odd-panel-groups): the heading's right-hand value — `N odd`, lowercase —
|
|
409
|
+
// the way the CHANGES card reads `1 file`. The host paints it in its muted role,
|
|
410
|
+
// so the count never competes with the section title. The heading only READS the
|
|
411
|
+
// snapshot: a collapsed card is drawn with this call alone, so scheduling a
|
|
412
|
+
// refresh here would make a hidden section cost the scan it is meant to cost
|
|
413
|
+
// nothing, and a list that is no longer live says `· stale` instead of hiding
|
|
414
|
+
// the failure. No snapshot is no count.
|
|
415
|
+
function meta(_ctx) {
|
|
416
|
+
try {
|
|
417
|
+
noteDrawn();
|
|
418
|
+
if (snapshot === null) return undefined;
|
|
419
|
+
if (snapshot.status === 'stale') return `${snapshot.total} odd · stale`;
|
|
420
|
+
if (snapshot.status !== 'ready') return undefined;
|
|
421
|
+
return `${snapshot.total} odd`;
|
|
422
|
+
} catch {
|
|
423
|
+
return undefined;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
408
427
|
// A drawing call stamps the frame. A clock that throws or answers nonsense
|
|
409
428
|
// costs the drawn window, never the frame itself.
|
|
410
429
|
function noteDrawn() {
|
|
@@ -451,6 +470,8 @@ function createOddRailSection(options = {}) {
|
|
|
451
470
|
// S1: right after the native AGENTS part, never at the top.
|
|
452
471
|
placement: { after: 'agents' },
|
|
453
472
|
lines,
|
|
473
|
+
// S7 (odd-panel-groups): the heading's `N odd`, lowercase and muted by the host.
|
|
474
|
+
meta,
|
|
454
475
|
};
|
|
455
476
|
|
|
456
477
|
return { section, refresh, refreshIfStale, invalidate, drawnWithin, dispose };
|
package/lib/odd-view.js
CHANGED
|
@@ -63,6 +63,13 @@ const MIN_WIDTH = 24;
|
|
|
63
63
|
const DEFAULT_LIST_WIDTH = layout.paneWidths(layout.innerWidth(80), { listShare: layout.READER_LIST_SHARE }).left;
|
|
64
64
|
const EMPTY_LIST = 'no odd documents';
|
|
65
65
|
const EMPTY_HINT = 'create one under odd/tasks/';
|
|
66
|
+
// odd-panel-groups S1: the panel opens with every group folded, so the first frame
|
|
67
|
+
// can stand on a header that holds no document. The pane says what to press instead
|
|
68
|
+
// of claiming a filter matched nothing.
|
|
69
|
+
const FOLDED_HINT = 'enter opens this group';
|
|
70
|
+
// S3: the 2-cell indent a document carries so its text starts at the column its
|
|
71
|
+
// group's name starts at, under the chevron's own column.
|
|
72
|
+
const CHILD_INDENT = ' ';
|
|
66
73
|
// S2: ONE legend, ONE terminal row — every key rides the same row instead of
|
|
67
74
|
// a second footer row. `text` is the full token, `short` the compact form used
|
|
68
75
|
// when the full one does not fit, and `priority` decides what a
|
|
@@ -400,8 +407,7 @@ function checkoutGroupName(group) {
|
|
|
400
407
|
return group.isMain === true ? 'main' : '';
|
|
401
408
|
}
|
|
402
409
|
|
|
403
|
-
function normalizeGroups(raw) {
|
|
404
|
-
if (!Array.isArray(raw)) return null;
|
|
410
|
+
function normalizeGroups(raw) { if (!Array.isArray(raw)) return null;
|
|
405
411
|
const out = [];
|
|
406
412
|
for (const entry of raw) {
|
|
407
413
|
if (!entry || typeof entry !== 'object') continue;
|
|
@@ -454,9 +460,12 @@ function createOddView(options = {}) {
|
|
|
454
460
|
let allMode = false;
|
|
455
461
|
let requestedAll = false;
|
|
456
462
|
const notifyToggleAll = typeof options.onToggleAll === 'function' ? options.onToggleAll : null;
|
|
457
|
-
// The groups the reader
|
|
458
|
-
//
|
|
459
|
-
|
|
463
|
+
// The groups the reader OPENED, keyed by checkout (odd-panel-groups S1): the set
|
|
464
|
+
// starts empty, so every group is folded and a panel opens as a list of headers —
|
|
465
|
+
// only the group of the document the panel was opened on is expanded (S2). A
|
|
466
|
+
// group that leaves the listing drops its own key, and an expansion survives a
|
|
467
|
+
// reload of the same listing.
|
|
468
|
+
const expandedCheckouts = new Set();
|
|
460
469
|
let docs = Array.isArray(options.docs) ? options.docs.slice() : [];
|
|
461
470
|
const entries = new Map();
|
|
462
471
|
const state = {
|
|
@@ -542,11 +551,17 @@ function createOddView(options = {}) {
|
|
|
542
551
|
|
|
543
552
|
function groupView(group, list) {
|
|
544
553
|
const key = checkoutGroupKey(group);
|
|
554
|
+
const name = checkoutGroupName(group);
|
|
545
555
|
return {
|
|
546
556
|
key,
|
|
547
|
-
name
|
|
557
|
+
name,
|
|
558
|
+
// S4: what a header reads. `name` unless two drawn checkouts share it (see
|
|
559
|
+
// `labelHeaders`), which is the only case a folded header could be mistaken
|
|
560
|
+
// for its twin.
|
|
561
|
+
label: name,
|
|
562
|
+
root: typeof group.checkoutRoot === 'string' ? group.checkoutRoot : '',
|
|
548
563
|
isMain: group.isMain === true,
|
|
549
|
-
folded:
|
|
564
|
+
folded: !expandedCheckouts.has(key),
|
|
550
565
|
// `list` is what the filter leaves to paint; `total` is what the checkout
|
|
551
566
|
// owns, so the frame's count never moves with the query.
|
|
552
567
|
total: group.docs.length,
|
|
@@ -554,6 +569,32 @@ function createOddView(options = {}) {
|
|
|
554
569
|
};
|
|
555
570
|
}
|
|
556
571
|
|
|
572
|
+
// The last directory before a checkout root: `…/repo-worktrees-a/same checkout`
|
|
573
|
+
// answers `repo-worktrees-a`. Empty when the root has no parent segment.
|
|
574
|
+
function parentSegment(root) {
|
|
575
|
+
const clean = typeof root === 'string' ? root.replace(/\/+$/, '') : '';
|
|
576
|
+
if (clean === '') return '';
|
|
577
|
+
const cut = clean.lastIndexOf('/');
|
|
578
|
+
if (cut <= 0) return '';
|
|
579
|
+
const parent = clean.slice(0, cut);
|
|
580
|
+
return parent.slice(parent.lastIndexOf('/') + 1);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// S1/S4: a folded group paints its header ALONE, so two checkouts with the same
|
|
584
|
+
// name would be two identical rows. A name that repeats among the drawn groups
|
|
585
|
+
// is qualified with its parent directory, which is what tells the twins apart;
|
|
586
|
+
// a unique name is left exactly as the checkout named it.
|
|
587
|
+
function labelHeaders(views) {
|
|
588
|
+
const counts = new Map();
|
|
589
|
+
for (const view of views) counts.set(view.name, (counts.get(view.name) || 0) + 1);
|
|
590
|
+
for (const view of views) {
|
|
591
|
+
if ((counts.get(view.name) || 0) < 2) continue;
|
|
592
|
+
const parent = parentSegment(view.root);
|
|
593
|
+
if (parent !== '') view.label = `${parent}/${view.name}`;
|
|
594
|
+
}
|
|
595
|
+
return views;
|
|
596
|
+
}
|
|
597
|
+
|
|
557
598
|
// S10/S13 (T9): the groups a frame actually draws, or null for the ordinary
|
|
558
599
|
// flat listing. The main group is ALWAYS drawn so every ODD of main stays
|
|
559
600
|
// reachable; a worktree group is drawn only while it still has documents after
|
|
@@ -569,10 +610,10 @@ function createOddView(options = {}) {
|
|
|
569
610
|
.map((group) => ({ group, list: filterAndOrder(group.docs) }))
|
|
570
611
|
.filter((entry) => entry.list.length > 0);
|
|
571
612
|
if (worktrees.length === 0) return null;
|
|
572
|
-
return [
|
|
613
|
+
return labelHeaders([
|
|
573
614
|
groupView(main, filterAndOrder(main.docs)),
|
|
574
615
|
...worktrees.map((entry) => groupView(entry.group, entry.list)),
|
|
575
|
-
];
|
|
616
|
+
]);
|
|
576
617
|
}
|
|
577
618
|
|
|
578
619
|
// S10 (T9): the rows a frame paints. Without groups every row is a document,
|
|
@@ -601,7 +642,12 @@ function createOddView(options = {}) {
|
|
|
601
642
|
// keeps the plain reader it always had.
|
|
602
643
|
function rowLabel(row) {
|
|
603
644
|
if (row.kind === 'header') {
|
|
604
|
-
|
|
645
|
+
const mark = row.group.folded ? GROUP_COLLAPSED_MARK : GROUP_EXPANDED_MARK;
|
|
646
|
+
// S4: the count rides the header, so a folded group still says how much it
|
|
647
|
+
// holds: `main (40 odd)`. It is the group's TOTAL, the same number the title
|
|
648
|
+
// sums, so the two can never disagree (a live query narrows the rows, never
|
|
649
|
+
// the count).
|
|
650
|
+
return `${mark} ${row.group.label} (${row.group.total} odd)`;
|
|
605
651
|
}
|
|
606
652
|
const label = row.doc && row.doc.label;
|
|
607
653
|
if (typeof label === 'string' && label.length > 0) return label;
|
|
@@ -646,14 +692,15 @@ function createOddView(options = {}) {
|
|
|
646
692
|
}
|
|
647
693
|
|
|
648
694
|
// S6/S10 (T9): the requested document becomes the selection inside whatever
|
|
649
|
-
// group holds it
|
|
650
|
-
//
|
|
651
|
-
//
|
|
652
|
-
//
|
|
695
|
+
// group holds it, and ITS group is the ONLY one expanded (odd-panel-groups S2):
|
|
696
|
+
// a panel opened from a sidebar ODD shows that ODD, with every other group
|
|
697
|
+
// folded. With no request (or an unknown one) nothing is expanded and the first
|
|
698
|
+
// HEADER opens, which is the folded listing's first row.
|
|
653
699
|
function mountIndex(request) {
|
|
654
700
|
const located = locateDocument(request);
|
|
655
701
|
if (located) {
|
|
656
|
-
|
|
702
|
+
expandedCheckouts.clear();
|
|
703
|
+
if (located.group) expandedCheckouts.add(checkoutGroupKey(located.group));
|
|
657
704
|
const at = rowOfDoc(documentKey(located.doc));
|
|
658
705
|
if (at >= 0) return at;
|
|
659
706
|
}
|
|
@@ -691,6 +738,12 @@ function createOddView(options = {}) {
|
|
|
691
738
|
return activeDocument();
|
|
692
739
|
}
|
|
693
740
|
|
|
741
|
+
// S1: whether the cursor stands on a group header (which holds no document).
|
|
742
|
+
function focusedHeader(rows) {
|
|
743
|
+
const row = rows[state.index] || null;
|
|
744
|
+
return row !== null && row.kind === 'header';
|
|
745
|
+
}
|
|
746
|
+
|
|
694
747
|
function renderLines(entry, text, width) {
|
|
695
748
|
entry.lines = renderOddMarkdown(text, {
|
|
696
749
|
width,
|
|
@@ -909,7 +962,7 @@ function createOddView(options = {}) {
|
|
|
909
962
|
if (at < 0) {
|
|
910
963
|
const located = locateDocument(focusedKey);
|
|
911
964
|
if (located && located.group) {
|
|
912
|
-
|
|
965
|
+
expandedCheckouts.add(checkoutGroupKey(located.group));
|
|
913
966
|
at = rowOfDoc(focusedKey);
|
|
914
967
|
}
|
|
915
968
|
}
|
|
@@ -938,11 +991,11 @@ function createOddView(options = {}) {
|
|
|
938
991
|
repaint();
|
|
939
992
|
}
|
|
940
993
|
|
|
941
|
-
// S10 (T9): Enter
|
|
942
|
-
// documents under it go, and so the focus stays where it was.
|
|
994
|
+
// S10 (T9): Enter opens or closes the focused checkout's group — the header
|
|
995
|
+
// stays, the documents under it come and go, and so the focus stays where it was.
|
|
943
996
|
function toggleFold(group) {
|
|
944
|
-
if (
|
|
945
|
-
else
|
|
997
|
+
if (expandedCheckouts.has(group.key)) expandedCheckouts.delete(group.key);
|
|
998
|
+
else expandedCheckouts.add(group.key);
|
|
946
999
|
const at = visibleRows().findIndex((row) => row.kind === 'header' && row.group.key === group.key);
|
|
947
1000
|
if (at >= 0) state.index = at;
|
|
948
1001
|
const win = layout.scrollWindow(listCosts(), {
|
|
@@ -1049,7 +1102,14 @@ function createOddView(options = {}) {
|
|
|
1049
1102
|
}
|
|
1050
1103
|
continue;
|
|
1051
1104
|
}
|
|
1052
|
-
|
|
1105
|
+
// S3: a document reads at the column its group NAME starts at, so the
|
|
1106
|
+
// disclosure chevron keeps a column of its own and the two rows line up
|
|
1107
|
+
// (`▾ main` over ` alpha`). The continuation prefix carries the same
|
|
1108
|
+
// indent, so a wrapped name stays under its own text. Only a GROUPED row
|
|
1109
|
+
// is indented: the flat listing has no header to line up with, and its
|
|
1110
|
+
// frames stay byte-identical.
|
|
1111
|
+
const indent = row.group ? CHILD_INDENT : '';
|
|
1112
|
+
const wrapped = labelRows(rowLabel(row), listWidth, `${focused ? '▸ ' : ' '}${indent}`, ` ${indent}`);
|
|
1053
1113
|
for (const line of wrapped) {
|
|
1054
1114
|
listLines.push(highlight(theme, pad(helpers, line, listWidth), focused));
|
|
1055
1115
|
}
|
|
@@ -1060,6 +1120,10 @@ function createOddView(options = {}) {
|
|
|
1060
1120
|
if (documentCount() === 0) {
|
|
1061
1121
|
contentLines.push(paint(theme, 'muted', EMPTY_LIST));
|
|
1062
1122
|
contentLines.push(paint(theme, 'dim', EMPTY_HINT));
|
|
1123
|
+
} else if (focusedHeader(rows) && state.query.trim() === '') {
|
|
1124
|
+
// S1: the panel opens on a HEADER now, which holds no document. The pane
|
|
1125
|
+
// says how to open one instead of claiming a filter matched nothing.
|
|
1126
|
+
contentLines.push(paint(theme, 'muted', FOLDED_HINT));
|
|
1063
1127
|
} else {
|
|
1064
1128
|
contentLines.push(paint(theme, 'muted', `(no matches for filter "${state.query}")`));
|
|
1065
1129
|
}
|