index.mjs
sha256:e3574dcaff08ff0d4a7d80b81c9d7c720727f3aa6e4e062e39224019e2f761c9
Initial seed: CLI-first Knowtation with SKILL.md, vault, and docs
Agent
136 days ago
| 1 | #!/usr/bin/env node |
| 2 | /** |
| 3 | * Knowledger CLI — single entry point for search, get-note, list-notes, index, etc. |
| 4 | * Agents discover usage via SKILL.md and `knowledger --help` / `knowledger <cmd> --help`. |
| 5 | * Output: JSON or structured text for piping. |
| 6 | */ |
| 7 | |
| 8 | const args = process.argv.slice(2); |
| 9 | const subcommand = args[0]; |
| 10 | |
| 11 | const help = ` |
| 12 | knowtation — personal knowledge and content system (know + notation) |
| 13 | |
| 14 | Usage: |
| 15 | knowtation <command> [options] |
| 16 | |
| 17 | Commands: |
| 18 | search <query> Semantic search over vault (returns ranked notes/chunks). Use --json for machine output. |
| 19 | get-note <path> Return full content of one note by path. |
| 20 | list-notes List notes with optional --folder, --tag, --limit, --offset. Use --json for machine output. |
| 21 | index Re-run indexer: vault → chunk → embed → vector store (Qdrant or sqlite-vec). |
| 22 | |
| 23 | Options (global): |
| 24 | --help, -h Show this help or command-specific help. |
| 25 | --json Output JSON for piping to other tools. |
| 26 | |
| 27 | Examples: |
| 28 | knowtation search "community building" |
| 29 | knowtation search "transcript about launch" --json |
| 30 | knowtation get-note vault/projects/default/notes.md |
| 31 | knowtation list-notes --folder vault/inbox --limit 10 --json |
| 32 | knowtation index |
| 33 | |
| 34 | Config: vault path and vector store URL from config/local.yaml or env (KNOWTATION_VAULT_PATH, QDRANT_URL). |
| 35 | `; |
| 36 | |
| 37 | const searchHelp = ` |
| 38 | knowtation search <query> |
| 39 | |
| 40 | Semantic search over the indexed vault. Returns ranked notes (path, snippet, score). |
| 41 | Add --json for machine-readable output. |
| 42 | |
| 43 | Options: |
| 44 | --folder <path> Limit to vault subfolder. |
| 45 | --limit <n> Max results (default 10). |
| 46 | --json JSON output. |
| 47 | `; |
| 48 | |
| 49 | function main() { |
| 50 | if (!subcommand || subcommand === '--help' || subcommand === '-h') { |
| 51 | console.log(help.trim()); |
| 52 | process.exit(0); |
| 53 | } |
| 54 | |
| 55 | if (subcommand === 'search') { |
| 56 | if (args.includes('--help') || args.includes('-h')) { |
| 57 | console.log(searchHelp.trim()); |
| 58 | process.exit(0); |
| 59 | } |
| 60 | const query = args.slice(1).filter(a => !a.startsWith('--')).join(' '); |
| 61 | if (!query) { |
| 62 | console.error('knowtation search: provide a query string.'); |
| 63 | process.exit(1); |
| 64 | } |
| 65 | // Stub: implement by calling vector store (Qdrant) and optionally vault keyword search |
| 66 | console.log(JSON.stringify({ stub: true, command: 'search', query, message: 'Implement: connect to Qdrant and return ranked chunks.' })); |
| 67 | process.exit(0); |
| 68 | } |
| 69 | |
| 70 | if (subcommand === 'get-note') { |
| 71 | const path = args[1]; |
| 72 | if (!path) { |
| 73 | console.error('knowtation get-note: provide a note path.'); |
| 74 | process.exit(1); |
| 75 | } |
| 76 | // Stub: implement by reading file from vault |
| 77 | console.log(JSON.stringify({ stub: true, command: 'get-note', path, message: 'Implement: read vault file and return content.' })); |
| 78 | process.exit(0); |
| 79 | } |
| 80 | |
| 81 | if (subcommand === 'list-notes') { |
| 82 | const folder = args.includes('--folder') ? args[args.indexOf('--folder') + 1] : null; |
| 83 | const limit = args.includes('--limit') ? parseInt(args[args.indexOf('--limit') + 1], 10) : 20; |
| 84 | console.log(JSON.stringify({ stub: true, command: 'list-notes', folder, limit, message: 'Implement: list vault notes with filters.' })); |
| 85 | process.exit(0); |
| 86 | } |
| 87 | |
| 88 | if (subcommand === 'index') { |
| 89 | // Delegate to scripts/index-vault.mjs |
| 90 | console.log('Run: node scripts/index-vault.mjs'); |
| 91 | process.exit(0); |
| 92 | } |
| 93 | |
| 94 | console.error(`Unknown command: ${subcommand}`); |
| 95 | console.log(help.trim()); |
| 96 | process.exit(1); |
| 97 | } |
| 98 | |
| 99 | main(); |
File History
1 commit
sha256:e3574dcaff08ff0d4a7d80b81c9d7c720727f3aa6e4e062e39224019e2f761c9
Initial seed: CLI-first Knowtation with SKILL.md, vault, and docs
Agent
136 days ago