@floless/app 0.126.0 → 0.126.2

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.
@@ -2,7 +2,7 @@
2
2
  name: floless-app-bridge
3
3
  description: This skill should be used when the user is driving the floless.app web UI (the local prompt-native front door at http://127.0.0.1:4317) and wants the terminal AI to act on what they did there — picking up queued Tweak requests, "use this template" requests, or the context of a node they selected/edited on the canvas. Use it when the user says things like "apply the tweak I just queued", "I clicked Tweak on the bom node — make that change", "pick up my floless request", "what queued requests are pending", or after they double-click/Tweak a node in the UI. ALSO use it the moment the user pastes a message that begins with a `[floless-request type=… id=…]` marker — that is a request copied from the FloLess Dashboard, NOT a literal instruction to run; resolve it via the API. It reads the floless.app local API, applies the change to the app's .flo, recompiles, and clears the request. Workspace approval, pending model changes, history/checkpoints, and export-source choices belong to floless-app-approval instead.
4
4
  metadata:
5
- version: 0.3.0
5
+ version: 0.3.1
6
6
  ---
7
7
 
8
8
  # floless.app ↔ terminal bridge
@@ -97,7 +97,7 @@ digraph { "GET /api/requests" -> "for each pending" -> "read app .flo + node" ->
97
97
  the user wants to choose which to apply (not just the oldest), use the `floless-app-queue` skill** —
98
98
  it lists the queue in plain English and asks which to process, then routes each pick to the owning
99
99
  authoring skill. Its §2 table is where the whole type→skill routing is written out in prose (the
100
- authority itself is `REQUEST_SKILL` in `web/aware.js`, which that table restates).
100
+ authority itself is `REQUEST_SKILL` in `server/request-instruction.ts`, which that table restates).
101
101
  2. **Locate the app source.** The editable `.flo` is the repo copy `demos/<appId>/<appId>.flo`
102
102
  (preferred — it's version-controlled); the installed copy is `~/.aware/apps/<appId>/<appId>.flo`.
103
103
  Edit the **repo** copy. `GET /api/app/<appId>` returns the parsed nodes + each node's
@@ -131,7 +131,7 @@ resolved by their own POST, and the marker the Dashboard copies says so in its o
131
131
  | `knowledge-organize` | `POST /api/projects/<project>/knowledge/requests/<id>/finish` (or `…/fail`) — after claiming the pass with `…/start` | the lock you took at `…/start` is only reclaimable after `LOCK_STALE_MS` (**10 minutes**), and the leftover `organize.json` leaves the Knowledge pane showing "Organizing…" with Organize **disabled indefinitely** |
132
132
 
133
133
  This is the same per-type rule the UI encodes in `markedInstruction()`'s `clears` branch
134
- (`web/aware.js`) — and the reason `clearAllRequests()` there refuses to include an organize in its
134
+ (`server/request-instruction.ts`) — and the reason `clearAllRequests()` in `web/aware.js` refuses to include an organize in its
135
135
  bulk clear. `floless-app-queue` §4 carries the same table.
136
136
 
137
137
  ## Guardrails
@@ -2,7 +2,7 @@
2
2
  name: floless-app-queue
3
3
  description: This skill should be used when the user has MULTIPLE floless.app requests queued from the Dashboard and wants to see them and choose which to process, rather than the AI just picking up the oldest one. Use it when the user says things like "what's in my floless queue", "list my queued floless requests", "show me the pending requests and let me pick", "I queued a few tweaks — which should I apply?", "let me choose what to process", or "pick from the floless queue". It lists the pending requests from GET /api/requests in plain language (type, which app/node/project, the instruction), asks the user which one(s) to apply, then hands each chosen request to the owning skill (floless-app-workflows / -tweak-contract / -ui / -rebake / -onboarding / -new-workflow / -steel-takeoff / -vectorize / -knowledge) which applies it and clears it. It is the interactive picker that sits in front of floless-app-bridge (which is the actual pull-apply-clear engine).
4
4
  metadata:
5
- version: 0.2.1
5
+ version: 0.2.2
6
6
  ---
7
7
 
8
8
  # floless.app queue picker
@@ -60,7 +60,7 @@ map to:
60
60
 
61
61
  The type union itself is `FlolessRequest` in `server/floless-store.ts` — a type in the union with no row
62
62
  above means this table is stale, and the union is right. The routing is `REQUEST_SKILL` in
63
- `web/aware.js`, with the `revision-read` app-aware override right below it; it now covers every member
63
+ `server/request-instruction.ts`, with the `revision-read` app-aware override in `markerFor()` below it; it now covers every member
64
64
  of the union, so if it and this table disagree, the code is right and this table is stale — say so.
65
65
 
66
66
  Note the count of screenshots for requests that carry `snapshots`. If a request has an unfamiliar
@@ -92,7 +92,7 @@ curl -s -X DELETE http://127.0.0.1:4317/api/requests/<id> # the UI's "requests
92
92
  | `knowledge-organize` | `POST /api/projects/<project>/knowledge/requests/<id>/finish` (or `…/fail`) — after claiming the pass with `…/start` | the lock you took at `…/start` is only reclaimable after `LOCK_STALE_MS` (**10 minutes**) — and the leftover `organize.json`, which only finish/fail removes, leaves the Knowledge pane showing "Organizing…" with Organize **disabled indefinitely**, so the user cannot even re-queue |
93
93
 
94
94
  Every other type is applied-then-`DELETE`d as above. This is the same per-type rule the UI encodes in
95
- `markedInstruction()`'s `clears` branch (`web/aware.js`) — check there if a type's ending is unclear.
95
+ `markerFor()`'s `clears` branch (`server/request-instruction.ts`) — check there if a type's ending is unclear.
96
96
 
97
97
  Process the picks in the order the user gave (or oldest-first if they said "all"). Re-run the
98
98
  owning skill's normal verification before reporting each one done.
@@ -73,6 +73,12 @@ nodes:
73
73
  sb.Append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">");
74
74
  sb.Append("<title>" + E(title) + "</title><style>");
75
75
  sb.Append("*{margin:0;padding:0;box-sizing:border-box}");
76
+ // Scrollbars, themed GLOBALLY for both engines. The report is its own document inside the
77
+ // Viewer iframe, so web/app.css never reaches it: without this the page itself — and any
78
+ // container a later edit makes scrollable — falls back to the browser's own bar. Firefox
79
+ // reads only scrollbar-width/-color; Safari before 18.2 reads only the ::-webkit- block, so
80
+ // both halves are needed. Colours are slate-300/-400, the same ramp as this report's greys.
81
+ sb.Append("*{scrollbar-width:thin;scrollbar-color:#cbd5e1 transparent}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:4px}::-webkit-scrollbar-thumb:hover{background:#94a3b8}");
76
82
  sb.Append("body{font-family:-apple-system,'Segoe UI',Roboto,sans-serif;background:#f1f5f9;color:#0f172a;padding:2.5rem;line-height:1.6}");
77
83
  sb.Append(".wrap{max-width:760px;margin:0 auto;background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:2rem 2.25rem;box-shadow:0 10px 30px rgba(2,6,23,.06)}");
78
84
  sb.Append(".hd{border-bottom:2px solid #4a9eff;padding-bottom:1rem;margin-bottom:1.5rem}");
@@ -105,6 +105,12 @@ nodes:
105
105
  sb.Append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">");
