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,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PPTX renderer: turns a presentation plan into a real .pptx file.
|
|
3
|
+
*
|
|
4
|
+
* Slides are laid out deterministically — three layout archetypes (title /
|
|
5
|
+
* section / content, with an automatic two-column variant for dense pages)
|
|
6
|
+
* on a 13.33x7.5 inch canvas, colored from the theme palettes rotating per
|
|
7
|
+
* slide — so identical plans always render to identical decks and no LLM
|
|
8
|
+
* call is needed at render time.
|
|
9
|
+
*
|
|
10
|
+
* House style: Microsoft YaHei everywhere, soft card shadows, hairline
|
|
11
|
+
* rules, numbered body points, a running footer with page numbers, and
|
|
12
|
+
* translucent decorative shapes for depth.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import PptxGenJSImport from "pptxgenjs";
|
|
16
|
+
import type { OfficePresentationPlan, OfficeSlidePlan } from "../scratchpad.ts";
|
|
17
|
+
import { type SlidePalette, type ThemeName, themePalettes } from "../themes.ts";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Minimal surface of pptxgenjs this renderer drives.
|
|
21
|
+
*
|
|
22
|
+
* Under NodeNext the library's CJS build does not expose a constructable
|
|
23
|
+
* default through its type declarations, so the import is cast to this
|
|
24
|
+
* interface — the runtime shape (UMD class) matches it exactly.
|
|
25
|
+
*/
|
|
26
|
+
type PptxTextRun = { text: string; options?: Record<string, unknown> };
|
|
27
|
+
|
|
28
|
+
interface PptxSlide {
|
|
29
|
+
addShape(shape: string, options: Record<string, unknown>): void;
|
|
30
|
+
addText(text: string | PptxTextRun[], options: Record<string, unknown>): void;
|
|
31
|
+
addNotes(text: string): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface PptxPresentation {
|
|
35
|
+
layout: string;
|
|
36
|
+
title: string;
|
|
37
|
+
author: string;
|
|
38
|
+
company: string;
|
|
39
|
+
defineLayout(options: { name: string; width: number; height: number }): void;
|
|
40
|
+
addSlide(): PptxSlide;
|
|
41
|
+
write(options: { outputType: "nodebuffer" }): Promise<Buffer>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const PptxGenJS = PptxGenJSImport as unknown as new () => PptxPresentation;
|
|
45
|
+
|
|
46
|
+
/** 16:9 canvas in inches (pptxgenjs works in inches). */
|
|
47
|
+
const PAGE_W = 13.33;
|
|
48
|
+
const PAGE_H = 7.5;
|
|
49
|
+
|
|
50
|
+
const FONT = "Microsoft YaHei";
|
|
51
|
+
const SUBTITLE_FALLBACK = "现代简洁演示文稿";
|
|
52
|
+
const BRAND = "DAL Code";
|
|
53
|
+
|
|
54
|
+
interface ShapeSpec {
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
w: number;
|
|
58
|
+
h: number;
|
|
59
|
+
fill: string;
|
|
60
|
+
shape: "rect" | "roundRect" | "ellipse" | "line";
|
|
61
|
+
transparency?: number;
|
|
62
|
+
rectRadius?: number;
|
|
63
|
+
lineWidth?: number;
|
|
64
|
+
shadowOpacity?: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface TextSpec {
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
70
|
+
w: number;
|
|
71
|
+
h: number;
|
|
72
|
+
content: string | PptxTextRun[];
|
|
73
|
+
fontSize: number;
|
|
74
|
+
/** Run-level colors win when content carries its own runs; omit for run-colored text. */
|
|
75
|
+
color?: string;
|
|
76
|
+
bold?: boolean;
|
|
77
|
+
align?: "left" | "center" | "right";
|
|
78
|
+
valign?: "top" | "middle" | "bottom";
|
|
79
|
+
transparency?: number;
|
|
80
|
+
charSpacing?: number;
|
|
81
|
+
lineSpacingMultiple?: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function text(spec: TextSpec): TextSpec {
|
|
85
|
+
return spec;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function shape(spec: ShapeSpec): ShapeSpec {
|
|
89
|
+
return spec;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function isText(element: ShapeSpec | TextSpec): element is TextSpec {
|
|
93
|
+
return "content" in element;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Zero-padded slide marker, e.g. "03". */
|
|
97
|
+
function marker(index: number): string {
|
|
98
|
+
return String(index).padStart(2, "0");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function titleSlideElements(plan: OfficeSlidePlan, c: SlidePalette, year: number): Array<ShapeSpec | TextSpec> {
|
|
102
|
+
const subtitle = plan.goal ?? plan.visual ?? SUBTITLE_FALLBACK;
|
|
103
|
+
return [
|
|
104
|
+
shape({ x: 0, y: 0, w: PAGE_W, h: PAGE_H, fill: c.bg, shape: "rect" }),
|
|
105
|
+
// Layered translucent washes in the top-right corner for depth.
|
|
106
|
+
shape({ x: 8.1, y: -2.1, w: 7.2, h: 7.2, fill: c.accent, shape: "ellipse", transparency: 84 }),
|
|
107
|
+
shape({ x: 10.4, y: -1.2, w: 4.4, h: 4.4, fill: c.primary, shape: "ellipse", transparency: 88 }),
|
|
108
|
+
shape({ x: 11.35, y: 1.15, w: 0.5, h: 0.5, fill: c.primary, shape: "ellipse" }),
|
|
109
|
+
// Kicker with a short accent bar.
|
|
110
|
+
shape({ x: 0.92, y: 2.14, w: 0.42, h: 0.065, fill: c.primary, shape: "rect" }),
|
|
111
|
+
text({
|
|
112
|
+
x: 1.5,
|
|
113
|
+
y: 1.98,
|
|
114
|
+
w: 8,
|
|
115
|
+
h: 0.36,
|
|
116
|
+
content: BRAND,
|
|
117
|
+
fontSize: 13,
|
|
118
|
+
color: c.primary,
|
|
119
|
+
bold: true,
|
|
120
|
+
charSpacing: 3,
|
|
121
|
+
}),
|
|
122
|
+
text({ x: 0.9, y: 2.52, w: 11.6, h: 1.15, content: plan.title, fontSize: 46, color: c.dark, bold: true }),
|
|
123
|
+
shape({ x: 0.95, y: 3.98, w: 2.1, h: 0, fill: c.accent, shape: "line", lineWidth: 2.25 }),
|
|
124
|
+
text({ x: 0.9, y: 4.22, w: 10.2, h: 0.55, content: subtitle, fontSize: 20, color: c.muted }),
|
|
125
|
+
// Bottom row: brand left, four points motif right.
|
|
126
|
+
text({ x: 0.92, y: 6.82, w: 4.5, h: 0.3, content: `${BRAND} · ${year}`, fontSize: 12, color: c.muted }),
|
|
127
|
+
text({
|
|
128
|
+
x: 9.9,
|
|
129
|
+
y: 6.82,
|
|
130
|
+
w: 2.55,
|
|
131
|
+
h: 0.3,
|
|
132
|
+
content: "· · · ·",
|
|
133
|
+
fontSize: 12,
|
|
134
|
+
color: c.accent,
|
|
135
|
+
align: "right",
|
|
136
|
+
charSpacing: 2,
|
|
137
|
+
}),
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function sectionSlideElements(plan: OfficeSlidePlan, c: SlidePalette, ordinal: number): Array<ShapeSpec | TextSpec> {
|
|
142
|
+
return [
|
|
143
|
+
shape({ x: 0, y: 0, w: PAGE_W, h: PAGE_H, fill: c.primary, shape: "rect" }),
|
|
144
|
+
shape({ x: 8.9, y: -1.6, w: 5.6, h: 5.6, fill: c.accent, shape: "ellipse", transparency: 74 }),
|
|
145
|
+
// Ghost section number on the right.
|
|
146
|
+
text({
|
|
147
|
+
x: 7.6,
|
|
148
|
+
y: 2.15,
|
|
149
|
+
w: 4.9,
|
|
150
|
+
h: 2.6,
|
|
151
|
+
content: marker(ordinal),
|
|
152
|
+
fontSize: 120,
|
|
153
|
+
color: c.bg,
|
|
154
|
+
bold: true,
|
|
155
|
+
align: "right",
|
|
156
|
+
transparency: 72,
|
|
157
|
+
}),
|
|
158
|
+
shape({ x: 1.0, y: 2.98, w: 0.6, h: 0.07, fill: c.bg, shape: "rect", transparency: 30 }),
|
|
159
|
+
text({ x: 0.98, y: 3.22, w: 8.2, h: 1.0, content: plan.title, fontSize: 40, color: c.bg, bold: true }),
|
|
160
|
+
text({ x: 1.02, y: 4.42, w: 9.0, h: 0.5, content: plan.goal ?? "", fontSize: 18, color: c.bg, transparency: 22 }),
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Numbered point paragraphs: primary "01" marker + body text, with breathing room. */
|
|
165
|
+
function numberedPoints(points: string[], c: SlidePalette, paraSpaceAfter: number, startAt = 1): PptxTextRun[] {
|
|
166
|
+
return points.flatMap((point, index) => [
|
|
167
|
+
{ text: `${marker(startAt + index)} `, options: { color: c.primary, bold: true } },
|
|
168
|
+
{ text: point, options: { color: c.body, breakLine: true, paraSpaceAfter } },
|
|
169
|
+
]);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function contentSlideElements(
|
|
173
|
+
plan: OfficeSlidePlan,
|
|
174
|
+
c: SlidePalette,
|
|
175
|
+
deckTitle: string,
|
|
176
|
+
index: number,
|
|
177
|
+
total: number,
|
|
178
|
+
): Array<ShapeSpec | TextSpec> {
|
|
179
|
+
const elements: Array<ShapeSpec | TextSpec> = [
|
|
180
|
+
shape({ x: 0, y: 0, w: PAGE_W, h: PAGE_H, fill: c.bg, shape: "rect" }),
|
|
181
|
+
shape({
|
|
182
|
+
x: 0.75,
|
|
183
|
+
y: 0.7,
|
|
184
|
+
w: 11.83,
|
|
185
|
+
h: 6.1,
|
|
186
|
+
fill: c.card,
|
|
187
|
+
shape: "roundRect",
|
|
188
|
+
rectRadius: 0.13,
|
|
189
|
+
shadowOpacity: c.shadowOpacity,
|
|
190
|
+
}),
|
|
191
|
+
// Kicker (deck title) and page marker inside the card.
|
|
192
|
+
text({ x: 1.16, y: 1.0, w: 8.5, h: 0.3, content: deckTitle, fontSize: 11, color: c.muted, charSpacing: 1.5 }),
|
|
193
|
+
text({
|
|
194
|
+
x: 10.2,
|
|
195
|
+
y: 1.0,
|
|
196
|
+
w: 2.0,
|
|
197
|
+
h: 0.3,
|
|
198
|
+
content: `${marker(index + 1)} / ${marker(total)}`,
|
|
199
|
+
fontSize: 11,
|
|
200
|
+
color: c.muted,
|
|
201
|
+
align: "right",
|
|
202
|
+
}),
|
|
203
|
+
text({ x: 1.13, y: 1.36, w: 11.0, h: 0.78, content: plan.title, fontSize: 30, color: c.dark, bold: true }),
|
|
204
|
+
shape({ x: 1.16, y: 2.26, w: 0.85, h: 0.055, fill: c.primary, shape: "rect" }),
|
|
205
|
+
];
|
|
206
|
+
|
|
207
|
+
const points = (plan.points ?? []).slice(0, 8);
|
|
208
|
+
if (points.length > 0) {
|
|
209
|
+
const twoColumn = plan.layout === "two-column" || points.length > 4;
|
|
210
|
+
if (twoColumn) {
|
|
211
|
+
const half = Math.ceil(points.length / 2);
|
|
212
|
+
elements.push(
|
|
213
|
+
shape({ x: 6.6, y: 2.78, w: 0, h: 3.1, fill: c.line, shape: "line", lineWidth: 1 }),
|
|
214
|
+
text({
|
|
215
|
+
x: 1.2,
|
|
216
|
+
y: 2.72,
|
|
217
|
+
w: 5.05,
|
|
218
|
+
h: 3.4,
|
|
219
|
+
content: numberedPoints(points.slice(0, half), c, 10),
|
|
220
|
+
fontSize: 16.5,
|
|
221
|
+
valign: "top",
|
|
222
|
+
lineSpacingMultiple: 1.16,
|
|
223
|
+
}),
|
|
224
|
+
text({
|
|
225
|
+
x: 6.95,
|
|
226
|
+
y: 2.72,
|
|
227
|
+
w: 5.15,
|
|
228
|
+
h: 3.4,
|
|
229
|
+
content: numberedPoints(points.slice(half), c, 10, half + 1),
|
|
230
|
+
fontSize: 16.5,
|
|
231
|
+
valign: "top",
|
|
232
|
+
lineSpacingMultiple: 1.16,
|
|
233
|
+
}),
|
|
234
|
+
);
|
|
235
|
+
} else {
|
|
236
|
+
elements.push(
|
|
237
|
+
text({
|
|
238
|
+
x: 1.2,
|
|
239
|
+
y: 2.62,
|
|
240
|
+
w: 10.9,
|
|
241
|
+
h: 3.6,
|
|
242
|
+
content: numberedPoints(points, c, 15),
|
|
243
|
+
fontSize: 18.5,
|
|
244
|
+
valign: "top",
|
|
245
|
+
lineSpacingMultiple: 1.22,
|
|
246
|
+
}),
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (plan.goal) {
|
|
252
|
+
elements.push(
|
|
253
|
+
shape({ x: 1.2, y: 6.28, w: 0.055, h: 0.32, fill: c.primary, shape: "rect" }),
|
|
254
|
+
text({
|
|
255
|
+
x: 1.38,
|
|
256
|
+
y: 6.24,
|
|
257
|
+
w: 10.6,
|
|
258
|
+
h: 0.4,
|
|
259
|
+
content: plan.goal,
|
|
260
|
+
fontSize: 12.5,
|
|
261
|
+
color: c.muted,
|
|
262
|
+
valign: "middle",
|
|
263
|
+
}),
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
return elements;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function isTitleSlide(plan: OfficeSlidePlan, index: number): boolean {
|
|
270
|
+
return index === 0 || plan.layout === "title";
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** Minimal three-slide plan used when neither scratchpad nor inline slides are available. */
|
|
274
|
+
export function fallbackPlan(title: string, topic: string): OfficePresentationPlan {
|
|
275
|
+
return {
|
|
276
|
+
title,
|
|
277
|
+
slides: [
|
|
278
|
+
{ title, layout: "title", goal: topic, visual: "标题页" },
|
|
279
|
+
{
|
|
280
|
+
title: "核心内容",
|
|
281
|
+
layout: "content",
|
|
282
|
+
goal: "展开说明",
|
|
283
|
+
points: ["核心观点", "关键价值", "应用场景", "下一步"],
|
|
284
|
+
visual: "卡片列表",
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
title: "总结",
|
|
288
|
+
layout: "content",
|
|
289
|
+
goal: "总结与展望",
|
|
290
|
+
points: ["成果回顾", "未来规划"],
|
|
291
|
+
visual: "要点总结",
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export async function renderPptx(plan: OfficePresentationPlan, theme: ThemeName): Promise<Buffer> {
|
|
298
|
+
const pptx: PptxPresentation = new PptxGenJS();
|
|
299
|
+
pptx.defineLayout({ name: "W16x9", width: 13.333, height: 7.5 });
|
|
300
|
+
pptx.layout = "W16x9";
|
|
301
|
+
pptx.title = plan.title;
|
|
302
|
+
pptx.author = BRAND;
|
|
303
|
+
pptx.company = BRAND;
|
|
304
|
+
|
|
305
|
+
const palettes = themePalettes(theme);
|
|
306
|
+
const year = new Date().getFullYear();
|
|
307
|
+
const total = plan.slides.length;
|
|
308
|
+
|
|
309
|
+
// Sections are numbered in presentation order for the ghost marker.
|
|
310
|
+
const sectionOrdinals = new Map<number, number>();
|
|
311
|
+
let sectionOrdinal = 0;
|
|
312
|
+
plan.slides.forEach((slidePlan, index) => {
|
|
313
|
+
if (slidePlan.layout === "section") {
|
|
314
|
+
sectionOrdinal += 1;
|
|
315
|
+
sectionOrdinals.set(index, sectionOrdinal);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
plan.slides.forEach((slidePlan, index) => {
|
|
320
|
+
const slide = pptx.addSlide();
|
|
321
|
+
const c = palettes[index % palettes.length];
|
|
322
|
+
const elements = isTitleSlide(slidePlan, index)
|
|
323
|
+
? titleSlideElements(slidePlan, c, year)
|
|
324
|
+
: slidePlan.layout === "section"
|
|
325
|
+
? sectionSlideElements(slidePlan, c, sectionOrdinals.get(index) ?? sectionOrdinal)
|
|
326
|
+
: contentSlideElements(slidePlan, c, plan.title, index, total);
|
|
327
|
+
|
|
328
|
+
for (const element of elements) {
|
|
329
|
+
if (isText(element)) {
|
|
330
|
+
slide.addText(element.content, {
|
|
331
|
+
x: element.x,
|
|
332
|
+
y: element.y,
|
|
333
|
+
w: element.w,
|
|
334
|
+
h: element.h,
|
|
335
|
+
fontSize: element.fontSize,
|
|
336
|
+
fontFace: FONT,
|
|
337
|
+
...(element.color !== undefined ? { color: element.color } : {}),
|
|
338
|
+
bold: element.bold ?? false,
|
|
339
|
+
align: element.align ?? "left",
|
|
340
|
+
valign: element.valign ?? "top",
|
|
341
|
+
margin: 0,
|
|
342
|
+
...(element.transparency !== undefined ? { transparency: element.transparency } : {}),
|
|
343
|
+
...(element.charSpacing !== undefined ? { charSpacing: element.charSpacing } : {}),
|
|
344
|
+
...(element.lineSpacingMultiple !== undefined
|
|
345
|
+
? { lineSpacingMultiple: element.lineSpacingMultiple }
|
|
346
|
+
: {}),
|
|
347
|
+
});
|
|
348
|
+
} else {
|
|
349
|
+
const shapeOptions: Record<string, unknown> = {
|
|
350
|
+
x: element.x,
|
|
351
|
+
y: element.y,
|
|
352
|
+
w: element.w,
|
|
353
|
+
h: element.h,
|
|
354
|
+
fill: {
|
|
355
|
+
color: element.fill,
|
|
356
|
+
...(element.transparency !== undefined ? { transparency: element.transparency } : {}),
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
if (element.shape === "line") {
|
|
360
|
+
shapeOptions.line = { color: element.fill, width: element.lineWidth ?? 1 };
|
|
361
|
+
}
|
|
362
|
+
if (element.rectRadius !== undefined) {
|
|
363
|
+
shapeOptions.rectRadius = element.rectRadius;
|
|
364
|
+
}
|
|
365
|
+
if (element.shadowOpacity !== undefined) {
|
|
366
|
+
shapeOptions.shadow = {
|
|
367
|
+
type: "outer",
|
|
368
|
+
angle: 90,
|
|
369
|
+
blur: 14,
|
|
370
|
+
offset: 4,
|
|
371
|
+
color: "0F172A",
|
|
372
|
+
opacity: element.shadowOpacity,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
slide.addShape(element.shape, shapeOptions);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (slidePlan.goal && !isTitleSlide(slidePlan, index) && slidePlan.layout !== "section") {
|
|
380
|
+
slide.addNotes(slidePlan.goal);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
const data = (await pptx.write({ outputType: "nodebuffer" })) as Buffer;
|
|
385
|
+
return data;
|
|
386
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XLSX renderer: turns named tables into an Excel workbook.
|
|
3
|
+
*
|
|
4
|
+
* One worksheet per table (frozen header row, bold header, auto-sized
|
|
5
|
+
* columns, thin borders). Numeric-looking cells are written as real numbers
|
|
6
|
+
* so columns sort and aggregate correctly in Excel/WPS.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import ExcelJS from "exceljs";
|
|
10
|
+
|
|
11
|
+
export interface SheetTableInput {
|
|
12
|
+
title: string;
|
|
13
|
+
headers: string[];
|
|
14
|
+
rows: string[][];
|
|
15
|
+
summary?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SheetOutputInput {
|
|
19
|
+
title: string;
|
|
20
|
+
summary?: string;
|
|
21
|
+
tables: SheetTableInput[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const HEADER_FILL = "FFE8EEF7";
|
|
25
|
+
const BORDER_COLOR = "FFCCCCCC";
|
|
26
|
+
const MIN_COL_WIDTH = 10;
|
|
27
|
+
const MAX_COL_WIDTH = 48;
|
|
28
|
+
|
|
29
|
+
/** Excel worksheet names: <=31 chars, no []:*?/\ — collisions get a numeric suffix. */
|
|
30
|
+
export function sanitizeSheetName(name: string, used: Set<string>): string {
|
|
31
|
+
const cleaned =
|
|
32
|
+
name
|
|
33
|
+
.replace(/[[\]:*?/\\]/g, " ")
|
|
34
|
+
.trim()
|
|
35
|
+
.slice(0, 28) || "Sheet";
|
|
36
|
+
let candidate = cleaned;
|
|
37
|
+
for (let attempt = 2; used.has(candidate); attempt++) {
|
|
38
|
+
candidate = `${cleaned}-${attempt}`;
|
|
39
|
+
}
|
|
40
|
+
used.add(candidate);
|
|
41
|
+
return candidate;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Numeric-looking strings become numbers; anything else stays text. */
|
|
45
|
+
export function coerceCell(value: string): string | number {
|
|
46
|
+
const trimmed = value.trim();
|
|
47
|
+
if (/^-?\d{1,15}(\.\d+)?$/.test(trimmed) && trimmed.length > 0) {
|
|
48
|
+
return Number(trimmed);
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function thinBorders(): Partial<ExcelJS.Borders> {
|
|
54
|
+
const border = { style: "thin" as const, color: { argb: BORDER_COLOR } };
|
|
55
|
+
return { top: border, left: border, bottom: border, right: border };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function renderXlsx(output: SheetOutputInput): Promise<Buffer> {
|
|
59
|
+
const workbook = new ExcelJS.Workbook();
|
|
60
|
+
workbook.creator = "DAL Code";
|
|
61
|
+
workbook.created = new Date();
|
|
62
|
+
const usedNames = new Set<string>();
|
|
63
|
+
|
|
64
|
+
for (const table of output.tables) {
|
|
65
|
+
const sheet = workbook.addWorksheet(sanitizeSheetName(table.title, usedNames), {
|
|
66
|
+
views: [{ state: "frozen", ySplit: 1 }],
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const headerRow = sheet.addRow(table.headers);
|
|
70
|
+
headerRow.eachCell((cell) => {
|
|
71
|
+
cell.font = { bold: true };
|
|
72
|
+
cell.fill = { type: "pattern", pattern: "solid", fgColor: { argb: HEADER_FILL } };
|
|
73
|
+
cell.border = thinBorders();
|
|
74
|
+
cell.alignment = { vertical: "middle" };
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
for (const row of table.rows) {
|
|
78
|
+
const added = sheet.addRow(row.map(coerceCell));
|
|
79
|
+
added.eachCell((cell) => {
|
|
80
|
+
cell.border = thinBorders();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
for (let col = 1; col <= table.headers.length; col++) {
|
|
85
|
+
let width = table.headers[col - 1]?.length ?? MIN_COL_WIDTH;
|
|
86
|
+
for (const row of table.rows) {
|
|
87
|
+
width = Math.max(width, row[col - 1]?.length ?? 0);
|
|
88
|
+
}
|
|
89
|
+
sheet.getColumn(col).width = Math.min(Math.max(width + 2, MIN_COL_WIDTH), MAX_COL_WIDTH);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (table.summary) {
|
|
93
|
+
sheet.getCell("A1").note = table.summary;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const data = await workbook.xlsx.writeBuffer();
|
|
98
|
+
return Buffer.from(data as unknown as Uint8Array);
|
|
99
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Business-scene inference shared by the document-generation tools.
|
|
3
|
+
*
|
|
4
|
+
* A tiny keyword scorer over the user's topic picks one of six common
|
|
5
|
+
* business scenes (product, operations, sales, tech, training, project) and
|
|
6
|
+
* returns an organizational hint that is appended to the tool observation —
|
|
7
|
+
* nudging the model toward the structure a reviewer would expect from that
|
|
8
|
+
* kind of deliverable.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { t } from "@dalcode/dal-pi-kit";
|
|
12
|
+
|
|
13
|
+
export interface SceneRule {
|
|
14
|
+
keywords: string[];
|
|
15
|
+
guide: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function rule(keywords: string[], guide: string): SceneRule {
|
|
19
|
+
return { keywords, guide: t(guide) };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Scene rules for presentation outlines. */
|
|
23
|
+
export const PPT_SCENE_RULES: SceneRule[] = [
|
|
24
|
+
rule(
|
|
25
|
+
["产品", "需求", "prd", "roadmap", "版本", "迭代", "用户故事", "feature"],
|
|
26
|
+
"当前更像产品方案场景,优先组织为:背景与机会、用户与问题、方案设计、核心流程、版本规划、收益与风险。",
|
|
27
|
+
),
|
|
28
|
+
rule(
|
|
29
|
+
["运营", "增长", "拉新", "留存", "转化", "活动", "campaign", "gmv"],
|
|
30
|
+
"当前更像运营复盘/增长场景,优先组织为:目标与结果、核心指标、问题拆解、关键动作、复盘结论、下阶段计划。",
|
|
31
|
+
),
|
|
32
|
+
rule(
|
|
33
|
+
["销售", "客户", "商机", "渠道", "业绩", "回款", "签约", "线索"],
|
|
34
|
+
"当前更像销售汇报场景,优先组织为:业绩概览、区域/客户分析、机会与风险、重点动作、预测与资源诉求。",
|
|
35
|
+
),
|
|
36
|
+
rule(
|
|
37
|
+
["技术", "架构", "系统", "平台", "接口", "部署", "微服务", "数据库", "agent", "ai"],
|
|
38
|
+
"当前更像技术设计/架构汇报场景,优先组织为:建设背景、总体架构、模块分层、关键流程、稳定性与安全、落地计划。",
|
|
39
|
+
),
|
|
40
|
+
rule(
|
|
41
|
+
["培训", "课程", "学习", "上手", "入门", "手册", "宣导", "workshop"],
|
|
42
|
+
"当前更像培训课件场景,优先组织为:学习目标、核心概念、方法步骤、案例演示、常见误区、行动建议。",
|
|
43
|
+
),
|
|
44
|
+
rule(
|
|
45
|
+
["项目", "排期", "里程碑", "实施", "交付", "风险", "计划"],
|
|
46
|
+
"当前更像项目实施/计划汇报场景,优先组织为:目标范围、阶段计划、里程碑、角色分工、风险依赖、验收标准。",
|
|
47
|
+
),
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
/** Scene rules for Word-style documents. */
|
|
51
|
+
export const DOC_SCENE_RULES: SceneRule[] = [
|
|
52
|
+
rule(
|
|
53
|
+
["产品", "需求", "prd", "roadmap", "版本", "迭代", "用户故事", "feature"],
|
|
54
|
+
"当前更像产品方案/PRD 场景,请重点补足用户场景、功能设计、流程说明、优先级、边界和验收标准。",
|
|
55
|
+
),
|
|
56
|
+
rule(
|
|
57
|
+
["运营", "增长", "拉新", "留存", "转化", "活动", "campaign", "gmv"],
|
|
58
|
+
"当前更像运营分析/复盘场景,请重点补足指标口径、动作拆解、问题诊断、结论和下阶段策略。",
|
|
59
|
+
),
|
|
60
|
+
rule(
|
|
61
|
+
["销售", "客户", "商机", "渠道", "业绩", "回款", "签约", "线索"],
|
|
62
|
+
"当前更像销售方案/经营汇报场景,请重点补足业绩结构、客户分层、商机推进、风险点和资源诉求。",
|
|
63
|
+
),
|
|
64
|
+
rule(
|
|
65
|
+
["技术", "架构", "系统", "平台", "接口", "部署", "微服务", "数据库", "agent", "ai"],
|
|
66
|
+
"当前更像技术设计文档场景,请重点补足架构分层、关键流程、接口边界、依赖项、稳定性和安全要求。",
|
|
67
|
+
),
|
|
68
|
+
rule(
|
|
69
|
+
["培训", "课程", "学习", "上手", "入门", "手册", "宣导", "workshop"],
|
|
70
|
+
"当前更像培训手册/课程文档场景,请重点补足学习目标、章节安排、案例说明、常见问题和实践建议。",
|
|
71
|
+
),
|
|
72
|
+
rule(
|
|
73
|
+
["项目", "排期", "里程碑", "实施", "交付", "风险", "计划"],
|
|
74
|
+
"当前更像项目实施/交付文档场景,请重点补足阶段任务、责任分工、里程碑、风险依赖和验收方式。",
|
|
75
|
+
),
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
/** Scene rules for spreadsheets. */
|
|
79
|
+
export const SHEET_SCENE_RULES: SceneRule[] = [
|
|
80
|
+
rule(
|
|
81
|
+
["产品", "需求", "prd", "roadmap", "版本", "迭代", "feature"],
|
|
82
|
+
"当前更像产品管理场景,优先设计需求池、版本规划、优先级评估、验收清单等表格。",
|
|
83
|
+
),
|
|
84
|
+
rule(
|
|
85
|
+
["运营", "增长", "拉新", "留存", "转化", "活动", "campaign", "gmv"],
|
|
86
|
+
"当前更像运营分析场景,优先设计指标明细、渠道效果、活动复盘、周报汇总等表格。",
|
|
87
|
+
),
|
|
88
|
+
rule(
|
|
89
|
+
["销售", "客户", "商机", "渠道", "业绩", "回款", "签约", "线索"],
|
|
90
|
+
"当前更像销售管理场景,优先设计线索跟进、客户分层、商机漏斗、区域业绩等表格。",
|
|
91
|
+
),
|
|
92
|
+
rule(
|
|
93
|
+
["技术", "架构", "系统", "平台", "接口", "部署", "微服务", "数据库", "agent", "ai"],
|
|
94
|
+
"当前更像技术项目场景,优先设计接口清单、服务台账、发布计划、风险清单或测试追踪表。",
|
|
95
|
+
),
|
|
96
|
+
rule(
|
|
97
|
+
["培训", "课程", "学习", "上手", "入门", "手册", "宣导", "workshop"],
|
|
98
|
+
"当前更像培训管理场景,优先设计课程安排、签到成绩、练习任务、反馈汇总等表格。",
|
|
99
|
+
),
|
|
100
|
+
rule(
|
|
101
|
+
["项目", "排期", "里程碑", "实施", "交付", "风险", "计划"],
|
|
102
|
+
"当前更像项目管理场景,优先设计排期、里程碑、责任分工、风险跟踪和验收清单等表格。",
|
|
103
|
+
),
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
/** Scene rules for draw.io diagrams. */
|
|
107
|
+
export const DIAGRAM_SCENE_RULES: SceneRule[] = [
|
|
108
|
+
rule(
|
|
109
|
+
["产品", "需求", "prd", "roadmap", "版本", "迭代", "feature"],
|
|
110
|
+
"当前更像产品方案场景,优先体现用户流程、功能模块、角色关系或版本路径。",
|
|
111
|
+
),
|
|
112
|
+
rule(
|
|
113
|
+
["运营", "增长", "拉新", "留存", "转化", "活动", "campaign", "gmv"],
|
|
114
|
+
"当前更像运营流程场景,优先体现渠道、动作链路、指标漏斗和复盘闭环。",
|
|
115
|
+
),
|
|
116
|
+
rule(
|
|
117
|
+
["销售", "客户", "商机", "渠道", "业绩", "回款", "签约", "线索"],
|
|
118
|
+
"当前更像销售流程/经营场景,优先体现线索到签约的阶段流转、角色协同和客户分层。",
|
|
119
|
+
),
|
|
120
|
+
rule(
|
|
121
|
+
["技术", "架构", "系统", "平台", "接口", "部署", "微服务", "数据库", "agent", "ai"],
|
|
122
|
+
"当前更像技术架构场景,优先体现系统边界、模块层次、调用链路、数据流和基础设施。",
|
|
123
|
+
),
|
|
124
|
+
rule(
|
|
125
|
+
["培训", "课程", "学习", "上手", "入门", "手册", "宣导", "workshop"],
|
|
126
|
+
"当前更像培训流程场景,优先体现学习路径、步骤、角色分工和知识结构。",
|
|
127
|
+
),
|
|
128
|
+
rule(
|
|
129
|
+
["项目", "排期", "里程碑", "实施", "交付", "风险", "计划"],
|
|
130
|
+
"当前更像项目实施场景,优先体现阶段、责任人、交付物和依赖关系。",
|
|
131
|
+
),
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
/** Scene rules for Markdown documents. */
|
|
135
|
+
export const MARKDOWN_SCENE_RULES: SceneRule[] = [
|
|
136
|
+
rule(
|
|
137
|
+
["产品", "需求", "prd", "roadmap", "版本", "迭代", "用户故事", "feature"],
|
|
138
|
+
"当前更像产品知识沉淀场景,请重点补足背景、用户场景、功能说明、流程、边界和 FAQ。",
|
|
139
|
+
),
|
|
140
|
+
rule(
|
|
141
|
+
["运营", "增长", "拉新", "留存", "转化", "活动", "campaign", "gmv"],
|
|
142
|
+
"当前更像运营复盘/方法论沉淀场景,请重点补足指标口径、动作拆解、案例和经验总结。",
|
|
143
|
+
),
|
|
144
|
+
rule(
|
|
145
|
+
["销售", "客户", "商机", "渠道", "业绩", "回款", "签约", "线索"],
|
|
146
|
+
"当前更像销售资料整理场景,请重点补足客户画像、销售流程、关键话术、阶段策略和常见问题。",
|
|
147
|
+
),
|
|
148
|
+
rule(
|
|
149
|
+
["技术", "架构", "系统", "平台", "接口", "部署", "微服务", "数据库", "agent", "ai"],
|
|
150
|
+
"当前更像技术文档/README 场景,请重点补足架构说明、目录结构、安装步骤、配置示例、调用示例和排错说明。",
|
|
151
|
+
),
|
|
152
|
+
rule(
|
|
153
|
+
["培训", "课程", "学习", "上手", "入门", "手册", "宣导", "workshop"],
|
|
154
|
+
"当前更像培训讲义/操作手册场景,请重点补足学习路径、步骤、示例、练习建议和常见误区。",
|
|
155
|
+
),
|
|
156
|
+
rule(
|
|
157
|
+
["项目", "排期", "里程碑", "实施", "交付", "风险", "计划"],
|
|
158
|
+
"当前更像项目执行手册场景,请重点补足实施阶段、责任分工、里程碑、依赖项和验收标准。",
|
|
159
|
+
),
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
const PPT_FALLBACK = t("未识别到强场景时,默认按商务化正式汇报组织,兼顾背景、分析、方案、价值与下一步。");
|
|
163
|
+
const DOC_FALLBACK = t("默认按正式商务文档处理,兼顾背景、问题、方案、价值、风险与下一步。");
|
|
164
|
+
const SHEET_FALLBACK = t("默认按真实业务表格处理,兼顾明细、汇总、分析字段和执行字段。");
|
|
165
|
+
const DIAGRAM_FALLBACK = t("默认按方案汇报图处理,兼顾层次、关系和对外讲解的清晰度。");
|
|
166
|
+
const MARKDOWN_FALLBACK = t("默认按正式知识文档处理,兼顾背景、核心说明、示例、FAQ 和后续建议。");
|
|
167
|
+
|
|
168
|
+
/** Scores the topic against the rules and returns the first hit's guide, or the fallback. */
|
|
169
|
+
export function inferScene(topic: string, rules: SceneRule[], fallback: string): string {
|
|
170
|
+
const lower = topic.toLowerCase();
|
|
171
|
+
for (const scene of rules) {
|
|
172
|
+
if (scene.keywords.some((keyword) => lower.includes(keyword))) {
|
|
173
|
+
return scene.guide;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return fallback;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function inferPptScene(topic: string): string {
|
|
180
|
+
return inferScene(topic, PPT_SCENE_RULES, PPT_FALLBACK);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function inferDocScene(topic: string): string {
|
|
184
|
+
return inferScene(topic, DOC_SCENE_RULES, DOC_FALLBACK);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function inferSheetScene(topic: string): string {
|
|
188
|
+
return inferScene(topic, SHEET_SCENE_RULES, SHEET_FALLBACK);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function inferDiagramScene(topic: string): string {
|
|
192
|
+
return inferScene(topic, DIAGRAM_SCENE_RULES, DIAGRAM_FALLBACK);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function inferMarkdownScene(topic: string): string {
|
|
196
|
+
return inferScene(topic, MARKDOWN_SCENE_RULES, MARKDOWN_FALLBACK);
|
|
197
|
+
}
|