@beehexa/hexasync-template-index 2608.20.18 → 2608.20.32
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/dist/checkpoints.d.ts +47 -0
- package/dist/checkpoints.d.ts.map +1 -0
- package/dist/checkpoints.js +59 -0
- package/dist/checkpoints.js.map +1 -0
- package/dist/cursorContext.d.ts +204 -0
- package/dist/cursorContext.d.ts.map +1 -0
- package/dist/cursorContext.js +479 -0
- package/dist/cursorContext.js.map +1 -0
- package/dist/detectors.d.ts +103 -0
- package/dist/detectors.d.ts.map +1 -0
- package/dist/detectors.js +104 -0
- package/dist/detectors.js.map +1 -0
- package/dist/discovery.d.ts +249 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +455 -0
- package/dist/discovery.js.map +1 -0
- package/dist/effectiveGraph.d.ts +251 -0
- package/dist/effectiveGraph.d.ts.map +1 -0
- package/dist/effectiveGraph.js +559 -0
- package/dist/effectiveGraph.js.map +1 -0
- package/dist/failures.d.ts +50 -0
- package/dist/failures.d.ts.map +1 -0
- package/dist/failures.js +125 -0
- package/dist/failures.js.map +1 -0
- package/dist/graph.d.ts +47 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +230 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/queries.d.ts +102 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +469 -0
- package/dist/queries.js.map +1 -0
- package/dist/ranges.d.ts +104 -0
- package/dist/ranges.d.ts.map +1 -0
- package/dist/ranges.js +411 -0
- package/dist/ranges.js.map +1 -0
- package/dist/resolveField.d.ts +125 -0
- package/dist/resolveField.d.ts.map +1 -0
- package/dist/resolveField.js +234 -0
- package/dist/resolveField.js.map +1 -0
- package/dist/tier1Service.d.ts +96 -0
- package/dist/tier1Service.d.ts.map +1 -0
- package/dist/tier1Service.js +194 -0
- package/dist/tier1Service.js.map +1 -0
- package/dist/tier2Service.d.ts +195 -0
- package/dist/tier2Service.d.ts.map +1 -0
- package/dist/tier2Service.js +642 -0
- package/dist/tier2Service.js.map +1 -0
- package/dist/yamlScalar.d.ts +17 -0
- package/dist/yamlScalar.d.ts.map +1 -0
- package/dist/yamlScalar.js +101 -0
- package/dist/yamlScalar.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the cursor is pointing at, semantically (Story 3.7, FR-48 and FR-49).
|
|
3
|
+
*
|
|
4
|
+
* Every context-aware feature in later phases — completion, hover, definition, code actions —
|
|
5
|
+
* needs the same answer, and the answer has to be about MEANING rather than about the property's
|
|
6
|
+
* name. `displayType` under a step and `displayType` under an option input are the same eleven
|
|
7
|
+
* characters and two unrelated things; a feature keyed to the name gets one of them wrong.
|
|
8
|
+
*
|
|
9
|
+
* Two rules shape everything here:
|
|
10
|
+
*
|
|
11
|
+
* - **It reads, and only reads.** Resolution runs on cursor movement, so it takes an existing
|
|
12
|
+
* snapshot and never composes. A function that could trigger a build would make moving the
|
|
13
|
+
* caret the most expensive thing in the editor (NFR-8's anti-pattern, stated as code).
|
|
14
|
+
* - **The measured registry decides, plus the document.** Reference kinds come from
|
|
15
|
+
* `references.ts`, which knows the fixed targets, the two properties whose target is chosen by
|
|
16
|
+
* a SIBLING (`entityId` follows `entityType`, `targetId` follows `targetType`), the value shapes
|
|
17
|
+
* that make a value a reference at all, and the one collection whose KEY is a reference.
|
|
18
|
+
*
|
|
19
|
+
* **A schema lookup used to sit here and has been removed (2026-08-02).** `x-hexasync-reference`,
|
|
20
|
+
* `x-hexasync-step-type` and `x-hexasync-expressions` were authored into the asset bundle and then
|
|
21
|
+
* deleted, because a per-node annotation cannot express a sibling-discriminated reference or a
|
|
22
|
+
* value-shape-dependent one, and the per-definition problem it was designed for does not occur
|
|
23
|
+
* among reference properties. The `displayType` collision in the paragraph above is real, but it is
|
|
24
|
+
* a description-and-completion concern that VS Code resolves natively from the schema — not a
|
|
25
|
+
* reference concern. Retired Story 3.9; reasoning in `NOTES-epic-3.md` §5a.
|
|
26
|
+
*/
|
|
27
|
+
import { parseDocument, visit, isScalar, isPair, isSeq } from 'yaml';
|
|
28
|
+
import { classifyTemplating, } from '@beehexa/hexasync-template-model';
|
|
29
|
+
import { resolveReferenceKind, nestedReferenceBlockFor, COLLECTIONS_KEYED_BY_REFERENCE, KEY_REFERENCE_PROPERTY, } from '@beehexa/hexasync-template-model';
|
|
30
|
+
/**
|
|
31
|
+
* The property whose value names a step's variant.
|
|
32
|
+
*
|
|
33
|
+
* One constant, not an annotation set: the variant is written in the document the developer is
|
|
34
|
+
* looking at, as a sibling of every property inside the step. `x-hexasync-step-type` existed to
|
|
35
|
+
* say this and said nothing the file does not already.
|
|
36
|
+
*/
|
|
37
|
+
const STEP_TYPE_PROPERTY = 'displayType';
|
|
38
|
+
/**
|
|
39
|
+
* Locate the cursor within a YAML document.
|
|
40
|
+
*
|
|
41
|
+
* Walks the parsed AST rather than the text: a bracket-counting scan gets `a: "b: c"` wrong, and
|
|
42
|
+
* the parser already knows the answer. Returns the innermost node whose range contains the
|
|
43
|
+
* offset, along with the path to it.
|
|
44
|
+
*/
|
|
45
|
+
export function pathAtOffset(text, offset, parsed) {
|
|
46
|
+
// Accepts an already-parsed document so a caller resolving several things about one cursor pays
|
|
47
|
+
// for one parse. Measured 85 ms on an 82 KB authored partial and 653 ms on a 1 MB output.yaml,
|
|
48
|
+
// and this runs on caret movement, so parsing twice for one keystroke is not affordable.
|
|
49
|
+
const doc = parsed ?? parseDocument(text, { keepSourceTokens: true });
|
|
50
|
+
if (!doc.contents)
|
|
51
|
+
return { path: [], nodeKind: 'empty' };
|
|
52
|
+
let best;
|
|
53
|
+
visit(doc, (key, node, ancestors) => {
|
|
54
|
+
const range = node?.range;
|
|
55
|
+
if (!range)
|
|
56
|
+
return;
|
|
57
|
+
const [start, valueEnd] = range;
|
|
58
|
+
// The third element is the end INCLUDING trailing whitespace and comments; using it would
|
|
59
|
+
// claim the cursor is inside a value when it is on the blank line after it.
|
|
60
|
+
if (offset < start || offset > valueEnd)
|
|
61
|
+
return;
|
|
62
|
+
const path = pathFrom(ancestors, node);
|
|
63
|
+
const nodeKind = key === 'key'
|
|
64
|
+
? 'key'
|
|
65
|
+
: typeof key === 'number'
|
|
66
|
+
? 'sequence-item'
|
|
67
|
+
: 'value';
|
|
68
|
+
// Deeper nodes are visited later, so the last containing node is the innermost.
|
|
69
|
+
best = { path, nodeKind, node };
|
|
70
|
+
});
|
|
71
|
+
if (!best)
|
|
72
|
+
return { path: [], nodeKind: 'empty' };
|
|
73
|
+
const scalar = isScalar(best.node) ? best.node : undefined;
|
|
74
|
+
return {
|
|
75
|
+
path: best.path,
|
|
76
|
+
nodeKind: best.nodeKind,
|
|
77
|
+
value: scalar
|
|
78
|
+
? scalar.value
|
|
79
|
+
: best.node?.toJSON?.(),
|
|
80
|
+
selection: typeof scalar?.value === 'string' ? scalar.value : undefined,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Turn `visit`'s ancestor chain into a path of keys and indices.
|
|
85
|
+
*
|
|
86
|
+
* The chain runs Document → … → parent, so the node being visited is appended to make every link
|
|
87
|
+
* a parent/child pair. Each link contributes at most one segment: a sequence contributes the
|
|
88
|
+
* index of the child within it, and a pair contributes its key — but only when the child is the
|
|
89
|
+
* pair's VALUE, since a cursor sitting on the key is not inside anything the key names.
|
|
90
|
+
*/
|
|
91
|
+
function pathFrom(ancestors, node) {
|
|
92
|
+
const chain = [...ancestors, node];
|
|
93
|
+
const path = [];
|
|
94
|
+
for (let i = 0; i < chain.length - 1; i++) {
|
|
95
|
+
const parent = chain[i];
|
|
96
|
+
const child = chain[i + 1];
|
|
97
|
+
if (isSeq(parent)) {
|
|
98
|
+
const at = parent.items.indexOf(child);
|
|
99
|
+
if (at >= 0)
|
|
100
|
+
path.push(at);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (isPair(parent) && child === parent.value && isScalar(parent.key)) {
|
|
104
|
+
path.push(String(parent.key.value));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return path;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Resolve what the cursor points at.
|
|
111
|
+
*
|
|
112
|
+
* Synchronous and pure by design — see the file header. Callable on every caret move.
|
|
113
|
+
*/
|
|
114
|
+
export function resolveCursorContext(input) {
|
|
115
|
+
const { graph, file, text, offset } = input;
|
|
116
|
+
// The file has to belong to the project the graph describes. A graph for a DIFFERENT project
|
|
117
|
+
// would answer confidently and wrongly, which is worse than declining.
|
|
118
|
+
const item = graph.worklist.find((w) => w.path === file);
|
|
119
|
+
const isRootMain = file === `${graph.componentPath}/main.yaml`;
|
|
120
|
+
if (!item && !isRootMain)
|
|
121
|
+
return { kind: 'no-project-context', file };
|
|
122
|
+
// `prettyErrors` is what populates `linePos`; without it an error carries only a byte offset and the
|
|
123
|
+
// consumer would have to count newlines itself to place a squiggle.
|
|
124
|
+
const doc = parseDocument(text, {
|
|
125
|
+
keepSourceTokens: true,
|
|
126
|
+
prettyErrors: true,
|
|
127
|
+
});
|
|
128
|
+
const located = pathAtOffset(text, offset, doc);
|
|
129
|
+
// The map the cursor's value sits in. `entityId` means a Task or nothing at all depending on the
|
|
130
|
+
// `entityType` BESIDE it, so the siblings are part of the question, not context for a nicety.
|
|
131
|
+
const siblings = siblingsAt(doc, located.path);
|
|
132
|
+
const enclosing = enclosingComponent(graph, file, located.path, doc);
|
|
133
|
+
const property = nearestProperty(located.path, located.nodeKind);
|
|
134
|
+
const reference =
|
|
135
|
+
// A KEY that is itself a reference, which no property-and-value rule can see: the caret sits
|
|
136
|
+
// ON the key, so there is no `property` naming it and no string value beneath it. An
|
|
137
|
+
// `objectAssociations` entry is keyed by the taskId it describes.
|
|
138
|
+
keyReferenceAt(graph, located) ??
|
|
139
|
+
referenceAt(graph, property, located.path, located, siblings);
|
|
140
|
+
// The SLOT, resolved whether or not a value is present. Derived from the reference when there is one,
|
|
141
|
+
// so the two can never disagree; computed from the position alone when there is not.
|
|
142
|
+
const referenceSlot = reference
|
|
143
|
+
? {
|
|
144
|
+
property: reference.property,
|
|
145
|
+
...(reference.targetCollection
|
|
146
|
+
? { targetCollection: reference.targetCollection }
|
|
147
|
+
: {}),
|
|
148
|
+
}
|
|
149
|
+
: referenceSlotAt(property, located.path, siblings, located.value);
|
|
150
|
+
const templating = typeof located.selection === 'string'
|
|
151
|
+
? classifyTemplating(located.selection)
|
|
152
|
+
: [];
|
|
153
|
+
return {
|
|
154
|
+
kind: 'context',
|
|
155
|
+
file,
|
|
156
|
+
fileType: fileTypeOf(file, graph.componentPath),
|
|
157
|
+
projectId: graph.projectId,
|
|
158
|
+
generation: item?.generation ?? 0,
|
|
159
|
+
componentCollection: enclosing?.collection,
|
|
160
|
+
componentId: enclosing?.id,
|
|
161
|
+
component: enclosing,
|
|
162
|
+
yamlPath: located.path,
|
|
163
|
+
nodeKind: located.nodeKind,
|
|
164
|
+
// From the DOCUMENT. The variant is the step entry's own `displayType`, which is a sibling of
|
|
165
|
+
// every property inside that step, so walking up the path finds it wherever the caret is —
|
|
166
|
+
// including on `data.url`, where the schema-annotation version reported nothing.
|
|
167
|
+
...stepTypeOf(doc, located),
|
|
168
|
+
value: located.value,
|
|
169
|
+
selection: located.selection,
|
|
170
|
+
...(reference ? { reference } : {}),
|
|
171
|
+
templating,
|
|
172
|
+
...(referenceSlot ? { referenceSlot } : {}),
|
|
173
|
+
...(doc.errors.length > 0
|
|
174
|
+
? { parseErrors: true, parseErrorDetail: describeParseErrors(doc.errors) }
|
|
175
|
+
: {}),
|
|
176
|
+
...(hasMultipleDocuments(text) ? { multipleDocuments: true } : {}),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Whether the text is a multi-document stream.
|
|
181
|
+
*
|
|
182
|
+
* A `---` at the start of a line, after anything other than the leading directives/first marker.
|
|
183
|
+
* Cheap and conservative: it can only over-report on a file whose block scalar contains a line that
|
|
184
|
+
* is exactly `---`, and over-reporting makes a consumer cautious rather than wrong.
|
|
185
|
+
*/
|
|
186
|
+
function hasMultipleDocuments(text) {
|
|
187
|
+
let seen = 0;
|
|
188
|
+
for (const line of text.split('\n')) {
|
|
189
|
+
if (/^---\s*$/.test(line) || /^---\s/.test(line)) {
|
|
190
|
+
seen++;
|
|
191
|
+
if (seen > 1)
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The component the cursor is inside — identified by the id written in the DOCUMENT.
|
|
199
|
+
*
|
|
200
|
+
* Reads the entry's own `id`/`key` out of the editor's AST and looks the component up by identity.
|
|
201
|
+
* That is the only version that survives the two cases the previous one failed:
|
|
202
|
+
*
|
|
203
|
+
* - **The editor's text is newer than the graph.** The old version indexed `graph.authored`
|
|
204
|
+
* positionally with an index taken from the current text. Insert a component at the top of a file
|
|
205
|
+
* and every component below it was misattributed — confidently and silently — until the next
|
|
206
|
+
* rebuild. Reading the sibling `id` cannot drift, because the identity and the position come from
|
|
207
|
+
* the same parse.
|
|
208
|
+
* - **Inherited files.** `graph.authored` holds generation 0 only, while `resolveCursorContext`
|
|
209
|
+
* accepts any worklist file and reports its generation. Opening an ancestor's partial therefore
|
|
210
|
+
* returned no enclosing component at all for every array-indexed collection.
|
|
211
|
+
*
|
|
212
|
+
* `id` is preferred over `key`, matching `collectComponents`; a `!`-prefixed id is a REMOVAL
|
|
213
|
+
* directive rather than a declaration, so the caret is not inside a component the project has.
|
|
214
|
+
*/
|
|
215
|
+
function enclosingComponent(graph, file, path, doc) {
|
|
216
|
+
const [collection, index] = path;
|
|
217
|
+
if (typeof collection !== 'string' || index === undefined)
|
|
218
|
+
return undefined;
|
|
219
|
+
// A map collection is keyed by its own keys rather than indexed, so the key IS the identity.
|
|
220
|
+
if (typeof index === 'string') {
|
|
221
|
+
return graph.effective.find((c) => c.collection === collection && c.id === index);
|
|
222
|
+
}
|
|
223
|
+
if (typeof index !== 'number')
|
|
224
|
+
return undefined;
|
|
225
|
+
const entry = doc.getIn([collection, index], false);
|
|
226
|
+
const plain = entry?.toJSON?.();
|
|
227
|
+
if (!plain || typeof plain !== 'object' || Array.isArray(plain))
|
|
228
|
+
return undefined;
|
|
229
|
+
const raw = plain.id ??
|
|
230
|
+
plain.key;
|
|
231
|
+
if (raw === undefined || raw === null)
|
|
232
|
+
return undefined;
|
|
233
|
+
const id = String(raw);
|
|
234
|
+
// A removal directive declares nothing, so there is no component here to be inside.
|
|
235
|
+
if (id.startsWith('!'))
|
|
236
|
+
return undefined;
|
|
237
|
+
// Prefer the EFFECTIVE component — the one the project actually has, which may be a merged
|
|
238
|
+
// version — and fall back to what this file authored, which is what an inherited or
|
|
239
|
+
// not-yet-merged entry has.
|
|
240
|
+
return (graph.effective.find((c) => c.collection === collection && c.id === id) ??
|
|
241
|
+
graph.authored.find((c) => c.collection === collection &&
|
|
242
|
+
c.id === id &&
|
|
243
|
+
c.provenance.sourceFile === file));
|
|
244
|
+
}
|
|
245
|
+
/** The property name the cursor's value belongs to. */
|
|
246
|
+
function nearestProperty(path, nodeKind) {
|
|
247
|
+
if (nodeKind === 'key')
|
|
248
|
+
return undefined;
|
|
249
|
+
for (let i = path.length - 1; i >= 0; i--) {
|
|
250
|
+
const segment = path[i];
|
|
251
|
+
if (typeof segment === 'string')
|
|
252
|
+
return segment;
|
|
253
|
+
}
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Classify a file the way the composer does.
|
|
258
|
+
*
|
|
259
|
+
* `main.yaml` is matched against the project's OWN component path, so an ancestor's `main.yaml` —
|
|
260
|
+
* a worklist entry here rather than this project's base — reads as a partial instead of as this
|
|
261
|
+
* project's declaration. `variables.yaml` is matched by basename, which is how
|
|
262
|
+
* `contributesVariables` matches it.
|
|
263
|
+
*/
|
|
264
|
+
function fileTypeOf(file, componentPath) {
|
|
265
|
+
if (file === `${componentPath}/main.yaml`)
|
|
266
|
+
return 'project-main';
|
|
267
|
+
if (file.endsWith('/variables.yaml'))
|
|
268
|
+
return 'variables';
|
|
269
|
+
return 'partial';
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* The map the cursor's value sits in, as plain data.
|
|
273
|
+
*
|
|
274
|
+
* Needed because two reference properties are decided by a SIBLING rather than by their own name.
|
|
275
|
+
* Walks from the document root along the path, stopping one short so the result is the CONTAINER
|
|
276
|
+
* of the value at the cursor.
|
|
277
|
+
*/
|
|
278
|
+
function siblingsAt(doc, path) {
|
|
279
|
+
if (path.length === 0)
|
|
280
|
+
return undefined;
|
|
281
|
+
const container = doc.getIn(path.slice(0, -1), false);
|
|
282
|
+
const plain = container?.toJSON?.();
|
|
283
|
+
return plain && typeof plain === 'object' && !Array.isArray(plain)
|
|
284
|
+
? plain
|
|
285
|
+
: undefined;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The step variant at the cursor, read from the DOCUMENT.
|
|
289
|
+
*
|
|
290
|
+
* A step's variant is its own `displayType` value, and that value is a sibling of every property
|
|
291
|
+
* nested inside the step — so walking up the path until a map carries one answers for a caret on
|
|
292
|
+
* `data.url` just as well as for a caret on the discriminator itself.
|
|
293
|
+
*
|
|
294
|
+
* The previous version read this from an `x-hexasync-step-type` schema annotation and therefore
|
|
295
|
+
* only ever answered when the caret sat literally on `displayType`, where the value is already in
|
|
296
|
+
* hand and the answer is worthless. The variant was in the file the whole time.
|
|
297
|
+
*/
|
|
298
|
+
function stepTypeOf(doc, located) {
|
|
299
|
+
// From the containing map outwards. `slice(0, -1)` first: a caret ON `displayType` should report
|
|
300
|
+
// the step it discriminates, not require the map beneath it.
|
|
301
|
+
for (let end = located.path.length - 1; end >= 0; end--) {
|
|
302
|
+
const node = doc.getIn(located.path.slice(0, end), false);
|
|
303
|
+
const plain = node?.toJSON?.();
|
|
304
|
+
if (!plain || typeof plain !== 'object' || Array.isArray(plain))
|
|
305
|
+
continue;
|
|
306
|
+
const variant = plain[STEP_TYPE_PROPERTY];
|
|
307
|
+
if (typeof variant === 'string' && variant !== '') {
|
|
308
|
+
return { parentStepType: variant };
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return {};
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* A reference carried by the component's own KEY, rather than by a property's value.
|
|
315
|
+
*
|
|
316
|
+
* `objectAssociations` is keyed BY the taskId it describes, so the key names an entry in `objects`.
|
|
317
|
+
* Structural rather than annotated, which is what makes the DEPTH check below possible: the key of
|
|
318
|
+
* the collection sits at exactly one segment past the collection name. A key one level deeper —
|
|
319
|
+
* `table:`, `puller:`, `pusher:` inside the entry — is not a key of this collection and is not a
|
|
320
|
+
* reference. The annotation-driven version had no way to tell the two apart and reported all three
|
|
321
|
+
* child keys as broken references, across roughly 4,182 authored nested blocks.
|
|
322
|
+
*/
|
|
323
|
+
function keyReferenceAt(graph, located) {
|
|
324
|
+
// Where the key IS depends on where the caret is. Sitting ON the key, the key is the node's own
|
|
325
|
+
// value and does not appear in the path at all — the path stops at the container. Sitting inside
|
|
326
|
+
// the entry the key opens, it is the last segment.
|
|
327
|
+
const onKey = located.nodeKind === 'key' && typeof located.value === 'string';
|
|
328
|
+
const keyPath = onKey
|
|
329
|
+
? [...located.path, located.value]
|
|
330
|
+
: located.path;
|
|
331
|
+
// `[collection, key]` exactly: the collection name, then the key. Anything deeper is inside the
|
|
332
|
+
// entry rather than naming it.
|
|
333
|
+
if (keyPath.length !== 2)
|
|
334
|
+
return undefined;
|
|
335
|
+
const [collectionSegment, keySegment] = keyPath;
|
|
336
|
+
if (typeof collectionSegment !== 'string' || typeof keySegment !== 'string') {
|
|
337
|
+
return undefined;
|
|
338
|
+
}
|
|
339
|
+
const collection = COLLECTIONS_KEYED_BY_REFERENCE.get(collectionSegment);
|
|
340
|
+
if (!collection || keySegment === '')
|
|
341
|
+
return undefined;
|
|
342
|
+
const target = graph.effective.find((c) => c.collection === collection && c.id === keySegment);
|
|
343
|
+
return {
|
|
344
|
+
property: KEY_REFERENCE_PROPERTY,
|
|
345
|
+
targetId: keySegment,
|
|
346
|
+
targetCollection: collection,
|
|
347
|
+
...(target ? { target } : {}),
|
|
348
|
+
resolves: target !== undefined,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
/** Whether the cursor sits on a reference, and whether it resolves. */
|
|
352
|
+
/**
|
|
353
|
+
* What kind of reference a position takes, with no value to go on.
|
|
354
|
+
*
|
|
355
|
+
* Shares `referenceAt`'s nested-block handling — `table: { id: … }` names a table, which is the
|
|
356
|
+
* corpus's dominant reference form by roughly 10:1 — because re-deriving that here would be a second,
|
|
357
|
+
* worse copy of the cleverness that makes the flat-property case the exception rather than the rule.
|
|
358
|
+
*
|
|
359
|
+
* A PLACEHOLDER token-form value is used for the two registry entries that accept token form only
|
|
360
|
+
* (`entityId`, `targetId`) — but ONLY when the file has no value there yet. That is the right question
|
|
361
|
+
* for an empty slot: the developer is about to insert a `**Token**`, so "would a token-form value be a
|
|
362
|
+
* reference here" is exactly what completion needs to know, and asking with the empty string would
|
|
363
|
+
* answer "no" for a position that plainly takes one.
|
|
364
|
+
*
|
|
365
|
+
* When a value IS present, the registry is asked about THAT value and its answer is final. Using the
|
|
366
|
+
* placeholder regardless defeated the `tokenFormOnly` guard, which exists so a raw UUID in `entityId`
|
|
367
|
+
* reads as "not a component reference" rather than "a reference that is broken" — 288 such values in
|
|
368
|
+
* the corpus. The result was a contradiction this file claimed was impossible: *Validate Reference*
|
|
369
|
+
* announced "entityId names nothing in objects" while the Problems panel stayed deliberately silent.
|
|
370
|
+
* Found by code review (M-3).
|
|
371
|
+
*/
|
|
372
|
+
/**
|
|
373
|
+
* The collection a cursor path sits inside, when the path names one.
|
|
374
|
+
*
|
|
375
|
+
* A YAML path interleaves keys and array indices (`['connectors', 0, 'connectorId']`), so the first segment is
|
|
376
|
+
* the collection only when it is a string — an index at the root would mean a document that is a sequence, and
|
|
377
|
+
* that names no collection. Returning `undefined` there keeps `resolveReferenceKind`'s position-unknown
|
|
378
|
+
* behaviour (resolve, do not decline) correct rather than accidental.
|
|
379
|
+
*/
|
|
380
|
+
function enclosingCollection(path) {
|
|
381
|
+
const first = path[0];
|
|
382
|
+
return typeof first === 'string' ? first : undefined;
|
|
383
|
+
}
|
|
384
|
+
function referenceSlotAt(property, path, siblings,
|
|
385
|
+
/** What the file holds here, when it holds anything. */
|
|
386
|
+
value) {
|
|
387
|
+
if (!property)
|
|
388
|
+
return undefined;
|
|
389
|
+
const nested = property === 'id'
|
|
390
|
+
? nestedReferenceBlockFor(String(path[path.length - 2] ?? ''))
|
|
391
|
+
: undefined;
|
|
392
|
+
if (nested) {
|
|
393
|
+
return {
|
|
394
|
+
property: `${nested.property}.id`,
|
|
395
|
+
targetCollection: nested.collection,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
// The placeholder ONLY where the file is empty. A present value gets asked about on its own terms,
|
|
399
|
+
// and a decline is then a real answer rather than something to route around.
|
|
400
|
+
const present = typeof value === 'string' && value !== '';
|
|
401
|
+
// POSITION, not just siblings (FR-47, added by the Epic 1 review). `path[0]` is the enclosing collection, so
|
|
402
|
+
// a connection's own `connectorId` — its PLATFORM identity — stops being offered connection ids as
|
|
403
|
+
// completions. Story 1.7 patched the REF-K rule and the index's `relationsOf` and missed this file, so the
|
|
404
|
+
// Problems panel went silent while completion and hover carried on contradicting it — the same M-3 class of
|
|
405
|
+
// contradiction this file's own header records.
|
|
406
|
+
const kind = resolveReferenceKind(property, present ? value : PLACEHOLDER_TOKEN, siblings, enclosingCollection(path));
|
|
407
|
+
if (!kind)
|
|
408
|
+
return undefined;
|
|
409
|
+
return {
|
|
410
|
+
property: kind.property,
|
|
411
|
+
...(kind.collection ? { targetCollection: kind.collection } : {}),
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
/** Token form, so the two `tokenFormOnly` entries answer the slot question rather than declining. */
|
|
415
|
+
const PLACEHOLDER_TOKEN = '**x**';
|
|
416
|
+
/**
|
|
417
|
+
* Each parse failure with its position, one line of message.
|
|
418
|
+
*
|
|
419
|
+
* The parser appends a source excerpt to `message` ("… at line 3, column 1:\n\n\tname: …"); only the
|
|
420
|
+
* first line belongs in a diagnostic, because the editor is already showing the source.
|
|
421
|
+
*/
|
|
422
|
+
/**
|
|
423
|
+
* The YAML syntax errors in a document, positioned.
|
|
424
|
+
*
|
|
425
|
+
* Exported so the editor can squiggle them without re-deriving the parse. Same call and same shaping as
|
|
426
|
+
* `resolveCursorContext` uses for `parseErrorDetail`, so the diagnostic and the withheld completion can
|
|
427
|
+
* never disagree about whether the file is broken (code review D-4).
|
|
428
|
+
*/
|
|
429
|
+
export function yamlSyntaxErrors(text) {
|
|
430
|
+
return describeParseErrors(parseDocument(text, { keepSourceTokens: true, prettyErrors: true }).errors);
|
|
431
|
+
}
|
|
432
|
+
function describeParseErrors(errors) {
|
|
433
|
+
return errors.map((error) => {
|
|
434
|
+
const start = error.linePos?.[0];
|
|
435
|
+
const end = error.linePos?.[1] ?? start;
|
|
436
|
+
return {
|
|
437
|
+
code: error.code ?? 'YAML_ERROR',
|
|
438
|
+
// Trimmed at the first newline AND at the parser's own " at line N, column M:" suffix, which
|
|
439
|
+
// duplicates the position the diagnostic already carries.
|
|
440
|
+
message: (error.message.split('\n')[0] ?? error.message).replace(/ at line \d+, column \d+:?$/, ''),
|
|
441
|
+
line: start?.line ?? 1,
|
|
442
|
+
column: start?.col ?? 1,
|
|
443
|
+
endLine: end?.line ?? start?.line ?? 1,
|
|
444
|
+
endColumn: end?.col ?? start?.col ?? 1,
|
|
445
|
+
};
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function referenceAt(graph, property, path, located, siblings) {
|
|
449
|
+
if (!property || typeof located.value !== 'string' || located.value === '') {
|
|
450
|
+
return undefined;
|
|
451
|
+
}
|
|
452
|
+
// A NESTED block: the property at the cursor is `id`, and what it means comes from the block
|
|
453
|
+
// containing it — `table: { id: … }` names a table. This is the corpus's dominant reference
|
|
454
|
+
// form by roughly 10:1, so a cursor that only understood flat `tableId:` would fail to explain
|
|
455
|
+
// almost every real reference a developer puts their caret on.
|
|
456
|
+
const nested = property === 'id'
|
|
457
|
+
? nestedReferenceBlockFor(String(path[path.length - 2] ?? ''))
|
|
458
|
+
: undefined;
|
|
459
|
+
// The registry decides, reading the siblings where the target depends on them. It returns
|
|
460
|
+
// `undefined` for a value that is not a reference AT ALL — a raw runtime UUID in `entityId`, or
|
|
461
|
+
// `entityType: SELF` — which is a different answer from "a reference that does not resolve" and
|
|
462
|
+
// must not be reported as one.
|
|
463
|
+
const kind = nested
|
|
464
|
+
? { property: `${nested.property}.id`, collection: nested.collection }
|
|
465
|
+
: resolveReferenceKind(property, located.value, siblings, enclosingCollection(path));
|
|
466
|
+
if (!kind)
|
|
467
|
+
return undefined;
|
|
468
|
+
const targetCollection = kind.collection;
|
|
469
|
+
const target = graph.effective.find((c) => c.id === located.value &&
|
|
470
|
+
(targetCollection === undefined || c.collection === targetCollection));
|
|
471
|
+
return {
|
|
472
|
+
property: kind.property,
|
|
473
|
+
targetId: located.value,
|
|
474
|
+
...(targetCollection ? { targetCollection } : {}),
|
|
475
|
+
...(target ? { target } : {}),
|
|
476
|
+
resolves: target !== undefined,
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
//# sourceMappingURL=cursorContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursorContext.js","sourceRoot":"","sources":["../src/cursorContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACrE,OAAO,EACL,kBAAkB,GAEnB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,oBA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UAAU,EAAE;QACtE,CAAC,CAAC,oBAAoB,CAClB,QAAQ,EACR,OAAO,CAAC,KAAK,EACb,QAAQ,EACR,mBAAmB,CAAC,IAAI,CAAC,CAC1B,CAAC;IACN,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAE5B,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC;IACzC,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CACjC,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,KAAK;QACtB,CAAC,gBAAgB,KAAK,SAAS,IAAI,CAAC,CAAC,UAAU,KAAK,gBAAgB,CAAC,CACxE,CAAC;IAEF,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,QAAQ,EAAE,OAAO,CAAC,KAAK;QACvB,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7B,QAAQ,EAAE,MAAM,KAAK,SAAS;KAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a project of this kind can actually do.
|
|
3
|
+
*
|
|
4
|
+
* Carried as capabilities rather than read off the kind name, because callers care about the
|
|
5
|
+
* capability, never the label. `compose` is profile-only; `compose description` works on any
|
|
6
|
+
* kind, since it inlines `!md[...]` and depends on no business rule. A caller that asks
|
|
7
|
+
* "does this kind compose?" keeps working when a third kind appears; one that asks
|
|
8
|
+
* "is this kind 'profile'?" silently starts excluding it.
|
|
9
|
+
*/
|
|
10
|
+
export interface ProjectCapabilities {
|
|
11
|
+
/** `compose` produces a composed profile for this kind. */
|
|
12
|
+
readonly composes: boolean;
|
|
13
|
+
/** `compose description` applies — true for every kind, and stated rather than assumed. */
|
|
14
|
+
readonly composesDescription: boolean;
|
|
15
|
+
/** Declares `externals` and takes part in the inheritance graph. */
|
|
16
|
+
readonly inherits: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ProjectDetector {
|
|
19
|
+
/** Stable identifier for the kind. Persisted in snapshots, so treat it as a contract. */
|
|
20
|
+
readonly kind: string;
|
|
21
|
+
/** Human-readable, for the status bar and diagnostics. */
|
|
22
|
+
readonly label: string;
|
|
23
|
+
/** Glob, relative to a workspace folder, whose hits are candidate descriptors. */
|
|
24
|
+
readonly descriptorGlob: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional marker declaring WHERE this kind lives — a scope, not an identity.
|
|
27
|
+
*
|
|
28
|
+
* When present anywhere in the workspace it is AUTHORITATIVE: only descriptors beneath a
|
|
29
|
+
* marker root count. When absent, detection falls back to the descriptor glob workspace-wide.
|
|
30
|
+
*
|
|
31
|
+
* Scope and identity are deliberately separate. One `hx-templates.json` root can hold many
|
|
32
|
+
* projects — `001-projects/variux` holds 27 — so treating the marker as the project itself
|
|
33
|
+
* would collapse those 27 into one and destroy the per-project boundary the index exists to
|
|
34
|
+
* provide. The marker says "profile templates live here"; `main.yaml` says "this is one".
|
|
35
|
+
*/
|
|
36
|
+
readonly scopeMarkerGlob?: string;
|
|
37
|
+
readonly capabilities: ProjectCapabilities;
|
|
38
|
+
/**
|
|
39
|
+
* Higher wins when two detectors claim the same folder.
|
|
40
|
+
*
|
|
41
|
+
* Ambiguity is a real state, not a hypothetical — a folder can end up holding both a
|
|
42
|
+
* `main.yaml` and a marker — and resolving it by declaration order would make the answer
|
|
43
|
+
* depend on array position, which is not a decision anyone made.
|
|
44
|
+
*/
|
|
45
|
+
readonly precedence: number;
|
|
46
|
+
/** The folder that owns the descriptor. Defaults to its directory. */
|
|
47
|
+
componentPathFor(descriptorUri: string): string;
|
|
48
|
+
/** The project's own root folder, which ownership is tested against. */
|
|
49
|
+
rootFor(componentPath: string): string;
|
|
50
|
+
/** Display name. */
|
|
51
|
+
nameFor(componentPath: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* A last check once the descriptor has been read.
|
|
54
|
+
*
|
|
55
|
+
* The hook a shape-based kind needs: a future detector may glob broadly and then accept only
|
|
56
|
+
* documents carrying a particular root key, which a filename can never express.
|
|
57
|
+
*/
|
|
58
|
+
accepts(descriptorUri: string, descriptorText: string): boolean;
|
|
59
|
+
}
|
|
60
|
+
/** The descriptor's directory — right for any kind whose descriptor sits in its project. */
|
|
61
|
+
export declare const dirnameComponentPath: (descriptorUri: string) => string;
|
|
62
|
+
/**
|
|
63
|
+
* The parent of `partials`/`partial`, else the folder itself.
|
|
64
|
+
*
|
|
65
|
+
* Both spellings are read (FR-38) because 2 of the 113 corpus projects use the singular; only
|
|
66
|
+
* the plural is ever emitted.
|
|
67
|
+
*/
|
|
68
|
+
export declare function partialsAwareRoot(componentPath: string): string;
|
|
69
|
+
/** The folder's own name — the default display name. */
|
|
70
|
+
export declare const folderBasename: (componentPath: string) => string;
|
|
71
|
+
/** Accept every candidate. The default for kinds whose descriptor name is enough. */
|
|
72
|
+
export declare const acceptAll: () => boolean;
|
|
73
|
+
/**
|
|
74
|
+
* A PROFILE TEMPLATE — the thing `compose` operates on.
|
|
75
|
+
*
|
|
76
|
+
* Identified by `main.yaml`, and never by `output.yaml` (FR-37): that is a build artefact,
|
|
77
|
+
* absent in projects nobody has composed and present in folders that are not projects, so it
|
|
78
|
+
* would be wrong in both directions.
|
|
79
|
+
*/
|
|
80
|
+
export declare const PROFILE_TEMPLATE_DETECTOR: ProjectDetector;
|
|
81
|
+
/**
|
|
82
|
+
* A CONNECTOR TEMPLATE — a flat catalogue of connector definitions.
|
|
83
|
+
*
|
|
84
|
+
* Identified by an `hx-connectors.json` marker, wherever it sits. There is deliberately no fixed
|
|
85
|
+
* `connectors/` path: a workspace may declare several connector roots anywhere, and a path
|
|
86
|
+
* convention would silently miss every one that did not follow it.
|
|
87
|
+
*
|
|
88
|
+
* It does not compose. `compose description` still applies, because inlining `!md[...]` depends
|
|
89
|
+
* on no business rule.
|
|
90
|
+
*/
|
|
91
|
+
export declare const CONNECTOR_TEMPLATE_DETECTOR: ProjectDetector;
|
|
92
|
+
/** The kinds shipped today. Callers may pass their own set, or extend this one. */
|
|
93
|
+
export declare const DEFAULT_DETECTORS: readonly ProjectDetector[];
|
|
94
|
+
/** Look up a detector by kind — how a consumer asks what a project can do. */
|
|
95
|
+
export declare function detectorFor(kind: string, detectors?: readonly ProjectDetector[]): ProjectDetector | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* A helper for building a kind that is a variation on an existing one.
|
|
98
|
+
*
|
|
99
|
+
* The reuse path Jazz asked for: a future kind that differs from profiles only in its descriptor
|
|
100
|
+
* name, or only in whether it inherits, should be a few lines rather than a copy.
|
|
101
|
+
*/
|
|
102
|
+
export declare function deriveDetector(base: ProjectDetector, overrides: Partial<ProjectDetector> & Pick<ProjectDetector, 'kind'>): ProjectDetector;
|
|
103
|
+
//# sourceMappingURL=detectors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectors.d.ts","sourceRoot":"","sources":["../src/detectors.ts"],"names":[],"mappings":"AAmBA;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,2FAA2F;IAC3F,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,yFAAyF;IACzF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kFAAkF;IAClF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,eAAe,CAAC,EAA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