diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 60373d1..382c3b5 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -30,7 +30,9 @@ "Bash(npm test:*)", "Bash(npx tsc:*)", "Bash(grep -r \"export\\\\|json\\\\|format\" /c/Workspace/Personal/llm-wiki/docs/*.md)", - "Bash(ls:*)" + "Bash(ls:*)", + "Bash(npm install:*)", + "Bash(npm uninstall:*)" ] } } diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..f1cf04e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,207 @@ +{ + "name": "llmwiki-cli", + "version": "0.2.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "llmwiki-cli", + "version": "0.2.1", + "license": "MIT", + "dependencies": { + "commander": "^12.0.0", + "js-yaml": "^4.1.0" + }, + "bin": { + "llmwiki": "dist/wiki.js", + "wiki": "dist/wiki.js" + }, + "devDependencies": { + "@types/bun": "latest", + "@types/js-yaml": "^4.0.9" + }, + "optionalDependencies": { + "@supabase/supabase-js": "^2.49.0" + } + }, + "node_modules/@supabase/auth-js": { + "version": "2.103.0", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "2.8.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@supabase/functions-js": { + "version": "2.103.0", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "2.8.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@supabase/phoenix": { + "version": "0.4.0", + "license": "MIT", + "optional": true + }, + "node_modules/@supabase/postgrest-js": { + "version": "2.103.0", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "2.8.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@supabase/realtime-js": { + "version": "2.103.0", + "license": "MIT", + "optional": true, + "dependencies": { + "@supabase/phoenix": "^0.4.0", + "@types/ws": "^8.18.1", + "tslib": "2.8.1", + "ws": "^8.18.2" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@supabase/storage-js": { + "version": "2.103.0", + "license": "MIT", + "optional": true, + "dependencies": { + "iceberg-js": "^0.8.1", + "tslib": "2.8.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@supabase/supabase-js": { + "version": "2.103.0", + "license": "MIT", + "optional": true, + "dependencies": { + "@supabase/auth-js": "2.103.0", + "@supabase/functions-js": "2.103.0", + "@supabase/postgrest-js": "2.103.0", + "@supabase/realtime-js": "2.103.0", + "@supabase/storage-js": "2.103.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/@types/bun": { + "version": "1.3.12", + "resolved": "https://registry.npmjs.org/@types/bun/-/bun-1.3.12.tgz", + "integrity": "sha512-DBv81elK+/VSwXHDlnH3Qduw+KxkTIWi7TXkAeh24zpi5l0B2kUg9Ga3tb4nJaPcOFswflgi/yAvMVBPrxMB+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "bun-types": "1.3.12" + } + }, + "node_modules/@types/js-yaml": { + "version": "4.0.9", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "25.6.0", + "devOptional": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.19.0" + } + }, + "node_modules/@types/ws": { + "version": "8.18.1", + "license": "MIT", + "optional": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "license": "Python-2.0" + }, + "node_modules/bun-types": { + "version": "1.3.12", + "resolved": "https://registry.npmjs.org/bun-types/-/bun-types-1.3.12.tgz", + "integrity": "sha512-HqOLj5PoFajAQciOMRiIZGNoKxDJSr6qigAttOX40vJuSp6DN/CxWp9s3C1Xwm4oH7ybueITwiaOcWXoYVoRkA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/commander": { + "version": "12.1.0", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/iceberg-js": { + "version": "0.8.1", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/js-yaml": { + "version": "4.1.1", + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "license": "0BSD", + "optional": true + }, + "node_modules/undici-types": { + "version": "7.19.2", + "devOptional": true, + "license": "MIT" + }, + "node_modules/ws": { + "version": "8.20.0", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/src/commands/init.ts b/src/commands/init.ts index 834064e..c3e1fa3 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -18,14 +18,15 @@ import { } from "../lib/templates.ts"; import type { BackendType, RegistryEntry } from "../types.ts"; -const SUPABASE_SQL = `-- Run this in your Supabase SQL Editor: -create table if not exists wiki_pages ( +const SUPABASE_SQL_RAW = `create table if not exists wiki_pages ( wiki_id text not null, path text not null, content text not null, updated_at timestamptz default now(), primary key (wiki_id, path) -);`; +)`; + +const SUPABASE_SQL = `-- Run this in your Supabase SQL Editor:\n${SUPABASE_SQL_RAW};`; export function makeInitCommand(): Command { return new Command("init") @@ -174,16 +175,28 @@ export function makeInitCommand(): Command { await saveConfig(targetDir, config); if (backend === "supabase") { - // Supabase: write initial pages via provider + // Supabase: check if table exists before writing initial pages const provider = await createProvider(config, targetDir); - await provider.writePage("SCHEMA.md", getDefaultSchema(name, domain)); - await provider.writePage("wiki/index.md", getDefaultIndex()); - await provider.writePage("wiki/log.md", getDefaultLog()); + let tableExists = true; + try { + await provider.listPages(); + } catch { + tableExists = false; + } - console.log(`\n${SUPABASE_SQL}\n`); - console.log( - "Make sure the wiki_pages table exists in your Supabase project.", - ); + if (tableExists) { + await provider.writePage("SCHEMA.md", getDefaultSchema(name, domain)); + await provider.writePage("wiki/index.md", getDefaultIndex()); + await provider.writePage("wiki/log.md", getDefaultLog()); + } else { + console.log(`\n${SUPABASE_SQL}\n`); + console.log( + "Table wiki_pages not found. Run the SQL above in your Supabase SQL Editor,", + ); + console.log( + "then re-run this command.", + ); + } } else { // Filesystem/git: create local directory structure + files const dirs = [