@liustack/pptwise 0.22.0

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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +127 -0
  3. package/README.zh-CN.md +136 -0
  4. package/cordis.patch.yml +5 -0
  5. package/dist/chunk-3ZUKISTY.js +114 -0
  6. package/dist/chunk-3ZUKISTY.js.map +1 -0
  7. package/dist/chunk-M35M4QUC.js +1167 -0
  8. package/dist/chunk-M35M4QUC.js.map +1 -0
  9. package/dist/chunk-VUOLBHD7.js +19 -0
  10. package/dist/chunk-VUOLBHD7.js.map +1 -0
  11. package/dist/chunk-WL5KWYKS.js +49762 -0
  12. package/dist/chunk-WL5KWYKS.js.map +1 -0
  13. package/dist/cli.js +4753 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/index.d.ts +4224 -0
  16. package/dist/index.js +99 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/node.d.ts +7 -0
  19. package/dist/node.js +11 -0
  20. package/dist/node.js.map +1 -0
  21. package/dist/pixel-audit-H5K6JK3X.js +218 -0
  22. package/dist/pixel-audit-H5K6JK3X.js.map +1 -0
  23. package/dist/registry-C0GJH7ZT.d.ts +46 -0
  24. package/dsh/client.js +1398 -0
  25. package/dsh/index.js +141 -0
  26. package/dsh/preview-tool.js +1931 -0
  27. package/dsh/spawnHidden.js +109 -0
  28. package/package.json +113 -0
  29. package/skills/pptwise/SKILL.md +100 -0
  30. package/skills/pptwise/SKILL.zh-CN.md +102 -0
  31. package/skills/pptwise/references/branding.md +18 -0
  32. package/skills/pptwise/references/branding.zh-CN.md +21 -0
  33. package/skills/pptwise/references/components.md +35 -0
  34. package/skills/pptwise/references/components.zh-CN.md +40 -0
  35. package/skills/pptwise/references/density.md +17 -0
  36. package/skills/pptwise/references/density.zh-CN.md +22 -0
  37. package/skills/pptwise/references/images.md +42 -0
  38. package/skills/pptwise/references/images.zh-CN.md +47 -0
  39. package/skills/pptwise/references/layouts.md +37 -0
  40. package/skills/pptwise/references/layouts.zh-CN.md +42 -0
  41. package/skills/pptwise/references/spec.md +107 -0
  42. package/skills/pptwise/references/spec.zh-CN.md +112 -0
  43. package/skills/pptwise/references/validate.md +82 -0
  44. package/skills/pptwise/references/validate.zh-CN.md +87 -0
  45. package/skills/pptwise/scripts/run.ps1 +192 -0
  46. package/skills/pptwise/scripts/run.sh +229 -0
