staffos 0.1.4 → 0.1.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 +14 -0
- package/bin/cli.js +81 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,20 @@ Para **analizar y estimar el ahorro exacto de tokens** y el costo proyectado de
|
|
|
31
31
|
npx staffos estimate
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
Puedes especificar un modelo de IA en particular mediante el flag `--model` para obtener estimaciones de costos exactas basadas en las tarifas de 2026:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx staffos estimate --model=gemini-pro
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Los modelos de IA soportados son:
|
|
41
|
+
* `claude-sonnet` (Claude 4.8 Sonnet - predeterminado)
|
|
42
|
+
* `claude-opus` (Claude 4.8 Opus)
|
|
43
|
+
* `gemini-pro` (Gemini 3.1 Pro)
|
|
44
|
+
* `gemini-flash` (Gemini 3.5 Flash)
|
|
45
|
+
* `gpt-5.5` (GPT 5.5)
|
|
46
|
+
* `local` (Modelos locales de Ollama/Llama sin costo de API)
|
|
47
|
+
|
|
34
48
|
Este comando escaneará la base de código de tu proyecto local y generará una tabla detallada con los cálculos en tiempo real.
|
|
35
49
|
|
|
36
50
|
---
|
package/bin/cli.js
CHANGED
|
@@ -121,10 +121,76 @@ function getFilesRecursive(dir, fileList = []) {
|
|
|
121
121
|
return fileList;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
// Model Pricing Registry (2026 Standard Rates per 1M tokens)
|
|
125
|
+
const modelsPricing = {
|
|
126
|
+
'claude-sonnet': { name: 'Claude 4.8 Sonnet', input: 3.00, output: 15.00 },
|
|
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 },
|
|
131
|
+
'local': { name: 'Modelos Locales (Ollama/DeepSeek)', input: 0.00, output: 0.00 }
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// Auto-detect the active AI environment
|
|
135
|
+
function detectActiveAI() {
|
|
136
|
+
// 1. Directory heuristics
|
|
137
|
+
if (fs.existsSync(path.join(targetDir, '.claudecode'))) {
|
|
138
|
+
return { key: 'claude-sonnet', reason: 'directorio .claudecode detectado' };
|
|
139
|
+
}
|
|
140
|
+
if (fs.existsSync(path.join(targetDir, '.opencode'))) {
|
|
141
|
+
return { key: 'gemini-pro', reason: 'directorio .opencode detectado' };
|
|
142
|
+
}
|
|
143
|
+
if (fs.existsSync(path.join(targetDir, '.cursorrules'))) {
|
|
144
|
+
if (process.env.OPENAI_API_KEY && !process.env.ANTHROPIC_API_KEY) {
|
|
145
|
+
return { key: 'gpt-5.5', reason: 'archivo .cursorrules y OPENAI_API_KEY detectados' };
|
|
146
|
+
}
|
|
147
|
+
return { key: 'claude-sonnet', reason: 'archivo .cursorrules detectado (Cursor default)' };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// 2. Env Var heuristics
|
|
151
|
+
if (process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY) {
|
|
152
|
+
return { key: 'gemini-pro', reason: 'variable de entorno GEMINI_API_KEY / GOOGLE_API_KEY' };
|
|
153
|
+
}
|
|
154
|
+
if (process.env.ANTHROPIC_API_KEY) {
|
|
155
|
+
return { key: 'claude-sonnet', reason: 'variable de entorno ANTHROPIC_API_KEY' };
|
|
156
|
+
}
|
|
157
|
+
if (process.env.OPENAI_API_KEY) {
|
|
158
|
+
return { key: 'gpt-5.5', reason: 'variable de entorno OPENAI_API_KEY' };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 3. Process/Terminal heuristics
|
|
162
|
+
if (process.env.TERM_PROGRAM === 'vscode') {
|
|
163
|
+
return { key: 'claude-sonnet', reason: 'ejecutado bajo Cursor/VSCode' };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return { key: 'claude-sonnet', reason: 'predeterminado por defecto' };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function getModelSelection() {
|
|
170
|
+
const modelArg = process.argv.find(arg => arg.startsWith('--model='));
|
|
171
|
+
if (modelArg) {
|
|
172
|
+
const key = modelArg.split('=')[1].toLowerCase();
|
|
173
|
+
return { key, reason: 'parámetro --model especificado' };
|
|
174
|
+
}
|
|
175
|
+
const modelIndex = process.argv.indexOf('-m');
|
|
176
|
+
if (modelIndex !== -1 && process.argv[modelIndex + 1]) {
|
|
177
|
+
const key = process.argv[modelIndex + 1].toLowerCase();
|
|
178
|
+
return { key, reason: 'parámetro -m especificado' };
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Run auto-detection
|
|
182
|
+
return detectActiveAI();
|
|
183
|
+
}
|
|
184
|
+
|
|
124
185
|
// Estimate token savings for the current workspace
|
|
125
186
|
function runEstimator() {
|
|
187
|
+
const selection = getModelSelection();
|
|
188
|
+
const pricing = modelsPricing[selection.key] || modelsPricing['claude-sonnet'];
|
|
189
|
+
|
|
126
190
|
console.log(`${colors.cyan}${colors.bold}=== StaffOS Token & Cost Estimator ===${colors.reset}\n`);
|
|
127
191
|
console.log(`Scanning workspace at: ${colors.gray}${targetDir}${colors.reset}`);
|
|
192
|
+
console.log(`Target AI Model: ${colors.yellow}${colors.bold}${pricing.name}${colors.reset} (Input: $${pricing.input}/1M, Output: $${pricing.output}/1M)`);
|
|
193
|
+
console.log(`Detección de IA: ${colors.gray}${selection.reason}${colors.reset}`);
|
|
128
194
|
|
|
129
195
|
const files = getFilesRecursive(targetDir);
|
|
130
196
|
let totalCharacters = 0;
|
|
@@ -141,25 +207,17 @@ function runEstimator() {
|
|
|
141
207
|
}
|
|
142
208
|
|
|
143
209
|
// Token math modeling
|
|
144
|
-
// 1 token approx 3.8 characters in code
|
|
145
210
|
const codebaseTokens = Math.round(totalCharacters / 3.8);
|
|
146
211
|
|
|
147
212
|
// Scenario A: Traditional Agent (Unconstrained)
|
|
148
|
-
// - Performs a full repository scan to start.
|
|
149
|
-
// - Runs 4 iterative repair cycles, re-reading context.
|
|
150
|
-
// - Rewrites complete files (avg. 1,500 tokens output) on each cycle.
|
|
151
213
|
const tradInputTokens = codebaseTokens * 4;
|
|
152
214
|
const tradOutputTokens = 1500 * 4;
|
|
153
215
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const tradInputCost = (tradInputTokens / 1_000_000) * 3.00;
|
|
157
|
-
const tradOutputCost = (tradOutputTokens / 1_000_000) * 15.00;
|
|
216
|
+
const tradInputCost = (tradInputTokens / 1_000_000) * pricing.input;
|
|
217
|
+
const tradOutputCost = (tradOutputTokens / 1_000_000) * pricing.output;
|
|
158
218
|
const tradTotalCost = tradInputCost + tradOutputCost;
|
|
159
219
|
|
|
160
220
|
// Scenario B: StaffOS Agent
|
|
161
|
-
// - Reads AI_CONTEXT.md + AGENTS.md + SKILL.md.
|
|
162
|
-
// - If they exist, read actual length. If not, default to 1,500 tokens baseline.
|
|
163
221
|
let staffOsContextLength = 0;
|
|
164
222
|
const docsToCheck = [
|
|
165
223
|
path.join(targetDir, 'AGENTS.md'),
|
|
@@ -182,11 +240,10 @@ function runEstimator() {
|
|
|
182
240
|
? Math.round(staffOsContextLength / 3.8)
|
|
183
241
|
: 1500; // default baseline
|
|
184
242
|
|
|
185
|
-
// StaffOS restricts changes to minimal patches (avg. 100 tokens output per task) over 1 cycle
|
|
186
243
|
const staffOsOutputTokens = 100;
|
|
187
244
|
|
|
188
|
-
const staffOsInputCost = (staffOsInputTokens / 1_000_000) *
|
|
189
|
-
const staffOsOutputCost = (staffOsOutputTokens / 1_000_000) *
|
|
245
|
+
const staffOsInputCost = (staffOsInputTokens / 1_000_000) * pricing.input;
|
|
246
|
+
const staffOsOutputCost = (staffOsOutputTokens / 1_000_000) * pricing.output;
|
|
190
247
|
const staffOsTotalCost = staffOsInputCost + staffOsOutputCost;
|
|
191
248
|
|
|
192
249
|
// Savings
|
|
@@ -209,8 +266,11 @@ function runEstimator() {
|
|
|
209
266
|
console.log(`${colors.bold}${'COSTO TOTAL ESTIMADO / TAREA'.padEnd(28)} | $${tradTotalCost.toFixed(4).padEnd(19)} | $${staffOsTotalCost.toFixed(4).padEnd(13)} | ${colors.green}${savingsPercent.toFixed(1)}%${colors.reset}`);
|
|
210
267
|
console.log('--------------------------------------------------------------------------------');
|
|
211
268
|
|
|
212
|
-
|
|
213
|
-
|
|
269
|
+
if (pricing.input === 0) {
|
|
270
|
+
console.log(`\n${colors.green}${colors.bold}🎉 Ahorro Estimado: ~${savingsPercent.toFixed(0)}% en tokens por tarea (ejecución local gratuita).${colors.reset}\n`);
|
|
271
|
+
} else {
|
|
272
|
+
console.log(`\n${colors.green}${colors.bold}🎉 Ahorro Estimado: ~${savingsPercent.toFixed(0)}% en costos de API por tarea.${colors.reset}\n`);
|
|
273
|
+
}
|
|
214
274
|
}
|
|
215
275
|
|
|
216
276
|
// Help command
|
|
@@ -218,8 +278,13 @@ function runHelp() {
|
|
|
218
278
|
console.log(`\n${colors.cyan}${colors.bold}StaffOS CLI v${currentVersion}${colors.reset}`);
|
|
219
279
|
console.log('Uso:');
|
|
220
280
|
console.log(` ${colors.bold}npx staffos${colors.reset} - Instala e inicializa StaffOS en el proyecto actual.`);
|
|
221
|
-
console.log(` ${colors.bold}npx staffos estimate${colors.reset} - Escanea el proyecto
|
|
281
|
+
console.log(` ${colors.bold}npx staffos estimate${colors.reset} - Escanea el proyecto y auto-detecta tu IA activa para estimar costos.`);
|
|
282
|
+
console.log(` ${colors.bold}npx staffos estimate --model=<tipo>${colors.reset} - Fuerza la estimación usando un modelo específico.`);
|
|
222
283
|
console.log(` ${colors.bold}npx staffos help${colors.reset} - Muestra este menú de ayuda.`);
|
|
284
|
+
console.log('\nModelos de IA soportados para estimación (`--model=`):');
|
|
285
|
+
Object.keys(modelsPricing).forEach(key => {
|
|
286
|
+
console.log(` - ${colors.yellow}${key.padEnd(15)}${colors.reset} : ${modelsPricing[key].name}`);
|
|
287
|
+
});
|
|
223
288
|
console.log();
|
|
224
289
|
}
|
|
225
290
|
|