ework-web 0.10.91 → 0.10.93

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": "ework-web",
3
- "version": "0.10.91",
3
+ "version": "0.10.93",
4
4
  "type": "module",
5
5
  "description": "ework-web — standalone multi-project issue tracker. Local SQLite-backed, no external API dependency. Bun + TypeScript + SSR HTML.",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "module";
1
2
  import { buildPiSessionPage } from "./pi-sessions";
2
3
  import { join, dirname } from "path";
3
4
  import { fileURLToPath } from "url";
@@ -220,8 +221,10 @@ function buildCsp(cfg: Config): string {
220
221
  const hlCss = loadHighlightCss();
221
222
 
222
223
  function loadHighlightCss(): string {
223
- const light = readFileSafe(join(__dirname, "..", "node_modules", "highlight.js", "styles", "github.css"));
224
- const dark = readFileSafe(join(__dirname, "..", "node_modules", "highlight.js", "styles", "github-dark.css"));
224
+ let dir: string | null = null;
225
+ try { dir = dirname(createRequire(import.meta.url).resolve("highlight.js/package.json")); } catch { dir = null; }
226
+ const light = readFileSafe(dir ? join(dir, "styles", "github.css") : null) || readFileSafe(join(__dirname, "..", "node_modules", "highlight.js", "styles", "github.css"));
227
+ const dark = readFileSafe(dir ? join(dir, "styles", "github-dark.css") : null) || readFileSafe(join(__dirname, "..", "node_modules", "highlight.js", "styles", "github-dark.css"));
225
228
  if (!light && !dark) return "";
226
229
  const darkRule = dark
227
230
  ? `@media (prefers-color-scheme:dark){${stripAtMedia(dark)}}`
@@ -229,7 +232,8 @@ function loadHighlightCss(): string {
229
232
  return `${light}${darkRule}`;
230
233
  }
231
234
 
232
- function readFileSafe(p: string): string {
235
+ function readFileSafe(p: string | null): string {
236
+ if (!p) return "";
233
237
  try {
234
238
  return readFileSync(p, "utf8");
235
239
  } catch {
@@ -82,7 +82,11 @@ function resultText(output: unknown): string {
82
82
 
83
83
  function toolCard(t: PiToolCall): string {
84
84
  const argStr = t.args.length > 600 ? t.args.slice(0, 600) + "…" : t.args;
85
- return `<details class="pi-tool"><summary>🔧 ${escapeHtml(t.name)}<span class="pi-tool-args">${escapeHtml(argStr)}</span></summary><div class="tool-io"><pre>${escapeHtml(t.result ? resultText(t.result).slice(0, 4000) : "(无返回)")}</pre></div></details>`;
85
+ const argsBlock = t.args && t.args !== "{}"
86
+ ? `<div class="pi-io-label">完整参数</div><pre>${escapeHtml(t.args.length > 20000 ? t.args.slice(0, 20000) + "\n…(截断)" : t.args)}</pre>`
87
+ : "";
88
+ const resultBlock = `<div class="pi-io-label">返回</div><pre>${escapeHtml(t.result ?? "(无返回)")}</pre>`;
89
+ return `<details class="pi-tool"><summary>🔧 ${escapeHtml(t.name)}<span class="pi-tool-args">${escapeHtml(argStr)}</span></summary><div class="tool-io">${argsBlock}${resultBlock}</div></details>`;
86
90
  }
87
91
 
88
92
  function renderCard(c: PiCard): string {
@@ -234,6 +238,7 @@ export function buildPiSessionPage(sessionId: string, limit: number, asc = false
234
238
  .mb .tool-io{position:relative;padding:.5rem .6rem}
235
239
  .mb .tool-io pre{margin:.2rem 0}
236
240
  .pi-tool summary .pi-tool-args{font-family:ui-monospace,monospace;font-size:11px;color:var(--text-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:60%}
241
+ .pi-io-label{font-size:11px;color:var(--text-muted);margin:6px 0 2px;font-weight:600}
237
242
  .more-bar{max-width:900px;margin:1rem auto 0;padding:.8rem 1rem;text-align:center;border:1px dashed var(--border);border-radius:8px;color:var(--text-muted);font-size:13px}
238
243
  .more-bar a{font-weight:600}
239
244
  </style></head><body>