dal-code 1.0.11 → 1.0.13

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.
Files changed (109) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/core/keybindings.d.ts +1 -1
  3. package/dist/core/keybindings.d.ts.map +1 -1
  4. package/dist/core/keybindings.js +1 -1
  5. package/dist/core/keybindings.js.map +1 -1
  6. package/dist/core/settings-manager.d.ts +3 -0
  7. package/dist/core/settings-manager.d.ts.map +1 -1
  8. package/dist/core/settings-manager.js +8 -0
  9. package/dist/core/settings-manager.js.map +1 -1
  10. package/dist/dal/builtins.d.ts.map +1 -1
  11. package/dist/dal/builtins.js +1 -0
  12. package/dist/dal/builtins.js.map +1 -1
  13. package/dist/modes/interactive/components/bash-execution.d.ts +1 -0
  14. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  15. package/dist/modes/interactive/components/bash-execution.js +7 -4
  16. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  17. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  18. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  19. package/dist/modes/interactive/components/settings-selector.js +9 -0
  20. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  21. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  22. package/dist/modes/interactive/external-editor.js +9 -2
  23. package/dist/modes/interactive/external-editor.js.map +1 -1
  24. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  25. package/dist/modes/interactive/interactive-mode.js +13 -12
  26. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  27. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  28. package/dist/node_modules/@dalcode/dal-bridge/src/client.ts +2 -2
  29. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  30. package/dist/node_modules/@dalcode/dal-gateway/src/index.ts +35 -7
  31. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  32. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  33. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  34. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  35. package/dist/node_modules/@dalcode/dal-lsp/src/client.ts +14 -0
  36. package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
  37. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  38. package/dist/node_modules/@dalcode/dal-office/src/render/docx.ts +12 -1
  39. package/dist/node_modules/@dalcode/dal-office/src/render/xlsx.ts +31 -2
  40. package/dist/node_modules/@dalcode/dal-office/src/tools/chart-generate.ts +9 -0
  41. package/dist/node_modules/@dalcode/dal-office/src/tools/ppt-generate.ts +10 -6
  42. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.d.ts.map +1 -1
  43. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +31 -2
  44. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js.map +1 -1
  45. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  46. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.ts +35 -3
  47. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  48. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  49. package/dist/node_modules/@dalcode/dal-subagent/src/index.ts +14 -1
  50. package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
  51. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  52. package/dist/node_modules/@dalcode/deepailab/src/oidc.ts +1 -1
  53. package/dist/node_modules/@earendil-works/chord/package.json +1 -1
  54. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  55. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  56. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  57. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  58. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  59. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  60. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  61. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  62. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  63. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  64. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  65. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
  66. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
  67. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
  68. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
  69. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
  70. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  71. package/dist/node_modules/@earendil-works/pi-client/package.json +2 -2
  72. package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
  73. package/dist/node_modules/@earendil-works/pi-server/package.json +3 -3
  74. package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/package.json +3 -3
  75. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  76. package/dist/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
  77. package/dist/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +1 -1
  78. package/dist/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
  79. package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
  80. package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.js +3 -1
  81. package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  82. package/dist/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +1 -0
  83. package/dist/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +1 -1
  84. package/dist/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +12 -1
  85. package/dist/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +1 -1
  86. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.d.ts.map +1 -1
  87. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +3 -1
  88. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js.map +1 -1
  89. package/dist/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
  90. package/dist/node_modules/@earendil-works/pi-tui/dist/utils.js +43 -6
  91. package/dist/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
  92. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  93. package/dist/utils/clipboard.d.ts.map +1 -1
  94. package/dist/utils/clipboard.js +25 -2
  95. package/dist/utils/clipboard.js.map +1 -1
  96. package/dist/utils/shell.d.ts.map +1 -1
  97. package/dist/utils/shell.js +9 -1
  98. package/dist/utils/shell.js.map +1 -1
  99. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  100. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  101. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  102. package/examples/extensions/gondolin/package-lock.json +2 -2
  103. package/examples/extensions/gondolin/package.json +1 -1
  104. package/examples/extensions/sandbox/package-lock.json +2 -2
  105. package/examples/extensions/sandbox/package.json +1 -1
  106. package/examples/extensions/with-deps/package-lock.json +2 -2
  107. package/examples/extensions/with-deps/package.json +1 -1
  108. package/npm-shrinkwrap.json +2 -2
  109. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-bridge",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "dependencies": {
21
- "@dalcode/dal-pi-kit": "1.0.11",
21
+ "@dalcode/dal-pi-kit": "1.0.13",
22
22
  "typebox": "1.3.7"
23
23
  },
