claude-simple 0.2.22 → 0.2.23

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/index.html CHANGED
@@ -4,13 +4,13 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
6
6
  <title>Claude Code</title>
7
- <link rel="stylesheet" href="/style.0.2.22.min.css">
7
+ <link rel="stylesheet" href="/style.0.2.23.min.css">
8
8
  <link rel="stylesheet" href="/highlight.min.css">
9
9
  <script src="/marked.min.js"></script>
10
10
  <script src="/highlight.min.js"></script>
11
11
  </head>
12
12
  <body class="h-dvh overflow-hidden flex flex-col bg-base-100 text-base-content">
13
13
  <div id="root" class="flex flex-col flex-1 overflow-hidden"></div>
14
- <script type="module" src="/app.0.2.22.min.js"></script>
14
+ <script type="module" src="/app.0.2.23.min.js"></script>
15
15
  </body>
16
16
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-simple",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "claude-simple": "server.js",
@@ -6,6 +6,7 @@ import { esc, $ } from './lib.js';
6
6
  import { api, authHeaders, currentMachineId } from './api.js';
7
7
  import { hubMode, ctx, currentAgent, currentProject } from './state.js';
8
8
  import { renderMermaid } from './mermaid.js';
9
+ import { normalizeMarkdownText } from './markdown.js';
9
10
 
10
11
  let panelOpen = false;
11
12
  let mode = 'chat'; // chat | report | history | config
@@ -29,7 +30,7 @@ const LAST_SESSION_KEY = 'ma_last_session_id';
29
30
  function mdHtml(text) {
30
31
  if (typeof marked !== 'undefined') {
31
32
  try {
32
- return marked.parse(String(text ?? ''), { breaks: true, gfm: true });
33
+ return marked.parse(normalizeMarkdownText(text), { breaks: true, gfm: true });
33
34
  } catch { /* fallthrough */ }
34
35
  }
35
36
  return esc(text).replace(/\n/g, '<br>');
package/public/chat.js CHANGED
@@ -8,6 +8,7 @@ import { initWakeLock, setWakeLockDesired } from './wake-lock.js';
8
8
  import { pushNotification } from './notifications.js';
9
9
  import { renderMermaid } from './mermaid.js';
10
10
  import { renderMath } from './math.js';
11
+ import { normalizeMarkdownText } from './markdown.js';
11
12
 
12
13
  function assistantLabel() {
13
14
  return AGENT_LABELS[currentAgent.peek()] || 'Assistant';
@@ -1524,6 +1525,13 @@ function ensureMarked() {
1524
1525
  }
1525
1526
  return `<div class="table-wrap"><table><thead>${header}</thead><tbody>${body}</tbody></table></div>`;
1526
1527
  },
1528
+ // Agent output is untrusted Markdown, not application HTML. In
1529
+ // particular agy's native transcript may contain `<truncated N bytes>`;
1530
+ // letting marked emit that raw tag can unbalance the surrounding message
1531
+ // DOM. Show HTML-like content literally instead.
1532
+ html(raw) {
1533
+ return escapeCode(raw);
1534
+ },
1527
1535
  };
1528
1536
 
1529
1537
  try {
@@ -1545,7 +1553,7 @@ function renderMarkdown(text) {
1545
1553
  if (typeof marked === 'undefined') return esc(text);
1546
1554
  try {
1547
1555
  ensureMarked();
1548
- return marked.parse(String(text ?? ''), { breaks: true, gfm: true });
1556
+ return marked.parse(normalizeMarkdownText(text), { breaks: true, gfm: true });
1549
1557
  } catch {
1550
1558
  return esc(text);
1551
1559
  }
package/public/index.html CHANGED
@@ -85,7 +85,7 @@
85
85
  <script src="/vendor/mermaid.min.js"></script>
86
86
  <link rel="stylesheet" href="/vendor/katex.min.css">
87
87
  <script src="/vendor/katex.min.js"></script>
88
- <link rel="stylesheet" href="style.css?v=ui-19">
88
+ <link rel="stylesheet" href="style.css?v=ui-20">
89
89
  </head>
90
90
  <body class="h-dvh overflow-hidden flex flex-col bg-base-100 text-base-content">
91
91
  <div id="root" class="flex flex-col flex-1 overflow-hidden"></div>
@@ -101,6 +101,6 @@
101
101
  }
102
102
  }, 10000);
