aboutsummaryrefslogtreecommitdiff
path: root/modules/ext/skill-pack-core.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-05-25 18:02:02 +0200
committerAgando <roduccomm@gmail.com>2026-05-25 18:02:02 +0200
commit4baa484b84c5184286cac2743575251454a5ee2b (patch)
treecb9002f93644f363d0f35831dc97e6492bbb0ed6 /modules/ext/skill-pack-core.js
auto: 2026-05-25_18:02 changes
Diffstat (limited to 'modules/ext/skill-pack-core.js')
-rw-r--r--modules/ext/skill-pack-core.js285
1 files changed, 285 insertions, 0 deletions
diff --git a/modules/ext/skill-pack-core.js b/modules/ext/skill-pack-core.js
new file mode 100644
index 0000000..95da385
--- /dev/null
+++ b/modules/ext/skill-pack-core.js
@@ -0,0 +1,285 @@
+class SkillPackCoreModule {
+ constructor() {
+ this.commands = {};
+ this.terminal = null;
+ this._seeded = false;
+ this._skills = this._buildSkills();
+ }
+
+ requirements() {
+ try {
+ const fs = this.terminal && this.terminal.fs;
+ if (fs && fs.readFile('/skills/_seeded')) {
+ return { met: true, missing: [] };
+ }
+ return { met: false, missing: ['Skills directory not initialized. Will be created on first use.'] };
+ } catch (e) {
+ return { met: true, missing: [] };
+ }
+ }
+
+ getHelpInfo() {
+ return {
+ 'skill-pack-core': 'Seed and manage built-in core skills (navigation, memory, search, modules, backup, mindmap, etc.)',
+ };
+ }
+
+ _buildSkills() {
+ const s = (name, desc, tags, cat, steps) => ({
+ name, description: desc, tags, category: cat,
+ content: `---\nname: ${name}\ndescription: ${desc}\ntags: [${tags.join(', ')}]\ncategory: ${cat}\n---\n## Steps\n${steps}`
+ });
+
+ return [
+ s('navigating-the-terminal', 'How to explore the WebX11 terminal, find commands, check status, and navigate the filesystem', ['terminal', 'navigation', 'help', 'filesystem'], 'system',
+`1. **Get an overview of available commands:**
+ - Call get_help() to get a full command list sorted by category
+ - Call get_status() to see filesystem state, loaded modules, Ollama status
+ - For a specific command, use help <command> or check the help map
+
+2. **Explore the filesystem:**
+ - Use list_files(path?) to browse directories (omit path for current dir)
+ - Use read_file(path) to view file contents
+ - Use get_current_dir to see your working directory
+ - Use run_command("ls") or run_command("tree") for visual output
+
+3. **Understand system state:**
+ - run_command("mem") — memory usage
+ - run_command("status") — network, files, modules, Ollama
+ - run_command("modules") — module manager GUI
+ - get_module_status() — loaded modules, URLs, local edits
+
+4. **When user asks a vague question:**
+ - First call get_status() and get_help() to understand the current state
+ - Then ask clarifying questions based on what you found`),
+
+ s('memory-and-profile', 'How to use the user profile system, session memory, and pattern tracking for persistent context', ['memory', 'profile', 'session', 'persistence'], 'system',
+`1. **User Profile (persists across sessions):**
+ - user_get(key) — read any profile field (e.g. "preferredModel", "fontSize")
+ - user_set(key, value) — write to profile, auto-persists to localStorage
+ - user_list — show all stored profile keys
+ - user_forget(key) — delete a profile key
+ - Dot notation supported: user_set knownFacts.name "Alex"
+
+2. **Session Memory (VFS-based daily logs):**
+ - session_save(summary) — save a summary of what was accomplished
+ - session_load(date) — read a specific day's log (format: YYYY-MM-DD)
+ - session_recent(count) — show last N session summaries
+ - session_stats — aggregate totals across all sessions
+ - Recent sessions auto-load into context on first message
+
+3. **Conversation Patterns:**
+ - Pattern tracking runs automatically — frequent topics surface as hints
+ - my-set, my-get, my-list store additional personal data
+ - AI conversation context persists within a session (use ai-clear to reset)
+
+4. **When to use:**
+ - At start: call session_recent(3) to see what was worked on before
+ - After identifying user preferences: call user_set to store them
+ - After complex tasks: call session_save with a brief summary`),
+
+ s('web-search-and-fetch', 'How to search the web and fetch URL content using the WebX11 proxy API', ['search', 'fetch', 'web', 'proxy', 'api'], 'research',
+`1. **Search the web:**
+ - Call web_search(query) — uses /api/search which queries SearXNG + DDG fallback
+ - Results include: title, url, content snippet, source engine
+ - Always available (same-origin, no CORS issues)
+ - 5-minute server-side cache for repeated queries
+
+2. **Fetch URL content:**
+ - Call web_fetch(url) — uses /api/extract which strips HTML, extracts clean text
+ - Returns: title, content (up to 4000 chars), word_count, extraction method
+ - SSRF protection blocks internal network addresses
+ - 15-minute server-side cache
+
+3. **Search flags (via terminal search command):**
+ - search <query> --summarize — adds AI-generated overview via Ollama
+ - search <query> --fetch — fetches content snippets for top 3 results
+
+4. **When to use:**
+ - User asks about current events, facts, research → call web_search
+ - User says "read this article" or provides a URL → call web_fetch
+ - For in-depth analysis: search first, then fetch top results`),
+
+ s('module-management', 'How to view, edit, test, reload modules and manage startup configuration', ['modules', 'editing', 'code', 'self-improvement'], 'dev',
+`1. **View module source:**
+ - view_module(name) — fetches original source or reads from _mods/ if edited
+ - Supports all loaded modules: SystemModule, FileSystemModule, SearXNGModule, etc.
+
+2. **Edit a module:**
+ - edit_module(name) — copies source to _mods/<name>.js and opens code editor
+ - Editor shows the full source in a textarea
+ - Click "Save & Test" to save and auto-load the edited version
+
+3. **Test and reload:**
+ - test_module(name) — loads edited module from _mods/ for live testing
+ - reload_module(name) — discards edits and reloads from original URL
+ - list_modified_modules — shows all modules with pending edits
+
+4. **Check for updates:**
+ - check_updates — HEAD-requests all loaded module URLs to verify reachability
+
+5. **Manage startup:**
+ - startup-modules — opens the Startup Modules UI to select which modules load
+ - load-local <path> — load a module from VFS or URL without editing
+
+6. **When to use:**
+ - User reports a bug in a module → view_module, edit_module, test_module
+ - User asks "can you add X feature?" → same workflow
+ - Always save edits before testing. If test fails, the original module stays loaded.`),
+
+ s('system-maintenance', 'How to reset, troubleshoot, and maintain the WebX11 terminal', ['system', 'maintenance', 'reset', 'troubleshoot', 'config'], 'system',
+`1. **Factory reset (wipes everything):**
+ - factory-reset --confirm — clears all webx11_ localStorage keys, resets VFS, reloads
+ - Use only when the system is in an unrecoverable state
+
+2. **Soft VFS reset:**
+ - reset-vfs --confirm — clears only the filesystem, preserves settings/profile/modules
+
+3. **Config management:**
+ - config-list — show all config keys and values
+ - config-set <key> <value> — set a config value
+ - config-delete <key> — remove a config key
+ - config-export — dump all config as JSON
+ - config-reset — restore defaults (use before factory-reset if you want to save data)
+
+4. **Health checks (run automatically after complex tasks):**
+ - Check module loading status: loaded vs total
+ - Check for pending module edits
+ - Check memory usage (high if >100MB)
+ - Check skill count (0 skills after 2+ tool calls → suggest create_skill)
+
+5. **Font size and display:**
+ - font-size <8-32> — set terminal font size, persists across sessions
+ - setfont — alias for font-size
+
+6. **When to use:**
+ - System is slow or modules fail to load → check check_updates, memory
+ - User says "reset everything" → factory-reset --confirm
+ - User says "clear my files but keep settings" → reset-vfs --confirm`),
+
+ s('backup-and-restore', 'How to backup, restore, and export WebX11 data', ['backup', 'restore', 'export', 'import', 'persistence'], 'system',
+`1. **Backup VFS:**
+ - vfs-export — downloads the entire virtual filesystem as a dated JSON file
+ - backup — creates a full backup including VFS, modules, config (saves to _backups/)
+
+2. **Export/Import personal data:**
+ - my-export — prints all my-set data as formatted JSON
+ - my-import <json> — bulk-import personal data from JSON string
+
+3. **Export/Import modules:**
+ - export-mods — exports module registry as JSON
+ - import-mods <json> — imports modules from JSON backup
+
+4. **Restore:**
+ - restore <json> — restores terminal state from a backup JSON
+ - Session logs are saved to /memory/ automatically on page unload
+
+5. **When to use:**
+ - Before factory-reset: call my-export, vfs-export, export-mods to save data
+ - When switching browsers or devices: export all, then import
+ - User says "backup my data" or "save my files"`),
+
+ s('mindmap-workflow', 'How to create, view, edit, and manage brainstorming mindmaps', ['mindmap', 'brainstorming', 'planning', 'organization'], 'productivity',
+`1. **Create a new mindmap:**
+ - mindmap new "<topic>" -t tag1,tag2 — creates a root node
+ - Tags are optional (e.g. planning, research, dev)
+ - Root gets auto-assigned a color from 7-color palette
+
+2. **Add child nodes:**
+ - mindmap add <parent-id> "<idea>" -t tag — add a child
+ - Get the parent-id from mindmap show
+ - IDs are 4-char random strings (e.g. a3f8, x7k2)
+
+3. **View:**
+ - mindmap show — full tree with Unicode box-drawing
+ - mindmap show <id> — subtree starting at that node
+
+4. **Edit nodes:**
+ - mindmap rename <id> "<new text>" — change text
+ - mindmap color <id> <color> — set color (red/green/yellow/blue/cyan/magenta/white)
+ - mindmap tag <id> <tag> — add a tag
+
+5. **Persistence:**
+ - mindmap save <name> — save to localStorage
+ - mindmap load <name> — restore
+ - mindmap list — show saved mindmaps
+ - mindmap delete <name> — remove saved
+
+6. **Export:**
+ - mindmap export [id] — Markdown bullet list output, auto-copies to clipboard
+
+7. **When to use:**
+ - Map out project structure, brainstorm features, organize ideas
+ - Break down complex tasks into subtrees
+ - User says "brainstorm", "diagram", "organize thoughts", "plan"`),
+
+ s('skills-system-guide', 'How to use the skills system: load, create, patch, list, and audit skills for persistent procedural memory', ['skills', 'system', 'meta'], 'system',
+`1. **Always load skills at task start:**
+ - At the START of every task, call load_skills(query) to check for stored procedures
+ - Example: load_skills("search the web") returns matching skill content
+ - Example: load_skills("edit module") returns the module editing workflow
+
+2. **Create skills after complex tasks:**
+ - After any task with 3+ tool calls, call create_skill to save the approach
+ - Required fields: name (kebab-case), description, content (markdown with YAML frontmatter)
+ - Optional: tags (comma-separated), category (e.g. research, system, dev)
+ - Skills persist in /skills/ as .md files with /skills/index.json for fast lookup
+
+3. **Patch skills when they're outdated:**
+ - If a stored procedure has wrong steps, call patch_skill(name, newContent)
+ - This replaces the entire skill content and updates the index
+ - Do NOT create a duplicate — always patch the existing skill
+
+4. **Auto-created error skills:**
+ - If the same tool fails 3+ times, a workaround skill is created automatically
+ - Named tool-<name>-workaround (e.g. tool-write_file-workaround)
+
+5. **Audit and maintenance:**
+ - list_skills(category?) — browse available skills, optionally filter
+ - Skills are audited every 20 messages for staleness (empty content, >30 days old)
+
+6. **YAML frontmatter format:**
+ - Each skill file must start with: ---\\nname: <name>\\ndescription: <text>\\ntags: [...]\\ncategory: <cat>\\n---\\n
+ - Steps follow under ## Steps heading
+ - Use numbered lists for sequential steps`),
+ ];
+ }
+ registerCommands() {
+ this.commands['skill-pack-core'] = () => {
+ const count = this._skills.length;
+ this.terminal.print(`Skill Pack: Core — ${count} skills available`, 'info');
+ this.terminal.print('Skills will auto-seed on load', 'info');
+ };
+ }
+ init() {
+ this.seed();
+ }
+ async seed() {
+ console.log('[SkillPackCore] seed() called, _seeded=' + this._seeded);
+ if (this._seeded) return;
+ const fs = this.terminal.fs;
+ if (!fs) { console.warn('[SkillPackCore] this.terminal.fs not available'); return; }
+ fs.mkdirRecursive('/skills');
+ let index = fs.fsReadJSON('/skills/index.json') || {};
+ console.log('[SkillPackCore] existing index keys:', Object.keys(index));
+ let seeded = 0;
+ for (const skill of this._skills) {
+ if (!index[skill.name]) {
+ fs.fsWrite(`/skills/${skill.name}.md`, skill.content);
+ index[skill.name] = {
+ name: skill.name,
+ description: skill.description,
+ tags: skill.tags,
+ category: skill.category,
+ created: new Date().toISOString(),
+ updated: new Date().toISOString()
+ };
+ seeded++;
+ }
+ }
+ if (seeded > 0) {
+ fs.fsWriteJSON('/skills/index.json', index);
+ }
+ this._seeded = true;
+ }
+}