@monoes/monomindcli 2.14.0 → 2.14.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.
Files changed (124) hide show
  1. package/.claude/skills/monodesign/scripts/context.mjs +1 -1
  2. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns-browser.js +2 -2
  3. package/.claude/skills/monodesign/scripts/detector/rules/checks.mjs +2 -2
  4. package/.claude/skills/monodesign/scripts/live-browser.js +1 -1
  5. package/bin/cli.js +21 -1
  6. package/bin/mcp-server.js +21 -1
  7. package/dist/src/capabilities/cap-documents.d.ts.map +1 -1
  8. package/dist/src/capabilities/cap-documents.js +23 -0
  9. package/dist/src/capabilities/cap-documents.js.map +1 -1
  10. package/dist/src/commands/doc-filters.d.ts +19 -0
  11. package/dist/src/commands/doc-filters.d.ts.map +1 -0
  12. package/dist/src/commands/doc-filters.js +58 -0
  13. package/dist/src/commands/doc-filters.js.map +1 -0
  14. package/dist/src/commands/doc-library.d.ts +21 -0
  15. package/dist/src/commands/doc-library.d.ts.map +1 -0
  16. package/dist/src/commands/doc-library.js +390 -0
  17. package/dist/src/commands/doc-library.js.map +1 -0
  18. package/dist/src/commands/doc-list.d.ts +9 -0
  19. package/dist/src/commands/doc-list.d.ts.map +1 -0
  20. package/dist/src/commands/doc-list.js +99 -0
  21. package/dist/src/commands/doc-list.js.map +1 -0
  22. package/dist/src/commands/doc.d.ts.map +1 -1
  23. package/dist/src/commands/doc.js +49 -37
  24. package/dist/src/commands/doc.js.map +1 -1
  25. package/dist/src/knowledge/capture-envelope.d.ts +80 -0
  26. package/dist/src/knowledge/capture-envelope.d.ts.map +1 -0
  27. package/dist/src/knowledge/capture-envelope.js +165 -0
  28. package/dist/src/knowledge/capture-envelope.js.map +1 -0
  29. package/dist/src/knowledge/capture-text.d.ts +23 -0
  30. package/dist/src/knowledge/capture-text.d.ts.map +1 -0
  31. package/dist/src/knowledge/capture-text.js +49 -0
  32. package/dist/src/knowledge/capture-text.js.map +1 -0
  33. package/dist/src/knowledge/citation.d.ts +121 -0
  34. package/dist/src/knowledge/citation.d.ts.map +1 -0
  35. package/dist/src/knowledge/citation.js +252 -0
  36. package/dist/src/knowledge/citation.js.map +1 -0
  37. package/dist/src/knowledge/document-pipeline.d.ts +60 -0
  38. package/dist/src/knowledge/document-pipeline.d.ts.map +1 -1
  39. package/dist/src/knowledge/document-pipeline.js +188 -4
  40. package/dist/src/knowledge/document-pipeline.js.map +1 -1
  41. package/dist/src/knowledge/html-extract.d.ts +43 -0
  42. package/dist/src/knowledge/html-extract.d.ts.map +1 -0
  43. package/dist/src/knowledge/html-extract.js +286 -0
  44. package/dist/src/knowledge/html-extract.js.map +1 -0
  45. package/dist/src/knowledge/html-tags.d.ts +30 -0
  46. package/dist/src/knowledge/html-tags.d.ts.map +1 -0
  47. package/dist/src/knowledge/html-tags.js +229 -0
  48. package/dist/src/knowledge/html-tags.js.map +1 -0
  49. package/dist/src/knowledge/library.d.ts +106 -0
  50. package/dist/src/knowledge/library.d.ts.map +1 -0
  51. package/dist/src/knowledge/library.js +195 -0
  52. package/dist/src/knowledge/library.js.map +1 -0
  53. package/dist/src/knowledge/mhtml.d.ts +60 -0
  54. package/dist/src/knowledge/mhtml.d.ts.map +1 -0
  55. package/dist/src/knowledge/mhtml.js +154 -0
  56. package/dist/src/knowledge/mhtml.js.map +1 -0
  57. package/dist/src/knowledge/related.d.ts +58 -0
  58. package/dist/src/knowledge/related.d.ts.map +1 -0
  59. package/dist/src/knowledge/related.js +222 -0
  60. package/dist/src/knowledge/related.js.map +1 -0
  61. package/dist/src/knowledge/section-diff.d.ts +48 -0
  62. package/dist/src/knowledge/section-diff.d.ts.map +1 -0
  63. package/dist/src/knowledge/section-diff.js +151 -0
  64. package/dist/src/knowledge/section-diff.js.map +1 -0
  65. package/dist/src/knowledge/watch.d.ts +92 -0
  66. package/dist/src/knowledge/watch.d.ts.map +1 -0
  67. package/dist/src/knowledge/watch.js +221 -0
  68. package/dist/src/knowledge/watch.js.map +1 -0
  69. package/dist/src/mcp-server.d.ts.map +1 -1
  70. package/dist/src/mcp-server.js +44 -87
  71. package/dist/src/mcp-server.js.map +1 -1
  72. package/dist/src/mcp-tools/browser-instrument-tools.d.ts +35 -0
  73. package/dist/src/mcp-tools/browser-instrument-tools.d.ts.map +1 -0
  74. package/dist/src/mcp-tools/browser-instrument-tools.js +359 -0
  75. package/dist/src/mcp-tools/browser-instrument-tools.js.map +1 -0
  76. package/dist/src/mcp-tools/browser-metrics.d.ts +42 -0
  77. package/dist/src/mcp-tools/browser-metrics.d.ts.map +1 -0
  78. package/dist/src/mcp-tools/browser-metrics.js +91 -0
  79. package/dist/src/mcp-tools/browser-metrics.js.map +1 -0
  80. package/dist/src/mcp-tools/browser-profile-tools.d.ts +16 -0
  81. package/dist/src/mcp-tools/browser-profile-tools.d.ts.map +1 -0
  82. package/dist/src/mcp-tools/browser-profile-tools.js +324 -0
  83. package/dist/src/mcp-tools/browser-profile-tools.js.map +1 -0
  84. package/dist/src/mcp-tools/browser-session.d.ts +68 -0
  85. package/dist/src/mcp-tools/browser-session.d.ts.map +1 -0
  86. package/dist/src/mcp-tools/browser-session.js +224 -0
  87. package/dist/src/mcp-tools/browser-session.js.map +1 -0
  88. package/dist/src/mcp-tools/browser-tools.d.ts.map +1 -1
  89. package/dist/src/mcp-tools/browser-tools.js +10 -176
  90. package/dist/src/mcp-tools/browser-tools.js.map +1 -1
  91. package/dist/src/mcp-tools/capture-resource-read.d.ts +115 -0
  92. package/dist/src/mcp-tools/capture-resource-read.d.ts.map +1 -0
  93. package/dist/src/mcp-tools/capture-resource-read.js +296 -0
  94. package/dist/src/mcp-tools/capture-resource-read.js.map +1 -0
  95. package/dist/src/mcp-tools/capture-resource-tools.d.ts +22 -0
  96. package/dist/src/mcp-tools/capture-resource-tools.d.ts.map +1 -0
  97. package/dist/src/mcp-tools/capture-resource-tools.js +182 -0
  98. package/dist/src/mcp-tools/capture-resource-tools.js.map +1 -0
  99. package/dist/src/mcp-tools/capture-resources.d.ts +142 -0
  100. package/dist/src/mcp-tools/capture-resources.d.ts.map +1 -0
  101. package/dist/src/mcp-tools/capture-resources.js +289 -0
  102. package/dist/src/mcp-tools/capture-resources.js.map +1 -0
  103. package/dist/src/mcp-tools/index.d.ts +3 -0
  104. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  105. package/dist/src/mcp-tools/index.js +6 -0
  106. package/dist/src/mcp-tools/index.js.map +1 -1
  107. package/dist/src/mcp-tools/knowledge-tools.d.ts.map +1 -1
  108. package/dist/src/mcp-tools/knowledge-tools.js +9 -1
  109. package/dist/src/mcp-tools/knowledge-tools.js.map +1 -1
  110. package/dist/src/mcp-tools/resource-router.d.ts +86 -0
  111. package/dist/src/mcp-tools/resource-router.d.ts.map +1 -0
  112. package/dist/src/mcp-tools/resource-router.js +181 -0
  113. package/dist/src/mcp-tools/resource-router.js.map +1 -0
  114. package/dist/src/memory/memory-bridge.js +1 -1
  115. package/dist/src/memory/memory-bridge.js.map +1 -1
  116. package/dist/src/orgrt/session-ledger.d.ts +7 -0
  117. package/dist/src/orgrt/session-ledger.d.ts.map +1 -1
  118. package/dist/src/orgrt/session-ledger.js +15 -0
  119. package/dist/src/orgrt/session-ledger.js.map +1 -1
  120. package/dist/src/orgrt/session.d.ts.map +1 -1
  121. package/dist/src/orgrt/session.js +21 -8
  122. package/dist/src/orgrt/session.js.map +1 -1
  123. package/dist/tsconfig.tsbuildinfo +1 -1
  124. package/package.json +6 -6
