browzy 1.0.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 (104) hide show
  1. package/README.md +324 -0
  2. package/dist/cli/app.d.ts +16 -0
  3. package/dist/cli/app.js +615 -0
  4. package/dist/cli/banner.d.ts +1 -0
  5. package/dist/cli/banner.js +60 -0
  6. package/dist/cli/commands/compile.d.ts +2 -0
  7. package/dist/cli/commands/compile.js +42 -0
  8. package/dist/cli/commands/ingest.d.ts +2 -0
  9. package/dist/cli/commands/ingest.js +32 -0
  10. package/dist/cli/commands/init.d.ts +2 -0
  11. package/dist/cli/commands/init.js +48 -0
  12. package/dist/cli/commands/lint.d.ts +2 -0
  13. package/dist/cli/commands/lint.js +40 -0
  14. package/dist/cli/commands/query.d.ts +2 -0
  15. package/dist/cli/commands/query.js +36 -0
  16. package/dist/cli/commands/search.d.ts +2 -0
  17. package/dist/cli/commands/search.js +34 -0
  18. package/dist/cli/commands/status.d.ts +2 -0
  19. package/dist/cli/commands/status.js +27 -0
  20. package/dist/cli/components/Banner.d.ts +13 -0
  21. package/dist/cli/components/Banner.js +20 -0
  22. package/dist/cli/components/Markdown.d.ts +14 -0
  23. package/dist/cli/components/Markdown.js +324 -0
  24. package/dist/cli/components/Message.d.ts +14 -0
  25. package/dist/cli/components/Message.js +17 -0
  26. package/dist/cli/components/Spinner.d.ts +7 -0
  27. package/dist/cli/components/Spinner.js +19 -0
  28. package/dist/cli/components/StatusBar.d.ts +14 -0
  29. package/dist/cli/components/StatusBar.js +19 -0
  30. package/dist/cli/components/Suggestions.d.ts +13 -0
  31. package/dist/cli/components/Suggestions.js +14 -0
  32. package/dist/cli/entry.d.ts +2 -0
  33. package/dist/cli/entry.js +61 -0
  34. package/dist/cli/helpers.d.ts +14 -0
  35. package/dist/cli/helpers.js +32 -0
  36. package/dist/cli/hooks/useAutocomplete.d.ts +11 -0
  37. package/dist/cli/hooks/useAutocomplete.js +71 -0
  38. package/dist/cli/hooks/useHistory.d.ts +13 -0
  39. package/dist/cli/hooks/useHistory.js +106 -0
  40. package/dist/cli/hooks/useSession.d.ts +16 -0
  41. package/dist/cli/hooks/useSession.js +133 -0
  42. package/dist/cli/index.d.ts +2 -0
  43. package/dist/cli/index.js +41 -0
  44. package/dist/cli/keystore.d.ts +28 -0
  45. package/dist/cli/keystore.js +59 -0
  46. package/dist/cli/onboarding.d.ts +18 -0
  47. package/dist/cli/onboarding.js +306 -0
  48. package/dist/cli/personality.d.ts +34 -0
  49. package/dist/cli/personality.js +196 -0
  50. package/dist/cli/repl.d.ts +20 -0
  51. package/dist/cli/repl.js +338 -0
  52. package/dist/cli/theme.d.ts +25 -0
  53. package/dist/cli/theme.js +64 -0
  54. package/dist/core/compile/compiler.d.ts +25 -0
  55. package/dist/core/compile/compiler.js +229 -0
  56. package/dist/core/compile/index.d.ts +2 -0
  57. package/dist/core/compile/index.js +1 -0
  58. package/dist/core/config.d.ts +10 -0
  59. package/dist/core/config.js +92 -0
  60. package/dist/core/index.d.ts +12 -0
  61. package/dist/core/index.js +11 -0
  62. package/dist/core/ingest/image.d.ts +3 -0
  63. package/dist/core/ingest/image.js +61 -0
  64. package/dist/core/ingest/index.d.ts +18 -0
  65. package/dist/core/ingest/index.js +79 -0
  66. package/dist/core/ingest/pdf.d.ts +2 -0
  67. package/dist/core/ingest/pdf.js +36 -0
  68. package/dist/core/ingest/text.d.ts +2 -0
  69. package/dist/core/ingest/text.js +38 -0
  70. package/dist/core/ingest/web.d.ts +2 -0
  71. package/dist/core/ingest/web.js +202 -0
  72. package/dist/core/lint/index.d.ts +1 -0
  73. package/dist/core/lint/index.js +1 -0
  74. package/dist/core/lint/linter.d.ts +27 -0
  75. package/dist/core/lint/linter.js +147 -0
  76. package/dist/core/llm/index.d.ts +2 -0
  77. package/dist/core/llm/index.js +1 -0
  78. package/dist/core/llm/provider.d.ts +15 -0
  79. package/dist/core/llm/provider.js +241 -0
  80. package/dist/core/prompts.d.ts +28 -0
  81. package/dist/core/prompts.js +374 -0
  82. package/dist/core/query/engine.d.ts +29 -0
  83. package/dist/core/query/engine.js +131 -0
  84. package/dist/core/query/index.d.ts +2 -0
  85. package/dist/core/query/index.js +1 -0
  86. package/dist/core/sanitization.d.ts +11 -0
  87. package/dist/core/sanitization.js +50 -0
  88. package/dist/core/storage/filesystem.d.ts +23 -0
  89. package/dist/core/storage/filesystem.js +106 -0
  90. package/dist/core/storage/index.d.ts +2 -0
  91. package/dist/core/storage/index.js +2 -0
  92. package/dist/core/storage/sqlite.d.ts +30 -0
  93. package/dist/core/storage/sqlite.js +104 -0
  94. package/dist/core/types.d.ts +95 -0
  95. package/dist/core/types.js +4 -0
  96. package/dist/core/utils.d.ts +8 -0
  97. package/dist/core/utils.js +94 -0
  98. package/dist/core/wiki/index.d.ts +1 -0
  99. package/dist/core/wiki/index.js +1 -0
  100. package/dist/core/wiki/wiki.d.ts +19 -0
  101. package/dist/core/wiki/wiki.js +37 -0
  102. package/dist/index.d.ts +2 -0
  103. package/dist/index.js +3 -0
  104. package/package.json +54 -0
