@ontologie/cli 0.1.0-preview.1

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 (266) hide show
  1. package/README.md +492 -0
  2. package/dist/cache/keys.d.ts +11 -0
  3. package/dist/cache/keys.d.ts.map +1 -0
  4. package/dist/cache/keys.js +14 -0
  5. package/dist/cache/keys.js.map +1 -0
  6. package/dist/cache/store.d.ts +23 -0
  7. package/dist/cache/store.d.ts.map +1 -0
  8. package/dist/cache/store.js +160 -0
  9. package/dist/cache/store.js.map +1 -0
  10. package/dist/cli-compat.d.ts +6 -0
  11. package/dist/cli-compat.d.ts.map +1 -0
  12. package/dist/cli-compat.js +11 -0
  13. package/dist/cli-compat.js.map +1 -0
  14. package/dist/cli.d.ts +30 -0
  15. package/dist/cli.d.ts.map +1 -0
  16. package/dist/cli.js +119 -0
  17. package/dist/cli.js.map +1 -0
  18. package/dist/client.d.ts +7 -0
  19. package/dist/client.d.ts.map +1 -0
  20. package/dist/client.js +15 -0
  21. package/dist/client.js.map +1 -0
  22. package/dist/commands/actions.d.ts +22 -0
  23. package/dist/commands/actions.d.ts.map +1 -0
  24. package/dist/commands/actions.js +211 -0
  25. package/dist/commands/actions.js.map +1 -0
  26. package/dist/commands/agent-files.d.ts +27 -0
  27. package/dist/commands/agent-files.d.ts.map +1 -0
  28. package/dist/commands/agent-files.js +167 -0
  29. package/dist/commands/agent-files.js.map +1 -0
  30. package/dist/commands/agent.d.ts +23 -0
  31. package/dist/commands/agent.d.ts.map +1 -0
  32. package/dist/commands/agent.js +314 -0
  33. package/dist/commands/agent.js.map +1 -0
  34. package/dist/commands/audit.d.ts +11 -0
  35. package/dist/commands/audit.d.ts.map +1 -0
  36. package/dist/commands/audit.js +94 -0
  37. package/dist/commands/audit.js.map +1 -0
  38. package/dist/commands/cache.d.ts +8 -0
  39. package/dist/commands/cache.d.ts.map +1 -0
  40. package/dist/commands/cache.js +40 -0
  41. package/dist/commands/cache.js.map +1 -0
  42. package/dist/commands/capabilities.d.ts +56 -0
  43. package/dist/commands/capabilities.d.ts.map +1 -0
  44. package/dist/commands/capabilities.js +304 -0
  45. package/dist/commands/capabilities.js.map +1 -0
  46. package/dist/commands/check.d.ts +7 -0
  47. package/dist/commands/check.d.ts.map +1 -0
  48. package/dist/commands/check.js +16 -0
  49. package/dist/commands/check.js.map +1 -0
  50. package/dist/commands/config.d.ts +6 -0
  51. package/dist/commands/config.d.ts.map +1 -0
  52. package/dist/commands/config.js +133 -0
  53. package/dist/commands/config.js.map +1 -0
  54. package/dist/commands/context.d.ts +6 -0
  55. package/dist/commands/context.d.ts.map +1 -0
  56. package/dist/commands/context.js +226 -0
  57. package/dist/commands/context.js.map +1 -0
  58. package/dist/commands/dev.d.ts +15 -0
  59. package/dist/commands/dev.d.ts.map +1 -0
  60. package/dist/commands/dev.js +62 -0
  61. package/dist/commands/dev.js.map +1 -0
  62. package/dist/commands/docs-alias.d.ts +14 -0
  63. package/dist/commands/docs-alias.d.ts.map +1 -0
  64. package/dist/commands/docs-alias.js +28 -0
  65. package/dist/commands/docs-alias.js.map +1 -0
  66. package/dist/commands/docs.d.ts +6 -0
  67. package/dist/commands/docs.d.ts.map +1 -0
  68. package/dist/commands/docs.js +67 -0
  69. package/dist/commands/docs.js.map +1 -0
  70. package/dist/commands/doctor.d.ts +6 -0
  71. package/dist/commands/doctor.d.ts.map +1 -0
  72. package/dist/commands/doctor.js +161 -0
  73. package/dist/commands/doctor.js.map +1 -0
  74. package/dist/commands/generate.d.ts +7 -0
  75. package/dist/commands/generate.d.ts.map +1 -0
  76. package/dist/commands/generate.js +36 -0
  77. package/dist/commands/generate.js.map +1 -0
  78. package/dist/commands/graph.d.ts +9 -0
  79. package/dist/commands/graph.d.ts.map +1 -0
  80. package/dist/commands/graph.js +149 -0
  81. package/dist/commands/graph.js.map +1 -0
  82. package/dist/commands/import.d.ts +19 -0
  83. package/dist/commands/import.d.ts.map +1 -0
  84. package/dist/commands/import.js +330 -0
  85. package/dist/commands/import.js.map +1 -0
  86. package/dist/commands/index.d.ts +80 -0
  87. package/dist/commands/index.d.ts.map +1 -0
  88. package/dist/commands/index.js +345 -0
  89. package/dist/commands/index.js.map +1 -0
  90. package/dist/commands/init.d.ts +7 -0
  91. package/dist/commands/init.d.ts.map +1 -0
  92. package/dist/commands/init.js +101 -0
  93. package/dist/commands/init.js.map +1 -0
  94. package/dist/commands/instances.d.ts +7 -0
  95. package/dist/commands/instances.d.ts.map +1 -0
  96. package/dist/commands/instances.js +418 -0
  97. package/dist/commands/instances.js.map +1 -0
  98. package/dist/commands/keys.d.ts +6 -0
  99. package/dist/commands/keys.d.ts.map +1 -0
  100. package/dist/commands/keys.js +113 -0
  101. package/dist/commands/keys.js.map +1 -0
  102. package/dist/commands/knowledge.d.ts +6 -0
  103. package/dist/commands/knowledge.d.ts.map +1 -0
  104. package/dist/commands/knowledge.js +76 -0
  105. package/dist/commands/knowledge.js.map +1 -0
  106. package/dist/commands/model.d.ts +3 -0
  107. package/dist/commands/model.d.ts.map +1 -0
  108. package/dist/commands/model.js +40 -0
  109. package/dist/commands/model.js.map +1 -0
  110. package/dist/commands/nodes.d.ts +6 -0
  111. package/dist/commands/nodes.d.ts.map +1 -0
  112. package/dist/commands/nodes.js +111 -0
  113. package/dist/commands/nodes.js.map +1 -0
  114. package/dist/commands/openapi.d.ts +7 -0
  115. package/dist/commands/openapi.d.ts.map +1 -0
  116. package/dist/commands/openapi.js +17 -0
  117. package/dist/commands/openapi.js.map +1 -0
  118. package/dist/commands/plan.d.ts +19 -0
  119. package/dist/commands/plan.d.ts.map +1 -0
  120. package/dist/commands/plan.js +563 -0
  121. package/dist/commands/plan.js.map +1 -0
  122. package/dist/commands/process.d.ts +3 -0
  123. package/dist/commands/process.d.ts.map +1 -0
  124. package/dist/commands/process.js +67 -0
  125. package/dist/commands/process.js.map +1 -0
  126. package/dist/commands/query.d.ts +26 -0
  127. package/dist/commands/query.d.ts.map +1 -0
  128. package/dist/commands/query.js +253 -0
  129. package/dist/commands/query.js.map +1 -0
  130. package/dist/commands/schema.d.ts +24 -0
  131. package/dist/commands/schema.d.ts.map +1 -0
  132. package/dist/commands/schema.js +933 -0
  133. package/dist/commands/schema.js.map +1 -0
  134. package/dist/commands/search.d.ts +10 -0
  135. package/dist/commands/search.d.ts.map +1 -0
  136. package/dist/commands/search.js +74 -0
  137. package/dist/commands/search.js.map +1 -0
  138. package/dist/commands/shared.d.ts +32 -0
  139. package/dist/commands/shared.d.ts.map +1 -0
  140. package/dist/commands/shared.js +63 -0
  141. package/dist/commands/shared.js.map +1 -0
  142. package/dist/commands/usage.d.ts +6 -0
  143. package/dist/commands/usage.d.ts.map +1 -0
  144. package/dist/commands/usage.js +86 -0
  145. package/dist/commands/usage.js.map +1 -0
  146. package/dist/commands/validators.d.ts +30 -0
  147. package/dist/commands/validators.d.ts.map +1 -0
  148. package/dist/commands/validators.js +93 -0
  149. package/dist/commands/validators.js.map +1 -0
  150. package/dist/commands/whoami.d.ts +6 -0
  151. package/dist/commands/whoami.d.ts.map +1 -0
  152. package/dist/commands/whoami.js +48 -0
  153. package/dist/commands/whoami.js.map +1 -0
  154. package/dist/config.d.ts +47 -0
  155. package/dist/config.d.ts.map +1 -0
  156. package/dist/config.js +127 -0
  157. package/dist/config.js.map +1 -0
  158. package/dist/credentials.d.ts +9 -0
  159. package/dist/credentials.d.ts.map +1 -0
  160. package/dist/credentials.js +79 -0
  161. package/dist/credentials.js.map +1 -0
  162. package/dist/keychain.d.ts +9 -0
  163. package/dist/keychain.d.ts.map +1 -0
  164. package/dist/keychain.js +51 -0
  165. package/dist/keychain.js.map +1 -0
  166. package/dist/output/csv.d.ts +5 -0
  167. package/dist/output/csv.d.ts.map +1 -0
  168. package/dist/output/csv.js +22 -0
  169. package/dist/output/csv.js.map +1 -0
  170. package/dist/output/envelope.schema.d.ts +1053 -0
  171. package/dist/output/envelope.schema.d.ts.map +1 -0
  172. package/dist/output/envelope.schema.js +256 -0
  173. package/dist/output/envelope.schema.js.map +1 -0
  174. package/dist/output/errors.d.ts +58 -0
  175. package/dist/output/errors.d.ts.map +1 -0
  176. package/dist/output/errors.js +339 -0
  177. package/dist/output/errors.js.map +1 -0
  178. package/dist/output/formatter.d.ts +27 -0
  179. package/dist/output/formatter.d.ts.map +1 -0
  180. package/dist/output/formatter.js +80 -0
  181. package/dist/output/formatter.js.map +1 -0
  182. package/dist/output/json.d.ts +41 -0
  183. package/dist/output/json.d.ts.map +1 -0
  184. package/dist/output/json.js +215 -0
  185. package/dist/output/json.js.map +1 -0
  186. package/dist/output/markdown.d.ts +6 -0
  187. package/dist/output/markdown.d.ts.map +1 -0
  188. package/dist/output/markdown.js +51 -0
  189. package/dist/output/markdown.js.map +1 -0
  190. package/dist/output/meta.d.ts +49 -0
  191. package/dist/output/meta.d.ts.map +1 -0
  192. package/dist/output/meta.js +96 -0
  193. package/dist/output/meta.js.map +1 -0
  194. package/dist/output/plain.d.ts +6 -0
  195. package/dist/output/plain.d.ts.map +1 -0
  196. package/dist/output/plain.js +51 -0
  197. package/dist/output/plain.js.map +1 -0
  198. package/dist/output/table.d.ts +5 -0
  199. package/dist/output/table.d.ts.map +1 -0
  200. package/dist/output/table.js +54 -0
  201. package/dist/output/table.js.map +1 -0
  202. package/dist/output/types.d.ts +54 -0
  203. package/dist/output/types.d.ts.map +1 -0
  204. package/dist/output/types.js +80 -0
  205. package/dist/output/types.js.map +1 -0
  206. package/dist/output/warnings.d.ts +15 -0
  207. package/dist/output/warnings.d.ts.map +1 -0
  208. package/dist/output/warnings.js +46 -0
  209. package/dist/output/warnings.js.map +1 -0
  210. package/dist/output/yaml.d.ts +6 -0
  211. package/dist/output/yaml.d.ts.map +1 -0
  212. package/dist/output/yaml.js +9 -0
  213. package/dist/output/yaml.js.map +1 -0
  214. package/dist/schema/breaking-changes.d.ts +17 -0
  215. package/dist/schema/breaking-changes.d.ts.map +1 -0
  216. package/dist/schema/breaking-changes.js +108 -0
  217. package/dist/schema/breaking-changes.js.map +1 -0
  218. package/dist/schema/helpers.d.ts +18 -0
  219. package/dist/schema/helpers.d.ts.map +1 -0
  220. package/dist/schema/helpers.js +48 -0
  221. package/dist/schema/helpers.js.map +1 -0
  222. package/dist/schema/load-schema-file.d.ts +13 -0
  223. package/dist/schema/load-schema-file.d.ts.map +1 -0
  224. package/dist/schema/load-schema-file.js +88 -0
  225. package/dist/schema/load-schema-file.js.map +1 -0
  226. package/dist/schema/lockfile.d.ts +6 -0
  227. package/dist/schema/lockfile.d.ts.map +1 -0
  228. package/dist/schema/lockfile.js +34 -0
  229. package/dist/schema/lockfile.js.map +1 -0
  230. package/dist/schema/manifest-client.d.ts +31 -0
  231. package/dist/schema/manifest-client.d.ts.map +1 -0
  232. package/dist/schema/manifest-client.js +282 -0
  233. package/dist/schema/manifest-client.js.map +1 -0
  234. package/dist/schema/output.d.ts +38 -0
  235. package/dist/schema/output.d.ts.map +1 -0
  236. package/dist/schema/output.js +95 -0
  237. package/dist/schema/output.js.map +1 -0
  238. package/dist/stdin.d.ts +8 -0
  239. package/dist/stdin.d.ts.map +1 -0
  240. package/dist/stdin.js +21 -0
  241. package/dist/stdin.js.map +1 -0
  242. package/dist/templates/basic.d.ts +6 -0
  243. package/dist/templates/basic.d.ts.map +1 -0
  244. package/dist/templates/basic.js +90 -0
  245. package/dist/templates/basic.js.map +1 -0
  246. package/dist/templates/contract-review.d.ts +9 -0
  247. package/dist/templates/contract-review.d.ts.map +1 -0
  248. package/dist/templates/contract-review.js +172 -0
  249. package/dist/templates/contract-review.js.map +1 -0
  250. package/dist/templates/customer-onboarding.d.ts +9 -0
  251. package/dist/templates/customer-onboarding.d.ts.map +1 -0
  252. package/dist/templates/customer-onboarding.js +176 -0
  253. package/dist/templates/customer-onboarding.js.map +1 -0
  254. package/dist/templates/index.d.ts +11 -0
  255. package/dist/templates/index.d.ts.map +1 -0
  256. package/dist/templates/index.js +16 -0
  257. package/dist/templates/index.js.map +1 -0
  258. package/dist/templates/react-dashboard.d.ts +6 -0
  259. package/dist/templates/react-dashboard.d.ts.map +1 -0
  260. package/dist/templates/react-dashboard.js +146 -0
  261. package/dist/templates/react-dashboard.js.map +1 -0
  262. package/dist/templates/vendor-risk.d.ts +9 -0
  263. package/dist/templates/vendor-risk.d.ts.map +1 -0
  264. package/dist/templates/vendor-risk.js +186 -0
  265. package/dist/templates/vendor-risk.js.map +1 -0
  266. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,492 @@
