@aiti-ai/aiti-git-ops 0.1.12 → 0.1.14

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
@@ -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/pi-web)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
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 (aiti-agent, built on pi-web): <https://github.com/aiti-ai/pi-web>
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
  Category: Server-side engine · Tags: `git` · `server-side` · `engine`
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/pi-web) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
9
+ 本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/aiti-ai) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
10
10
 
11
- - 工作台(aiti-agent,基于 pi-web): <https://github.com/aiti-ai/pi-web>
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
  分类: 服务端引擎 · tags: `git` · `server-side` · `engine`
@@ -310,6 +310,24 @@ test("log 分页:--graph 无 --skip 语义下翻页完整(55 空提交)",
310
310
  assert.equal(tail.body.lines.length, 0); // 越界空页不炸
311
311
  });
312
312
 
313
+ test("log: decorate always on + ref filter (graph view branch filter, borrow plan 2.1)", async () => {
314
+ git(["checkout", "-b", "graphview-x"]);
315
+ git(["commit", "--allow-empty", "-m", "gvx-1"]);
316
+ git(["commit", "--allow-empty", "-m", "gvx-2"]);
317
+ const r = await call(["git", "log"], { cwd: repo, ref: "graphview-x" });
318
+ assert.equal(r.status, 200);
319
+ const tip = r.body.lines.find((l) => l.includes("gvx-2"));
320
+ assert.ok(/\(HEAD -> graphview-x\)/.test(tip)); // --decorate=short badge inline
321
+ assert.ok(r.body.lines.some((l) => l.includes("gvx-1")));
322
+ const back = await call(["git", "log"], { cwd: repo, ref: "main", cursor: 0 });
323
+ assert.equal(back.status, 200);
324
+ assert.ok(!back.body.lines.some((l) => l.includes("gvx-2"))); // main view excludes branch-only commits
325
+ assert.ok(back.body.lines.some((l) => l.includes("c55"))); // shared history still visible
326
+ const bad = await call(["git", "log"], { cwd: repo, ref: "-U executing" });
327
+ assert.equal(bad.status, 400); // same assertSafeRef gate as checkout
328
+ git(["checkout", "main"]);
329
+ });
330
+
313
331
  test("审计 jsonl 已写入(state 分层路径)", async () => {
314
332
  const auditPath = join(tmp, "ext", "config", "state", "aiti-git-ops", "git-ops.jsonl");
315
333
  assert.equal(existsSync(auditPath), true);
package/git-engine.ts CHANGED
@@ -195,7 +195,9 @@ export function parseStatusZ(out: string): StatusEntry[] {
195
195
  }
196
196
 
197
197
  async function statusEntries(repo: string): Promise<StatusEntry[]> {
198
- return parseStatusZ(await run(repo, ["status", "--porcelain", "-z"], 15_000));
198
+ // Read-only: `--no-optional-locks` keeps the index stat refresh (index.lock)
199
+ // out of .git, so probes do not wake directory watchers (aiti-folder loops).
200
+ return parseStatusZ(await run(repo, ["--no-optional-locks", "status", "--porcelain", "-z"], 15_000));
199
201
  }
200
202
 
201
203
  // ── checkout 预检管道(§1.3) ────────────────────────────────────────────────
@@ -295,18 +297,22 @@ export async function stashFiles(cwd: string, index: number): Promise<{ tracked:
295
297
  /**
296
298
  * 图谱分页。注意:`git log --graph` 与 `--skip` 不兼容(静默返回空,实测 git 2.48),
297
299
  * 改为 --max-count=(skip+count+1) 后本地切片;是否还有下一页用 rev-list --count 判断。
300
+ * ref (optional, graph-view branch filter): defaults to HEAD; --decorate=short always on so the client can draw ref badges.
298
301
  */
299
- export async function gitLog(cwd: string, cursor: number, count = 50): Promise<{ lines: string[]; nextCursor: number | null }> {
302
+ export async function gitLog(cwd: string, cursor: number, count = 50, ref?: string): Promise<{ lines: string[]; nextCursor: number | null }> {
300
303
  const repo = await repoRoot(cwd);
304
+ const wanted = typeof ref === "string" ? ref.trim() : "";
305
+ const rev = wanted && wanted !== "HEAD" ? wanted : "HEAD";
306
+ if (rev !== "HEAD") assertSafeRef(rev, "ref");
301
307
  const skip = Number.isInteger(cursor) && cursor > 0 ? cursor : 0;
302
- const out = await run(repo, ["log", "--graph", "--oneline", "--date-order", `--max-count=${skip + count + 1}`], 60_000);
308
+ const out = await run(repo, ["log", "--graph", "--oneline", "--date-order", "--decorate=short", `--max-count=${skip + count + 1}`, rev], 60_000);
303
309
  const all = out.split("\n");
304
310
  if (all[all.length - 1] === "") all.pop();
305
311
  const lines = all.slice(skip, skip + count);
306
312
  let nextCursor: number | null = null;
307
313
  if (lines.length === count) {
308
314
  try {
309
- const total = Number((await run(repo, ["rev-list", "--count", "HEAD"], 30_000)).trim());
315
+ const total = Number((await run(repo, ["rev-list", "--count", rev], 30_000)).trim());
310
316
  if (skip + count < total) nextCursor = skip + count;
311
317
  } catch { /* 空仓库 */ }
312
318
  }
package/index.ts CHANGED
@@ -52,7 +52,7 @@ export default {
52
52
  try {
53
53
  ctx.services?.provide?.("aiti-git-ops.api", {
54
54
  refs: (cwd: string) => engine.gitRefs(cwd),
55
- log: (cwd: string, cursor: number) => engine.gitLog(cwd, cursor),
55
+ log: (cwd: string, cursor: number, ref?: string) => engine.gitLog(cwd, cursor, 50, ref),
56
56
  checkout: (cwd: string, ref: string, mode?: string) => engine.gitCheckout(cwd, ref, mode),
57
57
  branchCreate: (cwd: string, name: string, from?: string, checkout?: boolean) => engine.gitBranchCreate(cwd, name, from, checkout),
58
58
  branchDelete: (cwd: string, name: string) => engine.gitBranchDelete(cwd, name),
@@ -103,7 +103,7 @@ export default {
103
103
  try {
104
104
  switch (p[1]) {
105
105
  case "refs": return json({ ok: true, ...(await engine.gitRefs(cwd)) });
106
- case "log": return json({ ok: true, ...(await engine.gitLog(cwd, body?.cursor ?? 0)) });
106
+ case "log": return json({ ok: true, ...(await engine.gitLog(cwd, body?.cursor ?? 0, 50, body?.ref)) });
107
107
  case "checkout": return json(await engine.gitCheckout(cwd, body?.ref, body?.mode));
108
108
  case "branch-create": return json(await engine.gitBranchCreate(cwd, body?.name, body?.from, body?.checkout !== false));
109
109
  case "branch-delete": return json(await engine.gitBranchDelete(cwd, body?.name));
package/package.json CHANGED
@@ -1,14 +1,23 @@
1
1
  {
2
2
  "name": "@aiti-ai/aiti-git-ops",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Whitelisted git write engine — checkout precheck / stash / plan breakpoints / audit / changed topic, consumed by folder and session-manager",
5
+ "displayNameI18n": {
6
+ "en": "Git Ops (shared git operations engine)"
7
+ },
8
+ "descriptionI18n": {
9
+ "zh-CN": "白名单 git 写引擎——checkout 预检 / stash / plan 断点 / 审计 / changed topic,供 folder 与 session-manager 消费"
10
+ },
5
11
  "soul": "一处写仓,处处安全。",
12
+ "soulI18n": {
13
+ "en": "One place to write the repo, every place stays safe."
14
+ },
6
15
  "aitiExtProtocol": "1.0",
7
16
  "dependencies": {
8
17
  "@aiti-ai/ext-shared": "^0.1.12"
9
18
  },
10
19
  "license": "MIT",
11
- "contentHash": "98ec3c60db6ec2af",
20
+ "contentHash": "5d44e1528f360d9d",
12
21
  "repository": {
13
22
  "type": "git",
14
23
  "url": "git+https://github.com/aiti-ai/aiti-ai.git",