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
|
@@ -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";
|
package/web/css/workspace.css
CHANGED
package/web/views/workspace.js
CHANGED
|
@@ -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
|
},
|