@agent-wire/terminal 1.6.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.
- package/README.md +353 -0
- package/dist/api.d.ts +660 -0
- package/dist/api.js +1157 -0
- package/dist/api.js.map +1 -0
- package/dist/background-worker.d.ts +6 -0
- package/dist/background-worker.js +101 -0
- package/dist/background-worker.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +940 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/help-pointer.d.ts +11 -0
- package/dist/help-pointer.js +10 -0
- package/dist/help-pointer.js.map +1 -0
- package/dist/identity.d.ts +40 -0
- package/dist/identity.js +193 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/local-pull.d.ts +45 -0
- package/dist/local-pull.js +173 -0
- package/dist/local-pull.js.map +1 -0
- package/dist/lockfile.d.ts +16 -0
- package/dist/lockfile.js +78 -0
- package/dist/lockfile.js.map +1 -0
- package/dist/mcp-server.d.ts +43 -0
- package/dist/mcp-server.js +3159 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/response-shaper.d.ts +60 -0
- package/dist/response-shaper.js +893 -0
- package/dist/response-shaper.js.map +1 -0
- package/dist/slots.d.ts +65 -0
- package/dist/slots.js +128 -0
- package/dist/slots.js.map +1 -0
- package/dist/sync/diff.d.ts +17 -0
- package/dist/sync/diff.js +152 -0
- package/dist/sync/diff.js.map +1 -0
- package/dist/sync/hash.d.ts +11 -0
- package/dist/sync/hash.js +18 -0
- package/dist/sync/hash.js.map +1 -0
- package/dist/sync/index.d.ts +24 -0
- package/dist/sync/index.js +22 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/manifest.d.ts +29 -0
- package/dist/sync/manifest.js +59 -0
- package/dist/sync/manifest.js.map +1 -0
- package/dist/sync/match.d.ts +29 -0
- package/dist/sync/match.js +153 -0
- package/dist/sync/match.js.map +1 -0
- package/dist/sync/paginate.d.ts +16 -0
- package/dist/sync/paginate.js +34 -0
- package/dist/sync/paginate.js.map +1 -0
- package/dist/sync/preview.d.ts +16 -0
- package/dist/sync/preview.js +179 -0
- package/dist/sync/preview.js.map +1 -0
- package/dist/sync/pull.d.ts +23 -0
- package/dist/sync/pull.js +126 -0
- package/dist/sync/pull.js.map +1 -0
- package/dist/sync/push.d.ts +27 -0
- package/dist/sync/push.js +116 -0
- package/dist/sync/push.js.map +1 -0
- package/dist/sync/resolve.d.ts +19 -0
- package/dist/sync/resolve.js +42 -0
- package/dist/sync/resolve.js.map +1 -0
- package/dist/sync/types.d.ts +70 -0
- package/dist/sync/types.js +6 -0
- package/dist/sync/types.js.map +1 -0
- package/dist/sync/walk.d.ts +12 -0
- package/dist/sync/walk.js +155 -0
- package/dist/sync/walk.js.map +1 -0
- package/dist/wait-cli.d.ts +46 -0
- package/dist/wait-cli.js +280 -0
- package/dist/wait-cli.js.map +1 -0
- package/dist/worker.d.ts +14 -0
- package/dist/worker.js +252 -0
- package/dist/worker.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/sync/manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE7B,IAAI,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,GAAG,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC5D,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,SAAS,IAAI,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;QACxD,MAAM,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QACX,SAAS,EAAE,GAAG;QACd,KAAK,EAAE,YAAY;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document matching — maps local files to remote documents.
|
|
3
|
+
* Isomorphic — no Node.js dependencies.
|
|
4
|
+
*
|
|
5
|
+
* Matching strategy (in priority order):
|
|
6
|
+
* 1. Manifest-based: if a manifest exists, match by document_id
|
|
7
|
+
* 2. source_path-based: match by remote document's source_path field
|
|
8
|
+
* 3. Title-based: normalize filenames and titles, match by equality
|
|
9
|
+
* - Prefer published over draft
|
|
10
|
+
* - Exclude retracted documents
|
|
11
|
+
* - Flag ambiguous matches (multiple docs with same normalized title)
|
|
12
|
+
*/
|
|
13
|
+
import type { LocalFile, RemoteDocument, SyncManifest } from './types.js';
|
|
14
|
+
export interface MatchResult {
|
|
15
|
+
local?: LocalFile;
|
|
16
|
+
remote?: RemoteDocument;
|
|
17
|
+
matchedBy: 'manifest' | 'title' | 'source_path';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Normalize a filename to a comparable title string.
|
|
21
|
+
* Strips .md/.txt/.html extensions, converts hyphens and underscores
|
|
22
|
+
* to spaces, lowercases, trims, and collapses whitespace.
|
|
23
|
+
*/
|
|
24
|
+
export declare function normalizeTitle(filename: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Match local files to remote documents.
|
|
27
|
+
* Returns a Map keyed by relativePath with match results.
|
|
28
|
+
*/
|
|
29
|
+
export declare function matchDocuments(localFiles: Map<string, LocalFile>, remoteDocs: RemoteDocument[], manifest: SyncManifest | null): Map<string, MatchResult>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document matching — maps local files to remote documents.
|
|
3
|
+
* Isomorphic — no Node.js dependencies.
|
|
4
|
+
*
|
|
5
|
+
* Matching strategy (in priority order):
|
|
6
|
+
* 1. Manifest-based: if a manifest exists, match by document_id
|
|
7
|
+
* 2. source_path-based: match by remote document's source_path field
|
|
8
|
+
* 3. Title-based: normalize filenames and titles, match by equality
|
|
9
|
+
* - Prefer published over draft
|
|
10
|
+
* - Exclude retracted documents
|
|
11
|
+
* - Flag ambiguous matches (multiple docs with same normalized title)
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Normalize a filename to a comparable title string.
|
|
15
|
+
* Strips .md/.txt/.html extensions, converts hyphens and underscores
|
|
16
|
+
* to spaces, lowercases, trims, and collapses whitespace.
|
|
17
|
+
*/
|
|
18
|
+
export function normalizeTitle(filename) {
|
|
19
|
+
// Strip common extensions
|
|
20
|
+
let name = filename.replace(/\.(md|txt|html)$/i, '');
|
|
21
|
+
// Remove any leading directory path
|
|
22
|
+
const lastSlash = name.lastIndexOf('/');
|
|
23
|
+
if (lastSlash >= 0) {
|
|
24
|
+
name = name.substring(lastSlash + 1);
|
|
25
|
+
}
|
|
26
|
+
// Normalize hyphens and underscores to spaces
|
|
27
|
+
name = name.replace(/[-_]/g, ' ');
|
|
28
|
+
// Lowercase and collapse whitespace
|
|
29
|
+
return name.toLowerCase().replace(/\s+/g, ' ').trim();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Match local files to remote documents.
|
|
33
|
+
* Returns a Map keyed by relativePath with match results.
|
|
34
|
+
*/
|
|
35
|
+
export function matchDocuments(localFiles, remoteDocs, manifest) {
|
|
36
|
+
const results = new Map();
|
|
37
|
+
// Filter out retracted docs for matching purposes
|
|
38
|
+
const activeRemoteDocs = remoteDocs.filter(d => d.status !== 'retracted');
|
|
39
|
+
// Track which remote docs have been claimed
|
|
40
|
+
const claimedRemoteIds = new Set();
|
|
41
|
+
// ── Pass 1: Manifest-based matching ──────────────────────
|
|
42
|
+
if (manifest) {
|
|
43
|
+
for (const [relPath, entry] of Object.entries(manifest.files)) {
|
|
44
|
+
const local = localFiles.get(relPath);
|
|
45
|
+
const remote = activeRemoteDocs.find(d => d.id === entry.document_id);
|
|
46
|
+
if (local || remote) {
|
|
47
|
+
results.set(relPath, {
|
|
48
|
+
local: local || undefined,
|
|
49
|
+
remote: remote || undefined,
|
|
50
|
+
matchedBy: 'manifest',
|
|
51
|
+
});
|
|
52
|
+
if (remote)
|
|
53
|
+
claimedRemoteIds.add(remote.id);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// ── Pass 2: source_path matching for unmatched files ─────
|
|
58
|
+
for (const [relPath, local] of localFiles) {
|
|
59
|
+
if (results.has(relPath))
|
|
60
|
+
continue;
|
|
61
|
+
const matchByPath = activeRemoteDocs.find(d => !claimedRemoteIds.has(d.id) && d.source_path === relPath);
|
|
62
|
+
if (matchByPath) {
|
|
63
|
+
results.set(relPath, {
|
|
64
|
+
local,
|
|
65
|
+
remote: matchByPath,
|
|
66
|
+
matchedBy: 'source_path',
|
|
67
|
+
});
|
|
68
|
+
claimedRemoteIds.add(matchByPath.id);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// ── Pass 3: Title-based matching for remaining unmatched ─
|
|
72
|
+
// Build a map of normalized titles to remote docs (prefer published)
|
|
73
|
+
const titleMap = new Map();
|
|
74
|
+
for (const doc of activeRemoteDocs) {
|
|
75
|
+
if (claimedRemoteIds.has(doc.id))
|
|
76
|
+
continue;
|
|
77
|
+
const normTitle = normalizeTitle(doc.title);
|
|
78
|
+
const existing = titleMap.get(normTitle) || [];
|
|
79
|
+
existing.push(doc);
|
|
80
|
+
titleMap.set(normTitle, existing);
|
|
81
|
+
}
|
|
82
|
+
for (const [relPath, local] of localFiles) {
|
|
83
|
+
if (results.has(relPath))
|
|
84
|
+
continue;
|
|
85
|
+
const normFilename = normalizeTitle(relPath);
|
|
86
|
+
const candidates = titleMap.get(normFilename);
|
|
87
|
+
if (candidates && candidates.length > 0) {
|
|
88
|
+
// Sort: prefer published over draft
|
|
89
|
+
const sorted = [...candidates].sort((a, b) => {
|
|
90
|
+
if (a.status === 'published' && b.status !== 'published')
|
|
91
|
+
return -1;
|
|
92
|
+
if (b.status === 'published' && a.status !== 'published')
|
|
93
|
+
return 1;
|
|
94
|
+
// Prefer higher version number
|
|
95
|
+
return b.version_number - a.version_number;
|
|
96
|
+
});
|
|
97
|
+
const bestMatch = sorted[0];
|
|
98
|
+
// Only match if unambiguous (one candidate) or there's a clear published winner
|
|
99
|
+
if (candidates.length === 1 || bestMatch.status === 'published') {
|
|
100
|
+
results.set(relPath, {
|
|
101
|
+
local,
|
|
102
|
+
remote: bestMatch,
|
|
103
|
+
matchedBy: 'title',
|
|
104
|
+
});
|
|
105
|
+
claimedRemoteIds.add(bestMatch.id);
|
|
106
|
+
// Remove from title map
|
|
107
|
+
const remaining = candidates.filter(c => c.id !== bestMatch.id);
|
|
108
|
+
if (remaining.length > 0) {
|
|
109
|
+
titleMap.set(normFilename, remaining);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
titleMap.delete(normFilename);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
// Ambiguous — local-only, no match
|
|
117
|
+
results.set(relPath, {
|
|
118
|
+
local,
|
|
119
|
+
remote: undefined,
|
|
120
|
+
matchedBy: 'title',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
// No match at all — local only
|
|
126
|
+
results.set(relPath, {
|
|
127
|
+
local,
|
|
128
|
+
remote: undefined,
|
|
129
|
+
matchedBy: 'title',
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// ── Pass 4: Remote-only documents (no local match) ───────
|
|
134
|
+
for (const doc of activeRemoteDocs) {
|
|
135
|
+
if (claimedRemoteIds.has(doc.id))
|
|
136
|
+
continue;
|
|
137
|
+
// Use source_path if available, otherwise derive from title
|
|
138
|
+
let relPath = doc.source_path || `${doc.title.replace(/[^a-zA-Z0-9\s-_]/g, '').replace(/\s+/g, '-').toLowerCase()}.md`;
|
|
139
|
+
// If path collides, disambiguate with short doc ID suffix
|
|
140
|
+
if (results.has(relPath)) {
|
|
141
|
+
const ext = relPath.endsWith('.md') ? '.md' : relPath.endsWith('.txt') ? '.txt' : relPath.endsWith('.html') ? '.html' : '';
|
|
142
|
+
const base = ext ? relPath.slice(0, -ext.length) : relPath;
|
|
143
|
+
relPath = `${base}-${doc.id.slice(0, 8)}${ext}`;
|
|
144
|
+
}
|
|
145
|
+
results.set(relPath, {
|
|
146
|
+
local: undefined,
|
|
147
|
+
remote: doc,
|
|
148
|
+
matchedBy: doc.source_path ? 'source_path' : 'title',
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return results;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/sync/match.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,0BAA0B;IAC1B,IAAI,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IACrD,oCAAoC;IACpC,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACnB,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,8CAA8C;IAC9C,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAClC,oCAAoC;IACpC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAkC,EAClC,UAA4B,EAC5B,QAA6B;IAE7B,MAAM,OAAO,GAAG,IAAI,GAA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CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-pagination helper.
|
|
3
|
+
* Isomorphic — no Node.js dependencies.
|
|
4
|
+
*
|
|
5
|
+
* Fetches pages until a page returns fewer than pageSize results,
|
|
6
|
+
* indicating the last page has been reached.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Paginate through all results from a fetch function.
|
|
10
|
+
* Concatenates pages until a page returns fewer than pageSize items.
|
|
11
|
+
*
|
|
12
|
+
* @param fetchPage - Function that fetches a page (1-indexed page number, pageSize)
|
|
13
|
+
* @param pageSize - Number of items per page (default 100)
|
|
14
|
+
* @returns All items concatenated
|
|
15
|
+
*/
|
|
16
|
+
export declare function paginateAll<T>(fetchPage: (page: number, pageSize: number) => Promise<T[]>, pageSize?: number): Promise<T[]>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-pagination helper.
|
|
3
|
+
* Isomorphic — no Node.js dependencies.
|
|
4
|
+
*
|
|
5
|
+
* Fetches pages until a page returns fewer than pageSize results,
|
|
6
|
+
* indicating the last page has been reached.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Paginate through all results from a fetch function.
|
|
10
|
+
* Concatenates pages until a page returns fewer than pageSize items.
|
|
11
|
+
*
|
|
12
|
+
* @param fetchPage - Function that fetches a page (1-indexed page number, pageSize)
|
|
13
|
+
* @param pageSize - Number of items per page (default 100)
|
|
14
|
+
* @returns All items concatenated
|
|
15
|
+
*/
|
|
16
|
+
export async function paginateAll(fetchPage, pageSize = 100) {
|
|
17
|
+
const allItems = [];
|
|
18
|
+
let page = 1;
|
|
19
|
+
const MAX_PAGES = 500; // 500 pages * 100 per page = 50k docs max
|
|
20
|
+
while (true) {
|
|
21
|
+
if (page > MAX_PAGES) {
|
|
22
|
+
console.error(`[wire-sync] Pagination stopped at ${MAX_PAGES} pages (${allItems.length} items). If your corpus has more documents, contact support.`);
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
const items = await fetchPage(page, pageSize);
|
|
26
|
+
allItems.push(...items);
|
|
27
|
+
if (items.length < pageSize) {
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
page++;
|
|
31
|
+
}
|
|
32
|
+
return allItems;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=paginate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginate.js","sourceRoot":"","sources":["../../src/sync/paginate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,SAA2D,EAC3D,QAAQ,GAAG,GAAG;IAEd,MAAM,QAAQ,GAAQ,EAAE,CAAC;IACzB,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,MAAM,SAAS,GAAG,GAAG,CAAC,CAAE,0CAA0C;IAElE,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,IAAI,GAAG,SAAS,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,qCAAqC,SAAS,WAAW,QAAQ,CAAC,MAAM,8DAA8D,CAAC,CAAC;YACtJ,MAAM;QACR,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC9C,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAExB,IAAI,KAAK,CAAC,MAAM,GAAG,QAAQ,EAAE,CAAC;YAC5B,MAAM;QACR,CAAC;QAED,IAAI,EAAE,CAAC;IACT,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preview generation for sync operations.
|
|
3
|
+
* Isomorphic — no Node.js dependencies.
|
|
4
|
+
*
|
|
5
|
+
* Produces both human-readable ASCII box-drawing output (for CLI)
|
|
6
|
+
* and structured JSON (for programmatic consumers).
|
|
7
|
+
*/
|
|
8
|
+
import type { PreviewOutput } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Generate a human-readable ASCII preview of sync operations.
|
|
11
|
+
*/
|
|
12
|
+
export declare function generatePreview(result: PreviewOutput): string;
|
|
13
|
+
/**
|
|
14
|
+
* Generate structured JSON preview for programmatic use.
|
|
15
|
+
*/
|
|
16
|
+
export declare function generatePreviewJson(result: PreviewOutput): object;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preview generation for sync operations.
|
|
3
|
+
* Isomorphic — no Node.js dependencies.
|
|
4
|
+
*
|
|
5
|
+
* Produces both human-readable ASCII box-drawing output (for CLI)
|
|
6
|
+
* and structured JSON (for programmatic consumers).
|
|
7
|
+
*/
|
|
8
|
+
const BOX_WIDTH = 64;
|
|
9
|
+
function pad(text, width) {
|
|
10
|
+
if (text.length >= width)
|
|
11
|
+
return text.substring(0, width);
|
|
12
|
+
return text + ' '.repeat(width - text.length);
|
|
13
|
+
}
|
|
14
|
+
function formatEntryLine(tag, entry) {
|
|
15
|
+
const lines = [];
|
|
16
|
+
const label = `[${tag}]`.padEnd(10);
|
|
17
|
+
const name = entry.relativePath;
|
|
18
|
+
const size = entry.sizeInfo ? `(${entry.sizeInfo})` : '';
|
|
19
|
+
// Main line: fit tag + name + size within box
|
|
20
|
+
const mainContent = `${label}${name}`;
|
|
21
|
+
const mainLine = size
|
|
22
|
+
? `${mainContent.padEnd(BOX_WIDTH - size.length - 8)}${size}`
|
|
23
|
+
: mainContent;
|
|
24
|
+
lines.push(mainLine);
|
|
25
|
+
// Warning lines
|
|
26
|
+
for (const warning of entry.warnings) {
|
|
27
|
+
lines.push(` \u26A0 ${warning}`);
|
|
28
|
+
}
|
|
29
|
+
return lines;
|
|
30
|
+
}
|
|
31
|
+
function boxSection(title, entries, tag) {
|
|
32
|
+
if (entries.length === 0)
|
|
33
|
+
return [];
|
|
34
|
+
const lines = [];
|
|
35
|
+
lines.push(`\u2551 ${pad(title, BOX_WIDTH - 4)} \u2551`);
|
|
36
|
+
lines.push(`\u2551 \u250C${'─'.repeat(BOX_WIDTH - 5)}\u2510 \u2551`);
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
const entryLines = formatEntryLine(tag, entry);
|
|
39
|
+
for (const line of entryLines) {
|
|
40
|
+
lines.push(`\u2551 \u2502 ${pad(line, BOX_WIDTH - 6)}\u2502 \u2551`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// For push_update entries, add the UPDATE tag differently
|
|
44
|
+
lines.push(`\u2551 \u2514${'─'.repeat(BOX_WIDTH - 5)}\u2518 \u2551`);
|
|
45
|
+
return lines;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Generate a human-readable ASCII preview of sync operations.
|
|
49
|
+
*/
|
|
50
|
+
export function generatePreview(result) {
|
|
51
|
+
const lines = [];
|
|
52
|
+
// Top border
|
|
53
|
+
lines.push(`\u2554${'═'.repeat(BOX_WIDTH)}\u2557`);
|
|
54
|
+
// Header
|
|
55
|
+
lines.push(`\u2551 ${pad('Wire Corpus Sync \u2014 Preview', BOX_WIDTH - 4)} \u2551`);
|
|
56
|
+
const localLabel = result.local_dir.length > 25
|
|
57
|
+
? '...' + result.local_dir.slice(-22)
|
|
58
|
+
: result.local_dir;
|
|
59
|
+
lines.push(`\u2551 ${pad(`Local: ${localLabel} \u2194 Wire: ${result.corpus_slug}`, BOX_WIDTH - 4)} \u2551`);
|
|
60
|
+
// Separator
|
|
61
|
+
lines.push(`\u2560${'═'.repeat(BOX_WIDTH)}\u2563`);
|
|
62
|
+
// Push section
|
|
63
|
+
const pushEntries = [
|
|
64
|
+
...result.diff.push_new.map(e => ({ entry: e, tag: 'NEW' })),
|
|
65
|
+
...result.diff.push_update.map(e => ({ entry: e, tag: 'UPDATE' })),
|
|
66
|
+
];
|
|
67
|
+
if (pushEntries.length > 0) {
|
|
68
|
+
lines.push(`\u2551 ${pad('PUSH (Local \u2192 Wire)', BOX_WIDTH - 4)} \u2551`);
|
|
69
|
+
lines.push(`\u2551 \u250C${'─'.repeat(BOX_WIDTH - 5)}\u2510 \u2551`);
|
|
70
|
+
for (const { entry, tag } of pushEntries) {
|
|
71
|
+
const entryLines = formatEntryLine(tag, entry);
|
|
72
|
+
for (const line of entryLines) {
|
|
73
|
+
lines.push(`\u2551 \u2502 ${pad(line, BOX_WIDTH - 6)}\u2502 \u2551`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
lines.push(`\u2551 \u2514${'─'.repeat(BOX_WIDTH - 5)}\u2518 \u2551`);
|
|
77
|
+
}
|
|
78
|
+
// Pull section
|
|
79
|
+
const pullEntries = [
|
|
80
|
+
...result.diff.pull_new.map(e => ({ entry: e, tag: 'NEW' })),
|
|
81
|
+
...result.diff.pull_update.map(e => ({ entry: e, tag: 'UPDATE' })),
|
|
82
|
+
];
|
|
83
|
+
if (pullEntries.length > 0) {
|
|
84
|
+
lines.push(`\u2551 ${pad('PULL (Wire \u2192 Local)', BOX_WIDTH - 4)} \u2551`);
|
|
85
|
+
lines.push(`\u2551 \u250C${'─'.repeat(BOX_WIDTH - 5)}\u2510 \u2551`);
|
|
86
|
+
for (const { entry, tag } of pullEntries) {
|
|
87
|
+
const entryLines = formatEntryLine(tag, entry);
|
|
88
|
+
for (const line of entryLines) {
|
|
89
|
+
lines.push(`\u2551 \u2502 ${pad(line, BOX_WIDTH - 6)}\u2502 \u2551`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
lines.push(`\u2551 \u2514${'─'.repeat(BOX_WIDTH - 5)}\u2518 \u2551`);
|
|
93
|
+
}
|
|
94
|
+
// Conflicts section
|
|
95
|
+
if (result.diff.conflicts.length > 0) {
|
|
96
|
+
lines.push(`\u2551 ${pad('CONFLICTS (require resolution)', BOX_WIDTH - 4)} \u2551`);
|
|
97
|
+
lines.push(`\u2551 \u250C${'─'.repeat(BOX_WIDTH - 5)}\u2510 \u2551`);
|
|
98
|
+
for (const entry of result.diff.conflicts) {
|
|
99
|
+
const entryLines = formatEntryLine('CONFLICT', entry);
|
|
100
|
+
for (const line of entryLines) {
|
|
101
|
+
lines.push(`\u2551 \u2502 ${pad(line, BOX_WIDTH - 6)}\u2502 \u2551`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
lines.push(`\u2551 \u2514${'─'.repeat(BOX_WIDTH - 5)}\u2518 \u2551`);
|
|
105
|
+
}
|
|
106
|
+
// Summary
|
|
107
|
+
const { summary } = result;
|
|
108
|
+
const parts = [];
|
|
109
|
+
if (summary.push_new > 0)
|
|
110
|
+
parts.push(`${summary.push_new} new push${summary.push_new > 1 ? 'es' : ''}`);
|
|
111
|
+
if (summary.push_update > 0)
|
|
112
|
+
parts.push(`${summary.push_update} update push${summary.push_update > 1 ? 'es' : ''}`);
|
|
113
|
+
if (summary.pull_new > 0)
|
|
114
|
+
parts.push(`${summary.pull_new} new pull${summary.pull_new > 1 ? 's' : ''}`);
|
|
115
|
+
if (summary.pull_update > 0)
|
|
116
|
+
parts.push(`${summary.pull_update} update pull${summary.pull_update > 1 ? 's' : ''}`);
|
|
117
|
+
if (summary.in_sync > 0)
|
|
118
|
+
parts.push(`${summary.in_sync} in sync`);
|
|
119
|
+
if (summary.conflicts > 0)
|
|
120
|
+
parts.push(`${summary.conflicts} conflict${summary.conflicts > 1 ? 's' : ''}`);
|
|
121
|
+
const summaryText = parts.length > 0 ? `Summary: ${parts.join(', ')}` : 'Summary: nothing to sync';
|
|
122
|
+
lines.push(`\u2551 ${pad(summaryText, BOX_WIDTH - 4)} \u2551`);
|
|
123
|
+
// Action line
|
|
124
|
+
lines.push(`\u2551 ${pad('[A] Sync all [S] Select individually [Q] Cancel', BOX_WIDTH - 4)} \u2551`);
|
|
125
|
+
// Bottom border
|
|
126
|
+
lines.push(`\u255A${'═'.repeat(BOX_WIDTH)}\u255D`);
|
|
127
|
+
return lines.join('\n');
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Generate structured JSON preview for programmatic use.
|
|
131
|
+
*/
|
|
132
|
+
export function generatePreviewJson(result) {
|
|
133
|
+
return {
|
|
134
|
+
corpus_slug: result.corpus_slug,
|
|
135
|
+
local_dir: result.local_dir,
|
|
136
|
+
summary: result.summary,
|
|
137
|
+
push: {
|
|
138
|
+
new: result.diff.push_new.map(e => ({
|
|
139
|
+
path: e.relativePath,
|
|
140
|
+
size: e.sizeInfo,
|
|
141
|
+
warnings: e.warnings,
|
|
142
|
+
})),
|
|
143
|
+
update: result.diff.push_update.map(e => ({
|
|
144
|
+
path: e.relativePath,
|
|
145
|
+
size: e.sizeInfo,
|
|
146
|
+
remote_id: e.remoteDoc?.id,
|
|
147
|
+
remote_status: e.remoteDoc?.status,
|
|
148
|
+
remote_anchored: e.remoteDoc?.anchored,
|
|
149
|
+
remote_version: e.remoteDoc?.version_number,
|
|
150
|
+
warnings: e.warnings,
|
|
151
|
+
})),
|
|
152
|
+
},
|
|
153
|
+
pull: {
|
|
154
|
+
new: result.diff.pull_new.map(e => ({
|
|
155
|
+
path: e.relativePath,
|
|
156
|
+
remote_id: e.remoteDoc?.id,
|
|
157
|
+
remote_status: e.remoteDoc?.status,
|
|
158
|
+
warnings: e.warnings,
|
|
159
|
+
})),
|
|
160
|
+
update: result.diff.pull_update.map(e => ({
|
|
161
|
+
path: e.relativePath,
|
|
162
|
+
remote_id: e.remoteDoc?.id,
|
|
163
|
+
remote_status: e.remoteDoc?.status,
|
|
164
|
+
warnings: e.warnings,
|
|
165
|
+
})),
|
|
166
|
+
},
|
|
167
|
+
conflicts: result.diff.conflicts.map(e => ({
|
|
168
|
+
path: e.relativePath,
|
|
169
|
+
remote_id: e.remoteDoc?.id,
|
|
170
|
+
remote_status: e.remoteDoc?.status,
|
|
171
|
+
warnings: e.warnings,
|
|
172
|
+
})),
|
|
173
|
+
in_sync: result.diff.in_sync.map(e => ({
|
|
174
|
+
path: e.relativePath,
|
|
175
|
+
remote_id: e.remoteDoc?.id,
|
|
176
|
+
})),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../src/sync/preview.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,SAAS,GAAG,CAAC,IAAY,EAAE,KAAa;IACtC,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC1D,OAAO,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,eAAe,CAAC,GAAW,EAAE,KAAgB;IACpD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC;IAChC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAEzD,8CAA8C;IAC9C,MAAM,WAAW,GAAG,GAAG,KAAK,GAAG,IAAI,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAG,IAAI;QACnB,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE;QAC7D,CAAC,CAAC,WAAW,CAAC;IAChB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAErB,gBAAgB;IAChB,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrC,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;gBAClC,QAAQ,EAAE,CAAC,CAAC,QAAQ;aACrB,CAAC,CAAC;YACH,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACxC,IAAI,EAAE,CAAC,CAAC,YAAY;gBACpB,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE;gBAC1B,aAAa,EAAE,CAAC,CAAC,SAAS,EAAE,MAAM;gBAClC,QAAQ,EAAE,CAAC,CAAC,QAAQ;aACrB,CAAC,CAAC;SACJ;QACD,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACzC,IAAI,EAAE,CAAC,CAAC,YAAY;YACpB,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE;YAC1B,aAAa,EAAE,CAAC,CAAC,SAAS,EAAE,MAAM;YAClC,QAAQ,EAAE,CAAC,CAAC,QAAQ;SACrB,CAAC,CAAC;QACH,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACrC,IAAI,EAAE,CAAC,CAAC,YAAY;YACpB,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE;SAC3B,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pull remote documents to local filesystem.
|
|
3
|
+
* Node.js only — uses fs/promises.
|
|
4
|
+
*
|
|
5
|
+
* Reconstructs directory structure from source_path.
|
|
6
|
+
* Validates all paths stay within the sync root directory.
|
|
7
|
+
*/
|
|
8
|
+
import type { WireAPI } from '../api.js';
|
|
9
|
+
import type { DiffEntry } from './types.js';
|
|
10
|
+
export interface PullResult {
|
|
11
|
+
relativePath: string;
|
|
12
|
+
success: boolean;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Pull remote documents to the local filesystem.
|
|
17
|
+
*
|
|
18
|
+
* @param apiClient - Authenticated WireAPI instance
|
|
19
|
+
* @param syncDir - Local directory to pull files into
|
|
20
|
+
* @param entries - DiffEntry items to pull (pull_new or pull_update)
|
|
21
|
+
* @returns Array of pull results per file
|
|
22
|
+
*/
|
|
23
|
+
export declare function pullFiles(apiClient: WireAPI, syncDir: string, entries: DiffEntry[]): Promise<PullResult[]>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pull remote documents to local filesystem.
|
|
3
|
+
* Node.js only — uses fs/promises.
|
|
4
|
+
*
|
|
5
|
+
* Reconstructs directory structure from source_path.
|
|
6
|
+
* Validates all paths stay within the sync root directory.
|
|
7
|
+
*/
|
|
8
|
+
import { writeFile, mkdir } from 'fs/promises';
|
|
9
|
+
import { join, resolve, dirname } from 'path';
|
|
10
|
+
import { statfsSync } from 'fs';
|
|
11
|
+
import { computeHash } from './hash.js';
|
|
12
|
+
/**
|
|
13
|
+
* Validate that a resolved path is within the sync root.
|
|
14
|
+
* Prevents path traversal attacks.
|
|
15
|
+
*/
|
|
16
|
+
function validatePathWithinRoot(targetPath, rootDir) {
|
|
17
|
+
const resolved = resolve(targetPath);
|
|
18
|
+
const resolvedRoot = resolve(rootDir);
|
|
19
|
+
return resolved.startsWith(resolvedRoot + '/') || resolved === resolvedRoot;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check available disk space (in bytes).
|
|
23
|
+
* Returns null if unable to determine.
|
|
24
|
+
*/
|
|
25
|
+
function getAvailableDiskSpace(dir) {
|
|
26
|
+
try {
|
|
27
|
+
const stats = statfsSync(dir);
|
|
28
|
+
const availableBytes = stats.bavail * stats.bsize;
|
|
29
|
+
return availableBytes;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Ignore
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const MIN_DISK_SPACE_BYTES = 100 * 1024 * 1024; // 100 MB
|
|
37
|
+
/**
|
|
38
|
+
* Pull remote documents to the local filesystem.
|
|
39
|
+
*
|
|
40
|
+
* @param apiClient - Authenticated WireAPI instance
|
|
41
|
+
* @param syncDir - Local directory to pull files into
|
|
42
|
+
* @param entries - DiffEntry items to pull (pull_new or pull_update)
|
|
43
|
+
* @returns Array of pull results per file
|
|
44
|
+
*/
|
|
45
|
+
export async function pullFiles(apiClient, syncDir, entries) {
|
|
46
|
+
const rootDir = resolve(syncDir);
|
|
47
|
+
const results = [];
|
|
48
|
+
if (entries.length === 0) {
|
|
49
|
+
return results;
|
|
50
|
+
}
|
|
51
|
+
// Check disk space before starting
|
|
52
|
+
const availableSpace = getAvailableDiskSpace(rootDir);
|
|
53
|
+
if (availableSpace !== null && availableSpace < MIN_DISK_SPACE_BYTES) {
|
|
54
|
+
const availableMB = (availableSpace / (1024 * 1024)).toFixed(1);
|
|
55
|
+
return entries.map(e => ({
|
|
56
|
+
relativePath: e.relativePath,
|
|
57
|
+
success: false,
|
|
58
|
+
error: `Insufficient disk space: ${availableMB} MB available, need at least 100 MB`,
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
for (const entry of entries) {
|
|
62
|
+
try {
|
|
63
|
+
if (!entry.remoteDoc) {
|
|
64
|
+
results.push({
|
|
65
|
+
relativePath: entry.relativePath,
|
|
66
|
+
success: false,
|
|
67
|
+
error: 'No remote document reference available',
|
|
68
|
+
});
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
// Determine local file path
|
|
72
|
+
const relPath = entry.relativePath;
|
|
73
|
+
// Validate the path stays within sync root
|
|
74
|
+
const targetPath = join(rootDir, relPath);
|
|
75
|
+
if (!validatePathWithinRoot(targetPath, rootDir)) {
|
|
76
|
+
results.push({
|
|
77
|
+
relativePath: relPath,
|
|
78
|
+
success: false,
|
|
79
|
+
error: `Path escapes sync root: ${relPath}`,
|
|
80
|
+
});
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
// Fetch full document content from API
|
|
84
|
+
const doc = await apiClient.readDocument(entry.remoteDoc.id);
|
|
85
|
+
const content = doc.body || doc.content || '';
|
|
86
|
+
if (!content) {
|
|
87
|
+
results.push({
|
|
88
|
+
relativePath: relPath,
|
|
89
|
+
success: false,
|
|
90
|
+
error: 'Remote document has no body content',
|
|
91
|
+
});
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
// Verify downloaded content hash matches expected hash
|
|
95
|
+
if (entry.remoteDoc.body_hash) {
|
|
96
|
+
const downloadedHash = await computeHash(content);
|
|
97
|
+
if (downloadedHash !== entry.remoteDoc.body_hash) {
|
|
98
|
+
results.push({
|
|
99
|
+
relativePath: relPath,
|
|
100
|
+
success: false,
|
|
101
|
+
error: `Hash mismatch: expected ${entry.remoteDoc.body_hash}, got ${downloadedHash}`,
|
|
102
|
+
});
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Create directory structure
|
|
107
|
+
const targetDir = dirname(targetPath);
|
|
108
|
+
await mkdir(targetDir, { recursive: true });
|
|
109
|
+
// Write file
|
|
110
|
+
await writeFile(targetPath, content, 'utf-8');
|
|
111
|
+
results.push({
|
|
112
|
+
relativePath: relPath,
|
|
113
|
+
success: true,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
results.push({
|
|
118
|
+
relativePath: entry.relativePath,
|
|
119
|
+
success: false,
|
|
120
|
+
error: err instanceof Error ? err.message : String(err),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return results;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=pull.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../../src/sync/pull.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAkB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
|
|
2
|
+
* Push local files to Wire.
|
|
3
|
+
* Requires WireAPI client — uses HTTP calls, not fs.
|
|
4
|
+
*
|
|
5
|
+
* Strategy:
|
|
6
|
+
* - push_new: POST to create document with source_path set
|
|
7
|
+
* - push_update (draft): PATCH to update body directly
|
|
8
|
+
* - push_update (published): call createDocumentVersion RPC to atomically create a new version
|
|
9
|
+
*/
|
|
10
|
+
import type { WireAPI } from '../api.js';
|
|
11
|
+
import type { DiffEntry } from './types.js';
|
|
12
|
+
export interface PushResult {
|
|
13
|
+
relativePath: string;
|
|
14
|
+
documentId: string;
|
|
15
|
+
success: boolean;
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Push local files to the Wire corpus.
|
|
20
|
+
*
|
|
21
|
+
* @param apiClient - Authenticated WireAPI instance
|
|
22
|
+
* @param corpusSlug - The corpus slug to push to
|
|
23
|
+
* @param entries - DiffEntry items to push (push_new or push_update)
|
|
24
|
+
* @param publish - Whether to publish immediately (default: false, creates as draft)
|
|
25
|
+
* @returns Array of push results per file
|
|
26
|
+
*/
|
|
27
|
+
export declare function pushFiles(apiClient: WireAPI, corpusSlug: string, entries: DiffEntry[], publish?: boolean): Promise<PushResult[]>;
|