@khorsheed/dsh-game 0.0.0-stage → 0.1.1

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 (101) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.en.md +53 -0
  3. package/README.i18n.yaml +6 -0
  4. package/README.md +52 -2
  5. package/cordis.patch.yml +23 -0
  6. package/lib/client.js +30690 -0
  7. package/lib/index.js +4297 -0
  8. package/lib/typert.host.d.ts +3 -0
  9. package/lib/typert.host.js +3876 -0
  10. package/lib/typert.remote-client.d.ts +104 -0
  11. package/lib/typert.remote-client.js +2138 -0
  12. package/lib/types/agent.d.ts +20 -0
  13. package/lib/types/agent.js +43 -0
  14. package/lib/types/checks.d.ts +44 -0
  15. package/lib/types/checks.js +267 -0
  16. package/lib/types/client/DesignView.d.ts +22 -0
  17. package/lib/types/client/DesignView.js +134 -0
  18. package/lib/types/client/ElementsView.d.ts +21 -0
  19. package/lib/types/client/ElementsView.js +195 -0
  20. package/lib/types/client/GameTab.d.ts +14 -0
  21. package/lib/types/client/GameTab.js +261 -0
  22. package/lib/types/client/PlayFrame.d.ts +54 -0
  23. package/lib/types/client/PlayFrame.js +129 -0
  24. package/lib/types/client/PlayView.d.ts +19 -0
  25. package/lib/types/client/PlayView.js +163 -0
  26. package/lib/types/client/Preview3D.d.ts +52 -0
  27. package/lib/types/client/Preview3D.js +178 -0
  28. package/lib/types/client/ProjectSwitcher.d.ts +20 -0
  29. package/lib/types/client/ProjectSwitcher.js +75 -0
  30. package/lib/types/client/Recipe3DEditor.d.ts +19 -0
  31. package/lib/types/client/Recipe3DEditor.js +44 -0
  32. package/lib/types/client/StyleGallery.d.ts +18 -0
  33. package/lib/types/client/StyleGallery.js +27 -0
  34. package/lib/types/client/TurnCard.d.ts +62 -0
  35. package/lib/types/client/TurnCard.js +100 -0
  36. package/lib/types/client/VersionsView.d.ts +17 -0
  37. package/lib/types/client/VersionsView.js +68 -0
  38. package/lib/types/client/chat-node.d.ts +42 -0
  39. package/lib/types/client/chat-node.js +77 -0
  40. package/lib/types/client/contract.d.ts +131 -0
  41. package/lib/types/client/contract.js +6 -0
  42. package/lib/types/client/definition.d.ts +22 -0
  43. package/lib/types/client/definition.js +28 -0
  44. package/lib/types/client/index.d.ts +21 -0
  45. package/lib/types/client/index.js +263 -0
  46. package/lib/types/client/locales.d.ts +379 -0
  47. package/lib/types/client/locales.js +733 -0
  48. package/lib/types/client/looks.d.ts +36 -0
  49. package/lib/types/client/looks.js +105 -0
  50. package/lib/types/client/markdown.d.ts +11 -0
  51. package/lib/types/client/markdown.js +52 -0
  52. package/lib/types/client/preset-visibility.d.ts +94 -0
  53. package/lib/types/client/preset-visibility.js +115 -0
  54. package/lib/types/client/preview-entry.d.ts +24 -0
  55. package/lib/types/client/preview-entry.js +110 -0
  56. package/lib/types/client/refs.d.ts +36 -0
  57. package/lib/types/client/refs.js +44 -0
  58. package/lib/types/client/reveal.d.ts +43 -0
  59. package/lib/types/client/reveal.js +73 -0
  60. package/lib/types/client/style-samples.d.ts +5 -0
  61. package/lib/types/client/style-samples.js +196 -0
  62. package/lib/types/fsutil.d.ts +26 -0
  63. package/lib/types/fsutil.js +104 -0
  64. package/lib/types/hooks.d.ts +83 -0
  65. package/lib/types/hooks.js +108 -0
  66. package/lib/types/index.d.ts +30 -0
  67. package/lib/types/index.js +22 -0
  68. package/lib/types/kits/canvas2d.d.ts +6 -0
  69. package/lib/types/kits/canvas2d.js +60 -0
  70. package/lib/types/kits/ids.d.ts +11 -0
  71. package/lib/types/kits/ids.js +6 -0
  72. package/lib/types/kits/index.d.ts +26 -0
  73. package/lib/types/kits/index.js +28 -0
  74. package/lib/types/kits/three3d.d.ts +12 -0
  75. package/lib/types/kits/three3d.js +188 -0
  76. package/lib/types/kits/types.d.ts +52 -0
  77. package/lib/types/kits/types.js +6 -0
  78. package/lib/types/look3d.d.ts +20 -0
  79. package/lib/types/look3d.js +175 -0
  80. package/lib/types/panel-session.d.ts +21 -0
  81. package/lib/types/panel-session.js +16 -0
  82. package/lib/types/project.d.ts +138 -0
  83. package/lib/types/project.js +504 -0
  84. package/lib/types/remote.d.ts +184 -0
  85. package/lib/types/remote.js +263 -0
  86. package/lib/types/skills.d.ts +13 -0
  87. package/lib/types/skills.js +141 -0
  88. package/lib/types/store.d.ts +346 -0
  89. package/lib/types/store.js +1383 -0
  90. package/lib/types/tools.d.ts +12 -0
  91. package/lib/types/tools.js +309 -0
  92. package/lib/types/trash.d.ts +5 -0
  93. package/lib/types/trash.js +64 -0
  94. package/lib/types/types.d.ts +548 -0
  95. package/lib/types/types.js +85 -0
  96. package/lib/types/vfs.d.ts +94 -0
  97. package/lib/types/vfs.js +217 -0
  98. package/locale/en.json +6 -0
  99. package/locale/zh.json +6 -0
  100. package/package.json +132 -3
  101. package/runtime/dsh3d.js +1279 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The session a panel call names, by id. The wire's `agent`/`session` lookups
