@forwardimpact/guide 0.1.10 → 0.1.13

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 (2) hide show
  1. package/bin/fit-guide.js +110 -12
  2. package/package.json +3 -1
package/bin/fit-guide.js CHANGED
@@ -5,8 +5,8 @@
5
5
  * Conversational agent interface for the Guide knowledge platform.
6
6
  *
7
7
  * Usage:
8
- * bunx fit-guide
9
- * echo "Tell me about the company" | bunx fit-guide
8
+ * npx fit-guide
9
+ * echo "Tell me about the company" | npx fit-guide
10
10
  */
11
11
 
12
12
  import { resolve } from "path";
@@ -18,12 +18,13 @@ if (process.argv.includes("--help") || process.argv.includes("-h")) {
18
18
  console.log(`fit-guide — Conversational agent for the Guide knowledge platform
19
19
 
20
20
  Usage:
21
- bunx fit-guide Start interactive conversation
22
- bunx fit-guide --data=<path> Specify framework data directory
23
- echo "question" | bunx fit-guide Pipe a question directly
21
+ npx fit-guide Start interactive conversation
22
+ npx fit-guide --data=<path> Specify framework data directory
23
+ echo "question" | npx fit-guide Pipe a question directly
24
24
 
25
25
  Options:
26
26
  --data=<path> Path to framework data directory
27
+ --init Generate secrets, .env, and config/config.json
27
28
  --help, -h Show this help message
28
29
  --version, -v Show version
29
30
 
@@ -43,6 +44,103 @@ if (process.argv.includes("--version") || process.argv.includes("-v")) {
43
44
  process.exit(0);
44
45
  }
45
46
 
47
+ // --init flag (works without SERVICE_SECRET)
48
+ if (process.argv.includes("--init")) {
49
+ const { generateJWT, generateSecret, getOrGenerateSecret, updateEnvFile } =
50
+ await import("@forwardimpact/libsecret");
51
+
52
+ const serviceSecret = generateSecret();
53
+ const jwtSecret = await getOrGenerateSecret("JWT_SECRET", () =>
54
+ generateSecret(32),
55
+ );
56
+ const jwtAnonKey = generateJWT(
57
+ {
58
+ iss: "supabase",
59
+ iat: Math.floor(Date.now() / 1000),
60
+ exp: Math.floor(Date.now() / 1000) + 10 * 365 * 24 * 60 * 60,
61
+ role: "anon",
62
+ },
63
+ jwtSecret,
64
+ );
65
+
66
+ await updateEnvFile("SERVICE_SECRET", serviceSecret);
67
+ await updateEnvFile("JWT_SECRET", jwtSecret);
68
+ await updateEnvFile("JWT_ANON_KEY", jwtAnonKey);
69
+
70
+ // Assign unique ports so services don't all bind to the default 3000
71
+ const serviceUrls = {
72
+ SERVICE_AGENT_URL: "grpc://localhost:3002",
73
+ SERVICE_MEMORY_URL: "grpc://localhost:3003",
74
+ SERVICE_LLM_URL: "grpc://localhost:3004",
75
+ SERVICE_VECTOR_URL: "grpc://localhost:3005",
76
+ SERVICE_GRAPH_URL: "grpc://localhost:3006",
77
+ SERVICE_TOOL_URL: "grpc://localhost:3007",
78
+ SERVICE_TRACE_URL: "grpc://localhost:3008",
79
+ };
80
+
81
+ for (const [key, url] of Object.entries(serviceUrls)) {
82
+ await updateEnvFile(key, url);
83
+ }
84
+
85
+ console.log("SERVICE_SECRET was updated in .env");
86
+ console.log("JWT_SECRET is set in .env");
87
+ console.log("JWT_ANON_KEY was updated in .env");
88
+ console.log("Service URLs written to .env (ports 3002–3008).");
89
+
90
+ // Generate config/config.json with minimal service tree
91
+ const configDir = resolve("config");
92
+ const configPath = resolve("config", "config.json");
93
+
94
+ try {
95
+ await fs.access(configPath);
96
+ console.log("config/config.json already exists, skipping.");
97
+ } catch {
98
+ await fs.mkdir(configDir, { recursive: true });
99
+
100
+ const config = {
101
+ init: {
102
+ log_dir: "data/logs",
103
+ shutdown_timeout: 3000,
104
+ services: [
105
+ {
106
+ name: "trace",
107
+ command: "node -e \"import('@forwardimpact/svctrace/server.js')\"",
108
+ },
109
+ {
110
+ name: "vector",
111
+ command: "node -e \"import('@forwardimpact/svcvector/server.js')\"",
112
+ },
113
+ {
114
+ name: "graph",
115
+ command: "node -e \"import('@forwardimpact/svcgraph/server.js')\"",
116
+ },
117
+ {
118
+ name: "llm",
119
+ command: "node -e \"import('@forwardimpact/svcllm/server.js')\"",
120
+ },
121
+ {
122
+ name: "memory",
123
+ command: "node -e \"import('@forwardimpact/svcmemory/server.js')\"",
124
+ },
125
+ {
126
+ name: "tool",
127
+ command: "node -e \"import('@forwardimpact/svctool/server.js')\"",
128
+ },
129
+ {
130
+ name: "agent",
131
+ command: "node -e \"import('@forwardimpact/svcagent/server.js')\"",
132
+ },
133
+ ],
134
+ },
135
+ };
136
+
137
+ await fs.writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
138
+ console.log("config/config.json created with service configuration.");
139
+ }
140
+
141
+ process.exit(0);
142
+ }
143
+
46
144
  // SERVICE_SECRET gate — provide onboarding instructions instead of a cryptic error
47
145
  if (!process.env.SERVICE_SECRET) {
48
146
  console.log(`fit-guide — Conversational agent for the Guide knowledge platform
@@ -54,12 +152,12 @@ services must be available:
54
152
 
55
153
  To get started:
56
154
 
57
- 1. Clone the monorepo and run: just rc-start
58
- 2. Set SERVICE_SECRET in your environment
59
- 3. Run: bunx fit-guide
155
+ 1. Run: npx fit-guide --init
156
+ 2. Start the service stack: npx fit-rc start
157
+ 3. Run: npx fit-guide
60
158
 
61
159
  Documentation: https://www.forwardimpact.team/guide
62
- Run bunx fit-guide --help for CLI options.`);
160
+ Run npx fit-guide --help for CLI options.`);
63
161
  process.exit(1);
64
162
  }
