@hex4c59/pi-ext-config-sync 0.1.0 → 0.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.1 - 2026-11-17
4
+
5
+ ### Changed
6
+
7
+ - 内置设备码登录的 OAuth App Client ID,新设备直接运行 `/sync login`,无需逐台执行 `/sync setup`。
8
+ - 已保存的自定义 Client ID 继续优先;`config.json` 中为空或只有空白时回退到内置值。
9
+ - README 更正 npm 包加载方式:`settings.json` 中的 `packages` 由 Pi 在启动或 `/reload` 时安装。
10
+
3
11
  ## 0.1.0 - 2026-11-17
4
12
 
5
13
  ### Added
package/README.md CHANGED
@@ -22,29 +22,26 @@ pi install npm:@hex4c59/pi-ext-config-sync
22
22
  pi -e ./config-sync
23
23
  ```
24
24
 
25
- ## 准备 GitHub OAuth App
25
+ ## GitHub 登录与 OAuth App
26
26
 
27
- 每个使用者需要自己的 OAuth App,扩展不内置客户端凭据。
27
+ 扩展内置了设备码登录使用的 OAuth App Client ID,安装后直接登录即可,不需要逐台配置。
28
+
29
+ Client ID 是公开标识,不是密钥,只用于向 GitHub 发起设备码申请;设备码流程不需要 Client Secret。所有使用本扩展的设备共用同一个 OAuth App,因此每台设备只需登录,不需要再次设置。
30
+
31
+ 如需改用自己创建的 OAuth App:
28
32
 
29
33
  1. 打开 GitHub 的 `Settings` → `Developer settings` → `OAuth Apps` → `New OAuth App`。
30
34
  2. 填写名称、主页地址和 `Authorization callback URL`。设备码流程不使用回调地址,填一个可访问的地址即可,例如 `https://github.com`。
31
35
  3. 创建后在应用设置里勾选 `Enable Device Flow`。
32
- 4. 复制 `Client ID`。不需要 `Client Secret`。
33
-
34
- 然后在 Pi 中保存客户端 ID:
35
-
36
- ```text
37
- /sync setup <client-id>
38
- ```
36
+ 4. 复制 `Client ID`,在 Pi 中运行 `/sync setup <client-id>`。
39
37
 
40
- 客户端 ID 不是密钥,会写入本机的 `~/.pi/agent/config-sync/config.json`。
38
+ 自定义值写入本机的 `~/.pi/agent/config-sync/config.json`,优先于内置默认值。`config.json` 中留空时回退到内置值。
41
39
 
42
40
  ## 第一次使用
43
41
 
44
42
  第一台设备:
45
43
 
46
44
  ```text
47
- /sync setup <client-id>
48
45
  /sync login
49
46
  /sync push
50
47
  ```
@@ -56,7 +53,6 @@ pi -e ./config-sync
56
53
  第二台设备:
57
54
 
58
55
  ```text
59
- /sync setup <client-id>
60
56
  /sync login
61
57
  /sync pull
62
58
  ```
@@ -79,7 +75,7 @@ pi -e ./config-sync
79
75
  | 命令 | 作用 |
80
76
  | --- | --- |
81
77
  | `/sync help` | 显示命令列表 |
82
- | `/sync setup <client-id>` | 保存 GitHub OAuth App 的 Client ID |
78
+ | `/sync setup <client-id>` | 可选:保存自建 GitHub OAuth App 的 Client ID,覆盖内置值 |
83
79
  | `/sync login` | 开始 GitHub 设备码登录 |
84
80
  | `/sync logout` | 删除 `auth.json` 中的 GitHub 令牌 |
85
81
  | `/sync status` | 显示登录、仓库、分支、自动拉取和上次同步信息,不联网 |
@@ -175,7 +171,7 @@ pi -e ./config-sync
175
171
  | 路径 | 内容 |
176
172
  | --- | --- |
177
173
  | `~/.pi/agent/auth.json` | GitHub 令牌,provider ID 为 `config-sync` |
