@intentius/chant 0.83.0 → 0.85.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 (66) hide show
  1. package/dist/cli/main.d.ts.map +1 -1
  2. package/dist/cli/mcp/resource-handlers.d.ts +2 -1
  3. package/dist/cli/mcp/resource-handlers.d.ts.map +1 -1
  4. package/dist/cli/mcp/server.d.ts +1 -0
  5. package/dist/cli/mcp/server.d.ts.map +1 -1
  6. package/dist/cli/mcp/tools/composites.d.ts +44 -0
  7. package/dist/cli/mcp/tools/composites.d.ts.map +1 -0
  8. package/dist/cli/mcp/tools/search.d.ts.map +1 -1
  9. package/dist/cli/registry.d.ts +6 -0
  10. package/dist/cli/registry.d.ts.map +1 -1
  11. package/dist/components/cli-support.d.ts +4 -0
  12. package/dist/components/cli-support.d.ts.map +1 -1
  13. package/dist/composite.d.ts +6 -0
  14. package/dist/composite.d.ts.map +1 -1
  15. package/dist/lexicon.d.ts +44 -0
  16. package/dist/lexicon.d.ts.map +1 -1
  17. package/dist/workspace/__fixtures__/contract-repo.d.ts +7 -0
  18. package/dist/workspace/__fixtures__/contract-repo.d.ts.map +1 -1
  19. package/dist/workspace/composites.d.ts +139 -0
  20. package/dist/workspace/composites.d.ts.map +1 -0
  21. package/dist/workspace/graph-cli.d.ts +16 -1
  22. package/dist/workspace/graph-cli.d.ts.map +1 -1
  23. package/dist/workspace/intent-cli.d.ts +21 -0
  24. package/dist/workspace/intent-cli.d.ts.map +1 -0
  25. package/dist/workspace/intent-joins.d.ts +121 -0
  26. package/dist/workspace/intent-joins.d.ts.map +1 -0
  27. package/dist/workspace/intent.d.ts +310 -0
  28. package/dist/workspace/intent.d.ts.map +1 -0
  29. package/dist/workspace/member-commands.d.ts +7 -2
  30. package/dist/workspace/member-commands.d.ts.map +1 -1
  31. package/dist/workspace/reason-codes.d.ts +29 -0
  32. package/dist/workspace/reason-codes.d.ts.map +1 -1
  33. package/dist/workspace/records.d.ts +7 -1
  34. package/dist/workspace/records.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/cli/handlers/graph.ts +4 -0
  37. package/src/cli/main.test.ts +20 -0
  38. package/src/cli/main.ts +18 -0
  39. package/src/cli/mcp/resource-handlers.ts +17 -0
  40. package/src/cli/mcp/server.test.ts +140 -4
  41. package/src/cli/mcp/server.ts +5 -1
  42. package/src/cli/mcp/tools/composites.ts +98 -0
  43. package/src/cli/mcp/tools/search.ts +47 -5
  44. package/src/cli/registry.ts +6 -0
  45. package/src/components/cli-support.test.ts +16 -0
  46. package/src/components/cli-support.ts +8 -2
  47. package/src/composite.ts +9 -0
  48. package/src/lexicon.ts +47 -0
  49. package/src/workspace/__fixtures__/contract-repo.ts +17 -0
  50. package/src/workspace/composites.schema.json +471 -0
  51. package/src/workspace/composites.test.ts +244 -0
  52. package/src/workspace/composites.ts +295 -0
  53. package/src/workspace/graph-cli.ts +39 -3
  54. package/src/workspace/intent-cli.ts +119 -0
  55. package/src/workspace/intent-joins.ts +210 -0
  56. package/src/workspace/intent.schema.json +1141 -0
  57. package/src/workspace/intent.test.ts +566 -0
  58. package/src/workspace/intent.ts +999 -0
  59. package/src/workspace/member-commands.ts +11 -5
  60. package/src/workspace/read-contract.test.ts +46 -3
  61. package/src/workspace/reason-codes.test.ts +39 -2
  62. package/src/workspace/reason-codes.ts +40 -0
  63. package/src/workspace/records-contract.test.ts +22 -2
  64. package/src/workspace/records.schema.json +2 -2
  65. package/src/workspace/records.test.ts +93 -0
  66. package/src/workspace/records.ts +55 -11
@@ -98,3 +98,20 @@ case "$1" in
98
98
  *) echo "Error: Unknown command: $1" >&2; exit 1 ;;
99
99
  esac