package/README.md ADDED
@@ -0,0 +1,324 @@
1
+ <p align="center">
2
+ <strong style="font-size: 2em; color: #6C3BAA;">browzy.ai</strong>
3
+ </p>
4
+
5
+ <p align="center">
6
+ <em>Your knowledge, compiled.</em>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="#quickstart">Quickstart</a> &middot;
11
+ <a href="#how-it-works">How it works</a> &middot;
12
+ <a href="#commands">Commands</a> &middot;
13
+ <a href="#architecture">Architecture</a> &middot;
14
+ <a href="#configuration">Configuration</a>
15
+ </p>
16
+
17
+ ---
18
+
19
+ **browzy** is an LLM-powered personal knowledge base engine. Feed it articles, PDFs, images, and web links. It compiles everything into an interconnected wiki, then lets you ask questions, run health checks, and generate reports against your collected knowledge.
20
+
21
+ ```
22
+ $ browzy
23
+
24
+ ██████╗ ██████╗ ██████╗ ██╗ ██╗███████╗██╗ ██╗
25
+ ██╔══██╗██╔══██╗██╔═══██╗██║ ██║╚══███╔╝╚██╗ ██╔╝
26
+ ██████╔╝██████╔╝██║ ██║██║ █╗ ██║ ███╔╝ ╚████╔╝
27
+ ██╔══██╗██╔══██╗██║ ██║██║███╗██║ ███╔╝ ╚██╔╝
28
+ ██████╔╝██║ ██║╚██████╔╝╚███╔███╔╝███████╗ ██║
29
+ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝ ╚═╝
30
+
31
+ Good morning, Vihari. What are we researching today?
32
+
33
+ sources 12 articles 34 concepts 87
34
+ model claude-sonnet-4-20250514
35
+
36
+ ────────────────────────────────────────────────────────
37
+ › explain Helly's theorem and its applications
38
+ ```
39
+
40
+ ## Quickstart
41
+
42
+ ```bash
43
+ # Install globally
44
+ npm install -g browzy
45
+
46
+ # First launch — guided setup (name, API key, model picker)
47
+ browzy
48
+
49
+ # Or set your API key and init manually
50
+ export ANTHROPIC_API_KEY=sk-ant-...
51
+ browzy init
52
+ ```
53
+
54
+ **Add your first source:**
55
+
56
+ ```bash
57
+ # From the interactive prompt
58
+ /add https://arxiv.org/html/2604.01548v1
59
+
60
+ # Or from the command line
61
+ browzy ingest https://en.wikipedia.org/wiki/Transformer_(deep_learning_model)
62
+ browzy ingest ~/Downloads/paper.pdf
63
+ browzy ingest ~/research/notes.md
64
+ browzy compile
65
+ ```
66
+
67
+ **Ask questions:**
68
+
69
+ ```
70
+ › What are the key components of the transformer architecture?
71
+ › How does multi-head attention differ from self-attention?
72
+ › /health
73
+ ```
74
+
75
+ ## How it works
76
+
77
+ ```
78
+ 1. ADD 2. COMPILE 3. ASK
79
+ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
80
+ │ URLs │ │ LLM reads │ │ "Why did │
81
+ │ PDFs │────────▶│ raw sources, │────────▶│ transformers│
82
+ │ Images │ │ writes wiki │ │ replace │
83
+ │ Text files │ │ articles │ │ RNNs?" │
84
+ └──────────────┘ └──────────────┘ └──────────────┘
85
+ │ │ │
86
+ ▼ ▼ ▼
87
+ raw/*.md wiki/*.md Terminal output
88
+ _manifest.json _index.json or saved .md/.marp
89
+ SQLite index SQLite FTS filed back into wiki
90
+ ```
91
+
92
+ **The loop that compounds:**
93
+
94
+ 1. **Ingest** raw sources (web, PDF, image, text) into `raw/`
95
+ 2. **Compile** sources into interconnected wiki articles with cross-references, citations, and concept extraction
96
+ 3. **Ask** questions — browzy searches the wiki via FTS, gathers relevant articles, and synthesizes an answer with the LLM
97
+ 4. **Save** answers back into the wiki, so your explorations always build on themselves
98
+ 5. **Lint** the wiki for contradictions, broken links, gaps, and quality issues
99
+
100
+ ## Commands
101
+
102
+ browzy has two interfaces: an **interactive REPL** (type `browzy`) and a **CLI** (type `browzy <command>`).
103
+
104
+ ### Interactive mode
105
+
106
+ Type `browzy` to enter the interactive prompt. Just type a question to query your knowledge base, or use `/` commands:
107
+
108
+ | Command | Description |
109
+ |---------|-------------|
110
+ | `/add <sources...>` | Add URLs, PDFs, images, or text files. Ingests + auto-compiles. |
111
+ | `/ask <question>` | Explicitly query the knowledge base |
112
+ | `/health` | Stats + wiki health checks (contradictions, gaps, orphans) |
113
+ | `/rebuild` | Force recompile all sources into the wiki |
114
+ | `/format <md\|marp\|json>` | Set output format for answers |
115
+ | `/save` | Toggle auto-save for query outputs |
116
+ | `/export [filename]` | Export current session as markdown |
117
+ | `/help` | Show all commands |
118
+ | `/quit` | Exit |
119
+
120
+ **Keyboard shortcuts:**
121
+
122
+ | Key | Action |
123
+ |-----|--------|
124
+ | `Tab` | Autocomplete commands |
125
+ | `↑` `↓` | Browse command history |
126
+ | `→` | Accept ghost text suggestion |
127
+ | `Ctrl+E` | Open current input in `$EDITOR` |
128
+ | `Ctrl+S` | Stash/restore input draft |
129
+ | `Ctrl+C` | Clear input or exit |
130
+ | `Ctrl+D` | Exit |
131
+
132
+ ### CLI mode
133
+
134
+ For scripting and pipelines:
135
+
136
+ ```bash
137
+ browzy init # Initialize a knowledge base
138
+ browzy ingest <url-or-file> # Ingest a source
139
+ browzy compile # Compile wiki from sources
140
+ browzy query "your question" # Ask a question
141
+ browzy search "term" # Full-text search
142
+ browzy lint # Run health checks
143
+ browzy status # Show KB overview
144
+ ```
145
+
146
+ ## Source types
147
+
148
+ | Type | Input | What happens |
149
+ |------|-------|--------------|
150
+ | **Web** | URL | Fetches HTML, converts to markdown, downloads images |
151
+ | **PDF** | `.pdf` file | Extracts text and metadata |
152
+ | **Image** | `.png`, `.jpg`, `.webp`, etc. | Copies to images dir, generates LLM description for indexing |
153
+ | **Text** | `.txt` file | Ingests with frontmatter |
154
+ | **Markdown** | `.md` file | Ingests as-is with frontmatter |
155
+
156
+ Multiple sources at once:
157
+ ```
158
+ /add https://arxiv.org/html/2604.01548v1 ~/paper.pdf ~/notes.md
159
+ ```
160
+
161
+ Drag and drop files into the terminal to paste their paths.
162
+
163
+ ## Output formats
164
+
165
+ | Format | Command | Use case |
166
+ |--------|---------|----------|
167
+ | **Markdown** | `/format markdown` | Default. Rich text with headers, lists, code blocks, LaTeX |
168
+ | **Marp** | `/format marp` | Slide decks viewable in Obsidian (Marp plugin) or exported to PDF |
169
+ | **JSON** | `/format json` | Structured data with sections, confidence scores, and gap analysis |
170
+
171
+ ## Architecture
172
+
173
+ ```
174
+ browzy/
175
+ ├── src/
176
+ │ ├── core/ # The engine (importable as a library)
177
+ │ │ ├── prompts.ts # All system prompts (412 lines, 11 prompts)
178
+ │ │ ├── config.ts # Config loading + env var overrides
179
+ │ │ ├── types.ts # Shared TypeScript types
180
+ │ │ ├── ingest/ # Source processors (web, PDF, image, text)
181
+ │ │ ├── compile/ # Wiki compiler (incremental, concept extraction)
182
+ │ │ ├── query/ # Q&A engine (FTS search + LLM synthesis)
183
+ │ │ ├── lint/ # Health checks (links, orphans, contradictions)
184
+ │ │ ├── wiki/ # Wiki CRUD operations
185
+ │ │ ├── storage/
186
+ │ │ │ ├── filesystem.ts # .md file I/O with path traversal protection
187
+ │ │ │ └── sqlite.ts # FTS5 search index + metadata
188
+ │ │ └── llm/
189
+ │ │ └── provider.ts # Pluggable LLM (Claude + OpenAI, real streaming)
190
+ │ └── cli/ # Terminal interface
191
+ │ ├── entry.tsx # Entry point (Ink app or Commander CLI)
192
+ │ ├── app.tsx # Main Ink app (React for terminals)
193
+ │ ├── theme.ts # Color system (dark/light, brand palette)
194
+ │ ├── onboarding.ts # First-run setup (name, API key, model picker)
195
+ │ ├── components/
196
+ │ │ ├── Banner.tsx # Welcome screen with stats
197
+ │ │ ├── Markdown.tsx # Terminal markdown renderer (+ LaTeX → Unicode)
198
+ │ │ ├── Message.tsx # User/AI/system message display
199
+ │ │ ├── Spinner.tsx # Animated loading indicator
200
+ │ │ ├── StatusBar.tsx # Persistent footer bar
201
+ │ │ └── Suggestions.tsx # Autocomplete dropdown
202
+ │ └── hooks/
203
+ │ ├── useHistory.ts # Persistent command history
204
+ │ ├── useAutocomplete.ts # Slash command autocomplete
205
+ │ └── useSession.ts # Session persistence + export
206
+ └── data/ # Lives at ~/.browzy/ (not in repo)
207
+ ├── raw/ # Ingested source documents
208
+ │ ├── *.md # Converted sources with YAML frontmatter
209
+ │ ├── images/ # Downloaded/copied images
210
+ │ └── _manifest.json # Source registry
211
+ ├── wiki/ # Compiled wiki
212
+ │ ├── *.md # Articles with frontmatter (tags, backlinks, sources)
213
+ │ └── _index.json # Article index + concept map
214
+ ├── output/ # Generated reports, slides, exports
215
+ ├── sessions/ # Saved conversation history
216
+ └── .browzy/
217
+ └── browzy.db # SQLite FTS5 index
218
+ ```
219
+
220
+ ### Key design decisions
221
+
222
+ - **Data lives outside the repo** at `~/.browzy/` by default. Multiple knowledge bases are independently git-trackable.
223
+ - **Explicit storage layer** separates filesystem (`.md` files) from SQLite (indexes, search). Swappable.
224
+ - **Pluggable LLM** with real streaming. Claude is default, OpenAI supported. Both providers support `chat()` and `stream()`.
225
+ - **Core is a library.** `src/core/` is importable — the CLI is just one interface. A web UI or API server can use the same engine.
226
+ - **Ink-based TUI.** React components for the terminal. `<Static>` for completed messages (never re-renders), dynamic section for streaming + input.
227
+
228
+ ### Prompt engineering
229
+
230
+ browzy's prompts are in `src/core/prompts.ts` — 412 lines across 11 specialized prompts. Each is purpose-built:
231
+
232
+ | Prompt | Purpose |
233
+ |--------|---------|
234
+ | `QUERY_SYSTEM_PROMPT` | 8-section prompt for Q&A: identity, context rules, citations, formatting, math, honesty, tone, anti-patterns |
235
+ | `COMPILER_SYSTEM_PROMPT` | Wiki compilation with quality standards and "what makes a bad article" guidance |
236
+ | `LINTER_SYSTEM_PROMPT` | 7-category health check with strict JSON output format |
237
+ | `SEARCH_EXTRACTION_PROMPT` | Domain-aware search term extraction with examples |
238
+ | `CONTRADICTION_HANDLING_PROMPT` | Protocol for when new sources disagree with existing wiki |
239
+ | `CONVERSATION_CONTEXT_PROMPT` | Multi-turn continuity rules (pronouns, follow-ups, corrections) |
240
+ | `ARTICLE_OUTPUT_FORMAT` | Exact parser format for compiled articles |
241
+ | `CONCEPT_EXTRACTION_PROMPT` | Bridging concepts, foundational gaps, missing counterparts |
242
+ | `IMAGE_DESCRIPTION_PROMPT` | Systematic image analysis for indexing |
243
+ | `MARP_OUTPUT_PROMPT` | Full Marp slide deck specification |
244
+ | `JSON_OUTPUT_PROMPT` | Structured JSON output with confidence + gaps |
245
+
246
+ ## Configuration
247
+
248
+ ### Config file
249
+
250
+ browzy looks for config in this order:
251
+ 1. `./browzy.config.json` (current directory)
252
+ 2. `~/.browzy/config.json`
253
+ 3. Environment variables
254
+ 4. Defaults
255
+
256
+ ```json
257
+ {
258
+ "dataDir": "/Users/you/.browzy/default",
259
+ "llm": {
260
+ "provider": "claude",
261
+ "model": "claude-sonnet-4-20250514"
262
+ },
263
+ "compile": {
264
+ "batchSize": 20,
265
+ "extractConcepts": true
266
+ }
267
+ }
268
+ ```
269
+
270
+ ### Environment variables
271
+
272
+ | Variable | Description |
273
+ |----------|-------------|
274
+ | `ANTHROPIC_API_KEY` | Claude API key |
275
+ | `OPENAI_API_KEY` | OpenAI API key (if using OpenAI provider) |
276
+ | `BROWZY_DATA_DIR` | Override data directory |
277
+ | `BROWZY_THEME` | Force `dark` or `light` theme |
278
+ | `EDITOR` | Editor for Ctrl+E (defaults to `vi`) |
279
+
280
+ ### .env file
281
+
282
+ Create a `.env` file in your project directory:
283
+
284
+ ```
285
+ ANTHROPIC_API_KEY=sk-ant-...
286
+ ```
287
+
288
+ ## Obsidian integration
289
+
290
+ browzy's wiki is a directory of `.md` files with YAML frontmatter — fully compatible with Obsidian.
291
+
292
+ 1. Open `~/.browzy/default/wiki/` as an Obsidian vault
293
+ 2. `[[wiki-links]]` work as Obsidian internal links
294
+ 3. Install the Marp plugin to view `/format marp` slide decks
295
+ 4. The graph view shows your wiki's concept network
296
+
297
+ ## Tech stack
298
+
299
+ - **TypeScript** (full stack)
300
+ - **Ink** (React for terminals) + **React 19**
301
+ - **Anthropic SDK** (Claude) + **OpenAI SDK** (GPT)
302
+ - **SQLite** (better-sqlite3) with **FTS5** full-text search
303
+ - **gray-matter** for YAML frontmatter
304
+ - **Turndown** for HTML-to-markdown conversion
305
+ - **pdf-parse** for PDF text extraction
306
+ - **chalk** for terminal colors
307
+ - **Commander.js** for CLI subcommands
308
+
309
+ ## Development
310
+
311
+ ```bash
312
+ git clone https://github.com/VihariKanukollu/browzy.ai.git
313
+ cd browzy.ai
314
+ npm install
315
+ npm run build
316
+ sudo npm link # Makes 'browzy' available globally
317
+
318
+ # Development mode (watch for changes)
319
+ npm run dev
320
+ ```
321
+
322
+ ## License
323
+
324
+ MIT
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ interface ErrorBoundaryState {
3
+ hasError: boolean;
4
+ error?: Error;
5
+ }
6
+ export declare class BrowzyErrorBoundary extends React.Component<{
7
+ children: React.ReactNode;
8
+ }, ErrorBoundaryState> {
9
+ constructor(props: {
10
+ children: React.ReactNode;
11
+ });
12
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
13
+ render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
14
+ }
15
+ export declare const BrowzyApp: React.FC;
16
+ export {};