@gobing-ai/knowledge-kit 0.0.28 → 0.0.30

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 (97) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +114 -38
  3. package/package.json +1 -1
  4. package/plugins/generations/daily-article-gen/dist/index.js +45 -5
  5. package/plugins/generations/daily-article-gen/src/index.ts +59 -4
  6. package/plugins/generations/dailynews-gen/dist/index.js +46 -9
  7. package/plugins/generations/dailynews-gen/src/index.ts +36 -1
  8. package/plugins/generations/dailynews-gen/src/script-builder.ts +15 -12
  9. package/plugins/generations/dailynews-gen/src/script-plan.ts +21 -3
  10. package/plugins/generations/episode-plan-gen/dist/index.js +55 -4
  11. package/plugins/generations/episode-plan-gen/src/index.ts +80 -2
  12. package/plugins/generations/image-gen/assets/fonts/NotoSansSC-Bold.otf +0 -0
  13. package/plugins/generations/image-gen/assets/fonts/NotoSansSC-Regular.otf +0 -0
  14. package/plugins/generations/image-gen/assets/fonts/OFL.txt +92 -0
  15. package/plugins/generations/image-gen/assets/fonts/SOURCE.md +15 -0
  16. package/plugins/generations/image-gen/dist/index.js +700 -22
  17. package/plugins/generations/image-gen/package.json +1 -0
  18. package/plugins/generations/image-gen/presets/formats/daily-news-cover.yaml +2 -2
  19. package/plugins/generations/image-gen/presets/formats/xhs-card.yaml +19 -11
  20. package/plugins/generations/image-gen/presets/styles/xhs-knowledge.yaml +2 -1
  21. package/plugins/generations/image-gen/scripts/compose-e2e-artifact.ts +135 -0
  22. package/plugins/generations/image-gen/src/bytes.ts +116 -0
  23. package/plugins/generations/image-gen/src/compose/card.ts +294 -0
  24. package/plugins/generations/image-gen/src/compose/chromium.ts +147 -0
  25. package/plugins/generations/image-gen/src/compose/cmap.ts +177 -0
  26. package/plugins/generations/image-gen/src/index.ts +211 -13
  27. package/plugins/generations/image-gen/src/job.ts +12 -0
  28. package/plugins/generations/image-gen/src/presets.ts +53 -13
  29. package/plugins/generations/image-gen/src/providers/minimax.ts +12 -4
  30. package/plugins/generations/image-gen/src/providers/types.ts +12 -1
  31. package/plugins/kk/plugin.json +1 -1
  32. package/plugins/kk/scripts/daily-voice-style.zh.md +27 -14
  33. package/plugins/kk/scripts/itc-stages.ts +21 -3
  34. package/plugins/kk/scripts/kk-workflow-stages.ts +461 -10
  35. package/plugins/kk/scripts/topic-boundary.json +96 -0
  36. package/plugins/kk/scripts/validate-voicescript.ts +15 -0
  37. package/plugins/kk/skills/content-judge/SKILL.md +30 -0
  38. package/plugins/kk/skills/content-judge/references/workflow-integration.md +9 -2
  39. package/plugins/kk/skills/content-safety/SKILL.md +163 -0
  40. package/plugins/kk/skills/content-safety/references/platforms/apple-podcasts.md +36 -0
  41. package/plugins/kk/skills/content-safety/references/platforms/netease-music.md +31 -0
  42. package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +32 -0
  43. package/plugins/kk/skills/content-safety/references/platforms/xiaoyuzhou.md +35 -0
  44. package/plugins/kk/skills/publish/SKILL.md +1 -1
  45. package/plugins/kk/skills/xhs-images/SKILL.md +11 -7
  46. package/plugins/kk/skills/xhs-images/references/card-layouts.md +4 -4
  47. package/plugins/kk/workflows/judge-gated-publish-example.yaml +18 -10
  48. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +139 -24
  49. package/plugins/kk/workflows/kk-itc.yaml +21 -8
  50. package/plugins/publishings/podcast-pub/dist/index.js +4 -0
  51. package/plugins/publishings/podcast-pub/src/index.ts +2 -0
  52. package/plugins/publishings/podcast-pub/src/show-notes.ts +6 -0
  53. package/plugins/publishings/xhs-pub/dist/index.js +1 -1
  54. package/plugins/publishings/xhs-pub/src/automation-guard.ts +2 -2
  55. package/plugins/publishings/xhs-pub/src/index.ts +1 -1
  56. package/plugins/publishings/xhs-pub/src/profile-check.ts +2 -2
  57. package/plugins/sp/lib/env.ts +0 -46
  58. package/plugins/sp/lib/inline-run.generated.mjs +0 -1489
  59. package/plugins/sp/scripts/batch-preflight.mjs +0 -346
  60. package/plugins/sp/scripts/batch-preflight.ts +0 -459
  61. package/plugins/sp/scripts/daily-summary/daily-summary.mjs +0 -615
  62. package/plugins/sp/scripts/daily-summary/daily-summary.ts +0 -846
  63. package/plugins/sp/scripts/daily-summary/logger.ts +0 -28
  64. package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.mjs +0 -223
  65. package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts +0 -367
  66. package/plugins/sp/scripts/dogfood-testing/validate-report.mjs +0 -132
  67. package/plugins/sp/scripts/dogfood-testing/validate-report.ts +0 -169
  68. package/plugins/sp/scripts/feature-dev-precheck.mjs +0 -171
  69. package/plugins/sp/scripts/feature-dev-precheck.ts +0 -238
  70. package/plugins/sp/scripts/feature-sync-bounded.mjs +0 -285
  71. package/plugins/sp/scripts/feature-sync-bounded.ts +0 -478
  72. package/plugins/sp/scripts/feature-verification-steps.ts +0 -275
  73. package/plugins/sp/scripts/history-anatomy-cache.mjs +0 -902
  74. package/plugins/sp/scripts/history-anatomy-cache.ts +0 -1028
  75. package/plugins/sp/scripts/idea-handoff.mjs +0 -22
  76. package/plugins/sp/scripts/idea-handoff.ts +0 -44
  77. package/plugins/sp/scripts/inline-pipeline-parity-check.ts +0 -185
  78. package/plugins/sp/scripts/inline-run-setup.ts +0 -722
  79. package/plugins/sp/scripts/pr-reviewing.mjs +0 -769
  80. package/plugins/sp/scripts/pr-reviewing.ts +0 -925
  81. package/plugins/sp/scripts/quality-gate.mjs +0 -179
  82. package/plugins/sp/scripts/quality-gate.ts +0 -217
  83. package/plugins/sp/scripts/script-contract-check.ts +0 -319
  84. package/plugins/sp/scripts/stage-registry-adapter.ts +0 -1533
  85. package/plugins/sp/scripts/surface-drift-inventory.ts +0 -929
  86. package/plugins/sp/scripts/task-evidence-precheck.ts +0 -181
  87. package/plugins/sp/scripts/task-size-precheck.ts +0 -175
  88. package/plugins/sp/scripts/transition-shim-check.ts +0 -238
  89. package/plugins/sp/scripts/validate-commands.ts +0 -689
  90. package/plugins/sp/scripts/validate-flag-contracts.ts +0 -878
  91. package/plugins/sp/scripts/verify-answer-lint.ts +0 -530
  92. package/plugins/sp/scripts/workflow-step-profile.mjs +0 -316
  93. package/plugins/sp/scripts/workflow-step-profile.ts +0 -456
  94. package/plugins/sp/scripts/wrapup-drift-probe.mjs +0 -190
  95. package/plugins/sp/scripts/wrapup-drift-probe.ts +0 -258
  96. package/plugins/sp/scripts/wrapup-steps.mjs +0 -444
  97. package/plugins/sp/scripts/wrapup-steps.ts +0 -552