1
+ # @dataforge/cli
2
+
3
+ [![Version](https://img.shields.io/badge/version-3.4.0-blue)](./) [![License](https://img.shields.io/badge/license-MIT-green)](./)
4
+
5
+ > **`dataforge` -- SDK CLI for DataForge Platform**
6
+ > Project scaffolding, type generation, login, and context engineering for AI agents.
7
+ > Also available as `ontologie` (legacy alias).
8
+
9
+ ---
10
+
11
+ ## Pourquoi un CLI en plus des APIs et MCP ?
12
+
13
+ Le CLI appelle le meme backend que l'API REST — il n'est pas "plus rapide". Sa valeur est ailleurs :
14
+
15
+ - **Moins de friction** : 1 commande = aggregation multi-source (ontologie + knowledge + graphe). Remplace 3+ appels API sequentiels.
16
+ - **Composabilite shell** : pipes, jq, scripts — `ontologie nodes search "X" --ids-only | ontologie graph neighbors --stdin`
17
+ - **Integration pipeline agent** : stdout alimente directement les prompts LLM — `ontologie context pack "sujet" --format markdown | claude`
18
+ - **Simplicite E2E** : `ontologie context pack` compile un context pack complet en une seule invocation
19
+
20
+ **Cas d'usage** :
21
+ - Pre-prompt context injection (`ontologie context pack "sujet" | claude`)
22
+ - Scripts d'automatisation batch
23
+ - CI/CD (validation schemas, health checks)
24
+ - Composition Unix : `ontologie nodes search "X" --ids-only | ontologie graph neighbors --stdin`
25
+
26
+ ---
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ # Depuis le monorepo SDK
32
+ pnpm install
33
+ pnpm --filter @dataforge/cli build
34
+
35
+ # Link global
36
+ cd packages/cli && npm link
37
+
38
+ # Verification
39
+ dataforge --version # -> 3.4.0
40
+ dataforge --help
41
+ ```
42
+
43
+ > **Migration** : Les binaires `ontologie` et `df` restent disponibles comme alias mais affichent un avertissement de deprecation. Utilisez `dataforge` pour tous les nouveaux projets.
44
+
45
+ ---
46
+
47
+ ## Configuration
48
+
49
+ ### Ordre de resolution
50
+
51
+ ```
52
+ CLI flags (--api-key, --workspace)
53
+ |-> Variables d'environnement (ONTOLOGIE_API_KEY, ONTOLOGIE_WORKSPACE_ID)
54
+ |-> Variables legacy (DF_API_KEY, DF_WORKSPACE_ID) -- deprecated
55
+ |-> Fichier ~/.ontologierc (YAML, multi-profil)
56
+ |-> Fichier ~/.dfrc (deprecated)
57
+ |-> Defaut (api.dataforge.io)
58
+ ```
59
+
60
+ ### Fichier `~/.ontologierc`
61
+
62
+ ```yaml
63
+ default:
64
+ api_url: https://api.dataforge.io
65
+ workspace_id: <uuid>
66
+ api_key: df_...
67
+
68
+ staging:
69
+ api_url: https://api.dev-growthsystemes.com
70
+ workspace_id: <uuid>
71
+ api_key: df_...
72
+ ```
73
+
74
+ > **Migration** : Si vous aviez un `~/.dfrc`, lancez `ontologie config migrate` pour le copier vers `~/.ontologierc`.
75
+
76
+ ### Variables d'environnement
77
+
78
+ | Variable | Description | Legacy (deprecated) |
79
+ |----------|-------------|---------------------|
80
+ | `ONTOLOGIE_API_URL` | URL de base de l'API | `DF_API_URL` |
81
+ | `ONTOLOGIE_API_KEY` | Cle API (prefixe `df_`) | `DF_API_KEY` |
82
+ | `ONTOLOGIE_WORKSPACE_ID` | UUID du workspace | `DF_WORKSPACE_ID` |
83
+ | `ONTOLOGIE_SPACE_ID` | UUID de l'espace (optionnel) | `DF_ESPACE_ID` |
84
+ | `ONTOLOGIE_PROFILE` | Nom du profil ~/.ontologierc | `DF_PROFILE` |
85
+
86
+ ---
87
+
88
+ ## Commandes
89
+
90
+ ### `ontologie context pack <query>` -- Killer Feature
91
+
92
+ Assemble un context pack LLM-ready avec budget tokens, en une seule requete.
93
+
94
+ ```bash
95
+ # Basique
96
+ ontologie context pack "politique RGPD"
97
+
98
+ # Avec budget et profondeur custom
99
+ ontologie context pack "gestion clients" --budget 4000 --depth 1
100
+
101
+ # Sections specifiques
102
+ ontologie context pack "pipeline ETL" --include ontology,knowledge
103
+
104
+ # Format agent-optimized (Markdown)
105
+ ontologie context pack "architecture microservices" --format markdown
106
+
107
+ # JSON pour pipeline
108
+ ontologie context pack "analyse RH" --format json | jq '.sections.knowledge.results'
109
+ ```
110
+
111
+ **Options** :
112
+
113
+ | Option | Default | Description |
114
+ |--------|---------|-------------|
115
+ | `--budget <tokens>` | 8000 | Budget tokens total |
116
+ | `--depth <n>` | 2 | Profondeur traversee graphe (1-3) |
117
+ | `--include <sections>` | ontology,knowledge,graph | Sections a inclure |
118
+
119
+ **Budget allocation** :
120
+ - Ontology : 20% -- resume contextuel de l'ontologie
121
+ - Knowledge : 40% -- resultats hybrid search (vector + lexical + graph)
122
+ - Graph : 30% -- voisins graphe des entites trouvees
123
+ - Reserve : 10% -- metadata, headers
124
+
125
+ **Backend** : `POST /api/v1/context/pack` | Feature flag : `FEATURE_CONTEXT_PACK` | Auth : API key (no RBAC scope required)
126
+
127
+ ---
128
+
129
+ ### `ontologie nodes` -- Operations ontologie
130
+
131
+ ```bash
132
+ # Lister les noeuds
133
+ ontologie nodes list
134
+ ontologie nodes list --type ObjectType --status active
135
+ ontologie nodes list --ids-only # IDs seulement (pipe-friendly)
136
+ ontologie nodes list --all # Auto-pagination
137
+
138
+ # Recuperer un noeud
139
+ ontologie nodes get <uuid>
140
+
141
+ # Recherche hybride
142
+ ontologie nodes search "Client"
143
+ ontologie nodes search "employe RH" --types ObjectType --explain
144
+ ontologie nodes search "facturation" --ids-only | ontologie graph neighbors --stdin
145
+ ```
146
+
147
+ ---
148
+
149
+ ### `ontologie knowledge search` -- Knowledge Library
150
+
151
+ ```bash
152
+ ontologie knowledge search "politique de securite"
153
+ ontologie knowledge search "RGPD conformite" --limit 5
154
+ ontologie knowledge list
155
+ ontologie knowledge get <id>
156
+ ```
157
+
158
+ ---
159
+
160
+ ### `dataforge query <type>` -- Query instances
161
+
162
+ ```bash
163
+ # Basique
164
+ dataforge query Contract --limit 20
165
+ dataforge query Contract --where status=active --order-by created_at --order desc
166
+
167
+ # Filtre JSON avance
168
+ dataforge query Invoice --filter-json '{"status":"pending","amount_gt":1000}'
169
+
170
+ # Estimation de cout (sans executer)
171
+ dataforge query Contract --explain-cost --format json
172
+
173
+ # IDs ou count seuls
174
+ dataforge query Contract --ids-only
175
+ dataforge query Contract --count
176
+ ```
177
+
178
+ **Options** :
179
+
180
+ | Option | Default | Description |
181
+ |--------|---------|-------------|
182
+ | `--filter-json <json>` | — | JSON filter expression |
183
+ | `--where <expr>` | — | Simple key=value filter |
184
+ | `--order-by <field>` | — | Sort field |
185
+ | `--order <dir>` | asc | Sort direction: asc\|desc |
186
+ | `--select <fields>` | — | Comma-separated field list |
187
+ | `--ids-only` | — | Output only IDs |
188
+ | `--count` | — | Return only count |
189
+ | `--cursor <cursor>` | — | Pagination cursor |
190
+ | `--explain-cost` | — | Show estimated cost without executing |
191
+
192
+ > **Limit**: Max `--limit` is 10,000. Use `--cursor` for larger datasets.
193
+
194
+ ---
195
+
196
+ ### `dataforge search <query>` -- Search entities
197
+
198
+ ```bash
199
+ dataforge search "Acme" --types Company,Contract --limit 20
200
+ dataforge search "facturation" --mode deterministic --explain
201
+ dataforge search "Client" --ids-only
202
+ ```
203
+
204
+ **Options** :
205
+
206
+ | Option | Default | Description |
207
+ |--------|---------|-------------|
208
+ | `--types <types>` | — | Comma-separated entity types |
209
+ | `--limit <n>` | 10 | Max results |
210
+ | `--explain` | — | Include score breakdown |
211
+ | `--ids-only` | — | Output only IDs |
212
+ | `--mode <mode>` | auto | Search mode: `auto` or `deterministic` (exact/fuzzy only, no semantic) |
213
+
214
+ ---
215
+
216
+ ### `ontologie graph` -- Traversee graphe
217
+
218
+ ```bash
219
+ # Voisins directs (depth capped at 3)
220
+ ontologie graph neighbors <node-id>
221
+ ontologie graph neighbors <node-id> --depth 2 --direction outbound
222
+ ontologie graph neighbors <node-id> --edge-types "manages,owns" --ids-only
223
+
224
+ # N-hop traversal (depth capped at 5)
225
+ ontologie graph traverse <node-id> --depth 3 --direction outbound
226
+
227
+ # Shortest path (max-hops capped at 10)
228
+ ontologie graph path <from> <to> --max-hops 5
229
+
230
+ # Pipe composition
231
+ ontologie nodes search "Client" --ids-only | ontologie graph neighbors --stdin --depth 2
232
+ ```
233
+
234
+ **Depth limits (V1 stable)** :
235
+
236
+ | Subcommand | Max depth | Default |
237
+ |------------|-----------|---------|
238
+ | `neighbors` | 3 | 1 |
239
+ | `traverse` | 5 | 2 |
240
+ | `path` (max-hops) | 10 | 5 |
241
+
242
+ ---
243
+
244
+ ### `dataforge schema` -- Schema operations
245
+
246
+ ```bash
247
+ # Export full schema (raw JSON/YAML dump)
248
+ dataforge schema export
249
+ dataforge schema export --format yaml
250
+
251
+ # Compare local dataforge.schema.ts vs remote ontology
252
+ dataforge schema diff
253
+ dataforge schema diff --schema ./custom-schema.ts
254
+
255
+ # Push local schema changes to remote
256
+ dataforge schema push --dry-run # preview plan
257
+ dataforge schema push --yes # apply changes
258
+
259
+ # Generate dataforge.schema.ts from remote ontology
260
+ dataforge schema pull
261
+ dataforge schema pull --output ./src/schema.ts
262
+
263
+ # Compile schema + verify lockfile integrity
264
+ dataforge schema check
265
+ ```
266
+
267
+ **Schema workflow** :
268
+
269
+ ```
270
+ dataforge init -> Edit dataforge.schema.ts -> dataforge schema diff
271
+ |
272
+ dataforge schema push --yes
273
+ |
274
+ dataforge generate
275
+ ```
276
+
277
+ ---
278
+
279
+ ### `ontologie whoami` -- Connection info
280
+
281
+ ```bash
282
+ ontologie whoami
283
+ # -> Workspace: xxx | API: https://api... | Health: OK
284
+ ```
285
+
286
+ ---
287
+
288
+ ### `ontologie doctor` -- Diagnostics
289
+
290
+ ```bash
291
+ ontologie doctor
292
+ # Checks: config, rc file, env vars, API connectivity, cache, Node.js version
293
+ ```
294
+
295
+ ---
296
+
297
+ ### `ontologie config` -- Configuration
298
+
299
+ ```bash
300
+ ontologie config list
301
+ # -> Affiche la config resolue (profil, URL, workspace, key masquee)
302
+
303
+ ontologie config set api_key df_xxx
304
+ ontologie config get workspace_id
305
+ ontologie config migrate # ~/.dfrc -> ~/.ontologierc
306
+ ```
307
+
308
+ ---
309
+
310
+ ## Options globales
311
+
312
+ | Flag | Description |
313
+ |------|-------------|
314
+ | `-w, --workspace <id>` | Override workspace ID |
315
+ | `-s, --space <id>` | Override space ID |
316
+ | `--api-url <url>` | Override API URL |
317
+ | `--api-key <key>` | Override API key |
318
+ | `--profile <name>` | Profil ~/.ontologierc (defaut: "default") |
319
+ | `-f, --format <fmt>` | Format: json, table, csv, yaml, markdown, jsonl, raw |
320
+ | `--raw` | Alias pour `--format raw` (sans envelope _meta) |
321
+ | `-n, --limit <n>` | Nombre max de resultats |
322
+ | `-q, --quiet` | Supprimer les diagnostics stderr |
323
+ | `-v, --verbose` | Diagnostics detailles sur stderr |
324
+ | `--no-cache` | Bypass cache local |
325
+ | `--cache <ttl>` | TTL cache (ex: 60s, 5m, 1h) |
326
+ | `--keychain` | Force keychain credential resolution |
327
+
328
+ ---
329
+
330
+ ## Formats de sortie
331
+
332
+ | Format | Usage | Destination |
333
+ |--------|-------|-------------|
334
+ | `json` | Default (pipe) | Machine, jq, scripts |
335
+ | `table` | Default (TTY) | Humain, terminal |
336
+ | `markdown` | Agent-optimized | LLM, context injection |
337
+ | `csv` | Import | Tableurs, analyse |
338
+ | `yaml` | Config | Documentation, IaC |
339
+ | `jsonl` | Streaming | Logs, traitement ligne par ligne |
340
+ | `raw` | Sans envelope | Quand `_meta` n'est pas voulu |
341
+
342
+ > `--format plain` est un alias de `--format markdown` pour la retrocompatibilite.
343
+
344
+ **Auto-detection** : si stdout est un TTY -> `table`, sinon -> `json`.
345
+
346
+ ---
347
+
348
+ ## Pipe composition
349
+
350
+ Le CLI est concu pour la composition Unix :
351
+
352
+ ```bash
353
+ # Rechercher -> explorer le graphe
354
+ ontologie nodes search "Client" --ids-only | ontologie graph neighbors --stdin --depth 2
355
+
356
+ # Context pack -> injection prompt
357
+ ontologie context pack "architecture" --format markdown | pbcopy
358
+
359
+ # Schema -> analyse jq
360
+ ontologie schema export --format json | jq '.objectTypes | length'
361
+
362
+ # Batch node details
363
+ cat node-ids.txt | ontologie graph neighbors --stdin --ids-only | sort -u
364
+ ```
365
+
366
+ ---
367
+
368
+ ## Architecture
369
+
370
+ ```
371
+ +---------------------------------------------------------+
372
+ | $ ontologie context pack "query" --budget 4000 |
373
+ | |
374
+ | CLI (Commander.js) |
375
+ | +-- config.ts -- Resolution chaine (flag>env>file) |
376
+ | +-- client.ts -- Factory @dataforge/sdk-client |
377
+ | +-- stdin.ts -- Support pipe Unix |
378
+ | +-- cache/ -- Cache local SHA256 + TTL |
379
+ | +-- output/ -- 7 formatters (json,table,csv,...) |
380
+ | +-- commands/ -- 9 commandes enregistrees |
381
+ | | |
382
+ | v HTTP |
383
+ | @dataforge/sdk-client |
384
+ | +-- ContextOperations.pack() |
385
+ | | |
386
+ | v POST /api/v1/context/pack |
387
+ | Backend |
388
+ | +-- Route: context-pack.ts (Zod validation) |
389
+ | +-- Service: ContextPackService.ts |
390
+ | +-- OntologyContextService (20% budget) |
391
+ | +-- HybridSearchService (40% budget) |
392
+ | +-- ArangoDBService (30% budget) |
393
+ +---------------------------------------------------------+
394
+ ```
395
+
396
+ ---
397
+
398
+ ## Contrat JSON (`dataforge.cli.v1`)
399
+
400
+ Quand `--format json` est utilise, toutes les commandes retournent une enveloppe stable :
401
+
402
+ ```jsonc
403
+ {
404
+ "ok": true, // boolean
405
+ "data": [...], // resultat (null si erreur)
406
+ "error": null, // CliError (null si succes)
407
+ "page": null, // pagination cursor-based (si applicable)
408
+ "meta": {
409
+ "schemaVersion": "dataforge.cli.v1",
410
+ "command": "nodes.list",
411
+ "requestId": "local_req_...",
412
+ "workspaceId": "...",
413
+ "environment": "staging", // detecte depuis apiUrl
414
+ "warnings": []
415
+ }
416
+ }
417
+ ```
418
+
419
+ Specification complete : [`produit/02-cli/cli-contract.md`](../../../produit/02-cli/cli-contract.md)
420
+
421
+ ---
422
+
423
+ ## Codes de sortie
424
+
425
+ | Code | Error Code | Signification |
426
+ |------|-----------|--------------|
427
+ | 0 | *(succes)* | Commande reussie |
428
+ | 1 | `NOT_FOUND`, `UNAVAILABLE`, `INTERNAL_ERROR` | Ressource introuvable / erreur serveur |
429
+ | 2 | `INVALID_USAGE` | Arguments CLI invalides |
430
+ | 3 | `AUTHENTICATION_ERROR` | Credentials invalides ou manquants |
431
+ | 4 | `AUTHORIZATION_ERROR` | Permissions insuffisantes |
432
+ | 5 | `VALIDATION_ERROR` | Validation schema/payload echouee |
433
+ | 6 | `SCHEMA_DRIFT_ERROR` | Manifeste local != schema distant |
434
+ | 7 | `QUOTA_EXCEEDED` | Quota workspace epuise |
435
+ | 8 | `RATE_LIMITED` | Trop de requetes (retryable) |
436
+ | 9 | `CONFLICT_ERROR` | Conflit OCC (retryable) |
437
+ | 10 | `PRECONDITION_FAILED`, `CONFIRMATION_REQUIRED` | Precondition non remplie / `--yes` requis |
438
+ | 11 | `NETWORK_ERROR` | Connexion refusee / DNS (retryable) |
439
+ | 12 | `TIMEOUT_ERROR` | Timeout (retryable) |
440
+
441
+ ---
442
+
443
+ ## Developpement
444
+
445
+ ```bash
446
+ # Mode dev (sans build)
447
+ cd sdk/packages/cli
448
+ npx tsx src/cli.ts whoami --api-key df_... --workspace <uuid>
449
+
450
+ # Build
451
+ pnpm build
452
+
453
+ # Tests
454
+ pnpm test
455
+ ```
456
+
457
+ ---
458
+
459
+ ## Dependances
460
+
461
+ | Package | Role |
462
+ |---------|------|
463
+ | `@dataforge/schema` | Schema DSL, compiler, diff, push/pull |
464
+ | `@dataforge/sdk-client` | Client HTTP type-safe |
465
+ | `@dataforge/sdk-types` | Types runtime |
466
+ | `commander` | Framework CLI |
467
+ | `yaml` | Parsing ~/.ontologierc |
468
+ | `keytar` | (optional) Keychain credential storage |
469
+
470
+ ---
471
+
472
+ ## Migration depuis v0.1.0
473
+
474
+ | v0.1.0 | v0.2.0 | Notes |
475
+ |--------|--------|-------|
476
+ | `df` | `ontologie` | Binaire `df` est un shim deprece |
477
+ | `~/.dfrc` | `~/.ontologierc` | `ontologie config migrate` |
478
+ | `DF_API_KEY` | `ONTOLOGIE_API_KEY` | Legacy vars still work (with warning) |
479
+ | `DF_WORKSPACE_ID` | `ONTOLOGIE_WORKSPACE_ID` | Legacy vars still work (with warning) |
480
+ | `-e, --espace` | `-s, --space` | `--espace` still works (hidden) |
481
+ | `docs search` | `knowledge search` | `docs` still works (hidden alias) |
482
+ | `--format plain` | `--format markdown` | `plain` still works (alias) |
483
+ | `~/.df/cache/` | `~/.ontologie/cache/` | Old cache auto-detected |
484
+
485
+ ---
486
+
487
+ ## Voir aussi
488
+
489
+ - [SDK README](../../README.md) -- Vue d'ensemble du SDK
490
+ - [ContextPackService](../../../backend/src/services/ContextPackService.ts) -- Service backend
491
+ - [Route API](../../../backend/src/routes/v1/context-pack.ts) -- Endpoint REST
492
+ - [ContextCompiler](../../../backend/src/services/agent/memory/context/ContextCompiler.ts) -- Compilateur contexte agent avance
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Cache key generation — deterministic SHA256 of request params
3
+ */
4
+ export interface CacheKeyParams {
5
+ workspace: string;
6
+ espace?: string;
7
+ command: string;
8
+ params: Record<string, unknown>;
9
+ }
10
+ export declare function cacheKey(p: CacheKeyParams): string;
11
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/cache/keys.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAQlD"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Cache key generation — deterministic SHA256 of request params
3
+ */
4
+ import * as crypto from 'node:crypto';
5
+ export function cacheKey(p) {
6
+ const payload = JSON.stringify({
7
+ w: p.workspace,
8
+ e: p.espace || '',
9
+ c: p.command,
10
+ p: p.params,
11
+ });
12
+ return crypto.createHash('sha256').update(payload).digest('hex').slice(0, 16);
13
+ }
14
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/cache/keys.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAStC,MAAM,UAAU,QAAQ,CAAC,CAAiB;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,CAAC,EAAE,CAAC,CAAC,SAAS;QACd,CAAC,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;QACjB,CAAC,EAAE,CAAC,CAAC,OAAO;QACZ,CAAC,EAAE,CAAC,CAAC,MAAM;KACZ,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAChF,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * File-based cache -- ~/.ontologie/cache/
3
+ *
4
+ * Key: SHA256 of { workspace, space, command, params }
5
+ * Layout: ~/.ontologie/cache/{workspace_prefix_8chars}/{hash}.json
6
+ * Default TTL: 60s, configurable per command
7
+ */
8
+ import { type CacheKeyParams } from './keys.js';
9
+ /** Parse TTL string like "60s", "5m", "1h" to seconds */
10
+ export declare function parseTtl(ttl: string): number;
11
+ export declare function cacheGet(params: CacheKeyParams): unknown | null;
12
+ export declare function cacheSet(params: CacheKeyParams, data: unknown, ttlSeconds?: number): void;
13
+ export declare function cacheClear(): {
14
+ count: number;
15
+ size: number;
16
+ };
17
+ export declare function cacheStats(): {
18
+ count: number;
19
+ size: number;
20
+ oldest?: Date;
21
+ newest?: Date;
22
+ };
23
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/cache/store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AA4C1D,yDAAyD;AACzD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU5C;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI,CA8B/D;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,SAAK,GAAG,IAAI,CAerF;AAED,wBAAgB,UAAU,IAAI;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAyB5D;AAED,wBAAgB,UAAU,IAAI;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,CAAA;CAAE,CAiC1F"}