@ia-ccun/code-agent-cli 0.0.15 → 0.0.17
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/bin/cli.js +153 -84
- package/config/agent/extensions/working-msg.ts +33 -8
- package/config/agent/models.json +41 -11
- package/config/agent/prompts/code-simplifier.md +52 -0
- package/config/agent/skills/brainstorming/SKILL.md +165 -0
- package/config/agent/skills/brainstorming/scripts/frame-template.html +214 -0
- package/config/agent/skills/brainstorming/scripts/helper.js +88 -0
- package/config/agent/skills/brainstorming/scripts/server.cjs +338 -0
- package/config/agent/skills/brainstorming/scripts/start-server.sh +153 -0
- package/config/agent/skills/brainstorming/scripts/stop-server.sh +55 -0
- package/config/agent/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/config/agent/skills/brainstorming/visual-companion.md +286 -0
- package/config/agent/skills/dispatching-parallel-agents/SKILL.md +183 -0
- package/config/agent/skills/executing-plans/SKILL.md +71 -0
- package/config/agent/skills/finishing-a-development-branch/SKILL.md +201 -0
- package/config/agent/skills/owasp-security/SKILL.md +537 -0
- package/config/agent/skills/receiving-code-review/SKILL.md +214 -0
- package/config/agent/skills/requesting-code-review/SKILL.md +106 -0
- package/config/agent/skills/requesting-code-review/code-reviewer.md +146 -0
- package/config/agent/skills/skill-creator/SKILL.md +337 -213
- package/config/agent/skills/skill-creator/agents/analyzer.md +274 -0
- package/config/agent/skills/skill-creator/agents/comparator.md +202 -0
- package/config/agent/skills/skill-creator/agents/grader.md +223 -0
- package/config/agent/skills/skill-creator/assets/eval_review.html +146 -0
- package/config/agent/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/config/agent/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/config/agent/skills/skill-creator/references/schemas.md +430 -0
- package/config/agent/skills/skill-creator/scripts/__init__.py +0 -0
- package/config/agent/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/config/agent/skills/skill-creator/scripts/generate_report.py +326 -0
- package/config/agent/skills/skill-creator/scripts/improve_description.py +248 -0
- package/config/agent/skills/skill-creator/scripts/package_skill.py +33 -7
- package/config/agent/skills/skill-creator/scripts/quick_validate.py +11 -3
- package/config/agent/skills/skill-creator/scripts/run_eval.py +310 -0
- package/config/agent/skills/skill-creator/scripts/run_loop.py +332 -0
- package/config/agent/skills/skill-creator/scripts/utils.py +47 -0
- package/config/agent/skills/subagent-driven-development/SKILL.md +278 -0
- package/config/agent/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
- package/config/agent/skills/subagent-driven-development/implementer-prompt.md +113 -0
- package/config/agent/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/config/agent/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/config/agent/skills/systematic-debugging/SKILL.md +297 -0
- package/config/agent/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/config/agent/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/config/agent/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/config/agent/skills/systematic-debugging/find-polluter.sh +63 -0
- package/config/agent/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/config/agent/skills/systematic-debugging/test-academic.md +14 -0
- package/config/agent/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/config/agent/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/config/agent/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/config/agent/skills/test-driven-development/SKILL.md +372 -0
- package/config/agent/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/config/agent/skills/using-git-worktrees/SKILL.md +219 -0
- package/config/agent/skills/using-superpowers/SKILL.md +116 -0
- package/config/agent/skills/using-superpowers/references/codex-tools.md +25 -0
- package/config/agent/skills/using-superpowers/references/gemini-tools.md +33 -0
- package/config/agent/skills/verification-before-completion/SKILL.md +140 -0
- package/config/agent/skills/writing-plans/SKILL.md +146 -0
- package/config/agent/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/config/agent/skills/writing-skills/SKILL.md +667 -0
- package/config/agent/skills/writing-skills/anthropic-best-practices.md +1150 -0
- package/config/agent/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/config/agent/skills/writing-skills/graphviz-conventions.dot +172 -0
- package/config/agent/skills/writing-skills/persuasion-principles.md +187 -0
- package/config/agent/skills/writing-skills/render-graphs.js +168 -0
- package/config/agent/skills/writing-skills/testing-skills-with-subagents.md +384 -0
- package/package.json +14 -7
- package/scripts/postinstall.js +81 -19
- package/config/agent/skills/github/SKILL.md +0 -47
- package/config/agent/skills/owasp/SKILL.md +0 -169
- package/config/agent/skills/pua/SKILL.md +0 -364
- package/config/agent/skills/skill-creator/references/output-patterns.md +0 -82
- package/config/agent/skills/skill-creator/references/workflows.md +0 -28
- 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
|
-
*
|
|
4
|
-
*
|
|
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 {
|
|
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
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
//
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
94
|
+
}, 100); // 延迟 100ms 确保不影响主流程
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// WebUI 模式
|
|
98
|
+
if (webMode) {
|
|
99
|
+
const webuiDir = join(__dirname, '..', 'webui', 'server');
|
|
46
100
|
|
|
47
|
-
//
|
|
48
|
-
|
|
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
|
-
|
|
61
|
-
bannerConfig = config.banner || '';
|
|
104
|
+
execSync('npm run build', { cwd: webuiDir, stdio: 'inherit' });
|
|
62
105
|
} catch (e) {
|
|
63
|
-
|
|
106
|
+
console.error('Failed to build WebUI:', e);
|
|
107
|
+
process.exit(1);
|
|
64
108
|
}
|
|
65
109
|
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
let lines = [];
|
|
121
|
+
// 自动打开浏览器
|
|
122
|
+
const port = webPort || 3002;
|
|
123
|
+
setTimeout(() => {
|
|
77
124
|
try {
|
|
78
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
101
|
-
|
|
131
|
+
webuiProcess.on('exit', (code) => {
|
|
132
|
+
process.exit(code ?? 0);
|
|
133
|
+
});
|
|
102
134
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
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
|
-
|
|
111
|
-
|
|
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
|
-
|
|
17
|
-
"
|
|
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);
|
package/config/agent/models.json
CHANGED
|
@@ -1,23 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"providers": {
|
|
3
|
-
"
|
|
4
|
-
"name": "
|
|
5
|
-
"baseUrl": "https://
|
|
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": "
|
|
11
|
-
"name": "
|
|
12
|
-
"contextWindow":
|
|
13
|
-
"maxTokens":
|
|
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":
|
|
18
|
-
"output":
|
|
19
|
-
|
|
20
|
-
|
|
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`
|