178
- | `~/.pi/agent/config-sync/config.json` | 客户端 ID、仓库、分支和过滤设置 |
174
+ | `~/.pi/agent/config-sync/config.json` | 客户端 ID(可省略,回退内置值)、仓库、分支和过滤设置 |
179
175
  | `~/.pi/agent/config-sync/state.json` | 设备 ID、登录名、上次同步提交与文件哈希 |
180
176
  | `~/.pi/agent/config-sync/backups/<时间>/agent/` | 拉取覆盖或删除前的本机文件 |
181
177
 
@@ -207,7 +203,7 @@ pi -e ./config-sync
207
203
  - 只支持 GitHub,不支持 Google 登录或其他代码托管服务。
208
204
  - 没有后台定时同步;推送需要手动执行,自动拉取只在启动时运行一次。
209
205
  - 不同设备的 `settings.json` 中如果包含本机包路径或其他设备相关字段,需要自行加入 `localSettingsKeys`,否则会互相覆盖。
210
- - 同步的是配置内容,不安装 npm 包;`settings.json` 里的 `packages` 记录会随配置同步,但对应包仍需在每台设备上安装。
206
+ - `settings.json` 里的 `packages` 记录会随配置同步,Pi 在启动或 `/reload` 时安装其中的 npm 包。若旧设备推送时 `packages` 里还没有 config-sync 自己,新设备拉取后会在下次重启时丢失本扩展;推送前先在旧设备执行 `pi install npm:@hex4c59/pi-ext-config-sync`,让这条记录进入远端。
211
207
  - 不合并非 JSON 文件,不处理符号链接,不保留远端文件的历史版本。
212
208
  - 目前没有用于多个配置档案或多个 GitHub 账号的切换功能。
213
209
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hex4c59/pi-ext-config-sync",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Sync Pi configuration and encrypted credentials through a private GitHub repository.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/files.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  AGENT_PATH_PREFIX,
8
8
  AUTH_PROVIDER_ID,
9
9
  CONFIG_SYNC_DIR,
10
+ DEFAULT_CLIENT_ID,
10
11
  DEFAULT_EXCLUDE_AUTH_PROVIDERS,
11
12
  DEFAULT_LOCAL_SETTINGS_KEYS,
12
13
  SyncError,
@@ -151,7 +152,7 @@ export function authPath(agentDir: string): string {
151
152
  export function defaultConfig(): SyncConfig {
152
153
  return {
153
154
  version: 1,
154
- clientId: "",
155
+ clientId: DEFAULT_CLIENT_ID,
155
156
  repo: "",
156
157
  branch: "",
157
158
  autoPull: false,
@@ -172,7 +173,8 @@ export async function loadConfig(agentDir: string): Promise<SyncConfig> {
172
173
  }
173
174
  return {
174
175
  version: 1,
175
- clientId: readString(raw.clientId, defaults.clientId, "clientId"),
176
+ clientId: readString(raw.clientId, defaults.clientId, "clientId").trim()
177
+ || defaults.clientId,
176
178
  repo: readString(raw.repo, defaults.repo, "repo"),
177
179
  branch: readString(raw.branch, defaults.branch, "branch"),
178
180
  autoPull: readBoolean(raw.autoPull, defaults.autoPull, "autoPull"),
package/src/types.ts CHANGED
@@ -5,6 +5,9 @@ export const AGENT_PATH_PREFIX = "agent/";
5
5
  export const AUTH_PROVIDER_ID = "config-sync";
6
6
  export const MANIFEST_TOOL = "pi-config-sync";
7
7
 
8
+ // 设备码登录使用的公开 OAuth App 客户端 ID;它不是密钥,可用 /sync setup 覆盖为自建应用。
9
+ export const DEFAULT_CLIENT_ID = "Ov23li4a5umOHbBMy9uY";
10
+
8
11
  export const DEFAULT_LOCAL_SETTINGS_KEYS = [
9
12
  "shellPath",
10
13
  "lsp",