oh-my-patent 0.1.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 (152) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +298 -0
  3. package/README.zh-CN.md +303 -0
  4. package/dist/adapters/claude/index.d.ts +37 -0
  5. package/dist/adapters/claude/index.js +438 -0
  6. package/dist/adapters/claude/index.js.map +1 -0
  7. package/dist/adapters/codex/index.d.ts +45 -0
  8. package/dist/adapters/codex/index.js +597 -0
  9. package/dist/adapters/codex/index.js.map +1 -0
  10. package/dist/adapters/generate.d.ts +11 -0
  11. package/dist/adapters/generate.js +112 -0
  12. package/dist/adapters/generate.js.map +1 -0
  13. package/dist/adapters/loader.d.ts +19 -0
  14. package/dist/adapters/loader.js +343 -0
  15. package/dist/adapters/loader.js.map +1 -0
  16. package/dist/adapters/types.d.ts +108 -0
  17. package/dist/adapters/types.js +8 -0
  18. package/dist/adapters/types.js.map +1 -0
  19. package/dist/agents/archimedes.d.ts +14 -0
  20. package/dist/agents/archimedes.js +49 -0
  21. package/dist/agents/archimedes.js.map +1 -0
  22. package/dist/cli.d.ts +30 -0
  23. package/dist/cli.js +772 -0
  24. package/dist/cli.js.map +1 -0
  25. package/dist/commands/path-branch.d.ts +109 -0
  26. package/dist/commands/path-branch.js +342 -0
  27. package/dist/commands/path-branch.js.map +1 -0
  28. package/dist/commands/path-query.d.ts +149 -0
  29. package/dist/commands/path-query.js +262 -0
  30. package/dist/commands/path-query.js.map +1 -0
  31. package/dist/commands/path-restore.d.ts +72 -0
  32. package/dist/commands/path-restore.js +162 -0
  33. package/dist/commands/path-restore.js.map +1 -0
  34. package/dist/commands/path-visualization.d.ts +64 -0
  35. package/dist/commands/path-visualization.js +329 -0
  36. package/dist/commands/path-visualization.js.map +1 -0
  37. package/dist/commands/render.d.ts +28 -0
  38. package/dist/commands/render.js +337 -0
  39. package/dist/commands/render.js.map +1 -0
  40. package/dist/commands/shared.d.ts +18 -0
  41. package/dist/commands/shared.js +47 -0
  42. package/dist/commands/shared.js.map +1 -0
  43. package/dist/core/brainstorm-path.d.ts +164 -0
  44. package/dist/core/brainstorm-path.js +119 -0
  45. package/dist/core/brainstorm-path.js.map +1 -0
  46. package/dist/core/diagram-inserter.d.ts +33 -0
  47. package/dist/core/diagram-inserter.js +116 -0
  48. package/dist/core/diagram-inserter.js.map +1 -0
  49. package/dist/core/diagram-renderer.d.ts +39 -0
  50. package/dist/core/diagram-renderer.js +272 -0
  51. package/dist/core/diagram-renderer.js.map +1 -0
  52. package/dist/core/diagram-types.d.ts +103 -0
  53. package/dist/core/diagram-types.js +35 -0
  54. package/dist/core/diagram-types.js.map +1 -0
  55. package/dist/core/path-graph.d.ts +179 -0
  56. package/dist/core/path-graph.js +428 -0
  57. package/dist/core/path-graph.js.map +1 -0
  58. package/dist/core/path-persistence.d.ts +96 -0
  59. package/dist/core/path-persistence.js +263 -0
  60. package/dist/core/path-persistence.js.map +1 -0
  61. package/dist/core/router.d.ts +20 -0
  62. package/dist/core/router.js +79 -0
  63. package/dist/core/router.js.map +1 -0
  64. package/dist/core/state-manager.d.ts +7 -0
  65. package/dist/core/state-manager.js +59 -0
  66. package/dist/core/state-manager.js.map +1 -0
  67. package/dist/core/state.d.ts +30 -0
  68. package/dist/core/state.js +64 -0
  69. package/dist/core/state.js.map +1 -0
  70. package/dist/core/threshold-config.d.ts +90 -0
  71. package/dist/core/threshold-config.js +249 -0
  72. package/dist/core/threshold-config.js.map +1 -0
  73. package/dist/core/validator.d.ts +6 -0
  74. package/dist/core/validator.js +24 -0
  75. package/dist/core/validator.js.map +1 -0
  76. package/dist/core/workflow.d.ts +28 -0
  77. package/dist/core/workflow.js +86 -0
  78. package/dist/core/workflow.js.map +1 -0
  79. package/dist/index.d.ts +22 -0
  80. package/dist/index.js +26 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/skills/jurisdiction.d.ts +32 -0
  83. package/dist/skills/jurisdiction.js +127 -0
  84. package/dist/skills/jurisdiction.js.map +1 -0
  85. package/dist/skills/quality-gate.d.ts +15 -0
  86. package/dist/skills/quality-gate.js +44 -0
  87. package/dist/skills/quality-gate.js.map +1 -0
  88. package/dist/tui/app.d.ts +13 -0
  89. package/dist/tui/app.js +262 -0
  90. package/dist/tui/app.js.map +1 -0
  91. package/dist/tui/cli.d.ts +11 -0
  92. package/dist/tui/cli.js +18 -0
  93. package/dist/tui/cli.js.map +1 -0
  94. package/package.json +55 -0
  95. package/plugin.jsonc +179 -0
  96. package/src/adapters/claude/index.ts +494 -0
  97. package/src/adapters/codex/index.ts +676 -0
  98. package/src/adapters/generate.ts +131 -0
  99. package/src/adapters/loader.ts +427 -0
  100. package/src/adapters/types.ts +146 -0
  101. package/src/agents/archimedes.md +380 -0
  102. package/src/agents/archimedes.ts +75 -0
  103. package/src/agents/patent-adversarial-examiner.md +23 -0
  104. package/src/agents/patent-brainstorm-moderator.md +138 -0
  105. package/src/agents/patent-diagram-generator.md +147 -0
  106. package/src/agents/patent-disclosure-reviewer.md +20 -0
  107. package/src/agents/patent-disclosure-writer.md +23 -0
  108. package/src/agents/patent-innovation-architect.md +127 -0
  109. package/src/agents/patent-landscape-analyst.md +206 -0
  110. package/src/agents/patent-path-recorder.md +282 -0
  111. package/src/agents/patent-product-compliance-analyst.md +21 -0
  112. package/src/agents/patent-security-engineer.md +27 -0
  113. package/src/agents/patent-technical-responder.md +20 -0
  114. package/src/agents/patentability-evaluator.md +97 -0
  115. package/src/cli.ts +877 -0
  116. package/src/commands/archimedes.md +27 -0
  117. package/src/commands/brainstorm-resume.md +200 -0
  118. package/src/commands/patent-diagram.md +34 -0
  119. package/src/commands/patent-draft.md +24 -0
  120. package/src/commands/patent-new.md +30 -0
  121. package/src/commands/patent-review.md +27 -0
  122. package/src/commands/patent-search.md +28 -0
  123. package/src/commands/patent-status.md +28 -0
  124. package/src/commands/path-branch.ts +452 -0
  125. package/src/commands/path-query.ts +428 -0
  126. package/src/commands/path-restore.ts +238 -0
  127. package/src/commands/path-visualization.ts +395 -0
  128. package/src/commands/render.ts +410 -0
  129. package/src/commands/shared.ts +54 -0
  130. package/src/core/brainstorm-path.ts +359 -0
  131. package/src/core/diagram-inserter.ts +149 -0
  132. package/src/core/diagram-renderer.ts +322 -0
  133. package/src/core/diagram-types.ts +150 -0
  134. package/src/core/path-graph.ts +582 -0
  135. package/src/core/path-persistence.ts +332 -0
  136. package/src/core/router.ts +98 -0
  137. package/src/core/state-manager.ts +64 -0
  138. package/src/core/state.ts +94 -0
  139. package/src/core/threshold-config.ts +327 -0
  140. package/src/core/validator.ts +37 -0
  141. package/src/core/workflow.ts +97 -0
  142. package/src/index.ts +37 -0
  143. package/src/skills/brainstorm-path/SKILL.md +237 -0
  144. package/src/skills/disclosure-template/SKILL.md +39 -0
  145. package/src/skills/evidence-card/SKILL.md +31 -0
  146. package/src/skills/jurisdiction/SKILL.md +102 -0
  147. package/src/skills/jurisdiction.ts +167 -0
  148. package/src/skills/prior-art-search/SKILL.md +219 -0
  149. package/src/skills/quality-gate/SKILL.md +39 -0
  150. package/src/skills/quality-gate.ts +63 -0
  151. package/src/tui/app.tsx +669 -0
  152. package/src/tui/cli.ts +20 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 oh-my-patent contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,298 @@
