promptgraph-mcp 2.4.7 → 2.4.8

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 (95) hide show
  1. package/README.md +3 -6
  2. package/ann.js +23 -51
  3. package/api.js +200 -0
  4. package/config.js +7 -0
  5. package/db.js +20 -0
  6. package/embedder.js +10 -0
  7. package/github-import.js +102 -22
  8. package/indexer.js +45 -11
  9. package/marketplace.js +47 -5
  10. package/package.json +9 -3
  11. package/search.js +84 -20
  12. package/src/filter/hard-filter.js +2 -0
  13. package/src/filter/train.js +3 -1
  14. package/src/store/flat-store.js +61 -0
  15. package/src/store/hnsw-store.js +187 -0
  16. package/src/store/index.js +19 -0
  17. package/src/store/vector-store.js +9 -0
  18. package/validator.js +7 -1
  19. package/registry/training/bad/accepts-HISTORY.md +0 -250
  20. package/registry/training/bad/argparse-CHANGELOG.md +0 -185
  21. package/registry/training/bad/balanced-match-LICENSE.md +0 -23
  22. package/registry/training/bad/better-sqlite3-README.md +0 -99
  23. package/registry/training/bad/bindings-LICENSE.md +0 -22
  24. package/registry/training/bad/bl-LICENSE.md +0 -13
  25. package/registry/training/bad/body-parser-README.md +0 -494
  26. package/registry/training/bad/bytes-HISTORY.md +0 -97
  27. package/registry/training/bad/camelcase-README.md +0 -135
  28. package/registry/training/bad/chai-README.md +0 -162
  29. package/registry/training/bad/cli-progress-LICENSE.md +0 -24
  30. package/registry/training/bad/content-type-HISTORY.md +0 -29
  31. package/registry/training/bad/cookie-SECURITY.md +0 -25
  32. package/registry/training/bad/cookie-signature-HISTORY.md +0 -70
  33. package/registry/training/bad/cors-README.md +0 -277
  34. package/registry/training/bad/cross-spawn-README.md +0 -89
  35. package/registry/training/bad/deep-extend-CHANGELOG.md +0 -46
  36. package/registry/training/bad/depd-HISTORY.md +0 -103
  37. package/registry/training/bad/esprima-README.md +0 -46
  38. package/registry/training/bad/etag-HISTORY.md +0 -83
  39. package/registry/training/bad/expect-type-SECURITY.md +0 -14
  40. package/registry/training/bad/finalhandler-HISTORY.md +0 -239
  41. package/registry/training/bad/fresh-HISTORY.md +0 -80
  42. package/registry/training/bad/glob-LICENSE.md +0 -63
  43. package/registry/training/bad/hono-README.md +0 -85
  44. package/registry/training/bad/http-errors-HISTORY.md +0 -186
  45. package/registry/training/bad/jose-LICENSE.md +0 -21
  46. package/registry/training/bad/jose-README.md +0 -153
  47. package/registry/training/bad/js-yaml-README.md +0 -299
  48. package/registry/training/bad/json-schema-typed-LICENSE.md +0 -57
  49. package/registry/training/bad/json-stringify-safe-CHANGELOG.md +0 -14
  50. package/registry/training/bad/lru-cache-LICENSE.md +0 -55
  51. package/registry/training/bad/media-typer-HISTORY.md +0 -50
  52. package/registry/training/bad/minimatch-LICENSE.md +0 -55
  53. package/registry/training/bad/minimist-CHANGELOG.md +0 -298
  54. package/registry/training/bad/minimist-README.md +0 -121
  55. package/registry/training/bad/ms-LICENSE.md +0 -21
  56. package/registry/training/bad/negotiator-HISTORY.md +0 -114
  57. package/registry/training/bad/on-finished-HISTORY.md +0 -98
  58. package/registry/training/bad/pkce-challenge-CHANGELOG.md +0 -114
  59. package/registry/training/bad/postcss-README.md +0 -28
  60. package/registry/training/bad/prebuild-install-CHANGELOG.md +0 -131
  61. package/registry/training/bad/proxy-addr-HISTORY.md +0 -161
  62. package/registry/training/bad/qs-CHANGELOG.md +0 -822
  63. package/registry/training/bad/rc-README.md +0 -227
  64. package/registry/training/bad/readable-stream-CONTRIBUTING.md +0 -38
  65. package/registry/training/bad/router-HISTORY.md +0 -228
  66. package/registry/training/bad/semver-README.md +0 -680
  67. package/registry/training/bad/send-README.md +0 -317
  68. package/registry/training/bad/serve-static-README.md +0 -253
  69. package/registry/training/bad/statuses-HISTORY.md +0 -87
  70. package/registry/training/bad/type-is-HISTORY.md +0 -292
  71. package/registry/training/bad/vary-HISTORY.md +0 -39
  72. package/registry/training/bad/vite-LICENSE.md +0 -2230
  73. package/registry/training/bad/which-CHANGELOG.md +0 -166
  74. package/registry/training/bad/zod-README.md +0 -191
  75. package/registry/training/good/skills-store-autopilot.md +0 -85
  76. package/registry/training/good/skills-store-bot-builder.md +0 -70
  77. package/registry/training/good/skills-store-chain.md +0 -136
  78. package/registry/training/good/skills-store-evolve.md +0 -100
  79. package/registry/training/good/skills-store-game.md +0 -27
  80. package/registry/training/good/skills-store-hunt.md +0 -102
  81. package/registry/training/good/skills-store-intel.md +0 -56
  82. package/registry/training/good/skills-store-memory-gc.md +0 -58
  83. package/registry/training/good/skills-store-pcsort.md +0 -207
  84. package/registry/training/good/skills-store-pickup.md +0 -60
  85. package/registry/training/good/skills-store-recon.md +0 -141
  86. package/registry/training/good/skills-store-remember.md +0 -64
  87. package/registry/training/good/skills-store-report.md +0 -117
  88. package/registry/training/good/skills-store-router.md +0 -225
  89. package/registry/training/good/skills-store-search.md +0 -168
  90. package/registry/training/good/skills-store-surface.md +0 -53
  91. package/registry/training/good/skills-store-token-scan.md +0 -141
  92. package/registry/training/good/skills-store-triage.md +0 -97
  93. package/registry/training/good/skills-store-unity.md +0 -733
  94. package/registry/training/good/skills-store-validate.md +0 -135
  95. package/registry/training/good/skills-store-web3-audit.md +0 -217
