agent-loft 0.2.100 → 0.2.101

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-loft",
3
- "version": "0.2.100",
3
+ "version": "0.2.101",
4
4
  "type": "module",
5
5
  "description": "多个 agent 的工作台:把本机 Claude Code / Codex 放到一处统一管理,用飞书和 Web 页面随时驱动——会话、审批、模型切换都共用",
6
6
  "keywords": [
@@ -15,6 +15,7 @@ import {
15
15
  gitDiff,
16
16
  gitDiscard,
17
17
  gitFetch,
18
+ gitIgnoredPaths,
18
19
  gitPull,
19
20
  gitPush,
20
21
  GitError,
@@ -179,6 +180,8 @@ export async function handleWorkspaceApi(req: IncomingMessage, res: ServerRespon
179
180
  if (sub === "workspace-tree") {
180
181
  const listing = listWorkspaceEntries(cwd, requested);
181
182
  if (!listing) throw new HttpError(404, "目录不存在,或者不能查看");
183
+ const ignored = await gitIgnoredPaths(path.resolve(cwd, listing.path), listing.entries.map((entry) => entry.name));
184
+ for (const entry of listing.entries) if (ignored.has(entry.name)) entry.ignored = true;
182
185
  sendJson(res, 200, listing);
183
186
  return true;
184
187
  }
package/src/core/git.ts CHANGED
@@ -183,6 +183,22 @@ export async function findRepo(cwd: string): Promise<GitRepo> {
183
183
  return { repo: true, root };
184
184
  }
185
185
 
186
+ /** 批量检查目录中的路径;非仓库、Git 不可用时不影响文件树。跟踪中的文件不会标成忽略。 */
187
+ export async function gitIgnoredPaths(cwd: string, paths: string[]): Promise<Set<string>> {
188
+ if (!paths.length) return new Set();
189
+ try {
190
+ if (!(await findRepo(cwd)).repo) return new Set();
191
+ // check-ignore 不运行 filter,直接复用安全配置即可。NUL 分隔兼容空格、换行和以 - 开头的文件名。
192
+ const out = await run(cwd, [...SAFE_CONFIG.flatMap((c) => ["-c", c]), "check-ignore", "-z", "--stdin"], STATUS_MAX_BYTES, {
193
+ input: `${paths.join("\0")}\0`,
194
+ });
195
+ if (out.code === 0 && !out.truncated) return new Set(out.stdout.split("\0").filter(Boolean));
196
+ } catch {
197
+ // 忽略标记只是辅助显示,失败仍然让用户正常浏览文件。
198
+ }
199
+ return new Set();
200
+ }
201
+
186
202
  // ---------- status ----------
187
203
 
188
204
  export type GitFileState = "modified" | "added" | "deleted" | "renamed" | "copied" | "typechange" | "untracked" | "conflicted";
@@ -28,6 +28,8 @@ export type WorkspaceEntry = {
28
28
  mtime: number;
29
29
  /** 符号链接:显示时标一下,指向的类型算在 type 里 */
30
30
  link?: boolean;
31
+ /** 被 Git 忽略,文件树中淡化显示 */
32
+ ignored?: boolean;
31
33
  };
32
34
 
33
35
  export type WorkspaceListing = {
@@ -182,6 +182,10 @@ button.ws-row:hover {
182
182
  color: var(--fg-soft);
183
183
  }
184
184
 
185
+ .ws-row.ignored .ws-name {
186
+ color: var(--fg-faint);
187
+ }
188
+
185
189
  .ws-row-note {
186
190
  color: var(--fg-faint);
187
191
  font-size: 12px;
@@ -454,9 +454,9 @@ function treeRows(rel, depth) {
454
454
  h(
455
455
  "button",
456
456
  {
457
- class: `ws-row${entry.name.startsWith(".") ? " faint" : ""}`,
457
+ class: `ws-row${entry.name.startsWith(".") ? " faint" : ""}${entry.ignored ? " ignored" : ""}`,
458
458
  style: { paddingLeft: `${12 + depth * 16}px` },
459
- title: entry.path,
459
+ title: entry.ignored ? `${entry.path}(Git 已忽略)` : entry.path,
460
460
  ...(dir ? { "aria-expanded": open ? "true" : "false" } : {}),
461
461
  onclick: () => (dir ? toggleDir(entry.path) : openDetail({ kind: "file", path: entry.path, from: null })),
462
462
  },