inkdrift 0.1.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 (107) hide show
  1. package/.env.example +23 -0
  2. package/README.md +119 -0
  3. package/dist/index-once.d.ts +8 -0
  4. package/dist/index-once.d.ts.map +1 -0
  5. package/dist/index-once.js +45 -0
  6. package/dist/index-once.js.map +1 -0
  7. package/dist/index.d.ts +9 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +72 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/modules/bot/index.d.ts +11 -0
  12. package/dist/modules/bot/index.d.ts.map +1 -0
  13. package/dist/modules/bot/index.js +60 -0
  14. package/dist/modules/bot/index.js.map +1 -0
  15. package/dist/modules/bot/test.d.ts +13 -0
  16. package/dist/modules/bot/test.d.ts.map +1 -0
  17. package/dist/modules/bot/test.js +37 -0
  18. package/dist/modules/bot/test.js.map +1 -0
  19. package/dist/modules/distiller/index.d.ts +24 -0
  20. package/dist/modules/distiller/index.d.ts.map +1 -0
  21. package/dist/modules/distiller/index.js +124 -0
  22. package/dist/modules/distiller/index.js.map +1 -0
  23. package/dist/modules/distiller/test.d.ts +10 -0
  24. package/dist/modules/distiller/test.d.ts.map +1 -0
  25. package/dist/modules/distiller/test.js +92 -0
  26. package/dist/modules/distiller/test.js.map +1 -0
  27. package/dist/modules/extractor/index.d.ts +52 -0
  28. package/dist/modules/extractor/index.d.ts.map +1 -0
  29. package/dist/modules/extractor/index.js +114 -0
  30. package/dist/modules/extractor/index.js.map +1 -0
  31. package/dist/modules/extractor/test.d.ts +10 -0
  32. package/dist/modules/extractor/test.d.ts.map +1 -0
  33. package/dist/modules/extractor/test.js +80 -0
  34. package/dist/modules/extractor/test.js.map +1 -0
  35. package/dist/modules/fetcher/index.d.ts +2 -0
  36. package/dist/modules/fetcher/index.d.ts.map +1 -0
  37. package/dist/modules/fetcher/index.js +3 -0
  38. package/dist/modules/fetcher/index.js.map +1 -0
  39. package/dist/modules/fetcher/test.d.ts +2 -0
  40. package/dist/modules/fetcher/test.d.ts.map +1 -0
  41. package/dist/modules/fetcher/test.js +3 -0
  42. package/dist/modules/fetcher/test.js.map +1 -0
  43. package/dist/modules/flowus-source/index.d.ts +55 -0
  44. package/dist/modules/flowus-source/index.d.ts.map +1 -0
  45. package/dist/modules/flowus-source/index.js +195 -0
  46. package/dist/modules/flowus-source/index.js.map +1 -0
  47. package/dist/modules/flowus-source/test.d.ts +14 -0
  48. package/dist/modules/flowus-source/test.d.ts.map +1 -0
  49. package/dist/modules/flowus-source/test.js +63 -0
  50. package/dist/modules/flowus-source/test.js.map +1 -0
  51. package/dist/modules/flowus-source/types.d.ts +93 -0
  52. package/dist/modules/flowus-source/types.d.ts.map +1 -0
  53. package/dist/modules/flowus-source/types.js +5 -0
  54. package/dist/modules/flowus-source/types.js.map +1 -0
  55. package/dist/modules/memorizer/index.d.ts +29 -0
  56. package/dist/modules/memorizer/index.d.ts.map +1 -0
  57. package/dist/modules/memorizer/index.js +72 -0
  58. package/dist/modules/memorizer/index.js.map +1 -0
  59. package/dist/modules/memorizer/test.d.ts +10 -0
  60. package/dist/modules/memorizer/test.d.ts.map +1 -0
  61. package/dist/modules/memorizer/test.js +69 -0
  62. package/dist/modules/memorizer/test.js.map +1 -0
  63. package/dist/modules/queue/index.d.ts +45 -0
  64. package/dist/modules/queue/index.d.ts.map +1 -0
  65. package/dist/modules/queue/index.js +161 -0
  66. package/dist/modules/queue/index.js.map +1 -0
  67. package/dist/modules/queue/test.d.ts +2 -0
  68. package/dist/modules/queue/test.d.ts.map +1 -0
  69. package/dist/modules/queue/test.js +3 -0
  70. package/dist/modules/queue/test.js.map +1 -0
  71. package/dist/modules/webhook/index.d.ts +8 -0
  72. package/dist/modules/webhook/index.d.ts.map +1 -0
  73. package/dist/modules/webhook/index.js +8 -0
  74. package/dist/modules/webhook/index.js.map +1 -0
  75. package/dist/modules/webhook/test.d.ts +12 -0
  76. package/dist/modules/webhook/test.d.ts.map +1 -0
  77. package/dist/modules/webhook/test.js +14 -0
  78. package/dist/modules/webhook/test.js.map +1 -0
  79. package/dist/modules/wechat-client/index.d.ts +8 -0
  80. package/dist/modules/wechat-client/index.d.ts.map +1 -0
  81. package/dist/modules/wechat-client/index.js +8 -0
  82. package/dist/modules/wechat-client/index.js.map +1 -0
  83. package/dist/modules/wechat-client/test.d.ts +12 -0
  84. package/dist/modules/wechat-client/test.d.ts.map +1 -0
  85. package/dist/modules/wechat-client/test.js +14 -0
  86. package/dist/modules/wechat-client/test.js.map +1 -0
  87. package/dist/modules/wechat-fetcher/index.d.ts +18 -0
  88. package/dist/modules/wechat-fetcher/index.d.ts.map +1 -0
  89. package/dist/modules/wechat-fetcher/index.js +75 -0
  90. package/dist/modules/wechat-fetcher/index.js.map +1 -0
  91. package/dist/scripts/reset-one.d.ts +6 -0
  92. package/dist/scripts/reset-one.d.ts.map +1 -0
  93. package/dist/scripts/reset-one.js +40 -0
  94. package/dist/scripts/reset-one.js.map +1 -0
  95. package/dist/utils/config.d.ts +24 -0
  96. package/dist/utils/config.d.ts.map +1 -0
  97. package/dist/utils/config.js +35 -0
  98. package/dist/utils/config.js.map +1 -0
  99. package/dist/utils/logger.d.ts +2 -0
  100. package/dist/utils/logger.d.ts.map +1 -0
  101. package/dist/utils/logger.js +3 -0
  102. package/dist/utils/logger.js.map +1 -0
  103. package/dist/web/server.d.ts +2 -0
  104. package/dist/web/server.d.ts.map +1 -0
  105. package/dist/web/server.js +3 -0
  106. package/dist/web/server.js.map +1 -0
  107. package/package.json +61 -0
