gogcli-mcp-docs 4.2.4 → 4.3.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.
@@ -3,6 +3,7 @@ import { registerExtraDocsTools } from '../../src/tools/docs-extra.js';
3
3
  import * as lib from '../../../gogcli-mcp/src/lib.js';
4
4
  import { createTestHarness } from '@chrischall/mcp-utils/test';
5
5
  import { rawTextResult } from '@chrischall/mcp-utils';
6
+ import { pos } from '../../../gogcli-mcp/src/argv.js';
6
7
 
7
8
  vi.mock('../../../gogcli-mcp/src/lib.js', async (importOriginal) => {
8
9
  const actual = await importOriginal<typeof lib>();
@@ -23,7 +24,7 @@ describe('gog_docs_copy', () => {
23
24
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
24
25
  const harness = await setupHandlers();
25
26
  await harness.callTool('gog_docs_copy', { docId: 'abc', title: 'My Copy' });
26
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'copy', 'abc', 'My Copy'], { account: undefined });
27
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'copy', pos('abc'), pos('My Copy')], { account: undefined });
27
28
  });
28
29
 
29
30
  it('includes --parent when provided', async () => {
@@ -31,7 +32,7 @@ describe('gog_docs_copy', () => {
31
32
  const harness = await setupHandlers();
32
33
  await harness.callTool('gog_docs_copy', { docId: 'abc', title: 'Copy', parent: 'folder123' });
33
34
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
34
- ['docs', 'copy', 'abc', 'Copy', '--parent=folder123'],
35
+ ['docs', 'copy', pos('abc'), pos('Copy'), '--parent=folder123'],
35
36
  { account: undefined },
36
37
  );
37
38
  });
@@ -40,14 +41,14 @@ describe('gog_docs_copy', () => {
40
41
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
41
42
  const harness = await setupHandlers();
42
43
  await harness.callTool('gog_docs_copy', { docId: 'abc', title: 'Copy' });
43
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'copy', 'abc', 'Copy'], { account: undefined });
44
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'copy', pos('abc'), pos('Copy')], { account: undefined });
44
45
  });
45
46
 
46
47
  it('forwards account override', async () => {
47
48
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
48
49
  const harness = await setupHandlers();
49
50
  await harness.callTool('gog_docs_copy', { docId: 'abc', title: 'Copy', account: 'other@gmail.com' });
50
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'copy', 'abc', 'Copy'], { account: 'other@gmail.com' });
51
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'copy', pos('abc'), pos('Copy')], { account: 'other@gmail.com' });
51
52
  });
52
53
  });
53
54
 
@@ -59,7 +60,7 @@ describe('gog_docs_delete', () => {
59
60
  const harness = await setupHandlers();
60
61
  await harness.callTool('gog_docs_delete', { docId: 'abc', start: 5, end: 10 });
61
62
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
62
- ['docs', 'delete', '--start=5', '--end=10', 'abc'],
63
+ ['docs', 'delete', '--start=5', '--end=10', pos('abc')],
63
64
  { account: undefined },
64
65
  );
65
66
  });
@@ -70,7 +71,7 @@ describe('gog_docs_delete', () => {
70
71
  const harness = await setupHandlers();
71
72
  await harness.callTool('gog_docs_delete', { docId: 'abc', at: 'TODO', occurrence: 2, matchCase: true });
72
73
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
73
- ['docs', 'delete', 'abc', '--at=TODO', '--occurrence=2', '--match-case'],
74
+ ['docs', 'delete', pos('abc'), '--at=TODO', '--occurrence=2', '--match-case'],
74
75
  { account: undefined },
75
76
  );
76
77
  });
@@ -80,7 +81,7 @@ describe('gog_docs_delete', () => {
80
81
  const harness = await setupHandlers();
81
82
  await harness.callTool('gog_docs_delete', { docId: 'abc', start: 1, end: 5, tabId: 'tab1' });
82
83
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
83
- ['docs', 'delete', '--start=1', '--end=5', 'abc', '--tab-id=tab1'],
84
+ ['docs', 'delete', '--start=1', '--end=5', pos('abc'), '--tab-id=tab1'],
84
85
  { account: undefined },
85
86
  );
86
87
  });
@@ -90,7 +91,7 @@ describe('gog_docs_delete', () => {
90
91
  const harness = await setupHandlers();
91
92
  await harness.callTool('gog_docs_delete', { docId: 'abc', start: 1, end: 5 });
92
93
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
93
- ['docs', 'delete', '--start=1', '--end=5', 'abc'],
94
+ ['docs', 'delete', '--start=1', '--end=5', pos('abc')],
94
95
  { account: undefined },
95
96
  );
96
97
  });
@@ -104,7 +105,7 @@ describe('gog_docs_edit', () => {
104
105
  const harness = await setupHandlers();
105
106
  await harness.callTool('gog_docs_edit', { docId: 'abc', find: 'old', replace: 'new' });
106
107
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
107
- ['docs', 'edit', 'abc', 'old', 'new'],
108
+ ['docs', 'edit', pos('abc'), pos('old'), pos('new')],
108
109
  { account: undefined },
109
110
  );
110
111
  });
@@ -114,7 +115,7 @@ describe('gog_docs_edit', () => {
114
115
  const harness = await setupHandlers();
115
116
  await harness.callTool('gog_docs_edit', { docId: 'abc', find: 'old', replace: 'new', matchCase: true });
116
117
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
117
- ['docs', 'edit', 'abc', 'old', 'new', '--match-case'],
118
+ ['docs', 'edit', pos('abc'), pos('old'), pos('new'), '--match-case'],
118
119
  { account: undefined },
119
120
  );
120
121
  });
@@ -124,7 +125,7 @@ describe('gog_docs_edit', () => {
124
125
  const harness = await setupHandlers();
125
126
  await harness.callTool('gog_docs_edit', { docId: 'abc', find: 'old', replace: 'new', matchCase: false });
126
127
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
127
- ['docs', 'edit', 'abc', 'old', 'new'],
128
+ ['docs', 'edit', pos('abc'), pos('old'), pos('new')],
128
129
  { account: undefined },
129
130
  );
130
131
  });
@@ -137,7 +138,7 @@ describe('gog_docs_export', () => {
137
138
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
138
139
  const harness = await setupHandlers();
139
140
  await harness.callTool('gog_docs_export', { docId: 'abc' });
140
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'export', 'abc'], { account: undefined });
141
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'export', pos('abc')], { account: undefined });
141
142
  });
142
143
 
143
144
  it('includes --format when provided', async () => {
@@ -145,7 +146,7 @@ describe('gog_docs_export', () => {
145
146
  const harness = await setupHandlers();
146
147
  await harness.callTool('gog_docs_export', { docId: 'abc', format: 'html' });
147
148
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
148
- ['docs', 'export', 'abc', '--format=html'],
149
+ ['docs', 'export', pos('abc'), '--format=html'],
149
150
  { account: undefined },
150
151
  );
151
152
  });
@@ -155,7 +156,7 @@ describe('gog_docs_export', () => {
155
156
  const harness = await setupHandlers();
156
157
  await harness.callTool('gog_docs_export', { docId: 'abc', out: '/tmp/doc.pdf' });
157
158
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
158
- ['docs', 'export', 'abc', '--out=/tmp/doc.pdf'],
159
+ ['docs', 'export', pos('abc'), '--out=/tmp/doc.pdf'],
159
160
  { account: undefined },
160
161
  );
161
162
  });
@@ -165,7 +166,7 @@ describe('gog_docs_export', () => {
165
166
  const harness = await setupHandlers();
166
167
  await harness.callTool('gog_docs_export', { docId: 'abc', format: 'txt', out: '/tmp/doc.txt' });
167
168
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
168
- ['docs', 'export', 'abc', '--format=txt', '--out=/tmp/doc.txt'],
169
+ ['docs', 'export', pos('abc'), '--format=txt', '--out=/tmp/doc.txt'],
169
170
  { account: undefined },
170
171
  );
171
172
  });
@@ -174,7 +175,7 @@ describe('gog_docs_export', () => {
174
175
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
175
176
  const harness = await setupHandlers();
176
177
  await harness.callTool('gog_docs_export', { docId: 'abc' });
177
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'export', 'abc'], { account: undefined });
178
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'export', pos('abc')], { account: undefined });
178
179
  });
179
180
 
180
181
  it('includes --overwrite when requested', async () => {
@@ -182,7 +183,7 @@ describe('gog_docs_export', () => {
182
183
  const harness = await setupHandlers();
183
184
  await harness.callTool('gog_docs_export', { docId: 'abc', out: '/tmp/doc.pdf', overwrite: true });
184
185
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
185
- ['docs', 'export', 'abc', '--out=/tmp/doc.pdf', '--overwrite'],
186
+ ['docs', 'export', pos('abc'), '--out=/tmp/doc.pdf', '--overwrite'],
186
187
  { account: undefined },
187
188
  );
188
189
  });
@@ -196,7 +197,7 @@ describe('gog_docs_insert', () => {
196
197
  const harness = await setupHandlers();
197
198
  await harness.callTool('gog_docs_insert', { docId: 'abc', content: 'Hello world' });
198
199
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
199
- ['docs', 'insert', 'abc', 'Hello world'],
200
+ ['docs', 'insert', pos('abc'), pos('Hello world')],
200
201
  { account: undefined },
201
202
  );
202
203
  });
@@ -207,7 +208,7 @@ describe('gog_docs_insert', () => {
207
208
  const harness = await setupHandlers();
208
209
  await harness.callTool('gog_docs_insert', { docId: 'abc', content: 'X', at: 'HERE', occurrence: 3, matchCase: true });
209
210
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
210
- ['docs', 'insert', 'abc', 'X', '--at=HERE', '--occurrence=3', '--match-case'],
211
+ ['docs', 'insert', pos('abc'), pos('X'), '--at=HERE', '--occurrence=3', '--match-case'],
211
212
  { account: undefined },
212
213
  );
213
214
  });
@@ -217,7 +218,7 @@ describe('gog_docs_insert', () => {
217
218
  const harness = await setupHandlers();
218
219
  await harness.callTool('gog_docs_insert', { docId: 'abc', content: 'text', index: 5 });
219
220
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
220
- ['docs', 'insert', 'abc', 'text', '--index=5'],
221
+ ['docs', 'insert', pos('abc'), pos('text'), '--index=5'],
221
222
  { account: undefined },
222
223
  );
223
224
  });
@@ -227,7 +228,7 @@ describe('gog_docs_insert', () => {
227
228
  const harness = await setupHandlers();
228
229
  await harness.callTool('gog_docs_insert', { docId: 'abc', content: 'text', index: 0 });
229
230
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
230
- ['docs', 'insert', 'abc', 'text', '--index=0'],
231
+ ['docs', 'insert', pos('abc'), pos('text'), '--index=0'],
231
232
  { account: undefined },
232
233
  );
233
234
  });
@@ -237,7 +238,7 @@ describe('gog_docs_insert', () => {
237
238
  const harness = await setupHandlers();
238
239
  await harness.callTool('gog_docs_insert', { docId: 'abc', file: '/tmp/text.txt' });
239
240
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
240
- ['docs', 'insert', 'abc', '--file=/tmp/text.txt'],
241
+ ['docs', 'insert', pos('abc'), '--file=/tmp/text.txt'],
241
242
  { account: undefined },
242
243
  );
243
244
  });
@@ -247,7 +248,7 @@ describe('gog_docs_insert', () => {
247
248
  const harness = await setupHandlers();
248
249
  await harness.callTool('gog_docs_insert', { docId: 'abc', content: 'hi', tabId: 'tab1' });
249
250
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
250
- ['docs', 'insert', 'abc', 'hi', '--tab-id=tab1'],
251
+ ['docs', 'insert', pos('abc'), pos('hi'), '--tab-id=tab1'],
251
252
  { account: undefined },
252
253
  );
253
254
  });
@@ -256,7 +257,7 @@ describe('gog_docs_insert', () => {
256
257
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
257
258
  const harness = await setupHandlers();
258
259
  await harness.callTool('gog_docs_insert', { docId: 'abc' });
259
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'insert', 'abc'], { account: undefined });
260
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'insert', pos('abc')], { account: undefined });
260
261
  });
261
262
  });
262
263
 
@@ -267,14 +268,14 @@ describe('gog_docs_list_tabs', () => {
267
268
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
268
269
  const harness = await setupHandlers();
269
270
  await harness.callTool('gog_docs_list_tabs', { docId: 'abc' });
270
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'list-tabs', 'abc'], { account: undefined });
271
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'list-tabs', pos('abc')], { account: undefined });
271
272
  });
272
273
 
273
274
  it('forwards account override', async () => {
274
275
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
275
276
  const harness = await setupHandlers();
276
277
  await harness.callTool('gog_docs_list_tabs', { docId: 'abc', account: 'other@gmail.com' });
277
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'list-tabs', 'abc'], { account: 'other@gmail.com' });
278
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'list-tabs', pos('abc')], { account: 'other@gmail.com' });
278
279
  });
279
280
  });
280
281
 
@@ -286,7 +287,7 @@ describe('gog_docs_sed', () => {
286
287
  const harness = await setupHandlers();
287
288
  await harness.callTool('gog_docs_sed', { docId: 'abc', expression: 's/old/new/g' });
288
289
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
289
- ['docs', 'sed', 'abc', 's/old/new/g'],
290
+ ['docs', 'sed', pos('abc'), pos('s/old/new/g')],
290
291
  { account: undefined },
291
292
  );
292
293
  });
@@ -299,7 +300,7 @@ describe('gog_docs_sed', () => {
299
300
  expressions: ['s/foo/bar/g', 's/baz/qux/g'],
300
301
  });
