@kitelev/exocortex-cli 13.160.3

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 (3) hide show
  1. package/README.md +460 -0
  2. package/dist/index.js +323 -0
  3. package/package.json +68 -0
package/README.md ADDED
@@ -0,0 +1,460 @@
1
+ # @exocortex/cli
2
+
3
+ Command-line interface for Exocortex knowledge management system. Manage tasks, projects, and planning from the terminal without needing Obsidian.
4
+
5
+ ## API Stability
6
+
7
+ **Current Version: 0.1.x (Stable API)**
8
+
9
+ This CLI follows [Semantic Versioning](https://semver.org/). The commands documented below are considered **stable** and covered by versioning guarantees.
10
+
11
+ **Documentation:**
12
+ - [CLI API Reference](docs/CLI_API_REFERENCE.md) - Formal command signatures and options
13
+ - [Versioning Policy](VERSIONING.md) - What constitutes breaking changes
14
+ - [SPARQL Guide](docs/SPARQL_GUIDE.md) - Complete query reference
15
+ - [SPARQL Cookbook](docs/SPARQL_COOKBOOK.md) - Real-world query examples
16
+ - [Ontology Reference](docs/ONTOLOGY_REFERENCE.md) - Available predicates
17
+
18
+ **For MCP Integration:**
19
+ - Pin to `^0.1.0` for stable API access
20
+ - Use exit codes for status (not console messages)
21
+ - Use `--format json` for machine-readable output
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ npm install -g @exocortex/cli
27
+ ```
28
+
29
+ Or use directly with npx:
30
+
31
+ ```bash
32
+ npx @exocortex/cli [command]
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ```bash
38
+ exocortex --help
39
+ ```
40
+
41
+ ### SPARQL Query
42
+
43
+ Execute SPARQL queries against your Obsidian vault as an RDF knowledge graph.
44
+
45
+ ```bash
46
+ exocortex sparql query "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10" --vault ~/vault
47
+ ```
48
+
49
+ **Options:**
50
+ - `<query>` - SPARQL query string or path to .sparql file **[required]**
51
+ - `--vault <path>` - Path to Obsidian vault (default: current directory)
52
+ - `--format <type>` - Output format: `table` (default), `json`, `csv`
53
+ - `--explain` - Show optimized query plan (for debugging)
54
+ - `--stats` - Show execution statistics (load time, query time, results count)
55
+ - `--no-optimize` - Disable query optimization
56
+
57
+ **Examples:**
58
+
59
+ ```bash
60
+ # Find all tasks
61
+ exocortex sparql query \
62
+ "PREFIX exo: <https://exocortex.my/ontology/exo#>
63
+ PREFIX ems: <https://exocortex.my/ontology/ems#>
64
+ SELECT ?task ?label
65
+ WHERE {
66
+ ?task exo:Instance_class ems:Task .
67
+ ?task exo:Asset_label ?label .
68
+ }" \
69
+ --vault ~/vault
70
+
71
+ # Query from file
72
+ exocortex sparql query queries/my-query.sparql --vault ~/vault
73
+
74
+ # JSON output for automation
75
+ exocortex sparql query "SELECT ?s ?p ?o WHERE { ?s ?p ?o }" \
76
+ --vault ~/vault \
77
+ --format json > results.json
78
+
79
+ # Show query plan and stats
80
+ exocortex sparql query "SELECT ?task WHERE { ?task exo:Instance_class ems:Task }" \
81
+ --vault ~/vault \
82
+ --explain \
83
+ --stats
84
+ ```
85
+
86
+ **Sample Output (Table Format):**
87
+
88
+ ```
89
+ 📦 Loading vault: /Users/you/vault...
90
+ ✅ Loaded 1,234 triples in 45ms
91
+
92
+ 🔍 Parsing SPARQL query...
93
+ 🔄 Translating to algebra...
94
+ 🎯 Executing query...
95
+ ✅ Found 5 result(s) in 12ms
96
+
97
+ ┌────────────────────────────────────────────────────────────┐
98
+ │ ?label │ ?effort │
99
+ ├────────────────────────────┼───────────────────────────────┤
100
+ │ "Implement SPARQL Engine" │ "240" │
101
+ │ "Write Documentation" │ "120" │
102
+ │ "Design Architecture" │ "180" │
103
+ └────────────────────────────────────────────────────────────┘
104
+ ```
105
+
106
+ ### Command Execution
107
+
108
+ Execute plugin commands on single assets. All commands follow the pattern:
109
+
110
+ ```bash
111
+ exocortex command <command-name> <filepath> [options]
112
+ ```
113
+
114
+ **Common Options:**
115
+ - `--vault <path>` - Path to Obsidian vault (default: current directory)
116
+ - `--dry-run` - Preview changes without modifying files
117
+
118
+ See [CLI API Reference](docs/CLI_API_REFERENCE.md) for complete command documentation.
119
+
120
+ #### Status Commands
121
+
122
+ ```bash
123
+ # Start a task (ToDo → Doing)
124
+ exocortex command start "tasks/my-task.md" --vault ~/vault
125
+
126
+ # Complete a task (Doing → Done)
127
+ exocortex command complete "tasks/my-task.md" --vault ~/vault
128
+
129
+ # Move to backlog
130
+ exocortex command move-to-backlog "tasks/defer-task.md" --vault ~/vault
131
+
132
+ # Move to ToDo
133
+ exocortex command move-to-todo "tasks/ready-task.md" --vault ~/vault
134
+
135
+ # Trash a task
136
+ exocortex command trash "tasks/obsolete-task.md" --vault ~/vault
137
+
138
+ # Archive a task
139
+ exocortex command archive "tasks/old-task.md" --vault ~/vault
140
+ ```
141
+
142
+ #### Creation Commands
143
+
144
+ ```bash
145
+ # Create a new task
146
+ exocortex command create-task "tasks/new-task.md" \
147
+ --label "Implement feature X" \
148
+ --area "areas/product" \
149
+ --vault ~/vault
150
+
151
+ # Create a new meeting
152
+ exocortex command create-meeting "meetings/standup.md" \
153
+ --label "Daily Standup $(date +%Y-%m-%d)" \
154
+ --prototype "prototypes/standup-template" \
155
+ --vault ~/vault
156
+
157
+ # Create a new project
158
+ exocortex command create-project "projects/website-redesign.md" \
159
+ --label "Website Redesign Q1 2026" \
160
+ --vault ~/vault
161
+
162
+ # Create a new area
163
+ exocortex command create-area "areas/product.md" \
164
+ --label "Product Development" \
165
+ --vault ~/vault
166
+ ```
167
+
168
+ #### Property Commands
169
+
170
+ ```bash
171
+ # Rename file to match its UID
172
+ exocortex command rename-to-uid "tasks/My Task Name.md" --vault ~/vault
173
+
174
+ # Update asset label
175
+ exocortex command update-label "tasks/task.md" --label "New Label" --vault ~/vault
176
+
177
+ # Schedule task for a date
178
+ exocortex command schedule "tasks/feature.md" --date "2025-12-15" --vault ~/vault
179
+
180
+ # Set deadline
181
+ exocortex command set-deadline "tasks/feature.md" --date "2025-12-31" --vault ~/vault
182
+ ```
183
+
184
+ ## Workflow Examples
185
+
186
+ ### Morning Planning
187
+
188
+ ```bash
189
+ # Schedule tasks for today
190
+ exocortex command schedule "tasks/task1.md" --date "$(date +%Y-%m-%d)" --vault ~/vault
191
+ exocortex command schedule "tasks/task2.md" --date "$(date +%Y-%m-%d)" --vault ~/vault
192
+
193
+ # Move them to ToDo
194
+ exocortex command move-to-todo "tasks/task1.md" --vault ~/vault
195
+ exocortex command move-to-todo "tasks/task2.md" --vault ~/vault
196
+ ```
197
+
198
+ ### Creating Tasks from Project
199
+
200
+ ```bash
201
+ # Create multiple tasks for a project
202
+ exocortex command create-task "tasks/update-homepage.md" \
203
+ --label "Update homepage" \
204
+ --parent "projects/website-redesign" \
205
+ --vault ~/vault
206
+
207
+ exocortex command create-task "tasks/redesign-nav.md" \
208
+ --label "Redesign navigation" \
209
+ --parent "projects/website-redesign" \
210
+ --vault ~/vault
211
+
212
+ exocortex command create-task "tasks/test-mobile.md" \
213
+ --label "Test on mobile" \
214
+ --parent "projects/website-redesign" \
215
+ --vault ~/vault
216
+ ```
217
+
218
+ ### Weekly Review Workflow
219
+
220
+ ```bash
221
+ # Create this week's review meeting
222
+ exocortex command create-meeting "meetings/weekly-review-$(date +%Y-%m-%d).md" \
223
+ --label "Weekly Review $(date +%Y-%m-%d)" \
224
+ --prototype "prototypes/weekly-review-template" \
225
+ --vault ~/vault
226
+ ```
227
+
228
+ ### Task Lifecycle
229
+
230
+ ```bash
231
+ # 1. Create task
232
+ exocortex command create-task "tasks/feature.md" --label "Implement feature" --vault ~/vault
233
+
234
+ # 2. Move to ToDo when ready
235
+ exocortex command move-to-todo "tasks/feature.md" --vault ~/vault
236
+
237
+ # 3. Start working
238
+ exocortex command start "tasks/feature.md" --vault ~/vault
239
+
240
+ # 4. Complete when done
241
+ exocortex command complete "tasks/feature.md" --vault ~/vault
242
+
243
+ # 5. Archive for cleanup
244
+ exocortex command archive "tasks/feature.md" --vault ~/vault
245
+ ```
246
+
247
+ ### Batch Operations
248
+
249
+ Execute multiple operations in a single CLI invocation for better performance:
250
+
251
+ ```bash
252
+ # Execute batch from JSON input
253
+ exocortex batch --input '[
254
+ {"command":"start","filepath":"tasks/task1.md"},
255
+ {"command":"complete","filepath":"tasks/task2.md"},
256
+ {"command":"trash","filepath":"tasks/task3.md"}
257
+ ]' --vault ~/vault
258
+
259
+ # Execute batch from file
260
+ exocortex batch --file operations.json --vault ~/vault
261
+
262
+ # Atomic mode (all-or-nothing - rollback on any failure)
263
+ exocortex batch --file operations.json --vault ~/vault --atomic
264
+
265
+ # Dry run (preview without modifying files)
266
+ exocortex batch --input '[{"command":"start","filepath":"task.md"}]' --vault ~/vault --dry-run
267
+
268
+ # JSON output for MCP integration
269
+ exocortex batch --file operations.json --vault ~/vault --format json
270
+ ```
271
+
272
+ **Batch Options:**
273
+ - `--input <json>` - JSON array of operations to execute
274
+ - `--file <path>` - Path to JSON file containing operations
275
+ - `--atomic` - All-or-nothing execution (rollback on any failure)
276
+ - `--dry-run` - Preview changes without modifying files
277
+ - `--format <type>` - Output format: `text` (default), `json`
278
+ - `--vault <path>` - Path to Obsidian vault (default: current directory)
279
+
280
+ **Operation Format:**
281
+ ```json
282
+ {
283
+ "command": "start", // Command name (required)
284
+ "filepath": "tasks/task.md", // File path (required)
285
+ "options": { // Optional command parameters
286
+ "label": "New Label",
287
+ "date": "2025-12-15"
288
+ }
289
+ }
290
+ ```
291
+
292
+ **Supported Commands:**
293
+ - `start` - Start task (ToDo → Doing)
294
+ - `complete` - Complete task (Doing → Done)
295
+ - `trash` - Trash task
296
+ - `archive` - Archive task
297
+ - `move-to-backlog` - Move to Backlog
298
+ - `move-to-analysis` - Move to Analysis
299
+ - `move-to-todo` - Move to ToDo
300
+ - `update-label` - Update label (requires `options.label`)
301
+ - `schedule` - Schedule task (requires `options.date`)
302
+ - `set-deadline` - Set deadline (requires `options.date`)
303
+
304
+ **Performance Benefits:**
305
+ - Single process execution (no repeated Node.js startup overhead)
306
+ - Vault loaded once for all operations
307
+ - Batch of 10 operations is ~10x faster than 10 separate CLI calls
308
+
309
+ **MCP Integration Example:**
310
+ ```json
311
+ {
312
+ "success": true,
313
+ "data": {
314
+ "success": true,
315
+ "total": 3,
316
+ "succeeded": 3,
317
+ "failed": 0,
318
+ "results": [
319
+ {"success": true, "command": "start", "filepath": "task1.md", "action": "Started task"},
320
+ {"success": true, "command": "complete", "filepath": "task2.md", "action": "Completed task"},
321
+ {"success": true, "command": "trash", "filepath": "task3.md", "action": "Trashed task"}
322
+ ],
323
+ "durationMs": 45,
324
+ "atomic": false
325
+ },
326
+ "meta": {
327
+ "durationMs": 45,
328
+ "itemCount": 3
329
+ }
330
+ }
331
+ ```
332
+
333
+ ## Architecture
334
+
335
+ The CLI uses `exocortex` for business logic and implements a Node.js file system adapter:
336
+
337
+ ```
338
+ exocortex-cli/
339
+ ├── src/
340
+ │ ├── index.ts - Main CLI entry point
341
+ │ ├── adapters/
342
+ │ │ └── NodeFsAdapter.ts - Node.js file system implementation
343
+ │ └── commands/
344
+ │ ├── create-task.ts
345
+ │ ├── create-instance.ts
346
+ │ ├── status.ts
347
+ │ └── plan.ts
348
+ └── dist/ - Compiled output
349
+ ```
350
+
351
+ ## Features
352
+
353
+ - **SPARQL Query Engine** - Execute SPARQL 1.1 queries against vault as RDF knowledge graph
354
+ - BGP (Basic Graph Pattern) execution with variable bindings
355
+ - Query optimization (filter push-down, join reordering)
356
+ - Multiple output formats (table, JSON, CSV)
357
+ - Query plan visualization (--explain flag)
358
+ - Performance statistics (--stats flag)
359
+ - **File System Operations** - Read/write markdown files with frontmatter
360
+ - **Task Creation** - Generate tasks from areas, projects, and prototypes
361
+ - **Instance Creation** - Create instances from prototypes
362
+ - **Status Management** - Update task status through workflow
363
+ - **Planning** - Assign tasks to specific days
364
+ - **Frontmatter Support** - Full YAML frontmatter parsing and manipulation
365
+ - **Progress Indicators** - Spinners and colored output for better UX
366
+
367
+ ## Development
368
+
369
+ ```bash
370
+ # Install dependencies
371
+ npm install
372
+
373
+ # Build
374
+ npm run build
375
+
376
+ # Run locally
377
+ node dist/index.js --help
378
+
379
+ # Watch mode
380
+ npm run dev
381
+ ```
382
+
383
+ ## Requirements
384
+
385
+ - Node.js >= 18.0.0
386
+ - A vault with Exocortex-compatible markdown files
387
+
388
+ ## Vault Structure
389
+
390
+ Your vault should follow Exocortex conventions:
391
+
392
+ ```
393
+ vault/
394
+ ├── areas/
395
+ │ ├── work.md
396
+ │ └── personal.md
397
+ ├── projects/
398
+ │ └── website-redesign.md
399
+ ├── tasks/
400
+ │ ├── abc-123.md
401
+ │ └── def-456.md
402
+ └── prototypes/
403
+ ├── weekly-review.md
404
+ └── standup.md
405
+ ```
406
+
407
+ Each file should have YAML frontmatter with Exocortex properties:
408
+
409
+ ```yaml
410
+ ---
411
+ exo__Asset_isDefinedBy: my-ontology
412
+ exo__Asset_uid: abc-123
413
+ exo__Instance_class:
414
+ - "[[ems__Task]]"
415
+ ems__Effort_status: "[[ems__EffortStatusDraft]]"
416
+ ---
417
+ ```
418
+
419
+ ## Roadmap
420
+
421
+ ### Implemented Commands
422
+
423
+ **SPARQL Query:**
424
+ - `exocortex sparql query` - Execute SPARQL queries against vault
425
+
426
+ **Status Transitions:**
427
+ - `exocortex command start` - Start effort (ToDo → Doing)
428
+ - `exocortex command complete` - Complete effort (Doing → Done)
429
+ - `exocortex command trash` - Trash effort
430
+ - `exocortex command archive` - Archive effort
431
+ - `exocortex command move-to-backlog` - Move to Backlog
432
+ - `exocortex command move-to-analysis` - Move to Analysis
433
+ - `exocortex command move-to-todo` - Move to ToDo
434
+
435
+ **Asset Creation:**
436
+ - `exocortex command create-task` - Create new task
437
+ - `exocortex command create-meeting` - Create new meeting
438
+ - `exocortex command create-project` - Create new project
439
+ - `exocortex command create-area` - Create new area
440
+
441
+ **Property Mutations:**
442
+ - `exocortex command rename-to-uid` - Rename file to match UID
443
+ - `exocortex command update-label` - Update asset label
444
+ - `exocortex command schedule` - Set planned start date
445
+ - `exocortex command set-deadline` - Set planned end date
446
+
447
+ **Batch Operations:**
448
+ - `exocortex batch` - Execute multiple operations in single invocation
449
+
450
+ ### Planned Commands
451
+
452
+ - `exocortex command rollback-status` - Rollback to previous status
453
+ - `exocortex command shift-schedule` - Shift planned date forward/backward
454
+ - `exocortex list tasks` - List all tasks (with filters)
455
+ - `exocortex list today` - List today's scheduled tasks
456
+ - `exocortex report weekly` - Generate weekly effort report
457
+
458
+ ## License
459
+
460
+ MIT