@floless/app 0.163.0 → 0.165.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/dist/floless-server.cjs +37524 -36228
- package/dist/skills/floless-app-rfi/SKILL.md +25 -5
- package/dist/web/app.css +11 -5
- package/dist/web/aware.js +25 -8
- package/dist/web/chat.css +11 -1
- package/dist/web/chat.js +426 -41
- package/dist/web/commands-filter.js +35 -0
- package/dist/web/commands-shell.js +28 -11
- package/dist/web/commands-steel.js +9 -0
- package/dist/web/model-editor-steel-adapter.js +2 -0
- package/dist/web/project-rfis.js +68 -10
- package/dist/web/steel-3d-view.js +154 -0
- package/dist/web/steel-ai-marks.js +233 -0
- package/dist/web/steel-editor.html +509 -24
- package/dist/web/steel-filter-flo.js +225 -0
- package/dist/web/steel-filter.html +118 -4
- package/dist/web/workspaces.js +151 -21
- package/package.json +1 -1
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* steel-ai-marks — which members of a steel model rest on an AI decision, and how (#2521 row 6).
|
|
3
|
+
*
|
|
4
|
+
* Plan: `docs/superpowers/specs/2026-10-29-quick-model-row6-PLAN.md` (with Revisions 1 and 2, after two Codex rounds).
|
|
5
|
+
* Pattern: #2374's AI-answer marks.
|
|
6
|
+
*
|
|
7
|
+
* A Quick model is built by the AI deciding wherever a precise read would have asked the person, and every such
|
|
8
|
+
* decision is recorded. The model carries what it rests on (#2521 row 4, `server/ai-decision-list.ts`):
|
|
9
|
+
* - a member END whose height the AI decided says so in its own arm (`z.decided`, with `alsoRestsOn` for a split or
|
|
10
|
+
* merge). Exact, and it follows the member through moves, copies and splits; a typed height clears it;
|
|
11
|
+
* - every other decision is an entry of the server-owned `ai_decisions` list, which may over-report.
|
|
12
|
+
*
|
|
13
|
+
* What the screens show (owner rulings 2026-10-29):
|
|
14
|
+
* - end marks: each end whose height the AI decided (canvas, 3D, Inspect);
|
|
15
|
+
* - joint marks: each connection whose assumption the AI decided, once on the joint (canvas, 3D), and a line in the
|
|
16
|
+
* Inspect of each of its members;
|
|
17
|
+
* - view lines: a plan view whose scale or level the AI decided, a note on that view and a line in the Inspect of
|
|
18
|
+
* each member that view shows (the editor's own presence rule), never a canvas mark;
|
|
19
|
+
* - the model note: everything that bears on the whole model (the Drawing Filter, the origin, audit gaps, unmodelled
|
|
20
|
+
* details) and anything that cannot be placed on a member, said once.
|
|
21
|
+
*
|
|
22
|
+
* A MARK IS A FINDING, never a claim that the unmarked rest was drawn. Nothing is dropped unseen: what cannot be placed
|
|
23
|
+
* goes to the model note, and what cannot be read makes the state `unknown` (the server's "Possibly Quick model").
|
|
24
|
+
*
|
|
25
|
+
* The counting and readability follow the server's (`quickDependenciesOf`, `armsReadable`, `isWellFormedAiDecisionList`),
|
|
26
|
+
* except that a Filter value's digest cannot be checked here; `aiMarksDisplayState` therefore also reads the server's
|
|
27
|
+
* last-saved verdict, so the screen never says less than the label (plan Revision 2, V1).
|
|
28
|
+
*
|
|
29
|
+
* Pure, and read from the LIVE model the editor holds, so a mark sits on the member on screen.
|
|
30
|
+
*/
|
|
31
|
+
import { planViewId } from './steel-plan-view-id.js';
|
|
32
|
+
import { createMemberPresenceIndex, memberPresence } from './steel-model-v2-projection.js';
|
|
33
|
+
|
|
34
|
+
const AI_ID = /^[0-9a-f]{12}$/;
|
|
35
|
+
const DIGEST = /^[0-9a-f]{64}$/;
|
|
36
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
37
|
+
const only = (o, keys) => Object.keys(o).every((k) => keys.includes(k));
|
|
38
|
+
const str = (v, max) => typeof v === 'string' && v.trim().length > 0 && v.length <= max;
|
|
39
|
+
const finite = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
40
|
+
const nonNegInt = (v) => typeof v === 'number' && Number.isSafeInteger(v) && v >= 0;
|
|
41
|
+
const ENDS = /** @type {const} */ (['from', 'to']);
|
|
42
|
+
const ID_MAX = 200;
|
|
43
|
+
|
|
44
|
+
/** `parseCovers` (`server/connection-assumption-store.ts`), shape only. */
|
|
45
|
+
function coversOk(v) {
|
|
46
|
+
if (!isObj(v)) return false;
|
|
47
|
+
if (v.kind === 'fact') return only(v, ['kind', 'factId']) && str(v.factId, 200);
|
|
48
|
+
if (v.kind === 'unmeasured') return only(v, ['kind', 'text']) && str(v.text, 600);
|
|
49
|
+
if (v.kind === 'issue') return only(v, ['kind', 'code']) && str(v.code, 120);
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** `parseSubject` (`server/ai-decision-store.ts`), every channel. */
|
|
54
|
+
export function subjectOk(v) {
|
|
55
|
+
if (!isObj(v)) return false;
|
|
56
|
+
switch (v.channel) {
|
|
57
|
+
case 'height': return only(v, ['channel', 'memberId', 'end']) && str(v.memberId, ID_MAX) && (v.end === 0 || v.end === 1);
|
|
58
|
+
case 'setup':
|
|
59
|
+
if (v.row === 'origin') return only(v, ['channel', 'row']);
|
|
60
|
+
return (v.row === 'scale' || v.row === 'level') && only(v, ['channel', 'row', 'viewId']) && str(v.viewId, ID_MAX);
|
|
61
|
+
case 'audit-gap': {
|
|
62
|
+
if (!only(v, ['channel', 'gapKind', 'fields']) || !str(v.gapKind, 120) || !isObj(v.fields)) return false;
|
|
63
|
+
const fields = Object.entries(v.fields);
|
|
64
|
+
return fields.length > 0 && fields.length <= 12 && fields.every(([key, value]) => /^[A-Za-z][A-Za-z0-9]{0,39}$/.test(key)
|
|
65
|
+
&& (typeof value === 'number' ? Number.isFinite(value) : str(value, ID_MAX)));
|
|
66
|
+
}
|
|
67
|
+
case 'connection': return only(v, ['channel', 'jointId', 'covers']) && str(v.jointId, ID_MAX) && coversOk(v.covers);
|
|
68
|
+
case 'unmodelled-detail': return only(v, ['channel', 'sheetId', 'detailRef']) && str(v.sheetId, ID_MAX) && str(v.detailRef, ID_MAX);
|
|
69
|
+
case 'filter': return only(v, ['channel', 'checkpointDigest']) && typeof v.checkpointDigest === 'string' && DIGEST.test(v.checkpointDigest);
|
|
70
|
+
default: return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** `parseDecisionValue`'s SHAPE, per channel. The Filter value's digest binding is the server's alone (V1). */
|
|
75
|
+
export function valueOk(subject, v) {
|
|
76
|
+
switch (subject.channel) {
|
|
77
|
+
case 'height': return isObj(v) && only(v, ['mm']) && finite(v.mm);
|
|
78
|
+
case 'filter': {
|
|
79
|
+
if (v === undefined) return true;
|
|
80
|
+
if (!isObj(v) || !only(v, ['manifestHash', 'savedFilterHash', 'exclusionDigest', 'valueCount', 'dismissibleCount'])) return false;
|
|
81
|
+
if (v.dismissibleCount !== undefined && !nonNegInt(v.dismissibleCount)) return false;
|
|
82
|
+
if (typeof v.manifestHash !== 'string' || !DIGEST.test(v.manifestHash) || typeof v.savedFilterHash !== 'string' || !DIGEST.test(v.savedFilterHash)) return false;
|
|
83
|
+
if (v.exclusionDigest !== null && (typeof v.exclusionDigest !== 'string' || !DIGEST.test(v.exclusionDigest))) return false;
|
|
84
|
+
return nonNegInt(v.valueCount) && !(v.exclusionDigest === null && v.valueCount !== 0);
|
|
85
|
+
}
|
|
86
|
+
case 'setup':
|
|
87
|
+
if (!isObj(v)) return false;
|
|
88
|
+
if (subject.row === 'scale') return only(v, ['mmPerPx']) && finite(v.mmPerPx) && v.mmPerPx > 0;
|
|
89
|
+
if (subject.row === 'level') return (only(v, ['noSingleLevel']) && v.noSingleLevel === true) || (only(v, ['mm']) && finite(v.mm));
|
|
90
|
+
return only(v, ['xAxisId', 'yAxisId', 'xLabel', 'yLabel']) && [v.xAxisId, v.yAxisId, v.xLabel, v.yLabel].every((s) => str(s, ID_MAX));
|
|
91
|
+
default: return v === undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** One entry of `ai_decisions`, as `isWellFormedAiDecisionList` reads it (less the Filter digest). */
|
|
96
|
+
function entryOk(entry) {
|
|
97
|
+
return isObj(entry) && only(entry, ['id', 'buildId', 'channel', 'subject', 'chosen', 'value'])
|
|
98
|
+
&& typeof entry.id === 'string' && AI_ID.test(entry.id) && str(entry.buildId, ID_MAX) && typeof entry.chosen === 'string'
|
|
99
|
+
&& subjectOk(entry.subject) && entry.subject.channel === entry.channel && valueOk(entry.subject, entry.value);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @param {unknown} model a steel.model/v2 document (the editor's `C`)
|
|
104
|
+
*/
|
|
105
|
+
export function aiDecisionMarksOf(model) {
|
|
106
|
+
const members = new Map();
|
|
107
|
+
const ends = [];
|
|
108
|
+
const views = new Map();
|
|
109
|
+
const note = [];
|
|
110
|
+
const entries = new Map();
|
|
111
|
+
const jointsById = new Map();
|
|
112
|
+
const dependencies = new Set();
|
|
113
|
+
let readable = isObj(model) && model.type === 'steel.model/v2' && Array.isArray(model.members);
|
|
114
|
+
const push = (memberId, mark) => {
|
|
115
|
+
if (!members.has(memberId)) members.set(memberId, []);
|
|
116
|
+
members.get(memberId).push(mark);
|
|
117
|
+
};
|
|
118
|
+
const live = new Set();
|
|
119
|
+
|
|
120
|
+
// 1. Heights, from the member ends themselves. A malformed end could hide an arm (`armsReadable`), so it makes the
|
|
121
|
+
// whole reading unknown; an arm that names its decision oddly is still marked (over-mark, never drop).
|
|
122
|
+
for (const member of isObj(model) && Array.isArray(model.members) ? model.members : []) {
|
|
123
|
+
if (!isObj(member) || typeof member.id !== 'string') { readable = false; continue; }
|
|
124
|
+
live.add(member.id);
|
|
125
|
+
ENDS.forEach((key, end) => {
|
|
126
|
+
const point = member[key];
|
|
127
|
+
if (!isObj(point) || !isObj(point.z)) { readable = false; return; }
|
|
128
|
+
const decided = point.z.decided;
|
|
129
|
+
if (decided === undefined) return;
|
|
130
|
+
if (!isObj(decided) || decided.by !== 'ai' || typeof decided.decisionId !== 'string' || !AI_ID.test(decided.decisionId)
|
|
131
|
+
|| (decided.alsoRestsOn !== undefined && !(Array.isArray(decided.alsoRestsOn) && decided.alsoRestsOn.every((id) => typeof id === 'string' && AI_ID.test(id))))) {
|
|
132
|
+
readable = false;
|
|
133
|
+
}
|
|
134
|
+
const ids = isObj(decided)
|
|
135
|
+
? [decided.decisionId, ...(Array.isArray(decided.alsoRestsOn) ? decided.alsoRestsOn : [])].filter((id) => typeof id === 'string' && id)
|
|
136
|
+
: [];
|
|
137
|
+
const mark = { kind: 'height', end, decisionIds: [...new Set(ids)], derived: isObj(decided) && decided.derived === true };
|
|
138
|
+
for (const id of mark.decisionIds) dependencies.add(id);
|
|
139
|
+
ends.push({ memberId: member.id, end, decisionIds: mark.decisionIds, derived: mark.derived });
|
|
140
|
+
push(member.id, mark);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 2. Everything else, from the list the model carries. A height entry is evidence for an arm, never a mark or a
|
|
145
|
+
// dependency of its own (`quickDependenciesOf`); it is kept for the words Inspect shows.
|
|
146
|
+
const list = isObj(model) ? model.ai_decisions : undefined;
|
|
147
|
+
if (list !== undefined && !Array.isArray(list)) readable = false;
|
|
148
|
+
const plans = isObj(model) && Array.isArray(model.plans) ? model.plans.filter(isObj) : [];
|
|
149
|
+
const plansByView = new Map();
|
|
150
|
+
for (const plan of plans) { const v = planViewId(plan); if (v && !plansByView.has(v)) plansByView.set(v, plan); }
|
|
151
|
+
const jointIndex = new Map();
|
|
152
|
+
for (const joint of isObj(model) && Array.isArray(model.joints) ? model.joints : []) {
|
|
153
|
+
if (isObj(joint) && typeof joint.id === 'string' && !jointIndex.has(joint.id)) jointIndex.set(joint.id, joint);
|
|
154
|
+
}
|
|
155
|
+
let presence = null;
|
|
156
|
+
const presenceIndex = () => (presence ??= createMemberPresenceIndex(model));
|
|
157
|
+
for (const entry of Array.isArray(list) ? list : []) {
|
|
158
|
+
const ok = entryOk(entry) && !entries.has(entry.id);
|
|
159
|
+
if (!ok) {
|
|
160
|
+
readable = false;
|
|
161
|
+
const id = isObj(entry) && typeof entry.id === 'string' && AI_ID.test(entry.id) && !entries.has(entry.id) ? entry.id : null;
|
|
162
|
+
if (id && !(isObj(entry) && entry.channel === 'height')) dependencies.add(id);
|
|
163
|
+
note.push({ decisionId: id, channel: isObj(entry) && typeof entry.channel === 'string' ? entry.channel : 'unknown', reason: 'unreadable' });
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
entries.set(entry.id, entry);
|
|
167
|
+
if (entry.channel === 'height') continue;
|
|
168
|
+
const id = entry.id, subject = entry.subject;
|
|
169
|
+
dependencies.add(id);
|
|
170
|
+
switch (entry.channel) {
|
|
171
|
+
case 'connection': {
|
|
172
|
+
const joint = jointIndex.get(subject.jointId);
|
|
173
|
+
const named = joint ? [joint.main, ...(Array.isArray(joint.secondaries) ? joint.secondaries : [])] : [];
|
|
174
|
+
const memberIds = [...new Set(named.filter((m) => typeof m === 'string' && live.has(m)))];
|
|
175
|
+
if (!memberIds.length) { note.push({ decisionId: id, channel: 'connection', reason: joint ? 'unplaced' : 'gone' }); break; }
|
|
176
|
+
if (!jointsById.has(joint.id)) {
|
|
177
|
+
jointsById.set(joint.id, { jointId: joint.id, decisionIds: [], memberIds, main: live.has(joint.main) ? joint.main : null,
|
|
178
|
+
...(mainEndOf(joint) !== null && live.has(joint.main) ? { mainEnd: mainEndOf(joint) } : {}),
|
|
179
|
+
...(Array.isArray(joint.place) && joint.place.length === 3 && joint.place.every(finite) ? { place: joint.place } : {}) });
|
|
180
|
+
}
|
|
181
|
+
jointsById.get(joint.id).decisionIds.push(id);
|
|
182
|
+
for (const m of memberIds) push(m, { kind: 'connection', decisionId: id, jointId: joint.id });
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
case 'setup': {
|
|
186
|
+
if (subject.row === 'origin') { note.push({ decisionId: id, channel: 'setup-origin', reason: 'model' }); break; }
|
|
187
|
+
const plan = plansByView.get(subject.viewId);
|
|
188
|
+
if (!plan) { note.push({ decisionId: id, channel: 'setup', reason: 'gone' }); break; }
|
|
189
|
+
if (!views.has(subject.viewId)) views.set(subject.viewId, []);
|
|
190
|
+
views.get(subject.viewId).push({ decisionId: id, row: subject.row });
|
|
191
|
+
const index = presenceIndex();
|
|
192
|
+
for (const member of index.members.values()) {
|
|
193
|
+
if (memberPresence(model, plan, member, index).visible) push(member.id, { kind: 'view', decisionId: id, viewId: subject.viewId, row: subject.row });
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
default: // filter, audit-gap, unmodelled-detail: they bear on the whole model
|
|
198
|
+
note.push({ decisionId: id, channel: entry.channel, reason: 'model' });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
state: !readable ? 'unknown' : dependencies.size ? 'marks' : 'none',
|
|
204
|
+
members, ends, joints: [...jointsById.values()], views, model: note, entries,
|
|
205
|
+
decisionCount: dependencies.size,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* What every surface shows (plan Revision 2, V1): the live analysis and the server's verdict on the last saved model,
|
|
211
|
+
* whichever says more. `savedQuick`: `null` (the last save was precise), `{ state: 'quick'|'unknown' }`, or `undefined`
|
|
212
|
+
* when the editor never received a verdict it could read. Never `none` when either side cannot vouch for it.
|
|
213
|
+
*/
|
|
214
|
+
export function aiMarksDisplayState(marks, savedQuick) {
|
|
215
|
+
const saved = savedQuick === null ? 'none' : isObj(savedQuick) && savedQuick.state === 'quick' ? 'marks' : 'unknown';
|
|
216
|
+
if (marks.state === 'unknown' || saved === 'unknown') return 'unknown';
|
|
217
|
+
return marks.state === 'marks' || saved === 'marks' ? 'marks' : 'none';
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** The end of its main member a joint sits at, when its `at` names one ('base' and 'end0' the start, 'top' and 'end1' the end). */
|
|
221
|
+
export function mainEndOf(joint) {
|
|
222
|
+
const at = isObj(joint) ? joint.at : undefined;
|
|
223
|
+
return at === 'base' || at === 'end0' ? 0 : at === 'top' || at === 'end1' ? 1 : null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** The canvas and 3D payload: only the specific cases (owner ruling 2026-10-29), never view or model-wide decisions. */
|
|
227
|
+
export function canvasMarksOf(marks) {
|
|
228
|
+
return {
|
|
229
|
+
ends: marks.ends.map((e) => [e.memberId, e.end]),
|
|
230
|
+
joints: marks.joints.map((j) => ({ jointId: j.jointId, memberIds: j.memberIds, main: j.main,
|
|
231
|
+
...(j.mainEnd !== undefined ? { mainEnd: j.mainEnd } : {}), ...(j.place ? { place: j.place } : {}) })),
|
|
232
|
+
};
|
|
233
|
+
}
|