yarramate 0.5.0 → 0.7.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 (48) hide show
  1. package/README.md +39 -10
  2. package/catalogues/core-enrichment.yaml +700 -0
  3. package/dist/adapters/likec4-cli.js +179 -55
  4. package/dist/adapters/likec4-export.d.ts +1 -1
  5. package/dist/adapters/likec4-prepare.d.ts +6 -0
  6. package/dist/adapters/likec4-prepare.js +40 -2
  7. package/dist/adapters/mcp-cli.js +55 -49
  8. package/dist/apply-command.d.ts +2 -0
  9. package/dist/apply-command.js +199 -0
  10. package/dist/{new-command.d.ts → ask-command.d.ts} +1 -1
  11. package/dist/ask-command.js +729 -0
  12. package/dist/brief.d.ts +3 -0
  13. package/dist/brief.js +235 -0
  14. package/dist/check-command.js +70 -4
  15. package/dist/cli-support.d.ts +4 -1
  16. package/dist/cli-support.js +3 -2
  17. package/dist/cli.js +22 -586
  18. package/dist/compiler.js +45 -7
  19. package/dist/core-contract.d.ts +1 -1
  20. package/dist/{status-command.d.ts → design-command.d.ts} +1 -1
  21. package/dist/design-command.js +218 -0
  22. package/dist/export-command.d.ts +2 -0
  23. package/dist/export-command.js +228 -0
  24. package/dist/interrogate-command.d.ts +104 -0
  25. package/dist/interrogate-command.js +268 -0
  26. package/dist/next-command.d.ts +22 -0
  27. package/dist/next-command.js +167 -0
  28. package/dist/reconciliation.d.ts +2 -0
  29. package/dist/reconciliation.js +38 -0
  30. package/docs/CONSUMING-YARRAMATE.md +28 -21
  31. package/package.json +13 -10
  32. package/schema/yarramate-apply-result.schema.json +32 -0
  33. package/schema/yarramate-ask-result.schema.json +391 -0
  34. package/schema/yarramate-check-result.schema.json +12 -0
  35. package/schema/yarramate-core-contract.schema.json +5 -10
  36. package/schema/yarramate-design-step.schema.json +152 -0
  37. package/schema/yarramate-document.schema.json +76 -9
  38. package/schema/yarramate-interrogation-report.schema.json +89 -0
  39. package/schema/yarramate-likec4-generated-project-v2.schema.json +6 -0
  40. package/schema/yarramate-likec4-generated-project.schema.json +6 -0
  41. package/schema/yarramate-operations.schema.json +303 -0
  42. package/schema/yarramate-question-catalogue.schema.json +431 -0
  43. package/schema/yarramate-reconciliation-report.schema.json +8 -2
  44. package/skills/yarramate-architecture/SKILL.md +42 -17
  45. package/skills/yarramate-architecture/references/native-authoring.md +73 -17
  46. package/dist/new-command.js +0 -111
  47. package/dist/status-command.js +0 -171
  48. package/schema/yarramate-status-result.schema.json +0 -273
@@ -1,111 +0,0 @@
1
- import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
2
- import { dirname, resolve } from 'node:path';
3
- import { humanDiagnostics, usage } from './cli-support.js';
4
- import { loadProjection } from './projection.js';
5
- const singleValueFlags = new Set([
6
- '--id',
7
- '--version',
8
- '--title',
9
- '--description',
10
- '--relationships',
11
- ]);
12
- const repeatableFlags = new Set(['--document', '--subject', '--kind']);
13
- const yamlText = (value) => /^[A-Za-z0-9][A-Za-z0-9 ._/@#-]*$/.test(value)
14
- ? value
15
- : JSON.stringify(value);
16
- export function runNewCommand(options, cwd) {
17
- const [family, target, ...flags] = options;
18
- if (family !== 'projection' || target === undefined || target.startsWith('-')) {
19
- return { exitCode: 2, stdout: '', stderr: usage };
20
- }
21
- const single = new Map();
22
- const repeated = new Map();
23
- for (let index = 0; index < flags.length; index += 2) {
24
- const flag = flags[index];
25
- const value = flags[index + 1];
26
- if (flag === undefined ||
27
- value === undefined ||
28
- value.startsWith('--') ||
29
- (!singleValueFlags.has(flag) && !repeatableFlags.has(flag))) {
30
- return { exitCode: 2, stdout: '', stderr: usage };
31
- }
32
- if (singleValueFlags.has(flag)) {
33
- if (single.has(flag)) {
34
- return { exitCode: 2, stdout: '', stderr: usage };
35
- }
36
- single.set(flag, value);
37
- }
38
- else {
39
- repeated.set(flag, [...(repeated.get(flag) ?? []), value]);
40
- }
41
- }
42
- const id = single.get('--id');
43
- if (id === undefined) {
44
- return { exitCode: 2, stdout: '', stderr: usage };
45
- }
46
- const documents = repeated.get('--document');
47
- const subjects = repeated.get('--subject');
48
- const kinds = repeated.get('--kind');
49
- if (documents === undefined && subjects === undefined && kinds === undefined) {
50
- return {
51
- exitCode: 2,
52
- stdout: '',
53
- stderr: 'new projection requires at least one selector: --document, --subject, or --kind\n',
54
- };
55
- }
56
- const targetPath = resolve(cwd, target);
57
- if (existsSync(targetPath)) {
58
- return {
59
- exitCode: 2,
60
- stdout: '',
61
- stderr: `${target} already exists; nothing was changed\n`,
62
- };
63
- }
64
- const lines = [
65
- 'format: yarramate/projection/v1',
66
- `id: ${yamlText(id)}`,
67
- `version: "${single.get('--version') ?? '1.0'}"`,
68
- 'query:',
69
- ];
70
- const list = (key, values) => {
71
- if (values === undefined)
72
- return;
73
- lines.push(` ${key}:`);
74
- for (const value of values)
75
- lines.push(` - ${yamlText(value)}`);
76
- };
77
- list('subjects', subjects);
78
- list('documents', documents);
79
- list('kinds', kinds);
80
- const relationships = single.get('--relationships');
81
- if (relationships !== undefined) {
82
- lines.push(` relationships: ${yamlText(relationships)}`);
83
- }
84
- const title = single.get('--title');
85
- const description = single.get('--description');
86
- if (title !== undefined || description !== undefined) {
87
- lines.push('presentation:');
88
- if (title !== undefined)
89
- lines.push(` title: ${yamlText(title)}`);
90
- if (description !== undefined) {
91
- lines.push(` description: ${yamlText(description)}`);
92
- }
93
- }
94
- const source = `${lines.join('\n')}\n`;
95
- const loaded = loadProjection({ path: target, source });
96
- if (!loaded.ok) {
97
- return {
98
- exitCode: 1,
99
- stdout: '',
100
- stderr: humanDiagnostics(loaded.diagnostics),
101
- };
102
- }
103
- mkdirSync(dirname(targetPath), { recursive: true });
104
- writeFileSync(targetPath, source, 'utf8');
105
- return {
106
- exitCode: 0,
107
- stdout: `Created ${target} (${loaded.projection.id}@${loaded.projection.version})\n` +
108
- 'Include it in the workspace manifest projections list if no glob already covers it\n',
109
- stderr: '',
110
- };
111
- }
@@ -1,171 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { resolve } from 'node:path';
3
- import { parseDocument } from 'yaml';
4
- import { runCheckCommand } from './check-command.js';
5
- import { diagnosticJson, humanDiagnostics, usage, } from './cli-support.js';
6
- import { compileWorkspace } from './compiler.js';
7
- import { evaluateEvidenceWorkspace, loadEvidence } from './evidence.js';
8
- import { loadProjection } from './projection.js';
9
- import { reconcileEvidenceReports, } from './reconciliation.js';
10
- import { loadWorkspaceManifest } from './workspace.js';
11
- const plural = (count, singular, pluralForm) => `${count} ${count === 1 ? singular : (pluralForm ?? `${singular}s`)}`;
12
- export function runStatusCommand(options, cwd) {
13
- const json = options.includes('--json');
14
- const paths = options.filter((option) => option !== '--json');
15
- const [workspacePath] = paths;
16
- if (paths.length !== 1 ||
17
- workspacePath === undefined ||
18
- workspacePath.startsWith('-')) {
19
- return { exitCode: 2, stdout: '', stderr: usage };
20
- }
21
- try {
22
- const manifestSource = readFileSync(resolve(cwd, workspacePath), 'utf8');
23
- if (parseDocument(manifestSource).get('format') !==
24
- 'yarramate/workspace/v1') {
25
- return {
26
- exitCode: 2,
27
- stdout: '',
28
- stderr: 'status requires an explicit workspace manifest (yarramate/workspace/v1)\n',
29
- };
30
- }
31
- const loadedWorkspace = loadWorkspaceManifest({ path: workspacePath, source: manifestSource }, cwd);
32
- if (!loadedWorkspace.ok) {
33
- return {
34
- exitCode: 1,
35
- stdout: json
36
- ? diagnosticJson(loadedWorkspace.diagnostics)
37
- : humanDiagnostics(loadedWorkspace.diagnostics),
38
- stderr: '',
39
- };
40
- }
41
- const workspace = loadedWorkspace.workspace;
42
- const checked = runCheckCommand([workspacePath, '--json'], cwd);
43
- const checkPayload = JSON.parse(checked.stdout);
44
- const projections = workspace.projections.map((path) => {
45
- const loaded = loadProjection({
46
- path,
47
- source: readFileSync(resolve(cwd, path), 'utf8'),
48
- });
49
- return loaded.ok
50
- ? {
51
- id: loaded.projection.id,
52
- path,
53
- ...(loaded.projection.presentation?.title === undefined
54
- ? {}
55
- : { title: loaded.projection.presentation.title }),
56
- }
57
- : { id: path, path };
58
- });
59
- let documents = workspace.documents.map((path) => ({ id: path, path }));
60
- let states = [];
61
- let reconciliation;
62
- if (checkPayload.ok) {
63
- const compilation = compileWorkspace([...workspace.profiles, ...workspace.documents].map((path) => ({
64
- path,
65
- source: readFileSync(resolve(cwd, path), 'utf8'),
66
- })));
67
- if (compilation.ok) {
68
- const sourceByDocument = new Map(compilation.graph.documents.map((document) => [
69
- document.id,
70
- document.source,
71
- ]));
72
- documents = workspace.documents.map((path) => {
73
- const id = [...sourceByDocument.entries()].find(([, source]) => source === path)?.[0];
74
- return { id: id ?? path, path };
75
- });
76
- states = compilation.graph.claims
77
- .filter(({ predicate }) => predicate === 'yarramate/state/type')
78
- .map(({ subject, object }) => ({
79
- id: subject,
80
- type: 'value' in object && typeof object.value === 'string'
81
- ? object.value
82
- : 'baseline',
83
- }));
84
- if (workspace.evidence.length > 0) {
85
- const evidenceDocuments = workspace.evidence.flatMap((path) => {
86
- const loaded = loadEvidence({
87
- path,
88
- source: readFileSync(resolve(cwd, path), 'utf8'),
89
- });
90
- return loaded.ok ? [loaded.evidence] : [];
91
- });
92
- const evaluation = evaluateEvidenceWorkspace(compilation.graph, evidenceDocuments);
93
- if (evaluation.ok) {
94
- reconciliation = reconcileEvidenceReports(workspace.id, evaluation.reports, compilation.graph).summary;
95
- }
96
- }
97
- }
98
- }
99
- const result = {
100
- format: 'yarramate/status-result/v1',
101
- workspace: workspace.id,
102
- ok: checkPayload.ok,
103
- check: {
104
- ok: checkPayload.ok,
105
- diagnostics: checkPayload.ok ? [] : checkPayload.diagnostics,
106
- ...(checkPayload.counted === undefined
107
- ? {}
108
- : { counted: checkPayload.counted }),
109
- },
110
- ...(reconciliation === undefined ? {} : { reconciliation }),
111
- inventory: {
112
- documents,
113
- profiles: workspace.profiles,
114
- states,
115
- projections,
116
- evidence: workspace.evidence,
117
- adapterMappings: workspace.adapterMappings,
118
- contracts: workspace.contracts,
119
- },
120
- };
121
- if (json) {
122
- return {
123
- exitCode: result.ok ? 0 : 1,
124
- stdout: `${JSON.stringify(result, null, 2)}\n`,
125
- stderr: '',
126
- };
127
- }
128
- const lines = [];
129
- const counted = result.check.counted;
130
- lines.push(`Workspace ${result.workspace}: check ${result.ok ? 'ok' : 'failing'}` +
131
- (counted === undefined
132
- ? ''
133
- : ` (${plural(counted.concepts, 'concept')}, ` +
134
- `${plural(counted.relationships, 'relationship')}, ` +
135
- `${plural(counted.states, 'state')}, ` +
136
- `${plural(counted.documents, 'document')})`));
137
- if (!result.ok) {
138
- lines.push(`Diagnostics: ${plural(result.check.diagnostics.length, 'error')}; run \`yarramate check ${workspacePath}\` for details`);
139
- }
140
- if (result.reconciliation !== undefined) {
141
- lines.push(`Reconciliation: ${plural(result.reconciliation.observations, 'observation')}, ` +
142
- `${result.reconciliation.confirmed} confirmed, ` +
143
- `${plural(result.reconciliation.findings, 'finding')}` +
144
- (result.reconciliation.findings > 0
145
- ? ` (${result.reconciliation.contradicted} contradicted, ` +
146
- `${result.reconciliation.unknown} unknown, ` +
147
- `${result.reconciliation.notObserved} not observed)`
148
- : ''));
149
- }
150
- lines.push(`Documents: ${documents.map(({ id }) => id).join(', ') || 'none'}`);
151
- if (states.length > 0) {
152
- lines.push(`States: ${states.map(({ id, type }) => `${id} (${type})`).join(', ')}`);
153
- }
154
- lines.push(`Projections: ${projections
155
- .map(({ id, title }) => title === undefined ? id : `${id} — ${title}`)
156
- .join('; ') || 'none'}`);
157
- lines.push(`Profiles: ${workspace.profiles.length} · ` +
158
- `Evidence: ${workspace.evidence.length} · ` +
159
- `Adapter mappings: ${workspace.adapterMappings.length} · ` +
160
- `Contracts: ${workspace.contracts.length}`);
161
- return {
162
- exitCode: result.ok ? 0 : 1,
163
- stdout: `${lines.join('\n')}\n`,
164
- stderr: '',
165
- };
166
- }
167
- catch (error) {
168
- const message = error instanceof Error ? error.message : String(error);
169
- return { exitCode: 2, stdout: '', stderr: `${message}\n` };
170
- }
171
- }
@@ -1,273 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://yarramate.org/schema/status-result/v1",
4
- "title": "YarraMate workspace status result",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "required": [
8
- "format",
9
- "workspace",
10
- "ok",
11
- "check",
12
- "inventory"
13
- ],
14
- "properties": {
15
- "format": {
16
- "const": "yarramate/status-result/v1"
17
- },
18
- "workspace": {
19
- "type": "string",
20
- "minLength": 1
21
- },
22
- "ok": {
23
- "type": "boolean"
24
- },
25
- "check": {
26
- "type": "object",
27
- "additionalProperties": false,
28
- "required": [
29
- "ok",
30
- "diagnostics"
31
- ],
32
- "properties": {
33
- "ok": {
34
- "type": "boolean"
35
- },
36
- "diagnostics": {
37
- "type": "array",
38
- "items": {
39
- "$ref": "#/$defs/diagnostic"
40
- }
41
- },
42
- "counted": {
43
- "type": "object",
44
- "additionalProperties": false,
45
- "required": [
46
- "documents",
47
- "concepts",
48
- "relationships",
49
- "states"
50
- ],
51
- "properties": {
52
- "documents": {
53
- "type": "integer",
54
- "minimum": 0
55
- },
56
- "concepts": {
57
- "type": "integer",
58
- "minimum": 0
59
- },
60
- "relationships": {
61
- "type": "integer",
62
- "minimum": 0
63
- },
64
- "states": {
65
- "type": "integer",
66
- "minimum": 0
67
- }
68
- }
69
- }
70
- }
71
- },
72
- "reconciliation": {
73
- "type": "object",
74
- "additionalProperties": false,
75
- "required": [
76
- "evidenceDocuments",
77
- "observations",
78
- "confirmed",
79
- "findings",
80
- "contradicted",
81
- "unknown",
82
- "notObserved"
83
- ],
84
- "properties": {
85
- "evidenceDocuments": {
86
- "type": "integer",
87
- "minimum": 0
88
- },
89
- "observations": {
90
- "type": "integer",
91
- "minimum": 0
92
- },
93
- "confirmed": {
94
- "type": "integer",
95
- "minimum": 0
96
- },
97
- "findings": {
98
- "type": "integer",
99
- "minimum": 0
100
- },
101
- "contradicted": {
102
- "type": "integer",
103
- "minimum": 0
104
- },
105
- "unknown": {
106
- "type": "integer",
107
- "minimum": 0
108
- },
109
- "notObserved": {
110
- "type": "integer",
111
- "minimum": 0
112
- }
113
- }
114
- },
115
- "inventory": {
116
- "type": "object",
117
- "additionalProperties": false,
118
- "required": [
119
- "documents",
120
- "profiles",
121
- "states",
122
- "projections",
123
- "evidence",
124
- "adapterMappings",
125
- "contracts"
126
- ],
127
- "properties": {
128
- "documents": {
129
- "type": "array",
130
- "items": {
131
- "type": "object",
132
- "additionalProperties": false,
133
- "required": [
134
- "id",
135
- "path"
136
- ],
137
- "properties": {
138
- "id": {
139
- "type": "string",
140
- "minLength": 1
141
- },
142
- "path": {
143
- "type": "string",
144
- "minLength": 1
145
- }
146
- }
147
- }
148
- },
149
- "profiles": {
150
- "type": "array",
151
- "items": {
152
- "type": "string",
153
- "minLength": 1
154
- }
155
- },
156
- "states": {
157
- "type": "array",
158
- "items": {
159
- "type": "object",
160
- "additionalProperties": false,
161
- "required": [
162
- "id",
163
- "type"
164
- ],
165
- "properties": {
166
- "id": {
167
- "type": "string",
168
- "minLength": 1
169
- },
170
- "type": {
171
- "enum": [
172
- "baseline",
173
- "transition",
174
- "target"
175
- ]
176
- }
177
- }
178
- }
179
- },
180
- "projections": {
181
- "type": "array",
182
- "items": {
183
- "type": "object",
184
- "additionalProperties": false,
185
- "required": [
186
- "id",
187
- "path"
188
- ],
189
- "properties": {
190
- "id": {
191
- "type": "string",
192
- "minLength": 1
193
- },
194
- "path": {
195
- "type": "string",
196
- "minLength": 1
197
- },
198
- "title": {
199
- "type": "string",
200
- "minLength": 1
201
- }
202
- }
203
- }
204
- },
205
- "evidence": {
206
- "type": "array",
207
- "items": {
208
- "type": "string",
209
- "minLength": 1
210
- }
211
- },
212
- "adapterMappings": {
213
- "type": "array",
214
- "items": {
215
- "type": "string",
216
- "minLength": 1
217
- }
218
- },
219
- "contracts": {
220
- "type": "array",
221
- "items": {
222
- "type": "string",
223
- "minLength": 1
224
- }
225
- }
226
- }
227
- }
228
- },
229
- "$defs": {
230
- "diagnostic": {
231
- "type": "object",
232
- "additionalProperties": false,
233
- "required": [
234
- "severity",
235
- "code",
236
- "message",
237
- "path",
238
- "pointer",
239
- "line",
240
- "column"
241
- ],
242
- "properties": {
243
- "severity": {
244
- "const": "error"
245
- },
246
- "code": {
247
- "type": "string",
248
- "pattern": "^YM[0-9]{3}$"
249
- },
250
- "message": {
251
- "type": "string",
252
- "minLength": 1
253
- },
254
- "path": {
255
- "type": "string",
256
- "minLength": 1
257
- },
258
- "pointer": {
259
- "type": "string",
260
- "pattern": "^/"
261
- },
262
- "line": {
263
- "type": "integer",
264
- "minimum": 1
265
- },
266
- "column": {
267
- "type": "integer",
268
- "minimum": 1
269
- }
270
- }
271
- }
272
- }
273
- }