refactor: implement template-driven node tree and human-readable vault layout

Unified Node model: added template_id, fs_path, archived, sort_order fields.
Template registry: system templates embedded as JSON (folder/project/client/
document/recipe), with Registry for enabled/disabled/filtered access.
SafeDisplayNameToPathSegment: human-readable path segments with Cyrillic
support, illegal char replacement, uniqueness via numeric suffixes.
Sidebar refactored: system views (Today/Inbox/Activity) separate from
workspace tree. Creation menu built dynamically from enabled templates.
Create/Rename/Move: physical folder operations with fs_path update,
recursive descendant path updates.
DB migration 012: adds template_id, fs_path, archived columns.
Vault migration command: rebuilds fs_path for existing nodes.
Tests: safename, registry, node model, repository integration.
Docs: VAULT_LAYOUT.md, TEMPLATES.md, PLAN.md updated.
i18n: nav.system, nav.workspace, template.*, common.rename/archive,
migrate.* keys added to ru.json and en.json.
This commit is contained in:
2026-06-02 12:47:06 +08:00
parent 12f2916a24
commit 0b26f7e5b3
37 changed files with 1479 additions and 338 deletions
+16
View File
@@ -392,3 +392,19 @@ verstak/
- **Критично:** Wails требует Node.js для frontend-сборки
- **Критично:** go-sqlite3 + cgo; gcc уже установлен
- **Зависимость:** Steps 15+ ждут завершения step 14 (MVP stabilization)
---
## Phase 4: Template-Driven Architecture
Implemented in this commit:
- **Template system** — built-in system templates for folder, project, client, document, and recipe types.
Each template defines default modules, default files (`Overview.md`), and default subfolders.
- **Vault layout** — human-readable folder structure on disk. Every node gets a folder named after its
title (sanitized). Nesting reflects parent-child relationships. UUIDs are never exposed in user paths.
- **`.verstak/` directory** — app-internal data (db, backups, thumbnails, cache, sync, trash, history).
- **i18n keys** — new locale keys for `nav.*`, `template.*`, `common.archive`, and `migrate.*` namespaces
added to both `ru.json` and `en.json`.
- **Documentation** — `docs/VAULT_LAYOUT.md` (vault folder structure, rules, migration) and
`docs/TEMPLATES.md` (system templates, template structure JSON, UI integration).
+58
View File
@@ -0,0 +1,58 @@
# Template System
## What is a Template?
A template defines the **type**, **default structure**, and **available modules**
for a Node. Every workspace node is created from a template.
## System Templates
Verstak ships with these built-in (system) templates:
| ID | Type | Default Modules | Default Files | Default Folders |
|---|---|---|---|---|
| `folder.default` | folder | overview, children, activity | — | — |
| `project.default` | project | overview, notes, files, activity, actions, worklog | Overview.md | Documents, Notes, Files |
| `client.default` | client | overview, notes, files, activity, actions | Overview.md | Notes, Files |
| `document.default` | document | overview, files, activity | — | — |
| `recipe.default` | recipe | overview, notes, files, activity | Overview.md | — |
## Template Structure
```json
{
"id": "project.default",
"title": "Проект",
"type": "project",
"enabled": true,
"system": true,
"icon": "project",
"default_modules": ["overview", "notes", "files", "activity", "actions", "worklog"],
"default_files": [
{"path": "Overview.md", "content_template": "project_overview"}
],
"default_folders": ["Documents", "Notes", "Files"],
"allowed_parent_types": ["folder", "root"],
"allowed_child_templates": ["*"]
}
```
## How Templates Drive the UI
1. The creation menu is built from **enabled templates**.
2. When you right-click a node, you see "Create inside" → [list of enabled templates].
3. Selecting a template creates a Node with that template's type and defaults.
4. Disabling a template removes it from the creation menu.
## Template Fields
- **id** — unique identifier
- **title** — i18n key for display name
- **type** — technical type (folder, project, client, etc.)
- **enabled** — whether it appears in the creation menu
- **system** — whether it's a built-in template
- **default_modules** — which tabs/modules are available in the node view
- **default_files** — files to create inside the node folder
- **default_folders** — subfolders to create inside the node folder
- **allowed_parent_types** — which node types can be parents of this template
- **allowed_child_templates** — which templates are allowed as children ("*" = any)
+71
View File
@@ -0,0 +1,71 @@
# Vault Layout
## Philosophy
Verstak's vault is designed to be **human-readable**. You can close Verstak, open your vault
in any file manager, and find materials by browsing the folder structure.
## Structure
```
vault/
.verstak/ # App data — not user-facing
vault.db
backups/
thumbnails/
cache/
sync/
trash/
history/
Проекты/ # User-created workspace nodes
Рабочие/
Разработка серверной/
Overview.md
Documents/
Notes/
Files/
Archive/
Клиенты/
ИТ-Вектор/
Projects/
LMS/
Overview.md
Documents/
Contracts/
```
## Rules
1. **Every Node has a folder** — the folder name matches the node title (sanitized).
2. **Nesting reflects parent-child relationships** — if Node A is parent of Node B,
B's folder is inside A's folder.
3. **Safe names** — folder names preserve Cyrillic, spaces, and readable characters.
Illegal filename chars (`/\:*?"<>|`) are replaced. Control chars are removed.
4. **Uniqueness** — if a folder already exists, a numeric suffix is added:
`Project`, `Project (2)`, `Project (3)`
5. **No UUIDs in user paths** — UUIDs are stored in the database and in `.verstak/`,
never in the user-visible folder tree.
6. **Template default files** — templates may create default files like `Overview.md`
inside the node folder.
7. **Archive/Delete** — archiving sets `archived = true` but doesn't move the folder.
Deletion moves the folder to `.verstak/trash/`.
## `.verstak/` directory
Contains all application internal data:
- `vault.db` — SQLite database
- `backups/` — automatic vault backups
- `thumbnails/` — generated thumbnails
- `cache/` — temporary cache
- `sync/` — sync state and blobs
- `trash/` — moved here on deletion
- `history/` — file version history
## Migration
Existing vaults can be migrated with the `MigrateVaultLayout()` command,
which computes `fs_path` for every node based on the parent-child tree
and creates the corresponding folders on disk.