301
302
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
302
- ['docs', 'sed', 'abc', '--expressions=s/foo/bar/g', '--expressions=s/baz/qux/g'],
303
+ ['docs', 'sed', pos('abc'), '--expressions=s/foo/bar/g', '--expressions=s/baz/qux/g'],
303
304
  { account: undefined },
304
305
  );
305
306
  });
@@ -309,7 +310,7 @@ describe('gog_docs_sed', () => {
309
310
  const harness = await setupHandlers();
310
311
  await harness.callTool('gog_docs_sed', { docId: 'abc', file: '/tmp/sed.txt' });
311
312
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
312
- ['docs', 'sed', 'abc', '--file=/tmp/sed.txt'],
313
+ ['docs', 'sed', pos('abc'), '--file=/tmp/sed.txt'],
313
314
  { account: undefined },
314
315
  );
315
316
  });
@@ -319,7 +320,7 @@ describe('gog_docs_sed', () => {
319
320
  const harness = await setupHandlers();
320
321
  await harness.callTool('gog_docs_sed', { docId: 'abc', expression: 's/a/b/', tab: 'Notes' });
321
322
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
322
- ['docs', 'sed', 'abc', 's/a/b/', '--tab=Notes'],
323
+ ['docs', 'sed', pos('abc'), pos('s/a/b/'), '--tab=Notes'],
323
324
  { account: undefined },
324
325
  );
325
326
  });
@@ -328,7 +329,7 @@ describe('gog_docs_sed', () => {
328
329
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
329
330
  const harness = await setupHandlers();
330
331
  await harness.callTool('gog_docs_sed', { docId: 'abc' });
331
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'sed', 'abc'], { account: undefined });
332
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'sed', pos('abc')], { account: undefined });
332
333
  });
333
334
  });
334
335
 
@@ -340,7 +341,7 @@ describe('gog_docs_update', () => {
340
341
  const harness = await setupHandlers();
341
342
  await harness.callTool('gog_docs_update', { docId: 'abc', text: 'Hello' });
342
343
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
343
- ['docs', 'update', 'abc', '--text=Hello'],
344
+ ['docs', 'update', pos('abc'), '--text=Hello'],
344
345
  { account: undefined },
345
346
  );
346
347
  });
@@ -351,7 +352,7 @@ describe('gog_docs_update', () => {
351
352
  const harness = await setupHandlers();
352
353
  await harness.callTool('gog_docs_update', { docId: 'abc', text: 'New', at: 'OLD', occurrence: 1, matchCase: true });
353
354
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
354
- ['docs', 'update', 'abc', '--text=New', '--at=OLD', '--occurrence=1', '--match-case'],
355
+ ['docs', 'update', pos('abc'), '--text=New', '--at=OLD', '--occurrence=1', '--match-case'],
355
356
  { account: undefined },
356
357
  );
357
358
  });
@@ -361,7 +362,7 @@ describe('gog_docs_update', () => {
361
362
  const harness = await setupHandlers();
362
363
  await harness.callTool('gog_docs_update', { docId: 'abc', file: '/tmp/content.txt' });
363
364
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
364
- ['docs', 'update', 'abc', '--file=/tmp/content.txt'],
365
+ ['docs', 'update', pos('abc'), '--file=/tmp/content.txt'],
365
366
  { account: undefined },
366
367
  );
367
368
  });
@@ -371,7 +372,7 @@ describe('gog_docs_update', () => {
371
372
  const harness = await setupHandlers();
372
373
  await harness.callTool('gog_docs_update', { docId: 'abc', text: 'hi', index: 10 });
373
374
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
374
- ['docs', 'update', 'abc', '--text=hi', '--index=10'],
375
+ ['docs', 'update', pos('abc'), '--text=hi', '--index=10'],
375
376
  { account: undefined },
376
377
  );
377
378
  });
@@ -381,7 +382,7 @@ describe('gog_docs_update', () => {
381
382
  const harness = await setupHandlers();
382
383
  await harness.callTool('gog_docs_update', { docId: 'abc', text: 'hi', index: 0 });
383
384
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
384
- ['docs', 'update', 'abc', '--text=hi', '--index=0'],
385
+ ['docs', 'update', pos('abc'), '--text=hi', '--index=0'],
385
386
  { account: undefined },
386
387
  );
387
388
  });
@@ -391,7 +392,7 @@ describe('gog_docs_update', () => {
391
392
  const harness = await setupHandlers();
392
393
  await harness.callTool('gog_docs_update', { docId: 'abc', text: 'hi', tabId: 'tab1' });
393
394
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
394
- ['docs', 'update', 'abc', '--text=hi', '--tab-id=tab1'],
395
+ ['docs', 'update', pos('abc'), '--text=hi', '--tab-id=tab1'],
395
396
  { account: undefined },
396
397
  );
397
398
  });
@@ -401,7 +402,7 @@ describe('gog_docs_update', () => {
401
402
  const harness = await setupHandlers();
402
403
  await harness.callTool('gog_docs_update', { docId: 'abc', pageless: true });
403
404
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
404
- ['docs', 'update', 'abc', '--pageless'],
405
+ ['docs', 'update', pos('abc'), '--pageless'],
405
406
  { account: undefined },
406
407
  );
407
408
  });
@@ -411,7 +412,7 @@ describe('gog_docs_update', () => {
411
412
  const harness = await setupHandlers();
412
413
  await harness.callTool('gog_docs_update', { docId: 'abc', pageless: false });
413
414
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
414
- ['docs', 'update', 'abc'],
415
+ ['docs', 'update', pos('abc')],
415
416
  { account: undefined },
416
417
  );
417
418
  });
@@ -420,7 +421,7 @@ describe('gog_docs_update', () => {
420
421
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
421
422
  const harness = await setupHandlers();
422
423
  await harness.callTool('gog_docs_update', { docId: 'abc' });
423
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'update', 'abc'], { account: undefined });
424
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'update', pos('abc')], { account: undefined });
424
425
  });
425
426
 
426
427
  it('includes --replace-range when provided', async () => {
@@ -428,7 +429,7 @@ describe('gog_docs_update', () => {
428
429
  const harness = await setupHandlers();
429
430
  await harness.callTool('gog_docs_update', { docId: 'abc', text: 'new', replaceRange: '25:40' });
430
431
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
431
- ['docs', 'update', 'abc', '--text=new', '--replace-range=25:40'],
432
+ ['docs', 'update', pos('abc'), '--text=new', '--replace-range=25:40'],
432
433
  { account: undefined },
433
434
  );
434
435
  });
@@ -438,7 +439,7 @@ describe('gog_docs_update', () => {
438
439
  const harness = await setupHandlers();
439
440
  await harness.callTool('gog_docs_update', { docId: 'abc', text: '# Heading', markdown: true });
440
441
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
441
- ['docs', 'update', 'abc', '--text=# Heading', '--markdown'],
442
+ ['docs', 'update', pos('abc'), '--text=# Heading', '--markdown'],
442
443
  { account: undefined },
443
444
  );
444
445
  });
@@ -448,7 +449,7 @@ describe('gog_docs_update', () => {
448
449
  const harness = await setupHandlers();
449
450
  await harness.callTool('gog_docs_update', { docId: 'abc', text: 'hi', markdown: false });
450
451
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
451
- ['docs', 'update', 'abc', '--text=hi'],
452
+ ['docs', 'update', pos('abc'), '--text=hi'],
452
453
  { account: undefined },
453
454
  );
454
455
  });
@@ -461,7 +462,7 @@ describe('gog_docs_comments_list', () => {
461
462
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
462
463
  const harness = await setupHandlers();
463
464
  await harness.callTool('gog_docs_comments_list', { docId: 'abc' });
464
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'list', 'abc'], { account: undefined });
465
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'list', pos('abc')], { account: undefined });
465
466
  });
466
467
 
467
468
  it('includes --include-resolved when set', async () => {
@@ -469,7 +470,7 @@ describe('gog_docs_comments_list', () => {
469
470
  const harness = await setupHandlers();
470
471
  await harness.callTool('gog_docs_comments_list', { docId: 'abc', includeResolved: true });
471
472
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
472
- ['docs', 'comments', 'list', 'abc', '--include-resolved'],
473
+ ['docs', 'comments', 'list', pos('abc'), '--include-resolved'],
473
474
  { account: undefined },
474
475
  );
475
476
  });
@@ -478,7 +479,7 @@ describe('gog_docs_comments_list', () => {
478
479
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
479
480
  const harness = await setupHandlers();
480
481
  await harness.callTool('gog_docs_comments_list', { docId: 'abc', includeResolved: false });
481
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'list', 'abc'], { account: undefined });
482
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'list', pos('abc')], { account: undefined });
482
483
  });
483
484
 
484
485
  it('forwards account override', async () => {
@@ -486,7 +487,7 @@ describe('gog_docs_comments_list', () => {
486
487
  const harness = await setupHandlers();
487
488
  await harness.callTool('gog_docs_comments_list', { docId: 'abc', account: 'other@gmail.com' });
488
489
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
489
- ['docs', 'comments', 'list', 'abc'],
490
+ ['docs', 'comments', 'list', pos('abc')],
490
491
  { account: 'other@gmail.com' },
491
492
  );
492
493
  });
@@ -499,7 +500,7 @@ describe('gog_docs_comments_list', () => {
499
500
  docId: 'abc', includeResolved: true, since: '2026-06-01T00:00:00Z', max: 10, page: 'tok', all: true,
500
501
  });
501
502
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
502
- ['docs', 'comments', 'list', 'abc', '--include-resolved', '--since=2026-06-01T00:00:00Z', '--max=10', '--page=tok', '--all'],
503
+ ['docs', 'comments', 'list', pos('abc'), '--include-resolved', '--since=2026-06-01T00:00:00Z', '--max=10', '--page=tok', '--all'],
503
504
  { account: undefined },
504
505
  );
505
506
  });
@@ -513,7 +514,7 @@ describe('gog_docs_comments_list', () => {
513
514
  const harness = await setupHandlers();
514
515
  await harness.callTool('gog_docs_comments_list', { docId: 'abc', locate: true });
515
516
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
516
- ['docs', 'comments', 'list', 'abc', '--locate'],
517
+ ['docs', 'comments', 'list', pos('abc'), '--locate'],
517
518
  { account: undefined },
518
519
  );
519
520
  });
@@ -522,7 +523,7 @@ describe('gog_docs_comments_list', () => {
522
523
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
523
524
  const harness = await setupHandlers();
524
525
  await harness.callTool('gog_docs_comments_list', { docId: 'abc', locate: false });
525
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'list', 'abc'], { account: undefined });
526
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'list', pos('abc')], { account: undefined });
526
527
  });
527
528
 
528
529
  it('includes --tab, which gog treats as implying --locate', async () => {
@@ -530,7 +531,7 @@ describe('gog_docs_comments_list', () => {
530
531
  const harness = await setupHandlers();
531
532
  await harness.callTool('gog_docs_comments_list', { docId: 'abc', tab: 'Notes' });
532
533
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
533
- ['docs', 'comments', 'list', 'abc', '--tab=Notes'],
534
+ ['docs', 'comments', 'list', pos('abc'), '--tab=Notes'],
534
535
  { account: undefined },
535
536
  );
536
537
  });
@@ -541,7 +542,7 @@ describe('gog_docs_comments_list', () => {
541
542
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
542
543
  const harness = await setupHandlers();
543
544
  await harness.callTool('gog_docs_comments_list', { docId: 'abc', tab: '' });
544
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'list', 'abc'], { account: undefined });
545
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'list', pos('abc')], { account: undefined });
545
546
  });
546
547
 
547
548
  it('combines --locate and --tab with the existing filters and pagination', async () => {
@@ -553,7 +554,7 @@ describe('gog_docs_comments_list', () => {
553
554
  });
554
555
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
555
556
  [
556
- 'docs', 'comments', 'list', 'abc',
557
+ 'docs', 'comments', 'list', pos('abc'),
557
558
  '--include-resolved',
558
559
  '--since=2026-06-01T00:00:00Z',
559
560
  '--locate',
@@ -589,7 +590,7 @@ describe('gog_docs_table_column_width', () => {
589
590
  docId: 'd1', col: 2, width: 120, tableIndex: 1, tab: 'Body',
590
591
  });
591
592
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
592
- ['docs', 'table-column-width', 'd1', '--col=2', '--width=120', '--table-index=1', '--tab=Body'],
593
+ ['docs', 'table-column-width', pos('d1'), '--col=2', '--width=120', '--table-index=1', '--tab=Body'],
593
594
  { account: undefined },
594
595
  );
595
596
  });
@@ -599,7 +600,7 @@ describe('gog_docs_table_column_width', () => {
599
600
  const harness = await setupHandlers();
600
601
  await harness.callTool('gog_docs_table_column_width', { docId: 'd1', evenlyDistributed: true });
601
602
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
602
- ['docs', 'table-column-width', 'd1', '--evenly-distributed'],
603
+ ['docs', 'table-column-width', pos('d1'), '--evenly-distributed'],
603
604
  { account: undefined },
604
605
  );
605
606
  });
@@ -609,7 +610,7 @@ describe('gog_docs_table_column_width', () => {
609
610
  const harness = await setupHandlers();
610
611
  await harness.callTool('gog_docs_table_column_width', { docId: 'd1', col: 1, width: 80, account: 'other@gmail.com' });
611
612
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
612
- ['docs', 'table-column-width', 'd1', '--col=1', '--width=80'],
613
+ ['docs', 'table-column-width', pos('d1'), '--col=1', '--width=80'],
613
614
  { account: 'other@gmail.com' },
614
615
  );
615
616
  });
@@ -621,7 +622,7 @@ describe('gog_docs_find_range', () => {
621
622
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
622
623
  const harness = await setupHandlers();
623
624
  await harness.callTool('gog_docs_find_range', { docId: 'd1', text: 'hello' });
624
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'find-range', 'd1', 'hello'], { account: undefined });
625
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'find-range', pos('d1'), pos('hello')], { account: undefined });
625
626
  });
