@gobing-ai/knowledge-kit 0.1.10 → 0.1.11

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/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +128 -25
  3. package/package.json +1 -1
  4. package/plugins/kk/plugin.json +1 -1
  5. package/plugins/kk/scripts/daily-scheduled-run.ts +298 -0
  6. package/plugins/kk/scripts/daily-stages.ts +1057 -108
  7. package/plugins/kk/scripts/kk-workflow-stages.ts +76 -10
  8. package/plugins/kk/scripts/safety-artifact-check.ts +235 -0
  9. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +168 -121
  10. package/plugins/kk/workflows/kk-daily-safety.yaml +129 -50
  11. package/plugins/publishings/bilibili-pub/dist/index.js +2 -1
  12. package/plugins/publishings/bilibili-pub/dist/profile-check.js +2 -1
  13. package/plugins/publishings/cnblogs-pub/dist/index.js +2 -1
  14. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +2 -1
  15. package/plugins/publishings/csdn-pub/dist/index.js +2 -1
  16. package/plugins/publishings/csdn-pub/dist/profile-check.js +2 -1
  17. package/plugins/publishings/infoq-pub/dist/index.js +2 -1
  18. package/plugins/publishings/infoq-pub/dist/profile-check.js +2 -1
  19. package/plugins/publishings/jike-pub/dist/index.js +2 -1
  20. package/plugins/publishings/jike-pub/dist/profile-check.js +2 -1
  21. package/plugins/publishings/juejin-pub/dist/index.js +2 -1
  22. package/plugins/publishings/juejin-pub/dist/profile-check.js +2 -1
  23. package/plugins/publishings/podcast-pub/dist/index.js +46 -8
  24. package/plugins/publishings/podcast-pub/src/index.ts +62 -5
  25. package/plugins/publishings/shipinhao-pub/dist/index.js +2 -1
  26. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +2 -1
  27. package/plugins/publishings/sspai-pub/dist/index.js +2 -1
  28. package/plugins/publishings/sspai-pub/dist/profile-check.js +2 -1
  29. package/plugins/publishings/substack-pub/dist/index.js +2 -1
  30. package/plugins/publishings/substack-pub/dist/profile-check.js +2 -1
  31. package/plugins/publishings/surfdash-pub/dist/index.js +460 -52
  32. package/plugins/publishings/surfdash-pub/src/digest-check.ts +85 -19
  33. package/plugins/publishings/surfdash-pub/src/index.ts +589 -64
  34. package/plugins/publishings/wechatmp-pub/dist/index.js +933 -98
  35. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +60 -3
  36. package/plugins/publishings/wechatmp-pub/src/flow.ts +1125 -85
  37. package/plugins/publishings/wechatmp-pub/src/index.ts +112 -30
  38. package/plugins/publishings/wechatmp-pub/src/page.ts +105 -0
  39. package/plugins/publishings/weibo-pub/dist/index.js +2 -1
  40. package/plugins/publishings/weibo-pub/dist/profile-check.js +2 -1
  41. package/plugins/publishings/x-pub/dist/index.js +2 -1
  42. package/plugins/publishings/x-pub/dist/profile-check.js +2 -1
  43. package/plugins/publishings/xhs-pub/dist/index.js +2 -1
  44. package/plugins/publishings/xhs-pub/dist/profile-check.js +2 -1
  45. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +2 -1
  46. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +2 -1
@@ -1,5 +1,10 @@
1
1
  /**
2
- * Post-refine digest contract check (2026-10-24).
2
+ * Fast offline pre-check for post-refine digest contract (2026-10-24).
3
+ *
4
+ * NOTE: This module is a fast, offline pre-check run before the slower site gate to catch
5
+ * frontmatter shape errors early in-process. The authoritative source of truth is the surfdash
6
+ * site gate (`bun run sd check digest` and `bun run check:content`), which runs in the surfdash
7
+ * checkout before commit+push.
3
8
  *
4
9
  * The surfdash refine step (scripts/lib/seo-digest.ts) owns the daily-digest title, description
5
10
  * and key_points (ADR-008). `requireRefined` only proves refine *ran*; this module re-verifies the
@@ -8,9 +13,9 @@
8
13
  * ellipsis, `label — sentence` key_points) so a regressed derivation fails the publish loud
9
14
  * instead of shipping broken SEO metadata.
10
15
  *
11
- * Pure, line-based frontmatter parsing — no YAML dependency (same stance as
12
- * {@link normalizeLocaleFrontmatter} and the site's own check-digest script). Handles `"..."`,
13
- * `'...'`, plain and `>-`-folded scalars, flow arrays and ` - "..."` block lists.
16
+ * Line-based frontmatter parsing with Bun's stdlib YAML renderer for block scalars (no package
17
+ * dependency; same field compatibility as the site's own check-digest script). Handles `"..."`,
18
+ * `'...'`, plain and folded/literal block scalars, flow arrays and ` - "..."` block lists.
14
19
  */
15
20
  import { SERIES_NAMES } from './patch';
16
21
 
@@ -31,9 +36,65 @@ type FrontmatterValue = string | string[];
31
36
 
32
37
  /** Opening `key:` line: bare key, no leading whitespace (frontmatter is never indented). */
33
38
  const KEY_LINE = /^([A-Za-z_][A-Za-z0-9_-]*):(.*)$/;
39
+ const BLOCK_SCALAR = /^[>|][+-]?$/;
34
40
 
35
41
  const escapeRe = (token: string): string => token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
36
42
 
