stellavault 0.4.0 → 0.4.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/CHANGELOG.md +24 -0
- package/README.md +96 -151
- package/package.json +2 -2
- package/packages/cli/dist/commands/draft-cmd.d.ts +5 -0
- package/packages/cli/dist/commands/draft-cmd.js +99 -0
- package/packages/cli/dist/commands/ingest-cmd.js +42 -12
- package/packages/cli/dist/index.js +7 -0
- package/packages/core/dist/api/server.js +109 -0
- package/packages/core/dist/config.d.ts +8 -0
- package/packages/core/dist/config.js +9 -1
- package/packages/core/dist/index.d.ts +2 -2
- package/packages/core/dist/index.js +1 -1
- package/packages/core/dist/intelligence/draft-generator.d.ts +19 -0
- package/packages/core/dist/intelligence/draft-generator.js +161 -0
- package/packages/core/dist/intelligence/file-extractors.d.ts +18 -0
- package/packages/core/dist/intelligence/file-extractors.js +127 -0
- package/packages/core/dist/intelligence/ingest-pipeline.d.ts +4 -3
- package/packages/core/dist/intelligence/ingest-pipeline.js +28 -11
- package/packages/core/dist/mcp/server.js +6 -0
- package/packages/core/dist/mcp/tools/generate-draft.d.ts +34 -0
- package/packages/core/dist/mcp/tools/generate-draft.js +120 -0
- package/packages/core/package.json +16 -1
- package/Autonomous_Knowledge_Foundry.pdf +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.1] - 2026-04-07
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
- **Binary File Ingest** — PDF (unpdf), DOCX (mammoth), PPTX (officeparser), XLSX (SheetJS) text extraction
|
|
7
|
+
- **Auto Pipeline** — `ingest` now auto-runs `compile` → wiki generated automatically
|
|
8
|
+
- **Web File Upload** — Drag & drop files in browser (POST /api/ingest/file, 50MB limit)
|
|
9
|
+
- **Mobile/PWA** — Responsive IngestPanel, service worker registration, installable as app
|
|
10
|
+
- **Express: stellavault draft** — Generate blog/report/outline from vault knowledge
|
|
11
|
+
- **MCP generate-draft** — 20th MCP tool: Claude writes drafts using vault context (free in Claude Code)
|
|
12
|
+
- **CLI --ai flag** — `stellavault draft --ai` uses Claude API for full AI-generated drafts
|
|
13
|
+
- **Configurable folders** — Override raw/_wiki/_literature/ in .stellavault.json
|
|
14
|
+
- **Multilingual embeddings** — paraphrase-multilingual-MiniLM-L12-v2 (50+ languages)
|
|
15
|
+
|
|
16
|
+
### Changes
|
|
17
|
+
- Binary files default to fleeting stage (Zettelkasten principle: all inputs start as fleeting)
|
|
18
|
+
- Repositioned as "Self-compiling knowledge MCP server"
|
|
19
|
+
- .npmignore excludes PDF (was 16MB in npm package)
|
|
20
|
+
- MCP tools: 19 → 20
|
|
21
|
+
|
|
22
|
+
### Fixes
|
|
23
|
+
- CLI YouTube ingest now properly calls extractYouTubeContent
|
|
24
|
+
- officeparser type cast fix (OfficeParserAST → string)
|
|
25
|
+
- unpdf text array handling (pages returned as array, not string)
|
|
26
|
+
|
|
3
27
|
## [0.4.0] - 2026-04-06
|
|
4
28
|
|
|
5
29
|
### Features
|
package/README.md
CHANGED
|
@@ -1,124 +1,89 @@
|
|
|
1
1
|
# Stellavault
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **Self-compiling knowledge MCP server** — ingest anything, auto-organize into Zettelkasten wiki, and let Claude access your entire knowledge base.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Drop a PDF, paste a YouTube link, type a thought — Stellavault compiles it into structured knowledge, connects the dots, and gives your AI agent full access through 20 MCP tools.
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<img src="images/screenshots/graph-dark-full.png" alt="3D Knowledge Graph" width="800" />
|
|
9
9
|
<br><em>Your vault as a neural network. Clusters form constellations.</em>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Two Core Ideas
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|---------|---------------------|
|
|
16
|
-
| Notes pile up but never become knowledge | **Self-compiling wiki** — raw notes auto-organized into linked concepts |
|
|
17
|
-
| You forget what you wrote | **FSRS decay tracking** — see what's fading, get review suggestions |
|
|
18
|
-
| Search finds words, not meaning | **Hybrid AI search** — BM25 + vector + RRF fusion, locally |
|
|
19
|
-
| AI agents can't access your knowledge | **17 MCP tools** — Claude remembers everything you know |
|
|
20
|
-
| No way to see the big picture | **3D neural graph** — constellations, heatmaps, timeline |
|
|
21
|
-
|
|
22
|
-
## 5-Minute Setup
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
# Install
|
|
26
|
-
npm install -g stellavault
|
|
27
|
-
|
|
28
|
-
# Interactive setup (indexes your vault + verifies search)
|
|
29
|
-
stellavault init
|
|
30
|
-
|
|
31
|
-
# Launch 3D graph + API server
|
|
32
|
-
stellavault graph
|
|
14
|
+
**1. "Drop it and forget it"** (Karpathy's Self-Compiling Knowledge)
|
|
33
15
|
```
|
|
16
|
+
Any input → auto-classify → raw/ → compile → wiki → connected knowledge
|
|
17
|
+
```
|
|
18
|
+
PDF, DOCX, YouTube, URL, text — everything goes through the same pipeline. You never manually organize.
|
|
34
19
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## Give Your AI Agent Memory
|
|
38
|
-
|
|
20
|
+
**2. "Claude knows what you know"** (MCP Integration)
|
|
39
21
|
```bash
|
|
40
22
|
claude mcp add stellavault -- stellavault serve
|
|
41
23
|
```
|
|
24
|
+
20 MCP tools give Claude direct access to search, ask, draft, and navigate your entire knowledge base.
|
|
42
25
|
|
|
43
|
-
|
|
26
|
+
## 5-Minute Setup
|
|
44
27
|
|
|
45
|
-
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g stellavault
|
|
30
|
+
stellavault init # Interactive setup + vault indexing
|
|
31
|
+
stellavault graph # Launch 3D graph + API server
|
|
32
|
+
```
|
|
46
33
|
|
|
47
|
-
|
|
48
|
-
<img src="images/screenshots/graph-search-highlight.png" alt="Semantic Search" width="800" />
|
|
49
|
-
<br><em>Search by meaning. Matching nodes pulse and glow.</em>
|
|
50
|
-
</p>
|
|
34
|
+
> **Prerequisites**: Node.js 20+
|
|
51
35
|
|
|
52
|
-
|
|
53
|
-
<summary>More screenshots</summary>
|
|
36
|
+
## The Pipeline
|
|
54
37
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
| <img src="images/screenshots/graph-light-mode.png" width="260" /> | <img src="images/screenshots/graph-timeline.png" width="260" /> | <img src="images/screenshots/graph-heatmap.png" width="260" /> |
|
|
38
|
+
```
|
|
39
|
+
Capture ──→ Organize ──→ Distill ──→ Express
|
|
58
40
|
|
|
59
|
-
|
|
41
|
+
stellavault ingest <anything> # PDF, DOCX, URL, YouTube, text
|
|
42
|
+
→ auto-extract text # unpdf, mammoth, yt-dlp
|
|
43
|
+
→ raw/ (fleeting) # Zettelkasten inbox
|
|
44
|
+
→ compile → _wiki/ # Auto: concepts + backlinks
|
|
45
|
+
→ stellavault draft "topic" # Blog, report, or outline
|
|
46
|
+
```
|
|
60
47
|
|
|
61
|
-
|
|
48
|
+
### Ingest Anything
|
|
62
49
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
stellavault
|
|
67
|
-
stellavault ingest
|
|
68
|
-
stellavault
|
|
69
|
-
|
|
70
|
-
stellavault ask "question" # Q&A with auto-filing (--save)
|
|
71
|
-
stellavault lint # Knowledge health check (score 0-100)
|
|
72
|
-
```
|
|
50
|
+
| Input | How |
|
|
51
|
+
|-------|-----|
|
|
52
|
+
| PDF, DOCX, PPTX, XLSX | `stellavault ingest report.pdf` — auto text extraction |
|
|
53
|
+
| YouTube | `stellavault ingest https://youtu.be/...` — transcript + timestamps |
|
|
54
|
+
| URL | `stellavault ingest https://...` — HTML → clean text |
|
|
55
|
+
| Text | `stellavault ingest "quick thought"` |
|
|
56
|
+
| Web UI | Drag & drop files in browser (mobile too) |
|
|
73
57
|
|
|
74
|
-
|
|
58
|
+
### Express: Get Knowledge Out
|
|
75
59
|
|
|
76
60
|
```bash
|
|
77
|
-
stellavault
|
|
78
|
-
stellavault
|
|
79
|
-
stellavault
|
|
80
|
-
stellavault
|
|
81
|
-
stellavault review # FSRS spaced repetition session
|
|
82
|
-
stellavault gaps # Knowledge gap detection
|
|
61
|
+
stellavault draft "AI" # Rule-based scaffold (free)
|
|
62
|
+
stellavault draft "AI" --ai # Claude API writes full draft ($0.03)
|
|
63
|
+
stellavault draft "AI" --format report # Formal report format
|
|
64
|
+
stellavault draft --format outline # All-knowledge outline
|
|
83
65
|
```
|
|
84
66
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
| Feature | Command | What it does |
|
|
88
|
-
|---------|---------|-------------|
|
|
89
|
-
| **FSRS Decay** | `sv decay` | Track memory strength with spaced repetition |
|
|
90
|
-
| **Gap Detection** | `sv gaps` | Find missing connections between topics |
|
|
91
|
-
| **Contradiction Detection** | `sv contradictions` | Spot conflicting statements |
|
|
92
|
-
| **Duplicate Detection** | `sv duplicates` | Find redundant notes |
|
|
93
|
-
| **Knowledge Lint** | `sv lint` | Health score + issues + suggestions |
|
|
94
|
-
| **Learning Path** | `sv learn` | AI-recommended review order |
|
|
95
|
-
| **Semantic Evolution** | MCP `get-evolution` | Track how ideas change over time |
|
|
96
|
-
| **Code Linker** | MCP `link-code` | Connect code files to knowledge notes |
|
|
97
|
-
| **Adaptive Search** | MCP `search` | Context-aware result reranking |
|
|
98
|
-
|
|
99
|
-
## Zettelkasten Automation
|
|
67
|
+
Or in Claude Code: *"Write a blog post about machine learning from my notes"* — Claude uses MCP `generate-draft` tool (free, no API key).
|
|
100
68
|
|
|
101
|
-
|
|
69
|
+
## Daily Commands
|
|
102
70
|
|
|
103
71
|
```bash
|
|
104
|
-
stellavault
|
|
105
|
-
stellavault
|
|
106
|
-
stellavault
|
|
107
|
-
stellavault
|
|
108
|
-
stellavault
|
|
72
|
+
stellavault ask "What did I learn about X?" # Q&A from vault
|
|
73
|
+
stellavault brief # Morning knowledge briefing
|
|
74
|
+
stellavault decay # What's fading from memory?
|
|
75
|
+
stellavault lint # Health score (0-100)
|
|
76
|
+
stellavault learn # AI learning path
|
|
77
|
+
stellavault digest --visual # Weekly Mermaid chart report
|
|
109
78
|
```
|
|
110
79
|
|
|
111
|
-
|
|
112
|
-
- **Luhmann index codes** — auto-assigned hierarchical numbering (1A → 1A1)
|
|
113
|
-
- **Inbox Zero** — processed notes auto-archived
|
|
114
|
-
- **Atomicity check** — detects notes with too many topics
|
|
115
|
-
- **3-stage classification** — fleeting → literature → permanent
|
|
116
|
-
|
|
117
|
-
## MCP Tools (17)
|
|
80
|
+
## MCP Tools (20)
|
|
118
81
|
|
|
119
82
|
| Tool | What it does |
|
|
120
83
|
|------|-------------|
|
|
121
84
|
| `search` | Hybrid search (BM25 + vector + RRF) |
|
|
85
|
+
| `ask` | Q&A with optional vault filing |
|
|
86
|
+
| `generate-draft` | Gather vault context for AI draft writing |
|
|
122
87
|
| `get-document` | Full document with metadata |
|
|
123
88
|
| `get-related` | Semantically similar documents |
|
|
124
89
|
| `list-topics` | Topic cloud |
|
|
@@ -128,7 +93,6 @@ stellavault autopilot # Full cycle: inbox → compile → lin
|
|
|
128
93
|
| `detect-gaps` | Knowledge gap analysis |
|
|
129
94
|
| `get-evolution` | Semantic drift tracking |
|
|
130
95
|
| `link-code` | Code-knowledge connections |
|
|
131
|
-
| `ask` | Q&A with optional vault filing |
|
|
132
96
|
| `create-knowledge-node` | AI creates wiki-quality notes |
|
|
133
97
|
| `create-knowledge-link` | AI connects existing notes |
|
|
134
98
|
| `log-decision` / `find-decisions` | Decision journal |
|
|
@@ -136,38 +100,53 @@ stellavault autopilot # Full cycle: inbox → compile → lin
|
|
|
136
100
|
| `generate-claude-md` | Auto-generate CLAUDE.md |
|
|
137
101
|
| `export` | JSON/CSV export |
|
|
138
102
|
|
|
139
|
-
##
|
|
103
|
+
## Zettelkasten (Luhmann + Karpathy)
|
|
140
104
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
- **Export** — PNG screenshots + WebM recording
|
|
105
|
+
```bash
|
|
106
|
+
stellavault fleeting "raw idea" # → raw/
|
|
107
|
+
stellavault ingest report.pdf # → auto text extract → raw/
|
|
108
|
+
stellavault compile # → raw/ → _wiki/ (concepts + backlinks)
|
|
109
|
+
stellavault promote note.md --to permanent # Upgrade stage
|
|
110
|
+
stellavault autopilot # Full cycle: inbox → compile → lint → archive
|
|
111
|
+
```
|
|
149
112
|
|
|
150
|
-
|
|
113
|
+
- **3-stage flow**: fleeting → literature → permanent
|
|
114
|
+
- **Luhmann index codes**: auto-assigned (1A → 1A1)
|
|
115
|
+
- **Frontmatter-first scanning**: 10x token reduction
|
|
116
|
+
- **Configurable folders**: override raw/_wiki/_literature/ in `.stellavault.json`
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"vaultPath": "/path/to/vault",
|
|
121
|
+
"folders": {
|
|
122
|
+
"fleeting": "01-Inbox",
|
|
123
|
+
"literature": "02-Reading",
|
|
124
|
+
"permanent": "03-Notes",
|
|
125
|
+
"wiki": "04-Wiki"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
151
129
|
|
|
152
|
-
|
|
130
|
+
## Intelligence
|
|
153
131
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
132
|
+
| Feature | Command |
|
|
133
|
+
|---------|---------|
|
|
134
|
+
| FSRS Decay | `sv decay` — spaced repetition memory tracking |
|
|
135
|
+
| Gap Detection | `sv gaps` — missing connections between topics |
|
|
136
|
+
| Contradictions | `sv contradictions` — conflicting statements |
|
|
137
|
+
| Duplicates | `sv duplicates` — redundant notes |
|
|
138
|
+
| Learning Path | `sv learn` — AI review recommendations |
|
|
139
|
+
| Code Linker | MCP `link-code` — connect code to knowledge |
|
|
158
140
|
|
|
159
|
-
|
|
141
|
+
## 3D Visualization
|
|
160
142
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
│ ├── graph/ 3D visualization (React Three Fiber)
|
|
169
|
-
│ └── sync/ Notion ↔ Obsidian sync
|
|
170
|
-
```
|
|
143
|
+
- Neural graph with cluster coloring
|
|
144
|
+
- Constellation view (MST star patterns)
|
|
145
|
+
- Heatmap overlay (activity score)
|
|
146
|
+
- Timeline slider (creation/modification filter)
|
|
147
|
+
- Decay overlay (fading knowledge)
|
|
148
|
+
- Dark/Light theme
|
|
149
|
+
- Mobile responsive + PWA installable
|
|
171
150
|
|
|
172
151
|
## Tech Stack
|
|
173
152
|
|
|
@@ -175,46 +154,12 @@ stellavault/
|
|
|
175
154
|
|-------|------|
|
|
176
155
|
| Runtime | Node.js 20+ (ESM, TypeScript) |
|
|
177
156
|
| Vector Store | SQLite-vec (local, no server) |
|
|
178
|
-
| Embedding |
|
|
157
|
+
| Embedding | paraphrase-multilingual-MiniLM-L12-v2 (local, 50+ languages) |
|
|
179
158
|
| Search | BM25 + Cosine + RRF Fusion |
|
|
159
|
+
| File Parsing | unpdf, mammoth, officeparser, SheetJS |
|
|
180
160
|
| Memory | FSRS (Free Spaced Repetition Scheduler) |
|
|
181
|
-
| 3D | React Three Fiber + Three.js
|
|
182
|
-
|
|
|
183
|
-
| AI | MCP (Model Context Protocol) |
|
|
184
|
-
| Security | AES-256-GCM, HMAC-SHA256, Differential Privacy |
|
|
185
|
-
|
|
186
|
-
## Troubleshooting
|
|
187
|
-
|
|
188
|
-
<details>
|
|
189
|
-
<summary>"Stellavault API server not found"</summary>
|
|
190
|
-
|
|
191
|
-
The Obsidian plugin and 3D graph require the API server. Open a terminal in your vault:
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
stellavault graph
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
Default port: 3333. Change in `.stellavault.json`: `{ "mcp": { "port": 3334 } }`
|
|
198
|
-
</details>
|
|
199
|
-
|
|
200
|
-
<details>
|
|
201
|
-
<summary>"No documents indexed"</summary>
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
stellavault index /path/to/your/vault
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
First indexing takes 2-5 minutes for large vaults (1000+ notes).
|
|
208
|
-
</details>
|
|
209
|
-
|
|
210
|
-
<details>
|
|
211
|
-
<summary>Port conflict</summary>
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
# Use a different port
|
|
215
|
-
stellavault graph --port 3334
|
|
216
|
-
```
|
|
217
|
-
</details>
|
|
161
|
+
| 3D | React Three Fiber + Three.js |
|
|
162
|
+
| AI | MCP (Model Context Protocol) + Anthropic SDK |
|
|
218
163
|
|
|
219
164
|
## License
|
|
220
165
|
|
|
@@ -223,5 +168,5 @@ MIT
|
|
|
223
168
|
## Links
|
|
224
169
|
|
|
225
170
|
- [Obsidian Plugin](https://github.com/Evanciel/stellavault-obsidian)
|
|
226
|
-
- [
|
|
227
|
-
- [
|
|
171
|
+
- [npm](https://www.npmjs.com/package/stellavault)
|
|
172
|
+
- [GitHub Releases](https://github.com/Evanciel/stellavault/releases)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stellavault",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Self-compiling knowledge MCP server — ingest anything, auto-organize into Zettelkasten wiki, search with AI, and let Claude access your entire knowledge base.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/Evanciel/stellavault"
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// stellavault draft — Express: 지식에서 초안 생성
|
|
2
|
+
// 카파시 자가 컴파일 → 외부 표현의 출구
|
|
3
|
+
// 두 가지 모드: rule-based (무료) + --ai (Claude API로 실제 글 생성)
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { loadConfig } from '@stellavault/core';
|
|
6
|
+
import { generateDraft } from '@stellavault/core/intelligence/draft-generator';
|
|
7
|
+
export async function draftCommand(topic, options) {
|
|
8
|
+
const config = loadConfig();
|
|
9
|
+
if (!config.vaultPath) {
|
|
10
|
+
console.error(chalk.red('No vault configured. Run `stellavault init` first.'));
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
const format = (options.format ?? 'blog');
|
|
14
|
+
try {
|
|
15
|
+
// Step 1: rule-based 초안 생성 (스캐폴딩 + 소스 수집)
|
|
16
|
+
const result = generateDraft(config.vaultPath, { topic, format }, config.folders);
|
|
17
|
+
if (options.ai) {
|
|
18
|
+
// Step 2: --ai 모드 → Claude API로 실제 글 생성
|
|
19
|
+
console.log(chalk.dim(' AI mode: generating with Claude...'));
|
|
20
|
+
await enhanceWithAI(config.vaultPath, result.filePath, topic ?? 'knowledge', format);
|
|
21
|
+
}
|
|
22
|
+
console.log(chalk.green(`Draft generated: ${result.title}`));
|
|
23
|
+
console.log(chalk.dim(` Format: ${format}`));
|
|
24
|
+
console.log(chalk.dim(` Mode: ${options.ai ? 'AI-enhanced (Claude)' : 'rule-based'}`));
|
|
25
|
+
console.log(chalk.dim(` Saved: ${result.filePath}`));
|
|
26
|
+
console.log(chalk.dim(` Words: ${result.wordCount}`));
|
|
27
|
+
console.log(chalk.dim(` Sources: ${result.sourceCount} documents`));
|
|
28
|
+
if (result.concepts.length > 0) {
|
|
29
|
+
console.log(chalk.dim(` Concepts: ${result.concepts.join(', ')}`));
|
|
30
|
+
}
|
|
31
|
+
console.log('');
|
|
32
|
+
if (!options.ai) {
|
|
33
|
+
console.log(chalk.dim('Tip: Use --ai to generate with Claude API, or use MCP generate-draft tool in Claude Code.'));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
console.error(chalk.red(err instanceof Error ? err.message : 'Draft generation failed'));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function enhanceWithAI(vaultPath, draftPath, topic, format) {
|
|
42
|
+
const { readFileSync, writeFileSync } = await import('node:fs');
|
|
43
|
+
const { resolve } = await import('node:path');
|
|
44
|
+
const fullPath = resolve(vaultPath, draftPath);
|
|
45
|
+
const scaffold = readFileSync(fullPath, 'utf-8');
|
|
46
|
+
// Extract source excerpts from scaffold
|
|
47
|
+
const excerpts = scaffold
|
|
48
|
+
.split('\n')
|
|
49
|
+
.filter(l => l.startsWith('> '))
|
|
50
|
+
.map(l => l.slice(2))
|
|
51
|
+
.join('\n');
|
|
52
|
+
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
53
|
+
if (!apiKey) {
|
|
54
|
+
console.error(chalk.yellow(' ANTHROPIC_API_KEY not set. Falling back to rule-based draft.'));
|
|
55
|
+
console.error(chalk.yellow(' Set it with: export ANTHROPIC_API_KEY=sk-ant-...'));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const Anthropic = (await import('@anthropic-ai/sdk')).default;
|
|
60
|
+
const client = new Anthropic({ apiKey });
|
|
61
|
+
const message = await client.messages.create({
|
|
62
|
+
model: 'claude-sonnet-4-20250514',
|
|
63
|
+
max_tokens: 4096,
|
|
64
|
+
messages: [{
|
|
65
|
+
role: 'user',
|
|
66
|
+
content: `You are writing a ${format} about "${topic}" based ONLY on the following knowledge notes.
|
|
67
|
+
Do not add information beyond what's in the notes. Write in the same language as the source material.
|
|
68
|
+
Use [[title]] wikilink format for citations.
|
|
69
|
+
|
|
70
|
+
SOURCE NOTES:
|
|
71
|
+
${excerpts.slice(0, 8000)}
|
|
72
|
+
|
|
73
|
+
Write a complete, well-structured ${format}. No TODO placeholders.`,
|
|
74
|
+
}],
|
|
75
|
+
});
|
|
76
|
+
const aiContent = message.content[0];
|
|
77
|
+
if (aiContent.type === 'text') {
|
|
78
|
+
const enhanced = `---
|
|
79
|
+
title: "Draft: ${topic}"
|
|
80
|
+
type: draft
|
|
81
|
+
format: ${format}
|
|
82
|
+
mode: ai-enhanced
|
|
83
|
+
sources: ${excerpts.split('\n').length} excerpts
|
|
84
|
+
created: ${new Date().toISOString()}
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
${aiContent.text}
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
*Generated by \`stellavault draft --ai\` using Claude API at ${new Date().toISOString()}*
|
|
91
|
+
`;
|
|
92
|
+
writeFileSync(fullPath, enhanced, 'utf-8');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
console.error(chalk.yellow(` AI enhancement failed: ${err instanceof Error ? err.message : 'unknown'}. Keeping rule-based draft.`));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=draft-cmd.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { loadConfig, ingest, promoteNote } from '@stellavault/core';
|
|
4
4
|
import { readFileSync, existsSync } from 'node:fs';
|
|
5
|
-
import { extname } from 'node:path';
|
|
5
|
+
import { extname, resolve } from 'node:path';
|
|
6
6
|
export async function ingestCommand(input, options) {
|
|
7
7
|
if (!input) {
|
|
8
8
|
console.error(chalk.yellow('Usage: stellavault ingest <url|file|text> [--tags t1,t2] [--stage fleeting|literature|permanent]'));
|
|
@@ -85,15 +85,46 @@ export async function ingestCommand(input, options) {
|
|
|
85
85
|
else if (existsSync(input)) {
|
|
86
86
|
// 파일
|
|
87
87
|
const ext = extname(input).toLowerCase();
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
const binaryExts = new Set(['.pdf', '.docx', '.pptx', '.xlsx', '.xls']);
|
|
89
|
+
if (binaryExts.has(ext)) {
|
|
90
|
+
// 바이너리 파일: 전용 파서로 텍스트 추출
|
|
91
|
+
try {
|
|
92
|
+
const { extractFileContent } = await import('@stellavault/core/intelligence/file-extractors');
|
|
93
|
+
const extracted = await extractFileContent(resolve(input));
|
|
94
|
+
console.log(chalk.dim(` Extracted ${extracted.metadata.wordCount} words from ${ext} file`));
|
|
95
|
+
ingestInput = {
|
|
96
|
+
type: extracted.sourceFormat,
|
|
97
|
+
content: extracted.text,
|
|
98
|
+
tags: [...tags, extracted.sourceFormat],
|
|
99
|
+
stage, // 제텔카스텐: 모든 인풋은 fleeting에서 시작
|
|
100
|
+
title: options.title ?? extracted.metadata.title,
|
|
101
|
+
source: input,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
console.error(chalk.yellow(`Binary file extraction failed, saving as-is. (${err instanceof Error ? err.message : 'error'})`));
|
|
106
|
+
ingestInput = {
|
|
107
|
+
type: 'file',
|
|
108
|
+
content: readFileSync(input, 'utf-8'),
|
|
109
|
+
tags,
|
|
110
|
+
stage,
|
|
111
|
+
title: options.title,
|
|
112
|
+
source: input,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// 텍스트 파일: 기존 동작
|
|
118
|
+
const fileContent = readFileSync(input, 'utf-8');
|
|
119
|
+
ingestInput = {
|
|
120
|
+
type: 'file',
|
|
121
|
+
content: fileContent,
|
|
122
|
+
tags,
|
|
123
|
+
stage,
|
|
124
|
+
title: options.title,
|
|
125
|
+
source: input,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
97
128
|
}
|
|
98
129
|
else {
|
|
99
130
|
// 플레인 텍스트
|
|
@@ -114,9 +145,8 @@ export async function ingestCommand(input, options) {
|
|
|
114
145
|
console.log(chalk.dim(` Index: ${result.indexCode}`));
|
|
115
146
|
if (result.tags.length > 0)
|
|
116
147
|
console.log(chalk.dim(` Tags: ${result.tags.join(', ')}`));
|
|
148
|
+
console.log(chalk.dim(' Wiki: auto-compiled'));
|
|
117
149
|
console.log('');
|
|
118
|
-
console.log(chalk.dim('Run `stellavault compile` to process into wiki.'));
|
|
119
|
-
console.log(chalk.dim('Run `stellavault autopilot` for full pipeline.'));
|
|
120
150
|
}
|
|
121
151
|
export async function promoteCommand(filePath, options) {
|
|
122
152
|
const config = loadConfig();
|
|
@@ -23,6 +23,7 @@ import { vaultAddCommand, vaultListCommand, vaultRemoveCommand, vaultSearchAllCo
|
|
|
23
23
|
import { captureCommand } from './commands/capture-cmd.js';
|
|
24
24
|
import { askCommand } from './commands/ask-cmd.js';
|
|
25
25
|
import { compileCommand } from './commands/compile-cmd.js';
|
|
26
|
+
import { draftCommand } from './commands/draft-cmd.js';
|
|
26
27
|
import { lintCommand } from './commands/lint-cmd.js';
|
|
27
28
|
import { fleetingCommand } from './commands/fleeting-cmd.js';
|
|
28
29
|
import { ingestCommand, promoteCommand } from './commands/ingest-cmd.js';
|
|
@@ -139,6 +140,12 @@ program
|
|
|
139
140
|
.option('-w, --wiki <dir>', 'Wiki output directory (default: _wiki/)')
|
|
140
141
|
.option('-f, --force', 'Overwrite existing wiki files')
|
|
141
142
|
.action((opts) => compileCommand(opts));
|
|
143
|
+
program
|
|
144
|
+
.command('draft [topic]')
|
|
145
|
+
.description('Express: Generate a blog post, report, or outline draft from your knowledge')
|
|
146
|
+
.option('--format <type>', 'Output format: blog, report, outline (default: blog)')
|
|
147
|
+
.option('--ai', 'Use Claude API for AI-enhanced draft (requires ANTHROPIC_API_KEY)')
|
|
148
|
+
.action((topic, opts) => draftCommand(topic, opts));
|
|
142
149
|
program
|
|
143
150
|
.command('lint')
|
|
144
151
|
.description('Knowledge health check — find gaps, duplicates, contradictions, stale notes')
|