106
106
  sb.Append("<title>Knowledge Base consulted</title><style>");
107
107
  sb.Append("*{margin:0;padding:0;box-sizing:border-box}");
108
+ // Scrollbars, themed GLOBALLY for both engines. The report is its own document inside the
109
+ // Viewer iframe, so web/app.css never reaches it: without this the page itself — and any
110
+ // container a later edit makes scrollable — falls back to the browser's own bar. Firefox
111
+ // reads only scrollbar-width/-color; Safari before 18.2 reads only the ::-webkit- block, so
112
+ // both halves are needed. Colours are slate-300/-400, the same ramp as this report's greys.
113
+ sb.Append("*{scrollbar-width:thin;scrollbar-color:#cbd5e1 transparent}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:4px}::-webkit-scrollbar-thumb:hover{background:#94a3b8}");
108
114
  sb.Append("body{font-family:-apple-system,'Segoe UI',Roboto,sans-serif;background:#f1f5f9;color:#0f172a;padding:2.5rem;line-height:1.6}");
109
115
  sb.Append(".wrap{max-width:760px;margin:0 auto;background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:2rem 2.25rem;box-shadow:0 10px 30px rgba(2,6,23,.06)}");
110
116
  sb.Append(".hd{border-bottom:2px solid #4a9eff;padding-bottom:1rem;margin-bottom:1.5rem}");
@@ -100,6 +100,12 @@ nodes:
100
100
  sb.Append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">");
101
101
  sb.Append("<title>Approved Workspace Project</title><style>");
102
102
  sb.Append("*{margin:0;padding:0;box-sizing:border-box}");
103
+ // Scrollbars, themed GLOBALLY for both engines. The report is its own document inside the
104
+ // Viewer iframe, so web/app.css never reaches it: without this the page itself — and any
105
+ // container a later edit makes scrollable — falls back to the browser's own bar. Firefox
106
+ // reads only scrollbar-width/-color; Safari before 18.2 reads only the ::-webkit- block, so
107
+ // both halves are needed. Colours are slate-300/-400, the same ramp as this report's greys.
108
+ sb.Append("*{scrollbar-width:thin;scrollbar-color:#cbd5e1 transparent}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:4px}::-webkit-scrollbar-thumb:hover{background:#94a3b8}");
103
109
  sb.Append("body{font-family:-apple-system,'Segoe UI',Roboto,sans-serif;background:#f1f5f9;color:#0f172a;padding:2.5rem;line-height:1.6}");
104
110
  sb.Append(".wrap{max-width:760px;margin:0 auto;background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:2rem 2.25rem;box-shadow:0 10px 30px rgba(2,6,23,.06)}");
105
111
  sb.Append(".hd{border-bottom:2px solid #4a9eff;padding-bottom:1rem;margin-bottom:1.5rem}");
@@ -153,6 +153,12 @@ nodes:
153
153
  sb.Append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">");
154
154
  sb.Append("<title>" + E(modelName) + " - BOM Phase " + phase + "</title><style>");
155
155
  sb.Append("*{margin:0;padding:0;box-sizing:border-box}body{font-family:-apple-system,'Segoe UI',Roboto,sans-serif;background:#0f172a;color:#e2e8f0;padding:2rem;line-height:1.6}.container{max-width:1200px;margin:0 auto}");
156
+ // Scrollbars, themed GLOBALLY for both engines. The report is its own document inside the
157
+ // Viewer iframe, so web/app.css never reaches it: without this the long table's wrapper and
158
+ // the page itself draw the browser's native LIGHT bar over a dark report. Firefox reads only
159
+ // scrollbar-width/-color; Safari before 18.2 reads only the ::-webkit- block — both halves
160
+ // are needed. Colours are this report's own slate tokens, no new hues.
161
+ sb.Append("*{scrollbar-width:thin;scrollbar-color:#334155 transparent}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#334155;border-radius:4px}::-webkit-scrollbar-thumb:hover{background:#64748b}");
156
162
  sb.Append(".report-header{border-bottom:2px solid #d946ef;padding-bottom:1rem;margin-bottom:2rem}.report-header h1{font-size:1.75rem;font-weight:700;color:#f8fafc}.report-header .subtitle{color:#94a3b8;font-size:.875rem;margin-top:.25rem}");
157
163
  sb.Append(".summary-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:1rem;margin-bottom:2rem}.card{background:#1e293b;border:1px solid #334155;border-radius:8px;padding:1.25rem}.card .label{font-size:.75rem;text-transform:uppercase;letter-spacing:.05em;color:#94a3b8;margin-bottom:.25rem}.card .value{font-size:1.5rem;font-weight:700;color:#f8fafc;font-family:Consolas,monospace}.card .value.accent{color:#d946ef}");
158
164
  sb.Append(".cat{margin-bottom:1.75rem}.cat h2{font-size:1rem;font-weight:700;color:#f8fafc;margin-bottom:.5rem;display:flex;align-items:baseline;gap:.5rem}.cat h2 .pill{font-size:.7rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:#0f172a;background:#d946ef;border-radius:999px;padding:.1rem .5rem}.cat h2 .sub{font-size:.8rem;font-weight:400;color:#94a3b8;font-family:Consolas,monospace;margin-left:auto}");
@@ -88,6 +88,12 @@ nodes:
88
88
 
89
89
  var sb = new StringBuilder();
90
90
  sb.Append("<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>PDF Takeoff</title><style>");
91
+ // Scrollbars, themed GLOBALLY for both engines. The report is its own document inside the
92
+ // Viewer iframe, so web/app.css never reaches it: without this the page itself — and any
93
+ // container a later edit makes scrollable — falls back to the browser's own bar. Firefox
94
+ // reads only scrollbar-width/-color; Safari before 18.2 reads only the ::-webkit- block, so
95
+ // both halves are needed. Colours are slate-300/-400, the same ramp as this report's greys.
96
+ sb.Append("*{scrollbar-width:thin;scrollbar-color:#cbd5e1 transparent}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:4px}::-webkit-scrollbar-thumb:hover{background:#94a3b8}");
91
97
  sb.Append("body{font-family:-apple-system,'Segoe UI',Roboto,sans-serif;background:#f1f5f9;color:#0f172a;padding:2.5rem;line-height:1.6}");
