ai-engineer
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -6,2 +6,4 @@ "use strict"; | ||
const fs = require("fs-extra"); | ||
const path = require("path"); | ||
const os = require("os"); | ||
const inquirer = require("inquirer"); | ||
@@ -43,3 +45,4 @@ const ora = require("ora"); | ||
} | ||
let totalUsage = { | ||
const aercPath = path.join(os.homedir(), '.aerc'); | ||
let aercJSON = { | ||
prompt_tokens: 0, | ||
@@ -49,2 +52,6 @@ completion_tokens: 0, | ||
}; | ||
if (fs.existsSync(aercPath)) { | ||
aercJSON = fs.readJSONSync(aercPath); | ||
} | ||
let totalUsage = aercJSON; | ||
try { | ||
@@ -98,2 +105,3 @@ const filePaths = await globby([...(config.includes || []), '!node_modules', ...(config.excludes || []).map((item) => '!' + item)], { cwd }); | ||
totalUsage.total_tokens += result.usage.total_tokens; | ||
fs.writeJSONSync(aercPath, totalUsage); | ||
(0, OpenAIModel_1.printUsageAsPrice)(totalUsage, ' 总花费:'); | ||
@@ -105,3 +113,3 @@ let aiSegment = (0, utils_1.getCode)(result.content); | ||
// eslint-disable-next-line no-return-assign | ||
sourceIndexMap.forEach((j, i) => (subLines[j] = aiOutputLines[i])); | ||
sourceIndexMap.forEach((j, i) => aiOutputLines[i] && (subLines[j] = aiOutputLines[i])); | ||
output.push(subLines.join('\n') + '\n'); | ||
@@ -108,0 +116,0 @@ await config.writeFile(filePath, output.join('') + lines.slice(i + config.maxLines).join('\n')); |
@@ -8,2 +8,3 @@ #!/usr/bin/env node | ||
const path = require("path"); | ||
const os = require("os"); | ||
const exec_1 = require("../utils/exec"); | ||
@@ -71,4 +72,20 @@ const globby = require("globby"); | ||
} | ||
else if (argv._[0] === 'clear-billing') { | ||
const aercPath = path.join(os.homedir(), '.aerc'); | ||
fs.removeSync(aercPath); | ||
} | ||
else if (argv._[0] === 'help') { | ||
console.log(`Usage: ae [command] [options] | ||
--config: Specify config file | ||
init: Initialize config file | ||
commit: Commit with AI Engineer as author | ||
fac: Fast add and commit, with AI Engineer as author | ||
ls: List files | ||
help: Print help | ||
--version, -v: Print version | ||
`); | ||
} | ||
else { | ||
console.error('Unknown command'); | ||
} |
{ | ||
"name": "ai-engineer", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=18" |
51153
1281