Desktop app for designing parametric 3D models in CadQuery together with the coding agent of your choice
TypeScript 3d-modeling3d-printing3d-printing-toolsagentagentic-aiai-cadcadcadqueryclaude-codecodexelectronfemllmmacdmakeropencodeparametric-designpythonsteptext-to-cad
App: Knopf „Import“ neben Export
Kai-Jungsthoefel152179e187b5
diff --git a/app/resources/skills/soma-app.md b/app/resources/skills/soma-app.mdindex 9281f1a..c5d68c0 100644--- a/app/resources/skills/soma-app.md+++ b/app/resources/skills/soma-app.md@@ -29,14 +29,15 @@ things, and ask for changes.1. **Model menu**: new model, open, recent models, save as. Next to it: whether the model is saved.2. **Build status**: "Built" when the model is up to date, "Build failed" if the code has an error. Click for details. With "Auto on" the model is rebuilt whenever the code changes.3. **Columns**: show or hide the sidebar, the code and the agent (Ctrl 1, Ctrl 2, Ctrl 3).-4. **Export**: write parts as STL, STEP and other formats.-5. **Save**: saves the model as a .soma file and adds a version to the history (Ctrl S).-6. **Sidebar**: parameters, files, analysis, animation, skills, help and settings.-7. **Structure tree**: the parts of the model. Click the arrow to expand it.-8. **Tools**: measure, section, explode and mark up.-9. **View cube**: click a side, edge or corner to look from there.-10. **History**: every saved version. Click a dot to look at it.-11. **Agent**: the terminal where you talk to the agent.+4. **Import**: add files such as STEP models, images or sketches to `inputs/`, where the agent can use them. Dragging files or folders into the window does the same.+5. **Export**: write parts as STL, STEP and other formats.+6. **Save**: saves the model as a .soma file and adds a version to the history (Ctrl S).+7. **Sidebar**: parameters, files, analysis, animation, skills, help and settings.+8. **Structure tree**: the parts of the model. Click the arrow to expand it.+9. **Tools**: measure, section, explode and mark up.+10. **View cube**: click a side, edge or corner to look from there.+11. **History**: every saved version. Click a dot to look at it.+12. **Agent**: the terminal where you talk to the agent.The logo at the top left opens the start page.diff --git a/app/src/main/dialogs.ts b/app/src/main/dialogs.tsindex 87435cc..213d13c 100644--- a/app/src/main/dialogs.ts+++ b/app/src/main/dialogs.ts@@ -60,6 +60,17 @@ export async function chooseSkillFiles(win: BrowserWindow | null): Promise<strinreturn r.canceled ? [] : r.filePaths;}+/**+ * Dateien für inputs/ wählen (Knopf „Import“, gleicher Weg wie Reinziehen). Ordner nur per Ziehen: Der Dialog von+ * Windows kann nicht Dateien und Ordner zugleich wählen. Leere Liste: abgebrochen.+ */+export async function chooseInputFiles(win: BrowserWindow | null): Promise<string[]> {+ if (testMode()) return nextAnswer<string[] | null>('Import files') ?? [];+ const opts = { title: 'Import files into the model', defaultPath: documentsDir(), buttonLabel: 'Import', properties: ['openFile' as const, 'multiSelections' as const] };+ const r = win ? await dialog.showOpenDialog(win, opts) : await dialog.showOpenDialog(opts);+ return r.canceled ? [] : r.filePaths;+}+export type ChooseOptions = { title: string; message: string; detail?: string; buttons: string[] };/** Zeigt Rückfragen im Fenster der App. `null`: geht gerade nicht (Fenster lädt, abgestürzt), dann der Dialog des Systems. */type DialogHost = (o: ChooseOptions) => Promise<number | null>;diff --git a/app/src/main/main.ts b/app/src/main/main.tsindex 066c32b..ddb9f4b 100644--- a/app/src/main/main.ts+++ b/app/src/main/main.ts@@ -5,7 +5,7 @@ import { aboutInfo, aboutText } from './about';import { detectAgents } from './agents';import { bridgeEnv, startBridge, stopBridge } from './bridge';import { stopWarm, warmUp } from './build';-import { choose, chooseSkillFiles, setDialogHost, setTestAnswers, trashItem, type ChooseOptions } from './dialogs';+import { choose, chooseInputFiles, chooseSkillFiles, setDialogHost, setTestAnswers, trashItem, type ChooseOptions } from './dialogs';import { viewDxf } from './dxf';import { backupText, createEntry, entryPath, importInputs, listFiles, renameEntry, resolveInside, saveFeedbackImage, trashEntry, writeProjectText } from './files';import { ProjectController } from './projects';@@ -78,6 +78,11 @@ function registerIpc(ctl: ProjectController): void {ipcMain.handle('fs:list', () => listFiles(dir()));ipcMain.handle('fs:import', (_e, paths: string[]) => importInputs(dir(), Array.isArray(paths) ? paths.map(String) : []));+ ipcMain.handle('fs:importPick', async () => {+ const root = dir();+ const files = await chooseInputFiles(win);+ return files.length ? importInputs(root, files) : null;+ });ipcMain.handle('fs:create', (_e, parent: string, name: string, isDir: boolean) => createEntry(dir(), String(parent ?? ''), String(name ?? ''), !!isDir));ipcMain.handle('fs:rename', (_e, rel: string, name: string) => renameEntry(dir(), String(rel ?? ''), String(name ?? '')));ipcMain.handle('fs:trash', async (_e, rel: string): Promise<FileOpResult> => {diff --git a/app/src/preload/preload.ts b/app/src/preload/preload.tsindex 398077b..132c444 100644--- a/app/src/preload/preload.ts+++ b/app/src/preload/preload.ts@@ -42,6 +42,7 @@ const api: SomaApi = {onChanged: (cb) => { ipcRenderer.on('fs:changed', () => cb()); },// Der Renderer kennt keine Dateipfade. Nur die Pfade gezogener Dateien gehen an den Hauptprozess, der prüft und kopiert.importFiles: (files) => ipcRenderer.invoke('fs:import', files.map((f) => webUtils.getPathForFile(f)).filter(Boolean)),+ importPick: () => ipcRenderer.invoke('fs:importPick'),create: (parent, name, dir) => ipcRenderer.invoke('fs:create', parent, name, dir),rename: (rel, name) => ipcRenderer.invoke('fs:rename', rel, name),trash: (rel) => ipcRenderer.invoke('fs:trash', rel),diff --git a/app/src/renderer/icons.ts b/app/src/renderer/icons.tsindex 63f7fec..fd07002 100644--- a/app/src/renderer/icons.ts+++ b/app/src/renderer/icons.ts@@ -15,6 +15,7 @@ const PATHS: Record<string, string> = {more: '<circle cx="5" cy="12" r="1.3" fill="currentColor"/><circle cx="12" cy="12" r="1.3" fill="currentColor"/><circle cx="19" cy="12" r="1.3" fill="currentColor"/>',refresh: '<path d="M20 12a8 8 0 1 1-2.3-5.7L20 8.5"/><path d="M20 3.5v5h-5"/>',export: '<path d="M12 15V4M7 9l5-5 5 5"/><path d="M5 14v5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5"/>',+ import: '<path d="M12 4v11M7 10l5 5 5-5"/><path d="M5 14v5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5"/>',folder: '<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>',code: '<path d="m16 18 6-6-6-6M8 6l-6 6 6 6"/>',book: '<path d="M2 5h6a4 4 0 0 1 4 4v11a3 3 0 0 0-3-3H2z"/><path d="M22 5h-6a4 4 0 0 0-4 4v11a3 3 0 0 1 3-3h7z"/>',diff --git a/app/src/renderer/index.html b/app/src/renderer/index.htmlindex 0817b5d..17f9d10 100644--- a/app/src/renderer/index.html+++ b/app/src/renderer/index.html@@ -32,6 +32,7 @@<button id="btn-lay-code" aria-pressed="false" title="Show or hide the code (Ctrl 2)" aria-label="Code"><i data-icon="code" data-size="16" data-stroke="1.9"></i></button><button id="btn-lay-agent" aria-pressed="true" title="Expand or collapse the agent (Ctrl 3). Collapsed, it keeps running." aria-label="Agent"><i data-icon="panel" data-size="17" data-stroke="1.7"></i></button></div>+ <button id="btn-import" class="btn" title="Add files to inputs/ (STEP, images, drawings …). The agent can then use them. Dragging files or folders into the window does the same."><i data-icon="import" data-size="15"></i>Import</button><button id="btn-export" class="btn" aria-haspopup="menu" aria-expanded="false"><i data-icon="export" data-size="15"></i>Export<i data-icon="down" data-size="13" data-stroke="2"></i></button><button id="btn-save" class="btn primary" title="Add a snapshot to the history and write the .soma file">Save <span class="kbd">Ctrl S</span></button></header>diff --git a/app/src/renderer/main.ts b/app/src/renderer/main.tsindex 2197448..d0daa98 100644--- a/app/src/renderer/main.ts+++ b/app/src/renderer/main.ts@@ -1,6 +1,6 @@import { affectsBuild } from '../shared/editable';import { DEFAULT_SETTINGS, type SettingsPatch, type SettingsResult, type SettingsState } from '../shared/settings';-import type { AgentInfo, AnimEntry, BuildStatus, ExportResult, FileNode, ModelMap, PartMap, PreviewResult, ProjectInfo, ProjectListEntry, ResultEntry, SaveState } from '../shared/types';+import type { AgentInfo, AnimEntry, BuildStatus, ExportResult, FileNode, ImportResult, ModelMap, PartMap, PreviewResult, ProjectInfo, ProjectListEntry, ResultEntry, SaveState } from '../shared/types';import { AnalysisPanel } from './analysispanel';import { AnimPanel, animKey, videoKey } from './animpanel';import { SOMA_VERSION } from '../shared/version';@@ -392,7 +392,17 @@ document.addEventListener('drop', (e) => {});async function importFiles(list: File[]): Promise<void> {- const r = await api.fs.importFiles(list);+ reportImport(await api.fs.importFiles(list));+}++// Knopf „Import“: derselbe Weg wie Ziehen, nur mit Dateidialog. Zeigt Nutzern, wie Daten ins Modell kommen+$('btn-import').addEventListener('click', async () => {+ if (!project) return;+ const r = await api.fs.importPick();+ if (r) reportImport(r);+});++function reportImport(r: ImportResult): void {showPanel('files');const lines: string[] = [];if (r.files.length) lines.push(`Added to inputs/: ${r.files.map((f) => f.replace(/^inputs\//, '')).join(', ')}`, 'The agent can now use them in the script.');diff --git a/app/src/shared/types.ts b/app/src/shared/types.tsindex 32b611c..4d4b3b3 100644--- a/app/src/shared/types.ts+++ b/app/src/shared/types.ts@@ -418,6 +418,8 @@ export interface SomaApi {onChanged(cb: () => void): void;/** Kopiert gezogene Dateien nach inputs/. Vorhandenes wird nie überschrieben. */importFiles(files: File[]): Promise<ImportResult>;+ /** Wie importFiles, die Dateien wählt der Nutzer im Dialog. null: abgebrochen. */+ importPick(): Promise<ImportResult | null>;/** Neue, leere Datei oder neuer Ordner in `parent` ('' = Projektordner). Vorhandenes wird nie überschrieben. */create(parent: string, name: string, dir: boolean): Promise<FileOpResult>;/** Benennt eine Datei oder einen Ordner im selben Ordner um. Vorhandenes wird nie überschrieben. */diff --git a/app/test/editor.mjs b/app/test/editor.mjsindex 2592f15..7c0b8ec 100644--- a/app/test/editor.mjs+++ b/app/test/editor.mjs@@ -248,6 +248,23 @@ try {s = await ed();check('Kaputte PDF: Meldung in der Ansicht, App läuft weiter', !!s.pdf?.error && await ev(() => [...document.querySelectorAll('.pdf-msg')].some((m) => m.offsetParent && m.textContent.includes('cannot be read'))), s.pdf?.error ?? '');+ // 9e) Knopf „Import": wie Ziehen, nur mit Dateidialog. Gleicher Name wird nicht überschrieben, Abbrechen tut nichts+ const extern = path.join(ud, 'skizze.png');+ fs.writeFileSync(extern, 'kein echtes Bild');+ await app.answers([[extern]]);+ await domClick('btn-import');+ const inp = (n) => path.join(proj.dir, 'inputs', n);+ for (let i = 0; i < 20 && !fs.existsSync(inp('skizze.png')); i++) await sleep(150);+ check('„Import": gewählte Datei landet in inputs/', fs.existsSync(inp('skizze.png')));+ await app.answers([[extern]]);+ await domClick('btn-import');+ for (let i = 0; i < 20 && !fs.existsSync(inp('skizze (2).png')); i++) await sleep(150);+ check('„Import" gleicher Name: neue Kopie, nichts überschrieben', fs.existsSync(inp('skizze (2).png')));+ await app.answers([null]);+ await domClick('btn-import');+ await sleep(400);+ check('„Import" abgebrochen: keine weitere Datei', fs.readdirSync(path.join(proj.dir, 'inputs')).filter((n) => n.startsWith('skizze')).length === 2);+// 10) Build-Fehler: „Code öffnen" markiert die Zeile rotawait open('model.py');await replace('LENGTH = param(79.0', 'LENGTH = param(79.0 +');diff --git a/app/test/helpshots-spec.mjs b/app/test/helpshots-spec.mjsindex be1a859..472c32d 100644--- a/app/test/helpshots-spec.mjs+++ b/app/test/helpshots-spec.mjs@@ -14,6 +14,7 @@ export const SHOTS = [{ label: 'Model menu', sel: '#btn-doc', at: 'tr', box: true },{ label: 'Build status', sel: '#build-pill', at: 'b', box: true },{ label: 'Columns', sel: '#layout', at: 'b', box: true },+ { label: 'Import', sel: '#btn-import', at: 'b' },{ label: 'Export', sel: '#btn-export', at: 'b' },{ label: 'Save', sel: '#btn-save', at: 'b' },{ label: 'Sidebar', sel: '#rail', at: 'r', box: true },