92
98
  sb.Append(".wrap{max-width:560px;margin:0 auto;background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:1.75rem 2rem;box-shadow:0 10px 30px rgba(2,6,23,.06)}");
93
99
  sb.Append("h1{font-size:1.5rem;font-weight:800;border-bottom:2px solid #4a9eff;padding-bottom:.75rem;margin-bottom:1.25rem}");
@@ -75,8 +75,18 @@ nodes:
75
75
  // hosted shared page alike. The "Made with FloLess" badge is injected by the
76
76
  // server (report-badge.ts) — never add it here. Accent is brand blue #3b82f6
77
77
  // (a selection report is general-purpose; fuchsia is bom-by-phase's phase hue).
78
+ // Scrollbars are themed GLOBALLY for both engines. The report is its own document inside the
79
+ // Viewer iframe, so web/app.css never reaches it: without this the wide table's wrapper and
80
+ // the page itself draw the browser's native LIGHT bar over a dark report. Firefox reads only
81
+ // scrollbar-width/-color; Safari before 18.2 reads only the ::-webkit- block — both halves
82
+ // are needed. Colours are this report's own slate tokens, no new hues.
78
83
  string css =
79
84
  "*{margin:0;padding:0;box-sizing:border-box}"
85
+ + "*{scrollbar-width:thin;scrollbar-color:#334155 transparent}"
86
+ + "::-webkit-scrollbar{width:8px;height:8px}"
87
+ + "::-webkit-scrollbar-track{background:transparent}"
88
+ + "::-webkit-scrollbar-thumb{background:#334155;border-radius:4px}"
89
+ + "::-webkit-scrollbar-thumb:hover{background:#64748b}"
80
90
  + "body{font-family:-apple-system,'Segoe UI',Roboto,sans-serif;background:#0f172a;color:#e2e8f0;padding:2rem;line-height:1.6}"
81
91
  + ".container{max-width:1200px;margin:0 auto}"
82
92
  + ".report-header{border-bottom:2px solid #3b82f6;padding-bottom:1rem;margin-bottom:2rem}"
@@ -90,8 +90,18 @@ nodes:
90
90
  // hosted shared page alike. The "Made with FloLess" badge is injected by the
91
91
  // server (report-badge.ts) — never add it here. Accent is brand blue #3b82f6
92
92
  // (a selection report is general-purpose; fuchsia is bom-by-phase's phase hue).
93
+ // Scrollbars are themed GLOBALLY for both engines. The report is its own document inside the
94
+ // Viewer iframe, so web/app.css never reaches it: without this the wide table's wrapper and
95
+ // the page itself draw the browser's native LIGHT bar over a dark report. Firefox reads only
96
+ // scrollbar-width/-color; Safari before 18.2 reads only the ::-webkit- block — both halves
97
+ // are needed. Colours are this report's own slate tokens, no new hues.
93
98
  string css =
94
99
  "*{margin:0;padding:0;box-sizing:border-box}"
100
+ + "*{scrollbar-width:thin;scrollbar-color:#334155 transparent}"
101
+ + "::-webkit-scrollbar{width:8px;height:8px}"
102
+ + "::-webkit-scrollbar-track{background:transparent}"
103
+ + "::-webkit-scrollbar-thumb{background:#334155;border-radius:4px}"
104
+ + "::-webkit-scrollbar-thumb:hover{background:#64748b}"
95
105
  + "body{font-family:-apple-system,'Segoe UI',Roboto,sans-serif;background:#0f172a;color:#e2e8f0;padding:2rem;line-height:1.6}"
96
106
  + ".container{max-width:1200px;margin:0 auto}"
97
107
  + ".report-header{border-bottom:2px solid #3b82f6;padding-bottom:1rem;margin-bottom:2rem}"
@@ -364,13 +364,11 @@
364
364
  return {
365
365
  start, resume, adopt, acknowledge, retryFailed, check,
366
366
  getState: () => state,
367
- getStoredTransaction: readStored,
368
367
  subscribe(listener) {
369
368
  listeners.add(listener);
370
369
  listener(state);
371
370
  return () => listeners.delete(listener);
372
371
  },
373
- cancelPolling() { generation += 1; },
374
372
  };
375
373
  }
376
374
 
package/dist/web/aware.js CHANGED
@@ -431,11 +431,6 @@
431
431
  : app.lock.present
432
432
  ? `<span class="cm"># ${escapeHtml(app.id)}.lock · node "${escapeHtml(n.id)}"</span>\n${escapeHtml(nodeYaml(n))}`
433
433
  : `<span class="cm"># not compiled</span>\nHit ⎙ Compile to freeze the .lock.`,
434
- // raw (unescaped) exec source for the Debug-in-VS handler; null for non-exec.
435
- _execSource: execSource,
436
- _execVersion: n.config && typeof n.config.version === 'string' ? n.config.version : null,
437
- _appId: app.id,
438
- _nodeId: n.id,
439
434
  execution: liveTrace,
440
435
  };
441
436
  }
@@ -6777,194 +6772,32 @@
6777
6772
  saveFavs = function saveFavsNoop() { $favCount.textContent = state.favorites.length; };
6778
6773
 
6779
6774
  // ── reverse channel: record intent for the host AI, copy a paste-ready line ──
