arclith-cli 0.7.1__tar.gz → 0.10.0__tar.gz

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 (32) hide show
  1. arclith_cli-0.10.0/LICENSE +180 -0
  2. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/PKG-INFO +3 -2
  3. arclith_cli-0.10.0/README.md +264 -0
  4. arclith_cli-0.10.0/arclith_cli/__init__.py +1 -0
  5. arclith_cli-0.10.0/arclith_cli/adapter_templates.py +194 -0
  6. arclith_cli-0.10.0/arclith_cli/add_adapter.py +609 -0
  7. arclith_cli-0.10.0/arclith_cli/capabilities.py +543 -0
  8. arclith_cli-0.10.0/arclith_cli/core_scaffold.py +165 -0
  9. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/arclith_cli/entity_scanner.py +6 -5
  10. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/arclith_cli/main.py +160 -5
  11. arclith_cli-0.10.0/arclith_cli/project_paths.py +65 -0
  12. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/arclith_cli/rename.py +45 -13
  13. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/arclith_cli/scaffold.py +17 -2
  14. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/arclith_cli/updater.py +1 -3
  15. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/pyproject.toml +8 -3
  16. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/tests/e2e_manual.sh +18 -6
  17. arclith_cli-0.10.0/tests/test_add_adapter.py +393 -0
  18. arclith_cli-0.10.0/tests/test_capabilities.py +172 -0
  19. arclith_cli-0.10.0/tests/test_core_scaffold.py +91 -0
  20. arclith_cli-0.10.0/tests/test_e2e_scaffold.py +302 -0
  21. arclith_cli-0.10.0/tests/test_project_paths.py +43 -0
  22. arclith_cli-0.10.0/tests/test_rename.py +43 -0
  23. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/uv.lock +116 -8
  24. arclith_cli-0.7.1/README.md +0 -139
  25. arclith_cli-0.7.1/arclith_cli/__init__.py +0 -2
  26. arclith_cli-0.7.1/arclith_cli/adapter_templates.py +0 -173
  27. arclith_cli-0.7.1/arclith_cli/add_adapter.py +0 -288
  28. arclith_cli-0.7.1/tests/test_e2e_scaffold.py +0 -148
  29. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/.gitignore +0 -0
  30. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/Makefile +0 -0
  31. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/arclith_cli/export_config.py +0 -0
  32. {arclith_cli-0.7.1 → arclith_cli-0.10.0}/tests/__init__.py +0 -0
