@floless/app 0.162.1 → 0.164.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.
Files changed (39) hide show
  1. package/dist/floless-server.cjs +39748 -35132
  2. package/dist/schemas/steel.model.v2.schema.json +16 -2
  3. package/dist/skills/floless-app-actions/SKILL.md +54 -3
  4. package/dist/skills/floless-app-onboarding/SKILL.md +2 -2
  5. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +8 -6
  6. package/dist/skills/floless-app-report-issue/SKILL.md +12 -1
  7. package/dist/skills/floless-app-rfi/SKILL.md +36 -9
  8. package/dist/skills/floless-app-steel-model/SKILL.md +5 -3
  9. package/dist/skills/floless-app-steel-takeoff/SKILL.md +39 -34
  10. package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +10 -6
  11. package/dist/web/agents.js +24 -4
  12. package/dist/web/app.css +47 -7
  13. package/dist/web/app.js +22 -3
  14. package/dist/web/aware.js +157 -43
  15. package/dist/web/chat.css +36 -1
  16. package/dist/web/chat.js +322 -44
  17. package/dist/web/commands-filter.js +35 -0
  18. package/dist/web/commands-shell.js +208 -11
  19. package/dist/web/commands-steel.js +23 -0
  20. package/dist/web/failure-copy.js +168 -0
  21. package/dist/web/index.html +35 -1
  22. package/dist/web/instructor.js +3 -1
  23. package/dist/web/landing-sort.js +277 -0
  24. package/dist/web/model-editor-steel-adapter.js +5 -0
  25. package/dist/web/model-panel-bridge.js +13 -2
  26. package/dist/web/model-view-query.js +23 -15
  27. package/dist/web/project-access.js +3 -3
  28. package/dist/web/project-rfis.js +303 -10
  29. package/dist/web/project-workflows.js +1 -1
  30. package/dist/web/steel-3d-view.js +162 -1
  31. package/dist/web/steel-ai-marks.js +233 -0
  32. package/dist/web/steel-editor.html +950 -36
  33. package/dist/web/steel-filter-core.js +2 -0
  34. package/dist/web/steel-filter-flo.js +225 -0
  35. package/dist/web/steel-filter.html +156 -9
  36. package/dist/web/steel-model-v2-commands.js +3 -1
  37. package/dist/web/steel-profile-colours.js +124 -24
  38. package/dist/web/workspaces.js +380 -58
  39. package/package.json +1 -1
@@ -1,6 +1,20 @@
1
1
  /*
2
2
  * One pure profile-colour identity seam for the browser editor and the server scene bake.
3
3
  * Keep policy here: consumers choose neither a different canonicalizer nor a different alias winner.
4
+ *
5
+ * SPELLINGS (#2877). One catalogue section can be written several ways (`UC305X97`, `UC305*305*97`,
6
+ * `305X305X97 UC`), and `canonicalProfile` only folds case, the multiplication sign and spaces, so it
7
+ * cannot tell that those name the same steel. The catalogue can. Each consumer hands this module a
8
+ * `spellingsOf(profile)` built from its own catalogue with `catalogueSpellings`, and a colour keyed
9
+ * under ANY spelling of a section is that section's colour. Without that the editor wrote `UC305X97`
10
+ * while the bake looked up `UC305*305*97`, so a UK model drew every member in the palette's last
11
+ * colour in 3D while 2D showed the chosen one.
12
+ *
13
+ * Determinism: the candidate order for a section depends only on the MODEL, never on which member is
14
+ * asking, so 2D (per member) and 3D (per group) always pick the same key. The order is the spellings
15
+ * the model's members actually carry (sorted), then the asking profile, then the catalogue spellings
16
+ * in catalogue order (`sectionSpellings`). The editor writes a colour under the member's own spelling
17
+ * and removes every key under that same list, so after one edit no other key the lookup reads remains.
4
18
  */
5
19
 
6
20
  export const canonicalProfile = (value) => String(value == null ? '' : value)
@@ -8,47 +22,133 @@ export const canonicalProfile = (value) => String(value == null ? '' : value)
8
22
 
9
23
  const warnedCollisions = new Set();
10
24
 
