@aiti-ai/aiti-git-ops 0.1.9 → 0.1.10
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 +14 -23
- package/README.zh-CN.md +31 -0
- package/dev-pack.mjs +3 -3
- package/git-engine.ts +39 -1
- package/index.ts +2 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,39 +1,30 @@
|
|
|
1
1
|
# @aiti-ai/aiti-git-ops
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Whitelisted git write engine — checkout precheck / stash / plan breakpoints / audit / changed topic, consumed by folder and session-manager
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
English · [简体中文](./README.zh-CN.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## About aiti
|
|
8
8
|
|
|
9
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/pi-web)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
11
|
+
- Workbench (aiti-agent, built on pi-web): <https://github.com/aiti-ai/pi-web>
|
|
12
|
+
- Ecosystem monorepo: <https://github.com/aiti-ai/aiti-ai>
|
|
13
|
+
- Site: <https://aiti.pw>
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Category: Server-side engine · Tags: `git` · `server-side` · `engine`
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## Install
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Bundled with **aiti-agent** (`@aiti-ai/pi-web`) — enable it from the in-app extension manager (ExtMan / App Center).
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Manual install: place this package at `~/.pi/web/extensions/aiti-git-ops/` and reload pi-web.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
## Documentation
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
# 部署到 ~/.pi/web/extensions/aiti-git-ops/ 后 reload
|
|
29
|
-
node pi-web-ext/aiti-git-ops/tools/deploy.mjs
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## 文档 · Documentation
|
|
33
|
-
|
|
34
|
-
- 中文完整文档(aiti-docs): <https://aiti.pw/extensions/aiti-git-ops.html>
|
|
35
|
-
- English docs: <https://aiti.pw/en/extensions/aiti-git-ops.html>
|
|
36
|
-
- 扩展注册表 / registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
|
|
25
|
+
- Documentation (English): <https://aiti.pw/en/extensions/aiti-git-ops.html>
|
|
26
|
+
- 文档(中文): <https://aiti.pw/extensions/aiti-git-ops.html>
|
|
27
|
+
- Extension registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
|
|
37
28
|
|
|
38
29
|
## License
|
|
39
30
|
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @aiti-ai/aiti-git-ops
|
|
2
|
+
|
|
3
|
+
> 白名单 git 写引擎——checkout 预检 / stash / plan 断点 / 审计 / changed topic,供 folder 与 session-manager 消费
|
|
4
|
+
|
|
5
|
+
[English](./README.md) · 简体中文
|
|
6
|
+
|
|
7
|
+
## 关于 aiti
|
|
8
|
+
|
|
9
|
+
本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/pi-web) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
|
|
10
|
+
|
|
11
|
+
- 工作台(aiti-agent,基于 pi-web): <https://github.com/aiti-ai/pi-web>
|
|
12
|
+
- 生态仓库: <https://github.com/aiti-ai/aiti-ai>
|
|
13
|
+
- 官网: <https://aiti.pw>
|
|
14
|
+
|
|
15
|
+
分类: 服务端引擎 · tags: `git` · `server-side` · `engine`
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
随 **aiti-agent**(`@aiti-ai/pi-web`)捆绑发行——在工作台内的扩展管理器(ExtMan / 应用中心)启用即可。
|
|
20
|
+
|
|
21
|
+
手动安装:把本包放到 `~/.pi/web/extensions/aiti-git-ops/` 后 reload。
|
|
22
|
+
|
|
23
|
+
## 文档
|
|
24
|
+
|
|
25
|
+
- 中文文档: <https://aiti.pw/extensions/aiti-git-ops.html>
|
|
26
|
+
- Documentation (English): <https://aiti.pw/en/extensions/aiti-git-ops.html>
|
|
27
|
+
- 扩展注册表: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
|
|
28
|
+
|
|
29
|
+
## 许可证
|
|
30
|
+
|
|
31
|
+
MIT
|
package/dev-pack.mjs
CHANGED
|
@@ -77,7 +77,7 @@ export function agentsMdTemplate(extId) {
|
|
|
77
77
|
|
|
78
78
|
/** 默认 tools/build.mjs(esbuild 单包零配置;扩展自带 tools/build.mjs 则不走到这里)。 */
|
|
79
79
|
function buildMjsTemplate(extId, extRoot, clientOut, entryRel) {
|
|
80
|
-
const repoHint = "/home/pi/workspace/
|
|
80
|
+
const repoHint = "/home/pi/workspace/pi-work"; // 现场构建探测源码仓 node_modules 用(三机各不同,缺失时走 npm exec)
|
|
81
81
|
return `/**
|
|
82
82
|
* ${extId} · 现场构建入口(dev-pack 默认模板,esbuild 单包零配置)
|
|
83
83
|
* 用法:node tools/build.mjs
|
|
@@ -100,8 +100,8 @@ function findEsbuild() {
|
|
|
100
100
|
const home = (process.env.HOME || process.env.USERPROFILE || "").split(pathSep).join("/");
|
|
101
101
|
const candidates = [
|
|
102
102
|
extRoot + "/node_modules/esbuild/bin/esbuild",
|
|
103
|
-
home + "/workspace/
|
|
104
|
-
"
|
|
103
|
+
home + "/workspace/pi-work/node_modules/esbuild/bin/esbuild",
|
|
104
|
+
"D:/workspace/pi-work/node_modules/esbuild/bin/esbuild", // 155 win(源码在 D 盘)
|
|
105
105
|
];
|
|
106
106
|
for (const c of candidates) {
|
|
107
107
|
if (!existsSync(c)) continue;
|
package/git-engine.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* - 审计 jsonl(state 层 5MB 滚动)+ 事件 onChanged 回调(index.ts 接 event-bus topic)。
|
|
14
14
|
*/
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
|
-
import { mkdir, rename, rm, cp, appendFile, stat } from "node:fs/promises";
|
|
16
|
+
import { mkdir, readFile, rename, rm, cp, appendFile, stat } from "node:fs/promises";
|
|
17
17
|
import { dirname, join, isAbsolute, relative, resolve as pathResolve } from "node:path";
|
|
18
18
|
import { execFileAsync, queueRepo } from "@aiti-ai/ext-shared/exec-async";
|
|
19
19
|
|
|
@@ -703,6 +703,44 @@ export async function gitDiscard(cwd: string, paths: string[]): Promise<{ ok: tr
|
|
|
703
703
|
});
|
|
704
704
|
}
|
|
705
705
|
|
|
706
|
+
/**
|
|
707
|
+
* 将路径追加进仓库 .gitignore(变更列表「加入 .gitignore」动作,主要面向 untracked 新文件)。
|
|
708
|
+
* 规则:条目 = 相对仓库根的正斜杠路径(.gitignore 在根,相对语义精确命中);
|
|
709
|
+
* 已存在等值行(trim 后比对)则跳过;原文件末尾无换行时先补换行再追加。
|
|
710
|
+
*/
|
|
711
|
+
export async function gitIgnoreAdd(cwd: string, paths: string[]): Promise<{ ok: true; added: string[]; skipped: string[] }> {
|
|
712
|
+
const repo = await repoRoot(cwd);
|
|
713
|
+
const rels = relPaths(repo, paths);
|
|
714
|
+
return queueRepo(repo, async () => {
|
|
715
|
+
const giPath = join(repo, ".gitignore");
|
|
716
|
+
let existing = "";
|
|
717
|
+
try {
|
|
718
|
+
existing = await readFile(giPath, "utf8");
|
|
719
|
+
} catch { /* 无 .gitignore:新建 */ }
|
|
720
|
+
const lines = new Set(existing.split(/\r?\n/).map((l) => l.trim()).filter(Boolean));
|
|
721
|
+
const added: string[] = [];
|
|
722
|
+
const skipped: string[] = [];
|
|
723
|
+
let content = existing;
|
|
724
|
+
if (content && !content.endsWith("\n")) content += "\n";
|
|
725
|
+
for (const rel of rels) {
|
|
726
|
+
const entry = rel.replace(/\\/g, "/");
|
|
727
|
+
if (lines.has(entry)) {
|
|
728
|
+
skipped.push(entry);
|
|
729
|
+
continue;
|
|
730
|
+
}
|
|
731
|
+
lines.add(entry);
|
|
732
|
+
content += entry + "\n";
|
|
733
|
+
added.push(entry);
|
|
734
|
+
}
|
|
735
|
+
if (added.length > 0) {
|
|
736
|
+
await appendFile(giPath, added.map((e) => e + "\n").join(""), "utf8");
|
|
737
|
+
await audit({ repo, cmd: "ignore-add", paths: added });
|
|
738
|
+
changed(repo, "stage", `ignore +${added.length}`);
|
|
739
|
+
}
|
|
740
|
+
return { ok: true as const, added, skipped };
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
|
|
706
744
|
export async function gitCommit(cwd: string, message?: string, amend = false): Promise<{ ok: true; sha: string; summary: string }> {
|
|
707
745
|
const repo = await repoRoot(cwd);
|
|
708
746
|
if (!amend && (!message || typeof message !== "string")) fail(400, "缺少提交消息");
|
package/index.ts
CHANGED
|
@@ -17,7 +17,6 @@ import * as engine from "./git-engine.ts";
|
|
|
17
17
|
export default {
|
|
18
18
|
id: "aiti-git-ops",
|
|
19
19
|
name: "Git Ops(共享 Git 操作引擎)",
|
|
20
|
-
version: "0.1.0",
|
|
21
20
|
icon: "icons/git-branch.svg",
|
|
22
21
|
// 零 client bundle(同 aiti-echo-agent 等 10 个纯服务端扩展先例)
|
|
23
22
|
provides: ["aiti-git-ops.api"],
|
|
@@ -55,6 +54,7 @@ export default {
|
|
|
55
54
|
stage: (cwd: string, paths: string[]) => engine.gitStage(cwd, paths),
|
|
56
55
|
unstage: (cwd: string, paths: string[]) => engine.gitUnstage(cwd, paths),
|
|
57
56
|
discard: (cwd: string, paths: string[]) => engine.gitDiscard(cwd, paths),
|
|
57
|
+
ignoreAdd: (cwd: string, paths: string[]) => engine.gitIgnoreAdd(cwd, paths),
|
|
58
58
|
commit: (cwd: string, message?: string, amend?: boolean) => engine.gitCommit(cwd, message, amend),
|
|
59
59
|
planExecute: (cwd: string, groups: engine.PlanGroup[]) => engine.gitPlanExecute(cwd, groups),
|
|
60
60
|
planRollback: (cwd: string, baseHEAD: string) => engine.gitPlanRollback(cwd, baseHEAD),
|
|
@@ -105,6 +105,7 @@ export default {
|
|
|
105
105
|
case "stage": return json(await engine.gitStage(cwd, body?.paths));
|
|
106
106
|
case "unstage": return json(await engine.gitUnstage(cwd, body?.paths));
|
|
107
107
|
case "discard": return json(await engine.gitDiscard(cwd, body?.paths));
|
|
108
|
+
case "ignore-add": return json(await engine.gitIgnoreAdd(cwd, body?.paths));
|
|
108
109
|
case "commit": return json(await engine.gitCommit(cwd, body?.message, !!body?.amend));
|
|
109
110
|
case "plan":
|
|
110
111
|
if (p[2] === "execute") return json(await engine.gitPlanExecute(cwd, body?.groups));
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiti-ai/aiti-git-ops",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.10",
|
|
4
|
+
"description": "Whitelisted git write engine — checkout precheck / stash / plan breakpoints / audit / changed topic, consumed by folder and session-manager",
|
|
5
5
|
"soul": "一处写仓,处处安全。",
|
|
6
6
|
"aitiExtProtocol": "1.0",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@aiti-ai/ext-shared": "^0.1.
|
|
8
|
+
"@aiti-ai/ext-shared": "^0.1.12"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"contentHash": "
|
|
11
|
+
"contentHash": "c4b6c972aadc85ea",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "git+https://github.com/aiti-ai/aiti-ai.git",
|