24
24
  "peerDependencies": {
@@ -31,8 +31,8 @@ const REQUEST_TIMEOUT_MS = 150_000;
31
31
  * a pi run outside DAL Code, and the extension simply stands down.
32
32
  */
33
33
  export function readBridgeConfig(env: NodeJS.ProcessEnv = process.env): BridgeConfig | undefined {
34
- const baseUrl = env["DALCODE_BRIDGE_URL"];
35
- const token = env["DALCODE_BRIDGE_TOKEN"];
34
+ const baseUrl = env.DALCODE_BRIDGE_URL;
35
+ const token = env.DALCODE_BRIDGE_TOKEN;
36
36
  if (!baseUrl || !token) return undefined;
37
37
  return { baseUrl: baseUrl.replace(/\/+$/, ""), token };
38
38
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-gateway",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -17,7 +17,7 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@dalcode/deepailab": "1.0.11"
20
+ "@dalcode/deepailab": "1.0.13"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -38,7 +38,7 @@ const CATALOG_TIMEOUT_MS = 20_000;
38
38
 
39
39
  /** Reads the gateway base URL, normalised without a trailing slash. */
40
40
  function gatewayBaseUrl(): string | undefined {
41
- const raw = process.env["DALCODE_GATEWAY_URL"];
41
+ const raw = process.env.DALCODE_GATEWAY_URL;
42
42
  return raw !== undefined && raw.length > 0 ? raw.replace(/\/+$/, "") : undefined;
43
43
  }
44
44
 
@@ -73,7 +73,7 @@ export default function (pi: ExtensionAPI) {
73
73
  // any failure keeps the seed list, so a slow or unreachable gateway delays
74
74
  // model choice rather than breaking the turn.
75
75
  pi.on("session_start", async () => {
76
- const token = process.env["DALCODE_GATEWAY_TOKEN"];
76
+ const token = process.env.DALCODE_GATEWAY_TOKEN;
77
77
  if (token === undefined || token.length === 0) {
78
78
  return;
79
79
  }
@@ -90,10 +90,38 @@ export default function (pi: ExtensionAPI) {
90
90
  );
91
91
  return;
92
92
  }
93
- const body = (await response.json()) as { data?: Array<{ id?: string }> };
93
+ // Forward the catalog's real metadata (context window, output cap,
94
+ // capabilities, measured reasoning efforts, pricing) instead of only
95
+ // the id: the five-factor model factory needs actual cost and context
96
+ // numbers, and the model layer needs the true window.
97
+ const body = (await response.json()) as {
98
+ data?: Array<{
99
+ id?: string;
100
+ display_name?: string;
101
+ name?: string;
102
+ context_window?: number;
103
+ max_output_tokens?: number;
104
+ capabilities?: string[];
105
+ reasoning_efforts?: string[];
106
+ pricing?: {
107
+ input_per_1m?: number;
108
+ output_per_1m?: number;
109
+ cache_read_per_1m?: number;
110
+ cache_write_per_1m?: number;
111
+ };
112
+ }>;
113
+ };
94
114
  const models = (body.data ?? [])
95
- .filter((m): m is { id: string } => typeof m.id === "string" && m.id.length > 0)
96
- .map((m) => gatewayModelDefaults(m.id));
115
+ .filter((m) => typeof m.id === "string" && m.id.length > 0)
116
+ .map((m) =>
117
+ gatewayModelDefaults(m.id as string, m.display_name ?? m.name, {
118
+ contextWindow: m.context_window,
119
+ maxTokens: m.max_output_tokens,
120
+ capabilities: m.capabilities,
121
+ reasoningEfforts: m.reasoning_efforts,
122
+ pricing: m.pricing,
123
+ }),
124
+ );
97
125
  if (models.length > 0) {
98
126
  register(models);
99
127
  }
@@ -120,8 +148,8 @@ function installMeteringHeaders(baseUrl: string): void {
120
148
  return inner(input, init);
121
149
  }
122
150
  const headers = new Headers(init?.headers);
123
- const taskId = process.env["DALCODE_TASK_ID"];
124
- const sessionId = process.env["DALCODE_SESSION_ID"];
151
+ const taskId = process.env.DALCODE_TASK_ID;
152
+ const sessionId = process.env.DALCODE_SESSION_ID;
125
153
  if (taskId) {
126
154
  headers.set("x-dal-task-id", taskId);
127
155
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-guard",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -17,9 +17,9 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@dalcode/dal-pi-kit": "1.0.11",
21
- "@dalcode/dal-bridge": "1.0.11",
22
- "@dalcode/dal-halo": "1.0.11"
20
+ "@dalcode/dal-pi-kit": "1.0.13",
21
+ "@dalcode/dal-bridge": "1.0.13",
22
+ "@dalcode/dal-halo": "1.0.13"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-halo",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-lang",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -17,8 +17,8 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@dalcode/dal-pi-kit": "1.0.11",
21
- "@dalcode/dal-bridge": "1.0.11"
20
+ "@dalcode/dal-pi-kit": "1.0.13",
21
+ "@dalcode/dal-bridge": "1.0.13"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@earendil-works/pi-coding-agent": "^1.0.9"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-lsp",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -19,8 +19,8 @@
19
19
  ]
20
20
  },
21
21
  "dependencies": {
22
- "@dalcode/dal-bridge": "1.0.11",
23
- "@dalcode/dal-pi-kit": "1.0.11",
22
+ "@dalcode/dal-bridge": "1.0.13",
23
+ "@dalcode/dal-pi-kit": "1.0.13",
24
24
  "cross-spawn": "7.0.6",
25
25
  "typebox": "1.3.7"
26
26
  },
@@ -11,6 +11,7 @@ interface PendingRequest {
11
11
 
12
12
  interface JsonRpcMessage {
13
13
  id?: number;
14
+ method?: string;
14
15
  result?: unknown;
15
16
  error?: { message?: string; code?: number };
16
17
  }
@@ -203,6 +204,19 @@ export class LspClient {
203
204
  return;
204
205
  }
205
206
  if (typeof message.id !== "number") return;
207
+ // A message with both id and method is a server→client REQUEST, not a
208
+ // response. Matching it against our pending table could resolve an
209
+ // in-flight call with the wrong id, and the LSP spec requires clients to
210
+ // answer every request — servers retry (or stall) when they never hear
211
+ // back. We support none of them, so decline with MethodNotFound.
212
+ if (typeof message.method === "string") {
213
+ this.writeMessage({
214
+ jsonrpc: "2.0",
215
+ id: message.id,
216
+ error: { code: -32601, message: `Method not found: ${message.method}` },
217
+ });
218
+ return;
219
+ }
206
220
  const pending = this.pending.get(message.id);
207
221
  if (!pending) return;
208
222
  this.pending.delete(message.id);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-mcp",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -23,10 +23,10 @@
23
23
  ]
24
24
  },
25
25
  "dependencies": {
26
- "@dalcode/dal-bridge": "1.0.11",
27
- "@dalcode/dal-guard": "1.0.11",
28
- "@dalcode/dal-pi-kit": "1.0.11",
29
- "@dalcode/deepailab": "1.0.11",
26
+ "@dalcode/dal-bridge": "1.0.13",
27
+ "@dalcode/dal-guard": "1.0.13",
28
+ "@dalcode/dal-pi-kit": "1.0.13",
29
+ "@dalcode/deepailab": "1.0.13",
30
30
  "cross-spawn": "7.0.6"
31
31
  },
32
32
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalcode/dal-office",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -17,7 +17,7 @@
17
17
  ]
18
18
  },