65
163
 
@@ -79,8 +177,8 @@ The agent maintains conversation context across multiple turns.
79
177
 
80
178
  **Examples:**
81
179
 
82
- echo "Tell me about the company" | bunx fit-guide
83
- printf "What is microservices?\\nWhat are the benefits?\\n" | bunx fit-guide`;
180
+ echo "Tell me about the company" | npx fit-guide
181
+ printf "What is microservices?\\nWhat are the benefits?\\n" | npx fit-guide`;
84
182
 
85
183
  // Parse --data flag from CLI args
86
184
  const dataArg = process.argv.find((a) => a.startsWith("--data="));
@@ -173,7 +271,7 @@ Error: ${err.message}
173
271
  Ensure all required services are running:
174
272
  agent, llm, memory, graph, vector, tool, trace, web
175
273
 
176
- For local development: just rc-start
274
+ Start the service stack: npx fit-rc start
177
275
  Documentation: https://www.forwardimpact.team/guide`);
178
276
  process.exit(1);
179
277
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forwardimpact/guide",
3
- "version": "0.1.10",
3
+ "version": "0.1.13",
4
4
  "description": "Conversational agent for engineering framework guidance — How do I find my bearing?",
5
5
  "license": "Apache-2.0",
6
6
  "author": "D. Olsson <hi@senzilla.io>",
@@ -34,7 +34,9 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@forwardimpact/libcodegen": "^0.1.32",
37
+ "@forwardimpact/librc": "^0.1.16",
37
38
  "@forwardimpact/libconfig": "^0.1.58",
39
+ "@forwardimpact/libsecret": "^0.1.7",
38
40
  "@forwardimpact/librepl": "^0.1.0",
39
41
  "@forwardimpact/librpc": "^0.1.77",
40
42
  "@forwardimpact/libstorage": "^0.1.53",