626
627
 
627
628
  it('passes all match flags', async () => {
@@ -631,7 +632,7 @@ describe('gog_docs_find_range', () => {
631
632
  docId: 'd1', text: 'hello', occurrence: 2, matchCase: true, normalizeWhitespace: true, all: true, failEmpty: true, tab: 'T',
632
633
  });
633
634
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
634
- ['docs', 'find-range', 'd1', 'hello', '--occurrence=2', '--match-case', '--normalize-whitespace', '--all', '--fail-empty', '--tab=T'],
635
+ ['docs', 'find-range', pos('d1'), pos('hello'), '--occurrence=2', '--match-case', '--normalize-whitespace', '--all', '--fail-empty', '--tab=T'],
635
636
  { account: undefined },
636
637
  );
637
638
  });
@@ -642,7 +643,7 @@ describe('gog_docs_comments_locate', () => {
642
643
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
643
644
  const harness = await setupHandlers();
644
645
  await harness.callTool('gog_docs_comments_locate', { docId: 'd1', commentId: 'c1' });
645
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'locate', 'd1', 'c1'], { account: undefined });
646
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'locate', pos('d1'), pos('c1')], { account: undefined });
646
647
  });
647
648
 
648
649
  it('passes match flags', async () => {
@@ -650,7 +651,7 @@ describe('gog_docs_comments_locate', () => {
650
651
  const harness = await setupHandlers();
651
652
  await harness.callTool('gog_docs_comments_locate', { docId: 'd1', commentId: 'c1', matchCase: true, normalizeWhitespace: true, tab: 'T' });
652
653
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
653
- ['docs', 'comments', 'locate', 'd1', 'c1', '--match-case', '--normalize-whitespace', '--tab=T'],
654
+ ['docs', 'comments', 'locate', pos('d1'), pos('c1'), '--match-case', '--normalize-whitespace', '--tab=T'],
654
655
  { account: undefined },
655
656
  );
656
657
  });
@@ -661,7 +662,7 @@ describe('gog_docs_comments_get', () => {
661
662
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
662
663
  const harness = await setupHandlers();
663
664
  await harness.callTool('gog_docs_comments_get', { docId: 'abc', commentId: 'c1' });
664
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'get', 'abc', 'c1'], { account: undefined });
665
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'comments', 'get', pos('abc'), pos('c1')], { account: undefined });
665
666
  });
666
667
  });
667
668
 
@@ -671,7 +672,7 @@ describe('gog_docs_comments_add', () => {
671
672
  const harness = await setupHandlers();
672
673
  await harness.callTool('gog_docs_comments_add', { docId: 'abc', content: 'Please review' });
673
674
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
674
- ['docs', 'comments', 'add', 'abc', 'Please review'],
675
+ ['docs', 'comments', 'add', pos('abc'), pos('Please review')],
675
676
  { account: undefined },
676
677
  );
677
678
  });
@@ -683,7 +684,7 @@ describe('gog_docs_comments_add', () => {
683
684
  docId: 'abc', content: 'Typo here', quoted: 'teh',
684
685
  });
685
686
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
686
- ['docs', 'comments', 'add', 'abc', 'Typo here', '--quoted=teh'],
687
+ ['docs', 'comments', 'add', pos('abc'), pos('Typo here'), '--quoted=teh'],
687
688
  { account: undefined },
688
689
  );
689
690
  });
@@ -693,7 +694,7 @@ describe('gog_docs_comments_add', () => {
693
694
  const harness = await setupHandlers();
694
695
  await harness.callTool('gog_docs_comments_add', { docId: 'abc', content: 'Nice' });
695
696
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
696
- ['docs', 'comments', 'add', 'abc', 'Nice'],
697
+ ['docs', 'comments', 'add', pos('abc'), pos('Nice')],
697
698
  { account: undefined },
698
699
  );
699
700
  });
@@ -705,7 +706,7 @@ describe('gog_docs_comments_reply', () => {
705
706
  const harness = await setupHandlers();
706
707
  await harness.callTool('gog_docs_comments_reply', { docId: 'abc', commentId: 'c1', content: 'Done' });
707
708
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
708
- ['docs', 'comments', 'reply', 'abc', 'c1', 'Done'],
709
+ ['docs', 'comments', 'reply', pos('abc'), pos('c1'), pos('Done')],
709
710
  { account: undefined },
710
711
  );
711
712
  });
@@ -717,7 +718,7 @@ describe('gog_docs_comments_resolve', () => {
717
718
  const harness = await setupHandlers();
718
719
  await harness.callTool('gog_docs_comments_resolve', { docId: 'abc', commentId: 'c1' });
719
720
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
720
- ['docs', 'comments', 'resolve', 'abc', 'c1'],
721
+ ['docs', 'comments', 'resolve', pos('abc'), pos('c1')],
721
722
  { account: undefined },
722
723
  );
723
724
  });
@@ -729,7 +730,7 @@ describe('gog_docs_comments_resolve', () => {
729
730
  docId: 'abc', commentId: 'c1', message: 'Fixed in v2',
730
731
  });
731
732
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
732
- ['docs', 'comments', 'resolve', 'abc', 'c1', '--message=Fixed in v2'],
733
+ ['docs', 'comments', 'resolve', pos('abc'), pos('c1'), '--message=Fixed in v2'],
733
734
  { account: undefined },
734
735
  );
735
736
  });
@@ -739,7 +740,7 @@ describe('gog_docs_comments_resolve', () => {
739
740
  const harness = await setupHandlers();
740
741
  await harness.callTool('gog_docs_comments_resolve', { docId: 'abc', commentId: 'c1' });
741
742
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
742
- ['docs', 'comments', 'resolve', 'abc', 'c1'],
743
+ ['docs', 'comments', 'resolve', pos('abc'), pos('c1')],
743
744
  { account: undefined },
744
745
  );
745
746
  });
@@ -751,7 +752,7 @@ describe('gog_docs_comments_delete', () => {
751
752
  const harness = await setupHandlers();
752
753
  await harness.callTool('gog_docs_comments_delete', { docId: 'abc', commentId: 'c1' });
753
754
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
754
- ['docs', 'comments', 'delete', 'abc', 'c1', '--force'],
755
+ ['docs', 'comments', 'delete', pos('abc'), pos('c1'), '--force'],
755
756
  { account: undefined },
756
757
  );
757
758
  });
@@ -762,7 +763,7 @@ describe('gog_docs_trash', () => {
762
763
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
763
764
  const harness = await setupHandlers();
764
765
  await harness.callTool('gog_docs_trash', { docId: 'd1' });
765
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['drive', 'delete', 'd1', '--force'], { account: undefined });
766
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['drive', 'delete', pos('d1'), '--force'], { account: undefined });
766
767
  });
767
768
  });
768
769
 
@@ -772,7 +773,7 @@ describe('gog_docs_append', () => {
772
773
  const harness = await setupHandlers();
773
774
  await harness.callTool('gog_docs_append', { docId: 'd1', text: 'Hello' });
774
775
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
775
- ['docs', 'write', 'd1', '--append', '--text=Hello'],
776
+ ['docs', 'write', pos('d1'), '--append', '--text=Hello'],
776
777
  { account: undefined },
777
778
  );
778
779
  });
@@ -784,7 +785,7 @@ describe('gog_docs_append', () => {
784
785
  docId: 'd1', file: '/tmp/section.md', markdown: true, tab: 'Notes',
785
786
  });
786
787
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
787
- ['docs', 'write', 'd1', '--append', '--file=/tmp/section.md', '--markdown', '--tab=Notes'],
788
+ ['docs', 'write', pos('d1'), '--append', '--file=/tmp/section.md', '--markdown', '--tab=Notes'],
788
789
  { account: undefined },
789
790
  );
790
791
  });
@@ -817,14 +818,14 @@ describe('gog_docs_read', () => {
817
818
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('hello'));
818
819
  const harness = await setupHandlers();
819
820
  await harness.callTool('gog_docs_read', { docId: 'd1' });
820
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'cat', 'd1'], { account: undefined });
821
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'cat', pos('d1')], { account: undefined });
821
822
  });
822
823
 
823
824
  it('routes json format to gog docs raw --pretty', async () => {
824
825
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
825
826
  const harness = await setupHandlers();
826
827
  await harness.callTool('gog_docs_read', { docId: 'd1', format: 'json' });
827
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'raw', 'd1', '--pretty'], { account: undefined, lossless: true });
828
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'raw', pos('d1'), '--pretty'], { account: undefined, lossless: true });
828
829
  });
829
830
 
830
831
  it('passes tab, allTabs, maxBytes in text mode', async () => {
@@ -832,7 +833,7 @@ describe('gog_docs_read', () => {
832
833
  const harness = await setupHandlers();
833
834
  await harness.callTool('gog_docs_read', { docId: 'd1', tab: 'Section A', allTabs: true, maxBytes: 0 });
834
835
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
835
- ['docs', 'cat', 'd1', '--tab=Section A', '--all-tabs', '--max-bytes=0'],
836
+ ['docs', 'cat', pos('d1'), '--tab=Section A', '--all-tabs', '--max-bytes=0'],
836
837
  { account: undefined },
837
838
  );
838
839
  });
@@ -841,14 +842,14 @@ describe('gog_docs_read', () => {
841
842
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult(''));
842
843
  const harness = await setupHandlers();
843
844
  await harness.callTool('gog_docs_read', { docId: 'd1', chips: true });
844
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'cat', 'd1', '--chips'], { account: undefined });
845
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'cat', pos('d1'), '--chips'], { account: undefined });
845
846
  });
846
847
 
847
848
  it('ignores chips in json mode', async () => {
848
849
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
849
850
  const harness = await setupHandlers();
850
851
  await harness.callTool('gog_docs_read', { docId: 'd1', format: 'json', chips: true });
851
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'raw', 'd1', '--pretty'], { account: undefined, lossless: true });
852
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'raw', pos('d1'), '--pretty'], { account: undefined, lossless: true });
852
853
  });
853
854
  });
854
855
 
@@ -875,7 +876,7 @@ describe('gog_docs_format', () => {
875
876
  });
876
877
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
877
878
  [
878
- 'docs', 'format', 'd1',
879
+ 'docs', 'format', pos('d1'),
879
880
  '--match=Title',
880
881
  '--match-all',
881
882
  '--match-case',
@@ -906,7 +907,7 @@ describe('gog_docs_format', () => {
906
907
  noStrikethrough: true,
907
908
  });
908
909
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
909
- ['docs', 'format', 'd1', '--no-bold', '--no-italic', '--no-underline', '--no-strikethrough'],
910
+ ['docs', 'format', pos('d1'), '--no-bold', '--no-italic', '--no-underline', '--no-strikethrough'],
910
911
  { account: undefined },
911
912
  );
912
913
  });
@@ -915,7 +916,7 @@ describe('gog_docs_format', () => {
915
916
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
916
917
  const harness = await setupHandlers();
917
918
  await harness.callTool('gog_docs_format', { docId: 'd1' });
918
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'format', 'd1'], { account: undefined });
919
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'format', pos('d1')], { account: undefined });
919
920
  });
920
921
 
921
922
  // gog 0.18.0
@@ -926,7 +927,7 @@ describe('gog_docs_format', () => {
926
927
  docId: 'd1', match: 'Intro', headingLevel: 1, namedStyle: 'HEADING_1',
927
928
  });
928
929
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
929
- ['docs', 'format', 'd1', '--match=Intro', '--heading-level=1', '--named-style=HEADING_1'],
930
+ ['docs', 'format', pos('d1'), '--match=Intro', '--heading-level=1', '--named-style=HEADING_1'],
930
931
  { account: undefined },
931
932
  );
932
933
  });
@@ -936,7 +937,7 @@ describe('gog_docs_format', () => {
936
937
  const harness = await setupHandlers();
937
938
  await harness.callTool('gog_docs_format', { docId: 'd1', headingLevel: 0 });
938
939
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
939
- ['docs', 'format', 'd1', '--heading-level=0'],
940
+ ['docs', 'format', pos('d1'), '--heading-level=0'],
940
941
  { account: undefined },
941
942
  );
942
943
  });
@@ -947,7 +948,7 @@ describe('gog_docs_format', () => {
947
948
  const harness = await setupHandlers();
948
949
  await harness.callTool('gog_docs_format', { docId: 'd1', match: 'snippet', code: true });
949
950
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
950
- ['docs', 'format', 'd1', '--match=snippet', '--code'],
951
+ ['docs', 'format', pos('d1'), '--match=snippet', '--code'],
951
952
  { account: undefined },
952
953
  );
953
954
  });
@@ -958,7 +959,7 @@ describe('gog_docs_format', () => {
958
959
  const harness = await setupHandlers();
959
960
  await harness.callTool('gog_docs_format', { docId: 'd1', match: 'see docs', link: 'https://example.com' });
960
961
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
961
- ['docs', 'format', 'd1', '--match=see docs', '--link=https://example.com'],
962
+ ['docs', 'format', pos('d1'), '--match=see docs', '--link=https://example.com'],
962
963
  { account: undefined },
963
964
  );
964
965
  });
@@ -968,7 +969,7 @@ describe('gog_docs_format', () => {
968
969
  const harness = await setupHandlers();
969
970
  await harness.callTool('gog_docs_format', { docId: 'd1', match: 'linked', noLink: true });
970
971
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
971
- ['docs', 'format', 'd1', '--match=linked', '--no-link'],
972
+ ['docs', 'format', pos('d1'), '--match=linked', '--no-link'],
972
973
  { account: undefined },
973
974
  );
974
975
  });
