llms-py 3.0.14__py3-none-any.whl → 3.0.16__py3-none-any.whl

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.
Files changed (38) hide show
  1. llms/extensions/app/ui/threadStore.mjs +10 -3
  2. llms/extensions/computer/README.md +96 -0
  3. llms/extensions/computer/__init__.py +59 -0
  4. llms/extensions/{computer_use → computer}/bash.py +2 -2
  5. llms/extensions/{computer_use → computer}/edit.py +10 -14
  6. llms/extensions/computer/filesystem.py +542 -0
  7. llms/extensions/core_tools/__init__.py +0 -38
  8. llms/extensions/providers/google.py +57 -30
  9. llms/extensions/skills/LICENSE +202 -0
  10. llms/extensions/skills/__init__.py +130 -0
  11. llms/extensions/skills/errors.py +25 -0
  12. llms/extensions/skills/models.py +39 -0
  13. llms/extensions/skills/parser.py +178 -0
  14. llms/extensions/skills/ui/index.mjs +362 -0
  15. llms/extensions/skills/ui/skills/create-plan/SKILL.md +74 -0
  16. llms/extensions/skills/validator.py +177 -0
  17. llms/extensions/system_prompts/ui/index.mjs +6 -10
  18. llms/extensions/tools/__init__.py +5 -82
  19. llms/extensions/tools/ui/index.mjs +93 -5
  20. llms/main.py +215 -35
  21. llms/ui/ai.mjs +1 -1
  22. llms/ui/app.css +527 -22
  23. llms/ui/ctx.mjs +53 -6
  24. llms/ui/modules/chat/ChatBody.mjs +186 -24
  25. llms/ui/modules/chat/index.mjs +107 -103
  26. llms/ui/tailwind.input.css +10 -0
  27. llms/ui/utils.mjs +25 -1
  28. {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/METADATA +1 -1
  29. {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/RECORD +37 -27
  30. {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/WHEEL +1 -1
  31. llms/extensions/computer_use/__init__.py +0 -27
  32. /llms/extensions/{computer_use → computer}/base.py +0 -0
  33. /llms/extensions/{computer_use → computer}/computer.py +0 -0
  34. /llms/extensions/{computer_use → computer}/platform.py +0 -0
  35. /llms/extensions/{computer_use → computer}/run.py +0 -0
  36. {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/entry_points.txt +0 -0
  37. {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/licenses/LICENSE +0 -0
  38. {llms_py-3.0.14.dist-info → llms_py-3.0.16.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,362 @@
1
+ import { ref, inject, computed } from "vue"
2
+ import { leftPart } from "@servicestack/client"
3
+
4
+ let ext
5
+
6
+ const SkillSelector = {
7
+ template: `
8
+ <div class="px-4 py-4 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 max-h-[80vh] overflow-y-auto">
9
+
10
+ <!-- Global Controls -->
11
+ <div class="flex items-center justify-between mb-4">
12
+ <span class="text-xs font-bold uppercase text-gray-500 tracking-wider">Include Skills</span>
13
+ <div class="flex items-center gap-2">
14
+ <button @click="$ctx.setPrefs({ onlySkills: null })"
15
+ class="px-3 py-1 rounded-md text-xs font-medium border transition-colors select-none"
16
+ :class="$prefs.onlySkills == null
17
+ ? 'bg-green-100 dark:bg-green-900/40 text-green-800 dark:text-green-300 border-green-300 dark:border-green-800'
18
+ : 'cursor-pointer bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600'">
19
+ All Skills
20
+ </button>
21
+ <button @click="$ctx.setPrefs({ onlySkills:[] })"
22
+ class="px-3 py-1 rounded-md text-xs font-medium border transition-colors select-none"
23
+ :class="$prefs.onlySkills?.length === 0
24
+ ? 'bg-fuchsia-100 dark:bg-fuchsia-900/40 text-fuchsia-800 dark:text-fuchsia-300 border-fuchsia-200 dark:border-fuchsia-800'
25
+ : 'cursor-pointer bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600'">
26
+ No Skills
27
+ </button>
28
+ </div>
29
+ </div>
30
+
31
+ <!-- Groups -->
32
+ <div class="space-y-3">
33
+ <div v-for="group in skillGroups" :key="group.name"
34
+ class="bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden">
35
+
36
+ <!-- Group Header -->
37
+ <div class="flex items-center justify-between px-3 py-2 bg-gray-50/50 dark:bg-gray-800/50 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
38
+ @click="toggleCollapse(group.name)">
39
+
40
+ <div class="flex items-center gap-2 min-w-0">
41
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="w-4 h-4 text-gray-400 transition-transform duration-200" :class="{ '-rotate-90': isCollapsed(group.name) }">
42
+ <path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z" clip-rule="evenodd" />
43
+ </svg>
44
+ <span class="font-semibold text-sm text-gray-700 dark:text-gray-200 truncate">
45
+ {{ group.name || 'Other Skills' }}
46
+ </span>
47
+ <span class="text-xs text-gray-400 font-mono">
48
+ {{ getActiveCount(group) }}/{{ group.skills.length }}
49
+ </span>
50
+ </div>
51
+
52
+ <div class="flex items-center gap-2" @click.stop>
53
+ <button @click="setGroupSkills(group, true)" type="button"
54
+ title="Include All in Group"
55
+ class="px-2 py-0.5 rounded text-xs font-medium border transition-colors select-none"
56
+ :class="getActiveCount(group) === group.skills.length
57
+ ? 'bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-300 border-green-300 dark:border-green-800 hover:bg-green-100 dark:hover:bg-green-900/40'
58
+ : 'bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600'">
59
+ all
60
+ </button>
61
+ <button @click="setGroupSkills(group, false)" type="button"
62
+ title="Include None in Group"
63
+ class="px-2 py-0.5 rounded text-xs font-medium border transition-colors select-none"
64
+ :class="getActiveCount(group) === 0
65
+ ? 'bg-fuchsia-50 dark:bg-fuchsia-900/20 text-fuchsia-700 dark:text-fuchsia-300 border-fuchsia-200 dark:border-fuchsia-800 hover:bg-fuchsia-100 dark:hover:bg-fuchsia-900/40'
66
+ : 'bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600'">
67
+ none
68
+ </button>
69
+ </div>
70
+ </div>
71
+
72
+ <!-- Group Body -->
73
+ <div v-show="!isCollapsed(group.name)" class="p-3 bg-white dark:bg-gray-900 border-t border-gray-100 dark:border-gray-800">
74
+ <div class="flex flex-wrap gap-2">
75
+ <button v-for="skill in group.skills" :key="skill.name" type="button"
76
+ @click="toggleSkill(skill.name)"
77
+ :title="skill.description"
78
+ class="px-2.5 py-1 rounded-full text-xs font-medium border transition-colors select-none text-left truncate max-w-[200px]"
79
+ :class="isSkillActive(skill.name)
80
+ ? 'bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-300 border-blue-200 dark:border-blue-800'
81
+ : 'bg-gray-50 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600'">
82
+ {{ skill.name }}
83
+ </button>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ </div>
89
+ `,
90
+ setup() {
91
+ const ctx = inject('ctx')
92
+ const collapsedState = ref({})
93
+
94
+ const availableSkills = computed(() => Object.values(ctx.state.skills || {}))
95
+
96
+ const skillGroups = computed(() => {
97
+ const skills = availableSkills.value
98
+ const groupsMap = {}
99
+ const otherSkills = []
100
+
101
+ skills.forEach(skill => {
102
+ if (skill.group) {
103
+ if (!groupsMap[skill.group]) groupsMap[skill.group] = []
104
+ groupsMap[skill.group].push(skill)
105
+ } else {
106
+ otherSkills.push(skill)
107
+ }
108
+ })
109
+
110
+ const definedGroups = Object.entries(groupsMap).map(([name, skills]) => ({
111
+ name,
112
+ skills
113
+ }))
114
+
115
+ // Sort groups by name if needed, but for now rely on insertion order or backend order
116
+ definedGroups.sort((a, b) => a.name.localeCompare(b.name))
117
+
118
+ if (otherSkills.length > 0) {
119
+ definedGroups.push({ name: '', skills: otherSkills })
120
+ }
121
+
122
+ return definedGroups
123
+ })
124
+
125
+ function isSkillActive(name) {
126
+ const only = ctx.prefs.onlySkills
127
+ if (only == null) return true
128
+ if (Array.isArray(only)) {
129
+ return only.includes(name)
130
+ }
131
+ return false
132
+ }
133
+
134
+ function toggleSkill(name) {
135
+ let onlySkills = ctx.prefs.onlySkills
136
+
137
+ if (onlySkills == null) {
138
+ // If currently 'All', clicking a skill means we enter custom mode with all OTHER skills selected (deselecting clicked)
139
+ // Wait, logic in ToolSelector:
140
+ // if (onlyTools == null) { onlyTools = availableTools.value.map(t => t.function.name).filter(t => t !== name) }
141
+ // This means deselecting one tool switches to "custom" with all but that one.
142
+
143
+ onlySkills = availableSkills.value.map(s => s.name).filter(s => s !== name)
144
+ } else {
145
+ if (onlySkills.includes(name)) {
146
+ onlySkills = onlySkills.filter(s => s !== name)
147
+ } else {
148
+ onlySkills = [...onlySkills, name]
149
+ }
150
+ }
151
+
152
+ ctx.setPrefs({ onlySkills })
153
+ }
154
+
155
+ function toggleCollapse(groupName) {
156
+ const key = groupName || '_other_'
157
+ collapsedState.value[key] = !collapsedState.value[key]
158
+ }
159
+
160
+ function isCollapsed(groupName) {
161
+ const key = groupName || '_other_'
162
+ return !!collapsedState.value[key]
163
+ }
164
+
165
+ function setGroupSkills(group, enable) {
166
+ const groupSkillNames = group.skills.map(s => s.name)
167
+ let onlySkills = ctx.prefs.onlySkills
168
+
169
+ if (enable) {
170
+ if (onlySkills == null) return
171
+ const newSet = new Set(onlySkills)
172
+ groupSkillNames.forEach(n => newSet.add(n))
173
+ onlySkills = Array.from(newSet)
174
+ if (onlySkills.length === availableSkills.value.length) {
175
+ onlySkills = null
176
+ }
177
+ } else {
178
+ if (onlySkills == null) {
179
+ onlySkills = availableSkills.value
180
+ .map(s => s.name)
181
+ .filter(n => !groupSkillNames.includes(n))
182
+ } else {
183
+ onlySkills = onlySkills.filter(n => !groupSkillNames.includes(n))
184
+ }
185
+ }
186
+
187
+ ctx.setPrefs({ onlySkills })
188
+ }
189
+
190
+ function getActiveCount(group) {
191
+ const onlySkills = ctx.prefs.onlySkills
192
+ if (onlySkills == null) return group.skills.length
193
+ return group.skills.filter(s => onlySkills.includes(s.name)).length
194
+ }
195
+
196
+ return {
197
+ availableSkills,
198
+ skillGroups,
199
+ isSkillActive,
200
+ toggleSkill,
201
+ toggleCollapse,
202
+ isCollapsed,
203
+ setGroupSkills,
204
+ getActiveCount
205
+ }
206
+ }
207
+ }
208
+
209
+ function codeFragment(s) {
210
+ return "`" + s + "`"
211
+ }
212
+ function codeBlock(s) {
213
+ return "```\n" + s + "\n```\n"
214
+ }
215
+
216
+ const SkillInstructions = `
217
+ You have access to specialized skills that extend your capabilities with domain-specific knowledge, workflows, and tools.
218
+ Skills are modular packages containing instructions, scripts, references, and assets for particular tasks.
219
+
220
+ ## Using Skills
221
+
222
+ Use the skill tool to read a skill's main instructions and guidance, e.g:
223
+ ${codeBlock("skill({ name: \"skill-name\" })")}
224
+
225
+ To read a specific file within a skill (scripts, references, assets):
226
+ ${codeBlock("skill({ name: \"skill-name\", file: \"relative/path/to/file\" })")}
227
+
228
+ Examples:
229
+ - ${codeFragment("skill({ name: \"create-plan\" })")} - Read the create-plan skill's SKILL.md instructions
230
+ - ${codeFragment("skill({ name: \"web-artifacts-builder\", file: \"scripts/init-artifact.sh\" })")} - Read a specific script
231
+
232
+ ## When to Use Skills
233
+
234
+ You should read the appropriate skill BEFORE starting work on relevant tasks. Skills contain best practices, scripts, and reference materials that significantly improve output quality.
235
+
236
+ **Skill Selection Guidelines:**
237
+ - Match the task to available skill descriptions
238
+ - Multiple skills may be relevant - read all that apply
239
+ - Read the skill first, then follow its instructions
240
+
241
+ ## Available Skills
242
+ $$AVAILABLE_SKILLS$$
243
+
244
+ ## Important Notes
245
+
246
+ - Always read the skill BEFORE starting implementation
247
+ - Skills may contain scripts that can be executed directly without loading into context
248
+ - Multiple skills can and should be combined when tasks span multiple domains
249
+ - If a skill references additional files (references/, scripts/, assets/), read those as needed during execution
250
+ `
251
+
252
+ export default {
253
+ order: 15 - 100,
254
+
255
+ install(ctx) {
256
+ ext = ctx.scope("skills")
257
+
258
+ ctx.components({ SkillSelector })
259
+
260
+ const svg = (attrs, title) => `<svg ${attrs} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">${title ? "<title>" + title + "</title>" : ''}<path fill="currentColor" d="M20 17a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H9.46c.35.61.54 1.3.54 2h10v11h-9v2m4-10v2H9v13H7v-6H5v6H3v-8H1.5V9a2 2 0 0 1 2-2zM8 4a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2a2 2 0 0 1 2 2"/></svg>`
261
+
262
+ ctx.setTopIcons({
263
+ skills: {
264
+ component: {
265
+ template: svg([
266
+ `@click="$ctx.toggleTop('SkillSelector')"`,
267
+ `:class="$prefs.onlySkills == null ? 'text-green-600 dark:text-green-300' : $prefs.onlySkills.length ? 'text-blue-600! dark:text-blue-300!' : ''"`
268
+ ].join(' ')),
269
+ },
270
+ isActive({ top }) {
271
+ return top === 'SkillSelector'
272
+ },
273
+ get title() {
274
+ return ctx.prefs.onlySkills == null
275
+ ? `All Skills Included`
276
+ : ctx.prefs.onlySkills.length
277
+ ? `${ctx.prefs.onlySkills.length} ${ctx.utils.pluralize('Skill', ctx.prefs.onlySkills.length)} Included`
278
+ : 'No Skills Included'
279
+ }
280
+ }
281
+ })
282
+
283
+ ctx.chatRequestFilters.push(({ request, thread, context }) => {
284
+
285
+ const prefs = ctx.prefs
286
+ if (prefs.onlySkills != null) {
287
+ if (Array.isArray(prefs.onlySkills)) {
288
+ request.metadata.skills = prefs.onlySkills.length > 0
289
+ ? prefs.onlySkills.join(',')
290
+ : 'none'
291
+ }
292
+ } else {
293
+ request.metadata.skills = 'all'
294
+ }
295
+
296
+ console.log('skills.chatRequestFilters', prefs.onlySkills, Object.keys(ctx.state.skills || {}))
297
+ const skills = ctx.state.skills
298
+ if (!skills) return
299
+
300
+ const includeSkills = []
301
+ for (const skill of Object.values(skills)) {
302
+ if (prefs.onlySkills == null || prefs.onlySkills.includes(skill.name)) {
303
+ includeSkills.push(skill)
304
+ }
305
+ }
306
+ if (!includeSkills.length) return
307
+
308
+ const sb = []
309
+ sb.push("<available_skills>")
310
+ for (const skill of includeSkills) {
311
+ sb.push(" <skill>")
312
+ sb.push(" <name>" + ctx.utils.encodeHtml(skill.name) + "</name>")
313
+ sb.push(" <description>" + ctx.utils.encodeHtml(skill.description) + "</description>")
314
+ sb.push(" <location>" + ctx.utils.encodeHtml(skill.location) + "</location>")
315
+ sb.push(" </skill>")
316
+ }
317
+ sb.push("</available_skills>")
318
+
319
+ const skillsPrompt = SkillInstructions.replace('$$AVAILABLE_SKILLS$$', sb.join('\n')).trim()
320
+ context.requiredSystemPrompts.push(skillsPrompt)
321
+ })
322
+
323
+ ctx.setThreadFooters({
324
+ skills: {
325
+ component: {
326
+ template: `
327
+ <div class="mt-2 w-full flex justify-center">
328
+ <button type="button" @click="$ctx.chat.sendUserMessage('proceed')"
329
+ class="px-3 py-1 rounded-md text-xs font-medium border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors select-none">
330
+ proceed
331
+ </button>
332
+ </div>
333
+ `
334
+ },
335
+ show({ thread }) {
336
+ if (thread.messages.length < 2) return false
337
+ const msgRoles = thread.messages.map(m => m.role)
338
+ if (msgRoles[msgRoles.length - 1] != "assistant") return false
339
+ const hasSkillToolCall = thread.messages.some(m =>
340
+ m.tool_calls?.some(tc => tc.type == "function" && tc.function.name == "skill"))
341
+ const systemPrompt = thread.messages.find(m => m.role == "system")?.content.toLowerCase() || ''
342
+ const line1 = leftPart(systemPrompt.trim(), "\n")
343
+ const hasPlanSystemPrompt = line1.includes("plan") || systemPrompt.includes("# plan")
344
+ return hasSkillToolCall || hasPlanSystemPrompt
345
+ }
346
+ }
347
+ })
348
+
349
+ ctx.setState({
350
+ skills: {}
351
+ })
352
+ },
353
+
354
+ async load(ctx) {
355
+ const api = await ext.getJson('/')
356
+ if (api.response) {
357
+ ctx.setState({ skills: api.response })
358
+ } else {
359
+ ctx.setError(api.error)
360
+ }
361
+ }
362
+ }
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: create-plan
3
+ description: Create a concise plan. Use when a user explicitly asks for a plan related to a coding task.
4
+ metadata:
5
+ short-description: Create a plan
6
+ ---
7
+
8
+ # Create Plan
9
+
10
+ ## Goal
11
+
12
+ Turn a user prompt into a **single, actionable plan** delivered in the final assistant message.
13
+
14
+ ## Minimal workflow
15
+
16
+ Throughout the entire workflow, operate in read-only mode. Do not write or update files.
17
+
18
+ 1. **Scan context quickly**
19
+ - Read `README.md` and any obvious docs (`docs/`, `CONTRIBUTING.md`, `ARCHITECTURE.md`).
20
+ - Skim relevant files (the ones most likely touched).
21
+ - Identify constraints (language, frameworks, CI/test commands, deployment shape).
22
+
23
+ 2. **Ask follow-ups only if blocking**
24
+ - Ask **at most 1–2 questions**.
25
+ - Only ask if you cannot responsibly plan without the answer; prefer multiple-choice.
26
+ - If unsure but not blocked, make a reasonable assumption and proceed.
27
+
28
+ 3. **Create a plan using the template below**
29
+ - Start with **1 short paragraph** describing the intent and approach.
30
+ - Clearly call out what is **in scope** and what is **not in scope** in short.
31
+ - Then provide a **small checklist** of action items (default 6–10 items).
32
+ - Each checklist item should be a concrete action and, when helpful, mention files/commands.
33
+ - **Make items atomic and ordered**: discovery → changes → tests → rollout.
34
+ - **Verb-first**: “Add…”, “Refactor…”, “Verify…”, “Ship…”.
35
+ - Include at least one item for **tests/validation** and one for **edge cases/risk** when applicable.
36
+ - If there are unknowns, include a tiny **Open questions** section (max 3).
37
+
38
+ 4. **Do not preface the plan with meta explanations; output only the plan as per template**
39
+
40
+ ## Plan template (follow exactly)
41
+
42
+ ```markdown
43
+ # Plan
44
+
45
+ <1–3 sentences: what we’re doing, why, and the high-level approach.>
46
+
47
+ ## Scope
48
+ - In:
49
+ - Out:
50
+
51
+ ## Action items
52
+ [ ] <Step 1>
53
+ [ ] <Step 2>
54
+ [ ] <Step 3>
55
+ [ ] <Step 4>
56
+ [ ] <Step 5>
57
+ [ ] <Step 6>
58
+
59
+ ## Open questions
60
+ - <Question 1>
61
+ - <Question 2>
62
+ - <Question 3>
63
+ ```
64
+
65
+ ## Checklist item guidance
66
+ Good checklist items:
67
+ - Point to likely files/modules: src/..., app/..., services/...
68
+ - Name concrete validation: “Run npm test”, “Add unit tests for X”
69
+ - Include safe rollout when relevant: feature flag, migration plan, rollback note
70
+
71
+ Avoid:
72
+ - Vague steps (“handle backend”, “do auth”)
73
+ - Too many micro-steps
74
+ - Writing code snippets (keep the plan implementation-agnostic)
@@ -0,0 +1,177 @@
1
+ """Skill validation logic."""
2
+
3
+ import unicodedata
4
+ from pathlib import Path
5
+ from typing import Optional
6
+
7
+ from .errors import ParseError
8
+ from .parser import find_skill_md, parse_frontmatter
9
+
10
+ MAX_SKILL_NAME_LENGTH = 64
11
+ MAX_DESCRIPTION_LENGTH = 1024
12
+ MAX_COMPATIBILITY_LENGTH = 500
13
+
14
+ # Allowed frontmatter fields per Agent Skills Spec
15
+ ALLOWED_FIELDS = {
16
+ "name",
17
+ "description",
18
+ "license",
19
+ "allowed-tools",
20
+ "metadata",
21
+ "compatibility",
22
+ }
23
+
24
+
25
+ def _validate_name(name: str, skill_dir: Path) -> list[str]:
26
+ """Validate skill name format and directory match.
27
+
28
+ Skill names support i18n characters (Unicode letters) plus hyphens.
29
+ Names must be lowercase and cannot start/end with hyphens.
30
+ """
31
+ errors = []
32
+
33
+ if not name or not isinstance(name, str) or not name.strip():
34
+ errors.append("Field 'name' must be a non-empty string")
35
+ return errors
36
+
37
+ name = unicodedata.normalize("NFKC", name.strip())
38
+
39
+ if len(name) > MAX_SKILL_NAME_LENGTH:
40
+ errors.append(
41
+ f"Skill name '{name}' exceeds {MAX_SKILL_NAME_LENGTH} character limit "
42
+ f"({len(name)} chars)"
43
+ )
44
+
45
+ if name != name.lower():
46
+ errors.append(f"Skill name '{name}' must be lowercase")
47
+
48
+ if name.startswith("-") or name.endswith("-"):
49
+ errors.append("Skill name cannot start or end with a hyphen")
50
+
51
+ if "--" in name:
52
+ errors.append("Skill name cannot contain consecutive hyphens")
53
+
54
+ if not all(c.isalnum() or c == "-" for c in name):
55
+ errors.append(
56
+ f"Skill name '{name}' contains invalid characters. "
57
+ "Only letters, digits, and hyphens are allowed."
58
+ )
59
+
60
+ if skill_dir:
61
+ dir_name = unicodedata.normalize("NFKC", skill_dir.name)
62
+ if dir_name != name:
63
+ errors.append(
64
+ f"Directory name '{skill_dir.name}' must match skill name '{name}'"
65
+ )
66
+
67
+ return errors
68
+
69
+
70
+ def _validate_description(description: str) -> list[str]:
71
+ """Validate description format."""
72
+ errors = []
73
+
74
+ if not description or not isinstance(description, str) or not description.strip():
75
+ errors.append("Field 'description' must be a non-empty string")
76
+ return errors
77
+
78
+ if len(description) > MAX_DESCRIPTION_LENGTH:
79
+ errors.append(
80
+ f"Description exceeds {MAX_DESCRIPTION_LENGTH} character limit "
81
+ f"({len(description)} chars)"
82
+ )
83
+
84
+ return errors
85
+
86
+
87
+ def _validate_compatibility(compatibility: str) -> list[str]:
88
+ """Validate compatibility format."""
89
+ errors = []
90
+
91
+ if not isinstance(compatibility, str):
92
+ errors.append("Field 'compatibility' must be a string")
93
+ return errors
94
+
95
+ if len(compatibility) > MAX_COMPATIBILITY_LENGTH:
96
+ errors.append(
97
+ f"Compatibility exceeds {MAX_COMPATIBILITY_LENGTH} character limit "
98
+ f"({len(compatibility)} chars)"
99
+ )
100
+
101
+ return errors
102
+
103
+
104
+ def _validate_metadata_fields(metadata: dict) -> list[str]:
105
+ """Validate that only allowed fields are present."""
106
+ errors = []
107
+
108
+ extra_fields = set(metadata.keys()) - ALLOWED_FIELDS
109
+ if extra_fields:
110
+ errors.append(
111
+ f"Unexpected fields in frontmatter: {', '.join(sorted(extra_fields))}. "
112
+ f"Only {sorted(ALLOWED_FIELDS)} are allowed."
113
+ )
114
+
115
+ return errors
116
+
117
+
118
+ def validate_metadata(metadata: dict, skill_dir: Optional[Path] = None) -> list[str]:
119
+ """Validate parsed skill metadata.
120
+
121
+ This is the core validation function that works on already-parsed metadata,
122
+ avoiding duplicate file I/O when called from the parser.
123
+
124
+ Args:
125
+ metadata: Parsed YAML frontmatter dictionary
126
+ skill_dir: Optional path to skill directory (for name-directory match check)
127
+
128
+ Returns:
129
+ List of validation error messages. Empty list means valid.
130
+ """
131
+ errors = []
132
+ errors.extend(_validate_metadata_fields(metadata))
133
+
134
+ if "name" not in metadata:
135
+ errors.append("Missing required field in frontmatter: name")
136
+ else:
137
+ errors.extend(_validate_name(metadata["name"], skill_dir))
138
+
139
+ if "description" not in metadata:
140
+ errors.append("Missing required field in frontmatter: description")
141
+ else:
142
+ errors.extend(_validate_description(metadata["description"]))
143
+
144
+ if "compatibility" in metadata:
145
+ errors.extend(_validate_compatibility(metadata["compatibility"]))
146
+
147
+ return errors
148
+
149
+
150
+ def validate(skill_dir: Path) -> list[str]:
151
+ """Validate a skill directory.
152
+
153
+ Args:
154
+ skill_dir: Path to the skill directory
155
+
156
+ Returns:
157
+ List of validation error messages. Empty list means valid.
158
+ """
159
+ skill_dir = Path(skill_dir)
160
+
161
+ if not skill_dir.exists():
162
+ return [f"Path does not exist: {skill_dir}"]
163
+
164
+ if not skill_dir.is_dir():
165
+ return [f"Not a directory: {skill_dir}"]
166
+
167
+ skill_md = find_skill_md(skill_dir)
168
+ if skill_md is None:
169
+ return ["Missing required file: SKILL.md"]
170
+
171
+ try:
172
+ content = skill_md.read_text()
173
+ metadata, _ = parse_frontmatter(content)
174
+ except ParseError as e:
175
+ return [str(e)]
176
+
177
+ return validate_metadata(metadata, skill_dir)
@@ -163,7 +163,7 @@ const SystemPromptEditor = {
163
163
  </div>
164
164
  </div>
165
165
  <div v-if="hasMessages" class="w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 px-3 py-2 text-sm">
166
- {{$threads.currentThread.value?.systemPrompt || 'No System Prompt was used' }}
166
+ <TextViewer prefsName="systemPrompt" :text="$threads.getCurrentThreadSystemPrompt() || 'No System Prompt was used'" />
167
167
  </div>
168
168
  <div v-else>
169
169
  <textarea
@@ -251,21 +251,17 @@ export default {
251
251
  }
252
252
  })
253
253
 
254
- ctx.chatRequestFilters.push(({ request, thread }) => {
254
+ ctx.chatRequestFilters.push(({ request, thread, context }) => {
255
255
 
256
- const hasSystemPrompt = request.messages.find(x => x.role === 'system')
256
+ const hasSystemPrompt = !!context.systemPrompt
257
+ console.log('system_prompts chatRequestFilters', hasSystemPrompt)
257
258
  if (hasSystemPrompt) {
258
259
  console.log('Already has system prompt', hasSystemPrompt.content)
259
260
  return
260
261
  }
261
262
 
262
- // Only add the selected system prompt for new requests
263
- if (ext.prefs.systemPrompt && request.messages.length <= 1) {
264
- // add message to start
265
- request.messages.unshift({
266
- role: 'system',
267
- content: ext.prefs.systemPrompt
268
- })
263
+ if (ext.prefs.systemPrompt) {
264
+ context.systemPrompt = ext.prefs.systemPrompt
269
265
  }
270
266
  })
271
267