openclaw-sync-assistant 0.0.2 → 0.0.3

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/index.js CHANGED
@@ -21,108 +21,112 @@ module.exports = {
21
21
 
22
22
  // 在 OpenClaw 插件 API 中注册 CLI 命令
23
23
  if (context.registerCommand) {
24
- context.registerCommand("sync.setup", async () => {
25
- console.log("\n");
26
- intro(pc.bgCyan(pc.black(" OpenClaw Sync Assistant Setup ")));
24
+ context.registerCommand({
25
+ command: "sync.setup",
26
+ description: "Initialize OpenClaw Sync Assistant configuration",
27
+ action: async () => {
28
+ console.log("\n");
29
+ intro(pc.bgCyan(pc.black(" OpenClaw Sync Assistant Setup ")));
27
30
 
28
- const syncMethod = await select({
29
- message: "请选择同步方式 (Sync Method):",
30
- options: [
31
- { value: "p2p", label: "点对点直连 (P2P - 基于 Hyperswarm)" },
32
- { value: "github", label: "GitHub 托管 (基于 Git 仓库)" },
33
- ],
34
- });
35
-
36
- const syncMode = await select({
37
- message: "请选择同步模式 (Sync Mode):",
38
- options: [
39
- {
40
- value: "decentralized",
41
- label:
42
- "去中心模式 (Decentralized - 适合多设备对等同步,随时随地拉取)",
43
- },
44
- {
45
- value: "centralized",
46
- label:
47
- "中心模式 (Centralized - 适合以某台设备或仓库为主的主从同步)",
48
- },
49
- ],
50
- });
51
-
52
- let syncSecret = "";
53
- let githubRepo = "";
54
-
55
- if (syncMethod === "p2p") {
56
- syncSecret = await text({
57
- message:
58
- "请输入您的同步密钥 (Sync Secret, 用于生成 P2P 发现的 Topic 和加密数据):",
59
- placeholder: "例如: my-super-secret-key",
60
- validate(value) {
61
- if (value.length === 0) return "同步密钥不能为空!";
62
- },
31
+ const syncMethod = await select({
32
+ message: "请选择同步方式 (Sync Method):",
33
+ options: [
34
+ { value: "p2p", label: "点对点直连 (P2P - 基于 Hyperswarm)" },
35
+ { value: "github", label: "GitHub 托管 (基于 Git 仓库)" },
36
+ ],
63
37
  });
64
- } else if (syncMethod === "github") {
65
- githubRepo = await text({
66
- message: "请输入用于同步的 GitHub 仓库地址:",
67
- placeholder: "例如: https://github.com/your-name/sync-repo.git",
68
- validate(value) {
69
- if (value.length === 0) return "GitHub 仓库地址不能为空!";
70
- },
38
+
39
+ const syncMode = await select({
40
+ message: "请选择同步模式 (Sync Mode):",
41
+ options: [
42
+ {
43
+ value: "decentralized",
44
+ label:
45
+ "去中心模式 (Decentralized - 适合多设备对等同步,随时随地拉取)",
46
+ },
47
+ {
48
+ value: "centralized",
49
+ label:
50
+ "中心模式 (Centralized - 适合以某台设备或仓库为主的主从同步)",
51
+ },
52
+ ],
71
53
  });
72
- }
73
54
 
74
- const syncItems = await multiselect({
75
- message: "请选择要同步的内容:",
76
- options: [
77
- { value: "Config", label: "Config", hint: "OpenClaw 核心配置" },
78
- { value: "Auth", label: "Auth", hint: "认证信息" },
79
- { value: "Sessions", label: "Sessions", hint: "会话记录" },
80
- { value: "Workspace", label: "Workspace", hint: "工作区状态" },
81
- ],
82
- required: true,
83
- });
55
+ let syncSecret = "";
56
+ let githubRepo = "";
84
57
 
85
- const s = spinner();
86
- s.start(
87
- `正在初始化 [${syncMethod.toUpperCase()} - ${syncMode}] 同步服务...`,
88
- );
58
+ if (syncMethod === "p2p") {
59
+ syncSecret = await text({
60
+ message:
61
+ "请输入您的同步密钥 (Sync Secret, 用于生成 P2P 发现的 Topic 和加密数据):",
62
+ placeholder: "例如: my-super-secret-key",
63
+ validate(value) {
64
+ if (value.length === 0) return "同步密钥不能为空!";
65
+ },
66
+ });
67
+ } else if (syncMethod === "github") {
68
+ githubRepo = await text({
69
+ message: "请输入用于同步的 GitHub 仓库地址:",
70
+ placeholder: "例如: https://github.com/your-name/sync-repo.git",
71
+ validate(value) {
72
+ if (value.length === 0) return "GitHub 仓库地址不能为空!";
73
+ },
74
+ });
75
+ }
89
76
 
90
- // 模拟保存配置 (实际应使用 context.api.config.update 等方法)
91
- if (context.api.config && context.api.config.update) {
92
- await context.api.config.update(
93
- "openclaw-sync-assistant.syncMethod",
94
- syncMethod,
95
- );
96
- await context.api.config.update(
97
- "openclaw-sync-assistant.syncMode",
98
- syncMode,
77
+ const syncItems = await multiselect({
78
+ message: "请选择要同步的内容:",
79
+ options: [
80
+ { value: "Config", label: "Config", hint: "OpenClaw 核心配置" },
81
+ { value: "Auth", label: "Auth", hint: "认证信息" },
82
+ { value: "Sessions", label: "Sessions", hint: "会话记录" },
83
+ { value: "Workspace", label: "Workspace", hint: "工作区状态" },
84
+ ],
85
+ required: true,
86
+ });
87
+
88
+ const s = spinner();
89
+ s.start(
90
+ `正在初始化 [${syncMethod.toUpperCase()} - ${syncMode}] 同步服务...`,
99
91
  );
100
- if (syncSecret)
92
+
93
+ // 模拟保存配置 (实际应使用 context.api.config.update 等方法)
94
+ if (context.api.config && context.api.config.update) {
101
95
  await context.api.config.update(
102
- "openclaw-sync-assistant.syncSecret",
103
- syncSecret,
96
+ "openclaw-sync-assistant.syncMethod",
97
+ syncMethod,
104
98
  );
105
- if (githubRepo)
106
99
  await context.api.config.update(
107
- "openclaw-sync-assistant.githubRepo",
108
- githubRepo,
100
+ "openclaw-sync-assistant.syncMode",
101
+ syncMode,
109
102
  );
110
- await context.api.config.update(
111
- "openclaw-sync-assistant.syncItems",
112
- syncItems,
113
- );
114
- }
103
+ if (syncSecret)
104
+ await context.api.config.update(
105
+ "openclaw-sync-assistant.syncSecret",
106
+ syncSecret,
107
+ );
108
+ if (githubRepo)
109
+ await context.api.config.update(
110
+ "openclaw-sync-assistant.githubRepo",
111
+ githubRepo,
112
+ );
113
+ await context.api.config.update(
114
+ "openclaw-sync-assistant.syncItems",
115
+ syncItems,
116
+ );
117
+ }
115
118
 
116
- // 模拟启动相关服务等耗时操作
117
- await new Promise((resolve) => setTimeout(resolve, 1500));
119
+ // 模拟启动相关服务等耗时操作
120
+ await new Promise((resolve) => setTimeout(resolve, 1500));
118
121
 
119
- s.stop("配置已保存!");
122
+ s.stop("配置已保存!");
120
123
 
121
- outro(
122
- pc.green(
123
- `✔ 配置完成!同步助手后台服务已按 [${syncMethod.toUpperCase()} - ${syncMode}] 接管状态同步。`,
124
- ),
125
- );
124
+ outro(
125
+ pc.green(
126
+ `✔ 配置完成!同步助手后台服务已按 [${syncMethod.toUpperCase()} - ${syncMode}] 接管状态同步。`,
127
+ ),
128
+ );
129
+ },
126
130
  });
127
131
  } else if (process.env.DEBUG === "openclaw:sync") {
128
132
  console.log(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "openclaw-sync-assistant",
3
3
  "name": "openclaw-sync-assistant",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "description": "OpenClaw Sync Assistant Plugin",
6
6
  "configSchema": {
7
7
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-sync-assistant",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "An OpenClaw plugin for P2P file and data synchronization using Hyperswarm and Hyperdrive ecosystem.",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",