@gobing-ai/knowledge-kit 0.0.22 → 0.0.24

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 (76) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +137 -59
  3. package/package.json +4 -4
  4. package/plugins/generations/content-gen/dist/index.js +97 -45
  5. package/plugins/generations/core-facts-gen/dist/index.js +106 -57
  6. package/plugins/generations/daily-article-gen/dist/index.js +105 -56
  7. package/plugins/generations/dailynews-gen/dist/index.js +235 -57
  8. package/plugins/generations/dailynews-gen/src/index.ts +67 -2
  9. package/plugins/generations/dailynews-gen/src/script-builder.ts +36 -15
  10. package/plugins/generations/dailynews-gen/src/script-plan.ts +142 -0
  11. package/plugins/generations/episode-plan-gen/dist/index.js +115 -66
  12. package/plugins/generations/gemini-tts/README.md +125 -0
  13. package/plugins/generations/gemini-tts/dist/index.js +23348 -0
  14. package/plugins/generations/gemini-tts/package.json +16 -0
  15. package/plugins/generations/gemini-tts/plugin.json +6 -0
  16. package/plugins/generations/gemini-tts/profiles.json +3 -0
  17. package/plugins/generations/gemini-tts/src/gemini-client.ts +220 -0
  18. package/plugins/generations/gemini-tts/src/index.ts +33 -0
  19. package/plugins/generations/gemini-tts/src/voice-create.ts +180 -0
  20. package/plugins/generations/gemini-tts/tsconfig.json +8 -0
  21. package/plugins/generations/image-gen/dist/index.js +338 -117
  22. package/plugins/generations/image-gen/presets/formats/daily-news-cover.yaml +19 -0
  23. package/plugins/generations/image-gen/presets/formats/xhs-card.yaml +55 -0
  24. package/plugins/generations/image-gen/presets/styles/daily-news.yaml +9 -0
  25. package/plugins/generations/image-gen/presets/styles/xhs-knowledge.yaml +7 -0
  26. package/plugins/generations/image-gen/src/index.ts +148 -14
  27. package/plugins/generations/image-gen/src/job.ts +30 -0
  28. package/plugins/generations/image-gen/src/providers/errors.ts +91 -0
  29. package/plugins/generations/image-gen/src/providers/types.ts +79 -0
  30. package/plugins/generations/news-report-gen/dist/index.js +136 -55
  31. package/plugins/generations/news-report-gen/src/index.ts +57 -1
  32. package/plugins/generations/voice-gen/dist/index.js +121 -69
  33. package/plugins/generations/voice-gen/package.json +3 -0
  34. package/plugins/generations/voice-gen/src/index.ts +2 -1
  35. package/plugins/generations/voice-gen/src/voicebox-client.ts +2 -1
  36. package/plugins/ingestions/aihot-ingest/dist/index.js +103 -53
  37. package/plugins/ingestions/horizon-ingest/dist/index.js +102 -53
  38. package/plugins/ingestions/karakeep-local/dist/index.js +273 -224
  39. package/plugins/ingestions/last30days-ingest/dist/index.js +97 -48
  40. package/plugins/ingestions/web-search/dist/index.js +121 -72
  41. package/plugins/kk/config.example.yaml +13 -0
  42. package/plugins/kk/plugin.json +1 -1
  43. package/plugins/kk/scripts/daily-voice-style.zh.md +52 -0
  44. package/plugins/kk/scripts/kk-workflow-stages.ts +438 -17
  45. package/plugins/kk/skills/publish/SKILL.md +24 -1
  46. package/plugins/kk/skills/xhs-images/SKILL.md +89 -0
  47. package/plugins/kk/skills/xhs-images/references/card-layouts.md +35 -0
  48. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +164 -13
  49. package/plugins/publishings/emdash-pub/dist/index.js +94 -45
  50. package/plugins/publishings/infoq-pub/dist/index.js +94 -45
  51. package/plugins/publishings/juejin-pub/dist/index.js +94 -45
  52. package/plugins/publishings/medium-pub/dist/index.js +94 -45
  53. package/plugins/publishings/podcast-pub/dist/index.js +115 -55
  54. package/plugins/publishings/podcast-pub/src/map.ts +30 -10
  55. package/plugins/publishings/podcast-pub/src/show-notes.ts +6 -1
  56. package/plugins/publishings/qiita-pub/dist/index.js +94 -45
  57. package/plugins/publishings/substack-pub/dist/index.js +94 -45
  58. package/plugins/publishings/surfdash-pub/dist/index.js +99 -63
  59. package/plugins/publishings/surfdash-pub/src/index.ts +10 -1
  60. package/plugins/publishings/wechatmp-pub/dist/index.js +94 -45
  61. package/plugins/publishings/x-pub/dist/index.js +94 -45
  62. package/plugins/publishings/xhs-pub/dist/index.js +8908 -229
  63. package/plugins/publishings/xhs-pub/package.json +1 -0
  64. package/plugins/publishings/xhs-pub/plugin.json +1 -1
  65. package/plugins/publishings/xhs-pub/src/automation-guard.ts +128 -0
  66. package/plugins/publishings/xhs-pub/src/index.ts +753 -24
  67. package/plugins/publishings/xhs-pub/src/profile-check.ts +133 -0
  68. package/plugins/publishings/zenn-pub/dist/index.js +94 -45
  69. package/plugins/sp/lib/env.ts +46 -0
  70. package/plugins/sp/lib/inline-run.generated.mjs +1489 -0
  71. package/plugins/sp/scripts/feature-verification-steps.ts +275 -0
  72. package/plugins/sp/scripts/inline-run-setup.ts +571 -47
  73. package/plugins/sp/scripts/wrapup-drift-probe.mjs +190 -0
  74. package/plugins/sp/scripts/wrapup-drift-probe.ts +258 -0
  75. package/plugins/sp/scripts/wrapup-steps.mjs +77 -6
  76. package/plugins/sp/scripts/wrapup-steps.ts +91 -5
