staffos 0.1.5 → 0.1.7
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/bin/cli.js +68 -12
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -125,32 +125,89 @@ function getFilesRecursive(dir, fileList = []) {
|
|
|
125
125
|
const modelsPricing = {
|
|
126
126
|
'claude-sonnet': { name: 'Claude 4.8 Sonnet', input: 3.00, output: 15.00 },
|
|
127
127
|
'claude-opus': { name: 'Claude 4.8 Opus', input: 15.00, output: 75.00 },
|
|
128
|
-
'gemini-pro': { name: 'Gemini 3.1 Pro', input: 2.00, output: 12.00 },
|
|
129
|
-
'gemini-flash': { name: 'Gemini 3.5 Flash', input: 0.075, output: 0.30 },
|
|
130
|
-
'gpt-5.5': { name: 'GPT 5.5', input: 5.00, output: 30.00 },
|
|
128
|
+
'gemini-pro': { name: 'Gemini 3.1 Pro (OpenCode)', input: 2.00, output: 12.00 },
|
|
129
|
+
'gemini-flash': { name: 'Gemini 3.5 Flash (Antigravity 2.0)', input: 0.075, output: 0.30 },
|
|
130
|
+
'gpt-5.5': { name: 'GPT 5.5 (Codex)', input: 5.00, output: 30.00 },
|
|
131
131
|
'local': { name: 'Modelos Locales (Ollama/DeepSeek)', input: 0.00, output: 0.00 }
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
// Auto-detect the active AI environment
|
|
135
|
+
function detectActiveAI() {
|
|
136
|
+
// Heuristic 1: Env Var flags (Explicit platform setups)
|
|
137
|
+
if (process.env.ANTIGRAVITY === 'true' || process.env.ANTIGRAVITY_VERSION) {
|
|
138
|
+
return { key: 'gemini-flash', reason: 'detección de entorno Antigravity 2.0' };
|
|
139
|
+
}
|
|
140
|
+
if (process.env.CODEX === 'true' || process.env.CODEX_AGENT) {
|
|
141
|
+
return { key: 'gpt-5.5', reason: 'detección de entorno OpenAI Codex' };
|
|
142
|
+
}
|
|
143
|
+
if (process.env.OPENCODE === 'true') {
|
|
144
|
+
return { key: 'gemini-pro', reason: 'detección de entorno OpenCode' };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Heuristic 2: Directory structures
|
|
148
|
+
if (fs.existsSync(path.join(targetDir, '.opencode')) || fs.existsSync(path.join(targetDir, 'opencode.json')) || fs.existsSync(path.join(targetDir, 'opencode.jsonc'))) {
|
|
149
|
+
return { key: 'gemini-pro', reason: 'configuración de OpenCode detectada (.opencode)' };
|
|
150
|
+
}
|
|
151
|
+
if (fs.existsSync(path.join(targetDir, 'adapters/codex')) || fs.existsSync(path.join(targetDir, 'codex.json'))) {
|
|
152
|
+
return { key: 'gpt-5.5', reason: 'configuración de Codex detectada (adapters/codex)' };
|
|
153
|
+
}
|
|
154
|
+
if (fs.existsSync(path.join(targetDir, '.gemini')) || fs.existsSync(path.join(targetDir, 'adapters/antigravity'))) {
|
|
155
|
+
return { key: 'gemini-flash', reason: 'configuración de Antigravity 2.0 detectada (.gemini)' };
|
|
156
|
+
}
|
|
157
|
+
if (fs.existsSync(path.join(targetDir, '.claudecode'))) {
|
|
158
|
+
return { key: 'claude-sonnet', reason: 'directorio .claudecode detectado' };
|
|
159
|
+
}
|
|
160
|
+
if (fs.existsSync(path.join(targetDir, '.cursorrules'))) {
|
|
161
|
+
if (process.env.OPENAI_API_KEY && !process.env.ANTHROPIC_API_KEY) {
|
|
162
|
+
return { key: 'gpt-5.5', reason: 'archivo .cursorrules y OPENAI_API_KEY detectados' };
|
|
163
|
+
}
|
|
164
|
+
return { key: 'claude-sonnet', reason: 'archivo .cursorrules detectado (Cursor default)' };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Heuristic 3: Env Var keys
|
|
168
|
+
if (process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY) {
|
|
169
|
+
return { key: 'gemini-pro', reason: 'variable de entorno GEMINI_API_KEY / GOOGLE_API_KEY' };
|
|
170
|
+
}
|
|
171
|
+
if (process.env.ANTHROPIC_API_KEY) {
|
|
172
|
+
return { key: 'claude-sonnet', reason: 'variable de entorno ANTHROPIC_API_KEY' };
|
|
173
|
+
}
|
|
174
|
+
if (process.env.OPENAI_API_KEY) {
|
|
175
|
+
return { key: 'gpt-5.5', reason: 'variable de entorno OPENAI_API_KEY' };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Heuristic 4: Terminal program
|
|
179
|
+
if (process.env.TERM_PROGRAM === 'vscode') {
|
|
180
|
+
return { key: 'claude-sonnet', reason: 'ejecutado bajo Cursor/VSCode' };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return { key: 'claude-sonnet', reason: 'predeterminado por defecto' };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function getModelSelection() {
|
|
135
187
|
const modelArg = process.argv.find(arg => arg.startsWith('--model='));
|
|
136
188
|
if (modelArg) {
|
|
137
|
-
|
|
189
|
+
const key = modelArg.split('=')[1].toLowerCase();
|
|
190
|
+
return { key, reason: 'parámetro --model especificado' };
|
|
138
191
|
}
|
|
139
192
|
const modelIndex = process.argv.indexOf('-m');
|
|
140
193
|
if (modelIndex !== -1 && process.argv[modelIndex + 1]) {
|
|
141
|
-
|
|
194
|
+
const key = process.argv[modelIndex + 1].toLowerCase();
|
|
195
|
+
return { key, reason: 'parámetro -m especificado' };
|
|
142
196
|
}
|
|
143
|
-
|
|
197
|
+
|
|
198
|
+
// Run auto-detection
|
|
199
|
+
return detectActiveAI();
|
|
144
200
|
}
|
|
145
201
|
|
|
146
202
|
// Estimate token savings for the current workspace
|
|
147
203
|
function runEstimator() {
|
|
148
|
-
const
|
|
149
|
-
const pricing = modelsPricing[
|
|
204
|
+
const selection = getModelSelection();
|
|
205
|
+
const pricing = modelsPricing[selection.key] || modelsPricing['claude-sonnet'];
|
|
150
206
|
|
|
151
207
|
console.log(`${colors.cyan}${colors.bold}=== StaffOS Token & Cost Estimator ===${colors.reset}\n`);
|
|
152
208
|
console.log(`Scanning workspace at: ${colors.gray}${targetDir}${colors.reset}`);
|
|
153
209
|
console.log(`Target AI Model: ${colors.yellow}${colors.bold}${pricing.name}${colors.reset} (Input: $${pricing.input}/1M, Output: $${pricing.output}/1M)`);
|
|
210
|
+
console.log(`Detección de IA: ${colors.gray}${selection.reason}${colors.reset}`);
|
|
154
211
|
|
|
155
212
|
const files = getFilesRecursive(targetDir);
|
|
156
213
|
let totalCharacters = 0;
|
|
@@ -167,7 +224,6 @@ function runEstimator() {
|
|
|
167
224
|
}
|
|
168
225
|
|
|
169
226
|
// Token math modeling
|
|
170
|
-
// 1 token approx 3.8 characters in code
|
|
171
227
|
const codebaseTokens = Math.round(totalCharacters / 3.8);
|
|
172
228
|
|
|
173
229
|
// Scenario A: Traditional Agent (Unconstrained)
|
|
@@ -239,8 +295,8 @@ function runHelp() {
|
|
|
239
295
|
console.log(`\n${colors.cyan}${colors.bold}StaffOS CLI v${currentVersion}${colors.reset}`);
|
|
240
296
|
console.log('Uso:');
|
|
241
297
|
console.log(` ${colors.bold}npx staffos${colors.reset} - Instala e inicializa StaffOS en el proyecto actual.`);
|
|
242
|
-
console.log(` ${colors.bold}npx staffos estimate${colors.reset} - Escanea el proyecto y
|
|
243
|
-
console.log(` ${colors.bold}npx staffos estimate --model=<tipo>${colors.reset} -
|
|
298
|
+
console.log(` ${colors.bold}npx staffos estimate${colors.reset} - Escanea el proyecto y auto-detecta tu IA activa para estimar costos.`);
|
|
299
|
+
console.log(` ${colors.bold}npx staffos estimate --model=<tipo>${colors.reset} - Fuerza la estimación usando un modelo específico.`);
|
|
244
300
|
console.log(` ${colors.bold}npx staffos help${colors.reset} - Muestra este menú de ayuda.`);
|
|
245
301
|
console.log('\nModelos de IA soportados para estimación (`--model=`):');
|
|
246
302
|
Object.keys(modelsPricing).forEach(key => {
|