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