@parall/cli 1.58.2 → 1.60.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.
@@ -0,0 +1,437 @@
1
+ /**
2
+ * Reconciling a local wiki workspace with a server that moved on:
3
+ *
4
+ * - a line-level three-way text merge, used by `wiki sync` when both the
5
+ * server and the workspace changed the same file: non-overlapping edits
6
+ * merge silently, overlapping ones are written into the working file as
7
+ * `<<<<<<< mine (parall-merge)` / `======= (parall-merge)` /
8
+ * `>>>>>>> latest (parall-merge)` blocks — git's shape, the one every
9
+ * agent already knows how to edit, plus a tag so a quoted example of the
10
+ * block in the document is never mistaken for a delimiter;
11
+ * - the propose-time backstop that refuses a file still carrying such a
12
+ * block;
13
+ * - the stale-base recovery policy `changeset create` follows before it
14
+ * hands the situation back to the agent.
15
+ *
16
+ * Everything here is pure (no filesystem, no network) so the policy is
17
+ * unit-testable without a mock wiki-service.
18
+ *
19
+ * Format twin: `ts/app/src/lib/wikiThreeWayMerge.ts` (the Web editor's draft
20
+ * merge, landing with PR #2724) is written to generate and recognise the exact
21
+ * same delimiter sets under the same rules. The two packages cannot share code
22
+ * (the CLI does not depend on the app), so each carries its own "format
23
+ * constants" test over one shared fixture; nothing here can enforce the other
24
+ * side. Keep them in lockstep: a human resolving in the browser and an agent
25
+ * resolving in a workspace must see, and be able to hand each other, the same
26
+ * bytes.
27
+ */
28
+ import { ApiError } from '@parall/sdk';
29
+ import { diff3Merge } from 'node-diff3';
30
+ /** Server error code: a file_change's base_sha no longer matches the default branch. */
31
+ export const STALE_BASE_CODE = 'STALE_BASE';
32
+ /**
33
+ * How many times one propose call may recover from a stale base on its own.
34
+ * One covers "the server moved since my last sync". A second stale hit right
35
+ * after a fresh re-sync means someone is publishing to the same files right
36
+ * now — that is a decision for the caller, not a retry loop.
37
+ */
38
+ export const MAX_STALE_RECOVERIES = 1;
39
+ /** Marker labels are agent-facing (they land in the working file). */
40
+ export const MERGE_LABEL_MINE = 'mine';
41
+ export const MERGE_LABEL_THEIRS = 'latest';
42
+ const TAG_BASE = 'parall-merge';
43
+ /**
44
+ * Delimiter set `n` (1-based). Set 1 is `<<<<<<< mine (parall-merge)` /
45
+ * `======= (parall-merge)` / `>>>>>>> latest (parall-merge)`; higher sets add
46
+ * `-n` to the tag, MIME-boundary style, and are only used when a document
47
+ * happens to contain set 1 verbatim (say, a wiki page documenting this very
48
+ * feature).
49
+ */
50
+ export function conflictDelimiters(n = 1) {
51
+ const tag = n <= 1 ? `(${TAG_BASE})` : `(${TAG_BASE}-${n})`;
52
+ return {
53
+ open: `<<<<<<< ${MERGE_LABEL_MINE} ${tag}`,
54
+ sep: `======= ${tag}`,
55
+ close: `>>>>>>> ${MERGE_LABEL_THEIRS} ${tag}`,
56
+ };
57
+ }
58
+ /**
59
+ * Highest delimiter set this CLI generates or recognises. The set number is
60
+ * parsed with `Number()`, so an unbounded digit run in content could yield
61
+ * `Infinity` (which JSON-serialises to `null` and would blank the manifest's
62
+ * `conflict_set`) or lose integer precision (so `max + 1` would not move) —
63
+ * either way the guards would stop recognising the block sync itself wrote.
64
+ * Tags with more digits than this are content, and a document that already
65
+ * quotes set {@link MAX_CONFLICT_SET} cannot get an in-file merge at all: the
66
+ * merge reports `delimiter-sets-exhausted` and sync falls back to the
67
+ * `.remote` copy, exactly like binary content.
68
+ */
69
+ export const MAX_CONFLICT_SET = 999_999;
70
+ const SET_DIGITS = String(MAX_CONFLICT_SET).length;
71
+ // Set-number extractors for the three delimiter shapes. A match means "this
72
+ // line is delimiter-shaped, of set n" — whether it is OURS is decided by the
73
+ // recorded set (`hasDelimiterLine`), never by position in the text.
74
+ const TAG_RE_SRC = `\\(${TAG_BASE}(?:-(\\d{1,${SET_DIGITS}}))?\\)$`;
75
+ const OPEN_RE = new RegExp(`^<{7} ${MERGE_LABEL_MINE} ${TAG_RE_SRC}`);
76
+ const SEP_RE = new RegExp(`^={7} ${TAG_RE_SRC}`);
77
+ const CLOSE_RE = new RegExp(`^>{7} ${MERGE_LABEL_THEIRS} ${TAG_RE_SRC}`);
78
+ /** A line without its `\n` / `\r\n` terminator — delimiters are compared this way. */
79
+ function stripEol(line) {
80
+ if (line.endsWith('\r\n'))
81
+ return line.slice(0, -2);
82
+ if (line.endsWith('\n'))
83
+ return line.slice(0, -1);
84
+ if (line.endsWith('\r'))
85
+ return line.slice(0, -1);
86
+ return line;
87
+ }
88
+ function setNumber(line, re) {
89
+ const m = re.exec(line);
90
+ if (!m)
91
+ return 0;
92
+ return m[1] ? Number(m[1]) : 1;
93
+ }
94
+ /**
95
+ * Delimiter set for a document: one past the highest set any content line
96
+ * belongs to (any of the three shapes). Content can therefore only ever carry
97
+ * LOWER sets than the delimiters around it. Sync records the chosen set on the
98
+ * manifest entry (`conflict_set`) and every guard asks for exactly that set
99
+ * (`hasDelimiterLine`), so quoted marker text anywhere in the document stays
100
+ * content.
101
+ */
102
+ export function pickSet(content) {
103
+ let max = 0;
104
+ for (const raw of content) {
105
+ const line = stripEol(raw);
106
+ max = Math.max(max, setNumber(line, OPEN_RE), setNumber(line, SEP_RE), setNumber(line, CLOSE_RE));
107
+ }
108
+ return max + 1;
109
+ }
110
+ export function pickDelimiters(content) {
111
+ return conflictDelimiters(pickSet(content));
112
+ }
113
+ const LFS_POINTER_PREFIX = 'version https://git-lfs.github.com/spec/';
114
+ /**
115
+ * Upper bound on the line-match pairs one diff may process. node-diff3's LCS
116
+ * walks every (line in A, identical line in B) pair, so a file with many
117
+ * repeated lines (blank lines, table separators) costs occurrences² — about
118
+ * 1 s per million pairs on a laptop, 7–8 s at four million. Above the budget
119
+ * the merge is skipped in favour of the conflict marker: slow but correct is
120
+ * still a hang from the agent's point of view.
121
+ */
122
+ export const MERGE_MATCH_PAIR_BUDGET = 1_000_000;
123
+ /**
124
+ * Upper bound on lines per side. Independently of repeated lines, node-diff3
125
+ * scans a growing candidate array once per matched line, so even all-unique
126
+ * files cost roughly lines²: ≈90 ms at 10,000 lines and ≈200 ms at 15,000
127
+ * on a laptop (both sides editing distant regions), ≈4.7 s at 50,000 in
128
+ * review. 15,000 lines is far above any wiki document that is still a
129
+ * document; beyond it the merge is skipped for the conflict marker.
130
+ */
131
+ export const MERGE_MAX_LINES = 15_000;
132
+ /**
133
+ * Number of (i, j) pairs with a[i] === b[j] — the work an LCS over the two
134
+ * line arrays performs — computed in O(|a| + |b|) from line multiplicities.
135
+ */
136
+ export function countMatchPairs(a, b) {
137
+ const counts = new Map();
138
+ for (const line of a)
139
+ counts.set(line, (counts.get(line) ?? 0) + 1);
140
+ let pairs = 0;
141
+ for (const line of b) {
142
+ pairs += counts.get(line) ?? 0;
143
+ }
144
+ return pairs;
145
+ }
146
+ /**
147
+ * Merge `local` and `remote`, both derived from `base`, at line granularity.
148
+ * Clean when every changed region was touched by one side only, or both
149
+ * sides made the identical change; overlapping hunks are never auto-resolved.
150
+ * diff3 semantics: two changed regions overlap when no unchanged line
151
+ * separates them, so adjacent edits conflict even if they touch different
152
+ * lines — that is deliberate (git behaves the same) and the skill text says
153
+ * so.
154
+ * Binary content and Git LFS pointers are refused — a line merge of either
155
+ * would corrupt the file — so the caller keeps its conflict-marker path.
156
+ */
157
+ export function mergeTextThreeWay(input) {
158
+ for (const buf of [input.base, input.local, input.remote]) {
159
+ if (!input.isText(buf))
160
+ return { kind: 'not-mergeable', reason: 'binary' };
161
+ if (buf.toString('utf8', 0, LFS_POINTER_PREFIX.length) === LFS_POINTER_PREFIX) {
162
+ return { kind: 'not-mergeable', reason: 'lfs-pointer' };
163
+ }
164
+ }
165
+ const localLines = splitLines(input.local.toString('utf8'));
166
+ const baseLines = splitLines(input.base.toString('utf8'));
167
+ const remoteLines = splitLines(input.remote.toString('utf8'));
168
+ // Two independent cost drivers, both bounded before diff3 runs: sheer
169
+ // length (candidate-array scans grow with the LCS) and repeated lines
170
+ // (identical-line pairs). diff3 runs two LCS passes (base↔local,
171
+ // base↔remote); budget each.
172
+ if (Math.max(baseLines.length, localLines.length, remoteLines.length) > MERGE_MAX_LINES) {
173
+ return { kind: 'not-mergeable', reason: 'too-complex' };
174
+ }
175
+ if (countMatchPairs(baseLines, localLines) > MERGE_MATCH_PAIR_BUDGET ||
176
+ countMatchPairs(baseLines, remoteLines) > MERGE_MATCH_PAIR_BUDGET) {
177
+ return { kind: 'not-mergeable', reason: 'too-complex' };
178
+ }
179
+ const regions = diff3Merge(localLines, baseLines, remoteLines, { excludeFalseConflicts: true });
180
+ // Marker text is built here, from the structured regions (never from
181
+ // node-diff3's bare-label `merge()` output), with a delimiter set chosen
182
+ // against every line that can appear in the output — so the delimiters are
183
+ // unambiguous by construction: a quoted set-1 block in the document simply
184
+ // pushes this merge to set 2. Same rule as the Web editor's module.
185
+ const set = pickSet([...localLines, ...remoteLines]);
186
+ // A clean merge writes no delimiters, so the cap only matters once there is
187
+ // a block to write: non-overlapping edits around a quoted top-set marker
188
+ // still merge on their own.
189
+ if (set > MAX_CONFLICT_SET && regions.some((region) => region.conflict)) {
190
+ return { kind: 'not-mergeable', reason: 'delimiter-sets-exhausted' };
191
+ }
192
+ const d = conflictDelimiters(set);
193
+ // Marker lines take the document's own line ending so a CRLF file stays
194
+ // CRLF (a mixed-EOL file gets CRLF markers if it contains any CRLF — one
195
+ // style per block, chosen from the local side); a side whose last line has
196
+ // no terminator gets one inside the block (the block is what the agent
197
+ // edits anyway) so the closing marker never glues onto content.
198
+ const eol = /\r\n/.test(input.local.toString('utf8')) ? '\r\n' : '\n';
199
+ const terminated = (lines) => lines.length > 0 && !lines[lines.length - 1].endsWith('\n')
200
+ ? [...lines.slice(0, -1), `${lines[lines.length - 1]}${eol}`]
201
+ : lines;
202
+ const out = [];
203
+ let conflictRegions = 0;
204
+ for (const region of regions) {
205
+ if (region.ok) {
206
+ out.push(...region.ok);
207
+ }
208
+ else if (region.conflict) {
209
+ conflictRegions++;
210
+ out.push(`${d.open}${eol}`);
211
+ out.push(...terminated(region.conflict.a));
212
+ out.push(`${d.sep}${eol}`);
213
+ out.push(...terminated(region.conflict.b));
214
+ out.push(`${d.close}${eol}`);
215
+ }
216
+ }
217
+ const merged = Buffer.from(out.join(''), 'utf8');
218
+ if (conflictRegions > 0) {
219
+ return { kind: 'conflict', conflictRegions, set, delimiters: d, marked: merged };
220
+ }
221
+ return { kind: 'clean', merged };
222
+ }
223
+ /**
224
+ * True when `text` carries ANY delimiter line of set `set` — its opener,
225
+ * separator or closer, byte-exact (terminator stripped), complete block or
226
+ * not.
227
+ *
228
+ * This is THE predicate behind every decision about a conflicted path: the
229
+ * propose-time refusal (early scan and the encode-time re-check), sync's
230
+ * "markers still unresolved → don't merge again" guard, and dropping the
231
+ * recorded set once the agent has edited the block away. Callers pass the set
232
+ * sync recorded on the manifest entry (`conflict_set`) when it wrote the
233
+ * block, so:
234
+ *
235
+ * - a half-finished hand merge that deleted only the closer still blocks
236
+ * propose — a lone `<<<<<<< mine (parall-merge)` must never land in the
237
+ * wiki (same rule as the Web editor's publish guard, its round 5);
238
+ * - every OTHER set is content: a page that quotes a complete set-1 block
239
+ * verbatim conflicts with set 2 and, once resolved, proposes — only the
240
+ * recorded set is live. The Web draft's `merge_conflict` flag plays the
241
+ * role the manifest's `conflict_set` plays here;
242
+ * - a Setext `=======`, a git-style `<<<<<<< HEAD … >>>>>>> latest` example
243
+ * and the bare `<<<<<<< mine` this CLI used to emit never match: they carry
244
+ * no `(parall-merge…)` tag.
245
+ *
246
+ * Paths without a recorded set are not scanned at all.
247
+ */
248
+ export function hasDelimiterLine(text, set) {
249
+ const d = conflictDelimiters(set);
250
+ for (const raw of text.split('\n')) {
251
+ const line = stripEol(raw);
252
+ if (line === d.open || line === d.sep || line === d.close)
253
+ return true;
254
+ }
255
+ return false;
256
+ }
257
+ /**
258
+ * Split into lines that keep their own terminator (`\n` or `\r\n`), so a
259
+ * merge round-trips byte-exactly: joining the pieces back reproduces the
260
+ * input, including a missing trailing newline on the last line.
261
+ */
262
+ function splitLines(text) {
263
+ if (text === '')
264
+ return [];
265
+ const parts = text.split('\n');
266
+ const last = parts.pop();
267
+ const lines = parts.map((line) => `${line}\n`);
268
+ if (last !== '')
269
+ lines.push(last);
270
+ return lines;
271
+ }
272
+ /**
273
+ * Compare each locally changed path's sync baseline against the server's
274
+ * current blob SHA. A locally created file is stale when the server now has
275
+ * one at that path; an update/delete is stale when the server's copy changed
276
+ * or vanished.
277
+ */
278
+ export function findStalePaths(input) {
279
+ const stale = [];
280
+ for (const filePath of input.changedPaths) {
281
+ const base = input.baseSha(filePath);
282
+ const server = input.serverSha(filePath);
283
+ if (base === undefined) {
284
+ if (server !== undefined)
285
+ stale.push({ path: filePath, reason: 'created' });
286
+ }
287
+ else if (server === undefined) {
288
+ stale.push({ path: filePath, reason: 'deleted' });
289
+ }
290
+ else if (server !== base) {
291
+ stale.push({ path: filePath, reason: 'modified' });
292
+ }
293
+ }
294
+ return stale;
295
+ }
296
+ export function describeStalePath(stale) {
297
+ return `${stale.path} (${stale.reason} on the server since your last sync)`;
298
+ }
299
+ /**
300
+ * After a stale-base hit and a re-sync, decide whether propose may run again.
301
+ * Failures and conflicts always win over the retry budget: an exhausted
302
+ * budget with a clean sync means "the server keeps moving", but leftover
303
+ * conflicts are the more useful thing to tell the agent about.
304
+ */
305
+ export function decideStaleRecovery(input) {
306
+ if (input.outcome.failed.length > 0)
307
+ return { kind: 'stop', reason: 'failures' };
308
+ if (input.outcome.conflicts.length > 0)
309
+ return { kind: 'stop', reason: 'conflicts' };
310
+ if (input.attempt >= MAX_STALE_RECOVERIES)
311
+ return { kind: 'stop', reason: 'retries-exhausted' };
312
+ return { kind: 'retry' };
313
+ }
314
+ export function isStaleBaseError(err) {
315
+ return err instanceof ApiError && err.code === STALE_BASE_CODE;
316
+ }
317
+ /** Set-1 delimiters, used only to SHOW the block shape in agent-facing text. */
318
+ const DISPLAY = conflictDelimiters(1);
319
+ /**
320
+ * Agent-facing text for a recovery that stopped on conflicts.
321
+ *
322
+ * There is no resolution recipe any more. `sync` has already moved each
323
+ * conflicted path's baseline to the server's version and left the working tree
324
+ * saying what the agent meant (marker blocks to edit, a kept file, a kept
325
+ * delete), so the only step left is "make the file say what you want, then
326
+ * propose". Every artifact the agent might need is named with its absolute
327
+ * path.
328
+ */
329
+ export function formatStaleRecoveryError(input) {
330
+ const moved = input.stale.length > 0
331
+ ? `${input.stale.length} file(s) changed on the server since your last sync:\n` +
332
+ input.stale.map((s) => ` ${describeStalePath(s)}`).join('\n')
333
+ : 'the server rejected the proposal as based on a stale sync';
334
+ switch (input.decision.reason) {
335
+ case 'conflicts': {
336
+ const lines = input.outcome.conflicts
337
+ .map((c) => ` ${c.path} — ${describeConflict(c)}`)
338
+ .join('\n');
339
+ // The same recovery can have merged other paths cleanly, rewriting those
340
+ // working copies — say so, or the caller re-reads a file it believes it
341
+ // still owns.
342
+ const mergedNote = input.outcome.merged.length > 0
343
+ ? `Other path(s) merged cleanly and their working copies were rewritten (no action needed): ${input.outcome.merged.join(', ')}.\n`
344
+ : '';
345
+ return (`cannot propose: ${moved}\n` +
346
+ `Re-synced; ${input.outcome.conflicts.length} file(s) need your decision. ` +
347
+ "Your baseline already moved to the server's version, so once each file says what you want, " +
348
+ 'propose again — no further sync needed:\n' +
349
+ `${lines}\n` +
350
+ mergedNote +
351
+ `A file that still contains a \`${DISPLAY.open}\` … \`${DISPLAY.close}\` block ` +
352
+ '(the tag may read `parall-merge-2`, `-3`, … when the page itself quotes the markers) is refused at propose; ' +
353
+ 'delete the three marker lines along with the side you do not want.');
354
+ }
355
+ case 'failures': {
356
+ const lines = input.outcome.failed
357
+ .map((f) => ` ${f.path} — ${f.reason}${f.detail ? `: ${f.detail}` : ''}`)
358
+ .join('\n');
359
+ return (`cannot propose: ${moved}\n` +
360
+ `Re-syncing failed for ${input.outcome.failed.length} path(s):\n${lines}\n` +
361
+ 'Run `parall wiki sync` again (transient failures retry), then propose again.');
362
+ }
363
+ case 'retries-exhausted':
364
+ return (`cannot propose: ${moved}\n` +
365
+ 'Re-synced once already, and the server moved again before the re-proposal landed — ' +
366
+ 'someone else is publishing to the same files right now. Wait a moment, run `parall wiki sync`, then propose again.');
367
+ }
368
+ }
369
+ /**
370
+ * Text for the propose-time backstop: files that still carry a marker block.
371
+ * Fail-closed and local — nothing was sent to the server.
372
+ */
373
+ export function formatUnresolvedMarkersError(paths) {
374
+ return (`cannot propose: ${paths.length} file(s) still contain unresolved conflict markers ` +
375
+ `(\`${DISPLAY.open}\` … \`${DISPLAY.close}\`, tag possibly \`parall-merge-n\`): ${paths.join(', ')}\n` +
376
+ 'Edit each file so it says what you want — keep one side or combine them — delete the three ' +
377
+ 'marker lines, then propose again. Your pre-merge copy is under .parall-wiki/conflicts/<path>.mine. ' +
378
+ 'Nothing was sent to the server.');
379
+ }
380
+ /** One line per conflict: what happened, what the working tree now holds, where the artifacts are. */
381
+ export function describeConflict(conflict) {
382
+ switch (conflict.resolution) {
383
+ case 'in-file-markers': {
384
+ const n = conflict.conflictRegions ?? 0;
385
+ return (`${describeReason(conflict.reason)}; ${n} overlapping block(s) are marked in the file ` +
386
+ `(\`${DISPLAY.open}\` … \`${DISPLAY.close}\`) with the non-overlapping changes already merged around them` +
387
+ (conflict.mineCopyPath ? `; your pre-merge copy: ${conflict.mineCopyPath}` : ''));
388
+ }
389
+ case 'upstream-copy':
390
+ return (`${describeReason(conflict.reason)}; not merged in place (${describeNotMergeable(conflict.notMergeableReason)}) ` +
391
+ `— your file is untouched; the server's version is at ${conflict.remoteCopyPath ?? '<missing>'}. ` +
392
+ 'Edit your file to include what you want from it, then propose.');
393
+ case 'local-delete-kept':
394
+ return (`${describeReason(conflict.reason)}; your delete stands and will be proposed as-is. ` +
395
+ `The server's newer version is at ${conflict.remoteCopyPath ?? '<missing>'} — copy it back to the workspace path instead if you want to keep the file.`);
396
+ case 'local-file-kept':
397
+ if (conflict.notMergeableReason === 'unresolved-markers') {
398
+ return (`${describeReason(conflict.reason)}; your file is kept, but it still has unresolved conflict markers from an earlier sync — ` +
399
+ 'edit those away first, then propose: it re-syncs this path and reports the file as kept; ' +
400
+ 'propose once more to recreate it, or delete the file to accept the removal.');
401
+ }
402
+ return (`${describeReason(conflict.reason)}; your file is kept and will be proposed as a new file. ` +
403
+ 'Delete it to accept the removal instead.');
404
+ }
405
+ }
406
+ function describeReason(reason) {
407
+ switch (reason) {
408
+ case 'remote-changed-local-edited':
409
+ return 'both you and the server changed it and the changes overlap';
410
+ case 'remote-deleted-local-edited':
411
+ return 'the server deleted it and you still have edits';
412
+ case 'remote-added-local-collides':
413
+ return 'the server created this path with different content';
414
+ case 'remote-changed-local-deleted':
415
+ return 'the server changed it and you deleted it';
416
+ }
417
+ }
418
+ function describeNotMergeable(reason) {
419
+ switch (reason) {
420
+ case 'binary':
421
+ return 'binary content';
422
+ case 'lfs-pointer':
423
+ return 'Git LFS pointer';
424
+ case 'too-complex':
425
+ return 'file too long or too repetitive to merge within the time budget';
426
+ case 'delimiter-sets-exhausted':
427
+ return `the file already quotes the highest conflict-marker set this CLI can tag (parall-merge-${MAX_CONFLICT_SET}), so the conflict could not be written into it`;
428
+ case 'unresolved-markers':
429
+ return 'your file still has unresolved conflict markers from an earlier sync — resolve those first';
430
+ case 'no-baseline':
431
+ return 'no local copy of the previous baseline';
432
+ case 'moved-since-snapshot':
433
+ return 'the file changed while sync was running';
434
+ default:
435
+ return 'not mergeable';
436
+ }
437
+ }
@@ -0,0 +1,43 @@
1
+ import { type WikiChangeset, type WikiDiffFile } from '@parall/sdk';
2
+ import { type StaleRecoveryReport } from './wiki-merge.js';
3
+ import { type ParallContext, type WikiSyncOutcome } from './wiki-shared.js';
4
+ export type WikiProposeOptions = {
5
+ changesetId?: string;
6
+ title: string;
7
+ message?: string;
8
+ sourceChatId?: string;
9
+ sourceMessageId?: string;
10
+ sourceRunId?: string;
11
+ };
12
+ export type WikiProposeResult = {
13
+ wiki_id: string;
14
+ wiki_slug: string;
15
+ wiki_name: string;
16
+ mount_path: string;
17
+ changed_paths: string[];
18
+ diff_files: WikiDiffFile[];
19
+ changeset: WikiChangeset;
20
+ status: WikiChangeset['status'];
21
+ auto_merged: boolean;
22
+ requires_review: boolean;
23
+ next_action: string;
24
+ post_merge_sync: WikiSyncOutcome | null;
25
+ post_merge_sync_error: string | null;
26
+ /** Set when the server had moved since the last sync and propose re-synced and retried on its own. */
27
+ stale_recovery: StaleRecoveryReport | null;
28
+ source: 'local_mount';
29
+ };
30
+ export declare function proposeWikiChangeset(ctx: ParallContext, wikiRef: string | undefined, options: WikiProposeOptions): Promise<WikiProposeResult>;
31
+ /**
32
+ * Discard all local changes and restore files to the last synced state.
33
+ * Restores from the local baseline object store (network only as a
34
+ * SHA-verified fallback for pre-objects mounts), so the workspace lands
35
+ * exactly on the manifest baseline — `wiki status` reports clean afterwards.
36
+ */
37
+ export declare function resetWikiWorkspace(ctx: ParallContext, wikiRef?: string): Promise<{
38
+ wiki_id: string;
39
+ wiki_slug: string;
40
+ files_restored: number;
41
+ unrestorable_paths: string[];
42
+ }>;
43
+ //# sourceMappingURL=wiki-propose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wiki-propose.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-propose.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAA4B,MAAM,aAAa,CAAC;AAC9F,OAAO,EAEL,KAAK,mBAAmB,EAOzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,aAAa,EAIlB,KAAK,eAAe,EAUrB,MAAM,kBAAkB,CAAC;AAW1B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,sGAAsG;IACtG,cAAc,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC3C,MAAM,EAAE,aAAa,CAAC;CACvB,CAAC;AAMF,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CA0B5B;AAoTD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,aAAa,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B,CAAC,CAiDD"}