yarramate 0.18.0 → 0.20.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.
- package/README.md +9 -1
- package/catalogues/core-enrichment.yaml +52 -1
- package/dist/adapters/graphify-cli.js +0 -0
- package/dist/adapters/likec4-cli.js +0 -0
- package/dist/adapters/likec4-export.d.ts +1 -1
- package/dist/adapters/likec4-export.js +32 -0
- package/dist/adapters/mcp-cli.js +0 -0
- package/dist/adapters/visual/client.js +0 -1
- package/dist/adapters/visual/protocol-contract.d.ts +118 -35
- package/dist/adapters/visual/protocol-contract.js +1 -11
- package/dist/adapters/visual/protocol.d.ts +8 -1
- package/dist/adapters/visual/protocol.js +86 -46
- package/dist/adapters/visual/request.d.ts +37 -0
- package/dist/adapters/visual/request.js +131 -0
- package/dist/adapters/visual/session-server.d.ts +12 -14
- package/dist/adapters/visual/session-server.js +641 -283
- package/dist/adapters/visual/session-store.d.ts +31 -29
- package/dist/adapters/visual/session-store.js +94 -94
- package/dist/adapters/visual/wire.d.ts +36 -10
- package/dist/adapters/visual-cli.d.ts +3 -0
- package/dist/adapters/visual-cli.js +66 -1
- package/dist/apply-command.d.ts +10 -0
- package/dist/apply-command.js +399 -247
- package/dist/cli.js +0 -0
- package/dist/compiler.d.ts +66 -0
- package/dist/compiler.js +209 -89
- package/dist/graph-projection.d.ts +62 -0
- package/dist/graph-projection.js +222 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/interrogate-command.d.ts +2 -0
- package/dist/interrogate-command.js +22 -0
- package/dist/kind-label.d.ts +8 -0
- package/dist/kind-label.js +8 -0
- package/dist/operations.d.ts +139 -0
- package/dist/operations.js +11 -0
- package/dist/projection.d.ts +2 -0
- package/dist/projection.js +8 -2
- package/dist/reconciliation.js +8 -7
- package/dist/source-document.d.ts +10 -0
- package/dist/source-document.js +21 -1
- package/dist/visual-app/assets/index-6oSR9RGM.js +354 -0
- package/dist/visual-app/assets/index-dwA9AOr5.css +1 -0
- package/dist/visual-app/index.html +2 -2
- package/docs/CONSUMING-YARRAMATE.md +25 -19
- package/package.json +9 -4
- package/schema/yarramate-adapter-mapping.schema.json +1 -1
- package/schema/yarramate-apply-result.schema.json +8 -2
- package/schema/yarramate-document.schema.json +1 -1
- package/schema/yarramate-likec4-diagnostic-result.schema.json +1 -1
- package/schema/yarramate-operations.schema.json +203 -1
- package/schema/yarramate-projection.schema.json +12 -3
- package/schema/yarramate-question-catalogue.schema.json +15 -2
- package/schema/yarramate-visual-event.schema.json +143 -0
- package/schema/yarramate-visual-graph.schema.json +272 -0
- package/schema/yarramate-visual-layout.schema.json +41 -0
- package/schema/yarramate-visual-model.schema.json +6 -44
- package/schema/yarramate-visual-response.schema.json +170 -19
- package/schema/yarramate-visual-session-descriptor.schema.json +1 -1
- package/schema/yarramate-visual-session-request.schema.json +0 -70
- package/schema/yarramate-visual-session-started.schema.json +2 -9
- package/schema/yarramate-visual-status.schema.json +3 -2
- package/skills/yarramate-architecture/SKILL.md +20 -13
- package/skills/yarramate-architecture/references/journey-checklists.md +4 -2
- package/skills/yarramate-architecture/references/native-authoring.md +30 -0
- package/skills/yarramate-architecture/references/visual-conversations.md +149 -150
- package/dist/adapters/visual/likec4-compiler.d.ts +0 -55
- package/dist/adapters/visual/likec4-compiler.js +0 -460
- package/dist/visual-app/assets/index-CGvC8e3R.css +0 -1
- package/dist/visual-app/assets/index-CXuW1tOj.js +0 -209
package/dist/cli.js
CHANGED
|
File without changes
|
package/dist/compiler.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Aspect } from './profile.js';
|
|
1
2
|
export interface WorkspaceSource {
|
|
2
3
|
readonly path: string;
|
|
3
4
|
readonly source: string;
|
|
@@ -43,10 +44,16 @@ export interface SemanticGraph {
|
|
|
43
44
|
}>;
|
|
44
45
|
readonly claims: readonly GraphClaim[];
|
|
45
46
|
}
|
|
47
|
+
export interface RelationshipEndpointAspects {
|
|
48
|
+
readonly source?: readonly Aspect[];
|
|
49
|
+
readonly target?: readonly Aspect[];
|
|
50
|
+
}
|
|
46
51
|
export interface ResolvedProfileContext {
|
|
47
52
|
readonly conceptKindLineages: ReadonlyMap<string, readonly string[]>;
|
|
48
53
|
readonly relationshipKindLineages: ReadonlyMap<string, readonly string[]>;
|
|
49
54
|
readonly conceptKindLayers: ReadonlyMap<string, string>;
|
|
55
|
+
readonly conceptKindAspects: ReadonlyMap<string, string>;
|
|
56
|
+
readonly relationshipKindEndpointAspects: ReadonlyMap<string, RelationshipEndpointAspects>;
|
|
50
57
|
}
|
|
51
58
|
export type CompilationResult = {
|
|
52
59
|
readonly ok: true;
|
|
@@ -63,6 +70,44 @@ export type ContextualCompilationResult = {
|
|
|
63
70
|
readonly ok: false;
|
|
64
71
|
readonly diagnostics: readonly Diagnostic[];
|
|
65
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* One parsed workspace source, retained by a {@link CompilationCache}. Hold it
|
|
75
|
+
* and hand it back; never construct one. `value` is the composed YAML of
|
|
76
|
+
* `source` and nothing else, so an entry is a pure function of its text.
|
|
77
|
+
*/
|
|
78
|
+
export interface ParsedWorkspaceSource {
|
|
79
|
+
readonly source: string;
|
|
80
|
+
readonly kind: 'profile' | 'document';
|
|
81
|
+
readonly value: unknown;
|
|
82
|
+
readonly schemaDiagnostics: readonly Diagnostic[];
|
|
83
|
+
/**
|
|
84
|
+
* Line/column already resolved for this text, keyed by YAML path. An
|
|
85
|
+
* internal memo of the compiler, filled as positions are asked for; a
|
|
86
|
+
* consumer that mutates it corrupts the `source` of later claims.
|
|
87
|
+
*/
|
|
88
|
+
readonly positions: Map<string, ResolvedPosition>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Opaque parse cache returned by {@link compileWorkspaceIncremental} and
|
|
92
|
+
* accepted by its next call. Reuse is decided by exact source-text equality,
|
|
93
|
+
* not by a caller-declared change set and not by a digest, so a stale cache
|
|
94
|
+
* cannot change the compiled output - it can only fail to save work.
|
|
95
|
+
*/
|
|
96
|
+
export interface CompilationCache {
|
|
97
|
+
readonly sources: ReadonlyMap<string, ParsedWorkspaceSource>;
|
|
98
|
+
}
|
|
99
|
+
export type IncrementalCompilationResult = ({
|
|
100
|
+
readonly ok: true;
|
|
101
|
+
readonly graph: SemanticGraph;
|
|
102
|
+
readonly profileContext: ResolvedProfileContext;
|
|
103
|
+
} | {
|
|
104
|
+
readonly ok: false;
|
|
105
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
106
|
+
}) & {
|
|
107
|
+
/** False when every source had to be parsed, e.g. the first call. */
|
|
108
|
+
readonly incremental: boolean;
|
|
109
|
+
readonly cache: CompilationCache;
|
|
110
|
+
};
|
|
66
111
|
export declare const ATTESTATION_PREDICATE_PREFIX = "yarramate/attestation/";
|
|
67
112
|
export declare const attestationClaimValue: (attestation: {
|
|
68
113
|
readonly by: string;
|
|
@@ -75,5 +120,26 @@ export interface AttestationClaimParts {
|
|
|
75
120
|
readonly recordedBy?: string;
|
|
76
121
|
}
|
|
77
122
|
export declare const parseAttestationClaimValue: (value: string) => AttestationClaimParts | undefined;
|
|
123
|
+
export interface ConstraintExpectsParts {
|
|
124
|
+
readonly provider: string;
|
|
125
|
+
readonly key: string;
|
|
126
|
+
readonly value: string;
|
|
127
|
+
}
|
|
128
|
+
export declare const parseConstraintExpectsValue: (value: string) => ConstraintExpectsParts | undefined;
|
|
129
|
+
interface ResolvedPosition {
|
|
130
|
+
readonly line: number;
|
|
131
|
+
readonly col: number;
|
|
132
|
+
}
|
|
78
133
|
export declare function compileWorkspace(sources: readonly WorkspaceSource[]): CompilationResult;
|
|
79
134
|
export declare const compileWorkspaceWithProfileContext: (sources: readonly WorkspaceSource[]) => ContextualCompilationResult;
|
|
135
|
+
/**
|
|
136
|
+
* Compiles the whole workspace, reusing the YAML parse of every source whose
|
|
137
|
+
* text is unchanged since `previous`. The compiled output is byte-identical to
|
|
138
|
+
* {@link compileWorkspaceWithProfileContext} for the same sources: the cache
|
|
139
|
+
* holds parse results only, and every cross-document decision is re-derived.
|
|
140
|
+
*
|
|
141
|
+
* Hold the returned `cache` and pass it to the next call. It retains one
|
|
142
|
+
* composed value per current source and drops sources that left the workspace.
|
|
143
|
+
*/
|
|
144
|
+
export declare const compileWorkspaceIncremental: (sources: readonly WorkspaceSource[], previous?: CompilationCache) => IncrementalCompilationResult;
|
|
145
|
+
export {};
|
package/dist/compiler.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
2
|
import { LineCounter, parseDocument } from 'yaml';
|
|
3
3
|
import { conceptKinds, relationshipPolicies, } from './profile.js';
|
|
4
4
|
import { closestCandidate, describeSchemaViolation, } from './source-document.js';
|
|
@@ -7,7 +7,9 @@ import documentSchema from '../schema/yarramate-document.schema.json' with { typ
|
|
|
7
7
|
import profileSchema from '../schema/yarramate-profile.schema.json' with { type: 'json'
|
|
8
8
|
};
|
|
9
9
|
const coreProfile = 'yarramate/core@0.1';
|
|
10
|
-
const
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const ajv2020Module = require('ajv/dist/2020.js');
|
|
12
|
+
const Ajv2020 = ajv2020Module.default ?? ajv2020Module;
|
|
11
13
|
const validateDocument = new Ajv2020({ allErrors: true }).compile(documentSchema);
|
|
12
14
|
const validateProfile = new Ajv2020({ allErrors: true }).compile(profileSchema);
|
|
13
15
|
const immutableMap = (entries) => {
|
|
@@ -56,6 +58,22 @@ export const parseAttestationClaimValue = (value) => {
|
|
|
56
58
|
...(recordedBy === undefined ? {} : { recordedBy }),
|
|
57
59
|
};
|
|
58
60
|
};
|
|
61
|
+
// Mirrors the compiler's own write-side encoding (ADR 0075): provider and
|
|
62
|
+
// key admit no whitespace, so the first two spaces delimit them and
|
|
63
|
+
// everything after the second space is the expected value verbatim, spaces
|
|
64
|
+
// included. This is the sole authority for decoding the value written at
|
|
65
|
+
// the constraint's `expects` claim — reconciliation.ts delegates here
|
|
66
|
+
// rather than mirroring the regex itself.
|
|
67
|
+
export const parseConstraintExpectsValue = (value) => {
|
|
68
|
+
const match = /^(\S+) (\S+) ([\s\S]+)$/.exec(value);
|
|
69
|
+
if (match === null)
|
|
70
|
+
return undefined;
|
|
71
|
+
return {
|
|
72
|
+
provider: match[1],
|
|
73
|
+
key: match[2],
|
|
74
|
+
value: match[3],
|
|
75
|
+
};
|
|
76
|
+
};
|
|
59
77
|
const describeAspect = (aspect) => aspect.replace('-', ' ');
|
|
60
78
|
// Candidate order is the policy-matrix declaration order: the resolved kind
|
|
61
79
|
// map inserts core policies first, then extension kinds as declared.
|
|
@@ -81,12 +99,143 @@ const diagnosticFailure = (diagnostics) => ({
|
|
|
81
99
|
left.code.localeCompare(right.code) ||
|
|
82
100
|
left.message.localeCompare(right.message)),
|
|
83
101
|
});
|
|
84
|
-
|
|
102
|
+
const nodePosition = (yaml, lineCounter, yamlPath) => {
|
|
103
|
+
const node = yaml.getIn(yamlPath, true);
|
|
104
|
+
const offset = typeof node === 'object' &&
|
|
105
|
+
node !== null &&
|
|
106
|
+
'range' in node &&
|
|
107
|
+
Array.isArray(node.range)
|
|
108
|
+
? node.range[0]
|
|
109
|
+
: 0;
|
|
110
|
+
return lineCounter.linePos(offset);
|
|
111
|
+
};
|
|
112
|
+
// A position is read for every emitted claim's `source`, not only for faults,
|
|
113
|
+
// so a compile that re-derived them from text would parse every fresh source
|
|
114
|
+
// twice - measured at 282us/document against 193us/document for one parse.
|
|
115
|
+
// A source parsed in this call hands its composed document straight to the
|
|
116
|
+
// reader; a source served from cache carries the memo its earlier compile
|
|
117
|
+
// filled and parses only for a path never asked for before. The reader
|
|
118
|
+
// memoises either way, so the returned cache answers next time without the
|
|
119
|
+
// document - and without the memo a delta costs 95% of a full compile.
|
|
120
|
+
const positionReader = (source, positions, fresh) => {
|
|
121
|
+
let parsed = fresh;
|
|
122
|
+
return (yamlPath) => {
|
|
123
|
+
// Paths mix keys and indices; a JSON key cannot confuse `['a']` with
|
|
124
|
+
// `['a', 0]` the way a joined string could, and a wrong hit here would be
|
|
125
|
+
// a wrong line number in compiled output rather than lost work.
|
|
126
|
+
const key = JSON.stringify(yamlPath);
|
|
127
|
+
const memoised = positions.get(key);
|
|
128
|
+
if (memoised !== undefined) {
|
|
129
|
+
return memoised;
|
|
130
|
+
}
|
|
131
|
+
if (parsed === undefined) {
|
|
132
|
+
const lineCounter = new LineCounter();
|
|
133
|
+
parsed = { yaml: parseDocument(source, { lineCounter }), lineCounter };
|
|
134
|
+
}
|
|
135
|
+
const position = nodePosition(parsed.yaml, parsed.lineCounter, yamlPath);
|
|
136
|
+
positions.set(key, position);
|
|
137
|
+
return position;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
// Every field of the entry is derived from `input.source` alone, which is what
|
|
141
|
+
// makes an entry reusable across compiles: profile membership, the composed
|
|
142
|
+
// value, and the faults the text carries on its own. Cross-document faults are
|
|
143
|
+
// never cached - they are re-derived on every compile.
|
|
144
|
+
const parseWorkspaceSource = (input) => {
|
|
145
|
+
const lineCounter = new LineCounter();
|
|
146
|
+
const yaml = parseDocument(input.source, { lineCounter });
|
|
147
|
+
const value = yaml.toJS();
|
|
148
|
+
const parseDiagnostics = yaml.errors.map((error) => {
|
|
149
|
+
const position = error.linePos?.[0] ?? { line: 1, col: 1 };
|
|
150
|
+
return {
|
|
151
|
+
severity: 'error',
|
|
152
|
+
code: 'YM101',
|
|
153
|
+
message: error.message.split(' at line ')[0] ?? error.message,
|
|
154
|
+
path: input.path,
|
|
155
|
+
pointer: '/',
|
|
156
|
+
line: position.line,
|
|
157
|
+
column: position.col,
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
// Classification reads the composed mapping through the YAML document, which
|
|
161
|
+
// types the lookup as `unknown` - the same key the old probe pass read.
|
|
162
|
+
const fresh = { yaml, lineCounter };
|
|
163
|
+
if (yaml.get('format') === 'yarramate/profile/v1') {
|
|
164
|
+
return {
|
|
165
|
+
entry: {
|
|
166
|
+
source: input.source,
|
|
167
|
+
kind: 'profile',
|
|
168
|
+
value,
|
|
169
|
+
schemaDiagnostics: parseDiagnostics,
|
|
170
|
+
positions: new Map(),
|
|
171
|
+
},
|
|
172
|
+
fresh,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const valid = parseDiagnostics.length === 0 && validateDocument(value);
|
|
176
|
+
const schemaDiagnostics = parseDiagnostics.length > 0
|
|
177
|
+
? parseDiagnostics
|
|
178
|
+
: valid
|
|
179
|
+
? []
|
|
180
|
+
: (validateDocument.errors ?? []).map((error) => {
|
|
181
|
+
const property = error.keyword === 'additionalProperties'
|
|
182
|
+
? String(error.params.additionalProperty)
|
|
183
|
+
: undefined;
|
|
184
|
+
const pointer = property
|
|
185
|
+
? `${error.instancePath}/${property}`
|
|
186
|
+
: error.instancePath || '/';
|
|
187
|
+
const yamlPath = pointer
|
|
188
|
+
.split('/')
|
|
189
|
+
.slice(1)
|
|
190
|
+
.map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
|
|
191
|
+
const position = nodePosition(yaml, lineCounter, yamlPath);
|
|
192
|
+
return {
|
|
193
|
+
severity: 'error',
|
|
194
|
+
code: 'YM201',
|
|
195
|
+
message: property
|
|
196
|
+
? `Property "${property}" is not allowed`
|
|
197
|
+
: `Document schema violation: ${describeSchemaViolation(error)}`,
|
|
198
|
+
path: input.path,
|
|
199
|
+
pointer,
|
|
200
|
+
line: position.line,
|
|
201
|
+
column: position.col,
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
entry: {
|
|
206
|
+
source: input.source,
|
|
207
|
+
kind: 'document',
|
|
208
|
+
value,
|
|
209
|
+
schemaDiagnostics,
|
|
210
|
+
positions: new Map(),
|
|
211
|
+
},
|
|
212
|
+
fresh,
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
// Reuse is decided by exact source-text equality against the previous cache, so
|
|
216
|
+
// a wrong or stale cache can only cost work, never change output. Sources that
|
|
217
|
+
// left the workspace leave the returned cache with them.
|
|
218
|
+
const parseSources = (sources, previous) => {
|
|
219
|
+
const entries = new Map();
|
|
220
|
+
let reused = 0;
|
|
221
|
+
const parsed = sources.map((input) => {
|
|
222
|
+
const cached = previous?.sources.get(input.path);
|
|
223
|
+
if (cached !== undefined && cached.source === input.source) {
|
|
224
|
+
reused += 1;
|
|
225
|
+
entries.set(input.path, cached);
|
|
226
|
+
return { input, entry: cached };
|
|
227
|
+
}
|
|
228
|
+
const { entry, fresh } = parseWorkspaceSource(input);
|
|
229
|
+
entries.set(input.path, entry);
|
|
230
|
+
return { input, entry, fresh };
|
|
231
|
+
});
|
|
232
|
+
return { parsed, cache: { sources: entries }, reused };
|
|
233
|
+
};
|
|
234
|
+
function compileWorkspaceResolved(parsed) {
|
|
85
235
|
const profileInputs = [];
|
|
86
236
|
const documentInputs = [];
|
|
87
|
-
for (const source of
|
|
88
|
-
|
|
89
|
-
if (probe.get('format') === 'yarramate/profile/v1') {
|
|
237
|
+
for (const source of parsed) {
|
|
238
|
+
if (source.entry.kind === 'profile') {
|
|
90
239
|
profileInputs.push(source);
|
|
91
240
|
}
|
|
92
241
|
else {
|
|
@@ -128,33 +277,13 @@ function compileWorkspaceResolved(sources) {
|
|
|
128
277
|
});
|
|
129
278
|
const profileDiagnostics = [];
|
|
130
279
|
const pendingProfiles = [];
|
|
131
|
-
for (const input of profileInputs) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const value =
|
|
135
|
-
const positionFor = (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
node !== null &&
|
|
139
|
-
'range' in node &&
|
|
140
|
-
Array.isArray(node.range)
|
|
141
|
-
? node.range[0]
|
|
142
|
-
: 0;
|
|
143
|
-
return lineCounter.linePos(offset);
|
|
144
|
-
};
|
|
145
|
-
if (yaml.errors.length > 0) {
|
|
146
|
-
for (const error of yaml.errors) {
|
|
147
|
-
const position = error.linePos?.[0] ?? { line: 1, col: 1 };
|
|
148
|
-
profileDiagnostics.push({
|
|
149
|
-
severity: 'error',
|
|
150
|
-
code: 'YM101',
|
|
151
|
-
message: error.message.split(' at line ')[0] ?? error.message,
|
|
152
|
-
path: input.path,
|
|
153
|
-
pointer: '/',
|
|
154
|
-
line: position.line,
|
|
155
|
-
column: position.col,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
280
|
+
for (const { input, entry, fresh } of profileInputs) {
|
|
281
|
+
// `validateProfile` below is what checks this shape; the cast carries the
|
|
282
|
+
// same pre-validation assumption the loop has always made.
|
|
283
|
+
const value = entry.value;
|
|
284
|
+
const positionFor = positionReader(input.source, entry.positions, fresh);
|
|
285
|
+
if (entry.schemaDiagnostics.length > 0) {
|
|
286
|
+
profileDiagnostics.push(...entry.schemaDiagnostics);
|
|
158
287
|
continue;
|
|
159
288
|
}
|
|
160
289
|
if (!validateProfile(value)) {
|
|
@@ -365,19 +494,13 @@ function compileWorkspaceResolved(sources) {
|
|
|
365
494
|
if (profileDiagnostics.length > 0) {
|
|
366
495
|
return diagnosticFailure(profileDiagnostics);
|
|
367
496
|
}
|
|
368
|
-
const documents = documentInputs.map((input) => {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
const value =
|
|
497
|
+
const documents = documentInputs.map(({ input, entry, fresh }) => {
|
|
498
|
+
// Schema-checked by `parseWorkspaceSource`; the faults it found are the
|
|
499
|
+
// `schemaDiagnostics` returned below, and they gate every later phase.
|
|
500
|
+
const value = entry.value;
|
|
501
|
+
const positionAt = positionReader(input.source, entry.positions, fresh);
|
|
372
502
|
const location = (yamlPath, pointer) => {
|
|
373
|
-
const
|
|
374
|
-
const offset = typeof node === 'object' &&
|
|
375
|
-
node !== null &&
|
|
376
|
-
'range' in node &&
|
|
377
|
-
Array.isArray(node.range)
|
|
378
|
-
? node.range[0]
|
|
379
|
-
: 0;
|
|
380
|
-
const position = lineCounter.linePos(offset);
|
|
503
|
+
const position = positionAt(yamlPath);
|
|
381
504
|
return {
|
|
382
505
|
document: value?.id ?? '<unknown>',
|
|
383
506
|
path: input.path,
|
|
@@ -386,48 +509,12 @@ function compileWorkspaceResolved(sources) {
|
|
|
386
509
|
column: position.col,
|
|
387
510
|
};
|
|
388
511
|
};
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
path: input.path,
|
|
396
|
-
pointer: '/',
|
|
397
|
-
line: position.line,
|
|
398
|
-
column: position.col,
|
|
399
|
-
};
|
|
400
|
-
});
|
|
401
|
-
const valid = parseDiagnostics.length === 0 && validateDocument(value);
|
|
402
|
-
const schemaDiagnostics = parseDiagnostics.length > 0
|
|
403
|
-
? parseDiagnostics
|
|
404
|
-
: valid
|
|
405
|
-
? []
|
|
406
|
-
: (validateDocument.errors ?? []).map((error) => {
|
|
407
|
-
const property = error.keyword === 'additionalProperties'
|
|
408
|
-
? String(error.params.additionalProperty)
|
|
409
|
-
: undefined;
|
|
410
|
-
const pointer = property
|
|
411
|
-
? `${error.instancePath}/${property}`
|
|
412
|
-
: error.instancePath || '/';
|
|
413
|
-
const yamlPath = pointer
|
|
414
|
-
.split('/')
|
|
415
|
-
.slice(1)
|
|
416
|
-
.map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
|
|
417
|
-
const source = location(yamlPath, pointer);
|
|
418
|
-
return {
|
|
419
|
-
severity: 'error',
|
|
420
|
-
code: 'YM201',
|
|
421
|
-
message: property
|
|
422
|
-
? `Property "${property}" is not allowed`
|
|
423
|
-
: `Document schema violation: ${describeSchemaViolation(error)}`,
|
|
424
|
-
path: input.path,
|
|
425
|
-
pointer,
|
|
426
|
-
line: source.line,
|
|
427
|
-
column: source.column,
|
|
428
|
-
};
|
|
429
|
-
});
|
|
430
|
-
return { input, value, location, schemaDiagnostics };
|
|
512
|
+
return {
|
|
513
|
+
input,
|
|
514
|
+
value,
|
|
515
|
+
location,
|
|
516
|
+
schemaDiagnostics: entry.schemaDiagnostics,
|
|
517
|
+
};
|
|
431
518
|
});
|
|
432
519
|
const claims = [];
|
|
433
520
|
const subjects = [];
|
|
@@ -1346,6 +1433,22 @@ function compileWorkspaceResolved(sources) {
|
|
|
1346
1433
|
conceptKindLayers: immutableMap([...conceptKindByIdentity]
|
|
1347
1434
|
.sort(([left], [right]) => left.localeCompare(right))
|
|
1348
1435
|
.map(([identity, kind]) => [identity, kind.layer])),
|
|
1436
|
+
conceptKindAspects: immutableMap([...conceptKindByIdentity]
|
|
1437
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
1438
|
+
.map(([identity, kind]) => [identity, kind.aspect])),
|
|
1439
|
+
relationshipKindEndpointAspects: immutableMap([...relationshipKindByIdentity]
|
|
1440
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
1441
|
+
.map(([identity, kind]) => [
|
|
1442
|
+
identity,
|
|
1443
|
+
Object.freeze({
|
|
1444
|
+
...(kind.sourceAspects === undefined
|
|
1445
|
+
? {}
|
|
1446
|
+
: { source: Object.freeze([...kind.sourceAspects]) }),
|
|
1447
|
+
...(kind.targetAspects === undefined
|
|
1448
|
+
? {}
|
|
1449
|
+
: { target: Object.freeze([...kind.targetAspects]) }),
|
|
1450
|
+
}),
|
|
1451
|
+
])),
|
|
1349
1452
|
},
|
|
1350
1453
|
graph: {
|
|
1351
1454
|
format: 'yarramate/graph/v2',
|
|
@@ -1361,7 +1464,24 @@ function compileWorkspaceResolved(sources) {
|
|
|
1361
1464
|
};
|
|
1362
1465
|
}
|
|
1363
1466
|
export function compileWorkspace(sources) {
|
|
1364
|
-
const result = compileWorkspaceResolved(sources);
|
|
1467
|
+
const result = compileWorkspaceResolved(parseSources(sources).parsed);
|
|
1365
1468
|
return result.ok ? { ok: true, graph: result.graph } : result;
|
|
1366
1469
|
}
|
|
1367
|
-
export const compileWorkspaceWithProfileContext = (sources) => compileWorkspaceResolved(sources);
|
|
1470
|
+
export const compileWorkspaceWithProfileContext = (sources) => compileWorkspaceResolved(parseSources(sources).parsed);
|
|
1471
|
+
/**
|
|
1472
|
+
* Compiles the whole workspace, reusing the YAML parse of every source whose
|
|
1473
|
+
* text is unchanged since `previous`. The compiled output is byte-identical to
|
|
1474
|
+
* {@link compileWorkspaceWithProfileContext} for the same sources: the cache
|
|
1475
|
+
* holds parse results only, and every cross-document decision is re-derived.
|
|
1476
|
+
*
|
|
1477
|
+
* Hold the returned `cache` and pass it to the next call. It retains one
|
|
1478
|
+
* composed value per current source and drops sources that left the workspace.
|
|
1479
|
+
*/
|
|
1480
|
+
export const compileWorkspaceIncremental = (sources, previous) => {
|
|
1481
|
+
const { parsed, cache, reused } = parseSources(sources, previous);
|
|
1482
|
+
return {
|
|
1483
|
+
...compileWorkspaceResolved(parsed),
|
|
1484
|
+
incremental: reused > 0,
|
|
1485
|
+
cache,
|
|
1486
|
+
};
|
|
1487
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type ResolvedProfileContext, type SemanticGraph } from './compiler.js';
|
|
2
|
+
export interface CanvasNode {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly localId: string;
|
|
5
|
+
readonly document: string;
|
|
6
|
+
readonly kind: string;
|
|
7
|
+
readonly kindLabel: string;
|
|
8
|
+
readonly layer: string | null;
|
|
9
|
+
readonly aspect: string | null;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly description: string | null;
|
|
12
|
+
readonly aka: readonly string[];
|
|
13
|
+
readonly status: string | null;
|
|
14
|
+
readonly owner: string | null;
|
|
15
|
+
readonly distinctFrom: readonly string[];
|
|
16
|
+
readonly supersedes: readonly string[];
|
|
17
|
+
readonly constraints: ReadonlyArray<{
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly ref: string;
|
|
20
|
+
readonly expects: {
|
|
21
|
+
readonly provider: string;
|
|
22
|
+
readonly key: string;
|
|
23
|
+
readonly value: string;
|
|
24
|
+
} | null;
|
|
25
|
+
}>;
|
|
26
|
+
readonly references: ReadonlyArray<{
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly ref: string;
|
|
29
|
+
}>;
|
|
30
|
+
readonly presentIn: readonly string[];
|
|
31
|
+
readonly attestations: ReadonlyArray<{
|
|
32
|
+
readonly topic: string;
|
|
33
|
+
readonly by: string;
|
|
34
|
+
readonly on: string;
|
|
35
|
+
readonly recordedBy: string | null;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export interface CanvasEdge {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly localId: string;
|
|
41
|
+
readonly document: string;
|
|
42
|
+
readonly kind: string;
|
|
43
|
+
readonly kindLabel: string;
|
|
44
|
+
readonly coreKindLabel: string;
|
|
45
|
+
readonly from: string;
|
|
46
|
+
readonly to: string;
|
|
47
|
+
readonly name: string | null;
|
|
48
|
+
readonly description: string | null;
|
|
49
|
+
readonly mode: string | null;
|
|
50
|
+
readonly content: string | null;
|
|
51
|
+
readonly status: string | null;
|
|
52
|
+
readonly references: ReadonlyArray<{
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly ref: string;
|
|
55
|
+
}>;
|
|
56
|
+
readonly presentIn: readonly string[];
|
|
57
|
+
}
|
|
58
|
+
export interface CanvasGraph {
|
|
59
|
+
readonly nodes: readonly CanvasNode[];
|
|
60
|
+
readonly edges: readonly CanvasEdge[];
|
|
61
|
+
}
|
|
62
|
+
export declare function projectGraphForCanvas(graph: SemanticGraph, profileContext: ResolvedProfileContext): CanvasGraph;
|