@floless/app 0.137.4 → 0.138.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/floless-server.cjs +48371 -27278
  2. package/dist/internal-workflows/floless-rfi-gmail-send/.floless-owner.json +1 -0
  3. package/dist/internal-workflows/floless-rfi-gmail-send/floless-rfi-gmail-send.flo +32 -0
  4. package/dist/schemas/steel.model.v2.schema.json +218 -27
  5. package/dist/skills/floless-app-knowledge/SKILL.md +5 -2
  6. package/dist/skills/floless-app-rfi/SKILL.md +410 -0
  7. package/dist/skills/floless-app-routines/SKILL.md +7 -2
  8. package/dist/skills/floless-app-routines/references/routines-api.md +14 -5
  9. package/dist/skills/floless-app-steel-model/SKILL.md +34 -32
  10. package/dist/skills/floless-app-steel-takeoff/SKILL.md +498 -34
  11. package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +6 -6
  12. package/dist/skills/floless-app-tweak-contract/SKILL.md +6 -2
  13. package/dist/templates/floless-workspace-knowledge.flo +20 -4
  14. package/dist/templates/steel-model.flo +27 -15
  15. package/dist/web/app.css +559 -131
  16. package/dist/web/app.js +216 -54
  17. package/dist/web/aware.js +982 -128
  18. package/dist/web/checkpoint-standard.js +218 -0
  19. package/dist/web/commands-filter.js +23 -0
  20. package/dist/web/commands-shell.js +237 -5
  21. package/dist/web/commands-steel.js +172 -47
  22. package/dist/web/connection-review-client.js +2 -2
  23. package/dist/web/display-units.js +243 -0
  24. package/dist/web/grid-core.js +470 -56
  25. package/dist/web/grid-display.js +344 -0
  26. package/dist/web/index.html +106 -66
  27. package/dist/web/instructor-reporter.js +5 -0
  28. package/dist/web/instructor.js +175 -33
  29. package/dist/web/json-schema-subset.js +145 -25
  30. package/dist/web/steel-3d-core.js +124 -140
  31. package/dist/web/steel-3d-view.js +352 -100
  32. package/dist/web/steel-catalog-picker.js +98 -15
  33. package/dist/web/steel-detail-refs.js +1 -1
  34. package/dist/web/steel-editor.html +6458 -915
  35. package/dist/web/steel-filter.html +404 -57
  36. package/dist/web/steel-model-adapter.js +1 -1
  37. package/dist/web/steel-model-commands.js +71 -64
  38. package/dist/web/steel-model-v2-client-validation.js +10 -3
  39. package/dist/web/steel-model-v2-commands.js +268 -76
  40. package/dist/web/steel-model-v2-projection.js +18 -17
  41. package/dist/web/steel-plan-transform.js +13 -13
  42. package/dist/web/steel-plan-view-id.js +1 -7
  43. package/dist/web/steel-read-confidence.js +454 -5
  44. package/dist/web/steel-units.js +17 -3
  45. package/dist/web/steel-view-generation.js +21 -7
  46. package/dist/web/workspaces.js +2178 -497
  47. package/package.json +4 -1