@@ -982,7 +983,7 @@ describe('gog_docs_insert_page_break', () => {
982
983
  const harness = await setupHandlers();
983
984
  await harness.callTool('gog_docs_insert_page_break', { docId: 'd1', index: 42 });
984
985
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
985
- ['docs', 'insert-page-break', 'd1', '--index=42'],
986
+ ['docs', 'insert-page-break', pos('d1'), '--index=42'],
986
987
  { account: undefined },
987
988
  );
988
989
  });
@@ -993,7 +994,7 @@ describe('gog_docs_insert_page_break', () => {
993
994
  const harness = await setupHandlers();
994
995
  await harness.callTool('gog_docs_insert_page_break', { docId: 'd1', at: 'Chapter 2', occurrence: 1, matchCase: true });
995
996
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
996
- ['docs', 'insert-page-break', 'd1', '--at=Chapter 2', '--occurrence=1', '--match-case'],
997
+ ['docs', 'insert-page-break', pos('d1'), '--at=Chapter 2', '--occurrence=1', '--match-case'],
997
998
  { account: undefined },
998
999
  );
999
1000
  });
@@ -1003,7 +1004,7 @@ describe('gog_docs_insert_page_break', () => {
1003
1004
  const harness = await setupHandlers();
1004
1005
  await harness.callTool('gog_docs_insert_page_break', { docId: 'd1', atEnd: true, tab: 'Body' });
1005
1006
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1006
- ['docs', 'insert-page-break', 'd1', '--at-end', '--tab=Body'],
1007
+ ['docs', 'insert-page-break', pos('d1'), '--at-end', '--tab=Body'],
1007
1008
  { account: undefined },
1008
1009
  );
1009
1010
  });
@@ -1013,7 +1014,7 @@ describe('gog_docs_insert_page_break', () => {
1013
1014
  const harness = await setupHandlers();
1014
1015
  await harness.callTool('gog_docs_insert_page_break', { docId: 'd1', index: 1 });
1015
1016
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1016
- ['docs', 'insert-page-break', 'd1', '--index=1'],
1017
+ ['docs', 'insert-page-break', pos('d1'), '--index=1'],
1017
1018
  { account: undefined },
1018
1019
  );
1019
1020
  });
@@ -1025,7 +1026,7 @@ describe('gog_docs_page_layout', () => {
1025
1026
  const harness = await setupHandlers();
1026
1027
  await harness.callTool('gog_docs_page_layout', { docId: 'd1', layout: 'pages' });
1027
1028
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1028
- ['docs', 'page-layout', 'd1', '--layout=pages'],
1029
+ ['docs', 'page-layout', pos('d1'), '--layout=pages'],
1029
1030
  { account: undefined },
1030
1031
  );
1031
1032
  });
@@ -1034,7 +1035,7 @@ describe('gog_docs_page_layout', () => {
1034
1035
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1035
1036
  const harness = await setupHandlers();
1036
1037
  await harness.callTool('gog_docs_page_layout', { docId: 'd1' });
1037
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'page-layout', 'd1'], { account: undefined });
1038
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'page-layout', pos('d1')], { account: undefined });
1038
1039
  });
1039
1040
 
1040
1041
  it('passes --page-size, page dimensions and all margins', async () => {
@@ -1045,7 +1046,7 @@ describe('gog_docs_page_layout', () => {
1045
1046
  marginTop: '1in', marginBottom: '1in', marginLeft: '0.75in', marginRight: '0.75in',
1046
1047
  });
1047
1048
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1048
- ['docs', 'page-layout', 'd1', '--layout=pages', '--page-size=A4', '--page-width=8.5in',
1049
+ ['docs', 'page-layout', pos('d1'), '--layout=pages', '--page-size=A4', '--page-width=8.5in',
1049
1050
  '--page-height=11in', '--margin-top=1in', '--margin-bottom=1in', '--margin-left=0.75in', '--margin-right=0.75in'],
1050
1051
  { account: undefined },
1051
1052
  );
@@ -1059,7 +1060,7 @@ describe('gog_docs_page_layout', () => {
1059
1060
  const harness = await setupHandlers();
1060
1061
  await harness.callTool('gog_docs_page_layout', { docId: 'd1', pageSize: 'A3' });
1061
1062
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1062
- ['docs', 'page-layout', 'd1', '--page-size=A3'],
1063
+ ['docs', 'page-layout', pos('d1'), '--page-size=A3'],
1063
1064
  { account: undefined },
1064
1065
  );
1065
1066
  });
@@ -1071,7 +1072,7 @@ describe('gog_docs_cell_update', () => {
1071
1072
  const harness = await setupHandlers();
1072
1073
  await harness.callTool('gog_docs_cell_update', { docId: 'd1', row: 2, col: 3, content: 'hi' });
1073
1074
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1074
- ['docs', 'cell-update', 'd1', '--row=2', '--col=3', '--content=hi'],
1075
+ ['docs', 'cell-update', pos('d1'), '--row=2', '--col=3', '--content=hi'],
1075
1076
  { account: undefined },
1076
1077
  );
1077
1078
  });
@@ -1084,7 +1085,7 @@ describe('gog_docs_cell_update', () => {
1084
1085
  format: 'plain', tableIndex: -1, tab: 'Tab2',
1085
1086
  });
1086
1087
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1087
- ['docs', 'cell-update', 'd1', '--row=1', '--col=1', '--content=',
1088
+ ['docs', 'cell-update', pos('d1'), '--row=1', '--col=1', '--content=',
1088
1089
  '--append', '--format=plain', '--table-index=-1', '--tab=Tab2'],
1089
1090
  { account: undefined },
1090
1091
  );
@@ -1097,7 +1098,7 @@ describe('gog_docs_cell_update', () => {
1097
1098
  docId: 'd1', row: 1, col: 1, contentFile: '/tmp/c.md',
1098
1099
  });
1099
1100
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1100
- ['docs', 'cell-update', 'd1', '--row=1', '--col=1', '--content-file=/tmp/c.md'],
1101
+ ['docs', 'cell-update', pos('d1'), '--row=1', '--col=1', '--content-file=/tmp/c.md'],
1101
1102
  { account: undefined },
1102
1103
  );
1103
1104
  });
@@ -1133,7 +1134,7 @@ describe('gog_docs_cell_update', () => {
1133
1134
  const big = 'c'.repeat(lib.PAYLOAD_INLINE_MAX + 1);
1134
1135
  await harness.callTool('gog_docs_cell_update', { docId: 'd1', row: 2, col: 3, content: big });
1135
1136
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1136
- ['docs', 'cell-update', 'd1', '--row=2', '--col=3',
1137
+ ['docs', 'cell-update', pos('d1'), '--row=2', '--col=3',
1137
1138
  { kind: 'file', flag: 'content-file', contents: big, ext: 'md' }],
1138
1139
  { account: undefined },
1139
1140
  );
@@ -1144,7 +1145,7 @@ describe('gog_docs_cell_update', () => {
1144
1145
  const harness = await setupHandlers();
1145
1146
  await harness.callTool('gog_docs_cell_update', { docId: 'd1', row: 1, col: 2, account: 'a@b.com' });
1146
1147
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1147
- ['docs', 'cell-update', 'd1', '--row=1', '--col=2'],
1148
+ ['docs', 'cell-update', pos('d1'), '--row=1', '--col=2'],
1148
1149
  { account: 'a@b.com' },
1149
1150
  );
1150
1151
  });
@@ -1156,7 +1157,7 @@ describe('gog_docs_cell_style', () => {
1156
1157
  const harness = await setupHandlers();
1157
1158
  await harness.callTool('gog_docs_cell_style', { docId: 'd1', row: 0, col: 0 });
1158
1159
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1159
- ['docs', 'cell-style', 'd1', '--row=0', '--col=0'],
1160
+ ['docs', 'cell-style', pos('d1'), '--row=0', '--col=0'],
1160
1161
  { account: undefined },
1161
1162
  );
1162
1163
  });
@@ -1169,7 +1170,7 @@ describe('gog_docs_cell_style', () => {
1169
1170
  textColor: '#111', bold: true, italic: true, underline: true, tableIndex: 1, tab: 'T',
1170
1171
  });
1171
1172
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1172
- ['docs', 'cell-style', 'd1', '--row=1', '--col=2', '--row-span=2', '--col-span=3',
1173
+ ['docs', 'cell-style', pos('d1'), '--row=1', '--col=2', '--row-span=2', '--col-span=3',
1173
1174
  '--background-color=#eee', '--text-color=#111', '--bold', '--italic', '--underline',
1174
1175
  '--table-index=1', '--tab=T'],
1175
1176
  { account: undefined },
@@ -1181,7 +1182,7 @@ describe('gog_docs_cell_style', () => {
1181
1182
  const harness = await setupHandlers();
1182
1183
  await harness.callTool('gog_docs_cell_style', { docId: 'd1', row: 0, col: 0, bold: false, italic: false, underline: false });
1183
1184
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1184
- ['docs', 'cell-style', 'd1', '--row=0', '--col=0'],
1185
+ ['docs', 'cell-style', pos('d1'), '--row=0', '--col=0'],
1185
1186
  { account: undefined },
1186
1187
  );
1187
1188
  });
@@ -1196,7 +1197,7 @@ describe('gog_docs_cell_style', () => {
1196
1197
  contentAlign: 'middle',
1197
1198
  });
1198
1199
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1199
- ['docs', 'cell-style', 'd1', '--row=0', '--col=0',
1200
+ ['docs', 'cell-style', pos('d1'), '--row=0', '--col=0',
1200
1201
  '--border-all=1pt,#000,DASH', '--border-top=2pt', '--border-bottom=2pt', '--border-left=1pt', '--border-right=1pt',
1201
1202
  '--padding-all=5', '--padding-top=6pt', '--padding-bottom=6pt', '--padding-left=4mm', '--padding-right=4mm',
1202
1203
  '--content-align=middle'],
@@ -1211,7 +1212,7 @@ describe('gog_docs_insert_image', () => {
1211
1212
  const harness = await setupHandlers();
1212
1213
  await harness.callTool('gog_docs_insert_image', { docId: 'd1', file: '/tmp/pic.png' });
1213
1214
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1214
- ['docs', 'insert-image', 'd1', '--file=/tmp/pic.png', '--force'],
1215
+ ['docs', 'insert-image', pos('d1'), '--file=/tmp/pic.png', '--force'],
1215
1216
  { account: undefined },
1216
1217
  );
1217
1218
  });
@@ -1224,7 +1225,7 @@ describe('gog_docs_insert_image', () => {
1224
1225
  name: 'logo.png', parent: 'folder1', onRestricted: 'link', tab: 'T',
1225
1226
  });
1226
1227
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1227
- ['docs', 'insert-image', 'd1', '--file=/tmp/pic.png', '--at={{logo}}', '--width=200',
1228
+ ['docs', 'insert-image', pos('d1'), '--file=/tmp/pic.png', '--at={{logo}}', '--width=200',
1228
1229
  '--height=100', '--name=logo.png', '--parent=folder1', '--on-restricted=link', '--tab=T', '--force'],
1229
1230
  { account: undefined },
1230
1231
  );
@@ -1237,7 +1238,7 @@ describe('gog_docs_insert_image', () => {
1237
1238
  docId: 'd1', url: 'https://x.test/i.png', before: 'Intro', after: 'Outro',
1238
1239
  });
1239
1240
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1240
- ['docs', 'insert-image', 'd1', '--url=https://x.test/i.png', '--before=Intro', '--after=Outro'],
1241
+ ['docs', 'insert-image', pos('d1'), '--url=https://x.test/i.png', '--before=Intro', '--after=Outro'],
1241
1242
  { account: undefined },
1242
1243
  );
1243
1244
  });
@@ -1249,7 +1250,7 @@ describe('gog_docs_insert_person', () => {
1249
1250
  const harness = await setupHandlers();
1250
1251
  await harness.callTool('gog_docs_insert_person', { docId: 'd1', email: 'a@b.com' });
1251
1252
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1252
- ['docs', 'insert-person', 'd1', '--email=a@b.com'],
1253
+ ['docs', 'insert-person', pos('d1'), '--email=a@b.com'],
1253
1254
  { account: undefined },
1254
1255
  );
1255
1256
  });
@@ -1260,7 +1261,7 @@ describe('gog_docs_insert_person', () => {
1260
1261
  const harness = await setupHandlers();
1261
1262
  await harness.callTool('gog_docs_insert_person', { docId: 'd1', email: 'a@b.com', at: '@alice', occurrence: 1, matchCase: true });
1262
1263
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1263
- ['docs', 'insert-person', 'd1', '--email=a@b.com', '--at=@alice', '--occurrence=1', '--match-case'],
1264
+ ['docs', 'insert-person', pos('d1'), '--email=a@b.com', '--at=@alice', '--occurrence=1', '--match-case'],
1264
1265
  { account: undefined },
1265
1266
  );
1266
1267
  });
@@ -1270,7 +1271,7 @@ describe('gog_docs_insert_person', () => {
1270
1271
  const harness = await setupHandlers();
1271
1272
  await harness.callTool('gog_docs_insert_person', { docId: 'd1', email: 'a@b.com', index: 0, atEnd: true, tab: 'T' });
1272
1273
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1273
- ['docs', 'insert-person', 'd1', '--email=a@b.com', '--index=0', '--at-end', '--tab=T'],
1274
+ ['docs', 'insert-person', pos('d1'), '--email=a@b.com', '--index=0', '--at-end', '--tab=T'],
1274
1275
  { account: undefined },
1275
1276
  );
1276
1277
  });
@@ -1281,7 +1282,7 @@ describe('gog_docs_insert_date_chip', () => {
1281
1282
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1282
1283
  const harness = await setupHandlers();
1283
1284
  await harness.callTool('gog_docs_insert_date_chip', { docId: 'd1' });
1284
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'insert-date-chip', 'd1'], { account: undefined });
1285
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'insert-date-chip', pos('d1')], { account: undefined });
1285
1286
  });