@@ -1,141 +0,0 @@
1
- ---
2
- name: recon
3
- description: Run full recon pipeline on a target — subdomain enum (Chaos API + subfinder), live host discovery (dnsx + httpx), URL crawl (katana + waybackurls + gau), gf pattern classification, nuclei scan. Outputs to recon/<target>/ directory. Usage: /recon target.com
4
- ---
5
-
6
- # /recon
7
-
8
- Run the full recon pipeline on a target and produce a prioritized attack surface.
9
-
10
- ## What This Does
11
-
12
- 1. Enumerates subdomains (Chaos API + subfinder + assetfinder)
13
- 2. Resolves DNS and finds live hosts (dnsx + httpx with status/title/tech)
14
- 3. Crawls URLs (katana deep crawl + waybackurls + gau historical)
15
- 4. Classifies URLs by bug class (gf patterns)
16
- 5. Runs nuclei for known CVEs and misconfigs
17
- 6. Outputs prioritized attack surface summary
18
-
19
- ## Usage
20
-
21
- ```
22
- /recon target.com
23
- ```
24
-
25
- Or with specific focus:
26
- ```
27
- /recon target.com --focus api
28
- /recon target.com --focus auth
29
- /recon target.com --fast (skip historical URLs)
30
- ```
31
-
32
- ## Steps
33
-
34
- ### Step 1: Subdomain Enumeration
35
-
36
- ```bash
37
- TARGET="$1"
38
- mkdir -p recon/$TARGET
39
-
40
- # Chaos API (ProjectDiscovery — most comprehensive)
41
- curl -s "https://dns.projectdiscovery.io/dns/$TARGET/subdomains" \
42
- -H "Authorization: $CHAOS_API_KEY" \
43
- | jq -r '.[]' > recon/$TARGET/subdomains.txt
44
-
45
- # subfinder + assetfinder
46
- subfinder -d $TARGET -silent | anew recon/$TARGET/subdomains.txt
47
- assetfinder --subs-only $TARGET | anew recon/$TARGET/subdomains.txt
48
-
49
- echo "[+] Subdomains: $(wc -l < recon/$TARGET/subdomains.txt)"
50
- ```
51
-
52
- ### Step 2: Live Host Discovery
53
-
54
- ```bash
55
- # DNS resolve + HTTP probe with tech detection
56
- cat recon/$TARGET/subdomains.txt \
57
- | dnsx -silent \
58
- | httpx -silent -status-code -title -tech-detect \
59
- | tee recon/$TARGET/live-hosts.txt
60
-
61
- echo "[+] Live hosts: $(wc -l < recon/$TARGET/live-hosts.txt)"
62
- ```
63
-
64
- ### Step 3: URL Crawl
65
-
66
- ```bash
67
- # Active crawl
68
- cat recon/$TARGET/live-hosts.txt | awk '{print $1}' \
69
- | katana -d 3 -jc -kf all -silent \
70
- | anew recon/$TARGET/urls.txt
71
-
72
- # Historical URLs
73
- echo $TARGET | waybackurls | anew recon/$TARGET/urls.txt
74
- gau $TARGET --subs | anew recon/$TARGET/urls.txt
75
-
76
- echo "[+] Total URLs: $(wc -l < recon/$TARGET/urls.txt)"
77
- ```
78
-
79
- ### Step 4: Classify URLs
80
-
81
- ```bash
82
- # Bug class classification
83
- cat recon/$TARGET/urls.txt | gf xss > recon/$TARGET/xss-candidates.txt
84
- cat recon/$TARGET/urls.txt | gf ssrf > recon/$TARGET/ssrf-candidates.txt
85
- cat recon/$TARGET/urls.txt | gf idor > recon/$TARGET/idor-candidates.txt
86
- cat recon/$TARGET/urls.txt | gf sqli > recon/$TARGET/sqli-candidates.txt
87
- cat recon/$TARGET/urls.txt | gf redirect > recon/$TARGET/redirect-candidates.txt
88
- cat recon/$TARGET/urls.txt | gf lfi > recon/$TARGET/lfi-candidates.txt
89
-
90
- # API endpoints
91
- cat recon/$TARGET/urls.txt | grep -E "/api/|/v1/|/v2/|/graphql|/rest/" \
92
- > recon/$TARGET/api-endpoints.txt
93
-
94
- echo "[+] IDOR candidates: $(wc -l < recon/$TARGET/idor-candidates.txt)"
95
- echo "[+] SSRF candidates: $(wc -l < recon/$TARGET/ssrf-candidates.txt)"
96
- echo "[+] API endpoints: $(wc -l < recon/$TARGET/api-endpoints.txt)"
97
- ```
98
-
99
- ### Step 5: Nuclei Scan
100
-
101
- ```bash
102
- nuclei -l recon/$TARGET/live-hosts.txt \
103
- -t ~/nuclei-templates/ \
104
- -severity critical,high,medium \
105
- -o recon/$TARGET/nuclei.txt
106
-
107
- echo "[+] Nuclei findings: $(wc -l < recon/$TARGET/nuclei.txt)"
108
- ```
109
-
110
- ## Output
111
-
112
- After running, you will have in `recon/<target>/`:
113
- ```
114
- subdomains.txt # All discovered subdomains
115
- live-hosts.txt # Live hosts with status/title/tech
116
- urls.txt # All crawled URLs
117
- api-endpoints.txt # API-specific paths
118
- idor-candidates.txt # URLs with ID parameters
119
- ssrf-candidates.txt # URLs with URL parameters
120
- xss-candidates.txt # URLs with reflection candidates
121
- nuclei.txt # Known CVE/misconfig findings
122
- ```
123
-
124
- ## What to Do Next
125
-
126
- 1. Review `live-hosts.txt` — open interesting ones in browser
127
- 2. Check `nuclei.txt` — any high/critical findings?
128
- 3. Review `api-endpoints.txt` — start IDOR testing
129
- 4. Check for admin panels: grep live-hosts for `/admin`, `/jenkins`, `/grafana`
130
- 5. Run `/hunt target.com` to start active vulnerability testing
131
-
132
- ## 5-Minute Rule
133
-
134
- If after running this pipeline:
135
- - All hosts return 403 or static pages
136
- - No API endpoints visible
137
- - No interesting parameters in URLs
138
- - nuclei returns 0 medium/high findings
139
-
140
- **→ Move on to a different target.**
141
-
@@ -1,64 +0,0 @@
1
- ---
2
- name: remember
3
- description: Log current finding or successful pattern to hunt memory. Auto-fills from /validate output if available. Usage: /remember
4
- ---
5
-
6
- # /remember
7
-
8
- Save a finding or successful pattern to persistent hunt memory.
9
-
10
- ## What This Does
11
-
12
- 1. Auto-populates fields from session context (target, endpoint, vuln_class, technique)
13
- 2. If `/validate` was run in this session, pre-fills from validation output
14
- 3. Prompts you to confirm or edit before saving
15
- 4. Writes to `journal.jsonl` (always) + `patterns.jsonl` (if confirmed + payout > 0)
16
- 5. Updates the target profile's `tested_endpoints` and `findings`
17
-
18
- ## Usage
19
-
20
- ```
21
- /remember # after finding something
22
- /remember --from-validate # explicitly pull from last /validate
23
- ```
24
-
25
- ## Interactive Flow
26
-
27
- ```
28
- REMEMBER — Log finding to hunt memory
29
-
30
- Target: target.com (auto-detected)
31
- Endpoint: /api/v2/users/{id}/orders (from session)
32
- Vuln Class: idor (from session)
33
- Technique: numeric_id_swap_with_put_method
34
-
35
- Result: [confirmed / rejected / partial / informational]?
36
- Severity: [critical / high / medium / low]?
37
- Payout: $___?
38
- Notes: ___?
39
- Tags: [comma-separated]?
40
-
41
- Save to hunt memory? [y/n]
42
- ```
43
-
44
- ## Minimum Required Fields
45
-
46
- - target
47
- - vuln_class
48
- - endpoint
49
- - result
50
-
51
- ## What Gets Written
52
-
53
- | Field | journal.jsonl | patterns.jsonl | target profile |
54
- |---|---|---|---|
55
- | Finding details | Always | If confirmed + payout > 0 | findings[] updated |
56
- | Tested endpoint | — | — | tested_endpoints[] updated |
57
- | Tech stack | — | From target profile | — |
58
-
59
- ## Why This Matters
60
-
61
- - Next time you hunt a target with similar tech stack, your successful patterns are suggested first
62
- - `/pickup target.com` shows which endpoints you've tested and which remain
63
- - Cross-target learning: patterns from target A inform hunting on target B
64
-
@@ -1,117 +0,0 @@
1
- ---
2
- name: report
3
- description: Write a submission-ready bug bounty report. Generates H1/Bugcrowd/Intigriti/Immunefi format with CVSS 3.1 score, proof of concept, impact statement, and remediation. Run /validate first. Usage: /report
4
- ---
5
-
6
- # /report
7
-
8
- Generate a submission-ready bug bounty report.
9
-
10
- ## Pre-Conditions
11
-
12
- Run `/validate` first. All 4 gates must pass before running this command.
13
-
14
- Never write a report before validating. N/A submissions hurt your validity ratio.
15
-
16
- ## Usage
17
-
18
- ```
19
- /report
20
- ```
21
-
22
- Provide when prompted:
23
- - Platform (HackerOne / Bugcrowd / Intigriti / Immunefi)
24
- - Bug class
25
- - Affected endpoint
26
- - Your two test accounts and their IDs
27
- - The exact HTTP request that demonstrates the bug
28
- - The exact response that shows the impact
29
- - Tech stack (for CVSS and remediation advice)
30
-
31
- ## What This Generates
32
-
33
- 1. Title following the formula: `[Bug Class] in [Endpoint] allows [actor] to [impact]`
34
- 2. Summary paragraph (impact-first, no "could potentially")
35
- 3. Vulnerability details with CVSS 3.1 score and vector string
36
- 4. Steps to Reproduce with copy-paste HTTP requests
37
- 5. Impact statement with quantification
38
- 6. Recommended fix (1-2 sentences, specific)
39
- 7. Supporting materials section
40
-
41
- ## Platform Selection
42
-
43
- ### HackerOne Format
44
- - Markdown sections: Summary, Vulnerability Details, Steps to Reproduce, Impact, Recommended Fix
45
- - Include CVSS 3.1 score + vector string
46
- - Include two test account setup instructions
47
- - Keep under 600 words
48
-
49
- ### Bugcrowd Format
50
- - Title with VRT category: `[VRT Category] > [Subcategory] > P[1-4]`
51
- - Expected vs Actual Behavior section
52
- - Severity Justification section referencing Bugcrowd VRT
53
-
54
- ### Intigriti Format
55
- - CVSS score prominent at top
56
- - Clear reproduction steps
57
- - Business impact focused
58
-
59
- ### Immunefi Format (Web3)
60
- - Root cause in Solidity code
61
- - Foundry PoC test included
62
- - Economic impact quantified in $ value
63
- - Comparison evidence (same check present elsewhere, missing here)
64
-
65
- ## Writing Rules
66
-
67
- 1. **Never use:** "could potentially", "may allow", "might be possible"
68
- 2. **Always prove:** show actual data/action, not just "200 OK"
69
- 3. **Impact first:** sentence 1 = what attacker gets, not what the bug is
70
- 4. **Quantify:** how many users affected, what data type, $ amount
71
- 5. **Short:** triagers skim. < 600 words.
72
- 6. **Human:** write to a person, not a system
73
-
74
- ## CVSS 3.1 Calculation Guide
75
-
76
- Common patterns:
77
- ```
78
- IDOR read PII (any user, auth needed):
79
- → AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N = 6.5 Medium
80
-
81
- Auth bypass → admin (no auth):
82
- → AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H = 9.8 Critical
83
-
84
- SSRF → cloud metadata:
85
- → AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N = 9.1 Critical
86
-
87
- Stored XSS (any user, scope changed):
88
- → AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:N = 8.2 High
89
- ```
90
-
91
- ## Escalation Language
92
-
93
- Use when payout is being downgraded:
94
- ```
95
- "This requires only a free account — no special privileges."
96
- "The exposed data includes [PII type], subject to GDPR/CCPA requirements."
97
- "An attacker can automate this — all [N] records in [X] minutes with a simple loop."
98
- "This is exploitable externally without any internal network access."
99
- "The impact is equivalent to a full data breach of [feature/data type]."
100
- ```
101
-
102
- ## Final Checklist Before Submitting
103
-
104
- ```
105
- [ ] Title follows formula
106
- [ ] First sentence states exact impact
107
- [ ] HTTP request is copy-pasteable
108
- [ ] Response showing impact included
109
- [ ] Two accounts used (not self-testing)
110
- [ ] CVSS calculated and included
111
- [ ] Fix: 1-2 sentences
112
- [ ] No typos in endpoint/param names
113
- [ ] Under 600 words
114
- [ ] Severity matches impact (no overclaiming)
115
- [ ] NEVER used "could potentially"
116
- ```
117
-
@@ -1,225 +0,0 @@
1
- # Router Configurator — OpenWRT
2
- Activated by: `/router`
3
-
4
- You are the cognitive core of the OpenWRT Router Configurator. OpenCode agents are execution workers. You reason, plan, and decide. Agents read state, generate UCI commands, and validate. You commit nothing without seeing the exact commands first.
5
-
6
- ---
7
-
8
- ## System Rules
9
-
10
- 1. **SSH-first:** every router interaction goes through `ssh root@<ip>`. Never edit config files directly — use UCI.
11
- 2. **UCI-only:** always `uci set / uci commit`, never `vi /etc/config/*`.
12
- 3. **Dry-run default:** generate all UCI commands, show them to the user, get explicit confirmation before running a single one.
13
- 4. **Backup before risk:** any operation that touches networking topology, firewall defaults, or firmware MUST create a backup first.
14
- 5. **Never break SSH access:** firewall rules must never block port 22 (or the configured SSH port) from the management interface.
15
- 6. **Single OpenCode CLI:** one `opencode-cli run` process; parallel work via Task subagents inside unity-orchestrator.
16
- 7. **State file:** `.router-state/ROUTER_STATE.json` — router-state-reader is sole writer.
17
-
18
- Default SSH target: `root@192.168.1.1` — ask user if not provided.
19
-
20
- ---
21
-
22
- ## Router State Schema (`.router-state/ROUTER_STATE.json`)
23
-
24
- ```json
25
- {
26
- "router": { "ip": "", "model": "", "firmware": "", "arch": "", "uptime": "" },
27
- "network": {
28
- "interfaces": {},
29
- "routes": [],
30
- "vlans": []
31
- },
32
- "wireless": { "radios": [], "ifaces": [] },
33
- "firewall": { "zones": [], "rules": [], "redirects": [], "defaults": {} },
34
- "dhcp": { "config": {}, "static_leases": [], "leases": [] },
35
- "system": { "hostname": "", "timezone": "", "ntp": [] },
36
- "packages": { "installed": [], "pending_updates": [] },
37
- "lastRead": ""
38
- }
39
- ```
40
-
41
- ---
42
-
43
- ## Phase 0: Intent Recognition
44
-
45
- Classify user request:
46
-
47
- | Intent | Examples | Risk |
48
- |--------|----------|------|
49
- | `read` | "show config", "what's my IP", "list devices" | NONE |
50
- | `network` | "add VLAN", "change LAN IP", "set static IP" | MEDIUM |
51
- | `wireless` | "change WiFi password", "add guest network" | LOW |
52
- | `firewall` | "allow port", "block IP", "port forward" | MEDIUM |
53
- | `dhcp` | "reserve IP", "change DHCP range" | LOW |
54
- | `package` | "install luci-app-*", "remove package" | LOW |
55
- | `system` | "change hostname", "set timezone" | LOW |
56
- | `backup` | "backup config", "restore backup" | LOW |
57
- | `firmware` | "update firmware", "sysupgrade" | HIGH — always confirm twice |
58
- | `vpn` | "setup WireGuard", "setup OpenVPN" | HIGH |
59
-
60
- Clarify router IP if not given. Proceed only after intent is clear.
61
-
62
- ---
63
-
64
- ## Phase 1: Read Router State
65
-
66
- ```bash
67
- opencode-cli run --attach http://localhost:4100 --agent router-state-reader \
68
- "SSH to <ip> as root and read complete OpenWRT router state. Read: uci show network, uci show wireless, uci show firewall, uci show dhcp, uci show system, cat /etc/openwrt_release, opkg list-installed. Write state to .router-state/ROUTER_STATE.json. Do NOT use the Task tool."
69
- ```
70
-
71
- Read `.router-state/ROUTER_STATE.json`. This is your ground truth for the session.
72
-
73
- For `read` intent → skip Phase 2-4, summarize state directly for user.
74
-
75
- ---
76
-
77
- ## Phase 2: Plan Configuration
78
-
79
- ### Network / VLAN changes:
80
- ```bash
81
- opencode-cli run --attach http://localhost:4100 --agent uci-configurator \
82
- "Plan UCI commands for: <change description>. Read .router-state/ROUTER_STATE.json for current state. Output exact UCI commands in order. Do NOT execute. Do NOT use the Task tool."
83
- ```
84
-
85
- ### Firewall changes:
86
- ```bash
87
- opencode-cli run --attach http://localhost:4100 --agent firewall-builder \
88
- "Plan firewall rule for: <rule description>. Read .router-state/ROUTER_STATE.json. Output exact UCI commands and verify no rule blocks SSH on management zone. Do NOT execute. Do NOT use the Task tool."
89
- ```
90
-
91
- ### Package operations:
92
- ```bash
93
- opencode-cli run --attach http://localhost:4100 --agent opkg-manager \
94
- "Plan opkg commands for: <operation>. Read .router-state/ROUTER_STATE.json for installed packages. Output exact commands. Do NOT execute. Do NOT use the Task tool."
95
- ```
96
-
97
- ---
98
-
99
- ## Phase 3: Validate Plan
100
-
101
- ```bash
102
- opencode-cli run --attach http://localhost:4100 --agent router-validator \
103
- "Validate these UCI commands against current router state in .router-state/ROUTER_STATE.json: <commands>. Check for: SSH lockout risk, conflicting IP ranges, invalid UCI paths, missing commit steps, service restart requirements. Output APPROVED or BLOCKED with reasons. Do NOT use the Task tool."
104
- ```
105
-
106
- If BLOCKED → revise plan and re-validate. Do not proceed until APPROVED.
107
-
108
- ---
109
-
110
- ## Phase 4: Show Plan and Confirm
111
-
112
- Present to user:
113
- ```
114
- ## Router Change Plan
115
- Target: root@<ip>
116
-
117
- ### Commands to execute:
118
- 1. ssh root@<ip> "uci set <key>=<value>"
119
- 2. ssh root@<ip> "uci commit <config>"
120
- 3. ssh root@<ip> "/etc/init.d/<service> restart"
121
-
122
- ### Risk level: LOW|MEDIUM|HIGH
123
- ### Services that will restart: <list>
124
- ### Estimated downtime: <duration or "none">
125
-
126
- Type CONFIRM to proceed or CANCEL to abort.
127
- ```
128
-
129
- **Do not execute until user types CONFIRM.**
130
-
131
- For HIGH risk: require the user to type the exact IP address as confirmation.
132
-
133
- ---
134
-
135
- ## Phase 5: Execute
136
-
137
- If confirmed — execute via Bash tool directly (not through agent, for reliability):
138
-
139
- ```bash
140
- ssh root@<ip> "uci set <key>=<value> && uci commit <config> && /etc/init.d/<service> restart"
141
- ```
142
-
143
- Execute one logical group at a time. Check exit code after each group.
144
-
145
- For firmware upgrade:
146
- ```bash
147
- # First backup
148
- ssh root@<ip> "sysupgrade -b /tmp/backup-$(date +%Y%m%d).tar.gz"
149
- scp root@<ip>:/tmp/backup-*.tar.gz ./
150
-
151
- # Then upgrade (user must confirm image path)
152
- scp <firmware.bin> root@<ip>:/tmp/
153
- ssh root@<ip> "sysupgrade /tmp/<firmware.bin>"
154
- ```
155
-
156
- ---
157
-
158
- ## Phase 6: Verify
159
-
160
- After execution:
161
- 1. Ping router to confirm reachability: `ping -n 2 <ip>`
162
- 2. Re-read state: re-run router-state-reader
163
- 3. Confirm the changed values match expected values
164
- 4. Report result to user
165
-
166
- If router unreachable after changes → guide user through recovery (console access, failsafe mode: press reset during boot).
167
-
168
- ---
169
-
170
- ## Agent Routing Table
171
-
172
- | Agent | Use for |
173
- |-------|---------|
174
- | `router-state-reader` | Reading all UCI state, package list, system info |
175
- | `uci-configurator` | Network, wireless, DHCP, system UCI command generation |
176
- | `firewall-builder` | Firewall rules, port forwards, traffic shaping rules |
177
- | `opkg-manager` | Package install/remove/update planning |
178
- | `router-validator` | Pre-execution validation of any UCI command set |
179
-
180
- ---
181
-
182
- ## Common Operation Templates
183
-
184
- ### Port forwarding (DNAT):
185
- ```
186
- uci add firewall redirect
187
- uci set firewall.@redirect[-1].name='<name>'
188
- uci set firewall.@redirect[-1].target='DNAT'
189
- uci set firewall.@redirect[-1].src='wan'
190
- uci set firewall.@redirect[-1].src_dport='<external_port>'
191
- uci set firewall.@redirect[-1].dest='lan'
192
- uci set firewall.@redirect[-1].dest_ip='<internal_ip>'
193
- uci set firewall.@redirect[-1].dest_port='<internal_port>'
194
- uci set firewall.@redirect[-1].proto='tcp udp'
195
- uci commit firewall
196
- /etc/init.d/firewall restart
197
- ```
198
-
199
- ### Guest WiFi VLAN:
200
- Requires: new wifi-iface → new network interface → new firewall zone → forwarding rules allowing WAN but blocking LAN.
201
-
202
- ### WireGuard VPN:
203
- Requires: `opkg install wireguard-tools kmod-wireguard luci-app-wireguard` → interface config → peer config → firewall zone.
204
-
205
- ### Static DHCP lease:
206
- ```
207
- uci add dhcp host
208
- uci set dhcp.@host[-1].name='<hostname>'
209
- uci set dhcp.@host[-1].mac='<MAC>'
210
- uci set dhcp.@host[-1].ip='<ip>'
211
- uci commit dhcp
212
- /etc/init.d/dnsmasq restart
213
- ```
214
-
215
- ---
216
-
217
- ## Core Rules (never violate)
218
-
219
- 1. Show commands before executing — always.
220
- 2. Never block SSH from LAN to router.
221
- 3. Backup before firmware upgrade — always.
222
- 4. `uci commit` must follow every `uci set` block for the same config.
223
- 5. Service restart must follow commit for changes to take effect.
224
- 6. For unknown UCI paths → read `uci show <config>` first, never guess.
225
-