@parall/cli 1.59.0 → 1.61.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.
Files changed (53) hide show
  1. package/dist/commands/agents.d.ts +9 -0
  2. package/dist/commands/agents.d.ts.map +1 -1
  3. package/dist/commands/agents.js +288 -8
  4. package/dist/commands/approvals.d.ts.map +1 -1
  5. package/dist/commands/approvals.js +19 -0
  6. package/dist/commands/chats.d.ts.map +1 -1
  7. package/dist/commands/chats.js +84 -0
  8. package/dist/commands/comments.d.ts +3 -0
  9. package/dist/commands/comments.d.ts.map +1 -1
  10. package/dist/commands/comments.js +44 -1
  11. package/dist/commands/labels.d.ts +5 -0
  12. package/dist/commands/labels.d.ts.map +1 -0
  13. package/dist/commands/labels.js +114 -0
  14. package/dist/commands/messages.d.ts.map +1 -1
  15. package/dist/commands/messages.js +35 -0
  16. package/dist/commands/projects.d.ts.map +1 -1
  17. package/dist/commands/projects.js +4 -2
  18. package/dist/commands/search.d.ts +5 -0
  19. package/dist/commands/search.d.ts.map +1 -1
  20. package/dist/commands/search.js +28 -1
  21. package/dist/commands/tasks.d.ts +13 -3
  22. package/dist/commands/tasks.d.ts.map +1 -1
  23. package/dist/commands/tasks.js +214 -8
  24. package/dist/commands/watch.d.ts.map +1 -1
  25. package/dist/commands/watch.js +7 -5
  26. package/dist/commands/wiki-comments.d.ts +6 -0
  27. package/dist/commands/wiki-comments.d.ts.map +1 -0
  28. package/dist/commands/wiki-comments.js +108 -0
  29. package/dist/commands/wiki.d.ts.map +1 -1
  30. package/dist/commands/wiki.js +2 -98
  31. package/dist/index.js +2 -0
  32. package/dist/lib/wiki-index.d.ts +67 -0
  33. package/dist/lib/wiki-index.d.ts.map +1 -0
  34. package/dist/lib/wiki-index.js +758 -0
  35. package/dist/lib/wiki-merge.d.ts +113 -6
  36. package/dist/lib/wiki-merge.d.ts.map +1 -1
  37. package/dist/lib/wiki-merge.js +236 -31
  38. package/dist/lib/wiki-propose.d.ts +43 -0
  39. package/dist/lib/wiki-propose.d.ts.map +1 -0
  40. package/dist/lib/wiki-propose.js +335 -0
  41. package/dist/lib/wiki-shared.d.ts +291 -0
  42. package/dist/lib/wiki-shared.d.ts.map +1 -0
  43. package/dist/lib/wiki-shared.js +407 -0
  44. package/dist/lib/wiki-sync.d.ts +109 -0
  45. package/dist/lib/wiki-sync.d.ts.map +1 -0
  46. package/dist/lib/wiki-sync.js +637 -0
  47. package/dist/lib/wiki-workspace.d.ts +58 -0
  48. package/dist/lib/wiki-workspace.d.ts.map +1 -0
  49. package/dist/lib/wiki-workspace.js +255 -0
  50. package/dist/lib/wiki.d.ts +6 -312
  51. package/dist/lib/wiki.d.ts.map +1 -1
  52. package/dist/lib/wiki.js +53 -2208
  53. package/package.json +4 -4
