@infinite-room-labs/claudesync-cli 0.5.1 → 0.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-all.d.ts","sourceRoot":"","sources":["../../src/commands/export-all.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"export-all.d.ts","sourceRoot":"","sources":["../../src/commands/export-all.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC,eAAO,MAAM,gBAAgB,SAuKzB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
-
import { existsSync,
|
|
4
|
-
import {
|
|
3
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { exportToGit, fetchAndBuild, syncConversation, safeSlug, displayName, replaceWithPreserve, } from "@infinite-room-labs/claudesync-core";
|
|
5
5
|
import { createClient, resolveOrgId } from "../utils.js";
|
|
6
6
|
export const exportAllCommand = new Command("export-all")
|
|
7
7
|
.description("Export entire organization: all projects (with knowledge + conversations) and standalone conversations")
|
|
@@ -13,6 +13,7 @@ export const exportAllCommand = new Command("export-all")
|
|
|
13
13
|
.option("--skip-artifacts", "Skip downloading artifacts (faster)")
|
|
14
14
|
.option("--skip-existing", "Skip conversations/projects whose output directory already exists")
|
|
15
15
|
.option("--skip-same", "Skip conversations unchanged since the last sync (uses .claudesync-state.json sidecar). Mutually exclusive with --skip-existing.")
|
|
16
|
+
.option("--preserve <glob>", "Glob (POSIX-style, relative to each conversation dir) of locally-added files to keep across re-syncs in --format files. Repeatable. CHANGELOG.md is always preserved. Examples: --preserve INDEX.md --preserve 'notes/**'", (value, previous = []) => previous.concat(value), [])
|
|
16
17
|
.action(async (options) => {
|
|
17
18
|
if (options.skipSame && options.skipExisting) {
|
|
18
19
|
console.error("error: --skip-same and --skip-existing are mutually exclusive");
|
|
@@ -33,16 +34,17 @@ export const exportAllCommand = new Command("export-all")
|
|
|
33
34
|
for (let pi = 0; pi < projects.length; pi++) {
|
|
34
35
|
const project = projects[pi];
|
|
35
36
|
const projectProgress = `[project ${pi + 1}/${projects.length}]`;
|
|
36
|
-
const
|
|
37
|
+
const projectLabel = displayName(project.name, project.uuid);
|
|
38
|
+
const projectSlug = safeSlug(project.name, project.uuid);
|
|
37
39
|
const projectPath = resolve(outputRoot, "projects", projectSlug);
|
|
38
40
|
if (options.skipExisting && existsSync(projectPath)) {
|
|
39
|
-
console.log(`${projectProgress} Skipping (exists): ${
|
|
41
|
+
console.log(`${projectProgress} Skipping (exists): ${projectLabel}`);
|
|
40
42
|
const projConvs = await client.getProjectConversations(orgId, project.uuid);
|
|
41
43
|
for (const c of projConvs)
|
|
42
44
|
projectConvUuids.add(c.uuid);
|
|
43
45
|
continue;
|
|
44
46
|
}
|
|
45
|
-
console.log(`${projectProgress} ${
|
|
47
|
+
console.log(`${projectProgress} ${projectLabel}`);
|
|
46
48
|
const docs = await client.getProjectDocs(orgId, project.uuid);
|
|
47
49
|
const projConvs = await client.getProjectConversations(orgId, project.uuid);
|
|
48
50
|
for (const c of projConvs)
|
|
@@ -56,28 +58,26 @@ export const exportAllCommand = new Command("export-all")
|
|
|
56
58
|
projectFiles[`knowledge/${safeName}`] = doc.content;
|
|
57
59
|
}
|
|
58
60
|
commits.push({
|
|
59
|
-
message: `Export project: ${
|
|
61
|
+
message: `Export project: ${projectLabel}`,
|
|
60
62
|
timestamp: project.created_at,
|
|
61
63
|
author,
|
|
62
64
|
files: projectFiles,
|
|
63
65
|
});
|
|
64
|
-
// Conversations within the project:
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
// applied at this layer (the project repo is rebuilt as a unit).
|
|
66
|
+
// Conversations within the project: route through fetchAndBuild for
|
|
67
|
+
// identical name/slug fallbacks and tree handling. --skip-same does not
|
|
68
|
+
// apply at this layer (the project repo is rebuilt as a unit each run).
|
|
68
69
|
for (let ci = 0; ci < projConvs.length; ci++) {
|
|
69
70
|
const convSummary = projConvs[ci];
|
|
70
71
|
const convProgress = ` [${ci + 1}/${projConvs.length}]`;
|
|
71
|
-
|
|
72
|
-
const conversation = await client.getConversation(orgId, convSummary.uuid, { tree: true });
|
|
73
|
-
const { artifacts, artifactContents } = await fetchArtifacts(client, orgId, convSummary.uuid, !options.skipArtifacts);
|
|
74
|
-
const subBundle = buildGitBundle(conversation, artifacts, artifactContents, {
|
|
72
|
+
const built = await fetchAndBuild(client, orgId, convSummary, {
|
|
75
73
|
authorName: options.authorName,
|
|
76
74
|
authorEmail: options.authorEmail,
|
|
75
|
+
skipArtifacts: options.skipArtifacts,
|
|
77
76
|
multiBranch: true,
|
|
78
77
|
});
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
console.log(`${convProgress} ${built.displayName}`);
|
|
79
|
+
const convDir = `conversations/${built.slug}`;
|
|
80
|
+
for (const commit of built.bundle.commits) {
|
|
81
81
|
const remappedFiles = {};
|
|
82
82
|
for (const [p, content] of Object.entries(commit.files)) {
|
|
83
83
|
remappedFiles[`${convDir}/${p}`] = content;
|
|
@@ -88,25 +88,22 @@ export const exportAllCommand = new Command("export-all")
|
|
|
88
88
|
const bundle = {
|
|
89
89
|
metadata: {
|
|
90
90
|
conversationId: project.uuid,
|
|
91
|
-
conversationName:
|
|
91
|
+
conversationName: projectLabel,
|
|
92
92
|
model: null,
|
|
93
93
|
createdAt: project.created_at,
|
|
94
94
|
exportedAt: new Date().toISOString(),
|
|
95
95
|
},
|
|
96
96
|
commits,
|
|
97
97
|
};
|
|
98
|
-
await writeProjectBundle(bundle, projectPath, options.format);
|
|
98
|
+
await writeProjectBundle(bundle, projectPath, options.format, options.preserve);
|
|
99
99
|
}
|
|
100
|
-
// 2. Standalone conversations
|
|
101
|
-
// applies per conversation via the orchestrator.
|
|
100
|
+
// 2. Standalone conversations -- --skip-same applies here per conversation.
|
|
102
101
|
const standaloneConvs = allConversations.filter((c) => !c.project_uuid && !projectConvUuids.has(c.uuid));
|
|
103
102
|
console.log(`\n${standaloneConvs.length} standalone conversation(s) to export`);
|
|
104
103
|
for (let ci = 0; ci < standaloneConvs.length; ci++) {
|
|
105
104
|
const convSummary = standaloneConvs[ci];
|
|
106
105
|
const convProgress = `[conv ${ci + 1}/${standaloneConvs.length}]`;
|
|
107
|
-
const
|
|
108
|
-
const convSlug = slugify(convSummary.name) || `unnamed-${convSummary.uuid}`;
|
|
109
|
-
const convPath = resolve(outputRoot, "conversations", convSlug);
|
|
106
|
+
const convPath = resolve(outputRoot, "conversations", safeSlug(convSummary.name, convSummary.uuid));
|
|
110
107
|
try {
|
|
111
108
|
const result = await syncConversation(client, orgId, convSummary, convPath, {
|
|
112
109
|
format: options.format,
|
|
@@ -115,14 +112,16 @@ export const exportAllCommand = new Command("export-all")
|
|
|
115
112
|
skipSame: options.skipSame,
|
|
116
113
|
skipExisting: options.skipExisting,
|
|
117
114
|
skipArtifacts: options.skipArtifacts,
|
|
115
|
+
preserve: options.preserve,
|
|
118
116
|
});
|
|
119
117
|
const tag = result.action === "skipped" ? "Skipping (same)" :
|
|
120
118
|
result.action === "skipped-existing" ? "Skipping (exists)" :
|
|
121
119
|
result.action === "incremental" ? "Updated" : "Exported";
|
|
122
|
-
console.log(`${convProgress} ${tag}: ${
|
|
120
|
+
console.log(`${convProgress} ${tag}: ${result.displayName}`);
|
|
123
121
|
}
|
|
124
122
|
catch (err) {
|
|
125
|
-
|
|
123
|
+
const fallback = displayName(convSummary.name, convSummary.uuid);
|
|
124
|
+
console.error(`${convProgress} ERROR exporting ${fallback}: ${err instanceof Error ? err.message : String(err)}`);
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
127
|
console.log(`\nOrg export complete!`);
|
|
@@ -130,54 +129,29 @@ export const exportAllCommand = new Command("export-all")
|
|
|
130
129
|
console.log(` Projects: ${projects.length}`);
|
|
131
130
|
console.log(` Standalone conversations: ${standaloneConvs.length}`);
|
|
132
131
|
});
|
|
133
|
-
async function
|
|
134
|
-
const empty = { success: true, files: [], files_metadata: [] };
|
|
135
|
-
if (!enabled)
|
|
136
|
-
return { artifacts: empty, artifactContents: new Map() };
|
|
137
|
-
const artifactContents = new Map();
|
|
138
|
-
let artifacts = empty;
|
|
139
|
-
try {
|
|
140
|
-
artifacts = await client.listArtifacts(orgId, convId);
|
|
141
|
-
for (const meta of artifacts.files_metadata) {
|
|
142
|
-
try {
|
|
143
|
-
const content = await client.downloadArtifact(orgId, convId, meta.path);
|
|
144
|
-
artifactContents.set(meta.path, content);
|
|
145
|
-
}
|
|
146
|
-
catch { }
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch { }
|
|
150
|
-
return { artifacts, artifactContents };
|
|
151
|
-
}
|
|
152
|
-
async function writeProjectBundle(bundle, outputPath, format) {
|
|
132
|
+
async function writeProjectBundle(bundle, outputPath, format, preserve) {
|
|
153
133
|
if (format === "json") {
|
|
154
134
|
writeFileSync(outputPath + ".json", JSON.stringify(bundle, null, 2), "utf-8");
|
|
155
135
|
return;
|
|
156
136
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
await
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
function displayName(name, uuid) {
|
|
173
|
-
const trimmed = (name ?? "").trim();
|
|
174
|
-
if (trimmed)
|
|
175
|
-
return trimmed;
|
|
176
|
-
return `<unnamed ${uuid}>`;
|
|
137
|
+
// Files / git mode: rebuild the project tree from scratch, but route through
|
|
138
|
+
// replaceWithPreserve so locally-added files (INDEX.md at project + nested
|
|
139
|
+
// conversation scope, hand-written notes, etc.) survive the re-sync.
|
|
140
|
+
await replaceWithPreserve({
|
|
141
|
+
outputPath,
|
|
142
|
+
writeFresh: async () => {
|
|
143
|
+
await exportToGit(bundle, outputPath);
|
|
144
|
+
if (format === "files") {
|
|
145
|
+
const { rmSync } = await import("node:fs");
|
|
146
|
+
rmSync(resolve(outputPath, ".git"), { recursive: true, force: true });
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
preserveGlobs: preserve,
|
|
150
|
+
});
|
|
177
151
|
}
|
|
178
152
|
function buildProjectReadme(project, docCount, convCount) {
|
|
179
153
|
const lines = [];
|
|
180
|
-
lines.push(`# ${project.name}`);
|
|
154
|
+
lines.push(`# ${displayName(project.name, project.uuid)}`);
|
|
181
155
|
lines.push("");
|
|
182
156
|
if (project.description) {
|
|
183
157
|
lines.push(project.description);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-all.js","sourceRoot":"","sources":["../../src/commands/export-all.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"export-all.js","sourceRoot":"","sources":["../../src/commands/export-all.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,mBAAmB,GAGpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC;KACtD,WAAW,CAAC,wGAAwG,CAAC;KACrH,MAAM,CAAC,eAAe,EAAE,4CAA4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K,CAAC,CAAC;IAClB,KAAK,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IAChE,KAAK,CAAC,IAAI,CAAC,6DAA6D,CAAC,CAAC;IAC1E,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;IACvF,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,aAAa,SAyFtB,CAAC"}
|
package/dist/commands/export.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
-
import { syncConversation, } from "@infinite-room-labs/claudesync-core";
|
|
3
|
+
import { syncConversation, safeSlug, displayName, } from "@infinite-room-labs/claudesync-core";
|
|
4
4
|
import { createClient, resolveOrgId } from "../utils.js";
|
|
5
5
|
export const exportCommand = new Command("export")
|
|
6
6
|
.description("Export a conversation to a git repository, file tree, or JSON")
|
|
@@ -13,6 +13,7 @@ export const exportCommand = new Command("export")
|
|
|
13
13
|
.option("--skip-artifacts", "Skip downloading artifacts (faster)")
|
|
14
14
|
.option("--skip-existing", "Skip if the output directory already exists (no change detection)")
|
|
15
15
|
.option("--skip-same", "Skip if the conversation is unchanged since the last sync. Mutually exclusive with --skip-existing.")
|
|
16
|
+
.option("--preserve <glob>", "Glob (POSIX, relative to the conversation dir) of locally-added files to keep across re-syncs in --format files. Repeatable. CHANGELOG.md is always preserved.", (value, previous = []) => previous.concat(value), [])
|
|
16
17
|
.action(async (conversationId, options) => {
|
|
17
18
|
if (options.skipSame && options.skipExisting) {
|
|
18
19
|
console.error("error: --skip-same and --skip-existing are mutually exclusive");
|
|
@@ -29,13 +30,9 @@ export const exportCommand = new Command("export")
|
|
|
29
30
|
process.exit(1);
|
|
30
31
|
return; // unreachable after process.exit, helps the type narrower
|
|
31
32
|
}
|
|
32
|
-
const slug = (summary.name
|
|
33
|
-
.toLowerCase()
|
|
34
|
-
.replace(/[^a-z0-9]+/g, "-")
|
|
35
|
-
.replace(/^-|-$/g, "")
|
|
36
|
-
.slice(0, 60) || `unnamed-${summary.uuid}`;
|
|
33
|
+
const slug = safeSlug(summary.name, summary.uuid);
|
|
37
34
|
const outputPath = resolve(options.output ?? `./${slug}`);
|
|
38
|
-
const label = (summary.name
|
|
35
|
+
const label = displayName(summary.name, summary.uuid);
|
|
39
36
|
console.log(`Syncing conversation ${label} (${summary.uuid})`);
|
|
40
37
|
console.log(` Format: ${options.format}`);
|
|
41
38
|
console.log(` Output: ${outputPath}`);
|
|
@@ -46,6 +43,7 @@ export const exportCommand = new Command("export")
|
|
|
46
43
|
skipSame: options.skipSame,
|
|
47
44
|
skipExisting: options.skipExisting,
|
|
48
45
|
skipArtifacts: options.skipArtifacts,
|
|
46
|
+
preserve: options.preserve,
|
|
49
47
|
});
|
|
50
48
|
switch (result.action) {
|
|
51
49
|
case "skipped":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE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xE,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CAAC;IAEH,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;QACtB,KAAK,SAAS;YACZ,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAChD,MAAM;QACR,KAAK,kBAAkB;YACrB,OAAO,CAAC,GAAG,CAAC,qBAAqB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAClD,MAAM;QACR,KAAK,MAAM;YACT,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;YACxC,MAAM;QACR,KAAK,aAAa;YAChB,OAAO,CAAC,GAAG,CACT,4BAA4B,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,GAAG,CACrF,CAAC;YACF,MAAM;IACV,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infinite-room-labs/claudesync-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/InfiniteRoomLabs/claudesync"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"ink": "^6.8.0",
|
|
19
19
|
"ink-text-input": "^6.0.0",
|
|
20
20
|
"react": "^19.2.4",
|
|
21
|
-
"@infinite-room-labs/claudesync-core": "0.
|
|
21
|
+
"@infinite-room-labs/claudesync-core": "0.5.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^25.5.0",
|