skill-os 0.1.6 → 0.1.7
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/lib/sync.js +11 -2
- package/package.json +1 -1
package/lib/sync.js
CHANGED
|
@@ -73,10 +73,12 @@ function cmdSync() {
|
|
|
73
73
|
|
|
74
74
|
// 1. 加载旧索引(用于对比)
|
|
75
75
|
let oldSkills = {};
|
|
76
|
+
let currentVersion = '0.0';
|
|
76
77
|
if (fs.existsSync(indexPath)) {
|
|
77
78
|
try {
|
|
78
79
|
const old = JSON.parse(fs.readFileSync(indexPath, 'utf-8'));
|
|
79
80
|
oldSkills = old.skills || {};
|
|
81
|
+
if (old.version) currentVersion = old.version;
|
|
80
82
|
} catch (e) {
|
|
81
83
|
// 忽略解析错误
|
|
82
84
|
}
|
|
@@ -142,9 +144,16 @@ function cmdSync() {
|
|
|
142
144
|
const updated = [...newKeys].filter(k => oldKeys.has(k) &&
|
|
143
145
|
JSON.stringify(newSkills[k]) !== JSON.stringify(oldSkills[k]));
|
|
144
146
|
|
|
145
|
-
// 4.
|
|
147
|
+
// 4. 计算下一个版本号并写入索引
|
|
148
|
+
const hasChanges = added.length > 0 || removed.length > 0 || updated.length > 0;
|
|
149
|
+
let nextVersion = currentVersion || '3.0';
|
|
150
|
+
|
|
151
|
+
if (hasChanges && !isNaN(parseFloat(currentVersion))) {
|
|
152
|
+
nextVersion = (parseFloat(currentVersion) + 0.1).toFixed(1);
|
|
153
|
+
}
|
|
154
|
+
|
|
146
155
|
const indexData = {
|
|
147
|
-
version:
|
|
156
|
+
version: nextVersion,
|
|
148
157
|
repository: 'https://code.alibaba-inc.com/os-copilot/skill-os',
|
|
149
158
|
skills: newSkills,
|
|
150
159
|
generated_at: new Date().toISOString(),
|