package/dsh/index.js ADDED
@@ -0,0 +1,141 @@
1
+ // DeepSeek Harness (DSH) plugin: registers the pptwise deck-generation
2
+ // skill into DSH's skill system (v0, skill-registration wave). The model
3
+ // then drives the pptwise CLI from the DSH terminal exactly the way the
4
+ // skill teaches every other harness.
5
+ //
6
+ // Loaded via the package root export (`exports["."]` → this file) and the
7
+ // cordis.patch.yml bundle row `@liustack/pptwise` — DSH's plugin card
8
+ // derives its label by stripping the scope, so the card reads "pptwise".
9
+ //
10
+ // Verified against DSH 0.1.0-rc.6 source:
11
+ // - `ctx.skills.register(registration)` takes the skill *content* as a
12
+ // string (frontmatter must be stripped — the registry treats content as
13
+ // body verbatim) and returns a disposer; registration rides a Cordis
14
+ // effect, so unloading the plugin removes the skill (reversible, no
15
+ // residue).
16
+ // - The profile's `node_modules/.bin` never enters the DSH terminal's
17
+ // PATH (dsh-subprocess inherits the parent env untouched), so the skill
18
+ // body gets a runtime preamble that maps `pptwise <args>` onto
19
+ // `node <abs path to this package's dist/cli.js> <args>` — no PATH
20
+ // lookup, no npx, plugin and engine version-locked together (the
21
+ // modlens precedent).
22
+ // - Registered names carry the pptwise identity ("pptwise") and collide
23
+ // with no built-in skill (`dsh-badge`, `cordis-plugin-development`,
24
+ // `editing-cordis-compositions`) or provider (`runtime`, `filesystem`,
25
+ // `dsh-badge`).
26
+ //
27
+ // This file is plain dependency-free JS by design (node builtins only):
28
+ // no build step, no dsh type imports, resilient to rc surface drift.
29
+ import { readFileSync } from 'node:fs'
30
+ import { fileURLToPath } from 'node:url'
31
+ import { createPreviewService, TOOL_NAME } from './preview-tool.js'
32
+
33
+ const SKILL_FILE_URL = new URL('../skills/pptwise/SKILL.md', import.meta.url)
34
+ const SKILL_DIR = fileURLToPath(new URL('../skills/pptwise/', import.meta.url))
35
+ const CLI_PATH = fileURLToPath(new URL('../dist/cli.js', import.meta.url))
36
+
37
+ export const name = 'pptwise'
38
+ export const inject = ['skills', 'tools']
39
+
40
+ export const SKILL_NAME = 'pptwise'
41
+ export const PREVIEW_TOOL_NAME = TOOL_NAME
42
+
43
+ /**
44
+ * Split SKILL.md into { description, body }. DSH's runtime registry does
45
+ * not parse frontmatter (that is the filesystem provider's job), so the
46
+ * `---` block must come off here and the description travels as its own
47
+ * registration field.
48
+ */
49
+ export function parseSkillMarkdown(raw) {
50
+ const fm = raw.match(/^---\n([\s\S]*?)\n---\n?/)
51
+ if (!fm) {
52
+ throw new Error('SKILL.md has no frontmatter block')
53
+ }
54
+ const description = fm[1].match(/^description:\s*(.+)$/m)?.[1]?.trim()
55
+ if (!description) {
56
+ throw new Error('SKILL.md frontmatter has no description field')
57
+ }
58
+ const body = raw.slice(fm[0].length).trim()
59
+ if (body === '') {
60
+ throw new Error('SKILL.md has an empty body')
61
+ }
62
+ return { description, body }
63
+ }
64
+
65
+ /**
66
+ * The DSH-specific note prepended to the skill body. Kept as a function of
67
+ * the CLI path so tests can pin the contract without touching the module
68
+ * constant.
69
+ */
70
+ export function dshRuntimePreamble(cliPath) {
71
+ return [
72
+ '## DSH runtime note (injected by the pptwise DSH plugin)',
73
+ '',
74
+ 'The `pptwise` bin is not on PATH in this environment. Whenever this playbook says `pptwise <args>`, run this in the terminal instead:',
75
+ '',
76
+ '```bash',
77
+ `node "${cliPath}" <args>`,
78
+ '```',
79
+ '',
80
+ 'That CLI ships inside this plugin\'s own package, version-locked to this skill, so it wins over the "Run it" section below: ignore the launcher scripts there, this line is the mapping. Only if that file is missing, fall back to `npx -y @liustack/pptwise <args>`.',
81
+ ].join('\n')
82
+ }
83
+
84
+ export function apply(ctx) {
85
+ // Any failure degrades loudly instead of taking the plugin's host scope
86
+ // down: a skill that fails to register is a console line, not a crash.
87
+ let skill
88
+ try {
89
+ skill = parseSkillMarkdown(readFileSync(SKILL_FILE_URL, 'utf8'))
90
+ } catch (error) {
91
+ console.error(`[pptwise] skill registration skipped (cannot read ${fileURLToPath(SKILL_FILE_URL)}): ${error}`)
92
+ return
93
+ }
94
+ // The preview tool is what gives pptwise a seat in the conversation. The
95
+ // skill alone leaves every call belonging to `bash`, whose card this plugin
96
+ // cannot contribute to — which is why the review loop used to end in "open
97
+ // this URL yourself". Registered first and independently: a tool failure
98
+ // must not cost the skill, and vice versa.
99
+ //
100
+ // One service per apply(), and the tool and the route below are its two
101
+ // halves: they must agree on the same CLI path and the same decks, and a
102
+ // second apply() (plugin reload, a second profile) must get its own pair
103
+ // rather than reaching into the first one's.
104
+ const preview = createPreviewService(CLI_PATH)
105
+ try {
106
+ ctx.tools.register(preview.tool)
107
+ } catch (error) {
108
+ console.error(`[pptwise] preview tool registration skipped: ${error}`)
109
+ }
110
+
111
+ // The route the preview card fetches a rendered deck from. `webServer`
112
+ // exists only under the web profile and this cordis has no optional-inject
113
+ // form, so it rides a scoped `ctx.inject`: the closure runs when the
114
+ // service appears and never runs where it does not, leaving headless
115
+ // untouched (modlens's own routes take the same shape).
116
+ if (typeof ctx.inject === 'function') {
117
+ ctx.inject(['webServer'], (scope) => {
118
+ try {
119
+ preview.registerRoute(scope)
120
+ } catch (error) {
121
+ console.error(`[pptwise] preview route skipped: ${error}`)
122
+ }
123
+ })
124
+ }
125
+
126
+ try {
127
+ // The returned disposer is intentionally unused here: register() wires
128
+ // itself as a Cordis effect on the calling context, so disposing this
129
+ // plugin's fiber (plugin remove / reload) unregisters the skill.
130
+ ctx.skills.register({
131
+ name: SKILL_NAME,
132
+ description: skill.description,
133
+ source: 'bundled',
134
+ content: `${dshRuntimePreamble(CLI_PATH)}\n\n${skill.body}`,
135
+ path: fileURLToPath(SKILL_FILE_URL),
136
+ resourceBase: { kind: 'directory', path: SKILL_DIR },
137
+ })
138
+ } catch (error) {
139
+ console.error(`[pptwise] skill registration skipped: ${error}`)
140
+ }
141
+ }