Skip to content

armgit / SOMA

Public Imported from GitHub
0

Desktop app for designing parametric 3D models in CadQuery together with the coding agent of your choice

App: Einstellungen für Skills (E17)

Kai-Jungsthoefelb00849c667e3
diff --git a/app/resources/skills/3d-druck.md b/app/resources/skills/3d-druck.md
index b162f0b..f16b93f 100644
--- a/app/resources/skills/3d-druck.md
+++ b/app/resources/skills/3d-druck.md
@@ -1,43 +1,68 @@
---
title: 3D-Druck (FDM)
name: 3D printing (FDM)
-summary: Druckbare Wandstärken, Überhänge bis 45°, Spiel für Passungen, Ausrichtung auf dem Druckbett, Gewinde über Einschmelzmuttern.
+summary: Druckbare Wandstärken, Überhänge bis {{overhang}}°, Spiel für Passungen, Ausrichtung auf dem Druckbett, Gewinde über Einschmelzmuttern.
order: 10
-topics: Wände und kleine Details; Überhänge und Brücken; Ausrichtung und Bauraum; Spiel und Passungen; Schrauben und Gewinde; Export als STL oder 3MF
+topics: Drucker und Material; Wände und kleine Details; Überhänge und Brücken; Ausrichtung und Bauraum; Spiel und Passungen; Schrauben und Gewinde; Export als STL oder 3MF
+var material: PLA | | Material | PLA, PETG, ABS, ASA, TPU
+var nozzle: 0.4 | mm | Düse | 0.1..1.2
+var layer: 0.2 | mm | Schichthöhe | 0.04..0.8
+var bed_x: 220 | mm | Bauraum X | 30..2000
+var bed_y: 220 | mm | Bauraum Y | 30..2000
+var bed_z: 250 | mm | Bauraum Z | 30..2000
+var overhang: 45 | ° | Max. Überhangwinkel | 10..85
+var bridge: 10 | mm | Max. Brücke ohne Stütze | 0..200
+var min_wall: 1.2 | mm | Mindestwand | 0.2..20
+var clearance: 0.3 | mm | Spiel je Seite (Gleitpassung) | 0..3
---
# Skill: 3D printing (FDM)
-The parts will be printed on a filament printer (FDM). Unless `NOTES.md` or the user says otherwise, assume a 0.4 mm
-nozzle, 0.2 mm layers, PLA or PETG and a build volume of 220 × 220 × 250 mm. Put these assumptions into named constants
-at the top of `model.py` (`NOZZLE = 0.4`, `CLEARANCE = 0.3`, `BED = (220, 220, 250)`) so the user can change them.
+The parts will be printed on a filament printer (FDM). The user set these values in the app, they are binding unless
+the user says otherwise in the chat or in `NOTES.md`:
+
+| Setting | Value |
+|---|---|
+| Material | {{material}} |
+| Nozzle | {{nozzle}} mm |
+| Layer height | {{layer}} mm |
+| Build volume | {{bed_x}} × {{bed_y}} × {{bed_z}} mm |
+| Max. overhang without support | {{overhang}}° from vertical |
+| Max. bridge without support | {{bridge}} mm |
+| Minimum wall | {{min_wall}} mm |
+| Clearance per side for sliding fits | {{clearance}} mm |
+
+Put them into named constants at the top of `model.py` (`NOZZLE = {{nozzle}}`, `CLEARANCE = {{clearance}}`,
+`MAX_OVERHANG = {{overhang}}`, `BED = ({{bed_x}}, {{bed_y}}, {{bed_z}})`) and use the constants, not the numbers.
## Walls and small features
-- Walls at least 1.2 mm (three lines of 0.4 mm), 2 mm or more where the part carries load or holds screws. Prefer
- multiples of the line width (0.8, 1.2, 1.6, 2.0 mm).
-- No feature thinner than 0.8 mm, no gap narrower than 0.5 mm, no pin thinner than 2 mm.
-- Embossed or engraved text: at least 0.6 mm high or deep, letters at least 5 mm tall.
+- Walls at least {{min_wall}} mm, more where the part carries load or holds screws. Prefer multiples of the nozzle width
+ ({{nozzle}} mm).
+- No feature thinner than two nozzle widths, no gap narrower than 0.5 mm, no pin thinner than 2 mm.
+- Embossed or engraved text: at least three layers high or deep, letters at least 5 mm tall.
## Overhangs and bridges
-- Overhangs up to 45° from vertical print without support. Avoid shapes that need support, or say clearly where they do.
-- Bridges (flat ceilings between two walls) up to about 10 mm are fine.
-- Horizontal holes larger than about 8 mm: give them a pointed (teardrop) or flat top instead of a round one.
+- Overhangs up to {{overhang}}° from vertical (0° is a vertical wall, 90° a flat ceiling) print without support. Avoid
+ shapes that need support, or say clearly where they do.
+- Bridges (flat ceilings between two walls) up to {{bridge}} mm are fine.
+- Horizontal holes whose top would overhang more than {{overhang}}°: give them a pointed (teardrop) or flat top instead
+ of a round one.
- Edges on the print bed: chamfer them (0.5 to 1 mm) instead of filleting. A fillet there becomes an overhang.
## Orientation and size
- Design each part with its largest flat face on the bed and say which orientation you assume.
- Layers are the weak direction. Loads should run along the layers, not pull them apart. Snap hooks and clips lie flat.
-- If a part does not fit the build volume, split it into pieces that do (with alignment pins or a lap joint) and register
- every piece with `add_part`.
+- If a part does not fit the build volume of {{bed_x}} × {{bed_y}} × {{bed_z}} mm, split it into pieces that do (with
+ alignment pins or a lap joint) and register every piece with `add_part`.
- One `add_part` per printed body. Do not merge parts that are printed separately.
## Fits and clearances
-- Parts that slide or turn in each other: 0.3 mm clearance per side. Loose fit 0.4 mm. Press fit 0.1 mm or less,
- suggest a small test print first.
-- Lids, drawers and sliding parts: 0.3 to 0.5 mm gap on every side.
+- Parts that slide or turn in each other: {{clearance}} mm clearance per side. Loose fit: add 0.1 mm. Press fit: 0.1 mm
+ or less, suggest a small test print first.
+- Lids, drawers and sliding parts: at least {{clearance}} mm gap on every side.
- Printed holes come out about 0.1 to 0.2 mm smaller than modeled. Model screw holes 0.2 mm larger than the nominal
clearance hole.
- Every clearance is a named constant. Mating faces never touch with zero gap.
diff --git a/app/resources/skills/gehaeuse.md b/app/resources/skills/gehaeuse.md
index cc03752..aeb8091 100644
--- a/app/resources/skills/gehaeuse.md
+++ b/app/resources/skills/gehaeuse.md
@@ -1,9 +1,18 @@
---
title: Gehäusebau
name: Enclosure design
-summary: Gehäuse um eine Platine oder ein Gerät: Wand und Deckel mit Falz, Abstand zur Referenz, Dome für Schrauben, Ausschnitte, Belüftung.
+summary: Gehäuse um eine Platine oder ein Gerät: Wand {{wall}} mm, Deckel mit Falz, Abstand zur Referenz, Dome für {{screw}}-Schrauben, Ausschnitte, Belüftung.
order: 30
-topics: Aufbau aus Unterteil, Deckel und Referenz; Startwerte für Wand, Boden und Abstand; Dome für die Platine; Ausschnitte, Belüftung, Kabel; Prüfungen vor dem Abschluss
+topics: Aufbau aus Unterteil, Deckel und Referenz; Maße für Wand, Boden und Abstand; Dome für die Platine; Ausschnitte, Belüftung, Kabel; Prüfungen vor dem Abschluss
+var wall: 2 | mm | Wandstärke | 0.5..20
+var floor: 2 | mm | Boden und Deckel | 0.5..20
+var gap: 1 | mm | Abstand zur Referenz | 0..50
+var headroom: 2 | mm | Luft über dem höchsten Bauteil | 0..100
+var lid: lip | | Deckel | lip=mit Falz, screwed=flach und verschraubt
+var lid_clearance: 0.25 | mm | Spiel Deckel zu Unterteil je Seite | 0..2
+var screw: M3 | | Schrauben | M2, M2.5, M3, M4, M5
+var edge_radius: 1.5 | mm | Außenkanten gerundet | 0..20
+var opening_clearance: 0.5 | mm | Spiel an Ausschnitten je Seite | 0..5
---
# Skill: Enclosure design
@@ -17,26 +26,30 @@ Build enclosures around a circuit board or another part the user brought.
export it.
- Derive positions from the reference instead of typing numbers: `asm.toCompound().BoundingBox()` for an assembly,
`shape.val().BoundingBox()` for a single shape. Write the key dimensions of the reference into `NOTES.md`.
-- Constants at the top: `WALL`, `FLOOR`, `LID`, `GAP` (reference to wall), `CLEARANCE` (lid to base), the screw size.
+- Constants at the top: `WALL = {{wall}}`, `FLOOR = {{floor}}`, `GAP = {{gap}}` (reference to wall),
+ `HEADROOM = {{headroom}}`, `LID_CLEARANCE = {{lid_clearance}}`, `SCREW = "{{screw}}"`.
-## Starting values
+## Dimensions
-Change them when the user or another active skill says otherwise.
+The user set these values in the app. They apply unless the user says otherwise in the chat or in `NOTES.md`.
-- Wall 2 mm, floor and lid 2 mm. Inner corner radius at least the wall thickness, outer edges rounded 1 to 2 mm.
-- At least 1 mm between the reference and every inner wall, 2 mm above the tallest component.
-- Lid with a lip 1.5 to 2 mm high that reaches into the base, 0.2 to 0.3 mm clearance per side. Or a flat lid on screws.
+- Wall {{wall}} mm, floor and lid {{floor}} mm. Inner corner radius at least the wall thickness, outer edges rounded
+ {{edge_radius}} mm.
+- At least {{gap}} mm between the reference and every inner wall, {{headroom}} mm above the tallest component.
+- Lid style: **{{lid}}**. "lip": the lid has a lip 1.5 to 2 mm high that reaches into the base. "screwed": a flat lid
+ held by screws into the standoffs or extra bosses in the corners. Either way {{lid_clearance}} mm clearance per side
+ between lid and base.
## Mounting the board
-- Standoffs under the mounting holes of the board: outer Ø about 2.2 × the screw size, hole for a heat-set insert or a
- tap drill, high enough that the lowest component on the underside clears the floor by 1 mm.
+- Standoffs under the mounting holes of the board for {{screw}} screws: outer Ø about 2.2 × the screw size, hole for a
+ heat-set insert or a tap drill, high enough that the lowest component on the underside clears the floor by 1 mm.
- The hole positions must match the reference exactly. Take them from the reference and check them with a measurement.
## Openings
-- Cutouts for connectors, buttons, LEDs and displays come from the position of the part in the reference, plus 0.5 mm
- clearance per side (1 mm for plugs with molded housings).
+- Cutouts for connectors, buttons, LEDs and displays come from the position of the part in the reference, plus
+ {{opening_clearance}} mm clearance per side (more for plugs with molded housings).
- Ventilation: slots 1.5 to 2 mm wide with webs of at least 2 mm, not where liquid could drip in.
- Cable entry: a hole or slot with rounded edges, optionally with a strain relief.
diff --git a/app/resources/skills/toleranzen.md b/app/resources/skills/toleranzen.md
index 657ce89..d717618 100644
--- a/app/resources/skills/toleranzen.md
+++ b/app/resources/skills/toleranzen.md
@@ -3,7 +3,11 @@ title: Toleranzen und Passungen
name: Tolerances and fits
summary: Spiel als benannte Konstanten, Kollisionsprüfung im Code, Durchgangs- und Kernlöcher, Senkungen für Zylinderschrauben, ISO-Passungen.
order: 20
-topics: Spiel als benannte Konstanten; Kollisionen und Abstände im Code prüfen; Durchgangs- und Kernlöcher (ISO 273); Senkungen für Zylinderschrauben; ISO-Passungen für gefertigte Teile; Laser- und Blechteile
+topics: Fertigung: {{process}}; Spiel als benannte Konstanten; Kollisionen und Abstände im Code prüfen; Durchgangslöcher ({{hole_fit}}) und Kernlöcher; Senkungen für Zylinderschrauben; ISO-Passungen für gefertigte Teile; Laser- und Blechteile
+var process: unknown | | Fertigung | unknown=noch offen (Agent fragt), 3D printing=3D-Druck, CNC milling=CNC-Fräsen, laser cutting=Laserschneiden, sheet metal=Blech
+var hole_fit: medium | | Durchgangslöcher nach ISO 273 | fine=fein, medium=mittel, coarse=grob
+var min_gap: 0.2 | mm | Mindestabstand zwischen Teilen | 0..5
+var kerf: 0.15 | mm | Spiel für Laserteile je Seite | 0..1
---
# Skill: Tolerances and fits
@@ -11,11 +15,12 @@ Every real part deviates from its nominal size. Design so that parts still fit w
## General rules
-- If `NOTES.md` does not say how the parts are made (3D printing, CNC milling, laser cutting, sheet metal), ask. The
- clearances depend on it.
+- Manufacturing process set by the user in the app: **{{process}}**. If it is "unknown" and `NOTES.md` does not say how
+ the parts are made (3D printing, CNC milling, laser cutting, sheet metal), ask. The clearances depend on it.
- Put every clearance, fit and allowance into a named constant at the top of `model.py` (`SCREW_CLEARANCE`, `LID_GAP`).
Never hide them in expressions.
- Mating faces never share the exact same coordinate: leave a defined gap, or a defined overlap for a press fit.
+- Parts that must not touch keep at least {{min_gap}} mm distance (`MIN_GAP = {{min_gap}}`).
- Dimension from the functional faces: a hole follows the part it has to meet, not an arbitrary outer edge.
- After building, check the critical gaps (measure them or compute them, see below) and tell the user the values.
@@ -23,15 +28,15 @@ Every real part deviates from its nominal size. Design so that parts still fit w
- Interference: `a.intersect(b).val().Volume()` must be (close to) 0 for parts that must not touch, and for a part and
a reference (`role="reference"`).
-- Smallest gap between two shapes in mm: `a.val().distance(b.val())`.
+- Smallest gap between two shapes in mm: `a.val().distance(b.val())`, at least {{min_gap}} mm.
- Print such checks only while you work on them and remove the debug output afterwards.
## Holes for metric screws
-Clearance holes after ISO 273 and tap drills (core holes) for coarse threads, in mm. Use "medium" unless the user wants
-otherwise. For printed parts the 3D printing skill adds to these values.
+Clearance holes after ISO 273 and tap drills (core holes) for coarse threads, in mm. The user chose the **{{hole_fit}}**
+column. For printed parts the 3D printing skill adds to these values.
-| Thread | Close | Medium | Free | Tap drill |
+| Thread | Fine | Medium | Coarse | Tap drill |
|---|---|---|---|---|
| M2 | 2.2 | 2.4 | 2.6 | 1.6 |
| M2.5 | 2.7 | 2.9 | 3.1 | 2.05 |
@@ -67,4 +72,4 @@ In CadQuery: `.cboreHole(diameter, cboreDiameter, cboreDepth)`. Countersunk scre
## Laser-cut and sheet parts
-- Slots and tabs: 0.1 to 0.2 mm clearance per side, depending on the kerf. Keep the material thickness as a constant.
+- Slots and tabs: {{kerf}} mm clearance per side (`KERF_CLEARANCE = {{kerf}}`). Keep the material thickness as a constant.
diff --git a/app/resources/template/AGENTS.md b/app/resources/template/AGENTS.md
index bf23e73..92379ba 100644
--- a/app/resources/template/AGENTS.md
+++ b/app/resources/template/AGENTS.md
@@ -59,7 +59,7 @@ The app pastes short notes into your input. The user adds their own words and se
- `[Markierung: .soma/feedback/markierung-20260930-1405.png]`: a picture of the 3D view (or a blank sketch) with the user's drawings: arrows, circles, handwritten text, often with dimensions. **Open the image file and look at it**, compare it with the model, then change the code. If the note says `zeigt den älteren Stand <hash>`, the picture shows that older commit, not the current code (`git show <hash>:model.py`). Leave the images where they are.
- `[Auswahl: Bauteil "…", model.py Zeile …]`: the part the user clicked, with the lines of its `add_part` call and the clicked face.
- `[Build-Fehler: …]`: the message of the last failed build.
-- `[Skill: .soma/skills/<name>.md]`: the user switched on this rule set. Read the file now and follow it from here on. When the user switches a skill off, it disappears from the list below: stop applying it.
+- `[Skill: .soma/skills/<name>.md]`: the user switched on this rule set or changed its settings (the note may list them, they are already written into the file). Read the file again now and follow it from here on. When the user switches a skill off, it disappears from the list below: stop applying it.
The user can also edit files directly in the app's editor. Read a file again right before you change it, do not rely on an older copy.
diff --git a/app/src/main/main.ts b/app/src/main/main.ts
index 85affcb..dcf8c25 100644
--- a/app/src/main/main.ts
+++ b/app/src/main/main.ts
@@ -79,6 +79,7 @@ function registerIpc(ctl: ProjectController): void {
ipcMain.handle('measure:query', (_e, source: unknown, req: unknown) => ctl.measure(source, req));
ipcMain.handle('skills:list', () => ctl.skills());
ipcMain.handle('skills:set', (_e, id: unknown, on: unknown) => ctl.setSkill(id, !!on));
+ ipcMain.handle('skills:configure', (_e, id: unknown, values: unknown) => ctl.configureSkill(id, values));
// Rückfragen aus dem Renderer (etwa ungespeicherte Eingaben im Editor) laufen über dieselben Dialoge wie im Hauptprozess
ipcMain.handle('dialog:choose', (_e, o: { title?: unknown; message?: unknown; detail?: unknown; buttons?: unknown }) => {
const buttons = Array.isArray(o?.buttons) ? o.buttons.slice(0, 4).map(String) : [];
diff --git a/app/src/main/projects.ts b/app/src/main/projects.ts
index 3cc3d9c..ff4cee1 100644
--- a/app/src/main/projects.ts
+++ b/app/src/main/projects.ts
@@ -7,12 +7,12 @@ import { choose, choosePath } from './dialogs';
import { GitRepo } from './git';
import { MeasureService } from './measure';
import { previewsDir, skillBackupsDir, skillsDir } from './paths';
-import { copySkill, isSkillId, listSkills, removeSkill, skillName, writeAgentsList } from './skills';
+import { bundledSkill, checkValue, cleanValues, copySkill, isSkillId, listSkills, removeSkill, skillName, writeAgentsList, type SkillValues } from './skills';
import { TerminalManager } from './terminals';
import { watchProject } from './watcher';
import {
backupWorkspace, createProject, extractProject, getAppState, inspectProject, isProjectId, patchAppState, projectDir,
- readProjectJson, renameProject, setLastProject, setProjectSkills,
+ readProjectJson, renameProject, setLastProject, updateProjectSkills,
} from './workspace';
import { readZipTexts, saveProjectZip, ZIP_INFO_PATH, type ZipInfo } from './zip';
@@ -346,7 +346,13 @@ export class ProjectController {
skills(): SkillInfo[] {
const s = this.need();
- return listSkills(s.dir, skillsDir(), this.activeSkills(s.id));
+ return listSkills(s.dir, skillsDir(), this.activeSkills(s.id), readProjectJson(s.id)?.skill_settings ?? null);
+ }
+
+ /** Gültige, vom Standard abweichende Werte eines Skills laut project.json. */
+ private skillValues(id: string, skill: string): SkillValues {
+ const b = bundledSkill(skillsDir(), skill);
+ return b ? cleanValues(b.vars, readProjectJson(id)?.skill_settings?.[skill]) : {};
}
/**
@@ -360,9 +366,10 @@ export class ProjectController {
if (!isSkillId(skill)) return { ok: false, error: 'Unbekannter Skill.', skills: list() };
if (!active) return { ok: false, error: '.soma/project.json fehlt oder ist unlesbar. Ohne sie lässt sich kein Skill ein- oder ausschalten.', skills: list() };
try {
- const backup = on ? copySkill(s.dir, skillsDir(), skill, skillBackupsDir(s.id)) : removeSkill(s.dir, skillsDir(), skill, skillBackupsDir(s.id));
+ const values = this.skillValues(s.id, skill);
+ const backup = on ? copySkill(s.dir, skillsDir(), skill, skillBackupsDir(s.id), values) : removeSkill(s.dir, skillsDir(), skill, skillBackupsDir(s.id), values);
const next = on ? [...new Set([...active, skill])] : active.filter((x) => x !== skill);
- setProjectSkills(s.id, next);
+ updateProjectSkills(s.id, { skills: next });
const warning = writeAgentsList(s.dir, next.map((id) => ({ id, name: skillName(s.dir, skillsDir(), id) })));
return { ok: true, backup, ...(warning ? { warning } : {}), skills: list() };
} catch (e) {
@@ -370,6 +377,38 @@ export class ProjectController {
}
}
+ /**
+ * Einstellungen eines Skills ändern (null: zurück zum Standard). Erst alles prüfen, dann speichern. Ist der Skill an,
+ * wird seine Kopie mit den neuen Werten geschrieben (von Hand Geändertes vorher in die Sicherung).
+ */
+ configureSkill(skill: unknown, values: unknown): SkillResult {
+ const s = this.need();
+ const list = () => this.skills();
+ const b = isSkillId(skill) ? bundledSkill(skillsDir(), skill) : undefined;
+ if (!isSkillId(skill) || !b) return { ok: false, error: 'Diesen Skill bringt die App nicht mit, er lässt sich nicht einstellen.', skills: list() };
+ const pj = readProjectJson(s.id);
+ if (!pj) return { ok: false, error: '.soma/project.json fehlt oder ist unlesbar. Ohne sie lässt sich nichts einstellen.', skills: list() };
+ if (!values || typeof values !== 'object') return { ok: false, error: 'Keine Werte.', skills: list() };
+ const prev = this.skillValues(s.id, skill);
+ const next: SkillValues = { ...prev };
+ for (const [name, raw] of Object.entries(values as Record<string, unknown>)) {
+ const v = b.vars.find((x) => x.name === name);
+ if (!v) return { ok: false, error: `Der Skill hat keine Einstellung „${name}“.`, skills: list() };
+ if (raw === null) { delete next[name]; continue; }
+ const r = checkValue(v, raw);
+ if ('error' in r) return { ok: false, error: r.error, skills: list() };
+ if (r.value === v.default) delete next[name]; else next[name] = r.value;
+ }
+ try {
+ updateProjectSkills(s.id, { skill_settings: { ...(pj.skill_settings ?? {}), [skill]: next } });
+ const active = Array.isArray(pj.skills) && pj.skills.includes(skill);
+ const backup = active ? copySkill(s.dir, skillsDir(), skill, skillBackupsDir(s.id), next, prev) : null;
+ return { ok: true, backup, skills: list() };
+ } catch (e) {
+ return { ok: false, error: e instanceof Error ? e.message : String(e), skills: list() };
+ }
+ }
+
async confirmClose(editor: { dirty: string[]; save(): Promise<boolean>; discard(): Promise<void> }): Promise<boolean> {
if (!this.session || process.env.SOMA_TEST === '1') return true;
const st = await this.saveState();
diff --git a/app/src/main/skills.ts b/app/src/main/skills.ts
index c65c81f..8781cac 100644
--- a/app/src/main/skills.ts
+++ b/app/src/main/skills.ts
@@ -1,13 +1,17 @@
import fs from 'node:fs';
import path from 'node:path';
-import type { SkillInfo } from '../shared/types';
+import type { SkillInfo, SkillValue, SkillVar } from '../shared/types';
import { backupText, resolveInside } from './files';
/**
* Skills (E17): Regelwerke als Markdown, die der Nutzer pro Modell zuschaltet. Die App liefert sie mit
* (`resources/skills/`). Ein aktivierter Skill wird nach `.soma/skills/<id>.md` kopiert, steht in `project.json` und wird
* in einem eigenen Abschnitt der `AGENTS.md` aufgeführt. So wandert er mit ZIP und Git und gilt für jeden Agenten.
- * Die Kopie im Projekt bleibt, wie sie ist, auch wenn eine neuere App eine neuere Fassung mitbringt.
+ *
+ * Einstellungen: Ein Skill kann im Kopf Variablen erklären (`var overhang: 45 | ° | Max. Überhang | 20..80`) und im Text
+ * Platzhalter verwenden (`{{overhang}}`). Der Nutzer stellt die Werte im Panel ein, sie stehen in `project.json`
+ * (`skill_settings`). Die Kopie im Projekt enthält die eingesetzten Werte: Der Agent liest konkrete Zahlen.
+ * Die Kopie bleibt, wie sie ist, auch wenn eine neuere App eine neuere Fassung mitbringt.
*/
/** Kennung = Dateiname ohne .md. Nur Kleinbuchstaben, Ziffern und Bindestrich: Sie landet in Pfaden und in AGENTS.md. */
@@ -17,23 +21,54 @@ export const SKILLS_DIR = '.soma/skills';
const BEGIN = '<!-- soma:skills -->';
const END = '<!-- /soma:skills -->';
const MAX_BYTES = 256 * 1024;
+const VAR_LINE = /^var\s+([a-z][a-z0-9_]{0,30}):\s*(.*)$/;
+const PLACEHOLDER = /\{\{\s*([a-z][a-z0-9_]{0,30})\s*\}\}/g;
-interface Parsed { id: string; title: string; name: string; summary: string; order: number; topics: string[]; text: string }
+/** Eingestellte Werte eines Skills, nur die vom Standard abweichenden. */
+export type SkillValues = Record<string, SkillValue>;
+/** Kopf einer Variablen ohne aktuellen Wert. */
+type VarDef = Omit<SkillVar, 'value'>;
+interface Parsed { id: string; title: string; name: string; summary: string; order: number; topics: string[]; vars: VarDef[]; text: string }
/** Zeilenenden vereinheitlichen: Eine Kopie mit CRLF (etwa nach einem Git-Checkout) gilt nicht als geändert. */
const norm = (t: string) => t.replace(/\r\n?/g, '\n');
+const FRONT = /^---\n([\s\S]*?)\n---\n?/;
+
+/**
+ * Variable aus dem Kopf: `Standard | Einheit | Bezeichnung | Bereich oder Auswahl`. Ein Bereich `20..80` macht eine Zahl,
+ * eine Liste `PLA, PETG` eine Auswahl, Einträge mit `wert=Anzeige` zeigen in der Oberfläche einen deutschen Namen.
+ */
+function parseVar(name: string, spec: string): VarDef | null {
+ const [def = '', unit = '', label = '', rule = ''] = spec.split('|').map((x) => x.trim());
+ if (!def) return null;
+ const range = /^(-?\d+(?:\.\d+)?)\s*\.\.\s*(-?\d+(?:\.\d+)?)$/.exec(rule);
+ if (rule.includes(',') || (!range && !Number.isFinite(Number(def)))) {
+ const options = (rule ? rule.split(',') : [def]).map((o) => o.trim()).filter(Boolean).map((o) => {
+ const [value, shown] = o.split('=').map((x) => x.trim());
+ return { value, label: shown || value };
+ });
+ if (!options.some((o) => o.value === def)) options.unshift({ value: def, label: def });
+ return { name, label: label || name, unit, kind: 'choice', default: def, options };
+ }
+ const d = Number(def);
+ if (!Number.isFinite(d)) return null;
+ return { name, label: label || name, unit, kind: 'number', default: d, ...(range ? { min: Number(range[1]), max: Number(range[2]) } : {}) };
+}
/**
* Liest Kopf und Inhalt. Der Kopf steht zwischen zwei `---`-Zeilen als `schlüssel: wert` (title, summary und topics für
- * die Oberfläche auf Deutsch, name auf Englisch für AGENTS.md). Fehlt er, gilt die erste Überschrift als Titel.
+ * die Oberfläche auf Deutsch, name auf Englisch für AGENTS.md, var für Einstellungen). Fehlt er, gilt die erste Überschrift als Titel.
*/
export function parseSkill(id: string, raw: string): Parsed {
const text = norm(raw);
const meta: Record<string, string> = {};
+ const vars: VarDef[] = [];
let body = text;
- const m = /^---\n([\s\S]*?)\n---\n?/.exec(text);
+ const m = FRONT.exec(text);
if (m) {
for (const line of m[1].split('\n')) {
+ const v = VAR_LINE.exec(line.trim());
+ if (v) { const d = parseVar(v[1], v[2]); if (d && !vars.some((x) => x.name === d.name)) vars.push(d); continue; }
const kv = /^([a-z_]+):\s*(.*)$/.exec(line.trim());
if (kv) meta[kv[1]] = kv[2].trim();
}
@@ -44,7 +79,7 @@ export function parseSkill(id: string, raw: string): Parsed {
const topics = (meta.topics ? meta.topics.split(';') : [...body.matchAll(/^##\s+(.+)$/gm)].map((x) => x[1]))
.map((x) => x.trim()).filter(Boolean).slice(0, 12);
return {
- id, text: raw,
+ id, text: raw, vars,
title: meta.title || heading || id,
name: meta.name || heading || meta.title || id,
summary: meta.summary ?? '',
@@ -53,6 +88,75 @@ export function parseSkill(id: string, raw: string): Parsed {
};
}
+/** Zahl für den Agenten: Punkt als Dezimalzeichen, ohne Rundungsreste. */
+const agentNum = (v: number) => String(+v.toFixed(6));
+const showNum = (v: number) => v.toLocaleString('de-DE', { maximumFractionDigits: 6 });
+
+/**
+ * Prüft einen Wert gegen seine Variable. Zahlen dürfen als Text mit Komma kommen. Rückgabe: der saubere Wert oder ein
+ * Fehlertext für die Oberfläche.
+ */
+export function checkValue(v: VarDef, input: unknown): { value: SkillValue } | { error: string } {
+ if (v.kind === 'choice') {
+ const s = typeof input === 'string' ? input.trim() : '';
+ return v.options!.some((o) => o.value === s) ? { value: s } : { error: `${v.label}: „${String(input)}“ steht nicht zur Auswahl.` };
+ }
+ const n = typeof input === 'number' ? input : typeof input === 'string' ? Number(input.trim().replace('−', '-').replace(',', '.')) : NaN;
+ if (typeof input === 'string' && !input.trim()) return { error: `${v.label}: Bitte eine Zahl eingeben.` };
+ if (!Number.isFinite(n)) return { error: `${v.label}: „${String(input)}“ ist keine Zahl.` };
+ const unit = v.unit ? (v.unit === '°' ? '°' : ` ${v.unit}`) : '';
+ if ((v.min != null && n < v.min) || (v.max != null && n > v.max)) {
+ return { error: `${v.label}: erlaubt sind ${showNum(v.min ?? -Infinity)} bis ${showNum(v.max ?? Infinity)}${unit}.` };
+ }
+ return { value: +n.toFixed(6) };
+}
+
+/** Gespeicherte Werte (aus project.json, nicht vertrauenswürdig) auf gültige, vom Standard abweichende beschränken. */
+export function cleanValues(vars: VarDef[], stored: unknown): SkillValues {
+ const out: SkillValues = {};
+ if (!stored || typeof stored !== 'object') return out;
+ for (const v of vars) {
+ const raw = (stored as Record<string, unknown>)[v.name];
+ if (raw === undefined) continue;
+ const r = checkValue(v, raw);
+ if ('value' in r && r.value !== v.default) out[v.name] = r.value;
+ }
+ return out;
+}
+
+const effective = (vars: VarDef[], values: SkillValues): Record<string, SkillValue> =>
+ Object.fromEntries(vars.map((v) => [v.name, values[v.name] ?? v.default]));
+
+/**
+ * Skill mit eingesetzten Werten, so wie er ins Projekt kommt: Platzhalter im Text ersetzt, im Kopf stehen die Werte statt
+ * der Standardwerte (die Kopie ist in sich stimmig, auch für einen Agenten, der den Kopf liest).
+ */
+export function renderSkill(raw: string, values: SkillValues): string {
+ const text = norm(raw);
+ const p = parseSkill('', text);
+ const map = effective(p.vars, values);
+ const put = (s: string) => s.replace(PLACEHOLDER, (all, name: string) => (name in map ? (typeof map[name] === 'number' ? agentNum(map[name] as number) : String(map[name])) : all));
+ const m = FRONT.exec(text);
+ if (!m) return put(text);
+ const head = m[0].replace(/^(var\s+([a-z][a-z0-9_]*):\s*)([^|\n]*)/gm, (all, pre: string, name: string, cur: string) => {
+ if (!(name in map)) return all;
+ const v = map[name];
+ return pre + cur.replace(cur.trim(), typeof v === 'number' ? agentNum(v) : v);
+ });
+ return put(head) + put(text.slice(m[0].length));
+}
+
+/** Text der Oberfläche (Kurzbeschreibung, Themen) mit eingesetzten Werten, Zahlen mit Komma. */
+function showText(s: string, vars: VarDef[], values: SkillValues): string {
+ const map = effective(vars, values);
+ return s.replace(PLACEHOLDER, (all, name: string) => {
+ const v = vars.find((x) => x.name === name);
+ if (!v) return all;
+ const val = map[name];
+ return typeof val === 'number' ? showNum(val) : v.options?.find((o) => o.value === val)?.label ?? String(val);
+ });
+}
+
function readSkillFile(file: string): string | null {
try {
if (fs.statSync(file).size > MAX_BYTES) return null;
@@ -74,6 +178,8 @@ export function bundledSkills(dir: string): Map<string, Parsed> {
return out;
}
+export const bundledSkill = (dir: string, id: string): Parsed | undefined => bundledSkills(dir).get(id);
+
const relOf = (id: string) => `${SKILLS_DIR}/${id}.md`;
/** Kopie im Projekt, sofern lesbar. Der Pfad geht durch resolveInside: Ein Verweis nach außen wird nicht gelesen. */
@@ -93,9 +199,9 @@ function agentsList(text: string): string {
/**
* Alle Skills für die Oberfläche: die mitgelieferten und solche, die nur im Projekt liegen (etwa aus einer neueren App).
- * `active` stammt aus project.json (null: unlesbar). Auffälligkeiten werden gemeldet, nicht behoben (E28).
+ * `active` und `settings` stammen aus project.json (active null: unlesbar). Auffälligkeiten werden gemeldet, nicht behoben (E28).
*/
-export function listSkills(root: string, bundledDir: string, active: string[] | null): SkillInfo[] {
+export function listSkills(root: string, bundledDir: string, active: string[] | null, settings: unknown): SkillInfo[] {
const bundled = bundledSkills(bundledDir);
const on = new Set((active ?? []).filter(isSkillId));
let files: string[] = [];
@@ -108,10 +214,14 @@ export function listSkills(root: string, bundledDir: string, active: string[] |
const copy = projectCopy(root, id);
const meta = b ?? (copy != null ? parseSkill(id, copy) : null);
const isOn = on.has(id);
+ // Einstellen lassen sich nur mitgelieferte Skills: Nur dort gibt es den Text mit Platzhaltern
+ const vars = b?.vars ?? [];
+ const values = cleanValues(vars, (settings as Record<string, unknown> | null)?.[id]);
const info: SkillInfo = {
- id, title: meta?.title ?? id, summary: meta?.summary ?? '', topics: meta?.topics ?? [], order: meta?.order ?? 100,
- bundled: !!b, active: isOn, file: copy != null ? relOf(id) : null,
- changed: !!b && copy != null && norm(copy) !== norm(b.text),
+ id, title: meta?.title ?? id, summary: showText(meta?.summary ?? '', vars, values), topics: (meta?.topics ?? []).map((x) => showText(x, vars, values)),
+ order: meta?.order ?? 100, bundled: !!b, active: isOn, file: copy != null ? relOf(id) : null,
+ changed: !!b && copy != null && norm(copy) !== renderSkill(b.text, values),
+ vars: vars.map((v) => ({ ...v, value: values[v.name] ?? v.default })),
problems: [],
};
if (isOn && copy == null) info.problems.push(`Aktiv, aber ${relOf(id)} fehlt oder ist unlesbar. Der Agent findet die Regeln nicht.`);
@@ -137,11 +247,12 @@ function writeAtomic(file: string, text: string): void {
}
/**
- * Skill ins Projekt kopieren. Liegt dort schon eine abweichende Fassung (vom Nutzer, vom Agenten oder aus einer älteren
- * App), wandert sie vorher in die Sicherung. Gibt den Pfad der Sicherung zurück, falls es eine gab.
+ * Skill mit den Werten `values` ins Projekt schreiben. Liegt dort schon eine abweichende Fassung (vom Nutzer, vom Agenten
+ * oder aus einer älteren App), wandert sie vorher in die Sicherung. Ausgenommen ist die unveränderte Kopie mit den bisherigen
+ * Werten `prev` (beim Umstellen einer Einstellung). Gibt den Pfad der Sicherung zurück, falls es eine gab.
*/
-export function copySkill(root: string, bundledDir: string, id: string, backupDir: string): string | null {
- const b = bundledSkills(bundledDir).get(id);
+export function copySkill(root: string, bundledDir: string, id: string, backupDir: string, values: SkillValues, prev?: SkillValues): string | null {
+ const b = bundledSkill(bundledDir, id);
const abs = resolveInside(root, relOf(id));
const old = projectCopy(root, id);
if (!b) {
@@ -149,9 +260,11 @@ export function copySkill(root: string, bundledDir: string, id: string, backupDi
if (old == null) throw new Error(`Den Skill „${id}“ gibt es in dieser App nicht.`);
return null;
}
- if (old != null && norm(old) === norm(b.text)) return null;
- const backup = old != null ? backupText(backupDir, relOf(id), old) : null;
- writeAtomic(abs, b.text);
+ const next = renderSkill(b.text, values);
+ if (old != null && norm(old) === next) return null;
+ const pristine = old != null && prev != null && norm(old) === renderSkill(b.text, prev);
+ const backup = old != null && !pristine ? backupText(backupDir, relOf(id), old) : null;
+ writeAtomic(abs, next);
return backup;
}
@@ -159,12 +272,12 @@ export function copySkill(root: string, bundledDir: string, id: string, backupDi
* Kopie aus dem Projekt entfernen. Eine unveränderte Kopie eines mitgelieferten Skills lässt sich jederzeit neu anlegen und
* wird einfach gelöscht, alles andere kommt vorher in die Sicherung.
*/
-export function removeSkill(root: string, bundledDir: string, id: string, backupDir: string): string | null {
+export function removeSkill(root: string, bundledDir: string, id: string, backupDir: string, values: SkillValues): string | null {
const abs = resolveInside(root, relOf(id));
const old = projectCopy(root, id);
if (old == null) { fs.rmSync(abs, { force: true }); return null; }
- const b = bundledSkills(bundledDir).get(id);
- const backup = b && norm(old) === norm(b.text) ? null : backupText(backupDir, relOf(id), old);
+ const b = bundledSkill(bundledDir, id);
+ const backup = b && norm(old) === renderSkill(b.text, values) ? null : backupText(backupDir, relOf(id), old);
fs.rmSync(abs, { force: true });
return backup;
}
@@ -203,7 +316,7 @@ export function writeAgentsList(root: string, entries: { id: string; name: strin
/** Englischer Name eines Skills für AGENTS.md, aus der mitgelieferten Fassung oder der Kopie im Projekt. */
export function skillName(root: string, bundledDir: string, id: string): string {
- const b = bundledSkills(bundledDir).get(id);
+ const b = bundledSkill(bundledDir, id);
if (b) return b.name;
const copy = projectCopy(root, id);
return copy != null ? parseSkill(id, copy).name : id;
diff --git a/app/src/main/workspace.ts b/app/src/main/workspace.ts
index 6cca41c..c7d9b94 100644
--- a/app/src/main/workspace.ts
+++ b/app/src/main/workspace.ts
@@ -20,6 +20,8 @@ export interface ProjectJson {
created: string;
/** Aktive Skills (E17), ihre Kopien liegen in .soma/skills/. */
skills?: string[];
+ /** Einstellungen der Skills je Kennung, nur vom Standard abweichende Werte (auch für ausgeschaltete Skills). */
+ skill_settings?: Record<string, Record<string, number | string>>;
}
/** Zweite Kopie des Projektzustands in den App-Daten (E27) plus Angaben, die nur die App braucht. */
@@ -87,14 +89,22 @@ export function renameProject(id: string, name: string): void {
if (cur) writeJson(stateFile(id), { ...cur, name });
}
-/** Aktive Skills ins Projekt schreiben, in project.json und die App-Kopie (E27). Wirft, wenn project.json unlesbar ist. */
-export function setProjectSkills(id: string, skills: string[]): void {
+/** Skills und ihre Einstellungen ins Projekt schreiben, in project.json und die App-Kopie (E27). Wirft, wenn project.json unlesbar ist. */
+export function updateProjectSkills(id: string, patch: Pick<ProjectJson, 'skills' | 'skill_settings'>): void {
const file = path.join(projectDir(id), '.soma', 'project.json');
const pj = readJson<ProjectJson>(file);
if (!pj) throw new Error('.soma/project.json fehlt oder ist unlesbar. Ohne sie lässt sich kein Skill eintragen.');
- writeJson(file, { ...pj, skills });
+ // Leere Einstellungen fallen weg, damit project.json ohne Änderung auch gleich bleibt
+ const settings = Object.fromEntries(Object.entries(patch.skill_settings ?? pj.skill_settings ?? {}).filter(([, v]) => v && Object.keys(v).length));
+ const next: ProjectJson = { ...pj, ...(patch.skills ? { skills: patch.skills } : {}) };
+ if (Object.keys(settings).length) next.skill_settings = settings; else delete next.skill_settings;
+ writeJson(file, next);
const cur = readJson<ProjectState>(stateFile(id));
- if (cur) writeJson(stateFile(id), { ...cur, skills });
+ if (cur) {
+ const copy: ProjectState = { ...cur, skills: next.skills };
+ if (next.skill_settings) copy.skill_settings = next.skill_settings; else delete copy.skill_settings;
+ writeJson(stateFile(id), copy);
+ }
}
/** Prüft ein Projekt und MELDET Auffälligkeiten. Repariert nichts (E28). */
diff --git a/app/src/preload/preload.ts b/app/src/preload/preload.ts
index a0c5f4f..7e3be0f 100644
--- a/app/src/preload/preload.ts
+++ b/app/src/preload/preload.ts
@@ -56,7 +56,11 @@ const api: SomaApi = {
},
agents: { detect: () => ipcRenderer.invoke('agents:detect') },
measure: { query: (source, req) => ipcRenderer.invoke('measure:query', source, req) },
- skills: { list: () => ipcRenderer.invoke('skills:list'), set: (id, on) => ipcRenderer.invoke('skills:set', id, on) },
+ skills: {
+ list: () => ipcRenderer.invoke('skills:list'),
+ set: (id, on) => ipcRenderer.invoke('skills:set', id, on),
+ configure: (id, values) => ipcRenderer.invoke('skills:configure', id, values),
+ },
dialog: { choose: (o) => ipcRenderer.invoke('dialog:choose', o) },
// Nur im Testmodus: vorbereitete Antworten für native Dialoge
test: process.env.SOMA_TEST === '1'
diff --git a/app/src/renderer/main.ts b/app/src/renderer/main.ts
index 3b5a1dd..7413905 100644
--- a/app/src/renderer/main.ts
+++ b/app/src/renderer/main.ts
@@ -87,6 +87,7 @@ async function openCode(file: string, mark?: Mark): Promise<void> {
const skills = new SkillsPanel($('skills-list'), {
list: () => api.skills.list(),
set: (id, on) => api.skills.set(id, on),
+ configure: (id, values) => api.skills.configure(id, values),
open: (file) => void openCode(file),
insert: (text) => insertToAgent(text),
toast,
diff --git a/app/src/renderer/skills.ts b/app/src/renderer/skills.ts
index 9f8f387..55105b9 100644
--- a/app/src/renderer/skills.ts
+++ b/app/src/renderer/skills.ts
@@ -1,10 +1,11 @@
-import type { SkillInfo, SkillResult } from '../shared/types';
+import type { SkillInfo, SkillResult, SkillValue, SkillVar } from '../shared/types';
import { icon } from './icons';
import { el } from './ui';
interface Deps {
list(): Promise<SkillInfo[]>;
set(id: string, on: boolean): Promise<SkillResult>;
+ configure(id: string, values: Record<string, SkillValue | null>): Promise<SkillResult>;
/** Kopie im Projekt im Code-Panel zeigen (nur lesen). */
open(file: string): void;
/** Text in die Eingabe des Agenten einfügen (E11). */
@@ -14,6 +15,20 @@ interface Deps {
changed(): void;
}
+const unitOf = (v: SkillVar) => (v.unit ? (v.unit === '°' ? '°' : ` ${v.unit}`) : '');
+/** Wert für die Oberfläche: Zahl mit Komma und Einheit, bei einer Auswahl der deutsche Name. */
+const shown = (v: SkillVar, x: SkillValue = v.value) => (typeof x === 'number'
+ ? `${x.toLocaleString('de-DE', { maximumFractionDigits: 6 })}${unitOf(v)}` : v.options?.find((o) => o.value === x)?.label ?? String(x));
+/** Für den Agenten: Zahlen mit Punkt. */
+const forAgent = (v: SkillVar) => (typeof v.value === 'number' ? `${String(v.value)}${unitOf(v)}` : shown(v));
+const changedVars = (s: SkillInfo) => s.vars.filter((v) => v.value !== v.default);
+
+/** Text für die Eingabe des Agenten: Pfad und die vom Standard abweichenden Einstellungen. */
+export function skillNote(s: SkillInfo): string {
+ const set = changedVars(s);
+ return `[Skill: ${s.file}${set.length ? `, Einstellungen: ${set.map((v) => `${v.label} = ${forAgent(v)}`).join(', ')}` : ''}] `;
+}
+
/**
* Seitenpanel „Skills“ (E17): mitgelieferte Regelwerke mit Schalter je Modell. Ein- und Ausschalten erledigt der
* Hauptprozess (Kopie in .soma/skills/, project.json, AGENTS.md). Das Panel zeigt nur, was er meldet.
@@ -80,11 +95,16 @@ export class SkillsPanel {
const row = el('div', { className: 'sk-row' + (s.active ? ' on' : '') }, el('div', { className: 'sk-head' }, sw, text, more));
row.setAttribute('role', 'listitem');
row.dataset.id = s.id;
+ const set = changedVars(s);
+ if (set.length) row.append(el('div', { className: 'sk-setline', textContent: `Eingestellt: ${set.map((v) => `${v.label} ${shown(v)}`).join(' · ')}` }));
if (s.changed) row.append(el('div', { className: 'sk-note', textContent: 'Die Kopie im Projekt weicht von der Fassung dieser App ab. Aus- und wieder Einschalten übernimmt die Fassung der App, die bisherige kommt in die Sicherung.' }));
for (const p of s.problems) row.append(el('div', { className: 'sk-warn', textContent: p }));
if (open) {
const body = el('div', { className: 'sk-body' });
- if (s.topics.length) body.append(el('div', { textContent: 'Darauf achtet der Agent:' }), el('ul', {}, ...s.topics.map((t) => el('li', { textContent: t }))));
+ if (s.vars.length) {
+ body.append(el('div', { className: 'sk-h', textContent: 'Einstellungen' }), el('div', { className: 'sk-vars' }, ...s.vars.map((v) => this.field(s, v))));
+ }
+ if (s.topics.length) body.append(el('div', { className: 'sk-h', textContent: 'Darauf achtet der Agent' }), el('ul', {}, ...s.topics.map((t) => el('li', { textContent: t }))));
const actions = el('div', { className: 'sk-actions' });
if (s.file) {
const view = el('button', { className: 'btn sm', title: 'Die Kopie im Projekt im Code-Panel zeigen' }, icon('file', 14, 1.9), 'Ansehen');
@@ -93,7 +113,7 @@ export class SkillsPanel {
}
if (s.active && s.file) {
const send = el('button', { className: 'btn sm acc', title: 'Den Pfad in die Eingabe des Agenten einfügen' }, icon('send', 14, 1.9), 'An Agent geben');
- send.addEventListener('click', () => this.deps.insert(`[Skill: ${s.file}] `));
+ send.addEventListener('click', () => this.deps.insert(skillNote(s)));
actions.append(send);
}
if (!s.file) body.append(el('div', { className: 'c3', textContent: 'Eingeschaltet liegt der Skill als Markdown im Projekt und lässt sich ansehen.' }));
@@ -103,10 +123,61 @@ export class SkillsPanel {
return row;
}
+ /** Einstellung ändern (null: Standard). Der Hauptprozess prüft den Wert und schreibt die Kopie neu, wenn der Skill an ist. */
+ private async configure(s: SkillInfo, v: SkillVar, value: SkillValue | null): Promise<void> {
+ if (this.busy.has(s.id)) return;
+ this.busy.add(s.id);
+ let r: SkillResult;
+ try { r = await this.deps.configure(s.id, { [v.name]: value }); } catch (e) { r = { ok: false, error: e instanceof Error ? e.message : String(e), skills: this.skills }; }
+ this.busy.delete(s.id);
+ this.skills = r.skills;
+ this.render();
+ if (!r.ok) { this.deps.toast(r.error ?? 'Die Einstellung ließ sich nicht ändern.', 'error'); return; }
+ this.deps.changed();
+ const now = r.skills.find((x) => x.id === s.id)?.vars.find((x) => x.name === v.name) ?? v;
+ const kept = r.backup ? ' Die vorige Fassung im Projekt liegt in der Sicherung.' : '';
+ this.deps.toast(`„${s.title}“: ${v.label} ${shown(now)}${value === null ? ' (Standard)' : ''}. `
+ + (s.active ? `Steht in ${s.file}. Einem laufenden Agenten sagt „An Agent geben“ Bescheid.${kept}` : 'Gilt, sobald der Skill an ist.'));
+ }
+
+ /** Eingabe einer Einstellung: Zahlenfeld (Komma oder Punkt, Enter übernimmt, Escape verwirft) oder Auswahl. */
+ private field(s: SkillInfo, v: SkillVar): HTMLElement {
+ const id = `sk-${s.id}-${v.name}`;
+ let input: HTMLInputElement | HTMLSelectElement;
+ if (v.kind === 'choice') {
+ const sel = el('select', { id, className: 'sk-select' }, ...(v.options ?? []).map((o) => el('option', { value: o.value, textContent: o.label })));
+ sel.value = String(v.value);
+ sel.addEventListener('change', () => void this.configure(s, v, sel.value));
+ input = sel;
+ } else {
+ const shownNum = typeof v.value === 'number' ? v.value.toLocaleString('de-DE', { maximumFractionDigits: 6 }) : String(v.value);
+ const inp = el('input', { id, className: 'sk-num', type: 'text', value: shownNum, spellcheck: false, autocomplete: 'off' });
+ inp.inputMode = 'decimal';
+ inp.title = v.min != null && v.max != null ? `Erlaubt ${shown(v, v.min)} bis ${shown(v, v.max)}` : '';
+ inp.addEventListener('change', () => { if (inp.value.trim() !== shownNum) void this.configure(s, v, inp.value); });
+ inp.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter') { e.preventDefault(); inp.blur(); if (inp.value.trim() !== shownNum) void this.configure(s, v, inp.value); }
+ else if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); inp.value = shownNum; inp.blur(); }
+ });
+ input = inp;
+ }
+ input.disabled = this.busy.has(s.id);
+ const label = el('label', { textContent: v.label, htmlFor: id });
+ const isDefault = v.value === v.default;
+ const reset = el('button', { className: 'sk-reset', title: `Zurück auf den Standard (${shown(v, v.default)})` }, icon('undo', 13, 2));
+ reset.setAttribute('aria-label', `${v.label} zurück auf den Standard`);
+ reset.hidden = isDefault;
+ reset.addEventListener('click', () => void this.configure(s, v, null));
+ const row = el('div', { className: 'sk-var' + (isDefault ? '' : ' set') }, label, el('span', { className: 'sk-in' }, input, el('span', { className: 'c3', textContent: v.unit })), reset);
+ row.dataset.var = v.name;
+ return row;
+ }
+
/** Für Tests. */
state() {
return {
- skills: this.skills.map((s) => ({ id: s.id, title: s.title, active: s.active, file: s.file, changed: s.changed, problems: s.problems })),
+ skills: this.skills.map((s) => ({ id: s.id, title: s.title, summary: s.summary, active: s.active, file: s.file, changed: s.changed, problems: s.problems,
+ vars: Object.fromEntries(s.vars.map((v) => [v.name, v.value])) })),
busy: [...this.busy], text: this.list.innerText,
};
}
diff --git a/app/src/renderer/style.css b/app/src/renderer/style.css
index 30c0e3c..7953153 100644
--- a/app/src/renderer/style.css
+++ b/app/src/renderer/style.css
@@ -132,6 +132,20 @@ code { font-family:var(--mono); font-size:.95em; }
.sk-body li { margin:1px 0; }
.sk-actions { display:flex; gap:6px; flex-wrap:wrap; }
.sk-note { padding:0 12px 8px 56px; font-size:12px; color:var(--tx3); }
+.sk-setline { padding:0 12px 8px 56px; font-size:12px; color:var(--acc-tx); }
+.sk-h { margin:2px 0 4px; font-size:11px; letter-spacing:.06em; text-transform:uppercase; color:var(--tx3); }
+.sk-vars { display:flex; flex-direction:column; gap:3px; margin-bottom:10px; }
+.sk-var { display:flex; align-items:center; gap:6px; min-height:28px; }
+.sk-var label { flex:1; min-width:0; color:var(--tx2); }
+.sk-var.set label { color:var(--tx); }
+.sk-in { display:flex; align-items:center; gap:4px; flex-shrink:0; }
+.sk-in .c3 { width:16px; font-size:11.5px; }
+.sk-num { width:62px; height:26px; padding:0 6px; border-radius:5px; border:1px solid var(--line2); background:var(--term); color:var(--tx); font:12px var(--mono); text-align:right; }
+.sk-var.set .sk-num, .sk-var.set .sk-select { border-color:var(--acc-line); }
+.sk-select { max-width:150px; height:26px; padding:0 4px; border-radius:5px; border:1px solid var(--line2); background:var(--term); color:var(--tx); font:12px var(--sans); }
+.sk-reset { width:22px; height:22px; display:flex; align-items:center; justify-content:center; border-radius:5px; color:var(--tx3); flex-shrink:0; }
+.sk-reset:hover { background:var(--s3); color:var(--tx); }
+.sk-reset[hidden] { display:flex; visibility:hidden; }
.sk-warn { padding:0 12px 8px 56px; font-size:12px; color:var(--warn); }
.dropzone { margin:12px; padding:16px 14px; border:1.5px dashed var(--line2); border-radius:10px; display:flex; flex-direction:column; align-items:center; gap:6px; text-align:center; color:var(--tx2); font-size:12px; flex-shrink:0; }
.dropzone b { color:var(--tx); font-size:13px; font-weight:600; }
diff --git a/app/src/shared/types.ts b/app/src/shared/types.ts
index 12ef69f..7b5ec1a 100644
--- a/app/src/shared/types.ts
+++ b/app/src/shared/types.ts
@@ -84,6 +84,21 @@ export interface MeasureResult { build: string; a: MeasureInfo; b?: MeasureInfo;
/** `stale`: Die Anfrage gehört zu einem älteren Build, die Auswahl ist neu zu treffen. */
export interface MeasureResponse { ok: boolean; result?: MeasureResult; error?: string; stale?: boolean }
+/** Wert einer Einstellung eines Skills: Zahl oder gewählter Eintrag. */
+export type SkillValue = number | string;
+/** Einstellung eines Skills, im Kopf der Skill-Datei erklärt (`var …`) und im Text als `{{name}}` eingesetzt. */
+export interface SkillVar {
+ name: string; label: string;
+ /** Einheit hinter der Zahl, etwa „mm“ oder „°“, sonst leer. */
+ unit: string;
+ kind: 'number' | 'choice';
+ value: SkillValue; default: SkillValue;
+ /** Erlaubter Bereich (Zahlen). */
+ min?: number; max?: number;
+ /** Auswahl: Wert für den Agenten und Anzeige in der Oberfläche. */
+ options?: { value: string; label: string }[];
+}
+
/** Ein Skill (E17): Regelwerk für den Agenten, pro Modell zuschaltbar. */
export interface SkillInfo {
id: string;
@@ -95,8 +110,10 @@ export interface SkillInfo {
active: boolean;
/** Kopie im Projekt (`.soma/skills/<id>.md`), null wenn keine da ist. */
file: string | null;
- /** Die Kopie im Projekt weicht von der mitgelieferten Fassung ab. */
+ /** Die Kopie im Projekt weicht von der mitgelieferten Fassung (mit den eingestellten Werten) ab. */
changed: boolean;
+ /** Einstellungen mit ihren aktuellen Werten (nur bei mitgelieferten Skills). */
+ vars: SkillVar[];
/** Auffälligkeiten, nur gemeldet (E28). */
problems: string[];
}
@@ -191,7 +208,12 @@ export interface SomaApi {
/** Exakte Messung über den Python-Dienst (E9, E24). */
measure: { query(source: MeasureSource, req: MeasureRequest): Promise<MeasureResponse> };
/** Skills des offenen Modells (E17): auflisten, ein- und ausschalten. */
- skills: { list(): Promise<SkillInfo[]>; set(id: string, on: boolean): Promise<SkillResult> };
+ skills: {
+ list(): Promise<SkillInfo[]>;
+ set(id: string, on: boolean): Promise<SkillResult>;
+ /** Einstellungen ändern, null setzt auf den Standard zurück. Ein aktiver Skill wird im Projekt neu geschrieben. */
+ configure(id: string, values: Record<string, SkillValue | null>): Promise<SkillResult>;
+ };
/** Nativer Dialog mit Knöpfen, liefert den Index. Der letzte Knopf gilt als Abbrechen. Im Test über `test.answers` beantwortbar. */
dialog: { choose(o: { title: string; message: string; detail?: string; buttons: string[] }): Promise<number> };
}
diff --git a/app/test/skills.mjs b/app/test/skills.mjs
index efc6a08..27ec551 100644
--- a/app/test/skills.mjs
+++ b/app/test/skills.mjs
@@ -1,6 +1,7 @@
// Test der Skills (E17): Panel mit den mitgelieferten Skills, Ein- und Ausschalten (Kopie in .soma/skills/, project.json,
// Abschnitt in AGENTS.md), Ansehen und An Agent geben, geänderte Kopie wandert in die Sicherung, fehlende Dateien werden
-// gemeldet statt repariert (E28), Skills im Snapshot und in der ZIP. Aufruf: npm run test:skills (baut vorher).
+// gemeldet statt repariert (E28), Einstellungen (Werte in der Kopie, Prüfung, Standard, auch bei ausgeschaltetem Skill),
+// Skills im Snapshot und in der ZIP. Aufruf: npm run test:skills (baut vorher).
import { exec } from 'dugite';
import fs from 'node:fs';
import os from 'node:os';
@@ -44,6 +45,15 @@ try {
await ev((i) => document.querySelector(`#skills-list .sk-row[data-id="${i}"] .sk-switch`).click(), id);
await waitFor(`Skill ${id} ${on ? 'an' : 'aus'}`, ([i, o]) => { const s = window.__t.skills(); return !s.busy.length && s.skills.find((x) => x.id === i)?.active === o; }, 10000, [id, on]);
};
+ /** Wert in ein Feld der Einstellungen schreiben und mit Enter übernehmen (Auswahl: change). */
+ const setVar = (id, name, value) => ev(([i, n, v]) => {
+ const f = document.getElementById(`sk-${i}-${n}`);
+ f.value = v;
+ if (f.tagName === 'SELECT') f.dispatchEvent(new Event('change'));
+ else f.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
+ }, [id, name, value]);
+ const varOf = async (id, name) => (await skill(id)).vars[name];
+ const settings = () => pj().skill_settings ?? {};
const block = () => { const a = read('AGENTS.md') ?? ''; const m = /<!-- soma:skills -->([\s\S]*?)<!-- \/soma:skills -->/.exec(a); return m ? m[1] : null; };
// 1) Panel: drei mitgelieferte Skills, alle aus. Die Vorlage hat den leeren Abschnitt in AGENTS.md
@@ -58,7 +68,9 @@ try {
// 2) Einschalten: Kopie, project.json (und App-Kopie), Abschnitt in AGENTS.md, als Änderung sichtbar
await toggle('3d-druck', true);
const copy = read('.soma/skills/3d-druck.md');
- check('3D-Druck an: Kopie in .soma/skills/ entspricht der mitgelieferten Fassung', copy !== null && norm(copy) === norm(fs.readFileSync(path.join(BUNDLED, '3d-druck.md'), 'utf8')));
+ const bundledText = norm(fs.readFileSync(path.join(BUNDLED, '3d-druck.md'), 'utf8'));
+ check('3D-Druck an: Kopie in .soma/skills/ mit den Standardwerten eingesetzt', copy !== null && bundledText.includes('{{overhang}}') && !copy.includes('{{')
+ && copy.includes('Overhangs up to 45° from vertical') && copy.includes('| Nozzle | 0.4 mm |') && copy.split('\n').length === bundledText.split('\n').length);
check('project.json und die Kopie in den App-Daten nennen den Skill', JSON.stringify(pj().skills) === '["3d-druck"]'
&& JSON.stringify(JSON.parse(fs.readFileSync(path.join(ud, 'projects', `${proj.id}.json`), 'utf8')).skills) === '["3d-druck"]');
check('AGENTS.md führt ihn auf (Pfad und englischer Name), der Rest der Datei bleibt', (block() ?? '').includes('- `.soma/skills/3d-druck.md`: 3D printing (FDM)')
@@ -83,6 +95,48 @@ try {
check('„An Agent geben" fügt [Skill: .soma/skills/3d-druck.md] ein', (await ev(() => window.__t.toast())).text.includes('In die Eingabe von')
&& await ev(() => window.__inserted) === '[Skill: .soma/skills/3d-druck.md] ', await ev(() => window.__inserted));
+ // 3b) Einstellungen: Max. Überhang auf 50° (Wunsch des Nutzers), Werte landen in project.json und in der Kopie
+ check('Aufgeklappt: Einstellungen mit Standardwerten (Max. Überhang 45°, Düse 0,4 mm, Material PLA)', await ev(() =>
+ document.getElementById('sk-3d-druck-overhang')?.value === '45' && document.getElementById('sk-3d-druck-nozzle')?.value === '0,4' && document.getElementById('sk-3d-druck-material')?.value === 'PLA'));
+ await setVar('3d-druck', 'overhang', '50');
+ await waitFor('Überhang 50', () => window.__t.skills().skills.find((x) => x.id === '3d-druck')?.vars.overhang === 50, 10000);
+ let c3 = read('.soma/skills/3d-druck.md') ?? '';
+ check('Max. Überhang 50°: project.json, Kopie mit 50° (Text, Tabelle, Kopf), keine „Abweichung"', JSON.stringify(settings()) === '{"3d-druck":{"overhang":50}}'
+ && c3.includes('Overhangs up to 50° from vertical') && c3.includes('| Max. overhang without support | 50° from vertical |') && c3.includes('var overhang: 50 |') && c3.includes('MAX_OVERHANG = 50')
+ && !(await skill('3d-druck')).changed, JSON.stringify(settings()));
+ s = await st();
+ check('Karte: Kurzbeschreibung „Überhänge bis 50°", Zeile „Eingestellt: …", Rücksetzknopf', s.skills.find((x) => x.id === '3d-druck').summary.includes('Überhänge bis 50°')
+ && s.text.includes('Eingestellt: Max. Überhangwinkel 50°')
+ && await ev(() => !document.querySelector('#skills-list .sk-var[data-var="overhang"] .sk-reset').hidden && document.querySelector('#skills-list .sk-var[data-var="nozzle"] .sk-reset').hidden), s.skills[0].summary);
+ check('Meldung nennt Wert und Datei', (await ev(() => window.__t.toast())).text.includes('Max. Überhangwinkel 50°. Steht in .soma/skills/3d-druck.md'), (await ev(() => window.__t.toast())).text);
+ await setVar('3d-druck', 'overhang', '95');
+ await waitFor('Fehlermeldung', () => window.__t.toast().error, 5000).catch(() => {});
+ check('95° außerhalb des Bereichs: abgelehnt mit Grund, 50° bleibt', (await ev(() => window.__t.toast())).text.includes('erlaubt sind 10 bis 85°')
+ && await varOf('3d-druck', 'overhang') === 50 && JSON.stringify(settings()) === '{"3d-druck":{"overhang":50}}'
+ && await ev(() => document.getElementById('sk-3d-druck-overhang').value) === '50', (await ev(() => window.__t.toast())).text);
+ await setVar('3d-druck', 'material', 'PETG');
+ await waitFor('Material', () => window.__t.skills().skills.find((x) => x.id === '3d-druck')?.vars.material === 'PETG', 10000);
+ await setVar('3d-druck', 'nozzle', '0,6');
+ await waitFor('Düse', () => window.__t.skills().skills.find((x) => x.id === '3d-druck')?.vars.nozzle === 0.6, 10000);
+ c3 = read('.soma/skills/3d-druck.md') ?? '';
+ check('Auswahl (PETG) und Zahl mit Komma (0,6): in der Kopie mit Punkt', c3.includes('| Material | PETG |') && c3.includes('| Nozzle | 0.6 mm |') && c3.includes('NOZZLE = 0.6')
+ && await ev(() => document.getElementById('sk-3d-druck-nozzle').value) === '0,6');
+ await ev(() => [...document.querySelectorAll('#skills-list .sk-row[data-id="3d-druck"] .sk-actions button')].find((b) => b.textContent.includes('An Agent')).click());
+ await sleep(300);
+ check('„An Agent geben" nennt die geänderten Einstellungen (Zahlen mit Punkt)', await ev(() => window.__inserted)
+ === '[Skill: .soma/skills/3d-druck.md, Einstellungen: Material = PETG, Düse = 0.6 mm, Max. Überhangwinkel = 50°] ', await ev(() => window.__inserted));
+ await ev(() => document.querySelector('#skills-list .sk-var[data-var="nozzle"] .sk-reset').click());
+ await waitFor('Düse zurück', () => window.__t.skills().skills.find((x) => x.id === '3d-druck')?.vars.nozzle === 0.4, 10000);
+ check('Zurück auf den Standard: Düse 0,4 mm, aus project.json entfernt, Kopie wieder 0.4', settings()['3d-druck']?.overhang === 50 && settings()['3d-druck']?.material === 'PETG' && !('nozzle' in (settings()['3d-druck'] ?? {}))
+ && (read('.soma/skills/3d-druck.md') ?? '').includes('| Nozzle | 0.4 mm |'), JSON.stringify(settings()));
+ // Ausgeschalteter Skill: Werte lassen sich vorab einstellen und gelten beim Einschalten
+ await ev(() => document.querySelector('#skills-list .sk-row[data-id="gehaeuse"] .sk-more').click());
+ await setVar('gehaeuse', 'wall', '3');
+ await waitFor('Wand 3', () => window.__t.skills().skills.find((x) => x.id === 'gehaeuse')?.vars.wall === 3, 10000);
+ check('Gehäusebau (aus): Wand 3 mm gespeichert, keine Datei angelegt, Hinweis „gilt, sobald an"', settings().gehaeuse?.wall === 3 && read('.soma/skills/gehaeuse.md') === null
+ && (await ev(() => window.__t.toast())).text.includes('Gilt, sobald der Skill an ist'));
+ await shot('skills-3-einstellungen');
+
// 4) Zweiter Skill: beide stehen in AGENTS.md, in der Reihenfolge des Einschaltens
await toggle('toleranzen', true);
const b2 = block() ?? '';
@@ -94,13 +148,19 @@ try {
await ev(() => window.__t.showPanel('skills'));
await waitFor('geändert erkannt', () => window.__t.skills().skills.find((x) => x.id === '3d-druck')?.changed === true, 10000);
check('Geänderte Kopie: „weicht ab" in der Karte', (await st()).text.includes('weicht von der Fassung dieser App ab'));
- await toggle('3d-druck', false);
+ await setVar('3d-druck', 'overhang', '55');
+ await waitFor('Überhang 55', () => window.__t.skills().skills.find((x) => x.id === '3d-druck')?.vars.overhang === 55, 10000);
const bdir = path.join(ud, 'workspace-backups', `${proj.id}-skills`);
- const backups = fs.existsSync(bdir) ? fs.readdirSync(bdir) : [];
- check('Ausschalten: Kopie weg, die geänderte Fassung liegt in der Sicherung', read('.soma/skills/3d-druck.md') === null && backups.length === 1
- && fs.readFileSync(path.join(bdir, backups[0]), 'utf8').includes('Use PETG only.'), backups.join(','));
+ let backups = fs.existsSync(bdir) ? fs.readdirSync(bdir) : [];
+ check('Einstellung an geänderter Kopie: Kopie in die Sicherung, neu geschrieben mit 55°', backups.length === 1 && fs.readFileSync(path.join(bdir, backups[0]), 'utf8').includes('Use PETG only.')
+ && !(read('.soma/skills/3d-druck.md') ?? '').includes('Use PETG only.') && (read('.soma/skills/3d-druck.md') ?? '').includes('up to 55°') && !(await skill('3d-druck')).changed
+ && (await ev(() => window.__t.toast())).text.includes('Sicherung'), backups.join(','));
+ await toggle('3d-druck', false);
+ backups = fs.existsSync(bdir) ? fs.readdirSync(bdir) : [];
+ check('Ausschalten: Kopie weg, unveränderte Kopie ohne neue Sicherung, Einstellungen bleiben', read('.soma/skills/3d-druck.md') === null && backups.length === 1
+ && settings()['3d-druck']?.overhang === 55, backups.join(','));
check('AGENTS.md und project.json ohne 3D-Druck, Toleranzen bleibt', !(block() ?? '').includes('3d-druck') && (block() ?? '').includes('toleranzen.md') && JSON.stringify(pj().skills) === '["toleranzen"]');
- check('Meldung nennt Sicherung und den laufenden Agenten', /ist aus\..*Sag ihm Bescheid.*Sicherung/.test((await ev(() => window.__t.toast())).text), (await ev(() => window.__t.toast())).text);
+ check('Meldung nennt den laufenden Agenten', /ist aus\..*Sag ihm Bescheid/.test((await ev(() => window.__t.toast())).text), (await ev(() => window.__t.toast())).text);
// 6) Datei eines aktiven Skills fehlt: gemeldet, nicht neu angelegt (E28)
fs.rmSync(path.join(dir, '.soma', 'skills', 'toleranzen.md'));
@@ -118,12 +178,14 @@ try {
fs.writeFileSync(path.join(dir, 'AGENTS.md'), agents.replace(/\n*<!-- soma:skills -->[\s\S]*<!-- \/soma:skills -->\n?/, '\n'));
await toggle('gehaeuse', true);
const a2 = read('AGENTS.md');
+ check('Gehäusebau an: die vorher eingestellte Wand (3 mm) steht in der Kopie', (read('.soma/skills/gehaeuse.md') ?? '').includes('Wall 3 mm') && (read('.soma/skills/gehaeuse.md') ?? '').includes('WALL = 3'));
check('Ohne Abschnitt: am Ende angehängt, genau einmal', a2.trimEnd().endsWith('<!-- /soma:skills -->') && a2.split('<!-- soma:skills -->').length === 2 && (block() ?? '').includes('- `.soma/skills/gehaeuse.md`: Enclosure design'), String(block()));
// 8) AGENTS.md fehlt ganz: Skill geht trotzdem an, Warnung, AGENTS.md wird nicht neu angelegt
const keep = read('AGENTS.md');
fs.rmSync(path.join(dir, 'AGENTS.md'));
await toggle('3d-druck', true);
+ check('Wieder an: Kopie mit den gespeicherten Einstellungen (55°, PETG)', (read('.soma/skills/3d-druck.md') ?? '').includes('up to 55°') && (read('.soma/skills/3d-druck.md') ?? '').includes('| Material | PETG |'));
check('Ohne AGENTS.md: Skill an, Warnung, keine neue AGENTS.md', read('AGENTS.md') === null && read('.soma/skills/3d-druck.md') !== null
&& (await ev(() => window.__t.toast())).text.includes('AGENTS.md fehlt') && (await ev(() => window.__t.toast())).error, (await ev(() => window.__t.toast())).text);
fs.writeFileSync(path.join(dir, 'AGENTS.md'), keep);
diff --git a/app/test/unit.mjs b/app/test/unit.mjs
index 675920c..a83322f 100644
--- a/app/test/unit.mjs
+++ b/app/test/unit.mjs
@@ -96,6 +96,25 @@ try {
const icoSizes = Array.from({ length: ico.readUInt16LE(4) }, (_, i) => ico[6 + 16 * i] || 256);
check('App-Icon: icon.ico mit 16 bis 256 px, icon.png vorhanden', [16, 24, 32, 48, 256].every((s) => icoSizes.includes(s))
&& fs.existsSync(path.join(APP, 'resources', 'icon.png')), icoSizes.join(','));
+
+ // Skills mit Einstellungen (E17): Variablen im Kopf, Platzhalter im Text, Prüfung der Werte
+ const sk = path.join(tmp, 'skills.mjs');
+ await build({ entryPoints: [path.join(APP, 'src', 'main', 'skills.ts')], outfile: sk, bundle: true, platform: 'node', format: 'esm', logLevel: 'silent' });
+ const { parseSkill, renderSkill, checkValue, cleanValues, bundledSkills } = await import(pathToFileURL(sk).href);
+ const SRC = '---\ntitle: Test\nvar angle: 45 | ° | Winkel | 10..80\nvar mat: PLA | | Material | PLA, PETG=Petg-Filament\n---\n# Skill\n\nUp to {{angle}}° in {{mat}}, {{unknown}} stays.\n';
+ const ps = parseSkill('t', SRC);
+ check('Skill-Kopf: Zahl mit Einheit und Bereich, Auswahl mit Anzeigenamen', ps.vars.length === 2 && ps.vars[0].kind === 'number' && ps.vars[0].min === 10 && ps.vars[0].max === 80 && ps.vars[0].unit === '°'
+ && ps.vars[1].kind === 'choice' && ps.vars[1].options[1].value === 'PETG' && ps.vars[1].options[1].label === 'Petg-Filament', JSON.stringify(ps.vars));
+ const rs = renderSkill(SRC, { angle: 50, mat: 'PETG' });
+ check('Eingesetzt: Text mit Werten, Kopf mit Werten statt Standard, Unbekanntes bleibt', rs.includes('Up to 50° in PETG, {{unknown}} stays.') && rs.includes('var angle: 50 | °') && rs.includes('var mat: PETG |'), rs);
+ check('Ohne Einstellungen: die Standardwerte', renderSkill(SRC, {}).includes('Up to 45° in PLA'));
+ const cv = [checkValue(ps.vars[0], '52,5'), checkValue(ps.vars[0], 95), checkValue(ps.vars[0], 'abc'), checkValue(ps.vars[1], 'ABS')];
+ check('Werte geprüft: Komma geht, außerhalb des Bereichs, keine Zahl und fremde Auswahl abgelehnt', cv[0].value === 52.5 && cv[1].error?.includes('10 bis 80°') && cv[2].error && cv[3].error, JSON.stringify(cv));
+ check('Gespeicherte Werte bereinigt: Ungültiges und Standard fallen weg', JSON.stringify(cleanValues(ps.vars, { angle: 45, mat: 'XYZ', other: 1 })) === '{}'
+ && JSON.stringify(cleanValues(ps.vars, { angle: '60' })) === '{"angle":60}');
+ const shipped = [...bundledSkills(path.join(APP, 'resources', 'skills')).values()];
+ const leftover = shipped.map((s) => renderSkill(s.text, {})).filter((x) => /\{\{/.test(x));
+ check('Mitgelieferte Skills: jeder Platzhalter hat eine Variable', shipped.length >= 3 && shipped.every((s) => s.vars.length) && !leftover.length, shipped.map((s) => `${s.id}:${s.vars.length}`).join(','));
} catch (e) {
console.log('ABBRUCH:', e.message);
t.fail();