1286
1287
 
1287
1288
  it('passes --date, --format, --index and --at-end', async () => {
@@ -1289,7 +1290,7 @@ describe('gog_docs_insert_date_chip', () => {
1289
1290
  const harness = await setupHandlers();
1290
1291
  await harness.callTool('gog_docs_insert_date_chip', { docId: 'd1', date: '2026-06-01', format: 'iso', index: 5, atEnd: true });
1291
1292
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1292
- ['docs', 'insert-date-chip', 'd1', '--date=2026-06-01', '--format=iso', '--index=5', '--at-end'],
1293
+ ['docs', 'insert-date-chip', pos('d1'), '--date=2026-06-01', '--format=iso', '--index=5', '--at-end'],
1293
1294
  { account: undefined },
1294
1295
  );
1295
1296
  });
@@ -1301,7 +1302,7 @@ describe('gog_docs_insert_table', () => {
1301
1302
  const harness = await setupHandlers();
1302
1303
  await harness.callTool('gog_docs_insert_table', { docId: 'd1', rows: 3, cols: 2 });
1303
1304
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1304
- ['docs', 'insert-table', 'd1', '--rows=3', '--cols=2'],
1305
+ ['docs', 'insert-table', pos('d1'), '--rows=3', '--cols=2'],
1305
1306
  { account: undefined },
1306
1307
  );
1307
1308
  });
@@ -1314,7 +1315,7 @@ describe('gog_docs_insert_table', () => {
1314
1315
  docId: 'd1', rows: 2, cols: 2, index: 10, valuesJson: vj, tab: 'Body',
1315
1316
  });
1316
1317
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1317
- ['docs', 'insert-table', 'd1', '--rows=2', '--cols=2', '--index=10', `--values-json=${vj}`, '--tab=Body'],
1318
+ ['docs', 'insert-table', pos('d1'), '--rows=2', '--cols=2', '--index=10', `--values-json=${vj}`, '--tab=Body'],
1318
1319
  { account: undefined },
1319
1320
  );
1320
1321
  });
@@ -1324,7 +1325,7 @@ describe('gog_docs_insert_table', () => {
1324
1325
  const harness = await setupHandlers();
1325
1326
  await harness.callTool('gog_docs_insert_table', { docId: 'd1', rows: 1, cols: 1, atEnd: true });
1326
1327
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1327
- ['docs', 'insert-table', 'd1', '--rows=1', '--cols=1', '--at-end'],
1328
+ ['docs', 'insert-table', pos('d1'), '--rows=1', '--cols=1', '--at-end'],
1328
1329
  { account: undefined },
1329
1330
  );
1330
1331
  });
@@ -1336,7 +1337,7 @@ describe('gog_docs_comments_reopen', () => {
1336
1337
  const harness = await setupHandlers();
1337
1338
  await harness.callTool('gog_docs_comments_reopen', { docId: 'd1', commentId: 'c1' });
1338
1339
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1339
- ['docs', 'comments', 'reopen', 'd1', 'c1'],
1340
+ ['docs', 'comments', 'reopen', pos('d1'), pos('c1')],
1340
1341
  { account: undefined },
1341
1342
  );
1342
1343
  });
@@ -1346,7 +1347,7 @@ describe('gog_docs_comments_reopen', () => {
1346
1347
  const harness = await setupHandlers();
1347
1348
  await harness.callTool('gog_docs_comments_reopen', { docId: 'd1', commentId: 'c1', account: 'a@b.com' });
1348
1349
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1349
- ['docs', 'comments', 'reopen', 'd1', 'c1'],
1350
+ ['docs', 'comments', 'reopen', pos('d1'), pos('c1')],
1350
1351
  { account: 'a@b.com' },
1351
1352
  );
1352
1353
  });
@@ -1359,7 +1360,7 @@ describe('gog_docs_add_tab', () => {
1359
1360
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1360
1361
  const harness = await setupHandlers();
1361
1362
  await harness.callTool('gog_docs_add_tab', { docId: 'abc' });
1362
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'add-tab', 'abc'], { account: undefined });
1363
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'add-tab', pos('abc')], { account: undefined });
1363
1364
  });
1364
1365
 
1365
1366
  it('includes all flags when provided', async () => {
@@ -1374,7 +1375,7 @@ describe('gog_docs_add_tab', () => {
1374
1375
  account: 'a@b.com',
1375
1376
  });
1376
1377
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1377
- ['docs', 'add-tab', 'abc', '--title=Notes', '--index=2', '--parent-tab=Intro', '--icon-emoji=📌'],
1378
+ ['docs', 'add-tab', pos('abc'), '--title=Notes', '--index=2', '--parent-tab=Intro', '--icon-emoji=📌'],
1378
1379
  { account: 'a@b.com' },
1379
1380
  );
1380
1381
  });
@@ -1384,7 +1385,7 @@ describe('gog_docs_add_tab', () => {
1384
1385
  const harness = await setupHandlers();
1385
1386
  await harness.callTool('gog_docs_add_tab', { docId: 'abc', index: 0 });
1386
1387
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1387
- ['docs', 'add-tab', 'abc', '--index=0'],
1388
+ ['docs', 'add-tab', pos('abc'), '--index=0'],
1388
1389
  { account: undefined },
1389
1390
  );
1390
1391
  });
@@ -1398,7 +1399,7 @@ describe('gog_docs_rename_tab', () => {
1398
1399
  const harness = await setupHandlers();
1399
1400
  await harness.callTool('gog_docs_rename_tab', { docId: 'abc', tab: 'Old', title: 'New' });
1400
1401
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1401
- ['docs', 'rename-tab', 'abc', '--tab=Old', '--title=New'],
1402
+ ['docs', 'rename-tab', pos('abc'), '--tab=Old', '--title=New'],
1402
1403
  { account: undefined },
1403
1404
  );
1404
1405
  });
@@ -1408,7 +1409,7 @@ describe('gog_docs_rename_tab', () => {
1408
1409
  const harness = await setupHandlers();
1409
1410
  await harness.callTool('gog_docs_rename_tab', { docId: 'abc', tab: 't1', title: 'New', account: 'a@b.com' });
1410
1411
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1411
- ['docs', 'rename-tab', 'abc', '--tab=t1', '--title=New'],
1412
+ ['docs', 'rename-tab', pos('abc'), '--tab=t1', '--title=New'],
1412
1413
  { account: 'a@b.com' },
1413
1414
  );
1414
1415
  });
@@ -1422,7 +1423,7 @@ describe('gog_docs_delete_tab', () => {
1422
1423
  const harness = await setupHandlers();
1423
1424
  await harness.callTool('gog_docs_delete_tab', { docId: 'abc', tab: 'Old' });
1424
1425
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1425
- ['docs', 'delete-tab', 'abc', '--tab=Old', '--force'],
1426
+ ['docs', 'delete-tab', pos('abc'), '--tab=Old', '--force'],
1426
1427
  { account: undefined },
1427
1428
  );
1428
1429
  });
@@ -1432,7 +1433,7 @@ describe('gog_docs_delete_tab', () => {
1432
1433
  const harness = await setupHandlers();
1433
1434
  await harness.callTool('gog_docs_delete_tab', { docId: 'abc', tab: 't1', account: 'a@b.com' });
1434
1435
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1435
- ['docs', 'delete-tab', 'abc', '--tab=t1', '--force'],
1436
+ ['docs', 'delete-tab', pos('abc'), '--tab=t1', '--force'],
1436
1437
  { account: 'a@b.com' },
1437
1438
  );
1438
1439
  });
@@ -1445,14 +1446,14 @@ describe('gog_docs_clear', () => {
1445
1446
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1446
1447
  const harness = await setupHandlers();
1447
1448
  await harness.callTool('gog_docs_clear', { docId: 'abc' });
1448
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'clear', 'abc'], { account: undefined });
1449
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'clear', pos('abc')], { account: undefined });
1449
1450
  });
1450
1451
 
1451
1452
  it('forwards account override', async () => {
1452
1453
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1453
1454
  const harness = await setupHandlers();
1454
1455
  await harness.callTool('gog_docs_clear', { docId: 'abc', account: 'a@b.com' });
1455
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'clear', 'abc'], { account: 'a@b.com' });
1456
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'clear', pos('abc')], { account: 'a@b.com' });
1456
1457
  });
1457
1458
  });
1458
1459
 
@@ -1466,7 +1467,7 @@ describe('gog_docs_table_row_insert', () => {
1466
1467
  docId: 'd1', table: '2', at: 'end', valuesJson: '["A","B"]', tab: 'T',
1467
1468
  });
1468
1469
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1469
- ['docs', 'table-row', 'insert', 'd1', '--table=2', '--at=end', '--values-json=["A","B"]', '--tab=T'],
1470
+ ['docs', 'table-row', 'insert', pos('d1'), '--table=2', '--at=end', '--values-json=["A","B"]', '--tab=T'],
1470
1471
  { account: undefined },
1471
1472
  );
1472
1473
  });
@@ -1475,7 +1476,7 @@ describe('gog_docs_table_row_insert', () => {
1475
1476
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1476
1477
  const harness = await setupHandlers();
1477
1478
  await harness.callTool('gog_docs_table_row_insert', { docId: 'd1' });
1478
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'table-row', 'insert', 'd1'], { account: undefined });
1479
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'table-row', 'insert', pos('d1')], { account: undefined });
1479
1480
  });
1480
1481
  });
1481
1482
 
@@ -1485,7 +1486,7 @@ describe('gog_docs_table_row_delete', () => {
1485
1486
  const harness = await setupHandlers();
1486
1487
  await harness.callTool('gog_docs_table_row_delete', { docId: 'd1', row: -1, table: 'Budget' });
1487
1488
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1488
- ['docs', 'table-row', 'delete', 'd1', '--row=-1', '--table=Budget'],
1489
+ ['docs', 'table-row', 'delete', pos('d1'), '--row=-1', '--table=Budget'],
1489
1490
  { account: undefined },
1490
1491
  );
1491
1492
  });
@@ -1497,7 +1498,7 @@ describe('gog_docs_table_column_insert', () => {
1497
1498
  const harness = await setupHandlers();
1498
1499
  await harness.callTool('gog_docs_table_column_insert', { docId: 'd1', at: '3', table: '*', tab: 'T' });
1499
1500
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1500
- ['docs', 'table-column', 'insert', 'd1', '--at=3', '--table=*', '--tab=T'],
1501
+ ['docs', 'table-column', 'insert', pos('d1'), '--at=3', '--table=*', '--tab=T'],
1501
1502
  { account: undefined },
1502
1503
  );
1503
1504
  });
@@ -1509,7 +1510,7 @@ describe('gog_docs_table_column_delete', () => {
1509
1510
  const harness = await setupHandlers();
1510
1511
  await harness.callTool('gog_docs_table_column_delete', { docId: 'd1', col: 2 });
1511
1512
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1512
- ['docs', 'table-column', 'delete', 'd1', '--col=2'],
1513
+ ['docs', 'table-column', 'delete', pos('d1'), '--col=2'],
1513
1514
  { account: undefined },
1514
1515
  );
1515
1516
  });
@@ -1521,7 +1522,7 @@ describe('gog_docs_table_merge', () => {
1521
1522
  const harness = await setupHandlers();
1522
1523
  await harness.callTool('gog_docs_table_merge', { docId: 'd1', range: '1,1:2,3', table: '1' });
1523
1524
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1524
- ['docs', 'table-merge', 'd1', '--range=1,1:2,3', '--table=1'],
1525
+ ['docs', 'table-merge', pos('d1'), '--range=1,1:2,3', '--table=1'],
1525
1526
  { account: undefined },
1526
1527
  );
1527
1528
  });
@@ -1533,7 +1534,7 @@ describe('gog_docs_table_unmerge', () => {
1533
1534
  const harness = await setupHandlers();
1534
1535
  await harness.callTool('gog_docs_table_unmerge', { docId: 'd1', cell: '1,1', tab: 'T' });
1535
1536
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1536
- ['docs', 'table-unmerge', 'd1', '--cell=1,1', '--tab=T'],
1537
+ ['docs', 'table-unmerge', pos('d1'), '--cell=1,1', '--tab=T'],
1537
1538
  { account: undefined },
1538
1539
  );
1539
1540
  });
@@ -1547,7 +1548,7 @@ describe('gog_docs_named_range_create', () => {
1547
1548
  docId: 'd1', name: 'intro', at: 'Introduction', occurrence: 1, matchCase: true,
1548
1549
  });
1549
1550
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1550
- ['docs', 'named-range', 'create', 'd1', '--name=intro', '--at=Introduction', '--occurrence=1', '--match-case'],
1551
+ ['docs', 'named-range', 'create', pos('d1'), '--name=intro', '--at=Introduction', '--occurrence=1', '--match-case'],
1551
1552
  { account: undefined },
1552
1553
  );
1553
1554
  });
@@ -1557,7 +1558,7 @@ describe('gog_docs_named_range_create', () => {
1557
1558
  const harness = await setupHandlers();
1558
1559
  await harness.callTool('gog_docs_named_range_create', { docId: 'd1', name: 'intro', start: 5, end: 20, tab: 'T' });
1559
1560
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1560
- ['docs', 'named-range', 'create', 'd1', '--name=intro', '--start=5', '--end=20', '--tab=T'],
1561
+ ['docs', 'named-range', 'create', pos('d1'), '--name=intro', '--start=5', '--end=20', '--tab=T'],
1561
1562
  { account: undefined },
1562
1563
  );
1563
1564
  });
