pgserve 2.1.2 → 2.2.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 (227) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +105 -1
  3. package/bin/autopg-wrapper.cjs +16 -0
  4. package/bin/pgserve-wrapper.cjs +31 -6
  5. package/bin/postgres-server.js +80 -7
  6. package/console/README.md +131 -0
  7. package/console/api.js +173 -0
  8. package/console/app.jsx +483 -0
  9. package/console/colors_and_type.css +227 -0
  10. package/console/components.jsx +167 -0
  11. package/console/console.css +1666 -0
  12. package/console/data.jsx +350 -0
  13. package/console/index.html +31 -0
  14. package/console/screens/databases.jsx +5 -0
  15. package/console/screens/health.jsx +5 -0
  16. package/console/screens/ingress.jsx +5 -0
  17. package/console/screens/optimizer.jsx +5 -0
  18. package/console/screens/rlm-sim.jsx +5 -0
  19. package/console/screens/rlm-trace.jsx +5 -0
  20. package/console/screens/security.jsx +5 -0
  21. package/console/screens/settings.jsx +611 -0
  22. package/console/screens/sql.jsx +5 -0
  23. package/console/screens/sync.jsx +5 -0
  24. package/console/screens/tables.jsx +5 -0
  25. package/console/tweaks-panel.jsx +425 -0
  26. package/package.json +11 -1
  27. package/src/cli-config.cjs +310 -0
  28. package/src/cli-install.cjs +98 -11
  29. package/src/cli-restart.cjs +228 -0
  30. package/src/cli-ui.cjs +580 -0
  31. package/src/cluster.js +43 -38
  32. package/src/postgres.js +141 -19
  33. package/src/settings-loader.cjs +235 -0
  34. package/src/settings-migrate.cjs +212 -0
  35. package/src/settings-pg-args.cjs +146 -0
  36. package/src/settings-schema.cjs +422 -0
  37. package/src/settings-validator.cjs +416 -0
  38. package/src/settings-writer.cjs +288 -0
  39. package/.claude/context/windows-debug.md +0 -119
  40. package/.genie/AGENTS.md +0 -15
  41. package/.genie/agents/README.md +0 -110
  42. package/.genie/agents/analyze.md +0 -176
  43. package/.genie/agents/forge.md +0 -290
  44. package/.genie/agents/garbage-cleaner.md +0 -324
  45. package/.genie/agents/garbage-collector.md +0 -596
  46. package/.genie/agents/github-issue-gc.md +0 -618
  47. package/.genie/agents/review.md +0 -380
  48. package/.genie/agents/semantic-analyzer/find-duplicates.md +0 -90
  49. package/.genie/agents/semantic-analyzer/find-orphans.md +0 -99
  50. package/.genie/agents/semantic-analyzer.md +0 -101
  51. package/.genie/agents/update.md +0 -182
  52. package/.genie/agents/wish.md +0 -357
  53. package/.genie/brainstorms/pgserve-v2/DESIGN.md +0 -174
  54. package/.genie/code/AGENTS.md +0 -694
  55. package/.genie/code/agents/audit/risk.md +0 -173
  56. package/.genie/code/agents/audit/security.md +0 -189
  57. package/.genie/code/agents/audit.md +0 -145
  58. package/.genie/code/agents/challenge.md +0 -230
  59. package/.genie/code/agents/change-reviewer.md +0 -295
  60. package/.genie/code/agents/code-garbage-collector.md +0 -425
  61. package/.genie/code/agents/code-quality.md +0 -410
  62. package/.genie/code/agents/commit-suggester.md +0 -255
  63. package/.genie/code/agents/commit.md +0 -124
  64. package/.genie/code/agents/consensus.md +0 -204
  65. package/.genie/code/agents/daily-standup.md +0 -722
  66. package/.genie/code/agents/docgen.md +0 -48
  67. package/.genie/code/agents/explore.md +0 -79
  68. package/.genie/code/agents/fix.md +0 -100
  69. package/.genie/code/agents/git/commit-advisory.md +0 -219
  70. package/.genie/code/agents/git/workflows/issue.md +0 -244
  71. package/.genie/code/agents/git/workflows/pr.md +0 -179
  72. package/.genie/code/agents/git/workflows/release.md +0 -460
  73. package/.genie/code/agents/git/workflows/report.md +0 -342
  74. package/.genie/code/agents/git.md +0 -432
  75. package/.genie/code/agents/implementor.md +0 -161
  76. package/.genie/code/agents/install.md +0 -515
  77. package/.genie/code/agents/issue-creator.md +0 -344
  78. package/.genie/code/agents/polish.md +0 -116
  79. package/.genie/code/agents/qa.md +0 -653
  80. package/.genie/code/agents/refactor.md +0 -294
  81. package/.genie/code/agents/release.md +0 -1129
  82. package/.genie/code/agents/roadmap.md +0 -885
  83. package/.genie/code/agents/tests.md +0 -557
  84. package/.genie/code/agents/tracer.md +0 -50
  85. package/.genie/code/agents/update/upstream-update.md +0 -85
  86. package/.genie/code/agents/update/versions/generic-update.md +0 -305
  87. package/.genie/code/agents/vibe.md +0 -1317
  88. package/.genie/code/spells/agent-configuration.md +0 -58
  89. package/.genie/code/spells/automated-rc-publishing.md +0 -106
  90. package/.genie/code/spells/branch-tracker-guidance.md +0 -28
  91. package/.genie/code/spells/debug.md +0 -320
  92. package/.genie/code/spells/emoji-naming-convention.md +0 -303
  93. package/.genie/code/spells/evidence-storage.md +0 -26
  94. package/.genie/code/spells/file-naming-rules.md +0 -35
  95. package/.genie/code/spells/forge-code-blueprints.md +0 -195
  96. package/.genie/code/spells/genie-integration.md +0 -153
  97. package/.genie/code/spells/publishing-protocol.md +0 -61
  98. package/.genie/code/spells/team-consultation-protocol.md +0 -284
  99. package/.genie/code/spells/tool-requirements.md +0 -20
  100. package/.genie/code/spells/triad-maintenance-protocol.md +0 -154
  101. package/.genie/code/teams/tech-council/council.md +0 -328
  102. package/.genie/code/teams/tech-council/jt.md +0 -352
  103. package/.genie/code/teams/tech-council/nayr.md +0 -305
  104. package/.genie/code/teams/tech-council/oettam.md +0 -375
  105. package/.genie/neurons/README.md +0 -193
  106. package/.genie/neurons/forge.md +0 -106
  107. package/.genie/neurons/genie.md +0 -63
  108. package/.genie/neurons/review.md +0 -106
  109. package/.genie/neurons/wish.md +0 -104
  110. package/.genie/product/README.md +0 -20
  111. package/.genie/product/cli-automation.md +0 -359
  112. package/.genie/product/environment.md +0 -60
  113. package/.genie/product/mission.md +0 -60
  114. package/.genie/product/roadmap.md +0 -44
  115. package/.genie/product/tech-stack.md +0 -34
  116. package/.genie/product/templates/context-template.md +0 -218
  117. package/.genie/product/templates/qa-done-report-template.md +0 -68
  118. package/.genie/product/templates/review-report-template.md +0 -89
  119. package/.genie/product/templates/wish-template.md +0 -120
  120. package/.genie/scripts/helpers/analyze-commit.js +0 -195
  121. package/.genie/scripts/helpers/bullet-counter.js +0 -194
  122. package/.genie/scripts/helpers/bullet-find.js +0 -289
  123. package/.genie/scripts/helpers/bullet-id.js +0 -244
  124. package/.genie/scripts/helpers/check-secrets.js +0 -237
  125. package/.genie/scripts/helpers/count-tokens.js +0 -200
  126. package/.genie/scripts/helpers/create-frontmatter.js +0 -456
  127. package/.genie/scripts/helpers/detect-markers.js +0 -293
  128. package/.genie/scripts/helpers/detect-todos.js +0 -267
  129. package/.genie/scripts/helpers/detect-unlabeled-blocks.js +0 -135
  130. package/.genie/scripts/helpers/embeddings.js +0 -344
  131. package/.genie/scripts/helpers/find-empty-sections.js +0 -158
  132. package/.genie/scripts/helpers/index.js +0 -319
  133. package/.genie/scripts/helpers/validate-frontmatter.js +0 -578
  134. package/.genie/scripts/helpers/validate-links.js +0 -207
  135. package/.genie/scripts/helpers/validate-paths.js +0 -373
  136. package/.genie/spells/README.md +0 -9
  137. package/.genie/spells/ace-protocol.md +0 -118
  138. package/.genie/spells/ask-one-at-a-time.md +0 -175
  139. package/.genie/spells/backup-analyzer.md +0 -542
  140. package/.genie/spells/blocker.md +0 -12
  141. package/.genie/spells/break-things-move-fast.md +0 -56
  142. package/.genie/spells/context-candidates.md +0 -72
  143. package/.genie/spells/context-critic.md +0 -51
  144. package/.genie/spells/defer-to-expertise.md +0 -278
  145. package/.genie/spells/delegate-dont-do.md +0 -292
  146. package/.genie/spells/error-investigation-protocol.md +0 -328
  147. package/.genie/spells/evidence-based-completion.md +0 -273
  148. package/.genie/spells/experiment.md +0 -65
  149. package/.genie/spells/file-creation-protocol.md +0 -229
  150. package/.genie/spells/forge-integration.md +0 -281
  151. package/.genie/spells/forge-orchestration.md +0 -514
  152. package/.genie/spells/gather-context.md +0 -18
  153. package/.genie/spells/global-health-check.md +0 -34
  154. package/.genie/spells/global-noop-roundtrip.md +0 -25
  155. package/.genie/spells/install-genie.md +0 -1232
  156. package/.genie/spells/install.md +0 -82
  157. package/.genie/spells/investigate-before-commit.md +0 -112
  158. package/.genie/spells/know-yourself.md +0 -288
  159. package/.genie/spells/learn.md +0 -828
  160. package/.genie/spells/mcp-diagnostic-protocol.md +0 -246
  161. package/.genie/spells/mcp-first.md +0 -124
  162. package/.genie/spells/multi-step-execution.md +0 -67
  163. package/.genie/spells/orchestration-boundary-protocol.md +0 -256
  164. package/.genie/spells/orchestrator-not-implementor.md +0 -189
  165. package/.genie/spells/prompt.md +0 -746
  166. package/.genie/spells/reflect.md +0 -404
  167. package/.genie/spells/routing-decision-matrix.md +0 -368
  168. package/.genie/spells/run-in-parallel.md +0 -12
  169. package/.genie/spells/session-state-updater-example.md +0 -196
  170. package/.genie/spells/session-state-updater.md +0 -220
  171. package/.genie/spells/track-long-running-tasks.md +0 -133
  172. package/.genie/spells/troubleshoot-infrastructure.md +0 -176
  173. package/.genie/spells/upgrade-genie.md +0 -415
  174. package/.genie/spells/url-presentation-protocol.md +0 -301
  175. package/.genie/spells/wish-initiation.md +0 -158
  176. package/.genie/spells/wish-issue-linkage.md +0 -410
  177. package/.genie/spells/wish-lifecycle.md +0 -100
  178. package/.genie/state/provider-status.json +0 -3
  179. package/.genie/state/version.json +0 -16
  180. package/.genie/wishes/canonical-pgserve-pm2-supervision/WISH.md +0 -290
  181. package/.genie/wishes/pgserve-v2/BRIEF-from-genie-pgserve.md +0 -99
  182. package/.genie/wishes/pgserve-v2/WISH.md +0 -442
  183. package/.genie/wishes/release-system-genie-pattern/WISH.md +0 -268
  184. package/.genie/wishes/release-system-genie-pattern/validation.md +0 -205
  185. package/.gitguardian.yaml +0 -29
  186. package/.gitguardianignore +0 -16
  187. package/.github/workflows/ci.yml +0 -122
  188. package/.github/workflows/release.yml +0 -289
  189. package/.github/workflows/version.yml +0 -228
  190. package/.husky/pre-commit +0 -2
  191. package/AGENTS.md +0 -433
  192. package/CLAUDE.md +0 -1
  193. package/Makefile +0 -285
  194. package/assets/icon.ico +0 -0
  195. package/bun.lock +0 -435
  196. package/bunfig.toml +0 -28
  197. package/ecosystem.config.cjs +0 -23
  198. package/eslint.config.js +0 -63
  199. package/examples/multi-tenant-demo.js +0 -104
  200. package/install.sh +0 -123
  201. package/knip.json +0 -9
  202. package/scripts/test-bun-self-heal.sh +0 -163
  203. package/scripts/test-npx.sh +0 -60
  204. package/tests/audit.test.js +0 -189
  205. package/tests/backpressure.test.js +0 -167
  206. package/tests/benchmarks/runner.js +0 -1197
  207. package/tests/benchmarks/vector-generator.js +0 -368
  208. package/tests/cli-install.test.js +0 -322
  209. package/tests/control-db.test.js +0 -285
  210. package/tests/daemon-control.test.js +0 -171
  211. package/tests/daemon-fingerprint-integration.test.js +0 -111
  212. package/tests/daemon-pr24-regression.test.js +0 -198
  213. package/tests/fingerprint.test.js +0 -263
  214. package/tests/fixtures/240-orphan-seed.sql +0 -30
  215. package/tests/multi-tenant.test.js +0 -374
  216. package/tests/orphan-cleanup.test.js +0 -390
  217. package/tests/pg-version-regex.test.js +0 -129
  218. package/tests/quick-bench.js +0 -135
  219. package/tests/router-handshake-retry.test.js +0 -119
  220. package/tests/router-handshake-watchdog.test.js +0 -110
  221. package/tests/sdk.test.js +0 -71
  222. package/tests/stale-postmaster-pid.test.js +0 -85
  223. package/tests/stress-test.js +0 -439
  224. package/tests/sync-perf-test.js +0 -150
  225. package/tests/tcp-listen.test.js +0 -368
  226. package/tests/tenancy.test.js +0 -403
  227. package/tests/wrapper-supervision.test.js +0 -107
