@ia-ccun/code-agent-cli 0.0.15 → 0.0.16

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.
Files changed (75) hide show
  1. package/bin/cli.js +153 -84
  2. package/config/agent/extensions/working-msg.ts +33 -8
  3. package/config/agent/models.json +41 -11
  4. package/config/agent/prompts/code-simplifier.md +52 -0
  5. package/config/agent/skills/brainstorming/SKILL.md +165 -0
  6. package/config/agent/skills/brainstorming/scripts/frame-template.html +214 -0
  7. package/config/agent/skills/brainstorming/scripts/helper.js +88 -0
  8. package/config/agent/skills/brainstorming/scripts/server.cjs +338 -0
  9. package/config/agent/skills/brainstorming/scripts/start-server.sh +153 -0
  10. package/config/agent/skills/brainstorming/scripts/stop-server.sh +55 -0
  11. package/config/agent/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  12. package/config/agent/skills/brainstorming/visual-companion.md +286 -0
  13. package/config/agent/skills/dispatching-parallel-agents/SKILL.md +183 -0
  14. package/config/agent/skills/executing-plans/SKILL.md +71 -0
  15. package/config/agent/skills/finishing-a-development-branch/SKILL.md +201 -0
  16. package/config/agent/skills/owasp-security/SKILL.md +537 -0
  17. package/config/agent/skills/receiving-code-review/SKILL.md +214 -0
  18. package/config/agent/skills/requesting-code-review/SKILL.md +106 -0
  19. package/config/agent/skills/requesting-code-review/code-reviewer.md +146 -0
  20. package/config/agent/skills/skill-creator/SKILL.md +337 -213
  21. package/config/agent/skills/skill-creator/agents/analyzer.md +274 -0
  22. package/config/agent/skills/skill-creator/agents/comparator.md +202 -0
  23. package/config/agent/skills/skill-creator/agents/grader.md +223 -0
  24. package/config/agent/skills/skill-creator/assets/eval_review.html +146 -0
  25. package/config/agent/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  26. package/config/agent/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  27. package/config/agent/skills/skill-creator/references/schemas.md +430 -0
  28. package/config/agent/skills/skill-creator/scripts/__init__.py +0 -0
  29. package/config/agent/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  30. package/config/agent/skills/skill-creator/scripts/generate_report.py +326 -0
  31. package/config/agent/skills/skill-creator/scripts/improve_description.py +248 -0
  32. package/config/agent/skills/skill-creator/scripts/package_skill.py +33 -7
  33. package/config/agent/skills/skill-creator/scripts/quick_validate.py +11 -3
  34. package/config/agent/skills/skill-creator/scripts/run_eval.py +310 -0
  35. package/config/agent/skills/skill-creator/scripts/run_loop.py +332 -0
  36. package/config/agent/skills/skill-creator/scripts/utils.py +47 -0
  37. package/config/agent/skills/subagent-driven-development/SKILL.md +278 -0
  38. package/config/agent/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  39. package/config/agent/skills/subagent-driven-development/implementer-prompt.md +113 -0
  40. package/config/agent/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  41. package/config/agent/skills/systematic-debugging/CREATION-LOG.md +119 -0
  42. package/config/agent/skills/systematic-debugging/SKILL.md +297 -0
  43. package/config/agent/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  44. package/config/agent/skills/systematic-debugging/condition-based-waiting.md +115 -0
  45. package/config/agent/skills/systematic-debugging/defense-in-depth.md +122 -0
  46. package/config/agent/skills/systematic-debugging/find-polluter.sh +63 -0
  47. package/config/agent/skills/systematic-debugging/root-cause-tracing.md +169 -0
  48. package/config/agent/skills/systematic-debugging/test-academic.md +14 -0
  49. package/config/agent/skills/systematic-debugging/test-pressure-1.md +58 -0
  50. package/config/agent/skills/systematic-debugging/test-pressure-2.md +68 -0
  51. package/config/agent/skills/systematic-debugging/test-pressure-3.md +69 -0
  52. package/config/agent/skills/test-driven-development/SKILL.md +372 -0
  53. package/config/agent/skills/test-driven-development/testing-anti-patterns.md +299 -0
  54. package/config/agent/skills/using-git-worktrees/SKILL.md +219 -0
  55. package/config/agent/skills/using-superpowers/SKILL.md +116 -0
  56. package/config/agent/skills/using-superpowers/references/codex-tools.md +25 -0
  57. package/config/agent/skills/using-superpowers/references/gemini-tools.md +33 -0
  58. package/config/agent/skills/verification-before-completion/SKILL.md +140 -0
  59. package/config/agent/skills/writing-plans/SKILL.md +146 -0
  60. package/config/agent/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  61. package/config/agent/skills/writing-skills/SKILL.md +667 -0
  62. package/config/agent/skills/writing-skills/anthropic-best-practices.md +1150 -0
  63. package/config/agent/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  64. package/config/agent/skills/writing-skills/graphviz-conventions.dot +172 -0
  65. package/config/agent/skills/writing-skills/persuasion-principles.md +187 -0
  66. package/config/agent/skills/writing-skills/render-graphs.js +168 -0
  67. package/config/agent/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  68. package/package.json +14 -7
  69. package/scripts/postinstall.js +4 -18
  70. package/config/agent/skills/github/SKILL.md +0 -47
  71. package/config/agent/skills/owasp/SKILL.md +0 -169
  72. package/config/agent/skills/pua/SKILL.md +0 -364
  73. package/config/agent/skills/skill-creator/references/output-patterns.md +0 -82
  74. package/config/agent/skills/skill-creator/references/workflows.md +0 -28
  75. package/config/agent/skills/skill-creator/scripts/init_skill.py +0 -303
