g2log 1.3.0 → 1.4.0

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 CHANGED
@@ -1,4 +1,4 @@
1
- # Git 用户日志工具
1
+ # AI-Git 用户日报生成工具
2
2
 
3
3
  这是一个基于 Node.js 开发的命令行工具,用于获取指定用户在特定时间范围内的 Git 提交记录,并通过 AI 自动生成工作总结。
4
4
 
package/git-user-log.js CHANGED
@@ -407,6 +407,7 @@ ${colorize('⚙️ 配置管理:', 'magenta')}
407
407
  --set-prompt-template="file.txt" 从文件设置AI总结的prompt模板
408
408
  --reset-prompt-template 重置AI总结的prompt模板为默认值
409
409
  --fix-config 修复配置文件格式问题
410
+ --uninstall 删除g2log配置文件 (~/.git-user-log-config.json)
410
411
  --help 显示帮助信息
411
412
 
412
413
  ${colorize('📝 示例:', 'cyan')}
@@ -1017,7 +1018,7 @@ async function getDeepSeekResponse(apiKey, prompt, modelName, apiBaseURL, spinne
1017
1018
 
1018
1019
  // 处理结束
1019
1020
  res.on('end', () => {
1020
- if (spinner) spinner.stop('✅ DeepSeek响应已接收');
1021
+ if (spinner) spinner.stop('✅ AI响应已接收');
1021
1022
  console.log(); // 添加换行符
1022
1023
  resolve(fullContent);
1023
1024
  });
@@ -1314,9 +1315,10 @@ async function setupConfigInteractive() {
1314
1315
 
1315
1316
  // 步骤1: 设置API提供商
1316
1317
  console.log(colorize('\n📡 步骤1: 设置API提供商', 'yellow'));
1318
+ console.log(colorize(' (仅作为一个备注,示例:openai, deepseek, xxx)', 'cyan'));
1317
1319
  let apiProvider = config.api_provider || '';
1318
1320
 
1319
- const providerInput = await question(colorize(` 请选择API提供商 [${apiProvider ? apiProvider : 'OpenAI/DeepSeek'}]: `, 'green'));
1321
+ const providerInput = await question(colorize(` 请选择API提供商 [${apiProvider ? apiProvider : 'openai'}]: `, 'green'));
1320
1322
  if (providerInput.trim() !== '') {
1321
1323
  apiProvider = providerInput.trim();
1322
1324
  } else if (apiProvider === '') {
@@ -1329,6 +1331,7 @@ async function setupConfigInteractive() {
1329
1331
 
1330
1332
  // 步骤2: 设置API基础URL
1331
1333
  console.log(colorize('\n🔗 步骤2: 设置API基础URL', 'yellow'));
1334
+ console.log(colorize(' (示例: https://api.openai.com, https://api.deepseek.com 或其他API服务地址)', 'cyan'));
1332
1335
 
1333
1336
  // 根据提供商设置默认值
1334
1337
  let defaultBaseURL = config.api_base_url || '';
@@ -1347,6 +1350,12 @@ async function setupConfigInteractive() {
1347
1350
  // 步骤3: 设置AI模型
1348
1351
  console.log(colorize('\n🤖 步骤3: 设置AI模型', 'yellow'));
1349
1352
 
1353
+ // 根据提供商显示不同的模型示例
1354
+ const modelExamples = config.api_provider === 'openai' ?
1355
+ 'gpt-3.5-turbo, gpt-4, gpt-4-turbo' :
1356
+ 'deepseek-chat, deepseek-coder, deepseek-v3';
1357
+ console.log(colorize(` (常用模型示例: ${modelExamples})`, 'cyan'));
1358
+
1350
1359
  // 根据提供商设置默认模型
1351
1360
  let defaultModel = config.ai_model || '';
1352
1361
  if (!defaultModel) {
@@ -1363,6 +1372,7 @@ async function setupConfigInteractive() {
1363
1372
 
1364
1373
  // 步骤4: 设置API密钥
1365
1374
  console.log(colorize('\n🔑 步骤4: 设置API密钥', 'yellow'));
1375
+ console.log(colorize(' (格式示例: sk-abcdefg123456789... 密钥会安全存储在本地配置文件中)', 'cyan'));
1366
1376
  const existingKey = config.api_key || '';
1367
1377
  const keyInput = await question(colorize(` 请输入API密钥${existingKey ? ' [已配置,按Enter保留]' : ''}: `, 'green'));
1368
1378
  if (keyInput.trim() !== '') {
@@ -1376,6 +1386,7 @@ async function setupConfigInteractive() {
1376
1386
 
1377
1387
  // 步骤5: 设置默认作者
1378
1388
  console.log(colorize('\n👤 步骤5: 设置默认作者', 'yellow'));
1389
+ console.log(colorize(' (示例: 张三, user@example.com, 或Git提交时使用的用户名)', 'cyan'));
1379
1390
  const existingAuthor = config.default_author || '';
1380
1391
  const authorInput = await question(colorize(` 请输入默认作者名称 [${existingAuthor}]: `, 'green'));
1381
1392
  config.default_author = authorInput.trim() || existingAuthor;
@@ -1383,6 +1394,7 @@ async function setupConfigInteractive() {
1383
1394
 
1384
1395
  // 步骤6: 设置默认时间范围(可选)
1385
1396
  console.log(colorize('\n🕒 步骤6: 设置默认时间范围(可选)', 'yellow'));
1397
+ console.log(colorize(' (支持格式: "7 days ago", "1 week ago", "yesterday", "2023-01-01", "last monday")', 'cyan'));
1386
1398
 
1387
1399
  // 获取当前的默认值
1388
1400
  const defaultSince = config.default_since || '7 days ago';
@@ -1398,6 +1410,13 @@ async function setupConfigInteractive() {
1398
1410
 
1399
1411
  // 步骤7: 仓库配置(可选)
1400
1412
  console.log(colorize('\n📂 步骤7: 仓库配置(可选)', 'yellow'));
1413
+ console.log(colorize(' (仓库别名示例: frontend, backend, main-project)', 'cyan'));
1414
+
1415
+ // 根据操作系统提供路径示例
1416
+ const repoPathExample = process.platform === 'win32' ?
1417
+ 'C:\\项目\\前端仓库' :
1418
+ '/Users/用户名/projects/前端仓库';
1419
+ console.log(colorize(` (仓库路径示例: ${repoPathExample})`, 'cyan'));
1401
1420
 
1402
1421
  // 显示当前配置的仓库
1403
1422
  const repos = config.repositories || {};
@@ -1423,7 +1442,8 @@ async function setupConfigInteractive() {
1423
1442
  continue;
1424
1443
  }
1425
1444
 
1426
- // 获取仓库路径
1445
+ // 获取仓库路径,添加示例提示
1446
+ console.log(colorize(` (请输入Git仓库的绝对路径,示例: ${repoPathExample})`, 'cyan'));
1427
1447
  const repoPath = await question(colorize(' 请输入仓库路径(绝对路径): ', 'green'));
1428
1448
  if (!repoPath.trim()) {
1429
1449
  console.log(colorize(' ❌ 仓库路径不能为空', 'red'));
@@ -1489,7 +1509,7 @@ async function getGitLogs() {
1489
1509
  if (!args['set-api-key'] && !args['set-default-author'] && !args['add-repo'] &&
1490
1510
  !args['fix-config'] && !args['remove-repo'] && !args['list-repos'] &&
1491
1511
  !args['set-prompt-template'] && !args['reset-prompt-template'] &&
1492
- !args['skip-config-check']) {
1512
+ !args['skip-config-check'] && !args['uninstall']) {
1493
1513
 
1494
1514
  // 检查配置状态
1495
1515
  const configStatus = checkConfig();
@@ -1542,6 +1562,18 @@ async function getGitLogs() {
1542
1562
  // 加载配置(在配置检查和可能的设置之后)
1543
1563
  const config = loadConfig();
1544
1564
 
1565
+ // 删除配置文件
1566
+ if (args['uninstall']) {
1567
+ const uninstallSpinner = spinner.start('🗑️ 正在删除g2log配置文件...');
1568
+ if (removeConfigFile()) {
1569
+ uninstallSpinner.stop('✅ g2log配置文件已成功删除');
1570
+ console.log(colorize('💡 提示: 如需完全卸载g2log,还需执行 npm uninstall -g g2log', 'yellow'));
1571
+ } else {
1572
+ uninstallSpinner.fail('❌ 配置文件不存在或删除失败');
1573
+ }
1574
+ return;
1575
+ }
1576
+
1545
1577
  // 修复配置文件
1546
1578
  if (args['fix-config']) {
1547
1579
  const fixSpinner = spinner.start('🔧 正在修复配置文件...');
@@ -1814,4 +1846,45 @@ getGitLogs();
1814
1846
  // .then(() => console.log('配置测试已完成'));
1815
1847
 
1816
1848
  // 如果需要测试checkConfig(需要注释掉主函数调用)
1817
- // console.log(checkConfig());
1849
+ // console.log(checkConfig());
1850
+
1851
+ // 重置prompt模板为默认值
1852
+ function resetPromptTemplate() {
1853
+ try {
1854
+ const config = loadConfig();
1855
+ if (config.prompt_template) {
1856
+ delete config.prompt_template;
1857
+ return saveConfig(config);
1858
+ }
1859
+ return true; // 如果没有设置自定义模板,则视为重置成功
1860
+ } catch (error) {
1861
+ console.error(`❌ 重置prompt模板失败: ${error.message}`);
1862
+ return false;
1863
+ }
1864
+ }
1865
+
1866
+ // 删除配置文件
1867
+ function removeConfigFile() {
1868
+ try {
1869
+ if (fs.existsSync(CONFIG_PATH)) {
1870
+ fs.unlinkSync(CONFIG_PATH);
1871
+ return true;
1872
+ }
1873
+ return false; // 文件不存在
1874
+ } catch (error) {
1875
+ console.error(`❌ 删除配置文件失败: ${error.message}`);
1876
+ return false;
1877
+ }
1878
+ }
1879
+
1880
+ // 设置API提供商
1881
+ function setAPIProvider(provider) {
1882
+ try {
1883
+ const config = loadConfig();
1884
+ config.api_provider = provider;
1885
+ return saveConfig(config);
1886
+ } catch (error) {
1887
+ console.error(`❌ 设置API提供商失败: ${error.message}`);
1888
+ return false;
1889
+ }
1890
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "g2log",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "查询特定用户和时间范围的Git提交记录并通过AI进行总结,可通过npx直接运行",
5
5
  "main": "git-user-log.js",
6
6
  "bin": {
@@ -34,6 +34,5 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/chenxiangcai/git-user-log/issues"
36
36
  },
37
- "homepage": "https://github.com/chenxiangcai/git-user-log#readme",
38
- "dependencies": {}
37
+ "homepage": "https://github.com/chenxiangcai/git-user-log#readme"
39
38
  }