petercat-ai / petercat

A conversational Q&A agent configuration system, self-hosted deployment solutions, and a convenient all-in-one application SDK, allowing you to create intelligent Q&A bots for your GitHub repositories
https://petercat.ai
MIT License
605 stars 18 forks source link

feat: optimize issue resolver logic #401

Closed RaoHai closed 2 months ago

RaoHai commented 2 months ago
analysis_result=你可以尝试修改 `/usr/lib/node_modules/fanyi/bin/fanyi.js` 的 shebang 行,将 `--no-deprecation` 参数移到脚本内部处理。具体修改如下:

```diff
- #!/usr/bin/env -S node --no-deprecation
+ #!/usr/bin/env node

const { Command } = require('commander');
const chalk = require('chalk');
const updateNotifier = require('update-notifier');
const pkg = require('../package.json');
const config = require('../lib/config');
const { searchList } = require('../lib/searchHistory');

// 添加以下代码以禁用弃用警告
process.noDeprecation = true;

updateNotifier({ pkg }).notify();
const program = new Command();

program
  .name(pkg.name)
  .description(pkg.description)
  .version(pkg.version)
  .action(() => {
    // 你的代码
  });

program
  .command('config')
  .description('配置')
  .action(async () => {
    const options = await config.load();
    console.log(`${chalk.gray(config.getConfigPath())}`);
    console.log();
    for (const [key, value] of Object.entries(options)) {
      console.log(`${chalk.cyan(key)}: ${chalk.yellow(value)}`);
    }
  });

program
  .command('set')
  .description('设置')
  .argument('<key>', '键')
  .argument('<value>', '值')
  .action(async (key, value) => {
    const options = {};
    if (key === 'GROQ_API_KEY') {
      options[key] = value;
    } else {
      options[key] = value === 'true' ? true : value === 'false' ? false : value;
    }
    await config.write(options);
  });

program
  .command('list')
  .option('-d, --someDay <char>', '某天')
  .option('-r, --recentDays [number]', '最近几天', 0)
  .option('--all --show-file [boolean]', '显示文件', false)
  .action((args) => {
    searchList(args);
  });

program.on('--help', () => {
  console.log('');
  console.log(chalk.gray('  $ fanyi word'));
  console.log(chalk.cyan('  fanyi world peace'));
  console.log(chalk.cyan('  fanyi changlish'));
  console.log(chalk.cyan('  fanyi config set color true'));
  console.log(chalk.cyan('  fanyi config set iciba true'));
  console.log(chalk.cyan('  fanyi config set GROQ_API_KEY your_api_key_here'));
  console.log(chalk.cyan('  fanyi config list'));
  console.log('');
});

program.parse(process.argv);

if (!process.argv.slice(2).length) {
  program.help();
}

async function runFY(options = {}) {
  const defaultOptions = await config.load();
  const mergedOptions = { ...defaultOptions, ...options };
  const fanyi = require('..');
  fanyi(program.args.join(' '), mergedOptions);
}

这样可以避免在 shebang 中传递参数的问题,同时也能禁用弃用警告。请尝试上述修改并测试是否解决问题。如果有进一步的问题,请随时 @ 我。

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
petercat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 20, 2024 4:56pm
petercat-assistant[bot] commented 2 months ago

Walkthrough: 优化了 issue 回复逻辑,改进了对用户需求的分析和处理方式。

Changes: 文件 摘要
server/agent/prompts/issue_helper.py 改进了 issue 帮助提示,优化了用户需求分析和处理逻辑。
server/agent/qa_chat.py 添加了 sourcecode_tools 工厂方法。
server/agent/tools/issue.py 改进了 issue 工具,优化了代码格式和错误处理。
server/agent/tools/pull_request.py 添加了 traceback 以改进错误处理,优化了代码格式。
server/agent/tools/sourcecode.py 添加了替换特殊字符的函数,改进了 search_code 工具。
codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 21.62162% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
server/agent/tools/sourcecode.py 18.18% 18 Missing :warning:
server/agent/tools/pull_request.py 25.00% 6 Missing :warning:
server/agent/tools/issue.py 33.33% 4 Missing :warning:
server/agent/qa_chat.py 0.00% 1 Missing :warning:
Files with missing lines Coverage Δ
server/agent/prompts/issue_helper.py 66.66% <ø> (ø)
server/agent/qa_chat.py 42.85% <0.00%> (-2.15%) :arrow_down:
server/agent/tools/issue.py 17.39% <33.33%> (+2.17%) :arrow_up:
server/agent/tools/pull_request.py 15.55% <25.00%> (+1.60%) :arrow_up:
server/agent/tools/sourcecode.py 33.33% <18.18%> (-19.61%) :arrow_down: