yarramate 0.6.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 (38) hide show
  1. package/README.md +39 -12
  2. package/catalogues/core-enrichment.yaml +700 -0
  3. package/dist/adapters/mcp-cli.js +55 -49
  4. package/dist/apply-command.d.ts +2 -0
  5. package/dist/apply-command.js +199 -0
  6. package/dist/{new-command.d.ts → ask-command.d.ts} +1 -1
  7. package/dist/ask-command.js +729 -0
  8. package/dist/brief.d.ts +3 -0
  9. package/dist/brief.js +235 -0
  10. package/dist/cli-support.d.ts +1 -1
  11. package/dist/cli-support.js +1 -1
  12. package/dist/cli.js +22 -590
  13. package/dist/compiler.js +13 -0
  14. package/dist/core-contract.d.ts +1 -1
  15. package/dist/{status-command.d.ts → design-command.d.ts} +1 -1
  16. package/dist/design-command.js +218 -0
  17. package/dist/export-command.d.ts +2 -0
  18. package/dist/export-command.js +228 -0
  19. package/dist/interrogate-command.d.ts +104 -0
  20. package/dist/interrogate-command.js +268 -0
  21. package/dist/next-command.d.ts +5 -8
  22. package/dist/next-command.js +106 -211
  23. package/docs/CONSUMING-YARRAMATE.md +28 -21
  24. package/package.json +13 -11
  25. package/schema/yarramate-apply-result.schema.json +32 -0
  26. package/schema/yarramate-ask-result.schema.json +391 -0
  27. package/schema/yarramate-core-contract.schema.json +5 -11
  28. package/schema/yarramate-design-step.schema.json +152 -0
  29. package/schema/yarramate-document.schema.json +76 -9
  30. package/schema/yarramate-interrogation-report.schema.json +89 -0
  31. package/schema/yarramate-operations.schema.json +303 -0
  32. package/schema/yarramate-question-catalogue.schema.json +431 -0
  33. package/skills/yarramate-architecture/SKILL.md +42 -17
  34. package/skills/yarramate-architecture/references/native-authoring.md +73 -17
  35. package/dist/new-command.js +0 -111
  36. package/dist/status-command.js +0 -174
  37. package/schema/yarramate-next-result.schema.json +0 -85
  38. package/schema/yarramate-status-result.schema.json +0 -278
