@hamsterbase/evidra 0.6.1 → 0.7.1
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/dist/sdk/main.js +9 -0
- package/dist/service/cli.js +206 -101
- package/dist/web/assets/ProjectFileEditor-Drd5hhbo.js +90 -0
- package/dist/web/assets/ProjectFileEditor-uqf4b7Mq.css +1 -0
- package/dist/web/assets/{cssMode-Bp9HHvW7.js → cssMode-DLjojEX5.js} +1 -1
- package/dist/web/assets/editor-DjpsE8to.css +1 -0
- package/dist/web/assets/editor.api-Cm8Jz3Ng.js +908 -0
- package/dist/web/assets/{freemarker2-BfnklRK3.js → freemarker2-ffO1wPRi.js} +1 -1
- package/dist/web/assets/{handlebars-Dr05HF5Z.js → handlebars-B67yYAds.js} +1 -1
- package/dist/web/assets/{html-Ct1uYOSC.js → html-D4vuTio3.js} +1 -1
- package/dist/web/assets/{htmlMode-Bn39zG3X.js → htmlMode-Nau5A2BZ.js} +1 -1
- package/dist/web/assets/{index-B148ctmz.js → index-DuyTRx9x.js} +2 -2
- package/dist/web/assets/{javascript-G8E6TtRr.js → javascript-j7PBySIN.js} +1 -1
- package/dist/web/assets/{jsonMode-DsjA0P9q.js → jsonMode-Dlcb-cLx.js} +1 -1
- package/dist/web/assets/{liquid-C0Qe68hn.js → liquid-DSGlvFRw.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-D2cfzE9E.js → lspLanguageFeatures-DUpjT3Ad.js} +1 -1
- package/dist/web/assets/{main-Begg-8Nh.css → main-Bl-lTPMD.css} +1 -1
- package/dist/web/assets/main-DKZIIy2T.css +2 -0
- package/dist/web/assets/main-IQ1sFdJO.js +26 -0
- package/dist/web/assets/main-rJTrPQRY.js +18 -0
- package/dist/web/assets/{mdx-BrShTA3M.js → mdx-BjjEiDsC.js} +1 -1
- package/dist/web/assets/monaco-3fFILk_i.js +58 -0
- package/dist/web/assets/{python-BkqIHyNQ.js → python-dNdKGm1p.js} +1 -1
- package/dist/web/assets/{razor-DtX8gikg.js → razor-CATEbAgj.js} +1 -1
- package/dist/web/assets/{tsMode-Bx3w4Bb_.js → tsMode-BULlPLGv.js} +1 -1
- package/dist/web/assets/{typescript-DuX3E9Jz.js → typescript-Cwd0ePfj.js} +1 -1
- package/dist/web/assets/{workers-Dj20YQoo.js → workers-C57gUq9G.js} +1 -1
- package/dist/web/assets/{xml-CIaN_PJ3.js → xml-DjQsY_vM.js} +1 -1
- package/dist/web/assets/{yaml-BqFbaewv.js → yaml-BOOR4cPJ.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/editor-B8GMDV7_.css +0 -1
- package/dist/web/assets/editor.api-BZNIEFbB.js +0 -908
- package/dist/web/assets/main-BH8yzSnW.js +0 -26
- package/dist/web/assets/main-BRAOizZ3.js +0 -18
- package/dist/web/assets/main-CAvFOBUt.css +0 -2
- package/dist/web/assets/monaco-CuSMZpTT.js +0 -58
- package/dist/web/assets/useDisplayPreference-DTZ1jElj.js +0 -89
package/dist/sdk/main.js
CHANGED
|
@@ -1290,6 +1290,15 @@ z.object({
|
|
|
1290
1290
|
file: z.string(),
|
|
1291
1291
|
version: z.string().optional()
|
|
1292
1292
|
});
|
|
1293
|
+
z.object({
|
|
1294
|
+
repoRoot: z.string(),
|
|
1295
|
+
directory: z.string()
|
|
1296
|
+
});
|
|
1297
|
+
z.object({
|
|
1298
|
+
repoRoot: z.string(),
|
|
1299
|
+
file: z.string().min(1),
|
|
1300
|
+
offset: z.number().int().nonnegative().default(0)
|
|
1301
|
+
});
|
|
1293
1302
|
z.object({
|
|
1294
1303
|
repoRoot: z.string(),
|
|
1295
1304
|
/** 只统计可清理的任务数量,不删除。 */
|
package/dist/service/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/service/src/cli.ts
|
|
2
2
|
import { cac } from "cac";
|
|
3
|
-
import
|
|
3
|
+
import path36 from "node:path";
|
|
4
4
|
|
|
5
5
|
// modules/core/implementations/Functions/resolveConfig.ts
|
|
6
6
|
import path3 from "node:path";
|
|
@@ -2043,49 +2043,122 @@ async function getGitDiff(input) {
|
|
|
2043
2043
|
};
|
|
2044
2044
|
}
|
|
2045
2045
|
|
|
2046
|
-
// modules/core/implementations/Functions/
|
|
2047
|
-
import {
|
|
2048
|
-
import
|
|
2046
|
+
// modules/core/implementations/Functions/projectFiles.ts
|
|
2047
|
+
import { isUtf8 } from "node:buffer";
|
|
2048
|
+
import { constants } from "node:fs";
|
|
2049
|
+
import { lstat as lstat3, open, readdir as readdir3, readlink as readlink3, realpath as realpath3 } from "node:fs/promises";
|
|
2050
|
+
import path25 from "node:path";
|
|
2049
2051
|
|
|
2050
|
-
// modules/core/contracts/functions/
|
|
2052
|
+
// modules/core/contracts/functions/projectFiles.ts
|
|
2051
2053
|
import { z as z20 } from "zod";
|
|
2052
|
-
var
|
|
2054
|
+
var ListProjectFilesInputSchema = z20.object({
|
|
2053
2055
|
repoRoot: z20.string(),
|
|
2056
|
+
directory: z20.string()
|
|
2057
|
+
});
|
|
2058
|
+
var ReadProjectFileInputSchema = z20.object({
|
|
2059
|
+
repoRoot: z20.string(),
|
|
2060
|
+
file: z20.string().min(1),
|
|
2061
|
+
offset: z20.number().int().nonnegative().default(0)
|
|
2062
|
+
});
|
|
2063
|
+
|
|
2064
|
+
// modules/core/implementations/Functions/projectFiles.ts
|
|
2065
|
+
var pageBytes = 256 * 1024;
|
|
2066
|
+
async function projectPath(root, relative, directory) {
|
|
2067
|
+
const parts = relative ? relative.split("/") : [];
|
|
2068
|
+
if (parts.some(
|
|
2069
|
+
(part) => !part || part === "." || part === ".." || part.toLowerCase() === ".git" || part.includes("\0") || path25.sep === "\\" && /[\\:]/.test(part)
|
|
2070
|
+
)) {
|
|
2071
|
+
throw Object.assign(new Error("\u65E0\u6548\u7684\u5DE5\u4F5C\u533A\u8DEF\u5F84"), { statusCode: 400 });
|
|
2072
|
+
}
|
|
2073
|
+
const repo = await realpath3(root);
|
|
2074
|
+
const absolute = path25.join(repo, ...parts);
|
|
2075
|
+
const parent = directory ? absolute : path25.dirname(absolute);
|
|
2076
|
+
if (path25.relative(parent, await realpath3(parent)) !== "") {
|
|
2077
|
+
throw Object.assign(new Error("\u65E0\u6CD5\u6D4F\u89C8\u94FE\u63A5\u76EE\u5F55"), { statusCode: 403 });
|
|
2078
|
+
}
|
|
2079
|
+
return absolute;
|
|
2080
|
+
}
|
|
2081
|
+
async function listProjectFiles(input) {
|
|
2082
|
+
const { repoRoot, directory } = ListProjectFilesInputSchema.parse(input);
|
|
2083
|
+
const entries2 = await readdir3(await projectPath(repoRoot, directory, true), {
|
|
2084
|
+
withFileTypes: true
|
|
2085
|
+
});
|
|
2086
|
+
return entries2.filter(
|
|
2087
|
+
(entry) => entry.name.toLowerCase() !== ".git" && (entry.isFile() || entry.isDirectory() || entry.isSymbolicLink())
|
|
2088
|
+
).map((entry) => ({ name: entry.name, directory: entry.isDirectory() })).sort((a, b) => Number(b.directory) - Number(a.directory) || a.name.localeCompare(b.name));
|
|
2089
|
+
}
|
|
2090
|
+
async function readProjectFile(input) {
|
|
2091
|
+
const { repoRoot, file, offset } = ReadProjectFileInputSchema.parse(input);
|
|
2092
|
+
const absolute = await projectPath(repoRoot, file, false);
|
|
2093
|
+
const info = await lstat3(absolute);
|
|
2094
|
+
if (info.isSymbolicLink()) return { kind: "text", text: await readlink3(absolute) };
|
|
2095
|
+
if (!info.isFile()) throw Object.assign(new Error("\u8BF7\u9009\u62E9\u666E\u901A\u6587\u4EF6"), { statusCode: 400 });
|
|
2096
|
+
const handle = await open(
|
|
2097
|
+
absolute,
|
|
2098
|
+
constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK
|
|
2099
|
+
);
|
|
2100
|
+
try {
|
|
2101
|
+
const buffer = Buffer.alloc(pageBytes + 1);
|
|
2102
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, offset);
|
|
2103
|
+
let end = Math.min(bytesRead, pageBytes);
|
|
2104
|
+
if (bytesRead > end) {
|
|
2105
|
+
while (end > pageBytes - 3 && (buffer[end] & 192) === 128) end--;
|
|
2106
|
+
}
|
|
2107
|
+
const bytes = buffer.subarray(0, end);
|
|
2108
|
+
if (bytes.includes(0) || !isUtf8(bytes)) return { kind: "binary" };
|
|
2109
|
+
return {
|
|
2110
|
+
kind: "text",
|
|
2111
|
+
text: bytes.toString("utf8"),
|
|
2112
|
+
nextOffset: bytesRead > end ? offset + end : void 0
|
|
2113
|
+
};
|
|
2114
|
+
} finally {
|
|
2115
|
+
await handle.close();
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
// modules/core/implementations/Functions/pruneTasks.ts
|
|
2120
|
+
import { readdir as readdir5, readFile as readFile11, rm as rm5, rmdir, stat } from "node:fs/promises";
|
|
2121
|
+
import path27 from "node:path";
|
|
2122
|
+
|
|
2123
|
+
// modules/core/contracts/functions/pruneTasks.ts
|
|
2124
|
+
import { z as z21 } from "zod";
|
|
2125
|
+
var PruneTasksInputSchema = z21.object({
|
|
2126
|
+
repoRoot: z21.string(),
|
|
2054
2127
|
/** 只统计可清理的任务数量,不删除。 */
|
|
2055
|
-
dryRun:
|
|
2128
|
+
dryRun: z21.boolean().optional()
|
|
2056
2129
|
});
|
|
2057
2130
|
|
|
2058
2131
|
// modules/core/contracts/internal/listTasks.ts
|
|
2059
|
-
import { z as
|
|
2060
|
-
var ListTasksInputSchema =
|
|
2061
|
-
limit:
|
|
2132
|
+
import { z as z22 } from "zod";
|
|
2133
|
+
var ListTasksInputSchema = z22.object({
|
|
2134
|
+
limit: z22.number().int().min(1).max(100).optional()
|
|
2062
2135
|
});
|
|
2063
2136
|
var TASK_LIST_LIMIT = 50;
|
|
2064
2137
|
|
|
2065
2138
|
// modules/core/implementations/internal/listTasks.ts
|
|
2066
|
-
import { readdir as
|
|
2067
|
-
import
|
|
2139
|
+
import { readdir as readdir4 } from "node:fs/promises";
|
|
2140
|
+
import path26 from "node:path";
|
|
2068
2141
|
async function listTasks(input, cwd, namespaces) {
|
|
2069
2142
|
const { limit = 20 } = ListTasksInputSchema.parse(input);
|
|
2070
|
-
const root =
|
|
2143
|
+
const root = path26.join(cwd, "tasks");
|
|
2071
2144
|
const tasks = [];
|
|
2072
2145
|
const removable = [];
|
|
2073
2146
|
async function directories(directory, pattern) {
|
|
2074
2147
|
try {
|
|
2075
|
-
return (await
|
|
2148
|
+
return (await readdir4(directory, { withFileTypes: true })).filter((entry) => entry.isDirectory() && pattern.test(entry.name)).map((entry) => entry.name).sort((a, b) => a < b ? 1 : a > b ? -1 : 0);
|
|
2076
2149
|
} catch (error) {
|
|
2077
2150
|
if (error.code === "ENOENT") return [];
|
|
2078
2151
|
throw error;
|
|
2079
2152
|
}
|
|
2080
2153
|
}
|
|
2081
2154
|
for (const day of await directories(root, /^\d{4}-\d{2}-\d{2}$/)) {
|
|
2082
|
-
const dayRoot =
|
|
2155
|
+
const dayRoot = path26.join(root, day);
|
|
2083
2156
|
for (const run of await directories(dayRoot, /^\d{2}-\d{2}-\d{2}-[A-Za-z0-9-]+$/)) {
|
|
2084
2157
|
if (tasks.length === limit) {
|
|
2085
2158
|
removable.push(`${day}/${run}`);
|
|
2086
2159
|
continue;
|
|
2087
2160
|
}
|
|
2088
|
-
const file =
|
|
2161
|
+
const file = path26.join(dayRoot, run, "task.json");
|
|
2089
2162
|
const manifest = await readJson(file);
|
|
2090
2163
|
if (!manifest || (manifest.formatVersion ?? 0) < TASK_SCHEMA_VERSION || !namespaces.has(manifest.task.namespace))
|
|
2091
2164
|
continue;
|
|
@@ -2107,7 +2180,7 @@ async function listTasks(input, cwd, namespaces) {
|
|
|
2107
2180
|
var OBJECT_GRACE_MS = 10 * 60 * 1e3;
|
|
2108
2181
|
async function entries(directory) {
|
|
2109
2182
|
try {
|
|
2110
|
-
return await
|
|
2183
|
+
return await readdir5(directory, { withFileTypes: true });
|
|
2111
2184
|
} catch (error) {
|
|
2112
2185
|
if (error.code === "ENOENT") return [];
|
|
2113
2186
|
throw error;
|
|
@@ -2120,34 +2193,34 @@ async function removeIfEmpty(directory) {
|
|
|
2120
2193
|
}
|
|
2121
2194
|
async function removeUnreferencedObjects(reportDir) {
|
|
2122
2195
|
const referenced = /* @__PURE__ */ new Set();
|
|
2123
|
-
const tasks =
|
|
2196
|
+
const tasks = path27.join(reportDir, "tasks");
|
|
2124
2197
|
for (const day of await entries(tasks)) {
|
|
2125
2198
|
if (!day.isDirectory() || day.name === "_index") continue;
|
|
2126
|
-
for (const run of await entries(
|
|
2127
|
-
const cases =
|
|
2199
|
+
for (const run of await entries(path27.join(tasks, day.name))) {
|
|
2200
|
+
const cases = path27.join(tasks, day.name, run.name, "cases");
|
|
2128
2201
|
for (const file of await entries(cases)) {
|
|
2129
2202
|
if (!file.name.endsWith(".json")) continue;
|
|
2130
|
-
const item = JSON.parse(await readFile11(
|
|
2203
|
+
const item = JSON.parse(await readFile11(path27.join(cases, file.name), "utf8"));
|
|
2131
2204
|
for (const image of [...item.snapshots ?? [], ...item.observations ?? []])
|
|
2132
2205
|
if (image.type === "image") referenced.add(image.key);
|
|
2133
2206
|
}
|
|
2134
2207
|
}
|
|
2135
2208
|
}
|
|
2136
|
-
const objects =
|
|
2209
|
+
const objects = path27.join(reportDir, "objects");
|
|
2137
2210
|
const deadline = Date.now() - OBJECT_GRACE_MS;
|
|
2138
2211
|
const directories = [];
|
|
2139
|
-
for (const entry of await
|
|
2212
|
+
for (const entry of await readdir5(objects, { withFileTypes: true, recursive: true }).catch(
|
|
2140
2213
|
(error) => {
|
|
2141
2214
|
if (error.code === "ENOENT") return [];
|
|
2142
2215
|
throw error;
|
|
2143
2216
|
}
|
|
2144
2217
|
)) {
|
|
2145
|
-
const file =
|
|
2218
|
+
const file = path27.join(entry.parentPath, entry.name);
|
|
2146
2219
|
if (entry.isDirectory()) {
|
|
2147
2220
|
directories.push(file);
|
|
2148
2221
|
continue;
|
|
2149
2222
|
}
|
|
2150
|
-
if (referenced.has(
|
|
2223
|
+
if (referenced.has(path27.relative(objects, file).split(path27.sep).join("/"))) continue;
|
|
2151
2224
|
if ((await stat(file)).mtimeMs < deadline) await rm5(file);
|
|
2152
2225
|
}
|
|
2153
2226
|
for (const directory of directories.sort((a, b) => b.length - a.length))
|
|
@@ -2164,29 +2237,29 @@ async function pruneTasks(input) {
|
|
|
2164
2237
|
);
|
|
2165
2238
|
if (dryRun || !removable.length) return { count: removable.length };
|
|
2166
2239
|
const cache = pathSchema.cache(reportDir).directory;
|
|
2167
|
-
const comparisons =
|
|
2168
|
-
const taskComparisons =
|
|
2240
|
+
const comparisons = path27.join(cache, "comparisons");
|
|
2241
|
+
const taskComparisons = path27.join(cache, "task-comparisons");
|
|
2169
2242
|
const options = { recursive: true, force: true };
|
|
2170
2243
|
for (const taskPath of removable) {
|
|
2171
2244
|
const taskId = taskPath.split("/")[1].slice("HH-mm-ss-".length);
|
|
2172
2245
|
await rm5(taskDirectory(reportDir, taskPath), options);
|
|
2173
2246
|
await rm5(pathSchema.taskIndex(reportDir, taskId), { force: true });
|
|
2174
2247
|
for (const namespace of await entries(comparisons))
|
|
2175
|
-
await rm5(
|
|
2176
|
-
await rm5(
|
|
2248
|
+
await rm5(path27.join(comparisons, namespace.name, taskId), options);
|
|
2249
|
+
await rm5(path27.join(taskComparisons, taskId), options);
|
|
2177
2250
|
for (const base of await entries(taskComparisons))
|
|
2178
|
-
await rm5(
|
|
2251
|
+
await rm5(path27.join(taskComparisons, base.name, taskId), options);
|
|
2179
2252
|
}
|
|
2180
2253
|
for (const day of new Set(removable.map((taskPath) => taskPath.split("/")[0])))
|
|
2181
|
-
await removeIfEmpty(
|
|
2254
|
+
await removeIfEmpty(path27.join(reportDir, "tasks", day));
|
|
2182
2255
|
await removeUnreferencedObjects(reportDir);
|
|
2183
2256
|
return { count: removable.length };
|
|
2184
2257
|
}
|
|
2185
2258
|
|
|
2186
2259
|
// modules/core/contracts/functions/listTaskSummaries.ts
|
|
2187
|
-
import { z as
|
|
2188
|
-
var ListTaskSummariesInputSchema =
|
|
2189
|
-
repoRoot:
|
|
2260
|
+
import { z as z23 } from "zod";
|
|
2261
|
+
var ListTaskSummariesInputSchema = z23.object({
|
|
2262
|
+
repoRoot: z23.string()
|
|
2190
2263
|
});
|
|
2191
2264
|
|
|
2192
2265
|
// modules/core/implementations/reportStatus.ts
|
|
@@ -2275,8 +2348,8 @@ async function listTaskSummaries(input) {
|
|
|
2275
2348
|
}
|
|
2276
2349
|
|
|
2277
2350
|
// modules/core/contracts/functions/readProjectInfo.ts
|
|
2278
|
-
import { z as
|
|
2279
|
-
var ReadProjectInfoInputSchema =
|
|
2351
|
+
import { z as z24 } from "zod";
|
|
2352
|
+
var ReadProjectInfoInputSchema = z24.object({ repoRoot: z24.string() });
|
|
2280
2353
|
|
|
2281
2354
|
// modules/core/implementations/Functions/readProjectInfo.ts
|
|
2282
2355
|
var FALLBACK_REFS = ["main", "master", "origin/main", "origin/master"];
|
|
@@ -2322,8 +2395,8 @@ async function readProjectInfo(input) {
|
|
|
2322
2395
|
}
|
|
2323
2396
|
|
|
2324
2397
|
// modules/core/contracts/functions/listBaselines.ts
|
|
2325
|
-
import { z as
|
|
2326
|
-
var ListBaselinesInputSchema =
|
|
2398
|
+
import { z as z25 } from "zod";
|
|
2399
|
+
var ListBaselinesInputSchema = z25.object({ repoRoot: z25.string() });
|
|
2327
2400
|
|
|
2328
2401
|
// modules/core/implementations/reportTree.ts
|
|
2329
2402
|
var reportEntryKey = (namespace, id) => JSON.stringify([namespace, id]);
|
|
@@ -2401,11 +2474,11 @@ async function listBaselines(input) {
|
|
|
2401
2474
|
}
|
|
2402
2475
|
|
|
2403
2476
|
// modules/core/implementations/Functions/readTaskReport.ts
|
|
2404
|
-
import
|
|
2477
|
+
import path28 from "node:path";
|
|
2405
2478
|
|
|
2406
2479
|
// modules/core/contracts/functions/readTaskReport.ts
|
|
2407
|
-
import { z as
|
|
2408
|
-
var ReadTaskReportInputSchema =
|
|
2480
|
+
import { z as z26 } from "zod";
|
|
2481
|
+
var ReadTaskReportInputSchema = z26.object({ repoRoot: z26.string(), taskId: z26.string() });
|
|
2409
2482
|
|
|
2410
2483
|
// modules/core/implementations/Functions/readTaskReport.ts
|
|
2411
2484
|
async function readTaskReport(input) {
|
|
@@ -2425,7 +2498,7 @@ async function readTaskReport(input) {
|
|
|
2425
2498
|
}
|
|
2426
2499
|
for (const snapshot of item.snapshots) {
|
|
2427
2500
|
if (snapshot.diffFile)
|
|
2428
|
-
snapshot.diffUrl = reportStaticUrl(reportDir,
|
|
2501
|
+
snapshot.diffUrl = reportStaticUrl(reportDir, path28.join(reportDir, snapshot.diffFile));
|
|
2429
2502
|
}
|
|
2430
2503
|
}
|
|
2431
2504
|
const config = await loadConfig({ repoRoot: root });
|
|
@@ -2452,45 +2525,45 @@ async function readTaskReport(input) {
|
|
|
2452
2525
|
}
|
|
2453
2526
|
|
|
2454
2527
|
// modules/core/implementations/Functions/listChangelogCommits.ts
|
|
2455
|
-
import
|
|
2528
|
+
import path30 from "node:path";
|
|
2456
2529
|
|
|
2457
2530
|
// modules/core/contracts/functions/changelog.ts
|
|
2458
|
-
import { z as
|
|
2459
|
-
var ChangelogNoteSchema =
|
|
2460
|
-
changelog:
|
|
2461
|
-
reviewed:
|
|
2462
|
-
entries:
|
|
2463
|
-
excludeTags:
|
|
2531
|
+
import { z as z27 } from "zod";
|
|
2532
|
+
var ChangelogNoteSchema = z27.object({
|
|
2533
|
+
changelog: z27.string().optional(),
|
|
2534
|
+
reviewed: z27.boolean().optional(),
|
|
2535
|
+
entries: z27.record(z27.string(), z27.string()).optional(),
|
|
2536
|
+
excludeTags: z27.array(z27.string()).optional()
|
|
2464
2537
|
}).passthrough();
|
|
2465
|
-
var ListChangelogCommitsInputSchema =
|
|
2466
|
-
repoRoot:
|
|
2538
|
+
var ListChangelogCommitsInputSchema = z27.object({
|
|
2539
|
+
repoRoot: z27.string()
|
|
2467
2540
|
});
|
|
2468
|
-
var GetChangelogFilesInputSchema =
|
|
2469
|
-
repoRoot:
|
|
2470
|
-
commitId:
|
|
2541
|
+
var GetChangelogFilesInputSchema = z27.object({
|
|
2542
|
+
repoRoot: z27.string(),
|
|
2543
|
+
commitId: z27.string().regex(/^[a-f0-9]{40}$/)
|
|
2471
2544
|
});
|
|
2472
2545
|
var GetChangelogDiffInputSchema = GetChangelogFilesInputSchema.extend({
|
|
2473
|
-
file:
|
|
2546
|
+
file: z27.string().min(1)
|
|
2474
2547
|
});
|
|
2475
|
-
var ChangelogPatchSchema =
|
|
2476
|
-
scope:
|
|
2477
|
-
changelog:
|
|
2478
|
-
reviewed:
|
|
2479
|
-
excludeTags:
|
|
2548
|
+
var ChangelogPatchSchema = z27.object({
|
|
2549
|
+
scope: z27.string().optional(),
|
|
2550
|
+
changelog: z27.string().optional(),
|
|
2551
|
+
reviewed: z27.boolean().optional(),
|
|
2552
|
+
excludeTags: z27.array(z27.string()).optional()
|
|
2480
2553
|
});
|
|
2481
2554
|
var UpdateChangelogNoteInputSchema = GetChangelogFilesInputSchema.extend({
|
|
2482
2555
|
patch: ChangelogPatchSchema
|
|
2483
2556
|
});
|
|
2484
2557
|
|
|
2485
2558
|
// modules/core/implementations/changelog.ts
|
|
2486
|
-
import
|
|
2559
|
+
import path29 from "node:path";
|
|
2487
2560
|
async function changelogConfig(repoRoot) {
|
|
2488
2561
|
const config = await loadConfig({ repoRoot });
|
|
2489
2562
|
if (!config.change) throw Object.assign(new Error("\u6B64\u9879\u76EE\u672A\u914D\u7F6E\u66F4\u65B0\u65E5\u5FD7"), { statusCode: 404 });
|
|
2490
|
-
return { ...config.change, notedir:
|
|
2563
|
+
return { ...config.change, notedir: path29.resolve(repoRoot, config.change.notedir) };
|
|
2491
2564
|
}
|
|
2492
2565
|
function notePath(notedir, commitId) {
|
|
2493
|
-
return
|
|
2566
|
+
return path29.join(notedir, commitId.slice(0, 2), `${commitId.slice(2)}.json`);
|
|
2494
2567
|
}
|
|
2495
2568
|
async function readChangelogNote(notedir, commitId) {
|
|
2496
2569
|
return ChangelogNoteSchema.parse(await readJson(notePath(notedir, commitId)) ?? {});
|
|
@@ -2573,7 +2646,7 @@ async function listChangelogCommits(input) {
|
|
|
2573
2646
|
const [commitId, date, message] = line.split("\0");
|
|
2574
2647
|
return toChangelogCommit(
|
|
2575
2648
|
{ commitId, date, message, tags: tags.get(commitId) ?? [] },
|
|
2576
|
-
await readChangelogNote(
|
|
2649
|
+
await readChangelogNote(path30.resolve(repoRoot, config.notedir), commitId),
|
|
2577
2650
|
config.scope
|
|
2578
2651
|
);
|
|
2579
2652
|
});
|
|
@@ -2661,13 +2734,13 @@ import { serveStatic } from "@hono/node-server/serve-static";
|
|
|
2661
2734
|
import { Hono as Hono2 } from "hono";
|
|
2662
2735
|
import { existsSync as existsSync2 } from "node:fs";
|
|
2663
2736
|
import { stat as stat3 } from "node:fs/promises";
|
|
2664
|
-
import
|
|
2665
|
-
import { z as
|
|
2737
|
+
import path33 from "node:path";
|
|
2738
|
+
import { z as z28 } from "zod";
|
|
2666
2739
|
|
|
2667
2740
|
// packages/service/src/conformance.ts
|
|
2668
2741
|
import { existsSync } from "node:fs";
|
|
2669
|
-
import { readFile as readFile12, realpath as
|
|
2670
|
-
import
|
|
2742
|
+
import { readFile as readFile12, realpath as realpath4, stat as stat2 } from "node:fs/promises";
|
|
2743
|
+
import path32 from "node:path";
|
|
2671
2744
|
import { Hono } from "hono";
|
|
2672
2745
|
|
|
2673
2746
|
// packages/conformance/builtinRules.ts
|
|
@@ -2685,11 +2758,11 @@ var builtinRules = {
|
|
|
2685
2758
|
|
|
2686
2759
|
// packages/conformance/runner/load.ts
|
|
2687
2760
|
import { access as access2 } from "node:fs/promises";
|
|
2688
|
-
import
|
|
2761
|
+
import path31 from "node:path";
|
|
2689
2762
|
import { pathToFileURL } from "node:url";
|
|
2690
2763
|
import { tsImport } from "tsx/esm/api";
|
|
2691
2764
|
async function loadConformanceConfig(directory) {
|
|
2692
|
-
const file =
|
|
2765
|
+
const file = path31.resolve(directory, "evidra.conformance.ts");
|
|
2693
2766
|
try {
|
|
2694
2767
|
await access2(file);
|
|
2695
2768
|
} catch (error) {
|
|
@@ -2708,14 +2781,14 @@ async function loadConformanceConfig(directory) {
|
|
|
2708
2781
|
if (!config || !Array.isArray(config.rules) || config.rules.some((task) => typeof task !== "function") || config.projectRoot !== void 0 && typeof config.projectRoot !== "string") {
|
|
2709
2782
|
throw new Error(`${file} \u5FC5\u987B\u9ED8\u8BA4\u5BFC\u51FA { projectRoot?: string, rules: RuleTask[] }`);
|
|
2710
2783
|
}
|
|
2711
|
-
const projectRoot =
|
|
2784
|
+
const projectRoot = path31.resolve(path31.dirname(file), config.projectRoot ?? ".");
|
|
2712
2785
|
return { projectRoot, rules: config.rules };
|
|
2713
2786
|
}
|
|
2714
2787
|
|
|
2715
2788
|
// packages/service/src/conformance.ts
|
|
2716
2789
|
var builtinDirectory = [
|
|
2717
|
-
|
|
2718
|
-
|
|
2790
|
+
path32.resolve(import.meta.dirname, "../../conformance/rules"),
|
|
2791
|
+
path32.resolve(import.meta.dirname, "../../packages/conformance/rules")
|
|
2719
2792
|
].find((directory) => existsSync(directory));
|
|
2720
2793
|
var catalog = Object.values(builtinRules);
|
|
2721
2794
|
async function listRules(root) {
|
|
@@ -2742,16 +2815,16 @@ async function listRules(root) {
|
|
|
2742
2815
|
return { rules, entries: entries2 };
|
|
2743
2816
|
}
|
|
2744
2817
|
function isWithin(directory, file) {
|
|
2745
|
-
const relative =
|
|
2746
|
-
return relative !== ".." && !relative.startsWith(`..${
|
|
2818
|
+
const relative = path32.relative(directory, file);
|
|
2819
|
+
return relative !== ".." && !relative.startsWith(`..${path32.sep}`) && !path32.isAbsolute(relative);
|
|
2747
2820
|
}
|
|
2748
2821
|
async function resolveMarkdown(directory, file) {
|
|
2749
|
-
if (
|
|
2750
|
-
const candidate =
|
|
2822
|
+
if (path32.isAbsolute(file) || path32.extname(file).toLowerCase() !== ".md") return null;
|
|
2823
|
+
const candidate = path32.resolve(directory, file);
|
|
2751
2824
|
if (!isWithin(directory, candidate)) return null;
|
|
2752
2825
|
try {
|
|
2753
|
-
const resolved = await
|
|
2754
|
-
if (!isWithin(await
|
|
2826
|
+
const resolved = await realpath4(candidate);
|
|
2827
|
+
if (!isWithin(await realpath4(directory), resolved) || !(await stat2(resolved)).isFile())
|
|
2755
2828
|
return null;
|
|
2756
2829
|
return resolved;
|
|
2757
2830
|
} catch (error) {
|
|
@@ -2762,7 +2835,7 @@ async function resolveMarkdown(directory, file) {
|
|
|
2762
2835
|
async function resolveReadme(root, readme) {
|
|
2763
2836
|
if (typeof readme === "string") return resolveMarkdown(root, readme);
|
|
2764
2837
|
if (!readme || !builtinDirectory) return null;
|
|
2765
|
-
return await resolveMarkdown(builtinDirectory,
|
|
2838
|
+
return await resolveMarkdown(builtinDirectory, path32.join(readme.builtin, "README.md")) ?? resolveMarkdown(builtinDirectory, path32.join(readme.builtin, "RULE.md"));
|
|
2766
2839
|
}
|
|
2767
2840
|
function createConformanceRoutes(root) {
|
|
2768
2841
|
const app = new Hono();
|
|
@@ -2792,12 +2865,12 @@ function createConformanceRoutes(root) {
|
|
|
2792
2865
|
|
|
2793
2866
|
// packages/service/src/server.ts
|
|
2794
2867
|
function defaultWebDist() {
|
|
2795
|
-
const fromSource =
|
|
2796
|
-
const fromBundle =
|
|
2797
|
-
return [fromSource, fromBundle].find((directory) => existsSync2(
|
|
2868
|
+
const fromSource = path33.resolve(import.meta.dirname, "../../../dist/web");
|
|
2869
|
+
const fromBundle = path33.resolve(import.meta.dirname, "../../dist/web");
|
|
2870
|
+
return [fromSource, fromBundle].find((directory) => existsSync2(path33.join(directory, "index.html"))) ?? fromSource;
|
|
2798
2871
|
}
|
|
2799
2872
|
async function startServer(options) {
|
|
2800
|
-
const root =
|
|
2873
|
+
const root = path33.resolve(options.repoRoot);
|
|
2801
2874
|
await loadConfig({ repoRoot: root });
|
|
2802
2875
|
const webDist = options.webDist ?? defaultWebDist();
|
|
2803
2876
|
const app = createApp(root, webDist);
|
|
@@ -2825,10 +2898,23 @@ async function startServer(options) {
|
|
|
2825
2898
|
}
|
|
2826
2899
|
};
|
|
2827
2900
|
}
|
|
2901
|
+
function projectFileError(error) {
|
|
2902
|
+
if (!(error instanceof Error) || !("code" in error)) throw error;
|
|
2903
|
+
switch (error.code) {
|
|
2904
|
+
case "ENOENT":
|
|
2905
|
+
case "ENOTDIR":
|
|
2906
|
+
throw Object.assign(new Error("\u6587\u4EF6\u6216\u76EE\u5F55\u4E0D\u5B58\u5728\uFF0C\u53EF\u80FD\u5DF2\u88AB\u5220\u9664\u3002"), { statusCode: 404 });
|
|
2907
|
+
case "EPERM":
|
|
2908
|
+
case "EACCES":
|
|
2909
|
+
throw Object.assign(new Error("\u6CA1\u6709\u6743\u9650\u8BFB\u53D6\u8FD9\u4E2A\u6587\u4EF6\u6216\u76EE\u5F55\u3002"), { statusCode: 403 });
|
|
2910
|
+
default:
|
|
2911
|
+
throw new Error("\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6\u6216\u76EE\u5F55\u3002");
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2828
2914
|
function createApp(root, webDist) {
|
|
2829
2915
|
const app = new Hono2();
|
|
2830
2916
|
app.onError((error, context) => {
|
|
2831
|
-
const status = error instanceof
|
|
2917
|
+
const status = error instanceof z28.ZodError ? 400 : error.statusCode ?? 500;
|
|
2832
2918
|
return context.json({ error: String(error.message ?? error) }, status);
|
|
2833
2919
|
});
|
|
2834
2920
|
app.use("/api/*", async (context, next) => {
|
|
@@ -2840,6 +2926,25 @@ function createApp(root, webDist) {
|
|
|
2840
2926
|
async (context) => context.json(await readProjectInfo({ repoRoot: root }))
|
|
2841
2927
|
);
|
|
2842
2928
|
app.route("/api/conformance", createConformanceRoutes(root));
|
|
2929
|
+
app.get(
|
|
2930
|
+
"/api/files",
|
|
2931
|
+
async (context) => context.json(
|
|
2932
|
+
await listProjectFiles({
|
|
2933
|
+
repoRoot: root,
|
|
2934
|
+
directory: context.req.query("directory") ?? ""
|
|
2935
|
+
}).catch(projectFileError)
|
|
2936
|
+
)
|
|
2937
|
+
);
|
|
2938
|
+
app.get(
|
|
2939
|
+
"/api/files/content",
|
|
2940
|
+
async (context) => context.json(
|
|
2941
|
+
await readProjectFile({
|
|
2942
|
+
repoRoot: root,
|
|
2943
|
+
file: context.req.query("path") ?? "",
|
|
2944
|
+
offset: Number(context.req.query("offset") ?? 0)
|
|
2945
|
+
}).catch(projectFileError)
|
|
2946
|
+
)
|
|
2947
|
+
);
|
|
2843
2948
|
app.get(
|
|
2844
2949
|
"/api/changelog",
|
|
2845
2950
|
async (context) => context.json(await listChangelogCommits({ repoRoot: root }))
|
|
@@ -2953,7 +3058,7 @@ function createApp(root, webDist) {
|
|
|
2953
3058
|
"ETag",
|
|
2954
3059
|
`W/"${stats.size.toString(16)}-${stats.mtimeMs.toString(16)}-${stats.ctimeMs.toString(16)}"`
|
|
2955
3060
|
);
|
|
2956
|
-
const relativePath =
|
|
3061
|
+
const relativePath = path33.relative(webDist, filePath).split(path33.sep).join("/");
|
|
2957
3062
|
const immutable = context.req.path.startsWith("/report-static/") && /(?:^|[-/])[a-f0-9]{64}\.png$/.test(context.req.path) || !context.req.path.startsWith("/report-static/") && /^assets\/.+-[\w-]{8,}\.[\w.]+$/.test(relativePath);
|
|
2958
3063
|
context.header("Cache-Control", immutable ? "public, max-age=31536000, immutable" : "no-cache");
|
|
2959
3064
|
if (context.res.status !== 200 || !["GET", "HEAD"].includes(context.req.method)) return;
|
|
@@ -2993,7 +3098,7 @@ function createApp(root, webDist) {
|
|
|
2993
3098
|
await next();
|
|
2994
3099
|
});
|
|
2995
3100
|
app.get("*", serveStatic({ root: webDist, ...staticOptions }));
|
|
2996
|
-
app.get("*", (context, next) =>
|
|
3101
|
+
app.get("*", (context, next) => path33.extname(context.req.path) ? context.notFound() : next());
|
|
2997
3102
|
app.get("*", serveStatic({ root: webDist, path: "index.html", ...staticOptions }));
|
|
2998
3103
|
app.get("*", (context) => context.text("\u62A5\u544A UI \u5C1A\u672A\u6784\u5EFA\uFF1A\u8BF7\u5148\u8FD0\u884C pnpm build", 404));
|
|
2999
3104
|
return app;
|
|
@@ -3023,44 +3128,44 @@ async function startWorkbench(options) {
|
|
|
3023
3128
|
|
|
3024
3129
|
// packages/service/src/init.ts
|
|
3025
3130
|
import { mkdir as mkdir3, readFile as readFile13, stat as stat4, writeFile as writeFile3 } from "node:fs/promises";
|
|
3026
|
-
import
|
|
3131
|
+
import path34 from "node:path";
|
|
3027
3132
|
async function initProject(directory) {
|
|
3028
|
-
const root =
|
|
3133
|
+
const root = path34.resolve(directory);
|
|
3029
3134
|
await mkdir3(root, { recursive: true });
|
|
3030
3135
|
const messages = [];
|
|
3031
3136
|
async function create(file, content) {
|
|
3032
3137
|
try {
|
|
3033
3138
|
await writeFile3(file, content, { flag: "wx" });
|
|
3034
|
-
messages.push(`\u5DF2\u521B\u5EFA ${
|
|
3139
|
+
messages.push(`\u5DF2\u521B\u5EFA ${path34.relative(root, file)}`);
|
|
3035
3140
|
} catch (error) {
|
|
3036
3141
|
if (error.code !== "EEXIST") throw error;
|
|
3037
|
-
messages.push(`\u5DF2\u4FDD\u7559 ${
|
|
3142
|
+
messages.push(`\u5DF2\u4FDD\u7559 ${path34.relative(root, file)}`);
|
|
3038
3143
|
}
|
|
3039
3144
|
}
|
|
3040
3145
|
const skill = await readFile13(
|
|
3041
|
-
|
|
3146
|
+
path34.resolve(import.meta.dirname, "../../../skills/evidra/SKILL.md"),
|
|
3042
3147
|
"utf8"
|
|
3043
3148
|
);
|
|
3044
3149
|
let injected = false;
|
|
3045
3150
|
for (const agent of [".claude", ".codex"]) {
|
|
3046
3151
|
let exists = false;
|
|
3047
3152
|
try {
|
|
3048
|
-
exists = (await stat4(
|
|
3153
|
+
exists = (await stat4(path34.join(root, agent))).isDirectory();
|
|
3049
3154
|
} catch (error) {
|
|
3050
3155
|
if (error.code !== "ENOENT") throw error;
|
|
3051
3156
|
}
|
|
3052
3157
|
if (!exists) continue;
|
|
3053
3158
|
injected = true;
|
|
3054
|
-
const target =
|
|
3159
|
+
const target = path34.join(root, agent, "skills/evidra");
|
|
3055
3160
|
await mkdir3(target, { recursive: true });
|
|
3056
|
-
await create(
|
|
3161
|
+
await create(path34.join(target, "SKILL.md"), skill);
|
|
3057
3162
|
}
|
|
3058
3163
|
if (!injected) messages.push("\u672A\u53D1\u73B0 .claude \u6216 .codex \u6587\u4EF6\u5939\uFF0C\u672A\u6CE8\u5165\u4EFB\u4F55 skill\u3002");
|
|
3059
3164
|
return messages;
|
|
3060
3165
|
}
|
|
3061
3166
|
|
|
3062
3167
|
// packages/conformance/runner/cli.ts
|
|
3063
|
-
import
|
|
3168
|
+
import path35 from "node:path";
|
|
3064
3169
|
|
|
3065
3170
|
// packages/conformance/runner/run.ts
|
|
3066
3171
|
async function runner(common, tasks) {
|
|
@@ -3099,14 +3204,14 @@ function printResults(results) {
|
|
|
3099
3204
|
async function runConformance(directory) {
|
|
3100
3205
|
const config = await loadConformanceConfig(directory);
|
|
3101
3206
|
if (!config)
|
|
3102
|
-
throw new Error(`\u65E0\u6CD5\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6\uFF1A${
|
|
3207
|
+
throw new Error(`\u65E0\u6CD5\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6\uFF1A${path35.resolve(directory, "evidra.conformance.ts")}`);
|
|
3103
3208
|
return printResults(await runner({ projectRoot: config.projectRoot }, config.rules));
|
|
3104
3209
|
}
|
|
3105
3210
|
|
|
3106
3211
|
// packages/service/src/cli.ts
|
|
3107
3212
|
var cli = cac("evidra");
|
|
3108
3213
|
cli.command("init [path]", "\u590D\u5236 skill \u5230\u9879\u76EE\uFF0C\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55").action(async (target) => {
|
|
3109
|
-
const root =
|
|
3214
|
+
const root = path36.resolve(target ?? process.cwd());
|
|
3110
3215
|
console.log(`\u521D\u59CB\u5316 Evidra\uFF1A${root}`);
|
|
3111
3216
|
for (const message of await initProject(root)) console.log(message);
|
|
3112
3217
|
});
|
|
@@ -3115,14 +3220,14 @@ cli.command("start", "\u542F\u52A8\u5DE5\u4F5C\u53F0\uFF0C\u670D\u52A1\u5728\u52
|
|
|
3115
3220
|
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
3116
3221
|
throw new Error("\u7AEF\u53E3\u5FC5\u987B\u662F 1\u201365535 \u7684\u6574\u6570");
|
|
3117
3222
|
await startWorkbench({
|
|
3118
|
-
repoRoot:
|
|
3223
|
+
repoRoot: path36.resolve(options.repo ?? process.env.TEST_REPORT_REPO ?? process.cwd()),
|
|
3119
3224
|
port
|
|
3120
3225
|
});
|
|
3121
3226
|
});
|
|
3122
3227
|
cli.command("compare", "\u8C03\u7528 core \u6BD4\u8F83\u4EFB\u52A1\u548C\u57FA\u7EBF\uFF0C\u8F93\u51FA summary").option("--repo <path>", "\u4ED3\u5E93\u8DEF\u5F84\uFF0C\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55").option("--task-id <id>", "\u4EFB\u52A1 ID").option("--full", "\u8F93\u51FA\u5B8C\u6574\u6BD4\u8F83\u7ED3\u679C").action(async (options) => {
|
|
3123
3228
|
if (!options.taskId) throw new Error("\u8BF7\u63D0\u4F9B --task-id");
|
|
3124
3229
|
const result = await compareTask({
|
|
3125
|
-
repoRoot:
|
|
3230
|
+
repoRoot: path36.resolve(options.repo ?? process.cwd()),
|
|
3126
3231
|
taskId: options.taskId
|
|
3127
3232
|
});
|
|
3128
3233
|
console.log(JSON.stringify(options.full ? result : result.summary, null, 2));
|
|
@@ -3132,7 +3237,7 @@ cli.command("compare-tasks", "\u6BD4\u8F83\u4E24\u4E2A\u4EFB\u52A1\u7684\u7528\u
|
|
|
3132
3237
|
if (!options.baseTaskId) throw new Error("\u8BF7\u63D0\u4F9B --base-task-id");
|
|
3133
3238
|
if (!options.taskId) throw new Error("\u8BF7\u63D0\u4F9B --task-id");
|
|
3134
3239
|
const result = await compareTasks({
|
|
3135
|
-
repoRoot:
|
|
3240
|
+
repoRoot: path36.resolve(options.repo ?? process.cwd()),
|
|
3136
3241
|
baseTaskId: options.baseTaskId,
|
|
3137
3242
|
taskId: options.taskId
|
|
3138
3243
|
});
|