mindforge-cc 11.5.1 → 11.7.0

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 (214) hide show
  1. package/.agent/mindforge/skill-tdd.md +53 -0
  2. package/.agent/mindforge/skills-index.md +118 -0
  3. package/.agent/mindforge/systematic-debug.md +60 -0
  4. package/.agent/mindforge/wf-catalog.md +37 -0
  5. package/.agent/mindforge/wf-code-audit.md +31 -0
  6. package/.agent/mindforge/wf-competitive-analysis.md +31 -0
  7. package/.agent/mindforge/wf-deep-research.md +32 -0
  8. package/.agent/mindforge/wf-feature-planner.md +31 -0
  9. package/.agent/mindforge/wf-incident-response.md +31 -0
  10. package/.agent/mindforge/wf-onboard-codebase.md +31 -0
  11. package/.agent/mindforge/wf-perf-optimize.md +31 -0
  12. package/.agent/mindforge/wf-pr-review.md +31 -0
  13. package/.agent/mindforge/wf-refactor-plan.md +31 -0
  14. package/.agent/mindforge/wf-release-prep.md +31 -0
  15. package/.agent/mindforge/wf-tdd-sprint.md +31 -0
  16. package/.agent/mindforge/wf-tech-evaluation.md +31 -0
  17. package/.agent/skills/1password-skill/SKILL.md +156 -0
  18. package/.agent/skills/1password-skill/references/cli-examples.md +31 -0
  19. package/.agent/skills/1password-skill/references/get-started.md +21 -0
  20. package/.agent/skills/article-illustrator/SKILL.md +199 -0
  21. package/.agent/skills/article-illustrator/references/prompt-construction.md +426 -0
  22. package/.agent/skills/article-illustrator/references/style-presets.md +80 -0
  23. package/.agent/skills/article-illustrator/references/styles.md +224 -0
  24. package/.agent/skills/article-illustrator/references/usage.md +50 -0
  25. package/.agent/skills/article-illustrator/references/workflow.md +332 -0
  26. package/.agent/skills/arxiv/SKILL.md +275 -0
  27. package/.agent/skills/blogwatcher/SKILL.md +130 -0
  28. package/.agent/skills/code-wiki/SKILL.md +438 -0
  29. package/.agent/skills/code-wiki/templates/README.md +31 -0
  30. package/.agent/skills/code-wiki/templates/architecture.md +30 -0
  31. package/.agent/skills/code-wiki/templates/getting-started.md +47 -0
  32. package/.agent/skills/code-wiki/templates/module.md +38 -0
  33. package/.agent/skills/codebase-inspection/SKILL.md +109 -0
  34. package/.agent/skills/comic-creator/SKILL.md +240 -0
  35. package/.agent/skills/comic-creator/references/analysis-framework.md +176 -0
  36. package/.agent/skills/comic-creator/references/auto-selection.md +71 -0
  37. package/.agent/skills/comic-creator/references/base-prompt.md +98 -0
  38. package/.agent/skills/comic-creator/references/character-template.md +180 -0
  39. package/.agent/skills/comic-creator/references/ohmsha-guide.md +85 -0
  40. package/.agent/skills/comic-creator/references/partial-workflows.md +106 -0
  41. package/.agent/skills/comic-creator/references/storyboard-template.md +143 -0
  42. package/.agent/skills/comic-creator/references/workflow.md +401 -0
  43. package/.agent/skills/concept-diagrams/SKILL.md +355 -0
  44. package/.agent/skills/concept-diagrams/references/dashboard-patterns.md +43 -0
  45. package/.agent/skills/concept-diagrams/references/infrastructure-patterns.md +144 -0
  46. package/.agent/skills/concept-diagrams/references/physical-shape-cookbook.md +42 -0
  47. package/.agent/skills/creative-ideation/SKILL.md +144 -0
  48. package/.agent/skills/creative-ideation/references/full-prompt-library.md +110 -0
  49. package/.agent/skills/devops-cli/SKILL.md +149 -0
  50. package/.agent/skills/devops-cli/references/app-discovery.md +112 -0
  51. package/.agent/skills/devops-cli/references/authentication.md +59 -0
  52. package/.agent/skills/devops-cli/references/cli-reference.md +104 -0
  53. package/.agent/skills/devops-cli/references/running-apps.md +171 -0
  54. package/.agent/skills/devops-watchers/SKILL.md +103 -0
  55. package/.agent/skills/docker-management/SKILL.md +273 -0
  56. package/.agent/skills/domain-intel/SKILL.md +96 -0
  57. package/.agent/skills/duckduckgo-search/SKILL.md +230 -0
  58. package/.agent/skills/github-auth/SKILL.md +240 -0
  59. package/.agent/skills/github-code-review/SKILL.md +474 -0
  60. package/.agent/skills/github-code-review/references/review-output-template.md +74 -0
  61. package/.agent/skills/github-issues/SKILL.md +363 -0
  62. package/.agent/skills/github-issues/templates/bug-report.md +35 -0
  63. package/.agent/skills/github-issues/templates/feature-request.md +31 -0
  64. package/.agent/skills/github-pr-workflow/SKILL.md +360 -0
  65. package/.agent/skills/github-pr-workflow/references/ci-troubleshooting.md +183 -0
  66. package/.agent/skills/github-pr-workflow/references/conventional-commits.md +71 -0
  67. package/.agent/skills/github-pr-workflow/templates/pr-body-bugfix.md +35 -0
  68. package/.agent/skills/github-pr-workflow/templates/pr-body-feature.md +33 -0
  69. package/.agent/skills/github-repo-management/SKILL.md +509 -0
  70. package/.agent/skills/github-repo-management/references/github-api-cheatsheet.md +161 -0
  71. package/.agent/skills/godmode/SKILL.md +396 -0
  72. package/.agent/skills/godmode/references/jailbreak-templates.md +128 -0
  73. package/.agent/skills/godmode/references/refusal-detection.md +142 -0
  74. package/.agent/skills/hyperframes/SKILL.md +182 -0
  75. package/.agent/skills/hyperframes/references/cli.md +185 -0
  76. package/.agent/skills/hyperframes/references/composition.md +129 -0
  77. package/.agent/skills/hyperframes/references/features.md +289 -0
  78. package/.agent/skills/hyperframes/references/gsap.md +136 -0
  79. package/.agent/skills/hyperframes/references/troubleshooting.md +137 -0
  80. package/.agent/skills/hyperframes/references/website-to-video.md +145 -0
  81. package/.agent/skills/jupyter-live-kernel/SKILL.md +160 -0
  82. package/.agent/skills/kanban-orchestrator/SKILL.md +209 -0
  83. package/.agent/skills/kanban-worker/SKILL.md +188 -0
  84. package/.agent/skills/llm-wiki/SKILL.md +499 -0
  85. package/.agent/skills/meme-generation/SKILL.md +122 -0
  86. package/.agent/skills/node-inspect-debugger/SKILL.md +312 -0
  87. package/.agent/skills/obsidian/SKILL.md +60 -0
  88. package/.agent/skills/osint-investigation/SKILL.md +269 -0
  89. package/.agent/skills/osint-investigation/templates/source-template.md +59 -0
  90. package/.agent/skills/oss-forensics/SKILL.md +422 -0
  91. package/.agent/skills/oss-forensics/references/evidence-types.md +89 -0
  92. package/.agent/skills/oss-forensics/references/github-archive-guide.md +184 -0
  93. package/.agent/skills/oss-forensics/references/investigation-templates.md +131 -0
  94. package/.agent/skills/oss-forensics/references/recovery-techniques.md +164 -0
  95. package/.agent/skills/oss-forensics/templates/forensic-report.md +151 -0
  96. package/.agent/skills/oss-forensics/templates/malicious-package-report.md +43 -0
  97. package/.agent/skills/parallel-cli/SKILL.md +384 -0
  98. package/.agent/skills/pinggy-tunnel/SKILL.md +302 -0
  99. package/.agent/skills/pixel-art/SKILL.md +209 -0
  100. package/.agent/skills/pixel-art/references/palettes.md +49 -0
  101. package/.agent/skills/plan/SKILL.md +331 -0
  102. package/.agent/skills/polymarket/SKILL.md +75 -0
  103. package/.agent/skills/polymarket/references/api-endpoints.md +220 -0
  104. package/.agent/skills/python-debugpy/SKILL.md +368 -0
  105. package/.agent/skills/requesting-code-review/SKILL.md +273 -0
  106. package/.agent/skills/research-paper-writing/SKILL.md +2367 -0
  107. package/.agent/skills/research-paper-writing/references/autoreason-methodology.md +394 -0
  108. package/.agent/skills/research-paper-writing/references/checklists.md +434 -0
  109. package/.agent/skills/research-paper-writing/references/citation-workflow.md +563 -0
  110. package/.agent/skills/research-paper-writing/references/experiment-patterns.md +728 -0
  111. package/.agent/skills/research-paper-writing/references/human-evaluation.md +476 -0
  112. package/.agent/skills/research-paper-writing/references/paper-types.md +481 -0
  113. package/.agent/skills/research-paper-writing/references/reviewer-guidelines.md +433 -0
  114. package/.agent/skills/research-paper-writing/references/sources.md +191 -0
  115. package/.agent/skills/research-paper-writing/references/writing-guide.md +474 -0
  116. package/.agent/skills/research-paper-writing/templates/README.md +251 -0
  117. package/.agent/skills/rest-graphql-debug/SKILL.md +507 -0
  118. package/.agent/skills/s6-container-supervision/SKILL.md +171 -0
  119. package/.agent/skills/scrapling/SKILL.md +328 -0
  120. package/.agent/skills/sherlock/SKILL.md +186 -0
  121. package/.agent/skills/simplify-code/SKILL.md +168 -0
  122. package/.agent/skills/skill-authoring/SKILL.md +158 -0
  123. package/.agent/skills/spike/SKILL.md +190 -0
  124. package/.agent/skills/subagent-driven-development/SKILL.md +345 -0
  125. package/.agent/skills/subagent-driven-development/references/context-budget-discipline.md +53 -0
  126. package/.agent/skills/subagent-driven-development/references/gates-taxonomy.md +93 -0
  127. package/.agent/skills/systematic-debugging/SKILL.md +360 -0
  128. package/.agent/skills/test-driven-development/SKILL.md +336 -0
  129. package/.agent/skills/video-orchestrator/SKILL.md +194 -0
  130. package/.agent/skills/video-orchestrator/references/examples.md +227 -0
  131. package/.agent/skills/video-orchestrator/references/intake.md +166 -0
  132. package/.agent/skills/video-orchestrator/references/kanban-setup.md +278 -0
  133. package/.agent/skills/video-orchestrator/references/monitoring.md +180 -0
  134. package/.agent/skills/video-orchestrator/references/role-archetypes.md +298 -0
  135. package/.agent/skills/video-orchestrator/references/tool-matrix.md +317 -0
  136. package/.agent/skills/web-pentest/SKILL.md +332 -0
  137. package/.agent/skills/web-pentest/references/bypass-techniques.md +133 -0
  138. package/.agent/skills/web-pentest/references/exploitation-techniques.md +204 -0
  139. package/.agent/skills/web-pentest/references/scope-enforcement.md +110 -0
  140. package/.agent/skills/web-pentest/references/vuln-taxonomy.md +81 -0
  141. package/.agent/skills/web-pentest/templates/authorization.md +69 -0
  142. package/.agent/skills/web-pentest/templates/pentest-report.md +178 -0
  143. package/.claude/commands/mindforge/skill-tdd.md +53 -0
  144. package/.claude/commands/mindforge/skills-index.md +118 -0
  145. package/.claude/commands/mindforge/systematic-debug.md +60 -0
  146. package/.claude/commands/mindforge/wf-catalog.md +37 -0
  147. package/.claude/commands/mindforge/wf-code-audit.md +31 -0
  148. package/.claude/commands/mindforge/wf-competitive-analysis.md +31 -0
  149. package/.claude/commands/mindforge/wf-deep-research.md +32 -0
  150. package/.claude/commands/mindforge/wf-feature-planner.md +31 -0
  151. package/.claude/commands/mindforge/wf-incident-response.md +31 -0
  152. package/.claude/commands/mindforge/wf-onboard-codebase.md +31 -0
  153. package/.claude/commands/mindforge/wf-perf-optimize.md +31 -0
  154. package/.claude/commands/mindforge/wf-pr-review.md +31 -0
  155. package/.claude/commands/mindforge/wf-refactor-plan.md +31 -0
  156. package/.claude/commands/mindforge/wf-release-prep.md +31 -0
  157. package/.claude/commands/mindforge/wf-tdd-sprint.md +31 -0
  158. package/.claude/commands/mindforge/wf-tech-evaluation.md +31 -0
  159. package/.mindforge/config.json +2 -2
  160. package/.mindforge/dynamic-workflows/REGISTRY.md +65 -0
  161. package/.mindforge/dynamic-workflows/index.json +171 -0
  162. package/.mindforge/dynamic-workflows/scripts/code-audit.js +103 -0
  163. package/.mindforge/dynamic-workflows/scripts/competitive-analysis.js +85 -0
  164. package/.mindforge/dynamic-workflows/scripts/deep-research.js +151 -0
  165. package/.mindforge/dynamic-workflows/scripts/feature-planner.js +104 -0
  166. package/.mindforge/dynamic-workflows/scripts/incident-response.js +106 -0
  167. package/.mindforge/dynamic-workflows/scripts/onboard-codebase.js +102 -0
  168. package/.mindforge/dynamic-workflows/scripts/perf-optimize.js +128 -0
  169. package/.mindforge/dynamic-workflows/scripts/pr-review.js +87 -0
  170. package/.mindforge/dynamic-workflows/scripts/refactor-plan.js +121 -0
  171. package/.mindforge/dynamic-workflows/scripts/release-prep.js +102 -0
  172. package/.mindforge/dynamic-workflows/scripts/tdd-sprint.js +103 -0
  173. package/.mindforge/dynamic-workflows/scripts/tech-evaluation.js +72 -0
  174. package/.mindforge/memory/sync-manifest.json +1 -1
  175. package/.mindforge/skills/arxiv/SKILL.md +294 -0
  176. package/.mindforge/skills/blogwatcher/SKILL.md +147 -0
  177. package/.mindforge/skills/code-wiki/SKILL.md +457 -0
  178. package/.mindforge/skills/codebase-inspection/SKILL.md +126 -0
  179. package/.mindforge/skills/concept-diagrams/SKILL.md +373 -0
  180. package/.mindforge/skills/creative-ideation/SKILL.md +162 -0
  181. package/.mindforge/skills/domain-intel/SKILL.md +116 -0
  182. package/.mindforge/skills/duckduckgo-search/SKILL.md +249 -0
  183. package/.mindforge/skills/github-code-review/SKILL.md +493 -0
  184. package/.mindforge/skills/github-issues/SKILL.md +382 -0
  185. package/.mindforge/skills/github-pr-workflow/SKILL.md +379 -0
  186. package/.mindforge/skills/jupyter-live-kernel/SKILL.md +179 -0
  187. package/.mindforge/skills/kanban-orchestrator/SKILL.md +227 -0
  188. package/.mindforge/skills/kanban-worker/SKILL.md +206 -0
  189. package/.mindforge/skills/meme-generation/SKILL.md +141 -0
  190. package/.mindforge/skills/obsidian/SKILL.md +80 -0
  191. package/.mindforge/skills/osint-investigation/SKILL.md +288 -0
  192. package/.mindforge/skills/oss-forensics/SKILL.md +421 -0
  193. package/.mindforge/skills/pixel-art/SKILL.md +228 -0
  194. package/.mindforge/skills/plan/SKILL.md +350 -0
  195. package/.mindforge/skills/requesting-code-review/SKILL.md +292 -0
  196. package/.mindforge/skills/research-paper-writing/SKILL.md +2384 -0
  197. package/.mindforge/skills/scrapling/SKILL.md +345 -0
  198. package/.mindforge/skills/sherlock/SKILL.md +203 -0
  199. package/.mindforge/skills/simplify-code/SKILL.md +187 -0
  200. package/.mindforge/skills/spike/SKILL.md +209 -0
  201. package/.mindforge/skills/subagent-driven-development/SKILL.md +364 -0
  202. package/.mindforge/skills/systematic-debugging/SKILL.md +379 -0
  203. package/.mindforge/skills/test-driven-development/SKILL.md +355 -0
  204. package/.mindforge/skills/web-pentest/SKILL.md +327 -0
  205. package/CHANGELOG.md +71 -0
  206. package/MINDFORGE.md +2 -2
  207. package/README.md +72 -3
  208. package/RELEASENOTES.md +109 -0
  209. package/bin/installer-core.js +6 -2
  210. package/bin/mindforge-cli.js +7 -0
  211. package/bin/workflows/workflow-runner.js +110 -0
  212. package/docs/commands-reference.md +25 -0
  213. package/docs/getting-started.md +42 -5
  214. package/package.json +2 -1