package/bin/cli.js CHANGED
@@ -1,111 +1,180 @@
1
1
  #!/usr/bin/env node
2
+
2
3
  /**
3
- * CLI entry point for aicode-cli
4
- * Delegates to @mariozechner/pi-coding-agent
5
- * Shows wrapper version for --version flag
4
+ * aicode-cli
5
+ * AI Coding Agent CLI - 基于 @mariozechner/pi-coding-agent
6
6
  */
7
7
 
8
- import { readFileSync } from 'fs';
9
- import { dirname, join } from 'path';
8
+ import { spawn, execSync } from 'child_process';
10
9
  import { fileURLToPath } from 'url';
10
+ import { dirname, join } from 'path';
11
+ import { existsSync, readFileSync } from 'fs';
12
+ import { getConfig, getConfigDir, loadConfig } from '../dist/config-loader.js';
13
+ import { generateBanner } from '../dist/banner.js';
11
14
 
12
15
  const __filename = fileURLToPath(import.meta.url);
13
16
  const __dirname = dirname(__filename);
14
17
 
15
- // Check if --version or -v is requested
16
- const args = process.argv.slice(2);
17
- if (args.includes('--version') || args.includes('-v')) {
18
- // Read wrapper package version
19
- const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
20
- console.log(packageJson.version);
21
- process.exit(0);
18
+ // 解析命令行参数
19
+ function parseArgs() {
20
+ const args = process.argv.slice(2);
21
+ let configDir;
22
+ let webMode = false;
23
+ let webPort;
24
+
25
+ for (let i = 0; i < args.length; i++) {
26
+ const arg = args[i];
27
+ if (arg === '--config' || arg === '-c') {
28
+ configDir = args[i + 1];
29
+ args.splice(i, 2);
30
+ i--;
31
+ } else if (arg === '--web' || arg === '--webui') {
32
+ webMode = true;
33
+ args.splice(i, 1);
34
+ i--;
35
+ } else if (arg === '--port' || arg === '-p') {
36
+ webPort = parseInt(args[i + 1], 10);
37
+ args.splice(i, 2);
38
+ i--;
39
+ }
40
+ }
41
+
42
+ return { remainingArgs: args, configDir, webMode, webPort };
22
43
  }
23
44
 
24
- // Print custom Banner (always show, not affected by quietStartup)
25
- const configPath = join(__dirname, '..', 'config.json');
26
- let showBanner = true;
27
- try {
28
- const config = JSON.parse(readFileSync(configPath, 'utf-8'));
29
- // Show banner only if banner field is set and not empty
30
- showBanner = config.banner && config.banner !== '' && config.banner !== '""';
31
- } catch (e) {
32
- // ignore
45
+ const { remainingArgs, configDir: cliConfigDir, webMode, webPort } = parseArgs();
46
+
47
+ // 优先使用命令行参数,其次使用环境变量,最后使用默认值
48
+ const effectiveConfigDir = cliConfigDir || process.env.AICODE_CLI_CONFIG_DIR;
49
+
50
+ // 如果指定了配置目录,加载该目录下的配置
51
+ let config;
52
+ if (effectiveConfigDir) {
53
+ // 临时覆盖环境变量
54
+ process.env.AICODE_CLI_CONFIG_DIR = effectiveConfigDir;
55
+ config = loadConfig();
56
+ } else {
57
+ config = getConfig();
33
58
  }
34
59
 
35
- if (showBanner) {
36
- // Read theme color from config
37
- let themeColor = '#49bccf'; // default
38
- try {
39
- const config = JSON.parse(readFileSync(configPath, 'utf-8'));
40
- if (config.themeColor) {
41
- themeColor = config.themeColor;
60
+
61
+
62
+ // 显示 Banner
63
+ if (config.banner === '__default__' || config.banner !== '') {
64
+ console.log(generateBanner(config.themeColor));
65
+ }
66
+
67
+ // 检查新版本(后台异步执行,不阻塞启动)
68
+ function checkForUpdates() {
69
+ setTimeout(async () => {
70
+ try {
71
+ // 读取本地版本
72
+ const pkgPath = new URL('../package.json', import.meta.url).pathname;
73
+ const localVersion = JSON.parse(readFileSync(pkgPath)).version;
74
+
75
+ // 获取当前 registry
76
+ const registry = execSync('npm config get registry', { encoding: 'utf8', stdio: 'pipe' }).trim();
77
+ const latestVersion = execSync(`npm view @nucc/code-agent-cli version --registry=${registry}`, { encoding: 'utf8', stdio: 'pipe' }).trim();
78
+
79
+ // 比较版本号
80
+ const localParts = localVersion.split('.').map(Number);
81
+ const latestParts = latestVersion.split('.').map(Number);
82
+ const needsUpdate = latestParts[0] > localParts[0] ||
83
+ (latestParts[0] === localParts[0] && latestParts[1] > localParts[1]) ||
84
+ (latestParts[0] === localParts[0] && latestParts[1] === localParts[1] && latestParts[2] > localParts[2]);
85
+
86
+ if (needsUpdate) {
87
+ console.log('\n\x1b[33m⚠️ 发现新版本 v%s → v%s\x1b[0m', localVersion, latestVersion);
88
+ console.log('\x1b[36m 运行以下命令更新:\x1b[0m');
89
+ console.log(' npm install -g @nucc/code-agent-cli\n');
90
+ }
91
+ } catch (e) {
92
+ // 忽略检查失败
42
93
  }
43
- } catch (e) {
44
- // ignore
45
- }
94
+ }, 100); // 延迟 100ms 确保不影响主流程
95
+ }
96
+
97
+ // WebUI 模式
98
+ if (webMode) {
99
+ const webuiDir = join(__dirname, '..', 'webui', 'server');
46
100
 
47
- // Generate colored banner
48
- const hexToRgb = (hex) => {
49
- hex = hex.replace('#', '');
50
- return {
51
- r: parseInt(hex.slice(0, 2), 16),
52
- g: parseInt(hex.slice(2, 4), 16),
53
- b: parseInt(hex.slice(4, 6), 16)
54
- };
55
- };
56
-
57
- // Read banner config
58
- let bannerConfig = '';
101
+ // 先构建 webui
102
+ console.log('🔨 Building WebUI...');
59
103
  try {
60
- const config = JSON.parse(readFileSync(configPath, 'utf-8'));
61
- bannerConfig = config.banner || '';
104
+ execSync('npm run build', { cwd: webuiDir, stdio: 'inherit' });
62
105
  } catch (e) {
63
- // ignore
106
+ console.error('Failed to build WebUI:', e);
107
+ process.exit(1);
64
108
  }
65
109
 
66
- const rgb = hexToRgb(themeColor);
67
- const colorCode = `\x1b[38;2;${rgb.r};${rgb.g};${rgb.b}m`;
68
- const resetCode = '\x1b[0m';
69
-
70
- // Get terminal width for centering
71
- const terminalWidth = process.stdout.columns || 80;
110
+ // 启动 WebUI 服务器
111
+ const portArgs = webPort ? ['--port', String(webPort)] : [];
112
+ const webuiProcess = spawn('node', ['dist/index.js', ...portArgs], {
113
+ cwd: webuiDir,
114
+ stdio: 'inherit',
115
+ env: {
116
+ ...process.env,
117
+ AICODE_CLI_CONFIG_DIR: config.configDir,
118
+ }
119
+ });
72
120
 
73
- // If banner is "__default__", use ASCII art; otherwise use custom text
74
- if (bannerConfig === '__default__') {
75
- // Banner from scripts/banner.txt
76
- let lines = [];
121
+ // 自动打开浏览器
122
+ const port = webPort || 3002;
123
+ setTimeout(() => {
77
124
  try {
78
- const bannerPath = join(__dirname, '..', 'scripts', 'banner.txt');
79
- const bannerContent = readFileSync(bannerPath, 'utf-8');
80
- lines = bannerContent.trim().split('\n');
125
+ execSync(`open http://localhost:${port}`, { stdio: 'ignore' });
81
126
  } catch (e) {
82
- // fallback - no banner
83
- }
84
- lines.forEach(line => console.log(colorCode + line + resetCode));
85
- } else if (bannerConfig && bannerConfig !== '') {
86
- // Custom text banner - handle both string and array
87
- let quotes = [];
88
- if (Array.isArray(bannerConfig)) {
89
- quotes = bannerConfig;
90
- } else if (typeof bannerConfig === 'string' && bannerConfig.startsWith('[')) {
91
- try {
92
- quotes = JSON.parse(bannerConfig);
93
- } catch (e) {
94
- quotes = [bannerConfig];
95
- }
96
- } else {
97
- quotes = [bannerConfig];
127
+ // 忽略打开浏览器失败
98
128
  }
129
+ }, 2000);
99
130
 
100
- // Random quote
101
- const quote = quotes[Math.floor(Math.random() * quotes.length)];
131
+ webuiProcess.on('exit', (code) => {
132
+ process.exit(code ?? 0);
133
+ });
102
134
 
103
- // Center the quote
104
- const padding = Math.max(0, Math.floor((terminalWidth - quote.length) / 2));
105
- console.log(colorCode + ' '.repeat(padding) + quote + resetCode);
106
- }
107
- console.log('');
135
+ webuiProcess.on('error', (err) => {
136
+ console.error('Failed to start WebUI:', err);
137
+ process.exit(1);
138
+ });
139
+
140
+ // WebUI 模式下不执行后续的 TUI 逻辑
141
+ checkForUpdates();
142
+ // 不阻塞,让 webui 进程继续运行
108
143
  }
109
144
 
110
- // Delegate to pi-coding-agent for all other commands
111
- import('../node_modules/@mariozechner/pi-coding-agent/dist/cli.js');
145
+ checkForUpdates();
146
+
147
+ // 获取 node_modules 中 pi-coding-agent 的 CLI 路径
148
+ const piAgentPath = new URL('../node_modules/@mariozechner/pi-coding-agent/dist/cli.js', import.meta.url);
149
+
150
+ // 设置环境变量
151
+ const env = {
152
+ ...process.env,
153
+ AICODE_CLI_CONFIG_DIR: config.configDir,
154
+ AICODE_CLI_NAME: config.name,
155
+ PI_SKIP_VERSION_CHECK: '1'
156
+ };
157
+
158
+ // 传递配置目录给 pi
159
+ // pi 使用 AICODE_CLI_CODING_AGENT_DIR 环境变量 (基于 piConfig.name)
160
+ // 确保使用完整的绝对路径
161
+ const fullPath = join(process.env.HOME || process.env.USERPROFILE, config.configDir);
162
+ const agentDir = join(fullPath, 'agent');
163
+ env.AICODE_CLI_CODING_AGENT_DIR = agentDir;
164
+
165
+
166
+
167
+ // 启动 pi-coding-agent
168
+ const child = spawn('node', [piAgentPath.pathname, ...remainingArgs], {
169
+ stdio: 'inherit',
170
+ env
171
+ });
172
+
173
+ child.on('exit', (code) => {
174
+ process.exit(code ?? 0);
175
+ });
176
+
177
+ child.on('error', (err) => {
178
+ console.error('Failed to start agent:', err);
179
+ process.exit(1);
180
+ });
@@ -11,22 +11,47 @@ import type { AssistantMessage } from "@mariozechner/pi-ai";
11
11
  const accentColor = "\x1b[38;2;73;188;207m";
12
12
  const reset = "\x1b[0m";
13
13
 
14
- // 随机消息列表
14
+ // 随机消息列表 - 金融/支付/科技术语
15
15
  const workingMessages = [
16
- "记得打卡~", "Thinking", "AICoding", "断直连", "备付金存管", "小额高频", "大额支付", "备用渠道", "聚合支付", "统一接口", "技术中台", "Processing","外包服务机构", "技术方案", "产品介绍", "业务量统计", "风险评级", "支付流程", "支付指令", "资金划转", "交易信息", "可追溯性", "支付成本", "支付创新", "数字翻译官", "信息转换", "安全保障", "指令传递", "协议适配", "系统对接", "技术规范", "交易透明度", "市场公平竞争", "路由", "支付转化率", "无感支付", "可靠性", "无主动确认支付", "资金流向相反", "批量付款", "收银台", "支付成功", "资金保障险", "72小时赔付", "盗刷赔付", "全链路服务", "资金查询", "结算服务", "对账服务", "生态完善", "打卡了吗",
17
- "Debugging", "Learning", "支付行业健康", "Reasoning", "Summarizing", "一会儿吃啥","Planning", "Executing","Refactoring", "aicoding","Documenting", "Researching", "Evaluating", "Comparing", "Calculating","支付", "清算", "结算", "交易", "货币债权", "贷记业务", "借记业务", "预付价值", "卡组织", "商业银行", "非银行支付机构", "收单机构", "账户侧", "受理侧", "服务商", "代理商", "清算所", "中央银行", "Fetching", "Parsing", "Validating","双人复核","Building", "Testing", "Deploying", "Monitoring", "四方模式", "本代本收单", "本代他收单", "银行卡支付", "实体卡", "数字卡", "贷记卡", "借记卡", "双标银行卡", "磁条卡", "芯片卡", "伪卡", "盗卡", "销售点终端(POS)", "POS签购单", "商户类别码(MCC)","Analyzing", "Reading", "Writing", "干活儿中","Searching", "Generating", "Compiling", "Running", "Optimizing", "非接触式支付", "拍卡过闸", "移动支付", "二维码支付", "条码支付", "NFC支付", "刷脸支付", "刷掌支付", "碰一下", "网关支付", "快捷支付", "认证支付", "IVR电话支付", "短信支付", "电子支付", "网上支付跨行清算系统(IBPS)", "mPOS", "数字钱包", "加密钱包支付", "账户对账户支付(A2A)", "先买后付(BNPL)", "稳定币", "代币化资产", "物联网+无感支付", "支付系统", "大额支付系统(HVPS)", "小额批量支付系统(BEPS)", "境内外币支付系统(CFXPS)", "清算账务系统", "账户系统", "登录账户", "支付账户", "银行接口", "对账", "冲正交易", "掉单", "补单", "参考号", "T+0", "T+1", "一清机", "二清机", "可信服务管理(TSM)", "风控系统", "反欺诈", "深度伪造(Deepfake)", "报文鉴别码(MAC)", "安全超文本传输协议(HTTPS)", "动态口令", "USB电子密钥", "侧录", "钓鱼网站", "非法移机", "调单", "一机一码", "一机一户", "259号文", "穿透式监管", "监管一致性", "支付牌照", "反洗钱(AML)", "无代码反洗钱采纳", "互联互通", "人工智能(AI)", "智能体(AI Agent)", "生成式AI(GenAI)", "数字身份", "虚拟卡", "循环经济", "法币抵押型稳定币", "加密资产抵押型稳定币", "算法稳定币", "商品抵押型稳定币", "支付型稳定币", "USDT", "USDC", "泰达币", "Circle", "美元稳定币", "港元稳定币", "离岸人民币稳定币", "稳定币发行方", "稳定币储备资产", "1:1锚定", "脱钩风险", "挤兑风险", "支付稳定币法案", "GENIUS法案", "稳定币条例", "稳定币沙盒", "链上法币", "跨境支付稳定币", "区块链", "分布式账本技术", "智能合约", "公有链", "联盟链", "最终性", "快速最终确认", "高吞吐量", "跨链", "Layer 2", "闪电网络", "DeFi", "去中心化金融", "RWA", "真实世界资产", "代币化", "资产代币化", "代币化存款", "加密钱包", "自托管钱包", "支付服务处理器", "支付网关", "出入金通道", "链上交易", "链下交易", "加密支付", "可编程支付", "可编程货币", "专用货币", "条件支付", "点对点支付", "加密编排层", "M0协议", "稳定币即服务", "第三方支付", "非金融机构支付", "互联网支付", "移动支付", "网络支付", "预付卡", "单用途预付卡", "多用途预付卡", "银行卡收单", "收单机构", "特约商户", "支付网关", "支付牌照", "支付中介", "网络支付接口", "受理终端", "聚合支付", "资金结算", "货币汇兑", "固定电话支付", "数字电视支付", "支付稳定币", "稳定币支付", "链上结算", "SWIFT替代", "跨境支付结算", "支付巨头稳定币布局", "支付基础设施", "商业银行稳定币", "监管一致性", "牌照管理", "合规成本", "生态协同", "网络效应", "真实采用", "商户结算", "稳定币交易手续费", "储备资产收益", "利息差额", "托管费", "无代码反洗钱采纳", "数字身份", "代币化资产", "物联网+无感支付", "循环经济", "网络安全", "信息安全", "数据安全", "加密技术", "数据加密", "传输加密", "存储加密", "端到端加密", "密钥管理", "密钥生命周期", "硬件安全模块(HSM)", "安全多方计算(MPC)", "可信执行环境(TEE)", "安全元件(SE)", "主机卡模拟(HCE)", "访问控制", "身份认证", "多因素认证(MFA)", "生物识别", "数据脱敏", "隐私计算", "差分隐私", "交易安全", "支付安全", "账户安全", "风控系统", "反欺诈", "实时风控", "行为分析", "设备指纹", "生物探针", "关联网络", "异常交易检测", "交易监控", "限额管理", "黑名单", "灰名单", "商户风险管理", "套现风险", "洗钱风险", "赌博风险", "欺诈交易", "盗刷", "账户盗用", "身份冒用", "薅羊毛", "恶意退款", "二次授权", "风险参数", "风险评分", "安全控件", "支付标记化", "终端安全", "移动安全", "应用安全", "代码混淆", "安全加固", "模拟器检测", "调试检测", "根检测", "Hook检测", "通信协议安全", "API安全", "网关安全", "服务器安全", "主机安全", "云安全", "容器安全", "中间件安全", "数据库安全", "Web应用防火墙(WAF)", "DDoS防护", "入侵检测", "入侵防御", "漏洞扫描", "渗透测试", "安全审计", "网络攻击", "黑客", "病毒", "木马", "蠕虫", "钓鱼", "鱼叉钓鱼", "短信钓鱼", "语音钓鱼", "恶意软件", "勒索软件", "间谍软件", "中间人攻击", "重放攻击", "会话劫持", "跨站脚本", "SQL注入", "撞库", "暴力破解", "密码猜测", "社会工程学", "伪基站", "嗅探", "侧录", "侧信道攻击", "冷板凳攻击", "智能合约安全", "重入攻击", "闪电贷攻击", "预言机攻击", "女巫攻击", "Sybil攻击", "51%攻击", "双花", "粉尘攻击", "蜜罐", "貔貅盘", "私钥安全", "助记词安全", "冷钱包", "热钱包", "多重签名", "私钥泄露", "授权攻击", "钓鱼签名", "假充值", "跨链桥安全", "共识算法安全", "零知识证明", "可信设置", "合规安全", "等级保护", "个人信息保护", "隐私政策", "安全标准", "PCI DSS", "PIN安全", "支付标记化标准", "EMVCo", "ISO 27001", "GDPR", "网络安全法", "数据安全法", "金融网络安全", "监管合规", "安全检查", "安全评估", "风险控制指标", "网络安全等级保护", "商用密码应用", "国密算法","断直连", "公共转接清算", "集中化清算", "透明化清算", "协议支付", "商业委托支付", "代收代扣", "付款业务", "退款业务", "辅助接口", "签约接口", "解约接口", "身份认证", "银行网关", "企业网银", "个人网银", "限额高", "体验流畅", "支付效率", "资金安全", "客户备付金", "风险控制", "跨行交易", "合法清算机构", "条码支付业务规范", "商户实名制", "交易风险监测", "本地化经营", "定期巡检", "业务创新"
16
+ // 金融支付类
17
+ "备付金", "网银支付", "快捷支付", "代付", "代收", "清算", "结算", "对账",
18
+ "交易路由", "风控", "反欺诈", "欺诈检测", "洗钱防控", "合规审查", "反洗钱",
19
+ "支付通道", "渠道商", "商户", "收款", "退款", "拒付", "冲正", "挂账",
20
+ "资金池", "沉淀资金", "T+1结算", "实时结算", "分账", "分润", "抽成",
21
+ "银行卡", "信用卡", "借记卡", "IC卡", "磁条卡", "虚拟卡", "预付费卡",
22
+ "二维码支付", "NFC支付", "刷脸支付", "指纹支付", "声纹支付",
23
+ "跨境支付", "外汇结算", "汇率", "国际清算", "SWIFT", "CIPS",
24
+
25
+ // 区块链/网络安全类
26
+ "区块链", "智能合约", "共识机制", "PoW", "PoS", "DPoS", "Gas费",
27
+ "加密货币", "比特币", "以太坊", "稳定币", "DeFi", "NFT", "Web3",
28
+ "数字签名", "哈希", "非对称加密", "对称加密", "公钥", "私钥", "证书",
29
+ "数字证书", "PKI体系", "CA中心", "SSL/TLS", "HTTPS", "国密算法",
30
+ "防火墙", "入侵检测", "DDoS防护", "WAF", "漏洞扫描", "渗透测试",
31
+
32
+ // 生产变更/运维类
33
+ "变更管理", "发布", "回滚", "灰度发布", "蓝绿部署", "金丝雀发布",
34
+ "熔断", "限流", "降级", "切流", "流量切换", "流量调度",
35
+ "监控", "告警", "日志", "链路追踪", "APM", "性能监控", "可用性",
36
+
37
+ // 技术通用类
38
+ "Proofing", "Thinking", "Analyzing", "Reading", "Writing", "Searching",
39
+ "Generating", "Compiling", "Running", "Optimizing", "Debugging", "Learning",
40
+ "Processing", "Reasoning", "Summarizing", "Planning", "Executing", "Fetching",
41
+ "Parsing", "Validating", "Building", "Testing", "Deploying", "Refactoring",
42
+ "Documenting", "Researching", "Evaluating", "Comparing", "Calculating",
43
+ "Algorithm", "Architecture", "Database", "Cache", "Queue", "Microservice",
18
44
  ];
19
45
 
46
+ let intervalId: ReturnType<typeof setInterval> | null = null;
47
+ let startTime = 0;
48
+ let totalTokens = 0;
49
+
20
50
  function getNextMessage(): string {
21
- // 随机选择词汇
22
51
  const randomIndex = Math.floor(Math.random() * workingMessages.length);
23
52
  return workingMessages[randomIndex];
24
53
  }
25
54
 
26
- let intervalId: ReturnType<typeof setInterval> | null = null;
27
- let startTime = 0;
28
- let totalTokens = 0;
29
-
30
55
  function formatTime(seconds: number): string {
31
56
  if (seconds < 60) return `${seconds} s`;
32
57
  const mins = Math.floor(seconds / 60);
@@ -1,23 +1,53 @@
1
1
  {
2
2
  "providers": {
3
- "GLM": {
4
- "name": "GLM",
5
- "baseUrl": "https://ai-llm.xxxxx.com/v1",
3
+ "openai": {
4
+ "name": "OpenAI",
5
+ "baseUrl": "https://api.openai.com/v1",
6
6
  "api": "openai-completions",
7
7
  "apiKey": "YOUR_API_KEY_HERE",
8
8
  "models": [
9
9
  {
10
- "id": "GLM-4.7-W8A8",
11
- "name": "GLM4.7",
12
- "contextWindow": 200000,
13
- "maxTokens": 100000,
10
+ "id": "gpt-4o",
11
+ "name": "GPT-4o",
12
+ "contextWindow": 128000,
13
+ "maxTokens": 16384,
14
+ "reasoning": false,
15
+ "input": ["text"],
16
+ "cost": {
17
+ "input": 2.5,
18
+ "output": 10
19
+ }
20
+ },
21
+ {
22
+ "id": "gpt-4o-mini",
23
+ "name": "GPT-4o Mini",
24
+ "contextWindow": 128000,
25
+ "maxTokens": 16384,
14
26
  "reasoning": false,
15
27
  "input": ["text"],
16
28
  "cost": {
17
- "input": 5,
18
- "output": 5,
19
- "cacheRead": 0,
20
- "cacheWrite": 0
29
+ "input": 0.075,
30
+ "output": 0.3
31
+ }
32
+ }
33
+ ]
34
+ },
35
+ "anthropic": {
36
+ "name": "Anthropic",
37
+ "baseUrl": "https://api.anthropic.com",
38
+ "api": "anthropic-messages",
39
+ "apiKey": "YOUR_API_KEY_HERE",
40
+ "models": [
41
+ {
42
+ "id": "claude-sonnet-4-20250514",
43
+ "name": "Claude Sonnet 4",
44
+ "contextWindow": 200000,
45
+ "maxTokens": 8192,
46
+ "reasoning": true,
47
+ "input": ["text"],
48
+ "cost": {
49
+ "input": 3,
50
+ "output": 15
21
51
  }
22
52
  }
23
53
  ]
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: code-simplifier
3
+ description: Simplifies and refines code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code unless instructed otherwise.
4
+ autho: xujianjiang
5
+ ---
6
+
7
+ You are an expert code simplification specialist focused on enhancing code clarity, consistency, and maintainability while preserving exact functionality. Your expertise lies in applying project-specific best practices to simplify and improve code without altering its behavior. You prioritize readable, explicit code over overly compact solutions. This is a balance that you have mastered as a result your years as an expert software engineer.
8
+
9
+ You will analyze recently modified code and apply refinements that:
10
+
11
+ 1. **Preserve Functionality**: Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.
12
+
13
+ 2. **Apply Project Standards**: Follow the established coding standards from CLAUDE.md including:
14
+
15
+ - Use ES modules with proper import sorting and extensions
16
+ - Prefer `function` keyword over arrow functions
17
+ - Use explicit return type annotations for top-level functions
18
+ - Follow proper React component patterns with explicit Props types
19
+ - Use proper error handling patterns (avoid try/catch when possible)
20
+ - Maintain consistent naming conventions
21
+
22
+ 3. **Enhance Clarity**: Simplify code structure by:
23
+
24
+ - Reducing unnecessary complexity and nesting
25
+ - Eliminating redundant code and abstractions
26
+ - Improving readability through clear variable and function names
27
+ - Consolidating related logic
28
+ - Removing unnecessary comments that describe obvious code
29
+ - IMPORTANT: Avoid nested ternary operators - prefer switch statements or if/else chains for multiple conditions
30
+ - Choose clarity over brevity - explicit code is often better than overly compact code
31
+
32
+ 4. **Maintain Balance**: Avoid over-simplification that could:
33
+
34
+ - Reduce code clarity or maintainability
35
+ - Create overly clever solutions that are hard to understand
36
+ - Combine too many concerns into single functions or components
37
+ - Remove helpful abstractions that improve code organization
38
+ - Prioritize "fewer lines" over readability (e.g., nested ternaries, dense one-liners)
39
+ - Make the code harder to debug or extend
40
+
41
+ 5. **Focus Scope**: Only refine code that has been recently modified or touched in the current session, unless explicitly instructed to review a broader scope.
42
+
43
+ Your refinement process:
44
+
45
+ 1. Identify the recently modified code sections
46
+ 2. Analyze for opportunities to improve elegance and consistency
47
+ 3. Apply project-specific best practices and coding standards
48
+ 4. Ensure all functionality remains unchanged
49
+ 5. Verify the refined code is simpler and more maintainable
50
+ 6. Document only significant changes that affect understanding
51
+
52
+ You operate autonomously and proactively, refining code immediately after it's written or modified without requiring explicit requests. Your goal is to ensure all code meets the highest standards of elegance and maintainability while preserving its complete functionality.
@@ -0,0 +1,165 @@
1
+ ---
2
+ name: brainstorming
3
+ author: xujianjiang
4
+ description: "You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation."
5
+ ---
6
+
7
+ # Brainstorming Ideas Into Designs
8
+
9
+ Help turn ideas into fully formed designs and specs through natural collaborative dialogue.
10
+
11
+ Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design and get user approval.
12
+
13
+ <HARD-GATE>
14
+ Do NOT invoke any implementation skill, write any code, scaffold any project, or take any implementation action until you have presented a design and the user has approved it. This applies to EVERY project regardless of perceived simplicity.
15
+ </HARD-GATE>
16
+
17
+ ## Anti-Pattern: "This Is Too Simple To Need A Design"
18
+
19
+ Every project goes through this process. A todo list, a single-function utility, a config change — all of them. "Simple" projects are where unexamined assumptions cause the most wasted work. The design can be short (a few sentences for truly simple projects), but you MUST present it and get approval.
20
+
21
+ ## Checklist
22
+
23
+ You MUST create a task for each of these items and complete them in order:
24
+
25
+ 1. **Explore project context** — check files, docs, recent commits
26
+ 2. **Offer visual companion** (if topic will involve visual questions) — this is its own message, not combined with a clarifying question. See the Visual Companion section below.
27
+ 3. **Ask clarifying questions** — one at a time, understand purpose/constraints/success criteria
28
+ 4. **Propose 2-3 approaches** — with trade-offs and your recommendation
29
+ 5. **Present design** — in sections scaled to their complexity, get user approval after each section
30
+ 6. **Write design doc** — save to `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md` and commit
31
+ 7. **Spec review loop** — dispatch spec-document-reviewer subagent with precisely crafted review context (never your session history); fix issues and re-dispatch until approved (max 3 iterations, then surface to human)
32
+ 8. **User reviews written spec** — ask user to review the spec file before proceeding
33
+ 9. **Transition to implementation** — invoke writing-plans skill to create implementation plan
34
+
35
+ ## Process Flow
36
+
37
+ ```dot
38
+ digraph brainstorming {
39
+ "Explore project context" [shape=box];
40
+ "Visual questions ahead?" [shape=diamond];
41
+ "Offer Visual Companion\n(own message, no other content)" [shape=box];
42
+ "Ask clarifying questions" [shape=box];
43
+ "Propose 2-3 approaches" [shape=box];
44
+ "Present design sections" [shape=box];
45
+ "User approves design?" [shape=diamond];
46
+ "Write design doc" [shape=box];
47
+ "Spec review loop" [shape=box];
48
+ "Spec review passed?" [shape=diamond];
49
+ "User reviews spec?" [shape=diamond];
50
+ "Invoke writing-plans skill" [shape=doublecircle];
51
+
52
+ "Explore project context" -> "Visual questions ahead?";
53
+ "Visual questions ahead?" -> "Offer Visual Companion\n(own message, no other content)" [label="yes"];
54
+ "Visual questions ahead?" -> "Ask clarifying questions" [label="no"];
55
+ "Offer Visual Companion\n(own message, no other content)" -> "Ask clarifying questions";
56
+ "Ask clarifying questions" -> "Propose 2-3 approaches";
57
+ "Propose 2-3 approaches" -> "Present design sections";
58
+ "Present design sections" -> "User approves design?";
59
+ "User approves design?" -> "Present design sections" [label="no, revise"];
60
+ "User approves design?" -> "Write design doc" [label="yes"];
61
+ "Write design doc" -> "Spec review loop";
62
+ "Spec review loop" -> "Spec review passed?";
63
+ "Spec review passed?" -> "Spec review loop" [label="issues found,\nfix and re-dispatch"];
64
+ "Spec review passed?" -> "User reviews spec?" [label="approved"];
65
+ "User reviews spec?" -> "Write design doc" [label="changes requested"];
66
+ "User reviews spec?" -> "Invoke writing-plans skill" [label="approved"];
67
+ }
68
+ ```
69
+
70
+ **The terminal state is invoking writing-plans.** Do NOT invoke frontend-design, mcp-builder, or any other implementation skill. The ONLY skill you invoke after brainstorming is writing-plans.
71
+
72
+ ## The Process
73
+
74
+ **Understanding the idea:**
75
+
76
+ - Check out the current project state first (files, docs, recent commits)
77
+ - Before asking detailed questions, assess scope: if the request describes multiple independent subsystems (e.g., "build a platform with chat, file storage, billing, and analytics"), flag this immediately. Don't spend questions refining details of a project that needs to be decomposed first.
78
+ - If the project is too large for a single spec, help the user decompose into sub-projects: what are the independent pieces, how do they relate, what order should they be built? Then brainstorm the first sub-project through the normal design flow. Each sub-project gets its own spec → plan → implementation cycle.
79
+ - For appropriately-scoped projects, ask questions one at a time to refine the idea
80
+ - Prefer multiple choice questions when possible, but open-ended is fine too
81
+ - Only one question per message - if a topic needs more exploration, break it into multiple questions
82
+ - Focus on understanding: purpose, constraints, success criteria
83
+
84
+ **Exploring approaches:**
85
+
86
+ - Propose 2-3 different approaches with trade-offs
87
+ - Present options conversationally with your recommendation and reasoning
88
+ - Lead with your recommended option and explain why
89
+
90
+ **Presenting the design:**
91
+
92
+ - Once you believe you understand what you're building, present the design
93
+ - Scale each section to its complexity: a few sentences if straightforward, up to 200-300 words if nuanced
94
+ - Ask after each section whether it looks right so far
95
+ - Cover: architecture, components, data flow, error handling, testing
96
+ - Be ready to go back and clarify if something doesn't make sense
97
+
98
+ **Design for isolation and clarity:**
99
+
100
+ - Break the system into smaller units that each have one clear purpose, communicate through well-defined interfaces, and can be understood and tested independently
101
+ - For each unit, you should be able to answer: what does it do, how do you use it, and what does it depend on?
102
+ - Can someone understand what a unit does without reading its internals? Can you change the internals without breaking consumers? If not, the boundaries need work.
103
+ - Smaller, well-bounded units are also easier for you to work with - you reason better about code you can hold in context at once, and your edits are more reliable when files are focused. When a file grows large, that's often a signal that it's doing too much.
104
+
105
+ **Working in existing codebases:**
106
+
107
+ - Explore the current structure before proposing changes. Follow existing patterns.
108
+ - Where existing code has problems that affect the work (e.g., a file that's grown too large, unclear boundaries, tangled responsibilities), include targeted improvements as part of the design - the way a good developer improves code they're working in.
109
+ - Don't propose unrelated refactoring. Stay focused on what serves the current goal.
110
+
111
+ ## After the Design
112
+
113
+ **Documentation:**
114
+
115
+ - Write the validated design (spec) to `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md`
116
+ - (User preferences for spec location override this default)
117
+ - Use elements-of-style:writing-clearly-and-concisely skill if available
118
+ - Commit the design document to git
119
+
120
+ **Spec Review Loop:**
121
+ After writing the spec document:
122
+
123
+ 1. Dispatch spec-document-reviewer subagent (see spec-document-reviewer-prompt.md)
124
+ 2. If Issues Found: fix, re-dispatch, repeat until Approved
125
+ 3. If loop exceeds 3 iterations, surface to human for guidance
126
+
127
+ **User Review Gate:**
128
+ After the spec review loop passes, ask the user to review the written spec before proceeding:
129
+
130
+ > "Spec written and committed to `<path>`. Please review it and let me know if you want to make any changes before we start writing out the implementation plan."
131
+
132
+ Wait for the user's response. If they request changes, make them and re-run the spec review loop. Only proceed once the user approves.
133
+
134
+ **Implementation:**
135
+
136
+ - Invoke the writing-plans skill to create a detailed implementation plan
137
+ - Do NOT invoke any other skill. writing-plans is the next step.
138
+
139
+ ## Key Principles
140
+
141
+ - **One question at a time** - Don't overwhelm with multiple questions
142
+ - **Multiple choice preferred** - Easier to answer than open-ended when possible
143
+ - **YAGNI ruthlessly** - Remove unnecessary features from all designs
144
+ - **Explore alternatives** - Always propose 2-3 approaches before settling
145
+ - **Incremental validation** - Present design, get approval before moving on
146
+ - **Be flexible** - Go back and clarify when something doesn't make sense
147
+
148
+ ## Visual Companion
149
+
150
+ A browser-based companion for showing mockups, diagrams, and visual options during brainstorming. Available as a tool — not a mode. Accepting the companion means it's available for questions that benefit from visual treatment; it does NOT mean every question goes through the browser.
151
+
152
+ **Offering the companion:** When you anticipate that upcoming questions will involve visual content (mockups, layouts, diagrams), offer it once for consent:
153
+ > "Some of what we're working on might be easier to explain if I can show it to you in a web browser. I can put together mockups, diagrams, comparisons, and other visuals as we go. This feature is still new and can be token-intensive. Want to try it? (Requires opening a local URL)"
154
+
155
+ **This offer MUST be its own message.** Do not combine it with clarifying questions, context summaries, or any other content. The message should contain ONLY the offer above and nothing else. Wait for the user's response before continuing. If they decline, proceed with text-only brainstorming.
156
+
157
+ **Per-question decision:** Even after the user accepts, decide FOR EACH QUESTION whether to use the browser or the terminal. The test: **would the user understand this better by seeing it than reading it?**
158
+
159
+ - **Use the browser** for content that IS visual — mockups, wireframes, layout comparisons, architecture diagrams, side-by-side visual designs
160
+ - **Use the terminal** for content that is text — requirements questions, conceptual choices, tradeoff lists, A/B/C/D text options, scope decisions
161
+
162
+ A question about a UI topic is not automatically a visual question. "What does personality mean in this context?" is a conceptual question — use the terminal. "Which wizard layout works better?" is a visual question — use the browser.
163
+
164
+ If they agree to the companion, read the detailed guide before proceeding:
165
+ `skills/brainstorming/visual-companion.md`