skillwiki 0.9.63 → 0.10.1

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.
Files changed (36) hide show
  1. package/dist/chunk-C5OLZRRM.js +357 -0
  2. package/dist/chunk-IZABIE44.js +647 -0
  3. package/dist/chunk-R6BKJWVC.js +890 -0
  4. package/dist/chunk-SCGC7YNM.js +213 -0
  5. package/dist/{chunk-TUFQZ5K4.js → chunk-XSTXPA34.js} +834 -1981
  6. package/dist/cli.js +1780 -697
  7. package/dist/index-projection-ERFX76U5.js +10 -0
  8. package/dist/managed-write-preflight-PW4OOOMV.js +11 -0
  9. package/dist/skillwiki-mcp.js +4 -1
  10. package/dist/vault-sync/scripts/lib/conflict-markers.sh +69 -0
  11. package/dist/vault-sync/scripts/lib/delete-intent.sh +74 -0
  12. package/dist/vault-sync/scripts/lib/fleet.sh +103 -0
  13. package/dist/vault-sync/scripts/lib/git-case.sh +71 -0
  14. package/dist/vault-sync/scripts/lib/git-materialization.sh +264 -0
  15. package/dist/vault-sync/scripts/lib/git-operation-journal.sh +469 -0
  16. package/dist/vault-sync/scripts/lib/git-rebase-state.sh +180 -0
  17. package/dist/vault-sync/scripts/lib/lockfile.sh +70 -0
  18. package/dist/vault-sync/scripts/lib/managed-write-lock.sh +80 -0
  19. package/dist/vault-sync/scripts/lib/platform.sh +184 -0
  20. package/dist/vault-sync/scripts/lib/runtime-manifest.sh +223 -0
  21. package/dist/vault-sync/scripts/wiki-fetch-notify.sh +207 -0
  22. package/dist/vault-sync/scripts/wiki-fuse-refresh.sh +405 -0
  23. package/dist/vault-sync/scripts/wiki-pull-with-auto-resolve.sh +631 -0
  24. package/dist/vault-sync/scripts/wiki-push.sh +364 -0
  25. package/dist/vault-sync/scripts/wiki-snapshot.sh +587 -0
  26. package/package.json +2 -2
  27. package/skills/.claude-plugin/plugin.json +1 -1
  28. package/skills/.codex-plugin/plugin.json +1 -1
  29. package/skills/README.md +13 -0
  30. package/skills/package.json +1 -1
  31. package/skills/proj-work/SKILL.md +3 -0
  32. package/skills/skills/proj-work/SKILL.md +3 -0
  33. package/skills/skills/using-skillwiki/SKILL.md +24 -0
  34. package/skills/skills/wiki-crystallize/SKILL.md +3 -0
  35. package/skills/using-skillwiki/SKILL.md +24 -0
  36. package/skills/wiki-crystallize/SKILL.md +3 -0