@@ -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,174 +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
- (result.reconciliation.subjectsWithoutEvidence > 0
150
- ? `, ${plural(result.reconciliation.subjectsWithoutEvidence, 'current subject')} without evidence`
151
- : ''));
152
- }
153
- lines.push(`Documents: ${documents.map(({ id }) => id).join(', ') || 'none'}`);
154
- if (states.length > 0) {
155
- lines.push(`States: ${states.map(({ id, type }) => `${id} (${type})`).join(', ')}`);
156
- }
157
- lines.push(`Projections: ${projections
158
- .map(({ id, title }) => title === undefined ? id : `${id} — ${title}`)
159
- .join('; ') || 'none'}`);
160
- lines.push(`Profiles: ${workspace.profiles.length} · ` +
161
- `Evidence: ${workspace.evidence.length} · ` +
162
- `Adapter mappings: ${workspace.adapterMappings.length} · ` +
163
- `Contracts: ${workspace.contracts.length}`);
164
- return {
165
- exitCode: result.ok ? 0 : 1,
166
- stdout: `${lines.join('\n')}\n`,
167
- stderr: '',
168
- };
169
- }
170
- catch (error) {
171
- const message = error instanceof Error ? error.message : String(error);
172
- return { exitCode: 2, stdout: '', stderr: `${message}\n` };
173
- }
174
- }
@@ -1,85 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://yarramate.org/schema/next-result/v1",
4
- "title": "YarraMate next result",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "required": ["format", "workspace", "projection", "subjects"],
8
- "properties": {
9
- "format": {
10
- "const": "yarramate/next-result/v1"
11
- },
12
- "workspace": {
13
- "type": "string",
14
- "minLength": 1
15
- },
16
- "projection": {
17
- "type": "string",
18
- "minLength": 1
19
- },
20
- "subjects": {
21
- "type": "array",
22
- "items": {
23
- "$ref": "#/$defs/subject"
24
- }
25
- }
26
- },
27
- "$defs": {
28
- "subject": {
29
- "type": "object",
30
- "additionalProperties": false,
31
- "required": ["id", "kind", "dependsOn", "requiredBy", "evidence"],
32
- "properties": {
33
- "id": {
34
- "type": "string",
35
- "minLength": 1
36
- },
37
- "kind": {
38
- "type": "string",
39
- "minLength": 1
40
- },
41
- "name": {
42
- "type": "string"
43
- },
44
- "dependsOn": {
45
- "type": "array",
46
- "items": {
47
- "type": "string",
48
- "minLength": 1
49
- }
50
- },
51
- "requiredBy": {
52
- "type": "array",
53
- "items": {
54
- "type": "string",
55
- "minLength": 1
56
- }
57
- },
58
- "evidence": {
59
- "$ref": "#/$defs/coverage"
60
- },
61
- "cycle": {
62
- "const": true
63
- }
64
- }
65
- },
66
- "coverage": {
67
- "type": "object",
68
- "additionalProperties": false,
69
- "required": [
70
- "observations",
71
- "confirmed",
72
- "contradicted",
73
- "unknown",
74
- "notObserved"
75
- ],
76
- "properties": {
77
- "observations": { "type": "integer", "minimum": 0 },
78
- "confirmed": { "type": "integer", "minimum": 0 },
79
- "contradicted": { "type": "integer", "minimum": 0 },
80
- "unknown": { "type": "integer", "minimum": 0 },
81
- "notObserved": { "type": "integer", "minimum": 0 }
82
- }
83
- }
84
- }
85
- }
@@ -1,278 +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
- "subjectsWithoutEvidence"
84
- ],
85
- "properties": {
86
- "evidenceDocuments": {
87
- "type": "integer",
88
- "minimum": 0
89
- },
90
- "observations": {
91
- "type": "integer",
92
- "minimum": 0
93
- },
94
- "confirmed": {
95
- "type": "integer",
96
- "minimum": 0
97
- },
98
- "findings": {
99
- "type": "integer",
100
- "minimum": 0
101
- },
102
- "contradicted": {
103
- "type": "integer",
104
- "minimum": 0
105
- },
106
- "unknown": {
107
- "type": "integer",
108
- "minimum": 0
109
- },
110
- "notObserved": {
111
- "type": "integer",
112
- "minimum": 0
113
- },
114
- "subjectsWithoutEvidence": {
115
- "type": "integer",
116
- "minimum": 0
117
- }
118
- }
119
- },
120
- "inventory": {
121
- "type": "object",
122
- "additionalProperties": false,
123
- "required": [
124
- "documents",
125
- "profiles",
126
- "states",
127
- "projections",
128
- "evidence",
129
- "adapterMappings",
130
- "contracts"
131
- ],
132
- "properties": {
133
- "documents": {
134
- "type": "array",
135
- "items": {
136
- "type": "object",
137
- "additionalProperties": false,
138
- "required": [
139
- "id",
140
- "path"
141
- ],
142
- "properties": {
143
- "id": {
144
- "type": "string",
145
- "minLength": 1
146
- },
147
- "path": {
148
- "type": "string",
149
- "minLength": 1
150
- }
151
- }
152
- }
153
- },
154
- "profiles": {
155
- "type": "array",
156
- "items": {
157
- "type": "string",
158
- "minLength": 1
159
- }
160
- },
161
- "states": {
162
- "type": "array",
163
- "items": {
164
- "type": "object",
165
- "additionalProperties": false,
166
- "required": [
167
- "id",
168
- "type"
169
- ],
170
- "properties": {
171
- "id": {
172
- "type": "string",
173
- "minLength": 1
174
- },
175
- "type": {
176
- "enum": [
177
- "baseline",
178
- "transition",
179
- "target"
180
- ]
181
- }
182
- }
183
- }
184
- },
185
- "projections": {
186
- "type": "array",
187
- "items": {
188
- "type": "object",
189
- "additionalProperties": false,
190
- "required": [
191
- "id",
192
- "path"
193
- ],
194
- "properties": {
195
- "id": {
196
- "type": "string",
197
- "minLength": 1
198
- },
199
- "path": {
200
- "type": "string",
201
- "minLength": 1
202
- },
203
- "title": {
204
- "type": "string",
205
- "minLength": 1
206
- }
207
- }
208
- }
209
- },
210
- "evidence": {
211
- "type": "array",
212
- "items": {
213
- "type": "string",
214
- "minLength": 1
215
- }
216
- },
217
- "adapterMappings": {
218
- "type": "array",
219
- "items": {
220
- "type": "string",
221
- "minLength": 1
222
- }
223
- },
224
- "contracts": {
225
- "type": "array",
226
- "items": {
227
- "type": "string",
228
- "minLength": 1
229
- }
230
- }
231
- }
232
- }
233
- },
234
- "$defs": {
235
- "diagnostic": {
236
- "type": "object",
237
- "additionalProperties": false,
238
- "required": [
239
- "severity",
240
- "code",
241
- "message",
242
- "path",
243
- "pointer",
244
- "line",
245
- "column"
246
- ],
247
- "properties": {
248
- "severity": {
249
- "const": "error"
250
- },
251
- "code": {
252
- "type": "string",
253
- "pattern": "^YM[0-9]{3}$"
254
- },
255
- "message": {
256
- "type": "string",
257
- "minLength": 1
258
- },
259
- "path": {
260
- "type": "string",
261
- "minLength": 1
262
- },
263
- "pointer": {
264
- "type": "string",
265
- "pattern": "^/"
266
- },
267
- "line": {
268
- "type": "integer",
269
- "minimum": 1
270
- },
271
- "column": {
272
- "type": "integer",
273
- "minimum": 1
274
- }
275
- }
276
- }
277
- }
278
- }