@@ -0,0 +1,180 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and its Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of developing and
55
+ refining the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent contributions
76
+ Licensable by such Contributor that are necessarily infringed by
77
+ their Contribution(s) alone or by the combination of their
78
+ Contribution(s) with the Work to which such Contribution(s) was
79
+ submitted. If You institute patent litigation against any entity
80
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
81
+ the Work or any Contribution embodied within the Work constitutes
82
+ direct or contributory patent infringement, then any patent licenses
83
+ granted to You under this License for that Work shall terminate as
84
+ of the date such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or in addition to the
115
+ NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, copy, modify, merge,
120
+ publish, distribute, sublicense, and/or sell copies of the Work.
121
+
122
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
123
+ any Contribution intentionally submitted for inclusion in the Work
124
+ by You to the Licensor shall be under the terms and conditions of
125
+ this License, without any additional terms or conditions.
126
+ Notwithstanding the above, nothing herein shall supersede or modify
127
+ the terms of any separate license agreement you may have executed
128
+ with Licensor regarding such Contributions.
129
+
130
+ 6. Trademarks. This License does not grant permission to use the trade
131
+ names, trademarks, service marks, or product names of the Licensor,
132
+ except as required for reasonable and customary use in describing the
133
+ origin of the Work and reproducing the content of the NOTICE file.
134
+
135
+ 7. Disclaimer of Warranty. Unless required by applicable law or
136
+ agreed to in writing, Licensor provides the Work (and each
137
+ Contributor provides its Contributions) on an "AS IS" BASIS,
138
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
139
+ implied, including, without limitation, any warranties or conditions
140
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
141
+ PARTICULAR PURPOSE. You are solely responsible for determining the
142
+ appropriateness of using or reproducing the Work and assume any
143
+ risks associated with Your exercise of permissions under this License.
144
+
145
+ 8. Limitation of Liability. In no event and under no legal theory,
146
+ whether in tort (including negligence), contract, or otherwise,
147
+ unless required by applicable law (such as deliberate and grossly
148
+ negligent acts) or agreed to in writing, shall any Contributor be
149
+ liable to You for damages, including any direct, indirect, special,
150
+ incidental, or exemplary damages of any character arising as a
151
+ result of this License or out of the use or inability to use the
152
+ Work (including but not limited to damages for loss of goodwill,
153
+ work stoppage, computer failure or malfunction, or all other
154
+ commercial damages or losses), even if such Contributor has been
155
+ advised of the possibility of such damages.
156
+
157
+ 9. Accepting Warranty or Liability. While redistributing the Work or
158
+ Derivative Works thereof, You may choose to offer, and charge a fee
159
+ for, acceptance of support, warranty, indemnity, or other liability
160
+ obligations and/or rights consistent with this License. However, in
161
+ accepting such obligations, You may offer only conditions that
162
+ You alone are responsible for, and not on behalf of any other
163
+ Contributor.
164
+
165
+ END OF TERMS AND CONDITIONS
166
+
167
+ Copyright 2026 Killian KOPP
168
+
169
+ Licensed under the Apache License, Version 2.0 (the "License");
170
+ you may not use this file except in compliance with the License.
171
+ You may obtain a copy of the License at
172
+
173
+ http://www.apache.org/licenses/LICENSE-2.0
174
+
175
+ Unless required by applicable law or agreed to in writing, software
176
+ distributed under the License is distributed on an "AS IS" BASIS,
177
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
178
+ See the License for the specific language governing permissions and
179
+ limitations under the License.
180
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arclith-cli
3
- Version: 0.7.1
3
+ Version: 0.10.0
4
4
  Summary: CLI scaffolding tool for arclith — hexagonal architecture framework
5
5
  Author-email: Killian KOPP <killiankopp@gmail.com>
6
6
  License: Apache License
@@ -183,9 +183,10 @@ License: Apache License
183
183
  See the License for the specific language governing permissions and
184
184
  limitations under the License.
185
185
 
186
+ License-File: LICENSE
186
187
  Keywords: arclith,cli,ddd,hexagonal-architecture,scaffold
187
188
  Requires-Python: >=3.13
188
- Requires-Dist: arclith>=0.7.0
189
+ Requires-Dist: arclith>=0.13.0
189
190
  Requires-Dist: httpx>=0.27.0
190
191
  Requires-Dist: rich>=13.0.0
191
192
  Requires-Dist: typer>=0.15.0