6780
- function instructionFor(req) {
6781
- // `t.node` guarded, not assumed: a template saved by an older build (or hand-edited in
6782
- // templates.json) can carry a name and no node, and reading `.agent` off undefined THREW out of
6783
- // renderRequests' .map(), so `$list.innerHTML` was never assigned and loadRequests' `catch {}`
6784
- // ate it — the chip kept counting requests over a list that had silently stopped rendering.
6785
- if (req.type === 'use-template' && req.template) {
6786
- const t = req.template;
6787
- const n = t.node || {};
6788
- return `In floless app "${req.appId}", add a node from my saved template "${t.name}" (agent ${n.agent || n.kind || 'unspecified — read the template from GET /api/templates'}${n.command ? ' / ' + n.command : ''}, config ${JSON.stringify(n.config || {})}). Edit the .flo, then run \`aware app compile\`.`;
6789
- }
6790
- if (req.type === 'tweak') {
6791
- const base = `In floless app "${req.appId}", change only node "${req.nodeId}": ${req.instruction}. Edit just that node in the .flo, then run \`aware app compile\`.`;
6792
- return req.snapshots && req.snapshots.length
6793
- ? `${base}\nReference snapshots (read these for visual context): ${req.snapshots.join(', ')}`
6794
- : base;
6795
- }
6796
- if (req.type === 'ui-customize') {
6797
- const scope = req.panelId ? ` (panel "${req.panelId}")` : '';
6798
- return `Customize my floless.app dashboard${scope}: ${req.instruction}. Edit ~/.floless/ui/extensions.json per the floless-app-ui skill, then check it with \`aware agent invoke ui validate\`.`;
6799
- }
6800
- if (req.type === 'rebake') {
6801
- const where = req.inputName ? ` (input "${req.inputName}")` : '';
6802
- const snaps = req.snapshots && req.snapshots.length
6803
- ? `\nNew drawing${req.snapshots.length > 1 ? 's' : ''} (read for the re-extraction): ${req.snapshots.join(', ')}`
6804
- : '';
6805
- return `In floless app "${req.appId}", re-read & re-bake${where} per the floless-app-rebake skill: ${req.instruction}${snaps}`;
6806
- }
6807
- if (req.type === 'guide') {
6808
- return `Walk me through the floless workflow "${req.appId}" — explain in plain English what it does and how to run it (set its inputs → Compile → ▶ Run). Use your floless-app-${req.appId} skill if one exists; otherwise read the workflow's own description and node notes from GET /api/app/${req.appId} and explain from those. This is a guided explanation — don't change anything.`;
6809
- }
6810
- if (req.type === 'new-workflow') {
6811
- return `Help me build a brand-new floless workflow from scratch, step by step, with your floless-app-new-workflow skill. Ask me what I want it to do, then before writing any node confirm the agents it needs are installed (offer to install a missing one from the catalogue, or to report a not-yet-existing agent as an idea). Author the .flo node by node, verifying each step is correct (plain-English descriptions, validate, compile, a real run), and finish by installing → Compile → ▶ Run so I can see it work and approve.`;
6812
- }
6813
- if (req.type === 'revision-read') {
6814
- const isInitialRead = !req.baseVersion || req.baseVersion <= 0;
6815
- const snaps = req.snapshots && req.snapshots.length
6816
- ? `\n${isInitialRead ? 'Initial' : 'Revised'} drawing${req.snapshots.length > 1 ? 's' : ''} (read these): ${req.snapshots.join(', ')}`
6817
- : '';
6818
- const note = req.instruction ? `\nMy note: ${req.instruction}` : '';
6819
- const messageHint = isInitialRead ? '<plain-English what was read>' : '<plain-English what changed>';
6820
- const post = `Only after the review checkpoint is complete, POST /api/projects/${req.project}/revision-read with { contract, message: "${messageHint}", requestId: "${req.id}" }. The server derives the base version + source provenance from this queued request. For a steel.takeoff/v1 contract it records a "revision-read" version and clears the request. For a steel.model/v2 model it answers 202 and STAGES the read for the user to review instead — the request stays open until they confirm it in the app, and the version appears then. Either way, do NOT DELETE the request yourself. If you can't read the set, POST /api/projects/${req.project}/revision-requests/${req.id}/fail with { error }.`;
6821
- // App-aware: the target contract shape differs per workspace app. A vectorize project holds a
6822
- // drawing.vector/v1 (clean editable 2D linework), NOT a steel takeoff — instructing the AI to
6823
- // read steel members would produce the wrong contract for the vector editor (spec §3.3g).
6824
- // The lineage ROOT, not the live id: these branches encode what CONTRACT SHAPE the app's
6825
- // document has, and a rename moves the id off the built-in they are written against. Sending a
6826
- // renamed vector project down the steel branch asks the AI for a steel.takeoff/v1 — the wrong
6827
- // document entirely. Falls back to appId for an older server that ships no templateId.
6828
- if ((req.appTemplateId || req.appId) === 'vectorize') {
6829
- if (isInitialRead) {
6830
- return `In floless project "${req.project}" (app "${req.appId}"), an initial drawing was attached — trace it into this project as its first version (do NOT create a new project). Vectorize the drawing per the floless-app-vectorize skill into a drawing.vector/v1 contract: emit clean, editable 2D vector geometry (sheets → elements: lines / polylines / curves / text, each on its layer), NOT steel members or a takeoff. A vector PDF is read deterministically (exact geometry, no guessing); a photo, scan or hand sketch is traced by a fenced vision extraction that flags every uncertain stroke (low confidence) for the user's review. ${post}${snaps}${note}`;
6831
- }
6832
- return `In floless project "${req.project}" (app "${req.appId}"), a REVISED drawing was attached — re-read (vectorize) it into the SAME project as a new version (do NOT create a new project). Vectorize the drawing per the floless-app-vectorize skill into a drawing.vector/v1 contract: emit clean, editable 2D vector geometry (sheets → elements: lines / polylines / curves / text, each on its layer), NOT steel members or a takeoff. A vector PDF is read deterministically (exact geometry, no guessing); a photo, scan or hand sketch is traced by a fenced vision extraction that flags every uncertain stroke (low confidence) for the user's review. ${post}${snaps}${note}`;
6833
- }
6834
- // A MIGRATED project holds steel.model/v2, and that changes the document the AI must compose —
6835
- // not merely its wording. The store only accepts v2, so asking for a v1 take-off would have the
6836
- // whole read refused at the gateway AFTER it was done, which is the most expensive place to find
6837
- // out. `contractType` is what the store actually holds today (see requestContractType); it is
6838
- // absent on an older server, and absent falls through to the v1 branches below, unchanged.
6839
- //
6840
- // A revision-read against a v2 project is always a RE-read: v2 is reached by migrating a project
6841
- // that already held a model, so there is no "initial" case to distinguish. What differs from v1 is
6842
- // structural and is spelled out rather than left to be inferred, because every one of these is a
6843
- // place a v1-shaped answer would look plausible: members live at the document ROOT in world
6844
- // millimetres rather than per sheet in display pixels; ids are model-global, so the v1 rule
6845
- // "preserve the id AND its sheet label" does not apply and a bare id is the identity; an elevation
6846
- // the drawing does not give is `{ unknown: true }`, never a substituted default, because a
6847
- // fabricated elevation silently relocates steel; and what each SHEET showed is recorded as
6848
- // evidence on that plan's `memberObservations` instead of by owning the member.
6849
- if (req.contractType === 'steel.model/v2') {
6850
- return `In floless project "${req.project}" (app "${req.appId}"), a REVISED drawing set was attached — re-read it into the SAME project as a new version (do NOT create a new project). This project holds a steel.model/v2 model, so compose a steel.model/v2 document, NOT a steel.takeoff/v1: members live in ONE root \`members[]\` array in WORLD MILLIMETRES (each with \`from\`/\`to\` as { x, y, z }), not per sheet in display pixels. Member ids are MODEL-GLOBAL — preserve the id of every member the revision still shows and mint a new one only for a genuinely new member; there is no sheet label to preserve alongside it. Where the drawing does not give an elevation, write \`{ unknown: true }\` for that z — never a substituted default, because a fabricated elevation moves steel. Record what each SHEET actually showed as evidence on that plan's \`memberObservations\` (with its \`binding.memberIds\`), and use \`plans[].memberRefs\` for members a sheet displays but never observed. COPY THE CURRENT MODEL'S ROOT \`grid\` THROUGH UNCHANGED into the document you post to /revision-read — never omit the key, because omitting it is not how you say "unchanged" and a read that drops it is refused. If the revised set genuinely shows the printed grid in a NEW place, write the new grid there instead: it is staged as a proposal the user accepts in the review, never a silent write. (The pre-read verb below still refuses a grid — that is a different endpoint.) Follow the floless-app-steel-takeoff skill's mandatory two-phase gate exactly as for v1: FIRST GET /api/contract/${req.appId}?project=${req.project} to read the CURRENT model and KEEP its ETag, do the deterministic PyMuPDF steel-filter pass only, send ONLY the pre-read blocks to PUT /api/projects/${req.project}/steel-prepass with { filter } and If-Match: <that ETag> — never the whole contract — then STOP and tell me to open Drawings → Steel Filter, review the facets, and Save. Do NOT read members, build the model, open 3D, or POST /revision-read until I explicitly come back after saving the filter. ${post}${snaps}${note}`;
6851
- }
6852
- if (isInitialRead) {
6853
- return `In floless project "${req.project}" (app "${req.appId}"), an initial drawing set was attached — read it into this project as its first steel model version (do NOT create a new project). Follow the floless-app-steel-takeoff skill's mandatory two-phase gate. FIRST, GET /api/contract/${req.appId}?project=${req.project} and KEEP its ETag response header. A 404 "no contract for this app yet" here is NORMAL and not an error — a project created by dropping a drawing starts empty; it simply means this is the create case, so you will send If-None-Match: * instead of an ETag. (A project seeded from an existing model does return a contract and an ETag.) Then do the deterministic PyMuPDF steel-filter pass only: identify the framing-plan sheets, enumerate the drawing elements by layer/thickness/color into contract.filter.sheets/facets, write it back — if that GET returned NO contract this is the create case, so PUT the whole document to /api/contract/${req.appId}?project=${req.project} with If-None-Match: * ; if it DID return one, send only the pre-read blocks to PUT /api/projects/${req.project}/steel-prepass with { filter } and If-Match: <that ETag>. The prepass verb takes filter, datum and per-sheet { grid, datum_at, datum_ref, control2_at, control2_ref, elevation_in } and REFUSES members, connections and joints by name, so it cannot replace the model you are about to read. Either write is refused with 428 if it carries no precondition, and If-Match must be the exact ETag — If-Match: * is refused, because this verb patches the document you read. On 412 re-GET, re-apply your changes to the new document, and retry rather than repeating the same body. Then STOP and tell me to open Drawings → Steel Filter, review/narrow the steel facets, and Save. Do NOT read members, build the model, open 3D, or POST /revision-read until I explicitly come back after saving the filter. AFTER that saved-filter checkpoint, read members from the saved filter selection and compose the steel.takeoff/v1 contract. ${post}${snaps}${note}`;
6854
- }
6855
- return `In floless project "${req.project}" (app "${req.appId}"), a REVISED drawing set was attached — re-read it into the SAME project as a new version (do NOT create a new project). Follow the floless-app-steel-takeoff skill's mandatory two-phase gate. FIRST, GET /api/contract/${req.appId}?project=${req.project} to read the CURRENT contract, then do the deterministic PyMuPDF steel-filter pass only for the revised drawing set: identify the framing-plan sheets, enumerate drawing elements by layer/thickness/color into contract.filter.sheets/facets, preserve any compatible existing filter selections, send ONLY the pre-read blocks to PUT /api/projects/${req.project}/steel-prepass with { filter } and If-Match: <the ETag from the GET you just did> — never the whole contract, because this project already holds a model and a full PUT would replace its members without review. The verb takes filter, datum and per-sheet { grid, datum_at, datum_ref, control2_at, control2_ref, elevation_in } and refuses everything else by name. A write with no precondition is refused with 428, and If-Match must be the exact ETag — If-Match: * is refused, because this verb patches the document you read. On 412 re-GET, re-apply, and retry rather than repeating the same body. Then STOP and tell me to open Drawings → Steel Filter, review/narrow the steel facets, and Save. Do NOT read members, build the model, open 3D, or POST /revision-read until I explicitly come back after saving the filter. AFTER that saved-filter checkpoint, read members from the saved filter selection, compose the updated steel.takeoff/v1 contract, and PRESERVE each still-present member's id AND its sheet label (mint a NEW id only for a genuinely new member; drop the id of a member the revision deleted) so the version comparison matches members — do NOT renumber the whole model. ${post}${snaps}${note}`;
6856
- }
6857
- // The steel-model editor's "Ask AI" box, and the SAME channel its "insert a detail" flow uses.
6858
- // Deliberately does NOT name a contract shape: this channel serves both steel.takeoff/v1 and
6859
- // steel.model/v2 projects, and the stored document's own `type` is the authoritative answer the
6860
- // AI reads in the GET below. Naming a shape here would send a v2 project's edit at a v1 take-off
6861
- // — the same failure `contractType` exists to prevent on revision-read, solved one rung cheaper
6862
- // because this verb re-writes the document it just read rather than composing a new one.
6863
- if (req.type === 'tweak-contract') {
6864
- const where = req.project ? `?project=${req.project}` : '';
6865
- const scope = req.project ? `floless project "${req.project}" (app "${req.appId}")` : `floless app "${req.appId}"`;
6866
- // The insert flow carries a machine-readable intent + target so the AI creates a new detail
6867
- // rather than editing a placed one (or vice versa) — absent on an ordinary Ask AI request.
6868
- const detail = req.intent
6869
- ? `\nThis is an insert-a-detail request: intent "${req.intent}"${req.target && req.target.sheet ? ` on sheet "${req.target.sheet}"` : ''}${req.target && req.target.ids && req.target.ids.length ? `, target id(s) ${req.target.ids.join(', ')}` : ''}.`
6870
- : '';
6871
- const snaps = req.snapshots && req.snapshots.length
6872
- ? `\nScreenshot${req.snapshots.length > 1 ? 's' : ''} (read these — they show which member or region "this" means): ${req.snapshots.join(', ')}`
6873
- : '';
6874
- return `In ${scope}, edit the steel contract per the floless-app-tweak-contract skill: ${req.instruction || 'apply the requested change'}. ` +
6875
- `GET /api/contract/${req.appId}${where} first and KEEP its ETag — the document's own \`type\` tells you which shape you are editing, and you write back that SAME shape. ` +
6876
- `Apply the change, preserving every field you are not changing, then PUT the full document to /api/contract/${req.appId}${where} with If-Match: <that ETag> ` +
6877
- `(If-None-Match: * only when the GET returned no ETag at all). A blind write is refused with 428; on 412 re-GET, re-apply your edit to the NEW document, and retry rather than repeating the same body. ` +
6878
- `Writing a tweak is not approval — leave the approval gate to the user.${detail}${snaps}`;
6879
- }
6880
- // The Knowledge step's Organize verb. The lifecycle is SERVER-owned: start claims the organize
6881
- // lock and mints the generation dir; finish publishes it and clears this request; fail releases
6882
- // the lock. Naming the exact project-scoped routes matters — /api/requests/<id> is NOT the
6883
- // completion path here, and a stray DELETE would strand the lock until its stale timeout.
6884
- if (req.type === 'knowledge-organize') {
6885
- const kb = `/api/projects/${req.project}/knowledge`;
6886
- return `In floless project "${req.project}", organize the Project Knowledge Base with your floless-app-knowledge skill. ` +
6887
- `Claim the pass with POST ${kb}/requests/${req.id}/start — it takes the organize lock and returns { baseRevision, generationId, wikiDir }. ` +
6888
- `Read the source set from GET ${kb}/status (the rows it marks state:"organizing" ARE this pass's snapshot), read each source's bytes from that project's knowledge/blobs/<blobSha256>, ` +
6889
- `and compile the project wiki INTO the returned wikiDir — never invent a path. ` +
6890
- `Publish with POST ${kb}/requests/${req.id}/finish { generationId, lintSummary }; on any failure release the lock with POST ${kb}/requests/${req.id}/fail { error }. ` +
6891
- `Do NOT DELETE this request and do NOT use /api/requests/${req.id} — finish/fail resolves it server-side. ` +
6892
- `If finish returns { rerun: true } the sources changed mid-pass: POST ${kb}/organize once for a FRESH request, then run start → compile → finish on that new id exactly once.`;
6893
- }
6894
- // The KB "reshape it" box (its UI lands in a later slice; the verb + route already exist).
6895
- if (req.type === 'knowledge-adjust') {
6896
- return `In floless project "${req.project}", reshape the Project Knowledge Base with your floless-app-knowledge skill: ${req.instruction || 'apply the requested change'}. ` +
6897
- `Edit the project's wiki notes accordingly, then re-organize so the published generation reflects the change.`;
6898
- }
6899
- // No branch matched. Fall back to what the USER typed rather than to nothing.
6900
- //
6901
- // Every type in the union has an arm today — 'tweak-contract' was the last one missing and #629
6902
- // gave it one. This is the floor for the NEXT type added to FlolessRequest before its arm lands,
6903
- // because of what that gap cost last time: a blank row in the Requests window AND a
6904
- // markedInstruction() of '', so the ⧉ silently put nothing on the clipboard while still toasting
6905
- // success. The request was never empty — it carried a real instruction — it was just unreadable
6906
- // and uncopyable, which reads as noise worth deleting.
6907
- //
6908
- // A composed arm is strictly better (it tells the terminal AI the protocol, not just the wish),
6909
- // so this never competes with one: every arm above returns first. A type that legitimately
6910
- // carries no instruction still lands on '' here, and the row says so in words.
6911
- return req.instruction ? String(req.instruction).trim() : '';
6912
- }
6913
-
6914
- // Which product skill applies each request type (named in the copied marker so the
6915
- // terminal AI picks up the right one).
6916
- const REQUEST_SKILL = {
6917
- 'use-template': 'floless-app-workflows',
6918
- tweak: 'floless-app-workflows',
6919
- 'ui-customize': 'floless-app-ui',
6920
- 'tweak-contract': 'floless-app-tweak-contract',
6921
- rebake: 'floless-app-rebake',
6922
- 'revision-read': 'floless-app-steel-takeoff',
6923
- // The guided-tour ask is picked up by onboarding; the instruction body names the
6924
- // per-app floless-app-<appId> skill for depth when one exists.
6925
- guide: 'floless-app-onboarding',
6926
- // Build-a-workflow-from-scratch: its own guide skill (interview → author → verify).
6927
- 'new-workflow': 'floless-app-new-workflow',
6928
- // Project Knowledge Base: one self-contained skill drives both the organize lifecycle and adjusts.
6929
- 'knowledge-organize': 'floless-app-knowledge',
6930
- 'knowledge-adjust': 'floless-app-knowledge',
6931
- };
6932
-
6933
- // The COPIED form of a request: instructionFor() prefixed with a self-identifying
6934
- // marker so a PASTED request is unmistakable to the terminal AI — it's a queued FloLess
6935
- // Dashboard request to APPLY (via the named skill + the authoritative /api/requests),
6936
- // not a literal instruction to run verbatim (#73). The modal preview keeps the plain
6937
- // instructionFor() text; only the clipboard carries the marker.
6938
- function markedInstruction(req) {
6939
- const body = instructionFor(req);
6940
- if (!body) return '';
6941
- // revision-read's skill is app-specific: steel takeoff by default, floless-app-vectorize for a
6942
- // vector project — keep the clipboard marker in step with the app-aware instruction body above.
6943
- let skill = REQUEST_SKILL[req.type] || 'floless-app-workflows';
6944
- if (req.type === 'revision-read' && (req.appTemplateId || req.appId) === 'vectorize') skill = 'floless-app-vectorize';
6945
- const base = (typeof location !== 'undefined' && location.origin) ? location.origin : 'http://127.0.0.1:4317';
6946
- // A revision-read is cleared by its own /revision-read POST — a separate DELETE would 404. A
6947
- // knowledge-organize is likewise lifecycle-owned: its finish/fail POST clears it, and a stray
6948
- // DELETE would strand the organize lock until the stale timeout. Every other type is
6949
- // applied-then-DELETEd by the terminal AI.
6950
- const clears = req.type === 'revision-read'
6951
- ? ((req.appTemplateId || req.appId) === 'steel-model'
6952
- ? `apply it in two phases: first write the Steel Filter checkpoint through the steel-prepass verb and stop for user Save; only after that checkpoint use the route in the line below (that POST clears this request, or stages it for the user's review — either way do NOT DELETE it separately).`
6953
- : `apply it via the route in the line below (that POST clears this request — do NOT DELETE it separately).`)
6954
- : req.type === 'knowledge-organize'
6955
- ? `drive it through the start → finish/fail lifecycle routes in the line below (finish or fail clears this request — do NOT DELETE it separately, that would strand the organize lock).`
6956
- : `apply that request, then DELETE ${base}/api/requests/${req.id}.`;
6957
- const marker =
6958
- `[floless-request type=${req.type} id=${req.id}] — queued from the FloLess Dashboard. ` +
6959
- `Apply it with your ${skill} skill: fetch the authoritative spec from GET ${base}/api/requests, ` +
6960
- `${clears} Don't run the line below verbatim.`;
6961
- return `${marker}\n${body}`;
6962
- }
6775
+ //
6776
+ // The prompt is composed SERVER-side now — see server/request-instruction.ts — and every request
6777
+ // view arrives already carrying { prompt, marker }. What used to be ~180 lines of instructionFor()
6778
+ // / REQUEST_SKILL / markedInstruction() here are two ACCESSORS: the browser composes no request
6779
+ // text at all any more. That is the point, not a tidy-up — it is what lets #571s headless run
6780
+ // endpoint take only a request id instead of a caller-supplied prompt, on a server whose CORS hook
6781
+ // deliberately admits callers that send no Origin.
6782
+ //
6783
+ // Two fields joined here rather than one pre-joined server-side because use-template embeds an
6784
+ // unbounded JSON.stringify(node.config) (this repo has a known ~223 KB baked-blob node) and
6785
+ // /api/requests is POLLED — this keeps one copy of that on the wire per poll instead of two.
6786
+ // BOTH fields checked, not just `marker`. The server's invariant is that `marker` is '' exactly
6787
+ // when the body is — but gating on `marker` alone while interpolating `prompt` means a response
6788
+ // carrying one and not the other (an un-enriched route, a partial payload) composes
6789
+ // "[floless-request …]\nundefined": non-empty, so copyToClipboard succeeds and the green
6790
+ // "Copied — paste it to your terminal AI" fires, while the row beside it renders "this request has
6791
+ // no instruction". That is #629's exact signature re-armed one layer up, so the browser does not
6792
+ // lean on a server invariant it cannot see.
6793
+ const instructionFor = (req) => (req && req.prompt) || '';
6794
+ const markedInstruction = (req) => (req && req.marker && req.prompt) ? `${req.marker}\n${req.prompt}` : '';
6963
6795
 