@@ -0,0 +1,58 @@
1
+ import { type WikiDiffFile } from '@parall/sdk';
2
+ import { type LocalManifest, type LocalManifestFileEntry, type LocalWikiMount } from './wiki-shared.js';
3
+ type LocalBlobProbe = {
4
+ kind: 'file';
5
+ sha: string;
6
+ } | {
7
+ kind: 'absent';
8
+ sha: null;
9
+ } | {
10
+ kind: 'shape-conflict';
11
+ detail: string;
12
+ };
13
+ /**
14
+ * Read a working-tree file as a git blob, returning a structured shape so
15
+ * callers can distinguish "absent" from "shape mismatch" (directory where a
16
+ * file is expected, or a parent path is a file blocking nested reads).
17
+ */
18
+ export declare function probeLocalGitBlob(mountRoot: string, relPath: string): Promise<LocalBlobProbe>;
19
+ export declare function readLocalManifest(mountRoot: string): Promise<LocalManifest>;
20
+ export declare function writeLocalManifest(mountRoot: string, manifest: LocalManifest): Promise<void>;
21
+ export declare function readBaselineObject(mountRoot: string, sha: string): Promise<Buffer | null>;
22
+ /**
23
+ * Make sure every manifest entry has its baseline object on disk.
24
+ * Content sources, in order: bytes downloaded during this sync
25
+ * (`contentBySha`), then the local working-tree file when its blob SHA still
26
+ * matches the manifest (clean file — typical for pre-objects mounts being
27
+ * upgraded). Files that are locally dirty AND missing an object stay absent;
28
+ * diff falls back per-file (see loadBaselineContent).
29
+ */
30
+ export declare function ensureBaselineObjects(mountRoot: string, files: Record<string, LocalManifestFileEntry>, contentBySha?: Map<string, Buffer>): Promise<void>;
31
+ /** Drop baseline objects no longer referenced by any manifest entry. */
32
+ export declare function gcBaselineObjects(mountRoot: string, files: Record<string, LocalManifestFileEntry>): Promise<void>;
33
+ /**
34
+ * Load the baseline (last-synced) content for a manifest entry. Objects store
35
+ * first; when absent (mount predates the objects store and the file is
36
+ * locally dirty), fall back to downloading the server's current content and
37
+ * accept it ONLY if its blob SHA matches the manifest base — otherwise the
38
+ * server has moved and no true baseline is available (returns null).
39
+ */
40
+ export declare function loadBaselineContent(mount: LocalWikiMount, relPath: string, expectedSha: string): Promise<Buffer | null>;
41
+ /** Compute list of changed files by comparing local disk to local manifest. */
42
+ export declare function computeLocalChanges(mount: LocalWikiMount): Promise<WikiDiffFile[]>;
43
+ export type LocalDiffResult = {
44
+ changedPaths: string[];
45
+ diffFiles: WikiDiffFile[];
46
+ patch: string;
47
+ /** Manifest base blob SHA per changed path (absent for newly created files). */
48
+ baseShaByPath: Map<string, string>;
49
+ };
50
+ /**
51
+ * Compute the local workspace diff against the last-synced baseline. Base
52
+ * content comes from the local objects store (with a SHA-verified network
53
+ * fallback for pre-objects mounts), so the diff base is always the true sync
54
+ * point — never the server's current content.
55
+ */
56
+ export declare function computeLocalDiff(mount: LocalWikiMount, manifest: LocalManifest): Promise<LocalDiffResult>;
57
+ export {};
58
+ //# sourceMappingURL=wiki-workspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wiki-workspace.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-workspace.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EAOpB,MAAM,kBAAkB,CAAC;AAe1B,KAAK,cAAc,GACf;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/C;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,cAAc,CAAC,CAkBzB;AAMD,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAQjF;AAED,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAQf;AAeD,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAM/F;AAQD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,EAC7C,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wEAAwE;AACxE,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAC5C,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAuBxB;AAMD,+EAA+E;AAC/E,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAIxF;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,eAAe,CAAC,CAwD1B"}
@@ -0,0 +1,255 @@
1
+ // Local wiki workspace state: manifest I/O, the baseline object store and
2
+ // manifest-based local change detection. Entry point for consumers is ./wiki.ts.
3
+ import { promises as fs } from 'node:fs';
4
+ import path from 'node:path';
5
+ import { structuredPatch } from 'diff';
6
+ import { LOCAL_MANIFEST_FILE, PRLL_WIKI_DIR, bulkDownloadFiles, computeGitBlobSHA, pathExists, resolvePathInsideRoot, walkLocalFiles, } from './wiki-shared.js';
7
+ const OBJECTS_DIR = 'objects';
8
+ /** Compute the git blob SHA of a working-tree file, or null if absent. */
9
+ async function readLocalGitBlobSha(mountRoot, relPath) {
10
+ const probe = await probeLocalGitBlob(mountRoot, relPath);
11
+ if (probe.kind === 'shape-conflict') {
12
+ // Surface as throw at this entry point — the caller (computeLocalChanges /
13
+ // computeLocalDiff) doesn't currently model shape conflicts. syncSingleWiki
14
+ // uses probeLocalGitBlob directly so it can route the failure structurally.
15
+ throw new Error(`shape conflict at ${relPath}: ${probe.detail}`);
16
+ }
17
+ return probe.sha;
18
+ }
19
+ /**
20
+ * Read a working-tree file as a git blob, returning a structured shape so
21
+ * callers can distinguish "absent" from "shape mismatch" (directory where a
22
+ * file is expected, or a parent path is a file blocking nested reads).
23
+ */
24
+ export async function probeLocalGitBlob(mountRoot, relPath) {
25
+ let fullPath;
26
+ try {
27
+ fullPath = resolvePathInsideRoot(mountRoot, relPath);
28
+ }
29
+ catch {
30
+ return { kind: 'absent', sha: null };
31
+ }
32
+ try {
33
+ const buf = await fs.readFile(fullPath);
34
+ return { kind: 'file', sha: computeGitBlobSHA(buf) };
35
+ }
36
+ catch (err) {
37
+ const code = err.code;
38
+ if (code === 'ENOENT')
39
+ return { kind: 'absent', sha: null };
40
+ if (code === 'EISDIR' || code === 'ENOTDIR') {
41
+ return { kind: 'shape-conflict', detail: code };
42
+ }
43
+ throw err;
44
+ }
45
+ }
46
+ // ---------------------------------------------------------------------------
47
+ // Local manifest I/O
48
+ // ---------------------------------------------------------------------------
49
+ export async function readLocalManifest(mountRoot) {
50
+ const manifestPath = path.join(mountRoot, PRLL_WIKI_DIR, LOCAL_MANIFEST_FILE);
51
+ try {
52
+ const raw = await fs.readFile(manifestPath, 'utf8');
53
+ return JSON.parse(raw);
54
+ }
55
+ catch {
56
+ return { wiki_id: '', synced_at: '', files: {} };
57
+ }
58
+ }
59
+ export async function writeLocalManifest(mountRoot, manifest) {
60
+ const metaDir = path.join(mountRoot, PRLL_WIKI_DIR);
61
+ await fs.mkdir(metaDir, { recursive: true });
62
+ await fs.writeFile(path.join(metaDir, LOCAL_MANIFEST_FILE), JSON.stringify(manifest, null, 2), 'utf8');
63
+ }
64
+ // ---------------------------------------------------------------------------
65
+ // Baseline object store (.parall-wiki/objects/<sha>)
66
+ //
67
+ // Content-addressed copies of the last-synced version of every manifest file.
68
+ // diff/status/reset read the true sync baseline from here instead of fetching
69
+ // the server's CURRENT content (which is the wrong base whenever the server
70
+ // has moved past the local sync point).
71
+ // ---------------------------------------------------------------------------
72
+ function baselineObjectPath(mountRoot, sha) {
73
+ return path.join(mountRoot, PRLL_WIKI_DIR, OBJECTS_DIR, sha);
74
+ }
75
+ export async function readBaselineObject(mountRoot, sha) {
76
+ try {
77
+ return await fs.readFile(baselineObjectPath(mountRoot, sha));
78
+ }
79
+ catch {
80
+ return null;
81
+ }
82
+ }
83
+ async function writeBaselineObject(mountRoot, sha, content) {
84
+ const target = baselineObjectPath(mountRoot, sha);
85
+ await fs.mkdir(path.dirname(target), { recursive: true });
86
+ await fs.writeFile(target, content);
87
+ }
88
+ /**
89
+ * Make sure every manifest entry has its baseline object on disk.
90
+ * Content sources, in order: bytes downloaded during this sync
91
+ * (`contentBySha`), then the local working-tree file when its blob SHA still
92
+ * matches the manifest (clean file — typical for pre-objects mounts being
93
+ * upgraded). Files that are locally dirty AND missing an object stay absent;
94
+ * diff falls back per-file (see loadBaselineContent).
95
+ */
96
+ export async function ensureBaselineObjects(mountRoot, files, contentBySha) {
97
+ for (const [relPath, entry] of Object.entries(files)) {
98
+ if (await pathExists(baselineObjectPath(mountRoot, entry.sha))) {
99
+ continue;
100
+ }
101
+ const downloaded = contentBySha?.get(entry.sha);
102
+ if (downloaded) {
103
+ await writeBaselineObject(mountRoot, entry.sha, downloaded);
104
+ continue;
105
+ }
106
+ const probe = await probeLocalGitBlob(mountRoot, relPath);
107
+ if (probe.kind === 'file' && probe.sha === entry.sha) {
108
+ const fullPath = resolvePathInsideRoot(mountRoot, relPath);
109
+ await writeBaselineObject(mountRoot, entry.sha, await fs.readFile(fullPath));
110
+ }
111
+ }
112
+ }
113
+ /** Drop baseline objects no longer referenced by any manifest entry. */
114
+ export async function gcBaselineObjects(mountRoot, files) {
115
+ const objectsDir = path.join(mountRoot, PRLL_WIKI_DIR, OBJECTS_DIR);
116
+ let names;
117
+ try {
118
+ names = await fs.readdir(objectsDir);
119
+ }
120
+ catch {
121
+ return;
122
+ }
123
+ const live = new Set(Object.values(files).map((e) => e.sha));
124
+ for (const name of names) {
125
+ if (!live.has(name)) {
126
+ await fs.rm(path.join(objectsDir, name), { force: true });
127
+ }
128
+ }
129
+ }
130
+ /**
131
+ * Load the baseline (last-synced) content for a manifest entry. Objects store
132
+ * first; when absent (mount predates the objects store and the file is
133
+ * locally dirty), fall back to downloading the server's current content and
134
+ * accept it ONLY if its blob SHA matches the manifest base — otherwise the
135
+ * server has moved and no true baseline is available (returns null).
136
+ */
137
+ export async function loadBaselineContent(mount, relPath, expectedSha) {
138
+ const cached = await readBaselineObject(mount.root, expectedSha);
139
+ if (cached) {
140
+ return cached;
141
+ }
142
+ if (!mount.token) {
143
+ return null;
144
+ }
145
+ try {
146
+ const entries = await bulkDownloadFiles(mount.bulkDownloadUrl, mount.token, [relPath]);
147
+ const entry = entries[0];
148
+ if (!entry || entry.error) {
149
+ return null;
150
+ }
151
+ const content = Buffer.from(entry.content_base64, 'base64');
152
+ if (computeGitBlobSHA(content) !== expectedSha) {
153
+ return null;
154
+ }
155
+ await writeBaselineObject(mount.root, expectedSha, content);
156
+ return content;
157
+ }
158
+ catch {
159
+ return null;
160
+ }
161
+ }
162
+ // ---------------------------------------------------------------------------
163
+ // Local change detection (manifest-based)
164
+ // ---------------------------------------------------------------------------
165
+ /** Compute list of changed files by comparing local disk to local manifest. */
166
+ export async function computeLocalChanges(mount) {
167
+ const manifest = await readLocalManifest(mount.root);
168
+ const diff = await computeLocalDiff(mount, manifest);
169
+ return diff.diffFiles;
170
+ }
171
+ /**
172
+ * Compute the local workspace diff against the last-synced baseline. Base
173
+ * content comes from the local objects store (with a SHA-verified network
174
+ * fallback for pre-objects mounts), so the diff base is always the true sync
175
+ * point — never the server's current content.
176
+ */
177
+ export async function computeLocalDiff(mount, manifest) {
178
+ const diffFiles = [];
179
+ const patchParts = [];
180
+ const visited = new Set();
181
+ const baseShaByPath = new Map();
182
+ const loadBase = async (relPath, entry) => {
183
+ const base = await loadBaselineContent(mount, relPath, entry.sha);
184
+ // A missing baseline (pre-objects mount with a locally dirty file and a
185
+ // server that has since moved) degrades to an empty base: the patch shows
186
+ // the full local content as additions. propose() still carries the right
187
+ // base_sha, so staleness is caught server-side regardless.
188
+ return base ? base.toString('utf8') : '';
189
+ };
190
+ // Walk local files to find modified/added
191
+ await walkLocalFiles(mount.root, mount.root, async (fullPath, relativePath) => {
192
+ visited.add(relativePath);
193
+ const localContent = await fs.readFile(fullPath);
194
+ const localSha = computeGitBlobSHA(localContent);
195
+ const manifestEntry = manifest.files[relativePath];
196
+ if (!manifestEntry) {
197
+ // New file
198
+ const localText = localContent.toString('utf8');
199
+ appendFileDiff(diffFiles, patchParts, relativePath, '', localText, 'create');
200
+ }
201
+ else if (localSha !== manifestEntry.sha) {
202
+ // Modified file
203
+ baseShaByPath.set(relativePath, manifestEntry.sha);
204
+ const baseText = await loadBase(relativePath, manifestEntry);
205
+ appendFileDiff(diffFiles, patchParts, relativePath, baseText, localContent.toString('utf8'), 'update');
206
+ }
207
+ });
208
+ // Find deleted files
209
+ for (const [filePath, entry] of Object.entries(manifest.files)) {
210
+ if (!visited.has(filePath)) {
211
+ baseShaByPath.set(filePath, entry.sha);
212
+ const baseText = await loadBase(filePath, entry);
213
+ appendFileDiff(diffFiles, patchParts, filePath, baseText, '', 'delete');
214
+ }
215
+ }
216
+ diffFiles.sort((a, b) => a.path.localeCompare(b.path));
217
+ const changedPaths = diffFiles.map((f) => f.path);
218
+ const patch = patchParts.join('');
219
+ return { changedPaths, diffFiles, patch, baseShaByPath };
220
+ }
221
+ /** Append one file's real (Myers) unified diff and +/- counts. */
222
+ function appendFileDiff(diffFiles, patchParts, filePath, oldText, newText, action) {
223
+ const hunks = structuredPatch(filePath, filePath, oldText, newText, undefined, undefined, {
224
+ context: 3,
225
+ }).hunks;
226
+ let additions = 0;
227
+ let deletions = 0;
228
+ const parts = [`diff --git a/${filePath} b/${filePath}\n`];
229
+ if (action === 'create') {
230
+ parts.push('new file mode 100644\n');
231
+ }
232
+ else if (action === 'delete') {
233
+ parts.push('deleted file mode 100644\n');
234
+ }
235
+ parts.push(`--- ${action === 'create' ? '/dev/null' : `a/${filePath}`}\n`);
236
+ parts.push(`+++ ${action === 'delete' ? '/dev/null' : `b/${filePath}`}\n`);
237
+ for (const hunk of hunks) {
238
+ parts.push(`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@\n`);
239
+ for (const line of hunk.lines) {
240
+ parts.push(`${line}\n`);
241
+ if (line.startsWith('+'))
242
+ additions++;
243
+ else if (line.startsWith('-'))
244
+ deletions++;
245
+ }
246
+ }
247
+ diffFiles.push({ path: filePath, action, additions, deletions });
248
+ // An empty-file create/delete produces zero hunks but is still a real
249
+ // change — emit the header-only entry so the patch lists every changed
250
+ // path. Only a hunk-less UPDATE (identical content, e.g. mode-only noise)
251
+ // is genuinely nothing to show.
252
+ if (hunks.length > 0 || action !== 'update') {
253
+ patchParts.push(parts.join(''));
254
+ }
255
+ }
@@ -1,154 +1,10 @@
1
- import { type ParallClient, type Wiki, type WikiChangeset, type WikiDiff, type WikiDiffFile, type WikiTreeEntry } from '@parall/sdk';
2
- import { type StaleRecoveryReport } from './wiki-merge.js';
1
+ import { type Wiki, type WikiChangeset, type WikiDiffFile, type WikiTreeEntry } from '@parall/sdk';
2
+ import { type ParallContext, type WikiChangesetDiffResult, type WikiContentSource, type WikiOutlineResult, type WikiQueryResult, type WikiSearchOptions, type WikiSearchResult, type WikiSectionResult, type WikiWorkspaceDiffResult, type WikiWorkspaceStatusResult } from './wiki-shared.js';
3
3
  export { type ParsedFrontMatter, parseFrontMatter } from './wiki-frontmatter.js';