@@ -0,0 +1,92 @@
1
+ /**
2
+ * distiller module standalone test
3
+ *
4
+ * Usage: npx tsx src/modules/distiller/test.ts
5
+ *
6
+ * Reads a real article from FlowUs, extracts content, sends to LLM,
7
+ * prints distilled knowledge points.
8
+ */
9
+ import '../../utils/config.js';
10
+ import { config } from '../../utils/config.js';
11
+ import { FlowUsClient } from '../flowus-source/index.js';
12
+ import { extract } from '../extractor/index.js';
13
+ import { distill } from './index.js';
14
+ const { flowus, glm } = config;
15
+ if (!flowus.token || !flowus.databaseId) {
16
+ console.error('Missing FLOWUS_TOKEN or FLOWUS_DATABASE_ID in .env');
17
+ process.exit(1);
18
+ }
19
+ if (!glm.apiKey) {
20
+ console.error('Missing GLM_API_KEY in .env');
21
+ process.exit(1);
22
+ }
23
+ const client = new FlowUsClient({
24
+ baseUrl: flowus.baseUrl,
25
+ token: flowus.token,
26
+ databaseId: flowus.databaseId,
27
+ });
28
+ console.log('=== distiller module test ===\n');
29
+ // Step 1: Get one article from FlowUs
30
+ console.log('[1] Fetching article from FlowUs...');
31
+ const pages = await client.queryNewArticles();
32
+ if (pages.length === 0) {
33
+ console.log(' No articles found. Nothing to distill.');
34
+ process.exit(0);
35
+ }
36
+ console.log(` Found ${pages.length} article(s), using first one.\n`);
37
+ const page = pages[0];
38
+ const article = await client.getFullArticle(page);
39
+ console.log(` Title: ${article.title}`);
40
+ console.log(` URL: ${article.url}`);
41
+ console.log(` Raw content length: ${article.content.length} chars\n`);
42
+ // Step 2: Extract (clean)
43
+ console.log('[2] Running extractor...');
44
+ const extracted = extract(article.content);
45
+ console.log(` Cleaned length: ${extracted.markdown.length} chars`);
46
+ console.log(` Word count: ${extracted.wordCount}\n`);
47
+ // Step 3: Distill with LLM
48
+ console.log('[3] Calling LLM for knowledge distillation...');
49
+ console.log(` Model: ${glm.model}\n`);
50
+ const knowledgePoints = await distill(extracted.markdown, article.url, {
51
+ baseUrl: glm.baseUrl,
52
+ apiKey: glm.apiKey,
53
+ model: glm.model,
54
+ });
55
+ console.log(` Extracted ${knowledgePoints.length} knowledge point(s)\n`);
56
+ if (knowledgePoints.length === 0) {
57
+ console.log(' No knowledge points (article may have no substance).');
58
+ process.exit(0);
59
+ }
60
+ // Step 4: Print knowledge points
61
+ console.log('[4] Knowledge points:');
62
+ for (let i = 0; i < knowledgePoints.length; i++) {
63
+ const kp = knowledgePoints[i];
64
+ console.log(`\n --- KP ${i + 1} ---`);
65
+ console.log(` Title: ${kp.title}`);
66
+ console.log(` Content: ${kp.content.substring(0, 150)}...`);
67
+ console.log(` Tags: ${kp.tags.join(', ')}`);
68
+ console.log(` Importance: ${kp.importance}`);
69
+ }
70
+ // Step 5: Validate
71
+ console.log('\n[5] Validating...');
72
+ const checks = [];
73
+ for (const kp of knowledgePoints) {
74
+ if (!kp.content.includes(article.url)) {
75
+ checks.push(`FAIL: "${kp.title}" missing source URL`);
76
+ }
77
+ if (kp.tags.length < 2 || kp.tags.length > 5) {
78
+ checks.push(`FAIL: "${kp.title}" tags count ${kp.tags.length}`);
79
+ }
80
+ if (kp.importance < 0 || kp.importance > 1) {
81
+ checks.push(`FAIL: "${kp.title}" importance out of range`);
82
+ }
83
+ }
84
+ if (checks.length === 0) {
85
+ console.log(' PASS: All knowledge points valid');
86
+ }
87
+ else {
88
+ for (const c of checks)
89
+ console.log(` ${c}`);
90
+ }
91
+ console.log('\n=== Test complete ===');
92
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../../src/modules/distiller/test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;AAE/B,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACxC,OAAO,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC,GAAG,CAAC,M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-0,0 +1,52 @@
1
+ /**
2
+ * extractor module
3
+ *
4
+ * Receives Markdown from flowus-source, cleans it up,
5
+ * extracts metadata (summary, word count), and splits into sections.
6
+ *
7
+ * Pure text processing, no external dependencies.
8
+ */
9
+ export interface Section {
10
+ heading: string;
11
+ content: string;
12
+ }
13
+ export interface ExtractedContent {
14
+ markdown: string;
15
+ summary: string;
16
+ wordCount: number;
17
+ sections: Section[];
18
+ }
19
+ /**
20
+ * Detect if content is a FlowUs capture failure placeholder.
21
+ * Returns true if the content contains known placeholder patterns
22
+ * AND is short (under 500 chars), indicating FlowUs couldn't fetch the real content.
23
+ */
24
+ export declare function isPlaceholderContent(content: string): boolean;
25
+ /**
26
+ * Extract the first URL from content (for placeholder articles,
27
+ * this is typically the original WeChat article link).
28
+ */
29
+ export declare function extractUrl(content: string): string | null;
30
+ /**
31
+ * Clean Markdown: merge blank lines, trim whitespace, remove blank-only lines.
32
+ * Preserves code blocks, lists, and other formatting.
33
+ */
34
+ export declare function cleanMarkdown(md: string): string;
35
+ /**
36
+ * Extract metadata: summary (first 200 chars of body text) and word count.
37
+ * Word count excludes headings and blank lines.
38
+ */
39
+ export declare function extractMetadata(md: string): {
40
+ summary: string;
41
+ wordCount: number;
42
+ };
43
+ /**
44
+ * Split Markdown into sections by headings (# ~ ###).
45
+ * The first section has an empty heading if content precedes the first heading.
46
+ */
47
+ export declare function splitSections(md: string): Section[];
48
+ /**
49
+ * One-shot: clean + extract metadata + split sections.
50
+ */
51
+ export declare function extract(md: string): ExtractedContent;
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/extractor/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAWD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAI7D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGzD;AAID;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAsBhD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAUlF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,EAAE,CA+BnD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,CAMpD"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * extractor module
3
+ *
4
+ * Receives Markdown from flowus-source, cleans it up,
5
+ * extracts metadata (summary, word count), and splits into sections.
6
+ *
7
+ * Pure text processing, no external dependencies.
8
+ */
9
+ // ---- Placeholder detection ----
10
+ const PLACEHOLDER_PATTERNS = [
11
+ '微信安全验证',
12
+ '无法自动获取',
13
+ '请在微信客户端打开',
14
+ '内容无法访问',
15
+ ];
16
+ /**
17
+ * Detect if content is a FlowUs capture failure placeholder.
18
+ * Returns true if the content contains known placeholder patterns
19
+ * AND is short (under 500 chars), indicating FlowUs couldn't fetch the real content.
20
+ */
21
+ export function isPlaceholderContent(content) {
22
+ const trimmed = content.trim();
23
+ if (trimmed.length > 500)
24
+ return false;
25
+ return PLACEHOLDER_PATTERNS.some((p) => trimmed.includes(p));
26
+ }
27
+ /**
28
+ * Extract the first URL from content (for placeholder articles,
29
+ * this is typically the original WeChat article link).
30
+ */
31
+ export function extractUrl(content) {
32
+ const match = content.match(/https?:\/\/[^\s)\]}>]+/);
33
+ return match ? match[0] : null;
34
+ }
35
+ // ---- Public API ----
36
+ /**
37
+ * Clean Markdown: merge blank lines, trim whitespace, remove blank-only lines.
38
+ * Preserves code blocks, lists, and other formatting.
39
+ */
40
+ export function cleanMarkdown(md) {
41
+ const lines = md.split('\n');
42
+ const result = [];
43
+ for (let i = 0; i < lines.length; i++) {
44
+ const trimmed = lines[i].trimEnd();
45
+ // Keep the line as-is (with leading whitespace for indented content)
46
+ // but skip lines that are purely whitespace
47
+ if (trimmed === '' && result.length > 0 && result[result.length - 1] === '') {
48
+ continue; // skip consecutive blank lines
49
+ }
50
+ result.push(trimmed);
51
+ }
52
+ // Trim trailing blank lines
53
+ while (result.length > 0 && result[result.length - 1] === '') {
54
+ result.pop();
55
+ }
56
+ return result.join('\n');
57
+ }
58
+ /**
59
+ * Extract metadata: summary (first 200 chars of body text) and word count.
60
+ * Word count excludes headings and blank lines.
61
+ */
62
+ export function extractMetadata(md) {
63
+ const bodyLines = md
64
+ .split('\n')
65
+ .filter((line) => line.trim() !== '' && !line.startsWith('#'));
66
+ const bodyText = bodyLines.join(' ').replace(/\s+/g, ' ').trim();
67
+ const wordCount = bodyText.length;
68
+ const summary = bodyText.substring(0, 200);
69
+ return { summary, wordCount };
70
+ }
71
+ /**
72
+ * Split Markdown into sections by headings (# ~ ###).
73
+ * The first section has an empty heading if content precedes the first heading.
74
+ */
75
+ export function splitSections(md) {
76
+ const lines = md.split('\n');
77
+ const sections = [];
78
+ let currentHeading = '';
79
+ let currentLines = [];
80
+ for (const line of lines) {
81
+ if (/^#{1,3}\s/.test(line)) {
82
+ // Flush current section
83
+ if (currentLines.length > 0 || currentHeading !== '') {
84
+ sections.push({
85
+ heading: currentHeading,
86
+ content: currentLines.join('\n').trim(),
87
+ });
88
+ }
89
+ currentHeading = line.replace(/^#+\s*/, '').trim();
90
+ currentLines = [];
91
+ }
92
+ else {
93
+ currentLines.push(line);
94
+ }
95
+ }
96
+ // Flush last section
97
+ if (currentLines.length > 0 || currentHeading !== '') {
98
+ sections.push({
99
+ heading: currentHeading,
100
+ content: currentLines.join('\n').trim(),
101
+ });
102
+ }
103
+ return sections;
104
+ }
105
+ /**
106
+ * One-shot: clean + extract metadata + split sections.
107
+ */
108
+ export function extract(md) {
109
+ const markdown = cleanMarkdown(md);
110
+ const { summary, wordCount } = extractMetadata(markdown);
111
+ const sections = splitSections(markdown);
112
+ return { markdown, summary, wordCount, sections };
113
+ }
114
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/extractor/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,kCAAkC;AAElC,MAAM,oBAAoB,GAAG;IAC3B,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,QAAQ;CACT,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IACvC,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACtD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,uBAAuB;AAEvB;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,M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Aa,CAAC,EAAE,CAAC,CAAC;IACnC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAEzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AACpD,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * extractor module standalone test
3
+ *
4
+ * Usage: npx tsx src/modules/extractor/test.ts
5
+ *
6
+ * Reads a real article from FlowUs, passes through extractor,
7
+ * prints cleaned result, summary, word count, sections.
8
+ */
9
+ import '../../utils/config.js';
10
+ //# sourceMappingURL=test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../src/modules/extractor/test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,uBAAuB,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * extractor module standalone test
3
+ *
4
+ * Usage: npx tsx src/modules/extractor/test.ts
5
+ *
6
+ * Reads a real article from FlowUs, passes through extractor,
7
+ * prints cleaned result, summary, word count, sections.
8
+ */
9
+ import '../../utils/config.js';
10
+ import { config } from '../../utils/config.js';
11
+ import { FlowUsClient } from '../flowus-source/index.js';
12
+ import { extract } from './index.js';
13
+ const { token, databaseId, baseUrl } = config.flowus;
14
+ if (!token || !databaseId) {
15
+ console.error('Missing FLOWUS_TOKEN or FLOWUS_DATABASE_ID in .env');
16
+ process.exit(1);
17
+ }
18
+ const client = new FlowUsClient({ baseUrl, token, databaseId });
19
+ console.log('=== extractor module test ===\n');
20
+ // Step 1: Get one article from FlowUs
21
+ console.log('[1] Fetching articles from FlowUs...');
22
+ const pages = await client.queryNewArticles();
23
+ if (pages.length === 0) {
24
+ console.log(' No articles found. Test passed (nothing to extract).');
25
+ process.exit(0);
26
+ }
27
+ console.log(` Found ${pages.length} article(s), using first one.\n`);
28
+ const page = pages[0];
29
+ const article = await client.getFullArticle(page);
30
+ console.log(` Title: ${article.title}`);
31
+ console.log(` Raw content length: ${article.content.length} chars\n`);
32
+ // Step 2: Extract
33
+ console.log('[2] Running extract()...');
34
+ const result = extract(article.content);
35
+ console.log(` Cleaned length: ${result.markdown.length} chars`);
36
+ console.log(` Word count: ${result.wordCount}`);
37
+ console.log(` Summary (${result.summary.length} chars):`);
38
+ console.log(` ${result.summary.substring(0, 120)}...`);
39
+ console.log(` Sections: ${result.sections.length}`);
40
+ for (const s of result.sections.slice(0, 5)) {
41
+ const label = s.heading || '(preamble)';
42
+ console.log(` - "${label}" (${s.content.length} chars)`);
43
+ }
44
+ if (result.sections.length > 5) {
45
+ console.log(` ... and ${result.sections.length - 5} more`);
46
+ }
47
+ // Step 3: Show cleaned content preview
48
+ console.log('\n[3] Cleaned content preview (first 500 chars):');
49
+ console.log('---');
50
+ console.log(result.markdown.substring(0, 500));
51
+ console.log('---');
52
+ // Step 4: Verify basic clean rules
53
+ console.log('\n[4] Verifying clean rules...');
54
+ const checks = [];
55
+ // No consecutive blank lines
56
+ if (!/\n\n\n/.test(result.markdown)) {
57
+ checks.push('PASS: No consecutive blank lines');
58
+ }
59
+ else {
60
+ checks.push('FAIL: Found consecutive blank lines');
61
+ }
62
+ // No trailing whitespace per line
63
+ const trailingWs = result.markdown.split('\n').filter((l) => l !== l.trimEnd());
64
+ if (trailingWs.length === 0) {
65
+ checks.push('PASS: No trailing whitespace');
66
+ }
67
+ else {
68
+ checks.push(`FAIL: ${trailingWs.length} lines with trailing whitespace`);
69
+ }
70
+ // No leading/trailing blank lines
71
+ if (result.markdown === result.markdown.trim()) {
72
+ checks.push('PASS: No leading/trailing blank lines');
73
+ }
74
+ else {
75
+ checks.push('FAIL: Has leading or trailing blank lines');
76
+ }
77
+ for (const c of checks)
78
+ console.log(` ${c}`);
79
+ console.log('\n=== Test complete ===');
80
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
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AEhD,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/fetcher/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export {};
2
+ // fetcher module - article fetching
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/fetcher/index.ts"],"names":[],"mappings":";AAAA,oCAAoC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../src/modules/fetcher/test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export {};
2
+ // fetcher module - standalone test entry
3
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../../src/modules/fetcher/test.ts"],"names":[],"mappings":";AAAA,yCAAyC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * flowus-source module
3
+ *
4
+ * FlowUs API client for reading articles from a multi-dimensional table.
5
+ * Replaces the wechaty bot as the article source in Phase 1.
6
+ */
7
+ import type { FlowUsConfig, FlowUsPage, FlowUsBlock, FlowUsArticle } from './types.js';
8
+ export declare class FlowUsClient {
9
+ private baseUrl;
10
+ private token;
11
+ private databaseId;
12
+ private headers;
13
+ constructor(config: FlowUsConfig);
14
+ /**
15
+ * Query all unprocessed articles from the database.
16
+ * Returns articles where "处理状态" is empty or "未处理".
17
+ */
18
+ queryNewArticles(): Promise<FlowUsPage[]>;
19
+ /**
20
+ * Read article content (all child blocks) and return as plain text/Markdown.
21
+ */
22
+ getArticleContent(pageId: string): Promise<string>;
23
+ /**
24
+ * Fetch all blocks for a page (raw, for inspection/testing).
25
+ */
26
+ getBlocks(pageId: string): Promise<FlowUsBlock[]>;
27
+ /**
28
+ * Mark an article as "处理中".
29
+ */
30
+ markProcessing(pageId: string): Promise<void>;
31
+ /**
32
+ * Mark an article as "已完成".
33
+ */
34
+ markAsProcessed(pageId: string): Promise<void>;
35
+ /**
36
+ * Mark an article as "失败".
37
+ */
38
+ markAsFailed(pageId: string, error?: string): Promise<void>;
39
+ private setStatus;
40
+ /**
41
+ * Convenience: get a full article with content from a page record.
42
+ */
43
+ getFullArticle(page: FlowUsPage): Promise<FlowUsArticle>;
44
+ /**
45
+ * Recursively fetch all blocks for a page, including nested children.
46
+ */
47
+ private fetchAllBlocks;
48
+ /**
49
+ * Convert a single block to Markdown string.
50
+ * FlowUs uses block.data (unlike Notion's block[block.type]).
51
+ */
52
+ private blockToMarkdown;
53
+ }
54
+ export type { FlowUsConfig, FlowUsPage, FlowUsBlock, FlowUsBlockData, FlowUsArticle } from './types.js';
55
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/flowus-source/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,WAAW,EACX,aAAa,EAGd,MAAM,YAAY,CAAC;AAMpB,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAyB;gBAE5B,MAAM,EAAE,YAAY;IAUhC;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IA+B/C;;OAEG;IACG,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKxD;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAIvD;;OAEG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD;;OAEG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpD;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAInD,SAAS;IAgBvB;;OAEG;IACG,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IAgC9D;;OAEG;YACW,cAAc;IA8B5B;;;OAGG;IACH,OAAO,CAAC,eAAe;CAuCxB;AAED,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}