@@ -0,0 +1,286 @@
1
+ /**
2
+ * Dependency-free HTML → readable Markdown-ish text (RCL-01).
3
+ *
4
+ * WHY NO DEPENDENCY — the capture path has to work in an `npx monomind`
5
+ * install with nothing extra resolved, and the extension already runs
6
+ * Readability against the live DOM. What lands here is the fallback for an
7
+ * archive nobody cleaned: a small, predictable extractor beats a large one we
8
+ * cannot install.
9
+ *
10
+ * WHY BOILERPLATE STRIPPING IS THE POINT — a site's nav, header, footer and
11
+ * cookie banner are byte-identical on every page. Leave them in and every
12
+ * document from that site chunks into near-identical text, so their embeddings
13
+ * cluster on the chrome rather than the article and recall collapses. Dropping
14
+ * a little real content is a far cheaper error than keeping the chrome.
15
+ *
16
+ * @module v1/cli/knowledge/html-extract
17
+ */
18
+ import { BLOCK_TAGS, CELL_TAGS, CHROME_ROLES, CHROME_TAGS, CHROME_WORDS, decodeEntities, NON_TEXT_TAGS, RAW_TEXT_TAGS, VOID_TAGS, } from './html-tags.js';
19
+ export { decodeEntities };
20
+ const ATTR_RE = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*(?:=\s*("[^"]*"|'[^']*'|[^\s"'`=<>]+))?/g;
21
+ function parseAttrs(source) {
22
+ const attrs = {};
23
+ ATTR_RE.lastIndex = 0;
24
+ let m = ATTR_RE.exec(source);
25
+ while (m) {
26
+ const raw = m[2] ?? '';
27
+ attrs[m[1].toLowerCase()] = decodeEntities(raw.replace(/^["']|["']$/g, ''));
28
+ m = ATTR_RE.exec(source);
29
+ }
30
+ return attrs;
31
+ }
32
+ function* tokenize(html) {
33
+ let i = 0;
34
+ while (i < html.length) {
35
+ const lt = html.indexOf('<', i);
36
+ if (lt === -1) {
37
+ yield { t: 'text', value: html.slice(i) };
38
+ return;
39
+ }
40
+ if (lt > i)
41
+ yield { t: 'text', value: html.slice(i, lt) };
42
+ if (html.startsWith('<!--', lt)) {
43
+ const end = html.indexOf('-->', lt + 4);
44
+ i = end === -1 ? html.length : end + 3;
45
+ continue;
46
+ }
47
+ if (html.startsWith('<![CDATA[', lt)) {
48
+ const end = html.indexOf(']]>', lt + 9);
49
+ yield { t: 'text', value: html.slice(lt + 9, end === -1 ? undefined : end) };
50
+ i = end === -1 ? html.length : end + 3;
51
+ continue;
52
+ }
53
+ if (html.startsWith('<!', lt) || html.startsWith('<?', lt)) {
54
+ const end = html.indexOf('>', lt);
55
+ i = end === -1 ? html.length : end + 1;
56
+ continue;
57
+ }
58
+ if (html.startsWith('</', lt)) {
59
+ const end = html.indexOf('>', lt);
60
+ if (end === -1) {
61
+ i = html.length;
62
+ continue;
63
+ }
64
+ const name = /^[a-zA-Z][a-zA-Z0-9:-]*/.exec(html.slice(lt + 2, end).trim())?.[0];
65
+ if (name)
66
+ yield { t: 'close', name: name.toLowerCase() };
67
+ i = end + 1;
68
+ continue;
69
+ }
70
+ const nameMatch = /^<([a-zA-Z][a-zA-Z0-9:-]*)/.exec(html.slice(lt, lt + 80));
71
+ if (!nameMatch) {
72
+ // A bare `<` in prose, e.g. "a < b". Keep it as text.
73
+ yield { t: 'text', value: '<' };
74
+ i = lt + 1;
75
+ continue;
76
+ }
77
+ const name = nameMatch[1].toLowerCase();
78
+ // Walk to the tag's `>` while honouring quoted attribute values, so
79
+ // `alt="a > b"` does not end the tag early.
80
+ let j = lt + nameMatch[0].length;
81
+ let quote = '';
82
+ while (j < html.length) {
83
+ const c = html[j];
84
+ if (quote) {
85
+ if (c === quote)
86
+ quote = '';
87
+ }
88
+ else if (c === '"' || c === "'") {
89
+ quote = c;
90
+ }
91
+ else if (c === '>') {
92
+ break;
93
+ }
94
+ j++;
95
+ }
96
+ const inner = html.slice(lt + nameMatch[0].length, j);
97
+ const selfClosing = inner.trimEnd().endsWith('/') || VOID_TAGS.has(name);
98
+ yield { t: 'open', tag: { name, attrs: parseAttrs(inner), selfClosing } };
99
+ i = j + 1;
100
+ if (RAW_TEXT_TAGS.has(name) && !inner.trimEnd().endsWith('/')) {
101
+ const rest = html.slice(i);
102
+ const close = new RegExp(`</${name}\\s*>`, 'i').exec(rest);
103
+ yield { t: 'text', value: close ? rest.slice(0, close.index) : rest };
104
+ yield { t: 'close', name };
105
+ i = close ? i + close.index + close[0].length : html.length;
106
+ }
107
+ }
108
+ }
109
+ // ── Drop decisions ─────────────────────────────────────────────────
110
+ function classTokens(value) {
111
+ return value
112
+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
113
+ .toLowerCase()
114
+ .split(/[^a-z0-9]+/)
115
+ .filter(Boolean);
116
+ }
117
+ function isChromeAttrs(attrs) {
118
+ const role = attrs.role?.trim().toLowerCase();
119
+ if (role?.split(/\s+/).some((r) => CHROME_ROLES.has(r)))
120
+ return true;
121
+ for (const key of ['class', 'id']) {
122
+ const value = attrs[key];
123
+ if (!value)
124
+ continue;
125
+ if (classTokens(value).some((w) => CHROME_WORDS.has(w)))
126
+ return true;
127
+ }
128
+ return false;
129
+ }
130
+ function isHidden(attrs) {
131
+ if (attrs['aria-hidden']?.trim().toLowerCase() === 'true')
132
+ return true;
133
+ if ('hidden' in attrs)
134
+ return true;
135
+ const style = attrs.style;
136
+ return !!style && /(?:^|;)\s*display\s*:\s*none/i.test(style);
137
+ }
138
+ /** The innermost open block decides how the buffered text renders — so a
139
+ * `<p>` nested inside an `<li>` still comes out as a bullet, not a
140
+ * paragraph. */
141
+ function resolveKind(openBlocks) {
142
+ for (let i = openBlocks.length - 1; i >= 0; i--) {
143
+ const name = openBlocks[i];
144
+ if (/^h[1-6]$/.test(name))
145
+ return { kind: 'heading', level: Number(name[1]) };
146
+ if (name === 'li') {
147
+ let indent = -1;
148
+ for (let k = 0; k <= i; k++)
149
+ if (openBlocks[k] === 'li')
150
+ indent++;
151
+ return { kind: 'li', indent: Math.max(0, indent) };
152
+ }
153
+ if (name === 'pre')
154
+ return { kind: 'pre' };
155
+ if (name === 'blockquote')
156
+ return { kind: 'quote' };
157
+ }
158
+ return { kind: 'para' };
159
+ }
160
+ function render(blocks) {
161
+ let out = '';
162
+ for (let i = 0; i < blocks.length; i++) {
163
+ const b = blocks[i];
164
+ let line;
165
+ if (b.kind === 'heading')
166
+ line = `${'#'.repeat(Math.min(6, b.level ?? 1))} ${b.text}`;
167
+ else if (b.kind === 'li')
168
+ line = `${' '.repeat(b.indent ?? 0)}- ${b.text}`;
169
+ else if (b.kind === 'quote')
170
+ line = `> ${b.text}`;
171
+ else
172
+ line = b.text;
173
+ if (i === 0)
174
+ out += line;
175
+ else if (blocks[i - 1].kind === 'li' && b.kind === 'li')
176
+ out += `\n${line}`;
177
+ else
178
+ out += `\n\n${line}`;
179
+ }
180
+ return out.replace(/\n{3,}/g, '\n\n').trim();
181
+ }
182
+ /**
183
+ * Parse `html` into a title and clean block text.
184
+ *
185
+ * Unbalanced markup is expected — real archives are full of it — so closing a
186
+ * tag pops back to its last matching open and a never-closed element simply
187
+ * stays open until its parent closes. Nothing here throws.
188
+ */
189
+ export function extractHtmlDocument(html, opts = {}) {
190
+ const stripBoilerplate = opts.stripBoilerplate !== false;
191
+ const blocks = [];
192
+ const openBlocks = [];
193
+ let buf = '';
194
+ let title = null;
195
+ let inTitle = false;
196
+ // Drop state: the element being skipped and how deep we are inside nested
197
+ // elements of the same name.
198
+ let dropName = null;
199
+ let dropNest = 0;
200
+ const flush = () => {
201
+ const resolved = resolveKind(openBlocks);
202
+ let text = resolved.kind === 'pre' ? buf.replace(/[ \t]+$/gm, '') : buf.replace(/\s+/g, ' ');
203
+ buf = '';
204
+ text = text.replace(/\s*\|\s*$/, '').trim();
205
+ if (!text)
206
+ return;
207
+ blocks.push({ kind: resolved.kind, text, level: resolved.level, indent: resolved.indent });
208
+ };
209
+ for (const token of tokenize(html)) {
210
+ if (dropName) {
211
+ if (token.t === 'open' && token.tag.name === dropName && !token.tag.selfClosing)
212
+ dropNest++;
213
+ else if (token.t === 'close' && token.name === dropName && --dropNest === 0)
214
+ dropName = null;
215
+ continue;
216
+ }
217
+ if (token.t === 'text') {
218
+ if (inTitle) {
219
+ title = decodeEntities(token.value).replace(/\s+/g, ' ').trim() || null;
220
+ }
221
+ else {
222
+ buf += decodeEntities(token.value);
223
+ }
224
+ continue;
225
+ }
226
+ if (token.t === 'open') {
227
+ const { name, attrs, selfClosing } = token.tag;
228
+ if (name === 'title') {
229
+ // Captured for the document heading, never emitted into the body.
230
+ inTitle = true;
231
+ continue;
232
+ }
233
+ const drop = NON_TEXT_TAGS.has(name) ||
234
+ isHidden(attrs) ||
235
+ (stripBoilerplate && (CHROME_TAGS.has(name) || isChromeAttrs(attrs)));
236
+ if (drop) {
237
+ flush();
238
+ if (!selfClosing) {
239
+ dropName = name;
240
+ dropNest = 1;
241
+ }
242
+ continue;
243
+ }
244
+ if (BLOCK_TAGS.has(name)) {
245
+ flush();
246
+ if (!selfClosing)
247
+ openBlocks.push(name);
248
+ }
249
+ if (name === 'img' && attrs.alt?.trim())
250
+ buf += ` ${attrs.alt.trim()} `;
251
+ continue;
252
+ }
253
+ // close
254
+ const { name } = token;
255
+ if (name === 'title') {
256
+ inTitle = false;
257
+ continue;
258
+ }
259
+ if (CELL_TAGS.has(name)) {
260
+ if (buf.trim())
261
+ buf = `${buf.trimEnd()} | `;
262
+ continue;
263
+ }
264
+ if (BLOCK_TAGS.has(name)) {
265
+ flush();
266
+ const idx = openBlocks.lastIndexOf(name);
267
+ if (idx !== -1)
268
+ openBlocks.splice(idx);
269
+ }
270
+ }
271
+ flush();
272
+ return { title, text: render(blocks) };
273
+ }
274
+ /**
275
+ * Clean text for an HTML document, with the `<title>` promoted to an `# h1`
276
+ * when the page has no top-level heading of its own.
277
+ */
278
+ export function htmlToMarkdown(html, opts = {}) {
279
+ const doc = extractHtmlDocument(html, opts);
280
+ if (!doc.title)
281
+ return doc.text;
282
+ if (/^# (?!#)/m.test(doc.text))
283
+ return doc.text;
284
+ return doc.text ? `# ${doc.title}\n\n${doc.text}` : `# ${doc.title}`;
285
+ }
286
+ //# sourceMappingURL=html-extract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-extract.js","sourceRoot":"","sources":["../../../src/knowledge/html-extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,SAAS,GACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,CAAC;AA2B1B,MAAM,OAAO,GAAG,yEAAyE,CAAC;AAE1F,SAAS,UAAU,CAAC,MAAc;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,KAAK,CAAC;YAChB,SAAS;QACX,CAAC;QACD,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,IAAI,GAAG,CAAC,IAAI,EAAE;gBAAE,GAAG,GAAG,GAAG,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC;YAC5C,SAAS;QACX,CAAC;QACD,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,KAAK,EAAE,CAAC;YACR,MAAM,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACzC,IAAI,GAAG,KAAK,CAAC,CAAC;gBAAE,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC;IAER,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,IAAI,GAAuB,EAAE;IACxE,MAAM,GAAG,GAAG,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5C,IAAI,CAAC,GAAG,CAAC,KAAK;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC;IAChC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC;IAChD,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Tag and entity tables for the HTML extractor (RCL-01).
3
+ *
4
+ * Split out of `html-extract.ts` purely for size: these are data, the file
5
+ * next door is the algorithm.
6
+ *
7
+ * @module v1/cli/knowledge/html-tags
8
+ */
9
+ export declare const VOID_TAGS: Set<string>;
10
+ /** Elements whose content is never prose. Dropped regardless of options. */
11
+ export declare const NON_TEXT_TAGS: Set<string>;
12
+ /** Structural chrome. Dropped only when `stripBoilerplate` is on. */
13
+ export declare const CHROME_TAGS: Set<string>;
14
+ /** ARIA landmark roles that mark chrome rather than content. */
15
+ export declare const CHROME_ROLES: Set<string>;
16
+ /**
17
+ * Class/id word list. Matched against `-`/`_`/space/camelCase-split tokens, so
18
+ * `site-header`, `cookieBanner` and `ad_slot` all hit and `content-wrapper`
19
+ * does not.
20
+ */
21
+ export declare const CHROME_WORDS: Set<string>;
22
+ /** Elements that start a new output block. */
23
+ export declare const BLOCK_TAGS: Set<string>;
24
+ /** Table cells are joined into their row with ` | ` rather than broken out
25
+ * into blocks of their own, so a row survives as one readable line. */
26
+ export declare const CELL_TAGS: Set<string>;
27
+ /** Elements whose content is raw text — `<` inside them is not markup. */
28
+ export declare const RAW_TEXT_TAGS: Set<string>;
29
+ export declare function decodeEntities(s: string): string;
30
+ //# sourceMappingURL=html-tags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-tags.d.ts","sourceRoot":"","sources":["../../../src/knowledge/html-tags.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,SAAS,aAepB,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,aAAa,aAaxB,CAAC;AAEH,qEAAqE;AACrE,eAAO,MAAM,WAAW,aAUtB,CAAC;AAEH,gEAAgE;AAChE,eAAO,MAAM,YAAY,aAWvB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,aAmDvB,CAAC;AAEH,8CAA8C;AAC9C,eAAO,MAAM,UAAU,aAqCrB,CAAC;AAEH;wEACwE;AACxE,eAAO,MAAM,SAAS,aAAwB,CAAC;AAE/C,0EAA0E;AAC1E,eAAO,MAAM,aAAa,aAAoD,CAAC;AA+C/E,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAgBhD"}
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Tag and entity tables for the HTML extractor (RCL-01).
3
+ *
4
+ * Split out of `html-extract.ts` purely for size: these are data, the file
5
+ * next door is the algorithm.
6
+ *
7
+ * @module v1/cli/knowledge/html-tags
8
+ */
9
+ export const VOID_TAGS = new Set([
10
+ 'area',
11
+ 'base',
12
+ 'br',
13
+ 'col',
14
+ 'embed',
15
+ 'hr',
16
+ 'img',
17
+ 'input',
18
+ 'link',
19
+ 'meta',
20
+ 'param',
21
+ 'source',
22
+ 'track',
23
+ 'wbr',
24
+ ]);
25
+ /** Elements whose content is never prose. Dropped regardless of options. */
26
+ export const NON_TEXT_TAGS = new Set([
27
+ 'script',
28
+ 'style',
29
+ 'noscript',
30
+ 'svg',
31
+ 'math',
32
+ 'template',
33
+ 'canvas',
34
+ 'iframe',
35
+ 'object',
36
+ 'applet',
37
+ 'audio',
38
+ 'video',
39
+ ]);
40
+ /** Structural chrome. Dropped only when `stripBoilerplate` is on. */
41
+ export const CHROME_TAGS = new Set([
42
+ 'nav',
43
+ 'header',
44
+ 'footer',
45
+ 'aside',
46
+ 'menu',
47
+ 'dialog',
48
+ 'button',
49
+ 'select',
50
+ 'textarea',
51
+ ]);
52
+ /** ARIA landmark roles that mark chrome rather than content. */
53
+ export const CHROME_ROLES = new Set([
54
+ 'navigation',
55
+ 'banner',
56
+ 'contentinfo',
57
+ 'complementary',
58
+ 'search',
59
+ 'menubar',
60
+ 'menu',
61
+ 'toolbar',
62
+ 'dialog',
63
+ 'alertdialog',
64
+ ]);
65
+ /**
66
+ * Class/id word list. Matched against `-`/`_`/space/camelCase-split tokens, so
67
+ * `site-header`, `cookieBanner` and `ad_slot` all hit and `content-wrapper`
68
+ * does not.
69
+ */
70
+ export const CHROME_WORDS = new Set([
71
+ 'cookie',
72
+ 'cookies',
73
+ 'consent',
74
+ 'gdpr',
75
+ 'ccpa',
76
+ 'cmp',
77
+ 'banner',
78
+ 'promo',
79
+ 'promotion',
80
+ 'ad',
81
+ 'ads',
82
+ 'advert',
83
+ 'advertisement',
84
+ 'adsbygoogle',
85
+ 'sponsored',
86
+ 'newsletter',
87
+ 'subscribe',
88
+ 'signup',
89
+ 'paywall',
90
+ 'popup',
91
+ 'modal',
92
+ 'overlay',
93
+ 'lightbox',
94
+ 'nav',
95
+ 'navbar',
96
+ 'navigation',
97
+ 'menu',
98
+ 'breadcrumb',
99
+ 'breadcrumbs',
100
+ 'masthead',
101
+ 'topbar',
102
+ 'toolbar',
103
+ 'sidebar',
104
+ 'skiplink',
105
+ 'pagination',
106
+ 'paginate',
107
+ 'pager',
108
+ 'share',
109
+ 'sharing',
110
+ 'social',
111
+ 'socials',
112
+ 'footer',
113
+ 'header',
114
+ 'copyright',
115
+ 'related',
116
+ 'recommended',
117
+ 'recirc',
118
+ 'trending',
119
+ 'comments',
120
+ 'disqus',
121
+ ]);
122
+ /** Elements that start a new output block. */
123
+ export const BLOCK_TAGS = new Set([
124
+ 'address',
125
+ 'article',
126
+ 'blockquote',
127
+ 'br',
128
+ 'dd',
129
+ 'details',
130
+ 'div',
131
+ 'dl',
132
+ 'dt',
133
+ 'fieldset',
134
+ 'figcaption',
135
+ 'figure',
136
+ 'footer',
137
+ 'form',
138
+ 'h1',
139
+ 'h2',
140
+ 'h3',
141
+ 'h4',
142
+ 'h5',
143
+ 'h6',
144
+ 'header',
145
+ 'hr',
146
+ 'li',
147
+ 'main',
148
+ 'nav',
149
+ 'ol',
150
+ 'p',
151
+ 'pre',
152
+ 'section',
153
+ 'summary',
154
+ 'table',
155
+ 'tbody',
156
+ 'tfoot',
157
+ 'thead',
158
+ 'tr',
159
+ 'ul',
160
+ ]);
161
+ /** Table cells are joined into their row with ` | ` rather than broken out
162
+ * into blocks of their own, so a row survives as one readable line. */
163
+ export const CELL_TAGS = new Set(['td', 'th']);
164
+ /** Elements whose content is raw text — `<` inside them is not markup. */
165
+ export const RAW_TEXT_TAGS = new Set(['script', 'style', 'textarea', 'title']);
166
+ // ── Entities ───────────────────────────────────────────────────────
167
+ const NAMED_ENTITIES = {
168
+ amp: '&',
169
+ lt: '<',
170
+ gt: '>',
171
+ quot: '"',
172
+ apos: "'",
173
+ nbsp: ' ',
174
+ ensp: ' ',
175
+ emsp: ' ',
176
+ thinsp: ' ',
177
+ shy: '',
178
+ mdash: '—',
179
+ ndash: '–',
180
+ hellip: '…',
181
+ lsquo: '‘',
182
+ rsquo: '’',
183
+ ldquo: '“',
184
+ rdquo: '”',
185
+ bull: '•',
186
+ middot: '·',
187
+ laquo: '«',
188
+ raquo: '»',
189
+ copy: '©',
190
+ reg: '®',
191
+ trade: '™',
192
+ deg: '°',
193
+ euro: '€',
194
+ pound: '£',
195
+ yen: '¥',
196
+ cent: '¢',
197
+ sect: '§',
198
+ para: '¶',
199
+ dagger: '†',
200
+ times: '×',
201
+ divide: '÷',
202
+ plusmn: '±',
203
+ frac12: '½',
204
+ prime: '′',
205
+ larr: '←',
206
+ rarr: '→',
207
+ harr: '↔',
208
+ };
209
+ export function decodeEntities(s) {
210
+ if (!s.includes('&'))
211
+ return s;
212
+ return s.replace(/&(#[xX]?[0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]{1,31});/g, (whole, body) => {
213
+ if (body[0] === '#') {
214
+ const hex = body[1] === 'x' || body[1] === 'X';
215
+ const code = Number.parseInt(hex ? body.slice(2) : body.slice(1), hex ? 16 : 10);
216
+ if (!Number.isFinite(code) || code <= 0 || code > 0x10ffff)
217
+ return whole;
218
+ try {
219
+ return String.fromCodePoint(code);
220
+ }
221
+ catch {
222
+ return whole;
223
+ }
224
+ }
225
+ const hit = NAMED_ENTITIES[body] ?? NAMED_ENTITIES[body.toLowerCase()];
226
+ return hit === undefined ? whole : hit;
227
+ });
228
+ }
229
+ //# sourceMappingURL=html-tags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-tags.js","sourceRoot":"","sources":["../../../src/knowledge/html-tags.ts"],"names":[],"mappings":"AAAA;;;;;;;GAO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AC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACjF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,GAAG,QAAQ;gBAAE,OAAO,KAAK,CAAC;YACzE,IAAI,CAAC;gBACH,OAAO,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACvE,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * The capture library (RCL-09) — browsing what has been captured, rather than
3
+ * searching it.
4
+ *
5
+ * `listDocuments` answers "what is indexed". A library answers a different
6
+ * question: everything from this site, captured last week, tagged `reading`,
7
+ * newest first. The facets come from the capture envelope's `meta.json`
8
+ * (RCL-07), which is already on every record — this module is the query layer
9
+ * over them, and the data layer the desktop GUI renders.
10
+ *
11
+ * Rules, once, here:
12
+ * - within a facet values are OR'd, across facets AND'd (`--site a --site b
13
+ * --tag x` = "from a or b, tagged x");
14
+ * - `--site example.com` matches `www.example.com` and `docs.example.com`,
15
+ * because nobody browsing their own library means the bare host only;
16
+ * - a document with no provenance (an ordinary file on disk) sorts by its
17
+ * index time and matches no capture facet — it is not a capture.
18
+ *
19
+ * @module v1/cli/knowledge/library
20
+ */
21
+ import type { CaptureProvenance } from './capture-envelope.js';
22
+ import type { DocumentMeta } from './document-pipeline.js';
23
+ export interface LibraryFilter {
24
+ /** Host, or a parent domain of it. */
25
+ site?: string[];
26
+ tag?: string[];
27
+ collection?: string[];
28
+ /** `extension` | `monobrowse` | `crawl`. */
29
+ source?: string[];
30
+ /** ISO date/time, or a relative age: `7d`, `24h`, `30m`. */
31
+ since?: string;
32
+ until?: string;
33
+ /** Only documents that came from a capture envelope. */
34
+ capturedOnly?: boolean;
35
+ scope?: string;
36
+ /** Substring over title, URL and path. */
37
+ text?: string;
38
+ }
39
+ export type LibrarySort = 'captured' | 'indexed' | 'title' | 'path' | 'size';
40
+ export interface LibraryEntry {
41
+ filePath: string;
42
+ scope: string;
43
+ title: string;
44
+ url?: string;
45
+ site?: string;
46
+ capturedAt: string;
47
+ indexedAt: string;
48
+ source?: string;
49
+ collection?: string;
50
+ tags: string[];
51
+ chunkCount: number;
52
+ size: number;
53
+ version?: number;
54
+ /** False for ordinary files on disk: no capture envelope backed this one. */
55
+ captured: boolean;
56
+ }
57
+ /** The host a document was captured from, or undefined for a local file. */
58
+ export declare function documentSite(meta: {
59
+ canonicalUrl?: string;
60
+ provenance?: CaptureProvenance;
61
+ }): string | undefined;
62
+ /** When the page was captured; falls back to when it was indexed. */
63
+ export declare function documentCapturedAt(meta: {
64
+ indexedAt?: string;
65
+ provenance?: CaptureProvenance;
66
+ }): string;
67
+ /**
68
+ * A point in time from `2026-09-01`, a full ISO stamp, or an AGE like `7d`
69
+ * (meaning "7 days ago"). Returns null for anything unparseable so a typo
70
+ * cannot silently filter the whole library away.
71
+ */
72
+ export declare function parseWhen(value: string | undefined, now?: number): number | null;
73
+ /** True when a document belongs in this view. */
74
+ export declare function matchesLibraryFilter(meta: DocumentMeta, filter?: LibraryFilter, now?: number): boolean;
75
+ export declare function filterDocuments(docs: DocumentMeta[], filter?: LibraryFilter, now?: number): DocumentMeta[];
76
+ export declare function sortDocuments(docs: DocumentMeta[], sort?: LibrarySort, order?: 'asc' | 'desc'): DocumentMeta[];
77
+ /** The flat, JSON-friendly row the GUI and `--json` consumers read. */
78
+ export declare function libraryEntry(meta: DocumentMeta): LibraryEntry;
79
+ export interface ListLibraryOptions extends LibraryFilter {
80
+ sort?: LibrarySort;
81
+ order?: 'asc' | 'desc';
82
+ limit?: number;
83
+ now?: number;
84
+ }
85
+ /** Browse the library: filter, sort, cap. Never throws on an empty store. */
86
+ export declare function listLibrary(docs: DocumentMeta[], opts?: ListLibraryOptions): LibraryEntry[];
87
+ /** Facet counts for the current view — what a sidebar renders. */
88
+ export declare function libraryFacets(docs: DocumentMeta[]): {
89
+ sites: Array<{
90
+ value: string;
91
+ count: number;
92
+ }>;
93
+ tags: Array<{
94
+ value: string;
95
+ count: number;
96
+ }>;
97
+ collections: Array<{
98
+ value: string;
99
+ count: number;
100
+ }>;
101
+ sources: Array<{
102
+ value: string;
103
+ count: number;
104
+ }>;
105
+ };
106
+ //# sourceMappingURL=library.d.ts.map