@@ -1569,7 +1570,7 @@ describe('gog_docs_named_range_list', () => {
1569
1570
  const harness = await setupHandlers();
1570
1571
  await harness.callTool('gog_docs_named_range_list', { docId: 'd1', name: 'intro' });
1571
1572
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1572
- ['docs', 'named-range', 'list', 'd1', '--name=intro'],
1573
+ ['docs', 'named-range', 'list', pos('d1'), '--name=intro'],
1573
1574
  { account: undefined },
1574
1575
  );
1575
1576
  });
@@ -1581,7 +1582,7 @@ describe('gog_docs_named_range_delete', () => {
1581
1582
  const harness = await setupHandlers();
1582
1583
  await harness.callTool('gog_docs_named_range_delete', { docId: 'd1', nameOrId: 'intro' });
1583
1584
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1584
- ['docs', 'named-range', 'delete', 'd1', 'intro'],
1585
+ ['docs', 'named-range', 'delete', pos('d1'), pos('intro')],
1585
1586
  { account: undefined },
1586
1587
  );
1587
1588
  });
@@ -1593,7 +1594,7 @@ describe('gog_docs_named_range_replace', () => {
1593
1594
  const harness = await setupHandlers();
1594
1595
  await harness.callTool('gog_docs_named_range_replace', { docId: 'd1', nameOrId: 'intro', text: 'New intro', tab: 'T' });
1595
1596
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1596
- ['docs', 'named-range', 'replace', 'd1', 'intro', '--text=New intro', '--tab=T'],
1597
+ ['docs', 'named-range', 'replace', pos('d1'), pos('intro'), '--text=New intro', '--tab=T'],
1597
1598
  { account: undefined },
1598
1599
  );
1599
1600
  });
@@ -1603,7 +1604,7 @@ describe('gog_docs_named_range_replace', () => {
1603
1604
  const harness = await setupHandlers();
1604
1605
  await harness.callTool('gog_docs_named_range_replace', { docId: 'd1', nameOrId: 'kix.abc', file: '/tmp/intro.txt' });
1605
1606
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1606
- ['docs', 'named-range', 'replace', 'd1', 'kix.abc', '--file=/tmp/intro.txt'],
1607
+ ['docs', 'named-range', 'replace', pos('d1'), pos('kix.abc'), '--file=/tmp/intro.txt'],
1607
1608
  { account: undefined },
1608
1609
  );
1609
1610
  });
@@ -1614,7 +1615,7 @@ describe('gog_docs_tables_list', () => {
1614
1615
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1615
1616
  const harness = await setupHandlers();
1616
1617
  await harness.callTool('gog_docs_tables_list', { docId: 'd1', tab: 'T' });
1617
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'tables', 'list', 'd1', '--tab=T'], { account: undefined });
1618
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'tables', 'list', pos('d1'), '--tab=T'], { account: undefined });
1618
1619
  });
1619
1620
  });
1620
1621
 
@@ -1623,7 +1624,7 @@ describe('gog_docs_images_list', () => {
1623
1624
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1624
1625
  const harness = await setupHandlers();
1625
1626
  await harness.callTool('gog_docs_images_list', { docId: 'd1' });
1626
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'images', 'list', 'd1'], { account: undefined });
1627
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'images', 'list', pos('d1')], { account: undefined });
1627
1628
  });
1628
1629
  });
1629
1630
 
@@ -1632,7 +1633,7 @@ describe('gog_docs_headings_list', () => {
1632
1633
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1633
1634
  const harness = await setupHandlers();
1634
1635
  await harness.callTool('gog_docs_headings_list', { docId: 'd1', level: 2 });
1635
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'headings', 'list', 'd1', '--level=2'], { account: undefined });
1636
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'headings', 'list', pos('d1'), '--level=2'], { account: undefined });
1636
1637
  });
1637
1638
  });
1638
1639
 
@@ -1642,7 +1643,7 @@ describe('gog_docs_paragraphs_list', () => {
1642
1643
  const harness = await setupHandlers();
1643
1644
  await harness.callTool('gog_docs_paragraphs_list', { docId: 'd1', style: 'HEADING_2', tab: 'T' });
1644
1645
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1645
- ['docs', 'paragraphs', 'list', 'd1', '--style=HEADING_2', '--tab=T'],
1646
+ ['docs', 'paragraphs', 'list', pos('d1'), '--style=HEADING_2', '--tab=T'],
1646
1647
  { account: undefined },
1647
1648
  );
1648
1649
  });
@@ -1654,7 +1655,7 @@ describe('gog_docs_insert_image url mode', () => {
1654
1655
  const harness = await setupHandlers();
1655
1656
  await harness.callTool('gog_docs_insert_image', { docId: 'd1', url: 'https://x.test/i.png', at: '{{logo}}' });
1656
1657
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1657
- ['docs', 'insert-image', 'd1', '--url=https://x.test/i.png', '--at={{logo}}'],
1658
+ ['docs', 'insert-image', pos('d1'), '--url=https://x.test/i.png', '--at={{logo}}'],
1658
1659
  { account: undefined },
1659
1660
  );
1660
1661
  });
@@ -1665,14 +1666,14 @@ describe('gog_docs_read json tab targeting', () => {
1665
1666
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1666
1667
  const harness = await setupHandlers();
1667
1668
  await harness.callTool('gog_docs_read', { docId: 'd1', format: 'json', tab: 'T' });
1668
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'raw', 'd1', '--pretty', '--tab=T'], { account: undefined, lossless: true });
1669
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'raw', pos('d1'), '--pretty', '--tab=T'], { account: undefined, lossless: true });
1669
1670
  });
1670
1671
 
1671
1672
  it('passes --all-tabs through to docs raw in json mode', async () => {
1672
1673
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1673
1674
  const harness = await setupHandlers();
1674
1675
  await harness.callTool('gog_docs_read', { docId: 'd1', format: 'json', allTabs: true });
1675
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'raw', 'd1', '--pretty', '--all-tabs'], { account: undefined, lossless: true });
1676
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'raw', pos('d1'), '--pretty', '--all-tabs'], { account: undefined, lossless: true });
1676
1677
  });
1677
1678
  });
1678
1679
 
@@ -1704,7 +1705,7 @@ describe('batch lifecycle tools', () => {
1704
1705
  const harness = await setupHandlers();
1705
1706
  await harness.callTool('gog_batch_end', { batchId: 'b1', autoSplit: true, continueOnError: true });
1706
1707
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1707
- ['batch', 'end', 'b1', '--auto-split', '--continue-on-error'],
1708
+ ['batch', 'end', pos('b1'), '--auto-split', '--continue-on-error'],
1708
1709
  { account: undefined },
1709
1710
  );
1710
1711
  });
@@ -1714,7 +1715,7 @@ describe('batch lifecycle tools', () => {
1714
1715
  const harness = await setupHandlers();
1715
1716
  await harness.callTool('gog_batch_end', { batchId: 'b1' });
1716
1717
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1717
- ['batch', 'end', 'b1'],
1718
+ ['batch', 'end', pos('b1')],
1718
1719
  { account: undefined },
1719
1720
  );
1720
1721
  });
@@ -1723,7 +1724,7 @@ describe('batch lifecycle tools', () => {
1723
1724
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1724
1725
  const harness = await setupHandlers();
1725
1726
  await harness.callTool('gog_batch_abort', { batchId: 'b1' });
1726
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['batch', 'abort', 'b1'], { account: undefined });
1727
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['batch', 'abort', pos('b1')], { account: undefined });
1727
1728
  });
1728
1729
 
1729
1730
  it('gog_batch_list / gog_batch_show read batch state', async () => {
@@ -1732,7 +1733,7 @@ describe('batch lifecycle tools', () => {
1732
1733
  await harness.callTool('gog_batch_list', {});
1733
1734
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(['batch', 'list'], { account: undefined });
1734
1735
  await harness.callTool('gog_batch_show', { batchId: 'b1' });
1735
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['batch', 'show', 'b1'], { account: undefined });
1736
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['batch', 'show', pos('b1')], { account: undefined });
1736
1737
  });
1737
1738
 
1738
1739
  it('gog_batch_prune deletes stale batches', async () => {
@@ -1755,23 +1756,23 @@ describe('batch param on docs mutation tools (gog 0.25.0)', () => {
1755
1756
  // batch instead of submitting when batch is supplied.
1756
1757
  const cases: Array<{ tool: string; input: Record<string, unknown>; expected: string[] }> = [
1757
1758
  { tool: 'gog_docs_insert', input: { docId: 'd1', content: 'X', batch: 'b1' },
1758
- expected: ['docs', 'insert', 'd1', 'X', '--batch=b1'] },
1759
+ expected: ['docs', 'insert', pos('d1'), pos('X'), '--batch=b1'] },
1759
1760
  { tool: 'gog_docs_delete', input: { docId: 'd1', start: 1, end: 5, batch: 'b1' },
1760
- expected: ['docs', 'delete', '--start=1', '--end=5', 'd1', '--batch=b1'] },
1761
+ expected: ['docs', 'delete', '--start=1', '--end=5', pos('d1'), '--batch=b1'] },
1761
1762
  { tool: 'gog_docs_update', input: { docId: 'd1', text: 'T', batch: 'b1' },
1762
- expected: ['docs', 'update', 'd1', '--text=T', '--batch=b1'] },
1763
+ expected: ['docs', 'update', pos('d1'), '--text=T', '--batch=b1'] },
1763
1764
  { tool: 'gog_docs_format', input: { docId: 'd1', match: 'm', bold: true, batch: 'b1' },
1764
- expected: ['docs', 'format', 'd1', '--match=m', '--bold', '--batch=b1'] },
1765
+ expected: ['docs', 'format', pos('d1'), '--match=m', '--bold', '--batch=b1'] },
1765
1766
  { tool: 'gog_docs_insert_page_break', input: { docId: 'd1', atEnd: true, batch: 'b1' },
1766
- expected: ['docs', 'insert-page-break', 'd1', '--at-end', '--batch=b1'] },
1767
+ expected: ['docs', 'insert-page-break', pos('d1'), '--at-end', '--batch=b1'] },
1767
1768
  { tool: 'gog_docs_insert_person', input: { docId: 'd1', email: 'a@b.com', batch: 'b1' },
1768
- expected: ['docs', 'insert-person', 'd1', '--email=a@b.com', '--batch=b1'] },
1769
+ expected: ['docs', 'insert-person', pos('d1'), '--email=a@b.com', '--batch=b1'] },
1769
1770
  { tool: 'gog_docs_insert_date_chip', input: { docId: 'd1', batch: 'b1' },
1770
- expected: ['docs', 'insert-date-chip', 'd1', '--batch=b1'] },
1771
+ expected: ['docs', 'insert-date-chip', pos('d1'), '--batch=b1'] },
1771
1772
  { tool: 'gog_docs_table_column_width', input: { docId: 'd1', col: 1, width: 80, batch: 'b1' },
1772
- expected: ['docs', 'table-column-width', 'd1', '--col=1', '--width=80', '--batch=b1'] },
1773
+ expected: ['docs', 'table-column-width', pos('d1'), '--col=1', '--width=80', '--batch=b1'] },
1773
1774
  { tool: 'gog_docs_cell_style', input: { docId: 'd1', row: 0, col: 0, bold: true, batch: 'b1' },
1774
- expected: ['docs', 'cell-style', 'd1', '--row=0', '--col=0', '--bold', '--batch=b1'] },
1775
+ expected: ['docs', 'cell-style', pos('d1'), '--row=0', '--col=0', '--bold', '--batch=b1'] },
1775
1776
  ];
1776
1777
 
1777
1778
  for (const { tool, input, expected } of cases) {
@@ -1789,23 +1790,23 @@ describe('batch param on docs mutation tools (gog 0.25.0)', () => {
1789
1790
  describe('tab/table selector branch coverage', () => {
1790
1791
  const cases: Array<{ tool: string; input: Record<string, unknown>; expected: string[] }> = [
1791
1792
  { tool: 'gog_docs_table_row_delete', input: { docId: 'd1', row: 1, tab: 'T' },
1792
- expected: ['docs', 'table-row', 'delete', 'd1', '--row=1', '--tab=T'] },
1793
+ expected: ['docs', 'table-row', 'delete', pos('d1'), '--row=1', '--tab=T'] },
1793
1794
  { tool: 'gog_docs_table_column_delete', input: { docId: 'd1', col: 1, table: '2', tab: 'T' },
1794
- expected: ['docs', 'table-column', 'delete', 'd1', '--col=1', '--table=2', '--tab=T'] },
1795
+ expected: ['docs', 'table-column', 'delete', pos('d1'), '--col=1', '--table=2', '--tab=T'] },
1795
1796
  { tool: 'gog_docs_table_merge', input: { docId: 'd1', range: '1,1:2,2', tab: 'T' },
1796
- expected: ['docs', 'table-merge', 'd1', '--range=1,1:2,2', '--tab=T'] },
1797
+ expected: ['docs', 'table-merge', pos('d1'), '--range=1,1:2,2', '--tab=T'] },
1797
1798
  { tool: 'gog_docs_table_unmerge', input: { docId: 'd1', cell: '1,1', table: 'Budget' },
1798
- expected: ['docs', 'table-unmerge', 'd1', '--cell=1,1', '--table=Budget'] },
1799
+ expected: ['docs', 'table-unmerge', pos('d1'), '--cell=1,1', '--table=Budget'] },
1799
1800
  { tool: 'gog_docs_named_range_list', input: { docId: 'd1', tab: 'T' },
1800
- expected: ['docs', 'named-range', 'list', 'd1', '--tab=T'] },
1801
+ expected: ['docs', 'named-range', 'list', pos('d1'), '--tab=T'] },
1801
1802
  { tool: 'gog_docs_named_range_delete', input: { docId: 'd1', nameOrId: 'nr', tab: 'T' },
1802
- expected: ['docs', 'named-range', 'delete', 'd1', 'nr', '--tab=T'] },
1803
+ expected: ['docs', 'named-range', 'delete', pos('d1'), pos('nr'), '--tab=T'] },
1803
1804
  { tool: 'gog_docs_images_list', input: { docId: 'd1', tab: 'T' },
1804
- expected: ['docs', 'images', 'list', 'd1', '--tab=T'] },
1805
+ expected: ['docs', 'images', 'list', pos('d1'), '--tab=T'] },
1805
1806
  { tool: 'gog_docs_headings_list', input: { docId: 'd1', tab: 'T' },
1806
- expected: ['docs', 'headings', 'list', 'd1', '--tab=T'] },
1807
+ expected: ['docs', 'headings', 'list', pos('d1'), '--tab=T'] },
1807
1808
  { tool: 'gog_docs_insert_date_chip', input: { docId: 'd1', tab: 'T' },
1808
- expected: ['docs', 'insert-date-chip', 'd1', '--tab=T'] },
1809
+ expected: ['docs', 'insert-date-chip', pos('d1'), '--tab=T'] },
1809
1810
  ];
