17 Commits

Author SHA1 Message Date
NiJingzhe 56f6fba13f feat(inspect): render inspect.brep with the software renderer; drop VTK
Entity-map callouts re-anchor onto their own geometry when occluded; the
VTK dependency, worker process and xvfb steps are gone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 02:00:42 +08:00
NiJingzhe a452f10daf fix(render): close the supersample temp handle before vtkPNGWriter writes
Fixes #32. _write_window_supersampled held a NamedTemporaryFile handle open
while vtkPNGWriter opened the same path — Windows denies the second open,
so every default-supersample screenshot failed there (POSIX masked it). The
temp frame is now created with mkstemp, the handle closed before VTK runs,
and the file unlinked in a finally so render failures no longer leak
'.*-ssNx-*' siblings. Covered by new regression tests (downsample+cleanup
happy path, failure cleanup) that fail on the old form.
2026-09-27 00:47:26 +08:00
NiJingzhe c72bc5e610 refactor: remove re-mode viewer; studio lives in sca-web-editor
The standalone viewer/ React app (scene viewer + re-mode) and its case
server tests are deleted; the studio product now lives in the separate
sca-web-editor workspace runtime. Docs/updates refreshed accordingly;
pyproject picks up marimo/plotly used by the notebook tooling.
2026-09-26 23:06:12 +08:00
NiJingzhe eb2f2c08d3 feat(addon): runtime state outside the payload + 'sca addon check'
- per-addon runtime dirs (~/.sca/runtimes/<name>), created at install,
  untouched by update, removed with the addon; {runtime_dir} placeholder
  in command_prefix and check_cmd alongside {addon_dir}
- 'sca addon check [name]': re-probe the installed runtime NOW and
  refresh the cached registry record (install-time probe is a cache,
  not truth); list shows cached state with its timestamp
- sca addon use exports SCA_RUNTIME_DIR for self-locating provisioning
- update replaces the payload wholesale but preserves a legacy in-payload
  .venv (pre-runtime_dir addons keep working)
- remove: records without runtime_dir delete nothing extra — never
  interpret the missing field as Path('') == CWD (regression test pins
  the exact failure that motivated this guard)
- docs: Payload vs runtime state section, check verb, updated examples
- version 2.1.3b4
2026-09-17 05:18:43 +08:00
NiJingzhe 6dc9fee702 feat(viewer): re-studio React 19 + shadcn rebuild with composer fixes
- remode UI migrated to React 19 + Tailwind 4 + shadcn-style components
  (tabs/toggles/tooltips/resizable/sonner); imperative kernel (SceneView,
  TokenComposer, OpSuggest, PythonEditor, FeatureTreeView) bridged via refs
- composer: same op tip can be cited twice (dedupe guard removed; backspace
  deletes the exact chip); capsule hover bubble is content-sized with a
  560px/72vw max width
- renderer: shift+left-drag pan via TrackballControls keyState borrow
- server: submit payload never truncates user entity selections (cap
  removed, regression test added)
- shared style.css imported into a cascade layer so Tailwind utilities win
2026-09-07 02:29:20 +08:00
NiJingzhe fb1e1f4182 Merge remote-tracking branch 'cadir/dev' into bugfix/connector-interface-hash 2026-09-06 18:30:49 +08:00
NiJingzhe 4be52a66c4 fix(placement): integer-tick canonical identity for all hashed frames
Float frames re-normalized on every Placement reconstruction, so
canonical JSON bytes and content hashes drifted across save/load cycles
(connector interface_hash mismatch, unstable PartInstance placement
identity, spurious cache/dirty misses).

Store every hashed/persisted frame as exact integer ticks at 1e-9
resolution instead:

- placement.py: placement_ticks / validate_placement_ticks (pure integer
  unit-orthogonal-handedness checks) / placement_from_canonical with a
  from_exact_frame constructor that keeps durable components verbatim;
  tick frames short-circuit re-quantization; placement_frame_mm exports
  millimetre floats for translators
- ConnectorInterface.local_frame and PartInstance.placement store ticks;
  definition content hashes are byte-stable across round trips
- solved snapshots, authored placements, assembly state, solve keys and
  component cache payloads compare tick-to-tick; rebuilds reuse
  from_exact_frame so verification is exact instead of tolerance-based
- occurrence-graph transforms and scene product ingestion convert ticks
  at the runtime boundary only
- FreeCAD runtime and Fusion360/SolidWorks translators convert recorded
  tick frames back to millimetre floats when emitting target payloads

