1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
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.writeFile(`/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;
}
}
if (typeof window.webx11 !== 'undefined' && window.webx11) {
webx11.moduleManager.registerModule(new SkillPackCoreModule(), 'https://webx11.duckdns.org/spaces/newos4/modules/ext/skill-pack-core.js');
}
|