opencode-api-security-testing 3.0.2 → 3.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-api-security-testing",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "API Security Testing Plugin for OpenCode - Automated vulnerability scanning and penetration testing",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/postinstall.mjs CHANGED
@@ -4,17 +4,16 @@
4
4
  * postinstall.mjs - API Security Testing Plugin
5
5
  *
6
6
  * Installs:
7
- * 1. Agents to ~/.config/opencode/agents/
8
- * 2. Skill (SKILL.md) to ~/.config/opencode/skills/api-security-testing/
9
- * 3. References to ~/.config/opencode/skills/api-security-testing/
7
+ * 1. agents to ~/.config/opencode/agents/
8
+ * 2. SKILL.md and references to ~/.config/opencode/skills/api-security-testing/
10
9
  */
11
10
 
12
11
  import { copyFileSync, existsSync, mkdirSync, readdirSync } from "node:fs";
13
- import { join, dirname } from "node:path";
12
+ import { join } from "node:path";
14
13
  import { fileURLToPath } from "node:url";
15
14
 
16
15
  const __filename = fileURLToPath(import.meta.url);
17
- const __dirname = dirname(__filename);
16
+ const __dirname = join(__filename, "..");
18
17
 
19
18
  function getOpencodeBaseDir() {
20
19
  const home = process.env.HOME || process.env.USERPROFILE || "/root";
@@ -29,100 +28,90 @@ function main() {
29
28
 
30
29
  console.log("[api-security-testing] Installing...");
31
30
  console.log(` Package root: ${packageRoot}`);
32
- console.log(` Target base: ${getOpencodeBaseDir()}`);
33
31
 
34
- let successCount = 0;
35
- let totalFiles = 0;
32
+ let totalInstalled = 0;
33
+ let totalFailed = 0;
36
34
 
37
35
  // 1. Install agents
38
36
  console.log("\n[1/3] Installing agents...");
39
37
  if (existsSync(agentsSourceDir)) {
40
- const agentFiles = readdirSync(agentsSourceDir).filter(f => f.endsWith(".md"));
41
- totalFiles += agentFiles.length;
42
-
43
38
  if (!existsSync(agentsTargetDir)) {
44
39
  mkdirSync(agentsTargetDir, { recursive: true });
45
40
  }
46
41
 
47
- for (const file of agentFiles) {
48
- const sourcePath = join(agentsSourceDir, file);
49
- const targetPath = join(agentsTargetDir, file);
42
+ const files = readdirSync(agentsSourceDir).filter(f => f.endsWith(".md"));
43
+ for (const file of files) {
50
44
  try {
51
- copyFileSync(sourcePath, targetPath);
52
- console.log(` ✓ Installed agent: ${file}`);
53
- successCount++;
45
+ copyFileSync(join(agentsSourceDir, file), join(agentsTargetDir, file));
46
+ console.log(` ✓ ${file}`);
47
+ totalInstalled++;
54
48
  } catch (err) {
55
- console.error(` ✗ Failed: ${file} - ${err.message}`);
49
+ console.error(` ✗ ${file}: ${err.message}`);
50
+ totalFailed++;
56
51
  }
57
52
  }
58
- } else {
59
- console.error(" ✗ agents/ directory not found");
60
53
  }
61
54
 
62
55
  // 2. Install SKILL.md
63
- console.log("\n[2/3] Installing skill...");
56
+ console.log("\n[2/3] Installing SKILL.md...");
64
57
  const skillSource = join(packageRoot, "SKILL.md");
65
- const skillTarget = join(skillTargetDir, "SKILL.md");
66
- totalFiles++;
67
-
68
58
  if (existsSync(skillSource)) {
69
59
  if (!existsSync(skillTargetDir)) {
70
60
  mkdirSync(skillTargetDir, { recursive: true });
71
61
  }
72
62
  try {
73
- copyFileSync(skillSource, skillTarget);
74
- console.log(`Installed: SKILL.md`);
75
- successCount++;
63
+ copyFileSync(skillSource, join(skillTargetDir, "SKILL.md"));
64
+ console.log(" ✓ SKILL.md");
65
+ totalInstalled++;
76
66
  } catch (err) {
77
- console.error(` ✗ Failed: SKILL.md - ${err.message}`);
67
+ console.error(` ✗ SKILL.md: ${err.message}`);
68
+ totalFailed++;
78
69
  }
79
- } else {
80
- console.error(" ✗ SKILL.md not found");
81
70
  }
82
71
 
83
72
  // 3. Install references
84
73
  console.log("\n[3/3] Installing references...");
85
74
  const refsSourceDir = join(packageRoot, "references");
86
75
  const refsTargetDir = join(skillTargetDir, "references");
87
-
88
76
  if (existsSync(refsSourceDir)) {
89
77
  if (!existsSync(refsTargetDir)) {
90
78
  mkdirSync(refsTargetDir, { recursive: true });
91
79
  }
92
80
 
93
- const refFiles = readdirSync(refsSourceDir, { recursive: true }).filter(f => typeof f === "string");
94
- totalFiles += refFiles.length;
95
-
96
- for (const file of refFiles) {
97
- const sourcePath = join(refsSourceDir, file);
98
- const targetPath = join(refsTargetDir, file);
99
- const targetFileDir = join(refsTargetDir, file).replace(/\/[^\/]+$/, "");
100
- if (!existsSync(targetFileDir)) {
101
- mkdirSync(targetFileDir, { recursive: true });
102
- }
103
- try {
104
- copyFileSync(sourcePath, targetPath);
105
- console.log(` ✓ Installed: references/${file}`);
106
- successCount++;
107
- } catch (err) {
108
- console.error(` ✗ Failed: references/${file} - ${err.message}`);
81
+ function copyDir(src, dest) {
82
+ const items = readdirSync(src);
83
+ for (const item of items) {
84
+ const srcPath = join(src, item);
85
+ const destPath = join(dest, item);
86
+ try {
87
+ copyFileSync(srcPath, destPath);
88
+ totalInstalled++;
89
+ } catch {
90
+ if (existsSync(srcPath) && !srcPath.endsWith(".md")) {
91
+ mkdirSync(destPath, { recursive: true });
92
+ copyDir(srcPath, destPath);
93
+ }
94
+ }
109
95
  }
110
96
  }
111
- } else {
112
- console.log(" (references/ not found, skipping)");
97
+
98
+ try {
99
+ copyDir(refsSourceDir, refsTargetDir);
100
+ console.log(" ✓ references/");
101
+ totalInstalled++;
102
+ } catch (err) {
103
+ console.error(` ✗ references/: ${err.message}`);
104
+ totalFailed++;
105
+ }
113
106
  }
114
107
 
115
- // Summary
116
- console.log("\n========================================");
117
- if (successCount === totalFiles) {
118
- console.log(`✓ Successfully installed ${successCount} file(s)`);
119
- console.log(`\nAgent location: ${agentsTargetDir}`);
120
- console.log(`Skill location: ${skillTargetDir}`);
121
- console.log("\nTo use:");
122
- console.log(" @api-cyber-supervisor - Start security testing");
123
- console.log(" skill({ name: \"api-security-testing\" }) - Load skill");
108
+ console.log(`\n========================================`);
109
+ if (totalFailed === 0) {
110
+ console.log(`✓ Installed ${totalInstalled} file(s)`);
111
+ console.log(`\nAgents: ${agentsTargetDir}`);
112
+ console.log(`Skill: ${skillTargetDir}`);
124
113
  } else {
125
- console.log(`⚠ Partially installed: ${successCount}/${totalFiles}`);
114
+ console.log(`⚠ Installed ${totalInstalled}, failed ${totalFailed}`);
126
115
  process.exit(1);
127
116
  }
128
117
  }
package/src/index.ts CHANGED
@@ -361,7 +361,7 @@ print(result)
361
361
  prompt: VULN_VERIFIER_PROMPT,
362
362
  };
363
363
 
364
- console.log("[api-security-testing] Agents registered:", Object.keys(agents));
364
+ console.log("[api-security-testing] Tools registered");
365
365
  },
366
366
  };
367
367
  };