Compare commits

...

56 Commits

Author SHA1 Message Date
forbes
d28c54b54f chore: configure submodules to track main branch
Add branch = main to mods/silo and mods/ztools in .gitmodules.
Add branch = main to silo-client in mods/silo/.gitmodules.

Enables 'git submodule update --remote' to auto-advance Kindred
submodules to latest main. Third-party deps (GSL, googletest,
AddonManager) remain pinned.

Also updates submodule pointers to latest main commits.
2026-02-19 14:55:18 -06:00
0bc2cf3b6a Merge pull request 'feat(ztools): migrate to kindred_sdk palette system (#278)' (#283) from feat/ztools-sdk-migration into main
Some checks failed
Build and Test / build (push) Has been cancelled
Reviewed-on: #283
2026-02-19 20:48:37 +00:00
forbes
0330396843 refactor: extract theme from ztools into base distribution (#278)
All checks were successful
Build and Test / build (pull_request) Successful in 29m25s
- Add Spreadsheet color preferences to KindredCreate.cfg using FCText
  entries (TextColor, AliasedCellBackgroundColor, PositiveNumberColor,
  NegativeNumberColor) matching the C++ GetASCII() reader in SheetModel.cpp
- Remove CatppuccinMocha install directive from CMakeLists.txt
- Update ztools submodule: theme.py deleted, CatppuccinMocha preference
  pack removed, package.xml cleaned up

The previous apply_spreadsheet_colors() in ztools was a no-op: it called
SetUnsigned() but the Spreadsheet C++ reads GetASCII() — different param
types in FreeCAD's parameter system. Now properly fixed via preference pack.

Closes #278
2026-02-19 14:46:59 -06:00
forbes
6690d0355a chore: update mods/ztools pointer for SDK migration (#278)
All checks were successful
Build and Test / build (pull_request) Successful in 29m54s
Points to feat/sdk-migration branch with kindred_sdk palette integration.
2026-02-19 14:35:27 -06:00
7fe046379b Merge pull request 'feat: BOM auto-extraction from Assembly links + manifest field population' (#282) from feat/bom-sync-and-manifest into main
Some checks failed
Deploy Docs / build-and-deploy (push) Successful in 37s
Build and Test / build (push) Has been cancelled
Reviewed-on: #282
2026-02-19 20:23:22 +00:00
forbes
0bc03ea421 feat: BOM auto-extraction and manifest field population (#276, #277)
All checks were successful
Build and Test / build (pull_request) Successful in 29m22s
Documentation updates:
- KNOWN_ISSUES.md: correct #6 (datum handling), resolve #10
  (delete_bom_entry) and #11 (silo icons), fix stale formatDate
  reference, mark completed next steps, add new next steps.
- INTEGRATION_PLAN.md: correct ztools SDK migration claim.

kc_format.py (#277):
- New _manifest_enrich_hook: populates part_uuid from SiloItemId and
  silo_instance from Silo API URL on every .kc save.
- New update_manifest_fields(): public API to update manifest fields
  in an already-saved .kc ZIP (used for post-upload revision_hash).

mods/silo submodule (#276):
- New bom_sync.py extraction engine.
- Post-commit hooks for BOM sync and manifest revision update.
- SSE bom_merged signal + Activity pane handler.
- merge_bom_json client method (forward-looking).

Refs: #276, #277
2026-02-19 12:37:24 -06:00
0c43957e9b Merge pull request 'chore: update mods/silo submodule pointer to main' (#275) from fix/silo-submodule-pointer into main
All checks were successful
Build and Test / build (push) Successful in 30m4s
Sync Silo Server Docs / sync (push) Successful in 41s
Reviewed-on: #275
2026-02-19 01:58:49 +00:00
forbes
2ce00a527a chore: update mods/silo pointer to main
All checks were successful
Build and Test / build (pull_request) Successful in 28m57s
Points to silo-mod main (af98994) which includes the correct
silo-client submodule pointer at main (285bd1f).
2026-02-18 19:58:30 -06:00
967e434607 Merge pull request 'feat(create): server integration for silo viewer widgets' (#274) from feat/server-integration into main
Some checks failed
Build and Test / build (push) Has been cancelled
Reviewed-on: #274
2026-02-19 01:41:59 +00:00
forbes
264e82179d feat(create): server integration for silo viewer widgets
All checks were successful
Build and Test / build (pull_request) Successful in 29m45s
Wire live data fetching, SSE subscriptions, and server write-back into
the History, Metadata, and Dependency viewer widgets.

Changes:
- Add server integration helpers (_init_server, _is_online,
  _get_part_number, offline banner) with lazy silo_commands import
- SiloHistoryViewer: Refresh button fetches live revisions via
  SiloClient.get_revisions(); SSE revision_created auto-refreshes
- SiloMetadataEditor: Save pushes to server (update_metadata,
  patch_lifecycle, patch_tags); SSE item_updated refreshes form
  when no local edits pending; offline banner
- SiloDependencyTable: Server-side UUID resolution via
  resolve_dependencies(); Download button for unresolved items;
  Refresh re-checks status; three-state icons (resolved/
  downloadable/missing)
- All viewers show 'Offline — showing cached data' banner when
  disconnected and disable server-dependent controls

Bump silo submodule to track new silo-client API methods:
  get_metadata, update_metadata, patch_lifecycle, patch_tags,
  resolve_dependencies (silo-client PR #19)

Closes kindred/silo-mod#43
2026-02-18 19:36:04 -06:00
Kindred Bot
40fac46862 docs: sync Silo server documentation
Some checks failed
Deploy Docs / build-and-deploy (push) Successful in 34s
Build and Test / build (push) Has been cancelled
Auto-synced from kindred/silo main branch.
2026-02-19 01:13:03 +00:00
ed71a0c8b9 Merge pull request 'art(create): placeholder tree-node icons for Silo viewer nodes' (#273) from feat/silo-tree-icons into main
Some checks failed
Build and Test / build (push) Has been cancelled
Reviewed-on: #273
2026-02-19 01:11:45 +00:00
0ea2622a73 Merge pull request 'feat(create): remaining viewers — dependencies, jobs, macros, approvals' (#272) from feat/remaining-viewers into main
Some checks failed
Build and Test / build (push) Has been cancelled
Reviewed-on: #272
2026-02-19 00:54:24 +00:00
forbes
9748384e7d art(create): placeholder tree-node icons for Silo viewer nodes (#42)
All checks were successful
Build and Test / build (pull_request) Successful in 29m26s
Add 10 SVG placeholder icons copied from existing silo action icons.
These provide immediate visual feedback in the document tree while
proper Catppuccin-themed icons are designed later.

Icons: silo-group, silo-manifest, silo-metadata, silo-history,
silo-approvals, silo-dependencies, silo-job, silo-macro,
silo-jobs-group, silo-macros-group

Also adds install(DIRECTORY) rule for resources/icons/ in CMakeLists.

Closes #42
2026-02-18 18:53:55 -06:00
forbes
bb14d7b0ef feat(create): remaining viewers — dependencies, jobs, macros, approvals (#41)
All checks were successful
Build and Test / build (pull_request) Successful in 31m3s
Add four viewer widgets for the remaining Silo tree node types:

- SiloApprovalsViewer: ECO approval status cards with colored status
  icons, state badge, and Open in Silo Web UI button
- SiloDependencyTable: QTableView with resolution status (checks open
  documents for matching part_uuid)
- SiloJobViewer: YAML source editor with Edit/Lock toggle, monospace
  font, dirty tracking, and unsaved-changes guard
- SiloMacroEditor: Python source editor with Run Now (exec in FreeCAD
  context), Save button, and dirty tracking

Also extends the viewer factory with prefix-based routing for
silo/jobs/*.yaml and silo/macros/*.py entries.

Closes #41
2026-02-18 18:46:06 -06:00
099d2a025a Merge pull request 'feat(create): history viewer — revision timeline display' (#271) from feat/history-viewer into main
Some checks failed
Build and Test / build (push) Has been cancelled
Reviewed-on: #271
2026-02-19 00:43:14 +00:00
3e93f4a756 Merge branch 'main' into feat/history-viewer
All checks were successful
Build and Test / build (pull_request) Successful in 29m35s
2026-02-19 00:43:03 +00:00
8b6205a340 Merge pull request 'feat(create): metadata editor — editable form with dirty tracking and save-back' (#270) from feat/metadata-editor into main
Some checks failed
Build and Test / build (push) Has been cancelled
Reviewed-on: #270
2026-02-19 00:42:54 +00:00
6fe5cc1d4d Merge branch 'main' into feat/metadata-editor
All checks were successful
Build and Test / build (pull_request) Successful in 29m56s
2026-02-19 00:42:45 +00:00
forbes
29f4a7b110 feat(create): history viewer — revision timeline display (#40)
All checks were successful
Build and Test / build (pull_request) Successful in 29m36s
Add SiloHistoryViewer widget that opens in an MDI subwindow when the
user double-clicks the History node in the Silo tree. Displays revision
cards newest-first with revision number, Catppuccin-themed lifecycle
status badges, author, timestamp, and commit comment.

Changes:
- silo_viewers.py: SiloHistoryViewer with revision card layout,
  status badge QSS, scroll area, empty-history placeholder

Closes #40
2026-02-18 18:41:56 -06:00
forbes
e947822c7a feat(create): metadata editor — editable form with dirty tracking and save-back (#39)
All checks were successful
Build and Test / build (pull_request) Successful in 30m48s
Add SiloMetadataEditor widget that opens in an MDI subwindow when the
user double-clicks the Metadata node in the Silo tree. Supports editing
lifecycle state, tags (add/remove chips), and schema-defined fields with
type-inferred widgets (QCheckBox, QDoubleSpinBox, QLineEdit).

Changes:
- silo_viewers.py: SiloMetadataEditor with dirty tracking, Save/Reset
  buttons, unsaved-changes close guard, and tag chip management
- silo_objects.py: mark_dirty()/is_dirty()/clear_dirty() on proxy
- kc_format.py: fix entries=None before hooks; _metadata_save_hook
  writes dirty RawContent back to silo/ cache on document save

Closes #39
2026-02-18 17:11:05 -06:00
92183ef697 Merge pull request 'feat(create): manifest viewer — read-only MDI widget for silo/manifest.json' (#269) from feat/manifest-viewer into main
All checks were successful
Build and Test / build (push) Successful in 29m5s
Reviewed-on: #269
2026-02-18 22:50:32 +00:00
b721e67c8d Merge branch 'main' into feat/manifest-viewer
All checks were successful
Build and Test / build (pull_request) Successful in 29m6s
2026-02-18 22:50:16 +00:00
forbes
90728414a9 feat(create): manifest viewer — read-only MDI widget for silo/manifest.json (#38)
All checks were successful
Build and Test / build (pull_request) Successful in 29m13s
Add SiloManifestViewer widget that opens in an MDI subwindow when the
user double-clicks the Manifest node in the Silo tree. Displays all
manifest.json fields in a read-only QFormLayout with copy buttons for
Part UUID and Silo Instance.

New files:
- silo_viewers.py: SiloManifestViewer widget + create_viewer_widget()
  factory with _VIEWER_REGISTRY for future viewer classes

Modified files:
- silo_viewproviders.py: doubleClicked() wired to open MDI subwindow
  with deduplication via widget objectName()
- CMakeLists.txt: add silo_viewers.py to install list

Closes #38
2026-02-18 16:48:34 -06:00
d87b79698f Merge pull request 'feat(create): silo tree foundation for .kc files' (#268) from feat/silo-tree-foundation into main
Some checks failed
Build and Test / build (push) Has been cancelled
Reviewed-on: #268
2026-02-18 22:38:22 +00:00
forbes
65f24b23eb feat(create): silo tree foundation for .kc files (#37)
All checks were successful
Build and Test / build (pull_request) Successful in 29m13s
Add document tree infrastructure that creates Silo metadata nodes when
a .kc file is opened. Nodes appear under a "Silo" group and represent
the silo/ ZIP directory entries (manifest, metadata, history, etc.).

New files:
- silo_objects.py: SiloViewerObject proxy with Transient properties
- silo_viewproviders.py: SiloViewerViewProvider with icon stubs
- silo_tree.py: SiloTreeBuilder with conditional node creation
- silo_document.py: SiloDocumentObserver singleton + registration

Modified files:
- kc_format.py: pre_reinject hook system for silo/ entry mutation
- InitGui.py: 600ms timer registration for document observer
- CMakeLists.txt: install list for 4 new Python files

Closes #37
2026-02-18 16:36:29 -06:00
Kindred Bot
deb425db44 docs: sync Silo server documentation
All checks were successful
Deploy Docs / build-and-deploy (push) Successful in 34s
Build and Test / build (push) Successful in 28m56s
Auto-synced from kindred/silo main branch.
2026-02-18 21:05:53 +00:00
Kindred Bot
e70348508e docs: sync Silo server documentation
Some checks failed
Deploy Docs / build-and-deploy (push) Successful in 37s
Build and Test / build (push) Has been cancelled
Auto-synced from kindred/silo main branch.
2026-02-18 20:47:26 +00:00
41669eea8b Merge pull request 'fix(gui): make SVG icon rasterization DPI-aware in loadPixmap (#189)' (#266) from fix/toolbar-icon-dpi-scaling into main
All checks were successful
Build and Test / build (push) Successful in 29m59s
Reviewed-on: #266
2026-02-18 18:57:14 +00:00
forbes
ea49736549 test(gui): add BitmapFactory DPI-aware SVG rendering tests (#189)
All checks were successful
Build and Test / build (pull_request) Successful in 29m28s
Three tests for the loadPixmap() DPI fix:
- pixmapFromSvg(content, size) renders at the exact requested size
- getMaximumDPR() returns >= 1.0
- pixmap() loaded from an SVG file has correct devicePixelRatio and
  physical size matching 64 * DPR
2026-02-18 12:54:48 -06:00
forbes
99f2a92df4 fix(gui): make SVG icon rasterization DPI-aware in loadPixmap (#189)
loadPixmap() rendered all SVGs at a hardcoded 64x64 pixels regardless of
display DPI. On HiDPI screens, Qt then downscaled these low-resolution
pixmaps to the toolbar icon size, producing chunky/aliased icons.

Multiply the render size by getMaximumDPR() and tag the resulting pixmap
with the correct devicePixelRatio, matching the pattern already used in
pixmapFromSvg(const char* name, QSizeF size). This ensures SVGs are
rasterized at the physical resolution needed for crisp display.
2026-02-18 12:52:14 -06:00
4510ace7b9 Merge pull request 'fix(tests): add mods/sdk to sys.path in test_kindred_pure' (#265) from fix/test-sdk-path into main
All checks were successful
Build and Test / build (push) Successful in 30m40s
Sync Silo Server Docs / sync (push) Successful in 35s
Reviewed-on: #265
2026-02-17 18:53:24 +00:00
a1105c9d80 fix(tests): add mods/sdk to sys.path in test_kindred_pure
All checks were successful
Build and Test / build (pull_request) Successful in 28m20s
The SDK migration (#250) moved kindred_sdk into mods/sdk/ but the
test file was not updated with the new path, causing
ModuleNotFoundError when importing kindred_sdk.
2026-02-17 12:51:05 -06:00
06c698d425 Merge pull request 'docs: update architecture docs for addon-first model (#255)' (#264) from docs/update-architecture-for-addon-model into main
Some checks failed
Deploy Docs / build-and-deploy (push) Successful in 34s
Build and Test / build (push) Failing after 1m52s
Reviewed-on: #264
2026-02-17 18:46:03 +00:00
252e2c3b3e docs: update architecture docs for addon-first model (#255)
Some checks failed
Build and Test / build (pull_request) Failing after 2m1s
ARCHITECTURE.md:
- Replace exec()-based bootstrap flow with manifest-driven loader diagram
- Add addon lifecycle section (scan → parse → validate → resolve → load → register)
- Add SDK and C++ scaffold to source layout
- Document load order: sdk (0) → ztools (50) → silo (60)

INTEGRATION_PLAN.md:
- Add Layer 4 (Addon SDK) between bootstrap and addons (now 5 layers)
- Update Layer 3: now hosts both Python loader AND C++ scaffold
- Add Phase 1.5 (SDK) and Phase 1.75 (C++ scaffold) as DONE
- Update Phase 4 (theme): colors centralized in SDK YAML palette
- Update Phase 6 (build): now DONE with CMake install rules for all addons
- Add design decisions #7 (SDK as adaptation layer) and #8 (manifest-driven loading)

README.md:
- Update addon integration section: manifest-driven loading, SDK wrappers
- Add mods/sdk/ to project structure tree
- Update Create module description to mention C++ scaffold

Closes #255.
2026-02-17 12:38:18 -06:00
68380357fb Merge pull request 'docs: classify C++ patches by purpose and upstream-ability (#254)' (#263) from docs/classify-cpp-patches into main
Some checks failed
Deploy Docs / build-and-deploy (push) Successful in 35s
Build and Test / build (push) Failing after 1m53s
Reviewed-on: #263
2026-02-17 18:26:05 +00:00
076a1e90b0 docs: classify C++ patches by purpose and upstream-ability (#254)
Some checks failed
Build and Test / build (pull_request) Failing after 2m2s
Add Category column to Phase 2 cherry-pick table:
- 16 × Category 1 (Extension points) — KEEP
- 16 × Category 2 (Branding/theming) — KEEP, minimize
-  4 × Category 3 (Bug fixes) — UPSTREAM candidates

Add upstream verification for Category 3 patches:
- #26/#27 (Wayland scaling, menu icon size): partially upstream, menu pref not contributed
- #31 (window flickering): not upstream, good PR candidate
- #33 (ToolBarItem/reportException): Kindred-internal only

Update Assembly fixes with verified upstream status:
- All 4 patches still needed (joint flip, SIGSEGV, datum plane/point handling)
- App::Line handling fixed upstream via FreeCAD PR#20026

Closes #254.
2026-02-17 12:22:27 -06:00
ab2fde4755 Merge pull request 'feat(create): add C++ module scaffold with App/ and Gui/ targets (#251)' (#262) from feat/cpp-module-scaffold into main
Some checks failed
Build and Test / build (push) Failing after 1m57s
Reviewed-on: #262
2026-02-17 17:55:26 +00:00
5d8a253956 feat(create): add C++ module scaffold with App/ and Gui/ targets (#251)
Some checks failed
Build and Test / build (pull_request) Failing after 2m2s
Establish build infrastructure for Kindred-specific C++ features:

- CreateGlobal.h: export macros (CreateExport, CreateGuiExport)
- App/: CreateApp shared library (PyMOD_INIT_FUNC, Py::ExtensionModule)
- Gui/: CreateGui shared library (links CreateApp + FreeCADGui)
- CMakeLists.txt: add_subdirectory(App) + conditional add_subdirectory(Gui)

Scaffold only — no features. Follows the Assembly module pattern.
Existing Python Init.py/InitGui.py bootstrap unchanged.
2026-02-17 11:50:44 -06:00
6c11d64c5f Merge pull request 'fix: update silo submodule pointer after rebase onto main' (#261) from fix/silo-submodule-rebase into main
Some checks failed
Build and Test / build (push) Failing after 1m54s
Reviewed-on: #261
2026-02-17 17:05:51 +00:00
0ffa171c52 fix: update silo submodule pointer after rebase onto main
Some checks failed
Build and Test / build (pull_request) Failing after 2m2s
2026-02-17 11:04:18 -06:00
acfb627d67 Merge pull request 'refactor: migrate ztools and Silo to kindred-addon-sdk (#250)' (#260) from feat/migrate-addons-to-sdk into main
Some checks failed
Build and Test / build (push) Failing after 1m39s
Reviewed-on: #260
2026-02-17 15:50:58 +00:00
64edae4c04 refactor: migrate ztools and Silo to kindred-addon-sdk (#250)
Some checks failed
Build and Test / build (pull_request) Failing after 1m51s
Route platform API calls through kindred_sdk wrappers:

ZTools:
- Replace hardcoded MOCHA dict with kindred_sdk.get_theme_tokens()
- Add sdk dependency to package.xml

Silo:
- Replace FreeCADGui.registerEditingOverlay() with kindred_sdk.register_overlay()
- Replace FreeCADGui.addOrigin()/removeOrigin() with kindred_sdk wrappers
- Replace hardcoded _MOCHA palette subset with kindred_sdk.get_theme_tokens()
- Add sdk dependency to package.xml

Create module:
- Replace dock panel boilerplate with kindred_sdk.register_dock_panel()

Behavior is identical before and after — this is a refactor only.

Closes #250
2026-02-17 08:59:56 -06:00
0ea1b1fde5 Merge pull request 'feat(addon-system): create kindred-addon-sdk package (#249)' (#259) from feat/kindred-addon-sdk into main
Some checks failed
Build and Test / build (push) Failing after 1m37s
Reviewed-on: #259
2026-02-17 14:49:32 +00:00
e667aceead feat(addon-system): create kindred-addon-sdk package (#249)
Some checks failed
Build and Test / build (pull_request) Failing after 1m40s
Add mods/sdk/ with the kindred_sdk Python package providing a stable
API layer for addon integration with Kindred Create platform features.

Modules:
- context: editing context/overlay registration wrappers
- theme: YAML-driven palette system (Catppuccin Mocha)
- origin: FileOrigin registration helpers
- dock: deferred dock panel registration
- compat: version detection utilities

The SDK loads at priority 0 (before all other addons) via the existing
manifest-driven loader. Theme colors are defined in a single YAML
palette file instead of hardcoded Python dicts, enabling future theme
support and eliminating color duplication across addons.

Closes #249
2026-02-17 08:36:27 -06:00
34964066a0 Merge pull request 'feat(addon-system): add <kindred> package.xml extensions and schema docs' (#257) from feat/package-xml-schema into main
Some checks failed
Deploy Docs / build-and-deploy (push) Successful in 46s
Build and Test / build (push) Failing after 2m1s
Reviewed-on: #257
2026-02-17 13:15:47 +00:00
33026b6ff9 Merge pull request 'feat: addon registry with runtime introspection API (#253)' (#258) from feat/addon-registry-api into main
All checks were successful
Build and Test / build (push) Successful in 30m27s
Sync Silo Server Docs / sync (push) Successful in 50s
Reviewed-on: #258
2026-02-16 23:41:17 +00:00
forbes
9dd43a7cc3 feat: addon registry with runtime introspection API (#253)
All checks were successful
Build and Test / build (pull_request) Successful in 44m33s
Add FreeCAD.getAddonRegistry() function for runtime addon introspection.

Changes to addon_loader.py:
- Add contexts field to AddonManifest for tracking context IDs
- Add register_context() method for addons to declare contexts at runtime
- Add contexts() method returning {context_id: [addon_names]} mapping
- Parse <contexts> element from <kindred> in package.xml
- Add getAddonRegistry() function returning the registry singleton

Changes to Init.py:
- Expose getAddonRegistry as FreeCAD.getAddonRegistry after loading

Usage:
  registry = FreeCAD.getAddonRegistry()
  registry.get('ztools')        # AddonManifest for ztools
  registry.loaded()             # list of loaded addons
  registry.is_loaded('silo')    # True/False
  registry.contexts()           # {context_id: [addon_names]}

Closes #253
2026-02-16 17:33:28 -06:00
98d1877472 feat(addon-system): add <kindred> package.xml extensions and schema docs
Some checks failed
Build and Test / build (pull_request) Failing after 2m59s
Add <kindred> elements to ztools (priority=50) and silo (priority=60)
package.xml files declaring min_create_version, load_priority,
pure_python, and context metadata.

Fix addon_loader.py topological sort to use level-by-level processing
with (priority, name) sorting within each level, replacing
static_order() which did not guarantee deterministic ordering.

Add docs/src/development/package-xml-schema.md documenting the full
field reference, schema example, and backward compatibility notes.

Closes #252
2026-02-16 14:21:27 -06:00
587a95dd66 Merge pull request 'feat(bootstrap): replace exec()-based addon loading with manifest-driven loader' (#256) from feat/manifest-addon-loader into main
All checks were successful
Build and Test / build (push) Successful in 50m29s
Reviewed-on: #256
2026-02-16 19:17:59 +00:00
73f6641199 Merge pull request 'docs: extend README with architecture, platform support, and usage detail' (#247) from docs/extend-readme into main
Some checks failed
Build and Test / build (push) Has been cancelled
Reviewed-on: #247
2026-02-16 19:17:42 +00:00
60ceb47e4f feat(bootstrap): replace exec()-based addon loading with manifest-driven loader
All checks were successful
Build and Test / build (pull_request) Successful in 34m4s
Add addon_loader.py implementing a six-stage pipeline: scan mods/ for
package.xml files, parse standard fields and optional <kindred>
extensions via ElementTree, validate version compatibility, resolve
load order via graphlib.TopologicalSorter (with legacy fallback),
exec() Init.py/InitGui.py, and populate a runtime AddonRegistry
exposed as FreeCAD.KindredAddons.

Replace hard-coded addon lists in Init.py and InitGui.py with calls
to addon_loader.load_addons(). All QTimer-based Silo integration code
in InitGui.py is unchanged.

Backward compatible: addons without <kindred> elements load with no
constraints using the existing ztools-then-silo order.

Closes #248
2026-02-16 13:13:46 -06:00
a8df078eb3 docs: extend README with architecture, platform support, and usage detail
All checks were successful
Build and Test / build (pull_request) Successful in 35m8s
Add editing context system description, built-in context table, and
Python API reference. Add architecture section covering addon
integration and unified origin system. Expand ztools and Silo usage
sections with command breakdowns. Add platform support table. Expand
project structure tree with Kindred-specific files.
2026-02-16 11:02:11 -06:00
f4d91db094 Merge pull request 'feat(icons): add icon theming infrastructure with Catppuccin color remapping' (#246) from feat/icon-theming into main
Some checks failed
Build and Test / build (push) Has been cancelled
Deploy Docs / build-and-deploy (push) Successful in 46s
Sync Silo Server Docs / sync (push) Successful in 37s
Reviewed-on: #246
2026-02-16 02:36:17 +00:00
b083970a4d Merge branch 'main' into feat/icon-theming
Some checks failed
Build and Test / build (pull_request) Has been cancelled
2026-02-16 02:36:01 +00:00
19a91cb221 Merge pull request 'fix(assembly): guard onChanged against solver during document restore' (#245) from fix/assembly-restore-segfault into main
Some checks failed
Build and Test / build (push) Has been cancelled
Reviewed-on: #245
2026-02-16 00:46:17 +00:00
64 changed files with 5504 additions and 431 deletions

2
.gitmodules vendored
View File

@@ -13,6 +13,8 @@
[submodule "mods/ztools"]
path = mods/ztools
url = https://git.kindred-systems.com/forbes/ztools.git
branch = main
[submodule "mods/silo"]
path = mods/silo
url = https://git.kindred-systems.com/kindred/silo-mod.git
branch = main

135
README.md

File diff suppressed because one or more lines are too long

View File

@@ -5,42 +5,116 @@
```
FreeCAD startup
└─ src/Mod/Create/Init.py
└─ setup_kindred_addons()
├─ exec(mods/ztools/ztools/Init.py)
exec(mods/silo/freecad/Init.py)
└─ addon_loader.load_addons(gui=False)
├─ scan_addons("mods/") — find package.xml manifests
parse_manifest() — extract <kindred> extensions
├─ validate_manifest() — check min/max_create_version
├─ resolve_load_order() — topological sort by <dependency>
└─ for each addon in order:
├─ add addon dir to sys.path
├─ exec(Init.py)
└─ register in AddonRegistry (FreeCAD.KindredAddons)
└─ src/Mod/Create/InitGui.py
├─ setup_kindred_workbenches()
exec(mods/ztools/ztools/InitGui.py)
└─ schedules deferred _register() (2000ms)
├─ imports ZTools commands
├─ installs _ZToolsManipulator (global)
└─ injects commands into editing contexts
└─ exec(mods/silo/freecad/InitGui.py)
├─ registers SiloWorkbench
└─ schedules deferred Silo overlay registration (2500ms)
├─ addon_loader.load_addons(gui=True)
for each addon in order:
└─ exec(InitGui.py)
├─ sdk (priority 0): logs "SDK loaded"
├─ ztools (priority 50): schedules deferred _register() (2000ms)
│ ├─ imports ZTools commands
│ ├─ installs _ZToolsManipulator (global)
│ └─ injects commands into editing contexts
└─ silo (priority 60): registers SiloWorkbench
│ └─ schedules deferred Silo overlay registration (2500ms)
├─ EditingContextResolver singleton created (MainWindow constructor)
│ ├─ registers built-in contexts (PartDesign, Sketcher, Assembly, Spreadsheet)
│ ├─ connects to signalInEdit/signalResetEdit/signalActiveDocument/signalActivateView
│ └─ BreadcrumbToolBar connected to contextChanged signal
└─ Deferred setup (QTimer):
├─ 500ms: _register_kc_format() → .kc file format
├─ 1500ms: _register_silo_origin() → registers Silo FileOrigin
├─ 2000ms: _setup_silo_auth_panel() → "Database Auth" dock
├─ 2000ms: ZTools _register() → commands + manipulator
├─ 2500ms: Silo overlay registration → "Silo Origin" toolbar overlay
├─ 3000ms: _check_silo_first_start() → settings prompt
├─ 4000ms: _setup_silo_activity_panel() → "Database Activity" dock (SSE)
├─ 4000ms: _setup_silo_activity_panel() → "Database Activity" dock
└─ 10000ms: _check_for_updates() → update checker (Gitea API)
```
### Addon lifecycle
Each addon in `mods/` provides a `package.xml` manifest with a `<kindred>` extension block:
```xml
<kindred>
<min_create_version>0.1.0</min_create_version>
<load_priority>50</load_priority>
<pure_python>true</pure_python>
<dependencies>
<dependency>sdk</dependency>
</dependencies>
</kindred>
```
The loader (`addon_loader.py`) processes addons in this order:
1. **Scan** — find all `mods/*/package.xml` files
2. **Parse** — extract `<kindred>` metadata (version bounds, priority, dependencies)
3. **Validate** — reject addons incompatible with the current Create version
4. **Resolve** — topological sort by `<dependency>` declarations, breaking ties by `<load_priority>`
5. **Load** — execute `Init.py` (console) then `InitGui.py` (GUI) for each addon
6. **Register** — populate `FreeCAD.KindredAddons` registry with addon state
Current load order: **sdk** (0) → **ztools** (50) → **silo** (60)
## Key source layout
```
src/Mod/Create/ Kindred bootstrap module (Python)
├── Init.py Adds mods/ addon paths, loads Init.py files
├── InitGui.py Loads workbenches, installs Silo manipulators
src/Mod/Create/ Kindred Create module
├── Init.py Console bootstrap — loads addons via manifest-driven loader
├── InitGui.py GUI bootstrap — loads addons, Silo integration, update checker
├── addon_loader.py Manifest-driven addon loader with dependency resolution
├── kc_format.py .kc file format round-trip preservation
├── version.py.in CMake template → version.py (build-time)
── update_checker.py Checks Gitea releases API for updates
── update_checker.py Checks Gitea releases API for updates
├── CreateGlobal.h C++ export macros (CreateExport, CreateGuiExport)
├── App/ C++ App library (CreateApp.so)
│ ├── AppCreate.cpp Module entry point — PyMOD_INIT_FUNC(CreateApp)
│ └── AppCreatePy.cpp Python module object (Py::ExtensionModule)
└── Gui/ C++ Gui library (CreateGui.so)
├── AppCreateGui.cpp Module entry point — PyMOD_INIT_FUNC(CreateGui)
└── AppCreateGuiPy.cpp Python module object (Py::ExtensionModule)
mods/sdk/ [dir] Kindred addon SDK — stable API contract
├── package.xml Manifest (priority 0, no dependencies)
├── kindred_sdk/
│ ├── __init__.py Public API re-exports
│ ├── context.py Editing context wrappers (register_context, register_overlay, ...)
│ ├── theme.py YAML-driven palette system (get_theme_tokens, load_palette, Palette)
│ ├── origin.py FileOrigin registration (register_origin, unregister_origin)
│ ├── dock.py Deferred dock panel helper (register_dock_panel)
│ ├── compat.py Version detection (create_version, freecad_version)
│ └── palettes/
│ └── catppuccin-mocha.yaml 26 colors + 14 semantic roles
└── Init.py / InitGui.py Minimal log messages
mods/ztools/ [submodule] command provider (not a workbench)
├── package.xml Manifest (priority 50, depends on sdk)
├── ztools/InitGui.py Deferred command registration + _ZToolsManipulator
├── ztools/ztools/
│ ├── commands/ Datum, pattern, pocket, assembly, spreadsheet
│ ├── datums/core.py Datum creation via Part::AttachExtension
│ └── resources/ Icons (SDK theme tokens), theme utilities
└── CatppuccinMocha/ Theme preference pack (QSS)
mods/silo/ [submodule → silo-mod.git] FreeCAD workbench
├── freecad/package.xml Manifest (priority 60, depends on sdk)
├── silo-client/ [submodule → silo-client.git] shared API client
│ └── silo_client/ SiloClient, SiloSettings, CATEGORY_NAMES
└── freecad/ FreeCAD workbench (Python)
├── InitGui.py SiloWorkbench + overlay registration (via SDK)
├── silo_commands.py Commands + FreeCADSiloSettings adapter
└── silo_origin.py FileOrigin backend for Silo (via SDK)
src/Gui/EditingContext.h/.cpp EditingContextResolver singleton + context registry
src/Gui/BreadcrumbToolBar.h/.cpp Color-coded breadcrumb toolbar (Catppuccin Mocha)
@@ -49,22 +123,6 @@ src/Gui/CommandOrigin.cpp Origin_Commit/Pull/Push/Info/BOM commands
src/Gui/OriginManager.h/.cpp Origin lifecycle management
src/Gui/OriginSelectorWidget.h/.cpp UI for origin selection
mods/ztools/ [submodule] command provider (not a workbench)
├── ztools/InitGui.py Deferred command registration + _ZToolsManipulator
├── ztools/ztools/
│ ├── commands/ Datum, pattern, pocket, assembly, spreadsheet
│ ├── datums/core.py Datum creation via Part::AttachExtension
│ └── resources/ Icons, theme utilities
└── CatppuccinMocha/ Theme preference pack (QSS)
mods/silo/ [submodule -> silo-mod.git] FreeCAD workbench
├── silo-client/ [submodule -> silo-client.git] shared API client
│ └── silo_client/ SiloClient, SiloSettings, CATEGORY_NAMES
└── freecad/ FreeCAD workbench (Python)
├── InitGui.py SiloWorkbench + Silo overlay context registration
├── silo_commands.py Commands + FreeCADSiloSettings adapter
└── silo_origin.py FileOrigin backend for Silo
src/Gui/Stylesheets/ QSS themes and SVG assets
src/Gui/PreferencePacks/ KindredCreate preference pack (cfg + build-time QSS)
```

File diff suppressed because one or more lines are too long

View File

@@ -16,7 +16,7 @@
5. **No unit tests.** Zero test coverage for ztools and Silo FreeCAD commands. Silo Go backend also lacks tests.
6. **Assembly solver datum handling is minimal.** The `findPlacement()` fix in `src/Mod/Assembly/UtilsAssembly.py` extracts placement from `obj.Shape.Faces[0]` for `PartDesign::Plane` and from shape vertex for `PartDesign::Point`. Does not handle empty shapes or non-planar datum objects.
6. **Assembly solver datum handling is minimal.** `UtilsAssembly.findPlacement()` handles standard shapes (faces, edges, vertices) and `App::Line` origin objects. It does not extract placement from `PartDesign::Plane` or `PartDesign::Point` datum objects — when no element is selected, it returns a default `App.Placement()`. This means assembly joints referencing datum planes/points may produce incorrect placement.
### Medium
@@ -26,9 +26,9 @@
9. **tangent_to_cylinder falls back to manual placement.** TangentPlane MapMode requires a vertex reference not collected by the current UI.
10. **`delete_bom_entry()` bypasses error normalization.** Uses raw `urllib.request` instead of `SiloClient._request()`.
10. ~~**`delete_bom_entry()` bypasses error normalization.**~~ Resolved. `delete_bom_entry()` uses `self._request("DELETE", ...)` which routes through `SiloClient._request()` with proper error handling.
11. **Missing Silo icons.** Three commands reference icons that don't exist: `silo-tag.svg` (`Silo_TagProjects`), `silo-rollback.svg` (`Silo_Rollback`), `silo-status.svg` (`Silo_SetStatus`). The `_icon()` function returns an empty string, so these commands render without toolbar icons.
11. ~~**Missing Silo icons.**~~ Resolved. All three icons now exist: `silo-tag.svg`, `silo-rollback.svg`, `silo-status.svg` in `mods/silo/freecad/resources/icons/`.
### Fixed (retain for reference)
@@ -50,7 +50,7 @@
| CSRF protection | Implemented | `nosurf` library on web form routes |
| File locking | Not implemented | Needed to prevent concurrent edits |
| Odoo ERP integration | Stub only | Returns "not yet implemented" |
| Part number date segments | Broken | `formatDate()` returns error |
| Part number date segments | Unknown | `formatDate()` reference is stale — function not found in codebase |
| Location/inventory APIs | Tables exist, no handlers | |
| CSV import rollback | Not implemented | `bom_handlers.go` |
| SSE event streaming | Implemented | Reconnect logic with exponential backoff |
@@ -71,14 +71,20 @@
1. **Authentication hardening** -- Deploy FreeIPA and Keycloak infrastructure. End-to-end test LDAP and OIDC flows. Harden token rotation and session expiry.
2. **BOM-Assembly bridge** -- Auto-populate Silo BOM from Assembly component links on save.
2. **BOM-Assembly bridge** -- Auto-populate Silo BOM from Assembly component links on save. See `docs/BOM_MERGE.md` for specification.
3. **File locking** -- Pessimistic locks on `Silo_Open` to prevent concurrent edits. Requires server-side lock table and client-side lock display.
4. **Build system** -- CMake install rules for `mods/` submodules so packages include ztools and Silo without manual steps.
4. ~~**Build system**~~ Done. CMake install rules in `src/Mod/Create/CMakeLists.txt` handle all `mods/` submodules.
5. **Test coverage** -- Unit tests for ztools datum creation, Silo FreeCAD commands, and Go API endpoints.
6. **QSS consolidation** -- Eliminate the 3-copy QSS duplication via build-time copy or symlinks. The canonical source is `resources/preferences/KindredCreate/KindredCreate.qss`.
6. ~~**QSS consolidation**~~ Done. Canonical QSS is `src/Gui/Stylesheets/KindredCreate.qss`; PreferencePacks copy generated at build time via `configure_file()`.
7. **Update notification UI** -- Display in-app notification when a new release is available (issue #30). The update checker backend is already implemented.
7. **Update notification UI** -- Display in-app notification when a new release is available (issue #30). The update checker backend (`update_checker.py`) runs at startup; notification UI still needed.
8. **KC file format completion** -- Populate `silo_instance` and `revision_hash` in manifest.json. Implement write-back for history.json, approvals.json, dependencies.json. See `docs/KC_SPECIFICATION.md`.
9. **ztools SDK migration** -- Add `<kindred>` metadata to `mods/ztools/package.xml` (load priority, version bounds, SDK dependency). Migrate `InitGui.py` to use `kindred_sdk` APIs for context/overlay registration.
10. **DAG cross-item edges** -- Assembly constraints referencing geometry in child parts should populate `dag_cross_edges`. Deferred until assembly constraint model is finalized.

View File

@@ -74,46 +74,71 @@ These files/directories exist only in Kindred Create and can be copied directly
36 Kindred commits touch core FreeCAD C++ files. Of those, **38 files** also changed on `upstream/main`, creating potential conflicts. Listed in chronological order (oldest first) for cherry-pick sequence.
### Category legend
| Category | Meaning | Long-term plan |
|----------|---------|----------------|
| **1 — Extension** | Platform extension points for Python addons. Core differentiator. | KEEP — maintain and isolate |
| **2 — Branding** | Branding and theming. Unavoidable in a fork. | KEEP — minimize surface area |
| **3 — Bug fix** | Bug fixes and polish applicable to upstream FreeCAD. | UPSTREAM — contribute and eliminate |
### Commit sequence
| # | Hash | Summary | Conflict Risk | Files |
|---|------|---------|---------------|-------|
| 1 | `316d4f4b524` | Initial branding (CMakeLists, splash, about, theme, icons, QRC) | **HIGH** — CMakeLists.txt, DlgAbout.cpp, SplashScreen.cpp, resource.qrc all changed upstream | 14 files |
| 2 | `8c6837cc152` | Theme padding/clipping fixes | LOW — KindredCreate.qss is new file | 1 file |
| 3 | `bb3f3ac6d6c` | Dock task panel right, remove non-Kindred themes | **MEDIUM** — MainWindow.cpp, PreferencePacks CMakeLists changed upstream | 8 files |
| 4 | `e85162947b7` | Startup theme selector fix | **MEDIUM** — StartupProcess.cpp changed upstream | 4 files |
| 5 | `eb80c07f57a` | Theme QSS refinements | LOW — Kindred-only files | 4 files |
| 6 | `8639b6fd8ab` | Resolve unknown command/style token errors | **MEDIUM** — StartupProcess.cpp | 5 files |
| 7 | `fea1280fa90` | Theme alternate-background-color | LOW | 2 files |
| 8 | `b3fedfb19fb` | Theme tree item padding | LOW | 2 files |
| 9 | `0d4545b7d67` | Tree branch line SVGs | LOW — new files | 8 files |
| 10 | `434ae797a43` | Theme selector cleanup | **MEDIUM** — StartupProcess.cpp | 4 files |
| 11 | `224feda4ad6` | Catppuccin icon override infrastructure | **MEDIUM** — BitmapFactory.cpp, CMakeLists.txt | 2 files |
| 12 | `7535a48ec4c` | Origin abstraction layer | **HIGH** — Application.cpp, ApplicationPy.cpp/.h, CMakeLists.txt | 6 files (4 new) |
| 13 | `38358e431d2` | LocalFileOrigin and Std_* delegation | **HIGH** — CommandDoc.cpp, FileOrigin.cpp/.h | 3 files |
| 14 | `79c85ed2e5d` | FileOriginPython interactive methods | LOW — Kindred-only files | 3 files |
| 15 | `deeb6376f71` | OriginSelectorWidget | **HIGH** — Action.cpp/.h, CommandStd.cpp, Workbench.cpp, CMakeLists.txt | 8 files |
| 16 | `679aaec6d49` | Origin commands (Commit/Pull/Push) | **MEDIUM** — Application.cpp, Command.h, Workbench.cpp | 5 files |
| 17 | `db85277f262` | OriginManagerDialog | LOW — new files + OriginSelectorWidget.cpp | 3 files |
| 18 | `015df38328c` | Document-origin tracking in window title | **MEDIUM** — MDIView.cpp | 3 files |
| 19 | `a6e84552da5` | Cross-origin detection in SaveAs | **MEDIUM** — CommandDoc.cpp | 1 file |
| 20 | `84b69b935b2` | Build fix: remove SelectModule.h include | LOW | 1 file |
| 21 | `2f594dac0a5` | Use Python API for viewDefaultOrientation | **MEDIUM** — CommandDoc.cpp | 1 file |
| 22 | `724440dcb75` | Build fixes for OriginSelectorWidget/Manager | LOW — Kindred files | 2 files |
| 23 | `c858706d480` | Add silo icons to QRC | LOW — resource.qrc (additive) | 6 files |
| 24 | `d95c850b7b1` | Widen origin selector widget | LOW | 1 file |
| 25 | `10b5c9d584f` | Wire OriginManagerDialog to Silo_Settings | LOW | 1 file |
| 26 | `cc5ba638d1f` | UI polish — Wayland scaling, menu icon size | **HIGH** — DlgSettingsGeneral.cpp/.h/.ui changed upstream | 6 files |
| 27 | `4bf74cf3391` | Build fix for DlgSettingsGeneral | **MEDIUM** — DlgSettingsGeneral.h, StartupProcess.cpp | 2 files |
| 28 | `6773ca0dfd8` | Eliminate QSS/CFG duplication | LOW — Kindred files | 3 files |
| 29 | `977fa3c9347` | QGroupBox indicator, hyperlink color | LOW — KindredCreate.qss | 1 file |
| 30 | `8b2ce4b73a4` | Native Qt start panel + kindred:// URL | **MEDIUM** — MainWindow.cpp | 1 file |
| 31 | `bf637af4e45` | Window flickering and icon clipping fix | **MEDIUM** — MainWindow.cpp/.h | 3 files |
| 32 | `70118201b02` | MDI pre-document tab for Silo new item | **HIGH** — ApplicationPy, BreadcrumbToolBar, EditingContext, MainWindow, Workbench | 11 files |
| 33 | `1f49e3fa6da` | Build fix: ToolBarItem incomplete type, reportException | **LOW** — likely already fixed upstream | 2 files |
| 34 | `f71decca089` | Splash screen: skip runtime draw, mantle bg | **MEDIUM** — SplashScreen.cpp | 3 files |
| 35 | `2b0c6774c07` | Dev build defaults, skip version migration | **MEDIUM** — CMakeLists.txt, DlgVersionMigrator.cpp | 2 files |
| 36 | `ab71902a4c2` | Forward visibility arg in appendToolbar() | LOW — FreeCADGuiInit.py | 1 file |
| # | Hash | Summary | Category | Conflict Risk | Files |
|---|------|---------|----------|---------------|-------|
| 1 | `316d4f4b524` | Initial branding (CMakeLists, splash, about, theme, icons, QRC) | 2 — Branding | **HIGH** — CMakeLists.txt, DlgAbout.cpp, SplashScreen.cpp, resource.qrc all changed upstream | 14 files |
| 2 | `8c6837cc152` | Theme padding/clipping fixes | 2 — Branding | LOW — KindredCreate.qss is new file | 1 file |
| 3 | `bb3f3ac6d6c` | Dock task panel right, remove non-Kindred themes | 2 — Branding | **MEDIUM** — MainWindow.cpp, PreferencePacks CMakeLists changed upstream | 8 files |
| 4 | `e85162947b7` | Startup theme selector fix | 2 — Branding | **MEDIUM** — StartupProcess.cpp changed upstream | 4 files |
| 5 | `eb80c07f57a` | Theme QSS refinements | 2 — Branding | LOW — Kindred-only files | 4 files |
| 6 | `8639b6fd8ab` | Resolve unknown command/style token errors | 2 — Branding | **MEDIUM** — StartupProcess.cpp | 5 files |
| 7 | `fea1280fa90` | Theme alternate-background-color | 2 — Branding | LOW | 2 files |
| 8 | `b3fedfb19fb` | Theme tree item padding | 2 — Branding | LOW | 2 files |
| 9 | `0d4545b7d67` | Tree branch line SVGs | 2 — Branding | LOW — new files | 8 files |
| 10 | `434ae797a43` | Theme selector cleanup | 2 — Branding | **MEDIUM** — StartupProcess.cpp | 4 files |
| 11 | `224feda4ad6` | Catppuccin icon override infrastructure | 2 — Branding | **MEDIUM** — BitmapFactory.cpp, CMakeLists.txt | 2 files |
| 12 | `7535a48ec4c` | Origin abstraction layer | 1 — Extension | **HIGH** — Application.cpp, ApplicationPy.cpp/.h, CMakeLists.txt | 6 files (4 new) |
| 13 | `38358e431d2` | LocalFileOrigin and Std_* delegation | 1 — Extension | **HIGH** — CommandDoc.cpp, FileOrigin.cpp/.h | 3 files |
| 14 | `79c85ed2e5d` | FileOriginPython interactive methods | 1 — Extension | LOW — Kindred-only files | 3 files |
| 15 | `deeb6376f71` | OriginSelectorWidget | 1 — Extension | **HIGH** — Action.cpp/.h, CommandStd.cpp, Workbench.cpp, CMakeLists.txt | 8 files |
| 16 | `679aaec6d49` | Origin commands (Commit/Pull/Push) | 1 — Extension | **MEDIUM** — Application.cpp, Command.h, Workbench.cpp | 5 files |
| 17 | `db85277f262` | OriginManagerDialog | 1 — Extension | LOW — new files + OriginSelectorWidget.cpp | 3 files |
| 18 | `015df38328c` | Document-origin tracking in window title | 1 — Extension | **MEDIUM** — MDIView.cpp | 3 files |
| 19 | `a6e84552da5` | Cross-origin detection in SaveAs | 1 — Extension | **MEDIUM** — CommandDoc.cpp | 1 file |
| 20 | `84b69b935b2` | Build fix: remove SelectModule.h include | 1 — Extension | LOW | 1 file |
| 21 | `2f594dac0a5` | Use Python API for viewDefaultOrientation | 1 — Extension | **MEDIUM** — CommandDoc.cpp | 1 file |
| 22 | `724440dcb75` | Build fixes for OriginSelectorWidget/Manager | 1 — Extension | LOW — Kindred files | 2 files |
| 23 | `c858706d480` | Add silo icons to QRC | 2 — Branding | LOW — resource.qrc (additive) | 6 files |
| 24 | `d95c850b7b1` | Widen origin selector widget | 1 — Extension | LOW | 1 file |
| 25 | `10b5c9d584f` | Wire OriginManagerDialog to Silo_Settings | 1 — Extension | LOW | 1 file |
| 26 | `cc5ba638d1f` | UI polish — Wayland scaling, menu icon size | 3 — Bug fix | **HIGH** — DlgSettingsGeneral.cpp/.h/.ui changed upstream | 6 files |
| 27 | `4bf74cf3391` | Build fix for DlgSettingsGeneral | 3 — Bug fix | **MEDIUM** — DlgSettingsGeneral.h, StartupProcess.cpp | 2 files |
| 28 | `6773ca0dfd8` | Eliminate QSS/CFG duplication | 2 — Branding | LOW — Kindred files | 3 files |
| 29 | `977fa3c9347` | QGroupBox indicator, hyperlink color | 2 — Branding | LOW — KindredCreate.qss | 1 file |
| 30 | `8b2ce4b73a4` | Native Qt start panel + kindred:// URL | 1 — Extension | **MEDIUM** — MainWindow.cpp | 1 file |
| 31 | `bf637af4e45` | Window flickering and icon clipping fix | 3 — Bug fix | **MEDIUM** — MainWindow.cpp/.h | 3 files |
| 32 | `70118201b02` | MDI pre-document tab for Silo new item | 1 — Extension | **HIGH** — ApplicationPy, BreadcrumbToolBar, EditingContext, MainWindow, Workbench | 11 files |
| 33 | `1f49e3fa6da` | Build fix: ToolBarItem incomplete type, reportException | 3 — Bug fix | **LOW** — Kindred-specific build fix | 2 files |
| 34 | `f71decca089` | Splash screen: skip runtime draw, mantle bg | 2 — Branding | **MEDIUM** — SplashScreen.cpp | 3 files |
| 35 | `2b0c6774c07` | Dev build defaults, skip version migration | 2 — Branding | **MEDIUM** — CMakeLists.txt, DlgVersionMigrator.cpp | 2 files |
| 36 | `ab71902a4c2` | Forward visibility arg in appendToolbar() | 1 — Extension | LOW — FreeCADGuiInit.py | 1 file |
### Category summary
| Category | Count | Commits |
|----------|-------|---------|
| 1 — Extension | 16 | #1222, #2425, #30, #32, #36 |
| 2 — Branding | 16 | #111, #23, #2829, #3435 |
| 3 — Bug fix | 4 | #2627, #31, #33 |
### Category 3 — Upstream status (verified Feb 2026)
| # | Summary | Upstream Fixed? | FreeCAD Issues | Notes |
|---|---------|-----------------|----------------|-------|
| 26 | Wayland scaling, menu icon size pref | PARTIAL | [#25448](https://github.com/FreeCAD/FreeCAD/issues/25448), [#23830](https://github.com/FreeCAD/FreeCAD/issues/23830), [#23396](https://github.com/FreeCAD/FreeCAD/issues/23396) | Upstream has some HiDPI C++ fixes but Wayland fractional scaling still open. Menu icon size pref is a Kindred-added feature, not yet contributed. |
| 27 | Build fix for DlgSettingsGeneral | NO | — | Companion to #26. `setMenuIconSize()` in StartupProcess is Kindred-added. |
| 31 | Window flickering and icon clipping | NO | [#12917](https://github.com/FreeCAD/FreeCAD/issues/12917), [#18481](https://github.com/FreeCAD/FreeCAD/issues/18481) | Upstream still uses `setStyleSheet()` on statusBar causing repaint cascade. Good upstream PR candidate — replace with `setPalette()`. |
| 33 | ToolBarItem incomplete type, reportException | N/A | — | Kindred-internal build fix. The `ToolBarItem` forward-decl issue only manifests with Kindred modifications to Workbench.h. The `reportException` typo is in Kindred-only editing context code. |
### HIGH conflict files (need manual attention)
@@ -137,14 +162,14 @@ These files are modified by both Kindred and upstream. They will almost certainl
## Phase 3: Module-Level Changes
### Assembly fixes (check if still needed)
### Assembly fixes (verified Feb 2026)
| Hash | Summary | Status |
|------|---------|--------|
| `316d4f4b524` | Joint flip overconstrain fix | May be fixed upstream — verify |
| `9dc50cef727` | SIGSEGV during document restore | May be fixed upstream — verify |
| `ddefb236521` | Solver ignoring datum plane refs | May be fixed upstream — verify |
| `b7374d7b1fc` | findPlacement() datum/origin handling | May be fixed upstream — verify |
| Hash | Summary | Upstream Status | Action |
|------|---------|-----------------|--------|
| `316d4f4b524` | Joint flip overconstrain fix (91° rotation guard) | **NOT fixed** — upstream has basic grounded-object validation only. [FreeCAD#20377](https://github.com/FreeCAD/FreeCAD/issues/20377) open. | KEEP — re-apply |
| `9dc50cef727` | SIGSEGV during document restore (`isRestoring()` guard) | **NOT fixed** — upstream `onChanged()` has no restore guard. [FreeCAD#18225](https://github.com/FreeCAD/FreeCAD/issues/18225) closed via different path. | KEEP — re-apply |
| `ddefb236521` | Solver ignoring datum plane refs (`PartDesign::Plane`/`Point`) | **NOT fixed** — upstream `findPlacement()` lacks these types. | KEEP — re-apply, upstream candidate |
| `b7374d7b1fc` | findPlacement() datum/origin handling (`App::Plane`/`Point`) | **PARTIAL**`App::Line` fixed upstream via [PR#20026](https://github.com/FreeCAD/FreeCAD/pull/20026). `App::Plane`/`App::Point` still missing. | KEEP — re-apply the `Plane`/`Point` parts only |
Files touched: `src/Mod/Assembly/App/AssemblyObject.cpp`, `src/Mod/Assembly/UtilsAssembly.py`, `src/Mod/Assembly/InitGui.py`

View File

@@ -28,6 +28,7 @@
- [Repository Structure](./development/repo-structure.md)
- [Build System](./development/build-system.md)
- [Gui Module Build](./development/gui-build-integration.md)
- [Package.xml Schema Extensions](./development/package-xml-schema.md)
# Silo Server

View File

@@ -0,0 +1,109 @@
# Package.xml Schema Extensions
Kindred Create extends FreeCAD's standard `package.xml` addon manifest with a `<kindred>` element. This element provides metadata for the manifest-driven addon loader: version compatibility, load ordering, dependency declarations, and editing context registration.
The `<kindred>` element is ignored by FreeCAD's AddonManager and stock module loader. Addons with this element remain compatible with upstream FreeCAD.
## Field reference
| Field | Parsed by loader | Required | Default | Description |
|---|---|---|---|---|
| `min_create_version` | Yes | No | *(none)* | Minimum Kindred Create version. Addon is skipped if the running version is lower. |
| `max_create_version` | Yes | No | *(none)* | Maximum Kindred Create version. Addon is skipped if the running version is higher. |
| `load_priority` | Yes | No | `100` | Integer. Lower values load first. Used as a secondary sort after dependency resolution. |
| `dependencies` | Yes | No | *(none)* | List of addon names (by `<name>` in their `package.xml`) that must load before this one. |
| `sdk_version` | No | No | *(none)* | Required kindred-addon-sdk version. Reserved for future use when the SDK is available. |
| `pure_python` | No | No | `true` | If `false`, the addon requires compiled C++ components. Informational. |
| `contexts` | No | No | *(none)* | Editing contexts this addon registers or injects into. Informational. |
Fields marked "Parsed by loader" are read by `addon_loader.py` and affect load behavior. Other fields are informational metadata for tooling and documentation.
## Schema
```xml
<kindred>
<min_create_version>0.1.0</min_create_version>
<max_create_version>1.0.0</max_create_version>
<sdk_version>0.1.0</sdk_version>
<load_priority>100</load_priority>
<pure_python>true</pure_python>
<dependencies>
<dependency>sdk</dependency>
<dependency>other-addon</dependency>
</dependencies>
<contexts>
<context id="partdesign.body" action="inject"/>
<context id="sketcher.edit" action="register"/>
<context id="*" action="overlay"/>
</contexts>
</kindred>
```
All child elements are optional. An empty `<kindred/>` element is valid and signals that the addon is Kindred-aware with all defaults.
### Version fields
`min_create_version` and `max_create_version` are compared against the running Kindred Create version using semantic versioning (major.minor.patch). If the running version falls outside the declared range, the addon is skipped with a warning in the report view.
### Load priority
When multiple addons have no dependency relationship, `load_priority` determines their relative order. Lower values load first. Suggested ranges:
| Range | Use |
|---|---|
| 0-9 | SDK and core infrastructure |
| 10-49 | Foundation addons that others may depend on |
| 50-99 | Standard addons |
| 100+ | Optional or late-loading addons |
### Dependencies
Each `<dependency>` names another addon by its `<name>` element in `package.xml`. The loader resolves load order using topological sort. If a dependency is not found among discovered addons, the dependent addon is skipped.
### Contexts
The `<contexts>` element documents which editing contexts the addon interacts with. The `action` attribute describes the type of interaction:
| Action | Meaning |
|---|---|
| `inject` | Addon injects commands into this context's toolbars |
| `register` | Addon registers this as a new context |
| `overlay` | Addon registers an overlay that may apply across contexts |
A wildcard `id="*"` indicates the addon's overlay applies universally (matched by a condition function rather than a specific context ID).
## Example: complete package.xml
```xml
<?xml version="1.0" encoding="UTF-8"?>
<package format="1" xmlns="https://wiki.freecad.org/Package_Metadata">
<name>MyAddon</name>
<description>Example Kindred Create addon</description>
<version>0.2.0</version>
<maintainer email="dev@example.com">Developer</maintainer>
<license>LGPL-2.1-or-later</license>
<url type="repository">https://git.example.com/myaddon</url>
<content>
<workbench>
<classname>MyAddonWorkbench</classname>
<subdirectory>./</subdirectory>
</workbench>
</content>
<kindred>
<min_create_version>0.1.0</min_create_version>
<load_priority>80</load_priority>
<pure_python>true</pure_python>
<contexts>
<context id="partdesign.body" action="inject"/>
</contexts>
</kindred>
</package>
```
## Backward compatibility
- The `<kindred>` element sits outside `<content>` and is not part of FreeCAD's package.xml specification. FreeCAD's `App.Metadata` C++ parser and the AddonManager's Python `MetadataReader` both ignore unknown elements.
- An addon installed in stock FreeCAD will work normally; the `<kindred>` extensions are simply unused.
- The Kindred Create loader works with or without the `<kindred>` element. Addons that omit it load with no version constraints and default priority (100).

View File

@@ -73,25 +73,27 @@ database:
---
## Storage (MinIO/S3)
## Storage (Filesystem)
| Key | Type | Default | Env Override | Description |
|-----|------|---------|-------------|-------------|
| `storage.endpoint` | string | — | `SILO_MINIO_ENDPOINT` | MinIO/S3 endpoint (`host:port`) |
| `storage.access_key` | string | — | `SILO_MINIO_ACCESS_KEY` | Access key |
| `storage.secret_key` | string | — | `SILO_MINIO_SECRET_KEY` | Secret key |
| `storage.bucket` | string | — | — | S3 bucket name (created automatically if missing) |
| `storage.use_ssl` | bool | `false` | — | Use HTTPS for MinIO connections |
| `storage.region` | string | `"us-east-1"` | — | S3 region |
Files are stored on the local filesystem under a configurable root directory.
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| `storage.backend` | string | `"filesystem"` | Storage backend (`filesystem`) |
| `storage.filesystem.root_dir` | string | — | Root directory for file storage (required) |
```yaml
storage:
endpoint: "localhost:9000"
access_key: "" # use SILO_MINIO_ACCESS_KEY env var
secret_key: "" # use SILO_MINIO_SECRET_KEY env var
bucket: "silo-files"
use_ssl: false
region: "us-east-1"
backend: "filesystem"
filesystem:
root_dir: "/opt/silo/data"
```
Ensure the directory exists and is writable by the `silo` user:
```bash
sudo mkdir -p /opt/silo/data
sudo chown silo:silo /opt/silo/data
```
---
@@ -264,9 +266,6 @@ All environment variable overrides. These take precedence over values in `config
| `SILO_DB_NAME` | `database.name` | PostgreSQL database name |
| `SILO_DB_USER` | `database.user` | PostgreSQL user |
| `SILO_DB_PASSWORD` | `database.password` | PostgreSQL password |
| `SILO_MINIO_ENDPOINT` | `storage.endpoint` | MinIO endpoint |
| `SILO_MINIO_ACCESS_KEY` | `storage.access_key` | MinIO access key |
| `SILO_MINIO_SECRET_KEY` | `storage.secret_key` | MinIO secret key |
| `SILO_SESSION_SECRET` | `auth.session_secret` | Session cookie signing secret |
| `SILO_ADMIN_USERNAME` | `auth.local.default_admin_username` | Default admin username |
| `SILO_ADMIN_PASSWORD` | `auth.local.default_admin_password` | Default admin password |
@@ -296,11 +295,9 @@ database:
sslmode: "disable"
storage:
endpoint: "localhost:9000"
access_key: "minioadmin"
secret_key: "minioadmin"
bucket: "silo-files"
use_ssl: false
backend: "filesystem"
filesystem:
root_dir: "./data"
schemas:
directory: "./schemas"

View File

@@ -4,7 +4,7 @@
> instructions. This document covers ongoing maintenance and operations for an
> existing deployment.
This guide covers deploying Silo to a dedicated VM using external PostgreSQL and MinIO services.
This guide covers deploying Silo to a dedicated VM using external PostgreSQL and local filesystem storage.
## Table of Contents
@@ -26,28 +26,25 @@ This guide covers deploying Silo to a dedicated VM using external PostgreSQL and
│ │ silod │ │
│ │ (Silo API Server) │ │
│ │ :8080 │ │
│ │ Files: /opt/silo/data │ │
│ └───────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────┐ ┌─────────────────────────────────┐
│ psql.example.internal │ │ minio.example.internal │
│ PostgreSQL 16 │ │ MinIO S3 │
│ :5432 │ │ :9000 (API) │
│ │ │ :9001 (Console) │
└─────────────────────────┘ └─────────────────────────────────┘
┌─────────────────────────┐
│ psql.example.internal │
│ PostgreSQL 16 │
│ :5432 │
└─────────────────────────┘
```
## External Services
The following external services are already configured:
| Service | Host | Database/Bucket | User |
|---------|------|-----------------|------|
| Service | Host | Database | User |
|---------|------|----------|------|
| PostgreSQL | psql.example.internal:5432 | silo | silo |
| MinIO | minio.example.internal:9000 | silo-files | silouser |
Migrations have been applied to the database.
Files are stored on the local filesystem at `/opt/silo/data`. Migrations have been applied to the database.
---
@@ -107,21 +104,15 @@ Fill in the values:
# Database credentials (psql.example.internal)
SILO_DB_PASSWORD=your-database-password
# MinIO credentials (minio.example.internal)
SILO_MINIO_ACCESS_KEY=silouser
SILO_MINIO_SECRET_KEY=your-minio-secret-key
```
### Verify External Services
Before deploying, verify connectivity to external services:
Before deploying, verify connectivity to PostgreSQL:
```bash
# Test PostgreSQL
psql -h psql.example.internal -U silo -d silo -c 'SELECT 1'
# Test MinIO
curl -I http://minio.example.internal:9000/minio/health/live
```
---
@@ -183,6 +174,7 @@ sudo -E /opt/silo/src/scripts/deploy.sh
| File | Purpose |
|------|---------|
| `/opt/silo/bin/silod` | Server binary |
| `/opt/silo/data/` | File storage root |
| `/opt/silo/src/` | Git repository checkout |
| `/etc/silo/config.yaml` | Server configuration |
| `/etc/silo/silod.env` | Environment variables (secrets) |
@@ -242,7 +234,7 @@ sudo journalctl -u silod --since "2024-01-15 10:00:00"
# Basic health check
curl http://localhost:8080/health
# Full readiness check (includes DB and MinIO)
# Full readiness check (includes DB)
curl http://localhost:8080/ready
```
@@ -318,24 +310,6 @@ psql -h psql.example.internal -U silo -d silo -f /opt/silo/src/migrations/008_ne
3. Check `pg_hba.conf` on PostgreSQL server allows connections from this host.
### Connection Refused to MinIO
1. Test network connectivity:
```bash
nc -zv minio.example.internal 9000
```
2. Test with curl:
```bash
curl -I http://minio.example.internal:9000/minio/health/live
```
3. Check SSL settings in config match MinIO setup:
```yaml
storage:
use_ssl: true # or false
```
### Health Check Fails
```bash
@@ -345,7 +319,9 @@ curl -v http://localhost:8080/ready
# If ready fails but health passes, check external services
psql -h psql.example.internal -U silo -d silo -c 'SELECT 1'
curl http://minio.example.internal:9000/minio/health/live
# Check file storage directory
ls -la /opt/silo/data
```
### Build Fails
@@ -460,10 +436,9 @@ sudo systemctl reload nginx
- [ ] `/etc/silo/silod.env` has mode 600 (`chmod 600`)
- [ ] Database password is strong and unique
- [ ] MinIO credentials are specific to silo (not admin)
- [ ] SSL/TLS enabled for PostgreSQL (`sslmode: require`)
- [ ] SSL/TLS enabled for MinIO (`use_ssl: true`) if available
- [ ] HTTPS enabled via nginx reverse proxy
- [ ] File storage directory (`/opt/silo/data`) owned by `silo` user with mode 750
- [ ] Silod listens on localhost only (`host: 127.0.0.1`)
- [ ] Firewall allows only ports 80, 443 (not 8080)
- [ ] Service runs as non-root `silo` user

View File

@@ -76,7 +76,7 @@ See [ROADMAP.md](ROADMAP.md) for the platform roadmap and dependency tier struct
| Append-only revision history | Complete | `internal/db/items.go` |
| Sequential revision numbering | Complete | Database trigger |
| Property snapshots (JSONB) | Complete | `revisions.properties` |
| File versioning (MinIO) | Complete | `internal/storage/` |
| File storage (filesystem) | Complete | `internal/storage/` |
| SHA256 checksums | Complete | Captured on upload |
| Revision comments | Complete | `revisions.comment` |
| User attribution | Complete | `revisions.created_by` |
@@ -93,7 +93,7 @@ CREATE TABLE revisions (
revision_number INTEGER NOT NULL,
properties JSONB NOT NULL DEFAULT '{}',
file_key TEXT,
file_version TEXT, -- MinIO version ID
file_version TEXT, -- storage version ID
file_checksum TEXT, -- SHA256
file_size BIGINT,
thumbnail_key TEXT,
@@ -283,7 +283,7 @@ Effort: Medium | Priority: Low | Risk: Low
**Changes:**
- Add thumbnail generation on file upload
- Store in MinIO at `thumbnails/{part_number}/rev{n}.png`
- Store at `thumbnails/{part_number}/rev{n}.png`
- Expose via `GET /api/items/{pn}/thumbnail/{rev}`
---
@@ -377,7 +377,7 @@ internal/
relationships.go # BOM repository
projects.go # Project repository
storage/
storage.go # MinIO file storage helpers
storage.go # File storage helpers
migrations/
001_initial.sql # Core schema
...
@@ -572,7 +572,7 @@ Reporting capabilities are absent. Basic reports (item counts, revision activity
| Feature | SOLIDWORKS PDM | Silo Status | Priority | Complexity |
|---------|---------------|-------------|----------|------------|
| File versioning | Automatic | Full (MinIO) | - | - |
| File versioning | Automatic | Full (filesystem) | - | - |
| File preview | Thumbnails, 3D preview | None | Medium | Complex |
| File conversion | PDF, DXF generation | None | Medium | Complex |
| Replication | Multi-site sync | None | Low | Complex |

View File

@@ -3,7 +3,7 @@
This guide covers two installation methods:
- **[Option A: Docker Compose](#option-a-docker-compose)** — self-contained stack with all services. Recommended for evaluation, small teams, and environments where Docker is the standard.
- **[Option B: Daemon Install](#option-b-daemon-install-systemd--external-services)** — systemd service with external PostgreSQL, MinIO, and optional LDAP/nginx. Recommended for production deployments integrated with existing infrastructure.
- **[Option B: Daemon Install](#option-b-daemon-install-systemd--external-services)** — systemd service with external PostgreSQL and optional LDAP/nginx. Files are stored on the local filesystem. Recommended for production deployments integrated with existing infrastructure.
Both methods produce the same result: a running Silo server with a web UI, REST API, and authentication.
@@ -48,7 +48,7 @@ Regardless of which method you choose:
## Option A: Docker Compose
A single Docker Compose file runs everything: PostgreSQL, MinIO, OpenLDAP, and Silo. An optional nginx container can be enabled for reverse proxying.
A single Docker Compose file runs everything: PostgreSQL, OpenLDAP, and Silo. Files are stored on the local filesystem. An optional nginx container can be enabled for reverse proxying.
### A.1 Prerequisites
@@ -80,7 +80,6 @@ The setup script generates credentials and configuration files:
It prompts for:
- Server domain (default: `localhost`)
- PostgreSQL password (auto-generated if you press Enter)
- MinIO credentials (auto-generated)
- OpenLDAP admin password and initial user (auto-generated)
- Silo local admin account (fallback when LDAP is unavailable)
@@ -106,7 +105,7 @@ Wait for all services to become healthy:
docker compose -f deployments/docker-compose.allinone.yaml ps
```
You should see `silo-postgres`, `silo-minio`, `silo-openldap`, and `silo-api` all in a healthy state.
You should see `silo-postgres`, `silo-openldap`, and `silo-api` all in a healthy state.
View logs:
@@ -124,7 +123,7 @@ docker compose -f deployments/docker-compose.allinone.yaml logs -f silo
# Health check
curl http://localhost:8080/health
# Readiness check (includes database and storage connectivity)
# Readiness check (includes database connectivity)
curl http://localhost:8080/ready
```
@@ -226,7 +225,7 @@ The Silo container is rebuilt from the updated source. Database migrations in `m
## Option B: Daemon Install (systemd + External Services)
This method runs Silo as a systemd service on a dedicated host, connecting to externally managed PostgreSQL, MinIO, and optionally LDAP services.
This method runs Silo as a systemd service on a dedicated host, connecting to externally managed PostgreSQL and optionally LDAP services. Files are stored on the local filesystem.
### B.1 Architecture Overview
@@ -240,21 +239,22 @@ This method runs Silo as a systemd service on a dedicated host, connecting to ex
│ ┌───────▼────────┐ │
│ │ silod │ │
│ │ (API server) │ │
└──┬─────────┬───┘
└─────┼─────────┼──────┘
┌─────────────┐ ┌─────────────────
│ PostgreSQL 16│ │ MinIO (S3)
:5432 │ │ :9000 API │
└──────────────┘ │ :9001 Console
└──────────────────┘
│ Files: /opt/ │
│ │ silo/data │ │
│ └──────┬─────────┘
─────────────────────
┌───────────▼──┐
│ PostgreSQL 16
│ :5432 │
└──────────────┘
```
### B.2 Prerequisites
- Linux host (Debian/Ubuntu or RHEL/Fedora/AlmaLinux)
- Root or sudo access
- Network access to your PostgreSQL and MinIO servers
- Network access to your PostgreSQL server
The setup script installs Go and other build dependencies automatically.
@@ -281,26 +281,6 @@ Verify:
psql -h YOUR_PG_HOST -U silo -d silo -c 'SELECT 1'
```
#### MinIO
Install MinIO and create a bucket and service account:
- [MinIO quickstart](https://min.io/docs/minio/linux/index.html)
```bash
# Using the MinIO client (mc):
mc alias set local http://YOUR_MINIO_HOST:9000 minioadmin minioadmin
mc mb local/silo-files
mc admin user add local silouser YOUR_MINIO_SECRET
mc admin policy attach local readwrite --user silouser
```
Verify:
```bash
curl -I http://YOUR_MINIO_HOST:9000/minio/health/live
```
#### LDAP / FreeIPA (Optional)
For LDAP authentication, you need an LDAP server with user and group entries. Options:
@@ -339,10 +319,10 @@ The script:
4. Clones the repository
5. Creates the environment file template
To override the default service hostnames:
To override the default database hostname:
```bash
SILO_DB_HOST=db.example.com SILO_MINIO_HOST=s3.example.com sudo -E bash scripts/setup-host.sh
SILO_DB_HOST=db.example.com sudo -E bash scripts/setup-host.sh
```
### B.5 Configure Credentials
@@ -357,10 +337,6 @@ sudo nano /etc/silo/silod.env
# Database
SILO_DB_PASSWORD=your-database-password
# MinIO
SILO_MINIO_ACCESS_KEY=silouser
SILO_MINIO_SECRET_KEY=your-minio-secret
# Authentication
SILO_SESSION_SECRET=generate-a-long-random-string
SILO_ADMIN_USERNAME=admin
@@ -379,7 +355,7 @@ Review the server configuration:
sudo nano /etc/silo/config.yaml
```
Update `database.host`, `storage.endpoint`, `server.base_url`, and authentication settings for your environment. See [CONFIGURATION.md](CONFIGURATION.md) for all options.
Update `database.host`, `storage.filesystem.root_dir`, `server.base_url`, and authentication settings for your environment. See [CONFIGURATION.md](CONFIGURATION.md) for all options.
### B.6 Deploy
@@ -412,10 +388,10 @@ sudo /opt/silo/src/scripts/deploy.sh --restart-only
sudo /opt/silo/src/scripts/deploy.sh --status
```
To override the target host or database host:
To override the target host:
```bash
SILO_DEPLOY_TARGET=silo.example.com SILO_DB_HOST=db.example.com sudo -E scripts/deploy.sh
SILO_DEPLOY_TARGET=silo.example.com sudo -E scripts/deploy.sh
```
### B.7 Set Up Nginx and TLS

View File

@@ -0,0 +1,485 @@
# .kc Server-Side Metadata Integration
**Status:** Draft
**Date:** February 2026
---
## 1. Purpose
When a `.kc` file is committed to Silo, the server extracts and indexes the `silo/` directory contents so that metadata is queryable, diffable, and streamable without downloading the full file. This document specifies the server-side processing pipeline, database storage, API endpoints, and SSE events that support the Create viewport widgets defined in [SILO_VIEWPORT.md](SILO_VIEWPORT.md).
The core principle: **the `.kc` file is the transport format; Silo is the index.** The `silo/` directory entries are extracted into database columns on commit and packed back into the ZIP on checkout. The server never modifies the FreeCAD standard zone (`Document.xml`, `.brp` files, `thumbnails/`).
---
## 2. Commit Pipeline
When a `.kc` file is uploaded via `POST /api/items/{partNumber}/file`, the server runs an extraction pipeline before returning success.
### 2.1 Pipeline Steps
```
Client uploads .kc file
|
v
+-----------------------------+
| 1. Store file to disk | (existing behavior -- unchanged)
| items/{pn}/rev{N}.kc |
+-----------------------------+
|
v
+-----------------------------+
| 2. Open ZIP, read silo/ |
| Parse each entry |
+-----------------------------+
|
v
+-----------------------------+
| 3. Validate manifest.json |
| - UUID matches item |
| - kc_version supported |
| - revision_hash present |
+-----------------------------+
|
v
+-----------------------------+
| 4. Index metadata |
| - Upsert item_metadata |
| - Upsert dependencies |
| - Append history entry |
| - Snapshot approvals |
| - Register macros |
| - Register job defs |
+-----------------------------+
|
v
+-----------------------------+
| 5. Broadcast SSE events |
| - revision.created |
| - metadata.updated |
| - bom.changed (if deps |
| differ from previous) |
+-----------------------------+
|
v
Return 201 Created
```
### 2.2 Validation Rules
| Check | Failure response |
|-------|-----------------|
| `silo/manifest.json` missing | `400 Bad Request` -- file is `.fcstd` not `.kc` |
| `manifest.uuid` doesn't match item's UUID | `409 Conflict` -- wrong item |
| `manifest.kc_version` > server's supported version | `422 Unprocessable` -- client newer than server |
| `manifest.revision_hash` matches current head | `200 OK` (no-op, file unchanged) |
| Any `silo/` JSON fails to parse | `422 Unprocessable` with path and parse error |
If validation fails, the blob is still stored (the user uploaded it), but no metadata indexing occurs. The item's revision is created with a `metadata_error` flag so the web UI can surface the problem.
### 2.3 Backward Compatibility
Plain `.fcstd` files (no `silo/` directory) continue to work exactly as today -- stored on disk, revision created, no metadata extraction. The pipeline short-circuits at step 2 when no `silo/` directory is found.
---
## 3. Database Schema
### 3.1 `item_metadata` Table
Stores the indexed contents of `silo/metadata.json` as structured JSONB, searchable and filterable via the existing item query endpoints.
```sql
CREATE TABLE item_metadata (
item_id UUID PRIMARY KEY REFERENCES items(id) ON DELETE CASCADE,
schema_name TEXT,
tags TEXT[] NOT NULL DEFAULT '{}',
lifecycle_state TEXT NOT NULL DEFAULT 'draft',
fields JSONB NOT NULL DEFAULT '{}',
kc_version TEXT,
manifest_uuid UUID,
silo_instance TEXT,
revision_hash TEXT,
updated_at TIMESTAMPTZ DEFAULT now(),
updated_by TEXT
);
CREATE INDEX idx_item_metadata_tags ON item_metadata USING GIN (tags);
CREATE INDEX idx_item_metadata_lifecycle ON item_metadata (lifecycle_state);
CREATE INDEX idx_item_metadata_fields ON item_metadata USING GIN (fields);
```
On commit, the server upserts this row from `silo/manifest.json` and `silo/metadata.json`. The `fields` column contains the schema-driven key-value pairs exactly as they appear in the JSON.
### 3.2 `item_dependencies` Table
Stores the indexed contents of `silo/dependencies.json`. Replaces the BOM for assembly relationships that originate from the CAD model.
```sql
CREATE TABLE item_dependencies (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
parent_item_id UUID REFERENCES items(id) ON DELETE CASCADE,
child_uuid UUID NOT NULL,
child_part_number TEXT,
child_revision INTEGER,
quantity DECIMAL,
label TEXT,
relationship TEXT NOT NULL DEFAULT 'component',
revision_number INTEGER NOT NULL,
created_at TIMESTAMPTZ DEFAULT now()
);
CREATE INDEX idx_item_deps_parent ON item_dependencies (parent_item_id);
CREATE INDEX idx_item_deps_child ON item_dependencies (child_uuid);
```
This table complements the existing `relationships` table. The `relationships` table is the server-authoritative BOM (editable via the web UI and API). The `item_dependencies` table is the CAD-authoritative record extracted from the file. BOM merge (per [BOM_MERGE.md](BOM_MERGE.md)) reconciles the two.
### 3.3 `item_approvals` Table
Stores the indexed contents of `silo/approvals.json`. Server-authoritative -- the `.kc` snapshot is a read cache.
```sql
CREATE TABLE item_approvals (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
item_id UUID REFERENCES items(id) ON DELETE CASCADE,
eco_number TEXT,
state TEXT NOT NULL DEFAULT 'draft',
updated_at TIMESTAMPTZ DEFAULT now(),
updated_by TEXT
);
CREATE TABLE approval_signatures (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
approval_id UUID REFERENCES item_approvals(id) ON DELETE CASCADE,
username TEXT NOT NULL,
role TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'pending',
signed_at TIMESTAMPTZ,
comment TEXT
);
```
These tables exist independent of `.kc` commits -- approvals are created and managed through the web UI and API. On `.kc` checkout, the current approval state is serialized into `silo/approvals.json` for offline display.
### 3.4 `item_macros` Table
Registers macros from `silo/macros/` for server-side discoverability and the future Macro Store module.
```sql
CREATE TABLE item_macros (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
item_id UUID REFERENCES items(id) ON DELETE CASCADE,
filename TEXT NOT NULL,
trigger TEXT NOT NULL DEFAULT 'manual',
content TEXT NOT NULL,
revision_number INTEGER NOT NULL,
created_at TIMESTAMPTZ DEFAULT now(),
UNIQUE(item_id, filename)
);
```
---
## 4. API Endpoints
These endpoints serve the viewport widgets in Create. All are under `/api/items/{partNumber}` and follow the existing auth model.
### 4.1 Metadata
| Method | Path | Auth | Description |
|--------|------|------|-------------|
| `GET` | `/metadata` | viewer | Get indexed metadata (schema fields, tags, lifecycle) |
| `PUT` | `/metadata` | editor | Update metadata fields from client |
| `PATCH` | `/metadata/lifecycle` | editor | Transition lifecycle state |
| `PATCH` | `/metadata/tags` | editor | Add/remove tags |
**`GET /api/items/{partNumber}/metadata`**
Returns the indexed metadata for viewport display. This is the fast path -- reads from `item_metadata` rather than downloading and parsing the `.kc` ZIP.
```json
{
"schema_name": "mechanical-part-v2",
"lifecycle_state": "draft",
"tags": ["structural", "aluminum"],
"fields": {
"material": "6061-T6",
"finish": "anodized",
"weight_kg": 0.34,
"category": "bracket"
},
"manifest": {
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"silo_instance": "https://silo.example.com",
"revision_hash": "a1b2c3d4e5f6",
"kc_version": "1.0"
},
"updated_at": "2026-02-13T20:30:00Z",
"updated_by": "joseph"
}
```
**`PUT /api/items/{partNumber}/metadata`**
Accepts a partial update of schema fields. The server merges into the existing `fields` JSONB. This is the write-back path for the Metadata Editor widget.
```json
{
"fields": {
"material": "7075-T6",
"weight_kg": 0.31
}
}
```
The server validates field names against the schema descriptor. Unknown fields are rejected with `422`.
**`PATCH /api/items/{partNumber}/metadata/lifecycle`**
Transitions lifecycle state. The server validates the transition is permitted (e.g., `draft` -> `review` is allowed, `released` -> `draft` is not without admin override).
```json
{ "state": "review" }
```
### 4.2 Dependencies
| Method | Path | Auth | Description |
|--------|------|------|-------------|
| `GET` | `/dependencies` | viewer | Get CAD-extracted dependency list |
| `GET` | `/dependencies/resolve` | viewer | Resolve UUIDs to current part numbers and file status |
**`GET /api/items/{partNumber}/dependencies`**
Returns the raw dependency list from the last `.kc` commit.
**`GET /api/items/{partNumber}/dependencies/resolve`**
Returns the dependency list with each UUID resolved to its current part number, revision, and whether the file exists on disk. This is what the Dependency Table widget calls to populate the status column.
```json
{
"links": [
{
"uuid": "660e8400-...",
"part_number": "KC-BRK-0042",
"label": "Base Plate",
"revision": 2,
"quantity": 1,
"resolved": true,
"file_available": true
},
{
"uuid": "770e8400-...",
"part_number": "KC-HDW-0108",
"label": "M6 SHCS",
"revision": 1,
"quantity": 4,
"resolved": true,
"file_available": true
},
{
"uuid": "880e8400-...",
"part_number": null,
"label": "Cover Panel",
"revision": 1,
"quantity": 1,
"resolved": false,
"file_available": false
}
]
}
```
### 4.3 Approvals
| Method | Path | Auth | Description |
|--------|------|------|-------------|
| `GET` | `/approvals` | viewer | Get current approval state |
| `POST` | `/approvals` | editor | Create ECO / start approval workflow |
| `POST` | `/approvals/{id}/sign` | editor | Sign (approve/reject) |
These endpoints power the Approvals Viewer widget. The viewer is read-only in Create -- sign actions happen in the web UI, but the API exists for both.
### 4.4 Macros
| Method | Path | Auth | Description |
|--------|------|------|-------------|
| `GET` | `/macros` | viewer | List registered macros |
| `GET` | `/macros/{filename}` | viewer | Get macro source |
Read-only server-side. Macros are authored in Create and committed inside the `.kc`. The server indexes them for discoverability in the future Macro Store.
### 4.5 Existing Endpoints (unchanged)
The viewport widgets also consume these existing endpoints:
| Widget | Endpoint | Purpose |
|--------|----------|---------|
| History Viewer | `GET /api/items/{pn}/revisions` | Full revision list |
| History Viewer | `GET /api/items/{pn}/revisions/compare` | Property diff |
| Job Viewer | `GET /api/jobs?item={pn}&definition={name}&limit=1` | Last job run |
| Job Viewer | `POST /api/jobs` | Trigger job |
| Job Viewer | `GET /api/jobs/{id}/logs` | Job log |
| Manifest Viewer | `GET /api/items/{pn}` | Item details (UUID, etc.) |
No changes needed to these -- they already exist and return the data the widgets need.
---
## 5. Checkout Pipeline
When a client downloads a `.kc` via `GET /api/items/{partNumber}/file`, the server packs current server-side state into the `silo/` directory before serving the file. This ensures the client always gets the latest metadata, even if it was edited via the web UI since the last commit.
### 5.1 Pipeline Steps
```
Client requests file download
|
v
+-----------------------------+
| 1. Read .kc from disk |
+-----------------------------+
|
v
+-----------------------------+
| 2. Pack silo/ from DB |
| - manifest.json (item) |
| - metadata.json (index) |
| - history.json (revs) |
| - approvals.json (ECO) |
| - dependencies.json |
| - macros/ (index) |
| - jobs/ (job defs) |
+-----------------------------+
|
v
+-----------------------------+
| 3. Replace silo/ in ZIP |
| Remove old entries |
| Write packed entries |
+-----------------------------+
|
v
Stream .kc to client
```
### 5.2 Packing Rules
| `silo/` entry | Source | Notes |
|---------------|--------|-------|
| `manifest.json` | `item_metadata` + `items` table | UUID from item, revision_hash from latest revision |
| `metadata.json` | `item_metadata.fields` + tags + lifecycle | Serialized from indexed columns |
| `history.json` | `revisions` table | Last 20 revisions for this item |
| `approvals.json` | `item_approvals` + `approval_signatures` | Current ECO state, omitted if no active ECO |
| `dependencies.json` | `item_dependencies` | Current revision's dependency list |
| `macros/*.py` | `item_macros` | All registered macros |
| `jobs/*.yaml` | `job_definitions` filtered by item type | Job definitions matching this item's trigger filters |
### 5.3 Caching
Packing the `silo/` directory on every download has a cost. To mitigate:
- **ETag header**: The response includes an ETag computed from the revision number + metadata `updated_at`. If the client sends `If-None-Match`, the server can return `304 Not Modified`.
- **Lazy packing**: If the `.kc` blob's `silo/manifest.json` revision_hash matches the current head *and* `item_metadata.updated_at` is older than the blob's upload time, skip repacking entirely -- the blob is already current.
---
## 6. SSE Events
The viewport widgets subscribe to SSE for live updates. These events are broadcast when server-side metadata changes, whether via `.kc` commit, web UI edit, or API call.
| Event | Payload | Trigger |
|-------|---------|---------|
| `metadata.updated` | `{part_number, changed_fields[], lifecycle_state, updated_by}` | Metadata PUT/PATCH |
| `metadata.lifecycle` | `{part_number, from_state, to_state, updated_by}` | Lifecycle transition |
| `metadata.tags` | `{part_number, added[], removed[]}` | Tag add/remove |
| `approval.created` | `{part_number, eco_number, state}` | ECO created |
| `approval.signed` | `{part_number, eco_number, user, role, status}` | Approver action |
| `approval.completed` | `{part_number, eco_number, final_state}` | All approvers acted |
| `dependencies.changed` | `{part_number, added[], removed[], changed[]}` | Dependency diff on commit |
Existing events (`revision.created`, `job.*`, `bom.changed`) continue to work as documented in [SPECIFICATION.md](SPECIFICATION.md) and [WORKERS.md](WORKERS.md).
### 6.1 Widget Subscription Map
| Viewport widget | Subscribes to |
|-----------------|---------------|
| Manifest Viewer | -- (read-only, no live updates) |
| Metadata Editor | `metadata.updated`, `metadata.lifecycle`, `metadata.tags` |
| History Viewer | `revision.created` |
| Approvals Viewer | `approval.created`, `approval.signed`, `approval.completed` |
| Dependency Table | `dependencies.changed` |
| Job Viewer | `job.created`, `job.progress`, `job.completed`, `job.failed` |
| Macro Editor | -- (local-only until committed) |
---
## 7. Web UI Integration
The Silo web UI also benefits from indexed metadata. These are additions to existing pages, not new pages.
### 7.1 Items Page
The item detail panel gains a **Metadata** tab (alongside Main, Properties, Revisions, BOM, Where Used) showing the schema-driven form from `GET /api/items/{pn}/metadata`. Editable for editors.
### 7.2 Items List
New filterable columns: `lifecycle_state`, `tags`. The existing search endpoint gains metadata-aware filtering:
```
GET /api/items?lifecycle=released&tag=aluminum
GET /api/items/search?q=bracket&lifecycle=draft
```
### 7.3 Approvals Page
A new page accessible from the top navigation (visible when a future `approvals` module is enabled). Lists all active ECOs with their approval progress.
---
## 8. Migration
### 8.1 Database Migration
A single migration adds the `item_metadata`, `item_dependencies`, `item_approvals`, `approval_signatures`, and `item_macros` tables. Existing items have no metadata rows -- they're created on first `.kc` commit or via `PUT /api/items/{pn}/metadata`.
### 8.2 Backfill
For items that already have `.kc` files stored on disk (committed before this feature), an admin endpoint re-runs the extraction pipeline:
```
POST /api/admin/reindex-metadata
```
This iterates all items with `.kc` files, opens each ZIP, and indexes the `silo/` contents. Idempotent -- safe to run multiple times.
---
## 9. Implementation Order
| Phase | Server work | Supports client phase |
|-------|------------|----------------------|
| 1 | `item_metadata` table + `GET/PUT /metadata` + commit extraction | SILO_VIEWPORT Phase 1-2 (Manifest, Metadata) |
| 2 | Pack `silo/` on checkout + ETag caching | SILO_VIEWPORT Phase 1-3 |
| 3 | `item_dependencies` table + `/dependencies/resolve` | SILO_VIEWPORT Phase 5 (Dependency Table) |
| 4 | `item_macros` table + `/macros` endpoints | SILO_VIEWPORT Phase 6 (Macro Editor) |
| 5 | `item_approvals` tables + `/approvals` endpoints | SILO_VIEWPORT Phase 7 (Approvals Viewer) |
| 6 | SSE events for metadata/approvals/dependencies | SILO_VIEWPORT Phase 8 (Live integration) |
| 7 | Web UI metadata tab + list filters | Independent of client |
Phases 1-2 are prerequisite for the viewport to work with live data. Phases 3-6 can be built in parallel with client widget development. Phase 7 is web-UI-only and independent.
---
## 10. References
- [SILO_VIEWPORT.md](SILO_VIEWPORT.md) -- Client-side viewport widget specification
- [KC_SPECIFICATION.md](KC_SPECIFICATION.md) -- .kc file format specification
- [SPECIFICATION.md](SPECIFICATION.md) -- Silo server API reference
- [BOM_MERGE.md](BOM_MERGE.md) -- BOM merge rules (dependency reconciliation)
- [WORKERS.md](WORKERS.md) -- Job queue (job viewer data source)
- [MODULES.md](MODULES.md) -- Module system (approval module gating)
- [ROADMAP.md](ROADMAP.md) -- Platform roadmap tiers

View File

@@ -0,0 +1,749 @@
# Module System Specification
**Status:** Draft
**Last Updated:** 2026-02-14
---
## 1. Purpose
Silo's module system defines the boundary between required infrastructure and optional capabilities. Each module groups a set of API endpoints, UI views, and configuration parameters. Modules can be enabled or disabled at runtime by administrators via the web UI, and clients can query which modules are active to adapt their feature set.
The goal: after initial deployment (where `config.yaml` sets database, storage, and server bind), all further operational configuration happens through the admin settings UI. The YAML file becomes the bootstrap; the database becomes the runtime source of truth.
---
## 2. Module Registry
### 2.1 Required Modules
These cannot be disabled. They define what Silo *is*.
| Module ID | Name | Description |
|-----------|------|-------------|
| `core` | Core PDM | Items, revisions, files, BOM, search, import/export, part number generation |
| `schemas` | Schemas | Part numbering schema parsing, segment management, form descriptors |
| `storage` | Storage | MinIO/S3 file storage, presigned uploads, versioning |
### 2.2 Optional Modules
| Module ID | Name | Default | Description |
|-----------|------|---------|-------------|
| `auth` | Authentication | `true` | Local, LDAP, OIDC authentication and RBAC |
| `projects` | Projects | `true` | Project management and item tagging |
| `audit` | Audit | `true` | Audit logging, completeness scoring |
| `odoo` | Odoo ERP | `false` | Odoo integration (config, sync-log, push/pull) |
| `freecad` | Create Integration | `true` | URI scheme, executable path, client settings |
| `jobs` | Job Queue | `false` | Async compute jobs, runner management |
| `dag` | Dependency DAG | `false` | Feature DAG sync, validation states, interference detection |
### 2.3 Module Dependencies
Some modules require others to function:
| Module | Requires |
|--------|----------|
| `dag` | `jobs` |
| `jobs` | `auth` (runner tokens) |
| `odoo` | `auth` |
When enabling a module, its dependencies are validated. The server rejects enabling `dag` without `jobs`. Disabling a module that others depend on shows a warning listing dependents.
---
## 3. Endpoint-to-Module Mapping
### 3.1 `core` (required)
```
# Health
GET /health
GET /ready
# Items
GET /api/items
GET /api/items/search
GET /api/items/by-uuid/{uuid}
GET /api/items/export.csv
GET /api/items/template.csv
GET /api/items/export.ods
GET /api/items/template.ods
POST /api/items
POST /api/items/import
POST /api/items/import.ods
GET /api/items/{partNumber}
PUT /api/items/{partNumber}
DELETE /api/items/{partNumber}
# Revisions
GET /api/items/{partNumber}/revisions
GET /api/items/{partNumber}/revisions/compare
GET /api/items/{partNumber}/revisions/{revision}
POST /api/items/{partNumber}/revisions
PATCH /api/items/{partNumber}/revisions/{revision}
POST /api/items/{partNumber}/revisions/{revision}/rollback
# Files
GET /api/items/{partNumber}/files
GET /api/items/{partNumber}/file
GET /api/items/{partNumber}/file/{revision}
POST /api/items/{partNumber}/file
POST /api/items/{partNumber}/files
DELETE /api/items/{partNumber}/files/{fileId}
PUT /api/items/{partNumber}/thumbnail
POST /api/uploads/presign
# BOM
GET /api/items/{partNumber}/bom
GET /api/items/{partNumber}/bom/expanded
GET /api/items/{partNumber}/bom/flat
GET /api/items/{partNumber}/bom/cost
GET /api/items/{partNumber}/bom/where-used
GET /api/items/{partNumber}/bom/export.csv
GET /api/items/{partNumber}/bom/export.ods
POST /api/items/{partNumber}/bom
POST /api/items/{partNumber}/bom/import
POST /api/items/{partNumber}/bom/merge
PUT /api/items/{partNumber}/bom/{childPartNumber}
DELETE /api/items/{partNumber}/bom/{childPartNumber}
# .kc Metadata
GET /api/items/{partNumber}/metadata
PUT /api/items/{partNumber}/metadata
PATCH /api/items/{partNumber}/metadata/lifecycle
PATCH /api/items/{partNumber}/metadata/tags
# .kc Dependencies
GET /api/items/{partNumber}/dependencies
GET /api/items/{partNumber}/dependencies/resolve
# .kc Macros
GET /api/items/{partNumber}/macros
GET /api/items/{partNumber}/macros/{filename}
# Part Number Generation
POST /api/generate-part-number
# Sheets
POST /api/sheets/diff
# Settings & Modules (admin)
GET /api/modules
GET /api/admin/settings
GET /api/admin/settings/{module}
PUT /api/admin/settings/{module}
POST /api/admin/settings/{module}/test
```
### 3.2 `schemas` (required)
```
GET /api/schemas
GET /api/schemas/{name}
GET /api/schemas/{name}/form
POST /api/schemas/{name}/segments/{segment}/values
PUT /api/schemas/{name}/segments/{segment}/values/{code}
DELETE /api/schemas/{name}/segments/{segment}/values/{code}
```
### 3.3 `storage` (required)
No dedicated endpoints — storage is consumed internally by file upload/download in `core`. Exposed through admin settings for connection status visibility.
### 3.4 `auth`
```
# Public (login flow)
GET /login
POST /login
POST /logout
GET /auth/oidc
GET /auth/callback
# Authenticated
GET /api/auth/me
GET /api/auth/tokens
POST /api/auth/tokens
DELETE /api/auth/tokens/{id}
# Web UI
GET /settings (account info, tokens)
POST /settings/tokens
POST /settings/tokens/{id}/revoke
```
When `auth` is disabled, all routes are open and a synthetic `dev` admin user is injected (current behavior).
### 3.5 `projects`
```
GET /api/projects
GET /api/projects/{code}
GET /api/projects/{code}/items
GET /api/projects/{code}/sheet.ods
POST /api/projects
PUT /api/projects/{code}
DELETE /api/projects/{code}
# Item-project tagging
GET /api/items/{partNumber}/projects
POST /api/items/{partNumber}/projects
DELETE /api/items/{partNumber}/projects/{code}
```
When disabled: project tag endpoints return `404`, project columns are hidden in UI list views, project filter is removed from item search.
### 3.6 `audit`
```
GET /api/audit/completeness
GET /api/audit/completeness/{partNumber}
```
When disabled: audit log table continues to receive writes (it's part of core middleware), but the completeness scoring endpoints and the Audit page in the web UI are hidden. Future: retention policies, export, and compliance reporting endpoints live here.
### 3.7 `odoo`
```
GET /api/integrations/odoo/config
GET /api/integrations/odoo/sync-log
PUT /api/integrations/odoo/config
POST /api/integrations/odoo/test-connection
POST /api/integrations/odoo/sync/push/{partNumber}
POST /api/integrations/odoo/sync/pull/{odooId}
```
### 3.8 `freecad`
No dedicated API endpoints currently. Configures URI scheme and executable path used by the web UI's "Open in Create" links and by CLI operations. Future: client configuration distribution endpoint.
### 3.9 `jobs`
```
# User-facing
GET /api/jobs
GET /api/jobs/{jobID}
GET /api/jobs/{jobID}/logs
POST /api/jobs
POST /api/jobs/{jobID}/cancel
# Job definitions
GET /api/job-definitions
GET /api/job-definitions/{name}
POST /api/job-definitions/reload
# Runner management (admin)
GET /api/runners
POST /api/runners
DELETE /api/runners/{runnerID}
# Runner-facing (runner token auth)
POST /api/runner/heartbeat
POST /api/runner/claim
PUT /api/runner/jobs/{jobID}/progress
POST /api/runner/jobs/{jobID}/complete
POST /api/runner/jobs/{jobID}/fail
POST /api/runner/jobs/{jobID}/log
PUT /api/runner/jobs/{jobID}/dag
```
### 3.10 `dag`
```
GET /api/items/{partNumber}/dag
GET /api/items/{partNumber}/dag/forward-cone/{nodeKey}
GET /api/items/{partNumber}/dag/dirty
PUT /api/items/{partNumber}/dag
POST /api/items/{partNumber}/dag/mark-dirty/{nodeKey}
```
---
## 4. Disabled Module Behavior
When a module is disabled:
1. **API routes** registered by that module return `404 Not Found` with body `{"error": "module '<id>' is not enabled"}`.
2. **Web UI** hides the module's navigation entry, page, and any inline UI elements (e.g., project tags on item cards).
3. **SSE events** from the module are not broadcast.
4. **Background goroutines** (e.g., job timeout sweeper, runner heartbeat checker) are not started.
5. **Database tables** are not dropped — they remain for re-enablement. No data loss on disable/enable cycle.
Implementation: each module's route group is wrapped in a middleware check:
```go
func RequireModule(id string) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !modules.IsEnabled(id) {
http.Error(w, `{"error":"module '`+id+`' is not enabled"}`, 404)
return
}
next.ServeHTTP(w, r)
})
}
}
```
---
## 5. Configuration Persistence
### 5.1 Precedence
```
Environment variables (highest — always wins, secrets live here)
Database overrides (admin UI writes here)
config.yaml (lowest — bootstrap defaults)
```
### 5.2 Database Table
```sql
-- Migration 014_settings.sql
CREATE TABLE settings_overrides (
key TEXT PRIMARY KEY, -- dotted path: "auth.ldap.enabled"
value JSONB NOT NULL, -- typed value
updated_by TEXT NOT NULL, -- username
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE module_state (
module_id TEXT PRIMARY KEY, -- "auth", "projects", etc.
enabled BOOLEAN NOT NULL,
updated_by TEXT NOT NULL,
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
```
### 5.3 Load Sequence
On startup:
1. Parse `config.yaml` into Go config struct.
2. Query `settings_overrides` — merge each key into the struct using dotted path resolution.
3. Apply environment variable overrides (existing `SILO_*` vars).
4. Query `module_state` — override default enabled/disabled from YAML.
5. Validate module dependencies.
6. Register only enabled modules' route groups.
7. Start only enabled modules' background goroutines.
### 5.4 Runtime Updates
When an admin saves settings via `PUT /api/admin/settings/{module}`:
1. Validate the payload against the module's config schema.
2. Write changed keys to `settings_overrides`.
3. Update `module_state` if `enabled` changed.
4. Apply changes to the in-memory config (hot reload where safe).
5. Broadcast `settings.changed` SSE event with `{module, enabled, changed_keys}`.
6. For changes that require restart (e.g., `server.port`, `database.*`), return a `restart_required: true` flag in the response. The UI shows a banner.
### 5.5 What Requires Restart
| Config Area | Hot Reload | Restart Required |
|-------------|-----------|------------------|
| Module enable/disable | Yes | No |
| `auth.*` provider toggles | Yes | No |
| `auth.cors.allowed_origins` | Yes | No |
| `odoo.*` connection settings | Yes | No |
| `freecad.*` | Yes | No |
| `jobs.*` timeouts, directory | Yes | No |
| `server.host`, `server.port` | No | Yes |
| `database.*` | No | Yes |
| `storage.*` | No | Yes |
| `schemas.directory` | No | Yes |
---
## 6. Public Module Discovery Endpoint
```
GET /api/modules
```
**No authentication required.** Clients need this pre-login to know whether OIDC is available, whether projects exist, etc.
### 6.1 Response
```json
{
"modules": {
"core": {
"enabled": true,
"required": true,
"name": "Core PDM",
"version": "0.2"
},
"schemas": {
"enabled": true,
"required": true,
"name": "Schemas"
},
"storage": {
"enabled": true,
"required": true,
"name": "Storage"
},
"auth": {
"enabled": true,
"required": false,
"name": "Authentication",
"config": {
"local_enabled": true,
"ldap_enabled": true,
"oidc_enabled": true,
"oidc_issuer_url": "https://keycloak.example.com/realms/silo"
}
},
"projects": {
"enabled": true,
"required": false,
"name": "Projects"
},
"audit": {
"enabled": true,
"required": false,
"name": "Audit"
},
"odoo": {
"enabled": false,
"required": false,
"name": "Odoo ERP"
},
"freecad": {
"enabled": true,
"required": false,
"name": "Create Integration",
"config": {
"uri_scheme": "silo"
}
},
"jobs": {
"enabled": false,
"required": false,
"name": "Job Queue"
},
"dag": {
"enabled": false,
"required": false,
"name": "Dependency DAG",
"depends_on": ["jobs"]
}
},
"server": {
"version": "0.2",
"read_only": false
}
}
```
The `config` sub-object exposes only public, non-secret metadata needed by clients. Never includes passwords, tokens, or secret keys.
---
## 7. Admin Settings Endpoints
### 7.1 Get All Settings
```
GET /api/admin/settings
Authorization: Bearer <admin token>
```
Returns full config grouped by module with secrets redacted:
```json
{
"core": {
"server": {
"host": "0.0.0.0",
"port": 8080,
"base_url": "https://silo.example.com",
"read_only": false
}
},
"schemas": {
"directory": "/etc/silo/schemas",
"default": "kindred-rd"
},
"storage": {
"endpoint": "minio:9000",
"bucket": "silo-files",
"access_key": "****",
"secret_key": "****",
"use_ssl": false,
"region": "us-east-1",
"status": "connected"
},
"database": {
"host": "postgres",
"port": 5432,
"name": "silo",
"user": "silo",
"password": "****",
"sslmode": "disable",
"max_connections": 10,
"status": "connected"
},
"auth": {
"enabled": true,
"session_secret": "****",
"local": { "enabled": true },
"ldap": {
"enabled": true,
"url": "ldaps://ipa.example.com",
"base_dn": "dc=kindred,dc=internal",
"user_search_dn": "cn=users,cn=accounts,dc=kindred,dc=internal",
"bind_password": "****",
"role_mapping": { "...": "..." }
},
"oidc": {
"enabled": true,
"issuer_url": "https://keycloak.example.com/realms/silo",
"client_id": "silo",
"client_secret": "****",
"redirect_url": "https://silo.example.com/auth/callback"
},
"cors": { "allowed_origins": ["https://silo.example.com"] }
},
"projects": { "enabled": true },
"audit": { "enabled": true },
"odoo": { "enabled": false, "url": "", "database": "", "username": "" },
"freecad": { "uri_scheme": "silo", "executable": "" },
"jobs": {
"enabled": false,
"directory": "/etc/silo/jobdefs",
"runner_timeout": 90,
"job_timeout_check": 30,
"default_priority": 100
},
"dag": { "enabled": false }
}
```
### 7.2 Get Module Settings
```
GET /api/admin/settings/{module}
```
Returns just the module's config block.
### 7.3 Update Module Settings
```
PUT /api/admin/settings/{module}
Content-Type: application/json
{
"enabled": true,
"ldap": {
"enabled": true,
"url": "ldaps://ipa.example.com"
}
}
```
**Response:**
```json
{
"updated": ["auth.ldap.enabled", "auth.ldap.url"],
"restart_required": false
}
```
### 7.4 Test Connectivity
```
POST /api/admin/settings/{module}/test
```
Available for modules with external connections:
| Module | Test Action |
|--------|------------|
| `storage` | Ping MinIO, verify bucket exists |
| `auth` (ldap) | Attempt LDAP bind with configured credentials |
| `auth` (oidc) | Fetch OIDC discovery document from issuer URL |
| `odoo` | Attempt XML-RPC connection to Odoo |
**Response:**
```json
{
"success": true,
"message": "LDAP bind successful",
"latency_ms": 42
}
```
---
## 8. Config YAML Changes
The existing `config.yaml` gains a `modules` section. Existing top-level keys remain for backward compatibility — the module system reads from both locations.
```yaml
# Existing keys (unchanged, still work)
server:
host: "0.0.0.0"
port: 8080
database:
host: postgres
port: 5432
name: silo
user: silo
password: silodev
sslmode: disable
storage:
endpoint: minio:9000
bucket: silo-files
access_key: silominio
secret_key: silominiosecret
use_ssl: false
schemas:
directory: /etc/silo/schemas
auth:
enabled: true
session_secret: change-me
local:
enabled: true
# New: explicit module toggles (optional, defaults shown)
modules:
projects:
enabled: true
audit:
enabled: true
odoo:
enabled: false
freecad:
enabled: true
uri_scheme: silo
jobs:
enabled: false
directory: /etc/silo/jobdefs
runner_timeout: 90
job_timeout_check: 30
default_priority: 100
dag:
enabled: false
```
If a module is not listed under `modules:`, its default enabled state from Section 2.2 applies. The `auth.enabled` field continues to control the `auth` module (no duplication under `modules:`).
---
## 9. SSE Events
```
settings.changed {module, enabled, changed_keys[], updated_by}
```
Broadcast on any admin settings change. The web UI listens for this to:
- Show/hide navigation entries when modules are toggled.
- Display a "Settings updated by another admin" toast.
- Show a "Restart required" banner when flagged.
---
## 10. Web UI — Admin Settings Page
The Settings page (`/settings`) is restructured into sections:
### 10.1 Existing (unchanged)
- **Account** — username, display name, email, auth source, role badge.
- **API Tokens** — create, list, revoke.
### 10.2 New: Module Configuration (admin only)
Visible only to admin users. Each module gets a collapsible card:
```
┌─────────────────────────────────────────────────────┐
│ [toggle] Authentication [status] │
├─────────────────────────────────────────────────────┤
│ │
│ ── Local Auth ──────────────────────────────────── │
│ Enabled: [toggle] │
│ │
│ ── LDAP / FreeIPA ──────────────────────────────── │
│ Enabled: [toggle] │
│ URL: [ldaps://ipa.example.com ] │
│ Base DN: [dc=kindred,dc=internal ] [Test] │
│ │
│ ── OIDC / Keycloak ────────────────────────────── │
│ Enabled: [toggle] │
│ Issuer URL: [https://keycloak.example.com] [Test] │
│ Client ID: [silo ] │
│ │
│ ── CORS ────────────────────────────────────────── │
│ Allowed Origins: [tag input] │
│ │
│ [Save] │
└─────────────────────────────────────────────────────┘
```
Module cards for required modules (`core`, `schemas`, `storage`) show their status and config but have no enable/disable toggle.
Status indicators per module:
| Status | Badge | Meaning |
|--------|-------|---------|
| Active | `green` | Enabled and operational |
| Disabled | `overlay1` | Toggled off |
| Error | `red` | Enabled but connectivity or config issue |
| Setup Required | `yellow` | Enabled but missing required config (e.g., LDAP URL empty) |
### 10.3 Infrastructure Section (admin, read-only)
Shows connection status for required infrastructure:
- **Database** — host, port, name, connection pool usage, status badge.
- **Storage** — endpoint, bucket, SSL, status badge.
These are read-only in the UI (setup-only via YAML/env). The "Test" button is available to verify connectivity.
---
## 11. Implementation Order
1. **Migration 014**`settings_overrides` and `module_state` tables.
2. **Config loader refactor** — YAML → DB merge → env override pipeline.
3. **Module registry** — Go struct defining all modules with metadata, dependencies, defaults.
4. **`GET /api/modules`** — public endpoint, no auth.
5. **`RequireModule` middleware** — gate route groups by module state.
6. **Admin settings API**`GET/PUT /api/admin/settings/{module}`, test endpoints.
7. **Web UI settings page** — module cards with toggles, config forms, test buttons.
8. **SSE integration**`settings.changed` event broadcast.
---
## 12. Future Considerations
- **Module manifest format** — per ROADMAP.md, each module will eventually declare routes, views, hooks, and permissions via a manifest. This spec covers the runtime module registry; the manifest format is TBD.
- **Custom modules** — third-party modules that register against the endpoint registry. Requires the manifest contract and a plugin loading mechanism.
- **Per-module permissions** — beyond the current role hierarchy, modules may define fine-grained scopes (e.g., `jobs:admin`, `dag:write`).
- **Location & Inventory module** — when the Location/Inventory API is implemented (tables already exist), it becomes a new optional module.
- **Notifications module** — per ROADMAP.md Tier 1, notifications/subscriptions will be a dedicated module.
---
## 13. References
- [CONFIGURATION.md](CONFIGURATION.md) — Current config reference
- [ROADMAP.md](ROADMAP.md) — Module manifest, API endpoint registry
- [AUTH.md](AUTH.md) — Authentication architecture
- [WORKERS.md](WORKERS.md) — Job queue system
- [DAG.md](DAG.md) — Dependency DAG specification
- [SPECIFICATION.md](SPECIFICATION.md) — Full endpoint listing

View File

@@ -88,7 +88,7 @@ Everything depends on these. They define what Silo *is*.
| Component | Description | Status |
|-----------|-------------|--------|
| **Core Silo** | Part/assembly storage, version control, auth, base REST API | Complete |
| **.kc Format Spec** | File format contract between Create and Silo | Not Started |
| **.kc Format Spec** | File format contract between Create and Silo | Complete |
| **API Endpoint Registry** | Module discovery, dynamic UI rendering, health checks | Not Started |
| **Web UI Shell** | App launcher, breadcrumbs, view framework, module rendering | Partial |
| **Python Scripting Engine** | Server-side hook execution, module extension point | Not Started |
@@ -313,7 +313,7 @@ For full SOLIDWORKS PDM comparison tables, see [GAP_ANALYSIS.md Appendix C](GAP_
- Rollback functionality
#### File Management
- MinIO integration with versioning
- Filesystem-based file storage
- File upload/download via REST API
- SHA256 checksums for integrity
- Storage path: `items/{partNumber}/rev{N}.FCStd`
@@ -377,8 +377,8 @@ For full SOLIDWORKS PDM comparison tables, see [GAP_ANALYSIS.md Appendix C](GAP_
## Appendix B: Phase 1 Detailed Tasks
### 1.1 MinIO Integration -- COMPLETE
- [x] MinIO service configured in Docker Compose
### 1.1 File Storage -- COMPLETE
- [x] Filesystem storage backend
- [x] File upload via REST API
- [x] File download via REST API (latest and by revision)
- [x] SHA256 checksums on upload

View File

@@ -37,7 +37,7 @@ Silo treats **part numbering schemas as configuration, not code**. Multiple numb
┌─────────────────────────────────────────────────────────────┐
│ Silo Server (silod) │
│ - REST API (78 endpoints) │
│ - REST API (86 endpoints) │
│ - Authentication (local, LDAP, OIDC) │
│ - Schema parsing and validation │
│ - Part number generation engine │
@@ -49,9 +49,9 @@ Silo treats **part numbering schemas as configuration, not code**. Multiple numb
┌───────────────┴───────────────┐
▼ ▼
┌─────────────────────────┐ ┌─────────────────────────────┐
│ PostgreSQL │ │ MinIO
│ PostgreSQL │ │ Local Filesystem
│ (psql.example.internal)│ │ - File storage │
│ - Item metadata │ │ - Versioned objects
│ - Item metadata │ │ - Revision files
│ - Relationships │ │ - Thumbnails │
│ - Revision history │ │ │
│ - Auth / Sessions │ │ │
@@ -64,7 +64,7 @@ Silo treats **part numbering schemas as configuration, not code**. Multiple numb
| Component | Technology | Notes |
|-----------|------------|-------|
| Database | PostgreSQL 16 | Existing instance at psql.example.internal |
| File Storage | MinIO | S3-compatible, versioning enabled |
| File Storage | Local filesystem | Files stored under configurable root directory |
| CLI & API Server | Go (1.24) | chi/v5 router, pgx/v5 driver, zerolog |
| Authentication | Multi-backend | Local (bcrypt), LDAP/FreeIPA, OIDC/Keycloak |
| Sessions | PostgreSQL pgxstore | alexedwards/scs, 24h lifetime |
@@ -83,7 +83,7 @@ An **item** is the fundamental entity. Items have:
- **Properties** (key-value pairs, schema-defined and custom)
- **Relationships** to other items
- **Revisions** (append-only history)
- **Files** (optional, stored in MinIO)
- **Files** (optional, stored on the local filesystem)
- **Location** (optional physical inventory location)
### 3.2 Database Schema (Conceptual)
@@ -115,7 +115,7 @@ CREATE TABLE revisions (
item_id UUID REFERENCES items(id) NOT NULL,
revision_number INTEGER NOT NULL,
properties JSONB NOT NULL, -- all properties at this revision
file_version TEXT, -- MinIO version ID if applicable
file_version TEXT, -- storage version ID if applicable
created_at TIMESTAMPTZ DEFAULT now(),
created_by TEXT, -- user identifier (future: LDAP DN)
comment TEXT,
@@ -345,7 +345,7 @@ CAD workbench and spreadsheet extension implementations are maintained in separa
### 5.1 File Storage Strategy
Files are stored as whole objects in MinIO with versioning enabled. Storage path convention: `items/{partNumber}/rev{N}.ext`. SHA-256 checksums are captured on upload for integrity verification.
Files are stored on the local filesystem under a configurable root directory. Storage path convention: `items/{partNumber}/rev{N}.ext`. SHA-256 checksums are captured on upload for integrity verification.
Future option: exploded storage (unpack ZIP-based CAD archives for better diffing).
@@ -439,7 +439,7 @@ Revisions are created explicitly by user action (not automatic):
### 7.3 Revision vs. File Version
- **Revision**: Silo metadata revision (tracked in PostgreSQL)
- **File Version**: MinIO object version (automatic on upload)
- **File Version**: File on disk corresponding to a revision
A single Silo revision may span multiple file uploads during editing. Only committed revisions create formal revision records.
@@ -598,12 +598,12 @@ See [AUTH.md](AUTH.md) for full architecture details and [AUTH_USER_GUIDE.md](AU
## 11. API Design
### 11.1 REST Endpoints (78 Implemented)
### 11.1 REST Endpoints (86 Implemented)
```
# Health (no auth)
GET /health # Basic health check
GET /ready # Readiness (DB + MinIO)
GET /ready # Readiness (DB)
# Auth (no auth required)
GET /login # Login page
@@ -624,8 +624,8 @@ GET /api/auth/tokens # List user's API to
POST /api/auth/tokens # Create API token
DELETE /api/auth/tokens/{id} # Revoke API token
# Presigned Uploads (editor)
POST /api/uploads/presign # Get presigned MinIO upload URL [editor]
# Direct Uploads (editor)
POST /api/uploads/presign # Get upload URL [editor]
# Schemas (read: viewer, write: editor)
GET /api/schemas # List all schemas
@@ -697,6 +697,20 @@ POST /api/items/{partNumber}/bom/merge # Merge BOM from ODS
PUT /api/items/{partNumber}/bom/{childPartNumber} # Update BOM entry [editor]
DELETE /api/items/{partNumber}/bom/{childPartNumber} # Remove BOM entry [editor]
# .kc Metadata (read: viewer, write: editor)
GET /api/items/{partNumber}/metadata # Get indexed .kc metadata
PUT /api/items/{partNumber}/metadata # Update metadata fields [editor]
PATCH /api/items/{partNumber}/metadata/lifecycle # Transition lifecycle state [editor]
PATCH /api/items/{partNumber}/metadata/tags # Add/remove tags [editor]
# .kc Dependencies (viewer)
GET /api/items/{partNumber}/dependencies # List raw dependencies
GET /api/items/{partNumber}/dependencies/resolve # Resolve UUIDs to part numbers + file availability
# .kc Macros (viewer)
GET /api/items/{partNumber}/macros # List registered macros
GET /api/items/{partNumber}/macros/{filename} # Get macro source content
# Audit (viewer)
GET /api/audit/completeness # Item completeness scores
GET /api/audit/completeness/{partNumber} # Item detail breakdown
@@ -735,6 +749,139 @@ POST /api/inventory/{partNumber}/move
---
## 11.3 .kc File Integration
Silo supports the `.kc` file format — a ZIP archive that is a superset of FreeCAD's `.fcstd`. A `.kc` file contains everything an `.fcstd` does, plus a `silo/` directory with platform metadata.
#### Standard entries (preserved as-is)
`Document.xml`, `GuiDocument.xml`, BREP geometry files (`.brp`), `thumbnails/`
#### Silo entries (`silo/` directory)
| Path | Purpose |
|------|---------|
| `silo/manifest.json` | Instance origin, part UUID, revision hash, `.kc` schema version |
| `silo/metadata.json` | Custom schema field values, tags, lifecycle state |
| `silo/history.json` | Local revision log (server-generated on checkout) |
| `silo/dependencies.json` | Assembly link references by Silo UUID |
| `silo/macros/*.py` | Embedded macro scripts bound to this part |
#### Commit-time extraction
When a `.kc` file is uploaded via `POST /api/items/{partNumber}/file`, the server:
1. Opens the ZIP and scans for `silo/` entries
2. Parses `silo/manifest.json` and validates the UUID matches the item
3. Upserts `silo/metadata.json` fields into the `item_metadata` table
4. Replaces `silo/dependencies.json` entries in the `item_dependencies` table
5. Replaces `silo/macros/*.py` entries in the `item_macros` table
6. Broadcasts SSE events: `metadata.updated`, `dependencies.changed`, `macros.changed`
Extraction is best-effort — failures are logged as warnings but do not block the upload.
#### Checkout-time packing
When a `.kc` file is downloaded via `GET /api/items/{partNumber}/file/{revision}`, the server repacks the `silo/` directory with current database state:
- `silo/manifest.json` — current item UUID and metadata freshness
- `silo/metadata.json` — latest schema fields, tags, lifecycle state
- `silo/history.json` — last 20 revisions from the database
- `silo/dependencies.json` — current dependency list from `item_dependencies`
Non-silo ZIP entries are passed through unchanged. If the file is a plain `.fcstd` (no `silo/` directory), it is served as-is.
ETag caching: the server computes an ETag from `revision_number:metadata.updated_at` and returns `304 Not Modified` when the client's `If-None-Match` header matches.
#### Lifecycle state machine
The `lifecycle_state` field in `item_metadata` follows this state machine:
```
draft → review → released → obsolete
↑ ↓
└────────┘
```
Valid transitions are enforced by `PATCH /metadata/lifecycle`. Invalid transitions return `422 Unprocessable Entity`.
#### Metadata response shape
```json
{
"schema_name": "kindred-rd",
"lifecycle_state": "draft",
"tags": ["prototype", "v2"],
"fields": {"material": "AL6061", "finish": "anodized"},
"manifest": {
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"silo_instance": "silo.example.com",
"revision_hash": "abc123",
"kc_version": "1.0"
},
"updated_at": "2026-02-18T12:00:00Z",
"updated_by": "forbes"
}
```
#### Dependency response shape
```json
[
{
"uuid": "550e8400-...",
"part_number": "F01-0042",
"revision": 3,
"quantity": 4.0,
"label": "M5 Bolt",
"relationship": "component"
}
]
```
#### Resolved dependency response shape
```json
[
{
"uuid": "550e8400-...",
"part_number": "F01-0042",
"label": "M5 Bolt",
"revision": 3,
"quantity": 4.0,
"resolved": true,
"file_available": true
}
]
```
#### Macro list response shape
```json
[
{"filename": "validate_dims.py", "trigger": "manual", "revision_number": 5}
]
```
#### Macro detail response shape
```json
{
"filename": "validate_dims.py",
"trigger": "manual",
"content": "import FreeCAD\n...",
"revision_number": 5
}
```
#### Database tables (migration 018)
- `item_metadata` — schema fields, lifecycle state, tags, manifest info
- `item_dependencies` — parent/child UUID references with quantity and relationship type
- `item_macros` — filename, trigger type, source content, indexed per item
---
## 12. MVP Scope
### 12.1 Implemented
@@ -743,8 +890,8 @@ POST /api/inventory/{partNumber}/move
- [x] YAML schema parser for part numbering
- [x] Part number generation engine
- [x] CLI tool (`cmd/silo`)
- [x] API server (`cmd/silod`) with 78 endpoints
- [x] MinIO integration for file storage with versioning
- [x] API server (`cmd/silod`) with 86 endpoints
- [x] Filesystem-based file storage
- [x] BOM relationships (component, alternate, reference)
- [x] Multi-level BOM (recursive expansion with configurable depth)
- [x] Where-used queries (reverse parent lookup)
@@ -765,6 +912,12 @@ POST /api/inventory/{partNumber}/move
- [x] Audit logging and completeness scoring
- [x] CSRF protection (nosurf)
- [x] Fuzzy search
- [x] .kc file extraction pipeline (metadata, dependencies, macros indexed on commit)
- [x] .kc file packing on checkout (manifest, metadata, history, dependencies)
- [x] .kc metadata API (get, update fields, lifecycle transitions, tags)
- [x] .kc dependency API (list, resolve with file availability)
- [x] .kc macro API (list, get source content)
- [x] ETag caching for .kc file downloads
- [x] Property schema versioning framework
- [x] Docker Compose deployment (dev and prod)
- [x] systemd service and deployment scripts

View File

@@ -10,12 +10,12 @@
| Component | Status | Notes |
|-----------|--------|-------|
| PostgreSQL schema | Complete | 13 migrations applied |
| PostgreSQL schema | Complete | 18 migrations applied |
| YAML schema parser | Complete | Supports enum, serial, constant, string segments |
| Part number generator | Complete | Scoped sequences, category-based format |
| API server (`silod`) | Complete | 78 REST endpoints via chi/v5 |
| API server (`silod`) | Complete | 86 REST endpoints via chi/v5 |
| CLI tool (`silo`) | Complete | Item registration and management |
| MinIO file storage | Complete | Upload, download, versioning, checksums |
| Filesystem file storage | Complete | Upload, download, checksums |
| Revision control | Complete | Append-only history, rollback, comparison, status/labels |
| Project management | Complete | CRUD, many-to-many item tagging |
| CSV import/export | Complete | Dry-run validation, template generation |
@@ -29,7 +29,12 @@
| CSRF protection | Complete | nosurf on web forms |
| Fuzzy search | Complete | sahilm/fuzzy library |
| Web UI | Complete | React SPA (Vite + TypeScript), 6 pages, Catppuccin Mocha theme |
| File attachments | Complete | Presigned uploads, item file association, thumbnails |
| File attachments | Complete | Direct uploads, item file association, thumbnails |
| .kc extraction pipeline | Complete | Metadata, dependencies, macros indexed on commit |
| .kc checkout packing | Complete | Manifest, metadata, history, dependencies repacked on download |
| .kc metadata API | Complete | GET/PUT metadata, lifecycle transitions, tag management |
| .kc dependency API | Complete | List raw deps, resolve UUIDs to part numbers + file availability |
| .kc macro API | Complete | List macros, get source content by filename |
| Odoo ERP integration | Partial | Config and sync-log CRUD functional; push/pull are stubs |
| Docker Compose | Complete | Dev and production configurations |
| Deployment scripts | Complete | setup-host, deploy, init-db, setup-ipa-nginx |
@@ -56,7 +61,7 @@ FreeCAD workbench and LibreOffice Calc extension are maintained in separate repo
| Service | Host | Status |
|---------|------|--------|
| PostgreSQL | psql.example.internal:5432 | Running |
| MinIO | localhost:9000 (API) / :9001 (console) | Configured |
| File Storage | /opt/silo/data (filesystem) | Configured |
| Silo API | localhost:8080 | Builds successfully |
---
@@ -96,3 +101,8 @@ The schema defines 170 category codes across 10 groups:
| 011_item_files.sql | Item file attachments (item_files table, thumbnail_key column) |
| 012_bom_source.sql | BOM entry source tracking |
| 013_move_cost_sourcing_to_props.sql | Move sourcing_link and standard_cost from item columns to revision properties |
| 014_settings.sql | Settings overrides and module state tables |
| 015_jobs.sql | Job queue, runner, and job log tables |
| 016_dag.sql | Dependency DAG nodes and edges |
| 017_locations.sql | Location hierarchy and inventory tracking |
| 018_kc_metadata.sql | .kc metadata tables (item_metadata, item_dependencies, item_macros, item_approvals, approval_signatures) |

3
mods/sdk/Init.py Normal file
View File

@@ -0,0 +1,3 @@
import FreeCAD
FreeCAD.Console.PrintLog("kindred-addon-sdk loaded\n")

3
mods/sdk/InitGui.py Normal file
View File

@@ -0,0 +1,3 @@
import FreeCAD
FreeCAD.Console.PrintLog("kindred-addon-sdk GUI initialized\n")

View File

@@ -0,0 +1,34 @@
# kindred-addon-sdk — stable API for Kindred Create addon integration
from kindred_sdk.version import SDK_VERSION
from kindred_sdk.context import (
register_context,
unregister_context,
register_overlay,
unregister_overlay,
inject_commands,
current_context,
refresh_context,
)
from kindred_sdk.theme import get_theme_tokens, load_palette
from kindred_sdk.origin import register_origin, unregister_origin
from kindred_sdk.dock import register_dock_panel
from kindred_sdk.compat import create_version, freecad_version
__all__ = [
"SDK_VERSION",
"register_context",
"unregister_context",
"register_overlay",
"unregister_overlay",
"inject_commands",
"current_context",
"refresh_context",
"get_theme_tokens",
"load_palette",
"register_origin",
"unregister_origin",
"register_dock_panel",
"create_version",
"freecad_version",
]

View File

@@ -0,0 +1,21 @@
"""Version detection utilities."""
import FreeCAD
def create_version():
"""Return the Kindred Create version string (e.g. ``"0.1.3"``)."""
try:
from version import VERSION
return VERSION
except ImportError:
return "0.0.0"
def freecad_version():
"""Return the FreeCAD base version as a tuple of strings.
Example: ``("1", "0", "0", "2025.01.01")``.
"""
return tuple(FreeCAD.Version())

View File

@@ -0,0 +1,152 @@
"""Editing context and overlay registration wrappers.
Thin wrappers around FreeCADGui editing context bindings. If the
underlying C++ API changes during an upstream rebase, only this module
needs to be updated.
"""
import FreeCAD
def _gui():
"""Lazy import of FreeCADGui (not available in console mode)."""
import FreeCADGui
return FreeCADGui
def register_context(context_id, label, color, toolbars, match, priority=50):
"""Register an editing context.
Parameters
----------
context_id : str
Unique identifier (e.g. ``"myaddon.edit"``).
label : str
Display label template. Supports ``{name}`` placeholder.
color : str
Hex color for the breadcrumb (e.g. ``"#f38ba8"``).
toolbars : list[str]
Toolbar names to show when this context is active.
match : callable
Zero-argument callable returning *True* when this context is active.
priority : int, optional
Higher values are checked first. Default 50.
"""
if not isinstance(context_id, str):
raise TypeError(f"context_id must be str, got {type(context_id).__name__}")
if not isinstance(toolbars, list):
raise TypeError(f"toolbars must be list, got {type(toolbars).__name__}")
if not callable(match):
raise TypeError("match must be callable")
try:
_gui().registerEditingContext(context_id, label, color, toolbars, match, priority)
except Exception as e:
FreeCAD.Console.PrintWarning(
f"kindred_sdk: Failed to register context '{context_id}': {e}\n"
)
def unregister_context(context_id):
"""Remove a previously registered editing context."""
if not isinstance(context_id, str):
raise TypeError(f"context_id must be str, got {type(context_id).__name__}")
try:
_gui().unregisterEditingContext(context_id)
except Exception as e:
FreeCAD.Console.PrintWarning(
f"kindred_sdk: Failed to unregister context '{context_id}': {e}\n"
)
def register_overlay(overlay_id, toolbars, match):
"""Register an editing overlay.
Overlays add toolbars to whatever context is currently active when
*match* returns True.
Parameters
----------
overlay_id : str
Unique overlay identifier.
toolbars : list[str]
Toolbar names to append.
match : callable
Zero-argument callable returning *True* when the overlay applies.
"""
if not isinstance(overlay_id, str):
raise TypeError(f"overlay_id must be str, got {type(overlay_id).__name__}")
if not isinstance(toolbars, list):
raise TypeError(f"toolbars must be list, got {type(toolbars).__name__}")
if not callable(match):
raise TypeError("match must be callable")
try:
_gui().registerEditingOverlay(overlay_id, toolbars, match)
except Exception as e:
FreeCAD.Console.PrintWarning(
f"kindred_sdk: Failed to register overlay '{overlay_id}': {e}\n"
)
def unregister_overlay(overlay_id):
"""Remove a previously registered editing overlay."""
if not isinstance(overlay_id, str):
raise TypeError(f"overlay_id must be str, got {type(overlay_id).__name__}")
try:
_gui().unregisterEditingOverlay(overlay_id)
except Exception as e:
FreeCAD.Console.PrintWarning(
f"kindred_sdk: Failed to unregister overlay '{overlay_id}': {e}\n"
)
def inject_commands(context_id, toolbar_name, commands):
"""Inject commands into a context's toolbar.
Parameters
----------
context_id : str
Target context identifier.
toolbar_name : str
Toolbar within that context.
commands : list[str]
Command names to add.
"""
if not isinstance(context_id, str):
raise TypeError(f"context_id must be str, got {type(context_id).__name__}")
if not isinstance(toolbar_name, str):
raise TypeError(f"toolbar_name must be str, got {type(toolbar_name).__name__}")
if not isinstance(commands, list):
raise TypeError(f"commands must be list, got {type(commands).__name__}")
try:
_gui().injectEditingCommands(context_id, toolbar_name, commands)
except Exception as e:
FreeCAD.Console.PrintWarning(
f"kindred_sdk: Failed to inject commands into '{context_id}': {e}\n"
)
def current_context():
"""Return the current editing context as a dict.
Keys: ``id``, ``label``, ``color``, ``toolbars``, ``breadcrumb``,
``breadcrumbColors``. Returns ``None`` if no context is active.
"""
try:
return _gui().currentEditingContext()
except Exception as e:
FreeCAD.Console.PrintWarning(f"kindred_sdk: Failed to get current context: {e}\n")
return None
def refresh_context():
"""Force re-resolution and update of the editing context."""
try:
_gui().refreshEditingContext()
except Exception as e:
FreeCAD.Console.PrintWarning(f"kindred_sdk: Failed to refresh context: {e}\n")

View File

@@ -0,0 +1,73 @@
"""Deferred dock panel registration helper.
Replaces the manual ``QTimer.singleShot()`` + duplicate-check +
try/except pattern used in ``src/Mod/Create/InitGui.py``.
"""
import FreeCAD
_AREA_MAP = {
"left": 1, # Qt.LeftDockWidgetArea
"right": 2, # Qt.RightDockWidgetArea
"top": 4, # Qt.TopDockWidgetArea
"bottom": 8, # Qt.BottomDockWidgetArea
}
def register_dock_panel(object_name, title, widget_factory, area="right", delay_ms=0):
"""Register a dock panel, optionally deferred.
Parameters
----------
object_name : str
Qt object name for duplicate prevention.
title : str
Dock widget title bar text.
widget_factory : callable
Zero-argument callable returning a ``QWidget``. Called only
when the panel is actually created (after *delay_ms*).
area : str, optional
Dock area: ``"left"``, ``"right"``, ``"top"``, or ``"bottom"``.
Default ``"right"``.
delay_ms : int, optional
Milliseconds to wait before creating the panel. Default 0
(immediate, but still posted to the event loop).
"""
if not isinstance(object_name, str):
raise TypeError(f"object_name must be str, got {type(object_name).__name__}")
if not callable(widget_factory):
raise TypeError("widget_factory must be callable")
qt_area = _AREA_MAP.get(area)
if qt_area is None:
raise ValueError(f"area must be one of {list(_AREA_MAP)}, got {area!r}")
def _create():
try:
from PySide import QtCore, QtWidgets
import FreeCADGui
mw = FreeCADGui.getMainWindow()
if mw is None:
return
if mw.findChild(QtWidgets.QDockWidget, object_name):
return
widget = widget_factory()
panel = QtWidgets.QDockWidget(title, mw)
panel.setObjectName(object_name)
panel.setWidget(widget)
mw.addDockWidget(QtCore.Qt.DockWidgetArea(qt_area), panel)
except Exception as e:
FreeCAD.Console.PrintLog(f"kindred_sdk: Dock panel '{object_name}' skipped: {e}\n")
try:
from PySide.QtCore import QTimer
QTimer.singleShot(max(0, delay_ms), _create)
except Exception as e:
FreeCAD.Console.PrintLog(
f"kindred_sdk: Could not schedule dock panel '{object_name}': {e}\n"
)

View File

@@ -0,0 +1,42 @@
"""FileOrigin registration wrappers.
Wraps ``FreeCADGui.addOrigin()`` / ``removeOrigin()`` with validation
and error handling. Addons implement the FileOrigin duck-typed
interface directly (see Silo's ``SiloOrigin`` for the full contract).
"""
import FreeCAD
_REQUIRED_METHODS = ("id", "name", "type", "ownsDocument")
def _gui():
import FreeCADGui
return FreeCADGui
def register_origin(origin):
"""Register a FileOrigin with FreeCADGui.
*origin* must be a Python object implementing at least ``id()``,
``name()``, ``type()``, and ``ownsDocument(doc)`` methods.
"""
missing = [m for m in _REQUIRED_METHODS if not hasattr(origin, m)]
if missing:
raise TypeError(f"origin is missing required methods: {', '.join(missing)}")
try:
_gui().addOrigin(origin)
FreeCAD.Console.PrintLog(f"kindred_sdk: Registered origin '{origin.id()}'\n")
except Exception as e:
FreeCAD.Console.PrintWarning(f"kindred_sdk: Failed to register origin: {e}\n")
def unregister_origin(origin):
"""Remove a previously registered FileOrigin."""
try:
_gui().removeOrigin(origin)
FreeCAD.Console.PrintLog(f"kindred_sdk: Unregistered origin '{origin.id()}'\n")
except Exception as e:
FreeCAD.Console.PrintWarning(f"kindred_sdk: Failed to unregister origin: {e}\n")

View File

@@ -0,0 +1,46 @@
name: Catppuccin Mocha
slug: catppuccin-mocha
colors:
rosewater: "#f5e0dc"
flamingo: "#f2cdcd"
pink: "#f5c2e7"
mauve: "#cba6f7"
red: "#f38ba8"
maroon: "#eba0ac"
peach: "#fab387"
yellow: "#f9e2af"
green: "#a6e3a1"
teal: "#94e2d5"
sky: "#89dceb"
sapphire: "#74c7ec"
blue: "#89b4fa"
lavender: "#b4befe"
text: "#cdd6f4"
subtext1: "#bac2de"
subtext0: "#a6adc8"
overlay2: "#9399b2"
overlay1: "#7f849c"
overlay0: "#6c7086"
surface2: "#585b70"
surface1: "#45475a"
surface0: "#313244"
base: "#1e1e2e"
mantle: "#181825"
crust: "#11111b"
roles:
background: base
background.toolbar: mantle
background.darkest: crust
foreground: text
foreground.muted: subtext0
foreground.subtle: overlay1
accent.primary: mauve
accent.info: blue
accent.success: green
accent.warning: yellow
accent.error: red
border: surface1
selection: surface2
input.background: surface0

View File

@@ -0,0 +1,181 @@
"""YAML-driven theme system.
Loads color palettes from YAML files and provides runtime access to
color tokens, semantic roles, QSS template formatting, and FreeCAD
preference-pack value conversion.
"""
import os
import re
import FreeCAD
class Palette:
"""A loaded color palette with raw tokens and semantic roles."""
def __init__(self, name, slug, colors, roles):
self.name = name
self.slug = slug
self.colors = dict(colors)
self.roles = {k: colors[v] for k, v in roles.items() if v in colors}
def get(self, key):
"""Look up a color by role first, then by raw color name.
Returns the hex string or *None* if not found.
"""
return self.roles.get(key) or self.colors.get(key)
@staticmethod
def hex_to_rgba_uint(hex_color):
"""Convert ``#RRGGBB`` to FreeCAD's unsigned-int RGBA format.
>>> Palette.hex_to_rgba_uint("#cdd6f4")
3453416703
"""
h = hex_color.lstrip("#")
r = int(h[0:2], 16)
g = int(h[2:4], 16)
b = int(h[4:6], 16)
a = 255
return (r << 24) | (g << 16) | (b << 8) | a
def format_qss(self, template):
"""Substitute ``{token}`` placeholders in a QSS template string.
Both raw color names (``{blue}``) and dotted role names
(``{accent.primary}``) are supported. Dotted names are tried
first so they take precedence over any same-named color.
Unknown tokens are left as-is.
"""
lookup = {}
lookup.update(self.colors)
# Roles use dotted names which aren't valid Python identifiers,
# so we do regex-based substitution.
lookup.update(self.roles)
def _replace(m):
key = m.group(1)
return lookup.get(key, m.group(0))
return re.sub(r"\{([a-z][a-z0-9_.]*)\}", _replace, template)
def __repr__(self):
return f"Palette({self.name!r}, {len(self.colors)} colors, {len(self.roles)} roles)"
# ---------------------------------------------------------------------------
# YAML loading with fallback
# ---------------------------------------------------------------------------
def _load_yaml(path):
"""Load a YAML file, preferring PyYAML if available."""
try:
import yaml
with open(path) as f:
return yaml.safe_load(f)
except ImportError:
return _load_yaml_fallback(path)
def _load_yaml_fallback(path):
"""Minimal YAML parser for flat key-value palette files.
Handles the subset of YAML used by palette files: top-level keys
with string/scalar values, and one level of nested mappings.
"""
data = {}
current_section = None
with open(path) as f:
for line in f:
stripped = line.rstrip()
# Skip blank lines and comments
if not stripped or stripped.startswith("#"):
continue
# Detect indentation
indent = len(line) - len(line.lstrip())
# Top-level key
if indent == 0 and ":" in stripped:
key, _, value = stripped.partition(":")
key = key.strip()
value = value.strip().strip('"').strip("'")
if value:
data[key] = value
current_section = None
else:
# Start of a nested section
current_section = key
data[current_section] = {}
continue
# Nested key (indented)
if current_section is not None and indent > 0 and ":" in stripped:
key, _, value = stripped.partition(":")
key = key.strip()
value = value.strip().strip('"').strip("'")
data[current_section][key] = value
return data
# ---------------------------------------------------------------------------
# Public API
# ---------------------------------------------------------------------------
_cache = {}
_PALETTES_DIR = os.path.join(os.path.dirname(__file__), "palettes")
def load_palette(name="catppuccin-mocha"):
"""Load a named palette from the ``palettes/`` directory.
Results are cached; subsequent calls with the same *name* return
the same ``Palette`` instance.
"""
if name in _cache:
return _cache[name]
path = os.path.join(_PALETTES_DIR, f"{name}.yaml")
if not os.path.isfile(path):
FreeCAD.Console.PrintWarning(f"kindred_sdk: Palette file not found: {path}\n")
return None
try:
raw = _load_yaml(path)
except Exception as e:
FreeCAD.Console.PrintWarning(f"kindred_sdk: Failed to load palette '{name}': {e}\n")
return None
palette = Palette(
name=raw.get("name", name),
slug=raw.get("slug", name),
colors=raw.get("colors", {}),
roles=raw.get("roles", {}),
)
_cache[name] = palette
FreeCAD.Console.PrintLog(
f"kindred_sdk: Loaded palette '{palette.name}' ({len(palette.colors)} colors)\n"
)
return palette
def get_theme_tokens(name="catppuccin-mocha"):
"""Return a dict of ``{token_name: "#hex"}`` for all colors in a palette.
This is a convenience shorthand for ``load_palette(name).colors``.
Returns a copy so callers cannot mutate the cached palette.
"""
palette = load_palette(name)
if palette is None:
return {}
return dict(palette.colors)

View File

@@ -0,0 +1 @@
SDK_VERSION = "0.1.0"

23
mods/sdk/package.xml Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<package format="1" xmlns="https://wiki.freecad.org/Package_Metadata">
<name>sdk</name>
<description>Kindred Create addon SDK - stable API for addon integration</description>
<version>0.1.0</version>
<maintainer email="info@kindredsystems.io">Kindred Systems</maintainer>
<license file="LICENSE">LGPL-2.1-or-later</license>
<content>
<workbench>
<classname>SdkWorkbench</classname>
<subdirectory>./</subdirectory>
</workbench>
</content>
<kindred>
<min_create_version>0.1.0</min_create_version>
<load_priority>0</load_priority>
<pure_python>true</pure_python>
</kindred>
</package>

View File

@@ -217,7 +217,9 @@ bool BitmapFactoryInst::loadPixmap(const QString& filename, QPixmap& icon) const
QFile svgFile(fi.filePath());
if (svgFile.open(QFile::ReadOnly | QFile::Text)) {
QByteArray content = svgFile.readAll();
icon = pixmapFromSvg(content, QSize(64, 64));
static qreal dpr = getMaximumDPR();
icon = pixmapFromSvg(content, QSize(64, 64) * dpr);
icon.setDevicePixelRatio(dpr);
}
}
else {

View File

@@ -136,6 +136,12 @@
<FCParamGroup Name="Sketcher">
<FCUInt Name="GridLineColor" Value="1162304255" />
</FCParamGroup>
<FCParamGroup Name="Spreadsheet">
<FCText Name="TextColor">#cdd6f4</FCText>
<FCText Name="AliasedCellBackgroundColor">#313244</FCText>
<FCText Name="PositiveNumberColor">#a6e3a1</FCText>
<FCText Name="NegativeNumberColor">#f38ba8</FCText>
</FCParamGroup>
</FCParamGroup>
</FCParamGroup>
</FCParamGroup>

View File

@@ -0,0 +1,21 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <Base/Console.h>
#include <Base/PyObjectBase.h>
namespace Create
{
extern PyObject* initModule();
}
/* Python entry */
PyMOD_INIT_FUNC(CreateApp)
{
PyObject* mod = Create::initModule();
Base::Console().log("Loading Create module... done\n");
// Future: Create::FeatureFlipPocket::init(); etc.
PyMOD_Return(mod);
}

View File

@@ -0,0 +1,23 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <Base/Interpreter.h>
namespace Create
{
class Module: public Py::ExtensionModule<Module>
{
public:
Module()
: Py::ExtensionModule<Module>("CreateApp")
{
initialize("Kindred Create module.");
}
};
PyObject* initModule()
{
return Base::Interpreter().addModule(new Module);
}
} // namespace Create

View File

@@ -0,0 +1,35 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
set(Create_LIBS
FreeCADApp
)
SET(Module_SRCS
AppCreate.cpp
AppCreatePy.cpp
PreCompiled.h
)
SOURCE_GROUP("Module" FILES ${Module_SRCS})
SET(Create_SRCS
${Module_SRCS}
)
add_library(Create SHARED ${Create_SRCS})
target_include_directories(Create PRIVATE
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(Create ${Create_LIBS})
if(FREECAD_USE_PCH)
target_precompile_headers(Create PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">)
endif()
SET_BIN_DIR(Create CreateApp /Mod/Create)
SET_PYTHON_PREFIX_SUFFIX(Create)
INSTALL(TARGETS Create DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@@ -0,0 +1,11 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef CREATE_PRECOMPILED_H
#define CREATE_PRECOMPILED_H
#include <FCConfig.h>
#include <string>
#include <vector>
#endif // CREATE_PRECOMPILED_H

View File

@@ -1,6 +1,13 @@
# Kindred Create core module
# Handles auto-loading of ztools and Silo addons
# C++ module targets
add_subdirectory(App)
if(BUILD_GUI)
add_subdirectory(Gui)
endif(BUILD_GUI)
# Generate version.py from template with Kindred Create version
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/version.py.in
@@ -13,13 +20,27 @@ install(
FILES
Init.py
InitGui.py
addon_loader.py
kc_format.py
silo_document.py
silo_objects.py
silo_tree.py
silo_viewers.py
silo_viewproviders.py
update_checker.py
${CMAKE_CURRENT_BINARY_DIR}/version.py
DESTINATION
Mod/Create
)
# Install Silo tree-node icons
install(
DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/resources/icons/
DESTINATION
Mod/Create/resources/icons
)
# Install ztools addon
install(
DIRECTORY
@@ -27,12 +48,6 @@ install(
DESTINATION
mods/ztools
)
install(
DIRECTORY
${CMAKE_SOURCE_DIR}/mods/ztools/CatppuccinMocha
DESTINATION
mods/ztools
)
install(
FILES
${CMAKE_SOURCE_DIR}/mods/ztools/package.xml
@@ -53,3 +68,19 @@ install(
DESTINATION
mods/silo/silo-client
)
# Install SDK
install(
DIRECTORY
${CMAKE_SOURCE_DIR}/mods/sdk/kindred_sdk
DESTINATION
mods/sdk
)
install(
FILES
${CMAKE_SOURCE_DIR}/mods/sdk/package.xml
${CMAKE_SOURCE_DIR}/mods/sdk/Init.py
${CMAKE_SOURCE_DIR}/mods/sdk/InitGui.py
DESTINATION
mods/sdk
)

View File

@@ -0,0 +1,26 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <FCGlobal.h>
#ifndef CREATE_GLOBAL_H
#define CREATE_GLOBAL_H
// CreateApp
#ifndef CreateExport
# ifdef Create_EXPORTS
# define CreateExport FREECAD_DECL_EXPORT
# else
# define CreateExport FREECAD_DECL_IMPORT
# endif
#endif
// CreateGui
#ifndef CreateGuiExport
# ifdef CreateGui_EXPORTS
# define CreateGuiExport FREECAD_DECL_EXPORT
# else
# define CreateGuiExport FREECAD_DECL_IMPORT
# endif
#endif
#endif // CREATE_GLOBAL_H

View File

@@ -0,0 +1,21 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <Base/Console.h>
#include <Base/PyObjectBase.h>
namespace CreateGui
{
extern PyObject* initModule();
}
/* Python entry */
PyMOD_INIT_FUNC(CreateGui)
{
PyObject* mod = CreateGui::initModule();
Base::Console().log("Loading CreateGui module... done\n");
// Future: CreateGui::ViewProviderFlipPocket::init(); etc.
PyMOD_Return(mod);
}

View File

@@ -0,0 +1,23 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <Base/Interpreter.h>
namespace CreateGui
{
class Module: public Py::ExtensionModule<Module>
{
public:
Module()
: Py::ExtensionModule<Module>("CreateGui")
{
initialize("Kindred Create GUI module.");
}
};
PyObject* initModule()
{
return Base::Interpreter().addModule(new Module);
}
} // namespace CreateGui

View File

@@ -0,0 +1,34 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
set(CreateGui_LIBS
Create
FreeCADGui
)
SET(Module_SRCS
AppCreateGui.cpp
AppCreateGuiPy.cpp
PreCompiled.h
)
SOURCE_GROUP("Module" FILES ${Module_SRCS})
SET(CreateGui_SRCS
${Module_SRCS}
)
add_library(CreateGui SHARED ${CreateGui_SRCS})
target_include_directories(CreateGui PRIVATE
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(CreateGui ${CreateGui_LIBS})
if(FREECAD_USE_PCH)
target_precompile_headers(CreateGui PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:"${CMAKE_CURRENT_LIST_DIR}/PreCompiled.h">)
endif()
SET_BIN_DIR(CreateGui CreateGui /Mod/Create)
SET_PYTHON_PREFIX_SUFFIX(CreateGui)
INSTALL(TARGETS CreateGui DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@@ -0,0 +1,12 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef CREATEGUI_PRECOMPILED_H
#define CREATEGUI_PRECOMPILED_H
#include <FCConfig.h>
#include <string>
#include <Gui/QtAll.h>
#endif // CREATEGUI_PRECOMPILED_H

View File

@@ -1,48 +1,14 @@
# Kindred Create - Core Module
# Console initialization - loads ztools and Silo addons
import os
import sys
# Console initialization - loads Kindred addons via manifest-driven loader
import FreeCAD
try:
from addon_loader import getAddonRegistry, load_addons
def setup_kindred_addons():
"""Add Kindred Create addon paths and load their Init.py files."""
# Get the FreeCAD home directory (where src/Mod/Create is installed)
home = FreeCAD.getHomePath()
mods_dir = os.path.join(home, "mods")
load_addons(gui=False)
FreeCAD.getAddonRegistry = getAddonRegistry
except Exception as e:
FreeCAD.Console.PrintWarning(f"Create: Addon loader failed: {e}\n")
# Define built-in addons with their paths relative to mods/
addons = [
("ztools", "ztools/ztools"), # mods/ztools/ztools/
("silo", "silo/freecad"), # mods/silo/freecad/
]
for name, subpath in addons:
addon_path = os.path.join(mods_dir, subpath)
if os.path.isdir(addon_path):
# Add to sys.path if not already present
if addon_path not in sys.path:
sys.path.insert(0, addon_path)
# Execute Init.py if it exists
init_file = os.path.join(addon_path, "Init.py")
if os.path.isfile(init_file):
try:
with open(init_file) as f:
exec_globals = globals().copy()
exec_globals["__file__"] = init_file
exec_globals["__name__"] = name
exec(compile(f.read(), init_file, "exec"), exec_globals)
FreeCAD.Console.PrintLog(f"Create: Loaded {name} Init.py\n")
except Exception as e:
FreeCAD.Console.PrintWarning(
f"Create: Failed to load {name}: {e}\n"
)
else:
FreeCAD.Console.PrintLog(f"Create: Addon path not found: {addon_path}\n")
setup_kindred_addons()
FreeCAD.Console.PrintLog("Create module initialized\n")

View File

@@ -1,50 +1,16 @@
# Kindred Create - Core Module
# GUI initialization - loads ztools and Silo workbenches
import os
import sys
# GUI initialization - loads Kindred addon workbenches via manifest-driven loader
import FreeCAD
import FreeCADGui
try:
from addon_loader import load_addons
def setup_kindred_workbenches():
"""Load Kindred Create addon workbenches."""
home = FreeCAD.getHomePath()
mods_dir = os.path.join(home, "mods")
load_addons(gui=True)
except Exception as e:
FreeCAD.Console.PrintWarning(f"Create: Addon GUI loader failed: {e}\n")
addons = [
("ztools", "ztools/ztools"),
("silo", "silo/freecad"),
]
for name, subpath in addons:
addon_path = os.path.join(mods_dir, subpath)
if os.path.isdir(addon_path):
# Ensure path is in sys.path
if addon_path not in sys.path:
sys.path.insert(0, addon_path)
# Execute InitGui.py if it exists
init_gui_file = os.path.join(addon_path, "InitGui.py")
if os.path.isfile(init_gui_file):
try:
with open(init_gui_file) as f:
exec_globals = globals().copy()
exec_globals["__file__"] = init_gui_file
exec_globals["__name__"] = name
exec(
compile(f.read(), init_gui_file, "exec"),
exec_globals,
)
FreeCAD.Console.PrintLog(f"Create: Loaded {name} workbench\n")
except Exception as e:
FreeCAD.Console.PrintWarning(
f"Create: Failed to load {name} GUI: {e}\n"
)
setup_kindred_workbenches()
FreeCAD.Console.PrintLog("Create GUI module initialized\n")
@@ -58,6 +24,16 @@ def _register_kc_format():
FreeCAD.Console.PrintLog(f"Create: kc_format registration skipped: {e}\n")
def _register_silo_document_observer():
"""Register the Silo document observer for .kc tree building."""
try:
import silo_document
silo_document.register()
except Exception as e:
FreeCAD.Console.PrintLog(f"Create: silo_document registration skipped: {e}\n")
# ---------------------------------------------------------------------------
# Silo integration enhancements
# ---------------------------------------------------------------------------
@@ -89,26 +65,17 @@ def _register_silo_origin():
def _setup_silo_auth_panel():
"""Dock the Silo authentication panel in the right-hand side panel."""
try:
from PySide import QtCore, QtWidgets
from kindred_sdk import register_dock_panel
mw = FreeCADGui.getMainWindow()
if mw is None:
return
def _factory():
import silo_commands
# Don't create duplicate panels
if mw.findChild(QtWidgets.QDockWidget, "SiloDatabaseAuth"):
return
auth = silo_commands.SiloAuthDockWidget()
# Prevent GC of the auth timer by stashing on the widget
auth.widget._auth = auth
return auth.widget
import silo_commands
auth = silo_commands.SiloAuthDockWidget()
panel = QtWidgets.QDockWidget("Database Auth", mw)
panel.setObjectName("SiloDatabaseAuth")
panel.setWidget(auth.widget)
# Keep the auth object alive so its QTimer isn't destroyed while running
panel._auth = auth
mw.addDockWidget(QtCore.Qt.RightDockWidgetArea, panel)
register_dock_panel("SiloDatabaseAuth", "Database Auth", _factory)
except Exception as e:
FreeCAD.Console.PrintLog(f"Create: Silo auth panel skipped: {e}\n")
@@ -116,49 +83,36 @@ def _setup_silo_auth_panel():
def _setup_silo_activity_panel():
"""Show a dock widget with recent Silo database activity."""
try:
from PySide import QtCore, QtWidgets
from kindred_sdk import register_dock_panel
mw = FreeCADGui.getMainWindow()
if mw is None:
return
def _factory():
from PySide import QtWidgets
# Don't create duplicate panels
if mw.findChild(QtWidgets.QDockWidget, "SiloDatabaseActivity"):
return
widget = QtWidgets.QWidget()
layout = QtWidgets.QVBoxLayout(widget)
activity_list = QtWidgets.QListWidget()
layout.addWidget(activity_list)
panel = QtWidgets.QDockWidget("Database Activity", mw)
panel.setObjectName("SiloDatabaseActivity")
try:
import silo_commands
widget = QtWidgets.QWidget()
layout = QtWidgets.QVBoxLayout(widget)
items = silo_commands._client.list_items()
if isinstance(items, list):
for item in items[:20]:
pn = item.get("part_number", "")
desc = item.get("description", "")
updated = item.get("updated_at", "")
if updated:
updated = updated[:10]
activity_list.addItem(f"{pn} - {desc} - {updated}")
if activity_list.count() == 0:
activity_list.addItem("(No items in database)")
except Exception:
activity_list.addItem("(Unable to connect to Silo database)")
activity_list = QtWidgets.QListWidget()
layout.addWidget(activity_list)
return widget
try:
import silo_commands
items = silo_commands._client.list_items()
if isinstance(items, list):
for item in items[:20]:
pn = item.get("part_number", "")
desc = item.get("description", "")
updated = item.get("updated_at", "")
if updated:
updated = updated[:10]
activity_list.addItem(f"{pn} - {desc} - {updated}")
if activity_list.count() == 0:
activity_list.addItem("(No items in database)")
except Exception:
activity_list.addItem("(Unable to connect to Silo database)")
panel.setWidget(widget)
mw.addDockWidget(QtCore.Qt.RightDockWidgetArea, panel)
# Give the activity panel most of the vertical space
auth_panel = mw.findChild(QtWidgets.QDockWidget, "SiloDatabaseAuth")
if auth_panel:
mw.resizeDocks([auth_panel, panel], [120, 500], QtCore.Qt.Vertical)
register_dock_panel("SiloDatabaseActivity", "Database Activity", _factory)
except Exception as e:
FreeCAD.Console.PrintLog(f"Create: Silo activity panel skipped: {e}\n")
@@ -178,6 +132,7 @@ try:
from PySide.QtCore import QTimer
QTimer.singleShot(500, _register_kc_format)
QTimer.singleShot(600, _register_silo_document_observer)
QTimer.singleShot(1500, _register_silo_origin)
QTimer.singleShot(2000, _setup_silo_auth_panel)
QTimer.singleShot(3000, _check_silo_first_start)

View File

@@ -0,0 +1,536 @@
# Kindred Create - Manifest-driven addon loader
#
# Replaces the hard-coded exec() loading in Init.py/InitGui.py with a
# pipeline that scans mods/, parses package.xml manifests, validates
# compatibility, resolves dependency order, and exposes a runtime registry.
import enum
import os
import sys
import time
import xml.etree.ElementTree as ET
from dataclasses import dataclass, field
from typing import Optional
import FreeCAD
# ---------------------------------------------------------------------------
# Data structures
# ---------------------------------------------------------------------------
class AddonState(enum.Enum):
DISCOVERED = "discovered"
VALIDATED = "validated"
LOADED = "loaded"
SKIPPED = "skipped"
FAILED = "failed"
@dataclass
class AddonManifest:
"""Parsed addon metadata from package.xml plus Kindred extensions."""
# Identity (from package.xml standard fields)
name: str
version: str
description: str = ""
# Paths (resolved during discovery)
package_xml_path: str = ""
addon_root: str = ""
workbench_path: str = ""
# Kindred extensions (from <kindred> element, all optional)
min_create_version: Optional[str] = None
max_create_version: Optional[str] = None
load_priority: int = 100
dependencies: list[str] = field(default_factory=list)
has_kindred_element: bool = False
# Runtime state
state: AddonState = AddonState.DISCOVERED
error: str = ""
load_time_ms: float = 0.0
contexts: list[str] = field(default_factory=list)
def __repr__(self):
return f"AddonManifest(name={self.name!r}, version={self.version!r}, state={self.state.value})"
# ---------------------------------------------------------------------------
# Addon registry
# ---------------------------------------------------------------------------
class AddonRegistry:
"""Runtime registry of discovered addons and their load status."""
def __init__(self):
self._addons: dict[str, AddonManifest] = {}
self._load_order: list[str] = []
def register(self, manifest: AddonManifest):
self._addons[manifest.name] = manifest
def set_load_order(self, names: list[str]):
self._load_order = list(names)
def get(self, name: str) -> Optional[AddonManifest]:
return self._addons.get(name)
def all(self) -> list[AddonManifest]:
return list(self._addons.values())
def loaded(self) -> list[AddonManifest]:
return [m for m in self._by_load_order() if m.state == AddonState.LOADED]
def failed(self) -> list[AddonManifest]:
return [m for m in self._addons.values() if m.state == AddonState.FAILED]
def skipped(self) -> list[AddonManifest]:
return [m for m in self._addons.values() if m.state == AddonState.SKIPPED]
def is_loaded(self, name: str) -> bool:
m = self._addons.get(name)
return m is not None and m.state == AddonState.LOADED
def register_context(self, addon_name: str, context_id: str):
"""Register a context ID as provided by an addon."""
m = self._addons.get(addon_name)
if m is not None and context_id not in m.contexts:
m.contexts.append(context_id)
def contexts(self) -> dict[str, list[str]]:
"""Return a mapping of context IDs to the addon names that provide them."""
result: dict[str, list[str]] = {}
for m in self._addons.values():
for ctx in m.contexts:
result.setdefault(ctx, []).append(m.name)
return result
def _by_load_order(self) -> list[AddonManifest]:
ordered = []
for name in self._load_order:
m = self._addons.get(name)
if m is not None:
ordered.append(m)
# Include any addons not in load order (shouldn't happen, but safe)
seen = set(self._load_order)
for name, m in self._addons.items():
if name not in seen:
ordered.append(m)
return ordered
def __repr__(self):
loaded = len(self.loaded())
total = len(self._addons)
names = ", ".join(m.name for m in self.loaded())
return f"AddonRegistry({loaded}/{total} loaded: {names})"
# Module-level singleton
_registry: Optional[AddonRegistry] = None
# Legacy load order for backward compatibility when no <kindred> elements exist.
# Once addons declare <kindred> in their package.xml (issue #252), this is ignored.
_LEGACY_ORDER = ["ztools", "silo"]
# ---------------------------------------------------------------------------
# Discovery
# ---------------------------------------------------------------------------
def scan_addons(mods_dir: str) -> list[AddonManifest]:
"""Scan mods/ for directories containing package.xml at depth 1-2."""
manifests = []
if not os.path.isdir(mods_dir):
FreeCAD.Console.PrintLog(f"Create: mods directory not found: {mods_dir}\n")
return manifests
for entry in os.listdir(mods_dir):
entry_path = os.path.join(mods_dir, entry)
if not os.path.isdir(entry_path):
continue
# Check depth 1: mods/<addon>/package.xml
pkg_xml = os.path.join(entry_path, "package.xml")
if os.path.isfile(pkg_xml):
manifests.append(
AddonManifest(
name="",
version="",
package_xml_path=pkg_xml,
addon_root=entry_path,
)
)
continue
# Check depth 2: mods/<addon>/<subdir>/package.xml
for sub in os.listdir(entry_path):
sub_path = os.path.join(entry_path, sub)
if not os.path.isdir(sub_path):
continue
pkg_xml = os.path.join(sub_path, "package.xml")
if os.path.isfile(pkg_xml):
manifests.append(
AddonManifest(
name="",
version="",
package_xml_path=pkg_xml,
addon_root=sub_path,
)
)
return manifests
# ---------------------------------------------------------------------------
# Parsing
# ---------------------------------------------------------------------------
# FreeCAD package.xml namespace
_PKG_NS = "https://wiki.freecad.org/Package_Metadata"
def _find(parent, tag):
"""Find a child element, trying with and without namespace."""
el = parent.find(f"{{{_PKG_NS}}}{tag}")
if el is None:
el = parent.find(tag)
return el
def _findall(parent, tag):
"""Find all child elements, trying with and without namespace."""
els = parent.findall(f"{{{_PKG_NS}}}{tag}")
if not els:
els = parent.findall(tag)
return els
def _text(parent, tag, default=""):
"""Get text content of a child element."""
el = _find(parent, tag)
return el.text.strip() if el is not None and el.text else default
def parse_manifest(manifest: AddonManifest):
"""Parse package.xml into the manifest, including <kindred> extensions."""
try:
tree = ET.parse(manifest.package_xml_path)
root = tree.getroot()
except ET.ParseError as e:
manifest.state = AddonState.FAILED
manifest.error = f"XML parse error: {e}"
FreeCAD.Console.PrintWarning(
f"Create: Failed to parse {manifest.package_xml_path}: {e}\n"
)
return
# Standard fields
manifest.name = _text(root, "name") or os.path.basename(manifest.addon_root)
manifest.version = _text(root, "version", "0.0.0")
manifest.description = _text(root, "description")
# Resolve workbench path from <content><workbench><subdirectory>
content = _find(root, "content")
if content is not None:
workbench = _find(content, "workbench")
if workbench is not None:
subdir = _text(workbench, "subdirectory", ".")
# Normalize: strip leading ./
if subdir.startswith("./"):
subdir = subdir[2:]
if subdir == "" or subdir == ".":
manifest.workbench_path = manifest.addon_root
else:
manifest.workbench_path = os.path.join(manifest.addon_root, subdir)
# Fallback: use addon_root if no workbench subdirectory found
if not manifest.workbench_path:
manifest.workbench_path = manifest.addon_root
# Kindred extensions (optional)
kindred = _find(root, "kindred")
if kindred is not None:
manifest.has_kindred_element = True
manifest.min_create_version = _text(kindred, "min_create_version") or None
manifest.max_create_version = _text(kindred, "max_create_version") or None
priority_str = _text(kindred, "load_priority")
if priority_str:
try:
manifest.load_priority = int(priority_str)
except ValueError:
pass
deps = _find(kindred, "dependencies")
if deps is not None:
for dep in _findall(deps, "dependency"):
if dep.text and dep.text.strip():
manifest.dependencies.append(dep.text.strip())
ctxs = _find(kindred, "contexts")
if ctxs is not None:
for ctx in _findall(ctxs, "context"):
if ctx.text and ctx.text.strip():
manifest.contexts.append(ctx.text.strip())
FreeCAD.Console.PrintLog(
f"Create: Parsed {manifest.name} v{manifest.version} from {manifest.package_xml_path}\n"
)
# ---------------------------------------------------------------------------
# Validation
# ---------------------------------------------------------------------------
def _parse_version(v: str) -> tuple:
"""Parse a version string into a comparable tuple of ints."""
try:
return tuple(int(x) for x in v.split("."))
except (ValueError, AttributeError):
return (0, 0, 0)
def validate_manifest(manifest: AddonManifest, create_version: str) -> bool:
"""Check version compatibility and path existence. Returns True if valid."""
if manifest.state == AddonState.FAILED:
return False
cv = _parse_version(create_version)
if manifest.min_create_version:
if cv < _parse_version(manifest.min_create_version):
manifest.state = AddonState.SKIPPED
manifest.error = f"Requires Create >= {manifest.min_create_version}, running {create_version}"
FreeCAD.Console.PrintWarning(
f"Create: Skipping {manifest.name}: {manifest.error}\n"
)
return False
if manifest.max_create_version:
if cv > _parse_version(manifest.max_create_version):
manifest.state = AddonState.SKIPPED
manifest.error = f"Requires Create <= {manifest.max_create_version}, running {create_version}"
FreeCAD.Console.PrintWarning(
f"Create: Skipping {manifest.name}: {manifest.error}\n"
)
return False
if not os.path.isdir(manifest.workbench_path):
manifest.state = AddonState.SKIPPED
manifest.error = f"Workbench path not found: {manifest.workbench_path}"
FreeCAD.Console.PrintWarning(
f"Create: Skipping {manifest.name}: {manifest.error}\n"
)
return False
# At least one of Init.py or InitGui.py must exist
has_init = os.path.isfile(os.path.join(manifest.workbench_path, "Init.py"))
has_gui = os.path.isfile(os.path.join(manifest.workbench_path, "InitGui.py"))
if not has_init and not has_gui:
manifest.state = AddonState.SKIPPED
manifest.error = f"No Init.py or InitGui.py in {manifest.workbench_path}"
FreeCAD.Console.PrintWarning(
f"Create: Skipping {manifest.name}: {manifest.error}\n"
)
return False
manifest.state = AddonState.VALIDATED
return True
# ---------------------------------------------------------------------------
# Dependency resolution
# ---------------------------------------------------------------------------
def resolve_load_order(
manifests: list[AddonManifest], mods_dir: str
) -> list[AddonManifest]:
"""Sort addons by dependencies, then by (load_priority, name).
If no addons declare a <kindred> element, fall back to the legacy
hard-coded order for backward compatibility.
"""
if not manifests:
return []
by_name = {m.name: m for m in manifests}
any_kindred = any(m.has_kindred_element for m in manifests)
if not any_kindred:
# Legacy fallback: use hard-coded order matched by directory name
return _legacy_order(manifests, mods_dir)
# Topological sort with graphlib
from graphlib import CycleError, TopologicalSorter
ts = TopologicalSorter()
for m in manifests:
# Only include dependencies that are actually discovered
known_deps = [d for d in m.dependencies if d in by_name]
unknown_deps = [d for d in m.dependencies if d not in by_name]
for dep in unknown_deps:
m.state = AddonState.SKIPPED
m.error = f"Missing dependency: {dep}"
FreeCAD.Console.PrintWarning(f"Create: Skipping {m.name}: {m.error}\n")
if m.state != AddonState.SKIPPED:
ts.add(m.name, *known_deps)
try:
# Process level by level so we can sort within each topological level
ts.prepare()
order = []
while ts.is_active():
ready = list(ts.get_ready())
# Sort each level by (priority, name) for determinism
ready.sort(key=lambda n: (by_name[n].load_priority, n) if n in by_name else (999, n))
for name in ready:
ts.done(name)
order.extend(ready)
except CycleError as e:
FreeCAD.Console.PrintWarning(
f"Create: Dependency cycle detected: {e}. Falling back to priority order.\n"
)
return sorted(
[m for m in manifests if m.state != AddonState.SKIPPED],
key=lambda m: (m.load_priority, m.name),
)
# Filter to actual manifests, preserving sorted topological order
result = []
for name in order:
m = by_name.get(name)
if m is not None and m.state != AddonState.SKIPPED:
result.append(m)
return result
def _legacy_order(manifests: list[AddonManifest], mods_dir: str) -> list[AddonManifest]:
"""Order addons using the legacy hard-coded list, matched by directory path."""
by_dir = {}
for m in manifests:
# Extract the top-level directory name under mods/
rel = os.path.relpath(m.addon_root, mods_dir)
top_dir = rel.split(os.sep)[0]
by_dir[top_dir] = m
ordered = []
for dir_name in _LEGACY_ORDER:
if dir_name in by_dir:
ordered.append(by_dir.pop(dir_name))
# Append any addons not in the legacy list (alphabetically)
for name in sorted(by_dir.keys()):
ordered.append(by_dir[name])
return ordered
# ---------------------------------------------------------------------------
# Loading
# ---------------------------------------------------------------------------
def _load_addon(manifest: AddonManifest, gui: bool = False):
"""Execute an addon's Init.py or InitGui.py."""
init_file = "InitGui.py" if gui else "Init.py"
filepath = os.path.join(manifest.workbench_path, init_file)
if not os.path.isfile(filepath):
return
# Ensure workbench path is in sys.path
if manifest.workbench_path not in sys.path:
sys.path.insert(0, manifest.workbench_path)
start = time.monotonic()
try:
with open(filepath) as f:
exec_globals = globals().copy()
exec_globals["__file__"] = filepath
exec_globals["__name__"] = manifest.name
exec(compile(f.read(), filepath, "exec"), exec_globals)
elapsed = (time.monotonic() - start) * 1000
if not gui:
manifest.load_time_ms = elapsed
else:
manifest.load_time_ms += elapsed
manifest.state = AddonState.LOADED
FreeCAD.Console.PrintLog(
f"Create: Loaded {manifest.name} {init_file} ({elapsed:.0f}ms)\n"
)
except Exception as e:
manifest.state = AddonState.FAILED
manifest.error = str(e)
FreeCAD.Console.PrintWarning(f"Create: Failed to load {manifest.name}: {e}\n")
# ---------------------------------------------------------------------------
# Top-level API
# ---------------------------------------------------------------------------
def _get_create_version() -> str:
try:
from version import VERSION
return VERSION
except ImportError:
return "0.0.0"
def load_addons(gui: bool = False):
"""Load Kindred addons from mods/.
Called twice: once from Init.py (gui=False) to run each addon's Init.py,
and once from InitGui.py (gui=True) to run each addon's InitGui.py.
The gui=False call runs the full pipeline and builds the registry.
The gui=True call reuses the registry and loads InitGui.py for each
successfully loaded addon.
"""
global _registry
mods_dir = os.path.join(FreeCAD.getHomePath(), "mods")
if not gui:
# Full pipeline: scan -> parse -> validate -> sort -> load -> register
manifests = scan_addons(mods_dir)
for m in manifests:
parse_manifest(m)
create_version = _get_create_version()
validated = [m for m in manifests if validate_manifest(m, create_version)]
ordered = resolve_load_order(validated, mods_dir)
_registry = AddonRegistry()
for m in manifests:
_registry.register(m)
_registry.set_load_order([m.name for m in ordered])
FreeCAD.KindredAddons = _registry
for m in ordered:
_load_addon(m, gui=False)
else:
# GUI phase: reuse registry, load InitGui.py in load order
if _registry is None:
FreeCAD.Console.PrintWarning(
"Create: Addon registry not initialized, skipping GUI load\n"
)
return
for m in _registry.loaded():
_load_addon(m, gui=True)
def getAddonRegistry() -> Optional[AddonRegistry]:
"""Return the addon registry singleton, or None if not yet initialized.
Exposed as FreeCAD.getAddonRegistry() for runtime introspection.
"""
return _registry

View File

@@ -18,6 +18,78 @@ import FreeCAD
# Cache: filepath -> {entry_name: bytes}
_silo_cache = {}
# Pre-reinject hooks: called with (doc, filename, entries) before ZIP write.
_pre_reinject_hooks = []
def register_pre_reinject(callback):
"""Register a callback invoked before silo/ entries are written to ZIP.
Signature: callback(doc, filename, entries) -> None
``entries`` is a dict {entry_name: bytes} or None. Mutate in place.
"""
_pre_reinject_hooks.append(callback)
def _metadata_save_hook(doc, filename, entries):
"""Write dirty metadata back to the silo/ cache before ZIP write."""
obj = doc.getObject("SiloMetadata")
if obj is None or not hasattr(obj, "Proxy"):
return
proxy = obj.Proxy
if proxy is None or not proxy.is_dirty():
return
entries["silo/metadata.json"] = obj.RawContent.encode("utf-8")
register_pre_reinject(_metadata_save_hook)
def _manifest_enrich_hook(doc, filename, entries):
"""Populate silo_instance and part_uuid from the tracked Silo object."""
raw = entries.get("silo/manifest.json")
if raw is None:
return
try:
manifest = json.loads(raw)
except (json.JSONDecodeError, ValueError):
return
changed = False
# Populate part_uuid from SiloItemId if available.
for obj in doc.Objects:
if hasattr(obj, "SiloItemId") and obj.SiloItemId:
if manifest.get("part_uuid") != obj.SiloItemId:
manifest["part_uuid"] = obj.SiloItemId
changed = True
break
# Populate silo_instance from Silo settings.
if not manifest.get("silo_instance"):
try:
import silo_commands
api_url = silo_commands._get_api_url()
if api_url:
# Strip /api suffix to get base instance URL.
instance = api_url.rstrip("/")
if instance.endswith("/api"):
instance = instance[:-4]
manifest["silo_instance"] = instance
changed = True
except Exception:
pass
if changed:
entries["silo/manifest.json"] = (json.dumps(manifest, indent=2) + "\n").encode(
"utf-8"
)
register_pre_reinject(_manifest_enrich_hook)
KC_VERSION = "1.0"
@@ -62,6 +134,15 @@ class _KcFormatObserver:
_silo_cache.pop(filename, None)
return
entries = _silo_cache.pop(filename, None)
if entries is None:
entries = {}
for _hook in _pre_reinject_hooks:
try:
_hook(doc, filename, entries)
except Exception as exc:
FreeCAD.Console.PrintWarning(
f"kc_format: pre_reinject hook failed: {exc}\n"
)
try:
with zipfile.ZipFile(filename, "a") as zf:
existing = set(zf.namelist())
@@ -97,6 +178,34 @@ class _KcFormatObserver:
)
def update_manifest_fields(filename, updates):
"""Update fields in an existing .kc manifest after save.
*filename*: path to the .kc file.
*updates*: dict of field_name -> value to merge into the manifest.
Used by silo_commands to write ``revision_hash`` after a successful
upload (which happens after the ZIP has already been written by save).
"""
if not filename or not filename.lower().endswith(".kc"):
return
if not os.path.isfile(filename):
return
try:
with zipfile.ZipFile(filename, "a") as zf:
if "silo/manifest.json" not in zf.namelist():
return
raw = zf.read("silo/manifest.json")
manifest = json.loads(raw)
manifest.update(updates)
zf.writestr(
"silo/manifest.json",
json.dumps(manifest, indent=2) + "\n",
)
except Exception as e:
FreeCAD.Console.PrintWarning(f"kc_format: failed to update manifest: {e}\n")
def register():
"""Connect to application-level save signals."""
FreeCAD.addDocumentObserver(_KcFormatObserver())

View File

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#cba6f7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<!-- Padlock body -->
<rect x="5" y="11" width="14" height="10" rx="2" fill="#313244" stroke="#cba6f7"/>
<!-- Padlock shackle -->
<path d="M8 11V7a4 4 0 0 1 8 0v4" fill="none" stroke="#89dceb"/>
<!-- Keyhole -->
<circle cx="12" cy="16" r="1.5" fill="#89dceb" stroke="none"/>
</svg>

After

Width:  |  Height:  |  Size: 448 B

View File

@@ -0,0 +1,12 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#cba6f7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<!-- Outer box -->
<rect x="3" y="3" width="18" height="18" rx="2" fill="#313244"/>
<!-- List lines (BOM rows) -->
<line x1="8" y1="8" x2="18" y2="8" stroke="#89dceb" stroke-width="1.5"/>
<line x1="8" y1="12" x2="18" y2="12" stroke="#89dceb" stroke-width="1.5"/>
<line x1="8" y1="16" x2="18" y2="16" stroke="#89dceb" stroke-width="1.5"/>
<!-- Hierarchy dots -->
<circle cx="6" cy="8" r="1" fill="#cba6f7"/>
<circle cx="6" cy="12" r="1" fill="#cba6f7"/>
<circle cx="6" cy="16" r="1" fill="#cba6f7"/>
</svg>

After

Width:  |  Height:  |  Size: 680 B

View File

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#cba6f7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<!-- Folder open icon -->
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" fill="#313244"/>
<path d="M2 10h20" stroke="#6c7086"/>
<!-- Search magnifier -->
<circle cx="17" cy="15" r="3" fill="#1e1e2e" stroke="#a6e3a1" stroke-width="1.5"/>
<line x1="19.5" y1="17.5" x2="22" y2="20" stroke="#a6e3a1" stroke-width="1.5"/>
</svg>

After

Width:  |  Height:  |  Size: 529 B

View File

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#cba6f7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<!-- Counter-clockwise arrow -->
<polyline points="1 4 1 10 7 10" stroke="#f38ba8"/>
<path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10" stroke="#cba6f7"/>
<!-- Clock hands -->
<line x1="12" y1="7" x2="12" y2="12" stroke="#89dceb" stroke-width="1.5"/>
<line x1="12" y1="12" x2="15" y2="14" stroke="#89dceb" stroke-width="1.5"/>
</svg>

After

Width:  |  Height:  |  Size: 493 B

View File

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#cba6f7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<!-- Cloud -->
<path d="M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z" fill="#313244"/>
<!-- Upload arrow -->
<path d="M12 18v-5m0 0l-2 2m2-2l2 2" stroke="#a6e3a1" stroke-width="2"/>
<line x1="12" y1="13" x2="12" y2="9" stroke="#a6e3a1" stroke-width="2"/>
</svg>

After

Width:  |  Height:  |  Size: 427 B

View File

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#cba6f7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<!-- Folder open icon -->
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" fill="#313244"/>
<path d="M2 10h20" stroke="#6c7086"/>
<!-- Search magnifier -->
<circle cx="17" cy="15" r="3" fill="#1e1e2e" stroke="#a6e3a1" stroke-width="1.5"/>
<line x1="19.5" y1="17.5" x2="22" y2="20" stroke="#a6e3a1" stroke-width="1.5"/>
</svg>

After

Width:  |  Height:  |  Size: 529 B

View File

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#cba6f7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<!-- Document with plus -->
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" fill="#313244"/>
<polyline points="14 2 14 8 20 8" fill="#45475a" stroke="#cba6f7"/>
<!-- Plus sign -->
<line x1="12" y1="11" x2="12" y2="17" stroke="#a6e3a1" stroke-width="2"/>
<line x1="9" y1="14" x2="15" y2="14" stroke="#a6e3a1" stroke-width="2"/>
</svg>

After

Width:  |  Height:  |  Size: 521 B

View File

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#cba6f7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<!-- Folder open icon -->
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" fill="#313244"/>
<path d="M2 10h20" stroke="#6c7086"/>
<!-- Search magnifier -->
<circle cx="17" cy="15" r="3" fill="#1e1e2e" stroke="#a6e3a1" stroke-width="1.5"/>
<line x1="19.5" y1="17.5" x2="22" y2="20" stroke="#a6e3a1" stroke-width="1.5"/>
</svg>

After

Width:  |  Height:  |  Size: 529 B

View File

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#cba6f7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<!-- Info circle -->
<circle cx="12" cy="12" r="10" fill="#313244"/>
<line x1="12" y1="16" x2="12" y2="12" stroke="#89dceb" stroke-width="2"/>
<circle cx="12" cy="8" r="0.5" fill="#89dceb" stroke="#89dceb"/>
</svg>

After

Width:  |  Height:  |  Size: 377 B

View File

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#cba6f7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<!-- Tag shape -->
<path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z" fill="#313244"/>
<!-- Tag hole -->
<circle cx="7" cy="7" r="1.5" fill="#cba6f7" stroke="none"/>
</svg>

After

Width:  |  Height:  |  Size: 373 B

View File

@@ -0,0 +1,85 @@
"""
silo_document.py - Document observer that builds the Silo metadata tree
when a .kc file is opened in FreeCAD.
Hooks slotCreatedDocument (primary) and slotActivateDocument (fallback)
to detect .kc opens, then defers tree building to the next event loop
tick via QTimer.singleShot(0, ...) so the document is fully loaded.
"""
import FreeCAD
_observer = None
def _on_kc_restored(doc):
"""Deferred callback: build the Silo tree after document is fully loaded."""
try:
filename = doc.FileName
if not filename:
return
from silo_tree import SiloTreeBuilder
contents = SiloTreeBuilder.read_silo_directory(filename)
if contents:
SiloTreeBuilder.build_tree(doc, contents)
except Exception as exc:
FreeCAD.Console.PrintWarning(
f"silo_document: failed to build silo tree for {doc.Name!r}: {exc}\n"
)
class SiloDocumentObserver:
"""Singleton observer that triggers Silo tree creation for .kc files."""
def slotCreatedDocument(self, doc):
"""Called when a document is created or opened."""
try:
filename = doc.FileName
if not filename or not filename.lower().endswith(".kc"):
return
from PySide.QtCore import QTimer
QTimer.singleShot(0, lambda: _on_kc_restored(doc))
except Exception as exc:
FreeCAD.Console.PrintWarning(
f"silo_document: slotCreatedDocument error: {exc}\n"
)
def slotActivateDocument(self, doc):
"""Fallback for documents opened before observer registration."""
try:
filename = doc.FileName
if not filename or not filename.lower().endswith(".kc"):
return
if doc.getObject("Silo") is not None:
return
from PySide.QtCore import QTimer
QTimer.singleShot(0, lambda: _on_kc_restored(doc))
except Exception as exc:
FreeCAD.Console.PrintWarning(
f"silo_document: slotActivateDocument error: {exc}\n"
)
def slotDeletedDocument(self, doc):
"""Placeholder for future cleanup."""
pass
def register():
"""Register the singleton observer. Safe to call multiple times."""
global _observer
if _observer is not None:
return
_observer = SiloDocumentObserver()
FreeCAD.addDocumentObserver(_observer)
FreeCAD.Console.PrintLog("silo_document: observer registered\n")
# Bootstrap: handle documents already open before registration.
try:
for doc in FreeCAD.listDocuments().values():
_observer.slotActivateDocument(doc)
except Exception as exc:
FreeCAD.Console.PrintWarning(f"silo_document: bootstrap scan failed: {exc}\n")

View File

@@ -0,0 +1,70 @@
"""
silo_objects.py - Create FeaturePython proxy for Silo tree leaf nodes.
Each silo/ ZIP entry in a .kc file gets one SiloViewerObject in the
FreeCAD document tree. All properties are Transient so they are never
persisted in Document.xml.
"""
import FreeCAD
class SiloViewerObject:
"""Proxy for App::FeaturePython silo viewer nodes.
Properties (all Transient):
SiloPath - ZIP entry path, e.g. "silo/manifest.json"
ContentType - "json", "yaml", or "py"
RawContent - decoded UTF-8 content of the entry
"""
def __init__(self, obj):
obj.Proxy = self
obj.addProperty(
"App::PropertyString",
"SiloPath",
"Silo",
"ZIP entry path of this silo item",
)
obj.addProperty(
"App::PropertyString",
"ContentType",
"Silo",
"Content type of this silo item",
)
obj.addProperty(
"App::PropertyString",
"RawContent",
"Silo",
"Raw text content of this silo entry",
)
obj.setPropertyStatus("SiloPath", "Transient")
obj.setPropertyStatus("ContentType", "Transient")
obj.setPropertyStatus("RawContent", "Transient")
obj.setEditorMode("SiloPath", 1) # read-only in property panel
obj.setEditorMode("ContentType", 1)
obj.setEditorMode("RawContent", 2) # hidden in property panel
def execute(self, obj):
pass
def mark_dirty(self):
"""Flag this object's content as modified by a viewer widget."""
self._dirty = True
def is_dirty(self):
"""Return True if content has been modified since last save."""
return getattr(self, "_dirty", False)
def clear_dirty(self):
"""Clear the dirty flag after saving."""
self._dirty = False
def __getstate__(self):
return None
def __setstate__(self, state):
pass

229
src/Mod/Create/silo_tree.py Normal file
View File

@@ -0,0 +1,229 @@
"""
silo_tree.py - Builds the Silo metadata tree in the FreeCAD document.
Reads silo/ entries from a .kc ZIP and creates a conditional hierarchy
of App::FeaturePython and App::DocumentObjectGroup objects in the
document tree.
Tree structure:
Silo (App::DocumentObjectGroup)
+-- Manifest (always present)
+-- Metadata (if metadata.json is non-empty)
+-- History (if history.json has revisions)
+-- Approvals (if approvals.json has eco field)
+-- Dependencies (if dependencies.json has links)
+-- Jobs (group, if silo/jobs/ has YAML files)
| +-- default.yaml
+-- Macros (group, if silo/macros/ has .py files)
+-- on_save
"""
import json
import zipfile
import FreeCAD
_SILO_GROUP_NAME = "Silo"
# Top-level silo/ entries with their object names, labels, and
# optional JSON field checks for conditional creation.
_KNOWN_ENTRIES = [
# (zip_name, object_name, label, json_check)
# json_check is None (always create) or (field_name, check_fn)
("silo/manifest.json", "SiloManifest", "Manifest", None),
("silo/metadata.json", "SiloMetadata", "Metadata", None),
(
"silo/history.json",
"SiloHistory",
"History",
("revisions", lambda v: isinstance(v, list) and len(v) > 0),
),
(
"silo/approvals.json",
"SiloApprovals",
"Approvals",
("eco", lambda v: v is not None),
),
(
"silo/dependencies.json",
"SiloDependencies",
"Dependencies",
("links", lambda v: isinstance(v, list) and len(v) > 0),
),
]
def _content_type(entry_name):
"""Determine content type from ZIP entry name."""
if entry_name.endswith(".json"):
return "json"
if entry_name.endswith((".yaml", ".yml")):
return "yaml"
if entry_name.endswith(".py"):
return "py"
return "text"
def _decode(data):
"""Decode bytes to UTF-8 string, returning '' on failure."""
try:
return data.decode("utf-8")
except Exception:
return ""
def _should_create(data, json_check):
"""Check whether a conditional node should be created."""
if json_check is None:
return True
field_name, check_fn = json_check
try:
parsed = json.loads(data)
return check_fn(parsed.get(field_name))
except Exception:
return False
def _create_leaf(doc, parent, entry_name, data, obj_name, label):
"""Create one App::FeaturePython leaf and add it to parent group."""
from silo_objects import SiloViewerObject
from silo_viewproviders import SiloViewerViewProvider
obj = doc.addObject("App::FeaturePython", obj_name)
SiloViewerObject(obj)
obj.SiloPath = entry_name
obj.ContentType = _content_type(entry_name)
obj.RawContent = _decode(data)
obj.Label = label
try:
import FreeCADGui # noqa: F401
if obj.ViewObject is not None:
SiloViewerViewProvider(obj.ViewObject)
except ImportError:
pass # headless mode
parent.addObject(obj)
return obj
class SiloTreeBuilder:
"""Reads silo/ from a .kc ZIP and builds the document tree."""
@staticmethod
def read_silo_directory(filename):
"""Read silo/ entries from a .kc ZIP.
Returns dict {entry_name: bytes}, e.g. {"silo/manifest.json": b"..."}.
Returns {} on failure.
"""
entries = {}
try:
with zipfile.ZipFile(filename, "r") as zf:
for name in zf.namelist():
if name.startswith("silo/") and not name.endswith("/"):
entries[name] = zf.read(name)
except Exception as exc:
FreeCAD.Console.PrintWarning(
f"silo_tree: could not read silo/ from {filename!r}: {exc}\n"
)
return entries
@staticmethod
def build_tree(doc, silo_contents):
"""Create the Silo group hierarchy in doc from silo/ entries."""
if not silo_contents:
return
SiloTreeBuilder.remove_silo_tree(doc)
root = doc.addObject("App::DocumentObjectGroup", _SILO_GROUP_NAME)
root.Label = "Silo"
# Top-level known entries (conditional creation)
for zip_name, obj_name, label, json_check in _KNOWN_ENTRIES:
if zip_name not in silo_contents:
continue
data = silo_contents[zip_name]
if not _should_create(data, json_check):
continue
_create_leaf(doc, root, zip_name, data, obj_name, label)
# Jobs subgroup
job_entries = {
k: v
for k, v in silo_contents.items()
if k.startswith("silo/jobs/") and not k.endswith("/")
}
if job_entries:
jobs_group = doc.addObject("App::DocumentObjectGroup", "SiloJobs")
jobs_group.Label = "Jobs"
root.addObject(jobs_group)
for entry_name in sorted(job_entries):
basename = entry_name.split("/")[-1]
safe_name = "SiloJob_" + basename.replace(".", "_").replace("-", "_")
_create_leaf(
doc,
jobs_group,
entry_name,
job_entries[entry_name],
safe_name,
basename,
)
# Macros subgroup
macro_entries = {
k: v
for k, v in silo_contents.items()
if k.startswith("silo/macros/") and not k.endswith("/")
}
if macro_entries:
macros_group = doc.addObject("App::DocumentObjectGroup", "SiloMacros")
macros_group.Label = "Macros"
root.addObject(macros_group)
for entry_name in sorted(macro_entries):
basename = entry_name.split("/")[-1]
label = basename[:-3] if basename.endswith(".py") else basename
safe_name = "SiloMacro_" + basename.replace(".", "_").replace("-", "_")
_create_leaf(
doc,
macros_group,
entry_name,
macro_entries[entry_name],
safe_name,
label,
)
doc.recompute()
FreeCAD.Console.PrintLog(
f"silo_tree: built tree with {len(silo_contents)} entries in {doc.Name!r}\n"
)
@staticmethod
def remove_silo_tree(doc):
"""Remove the Silo group and all descendants. Safe if absent."""
root = doc.getObject(_SILO_GROUP_NAME)
if root is None:
return
names = []
def _collect(obj):
if obj.Name in names:
return
names.append(obj.Name)
if hasattr(obj, "OutList"):
for child in obj.OutList:
_collect(child)
_collect(root)
for name in reversed(names):
try:
doc.removeObject(name)
except Exception as exc:
FreeCAD.Console.PrintWarning(
f"silo_tree: could not remove {name!r}: {exc}\n"
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,113 @@
"""
silo_viewproviders.py - ViewProvider proxy for Silo tree leaf nodes.
Controls tree icon, double-click behavior, and context menu for
SiloViewerObject nodes in the document tree.
"""
import os
# Icon directory — Phase 6 will add SVGs here.
_ICON_DIR = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"resources",
"icons",
)
# Map silo/ paths to icon basenames (without .svg extension).
_SILO_PATH_ICONS = {
"silo/manifest.json": "silo-manifest",
"silo/metadata.json": "silo-metadata",
"silo/history.json": "silo-history",
"silo/approvals.json": "silo-approvals",
"silo/dependencies.json": "silo-dependencies",
}
# Prefix-based fallbacks for subdirectory entries.
_SILO_PREFIX_ICONS = {
"silo/jobs/": "silo-job",
"silo/macros/": "silo-macro",
}
def _icon_for_path(silo_path):
"""Return absolute icon path for a silo/ entry, or '' if not found."""
name = _SILO_PATH_ICONS.get(silo_path)
if name is None:
for prefix, icon_name in _SILO_PREFIX_ICONS.items():
if silo_path.startswith(prefix):
name = icon_name
break
if name is None:
return ""
path = os.path.join(_ICON_DIR, f"{name}.svg")
return path if os.path.exists(path) else ""
class SiloViewerViewProvider:
"""ViewProvider proxy for SiloViewerObject leaf nodes."""
def __init__(self, vobj):
vobj.Proxy = self
self.Object = vobj.Object
def attach(self, vobj):
"""Store back-reference; called on document restore."""
self.Object = vobj.Object
def getIcon(self):
"""Return icon path based on SiloPath; '' uses FreeCAD default."""
try:
return _icon_for_path(self.Object.SiloPath)
except Exception:
return ""
def doubleClicked(self, vobj):
"""Open a read-only MDI viewer for this silo node."""
try:
import FreeCADGui
from PySide import QtWidgets
from silo_viewers import create_viewer_widget
obj = vobj.Object
widget = create_viewer_widget(obj)
if widget is None:
return False
mw = FreeCADGui.getMainWindow()
mdi = mw.findChild(QtWidgets.QMdiArea)
if mdi is None:
return False
# Reuse existing subwindow if already open for this object
target_name = widget.objectName()
for sw in mdi.subWindowList():
if sw.widget() and sw.widget().objectName() == target_name:
widget.deleteLater()
mdi.setActiveSubWindow(sw)
sw.show()
return True
sw = mdi.addSubWindow(widget)
sw.setWindowTitle(getattr(widget, "WINDOW_TITLE", "Silo Viewer"))
sw.show()
mdi.setActiveSubWindow(sw)
return True
except Exception as exc:
import FreeCAD
FreeCAD.Console.PrintWarning(
f"silo_viewproviders: doubleClicked failed: {exc}\n"
)
return False
def setupContextMenu(self, vobj, menu):
"""Phase 1: no context menu items."""
pass
def __getstate__(self):
return None
def __setstate__(self, state):
pass

View File

@@ -0,0 +1,92 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <gtest/gtest.h>
#include <QApplication>
#include <QDir>
#include <QFile>
#include <QTemporaryDir>
#include <Gui/BitmapFactory.h>
#include <src/App/InitApplication.h>
namespace
{
// Minimal valid SVG used as test icon
constexpr const char* kTestSvg =
R"(<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64")"
R"( viewBox="0 0 64 64"><rect width="64" height="64" fill="#ff0000"/></svg>)";
} // namespace
class BitmapFactoryTest : public ::testing::Test
{
protected:
static void SetUpTestSuite()
{
tests::initApplication();
// QPixmap and QSvgRenderer require a QGuiApplication.
// gtest_main does not create one, so we construct it here.
if (!QApplication::instance()) {
static int argc = 1;
static char arg0[] = "Gui_tests_run";
static char* argv[] = {arg0, nullptr};
static QApplication app(argc, argv);
}
}
};
// pixmapFromSvg(content, size) renders at the exact requested size
TEST_F(BitmapFactoryTest, PixmapFromSvgContentRendersAtRequestedSize)
{
QByteArray svg(kTestSvg);
QSize requested(48, 48);
QPixmap px = Gui::BitmapFactory().pixmapFromSvg(svg, requested);
ASSERT_FALSE(px.isNull());
EXPECT_EQ(px.width(), 48);
EXPECT_EQ(px.height(), 48);
}
// getMaximumDPR returns at least 1.0
TEST_F(BitmapFactoryTest, MaximumDPRIsAtLeastOne)
{
qreal dpr = Gui::BitmapFactoryInst::getMaximumDPR();
EXPECT_GE(dpr, 1.0);
}
// pixmap() loaded from an SVG file has correct devicePixelRatio and physical size
TEST_F(BitmapFactoryTest, PixmapFromSvgFileHasCorrectDPR)
{
// Write a test SVG to a temporary directory
QTemporaryDir tmpDir;
ASSERT_TRUE(tmpDir.isValid());
QString svgPath = tmpDir.path() + QDir::separator() + "test-dpi-icon.svg";
QFile file(svgPath);
ASSERT_TRUE(file.open(QFile::WriteOnly | QFile::Text));
file.write(kTestSvg);
file.close();
// Add the temp dir as a search path and load via pixmap()
Gui::BitmapFactory().addPath(tmpDir.path());
QPixmap px = Gui::BitmapFactory().pixmap("test-dpi-icon");
ASSERT_FALSE(px.isNull());
qreal expectedDpr = Gui::BitmapFactoryInst::getMaximumDPR();
EXPECT_DOUBLE_EQ(px.devicePixelRatio(), expectedDpr);
// Physical size should be 64 * dpr
int expectedPhysical = static_cast<int>(64 * expectedDpr);
EXPECT_EQ(px.width(), expectedPhysical);
EXPECT_EQ(px.height(), expectedPhysical);
Gui::BitmapFactory().removePath(tmpDir.path());
}

View File

@@ -3,6 +3,7 @@
# Standard C++ GTest tests
add_executable(Gui_tests_run
Assistant.cpp
BitmapFactory.cpp
Camera.cpp
StyleParameters/StyleParametersApplicationTest.cpp
StyleParameters/ParserTest.cpp

View File

@@ -98,6 +98,7 @@ sys.modules["silo_client._ssl"] = mock.MagicMock()
# Add addon source paths
sys.path.insert(0, str(_REPO_ROOT / "src" / "Mod" / "Create"))
sys.path.insert(0, str(_REPO_ROOT / "mods" / "sdk"))
sys.path.insert(0, str(_REPO_ROOT / "mods" / "ztools" / "ztools"))
sys.path.insert(0, str(_REPO_ROOT / "mods" / "silo" / "freecad"))