@aiti-ai/ext-shared 0.1.12 → 0.1.16

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.
@@ -0,0 +1,118 @@
1
+ /**
2
+ * git-ops-client · git log --graph ASCII art → per-row lane geometry (pure, no DOM).
3
+ *
4
+ * Graph view data layer (dsh-better-sidebar borrow plan §2.1): the engine already emits
5
+ * `--graph --oneline --date-order --decorate=short` lines; we decode git's own layout
6
+ * instead of re-deriving it. Lane grid = 1 char per half-lane (git lanes are 2 chars wide),
7
+ * so a `\` drawn at index i connects lane column (i-1) above to (i+1) below, and `/`
8
+ * connects (i+1) above to (i-1) below. Renderer draws one SVG per row; consecutive rows
9
+ * connect seamlessly because every row draws its own full-height verticals.
10
+ *
11
+ * Lane ids are cosmetic (edge/node coloring only): a `*` node inherits the pipe lane
12
+ * above it; `\` opens a new lane; `/` keeps the collapsing lane's color unless a pipe
13
+ * already owns that column (merge junctions must stay on the main lane's color).
14
+ */
15
+
16
+ // Graph-art characters git can emit (anything else means the line is not graph art).
17
+ const GRAPH_CHARS = new Set(["*", "|", "\\", "/", "-", "_", ".", " "]);
18
+
19
+ const SHA_RE = /[0-9a-f]{7,40}/;
20
+
21
+ /** Decorations look like refs: `HEAD -> main`, `origin/x`, `tag: v1`, `HEAD`. */
22
+ function looksLikeRef(part) {
23
+ if (part === "HEAD") return true;
24
+ if (part.startsWith("tag:")) return true;
25
+ if (part.startsWith("HEAD ->")) return true;
26
+ return /^[\w.-]+\/?[\w./-]*$/.test(part) && /[\w._-]/.test(part);
27
+ }
28
+
29
+ /**
30
+ * Parse one log line into { graph, sha, refs, subject } | null.
31
+ * `graph` keeps the ASCII prefix (trimmed of trailing blanks); continuation rows
32
+ * (bare `|\` / `|/` art without a commit) return with sha=null and subject="".
33
+ * Returns null for lines that carry no graph prefix at all (defensive; --graph output
34
+ * always has one, but octopus corner cases may surprise us — caller falls back to raw text).
35
+ */
36
+ export function parseGraphRow(line) {
37
+ if (typeof line !== "string") return null;
38
+ // Find the sha: first 7-40 hex run that sits after a graph-art prefix.
39
+ const m = /^([\s|\\/.*_-]*)([0-9a-f]{7,40})(?:[ ]+\(([^)]*)\))?(?:[ ](.*))?$/.exec(line);
40
+ if (!m) {
41
+ // No sha → continuation row; keep it only if it is really graph art.
42
+ const art = line.replace(/\s+$/, "");
43
+ if (!art || ![...art].every((c) => GRAPH_CHARS.has(c))) return null;
44
+ return { graph: art, sha: null, refs: [], subject: "" };
45
+ }
46
+ let [, prefix, sha, deco, subject] = m;
47
+ // Guard: a subject that merely starts with "(...)" must not become a ref badge.
48
+ if (deco !== undefined) {
49
+ const parts = deco.split(",").map((s) => s.trim());
50
+ if (parts.length === 0 || parts.some((s) => !looksLikeRef(s))) {
51
+ subject = (deco + " " + (subject ?? "")).trim();
52
+ deco = undefined;
53
+ }
54
+ }
55
+ const refs = deco === undefined ? [] : deco.split(",").map((s) => s.trim()).filter(Boolean);
56
+ return { graph: prefix.replace(/\s+$/, ""), sha, refs, subject: (subject ?? "").trimEnd() };
57
+ }
58
+
59
+ /** Parse a whole page of log lines; unparseable lines come back as { raw } rows. */
60
+ export function parseGraphRows(lines) {
61
+ const rows = [];
62
+ for (const line of Array.isArray(lines) ? lines : []) {
63
+ const row = parseGraphRow(line);
64
+ rows.push(row ?? { raw: String(line) });
65
+ }
66
+ return rows;
67
+ }
68
+
69
+ /**
70
+ * Assign lane ids per row. Returns rows with:
71
+ * - lanes: Array<[col, laneId]> vertical continuity map of this row,
72
+ * - prevLanes: same map of the row above (edge coloring: a `/` merge edge keeps
73
+ * the collapsing lane's color, a `\` branch edge takes the new branch's color),
74
+ * - nodeCol / nodeLane: where the `*` sits (or -1/-1 on continuation rows).
75
+ */
76
+ export function assignLanes(rows) {
77
+ let lanesAbove = new Map();
78
+ let nextLane = 0;
79
+ return rows.map((row) => {
80
+ if (row.raw !== undefined) return { ...row, lanes: [], prevLanes: [], nodeCol: -1, nodeLane: -1 };
81
+ const above = lanesAbove;
82
+ const lanes = new Map();
83
+ let nodeCol = -1;
84
+ let nodeLane = -1;
85
+ const g = row.graph;
86
+ for (let i = 0; i < g.length; i++) {
87
+ const ch = g[i];
88
+ if (ch === "*" || ch === "|") {
89
+ const id = above.get(i) ?? lanes.get(i) ?? nextLane++;
90
+ lanes.set(i, id);
91
+ if (ch === "*") { nodeCol = i; nodeLane = id; }
92
+ } else if (ch === "\\") {
93
+ // Branch-out edge: the new branch line below gets its own color.
94
+ if (!lanes.has(i + 1)) lanes.set(i + 1, nextLane++);
95
+ } else if (ch === "/") {
96
+ // Merge-in edge: collapsing lane keeps its color, unless a pipe owns the target column.
97
+ const id = above.get(i + 1) ?? nextLane++;
98
+ if (!lanes.has(i - 1)) lanes.set(i - 1, id);
99
+ }
100
+ }
101
+ lanesAbove = lanes;
102
+ return { ...row, lanes: [...lanes.entries()], prevLanes: [...above.entries()], nodeCol, nodeLane };
103
+ });
104
+ }
105
+
106
+ /** Palette derived from host CSS vars only (theme hard rule: no raw color values). */
107
+ export const LANE_COLORS = [
108
+ "var(--accent)",
109
+ "color-mix(in srgb, var(--ok, var(--accent)) 65%, var(--text-muted))",
110
+ "color-mix(in srgb, var(--danger, var(--text-muted)) 60%, var(--text-muted))",
111
+ "color-mix(in srgb, var(--accent) 45%, var(--text-dim))",
112
+ "color-mix(in srgb, var(--accent) 70%, var(--text-muted))",
113
+ "var(--text-dim)",
114
+ ];
115
+
116
+ export function laneColor(laneId) {
117
+ return LANE_COLORS[Math.abs(laneId) % LANE_COLORS.length];
118
+ }
@@ -0,0 +1,132 @@
1
+ /**
2
+ * graph-lanes · pure parser tests (graph view data layer, borrow plan §2.1).
3
+ * Run: node --experimental-strip-types --test extensions/_shared/git-ops-client/graph-lanes.test.mjs
4
+ */
5
+ import { test } from "node:test";
6
+ import assert from "node:assert/strict";
7
+ import { assignLanes, laneColor, parseGraphRow, parseGraphRows } from "./graph-lanes.mjs";
8
+
9
+ test("plain straight line: node on lane 0, subject kept", () => {
10
+ const row = parseGraphRow("* abc1234 fix: parser edge");
11
+ assert.equal(row.graph, "*");
12
+ assert.equal(row.sha, "abc1234");
13
+ assert.deepEqual(row.refs, []);
14
+ assert.equal(row.subject, "fix: parser edge");
15
+ });
16
+
17
+ test("decorate=short: HEAD -> main / tag / remote badges split", () => {
18
+ const row = parseGraphRow("* abc1234 (HEAD -> main, origin/main, tag: v1.0) init");
19
+ assert.deepEqual(row.refs, ["HEAD -> main", "origin/main", "tag: v1.0"]);
20
+ assert.equal(row.subject, "init");
21
+ });
22
+
23
+ test("bare HEAD decoration", () => {
24
+ const row = parseGraphRow("* abc1234 (HEAD) detached subject");
25
+ assert.deepEqual(row.refs, ["HEAD"]);
26
+ assert.equal(row.subject, "detached subject");
27
+ });
28
+
29
+ test("paren group right after sha is treated as decorations (bare words are valid branch names, indistinguishable)", () => {
30
+ const row = parseGraphRow("* abc1234 (WIP) fix things");
31
+ assert.deepEqual(row.refs, ["WIP"]);
32
+ assert.equal(row.subject, "fix things");
33
+ });
34
+
35
+ test("merge commit line: wide graph prefix, sha extracted", () => {
36
+ const row = parseGraphRow("* deadbee Merge branch 'feature'");
37
+ assert.equal(row.sha, "deadbee");
38
+ assert.equal(row.subject, "Merge branch 'feature'");
39
+ });
40
+
41
+ test("continuation rows (bare art, no sha) kept as graph-only rows", () => {
42
+ const a = parseGraphRow("|\\");
43
+ assert.equal(a.sha, null);
44
+ assert.equal(a.graph, "|\\");
45
+ const b = parseGraphRow("|/");
46
+ assert.equal(b.sha, null);
47
+ const c = parseGraphRow("| |/");
48
+ assert.equal(c.sha, null);
49
+ assert.equal(c.graph, "| |/");
50
+ });
51
+
52
+ test("non-graph line returns null (caller falls back to raw)", () => {
53
+ assert.equal(parseGraphRow("hello world"), null);
54
+ assert.equal(parseGraphRow(""), null);
55
+ assert.equal(parseGraphRow(null), null);
56
+ });
57
+
58
+ test("parseGraphRows: unparseable lines become { raw } fallback rows", () => {
59
+ const rows = parseGraphRows(["* abc1234 ok", "weird line"]);
60
+ assert.equal(rows[0].sha, "abc1234");
61
+ assert.equal(rows[1].raw, "weird line");
62
+ });
63
+
64
+ test("assignLanes: straight history, single lane", () => {
65
+ const rows = assignLanes(parseGraphRows(["* aaa1111 second", "* bbb2222 first"]));
66
+ assert.equal(rows[0].nodeCol, 0);
67
+ assert.equal(rows[1].nodeCol, 0);
68
+ assert.equal(rows[0].lanes.length, 1);
69
+ assert.equal(rows[0].lanes[0][0], 0);
70
+ });
71
+
72
+ test("assignLanes: branch-out inherits pipe, branch gets own lane color", () => {
73
+ const rows = assignLanes(parseGraphRows([
74
+ "* aaa1111 main tip",
75
+ "|\\",
76
+ "| * bbb2222 on feature",
77
+ "|/",
78
+ "* ccc3333 main base",
79
+ ]));
80
+ const mainId = rows[0].lanes[0][1];
81
+ // row `|\`: main pipe col0 keeps main color; branch lane at col2 is new
82
+ const branchRow = rows[1];
83
+ assert.deepEqual(branchRow.lanes.map((e) => e[0]).sort((a, b) => a - b), [0, 2]);
84
+ assert.equal(branchRow.lanes.find((e) => e[0] === 0)[1], mainId);
85
+ const branchId = branchRow.lanes.find((e) => e[0] === 2)[1];
86
+ assert.notEqual(branchId, mainId);
87
+ // row `| *`: node at col2 inherits the branch lane
88
+ assert.equal(rows[2].nodeCol, 2);
89
+ assert.equal(rows[2].lanes.find((e) => e[0] === 2)[1], branchId);
90
+ // row `|/`: pipe at col0 stays main; merge junction does not steal main's color
91
+ assert.equal(rows[3].lanes.find((e) => e[0] === 0)[1], mainId);
92
+ // row `* col0`: back on main lane color
93
+ assert.equal(rows[4].nodeCol, 0);
94
+ assert.equal(rows[4].lanes.find((e) => e[0] === 0)[1], mainId);
95
+ });
96
+
97
+ test("assignLanes: merge edge keeps collapsing lane color via prevLanes", () => {
98
+ const rows = assignLanes(parseGraphRows(["* aaa1111 tip", "|\\", "| * bbb2222 feat", "|/", "* ccc3333 base"]));
99
+ const branchId = rows[1].lanes.find((e) => e[0] === 2)[1];
100
+ const prevMap = new Map(rows[3].prevLanes);
101
+ assert.equal(prevMap.get(2), branchId); // `/` edge at row `|/` pulls the feature lane color
102
+ });
103
+
104
+ test("assignLanes: raw fallback rows carry empty lane maps", () => {
105
+ const rows = assignLanes(parseGraphRows(["* abc1234 ok", "not art"]));
106
+ assert.deepEqual(rows[1].lanes, []);
107
+ assert.equal(rows[1].nodeCol, -1);
108
+ });
109
+
110
+ test("laneColor: stable per id, cycles within palette", () => {
111
+ assert.equal(laneColor(0), laneColor(0));
112
+ assert.equal(laneColor(7), laneColor(1));
113
+ assert.equal(laneColor(-3), laneColor(3)); // negative ids still map into the palette
114
+ });
115
+
116
+ test("octopus-ish merge: every row parses, no raw fallback", () => {
117
+ const rows = assignLanes(parseGraphRows([
118
+ "* aaa1111 Merge branches 'b1' and 'b2'",
119
+ "|\\",
120
+ "| \\",
121
+ "| \\",
122
+ "| * bbb2222 on b2",
123
+ "* | ccc3333 on b1",
124
+ "|/",
125
+ "* ddd4444 base",
126
+ ]));
127
+ assert.equal(rows[0].sha, "aaa1111");
128
+ assert.equal(rows[1].sha, null);
129
+ assert.equal(rows[4].nodeCol, 2);
130
+ assert.equal(rows[5].nodeCol, 0);
131
+ assert.ok(rows.every((r) => r.raw === undefined));
132
+ });
@@ -26,6 +26,9 @@ const DICT = {
26
26
  graph: "图谱 · 最近 commit",
27
27
  graphMore: "↓ 加载更多",
28
28
  graphEmpty: "(空仓库)",
29
+ graphBranch: "分支",
30
+ graphBranchHead: "HEAD(当前)",
31
+ graphRefHead: "HEAD",
29
32
  createAt: "在此 commit 创建分支",
30
33
  from: "起点",
31
34
  worktree: "Worktree",
@@ -128,6 +131,9 @@ const DICT = {
128
131
  graph: "Graph · recent commits",
129
132
  graphMore: "↓ Load more",
130
133
  graphEmpty: "(empty repo)",
134
+ graphBranch: "Branch",
135
+ graphBranchHead: "HEAD (current)",
136
+ graphRefHead: "HEAD",
131
137
  createAt: "Create branch at this commit",
132
138
  from: "from",
133
139
  worktree: "Worktrees",
@@ -230,6 +236,9 @@ const DICT = {
230
236
  graph: "圖譜 · 最近 commit",
231
237
  graphMore: "↓ 載入更多",
232
238
  graphEmpty: "(空倉庫)",
239
+ graphBranch: "分支",
240
+ graphBranchHead: "HEAD(目前)",
241
+ graphRefHead: "HEAD",
233
242
  createAt: "在此 commit 建立分支",
234
243
  from: "起點",
235
244
  worktree: "Worktree",
package/icons/box.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z"/><path d="M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1"/></svg>
package/icons/film.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z"/><path d="m6.2 5.3 3.1 3.9"/><path d="m12.4 3.4 3.1 4"/><path d="M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"/></svg>
package/icons/flag.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"/><line x1="4" x2="4" y1="22" y2="15"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/><path d="M13 8H7"/><path d="M17 12H7"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="6" height="6" rx="1"/><path d="M6 6h.01"/><rect x="15" y="3" width="6" height="6" rx="1"/><path d="M18 6h.01"/><rect x="3" y="15" width="6" height="6" rx="1"/><path d="M6 18h.01"/><path d="M14 14h.01"/><path d="M17 14h.01"/><path d="M20 14h.01"/><path d="M14 17h.01"/><path d="M17 17h.01"/><path d="M20 17h.01"/><path d="M14 20h.01"/><path d="M17 20h.01"/><path d="M20 20h.01"/></svg>
package/icons/star.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>
package/menu-row.tsx ADDED
@@ -0,0 +1,92 @@
1
+ /**
2
+ * MenuActionRow — the one row shape for action entries at the bottom of a dropdown
3
+ * (project menu: "Use default directory" / "Browse folders…" / injected workspace
4
+ * actions; the new-session workspace menu reuses the same body, so it gets the same rows).
5
+ *
6
+ * Why a shared component: the rows used to be hand-styled per extension (padding/font/icon
7
+ * size drifted, dim text made "Custom path…" read as a label instead of a button). One
8
+ * component keeps them recognizable as actions in every menu.
9
+ *
10
+ * Theme: colors come from host CSS vars only (no literal values); hover is local state
11
+ * because inline styles cannot express :hover.
12
+ */
13
+ import { useState, type ReactNode } from "react";
14
+
15
+ /** The row's base look: full width, 12px, readable (not dim) text, 8/12 padding. */
16
+ export const MENU_ACTION_ROW_STYLE: Record<string, string | number> = {
17
+ display: "flex",
18
+ alignItems: "center",
19
+ gap: 8,
20
+ width: "100%",
21
+ minHeight: 30,
22
+ padding: "6px 12px",
23
+ border: 0,
24
+ borderRadius: 0,
25
+ background: "none",
26
+ color: "var(--text-muted)",
27
+ fontFamily: "inherit",
28
+ fontSize: 12,
29
+ lineHeight: 1.35,
30
+ textAlign: "left",
31
+ cursor: "pointer",
32
+ };
33
+
34
+ /** Footer container: a divider above the action group (no section caption by design). */
35
+ export const MENU_GROUP_STYLE: Record<string, string | number> = {
36
+ flexShrink: 0,
37
+ borderTop: "1px solid var(--border)",
38
+ paddingTop: 4,
39
+ paddingBottom: 4,
40
+ };
41
+
42
+ export interface MenuActionRowProps {
43
+ /** Leading icon (13px), rendered in the muted color unless the row is emphasized. */
44
+ icon?: ReactNode;
45
+ label: string;
46
+ /** Tooltip: say what the row does (e.g. "Browse the filesystem to pick any folder"). */
47
+ title?: string;
48
+ /** The row reads as the primary way out of the list (folder browser). */
49
+ emphasized?: boolean;
50
+ disabled?: boolean;
51
+ /** Trailing content (shortcut, count, caret). */
52
+ trailing?: ReactNode;
53
+ onClick: (event: { stopPropagation: () => void }) => void;
54
+ }
55
+
56
+ export function MenuActionRow(props: MenuActionRowProps) {
57
+ const { icon, label, title, emphasized = false, disabled = false, trailing, onClick } = props;
58
+ const [hovered, setHovered] = useState(false);
59
+ const active = hovered && !disabled;
60
+ return (
61
+ <button
62
+ type="button"
63
+ className={`menu-action-row${emphasized ? " is-emphasized" : ""}`}
64
+ title={title ?? label}
65
+ disabled={disabled}
66
+ onClick={(event) => {
67
+ event.stopPropagation();
68
+ onClick({ stopPropagation: () => event.stopPropagation() });
69
+ }}
70
+ onMouseEnter={() => setHovered(true)}
71
+ onMouseLeave={() => setHovered(false)}
72
+ style={{
73
+ ...MENU_ACTION_ROW_STYLE,
74
+ color: disabled ? "var(--text-dim)" : active || emphasized ? "var(--text)" : "var(--text-muted)",
75
+ background: active ? "var(--bg-hover)" : "none",
76
+ opacity: disabled ? 0.55 : 1,
77
+ cursor: disabled ? "default" : "pointer",
78
+ }}
79
+ >
80
+ {icon ? (
81
+ <span
82
+ aria-hidden="true"
83
+ style={{ display: "inline-flex", flexShrink: 0, color: emphasized || active ? "var(--text)" : "var(--text-dim)" }}
84
+ >
85
+ {icon}
86
+ </span>
87
+ ) : null}
88
+ <span style={{ flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>{label}</span>
89
+ {trailing ? <span style={{ flexShrink: 0, color: "var(--text-dim)", fontSize: 11 }}>{trailing}</span> : null}
90
+ </button>
91
+ );
92
+ }
@@ -115,7 +115,7 @@ test("resolveNewSessionCwd v2:关注路径配置在目标子层(目标目录
115
115
  test("resolveNewSessionCwd v2:已知 workspace 覆盖 → 最长匹配", () => {
116
116
  const r = resolveNewSessionCwd({
117
117
  targetDir: "/home/w/pi-web/lib", targetPath: "/home/w/pi-web/lib/x.ts",
118
- currentCwd: "/home/w/pi-work",
118
+ currentCwd: "/home/w/demo-repo",
119
119
  knownWorkspaces: ["/home/w", "/home/w/pi-web", "/home/w/other"],
120
120
  });
121
121
  assert.equal(r.cwd, "/home/w/pi-web");
@@ -135,8 +135,8 @@ test("resolveNewSessionCwd v2:常规目录剥离(无 workspace 命中)", (
135
135
  test("resolveNewSessionCwd v2:剥离后命中 workspace → 用 workspace", () => {
136
136
  const r = resolveNewSessionCwd({
137
137
  targetDir: "/home/w/pi-web/docs", targetPath: "/home/w/pi-web/docs/guide.md",
138
- currentCwd: "/home/w/pi-work",
139
- knownWorkspaces: ["/home/w/pi-work", "/home/w/pi-web"],
138
+ currentCwd: "/home/w/demo-repo",
139
+ knownWorkspaces: ["/home/w/demo-repo", "/home/w/pi-web"],
140
140
  });
141
141
  assert.equal(r.cwd, "/home/w/pi-web"); // 剥 docs 后 /home/w/pi-web 命中已知 workspace
142
142
  });
@@ -246,7 +246,7 @@ test("resolveNewSessionCwdClient:端点失败/缺席 → 本地判定兜底(
246
246
  // git-trace 端点 fetch 抛异常(未装/404)→ 兜底 = 本地 resolveNewSessionCwd(knownWorkspaces 已从 sessions 派生)
247
247
  const cwd = await resolveNewSessionCwdClient({
248
248
  targetDir: "/home/w/pi-web/docs", targetPath: "/home/w/pi-web/docs/guide.md",
249
- currentCwd: "/home/w/pi-work",
249
+ currentCwd: "/home/w/demo-repo",
250
250
  apiUrl: (p) => "http://host" + p,
251
251
  fetchFn: (async (url) => {
252
252
  if (String(url).includes("/api/sessions")) return { ok: true, json: async () => ({ sessions: [{ cwd: "/home/w/pi-web" }] }) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiti-ai/ext-shared",
3
- "version": "0.1.12",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "description": "pi-web 扩展共享层(_shared 原地 package 化)——exports 子路径逐文件暴露",
6
6
  "exports": {
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "license": "MIT",
56
56
  "aitiExtProtocol": "1.0",
57
- "contentHash": "fe72c9a5a10bf886",
57
+ "contentHash": "a2809fd2072521da",
58
58
  "repository": {
59
59
  "type": "git",
60
60
  "url": "git+https://github.com/aiti-ai/aiti-ai.git",