opencode-api-security-testing 3.0.6 → 3.0.7

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 (2) hide show
  1. package/package.json +5 -3
  2. package/preuninstall.mjs +76 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-api-security-testing",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
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",
@@ -10,10 +10,12 @@
10
10
  "core/",
11
11
  "references/",
12
12
  "SKILL.md",
13
- "postinstall.mjs"
13
+ "postinstall.mjs",
14
+ "preuninstall.mjs"
14
15
  ],
15
16
  "scripts": {
16
- "postinstall": "node postinstall.mjs"
17
+ "postinstall": "node postinstall.mjs",
18
+ "preuninstall": "node preuninstall.mjs"
17
19
  },
18
20
  "keywords": [
19
21
  "opencode",
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * preuninstall.mjs - API Security Testing Plugin Cleanup
5
+ *
6
+ * Removes:
7
+ * 1. agents from ~/.config/opencode/agents/
8
+ * 2. SKILL.md and references from ~/.config/opencode/skills/api-security-testing/
9
+ */
10
+
11
+ import { unlinkSync, existsSync, readdirSync, rmdirSync, rmSync } from "node:fs";
12
+ import { join } from "node:path";
13
+ import { fileURLToPath } from "node:url";
14
+
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = join(__filename, "..");
17
+
18
+ function getOpencodeBaseDir() {
19
+ const home = process.env.HOME || process.env.USERPROFILE || "/root";
20
+ return join(home, ".config", "opencode");
21
+ }
22
+
23
+ const AGENTS_TO_REMOVE = [
24
+ "api-cyber-supervisor.md",
25
+ "api-probing-miner.md",
26
+ "api-resource-specialist.md",
27
+ "api-vuln-verifier.md",
28
+ ];
29
+
30
+ function main() {
31
+ const agentsTargetDir = join(getOpencodeBaseDir(), "agents");
32
+ const skillTargetDir = join(getOpencodeBaseDir(), "skills", "api-security-testing");
33
+
34
+ console.log("[api-security-testing] Cleaning up...");
35
+ console.log(` Home: ${getOpencodeBaseDir()}`);
36
+
37
+ let totalRemoved = 0;
38
+ let totalFailed = 0;
39
+
40
+ console.log("\n[1/2] Removing agents...");
41
+ for (const agent of AGENTS_TO_REMOVE) {
42
+ const agentPath = join(agentsTargetDir, agent);
43
+ try {
44
+ if (existsSync(agentPath)) {
45
+ unlinkSync(agentPath);
46
+ console.log(` ✓ ${agent}`);
47
+ totalRemoved++;
48
+ }
49
+ } catch (err) {
50
+ console.error(` ✗ ${agent}: ${err.message}`);
51
+ totalFailed++;
52
+ }
53
+ }
54
+
55
+ console.log("\n[2/2] Removing skill files...");
56
+ try {
57
+ if (existsSync(skillTargetDir)) {
58
+ rmSync(skillTargetDir, { recursive: true, force: true });
59
+ console.log(` ✓ ${skillTargetDir}`);
60
+ totalRemoved++;
61
+ }
62
+ } catch (err) {
63
+ console.error(` ✗ ${skillTargetDir}: ${err.message}`);
64
+ totalFailed++;
65
+ }
66
+
67
+ console.log(`\n========================================`);
68
+ if (totalFailed === 0) {
69
+ console.log(`✓ Removed ${totalRemoved} item(s)`);
70
+ console.log(`\nThanks for using api-security-testing!`);
71
+ } else {
72
+ console.log(`⚠ Removed ${totalRemoved}, failed ${totalFailed}`);
73
+ }
74
+ }
75
+
76
+ main();