@alfe.ai/openclaw-sync 0.0.15 → 0.0.17
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/dist/cli/index.cjs +45 -109
- package/dist/cli/index.js +45 -109
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +4 -11
- package/dist/index.d.cts +798 -190
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +798 -190
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/plugin.d.cts +16 -18
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.ts +16 -18
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin2.cjs +111 -104
- package/dist/plugin2.js +110 -103
- package/dist/plugin2.js.map +1 -1
- package/dist/sync-engine.cjs +263 -344
- package/dist/sync-engine.js +226 -318
- package/dist/sync-engine.js.map +1 -1
- package/package.json +2 -1
- package/dist/ignore.cjs +0 -120
- package/dist/ignore.js +0 -74
- package/dist/ignore.js.map +0 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -1,76 +1,58 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require("../ignore.cjs");
|
|
3
2
|
const require_sync_engine = require("../sync-engine.cjs");
|
|
4
3
|
let node_fs_promises = require("node:fs/promises");
|
|
5
4
|
let node_path = require("node:path");
|
|
5
|
+
let _alfe_ai_config = require("@alfe.ai/config");
|
|
6
|
+
let _alfe_ai_agent_api_client = require("@alfe.ai/agent-api-client");
|
|
7
|
+
let commander = require("commander");
|
|
6
8
|
//#region src/cli/index.ts
|
|
7
9
|
/**
|
|
8
|
-
* AlfeSync CLI — alfesync command-line interface.
|
|
10
|
+
* AlfeSync CLI — `alfesync` command-line interface.
|
|
11
|
+
*
|
|
12
|
+
* Credentials come from `~/.alfe/config.toml` (set up via `alfe login`).
|
|
13
|
+
* No separate sync init step is required.
|
|
9
14
|
*
|
|
10
15
|
* Commands:
|
|
11
|
-
*
|
|
16
|
+
* register - Idempotently register this agent with the sync service
|
|
12
17
|
* push - Push local changes to remote
|
|
13
18
|
* pull - Pull remote changes to local
|
|
14
19
|
* status - Show sync status and pending changes
|
|
15
20
|
* conflicts - List conflict files
|
|
16
|
-
* history - Show version history for a file
|
|
17
21
|
* restore - Restore agent workspace from remote
|
|
18
22
|
*/
|
|
19
|
-
|
|
23
|
+
function buildClient() {
|
|
24
|
+
if (!(0, _alfe_ai_config.configExists)()) throw new Error("Alfe not configured — run `alfe login` first.");
|
|
25
|
+
const config = (0, _alfe_ai_config.resolveConfig)();
|
|
26
|
+
return {
|
|
27
|
+
client: new _alfe_ai_agent_api_client.AgentApiClient({
|
|
28
|
+
apiKey: config.apiKey,
|
|
29
|
+
apiUrl: config.apiUrl
|
|
30
|
+
}),
|
|
31
|
+
workspacePath: config.workspacePath
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const program = new commander.Command();
|
|
20
35
|
program.name("alfesync").description("AlfeSync — agent workspace backup and sync").version("1.0.0");
|
|
21
|
-
program.command("
|
|
22
|
-
const workspacePath = (0, node_path.resolve)(".");
|
|
23
|
-
if (require_sync_engine.isInitialized(workspacePath)) {
|
|
24
|
-
console.log("AlfeSync is already initialized in this workspace.");
|
|
25
|
-
const existing = await require_sync_engine.readConfig(workspacePath);
|
|
26
|
-
if (existing) {
|
|
27
|
-
console.log(` Agent: ${existing.agentId}`);
|
|
28
|
-
console.log(` API: ${existing.apiUrl}`);
|
|
29
|
-
}
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const token = opts.token ?? process.env.ALFESYNC_TOKEN;
|
|
33
|
-
const apiUrl = opts.apiUrl ?? process.env.ALFESYNC_API_URL ?? "https://api.alfe.ai";
|
|
34
|
-
const agentId = opts.agentId ?? process.env.ALFESYNC_AGENT_ID;
|
|
35
|
-
if (!token) {
|
|
36
|
-
console.error("Error: --token is required (or set ALFESYNC_TOKEN env var)");
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
if (!agentId) {
|
|
40
|
-
console.error("Error: --agent-id is required (or set ALFESYNC_AGENT_ID env var)");
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
console.log("Registering agent with AlfeSync...");
|
|
44
|
-
const client = require_sync_engine.createApiClient({
|
|
45
|
-
apiUrl,
|
|
46
|
-
token,
|
|
47
|
-
agentId
|
|
48
|
-
});
|
|
36
|
+
program.command("register").description("Register this agent with the sync service (idempotent)").option("-n, --display-name <name>", "Display name for the agent").action(async (opts) => {
|
|
49
37
|
try {
|
|
50
|
-
const
|
|
51
|
-
await
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
workspacePath,
|
|
56
|
-
apiUrl
|
|
57
|
-
});
|
|
58
|
-
console.log("✓ AlfeSync initialized!");
|
|
59
|
-
console.log(` Agent: ${agentId}`);
|
|
60
|
-
console.log(` Org: ${orgId}`);
|
|
61
|
-
console.log(` API: ${apiUrl}`);
|
|
38
|
+
const { client, workspacePath } = buildClient();
|
|
39
|
+
const result = await client.syncRegister(opts.displayName ? { displayName: opts.displayName } : void 0);
|
|
40
|
+
console.log("✓ Agent registered with AlfeSync");
|
|
41
|
+
console.log(` Agent: ${result.agent.agentId}`);
|
|
42
|
+
console.log(` Org: ${result.agent.tenantId}`);
|
|
62
43
|
console.log(` Workspace: ${workspacePath}`);
|
|
63
|
-
console.log("");
|
|
64
|
-
console.log("Run 'alfesync push' to sync your workspace.");
|
|
65
44
|
} catch (err) {
|
|
66
|
-
console.error(
|
|
45
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
67
46
|
process.exit(1);
|
|
68
47
|
}
|
|
69
48
|
});
|
|
70
49
|
program.command("push").description("Push local changes to remote").option("-q, --quiet", "Suppress output").option("-f, --filter <prefix>", "Only push files matching this prefix").action(async (opts) => {
|
|
71
|
-
const workspacePath = (0, node_path.resolve)(".");
|
|
72
50
|
try {
|
|
73
|
-
|
|
51
|
+
const { client, workspacePath } = buildClient();
|
|
52
|
+
await require_sync_engine.createSyncEngine({
|
|
53
|
+
workspacePath,
|
|
54
|
+
client
|
|
55
|
+
}).push(void 0, {
|
|
74
56
|
quiet: opts.quiet,
|
|
75
57
|
filter: opts.filter
|
|
76
58
|
});
|
|
@@ -80,38 +62,30 @@ program.command("push").description("Push local changes to remote").option("-q,
|
|
|
80
62
|
}
|
|
81
63
|
});
|
|
82
64
|
program.command("pull").description("Pull remote changes to local").option("-q, --quiet", "Suppress output").action(async (opts) => {
|
|
83
|
-
const workspacePath = (0, node_path.resolve)(".");
|
|
84
65
|
try {
|
|
85
|
-
|
|
66
|
+
const { client, workspacePath } = buildClient();
|
|
67
|
+
await require_sync_engine.createSyncEngine({
|
|
68
|
+
workspacePath,
|
|
69
|
+
client
|
|
70
|
+
}).pull({ quiet: opts.quiet });
|
|
86
71
|
} catch (err) {
|
|
87
72
|
console.error(err instanceof Error ? err.message : String(err));
|
|
88
73
|
process.exit(1);
|
|
89
74
|
}
|
|
90
75
|
});
|
|
91
76
|
program.command("status").description("Show sync status and pending changes").action(async () => {
|
|
92
|
-
const workspacePath = (0, node_path.resolve)(".");
|
|
93
77
|
try {
|
|
94
|
-
const
|
|
95
|
-
if (!config) {
|
|
96
|
-
console.log("AlfeSync not initialized. Run: alfesync init");
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const client = require_sync_engine.createApiClient({
|
|
100
|
-
apiUrl: config.apiUrl,
|
|
101
|
-
token: config.token,
|
|
102
|
-
agentId: config.agentId
|
|
103
|
-
});
|
|
78
|
+
const { client, workspacePath } = buildClient();
|
|
104
79
|
const [localManifest, remoteManifest, stats] = await Promise.all([
|
|
105
80
|
require_sync_engine.readManifest(workspacePath),
|
|
106
|
-
client.
|
|
107
|
-
client.
|
|
81
|
+
client.syncGetManifest(),
|
|
82
|
+
client.syncGetStats()
|
|
108
83
|
]);
|
|
109
84
|
const diff = require_sync_engine.diffManifests(localManifest, remoteManifest);
|
|
110
85
|
console.log("AlfeSync Status");
|
|
111
86
|
console.log("═══════════════");
|
|
112
|
-
console.log(`Agent: ${
|
|
87
|
+
console.log(`Agent: ${stats.agentId}`);
|
|
113
88
|
console.log(`Workspace: ${workspacePath}`);
|
|
114
|
-
console.log(`API: ${config.apiUrl}`);
|
|
115
89
|
console.log("");
|
|
116
90
|
console.log("Storage:");
|
|
117
91
|
console.log(` Standard: ${formatBytes(stats.standardBytes)}`);
|
|
@@ -146,8 +120,8 @@ program.command("status").description("Show sync status and pending changes").ac
|
|
|
146
120
|
}
|
|
147
121
|
});
|
|
148
122
|
program.command("conflicts").description("List conflict files in the workspace").action(async () => {
|
|
149
|
-
const workspacePath = (0, node_path.resolve)(".");
|
|
150
123
|
try {
|
|
124
|
+
const { workspacePath } = buildClient();
|
|
151
125
|
const conflicts = await findConflictFiles(workspacePath);
|
|
152
126
|
if (conflicts.length === 0) {
|
|
153
127
|
console.log("No conflict files found.");
|
|
@@ -160,42 +134,9 @@ program.command("conflicts").description("List conflict files in the workspace")
|
|
|
160
134
|
process.exit(1);
|
|
161
135
|
}
|
|
162
136
|
});
|
|
163
|
-
program.command("history <file>").description("Show version history for a file").action(async (file) => {
|
|
164
|
-
const workspacePath = (0, node_path.resolve)(".");
|
|
165
|
-
try {
|
|
166
|
-
const config = await require_sync_engine.readConfig(workspacePath);
|
|
167
|
-
if (!config) {
|
|
168
|
-
console.log("AlfeSync not initialized. Run: alfesync init");
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
const versions = await require_sync_engine.createApiClient({
|
|
172
|
-
apiUrl: config.apiUrl,
|
|
173
|
-
token: config.token,
|
|
174
|
-
agentId: config.agentId
|
|
175
|
-
}).getFileHistory(file);
|
|
176
|
-
if (versions.length === 0) {
|
|
177
|
-
console.log(`No history found for: ${file}`);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
console.log(`Version history for: ${file}`);
|
|
181
|
-
console.log("─".repeat(60));
|
|
182
|
-
for (const v of versions) {
|
|
183
|
-
const marker = v.isLatest ? " (latest)" : "";
|
|
184
|
-
console.log(` ${v.lastModified} ${formatBytes(v.size)} ${v.versionId.slice(0, 12)}${marker}`);
|
|
185
|
-
}
|
|
186
|
-
} catch (err) {
|
|
187
|
-
console.error(err instanceof Error ? err.message : String(err));
|
|
188
|
-
process.exit(1);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
137
|
program.command("restore").description("Restore agent workspace from remote backup").option("-m, --mode <mode>", "Restore mode: full, active, memory", "full").option("-q, --quiet", "Suppress output").action(async (opts) => {
|
|
192
|
-
const workspacePath = (0, node_path.resolve)(".");
|
|
193
138
|
try {
|
|
194
|
-
const
|
|
195
|
-
if (!config) {
|
|
196
|
-
console.log("AlfeSync not initialized. Run: alfesync init");
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
139
|
+
const { client, workspacePath } = buildClient();
|
|
199
140
|
const mode = opts.mode;
|
|
200
141
|
if (![
|
|
201
142
|
"full",
|
|
@@ -205,13 +146,8 @@ program.command("restore").description("Restore agent workspace from remote back
|
|
|
205
146
|
console.error("Error: mode must be full, active, or memory");
|
|
206
147
|
process.exit(1);
|
|
207
148
|
}
|
|
208
|
-
const client = require_sync_engine.createApiClient({
|
|
209
|
-
apiUrl: config.apiUrl,
|
|
210
|
-
token: config.token,
|
|
211
|
-
agentId: config.agentId
|
|
212
|
-
});
|
|
213
149
|
if (!opts.quiet) console.log(`Restoring workspace (mode: ${mode})...`);
|
|
214
|
-
const bundle = await client.
|
|
150
|
+
const bundle = await client.syncReconstruct({ mode });
|
|
215
151
|
if (!opts.quiet) console.log(`Downloading ${String(bundle.fileCount)} files (${formatBytes(bundle.totalSize)})...`);
|
|
216
152
|
const { writeFile, mkdir } = await import("node:fs/promises");
|
|
217
153
|
const { dirname } = await import("node:path");
|
|
@@ -240,7 +176,7 @@ async function findConflictFiles(dir, base) {
|
|
|
240
176
|
const results = [];
|
|
241
177
|
const entries = await (0, node_fs_promises.readdir)(dir, { withFileTypes: true });
|
|
242
178
|
for (const entry of entries) {
|
|
243
|
-
if (entry.name === "node_modules" || entry.name === ".git"
|
|
179
|
+
if (entry.name === "node_modules" || entry.name === ".git") continue;
|
|
244
180
|
const fullPath = (0, node_path.join)(dir, entry.name);
|
|
245
181
|
const relativePath = base ? (0, node_path.join)(base, entry.name) : entry.name;
|
|
246
182
|
if (entry.isDirectory()) {
|
package/dist/cli/index.js
CHANGED
|
@@ -1,76 +1,58 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { l as diffManifests, t as createSyncEngine, u as readManifest } from "../sync-engine.js";
|
|
3
3
|
import { readdir } from "node:fs/promises";
|
|
4
|
-
import { join
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { configExists, resolveConfig } from "@alfe.ai/config";
|
|
6
|
+
import { AgentApiClient } from "@alfe.ai/agent-api-client";
|
|
5
7
|
import { Command } from "commander";
|
|
6
8
|
//#region src/cli/index.ts
|
|
7
9
|
/**
|
|
8
|
-
* AlfeSync CLI — alfesync command-line interface.
|
|
10
|
+
* AlfeSync CLI — `alfesync` command-line interface.
|
|
11
|
+
*
|
|
12
|
+
* Credentials come from `~/.alfe/config.toml` (set up via `alfe login`).
|
|
13
|
+
* No separate sync init step is required.
|
|
9
14
|
*
|
|
10
15
|
* Commands:
|
|
11
|
-
*
|
|
16
|
+
* register - Idempotently register this agent with the sync service
|
|
12
17
|
* push - Push local changes to remote
|
|
13
18
|
* pull - Pull remote changes to local
|
|
14
19
|
* status - Show sync status and pending changes
|
|
15
20
|
* conflicts - List conflict files
|
|
16
|
-
* history - Show version history for a file
|
|
17
21
|
* restore - Restore agent workspace from remote
|
|
18
22
|
*/
|
|
23
|
+
function buildClient() {
|
|
24
|
+
if (!configExists()) throw new Error("Alfe not configured — run `alfe login` first.");
|
|
25
|
+
const config = resolveConfig();
|
|
26
|
+
return {
|
|
27
|
+
client: new AgentApiClient({
|
|
28
|
+
apiKey: config.apiKey,
|
|
29
|
+
apiUrl: config.apiUrl
|
|
30
|
+
}),
|
|
31
|
+
workspacePath: config.workspacePath
|
|
32
|
+
};
|
|
33
|
+
}
|
|
19
34
|
const program = new Command();
|
|
20
35
|
program.name("alfesync").description("AlfeSync — agent workspace backup and sync").version("1.0.0");
|
|
21
|
-
program.command("
|
|
22
|
-
const workspacePath = resolve(".");
|
|
23
|
-
if (isInitialized(workspacePath)) {
|
|
24
|
-
console.log("AlfeSync is already initialized in this workspace.");
|
|
25
|
-
const existing = await readConfig(workspacePath);
|
|
26
|
-
if (existing) {
|
|
27
|
-
console.log(` Agent: ${existing.agentId}`);
|
|
28
|
-
console.log(` API: ${existing.apiUrl}`);
|
|
29
|
-
}
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const token = opts.token ?? process.env.ALFESYNC_TOKEN;
|
|
33
|
-
const apiUrl = opts.apiUrl ?? process.env.ALFESYNC_API_URL ?? "https://api.alfe.ai";
|
|
34
|
-
const agentId = opts.agentId ?? process.env.ALFESYNC_AGENT_ID;
|
|
35
|
-
if (!token) {
|
|
36
|
-
console.error("Error: --token is required (or set ALFESYNC_TOKEN env var)");
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
if (!agentId) {
|
|
40
|
-
console.error("Error: --agent-id is required (or set ALFESYNC_AGENT_ID env var)");
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
console.log("Registering agent with AlfeSync...");
|
|
44
|
-
const client = createApiClient({
|
|
45
|
-
apiUrl,
|
|
46
|
-
token,
|
|
47
|
-
agentId
|
|
48
|
-
});
|
|
36
|
+
program.command("register").description("Register this agent with the sync service (idempotent)").option("-n, --display-name <name>", "Display name for the agent").action(async (opts) => {
|
|
49
37
|
try {
|
|
50
|
-
const
|
|
51
|
-
await
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
workspacePath,
|
|
56
|
-
apiUrl
|
|
57
|
-
});
|
|
58
|
-
console.log("✓ AlfeSync initialized!");
|
|
59
|
-
console.log(` Agent: ${agentId}`);
|
|
60
|
-
console.log(` Org: ${orgId}`);
|
|
61
|
-
console.log(` API: ${apiUrl}`);
|
|
38
|
+
const { client, workspacePath } = buildClient();
|
|
39
|
+
const result = await client.syncRegister(opts.displayName ? { displayName: opts.displayName } : void 0);
|
|
40
|
+
console.log("✓ Agent registered with AlfeSync");
|
|
41
|
+
console.log(` Agent: ${result.agent.agentId}`);
|
|
42
|
+
console.log(` Org: ${result.agent.tenantId}`);
|
|
62
43
|
console.log(` Workspace: ${workspacePath}`);
|
|
63
|
-
console.log("");
|
|
64
|
-
console.log("Run 'alfesync push' to sync your workspace.");
|
|
65
44
|
} catch (err) {
|
|
66
|
-
console.error(
|
|
45
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
67
46
|
process.exit(1);
|
|
68
47
|
}
|
|
69
48
|
});
|
|
70
49
|
program.command("push").description("Push local changes to remote").option("-q, --quiet", "Suppress output").option("-f, --filter <prefix>", "Only push files matching this prefix").action(async (opts) => {
|
|
71
|
-
const workspacePath = resolve(".");
|
|
72
50
|
try {
|
|
73
|
-
|
|
51
|
+
const { client, workspacePath } = buildClient();
|
|
52
|
+
await createSyncEngine({
|
|
53
|
+
workspacePath,
|
|
54
|
+
client
|
|
55
|
+
}).push(void 0, {
|
|
74
56
|
quiet: opts.quiet,
|
|
75
57
|
filter: opts.filter
|
|
76
58
|
});
|
|
@@ -80,38 +62,30 @@ program.command("push").description("Push local changes to remote").option("-q,
|
|
|
80
62
|
}
|
|
81
63
|
});
|
|
82
64
|
program.command("pull").description("Pull remote changes to local").option("-q, --quiet", "Suppress output").action(async (opts) => {
|
|
83
|
-
const workspacePath = resolve(".");
|
|
84
65
|
try {
|
|
85
|
-
|
|
66
|
+
const { client, workspacePath } = buildClient();
|
|
67
|
+
await createSyncEngine({
|
|
68
|
+
workspacePath,
|
|
69
|
+
client
|
|
70
|
+
}).pull({ quiet: opts.quiet });
|
|
86
71
|
} catch (err) {
|
|
87
72
|
console.error(err instanceof Error ? err.message : String(err));
|
|
88
73
|
process.exit(1);
|
|
89
74
|
}
|
|
90
75
|
});
|
|
91
76
|
program.command("status").description("Show sync status and pending changes").action(async () => {
|
|
92
|
-
const workspacePath = resolve(".");
|
|
93
77
|
try {
|
|
94
|
-
const
|
|
95
|
-
if (!config) {
|
|
96
|
-
console.log("AlfeSync not initialized. Run: alfesync init");
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const client = createApiClient({
|
|
100
|
-
apiUrl: config.apiUrl,
|
|
101
|
-
token: config.token,
|
|
102
|
-
agentId: config.agentId
|
|
103
|
-
});
|
|
78
|
+
const { client, workspacePath } = buildClient();
|
|
104
79
|
const [localManifest, remoteManifest, stats] = await Promise.all([
|
|
105
80
|
readManifest(workspacePath),
|
|
106
|
-
client.
|
|
107
|
-
client.
|
|
81
|
+
client.syncGetManifest(),
|
|
82
|
+
client.syncGetStats()
|
|
108
83
|
]);
|
|
109
84
|
const diff = diffManifests(localManifest, remoteManifest);
|
|
110
85
|
console.log("AlfeSync Status");
|
|
111
86
|
console.log("═══════════════");
|
|
112
|
-
console.log(`Agent: ${
|
|
87
|
+
console.log(`Agent: ${stats.agentId}`);
|
|
113
88
|
console.log(`Workspace: ${workspacePath}`);
|
|
114
|
-
console.log(`API: ${config.apiUrl}`);
|
|
115
89
|
console.log("");
|
|
116
90
|
console.log("Storage:");
|
|
117
91
|
console.log(` Standard: ${formatBytes(stats.standardBytes)}`);
|
|
@@ -146,8 +120,8 @@ program.command("status").description("Show sync status and pending changes").ac
|
|
|
146
120
|
}
|
|
147
121
|
});
|
|
148
122
|
program.command("conflicts").description("List conflict files in the workspace").action(async () => {
|
|
149
|
-
const workspacePath = resolve(".");
|
|
150
123
|
try {
|
|
124
|
+
const { workspacePath } = buildClient();
|
|
151
125
|
const conflicts = await findConflictFiles(workspacePath);
|
|
152
126
|
if (conflicts.length === 0) {
|
|
153
127
|
console.log("No conflict files found.");
|
|
@@ -160,42 +134,9 @@ program.command("conflicts").description("List conflict files in the workspace")
|
|
|
160
134
|
process.exit(1);
|
|
161
135
|
}
|
|
162
136
|
});
|
|
163
|
-
program.command("history <file>").description("Show version history for a file").action(async (file) => {
|
|
164
|
-
const workspacePath = resolve(".");
|
|
165
|
-
try {
|
|
166
|
-
const config = await readConfig(workspacePath);
|
|
167
|
-
if (!config) {
|
|
168
|
-
console.log("AlfeSync not initialized. Run: alfesync init");
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
const versions = await createApiClient({
|
|
172
|
-
apiUrl: config.apiUrl,
|
|
173
|
-
token: config.token,
|
|
174
|
-
agentId: config.agentId
|
|
175
|
-
}).getFileHistory(file);
|
|
176
|
-
if (versions.length === 0) {
|
|
177
|
-
console.log(`No history found for: ${file}`);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
console.log(`Version history for: ${file}`);
|
|
181
|
-
console.log("─".repeat(60));
|
|
182
|
-
for (const v of versions) {
|
|
183
|
-
const marker = v.isLatest ? " (latest)" : "";
|
|
184
|
-
console.log(` ${v.lastModified} ${formatBytes(v.size)} ${v.versionId.slice(0, 12)}${marker}`);
|
|
185
|
-
}
|
|
186
|
-
} catch (err) {
|
|
187
|
-
console.error(err instanceof Error ? err.message : String(err));
|
|
188
|
-
process.exit(1);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
137
|
program.command("restore").description("Restore agent workspace from remote backup").option("-m, --mode <mode>", "Restore mode: full, active, memory", "full").option("-q, --quiet", "Suppress output").action(async (opts) => {
|
|
192
|
-
const workspacePath = resolve(".");
|
|
193
138
|
try {
|
|
194
|
-
const
|
|
195
|
-
if (!config) {
|
|
196
|
-
console.log("AlfeSync not initialized. Run: alfesync init");
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
139
|
+
const { client, workspacePath } = buildClient();
|
|
199
140
|
const mode = opts.mode;
|
|
200
141
|
if (![
|
|
201
142
|
"full",
|
|
@@ -205,13 +146,8 @@ program.command("restore").description("Restore agent workspace from remote back
|
|
|
205
146
|
console.error("Error: mode must be full, active, or memory");
|
|
206
147
|
process.exit(1);
|
|
207
148
|
}
|
|
208
|
-
const client = createApiClient({
|
|
209
|
-
apiUrl: config.apiUrl,
|
|
210
|
-
token: config.token,
|
|
211
|
-
agentId: config.agentId
|
|
212
|
-
});
|
|
213
149
|
if (!opts.quiet) console.log(`Restoring workspace (mode: ${mode})...`);
|
|
214
|
-
const bundle = await client.
|
|
150
|
+
const bundle = await client.syncReconstruct({ mode });
|
|
215
151
|
if (!opts.quiet) console.log(`Downloading ${String(bundle.fileCount)} files (${formatBytes(bundle.totalSize)})...`);
|
|
216
152
|
const { writeFile, mkdir } = await import("node:fs/promises");
|
|
217
153
|
const { dirname } = await import("node:path");
|
|
@@ -240,7 +176,7 @@ async function findConflictFiles(dir, base) {
|
|
|
240
176
|
const results = [];
|
|
241
177
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
242
178
|
for (const entry of entries) {
|
|
243
|
-
if (entry.name === "node_modules" || entry.name === ".git"
|
|
179
|
+
if (entry.name === "node_modules" || entry.name === ".git") continue;
|
|
244
180
|
const fullPath = join(dir, entry.name);
|
|
245
181
|
const relativePath = base ? join(base, entry.name) : entry.name;
|
|
246
182
|
if (entry.isDirectory()) {
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * AlfeSync CLI — alfesync command-line interface.\n *\n * Commands:\n * init - Initialize AlfeSync in a workspace\n * push - Push local changes to remote\n * pull - Pull remote changes to local\n * status - Show sync status and pending changes\n * conflicts - List conflict files\n * history - Show version history for a file\n * restore - Restore agent workspace from remote\n */\n\nimport { Command } from \"commander\";\nimport { resolve, join } from \"node:path\";\nimport { readdir } from \"node:fs/promises\";\nimport {\n readConfig,\n writeConfig,\n isInitialized,\n} from \"../config.js\";\nimport { createApiClient } from \"../api-client.js\";\nimport { createSyncEngine } from \"../sync-engine.js\";\nimport { readManifest, diffManifests } from \"../manifest.js\";\n\n\nconst program = new Command();\n\nprogram\n .name(\"alfesync\")\n .description(\"AlfeSync — agent workspace backup and sync\")\n .version(\"1.0.0\");\n\n// ─── init ─────────────────────────────────────────────────\n\nprogram\n .command(\"init\")\n .description(\"Initialize AlfeSync in the current workspace\")\n .option(\"-t, --token <token>\", \"Alfe Connect bearer token\")\n .option(\"-u, --api-url <url>\", \"AlfeSync API URL\", \"https://api.alfe.ai\")\n .option(\"-a, --agent-id <id>\", \"Agent ID for this workspace\")\n .option(\"-n, --display-name <name>\", \"Display name for the agent\")\n .action(async (opts: { token?: string; apiUrl?: string; agentId?: string; displayName?: string }) => {\n const workspacePath = resolve(\".\");\n\n if (isInitialized(workspacePath)) {\n console.log(\"AlfeSync is already initialized in this workspace.\");\n const existing = await readConfig(workspacePath);\n if (existing) {\n console.log(` Agent: ${existing.agentId}`);\n console.log(` API: ${existing.apiUrl}`);\n }\n return;\n }\n\n const token = opts.token ?? process.env.ALFESYNC_TOKEN;\n const apiUrl = opts.apiUrl ?? process.env.ALFESYNC_API_URL ?? \"https://api.alfe.ai\";\n const agentId = opts.agentId ?? process.env.ALFESYNC_AGENT_ID;\n\n if (!token) {\n console.error(\n \"Error: --token is required (or set ALFESYNC_TOKEN env var)\",\n );\n process.exit(1);\n }\n if (!agentId) {\n console.error(\n \"Error: --agent-id is required (or set ALFESYNC_AGENT_ID env var)\",\n );\n process.exit(1);\n }\n\n // Register agent with the API\n console.log(\"Registering agent with AlfeSync...\");\n const client = createApiClient({ apiUrl, token, agentId });\n\n try {\n const result = await client.registerAgent(opts.displayName ?? agentId);\n const orgId = result.agent.orgId;\n\n await writeConfig({\n agentId,\n orgId,\n token,\n workspacePath,\n apiUrl,\n });\n\n console.log(\"✓ AlfeSync initialized!\");\n console.log(` Agent: ${agentId}`);\n console.log(` Org: ${orgId}`);\n console.log(` API: ${apiUrl}`);\n console.log(` Workspace: ${workspacePath}`);\n console.log(\"\");\n console.log(\"Run 'alfesync push' to sync your workspace.\");\n } catch (err) {\n console.error(\n \"Failed to register agent:\",\n err instanceof Error ? err.message : String(err),\n );\n process.exit(1);\n }\n });\n\n// ─── push ─────────────────────────────────────────────────\n\nprogram\n .command(\"push\")\n .description(\"Push local changes to remote\")\n .option(\"-q, --quiet\", \"Suppress output\")\n .option(\"-f, --filter <prefix>\", \"Only push files matching this prefix\")\n .action(async (opts: { quiet?: boolean; filter?: string }) => {\n const workspacePath = resolve(\".\");\n\n try {\n const engine = await createSyncEngine(workspacePath);\n await engine.push(undefined, {\n quiet: opts.quiet,\n filter: opts.filter,\n });\n } catch (err) {\n console.error(\n err instanceof Error ? err.message : String(err),\n );\n process.exit(1);\n }\n });\n\n// ─── pull ─────────────────────────────────────────────────\n\nprogram\n .command(\"pull\")\n .description(\"Pull remote changes to local\")\n .option(\"-q, --quiet\", \"Suppress output\")\n .action(async (opts: { quiet?: boolean }) => {\n const workspacePath = resolve(\".\");\n\n try {\n const engine = await createSyncEngine(workspacePath);\n await engine.pull({ quiet: opts.quiet });\n } catch (err) {\n console.error(\n err instanceof Error ? err.message : String(err),\n );\n process.exit(1);\n }\n });\n\n// ─── status ───────────────────────────────────────────────\n\nprogram\n .command(\"status\")\n .description(\"Show sync status and pending changes\")\n .action(async () => {\n const workspacePath = resolve(\".\");\n\n try {\n const config = await readConfig(workspacePath);\n if (!config) {\n console.log(\"AlfeSync not initialized. Run: alfesync init\");\n return;\n }\n\n const client = createApiClient({\n apiUrl: config.apiUrl,\n token: config.token,\n agentId: config.agentId,\n });\n\n const [localManifest, remoteManifest, stats] = await Promise.all([\n readManifest(workspacePath),\n client.getManifest(),\n client.getStats(),\n ]);\n\n const diff = diffManifests(localManifest, remoteManifest);\n\n console.log(\"AlfeSync Status\");\n console.log(\"═══════════════\");\n console.log(`Agent: ${config.agentId}`);\n console.log(`Workspace: ${workspacePath}`);\n console.log(`API: ${config.apiUrl}`);\n console.log(\"\");\n\n console.log(\"Storage:\");\n console.log(\n ` Standard: ${formatBytes(stats.standardBytes)}`,\n );\n console.log(\n ` Glacier IR: ${formatBytes(stats.glacierBytes)}`,\n );\n console.log(` Total files: ${String(stats.fileCount)}`);\n console.log(\n ` Last sync: ${stats.lastSyncAt ?? \"never\"}`,\n );\n console.log(\"\");\n\n console.log(\"Pending Changes:\");\n console.log(` To push: ${String(diff.toPush.length)}`);\n console.log(` To pull: ${String(diff.toPull.length)}`);\n console.log(` Conflicts: ${String(diff.conflicts.length)}`);\n\n if (diff.toPush.length > 0) {\n console.log(\"\");\n console.log(\"Files to push:\");\n for (const p of diff.toPush.slice(0, 20)) {\n console.log(` ↑ ${p}`);\n }\n if (diff.toPush.length > 20) {\n console.log(` ... and ${String(diff.toPush.length - 20)} more`);\n }\n }\n\n if (diff.toPull.length > 0) {\n console.log(\"\");\n console.log(\"Files to pull:\");\n for (const p of diff.toPull.slice(0, 20)) {\n console.log(` ↓ ${p}`);\n }\n if (diff.toPull.length > 20) {\n console.log(` ... and ${String(diff.toPull.length - 20)} more`);\n }\n }\n\n if (diff.conflicts.length > 0) {\n console.log(\"\");\n console.log(\"Conflicts:\");\n for (const p of diff.conflicts) {\n console.log(` ⚡ ${p}`);\n }\n }\n } catch (err) {\n console.error(\n err instanceof Error ? err.message : String(err),\n );\n process.exit(1);\n }\n });\n\n// ─── conflicts ────────────────────────────────────────────\n\nprogram\n .command(\"conflicts\")\n .description(\"List conflict files in the workspace\")\n .action(async () => {\n const workspacePath = resolve(\".\");\n\n try {\n const conflicts = await findConflictFiles(workspacePath);\n if (conflicts.length === 0) {\n console.log(\"No conflict files found.\");\n return;\n }\n\n console.log(`Found ${String(conflicts.length)} conflict file(s):`);\n for (const f of conflicts) {\n console.log(` ⚡ ${f}`);\n }\n } catch (err) {\n console.error(\n err instanceof Error ? err.message : String(err),\n );\n process.exit(1);\n }\n });\n\n// ─── history ──────────────────────────────────────────────\n\nprogram\n .command(\"history <file>\")\n .description(\"Show version history for a file\")\n .action(async (file: string) => {\n const workspacePath = resolve(\".\");\n\n try {\n const config = await readConfig(workspacePath);\n if (!config) {\n console.log(\"AlfeSync not initialized. Run: alfesync init\");\n return;\n }\n\n const client = createApiClient({\n apiUrl: config.apiUrl,\n token: config.token,\n agentId: config.agentId,\n });\n\n const versions = await client.getFileHistory(file);\n if (versions.length === 0) {\n console.log(`No history found for: ${file}`);\n return;\n }\n\n console.log(`Version history for: ${file}`);\n console.log(\"─\".repeat(60));\n for (const v of versions) {\n const marker = v.isLatest ? \" (latest)\" : \"\";\n console.log(\n ` ${v.lastModified} ${formatBytes(v.size)} ${v.versionId.slice(0, 12)}${marker}`,\n );\n }\n } catch (err) {\n console.error(\n err instanceof Error ? err.message : String(err),\n );\n process.exit(1);\n }\n });\n\n// ─── restore ──────────────────────────────────────────────\n\nprogram\n .command(\"restore\")\n .description(\"Restore agent workspace from remote backup\")\n .option(\n \"-m, --mode <mode>\",\n \"Restore mode: full, active, memory\",\n \"full\",\n )\n .option(\"-q, --quiet\", \"Suppress output\")\n .action(async (opts: { mode?: string; quiet?: boolean }) => {\n const workspacePath = resolve(\".\");\n\n try {\n const config = await readConfig(workspacePath);\n if (!config) {\n console.log(\"AlfeSync not initialized. Run: alfesync init\");\n return;\n }\n\n const mode = opts.mode as \"full\" | \"active\" | \"memory\";\n if (![\"full\", \"active\", \"memory\"].includes(mode)) {\n console.error(\"Error: mode must be full, active, or memory\");\n process.exit(1);\n }\n\n const client = createApiClient({\n apiUrl: config.apiUrl,\n token: config.token,\n agentId: config.agentId,\n });\n\n if (!opts.quiet) {\n console.log(`Restoring workspace (mode: ${mode})...`);\n }\n\n const bundle = await client.reconstruct(mode);\n\n if (!opts.quiet) {\n console.log(\n `Downloading ${String(bundle.fileCount)} files (${formatBytes(bundle.totalSize)})...`,\n );\n }\n\n // Download each file from the bundle's presigned URLs\n const { writeFile, mkdir } = await import(\"node:fs/promises\");\n const { dirname } = await import(\"node:path\");\n\n let downloaded = 0;\n let errors = 0;\n\n for (const file of bundle.files) {\n try {\n const response = await fetch(file.url);\n if (!response.ok) {\n throw new Error(`HTTP ${String(response.status)}`);\n }\n\n const buffer = Buffer.from(await response.arrayBuffer());\n const absolutePath = join(workspacePath, file.path);\n await mkdir(dirname(absolutePath), { recursive: true });\n await writeFile(absolutePath, buffer);\n\n downloaded++;\n if (!opts.quiet) {\n console.log(\n ` ↓ ${file.path} (${formatBytes(file.size)})`,\n );\n }\n } catch (err) {\n errors++;\n if (!opts.quiet) {\n console.error(\n ` ✗ ${file.path}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n }\n\n if (!opts.quiet) {\n console.log(\n `\\nRestore complete: ${String(downloaded)} files downloaded, ${String(errors)} errors.`,\n );\n }\n } catch (err) {\n console.error(\n err instanceof Error ? err.message : String(err),\n );\n process.exit(1);\n }\n });\n\n// ─── Helpers ──────────────────────────────────────────────\n\nasync function findConflictFiles(\n dir: string,\n base?: string,\n): Promise<string[]> {\n const results: string[] = [];\n const entries = await readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n if (\n entry.name === \"node_modules\" ||\n entry.name === \".git\" ||\n entry.name === \".alfesync\"\n ) {\n continue;\n }\n\n const fullPath = join(dir, entry.name);\n const relativePath = base\n ? join(base, entry.name)\n : entry.name;\n\n if (entry.isDirectory()) {\n const sub = await findConflictFiles(fullPath, relativePath);\n results.push(...sub);\n } else if (entry.name.includes(\".conflict-\")) {\n results.push(relativePath);\n }\n }\n\n return results;\n}\n\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) return `${String(bytes)} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n if (bytes < 1024 * 1024 * 1024)\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;\n}\n\n// ─── Run ──────────────────────────────────────────────────\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAM,UAAU,IAAI,SAAS;AAE7B,QACG,KAAK,WAAW,CAChB,YAAY,6C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Q,EAAE,CAAC;AAC7D,KAAI,QAAQ,OAAO,OAAO,KACxB,QAAO,IAAI,SAAS,OAAO,OAAO,QAAQ,EAAE,CAAC;AAC/C,QAAO,IAAI,SAAS,OAAO,OAAO,OAAO,QAAQ,EAAE,CAAC;;AAKtD,QAAQ,OAAO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["resolveAlfeConfig"],"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * AlfeSync CLI — `alfesync` command-line interface.\n *\n * Credentials come from `~/.alfe/config.toml` (set up via `alfe login`).\n * No separate sync init step is required.\n *\n * Commands:\n * register - Idempotently register this agent with the sync service\n * push - Push local changes to remote\n * pull - Pull remote changes to local\n * status - Show sync status and pending changes\n * conflicts - List conflict files\n * restore - Restore agent workspace from remote\n */\n\nimport { Command } from \"commander\";\nimport { join } from \"node:path\";\nimport { readdir } from \"node:fs/promises\";\nimport { AgentApiClient } from \"@alfe.ai/agent-api-client\";\nimport { resolveConfig as resolveAlfeConfig, configExists } from \"@alfe.ai/config\";\nimport { createSyncEngine } from \"../sync-engine.js\";\nimport { readManifest, diffManifests } from \"../manifest.js\";\n\nfunction buildClient(): { client: AgentApiClient; workspacePath: string } {\n if (!configExists()) {\n throw new Error(\"Alfe not configured — run `alfe login` first.\");\n }\n const config = resolveAlfeConfig();\n return {\n client: new AgentApiClient({ apiKey: config.apiKey, apiUrl: config.apiUrl }),\n workspacePath: config.workspacePath,\n };\n}\n\nconst program = new Command();\n\nprogram\n .name(\"alfesync\")\n .description(\"AlfeSync — agent workspace backup and sync\")\n .version(\"1.0.0\");\n\n// ─── register ─────────────────────────────────────────────\n\nprogram\n .command(\"register\")\n .description(\"Register this agent with the sync service (idempotent)\")\n .option(\"-n, --display-name <name>\", \"Display name for the agent\")\n .action(async (opts: { displayName?: string }) => {\n try {\n const { client, workspacePath } = buildClient();\n const result = await client.syncRegister(\n opts.displayName ? { displayName: opts.displayName } : undefined,\n );\n console.log(\"✓ Agent registered with AlfeSync\");\n console.log(` Agent: ${result.agent.agentId}`);\n console.log(` Org: ${result.agent.tenantId}`);\n console.log(` Workspace: ${workspacePath}`);\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\n// ─── push ─────────────────────────────────────────────────\n\nprogram\n .command(\"push\")\n .description(\"Push local changes to remote\")\n .option(\"-q, --quiet\", \"Suppress output\")\n .option(\"-f, --filter <prefix>\", \"Only push files matching this prefix\")\n .action(async (opts: { quiet?: boolean; filter?: string }) => {\n try {\n const { client, workspacePath } = buildClient();\n const engine = createSyncEngine({ workspacePath, client });\n await engine.push(undefined, { quiet: opts.quiet, filter: opts.filter });\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\n// ─── pull ─────────────────────────────────────────────────\n\nprogram\n .command(\"pull\")\n .description(\"Pull remote changes to local\")\n .option(\"-q, --quiet\", \"Suppress output\")\n .action(async (opts: { quiet?: boolean }) => {\n try {\n const { client, workspacePath } = buildClient();\n const engine = createSyncEngine({ workspacePath, client });\n await engine.pull({ quiet: opts.quiet });\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\n// ─── status ───────────────────────────────────────────────\n\nprogram\n .command(\"status\")\n .description(\"Show sync status and pending changes\")\n .action(async () => {\n try {\n const { client, workspacePath } = buildClient();\n const [localManifest, remoteManifest, stats] = await Promise.all([\n readManifest(workspacePath),\n client.syncGetManifest(),\n client.syncGetStats(),\n ]);\n const diff = diffManifests(localManifest, remoteManifest);\n\n console.log(\"AlfeSync Status\");\n console.log(\"═══════════════\");\n console.log(`Agent: ${stats.agentId}`);\n console.log(`Workspace: ${workspacePath}`);\n console.log(\"\");\n\n console.log(\"Storage:\");\n console.log(` Standard: ${formatBytes(stats.standardBytes)}`);\n console.log(` Glacier IR: ${formatBytes(stats.glacierBytes)}`);\n console.log(` Total files: ${String(stats.fileCount)}`);\n console.log(` Last sync: ${stats.lastSyncAt ?? \"never\"}`);\n console.log(\"\");\n\n console.log(\"Pending Changes:\");\n console.log(` To push: ${String(diff.toPush.length)}`);\n console.log(` To pull: ${String(diff.toPull.length)}`);\n console.log(` Conflicts: ${String(diff.conflicts.length)}`);\n\n if (diff.toPush.length > 0) {\n console.log(\"\");\n console.log(\"Files to push:\");\n for (const p of diff.toPush.slice(0, 20)) console.log(` ↑ ${p}`);\n if (diff.toPush.length > 20) {\n console.log(` ... and ${String(diff.toPush.length - 20)} more`);\n }\n }\n\n if (diff.toPull.length > 0) {\n console.log(\"\");\n console.log(\"Files to pull:\");\n for (const p of diff.toPull.slice(0, 20)) console.log(` ↓ ${p}`);\n if (diff.toPull.length > 20) {\n console.log(` ... and ${String(diff.toPull.length - 20)} more`);\n }\n }\n\n if (diff.conflicts.length > 0) {\n console.log(\"\");\n console.log(\"Conflicts:\");\n for (const p of diff.conflicts) console.log(` ⚡ ${p}`);\n }\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\n// ─── conflicts ────────────────────────────────────────────\n\nprogram\n .command(\"conflicts\")\n .description(\"List conflict files in the workspace\")\n .action(async () => {\n try {\n const { workspacePath } = buildClient();\n const conflicts = await findConflictFiles(workspacePath);\n if (conflicts.length === 0) {\n console.log(\"No conflict files found.\");\n return;\n }\n console.log(`Found ${String(conflicts.length)} conflict file(s):`);\n for (const f of conflicts) console.log(` ⚡ ${f}`);\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\n// ─── restore ──────────────────────────────────────────────\n\nprogram\n .command(\"restore\")\n .description(\"Restore agent workspace from remote backup\")\n .option(\"-m, --mode <mode>\", \"Restore mode: full, active, memory\", \"full\")\n .option(\"-q, --quiet\", \"Suppress output\")\n .action(async (opts: { mode?: string; quiet?: boolean }) => {\n try {\n const { client, workspacePath } = buildClient();\n const mode = opts.mode as \"full\" | \"active\" | \"memory\";\n if (![\"full\", \"active\", \"memory\"].includes(mode)) {\n console.error(\"Error: mode must be full, active, or memory\");\n process.exit(1);\n }\n\n if (!opts.quiet) console.log(`Restoring workspace (mode: ${mode})...`);\n const bundle = await client.syncReconstruct({ mode });\n\n if (!opts.quiet) {\n console.log(\n `Downloading ${String(bundle.fileCount)} files (${formatBytes(bundle.totalSize)})...`,\n );\n }\n\n const { writeFile, mkdir } = await import(\"node:fs/promises\");\n const { dirname } = await import(\"node:path\");\n\n let downloaded = 0;\n let errors = 0;\n for (const file of bundle.files) {\n try {\n const response = await fetch(file.url);\n if (!response.ok) throw new Error(`HTTP ${String(response.status)}`);\n const buffer = Buffer.from(await response.arrayBuffer());\n const absolutePath = join(workspacePath, file.path);\n await mkdir(dirname(absolutePath), { recursive: true });\n await writeFile(absolutePath, buffer);\n downloaded++;\n if (!opts.quiet) console.log(` ↓ ${file.path} (${formatBytes(file.size)})`);\n } catch (err) {\n errors++;\n if (!opts.quiet) {\n console.error(\n ` ✗ ${file.path}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n }\n\n if (!opts.quiet) {\n console.log(\n `\\nRestore complete: ${String(downloaded)} files downloaded, ${String(errors)} errors.`,\n );\n }\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\n// ─── Helpers ──────────────────────────────────────────────\n\nasync function findConflictFiles(dir: string, base?: string): Promise<string[]> {\n const results: string[] = [];\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.name === \"node_modules\" || entry.name === \".git\") continue;\n const fullPath = join(dir, entry.name);\n const relativePath = base ? join(base, entry.name) : entry.name;\n if (entry.isDirectory()) {\n const sub = await findConflictFiles(fullPath, relativePath);\n results.push(...sub);\n } else if (entry.name.includes(\".conflict-\")) {\n results.push(relativePath);\n }\n }\n return results;\n}\n\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) return `${String(bytes)} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;\n}\n\n// ─── Run ──────────────────────────────────────────────────\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAS,cAAiE;AACxE,KAAI,CAAC,cAAc,CACjB,OAAM,IAAI,MAAM,gDAAgD;CAElE,MAAM,SAASA,eAAmB;AAClC,QAAO;EACL,QAAQ,IAAI,eAAe;GAAE,QAAQ,OAAO;GAAQ,QAAQ,OAAO;GAAQ,CAAC;EAC5E,eAAe,OAAO;EACvB;;AAGH,MAAM,UAAU,IAAI,SAAS;AAE7B,QACG,KAAK,WAAW,CAChB,YAAY,6CAA6C,CACzD,QAAQ,QAAQ;AAInB,QACG,QAAQ,WAAW,CACnB,YAAY,yDAAyD,CACrE,OAAO,6BAA6B,6BAA6B,CACjE,OAAO,OAAO,SAAmC;AAChD,KAAI;EACF,MAAM,EAAE,QAAQ,kBAAkB,aAAa;EAC/C,MAAM,SAAS,MAAM,OAAO,aAC1B,KAAK,cAAc,EAAE,aAAa,KAAK,aAAa,GAAG,KAAA,EACxD;AACD,UAAQ,IAAI,mCAAmC;AAC/C,UAAQ,IAAI,gBAAgB,OAAO,MAAM,UAAU;AACnD,UAAQ,IAAI,gBAAgB,OAAO,MAAM,WAAW;AACpD,UAAQ,IAAI,gBAAgB,gBAAgB;UACrC,KAAK;AACZ,UAAQ,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI,CAAC;AAC/D,UAAQ,KAAK,EAAE;;EAEjB;AAIJ,QACG,QAAQ,OAAO,CACf,YAAY,+BAA+B,CAC3C,OAAO,eAAe,kBAAkB,CACxC,OAAO,yBAAyB,uCAAuC,CACvE,OAAO,OAAO,SAA+C;AAC5D,KAAI;EACF,MAAM,EAAE,QAAQ,kBAAkB,aAAa;AAE/C,QADe,iBAAiB;GAAE;GAAe;GAAQ,CAAC,CAC7C,KAAK,KAAA,GAAW;G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AAQ,OAAO"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_ignore = require("./ignore.cjs");
|
|
3
2
|
const require_sync_engine = require("./sync-engine.cjs");
|
|
4
3
|
const require_plugin = require("./plugin2.cjs");
|
|
5
4
|
exports.computeFileHash = require_sync_engine.computeFileHash;
|
|
6
|
-
exports.configDir = require_sync_engine.configDir;
|
|
7
|
-
exports.configPath = require_sync_engine.configPath;
|
|
8
|
-
exports.createApiClient = require_sync_engine.createApiClient;
|
|
9
5
|
exports.createSharedSyncEngine = require_plugin.createSharedSyncEngine;
|
|
10
6
|
exports.createSyncEngine = require_sync_engine.createSyncEngine;
|
|
11
7
|
exports.diffManifests = require_sync_engine.diffManifests;
|
|
12
8
|
exports.downloadFiles = require_sync_engine.downloadFiles;
|
|
13
|
-
exports.filterIgnored =
|
|
14
|
-
exports.
|
|
15
|
-
exports.loadIgnorePatterns = require_ignore.loadIgnorePatterns;
|
|
9
|
+
exports.filterIgnored = require_sync_engine.filterIgnored;
|
|
10
|
+
exports.loadIgnorePatterns = require_sync_engine.loadIgnorePatterns;
|
|
16
11
|
exports.plugin = require_plugin.plugin;
|
|
17
|
-
exports.readConfig = require_sync_engine.readConfig;
|
|
18
12
|
exports.readManifest = require_sync_engine.readManifest;
|
|
19
13
|
exports.removeManifestEntry = require_sync_engine.removeManifestEntry;
|
|
20
|
-
exports.
|
|
21
|
-
exports.shouldIgnore = require_ignore.shouldIgnore;
|
|
14
|
+
exports.shouldIgnore = require_sync_engine.shouldIgnore;
|
|
22
15
|
exports.startWatcher = require_plugin.startWatcher;
|
|
23
16
|
exports.updateManifestEntry = require_sync_engine.updateManifestEntry;
|
|
24
17
|
exports.uploadFiles = require_sync_engine.uploadFiles;
|
|
25
|
-
exports.
|
|
18
|
+
exports.withRetry = require_sync_engine.withRetry;
|
|
26
19
|
exports.writeManifest = require_sync_engine.writeManifest;
|