@gobing-ai/knowledge-kit 0.1.19 → 0.1.22

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 (147) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/board/collect/index.js +1 -0
  3. package/dist/board/daily-voice/index.js +1315 -264
  4. package/dist/board/itc/index.js +1 -0
  5. package/dist/index.js +14674 -8775
  6. package/package.json +1 -1
  7. package/plugins/generations/dailynews-gen/dist/index.js +285 -16
  8. package/plugins/generations/dailynews-gen/src/editorial-claims.ts +215 -0
  9. package/plugins/generations/dailynews-gen/src/index.ts +23 -4
  10. package/plugins/generations/dailynews-gen/src/script-builder.ts +10 -3
  11. package/plugins/generations/dailynews-gen/src/script-plan.ts +74 -14
  12. package/plugins/generations/image-gen/README.md +31 -31
  13. package/plugins/generations/image-gen/assets/sample/provenance.json +314 -0
  14. package/plugins/generations/image-gen/config.example.yaml +3 -0
  15. package/plugins/generations/image-gen/dist/index.js +154 -14
  16. package/plugins/generations/image-gen/presets/SOURCE.md +65 -0
  17. package/plugins/generations/image-gen/scripts/eval-style-presets.ts +513 -0
  18. package/plugins/generations/image-gen/scripts/gen-samples.ts +57 -7
  19. package/plugins/generations/image-gen/src/presets.ts +6 -5
  20. package/plugins/generations/image-gen/src/providers/h3-local.ts +196 -0
  21. package/plugins/generations/image-gen/src/providers/types.ts +11 -1
  22. package/plugins/generations/music-gen/README.md +277 -0
  23. package/plugins/generations/music-gen/dist/index.js +23544 -0
  24. package/plugins/generations/music-gen/package.json +24 -0
  25. package/plugins/generations/music-gen/plugin.json +23 -0
  26. package/plugins/generations/music-gen/presets/SOURCE.md +39 -0
  27. package/plugins/generations/music-gen/presets/formats/clip.yaml +21 -0
  28. package/plugins/generations/music-gen/presets/formats/jingle.yaml +22 -0
  29. package/plugins/generations/music-gen/presets/formats/loop.yaml +21 -0
  30. package/plugins/generations/music-gen/presets/formats/song.yaml +31 -0
  31. package/plugins/generations/music-gen/presets/formats/underscore.yaml +22 -0
  32. package/plugins/generations/music-gen/presets/themes/ambient-tech.yaml +30 -0
  33. package/plugins/generations/music-gen/presets/themes/cinematic.yaml +30 -0
  34. package/plugins/generations/music-gen/presets/themes/lofi.yaml +30 -0
  35. package/plugins/generations/music-gen/presets/themes/synthwave.yaml +30 -0
  36. package/plugins/generations/music-gen/scripts/gen-preset-index.ts +181 -0
  37. package/plugins/generations/music-gen/scripts/resolve-preset.ts +64 -0
  38. package/plugins/generations/music-gen/src/adapter/index.ts +35 -0
  39. package/plugins/generations/music-gen/src/adapter/instance.ts +904 -0
  40. package/plugins/generations/music-gen/src/adapter/offline.ts +124 -0
  41. package/plugins/generations/music-gen/src/artifact.ts +223 -0
  42. package/plugins/generations/music-gen/src/audio/checks.ts +618 -0
  43. package/plugins/generations/music-gen/src/audio/master.ts +267 -0
  44. package/plugins/generations/music-gen/src/audio/measure.ts +507 -0
  45. package/plugins/generations/music-gen/src/audio/profile.ts +131 -0
  46. package/plugins/generations/music-gen/src/audio.ts +122 -0
  47. package/plugins/generations/music-gen/src/brief.ts +191 -0
  48. package/plugins/generations/music-gen/src/config.ts +451 -0
  49. package/plugins/generations/music-gen/src/content.ts +199 -0
  50. package/plugins/generations/music-gen/src/digest.ts +100 -0
  51. package/plugins/generations/music-gen/src/index.ts +147 -0
  52. package/plugins/generations/music-gen/src/job.ts +131 -0
  53. package/plugins/generations/music-gen/src/plugin.ts +371 -0
  54. package/plugins/generations/music-gen/src/presets.ts +918 -0
  55. package/plugins/generations/music-gen/src/render.ts +87 -0
  56. package/plugins/generations/music-gen/src/request.ts +102 -0
  57. package/plugins/generations/music-gen/src/spend.ts +495 -0
  58. package/plugins/generations/music-gen/tsconfig.json +8 -0
  59. package/plugins/kk/config.example.yaml +3 -0
  60. package/plugins/kk/decisions/extract/ai-news.yaml +5 -2
  61. package/plugins/kk/plugin.json +1 -1
  62. package/plugins/kk/publish-presets/daily-ai-voice.json +48 -7
  63. package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +2 -1
  64. package/plugins/kk/scripts/cover-compositor.ts +380 -32
  65. package/plugins/kk/scripts/daily-cover-mock.ts +40 -3
  66. package/plugins/kk/scripts/daily-stages.ts +897 -34
  67. package/plugins/kk/scripts/episode-identity.ts +180 -0
  68. package/plugins/kk/scripts/kk-workflow-stages.ts +37 -1
  69. package/plugins/kk/scripts/music-stages.ts +624 -0
  70. package/plugins/kk/scripts/news-editorial-ledger.ts +906 -0
  71. package/plugins/kk/scripts/source-citation.ts +187 -0
  72. package/plugins/kk/scripts/topic-selection-attempts.ts +446 -0
  73. package/plugins/kk/scripts/topic-selection-calibration.ts +161 -0
  74. package/plugins/kk/skills/content-judge/SKILL.md +11 -6
  75. package/plugins/kk/skills/content-judge/references/music-quality-rubric.md +147 -0
  76. package/plugins/kk/skills/content-judge/references/rubrics.md +15 -0
  77. package/plugins/kk/skills/content-safety/SKILL.md +12 -0
  78. package/plugins/kk/skills/image-authoring/SKILL.md +7 -3
  79. package/plugins/kk/skills/image-authoring/references/providers.md +27 -0
  80. package/plugins/kk/skills/image-authoring/references/style-extraction.md +1 -1
  81. package/plugins/kk/skills/music-authoring/SKILL.md +276 -0
  82. package/plugins/kk/skills/music-authoring/references/judge-input.md +117 -0
  83. package/plugins/kk/skills/news-editorial/SKILL.md +102 -15
  84. package/plugins/kk/skills/news-editorial/references/selection.md +4 -0
  85. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +58 -11
  86. package/plugins/kk/skills/publish/SKILL.md +11 -0
  87. package/plugins/kk/skills/web-automation/SKILL.md +31 -1
  88. package/plugins/kk/workflows/kk-collect.yaml +8 -4
  89. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +10 -9
  90. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +11 -9
  91. package/plugins/kk/workflows/kk-music.yaml +328 -0
  92. package/plugins/kk/workflows/kk-news-generate.yaml +58 -3
  93. package/plugins/publishings/bilibili-pub/dist/index.js +11 -1
  94. package/plugins/publishings/bilibili-pub/dist/profile-check.js +11 -1
  95. package/plugins/publishings/cnblogs-pub/dist/index.js +11 -1
  96. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +11 -1
  97. package/plugins/publishings/csdn-pub/dist/index.js +11 -1
  98. package/plugins/publishings/csdn-pub/dist/profile-check.js +11 -1
  99. package/plugins/publishings/infoq-pub/dist/index.js +11 -1
  100. package/plugins/publishings/infoq-pub/dist/profile-check.js +11 -1
  101. package/plugins/publishings/jike-pub/dist/index.js +11 -1
  102. package/plugins/publishings/jike-pub/dist/profile-check.js +11 -1
  103. package/plugins/publishings/juejin-pub/dist/index.js +11 -1
  104. package/plugins/publishings/juejin-pub/dist/profile-check.js +11 -1
  105. package/plugins/publishings/linkedin-pub/dist/index.js +54 -7
  106. package/plugins/publishings/linkedin-pub/dist/profile-check.js +43 -6
  107. package/plugins/publishings/linkedin-pub/src/index.ts +52 -6
  108. package/plugins/publishings/podcast-pub/dist/index.js +586 -20
  109. package/plugins/publishings/podcast-pub/src/corrections.ts +509 -0
  110. package/plugins/publishings/podcast-pub/src/index.ts +257 -5
  111. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +240 -0
  112. package/plugins/publishings/podcast-pub/src/show-notes.ts +69 -13
  113. package/plugins/publishings/shipinhao-pub/dist/index.js +437 -32
  114. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +14 -2
  115. package/plugins/publishings/shipinhao-pub/plugin.json +1 -1
  116. package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +492 -0
  117. package/plugins/publishings/shipinhao-pub/src/flow.ts +227 -12
  118. package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -0
  119. package/plugins/publishings/sspai-pub/dist/index.js +11 -1
  120. package/plugins/publishings/sspai-pub/dist/profile-check.js +11 -1
  121. package/plugins/publishings/substack-pub/dist/index.js +11 -1
  122. package/plugins/publishings/substack-pub/dist/profile-check.js +11 -1
  123. package/plugins/publishings/surfdash-pub/dist/index.js +122 -28
  124. package/plugins/publishings/surfdash-pub/src/digest-check.ts +7 -3
  125. package/plugins/publishings/surfdash-pub/src/index.ts +159 -25
  126. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +37 -4
  127. package/plugins/publishings/threads-pub/dist/index.js +9206 -296
  128. package/plugins/publishings/threads-pub/dist/profile-check.js +21149 -0
  129. package/plugins/publishings/threads-pub/package.json +3 -1
  130. package/plugins/publishings/threads-pub/plugin.json +6 -1
  131. package/plugins/publishings/threads-pub/src/index.ts +8 -1
  132. package/plugins/publishings/threads-pub/src/post-rail.ts +357 -0
  133. package/plugins/publishings/threads-pub/src/profile-check.ts +17 -0
  134. package/plugins/publishings/wechatmp-pub/dist/index.js +18 -1
  135. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +11 -1
  136. package/plugins/publishings/wechatmp-pub/src/flow.ts +13 -0
  137. package/plugins/publishings/weibo-pub/dist/index.js +57 -3
  138. package/plugins/publishings/weibo-pub/dist/profile-check.js +11 -1
  139. package/plugins/publishings/weibo-pub/src/index.ts +74 -2
  140. package/plugins/publishings/x-pub/dist/index.js +274 -44
  141. package/plugins/publishings/x-pub/dist/profile-check.js +14 -2
  142. package/plugins/publishings/x-pub/src/index.ts +15 -1
  143. package/plugins/publishings/x-pub/src/post-rail.ts +334 -0
  144. package/plugins/publishings/xhs-pub/dist/index.js +11 -1
  145. package/plugins/publishings/xhs-pub/dist/profile-check.js +11 -1
  146. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +11 -1
  147. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +11 -1
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@gobing-ai/music-gen",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "exports": {
7
+ ".": "./src/index.ts"
8
+ },
9
+ "scripts": {
10
+ "typecheck": "tsc --noEmit",
11
+ "gen:preset-index": "bun scripts/gen-preset-index.ts",
12
+ "check:preset-index": "bun scripts/gen-preset-index.ts --check",
13
+ "resolve-preset": "bun scripts/resolve-preset.ts"
14
+ },
15
+ "dependencies": {
16
+ "@gobing-ai/kk-core": "workspace:*",
17
+ "@gobing-ai/ts-runtime": "catalog:",
18
+ "@gobing-ai/ts-utils": "catalog:",
19
+ "zod": "4.4.3"
20
+ },
21
+ "devDependencies": {
22
+ "@types/bun": "1.4.3"
23
+ }
24
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "music-gen",
3
+ "kind": "generator",
4
+ "entry": "./dist/index.js",
5
+ "version": "0.1.0",
6
+ "description": "Music generation plugin: one authored MusicBrief → audio Content over the self-hosted Lyria 3 instance (pro/clip), with a reconcile-don't-retry paid-call policy and an offline adapter (feature D8)",
7
+ "runtime": {
8
+ "requires": [
9
+ "@gobing-ai/kk-core",
10
+ "@gobing-ai/ts-runtime",
11
+ "@gobing-ai/ts-utils",
12
+ "fetch",
13
+ "ffmpeg",
14
+ "ffprobe",
15
+ "node:crypto",
16
+ "node:fs/promises",
17
+ "node:os",
18
+ "node:path",
19
+ "node:util",
20
+ "zod"
21
+ ]
22
+ }
23
+ }
@@ -0,0 +1,39 @@
1
+ # Preset provenance and evidence discipline
2
+
3
+ Every preset file carries a `provenance` block (`authoring_source`, `authored_at`, `status`). The
4
+ loader rejects a file without one, and rejects any `status` outside
5
+ `authored | evidence-pending | verified` — a preset may not claim a quality result it has not
6
+ produced.
7
+
8
+ | Status | Meaning |
9
+ | --- | --- |
10
+ | `authored` | Written from the design contract. No generated take has been judged against it yet. |
11
+ | `evidence-pending` | Queued for a real generation round; the round has not concluded. |
12
+ | `verified` | A real generated take was reviewed and accepted for this format × theme pair. **Requires a generation id.** |
13
+
14
+ ## Where these presets come from
15
+
16
+ `formats/*.yaml` and `themes/*.yaml` were authored for task 0399 (feature D8) from two sources inside
17
+ this repository: the frozen contract in `docs/design/music-gen.md` section 5 (precedence, portability,
18
+ `lyrics_policy`, clip's ~30 s ceiling) and the authoring form in
19
+ `plugins/generations/music-gen/README.md`. No third-party prompt corpus was imported, so there is no
20
+ licence obligation and no reference image set to vendor.
21
+
22
+ Nothing here names a provider, a base URL or an API model id. `model: pro|clip` is the instance's own
23
+ selector; the mapping to a concrete upstream model id belongs to the instance, so a provider swap
24
+ leaves every preset byte-identical. Prices are user config (`music.prices`, task 0400) for the same
25
+ reason.
26
+
27
+ ## Not shipped
28
+
29
+ `corporate-tech` and `xhs-pop` are deliberately absent. Both are plausible themes, but neither has
30
+ produced a generated take this feature could point at, and K3's lesson
31
+ (`plugins/generations/image-gen/presets/SOURCE.md`) is that bulk-imported presets without a generation
32
+ review are presets nobody can trust. They land in a later evidence round — authored from a real
33
+ listening comparison, not from a guess.
34
+
35
+ ## Promotion
36
+
37
+ A preset moves to `verified` only when task 0404's dogfood round generates the track, the operator
38
+ reviews it, and the evidence note names the generation id and the date. Until then the index in
39
+ `README.md` prints `authored`, and that is the honest answer.
@@ -0,0 +1,21 @@
1
+ # Format preset: one idea in roughly thirty seconds. A clip job ignores duration, so
2
+ # this preset declares no duration target and no structure line past the clip ceiling.
3
+ name: clip
4
+ description: Roughly thirty-second clip — one idea, no full arc.
5
+ intended_use: Quick preview, a direction check before a pro run, or a short social cut.
6
+ model: clip
7
+ lyrics_policy: allowed
8
+ structure:
9
+ - at: "0:00"
10
+ section: Statement
11
+ note: start on the main idea, no intro build
12
+ - at: "0:15"
13
+ section: Variation
14
+ note: add one instrument or restate the hook
15
+ - at: "0:26"
16
+ section: Close
17
+ note: land the last chord on the clip boundary
18
+ provenance:
19
+ authoring_source: task 0399 (feature D8) — docs/design/music-gen.md section 5 and the plugin README authoring form
20
+ authored_at: "2026-11-19"
21
+ status: authored
@@ -0,0 +1,22 @@
1
+ # Format preset: a twenty-second ident. The hook states the name once and the tag
2
+ # resolves fast, so the skeleton never reaches past the declared duration target.
3
+ name: jingle
4
+ description: Twenty-second ident with a sung or spoken tag.
5
+ intended_use: Product or station ident — the hook states the name once and resolves fast.
6
+ model: pro
7
+ duration_target: "0:20"
8
+ lyrics_policy: allowed
9
+ structure:
10
+ - at: "0:00"
11
+ section: Hook
12
+ note: state the product name once, on the downbeat
13
+ - at: "0:10"
14
+ section: Tag
15
+ note: short melodic tag, no fade
16
+ - at: "0:17"
17
+ section: Resolve
18
+ note: final sustained chord, ends on the beat
19
+ provenance:
20
+ authoring_source: task 0399 (feature D8) — docs/design/music-gen.md section 5 and the plugin README authoring form
21
+ authored_at: "2026-11-19"
22
+ status: authored
@@ -0,0 +1,21 @@
1
+ # Format preset: an instrumental loop bed. lyrics_policy forbidden resolves
2
+ # instrumental: true, so the renderer appends the no-vocals directive.
3
+ name: loop
4
+ description: Instrumental thirty-second loop that repeats cleanly at the boundary.
5
+ intended_use: Background bed for a talk-through, demo or menu loop; no vocals by design.
6
+ model: clip
7
+ lyrics_policy: forbidden
8
+ structure:
9
+ - at: "0:00"
10
+ section: Groove in
11
+ note: drums and bass from bar one, no intro
12
+ - at: "0:12"
13
+ section: Layer
14
+ note: add the pad and one percussive counter-line
15
+ - at: "0:24"
16
+ section: Loop point
17
+ note: return to the bar-one figure so the clip repeats seamlessly
18
+ provenance:
19
+ authoring_source: task 0399 (feature D8) — docs/design/music-gen.md section 5 and the plugin README authoring form
20
+ authored_at: "2026-11-19"
21
+ status: authored
@@ -0,0 +1,31 @@
1
+ # Format preset: the job intent and structural skeleton. Portable data — no upstream
2
+ # vendor identity or spend fact may appear here (see FORBIDDEN_PRESET_KEYS in src/presets.ts).
3
+ name: song
4
+ description: Full song with vocals — intro, two verses, two choruses and a closing resolve.
5
+ intended_use: A complete track with a sung hook; the default for lyrical pieces.
6
+ model: pro
7
+ duration_target: "2:30"
8
+ lyrics_policy: allowed
9
+ structure:
10
+ - at: "0:00"
11
+ section: Intro
12
+ note: establish the harmonic bed, drums enter after four bars
13
+ - at: "0:15"
14
+ section: Verse 1
15
+ note: sparse arrangement, vocal front and centre
16
+ - at: "0:45"
17
+ section: Chorus
18
+ note: full arrangement, hook lyric stated plainly
19
+ - at: "1:15"
20
+ section: Verse 2
21
+ note: one counter-melody added, vocal stays dry
22
+ - at: "1:45"
23
+ section: Chorus
24
+ note: repeat the hook with a wider harmony stack
25
+ - at: "2:10"
26
+ section: Outro
27
+ note: strip back to the harmonic bed and resolve without a fade
28
+ provenance:
29
+ authoring_source: task 0399 (feature D8) — docs/design/music-gen.md section 5 and the plugin README authoring form
30
+ authored_at: "2026-11-19"
31
+ status: authored
@@ -0,0 +1,22 @@
1
+ # Format preset: an instrumental bed under narration. No hook requirement — the arc
2
+ # deliberately withholds a melodic foreground so a voice can sit in the midrange.
3
+ name: underscore
4
+ description: Instrumental bed for narration — supports the voice, never competes with it.
5
+ intended_use: Underscore under spoken narration or a video essay; no hook or vocal required.
6
+ model: pro
7
+ duration_target: "0:45"
8
+ lyrics_policy: forbidden
9
+ structure:
10
+ - at: "0:00"
11
+ section: Establish
12
+ note: soft harmonic bed, no melodic foreground
13
+ - at: "0:15"
14
+ section: Sustain
15
+ note: hold the texture, leave the midrange open for a voice
16
+ - at: "0:35"
17
+ section: Settle
18
+ note: thin out and resolve under the last sentence
19
+ provenance:
20
+ authoring_source: task 0399 (feature D8) — docs/design/music-gen.md section 5 and the plugin README authoring form
21
+ authored_at: "2026-11-19"
22
+ status: authored
@@ -0,0 +1,30 @@
1
+ # Theme preset: the technical direction prose is the only control surface the model
2
+ # reads, so every facet below must appear verbatim in `style` (the loader enforces it).
3
+ name: ambient-tech
4
+ description: Glassy ambient techno with a steady pulse.
5
+ intended_use: Product walkthroughs, conference holds, editorial beds that must stay out of the way.
6
+ genre: glassy ambient techno
7
+ tempo: 100-115 BPM, steady and unaccented
8
+ key: C# minor
9
+ instrumentation:
10
+ - glassy FM bell
11
+ - granular pad
12
+ - muted kick and rim clicks
13
+ - clean sub pulse
14
+ - long reverb tail
15
+ vocal_character: no lead vocal; occasional whispered, heavily reverberated fragments
16
+ production: long reverb tails, wide stereo field, clean digital low end
17
+ style: |-
18
+ Glassy ambient techno, 100-115 BPM, steady and unaccented, in C# minor.
19
+ Instrumentation: glassy FM bell, granular pad, muted kick and rim clicks, clean sub pulse, long reverb tail.
20
+ Vocal: no lead vocal; occasional whispered, heavily reverberated fragments.
21
+ Production: long reverb tails, wide stereo field, clean digital low end.
22
+ avoid:
23
+ - hard drops
24
+ - talkbox vocals
25
+ - pop hooks
26
+ - vocal chops
27
+ provenance:
28
+ authoring_source: task 0399 (feature D8) — docs/design/music-gen.md section 5 and the plugin README authoring form
29
+ authored_at: "2026-11-19"
30
+ status: authored
@@ -0,0 +1,30 @@
1
+ # Theme preset: the technical direction prose is the only control surface the model
2
+ # reads, so every facet below must appear verbatim in `style` (the loader enforces it).
3
+ name: cinematic
4
+ description: Orchestral/hybrid score with a dramatic arc.
5
+ intended_use: Trailer-style openings, story intros, a track that must feel like a scene.
6
+ genre: cinematic orchestral hybrid score
7
+ tempo: 60-90 BPM with rubato swells
8
+ key: D minor
9
+ instrumentation:
10
+ - low string ostinato
11
+ - braam-style brass cluster
12
+ - taiko and frame drum
13
+ - felt piano
14
+ - wordless choir pad
15
+ vocal_character: wordless choir texture only; no lead vocal line
16
+ production: wide orchestral reverb, trailer-bright master, sub-heavy low end
17
+ style: |-
18
+ Cinematic orchestral hybrid score, 60-90 BPM with rubato swells, in D minor.
19
+ Instrumentation: low string ostinato, braam-style brass cluster, taiko and frame drum, felt piano, wordless choir pad.
20
+ Vocal: wordless choir texture only; no lead vocal line.
21
+ Production: wide orchestral reverb, trailer-bright master, sub-heavy low end.
22
+ avoid:
23
+ - horror stingers
24
+ - orchestral hits on every downbeat
25
+ - distorted electric guitar
26
+ - pop chorus stacks
27
+ provenance:
28
+ authoring_source: task 0399 (feature D8) — docs/design/music-gen.md section 5 and the plugin README authoring form
29
+ authored_at: "2026-11-19"
30
+ status: authored
@@ -0,0 +1,30 @@
1
+ # Theme preset: the technical direction prose is the only control surface the model
2
+ # reads, so every facet below must appear verbatim in `style` (the loader enforces it).
3
+ name: lofi
4
+ description: Dusty sampled lo-fi hip-hop bed.
5
+ intended_use: Study/focus background, calm narration bed, unhurried social cuts.
6
+ genre: dusty sampled lo-fi hip-hop
7
+ tempo: 70-85 BPM, swung and unhurried
8
+ key: A minor
9
+ instrumentation:
10
+ - vinyl-textured drum break
11
+ - sampled Rhodes chords
12
+ - upright bass
13
+ - mellow vibraphone
14
+ - tape hiss bed
15
+ vocal_character: optional intimate alto, close-mic and conversational; absent when the format is instrumental
16
+ production: tape saturation, a 12 kHz low-pass, gentle sidechain, audible vinyl crackle
17
+ style: |-
18
+ Dusty sampled lo-fi hip-hop, 70-85 BPM, swung and unhurried, in A minor.
19
+ Instrumentation: vinyl-textured drum break, sampled Rhodes chords, upright bass, mellow vibraphone, tape hiss bed.
20
+ Vocal: optional intimate alto, close-mic and conversational; absent when the format is instrumental.
21
+ Production: tape saturation, a 12 kHz low-pass, gentle sidechain, audible vinyl crackle.
22
+ avoid:
23
+ - trap hi-hat rolls
24
+ - hard drops
25
+ - EDM riser clichés
26
+ - over-compressed loudness
27
+ provenance:
28
+ authoring_source: task 0399 (feature D8) — docs/design/music-gen.md section 5 and the plugin README authoring form
29
+ authored_at: "2026-11-19"
30
+ status: authored
@@ -0,0 +1,30 @@
1
+ # Theme preset: the technical direction prose is the only control surface the model
2
+ # reads, so every facet below must appear verbatim in `style` (the loader enforces it).
3
+ name: synthwave
4
+ description: Analog synth revival with gated drums.
5
+ intended_use: Retro-tech explainers, night-drive montages, upbeat product stings.
6
+ genre: analog synthwave revival
7
+ tempo: 90-110 BPM, straight four-on-the-floor
8
+ key: A minor
9
+ instrumentation:
10
+ - detuned saw pad
11
+ - gated snare
12
+ - round sub bass
13
+ - arpeggiated lead
14
+ - chorus electric guitar
15
+ vocal_character: breathy female alto, doubled and slightly detuned; optional when the format is instrumental
16
+ production: analog tape warmth, wide stereo chorus, gated reverb on the snare
17
+ style: |-
18
+ Analog synthwave revival, 90-110 BPM, straight four-on-the-floor, in A minor.
19
+ Instrumentation: detuned saw pad, gated snare, round sub bass, arpeggiated lead, chorus electric guitar.
20
+ Vocal: breathy female alto, doubled and slightly detuned; optional when the format is instrumental.
21
+ Production: analog tape warmth, wide stereo chorus, gated reverb on the snare.
22
+ avoid:
23
+ - festival supersaws
24
+ - EDM risers
25
+ - distorted djent guitars
26
+ - modern trap percussion
27
+ provenance:
28
+ authoring_source: task 0399 (feature D8) — docs/design/music-gen.md section 5 and the plugin README authoring form
29
+ authored_at: "2026-11-19"
30
+ status: authored
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Preset index generator (task 0399 R5). Renders the format + theme inventory
3
+ * into `README.md` between the `<!-- preset-index:start -->` and
4
+ * `<!-- preset-index:end -->` markers, so the index cannot drift from the data
5
+ * files: `--check` fails when the README no longer equals the presets.
6
+ *
7
+ * bun plugins/generations/music-gen/scripts/gen-preset-index.ts # rewrite the block
8
+ * bun plugins/generations/music-gen/scripts/gen-preset-index.ts --check # exit 1 on drift
9
+ * bun run --cwd plugins/generations/music-gen gen:preset-index
10
+ *
11
+ * Only the shipped `presets/` root is read — a user or project preset root must
12
+ * never leak into the published index (image-gen's `gen-samples.ts` precedent).
13
+ */
14
+ import { readFileSync, writeFileSync } from 'node:fs';
15
+ import { join } from 'node:path';
16
+ import { type LoadedMusicPresets, loadMusicPresets, PresetDataError } from '../src/presets';
17
+
18
+ export const PLUGIN_DIR = join(import.meta.dir, '..');
19
+ export const README_PATH = join(PLUGIN_DIR, 'README.md');
20
+
21
+ /** Markers the generated block lives between. */
22
+ export const INDEX_START = '<!-- preset-index:start -->';
23
+ export const INDEX_END = '<!-- preset-index:end -->';
24
+
25
+ /** A duration cell for a format that has no target (clip is fixed at about 0:30). */
26
+ const NO_DURATION = '— (clip is fixed at ~0:30)';
27
+
28
+ /** Make a value safe inside a markdown table cell. */
29
+ function cell(value: string): string {
30
+ return value
31
+ .replace(/\|/g, '\\|')
32
+ .replace(/\s*\n\s*/g, ' ')
33
+ .trim();
34
+ }
35
+
36
+ /** One row per shipped format, sorted by name. */
37
+ function formatRows(presets: LoadedMusicPresets): string[] {
38
+ return [...presets.formats.values()]
39
+ .sort((a, b) => a.name.localeCompare(b.name))
40
+ .map((preset) => {
41
+ const duration = preset.duration_target === undefined ? NO_DURATION : `\`${preset.duration_target}\``;
42
+ return `| \`${preset.name}\` | \`${preset.model}\` | ${duration} | ${preset.lyrics_policy} | ${cell(preset.intended_use)} | \`${preset.provenance.status}\` |`;
43
+ });
44
+ }
45
+
46
+ /** One row per shipped theme, sorted by name. */
47
+ function themeRows(presets: LoadedMusicPresets): string[] {
48
+ return [...presets.themes.values()]
49
+ .sort((a, b) => a.name.localeCompare(b.name))
50
+ .map((preset) => {
51
+ const direction = `${preset.genre}; ${preset.tempo}; ${preset.key}`;
52
+ return `| \`${preset.name}\` | ${cell(direction)} | ${cell(preset.avoid.join(', '))} | ${cell(preset.intended_use)} | \`${preset.provenance.status}\` |`;
53
+ });
54
+ }
55
+
56
+ /** The full generated block, with a marker-free trailing newline. */
57
+ export function renderPresetIndex(presets: LoadedMusicPresets): string {
58
+ return [
59
+ `\`formats/\`: ${String(presets.formats.size)} · \`themes/\`: ${String(presets.themes.size)}. Regenerate with`,
60
+ '`bun plugins/generations/music-gen/scripts/gen-preset-index.ts`; `--check` fails on drift.',
61
+ '',
62
+ '### Formats',
63
+ '',
64
+ 'A format fixes the job intent, the instance selector (`pro|clip`), the default duration target and the',
65
+ 'timestamped section skeleton. `lyrics` is the format’s policy: `forbidden` resolves `instrumental: true`.',
66
+ '',
67
+ '| Format | Model | Default duration | Lyrics | Intended use | Status |',
68
+ '| --- | --- | --- | --- | --- | --- |',
69
+ ...formatRows(presets),
70
+ '',
71
+ '### Themes',
72
+ '',
73
+ 'A theme supplies the technical-direction prose the model reads — genre, tempo, key, instrumentation,',
74
+ 'vocal character and production — plus its default `avoid[]`, rendered as one `Avoid: …` segment.',
75
+ '',
76
+ '| Theme | Technical direction | Default avoid | Intended use | Status |',
77
+ '| --- | --- | --- | --- | --- |',
78
+ ...themeRows(presets),
79
+ ].join('\n');
80
+ }
81
+
82
+ /** Replace the block between the markers; a missing marker is a hard error, never a silent append. */
83
+ export function splicePresetIndex(readme: string, block: string): string {
84
+ const start = readme.indexOf(INDEX_START);
85
+ const end = readme.indexOf(INDEX_END);
86
+ if (start === -1 || end === -1 || end < start) {
87
+ throw new Error(`README is missing the ${INDEX_START} / ${INDEX_END} preset-index markers`);
88
+ }
89
+ return `${readme.slice(0, start + INDEX_START.length)}\n${block}\n${readme.slice(end)}`;
90
+ }
91
+
92
+ export interface PresetIndexOptions {
93
+ /** Preset root override (tests and probes use a throwaway tree). */
94
+ root?: string;
95
+ /** README path override, so a test never rewrites the shipped index by accident. */
96
+ readmePath?: string;
97
+ }
98
+
99
+ export interface PresetIndexCheck {
100
+ ok: boolean;
101
+ /** What the README must contain once the generator has run. */
102
+ expected: string;
103
+ /** What the README contains now. */
104
+ actual: string;
105
+ }
106
+
107
+ /** Compare the README block against the shipped presets (AC5). */
108
+ export async function checkPresetIndex(options: PresetIndexOptions = {}): Promise<PresetIndexCheck> {
109
+ const presets = await loadMusicPresets(options.root === undefined ? {} : { root: options.root });
110
+ const readmePath = options.readmePath ?? README_PATH;
111
+ const actual = readFileSync(readmePath, 'utf8');
112
+ return {
113
+ ok: splicePresetIndex(actual, renderPresetIndex(presets)) === actual,
114
+ expected: renderPresetIndex(presets),
115
+ actual,
116
+ };
117
+ }
118
+
119
+ /** Print the first differing line pair, so a drift report points at the row that changed. */
120
+ function driftReport(result: PresetIndexCheck): string[] {
121
+ const wanted = splicePresetIndex(result.actual, result.expected).split('\n');
122
+ const have = result.actual.split('\n');
123
+ const lines: string[] = [];
124
+ const length = Math.max(wanted.length, have.length);
125
+ for (let index = 0; index < length; index += 1) {
126
+ if (wanted[index] !== have[index]) {
127
+ lines.push(` line ${String(index + 1)}`);
128
+ lines.push(` - ${have[index] ?? '(missing)'}`);
129
+ lines.push(` + ${wanted[index] ?? '(missing)'}`);
130
+ if (lines.length >= 9) {
131
+ break;
132
+ }
133
+ }
134
+ }
135
+ return lines;
136
+ }
137
+
138
+ export async function main(argv: readonly string[], options: PresetIndexOptions = {}): Promise<number> {
139
+ const check = argv.includes('--check');
140
+ const readmePath = options.readmePath ?? README_PATH;
141
+ try {
142
+ if (check) {
143
+ const result = await checkPresetIndex(options);
144
+ if (result.ok) {
145
+ console.log('preset-index: README matches the shipped presets');
146
+ return 0;
147
+ }
148
+ console.error(
149
+ 'preset-index: README drift — run `bun run --cwd plugins/generations/music-gen gen:preset-index`',
150
+ );
151
+ for (const line of driftReport(result)) {
152
+ console.error(line);
153
+ }
154
+ return 1;
155
+ }
156
+ const presets = await loadMusicPresets(options.root === undefined ? {} : { root: options.root });
157
+ const readme = readFileSync(readmePath, 'utf8');
158
+ const next = splicePresetIndex(readme, renderPresetIndex(presets));
159
+ if (next === readme) {
160
+ console.log(
161
+ `preset-index: unchanged (${String(presets.formats.size)} formats, ${String(presets.themes.size)} themes)`,
162
+ );
163
+ return 0;
164
+ }
165
+ writeFileSync(readmePath, next);
166
+ console.log(
167
+ `preset-index: wrote ${String(presets.formats.size)} formats and ${String(presets.themes.size)} themes into README.md`,
168
+ );
169
+ return 0;
170
+ } catch (error) {
171
+ if (error instanceof PresetDataError) {
172
+ console.error(error.message);
173
+ return error.exitCode;
174
+ }
175
+ throw error;
176
+ }
177
+ }
178
+
179
+ if (import.meta.main) {
180
+ process.exit(await main(process.argv.slice(2)));
181
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Resolve one authored brief through the shipped presets and print the trace
3
+ * (task 0399 R3). This is the surface 0401's `kk music presets` verb wraps, and
4
+ * the one a test or a probe drives to prove the exit codes:
5
+ *
6
+ * bun plugins/generations/music-gen/scripts/resolve-preset.ts --in brief.yaml
7
+ * bun plugins/generations/music-gen/scripts/resolve-preset.ts --in brief.yaml --root /tmp/presets
8
+ * bun plugins/generations/music-gen/scripts/resolve-preset.ts --in brief.yaml --json
9
+ *
10
+ * Exit 0 resolved · 1 unparseable brief or unknown format/theme · 2 invalid preset file.
11
+ * An unknown name never falls back: it prints the valid names and the trace the
12
+ * layers that did exist produced.
13
+ */
14
+ import { readFileSync } from 'node:fs';
15
+ import { parseMusicBriefYaml } from '../src/brief';
16
+ import { explainJob, loadMusicPresets, PresetDataError, resolveNamedJob, UnknownPresetError } from '../src/presets';
17
+ import { renderGenerateRequest } from '../src/request';
18
+
19
+ function option(argv: readonly string[], name: string): string | undefined {
20
+ const index = argv.indexOf(name);
21
+ const value = index >= 0 ? argv[index + 1] : undefined;
22
+ return value === undefined ? undefined : value;
23
+ }
24
+
25
+ export async function main(argv: readonly string[]): Promise<number> {
26
+ const briefPath = option(argv, '--in');
27
+ if (briefPath === undefined) {
28
+ console.error('usage: resolve-preset.ts --in <brief.yaml> [--root <preset-root>] [--json]');
29
+ return 1;
30
+ }
31
+ let brief: ReturnType<typeof parseMusicBriefYaml>;
32
+ try {
33
+ brief = parseMusicBriefYaml(readFileSync(briefPath, 'utf8'));
34
+ } catch (error) {
35
+ console.error(`invalid brief ${briefPath}: ${error instanceof Error ? error.message : String(error)}`);
36
+ return 1;
37
+ }
38
+ const root = option(argv, '--root');
39
+ try {
40
+ const presets = await loadMusicPresets(root === undefined ? {} : { root });
41
+ const job = resolveNamedJob(brief, presets);
42
+ for (const line of explainJob(job)) {
43
+ console.log(line);
44
+ }
45
+ if (argv.includes('--json')) {
46
+ console.log(JSON.stringify(renderGenerateRequest(job), null, 2));
47
+ }
48
+ return 0;
49
+ } catch (error) {
50
+ if (error instanceof UnknownPresetError) {
51
+ console.error(error.report);
52
+ return error.exitCode;
53
+ }
54
+ if (error instanceof PresetDataError) {
55
+ console.error(error.message);
56
+ return error.exitCode;
57
+ }
58
+ throw error;
59
+ }
60
+ }
61
+
62
+ if (import.meta.main) {
63
+ process.exit(await main(process.argv.slice(2)));
64
+ }
@@ -0,0 +1,35 @@
1
+ import type { MusicConfig } from '../config';
2
+ import { createInstanceClient, type InstanceClientOptions, type MusicInstance } from './instance';
3
+ import { createOfflineInstance } from './offline';
4
+
5
+ /**
6
+ * Adapter selection (task 0398 R2/R4).
7
+ *
8
+ * `KK_MUSIC_DRY_RUN=1` — surfaced as {@link MusicConfig.dryRun} — selects the
9
+ * offline adapter and nothing else: the selected client holds no fetch seam, so
10
+ * a dry run cannot open a socket even if the injected fetch would answer.
11
+ */
12
+
13
+ export * from './instance';
14
+ export * from './offline';
15
+
16
+ /**
17
+ * Build the adapter for one run.
18
+ *
19
+ * @param config resolved music config (its `dryRun` is the `KK_MUSIC_DRY_RUN=1` switch)
20
+ * @param options live-client overrides; ignored by the offline adapter
21
+ */
22
+ export function createMusicInstance(
23
+ config: Pick<MusicConfig, 'baseUrl' | 'timeoutMs' | 'connectTimeoutMs' | 'dryRun'>,
24
+ options: InstanceClientOptions = {},
25
+ ): MusicInstance {
26
+ if (config.dryRun) {
27
+ return createOfflineInstance();
28
+ }
29
+ return createInstanceClient({
30
+ baseUrl: config.baseUrl,
31
+ timeoutMs: config.timeoutMs,
32
+ connectTimeoutMs: config.connectTimeoutMs,
33
+ ...options,
34
+ });
35
+ }