From 021aa37d540353553bc60c28d78e35c828c58458 Mon Sep 17 00:00:00 2001 From: Agando Date: Sat, 6 Jun 2026 18:01:01 +0200 Subject: auto: 2026-06-06_18:01 changes --- modules/ext/skill-pack-core.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'modules/ext') diff --git a/modules/ext/skill-pack-core.js b/modules/ext/skill-pack-core.js index 41844bd..6f7ad4c 100644 --- a/modules/ext/skill-pack-core.js +++ b/modules/ext/skill-pack-core.js @@ -29,6 +29,7 @@ class SkillPackCoreModule { 'skill-export': 'skill-export — Export a skill as JSON', 'skill-import': 'skill-import — Import a skill from JSON string', 'skill-sync': 'skill-sync — Rebuild skills index from /skills/ directory', + 'skill-webdav-sync': 'skill-webdav-sync — Push all skills to WebDAV as JSON files', }; } @@ -487,6 +488,7 @@ class SkillPackCoreModule { this.commands['skill-export'] = (args) => this._cmdSkillExport(args); this.commands['skill-import'] = (args) => this._cmdSkillImport(args); this.commands['skill-sync'] = () => this._cmdSkillSync(); + this.commands['skill-webdav-sync'] = () => this._cmdSkillWebdavSync(); } // ── Skill Commands ── @@ -690,6 +692,46 @@ class SkillPackCoreModule { this.terminal.print(`📚 Skill index rebuilt: ${synced} skills synced`, 'success'); } + async _cmdSkillWebdavSync() { + const fs = this.terminal.fs; + const index = fs.fsReadJSON('/skills/index.json') || {}; + const names = Object.keys(index); + if (names.length === 0) { + this.terminal.print('No skills to sync', 'info'); + return; + } + // Find the webdav module + const webdavMod = this.terminal.moduleManager.modules['WebDAVModule']; + if (!webdavMod || !webdavMod._webdavRequest) { + this.terminal.print('WebDAV module not loaded. Configure webdav first with webdav-config', 'warning'); + return; + } + this.terminal.print(`📤 Syncing ${names.length} skills to WebDAV...`, 'info'); + let ok = 0, fail = 0; + await webdavMod._ensureDir('skills'); + for (const name of names) { + const content = fs.readFile(`/skills/${name}.md`); + if (content === null) { fail++; continue; } + const meta = index[name]; + const exportObj = { ...meta, content }; + const json = JSON.stringify(exportObj, null, 2); + try { + const resp = await webdavMod._webdavRequest('PUT', 'skills/' + name + '.json', { + body: json, + headers: { 'Content-Type': 'application/json' } + }); + if (resp.ok || resp.status === 201 || resp.status === 204) { + ok++; + } else { + fail++; + } + } catch (e) { + fail++; + } + } + this.terminal.print(`📤 Skill WebDAV sync complete: ${ok} pushed, ${fail} failed`, fail > 0 ? 'warning' : 'success'); + } + init() { this.seed(); } -- cgit v1.2.3