@@ -3,12 +3,13 @@
3
3
  * wrapup-steps — deterministic wrap-up capture, metrics and feature sync behind the
4
4
  * wrapup-pipeline wrappers (task 0824, feature I21, governance §1.2 composition budgets).
5
5
  *
6
- * Reproduces the former wrapup-pipeline `task-resolve:onEnter:0`, `metrics-record:onEnter:0`
7
- * and `feature-transition:onEnter:0` shell programs one-for-one so the workflow stays inside
6
+ * Reproduces the former wrapup-pipeline `task-resolve:onEnter:0`, `task-resolve:onEnter:1`
7
+ * (route-reason writer, moved here in 0944), `metrics-record:onEnter:0` and
8
+ * `feature-transition:onEnter:0` shell programs one-for-one so the workflow stays inside
8
9
  * the shell-program caps while writing the same `.spur/run` artifacts:
9
10
  * - `<runId>-wrapup-tasks.json` normalized, deduplicated WBS capture (resolve)
10
11
  * - `<runId>-wrapup-resolve.status` `PASS`/`FAIL` (resolve)
11
- * - `<runId>-route-reason.txt` route reason (written by the workflow route writer)
12
+ * - `<runId>-route-reason.txt` route reason (route-reason subcommand)
12
13
  * - `.spur/memory/wrapup-metrics.jsonl` one row per task (metrics)
13
14
  * - `<runId>-wrapup-metrics.status` `PASS`/`FAIL` (metrics)
14
15
  * - `<runId>-wrapup-sync.status` `PASS`/`FAIL` (feature-transition)
@@ -31,6 +32,7 @@
31
32
  import { spawnSync } from 'node:child_process';
32
33
  import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
33
34
  import { join } from 'node:path';
35
+ import { getEnvVars } from '../lib/env';
34
36
 
