sphereai-cli 1.0.5 → 1.0.6
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.
- package/README.md +43 -2
- package/dist/commands/execute.d.ts +1 -1
- package/dist/commands/execute.d.ts.map +1 -1
- package/dist/commands/execute.js +167 -140
- package/dist/commands/execute.js.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/services/cli-api-client.d.ts +13 -2
- package/dist/services/cli-api-client.d.ts.map +1 -1
- package/dist/services/cli-api-client.js +28 -6
- package/dist/services/cli-api-client.js.map +1 -1
- package/dist/types/api-types.d.ts +16 -0
- package/dist/types/api-types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ sphereai auth logout
|
|
|
57
57
|
|
|
58
58
|
### File Management
|
|
59
59
|
|
|
60
|
-
Track files for
|
|
60
|
+
Track files for AI processing. Works similar to git staging.
|
|
61
61
|
|
|
62
62
|
| Command | Description |
|
|
63
63
|
|---------|-------------|
|
|
@@ -68,7 +68,15 @@ Track files for use with SphereAI services. Works similar to git staging.
|
|
|
68
68
|
| `sphereai files status` | Show status of tracked files |
|
|
69
69
|
| `sphereai files ignore` | Show current ignore patterns |
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
### AI Command Execution
|
|
72
|
+
|
|
73
|
+
Execute AI commands with your tracked files.
|
|
74
|
+
|
|
75
|
+
| Command | Description |
|
|
76
|
+
|---------|-------------|
|
|
77
|
+
| `sphereai execute -p <id>` | Execute AI command with tracked files |
|
|
78
|
+
|
|
79
|
+
**File Management Examples:**
|
|
72
80
|
|
|
73
81
|
```bash
|
|
74
82
|
# Add all files from current directory
|
|
@@ -96,6 +104,39 @@ sphereai files remove myfile.txt
|
|
|
96
104
|
sphereai files clear --force
|
|
97
105
|
```
|
|
98
106
|
|
|
107
|
+
**Execution Examples:**
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Execute AI command with tracked files
|
|
111
|
+
sphereai execute --prompt-id 123
|
|
112
|
+
|
|
113
|
+
# Execute with JSON output
|
|
114
|
+
sphereai execute --prompt-id 123 --output json
|
|
115
|
+
|
|
116
|
+
# Save detailed response to a specific directory
|
|
117
|
+
sphereai execute --prompt-id 123 --save-dir ./responses
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### Complete Workflow Example
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# 1. Login
|
|
124
|
+
sphereai auth login YOUR_USER_CHANNEL_KEY
|
|
125
|
+
|
|
126
|
+
# 2. Add files to track
|
|
127
|
+
sphereai files add .
|
|
128
|
+
|
|
129
|
+
# 3. Check what files are tracked
|
|
130
|
+
sphereai files list
|
|
131
|
+
|
|
132
|
+
# 4. Execute AI command with tracked files
|
|
133
|
+
sphereai execute --prompt-id 123
|
|
134
|
+
|
|
135
|
+
# 5. The detailed response is automatically saved to a markdown file
|
|
136
|
+
# 6. Clear tracked files when done
|
|
137
|
+
sphereai files clear --force
|
|
138
|
+
```
|
|
139
|
+
|
|
99
140
|
### .sphereignore File
|
|
100
141
|
|
|
101
142
|
Create a `.sphereignore` file in your project root to exclude files from tracking. It works like `.gitignore`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+J7D"}
|
package/dist/commands/execute.js
CHANGED
|
@@ -1,164 +1,191 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
8
|
-
const
|
|
39
|
+
exports.registerExecuteCommand = registerExecuteCommand;
|
|
40
|
+
const file_tracking_service_1 = require("../services/file-tracking-service");
|
|
41
|
+
const cli_api_client_1 = require("../services/cli-api-client");
|
|
9
42
|
const config_service_1 = require("../services/config-service");
|
|
10
43
|
const formatters_1 = require("../utils/formatters");
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
44
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const ora_1 = __importDefault(require("ora"));
|
|
48
|
+
function registerExecuteCommand(program) {
|
|
49
|
+
program
|
|
14
50
|
.command('execute')
|
|
15
51
|
.alias('exec')
|
|
16
|
-
.description('
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
.description('Start a new repository execution')
|
|
21
|
-
.requiredOption('-r, --repo-id <id>', 'Repository (Git) ID', parseInt)
|
|
22
|
-
.requiredOption('-v, --vendor-id <id>', 'AI Vendor ID', parseInt)
|
|
23
|
-
.requiredOption('-m, --model-id <id>', 'AI Model ID', parseInt)
|
|
24
|
-
.requiredOption('-p, --prompt-id <id>', 'Prompt ID', parseInt)
|
|
25
|
-
.option('-t, --temperature <number>', 'Temperature (0.0 - 2.0)', parseFloat, 0.7)
|
|
26
|
-
.option('-s, --subfolder <path>', 'Working subfolder')
|
|
27
|
-
.option('-d, --depth <number>', 'Folder depth limit', parseInt)
|
|
28
|
-
.option('-e, --exclude <patterns>', 'Additional exclude patterns')
|
|
29
|
-
.option('--include-root-md', 'Include root markdown files', false)
|
|
30
|
-
.option('-o, --output <format>', 'Output format (json|table)', 'table')
|
|
52
|
+
.description('Execute AI command with tracked files')
|
|
53
|
+
.requiredOption('-p, --prompt-id <id>', 'Prompt ID to use for AI processing')
|
|
54
|
+
.option('-o, --output <format>', 'Output format: table or json', 'table')
|
|
55
|
+
.option('--save-dir <dir>', 'Directory to save detailed response (defaults to current directory)', '.')
|
|
31
56
|
.action(async (options) => {
|
|
32
57
|
try {
|
|
33
|
-
|
|
34
|
-
(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
aiVendorId: options.vendorId,
|
|
39
|
-
aiModelId: options.modelId,
|
|
40
|
-
promptId: options.promptId,
|
|
41
|
-
temperature: options.temperature,
|
|
42
|
-
workingSubfolder: options.subfolder,
|
|
43
|
-
folderDepthLimit: options.depth,
|
|
44
|
-
additionalExcludePatterns: options.exclude,
|
|
45
|
-
includeRootMarkdownFiles: options.includeRootMd
|
|
46
|
-
};
|
|
47
|
-
const execution = await api_client_1.apiClient.createExecution(executionData);
|
|
48
|
-
spinner.succeed('Execution created successfully!');
|
|
49
|
-
const format = options.output;
|
|
50
|
-
console.log((0, formatters_1.formatExecution)(execution, format));
|
|
51
|
-
(0, formatters_1.info)(`Execution ID: ${execution.id}`);
|
|
52
|
-
if (execution.uniqueHash) {
|
|
53
|
-
(0, formatters_1.info)(`Unique Hash: ${execution.uniqueHash}`);
|
|
58
|
+
// Validate prompt ID
|
|
59
|
+
const promptId = parseInt(options.promptId, 10);
|
|
60
|
+
if (isNaN(promptId) || promptId <= 0) {
|
|
61
|
+
(0, formatters_1.error)('Invalid prompt ID. Must be a positive number.');
|
|
62
|
+
process.exit(1);
|
|
54
63
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
(0
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.command('get')
|
|
63
|
-
.description('Get execution details by ID or hash')
|
|
64
|
-
.argument('<id-or-hash>', 'Execution ID or unique hash')
|
|
65
|
-
.option('-o, --output <format>', 'Output format (json|table)', 'table')
|
|
66
|
-
.action(async (idOrHash, options) => {
|
|
67
|
-
try {
|
|
64
|
+
// Get tracked files
|
|
65
|
+
const tracked = file_tracking_service_1.fileTrackingService.getTrackedFiles();
|
|
66
|
+
if (tracked.length === 0) {
|
|
67
|
+
(0, formatters_1.error)('No files are currently tracked. Use "sphereai files add ." to add files first.');
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
// Check authentication
|
|
68
71
|
const token = config_service_1.configService.getToken();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// Check if it's a hash (non-numeric) or ID (numeric)
|
|
73
|
-
if (isNaN(Number(idOrHash))) {
|
|
74
|
-
execution = await api_client_1.apiClient.getExecutionByHash(idOrHash);
|
|
72
|
+
if (!token) {
|
|
73
|
+
(0, formatters_1.error)('Not authenticated. Please login first using: sphereai auth login YOUR_KEY');
|
|
74
|
+
process.exit(1);
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
// Set auth token for CLI API client
|
|
77
|
+
cli_api_client_1.cliApiClient.setAuthToken(token);
|
|
78
|
+
// Read file contents
|
|
79
|
+
(0, formatters_1.info)(`Reading ${tracked.length} tracked file(s)...`);
|
|
80
|
+
const files = [];
|
|
81
|
+
let missingFiles = 0;
|
|
82
|
+
for (const trackedFile of tracked) {
|
|
83
|
+
const absolutePath = path.resolve(trackedFile.path);
|
|
84
|
+
if (!fs.existsSync(absolutePath)) {
|
|
85
|
+
(0, formatters_1.warning)(`File not found: ${trackedFile.path}`);
|
|
86
|
+
missingFiles++;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const content = fs.readFileSync(absolutePath, 'utf-8');
|
|
91
|
+
files.push({
|
|
92
|
+
path: trackedFile.path,
|
|
93
|
+
name: path.basename(trackedFile.path),
|
|
94
|
+
code: content
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
(0, formatters_1.warning)(`Failed to read file ${trackedFile.path}: ${err instanceof Error ? err.message : String(err)}`);
|
|
99
|
+
missingFiles++;
|
|
100
|
+
}
|
|
78
101
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
catch (err) {
|
|
84
|
-
(0, errors_1.handleError)(err);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
// List executions command
|
|
88
|
-
execute
|
|
89
|
-
.command('list')
|
|
90
|
-
.alias('ls')
|
|
91
|
-
.description('List executions')
|
|
92
|
-
.option('-p, --page <number>', 'Page number', parseInt, 1)
|
|
93
|
-
.option('-s, --size <number>', 'Page size', parseInt, 20)
|
|
94
|
-
.option('-o, --output <format>', 'Output format (json|table)', 'table')
|
|
95
|
-
.action(async (options) => {
|
|
96
|
-
try {
|
|
97
|
-
const token = config_service_1.configService.getToken();
|
|
98
|
-
(0, errors_1.requireAuth)(token);
|
|
99
|
-
const spinner = (0, ora_1.default)('Fetching executions...').start();
|
|
100
|
-
const executions = await api_client_1.apiClient.listExecutions({
|
|
101
|
-
_page: options.page,
|
|
102
|
-
_size: options.size,
|
|
103
|
-
_order: '-createdAt' // Most recent first
|
|
104
|
-
});
|
|
105
|
-
spinner.stop();
|
|
106
|
-
const format = options.output;
|
|
107
|
-
console.log((0, formatters_1.formatExecutionsList)(executions, format));
|
|
108
|
-
(0, formatters_1.info)(`Showing page ${options.page} (${executions.length} results)`);
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
111
|
-
(0, errors_1.handleError)(err);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
// Get execution steps command
|
|
115
|
-
execute
|
|
116
|
-
.command('steps')
|
|
117
|
-
.description('Get execution steps')
|
|
118
|
-
.argument('<execution-id>', 'Execution ID', parseInt)
|
|
119
|
-
.option('-o, --output <format>', 'Output format (json|table)', 'table')
|
|
120
|
-
.action(async (executionId, options) => {
|
|
121
|
-
try {
|
|
122
|
-
const token = config_service_1.configService.getToken();
|
|
123
|
-
(0, errors_1.requireAuth)(token);
|
|
124
|
-
const spinner = (0, ora_1.default)('Fetching execution steps...').start();
|
|
125
|
-
const steps = await api_client_1.apiClient.getExecutionSteps(executionId);
|
|
126
|
-
spinner.stop();
|
|
127
|
-
const format = options.output;
|
|
128
|
-
console.log((0, formatters_1.formatExecutionSteps)(steps, format));
|
|
129
|
-
if (steps.length === 0) {
|
|
130
|
-
(0, formatters_1.info)('No steps found for this execution');
|
|
102
|
+
if (files.length === 0) {
|
|
103
|
+
(0, formatters_1.error)('No files could be read. Please check file paths and try again.');
|
|
104
|
+
process.exit(1);
|
|
131
105
|
}
|
|
132
|
-
|
|
133
|
-
(0, formatters_1.
|
|
106
|
+
if (missingFiles > 0) {
|
|
107
|
+
(0, formatters_1.warning)(`Skipped ${missingFiles} file(s) that could not be read.`);
|
|
134
108
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
(0,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
109
|
+
(0, formatters_1.success)(`Sending ${files.length} file(s) to AI for processing...`);
|
|
110
|
+
// Show spinner for long-running operation
|
|
111
|
+
const spinner = (0, ora_1.default)('Processing with AI...').start();
|
|
112
|
+
try {
|
|
113
|
+
// Execute command
|
|
114
|
+
const response = await cli_api_client_1.cliApiClient.executeCommand({
|
|
115
|
+
promptId,
|
|
116
|
+
files
|
|
117
|
+
});
|
|
118
|
+
spinner.stop();
|
|
119
|
+
// Display response based on format
|
|
120
|
+
if (options.output === 'json') {
|
|
121
|
+
console.log(JSON.stringify(response, null, 2));
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
console.log('\n' + chalk_1.default.cyan.bold('AI Response:') + '\n');
|
|
125
|
+
if (response.shortAnswer) {
|
|
126
|
+
console.log(chalk_1.default.green.bold('Short Answer:'));
|
|
127
|
+
console.log(response.shortAnswer);
|
|
128
|
+
console.log();
|
|
129
|
+
}
|
|
130
|
+
// Save detailed answer to file if it exists
|
|
131
|
+
if (response.detailedAnswer) {
|
|
132
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').split('T')[0];
|
|
133
|
+
const filename = `sphereai-response-${promptId}-${timestamp}.md`;
|
|
134
|
+
const saveDir = path.resolve(options.saveDir);
|
|
135
|
+
const filepath = path.join(saveDir, filename);
|
|
136
|
+
try {
|
|
137
|
+
// Ensure directory exists
|
|
138
|
+
if (!fs.existsSync(saveDir)) {
|
|
139
|
+
fs.mkdirSync(saveDir, { recursive: true });
|
|
140
|
+
}
|
|
141
|
+
// Create markdown content
|
|
142
|
+
const markdown = `# SphereAI Response - Prompt ${promptId}
|
|
143
|
+
|
|
144
|
+
**Generated:** ${new Date().toLocaleString()}
|
|
145
|
+
|
|
146
|
+
**Files processed:** ${files.length}
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
${response.detailedAnswer}
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Token Usage
|
|
155
|
+
|
|
156
|
+
- **Input tokens:** ${response.inputTokens.toLocaleString()}
|
|
157
|
+
- **Output tokens:** ${response.outputTokens.toLocaleString()}
|
|
158
|
+
- **Total tokens:** ${response.totalTokens.toLocaleString()}
|
|
159
|
+
`;
|
|
160
|
+
fs.writeFileSync(filepath, markdown, 'utf-8');
|
|
161
|
+
console.log(chalk_1.default.green.bold('Detailed Answer:'));
|
|
162
|
+
console.log(chalk_1.default.gray(`Saved to: ${chalk_1.default.cyan(filepath)}`));
|
|
163
|
+
console.log();
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
(0, formatters_1.warning)(`Failed to save detailed response: ${err instanceof Error ? err.message : String(err)}`);
|
|
167
|
+
console.log(chalk_1.default.green.bold('Detailed Answer:'));
|
|
168
|
+
console.log(response.detailedAnswer);
|
|
169
|
+
console.log();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Show token usage
|
|
173
|
+
console.log(chalk_1.default.gray('─'.repeat(60)));
|
|
174
|
+
console.log(chalk_1.default.cyan('Token Usage:'));
|
|
175
|
+
console.log(chalk_1.default.gray(` Input tokens: ${response.inputTokens.toLocaleString()}`));
|
|
176
|
+
console.log(chalk_1.default.gray(` Output tokens: ${response.outputTokens.toLocaleString()}`));
|
|
177
|
+
console.log(chalk_1.default.gray(` Total tokens: ${response.totalTokens.toLocaleString()}`));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
spinner.stop();
|
|
182
|
+
(0, formatters_1.error)(`Failed to execute command: ${err instanceof Error ? err.message : String(err)}`);
|
|
153
183
|
process.exit(1);
|
|
154
184
|
}
|
|
155
|
-
const spinner = (0, ora_1.default)('Updating execution temperature...').start();
|
|
156
|
-
await api_client_1.apiClient.updateExecutionTemperature(executionId, temperature);
|
|
157
|
-
spinner.succeed('Temperature updated successfully!');
|
|
158
|
-
(0, formatters_1.success)(`Execution ${executionId} temperature set to ${temperature.toFixed(2)}`);
|
|
159
185
|
}
|
|
160
186
|
catch (err) {
|
|
161
|
-
(0,
|
|
187
|
+
(0, formatters_1.error)(`Failed to execute command: ${err instanceof Error ? err.message : String(err)}`);
|
|
188
|
+
process.exit(1);
|
|
162
189
|
}
|
|
163
190
|
});
|
|
164
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/commands/execute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,wDA+JC;AAxKD,6EAAwE;AACxE,+DAA0D;AAC1D,+DAA2D;AAC3D,oDAAoE;AACpE,kDAA0B;AAC1B,uCAAyB;AACzB,2CAA6B;AAC7B,8CAAsB;AAEtB,SAAgB,sBAAsB,CAAC,OAAgB;IACrD,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,KAAK,CAAC,MAAM,CAAC;SACb,WAAW,CAAC,uCAAuC,CAAC;SACpD,cAAc,CAAC,sBAAsB,EAAE,oCAAoC,CAAC;SAC5E,MAAM,C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CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;oBACxC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;oBACxC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,oBAAoB,QAAQ,CAAC,WAAW,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC;oBACrF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,oBAAoB,QAAQ,CAAC,YAAY,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC;oBACtF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,oBAAoB,QAAQ,CAAC,WAAW,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC;gBACvF,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,EAAE,CAAC;gBACf,IAAA,kBAAK,EAAC,8BAA8B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACxF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAA,kBAAK,EAAC,8BAA8B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACxF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const commander_1 = require("commander");
|
|
|
11
11
|
const auth_1 = require("./commands/auth");
|
|
12
12
|
const prompts_1 = require("./commands/prompts");
|
|
13
13
|
const files_1 = require("./commands/files");
|
|
14
|
+
const execute_1 = require("./commands/execute");
|
|
14
15
|
const config_service_1 = require("./services/config-service");
|
|
15
16
|
const api_client_1 = require("./services/api-client");
|
|
16
17
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
@@ -44,6 +45,7 @@ program
|
|
|
44
45
|
(0, auth_1.registerAuthCommands)(program);
|
|
45
46
|
(0, prompts_1.registerPromptsCommands)(program);
|
|
46
47
|
(0, files_1.registerFilesCommands)(program);
|
|
48
|
+
(0, execute_1.registerExecuteCommand)(program);
|
|
47
49
|
// Add help examples
|
|
48
50
|
program.addHelpText('after', `
|
|
49
51
|
|
|
@@ -84,6 +86,9 @@ Examples:
|
|
|
84
86
|
# Clear all tracked files
|
|
85
87
|
$ sphereai files clear --force
|
|
86
88
|
|
|
89
|
+
# Execute AI command with tracked files
|
|
90
|
+
$ sphereai execute --prompt-id 123
|
|
91
|
+
|
|
87
92
|
Configuration:
|
|
88
93
|
Config file location: ~/.config/sphereai-cli/config.json
|
|
89
94
|
View config: sphereai auth config
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,oDAA4B;AAE5B,4CAA4C;AAC5C,gBAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAE/B,yCAAoC;AACpC,0CAAuD;AACvD,gDAA6D;AAC7D,4CAAyD;AACzD,8DAA0D;AAC1D,sDAAkD;AAClD,mEAA0C;AAG1C,8BAA8B;AAC9B,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,gDAAgD,CAAC;KAC7D,OAAO,CAAC,sBAAW,CAAC,OAAO,CAAC;KAC5B,MAAM,CAAC,iBAAiB,EAAE,sCAAsC,CAAC;KACjE,IAAI,CAAC,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from 'axios';
|
|
2
|
-
import { AuthResponse } from '../types/api-types';
|
|
2
|
+
import { AuthResponse, ModelUserRequest, ModelUserResponse } from '../types/api-types';
|
|
3
3
|
/**
|
|
4
4
|
* CLI API Client - Used for key-based authentication
|
|
5
5
|
* Uses SPHEREAI_CLI_API_URL endpoint
|
|
6
6
|
*/
|
|
7
7
|
export declare class CliApiClient {
|
|
8
8
|
private client;
|
|
9
|
+
private authToken?;
|
|
9
10
|
constructor(baseURL?: string);
|
|
11
|
+
/**
|
|
12
|
+
* Set authentication token for authenticated requests
|
|
13
|
+
*/
|
|
14
|
+
setAuthToken(token: string): void;
|
|
10
15
|
private handleError;
|
|
11
16
|
/**
|
|
12
|
-
* Authenticate using UserChannelKey (from swagger.
|
|
17
|
+
* Authenticate using UserChannelKey (from cli-swagger.json)
|
|
13
18
|
* POST /api/v1/Auth
|
|
14
19
|
*/
|
|
15
20
|
authenticate(key: string): Promise<AuthResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Execute a command by sending files to AI (from cli-swagger.json)
|
|
23
|
+
* POST /api/v1/Command
|
|
24
|
+
* Requires authentication (Bearer token)
|
|
25
|
+
*/
|
|
26
|
+
executeCommand(request: ModelUserRequest): Promise<ModelUserResponse>;
|
|
16
27
|
request<T>(config: AxiosRequestConfig): Promise<T>;
|
|
17
28
|
}
|
|
18
29
|
export declare const cliApiClient: CliApiClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-api-client.d.ts","sourceRoot":"","sources":["../../src/services/cli-api-client.ts"],"names":[],"mappings":"AAAA,OAAc,EAA6B,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,EAGL,YAAY,
|
|
1
|
+
{"version":3,"file":"cli-api-client.d.ts","sourceRoot":"","sources":["../../src/services/cli-api-client.ts"],"names":[],"mappings":"AAAA,OAAc,EAA6B,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,EAGL,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,SAAS,CAAC,CAAS;gBAEf,OAAO,CAAC,EAAE,MAAM;IA+B5B;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIjC,OAAO,CAAC,WAAW;IAgCnB;;;OAGG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAMtD;;;;OAIG;IACG,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAMrE,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;CAIzD;AAGD,eAAO,MAAM,YAAY,cAAqB,CAAC;AAG/C,eAAe,YAAY,CAAC"}
|
|
@@ -15,27 +15,40 @@ class CliApiClient {
|
|
|
15
15
|
const cliApiUrl = baseURL || config_service_1.configService.getCliApiUrl();
|
|
16
16
|
this.client = axios_1.default.create({
|
|
17
17
|
baseURL: cliApiUrl,
|
|
18
|
-
timeout:
|
|
18
|
+
timeout: 120000, // 2 minutes for AI processing
|
|
19
19
|
headers: {
|
|
20
20
|
'Content-Type': 'application/json'
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
+
// Request interceptor to add auth token
|
|
24
|
+
this.client.interceptors.request.use((config) => {
|
|
25
|
+
if (this.authToken) {
|
|
26
|
+
config.headers.Authorization = `Bearer ${this.authToken}`;
|
|
27
|
+
}
|
|
28
|
+
return config;
|
|
29
|
+
}, (error) => Promise.reject(error));
|
|
23
30
|
// Response interceptor for error handling
|
|
24
31
|
this.client.interceptors.response.use((response) => response, (error) => {
|
|
25
32
|
return Promise.reject(this.handleError(error));
|
|
26
33
|
});
|
|
27
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Set authentication token for authenticated requests
|
|
37
|
+
*/
|
|
38
|
+
setAuthToken(token) {
|
|
39
|
+
this.authToken = token;
|
|
40
|
+
}
|
|
28
41
|
handleError(error) {
|
|
29
42
|
if (error.response) {
|
|
30
43
|
const { status, data } = error.response;
|
|
31
44
|
// Handle specific status codes
|
|
32
45
|
switch (status) {
|
|
33
46
|
case 401:
|
|
34
|
-
return new Error('
|
|
47
|
+
return new Error('Authentication required. Please login first using: sphereai auth login YOUR_KEY');
|
|
35
48
|
case 403:
|
|
36
|
-
return new Error('Access denied. You do not have permission to
|
|
49
|
+
return new Error('Access denied. You do not have permission to perform this action.');
|
|
37
50
|
case 404:
|
|
38
|
-
return new Error(data?.detail || '
|
|
51
|
+
return new Error(data?.detail || 'Endpoint not found');
|
|
39
52
|
case 400:
|
|
40
53
|
if (data?.errors) {
|
|
41
54
|
const errorMessages = Object.entries(data.errors)
|
|
@@ -43,7 +56,7 @@ class CliApiClient {
|
|
|
43
56
|
.join('\n');
|
|
44
57
|
return new Error(`Validation failed:\n${errorMessages}`);
|
|
45
58
|
}
|
|
46
|
-
return new Error(data?.detail || 'Bad request - please check your
|
|
59
|
+
return new Error(data?.detail || 'Bad request - please check your input');
|
|
47
60
|
case 500:
|
|
48
61
|
return new Error('Internal server error. Please try again later.');
|
|
49
62
|
default:
|
|
@@ -58,7 +71,7 @@ class CliApiClient {
|
|
|
58
71
|
}
|
|
59
72
|
}
|
|
60
73
|
/**
|
|
61
|
-
* Authenticate using UserChannelKey (from swagger.
|
|
74
|
+
* Authenticate using UserChannelKey (from cli-swagger.json)
|
|
62
75
|
* POST /api/v1/Auth
|
|
63
76
|
*/
|
|
64
77
|
async authenticate(key) {
|
|
@@ -66,6 +79,15 @@ class CliApiClient {
|
|
|
66
79
|
const response = await this.client.post('/api/v1/Auth', request);
|
|
67
80
|
return response.data;
|
|
68
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Execute a command by sending files to AI (from cli-swagger.json)
|
|
84
|
+
* POST /api/v1/Command
|
|
85
|
+
* Requires authentication (Bearer token)
|
|
86
|
+
*/
|
|
87
|
+
async executeCommand(request) {
|
|
88
|
+
const response = await this.client.post('/api/v1/Command', request);
|
|
89
|
+
return response.data;
|
|
90
|
+
}
|
|
69
91
|
// Generic request method for custom calls
|
|
70
92
|
async request(config) {
|
|
71
93
|
const response = await this.client.request(config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-api-client.js","sourceRoot":"","sources":["../../src/services/cli-api-client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA6E;AAC7E,qDAAiD;
|
|
1
|
+
{"version":3,"file":"cli-api-client.js","sourceRoot":"","sources":["../../src/services/cli-api-client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA6E;AAC7E,qDAAiD;AASjD;;;GAGG;AACH,MAAa,YAAY;IAIvB,YAAY,OAAgB;QAC1B,MAAM,SAAS,GAAG,OAAO,IAAI,8BAAa,CAAC,YAAY,EAAE,CAAC;QAE1D,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,MAAM,EAAE,8BAA8B;YAC/C,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,wCAAwC;QACxC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAClC,CAAC,MAAM,EAAE,EAAE;YACT,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,MAAM,CAAC,OAAO,CAAC,aAAa,GAAG,UAAU,IAAI,CAAC,SAAS,EAAE,CAAC;YAC5D,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CACjC,CAAC;QAEF,0CAA0C;QAC1C,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CACnC,CAAC,QAAQ,EAAE,EAAE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,IAAI,KAAK,CAAC,IAAI,EAAE,MAAM,IAAI,8BAA8B,MAAM,EAAE,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,IAAI,KAAK,CAAC,gHAAgH,CAAC,CAAC;QACrI,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,IAAI,8BAA8B,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,YAAY,CAAC,GAAW;QAC5B,MAAM,OAAO,GAAmB,EAAE,GAAG,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAe,cAAc,EAAE,OAAO,CAAC,CAAC;QAC/E,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,cAAc,CAAC,OAAyB;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAoB,iBAAiB,EAAE,OAAO,CAAC,CAAC;QACvF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,0CAA0C;IAC1C,KAAK,CAAC,OAAO,CAAI,MAA0B;QACzC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAI,MAAM,CAAC,CAAC;QACtD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AAnGD,oCAmGC;AAED,uDAAuD;AAC1C,QAAA,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AAE/C,oCAAoC;AACpC,kBAAe,YAAY,CAAC"}
|
|
@@ -64,4 +64,20 @@ export interface PromptResponse {
|
|
|
64
64
|
createdAt: string;
|
|
65
65
|
updatedAt: string | null;
|
|
66
66
|
}
|
|
67
|
+
export interface CliFile {
|
|
68
|
+
path: string | null;
|
|
69
|
+
name: string | null;
|
|
70
|
+
code: string | null;
|
|
71
|
+
}
|
|
72
|
+
export interface ModelUserRequest {
|
|
73
|
+
promptId: number;
|
|
74
|
+
files: CliFile[] | null;
|
|
75
|
+
}
|
|
76
|
+
export interface ModelUserResponse {
|
|
77
|
+
shortAnswer: string | null;
|
|
78
|
+
detailedAnswer: string | null;
|
|
79
|
+
inputTokens: number;
|
|
80
|
+
outputTokens: number;
|
|
81
|
+
totalTokens: number;
|
|
82
|
+
}
|
|
67
83
|
//# sourceMappingURL=api-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-types.d.ts","sourceRoot":"","sources":["../../src/types/api-types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,oBAAY,QAAQ;IAClB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAGD,MAAM,WAAW,iBAAiB,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