@mulmoclaude/core 0.1.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/assets/helps/billing-clients-worklog.md +215 -0
- package/assets/helps/billing-invoice.md +458 -0
- package/assets/helps/business.md +104 -0
- package/assets/helps/collection-skills.md +810 -0
- package/assets/helps/custom-view.md +433 -0
- package/assets/helps/feeds.md +114 -0
- package/assets/helps/gemini.md +57 -0
- package/assets/helps/github.md +23 -0
- package/assets/helps/guide.md +61 -0
- package/assets/helps/index.md +89 -0
- package/assets/helps/lessons-collection.md +400 -0
- package/assets/helps/mulmoscript.md +249 -0
- package/assets/helps/portfolio-tracker.md +211 -0
- package/assets/helps/presentation-deck.md +828 -0
- package/assets/helps/presenthtml.md +89 -0
- package/assets/helps/sandbox.md +97 -0
- package/assets/helps/spreadsheet.md +43 -0
- package/assets/helps/storyteller.md +101 -0
- package/assets/helps/telegram.md +136 -0
- package/assets/helps/todo-collection.md +140 -0
- package/assets/helps/vocabulary.md +109 -0
- package/assets/helps/wiki.md +168 -0
- package/assets/skills-preset/mc-cooking-coach/SKILL.md +217 -0
- package/assets/skills-preset/mc-library/SKILL.md +188 -0
- package/assets/skills-preset/mc-manage-automations/SKILL.md +119 -0
- package/assets/skills-preset/mc-manage-skills/SKILL.md +141 -0
- package/assets/skills-preset/mc-wiki-deep-lint/SKILL.md +108 -0
- package/assets/skills-preset/mc-wiki-health-check/SKILL.md +61 -0
- package/assets/skills-preset/mc-wiki-ingest/SKILL.md +182 -0
- package/assets/skills-preset/mc-wiki-promote/SKILL.md +175 -0
- package/assets/skills-preset/mc-zenn/SKILL.md +136 -0
- package/dist/chunk-CKQMccvm.cjs +28 -0
- package/dist/collection/core/actionVisible.d.ts +34 -0
- package/dist/collection/core/calendarGrid.d.ts +120 -0
- package/dist/collection/core/deriveAll.d.ts +38 -0
- package/dist/collection/core/derivedFormula.d.ts +18 -0
- package/dist/collection/core/draft.d.ts +18 -0
- package/dist/collection/core/enumColors.d.ts +33 -0
- package/dist/collection/core/errorMessage.d.ts +4 -0
- package/dist/collection/core/itemLabel.d.ts +12 -0
- package/dist/collection/core/presentCollection.d.ts +13 -0
- package/dist/collection/core/promptSafety.d.ts +1 -0
- package/dist/collection/core/schema.d.ts +355 -0
- package/dist/collection/core/shortHexId.d.ts +8 -0
- package/dist/collection/core/sortItems.d.ts +29 -0
- package/dist/collection/core/uiTypes.d.ts +106 -0
- package/dist/collection/index.cjs +793 -0
- package/dist/collection/index.cjs.map +1 -0
- package/dist/collection/index.d.ts +14 -0
- package/dist/collection/index.js +740 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/paths.cjs +44 -0
- package/dist/collection/paths.cjs.map +1 -0
- package/dist/collection/paths.js +41 -0
- package/dist/collection/paths.js.map +1 -0
- package/dist/collection/server/atomic.d.ts +1 -0
- package/dist/collection/server/delete.d.ts +38 -0
- package/dist/collection/server/derive.d.ts +8 -0
- package/dist/collection/server/discoveredCollection.d.ts +18 -0
- package/dist/collection/server/discovery.d.ts +227 -0
- package/dist/collection/server/host.d.ts +77 -0
- package/dist/collection/server/index.cjs +1721 -0
- package/dist/collection/server/index.cjs.map +1 -0
- package/dist/collection/server/index.d.ts +11 -0
- package/dist/collection/server/index.js +1671 -0
- package/dist/collection/server/index.js.map +1 -0
- package/dist/collection/server/io.d.ts +114 -0
- package/dist/collection/server/paths.d.ts +52 -0
- package/dist/collection/server/spawn.d.ts +55 -0
- package/dist/collection/server/templatePath.d.ts +25 -0
- package/dist/collection/server/util.d.ts +3 -0
- package/dist/collection/server/validate.d.ts +19 -0
- package/dist/collection/server/views.d.ts +20 -0
- package/dist/deriveAll-C15OpM3K.cjs +399 -0
- package/dist/deriveAll-C15OpM3K.cjs.map +1 -0
- package/dist/deriveAll-C6BYnpBL.js +364 -0
- package/dist/deriveAll-C6BYnpBL.js.map +1 -0
- package/dist/file-change/index.cjs +72 -0
- package/dist/file-change/index.cjs.map +1 -0
- package/dist/file-change/index.d.ts +43 -0
- package/dist/file-change/index.js +66 -0
- package/dist/file-change/index.js.map +1 -0
- package/dist/notifier/engine.d.ts +72 -0
- package/dist/notifier/index.cjs +484 -0
- package/dist/notifier/index.cjs.map +1 -0
- package/dist/notifier/index.d.ts +3 -0
- package/dist/notifier/index.js +464 -0
- package/dist/notifier/index.js.map +1 -0
- package/dist/notifier/store.d.ts +18 -0
- package/dist/notifier/types.d.ts +118 -0
- package/dist/notifier/validate.d.ts +17 -0
- package/dist/scheduler/adapter.d.ts +48 -0
- package/dist/scheduler/index.cjs +352 -0
- package/dist/scheduler/index.cjs.map +1 -0
- package/dist/scheduler/index.d.ts +2 -0
- package/dist/scheduler/index.js +343 -0
- package/dist/scheduler/index.js.map +1 -0
- package/dist/scheduler/task-manager.d.ts +51 -0
- package/dist/whisper/client.cjs +241 -0
- package/dist/whisper/client.cjs.map +1 -0
- package/dist/whisper/client.d.ts +35 -0
- package/dist/whisper/client.js +239 -0
- package/dist/whisper/client.js.map +1 -0
- package/dist/whisper/ffmpeg.d.ts +6 -0
- package/dist/whisper/index.cjs +433 -0
- package/dist/whisper/index.cjs.map +1 -0
- package/dist/whisper/index.d.ts +5 -0
- package/dist/whisper/index.js +425 -0
- package/dist/whisper/index.js.map +1 -0
- package/dist/whisper/internal.d.ts +11 -0
- package/dist/whisper/models.d.ts +49 -0
- package/dist/whisper/sidecar.d.ts +8 -0
- package/dist/whisper/whisper.d.ts +28 -0
- package/dist/workspace-setup/assets.d.ts +10 -0
- package/dist/workspace-setup/index.d.ts +3 -0
- package/dist/workspace-setup/index.js +556 -0
- package/dist/workspace-setup/index.js.map +1 -0
- package/dist/workspace-setup/slug.d.ts +6 -0
- package/dist/workspace-setup/slug.js +13 -0
- package/dist/workspace-setup/slug.js.map +1 -0
- package/dist/workspace-setup/sync.d.ts +94 -0
- package/package.json +95 -0
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
import { PRESET_SLUG_PREFIX, isPresetSlug } from "./slug.js";
|
|
2
|
+
import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync } from "node:fs";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
//#region src/workspace-setup/sync.ts
|
|
7
|
+
function errorMessage(err) {
|
|
8
|
+
return err instanceof Error ? err.message : String(err);
|
|
9
|
+
}
|
|
10
|
+
function copyDirTreeSync(srcDir, destDir) {
|
|
11
|
+
mkdirSync(destDir, { recursive: true });
|
|
12
|
+
for (const entry of readdirSync(srcDir, { withFileTypes: true })) {
|
|
13
|
+
const srcPath = path.join(srcDir, entry.name);
|
|
14
|
+
const destPath = path.join(destDir, entry.name);
|
|
15
|
+
if (entry.isDirectory()) copyDirTreeSync(srcPath, destPath);
|
|
16
|
+
else if (entry.isFile()) copyFileSync(srcPath, destPath);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
var SKILL_FILENAME = "SKILL.md";
|
|
20
|
+
function classifySourceEntry(sourceDir, entry) {
|
|
21
|
+
if (entry.startsWith(".")) return {
|
|
22
|
+
ok: false,
|
|
23
|
+
reason: "hidden",
|
|
24
|
+
silent: true
|
|
25
|
+
};
|
|
26
|
+
const slugDir = path.join(sourceDir, entry);
|
|
27
|
+
let dirInfo;
|
|
28
|
+
try {
|
|
29
|
+
dirInfo = statSync(slugDir);
|
|
30
|
+
} catch {
|
|
31
|
+
return {
|
|
32
|
+
ok: false,
|
|
33
|
+
reason: "stat failed",
|
|
34
|
+
silent: true
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (!dirInfo.isDirectory()) return {
|
|
38
|
+
ok: false,
|
|
39
|
+
reason: "not a directory",
|
|
40
|
+
silent: true
|
|
41
|
+
};
|
|
42
|
+
if (!isPresetSlug(entry)) return {
|
|
43
|
+
ok: false,
|
|
44
|
+
reason: `slug must start with "mc-"`,
|
|
45
|
+
silent: false
|
|
46
|
+
};
|
|
47
|
+
const skillPath = path.join(slugDir, SKILL_FILENAME);
|
|
48
|
+
let skillInfo;
|
|
49
|
+
try {
|
|
50
|
+
skillInfo = statSync(skillPath);
|
|
51
|
+
} catch {
|
|
52
|
+
return {
|
|
53
|
+
ok: false,
|
|
54
|
+
reason: `missing ${SKILL_FILENAME}`,
|
|
55
|
+
silent: false
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (!skillInfo.isFile()) return {
|
|
59
|
+
ok: false,
|
|
60
|
+
reason: `${SKILL_FILENAME} must be a regular file`,
|
|
61
|
+
silent: false
|
|
62
|
+
};
|
|
63
|
+
return { ok: true };
|
|
64
|
+
}
|
|
65
|
+
/** Prepare the destination slug dir. Returns false if the slot is
|
|
66
|
+
* occupied by a regular file (local corruption / hand edits) — the
|
|
67
|
+
* caller logs + skips so one bad entry can't crash the whole boot
|
|
68
|
+
* (Codex review iter-1). */
|
|
69
|
+
function ensureDestSlugDir(destSlugDir) {
|
|
70
|
+
let info;
|
|
71
|
+
try {
|
|
72
|
+
info = statSync(destSlugDir);
|
|
73
|
+
} catch {
|
|
74
|
+
mkdirSync(destSlugDir, { recursive: true });
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
return info.isDirectory();
|
|
78
|
+
}
|
|
79
|
+
var REAL_FS_OPS = {
|
|
80
|
+
copyTree: copyDirTreeSync,
|
|
81
|
+
rename: renameSync,
|
|
82
|
+
remove: (target) => rmSync(target, {
|
|
83
|
+
recursive: true,
|
|
84
|
+
force: true
|
|
85
|
+
}),
|
|
86
|
+
exists: existsSync
|
|
87
|
+
};
|
|
88
|
+
/** Refresh one preset slot as a rollback-safe stage-and-swap. Wipe-and-replace
|
|
89
|
+
* (not merge) so stale sibling assets — e.g. a schema.json dropped between
|
|
90
|
+
* releases — don't linger; the catalog preset slot is launcher-owned, so user
|
|
91
|
+
* edits there are not preserved across boots.
|
|
92
|
+
*
|
|
93
|
+
* The live slot is never left without a recoverable copy:
|
|
94
|
+
* 1. Stage: copy the source into a temp sibling. A copy failure leaves the
|
|
95
|
+
* existing preset untouched (temp dir removed).
|
|
96
|
+
* 2. Move the existing tree ASIDE to a backup (rename, not delete), so the
|
|
97
|
+
* old contents survive even if the next step fails.
|
|
98
|
+
* 3. Move the staged copy into place. On failure, restore from the backup;
|
|
99
|
+
* if even the restore fails, BOTH backup and staging are preserved for
|
|
100
|
+
* manual recovery rather than deleted.
|
|
101
|
+
* 4. On success, drop the backup.
|
|
102
|
+
*
|
|
103
|
+
* Exported with a `_` prefix only so the rename-failure-after-move path can be
|
|
104
|
+
* regression-tested via the injected `fsOps`. Throws on failure (caller records
|
|
105
|
+
* + skips). */
|
|
106
|
+
function _replaceSlugTree(sourceSlugDir, destSlugDir, fsOps = REAL_FS_OPS) {
|
|
107
|
+
const staging = `${destSlugDir}.tmp-${randomUUID()}`;
|
|
108
|
+
try {
|
|
109
|
+
fsOps.copyTree(sourceSlugDir, staging);
|
|
110
|
+
} catch (err) {
|
|
111
|
+
fsOps.remove(staging);
|
|
112
|
+
throw err;
|
|
113
|
+
}
|
|
114
|
+
const backup = `${destSlugDir}.bak-${randomUUID()}`;
|
|
115
|
+
let backedUp = false;
|
|
116
|
+
if (fsOps.exists(destSlugDir)) try {
|
|
117
|
+
fsOps.rename(destSlugDir, backup);
|
|
118
|
+
backedUp = true;
|
|
119
|
+
} catch (err) {
|
|
120
|
+
fsOps.remove(staging);
|
|
121
|
+
throw err;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
fsOps.rename(staging, destSlugDir);
|
|
125
|
+
} catch (err) {
|
|
126
|
+
if (backedUp) try {
|
|
127
|
+
fsOps.rename(backup, destSlugDir);
|
|
128
|
+
fsOps.remove(staging);
|
|
129
|
+
} catch {}
|
|
130
|
+
else fsOps.remove(staging);
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
if (backedUp) fsOps.remove(backup);
|
|
134
|
+
}
|
|
135
|
+
function copySourcesIntoDest(sourceDir, destDir, opts, result) {
|
|
136
|
+
const keep = /* @__PURE__ */ new Set();
|
|
137
|
+
for (const entry of readdirSync(sourceDir)) {
|
|
138
|
+
const verdict = classifySourceEntry(sourceDir, entry);
|
|
139
|
+
if (!verdict.ok) {
|
|
140
|
+
if (!verdict.silent) {
|
|
141
|
+
result.skipped.push(`${entry}: ${verdict.reason}`);
|
|
142
|
+
opts.onWarn?.("preset entry skipped", {
|
|
143
|
+
slug: entry,
|
|
144
|
+
reason: verdict.reason
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const destSlugDir = path.join(destDir, entry);
|
|
150
|
+
if (!ensureDestSlugDir(destSlugDir)) {
|
|
151
|
+
const reason = "destination slot occupied by a non-directory; skipping";
|
|
152
|
+
result.skipped.push(`${entry}: ${reason}`);
|
|
153
|
+
opts.onWarn?.("preset entry skipped", {
|
|
154
|
+
slug: entry,
|
|
155
|
+
reason,
|
|
156
|
+
destSlugDir
|
|
157
|
+
});
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
keep.add(entry);
|
|
161
|
+
try {
|
|
162
|
+
_replaceSlugTree(path.join(sourceDir, entry), destSlugDir);
|
|
163
|
+
result.copied.push(entry);
|
|
164
|
+
} catch (err) {
|
|
165
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
166
|
+
result.skipped.push(`${entry}: ${reason}`);
|
|
167
|
+
opts.onWarn?.("preset copy failed, skipping", {
|
|
168
|
+
slug: entry,
|
|
169
|
+
reason
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return keep;
|
|
174
|
+
}
|
|
175
|
+
function removeRetiredPresets(destDir, keep, opts, result) {
|
|
176
|
+
for (const entry of readdirSync(destDir)) {
|
|
177
|
+
if (!isPresetSlug(entry)) continue;
|
|
178
|
+
if (keep.has(entry)) continue;
|
|
179
|
+
const stalePath = path.join(destDir, entry);
|
|
180
|
+
try {
|
|
181
|
+
if (!statSync(stalePath).isDirectory()) continue;
|
|
182
|
+
} catch {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
rmSync(stalePath, {
|
|
186
|
+
recursive: true,
|
|
187
|
+
force: true
|
|
188
|
+
});
|
|
189
|
+
result.removed.push(entry);
|
|
190
|
+
opts.onInfo?.("removed retired preset skill", { slug: entry });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** Copy every preset slug from `sourceDir` into `destDir` (the
|
|
194
|
+
* preset slot under the catalog root), then remove any `mc-*`
|
|
195
|
+
* entries in `destDir` that no longer have a source. The catalog
|
|
196
|
+
* preset subdir is fully launcher-owned, so the `mc-*` prefix
|
|
197
|
+
* check at destination is defence-in-depth: a stray non-preset
|
|
198
|
+
* slug landing in `catalog/preset/` is unexpected, and we'd
|
|
199
|
+
* rather skip it than silently delete a directory we don't
|
|
200
|
+
* recognise. */
|
|
201
|
+
function syncPresetSkills(opts) {
|
|
202
|
+
const result = {
|
|
203
|
+
copied: [],
|
|
204
|
+
removed: [],
|
|
205
|
+
skipped: []
|
|
206
|
+
};
|
|
207
|
+
if (!existsSync(opts.sourceDir)) return result;
|
|
208
|
+
let sourceInfo;
|
|
209
|
+
try {
|
|
210
|
+
sourceInfo = statSync(opts.sourceDir);
|
|
211
|
+
} catch (err) {
|
|
212
|
+
const reason = `source path stat failed: ${errorMessage(err)}`;
|
|
213
|
+
result.skipped.push(`${opts.sourceDir}: ${reason}`);
|
|
214
|
+
opts.onWarn?.("preset sync aborted", {
|
|
215
|
+
sourceDir: opts.sourceDir,
|
|
216
|
+
reason
|
|
217
|
+
});
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
if (!sourceInfo.isDirectory()) {
|
|
221
|
+
const reason = "source path exists as a non-directory; preset sync skipped";
|
|
222
|
+
result.skipped.push(`${opts.sourceDir}: ${reason}`);
|
|
223
|
+
opts.onWarn?.("preset sync aborted", {
|
|
224
|
+
sourceDir: opts.sourceDir,
|
|
225
|
+
reason
|
|
226
|
+
});
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
if (!ensureDestSlugDir(opts.destDir)) {
|
|
230
|
+
const reason = "root dest exists as a non-directory; preset sync skipped";
|
|
231
|
+
result.skipped.push(`${opts.destDir}: ${reason}`);
|
|
232
|
+
opts.onWarn?.("preset sync aborted", {
|
|
233
|
+
destDir: opts.destDir,
|
|
234
|
+
reason
|
|
235
|
+
});
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
const keep = copySourcesIntoDest(opts.sourceDir, opts.destDir, opts, result);
|
|
239
|
+
removeRetiredPresets(opts.destDir, keep, opts, result);
|
|
240
|
+
if (result.copied.length > 0 || result.removed.length > 0) opts.onInfo?.("preset skills synced", {
|
|
241
|
+
copied: result.copied.length,
|
|
242
|
+
removed: result.removed.length,
|
|
243
|
+
skipped: result.skipped.length
|
|
244
|
+
});
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
function filesEqual(left, right) {
|
|
248
|
+
try {
|
|
249
|
+
return readFileSync(left).equals(readFileSync(right));
|
|
250
|
+
} catch {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/** Copy `srcPath` over `destPath`. If `destPath` already exists and
|
|
255
|
+
* differs, rename it to `destPath + backupExt` first so the user's
|
|
256
|
+
* prior contents are recoverable. If `destPath` doesn't exist, just
|
|
257
|
+
* copy (no backup needed). Pure: no logging here — caller decides. */
|
|
258
|
+
function syncOneFile(srcPath, destPath, backupExt) {
|
|
259
|
+
let destExists;
|
|
260
|
+
try {
|
|
261
|
+
destExists = statSync(destPath).isFile();
|
|
262
|
+
} catch {
|
|
263
|
+
destExists = false;
|
|
264
|
+
}
|
|
265
|
+
if (!destExists) try {
|
|
266
|
+
copyFileSync(srcPath, destPath);
|
|
267
|
+
return "updated";
|
|
268
|
+
} catch {
|
|
269
|
+
return "skipped";
|
|
270
|
+
}
|
|
271
|
+
if (filesEqual(srcPath, destPath)) return "unchanged";
|
|
272
|
+
try {
|
|
273
|
+
renameSync(destPath, destPath + backupExt);
|
|
274
|
+
copyFileSync(srcPath, destPath);
|
|
275
|
+
return "updated";
|
|
276
|
+
} catch {
|
|
277
|
+
return "skipped";
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function syncDirTreeDiff(srcDir, destDir, backupExt) {
|
|
281
|
+
const stats = {
|
|
282
|
+
updated: 0,
|
|
283
|
+
unchanged: 0,
|
|
284
|
+
skipped: 0
|
|
285
|
+
};
|
|
286
|
+
try {
|
|
287
|
+
mkdirSync(destDir, { recursive: true });
|
|
288
|
+
} catch {
|
|
289
|
+
stats.skipped++;
|
|
290
|
+
return stats;
|
|
291
|
+
}
|
|
292
|
+
let entries;
|
|
293
|
+
try {
|
|
294
|
+
entries = readdirSync(srcDir, { withFileTypes: true });
|
|
295
|
+
} catch {
|
|
296
|
+
stats.skipped++;
|
|
297
|
+
return stats;
|
|
298
|
+
}
|
|
299
|
+
for (const entry of entries) {
|
|
300
|
+
const srcPath = path.join(srcDir, entry.name);
|
|
301
|
+
const destPath = path.join(destDir, entry.name);
|
|
302
|
+
if (entry.isDirectory()) {
|
|
303
|
+
const sub = syncDirTreeDiff(srcPath, destPath, backupExt);
|
|
304
|
+
stats.updated += sub.updated;
|
|
305
|
+
stats.unchanged += sub.unchanged;
|
|
306
|
+
stats.skipped += sub.skipped;
|
|
307
|
+
} else if (entry.isFile()) {
|
|
308
|
+
const outcome = syncOneFile(srcPath, destPath, backupExt);
|
|
309
|
+
stats[outcome]++;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return stats;
|
|
313
|
+
}
|
|
314
|
+
function abortActiveSync(opts, result, reason) {
|
|
315
|
+
result.skipped.push(`${opts.sourceDir}: ${reason}`);
|
|
316
|
+
opts.onWarn?.("active preset sync aborted", {
|
|
317
|
+
sourceDir: opts.sourceDir,
|
|
318
|
+
reason
|
|
319
|
+
});
|
|
320
|
+
return result;
|
|
321
|
+
}
|
|
322
|
+
/** True iff `absPath`'s realpath resolves inside `rootPath`'s
|
|
323
|
+
* realpath. Defends `processActiveSlug` against a starred `mc-*`
|
|
324
|
+
* slug that's actually a symlink to somewhere outside
|
|
325
|
+
* `activeDir`: without this check, the recursive copy below would
|
|
326
|
+
* follow the symlink and write through to the link's target
|
|
327
|
+
* (potentially anywhere on disk). Returns false on any error so
|
|
328
|
+
* the caller treats unreadable paths as "refused" rather than
|
|
329
|
+
* "OK to write". */
|
|
330
|
+
function isRealpathInside(absPath, rootPath) {
|
|
331
|
+
try {
|
|
332
|
+
const real = realpathSync(absPath);
|
|
333
|
+
const rootReal = realpathSync(rootPath);
|
|
334
|
+
return real === rootReal || real.startsWith(rootReal + path.sep);
|
|
335
|
+
} catch {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/** Validate the active dest slug dir before writing through it.
|
|
340
|
+
* Returns:
|
|
341
|
+
* - `{ ok: true }` — proceed with the sync
|
|
342
|
+
* - `{ kind: "not-active" }` — slug hasn't been starred yet
|
|
343
|
+
* - `{ ok: false; reason }` — refuse to write (symlink escape,
|
|
344
|
+
* non-directory, ancestor escape)
|
|
345
|
+
*
|
|
346
|
+
* Symlink defenses (Codex P1 review on PR #1490): `statSync`
|
|
347
|
+
* follows symlinks, so a starred `mc-*` slug that's actually a
|
|
348
|
+
* symlink to /etc would let the recursive copy below write
|
|
349
|
+
* outside the workspace. Two-layer defense:
|
|
350
|
+
* 1. `lstatSync` to see the link itself; if it's a symlink,
|
|
351
|
+
* only accept when its target stays inside `activeDir`.
|
|
352
|
+
* 2. Always realpath-verify the full path (catches the case
|
|
353
|
+
* where an ancestor like `.claude/` is symlinked even when
|
|
354
|
+
* the slug dir itself is a regular directory). */
|
|
355
|
+
function classifyActiveDest(slug, destSlugDir, activeDir) {
|
|
356
|
+
let destInfo;
|
|
357
|
+
try {
|
|
358
|
+
destInfo = lstatSync(destSlugDir);
|
|
359
|
+
} catch {
|
|
360
|
+
return { kind: "not-active" };
|
|
361
|
+
}
|
|
362
|
+
if (destInfo.isSymbolicLink()) {
|
|
363
|
+
if (!isRealpathInside(destSlugDir, activeDir)) return {
|
|
364
|
+
ok: false,
|
|
365
|
+
reason: "active slot is a symlink whose target escapes activeDir; refusing to write through it"
|
|
366
|
+
};
|
|
367
|
+
return { ok: true };
|
|
368
|
+
}
|
|
369
|
+
if (!destInfo.isDirectory()) return {
|
|
370
|
+
ok: false,
|
|
371
|
+
reason: "active slot is occupied by a non-directory; skipping"
|
|
372
|
+
};
|
|
373
|
+
if (!isRealpathInside(destSlugDir, activeDir)) return {
|
|
374
|
+
ok: false,
|
|
375
|
+
reason: "active slug dir escapes activeDir via an ancestor symlink"
|
|
376
|
+
};
|
|
377
|
+
return { ok: true };
|
|
378
|
+
}
|
|
379
|
+
/** Per-slug worker for `syncActivePresetSkills`. Extracted to keep
|
|
380
|
+
* the outer function under the `sonarjs/cognitive-complexity`
|
|
381
|
+
* threshold; no behavior difference vs the inline loop. */
|
|
382
|
+
function processActiveSlug(slug, opts, result, backupExt) {
|
|
383
|
+
const srcSlugDir = path.join(opts.sourceDir, slug);
|
|
384
|
+
try {
|
|
385
|
+
if (!statSync(srcSlugDir).isDirectory()) return;
|
|
386
|
+
} catch {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const destSlugDir = path.join(opts.activeDir, slug);
|
|
390
|
+
const verdict = classifyActiveDest(slug, destSlugDir, opts.activeDir);
|
|
391
|
+
if ("kind" in verdict) {
|
|
392
|
+
result.notActive.push(slug);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (!verdict.ok) {
|
|
396
|
+
result.skipped.push(`${slug}: ${verdict.reason}`);
|
|
397
|
+
opts.onWarn?.("active preset sync skipped", {
|
|
398
|
+
slug,
|
|
399
|
+
reason: verdict.reason,
|
|
400
|
+
destSlugDir
|
|
401
|
+
});
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
const stats = syncDirTreeDiff(srcSlugDir, destSlugDir, backupExt);
|
|
405
|
+
if (stats.updated > 0) {
|
|
406
|
+
result.updated.push(slug);
|
|
407
|
+
opts.onInfo?.("active preset skill updated from source", {
|
|
408
|
+
slug,
|
|
409
|
+
files: stats.updated,
|
|
410
|
+
backupSuffix: backupExt
|
|
411
|
+
});
|
|
412
|
+
} else if (stats.skipped === 0) result.unchanged.push(slug);
|
|
413
|
+
if (stats.skipped > 0) {
|
|
414
|
+
result.skipped.push(`${slug}: ${stats.skipped} file(s) skipped`);
|
|
415
|
+
opts.onWarn?.("active preset skill partial update", {
|
|
416
|
+
slug,
|
|
417
|
+
skipped: stats.skipped
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
/** Realpath targets of active symlinks. Used so the prune below never
|
|
422
|
+
* deletes a directory that's serving as a symlink target (e.g. a
|
|
423
|
+
* git-managed checkout the user symlinks an active slug to). */
|
|
424
|
+
function collectSymlinkTargets(activeDir, entries) {
|
|
425
|
+
const targets = /* @__PURE__ */ new Set();
|
|
426
|
+
for (const slug of entries) {
|
|
427
|
+
const entryPath = path.join(activeDir, slug);
|
|
428
|
+
try {
|
|
429
|
+
if (lstatSync(entryPath).isSymbolicLink()) targets.add(realpathSync(entryPath));
|
|
430
|
+
} catch {}
|
|
431
|
+
}
|
|
432
|
+
return targets;
|
|
433
|
+
}
|
|
434
|
+
/** True iff the active `slug` is a retired preset safe to delete: an
|
|
435
|
+
* `mc-*` real directory inside `activeDir`, with no source preset, and
|
|
436
|
+
* not itself a symlink or a symlink target. */
|
|
437
|
+
function isRetiredActiveSlug(slug, activeDir, sourceSlugs, symlinkTargets) {
|
|
438
|
+
if (!isPresetSlug(slug) || sourceSlugs.has(slug)) return false;
|
|
439
|
+
const destSlugDir = path.join(activeDir, slug);
|
|
440
|
+
let info;
|
|
441
|
+
try {
|
|
442
|
+
info = lstatSync(destSlugDir);
|
|
443
|
+
} catch {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
if (info.isSymbolicLink() || !info.isDirectory()) return false;
|
|
447
|
+
if (!isRealpathInside(destSlugDir, activeDir)) return false;
|
|
448
|
+
try {
|
|
449
|
+
return !symlinkTargets.has(realpathSync(destSlugDir));
|
|
450
|
+
} catch {
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
/** Prune active `mc-*` slugs whose launcher source preset no longer
|
|
455
|
+
* exists (a retired preset). Without this, an upgraded workspace that
|
|
456
|
+
* had starred a since-removed preset (e.g. `mc-manage-sources`) keeps
|
|
457
|
+
* the active copy forever — Claude would still discover a skill whose
|
|
458
|
+
* backend was deleted. Bounded to `mc-*` real directories that stay
|
|
459
|
+
* inside `activeDir` (never a symlink escape, never a user skill). */
|
|
460
|
+
function removeRetiredActivePresets(opts, result, sourceSlugs) {
|
|
461
|
+
let activeEntries;
|
|
462
|
+
try {
|
|
463
|
+
activeEntries = readdirSync(opts.activeDir);
|
|
464
|
+
} catch {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const symlinkTargets = collectSymlinkTargets(opts.activeDir, activeEntries);
|
|
468
|
+
for (const slug of activeEntries) {
|
|
469
|
+
if (!isRetiredActiveSlug(slug, opts.activeDir, sourceSlugs, symlinkTargets)) continue;
|
|
470
|
+
try {
|
|
471
|
+
rmSync(path.join(opts.activeDir, slug), {
|
|
472
|
+
recursive: true,
|
|
473
|
+
force: true
|
|
474
|
+
});
|
|
475
|
+
result.removed.push(slug);
|
|
476
|
+
opts.onInfo?.("removed retired active preset skill", { slug });
|
|
477
|
+
} catch (err) {
|
|
478
|
+
result.skipped.push(`${slug}: prune failed: ${errorMessage(err)}`);
|
|
479
|
+
opts.onWarn?.("active preset prune failed", {
|
|
480
|
+
slug,
|
|
481
|
+
reason: errorMessage(err)
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
/** Refresh every already-starred `mc-*` preset's active copy in
|
|
487
|
+
* `<workspaceRoot>/.claude/skills/<slug>/` to match the source.
|
|
488
|
+
* Per-file diff with `.bak.<timestamp>` backup on overwrite. Slugs
|
|
489
|
+
* that aren't starred yet are listed in `notActive` but never
|
|
490
|
+
* auto-created. */
|
|
491
|
+
function syncActivePresetSkills(opts) {
|
|
492
|
+
const result = {
|
|
493
|
+
updated: [],
|
|
494
|
+
unchanged: [],
|
|
495
|
+
notActive: [],
|
|
496
|
+
removed: [],
|
|
497
|
+
skipped: [],
|
|
498
|
+
backupSuffix: null
|
|
499
|
+
};
|
|
500
|
+
if (!existsSync(opts.sourceDir)) return result;
|
|
501
|
+
let sourceInfo;
|
|
502
|
+
try {
|
|
503
|
+
sourceInfo = statSync(opts.sourceDir);
|
|
504
|
+
} catch (err) {
|
|
505
|
+
return abortActiveSync(opts, result, `source path stat failed: ${errorMessage(err)}`);
|
|
506
|
+
}
|
|
507
|
+
if (!sourceInfo.isDirectory()) return abortActiveSync(opts, result, "source path exists as a non-directory; active preset sync skipped");
|
|
508
|
+
let sourceEntries;
|
|
509
|
+
try {
|
|
510
|
+
sourceEntries = readdirSync(opts.sourceDir);
|
|
511
|
+
} catch (err) {
|
|
512
|
+
return abortActiveSync(opts, result, `source readdir failed: ${errorMessage(err)}`);
|
|
513
|
+
}
|
|
514
|
+
const backupExt = `.bak.${Date.now()}`;
|
|
515
|
+
result.backupSuffix = backupExt;
|
|
516
|
+
const sourceSlugs = /* @__PURE__ */ new Set();
|
|
517
|
+
for (const slug of sourceEntries) {
|
|
518
|
+
if (slug.startsWith(".")) continue;
|
|
519
|
+
if (!isPresetSlug(slug)) continue;
|
|
520
|
+
sourceSlugs.add(slug);
|
|
521
|
+
processActiveSlug(slug, opts, result, backupExt);
|
|
522
|
+
}
|
|
523
|
+
removeRetiredActivePresets(opts, result, sourceSlugs);
|
|
524
|
+
if (result.updated.length > 0 || result.removed.length > 0) opts.onInfo?.("active preset skills synced", {
|
|
525
|
+
updated: result.updated.length,
|
|
526
|
+
unchanged: result.unchanged.length,
|
|
527
|
+
notActive: result.notActive.length,
|
|
528
|
+
removed: result.removed.length,
|
|
529
|
+
skipped: result.skipped.length,
|
|
530
|
+
backupSuffix: backupExt
|
|
531
|
+
});
|
|
532
|
+
return result;
|
|
533
|
+
}
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region src/workspace-setup/assets.ts
|
|
536
|
+
var ASSETS_DIR = fileURLToPath(new URL("../../assets", "" + import.meta.url));
|
|
537
|
+
/** The bundled help-docs source dir (`assets/helps/`). */
|
|
538
|
+
function helpsAssetDir() {
|
|
539
|
+
return path.join(ASSETS_DIR, "helps");
|
|
540
|
+
}
|
|
541
|
+
/** The bundled preset-skills source dir (`assets/skills-preset/`) — pass as the
|
|
542
|
+
* `sourceDir` of `syncPresetSkills` / `syncActivePresetSkills`. */
|
|
543
|
+
function presetSkillsAssetDir() {
|
|
544
|
+
return path.join(ASSETS_DIR, "skills-preset");
|
|
545
|
+
}
|
|
546
|
+
/** Copy every bundled help doc into `destDir` (created if missing). Idempotent —
|
|
547
|
+
* overwrites on each call so the help docs always track the package's version. */
|
|
548
|
+
function seedHelps(opts) {
|
|
549
|
+
mkdirSync(opts.destDir, { recursive: true });
|
|
550
|
+
const src = helpsAssetDir();
|
|
551
|
+
for (const file of readdirSync(src)) copyFileSync(path.join(src, file), path.join(opts.destDir, file));
|
|
552
|
+
}
|
|
553
|
+
//#endregion
|
|
554
|
+
export { PRESET_SLUG_PREFIX, _replaceSlugTree, helpsAssetDir, isPresetSlug, presetSkillsAssetDir, seedHelps, syncActivePresetSkills, syncPresetSkills };
|
|
555
|
+
|
|
556
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/workspace-setup/sync.ts","../../src/workspace-setup/assets.ts"],"sourcesContent":["// Preset skills bundled with mulmoclaude.\n//\n// History: introduced in #1210 to ship launcher-managed \"factory\"\n// skills like `mc-library`. Originally synced straight into\n// `<workspaceRoot>/.claude/skills/<slug>/`, which made every preset\n// auto-active and inflated the Claude system prompt as new presets\n// landed.\n//\n// #1335 PR-A flipped the destination to the catalog\n// (`<workspaceRoot>/data/skills/catalog/preset/<slug>/`). Catalog\n// entries are visible to UI / tooling but NOT discovered by Claude\n// Code's slash-command resolver — they don't enter the system\n// prompt unless the user (or a later UI in PR-B) explicitly copies\n// one into `.claude/skills/`.\n//\n// The launcher overwrites catalog entries unconditionally on every\n// boot — they're factory defaults, not user state. Anything in\n// `.claude/skills/` (active layer) is left untouched.\n//\n// `syncPresetSkills(...)` is exported as a pure-ish helper (takes\n// paths + a logger sink, returns a summary) so tests can drive it\n// against tmpdirs without touching a real workspace.\n\nimport { copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, type Dirent } from \"node:fs\";\nimport { randomUUID } from \"node:crypto\";\nimport path from \"node:path\";\nimport { PRESET_SLUG_PREFIX, isPresetSlug } from \"./slug.js\";\n\n// Inlined (was the host's ../utils/errors.js) so the package has no host coupling.\nfunction errorMessage(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n// Recursively mirror `srcDir` into `destDir`. Used by the preset\n// sync so a preset skill that ships sibling assets (e.g.\n// `schema.json` for schema-driven apps, `templates/*.html`) gets\n// copied alongside `SKILL.md` rather than silently dropped. Only\n// regular files and directories are followed — symlinks / FIFOs /\n// sockets are skipped because the preset tree is launcher-managed\n// and shouldn't contain them.\nfunction copyDirTreeSync(srcDir: string, destDir: string): void {\n mkdirSync(destDir, { recursive: true });\n for (const entry of readdirSync(srcDir, { withFileTypes: true })) {\n const srcPath = path.join(srcDir, entry.name);\n const destPath = path.join(destDir, entry.name);\n if (entry.isDirectory()) {\n copyDirTreeSync(srcPath, destPath);\n } else if (entry.isFile()) {\n copyFileSync(srcPath, destPath);\n }\n }\n}\n\nconst SKILL_FILENAME = \"SKILL.md\";\n\nexport interface SyncPresetSkillsOptions {\n /** Source directory: `<launcher>/server/workspace/skills-preset/`. */\n sourceDir: string;\n /** Destination directory:\n * `<workspaceRoot>/data/skills/catalog/preset/`. The catalog\n * half of the catalog-vs-active split — entries here are visible\n * to UI but NOT to Claude Code's prompt-time skill resolver. */\n destDir: string;\n /** Logger callbacks — kept injectable so tests don't need to\n * spin up the structured logger. The boot-side wrapper threads\n * these through to `log.info` / `log.warn`. */\n onInfo?: (message: string, data?: Record<string, unknown>) => void;\n onWarn?: (message: string, data?: Record<string, unknown>) => void;\n}\n\nexport interface SyncPresetSkillsResult {\n /** Slugs successfully copied (or refreshed) from source to dest. */\n copied: string[];\n /** Slugs removed from dest because they no longer exist in source.\n * Bounded to `mc-*` entries — user-authored slugs are never\n * considered for removal. */\n removed: string[];\n /** Source entries that failed validation (wrong prefix, missing\n * SKILL.md, etc.) and were skipped. Each entry is human-readable. */\n skipped: string[];\n}\n\n// Classification of one source entry. `silent` distinguishes\n// structural skips (hidden files, non-directory entries — not the\n// dev's fault) from misconfigurations (bad slug, missing or\n// non-regular SKILL.md — the dev WANTS to know). The boolean lives\n// on the verdict so the caller never has to string-match `reason`,\n// which would silently drop warnings if reason wording changed\n// (CodeRabbit review).\ntype Verdict = { ok: true } | { ok: false; reason: string; silent: boolean };\n\nfunction classifySourceEntry(sourceDir: string, entry: string): Verdict {\n if (entry.startsWith(\".\")) return { ok: false, reason: \"hidden\", silent: true };\n const slugDir = path.join(sourceDir, entry);\n let dirInfo;\n try {\n dirInfo = statSync(slugDir);\n } catch {\n return { ok: false, reason: \"stat failed\", silent: true };\n }\n if (!dirInfo.isDirectory()) return { ok: false, reason: \"not a directory\", silent: true };\n if (!isPresetSlug(entry)) return { ok: false, reason: `slug must start with \"${PRESET_SLUG_PREFIX}\"`, silent: false };\n // Validate SKILL.md is a regular file — `existsSync` alone\n // accepts a directory at that path, which would then crash\n // copyFileSync. Codex review caught this edge case.\n const skillPath = path.join(slugDir, SKILL_FILENAME);\n let skillInfo;\n try {\n skillInfo = statSync(skillPath);\n } catch {\n return { ok: false, reason: `missing ${SKILL_FILENAME}`, silent: false };\n }\n if (!skillInfo.isFile()) return { ok: false, reason: `${SKILL_FILENAME} must be a regular file`, silent: false };\n return { ok: true };\n}\n\n/** Prepare the destination slug dir. Returns false if the slot is\n * occupied by a regular file (local corruption / hand edits) — the\n * caller logs + skips so one bad entry can't crash the whole boot\n * (Codex review iter-1). */\nfunction ensureDestSlugDir(destSlugDir: string): boolean {\n let info;\n try {\n info = statSync(destSlugDir);\n } catch {\n mkdirSync(destSlugDir, { recursive: true });\n return true;\n }\n return info.isDirectory();\n}\n\n/** Filesystem ops `_replaceSlugTree` depends on — injectable so the\n * mid-swap failure path can be regression-tested without real IO faults. */\nexport interface SlugTreeFsOps {\n copyTree: (src: string, dest: string) => void;\n rename: (from: string, dest: string) => void;\n remove: (target: string) => void;\n exists: (target: string) => boolean;\n}\n\nconst REAL_FS_OPS: SlugTreeFsOps = {\n copyTree: copyDirTreeSync,\n rename: renameSync,\n remove: (target) => rmSync(target, { recursive: true, force: true }),\n exists: existsSync,\n};\n\n/** Refresh one preset slot as a rollback-safe stage-and-swap. Wipe-and-replace\n * (not merge) so stale sibling assets — e.g. a schema.json dropped between\n * releases — don't linger; the catalog preset slot is launcher-owned, so user\n * edits there are not preserved across boots.\n *\n * The live slot is never left without a recoverable copy:\n * 1. Stage: copy the source into a temp sibling. A copy failure leaves the\n * existing preset untouched (temp dir removed).\n * 2. Move the existing tree ASIDE to a backup (rename, not delete), so the\n * old contents survive even if the next step fails.\n * 3. Move the staged copy into place. On failure, restore from the backup;\n * if even the restore fails, BOTH backup and staging are preserved for\n * manual recovery rather than deleted.\n * 4. On success, drop the backup.\n *\n * Exported with a `_` prefix only so the rename-failure-after-move path can be\n * regression-tested via the injected `fsOps`. Throws on failure (caller records\n * + skips). */\nexport function _replaceSlugTree(sourceSlugDir: string, destSlugDir: string, fsOps: SlugTreeFsOps = REAL_FS_OPS): void {\n const staging = `${destSlugDir}.tmp-${randomUUID()}`;\n try {\n fsOps.copyTree(sourceSlugDir, staging);\n } catch (err) {\n fsOps.remove(staging); // dest untouched\n throw err;\n }\n const backup = `${destSlugDir}.bak-${randomUUID()}`;\n let backedUp = false;\n if (fsOps.exists(destSlugDir)) {\n try {\n fsOps.rename(destSlugDir, backup);\n backedUp = true;\n } catch (err) {\n fsOps.remove(staging); // dest untouched; nothing was moved\n throw err;\n }\n }\n try {\n fsOps.rename(staging, destSlugDir);\n } catch (err) {\n if (backedUp) {\n try {\n fsOps.rename(backup, destSlugDir); // roll back to the previous tree\n fsOps.remove(staging);\n } catch {\n // Rollback failed — preserve BOTH backup and staging for manual\n // recovery rather than leaving the slot empty.\n }\n } else {\n fsOps.remove(staging); // dest never existed; nothing to restore\n }\n throw err;\n }\n if (backedUp) fsOps.remove(backup);\n}\n\nfunction copySourcesIntoDest(sourceDir: string, destDir: string, opts: SyncPresetSkillsOptions, result: SyncPresetSkillsResult): Set<string> {\n // `keep` is the set of slugs the retirement pass must NOT prune. It tracks\n // valid SOURCE slugs (present + usable dest slot), NOT successful copies — so\n // a slug whose refresh fails transiently keeps its existing contents (left\n // intact by the stage-and-swap above) instead of being pruned as \"retired\".\n const keep = new Set<string>();\n for (const entry of readdirSync(sourceDir)) {\n const verdict = classifySourceEntry(sourceDir, entry);\n if (!verdict.ok) {\n if (!verdict.silent) {\n result.skipped.push(`${entry}: ${verdict.reason}`);\n opts.onWarn?.(\"preset entry skipped\", { slug: entry, reason: verdict.reason });\n }\n continue;\n }\n const destSlugDir = path.join(destDir, entry);\n if (!ensureDestSlugDir(destSlugDir)) {\n const reason = \"destination slot occupied by a non-directory; skipping\";\n result.skipped.push(`${entry}: ${reason}`);\n opts.onWarn?.(\"preset entry skipped\", { slug: entry, reason, destSlugDir });\n continue;\n }\n // The slug exists in source with a usable dest slot — keep it regardless of\n // whether the refresh below succeeds, so a transient failure doesn't get it\n // pruned by `removeRetiredPresets`.\n keep.add(entry);\n // Per-slug isolation: a transient IO error / permission issue / partial\n // corruption on one preset must not abort syncing the rest, nor destroy\n // the existing copy. Skip the offender (recorded) and continue.\n try {\n _replaceSlugTree(path.join(sourceDir, entry), destSlugDir);\n result.copied.push(entry);\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err);\n result.skipped.push(`${entry}: ${reason}`);\n opts.onWarn?.(\"preset copy failed, skipping\", { slug: entry, reason });\n }\n }\n return keep;\n}\n\nfunction removeRetiredPresets(destDir: string, keep: ReadonlySet<string>, opts: SyncPresetSkillsOptions, result: SyncPresetSkillsResult): void {\n for (const entry of readdirSync(destDir)) {\n if (!isPresetSlug(entry)) continue;\n if (keep.has(entry)) continue;\n const stalePath = path.join(destDir, entry);\n try {\n if (!statSync(stalePath).isDirectory()) continue;\n } catch {\n continue;\n }\n rmSync(stalePath, { recursive: true, force: true });\n result.removed.push(entry);\n opts.onInfo?.(\"removed retired preset skill\", { slug: entry });\n }\n}\n\n/** Copy every preset slug from `sourceDir` into `destDir` (the\n * preset slot under the catalog root), then remove any `mc-*`\n * entries in `destDir` that no longer have a source. The catalog\n * preset subdir is fully launcher-owned, so the `mc-*` prefix\n * check at destination is defence-in-depth: a stray non-preset\n * slug landing in `catalog/preset/` is unexpected, and we'd\n * rather skip it than silently delete a directory we don't\n * recognise. */\nexport function syncPresetSkills(opts: SyncPresetSkillsOptions): SyncPresetSkillsResult {\n const result: SyncPresetSkillsResult = { copied: [], removed: [], skipped: [] };\n if (!existsSync(opts.sourceDir)) {\n // No preset directory in the launcher tarball — nothing to do.\n // This is the legitimate \"no presets shipped yet\" state.\n return result;\n }\n // Source-side validation: the launcher's preset path COULD exist\n // as a regular file (a packaging bug, a corrupted install). Without\n // this guard, `readdirSync(sourceDir)` would throw ENOTDIR and\n // crash boot. Codex review iter-3.\n let sourceInfo;\n try {\n sourceInfo = statSync(opts.sourceDir);\n } catch (err) {\n const reason = `source path stat failed: ${errorMessage(err)}`;\n result.skipped.push(`${opts.sourceDir}: ${reason}`);\n opts.onWarn?.(\"preset sync aborted\", { sourceDir: opts.sourceDir, reason });\n return result;\n }\n if (!sourceInfo.isDirectory()) {\n const reason = \"source path exists as a non-directory; preset sync skipped\";\n result.skipped.push(`${opts.sourceDir}: ${reason}`);\n opts.onWarn?.(\"preset sync aborted\", { sourceDir: opts.sourceDir, reason });\n return result;\n }\n // The root dest itself can be corrupted into a regular file by a\n // user / external tool; mkdirSync would throw EEXIST and crash\n // boot. Treat it as a recoverable \"skip the entire sync\" state\n // — log a clear warning so the user sees what to fix.\n // (Codex review iter-2.)\n if (!ensureDestSlugDir(opts.destDir)) {\n const reason = \"root dest exists as a non-directory; preset sync skipped\";\n result.skipped.push(`${opts.destDir}: ${reason}`);\n opts.onWarn?.(\"preset sync aborted\", { destDir: opts.destDir, reason });\n return result;\n }\n const keep = copySourcesIntoDest(opts.sourceDir, opts.destDir, opts, result);\n removeRetiredPresets(opts.destDir, keep, opts, result);\n if (result.copied.length > 0 || result.removed.length > 0) {\n opts.onInfo?.(\"preset skills synced\", {\n copied: result.copied.length,\n removed: result.removed.length,\n skipped: result.skipped.length,\n });\n }\n return result;\n}\n\n// ---------------------------------------------------------------\n// Active-layer sync: keep starred mc-* presets in lockstep with\n// their launcher-bundled source.\n//\n// Motivation: the catalog sync above refreshes\n// `data/skills/catalog/preset/<slug>/` on every boot, but once a\n// user stars an entry the active copy in\n// `<workspace>/.claude/skills/<slug>/` is never updated even when\n// the launcher ships a new SKILL.md (e.g. a typo fix or, as the\n// trigger for this code, the schema-driven-apps → collections\n// rename). The SKILL.md front-matter explicitly says\n// \"do not edit this file in the workspace, it is overwritten on\n// every server boot\" — until this function existed, that was a\n// promise the active layer didn't keep.\n//\n// Safety model:\n// - Only `mc-*` slugs are touched (defensive prefix check —\n// never touches user-authored skills).\n// - Per-file diff: a file is overwritten only if its bytes\n// differ from the source. No-op when already up to date.\n// - User-added files inside an active slug dir are left alone\n// (we walk the source tree, not the dest tree).\n// - If a file IS overwritten, the previous contents are first\n// renamed to `<file>.bak.<timestamp>` so a user who had\n// locally tweaked the preset can recover.\n// - A slug whose active dir doesn't exist (= not starred yet)\n// is skipped entirely, never auto-starred.\n// ---------------------------------------------------------------\n\nexport interface SyncActivePresetSkillsOptions {\n /** Source directory: `<launcher>/server/workspace/skills-preset/`. */\n sourceDir: string;\n /** Active skills directory: `<workspaceRoot>/.claude/skills/`. */\n activeDir: string;\n onInfo?: (message: string, data?: Record<string, unknown>) => void;\n onWarn?: (message: string, data?: Record<string, unknown>) => void;\n}\n\nexport interface SyncActivePresetSkillsResult {\n /** Slugs whose active copy had at least one file overwritten. */\n updated: string[];\n /** Slugs whose active copy already matched the source — no-op. */\n unchanged: string[];\n /** Slugs that haven't been starred yet (no active dir present).\n * Listed for diagnostics; the function never auto-stars. */\n notActive: string[];\n /** Active `mc-*` slugs pruned because the launcher no longer ships a\n * source preset for them (a retired preset). Bounded to `mc-*` —\n * user-authored skills are never removed. */\n removed: string[];\n /** Per-slug failure messages (permission errors, etc.). */\n skipped: string[];\n /** Common timestamp suffix used for every backup file produced by\n * this run. Exposed so the boot-time log can point a user at the\n * exact glob to inspect. */\n backupSuffix: string | null;\n}\n\ntype FileSyncOutcome = \"updated\" | \"unchanged\" | \"skipped\";\n\nfunction filesEqual(left: string, right: string): boolean {\n try {\n return readFileSync(left).equals(readFileSync(right));\n } catch {\n return false;\n }\n}\n\n/** Copy `srcPath` over `destPath`. If `destPath` already exists and\n * differs, rename it to `destPath + backupExt` first so the user's\n * prior contents are recoverable. If `destPath` doesn't exist, just\n * copy (no backup needed). Pure: no logging here — caller decides. */\nfunction syncOneFile(srcPath: string, destPath: string, backupExt: string): FileSyncOutcome {\n let destExists: boolean;\n try {\n destExists = statSync(destPath).isFile();\n } catch {\n destExists = false;\n }\n if (!destExists) {\n try {\n copyFileSync(srcPath, destPath);\n return \"updated\";\n } catch {\n return \"skipped\";\n }\n }\n if (filesEqual(srcPath, destPath)) return \"unchanged\";\n try {\n renameSync(destPath, destPath + backupExt);\n copyFileSync(srcPath, destPath);\n return \"updated\";\n } catch {\n return \"skipped\";\n }\n}\n\ninterface DirSyncStats {\n updated: number;\n unchanged: number;\n skipped: number;\n}\n\nfunction syncDirTreeDiff(srcDir: string, destDir: string, backupExt: string): DirSyncStats {\n const stats: DirSyncStats = { updated: 0, unchanged: 0, skipped: 0 };\n try {\n mkdirSync(destDir, { recursive: true });\n } catch {\n stats.skipped++;\n return stats;\n }\n let entries: Dirent[];\n try {\n entries = readdirSync(srcDir, { withFileTypes: true });\n } catch {\n stats.skipped++;\n return stats;\n }\n for (const entry of entries) {\n const srcPath = path.join(srcDir, entry.name);\n const destPath = path.join(destDir, entry.name);\n if (entry.isDirectory()) {\n const sub = syncDirTreeDiff(srcPath, destPath, backupExt);\n stats.updated += sub.updated;\n stats.unchanged += sub.unchanged;\n stats.skipped += sub.skipped;\n } else if (entry.isFile()) {\n const outcome = syncOneFile(srcPath, destPath, backupExt);\n stats[outcome]++;\n }\n // Symlinks / sockets / FIFOs intentionally ignored (the launcher\n // preset tree shouldn't contain them).\n }\n return stats;\n}\n\nfunction abortActiveSync(opts: SyncActivePresetSkillsOptions, result: SyncActivePresetSkillsResult, reason: string): SyncActivePresetSkillsResult {\n result.skipped.push(`${opts.sourceDir}: ${reason}`);\n opts.onWarn?.(\"active preset sync aborted\", { sourceDir: opts.sourceDir, reason });\n return result;\n}\n\n/** True iff `absPath`'s realpath resolves inside `rootPath`'s\n * realpath. Defends `processActiveSlug` against a starred `mc-*`\n * slug that's actually a symlink to somewhere outside\n * `activeDir`: without this check, the recursive copy below would\n * follow the symlink and write through to the link's target\n * (potentially anywhere on disk). Returns false on any error so\n * the caller treats unreadable paths as \"refused\" rather than\n * \"OK to write\". */\nfunction isRealpathInside(absPath: string, rootPath: string): boolean {\n try {\n const real = realpathSync(absPath);\n const rootReal = realpathSync(rootPath);\n return real === rootReal || real.startsWith(rootReal + path.sep);\n } catch {\n return false;\n }\n}\n\ntype DestVerdict = { ok: true } | { ok: false; reason: string } | { kind: \"not-active\" };\n\n/** Validate the active dest slug dir before writing through it.\n * Returns:\n * - `{ ok: true }` — proceed with the sync\n * - `{ kind: \"not-active\" }` — slug hasn't been starred yet\n * - `{ ok: false; reason }` — refuse to write (symlink escape,\n * non-directory, ancestor escape)\n *\n * Symlink defenses (Codex P1 review on PR #1490): `statSync`\n * follows symlinks, so a starred `mc-*` slug that's actually a\n * symlink to /etc would let the recursive copy below write\n * outside the workspace. Two-layer defense:\n * 1. `lstatSync` to see the link itself; if it's a symlink,\n * only accept when its target stays inside `activeDir`.\n * 2. Always realpath-verify the full path (catches the case\n * where an ancestor like `.claude/` is symlinked even when\n * the slug dir itself is a regular directory). */\nfunction classifyActiveDest(slug: string, destSlugDir: string, activeDir: string): DestVerdict {\n let destInfo;\n try {\n destInfo = lstatSync(destSlugDir);\n } catch {\n return { kind: \"not-active\" };\n }\n if (destInfo.isSymbolicLink()) {\n if (!isRealpathInside(destSlugDir, activeDir)) {\n return { ok: false, reason: \"active slot is a symlink whose target escapes activeDir; refusing to write through it\" };\n }\n return { ok: true };\n }\n if (!destInfo.isDirectory()) {\n return { ok: false, reason: \"active slot is occupied by a non-directory; skipping\" };\n }\n if (!isRealpathInside(destSlugDir, activeDir)) {\n return { ok: false, reason: \"active slug dir escapes activeDir via an ancestor symlink\" };\n }\n return { ok: true };\n}\n\n/** Per-slug worker for `syncActivePresetSkills`. Extracted to keep\n * the outer function under the `sonarjs/cognitive-complexity`\n * threshold; no behavior difference vs the inline loop. */\nfunction processActiveSlug(slug: string, opts: SyncActivePresetSkillsOptions, result: SyncActivePresetSkillsResult, backupExt: string): void {\n const srcSlugDir = path.join(opts.sourceDir, slug);\n try {\n if (!statSync(srcSlugDir).isDirectory()) return;\n } catch {\n return;\n }\n const destSlugDir = path.join(opts.activeDir, slug);\n const verdict = classifyActiveDest(slug, destSlugDir, opts.activeDir);\n if (\"kind\" in verdict) {\n result.notActive.push(slug);\n return;\n }\n if (!verdict.ok) {\n result.skipped.push(`${slug}: ${verdict.reason}`);\n opts.onWarn?.(\"active preset sync skipped\", { slug, reason: verdict.reason, destSlugDir });\n return;\n }\n const stats = syncDirTreeDiff(srcSlugDir, destSlugDir, backupExt);\n if (stats.updated > 0) {\n result.updated.push(slug);\n opts.onInfo?.(\"active preset skill updated from source\", { slug, files: stats.updated, backupSuffix: backupExt });\n } else if (stats.skipped === 0) {\n result.unchanged.push(slug);\n }\n if (stats.skipped > 0) {\n result.skipped.push(`${slug}: ${stats.skipped} file(s) skipped`);\n opts.onWarn?.(\"active preset skill partial update\", { slug, skipped: stats.skipped });\n }\n}\n\n/** Realpath targets of active symlinks. Used so the prune below never\n * deletes a directory that's serving as a symlink target (e.g. a\n * git-managed checkout the user symlinks an active slug to). */\nfunction collectSymlinkTargets(activeDir: string, entries: readonly string[]): Set<string> {\n const targets = new Set<string>();\n for (const slug of entries) {\n const entryPath = path.join(activeDir, slug);\n try {\n if (lstatSync(entryPath).isSymbolicLink()) targets.add(realpathSync(entryPath));\n } catch {\n /* unreadable — ignore */\n }\n }\n return targets;\n}\n\n/** True iff the active `slug` is a retired preset safe to delete: an\n * `mc-*` real directory inside `activeDir`, with no source preset, and\n * not itself a symlink or a symlink target. */\nfunction isRetiredActiveSlug(slug: string, activeDir: string, sourceSlugs: ReadonlySet<string>, symlinkTargets: ReadonlySet<string>): boolean {\n if (!isPresetSlug(slug) || sourceSlugs.has(slug)) return false;\n const destSlugDir = path.join(activeDir, slug);\n let info;\n try {\n info = lstatSync(destSlugDir);\n } catch {\n return false;\n }\n if (info.isSymbolicLink() || !info.isDirectory()) return false;\n if (!isRealpathInside(destSlugDir, activeDir)) return false;\n try {\n return !symlinkTargets.has(realpathSync(destSlugDir));\n } catch {\n return false;\n }\n}\n\n/** Prune active `mc-*` slugs whose launcher source preset no longer\n * exists (a retired preset). Without this, an upgraded workspace that\n * had starred a since-removed preset (e.g. `mc-manage-sources`) keeps\n * the active copy forever — Claude would still discover a skill whose\n * backend was deleted. Bounded to `mc-*` real directories that stay\n * inside `activeDir` (never a symlink escape, never a user skill). */\nfunction removeRetiredActivePresets(opts: SyncActivePresetSkillsOptions, result: SyncActivePresetSkillsResult, sourceSlugs: ReadonlySet<string>): void {\n let activeEntries: string[];\n try {\n activeEntries = readdirSync(opts.activeDir);\n } catch {\n return; // no active dir yet → nothing to prune\n }\n const symlinkTargets = collectSymlinkTargets(opts.activeDir, activeEntries);\n for (const slug of activeEntries) {\n if (!isRetiredActiveSlug(slug, opts.activeDir, sourceSlugs, symlinkTargets)) continue;\n try {\n rmSync(path.join(opts.activeDir, slug), { recursive: true, force: true });\n result.removed.push(slug);\n opts.onInfo?.(\"removed retired active preset skill\", { slug });\n } catch (err) {\n result.skipped.push(`${slug}: prune failed: ${errorMessage(err)}`);\n opts.onWarn?.(\"active preset prune failed\", { slug, reason: errorMessage(err) });\n }\n }\n}\n\n/** Refresh every already-starred `mc-*` preset's active copy in\n * `<workspaceRoot>/.claude/skills/<slug>/` to match the source.\n * Per-file diff with `.bak.<timestamp>` backup on overwrite. Slugs\n * that aren't starred yet are listed in `notActive` but never\n * auto-created. */\nexport function syncActivePresetSkills(opts: SyncActivePresetSkillsOptions): SyncActivePresetSkillsResult {\n const result: SyncActivePresetSkillsResult = { updated: [], unchanged: [], notActive: [], removed: [], skipped: [], backupSuffix: null };\n if (!existsSync(opts.sourceDir)) return result;\n let sourceInfo;\n try {\n sourceInfo = statSync(opts.sourceDir);\n } catch (err) {\n return abortActiveSync(opts, result, `source path stat failed: ${errorMessage(err)}`);\n }\n if (!sourceInfo.isDirectory()) {\n return abortActiveSync(opts, result, \"source path exists as a non-directory; active preset sync skipped\");\n }\n let sourceEntries: string[];\n try {\n sourceEntries = readdirSync(opts.sourceDir);\n } catch (err) {\n return abortActiveSync(opts, result, `source readdir failed: ${errorMessage(err)}`);\n }\n // Single timestamp per run so a multi-file update produces sibling\n // backups with a matching suffix — easier to grep / restore.\n const backupExt = `.bak.${Date.now()}`;\n result.backupSuffix = backupExt;\n const sourceSlugs = new Set<string>();\n for (const slug of sourceEntries) {\n if (slug.startsWith(\".\")) continue;\n if (!isPresetSlug(slug)) continue;\n sourceSlugs.add(slug);\n processActiveSlug(slug, opts, result, backupExt);\n }\n // Prune active copies of presets the launcher no longer ships.\n removeRetiredActivePresets(opts, result, sourceSlugs);\n if (result.updated.length > 0 || result.removed.length > 0) {\n opts.onInfo?.(\"active preset skills synced\", {\n updated: result.updated.length,\n unchanged: result.unchanged.length,\n notActive: result.notActive.length,\n removed: result.removed.length,\n skipped: result.skipped.length,\n backupSuffix: backupExt,\n });\n }\n return result;\n}\n","// Resolve the package's BUNDLED assets (shipped via package.json `files`) and seed\n// them into a workspace. ESM-only: `import.meta.url` points at this module under\n// `dist/workspace-setup/`, so `../../assets` is the package's assets dir at the\n// package root. (The workspace-setup entries build ESM only — `import.meta.url`\n// isn't available under CJS; both hosts run the server as ESM via tsx.)\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { copyFileSync, mkdirSync, readdirSync } from \"node:fs\";\n\nconst ASSETS_DIR = fileURLToPath(new URL(\"../../assets\", import.meta.url));\n\n/** The bundled help-docs source dir (`assets/helps/`). */\nexport function helpsAssetDir(): string {\n return path.join(ASSETS_DIR, \"helps\");\n}\n\n/** The bundled preset-skills source dir (`assets/skills-preset/`) — pass as the\n * `sourceDir` of `syncPresetSkills` / `syncActivePresetSkills`. */\nexport function presetSkillsAssetDir(): string {\n return path.join(ASSETS_DIR, \"skills-preset\");\n}\n\n/** Copy every bundled help doc into `destDir` (created if missing). Idempotent —\n * overwrites on each call so the help docs always track the package's version. */\nexport function seedHelps(opts: { destDir: string }): void {\n mkdirSync(opts.destDir, { recursive: true });\n const src = helpsAssetDir();\n for (const file of readdirSync(src)) {\n copyFileSync(path.join(src, file), path.join(opts.destDir, file));\n }\n}\n"],"mappings":";;;;;;AA6BA,SAAS,aAAa,KAAsB;CAC1C,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AACxD;AASA,SAAS,gBAAgB,QAAgB,SAAuB;CAC9D,UAAU,SAAS,EAAE,WAAW,KAAK,CAAC;CACtC,KAAK,MAAM,SAA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5B,SAAS,OAAO,QAAQ;EACxB,SAAS,OAAO,QAAQ;EACxB,cAAc;CAChB,CAAC;CAEH,OAAO;AACT;;;AC7oBA,IAAM,aAAa,cAAc,IAAA,IAAA,gBAAA,KAAA,OAAA,KAAA,GAAA,CAAwC;;AAGzE,SAAgB,gBAAwB;CACtC,OAAO,KAAK,KAAK,YAAY,OAAO;AACtC;;;AAIA,SAAgB,uBAA+B;CAC7C,OAAO,KAAK,KAAK,YAAY,eAAe;AAC9C;;;AAIA,SAAgB,UAAU,MAAiC;CACzD,UAAU,KAAK,SAAS,EAAE,WAAW,KAAK,CAAC;CAC3C,MAAM,MAAM,cAAc;CAC1B,KAAK,MAAM,QAAQ,YAAY,GAAG,GAChC,aAAa,KAAK,KAAK,KAAK,IAAI,GAAG,KAAK,KAAK,KAAK,SAAS,IAAI,CAAC;AAEpE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Launcher preset namespace. Preset skills (and only those) are `mc-*`. */
|
|
2
|
+
export declare const PRESET_SLUG_PREFIX = "mc-";
|
|
3
|
+
/** True for a launcher-managed preset slug (`mc-<something>`). The sync logic uses
|
|
4
|
+
* this to bound which active skills it may refresh/prune, so user-authored skills are
|
|
5
|
+
* never touched. */
|
|
6
|
+
export declare function isPresetSlug(slug: string): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/workspace-setup/slug.ts
|
|
2
|
+
/** Launcher preset namespace. Preset skills (and only those) are `mc-*`. */
|
|
3
|
+
var PRESET_SLUG_PREFIX = "mc-";
|
|
4
|
+
/** True for a launcher-managed preset slug (`mc-<something>`). The sync logic uses
|
|
5
|
+
* this to bound which active skills it may refresh/prune, so user-authored skills are
|
|
6
|
+
* never touched. */
|
|
7
|
+
function isPresetSlug(slug) {
|
|
8
|
+
return slug.startsWith("mc-") && slug.length > 3;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { PRESET_SLUG_PREFIX, isPresetSlug };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=slug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slug.js","names":[],"sources":["../../src/workspace-setup/slug.ts"],"sourcesContent":["// Preset-skill namespace — the ONE definition of \"is this a launcher-managed preset\n// skill\". Browser-safe (no node imports) so the Vue UI can import it via the package's\n// `./slug` entry while the server-only sync logic (`.` entry, uses node:fs) imports it\n// here too. Shared by MulmoClaude and MulmoTerminal so the `mc-` convention can't drift.\n\n/** Launcher preset namespace. Preset skills (and only those) are `mc-*`. */\nexport const PRESET_SLUG_PREFIX = \"mc-\";\n\n/** True for a launcher-managed preset slug (`mc-<something>`). The sync logic uses\n * this to bound which active skills it may refresh/prune, so user-authored skills are\n * never touched. */\nexport function isPresetSlug(slug: string): boolean {\n return slug.startsWith(PRESET_SLUG_PREFIX) && slug.length > PRESET_SLUG_PREFIX.length;\n}\n"],"mappings":";;AAMA,IAAa,qBAAqB;;;;AAKlC,SAAgB,aAAa,MAAuB;CAClD,OAAO,KAAK,WAAA,KAA6B,KAAK,KAAK,SAAS;AAC9D"}
|