@@ -1,119 +0,0 @@
1
- # Windows Debug Context
2
-
3
- ## RESOLVED (2025-12-12)
4
-
5
- The Windows router binding issue has been fixed. See "Solution Applied" below.
6
-
7
- ---
8
-
9
- ## Original Issue
10
- PostgreSQL starts successfully on port 9432, but the router/proxy on port 8432 was NOT listening.
11
- Clients could not connect because 8432 wasn't bound.
12
-
13
- ## Root Causes Found
14
-
15
- ### 1. `reusePort: true` - Linux-only feature (PRIMARY CAUSE)
16
- **Location:** `src/cluster.js:75`
17
-
18
- The cluster mode uses `Bun.listen({ reusePort: true })` which maps to `SO_REUSEPORT`.
19
- This socket option is Linux-only and **silently fails on Windows**.
20
-
21
- ### 2. Auto-enabled cluster mode on multi-core Windows systems
22
- **Location:** `bin/pglite-server.js:106`
23
-
24
- Windows systems with multiple CPU cores automatically entered cluster mode,
25
- triggering the `reusePort` failure.
26
-
27
- ### 3. TCP port opens before PostgreSQL ready for protocol handshakes
28
- **Location:** `src/postgres.js:803-821`
29
-
30
- PostgreSQL was marked "ready" when TCP port opened, but it wasn't actually
31
- ready for protocol-level handshakes. Admin pool connection timed out.
32
-
33
- ---
34
-
35
- ## Solution Applied
36
-
37
- ### Fix 1: Disable cluster mode on Windows
38
- **File:** `bin/pglite-server.js:98-108`
39
- ```javascript
40
- const isWindows = os.platform() === 'win32';
41
- cluster: cpuCount > 1 && !isWindows,
42
- ```
43
-
44
- ### Fix 2: Add platform check to reusePort
45
- **File:** `src/cluster.js:72-76`
46
- ```javascript
47
- const isWindows = os.platform() === 'win32';
48
- this.server = Bun.listen({
49
- reusePort: !isWindows, // SO_REUSEPORT only works on Linux/macOS
50
- ...
51
- });
52
- ```
53
-
54
- ### Fix 3: Add port binding verification
55
- **File:** `src/cluster.js:99-102`
56
- ```javascript
57
- if (!this.server || !this.server.port) {
58
- throw new Error(`Failed to bind to port ${this.port} - reusePort may not be supported`);
59
- }
60
- ```
61
-
62
- ### Fix 4: Add Windows readiness delay
63
- **File:** `src/postgres.js:813-817`
64
- ```javascript
65
- if (isWindows) {
66
- await Bun.sleep(2000); // 2 second delay for Windows
67
- }
68
- ```
69
-
70
- ### Fix 5: Increase admin pool retry for Windows
71
- **File:** `src/postgres.js:598-599`
72
- ```javascript
73
- const maxRetries = isWindows ? 10 : 5;
74
- const baseDelay = isWindows ? 2000 : 1000;
75
- ```
76
-
77
- ---
78
-
79
- ## Verification
80
-
81
- After applying fixes, server runs correctly on Windows:
82
- - Router: `127.0.0.1:7432` ✅
83
- - PostgreSQL: `127.0.0.1:8432` ✅
84
- - Database auto-provisioning: ✅
85
- - Query execution: ✅
86
-
87
- ```
88
- Server started successfully!
89
-
90
- Endpoint: postgresql://127.0.0.1:7432/<database>
91
- Mode: In-memory (ephemeral)
92
- PostgreSQL: Port 8432 (internal)
93
- Auto-create: Enabled
94
- ```
95
-
96
- ---
97
-
98
- ## Test Commands (Run from Windows)
99
- ```cmd
100
- # Build binary
101
- bun build --compile bin/pglite-server.js --outfile dist/pgserve-windows-x64.exe
102
-
103
- # Start server
104
- dist\pgserve-windows-x64.exe
105
-
106
- # Check ports are listening (should see BOTH)
107
- netstat -an | findstr "LISTEN" | findstr "8432 9432"
108
-
109
- # Test connection
110
- psql postgresql://localhost:8432/testdb
111
- ```
112
-
113
- ---
114
-
115
- ## Related Files
116
- - `bin/pglite-server.js` - Entry point, cluster mode decision
117
- - `src/cluster.js` - Cluster mode with reusePort
118
- - `src/router.js` - Single-process mode (works on Windows)
119
- - `src/postgres.js` - PostgreSQL startup and admin pool
package/.genie/AGENTS.md DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- name: Base
3
- label: 🧞 Base
4
- description: Global agents (orchestration, QA, analysis, maintenance)
5
- github_url: https://github.com/namastexlabs/automagik-genie/tree/main/.genie
6
- ---
7
-
8
- > **Shared rules in `~/.claude/rules/agent-bible.md`. Read it.**
9
-
10
- # Base Genie Agents
11
-
12
- **Global agents available across all collectives.**
13
-
14
- For complete orchestration framework and instructions, see:
15
- @AGENTS.md
@@ -1,110 +0,0 @@
1
- ## Agent Front Matter & Forge Configuration
2
-
3
- Every agent lives in a collective directory that includes an `AGENTS.md` marker and an `agents/` folder. The **agent identifier** is derived from its file path inside that folder, e.g. `.genie/code/agents/review.md` → `code/review`. If an agent sits at the workspace root (`.genie/agents/review.md`) it keeps the simple id `review`. Rename or relocate the markdown file to change the id—no extra metadata is required.
4
-
5
- ### Defaults
6
-
7
- If an agent’s front matter omits a `genie` block, the CLI and MCP server use the defaults from `.genie/config.yaml`:
8
-
9
- ```yaml
10
- defaults:
11
- executor: opencode # maps to Forge executor key
12
- variant: DEFAULT # maps to Forge executor profile variant
13
- ```
14
-
15
- That means most agents can stay minimal:
16
-
17
- ```markdown
18
- ---
19
- name: analyze
20
- description: Discovery + risk triage
21
- ---
22
- ```
23
-
24
- ### Overriding Forge execution per agent
25
-
26
- To specialize the executor or variant, add a `genie` section for orchestration settings and a `forge` section for executor-specific configuration. The CLI passes this metadata to Forge when calling `createAndStartTask`. Both blocks are optional.
27
-
28
- ```yaml
29
- ---
30
- name: review
31
- description: Evidence-based QA
32
- genie:
33
- executor: opencode # Orchestration: which executor to invoke
34
- variant: REVIEW_STRICT_EVIDENCE # Orchestration: which profile variant
35
- background: true # Orchestration: run in isolated worktree
36
- forge:
37
- model: sonnet # Executor config: passed to Forge as-is
38
- dangerously_skip_permissions: false
39
- ---
40
- ```
41
-
42
- #### Supported keys
43
-
44
- **`genie.*` namespace (Orchestration):**
45
-
46
- | Key | Purpose | Forge mapping |
47
- | --- | --- | --- |
48
- | `executor` | Logical executor name (`CLAUDE_CODE`, `OPENCODE`, `CODEX`, …). Case-insensitive. | Translated to Forge `executor_profile_id.executor`. |
49
- | `variant` | Profile variant (e.g. `DEFAULT`, `REVIEW_STRICT_EVIDENCE`, `DOCGEN_MEDIUM`). | Translated to Forge `executor_profile_id.variant`. |
50
- | `background` | Set to `false` to force foreground streaming (rare). Default: `true`. | Affects CLI behaviour only (worktree isolation). |
51
-
52
- **`forge.*` namespace (Executor Configuration):**
53
-
54
- Genie passes `forge.*` fields directly to Forge without validation. Forge validates against executor-specific schemas. Common fields:
55
-
56
- | Key | Executors | Purpose |
57
- | --- | --- | --- |
58
- | `model` | All | Model name (e.g. `sonnet`, `opus`, `haiku`) |
59
- | `dangerously_skip_permissions` | All | Skip permission checks (use with caution) |
60
- | `sandbox` | CODEX | Sandbox mode (`auto`, `write`, `workspace-write`) |
61
- | `append_prompt` | CLAUDE_CODE | Additional prompt text appended to agent prompt |
62
- | `claude_code_router` | CLAUDE_CODE | Enable Claude Code routing behavior |
63
- | `additional_params` | OPENCODE, CODEX | Array of key-value parameters |
64
-
65
- See Forge executor schemas for complete field reference: `@automagik/forge/shared/schemas/*.json`
66
-
67
- ### Precedence
68
-
69
- When a run starts, Genie applies overrides in this order:
70
-
71
- 1. Workspace defaults in `.genie/config.yaml`
72
- 2. Agent front matter (`genie.executor`, `genie.variant`, `forge.model`)
73
- 3. CLI flags at call-time (`genie run … --executor <id> --model <name>`)
74
-
75
- The last value wins. CLI flags override agent frontmatter, which overrides workspace defaults.
76
-
77
- ### Discovering available Forge options
78
-
79
- 1. **Inspect Forge executor schemas**
80
- Check `@automagik/forge/shared/schemas/*.json` for complete field definitions per executor. Each schema defines valid `forge.*` fields for that executor.
81
-
82
- 2. **Inspect Forge UI**
83
- The Automagik Forge UI exposes executor configurations under *Settings → Coding Agent Configurations*. Each field shown there can be set in agent `forge.*` frontmatter.
84
-
85
- 3. **Use agent frontmatter**
86
- Define executor-specific settings directly in agent frontmatter:
87
-
88
- ```yaml
89
- ---
90
- name: docgen
91
- genie:
92
- executor: OPENCODE
93
- variant: DOCGEN_DOCFIRST
94
- forge:
95
- append_prompt: |
96
- Prefer docstrings and API comments; avoid logic changes.
97
- additional_params:
98
- - { key: doc_mode, value: doc-first }
99
- ---
100
- ```
101
-
102
- Forge discovers `.genie/` folders natively and reads agent frontmatter directly.
103
-
104
- ### Quick checklist when creating a new agent
105
-
106
- 1. Place the markdown file in the correct collective (`.genie/<collective>/agents/`).
107
- 2. Keep identifiers simple. If you want the CLI id `analyze`, put the file under `.genie/agents/`; if you need `code/analyze`, move it under `.genie/code/agents/`.
108
- 3. Only add a `genie` block when you need a non-default executor, variant, or background mode.
109
- 4. Add a `forge` block for executor-specific configuration (model, permissions, etc.).
110
- 5. Run `pnpm run build:genie` so the CLI picks up changes, then `genie list agents` to verify the new id shows up.
@@ -1,176 +0,0 @@
1
- ---
2
- name: analyze
3
- description: System analysis and focused investigations (universal framework)
4
- genie:
5
- executor: OPENCODE
6
- background: true
7
- model: sonnet
8
- forge:
9
- CLAUDE_CODE:
10
- model: sonnet
11
- CODEX:
12
- model: gpt-5-codex
13
- OPENCODE:
14
- model: opencode/glm-4.6
15
- ---
16
-
17
- # Analyze Agent (Universal Framework)
18
-
19
- ## Identity & Mission
20
- Perform holistic system audits OR conduct focused deep investigations into specific topics, dependency graphs, or subsystems. Surface dependencies, hotspots, coupling, strategic improvement opportunities, and deliver comprehensive findings with evidence.
21
-
22
- **Works across ALL domains:** Code, research, legal, medical, finance, operations, strategy.
23
-
24
- **Two Modes:**
25
- 1. **System Analysis** - Holistic architecture audit and strategic assessment
26
- 2. **Focused Investigation** - Deep dive into specific topics with dependency mapping
27
-
28
- ## Success Criteria
29
- **System Analysis Mode:**
30
- - ✅ Executive overview with system fitness, key risks, and standout strengths
31
- - ✅ Strategic findings ordered by impact with actionable recommendations
32
- - ✅ Quick wins identified with effort vs. benefit analysis
33
- - ✅ System-level insights that inform strategic decisions
34
-
35
- **Focused Investigation Mode:**
36
- - ✅ Investigation scope clearly defined with boundaries (what's in/out)
37
- - ✅ Findings documented with source references and examples
38
- - ✅ Dependency map produced (if applicable) showing relationships
39
- - ✅ Follow-up actions prioritized with ownership and timeline
40
- - ✅ Verdict includes confidence level and recommended next steps
41
-
42
- ## Never Do (Universal)
43
- - ❌ Detailed bug hunts or minor critiques (use review instead)
44
- - ❌ "Rip-and-replace" proposals unless architecture is untenable
45
- - ❌ Speculative complexity recommendations without clear current need
46
- - ❌ Generic advice without domain-specific context
47
- - ❌ Investigate without defining scope boundaries (risk of unbounded exploration)
48
- - ❌ Present findings without source references or examples
49
- - ❌ Skip dependency mapping for architectural investigations
50
- - ❌ Ignore follow-up action prioritization or ownership assignment
51
- - ❌ Deliver verdict without explaining confidence rationale
52
-
53
- ---
54
-
55
- ## Mode 1: System Analysis (Universal)
56
-
57
- ### When to Use
58
- Use this mode for holistic audits to understand how a system aligns with long-term goals, architectural soundness, scalability, and maintainability.
59
-
60
- ### Operating Framework
61
- ```
62
- <task_breakdown>
63
- 1. [Discovery] Map the system structure, components, deployment model, and constraints
64
- 2. [Implementation] Determine how well current architecture serves stated goals and scaling needs
65
- 3. [Verification] Surface systemic risks and highlight opportunities for strategic improvements
66
- </task_breakdown>
67
- ```
68
-
69
- ### Key Dimensions (Domain-Agnostic)
70
- • **Architectural Alignment** – layering, domain boundaries, component relationships, fit for purpose
71
- • **Scalability & Growth Trajectory** – data/process flow, capacity model, bottleneck analysis
72
- • **Maintainability** – module cohesion, coupling, ownership clarity, documentation health
73
- • **Risk Posture** – systemic exposure points, failure modes, threat surfaces
74
- • **Operational Readiness** – observability, deployment/rollback processes, disaster recovery
75
- • **Future Proofing** – ease of evolution, dependency roadmap, sustainability
76
-
77
- ### Deliverable Format
78
-
79
- #### Executive Overview
80
- One paragraph summarizing system fitness, key risks, and standout strengths.
81
-
82
- #### Strategic Findings (Ordered by Impact)
83
-
84
- ##### 1. [FINDING NAME]
85
- **Insight:** Very concise statement of what matters and why.
86
- **Evidence:** Specific components/documents/metrics illustrating the point.
87
- **Impact:** How this affects scalability, maintainability, or strategic goals.
88
- **Recommendation:** Actionable next step.
89
- **Effort vs. Benefit:** Relative estimate (Low/Medium/High effort; Low/Medium/High payoff).
90
-
91
- #### Quick Wins
92
- Bullet list of low-effort changes offering immediate value.
93
-
94
- #### Long-Term Roadmap Suggestions
95
- High-level guidance for phased improvements (optional—include only if explicitly requested).
96
-
97
- ---
98
-
99
- ## Mode 2: Focused Investigation (Universal)
100
-
101
- ### When to Use
102
- Use this mode for focused deep investigations into specific topics, dependency graphs, or subsystems requiring comprehensive findings with dependency mapping.
103
-
104
- ### Operating Framework
105
- ```
106
- <task_breakdown>
107
- 1. [Discovery] Define investigation scope, map entry points, identify key components/dependencies
108
- 2. [Implementation] Trace relationships, extract findings with evidence, build dependency map
109
- 3. [Verification] Prioritize findings, assign follow-up actions, deliver verdict + confidence
110
- </task_breakdown>
111
- ```
112
-
113
- ### Investigation Framework (Domain-Agnostic)
114
-
115
- #### Investigation Types:
116
- 1. **Dependency Analysis** - "What depends on X? What does Y depend on?"
117
- 2. **Process Flow** - "How does process Z work end-to-end?"
118
- 3. **Architecture Understanding** - "How is subsystem A structured?"
119
- 4. **Bottleneck Investigation** - "Where are the constraints in B?"
120
- 5. **Risk Analysis** - "What are the vulnerabilities in C?"
121
- 6. **Migration Planning** - "What's impacted if we replace D with E?"
122
-
123
- #### Investigation Outputs:
124
- - **Findings** - Key insights with source references and examples
125
- - **Dependency Map** - Visual or text representation of component relationships
126
- - **Affected Components** - List of elements central to the investigation
127
- - **Follow-Up Actions** - Prioritized tasks to address findings
128
-
129
- ### Investigation Structure
130
-
131
- **Scope Definition:**
132
- - **In Scope:** What will be investigated
133
- - **Out of Scope:** Explicit boundaries to prevent scope creep
134
-
135
- **Entry Points:** Where to start the investigation
136
-
137
- **Findings Template:**
138
-
139
- **F1: [FINDING NAME] (Impact: CRITICAL/HIGH/MEDIUM/LOW)**
140
- - **Evidence:** Description with source references
141
- - **Example:** Concrete illustration
142
- - **Measurement:** Quantification (if applicable)
143
- - **Impact:** How this affects the system
144
- - **Source:** Location/reference
145
-
146
- **Dependency Map:** Visual or text representation of relationships
147
-
148
- **Affected Components:** List with references
149
-
150
- **Follow-Up Actions Table:**
151
-
152
- | Action | Priority | Owner | Timeline | Expected Impact |
153
- |--------|----------|-------|----------|-----------------|
154
- | ... | ... | ... | ... | ... |
155
-
156
- **Verdict:** Summary + recommended actions (confidence: low|medium|high - reasoning)
157
-
158
- ---
159
-
160
- ## Domain Customization
161
-
162
- Domain-specific implementations (code, legal, medical, etc.) should INCLUDE this universal framework and ADD domain-specific examples, patterns, and tooling.
163
-
164
- **Include pattern:**
165
- ```markdown
166
- # Analyze Agent - [Domain Name]
167
-
168
- @.genie/code/teams/analyze/README.md
169
-
170
- ## Domain-Specific Extensions
171
- [Add domain examples, patterns, tools here]
172
- ```
173
-
174
- ---
175
-
176
- **Analysis keeps systems honest—audit broadly, investigate deeply, and map dependencies thoroughly to surface strategic improvements.**