pi-odd-worktree 3.4.0 → 3.6.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 +3 -2
- package/extensions/odd-worktree-tools.ts +64 -3
- package/lib/depth-launch.js +70 -0
- package/lib/depth-prompt/depth.md +53 -0
- package/lib/depth-task.js +76 -0
- package/lib/files-index.js +99 -5
- package/lib/files-orders.js +1 -1
- package/lib/files-picker-view.js +45 -7
- package/lib/files-scope-detail.js +13 -6
- package/package.json +1 -1
- package/tools/depth-command.test.js +66 -0
- package/tools/depth-launch.test.js +123 -0
- package/tools/depth-task.test.js +76 -0
- package/tools/files-bridge.test.js +2 -2
- package/tools/files-command.test.js +117 -5
- package/tools/files-index.test.js +254 -13
- package/tools/files-orders.test.js +4 -4
- package/tools/files-picker-view.test.js +55 -2
- package/tools/files-scope-detail.test.js +6 -3
- package/tools/files-scope-view.test.js +3 -1
- package/tools/package-surface.test.js +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A Pi extension that gives an agent session worktrees, ODD documents and GitHub i
|
|
|
4
4
|
|
|
5
5
|
## What It Does
|
|
6
6
|
|
|
7
|
-
Two agent tools, four panels, one sidebar section 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 and issues without leaving Pi.
|
|
7
|
+
Two agent tools, four panels, one background-explorer command, one sidebar section 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 and issues without leaving Pi.
|
|
8
8
|
|
|
9
9
|
| Surface | Kind | What it does |
|
|
10
10
|
| --- | --- | --- |
|
|
@@ -14,6 +14,7 @@ Two agent tools, four panels, one sidebar section and two tool designs, loaded f
|
|
|
14
14
|
| `/odd` | panel | Reads this checkout's `odd/tasks/*.md`: list on the left, styled markdown on the right. |
|
|
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
16
|
| `/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. |
|
|
17
|
+
| `/depth` | command | Takes a request you type and starts one background `gentle-ai-explore` on it: what a top professional would do that you did not ask for, the raw material, the methods, and what outside the model would prove the result. The handoff — your request verbatim, how it was understood, a `path:line` map, proposals kept apart from the request, how it would be verified — arrives in the session. Edit its instructions in `lib/depth-prompt/depth.md`. |
|
|
17
18
|
| `GITHUB` rail section | sidebar section | Lists the open issues of this checkout's repository assigned to you, seven at a time plus a count of the rest; a click opens that issue in `/issues` on `Assigned` and the overflow row opens `/issues`. Needs `gh` and gentle-shell-bridge with its rail; without `gh` on `PATH` it is never added to the rail at all. |
|
|
18
19
|
| `activity` tags design | design on the bridge's `Card tags` line | Optional: `/gentle:customize` → `Cards` → `Card tags`, with `default` (the host's own card) and `activity`, which is selected for you on the first run. It covers `bash`, the read-only shell tools `grep`, `find`, `ls`, and `read`, `write` and `edit`: a bash card's heading names what the command does, each family in its own theme colour (`⌕ exploring`, `✓ checking`, …; an unnamed command reads `$ bash`), those three are always `⌕ exploring`, and a `read` — which runs no shell command — is left exactly as the host drew it. `read`, `write` and `edit` are covered so that the file card can ask about them too, `write` and `edit` through a scope limited to skill and ODD paths (gentle-shell-bridge 0.9.0): the design draws nothing of its own for any of the three, so a read, a write or an edit on a skill or an ODD artifact is the file card's row and everything else stays the host's. A finished call shows its duration on the closing rule and the frame turns `warning` while the call runs and `error` when it fails. Needs gentle-shell-bridge 0.6.0 or newer for the one `Card tags` row over the six tools, and 0.9.0 for `edit` and the scope that claims a write or an edit; on 0.5.0 the row is `Card bash`, covers bash alone and keeps everything above for bash cards. Registered through gentle-shell-bridge's `registerToolDesign`; the bridge owns the choice, remembers it and repaints cards already on screen. |
|
|
19
20
|
| `color` diff design | design on the bridge's `Card diff` line | Optional: `/gentle:customize` → `Cards` → `Card diff`, with `default` (the host's own card) and `color`, which is selected for you on the first run. It covers `write` and `edit` and redraws them as an IDE pane: a write's content behind a line-number gutter, and an edit's diff, both in the active theme's own syntax roles from Pi's highlighter — the same one `/files` previews with. A write or an edit on a skill or an ODD artifact stays the file card's row, because the `Card tags` line claims exactly those calls and a specific claim wins over this generic one. Needs gentle-shell-bridge 0.9.0 or newer; on anything older nothing is registered and `Card diff` never appears. |
|
|
@@ -49,7 +50,7 @@ gentle-shell install npm:pi-odd-worktree
|
|
|
49
50
|
|
|
50
51
|
From a local clone, `pi install .` installs the working copy, and `gentle-shell install .` does the same from inside a Gentle Shell session.
|
|
51
52
|
|
|
52
|
-
Expected result: `/warp`, `/odd`, `/files` and `/
|
|
53
|
+
Expected result: `/warp`, `/odd`, `/files`, `/issues` and `/depth` are available as commands — `/issues` only where `gh` is on `PATH` — the agent is offered `worktree_create` and `worktree_list`, a Gentle Shell whose `gentle-shell-bridge` is installed and whose rail is drawn shows a `GITHUB` section for this checkout, and its `/gentle:customize` → `Cards` page offers `activity` on its `Card tags` line — `Card bash` on a bridge older than 0.6.0.
|
|
53
54
|
|
|
54
55
|
## Core Workflow
|
|
55
56
|
|
|
@@ -6815,6 +6815,33 @@ function registerOddCommand(pi) {
|
|
|
6815
6815
|
});
|
|
6816
6816
|
}
|
|
6817
6817
|
|
|
6818
|
+
// ---------------------------------------------------------------------------
|
|
6819
|
+
// `/depth <request>` (depth-command S1-S8): the fifth command. It starts ONE background
|
|
6820
|
+
// `gentle-ai-explore` through the host's own `subagent_run` tool, with the Depth
|
|
6821
|
+
// instructions of `lib/depth-prompt/depth.md` and the request verbatim, and answers with
|
|
6822
|
+
// one notice. Everything after the start is gentle-agents' — the progress, the cancel and
|
|
6823
|
+
// the handoff that lands in the session — so the command draws nothing, keeps no state,
|
|
6824
|
+
// registers no key and spawns no child of its own (`lib/depth-launch.js`).
|
|
6825
|
+
// ---------------------------------------------------------------------------
|
|
6826
|
+
|
|
6827
|
+
function registerDepthCommand(pi) {
|
|
6828
|
+
if (typeof pi?.registerCommand !== "function") return;
|
|
6829
|
+
pi.registerCommand("depth", {
|
|
6830
|
+
description: "Understand a request in depth and explore it in the background; the handoff arrives in this session",
|
|
6831
|
+
handler: async (args, ctx) => {
|
|
6832
|
+
let outcome;
|
|
6833
|
+
try {
|
|
6834
|
+
outcome = await libRequire("depth-launch.js").launchDepth(typeof args === "string" ? args : "", ctx);
|
|
6835
|
+
} catch (error) {
|
|
6836
|
+
outcome = { level: "error", message: `/depth failed: ${error instanceof Error ? error.message : String(error)}` };
|
|
6837
|
+
}
|
|
6838
|
+
try {
|
|
6839
|
+
if (ctx && ctx.ui && typeof ctx.ui.notify === "function") ctx.ui.notify(outcome.message, outcome.level);
|
|
6840
|
+
} catch {}
|
|
6841
|
+
},
|
|
6842
|
+
});
|
|
6843
|
+
}
|
|
6844
|
+
|
|
6818
6845
|
// ---------------------------------------------------------------------------
|
|
6819
6846
|
// `/files` (T7: S9, S14, S17): the file picker over one checkout of this clone.
|
|
6820
6847
|
//
|
|
@@ -6962,7 +6989,11 @@ async function filesCheckouts(cwd) {
|
|
|
6962
6989
|
} catch {
|
|
6963
6990
|
// Git's own spelling is all it answered.
|
|
6964
6991
|
}
|
|
6965
|
-
|
|
6992
|
+
// S2: the branch a worktree's badges are measured against is the branch the
|
|
6993
|
+
// PRINCIPAL checkout has, whatever it is called — a repository on `master`
|
|
6994
|
+
// must not end up comparing against a `main` that does not exist.
|
|
6995
|
+
const mainBranch = main && typeof main.branch === 'string' && main.branch.length > 0 ? main.branch : null;
|
|
6996
|
+
return { repo, mainRoot, mainBranch, entries };
|
|
6966
6997
|
}
|
|
6967
6998
|
|
|
6968
6999
|
// S9: the ODD directory IS a checkout's identity in this package (invariant 12),
|
|
@@ -7004,6 +7035,7 @@ function filesAllWorktrees(checkouts) {
|
|
|
7004
7035
|
root: entry.path,
|
|
7005
7036
|
kind: 'worktree',
|
|
7006
7037
|
label: filesWorktreeLabel(entry.path, entry.branch),
|
|
7038
|
+
base: checkouts.mainBranch,
|
|
7007
7039
|
});
|
|
7008
7040
|
}
|
|
7009
7041
|
return others;
|
|
@@ -7017,10 +7049,29 @@ function filesAllWorktrees(checkouts) {
|
|
|
7017
7049
|
* local `main` for every worktree. A read that failed leaves its fields absent, so
|
|
7018
7050
|
* the step paints less instead of claiming a zero nobody measured.
|
|
7019
7051
|
*/
|
|
7052
|
+
/**
|
|
7053
|
+
* S1/S2: how a scope's change badges are read. The principal checkout answers
|
|
7054
|
+
* from its own `git status`, so a commit there clears the badge; a worktree
|
|
7055
|
+
* answers from the commits it has ahead of the principal branch, so a commit is
|
|
7056
|
+
* what MARKS the file. The comparison is the same one the `±`/`↑`/`↓` line uses
|
|
7057
|
+
* (`lib/files-scope-detail.js`), so the scope row and the picker's rows can never
|
|
7058
|
+
* disagree about what the branch changed.
|
|
7059
|
+
*/
|
|
7060
|
+
function filesComparison(detailLib, scope) {
|
|
7061
|
+
if (!scope || scope.kind !== 'worktree') return undefined;
|
|
7062
|
+
// The principal checkout's own branch when Git reported one, and the package's
|
|
7063
|
+
// conventional `main` when the principal checkout is detached.
|
|
7064
|
+
return typeof scope.base === 'string' && scope.base.length > 0 ? scope.base : detailLib.LOCAL_MAIN;
|
|
7065
|
+
}
|
|
7066
|
+
|
|
7020
7067
|
async function filesScopeFacts(index, detailLib, run, scope) {
|
|
7021
7068
|
const facts = {};
|
|
7022
7069
|
try {
|
|
7023
|
-
const listing = await index.listRepositoryEntries({
|
|
7070
|
+
const listing = await index.listRepositoryEntries({
|
|
7071
|
+
run,
|
|
7072
|
+
cwd: scope.root,
|
|
7073
|
+
comparison: filesComparison(detailLib, scope),
|
|
7074
|
+
});
|
|
7024
7075
|
if (listing && listing.ok === true && Array.isArray(listing.entries)) {
|
|
7025
7076
|
let changed = 0;
|
|
7026
7077
|
let newest;
|
|
@@ -7118,6 +7169,7 @@ function filesSessionScopes(checkouts, cwd, registeredRoots) {
|
|
|
7118
7169
|
root: entry.path,
|
|
7119
7170
|
kind: 'worktree',
|
|
7120
7171
|
label: filesWorktreeLabel(entry.path, entry.branch),
|
|
7172
|
+
base: checkouts.mainBranch,
|
|
7121
7173
|
});
|
|
7122
7174
|
}
|
|
7123
7175
|
return scopes;
|
|
@@ -7236,6 +7288,9 @@ async function mountFilesPicker(ctx, input) {
|
|
|
7236
7288
|
const index = libRequire('files-index.js');
|
|
7237
7289
|
const insertLib = libRequire('files-insert.js');
|
|
7238
7290
|
const pickerView = libRequire('files-picker-view.js');
|
|
7291
|
+
// The same module the scope step reads its comparison from, so the badges and
|
|
7292
|
+
// the `↑n main` line are measured against one branch (S1, S2).
|
|
7293
|
+
const scopeLib = libRequire('files-scope-detail.js');
|
|
7239
7294
|
const run = filesRunner(libRequire('worktree-git.js'));
|
|
7240
7295
|
const agent = await filesAgentSeam();
|
|
7241
7296
|
const scope = input.scope;
|
|
@@ -7270,7 +7325,11 @@ async function mountFilesPicker(ctx, input) {
|
|
|
7270
7325
|
cwd: input.cwd,
|
|
7271
7326
|
// The listing and the preview are the T1 reader's own, read from the scope
|
|
7272
7327
|
// root rather than the session cwd: the picker browses another checkout.
|
|
7273
|
-
loadEntries: () => index.listRepositoryEntries({
|
|
7328
|
+
loadEntries: () => index.listRepositoryEntries({
|
|
7329
|
+
run,
|
|
7330
|
+
cwd: scope.root,
|
|
7331
|
+
comparison: filesComparison(scopeLib, scope),
|
|
7332
|
+
}),
|
|
7274
7333
|
loadPreview: (relative) => index.readFilePreview(scope.root, relative),
|
|
7275
7334
|
...(agent.highlight === undefined ? {} : { highlight: agent.highlight }),
|
|
7276
7335
|
...(agent.languageForPath === undefined ? {} : { languageForPath: agent.languageForPath }),
|
|
@@ -9738,6 +9797,8 @@ function registerOddWorktreeSurfaceEntries(pi) {
|
|
|
9738
9797
|
// picker's — bound after its command exists, and therefore never when the
|
|
9739
9798
|
// `gh`-absent gate left that command unregistered.
|
|
9740
9799
|
bindIssuesShortcut(pi);
|
|
9800
|
+
// depth-command S6: the fifth command, `/depth`.
|
|
9801
|
+
registerDepthCommand(pi);
|
|
9741
9802
|
pi.registerTool(worktreeCreateTool);
|
|
9742
9803
|
pi.registerTool(worktreeListTool);
|
|
9743
9804
|
if (typeof pi?.on !== "function") return;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// `/depth`'s launch (S4, S5, S8): ONE background `gentle-ai-explore`, started through the host's own `subagent_run` tool
|
|
3
|
+
// with the Depth task of `lib/depth-task.js` and nothing else.
|
|
4
|
+
//
|
|
5
|
+
// Everything after the start belongs to gentle-agents, which this package never imports: it draws the progress, owns the
|
|
6
|
+
// cancel and, when the explorer finishes, sends its answer to the session as a message that starts a turn. So this module
|
|
7
|
+
// has no widget, no timer and no message of its own. It decides whether the launch can happen and answers in one sentence
|
|
8
|
+
// what did or did not.
|
|
9
|
+
//
|
|
10
|
+
// The host API is `ctx.executeTool(name, args)`, which never rejects for a tool failure — an unknown tool, a refused call
|
|
11
|
+
// and a thrown error all come back as `isError: true` — and `ctx.tools`, which lists what it can call (the same contract
|
|
12
|
+
// `lib/session-worktree-register.js` documents). `subagent_run` rejects any key outside its schema, so the arguments are
|
|
13
|
+
// exactly `agent`, `task`, `label` and `mode`.
|
|
14
|
+
//
|
|
15
|
+
// Never throws, never rejects.
|
|
16
|
+
|
|
17
|
+
const { buildDepthTask, depthLabel } = require('./depth-task.js');
|
|
18
|
+
|
|
19
|
+
const DEPTH_AGENT = 'gentle-ai-explore';
|
|
20
|
+
const DEPTH_TOOL = 'subagent_run';
|
|
21
|
+
|
|
22
|
+
function refuse(message) {
|
|
23
|
+
return { ok: false, level: 'error', message };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function toolAvailable(ctx) {
|
|
27
|
+
try {
|
|
28
|
+
if (!ctx || typeof ctx.executeTool !== 'function') return false;
|
|
29
|
+
const tools = ctx.tools;
|
|
30
|
+
return Array.isArray(tools) && tools.some((tool) => tool && tool.name === DEPTH_TOOL);
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// The words the host tool answered with, so a refusal reads in its own sentence.
|
|
37
|
+
function outcomeText(outcome) {
|
|
38
|
+
const parts = outcome && Array.isArray(outcome.content) ? outcome.content : [];
|
|
39
|
+
return parts
|
|
40
|
+
.map((part) => (part && part.type === 'text' && typeof part.text === 'string' ? part.text.trim() : ''))
|
|
41
|
+
.filter((text) => text.length > 0)
|
|
42
|
+
.join(' ');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function couldNotStart(detail) {
|
|
46
|
+
return refuse(`/depth couldn't start the explorer: ${detail}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function launchDepth(request, ctx) {
|
|
50
|
+
const task = buildDepthTask(request);
|
|
51
|
+
if (task === null) {
|
|
52
|
+
return refuse('/depth needs a request: /depth <request>. The explorer does not see this chat, so put everything it needs in the request.');
|
|
53
|
+
}
|
|
54
|
+
if (!toolAvailable(ctx)) {
|
|
55
|
+
return refuse(`/depth starts a ${DEPTH_AGENT} subagent through the ${DEPTH_TOOL} tool, and this session does not offer it.`);
|
|
56
|
+
}
|
|
57
|
+
const label = depthLabel(request);
|
|
58
|
+
let outcome;
|
|
59
|
+
try {
|
|
60
|
+
outcome = await ctx.executeTool(DEPTH_TOOL, { agent: DEPTH_AGENT, task, label, mode: 'background' });
|
|
61
|
+
} catch (error) {
|
|
62
|
+
return couldNotStart(error instanceof Error ? error.message : String(error));
|
|
63
|
+
}
|
|
64
|
+
if (!outcome || outcome.isError === true) {
|
|
65
|
+
return couldNotStart(outcomeText(outcome) || `the ${DEPTH_TOOL} tool reported an error.`);
|
|
66
|
+
}
|
|
67
|
+
return { ok: true, level: 'info', message: `Exploring in the background (${label}). The handoff arrives in this session when it finishes.` };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = { DEPTH_AGENT, DEPTH_TOOL, launchDepth };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
You are doing a Depth pass on the request in `## Request`, the last section of this task. You are read-only, you have no chat history, and you cannot ask the human anything: the request is everything they said. First find and read the code, files, docs and logs it touches, so every answer rests on them.
|
|
2
|
+
|
|
3
|
+
I want a deeper version of this request, not a bigger one. Answer these four questions from what you found, not from what a request like this usually needs:
|
|
4
|
+
|
|
5
|
+
(1) What would a top professional in this field do here that the request does not ask for?
|
|
6
|
+
(2) What is the rawest material they would start from, instead of what has already been digested?
|
|
7
|
+
(3) What specific methods and tools would they use?
|
|
8
|
+
(4) What, other than you or the human, would show the result is right?
|
|
9
|
+
|
|
10
|
+
Take the professional's method, not their voice: do what they do, do not write like them.
|
|
11
|
+
|
|
12
|
+
## How to work
|
|
13
|
+
|
|
14
|
+
1. Read the source, not summaries of it, whenever the source is reachable. Search the project and the paths the request names.
|
|
15
|
+
2. Match the effort to the request. A small, specific request gets a short handoff, a line per section. A section with nothing to say says `none`.
|
|
16
|
+
3. You cannot run commands. Where the raw material needs something to be run (a test, a reproduction, a log), give the exact command and say it was not run. Never claim a result you did not observe.
|
|
17
|
+
4. For (4), name only oracles that something outside you can execute: an existing test, a command, a type check, a file to compare. Cite `path:line` where one exists. "Review it" and "double-check it" are not oracles.
|
|
18
|
+
5. Everything the request does not ask for, which is most of (1) to (3), goes only under `## Not requested`. Tag each item `[evidencia: path:line]` when you found its basis in the project, or `[inferido]` when it is your judgement. These are proposals for the human to accept or drop: never a requirement, and never part of `## Understood`.
|
|
19
|
+
6. `## Understood` adds nothing the request does not say. If the request can reasonably be read two materially different ways, do not pick one silently: say which reading you used there, and put the questions for the human under `## Questions`. Otherwise `## Questions` says `none`.
|
|
20
|
+
|
|
21
|
+
Never carry the request out. Do not edit files or start work; you only read and report.
|
|
22
|
+
|
|
23
|
+
## Return
|
|
24
|
+
|
|
25
|
+
Reply in the language of the request, in at most ~2k tokens. Start with this line, unchanged:
|
|
26
|
+
|
|
27
|
+
**/depth handoff: read-only exploration, nothing was implemented.**
|
|
28
|
+
|
|
29
|
+
Then give exactly these headings, in this order, each alone on its line. Copy each heading character for character: the names stay in English whatever the language of the request, and translating one is an error. Do not drop a section; a section with nothing to say says `none`. The last section, `## For the parent`, is required: without it the main session may start implementing.
|
|
30
|
+
|
|
31
|
+
## Original request
|
|
32
|
+
The text under `## Request`, copied unchanged.
|
|
33
|
+
|
|
34
|
+
## Understood
|
|
35
|
+
The request as you read it, from what you found. Nothing the request does not say.
|
|
36
|
+
|
|
37
|
+
## Questions
|
|
38
|
+
Questions for the human, or `none`.
|
|
39
|
+
|
|
40
|
+
## Map
|
|
41
|
+
The relevant files, symbols and how they relate, each with `path:line`. No file contents.
|
|
42
|
+
|
|
43
|
+
## Not requested
|
|
44
|
+
What a top professional would add or do differently, from (1) to (3), each tagged as rule 5 says.
|
|
45
|
+
|
|
46
|
+
## How it would be verified
|
|
47
|
+
From (4): the external oracles, by rule 4.
|
|
48
|
+
|
|
49
|
+
## Uncertainty
|
|
50
|
+
What you could not settle, and what you did not read.
|
|
51
|
+
|
|
52
|
+
## For the parent
|
|
53
|
+
Copy this paragraph unchanged: Do not implement this request. If `## Questions` is not `none`, ask the human those questions first. Show `## Not requested` to the human and wait for them to accept or drop each item before anything is added to a spec.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// The task `/depth` hands the `gentle-ai-explore` subagent (S1, S3, S4, S8).
|
|
3
|
+
//
|
|
4
|
+
// The text is the instructions in `lib/depth-prompt/depth.md` — one Markdown file, so it can be read and edited as
|
|
5
|
+
// prose — followed by the request exactly as the person typed it. The explorer starts with no chat, so the request is
|
|
6
|
+
// the only thing it will ever know of the person's words; the instructions make it the first section of the handoff.
|
|
7
|
+
//
|
|
8
|
+
// The file is read on every call, so an edit applies to the next `/depth` with no reload. A missing or empty file falls
|
|
9
|
+
// back to a short built-in task that still names every return section, the way the prompt blocks of this package fall
|
|
10
|
+
// back to their heading: the command never fails because prose could not be read. Pure apart from that one read, and
|
|
11
|
+
// it never throws.
|
|
12
|
+
|
|
13
|
+
const fs = require('node:fs');
|
|
14
|
+
const path = require('node:path');
|
|
15
|
+
|
|
16
|
+
const DEPTH_FILE = path.join(__dirname, 'depth-prompt', 'depth.md');
|
|
17
|
+
const REQUEST_HEADING = '## Request';
|
|
18
|
+
|
|
19
|
+
// The handoff's sections in order. The parent reads this contract, so the names are fixed and in English whatever the
|
|
20
|
+
// language of the request; `tools/depth-task.test.js` holds the shipped file to them.
|
|
21
|
+
const DEPTH_RETURN_HEADINGS = Object.freeze([
|
|
22
|
+
'## Original request',
|
|
23
|
+
'## Understood',
|
|
24
|
+
'## Questions',
|
|
25
|
+
'## Map',
|
|
26
|
+
'## Not requested',
|
|
27
|
+
'## How it would be verified',
|
|
28
|
+
'## Uncertainty',
|
|
29
|
+
'## For the parent',
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
// The two lines that keep the parent from implementing. The parent wakes on the handoff alone, so the opening line and the
|
|
33
|
+
// closing paragraph both ask for it; `lib/depth-prompt/depth.md` carries the same text and the suite holds the two in step.
|
|
34
|
+
const DEPTH_BANNER = '**/depth handoff: read-only exploration, nothing was implemented.**';
|
|
35
|
+
const DEPTH_FOR_PARENT = 'Do not implement this request. If `## Questions` is not `none`, ask the human those questions first. Show `## Not requested` to the human and wait for them to accept or drop each item before anything is added to a spec.';
|
|
36
|
+
|
|
37
|
+
const FALLBACK = [
|
|
38
|
+
'Do a Depth pass on the request in `## Request`: find and read what it touches, then say what a top professional would do that it does not ask for, the rawest material they would start from, their methods and tools, and what outside you would show the result is right. A deeper version, not a bigger one.',
|
|
39
|
+
'Never carry the request out. You only read and report.',
|
|
40
|
+
`Start your reply with this line, unchanged:\n\n${DEPTH_BANNER}`,
|
|
41
|
+
`Then give exactly these headings, in this order, copied character for character:\n\n${DEPTH_RETURN_HEADINGS.join('\n\n')}`,
|
|
42
|
+
`Under \`## For the parent\`, copy this paragraph unchanged: ${DEPTH_FOR_PARENT}`,
|
|
43
|
+
].join('\n\n');
|
|
44
|
+
|
|
45
|
+
function readDepthFile() {
|
|
46
|
+
return fs.readFileSync(DEPTH_FILE, 'utf8');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function instructions(read) {
|
|
50
|
+
try {
|
|
51
|
+
const text = read();
|
|
52
|
+
return typeof text === 'string' && text.trim().length > 0 ? text.trim() : FALLBACK;
|
|
53
|
+
} catch {
|
|
54
|
+
return FALLBACK;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// The task for one request, or `null` when there is no request to explore.
|
|
59
|
+
function buildDepthTask(request, { read = readDepthFile } = {}) {
|
|
60
|
+
if (typeof request !== 'string' || request.trim().length === 0) return null;
|
|
61
|
+
return `${instructions(read)}\n\n${REQUEST_HEADING}\n\n${request.trim()}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const LABEL_PREFIX = 'depth: ';
|
|
65
|
+
const LABEL_MAX = 60;
|
|
66
|
+
|
|
67
|
+
// The one-line name the agents card shows for the task.
|
|
68
|
+
function depthLabel(request) {
|
|
69
|
+
if (typeof request !== 'string') return 'depth';
|
|
70
|
+
const first = request.split('\n').map((line) => line.replace(/\s+/g, ' ').trim()).find((line) => line.length > 0);
|
|
71
|
+
if (first === undefined) return 'depth';
|
|
72
|
+
const room = LABEL_MAX - LABEL_PREFIX.length;
|
|
73
|
+
return `${LABEL_PREFIX}${first.length > room ? `${first.slice(0, room - 1)}…` : first}`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = { DEPTH_FILE, DEPTH_RETURN_HEADINGS, DEPTH_BANNER, DEPTH_FOR_PARENT, buildDepthTask, depthLabel };
|
package/lib/files-index.js
CHANGED
|
@@ -18,10 +18,20 @@
|
|
|
18
18
|
// ever parsing it. Outside a repository the listing fails and the failure is a
|
|
19
19
|
// sentence a panel can paint, never an empty success.
|
|
20
20
|
//
|
|
21
|
-
// Change state (S6) comes from one
|
|
21
|
+
// Change state (S6) comes from two reads, one per scope kind. The principal
|
|
22
|
+
// checkout is marked from a single `git status --porcelain=v1 -z
|
|
22
23
|
// --untracked-files=all`: `??` is `new` (untracked), any other record is
|
|
23
|
-
// `
|
|
24
|
-
// `clean`.
|
|
24
|
+
// `modified` (tracked and dirty), and a file the status does not name is
|
|
25
|
+
// `clean`. A worktree is marked from its own work instead (S2): one
|
|
26
|
+
// `git diff --name-status -z -M <principal>...HEAD` names every path the branch
|
|
27
|
+
// changed ahead of the principal branch, with its net state — `A` when the
|
|
28
|
+
// merge-base does not have the path, `M` when it does — so committing a
|
|
29
|
+
// worktree no longer erases the badges. The two sets are unioned (S4): a path
|
|
30
|
+
// the commits already named keeps that state, and the worktree's uncommitted
|
|
31
|
+
// work still marks the rest. A path the commits deleted is dropped, because a
|
|
32
|
+
// file that is gone has no row to paint (S5).
|
|
33
|
+
//
|
|
34
|
+
// Change state carries no time, so the ages come from a stat under the
|
|
25
35
|
// repository root Git reports — `git rev-parse --show-toplevel`, never
|
|
26
36
|
// `process.cwd()`, because the picker browses another checkout than the one the
|
|
27
37
|
// process happens to sit in. An unreadable root or file leaves the timestamp
|
|
@@ -59,8 +69,32 @@ const STATUS_ARGS = Object.freeze([
|
|
|
59
69
|
// cwd because the picker can browse another checkout.
|
|
60
70
|
const ROOT_ARGS = Object.freeze(['rev-parse', '--show-toplevel']);
|
|
61
71
|
|
|
72
|
+
// S2: a worktree's own work is the record of what its branch changed ahead of
|
|
73
|
+
// the principal branch. Three dots compare against the merge-base, so a `main`
|
|
74
|
+
// that moved on since the fork is never read as this branch's work, and a path
|
|
75
|
+
// named by several commits arrives once, already deduplicated, with its net
|
|
76
|
+
// state (S3). `-z` for the same reason as every other read.
|
|
77
|
+
//
|
|
78
|
+
// The ref is spelled out as `refs/heads/<branch>` on purpose: a bare `main` is
|
|
79
|
+
// ambiguous the moment a tag or a remote of that name exists, and a checkout
|
|
80
|
+
// holding an ordinary file called `main...HEAD` makes the whole read fail. The
|
|
81
|
+
// trailing `--` says the argument list ends before any path could start.
|
|
82
|
+
// `--no-renames` keeps the read READ-ONLY: similarity detection is what makes
|
|
83
|
+
// Git fetch a missing blob in a partial clone and write a pack, and the net
|
|
84
|
+
// state does not need it — an undetected rename is delete plus add, and the
|
|
85
|
+
// delete is a path that gets no row anyway.
|
|
86
|
+
const commitArgs = (comparison) => [
|
|
87
|
+
'diff',
|
|
88
|
+
'--name-status',
|
|
89
|
+
'-z',
|
|
90
|
+
'--no-renames',
|
|
91
|
+
`refs/heads/${comparison}...HEAD`,
|
|
92
|
+
'--',
|
|
93
|
+
];
|
|
94
|
+
|
|
62
95
|
const FILES_ERROR = 'Cannot list repository files';
|
|
63
96
|
const CHANGES_ERROR = 'Cannot read repository changes';
|
|
97
|
+
const COMMITS_ERROR = "Cannot read the branch's commits";
|
|
64
98
|
|
|
65
99
|
const MINUTE = 60_000;
|
|
66
100
|
const HOUR = 3_600_000;
|
|
@@ -144,6 +178,13 @@ function changesFailure(failure, cwd) {
|
|
|
144
178
|
};
|
|
145
179
|
}
|
|
146
180
|
|
|
181
|
+
function commitsFailure(failure, cwd) {
|
|
182
|
+
return {
|
|
183
|
+
ok: false,
|
|
184
|
+
message: failure.notRepository ? notRepositoryMessage(cwd) : sentence(`${COMMITS_ERROR}: ${failure.detail}`),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
147
188
|
/** Repository-relative POSIX paths; a failed listing is a failure, never an empty success. */
|
|
148
189
|
async function listRepositoryFiles(input = {}) {
|
|
149
190
|
const run = input && input.run;
|
|
@@ -170,12 +211,49 @@ function parseStatus(stdout) {
|
|
|
170
211
|
if (typeof record !== 'string' || record.length < 4) continue;
|
|
171
212
|
const code = record.slice(0, 2);
|
|
172
213
|
const filePath = record.slice(3);
|
|
173
|
-
if (filePath.length > 0) states.set(filePath, code === '??' ? 'new' : '
|
|
214
|
+
if (filePath.length > 0) states.set(filePath, code === '??' ? 'new' : 'modified');
|
|
174
215
|
if (code[0] === 'R' || code[0] === 'C') index += 1;
|
|
175
216
|
}
|
|
176
217
|
return states;
|
|
177
218
|
}
|
|
178
219
|
|
|
220
|
+
// S3: `<letter>\0<path>\0` records, NUL terminated. `--no-renames` means the
|
|
221
|
+
// read produces `A`/`M`/`D`/`T` only, so a rename arrives as its two halves; a
|
|
222
|
+
// rename or copy record is still parsed (`<status>\0<original>\0<path>\0`, the
|
|
223
|
+
// original first) in case a caller ever turns detection back on, and the path the
|
|
224
|
+
// record is ABOUT is always the last field it carries. `A` is a path the
|
|
225
|
+
// merge-base does not have; anything else that is not a delete is `modified`. A
|
|
226
|
+
// delete maps to `deleted` so the caller drops it deliberately instead of relying
|
|
227
|
+
// on the path being absent.
|
|
228
|
+
function parseNameStatus(stdout) {
|
|
229
|
+
const states = new Map();
|
|
230
|
+
const fields = stdout.split('\0');
|
|
231
|
+
for (let index = 0; index < fields.length; index += 1) {
|
|
232
|
+
const record = fields[index];
|
|
233
|
+
if (typeof record !== 'string' || record.length === 0) continue;
|
|
234
|
+
const letter = record[0];
|
|
235
|
+
const carried = letter === 'R' || letter === 'C';
|
|
236
|
+
const filePath = fields[index + (carried ? 2 : 1)];
|
|
237
|
+
index += carried ? 2 : 1;
|
|
238
|
+
if (typeof filePath !== 'string' || filePath.length === 0) continue;
|
|
239
|
+
if (letter === 'D') states.set(filePath, 'deleted');
|
|
240
|
+
else if (letter === 'A' || carried) states.set(filePath, 'added');
|
|
241
|
+
else states.set(filePath, 'modified');
|
|
242
|
+
}
|
|
243
|
+
return states;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// The worktree half of the change read (S2, S5): the one name-status diff, with
|
|
247
|
+
// every deleted path dropped. Never throws; a failure comes back as
|
|
248
|
+
// `{ok:false}` so the caller paints one sentence instead of half a listing.
|
|
249
|
+
async function listCommitChanges(run, cwd, comparison) {
|
|
250
|
+
const named = await runGit(run, commitArgs(comparison), cwd);
|
|
251
|
+
if (named.ok !== true) return { ok: false, failure: named };
|
|
252
|
+
const states = parseNameStatus(named.stdout);
|
|
253
|
+
for (const [filePath, state] of states) if (state === 'deleted') states.delete(filePath);
|
|
254
|
+
return { ok: true, states };
|
|
255
|
+
}
|
|
256
|
+
|
|
179
257
|
async function repositoryRoot(run, cwd) {
|
|
180
258
|
const resolved = await runGit(run, ROOT_ARGS, cwd);
|
|
181
259
|
if (resolved.ok !== true) return undefined;
|
|
@@ -219,17 +297,33 @@ function clockMs(now) {
|
|
|
219
297
|
* The picker's rows: the same file set as `listRepositoryFiles`, changed files
|
|
220
298
|
* first and newest first, then untouched files by path. Each changed row carries
|
|
221
299
|
* its state, its mtime and the age label computed from the injected `now`.
|
|
300
|
+
*
|
|
301
|
+
* `comparison` selects how the states are read (S2, S4): omitted or empty, the
|
|
302
|
+
* principal checkout's own `git status`; the name of the principal BRANCH, the
|
|
303
|
+
* branch's net diff against the merge-base with it (`refs/heads/<branch>`),
|
|
304
|
+
* unioned with the status so uncommitted work is still marked. The commit state
|
|
305
|
+
* wins where both name a path.
|
|
222
306
|
*/
|
|
223
307
|
async function listRepositoryEntries(input = {}) {
|
|
224
308
|
const run = input && input.run;
|
|
225
309
|
const cwd = input && input.cwd;
|
|
226
310
|
const listing = await listRepositoryFiles({ run, cwd });
|
|
227
311
|
if (listing.ok !== true) return { ok: false, message: listing.message };
|
|
312
|
+
const comparison = input && typeof input.comparison === 'string' ? input.comparison.trim() : '';
|
|
313
|
+
let committed = new Map();
|
|
314
|
+
if (comparison.length > 0) {
|
|
315
|
+
const read = await listCommitChanges(run, cwd, comparison);
|
|
316
|
+
if (read.ok !== true) return commitsFailure(read.failure, cwd);
|
|
317
|
+
committed = read.states;
|
|
318
|
+
}
|
|
228
319
|
const status = await runGit(run, STATUS_ARGS, cwd);
|
|
229
320
|
if (status.ok !== true) {
|
|
230
321
|
return changesFailure(status, cwd);
|
|
231
322
|
}
|
|
232
|
-
const states =
|
|
323
|
+
const states = new Map(committed);
|
|
324
|
+
for (const [filePath, state] of parseStatus(status.stdout)) {
|
|
325
|
+
if (!states.has(filePath)) states.set(filePath, state);
|
|
326
|
+
}
|
|
233
327
|
const changedPaths = listing.files.filter((filePath) => states.has(filePath));
|
|
234
328
|
const root = changedPaths.length > 0 ? await repositoryRoot(run, cwd) : undefined;
|
|
235
329
|
const nowMs = clockMs(input && input.now);
|
package/lib/files-orders.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
// direction S40's legend paints.
|
|
23
23
|
//
|
|
24
24
|
// Entry shape is the listing seam's (lib/files-index.js): `{ path, state:
|
|
25
|
-
// "
|
|
25
|
+
// "added" | "modified" | "new" | "clean", mtimeMs? }`, already changed-first by recency
|
|
26
26
|
// then clean. `files` re-applies that rule here so the order is the module's own,
|
|
27
27
|
// not a property of the caller's array.
|
|
28
28
|
|
package/lib/files-picker-view.js
CHANGED
|
@@ -104,8 +104,7 @@ const CLOSE_HINT = 'esc';
|
|
|
104
104
|
const HINT_COLUMNS = CLOSE_HINT.length + 2;
|
|
105
105
|
const TITLE_SEPARATOR_COLUMNS = 3;
|
|
106
106
|
// The fewest columns a left-elided path is worth painting beside the title.
|
|
107
|
-
const MIN_DETAIL_COLUMNS = 4;
|
|
108
|
-
const BODY_RULE_ROWS = 1;
|
|
107
|
+
const MIN_DETAIL_COLUMNS = 4;const BODY_RULE_ROWS = 1;
|
|
109
108
|
const MIN_CARD_HEIGHT = CHROME_ROWS + 1;
|
|
110
109
|
const MIN_WIDTH = 20;
|
|
111
110
|
// 0-based row of the first body row: the top rule, the search row and the info row.
|
|
@@ -139,6 +138,14 @@ const LOADING_PREVIEW = 'Loading preview \u2026';
|
|
|
139
138
|
const NO_FILES = 'No files in this repository.';
|
|
140
139
|
const UNTRACKED_BADGE = 'U';
|
|
141
140
|
const MODIFIED_BADGE = 'M';
|
|
141
|
+
const ADDED_BADGE = 'A';
|
|
142
|
+
// S44: the title's ahead field — the scope step's own glyph, and the separator the
|
|
143
|
+
// card's heading uses between its name and its detail.
|
|
144
|
+
const AHEAD_MARK = '\u2191';
|
|
145
|
+
const DETAIL_SEPARATOR = ' \u00b7 ';
|
|
146
|
+
// S5: the whole vocabulary — the listing's states map to exactly these letters,
|
|
147
|
+
// and an unknown state still reads as a change instead of vanishing silently.
|
|
148
|
+
const BADGES = Object.freeze({ added: ADDED_BADGE, modified: MODIFIED_BADGE, new: UNTRACKED_BADGE });
|
|
142
149
|
// S38: a group row is a row the cursor rests on and it holds no file, so the preview
|
|
143
150
|
// keeps its box and says so — in the one notice shape T5 gives a preview with no
|
|
144
151
|
// numbered lines — instead of claiming a `line/total` position or blanking the pane.
|
|
@@ -771,19 +778,49 @@ function createFilesPickerView(options = {}) {
|
|
|
771
778
|
|
|
772
779
|
// ---- painting -------------------------------------------------------------
|
|
773
780
|
|
|
781
|
+
/**
|
|
782
|
+
* S44: the commits this checkout has that its comparison does not — ` · ↑3 main`
|
|
783
|
+
* — read from the scope's own detail, so the title names what the badges are
|
|
784
|
+
* measured against with no extra Git read. Only AHEAD is painted: a worktree is
|
|
785
|
+
* almost always behind its principal branch, and `↑1 · ↓310` reads as a
|
|
786
|
+
* contradiction even though both counts are true. Empty when the checkout is
|
|
787
|
+
* level, when the detail is absent, or when the count was never measured.
|
|
788
|
+
*/
|
|
789
|
+
function aheadField() {
|
|
790
|
+
const detail = scope.detail !== null && typeof scope.detail === 'object' ? scope.detail : undefined;
|
|
791
|
+
if (detail === undefined) return '';
|
|
792
|
+
const ahead = Number(detail.ahead);
|
|
793
|
+
if (!Number.isFinite(ahead) || Math.trunc(ahead) <= 0) return '';
|
|
794
|
+
const count = `${AHEAD_MARK}${Math.trunc(ahead)}`;
|
|
795
|
+
const comparison = typeof detail.comparison === 'string' ? sanitize(detail.comparison.trim()) : '';
|
|
796
|
+
return comparison === '' ? `${DETAIL_SEPARATOR}${count}` : `${DETAIL_SEPARATOR}${count} ${comparison}`;
|
|
797
|
+
}
|
|
798
|
+
|
|
774
799
|
/**
|
|
775
800
|
* S37: the checkout's path rides the panel's OWN title — `Files · <path>` — so it
|
|
776
801
|
* reads beside the panel's name and elides from its own left, which is what keeps
|
|
777
802
|
* the tail that identifies the checkout. `cardTop` clips a heading's detail from
|
|
778
803
|
* its RIGHT, so the path is elided here first, at exactly the columns the heading
|
|
779
804
|
* leaves it, and the substrate is handed one that already fits.
|
|
805
|
+
*
|
|
806
|
+
* S44 adds the ahead field at the tail of that detail, and the field never gives
|
|
807
|
+
* way: the path elides first, and when not even `MIN_DETAIL_COLUMNS` is left for a
|
|
808
|
+
* path worth painting, the field keeps the row alone.
|
|
780
809
|
*/
|
|
781
810
|
function titleDetail(width) {
|
|
782
811
|
const room = width - TOP_CHROME_COLUMNS - HINT_COLUMNS - titleHeadWidth - TITLE_SEPARATOR_COLUMNS;
|
|
783
812
|
if (room < MIN_DETAIL_COLUMNS) return undefined;
|
|
813
|
+
const field = aheadField();
|
|
814
|
+
const fieldWidth = field === '' ? 0 : measure(helpers, field);
|
|
784
815
|
const root = sanitize(scope.root === undefined ? '' : scope.root);
|
|
785
|
-
if (root
|
|
786
|
-
|
|
816
|
+
if (root !== '' && room - fieldWidth >= MIN_DETAIL_COLUMNS) {
|
|
817
|
+
return `${elideLeft(root, room - fieldWidth)}${field}`;
|
|
818
|
+
}
|
|
819
|
+
// The path is gone or was never there: the field answers for the detail, and
|
|
820
|
+
// only when it fits in the room the heading left it.
|
|
821
|
+
const alone = field.replace(/^ /, '');
|
|
822
|
+
if (alone !== '') return measure(helpers, alone) <= room ? alone : undefined;
|
|
823
|
+
return root === '' ? undefined : elideLeft(root, room);
|
|
787
824
|
}
|
|
788
825
|
|
|
789
826
|
// The card the top rule draws: the panel's name, and the path as its detail when
|
|
@@ -886,11 +923,12 @@ function createFilesPickerView(options = {}) {
|
|
|
886
923
|
return '';
|
|
887
924
|
}
|
|
888
925
|
|
|
889
|
-
// The trailing badge and age, plain: `/changes` own letters
|
|
890
|
-
//
|
|
926
|
+
// The trailing badge and age, plain: `/changes` own letters — `A` for a file
|
|
927
|
+
// the branch added, `M` for one it modified or that is dirty, `U` for one Git
|
|
928
|
+
// does not track yet (S5). A clean row paints neither.
|
|
891
929
|
function suffixOf(entry) {
|
|
892
930
|
if (entry.state === 'clean') return '';
|
|
893
|
-
const badge = entry.state
|
|
931
|
+
const badge = BADGES[entry.state] ?? MODIFIED_BADGE;
|
|
894
932
|
const age = ageOf(entry);
|
|
895
933
|
return age === '' ? badge : `${badge} ${age}`;
|
|
896
934
|
}
|
|
@@ -84,10 +84,12 @@ function countCell(files) {
|
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* The focused scope's line (S9): the last commit subject first, then `±n files`,
|
|
87
|
-
* the age of the last modification, suffixed `ago` (S42), and
|
|
88
|
-
* the comparison ref
|
|
89
|
-
*
|
|
90
|
-
* a
|
|
87
|
+
* the age of the last modification, suffixed `ago` (S42), and ONE distance from
|
|
88
|
+
* the comparison ref — `↑n main` when the checkout has commits the comparison
|
|
89
|
+
* does not, and `↓n main` only when it has none, because a checkout measured
|
|
90
|
+
* against a moving principal branch is almost always behind it and `↑1 · ↓310`
|
|
91
|
+
* reads as a contradiction though both are true (S44). A field that is zero or
|
|
92
|
+
* absent is not painted, and an unknown comparison never claims a distance.
|
|
91
93
|
*
|
|
92
94
|
* @param {{changedFiles?: number, lastModifiedMs?: number, lastCommitSubject?: string, ahead?: number, behind?: number, comparison?: string}} detail
|
|
93
95
|
* @param {number} nowMs the clock read once when the step opened.
|
|
@@ -106,9 +108,14 @@ function scopeDetailLine(detail, nowMs) {
|
|
|
106
108
|
if (Number.isFinite(modified) && modified > 0) fields.push(`${formatAge(modified, nowMs)} ${AGE_SUFFIX}`);
|
|
107
109
|
const comparison = typeof model.comparison === 'string' ? model.comparison.trim() : '';
|
|
108
110
|
const ahead = Number(model.ahead);
|
|
109
|
-
if (comparison !== '' && Number.isFinite(ahead) && ahead > 0) fields.push(`${AHEAD_SYMBOL}${Math.trunc(ahead)} ${comparison}`);
|
|
110
111
|
const behind = Number(model.behind);
|
|
111
|
-
|
|
112
|
+
// S44: one relation, never two. Ahead is the actionable half; behind is only
|
|
113
|
+
// worth a glyph when there is nothing ahead to report.
|
|
114
|
+
if (comparison !== '' && Number.isFinite(ahead) && Math.trunc(ahead) > 0) {
|
|
115
|
+
fields.push(`${AHEAD_SYMBOL}${Math.trunc(ahead)} ${comparison}`);
|
|
116
|
+
} else if (comparison !== '' && Number.isFinite(behind) && Math.trunc(behind) > 0) {
|
|
117
|
+
fields.push(`${BEHIND_SYMBOL}${Math.trunc(behind)} ${comparison}`);
|
|
118
|
+
}
|
|
112
119
|
return fields.join(SEPARATOR);
|
|
113
120
|
}
|
|
114
121
|
|