archmantic 1.0.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 (175) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +172 -0
  3. package/dist/agent.d.ts +20 -0
  4. package/dist/agent.d.ts.map +1 -0
  5. package/dist/agent.js +239 -0
  6. package/dist/agent.js.map +1 -0
  7. package/dist/analyze/datamodel.d.ts +9 -0
  8. package/dist/analyze/datamodel.d.ts.map +1 -0
  9. package/dist/analyze/datamodel.js +19 -0
  10. package/dist/analyze/datamodel.js.map +1 -0
  11. package/dist/analyze/derive.d.ts +21 -0
  12. package/dist/analyze/derive.d.ts.map +1 -0
  13. package/dist/analyze/derive.js +211 -0
  14. package/dist/analyze/derive.js.map +1 -0
  15. package/dist/analyze/drizzle.d.ts +3 -0
  16. package/dist/analyze/drizzle.d.ts.map +1 -0
  17. package/dist/analyze/drizzle.js +83 -0
  18. package/dist/analyze/drizzle.js.map +1 -0
  19. package/dist/analyze/endpoints.d.ts +3 -0
  20. package/dist/analyze/endpoints.d.ts.map +1 -0
  21. package/dist/analyze/endpoints.js +167 -0
  22. package/dist/analyze/endpoints.js.map +1 -0
  23. package/dist/analyze/fs-util.d.ts +3 -0
  24. package/dist/analyze/fs-util.d.ts.map +1 -0
  25. package/dist/analyze/fs-util.js +44 -0
  26. package/dist/analyze/fs-util.js.map +1 -0
  27. package/dist/analyze/incremental.d.ts +12 -0
  28. package/dist/analyze/incremental.d.ts.map +1 -0
  29. package/dist/analyze/incremental.js +102 -0
  30. package/dist/analyze/incremental.js.map +1 -0
  31. package/dist/analyze/index.d.ts +5 -0
  32. package/dist/analyze/index.d.ts.map +1 -0
  33. package/dist/analyze/index.js +49 -0
  34. package/dist/analyze/index.js.map +1 -0
  35. package/dist/analyze/parse-util.d.ts +10 -0
  36. package/dist/analyze/parse-util.d.ts.map +1 -0
  37. package/dist/analyze/parse-util.js +47 -0
  38. package/dist/analyze/parse-util.js.map +1 -0
  39. package/dist/analyze/prisma.d.ts +4 -0
  40. package/dist/analyze/prisma.d.ts.map +1 -0
  41. package/dist/analyze/prisma.js +97 -0
  42. package/dist/analyze/prisma.js.map +1 -0
  43. package/dist/analyze/sql.d.ts +3 -0
  44. package/dist/analyze/sql.d.ts.map +1 -0
  45. package/dist/analyze/sql.js +110 -0
  46. package/dist/analyze/sql.js.map +1 -0
  47. package/dist/analyze/stack.d.ts +4 -0
  48. package/dist/analyze/stack.d.ts.map +1 -0
  49. package/dist/analyze/stack.js +94 -0
  50. package/dist/analyze/stack.js.map +1 -0
  51. package/dist/analyze/tier0.d.ts +7 -0
  52. package/dist/analyze/tier0.d.ts.map +1 -0
  53. package/dist/analyze/tier0.js +57 -0
  54. package/dist/analyze/tier0.js.map +1 -0
  55. package/dist/analyze/tier1.d.ts +13 -0
  56. package/dist/analyze/tier1.d.ts.map +1 -0
  57. package/dist/analyze/tier1.js +144 -0
  58. package/dist/analyze/tier1.js.map +1 -0
  59. package/dist/analyze/tier2.d.ts +14 -0
  60. package/dist/analyze/tier2.d.ts.map +1 -0
  61. package/dist/analyze/tier2.js +231 -0
  62. package/dist/analyze/tier2.js.map +1 -0
  63. package/dist/analyze/walk.d.ts +3 -0
  64. package/dist/analyze/walk.d.ts.map +1 -0
  65. package/dist/analyze/walk.js +50 -0
  66. package/dist/analyze/walk.js.map +1 -0
  67. package/dist/auth.d.ts +12 -0
  68. package/dist/auth.d.ts.map +1 -0
  69. package/dist/auth.js +61 -0
  70. package/dist/auth.js.map +1 -0
  71. package/dist/cli.d.ts +3 -0
  72. package/dist/cli.d.ts.map +1 -0
  73. package/dist/cli.js +787 -0
  74. package/dist/cli.js.map +1 -0
  75. package/dist/cloud/api.d.ts +20 -0
  76. package/dist/cloud/api.d.ts.map +1 -0
  77. package/dist/cloud/api.js +81 -0
  78. package/dist/cloud/api.js.map +1 -0
  79. package/dist/cloud/index.d.ts +4 -0
  80. package/dist/cloud/index.d.ts.map +1 -0
  81. package/dist/cloud/index.js +20 -0
  82. package/dist/cloud/index.js.map +1 -0
  83. package/dist/cloud/store.d.ts +34 -0
  84. package/dist/cloud/store.d.ts.map +1 -0
  85. package/dist/cloud/store.js +137 -0
  86. package/dist/cloud/store.js.map +1 -0
  87. package/dist/diff/history.d.ts +9 -0
  88. package/dist/diff/history.d.ts.map +1 -0
  89. package/dist/diff/history.js +44 -0
  90. package/dist/diff/history.js.map +1 -0
  91. package/dist/diff/index.d.ts +5 -0
  92. package/dist/diff/index.d.ts.map +1 -0
  93. package/dist/diff/index.js +26 -0
  94. package/dist/diff/index.js.map +1 -0
  95. package/dist/diff/model-diff.d.ts +44 -0
  96. package/dist/diff/model-diff.d.ts.map +1 -0
  97. package/dist/diff/model-diff.js +153 -0
  98. package/dist/diff/model-diff.js.map +1 -0
  99. package/dist/diff/snapshot.d.ts +8 -0
  100. package/dist/diff/snapshot.d.ts.map +1 -0
  101. package/dist/diff/snapshot.js +50 -0
  102. package/dist/diff/snapshot.js.map +1 -0
  103. package/dist/env.d.ts +2 -0
  104. package/dist/env.d.ts.map +1 -0
  105. package/dist/env.js +44 -0
  106. package/dist/env.js.map +1 -0
  107. package/dist/index.d.ts +7 -0
  108. package/dist/index.d.ts.map +1 -0
  109. package/dist/index.js +23 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/ir/naming.d.ts +12 -0
  112. package/dist/ir/naming.d.ts.map +1 -0
  113. package/dist/ir/naming.js +31 -0
  114. package/dist/ir/naming.js.map +1 -0
  115. package/dist/ir/types.d.ts +149 -0
  116. package/dist/ir/types.d.ts.map +1 -0
  117. package/dist/ir/types.js +72 -0
  118. package/dist/ir/types.js.map +1 -0
  119. package/dist/mcp/bench.d.ts +25 -0
  120. package/dist/mcp/bench.d.ts.map +1 -0
  121. package/dist/mcp/bench.js +115 -0
  122. package/dist/mcp/bench.js.map +1 -0
  123. package/dist/mcp/queries.d.ts +22 -0
  124. package/dist/mcp/queries.d.ts.map +1 -0
  125. package/dist/mcp/queries.js +147 -0
  126. package/dist/mcp/queries.js.map +1 -0
  127. package/dist/mcp/server.d.ts +2 -0
  128. package/dist/mcp/server.d.ts.map +1 -0
  129. package/dist/mcp/server.js +147 -0
  130. package/dist/mcp/server.js.map +1 -0
  131. package/dist/mcp/usage.d.ts +23 -0
  132. package/dist/mcp/usage.d.ts.map +1 -0
  133. package/dist/mcp/usage.js +125 -0
  134. package/dist/mcp/usage.js.map +1 -0
  135. package/dist/project/bpmn-parse.d.ts +17 -0
  136. package/dist/project/bpmn-parse.d.ts.map +1 -0
  137. package/dist/project/bpmn-parse.js +60 -0
  138. package/dist/project/bpmn-parse.js.map +1 -0
  139. package/dist/project/bpmn.d.ts +11 -0
  140. package/dist/project/bpmn.d.ts.map +1 -0
  141. package/dist/project/bpmn.js +89 -0
  142. package/dist/project/bpmn.js.map +1 -0
  143. package/dist/project/capability.d.ts +16 -0
  144. package/dist/project/capability.d.ts.map +1 -0
  145. package/dist/project/capability.js +38 -0
  146. package/dist/project/capability.js.map +1 -0
  147. package/dist/project/erd.d.ts +17 -0
  148. package/dist/project/erd.d.ts.map +1 -0
  149. package/dist/project/erd.js +0 -0
  150. package/dist/project/erd.js.map +1 -0
  151. package/dist/project/html.d.ts +12 -0
  152. package/dist/project/html.d.ts.map +1 -0
  153. package/dist/project/html.js +166 -0
  154. package/dist/project/html.js.map +1 -0
  155. package/dist/project/index.d.ts +19 -0
  156. package/dist/project/index.d.ts.map +1 -0
  157. package/dist/project/index.js +113 -0
  158. package/dist/project/index.js.map +1 -0
  159. package/dist/project/mermaid.d.ts +20 -0
  160. package/dist/project/mermaid.d.ts.map +1 -0
  161. package/dist/project/mermaid.js +89 -0
  162. package/dist/project/mermaid.js.map +1 -0
  163. package/dist/project/spec.d.ts +69 -0
  164. package/dist/project/spec.d.ts.map +1 -0
  165. package/dist/project/spec.js +164 -0
  166. package/dist/project/spec.js.map +1 -0
  167. package/dist/project/trust.d.ts +35 -0
  168. package/dist/project/trust.d.ts.map +1 -0
  169. package/dist/project/trust.js +48 -0
  170. package/dist/project/trust.js.map +1 -0
  171. package/dist/system.d.ts +61 -0
  172. package/dist/system.d.ts.map +1 -0
  173. package/dist/system.js +161 -0
  174. package/dist/system.js.map +1 -0
  175. package/package.json +58 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # Archmantic