3
+ * refuse identities owned by subagent routing (a room's CLI member, a native
4
+ * subagent), so a panel opened on such a session could not even read. Panel
5
+ * calls take the session id instead: an attached session — subagent ones
6
+ * included — answers directly; anything else goes through the host's own
7
+ * `session` lookup, which resumes an ordinary cold session and raises the
8
+ * same errors a lookup parameter did.
9
+ */
10
+ import type { Context } from '@deepseek-ai/cordis';
11
+ import type { Session } from '@deepseek-ai/dsh-session';
12
+ import type { SessionId } from '@deepseek-ai/dsh-session/types';
13
+ /**
14
+ * Resolve the session a panel call names.
15
+ * @param ctx - host context carrying the session store and the typert lookups.
16
+ * @param sessionId - the session the panel shows.
17
+ * @returns the session.
18
+ * @throws the host lookup's refusal, or when no session has that id.
19
+ */
20
+ export declare function panelSession(ctx: Context, sessionId: SessionId): Promise<Session>;
21
+ //# sourceMappingURL=panel-session.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Resolve the session a panel call names.
3
+ * @param ctx - host context carrying the session store and the typert lookups.
4
+ * @param sessionId - the session the panel shows.
5
+ * @returns the session.
6
+ * @throws the host lookup's refusal, or when no session has that id.
7
+ */
8
+ export async function panelSession(ctx, sessionId) {
9
+ const attached = ctx.get('sessions')?.get(sessionId);
10
+ if (attached !== undefined)
11
+ return attached;
12
+ const resolved = await ctx.get('typert')?.lookups.get('session')?.resolve(sessionId);
13
+ if (resolved === undefined)
14
+ throw new Error(`session "${sessionId}" not found`);
15
+ return resolved;
16
+ }
@@ -0,0 +1,138 @@
1
+ import type { KitId, RuntimeKit } from './kits/types.ts';
2
+ import { type ArtStyle, type ChapterStatus, type CheckFailure, type ElementLook, type ElementView, type GameManifest, type GameParam } from './types.ts';
3
+ /** What `game_open create` must carry before a project exists (the light gate, decision D2). */
4
+ export interface CreateRequest {
5
+ /** `2d` (default) or `3d`; the kit the project is pinned to. */
6
+ readonly runtime?: string | undefined;
7
+ readonly title?: string | undefined;
8
+ readonly pitch?: string | undefined;
9
+ readonly elementTypes?: readonly string[] | string | undefined;
10
+ readonly artStyle?: string | undefined;
11
+ readonly pillars?: readonly string[] | string | undefined;
12
+ }
13
+ /** The gate's verdict: a manifest to write, or what is still missing (model-facing Chinese). */
14
+ export type GateVerdict = {
15
+ readonly ok: true;
16
+ readonly manifest: Omit<GameManifest, 'id' | 'createdAt'>;
17
+ } | {
18
+ readonly ok: false;
19
+ readonly missing: readonly string[];
20
+ };
21
+ /** Split a list given either as an array or as one 、/,/newline-separated string. */
22
+ export declare function listOf(value: readonly string[] | string | undefined): string[];
23
+ /**
24
+ * Resolve the art style the user picked: an example id, its Chinese label,
25
+ * or `custom:<description>`. Anything else is not a choice the user made.
26
+ * @param value - what the model passed.
27
+ * @returns the stored spelling, or undefined when it names no style.
28
+ */
29
+ export declare function resolveArtStyle(value: string | undefined, styles?: readonly ArtStyle[]): string | undefined;
30
+ /** The style's human label (`custom:` keeps the user's own words). */
31
+ export declare function artStyleLabel(id: string): string;
32
+ /**
33
+ * A style's short name for tight places (tags, chips): a custom description's
34
+ * lead — up to its first dash, colon, comma or bracket — at most 10 characters.
35
+ * The full label stays for the model and for hover text.
36
+ */
37
+ export declare function artStyleName(id: string): string;
38
+ /** The kit a create request asks for: `3d` / `3d-three` → 3D, anything else 2D. */
39
+ export declare function requestedKit(runtime: string | undefined): KitId;
40
+ /** The example styles a kit offers. */
41
+ export declare function stylesFor(kit: KitId): readonly ArtStyle[];
42
+ /**
43
+ * The light gate: a project needs a title, a one-sentence pitch, at least one
44
+ * element type and a chosen art style. The model gets back exactly what is
45
+ * missing, so it asks the user instead of inventing it.
46
+ * @param request - the create arguments.
47
+ * @returns the manifest body, or the missing items.
48
+ */
49
+ export declare function gate(request: CreateRequest): GateVerdict;
50
+ /** A style's palette; custom styles start from the pixel palette (the agent may set its own in game.json). */
51
+ export declare function stylePalette(styleId: string): string[];
52
+ /** Parse `game.json` `params[]`, dropping malformed rows and clamping each value into its range. */
53
+ export declare function parseParams(raw: unknown): GameParam[];
54
+ /** What a usable pixel look needs, worded for the model. */
55
+ export declare const PIXEL_LOOK_HINT = "look \u4E0D\u53EF\u7528\uFF1A\u9700\u8981 palette\uFF08#rrggbb \u6570\u7EC4\uFF09\u548C states\uFF08\u72B6\u6001\u540D \u2192 \u50CF\u7D20\u884C\u6570\u7EC4\uFF09";
56
+ /**
57
+ * Normalize an element's `look`: a palette of `#rrggbb` colors and pixel
58
+ * rows per state, every row padded/cut to the widest row, characters outside
59
+ * the palette turned transparent. Anything unusable is null.
60
+ */
61
+ export declare function normalizeLook(raw: unknown): ElementLook | null;
62
+ /** The look's grid size (first state). */
63
+ export declare function lookSize(look: ElementLook): {
64
+ w: number;
65
+ h: number;
66
+ };
67
+ /**
68
+ * Parse `game.json`. Unknown keys are dropped; a missing optional key takes
69
+ * its default, so a hand-edited manifest still loads.
70
+ * @param text - the file's contents.
71
+ * @returns the manifest, or a Chinese reason.
72
+ */
73
+ export declare function parseManifest(text: string): {
74
+ ok: true;
75
+ manifest: GameManifest;
76
+ } | {
77
+ ok: false;
78
+ error: string;
79
+ };
80
+ /** Serialize a manifest the way the plugin writes it. */
81
+ export declare function serializeManifest(manifest: GameManifest): string;
82
+ /**
83
+ * A chapter's status from its text: empty is `todo`, a `状态:定稿` (or
84
+ * `status: done`) line is `done`, anything else is a `draft`.
85
+ */
86
+ export declare function chapterStatus(text: string | undefined): ChapterStatus;
87
+ /**
88
+ * The one-pager (pitch, element types, style, pillars) lives in `game.json`
89
+ * and the panel pins it; `design/pillars.md` holds only the notes about the
90
+ * pillars (why each matters, how to test it). Projects created before
91
+ * 2026-10-10 got a pillars.md that restated the one-pager: this strips those
92
+ * restated lines so the notes view never shows the card twice.
93
+ * @param text - the chapter's text.
94
+ * @param manifest - the one-pager it may restate.
95
+ * @returns the notes that are not a restatement (trimmed; '' when none).
96
+ */
97
+ export declare function pillarNotes(text: string, manifest: Pick<GameManifest, 'title' | 'pitch' | 'pillars' | 'artStyle' | 'elementTypes'> | null): string;
98
+ /**
99
+ * Validate the element files. A file holds one element object or an array of
100
+ * them; each needs `id`, `name` and a `type` the manifest declares, and ids
101
+ * are unique across files.
102
+ * @param files - project-relative path → contents, only `elements/*.json`.
103
+ * @param elementTypes - the manifest's declared types (empty = accept any).
104
+ * @param looks - how the project's kit normalizes a `look` (default: 2D pixel rows).
105
+ * @returns the elements that parsed, and one failure per problem.
106
+ */
107
+ export declare function validateElements(files: Readonly<Record<string, string>>, elementTypes: readonly string[], looks?: Pick<RuntimeKit, 'normalizeLook' | 'lookHint'>): {
108
+ elements: ElementView[];
109
+ failures: CheckFailure[];
110
+ };
111
+ /** The generated 元素与数值 chapter: one table per element type. */
112
+ export declare function elementsChapter(elements: readonly ElementView[], elementTypes: readonly string[]): string;
113
+ /** The generated 元素设定 chapter: every element's 设定 by type (elements without one are left out). */
114
+ export declare function loreChapter(elements: readonly ElementView[], elementTypes: readonly string[]): string;
115
+ /**
116
+ * Whether a project-relative path belongs in a playable build: everything
117
+ * except the plugin's state, the design doc, the tests and dot-files.
118
+ */
119
+ export declare function isBuildFile(path: string): boolean;
120
+ /** A file's MIME type by extension. */
121
+ export declare function mimeOf(path: string): string;
122
+ /** Whether a file ships to the sandbox as text. */
123
+ export declare function isTextFile(path: string): boolean;
124
+ /**
125
+ * A directory-safe project folder name from a title: ASCII letters and
126
+ * digits kept, other runs collapsed to `-`; a title with none falls back to
127
+ * `game`. The store appends `-2`, `-3` … on collision.
128
+ */
129
+ export declare function slugOf(title: string): string;
130
+ /**
131
+ * Apply a patch to one element inside its file's text (an object, or one
132
+ * entry of an array), keeping every other key. `undefined` values delete.
133
+ * @returns the new file text, or undefined when the element is not there.
134
+ */
135
+ export declare function patchElementText(text: string, elementId: string, patch: Readonly<Record<string, unknown>>): string | undefined;
136
+ /** A look as model-facing text: palette, then each state's rows. */
137
+ export declare function lookText(look: ElementLook): string;
138
+ //# sourceMappingURL=project.d.ts.map