aboutsummaryrefslogtreecommitdiff
path: root/modules/ext/skill-pack-core.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-06-10 18:00:19 +0200
committerAgando <roduccomm@gmail.com>2026-06-10 18:00:19 +0200
commitc3d5fe64c268d7ca85d1e303b98201391f28c9e9 (patch)
treec621037b4f4a905ade1104c40dc0422bfee1ee64 /modules/ext/skill-pack-core.js
parent39b2df36ee5ccea52558d0537bfee87058558e94 (diff)
auto: 2026-06-10_18:00 changes
Diffstat (limited to 'modules/ext/skill-pack-core.js')
-rw-r--r--modules/ext/skill-pack-core.js50
1 files changed, 39 insertions, 11 deletions
diff --git a/modules/ext/skill-pack-core.js b/modules/ext/skill-pack-core.js
index bb00672..de50f89 100644
--- a/modules/ext/skill-pack-core.js
+++ b/modules/ext/skill-pack-core.js
@@ -2,7 +2,7 @@ class SkillPackCoreModule {
constructor() {
this.commands = {};
this.commandsMeta = {
- 'skill-list': { argType: 'dir' }, 'skill-view': { argType: 'file' },
+ 'skill-list': { argType: 'enum', enumFn: '_getSkillCategories' }, 'skill-view': { argType: 'file' },
'skill-create': { argType: 'dir' }, 'skill-patch': { argType: 'file' },
'skill-delete': { argType: 'file' }, 'skill-export': { argType: 'file' },
'skill-sync': { argType: 'file' },
@@ -775,6 +775,19 @@ class SkillPackCoreModule {
init() {
this.seed();
}
+
+ _getSkillCategories() {
+ // Read from /skills/index.json and return unique categories
+ const fs = this.terminal?.fs;
+ if (!fs) return ['system', 'research', 'devops', 'general'];
+ const index = fs.fsReadJSON('/skills/index.json') || {};
+ const cats = new Set();
+ for (const skill of Object.values(index)) {
+ if (skill.category) cats.add(skill.category);
+ }
+ return cats.size > 0 ? [...cats] : ['system', 'research', 'devops', 'general'];
+ }
+
async seed() {
console.log('[SkillPackCore] seed() called, _seeded=' + this._seeded);
if (this._seeded) return;
@@ -784,6 +797,7 @@ class SkillPackCoreModule {
let index = fs.fsReadJSON('/skills/index.json') || {};
console.log('[SkillPackCore] existing index keys:', Object.keys(index));
let seeded = 0;
+ let updated = 0;
for (const skill of this._skills) {
const existing = index[skill.name];
if (!existing) {
@@ -798,21 +812,35 @@ class SkillPackCoreModule {
};
seeded++;
} else {
- // Update existing skill content on fresh load (cache-bust version bump triggers this)
- fs.writeFile('/skills/' + skill.name + '.md', skill.content);
- index[skill.name] = {
- ...existing,
- description: skill.description,
- tags: skill.tags,
- category: skill.category,
- updated: new Date().toISOString()
- };
+ // Only rewrite the .md and update index if the bundled content has actually changed.
+ // This prevents a permanent re-index loop on /skills/index.json: every page refresh
+ // would otherwise bump the `updated` timestamp → hash mismatch → NVFS re-indexes
+ // the 7KB JSON file → LLM re-extracts 5 concepts → token waste.
+ const existingContent = fs.readFile('/skills/' + skill.name + '.md');
+ if (existingContent !== skill.content) {
+ fs.writeFile('/skills/' + skill.name + '.md', skill.content);
+ index[skill.name] = {
+ ...existing,
+ description: skill.description,
+ tags: skill.tags,
+ category: skill.category,
+ updated: new Date().toISOString()
+ };
+ updated++;
+ }
}
}
if (seeded > 0) {
this.terminal.print('📚 Seeded ' + seeded + ' new skill(s)', 'success');
}
- fs.fsWriteJSON('/skills/index.json', index);
+ if (updated > 0) {
+ this.terminal.print('📚 Updated ' + updated + ' skill(s) from new bundle', 'info');
+ }
+ // Only write index.json if something actually changed — otherwise we cause a
+ // hash mismatch on every refresh and NVFS re-indexes this 7KB file forever.
+ if (seeded > 0 || updated > 0) {
+ fs.fsWriteJSON('/skills/index.json', index);
+ }
this._seeded = true;
}
}