11
- /** Exact canonical key first; otherwise the lexicographically first equivalent raw key. */
12
- export function resolveProfileColour(profile, overrides, warn) {
13
- const canonical = canonicalProfile(profile);
25
+ /**
26
+ * Every spelling of one catalogue row that resolves BACK to that row: `[designation, ...aliases]`
27
+ * minus any alias that is another row's own name. The US catalogue carries such aliases (`RE#3`
28
+ * lists `RE#10`, which is also a primary), and treating them as the same steel would leak one
29
+ * section's colour onto another and delete it on edit. `resolve(spelling)` is the caller's own
30
+ * catalogue lookup, so the browser and the server each answer from the catalogue they hold.
31
+ */
32
+ export function catalogueSpellings(row, resolve) {
33
+ if (!row || !row.designation) return [];
34
+ const own = String(row.designation);
35
+ return [own, ...(Array.isArray(row.aliases) ? row.aliases : [])]
36
+ .filter((spelling) => spelling === own || resolve(spelling)?.designation === own);
37
+ }
38
+
39
+ /** The canonical identities to try, in order: the profile itself, then the given spellings. */
40
+ export function profileColourCandidates(profile, spellings) {
41
+ const out = [];
42
+ for (const value of [profile, ...(Array.isArray(spellings) ? spellings : [])]) {
43
+ const canonical = canonicalProfile(value);
44
+ if (canonical && !out.includes(canonical)) out.push(canonical);
45
+ }
46
+ return out;
47
+ }
48
+
49
+ /**
50
+ * The first candidate (see `profileColourCandidates`) that has a key wins. Within that candidate the
51
+ * exact canonical key wins, otherwise the lexicographically first equivalent raw key.
52
+ */
53
+ export function resolveProfileColour(profile, overrides, warn, spellings) {
54
+ const candidates = profileColourCandidates(profile, spellings);
14
55
  const map = overrides && typeof overrides === 'object' ? overrides : {};
15
- const aliases = Object.keys(map).filter((key) => canonicalProfile(key) === canonical).sort();
56
+ const aliases = Object.keys(map).filter((key) => candidates.includes(canonicalProfile(key))).sort();
16
57
  if (!aliases.length) return { value: null, winnerKey: null, aliases: [], collision: false };
17
- const winnerKey = Object.prototype.hasOwnProperty.call(map, canonical) ? canonical : aliases[0];
58
+ let winnerKey = aliases[0];
59
+ for (const candidate of candidates) {
60
+ const matches = aliases.filter((key) => canonicalProfile(key) === candidate);
61
+ if (!matches.length) continue;
62
+ winnerKey = Object.prototype.hasOwnProperty.call(map, candidate) ? candidate : matches[0];
63
+ break;
64
+ }
18
65
  const collision = new Set(aliases.map((key) => map[key])).size > 1;
19
- if (collision && typeof warn === 'function' && !warnedCollisions.has(canonical)) {
20
- warnedCollisions.add(canonical);
21
- warn(`Profile colour aliases collide for ${canonical}: ${aliases.join(', ')}. Using ${winnerKey}.`);
66
+ const label = candidates[0];
67
+ if (collision && typeof warn === 'function' && !warnedCollisions.has(label)) {
68
+ warnedCollisions.add(label);
69
+ warn(`Profile colour aliases collide for ${label}: ${aliases.join(', ')}. Using ${winnerKey}.`);
22
70
  }
23
71
  return { value: map[winnerKey], winnerKey, aliases, collision };
24
72
  }
25
73
 
26
- /** Mutates the persisted map into its canonical write shape: one key per profile identity. */
27
- export function setCanonicalProfileColour(overrides, profile, colour) {
74
+ /**
75
+ * Mutates the persisted map into its canonical write shape: one key per section. Keys under any other
76
+ * spelling of the same section (`spellings`: pass `sectionSpellings(context, profile)`, every spelling
77
+ * a lookup reads) go too, so a colour stored twice collapses to the key the editor writes instead of
78
+ * leaving a stale twin that a lookup would still prefer.
79
+ */
80
+ export function setCanonicalProfileColour(overrides, profile, colour, spellings) {
28
81
  const canonical = canonicalProfile(profile);
29
82
  if (!canonical || !overrides || typeof overrides !== 'object') return canonical;
30
- for (const key of Object.keys(overrides)) if (canonicalProfile(key) === canonical) delete overrides[key];
83
+ const candidates = profileColourCandidates(canonical, spellings);
84
+ for (const key of Object.keys(overrides)) if (candidates.includes(canonicalProfile(key))) delete overrides[key];
31
85
  overrides[canonical] = colour;
32
86
  return canonical;
33
87
  }
34
88
 
35
- /** Native v2 owns one root member array; only the explicit legacy branch reads plan-local members. */
36
- export function profileColourRank(model, weights) {
37
- const members = model?.type === 'steel.model/v2'
38
- ? (Array.isArray(model.members) ? model.members : [])
39
- : (Array.isArray(model?.plans) ? model.plans.flatMap((plan) => Array.isArray(plan?.members) ? plan.members : []) : []);
40
- return [...new Set([
41
- ...members.map((member) => canonicalProfile(member?.profile)).filter(Boolean),
42
- ...Object.keys(weights && typeof weights === 'object' ? weights : {}).map(canonicalProfile).filter(Boolean),
43
- ])].sort();
89
+ const modelMembers = (model) => (model?.type === 'steel.model/v2'
90
+ ? (Array.isArray(model.members) ? model.members : [])
91
+ : (Array.isArray(model?.plans) ? model.plans.flatMap((plan) => Array.isArray(plan?.members) ? plan.members : []) : []));
92
+
93
+ const spellingsFn = (spellingsOf) => (typeof spellingsOf === 'function'
94
+ ? (profile) => { const out = spellingsOf(profile); return Array.isArray(out) ? out : []; }
95
+ : () => []);
96
+
97
+ /** A section's identity: its catalogue designation when the catalogue knows it, else its own spelling. */
98
+ const sectionIdentity = (profile, spell) => canonicalProfile(spell(profile)[0] ?? profile) || canonicalProfile(profile);
99
+
100
+ /**
101
+ * The palette rank: the sorted unique set of every member's section and the weight-table keys. Native
102
+ * v2 owns one root member array; only the explicit legacy branch reads plan-local members. With
103
+ * `spellingsOf` the rank holds one entry per SECTION, so two spellings of one section share a slot.
104
+ */
105
+ export function profileColourRank(model, weights, spellingsOf) {
106
+ const spell = spellingsFn(spellingsOf);
107
+ const profiles = [
108
+ ...modelMembers(model).map((member) => member?.profile),
109
+ ...Object.keys(weights && typeof weights === 'object' ? weights : {}),
110
+ ].filter((profile) => canonicalProfile(profile));
111
+ return [...new Set(profiles.map((profile) => sectionIdentity(profile, spell)))].sort();
112
+ }
113
+
114
+ /**
115
+ * Everything a colour lookup needs from one model, built once per render (editor) or per bake
116
+ * (server): the palette rank and, per section, the spellings its members carry.
117
+ */
118
+ export function profileColourContext(model, weights, spellingsOf) {
119
+ const spell = spellingsFn(spellingsOf);
120
+ const used = new Map();
121
+ for (const member of modelMembers(model)) {
122
+ const own = canonicalProfile(member?.profile);
123
+ if (!own) continue;
124
+ const id = sectionIdentity(member.profile, spell);
125
+ if (!used.has(id)) used.set(id, new Set());
126
+ used.get(id).add(own);
127
+ }
128
+ return { rank: profileColourRank(model, weights, spellingsOf), spell, used };
44
129
  }
45
130
 
46
- export function profileColour(profile, overrides, rank, palette, warn) {
47
- const canonical = canonicalProfile(profile);
48
- const resolved = resolveProfileColour(canonical, overrides, warn);
131
+ /**
132
+ * Every spelling a lookup for `profile` reads, in priority order: the spellings the model's members
133
+ * carry for that section (sorted), the profile itself, then its catalogue spellings. A member spelling
134
+ * the catalogue resolves but does not list (the takeoff's spaced mixed fraction `HSS3 1/2X3 1/2X1/4`)
135
+ * is read here, so an edit must remove it too: `setCanonicalProfileColour` takes this same list.
136
+ */
137
+ export function sectionSpellings(context, profile) {
138
+ const spell = typeof context?.spell === 'function' ? context.spell : () => [];
139
+ const id = sectionIdentity(profile, spell);
140
+ return [...[...(context?.used?.get(id) ?? [])].sort(), profile, ...spell(profile)];
141
+ }
142
+
143
+ /** An override under any spelling first, else the section's palette slot (the last colour if unranked). */
144
+ export function profileColour(profile, overrides, context, palette, warn) {
145
+ const spell = typeof context?.spell === 'function' ? context.spell : () => [];
146
+ const id = sectionIdentity(profile, spell);
147
+ const ordered = sectionSpellings(context, profile);
148
+ const resolved = resolveProfileColour(ordered[0], overrides, warn, ordered.slice(1));
49
149
  if (resolved.value) return resolved.value;
50
150
  const colours = Array.isArray(palette) && palette.length ? palette : [];
51
151
  if (!colours.length) return null;
52
- const index = rank.indexOf(canonical);
152
+ const index = Array.isArray(context?.rank) ? context.rank.indexOf(id) : -1;
53
153
  return colours[((index % colours.length) + colours.length) % colours.length];
54
154
  }