@xrkseek/harness 0.2.2 → 0.2.4
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/node_modules/@xrkseek/core-tools/dist/subagent-prompt.d.ts +2 -2
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js +5 -6
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts +5 -0
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.js +21 -8
- package/node_modules/@xrkseek/preset-harness/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-minimal/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-server/dist/preset.d.ts +1 -0
- package/node_modules/@xrkseek/preset-server/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-server/dist/preset.js +12 -2
- package/node_modules/@xrkseek/preset-server/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-server/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-server/package.json +1 -0
- package/node_modules/@xrkseek/server-config/dist/index.d.ts +5 -1
- package/node_modules/@xrkseek/server-config/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-config/dist/index.js +15 -3
- package/node_modules/@xrkseek/server-config/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/catalog.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/catalog.js +15 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/catalog.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/session.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/session.js +8 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/session.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.js +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/presets-catalog.d.ts +51 -6
- package/node_modules/@xrkseek/server-face/dist/presets-catalog.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/presets-catalog.js +110 -10
- package/node_modules/@xrkseek/server-face/dist/presets-catalog.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +2 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/slash.d.ts +4 -0
- package/node_modules/@xrkseek/server-face/dist/slash.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/slash.js +14 -2
- package/node_modules/@xrkseek/server-face/dist/slash.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts +7 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.js +27 -7
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.js +26 -7
- package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js +4 -111
- package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/sidebar-live-line.d.ts +9 -0
- package/node_modules/@xrkseek/server-host/dist/sidebar-live-line.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-host/dist/sidebar-live-line.js +43 -0
- package/node_modules/@xrkseek/server-host/dist/sidebar-live-line.js.map +1 -0
- package/node_modules/@xrkseek/server-host/dist/standing-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/standing-tools.js +11 -4
- package/node_modules/@xrkseek/server-host/dist/standing-tools.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.js +0 -21
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-types.d.ts +3 -2
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-types.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/bundle-chunk-stub.d.ts +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/bundle-chunk-stub.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/bundle-chunk-stub.js +7 -5
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/bundle-chunk-stub.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-compat-matrix.js +3 -3
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-compat-matrix.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-path-capabilities.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-path-capabilities.js +0 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-path-capabilities.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.d.ts +2 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.js +1 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/index.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-face-bridge.d.ts +18 -7
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/sidebar-face-bridge.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/turn-rewind-workspace.js +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/turn-rewind-workspace.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/turn-rewind.d.ts +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/turn-rewind.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/index.d.ts +2 -1
- package/node_modules/@xrkseek/server-http/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/index.js +1 -0
- package/node_modules/@xrkseek/server-http/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/sidebar/bundle-chunk-stub.d.ts +21 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/bundle-chunk-stub.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/bundle-chunk-stub.js +123 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/bundle-chunk-stub.js.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/index.d.ts +20 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/index.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/index.js +27 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/index.js.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.d.ts +19 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.js +495 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.js.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-browser.d.ts +3 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-browser.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-browser.js +82 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-browser.js.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-face-bridge.d.ts +41 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-face-bridge.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-face-bridge.js +2 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-face-bridge.js.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-git.d.ts +59 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-git.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-git.js +197 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-git.js.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-html.d.ts +20 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-html.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-html.js +135 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-html.js.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-prefs-store.d.ts +9 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-prefs-store.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-prefs-store.js +57 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-prefs-store.js.map +1 -0
- package/node_modules/@xrkseek/server-http/package.json +5 -0
- package/node_modules/@xrkseek/workspace/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/workspace/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/index.js +1 -1
- package/node_modules/@xrkseek/workspace/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/recipes.d.ts +2 -0
- package/node_modules/@xrkseek/workspace/dist/recipes.d.ts.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/recipes.js +9 -0
- package/node_modules/@xrkseek/workspace/dist/recipes.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* better-sidebar embedded browser probe — HEAD/GET remote URL headers.
|
|
3
|
+
*/
|
|
4
|
+
import { request as httpRequest } from "node:http";
|
|
5
|
+
import { request as httpsRequest } from "node:https";
|
|
6
|
+
const PROBE_TIMEOUT_MS = 8_000;
|
|
7
|
+
function parseFrameAncestors(csp) {
|
|
8
|
+
if (!csp)
|
|
9
|
+
return undefined;
|
|
10
|
+
const match = /frame-ancestors\s+([^;]+)/i.exec(csp);
|
|
11
|
+
if (!match?.[1])
|
|
12
|
+
return undefined;
|
|
13
|
+
return match[1]
|
|
14
|
+
.trim()
|
|
15
|
+
.split(/\s+/)
|
|
16
|
+
.map((s) => s.replace(/['"]/g, ""))
|
|
17
|
+
.filter(Boolean);
|
|
18
|
+
}
|
|
19
|
+
function probeOnce(url) {
|
|
20
|
+
const transport = url.protocol === "https:" ? httpsRequest : httpRequest;
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
const req = transport(url, { method: "HEAD", timeout: PROBE_TIMEOUT_MS }, (res) => {
|
|
23
|
+
res.resume();
|
|
24
|
+
const out = { reachable: true };
|
|
25
|
+
const xfo = res.headers["x-frame-options"];
|
|
26
|
+
if (typeof xfo === "string")
|
|
27
|
+
out.xFrameOptions = xfo;
|
|
28
|
+
const fa = parseFrameAncestors(res.headers["content-security-policy"]);
|
|
29
|
+
if (fa)
|
|
30
|
+
out.frameAncestors = fa;
|
|
31
|
+
resolve(out);
|
|
32
|
+
});
|
|
33
|
+
req.on("timeout", () => {
|
|
34
|
+
req.destroy();
|
|
35
|
+
resolve({ reachable: false });
|
|
36
|
+
});
|
|
37
|
+
req.on("error", () => resolve({ reachable: false }));
|
|
38
|
+
req.end();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** Probe embeddability headers for better-sidebar browser tabs. */
|
|
42
|
+
export async function probeBrowserUrl(rawUrl) {
|
|
43
|
+
const trimmed = rawUrl.trim();
|
|
44
|
+
if (!trimmed) {
|
|
45
|
+
return { reachable: false, supported: false, reason: "empty-url" };
|
|
46
|
+
}
|
|
47
|
+
let url;
|
|
48
|
+
try {
|
|
49
|
+
url = new URL(trimmed);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return { reachable: false, supported: false, reason: "invalid-url" };
|
|
53
|
+
}
|
|
54
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
55
|
+
return { reachable: false, supported: false, reason: "unsupported-scheme" };
|
|
56
|
+
}
|
|
57
|
+
const head = await probeOnce(url);
|
|
58
|
+
if (!head.reachable && url.protocol === "https:") {
|
|
59
|
+
const get = await new Promise((resolve) => {
|
|
60
|
+
const req = httpsRequest(url, { method: "GET", timeout: PROBE_TIMEOUT_MS }, (res) => {
|
|
61
|
+
res.resume();
|
|
62
|
+
const out = { reachable: true };
|
|
63
|
+
const xfo = res.headers["x-frame-options"];
|
|
64
|
+
if (typeof xfo === "string")
|
|
65
|
+
out.xFrameOptions = xfo;
|
|
66
|
+
const fa = parseFrameAncestors(res.headers["content-security-policy"]);
|
|
67
|
+
if (fa)
|
|
68
|
+
out.frameAncestors = fa;
|
|
69
|
+
resolve(out);
|
|
70
|
+
});
|
|
71
|
+
req.on("timeout", () => {
|
|
72
|
+
req.destroy();
|
|
73
|
+
resolve({ reachable: false });
|
|
74
|
+
});
|
|
75
|
+
req.on("error", () => resolve({ reachable: false }));
|
|
76
|
+
req.end();
|
|
77
|
+
});
|
|
78
|
+
return { ...get, supported: true, url: url.toString() };
|
|
79
|
+
}
|
|
80
|
+
return { ...head, supported: true, url: url.toString() };
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=sidebar-browser.js.map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CAAC;YACrD,GAAG,CAAC,GAAG,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,GAAG,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native Host Face bridge contract for `/sidebar/*`.
|
|
3
|
+
* Implementation: `@xrkseek/server-host` (`createSidebarFaceBridgeFromFace`).
|
|
4
|
+
* Client: `xrkh-better-sidebar` (kind: client only).
|
|
5
|
+
*/
|
|
6
|
+
export type SidebarSubagentLiveActivity = {
|
|
7
|
+
readonly text?: string;
|
|
8
|
+
readonly tool?: {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly args: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export interface SidebarFaceBridge {
|
|
14
|
+
readonly openExternal: (payload: {
|
|
15
|
+
action: "reveal" | "url";
|
|
16
|
+
path?: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
}) => Promise<{
|
|
19
|
+
ok: true;
|
|
20
|
+
}>;
|
|
21
|
+
readonly readJobOutput?: (jobId: string) => {
|
|
22
|
+
text: string;
|
|
23
|
+
truncated?: boolean;
|
|
24
|
+
};
|
|
25
|
+
readonly killJob?: (jobId: string, reason?: string) => Promise<{
|
|
26
|
+
ok: boolean;
|
|
27
|
+
killed: boolean;
|
|
28
|
+
reason?: string;
|
|
29
|
+
}>;
|
|
30
|
+
readonly forkSessionAt?: (sessionId: string, beforeSeq: number) => Promise<{
|
|
31
|
+
sessionId: string;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Running-child live lines for `POST /sidebar/api/subagents.live`.
|
|
35
|
+
* Wire: nested `tool` (`LastActivity` / {@link SidebarSubagentLiveActivity}).
|
|
36
|
+
*/
|
|
37
|
+
readonly listSubagentsLive?: (rootSessionId: string) => Promise<{
|
|
38
|
+
readonly live: Readonly<Record<string, SidebarSubagentLiveActivity>>;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=sidebar-face-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-face-bridge.d.ts","sourceRoot":"","sources":["../../src/sidebar/sidebar-face-bridge.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAClE,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE;QAC/B,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,CACvB,KAAK,EAAE,MAAM,KACV;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,CACjB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,KACZ,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,QAAQ,CAAC,aAAa,CAAC,EAAE,CACvB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,KACd,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAC3B,aAAa,EAAE,MAAM,KAClB,OAAO,CAAC;QACX,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC,CAAC;KACtE,CAAC,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-face-bridge.js","sourceRoot":"","sources":["../../src/sidebar/sidebar-face-bridge.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export interface GitStatusEntry {
|
|
2
|
+
/** Porcelain XY pair — client reads `entry.xy[0]` / `entry.xy[1]`. */
|
|
3
|
+
readonly xy: string;
|
|
4
|
+
/** First porcelain char (index); kept for internal rewind helpers. */
|
|
5
|
+
readonly index: string;
|
|
6
|
+
/** Second porcelain char (worktree). */
|
|
7
|
+
readonly worktree: string;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function gitStatus(cwd: string): {
|
|
11
|
+
available: boolean;
|
|
12
|
+
branch: string | null;
|
|
13
|
+
entries: GitStatusEntry[];
|
|
14
|
+
};
|
|
15
|
+
/** Client expects `{ current, names }` (not `branches`). */
|
|
16
|
+
export declare function gitBranches(cwd: string): {
|
|
17
|
+
available: boolean;
|
|
18
|
+
current: string;
|
|
19
|
+
names: string[];
|
|
20
|
+
};
|
|
21
|
+
export interface GitLogEntry {
|
|
22
|
+
readonly hash: string;
|
|
23
|
+
readonly hashFull: string;
|
|
24
|
+
readonly subject: string;
|
|
25
|
+
readonly author: string;
|
|
26
|
+
readonly date: string;
|
|
27
|
+
readonly refs: string;
|
|
28
|
+
}
|
|
29
|
+
/** Client expects a bare array (not `{ entries }`). */
|
|
30
|
+
export declare function gitLog(cwd: string, limit?: number, skip?: number): GitLogEntry[];
|
|
31
|
+
export declare function gitDiff(cwd: string, filePath: string | undefined, staged: boolean): {
|
|
32
|
+
diff: string;
|
|
33
|
+
};
|
|
34
|
+
export declare function gitCommitDiff(cwd: string, hash: string): {
|
|
35
|
+
diff: string;
|
|
36
|
+
};
|
|
37
|
+
export declare function gitStage(cwd: string, filePath?: string): {
|
|
38
|
+
ok: true;
|
|
39
|
+
};
|
|
40
|
+
export declare function gitUnstage(cwd: string, filePath?: string): {
|
|
41
|
+
ok: true;
|
|
42
|
+
};
|
|
43
|
+
export declare function gitCommit(cwd: string, message: string): {
|
|
44
|
+
ok: true;
|
|
45
|
+
hash?: string;
|
|
46
|
+
};
|
|
47
|
+
export declare function gitCheckout(cwd: string, branch: string): {
|
|
48
|
+
ok: true;
|
|
49
|
+
};
|
|
50
|
+
export declare function gitDiscard(cwd: string, filePath: string): {
|
|
51
|
+
ok: true;
|
|
52
|
+
};
|
|
53
|
+
export declare function gitRevert(cwd: string, hash: string): {
|
|
54
|
+
ok: true;
|
|
55
|
+
};
|
|
56
|
+
export declare function gitCherryPick(cwd: string, hash: string): {
|
|
57
|
+
ok: true;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=sidebar-git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-git.d.ts","sourceRoot":"","sources":["../../src/sidebar/sidebar-git.ts"],"names":[],"mappings":"AA2CA,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,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,IAAI,CAAA;CAAE,CAQvE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAOnF;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAMrE;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAYtE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAIjE;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAIrE"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git helpers for dsh-better-sidebar (workspace-scoped, best-effort).
|
|
3
|
+
* Wire shapes match the community client (`xy`, `names`, log array, `{ diff }`).
|
|
4
|
+
*/
|
|
5
|
+
import { execFileSync } from "node:child_process";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
function isGitRepo(cwd) {
|
|
9
|
+
return existsSync(path.join(cwd, ".git"));
|
|
10
|
+
}
|
|
11
|
+
function runGit(cwd, args, options = {}) {
|
|
12
|
+
try {
|
|
13
|
+
return execFileSync("git", args, {
|
|
14
|
+
cwd,
|
|
15
|
+
encoding: "utf8",
|
|
16
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
17
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
18
|
+
}).trimEnd();
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
if (options.allowFail) {
|
|
22
|
+
const e = err;
|
|
23
|
+
const out = typeof e.stdout === "string" ? e.stdout.trimEnd() : "";
|
|
24
|
+
return out.length > 0 ? out : null;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function runGitOrThrow(cwd, args) {
|
|
30
|
+
return execFileSync("git", args, {
|
|
31
|
+
cwd,
|
|
32
|
+
encoding: "utf8",
|
|
33
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
34
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
35
|
+
}).trimEnd();
|
|
36
|
+
}
|
|
37
|
+
export function gitStatus(cwd) {
|
|
38
|
+
if (!isGitRepo(cwd)) {
|
|
39
|
+
return { available: false, branch: null, entries: [] };
|
|
40
|
+
}
|
|
41
|
+
const branch = runGit(cwd, ["branch", "--show-current"]);
|
|
42
|
+
const porcelain = runGit(cwd, ["status", "--porcelain", "-uall"]);
|
|
43
|
+
if (porcelain === null) {
|
|
44
|
+
return { available: false, branch, entries: [] };
|
|
45
|
+
}
|
|
46
|
+
const entries = [];
|
|
47
|
+
for (const line of porcelain.split(/\r?\n/)) {
|
|
48
|
+
if (line.length < 3)
|
|
49
|
+
continue;
|
|
50
|
+
const xy = line.slice(0, 2);
|
|
51
|
+
let filePath = line.slice(3);
|
|
52
|
+
// rename: "R old -> new"
|
|
53
|
+
const arrow = filePath.indexOf(" -> ");
|
|
54
|
+
if (arrow >= 0)
|
|
55
|
+
filePath = filePath.slice(arrow + 4);
|
|
56
|
+
filePath = filePath.replace(/^"|"$/g, "").trim();
|
|
57
|
+
if (!filePath)
|
|
58
|
+
continue;
|
|
59
|
+
entries.push({
|
|
60
|
+
xy,
|
|
61
|
+
index: xy[0] ?? " ",
|
|
62
|
+
worktree: xy[1] ?? " ",
|
|
63
|
+
path: filePath,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return { available: true, branch, entries };
|
|
67
|
+
}
|
|
68
|
+
/** Client expects `{ current, names }` (not `branches`). */
|
|
69
|
+
export function gitBranches(cwd) {
|
|
70
|
+
if (!isGitRepo(cwd)) {
|
|
71
|
+
return { available: false, current: "", names: [] };
|
|
72
|
+
}
|
|
73
|
+
const current = runGit(cwd, ["branch", "--show-current"]) ?? "";
|
|
74
|
+
const listed = runGit(cwd, ["branch", "--format=%(refname:short)"]);
|
|
75
|
+
const names = listed
|
|
76
|
+
? listed.split(/\r?\n/).map((b) => b.trim()).filter(Boolean)
|
|
77
|
+
: [];
|
|
78
|
+
return { available: true, current, names };
|
|
79
|
+
}
|
|
80
|
+
/** Client expects a bare array (not `{ entries }`). */
|
|
81
|
+
export function gitLog(cwd, limit = 20, skip = 0) {
|
|
82
|
+
if (!isGitRepo(cwd))
|
|
83
|
+
return [];
|
|
84
|
+
const max = Math.min(Math.max(limit, 1), 100);
|
|
85
|
+
const offset = Math.max(0, Math.floor(skip));
|
|
86
|
+
const out = runGit(cwd, [
|
|
87
|
+
"log",
|
|
88
|
+
`-n`,
|
|
89
|
+
String(max),
|
|
90
|
+
`--skip=${String(offset)}`,
|
|
91
|
+
"--pretty=format:%h%x00%H%x00%s%x00%an%x00%ar%x00%D",
|
|
92
|
+
]);
|
|
93
|
+
if (!out)
|
|
94
|
+
return [];
|
|
95
|
+
return out.split(/\r?\n/).flatMap((line) => {
|
|
96
|
+
const [hash, hashFull, subject, author, date, refs] = line.split("\0");
|
|
97
|
+
if (!hash || !hashFull)
|
|
98
|
+
return [];
|
|
99
|
+
return [
|
|
100
|
+
{
|
|
101
|
+
hash,
|
|
102
|
+
hashFull,
|
|
103
|
+
subject: subject ?? "",
|
|
104
|
+
author: author ?? "",
|
|
105
|
+
date: date ?? "",
|
|
106
|
+
refs: refs ?? "",
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
export function gitDiff(cwd, filePath, staged) {
|
|
112
|
+
if (!isGitRepo(cwd))
|
|
113
|
+
return { diff: "" };
|
|
114
|
+
const args = ["diff", "--no-color"];
|
|
115
|
+
if (staged)
|
|
116
|
+
args.push("--cached");
|
|
117
|
+
if (filePath?.trim())
|
|
118
|
+
args.push("--", filePath.trim());
|
|
119
|
+
const out = runGit(cwd, args, { allowFail: true });
|
|
120
|
+
return { diff: out ?? "" };
|
|
121
|
+
}
|
|
122
|
+
export function gitCommitDiff(cwd, hash) {
|
|
123
|
+
if (!isGitRepo(cwd) || !hash.trim())
|
|
124
|
+
return { diff: "" };
|
|
125
|
+
const out = runGit(cwd, ["show", "--no-color", "--format=", hash.trim()], { allowFail: true });
|
|
126
|
+
return { diff: out ?? "" };
|
|
127
|
+
}
|
|
128
|
+
export function gitStage(cwd, filePath) {
|
|
129
|
+
if (!isGitRepo(cwd))
|
|
130
|
+
throw new Error("not a git repository");
|
|
131
|
+
if (filePath?.trim()) {
|
|
132
|
+
runGitOrThrow(cwd, ["add", "--", filePath.trim()]);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
runGitOrThrow(cwd, ["add", "-A"]);
|
|
136
|
+
}
|
|
137
|
+
return { ok: true };
|
|
138
|
+
}
|
|
139
|
+
export function gitUnstage(cwd, filePath) {
|
|
140
|
+
if (!isGitRepo(cwd))
|
|
141
|
+
throw new Error("not a git repository");
|
|
142
|
+
if (filePath?.trim()) {
|
|
143
|
+
runGitOrThrow(cwd, ["restore", "--staged", "--", filePath.trim()]);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
runGitOrThrow(cwd, ["restore", "--staged", "."]);
|
|
147
|
+
}
|
|
148
|
+
return { ok: true };
|
|
149
|
+
}
|
|
150
|
+
export function gitCommit(cwd, message) {
|
|
151
|
+
if (!isGitRepo(cwd))
|
|
152
|
+
throw new Error("not a git repository");
|
|
153
|
+
const msg = message.trim();
|
|
154
|
+
if (!msg)
|
|
155
|
+
throw new Error("empty commit message");
|
|
156
|
+
runGitOrThrow(cwd, ["commit", "-m", msg]);
|
|
157
|
+
const hash = runGit(cwd, ["rev-parse", "--short", "HEAD"]) ?? undefined;
|
|
158
|
+
return { ok: true, ...(hash ? { hash } : {}) };
|
|
159
|
+
}
|
|
160
|
+
export function gitCheckout(cwd, branch) {
|
|
161
|
+
if (!isGitRepo(cwd))
|
|
162
|
+
throw new Error("not a git repository");
|
|
163
|
+
const name = branch.trim();
|
|
164
|
+
if (!name)
|
|
165
|
+
throw new Error("empty branch");
|
|
166
|
+
runGitOrThrow(cwd, ["checkout", name]);
|
|
167
|
+
return { ok: true };
|
|
168
|
+
}
|
|
169
|
+
export function gitDiscard(cwd, filePath) {
|
|
170
|
+
if (!isGitRepo(cwd))
|
|
171
|
+
throw new Error("not a git repository");
|
|
172
|
+
const p = filePath.trim();
|
|
173
|
+
if (!p)
|
|
174
|
+
throw new Error("empty path");
|
|
175
|
+
// Untracked: remove; tracked: restore worktree.
|
|
176
|
+
const staged = runGit(cwd, ["ls-files", "--", p]);
|
|
177
|
+
if (!staged) {
|
|
178
|
+
runGitOrThrow(cwd, ["clean", "-f", "--", p]);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
runGitOrThrow(cwd, ["restore", "--", p]);
|
|
182
|
+
}
|
|
183
|
+
return { ok: true };
|
|
184
|
+
}
|
|
185
|
+
export function gitRevert(cwd, hash) {
|
|
186
|
+
if (!isGitRepo(cwd))
|
|
187
|
+
throw new Error("not a git repository");
|
|
188
|
+
runGitOrThrow(cwd, ["revert", "--no-edit", hash.trim()]);
|
|
189
|
+
return { ok: true };
|
|
190
|
+
}
|
|
191
|
+
export function gitCherryPick(cwd, hash) {
|
|
192
|
+
if (!isGitRepo(cwd))
|
|
193
|
+
throw new Error("not a git repository");
|
|
194
|
+
runGitOrThrow(cwd, ["cherry-pick", hash.trim()]);
|
|
195
|
+
return { ok: true };
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=sidebar-git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-git.js","sourceRoot":"","sources":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AM,UAAU,aAAa,CAAC,GAAW,EAAE,IAAY;IACrD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC7D,aAAa,CAAC,GAAG,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host sidebar HTML preview: GET /sidebar/html/<sessionId>/<abs-path-segments…>
|
|
3
|
+
* Serves workspace files with real MIME so the iframe does not fall through to the SPA.
|
|
4
|
+
*/
|
|
5
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
6
|
+
/** Decode `/sidebar/html/<session>/<segments…>` into an absolute filesystem path. */
|
|
7
|
+
export declare function decodeSidebarHtmlPath(pathname: string): {
|
|
8
|
+
sessionId: string;
|
|
9
|
+
absPath: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
export interface SidebarHtmlOptions {
|
|
12
|
+
readonly resolveSessionCwd?: (sessionId: string) => string | undefined;
|
|
13
|
+
readonly defaultCwd?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Serve one file for the HTML preview iframe (and its relative assets).
|
|
17
|
+
* @returns true when the request was handled.
|
|
18
|
+
*/
|
|
19
|
+
export declare function handleSidebarHtml(_req: IncomingMessage, res: ServerResponse, pathname: string, options: SidebarHtmlOptions): Promise<boolean>;
|
|
20
|
+
//# sourceMappingURL=sidebar-html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-html.d.ts","sourceRoot":"","sources":["../../src/sidebar/sidebar-html.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AA+BjE,qFAAqF;AACrF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,SAAS,CA2CZ;AAeD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACvE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,eAAe,EACrB,GAAG,EAAE,cAAc,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,OAAO,CAAC,CAsClB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host sidebar HTML preview: GET /sidebar/html/<sessionId>/<abs-path-segments…>
|
|
3
|
+
* Serves workspace files with real MIME so the iframe does not fall through to the SPA.
|
|
4
|
+
*/
|
|
5
|
+
import { createReadStream, existsSync, statSync } from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { sendJson } from "../http-json.js";
|
|
8
|
+
const HTML_PREFIX = "/sidebar/html/";
|
|
9
|
+
const MIME_BY_EXT = {
|
|
10
|
+
".html": "text/html; charset=utf-8",
|
|
11
|
+
".htm": "text/html; charset=utf-8",
|
|
12
|
+
".css": "text/css; charset=utf-8",
|
|
13
|
+
".js": "text/javascript; charset=utf-8",
|
|
14
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
15
|
+
".json": "application/json; charset=utf-8",
|
|
16
|
+
".svg": "image/svg+xml",
|
|
17
|
+
".png": "image/png",
|
|
18
|
+
".jpg": "image/jpeg",
|
|
19
|
+
".jpeg": "image/jpeg",
|
|
20
|
+
".gif": "image/gif",
|
|
21
|
+
".webp": "image/webp",
|
|
22
|
+
".ico": "image/x-icon",
|
|
23
|
+
".woff": "font/woff",
|
|
24
|
+
".woff2": "font/woff2",
|
|
25
|
+
".ttf": "font/ttf",
|
|
26
|
+
".map": "application/json",
|
|
27
|
+
".txt": "text/plain; charset=utf-8",
|
|
28
|
+
".wasm": "application/wasm",
|
|
29
|
+
};
|
|
30
|
+
function fail(code, message) {
|
|
31
|
+
return { ok: false, error: { code, message } };
|
|
32
|
+
}
|
|
33
|
+
/** Decode `/sidebar/html/<session>/<segments…>` into an absolute filesystem path. */
|
|
34
|
+
export function decodeSidebarHtmlPath(pathname) {
|
|
35
|
+
if (!pathname.startsWith(HTML_PREFIX))
|
|
36
|
+
return undefined;
|
|
37
|
+
const rest = pathname.slice(HTML_PREFIX.length);
|
|
38
|
+
if (!rest)
|
|
39
|
+
return undefined;
|
|
40
|
+
const parts = rest.split("/").filter((p) => p.length > 0);
|
|
41
|
+
if (parts.length < 2)
|
|
42
|
+
return undefined;
|
|
43
|
+
// UNC: /sidebar/html/<session>//server/share/... → empty segment after session
|
|
44
|
+
const rawSplit = rest.split("/");
|
|
45
|
+
const sessionAt = rawSplit.findIndex((p) => p.length > 0);
|
|
46
|
+
if (sessionAt < 0)
|
|
47
|
+
return undefined;
|
|
48
|
+
const sessionEnc = rawSplit[sessionAt];
|
|
49
|
+
const afterSession = rawSplit.slice(sessionAt + 1);
|
|
50
|
+
const unc = afterSession[0] === "" && afterSession.length > 1;
|
|
51
|
+
const pathParts = (unc ? afterSession.slice(1) : afterSession).filter((p) => p.length > 0);
|
|
52
|
+
if (pathParts.length === 0)
|
|
53
|
+
return undefined;
|
|
54
|
+
let sessionId;
|
|
55
|
+
try {
|
|
56
|
+
sessionId = decodeURIComponent(sessionEnc);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const decoded = pathParts.map((p) => {
|
|
62
|
+
try {
|
|
63
|
+
return decodeURIComponent(p);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return p;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
// Windows drive: first segment "C:" + rest → C:\...
|
|
70
|
+
if (/^[A-Za-z]:$/.test(decoded[0])) {
|
|
71
|
+
const absPath = path.win32.join(`${decoded[0]}\\`, ...decoded.slice(1));
|
|
72
|
+
return { sessionId, absPath };
|
|
73
|
+
}
|
|
74
|
+
if (unc) {
|
|
75
|
+
return {
|
|
76
|
+
sessionId,
|
|
77
|
+
absPath: path.win32.join("\\\\" + decoded[0], ...decoded.slice(1)),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// POSIX absolute
|
|
81
|
+
return { sessionId, absPath: path.posix.join("/", ...decoded) };
|
|
82
|
+
}
|
|
83
|
+
function mimeFor(filePath) {
|
|
84
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
85
|
+
return MIME_BY_EXT[ext] ?? "application/octet-stream";
|
|
86
|
+
}
|
|
87
|
+
function underRoot(root, target) {
|
|
88
|
+
const rootResolved = path.resolve(root);
|
|
89
|
+
const abs = path.resolve(target);
|
|
90
|
+
return (abs === rootResolved || abs.startsWith(rootResolved + path.sep));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Serve one file for the HTML preview iframe (and its relative assets).
|
|
94
|
+
* @returns true when the request was handled.
|
|
95
|
+
*/
|
|
96
|
+
export async function handleSidebarHtml(_req, res, pathname, options) {
|
|
97
|
+
if (!pathname.startsWith(HTML_PREFIX))
|
|
98
|
+
return false;
|
|
99
|
+
if ((_req.method ?? "GET").toUpperCase() !== "GET") {
|
|
100
|
+
sendJson(res, 405, fail("method", "GET required"));
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
const decoded = decodeSidebarHtmlPath(pathname);
|
|
104
|
+
if (!decoded) {
|
|
105
|
+
sendJson(res, 400, fail("bad-request", "invalid html preview path"));
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
const cwd = (decoded.sessionId && options.resolveSessionCwd
|
|
109
|
+
? options.resolveSessionCwd(decoded.sessionId)
|
|
110
|
+
: undefined) ?? options.defaultCwd ?? process.cwd();
|
|
111
|
+
const abs = path.resolve(decoded.absPath);
|
|
112
|
+
if (!underRoot(cwd, abs) && !underRoot(path.resolve(cwd), abs)) {
|
|
113
|
+
// Allow absolute paths that resolve inside cwd only (same fence as relative).
|
|
114
|
+
sendJson(res, 403, fail("path", "html preview path escapes workspace"));
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
if (!existsSync(abs)) {
|
|
118
|
+
sendJson(res, 404, fail("not-found", "file missing"));
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
const st = statSync(abs);
|
|
122
|
+
if (!st.isFile()) {
|
|
123
|
+
sendJson(res, 400, fail("not-file", "not a file"));
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
res.writeHead(200, {
|
|
127
|
+
"content-type": mimeFor(abs),
|
|
128
|
+
"content-length": st.size,
|
|
129
|
+
// Preview iframes must not be framed as the product SPA; no CSP that blocks scripts in games.
|
|
130
|
+
"x-content-type-options": "nosniff",
|
|
131
|
+
});
|
|
132
|
+
createReadStream(abs).pipe(res);
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=sidebar-html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-html.js","sourceRoot":"","sources":["../../src/sidebar/sidebar-html.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC,MAAM,WAAW,GAA2B;IAC1C,OAAO,EAAE,0BAA0B;IACnC,MAAM,EAAE,0BAA0B;IAClC,MAAM,EAAE,yBAAyB;IACjC,KAAK,EAAE,gCAAgC;I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CAAC,CAAC;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC;QAC5B,gBAAgB,EAAE,EAAE,CAAC,IAAI;QACzB,8FAA8F;QAC9F,wBAAwB,EAAE,SAAS;KACpC,CAAC,CAAC;IACH,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const SIDEBAR_PREFS_DEFAULT: Record<string, unknown>;
|
|
2
|
+
export interface PrefsFile {
|
|
3
|
+
revision: number;
|
|
4
|
+
value: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export declare function loadSidebarPrefs(xrkHome?: string): PrefsFile;
|
|
7
|
+
export declare function saveSidebarPrefs(xrkHome: string | undefined, value: Record<string, unknown>, _revision?: number): number;
|
|
8
|
+
export declare function patchSidebarPrefs(xrkHome: string | undefined, patch: Record<string, unknown>): PrefsFile;
|
|
9
|
+
//# sourceMappingURL=sidebar-prefs-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebar-prefs-store.d.ts","sourceRoot":"","sources":["../../src/sidebar/sidebar-prefs-store.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CA2BzD,CAAC;AAOF,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAM5D;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAGR;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,SAAS,CAUX"}
|