@floless/app 0.85.0 → 0.86.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.
@@ -0,0 +1,111 @@
1
+ # Read an approved Workspace project's data from a workflow
2
+
3
+ A running `.flo` can read an **approved** Workspace project's data (its contract, and matching
4
+ versioned exports) through a FloLess-owned, AWARE-generic REST agent named **`floless-workspace`**.
5
+ AWARE stays extension-agnostic — it only sees a normal loopback REST agent; FloLess owns the
6
+ Workspace storage and the approval gate. Reference demo: `demos/floless-workspace-read/`.
7
+ Design: `docs/superpowers/specs/2026-07-06-workspaces-slice-6.5-workflow-data-seam-design.md`.
8
+
9
+ ## The agent
10
+
11
+ `floless-workspace` is written to `~/.aware/agents/floless-workspace/manifest.yaml` by the FloLess
12
+ server **at startup** (`server/workspace-agent-manifest.ts`, `transport.rest.base =
13
+ http://127.0.0.1:<PORT>`) — so a terminal-only `aware app run` depends on the FloLess server being
14
+ up. Two `mode: read` commands:
15
+
16
+ - **`list-approved`** — discover durable project ids (`app` optional query filter). Body:
17
+ `{ ok, projects: [{ id, name, app, currentApprovedAt, latestApprovedVersion }] }`.
18
+ - **`read-approved`** — one project's signed snapshot. Path param `project-id`; query `app` (guard —
19
+ mismatch 404), `version` (pin; omit = latest approved), `include` (`contract` default, `exports`
20
+ opt-in), `export-kind`, `export-contents`, `include-paths`, `max-bytes`.
21
+
22
+ ```yaml
23
+ nodes:
24
+ - id: project
25
+ agent: floless-workspace
26
+ command: read-approved
27
+ mode: read
28
+ config:
29
+ project-id: "{{ inputs.project_id }}"
30
+ include: contract
31
+ ```
32
+
33
+ ## Output shape — REST returns `{ status, headers, body }`, NO `.result` wrapper — VERIFIED
34
+
35
+ Unlike an exec node (whose return is wrapped under `.result`), an AWARE REST agent's output is
36
+ `{ status, headers, body }` at top level. Downstream nodes read **`{{ project.body.* }}`** and
37
+ **`{{ project.status }}`** — e.g. `{{ project.body.project.name }}`, `{{ project.body.version.n }}`,
38
+ `{{ project.body.contract.type }}`. Body on success:
39
+
40
+ ```
41
+ { ok, project:{ id, name, app, currentApprovedAt, dirtySinceApproval },
42
+ version:{ n, ts, gate, kind, contractHash },
43
+ contract:{…}, exports?:[…] }
44
+ ```
45
+
46
+ Authorization is from the version **ledger approve row** (`gate:"model"`, `kind:"approve"`), never
47
+ the mutable `approvedAt`. Default resolves the latest approve row; `version=<n>` pins one (**404** if
48
+ `<n>` is not an approve row, e.g. an unsigned `revision-read`). A later draft edit clears `approvedAt`
49
+ but the seam still returns the last **approved** snapshot and flags `dirtySinceApproval:true` — drafts
50
+ never leak. Status codes: `404` unknown/app-mismatch/version-not-approved, `409` no approved version /
51
+ stale-or-missing requested export, `400` malformed id/query, `413` export over `max-bytes`.
52
+
53
+ ## GOTCHA — a non-2xx read aborts the run under strict templating — VERIFIED (AWARE 0.87)
54
+
55
+ A `404`/`409` returns a body **without** `project`/`version`/`contract`. AWARE's template engine
56
+ (minijinja) is **strict on undefined attribute access and has no rescue**: `{{ project.body.project.name }}`
57
+ errors the **whole run** (`template render: undefined value`) when the read failed. `| default('')`
58
+ does **not** save a mid-chain undefined, and the **`tojson` filter is unknown**. So a single report
59
+ node **cannot** both reference success-only fields (`body.project.*`) and render an error card from
60
+ the error body — the missing fields blow up templating before the node's own code runs.
61
+
62
+ ## PATTERN — gate the branch on `status == 200` (AWARE has no conditional branch)
63
+
64
+ AWARE has no `when:`/conditional-branch primitive (`assert` evaluates against an **empty** context, so
65
+ it can't see upstream data). Use an **`inline` predicate** node evaluated against the read node's
66
+ output — it passes the output through on `true`, or **`Gated`**-stops the branch on `false` (a clean
67
+ `run-end: ok`, no report, no cryptic error, never a fake success). This is the explicit non-2xx check:
68
+
69
+ ```yaml
70
+ - id: gate
71
+ inline:
72
+ kind: predicate
73
+ description: Continue only when the seam returned HTTP 200 (an approved snapshot was found).
74
+ code: "e.status == 200" # `e` is the upstream (read) node's output
75
+ # then: project → gate → report ; report references {{ project.body.* }} safely
76
+ ```
77
+
78
+ (A predicate returns a bool and can't reshape data — `kind: shape`/`map` are rejected; see the main
79
+ skill's inline-node note. `e.<field>` is the upstream event, not `inputs.<field>`.)
80
+
81
+ ## Let the user PICK the project — `widget: workspace-project` — VERIFIED
82
+
83
+ Declaring an input `widget: workspace-project` (on a `type: string` input) makes the **Set inputs ▸**
84
+ dialog render a **themed approved-project picker** — a searchable dropdown listing every approved
85
+ project by **name** (`Name` + `App · vN` meta) — instead of a raw text box. The value stored/sent is
86
+ the opaque **project id**; the combo only displays a friendly label. It is a **client-only UI hint**
87
+ (never sent to `aware`, so AWARE stays extension-agnostic — same convention as `widget: file`).
88
+
89
+ ```yaml
90
+ inputs:
91
+ project_id:
92
+ type: string
93
+ widget: workspace-project # renders the approved-project picker in Set Inputs
94
+ # workspaceApp: steel-model # optional: pre-filter to one app; omit = all apps
95
+ description: Approved Workspace project to read.
96
+ ```
97
+
98
+ Empty state (zero approved projects): the trigger is disabled ("Approve a project first") with an
99
+ inline note pointing to Workspaces — the rest of the Set Inputs form stays usable. Implemented as a
100
+ `select` field type in `formModal` (`web/aware.js`) reusing the `.wf-combo/.wf-popover/.wf-option`
101
+ language; `openInputsDialog` fetches `GET /api/workspace-projects/approved` once on open.
102
+
103
+ ## Server seams (where this lives)
104
+
105
+ - `server/workspace-data.ts` — the routes (`GET /api/workspace-projects/approved`,
106
+ `/:projectId/approved`); query parsing; export-receipt matching.
107
+ - `server/workspace-approved-snapshot.ts` — `currentApprovedSnapshot(id, version?)`: resolves the
108
+ ledger approve row and reads that version's contract. Shared by the seam AND the project export routes.
109
+ - `server/workspace-agent-manifest.ts` — writes the `floless-workspace` manifest at startup.
110
+ - `server/project-export-receipts.ts` — `projects/<id>/exports/index.json`; exports are exposed only
111
+ when their receipt matches the selected approved version + contract hash.
@@ -2,7 +2,7 @@
2
2
  name: reading-structural-drawings
3
3
  description: This skill should be used BEFORE modelling anything from a structural/architectural drawing SET (PDF). Use it whenever turning drawings into a 3D frame, takeoff, IFC, or Tekla model — it is the prerequisite reading discipline for the `floless-app-steel-takeoff` reader (and the `floless-app-steel-model` guide that orchestrates the full flow). Triggers on "read this drawing set", "model this structure from the PDF", "take off this steel", "build a model from these drawings", or any pure-PDF → structure task. It encodes the method that stops the classic failures (missing that a set is TWO buildings, missing a curved/sloped roof, conflating grids across sheets, tracing dimension lines as members) — establish MASSING + COORDINATE FRAME first (from the index + elevations + sections), members LAST; deterministic geometry feeds the reasoning; cross-validate every view; verify before presenting.
4
4
  metadata:
5
- version: 0.1.2
5
+ version: 0.2.0
6
6
  ---
7
7
 
8
8
  # Reading a structural drawing set — the discipline (do this BEFORE you model anything)
@@ -26,6 +26,101 @@ ELEVATIONS and SECTIONS — read those before the framing plans.** (A real failu
26
26
  from: a set was modelled as one straight box from the plans; it was actually two separate buildings,
27
27
  one with a curved roof — both obvious in the elevations, invisible in the plan.)
28
28
 
29
+ ## Never fabricate geometry — extract it, or RFI it (the second mistake to never repeat)
30
+
31
+ The vector linework is ground truth; your judgement binds LABELS to it, it does not INVENT geometry.
32
+
33
+ - **Never hand-place a member/column/grid at coordinates you made up** (including "sensible" guesses
34
+ like putting columns at beam-endpoint clusters). If it isn't backed by drawn linework, it does not
35
+ go in. (Real failure: 8 columns invented at fake positions instead of the ~20 real ones sitting in
36
+ the `S-COLS-STEL` linework — which cluster out cleanly and, being on the shared grid xref, stack
37
+ across every story.)
38
+ - **Grids FIRST as the common frame; reuse the real detector, never re-port it.** In floless that
39
+ detector is `web/grid-core.js` `gridFromDrawing` (bubble-anchored, impostor-rejecting, reads
40
+ labels). A naive re-implementation produces sign-flipped spacings and phantom bays — don't.
41
+ - **RFI is a LAST RESORT — read the WHOLE set before you RFI anything.** The set is the source of
42
+ truth; a value absent from one sheet is NOT an RFI. A column's size is almost never on the framing
43
+ plan — it lives in the **COLUMN SCHEDULE** (a table keyed by mark/grid, on a foundation/general/
44
+ schedule sheet), or in **sections/details** through the column, or the **general notes** ("ALL COLS
45
+ HSS… UON"). GO READ THOSE and match by grid mark before you call it unknown. Same for heights (frame
46
+ elevations/level datums), `MF`/`BF`, materials, connection details. **A lazy RFI is the same sin as a
47
+ fabricated number** — both are shortcuts on the source of truth. Never fabricate to avoid an RFI, and
48
+ never RFI to avoid opening another sheet; RFI ONLY the values that are genuinely nowhere in the set,
49
+ and cite which sheet each resolved value came from.
50
+ - **Discriminate structure from annotation by CAD LAYER — not every extracted line is a member.** The
51
+ layer name (`get_drawings`/OCG layer, or the filter element's `layer`) tells you what a line IS. But
52
+ **which layer is which is a property of the set, not a fact you may assume.** Beam layers carry gravity
53
+ beams; bracing layers carry *bracing members*; the annotation layers carry the designation and
54
+ connection **symbols** (moment-frame, braced-frame, drag, stiffener, deck-span marks) that merely ride
55
+ an existing member. **Census a layer before you classify it** (see "Symbols mean what THIS set's legend
56
+ says", below) — a layer that holds only member-scale strokes and their end glyphs is a member layer,
57
+ whatever its name suggested. **Never drop a layer you have not censused:** dropping a member layer
58
+ deletes every member on it, silently, and no downstream check will notice.
59
+ **Never assign a symbol a size** (copying the nearest beam's label onto a designation symbol is
60
+ fabrication) and never keep a symbol as a member (it becomes phantom 3D geometry). Likewise a
61
+ **legend / notes glyph** (the bar inside an "INDICATES …" legend symbol) lands on a member layer but
62
+ sits in the title/notes block — reject it by position.
63
+ When a REAL beam shows only a frame mark (`MF`/`BF`-style) instead of a size, that's the extractor
64
+ grabbing the mark: read the size label (it sits on/above the beam line), and if it is genuinely not on
65
+ the plan, it is **section-defined** — flag it with the `n/S-3xx` section or brace-frame detail it
66
+ references, don't guess.
67
+ - **VECTORIZE the overlay.** When the PDF is vector (the normal case), the on-screen overlay you model
68
+ against must be the **vector linework** (crisp, snappable, measurable) — the same paths
69
+ `get_drawings()` returns — NOT a rasterized JPEG. A raster overlay on a vector PDF is a defect: it's
70
+ blurry and you can't snap or measure to it. Raster is only for genuinely scanned/raster-only sheets.
71
+ The same applies to the **linked detail/section sheets a callout points to** — extract each referenced
72
+ sheet to vector SVG (e.g. PyMuPDF `get_svg_image`, strip the embedded raster) so the callout opens crisp.
73
+
74
+ ## Symbols mean what THIS set's legend says — never a remembered mapping
75
+
76
+ A framing plan draws several things as "a line with marks on its ends", and they are not the same kind
77
+ of object. Getting one wrong silently deletes or invents whole classes of member. **Read the sheet's own
78
+ legend / PLAN NOTES block first, and bind every line symbol to the meaning it declares there.** Do not
79
+ carry a symbol→meaning mapping from another set, another firm, or memory — including from this skill.
80
+
81
+ - **A mark drawn ON an existing member is usually annotation** (a connection, a stiffener, a stud count,
82
+ a deck span). It rides a member that is already there.
83
+ - **A symbol drawn as its OWN line, spanning between two members, is usually a member** (a kicker, a
84
+ brace, a strut) — even when the legend describes it with a phrase like "indicates …". Beware the
85
+ exceptions: dimension lines, extent/span arrows and match-line marks are also free-standing.
86
+ - The two are easy to confuse because both render as a short line with end glyphs. No single signal
87
+ settles it. **Corroborate four:** the **legend** (authoritative), the **source layer**, the **topology**
88
+ (does it ride a member or span between two?), and the **scale/position** (a legend glyph sits in the
89
+ notes block, not the framing area). Where they disagree, the legend wins and the rest is evidence.
90
+ - **Census a layer's contents before you decide what it is** — count how many of its elements are
91
+ member-scale strokes vs tiny end-glyph fills. A layer that is *nothing but* long strokes and their
92
+ arrowheads holds members, whatever its name implied. Layer names are a per-firm CAD-template choice,
93
+ and blocks can inherit a parent's layer — so a census is evidence, not proof.
94
+
95
+ **Before dropping any layer, prove what is on it.** "This layer is only annotation" is a claim about the
96
+ set in front of you, and it is cheap to check and expensive to get wrong: dropping a member layer loses
97
+ every member on it and no test will ever notice.
98
+
99
+ ### Bracing may be documented in more than one view — find out which, per set
100
+
101
+ - **Lateral / kicker bracing** (a member that braces a beam) is *typically* drawn in plan, as its own
102
+ line between two beams.
103
+ - **Frame bracing** (the diagonal X / chevron / K / single diagonal that braces a bay) is *typically*
104
+ drawn in the **frame elevations**, and appears in plan — if at all — as a *mark* saying the bay is
105
+ braced. **A plan with no diagonal does not mean the frame is unbraced.** Open the brace-frame
106
+ elevations before concluding anything about bracing. Some sets do the opposite; the set decides, not
107
+ this list.
108
+ - To place a frame brace on a plan you must *derive* it: take **topology, levels, sizes and grid refs
109
+ from the elevation**, and take the **geometry from the plan** — an elevation coordinate must never
110
+ become plan geometry, because the two views are drawn at different scales.
111
+ **Where the work-points come from depends on the topology.** A full-bay diagonal or X terminates at
112
+ the bay's corners, so its plan work-points are the column centre-lines at those grids. A chevron,
113
+ inverted-V, K or multi-panel frame has **intermediate** work-points (mid-span of a beam, a panel
114
+ point) that are *not* on a column line — derive those from the elevation's own work-point/member-line
115
+ information registered onto the plan's frame plane, or record it as unresolved. Never force a
116
+ topology onto column centres because that is the easy case.
117
+
118
+ ### A member that spans two levels belongs to exactly ONE view
119
+
120
+ A column running through a floor, and a frame brace spanning storey to storey, each appear on more than
121
+ one plan. Emit each **once**, on one owning view, and say which. Emitting it on both is the classic way
122
+ to double the tonnage in a take-off while every individual sheet still looks right.
123
+
29
124
  ## Tools — use the deterministic layer; the AI interprets, never measures
30
125
 
31
126
  - **Render/extract with PyMuPDF (`fitz`)** — prefer it over `pdftoppm` (which may not be installed).
@@ -109,6 +204,12 @@ Only then build the scene / overlay / IFC. If unsure, present the **massing + gr
109
204
  - [ ] Member crossing a matchline read as terminating or double-counted.
110
205
  - [ ] Mezzanine / intermediate level missed (only sections show it).
111
206
  - [ ] Sizes scaled off the PDF instead of read from dimensions/schedule.
207
+ - [ ] A symbol's meaning assumed from memory instead of read from **this** set's legend.
208
+ - [ ] A whole layer dropped as "annotation" without censusing what is actually on it.
209
+ - [ ] Frame bracing declared absent because the plan shows no diagonal (it's in the elevations).
210
+ - [ ] A member spanning two levels emitted on both plans (doubles the tonnage).
211
+ - [ ] A size left as an RFI when the set does show it — a lazy RFI is as wrong as a fabricated number.
212
+ - [ ] A built-up shape (double angle, etc.) taken off as its single component (half the steel).
112
213
 
113
214
  ## Companion skills
114
215
  - After this reading produces a verified structure, hand to the **`floless-app-steel-takeoff`** reader
@@ -2,7 +2,7 @@
2
2
  name: steel-drawing-abbreviations
3
3
  description: Default legend of standard US (AISC, imperial) structural-steel drawing abbreviations, note conventions, and shape designations — the fallback meaning when a drawing set omits or only partially supplies its own abbreviations/legend sheet. This skill should be used while reading a structural steel drawing whenever an abbreviation, note code, or profile designation needs expanding (TYP, TOS, UON, EQ, (E)/(N), SIM, HSS, WT, and so on), or when the steel reader (floless-app-steel-takeoff / floless-app-steel-model) meets a note or label whose meaning is not defined on the supplied sheets. The project's own legend always overrides these defaults.
4
4
  metadata:
5
- version: "0.1.0"
5
+ version: "0.2.0"
6
6
  ---
7
7
 
8
8
  # Steel drawing abbreviations — default legend
@@ -46,6 +46,38 @@ warning). Keep this SKILL.md lean; load the reference when an actual lookup is n
46
46
  legend and the region-specific detailer agent (`steel-detailer-eu` / `steel-detailer-uk`); the
47
47
  shape designations especially differ.
48
48
 
49
+ ## Built-up shapes — a word in the callout changes the designation
50
+
51
+ A detail rarely spells the AISC key. It writes English, and the English carries the multiplicity:
52
+
53
+ | Callout reads | Means | Trap |
54
+ |---|---|---|
55
+ | `DOUBLE L4x4x3/8`, `(2) L4x4x3/8`, `2-L4x4x3/8` | a **double angle** → the `2L4X4X3/8…` family | Taking it off as the single `L4X4X3/8` books **half the steel**. |
56
+ | `L4x4x3/8 LLV` / `LLH` | one angle; `LLV`/`LLH` is leg orientation | Not part of the shape key — but it *is* part of a double angle's identity. |
57
+ | `W12x26 w/ PL …` | a `W12X26` **plus** a separate plate part | The plate is its own item, not a different beam. |
58
+
59
+ **"Double" is multiplicity, not yet a lookup key.** The AISC EDI designation for a double angle
60
+ (`2L…`) also encodes the **back-to-back spacing**, and for unequal legs the **orientation** (long legs
61
+ back-to-back or short) — the shapes database carries several `2L` entries per component angle, one per
62
+ spacing. So: read the spacing/orientation off the detail, form the exact key, and **look it up**. Never
63
+ double a single shape's weight by hand, and never guess the spacing.
64
+
65
+ *(Do not assume a `2`-prefixed family exists for every shape. Double angles are a standard EDI family;
66
+ most other "two of these" callouts are simply two separate members. Check the table, don't invent a key.)*
67
+
68
+ **The trailing number is the weight only for `W`/`S`/`M`/`HP`/`C`/`MC`/`WT`/`ST`/`MT`.** Elsewhere it
69
+ is a dimension: for `HSS` the wall thickness, for `L` the leg thickness, and for `PIPE` the nominal
70
+ outside diameter (with `STD`/`XS`/`XXS` naming the schedule, e.g. `Pipe6STD`). `HSS6X6X3/8` weighs
71
+ 27.48 lb/ft, not 0.375. Never read a weight off a designation; look it up.
72
+
73
+ ## Line symbols on a framing plan are NOT part of this glossary
74
+
75
+ A plan's `PLAN NOTES` block defines what each drawn line symbol means (which end-glyph marks a moment
76
+ connection, a braced-frame connection, a drag connection, a stiffener, a deck span, a lateral brace).
77
+ **Those meanings vary between firms and sets. Read the sheet's own legend; never assume a mapping** —
78
+ including from this file, which deliberately does not offer one. Getting a line symbol wrong deletes or
79
+ invents members, which no downstream check will catch.
80
+
49
81
  ## Companion skills
50
82
 
51
83
  - **`reading-structural-drawings`** — the reading discipline; its Pass 0 (inventory & legend) consults
@@ -0,0 +1,161 @@
1
+ app: floless-workspace-read
2
+ version: 0.1.0
3
+ display-name: Read Approved Workspace Project
4
+ description: |
5
+ Reads an approved FloLess Workspace project's data inside a running workflow and
6
+ renders it as a styled HTML report — the reference demo for the Workspaces →
7
+ Workflows data seam (Slice 6.5).
8
+
9
+ Give it a durable Workspace project id. The first node calls the local
10
+ `floless-workspace` REST agent's `read-approved` command, which returns the
11
+ project's signed, approved snapshot (never an unapproved draft): project name,
12
+ app, approved version number, approval timestamp, and the approved contract type.
13
+ The second node checks the HTTP status first — if the read failed it renders an
14
+ explicit error report instead of pretending it worked — and on success builds a
15
+ small HTML summary the in-app viewer shows on double-click.
16
+
17
+ No Tekla model is required: the report node runs on the host bridge with nothing
18
+ open. It proves a `.flo` can consume approved Workspace evidence through a real
19
+ AWARE node without the web UI composing the workflow and without teaching AWARE
20
+ what a FloLess Workspace is.
21
+ exposes-as-agent: false
22
+ inputs:
23
+ project_id:
24
+ type: string
25
+ default: ""
26
+ widget: workspace-project # client-only UI hint: render the approved-project picker instead of a text box (never sent to aware)
27
+ description: Approved Workspace project to read.
28
+ requires:
29
+ - floless-workspace@0.1.x
30
+ - tekla@0.1.x
31
+ layout: linear
32
+ nodes:
33
+ # ── node 1: read the approved project snapshot through the loopback REST seam ──
34
+ # Calls floless-workspace/read-approved. AWARE's REST transport returns
35
+ # { status, headers, body }, so downstream nodes read project.body.* — the body
36
+ # carries { ok, project, version, contract } for the latest approved version.
37
+ - id: project
38
+ agent: floless-workspace
39
+ command: read-approved
40
+ mode: read
41
+ config:
42
+ project-id: "{{ inputs.project_id }}"
43
+ include: contract
44
+ # ── node 2: gate — only continue when the read succeeded (HTTP 200) ──
45
+ # AWARE has no conditional branch, and its templating errors if a downstream node
46
+ # references a field that is absent on a non-2xx body. This predicate stops the run
47
+ # cleanly on a failed/unapproved read instead of letting the report node blow up on
48
+ # a missing field — so a bad read never masquerades as a rendered success report.
49
+ - id: gate
50
+ inline:
51
+ kind: predicate
52
+ description: Continue to the report only when the seam returned HTTP 200 — i.e. an approved snapshot was found.
53
+ code: "e.status == 200"
54
+ # ── node 3: render the approved snapshot as a report (terminal node) ──
55
+ - id: report
56
+ agent: tekla
57
+ command: exec
58
+ mode: read
59
+ config:
60
+ version: "2026.0"
61
+ args:
62
+ status: "{{ project.status }}"
63
+ ok: "{{ project.body.ok }}"
64
+ pid: "{{ project.body.project.id }}"
65
+ pname: "{{ project.body.project.name }}"
66
+ papp: "{{ project.body.project.app }}"
67
+ version_n: "{{ project.body.version.n }}"
68
+ approved_at: "{{ project.body.project.currentApprovedAt }}"
69
+ dirty: "{{ project.body.project.dirtySinceApproval }}"
70
+ ctype: "{{ project.body.contract.type }}"
71
+ chash: "{{ project.body.version.contractHash }}"
72
+ code: |
73
+ // Report — turns the approved Workspace snapshot read by the previous node
74
+ // into a styled HTML report the in-app viewer renders. It checks the HTTP
75
+ // status first: any non-200 (or ok != true) renders a plain error card so a
76
+ // failed read never masquerades as success. Touches no Tekla model, so it runs
77
+ // with nothing open. Manual HTML-escape (no System.Net available here).
78
+ using System;
79
+ using System.IO;
80
+ using System.Text;
81
+
82
+ Func<string,string> A = k => (args != null && args.TryGetValue(k, out var v) && v != null) ? v.ToString() : "";
83
+ Func<string,string> E = s => (s ?? "").Replace("&","&amp;").Replace("<","&lt;").Replace(">","&gt;").Replace("\"","&quot;");
84
+
85
+ string status = A("status");
86
+ string ok = A("ok");
87
+ bool good = status == "200" && (ok.Equals("true", StringComparison.OrdinalIgnoreCase) || ok == "True");
88
+
89
+ string pname = A("pname"), papp = A("papp"), pid = A("pid");
90
+ string versionN = A("version_n"), approvedAt = A("approved_at"), dirty = A("dirty");
91
+ string ctype = A("ctype"), chash = A("chash");
92
+ // Tidy the two values whose source can be null/bool (minijinja renders those as
93
+ // "none"/"true"): a dirty project has no current approvedAt — show an em dash, not "none".
94
+ if (approvedAt == "none" || approvedAt == "") approvedAt = "—";
95
+ string dirtyText = (dirty.Equals("true", StringComparison.OrdinalIgnoreCase) || dirty == "1") ? "Yes" : "No";
96
+ string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
97
+
98
+ var sb = new StringBuilder();
99
+ sb.Append("<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\">");
100
+ sb.Append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">");
101
+ sb.Append("<title>Approved Workspace Project</title><style>");
102
+ sb.Append("*{margin:0;padding:0;box-sizing:border-box}");
103
+ sb.Append("body{font-family:-apple-system,'Segoe UI',Roboto,sans-serif;background:#f1f5f9;color:#0f172a;padding:2.5rem;line-height:1.6}");
104
+ 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
+ sb.Append(".hd{border-bottom:2px solid #4a9eff;padding-bottom:1rem;margin-bottom:1.5rem}");
106
+ sb.Append(".hd h1{font-size:1.6rem;font-weight:800}");
107
+ sb.Append(".hd p{color:#64748b;font-size:.85rem;margin-top:.3rem}");
108
+ sb.Append(".cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:.85rem;margin-bottom:1.75rem}");
109
+ sb.Append(".card{background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;padding:.9rem 1rem}");
110
+ sb.Append(".card .l{font-size:.68rem;text-transform:uppercase;letter-spacing:.05em;color:#94a3b8}");
111
+ sb.Append(".card .v{font-size:1.15rem;font-weight:700;margin-top:.15rem}");
112
+ sb.Append("table{width:100%;border-collapse:collapse;font-size:.9rem;margin-top:.25rem}");
113
+ sb.Append("th,td{text-align:left;padding:.6rem .75rem;border-bottom:1px solid #eef2f7}");
114
+ sb.Append("th{font-size:.7rem;text-transform:uppercase;letter-spacing:.05em;color:#94a3b8}");
115
+ sb.Append("td:first-child{font-weight:600;color:#334155;width:34%}");
116
+ sb.Append(".err{background:#fef2f2;border:1px solid #fecaca;color:#991b1b;border-radius:8px;padding:1rem 1.15rem;font-size:.9rem}");
117
+ sb.Append(".ft{margin-top:1.75rem;padding-top:1rem;border-top:1px solid #eef2f7;color:#94a3b8;font-size:.78rem;text-align:center}");
118
+ sb.Append("</style></head><body><div class=\"wrap\">");
119
+
120
+ if (!good)
121
+ {
122
+ sb.Append("<div class=\"hd\"><h1>Could not read the approved project</h1>");
123
+ sb.Append("<p>The Workspace data seam did not return an approved snapshot.</p></div>");
124
+ sb.Append("<div class=\"err\">HTTP status <b>" + E(status) + "</b>");
125
+ sb.Append(" &middot; ok=<b>" + E(ok) + "</b>. ");
126
+ sb.Append("Check that the project id exists and has an approved (signed-off) version.</div>");
127
+ sb.Append("<div class=\"ft\">Generated by FloLess &middot; " + E(now) + "</div>");
128
+ sb.Append("</div></body></html>");
129
+ return new { ok = false, status, html = sb.ToString() };
130
+ }
131
+
132
+ sb.Append("<div class=\"hd\"><h1>" + E(pname) + "</h1>");
133
+ sb.Append("<p>Approved Workspace snapshot read live by a workflow &middot; " + E(now) + "</p></div>");
134
+ sb.Append("<div class=\"cards\">");
135
+ sb.Append("<div class=\"card\"><div class=\"l\">App</div><div class=\"v\">" + E(papp) + "</div></div>");
136
+ sb.Append("<div class=\"card\"><div class=\"l\">Approved version</div><div class=\"v\">v" + E(versionN) + "</div></div>");
137
+ sb.Append("<div class=\"card\"><div class=\"l\">Contract type</div><div class=\"v\">" + E(ctype) + "</div></div>");
138
+ sb.Append("</div>");
139
+ sb.Append("<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>");
140
+ sb.Append("<tr><td>Project id</td><td>" + E(pid) + "</td></tr>");
141
+ sb.Append("<tr><td>Approved at</td><td>" + E(approvedAt) + "</td></tr>");
142
+ sb.Append("<tr><td>Dirty since approval</td><td>" + E(dirtyText) + "</td></tr>");
143
+ sb.Append("<tr><td>Contract hash</td><td>" + E(chash) + "</td></tr>");
144
+ sb.Append("</tbody></table>");
145
+ sb.Append("<div class=\"ft\">Read through the floless-workspace seam &middot; approved data only</div>");
146
+ sb.Append("</div></body></html>");
147
+
148
+ string html = sb.ToString();
149
+
150
+ // Save a copy so the viewer's Open file / Reveal buttons have a real file.
151
+ string savedPath = null;
152
+ try {
153
+ var outPath = Path.Combine(Path.GetTempPath(), "floless-workspace-read.html");
154
+ File.WriteAllText(outPath, html);
155
+ savedPath = outPath;
156
+ } catch { savedPath = null; }
157
+
158
+ return new { ok = true, status, project_name = pname, html, saved_path = savedPath };
159
+ connections:
160
+ - { from: project, to: gate }
161
+ - { from: gate, to: report }