100
100
  `;
101
+
102
+ /**
103
+ * A chant older than `workspace member-run` that answers from files (#2662):
104
+ * `chant graph --components` prints the member's `components.json`, or an
105
+ * empty IR when there is none, and plain `chant graph` prints `ir.json`. A
106
+ * `components.json` holding `FAIL` makes the component graph exit 1.
107
+ */
108
+ export const FAKE_FILE_GRAPH_CHANT = `#!/bin/sh
109
+ [ "$1" = graph ] || { echo "Error: Unknown command: $1" >&2; exit 1; }
110
+ case " $* " in
111
+ *" --components "*)
112
+ if [ ! -f components.json ]; then printf '{"version":1,"nodes":[],"edges":[],"groups":{}}\\n'
113
+ elif grep -q FAIL components.json; then echo "Error: component discovery failed" >&2; exit 1
114
+ else cat components.json; fi ;;
115
+ *) cat ir.json ;;
116
+ esac
117
+ `;
@@ -0,0 +1,471 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://intentius.io/chant/schemas/workspace/composites/v1/composites.schema.json",
4
+ "title": "chant workspace graph --composites output",
5
+ "description": "What `chant workspace graph --composites` prints: each composite instance the workspace's members declare, joined to the components whose contract can deploy it (#2662). Each member of kind chant is read through its own `chant graph --format ir` and `chant graph --components --format ir`, under its own toolchain. An instance with no component is listed with an empty `components` array. chant supplies the rows and never picks one: each match says how it was made and how it crosses members. Readers ignore fields they do not know; a field is only ever added within a version. The reason and error codes are closed lists. Contract version 1 is written by chant 0.81.0 and newer, and this document was added to it by #2662; a chant without --composites refuses the flag. Every code is in the one closed list of `reason-codes.ts`.",
6
+ "oneOf": [
7
+ {
8
+ "$ref": "#/$defs/result"
9
+ },
10
+ {
11
+ "$ref": "#/$defs/failure"
12
+ }
13
+ ],
14
+ "$defs": {
15
+ "result": {
16
+ "description": "The workspace was read. Exit code 0, or 1 when a member's graph or component graph could not be read; the document is printed either way.",
17
+ "type": "object",
18
+ "required": [
19
+ "$schema",
20
+ "contract",
21
+ "chant",
22
+ "at",
23
+ "workspace",
24
+ "members",
25
+ "composites",
26
+ "components",
27
+ "reasons",
28
+ "summary"
29
+ ],
30
+ "properties": {
31
+ "$schema": {
32
+ "const": "https://intentius.io/chant/schemas/workspace/composites/v1/composites.schema.json"
33
+ },
34
+ "contract": {
35
+ "const": 1
36
+ },
37
+ "chant": {
38
+ "type": "string",
39
+ "description": "The chant that wrote the document."
40
+ },
41
+ "at": {
42
+ "description": "The full commit id the workspace was read at (--at), or null for the working tree.",
43
+ "type": [
44
+ "string",
45
+ "null"
46
+ ],
47
+ "pattern": "^[0-9a-f]{40,64}$"
48
+ },
49
+ "workspace": {
50
+ "type": "object",
51
+ "required": [
52
+ "name",
53
+ "root"
54
+ ],
55
+ "properties": {
56
+ "name": {
57
+ "type": "string"
58
+ },
59
+ "root": {
60
+ "type": "string",
61
+ "description": "The workspace root relative to the git root, \".\" for the git root."
62
+ }
63
+ }
64
+ },
65
+ "error": false,
66
+ "members": {
67
+ "type": "array",
68
+ "description": "Every member the read covered, in declaration order.",
69
+ "items": {
70
+ "$ref": "#/$defs/member"
71
+ }
72
+ },
73
+ "composites": {
74
+ "type": "array",
75
+ "description": "Every composite instance, sorted by id.",
76
+ "items": {
77
+ "$ref": "#/$defs/composite"
78
+ }
79
+ },
80
+ "components": {
81
+ "type": "array",
82
+ "description": "Every component the members read declare, sorted by id, whether or not it matches an instance.",
83
+ "items": {
84
+ "$ref": "#/$defs/component"
85
+ }
86
+ },
87
+ "reasons": {
88
+ "type": "array",
89
+ "description": "Why the list is empty, or why no instance has a component.",
90
+ "items": {
91
+ "$ref": "#/$defs/reason"
92
+ }
93
+ },
94
+ "summary": {
95
+ "type": "object",
96
+ "required": [
97
+ "composites",
98
+ "withComponent",
99
+ "withoutComponent",
100
+ "components"
101
+ ],
102
+ "properties": {
103
+ "composites": {
104
+ "type": "integer",
105
+ "minimum": 0
106
+ },
107
+ "withComponent": {
108
+ "type": "integer",
109
+ "minimum": 0,
110
+ "description": "Instances with at least one component."
111
+ },
112
+ "withoutComponent": {
113
+ "type": "integer",
114
+ "minimum": 0,
115
+ "description": "Instances with none."
116
+ },
117
+ "components": {
118
+ "type": "integer",
119
+ "minimum": 0
120
+ }
121
+ }
122
+ }
123
+ }
124
+ },
125
+ "member": {
126
+ "type": "object",
127
+ "required": [
128
+ "name",
129
+ "dir",
130
+ "kind",
131
+ "status",
132
+ "reason",
133
+ "chant"
134
+ ],
135
+ "properties": {
136
+ "name": {
137
+ "type": "string"
138
+ },
139
+ "dir": {
140
+ "type": "string",
141
+ "description": "Relative to the workspace root, with / separators; \".\" is the root member."
142
+ },
143
+ "kind": {
144
+ "type": "string"
145
+ },
146
+ "status": {
147
+ "enum": [
148
+ "read",
149
+ "skipped",
150
+ "failed"
151
+ ],
152
+ "description": "read: its graph and its component graph were both read. skipped: its kind is not run. failed: either read failed, and reason says which."
153
+ },
154
+ "reason": {
155
+ "oneOf": [
156
+ {
157
+ "type": "null"
158
+ },
159
+ {
160
+ "type": "object",
161
+ "required": [
162
+ "code",
163
+ "message"
164
+ ],
165
+ "properties": {
166
+ "code": {
167
+ "enum": [
168
+ "kind-not-run",
169
+ "dir-missing",
170
+ "unknown-kind",
171
+ "kind-probe-failed",
172
+ "command-failed",
173
+ "output-unreadable",
174
+ "ir-version-unsupported"
175
+ ]
176
+ },
177
+ "message": {
178
+ "type": "string"
179
+ }
180
+ }
181
+ }
182
+ ]
183
+ },
184
+ "chant": {
185
+ "type": [
186
+ "string",
187
+ "null"
188
+ ],
189
+ "description": "The chant version the member's toolchain reported, or null when a chant older than member-run read it."
190
+ }
191
+ },
192
+ "if": {
193
+ "type": "object",
194
+ "properties": {
195
+ "status": {
196
+ "const": "read"
197
+ }
198
+ },
199
+ "required": [
200
+ "status"
201
+ ]
202
+ },
203
+ "then": {
204
+ "type": "object",
205
+ "properties": {
206
+ "reason": {
207
+ "type": "null"
208
+ }
209
+ }
210
+ },
211
+ "else": {
212
+ "type": "object",
213
+ "properties": {
214
+ "reason": {
215
+ "type": "object"
216
+ }
217
+ }
218
+ }
219
+ },
220
+ "composite": {
221
+ "type": "object",
222
+ "required": [
223
+ "id",
224
+ "member",
225
+ "instance",
226
+ "kinds",
227
+ "lexicons",
228
+ "nodes",
229
+ "components"
230
+ ],
231
+ "properties": {
232
+ "id": {
233
+ "type": "string",
234
+ "description": "<member>/<instance>, the composed graph's compositeInstance."
235
+ },
236
+ "member": {
237
+ "type": "string"
238
+ },
239
+ "instance": {
240
+ "type": "string",
241
+ "description": "The instance's name in its member, the export name."
242
+ },
243
+ "kinds": {
244
+ "type": "array",
245
+ "items": {
246
+ "type": "string"
247
+ },
248
+ "description": "The composite kinds its nodes came from, sorted. One for a plain composite; a composite built from nested composites also lists the inner kinds."
249
+ },
250
+ "lexicons": {
251
+ "type": "array",
252
+ "items": {
253
+ "type": "string"
254
+ },
255
+ "description": "The lexicons of its nodes, sorted."
256
+ },
257
+ "nodes": {
258
+ "type": "array",
259
+ "items": {
260
+ "type": "string"
261
+ },
262
+ "description": "The composed ids of its nodes, as in chant workspace graph."
263
+ },
264
+ "components": {
265
+ "type": "array",
266
+ "description": "The components that match the instance, sorted by component id. Empty when none does.",
267
+ "items": {
268
+ "$ref": "#/$defs/match"
269
+ }
270
+ }
271
+ }
272
+ },
273
+ "match": {
274
+ "type": "object",
275
+ "required": [
276
+ "component",
277
+ "by",
278
+ "against",
279
+ "value",
280
+ "label",
281
+ "via"
282
+ ],
283
+ "properties": {
284
+ "component": {
285
+ "type": "string",
286
+ "description": "The id of an entry in components."
287
+ },
288
+ "by": {
289
+ "enum": [
290
+ "composites",
291
+ "name"
292
+ ],
293
+ "description": "composites: the component's contract lists one of the instance's kinds. name: the component lists no composites, and its name joins the instance's kind or the instance's name with the core joinKey()."
294
+ },
295
+ "against": {
296
+ "enum": [
297
+ "kind",
298
+ "instance"
299
+ ]
300
+ },
301
+ "value": {
302
+ "type": "string",
303
+ "description": "The kind or instance name that matched."
304
+ },
305
+ "label": {
306
+ "enum": [
307
+ "exact",
308
+ "folded"
309
+ ],
310
+ "description": "exact when the names are equal; folded when only case or punctuation differ. A composites match is always exact."
311
+ },
312
+ "via": {
313
+ "enum": [
314
+ "member",
315
+ "link",
316
+ "unlinked"
317
+ ],
318
+ "description": "member: the component and the instance are in the same member. link: the component's member reads the instance's member through a resolved member link. unlinked: neither."
319
+ }
320
+ }
321
+ },
322
+ "component": {
323
+ "type": "object",
324
+ "required": [
325
+ "id",
326
+ "name",
327
+ "member",
328
+ "archetype",
329
+ "composites",
330
+ "file"
331
+ ],
332
+ "properties": {
333
+ "id": {
334
+ "type": "string",
335
+ "description": "<member>/<name>."
336
+ },
337
+ "name": {
338
+ "type": "string"
339
+ },
340
+ "member": {
341
+ "type": "string"
342
+ },
343
+ "archetype": {
344
+ "type": [
345
+ "string",
346
+ "null"
347
+ ],
348
+ "description": "Declared or inferred, such as service, infra or producer-library. null when the member's chant does not print it."
349
+ },
350
+ "composites": {
351
+ "oneOf": [
352
+ {
353
+ "type": "null"
354
+ },
355
+ {
356
+ "type": "array",
357
+ "items": {
358
+ "type": "string"
359
+ },
360
+ "minItems": 1
361
+ }
362
+ ],
363
+ "description": "The contract's composites, or null when it declares none and name matching applies."
364
+ },
365
+ "file": {
366
+ "type": [
367
+ "string",
368
+ "null"
369
+ ],
370
+ "description": "The component's file from the workspace root, when the member's chant names it."
371
+ }
372
+ }
373
+ },
374
+ "reason": {
375
+ "type": "object",
376
+ "required": [
377
+ "code",
378
+ "message"
379
+ ],
380
+ "properties": {
381
+ "code": {
382
+ "enum": [
383
+ "composites-no-chant-member",
384
+ "composites-none-declared",
385
+ "composites-no-component"
386
+ ]
387
+ },
388
+ "message": {
389
+ "type": "string"
390
+ }
391
+ }
392
+ },
393
+ "failure": {
394
+ "description": "The declaration could not be read, and nothing was read. Exit code 1.",
395
+ "type": "object",
396
+ "required": [
397
+ "$schema",
398
+ "contract",
399
+ "chant",
400
+ "error"
401
+ ],
402
+ "properties": {
403
+ "$schema": {
404
+ "const": "https://intentius.io/chant/schemas/workspace/composites/v1/composites.schema.json"
405
+ },
406
+ "contract": {
407
+ "const": 1
408
+ },
409
+ "chant": {
410
+ "type": "string"
411
+ },
412
+ "error": {
413
+ "type": "object",
414
+ "required": [
415
+ "code",
416
+ "message",
417
+ "location"
418
+ ],
419
+ "properties": {
420
+ "code": {
421
+ "enum": [
422
+ "declaration-missing",
423
+ "declaration-ambiguous",
424
+ "declaration-unparseable",
425
+ "declaration-invalid",
426
+ "placement-invalid",
427
+ "reader-too-old",
428
+ "root-chant-required",
429
+ "not-a-git-repository",
430
+ "revision-unknown"
431
+ ]
432
+ },
433
+ "message": {
434
+ "type": "string"
435
+ },
436
+ "location": {
437
+ "description": "Where in the declaration the problem is, or null when it is not in the file.",
438
+ "oneOf": [
439
+ {
440
+ "type": "null"
441
+ },
442
+ {
443
+ "type": "object",
444
+ "required": [
445
+ "file",
446
+ "line",
447
+ "column"
448
+ ],
449
+ "properties": {
450
+ "file": {
451
+ "type": "string"
452
+ },
453
+ "line": {
454
+ "type": "integer",
455
+ "minimum": 1
456
+ },
457
+ "column": {
458
+ "type": "integer",
459
+ "minimum": 1
460
+ }
461
+ }
462
+ }
463
+ ]
464
+ }
465
+ }
466
+ },
467
+ "composites": false
468
+ }
469
+ }
470
+ }
471
+ }