1
+ # oh-my-patent
2
+
3
+ [![npm version](https://img.shields.io/npm/v/oh-my-patent.svg)](https://www.npmjs.com/package/oh-my-patent)
4
+ [![npm downloads](https://img.shields.io/npm/dm/oh-my-patent.svg)](https://www.npmjs.com/package/oh-my-patent)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue.svg)](https://www.typescriptlang.org/)
7
+ [![Tests](https://img.shields.io/badge/tests-87%20passing-brightgreen.svg)](https://github.com/zengbods/oh-my-patent)
8
+
9
+ > Your idea → a full patent disclosure document, without you herding 11 AI agents into a task queue.
10
+
11
+ ## One-Liner
12
+
13
+ Install. Type `/archimedes`. Describe what you want. The rest is handled by 11 patent-specialized AI agents.
14
+
15
+ ```bash
16
+ npm install -g oh-my-patent
17
+ oh-my-patent adapt setup --workspace-dir .
18
+ ```
19
+
20
+ Then:
21
+
22
+ ```text
23
+ /archimedes
24
+ > Create a patent project about homomorphic encryption in privacy-preserving computing.
25
+ ```
26
+
27
+ It will search, brainstorm, assess, draft, review, and generate patent figures on its own.
28
+ Every decision is recorded — you can roll back to any round, fork to explore alternatives, or revive a discarded innovation.
29
+
30
+ ---
31
+
32
+ ## 🎬 Quick Demo
33
+
34
+ ### Before oh-my-patent
35
+ ![Manual Patent Workflow](https://via.placeholder.com/800x400/2d3748/ffffff?text=Manual+workflow%3A+Switch+between+10+tools%2C+lose+context%2C+manually+merge+outputs)
36
+
37
+ ### After oh-my-patent
38
+ ![Automated Patent Workflow](https://via.placeholder.com/800x400/48bb78/ffffff?text=oh-my-patent%3A+One+command%2C+11+agents%2C+auditable+path%2C+auto-figures)
39
+
40
+ > **Note**: GIF demonstrations will be added in v0.1.1. Screenshots show the conceptual workflow difference.
41
+
42
+ ---
43
+
44
+ ## Your Pain vs. What This Does
45
+
46
+ | Your Pain | In Other Tools | In oh-my-patent |
47
+ |---|---|---|
48
+ | You have to prompt 10 different AIs, then consolidate everything yourself | You cut up the work, paste chat logs across windows, manually merge | **Archimedes**, the primary orchestrator, routes everything to 11 specialist agents. Outputs are auto-saved to `references/`, context passes between rounds automatically |
49
+ | After 3 rounds of brainstorming, you scroll up and the rejected gems are gone | Chat history scrolls away, and you can't find that one great idea from round 2 | **.brainstorm/ decision-path tracking** persists every round's scores, innovations, and pass/reject decisions as an auditable DAG. Roll back, fork, or revive at will |
50
+ | Patent figures are a cycle of Visio → screenshot → paste into Word | You draw by hand, export, format, lose the source | **Mermaid/PlantUML figure generation** extracts the architecture from MAIN.md, renders to SVG+PNG, and **auto-updates** the figure references in MAIN.md |
51
+ | Every new teammate who uses Claude Code or Codex needs a different, hand-written config | Claude Code settings, Codex settings, separate and manual for each project | **`oh-my-patent adapt setup`** — one command generates configs for **both** Claude Code (`.claude/` + CLAUDE.md) and Codex (`.codex/` + codex.json). Uninstall is also one command, and it **only** removes what we generated |
52
+ | Halfway through, your machine crashes or the conversation breaks | Scrambling through screenshots, starting over from zero | **Workflow state machine**. All stages are written to `state.json`, and the decision tree is in `path.json`. Resume from the exact point of failure |
53
+ | After 6 review rounds, you have no idea what "done" looks like | A mess of loose documents | **Quantitative threshold model** auto-decides if brainstorming is mature enough. The QA loop has a clear exit: 2 consecutive rounds with no new issues |
54
+
55
+ ## The Full Feature Set (For When You Want It)
56
+
57
+ The table above handles 90% of real use cases. Here's everything, for when you need to come back to check:
58
+
59
+ | | Feature | What it means in one sentence |
60
+ |---|---|---|
61
+ | 🧠 | **Brainstorm decision-path tracking** | `.brainstorm/` records every round's scores, innovations, and pass/reject decisions. Roll back to any node, fork to explore alternatives, or revive discarded ideas |
62
+ | 🤖 | **End-to-end 11-agent pipeline** | Search → ideation → patentability → draft → review → rebuttal → diagrams. The full patent lifecycle, with zero hand-holding between stages |
63
+ | ⚡ | **`/archimedes` one-liner entry** | Regardless of what you want, start with Archimedes. He reads your state, routes to specialists, waits for output, and moves to the next stage |
64
+ | 🔗 | **Zero-config cross-tool adapters** | `oh-my-patent adapt setup` generates configs for both Claude Code and Codex in one shot |
65
+ | 🛡️ | **Safe uninstall** | Exact-file cleanup — we only delete files we auto-generated. No `readdir + unlink` traversing your workspace |
66
+ | 📊 | **Auto figure rendering** | Parses MAIN.md for technical architecture, renders Mermaid/PlantUML to SVG+PNG, and auto-rewrites references |
67
+ | 🎯 | **Scoring thresholds & QA loops** | Quantitative model decides if a brainstorming round is ripe. Up to 6 review-rebuttal loops, exiting on 2 consecutive clean rounds |
68
+ | 💻 | **Interactive terminal blueprint** | Ink+React TUI for locally browsing the decision path, node details, and branch overviews with zero internet dependency |
69
+ | 🔄 | **Resumable workflow** | `INIT → RESEARCH → BRAINSTORM → DRAFT → QA_LOOP → FINAL_REVIEW → DIAGRAM → DONE`. Crashes or session breaks are non-destructive; resume from `state.json` |
70
+
71
+ ## Full Installation
72
+
73
+ ### Global install (after npm publish)
74
+
75
+ ```bash
76
+ npm install -g oh-my-patent
77
+ ```
78
+
79
+ ### Local development
80
+
81
+ ```bash
82
+ git clone <your repo>
83
+ cd oh-my-patent
84
+ npm install
85
+ npm run build
86
+ ```
87
+
88
+ Use `node dist/cli.js` or `npx -p . oh-my-patent` after building.
89
+
90
+ ### Install editor configs into your workspace
91
+
92
+ Run this from your project root (where `projects/` lives):
93
+
94
+ ```bash
95
+ # All adapters (Claude Code + Codex)
96
+ oh-my-patent adapt setup --workspace-dir .
97
+
98
+ # Or one at a time
99
+ oh-my-patent adapt setup --tool claude-code --workspace-dir .
100
+ ```
101
+
102
+ The CLI will automatically print the matching `uninstall` command on completion.
103
+
104
+ ```bash
105
+ oh-my-patent adapt install # alias for setup
106
+ oh-my-patent adapt generate # only writes to ./plugins/<tool>/, does not touch workspace
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Full Usage
112
+
113
+ ```
114
+ oh-my-patent <domain> <subcommand> [options]
115
+ ```
116
+
117
+ ### Brainstorm Path (`path`): track, branch, evaluate
118
+
119
+ | Subcommand | What it does |
120
+ |------------|--------------|
121
+ | `path init <project>` | Initialize `.brainstorm/` and `state.json` |
122
+ | `path record <project> --round <N> --data <json\|@file>` | Record round N with full scores, decisions, and innovation snapshots |
123
+ | `path overview <project>` | Path summary: from start to finish, where you are now, whether the project is done |
124
+ | `path node <project> <round-N>` | Details of a specific round: who said what, innovation scores, final decision |
125
+ | `path innovation(s) <project> [ID]` | Full history of one innovation — when it was proposed, how it was rated, where it ended up |
126
+ | `path branch <project> --from-node <id> --reason <text>` | **Fork** from any historical node to explore an alternative path with a different reason |
127
+ | `path branches <project>` | List all branches |
128
+ | `path restore <project> --node <id> --innovation <id>` | **Revive** a previously abandoned innovation and bring it back into the discussion |
129
+ | `path threshold <project> --round <N>` | Evaluate whether the round's scores pass the threshold, with a recommendation (iterate or proceed) |
130
+ | `path visualize <project> [--mode overview\|node\|innovation\|branch\|dashboard] --target <id>` | Terminal box-drawing visualization |
131
+ | `path markdown <project> [--mode overview\|node\|innovation\|branch] --target <id>` | Export a Markdown report |
132
+
133
+ ### Patent Diagrams (`diagram`): extract, render, rewrite
134
+
135
+ | Subcommand | What it does |
136
+ |------------|--------------|
137
+ | `diagram render <project> --specs <json\|@file> --phase draft\|final` | Batch render into `figures/` (SVG+PNG), and auto-update MAIN.md figure references |
138
+ | `diagram status <project>` | Get the list of rendered figures (figureNumber, phase, file paths) |
139
+ | `diagram rerender <project> --figure <ID> --source <mmd\|@file> --engine mermaid\|plantuml` | Update single figure (use after editing Mermaid/PlantUML source) |
140
+
141
+ ### Adapters (`adapt`): one command, all editors
142
+
143
+ | Subcommand | What it does |
144
+ |------------|--------------|
145
+ | `adapt setup [--tool claude-code\|codex] [--workspace-dir .]` | Recommended entry. Installs editor configs, then shows the exact `uninstall` command |
146
+ | `adapt install` | Behavior identical to `setup` |
147
+ | `adapt uninstall [--tool <name>] [--workspace-dir .]` | **Exact-file removal only**. We do not touch your custom files |
148
+ | `adapt generate` | Writes to `plugins/<tool>/` only, does not write to the workspace |
149
+
150
+ ### Interactive TUI (`tui`)
151
+
152
+ ```bash
153
+ oh-my-patent tui [project-path]
154
+ ```
155
+
156
+ Launches an Ink+React terminal UI. Navigate the decision path, view scores, switch branches, and revive innovations — all locally, no internet needed.
157
+
158
+ ---
159
+
160
+ ## The Workflow
161
+
162
+ ```
163
+ User proposes a topic
164
+ ↓
165
+ [INIT] Generate `projects/{NN}-{topic_slug}/`
166
+ Initialize .patent/state.json + .brainstorm/path.json
167
+ ↓
168
+ [RESEARCH] Patent search
169
+ → references/landscape.md (generated by landscape-analyst)
170
+ ↓
171
+ [BRAINSTORM_R1] Round 1
172
+ Head-to-head: innovation-architect generates candidates + adversarial-examiner attacks them
173
+ Scores are recorded, innovation snapshots saved to .brainstorm/nodes/round-1.json
174
+ ↓
175
+ [BRAINSTORM_R2] Round 2
176
+ Deep assessment by security-engineer, compliance-analyst, and evaluator
177
+ ↓ (threshold passed / 2 rounds done)
178
+ [DRAFT] Generate initial disclosure
179
+ → MAIN.md (generated by patent-disclosure-writer)
180
+ ↓
181
+ [QA_LOOP] Review-rebuttal loop
182
+ Reviewer raises issues → technical-responder writes revisions
183
+ ≤ 6 rounds, exiting on 2 consecutive rounds with no new issues
184
+ ↓
185
+ [FINAL_REVIEW] Final pass, can loop back to QA_LOOP
186
+ ↓
187
+ [DIAGRAM] Automatically render patent figures
188
+ → figures/ (SVG + PNG, with automatic references rewritten in MAIN.md)
189
+ ↓
190
+ [DONE] Quality gate: quality-gate check → finished
191
+
192
+ If the agent crashes mid-sentence: read state.json → resume from the exact stage
193
+ If you regret a round: `path branch --from-node round-{N}` → explore an alternative
194
+ If a long-forgotten innovation was actually good: `path restore` → bring it back
195
+ ```
196
+
197
+ ## Architecture
198
+
199
+ The system is split into four layers:
200
+
201
+ | Layer | What it governs | Key files |
202
+ |-------|-----------------|-----------|
203
+ | **Orchestration** | Agent/skill/command definitions. Defined once, consumed everywhere | `plugin.jsonc`, `opencode.jsonc`, `.opencode/skills/` |
204
+ | **Engine** | Path tracking, state machine, figure rendering, threshold logic | `src/core/` |
205
+ | **Command** | Unified CLI layer wrapping the engine's capabilities | `src/cli.ts`, `src/commands/` |
206
+ | **Adapter** | Converts orchestration definitions into Claude Code / Codex -ready configs | `src/adapters/claude/`, `src/adapters/codex/` |
207
+
208
+ Data flow between the layers:
209
+
210
+ ```
211
+ plugin.jsonc (orchestration layer definition)
212
+ ↓
213
+ [Adapters] generate automatically
214
+ ↓
215
+ .claude/ (Claude Code) <—— one file, consumed all tools
216
+ .codex/ (Codex) <——
217
+ AGENTS.md / CLAUDE.md
218
+ codex.json
219
+ ↓
220
+ AI in your editor invokes 11 specialist agents
221
+ ↓
222
+ Output → .brainstorm/ decision-path records
223
+ Output → state.json workflow state machine
224
+ Output → references/ with standardized filenames
225
+ Output → MAIN.md + figures/
226
+
227
+ CLI commands = automated operations on .brainstorm/ + .patent/ + references/
228
+ TUI = visualized browsing of .brainstorm/
229
+ ```
230
+
231
+ ## Directory Structure
232
+
233
+ ```
234
+ oh-my-patent/ # Core repo: configs and engine; no project deliverables
235
+ ├── src/
236
+ │ ├── cli.ts # CLI entry point
237
+ │ ├── core/
238
+ │ │ ├── brainstorm-path.ts # Decision-path data model + scoring thresholds
239
+ │ │ ├── path-persistence.ts # Atomic writes + rollback
240
+ │ │ ├── path-graph.ts # Graph structure + forking algorithms
241
+ │ │ ├── diagram-renderer.ts # Mermaid/PlantUML → SVG/PNG
242
+ │ │ └── threshold-config.ts # Quantitative threshold model
243
+ │ ├── commands/ # path init/record/overview/branch/restore...
244
+ │ ├── adapters/ # Zero-config cross-tool adapters
245
+ │ │ ├── claude/ # → .claude/ + CLAUDE.md
246
+ │ │ └── codex/ # → .codex/ + AGENTS.md + codex.json
247
+ │ └── tui/ # Ink+React interactive UI
248
+ ├── plugin.jsonc
249
+ ├── opencode.jsonc
250
+ └── dist/ (compiled output)
251
+
252
+ projects/{NN}-{topic_slug}/ # One Git repo per patent
253
+ ├── .brainstorm/
254
+ │ ├── path.json # Metadata + edges + current node + final decision
255
+ │ ├── nodes/
256
+ │ │ └── round-{n}.json # Round detail: scores, innovations, decisions, timestamps
257
+ │ ├── snapshots/
258
+ │ │ └── round-{n}-innovations.json # Innovation history snapshots
259
+ │ └── branches/
260
+ │ └── {branchId}/ # Branch steps — independent node copies
261
+ ├── .patent/
262
+ │ └── state.json # Workflow state machine: at DRAFT? QA round 3?
263
+ ├── references/
264
+ │ ├── landscape.md # Search results
265
+ │ ├── brainstorm_round1_archimedes.md
266
+ │ ├── argue_round2_adversarial-examiner.md
267
+ │ └── ... # Every agent output follows a strict naming convention
268
+ ├── figures/
269
+ │ ├── 001-system-overview.png
270
+ │ ├── 001-system-overview.svg
271
+ │ └── figures-manifest.json # Version management
272
+ ├── MAIN.md # Final disclosure (auto-updated by diagram inserter)
273
+ └── conversation.md # Chronological conversation log
274
+ ```
275
+
276
+ ## Script Quickref
277
+
278
+ ```bash
279
+ npm run build # Compile TypeScript → dist/
280
+ npm test # Run the vitest test suite
281
+ npm run lint # tsc --noEmit type checking
282
+ ```
283
+
284
+ ---
285
+
286
+ ## Acknowledgments
287
+
288
+ Special thanks to:
289
+
290
+ - **[LINUX DO Community](https://linux.do/)**
291
+ - All contributors who helped improve this project
292
+ - The open-source community for the amazing tools and libraries that made this possible
293
+
294
+ ---
295
+
296
+ ## License
297
+
298
+ MIT
@@ -0,0 +1,303 @@
1
+ # oh-my-patent
2
+
3
+ [![npm version](https://img.shields.io/npm/v/oh-my-patent.svg)](https://www.npmjs.com/package/oh-my-patent)
4
+ [![npm downloads](https://img.shields.io/npm/dm/oh-my-patent.svg)](https://www.npmjs.com/package/oh-my-patent)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue.svg)](https://www.typescriptlang.org/)
7
+ [![Tests](https://img.shields.io/badge/tests-87%20passing-brightgreen.svg)](https://github.com/zengbods/oh-my-patent)
8
+
9
+ > 你的创意 → 完整的专利交底书,不需要你组织 11 个 AI 的智能体排队干活。
10
+
11
+ ## 一句话
12
+
13
+ 安装。写作 `/archimedes`,说你要什么。剩下的交给 11 个专利专用 AI 智能体。
14
+
15
+ ```bash
16
+ npm install -g oh-my-patent
17
+ oh-my-patent adapt setup --workspace-dir .
18
+ ```
19
+
20
+ 然后:
21
+
22
+ ```text
23
+ /archimedes
24
+ > 基于同态加密在隐私计算中的应用,新建一个专利项目。
25
+ ```
26
+
27
+ 它会自己检索、头脑风暴、评估可专利性、撰写、审查、生成附图。
28
+ 每一步的决策都被记录下来——你能回退到任意一轮、分叉探索替代方案、复活已放弃的创新点。
29
+
30
+ ---
31
+
32
+ ## 🎬 快速演示
33
+
34
+ ### oh-my-patent 之前
35
+ ![手动专利工作流](https://via.placeholder.com/800x400/2d3748/ffffff?text=手动工作流:在10个工具间切换,丢失上下文,手动合并输出)
36
+
37
+ ### oh-my-patent 之后
38
+ ![自动化专利工作流](https://via.placeholder.com/800x400/48bb78/ffffff?text=oh-my-patent:一条命令,11个智能体,可审计路径,自动附图)
39
+
40
+ > **注意**: GIF 动画演示将在 v0.1.1 版本中添加。截图展示了工作流差异的概念。
41
+
42
+ ---
43
+
44
+ ## 你遇到的痛点 vs 这里怎么解决
45
+
46
+ | 你的痛苦 | 别的工具怎么做 | oh-my-patent 怎么做 |
47
+ |---|---|---|
48
+ | 要问 10 个 AI 不同的提示词,再人工整理输出 | 你需要自己切分任务、粘贴对话、手动归并 | **Archimedes 主编排器**自动路由到 11 个专业智能体,每轮产出自动写入 `references/`,上下文在各轮间自动传递 |
49
+ | 多轮头脑风暴翻完页就失忆了 | 对话历史丢失,放弃的创新点再也找不到 | **.brainstorm/ 决策路径系统**把每轮的评分、创新点、淘汰/通过决策持久化成有向无环图,支持回退、分叉、恢复 |
50
+ | 写专利附图要画 Visio/PPT 再贴图 | 手动作图、另存为图片再插入 Word | **Mermaid/PlantUML 自动渲染**从交底书提取技术架构,输出 SVG+PNG 并自动回写 `MAIN.md` |
51
+ | 帮同事安装 Claude Code 或 Codex 后,都给他写不同的配置 | Claude Code 一套,Codex 另一套,手抄 | **一条命令自动适配** Claude Code(.claude/ + CLAUDE.md)和 Codex(.codex/ + codex.json),卸载也是一条命令,且只删自己生成的文件 |
52
+ | 写了一半机器崩了/对话断了 | 从 jpg 里翻截图,从零重来 | **工作流状态机**。所有阶段写入 `state.json` + 决策树写入 `path.json`,断点即续 |
53
+ | 审查 6 轮后不知道自己到哪一关了 | 混乱的文档拼凑 | **量化阈值模型**自动判断头脑风暴是否成熟,QA 循环有明确的退出条件(连续 2 轮无新问题) |
54
+
55
+ ## 还有很多,但你不需要先读
56
+
57
+ 上表提到的功能已经够你跑完 90% 的用例。以下是完整的亮点怕你以后回来查:
58
+
59
+ ### 全部亮点
60
+
61
+ | 图标 | 名称 | 一句话解释 |
62
+ |-----:|:------|:------|
63
+ | 🧠 | **头脑风暴决策路径追踪** | `.brainstorm/` 里自动保存每轮的评分、创新点、淘汰/通过决策。能回退到任意节点、分叉探索替代方向、复活已放弃创新点 |
64
+ | 🤖 | **11 智能体端到端流水线** | 检索 → 创意激发 → 可专利性评估 → 撰写 → 审查 → 答辩 → 附图,覆盖交底书全生命周期 |
65
+ | ⚡ | **`/archimedes` 一句话启动** | 不管什么命令,先找 Archimedes。他判断阶段、分配任务、传递上下文、等待产出、推进下一关 |
66
+ | 🔗 | **零配置跨工具适配器** | `oh-my-patent adapt setup` 一条命令给 Claude Code 和 Codex 同时注册配置 |
67
+ | 🛡️ | **安全卸载** | 精确文件级清理——只删自动生成的文件,绝不 `readdir + unlink` 遍历你工作区 |
68
+ | 📊 | **自动附图渲染** | 解析 MAIN.md 中的技术架构描述,Mermaid/PlantUML → SVG/PNG,自动回写 |
69
+ | 🎯 | **评分阈值与 QA 循环** | 量化阈值模型自动判断头脑风暴够不够深入;审查阶段最多 6 轮 QA 循环,直到连续 2 轮无新问题 |
70
+ | 💻 | **交互式终端蓝草图** | 基于 Ink+React 的 TUI,本地可视化浏览决策路径、节点详情、分支概览 |
71
+ | 🔄 | **可恢复工作流** | `INIT → RESEARCH → BRAINSTORM → DRAFT → QA_LOOP → FINAL_REVIEW → DIAGRAM → DONE`,机器崩溃也能从 `state.json` 接上 |
72
+
73
+ ## 完整安装
74
+
75
+ ### 全局安装(发布到 npm 后)
76
+
77
+ ```bash
78
+ npm install -g oh-my-patent
79
+ ```
80
+
81
+ ### 本地开发
82
+
83
+ ```bash
84
+ # 克隆项目
85
+ git clone <你的仓库地址>
86
+ cd oh-my-patent
87
+ npm install
88
+ npm run build
89
+ ```
90
+
91
+ 构建后使用 `node dist/cli.js` 或 `npx -p . oh-my-patent`。
92
+
93
+ ### 为工作区安装编辑器配置
94
+
95
+ 进入你的项目根目录(即 `projects/` 所在目录):
96
+
97
+ ```bash
98
+ # 安装全部适配器(Claude Code + Codex)
99
+ oh-my-patent adapt setup --workspace-dir .
100
+
101
+ # 或只装一个
102
+ oh-my-patent adapt setup --tool claude-code --workspace-dir .
103
+ ```
104
+
105
+ 安装完后会给你对应的 `uninstall` 命令提示。
106
+
107
+ 更多安装方式:
108
+
109
+ ```bash
110
+ oh-my-patent adapt install # 与 setup 相同
111
+ oh-my-patent adapt generate # 仅生成到 ./plugins/<tool>/ 不写入工作区
112
+ ```
113
+
114
+ ---
115
+
116
+ ## 完整用法
117
+
118
+ ```
119
+ oh-my-patent <域> <子命令> [选项]
120
+ ```
121
+
122
+ ### 头脑风暴路径(`path`):追踪、分叉、评估
123
+
124
+ | 子命令 | 用途 |
125
+ |--------|------|
126
+ | `path init <项目>` | 初始化 `.brainstorm/` 目录结构和 `state.json` |
127
+ | `path record <项目> --round <N> --data <json\|@文件>` | 记录第 N 轮完整数据(评分、决策、创新点快照) |
128
+ | `path overview <项目>` | 路径概览:从哪到哪、当前在哪、是否完成 |
129
+ | `path node <项目> <round-N>` | 查看某轮详情:谁说了什么、创新点评分、最终决策 |
130
+ | `path innovation(s) <项目> [ID]` | 一个创新点的全部历史(哪轮提出、哪轮评估、后来去哪了) |
131
+ | `path branch <项目> --from-node <id> --reason <原因>` | **分叉**——从任意历史节点,用不同理由跑替代方案 |
132
+ | `path branches <项目>` | 列出所有分支 |
133
+ | `path restore <项目> --node <id> --innovation <id>` | **复活**——把一个已放弃的创新点重新带回讨论 |
134
+ | `path threshold <项目> --round <N>` | 该轮评分是否通过阈值,给出建议(继续迭代 / 进入撰写) |
135
+ | `path visualize <项目> [--mode overview\|node\|innovation\|branch\|dashboard] --target <id>` | 终端 box-drawing 可视化 |
136
+ | `path markdown <项目> [--mode overview\|node\|innovation\|branch] --target <id>` | 导出 Markdown 报告 |
137
+
138
+ ### 专利附图(`diagram`):自动提取、渲染、回写
139
+
140
+ | 子命令 | 用途 |
141
+ |--------|------|
142
+ | `diagram render <项目> --specs <json\|@文件> --phase draft\|final` | 批量渲染,输出 SVG+PNG,自动更新 MAIN.md 的图表引用 |
143
+ | `diagram status <项目>` | 查看已渲染图表清单(含 figureNumber、phase、文件路径) |
144
+ | `diagram rerender <项目> --figure <ID> --source <mmd\|@文件> --engine mermaid\|plantuml` | 更新单图(修改 Mermaid/PlantUML 源码后使用) |
145
+
146
+ ### 适配器(`adapt`):一条命令适配所有编辑器
147
+
148
+ | 子命令 | 用途 |
149
+ |--------|------|
150
+ | `adapt setup [--tool claude-code\|codex] [--workspace-dir .]` | 推荐入口。安装编辑器配置,带卸载提示 |
151
+ | `adapt install` | 与 `setup` 行为一致 |
152
+ | `adapt uninstall [--tool <name>] [--workspace-dir .]` | **只删自动生成的文件**。绝不碰你的自定义文件 |
153
+ | `adapt generate` | 只生成到 `plugins/<tool>/`,不写入工作区 |
154
+
155
+ ### 交互式 TUI(`tui`)
156
+
157
+ ```bash
158
+ oh-my-patent tui [项目路径]
159
+ ```
160
+
161
+ 启动 Ink+React 终端界面,键盘浏览决策路径、查看评分、切换分支、恢复创新点。
162
+
163
+ ---
164
+
165
+ ## 工作流
166
+
167
+ ```
168
+ 用户提出选题
169
+ ↓
170
+ [INIT] 生成 `projects/{NN}-{topic_slug}/`
171
+ 初始化 .patent/state.json + .brainstorm/path.json
172
+ ↓
173
+ [RESEARCH] 专利检索
174
+ → references/landscape.md(由 landscape-analyst 产出)
175
+ ↓
176
+ [BRAINSTORM_R1] 第 1 轮
177
+ 多头对战:innovation-architect 生成创意 + adversarial-examiner 砸漏洞
178
+ 评分 ↔ 创新点快照 → .brainstorm/nodes/round-1.json
179
+ ↓
180
+ [BRAINSTORM_R2] 第 2 轮
181
+ 深度评估:security-engineer + compliance-analyst + evaluator
182
+ ↓ (threshold 评估通过 / 2 轮)
183
+ [DRAFT] 生成交底书初稿
184
+ → MAIN.md(由 patent-disclosure-writer 产出)
185
+ ↓
186
+ [QA_LOOP] 审查-答辩循环
187
+ reviewer 提问题 → technical-responder 写修订
188
+ ≤ 6 轮,连续 2 轮无新 issue 则退出
189
+ ↓
190
+ [FINAL_REVIEW] 最终审查,决定通过或退回 QA_LOOP
191
+ ↓
192
+ [DIAGRAM] 自动渲染专利附图
193
+ → figures/(SVG + PNG + 回写 MAIN.md)
194
+ ↓
195
+ [DONE] 质量闸门:quality-gate 检查 → 完成
196
+
197
+ 任意阶段崩溃后:读取 state.json 可精确定位断点
198
+ 我不满意某轮结果:path branch --from-node round-{N} 开新分支
199
+ 很久以前的创新点其实不错:path restore 复活它
200
+ ```
201
+
202
+ ## 架构
203
+
204
+ 这个系统分为四层:
205
+
206
+ | 层 | 按照什么规则运转 | 关键文件 |
207
+ |---|---|---|
208
+ | **编排层** | 智能体/技能/命令的端口定义,一次定义,到处跑 | `plugin.jsonc`、`opencode.jsonc`、`.opencode/skills/` |
209
+ | **引擎层** | 路径追踪、状态机、图表渲染、阈值评估 | `src/core/` |
210
+ | **命令层** | 把引擎能力封装为统一的 CLI 命令 | `src/cli.ts`、`src/commands/` |
211
+ | **适配层** | 把编排层的定义自动转成 Claude Code / Codex 需要的格式 | `src/adapters/claude/`, `src/adapters/codex/` |
212
+
213
+ 三层之间的数据流:
214
+
215
+ ```
216
+ plugin.jsonc(编排层定义)
217
+ ↓
218
+ [适配器] 自动生成
219
+ ↓
220
+ .claude/ (Claude Code) <——一个文件,多处消费
221
+ .codex/ (Codex) <——
222
+ AGENTS.md / CLAUDE.md
223
+ codex.json
224
+ ↓
225
+ 编辑器中的 AI 调用 11 个专业智能体
226
+ ↓
227
+ 产出 → .brainstorm/ 决策路径记录
228
+ 产出 → state.json 工作流状态机
229
+ 产出 → references/ 标准命名文件
230
+ 产出 → MAIN.md + figures/
231
+
232
+ CLI 命令 = 对 .brainstorm/ + .patent/ + references/ 的自动化操作
233
+ TUI = 对 .brainstorm/ 的可视化浏览
234
+ ```
235
+
236
+ ## 目录结构
237
+
238
+ ```
239
+ oh-my-patent/ # 核心仓库:配置与引擎,不存项目交付物
240
+ ├── src/
241
+ │ ├── cli.ts # CLI 入口
242
+ │ ├── core/
243
+ │ │ ├── brainstorm-path.ts # 决策路径数据模型 + 分数阈值
244
+ │ │ ├── path-persistence.ts # 原子写入 + 回滚
245
+ │ │ ├── path-graph.ts # 图结构 + 分叉算法
246
+ │ │ ├── diagram-renderer.ts # Mermaid/PlantUML → SVG/PNG
247
+ │ │ └── threshold-config.ts # 量化阈值模型
248
+ │ ├── commands/ # path init/record/overview/branch/restore...
249
+ │ ├── adapters/ # 零配置适配器
250
+ │ │ ├── claude/ # → .claude/ + CLAUDE.md
251
+ │ │ └── codex/ # → .codex/ + AGENTS.md + codex.json
252
+ │ └── tui/ # Ink+React 交互界面
253
+ ├── plugin.jsonc
254
+ ├── opencode.jsonc
255
+ └── dist/ (编译产物)
256
+
257
+ projects/{NN}-{topic_slug}/ # 每个专利 = 独立 Git 仓库
258
+ ├── .brainstorm/
259
+ │ ├── path.json # 元数据 + 边 + 当前节点 + 最终决策
260
+ │ ├── nodes/
261
+ │ │ └── round-{n}.json # 评分、创新点、决策、时间戳
262
+ │ ├── snapshots/
263
+ │ │ └── round-{n}-innovations.json # 创新点历史快照
264
+ │ └── branches/
265
+ │ └── {branchId}/ # 分支独立节点副本
266
+ ├── .patent/
267
+ │ └── state.json # 工作流阶段机:到 DRAFT 了?第 3 轮 QA?
268
+ ├── references/
269
+ │ ├── landscape.md # 检索结果
270
+ │ ├── brainstorm_round1_archimedes.md
271
+ │ ├── argue_round2_adversarial-examiner.md
272
+ │ └── ... # 所有产出都遵循命名规范
273
+ ├── figures/
274
+ │ ├── 001-system-overview.png
275
+ │ ├── 001-system-overview.svg
276
+ │ └── figures-manifest.json # 版本管理
277
+ ├── MAIN.md # 最终交底书(随时被 diagram 回写)
278
+ └── conversation.md # 编年体对话记录
279
+ ```
280
+
281
+ ## 脚本速查
282
+
283
+ ```bash
284
+ npm run build # 编译 TypeScript → dist/
285
+ npm test # 运行 vitest 测试
286
+ npm run lint # tsc --noEmit 类型检查
287
+ ```
288
+
289
+ ---
290
+
291
+ ## 致谢
292
+
293
+ 特别感谢:
294
+
295
+ - **[LINUX DO 社区](https://linux.do/)** - 在开发过程中提供了宝贵的反馈和支持
296
+ - 所有帮助改进此项目的贡献者
297
+ - 开源社区提供的出色工具和库,使这个项目成为可能
298
+
299
+ ---
300
+
301
+ ## 许可证
302
+
303
+ MIT
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Claude Code Adapter
3
+ *
4
+ * Generates configuration files for Anthropic's Claude Code CLI from
5
+ * the portable oh-my-patent definitions.
6
+ *
7
+ * Outputs:
8
+ * - CLAUDE.md → Project instructions with agent routing, commands, workflow rules
9
+ * - .claude/agents/*.md → Per-agent prompt files (full prompt content, no OpenCode frontmatter)
10
+ * - .claude/settings.json → MCP server configuration in Claude Code format
11
+ */
12
+ import { PortableDef, ToolAdapter, GenerateResult } from '../types.js';
13
+ export declare class ClaudeCodeAdapter implements ToolAdapter {
14
+ readonly name = "claude-code";
15
+ generate(def: PortableDef, config: Record<string, unknown>): Promise<GenerateResult>;
16
+ private generateAgentPrompt;
17
+ /**
18
+ * Build YAML frontmatter for ccb/Claude Code agent recognition.
19
+ * Must appear at the very top of the .md file as `--- ... ---`.
20
+ */
21
+ private buildAgentFrontmatter;
22
+ /**
23
+ * Build a concise HTML comment header for human readability.
24
+ * This appears after the YAML frontmatter, not as frontmatter itself.
25
+ */
26
+ private buildAgentCommentHeader;
27
+ private generateCommandFile;
28
+ private generateSettings;
29
+ private generateClaudeMd;
30
+ getGeneratedFilePaths(def: PortableDef): string[];
31
+ uninstall(def: PortableDef, workspaceDir: string): Promise<{
32
+ filesRemoved: string[];
33
+ filesSkipped: string[];
34
+ success: boolean;
35
+ message: string;
36
+ }>;
37
+ }