skillwiki 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,88 +3,113 @@ version: 0.2.1
3
3
  name: wiki-sync
4
4
  description: Safely sync the vault git repository. Runs skillwiki sync status, then guides push or pull with lint guards and conflict resolution.
5
5
  ---
6
-
7
6
  # wiki-sync
8
-
9
7
  ## When This Skill Activates
10
-
11
8
  - User wants to push local vault changes to the remote.
12
9
  - User wants to pull remote changes into their local vault.
13
10
  - User asks about vault sync status, git state, or multi-device coordination.
14
11
  - Periodic maintenance before or after editing sessions.
15
-
16
12
  ## Pre-orientation reads
17
-
18
13
  Standard four reads.
19
-
20
14
  ## Steps
21
-
22
15
  0. Resolve vault: `skillwiki path` (record source for context).
23
16
  1. Run `skillwiki sync status <vault>`. Read the JSON output.
24
- - Exit code 0: vault is clean (nothing to sync).
25
- - Exit code 22: warnings — dirty/ahead/behind (needs action).
17
+ - Exit code 0: vault is clean (nothing to sync).
18
+ - Exit code 22: warnings — dirty/ahead/behind (needs action).
26
19
  2. Present the current state: `status`, `dirty`, `ahead`, `behind`, `last_commit`.
27
20
  3. Ask the user which operation they want: **push**, **pull**, or **both** (pull then push).
28
-
29
21
  ### Push workflow
30
-
31
22
  4. If vault is dirty, ask the user to review uncommitted changes before proceeding.
32
23
  5. Run `skillwiki lint <vault>`. If errors exist, stop and report — do not push lint errors to remote.
33
24
  6. If lint passes (errors = 0), stage and commit:
34
- - `git -C <vault> add -A`
35
- - `git -C <vault> commit -m "sync: vault update $(date -u +%Y-%m-%dT%H:%MZ)"`
25
+ - `git -C <vault> add -A`
26
+ - `git -C <vault> commit -m "sync: vault update $(date -u +%Y-%m-%dT%H:%MZ)"`
36
27
  7. Run `git -C <vault> push origin HEAD`. Report result.
37
28
  8. Append one `log.md` entry summarizing: files pushed, lint result, commit hash.
38
-
39
29
  ### Pull workflow
40
-
41
30
  9. If vault is dirty, stash first: `git -C <vault> stash push -m "auto-stash before pull $(date -u +%Y-%m-%dT%H:%MZ)"`.
42
31
  10. Run `git -C <vault> pull --rebase origin HEAD`. Report result.
43
32
  11. If a stash was created, pop it: `git -C <vault> stash pop`.
44
33
  12. If conflicts occur during stash pop, identify them and present to the user for resolution (see Conflict Resolution below).
45
34
  13. Run `skillwiki lint <vault>` after pull to verify vault integrity.
46
35
  14. Append one `log.md` entry summarizing: commits pulled, lint result, any conflicts.
47
-
48
36
  ### Pull-then-push workflow
49
-
50
37
  15. Execute the pull workflow (steps 9-13) first.
51
38
  16. Then execute the push workflow (steps 4-8).
52
-
53
39
  ## Conflict Resolution
54
-
55
40
  When merge conflicts are detected:
56
-
57
41
  - **Frontmatter conflicts:**
58
- - For `updated:` fields: always take the newer timestamp (compare both sides, keep the later one).
59
- - For all other frontmatter fields: present both versions to the user and ask which to keep.
42
+ - For `updated:` fields: always take the newer timestamp (compare both sides, keep the later one).
43
+ - For all other frontmatter fields: present both versions to the user and ask which to keep.
60
44
  - **Body conflicts:**
61
- - Do not auto-resolve body conflicts.
62
- - Mark unresolved regions with `???` on a line by itself between the conflicting versions, so the user can see both sides and decide.
63
- - Example:
64
- ```
65
- Content from local version
66
- ???
67
- Content from remote version
68
- ```
45
+ - Do not auto-resolve body conflicts.
46
+ - Mark unresolved regions with `???` on a line by itself between the conflicting versions, so the user can see both sides and decide.
47
+ - Example:
48
+ ```
49
+ Content from local version
50
+ ???
51
+ Content from remote version
52
+ ```
69
53
  - After resolving conflicts, run `skillwiki lint <vault>` to verify before committing.
70
-
71
54
  ## Multi-device coordination
72
-
73
55
  When the user mentions editing from Obsidian desktop and Claude Code on a server (or any two-device setup):
74
-
75
56
  - Recommend pulling before every editing session on each device.
76
57
  - Recommend pushing after every editing session on each device.
77
58
  - If both devices edit the same page between syncs, conflicts are inevitable — the Conflict Resolution section handles this.
78
59
  - Suggest enabling auto-commit in Obsidian (Community Plugins: `obsidian-git`) to reduce dirty-state drift.