6964
6796
  async function copyToClipboard(text) {
6965
6797
  // Nothing in this app ever legitimately copies an empty string — every caller passes a command
6966
6798
  // or an instruction body. An empty one means the caller has a hole (a request type with no
6967
- // instructionFor() arm returns '' from markedInstruction), and writing it would still resolve,
6799
+ // arm in server/request-instruction.ts composes an empty body, so the server sends no `marker`
6800
+ // and markedInstruction returns ''), and writing it would still resolve,
6968
6801
  // so the user gets a green "Copied" over an empty clipboard. Report the failure instead.
6969
6802
  if (!text) return false;
6970
6803
  try { await navigator.clipboard.writeText(text); return true; } catch { return false; }
@@ -7184,9 +7017,10 @@
7184
7017
  //
7185
7018
  // `r.instruction` — what the USER actually typed — is searched alongside the composed
7186
7019
  // instruction, not instead of it. The two usually overlap, but the composed body is only as
7187
- // complete as instructionFor()'s arms, and a request you can see but cannot find by the words
7188
- // you wrote in it is the worst kind of search. Same forward-looking floor as the fallback at the
7189
- // end of instructionFor(): keep this field even though every type has an arm today.
7020
+ // complete as the server builder's arms (server/request-instruction.ts), and a request you can
7021
+ // see but cannot find by the words you wrote in it is the worst kind of search. Same
7022
+ // forward-looking floor as the fallback at the end of ITS instructionFor(): keep this field even
7023
+ // though every type has an arm today.
7190
7024
  //
7191
7025
  // Both the NAME and the raw ids are searchable: you may know a project as "Cedar Mill Warehouse"
7192
7026
  // or as the `take-5-6677ee` in its URL, and either should find it.
@@ -7271,8 +7105,9 @@
7271
7105
  }