1810
1811
  for (const { tool, input, expected } of cases) {
1811
1812
  it(`${tool} passes its tab/table selectors`, async () => {
@@ -1820,11 +1821,11 @@ describe('tab/table selector branch coverage', () => {
1820
1821
  describe('bare-call branch coverage (no optional flags)', () => {
1821
1822
  const cases: Array<{ tool: string; input: Record<string, unknown>; expected: string[] }> = [
1822
1823
  { tool: 'gog_docs_table_column_insert', input: { docId: 'd1' },
1823
- expected: ['docs', 'table-column', 'insert', 'd1'] },
1824
+ expected: ['docs', 'table-column', 'insert', pos('d1')] },
1824
1825
  { tool: 'gog_docs_tables_list', input: { docId: 'd1' },
1825
- expected: ['docs', 'tables', 'list', 'd1'] },
1826
+ expected: ['docs', 'tables', 'list', pos('d1')] },
1826
1827
  { tool: 'gog_docs_paragraphs_list', input: { docId: 'd1' },
1827
- expected: ['docs', 'paragraphs', 'list', 'd1'] },
1828
+ expected: ['docs', 'paragraphs', 'list', pos('d1')] },
1828
1829
  ];
1829
1830
  for (const { tool, input, expected } of cases) {
1830
1831
  it(`${tool} with no optional flags`, async () => {
@@ -1846,7 +1847,7 @@ describe('segment targeting (gog 0.30)', () => {
1846
1847
  const harness = await setupHandlers();
1847
1848
  await harness.callTool('gog_docs_insert', { docId: 'd1', content: 'hi', segment: 'kix.h1' });
1848
1849
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1849
- ['docs', 'insert', 'd1', 'hi', '--segment=kix.h1'],
1850
+ ['docs', 'insert', pos('d1'), pos('hi'), '--segment=kix.h1'],
1850
1851
  { account: undefined },
1851
1852
  );
1852
1853
  });
@@ -1856,7 +1857,7 @@ describe('segment targeting (gog 0.30)', () => {
1856
1857
  const harness = await setupHandlers();
1857
1858
  await harness.callTool('gog_docs_update', { docId: 'd1', text: 'hi', segment: 'kix.f1' });
1858
1859
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1859
- ['docs', 'update', 'd1', '--text=hi', '--segment=kix.f1'],
1860
+ ['docs', 'update', pos('d1'), '--text=hi', '--segment=kix.f1'],
1860
1861
  { account: undefined },
1861
1862
  );
1862
1863
  });
@@ -1866,7 +1867,7 @@ describe('segment targeting (gog 0.30)', () => {
1866
1867
  const harness = await setupHandlers();
1867
1868
  await harness.callTool('gog_docs_delete', { docId: 'd1', start: 1, end: 5, segment: 'kix.h1' });
1868
1869
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1869
- ['docs', 'delete', '--start=1', '--end=5', 'd1', '--segment=kix.h1'],
1870
+ ['docs', 'delete', '--start=1', '--end=5', pos('d1'), '--segment=kix.h1'],
1870
1871
  { account: undefined },
1871
1872
  );
1872
1873
  });
@@ -1876,7 +1877,7 @@ describe('segment targeting (gog 0.30)', () => {
1876
1877
  const harness = await setupHandlers();
1877
1878
  await harness.callTool('gog_docs_find_range', { docId: 'd1', text: 'Heading', segment: 'kix.h1' });
1878
1879
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1879
- ['docs', 'find-range', 'd1', 'Heading', '--segment=kix.h1'],
1880
+ ['docs', 'find-range', pos('d1'), pos('Heading'), '--segment=kix.h1'],
1880
1881
  { account: undefined },
1881
1882
  );
1882
1883
  });
@@ -1892,7 +1893,7 @@ describe('gog_docs_format paragraph list / indent / spacing / keep (gog 0.30)',
1892
1893
  keepLinesTogether: true, keepWithNext: true, segment: 'kix.h1',
1893
1894
  });
1894
1895
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1895
- ['docs', 'format', 'd1', '--bullets', '--bullet-preset=BULLET_DISC_CIRCLE_SQUARE',
1896
+ ['docs', 'format', pos('d1'), '--bullets', '--bullet-preset=BULLET_DISC_CIRCLE_SQUARE',
1896
1897
  '--indent-start=18', '--indent-end=6', '--indent-first-line=36', '--space-above=4', '--space-below=8',
1897
1898
  '--keep-lines-together', '--keep-with-next', '--segment=kix.h1'],
1898
1899
  { account: undefined },
@@ -1906,7 +1907,7 @@ describe('gog_docs_format paragraph list / indent / spacing / keep (gog 0.30)',
1906
1907
  docId: 'd1', ordered: true, noBullets: true, keepLinesTogether: false, keepWithNext: false,
1907
1908
  });
1908
1909
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1909
- ['docs', 'format', 'd1', '--ordered', '--no-bullets', '--no-keep-lines-together', '--no-keep-with-next'],
1910
+ ['docs', 'format', pos('d1'), '--ordered', '--no-bullets', '--no-keep-lines-together', '--no-keep-with-next'],
1910
1911
  { account: undefined },
1911
1912
  );
1912
1913
  });
@@ -1921,7 +1922,7 @@ describe('gog_docs_insert_footnote', () => {
1921
1922
  at: 'word', occurrence: 2, matchCase: true, tab: 'T',
1922
1923
  });
1923
1924
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1924
- ['docs', 'insert-footnote', 'd1', '--text=note', '--file=/tmp/n.txt', '--index=5', '--at-end',
1925
+ ['docs', 'insert-footnote', pos('d1'), '--text=note', '--file=/tmp/n.txt', '--index=5', '--at-end',
1925
1926
  '--at=word', '--occurrence=2', '--match-case', '--tab=T'],
1926
1927
  { account: undefined },
1927
1928
  );
@@ -1931,7 +1932,7 @@ describe('gog_docs_insert_footnote', () => {
1931
1932
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1932
1933
  const harness = await setupHandlers();
1933
1934
  await harness.callTool('gog_docs_insert_footnote', { docId: 'd1' });
1934
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'insert-footnote', 'd1'], { account: undefined });
1935
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'insert-footnote', pos('d1')], { account: undefined });
1935
1936
  });
1936
1937
  });
1937
1938
 
@@ -1944,7 +1945,7 @@ describe('gog_docs_insert_section_break', () => {
1944
1945
  occurrence: 1, matchCase: true, tab: 'T', batch: 'b1',
1945
1946
  });
1946
1947
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1947
- ['docs', 'insert-section-break', 'd1', '--type=continuous', '--index=3', '--at-end',
1948
+ ['docs', 'insert-section-break', pos('d1'), '--type=continuous', '--index=3', '--at-end',
1948
1949
  '--at=x', '--occurrence=1', '--match-case', '--tab=T', '--batch=b1'],
1949
1950
  { account: undefined },
1950
1951
  );
@@ -1954,7 +1955,7 @@ describe('gog_docs_insert_section_break', () => {
1954
1955
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1955
1956
  const harness = await setupHandlers();
1956
1957
  await harness.callTool('gog_docs_insert_section_break', { docId: 'd1' });
1957
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'insert-section-break', 'd1'], { account: undefined });
1958
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'insert-section-break', pos('d1')], { account: undefined });
1958
1959
  });
1959
1960
  });
1960
1961
 
@@ -1966,7 +1967,7 @@ describe('gog_docs_insert_horizontal_rule', () => {
1966
1967
  docId: 'd1', index: 2, atEnd: true, at: 'x', occurrence: 1, matchCase: true, tab: 'T', batch: 'b1',
1967
1968
  });
1968
1969
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1969
- ['docs', 'insert-horizontal-rule', 'd1', '--index=2', '--at-end', '--at=x',
1970
+ ['docs', 'insert-horizontal-rule', pos('d1'), '--index=2', '--at-end', '--at=x',
1970
1971
  '--occurrence=1', '--match-case', '--tab=T', '--batch=b1'],
1971
1972
  { account: undefined },
1972
1973
  );
@@ -1976,7 +1977,7 @@ describe('gog_docs_insert_horizontal_rule', () => {
1976
1977
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
1977
1978
  const harness = await setupHandlers();
1978
1979
  await harness.callTool('gog_docs_insert_horizontal_rule', { docId: 'd1' });
1979
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'insert-horizontal-rule', 'd1'], { account: undefined });
1980
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'insert-horizontal-rule', pos('d1')], { account: undefined });
1980
1981
  });
1981
1982
  });
1982
1983
 
@@ -1989,7 +1990,7 @@ describe('gog_docs_section_columns', () => {
1989
1990
  at: 'x', occurrence: 1, matchCase: true, tab: 'T', batch: 'b1',
1990
1991
  });
1991
1992
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
1992
- ['docs', 'section-columns', 'd1', '--count=2', '--separator=between', '--index=4', '--at-end',
1993
+ ['docs', 'section-columns', pos('d1'), '--count=2', '--separator=between', '--index=4', '--at-end',
1993
1994
  '--at=x', '--occurrence=1', '--match-case', '--tab=T', '--batch=b1'],
1994
1995
  { account: undefined },
1995
1996
  );
@@ -1999,7 +2000,7 @@ describe('gog_docs_section_columns', () => {
1999
2000
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2000
2001
  const harness = await setupHandlers();
2001
2002
  await harness.callTool('gog_docs_section_columns', { docId: 'd1', count: 1 });
2002
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'section-columns', 'd1', '--count=1'], { account: undefined });
2003
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'section-columns', pos('d1'), '--count=1'], { account: undefined });
2003
2004
  });
2004
2005
  });
2005
2006
 
@@ -2008,14 +2009,14 @@ describe('gog_docs header lifecycle', () => {
2008
2009
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2009
2010
  const harness = await setupHandlers();
2010
2011
  await harness.callTool('gog_docs_header_list', { docId: 'd1', tab: 'T' });
2011
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'header', 'list', 'd1', '--tab=T'], { account: undefined });
2012
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'header', 'list', pos('d1'), '--tab=T'], { account: undefined });
2012
2013
  });
2013
2014
 
2014
2015
  it('header_list bare', async () => {
2015
2016
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2016
2017
  const harness = await setupHandlers();
2017
2018
  await harness.callTool('gog_docs_header_list', { docId: 'd1' });
2018
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'header', 'list', 'd1'], { account: undefined });
2019
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'header', 'list', pos('d1')], { account: undefined });
2019
2020
  });
2020
2021
 
2021
2022
  it('header_create passes text and anchor flags', async () => {
@@ -2026,7 +2027,7 @@ describe('gog_docs header lifecycle', () => {
2026
2027
  at: 'x', occurrence: 1, matchCase: true, tab: 'T',
2027
2028
  });
2028
2029
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2029
- ['docs', 'header', 'create', 'd1', '--text=Title', '--file=/tmp/h.txt', '--index=1', '--at-end',
2030
+ ['docs', 'header', 'create', pos('d1'), '--text=Title', '--file=/tmp/h.txt', '--index=1', '--at-end',
2030
2031
  '--at=x', '--occurrence=1', '--match-case', '--tab=T'],
2031
2032
  { account: undefined },
2032
2033
  );
@@ -2036,21 +2037,21 @@ describe('gog_docs header lifecycle', () => {
2036
2037
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2037
2038
  const harness = await setupHandlers();
2038
2039
  await harness.callTool('gog_docs_header_create', { docId: 'd1' });
2039
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'header', 'create', 'd1'], { account: undefined });
2040
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'header', 'create', pos('d1')], { account: undefined });
2040
2041
  });
2041
2042
 
2042
2043
  it('header_delete passes id and --tab', async () => {
2043
2044
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2044
2045
  const harness = await setupHandlers();
2045
2046
  await harness.callTool('gog_docs_header_delete', { docId: 'd1', headerId: 'kix.h1', tab: 'T' });
2046
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'header', 'delete', 'd1', 'kix.h1', '--tab=T', '--force'], { account: undefined });
2047
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'header', 'delete', pos('d1'), pos('kix.h1'), '--tab=T', '--force'], { account: undefined });
2047
2048
  });
2048
2049
 
2049
2050
  it('header_delete bare', async () => {
2050
2051
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2051
2052
  const harness = await setupHandlers();
2052
2053
  await harness.callTool('gog_docs_header_delete', { docId: 'd1', headerId: 'kix.h1' });
2053
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'header', 'delete', 'd1', 'kix.h1', '--force'], { account: undefined });
2054
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'header', 'delete', pos('d1'), pos('kix.h1'), '--force'], { account: undefined });
2054
2055
  });
2055
2056
  });
2056
2057
 
