dsh-image-gen 0.6.5 → 0.6.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.
Files changed (35) hide show
  1. package/README.en.md +381 -355
  2. package/README.md +381 -355
  3. package/README.zh-CN.md +3 -3
  4. package/docs/assets/readme/canvas-edit.webp +0 -0
  5. package/docs/assets/readme/canvas-generate.webp +0 -0
  6. package/docs/assets/readme/hero-en.webp +0 -0
  7. package/docs/assets/readme/hero-zh.webp +0 -0
  8. package/docs/assets/readme/workflow-overview-en.webp +0 -0
  9. package/docs/assets/readme/workflow-overview.webp +0 -0
  10. package/lib/client.js +499 -354
  11. package/lib/client.js.map +1 -1
  12. package/lib/types/client/inspiration-api.d.ts +10 -0
  13. package/lib/types/client/inspiration-detail.d.ts +14 -0
  14. package/lib/types/client/tl/canvas-sync.d.ts +3 -3
  15. package/lib/types/client/tl/conversation-landings.d.ts +33 -0
  16. package/lib/types/client/tl/studio-tl-canvas.d.ts +2 -0
  17. package/lib/types/client/tl/tl-canvas-bridge.d.ts +12 -32
  18. package/lib/types/client/tldraw/generated/tldraw-assets.d.ts +12 -0
  19. package/lib/types/client/tldraw/generated/tldraw-css.d.ts +1 -0
  20. package/lib/types/client/tldraw/tldraw-style.d.ts +1 -0
  21. package/lib/types/client/tldraw/tldraw-workspace.d.ts +1 -0
  22. package/lib/types/inspiration/cache.d.ts +20 -0
  23. package/lib/types/inspiration/downloader.d.ts +27 -0
  24. package/lib/types/inspiration/routes.d.ts +13 -0
  25. package/lib/types/inspiration/sources.d.ts +33 -0
  26. package/lib/types/inspiration/types.d.ts +65 -0
  27. package/lib/types/inspiration/updater.d.ts +7 -0
  28. package/package.json +8 -10
  29. package/skills/install-dsh-image-gen/SKILL.md +22 -22
  30. package/lib/types/client/studio-chat-panel.d.ts +0 -23
  31. package/lib/types/client/tl/diagram-landing.d.ts +0 -75
  32. package/lib/types/client/tl/diagram-layout.d.ts +0 -76
  33. package/lib/types/client/tl/diagram-measure.d.ts +0 -40
  34. package/lib/types/diagram.d.ts +0 -42
  35. package/lib/types/studio-chat.d.ts +0 -48
