@hamsterbase/evidra 0.7.1 → 0.8.0
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/service/cli.js +87 -9
- package/dist/web/assets/ProjectFileEditor-Bj-zatE8.js +90 -0
- package/dist/web/assets/ProjectFileEditor-VWaF-pTR.css +1 -0
- package/dist/web/assets/{cssMode-DLjojEX5.js → cssMode-Ddm6t3hn.js} +1 -1
- package/dist/web/assets/{editor.api-Cm8Jz3Ng.js → editor.api-yZNZ6nfl.js} +1 -1
- package/dist/web/assets/{freemarker2-ffO1wPRi.js → freemarker2-40SJX8wo.js} +1 -1
- package/dist/web/assets/{handlebars-B67yYAds.js → handlebars-ePjrLNPj.js} +1 -1
- package/dist/web/assets/{html-D4vuTio3.js → html-Ban_vpfh.js} +1 -1
- package/dist/web/assets/{htmlMode-Nau5A2BZ.js → htmlMode-BCUcamg2.js} +1 -1
- package/dist/web/assets/{index-DuyTRx9x.js → index-CjCPtr-V.js} +2 -2
- package/dist/web/assets/{javascript-j7PBySIN.js → javascript-CgwRLo5g.js} +1 -1
- package/dist/web/assets/{jsonMode-Dlcb-cLx.js → jsonMode-B8YN4550.js} +1 -1
- package/dist/web/assets/{liquid-DSGlvFRw.js → liquid-UnWzywQQ.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-DUpjT3Ad.js → lspLanguageFeatures-BAW51YOF.js} +1 -1
- package/dist/web/assets/main-Q3SeTusg.js +18 -0
- package/dist/web/assets/main-XYcKXGAp.css +2 -0
- package/dist/web/assets/main-hMTc347O.js +26 -0
- package/dist/web/assets/{mdx-BjjEiDsC.js → mdx-CscOfs_k.js} +1 -1
- package/dist/web/assets/{monaco-3fFILk_i.js → monaco-Dm9HqR-J.js} +4 -4
- package/dist/web/assets/{python-dNdKGm1p.js → python-CIi17zKW.js} +1 -1
- package/dist/web/assets/{razor-CATEbAgj.js → razor-5IWiTO5L.js} +1 -1
- package/dist/web/assets/{tsMode-BULlPLGv.js → tsMode-DgCKsYcC.js} +1 -1
- package/dist/web/assets/{typescript-Cwd0ePfj.js → typescript-CrunxCxj.js} +1 -1
- package/dist/web/assets/{workers-C57gUq9G.js → workers-CyBhaDDH.js} +1 -1
- package/dist/web/assets/{xml-DjQsY_vM.js → xml-DfdbA7Uf.js} +1 -1
- package/dist/web/assets/{yaml-BOOR4cPJ.js → yaml-2wU2J7hs.js} +1 -1
- package/dist/web/index.html +12 -3
- package/package.json +1 -1
- package/skills/evidra/SKILL.md +4 -0
- package/dist/web/assets/ProjectFileEditor-Drd5hhbo.js +0 -90
- package/dist/web/assets/ProjectFileEditor-uqf4b7Mq.css +0 -1
- package/dist/web/assets/main-DKZIIy2T.css +0 -2
- package/dist/web/assets/main-IQ1sFdJO.js +0 -26
- package/dist/web/assets/main-rJTrPQRY.js +0 -18
package/dist/service/cli.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// packages/service/src/cli.ts
|
|
2
2
|
import { cac } from "cac";
|
|
3
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
3
4
|
import path36 from "node:path";
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
4
6
|
|
|
5
7
|
// modules/core/implementations/Functions/resolveConfig.ts
|
|
6
8
|
import path3 from "node:path";
|
|
@@ -2732,6 +2734,8 @@ import process2 from "node:process";
|
|
|
2732
2734
|
import { serve } from "@hono/node-server";
|
|
2733
2735
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
2734
2736
|
import { Hono as Hono2 } from "hono";
|
|
2737
|
+
import { csrf } from "hono/csrf";
|
|
2738
|
+
import { HTTPException } from "hono/http-exception";
|
|
2735
2739
|
import { existsSync as existsSync2 } from "node:fs";
|
|
2736
2740
|
import { stat as stat3 } from "node:fs/promises";
|
|
2737
2741
|
import path33 from "node:path";
|
|
@@ -2863,6 +2867,44 @@ function createConformanceRoutes(root) {
|
|
|
2863
2867
|
return app;
|
|
2864
2868
|
}
|
|
2865
2869
|
|
|
2870
|
+
// packages/service/src/reportSession.ts
|
|
2871
|
+
import { createHash as createHash4, randomBytes, timingSafeEqual } from "node:crypto";
|
|
2872
|
+
import { getCookie, setCookie } from "hono/cookie";
|
|
2873
|
+
|
|
2874
|
+
// packages/client-sdk/src/error.ts
|
|
2875
|
+
var REPORT_PASSWORD_REQUIRED = "REPORT_PASSWORD_REQUIRED";
|
|
2876
|
+
var REPORT_PASSWORD_INVALID = "REPORT_PASSWORD_INVALID";
|
|
2877
|
+
|
|
2878
|
+
// packages/service/src/reportSession.ts
|
|
2879
|
+
function createReportSession(password) {
|
|
2880
|
+
const passwordHash = createHash4("sha256").update(password).digest();
|
|
2881
|
+
const token = randomBytes(32).toString("base64url");
|
|
2882
|
+
const cookieName = (context) => `evidra_session_${new URL(context.req.url).port || "default"}`;
|
|
2883
|
+
const requireSession = async (context, next) => {
|
|
2884
|
+
if (getCookie(context, cookieName(context)) !== token) {
|
|
2885
|
+
context.header("Cache-Control", "no-store");
|
|
2886
|
+
return context.json({ code: REPORT_PASSWORD_REQUIRED, error: "\u8BF7\u8F93\u5165\u62A5\u544A\u5BC6\u7801" }, 401);
|
|
2887
|
+
}
|
|
2888
|
+
await next();
|
|
2889
|
+
};
|
|
2890
|
+
async function login(context) {
|
|
2891
|
+
if (context.req.header("Content-Type")?.split(";")[0]?.trim().toLowerCase() !== "application/json")
|
|
2892
|
+
return context.json({ error: "\u8BF7\u4F7F\u7528 JSON \u63D0\u4EA4\u5BC6\u7801" }, 415);
|
|
2893
|
+
const body = await context.req.json().catch(() => null);
|
|
2894
|
+
if (typeof body?.password !== "string" || !timingSafeEqual(createHash4("sha256").update(body.password).digest(), passwordHash)) {
|
|
2895
|
+
return context.json({ code: REPORT_PASSWORD_INVALID, error: "\u5BC6\u7801\u9519\u8BEF\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\u3002" }, 401);
|
|
2896
|
+
}
|
|
2897
|
+
setCookie(context, cookieName(context), token, {
|
|
2898
|
+
httpOnly: true,
|
|
2899
|
+
sameSite: "Strict",
|
|
2900
|
+
secure: new URL(context.req.url).protocol === "https:",
|
|
2901
|
+
path: "/"
|
|
2902
|
+
});
|
|
2903
|
+
return context.body(null, 204);
|
|
2904
|
+
}
|
|
2905
|
+
return { login, requireSession };
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2866
2908
|
// packages/service/src/server.ts
|
|
2867
2909
|
function defaultWebDist() {
|
|
2868
2910
|
const fromSource = path33.resolve(import.meta.dirname, "../../../dist/web");
|
|
@@ -2873,7 +2915,8 @@ async function startServer(options) {
|
|
|
2873
2915
|
const root = path33.resolve(options.repoRoot);
|
|
2874
2916
|
await loadConfig({ repoRoot: root });
|
|
2875
2917
|
const webDist = options.webDist ?? defaultWebDist();
|
|
2876
|
-
|
|
2918
|
+
if (options.password === "") throw new Error("\u62A5\u544A\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A");
|
|
2919
|
+
const app = createApp(root, webDist, options.password);
|
|
2877
2920
|
let server;
|
|
2878
2921
|
const address = await new Promise((resolve, reject) => {
|
|
2879
2922
|
server = serve(
|
|
@@ -2911,9 +2954,10 @@ function projectFileError(error) {
|
|
|
2911
2954
|
throw new Error("\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6\u6216\u76EE\u5F55\u3002");
|
|
2912
2955
|
}
|
|
2913
2956
|
}
|
|
2914
|
-
function createApp(root, webDist) {
|
|
2957
|
+
function createApp(root, webDist, password) {
|
|
2915
2958
|
const app = new Hono2();
|
|
2916
2959
|
app.onError((error, context) => {
|
|
2960
|
+
if (error instanceof HTTPException) return context.json({ error: error.message }, error.status);
|
|
2917
2961
|
const status = error instanceof z28.ZodError ? 400 : error.statusCode ?? 500;
|
|
2918
2962
|
return context.json({ error: String(error.message ?? error) }, status);
|
|
2919
2963
|
});
|
|
@@ -2921,6 +2965,13 @@ function createApp(root, webDist) {
|
|
|
2921
2965
|
context.header("Cache-Control", "no-store");
|
|
2922
2966
|
await next();
|
|
2923
2967
|
});
|
|
2968
|
+
if (password !== void 0) {
|
|
2969
|
+
const session = createReportSession(password);
|
|
2970
|
+
app.post("/api/session", session.login);
|
|
2971
|
+
app.use("/api/*", session.requireSession);
|
|
2972
|
+
app.use("/api/*", csrf());
|
|
2973
|
+
app.use("/report-static/*", session.requireSession);
|
|
2974
|
+
}
|
|
2924
2975
|
app.get(
|
|
2925
2976
|
"/api/project",
|
|
2926
2977
|
async (context) => context.json(await readProjectInfo({ repoRoot: root }))
|
|
@@ -3059,8 +3110,16 @@ function createApp(root, webDist) {
|
|
|
3059
3110
|
`W/"${stats.size.toString(16)}-${stats.mtimeMs.toString(16)}-${stats.ctimeMs.toString(16)}"`
|
|
3060
3111
|
);
|
|
3061
3112
|
const relativePath = path33.relative(webDist, filePath).split(path33.sep).join("/");
|
|
3062
|
-
const
|
|
3063
|
-
|
|
3113
|
+
const reportFile = context.req.path.startsWith("/report-static/");
|
|
3114
|
+
if (reportFile && password !== void 0) {
|
|
3115
|
+
context.header("Cache-Control", "private, no-cache");
|
|
3116
|
+
} else {
|
|
3117
|
+
const immutable = reportFile ? /(?:^|[-/])[a-f0-9]{64}\.png$/.test(context.req.path) : /^assets\/.+-[\w-]{8,}\.[\w.]+$/.test(relativePath);
|
|
3118
|
+
context.header(
|
|
3119
|
+
"Cache-Control",
|
|
3120
|
+
immutable ? "public, max-age=31536000, immutable" : "no-cache"
|
|
3121
|
+
);
|
|
3122
|
+
}
|
|
3064
3123
|
if (context.res.status !== 200 || !["GET", "HEAD"].includes(context.req.method)) return;
|
|
3065
3124
|
const etag = context.res.headers.get("ETag");
|
|
3066
3125
|
if (!etag) return;
|
|
@@ -3106,13 +3165,13 @@ function createApp(root, webDist) {
|
|
|
3106
3165
|
|
|
3107
3166
|
// packages/service/src/index.ts
|
|
3108
3167
|
async function startWorkbench(options) {
|
|
3109
|
-
const {
|
|
3110
|
-
const server = await startServer({ repoRoot, port, host: "0.0.0.0" });
|
|
3168
|
+
const server = await startServer({ ...options, host: "0.0.0.0" });
|
|
3111
3169
|
console.log(`
|
|
3112
3170
|
\u6D4B\u8BD5\u62A5\u544A\u670D\u52A1\u5DF2\u542F\u52A8`);
|
|
3113
|
-
console.log(`\u4ED3\u5E93: ${repoRoot}`);
|
|
3171
|
+
console.log(`\u4ED3\u5E93: ${options.repoRoot}`);
|
|
3114
3172
|
console.log(`\u5730\u5740: ${server.url}`);
|
|
3115
3173
|
console.log(`\u9875\u9762: ${server.url}/`);
|
|
3174
|
+
if (options.password !== void 0) console.log(`\u5BC6\u7801: ${options.password}`);
|
|
3116
3175
|
console.log(`\u505C\u6B62: Ctrl+C
|
|
3117
3176
|
`);
|
|
3118
3177
|
let stopping = false;
|
|
@@ -3210,18 +3269,37 @@ async function runConformance(directory) {
|
|
|
3210
3269
|
|
|
3211
3270
|
// packages/service/src/cli.ts
|
|
3212
3271
|
var cli = cac("evidra");
|
|
3272
|
+
function startPassword() {
|
|
3273
|
+
const { tokens } = parseArgs({
|
|
3274
|
+
strict: false,
|
|
3275
|
+
allowPositionals: true,
|
|
3276
|
+
tokens: true,
|
|
3277
|
+
options: { repo: { type: "string" }, port: { type: "string" } }
|
|
3278
|
+
});
|
|
3279
|
+
let password;
|
|
3280
|
+
for (const [index, token] of tokens.entries()) {
|
|
3281
|
+
if (token.kind !== "option") continue;
|
|
3282
|
+
if (!cli.matchedCommand?.hasOption(token.name)) throw new Error(`\u672A\u77E5\u53C2\u6570\uFF1A${token.rawName}`);
|
|
3283
|
+
if (token.name !== "password") continue;
|
|
3284
|
+
if (password !== void 0) throw new Error("\u8BF7\u53EA\u6307\u5B9A\u4E00\u6B21 --password");
|
|
3285
|
+
const next = tokens[index + 1];
|
|
3286
|
+
password = token.value ?? (next?.kind === "positional" ? next.value : randomBytes2(16).toString("base64url"));
|
|
3287
|
+
}
|
|
3288
|
+
return password;
|
|
3289
|
+
}
|
|
3213
3290
|
cli.command("init [path]", "\u590D\u5236 skill \u5230\u9879\u76EE\uFF0C\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55").action(async (target) => {
|
|
3214
3291
|
const root = path36.resolve(target ?? process.cwd());
|
|
3215
3292
|
console.log(`\u521D\u59CB\u5316 Evidra\uFF1A${root}`);
|
|
3216
3293
|
for (const message of await initProject(root)) console.log(message);
|
|
3217
3294
|
});
|
|
3218
|
-
cli.command("start", "\u542F\u52A8\u5DE5\u4F5C\u53F0\uFF0C\u670D\u52A1\u5728\u524D\u53F0\u8FD0\u884C\uFF0C\u6309 Ctrl+C \u505C\u6B62").option("--repo <path>", "\u4ED3\u5E93\u8DEF\u5F84\uFF0C\u9ED8\u8BA4 TEST_REPORT_REPO \u6216\u5F53\u524D\u76EE\u5F55").option("--port <port>", "\u7AEF\u53E3\uFF0C\u9ED8\u8BA4 TEST_REPORT_PORT \u6216 4175").action(async (options) => {
|
|
3295
|
+
cli.command("start", "\u542F\u52A8\u5DE5\u4F5C\u53F0\uFF0C\u670D\u52A1\u5728\u524D\u53F0\u8FD0\u884C\uFF0C\u6309 Ctrl+C \u505C\u6B62").option("--repo <path>", "\u4ED3\u5E93\u8DEF\u5F84\uFF0C\u9ED8\u8BA4 TEST_REPORT_REPO \u6216\u5F53\u524D\u76EE\u5F55").option("--port <port>", "\u7AEF\u53E3\uFF0C\u9ED8\u8BA4 TEST_REPORT_PORT \u6216 4175").option("--password [value]", "\u542F\u7528\u62A5\u544A\u5BC6\u7801\u4FDD\u62A4\uFF0C\u7701\u7565\u503C\u65F6\u968F\u673A\u751F\u6210\uFF1B\u9ED8\u8BA4\u514D\u5BC6").action(async (options) => {
|
|
3219
3296
|
const port = Number(options.port ?? process.env.TEST_REPORT_PORT ?? "4175");
|
|
3220
3297
|
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
3221
3298
|
throw new Error("\u7AEF\u53E3\u5FC5\u987B\u662F 1\u201365535 \u7684\u6574\u6570");
|
|
3222
3299
|
await startWorkbench({
|
|
3223
3300
|
repoRoot: path36.resolve(options.repo ?? process.env.TEST_REPORT_REPO ?? process.cwd()),
|
|
3224
|
-
port
|
|
3301
|
+
port,
|
|
3302
|
+
password: startPassword()
|
|
3225
3303
|
});
|
|
3226
3304
|
});
|
|
3227
3305
|
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) => {
|