19
19
  "dependencies": {
20
- "@dalcode/dal-pi-kit": "1.0.11",
20
+ "@dalcode/dal-pi-kit": "1.0.13",
21
21
  "docx": "9.7.1",
22
22
  "echarts": "6.1.0",
23
23
  "exceljs": "4.4.0",
@@ -117,10 +117,21 @@ export async function renderDocx(doc: DocOutputInput): Promise<Buffer> {
117
117
  const children: Array<Paragraph | Table> = [
118
118
  new Paragraph({
119
119
  children: [new TextRun({ text: doc.title, bold: true, size: TITLE_SIZE })],
120
- spacing: { after: 240 },
120
+ spacing: { after: doc.summary ? 120 : 240 },
121
121
  }),
122
122
  ];
123
123
 
124
+ // The tool schema accepts an overall `summary`; it was silently dropped
125
+ // before — render it as an italic standfirst under the title.
126
+ if (doc.summary?.trim()) {
127
+ children.push(
128
+ new Paragraph({
129
+ children: [new TextRun({ text: doc.summary.trim(), italics: true, size: BODY_SIZE })],
130
+ spacing: { after: 240 },
131
+ }),
132
+ );
133
+ }
134
+
124
135
  for (const section of doc.sections) {
125
136
  children.push(headingParagraph(section));
126
137
  for (const paragraph of section.paragraphs ?? []) {
@@ -26,6 +26,35 @@ const BORDER_COLOR = "FFCCCCCC";
26
26
  const MIN_COL_WIDTH = 10;
27
27
  const MAX_COL_WIDTH = 48;
28
28
 
29
+ /**
30
+ * Column width is measured in cell units: East Asian wide/fullwidth characters
31
+ * occupy 2 units, everything else 1. UTF-16 `.length` undercounts CJK text and
32
+ * left long Chinese headers truncated.
33
+ */
34
+ function displayWidth(value: string): number {
35
+ let width = 0;
36
+ for (const char of value) {
37
+ const code = char.codePointAt(0) ?? 0;
38
+ const wide =
39
+ (code >= 0x1100 && code <= 0x115f) || // Hangul Jamo
40
+ (code >= 0x2e80 && code <= 0x303e) || // CJK radicals, Kangxi, symbols
41
+ (code >= 0x3041 && code <= 0x33ff) || // Hiragana .. CJK compatibility
42
+ (code >= 0x3400 && code <= 0x4dbf) || // CJK extension A
43
+ (code >= 0x4e00 && code <= 0x9fff) || // CJK unified ideographs
44
+ (code >= 0xa000 && code <= 0xa4cf) || // Yi syllables
45
+ (code >= 0xac00 && code <= 0xd7a3) || // Hangul syllables
46
+ (code >= 0xf900 && code <= 0xfaff) || // CJK compatibility ideographs
47
+ (code >= 0xfe30 && code <= 0xfe4f) || // CJK compatibility forms
48
+ (code >= 0xff00 && code <= 0xff60) || // Fullwidth forms
49
+ (code >= 0xffe0 && code <= 0xffe6) ||
50
+ (code >= 0x1f300 && code <= 0x1f64f) || // Emoji
51
+ (code >= 0x1f900 && code <= 0x1f9ff) ||
52
+ (code >= 0x20000 && code <= 0x3fffd); // CJK extensions B..
53
+ width += wide ? 2 : 1;
54
+ }
55
+ return width;
56
+ }
57
+
29
58
  /** Excel worksheet names: <=31 chars, no []:*?/\ — collisions get a numeric suffix. */
30
59
  export function sanitizeSheetName(name: string, used: Set<string>): string {
31
60
  const cleaned =
@@ -82,9 +111,9 @@ export async function renderXlsx(output: SheetOutputInput): Promise<Buffer> {
82
111
  }
83
112
 
84
113
  for (let col = 1; col <= table.headers.length; col++) {
85
- let width = table.headers[col - 1]?.length ?? MIN_COL_WIDTH;
114
+ let width = Math.max(displayWidth(table.headers[col - 1] ?? ""), MIN_COL_WIDTH);
86
115
  for (const row of table.rows) {
87
- width = Math.max(width, row[col - 1]?.length ?? 0);
116
+ width = Math.max(width, displayWidth(row[col - 1] ?? ""));
88
117
  }
89
118
  sheet.getColumn(col).width = Math.min(Math.max(width + 2, MIN_COL_WIDTH), MAX_COL_WIDTH);
90
119
  }
@@ -82,6 +82,15 @@ export function registerChartGenerate(pi: ExtensionAPI): void {
82
82
  let svgTarget: string;
83
83
  try {
84
84
  svgTarget = resolveOutputPath(ctx.cwd, params.path, title, "svg");
85
+ // The artifact family (.svg/.html/.json) is derived by stripping the
86
+ // extension; a non-.svg path would produce an .xlsx full of SVG text
87
+ // and double-dot siblings.
88
+ if (!svgTarget.toLowerCase().endsWith(".svg")) {
89
+ return officeFailure(
90
+ formatTemplate(t("图表的 path 必须以 .svg 结尾(当前:{path})"), { path: params.path ?? "" }),
91
+ "chart",
92
+ );
93
+ }
85
94
  } catch (error) {
86
95
  return officeFailure(error instanceof Error ? error.message : String(error), "chart");
87
96
  }
@@ -64,6 +64,16 @@ export function registerPptGenerate(pi: ExtensionAPI): void {
64
64
  return officeFailure(t("title 不能为空"), "pptx");
65
65
  }
66
66
  const sessionId = ctx.sessionManager.getSessionId();
67
+ // Resolve the output path BEFORE consuming the scratchpad plan:
68
+ // takePresentationPlan() deletes what it takes, and a rejected path
69
+ // must not cost the user their confirmed outline.
70
+ let target: string;
71
+ try {
72
+ target = resolveOutputPath(ctx.cwd, params.path, title, "pptx");
73
+ } catch (error) {
74
+ return officeFailure(error instanceof Error ? error.message : String(error), "pptx");
75
+ }
76
+
67
77
  const stored = takePresentationPlan(sessionId);
68
78
  let plan: OfficePresentationPlan;
69
79
  if (stored) {
@@ -76,12 +86,6 @@ export function registerPptGenerate(pi: ExtensionAPI): void {
76
86
 
77
87
  const theme: ThemeName = params.theme ?? "default";
78
88
  const buffer = await renderPptx(plan, theme);
79
- let target: string;
80
- try {
81
- target = resolveOutputPath(ctx.cwd, params.path, title, "pptx");
82
- } catch (error) {
83
- return officeFailure(error instanceof Error ? error.message : String(error), "pptx");
84
- }
85
89
  writeFileSync(target, buffer);
86
90
 
87
91
  const text = formatTemplate(