llms-py 3.0.13__py3-none-any.whl → 3.0.15__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 (34) hide show
  1. llms/extensions/app/ui/threadStore.mjs +10 -3
  2. llms/extensions/computer_use/README.md +96 -0
  3. llms/extensions/computer_use/__init__.py +27 -0
  4. llms/extensions/computer_use/base.py +80 -0
  5. llms/extensions/computer_use/bash.py +185 -0
  6. llms/extensions/computer_use/computer.py +523 -0
  7. llms/extensions/computer_use/edit.py +303 -0
  8. llms/extensions/computer_use/platform.py +461 -0
  9. llms/extensions/computer_use/run.py +37 -0
  10. llms/extensions/providers/anthropic.py +22 -3
  11. llms/extensions/skills/LICENSE +202 -0
  12. llms/extensions/skills/__init__.py +130 -0
  13. llms/extensions/skills/errors.py +25 -0
  14. llms/extensions/skills/models.py +39 -0
  15. llms/extensions/skills/parser.py +178 -0
  16. llms/extensions/skills/ui/index.mjs +335 -0
  17. llms/extensions/skills/ui/skills/create-plan/SKILL.md +74 -0
  18. llms/extensions/skills/validator.py +177 -0
  19. llms/extensions/system_prompts/ui/index.mjs +6 -10
  20. llms/extensions/tools/ui/index.mjs +1 -1
  21. llms/main.py +88 -11
  22. llms/ui/ai.mjs +1 -1
  23. llms/ui/app.css +39 -0
  24. llms/ui/ctx.mjs +53 -6
  25. llms/ui/modules/chat/ChatBody.mjs +138 -13
  26. llms/ui/modules/chat/index.mjs +4 -12
  27. llms/ui/tailwind.input.css +10 -0
  28. llms/ui/utils.mjs +25 -1
  29. {llms_py-3.0.13.dist-info → llms_py-3.0.15.dist-info}/METADATA +1 -1
  30. {llms_py-3.0.13.dist-info → llms_py-3.0.15.dist-info}/RECORD +34 -18
  31. {llms_py-3.0.13.dist-info → llms_py-3.0.15.dist-info}/WHEEL +0 -0
  32. {llms_py-3.0.13.dist-info → llms_py-3.0.15.dist-info}/entry_points.txt +0 -0
  33. {llms_py-3.0.13.dist-info → llms_py-3.0.15.dist-info}/licenses/LICENSE +0 -0
  34. {llms_py-3.0.13.dist-info → llms_py-3.0.15.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,335 @@
1
+ import { ref, inject, computed } from "vue"
2
+
3
+ let ext
4
+
5
+ const SkillSelector = {
6
+ template: `
7
+ <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">
8
+
9
+ <!-- Global Controls -->
10
+ <div class="flex items-center justify-between mb-4">
11
+ <span class="text-xs font-bold uppercase text-gray-500 tracking-wider">Include Skills</span>
12
+ <div class="flex items-center gap-2">
13
+ <button @click="$ctx.setPrefs({ onlySkills: null })"
14
+ class="px-3 py-1 rounded-md text-xs font-medium border transition-colors select-none"
15
+ :class="$prefs.onlySkills == null
16
+ ? 'bg-green-100 dark:bg-green-900/40 text-green-800 dark:text-green-300 border-green-300 dark:border-green-800'
17
+ : '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'">
18
+ All Skills
19
+ </button>
20
+ <button @click="$ctx.setPrefs({ onlySkills:[] })"
21
+ class="px-3 py-1 rounded-md text-xs font-medium border transition-colors select-none"
22
+ :class="$prefs.onlySkills?.length === 0
23
+ ? 'bg-fuchsia-100 dark:bg-fuchsia-900/40 text-fuchsia-800 dark:text-fuchsia-300 border-fuchsia-200 dark:border-fuchsia-800'
24
+ : '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'">
25
+ No Skills
26
+ </button>
27
+ </div>
28
+ </div>
29
+
30
+ <!-- Groups -->
31
+ <div class="space-y-3">
32
+ <div v-for="group in skillGroups" :key="group.name"
33
+ class="bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden">
34
+
35
+ <!-- Group Header -->
36
+ <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"
37
+ @click="toggleCollapse(group.name)">
38
+
39
+ <div class="flex items-center gap-2 min-w-0">
40
+ <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) }">
41
+ <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" />
42
+ </svg>
43
+ <span class="font-semibold text-sm text-gray-700 dark:text-gray-200 truncate">
44
+ {{ group.name || 'Other Skills' }}
45
+ </span>
46
+ <span class="text-xs text-gray-400 font-mono">
47
+ {{ getActiveCount(group) }}/{{ group.skills.length }}
48
+ </span>
49
+ </div>
50
+
51
+ <div class="flex items-center gap-2" @click.stop>
52
+ <button @click="setGroupSkills(group, true)" type="button"
53
+ title="Include All in Group"
54
+ class="px-2 py-0.5 rounded text-xs font-medium border transition-colors select-none"
55
+ :class="getActiveCount(group) === group.skills.length
56
+ ? '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'
57
+ : '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'">
58
+ all
59
+ </button>
60
+ <button @click="setGroupSkills(group, false)" type="button"
61
+ title="Include None in Group"
62
+ class="px-2 py-0.5 rounded text-xs font-medium border transition-colors select-none"
63
+ :class="getActiveCount(group) === 0
64
+ ? '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'
65
+ : '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'">
66
+ none
67
+ </button>
68
+ </div>
69
+ </div>
70
+
71
+ <!-- Group Body -->
72
+ <div v-show="!isCollapsed(group.name)" class="p-3 bg-white dark:bg-gray-900 border-t border-gray-100 dark:border-gray-800">
73
+ <div class="flex flex-wrap gap-2">
74
+ <button v-for="skill in group.skills" :key="skill.name" type="button"
75
+ @click="toggleSkill(skill.name)"
76
+ :title="skill.description"
77
+ class="px-2.5 py-1 rounded-full text-xs font-medium border transition-colors select-none text-left truncate max-w-[200px]"
78
+ :class="isSkillActive(skill.name)
79
+ ? 'bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-300 border-blue-200 dark:border-blue-800'
80
+ : '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'">
81
+ {{ skill.name }}
82
+ </button>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ `,
89
+ setup() {
90
+ const ctx = inject('ctx')
91
+ const collapsedState = ref({})
92
+
93
+ const availableSkills = computed(() => Object.values(ctx.state.skills || {}))
94
+
95
+ const skillGroups = computed(() => {
96
+ const skills = availableSkills.value
97
+ const groupsMap = {}
98
+ const otherSkills = []
99
+
100
+ skills.forEach(skill => {
101
+ if (skill.group) {
102
+ if (!groupsMap[skill.group]) groupsMap[skill.group] = []
103
+ groupsMap[skill.group].push(skill)
104
+ } else {
105
+ otherSkills.push(skill)
106
+ }
107
+ })
108
+
109
+ const definedGroups = Object.entries(groupsMap).map(([name, skills]) => ({
110
+ name,
111
+ skills
112
+ }))
113
+
114
+ // Sort groups by name if needed, but for now rely on insertion order or backend order
115
+ definedGroups.sort((a, b) => a.name.localeCompare(b.name))
116
+
117
+ if (otherSkills.length > 0) {
118
+ definedGroups.push({ name: '', skills: otherSkills })
119
+ }
120
+
121
+ return definedGroups
122
+ })
123
+
124
+ function isSkillActive(name) {
125
+ const only = ctx.prefs.onlySkills
126
+ if (only == null) return true
127
+ if (Array.isArray(only)) {
128
+ return only.includes(name)
129
+ }
130
+ return false
131
+ }
132
+
133
+ function toggleSkill(name) {
134
+ let onlySkills = ctx.prefs.onlySkills
135
+
136
+ if (onlySkills == null) {
137
+ // If currently 'All', clicking a skill means we enter custom mode with all OTHER skills selected (deselecting clicked)
138
+ // Wait, logic in ToolSelector:
139
+ // if (onlyTools == null) { onlyTools = availableTools.value.map(t => t.function.name).filter(t => t !== name) }
140
+ // This means deselecting one tool switches to "custom" with all but that one.
141
+
142
+ onlySkills = availableSkills.value.map(s => s.name).filter(s => s !== name)
143
+ } else {
144
+ if (onlySkills.includes(name)) {
145
+ onlySkills = onlySkills.filter(s => s !== name)
146
+ } else {
147
+ onlySkills = [...onlySkills, name]
148
+ }
149
+ }
150
+
151
+ ctx.setPrefs({ onlySkills })
152
+ }
153
+
154
+ function toggleCollapse(groupName) {
155
+ const key = groupName || '_other_'
156
+ collapsedState.value[key] = !collapsedState.value[key]
157
+ }
158
+
159
+ function isCollapsed(groupName) {
160
+ const key = groupName || '_other_'
161
+ return !!collapsedState.value[key]
162
+ }
163
+
164
+ function setGroupSkills(group, enable) {
165
+ const groupSkillNames = group.skills.map(s => s.name)
166
+ let onlySkills = ctx.prefs.onlySkills
167
+
168
+ if (enable) {
169
+ if (onlySkills == null) return
170
+ const newSet = new Set(onlySkills)
171
+ groupSkillNames.forEach(n => newSet.add(n))
172
+ onlySkills = Array.from(newSet)
173
+ if (onlySkills.length === availableSkills.value.length) {
174
+ onlySkills = null
175
+ }
176
+ } else {
177
+ if (onlySkills == null) {
178
+ onlySkills = availableSkills.value
179
+ .map(s => s.name)
180
+ .filter(n => !groupSkillNames.includes(n))
181
+ } else {
182
+ onlySkills = onlySkills.filter(n => !groupSkillNames.includes(n))
183
+ }
184
+ }
185
+
186
+ ctx.setPrefs({ onlySkills })
187
+ }
188
+
189
+ function getActiveCount(group) {
190
+ const onlySkills = ctx.prefs.onlySkills
191
+ if (onlySkills == null) return group.skills.length
192
+ return group.skills.filter(s => onlySkills.includes(s.name)).length
193
+ }
194
+
195
+ return {
196
+ availableSkills,
197
+ skillGroups,
198
+ isSkillActive,
199
+ toggleSkill,
200
+ toggleCollapse,
201
+ isCollapsed,
202
+ setGroupSkills,
203
+ getActiveCount
204
+ }
205
+ }
206
+ }
207
+
208
+ function codeFragment(s) {
209
+ return "`" + s + "`"
210
+ }
211
+ function codeBlock(s) {
212
+ return "```\n" + s + "\n```\n"
213
+ }
214
+
215
+ const SkillInstructions = `
216
+ You have access to specialized skills that extend your capabilities with domain-specific knowledge, workflows, and tools.
217
+ Skills are modular packages containing instructions, scripts, references, and assets for particular tasks.
218
+
219
+ ## Using Skills
220
+
221
+ Use the skill tool to read a skill's main instructions and guidance, e.g:
222
+ ${codeBlock("skill({ name: \"skill-name\" })")}
223
+
224
+ To read a specific file within a skill (scripts, references, assets):
225
+ ${codeBlock("skill({ name: \"skill-name\", file: \"relative/path/to/file\" })")}
226
+
227
+ Examples:
228
+ - ${codeFragment("skill({ name: \"create-plan\" })")} - Read the create-plan skill's SKILL.md instructions
229
+ - ${codeFragment("skill({ name: \"web-artifacts-builder\", file: \"scripts/init-artifact.sh\" })")} - Read a specific script
230
+
231
+ ## When to Use Skills
232
+
233
+ 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.
234
+
235
+ **Skill Selection Guidelines:**
236
+ - Match the task to available skill descriptions
237
+ - Multiple skills may be relevant - read all that apply
238
+ - Read the skill first, then follow its instructions
239
+
240
+ ## Available Skills
241
+ $$AVAILABLE_SKILLS$$
242
+
243
+ ## Important Notes
244
+
245
+ - Always read the skill BEFORE starting implementation
246
+ - Skills may contain scripts that can be executed directly without loading into context
247
+ - Multiple skills can and should be combined when tasks span multiple domains
248
+ - If a skill references additional files (references/, scripts/, assets/), read those as needed during execution
249
+ `
250
+
251
+ export default {
252
+ order: 15 - 100,
253
+
254
+ install(ctx) {
255
+ ext = ctx.scope("skills")
256
+
257
+ ctx.components({ SkillSelector })
258
+
259
+ 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>`
260
+
261
+ ctx.setTopIcons({
262
+ skills: {
263
+ component: {
264
+ template: svg([
265
+ `@click="$ctx.toggleTop('SkillSelector')"`,
266
+ `:class="$prefs.onlySkills == null ? 'text-green-600 dark:text-green-300' : $prefs.onlySkills.length ? 'text-blue-600! dark:text-blue-300!' : ''"`
267
+ ].join(' ')),
268
+ },
269
+ isActive({ top }) {
270
+ return top === 'SkillSelector'
271
+ },
272
+ get title() {
273
+ return ctx.prefs.onlySkills == null
274
+ ? `All Skills Included`
275
+ : ctx.prefs.onlySkills.length
276
+ ? `${ctx.prefs.onlySkills.length} ${ctx.utils.pluralize('Skill', ctx.prefs.onlySkills.length)} Included`
277
+ : 'No Skills Included'
278
+ }
279
+ }
280
+ })
281
+
282
+ ctx.chatRequestFilters.push(({ request, thread, context }) => {
283
+
284
+ const prefs = ctx.prefs
285
+ if (prefs.onlySkills != null) {
286
+ if (Array.isArray(prefs.onlySkills)) {
287
+ request.metadata.skills = prefs.onlySkills.length > 0
288
+ ? prefs.onlySkills.join(',')
289
+ : 'none'
290
+ }
291
+ } else {
292
+ request.metadata.skills = 'all'
293
+ }
294
+
295
+ console.log('skills.chatRequestFilters', prefs.onlySkills, Object.keys(ctx.state.skills || {}))
296
+ const skills = ctx.state.skills
297
+ if (!skills) return
298
+
299
+ const includeSkills = []
300
+ for (const skill of Object.values(skills)) {
301
+ if (prefs.onlySkills == null || prefs.onlySkills.includes(skill.name)) {
302
+ includeSkills.push(skill)
303
+ }
304
+ }
305
+ if (!includeSkills.length) return
306
+
307
+ const sb = []
308
+ sb.push("<available_skills>")
309
+ for (const skill of includeSkills) {
310
+ sb.push(" <skill>")
311
+ sb.push(" <name>" + ctx.utils.encodeHtml(skill.name) + "</name>")
312
+ sb.push(" <description>" + ctx.utils.encodeHtml(skill.description) + "</description>")
313
+ sb.push(" <location>" + ctx.utils.encodeHtml(skill.location) + "</location>")
314
+ sb.push(" </skill>")
315
+ }
316
+ sb.push("</available_skills>")
317
+
318
+ const skillsPrompt = SkillInstructions.replace('$$AVAILABLE_SKILLS$$', sb.join('\n')).trim()
319
+ context.requiredSystemPrompts.push(skillsPrompt)
320
+ })
321
+
322
+ ctx.setState({
323
+ skills: {}
324
+ })
325
+ },
326
+
327
+ async load(ctx) {
328
+ const api = await ext.getJson('/')
329
+ if (api.response) {
330
+ ctx.setState({ skills: api.response })
331
+ } else {
332
+ ctx.setError(api.error)
333
+ }
334
+ }
335
+ }
@@ -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
 
@@ -656,7 +656,7 @@ export default {
656
656
  }
657
657
  })
658
658
 
659
- ctx.chatRequestFilters.push(({ request, thread }) => {
659
+ ctx.chatRequestFilters.push(({ request, thread, context }) => {
660
660
  // Tool Preferences
661
661
  const prefs = ctx.prefs
662
662
  if (prefs.onlyTools != null) {