@@ -1,275 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * feature-verification-steps — the single writer of feature verification
4
- * receipts behind the `feature-verification` workflow (task 0915, remediated
5
- * to the frozen v1 contract; no public CLI verb exists by design).
6
- *
7
- * Usage (workflow onEnter, vars: featureId, verificationCmd, spurBin, __runId):
8
- * bun plugins/sp/scripts/feature-verification-steps.ts verify \
9
- * --feature-id D63 --run-id <runId> --cmd "bun run spur-check-feature"
10
- *
11
- * One pass, in order:
12
- * 1. resolve the selected `feature-verification` definition (project override
13
- * wins) for the verifier identity + configured command,
14
- * 2. capture the before proof-input digest, record the RUNNING receipt (both
15
- * copies) and register the run-scoped receipt as a run artifact,
16
- * 3. run the effective command via the safe launch splitter (never `sh -c`
17
- * interpolation), output to the run-scoped log,
18
- * 4. capture the after digest — a mismatch records FAIL,
19
- * 5. complete the receipt PASS/FAIL (both copies) and the coarse status file.
20
- *
21
- * Always exits 0 after verify; the transition guard reads the status file and
22
- * the completion boundary validates the receipt (fail-closed). Unsafe ids are
23
- * refused outright. Node-builtin imports only (ADR-065); the application seams come
24
- * from the generated inline bundle (`plugins/sp/lib/inline-run.generated.mjs`) — never
25
- * from `packages/app/src/index.ts`, which is not a plugin-script contract surface (0948 R3).
26
- */
27
-
28
- import { spawnSync } from 'node:child_process';
29
- import {
30
- closeSync,
31
- existsSync,
32
- mkdirSync,
33
- openSync,
34
- readdirSync,
35
- readFileSync,
36
- renameSync,
37
- writeFileSync,
38
- } from 'node:fs';
39
- import { join } from 'node:path';
40
- import { fileURLToPath } from 'node:url';
41
- import { getEnvVar } from '../lib/env';
42
-
43
- /** Single safe filename component — same class as the inline-run-setup run-id guard. */
44
- const SAFE_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
45
-
46
- /** Shape of the generated inline bundle / repo app source this script consumes. */
47
- interface VerificationModule {
48
- startFeatureVerificationReceipt: typeof import('../../packages/app/src/workflow/feature-verification-receipt')['startFeatureVerificationReceipt'];
49
- completeFeatureVerificationReceipt: typeof import('../../packages/app/src/workflow/feature-verification-receipt')['completeFeatureVerificationReceipt'];
50
- captureFeatureReceiptDigest: typeof import('../../packages/app/src/workflow/feature-verification-receipt')['captureFeatureReceiptDigest'];
51
- resolveWorkflowDefinition: typeof import('../../packages/app/src/workflow/workflow-resolver')['resolveWorkflowDefinition'];
52
- splitLaunchCommand: typeof import('../../packages/app/src/workflow/split-launch-command')['splitLaunchCommand'];
53
- openInlineRunProjectDb: typeof import('../../packages/app/src/services/inline-run-setup')['openInlineRunProjectDb'];
54
- ArtifactDao: new (
55
- adapter: never,
56
- ) => { record: (input: { runId: string; path: string; kind: string }) => Promise<unknown> };
57
- }
58
-
59
- /** Explicit module surface. Source is not the contract; the generated bundle is (0948 R3). */
60
- type ModuleMode = 'source' | 'bundle';
61
-
62
- function bundleEntry(): string {
63
- return fileURLToPath(new URL('../lib/inline-run.generated.mjs', import.meta.url));
64
- }
65
-
66
- /**
67
- * Source mode names the mode and the fix. The app source entry does not export
68
- * the verification seams, and "rebuild/install the sp plugin" cannot add them.
69
- */
70
- function sourceModeError(spurBin: string): Error {
71
- return new Error(
72
- `source mode: refusing to load packages/app/src/index.ts (spurBin=${JSON.stringify(spurBin)}). ` +
73
- 'That entry is not the feature-verification contract surface — it does not export ' +
74
- 'splitLaunchCommand / ArtifactDao. Fix: run in bundle mode so ' +
75
- 'plugins/sp/lib/inline-run.generated.mjs is loaded (omit --module-mode, or pass --module-mode bundle) ' +
76
- 'and regenerate that bundle if it is missing. Reinstalling the sp plugin does not add these seams to the app source entry.',
77
- );
78
- }
79
-
80
- function resolveModuleMode(raw: string): ModuleMode {
81
- if (raw === '' || raw === 'bundle') return 'bundle';
82
- if (raw === 'source') return 'source';
83
- throw new Error(`unknown --module-mode ${JSON.stringify(raw)}; expected "source" or "bundle"`);
84
- }
85
-
86
- /**
87
- * Bundle mode loads the generated inline bundle. Source mode fails closed with a named fix.
88
- *
89
- * `spurBin` no longer selects the module (it named the *caller's* CLI entry, not this
90
- * script's runtime surface); it is kept only to make the failure message actionable.
91
- */
92
- async function loadModule(spurBin: string, mode: ModuleMode): Promise<VerificationModule> {
93
- if (mode === 'source') throw sourceModeError(spurBin);
94
- const bundle = bundleEntry();
95
- if (!existsSync(bundle)) {
96
- throw new Error(
97
- `feature-verification-steps: mode=bundle — the generated inline bundle is missing at ${bundle}` +
98
- `${spurBin === '' ? '' : ` (spurBin=${spurBin})`}. ` +
99
- 'Fix: in a source checkout run `bun run build:bundle`; for an installed plugin reinstall it.',
100
- );
101
- }
102
- return requireModule(bundle, mode);
103
- }
104
-
105
- /** Dynamic-import the entry and refuse modules missing the verification seams. */
106
- async function requireModule(entry: string, mode: ModuleMode): Promise<VerificationModule> {
107
- const mod = (await import(entry)) as Partial<VerificationModule> & Record<string, unknown>;
108
- const missing = (
109
- [
110
- 'startFeatureVerificationReceipt',
111
- 'completeFeatureVerificationReceipt',
112
- 'captureFeatureReceiptDigest',
113
- 'resolveWorkflowDefinition',
114
- 'splitLaunchCommand',
115
- 'openInlineRunProjectDb',
116
- 'ArtifactDao',
117
- ] as const
118
- ).filter((k) => typeof mod[k] !== 'function');
119
- if (missing.length > 0) {
120
- throw new Error(
121
- `feature-verification-steps: mode=${mode} — application entry ${entry} is missing feature-verification seams (${missing.join(', ')}). ` +
122
- 'Fix: the generated inline bundle is stale or incomplete — run `bun run build:bundle` in a source checkout, or reinstall the sp plugin.',
123
- );
124
- }
125
- return mod as VerificationModule;
126
- }
127
-
128
- /** Refuse ids that could escape the run directory through receipt filenames. */
129
- function assertSafeId(kind: string, id: string): void {
130
- if (!SAFE_ID_RE.test(id) || id.includes('..')) {
131
- throw new Error(`refusing unsafe ${kind}: ${id}`);
132
- }
133
- }
134
-
135
- /** Locate `<id>_<slug>.md` under the features directory. */
136
- function findFeatureFile(featureDir: string, featureId: string): string | undefined {
137
- if (!existsSync(featureDir)) return undefined;
138
- const name = readdirSync(featureDir).find((n) => n.startsWith(`${featureId}_`) && n.endsWith('.md'));
139
- return name === undefined ? undefined : join(featureDir, name);
140
- }
141
-
142
- // ponytail: the receipt service is filesystem-pure over the ts-runtime
143
- // FileSystem port; only ensureDir/writeFile/rename are exercised on the
144
- // start/complete paths. Swap to createNodeFileSystem if more surface is needed.
145
- const nodeFsShim = {
146
- ensureDir: (dir: string) => {
147
- mkdirSync(dir, { recursive: true });
148
- },
149
- writeFile: (path: string, body: string) => {
150
- writeFileSync(path, body);
151
- },
152
- rename: (src: string, dest: string) => {
153
- renameSync(src, dest);
154
- },
155
- readFile: (path: string) => {
156
- return readFileSync(path, 'utf8');
157
- },
158
- } as never;
159
-
160
- /** One full verification pass for one feature. Always exits 0. */
161
- async function verify(
162
- featureId: string,
163
- runId: string,
164
- cmdOverride: string,
165
- spurBin: string,
166
- mode: ModuleMode,
167
- ): Promise<void> {
168
- assertSafeId('feature id', featureId);
169
- assertSafeId('run id', runId);
170
- const cwd = process.cwd();
171
- const mod = await loadModule(spurBin, mode);
172
- const runDir = join(cwd, '.spur', 'run');
173
- mkdirSync(runDir, { recursive: true });
174
-
175
- // 1. Selected verifier definition (project override wins); its configured
176
- // command is the completion contract — an override records but can't complete.
177
- const selected = await mod.resolveWorkflowDefinition(cwd, 'feature-verification');
178
- const vars = selected.workflow.vars as { verificationCmd?: unknown } | undefined;
179
- const configuredCmd =
180
- typeof vars?.verificationCmd === 'string' && vars.verificationCmd.length > 0
181
- ? vars.verificationCmd
182
- : 'bun run spur-check-feature';
183
- const effectiveCmd = cmdOverride !== '' ? cmdOverride : configuredCmd;
184
-
185
- const featureFile = findFeatureFile(join(cwd, 'docs', 'features'), featureId);
186
- if (featureFile === undefined) {
187
- throw new Error(`feature ${featureId} not found under ${join(cwd, 'docs', 'features')}`);
188
- }
189
- const featureContent = readFileSync(featureFile, 'utf8');
190
- const learningsPath = join(cwd, '.spur', 'context', 'learnings.md');
191
- const learningsContent = existsSync(learningsPath) ? readFileSync(learningsPath, 'utf8') : undefined;
192
-
193
- // 2. Before digest + RUNNING receipt (both copies) + artifact registration.
194
- const beforeDigest = await mod.captureFeatureReceiptDigest(cwd, featureContent, learningsContent);
195
- const receipt = await mod.startFeatureVerificationReceipt(nodeFsShim, runDir, {
196
- featureId,
197
- runId,
198
- workdir: cwd,
199
- verifier: {
200
- name: 'feature-verification',
201
- sourcePath: selected.path,
202
- layer: selected.layer,
203
- definitionDigest: selected.digest,
204
- },
205
- verificationCmd: effectiveCmd,
206
- inputDigest: beforeDigest,
207
- });
208
- const db = await mod.openInlineRunProjectDb(cwd);
209
- try {
210
- await new mod.ArtifactDao(db.adapter as never).record({
211
- runId,
212
- path: join(runDir, `${runId}-feature-verification.json`),
213
- kind: 'feature-verification',
214
- });
215
- } finally {
216
- db.close();
217
- }
218
-
219
- // 3. Run the effective command via the safe splitter (no `sh -c`).
220
- const logPath = join(runDir, `${runId}-feature-verification.log`);
221
- const launch = mod.splitLaunchCommand(effectiveCmd, 'feature-verification verificationCmd');
222
- if ('error' in launch) {
223
- await mod.completeFeatureVerificationReceipt(nodeFsShim, runDir, receipt, {
224
- status: 'FAIL',
225
- inputDigest: beforeDigest,
226
- });
227
- console.log(`feature-verification-steps: ${featureId} verification FAIL (${launch.error})`);
228
- return;
229
- }
230
- const logFd = openSync(logPath, 'a');
231
- try {
232
- const result = spawnSync(launch.command, launch.leadingArgs, {
233
- cwd,
234
- stdio: ['ignore', logFd, logFd],
235
- timeout: 4 * 60 * 60 * 1000,
236
- });
237
- const exit = result.status ?? 1;
238
-
239
- // 4/5. After digest — a mismatch records FAIL (the pass did not verify
240
- // the tree it left behind); otherwise the exit code decides.
241
- const afterDigest = await mod.captureFeatureReceiptDigest(cwd, featureContent, learningsContent);
242
- const status: 'PASS' | 'FAIL' = exit === 0 && afterDigest === beforeDigest ? 'PASS' : 'FAIL';
243
- await mod.completeFeatureVerificationReceipt(nodeFsShim, runDir, receipt, { status, inputDigest: afterDigest });
244
- console.log(`feature-verification-steps: ${featureId} verification ${status} (run ${runId}, log ${logPath})`);
245
- } finally {
246
- closeSync(logFd);
247
- }
248
- }
249
-
250
- function main(): void {
251
- const args = process.argv.slice(2);
252
- const command = args[0];
253
- const flag = (name: string): string => {
254
- const i = args.indexOf(name);
255
- return i >= 0 && i + 1 < args.length ? (args[i + 1] ?? '') : '';
256
- };
257
- if (command !== 'verify') {
258
- console.error('Usage: feature-verification-steps.ts verify --feature-id <id> --run-id <id> [--cmd <command>]');
259
- process.exit(2);
260
- }
261
- verify(
262
- flag('--feature-id') || getEnvVar('featureId') || '',
263
- flag('--run-id') || getEnvVar('__runId') || '',
264
- flag('--cmd') || getEnvVar('verificationCmd') || '',
265
- flag('--spur-bin') || getEnvVar('spurBin') || '',
266
- resolveModuleMode(flag('--module-mode')),
267
- )
268
- .then(() => process.exit(0))
269
- .catch((err: unknown) => {
270
- console.error(`feature-verification-steps: ${String(err)}`);
271
- process.exit(1);
272
- });
273
- }
274
-
275
- main();