@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.
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 +81 -19
  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
@@ -81,20 +81,7 @@ if (!existsSync(agentDir)) {
81
81
  console.log(`✓ Created directory: ${agentDir}`);
82
82
  }
83
83
 
84
- // Force overwrite files (regardless of whether user has modified them)
85
- const forceOverwriteFiles = [
86
- 'extensions/working-msg.ts',
87
- // 可以添加更多需要强制覆盖的文件,例如:
88
- // 'extensions/custom.ts',
89
- // 'SYSTEM.md',
90
- ];
91
-
92
- function shouldForceOverwrite(dest) {
93
- const relativePath = relative(agentDir, dest).replace(/\\/g, '/');
94
- return forceOverwriteFiles.includes(relativePath);
95
- }
96
-
97
- // Function to copy directory recursively (only copy if destination doesn't exist, unless in force list)
84
+ // Function to copy directory recursively (only copy if destination doesn't exist)
98
85
  function copyDirRecursive(src, dest) {
99
86
  const exists = existsSync(src);
100
87
  const stats = exists && statSync(src);
@@ -113,21 +100,41 @@ function copyDirRecursive(src, dest) {
113
100
  copyDirRecursive(srcPath, destPath);
114
101
  });
115
102
  } else {
116
- // Copy if source exists AND (destination doesn't exist OR force overwrite)
117
- if (exists && (!existsSync(dest) || shouldForceOverwrite(dest))) {
103
+ // Only copy if source exists AND destination doesn't exist (preserve user files)
104
+ if (exists && !existsSync(dest)) {
118
105
  // Ensure parent directory exists
119
106
  const parentDir = dirname(dest);
120
107
  if (!existsSync(parentDir)) {
121
108
  mkdirSync(parentDir, { recursive: true });
122
109
  }
123
110
 
124
- const action = existsSync(dest) ? '↻ Updated' : '+ Added';
125
111
  copyFileSync(src, dest);
126
- console.log(` ${action}: ${relative(agentDir, dest)}`);
112
+ console.log(` + Added: ${relative(agentDir, dest)}`);
127
113
  }
128
114
  }
129
115
  }
130
116
 
117
+ // Force copy directory recursively (always overwrite destination)
118
+ function forceCopyDirRecursive(src, dest) {
119
+ if (!existsSync(src)) return;
120
+
121
+ const stats = statSync(src);
122
+ if (stats.isDirectory()) {
123
+ if (!existsSync(dest)) {
124
+ mkdirSync(dest, { recursive: true });
125
+ }
126
+ readdirSync(src).forEach(file => {
127
+ forceCopyDirRecursive(join(src, file), join(dest, file));
128
+ });
129
+ } else {
130
+ const parentDir = dirname(dest);
131
+ if (!existsSync(parentDir)) {
132
+ mkdirSync(parentDir, { recursive: true });
133
+ }
134
+ copyFileSync(src, dest);
135
+ }
136
+ }
137
+
131
138
  // Copy config.json if it doesn't exist
132
139
  const packageConfigFile = join(__dirname, '..', 'config.json');
133
140
  const userConfigFile = join(aicodeCliDir, 'config.json');
@@ -139,8 +146,58 @@ if (existsSync(packageConfigFile) && !existsSync(userConfigFile)) {
139
146
  console.log('⚠ config.json not found in package');
140
147
  }
141
148
 
142
- // Copy config/agent contents to ~/.aicode-cli/agent only if they don't exist (preserve user customizations)
149
+ // ============================================================================
150
+ // Files/folders that must be force-overwritten on every install
151
+ // ============================================================================
143
152
  const packageConfigDir = join(__dirname, '..', 'config', 'agent');
