@yunkersek/dsh-prtsui 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.
Binary file
package/icon.svg ADDED
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
2
+ <rect width="64" height="64" fill="#0f0f10"/>
3
+ <path d="M8 20 L20 8 L56 8 L56 44 L44 56 L8 56 Z" fill="none" stroke="#18d1ff" stroke-width="2"/>
4
+ <rect x="16" y="18" width="24" height="3" fill="#18d1ff"/>
5
+ <rect x="16" y="27" width="32" height="2" fill="#7a7c7e"/>
6
+ <rect x="16" y="34" width="28" height="2" fill="#7a7c7e"/>
7
+ <rect x="16" y="41" width="18" height="2" fill="#7a7c7e"/>
8
+ <rect x="40" y="38" width="8" height="8" fill="#18d1ff"/>
9
+ </svg>
package/index.js ADDED
@@ -0,0 +1,200 @@
1
+ /**
2
+ * @yunkersek/dsh-prtsui — host half.
3
+ *
4
+ * Teaches the model the ```dsh-ui fence and the PRTS node vocabulary, exposes a
5
+ * validating tool, and bundles the `prtsui` skill. The rendering half lives in
6
+ * ./client.js (web). Rendering is pure DOM: no react-dom, no runtime assets.
7
+ */
8
+ import { readFile } from 'node:fs/promises'
9
+ import { dirname, join } from 'node:path'
10
+ import { fileURLToPath } from 'node:url'
11
+
12
+ export const name = '@yunkersek/dsh-prtsui'
13
+ export const inject = ['systemPrompt']
14
+
15
+ const HERE = dirname(fileURLToPath(import.meta.url))
16
+ const SKILL_PATH = join(HERE, 'SKILL.md')
17
+ const SKILL_FALLBACK = '# prtsui\n\nRender ```dsh-ui fences with the PRTS vocabulary.\n'
18
+
19
+ export const NODE_TYPES = [
20
+ 'text', 'hero', 'callout', 'list', 'table', 'stat', 'stats', 'keyvalue',
21
+ 'steps', 'choices', 'tabs', 'card', 'chart', 'code', 'divider', 'kbd',
22
+ 'badge', 'progress', 'quote', 'compare', 'image', 'accordion',
23
+ ]
24
+
25
+ const SECTION_TEXT = `## dsh-ui fence → PRTS inline UI (plugin: @yunkersek/dsh-prtsui)
26
+
27
+ When a structured block (comparison, status, steps, data, choices, a card) is clearer than prose, emit ONE fenced block in the reply body:
28
+
29
+ \`\`\`dsh-ui
30
+ {"title":"optional banner","gap":10,"items":[{"type":"table","columns":["A","B"],"rows":[["1","2"]]}]}
31
+ \`\`\`
32
+
33
+ Rules
34
+ - One JSON object per fence: {"items":[…]} plus optional "title", "gap". A bare array is also accepted.
35
+ - Node types: text, hero, callout, list, table, stat, stats, keyvalue, steps, choices, tabs, card, chart, code, divider, kbd, badge, progress, quote, compare, image, accordion.
36
+ - callout.tone: info | success | warning | error | brand. steps[].state: done | active | todo. chart.kind: bars | line | donut with data:[{label,value}].
37
+ - Every visible string follows the conversation language; the visual language is PRTS (terminal/dark, cyan rails, square corners, hairline strokes, uppercase overline labels).
38
+ - Put it where the reader looks: after the sentence that introduces it, not at the very end of a long answer.
39
+ - Do not nest fences, do not wrap the JSON in markdown, do not add prose inside the fence.
40
+ - Interactions: choices / tabs keep their state locally; a node carrying "action" sends [prtsui-action] back. Panel placement (panel:true) and tool-row rendering are not implemented — keep responses inline.
41
+ - Validate non-trivial specs with validate_prtsui before emitting; render_prtsui is a fallback for hosts without the fence channel.`
42
+
43
+ function summarize(spec) {
44
+ const items = Array.isArray(spec) ? spec : (spec && Array.isArray(spec.items) ? spec.items : [])
45
+ const counts = new Map()
46
+ let bad = []
47
+ for (const item of items) {
48
+ const type = item && typeof item === 'object' ? String(item.type || '') : ''
49
+ if (!NODE_TYPES.includes(type)) { bad.push(type || '(missing type)'); continue }
50
+ counts.set(type, (counts.get(type) || 0) + 1)
51
+ }
52
+ const parts = [...counts.entries()].map(([t, n]) => `${t}×${n}`)
53
+ return [
54
+ '[prtsui-render]',
55
+ `status=${bad.length ? 'partial' : 'ok'}`,
56
+ `nodes=${items.length}`,
57
+ `kinds=${parts.join(' ') || '-'}`,
58
+ ...(bad.length ? [`unknown=${bad.join(',')}`] : []),
59
+ ].join('\n')
60
+ }
61
+
62
+ function validateSpec(spec) {
63
+ const problems = []
64
+ const items = Array.isArray(spec) ? spec : (spec && Array.isArray(spec.items) ? spec.items : null)
65
+ if (!items) return ['items must be an array (or pass {items:[…]})']
66
+ if (items.length === 0) problems.push('items is empty')
67
+ for (const [i, node] of items.entries()) {
68
+ if (!node || typeof node !== 'object' || Array.isArray(node)) { problems.push(`items[${i}] is not an object`); continue }
69
+ if (typeof node.type !== 'string') { problems.push(`items[${i}].type is missing`); continue }
70
+ if (!NODE_TYPES.includes(node.type)) problems.push(`items[${i}].type "${node.type}" is not in the vocabulary`)
71
+ if (node.type === 'table' && (!Array.isArray(node.columns) || !Array.isArray(node.rows))) problems.push(`items[${i}] table needs columns[] and rows[]`)
72
+ if (node.type === 'chart' && (!Array.isArray(node.data) || node.data.length === 0)) problems.push(`items[${i}] chart needs data[]`)
73
+ if (node.type === 'list' && !Array.isArray(node.items)) problems.push(`items[${i}] list needs items[]`)
74
+ }
75
+ return problems
76
+ }
77
+
78
+ const SPEC_SCHEMA = {
79
+ type: 'object',
80
+ properties: {
81
+ spec: {
82
+ type: 'object',
83
+ properties: { title: { type: 'string' }, gap: { type: 'number' }, items: { type: 'array', items: { type: 'object' } } },
84
+ required: ['items'],
85
+ additionalProperties: true,
86
+ },
87
+ },
88
+ required: ['spec'],
89
+ additionalProperties: false,
90
+ }
91
+
92
+ function makeTools() {
93
+ const renderTool = {
94
+ name: 'render_prtsui',
95
+ description: 'Render a PRTS-styled UI card in the tool row from a spec {title?, gap?, items:[…]}. Prefer a ```dsh-ui fence in the reply body; use this tool only when the host has no fence channel.',
96
+ parameters: SPEC_SCHEMA,
97
+ output: {
98
+ schema: { type: 'string' },
99
+ render(_args, value) { return [{ type: 'text', text: String(value) }] },
100
+ presentationMeta(args) {
101
+ const spec = args && typeof args === 'object' ? args.spec : undefined
102
+ return spec && typeof spec === 'object' ? spec : null
103
+ },
104
+ },
105
+ async execute(args) {
106
+ const spec = args && typeof args === 'object' ? args.spec : undefined
107
+ const problems = validateSpec(spec)
108
+ if (problems.length) return ['[prtsui-render]', 'status=invalid', `problems=${problems.join('; ')}`, 'next=fix_and_retry'].join('\n')
109
+ return summarize(spec)
110
+ },
111
+ }
112
+
113
+ const validateTool = {
114
+ name: 'validate_prtsui',
115
+ description: 'Validate a ```dsh-ui PRTS spec before emitting it. Returns status, node counts, and a list of problems.',
116
+ parameters: SPEC_SCHEMA,
117
+ output: {
118
+ schema: { type: 'string' },
119
+ render(_args, value) { return [{ type: 'text', text: String(value) }] },
120
+ },
121
+ async execute(args) {
122
+ const spec = args && typeof args === 'object' ? args.spec : undefined
123
+ const problems = validateSpec(spec)
124
+ if (problems.length) return ['[prtsui-validate]', 'status=invalid', ...problems.map((p) => `problem=${p}`), 'next=fix_and_emit'].join('\n')
125
+ return ['[prtsui-validate]', 'status=ok', summarize(spec)].join('\n')
126
+ },
127
+ }
128
+
129
+ return [renderTool, validateTool]
130
+ }
131
+
132
+ function makeSkillProvider() {
133
+ let cache
134
+ async function read() {
135
+ if (!cache) cache = await readFile(SKILL_PATH, 'utf8').catch(() => SKILL_FALLBACK)
136
+ return cache
137
+ }
138
+ function frontmatter(raw) {
139
+ const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(raw)
140
+ if (!m) return { description: 'Render ```dsh-ui fences with the PRTS visual language.' }
141
+ const body = m[1]
142
+ const desc = /^description:\s*(.+)$/m.exec(body)
143
+ return { description: desc ? desc[1].trim() : 'Render ```dsh-ui fences with the PRTS visual language.' }
144
+ }
145
+ return {
146
+ name: 'prtsui',
147
+ async list() {
148
+ const raw = await read()
149
+ const { description } = frontmatter(raw)
150
+ return [{
151
+ name: 'prtsui',
152
+ description,
153
+ invocation: { modelInvocable: true, userInvocable: true },
154
+ source: 'bundled',
155
+ provider: 'prtsui',
156
+ path: SKILL_PATH,
157
+ resourceBase: { kind: 'directory', path: HERE },
158
+ rank: 600,
159
+ locator: SKILL_PATH,
160
+ }]
161
+ },
162
+ async get(candidate) {
163
+ // The registry hands back the candidate descriptor from list(), not a bare name.
164
+ const wanted = typeof candidate === 'string' ? candidate : candidate && candidate.name
165
+ if (wanted !== 'prtsui') return undefined
166
+ const raw = await read()
167
+ const { description } = frontmatter(raw)
168
+ return {
169
+ name: 'prtsui',
170
+ description,
171
+ invocation: { modelInvocable: true, userInvocable: true },
172
+ source: 'bundled',
173
+ provider: 'prtsui',
174
+ path: SKILL_PATH,
175
+ resourceBase: { kind: 'directory', path: HERE },
176
+ rank: 600,
177
+ locator: SKILL_PATH,
178
+ content: raw,
179
+ }
180
+ },
181
+ }
182
+ }
183
+
184
+ export function apply(ctx) {
185
+ ctx.systemPrompt.section({
186
+ name: 'prtsui:fence',
187
+ order: ctx.systemPrompt.getSectionOrder('STRUCTURED_OUTPUT'),
188
+ text: () => SECTION_TEXT,
189
+ })
190
+
191
+ ctx.inject(['skills'], (skillCtx) => {
192
+ skillCtx.skills.registerProvider(() => makeSkillProvider())
193
+ })
194
+
195
+ ctx.inject(['tools'], (toolsCtx) => {
196
+ for (const tool of makeTools()) {
197
+ toolsCtx.effect(() => toolsCtx.tools.register(tool), `@yunkersek/dsh-prtsui: ${tool.name}`)
198
+ }
199
+ })
200
+ }
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "PRTS UI (@yunkersek/dsh-prtsui)",
4
+ "description": "Renders ```dsh-ui fences with the prts-design (Arknights / terminal) visual language: square corners, cyan accent rails, hairline strokes, uppercase overline labels. Pure DOM, no external assets."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "PRTS 界面(@yunkersek/dsh-prtsui)",
4
+ "description": "用 prts-design(明日方舟 / 终端)的视觉语言渲染 ```dsh-ui 围栏:方形直角、青色强调轨、发丝描边、大写小标签。纯 DOM 实现,无外部资源。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@yunkersek/dsh-prtsui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "PRTS-styled inline UI for DeepSeek Harness: renders ```dsh-ui fences as square-cornered, cyan-railed cards. Pure DOM, no external assets.",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "exports": {
8
+ ".": "./index.js",
9
+ "./client": "./client.js",
10
+ "./locale/*.json": "./locale/*.json",
11
+ "./icon": "./icon.svg",
12
+ "./skill": "./SKILL.md"
13
+ },
14
+ "files": [
15
+ "index.js",
16
+ "client.js",
17
+ "cordis.patch.yml",
18
+ "SKILL.md",
19
+ "icon.svg",
20
+ "locale",
21
+ "README.md",
22
+ "LICENSE",
23
+ "docs"
24
+ ],
25
+ "dsh": {
26
+ "bundle": {
27
+ "patch": "./cordis.patch.yml"
28
+ },
29
+ "client": {
30
+ "platform": "web",
31
+ "immediately": true,
32
+ "inject": [
33
+ "@deepseek-ai/dsh-client-ui-conversation"
34
+ ]
35
+ }
36
+ },
37
+ "license": "MIT",
38
+ "keywords": [
39
+ "dsh",
40
+ "dsh-plugin",
41
+ "deepseek-harness",
42
+ "genui",
43
+ "ui",
44
+ "prts",
45
+ "arknights",
46
+ "inline-ui"
47
+ ],
48
+ "author": "dsh-prts authors",
49
+ "homepage": "https://github.com/MooncellWiki/prts-design",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/MooncellWiki/prts-design.git"
53
+ },
54
+ "publishConfig": {
55
+ "registry": "https://registry.npmjs.org",
56
+ "access": "public"
57
+ },
58
+ "bugs": {
59
+ "url": "https://github.com/MooncellWiki/prts-design/issues"
60
+ }
61
+ }