Derived z_axis is authoritative (computed once at write time) and is
never recomputed on read. BREP/zip/package integrity checks remain
strict byte hashes. Existing pre-tick packages must be recaptured;
examples/22_mecanum_wheel was rebuilt and revalidated.
2026-09-06 18:30:16 +08:00
NiJingzhe ec4bb31ae8 feat(viewer): submission context gains per-entity neighborhood cards; op registry 7 categories
- runtime.entity_neighborhood: one-level adjacency cards (face→edges with
  adjacent faces + vertices; edge→vertices/faces/adjacent edges; vertex→
  edges/faces), truncated lists name their totals
- compose_submission passes BRepModel.adjacency_details into the context
- scene_build tags edges with seam/degenerate flags and meshes edges at a
  finer tolerance (lin 0.1 / ang 0.1)
- operation registry: boolean.md split into union/cut/intersect; new
  box/cylinder/cone/sphere/shell/mirror/twisted_sweep/helical_sweep docs
  (5 → 7 categories, 23 operations)
- tests: seam flags, neighborhood cards per entity kind, registry shape
2026-09-06 02:32:49 +08:00
NiJingzhe 22d19263a7 feat(viewer): re-studio free-form composer with entity/op tags, highlighted source, feature DAG
- composer: contenteditable input where viewport picks and operation tips
  land as atomic colored chips ([face:6](face:6) / [fillet](op:fillet)),
  peers of free text; IME-safe Enter (composition never submits);
  atomic chip backspace; plain-text paste
- operation tips are markdown content, not code: viewer/server/operations/
  <op_id>.md (frontmatter label/category/api/reads/doc_refs + hint body),
  loaded by a stdlib frontmatter parser with mtime cache; broken files are
  named in payload errors, never silently skipped
- five categories per the human's classification (sketch / solid / modify /
  surface / pattern); palette rendered from GET /api/operations
- compose_submission embeds operation_context for every referenced op
- SOURCE tab: read-only CodeMirror python view (PythonEditor extracted from
  SourceDock, shared extensions) with file tabs and line-range reveal
- FEATURE TREE: viewer's DAG algorithm extracted as FeatureTreeView
  (apply_tag hidden, REF/USED/IN badges); clicking a feature switches to
  SOURCE and highlights its source span; FTC-header fallback before the
  first captured package
- tests: registry load + broken-file naming + operation context (9 pass)
2026-09-05 03:10:36 +08:00
NiJingzhe e5ed7b547e feat(viewer): reverse-engineering studio — human-annotated STEP reconstruction loop
Interactive re-mode (re.html) plus a local case server implementing the
ppt-master handshake: the human selects faces / draws regions / labels intent
on the original STEP, the browser composes a submission with server-side
entity context, and a waiting agent reconstructs per the existing
reconstruction contract and writes artifacts the UI polls back.

- viewer/server (stdlib-only): STEP -> synthesized Scene 2.0 projection
  (GLB + entity sidecars, same shape as package scenes), region resolve
  (centroid projection + front-facing filter), entity descriptors,
  atomic submissions, ndjson side recording, --daemon/--wait/--wait-only/
  --shutdown CLI with lockfile and 590s budget
- viewer/src: extract shared cad-three/entity-facts modules (main.ts now
  consumes them), new SceneView class (assembly/picking/highlight) reused
  by both studio viewports
- re-mode UI: annotation canvas (circle/lasso), intent palette, context
  preview, submit flow, rebuilt v3 package loading, comparison image,
  feature tree, evaluation tab
- governance: only the browser writes submission.json; UI never edits
  geometry — code stays the single source of truth
- tests: 6 server tests (scene contract, region math, submission context
  + named failures, wait handshake exit codes, HTTP endpoints)
2026-09-05 00:30:46 +08:00
NiJingzhe a5e6bf8eb6 feat(core)!: QL-only topology enumeration — remove bare getter list form
Plural topology getters (get_edges/get_faces/get_wires/get_vertices/
get_solids/get_inner_wires/get_edge_occurrences and the Compound
variants) now accept ONLY an index. The no-argument list form raises a
SimpleCADError with migration guidance (enumerate via
ql.<kind>().resolve(shape), pick via get_X(index)). This closes the
selection channel that escapes the graph: Python loops over bare lists
lose the predicate, capture kernel artifacts (the periodic-face seam
edges that broke FCStd translation), and leave no cardinality contract.

- each shape class keeps its enumeration logic as private _iter_<kind>();
  indexed picks record geo-select nodes as before (contract test added);
  Compound getters gain the same indexed recording they lacked
- _TopologySelectionList (the __getitem__ recording vehicle, which also
  made get_X()[i] a silent escape hatch) is retired
- all 109 internal call sites, 165 test call sites, and 31 example call
  sites migrated: SDK/tests use the private channel, user-facing
  examples use ql.<kind>().resolve(...)
- QL _resolve_scope_items switches to the private channel; scene
  contract profile descriptions synced; error strings recommending
  bracket indexing rewritten
