skill-os 0.1.5 → 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 +22 -13
- 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
|
}
|
|
@@ -96,22 +98,22 @@ function cmdSync() {
|
|
|
96
98
|
// 解析 frontmatter
|
|
97
99
|
const fm = parseSkillMdFrontmatter(skillMdPath);
|
|
98
100
|
|
|
99
|
-
if (!fm || !fm.name) {
|
|
100
|
-
errors.push({ path: skillPath, error: 'Missing or invalid frontmatter (
|
|
101
|
+
if (!fm || !fm.name || !fm.description) {
|
|
102
|
+
errors.push({ path: skillPath, error: 'Missing or invalid frontmatter (requires "name" and "description" fields)' });
|
|
101
103
|
skippedCount++;
|
|
102
104
|
continue;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
|
-
//
|
|
106
|
-
const v = new Validator();
|
|
107
|
-
const result = v.validate(fm, skillSchema);
|
|
107
|
+
// 基础校验(根据需求放宽其他条件校验)
|
|
108
|
+
// const v = new Validator();
|
|
109
|
+
// const result = v.validate(fm, skillSchema);
|
|
108
110
|
|
|
109
|
-
if (!result.valid) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
111
|
+
// if (!result.valid) {
|
|
112
|
+
// const msgs = result.errors.map(e => e.stack.replace('instance.', '')).join('; ');
|
|
113
|
+
// errors.push({ path: skillPath, error: msgs });
|
|
114
|
+
// skippedCount++;
|
|
115
|
+
// continue;
|
|
116
|
+
// }
|
|
115
117
|
|
|
116
118
|
// 构建索引条目
|
|
117
119
|
newSkills[skillPath] = {
|
|
@@ -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(),
|