@@ -1,76 +0,0 @@
1
- import type { DiagramNodeShape, DiagramSpec } from '../../shared.js';
2
- /** One laid-out node: local id, label, outline, top-left position, size. */
3
- export interface DiagramLayoutNode {
4
- id: string;
5
- label: string;
6
- shape: DiagramNodeShape;
7
- x: number;
8
- y: number;
9
- w: number;
10
- h: number;
11
- }
12
- /** A point in graph space (same origin as the layout nodes). */
13
- export interface DiagramPoint {
14
- x: number;
15
- y: number;
16
- }
17
- /** One laid-out edge between node local ids, with dagre's routing hint. */
18
- export interface DiagramLayoutEdge {
19
- from: string;
20
- to: string;
21
- label?: string;
22
- /**
23
- * dagre's polyline in graph space. points[0] lies on the source node's
24
- * outline and points[last] on the target's. Self loops carry an empty
25
- * array: dagre cannot route them, and the landing layer falls back to
26
- * center bindings (tldraw draws bound self loops natively).
27
- */
28
- points: DiagramPoint[];
29
- /**
30
- * Where the label sits along the polyline, as an arc-length ratio in
31
- * [0, 1] (tldraw's arrow labelPosition shares the ratio semantics). This
32
- * is a best-effort initial estimate: tldraw applies the ratio to its own
33
- * routed path, which may differ from dagre's polyline in the middle
34
- * segments. The final label position is validated on the real canvas.
35
- */
36
- labelPosition?: number;
37
- }
38
- export interface DiagramLayout {
39
- nodes: DiagramLayoutNode[];
40
- edges: DiagramLayoutEdge[];
41
- width: number;
42
- height: number;
43
- /** Growth direction of the layout, needed by the landing layer to pick
44
- * binding anchors (TB connects bottom→top edges, LR right→left edges). */
45
- direction: 'TB' | 'LR';
46
- }
47
- /** Node size in canvas units (top-left anchored, like tldraw shape props). */
48
- export interface DiagramSize {
49
- w: number;
50
- h: number;
51
- }
52
- /** Measured sizes fed into the pure layout function. */
53
- export interface DiagramMeasurements {
54
- /** node id → measured node size. Missing entries fall back to the default. */
55
- nodes: ReadonlyMap<string, DiagramSize>;
56
- /**
57
- * edge list index → measured label size. Only edges carrying a label are
58
- * present; dagre reserves rank space for these labels.
59
- */
60
- edgeLabels?: ReadonlyMap<number, DiagramSize>;
61
- }
62
- /** Fallback size for nodes the caller did not measure (defensive only). */
63
- export declare const DEFAULT_NODE_SIZE: DiagramSize;
64
- /**
65
- * Where a point sits along a polyline, as an arc-length ratio in [0, 1].
66
- * The point is projected onto the nearest polyline segment. Degenerate
67
- * polylines return 0.5.
68
- */
69
- export declare function arcRatioAlongPolyline(points: readonly DiagramPoint[], target: DiagramPoint): number;
70
- /**
71
- * Lay out a diagram spec with coordinates relative to (0, 0). The layout is
72
- * deterministic: same spec + same measurements always produce the same
73
- * coordinates (dagre is seeded by insertion order, which we keep stable by
74
- * iterating the spec's arrays as given).
75
- */
76
- export declare function layoutDiagram(diagram: DiagramSpec, measurements: DiagramMeasurements): DiagramLayout;
@@ -1,40 +0,0 @@
1
- /**
2
- * Measure diagram node/edge-label sizes with tldraw's own DOM text measuring.
3
- *
4
- * This is the "real" half of the measurement/layout split: the editor's
5
- * TextManager renders text with the same font family, size, line height and
6
- * wrap width the landed geo shapes will use, so RECTANGLE node sizes track
7
- * the rendered label 1:1 (no character-width heuristics).
8
- *
9
- * The measure parameters mirror tldraw's internal geo-shape constants for
10
- * our landed shapes (font 'sans', size 'm'): theme.fontSize * 1.375,
11
- * theme.lineHeight, label padding 16.
12
- *
13
- * Non-rectangular outlines are APPROXIMATE, not 1:1. tldraw re-wraps the
14
- * label against the SHAPE's width (shape w - padding), and we size the
15
- * shape from the text measured at the pre-inflation wrap width — so after
16
- * inflation the label re-wraps into fewer, wider lines. For short labels
17
- * (single line at the wrap width) the geometry below is exact. For long
18
- * wrapped labels the re-wrapped block can grow past the outline's inscribed
19
- * rectangle and crowd the diamond's slanted edges / the ellipse's arc:
20
- * greedy text wrapping scales with shape width while the inscribed rectangle
21
- * only halves it, so there is no closed-form fix. The create_diagram tool
22
- * prompt steers long text to rectangles and keeps diamond labels short;
23
- * whether a real label fits is ultimately a visual check on the real canvas
24
- * (see the diagram-verify harness), not something this module can promise.
25
- * - diamond: a single-line text rect (tw, th) fits exactly when
26
- * tw/w + th/h <= 1, so doubling the text size (+ padding) is exact for
27
- * unwrapped labels.
28
- * - ellipse: a single-line corner point fits exactly when
29
- * tw²/w² + th²/h² <= 1, so a √2 factor (+ padding) is exact for
30
- * unwrapped labels.
31
- */
32
- import type { Editor } from 'tldraw';
33
- import type { DiagramSpec } from '../../shared.js';
34
- import type { DiagramMeasurements } from './diagram-layout.js';
35
- /**
36
- * Measure every node and edge label of a spec against the editor's live
37
- * theme and fonts. Node sizes carry the outline inflation for diamond and
38
- * ellipse; edge-label sizes let dagre reserve rank space for labels.
39
- */
40
- export declare function measureDiagram(editor: Editor, diagram: DiagramSpec): DiagramMeasurements;
@@ -1,42 +0,0 @@
1
- /**
2
- * create_diagram: a structure-only tool whose results land on the workbench
3
- * infinite canvas.
4
- *
5
- * The model outputs a declarative DSL (nodes + edges with local ids, never
6
- * coordinates). The tool call succeeds immediately — exactly like image
7
- * generation — and the diagram rides the same landing bus: an open canvas
8
- * renders it at once, a closed one renders it the moment it opens. The canvas
9
- * computes the layered layout, creates geo shapes, and binds every arrow to
10
- * its endpoints so the user can drag nodes around with arrows following.
11
- */
12
- import type { Context } from '@deepseek-ai/cordis';
13
- import { type DiagramDirection, type DiagramEdgeSpec, type DiagramNodeSpec } from './shared.js';
14
- /** Value returned by create_diagram and echoed into the tool-result schema. */
15
- export interface CreateDiagramValue {
16
- diagramId: string;
17
- title: string;
18
- direction: DiagramDirection;
19
- nodeCount: number;
20
- edgeCount: number;
21
- }
22
- /** Untrusted create_diagram arguments as they arrive from the model. */
23
- export interface CreateDiagramArgs {
24
- title?: unknown;
25
- direction?: unknown;
26
- nodes?: unknown;
27
- edges?: unknown;
28
- }
29
- /** Register the create_diagram tool on a host context. */
30
- export declare function registerDiagramTool(ctx: Context): void;
31
- /**
32
- * Validate untrusted create_diagram arguments into a DiagramSpec. Returns
33
- * undefined for anything structurally unusable (no nodes, duplicate ids,
34
- * edges pointing at unknown nodes, over the caps) — the tool then fails with
35
- * an actionable message and the model can retry with a corrected diagram.
36
- */
37
- export declare function diagramSpecFromArgs(args: CreateDiagramArgs): {
38
- title?: string;
39
- direction?: DiagramDirection;
40
- nodes: DiagramNodeSpec[];
41
- edges: DiagramEdgeSpec[];
42
- } | undefined;
@@ -1,48 +0,0 @@
1
- /**
2
- * Dedicated DSH agent session backing the workbench chat panel.
3
- *
4
- * The panel is a real DSH conversation driven from the plugin, not a parallel
5
- * chat implementation: on first use the host creates an agent through
6
- * ctx.agents.create (the same factory the sidebar uses), then archives the
7
- * session through ctx.workspaceRegistry so it never appears in the sidebar
8
- * history list while remaining fully usable. The plugin never calls
9
- * sessions.open - archiving the selected session would clear the user's
10
- * current selection - and drives turns purely through agent.followup().
11
- *
12
- * Session events are projected into a small lossless-enough StudioChatEvent
13
- * feed (text turns, tool summaries, generated-image references) and served to
14
- * the browser through CHAT_ROUTE. The browser pulls increments with
15
- * ?since=<seq>; images land on the tldraw canvas from the browser side via
16
- * the existing IMAGE_ROUTE + landing-queue path.
17
- */
18
- import type { IncomingMessage, ServerResponse } from 'node:http';
19
- import type { Context } from '@deepseek-ai/cordis';
20
- import { type StudioChatEvent } from './shared.js';
21
- /** Wire responses for CHAT_ROUTE. */
22
- export interface StudioChatStateResponse {
23
- ok: true;
24
- latestSeq: number;
25
- events: StudioChatEvent[];
26
- /** Why the backing agent is missing, when creation failed; absent otherwise. */
27
- unavailable?: string;
28
- }
29
- export interface StudioChatSendResponse {
30
- ok: true;
31
- }
32
- export interface StudioChatErrorResponse {
33
- error: string;
34
- }
35
- export interface StudioChatDeps {
36
- maxBodyBytes: number;
37
- }
38
- /**
39
- * Install the studio chat: ensure the dedicated agent session, subscribe to
40
- * its events, and return the CHAT_ROUTE handler plus a disposer. Creation
41
- * failures never break the plugin load - the route reports the error and the
42
- * panel shows it, so a host without agent services degrades visibly instead
43
- * of fatally.
44
- */
45
- export declare function createStudioChat(ctx: Context, deps: StudioChatDeps): {
46
- serve: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
47
- dispose(): void;
48
- };