- skill docs: strict prohibition added to SKILL.md global rules (new
  rule 6), core README contract statement rewritten, solid/wire/face/
  shell/tagged_mixin pages re-exemplified with QL, geometric-validation
  anti-pattern section updated; mirrors rebuilt via tools/skillbuild.py

Gates: full suite 1418 passed / 5 skipped; translator suites 133 passed;
u_link stage verifiers + render check ALL PASS; scadpkg->FCStd
retranslation verified (5 visible deliverables, 167-object editable
tree).
2026-09-01 02:09:29 +08:00
Ni Jingzhe c454a3af10 feat(skill): per-harness skillbuild toolchain replaces skill-pack (#18)
* feat(skill): replace skill-pack with per-harness conditional compiler

skillbuild compiles the skill tree into per-target harness builds:
- <!-- skill:if omp,!claude --> blocks include text only for matching
  targets; name-list conditions only, no else/nesting, fail-loud on
  unknown targets and unpaired/nested directives
- fence-aware: directive-looking lines inside code fences are literal
- layout is the filesystem; tree root configured in skillproj.toml
- post-build assertion: zero directive residue, SKILL.md frontmatter
  name check

Migration to the new model:
- docs/skill/ becomes the self-contained source root (SKILL.md,
  references/, generated api/stdlib/core/guides now under
  references/docs/; SDK_OVERVIEW/LICENSE/inspect are ordinary tree
  files)
- auto_docs_gen output redirected into the tree (docs/api ->
  docs/skill/references/docs/api, likewise stdlib)
- skills/simplecadapi/ is now the compiled omp target output;
  dist/generic/simplecadapi the generic target
- dropped skill-pack entry point (plus dangling evolve/make-export
  entries and their orphaned test), release workflow builds via
  skillbuild + tar; README updated

First real conditional block: harness reading paths in SKILL.md
(skill:// mount on omp vs disk-relative on generic).

Verified: 59 tests pass (skillbuild 31, auto_docs_gen 19, persistence
regression 9); both targets build; outputs residue-clean; full suite
collects (1376 tests).

* refactor(tools): auto_docs_gen moves out of the installed package

tools/ scripts are repo-checkout dev scripts, not packaged CLIs:
- auto_docs_gen.py now lives in tools/ beside the other generators;
  auto_tools/ package removed entirely
- path resolution simplifies: repo root = parent of tools/, fail-loud
  if pyproject.toml missing; site-packages/cwd fallback branches were
  dead code once the script stopped shipping in the wheel
- auto-docs-gen console script dropped from [project.scripts];
  release.yml and README invoke python tools/auto_docs_gen.py
- MANIFEST.in stale src/auto_tools include removed; CadQuery-free
  runtime scan no longer needs the auto_tools filter
- run_examples.py retired (user removal): README example-runner text
  updated to direct examples/ scripts; dangling runner-contract test
  (runpy.run_path into the deleted script) removed

Verified: 53 tests pass (auto_docs_gen + skill_build + ocp runtime
scan) and test_example_model_contract passes; regeneration from
tools/ is byte-identical (zero docs drift).

* refactor(skill): strip harness and build-tool content from the skill tree

The skill is plain harness-neutral content again:
- SKILL.md 'Reading skill files' section removed (the omp skill://
  mount block and its !omp complement were the only conditional
  blocks; the tree compiles identically for every target now)
- references/README.md: build-tool meta removed ('per-harness
  conditional compilation', skillbuild packaging/validation claims —
  link validation was never implemented, so the claim was false)
- live test now asserts the tree stays harness-neutral (zero blocks)
- skillproj.toml targets aligned with the user's output table
  (omp -> skills/simplecadapi-omp, opencode -> skills/simplecadapi-opencode;
  leftover 'generic' entry had no output and failed the build)
- compiled outputs are regenerable artifacts: skills/simplecadapi/
  untracked from git, skills/simplecadapi-*/ gitignored, release.yml
  and README build via skillbuild and tar the omp output directly
  (bsdtar has no --transform; inner dir keeps its suffixed name)

Verified: 49 tests pass; both targets build 372 files with zero
conditional blocks; no omp/conditional/directive residue in the tree
or outputs.

* chore(docs): drop stale architecture review and design notes
2026-08-22 20:20:49 +08:00
NiJingzhe c9760f2866 Add replayable modeling and Scene packages 2026-07-23 03:15:43 +08:00
NiJingzhe f185406516 Support indexed geo select nodes 2026-06-02 23:29:27 +08:00
NiJingzhe 7425f71d79 Refactor SDK contract and QL selection replay 2026-06-01 01:14:19 +08:00
NiJingzhe 65beee4c81 Prepare 2.0.0b1 beta release 2026-05-09 23:17:08 +08:00
NiJingzhe a05f1e90e6 Refactor runtime to OCP-native kernel 2026-05-03 03:03:29 +08:00