dal-code 1.0.0 → 1.0.7
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/CHANGELOG.md +67 -1
- package/dist/core/auth-guidance.d.ts +1 -0
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-guidance.js +6 -0
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +4 -7
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +13 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +47 -48
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +46 -43
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybindings.d.ts +10 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +13 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/tools/bash.d.ts +3 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +61 -8
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +43 -6
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/dal/builtins.d.ts.map +1 -1
- package/dist/dal/builtins.js +1 -0
- package/dist/dal/builtins.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +12 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +22 -1
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +2 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +24 -7
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +39 -2
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +200 -29
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +35 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +177 -23
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +1 -1
- package/dist/modes/interactive/theme/light.json +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/tui-renderer.js +2 -2
- package/dist/modes/interactive/tui-renderer.js.map +1 -1
- package/dist/node_modules/@dalcode/dal-bridge/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-gateway/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-guard/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-halo/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-lang/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-lsp/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-mcp/package.json +9 -6
- package/dist/node_modules/@dalcode/dal-mcp/src/add-wizard.ts +142 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/command-parser.ts +218 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/config-edit.ts +99 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/index.ts +161 -18
- package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.ts +8 -3
- package/dist/node_modules/@dalcode/dal-office/LICENSE +21 -0
- package/dist/node_modules/@dalcode/dal-office/package.json +37 -0
- package/dist/node_modules/@dalcode/dal-office/src/extract/csv.ts +84 -0
- package/dist/node_modules/@dalcode/dal-office/src/extract/index.ts +111 -0
- package/dist/node_modules/@dalcode/dal-office/src/extract/ooxml.ts +109 -0
- package/dist/node_modules/@dalcode/dal-office/src/extract/pdf.ts +43 -0
- package/dist/node_modules/@dalcode/dal-office/src/index.ts +43 -0
- package/dist/node_modules/@dalcode/dal-office/src/paths.ts +107 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/chart.ts +111 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/docx.ts +155 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/pptx.ts +386 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/xlsx.ts +99 -0
- package/dist/node_modules/@dalcode/dal-office/src/scenes.ts +197 -0
- package/dist/node_modules/@dalcode/dal-office/src/scratchpad.ts +49 -0
- package/dist/node_modules/@dalcode/dal-office/src/themes.ts +240 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/chart-generate.ts +122 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/doc-generate.ts +123 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/drawio-generate.ts +99 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/md-generate.ts +76 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/ppt-generate.ts +106 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/ppt-plan.ts +91 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/read-file.ts +71 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/shared.ts +54 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/sheet-generate.ts +101 -0
- package/dist/node_modules/@dalcode/dal-office/src/truncate.ts +27 -0
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.d.ts.map +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +233 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js.map +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.ts +322 -1
- package/dist/node_modules/@dalcode/dal-skills/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-skills/src/discover.ts +101 -0
- package/dist/node_modules/@dalcode/dal-skills/src/index.ts +71 -9
- package/dist/node_modules/@dalcode/dal-skills/src/install.ts +140 -0
- package/dist/node_modules/@dalcode/dal-skills/src/manage.ts +446 -0
- package/dist/node_modules/@dalcode/dal-skills/src/packages.ts +39 -1
- package/dist/node_modules/@dalcode/dal-subagent/package.json +6 -6
- package/dist/node_modules/@dalcode/dal-subagent/src/index.ts +46 -4
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +3 -3
- package/dist/node_modules/@dalcode/deepailab/package.json +4 -4
- package/dist/node_modules/@dalcode/deepailab/src/index.ts +7 -1
- package/dist/node_modules/@dalcode/deepailab/src/model-defaults.ts +42 -6
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-client/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-protocol/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +3 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/input.js +3 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +23 -22
- package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +4 -3
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts.map +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +4 -2
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js.map +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/utils/changelog.d.ts +37 -4
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +80 -17
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +13 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/plugins/pi-example-plugin/package.json +1 -1
- package/npm-shrinkwrap.json +1511 -25
- package/package.json +8 -2
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scratchpad for the two-step PPT pipeline.
|
|
3
|
+
*
|
|
4
|
+
* office_ppt_plan stores the approved outline here; office_ppt_generate
|
|
5
|
+
* picks it up in the same session. Entries are keyed by session id and
|
|
6
|
+
* capped — a long-lived CLI process would otherwise accumulate plans
|
|
7
|
+
* across many sessions.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface OfficeSlidePlan {
|
|
11
|
+
title: string;
|
|
12
|
+
layout?: "title" | "content" | "two-column" | "section";
|
|
13
|
+
goal?: string;
|
|
14
|
+
visual?: string;
|
|
15
|
+
points?: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface OfficePresentationPlan {
|
|
19
|
+
title: string;
|
|
20
|
+
slides: OfficeSlidePlan[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const MAX_SCRATCHPAD_ENTRIES = 50;
|
|
24
|
+
|
|
25
|
+
/** Insertion-ordered: the oldest entry is evoked first when the cap is hit. */
|
|
26
|
+
const plans = new Map<string, OfficePresentationPlan>();
|
|
27
|
+
|
|
28
|
+
export function savePresentationPlan(sessionId: string, plan: OfficePresentationPlan): void {
|
|
29
|
+
if (!plans.has(sessionId) && plans.size >= MAX_SCRATCHPAD_ENTRIES) {
|
|
30
|
+
const oldest = plans.keys().next();
|
|
31
|
+
if (!oldest.done) plans.delete(oldest.value);
|
|
32
|
+
}
|
|
33
|
+
plans.set(sessionId, plan);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function loadPresentationPlan(sessionId: string): OfficePresentationPlan | undefined {
|
|
37
|
+
return plans.get(sessionId);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Reads and removes the plan — an outline is consumed by exactly one generation. */
|
|
41
|
+
export function takePresentationPlan(sessionId: string): OfficePresentationPlan | undefined {
|
|
42
|
+
const plan = plans.get(sessionId);
|
|
43
|
+
if (plan) plans.delete(sessionId);
|
|
44
|
+
return plan;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function clearPresentationPlan(sessionId: string): void {
|
|
48
|
+
plans.delete(sessionId);
|
|
49
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic slide palettes for the PPT renderer.
|
|
3
|
+
*
|
|
4
|
+
* Palettes rotate per slide (index % palettes.length) so consecutive pages
|
|
5
|
+
* get subtly different background tints while staying inside one theme.
|
|
6
|
+
* Every palette carries the full text-color set (title/body/muted) because
|
|
7
|
+
* dark themes need light body text — a fixed gray is unreadable there.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type ThemeName = "default" | "business" | "tech" | "warm" | "minimal";
|
|
11
|
+
|
|
12
|
+
export interface SlidePalette {
|
|
13
|
+
/** Page background wash. */
|
|
14
|
+
bg: string;
|
|
15
|
+
/** Card surface the content sits on. */
|
|
16
|
+
card: string;
|
|
17
|
+
/** Brand color: accent bars, numbered markers, kickers. */
|
|
18
|
+
primary: string;
|
|
19
|
+
/** Secondary decorative color (ellipses, hairlines on primary). */
|
|
20
|
+
accent: string;
|
|
21
|
+
/** Headline text color; light on dark palettes. */
|
|
22
|
+
dark: string;
|
|
23
|
+
/** Running body text, contrast-matched to `card`. */
|
|
24
|
+
body: string;
|
|
25
|
+
/** Footers, captions, kickers on light surfaces. */
|
|
26
|
+
muted: string;
|
|
27
|
+
/** Hairlines and dividers. */
|
|
28
|
+
line: string;
|
|
29
|
+
/** Shadow strength for cards on this surface. */
|
|
30
|
+
shadowOpacity: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const LIGHT_SHADOW = 0.14;
|
|
34
|
+
const DARK_SHADOW = 0.38;
|
|
35
|
+
|
|
36
|
+
const DEFAULT: SlidePalette[] = [
|
|
37
|
+
{
|
|
38
|
+
bg: "F8FAFC",
|
|
39
|
+
card: "FFFFFF",
|
|
40
|
+
primary: "2563EB",
|
|
41
|
+
accent: "38BDF8",
|
|
42
|
+
dark: "0F172A",
|
|
43
|
+
body: "334155",
|
|
44
|
+
muted: "64748B",
|
|
45
|
+
line: "E2E8F0",
|
|
46
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
bg: "FFF7ED",
|
|
50
|
+
card: "FFFFFF",
|
|
51
|
+
primary: "EA580C",
|
|
52
|
+
accent: "FDBA74",
|
|
53
|
+
dark: "7C2D12",
|
|
54
|
+
body: "44403C",
|
|
55
|
+
muted: "78716C",
|
|
56
|
+
line: "F5E3D3",
|
|
57
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
bg: "F0FDFA",
|
|
61
|
+
card: "FFFFFF",
|
|
62
|
+
primary: "0F766E",
|
|
63
|
+
accent: "5EEAD4",
|
|
64
|
+
dark: "134E4A",
|
|
65
|
+
body: "1F2937",
|
|
66
|
+
muted: "6B7280",
|
|
67
|
+
line: "D6EFE9",
|
|
68
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
bg: "F5F3FF",
|
|
72
|
+
card: "FFFFFF",
|
|
73
|
+
primary: "7C3AED",
|
|
74
|
+
accent: "C4B5FD",
|
|
75
|
+
dark: "2E1065",
|
|
76
|
+
body: "3F3F46",
|
|
77
|
+
muted: "6B7280",
|
|
78
|
+
line: "E9E4F8",
|
|
79
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
const BUSINESS: SlidePalette[] = [
|
|
84
|
+
{
|
|
85
|
+
bg: "F8FAFC",
|
|
86
|
+
card: "FFFFFF",
|
|
87
|
+
primary: "1D4ED8",
|
|
88
|
+
accent: "60A5FA",
|
|
89
|
+
dark: "0F172A",
|
|
90
|
+
body: "1E293B",
|
|
91
|
+
muted: "64748B",
|
|
92
|
+
line: "DBEAFE",
|
|
93
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
bg: "EFF6FF",
|
|
97
|
+
card: "FFFFFF",
|
|
98
|
+
primary: "0F4C81",
|
|
99
|
+
accent: "93C5FD",
|
|
100
|
+
dark: "111827",
|
|
101
|
+
body: "1F2937",
|
|
102
|
+
muted: "64748B",
|
|
103
|
+
line: "D6E6F7",
|
|
104
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
bg: "F1F5F9",
|
|
108
|
+
card: "FFFFFF",
|
|
109
|
+
primary: "334155",
|
|
110
|
+
accent: "38BDF8",
|
|
111
|
+
dark: "0F172A",
|
|
112
|
+
body: "334155",
|
|
113
|
+
muted: "64748B",
|
|
114
|
+
line: "E2E8F0",
|
|
115
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
const TECH: SlidePalette[] = [
|
|
120
|
+
{
|
|
121
|
+
bg: "020617",
|
|
122
|
+
card: "0F172A",
|
|
123
|
+
primary: "22D3EE",
|
|
124
|
+
accent: "A78BFA",
|
|
125
|
+
dark: "F8FAFC",
|
|
126
|
+
body: "CBD5E1",
|
|
127
|
+
muted: "94A3B8",
|
|
128
|
+
line: "1E293B",
|
|
129
|
+
shadowOpacity: DARK_SHADOW,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
bg: "0B1120",
|
|
133
|
+
card: "111827",
|
|
134
|
+
primary: "38BDF8",
|
|
135
|
+
accent: "34D399",
|
|
136
|
+
dark: "E5E7EB",
|
|
137
|
+
body: "CBD5E1",
|
|
138
|
+
muted: "94A3B8",
|
|
139
|
+
line: "1F2937",
|
|
140
|
+
shadowOpacity: DARK_SHADOW,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
bg: "111827",
|
|
144
|
+
card: "1F2937",
|
|
145
|
+
primary: "818CF8",
|
|
146
|
+
accent: "22D3EE",
|
|
147
|
+
dark: "F9FAFB",
|
|
148
|
+
body: "D1D5DB",
|
|
149
|
+
muted: "9CA3AF",
|
|
150
|
+
line: "374151",
|
|
151
|
+
shadowOpacity: DARK_SHADOW,
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
const WARM: SlidePalette[] = [
|
|
156
|
+
{
|
|
157
|
+
bg: "FFF7ED",
|
|
158
|
+
card: "FFFFFF",
|
|
159
|
+
primary: "EA580C",
|
|
160
|
+
accent: "FDBA74",
|
|
161
|
+
dark: "431407",
|
|
162
|
+
body: "44403C",
|
|
163
|
+
muted: "A8A29E",
|
|
164
|
+
line: "FDE8D8",
|
|
165
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
bg: "FEF3C7",
|
|
169
|
+
card: "FFFBEB",
|
|
170
|
+
primary: "D97706",
|
|
171
|
+
accent: "F59E0B",
|
|
172
|
+
dark: "422006",
|
|
173
|
+
body: "44403C",
|
|
174
|
+
muted: "A8A29E",
|
|
175
|
+
line: "FDE9C0",
|
|
176
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
bg: "FFF1F2",
|
|
180
|
+
card: "FFFFFF",
|
|
181
|
+
primary: "E11D48",
|
|
182
|
+
accent: "FDA4AF",
|
|
183
|
+
dark: "4C0519",
|
|
184
|
+
body: "44403C",
|
|
185
|
+
muted: "A8A29E",
|
|
186
|
+
line: "FEE4E9",
|
|
187
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
|
|
191
|
+
const MINIMAL: SlidePalette[] = [
|
|
192
|
+
{
|
|
193
|
+
bg: "FFFFFF",
|
|
194
|
+
card: "F8FAFC",
|
|
195
|
+
primary: "111827",
|
|
196
|
+
accent: "CBD5E1",
|
|
197
|
+
dark: "111827",
|
|
198
|
+
body: "1F2937",
|
|
199
|
+
muted: "6B7280",
|
|
200
|
+
line: "E5E7EB",
|
|
201
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
bg: "FAFAFA",
|
|
205
|
+
card: "FFFFFF",
|
|
206
|
+
primary: "27272A",
|
|
207
|
+
accent: "A1A1AA",
|
|
208
|
+
dark: "18181B",
|
|
209
|
+
body: "27272A",
|
|
210
|
+
muted: "71717A",
|
|
211
|
+
line: "E4E4E7",
|
|
212
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
bg: "F4F4F5",
|
|
216
|
+
card: "FFFFFF",
|
|
217
|
+
primary: "3F3F46",
|
|
218
|
+
accent: "D4D4D8",
|
|
219
|
+
dark: "18181B",
|
|
220
|
+
body: "27272A",
|
|
221
|
+
muted: "71717A",
|
|
222
|
+
line: "E4E4E7",
|
|
223
|
+
shadowOpacity: LIGHT_SHADOW,
|
|
224
|
+
},
|
|
225
|
+
];
|
|
226
|
+
|
|
227
|
+
export function themePalettes(theme: ThemeName): SlidePalette[] {
|
|
228
|
+
switch (theme) {
|
|
229
|
+
case "business":
|
|
230
|
+
return BUSINESS;
|
|
231
|
+
case "tech":
|
|
232
|
+
return TECH;
|
|
233
|
+
case "warm":
|
|
234
|
+
return WARM;
|
|
235
|
+
case "minimal":
|
|
236
|
+
return MINIMAL;
|
|
237
|
+
default:
|
|
238
|
+
return DEFAULT;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* office_chart_generate — ECharts chart renderer.
|
|
3
|
+
*
|
|
4
|
+
* Takes plain labels/values, builds the option for the requested chart type,
|
|
5
|
+
* renders a standalone SVG server-side (no DOM, no browser) and writes three
|
|
6
|
+
* artifacts: .svg, an .html wrapper and the raw .json option.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { writeFileSync } from "node:fs";
|
|
10
|
+
import { t } from "@dalcode/dal-pi-kit";
|
|
11
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
12
|
+
import { Type } from "typebox";
|
|
13
|
+
import { resolveOutputPath } from "../paths.ts";
|
|
14
|
+
import { buildChartOption, type ChartType, chartHtml, renderChartSvg } from "../render/chart.ts";
|
|
15
|
+
import { displayPath, formatTemplate, type OfficeToolDetails, officeFailure, officeResult } from "./shared.ts";
|
|
16
|
+
|
|
17
|
+
const chartGenerateSchema = Type.Object({
|
|
18
|
+
title: Type.String({ description: t("图表标题(同时用作文件名)") }),
|
|
19
|
+
chartType: Type.Optional(
|
|
20
|
+
Type.Union(
|
|
21
|
+
[
|
|
22
|
+
Type.Literal("line"),
|
|
23
|
+
Type.Literal("bar"),
|
|
24
|
+
Type.Literal("pie"),
|
|
25
|
+
Type.Literal("gauge"),
|
|
26
|
+
Type.Literal("funnel"),
|
|
27
|
+
Type.Literal("scatter"),
|
|
28
|
+
],
|
|
29
|
+
{ description: t("图表类型,不确定时默认 bar") },
|
|
30
|
+
),
|
|
31
|
+
),
|
|
32
|
+
labels: Type.Array(Type.String(), {
|
|
33
|
+
minItems: 1,
|
|
34
|
+
maxItems: 50,
|
|
35
|
+
description: t("类目标签(饼图/漏斗为各项名称,仪表盘为指标名)"),
|
|
36
|
+
}),
|
|
37
|
+
values: Type.Array(Type.Number(), { minItems: 1, maxItems: 50, description: t("数值,纯数字,不带单位或百分号") }),
|
|
38
|
+
seriesName: Type.Optional(Type.String({ description: t("指标/系列名称") })),
|
|
39
|
+
summary: Type.Optional(Type.String({ description: t("图表说明,写进结果便于用户理解") })),
|
|
40
|
+
path: Type.Optional(Type.String({ description: t("输出文件路径(可选,相对当前目录,默认写入 office-outputs/)") })),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export function registerChartGenerate(pi: ExtensionAPI): void {
|
|
44
|
+
pi.registerTool<typeof chartGenerateSchema, OfficeToolDetails>({
|
|
45
|
+
name: "office_chart_generate",
|
|
46
|
+
label: t("生成图表"),
|
|
47
|
+
description: t(
|
|
48
|
+
"生成可视化图表:根据 labels/values 渲染 ECharts 图表,输出 .svg(可插入文档)、.html(浏览器打开)与 .json(图表配置)三个文件,适合趋势、对比、占比、排名、漏斗与指标可视化。",
|
|
49
|
+
),
|
|
50
|
+
promptSnippet: t("office_chart_generate - 生成 ECharts 图表(趋势/对比/占比/排名/漏斗/仪表盘)"),
|
|
51
|
+
promptGuidelines: [
|
|
52
|
+
t(
|
|
53
|
+
"对话中出现数据对比、趋势、占比、排名或漏斗诉求时用本工具,即使用户没有要求 PPT 或 Excel。labels 与 values 必须等长;values 是纯数字;数据要有业务含义,缺少真实数据时补出贴合场景的合理数据。",
|
|
54
|
+
),
|
|
55
|
+
],
|
|
56
|
+
parameters: chartGenerateSchema,
|
|
57
|
+
execute: async (_toolCallId, params, _signal, _onUpdate, ctx) => {
|
|
58
|
+
const title = params.title.trim();
|
|
59
|
+
if (title.length === 0) {
|
|
60
|
+
return officeFailure(t("title 不能为空"), "chart");
|
|
61
|
+
}
|
|
62
|
+
if (params.labels.length !== params.values.length) {
|
|
63
|
+
return officeFailure(
|
|
64
|
+
formatTemplate(t("labels 与 values 长度必须一致(当前 {labels} / {values}),请修正后重试。"), {
|
|
65
|
+
labels: params.labels.length,
|
|
66
|
+
values: params.values.length,
|
|
67
|
+
}),
|
|
68
|
+
"chart",
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const chartType: ChartType = params.chartType ?? "bar";
|
|
73
|
+
const option = buildChartOption({
|
|
74
|
+
title,
|
|
75
|
+
chartType,
|
|
76
|
+
labels: params.labels,
|
|
77
|
+
values: params.values,
|
|
78
|
+
...(params.seriesName !== undefined ? { seriesName: params.seriesName } : {}),
|
|
79
|
+
...(params.summary !== undefined ? { summary: params.summary } : {}),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
let svgTarget: string;
|
|
83
|
+
try {
|
|
84
|
+
svgTarget = resolveOutputPath(ctx.cwd, params.path, title, "svg");
|
|
85
|
+
} catch (error) {
|
|
86
|
+
return officeFailure(error instanceof Error ? error.message : String(error), "chart");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let svg: string;
|
|
90
|
+
try {
|
|
91
|
+
svg = renderChartSvg(option);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return officeFailure(
|
|
94
|
+
formatTemplate(t("图表渲染失败:{error}"), {
|
|
95
|
+
error: error instanceof Error ? error.message : String(error),
|
|
96
|
+
}),
|
|
97
|
+
"chart",
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const stem = svgTarget.slice(0, svgTarget.length - ".svg".length);
|
|
102
|
+
const htmlTarget = `${stem}.html`;
|
|
103
|
+
const jsonTarget = `${stem}.json`;
|
|
104
|
+
writeFileSync(svgTarget, svg, "utf8");
|
|
105
|
+
writeFileSync(htmlTarget, chartHtml(svg, title), "utf8");
|
|
106
|
+
writeFileSync(jsonTarget, JSON.stringify({ title, chartType, option }, null, 2), "utf8");
|
|
107
|
+
|
|
108
|
+
const files = [svgTarget, htmlTarget, jsonTarget].map((file) => displayPath(ctx.cwd, file));
|
|
109
|
+
const text = formatTemplate(
|
|
110
|
+
t(
|
|
111
|
+
"已生成《{title}》{type} 图表,共 3 个文件:\n{files}\n其中 .svg 可直接插入文档或浏览器查看,.json 保留图表配置便于二次修改。",
|
|
112
|
+
),
|
|
113
|
+
{
|
|
114
|
+
title,
|
|
115
|
+
type: chartType,
|
|
116
|
+
files: files.map((file) => `- ${file}`).join("\n"),
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
return officeResult(text, { ok: true, kind: "chart", files });
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* office_doc_generate — structured Word document renderer.
|
|
3
|
+
*
|
|
4
|
+
* Sections arrive fully drafted as tool parameters; the tool adds a scene
|
|
5
|
+
* hint to the observation, renders .docx with the house style, and writes
|
|
6
|
+
* the file under the session cwd.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { writeFileSync } from "node:fs";
|
|
10
|
+
import { t } from "@dalcode/dal-pi-kit";
|
|
11
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
12
|
+
import { Type } from "typebox";
|
|
13
|
+
import { resolveOutputPath } from "../paths.ts";
|
|
14
|
+
import { renderDocx } from "../render/docx.ts";
|
|
15
|
+
import { inferDocScene } from "../scenes.ts";
|
|
16
|
+
import { displayPath, formatTemplate, type OfficeToolDetails, officeFailure, officeResult } from "./shared.ts";
|
|
17
|
+
|
|
18
|
+
const MAX_SECTIONS = 30;
|
|
19
|
+
|
|
20
|
+
const docTableSchema = Type.Object({
|
|
21
|
+
headers: Type.Array(Type.String(), { minItems: 1, maxItems: 12, description: t("表格列名,要专业、可执行") }),
|
|
22
|
+
rows: Type.Array(Type.Array(Type.String()), {
|
|
23
|
+
minItems: 1,
|
|
24
|
+
maxItems: 200,
|
|
25
|
+
description: t("表格数据行,每行长度与列数一致"),
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const docGenerateSchema = Type.Object({
|
|
30
|
+
title: Type.String({ description: t("文档标题") }),
|
|
31
|
+
format: Type.Optional(
|
|
32
|
+
Type.Union(
|
|
33
|
+
[
|
|
34
|
+
Type.Literal("report"),
|
|
35
|
+
Type.Literal("plan"),
|
|
36
|
+
Type.Literal("summary"),
|
|
37
|
+
Type.Literal("article"),
|
|
38
|
+
Type.Literal("prd"),
|
|
39
|
+
],
|
|
40
|
+
{ description: t("文档类型:report 报告 / plan 计划 / summary 总结 / article 文章 / prd 需求文档") },
|
|
41
|
+
),
|
|
42
|
+
),
|
|
43
|
+
audience: Type.Optional(Type.String({ description: t("目标读者(可选),写入场景判断") })),
|
|
44
|
+
summary: Type.Optional(Type.String({ description: t("一句话说明本文档的价值") })),
|
|
45
|
+
sections: Type.Array(
|
|
46
|
+
Type.Object({
|
|
47
|
+
heading: Type.String({ description: t("章节标题") }),
|
|
48
|
+
headingLevel: Type.Optional(Type.Integer({ minimum: 1, maximum: 3, description: t("标题级别 1-3,默认 1") })),
|
|
49
|
+
paragraphs: Type.Optional(
|
|
50
|
+
Type.Array(Type.String(), { description: t("段落文本,每段 50-150 字,可用 **粗体** 与 *斜体* 标记") }),
|
|
51
|
+
),
|
|
52
|
+
bullets: Type.Optional(Type.Array(Type.String(), { description: t("要点列表") })),
|
|
53
|
+
table: Type.Optional(docTableSchema),
|
|
54
|
+
}),
|
|
55
|
+
{
|
|
56
|
+
minItems: 1,
|
|
57
|
+
maxItems: MAX_SECTIONS,
|
|
58
|
+
description: t("章节列表:按 背景 → 分析 → 方案 → 结论 组织,像正式交付文档而不是提纲"),
|
|
59
|
+
},
|
|
60
|
+
),
|
|
61
|
+
path: Type.Optional(Type.String({ description: t("输出文件路径(可选,相对当前目录,默认写入 office-outputs/)") })),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export function registerDocGenerate(pi: ExtensionAPI): void {
|
|
65
|
+
pi.registerTool<typeof docGenerateSchema, OfficeToolDetails>({
|
|
66
|
+
name: "office_doc_generate",
|
|
67
|
+
label: t("生成 Word 文档"),
|
|
68
|
+
description: t(
|
|
69
|
+
"生成结构化 Word 文档(.docx),支持报告、计划、总结、文章、PRD:sections 里给出完整章节内容(段落/要点/表格),工具负责排版渲染。",
|
|
70
|
+
),
|
|
71
|
+
promptSnippet: t("office_doc_generate - 生成结构化 Word 文档(报告/计划/总结/文章/PRD)"),
|
|
72
|
+
promptGuidelines: [
|
|
73
|
+
t(
|
|
74
|
+
"Word/文档/报告/PRD/方案/总结类需求用本工具。sections 必须构成可直接交付的完整文档:章节内容具体有深度,禁止空泛提纲、模板占位符或「待补充」;缺少具体数据时按场景补出合理的示例数据、角色、阶段、风险与收益。",
|
|
75
|
+
),
|
|
76
|
+
t(
|
|
77
|
+
"当用户说「先写提示词 / 先出方案 / 帮我构思 / 先规划一下」时,当前是文本规划意图:直接回复文本或用 office_md_generate,不要调用本工具生成最终产物。",
|
|
78
|
+
),
|
|
79
|
+
],
|
|
80
|
+
parameters: docGenerateSchema,
|
|
81
|
+
execute: async (_toolCallId, params, _signal, _onUpdate, ctx) => {
|
|
82
|
+
const title = params.title.trim();
|
|
83
|
+
if (title.length === 0) {
|
|
84
|
+
return officeFailure(t("title 不能为空"), "docx");
|
|
85
|
+
}
|
|
86
|
+
if (params.sections.length === 0) {
|
|
87
|
+
return officeFailure(t("sections 不能为空"), "docx");
|
|
88
|
+
}
|
|
89
|
+
const format = params.format ?? "report";
|
|
90
|
+
const scene = inferDocScene(`${title} ${params.audience ?? ""}`);
|
|
91
|
+
|
|
92
|
+
let target: string;
|
|
93
|
+
try {
|
|
94
|
+
target = resolveOutputPath(ctx.cwd, params.path, title, "docx");
|
|
95
|
+
} catch (error) {
|
|
96
|
+
return officeFailure(error instanceof Error ? error.message : String(error), "docx");
|
|
97
|
+
}
|
|
98
|
+
const buffer = await renderDocx({
|
|
99
|
+
title,
|
|
100
|
+
sections: params.sections,
|
|
101
|
+
...(params.summary !== undefined ? { summary: params.summary } : {}),
|
|
102
|
+
});
|
|
103
|
+
writeFileSync(target, buffer);
|
|
104
|
+
|
|
105
|
+
const text = formatTemplate(
|
|
106
|
+
t("已生成 Word 文档《{title}》({format}),共 {count} 个章节。\n文件:{file}\n{scene}"),
|
|
107
|
+
{
|
|
108
|
+
title,
|
|
109
|
+
format,
|
|
110
|
+
count: params.sections.length,
|
|
111
|
+
file: displayPath(ctx.cwd, target),
|
|
112
|
+
scene,
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
return officeResult(text, {
|
|
116
|
+
ok: true,
|
|
117
|
+
kind: "docx",
|
|
118
|
+
file: displayPath(ctx.cwd, target),
|
|
119
|
+
sectionCount: params.sections.length,
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* office_drawio_generate — draw.io diagram writer.
|
|
3
|
+
*
|
|
4
|
+
* The model authors the draw.io XML itself; the tool strips accidental
|
|
5
|
+
* markdown fences, validates the root element, and writes a .drawio file
|
|
6
|
+
* that opens directly in draw.io / diagrams.net / VS Code.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { writeFileSync } from "node:fs";
|
|
10
|
+
import { t } from "@dalcode/dal-pi-kit";
|
|
11
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
12
|
+
import { Type } from "typebox";
|
|
13
|
+
import { resolveOutputPath } from "../paths.ts";
|
|
14
|
+
import { inferDiagramScene } from "../scenes.ts";
|
|
15
|
+
import { displayPath, formatTemplate, type OfficeToolDetails, officeFailure, officeResult } from "./shared.ts";
|
|
16
|
+
|
|
17
|
+
/** Removes a wrapping markdown code fence, if the model added one. */
|
|
18
|
+
export function stripMarkdownFence(xml: string): string {
|
|
19
|
+
return xml
|
|
20
|
+
.trim()
|
|
21
|
+
.replace(/^```(?:xml|html)?\s*\n?/, "")
|
|
22
|
+
.replace(/\n?```\s*$/, "")
|
|
23
|
+
.trim();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const drawioGenerateSchema = Type.Object({
|
|
27
|
+
topic: Type.String({ description: t("图表主题/用户需求") }),
|
|
28
|
+
diagramType: Type.Optional(
|
|
29
|
+
Type.Union(
|
|
30
|
+
[
|
|
31
|
+
Type.Literal("flowchart"),
|
|
32
|
+
Type.Literal("architecture"),
|
|
33
|
+
Type.Literal("swimlane"),
|
|
34
|
+
Type.Literal("topology"),
|
|
35
|
+
Type.Literal("er"),
|
|
36
|
+
Type.Literal("mindmap"),
|
|
37
|
+
],
|
|
38
|
+
{
|
|
39
|
+
description: t(
|
|
40
|
+
"图表类型:flowchart 流程图 / architecture 架构图 / swimlane 泳道图 / topology 拓扑图 / er 实体关系图 / mindmap 思维导图",
|
|
41
|
+
),
|
|
42
|
+
},
|
|
43
|
+
),
|
|
44
|
+
),
|
|
45
|
+
xml: Type.String({
|
|
46
|
+
description: t("完整 draw.io XML(mxGraphModel 或 mxfile 格式),使用合理布局坐标、箭头表达关系、中文标签"),
|
|
47
|
+
}),
|
|
48
|
+
path: Type.Optional(Type.String({ description: t("输出文件路径(可选,相对当前目录,默认写入 office-outputs/)") })),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export function registerDrawioGenerate(pi: ExtensionAPI): void {
|
|
52
|
+
pi.registerTool<typeof drawioGenerateSchema, OfficeToolDetails>({
|
|
53
|
+
name: "office_drawio_generate",
|
|
54
|
+
label: t("生成 draw.io 图表"),
|
|
55
|
+
description: t(
|
|
56
|
+
"生成 draw.io 可编辑图表(.drawio):流程图、架构图、泳道图、拓扑图、ER 图、思维导图。xml 参数给出完整 draw.io XML,工具负责校验与落盘。",
|
|
57
|
+
),
|
|
58
|
+
promptSnippet: t("office_drawio_generate - 生成 draw.io 可编辑图表(流程/架构/泳道/拓扑/ER/思维导图)"),
|
|
59
|
+
promptGuidelines: [
|
|
60
|
+
t(
|
|
61
|
+
"流程图/架构图/泳道图/拓扑图/ER图/思维导图类需求用本工具。xml 要有合理布局坐标:节点不重叠、用箭头连接表达关系、用颜色区分节点类型、中文标签;布局要「对外能讲清楚」,不要把所有节点排成一行。用户缺少细节时补足合理的模块、阶段、角色或组件。",
|
|
62
|
+
),
|
|
63
|
+
],
|
|
64
|
+
parameters: drawioGenerateSchema,
|
|
65
|
+
execute: async (_toolCallId, params, _signal, _onUpdate, ctx) => {
|
|
66
|
+
const topic = params.topic.trim();
|
|
67
|
+
if (topic.length === 0) {
|
|
68
|
+
return officeFailure(t("topic 不能为空"), "drawio");
|
|
69
|
+
}
|
|
70
|
+
const xml = stripMarkdownFence(params.xml);
|
|
71
|
+
if (!xml.includes("<mxGraphModel") && !xml.includes("<mxfile")) {
|
|
72
|
+
return officeFailure(
|
|
73
|
+
t("不是有效的 draw.io XML:需要包含 <mxGraphModel> 或 <mxfile> 根元素,请修正后重试。"),
|
|
74
|
+
"drawio",
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
const scene = inferDiagramScene(topic);
|
|
78
|
+
let target: string;
|
|
79
|
+
try {
|
|
80
|
+
target = resolveOutputPath(ctx.cwd, params.path, topic, "drawio");
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return officeFailure(error instanceof Error ? error.message : String(error), "drawio");
|
|
83
|
+
}
|
|
84
|
+
writeFileSync(target, xml, "utf8");
|
|
85
|
+
|
|
86
|
+
const diagramType = params.diagramType ?? "flowchart";
|
|
87
|
+
const text = formatTemplate(
|
|
88
|
+
t("已生成《{topic}》{type}。\n文件:{file}\n可用 draw.io / diagrams.net 打开继续编辑。{scene}"),
|
|
89
|
+
{
|
|
90
|
+
topic,
|
|
91
|
+
type: diagramType,
|
|
92
|
+
file: displayPath(ctx.cwd, target),
|
|
93
|
+
scene: `\n${scene}`,
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
return officeResult(text, { ok: true, kind: "drawio", file: displayPath(ctx.cwd, target) });
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|