@floless/app 0.117.1 → 0.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +65 -9
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +63 -8
- package/dist/skills/floless-app-vectorize/SKILL.md +91 -29
- package/dist/skills/floless-app-vectorize/scripts/classify_and_trace.py +1039 -0
- package/dist/skills/floless-app-vectorize/scripts/rectify_and_trace.py +447 -0
- package/dist/skills/floless-app-vectorize/scripts/vision_to_contract.py +176 -9
- package/dist/skills/reading-structural-drawings/SKILL.md +35 -3
- package/dist/skills/steel-drawing-abbreviations/SKILL.md +1 -1
- package/dist/skills/steel-drawing-abbreviations/references/standard-us-abbreviations.md +5 -1
- package/dist/web/app.css +18 -6
- package/dist/web/app.js +244 -0
- package/dist/web/steel-3d-core.js +3 -3
- package/dist/web/steel-editor.html +20 -10
- package/dist/web/steel-filter-core.js +1 -1
- package/dist/web/vector-3d.html +33 -7
- package/dist/web/vector-editor.html +26 -2
- package/package.json +4 -2
package/dist/floless-server.cjs
CHANGED
|
@@ -54469,7 +54469,7 @@ function appVersion() {
|
|
|
54469
54469
|
return resolveVersion({
|
|
54470
54470
|
isSea: isSea2(),
|
|
54471
54471
|
sqVersionXml: readSqVersionXml(),
|
|
54472
|
-
define: true ? "0.
|
|
54472
|
+
define: true ? "0.118.0" : void 0,
|
|
54473
54473
|
pkgVersion: readPkgVersion()
|
|
54474
54474
|
});
|
|
54475
54475
|
}
|
|
@@ -54485,7 +54485,7 @@ function resolveChannel(s) {
|
|
|
54485
54485
|
function appChannel() {
|
|
54486
54486
|
return resolveChannel({
|
|
54487
54487
|
isSea: isSea2(),
|
|
54488
|
-
define: true ? "0.
|
|
54488
|
+
define: true ? "0.118.0" : void 0,
|
|
54489
54489
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
54490
54490
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
54491
54491
|
modulePath: process.argv[1]
|
|
@@ -73505,17 +73505,37 @@ function dedupeElements(elements) {
|
|
|
73505
73505
|
});
|
|
73506
73506
|
return out;
|
|
73507
73507
|
}
|
|
73508
|
+
var NEIGHBOUR_OFFSETS = [-1, 0, 1];
|
|
73508
73509
|
function snapEndpoints(elements, tol = 1) {
|
|
73509
73510
|
const reps = [];
|
|
73510
73511
|
const tol2 = tol * tol;
|
|
73512
|
+
const cell = Math.abs(tol) > 0 ? Math.abs(tol) : 1;
|
|
73513
|
+
const grid = /* @__PURE__ */ new Map();
|
|
73514
|
+
const key = (cx, cy) => `${cx},${cy}`;
|
|
73511
73515
|
const snap = (p) => {
|
|
73512
|
-
|
|
73513
|
-
|
|
73514
|
-
|
|
73515
|
-
|
|
73516
|
-
|
|
73516
|
+
const cx = Math.floor(p[0] / cell);
|
|
73517
|
+
const cy = Math.floor(p[1] / cell);
|
|
73518
|
+
let bestIdx = -1;
|
|
73519
|
+
for (const ox of NEIGHBOUR_OFFSETS) {
|
|
73520
|
+
for (const oy of NEIGHBOUR_OFFSETS) {
|
|
73521
|
+
const bucket2 = grid.get(key(cx + ox, cy + oy));
|
|
73522
|
+
if (!bucket2) continue;
|
|
73523
|
+
for (const idx of bucket2) {
|
|
73524
|
+
if (bestIdx !== -1 && idx > bestIdx) continue;
|
|
73525
|
+
const r = reps[idx];
|
|
73526
|
+
const dx = p[0] - r[0];
|
|
73527
|
+
const dy = p[1] - r[1];
|
|
73528
|
+
if (dx * dx + dy * dy <= tol2) bestIdx = idx;
|
|
73529
|
+
}
|
|
73530
|
+
}
|
|
73531
|
+
}
|
|
73532
|
+
if (bestIdx !== -1) return reps[bestIdx];
|
|
73517
73533
|
const rep = [p[0], p[1]];
|
|
73518
73534
|
reps.push(rep);
|
|
73535
|
+
const k = key(cx, cy);
|
|
73536
|
+
const bucket = grid.get(k);
|
|
73537
|
+
if (bucket) bucket.push(reps.length - 1);
|
|
73538
|
+
else grid.set(k, [reps.length - 1]);
|
|
73519
73539
|
return rep;
|
|
73520
73540
|
};
|
|
73521
73541
|
return elements.map((el) => {
|
|
@@ -74827,7 +74847,6 @@ function createExportCompanion(ownerId, sink, appsRoot = defaultAppsRoot()) {
|
|
|
74827
74847
|
const id = `${PREFIX}${safeOwner}-${sink}-${token}`;
|
|
74828
74848
|
const root4 = (0, import_node_path34.resolve)(appsRoot);
|
|
74829
74849
|
const path = (0, import_node_path34.resolve)(root4, id);
|
|
74830
|
-
const lease = { pid: process.pid, token, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
74831
74850
|
return {
|
|
74832
74851
|
id,
|
|
74833
74852
|
path,
|
|
@@ -78054,7 +78073,44 @@ async function maintenanceChildIdentity(pid) {
|
|
|
78054
78073
|
].join(";");
|
|
78055
78074
|
const { stdout } = await execFileAsync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
|
|
78056
78075
|
windowsHide: true,
|
|
78057
|
-
|
|
78076
|
+
// This is a ceiling for a HUNG PowerShell, not a latency budget — and 5 s was being used as
|
|
78077
|
+
// the latter. What it has to survive is `powershell.exe` STARTING, which we do not control and
|
|
78078
|
+
// which degrades badly on a busy machine. A machine is at its busiest exactly when an install
|
|
78079
|
+
// is running, so the old value failed precisely when it mattered.
|
|
78080
|
+
//
|
|
78081
|
+
// What was actually measured, both directions:
|
|
78082
|
+
// • Nominal cost here is small — ~300 ms idle, ~500 ms at 8-way concurrency, ~800 ms at
|
|
78083
|
+
// 16-way, on a healthy desktop. So 5 s is not tight in normal conditions, and raising it
|
|
78084
|
+
// costs nothing in the common case: this call still returns in well under a second.
|
|
78085
|
+
// • It nonetheless FIRED, on the GitHub Actions windows runner: seven identity tests in one
|
|
78086
|
+
// master run (`not ok 268/269/272/275/276/277/278`), every one
|
|
78087
|
+
// `Command failed: powershell.exe … killed: true, signal: 'SIGTERM'` — the timeout, not a
|
|
78088
|
+
// query error. The same commit had been green on its own branch run minutes earlier.
|
|
78089
|
+
// Reproduced locally by running this suite against three concurrent full-suite runs.
|
|
78090
|
+
// The gap between those two is the point: nominal cost tells you nothing about the tail, and
|
|
78091
|
+
// the tail is what a timeout exists for. 30 s is ~100x the nominal cost, which is the sort of
|
|
78092
|
+
// headroom a process-spawn ceiling wants.
|
|
78093
|
+
//
|
|
78094
|
+
// What the extra patience costs, per call site — NOT a blanket "it's free":
|
|
78095
|
+
// • The install paths (installAwareGlobal's spawn handler, and the sidecar identity calls in
|
|
78096
|
+
// index.ts) overlap a global npm install that itself takes tens of seconds, so there a
|
|
78097
|
+
// higher ceiling delays no user-visible work.
|
|
78098
|
+
// • `maintenanceChildMatches` is the exception: startup maintenance recovery calls it with
|
|
78099
|
+
// NO install running. It is background work — it neither holds an HTTP response nor
|
|
78100
|
+
// delays the listening socket — but a genuinely hung probe can now delay AWARE readiness
|
|
78101
|
+
// and hold the exclusive lifecycle lock ~25 s longer than before.
|
|
78102
|
+
// That bounded, exceptional delay is the right trade: the alternative is what we had, where a
|
|
78103
|
+
// merely SLOW machine made the probe report failure, `maintenanceChildMatches` returned false,
|
|
78104
|
+
// and the server concluded its own live installer was dead — which is what starts a second
|
|
78105
|
+
// concurrent global install. A late answer beats a confidently wrong one here.
|
|
78106
|
+
//
|
|
78107
|
+
// Deliberately NOT changed: a probe failure is still FATAL to the install
|
|
78108
|
+
// (`installAwareGlobal` catches it and calls `killTree`). The tempting fix — record "identity
|
|
78109
|
+
// unavailable" and carry on — WEAKENS the crash-recovery invariant, because without the
|
|
78110
|
+
// durable pid+start+exe triple the updater cannot tell its own installer from PID reuse. So
|
|
78111
|
+
// fatal-on-failure is kept and false failures are made much rarer instead; that is the narrow,
|
|
78112
|
+
// safe fix rather than a deferral.
|
|
78113
|
+
timeout: 3e4,
|
|
78058
78114
|
maxBuffer: 16384
|
|
78059
78115
|
});
|
|
78060
78116
|
const parsed = JSON.parse(stdout);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: floless-app-steel-takeoff
|
|
3
3
|
description: Read a structural steel drawing into an editable steel.takeoff/v1 contract in floless.app — the "Steel Takeoff" reader. Triggers on a pending floless `rebake` request for the `steel-model` app (queued from its "Re-read & re-bake ▸" button), or asks like "read this framing plan into a takeoff", "turn this structural drawing into a takeoff", "bake my drawing into steel-model", "extract members from this PDF". Teaches the host AI to READ a steel drawing (PDF/image) with its own vision at COMPOSE time, build a steel.takeoff/v1 contract (members + profiles + elevations + weights from AISC lookup), write it to the contract store, and hand control to the editor — no model in the run path, no API key.
|
|
4
4
|
metadata:
|
|
5
|
-
version: 0.
|
|
5
|
+
version: 0.13.0
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Steel Takeoff — read a drawing into a steel.takeoff/v1 contract
|
|
@@ -401,12 +401,25 @@ Same flat shape as the datum above — a point plus which intersection it is:
|
|
|
401
401
|
reversed-hand view). A datum point fixes translation only; it cannot correct orientation, and
|
|
402
402
|
registering such a sheet as if it were square would silently distort every member read from it.
|
|
403
403
|
- **Record the elevation the sheet CUTS as `plan.elevation_in`** (decimal inches, same convention as
|
|
404
|
-
`default_tos`) — read it off the drawing's level
|
|
405
|
-
|
|
404
|
+
`default_tos`) — read it off the drawing's stated level datum for that view (the level table, the
|
|
405
|
+
frame elevations, a section). Datum + elevation together place the sheet as a horizontal cut plane in
|
|
406
|
+
3D: datum fixes it in plan, elevation fixes it in height.
|
|
407
|
+
**Never take it from a T.O.S. callout on a level that varies.** Those are surface points, not the cut
|
|
408
|
+
plane, and picking one of them collapses exactly the distinction the next bullet draws. If no cut
|
|
409
|
+
elevation is stated for the view, omit `elevation_in` rather than inventing one from the steel.
|
|
406
410
|
- **`default_tos` is NOT the sheet's cut elevation** — it is the fallback top-of-steel applied to members
|
|
407
411
|
whose ends are blank. The two often carry the same number on a framing plan, which makes conflating
|
|
408
412
|
them easy and wrong: a plan can default its blank ends to one level while cutting at another. Author
|
|
409
413
|
both, independently.
|
|
414
|
+
- **A SLOPED level must NOT be given a `default_tos` at all.** A single fallback is a lie about a surface
|
|
415
|
+
that varies. Resolve the ends from the T.O. STEEL callouts instead (§2 step 9, "Cross-sheet sources"),
|
|
416
|
+
and leave `default_tos` absent.
|
|
417
|
+
**But absent is not the same as safe: `steel.takeoff/v1` has no "unknown" elevation.** A blank
|
|
418
|
+
`ends[].tos` falls back to `default_tos ?? 0`, so with the default correctly omitted an unresolved end
|
|
419
|
+
renders **silently at zero** — roof steel on the ground, flagged by nothing. On a sloped plan every end
|
|
420
|
+
must therefore carry an EXPLICIT `tos`; a member whose ends genuinely cannot be resolved goes to
|
|
421
|
+
`read_notes` and is **not emitted at all**. (Only `steel.model/v2` can say "unknown" out loud — there
|
|
422
|
+
the member is retained and the export refuses rather than substituting anything.)
|
|
410
423
|
- **Read the elevation off the drawing; always ASK for the datum.** The elevation is printed and can be
|
|
411
424
|
re-read later; which intersection the project calls 0,0 is the user's intent and cannot be recovered
|
|
412
425
|
after the fact.
|
|
@@ -542,8 +555,44 @@ Follow the methodology condensed here (full detail + every gotcha in
|
|
|
542
555
|
see §2b. (The editor ALSO auto-dedupes on load, and it **deletes**, not flags. Produce a clean
|
|
543
556
|
contract here; do not lean on it, and do not hand it a contract it will quietly prune.)
|
|
544
557
|
9. **Cross-sheet sources.** Frame Elevation sheets → moment-frame schedule (resolve `MF` marks),
|
|
545
|
-
level datums (Ground / Second Floor / Roof elevations).
|
|
546
|
-
|
|
558
|
+
level datums (Ground / Second Floor / Roof elevations). **Section views → levels that appear
|
|
559
|
+
NOWHERE else — always open them if the set has any.** See guidance spec §5 for what each sheet
|
|
560
|
+
gives you.
|
|
561
|
+
|
|
562
|
+
**T.O. STEEL callouts are WORKING POINTS, not per-zone stamps.** Search for them FIRST, before
|
|
563
|
+
reaching for any default: each one fixes top-of-steel at a known location, so every member framing
|
|
564
|
+
at that point sits at that elevation and the level lies on the surface the points define. Do NOT
|
|
565
|
+
look for "a callout in this bay" and give up when there isn't one — that leaves a whole roof
|
|
566
|
+
unresolved when the sheet in fact over-determines it. Instead:
|
|
567
|
+
- **Trace each leader to its real endpoint.** A T.O.S. leader usually lands on a **column point**,
|
|
568
|
+
not a beam. Where the members meeting that point belong to one continuous surface, the callout
|
|
569
|
+
fixes all of them at once — that is what makes it powerful. It does NOT license blind propagation:
|
|
570
|
+
stepped framing, a dropped bay, secondary steel and overlapping roof facets can all put different
|
|
571
|
+
elevations at one plan point. Propagate only to members you have shown share that surface, and
|
|
572
|
+
stop at anything the drawing separates (a step note, a level change, a seismic joint).
|
|
573
|
+
- **Tabulate `(location → value)` and let it tell you the surface.** Candidate shapes to TEST, not a
|
|
574
|
+
law to apply: flat; a function of ONE axis (a one-way slope); a general plane varying in both
|
|
575
|
+
(`z = ax + by + c`); several independent surfaces (separate structures, or facets meeting at a
|
|
576
|
+
ridge/valley); or stepped/warped/cambered, which no single fit describes. **Check the fit and
|
|
577
|
+
record the residuals** — a tight fit is evidence, a poor one means your surface model is wrong,
|
|
578
|
+
not that the drawing is. Callouts sharing a coordinate the surface does not vary along must agree;
|
|
579
|
+
if they disagree, you have the wrong shape.
|
|
580
|
+
- **Then read every remaining member off the surface — and be honest about how each value was got.**
|
|
581
|
+
A value INTERPOLATED between callouts that bracket it is sound. **EXTRAPOLATION past the outermost
|
|
582
|
+
callout is not**: allow it only within the same continuous surface facet, only for a short reach
|
|
583
|
+
compared with the callout spacing you fitted (a fraction of one bay, never a new bay), and only
|
|
584
|
+
when nothing in the drawing suggests the surface changes out there. Beyond that the elevation is
|
|
585
|
+
**unresolved — RFI it**; do not stretch the plane to cover the sheet.
|
|
586
|
+
- **Name the derived elevations in `read_notes`.** Neither contract has an elevation-provenance
|
|
587
|
+
field: v1 records only `tosDef:false` ("explicit"), and the confidence scorer reads ANY explicit
|
|
588
|
+
`tos` as "from a drawing callout" and awards the same high band whether you measured it or fitted
|
|
589
|
+
it; v2's `z` distinguishes only known from unknown. So the score will not tell the user which
|
|
590
|
+
elevations were read and which were derived — `read_notes` is the only place that distinction
|
|
591
|
+
survives, which is exactly why naming them there is mandatory, not optional.
|
|
592
|
+
- **A member crossing the fall gets a different `tos` at each end** (`ends[0]`/`ends[1]`) — never one
|
|
593
|
+
averaged value. In `steel.model/v2` this is `from.z`/`to.z`, which are independent by design.
|
|
594
|
+
- Every set states this differently — some on the plans, some only in a section, some with a slope
|
|
595
|
+
note. The invariant is the ORDER: find the callouts, fit the surface, then place members.
|
|
547
596
|
|
|
548
597
|
**Hard-won gotchas (from the guidance spec § 6 — do not skip these):**
|
|
549
598
|
- **Text is outlined, not real text.** `get_text()` returns almost nothing. Everything textual
|
|
@@ -664,8 +713,11 @@ grid, registered to its grid. It does **not** mean the plan owns a column *membe
|
|
|
664
713
|
once as a single continuous member, so most plans legitimately hold none.
|
|
665
714
|
|
|
666
715
|
**Emit a `read_notes` entry and NO member** when the end grids are absent from `plan.grid`, when no plan
|
|
667
|
-
resolves a column centre at an intersection, when the upper level is `VARIES`
|
|
668
|
-
|
|
716
|
+
resolves a column centre at an intersection, when the upper level is `VARIES` and the sheet's `T.O. STEEL`
|
|
717
|
+
callouts do not determine a surface over that bay (§2 step 9, "Cross-sheet sources" — fit the surface
|
|
718
|
+
from ALL the callouts before
|
|
719
|
+
concluding this; a missing callout in one bay is NOT the same as an undetermined level), or when the
|
|
720
|
+
topology is unsupported. An unplaceable brace **cannot** be a member
|
|
669
721
|
(`wp` is required), and an `rfi:true` member whose profile *does* resolve would still be counted in the
|
|
670
722
|
BOM. Key each note `brace:<id> — <reason>`, rebuild them from the source on **every** read (drop the ones
|
|
671
723
|
that have become resolvable — never carry a stale note forward), and **state them in the hand-off**
|
|
@@ -717,7 +769,10 @@ requires `filterMissing: false`.
|
|
|
717
769
|
higher zoom; re-run the `steel-detailer-us` lookup. **rfi — "unresolved mark MF…":** resolve it from the
|
|
718
770
|
Frame Elevation schedule (grid + level) → set the real profile, keep `mf: true`.
|
|
719
771
|
- **med — "resolved from the frame schedule (assumed)":** confirm the MF resolution against the schedule.
|
|
720
|
-
**med — "plan-default elevation":**
|
|
772
|
+
**med — "plan-default elevation":** resolve that member's ends and set `ends[].tos` with `tosDef:false` —
|
|
773
|
+
from a local T.O.S callout if it has one, otherwise from the surface the sheet's callouts define
|
|
774
|
+
(§2 step 9). "No callout on this member" is not the end of the search; only a surface the callouts
|
|
775
|
+
genuinely do not determine is, and that is a `read_notes` entry.
|
|
721
776
|
- **low — "duplicate":** delete the coincident member (or merge).
|
|
722
777
|
- Re-`POST …/score`. Stop when `meetsTarget`, or after **2 rounds with no score gain** (diminishing returns).
|
|
723
778
|
3. PUT the final contract (step 5). **Be honest if you stop below target** — report the score, the gap,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: floless-app-vectorize
|
|
3
|
-
description: Vectorize a drawing into an editable drawing.vector/v1 contract in floless.app — the "Vectorize" reader. Triggers on a pending floless `rebake` request for the `vectorize` app (queued from its "Re-read & re-bake ▸" button), or asks like "vectorize this PDF", "turn my sketch into clean CAD linework", "read this detail into vectors", "trace this photo", "make this drawing 3D". Teaches the host AI to read a drawing at COMPOSE time — a vector PDF via ONE deterministic PyMuPDF pass (no LLM), a scan/photo/hand sketch
|
|
3
|
+
description: Vectorize a drawing into an editable drawing.vector/v1 contract in floless.app — the "Vectorize" reader. Triggers on a pending floless `rebake` request for the `vectorize` app (queued from its "Re-read & re-bake ▸" button), or asks like "vectorize this PDF", "turn my sketch into clean CAD linework", "read this detail into vectors", "trace this photo", "make this drawing 3D". Teaches the host AI to read a drawing at COMPOSE time — a vector PDF via ONE deterministic PyMuPDF pass (no LLM), a scan/photo/hand sketch by MEASURING its ink with a deterministic OpenCV centerline tracer for geometry plus AWARE's fenced vision.extract for the text (schema-bound, cached) — emit the drawing.vector/v1 contract, PUT it to the contract store, and hand the 2D vector editor to the user; and, for a multi-view set (plan + elevation), to classify views, read datums, and declare entities so the server reconstructs a viewable 3D model.
|
|
4
4
|
metadata:
|
|
5
|
-
version: 0.
|
|
5
|
+
version: 0.6.0
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Vectorize — read a drawing into a drawing.vector/v1 contract
|
|
@@ -18,10 +18,15 @@ The drawing is read **at compose time**, by one of two paths:
|
|
|
18
18
|
|
|
19
19
|
- **Vector PDF → deterministic.** One PyMuPDF pass; the geometry is exact, extracted, never
|
|
20
20
|
guessed. No model, no API key.
|
|
21
|
-
- **Raster (scan/photo/sketch) →
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
- **Raster (scan/photo/sketch) → measured geometry + model text.** The linework is MEASURED
|
|
22
|
+
from the sheet's ink by a deterministic OpenCV centerline tracer (no model, no API key); the
|
|
23
|
+
labels are read by AWARE's fenced `vision.extract` — a FIXED schema + prompt + pinned model,
|
|
24
|
+
content-hash cached (same input → same JSON, no repeat model call). The split is measured,
|
|
25
|
+
not assumed: on a real framing plan the model scored centerline F1 **0.008** against the
|
|
26
|
+
sheet's own CAD geometry where the tracer scored **0.73**, and the tracer reads no text at
|
|
27
|
+
all. **The model never sets a LINEWORK coordinate.** It does place its own text: a label's
|
|
28
|
+
`bbox`/`origin` come from the model, remapped from its 0..1000 frame. Geometry never
|
|
29
|
+
does — and never from you eyeballing pixels either.
|
|
25
30
|
|
|
26
31
|
There is **no model in the run path** either way. The app ships with a tiny hard-coded
|
|
27
32
|
example; this skill is how the user's OWN drawing replaces it.
|
|
@@ -56,9 +61,10 @@ skills do.
|
|
|
56
61
|
|
|
57
62
|
Probe the file: a PDF whose pages return `page.get_drawings()` paths is a **vector PDF** →
|
|
58
63
|
step 3a (deterministic, always preferred). An image file, or a PDF with no vector paths (a
|
|
59
|
-
scan, a photo, a hand sketch) → step 3b (
|
|
60
|
-
coordinates** — fabricated geometry is worse than no geometry; the raster
|
|
61
|
-
extraction is fenced, cached
|
|
64
|
+
scan, a photo, a hand sketch) → step 3b (measure the ink, read the text). **Never trace pixels
|
|
65
|
+
by eye into made-up coordinates** — fabricated geometry is worse than no geometry; the raster
|
|
66
|
+
path exists so the geometry is MEASURED and the text extraction is fenced, cached and
|
|
67
|
+
confidence-flagged instead.
|
|
62
68
|
|
|
63
69
|
### 3a. Vector path — one deterministic PyMuPDF pass
|
|
64
70
|
|
|
@@ -95,15 +101,47 @@ above is the contract. Hard schema requirements the server enforces on PUT: `typ
|
|
|
95
101
|
dedupe, snap, or derive layers yourself — the server post-processes every read of this
|
|
96
102
|
contract type.
|
|
97
103
|
|
|
98
|
-
### 3b. Raster path —
|
|
104
|
+
### 3b. Raster path — CV measures the geometry, the model reads the text
|
|
105
|
+
|
|
106
|
+
**The split, and why.** On a raster the two readers fail in opposite directions, and that was
|
|
107
|
+
measured against a sheet's own CAD data rather than argued:
|
|
108
|
+
|
|
109
|
+
| | geometry (centerline F1) | text |
|
|
110
|
+
|---|---|---|
|
|
111
|
+
| `vision.extract` | **0.008** | reads labels correctly, incl. handwriting |
|
|
112
|
+
| OpenCV centerline tracer | **0.73** | produces none at all |
|
|
113
|
+
|
|
114
|
+
Those two numbers are **one sheet** (a 42x30 in framing plan, scored against its own CAD
|
|
115
|
+
geometry) at the tracer's default settings. They establish the DIRECTION decisively — three
|
|
116
|
+
orders of magnitude is not a tuning difference — not that 0.73 is what any given sheet will
|
|
117
|
+
score. Do not quote 0.73 to a user as this drawing's accuracy.
|
|
118
|
+
|
|
119
|
+
So **geometry comes from the tracer and text from the model.** Neither replaces the other.
|
|
120
|
+
The model never sets a LINEWORK coordinate; it does place its own text boxes.
|
|
99
121
|
|
|
100
122
|
For each raster image (or rasterized PDF page exported to an image):
|
|
101
123
|
|
|
102
|
-
1.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
124
|
+
1. **Measure the geometry.** No model, no API key, ~10–60 s depending on sheet size:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
python <skill dir>/scripts/classify_and_trace.py <image> --dpi <dpi> --out <scratch>/cv.json
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Needs `pip install opencv-python-headless numpy` (the converter in step 3 also needs
|
|
131
|
+
`pymupdf`). A `ModuleNotFoundError` here means those are missing — say so and install them;
|
|
132
|
+
do not fall back to eyeballing.
|
|
133
|
+
|
|
134
|
+
Pass the real `--dpi` (default 300). Every length the tracer uses is expressed in
|
|
135
|
+
millimetres and converted from it, so a wrong `--dpi` reads the sheet at the wrong physical
|
|
136
|
+
scale — glyph size, hatch spacing and the minimum stroke all move together. It masks
|
|
137
|
+
lettering, hatch and stamps FIRST, then centerlines only what remains — skeletonising
|
|
138
|
+
everything yields clean confident geometry through every letter, which is worse than
|
|
139
|
+
missing geometry because nobody can see it is wrong.
|
|
140
|
+
|
|
141
|
+
2. **Read the text.** Copy `references/vision-inputs.template.json` (beside this file) to a
|
|
142
|
+
scratch file and set **only** `"file"` to the image's absolute path. The `prompt`, `schema`
|
|
143
|
+
and pinned `model` are FIXED — with the file bytes they form the extraction's content-hash
|
|
144
|
+
cache key and its fence; do not tweak them per run.
|
|
107
145
|
|
|
108
146
|
```
|
|
109
147
|
aware agent invoke vision extract --inputs @<scratch>/vision-inputs.json --json > <scratch>/vision-out.json
|
|
@@ -111,19 +149,43 @@ For each raster image (or rasterized PDF page exported to an image):
|
|
|
111
149
|
|
|
112
150
|
A cache miss shells out to the local authenticated `claude`/`codex` CLI (no API key) and can
|
|
113
151
|
take a minute; a repeat of the same input replays from cache instantly. If neither CLI nor a
|
|
114
|
-
`vision-model` credential is available,
|
|
115
|
-
|
|
116
|
-
|
|
152
|
+
`vision-model` credential is available, **you still have geometry**: run step 3 with
|
|
153
|
+
`--geometry` and NO vision file (the positional is optional). The contract then carries the
|
|
154
|
+
measured linework, no text, and `extractor: opencv/…` so nothing implies a model was
|
|
155
|
+
involved. Tell the user the labels are missing and why.
|
|
156
|
+
|
|
157
|
+
3. **Combine into the contract.** `--geometry` takes the linework from the tracer and keeps only
|
|
158
|
+
the model's text:
|
|
117
159
|
|
|
118
160
|
```
|
|
119
|
-
python <skill dir>/scripts/vision_to_contract.py <scratch>/vision-out.json <image>
|
|
161
|
+
python <skill dir>/scripts/vision_to_contract.py <scratch>/vision-out.json <image> \
|
|
162
|
+
--geometry <scratch>/cv.json --out contract.json
|
|
120
163
|
```
|
|
121
164
|
|
|
122
|
-
For a multi-image set, run steps 1–3 per image and append with
|
|
123
|
-
`--
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
165
|
+
For a multi-image set, run steps 1–3 per image and append with `--merge-into contract.json`
|
|
166
|
+
instead of `--out`. The contract's `source.extractor` records both halves
|
|
167
|
+
(`opencv/centerline+vision.text@<model>`), which is what the editor reads to tell the user
|
|
168
|
+
honestly how the drawing was read.
|
|
169
|
+
|
|
170
|
+
4. **Sanity-check before PUT:** element count > 0, and the traced text matches what the drawing
|
|
171
|
+
actually says. A wildly wrong trace usually means the image is too low-contrast — say so
|
|
172
|
+
rather than shipping garbage.
|
|
173
|
+
|
|
174
|
+
**Two fallbacks, and they go opposite ways.**
|
|
175
|
+
|
|
176
|
+
- *No text* (vision CLI/credential missing, or the model returned nothing useful): run step 3
|
|
177
|
+
with `--geometry` and no vision file. Measured linework, no labels.
|
|
178
|
+
- *No usable geometry* (the tracer refuses with "found nothing" — a whiteboard photo, a badly
|
|
179
|
+
degraded fax): drop `--geometry` and the command is exactly what it was before this change,
|
|
180
|
+
geometry and text both from the model, `extractor: vision.extract@<model>`.
|
|
181
|
+
|
|
182
|
+
Say which path you used. `--ink-method otsu` selects the older global-threshold behaviour if the
|
|
183
|
+
local default misreads an unusual sheet; it finds less light linework.
|
|
184
|
+
|
|
185
|
+
**What this path does NOT yet do.** Element counts sit close to the capacity budget on a dense
|
|
186
|
+
sheet, and the geometry has not passed a held-out quality gate — it is measurably far better
|
|
187
|
+
than the model on geometry, which is not the same as proven good. Do not tell the user the
|
|
188
|
+
linework is verified.
|
|
127
189
|
|
|
128
190
|
### 3c. Multi-view pass — make a plan + elevation set 3D (optional)
|
|
129
191
|
|
|
@@ -230,11 +292,11 @@ DELETE http://localhost:<port>/api/requests/<id>
|
|
|
230
292
|
- **Compose-time only.** The drawing is read HERE, by the terminal AI, then PUT to the store.
|
|
231
293
|
Never add a runtime node that reads the drawing — `aware app validate` rejects it, and it
|
|
232
294
|
breaks determinism.
|
|
233
|
-
- **Deterministic first, fenced second, eyeballs never.** Vector geometry is extracted
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
reproducible.
|
|
295
|
+
- **Deterministic first, fenced second, eyeballs never.** Vector geometry is extracted exactly.
|
|
296
|
+
Raster **geometry** is MEASURED by the bundled tracer — deterministic, no model. Raster
|
|
297
|
+
**text** goes ONLY through `vision.extract` (fixed schema/prompt/model, cached,
|
|
298
|
+
confidence-flagged). Never hand-write coordinates you read off pixels yourself, and never
|
|
299
|
+
swap the fenced text path for your own vision — the fence is what makes it reproducible.
|
|
238
300
|
- **Thin-UI contract.** The browser recorded intent and the file path; the brain is the
|
|
239
301
|
terminal AI. The UI never reads the drawing and never writes the contract itself.
|
|
240
302
|
- **Stay in scope.** Producing and handing off the contract is the whole job — do not wire
|