更新 lib/skill-sync.js
This commit is contained in:
parent
8f07cffb4e
commit
cc1912ab92
|
|
@ -33,7 +33,7 @@ import { createHash, randomUUID } from 'node:crypto';
|
||||||
import { mkdir, readFile, readdir, rename, rm, stat, writeFile } from 'node:fs/promises';
|
import { mkdir, readFile, readdir, rename, rm, stat, writeFile } from 'node:fs/promises';
|
||||||
import { dirname, join, resolve } from 'node:path';
|
import { dirname, join, resolve } from 'node:path';
|
||||||
import { describeError } from "./api.js";
|
import { describeError } from "./api.js";
|
||||||
import { dshHome } from "./store.js";
|
import { migrateLegacyFile, dshHome } from "./store.js";
|
||||||
/** Cloud skill names: lowercase kebab, at most 64 characters. */
|
/** Cloud skill names: lowercase kebab, at most 64 characters. */
|
||||||
export const CLOUD_SKILL_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
export const CLOUD_SKILL_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
||||||
/** Layout contract of the cloud skill center (mirrors its store rules). */
|
/** Layout contract of the cloud skill center (mirrors its store rules). */
|
||||||
|
|
@ -103,6 +103,13 @@ export function parseSkillFrontmatter(markdown) {
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
/** Sidecar state: `$DSH_HOME/dsh-brain-skills.json` (legacy `cloud-memory-skills.json` migrates on first use). */
|
||||||
|
/** Absolute sidecar path, carrying the pre-rename file over on first use. */
|
||||||
|
export function skillsStatePath() {
|
||||||
|
const target = join(dshHome(), 'dsh-brain-skills.json');
|
||||||
|
migrateLegacyFile(target, join(dshHome(), 'cloud-memory-skills.json'));
|
||||||
|
return target;
|
||||||
|
}
|
||||||
async function isDirectory(path) {
|
async function isDirectory(path) {
|
||||||
return stat(path).then((value) => value.isDirectory()).catch(() => false);
|
return stat(path).then((value) => value.isDirectory()).catch(() => false);
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +136,7 @@ export class SkillSync {
|
||||||
return this.deps.holdingDir?.() ?? join(dshHome(), 'skills-disabled');
|
return this.deps.holdingDir?.() ?? join(dshHome(), 'skills-disabled');
|
||||||
}
|
}
|
||||||
statePath() {
|
statePath() {
|
||||||
return join(dshHome(), 'cloud-memory-skills.json');
|
return skillsStatePath();
|
||||||
}
|
}
|
||||||
async loadState() {
|
async loadState() {
|
||||||
const clean = { version: 1, uploaded: {}, delivered: {}, removed: {} };
|
const clean = { version: 1, uploaded: {}, delivered: {}, removed: {} };
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue