pi-odd-worktree 3.8.0 → 3.8.1
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 +1 -1
- package/lib/worktree-guard.js +10 -0
- package/package.json +1 -1
- package/tools/worktree-write-guard.test.js +35 -0
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ The full rules of each step, including every refusal, are in [Create, list, move
|
|
|
78
78
|
- **File calls on a skill or an ODD are cards too.** While `Card activity` answers with `activity` for the tool being painted, a `read`, `edit` or `write` call whose path names a skill (anything below a `skills` folder) or an ODD (anything below an `odd` folder) heads as that file, with the tool, the path and a read's line range; its Markdown body — the whole document when expanded, the first rows when collapsed — is drawn by Pi's own renderer in the theme's Markdown roles — for an `edit`, the fragment it leaves behind, never its diff, and a call that leaves no fragment falls back to its own rows. Any other file call, and every call while that line answers anything else, is the host's own row. See [the file cards](docs/reference.md#the-file-cards).
|
|
79
79
|
- **Background-job tools are cards too.** While `Card activity` answers with `activity` for the tool being painted, `bash_background`, `monitor`, `job_stop` and `job_list` are drawn in the shell's own card style instead of Pi's plain box. Any other answer leaves Pi's box untouched. See [the jobs card](docs/reference.md#the-jobs-card).
|
|
80
80
|
- **The two advisory messages are cards too.** While `Card activity` answers with `activity`, `gentle-pi.exploration-budget` and `gentle-pi.verifier-settle-reminder` are drawn as `⌕ Exploration budget` and `⚑ Verifier reminder` in the shell's own card style, the whole body at every content level. They follow that line — no second switch, no row added to `Cards`, and a flip repaints the messages on screen and turns them off again. Any other answer hands the message back as Pi drew it, for the price of a registry walk and at most one tool-document read, and a bridge older than `0.12.1` — or one whose release string is not a clean numeric release — registers nothing at all. See [the message cards](docs/reference.md#the-message-cards).
|
|
81
|
-
- **`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, other repositories and linked worktrees are never blocked. See [the guard](docs/reference.md#the-edit-and-write-guard).
|
|
81
|
+
- **`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 (any path below an `odd/` folder, on any branch), other repositories and linked worktrees are never blocked. See [the guard](docs/reference.md#the-edit-and-write-guard).
|
|
82
82
|
- **`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).
|
|
83
83
|
- **Two 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. Both are appended after the host's own text, and `ODD_WORKTREE_PROMPT=0` suppresses them. See [the prompt blocks](docs/reference.md#the--odd-worktrees-block-in-the-system-prompt).
|
|
84
84
|
- **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 adds it or fixes only the differing fields and keeps the rest). 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). Its tool rows are drawn as a card.
|
package/lib/worktree-guard.js
CHANGED
|
@@ -101,6 +101,10 @@
|
|
|
101
101
|
const fs = require('node:fs');
|
|
102
102
|
const os = require('node:os');
|
|
103
103
|
const nodePath = require('node:path');
|
|
104
|
+
// S12 (S3 of odd-write-exempt): the ONE rule for "this path is an ODD artifact" is the file
|
|
105
|
+
// card's own identity, reused and never copied here, so a card and this guard can never
|
|
106
|
+
// disagree about what an `odd/` path is.
|
|
107
|
+
const { ODD_FILE_CARD, fileCardIdentity } = require('./skill-odd-card.js');
|
|
104
108
|
|
|
105
109
|
/** S1 (S10): creating a worktree with Git, refused in every cwd. */
|
|
106
110
|
const WORKTREE_ADD_REFUSAL = '`git worktree add` did not run: create the ODD\'s checkout with `worktree_create`.';
|
|
@@ -606,11 +610,17 @@ function decideWriteGuard(input) {
|
|
|
606
610
|
// git at all — scratch work (and a scratch repository) is the common case, so it is
|
|
607
611
|
// settled first, before the session's own checkout is even resolved. A path the
|
|
608
612
|
// filesystem cannot place is settled here too.
|
|
613
|
+
//
|
|
614
|
+
// S12 (odd-write-exempt): an ODD artifact is settled the same way, and for a stronger
|
|
615
|
+
// reason — the ODD document is where an ODD is written down, so the branch a checkout
|
|
616
|
+
// happens to be standing on cannot be a reason to refuse it. The folders decide, so a
|
|
617
|
+
// nested `odd/` is one and a file named `odd` is not.
|
|
609
618
|
let temps;
|
|
610
619
|
const candidates = [];
|
|
611
620
|
for (const value of raw) {
|
|
612
621
|
const judged = judgedPath(value, cwd);
|
|
613
622
|
if (judged === undefined) continue;
|
|
623
|
+
if (fileCardIdentity(judged) === ODD_FILE_CARD) continue;
|
|
614
624
|
if (temps === undefined) temps = tempRoots(process.env);
|
|
615
625
|
if (temps.some((root) => isInside(judged, root))) continue;
|
|
616
626
|
candidates.push(judged);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-odd-worktree",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.1",
|
|
4
4
|
"description": "Pi package for odd-worktree: the Git worktree tools a Pi session uses (create and list the checkouts the agent works in), the /warp worktree panel, the /odd ODD viewer, and the /issues GitHub issue reader. Needs only Pi and git: no companion app, no extra service.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -107,6 +107,41 @@ function harness(options = {}) {
|
|
|
107
107
|
return { run, reads };
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
// ---- S1/S3 (odd-write-exempt): an `odd/` path is always writable ----
|
|
111
|
+
|
|
112
|
+
describe('an ODD artifact is never refused, whatever branch the checkout is on', () => {
|
|
113
|
+
const oddFile = (name = 'tasks/probe.md') => path.join(PRINCIPAL, 'odd', name);
|
|
114
|
+
|
|
115
|
+
test('a write under `odd/` in the primary checkout on the default branch passes', { skip: NEEDS_NON_TEMP }, () => {
|
|
116
|
+
for (const toolName of ['edit', 'write']) {
|
|
117
|
+
const { run, reads } = harness();
|
|
118
|
+
assert.deepEqual(run([oddFile()], { toolName }), { block: false }, toolName);
|
|
119
|
+
assert.deepEqual(reads, { identity: 0, defaultBranch: 0, currentBranch: 0 }, `${toolName}: no git is read`);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('the folder decides, wherever it sits, and a FILE named `odd` is not inside one', { skip: NEEDS_NON_TEMP }, () => {
|
|
124
|
+
const { run } = harness();
|
|
125
|
+
assert.deepEqual(run([path.join(PRINCIPAL, 'odd', 'tasks', 'a.md')]), { block: false });
|
|
126
|
+
assert.deepEqual(run([path.join(PRINCIPAL, 'sub', 'odd', 'b.md')]), { block: false }, 'a nested odd folder is one too');
|
|
127
|
+
// A file whose own name is `odd`, or a folder that only starts with those letters, is not exempt.
|
|
128
|
+
assert.equal(run([path.join(PRINCIPAL, 'lib', 'odd')]).block, true, 'a file named odd is a file');
|
|
129
|
+
assert.equal(run([path.join(PRINCIPAL, 'docs', 'a.md')]).block, true, 'a sibling folder is not odd/');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('the exemption is per path: a refused path beside an ODD one still refuses, and names itself', { skip: NEEDS_NON_TEMP }, () => {
|
|
133
|
+
const { run } = harness();
|
|
134
|
+
assert.deepEqual(run([oddFile(), PRINCIPAL_FILE]), { block: true, reason: refusal(PRINCIPAL_FILE) });
|
|
135
|
+
assert.deepEqual(run([PRINCIPAL_FILE, oddFile()]), { block: true, reason: refusal(PRINCIPAL_FILE) });
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('every other exemption is untouched: another branch still passes, a temp path still passes', { skip: NEEDS_NON_TEMP }, () => {
|
|
139
|
+
const { run } = harness({ currentBranch: 'feat/x' });
|
|
140
|
+
assert.deepEqual(run([PRINCIPAL_FILE]), { block: false });
|
|
141
|
+
assert.deepEqual(harness().run([path.join(scratch('odd-exempt'), 'a.txt')]), { block: false });
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
110
145
|
// ---- S4: the refusal itself ----
|
|
111
146
|
|
|
112
147
|
describe('the refusal is one sentence (S4)', () => {
|