103
103
  </script>
104
- <script type="module" src="app.js?v=ui-19"></script>
104
+ <script type="module" src="app.js?v=ui-20"></script>
105
105
  </body>
106
106
  </html>
@@ -0,0 +1,12 @@
1
+ // Markdown input normalisation shared by chat, history and Meta Agent views.
2
+ // Some agent transcript formats use `<truncated N bytes>` as a transport
3
+ // placeholder. It is not HTML, but a Markdown parser will otherwise pass it
4
+ // through as an element and a malformed placeholder can corrupt the rest of a
5
+ // message's DOM.
6
+ const TRUNCATED_TRANSCRIPT_MARKER = /(?:<|\[)\s*(?:…\s*)?truncated\s+([\d,]+)\s+bytes\s*(?:>|\])/gi;
7
+
8
+ export function normalizeMarkdownText(value) {
9
+ return String(value ?? '').replace(TRUNCATED_TRANSCRIPT_MARKER, (_match, bytes) => {
10
+ return `\n\n> ⚠️ 原始记录已截断(${bytes} bytes)\n\n`;
11
+ });
12
+ }
@@ -13,6 +13,7 @@ import {
13
13
  import { api, NOT_MODIFIED } from '../api.js';
14
14
  import { getCachedSessions, setCachedSessions, getCachedWorkspaces, setCachedWorkspaces } from '../cache.js';
15
15
  import { formatTime, agentBadge, agentCountPills, shortPath } from './util.js';
16
+ import { normalizeMarkdownText } from '../markdown.js';
16
17
 
17
18
 
18
19
  function normalizeSessions(v) {
@@ -424,7 +425,7 @@ export function mdToHtml(text) {
424
425
  if (typeof marked === 'undefined') return `<pre class="whitespace-pre-wrap text-xs">${esc(text)}</pre>`;
425
426
  try {
426
427
  // Prefer shared renderer if chat has configured marked
427
- return marked.parse(String(text), { breaks: true, gfm: true });
428
+ return marked.parse(normalizeMarkdownText(text), { breaks: true, gfm: true });
428
429
  } catch {
429
430
  return `<pre class="whitespace-pre-wrap text-xs">${esc(text)}</pre>`;
430
431
  }
package/public/sw.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /* Agent UI service worker — cache shell assets only.
2
2
  * Never intercepts WebSocket or mutates API semantics beyond offline fallback.
3
3
  * Bump CACHE when shipping UI that must invalidate old shells. */
4
- const CACHE = 'agent-ui-shell-v24';
4
+ const CACHE = 'agent-ui-shell-v25';
5
5
  const PRECACHE = [
6
6
  '/',
7
7
  '/index.html',
8
8
  '/manifest.webmanifest',
9
- '/style.css?v=ui-19',
9
+ '/style.css?v=ui-20',
10
10
  '/style.css',
11
11
  '/ui.min.css',
12
12
  '/vendor/mini-react.min.js',
@@ -16,7 +16,7 @@ const PRECACHE = [
16
16
  '/vendor/mermaid.min.js',
17
17
  '/vendor/katex.min.js',
18
18
  '/vendor/katex.min.css',
19
- '/app.js?v=ui-19',
19
+ '/app.js?v=ui-20',
20
20
  '/icons/icon-192.png',
21
21
  '/icons/icon-512.png',
22
22
  '/icons/icon-maskable-512.png',