@aiti-ai/aiti-backup 0.1.11 → 0.1.13
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 +2 -3
- package/README.zh-CN.md +2 -3
- package/icon.svg +1 -1
- package/package.json +11 -2
- package/tools/deploy.mjs +2 -2
- package/deploy-commit.mjs +0 -52
- package/reload-instances.mjs +0 -60
package/README.md
CHANGED
|
@@ -6,10 +6,9 @@ English · [简体中文](./README.zh-CN.md)
|
|
|
6
6
|
|
|
7
7
|
## About aiti
|
|
8
8
|
|
|
9
|
-
This package is part of the **aiti** ecosystem — a personal AI development workbench powered by [pi](https://pi.dev): **aiti-agent** (a self-hosted web workbench built on the open-source [pi-web](https://github.com/aiti-ai/
|
|
9
|
+
This package is part of the **aiti** ecosystem — a personal AI development workbench powered by [pi](https://pi.dev): **aiti-agent** (a self-hosted web workbench built on the open-source [pi-web](https://github.com/aiti-ai/aiti-ai)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
|
|
10
10
|
|
|
11
|
-
- Workbench
|
|
12
|
-
- Ecosystem monorepo: <https://github.com/aiti-ai/aiti-ai>
|
|
11
|
+
- Workbench & monorepo: <https://github.com/aiti-ai/aiti-ai>
|
|
13
12
|
- Site: <https://aiti.pw>
|
|
14
13
|
|
|
15
14
|
## What it does
|
package/README.zh-CN.md
CHANGED
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
## 关于 aiti
|
|
8
8
|
|
|
9
|
-
本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/
|
|
9
|
+
本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/aiti-ai) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
- 生态仓库: <https://github.com/aiti-ai/aiti-ai>
|
|
11
|
+
- 工作台 / 生态仓库(aiti-agent,基于 pi-web): <https://github.com/aiti-ai/aiti-ai>
|
|
13
12
|
- 官网: <https://aiti.pw>
|
|
14
13
|
|
|
15
14
|
## 功能定位
|
package/icon.svg
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/></svg>
|
package/package.json
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiti-ai/aiti-backup",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Snapshot backup for large pi-web state data — hard-link incremental snapshots, out-of-process execution, crash-safe temp files, keepCount rotation. Complements aiti-configs, which versions small configs in git.",
|
|
5
|
+
"displayNameI18n": {
|
|
6
|
+
"en": "Data Backup (snapshots)"
|
|
7
|
+
},
|
|
8
|
+
"descriptionI18n": {
|
|
9
|
+
"zh-CN": "pi-web 数据备份扩展(state 层快照:硬链接增量 + 保留轮转 + 源严格只读;与 aiti-configs 互补)"
|
|
10
|
+
},
|
|
5
11
|
"type": "module",
|
|
6
12
|
"scripts": {
|
|
7
13
|
"deploy": "node tools/deploy.mjs"
|
|
8
14
|
},
|
|
9
15
|
"aitiExtProtocol": "1.0",
|
|
10
16
|
"license": "MIT",
|
|
11
|
-
"contentHash": "
|
|
17
|
+
"contentHash": "c750d3870a3e983b",
|
|
12
18
|
"repository": {
|
|
13
19
|
"type": "git",
|
|
14
20
|
"url": "git+https://github.com/aiti-ai/aiti-ai.git",
|
|
@@ -17,5 +23,8 @@
|
|
|
17
23
|
"homepage": "https://github.com/aiti-ai/aiti-ai#readme",
|
|
18
24
|
"bugs": {
|
|
19
25
|
"url": "https://github.com/aiti-ai/aiti-ai/issues"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@aiti-ai/ext-shared": "^0.1.22"
|
|
20
29
|
}
|
|
21
30
|
}
|
package/tools/deploy.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { copyFileSync, mkdirSync, cpSync } from "node:fs";
|
|
|
10
10
|
import { resolve } from "node:path";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
12
12
|
import { homedir } from "node:os";
|
|
13
|
-
import { deployCommit } from "
|
|
13
|
+
import { deployCommit } from "@aiti-ai/ext-shared/deploy-commit";
|
|
14
14
|
|
|
15
15
|
const root = resolve(import.meta.dirname, ".."); // pi-web-ext/aiti-backup
|
|
16
16
|
const targets = [
|
|
@@ -37,7 +37,7 @@ deployCommit({ repo: extRepo, name: "aiti-backup", paths: ["aiti-backup"], log:
|
|
|
37
37
|
|
|
38
38
|
// 双实例热重载(允许失败,不影响退出码)
|
|
39
39
|
try {
|
|
40
|
-
const { reloadInstances } = await import("
|
|
40
|
+
const { reloadInstances } = await import("@aiti-ai/ext-shared/reload-instances");
|
|
41
41
|
await reloadInstances();
|
|
42
42
|
} catch (e) {
|
|
43
43
|
console.log("[deploy] 自动 reload 未执行(" + String((e && e.message) || e) + ")— 需手动 POST /api/extensions/reload");
|
package/deploy-commit.mjs
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* deploy 脚本共享「部署状态 commit」助手(pi-web-ext 各扩展 tools/deploy.mjs 统一用)。
|
|
3
|
-
*
|
|
4
|
-
* 背景(2026-08-30 排障,session 0cc6ad47 op264):重复部署同内容时
|
|
5
|
-
* `git add -A && git commit` 以 "nothing to commit" exit 1,而 stdio:"ignore" 吞掉
|
|
6
|
-
* stderr,输出「提交失败(忽略):Command failed: …」假报警(msg-smart 实证);
|
|
7
|
-
* 另有 --allow-empty 族每次部署都造空 commit 噪音。本助手统一三态语义:
|
|
8
|
-
* committed → 有暂存变更,已提交
|
|
9
|
-
* clean → 无变更,跳过(不算失败)
|
|
10
|
-
* failed → git 真失败(带 stderr 首行,不阻断部署——部署本体永远优先)
|
|
11
|
-
*
|
|
12
|
-
* 用法:
|
|
13
|
-
* import { deployCommit } from "../../_shared/deploy-commit.mjs";
|
|
14
|
-
* deployCommit({ repo: extRepo, name: "aiti-msg-smart", paths: ["aiti-msg-smart"],
|
|
15
|
-
* log: (m) => console.log("[deploy] " + m) });
|
|
16
|
-
*
|
|
17
|
-
* 红线:本助手永不 throw、不触碰部署产物路径之外的任何东西;只对 <repo> 做
|
|
18
|
-
* add/diff/commit(默认 --no-verify,extRepo 无 hooks,防未来误挂)。
|
|
19
|
-
*/
|
|
20
|
-
import { execFileSync } from "node:child_process";
|
|
21
|
-
|
|
22
|
-
export function deployCommit({ repo, name, paths = null, extraMsg = "", ident = false, log = console.log }) {
|
|
23
|
-
const git = (args) =>
|
|
24
|
-
execFileSync("git", args, { cwd: repo, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
25
|
-
const firstLine = (s) => String(s || "").trim().split("\n")[0];
|
|
26
|
-
try {
|
|
27
|
-
// 暂存:默认只收本扩展子目录(与 add <ext> 行为对齐;避免把别的扩展的
|
|
28
|
-
// 未提交改动卷进本扩展的部署 commit);paths=null 时退回 add -A 全仓。
|
|
29
|
-
git(["add", ...(paths && paths.length ? ["--", ...paths] : ["-A"])]);
|
|
30
|
-
let dirty;
|
|
31
|
-
try {
|
|
32
|
-
git(["diff", "--cached", "--quiet"]);
|
|
33
|
-
dirty = false; // exit 0 = 暂存区与 HEAD 一致
|
|
34
|
-
} catch (e) {
|
|
35
|
-
if (e.status !== 1) throw e; // 1 = 有变更;其他才是真错误
|
|
36
|
-
dirty = true;
|
|
37
|
-
}
|
|
38
|
-
if (!dirty) {
|
|
39
|
-
log("扩展仓库无变化(跳过提交)");
|
|
40
|
-
return { status: "clean" };
|
|
41
|
-
}
|
|
42
|
-
const stamp = new Date().toISOString().replace("T", " ").slice(0, 19);
|
|
43
|
-
const msg = `[deploy] ${name} · ${stamp}${extraMsg ? " · " + extraMsg : ""}`;
|
|
44
|
-
git([...(ident ? ["-c", "user.name=deploy", "-c", "user.email=deploy@local"] : []), "commit", "--no-verify", "-m", msg]);
|
|
45
|
-
log("扩展仓库已提交:" + msg);
|
|
46
|
-
return { status: "committed", msg };
|
|
47
|
-
} catch (e) {
|
|
48
|
-
const reason = firstLine(e.stderr) || firstLine(e.message) || "git error";
|
|
49
|
-
log("提交失败(忽略,不影响部署):" + reason);
|
|
50
|
-
return { status: "failed", reason };
|
|
51
|
-
}
|
|
52
|
-
}
|
package/reload-instances.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* _shared/reload-instances.mjs · pi-web 双实例热重载(各扩展 deploy.mjs 共用)
|
|
3
|
-
*
|
|
4
|
-
* dev 3001 / 生产 3002;端口可经 AITI_DEV_PORT / AITI_PROD_PORT 覆盖;
|
|
5
|
-
* basePath 双 env(AITI_DEV_BASE_PATH / AITI_PROD_BASE_PATH)按机器设值,
|
|
6
|
-
* 推荐值不带斜杠(48:dev 与 空;155:系统级 wdev 与 win)——git-bash 启动
|
|
7
|
-
* 原生程序时会把 / 开头的 env 值做 MSYS 路径转换(/wdev → D:/apps/Git/wdev)
|
|
8
|
-
* 致 URL 非法;不带斜杠则不触发转换。此处自动补 /(旧 /xxx 格式仍兼容),
|
|
9
|
-
* 兼容不了时提示 MSYS_NO_PATHCONV=1。
|
|
10
|
-
* 避免「server 端代码改了、实例没 reload 导致跑旧逻辑」。
|
|
11
|
-
*
|
|
12
|
-
* 用法(静态 import 或顶层 await import 均可):
|
|
13
|
-
* import { reloadInstances } from "../../_shared/reload-instances.mjs";
|
|
14
|
-
* await reloadInstances(); // 默认 "[deploy] " 前缀
|
|
15
|
-
*/
|
|
16
|
-
const BASE_PATH_RE = /^\/[A-Za-z0-9._-]*$/;
|
|
17
|
-
|
|
18
|
-
function buildInstance(name, portEnv, portDefault, pathEnv, pathDefault) {
|
|
19
|
-
const origin = `http://127.0.0.1:${process.env[portEnv] || portDefault}`;
|
|
20
|
-
const raw = process.env[pathEnv];
|
|
21
|
-
if (raw === undefined || raw === null || String(raw).trim() === "") return { name, base: origin + pathDefault };
|
|
22
|
-
// 自动补 /:wdev → /wdev(推荐无斜杠格式,MSYS 不转换);/wdev → /wdev(旧格式兼容)
|
|
23
|
-
const p = "/" + String(raw).trim().replace(/^\/+|\/+$/g, "");
|
|
24
|
-
if (BASE_PATH_RE.test(p)) return { name, base: origin + p };
|
|
25
|
-
return { name, base: null, raw };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** 双实例清单(dev/prod 各 {name, base});reload-instances 与 reconcile-deps 等共用。 */
|
|
29
|
-
export function buildInstances() {
|
|
30
|
-
return [
|
|
31
|
-
buildInstance("dev", "AITI_DEV_PORT", 3001, "AITI_DEV_BASE_PATH", "/dev"),
|
|
32
|
-
buildInstance("prod", "AITI_PROD_PORT", 3002, "AITI_PROD_BASE_PATH", ""),
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export async function reloadInstances(prefix = "[deploy] ") {
|
|
37
|
-
// 批次合并(deploy-all 场景):子条目部署脚本被注入 PI_WEB_DEFER_RELOAD=1 时不各自 reload,
|
|
38
|
-
// 由 deploy-all 在全部条目完成后统一执行一轮(N 条目 × 2 实例 → 2 次 POST)。
|
|
39
|
-
// 避免批量部署时的 reload 风暴(2026-09-15 实测:65 条目逐个 reload 把 dev 实例打满)。
|
|
40
|
-
// 单独跑某个扩展 deploy.mjs 不带该 env → 行为不变(部署完立即 reload)。
|
|
41
|
-
if (process.env.PI_WEB_DEFER_RELOAD === "1") {
|
|
42
|
-
console.log(`${prefix}reload 已 defer(PI_WEB_DEFER_RELOAD=1,由 deploy-all 收尾统一执行)`);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
// 允许失败:网络异常/非 2xx/服务未启动/env 非法一律只打提示,永不 throw——不影响 deploy 退出码
|
|
46
|
-
for (const inst of buildInstances()) {
|
|
47
|
-
if (inst.base === null) {
|
|
48
|
-
const msysHint = /[\\:]/.test(inst.raw) ? "——疑似 git-bash MSYS 路径转换,用 MSYS_NO_PATHCONV=1 前缀重跑" : "";
|
|
49
|
-
console.log(`${prefix}reload ${inst.name} 跳过:AITI_${inst.name.toUpperCase()}_BASE_PATH="${inst.raw}" 非法(须形如 /xxx 或留空)${msysHint}`);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
try {
|
|
53
|
-
const r = await fetch(inst.base + "/api/extensions/reload", { method: "POST" });
|
|
54
|
-
console.log(`${prefix}reload ${inst.name} → HTTP ${r.status} ${r.ok ? "✓" : "⚠ 失败(请手动 POST /api/extensions/reload)"}`);
|
|
55
|
-
} catch (e) {
|
|
56
|
-
const cause = e && e.cause ? String(e.cause.code || e.cause.message || e.cause) : String((e && e.message) || e);
|
|
57
|
-
console.log(`${prefix}reload ${inst.name} 不可达(${cause})— 需手动 POST /api/extensions/reload`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|