35
37
  export interface WrapupStepsEnv {
36
38
  __runId?: string;
@@ -184,6 +186,89 @@ export function resolveTasks(env: WrapupStepsEnv, options: WrapupStepsOptions =
184
186
  return { status: 'PASS', statusFile: relStatusFile, tasksFile: relTasksFile, exitCode: 0 };
185
187
  }
186
188
 
189
+ /**
190
+ * 0944 R3 route-reason map — mirrors the former inline jq object one-for-one, plus the
191
+ * `safety` entry (operator-forced doc-sync). `fast:drift-probe-clean` is NOT in the map:
192
+ * it is only claimable when the drift probe itself classified the wrapup clean.
193
+ */
194
+ const ROUTE_REASON_TABLE: Record<string, string> = {
195
+ fast: 'fast:evidence complete+consistent',
196
+ '': 'safety:missing evidence (mode empty)',
197
+ unknown: 'safety:unknown evidence quality',
198
+ conflict: 'safety:conflicting evidence',
199
+ safety: 'safety:operator-forced doc-sync',
200
+ };
201
+
202
+ export interface RouteReasonResult {
203
+ reason: string;
204
+ reasonFile: string;
205
+ exitCode: number;
206
+ }
207
+
208
+ /**
209
+ * `route-reason` — derive the task-resolve route reason from the validated capture, the
210
+ * projected mode and the drift probe verdict (0944). A resolve FAIL keeps its own reason
211
+ * (nothing is written, exit 0). A missing or corrupted capture never yields a `skipped`
212
+ * or `fast:drift-probe-clean` claim. The log line is run-attributed (0770).
213
+ */
214
+ export function writeRouteReason(env: WrapupStepsEnv, options: WrapupStepsOptions = {}): RouteReasonResult {
215
+ const cwd = options.cwd;
216
+ const runId = env.__runId ?? '';
217
+ if (runId.length === 0) {
218
+ process.stderr.write('task-resolve: __runId is empty — refusing to write a route reason\n');
219
+ return { reason: '', reasonFile: '', exitCode: 1 };
220
+ }
221
+ mkdirSync(cwd ? join(cwd, '.spur', 'run') : join('.spur', 'run'), { recursive: true });
222
+ mkdirSync(cwd ? join(cwd, '.spur', 'memory') : join('.spur', 'memory'), { recursive: true });
223
+ const relReasonFile = join('.spur', 'run', `${runId}-route-reason.txt`);
224
+ const abs = (p: string): string => (cwd ? join(cwd, p) : p);
225
+
226
+ const statusFile = join('.spur', 'run', `${runId}-wrapup-resolve.status`);
227
+ if (readFileSyncSafe(abs(statusFile))?.trim() === 'FAIL') {
228
+ // The failed reason stands; the failed edge already owns the run.
229
+ return { reason: '', reasonFile: relReasonFile, exitCode: 0 };
230
+ }
231
+
232
+ // A missing/corrupted capture stays at -1: never 0, so no skipped claim can be invented.
233
+ let taskCount = -1;
234
+ try {
235
+ const parsed: unknown = JSON.parse(
236
+ readFileSync(abs(join('.spur', 'run', `${runId}-wrapup-tasks.json`)), 'utf8'),
237
+ );
238
+ if (Array.isArray(parsed)) taskCount = parsed.length;
239
+ } catch {
240
+ // treated as uncountable below
241
+ }
242
+ let probeClean = false;
243
+ try {
244
+ const probe: unknown = JSON.parse(readFileSync(abs(join('.spur', 'run', `${runId}-drift-probe.json`)), 'utf8'));
245
+ probeClean = (probe as { clean?: unknown } | null)?.clean === true;
246
+ } catch {
247
+ // no probe verdict — the map decides
248
+ }
249
+
250
+ const mode = env.mode ?? '';
251
+ let reason: string;
252
+ if (taskCount === 0) {
253
+ reason = 'skipped:empty task list';
254
+ } else if (mode === 'fast' && probeClean) {
255
+ reason = 'fast:drift-probe-clean';
256
+ } else {
257
+ reason = ROUTE_REASON_TABLE[mode] ?? `safety:unrecognized evidence (mode=${mode})`;
258
+ }
259
+ writeFileSync(abs(relReasonFile), `${reason}\n`);
260
+ appendFileSync(abs(join('.spur', 'memory', 'wrapup-routes.log')), `${runId} ${reason}\n`);
261
+ return { reason, reasonFile: relReasonFile, exitCode: 0 };
262
+ }
263
+
264
+ function readFileSyncSafe(path: string): string | null {
265
+ try {
266
+ return readFileSync(path, 'utf8');
267
+ } catch {
268
+ return null;
269
+ }
270
+ }
271
+
187
272
  export interface MetricsResult {
188
273
  status: 'PASS' | 'FAIL';
189
274
  statusFile: string;
@@ -447,11 +532,12 @@ export function runFeatureTransition(env: WrapupStepsEnv, options: WrapupStepsOp
447
532
  }
448
533
 
449
534
  export const WRAPUP_STEPS_USAGE =
450
- 'usage: wrapup-steps.ts <resolve|metrics|feature-transition> (env: __runId, tasks, feature, featureGateCmd, spurBin)';
535
+ 'usage: wrapup-steps.ts <resolve|route-reason|metrics|feature-transition> (env: __runId, tasks, mode, feature, featureGateCmd, spurBin)';
451
536
 
452
- export function main(argv: string[], env: WrapupStepsEnv = process.env, options: WrapupStepsOptions = {}): number {
537
+ export function main(argv: string[], env: WrapupStepsEnv = getEnvVars(), options: WrapupStepsOptions = {}): number {
453
538
  const sub = argv[0];
454
539
  if (sub === 'resolve') return resolveTasks(env, options).exitCode;
540
+ if (sub === 'route-reason') return writeRouteReason(env, options).exitCode;
455
541
  if (sub === 'metrics') {
456
542
  runMetrics(env, options);
457
543
  return 0;