4
- export type ParallContext = {
5
- client: ParallClient;
6
- orgId: string;
7
- agentId?: string;
8
- /** Per-account wiki mount root. Takes priority over process.env.PRLL_WIKI_MOUNT_ROOT. */
9
- mountRoot?: string;
10
- /** Base URL of the wiki-service. Defaults to PRLL_WIKI_URL, then PRLL_API_URL. */
11
- baseUrl?: string;
12
- };
13
- export type WikiSearchOptions = {
14
- ref?: string;
15
- pathPrefix?: string;
16
- limit?: number;
17
- includeContent?: boolean;
18
- };
19
- export type WikiNodeSection = {
20
- wiki_id: string;
21
- wiki_slug: string;
22
- wiki_name: string;
23
- node_id: string;
24
- path: string;
25
- title: string;
26
- heading_path?: string[];
27
- section_path: string;
28
- level: number;
29
- start_line: number;
30
- end_line: number;
31
- type?: string;
32
- description?: string;
33
- tags?: string[];
34
- };
35
- export type WikiOutlineResult = {
36
- wiki_id: string;
37
- wiki_slug: string;
38
- wiki_name: string;
39
- ref?: string;
40
- path_prefix?: string;
41
- generated_at: string;
42
- file_count: number;
43
- nodes: WikiNodeSection[];
44
- source: WikiContentSource;
45
- };
46
- export type WikiQueryDocument = {
47
- path: string;
48
- title: string;
49
- score: number;
50
- matched_headings: string[];
51
- node_count: number;
52
- };
53
- export type WikiQuerySectionResult = WikiSearchResult & {
54
- document_score: number;
55
- reasoning: string[];
56
- };
57
- export type WikiQueryResult = {
58
- wiki_id: string;
59
- wiki_slug: string;
60
- wiki_name: string;
61
- query: string;
62
- ref?: string;
63
- path_prefix?: string;
64
- generated_at: string;
65
- file_count: number;
66
- source: WikiContentSource;
67
- documents: WikiQueryDocument[];
68
- sections: WikiQuerySectionResult[];
69
- };
70
- export type WikiSearchResult = WikiNodeSection & {
71
- score: number;
72
- snippet: string;
73
- content?: string;
74
- source: WikiContentSource;
75
- };
76
- export type WikiSectionResult = WikiNodeSection & {
77
- content: string;
78
- source: WikiContentSource;
79
- };
80
- export type WikiChangesetDiffResult = {
81
- wiki_id: string;
82
- wiki_slug: string;
83
- wiki_name: string;
84
- changeset_id: string;
85
- diff: WikiDiff;
86
- };
87
- export type WikiWorkspaceStatusResult = {
88
- wiki_id: string;
89
- wiki_slug: string;
90
- wiki_name: string;
91
- mount_path: string;
92
- mode: string;
93
- default_ref: string;
94
- changed_paths: string[];
95
- diff_files: WikiDiffFile[];
96
- dirty: boolean;
97
- source: 'local_mount';
98
- };
99
- export type WikiWorkspaceDiffResult = {
100
- wiki_id: string;
101
- wiki_slug: string;
102
- wiki_name: string;
103
- mount_path: string;
104
- changed_paths: string[];
105
- diff_files: WikiDiffFile[];
106
- patch: string;
107
- source: 'local_mount';
108
- };
109
- export type WikiProposeOptions = {
110
- changesetId?: string;
111
- title: string;
112
- message?: string;
113
- sourceChatId?: string;
114
- sourceMessageId?: string;
115
- sourceRunId?: string;
116
- };
117
- export type WikiProposeResult = {
118
- wiki_id: string;
119
- wiki_slug: string;
120
- wiki_name: string;
121
- mount_path: string;
122
- changed_paths: string[];
123
- diff_files: WikiDiffFile[];
124
- changeset: WikiChangeset;
125
- status: WikiChangeset['status'];
126
- auto_merged: boolean;
127
- requires_review: boolean;
128
- next_action: string;
129
- post_merge_sync: WikiSyncOutcome | null;
130
- post_merge_sync_error: string | null;
131
- /** Set when the server had moved since the last sync and propose re-synced and retried on its own. */
132
- stale_recovery: StaleRecoveryReport | null;
133
- source: 'local_mount';
134
- };
135
- type WikiContentSource = 'local_mount' | 'api';
136
- /** Server-side text ceiling for changeset file content (mirrors filetype.TextMaxBytes). */
137
- export declare const TEXT_MAX_BYTES: number;
138
- /** A wiki the CLI may operate on: readable (not a degraded listing stub) and
139
- * therefore always slugged. Everything downstream of listWikis/resolveWikiRef
140
- * works in this narrowed type. */
141
- export type ReadableWiki = Wiki & {
142
- slug: string;
143
- };
144
- export declare function listWikis(ctx: ParallContext): Promise<ReadableWiki[]>;
145
- export declare function resolveWikiRef(ctx: ParallContext, wikiRef?: string): Promise<ReadableWiki>;
146
- /**
147
- * Resolve wiki reference. If wikiRef is omitted or empty, auto-resolves to
148
- * the org's single wiki. Errors if the org has zero or multiple wikis without
149
- * a ref specified.
150
- */
151
- export declare function resolveWikiRefOrDefault(ctx: ParallContext, wikiRef?: string): Promise<ReadableWiki>;
4
+ export { type ParallContext, type ReadableWiki, type SyncConflict, type SyncFailure, TEXT_MAX_BYTES, type WikiChangesetDiffResult, type WikiNodeSection, type WikiOutlineResult, type WikiQueryDocument, type WikiQueryResult, type WikiQuerySectionResult, type WikiSearchOptions, type WikiSearchResult, type WikiSectionResult, type WikiSyncOutcome, type WikiWorkspaceDiffResult, type WikiWorkspaceStatusResult, computeGitBlobSHA, isWikiTextContent, listWikis, normalizeRequiredWikiPath, resolveApiToken, resolveWikiRef, resolveWikiRefOrDefault, resolveWikiServiceBaseUrl, } from './wiki-shared.js';
5
+ export { type SyncAction, type SyncResult, planSyncActions, removeConflictArtifacts, syncAllMounts, syncSingleWiki, watchMounts, writeConflictMarker, } from './wiki-sync.js';
6
+ export { type WikiProposeOptions, type WikiProposeResult, proposeWikiChangeset, resetWikiWorkspace, } from './wiki-propose.js';
7
+ export { detectFrontMatterEnd } from './wiki-index.js';
152
8
  export declare function getWikiTree(ctx: ParallContext, wikiRef?: string, options?: {
153
9
  path?: string;
154
10
  }): Promise<{
@@ -209,19 +65,6 @@ export type AfcsDiffResult = {
209
65
  patch: string;
210
66
  };
211
67
  export declare function getAfcsDiff(ctx: ParallContext, wikiRef?: string): Promise<AfcsDiffResult>;
212
- export declare function proposeWikiChangeset(ctx: ParallContext, wikiRef: string | undefined, options: WikiProposeOptions): Promise<WikiProposeResult>;
213
- /**
214
- * Discard all local changes and restore files to the last synced state.
215
- * Restores from the local baseline object store (network only as a
216
- * SHA-verified fallback for pre-objects mounts), so the workspace lands
217
- * exactly on the manifest baseline — `wiki status` reports clean afterwards.
218
- */
219
- export declare function resetWikiWorkspace(ctx: ParallContext, wikiRef?: string): Promise<{
220
- wiki_id: string;
221
- wiki_slug: string;
222
- files_restored: number;
223
- unrestorable_paths: string[];
224
- }>;
225
68
  export type AfcsChangesetsResult = {
226
69
  wiki_id: string;
227
70
  wiki_slug: string;
@@ -269,153 +112,4 @@ export type AfcsLogResult = {
269
112
  * path: that file's commit history from the default branch.
270
113
  */
271
114
  export declare function getWikiLog(ctx: ParallContext, wikiRef?: string, filePath?: string): Promise<AfcsLogResult>;
272
- export type SyncResult = {
273
- /** True iff every wiki's per-path action ran without failure. Conflicts do
274
- * NOT clear this flag — they are an expected, structured outcome the agent
275
- * is responsible for resolving. Only `failed[]` (download error,
276
- * shape-conflict, etc.) flips ok to false. */
277
- ok: boolean;
278
- mounts: number;
279
- synced: {
280
- slug: string;
281
- path: string;
282
- applied: number;
283
- fastForwarded: number;
284
- conflicts: SyncConflict[];
285
- failed: SyncFailure[];
286
- /** Paths where non-overlapping local and upstream edits were merged into the working copy. */
287
- merged: string[];
288
- }[];
289
- };
290
- /**
291
- * Sync wiki workspaces via REST (manifest comparison + bulk download).
292
- * Without `wikiRef`: every accessible wiki is synced and stale mount
293
- * directories are pruned. With `wikiRef`: only that wiki is synced and
294
- * pruning is skipped — other wikis' workspaces must survive a scoped sync.
295
- * Mount path is determined client-side: {mountRoot}/{slug}/
296
- */
297
- export declare function syncAllMounts(ctx: ParallContext, wikiRef?: string): Promise<SyncResult>;
298
- /**
299
- * Run {@link syncAllMounts} in a loop, sleeping `intervalSec` between
300
- * iterations. Returns a `stop` callback to break the loop.
301
- */
302
- export declare function watchMounts(ctx: ParallContext, intervalSec: number): {
303
- stop: () => void;
304
- };
305
- /**
306
- * Sync a single wiki:
307
- * 1. Fetch server manifest (file listing with SHAs)
308
- * 2. Compare with local manifest
309
- * 3. Download new/modified files via bulk download
310
- * 4. Delete removed files
311
- * 5. Save updated local manifest
312
- */
313
- /** Per-path sync action computed by three-way comparison. */
314
- export type SyncAction = {
315
- kind: 'noop';
316
- path: string;
317
- } | {
318
- kind: 'apply-write';
319
- path: string;
320
- remoteSha: string;
321
- remoteSize: number;
322
- } | {
323
- kind: 'apply-delete';
324
- path: string;
325
- } | {
326
- kind: 'fast-forward';
327
- path: string;
328
- remoteSha: string;
329
- remoteSize: number;
330
- } | {
331
- kind: 'fast-forward-delete';
332
- path: string;
333
- } | {
334
- kind: 'conflict-write';
335
- path: string;
336
- remoteSha: string;
337
- remoteSize: number;
338
- baseSha: string | null;
339
- localSha: string | null;
340
- } | {
341
- kind: 'conflict-delete';
342
- path: string;
343
- baseSha: string;
344
- };
345
- /**
346
- * Pure three-way sync planner. Decides what to do per-path given the base
347
- * (manifest entry from last successful sync), the current local working tree
348
- * sha, and the latest remote sha. No I/O.
349
- */
350
- export declare function planSyncActions(input: {
351
- paths: Iterable<string>;
352
- baseSha: (path: string) => string | null;
353
- localSha: (path: string) => string | null;
354
- remote: (path: string) => {
355
- sha: string;
356
- size: number;
357
- } | null;
358
- }): SyncAction[];
359
- export type SyncConflict = {
360
- path: string;
361
- /** Where the upstream copy was written (or null for remote-deleted markers). */
362
- remoteCopyPath: string | null;
363
- /** Type of conflict for logging / UI surface. */
364
- reason: 'remote-changed-local-edited' | 'remote-deleted-local-edited' | 'remote-added-local-collides' | 'remote-changed-local-deleted';
365
- };
366
- export type SyncFailure = {
367
- path: string;
368
- /**
369
- * Reason classification:
370
- * - 'download' — bulk-download endpoint surfaced a per-file error.
371
- * - 'shape-conflict' — local working tree has an incompatible file/directory
372
- * shape at this path (e.g. local `foo` is a directory
373
- * while remote treats `foo` as a file, or vice versa
374
- * when remote is `foo/bar.md` but local has `foo` as
375
- * a regular file).
376
- */
377
- reason: 'download' | 'shape-conflict';
378
- /** Server-supplied error string or local errno, when available. */
379
- detail?: string;
380
- };
381
- export type WikiSyncOutcome = {
382
- applied: number;
383
- fastForwarded: number;
384
- conflicts: SyncConflict[];
385
- /** Per-path failures that prevented a planned action from running. Manifest is left unchanged for these — next sync retries. */
386
- failed: SyncFailure[];
387
- /**
388
- * Paths both sides edited whose changes did not overlap: the upstream
389
- * change was merged into the working copy at line level and the manifest
390
- * advanced to the remote blob. Local edits stay pending for propose.
391
- */
392
- merged: string[];
393
- };
394
- export declare function syncSingleWiki(ctx: ParallContext, wiki: import('@parall/sdk').Wiki, mountPath: string): Promise<WikiSyncOutcome>;
395
- /**
396
- * Write a sync conflict marker under .parall-wiki/conflicts/, mirroring the
397
- * source path so the agent (or user) can locate the upstream copy next to the
398
- * local edit. Returns the absolute path written.
399
- */
400
- export declare function writeConflictMarker(mountRoot: string, sourcePath: string, suffix: string, content: Buffer): Promise<string>;
401
- export declare function resolveApiToken(ctx?: ParallContext): string;
402
- /**
403
- * Resolve the wiki-service base URL (trailing slashes trimmed): explicit ctx
404
- * override, then PRLL_WIKI_URL, then PRLL_API_URL. SSOT for the raw-fetch wiki
405
- * endpoints (sync / bulk-download / binary file download). Hosted/staging/prod
406
- * collapse these to one gateway host; local dev can split api (:8080) and wiki
407
- * (:8090). Returns '' when none is set — callers decide whether that's fatal.
408
- */
409
- export declare function resolveWikiServiceBaseUrl(ctx: ParallContext): string;
410
- export declare function computeGitBlobSHA(content: Buffer): string;
411
- /**
412
- * Mirror of the server's text classifier (filetype.IsText): content-type
413
- * magic sniff, valid UTF-8, and no NUL bytes — kept aligned so content the
414
- * CLI accepts cannot bounce off the server's 422 USE_UPLOAD later. The
415
- * shared fixture table (test/testdata/text-classifier-cases.json) is
416
- * verified by both this implementation's tests and the Go package's tests.
417
- */
418
- export declare function isWikiTextContent(content: Buffer): boolean;
419
- export declare function detectFrontMatterEnd(lines: string[]): number;
420
- export declare function normalizeRequiredWikiPath(value: string): string;
421
115
  //# sourceMappingURL=wiki.d.ts.map