43
+ /** Number of leading indentation characters; YAML block indentation is spaces in refined posts. */
44
+ function leadingIndent(line: string): number {
45
+ return line.match(/^[ \t]*/)?.[0].length ?? 0;
46
+ }
47
+
48
+ /**
49
+ * Reads one block scalar without allowing a same-indentation sibling list item to become text.
50
+ * Bun's YAML renderer supplies folded/literal and blank-line semantics once the indentation
51
+ * boundary is known. The fallback keeps malformed frontmatter non-fatal, matching the old
52
+ * line parser's permissive behavior.
53
+ */
54
+ function readBlockScalar(
55
+ lines: string[],
56
+ start: number,
57
+ end: number,
58
+ parentIndent: number,
59
+ indicator: string,
60
+ ): { value: string; nextIndex: number } {
61
+ const content: string[] = [];
62
+ let j = start;
63
+ while (j < end) {
64
+ const line = lines[j] ?? '';
65
+ if (line.trim() === '') {
66
+ content.push('');
67
+ j++;
68
+ continue;
69
+ }
70
+ if (leadingIndent(line) <= parentIndent) break;
71
+ content.push(line);
72
+ j++;
73
+ }
74
+ if (content.length === 0) return { value: '', nextIndex: j };
75
+
76
+ const normalized = content.map((line) =>
77
+ line === '' ? '' : line.slice(Math.min(parentIndent, leadingIndent(line))),
78
+ );
79
+ try {
80
+ const parsed = Bun.YAML.parse([`value: ${indicator}`, ...normalized, 'sentinel: null'].join('\n')) as {
81
+ value?: unknown;
82
+ };
83
+ if (typeof parsed.value === 'string') return { value: parsed.value, nextIndex: j };
84
+ } catch {
85
+ // Keep the checker useful for malformed drafts; the contract gate reports the field issue.
86
+ }
87
+ const folded = indicator.startsWith('>');
88
+ const parts: string[] = [];
89
+ for (const line of normalized) {
90
+ if (line !== '') parts.push(line.trim());
91
+ }
92
+ return {
93
+ value: parts.join(folded ? ' ' : '\n'),
94
+ nextIndex: j,
95
+ };
96
+ }
97
+
37
98
  /** Unquotes a YAML scalar: `"…"` via JSON (mapContent writes JSON.stringify), `'…'` with '' unescape. */
38
99
  function unquote(value: string): string {
39
100
  if (value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
@@ -50,7 +111,7 @@ function unquote(value: string): string {
50
111
  }
51
112
 
52
113
  /**
53
- * Line-based frontmatter parse: scalars (plain/quoted/folded) and string lists (block `- item`
114
+ * Line-based frontmatter parse: scalars (plain/quoted/folded/literal) and string lists (block `- item`
54
115
  * or flow `[a, b]`). Unknown shapes degrade to the raw text; a missing frontmatter yields {}.
55
116
  */
56
117
  export function parseFrontmatterScalars(markdown: string): Map<string, FrontmatterValue> {
@@ -66,29 +127,34 @@ export function parseFrontmatterScalars(markdown: string): Map<string, Frontmatt
66
127
  if (!match?.[1] || match[2] === undefined) continue;
67
128
  const key = match[1];
68
129
  const value = match[2].trim();
69
- if (value === '>-' || value === '>' || value === '>+' || value === '|-' || value === '|') {
70
- // Folded scalar: indented continuation lines, joined with spaces (block scalars too —
71
- // descriptions are prose, a stray newline matters less than losing the text).
72
- const parts: string[] = [];
73
- let j = i + 1;
74
- while (j < end) {
75
- const continuation = lines[j];
76
- if (!continuation || !/^[ \t]+\S/.test(continuation)) break;
77
- parts.push(continuation.trim());
78
- j++;
79
- }
80
- out.set(key, parts.join(' '));
81
- i = j - 1;
130
+ if (BLOCK_SCALAR.test(value)) {
131
+ const block = readBlockScalar(lines, i + 1, end, leadingIndent(line), value);
132
+ out.set(key, block.value);
133
+ i = block.nextIndex - 1;
82
134
  continue;
83
135
  }
84
136
  if (value === '') {
85
137
  // Block list: `key:` followed by ` - item` lines; an empty key stays ''.
86
138
  const items: string[] = [];
139
+ let listIndent: number | undefined;
87
140
  let j = i + 1;
88
141
  while (j < end) {
89
142
  const itemLine = lines[j];
90
143
  if (!itemLine || !/^\s*-\s+/.test(itemLine)) break;
91
- items.push(unquote(itemLine.replace(/^\s*-\s+/, '').trim()));
144
+ const itemIndent = leadingIndent(itemLine);
145
+ if (listIndent === undefined) listIndent = itemIndent;
146
+ if (itemIndent !== listIndent) break;
147
+ const raw = itemLine.replace(/^\s*-\s+/, '').trim();
148
+ // Folded item (`- >-`): the refine writer folds long CJK bullets, and a bare
149
+ // ">-" item would fail the " — " separator check downstream — read the
150
+ // indented continuation lines into the item with YAML's block-scalar semantics.
151
+ if (BLOCK_SCALAR.test(raw)) {
152
+ const block = readBlockScalar(lines, j + 1, end, itemIndent, raw);
153
+ items.push(block.value);
154
+ j = block.nextIndex;
155
+ continue;
156
+ }
157
+ items.push(unquote(raw));
92
158
  j++;
93
159
  }
94
160
  if (items.length > 0) {