@sylphx/flow 1.0.3 → 1.0.4
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/core/state-detector.ts +19 -15
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -203,24 +203,28 @@ export class StateDetector {
|
|
|
203
203
|
const fullPath = path.join(this.projectPath, componentPath);
|
|
204
204
|
const exists = await fs.access(fullPath).then(() => true).catch(() => false);
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
if (!exists) {
|
|
207
|
+
state.components[componentName].installed = false;
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
207
210
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
pattern === '*.md' ? files.filter(f => f.endsWith('.md')).length : files.length;
|
|
211
|
+
// 计算文件数量
|
|
212
|
+
const files = await fs.readdir(fullPath).catch(() => []);
|
|
213
|
+
const count = pattern === '*.js' ? files.filter(f => f.endsWith('.js')).length :
|
|
214
|
+
pattern === '*.md' ? files.filter(f => f.endsWith('.md')).length : files.length;
|
|
213
215
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
216
|
+
// Component is only installed if it has files
|
|
217
|
+
state.components[componentName].installed = count > 0;
|
|
217
218
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
219
|
+
if (componentName === 'agents' || componentName === 'slashCommands' || componentName === 'rules') {
|
|
220
|
+
state.components[componentName].count = count;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// 这里可以读取版本信息(如果保存了的话)
|
|
224
|
+
const versionPath = path.join(fullPath, '.version');
|
|
225
|
+
const versionExists = await fs.access(versionPath).then(() => true).catch(() => false);
|
|
226
|
+
if (versionExists) {
|
|
227
|
+
state.components[componentName].version = await fs.readFile(versionPath, 'utf-8');
|
|
224
228
|
}
|
|
225
229
|
} catch {
|
|
226
230
|
state.components[componentName].installed = false;
|