@@ -2059,14 +2060,14 @@ describe('gog_docs footer lifecycle', () => {
2059
2060
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2060
2061
  const harness = await setupHandlers();
2061
2062
  await harness.callTool('gog_docs_footer_list', { docId: 'd1', tab: 'T' });
2062
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'footer', 'list', 'd1', '--tab=T'], { account: undefined });
2063
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'footer', 'list', pos('d1'), '--tab=T'], { account: undefined });
2063
2064
  });
2064
2065
 
2065
2066
  it('footer_list bare', async () => {
2066
2067
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2067
2068
  const harness = await setupHandlers();
2068
2069
  await harness.callTool('gog_docs_footer_list', { docId: 'd1' });
2069
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'footer', 'list', 'd1'], { account: undefined });
2070
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'footer', 'list', pos('d1')], { account: undefined });
2070
2071
  });
2071
2072
 
2072
2073
  it('footer_create passes text and anchor flags', async () => {
@@ -2077,7 +2078,7 @@ describe('gog_docs footer lifecycle', () => {
2077
2078
  at: 'x', occurrence: 1, matchCase: true, tab: 'T',
2078
2079
  });
2079
2080
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2080
- ['docs', 'footer', 'create', 'd1', '--text=Foot', '--file=/tmp/f.txt', '--index=1', '--at-end',
2081
+ ['docs', 'footer', 'create', pos('d1'), '--text=Foot', '--file=/tmp/f.txt', '--index=1', '--at-end',
2081
2082
  '--at=x', '--occurrence=1', '--match-case', '--tab=T'],
2082
2083
  { account: undefined },
2083
2084
  );
@@ -2087,21 +2088,21 @@ describe('gog_docs footer lifecycle', () => {
2087
2088
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2088
2089
  const harness = await setupHandlers();
2089
2090
  await harness.callTool('gog_docs_footer_create', { docId: 'd1' });
2090
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'footer', 'create', 'd1'], { account: undefined });
2091
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'footer', 'create', pos('d1')], { account: undefined });
2091
2092
  });
2092
2093
 
2093
2094
  it('footer_delete passes id and --tab', async () => {
2094
2095
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2095
2096
  const harness = await setupHandlers();
2096
2097
  await harness.callTool('gog_docs_footer_delete', { docId: 'd1', footerId: 'kix.f1', tab: 'T' });
2097
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'footer', 'delete', 'd1', 'kix.f1', '--tab=T', '--force'], { account: undefined });
2098
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'footer', 'delete', pos('d1'), pos('kix.f1'), '--tab=T', '--force'], { account: undefined });
2098
2099
  });
2099
2100
 
2100
2101
  it('footer_delete bare', async () => {
2101
2102
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2102
2103
  const harness = await setupHandlers();
2103
2104
  await harness.callTool('gog_docs_footer_delete', { docId: 'd1', footerId: 'kix.f1' });
2104
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'footer', 'delete', 'd1', 'kix.f1', '--force'], { account: undefined });
2105
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'footer', 'delete', pos('d1'), pos('kix.f1'), '--force'], { account: undefined });
2105
2106
  });
2106
2107
  });
2107
2108
 
@@ -2113,7 +2114,7 @@ describe('gog_docs_replace_image', () => {
2113
2114
  docId: 'd1', url: 'https://x.test/i.png', objectId: 'kix.img1', tab: 'T',
2114
2115
  });
2115
2116
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2116
- ['docs', 'replace-image', 'd1', '--url=https://x.test/i.png', '--object-id=kix.img1', '--tab=T'],
2117
+ ['docs', 'replace-image', pos('d1'), '--url=https://x.test/i.png', '--object-id=kix.img1', '--tab=T'],
2117
2118
  { account: undefined },
2118
2119
  );
2119
2120
  });
@@ -2125,7 +2126,7 @@ describe('gog_docs_replace_image', () => {
2125
2126
  docId: 'd1', file: '/tmp/i.png', matchAlt: 'logo', name: 'new.png', parent: 'folder1',
2126
2127
  });
2127
2128
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2128
- ['docs', 'replace-image', 'd1', '--file=/tmp/i.png', '--match-alt=logo', '--name=new.png', '--parent=folder1', '--force'],
2129
+ ['docs', 'replace-image', pos('d1'), '--file=/tmp/i.png', '--match-alt=logo', '--name=new.png', '--parent=folder1', '--force'],
2129
2130
  { account: undefined },
2130
2131
  );
2131
2132
  });
@@ -2137,7 +2138,7 @@ describe('gog_docs_table_row_pin_header', () => {
2137
2138
  const harness = await setupHandlers();
2138
2139
  await harness.callTool('gog_docs_table_row_pin_header', { docId: 'd1', rows: 2, table: '1', tab: 'T' });
2139
2140
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2140
- ['docs', 'table-row', 'pin-header', 'd1', '--rows=2', '--table=1', '--tab=T'],
2141
+ ['docs', 'table-row', 'pin-header', pos('d1'), '--rows=2', '--table=1', '--tab=T'],
2141
2142
  { account: undefined },
2142
2143
  );
2143
2144
  });
@@ -2147,7 +2148,7 @@ describe('gog_docs_table_row_pin_header', () => {
2147
2148
  const harness = await setupHandlers();
2148
2149
  await harness.callTool('gog_docs_table_row_pin_header', { docId: 'd1', rows: 0 });
2149
2150
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2150
- ['docs', 'table-row', 'pin-header', 'd1', '--rows=0'],
2151
+ ['docs', 'table-row', 'pin-header', pos('d1'), '--rows=0'],
2151
2152
  { account: undefined },
2152
2153
  );
2153
2154
  });
@@ -2161,7 +2162,7 @@ describe('gog_docs_table_row_style', () => {
2161
2162
  docId: 'd1', row: 1, minHeight: '20pt', preventOverflow: true, table: '1', tab: 'T',
2162
2163
  });
2163
2164
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2164
- ['docs', 'table-row', 'style', 'd1', '--row=1', '--min-height=20pt', '--prevent-overflow', '--table=1', '--tab=T'],
2165
+ ['docs', 'table-row', 'style', pos('d1'), '--row=1', '--min-height=20pt', '--prevent-overflow', '--table=1', '--tab=T'],
2165
2166
  { account: undefined },
2166
2167
  );
2167
2168
  });
@@ -2171,7 +2172,7 @@ describe('gog_docs_table_row_style', () => {
2171
2172
  const harness = await setupHandlers();
2172
2173
  await harness.callTool('gog_docs_table_row_style', { docId: 'd1', preventOverflow: false });
2173
2174
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2174
- ['docs', 'table-row', 'style', 'd1', '--no-prevent-overflow'],
2175
+ ['docs', 'table-row', 'style', pos('d1'), '--no-prevent-overflow'],
2175
2176
  { account: undefined },
2176
2177
  );
2177
2178
  });
@@ -2183,7 +2184,7 @@ describe('gog_docs_table_row_style overflow-unset branch', () => {
2183
2184
  const harness = await setupHandlers();
2184
2185
  await harness.callTool('gog_docs_table_row_style', { docId: 'd1', row: 2, minHeight: '30pt' });
2185
2186
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2186
- ['docs', 'table-row', 'style', 'd1', '--row=2', '--min-height=30pt'],
2187
+ ['docs', 'table-row', 'style', pos('d1'), '--row=2', '--min-height=30pt'],
2187
2188
  { account: undefined },
2188
2189
  );
2189
2190
  });
@@ -2196,7 +2197,7 @@ describe('gog_docs_suggestions_list', () => {
2196
2197
  vi.mocked(lib.runOrDiagnose).mockResolvedValue(rawTextResult('{}'));
2197
2198
  const harness = await setupHandlers();
2198
2199
  await harness.callTool('gog_docs_suggestions_list', { docId: 'd1' });
2199
- expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'suggestions', 'list', 'd1'], { account: undefined });
2200
+ expect(lib.runOrDiagnose).toHaveBeenCalledWith(['docs', 'suggestions', 'list', pos('d1')], { account: undefined });
2200
2201
  });
2201
2202
 
2202
2203
  it('includes --tab when provided', async () => {
@@ -2204,7 +2205,7 @@ describe('gog_docs_suggestions_list', () => {
2204
2205
  const harness = await setupHandlers();
2205
2206
  await harness.callTool('gog_docs_suggestions_list', { docId: 'd1', tab: 'Notes' });
2206
2207
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2207
- ['docs', 'suggestions', 'list', 'd1', '--tab=Notes'],
2208
+ ['docs', 'suggestions', 'list', pos('d1'), '--tab=Notes'],
2208
2209
  { account: undefined },
2209
2210
  );
2210
2211
  });
@@ -2214,7 +2215,7 @@ describe('gog_docs_suggestions_list', () => {
2214
2215
  const harness = await setupHandlers();
2215
2216
  await harness.callTool('gog_docs_suggestions_list', { docId: 'd1', account: 'other@gmail.com' });
2216
2217
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2217
- ['docs', 'suggestions', 'list', 'd1'],
2218
+ ['docs', 'suggestions', 'list', pos('d1')],
2218
2219
  { account: 'other@gmail.com' },
2219
2220
  );
2220
2221
  });
@@ -2230,7 +2231,7 @@ describe('gog_docs_format spacingMode', () => {
2230
2231
  docId: 'd1', spaceAbove: 6, spaceBelow: 12, spacingMode: 'COLLAPSE_LISTS',
2231
2232
  });
2232
2233
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2233
- ['docs', 'format', 'd1', '--space-above=6', '--space-below=12', '--spacing-mode=COLLAPSE_LISTS'],
2234
+ ['docs', 'format', pos('d1'), '--space-above=6', '--space-below=12', '--spacing-mode=COLLAPSE_LISTS'],
2234
2235
  { account: undefined },
2235
2236
  );
2236
2237
  });
@@ -2240,7 +2241,7 @@ describe('gog_docs_format spacingMode', () => {
2240
2241
  const harness = await setupHandlers();
2241
2242
  await harness.callTool('gog_docs_format', { docId: 'd1', spaceAbove: 6 });
2242
2243
  expect(lib.runOrDiagnose).toHaveBeenCalledWith(
2243
- ['docs', 'format', 'd1', '--space-above=6'],
2244
+ ['docs', 'format', pos('d1'), '--space-above=6'],
2244
2245
  { account: undefined },
2245
2246
  );
2246
2247
  });
@@ -2272,3 +2273,49 @@ describe('server-side file params never advertise stdin as usable', () => {
2272
2273
  expect(desc).toMatch(/hang|never writes/i);
2273
2274
  });
2274
2275
  });
2276
+
2277
+ // SEC-3/SEC-4: every model-supplied server path must resolve inside an
2278
+ // operator-configured root (GOG_FILE_ROOTS). The suite runs with '/' so the
2279
+ // arg-shape tests can use any path; these narrow it.
2280
+ async function withFileRoots<T>(roots: string, fn: () => Promise<T>): Promise<T> {
2281
+ const prev = process.env.GOG_FILE_ROOTS;
2282
+ process.env.GOG_FILE_ROOTS = roots;
2283
+ try {
2284
+ return await fn();
2285
+ } finally {
2286
+ process.env.GOG_FILE_ROOTS = prev;
2287
+ }
2288
+ }
2289
+
2290
+ describe('server paths are confined to GOG_FILE_ROOTS', () => {
2291
+ it.each([
2292
+ ['gog_docs_export', {"docId": "d1", "out": "/Users/me/.zshrc"}, 'out'],
2293
+ ['gog_docs_insert', {"docId": "d1", "file": "/etc/passwd"}, 'file'],
2294
+ ['gog_docs_append', {"docId": "d1", "file": "/etc/passwd"}, 'file'],
2295
+ ['gog_docs_sed', {"docId": "d1", "file": "/etc/passwd"}, 'file'],
2296
+ ['gog_docs_update', {"docId": "d1", "file": "/etc/passwd"}, 'file'],
2297
+ ['gog_docs_named_range_replace', {"docId": "d1", "nameOrId": "n", "file": "/etc/passwd"}, 'file'],
2298
+ ['gog_docs_cell_update', {"docId": "d1", "table": 1, "row": 1, "col": 1, "contentFile": "/etc/passwd"}, 'contentFile'],
2299
+ ['gog_docs_insert_image', {"docId": "d1", "file": "/etc/passwd"}, 'file'],
2300
+ ['gog_docs_insert_footnote', {"docId": "d1", "file": "/etc/passwd"}, 'file'],
2301
+ ['gog_docs_header_create', {"docId": "d1", "file": "/etc/passwd"}, 'file'],
2302
+ ['gog_docs_footer_create', {"docId": "d1", "file": "/etc/passwd"}, 'file'],
2303
+ ['gog_docs_replace_image', {"docId": "d1", "file": "/etc/passwd"}, 'file'],
2304
+ ] as Array<[string, Record<string, unknown>, string]>)('%s refuses %j outside the roots', async (tool, args, param) => {
2305
+ const h = await setupHandlers();
2306
+ const result = await withFileRoots('/srv/gog-files', () => h.callTool(tool, args));
2307
+ expect(result.isError).toBe(true);
2308
+ expect(result.content[0].text).toMatch(new RegExp(`${param} ".*" is outside the directories`));
2309
+ expect(lib.runOrDiagnose).not.toHaveBeenCalled();
2310
+ });
2311
+
2312
+ // Clients auto-approve readOnlyHint tools; these write (and can overwrite)
2313
+ // files on the gog host, so they must not claim to be read-only.
2314
+ it.each(["gog_docs_export"])('%s is not advertised as read-only and is marked destructive', async (name) => {
2315
+ const h = await setupHandlers();
2316
+ const { tools } = await h.client.listTools();
2317
+ const tool = tools.find((t) => t.name === name)!;
2318
+ expect(tool.annotations?.readOnlyHint).not.toBe(true);
2319
+ expect(tool.annotations?.destructiveHint).toBe(true);
2320
+ });
2321
+ });