pi-odd-worktree 3.7.2 → 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.
@@ -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)', () => {
@@ -440,7 +475,7 @@ describe('the tool_call handler the extension registers (S4)', () => {
440
475
  assert.equal(await callTool({ toolName: 'read', input: { path: target } }, PRINCIPAL), undefined);
441
476
  assert.equal(await callTool({ toolName: 'grep', input: { pattern: 'x', path: PRINCIPAL } }, PRINCIPAL), undefined);
442
477
  assert.deepEqual(await callTool(bash('git worktree add ../odd-b'), PRINCIPAL), { block: true, reason: WORKTREE_ADD_REFUSAL });
443
- assert.deepEqual(await callTool(bash('git worktree list --porcelain'), PRINCIPAL), { block: true, reason: '`git worktree list` did not run: use `worktree_list` (`all: true` also shows checkouts outside `<repo-name>-worktrees`).' });
478
+ assert.equal(await callTool(bash('git worktree list --porcelain'), PRINCIPAL), undefined);
444
479
  assert.deepEqual(await callTool(bash('git switch develop'), PRINCIPAL), { block: true, reason: BRANCH_SWITCH_REFUSAL });
445
480
  assert.equal(await callTool(bash('git switch develop'), linked), undefined);
446
481
  assert.equal(await callTool(bash('git status'), PRINCIPAL), undefined);
@@ -1,3 +0,0 @@
1
- ## ODD worktrees
2
-
3
- Work only under the worktree of your workspace root: if that is the primary checkout on the default branch, stop and report instead of writing.