@@ -0,0 +1,264 @@
1
+ # arclith-cli
2
+
3
+ `arclith-cli` génère instantanément un projet Python en architecture hexagonale prêt à démarrer, en téléchargeant le template officiel `_sample` depuis GitHub et en remplaçant l'entité de démo `Ingredient` par le nom de votre choix. Tout type de projet peut être scaffoldé — service REST, agent IA, API MCP — avec les ports, le nom de projet et le backend de persistance configurés d'emblée.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ uv tool install "git+https://github.com/karned-rekipe/arclith.git#subdirectory=cli"
9
+ ```
10
+
11
+ ## Commandes
12
+
13
+ ### `new` — Créer un projet
14
+
15
+ Scaffold un nouveau projet arclith depuis le template officiel `_sample`.
16
+
17
+ ```bash
18
+ # Mode interactif — l'outil pose les questions
19
+ arclith-cli new
20
+
21
+ # Mode direct
22
+ arclith-cli new Recipe my-recipe-service
23
+ arclith-cli new RecipeStep meal-planner --port 8400
24
+ arclith-cli new MealPlan meal-plan-service --dir ~/projects --port 8500
25
+ ```
26
+
27
+ | Option | Défaut | Description |
28
+ |--------|--------|-------------|
29
+ | `--port` / `-p` | `8000` | Port REST (MCP = port+1) |
30
+ | `--dir` / `-d` | `.` | Répertoire parent |
31
+ | `--ref` | `main` | Branche/tag du template |
32
+
33
+ Le projet généré utilise un layout `src/<package>/...` pour le code applicatif et un dossier `config/` structuré par adapter (voir section [Configuration](#configuration)).
34
+
35
+ ---
36
+
37
+ ### `add-entity` — Ajouter une entité métier
38
+
39
+ Crée uniquement le fichier minimal d'une entité dans `src/<package>/domain/models/`.
40
+
41
+ ```bash
42
+ cd my-recipe-service
43
+ arclith-cli add-entity ShoppingItem
44
+ ```
45
+
46
+ Fichier généré :
47
+
48
+ ```text
49
+ src/<package>/domain/models/shopping_item.py
50
+ ```
51
+
52
+ La commande ne génère aucun CRUD, aucun port repository, aucun adapter et aucun endpoint. Elle pose seulement le point d'ancrage du modèle métier ; le développeur complète ensuite les champs et invariants de l'entité.
53
+
54
+ ---
55
+
56
+ ### `add-usecase` — Ajouter un cas d'usage
57
+
58
+ Crée uniquement le fichier minimal d'un cas d'usage dans `src/<package>/application/use_cases/`.
59
+
60
+ ```bash
61
+ cd my-recipe-service
62
+ arclith-cli add-usecase PlanShoppingList
63
+ arclith-cli add-usecase find-by-name
64
+ ```
65
+
66
+ Fichier généré :
67
+
68
+ ```text
69
+ src/<package>/application/use_cases/plan_shopping_list.py
70
+ ```
71
+
72
+ Le nom peut être fourni en PascalCase, snake_case ou kebab-case. Le suffixe `UseCase` est normalisé : `PlanShoppingListUseCase` et `plan-shopping-list-use-case` génèrent tous les deux `PlanShoppingListUseCase`.
73
+
74
+ Comme `add-entity`, cette commande ne câble pas FastAPI, FastMCP, LangGraph, un repository ou un service. Les adapters se branchent ensuite explicitement avec `add-adapter`.
75
+
76
+ ---
77
+
78
+ ### `add-adapter` — Ajouter un adapter
79
+
80
+ Wizard interactif à lancer **depuis la racine du projet cible**. Scaffold le code Python et/ou les fichiers de configuration pour un nouvel adapter. Par défaut, la capacité cible est `repository`.
81
+
82
+ ```bash
83
+ cd my-recipe-service
84
+ arclith-cli add-adapter
85
+ ```
86
+
87
+ Mode direct, utile pour CI, scripts de migration ou commandes reproductibles :
88
+
89
+ ```bash
90
+ arclith-cli add-adapter --adapter mongodb --entity Recipe --db-name my_recipe_service --yes
91
+ arclith-cli add-adapter --adapter duckdb --all-entities --path data/ --no-activate --yes
92
+ arclith-cli add-adapter --adapter mariadb --entity Recipe --param database=my_recipe_service --param user=app --yes
93
+ arclith-cli add-adapter --capability api --adapter fastapi --param port=8080 --yes
94
+ arclith-cli add-adapter --capability mcp --adapter fastmcp --param port=8081 --yes
95
+ arclith-cli add-adapter --capability agent --adapter langgraph --param graph_name=recipe_agent --yes
96
+ arclith-cli add-adapter --capability observability --adapter langsmith
97
+ arclith-cli add-adapter --capability observability --adapter opentelemetry --param service_name=my_recipe_service --yes
98
+ arclith-cli add-adapter --capability repository --adapter memory --entity Recipe --yes
99
+ ```
100
+
101
+ **Étapes du wizard :**
102
+
103
+ 1. **Type d'adapter** — selon la capacité : `memory` · `mongodb` · `duckdb` · `mariadb` · `fastapi` · `fastmcp` · `langgraph` · `langsmith` · `opentelemetry`
104
+ 2. **Entité(s) cible(s)** — détectées automatiquement pour les adapters entity-scoped ; ignorées pour les transports globaux, `agent/langgraph` et les adapters d'observability
105
+ 3. **Paramètres** — questions spécifiques à l'adapter :
106
+ - `mongodb` → `db_name`, `multitenant`
107
+ - `duckdb` → `path`
108
+ - `mariadb` → `host`, `port`, `database`, `user`, `driver`, `table_prefix`
109
+ - `fastapi` → `host`, `port`, `reload`
110
+ - `fastmcp` → `host`, `port`
111
+ - `langgraph` → `graph_name`
112
+ - `langsmith` → `tracing`, `project`, `endpoint`, `LANGSMITH_API_KEY`
113
+ - `opentelemetry` → `service_name`, `endpoint`, `protocol`, `traces`, `metrics`, `instrument_fastapi`
114
+ - `memory` → aucun paramètre
115
+ 4. **Activation** — met à jour `config/adapters/adapters.yaml` pour les capacités à sélecteur (`repository: <adapter>` ou `observability: <adapter>`) ; `api/fastapi`, `mcp/fastmcp` et `agent/langgraph` sont exposés par leurs fichiers `config/adapters/inbound/*.yaml`
116
+ 5. **Récapitulatif** — liste des fichiers créés ou remplacés avant confirmation
117
+
118
+ | Option | Défaut | Description |
119
+ |--------|--------|-------------|
120
+ | `--capability` | `repository` | Capacité cible du catalogue standardisé (`repository`, `api`, `mcp`, `agent`, `observability`) |
121
+ | `--adapter` / `-a` | interactif | Adapter du catalogue : `memory`, `mongodb`, `duckdb`, `mariadb`, `fastapi`, `fastmcp`, `langgraph`, `langsmith`, `opentelemetry` |
122
+ | `--entity` / `-e` | auto si une seule entité | Entité cible, liste séparée par virgule acceptée |
123
+ | `--all-entities` | `false` | Génère l'adapter pour toutes les entités détectées |
124
+ | `--activate/--no-activate` | `--activate` | Met à jour `config/adapters/adapters.yaml` quand la capacité expose une clé d'activation |
125
+ | `--db-name` | nom du projet | Nom de base pour MongoDB |
126
+ | `--multitenant/--single-tenant` | `--single-tenant` | Mode MongoDB multitenant |
127
+ | `--path` | `data/` | Chemin DuckDB |
128
+ | `--param` | - | Paramètre adapter `key=value`, répétable pour les adapters du catalogue |
129
+ | `--yes` / `-y` | `false` | Skip la confirmation et utilise les valeurs fournies ou par défaut |
130
+
131
+ **Fichiers générés par entité :**
132
+
133
+ ```
134
+ config/adapters/outbound/<adapter>.yaml # config scopée si l'adapter en a besoin
135
+ src/<package>/adapters/outbound/<adapter>/__init__.py
136
+ src/<package>/adapters/outbound/<adapter>/repository.py # re-export
137
+ src/<package>/adapters/outbound/<adapter>/repositories/<entity>_repository.py # sous-classe à compléter
138
+ src/<package>/infrastructure/containers/<entity>_container.py # RepositoryRegistry régénéré
139
+ ```
140
+
141
+ > ⚠️ `src/<package>/infrastructure/containers/<entity>_container.py` est **régénéré intégralement** si le fichier existe déjà — un avertissement est affiché dans le récapitulatif.
142
+
143
+ **LangGraph / LangSmith :**
144
+
145
+ ```bash
146
+ uv add "arclith[langgraph]"
147
+ arclith-cli add-adapter --capability agent --adapter langgraph
148
+ arclith-cli add-adapter --capability observability --adapter langsmith
149
+ uv run langgraph dev --no-browser --allow-blocking --port 2024
150
+ ```
151
+
152
+ L'adapter `agent/langgraph` génère `langgraph.json`, `config/adapters/inbound/langgraph.yaml` et
153
+ `src/<package>/adapters/inbound/langgraph/agent.py`. Le projet ne modifie ensuite que ce fichier pour
154
+ son agent. Comme `fastapi` et `fastmcp`, LangGraph est configuré par son nom produit dans
155
+ `AppConfig.langgraph`, sans `adapters.agent`. L'adapter `observability/langsmith` génère
156
+ `config/adapters/outbound/langsmith.yaml`, met
157
+ à jour `.env` et ajoute `.env` au `.gitignore` si besoin. LangSmith Studio devient l'endroit standard
158
+ pour tester les agents. Une `LANGSMITH_API_KEY` déjà présente est conservée si aucune nouvelle valeur
159
+ n'est fournie.
160
+
161
+ **OpenTelemetry :**
162
+
163
+ ```bash
164
+ uv add "arclith[opentelemetry]"
165
+ arclith-cli add-adapter --capability observability --adapter opentelemetry --param service_name=my-recipe-service --yes
166
+ ```
167
+
168
+ L'adapter `observability/opentelemetry` génère `config/adapters/outbound/opentelemetry.yaml`, met à
169
+ jour `.env`, active `observability: opentelemetry` et branche l'instrumentation FastAPI quand
170
+ `Arclith.fastapi()` construit l'application.
171
+
172
+ Parcours complet avec entité, API, LangGraph, LangSmith et LM Studio:
173
+ [`docs/agent-quickstart.md`](../docs/agent-quickstart.md).
174
+
175
+ ---
176
+
177
+ ### `capabilities` — Lister le catalogue standardisé
178
+
179
+ Affiche les capacités et adapters connus par la CLI.
180
+
181
+ ```bash
182
+ arclith-cli capabilities
183
+ arclith-cli capabilities --json
184
+ ```
185
+
186
+ Le catalogue est la source de vérité pour les adapters supportés, leurs paramètres, leur chemin de configuration et la clé d'activation.
187
+
188
+ ---
189
+
190
+ ### `export-config` — Générer `config.yaml` pour K8s
191
+
192
+ Fusionne le dossier `config/` en un fichier YAML unique, à lancer **depuis la racine du projet**.
193
+
194
+ ```bash
195
+ arclith-cli export-config # → ./config.yaml
196
+ arclith-cli export-config --output dist/app.yaml # chemin personnalisé
197
+ ```
198
+
199
+ Le fichier généré peut être monté directement comme **ConfigMap** Kubernetes.
200
+ Arclith le lit au même titre que le dossier `config/` :
201
+
202
+ ```python
203
+ # dev
204
+ arclith = Arclith("config/")
205
+
206
+ # K8s (ConfigMap monté sur /app/config.yaml)
207
+ arclith = Arclith("config.yaml")
208
+ ```
209
+
210
+ > ⚠️ `config.yaml` est un **artefact généré** — l'ajouter à `.gitignore`.
211
+ > La source de vérité reste `config/`.
212
+
213
+ ---
214
+
215
+ ### `update` — Mettre à jour le CLI
216
+
217
+ ```bash
218
+ arclith-cli update
219
+ ```
220
+
221
+ ### `version` — Afficher la version
222
+
223
+ ```bash
224
+ arclith-cli version
225
+ ```
226
+
227
+ ---
228
+
229
+ ## Configuration
230
+
231
+ Les projets arclith utilisent un dossier `config/` à la place d'un `config.yaml` monolithique. Chaque fichier est **scopé** : son chemin détermine la section `AppConfig` dans laquelle son contenu est injecté.
232
+
233
+ ```
234
+ config/
235
+ app.yaml # app: { name, version, description }
236
+ soft_delete.yaml # soft_delete: { retention_days }
237
+ secrets.yaml # secrets: { resolver, mappings, vault, yaml }
238
+ adapters/
239
+ adapters.yaml # adapters: { logger, repository } ← adapter actif
240
+ outbound/
241
+ mongodb.yaml # adapters.mongodb: { db_name, multitenant }
242
+ duckdb.yaml # adapters.duckdb: { path, multitenant }
243
+ mariadb.yaml # adapters.mariadb: { host, port, database, user, ... }
244
+ langsmith.yaml # adapters.langsmith: { tracing, project, endpoint, ... }
245
+ opentelemetry.yaml # adapters.opentelemetry: { endpoint, protocol, traces, metrics, ... }
246
+ inbound/
247
+ fastapi.yaml # api: { host, port, reload }
248
+ fastmcp.yaml # mcp: { host, port }
249
+ probe.yaml # probe: { host, port, enabled }
250
+ keycloak.yaml # keycloak: { url, realm }
251
+ tenant.yaml # tenant: { vault_addr, … }
252
+ license.yaml # license: { role }
253
+ cache.yaml # cache: { backend, redis_url, … }
254
+ ```
255
+
256
+ Pour changer l'adapter actif sans passer par le wizard :
257
+
258
+ ```yaml
259
+ # config/adapters/adapters.yaml
260
+ repository: duckdb # memory | mongodb | duckdb | mariadb
261
+ observability: langsmith # none | langsmith | opentelemetry
262
+ ```
263
+
264
+ Pour MariaDB, ne committez pas le mot de passe. Mappez `adapters.mariadb.password` ou `adapters.mariadb.url` via `config/secrets.yaml`, un resolver `env` ou Vault.
@@ -0,0 +1 @@
1
+ __version__ = "0.10.0"
@@ -0,0 +1,194 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ # ── Python repository subclass templates ─────────────────────────────────────
6
+
7
+ REPO_PYTHON: dict[str, str] = {
8
+ "memory": """\
9
+ from arclith.adapters.outbound.memory.repository import InMemoryRepository
10
+ from {domain_import}.models.{snake} import {pascal}
11
+ from {domain_import}.ports.outbound.{snake}_repository import {pascal}Repository
12
+
13
+
14
+ class InMemory{pascal}Repository(InMemoryRepository[{pascal}], {pascal}Repository):
15
+ pass # TODO: add custom query methods if needed
16
+ """,
17
+ "mongodb": """\
18
+ from arclith.adapters.outbound.mongodb.config import MongoDBConfig
19
+ from arclith.adapters.outbound.mongodb.repository import MongoDBRepository
20
+ from arclith.domain.ports.outbound.logger import Logger
21
+ from {domain_import}.models.{snake} import {pascal}
22
+ from {domain_import}.ports.outbound.{snake}_repository import {pascal}Repository
23
+
24
+
25
+ class MongoDB{pascal}Repository(MongoDBRepository[{pascal}], {pascal}Repository):
26
+ def __init__(self, config: MongoDBConfig, logger: Logger) -> None:
27
+ super().__init__(config, {pascal}, logger)
28
+
29
+ # TODO: add custom query methods here
30
+ # async def find_by_name(self, name: str) -> list[{pascal}]:
31
+ # async with self._collection() as col:
32
+ # return [
33
+ # self._from_doc(doc)
34
+ # async for doc in col.find({{"name": name, "deleted_at": None}})
35
+ # ]
36
+ """,
37
+ "duckdb": """\
38
+ from arclith.adapters.outbound.duckdb.repository import DuckDBRepository
39
+ from {domain_import}.models.{snake} import {pascal}
40
+ from {domain_import}.ports.outbound.{snake}_repository import {pascal}Repository
41
+
42
+
43
+ class DuckDB{pascal}Repository(DuckDBRepository[{pascal}], {pascal}Repository):
44
+ def __init__(self, path: str) -> None:
45
+ super().__init__(path, {pascal})
46
+
47
+ # TODO: add custom query methods here
48
+ # async def find_by_name(self, name: str) -> list[{pascal}]:
49
+ # rows = self._fetch(
50
+ # f"SELECT * FROM {{self._table}} WHERE deleted_at IS NULL AND lower(name) LIKE ?",
51
+ # [f"%{{name.lower()}}%"],
52
+ # )
53
+ # return [self._row_to_entity(r) for r in rows]
54
+ """,
55
+ "mariadb": """\
56
+ from arclith.adapters.outbound.mariadb.config import MariaDBConfig
57
+ from arclith.adapters.outbound.mariadb.repository import MariaDBRepository
58
+ from arclith.domain.ports.outbound.logger import Logger
59
+ from {domain_import}.models.{snake} import {pascal}
60
+ from {domain_import}.ports.outbound.{snake}_repository import {pascal}Repository
61
+
62
+
63
+ class MariaDB{pascal}Repository(MariaDBRepository[{pascal}], {pascal}Repository):
64
+ def __init__(self, config: MariaDBConfig, logger: Logger) -> None:
65
+ super().__init__(config, {pascal}, logger)
66
+
67
+ # TODO: add custom query methods here
68
+ """,
69
+ }
70
+
71
+ # ── repository.py re-export template ─────────────────────────────────────────
72
+
73
+ REPO_REEXPORT: dict[str, str] = {
74
+ "memory": """\
75
+ from {adapters_import}.outbound.memory.repositories.{snake}_repository import InMemory{pascal}Repository
76
+
77
+ __all__ = ["InMemory{pascal}Repository"]
78
+ """,
79
+ "mongodb": """\
80
+ from {adapters_import}.outbound.mongodb.repositories.{snake}_repository import MongoDB{pascal}Repository
81
+
82
+ __all__ = ["MongoDB{pascal}Repository"]
83
+ """,
84
+ "duckdb": """\
85
+ from {adapters_import}.outbound.duckdb.repositories.{snake}_repository import DuckDB{pascal}Repository
86
+
87
+ __all__ = ["DuckDB{pascal}Repository"]
88
+ """,
89
+ "mariadb": """\
90
+ from {adapters_import}.outbound.mariadb.repositories.{snake}_repository import MariaDB{pascal}Repository
91
+
92
+ __all__ = ["MariaDB{pascal}Repository"]
93
+ """,
94
+ }
95
+
96
+ # ── Container template (full file, regenerated with all installed adapters) ───
97
+
98
+ _CONTAINER_HEADER = """\
99
+ from {application_import}.services.{snake}_service import {pascal}Service
100
+ from arclith import Arclith, RepositoryRegistry
101
+ from arclith.domain.ports.outbound.logger import Logger
102
+ from arclith.infrastructure.config import AppConfig
103
+ from {domain_import}.models.{snake} import {pascal}
104
+ from {domain_import}.ports.outbound.{snake}_repository import {pascal}Repository
105
+
106
+ """
107
+
108
+ _CONTAINER_FACTORY: dict[str, str] = {
109
+ "memory": """\
110
+ def _build_memory(_cfg: AppConfig, _entity_class: type[{pascal}], _log: Logger) -> {pascal}Repository:
111
+ from {adapters_import}.outbound.memory.repository import InMemory{pascal}Repository
112
+ return InMemory{pascal}Repository()
113
+
114
+ """,
115
+ "mongodb": """\
116
+ def _build_mongodb(cfg: AppConfig, _entity_class: type[{pascal}], log: Logger) -> {pascal}Repository:
117
+ from {adapters_import}.outbound.mongodb.repository import MongoDB{pascal}Repository
118
+ from arclith.adapters.outbound.mongodb.config import MongoDBConfig
119
+ mongo = cfg.adapters.mongodb
120
+ if mongo is None:
121
+ raise ValueError("MongoDB settings are required when repository=mongodb")
122
+ return MongoDB{pascal}Repository(MongoDBConfig(uri=mongo.uri, db_name=mongo.db_name), log)
123
+
124
+ """,
125
+ "duckdb": """\
126
+ def _build_duckdb(cfg: AppConfig, _entity_class: type[{pascal}], _log: Logger) -> {pascal}Repository:
127
+ from {adapters_import}.outbound.duckdb.repository import DuckDB{pascal}Repository
128
+ duckdb = cfg.adapters.duckdb
129
+ if duckdb is None:
130
+ raise ValueError("DuckDB settings are required when repository=duckdb")
131
+ return DuckDB{pascal}Repository(duckdb.path)
132
+
133
+ """,
134
+ "mariadb": """\
135
+ def _build_mariadb(cfg: AppConfig, _entity_class: type[{pascal}], log: Logger) -> {pascal}Repository:
136
+ from {adapters_import}.outbound.mariadb.repository import MariaDB{pascal}Repository
137
+ from arclith.adapters.outbound.mariadb.config import MariaDBConfig
138
+ mariadb = cfg.adapters.mariadb
139
+ if mariadb is None:
140
+ raise ValueError("MariaDB settings are required when repository=mariadb")
141
+ return MariaDB{pascal}Repository(
142
+ MariaDBConfig(
143
+ url=mariadb.url,
144
+ host=mariadb.host,
145
+ port=mariadb.port,
146
+ database=mariadb.database,
147
+ user=mariadb.user,
148
+ password=mariadb.password,
149
+ driver=mariadb.driver,
150
+ table_prefix=mariadb.table_prefix,
151
+ ),
152
+ log,
153
+ )
154
+
155
+ """,
156
+ }
157
+
158
+ _CONTAINER_FOOTER = """\
159
+ _repository_registry: RepositoryRegistry[{pascal}, {pascal}Repository] = (
160
+ RepositoryRegistry[{pascal}, {pascal}Repository]()
161
+ {registrations}
162
+ )
163
+
164
+
165
+ def build_{snake}_service(arclith: Arclith) -> tuple[{pascal}Service, Logger]:
166
+ arclith.logger.info("🗄️ Repository adapter selected", adapter=arclith.config.adapters.repository)
167
+ repo: {pascal}Repository = arclith.repository({pascal}, registry=_repository_registry)
168
+ return {pascal}Service(repo, arclith.logger, arclith.config.soft_delete.retention_days), arclith.logger
169
+ """
170
+
171
+
172
+ def render_container(pascal: str, snake: str, installed_adapters: list[str], import_vars: dict[str, str]) -> str:
173
+ """Generate the full container file content for a given entity and its adapters."""
174
+ # memory is always included (arclith built-in, needs no extra files)
175
+ adapters = list(dict.fromkeys(["memory"] + installed_adapters))
176
+ vars = {"pascal": pascal, "snake": snake, **import_vars}
177
+
178
+ header = _CONTAINER_HEADER.format(**vars)
179
+ factories = "".join(
180
+ _CONTAINER_FACTORY[a].format(**vars)
181
+ for a in adapters
182
+ if a in _CONTAINER_FACTORY
183
+ )
184
+ registrations = "\n".join(
185
+ f" .register(\"{a}\", _build_{a})"
186
+ for a in adapters
187
+ if a in _CONTAINER_FACTORY
188
+ )
189
+ footer = _CONTAINER_FOOTER.format(**vars, registrations=registrations)
190
+ return header + factories + footer
191
+
192
+
193
+ def render(template: str, vars: dict[str, Any]) -> str:
194
+ return template.format(**vars)