wikimem 0.8.0 → 0.8.1
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.
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +97 -8
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/core/connectors.d.ts +1 -1
- package/dist/core/connectors.d.ts.map +1 -1
- package/dist/core/git.d.ts +1 -1
- package/dist/core/git.d.ts.map +1 -1
- package/dist/core/git.js.map +1 -1
- package/dist/core/ingest.d.ts.map +1 -1
- package/dist/core/ingest.js +74 -3
- package/dist/core/ingest.js.map +1 -1
- package/dist/core/lint.d.ts.map +1 -1
- package/dist/core/lint.js +23 -4
- package/dist/core/lint.js.map +1 -1
- package/dist/core/oauth-defaults.d.ts +31 -0
- package/dist/core/oauth-defaults.d.ts.map +1 -0
- package/dist/core/oauth-defaults.js +77 -0
- package/dist/core/oauth-defaults.js.map +1 -0
- package/dist/core/observer.d.ts +24 -1
- package/dist/core/observer.d.ts.map +1 -1
- package/dist/core/observer.js +146 -4
- package/dist/core/observer.js.map +1 -1
- package/dist/core/sync/gdrive.d.ts +14 -0
- package/dist/core/sync/gdrive.d.ts.map +1 -0
- package/dist/core/sync/gdrive.js +205 -0
- package/dist/core/sync/gdrive.js.map +1 -0
- package/dist/core/sync/github.d.ts +20 -0
- package/dist/core/sync/github.d.ts.map +1 -0
- package/dist/core/sync/github.js +206 -0
- package/dist/core/sync/github.js.map +1 -0
- package/dist/core/sync/gmail.d.ts +15 -0
- package/dist/core/sync/gmail.d.ts.map +1 -0
- package/dist/core/sync/gmail.js +159 -0
- package/dist/core/sync/gmail.js.map +1 -0
- package/dist/core/sync/index.d.ts +47 -0
- package/dist/core/sync/index.d.ts.map +1 -0
- package/dist/core/sync/index.js +100 -0
- package/dist/core/sync/index.js.map +1 -0
- package/dist/core/sync/jira.d.ts +15 -0
- package/dist/core/sync/jira.d.ts.map +1 -0
- package/dist/core/sync/jira.js +176 -0
- package/dist/core/sync/jira.js.map +1 -0
- package/dist/core/sync/linear.d.ts +15 -0
- package/dist/core/sync/linear.d.ts.map +1 -0
- package/dist/core/sync/linear.js +111 -0
- package/dist/core/sync/linear.js.map +1 -0
- package/dist/core/sync/notion.d.ts +14 -0
- package/dist/core/sync/notion.d.ts.map +1 -0
- package/dist/core/sync/notion.js +168 -0
- package/dist/core/sync/notion.js.map +1 -0
- package/dist/core/sync/rss.d.ts +20 -0
- package/dist/core/sync/rss.d.ts.map +1 -0
- package/dist/core/sync/rss.js +165 -0
- package/dist/core/sync/rss.js.map +1 -0
- package/dist/core/sync/scheduler.d.ts +31 -0
- package/dist/core/sync/scheduler.d.ts.map +1 -0
- package/dist/core/sync/scheduler.js +129 -0
- package/dist/core/sync/scheduler.js.map +1 -0
- package/dist/core/sync/slack.d.ts +16 -0
- package/dist/core/sync/slack.d.ts.map +1 -0
- package/dist/core/sync/slack.js +173 -0
- package/dist/core/sync/slack.js.map +1 -0
- package/dist/core/vault.d.ts +22 -0
- package/dist/core/vault.d.ts.map +1 -1
- package/dist/core/vault.js +65 -0
- package/dist/core/vault.js.map +1 -1
- package/dist/core/webhooks.d.ts +13 -0
- package/dist/core/webhooks.d.ts.map +1 -0
- package/dist/core/webhooks.js +206 -0
- package/dist/core/webhooks.js.map +1 -0
- package/dist/mcp-server.d.ts +11 -6
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +99 -6
- package/dist/mcp-server.js.map +1 -1
- package/dist/mcp-tools-extended.d.ts +15 -0
- package/dist/mcp-tools-extended.d.ts.map +1 -0
- package/dist/mcp-tools-extended.js +277 -0
- package/dist/mcp-tools-extended.js.map +1 -0
- package/dist/processors/csv.d.ts +18 -0
- package/dist/processors/csv.d.ts.map +1 -0
- package/dist/processors/csv.js +230 -0
- package/dist/processors/csv.js.map +1 -0
- package/dist/processors/image.d.ts.map +1 -1
- package/dist/processors/image.js +55 -27
- package/dist/processors/image.js.map +1 -1
- package/dist/processors/pdf.d.ts.map +1 -1
- package/dist/processors/pdf.js +5 -1
- package/dist/processors/pdf.js.map +1 -1
- package/dist/processors/pptx.d.ts +3 -1
- package/dist/processors/pptx.d.ts.map +1 -1
- package/dist/processors/pptx.js +236 -95
- package/dist/processors/pptx.js.map +1 -1
- package/dist/processors/xlsx.d.ts +2 -0
- package/dist/processors/xlsx.d.ts.map +1 -1
- package/dist/processors/xlsx.js +182 -46
- package/dist/processors/xlsx.js.map +1 -1
- package/dist/templates/source-types.d.ts +33 -0
- package/dist/templates/source-types.d.ts.map +1 -0
- package/dist/templates/source-types.js +178 -0
- package/dist/templates/source-types.js.map +1 -0
- package/dist/web/public/index.html +1785 -103
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +746 -38
- package/dist/web/server.js.map +1 -1
- package/package.json +4 -1
- package/src/web/public/index.html +1785 -103
- package/templates/source-types/article.md +21 -0
- package/templates/source-types/book.md +21 -0
- package/templates/source-types/paper.md +23 -0
- package/templates/source-types/podcast.md +21 -0
- package/templates/source-types/raw-notes.md +17 -0
- package/templates/source-types/tweet-thread.md +19 -0
- package/templates/source-types/video.md +21 -0
package/dist/processors/xlsx.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Excel/spreadsheet (.xlsx, .xls) processor.
|
|
3
3
|
* Uses xlsx (SheetJS) for extraction, with a raw XML fallback.
|
|
4
|
+
* Features: multiple sheets as sections, formula result values,
|
|
5
|
+
* bold/italic header detection, cell metadata.
|
|
4
6
|
*/
|
|
5
7
|
import { readFileSync } from 'node:fs';
|
|
6
8
|
import { basename, extname } from 'node:path';
|
|
7
9
|
export async function processXlsx(filePath) {
|
|
8
10
|
const ext = extname(filePath).toLowerCase();
|
|
9
11
|
const title = basename(filePath, ext);
|
|
10
|
-
// Try SheetJS first (best quality), fall back to raw XML
|
|
11
12
|
let content;
|
|
12
13
|
let sheetCount = 0;
|
|
13
14
|
try {
|
|
@@ -32,74 +33,142 @@ export async function processXlsx(filePath) {
|
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
async function extractWithSheetJS(filePath) {
|
|
35
|
-
// Dynamic import — xlsx is an optional dependency
|
|
36
36
|
const XLSX = await import('xlsx');
|
|
37
37
|
const buffer = readFileSync(filePath);
|
|
38
|
-
const workbook = XLSX.read(buffer, {
|
|
38
|
+
const workbook = XLSX.read(buffer, {
|
|
39
|
+
type: 'buffer',
|
|
40
|
+
cellFormula: true,
|
|
41
|
+
cellDates: true,
|
|
42
|
+
cellStyles: true,
|
|
43
|
+
cellNF: true,
|
|
44
|
+
});
|
|
39
45
|
const sections = [];
|
|
40
|
-
|
|
46
|
+
const totalSheets = workbook.SheetNames.length;
|
|
47
|
+
for (let sheetIdx = 0; sheetIdx < totalSheets; sheetIdx++) {
|
|
48
|
+
const sheetName = workbook.SheetNames[sheetIdx];
|
|
49
|
+
if (!sheetName)
|
|
50
|
+
continue;
|
|
41
51
|
const sheet = workbook.Sheets[sheetName];
|
|
42
52
|
if (!sheet)
|
|
43
53
|
continue;
|
|
44
|
-
//
|
|
45
|
-
const
|
|
54
|
+
// Get sheet dimensions
|
|
55
|
+
const ref = sheet['!ref'];
|
|
56
|
+
let rowCount = 0;
|
|
57
|
+
let colCount = 0;
|
|
58
|
+
if (ref) {
|
|
59
|
+
const range = XLSX.utils.decode_range(ref);
|
|
60
|
+
rowCount = range.e.r - range.s.r + 1;
|
|
61
|
+
colCount = range.e.c - range.s.c + 1;
|
|
62
|
+
}
|
|
63
|
+
// Convert sheet to array of arrays (formula results rendered, not formula text)
|
|
64
|
+
const data = XLSX.utils.sheet_to_json(sheet, {
|
|
65
|
+
header: 1,
|
|
66
|
+
rawNumbers: false,
|
|
67
|
+
defval: '',
|
|
68
|
+
});
|
|
46
69
|
if (data.length === 0)
|
|
47
70
|
continue;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
71
|
+
// Analyze cells for formatting and formulas
|
|
72
|
+
const cellInfoMap = analyzeCells(sheet, XLSX);
|
|
73
|
+
const headerRow = detectHeaderRow(data, cellInfoMap, XLSX);
|
|
74
|
+
// Build section header with metadata
|
|
75
|
+
let section = '';
|
|
76
|
+
if (totalSheets > 1) {
|
|
77
|
+
section += `### Sheet ${sheetIdx + 1}: ${sheetName}\n\n`;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
section += `### ${sheetName}\n\n`;
|
|
81
|
+
}
|
|
82
|
+
// Sheet metadata line
|
|
83
|
+
const metaParts = [];
|
|
84
|
+
metaParts.push(`_${rowCount} rows × ${colCount} columns_`);
|
|
85
|
+
const merges = sheet['!merges'];
|
|
86
|
+
if (merges && merges.length > 0) {
|
|
87
|
+
metaParts.push(`_${merges.length} merged region(s)_`);
|
|
88
|
+
}
|
|
89
|
+
const formulaCount = Object.values(cellInfoMap).filter((c) => c.formula).length;
|
|
90
|
+
if (formulaCount > 0) {
|
|
91
|
+
metaParts.push(`_${formulaCount} formula(s)_`);
|
|
51
92
|
}
|
|
93
|
+
section += metaParts.join(' · ') + '\n\n';
|
|
94
|
+
// Build the table with formatting hints
|
|
95
|
+
const table = buildEnhancedTable(data, cellInfoMap, headerRow, XLSX);
|
|
96
|
+
if (table)
|
|
97
|
+
section += table;
|
|
98
|
+
// Formula summary (show formulas alongside their computed values)
|
|
99
|
+
const formulaSummary = buildFormulaSummary(cellInfoMap);
|
|
100
|
+
if (formulaSummary) {
|
|
101
|
+
section += '\n\n' + formulaSummary;
|
|
102
|
+
}
|
|
103
|
+
sections.push(section);
|
|
104
|
+
}
|
|
105
|
+
// Chart info
|
|
106
|
+
const chartInfo = extractChartInfo(workbook);
|
|
107
|
+
if (chartInfo) {
|
|
108
|
+
sections.push(`### Charts\n\n${chartInfo}`);
|
|
52
109
|
}
|
|
53
110
|
return {
|
|
54
111
|
content: sections.join('\n\n---\n\n'),
|
|
55
112
|
sheetCount: workbook.SheetNames.length,
|
|
56
113
|
};
|
|
57
114
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Analyze cells for formatting (bold, italic) and formulas.
|
|
117
|
+
*/
|
|
118
|
+
function analyzeCells(sheet, XLSX) {
|
|
119
|
+
const cellMap = {};
|
|
120
|
+
for (const [key, val] of Object.entries(sheet)) {
|
|
121
|
+
if (key.startsWith('!'))
|
|
122
|
+
continue;
|
|
123
|
+
const cell = val;
|
|
124
|
+
const displayValue = cell.w ?? (cell.v !== null && cell.v !== undefined ? String(cell.v) : '');
|
|
125
|
+
cellMap[key] = {
|
|
126
|
+
address: key,
|
|
127
|
+
value: String(displayValue),
|
|
128
|
+
formula: cell.f ? `=${cell.f}` : undefined,
|
|
129
|
+
isBold: !!(cell.s?.font?.bold),
|
|
130
|
+
isItalic: !!(cell.s?.font?.italic),
|
|
131
|
+
type: cell.t ?? 's',
|
|
132
|
+
};
|
|
70
133
|
}
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
134
|
+
// Suppress unused import warning — XLSX is used by callers for decode
|
|
135
|
+
void XLSX;
|
|
136
|
+
return cellMap;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Detect which row is the header row.
|
|
140
|
+
* Heuristics: first row with all string values, or first row with bold cells.
|
|
141
|
+
*/
|
|
142
|
+
function detectHeaderRow(data, cellInfoMap, XLSX) {
|
|
143
|
+
if (data.length === 0)
|
|
144
|
+
return 0;
|
|
145
|
+
// Check if first row has bold cells
|
|
146
|
+
const firstRow = data[0];
|
|
147
|
+
if (Array.isArray(firstRow)) {
|
|
148
|
+
let boldCount = 0;
|
|
149
|
+
for (let col = 0; col < firstRow.length; col++) {
|
|
150
|
+
const addr = XLSX.utils.encode_cell({ r: 0, c: col });
|
|
151
|
+
if (cellInfoMap[addr]?.isBold)
|
|
152
|
+
boldCount++;
|
|
76
153
|
}
|
|
154
|
+
if (boldCount > 0 && boldCount >= firstRow.length / 2)
|
|
155
|
+
return 0;
|
|
77
156
|
}
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
const sheetCount = sheetMatches ? sheetMatches.length : 1;
|
|
81
|
-
if (textParts.length === 0) {
|
|
82
|
-
return { content: '', sheetCount };
|
|
83
|
-
}
|
|
84
|
-
// Present as a simple list since we can't reconstruct table structure
|
|
85
|
-
const uniqueParts = [...new Set(textParts)].slice(0, 500);
|
|
86
|
-
return {
|
|
87
|
-
content: `**Extracted cell values:**\n\n${uniqueParts.join(' | ')}`,
|
|
88
|
-
sheetCount,
|
|
89
|
-
};
|
|
157
|
+
// Default: first row is header
|
|
158
|
+
return 0;
|
|
90
159
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Build markdown table with formatting hints.
|
|
162
|
+
* Bold cells get **wrapped**, italic cells get _wrapped_.
|
|
163
|
+
*/
|
|
164
|
+
function buildEnhancedTable(data, cellInfoMap, headerRow, XLSX) {
|
|
94
165
|
// Filter out completely empty rows
|
|
95
166
|
const rows = data.filter((row) => Array.isArray(row) && row.some((cell) => cell !== null && cell !== undefined && String(cell).trim() !== ''));
|
|
96
167
|
if (rows.length === 0)
|
|
97
168
|
return '';
|
|
98
|
-
// Determine max columns
|
|
99
169
|
const maxCols = Math.max(...rows.map((row) => (Array.isArray(row) ? row.length : 0)));
|
|
100
170
|
if (maxCols === 0)
|
|
101
171
|
return '';
|
|
102
|
-
// Build markdown table
|
|
103
172
|
const lines = [];
|
|
104
173
|
for (let i = 0; i < Math.min(rows.length, 100); i++) {
|
|
105
174
|
const row = rows[i];
|
|
@@ -108,12 +177,23 @@ function arrayToMarkdownTable(data) {
|
|
|
108
177
|
const cells = [];
|
|
109
178
|
for (let j = 0; j < maxCols; j++) {
|
|
110
179
|
const cell = row[j];
|
|
111
|
-
|
|
180
|
+
let cellStr = cell !== null && cell !== undefined ? String(cell).replace(/\|/g, '\\|').replace(/\n/g, ' ') : '';
|
|
181
|
+
// Apply formatting hints from cell style
|
|
182
|
+
const addr = XLSX.utils.encode_cell({ r: i, c: j });
|
|
183
|
+
const info = cellInfoMap[addr];
|
|
184
|
+
if (info) {
|
|
185
|
+
if (info.isBold && cellStr.length > 0) {
|
|
186
|
+
cellStr = `**${cellStr}**`;
|
|
187
|
+
}
|
|
188
|
+
else if (info.isItalic && cellStr.length > 0) {
|
|
189
|
+
cellStr = `_${cellStr}_`;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
112
192
|
cells.push(cellStr);
|
|
113
193
|
}
|
|
114
194
|
lines.push(`| ${cells.join(' | ')} |`);
|
|
115
|
-
//
|
|
116
|
-
if (i ===
|
|
195
|
+
// Header separator after the detected header row
|
|
196
|
+
if (i === headerRow) {
|
|
117
197
|
lines.push(`| ${cells.map(() => '---').join(' | ')} |`);
|
|
118
198
|
}
|
|
119
199
|
}
|
|
@@ -122,6 +202,62 @@ function arrayToMarkdownTable(data) {
|
|
|
122
202
|
}
|
|
123
203
|
return lines.join('\n');
|
|
124
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Build a formula summary section showing formula → computed value.
|
|
207
|
+
*/
|
|
208
|
+
function buildFormulaSummary(cellInfoMap) {
|
|
209
|
+
const formulas = Object.values(cellInfoMap).filter((c) => c.formula);
|
|
210
|
+
if (formulas.length === 0)
|
|
211
|
+
return '';
|
|
212
|
+
const lines = ['**Formulas:**', ''];
|
|
213
|
+
const shown = formulas.slice(0, 15);
|
|
214
|
+
for (const f of shown) {
|
|
215
|
+
lines.push(`- \`${f.address}\`: \`${f.formula}\` → **${f.value}**`);
|
|
216
|
+
}
|
|
217
|
+
if (formulas.length > 15) {
|
|
218
|
+
lines.push(`- _...and ${formulas.length - 15} more formulas_`);
|
|
219
|
+
}
|
|
220
|
+
return lines.join('\n');
|
|
221
|
+
}
|
|
222
|
+
function extractChartInfo(workbook) {
|
|
223
|
+
const sheets = workbook.Sheets;
|
|
224
|
+
const chartNotes = [];
|
|
225
|
+
for (const [name, sheet] of Object.entries(sheets)) {
|
|
226
|
+
const type = sheet['!type'];
|
|
227
|
+
if (type === 'chart') {
|
|
228
|
+
chartNotes.push(`- **${name}**: Chart sheet detected`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return chartNotes.length > 0 ? chartNotes.join('\n') : '';
|
|
232
|
+
}
|
|
233
|
+
function extractFromRawXml(filePath) {
|
|
234
|
+
const buffer = readFileSync(filePath);
|
|
235
|
+
const content = buffer.toString('latin1');
|
|
236
|
+
const textParts = [];
|
|
237
|
+
const textRegex = /<t[^>]*>([\s\S]*?)<\/t>/g;
|
|
238
|
+
let match;
|
|
239
|
+
while ((match = textRegex.exec(content)) !== null) {
|
|
240
|
+
if (match[1] && match[1].trim()) {
|
|
241
|
+
textParts.push(match[1].trim());
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const valueRegex = /<v>([\s\S]*?)<\/v>/g;
|
|
245
|
+
while ((match = valueRegex.exec(content)) !== null) {
|
|
246
|
+
if (match[1] && match[1].trim()) {
|
|
247
|
+
textParts.push(match[1].trim());
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const sheetMatches = content.match(/<sheet /g);
|
|
251
|
+
const sheetCount = sheetMatches ? sheetMatches.length : 1;
|
|
252
|
+
if (textParts.length === 0) {
|
|
253
|
+
return { content: '', sheetCount };
|
|
254
|
+
}
|
|
255
|
+
const uniqueParts = [...new Set(textParts)].slice(0, 500);
|
|
256
|
+
return {
|
|
257
|
+
content: `**Extracted cell values:**\n\n${uniqueParts.join(' | ')}`,
|
|
258
|
+
sheetCount,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
125
261
|
function buildMarkdown(title, filePath, content, sheetCount) {
|
|
126
262
|
return `# ${title}
|
|
127
263
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xlsx.js","sourceRoot":"","sources":["../../src/processors/xlsx.ts"],"names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AC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAE1D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;IACrC,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1D,OAAO;QACL,OAAO,EAAE,iCAAiC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QACnE,UAAU;KACX,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAAa,EAAE,QAAgB,EAAE,OAAe,EAAE,UAAkB;IACzF,OAAO,KAAK,KAAK;;iBAEF,QAAQ,CAAC,QAAQ,CAAC,KAAK,QAAQ;2BACrB,OAAO,CAAC,QAAQ,CAAC;gBAC5B,UAAU;mBACP,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;;;EAIvD,OAAO;CACR,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source-type templates for wiki page generation.
|
|
3
|
+
* Each template defines how a specific type of source should be
|
|
4
|
+
* structured when compiled into wiki pages.
|
|
5
|
+
*
|
|
6
|
+
* Used by ingest.ts to generate appropriately structured content.
|
|
7
|
+
*/
|
|
8
|
+
export interface SourceTypeTemplate {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
/** Keywords that help detect this source type from content */
|
|
13
|
+
detectionKeywords: string[];
|
|
14
|
+
/** MIME type patterns */
|
|
15
|
+
mimePatterns?: string[];
|
|
16
|
+
/** System prompt addition for LLM compilation */
|
|
17
|
+
systemPromptAddition: string;
|
|
18
|
+
/** Suggested frontmatter fields beyond the defaults */
|
|
19
|
+
extraFrontmatterFields: string[];
|
|
20
|
+
/** Suggested page structure (headings) */
|
|
21
|
+
suggestedStructure: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare const SOURCE_TYPE_TEMPLATES: SourceTypeTemplate[];
|
|
24
|
+
/**
|
|
25
|
+
* Detect source type from content and metadata.
|
|
26
|
+
* Returns the best-matching template or null for generic.
|
|
27
|
+
*/
|
|
28
|
+
export declare function detectSourceType(content: string, filename?: string, mimeType?: string): SourceTypeTemplate | null;
|
|
29
|
+
/**
|
|
30
|
+
* Get the system prompt addition for a detected source type.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getSourceTypePrompt(template: SourceTypeTemplate | null): string;
|
|
33
|
+
//# sourceMappingURL=source-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-types.d.ts","sourceRoot":"","sources":["../../src/templates/source-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,yBAAyB;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,iDAAiD;IACjD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uDAAuD;IACvD,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,0CAA0C;IAC1C,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,EAqHrD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,GAChB,kBAAkB,GAAG,IAAI,CAyC3B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,GAAG,MAAM,CAG/E"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source-type templates for wiki page generation.
|
|
3
|
+
* Each template defines how a specific type of source should be
|
|
4
|
+
* structured when compiled into wiki pages.
|
|
5
|
+
*
|
|
6
|
+
* Used by ingest.ts to generate appropriately structured content.
|
|
7
|
+
*/
|
|
8
|
+
export const SOURCE_TYPE_TEMPLATES = [
|
|
9
|
+
{
|
|
10
|
+
id: 'article',
|
|
11
|
+
name: 'Article / Blog Post',
|
|
12
|
+
description: 'Web articles, blog posts, news pieces',
|
|
13
|
+
detectionKeywords: ['article', 'blog', 'post', 'published', 'author', 'byline'],
|
|
14
|
+
mimePatterns: ['text/html'],
|
|
15
|
+
systemPromptAddition: `This source is a web article or blog post. Structure the wiki pages to capture:
|
|
16
|
+
- The core thesis or argument
|
|
17
|
+
- Key claims with supporting evidence
|
|
18
|
+
- Author's perspective and potential biases
|
|
19
|
+
- Practical takeaways and implications
|
|
20
|
+
- How this connects to other knowledge in the wiki
|
|
21
|
+
Use citation-style references when quoting the original.`,
|
|
22
|
+
extraFrontmatterFields: ['author', 'publication', 'publish_date', 'url'],
|
|
23
|
+
suggestedStructure: ['Summary', 'Key Arguments', 'Evidence & Claims', 'Implications', 'Related Concepts'],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'paper',
|
|
27
|
+
name: 'Academic Paper / Research',
|
|
28
|
+
description: 'Research papers, whitepapers, academic publications',
|
|
29
|
+
detectionKeywords: ['abstract', 'methodology', 'findings', 'conclusion', 'references', 'doi', 'arxiv', 'et al'],
|
|
30
|
+
mimePatterns: ['application/pdf'],
|
|
31
|
+
systemPromptAddition: `This source is an academic paper or research document. Structure the wiki pages to capture:
|
|
32
|
+
- Abstract / TL;DR in accessible language
|
|
33
|
+
- Research question and hypothesis
|
|
34
|
+
- Methodology overview (non-technical summary)
|
|
35
|
+
- Key findings and results
|
|
36
|
+
- Limitations acknowledged by authors
|
|
37
|
+
- Practical implications and applications
|
|
38
|
+
- How this advances the field
|
|
39
|
+
Translate academic jargon into plain language while preserving accuracy.`,
|
|
40
|
+
extraFrontmatterFields: ['authors', 'institution', 'year', 'doi', 'conference', 'citation_count'],
|
|
41
|
+
suggestedStructure: ['Abstract', 'Research Question', 'Methodology', 'Key Findings', 'Limitations', 'Implications', 'References'],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 'tweet-thread',
|
|
45
|
+
name: 'Tweet Thread / Social Post',
|
|
46
|
+
description: 'Twitter/X threads, social media discussions',
|
|
47
|
+
detectionKeywords: ['thread', 'tweet', '🧵', '1/', 'RT', '@', 'x.com', 'twitter.com'],
|
|
48
|
+
systemPromptAddition: `This source is a social media thread (likely Twitter/X). Structure the wiki pages to capture:
|
|
49
|
+
- The main argument condensed from the thread
|
|
50
|
+
- Key insights (numbered, one per point)
|
|
51
|
+
- Any data, links, or evidence shared
|
|
52
|
+
- Community reactions or counter-arguments if visible
|
|
53
|
+
- The author's credibility and context
|
|
54
|
+
Threads are informal — extract the substance while noting the conversational tone.`,
|
|
55
|
+
extraFrontmatterFields: ['author_handle', 'platform', 'post_date', 'engagement'],
|
|
56
|
+
suggestedStructure: ['Main Argument', 'Key Points', 'Evidence Shared', 'Context & Credibility'],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'podcast',
|
|
60
|
+
name: 'Podcast / Audio Content',
|
|
61
|
+
description: 'Podcast episodes, audio interviews, lectures',
|
|
62
|
+
detectionKeywords: ['podcast', 'episode', 'interview', 'host', 'guest', 'transcript', 'listen'],
|
|
63
|
+
mimePatterns: ['audio/'],
|
|
64
|
+
systemPromptAddition: `This source is a podcast episode or audio content (likely transcribed). Structure the wiki pages to capture:
|
|
65
|
+
- Episode summary (who, what, why it matters)
|
|
66
|
+
- Key quotes from each speaker (attributed)
|
|
67
|
+
- Main topics discussed (as separate sections)
|
|
68
|
+
- Actionable advice or takeaways
|
|
69
|
+
- Disagreements or debates between speakers
|
|
70
|
+
- Resources/links mentioned
|
|
71
|
+
Attribute quotes to speakers. Separate opinion from fact.`,
|
|
72
|
+
extraFrontmatterFields: ['host', 'guests', 'podcast_name', 'episode_number', 'duration', 'air_date'],
|
|
73
|
+
suggestedStructure: ['Episode Overview', 'Speakers', 'Key Topics', 'Notable Quotes', 'Takeaways', 'Resources Mentioned'],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 'video',
|
|
77
|
+
name: 'Video / Lecture',
|
|
78
|
+
description: 'YouTube videos, lectures, presentations, tutorials',
|
|
79
|
+
detectionKeywords: ['video', 'youtube', 'lecture', 'presentation', 'tutorial', 'watch', 'timestamp'],
|
|
80
|
+
mimePatterns: ['video/'],
|
|
81
|
+
systemPromptAddition: `This source is a video or lecture (likely transcribed). Structure the wiki pages to capture:
|
|
82
|
+
- Video summary with key timestamps
|
|
83
|
+
- Main concepts taught or discussed
|
|
84
|
+
- Visual elements described (diagrams, demos, code shown)
|
|
85
|
+
- Step-by-step instructions if tutorial
|
|
86
|
+
- Speaker's key arguments
|
|
87
|
+
- Q&A highlights if present
|
|
88
|
+
Note: visual content may be lost in transcription — flag where visuals were important.`,
|
|
89
|
+
extraFrontmatterFields: ['creator', 'channel', 'duration', 'publish_date', 'url', 'platform'],
|
|
90
|
+
suggestedStructure: ['Overview', 'Key Concepts', 'Timestamps', 'Visual Notes', 'Takeaways'],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: 'book',
|
|
94
|
+
name: 'Book / Long-form',
|
|
95
|
+
description: 'Books, book chapters, long-form essays, reports',
|
|
96
|
+
detectionKeywords: ['chapter', 'book', 'isbn', 'publisher', 'edition', 'foreword', 'preface'],
|
|
97
|
+
systemPromptAddition: `This source is a book or long-form document. Structure the wiki pages to capture:
|
|
98
|
+
- Book summary (thesis, scope, intended audience)
|
|
99
|
+
- Chapter-by-chapter key takeaways
|
|
100
|
+
- Core frameworks or models introduced
|
|
101
|
+
- Memorable examples and case studies
|
|
102
|
+
- Practical applications
|
|
103
|
+
- Author's background and perspective
|
|
104
|
+
- How this connects to other books/ideas in the wiki
|
|
105
|
+
Create separate wiki pages for major concepts introduced by the book.`,
|
|
106
|
+
extraFrontmatterFields: ['author', 'publisher', 'year', 'isbn', 'genre', 'pages'],
|
|
107
|
+
suggestedStructure: ['Book Summary', 'Core Thesis', 'Key Frameworks', 'Chapter Notes', 'Practical Applications', 'Related Works'],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: 'notes',
|
|
111
|
+
name: 'Raw Notes / Meeting Notes',
|
|
112
|
+
description: 'Personal notes, meeting notes, brainstorms, voice memos',
|
|
113
|
+
detectionKeywords: ['notes', 'meeting', 'action items', 'TODO', 'decision', 'brainstorm', 'idea'],
|
|
114
|
+
systemPromptAddition: `This source is raw notes (meeting notes, personal notes, brainstorm). Structure the wiki pages to capture:
|
|
115
|
+
- Clean summary of what was discussed/noted
|
|
116
|
+
- Action items extracted (with owners if mentioned)
|
|
117
|
+
- Decisions made
|
|
118
|
+
- Open questions or unresolved items
|
|
119
|
+
- Key ideas worth developing further
|
|
120
|
+
- Connections to existing wiki topics
|
|
121
|
+
Raw notes are messy — your job is to extract structure and meaning. Link to existing wiki pages where concepts overlap.`,
|
|
122
|
+
extraFrontmatterFields: ['meeting_date', 'participants', 'context'],
|
|
123
|
+
suggestedStructure: ['Summary', 'Key Points', 'Action Items', 'Decisions', 'Open Questions', 'Related Topics'],
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
/**
|
|
127
|
+
* Detect source type from content and metadata.
|
|
128
|
+
* Returns the best-matching template or null for generic.
|
|
129
|
+
*/
|
|
130
|
+
export function detectSourceType(content, filename, mimeType) {
|
|
131
|
+
const lowerContent = content.toLowerCase().slice(0, 2000); // Only check first 2K chars
|
|
132
|
+
const lowerFilename = (filename ?? '').toLowerCase();
|
|
133
|
+
let bestMatch = null;
|
|
134
|
+
let bestScore = 0;
|
|
135
|
+
for (const template of SOURCE_TYPE_TEMPLATES) {
|
|
136
|
+
let score = 0;
|
|
137
|
+
// Check keywords in content
|
|
138
|
+
for (const keyword of template.detectionKeywords) {
|
|
139
|
+
if (lowerContent.includes(keyword.toLowerCase()))
|
|
140
|
+
score += 1;
|
|
141
|
+
}
|
|
142
|
+
// Check MIME type
|
|
143
|
+
if (mimeType && template.mimePatterns) {
|
|
144
|
+
for (const pattern of template.mimePatterns) {
|
|
145
|
+
if (mimeType.startsWith(pattern))
|
|
146
|
+
score += 3;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// Check filename hints
|
|
150
|
+
if (lowerFilename.includes('paper') || lowerFilename.includes('arxiv')) {
|
|
151
|
+
if (template.id === 'paper')
|
|
152
|
+
score += 2;
|
|
153
|
+
}
|
|
154
|
+
if (lowerFilename.includes('notes') || lowerFilename.includes('meeting')) {
|
|
155
|
+
if (template.id === 'notes')
|
|
156
|
+
score += 2;
|
|
157
|
+
}
|
|
158
|
+
if (lowerFilename.includes('transcript') || lowerFilename.includes('podcast')) {
|
|
159
|
+
if (template.id === 'podcast')
|
|
160
|
+
score += 2;
|
|
161
|
+
}
|
|
162
|
+
if (score > bestScore) {
|
|
163
|
+
bestScore = score;
|
|
164
|
+
bestMatch = template;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Require minimum confidence (at least 2 keyword matches)
|
|
168
|
+
return bestScore >= 2 ? bestMatch : null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get the system prompt addition for a detected source type.
|
|
172
|
+
*/
|
|
173
|
+
export function getSourceTypePrompt(template) {
|
|
174
|
+
if (!template)
|
|
175
|
+
return '';
|
|
176
|
+
return `\n\nSOURCE TYPE DETECTED: ${template.name}\n${template.systemPromptAddition}`;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=source-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-types.js","sourceRoot":"","sources":["../../src/templates/source-types.ts"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