skillwiki 0.5.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +776 -204
- package/package.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/.codex-plugin/plugin.json +1 -1
- package/skills/package.json +1 -1
- package/skills/wiki-sync/SKILL.md +115 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skillwiki",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"skills": "./",
|
|
5
5
|
"description": "Project-aware Karpathy-style knowledge base for Claude Code: 18 prompt-only skills (wiki-*, proj-*, using-skillwiki) backed by the deterministic `skillwiki` CLI.",
|
|
6
6
|
"author": {
|
package/skills/package.json
CHANGED
|
@@ -1,47 +1,124 @@
|
|
|
1
1
|
---
|
|
2
|
-
version: 0.
|
|
2
|
+
version: 0.3.0
|
|
3
3
|
name: wiki-sync
|
|
4
|
-
description: Safely sync the vault git repository. Runs skillwiki sync status, then guides push or pull with lint guards and conflict resolution.
|
|
4
|
+
description: Safely sync the vault git repository — multi-session safe via advisory lockfile. Runs skillwiki sync status, then guides push or pull with lint guards and conflict resolution.
|
|
5
5
|
---
|
|
6
6
|
# wiki-sync
|
|
7
7
|
## When This Skill Activates
|
|
8
8
|
- User wants to push local vault changes to the remote.
|
|
9
9
|
- User wants to pull remote changes into their local vault.
|
|
10
10
|
- User asks about vault sync status, git state, or multi-device coordination.
|
|
11
|
+
- Multiple Claude Code sessions targeting the same vault.
|
|
11
12
|
- Periodic maintenance before or after editing sessions.
|
|
12
13
|
## Pre-orientation reads
|
|
13
14
|
Standard four reads.
|
|
14
15
|
## Steps
|
|
15
16
|
0. Resolve vault: `skillwiki path` (record source for context).
|
|
17
|
+
|
|
18
|
+
## Pre-flight peer check (multi-session safe)
|
|
19
|
+
|
|
20
|
+
**Before any git stash or pull/push operation**, check for peer sessions:
|
|
21
|
+
|
|
22
|
+
1. Run `skillwiki sync peers <vault>` to detect other sessions with active locks or recent `wiki-sync:*` stashes.
|
|
23
|
+
2. If any non-self peer is present (locked or has stashes newer than 5 minutes):
|
|
24
|
+
- Surface the peer's session_id, PID, and summary to the user
|
|
25
|
+
- Ask the user to wait for the peer to finish, or pass `--force` to proceed anyway
|
|
26
|
+
- If `--force` is not given and peer is detected, **abort and exit**
|
|
27
|
+
3. Acquire an advisory lock: `skillwiki sync lock <vault> --summary "wiki-sync <op>"` (where `<op>` is "pull" or "push")
|
|
28
|
+
- If lock is held (exit code 48), surface the holder (session_id, PID, summary) and abort
|
|
29
|
+
4. **Always pair with unlock on exit** (success or error):
|
|
30
|
+
- `skillwiki sync unlock <vault>` in a finally block or error handler
|
|
31
|
+
|
|
32
|
+
### Stash backlog warning
|
|
33
|
+
|
|
34
|
+
On every invocation, count `wiki-sync:*` stashes older than 24 hours via `skillwiki sync peers`:
|
|
35
|
+
- If any old stashes exist, warn the user: "Found N wiki-sync stash(es) older than 24h — audit and clean before proceeding"
|
|
36
|
+
- **Do not auto-drop old stashes** — the user audits each one
|
|
37
|
+
|
|
38
|
+
## Sync workflow
|
|
39
|
+
|
|
16
40
|
1. Run `skillwiki sync status <vault>`. Read the JSON output.
|
|
17
|
-
- Exit code 0: vault is clean (nothing to sync).
|
|
18
|
-
- Exit code 22: warnings — dirty/ahead/behind (needs action).
|
|
41
|
+
- Exit code 0: vault is clean (nothing to sync).
|
|
42
|
+
- Exit code 22: warnings — dirty/ahead/behind (needs action).
|
|
19
43
|
2. Present the current state: `status`, `dirty`, `ahead`, `behind`, `last_commit`.
|
|
20
44
|
3. Ask the user which operation they want: **push**, **pull**, or **both** (pull then push).
|
|
45
|
+
|
|
21
46
|
### Push workflow
|
|
22
47
|
4. If vault is dirty, ask the user to review uncommitted changes before proceeding.
|
|
23
48
|
5. Run `skillwiki lint <vault>`. If errors exist, stop and report — do not push lint errors to remote.
|
|
24
49
|
6. If lint passes (errors = 0), stage and commit:
|
|
25
|
-
- `git -C <vault> add -A`
|
|
26
|
-
- `git -C <vault> commit -m "sync: vault update $(date -u +%Y-%m-%dT%H:%MZ)"`
|
|
50
|
+
- `git -C <vault> add -A`
|
|
51
|
+
- `git -C <vault> commit -m "sync: vault update $(date -u +%Y-%m-%dT%H:%MZ)"`
|
|
27
52
|
7. Run `git -C <vault> push origin HEAD`. Report result.
|
|
28
53
|
8. Append one `log.md` entry summarizing: files pushed, lint result, commit hash.
|
|
54
|
+
|
|
29
55
|
### Pull workflow
|
|
30
|
-
9.
|
|
31
|
-
10.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
56
|
+
9. Run `skillwiki sync status <vault> --include-stashes` to check for untracked file collisions (see Untracked file fingerprint below).
|
|
57
|
+
10. If vault is dirty, stash first with the identifiable name format:
|
|
58
|
+
```bash
|
|
59
|
+
VAULT="<vault>"
|
|
60
|
+
SESSION_ID="$(echo $CLAUDE_SESSION_ID)" # or fallback to PID/hostname
|
|
61
|
+
CWD_HASH="$(echo -n "$VAULT" | sha256sum | cut -c1-8)"
|
|
62
|
+
ISO_TS="$(date -u +%Y-%m-%dT%H:%MZ)"
|
|
63
|
+
MSG="wiki-sync:${SESSION_ID}:${CWD_HASH}:${ISO_TS}:pre-pull"
|
|
64
|
+
git -C "$VAULT" stash push -m "$MSG"
|
|
65
|
+
```
|
|
66
|
+
11. Run `git -C <vault> pull --rebase origin HEAD`. Report result.
|
|
67
|
+
12. If a stash was created, pop it: `git -C <vault> stash pop`.
|
|
68
|
+
13. If conflicts occur during stash pop, identify them and present to the user for resolution (see Conflict Resolution below).
|
|
69
|
+
14. Run `skillwiki lint <vault>` after pull to verify vault integrity.
|
|
70
|
+
15. Append one `log.md` entry summarizing: commits pulled, lint result, any conflicts.
|
|
71
|
+
|
|
36
72
|
### Pull-then-push workflow
|
|
37
|
-
|
|
38
|
-
|
|
73
|
+
16. Execute the pull workflow (steps 9-14) first.
|
|
74
|
+
17. Then execute the push workflow (steps 4-8).
|
|
75
|
+
|
|
76
|
+
## Stash naming convention
|
|
77
|
+
|
|
78
|
+
When `wiki-sync` creates a stash, use the identifiable message format:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
wiki-sync:{session_id}:{cwd_hash}:{iso8601_timestamp}:{summary}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- **session_id**: prefer `$CLAUDE_SESSION_ID` env var if set, else `$$` (shell PID), else `unknown`
|
|
85
|
+
- **cwd_hash**: first 8 chars of sha256(`$VAULT` path)
|
|
86
|
+
- **iso8601_timestamp**: e.g., `2026-05-23T03:25:00Z` (UTC)
|
|
87
|
+
- **summary**: short label like `pre-pull`, `pre-push`, or custom reason
|
|
88
|
+
|
|
89
|
+
This allows any session to list `git stash list` and identify which stash came from which session/working directory.
|
|
90
|
+
|
|
91
|
+
## Untracked file fingerprint (pre-pull)
|
|
92
|
+
|
|
93
|
+
Before `git pull --rebase`, check for untracked files that exist on the remote and may collide:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
for f in $(git -C "$VAULT" ls-files --others --exclude-standard); do
|
|
97
|
+
if git -C "$VAULT" cat-file -e "origin/main:$f" 2>/dev/null; then
|
|
98
|
+
# File exists on remote; check if identical
|
|
99
|
+
if diff -q <(git -C "$VAULT" show "origin/main:$f") "$VAULT/$f" >/dev/null 2>&1; then
|
|
100
|
+
# Byte-identical — safe to remove (presync artifact)
|
|
101
|
+
rm "$VAULT/$f"
|
|
102
|
+
else
|
|
103
|
+
# DIFFERENT — surface to user, DO NOT silently --include-untracked
|
|
104
|
+
echo "UNTRACKED COLLISION: $f differs from origin/main — surface to user for resolution"
|
|
105
|
+
fi
|
|
106
|
+
fi
|
|
107
|
+
# If file does not exist on remote, leave it alone (pull won't touch it)
|
|
108
|
+
done
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
If collisions are found (different content), ask the user to resolve manually before pulling.
|
|
112
|
+
|
|
39
113
|
## Conflict Resolution
|
|
114
|
+
|
|
40
115
|
When merge conflicts are detected:
|
|
41
|
-
|
|
116
|
+
|
|
117
|
+
### Frontmatter conflicts
|
|
42
118
|
- For `updated:` fields: always take the newer timestamp (compare both sides, keep the later one).
|
|
43
119
|
- For all other frontmatter fields: present both versions to the user and ask which to keep.
|
|
44
|
-
|
|
120
|
+
|
|
121
|
+
### Body conflicts
|
|
45
122
|
- Do not auto-resolve body conflicts.
|
|
46
123
|
- Mark unresolved regions with `???` on a line by itself between the conflicting versions, so the user can see both sides and decide.
|
|
47
124
|
- Example:
|
|
@@ -51,12 +128,28 @@ Content from local version
|
|
|
51
128
|
Content from remote version
|
|
52
129
|
```
|
|
53
130
|
- After resolving conflicts, run `skillwiki lint <vault>` to verify before committing.
|
|
131
|
+
|
|
132
|
+
### Modify/delete conflicts
|
|
133
|
+
|
|
134
|
+
When `git pull --rebase` reports `CONFLICT (modify/delete)`:
|
|
135
|
+
|
|
136
|
+
1. Identify the commit that deleted the file:
|
|
137
|
+
```bash
|
|
138
|
+
git -C "$VAULT" log --diff-filter=D --pretty=oneline -- <path>
|
|
139
|
+
```
|
|
140
|
+
2. Read the commit message and any retro / log entry referencing it to determine if the deletion was intentional or accidental.
|
|
141
|
+
3. Decide:
|
|
142
|
+
- `git -C "$VAULT" rm <path>` — accept the deletion (rebase continues)
|
|
143
|
+
- `git -C "$VAULT" add <path>` — keep the local restoration (rebase continues)
|
|
144
|
+
4. `git -C "$VAULT" rebase --continue`.
|
|
145
|
+
|
|
54
146
|
## Multi-device coordination
|
|
55
147
|
When the user mentions editing from Obsidian desktop and Claude Code on a server (or any two-device setup):
|
|
56
148
|
- Recommend pulling before every editing session on each device.
|
|
57
149
|
- Recommend pushing after every editing session on each device.
|
|
58
150
|
- If both devices edit the same page between syncs, conflicts are inevitable — the Conflict Resolution section handles this.
|
|
59
151
|
- Suggest enabling auto-commit in Obsidian (Community Plugins: `obsidian-git`) to reduce dirty-state drift.
|
|
152
|
+
|
|
60
153
|
## Rclone-backed vault with git snapshotting (cron pattern)
|
|
61
154
|
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
155
|
### Architecture
|
|
@@ -105,12 +198,18 @@ bash ~/.hermes/scripts/wiki-snapshot.sh # Re-sync fresh
|
|
|
105
198
|
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
199
|
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
200
|
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.
|
|
201
|
+
|
|
108
202
|
## Stop conditions
|
|
109
203
|
- `skillwiki sync status` reports `not_a_repo` — the vault is not a git repository. Advise the user to initialize one.
|
|
110
204
|
- Lint errors are found before a push — do not push until resolved.
|
|
111
205
|
- `git push` or `git pull` fails with a network error — report and stop.
|
|
206
|
+
- Peer lock is held or peer stashes exist — abort and ask the user to wait or pass `--force`.
|
|
207
|
+
- Untracked file collision detected on pull — surface to user for manual resolution.
|
|
208
|
+
|
|
112
209
|
## Forbidden
|
|
113
210
|
- Pushing when lint errors exist.
|
|
114
211
|
- Auto-resolving body conflicts without user review.
|
|
115
212
|
- Force-pushing (`git push --force`).
|
|
116
213
|
- Modifying files in `raw/` to resolve conflicts (N9 — archive and re-ingest instead).
|
|
214
|
+
- Stashing without the `wiki-sync:...` name format (breaks peer detection).
|
|
215
|
+
- Force-deleting a peer's lockfile (use `--force` only if peer is confirmed dead).
|