@skild/core 0.10.19 → 0.10.22
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/index.d.ts +5 -1
- package/dist/index.js +35 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,10 @@ interface InstallRecord {
|
|
|
67
67
|
sourceType: SourceType;
|
|
68
68
|
installedAt: string;
|
|
69
69
|
updatedAt?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Derived at runtime from platform/scope/name.
|
|
72
|
+
* Stored install records omit this field to avoid machine-specific paths.
|
|
73
|
+
*/
|
|
70
74
|
installDir: string;
|
|
71
75
|
contentHash: string;
|
|
72
76
|
hasSkillMd: boolean;
|
|
@@ -96,7 +100,7 @@ interface LockEntry {
|
|
|
96
100
|
registryUrl?: string;
|
|
97
101
|
installedAt: string;
|
|
98
102
|
updatedAt?: string;
|
|
99
|
-
installDir
|
|
103
|
+
installDir?: string;
|
|
100
104
|
contentHash: string;
|
|
101
105
|
}
|
|
102
106
|
interface Lockfile {
|
package/dist/index.js
CHANGED
|
@@ -95,6 +95,35 @@ function writeJsonFilePrivate(filePath, value) {
|
|
|
95
95
|
} catch {
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
function toPersistedInstallRecord(record) {
|
|
99
|
+
const { installDir: _installDir, installedDependencies, ...rest } = record;
|
|
100
|
+
const sanitizedDeps = installedDependencies?.map((dep) => {
|
|
101
|
+
const { installDir: _depInstallDir, ...depRest } = dep;
|
|
102
|
+
return depRest;
|
|
103
|
+
});
|
|
104
|
+
if (!sanitizedDeps) return rest;
|
|
105
|
+
return { ...rest, installedDependencies: sanitizedDeps };
|
|
106
|
+
}
|
|
107
|
+
function hydrateInstallRecord(installDir, record) {
|
|
108
|
+
const hydrated = { ...record, installDir };
|
|
109
|
+
if (hydrated.installedDependencies?.length) {
|
|
110
|
+
hydrated.installedDependencies = hydrated.installedDependencies.map((dep) => {
|
|
111
|
+
if (dep.sourceType === "inline") return dep;
|
|
112
|
+
return { ...dep, installDir: getSkillInstallDir(hydrated.platform, hydrated.scope, dep.name) };
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return hydrated;
|
|
116
|
+
}
|
|
117
|
+
function toPersistedLockEntry(entry) {
|
|
118
|
+
const { installDir: _installDir, ...rest } = entry;
|
|
119
|
+
return rest;
|
|
120
|
+
}
|
|
121
|
+
function sanitizeLockfile(lockfile) {
|
|
122
|
+
const entries = Object.fromEntries(
|
|
123
|
+
Object.entries(lockfile.entries).map(([name, entry]) => [name, toPersistedLockEntry(entry)])
|
|
124
|
+
);
|
|
125
|
+
return { ...lockfile, entries };
|
|
126
|
+
}
|
|
98
127
|
function loadOrCreateGlobalConfig() {
|
|
99
128
|
const filePath = getGlobalConfigPath();
|
|
100
129
|
const existing = readJsonFile(filePath);
|
|
@@ -121,7 +150,7 @@ function loadLockfile(lockPath) {
|
|
|
121
150
|
return readJsonFile(lockPath);
|
|
122
151
|
}
|
|
123
152
|
function saveLockfile(lockPath, lockfile) {
|
|
124
|
-
writeJsonFile(lockPath, lockfile);
|
|
153
|
+
writeJsonFile(lockPath, sanitizeLockfile(lockfile));
|
|
125
154
|
}
|
|
126
155
|
function getLockPath(scope) {
|
|
127
156
|
return scope === "project" ? getProjectLockPath() : getGlobalLockPath();
|
|
@@ -136,7 +165,7 @@ function loadOrCreateLockfile(scope) {
|
|
|
136
165
|
}
|
|
137
166
|
function upsertLockEntry(scope, entry) {
|
|
138
167
|
const lockfile = loadOrCreateLockfile(scope);
|
|
139
|
-
lockfile.entries[entry.name] = entry;
|
|
168
|
+
lockfile.entries[entry.name] = toPersistedLockEntry(entry);
|
|
140
169
|
lockfile.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
141
170
|
saveLockfile(getLockPath(scope), lockfile);
|
|
142
171
|
}
|
|
@@ -148,12 +177,14 @@ function removeLockEntry(scope, name) {
|
|
|
148
177
|
}
|
|
149
178
|
function readInstallRecord(installDir) {
|
|
150
179
|
const filePath = getSkillInstallRecordPath(installDir);
|
|
151
|
-
|
|
180
|
+
const record = readJsonFile(filePath);
|
|
181
|
+
if (!record) return null;
|
|
182
|
+
return hydrateInstallRecord(installDir, record);
|
|
152
183
|
}
|
|
153
184
|
function writeInstallRecord(installDir, record) {
|
|
154
185
|
ensureDir(getSkillMetadataDir(installDir));
|
|
155
186
|
const filePath = getSkillInstallRecordPath(installDir);
|
|
156
|
-
writeJsonFile(filePath, record);
|
|
187
|
+
writeJsonFile(filePath, toPersistedInstallRecord(record));
|
|
157
188
|
}
|
|
158
189
|
|
|
159
190
|
// src/skill.ts
|