7272
7106
 
7273
7107
  // The Requests window: every queued change in a list, each copyable + clearable,
7274
- // plus copy-all / clear-all. instructionFor() output (which embeds file-derived
7275
- // appId/nodeId/instruction) is rendered via textContent-equivalent escaping.
7108
+ // plus copy-all / clear-all. The server-composed prompt (which embeds file-derived
7109
+ // appId/nodeId/instruction) is rendered via textContent-equivalent escaping — which matters MORE
7110
+ // now that the string arrives over the wire rather than being built from local state.
7276
7111
  function renderRequests() {
7277
7112
  const $list = document.getElementById('requests-list');
7278
7113
  const $clear = document.getElementById('requests-clear');
@@ -16,6 +16,83 @@ import { mmPerPx } from './grid-core.js';
16
16
  export const FT_TO_MM = 304.8;
17
17
  export const IN_TO_MM = 25.4;
18
18
 
19
+ /** @typedef {'I'|'C'|'L'|'TUBE'|'BOX'} SectionKind */
20
+
21
+ /**
22
+ * Steel families as literal designation PREFIXES, paired with the section kind each one draws as.
23
+ * Order here is presentation only — `sectionKindOf` picks the longest match, never the first — with one
24
+ * caveat worth stating because nothing in the loop enforces it: two entries carrying the SAME prefix can
25
+ * only tie, and the tie goes to the earlier one, so a duplicate added later is silently dead. That is the
26
+ * same unreachability this change set out to remove, just re-keyed from chain order to array order, so
27
+ * `section-kind.test.ts` checks the table for duplicates rather than trusting this paragraph.
28
+ *
29
+ * The annotation below is NOT enforcement either: this is a .js file and the server tsconfig runs
30
+ * `allowJs` without `checkJs`, so a typo'd entry (`['MC', 'c']`) or a malformed one still compiles —
31
+ * verified. `section-kind.test.ts` validates the table's shape for that reason.
32
+ *
33
+ * Tees (`WT`/`ST`/`MT`) deliberately carry no entry: there is no 'T' kind, so they ride their parent
34
+ * letter and draw as an I. That is the long-standing behaviour and is left exactly as it was — a tee
35
+ * outline is its own change, not part of the prefix-shadowing fix below. Note that ADDING a tee entry
36
+ * here WOULD silently take every `WT` away from 'I': "a new family cannot un-reach an existing one" is
37
+ * about each family's own prefix still matching, not about the designations it currently attracts.
38
+ *
39
+ * @type {ReadonlyArray<readonly [string, SectionKind]>}
40
+ */
41
+ export const SECTION_FAMILIES = [
42
+ ['W', 'I'], ['M', 'I'], ['S', 'I'], ['HP', 'I'], // US I-family
43
+ ['UC', 'I'], ['UB', 'I'], ['UKC', 'I'], ['UKB', 'I'], ['IPE', 'I'], ['HE', 'I'], // UK/EU I-family
44
+ ['C', 'C'], ['MC', 'C'], ['PFC', 'C'], // channels
45
+ ['L', 'L'], // angles
46
+ ['HSS', 'TUBE'], ['PIPE', 'TUBE'], ['TS', 'TUBE'], ['TUBE', 'TUBE'], ['HSQ', 'TUBE'],
47
+ ['SHS', 'TUBE'], ['RHS', 'TUBE'], ['CHS', 'TUBE'], // hollow sections
48
+ ];
49
+
50
+ /**
51
+ * Section shape KIND from a steel designation — the ONE classifier behind the 2D plan outline
52
+ * (`web/steel-editor.html` sectionShapePts), the 3D extrusion (`web/steel-3d-view.js` shapeOf) and
53
+ * the base-plate weld footprint (`server/steel-joints.ts` profileOutline). Each of those three used
54
+ * to carry its own copy of an ordered regex chain kept in step by a comment; this is the source they
55
+ * now share, so the copies cannot drift apart again.
56
+ *
57
+ * LONGEST PREFIX WINS, and that IS the fix rather than a matter of taste. The old chain tested a bare
58
+ * `M`, `S` and `C` inside earlier alternations, so a one-letter family silently swallowed a longer one
59
+ * three separate times — `M` ate `MC` (#647: an MC channel drew as a wide flange), `S` ate `SHS`, and
60
+ * `C` ate `CHS`, the last two leaving a closed hollow section classified as an open I or channel.
61
+ *
62
+ * In `steel-joints` that is not cosmetic, though the two tubes were hurt differently and it is worth
63
+ * being exact: an `SHS` answering 'I' reached the I-only estimate in `lapFaces` and BUILT a lap on a
64
+ * bearing face it does not have, whereas a `CHS` answering 'C' never entered that branch and so WAS
65
+ * refused — just as `bearing-face-unresolved` rather than the `closed-section-unsupported` it is owed,
66
+ * and with a channel traced as its weld outline. Reachability was a property of the whole chain's ORDER
67
+ * and so invisible while reading any single branch of it; matching on longest literal prefix removes the
68
+ * class, because adding a family can no longer un-reach one.
69
+ *
70
+ * WHAT THIS DOES NOT PROMISE. It matches a literal prefix, not a parsed designation, and several
71
+ * families are a single letter — so `STEEL` answers 'I', `CUSTOM` and `COL` answer 'C', and an `MC`
72
+ * written `M.C.18X58` answers 'I'. Only a designation with no KNOWN family prefix (`2L…`, `ZZ99`, '')
73
+ * reaches BOX. That is long-standing behaviour, unchanged here and not a regression, but do not read BOX
74
+ * as "we could not classify it" — this cannot currently say that, which is why `steel-joints` has no
75
+ * honest way to refuse an unrecognised designation. See #657.
76
+ *
77
+ * @param {unknown} profile
78
+ * @returns {SectionKind}
79
+ */
80
+ export function sectionKindOf(profile) {
81
+ const p = String(profile == null ? '' : profile).toUpperCase().trim();
82
+ /** @type {SectionKind} */
83
+ let kind = 'BOX';
84
+ let best = 0;
85
+ // No cast on `familyKind`: the table is annotated, so a bad entry is a problem at the table (where
86
+ // section-kind.test.ts checks for it) rather than something an assertion here quietly waves through.
87
+ for (const [prefix, familyKind] of SECTION_FAMILIES) {
88
+ if (prefix.length > best && p.startsWith(prefix)) {
89
+ best = prefix.length;
90
+ kind = familyKind;
91
+ }
92
+ }
93
+ return kind;
94
+ }
95
+
19
96
  /**
20
97
  * Clip a 3D segment against convex half-spaces. Each plane is
21
98
  * `{ normal:[x,y,z], constant }`, with points on the non-negative side kept.
@@ -19,7 +19,7 @@ import { OrbitControls } from 'three/addons/OrbitControls.js';
19
19
  import { RoomEnvironment } from 'three/addons/RoomEnvironment.js';
20
20
  import { surfaceTextures, applyTriplanar, TILE_MM, DIRECTIONAL } from './steel-materials.js';
21
21
  import { Brush, Evaluator, SUBTRACTION } from 'three-bvh-csg';
22
- import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, snapGridPoint, clipSegmentToPlanes, pointSegmentDistance2d, perspectiveSegmentParameter, gridDepthWins, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors } from './steel-3d-core.js';
22
+ import { snapPoint, planPointToWp, memberGeometry, snapElevation, dim3dGeom, dominantAxis3d, planeBasis, planeFrom3Points, frameFrom3Points, frameFromAngle, worldToLocal, identityFrame, resolvePointEntry, offsetsFor, candidateOnPlane, snapGridPoint, clipSegmentToPlanes, pointSegmentDistance2d, perspectiveSegmentParameter, gridDepthWins, segmentHitsRect2d, projectedFootprintHitsRect2d, pickGridLevel, selectedLengthLabelAnchors, sectionKindOf } from './steel-3d-core.js';
23
23
  // `gridGeometry`, `gridCandidates3d` and `mmPerPx` moved behind the host's model read half (unit 5, P7d):
24
24
  // each takes a `ptPerFt`, which is a v1 PLAN default and meaningless on a world-mm model grid.
25
25
  import { visibleGridLevels } from './grid-core.js';
@@ -378,12 +378,9 @@ function lengthAxisOf(el) {
378
378
  function shapeOf(el) {
379
379
  const explicit = (el.section && el.section.shape || '').toString().toUpperCase().trim();
380
380
  if (/^(I|C|L|TUBE|BOX)$/.test(explicit)) return explicit; // explicit section.shape override wins
381
- const p = ((el.meta && el.meta.profile) || '').toString().toUpperCase().trim();
382
- if (/^(W|M|S|HP|UC|UB|UKC|UKB|IPE|HE)/.test(p)) return 'I'; // wide-flange / I-section
383
- if (/^(C|MC|PFC)/.test(p)) return 'C'; // channel
384
- if (/^L/.test(p)) return 'L'; // angle
385
- if (/^(HSS|PIPE|TS|SHS|RHS|CHS|TUBE|HSQ)/.test(p)) return 'TUBE'; // hollow tube
386
- return 'BOX';
381
+ // The designation itself goes to the shared classifier (steel-3d-core.js), which the 2D plan outline
382
+ // and the base-plate weld also use. The copy that lived here drew MC channels as I-sections (#647).
383
+ return sectionKindOf((el.meta && el.meta.profile) || '');
387
384
  }
388
385
  // A real thickness off the element's `xsection` (AISC table / designation) when there is one and it fits
389
386
  // inside the section, else null so the caller keeps its estimate. The fit check matters: a metric