79
-
60
+ ## Rclone-backed vault with git snapshotting (cron pattern)
61
+ Some deployments use a cloud-backed vault (`rclone mount`) with a separate git repository for versioned snapshots. This pattern separates "live working vault" from "versioned backup".
62
+ ### Architecture
63
+ ```
64
+ ~/wiki → rclone mount to cloud storage (S3/IDrive/etc) — live vault
65
+ ~/wiki-git → git repository cloned from GitHub — snapshot target
66
+ cron hourly → rsync ~/wiki/ → ~/wiki-git/ → git commit → git push
67
+ ```
68
+ ### Implementation (wiki-snapshot.sh)
69
+ ```bash
70
+ #!/bin/bash
71
+ WIKI_DIR="/root/wiki"
72
+ GIT_DIR="/root/wiki-git"
73
+ DATE=$(date +%Y%m%d_%H%M%S)
74
+ # Sync from rclone mount to git repo (quiet mode for slow mounts)
75
+ rsync -a --delete -q \
76
+ --exclude='.snapshots' --exclude='.git' --exclude='.obsidian' --exclude='.skillwiki' \
77
+ "$WIKI_DIR/" "$GIT_DIR/"
78
+ cd "$GIT_DIR" || exit 1
79
+ git config user.email "cron@hermes.local"
80
+ git config user.name "Hermes Snapshot"
81
+ # Check for changes
82
+ if [ -z "$(git status --porcelain)" ]; then
83
+ exit 0 # Nothing to commit
84
+ fi
85
+ git add -A
86
+ git commit -m "Snapshot $DATE"
87
+ # Pull with rebase to handle remote changes (e.g., README edits on GitHub)
88
+ if ! git pull --rebase origin main 2>/dev/null; then
89
+ git pull origin main 2>/dev/null || true
90
+ fi
91
+ git push origin main || echo "Push failed"
92
+ ```
93
+ ### Pitfalls specific to this pattern
94
+ 1. **Divergent branches from external pushes**: If something else pushes to the same GitHub repo (manual edits from macOS desktop, GitHub web UI edits, another server), the local `~/wiki-git` will diverge. The `--rebase` flag handles most cases, but if commits conflict:
95
+ ```bash
96
+ cd ~/wiki-git
97
+ git rebase --abort 2>/dev/null || true
98
+ git fetch origin main
99
+ git reset --hard origin/main
100
+ bash ~/.hermes/scripts/wiki-snapshot.sh # Re-sync fresh
101
+ ```
102
+ **Prevention**: Avoid editing the GitHub repo directly via web interface or uncoordinated clones. The canonical flow is:
103
+ - Server: rclone mount → rsync → git commit → git push
104
+ - macOS/desktop: git pull → edit → git commit → git push → server pulls on next cron
105
+ 2. **Slow rsync on rclone mounts**: The rclone FUSE mount can be slow for large directory listings. Use `rsync -q` (quiet) to reduce output overhead, and consider `--delete-delay` instead of `--delete` if file churn is high. The rclone mount latency can cause `du` and `find` operations to timeout — this is normal, not an error.
106
+ 3. **Golden Rule violation**: Never mix sync methods on the same vault. If using rclone mount + git snapshotting, do NOT also enable Obsidian Sync, Syncthing, or iCloud on `~/wiki`. The rclone mount IS the sync mechanism.
107
+ 4. **Credential exposure**: The rclone mount and git remote use different credentials. Ensure git credentials are cached or use HTTPS with token, but never commit rclone config to git.
80
108
  ## Stop conditions
81
-
82
109
  - `skillwiki sync status` reports `not_a_repo` — the vault is not a git repository. Advise the user to initialize one.
83
110
  - Lint errors are found before a push — do not push until resolved.
84
111
  - `git push` or `git pull` fails with a network error — report and stop.
85
-
86
112
  ## Forbidden
87
-
88
113
  - Pushing when lint errors exist.
89
114
  - Auto-resolving body conflicts without user review.
90
115
  - Force-pushing (`git push --force`).
@@ -64,6 +64,40 @@ Obsidian-compatible Mermaid rules:
64
64
  - Avoid `\n` in labels; use `<br/>` or single-line labels.
65
65
  - Keep node IDs ASCII and simple (`CMUX_DB`, `OC_GW`).
66
66
 
67
+ ## Ad-Hoc Capture Format
68
+
69
+ Ad-hoc captures are mutable working notes created during development
70
+ (via `/wiki-add-task` or filesystem drop). They live in `raw/transcripts/`.
71
+
72
+ ### Frontmatter
73
+
74
+ ```yaml
75
+ ---
76
+ source_url: # null for ad-hoc (locally originated)
77
+ created: YYYY-MM-DD # when capture was written
78
+ ingested: # filled by ingest pipeline (empty at creation)
79
+ kind: # idea | bug | task | note | other
80
+ project: # optional: "[[slug]]" for cross-reference
81
+ ---
82
+ ```
83
+
84
+ ### Fields
85
+
86
+ - `created`: Date the ad-hoc capture was created. Set by `/wiki-add-task` or filesystem.
87
+ - `ingested`: Date processed into typed knowledge. **Empty at creation.** Filled by `wiki-ingest`, `wiki-crystallize`.
88
+ - `kind`: Capture type. Affects dev-loop routing (`bug`/`task` → work items; `idea` → knowledge development).
89
+ - `project`: Optional project cross-reference. Enables `provenance_projects:` auto-linking.
90
+
91
+ ### vs Ingested Sources
92
+
93
+ | Aspect | Ad-Hoc Capture | Ingested Source |
94
+ |--------|----------------|-----------------|
95
+ | Location | `raw/transcripts/` | `raw/articles/`, `raw/papers/`, etc. |
96
+ | Mutability | Mutable (working notes) | Immutable after ingest |
97
+ | `sha256` | **Omitted** | Required |
98
+ | `created` | Required | Use `ingested` |
99
+ | Entry | `/wiki-add-task`, filesystem drop | `wiki-ingest`, `skillwiki fetch` |
100
+
67
101
  ## Obsidian Integration
68
102
 
69
103
  - **Attachment folder:** `raw/assets/` — binary assets (images, diagrams) live here.
@@ -0,0 +1,8 @@
1
+ ---
2
+ source_url:
3
+ created: {{date:YYYY-MM-DD}}
4
+ ingested: # filled by ingest pipeline
5
+ kind: # idea | bug | task | note | other
6
+ project: # optional: "[[slug]]"
7
+ ---
8
+