@lythos/skill-deck 0.1.4 → 0.1.5
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/package.json +1 -1
- package/src/link.ts +10 -9
package/package.json
CHANGED
package/src/link.ts
CHANGED
|
@@ -169,7 +169,8 @@ const MAX_CARDS = Number(deck.deck?.max_cards || 10);
|
|
|
169
169
|
// ── 收集声明 ────────────────────────────────────────────────
|
|
170
170
|
|
|
171
171
|
interface DeclaredSkill {
|
|
172
|
-
name: string;
|
|
172
|
+
name: string; // 完整声明名(如 github.com/.../lythoskill-deck)
|
|
173
|
+
baseName: string; // working set 中的目录名(如 lythoskill-deck)
|
|
173
174
|
type: "innate" | "tool" | "combo" | "transient";
|
|
174
175
|
sourcePath: string;
|
|
175
176
|
expires?: string;
|
|
@@ -186,7 +187,8 @@ for (const section of ["innate", "tool", "combo"] as const) {
|
|
|
186
187
|
errors.push(`skill 未找到: ${name}`);
|
|
187
188
|
continue;
|
|
188
189
|
}
|
|
189
|
-
|
|
190
|
+
const baseName = name.split("/").pop() || name;
|
|
191
|
+
declared.push({ name, baseName, type: section, sourcePath: src });
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
|
|
@@ -199,7 +201,7 @@ for (const [key, value] of Object.entries(deck.transient || {})) {
|
|
|
199
201
|
errors.push(`transient 路径不存在: ${key} → ${src}`);
|
|
200
202
|
continue;
|
|
201
203
|
}
|
|
202
|
-
declared.push({ name: key, type: "transient", sourcePath: src, expires: t.expires });
|
|
204
|
+
declared.push({ name: key, baseName: key, type: "transient", sourcePath: src, expires: t.expires });
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
if (errors.length > 0) {
|
|
@@ -220,11 +222,11 @@ if (declared.length > MAX_CARDS) {
|
|
|
220
222
|
mkdirSync(WORKING_SET, { recursive: true });
|
|
221
223
|
|
|
222
224
|
// 清理未声明的条目
|
|
223
|
-
const
|
|
225
|
+
const declaredBaseNames = new Set(declared.map(d => d.baseName));
|
|
224
226
|
try {
|
|
225
227
|
for (const entry of readdirSync(WORKING_SET)) {
|
|
226
228
|
if (entry.startsWith("_")) continue;
|
|
227
|
-
if (!
|
|
229
|
+
if (!declaredBaseNames.has(entry)) {
|
|
228
230
|
rmSync(join(WORKING_SET, entry), { recursive: true, force: true });
|
|
229
231
|
console.log(` 🗑️ 移除: ${entry}`);
|
|
230
232
|
}
|
|
@@ -235,7 +237,7 @@ try {
|
|
|
235
237
|
const linkedSkills: LinkedSkill[] = [];
|
|
236
238
|
|
|
237
239
|
for (const item of declared) {
|
|
238
|
-
const dest = join(WORKING_SET, item.
|
|
240
|
+
const dest = join(WORKING_SET, item.baseName);
|
|
239
241
|
|
|
240
242
|
// 幂等:已存在则删除重建(lstat 不跟随 symlink,能处理断链/自引用 symlink)
|
|
241
243
|
try {
|
|
@@ -244,10 +246,9 @@ for (const item of declared) {
|
|
|
244
246
|
} catch {}
|
|
245
247
|
|
|
246
248
|
try {
|
|
247
|
-
mkdirSync(dirname(dest), { recursive: true });
|
|
248
249
|
symlinkSync(item.sourcePath, dest);
|
|
249
250
|
} catch (err: any) {
|
|
250
|
-
console.error(`❌ 链接失败: ${item.
|
|
251
|
+
console.error(`❌ 链接失败: ${item.baseName}: ${err.message}`);
|
|
251
252
|
continue;
|
|
252
253
|
}
|
|
253
254
|
|
|
@@ -273,7 +274,7 @@ for (const item of declared) {
|
|
|
273
274
|
deck_managed_dirs: managedDirs,
|
|
274
275
|
});
|
|
275
276
|
|
|
276
|
-
console.log(` 🔗 ${item.
|
|
277
|
+
console.log(` 🔗 ${item.baseName}`);
|
|
277
278
|
}
|
|
278
279
|
|
|
279
280
|
// ── Transient 过期检查 ──────────────────────────────────────
|