@@ -0,0 +1,213 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ findReviewRequiredOp,
4
+ git,
5
+ hasActiveGitSequencer,
6
+ hasUnmergedPaths,
7
+ loadFleetManifestAndHost,
8
+ runVaultSyncPullHelper,
9
+ supersedeStaleReviewRequiredJournals
10
+ } from "./chunk-R6BKJWVC.js";
11
+ import {
12
+ ExitCode,
13
+ err,
14
+ ok
15
+ } from "./chunk-C5OLZRRM.js";
16
+
17
+ // src/utils/managed-write-lock.ts
18
+ import { randomBytes } from "crypto";
19
+ import { mkdirSync, readFileSync, unlinkSync, writeFileSync } from "fs";
20
+ import { dirname, join } from "path";
21
+ function managedWriteLockPath(vault) {
22
+ const gitPath = git(vault, ["rev-parse", "--git-path", "vault-sync/managed-write.lock"]);
23
+ if (gitPath) return gitPath.startsWith("/") ? gitPath : join(vault, gitPath);
24
+ return join(vault, ".skillwiki", "managed-write.lock");
25
+ }
26
+ function acquireManagedWriteLock(vault, command) {
27
+ const path = managedWriteLockPath(vault);
28
+ const ownerToken = randomBytes(16).toString("hex");
29
+ const acquired = (/* @__PURE__ */ new Date()).toISOString();
30
+ try {
31
+ mkdirSync(dirname(path), { recursive: true });
32
+ writeFileSync(
33
+ path,
34
+ `${JSON.stringify({ pid: process.pid, owner_token: ownerToken, acquired, command })}
35
+ `,
36
+ { flag: "wx" }
37
+ );
38
+ return ok({ vault, path, ownerToken, acquired });
39
+ } catch (error) {
40
+ if (error.code === "EEXIST") return err("SYNC_LOCK_HELD", { path });
41
+ return err("WRITE_FAILED", { path, message: String(error) });
42
+ }
43
+ }
44
+ function releaseManagedWriteLock(handle) {
45
+ try {
46
+ const parsed = JSON.parse(readFileSync(handle.path, "utf8"));
47
+ if (parsed.owner_token !== handle.ownerToken || parsed.acquired !== handle.acquired) {
48
+ return err("SYNC_LOCK_HELD", {
49
+ path: handle.path,
50
+ message: "managed-write lock ownership changed"
51
+ });
52
+ }
53
+ unlinkSync(handle.path);
54
+ return ok({ released: true });
55
+ } catch (error) {
56
+ return err("WRITE_FAILED", { path: handle.path, message: String(error) });
57
+ }
58
+ }
59
+
60
+ // src/utils/managed-write-preflight.ts
61
+ var DEFAULT_DEPS = {
62
+ converge: (input) => runVaultSyncPullHelper(input)
63
+ };
64
+ function preflightBlocker(vault) {
65
+ const unmerged = hasUnmergedPaths(vault);
66
+ if (unmerged.length > 0) {
67
+ return {
68
+ reason: "unmerged-paths",
69
+ operation_id: findReviewRequiredOp(vault),
70
+ unmerged_paths: unmerged
71
+ };
72
+ }
73
+ if (hasActiveGitSequencer(vault)) {
74
+ return { reason: "git-operation-in-progress" };
75
+ }
76
+ supersedeStaleReviewRequiredJournals(vault, { by: "skillwiki-managed-write-preflight" });
77
+ const op = findReviewRequiredOp(vault);
78
+ if (op) return { reason: "review-required", operation_id: op };
79
+ return null;
80
+ }
81
+ async function runManagedWritePreflight(input, deps = DEFAULT_DEPS) {
82
+ const vault = input.vault;
83
+ const blocker = preflightBlocker(vault);
84
+ if (blocker) {
85
+ return {
86
+ exitCode: ExitCode.PREFLIGHT_FAILED,
87
+ result: err("PREFLIGHT_FAILED", {
88
+ reason: blocker.reason,
89
+ operation_id: blocker.operation_id,
90
+ unmerged_paths: blocker.unmerged_paths
91
+ })
92
+ };
93
+ }
94
+ const fleet = await loadFleetManifestAndHost({
95
+ vault,
96
+ hostId: input.hostId,
97
+ env: input.env,
98
+ home: input.home,
99
+ osHostname: input.osHostname
100
+ });
101
+ if (!fleet) {
102
+ const head = git(vault, ["rev-parse", "HEAD"]) || null;
103
+ return {
104
+ exitCode: ExitCode.OK,
105
+ result: ok({
106
+ mode: "standalone",
107
+ base_oid: head,
108
+ converged: false
109
+ })
110
+ };
111
+ }
112
+ if (fleet.identityStatus === "unknown" || fleet.identityStatus === "invalid" || !fleet.hostId) {
113
+ return {
114
+ exitCode: ExitCode.PREFLIGHT_FAILED,
115
+ result: err("PREFLIGHT_FAILED", {
116
+ reason: "fleet-identity-unresolved",
117
+ identity_status: fleet.identityStatus,
118
+ host_id: fleet.hostId
119
+ })
120
+ };
121
+ }
122
+ const host = fleet.manifest.hosts[fleet.hostId];
123
+ if (!host) {
124
+ return {
125
+ exitCode: ExitCode.PREFLIGHT_FAILED,
126
+ result: err("PREFLIGHT_FAILED", { reason: "fleet-host-missing", host_id: fleet.hostId })
127
+ };
128
+ }
129
+ const writesGithub = host.writes_to.includes("github");
130
+ if (!writesGithub) {
131
+ return {
132
+ exitCode: ExitCode.OK,
133
+ result: ok({
134
+ mode: "immutable-record",
135
+ host_id: fleet.hostId,
136
+ base_oid: null,
137
+ converged: false
138
+ })
139
+ };
140
+ }
141
+ const converge = await deps.converge({
142
+ vault,
143
+ lockToken: input.lockToken,
144
+ env: input.env,
145
+ home: input.home
146
+ });
147
+ if (!converge.ok) {
148
+ const exitCode = converge.error === "PREFLIGHT_FAILED" ? ExitCode.PREFLIGHT_FAILED : ExitCode.SYNC_PULL_FAILED;
149
+ return { exitCode, result: converge };
150
+ }
151
+ const baseOid = git(vault, ["rev-parse", "HEAD"]);
152
+ if (!baseOid) {
153
+ return {
154
+ exitCode: ExitCode.PREFLIGHT_FAILED,
155
+ result: err("PREFLIGHT_FAILED", { reason: "missing-head-after-converge" })
156
+ };
157
+ }
158
+ return {
159
+ exitCode: ExitCode.OK,
160
+ result: ok({
161
+ mode: "git-writer",
162
+ host_id: fleet.hostId,
163
+ base_oid: baseOid,
164
+ converged: true,
165
+ helper_path: converge.data.helper_path
166
+ })
167
+ };
168
+ }
169
+ async function runManagedWriteTransaction(input, deps = DEFAULT_DEPS) {
170
+ const lock = acquireManagedWriteLock(input.vault, input.command);
171
+ if (!lock.ok) {
172
+ return { exitCode: ExitCode.SYNC_LOCK_HELD, result: lock };
173
+ }
174
+ let handle = lock.data;
175
+ try {
176
+ const preflight = await runManagedWritePreflight(
177
+ {
178
+ vault: input.vault,
179
+ command: input.command,
180
+ hostId: input.hostId,
181
+ lockToken: handle.ownerToken,
182
+ env: input.env,
183
+ home: input.home,
184
+ osHostname: input.osHostname
185
+ },
186
+ deps
187
+ );
188
+ if (!preflight.result.ok) {
189
+ return { exitCode: preflight.exitCode, result: preflight.result };
190
+ }
191
+ const receipt = preflight.result.data;
192
+ if (receipt.mode === "immutable-record" && !input.allowImmutableRecord) {
193
+ return {
194
+ exitCode: ExitCode.PREFLIGHT_FAILED,
195
+ result: err("PREFLIGHT_FAILED", {
196
+ reason: "immutable-record-not-enabled",
197
+ message: "Release A rejects immutable-record mode; event mode arrives in Release B",
198
+ host_id: receipt.host_id
199
+ })
200
+ };
201
+ }
202
+ return await input.mutate(receipt);
203
+ } finally {
204
+ releaseManagedWriteLock(handle);
205
+ }
206
+ }
207
+
208
+ export {
209
+ acquireManagedWriteLock,
210
+ releaseManagedWriteLock,
211
+ runManagedWritePreflight,
212
+ runManagedWriteTransaction
213
+ };