ethan-skill 1.12.0 → 1.13.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/dist/cli/index.js CHANGED
@@ -4808,5 +4808,154 @@ program
4808
4808
  console.log(prompt);
4809
4809
  }
4810
4810
  });
4811
+ // ─── agent 命令 ─────────────────────────────────────────────────────────────
4812
+ const agentCmd = program
4813
+ .command('agent')
4814
+ .description('Multi-Agent 编排:将 Pipeline 步骤分配给不同 Agent 协作执行');
4815
+ agentCmd
4816
+ .command('list')
4817
+ .description('列出所有可用 Agent 及其 Skill 分配')
4818
+ .action(async () => {
4819
+ const { getActiveAgents } = await Promise.resolve().then(() => __importStar(require('../agents/index')));
4820
+ const agents = getActiveAgents(process.cwd());
4821
+ console.log('\n🤖 可用 Agent 列表\n');
4822
+ console.log('─'.repeat(70));
4823
+ for (const agent of agents) {
4824
+ console.log(`\n${agent.emoji} ${agent.name} [${agent.id}]`);
4825
+ console.log(` 职责:${agent.role}`);
4826
+ console.log(` Skills(${agent.skillIds.length}):${agent.skillIds.join(', ')}`);
4827
+ }
4828
+ console.log('\n─'.repeat(70));
4829
+ console.log(`\n共 ${agents.length} 个 Agent。自定义 Agent 放在 .ethan/agents/ 目录。\n`);
4830
+ });
4831
+ agentCmd
4832
+ .command('show <agentId>')
4833
+ .description('查看指定 Agent 的详细配置')
4834
+ .action(async (agentId) => {
4835
+ const { getActiveAgents } = await Promise.resolve().then(() => __importStar(require('../agents/index')));
4836
+ const agents = getActiveAgents(process.cwd());
4837
+ const agent = agents.find((a) => a.id === agentId);
4838
+ if (!agent) {
4839
+ console.error(`\n❌ 未找到 Agent: ${agentId}\n`);
4840
+ console.error(`可用 ID:${agents.map((a) => a.id).join(' | ')}\n`);
4841
+ process.exit(1);
4842
+ }
4843
+ console.log(`\n${agent.emoji} ${agent.name} [${agent.id}]`);
4844
+ console.log('─'.repeat(50));
4845
+ console.log(`英文名:${agent.nameEn}`);
4846
+ console.log(`职责:${agent.role}`);
4847
+ console.log(`\nSkills(${agent.skillIds.length} 个):`);
4848
+ agent.skillIds.forEach((id) => console.log(` - ${id}`));
4849
+ console.log('');
4850
+ });
4851
+ agentCmd
4852
+ .command('run [pipelineId]')
4853
+ .description('生成 Multi-Agent 编排 Prompt,粘贴到 AI 编辑器执行')
4854
+ .option('-c, --context <context>', '任务背景描述(如"实现用户登录功能")', '')
4855
+ .option('--lang <lang>', '输出语言:zh(默认)或 en', '')
4856
+ .option('--with-context', '自动采集项目上下文注入到提示词')
4857
+ .option('--no-copy', '不复制到剪贴板,直接打印到终端')
4858
+ .action(async (pipelineId, options) => {
4859
+ const { resolvePipeline, PIPELINES } = await Promise.resolve().then(() => __importStar(require('../skills/pipeline')));
4860
+ const { getActiveAgents, buildMultiAgentPrompt } = await Promise.resolve().then(() => __importStar(require('../agents/index')));
4861
+ const { buildProjectSnapshot, loadCachedSnapshot, saveSnapshotCache, formatSnapshotForPrompt } = await Promise.resolve().then(() => __importStar(require('../context/builder')));
4862
+ const config = (0, config_1.readConfig)(process.cwd());
4863
+ const lang = (options.lang || config.lang || 'zh');
4864
+ const isEn = lang === 'en';
4865
+ const agents = getActiveAgents(process.cwd());
4866
+ // 采集项目上下文快照
4867
+ let snapshotBlock;
4868
+ if (options.withContext) {
4869
+ const cached = loadCachedSnapshot(process.cwd());
4870
+ if (cached) {
4871
+ snapshotBlock = formatSnapshotForPrompt(cached, isEn);
4872
+ }
4873
+ else {
4874
+ console.log(isEn ? '🔍 Collecting project context...' : '🔍 正在采集项目上下文...');
4875
+ const snap = buildProjectSnapshot(process.cwd());
4876
+ saveSnapshotCache(snap, process.cwd());
4877
+ snapshotBlock = formatSnapshotForPrompt(snap, isEn);
4878
+ }
4879
+ }
4880
+ else {
4881
+ const cached = loadCachedSnapshot(process.cwd());
4882
+ if (cached)
4883
+ snapshotBlock = formatSnapshotForPrompt(cached, isEn);
4884
+ }
4885
+ // 获取任务上下文
4886
+ let context = (options.context || '').trim();
4887
+ if (!context) {
4888
+ const readline = await Promise.resolve().then(() => __importStar(require('readline')));
4889
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
4890
+ const ask = (q) => new Promise((resolve) => rl.question(q, (a) => resolve(a.trim())));
4891
+ context = await ask(isEn
4892
+ ? 'Describe your task context:\n> '
4893
+ : '请描述任务背景(例如:实现用户登录功能):\n> ');
4894
+ rl.close();
4895
+ if (!context) {
4896
+ console.error(isEn ? '\n❌ Context cannot be empty\n' : '\n❌ 任务背景不能为空\n');
4897
+ process.exit(1);
4898
+ }
4899
+ }
4900
+ // 确定目标 Pipeline
4901
+ let id = pipelineId;
4902
+ if (!id) {
4903
+ const customPipelines = loadCustomPipelines(process.cwd());
4904
+ const allPipelines = [
4905
+ ...PIPELINES,
4906
+ ...customPipelines.map((p) => ({ id: p.id, name: p.name, description: p.description, skillIds: p.skillIds })),
4907
+ ];
4908
+ const readline = await Promise.resolve().then(() => __importStar(require('readline')));
4909
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
4910
+ const ask = (q) => new Promise((resolve) => rl.question(q, (a) => resolve(a.trim())));
4911
+ console.log(isEn ? '\n🔄 Available Pipelines\n' : '\n🔄 可用工作流 Pipeline\n');
4912
+ console.log('─'.repeat(60));
4913
+ allPipelines.forEach((p, i) => {
4914
+ console.log(` ${i + 1}. ${p.name} [${p.id}]`);
4915
+ });
4916
+ console.log('');
4917
+ const choice = await ask(isEn
4918
+ ? `Select pipeline (1-${allPipelines.length} or ID):\n> `
4919
+ : `选择 Pipeline(序号 1-${allPipelines.length} 或直接输入 ID):\n> `);
4920
+ rl.close();
4921
+ const num = parseInt(choice, 10);
4922
+ id = !isNaN(num) && num >= 1 && num <= allPipelines.length
4923
+ ? allPipelines[num - 1].id
4924
+ : choice;
4925
+ }
4926
+ const resolved = resolvePipeline(id);
4927
+ if (!resolved) {
4928
+ console.error(isEn ? `\n❌ Unknown pipeline: ${id}\n` : `\n❌ 未找到 Pipeline: ${id}\n`);
4929
+ console.error(`Available: ${PIPELINES.map((p) => p.id).join(' | ')}`);
4930
+ process.exit(1);
4931
+ }
4932
+ const { pipeline, skills } = resolved;
4933
+ const prompt = buildMultiAgentPrompt(pipeline, skills, agents, {
4934
+ context,
4935
+ lang,
4936
+ snapshot: snapshotBlock,
4937
+ });
4938
+ console.log(isEn
4939
+ ? `\n🤖 Multi-Agent prompt generated: ${pipeline.name} (${skills.length} steps, ${agents.length} agents)`
4940
+ : `\n🤖 Multi-Agent 编排 Prompt 已生成:${pipeline.name}(${skills.length} 步,${agents.length} 个 Agent)`);
4941
+ console.log('─'.repeat(60));
4942
+ if (options.copy !== false) {
4943
+ if (copyToClipboard(prompt)) {
4944
+ console.log(isEn
4945
+ ? '\n✅ Multi-Agent prompt copied to clipboard! Paste into your AI editor.'
4946
+ : '\n✅ Multi-Agent 编排 Prompt 已复制到剪贴板!粘贴到 AI 编辑器,多 Agent 将协作执行所有步骤。');
4947
+ }
4948
+ else {
4949
+ console.log('\n' + prompt + '\n');
4950
+ }
4951
+ }
4952
+ else {
4953
+ console.log('\n' + prompt + '\n');
4954
+ }
4955
+ console.log(isEn
4956
+ ? '\n💡 Each Agent will execute its assigned steps and hand off results to the next Agent.\n'
4957
+ : '\n💡 每个 Agent 负责执行分配给自己的步骤,通过 Handoff 摘要将产出传递给下一个 Agent。\n');
4958
+ trackUsageWithStreak(`agent-run-${pipeline.id}`);
4959
+ });
4811
4960
  program.parse(process.argv);
4812
4961
  //# sourceMappingURL=index.js.map