oncall-cli 2.0.1

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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +172 -0
  3. package/bin/oncall.js +303 -0
  4. package/dist/api.d.ts +1 -0
  5. package/dist/api.js +23 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/cli.d.ts +2 -0
  8. package/dist/cli.js +91 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/code_hierarchy.d.ts +4 -0
  11. package/dist/code_hierarchy.js +92 -0
  12. package/dist/code_hierarchy.js.map +1 -0
  13. package/dist/config.d.ts +9 -0
  14. package/dist/config.js +12 -0
  15. package/dist/config.js.map +1 -0
  16. package/dist/helpers/cli-helpers.d.ts +22 -0
  17. package/dist/helpers/cli-helpers.js +261 -0
  18. package/dist/helpers/cli-helpers.js.map +1 -0
  19. package/dist/helpers/config-helpers.js +161 -0
  20. package/dist/helpers/ripgrep-tool.d.ts +15 -0
  21. package/dist/helpers/ripgrep-tool.js +110 -0
  22. package/dist/helpers/ripgrep-tool.js.map +1 -0
  23. package/dist/index.d.ts +3 -0
  24. package/dist/index.js +545 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/logsManager.d.ts +31 -0
  27. package/dist/logsManager.js +90 -0
  28. package/dist/logsManager.js.map +1 -0
  29. package/dist/tools/ripgrep.d.ts +15 -0
  30. package/dist/tools/ripgrep.js +110 -0
  31. package/dist/tools/ripgrep.js.map +1 -0
  32. package/dist/ui-graph.d.ts +1 -0
  33. package/dist/ui-graph.js +125 -0
  34. package/dist/ui-graph.js.map +1 -0
  35. package/dist/useWebSocket.d.ts +21 -0
  36. package/dist/useWebSocket.js +411 -0
  37. package/dist/useWebSocket.js.map +1 -0
  38. package/dist/utils/version-check.d.ts +2 -0
  39. package/dist/utils/version-check.js +124 -0
  40. package/dist/utils/version-check.js.map +1 -0
  41. package/dist/utils.d.ts +1 -0
  42. package/dist/utils.js +22 -0
  43. package/dist/utils.js.map +1 -0
  44. package/dist/websocket-server.d.ts +24 -0
  45. package/dist/websocket-server.js +221 -0
  46. package/dist/websocket-server.js.map +1 -0
  47. package/package.json +46 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Revise Network
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # OnCall CLI
2
+
3
+ **OnCall - Your AI-powered CLI Debugger**
4
+
5
+ OnCall CLI is an intelligent command-line tool that helps you debug your applications in real-time using AI assistance. Run your commands, view logs, and get AI-powered insights all in one interactive terminal interface.
6
+
7
+ ## Features
8
+
9
+ - šŸ¤– **AI-Powered Debugging**: Get intelligent assistance while debugging your applications
10
+ - šŸ“Š **Real-time Log Analysis**: View and analyze command output logs in real-time
11
+ - šŸ” **Code Search**: Search through your codebase with AI assistance
12
+ - šŸ’¬ **Interactive Chat**: Chat with AI about your debugging issues
13
+ - šŸš€ **Easy Setup**: Get started in minutes with simple initialization
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install -g oncall-cli
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### 1. Initialize OnCall
24
+
25
+ ```bash
26
+ oncall init -m "Your project description"
27
+ ```
28
+
29
+ This will:
30
+ - Create a configuration directory at `~/.oncall/`
31
+ - Generate an `oncall.yaml` file in your project directory
32
+ - Set up your project for OnCall
33
+
34
+ ### 2. Login
35
+
36
+ Get your API key from [OnCall Web Studio](https://app.oncall.build) and login:
37
+
38
+ ```bash
39
+ oncall login <your-auth-key>
40
+ ```
41
+
42
+ ### 3. Start Debugging
43
+
44
+ Run any command with OnCall:
45
+
46
+ ```bash
47
+ oncall npm run dev
48
+ oncall python app.py
49
+ oncall node server.js
50
+ ```
51
+
52
+ OnCall will launch an interactive terminal interface where you can:
53
+ - View command logs in real-time
54
+ - Chat with AI about debugging issues
55
+ - Search your codebase
56
+ - Get intelligent suggestions
57
+
58
+ ## Commands
59
+
60
+ ### `oncall init [-id <project-id>] -m <description>`
61
+
62
+ Initialize OnCall configuration and register your project directory.
63
+
64
+ **Options:**
65
+ - `-id <project-id>`: Specify a project ID (optional)
66
+ - `-m <description>`: Project description (required)
67
+
68
+ **Example:**
69
+ ```bash
70
+ oncall init -id my-project -m "Node.js API backend"
71
+ ```
72
+
73
+ ### `oncall login <your-auth-key>`
74
+
75
+ Login to OnCall using your authentication key from OnCall Web Studio.
76
+
77
+ **Example:**
78
+ ```bash
79
+ oncall login abc123xyz789
80
+ ```
81
+
82
+ ### `oncall cluster`
83
+
84
+ Start the lightweight local WebSocket server for cluster functionality.
85
+
86
+ **Example:**
87
+ ```bash
88
+ oncall cluster
89
+ ```
90
+
91
+ ### `oncall config [-id <project-id>] -m <description>`
92
+
93
+ Update project configuration for the current directory.
94
+
95
+ **Example:**
96
+ ```bash
97
+ oncall config -id my-project -m "Updated description"
98
+ ```
99
+
100
+ ### `oncall <command>...`
101
+
102
+ Run any command with OnCall's interactive debugging interface.
103
+
104
+ **Examples:**
105
+ ```bash
106
+ oncall npm run dev
107
+ oncall python manage.py runserver
108
+ oncall docker-compose up
109
+ ```
110
+
111
+ ## Configuration
112
+
113
+ OnCall stores its configuration in `~/.oncall/config`. You can manually edit this file if needed:
114
+
115
+ ```bash
116
+ # OnCall Configuration File
117
+ #
118
+ # Place your OnCall API key here.
119
+ # You can get a key from OnCall Web Studio.
120
+ #
121
+ API_KEY=your-api-key-here
122
+
123
+ # Project mappings (stored as JSON)
124
+ projects=[]
125
+ ```
126
+
127
+ ## Project Metadata
128
+
129
+ OnCall creates an `oncall.yaml` file in your project directory with metadata:
130
+
131
+ ```yaml
132
+ id: "project-id"
133
+ description: "Your project description"
134
+ name: "Project Name"
135
+ window_id: 1234567890
136
+ logs_available: true
137
+ code_available: true
138
+ ```
139
+
140
+ ## Environment Variables
141
+
142
+ - `ONCALL_CLUSTER_URL`: WebSocket URL for the cluster server (default: `ws://127.0.0.1:4466`)
143
+ - `ONCALL_WS_PORT`: Port for the WebSocket server (default: `6111`)
144
+ - `ONCALL_WS_HOST`: Host for the WebSocket server (default: `127.0.0.1`)
145
+ - `API_BASE_URL`: Base URL for the OnCall API (default: `https://api.oncall.build/v2/api`)
146
+
147
+ ## Keyboard Shortcuts
148
+
149
+ When using the interactive interface:
150
+
151
+ - `Tab`: Switch focus between panes
152
+ - `↑/↓`: Scroll (Keyboard Only)
153
+ - `Enter`: Send message
154
+ - `Ctrl+D`: Toggle chat/logs view
155
+ - `Ctrl+C`: Exit
156
+ - `Ctrl+R`: Reload AI chat
157
+
158
+ ## Requirements
159
+
160
+ - Node.js 18+
161
+ - npm or yarn
162
+
163
+ ## Support
164
+
165
+ For issues, questions, or contributions, please visit:
166
+ - Website: [https://oncall.build](https://oncall.build)
167
+ - Web Studio: [https://app.oncall.build](https://app.oncall.build)
168
+
169
+ ## License
170
+
171
+ MIT
172
+
package/bin/oncall.js ADDED
@@ -0,0 +1,303 @@
1
+ #!/usr/bin/env node
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import axios from "axios";
5
+ import { fileURLToPath } from "url";
6
+ import {
7
+ writeProjects,
8
+ readProjects,
9
+ upsertConfigValue,
10
+ parseConfigFlags,
11
+ resolveProjectId,
12
+ promptForInput,
13
+ } from "../dist/helpers/config-helpers.js";
14
+ import {
15
+ CONFIG_PATH,
16
+ CONFIG_TEMPLATE,
17
+ ensureConfigDir,
18
+ buildYaml,
19
+ loadProjectMetadata,
20
+ registerProjectWithCluster,
21
+ ensureClusterIsReady,
22
+ printHelp,
23
+ } from "../dist/helpers/cli-helpers.js";
24
+ import {
25
+ checkVersionAndExit,
26
+ checkVersionCompatibility,
27
+ } from "../dist/utils/version-check.js";
28
+
29
+ const __filename = fileURLToPath(import.meta.url);
30
+ const __dirname = path.dirname(__filename);
31
+
32
+ const pkgPath = path.resolve(__dirname, "../package.json");
33
+ const pkgJson = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
34
+
35
+ const args = process.argv.slice(2);
36
+
37
+ const detectedProjectMetadata = loadProjectMetadata();
38
+ const projectRegistrationPromise = detectedProjectMetadata
39
+ ? registerProjectWithCluster(detectedProjectMetadata)
40
+ : Promise.resolve(null);
41
+
42
+ const API_BASE_URL =
43
+ process.env.API_BASE_URL || "https://api.oncall.build/v2/api";
44
+
45
+ async function fetchYamlName(description, cwdPath = process.cwd()) {
46
+ const url = `${API_BASE_URL}/tool/generateyamlName`;
47
+ try {
48
+ const response = await axios.post(url, {
49
+ currentDirectory: cwdPath,
50
+ description,
51
+ });
52
+ const name = response?.data?.data?.name;
53
+ if (typeof name === "string" && name.trim()) {
54
+ return name.trim();
55
+ }
56
+ return null;
57
+ } catch (error) {
58
+ await checkVersionCompatibility(true).catch(() => {});
59
+ console.warn(
60
+ "Failed to fetch project name from OnCall API.",
61
+ error?.message || error
62
+ );
63
+ return null;
64
+ }
65
+ }
66
+
67
+ async function handleInit(argsList) {
68
+ try {
69
+ ensureConfigDir();
70
+ if (!fs.existsSync(CONFIG_PATH)) {
71
+ fs.writeFileSync(CONFIG_PATH, CONFIG_TEMPLATE, "utf8");
72
+ console.log(
73
+ `\nšŸŽ‰ Successfully initialized OnCall!\nConfiguration file created at: ${CONFIG_PATH}\n\nPlease edit this file and add your OnCall API KEY:\nAPI_KEY=<YOUR_ONCALL_API_KEY>\n`
74
+ );
75
+ }
76
+
77
+ const { projectId, message } = parseConfigFlags(argsList);
78
+ const resolvedProjectId =
79
+ projectId ||
80
+ (await promptForInput(
81
+ "\nEnter a project ID so OnCall can keep all sessions that share it in sync :"
82
+ ));
83
+
84
+ const generatedName = await fetchYamlName(message);
85
+ const yamlPath = path.join(process.cwd(), "oncall.yaml");
86
+ const yamlContent = buildYaml(resolvedProjectId, message, generatedName);
87
+ const isExists = fs.existsSync(yamlPath);
88
+ fs.writeFileSync(yamlPath, yamlContent, "utf8");
89
+ if (isExists) {
90
+ console.log(`Updated project config at ${yamlPath}`);
91
+ } else {
92
+ console.log(`Created project config at ${yamlPath}`);
93
+ }
94
+ process.exit(0);
95
+ } catch (err) {
96
+ console.error(`\nāŒ Error initializing OnCall:`, err);
97
+ process.exit(1);
98
+ }
99
+ }
100
+
101
+ function handleLogin(authKey) {
102
+ if (!authKey || typeof authKey !== "string" || !authKey.trim()) {
103
+ console.error("\nāŒ Usage: oncall login <your-auth-key>");
104
+ process.exit(1);
105
+ }
106
+ try {
107
+ ensureConfigDir();
108
+ let contents = "";
109
+ if (fs.existsSync(CONFIG_PATH)) {
110
+ contents = fs.readFileSync(CONFIG_PATH, "utf8");
111
+ }
112
+ const updatedContents = upsertConfigValue(contents, "API_KEY", authKey);
113
+ fs.writeFileSync(CONFIG_PATH, updatedContents, "utf8");
114
+ console.log("āœ… Auth key saved.");
115
+ process.exit(0);
116
+ } catch (err) {
117
+ console.error("āŒ Failed to save auth key:", err);
118
+ process.exit(1);
119
+ }
120
+ }
121
+
122
+ async function handleConfig(argsList) {
123
+ if (!fs.existsSync(CONFIG_PATH)) {
124
+ console.error(
125
+ "No OnCall configuration found. Run `oncall init` or `oncall login` first."
126
+ );
127
+ process.exit(1);
128
+ }
129
+
130
+ const { projectId, message } = parseConfigFlags(argsList);
131
+ const cwdPath = process.cwd();
132
+ const cwdMetadata = loadProjectMetadata(cwdPath);
133
+ const projectName = cwdMetadata?.name ?? null;
134
+ const window_id =
135
+ typeof cwdMetadata?.window_id === "number"
136
+ ? cwdMetadata.window_id
137
+ : Date.now();
138
+ const logs_available =
139
+ typeof cwdMetadata?.logs_available === "boolean"
140
+ ? cwdMetadata.logs_available
141
+ : true;
142
+ const code_available =
143
+ typeof cwdMetadata?.code_available === "boolean"
144
+ ? cwdMetadata.code_available
145
+ : true;
146
+
147
+ let contents = fs.readFileSync(CONFIG_PATH, "utf8");
148
+ const projectsList = readProjects(contents);
149
+ const resolvedProjectId = await resolveProjectId(projectId, projectsList);
150
+ let projectEntry = projectsList.find(
151
+ (entry) => entry.id === resolvedProjectId
152
+ );
153
+ if (!projectEntry) {
154
+ projectEntry = { id: resolvedProjectId, projects: [] };
155
+ projectsList.push(projectEntry);
156
+ }
157
+
158
+ const existingIndex = projectEntry.projects.findIndex(
159
+ (entry) => entry.path === cwdPath
160
+ );
161
+ if (existingIndex >= 0) {
162
+ const existingProject = projectEntry.projects[existingIndex];
163
+ existingProject.description = message;
164
+ if (projectName) {
165
+ existingProject.name = projectName;
166
+ }
167
+ existingProject.window_id = window_id;
168
+ existingProject.logs_available = logs_available;
169
+ existingProject.code_available = code_available;
170
+ console.log(
171
+ `šŸ” Updated description for ${cwdPath} under project ${resolvedProjectId}.`
172
+ );
173
+ } else {
174
+ const newProject = {
175
+ path: cwdPath,
176
+ description: message,
177
+ name: projectName ?? undefined,
178
+ window_id,
179
+ logs_available,
180
+ code_available,
181
+ };
182
+ projectEntry.projects.push(newProject);
183
+ console.log(`āœ… Added ${cwdPath} to project ${resolvedProjectId}.`);
184
+ }
185
+
186
+ contents = writeProjects(contents, projectsList);
187
+ fs.writeFileSync(CONFIG_PATH, contents, "utf8");
188
+ process.exit(0);
189
+ }
190
+
191
+ async function ensureClusterReady() {
192
+ return ensureClusterIsReady(
193
+ detectedProjectMetadata,
194
+ projectRegistrationPromise
195
+ );
196
+ }
197
+
198
+ async function handleClusterCommand(argsList) {
199
+ if (argsList.length > 0) {
200
+ console.warn(
201
+ `The cluster command does not accept additional arguments. Received: ${argsList.join(
202
+ " "
203
+ )}`
204
+ );
205
+ }
206
+
207
+ let startOnCallWebSocketServer;
208
+ try {
209
+ ({ startOnCallWebSocketServer } = await import(
210
+ "../dist/websocket-server.js"
211
+ ));
212
+ } catch (err) {
213
+ console.error("\nFailed to load the WebSocket server bundle.", err);
214
+ process.exit(1);
215
+ }
216
+
217
+ try {
218
+ const server = await startOnCallWebSocketServer({
219
+ port: 4466,
220
+ });
221
+ const address = server.address;
222
+ const host = address?.address ?? "127.0.0.1";
223
+ const port = address?.port ?? 4466;
224
+ console.log(
225
+ `OnCall server is running at ws://${host}:${port}\nPress Ctrl+C to stop.`
226
+ );
227
+
228
+ let shuttingDown = false;
229
+ const shutdown = async (signal) => {
230
+ if (shuttingDown) return;
231
+ shuttingDown = true;
232
+ console.log(`\nReceived ${signal}. Shutting down WebSocket server...`);
233
+ try {
234
+ await server.stop();
235
+ } catch (error) {
236
+ console.error("Error while stopping the WebSocket server:", error);
237
+ } finally {
238
+ process.exit(0);
239
+ }
240
+ };
241
+
242
+ ["SIGINT", "SIGTERM"].forEach((signal) => {
243
+ process.once(signal, () => shutdown(signal));
244
+ });
245
+ } catch (error) {
246
+ console.error("\nFailed to start the WebSocket server:", error);
247
+ process.exit(1);
248
+ }
249
+ }
250
+
251
+ async function main() {
252
+ if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
253
+ printHelp();
254
+ checkVersionCompatibility();
255
+ process.exit(0);
256
+ }
257
+
258
+ if (args.includes("--version") || args.includes("-v")) {
259
+ console.log(pkgJson.version || "0.0.0");
260
+ process.exit(0);
261
+ }
262
+
263
+ await checkVersionAndExit();
264
+
265
+ const command = args[0];
266
+ if (command === "init") {
267
+ projectRegistrationPromise.catch(() => null);
268
+ await handleInit(args);
269
+ return;
270
+ }
271
+ if (command === "login") {
272
+ projectRegistrationPromise.catch(() => null);
273
+ handleLogin(args[1]);
274
+ return;
275
+ }
276
+ if (command === "cluster") {
277
+ projectRegistrationPromise.catch(() => null);
278
+ await handleClusterCommand(args.slice(1));
279
+ return;
280
+ }
281
+ if (command === "config") {
282
+ projectRegistrationPromise.catch(() => null);
283
+ await handleConfig(args);
284
+ return;
285
+ }
286
+
287
+ const clusterReady = await ensureClusterReady();
288
+ if (!clusterReady) {
289
+ console.error(
290
+ "\nUnable to reach the local OnCall Cluster server.\nPlease start it in another terminal with `oncall cluster` and run your command again.\n"
291
+ );
292
+ process.exit(1);
293
+ }
294
+
295
+ try {
296
+ await import("../dist/index.js");
297
+ } catch (err) {
298
+ console.error(err);
299
+ process.exit(1);
300
+ }
301
+ }
302
+
303
+ main();
package/dist/api.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const toolFunctionCall: (tool_call_id: any, resultArgs: any, args: any, function_name: any) => Promise<any>;
package/dist/api.js ADDED
@@ -0,0 +1,23 @@
1
+ import axios from "axios";
2
+ import { config } from "./config.js";
3
+ import { checkVersionCompatibility } from "./utils/version-check.js";
4
+ const BASE_URL = config.api_base_url;
5
+ axios.interceptors.response.use((response) => response, async (error) => {
6
+ if (error.response) {
7
+ const isCompatible = await checkVersionCompatibility(true);
8
+ if (!isCompatible) {
9
+ return Promise.reject(new Error("CLI version deprecated. Try updating to the latest version."));
10
+ }
11
+ }
12
+ return Promise.reject(error);
13
+ });
14
+ export const toolFunctionCall = async (tool_call_id, resultArgs, args, function_name) => {
15
+ const result = await axios.post(`${BASE_URL}/tool/toolFunctionCall`, {
16
+ tool_call_id,
17
+ resultArgs,
18
+ args,
19
+ function_name,
20
+ });
21
+ return result?.data;
22
+ };
23
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC;AAErC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAC7B,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EACtB,KAAK,EAAE,KAAK,EAAE,EAAE;IACd,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,MAAM,YAAY,GAAG,MAAM,yBAAyB,CAAC,IAAI,CAAC,CAAC;QAC3D,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC,CAAC;QAClG,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACnC,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,aAAa,EACb,EAAE;IACF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,wBAAwB,EAAE;QACnE,YAAY;QACZ,UAAU;QACV,IAAI;QACJ,aAAa;KACd,CAAC,CAAC;IACH,OAAO,MAAM,EAAE,IAAI,CAAC;AACtB,CAAC,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env tsx
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env tsx
2
+ import * as fs from "fs";
3
+ import * as path from "path";
4
+ import * as os from "os";
5
+ import { render } from "ink";
6
+ import React from "react";
7
+ // The App component must be imported. We rely on index.tsx exporting it.
8
+ import { App } from "./index.js";
9
+ import * as dotenv from "dotenv";
10
+ import chalk from "chalk";
11
+ // --- Configuration Constants ---
12
+ const HOME_DIR = os.homedir();
13
+ const ONCALL_DIR = path.join(HOME_DIR, ".oncall");
14
+ const CONFIG_PATH = path.join(ONCALL_DIR, "config");
15
+ const CONFIG_CONTENT = `# OnCall Configuration File
16
+ #
17
+ # Place your OnCall API key here.
18
+ # You can get a key from OnCall Web Studio.
19
+ #
20
+ API_KEY=
21
+ `;
22
+ function handleInit() {
23
+ if (fs.existsSync(CONFIG_PATH)) {
24
+ console.warn(`
25
+ āš ļø Warning: OnCall configuration already exists.
26
+ Path: ${CONFIG_PATH}
27
+ If you need to re-initialize, please delete the file first.
28
+ `);
29
+ process.exit(0);
30
+ }
31
+ try {
32
+ if (!fs.existsSync(ONCALL_DIR)) {
33
+ fs.mkdirSync(ONCALL_DIR, { recursive: true });
34
+ console.log(`āœ… Created configuration directory: ${ONCALL_DIR}`);
35
+ }
36
+ fs.writeFileSync(CONFIG_PATH, CONFIG_CONTENT);
37
+ console.log(`
38
+ šŸŽ‰ Successfully initialized OnCall!
39
+ Configuration file created at: ${CONFIG_PATH}
40
+
41
+ Please edit this file and add your OnCall API KEY:
42
+ API_KEY=<YOUR_ONCALL_API_KEY>
43
+
44
+ Then run: oncall <your command here>
45
+ (e.g., oncall npm run dev)
46
+ `);
47
+ process.exit(0);
48
+ }
49
+ catch (error) {
50
+ console.error(`\nāŒ Error initializing OnCall:`, error);
51
+ process.exit(1);
52
+ }
53
+ }
54
+ function runTuiApp() {
55
+ dotenv.config({ path: CONFIG_PATH, override: true });
56
+ // 2. Check for API key presence before rendering the app
57
+ if (!process.env.API_KEY || process.env.API_KEY.trim() === "") {
58
+ const pathDisplay = CONFIG_PATH;
59
+ console.error(chalk.redBright("\nāŒ ERROR: API_KEY is missing or empty in your configuration file."));
60
+ console.error(chalk.yellow(`Please edit ${pathDisplay} and add your API key.\n`));
61
+ process.exit(1);
62
+ }
63
+ if (!fs.existsSync(CONFIG_PATH)) {
64
+ console.error(`
65
+ āŒ OnCall is not configured.
66
+ Please run: oncall init
67
+ `);
68
+ process.exit(1);
69
+ }
70
+ // add custom logic to verify API KEY authenticity
71
+ render(React.createElement(App, {}));
72
+ }
73
+ const args = process.argv.slice(2);
74
+ const command = args[0];
75
+ if (command === "init") {
76
+ handleInit();
77
+ }
78
+ else if (command) {
79
+ runTuiApp();
80
+ }
81
+ else {
82
+ console.log(`
83
+ OnCall - Your AI-powered CLI Debugger.
84
+
85
+ Usage:
86
+ oncall init - Create the configuration file (~/.oncall/config)
87
+ oncall <command>... - Run a command and launch the interactive AI debugger
88
+ `);
89
+ process.exit(0);
90
+ }
91
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,yEAAyE;AACzE,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,kCAAkC;AAClC,MAAM,QAAQ,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AAClD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AACpD,MAAM,cAAc,GAAG;;;;;;CAMtB,CAAC;AAEF,SAAS,UAAU;IACjB,IAAI,EAAE,CAAC,UAAU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