@@ -0,0 +1,220 @@
1
+ # Polymarket API Endpoints Reference
2
+
3
+ All endpoints are public REST (GET), return JSON, and need no authentication.
4
+
5
+ ## Gamma API — gamma-api.polymarket.com
6
+
7
+ ### Search Markets
8
+
9
+ ```
10
+ GET /public-search?q=QUERY
11
+ ```
12
+
13
+ Response structure:
14
+ ```json
15
+ {
16
+ "events": [
17
+ {
18
+ "id": "12345",
19
+ "title": "Event title",
20
+ "slug": "event-slug",
21
+ "volume": 1234567.89,
22
+ "markets": [
23
+ {
24
+ "question": "Will X happen?",
25
+ "outcomePrices": "[\"0.65\", \"0.35\"]",
26
+ "outcomes": "[\"Yes\", \"No\"]",
27
+ "clobTokenIds": "[\"TOKEN_YES\", \"TOKEN_NO\"]",
28
+ "conditionId": "0xabc...",
29
+ "volume": 500000
30
+ }
31
+ ]
32
+ }
33
+ ],
34
+ "pagination": {"hasMore": true, "totalResults": 100}
35
+ }
36
+ ```
37
+
38
+ ### List Events
39
+
40
+ ```
41
+ GET /events?limit=N&active=true&closed=false&order=volume&ascending=false
42
+ ```
43
+
44
+ Parameters:
45
+ - `limit` — max results (default varies)
46
+ - `offset` — pagination offset
47
+ - `active` — true/false
48
+ - `closed` — true/false
49
+ - `order` — sort field: `volume`, `createdAt`, `updatedAt`
50
+ - `ascending` — true/false
51
+ - `tag` — filter by tag slug
52
+ - `slug` — get specific event by slug
53
+
54
+ Response: array of event objects. Each event includes a `markets` array.
55
+
56
+ Event fields: `id`, `title`, `slug`, `description`, `volume`, `liquidity`,
57
+ `openInterest`, `active`, `closed`, `category`, `startDate`, `endDate`,
58
+ `markets` (array of market objects).
59
+
60
+ ### List Markets
61
+
62
+ ```
63
+ GET /markets?limit=N&active=true&closed=false&order=volume&ascending=false
64
+ ```
65
+
66
+ Same filter parameters as events, plus:
67
+ - `slug` — get specific market by slug
68
+
69
+ Market fields: `id`, `question`, `conditionId`, `slug`, `description`,
70
+ `outcomes`, `outcomePrices`, `volume`, `liquidity`, `active`, `closed`,
71
+ `marketType`, `clobTokenIds`, `endDate`, `category`, `createdAt`.
72
+
73
+ Important: `outcomePrices`, `outcomes`, and `clobTokenIds` are JSON strings
74
+ (double-encoded). Parse with json.loads() in Python.
75
+
76
+ ### List Tags
77
+
78
+ ```
79
+ GET /tags
80
+ ```
81
+
82
+ Returns array of tag objects: `id`, `label`, `slug`.
83
+ Use the `slug` value when filtering events/markets by tag.
84
+
85
+ ---
86
+
87
+ ## CLOB API — clob.polymarket.com
88
+
89
+ All CLOB price endpoints use `token_id` from the market's `clobTokenIds` field.
90
+ Index 0 = Yes outcome, Index 1 = No outcome.
91
+
92
+ ### Current Price
93
+
94
+ ```
95
+ GET /price?token_id=TOKEN_ID&side=buy
96
+ ```
97
+
98
+ Response: `{"price": "0.650"}`
99
+
100
+ The `side` parameter: `buy` or `sell`.
101
+
102
+ ### Midpoint Price
103
+
104
+ ```
105
+ GET /midpoint?token_id=TOKEN_ID
106
+ ```
107
+
108
+ Response: `{"mid": "0.645"}`
109
+
110
+ ### Spread
111
+
112
+ ```
113
+ GET /spread?token_id=TOKEN_ID
114
+ ```
115
+
116
+ Response: `{"spread": "0.02"}`
117
+
118
+ ### Orderbook
119
+
120
+ ```
121
+ GET /book?token_id=TOKEN_ID
122
+ ```
123
+
124
+ Response:
125
+ ```json
126
+ {
127
+ "market": "condition_id",
128
+ "asset_id": "token_id",
129
+ "bids": [{"price": "0.64", "size": "500"}, ...],
130
+ "asks": [{"price": "0.66", "size": "300"}, ...],
131
+ "min_order_size": "5",
132
+ "tick_size": "0.01",
133
+ "last_trade_price": "0.65"
134
+ }
135
+ ```
136
+
137
+ Bids and asks are sorted by price. Size is in shares (USDC-denominated).
138
+
139
+ ### Price History
140
+
141
+ ```
142
+ GET /prices-history?market=CONDITION_ID&interval=INTERVAL&fidelity=N
143
+ ```
144
+
145
+ Parameters:
146
+ - `market` — the conditionId (hex string with 0x prefix)
147
+ - `interval` — time range: `all`, `1d`, `1w`, `1m`, `3m`, `6m`, `1y`
148
+ - `fidelity` — number of data points to return
149
+
150
+ Response:
151
+ ```json
152
+ {
153
+ "history": [
154
+ {"t": 1709000000, "p": "0.55"},
155
+ {"t": 1709100000, "p": "0.58"}
156
+ ]
157
+ }
158
+ ```
159
+
160
+ `t` is Unix timestamp, `p` is price (probability).
161
+
162
+ Note: Very new markets may return empty history.
163
+
164
+ ### CLOB Markets List
165
+
166
+ ```
167
+ GET /markets?limit=N
168
+ ```
169
+
170
+ Response:
171
+ ```json
172
+ {
173
+ "data": [
174
+ {
175
+ "condition_id": "0xabc...",
176
+ "question": "Will X?",
177
+ "tokens": [
178
+ {"token_id": "123...", "outcome": "Yes", "price": 0.65},
179
+ {"token_id": "456...", "outcome": "No", "price": 0.35}
180
+ ],
181
+ "active": true,
182
+ "closed": false
183
+ }
184
+ ],
185
+ "next_cursor": "cursor_string",
186
+ "limit": 100,
187
+ "count": 1000
188
+ }
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Data API — data-api.polymarket.com
194
+
195
+ ### Recent Trades
196
+
197
+ ```
198
+ GET /trades?limit=N
199
+ GET /trades?market=CONDITION_ID&limit=N
200
+ ```
201
+
202
+ Trade fields: `side` (BUY/SELL), `size`, `price`, `timestamp`,
203
+ `title`, `slug`, `outcome`, `transactionHash`, `conditionId`.
204
+
205
+ ### Open Interest
206
+
207
+ ```
208
+ GET /oi?market=CONDITION_ID
209
+ ```
210
+
211
+ ---
212
+
213
+ ## Field Cross-Reference
214
+
215
+ To go from a Gamma market to CLOB data:
216
+
217
+ 1. Get market from Gamma: has `clobTokenIds` and `conditionId`
218
+ 2. Parse `clobTokenIds` (JSON string): `["YES_TOKEN", "NO_TOKEN"]`
219
+ 3. Use YES_TOKEN with `/price`, `/book`, `/midpoint`, `/spread`
220
+ 4. Use `conditionId` with `/prices-history` and Data API endpoints
@@ -0,0 +1,368 @@
1
+ ---
2
+ name: python-debugpy
3
+ description: "Debug Python: pdb REPL + debugpy remote (DAP)."
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # Python Debugger (pdb + debugpy)
8
+
9
+ ## Overview
10
+
11
+ Three tools, picked by situation:
12
+
13
+ | Tool | When |
14
+ |---|---|
15
+ | **`breakpoint()` + pdb** | Local, interactive, simplest. Add `breakpoint()` in the source, run normally, get a REPL at that line. |
16
+ | **`python -m pdb`** | Launch an existing script under pdb with no source edits. Useful for quick poking. |
17
+ | **`debugpy`** | Remote / headless / "attach to already-running process." Talks DAP, scriptable from terminal, works for long-lived processes (gateway, daemon, PTY children). |
18
+
19
+ **Start with `breakpoint()`.** It's the cheapest thing that works.
20
+
21
+ ## When to Use
22
+
23
+ - A test fails and the traceback doesn't reveal why a value is wrong
24
+ - You need to step through a function and watch a collection mutate
25
+ - A long-running process (hermes gateway, tui_gateway) misbehaves and you can't restart it
26
+ - Post-mortem: an exception fired in prod-ish code and you want to inspect locals at the crash site
27
+ - A subprocess / child (Python `_SlashWorker`, PTY bridge worker) is the actual bug site
28
+
29
+ **Don't use for:** things `print()` / `logging.debug` solve in under a minute, or things `pytest -vv --tb=long --showlocals` already reveals.
30
+
31
+ ## pdb Quick Reference
32
+
33
+ Inside any pdb prompt (`(Pdb)`):
34
+
35
+ | Command | Action |
36
+ |---|---|
37
+ | `h` / `h cmd` | help |
38
+ | `n` | next line (step over) |
39
+ | `s` | step into |
40
+ | `r` | return from current function |
41
+ | `c` | continue |
42
+ | `unt N` | continue until line N |
43
+ | `j N` | jump to line N (same function only) |
44
+ | `l` / `ll` | list source around current line / full function |
45
+ | `w` | where (stack trace) |
46
+ | `u` / `d` | move up / down in the stack |
47
+ | `a` | print args of the current function |
48
+ | `p expr` / `pp expr` | print / pretty-print expression |
49
+ | `display expr` | auto-print expr on every stop |
50
+ | `b file:line` | set breakpoint |
51
+ | `b func` | break on function entry |
52
+ | `b file:line, cond` | conditional breakpoint |
53
+ | `cl N` | clear breakpoint N |
54
+ | `tbreak file:line` | one-shot breakpoint |
55
+ | `!stmt` | execute arbitrary Python (assignments included) |
56
+ | `interact` | drop into full Python REPL in current scope (Ctrl+D to exit) |
57
+ | `q` | quit |
58
+
59
+ The `interact` command is the most powerful — you can import anything, inspect complex objects, even call methods that mutate state. Locals are read-only by default; use `!x = 42` from the `(Pdb)` prompt to mutate.
60
+
61
+ ## Recipe 1: Local breakpoint
62
+
63
+ Easiest. Edit the file:
64
+
65
+ ```python
66
+ def compute(x, y):
67
+ result = some_helper(x)
68
+ breakpoint() # <-- drops into pdb here
69
+ return result + y
70
+ ```
71
+
72
+ Run the code normally. You land at the `breakpoint()` line with full access to locals.
73
+
74
+ **Don't forget to remove `breakpoint()` before committing.** Use `git diff` or a pre-commit grep:
75
+ ```bash
76
+ rg -n 'breakpoint\(\)' --type py
77
+ ```
78
+
79
+ ## Recipe 2: Launch a script under pdb (no source edits)
80
+
81
+ ```bash
82
+ python -m pdb path/to/script.py arg1 arg2
83
+ # Lands at first line of script
84
+ (Pdb) b path/to/script.py:42
85
+ (Pdb) c
86
+ ```
87
+
88
+ ## Recipe 3: Debug a pytest test
89
+
90
+ The hermes test runner and pytest both support this:
91
+
92
+ ```bash
93
+ # Drop to pdb on failure (or on any raised exception):
94
+ scripts/run_tests.sh tests/path/to/test_file.py::test_name --pdb
95
+
96
+ # Drop to pdb at the START of the test:
97
+ scripts/run_tests.sh tests/path/to/test_file.py::test_name --trace
98
+
99
+ # Show locals in tracebacks without pdb:
100
+ scripts/run_tests.sh tests/path/to/test_file.py --showlocals --tb=long
101
+ ```
102
+
103
+ Note: `scripts/run_tests.sh` uses xdist (`-n 4`) by default, and pdb does NOT work under xdist. Add `-p no:xdist` or run a single test with `-n 0`:
104
+
105
+ ```bash
106
+ scripts/run_tests.sh tests/foo_test.py::test_bar --pdb -p no:xdist
107
+ # or
108
+ source .venv/bin/activate
109
+ python -m pytest tests/foo_test.py::test_bar --pdb
110
+ ```
111
+
112
+ This bypasses the hermetic-env guarantees — fine for debugging, but re-run under the wrapper to confirm before pushing.
113
+
114
+ ## Recipe 4: Post-mortem on any exception
115
+
116
+ ```python
117
+ import pdb, sys
118
+ try:
119
+ run_the_thing()
120
+ except Exception:
121
+ pdb.post_mortem(sys.exc_info()[2])
122
+ ```
123
+
124
+ Or wrap a whole script:
125
+
126
+ ```bash
127
+ python -m pdb -c continue script.py
128
+ # When it crashes, pdb catches it and you're in the frame of the exception
129
+ ```
130
+
131
+ Or set a global hook in a repl/jupyter:
132
+
133
+ ```python
134
+ import sys
135
+ def excepthook(etype, value, tb):
136
+ import pdb; pdb.post_mortem(tb)
137
+ sys.excepthook = excepthook
138
+ ```
139
+
140
+ ## Recipe 5: Remote debug with debugpy (attach to running process)
141
+
142
+ For long-lived processes: the agent gateway, tui_gateway, a daemon, a process that's already misbehaving and can't be restarted clean.
143
+
144
+ ### Setup
145
+
146
+ ```bash
147
+ source /home/bb/
148
+ pip install debugpy
149
+ ```
150
+
151
+ ### Pattern A: Source-edit — process waits for debugger at launch
152
+
153
+ Add near the top of the entry point (or inside the function you want to debug):
154
+
155
+ ```python
156
+ import debugpy
157
+ debugpy.listen(("127.0.0.1", 5678))
158
+ print("debugpy listening on 5678, waiting for client...", flush=True)
159
+ debugpy.wait_for_client()
160
+ debugpy.breakpoint() # optional: pause immediately once attached
161
+ ```
162
+
163
+ Start the process; it blocks on `wait_for_client()`.
164
+
165
+ ### Pattern B: No source edit — launch with `-m debugpy`
166
+
167
+ ```bash
168
+ python -m debugpy --listen 127.0.0.1:5678 --wait-for-client your_script.py arg1
169
+ ```
170
+
171
+ Equivalent for module entry:
172
+
173
+ ```bash
174
+ python -m debugpy --listen 127.0.0.1:5678 --wait-for-client -m your.module
175
+ ```
176
+
177
+ ### Pattern C: Attach to an already-running process
178
+
179
+ Needs the PID and debugpy preinstalled in the target's environment:
180
+
181
+ ```bash
182
+ python -m debugpy --listen 127.0.0.1:5678 --pid <pid>
183
+ # debugpy injects itself into the process. Then attach a client as below.
184
+ ```
185
+
186
+ Some kernels/security configs block the ptrace-based injection (`/proc/sys/kernel/yama/ptrace_scope`). Fix with:
187
+ ```bash
188
+ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
189
+ ```
190
+
191
+ ### Connecting a client from the terminal
192
+
193
+ The easiest terminal-side DAP client is VS Code CLI or a small script. From inside the agent you have two practical options:
194
+
195
+ **Option 1: `debugpy`'s own CLI REPL** — not an official feature, but a tiny DAP client script:
196
+
197
+ ```python
198
+ # /tmp/dap_client.py
199
+ import socket, json, itertools, time, sys
200
+
201
+ HOST, PORT = "127.0.0.1", 5678
202
+ s = socket.create_connection((HOST, PORT))
203
+ seq = itertools.count(1)
204
+
205
+ def send(msg):
206
+ msg["seq"] = next(seq)
207
+ body = json.dumps(msg).encode()
208
+ s.sendall(f"Content-Length: {len(body)}\r\n\r\n".encode() + body)
209
+
210
+ def recv():
211
+ header = b""
212
+ while b"\r\n\r\n" not in header:
213
+ header += s.recv(1)
214
+ length = int(header.decode().split("Content-Length:")[1].split("\r\n")[0].strip())
215
+ body = b""
216
+ while len(body) < length:
217
+ body += s.recv(length - len(body))
218
+ return json.loads(body)
219
+
220
+ send({"type": "request", "command": "initialize", "arguments": {"adapterID": "python"}})
221
+ print(recv())
222
+ send({"type": "request", "command": "attach", "arguments": {}})
223
+ print(recv())
224
+ send({"type": "request", "command": "setBreakpoints",
225
+ "arguments": {"source": {"path": sys.argv[1]},
226
+ "breakpoints": [{"line": int(sys.argv[2])}]}})
227
+ print(recv())
228
+ send({"type": "request", "command": "configurationDone"})
229
+ # ... loop reading events and sending continue/stepIn/etc.
230
+ ```
231
+
232
+ This is fine for one-off automation but painful as an interactive UX.
233
+
234
+ **Option 2: Attach from VS Code / Cursor / Zed** — if the user has one open, they can add a `launch.json`:
235
+
236
+ ```json
237
+ {
238
+ "name": "Attach to the agent",
239
+ "type": "debugpy",
240
+ "request": "attach",
241
+ "connect": { "host": "127.0.0.1", "port": 5678 },
242
+ "justMyCode": false,
243
+ "pathMappings": [
244
+ { "localRoot": "${workspaceFolder}", "remoteRoot": "/home/bb/
245
+ ]
246
+ }
247
+ ```
248
+
249
+ **Option 3: Ditch DAP, use `remote-pdb`** — usually what you actually want from a terminal agent:
250
+
251
+ ```bash
252
+ pip install remote-pdb
253
+ ```
254
+
255
+ In your code:
256
+ ```python
257
+ from remote_pdb import set_trace
258
+ set_trace(host="127.0.0.1", port=4444) # blocks until connection
259
+ ```
260
+
261
+ Then from the terminal:
262
+ ```bash
263
+ nc 127.0.0.1 4444
264
+ # You get a (Pdb) prompt exactly as if debugging locally.
265
+ ```
266
+
267
+ `remote-pdb` is the cleanest agent-friendly choice when `debugpy`'s DAP protocol is overkill. Use `debugpy` only when you actually need IDE integration.
268
+
269
+ ## Debugging the agent-specific Processes
270
+
271
+ ### Tests
272
+ See Recipe 3. Always add `-p no:xdist` or run single tests without xdist.
273
+
274
+ ### `run_agent.py` / CLI — one-shot
275
+ Easiest: add `breakpoint()` near the suspect line, then run `hermes` normally. Control returns to your terminal at the pause point.
276
+
277
+ ### `tui_gateway` subprocess (spawned by `hermes --tui`)
278
+ The gateway runs as a child of the Node TUI. Options:
279
+
280
+ **A. Source-edit the gateway:**
281
+ ```python
282
+ # tui_gateway/server.py near the top of serve()
283
+ import debugpy
284
+ debugpy.listen(("127.0.0.1", 5678))
285
+ debugpy.wait_for_client()
286
+ ```
287
+ Start `hermes --tui`. The TUI will appear frozen (its backend is waiting). Attach a client; execution resumes when you `continue`.
288
+
289
+ **B. Use `remote-pdb` at a specific handler:**
290
+ ```python
291
+ from remote_pdb import set_trace
292
+ set_trace(host="127.0.0.1", port=4444) # in the RPC handler you want to trap
293
+ ```
294
+ Trigger the matching slash command from the TUI, then `nc 127.0.0.1 4444` in another terminal.
295
+
296
+ ### `_SlashWorker` subprocess
297
+ Same pattern — `remote-pdb` with `set_trace()` inside the worker's `exec` path. The worker is persistent across slash commands, so the first trigger blocks until you connect; subsequent slash commands pass through normally unless you re-arm.
298
+
299
+ ### Gateway (`gateway/run.py`)
300
+ Long-lived. Use `remote-pdb` at a handler, or `debugpy` with `--wait-for-client` if you're restarting the gateway anyway.
301
+
302
+ ## Common Pitfalls
303
+
304
+ 1. **pdb under pytest-xdist silently does nothing.** You won't see the prompt, the test just hangs. Always use `-p no:xdist` or `-n 0`.
305
+
306
+ 2. **`breakpoint()` in CI / non-TTY contexts hangs the process.** Safe locally; never commit it. Add a pre-commit grep as a safety net.
307
+
308
+ 3. **`PYTHONBREAKPOINT=0`** disables all `breakpoint()` calls. Check the env if your breakpoint isn't hitting:
309
+ ```bash
310
+ echo $PYTHONBREAKPOINT
311
+ ```
312
+
313
+ 4. **`debugpy.listen` blocks only if you also call `wait_for_client()`.** Without it, execution continues and your first breakpoint may fire before the client is attached.
314
+
315
+ 5. **Attach to PID fails on hardened kernels.** `ptrace_scope=1` (Ubuntu default) allows only same-user ptrace of child processes. Workaround: `echo 0 > /proc/sys/kernel/yama/ptrace_scope` (needs root) or launch under `debugpy` from the start.
316
+
317
+ 6. **Threads.** `pdb` only debugs the current thread. For multithreaded code, use `debugpy` (thread-aware DAP) or set `threading.settrace()` per thread.
318
+
319
+ 7. **asyncio.** `pdb` works in coroutines but `await` inside pdb requires Python 3.13+ or `await` from `interact` mode on older versions. For 3.11/3.12, use `asyncio.run_coroutine_threadsafe` tricks or `!stmt`-based awaits via `asyncio.ensure_future`.
320
+
321
+ 8. **`scripts/run_tests.sh` strips credentials and sets `HOME=<tmpdir>`.** If your bug depends on user config or real API keys, it won't reproduce under the wrapper. Debug with raw `pytest` first to repro, then re-confirm under the wrapper.
322
+
323
+ 9. **Forking / multiprocessing.** pdb does not follow forks. Each child needs its own `breakpoint()` or `set_trace()`. For the agent subagents, debug one process at a time.
324
+
325
+ ## Verification Checklist
326
+
327
+ - [ ] After `pip install debugpy`, confirm: `python -c "import debugpy; print(debugpy.__version__)"`
328
+ - [ ] For remote debug, confirm the port is actually listening: `ss -tlnp | grep 5678`
329
+ - [ ] First breakpoint actually hits (if it doesn't, you likely have `PYTHONBREAKPOINT=0`, you're under xdist, or execution finished before attach)
330
+ - [ ] `where` / `w` shows the expected call stack
331
+ - [ ] Post-debug cleanup: no stray `breakpoint()` / `set_trace()` in committed code
332
+ ```bash
333
+ rg -n 'breakpoint\(\)|set_trace\(|debugpy\.listen' --type py
334
+ ```
335
+
336
+ ## One-Shot Recipes
337
+
338
+ **"Why is this dict missing a key?"**
339
+ ```python
340
+ # add above the KeyError site
341
+ breakpoint()
342
+ # then in pdb:
343
+ (Pdb) pp d
344
+ (Pdb) pp list(d.keys())
345
+ (Pdb) w # how did we get here
346
+ ```
347
+
348
+ **"This test passes in isolation but fails in the suite."**
349
+ ```bash
350
+ scripts/run_tests.sh tests/the_test.py --pdb -p no:xdist
351
+ # But if it only fails WITH other tests:
352
+ source .venv/bin/activate
353
+ python -m pytest tests/ -x --pdb -p no:xdist
354
+ # Now it pdb-traps at the exact failing test after state accumulated.
355
+ ```
356
+
357
+ **"My async handler deadlocks."**
358
+ ```python
359
+ # Add at handler entry
360
+ import remote_pdb; remote_pdb.set_trace(host="127.0.0.1", port=4444)
361
+ ```
362
+ Trigger the handler. `nc 127.0.0.1 4444`, then `w` to see the suspended frame, `!import asyncio; asyncio.all_tasks()` to see what else is pending.
363
+
364
+ **"Post-mortem on a crash in an Ink child process / subprocess."**
365
+ ```bash
366
+ PYTHONFAULTHANDLER=1 python -m pdb -c continue path/to/entrypoint.py
367
+ # On crash, pdb lands at the frame of the exception with full locals
368
+ ```