@@ -0,0 +1,243 @@
1
+ /*
2
+ * display-units.js — the ONE length formatter and the ONE length parser, both unit-aware.
3
+ *
4
+ * WHAT THIS IS FOR. The steel editor used to run an inches-canonical sub-world: its own `parseLen`
5
+ * answered decimal INCHES and its own `fmtFtIn` consumed them, while the contract, the 3D scene and
6
+ * `grid-core` were all millimetres. Two files converted between the two worlds and three more did it
7
+ * ad hoc, which is how `web/steel-3d-core.js` ended up multiplying a projected elevation by 25.4 in
8
+ * one place while `web/steel-editor.html` divided by it in another. This module ends that: everything
9
+ * inside the editor is millimetres, and a unit is chosen exactly once, here, at the moment a number
10
+ * becomes text a person reads — or stops being text a person typed.
11
+ *
12
+ * WHY IT IS ITS OWN LEAF MODULE and not part of `steel-units.js`. That file holds the three exact
13
+ * unit CONSTANTS, which are definitions (an inch IS 25.4 mm). What lives here is POLICY: how many
14
+ * decimals a millimetre gets, that an elevation reads in metres while a length reads bare, that a
15
+ * typed bare number means whatever the project is currently displaying. Policy and definition age
16
+ * differently and should not share a file. Being a leaf also means `server/*.test.ts` can import and
17
+ * execute it directly, which matters more than usual — `web/steel-editor.html` is a classic script
18
+ * `tsc` never type-checks, so a test that runs this code is the only check there is.
19
+ *
20
+ * LENGTH AND ELEVATION ARE DIFFERENT QUESTIONS, and each has its own inverse. This is not tidiness:
21
+ * `formatElevation(3048, 'mm')` renders `+3.048` (metres — the convention every real UK drawing uses
22
+ * for levels), and the elevation fields are EDITABLE, so a length parser reading that back would
23
+ * answer 3 mm. Pressing Enter on an untouched Default TOS field would move the datum by three orders
24
+ * of magnitude, silently, with a number that still looks like a number. So the module ships two
25
+ * PAIRS, and a caller picks a pair rather than picking a formatter:
26
+ *
27
+ * LENGTH formatLength <-> parseLengthMm
28
+ * ELEVATION formatElevation <-> parseElevationMm
29
+ *
30
+ * `docs/superpowers/specs/2026-09-02-uk-slice1-unit-inventory.md` records which pair every call site
31
+ * in the editor gets, and why.
32
+ *
33
+ * THE `ft-in` PATH IS BYTE-FOR-BYTE WHAT `fmtFtIn` DID. Deliberately, and it is the whole proof of
34
+ * the commit that introduced this file: the arithmetic below is the old function's, reassociated only
35
+ * where IEEE guarantees the same bits (`Math.abs(mm / 25.4)` and `Math.abs(mm) / 25.4` differ in sign
36
+ * handling, never in magnitude). A US project's every rendered string is unchanged, which is what
37
+ * makes "no pixel moved" a checkable claim rather than a hope.
38
+ */
39
+
40
+ import { FT_TO_MM, IN_TO_MM } from './steel-units.js';
41
+
42
+ /** Feet and inches, to the nearest sixteenth — the US/AISC drawing convention. */
43
+ export const FT_IN = 'ft-in';
44
+ /** Millimetres for lengths, metres for elevations — the convention measured on every real UK set. */
45
+ export const MM = 'mm';
46
+
47
+ /**
48
+ * What a project displays when nobody has said otherwise.
49
+ *
50
+ * `ft-in`, because every project that exists today is a US one and a default that changed what an
51
+ * existing model reads would be a silent migration dressed as a default.
52
+ */
53
+ export const DEFAULT_DISPLAY_UNITS = FT_IN;
54
+
55
+ /**
56
+ * Anything at all -> one of the two systems. An unknown value reads as the default rather than
57
+ * throwing: this is consulted on every render, and a display preference is never worth a blank canvas.
58
+ */
59
+ export function normalizeDisplayUnits(value) {
60
+ return value === MM ? MM : FT_IN;
61
+ }
62
+
63
+ /** Absent / unreadable numbers render as nothing, which is what `fmtFtIn` always did. */
64
+ const blank = (mm) => mm == null || typeof mm === 'boolean' || !Number.isFinite(Number(mm));
65
+
66
+ /**
67
+ * Millimetres -> the architectural ft-in string, to the nearest 1/16".
68
+ *
69
+ * The body is `fmtFtIn`'s, with its argument converted here instead of at each of 47 call sites.
70
+ */
71
+ function ftIn(mm) {
72
+ const value = Number(mm);
73
+ const neg = value < 0;
74
+ let sixteenths = Math.round(Math.abs(value) / IN_TO_MM * 16);
75
+ const feet = Math.floor(sixteenths / 192);
76
+ sixteenths -= feet * 192;
77
+ const inches = Math.floor(sixteenths / 16);
78
+ let numerator = sixteenths - inches * 16;
79
+ let denominator = 16;
80
+ while (numerator > 0 && numerator % 2 === 0) { numerator /= 2; denominator /= 2; }
81
+ const fraction = numerator > 0 ? (' ' + numerator + '/' + denominator) : '';
82
+ const body = feet > 0 ? (feet + "'-" + inches + fraction + '"') : (inches + fraction + '"');
83
+ return (neg ? '-' : '') + body;
84
+ }
85
+
86
+ /**
87
+ * A LENGTH, in the project's display units.
88
+ *
89
+ * Metric lengths are BARE — no `mm` suffix and no thousands separator — because a bare number on a
90
+ * steel drawing means millimetres everywhere in the world, and a grouped `3,000` is a number a
91
+ * European reader may read as three. The suffix appears only where a value is echoed back at someone
92
+ * who just typed it (`formatLengthEcho`) or in a table header.
93
+ *
94
+ * One decimal, and only when the value has one: catalogue sections genuinely carry sub-millimetre
95
+ * dimensions (a 16.0 mm wall, an 11.1 mm angle leg) and rounding those to whole millimetres would
96
+ * make two real sections print the same size.
97
+ */
98
+ export function formatLength(mm, units) {
99
+ if (blank(mm)) return '';
100
+ if (normalizeDisplayUnits(units) === FT_IN) return ftIn(mm);
101
+ const rounded = Math.round(Number(mm) * 10) / 10;
102
+ // `Object.is` rather than `=== 0`, so a value that rounds to negative zero prints "0" and not "-0".
103
+ if (Object.is(rounded, -0)) return '0';
104
+ return Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(1);
105
+ }
106
+
107
+ /**
108
+ * An ELEVATION — an absolute height in the model frame — in the project's display units.
109
+ *
110
+ * Metric elevations read in METRES, signed, to exactly three decimals: `+3.048`, `-1.250`. That is
111
+ * the convention on all three real UK sets measured for this epic ("all dimensions are in
112
+ * millimetres; levels are in metres"), and three decimals of a metre is exactly millimetre precision,
113
+ * so the mixed convention costs nothing — it is lossless, not a rounding.
114
+ *
115
+ * The sign is always shown. A level is measured from a datum that can legitimately sit above it, and
116
+ * `3.048` vs `+3.048` is the difference between a number and a level.
117
+ *
118
+ * A DIFFERENCE between two elevations is a LENGTH, not an elevation. The move-distance chip and the
119
+ * bolt-gauge diagnostic look like elevations and are not; the inventory names each one.
120
+ */
121
+ export function formatElevation(mm, units) {
122
+ if (blank(mm)) return '';
123
+ if (normalizeDisplayUnits(units) === FT_IN) return ftIn(mm);
124
+ const metres = Number(mm) / 1000;
125
+ const text = metres.toFixed(3);
126
+ // toFixed already carries the minus sign; only a non-negative needs one added. The `-0.000` case
127
+ // (a tiny negative that rounds away) is normalised to `+0.000` so a datum never reads as below itself.
128
+ if (text === '-0.000') return '+0.000';
129
+ return text.startsWith('-') ? text : ('+' + text);
130
+ }
131
+
132
+ /**
133
+ * The canonical echo under an input — what the number you typed actually means.
134
+ *
135
+ * In ft-in this is the decimal-inch reading `fmtDecIn` has always shown, which is how someone checks
136
+ * that `1'-0 1/4"` was understood as 12.25 and not 12.5. In mm it is the same value with its unit
137
+ * spelled out, because this is the one place the suffix earns its space: the field above it is where
138
+ * a person can type `25'-6"` into a metric project, and the echo answering `7772 mm` is the entire
139
+ * point of accepting that input at all.
140
+ *
141
+ * An em-dash for an absent value, matching `fmtDecIn` — this slot sits under a field that may be
142
+ * empty, and an empty echo under an empty field reads as a missing element rather than a missing value.
143
+ */
144
+ export function formatLengthEcho(mm, units) {
145
+ if (blank(mm)) return '—';
146
+ if (normalizeDisplayUnits(units) === FT_IN) return (Math.round(Number(mm) / IN_TO_MM * 100) / 100) + '"';
147
+ return formatLength(mm, MM) + ' mm';
148
+ }
149
+
150
+ /* There is deliberately no `formatElevationEcho`. One existed for a while and was character-for-character
151
+ * `formatLengthEcho`, exported, documented, uncalled and untested — an unused near-duplicate of the one
152
+ * function it must never drift from, which is the setup for a real bug rather than a guard against one.
153
+ * The echo answers the same question for both classes ("what does the number you typed actually mean"),
154
+ * so both classes use `formatLengthEcho`. If an elevation ever needs a different echo, this is the note
155
+ * that says the split is intentional when it comes back. */
156
+
157
+ /** Fail closed on Infinity (a `1/0` fraction) or a decimal that overflowed (`1e999`). */
158
+ const finiteOrNull = (value) => (Number.isFinite(value) ? value : null);
159
+
160
+ /**
161
+ * Split a typed length into its parts, or null if it is not a length at all.
162
+ *
163
+ * Returns `{ mm, bare, magnitude }` — `mm` is the value when the token named its own unit, and when
164
+ * it did not, `bare` is true and `magnitude` is the raw number for the caller to interpret. That
165
+ * split is the whole reason this is a separate function: a LENGTH reads a bare number as millimetres
166
+ * and an ELEVATION reads it as metres, and everything else about the two is identical.
167
+ */
168
+ function splitLength(text) {
169
+ if (text == null) return null;
170
+ let s = String(text).trim().replace(/[”″]/g, '"').replace(/[’′]/g, "'");
171
+ if (s === '') return null;
172
+ let sign = 1;
173
+ if (s[0] === '-') { sign = -1; s = s.slice(1).trim(); }
174
+ else if (s[0] === '+') { s = s.slice(1).trim(); }
175
+ if (s === '') return null;
176
+
177
+ // A token that NAMES its unit is read in that unit whatever the project displays. This is what lets
178
+ // a metric job accept `25'-6"` straight off an imported US detail, and a US job accept `7.5m`.
179
+ let m = /^([0-9]+(?:\.[0-9]+)?)\s*mm$/i.exec(s);
180
+ if (m) return { mm: finiteOrNull(sign * parseFloat(m[1])), bare: false, magnitude: 0 };
181
+ m = /^([0-9]+(?:\.[0-9]+)?)\s*m$/i.exec(s);
182
+ if (m) return { mm: finiteOrNull(sign * parseFloat(m[1]) * 1000), bare: false, magnitude: 0 };
183
+
184
+ let feet = 0;
185
+ const feetMatch = s.match(/^([0-9]+(?:\.[0-9]+)?)\s*'/);
186
+ const sawFeet = !!feetMatch;
187
+ if (feetMatch) { feet = parseFloat(feetMatch[1]); s = s.slice(feetMatch[0].length).replace(/^[-\s]+/, ''); }
188
+ const sawInchMark = s.includes('"');
189
+ s = s.replace(/"/g, '').trim();
190
+
191
+ let inches = 0;
192
+ let sawFraction = false;
193
+ let sawNumber = false;
194
+ if (s !== '') {
195
+ const im = s.match(/^([0-9]+(?:\.[0-9]+)?)?\s*([0-9]+)\/([0-9]+)$|^([0-9]+(?:\.[0-9]+)?)$/);
196
+ if (!im) return null;
197
+ sawNumber = true;
198
+ if (im[4] != null) inches = parseFloat(im[4]);
199
+ else {
200
+ sawFraction = true;
201
+ if (im[1] != null) inches += parseFloat(im[1]);
202
+ inches += parseInt(im[2], 10) / parseInt(im[3], 10);
203
+ }
204
+ } else if (!sawFeet) {
205
+ return null;
206
+ }
207
+
208
+ // BARE = a plain number with nothing imperial about it. A fraction counts as imperial even without
209
+ // an inch mark: `5 3/4` is not a metric way to write anything, and reading it as 5.75 mm would turn
210
+ // a typed detail dimension into dust.
211
+ const bare = !sawFeet && !sawInchMark && !sawFraction && sawNumber;
212
+ if (bare) return { mm: null, bare: true, magnitude: sign * inches };
213
+ return { mm: finiteOrNull(sign * (feet * FT_TO_MM + inches * IN_TO_MM)), bare: false, magnitude: 0 };
214
+ }
215
+
216
+ /**
217
+ * A typed LENGTH -> millimetres, or null.
218
+ *
219
+ * Accepts `5.75`, `5 3/4`, `3/4"`, `1'-0 1/4"`, `16'-6"`, `7.5m`, `3000mm` in BOTH systems. A bare
220
+ * number means the system currently on display: inches in a ft-in project (which is what the editor
221
+ * has always done — its placeholders invite `5 3/4"` and people type `204`), millimetres in a metric
222
+ * one (which is what is written on the drawing).
223
+ */
224
+ export function parseLengthMm(text, units) {
225
+ const parts = splitLength(text);
226
+ if (!parts) return null;
227
+ if (!parts.bare) return parts.mm;
228
+ return finiteOrNull(normalizeDisplayUnits(units) === MM ? parts.magnitude : parts.magnitude * IN_TO_MM);
229
+ }
230
+
231
+ /**
232
+ * A typed ELEVATION -> millimetres, or null. The true inverse of `formatElevation`.
233
+ *
234
+ * Identical to `parseLengthMm` except for the bare case, and that one difference is the point: a
235
+ * metric elevation is DISPLAYED in metres, so a bare number typed into that field is metres. Without
236
+ * this, the field would render `+3.048` and read it back as three millimetres.
237
+ */
238
+ export function parseElevationMm(text, units) {
239
+ const parts = splitLength(text);
240
+ if (!parts) return null;
241
+ if (!parts.bare) return parts.mm;
242
+ return finiteOrNull(normalizeDisplayUnits(units) === MM ? parts.magnitude * 1000 : parts.magnitude * IN_TO_MM);
243
+ }