@graview/studio 0.0.0-stage → 0.1.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/LICENSE +96 -0
- package/README.md +31 -2
- package/dist/agent-panel.d.ts +11 -0
- package/dist/agent-panel.d.ts.map +1 -0
- package/dist/agent-panel.js +334 -0
- package/dist/agent-panel.js.map +1 -0
- package/dist/agent.d.ts +24 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +371 -0
- package/dist/agent.js.map +1 -0
- package/dist/changes.d.ts +49 -0
- package/dist/changes.d.ts.map +1 -0
- package/dist/changes.js +217 -0
- package/dist/changes.js.map +1 -0
- package/dist/from-declaration.d.ts +13 -0
- package/dist/from-declaration.d.ts.map +1 -0
- package/dist/from-declaration.js +204 -0
- package/dist/from-declaration.js.map +1 -0
- package/dist/in-place.d.ts +27 -0
- package/dist/in-place.d.ts.map +1 -0
- package/dist/in-place.js +151 -0
- package/dist/in-place.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/lens.d.ts +9 -0
- package/dist/lens.d.ts.map +1 -0
- package/dist/lens.js +40 -0
- package/dist/lens.js.map +1 -0
- package/dist/meta.d.ts +2648 -0
- package/dist/meta.d.ts.map +1 -0
- package/dist/meta.js +553 -0
- package/dist/meta.js.map +1 -0
- package/dist/migration.d.ts +15 -0
- package/dist/migration.d.ts.map +1 -0
- package/dist/migration.js +82 -0
- package/dist/migration.js.map +1 -0
- package/dist/place.d.ts +61 -0
- package/dist/place.d.ts.map +1 -0
- package/dist/place.js +328 -0
- package/dist/place.js.map +1 -0
- package/dist/rewrite.d.ts +28 -0
- package/dist/rewrite.d.ts.map +1 -0
- package/dist/rewrite.js +52 -0
- package/dist/rewrite.js.map +1 -0
- package/dist/source.d.ts +69 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +465 -0
- package/dist/source.js.map +1 -0
- package/dist/studio.d.ts +64 -0
- package/dist/studio.d.ts.map +1 -0
- package/dist/studio.js +96 -0
- package/dist/studio.js.map +1 -0
- package/dist/to-declaration.d.ts +24 -0
- package/dist/to-declaration.d.ts.map +1 -0
- package/dist/to-declaration.js +439 -0
- package/dist/to-declaration.js.map +1 -0
- package/dist/write-in-place.d.ts +27 -0
- package/dist/write-in-place.d.ts.map +1 -0
- package/dist/write-in-place.js +61 -0
- package/dist/write-in-place.js.map +1 -0
- package/dist/zod-source.d.ts +7 -0
- package/dist/zod-source.d.ts.map +1 -0
- package/dist/zod-source.js +124 -0
- package/dist/zod-source.js.map +1 -0
- package/package.json +58 -3
package/dist/agent.js
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import { drawFigure, graphResponder, nearestFigure, validateProposals, } from "@graview/tools";
|
|
2
|
+
const squeeze = (text) => text.toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
3
|
+
/** Singular and plural of a word, squeezed, so "tasks" finds the kind "task". */
|
|
4
|
+
const forms = (word) => {
|
|
5
|
+
const one = squeeze(word);
|
|
6
|
+
const out = [one, `${one}s`, `${one}es`];
|
|
7
|
+
if (one.endsWith("ies"))
|
|
8
|
+
out.push(`${one.slice(0, -3)}y`);
|
|
9
|
+
if (one.endsWith("s"))
|
|
10
|
+
out.push(one.slice(0, -1));
|
|
11
|
+
return out;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* THE TYPE A NAME IMPLIES, and nothing cleverer.
|
|
15
|
+
*
|
|
16
|
+
* "a due date" is a date and "how many" is a number, in every domain that
|
|
17
|
+
* has ever existed. Where the name says nothing, the answer is a string —
|
|
18
|
+
* never a guess dressed up as a decision, because the person is about to
|
|
19
|
+
* see the act before they keep it and can change it there.
|
|
20
|
+
*/
|
|
21
|
+
export function typeFromName(name) {
|
|
22
|
+
const said = name.toLowerCase();
|
|
23
|
+
if (/\b(date|due|deadline|when|day|birthday|expires?|starts?|ends?)\b/.test(said))
|
|
24
|
+
return "date";
|
|
25
|
+
if (/\b(count|number|quantity|amount|size|age|price|cost|hours?|minutes?|score|rank)\b/.test(said))
|
|
26
|
+
return "number";
|
|
27
|
+
if (/^(is|has|was|can|should)\b|\b(done|complete|completed|active|archived|urgent|flag)\b/.test(said))
|
|
28
|
+
return "boolean";
|
|
29
|
+
if (/\b(notes?|note|description|comment|comments|body|summary|detail|details)\b/.test(said))
|
|
30
|
+
return "text";
|
|
31
|
+
return "string";
|
|
32
|
+
}
|
|
33
|
+
/** The graph-native studio conversation: the declaration, in its own words. */
|
|
34
|
+
export function studioResponder(options = {}) {
|
|
35
|
+
const floor = graphResponder();
|
|
36
|
+
return async (store, text, context) => {
|
|
37
|
+
const asked = text.toLowerCase();
|
|
38
|
+
const said = squeeze(text);
|
|
39
|
+
/*
|
|
40
|
+
* A QUESTION IS NEVER A CHANGE — the same rule the graph responder
|
|
41
|
+
* keeps. "what roles are there?" must not propose adding one.
|
|
42
|
+
*/
|
|
43
|
+
const question = /\?\s*$/.test(text) ||
|
|
44
|
+
/^\s*(what|who|whom|whose|which|when|where|why|how|is|are|was|were|does|do|did|can|could|should|would|will|has|have)\b/.test(asked);
|
|
45
|
+
/*
|
|
46
|
+
* A SENTENCE THAT OPENS WITH AN INSTRUCTION IS NOT A QUESTION.
|
|
47
|
+
*
|
|
48
|
+
* The branches below answer questions about the declaration, and they
|
|
49
|
+
* recognised them by the words they contained rather than by what the
|
|
50
|
+
* sentence was doing. "Add a Meal kind, with the name of the food and
|
|
51
|
+
* how many people it feeds" contains "kind" and "how many", so it was
|
|
52
|
+
* answered with an inventory of the kinds — and answered as a FACT,
|
|
53
|
+
* which takes the turn away from the model entirely. The one sentence
|
|
54
|
+
* most needing a model's help was the one guaranteed not to reach it.
|
|
55
|
+
*/
|
|
56
|
+
const imperative = /^\s*(add|give|put|attach|link|connect|tie|relate|make|create|draw|declare|rename|remove|delete|set|call)\b/.test(asked);
|
|
57
|
+
/**
|
|
58
|
+
* A FACT the declaration holds: what kinds there are, what an act
|
|
59
|
+
* writes, who may take it. No model may replace one of these.
|
|
60
|
+
*/
|
|
61
|
+
const grounded = (say, proposals = []) => ({
|
|
62
|
+
say,
|
|
63
|
+
proposals: validateProposals(store, proposals),
|
|
64
|
+
grounded: true,
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* A READING of what somebody wants changed — right often enough to be
|
|
68
|
+
* the floor, and never so right that a model should be kept out of it.
|
|
69
|
+
* Where a model is on the ladder this goes up as a starting point; where
|
|
70
|
+
* none is, it is the answer.
|
|
71
|
+
*/
|
|
72
|
+
const reading = (say, proposals = []) => ({
|
|
73
|
+
say,
|
|
74
|
+
proposals: validateProposals(store, proposals),
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* A sentence this rung could not read. Honest, and a dead end on its
|
|
78
|
+
* own — so it is marked, and a surface with no model chosen can offer
|
|
79
|
+
* the one that reads any phrasing.
|
|
80
|
+
*/
|
|
81
|
+
const unsure = (say) => ({ say, proposals: [], unsure: true });
|
|
82
|
+
const all = (kind) => [...store.graph.allNodes()].filter((node) => node.kind === kind);
|
|
83
|
+
const label = (node) => String(node?.["label"] ?? node?.id ?? "");
|
|
84
|
+
const out = (id, kind) => store.graph.out(id, kind);
|
|
85
|
+
const into = (id, kind) => store.graph.in(id, kind);
|
|
86
|
+
const list = (words) => words.length <= 1 ? (words[0] ?? "nothing") : `${words.slice(0, -1).join(", ")} and ${words[words.length - 1]}`;
|
|
87
|
+
/**
|
|
88
|
+
* The node of a meta-kind whose name (or plural) the message says,
|
|
89
|
+
* longest name first — and, where it matters, only within the PART of
|
|
90
|
+
* the sentence that names it.
|
|
91
|
+
*
|
|
92
|
+
* "every shift needs a volunteer" names two kinds and means a rule over
|
|
93
|
+
* the first: searching the whole sentence picked "volunteer" because it
|
|
94
|
+
* is the longer word, which is the seat confidently declaring a rule
|
|
95
|
+
* over the wrong thing. So each branch says where to look.
|
|
96
|
+
*/
|
|
97
|
+
const named = (kind, within = said) => {
|
|
98
|
+
const hay = squeeze(within);
|
|
99
|
+
/*
|
|
100
|
+
* THE EARLIEST NAME WINS, AND ITS OWN NAME BEATS ITS PLURAL.
|
|
101
|
+
*
|
|
102
|
+
* Longest-match alone read "Add details to Meal. The name of the food
|
|
103
|
+
* and the number of people it can feed" as a field on USER — because
|
|
104
|
+
* the user kind's plural is "People", "people" is inside "number of
|
|
105
|
+
* people", and six letters beat four. The kind this sentence is about
|
|
106
|
+
* is the one it says FIRST after pointing at it; a plural buried in a
|
|
107
|
+
* description of something else is not a subject.
|
|
108
|
+
*/
|
|
109
|
+
const hits = all(kind).flatMap((node) => {
|
|
110
|
+
const said = [
|
|
111
|
+
{ text: label(node), rank: 0 },
|
|
112
|
+
{ text: String(node["title"] ?? ""), rank: 0 },
|
|
113
|
+
{ text: String(node["plural"] ?? ""), rank: 1 },
|
|
114
|
+
].filter((one) => one.text.length > 0);
|
|
115
|
+
const found = said
|
|
116
|
+
.flatMap((one) => forms(one.text).map((form) => ({ form, rank: one.rank })))
|
|
117
|
+
.filter(({ form }) => form.length >= 3 && hay.includes(form))
|
|
118
|
+
.map(({ form, rank }) => ({ node, at: hay.indexOf(form), length: form.length, rank }))
|
|
119
|
+
.sort((a, b) => a.at - b.at || a.rank - b.rank || b.length - a.length);
|
|
120
|
+
return found.length > 0 ? [found[0]] : [];
|
|
121
|
+
});
|
|
122
|
+
return hits.sort((a, b) => a.at - b.at || a.rank - b.rank || b.length - a.length)[0]?.node;
|
|
123
|
+
};
|
|
124
|
+
/** The clause a phrase points at, cut at the first sentence end. */
|
|
125
|
+
const clause = (phrase) => (phrase ?? "").split(/[.;\n]/)[0] ?? "";
|
|
126
|
+
// ------------------------------------------------------------ figures
|
|
127
|
+
/*
|
|
128
|
+
* The drawing gap, recorded honestly when figures shipped: `drawFigure`
|
|
129
|
+
* carries the house style and judges its own answer with the checker's
|
|
130
|
+
* own function, and it was reachable from code and from the CLI and
|
|
131
|
+
* from nowhere a person sits. This is where a person sits.
|
|
132
|
+
*/
|
|
133
|
+
const aboutFigures = /\b(figure|figures|drawing|drawn|draw|icon|picture)\b/.test(asked);
|
|
134
|
+
if (aboutFigures && !imperative && /\b(no|without|missing|which|what|any|lack|lacks|lacking)\b/.test(asked) && !/\bfor\b/.test(asked)) {
|
|
135
|
+
const kinds = all("kind");
|
|
136
|
+
const undrawn = kinds.filter((kind) => typeof kind["figure"] !== "string" || kind["figure"] === "");
|
|
137
|
+
return grounded(undrawn.length === 0
|
|
138
|
+
? `Every kind is drawn — ${list(kinds.map((kind) => label(kind)))}.`
|
|
139
|
+
: `${undrawn.length} of ${kinds.length} ${kinds.length === 1 ? "kind has" : "kinds have"} no figure: ${list(undrawn.map((kind) => label(kind)))}. Ask me to draw one by name.`);
|
|
140
|
+
}
|
|
141
|
+
if (aboutFigures) {
|
|
142
|
+
const kind = named("kind");
|
|
143
|
+
if (!kind) {
|
|
144
|
+
return unsure(`Say which kind to draw — ${list(all("kind").map((one) => label(one)))} — and I will draw it in the house style.`);
|
|
145
|
+
}
|
|
146
|
+
const drawn = options.complete
|
|
147
|
+
? await drawFigure(label(kind), typeof kind["description"] === "string" ? kind["description"] : undefined, options.complete)
|
|
148
|
+
: { kind: label(kind), figure: nearestFigure(label(kind)), from: "shipped", refused: ["nothing is behind the seat to draw with"] };
|
|
149
|
+
const propose = [
|
|
150
|
+
{
|
|
151
|
+
mutation: "set-figure",
|
|
152
|
+
args: { id: kind.id, figure: drawn.figure },
|
|
153
|
+
why: drawn.from === "model" ? "drawn in the house style and passed the checker's own figure test" : "the nearest shipped figure",
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
return reading(drawn.from === "model"
|
|
157
|
+
? `Drawn for ${label(kind)}, in the house style — the checker's own figure test passed it. Keep it or ask again for another.`
|
|
158
|
+
: `I did not draw it: ${list(drawn.refused ?? [])}. The nearest shipped figure is "${drawn.figure}", which is an honest placeholder rather than a drawing of ${label(kind)}.`, propose);
|
|
159
|
+
}
|
|
160
|
+
// ----------------------------------------------------- who may what
|
|
161
|
+
if (!imperative && /\bwho\b/.test(asked) && /\b(may|can|allowed|permitted|able)\b/.test(asked)) {
|
|
162
|
+
const act = named("act");
|
|
163
|
+
const grants = all("grant").filter((g) => (act ? out(g.id, "may").some((one) => one.id === act.id) || g["allActs"] === true : true));
|
|
164
|
+
if (grants.length === 0) {
|
|
165
|
+
return grounded(act
|
|
166
|
+
? `No grant names ${label(act)}, so only a seat that may do anything can take it.`
|
|
167
|
+
: `This declaration grants nothing — every act is open to whoever is here.`);
|
|
168
|
+
}
|
|
169
|
+
const lines = grants.map((g) => {
|
|
170
|
+
const roles = g["everyone"] === true ? "everyone" : list(out(g.id, "lets").map((role) => label(role)));
|
|
171
|
+
const acts = g["allActs"] === true ? "every act" : list(out(g.id, "may").map((one) => String(one["title"] ?? label(one))));
|
|
172
|
+
const kinds = g["allKinds"] === true ? "" : ` on ${list(out(g.id, "allows-on").map((one) => label(one)))}`;
|
|
173
|
+
return `${roles} may ${acts}${kinds}${g["self"] === true ? ", on their own record only" : ""}`;
|
|
174
|
+
});
|
|
175
|
+
return grounded(`${lines.join("; ")}.`);
|
|
176
|
+
}
|
|
177
|
+
// ------------------------------------------- what an act does, exactly
|
|
178
|
+
const act = named("act");
|
|
179
|
+
if (act && !imperative && /\b(write|writes|do|does|change|changes|act|touch)\b/.test(asked)) {
|
|
180
|
+
const writes = Array.isArray(act["writes"]) ? act["writes"].map(String) : [];
|
|
181
|
+
const parts = [
|
|
182
|
+
writes.length > 0 ? `writes ${list(writes)}` : null,
|
|
183
|
+
out(act.id, "creates").length > 0 ? `brings ${list(out(act.id, "creates").map((one) => label(one)))} into being` : null,
|
|
184
|
+
out(act.id, "connects").length > 0 ? `makes the tie ${list(out(act.id, "connects").map((one) => label(one)))}` : null,
|
|
185
|
+
out(act.id, "severs").length > 0 ? `breaks the tie ${list(out(act.id, "severs").map((one) => label(one)))}` : null,
|
|
186
|
+
].filter((part) => part !== null);
|
|
187
|
+
const on = out(act.id, "on").map((one) => label(one));
|
|
188
|
+
const repaired = into(act.id, "repairs").map((one) => label(one));
|
|
189
|
+
return grounded(`${String(act["title"] ?? label(act))} ${parts.length > 0 ? parts.join(", ") : "writes nothing the declaration names"}${on.length > 0 ? `, on ${list(on)}` : ""}.${act["destructive"] === true ? " It is destructive." : ""}${repaired.length > 0 ? ` It repairs ${list(repaired)}.` : ""}`);
|
|
190
|
+
}
|
|
191
|
+
// --------------------------------------------- what a rule judges
|
|
192
|
+
const rule = named("rule");
|
|
193
|
+
if (rule && !imperative && /\b(judge|judges|rule|hold|holds|check|checks|mean|means)\b/.test(asked)) {
|
|
194
|
+
const over = out(rule.id, "over").map((one) => label(one));
|
|
195
|
+
const repairs = out(rule.id, "repairs").map((one) => String(one["title"] ?? label(one)));
|
|
196
|
+
return grounded(`${String(rule["title"] ?? label(rule))} — ${String(rule["description"] ?? "no description")} It judges ${rule["wholeGraph"] === true ? "the whole graph" : over.length > 0 ? list(over) : "nothing"}${rule["judgesPast"] === true ? ", including the past" : ""}. ${repairs.length > 0 ? `Put right by ${list(repairs)}.` : "It names no repair, so the interface can only complain about it."}`);
|
|
197
|
+
}
|
|
198
|
+
// ------------------------------------------------------ what is here
|
|
199
|
+
if (!imperative && /\b(kind|kinds|shape|declare|declares|declared|model|models|track)\b/.test(asked) && /\b(what|which|list|show|how many|any)\b/.test(asked)) {
|
|
200
|
+
const kinds = all("kind");
|
|
201
|
+
const lines = kinds.map((kind) => {
|
|
202
|
+
const fields = into(kind.id, "of").length;
|
|
203
|
+
const edges = into(kind.id, "from-kind").length;
|
|
204
|
+
return `${label(kind)} (${fields} field${fields === 1 ? "" : "s"}, ${edges} relation${edges === 1 ? "" : "s"})`;
|
|
205
|
+
});
|
|
206
|
+
return grounded(`${kinds.length} kind${kinds.length === 1 ? "" : "s"}: ${list(lines)}. There ${all("act").length === 1 ? "is" : "are"} ${all("act").length} act${all("act").length === 1 ? "" : "s"} and ${all("rule").length} rule${all("rule").length === 1 ? "" : "s"}.`);
|
|
207
|
+
}
|
|
208
|
+
// --------------------------------- a role or a kind, named in words
|
|
209
|
+
/*
|
|
210
|
+
* "add a new Role for Participant" — and it must be THE FLOOR that
|
|
211
|
+
* answers it, not a model.
|
|
212
|
+
*
|
|
213
|
+
* The graph responder only recognises an act when the message contains
|
|
214
|
+
* its title exactly, so "add a new role" missed "Add a role", the floor
|
|
215
|
+
* returned an ungrounded answer, and the on-device model got the turn.
|
|
216
|
+
* It proposed `add-role` with no label at all, which the store then
|
|
217
|
+
* refused for the arguments — a dead end with the person's own sentence
|
|
218
|
+
* on one side of it and a zod error on the other.
|
|
219
|
+
*/
|
|
220
|
+
const naming = /^\s*(?:add|create|make|declare)\b/.test(asked) || /\bnew\b/.test(asked);
|
|
221
|
+
if (naming && !question) {
|
|
222
|
+
const what = /\brole\b/.test(asked) ? "role" : /\bkind\b/.test(asked) ? "kind" : null;
|
|
223
|
+
if (what) {
|
|
224
|
+
/*
|
|
225
|
+
* What it is to be CALLED, from the ways people actually say it:
|
|
226
|
+
* in quotes, after "called"/"named"/"for", or in front of the word
|
|
227
|
+
* itself ("add a participant role"). Never guessed — with no name
|
|
228
|
+
* the seat asks for one rather than proposing an act that cannot
|
|
229
|
+
* apply.
|
|
230
|
+
*/
|
|
231
|
+
const given = text.match(/["'“”']([^"'“”']+)["'“”']/)?.[1] ??
|
|
232
|
+
new RegExp(`\\b(?:called|named|for)\\s+(?:an?\\s+|the\\s+)?([A-Za-z][A-Za-z0-9 _-]*?)\\s*$`, "i").exec(text)?.[1] ??
|
|
233
|
+
new RegExp(`\\b([A-Za-z][\\w-]*)\\s+${what}s?\\b`, "i").exec(text)?.[1];
|
|
234
|
+
const called = given?.trim().replace(/^(a|an|the|new)\s+/i, "").trim();
|
|
235
|
+
if (!called || /^(new|a|an|the)$/i.test(called)) {
|
|
236
|
+
return unsure(`What should the ${what} be called? Say it in quotes, or "add a ${what} called …", and I will propose it.`);
|
|
237
|
+
}
|
|
238
|
+
if (what === "role") {
|
|
239
|
+
const already = all("role").find((role) => squeeze(label(role)) === squeeze(called));
|
|
240
|
+
if (already)
|
|
241
|
+
return grounded(`There is already a role called ${label(already)}.`);
|
|
242
|
+
return reading(`A new role, "${called}". It is a seat somebody can hold — grants are what let it do anything, so it can take no act until one says so.`, [{ mutation: "add-role", args: { label: called }, why: `you asked for a ${called} role` }]);
|
|
243
|
+
}
|
|
244
|
+
const already = all("kind").find((kind) => squeeze(label(kind)) === squeeze(called));
|
|
245
|
+
if (already)
|
|
246
|
+
return grounded(`There is already a kind called ${label(already)}.`);
|
|
247
|
+
return reading(`A new kind, "${called}", with a name to be called by. Check it below before you keep it.`, [{ mutation: "add-kind", args: { label: called }, why: `you asked for a ${called} kind` }]);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// ------------------------------------------------- a tie, said in words
|
|
251
|
+
/*
|
|
252
|
+
* "Attach Meals to Shifts" — which the floor did not know at all, so the
|
|
253
|
+
* turn fell through to a model, which proposed `add-edge` with no kind
|
|
254
|
+
* and no label and earned a validation refusal in zod's own words.
|
|
255
|
+
*
|
|
256
|
+
* Which end declares it is a real decision and the seat must not hide
|
|
257
|
+
* that it made one: a shift HAS meals, so the tie is declared on the
|
|
258
|
+
* shift and points at the meal. The reply says so, and the proposal is
|
|
259
|
+
* editable before it is kept.
|
|
260
|
+
*/
|
|
261
|
+
const tying = /\b(attach|link|connect|relate|tie)\b.*\b(to|onto|with)\b/.test(asked) ||
|
|
262
|
+
/\b(has|have|holds?|carr(?:y|ies))\b\s+(?:many\s+|some\s+|a\s+|an\s+)?/.test(asked);
|
|
263
|
+
if (tying && !question) {
|
|
264
|
+
const joined = /\b(?:attach|link|connect|relate|tie)\b\s+(.+?)\s+\b(?:to|onto|with)\b\s*(.*)$/i.exec(text);
|
|
265
|
+
const owning = /^\s*(?:a|an|each|every|the)?\s*(.+?)\s+\b(?:has|have|holds|hold|carries|carry)\b\s+(?:many\s+|some\s+|a\s+|an\s+)?(.*)$/i.exec(text);
|
|
266
|
+
// "attach A to B" hangs the tie on B; "a B has A" already says B first.
|
|
267
|
+
const from = joined ? named("kind", clause(joined[2])) : owning ? named("kind", clause(owning[1])) : undefined;
|
|
268
|
+
const to = joined ? named("kind", clause(joined[1])) : owning ? named("kind", clause(owning[2])) : undefined;
|
|
269
|
+
if (from && to) {
|
|
270
|
+
const plural = String(to["plural"] ?? "") || `${label(to)}s`;
|
|
271
|
+
return reading(`A tie declared on ${label(from)}, pointing at ${label(to)} — a ${label(from)} has ${plural.toLowerCase()}. Change any of it below before you keep it.`, [
|
|
272
|
+
{
|
|
273
|
+
mutation: "add-edge",
|
|
274
|
+
args: {
|
|
275
|
+
kind: from.id,
|
|
276
|
+
to: to.id,
|
|
277
|
+
label: plural.toLowerCase(),
|
|
278
|
+
description: `its ${plural.toLowerCase()}`,
|
|
279
|
+
inverse: `the ${label(from)} it is on`,
|
|
280
|
+
cardinality: "many",
|
|
281
|
+
},
|
|
282
|
+
why: `you asked to tie ${label(to)} to ${label(from)}`,
|
|
283
|
+
},
|
|
284
|
+
]);
|
|
285
|
+
}
|
|
286
|
+
if (joined || owning) {
|
|
287
|
+
return unsure(`Say both kinds by name and I will propose the tie — there ${all("kind").length === 1 ? "is" : "are"} ${list(all("kind").map((one) => label(one)))}.`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// ----------------------------------------------- a field, said in words
|
|
291
|
+
/*
|
|
292
|
+
* "add a due date to tasks" — the shape a person actually says. The
|
|
293
|
+
* kind is named at the end, the field in the middle, and the type is
|
|
294
|
+
* whatever the name implies. Optional unless the person says otherwise:
|
|
295
|
+
* a required field added to a kind that already has records is a
|
|
296
|
+
* migration nobody asked for.
|
|
297
|
+
*/
|
|
298
|
+
const adding = /^\s*(add|give|put)\b/.test(asked) && /\b(to|on|for)\b/.test(asked);
|
|
299
|
+
if (adding) {
|
|
300
|
+
const between = /\b(?:add|give|put)\b\s+(?:an?\s+|the\s+)?(.+?)\s+\b(?:to|on|for)\b\s*(.*)$/i.exec(text);
|
|
301
|
+
const field = between?.[1]?.trim();
|
|
302
|
+
/*
|
|
303
|
+
* The kind is what comes AFTER "to", read no further than the end of
|
|
304
|
+
* that sentence: everything after the full stop is a description of
|
|
305
|
+
* the FIELD, and letting it name the kind put "details" on the wrong
|
|
306
|
+
* one entirely.
|
|
307
|
+
*/
|
|
308
|
+
const kind = named("kind", clause(between?.[2]));
|
|
309
|
+
if (!kind && field && between?.[2]) {
|
|
310
|
+
/*
|
|
311
|
+
* AND WHEN THE KIND IT POINTS AT IS NOT ONE, IT SAYS SO.
|
|
312
|
+
*
|
|
313
|
+
* Reaching past the clause for any kind name anywhere in the
|
|
314
|
+
* sentence is how "add details to Meal. The name of the food and
|
|
315
|
+
* the number of people it can feed" put a field on USER: no kind
|
|
316
|
+
* called Meal existed, and "people" is the user kind's plural.
|
|
317
|
+
* Guessing a subject from a description of something else is worse
|
|
318
|
+
* than asking.
|
|
319
|
+
*/
|
|
320
|
+
return unsure(`There is no kind called "${clause(between[2]).trim()}". There ${all("kind").length === 1 ? "is" : "are"} ${list(all("kind").map((one) => label(one)))} — or ask me to add it first.`);
|
|
321
|
+
}
|
|
322
|
+
if (kind && field && !/\b(edge|relation|tie|act|rule|role)\b/i.test(field)) {
|
|
323
|
+
const type = typeFromName(field);
|
|
324
|
+
const required = /\brequired\b|\bmust\b|\balways\b/.test(asked);
|
|
325
|
+
return reading(`"${field}" reads as ${type === "text" ? "a long text" : `a ${type}`}, on ${label(kind)}${required ? ", required" : ", optional so the records that already exist stay valid"}. Check it below before you keep it.`, [
|
|
326
|
+
{
|
|
327
|
+
mutation: "add-field",
|
|
328
|
+
args: { kind: kind.id, label: field, type, required },
|
|
329
|
+
why: `you asked for "${field}" on ${label(kind)}`,
|
|
330
|
+
},
|
|
331
|
+
]);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// ------------------------------------------------ a rule, said in words
|
|
335
|
+
const needs = /\b(every|each|all)\b.*\b(needs?|must|should|requires?|has to have)\b/.test(asked);
|
|
336
|
+
if (needs) {
|
|
337
|
+
const subject = /\b(?:every|each|all)\b\s+(.+?)\s+\b(?:needs?|must|should|requires?|has to have)\b/i.exec(text);
|
|
338
|
+
const kind = named("kind", subject?.[1] ?? said) ?? named("kind");
|
|
339
|
+
if (kind) {
|
|
340
|
+
const name = text
|
|
341
|
+
.trim()
|
|
342
|
+
.replace(/[.?!]+$/, "")
|
|
343
|
+
.toLowerCase()
|
|
344
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
345
|
+
.replace(/^-+|-+$/g, "")
|
|
346
|
+
.slice(0, 60);
|
|
347
|
+
return reading(`A rule over ${label(kind)}. The judgement itself is code — the studio declares the rule and names where its body goes; the file it writes says so where the checkout must fill it in.`, [
|
|
348
|
+
{
|
|
349
|
+
mutation: "add-rule",
|
|
350
|
+
args: { kind: kind.id, label: name, description: text.trim() },
|
|
351
|
+
why: `you said every ${label(kind)} needs it`,
|
|
352
|
+
},
|
|
353
|
+
]);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// ------------------------------------ everything else the graph can say
|
|
357
|
+
/*
|
|
358
|
+
* AND WHEN NOTHING HERE COULD READ IT, that is worth saying rather than
|
|
359
|
+
* answering a different question. The graph responder's last resort is
|
|
360
|
+
* a description of the shape — true, and not what was asked — so an
|
|
361
|
+
* answer with nothing under it from a sentence that was plainly asking
|
|
362
|
+
* for a CHANGE is marked as unread, and a surface with no model chosen
|
|
363
|
+
* can offer the rung that reads any phrasing.
|
|
364
|
+
*/
|
|
365
|
+
const fallback = await floor(store, text, context);
|
|
366
|
+
return fallback.grounded || fallback.proposals.length > 0 || question
|
|
367
|
+
? fallback
|
|
368
|
+
: { ...fallback, unsure: true };
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EAC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C,IAAI,QAAQ;YACnE,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACpC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AnySchema, DeclarationChange, GraviewApp, StudioDoorSource } from "@graview/core";
|
|
2
|
+
import type { Reading } from "./to-declaration.js";
|
|
3
|
+
/**
|
|
4
|
+
* WHAT CHANGED, AS THE SOURCE MUST RECEIVE IT.
|
|
5
|
+
*
|
|
6
|
+
* The studio holds the declaration as a graph and knows the graph it opened
|
|
7
|
+
* on, so the difference between the two IS the change a person made — and
|
|
8
|
+
* saying it as changes rather than as files is what lets the dev server make
|
|
9
|
+
* it inside the checkout's own `defineNode` calls without flattening them.
|
|
10
|
+
*
|
|
11
|
+
* Things are matched by what they mean, not by node id: a field is its kind
|
|
12
|
+
* and its name, an edge its name, so an edge removed from the plot and
|
|
13
|
+
* declared again on the planting is one relation MOVED — and moves with its
|
|
14
|
+
* comments — rather than one deleted and a stranger added.
|
|
15
|
+
*
|
|
16
|
+
* An act or rule whose declaration changed is code the studio cannot write
|
|
17
|
+
* by itself: it is named in `rewrite`, to be rewritten by a person or a seat
|
|
18
|
+
* before anything is written. What the source cannot receive this way at
|
|
19
|
+
* all yet — a role, a grant, a renamed kind — is said, one sentence each,
|
|
20
|
+
* in `unwritten`, and nothing is written while that list has something in
|
|
21
|
+
* it: half a change applied is a checkout that disagrees with itself.
|
|
22
|
+
*/
|
|
23
|
+
export interface SourceChanges {
|
|
24
|
+
readonly changes: readonly DeclarationChange[];
|
|
25
|
+
readonly rewrite: readonly Rewrite[];
|
|
26
|
+
readonly unwritten: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
/** An act or rule that must be written afresh before the change can be, and why. */
|
|
29
|
+
export interface Rewrite {
|
|
30
|
+
readonly sort: "act" | "rule";
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly why: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function sourceChanges(before: Reading, after: Reading, base?: GraviewApp<AnySchema>): SourceChanges;
|
|
35
|
+
/**
|
|
36
|
+
* THE CODE A CHANGE LEAVES SAYING SOMETHING UNTRUE.
|
|
37
|
+
*
|
|
38
|
+
* The declaration moved `tended-by` from the plot to the planting; the act
|
|
39
|
+
* that ties a gardener to a plot still adds a `tended-by` edge FROM a plot,
|
|
40
|
+
* and the rule that every plot has a caretaker still reads one. Both
|
|
41
|
+
* compile. Both pass the checker, which judges declarations, not bodies.
|
|
42
|
+
* Both are wrong the moment the app runs.
|
|
43
|
+
*
|
|
44
|
+
* So every act and rule the checkout wrote is read for the names the change
|
|
45
|
+
* moved or took away, and each one that mentions them is named for
|
|
46
|
+
* rewriting — by a person, a seat, or a person saying it still holds.
|
|
47
|
+
*/
|
|
48
|
+
export declare function codeTouched(changes: readonly DeclarationChange[], code: StudioDoorSource): readonly Rewrite[];
|
|
49
|
+
//# sourceMappingURL=changes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changes.d.ts","sourceRoot":"","sources":["../src/changes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGhG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAED,oFAAoF;AACpF,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAID,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,aAAa,CAmJ1G;AAYD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,EAAE,IAAI,EAAE,gBAAgB,GAAG,SAAS,OAAO,EAAE,CA+B7G"}
|