2
+
3
+ **A living, *trustworthy* architecture model your whole team — and your AI agents — share.**
4
+
5
+ Point Archmantic at a repo and it reverse-engineers a single grounded **architecture model** (the IR). Every diagram is a *projection* of that one model, every element is traceable to `file:line`, and the same model answers your agent's questions over MCP. No drift between views, no ungrounded "AI diagram" guesswork.
6
+
7
+ > Status: **v1.0.0** — published as [`archmantic`](https://www.npmjs.com/package/archmantic). Dependency-light TypeScript CLI, dogfooded on this repo. Node 24 LTS · TypeScript 6 · NodeNext.
8
+
9
+ ---
10
+
11
+ ## Why it's different
12
+
13
+ Most tools pick one camp: agent code-graph tools emit symbols/calls (no human view, no business semantics), and diagram tools draw pretty pictures you can't trust or query. Archmantic does the parts both camps miss:
14
+
15
+ - **Capability map** — plain-English "what can this system do?", for PMs/architects/new hires, not just engineers.
16
+ - **BPMN business-process view** — auto-detected from code. White space nobody else occupies.
17
+ - **Provenance + confidence** — every element shows "grounded in N refs" and a confidence band; low-confidence is flagged. Verifiable, not plausible.
18
+ - **Drift detection** — "your committed model vs. the code" diff.
19
+ - **PR architecture diff** — how a change reshapes the architecture (not a line diff), postable as a PR comment.
20
+ - **Architecture history** — how the system's shape evolved, commit by commit.
21
+ - **Data model (ERD)** — entities, fields, and relations parsed from your Prisma schema, Drizzle tables, or SQL `CREATE TABLE` migrations, grounded to `file:line` and projected as a Mermaid ERD.
22
+ - **API surface** — REST routes (Next.js App Router/Pages, Express/Fastify/Koa/Hono), tRPC procedures, and GraphQL operations, grounded to `file:line` — the contract layer for humans and agents.
23
+ - **Multi-repo auto-linking** — across an org's repos, classifies cross-service links as connected, **inferred** (detected coupling not yet declared), or **dangling** (declared dependency on a repo that isn't there — a real gap).
24
+ - **One model → many audiences** — C4-style context, components, sequence (Mermaid), BPMN, an ERD, capability list, and an MCP surface for agents.
25
+ - **Token savings** — agents query the model over MCP instead of reading whole files (~98% fewer tokens on this repo, by the built-in benchmark).
26
+ - **Usage stats** — every MCP tool call is recorded with the tokens it saved; `archmantic usage` and the web `/usage` dashboard prove the model is earning its keep (and meter agent activity).
27
+
28
+ ## Quickstart
29
+
30
+ No install needed — run it straight from npm:
31
+
32
+ ```bash
33
+ npx archmantic analyze # reverse-engineer the model → .archmantic/model.json
34
+ npx archmantic view # capability map + diagrams + trust report → .archmantic/view.html
35
+ npx archmantic bench # token-savings benchmark (MCP vs raw file reads)
36
+ ```
37
+
38
+ Or install the CLI globally — then use the short `amt` alias:
39
+
40
+ ```bash
41
+ npm install -g archmantic
42
+ amt analyze # `amt` and `archmantic` are equivalent
43
+ ```
44
+
45
+ **From source** (for contributors):
46
+
47
+ ```bash
48
+ npm install && npm run build
49
+ node dist/cli.js analyze
50
+ ```
51
+
52
+ ## Commands
53
+
54
+ | Command | What it does |
55
+ |---|---|
56
+ | `init [name]` | Create an empty `.archmantic/model.json` |
57
+ | `analyze [--tier N]` | Reverse-engineer the model. `--tier 2` adds the LLM semantic pass (BYOK) |
58
+ | `update [--hook]` | Incrementally re-analyze only what changed (git-diff driven). `--hook` prints a pre-commit hook |
59
+ | `view` | Capability map, diagrams, and trust report; writes a self-contained `view.html` |
60
+ | `spec` | Emit an agent-ready **build spec** (`build-spec.md` + `.json`) from the model |
61
+ | `apply [--from f]` | Merge a human BPMN canvas edit back into the model — the "edit" of edit-then-build (fetches your saved cloud edit via token, or a local `.bpmn`) |
62
+ | `handoff [--apply] [--check "<cmd>"]` | Run the build spec through Claude (Opus 4.8, BYOK) → an implementation plan; **`--apply`** runs an autonomous agent loop that edits the repo **and self-verifies** (runs build + tests, fixes failures until green) — the "build" of edit-then-build. Commit first; review with `git diff`. |
63
+ | `drift [--check]` | Compare the committed model vs. the code; `--check` exits 1 on drift (CI gate) |
64
+ | `diff [<ref>]` | Architecture diff from a git ref → working tree; writes PR-comment-ready `pr-diff.md` |
65
+ | `log [-n N]` | Architecture history: how the architecture changed per commit |
66
+ | `system [name] --repos a,b,c` | Unified cross-service view across multiple repos (microservices / split front-back). Declare links per repo in `.archmantic/config.json` → `{ "system": "...", "consumes": ["other-service"] }` |
67
+ | `mcp` | Start the MCP server exposing the model to AI agents (stdio) |
68
+ | `bench [--exact]` | Token-savings benchmark; `--exact` uses the Anthropic token counter (BYOK) |
69
+ | `usage [--sync]` | MCP usage + token savings from the local log; `--sync` pushes it to the team cloud (web `/usage`) |
70
+
71
+ ## How it works
72
+
73
+ **Model-first.** Archmantic builds a canonical [Architecture Model (IR)](docs/ARCHITECTURE.md); diagrams and the MCP API are projections of it — so the views never drift apart.
74
+
75
+ **Tiered analysis, cheapest-first:**
76
+
77
+ | Tier | What | Cost |
78
+ |---|---|---|
79
+ | 0 | Repo structure & manifests → systems, components | free |
80
+ | 1 | TS/JS static analysis (TypeScript compiler API) → import/dependency graph | cheap, deterministic |
81
+ | 1.5 | Structural derivation → capabilities (exports), one process/flow (entry-point chain) | deterministic |
82
+ | 2 | LLM semantic pass — Haiku for summaries, Opus for flow synthesis | metered tokens, opt-in (BYOK) |
83
+
84
+ **Provenance invariant:** every derived element carries `provenance` (`file:line`) and `confidence`. The LLM pass only *refines prose and raises confidence* on already-grounded elements — it never invents structure. Nothing ungrounded gets in.
85
+
86
+ ## Use it with your AI agent (MCP)
87
+
88
+ This repo ships a project [`.mcp.json`](.mcp.json). In Claude Code / Cursor, approve the **archmantic** server, then your agent can:
89
+
90
+ - **Read** the model: `get_context`, `search_capabilities`, `get_component`, `get_process`, `whats_related`, `list_components`, `get_sequence`.
91
+ - **Keep it live:** `refresh` (re-analyze from disk after a change) and `sync` (re-analyze **and push to the team cloud**, org-scoped). So when you ask the agent to change something, it can update the shared architecture model in the same flow — no manual `push`.
92
+
93
+ The MCP server reads credentials from `.env.local` (so `sync` uses your `ARCHMANTIC_TOKEN`). For fully hands-free syncing, add a Claude Code **Stop hook** that runs `archmantic update && archmantic push` after each turn.
94
+
95
+ ## Team cloud knowledge (shared model)
96
+
97
+ Share the architecture model across a team. `push`/`pull`/`cloud-log` work in **two modes**:
98
+
99
+ ```bash
100
+ node dist/cli.js push # upload the model under the current commit
101
+ node dist/cli.js pull # fetch the team's latest shared model into .archmantic/
102
+ node dist/cli.js cloud-log # list the per-commit snapshots in the cloud (direct mode)
103
+ ```
104
+
105
+ | Mode | Auth | For |
106
+ |---|---|---|
107
+ | **Self-host (free)** | `DATABASE_URL` in `.env.local` — writes Neon directly | OSS users / your own infra |
108
+ | **Managed SaaS** | `ARCHMANTIC_TOKEN` (+ `ARCHMANTIC_API_URL`) — pushes through the platform's authenticated, **org-scoped** API | teams / customers |
109
+
110
+ Mint a SaaS token from the web app's **Settings** page (signed in, in your org); it tags every push with your organization, so customers never hold the raw database URL. The committed `.archmantic/model.json` stays the source of truth; the cloud holds a **per-commit history** powering the team timeline and the web viewer.
111
+
112
+ ## CI: architecture diff on every PR
113
+
114
+ A reusable GitHub Action comments on each PR with the **architecture-level** delta — new/removed components, capabilities, data-model entities, and external systems — not a line diff. It posts a single sticky comment and updates it on every push.
115
+
116
+ ```yaml
117
+ # .github/workflows/architecture-diff.yml
118
+ name: Architecture diff
119
+ on: pull_request
120
+ permissions:
121
+ contents: read
122
+ pull-requests: write
123
+ jobs:
124
+ diff:
125
+ runs-on: ubuntu-latest
126
+ steps:
127
+ - uses: actions/checkout@v4
128
+ with:
129
+ fetch-depth: 0 # so the base ref can be analyzed
130
+ - uses: mgionas/Archmantic@v1 # the reusable action (action.yml)
131
+ ```
132
+
133
+ Inputs: `base-ref` (default: the PR base branch), `working-directory` (default `.`), `version` (default `latest`), `comment` (default `true`), `github-token` (default `${{ github.token }}`). It runs `archmantic diff` under the hood, so no install step is needed.
134
+
135
+ ## Tier 2 (LLM) & credentials
136
+
137
+ The LLM pass (`analyze --tier 2`) and `bench --exact` are **BYOK** and gated. Authenticate either way:
138
+
139
+ - **API key** — set `ANTHROPIC_API_KEY` in `.env.local` (gitignored), or
140
+ - **CLI login (OAuth)** — `ant auth login` (the Anthropic CLI); Archmantic picks up the session token automatically.
141
+
142
+ Without a credential, those paths skip gracefully and everything else runs fully offline.
143
+
144
+ ## Web platform (`web/`)
145
+
146
+ A read-only architecture viewer over the shared Neon store — Next.js (App Router), deployable to Vercel.
147
+
148
+ ```bash
149
+ cd web
150
+ npm install
151
+ echo 'DATABASE_URL="<your Neon URL>"' > .env.local # same URL as the CLI
152
+ npm run dev # http://localhost:3000 — project list + capability map + trust
153
+ ```
154
+
155
+ Deploy: import `web/` as the Vercel project root and set `DATABASE_URL` as an environment variable. Pages are server-rendered on demand (no build-time DB access).
156
+
157
+ ## Roadmap
158
+
159
+ The team **cloud knowledge** layer is taking shape: shared model across a team (`push`/`pull`), the CI architecture-diff bot ([already included](.github/workflows/architecture-diff.yml)), and the web platform above. Next: diagram rendering (Mermaid/BPMN) in the web viewer, an editable `bpmn-js` canvas, auth/multi-tenant, and the edit-then-build loop.
160
+
161
+ See [`docs/MVP_PLAN.md`](docs/MVP_PLAN.md), [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md), and [`docs/CONCEPT.md`](docs/CONCEPT.md).
162
+
163
+ ## License & model
164
+
165
+ Archmantic is **open-SaaS**:
166
+
167
+ - The **CLI & engine** (`/src`) are **Apache-2.0** ([`LICENSE`](LICENSE)) — free, local-first, your code never leaves your machine.
168
+ - The **web platform** (`/web`) is **AGPL-3.0** ([`web/LICENSE`](web/LICENSE)) — source-available.
169
+ - **Free** includes the full CLI + MCP + self-host (BYO database) + BYOK AI, and managed cloud for **up to 3 seats**.
170
+ - Paid: **Team** (per seat), **Managed AI** (metered — no-BYOK Tier-2 / `handoff` / autonomous build), **Enterprise** (SSO/RBAC/audit/on-prem/SLA).
171
+
172
+ Full business model: [`docs/STRATEGY.md`](docs/STRATEGY.md).
@@ -0,0 +1,20 @@
1
+ export interface HandoffResult {
2
+ ran: boolean;
3
+ reason?: string;
4
+ plan?: string;
5
+ inputTokens: number;
6
+ outputTokens: number;
7
+ estCostUsd: number;
8
+ }
9
+ export declare function runHandoff(specMarkdown: string, project: string): Promise<HandoffResult>;
10
+ export interface BuildResult extends HandoffResult {
11
+ filesChanged: string[];
12
+ turns: number;
13
+ summary?: string;
14
+ checkPassed?: boolean;
15
+ checkOutput?: string;
16
+ }
17
+ /** Autonomous build: agent reads/writes files in `root` to execute the plan, then
18
+ * self-verifies via the check command, fixing failures until green (or a cap). */
19
+ export declare function runAutonomousBuild(root: string, plan: string, project: string, checkCommand: string): Promise<BuildResult>;
20
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAMD,wBAAsB,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAgC9F;AAQD,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAiGD;mFACmF;AACnF,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,WAAW,CAAC,CAgFtB"}
package/dist/agent.js ADDED
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runHandoff = runHandoff;
7
+ exports.runAutonomousBuild = runAutonomousBuild;
8
+ /**
9
+ * Agent hand-off — the "build" of edit-then-build. Runs the Archmantic build
10
+ * spec through Claude (Opus 4.8, BYOK) to produce a concrete implementation plan
11
+ * a coding agent (e.g. Claude Code) can execute to realize the architecture.
12
+ *
13
+ * Read-only: it produces a plan, it does not edit the repo. Gated on an
14
+ * Anthropic credential (API key or `ant auth login`), like the Tier-2 pass.
15
+ */
16
+ const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
17
+ const node_fs_1 = require("node:fs");
18
+ const node_child_process_1 = require("node:child_process");
19
+ const node_path_1 = require("node:path");
20
+ const auth_js_1 = require("./auth.js");
21
+ const OPUS = "claude-opus-4-8";
22
+ /** USD per 1M tokens [input, output] for Opus 4.8. */
23
+ const PRICING = [5.0, 25.0];
24
+ const SYSTEM = `You are a senior software engineer receiving an Archmantic "build spec" — the intended architecture of a repository, derived from its code and grounded in file:line references (capabilities, components with responsibilities and dependencies, external systems, and a business process).
25
+
26
+ Produce a concrete, ordered implementation plan that a coding agent can execute to make the codebase realize this architecture. For each step: name the specific files/components to add or change, the dependencies involved, and why. Call out likely gaps between the spec and the current code, and a final verification step. Be actionable and concise. Output Markdown only — no preamble.`;
27
+ async function runHandoff(specMarkdown, project) {
28
+ if (!(0, auth_js_1.hasAnthropicCredentials)()) {
29
+ return { ran: false, reason: `${auth_js_1.NO_CREDENTIAL_HINT} (agent hand-off skipped)`, inputTokens: 0, outputTokens: 0, estCostUsd: 0 };
30
+ }
31
+ const client = new sdk_1.default();
32
+ try {
33
+ const resp = await client.messages.create({
34
+ model: OPUS,
35
+ max_tokens: 8192,
36
+ system: SYSTEM,
37
+ thinking: { type: "adaptive" },
38
+ messages: [{ role: "user", content: `Build spec for "${project}":\n\n${specMarkdown}` }],
39
+ });
40
+ const plan = resp.content
41
+ .filter((b) => b.type === "text")
42
+ .map((b) => b.text)
43
+ .join("\n")
44
+ .trim();
45
+ const u = resp.usage;
46
+ return {
47
+ ran: true,
48
+ plan,
49
+ inputTokens: u.input_tokens,
50
+ outputTokens: u.output_tokens,
51
+ estCostUsd: (u.input_tokens * PRICING[0] + u.output_tokens * PRICING[1]) / 1_000_000,
52
+ };
53
+ }
54
+ catch (err) {
55
+ if (err instanceof sdk_1.default.AuthenticationError) {
56
+ return { ran: false, reason: `Anthropic authentication failed — ${auth_js_1.NO_CREDENTIAL_HINT}`, inputTokens: 0, outputTokens: 0, estCostUsd: 0 };
57
+ }
58
+ throw err;
59
+ }
60
+ }
61
+ // ── Autonomous build: a tool-use agent loop that edits the repo ───────────────
62
+ const MAX_TURNS = 40;
63
+ const MAX_VERIFY_ROUNDS = 3;
64
+ const IGNORE_DIRS = new Set(["node_modules", ".git", "dist", ".next", ".archmantic", "out-tsc", ".vercel"]);
65
+ /** Run the project's verification command (build/tests) and capture its output. */
66
+ function runCheck(root, cmd) {
67
+ try {
68
+ const out = (0, node_child_process_1.execSync)(`${cmd} 2>&1`, { cwd: root, encoding: "utf8", timeout: 300_000, maxBuffer: 10 * 1024 * 1024 });
69
+ return { ok: true, output: out.slice(-4000) };
70
+ }
71
+ catch (err) {
72
+ const e = err;
73
+ return { ok: false, output: `${e.stdout ?? ""}${e.stderr ?? ""}${e.message ?? ""}`.slice(-4000) };
74
+ }
75
+ }
76
+ /** Resolve a model-provided path inside the repo; reject escapes and heavy dirs. */
77
+ function safePath(root, p) {
78
+ const abs = (0, node_path_1.resolve)(root, p);
79
+ const base = (0, node_path_1.resolve)(root);
80
+ if (abs !== base && !abs.startsWith(base + node_path_1.sep))
81
+ return null; // outside the repo
82
+ const rel = (0, node_path_1.relative)(base, abs);
83
+ if (rel.split(node_path_1.sep).some((seg) => IGNORE_DIRS.has(seg)))
84
+ return null;
85
+ return abs;
86
+ }
87
+ function listFiles(root, dir) {
88
+ const start = safePath(root, dir || ".");
89
+ if (!start)
90
+ return "error: path outside repo";
91
+ const out = [];
92
+ const stack = [start];
93
+ const baseAbs = (0, node_path_1.resolve)(root);
94
+ while (stack.length && out.length < 600) {
95
+ const cur = stack.pop();
96
+ let entries;
97
+ try {
98
+ entries = (0, node_fs_1.readdirSync)(cur, { withFileTypes: true });
99
+ }
100
+ catch {
101
+ continue;
102
+ }
103
+ for (const e of entries) {
104
+ const abs = (0, node_path_1.join)(cur, e.name);
105
+ if (e.isDirectory()) {
106
+ if (IGNORE_DIRS.has(e.name) || e.name.startsWith("."))
107
+ continue;
108
+ stack.push(abs);
109
+ }
110
+ else {
111
+ out.push((0, node_path_1.relative)(baseAbs, abs).split("\\").join("/"));
112
+ }
113
+ }
114
+ }
115
+ return out.sort().join("\n") || "(empty)";
116
+ }
117
+ const TOOLS = [
118
+ { name: "list_files", description: "List repository files (relative paths).", input_schema: { type: "object", properties: { dir: { type: "string", description: "optional subdirectory" } } } },
119
+ { name: "read_file", description: "Read a file's contents.", input_schema: { type: "object", properties: { path: { type: "string" } }, required: ["path"] } },
120
+ { name: "write_file", description: "Create or overwrite a file with the given content.", input_schema: { type: "object", properties: { path: { type: "string" }, content: { type: "string" } }, required: ["path", "content"] } },
121
+ { name: "run_check", description: "Run the project's verification (build + tests) and return the output. Use this after changes and fix any failures.", input_schema: { type: "object", properties: {} } },
122
+ ];
123
+ const BUILD_SYSTEM = `You are a careful coding agent operating inside a repository. You are given an Archmantic build plan/spec. Use the tools to read existing files and make the MINIMAL, correct changes needed to realize the plan. Prefer editing existing files over adding new ones. Do not touch generated/vendor files.
124
+
125
+ After making changes, call run_check to build and test the project. If it fails, read the output, fix the problem, and run_check again — repeat until it passes. When the work is complete and run_check passes (or there is nothing to change), stop calling tools and reply with a short summary of what you changed and why.`;
126
+ function runTool(root, name, input, changed, checkCommand) {
127
+ try {
128
+ if (name === "list_files")
129
+ return { text: listFiles(root, String(input.dir ?? "")) };
130
+ if (name === "run_check") {
131
+ process.stderr.write(` ⚙ run_check: ${checkCommand}\n`);
132
+ const { ok, output } = runCheck(root, checkCommand);
133
+ return { text: `exit ${ok ? 0 : 1}\n${output}` };
134
+ }
135
+ if (name === "read_file") {
136
+ const abs = safePath(root, String(input.path));
137
+ if (!abs)
138
+ return { text: "error: path outside repo", isError: true };
139
+ if (!(0, node_fs_1.existsSync)(abs))
140
+ return { text: "error: file not found", isError: true };
141
+ return { text: (0, node_fs_1.readFileSync)(abs, "utf8") };
142
+ }
143
+ if (name === "write_file") {
144
+ const rel = String(input.path);
145
+ const abs = safePath(root, rel);
146
+ if (!abs)
147
+ return { text: "error: path outside repo or in an ignored dir", isError: true };
148
+ (0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(abs), { recursive: true });
149
+ (0, node_fs_1.writeFileSync)(abs, String(input.content ?? ""), "utf8");
150
+ changed.add(rel);
151
+ process.stderr.write(` ✎ wrote ${rel}\n`);
152
+ return { text: `wrote ${rel}` };
153
+ }
154
+ return { text: `unknown tool ${name}`, isError: true };
155
+ }
156
+ catch (err) {
157
+ return { text: `error: ${err instanceof Error ? err.message : String(err)}`, isError: true };
158
+ }
159
+ }
160
+ /** Autonomous build: agent reads/writes files in `root` to execute the plan, then
161
+ * self-verifies via the check command, fixing failures until green (or a cap). */
162
+ async function runAutonomousBuild(root, plan, project, checkCommand) {
163
+ const base = { ran: false, filesChanged: [], turns: 0, inputTokens: 0, outputTokens: 0, estCostUsd: 0 };
164
+ if (!(0, auth_js_1.hasAnthropicCredentials)()) {
165
+ return { ...base, reason: `${auth_js_1.NO_CREDENTIAL_HINT} (autonomous build skipped)` };
166
+ }
167
+ const client = new sdk_1.default();
168
+ const changed = new Set();
169
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
170
+ const messages = [
171
+ { role: "user", content: `Implement this build plan in the repo "${project}". The verification command is: ${checkCommand}\n\n${plan}` },
172
+ ];
173
+ let summary = "";
174
+ let inTok = 0;
175
+ let outTok = 0;
176
+ let turns = 0;
177
+ let verifyRounds = 0;
178
+ let check = { ok: false, output: "" };
179
+ try {
180
+ for (; turns < MAX_TURNS; turns++) {
181
+ const resp = await client.messages.create({
182
+ model: OPUS,
183
+ max_tokens: 16000,
184
+ system: BUILD_SYSTEM,
185
+ thinking: { type: "adaptive" },
186
+ tools: TOOLS,
187
+ messages,
188
+ });
189
+ inTok += resp.usage.input_tokens;
190
+ outTok += resp.usage.output_tokens;
191
+ messages.push({ role: "assistant", content: resp.content });
192
+ const toolUses = resp.content.filter((b) => b.type === "tool_use");
193
+ if (resp.stop_reason !== "tool_use" || toolUses.length === 0) {
194
+ summary = resp.content
195
+ .filter((b) => b.type === "text")
196
+ .map((b) => b.text)
197
+ .join("\n")
198
+ .trim();
199
+ // Guarantee: verify on stop. If it changed files and the check fails,
200
+ // hand the failure back and let it fix — up to MAX_VERIFY_ROUNDS.
201
+ if (changed.size === 0)
202
+ break;
203
+ check = runCheck(root, checkCommand);
204
+ process.stderr.write(` ⚙ verify (${checkCommand}): ${check.ok ? "passed" : "FAILED"}\n`);
205
+ if (check.ok || verifyRounds >= MAX_VERIFY_ROUNDS)
206
+ break;
207
+ verifyRounds++;
208
+ messages.push({
209
+ role: "user",
210
+ content: `The verification command \`${checkCommand}\` failed. Fix the issues and run_check again until it passes.\n\n${check.output}`,
211
+ });
212
+ continue;
213
+ }
214
+ const results = toolUses.map((tu) => {
215
+ const r = runTool(root, tu.name, tu.input, changed, checkCommand);
216
+ return { type: "tool_result", tool_use_id: tu.id, content: r.text, is_error: r.isError };
217
+ });
218
+ messages.push({ role: "user", content: results });
219
+ }
220
+ }
221
+ catch (err) {
222
+ if (err instanceof sdk_1.default.AuthenticationError) {
223
+ return { ...base, reason: `Anthropic authentication failed — ${auth_js_1.NO_CREDENTIAL_HINT}` };
224
+ }
225
+ throw err;
226
+ }
227
+ return {
228
+ ran: true,
229
+ filesChanged: [...changed],
230
+ turns,
231
+ summary,
232
+ checkPassed: changed.size === 0 ? undefined : check.ok,
233
+ checkOutput: check.output ? check.output.slice(-1500) : undefined,
234
+ inputTokens: inTok,
235
+ outputTokens: outTok,
236
+ estCostUsd: (inTok * PRICING[0] + outTok * PRICING[1]) / 1_000_000,
237
+ };
238
+ }
239
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;;;;AA+BA,gCAgCC;AAiHD,gDAqFC;AArQD;;;;;;;GAOG;AACH,4DAA0C;AAC1C,qCAA0F;AAC1F,2DAA8C;AAC9C,yCAAkE;AAClE,uCAAwE;AAExE,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAC/B,sDAAsD;AACtD,MAAM,OAAO,GAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAW9C,MAAM,MAAM,GAAG;;kYAEmX,CAAC;AAE5X,KAAK,UAAU,UAAU,CAAC,YAAoB,EAAE,OAAe;IACpE,IAAI,CAAC,IAAA,iCAAuB,GAAE,EAAE,CAAC;QAC/B,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,4BAAkB,2BAA2B,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;IAClI,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,aAAS,EAAE,CAAC;IAC/B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;YACxC,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;YAC9B,QAAQ,EAAE,CAAC,EAAE,I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