153
+
154
+ const FORCE_OVERWRITE_LIST = [
155
+ 'extensions/working-msg.ts',
156
+ // Add more files or folders here to force overwrite on every install
157
+ // Examples:
158
+ // 'skills/some-skill',
159
+ // 'prompts/some-prompt.md',
160
+ // 'themes/dark.json',
161
+ ];
162
+
163
+ // Function to force overwrite specific files/folders
164
+ function forceOverwriteList(relativePaths) {
165
+ relativePaths.forEach(relativePath => {
166
+ const srcPath = join(packageConfigDir, relativePath);
167
+ const destPath = join(agentDir, relativePath);
168
+
169
+ if (existsSync(srcPath)) {
170
+ try {
171
+ const stats = statSync(srcPath);
172
+ if (stats.isDirectory()) {
173
+ // Force copy directory
174
+ if (!existsSync(destPath)) {
175
+ mkdirSync(destPath, { recursive: true });
176
+ }
177
+ forceCopyDirRecursive(srcPath, destPath);
178
+ console.log(`✓ Force overwritten (dir): ${relativePath}`);
179
+ } else {
180
+ // Force copy file
181
+ const parentDir = dirname(destPath);
182
+ if (!existsSync(parentDir)) {
183
+ mkdirSync(parentDir, { recursive: true });
184
+ }
185
+ copyFileSync(srcPath, destPath);
186
+ console.log(`✓ Force overwritten: ${relativePath}`);
187
+ }
188
+ } catch (e) {
189
+ console.log(`⚠ Could not force overwrite ${relativePath}: ${e.message}`);
190
+ if (e.stack) {
191
+ console.log(e.stack);
192
+ }
193
+ }
194
+ } else {
195
+ console.log(`⚠ Source path does not exist: ${relativePath}`);
196
+ }
197
+ });
198
+ }
199
+
200
+ // Copy config/agent contents to ~/.aicode-cli/agent only if they don't exist (preserve user customizations)
144
201
  if (existsSync(packageConfigDir)) {
145
202
  console.log(`📁 Syncing default config files to ${agentDir} (preserving user customizations)`);
146
203
 
@@ -148,6 +205,11 @@ if (existsSync(packageConfigDir)) {
148
205
  copyDirRecursive(packageConfigDir, agentDir);
149
206
  console.log('✓ Default config files synced successfully');
150
207
 
208
+ // Force overwrite specified files/folders
209
+ if (FORCE_OVERWRITE_LIST.length > 0) {
210
+ forceOverwriteList(FORCE_OVERWRITE_LIST);
211
+ }
212
+
151
213
  // Check for extensions
152
214
  const extensionsDir = join(agentDir, 'extensions');
153
215
  if (existsSync(extensionsDir)) {
@@ -1,47 +0,0 @@
1
- ---
2
- name: github
3
- description: "Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries."
4
- ---
5
-
6
- # GitHub Skill
7
-
8
- Use the `gh` CLI to interact with GitHub. Always specify `--repo owner/repo` when not in a git directory, or use URLs directly.
9
-
10
- ## Pull Requests
11
-
12
- Check CI status on a PR:
13
- ```bash
14
- gh pr checks 55 --repo owner/repo
15
- ```
16
-
17
- List recent workflow runs:
18
- ```bash
19
- gh run list --repo owner/repo --limit 10
20
- ```
21
-
22
- View a run and see which steps failed:
23
- ```bash
24
- gh run view <run-id> --repo owner/repo
25
- ```
26
-
27
- View logs for failed steps only:
28
- ```bash
29
- gh run view <run-id> --repo owner/repo --log-failed
30
- ```
31
-
32
- ## API for Advanced Queries
33
-
34
- The `gh api` command is useful for accessing data not available through other subcommands.
35
-
36
- Get PR with specific fields:
37
- ```bash
38
- gh api repos/owner/repo/pulls/55 --jq '.title, .state, .user.login'
39
- ```
40
-
41
- ## JSON Output
42
-
43
- Most commands support `--json` for structured output. You can use `--jq` to filter:
44
-
45
- ```bash
46
- gh issue list --repo owner/repo --json number,title --jq '.[] | "\(.number): \(.title)"'
47
- ```
@@ -1,169 +0,0 @@
1
- ---
2
- name: owasp
3
- description: |
4
- OWASP security guidelines and Top 10 vulnerabilities
5
-
6
- USE WHEN: user mentions "OWASP", "security audit", "vulnerability scan", asks about "injection", "XSS", "CSRF", "access control", "authentication security"
7
-
8
- DO NOT USE FOR: OWASP Top 10:2025 specific - use `owasp-top-10` instead
9
- allowed-tools: Read, Grep, Glob
10
- ---
11
- # OWASP Security - Quick Reference
12
-
13
- ## When to Use This Skill
14
- - Identify common vulnerabilities
15
- - Implement security controls
16
- - Code review for security issues
17
-
18
- ## When NOT to Use This Skill
19
- - **OWASP Top 10:2025** - Use `owasp-top-10` skill for latest 2025 standards
20
- - **Secrets management** - Use `secrets-management` skill for credentials handling
21
- - **Supply chain security** - Use `supply-chain` skill for dependency issues
22
- - **JWT/OAuth security** - Use authentication skills for protocol-specific issues
23
-
24
- > **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `owasp` for comprehensive documentation.
25
-
26
- ## OWASP Top 10 (2021)
27
-
28
- ### A01: Broken Access Control
29
- ```java
30
- // BAD - Direct object reference
31
- @GetMapping("/users/{id}")
32
- public User getUser(@PathVariable Long id) {
33
- return userRepository.findById(id);
34
- }
35
-
36
- // GOOD - Check authorization
37
- @GetMapping("/users/{id}")
38
- public User getUser(@PathVariable Long id, Authentication auth) {
39
- User user = userRepository.findById(id);
40
- if (!user.getId().equals(auth.getPrincipal().getId())) {
41
- throw new AccessDeniedException("Not authorized");
42
- }
43
- return user;
44
- }
45
- ```
46
-
47
- ### A02: Cryptographic Failures
48
- ```java
49
- // BAD - Weak hashing
50
- String hash = DigestUtils.md5Hex(password);
51
-
52
- // GOOD - Strong hashing with salt
53
- BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
54
- String hash = encoder.encode(password);
55
- ```
56
-
57
- ### A03: Injection
58
- ```java
59
- // BAD - SQL Injection
60
- String query = "SELECT * FROM users WHERE name = '" + name + "'";
61
-
62
- // GOOD - Parameterized query
63
- @Query("SELECT u FROM User u WHERE u.name = :name")
64
- User findByName(@Param("name") String name);
65
- ```
66
-
67
- ### A04: Insecure Design
68
- - Threat modeling during design phase
69
- - Security requirements in user stories
70
- - Defense in depth architecture
71
-
72
- ### A05: Security Misconfiguration
73
- ```yaml
74
- # Spring Security - disable defaults carefully
75
- spring:
76
- security:
77
- headers:
78
- content-security-policy: "default-src 'self'"
79
- x-frame-options: DENY
80
- x-content-type-options: nosniff
81
- ```
82
-
83
- ### A06: Vulnerable Components
84
- ```bash
85
- # Check for vulnerabilities
86
- npm audit
87
- mvn dependency-check:check
88
- pip-audit
89
- ```
90
-
91
- ### A07: Auth Failures
92
- ```java
93
- // Implement rate limiting
94
- @RateLimiter(name = "login", fallbackMethod = "loginFallback")
95
- public AuthResponse login(LoginRequest request) {
96
- // ...
97
- }
98
-
99
- // Account lockout
100
- if (failedAttempts >= 5) {
101
- lockAccount(user);
102
- }
103
- ```
104
-
105
- ### A08: Software Integrity
106
- - Verify signatures of dependencies
107
- - Use lock files (package-lock.json, pom.xml)
108
- - CI/CD pipeline security
109
-
110
- ### A09: Logging Failures
111
- ```java
112
- // Log security events
113
- log.info("Login attempt", Map.of(
114
- "user", username,
115
- "ip", request.getRemoteAddr(),
116
- "success", authenticated
117
- ));
118
-
119
- // DON'T log sensitive data
120
- log.info("Password: {}", password); // NEVER!
121
- ```
122
-
123
- ### A10: SSRF
124
- ```java
125
- // Validate URLs
126
- private boolean isAllowedUrl(String url) {
127
- URL parsed = new URL(url);
128
- return allowedHosts.contains(parsed.getHost());
129
- }
130
- ```
131
-
132
- ## Security Headers
133
-
134
- ```java
135
- @Configuration
136
- public class SecurityConfig {
137
- @Bean
138
- public SecurityFilterChain filterChain(HttpSecurity http) {
139
- return http
140
- .headers(headers -> headers
141
- .contentSecurityPolicy(csp -> csp.policyDirectives("default-src 'self'"))
142
- .frameOptions(frame -> frame.deny())
143
- .xssProtection(xss -> xss.disable())
144
- )
145
- .build();
146
- }
147
- }
148
- ```
149
-
150
- ## Anti-Patterns
151
-
152
- | Anti-Pattern | Why It's Bad | Correct Approach |
153
- |--------------|--------------|------------------|
154
- | Direct object references without auth | IDOR vulnerability (A01) | Always verify ownership before access |
155
- | Using MD5/SHA1 for passwords | Easily cracked | Use bcrypt/argon2 with salt |
156
- | String concatenation in SQL | SQL injection | Use parameterized queries/ORMs |
157
- | Exposing stack traces in prod | Information disclosure | Generic error messages only |
158
- | No rate limiting on login | Brute force attacks | Implement rate limiting + account lockout |
159
- | Storing secrets in code | Credential exposure | Use environment variables/vaults |
160
-
161
- ## Quick Troubleshooting
162
-
163
- | Issue | Likely Cause | Solution |
164
- |-------|--------------|----------|
165
- | 403 Forbidden on valid request | CORS misconfiguration | Check allowed origins in CORS config |
166
- | Session not persisting | SameSite cookie issue | Set `SameSite=Lax` or `None` with HTTPS |
167
- | JWT token rejected | Clock skew or expired | Add clock skew tolerance (5min) |
168
- | File upload fails | CSP blocking | Add upload domain to CSP directives |
169
- | API returns 401 unexpectedly | Missing/invalid Authorization header | Check Bearer token format |