openbuilder 0.1.0

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.
@@ -0,0 +1,166 @@
1
+ #!/usr/bin/env npx tsx
2
+ /**
3
+ * builder-config.ts — View and manage OpenBuilder configuration
4
+ *
5
+ * Usage:
6
+ * npx openbuilder config # show all config
7
+ * npx openbuilder config set <key> <value> # set a value
8
+ * npx openbuilder config get <key> # get a value
9
+ * npx openbuilder config delete <key> # delete a value
10
+ */
11
+
12
+ import {
13
+ CONFIG_FILE,
14
+ getConfig,
15
+ readConfig,
16
+ setConfigValue,
17
+ deleteConfigValue,
18
+ type OpenBuilderConfig,
19
+ } from "../src/utils/config.js";
20
+
21
+ const VALID_KEYS: (keyof OpenBuilderConfig)[] = [
22
+ "aiProvider",
23
+ "anthropicApiKey",
24
+ "openaiApiKey",
25
+ "botName",
26
+ "defaultDuration",
27
+ ];
28
+
29
+ const SENSITIVE_KEYS = new Set(["anthropicApiKey", "openaiApiKey"]);
30
+
31
+ function maskValue(key: string, value: string): string {
32
+ if (SENSITIVE_KEYS.has(key) && value.length > 8) {
33
+ return value.slice(0, 4) + "..." + value.slice(-4);
34
+ }
35
+ return value;
36
+ }
37
+
38
+ function showHelp() {
39
+ console.log(`OpenBuilder Config
40
+
41
+ Usage:
42
+ openbuilder config Show all configuration
43
+ openbuilder config set <key> <value> Set a configuration value
44
+ openbuilder config get <key> Get a configuration value
45
+ openbuilder config delete <key> Delete a configuration value
46
+
47
+ Keys:
48
+ aiProvider AI provider to use: claude or openai (default: claude)
49
+ anthropicApiKey Anthropic API key for Claude
50
+ openaiApiKey OpenAI API key
51
+ botName Default bot display name
52
+ defaultDuration Default meeting duration (e.g. 60m, 2h)
53
+
54
+ Environment variables (override config file):
55
+ OPENBUILDER_AI_PROVIDER
56
+ ANTHROPIC_API_KEY
57
+ OPENAI_API_KEY
58
+ OPENBUILDER_BOT_NAME
59
+ OPENBUILDER_DEFAULT_DURATION
60
+
61
+ Config file: ${CONFIG_FILE}`);
62
+ }
63
+
64
+ function showAll() {
65
+ const fileConfig = readConfig();
66
+ const effectiveConfig = getConfig();
67
+
68
+ console.log("OpenBuilder Configuration\n");
69
+ console.log(`Config file: ${CONFIG_FILE}\n`);
70
+
71
+ if (Object.keys(effectiveConfig).length === 0) {
72
+ console.log("(no configuration set)");
73
+ console.log("\nRun `openbuilder config set <key> <value>` to configure.");
74
+ return;
75
+ }
76
+
77
+ console.log("Current settings:");
78
+ for (const key of VALID_KEYS) {
79
+ const fileVal = fileConfig[key] as string | undefined;
80
+ const effectiveVal = effectiveConfig[key] as string | undefined;
81
+
82
+ if (effectiveVal) {
83
+ const source = fileVal === effectiveVal ? "config" : "env";
84
+ console.log(` ${key}: ${maskValue(key, effectiveVal)} (${source})`);
85
+ }
86
+ }
87
+ }
88
+
89
+ function main() {
90
+ const args = process.argv.slice(2);
91
+ const subcommand = args[0];
92
+
93
+ if (!subcommand || subcommand === "help" || subcommand === "--help") {
94
+ if (!subcommand) {
95
+ showAll();
96
+ return;
97
+ }
98
+ showHelp();
99
+ return;
100
+ }
101
+
102
+ if (subcommand === "set") {
103
+ const key = args[1] as keyof OpenBuilderConfig;
104
+ const value = args[2];
105
+
106
+ if (!key || !value) {
107
+ console.error("Usage: openbuilder config set <key> <value>");
108
+ process.exit(1);
109
+ }
110
+
111
+ if (!VALID_KEYS.includes(key)) {
112
+ console.error(`Unknown config key: ${key}`);
113
+ console.error(`Valid keys: ${VALID_KEYS.join(", ")}`);
114
+ process.exit(1);
115
+ }
116
+
117
+ if (key === "aiProvider" && value !== "claude" && value !== "openai") {
118
+ console.error("aiProvider must be 'claude' or 'openai'");
119
+ process.exit(1);
120
+ }
121
+
122
+ setConfigValue(key, value);
123
+ console.log(`Set ${key} = ${maskValue(key, value)}`);
124
+ return;
125
+ }
126
+
127
+ if (subcommand === "get") {
128
+ const key = args[1] as keyof OpenBuilderConfig;
129
+ if (!key) {
130
+ console.error("Usage: openbuilder config get <key>");
131
+ process.exit(1);
132
+ }
133
+
134
+ const config = getConfig();
135
+ const value = config[key] as string | undefined;
136
+ if (value) {
137
+ console.log(maskValue(key, value));
138
+ } else {
139
+ console.log(`(not set)`);
140
+ }
141
+ return;
142
+ }
143
+
144
+ if (subcommand === "delete") {
145
+ const key = args[1] as keyof OpenBuilderConfig;
146
+ if (!key) {
147
+ console.error("Usage: openbuilder config delete <key>");
148
+ process.exit(1);
149
+ }
150
+
151
+ if (!VALID_KEYS.includes(key)) {
152
+ console.error(`Unknown config key: ${key}`);
153
+ process.exit(1);
154
+ }
155
+
156
+ deleteConfigValue(key);
157
+ console.log(`Deleted ${key}`);
158
+ return;
159
+ }
160
+
161
+ console.error(`Unknown subcommand: ${subcommand}`);
162
+ showHelp();
163
+ process.exit(1);
164
+ }
165
+
166
+ main();