Add CLI package, config file support, and workspace setup

Add cli/ package with initial scaffolding. Add config-schema to shared
package for typed configuration. Add server config-file loader for
paperclip.config.ts support. Register cli in pnpm workspace. Add
.paperclip/ and .pnpm-store/ to gitignore. Minor Companies page fix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Forgotten
2026-02-17 13:39:47 -06:00
parent 0975907121
commit 5306142542
28 changed files with 1091 additions and 7 deletions

View File

@@ -0,0 +1,48 @@
import * as p from "@clack/prompts";
import type { DatabaseConfig } from "../config/schema.js";
export async function promptDatabase(): Promise<DatabaseConfig> {
const mode = await p.select({
message: "Database mode",
options: [
{ value: "pglite" as const, label: "PGlite (embedded, no setup needed)", hint: "recommended" },
{ value: "postgres" as const, label: "PostgreSQL (external server)" },
],
});
if (p.isCancel(mode)) {
p.cancel("Setup cancelled.");
process.exit(0);
}
if (mode === "postgres") {
const connectionString = await p.text({
message: "PostgreSQL connection string",
placeholder: "postgres://user:pass@localhost:5432/paperclip",
validate: (val) => {
if (!val) return "Connection string is required for PostgreSQL mode";
if (!val.startsWith("postgres")) return "Must be a postgres:// or postgresql:// URL";
},
});
if (p.isCancel(connectionString)) {
p.cancel("Setup cancelled.");
process.exit(0);
}
return { mode: "postgres", connectionString, pgliteDataDir: "./data/pglite" };
}
const pgliteDataDir = await p.text({
message: "PGlite data directory",
defaultValue: "./data/pglite",
placeholder: "./data/pglite",
});
if (p.isCancel(pgliteDataDir)) {
p.cancel("Setup cancelled.");
process.exit(0);
}
return { mode: "pglite", pgliteDataDir: pgliteDataDir || "./data/pglite" };
}

43
cli/src/prompts/llm.ts Normal file
View File

@@ -0,0 +1,43 @@
import * as p from "@clack/prompts";
import type { LlmConfig } from "../config/schema.js";
export async function promptLlm(): Promise<LlmConfig | undefined> {
const configureLlm = await p.confirm({
message: "Configure an LLM provider now?",
initialValue: false,
});
if (p.isCancel(configureLlm)) {
p.cancel("Setup cancelled.");
process.exit(0);
}
if (!configureLlm) return undefined;
const provider = await p.select({
message: "LLM provider",
options: [
{ value: "claude" as const, label: "Claude (Anthropic)" },
{ value: "openai" as const, label: "OpenAI" },
],
});
if (p.isCancel(provider)) {
p.cancel("Setup cancelled.");
process.exit(0);
}
const apiKey = await p.password({
message: `${provider === "claude" ? "Anthropic" : "OpenAI"} API key`,
validate: (val) => {
if (!val) return "API key is required";
},
});
if (p.isCancel(apiKey)) {
p.cancel("Setup cancelled.");
process.exit(0);
}
return { provider, apiKey };
}

View File

@@ -0,0 +1,35 @@
import * as p from "@clack/prompts";
import type { LoggingConfig } from "../config/schema.js";
export async function promptLogging(): Promise<LoggingConfig> {
const mode = await p.select({
message: "Logging mode",
options: [
{ value: "file" as const, label: "File-based logging", hint: "recommended" },
{ value: "cloud" as const, label: "Cloud logging", hint: "coming soon" },
],
});
if (p.isCancel(mode)) {
p.cancel("Setup cancelled.");
process.exit(0);
}
if (mode === "file") {
const logDir = await p.text({
message: "Log directory",
defaultValue: "./data/logs",
placeholder: "./data/logs",
});
if (p.isCancel(logDir)) {
p.cancel("Setup cancelled.");
process.exit(0);
}
return { mode: "file", logDir: logDir || "./data/logs" };
}
p.note("Cloud logging is coming soon. Using file-based logging for now.");
return { mode: "file", logDir: "./data/logs" };
}

35
cli/src/prompts/server.ts Normal file
View File

@@ -0,0 +1,35 @@
import * as p from "@clack/prompts";
import type { ServerConfig } from "../config/schema.js";
export async function promptServer(): Promise<ServerConfig> {
const portStr = await p.text({
message: "Server port",
defaultValue: "3100",
placeholder: "3100",
validate: (val) => {
const n = Number(val);
if (isNaN(n) || n < 1 || n > 65535 || !Number.isInteger(n)) {
return "Must be an integer between 1 and 65535";
}
},
});
if (p.isCancel(portStr)) {
p.cancel("Setup cancelled.");
process.exit(0);
}
const port = Number(portStr) || 3100;
const serveUi = await p.confirm({
message: "Serve the UI from the server?",
initialValue: false,
});
if (p.isCancel(serveUi)) {
p.cancel("Setup cancelled.");
process.exit(0);
}
return { port, serveUi };
}