From bf74f02420c9cf3d6f59e8972eed4a12e59eb7c4 Mon Sep 17 00:00:00 2001 From: "shumeiko.it" Date: Sun, 1 Nov 2026 11:15:37 +0100 Subject: [PATCH] fix: ship capability packs and starter skills, report the usable model (UF-066, UF-067) The SDK reads pack manifests and starter skills next to its own module, which in the bundle is service.js, and no build step copied them there: installed builds showed no packs and no starter skills. build-sidecar now copies both folders next to service.js and Tauri bundles them (UF-066). GET /api/agent/status returned the configured model even when it had no key, so the status bar named Claude while chats ran on the local model. It now resolves the model the way the chat route does (UF-067). --- .gitignore | 3 +++ app/src-tauri/tauri.conf.json | 2 +- docs/oss/upstream-fixes.md | 20 ++++++++++++++++++ packages/sdk/src/capability-packs/index.ts | 17 +++++++++------ packages/sdk/src/starter-skills/index.ts | 18 +++++++++------- packages/server/src/local/routes/agent.ts | 10 ++++++++- packages/server/tests/litellm-api.test.ts | 24 ++++++++++++++++++++++ packages/server/tests/tauri-config.test.ts | 9 ++++++++ scripts/build-sidecar.mjs | 14 +++++++++++++ 9 files changed, 102 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 68888b0..aa98f84 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,9 @@ scripts/.cache/ app/src-tauri/resources/node app/src-tauri/resources/node.exe app/src-tauri/resources/native/ +# Copied from packages/sdk/src by scripts/build-sidecar.mjs +app/src-tauri/resources/capability-packs/ +app/src-tauri/resources/starter-skills/ # D12: the bundled sidecar is generated by scripts/build-sidecar.mjs on every # build path (npm tauri:build*, CI, and the tauri.conf.json beforeBuildCommand # hook). A committed copy goes stale silently — a binary shipping an old server diff --git a/app/src-tauri/tauri.conf.json b/app/src-tauri/tauri.conf.json index b848cdb..b17745a 100644 --- a/app/src-tauri/tauri.conf.json +++ b/app/src-tauri/tauri.conf.json @@ -13,7 +13,7 @@ "icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico", "icons/icon.png"], "active": true, "targets": "all", - "resources": ["resources/*", "resources/native/*", "resources/native/onnxruntime/*", "resources/node_modules/**/*"], + "resources": ["resources/*", "resources/capability-packs/*", "resources/starter-skills/*", "resources/native/*", "resources/native/onnxruntime/*", "resources/node_modules/**/*"], "windows": { "nsis": { "installerHooks": "nsis/installer.nsi", diff --git a/docs/oss/upstream-fixes.md b/docs/oss/upstream-fixes.md index e51afa0..54f788b 100644 --- a/docs/oss/upstream-fixes.md +++ b/docs/oss/upstream-fixes.md @@ -94,6 +94,8 @@ Baseline: commit `b20b138` of the main Waggle repository. | UF-063 | `/config` and `/preferences` never run `/settings` | Fixed | Agent, commands | | UF-064 | Pins and documents ignore the configured data directory | Fixed | Sidecar | | UF-065 | The Windows uninstaller names a "Data & Privacy" settings page that does not exist | Fixed | Desktop, Windows installer | +| UF-066 | Installed builds have no capability packs and no starter skills | Fixed | Sidecar bundle, SDK | +| UF-067 | The status bar names a default model that chats cannot use | Fixed | Sidecar, Web UI | ## Entries @@ -655,3 +657,21 @@ Entries UF-010 to UF-019 come from the UI audit `anti-slop/audit-001-2026-10-14. - Cause: the copy predates the current Settings layout; the erase action is the "Erase all my data" button on Settings → General. - What we did: the message now names Settings > General > Erase all my data. - Recommendation: same change in the main project. + +### UF-066. Installed builds have no capability packs and no starter skills +- Status: Fixed +- Found: 2026-11-01 +- Where: at commit `b20b138`, `packages/sdk/src/capability-packs/index.ts` (`getCapabilityPacksDir`), `packages/sdk/src/starter-skills/index.ts` (`getStarterSkillsDir`), `scripts/build-sidecar.mjs` +- Symptom: in the packaged desktop app, Skills Hub → Packs says "No catalog packs found" and no starter skill can be installed; running from source shows five packs and 18 starter skills. +- Cause: the SDK reads the pack manifests (`*.json`) and starter skills (`*.md`) from disk next to its own module. esbuild inlines the SDK into `service.js`, so that directory is the resources folder, and no build step copies the files there. +- What we did: `build-sidecar.mjs` copies both folders next to `service.js`, the SDK also looks in `/capability-packs` and `/starter-skills`, and `tauri.conf.json` bundles the two folders. +- Recommendation: same change in the main project, or embed the manifests and skills in the bundle as JSON imports. + +### UF-067. The status bar names a default model that chats cannot use +- Status: Fixed +- Found: 2026-11-01 +- Where: at commit `b20b138`, `packages/server/src/local/routes/agent.ts` (`GET /api/agent/status`) +- Symptom: with no provider key and a local model installed, the status bar says "Default model: Claude Sonnet 4.6" after every restart, while chats answer with the local model. +- Cause: the chat route resolves the configured model to a usable one (`resolveUsableModel`), but the status endpoint returns the configured model as is. +- What we did: the status endpoint resolves the model the same way, without changing the configured one. A test covers it. +- Recommendation: same change in the main project. diff --git a/packages/sdk/src/capability-packs/index.ts b/packages/sdk/src/capability-packs/index.ts index 669a6c2..eceb913 100644 --- a/packages/sdk/src/capability-packs/index.ts +++ b/packages/sdk/src/capability-packs/index.ts @@ -12,14 +12,19 @@ export interface CapabilityPack { } /** - * Get the directory containing capability pack JSON manifests. - * Resolves to the source directory containing .json files. + * Get the directory containing capability pack JSON manifests: the package's + * src/ when running from src/ or dist/, or the `capability-packs` folder that + * scripts/build-sidecar.mjs copies next to the bundled service.js. */ export function getCapabilityPacksDir(): string { - // When running from compiled output (dist/), go up to package root then into src/ - const srcDir = path.resolve(__dirname, '..', '..', 'src', 'capability-packs'); - if (fs.existsSync(srcDir) && fs.readdirSync(srcDir).some(f => f.endsWith('.json'))) { - return srcDir; + const candidates = [ + path.resolve(__dirname, '..', '..', 'src', 'capability-packs'), + path.join(__dirname, 'capability-packs'), + ]; + for (const dir of candidates) { + if (fs.existsSync(dir) && fs.readdirSync(dir).some(f => f.endsWith('.json'))) { + return dir; + } } // Fallback: same directory (running directly from source) return __dirname; diff --git a/packages/sdk/src/starter-skills/index.ts b/packages/sdk/src/starter-skills/index.ts index 708acd7..6263961 100644 --- a/packages/sdk/src/starter-skills/index.ts +++ b/packages/sdk/src/starter-skills/index.ts @@ -5,15 +5,19 @@ import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** - * Get the directory containing starter skill files. - * Resolves to the source directory containing .md files. + * Get the directory containing starter skill files: the package's src/ when + * running from src/ or dist/, or the `starter-skills` folder that + * scripts/build-sidecar.mjs copies next to the bundled service.js. */ export function getStarterSkillsDir(): string { - // When running from compiled output (dist/), go up to package root then into src/ - // When running from source (src/), we're already in the right place - const srcDir = path.resolve(__dirname, '..', '..', 'src', 'starter-skills'); - if (fs.existsSync(srcDir) && fs.readdirSync(srcDir).some(f => f.endsWith('.md'))) { - return srcDir; + const candidates = [ + path.resolve(__dirname, '..', '..', 'src', 'starter-skills'), + path.join(__dirname, 'starter-skills'), + ]; + for (const dir of candidates) { + if (fs.existsSync(dir) && fs.readdirSync(dir).some(f => f.endsWith('.md'))) { + return dir; + } } // Fallback: same directory (running directly from source) return __dirname; diff --git a/packages/server/src/local/routes/agent.ts b/packages/server/src/local/routes/agent.ts index b4f95b0..f87fc64 100644 --- a/packages/server/src/local/routes/agent.ts +++ b/packages/server/src/local/routes/agent.ts @@ -32,9 +32,17 @@ export const agentRoutes: FastifyPluginAsync = async (server) => { // GET /api/agent/status — agent status including cost stats server.get('/api/agent/status', async () => { const stats = costTracker.getStats(); + // Report the model a chat will run on: chat.ts resolves the configured + // model the same way, so without a provider key this is the local model. + let model = server.agentState.currentModel; + try { + model = await resolveUsableModel(server, model); + } catch { + // Nothing usable yet; show the configured model. + } return { running: true, - model: server.agentState.currentModel, + model, tokensUsed: stats.totalInputTokens + stats.totalOutputTokens, estimatedCost: stats.estimatedCost, turns: stats.turns, diff --git a/packages/server/tests/litellm-api.test.ts b/packages/server/tests/litellm-api.test.ts index 91c7d10..c2a0d5e 100644 --- a/packages/server/tests/litellm-api.test.ts +++ b/packages/server/tests/litellm-api.test.ts @@ -432,6 +432,30 @@ describe('LiteLLM Management API', () => { expect(body.model).toBe('ollama/llama3.2:latest'); }); + it('GET /api/agent/status reports the model chats will use, not an unusable default (UF-067)', async () => { + vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => { + const url = String(input); + if (url.endsWith('/api/tags')) { + return { + ok: true, + json: async () => ({ models: [{ name: 'llama3.2:latest', size: 2_000_000_000 }] }), + } as Response; + } + return { ok: false, status: 503 } as Response; + }); + const priorCurrentModel = server.agentState.currentModel; + // As after a restart: the configured default has no key and nothing resolved it yet. + server.agentState.currentModel = 'claude-sonnet-4-6'; + try { + const res = await injectWithAuth(server, { method: 'GET', url: '/api/agent/status' }); + expect(res.statusCode).toBe(200); + expect(JSON.parse(res.body).model).toBe('ollama/llama3.2:latest'); + expect(server.agentState.currentModel).toBe('claude-sonnet-4-6'); + } finally { + server.agentState.currentModel = priorCurrentModel; + } + }); + it('prefers a deterministic credentialed cloud fallback over an unrelated host Ollama model', async () => { const runtimePath = path.join(dataDir, 'litellm.runtime.json'); const priorRuntime = fs.existsSync(runtimePath) ? fs.readFileSync(runtimePath, 'utf-8') : null; diff --git a/packages/server/tests/tauri-config.test.ts b/packages/server/tests/tauri-config.test.ts index 51031ae..3107949 100644 --- a/packages/server/tests/tauri-config.test.ts +++ b/packages/server/tests/tauri-config.test.ts @@ -213,6 +213,9 @@ describe('Tauri Production Configuration', () => { it('tauri.conf.json bundles resources directory', () => { const conf = JSON.parse(fs.readFileSync(path.join(TAURI_DIR, 'tauri.conf.json'), 'utf-8')); expect(conf.bundle.resources).toContain('resources/*'); + // UF-066: the bundled SDK reads these next to service.js. + expect(conf.bundle.resources).toContain('resources/capability-packs/*'); + expect(conf.bundle.resources).toContain('resources/starter-skills/*'); }); it('tauri.conf.json has correct window settings', () => { @@ -479,6 +482,8 @@ describe('Tauri Production Configuration', () => { ['package-lock.json', '{"lockfileVersion":3}\n'], ['package.json', '{"name":"sidecar-tsconfig-fixture","private":true}\n'], ['packages/marketplace/marketplace.db', 'fixture database'], + ['packages/sdk/src/capability-packs/research-workflow.json', '{"id":"research-workflow"}\n'], + ['packages/sdk/src/starter-skills/brainstorm.md', '# Brainstorm\n'], ['packages/server/package.json', '{"name":"@waggle/server"}\n'], ['packages/server/src/local/service.ts', 'export const fixture = true;\n'], ['packages/server/tsconfig.json', '{"extends":"../../tsconfig.base"}\n'], @@ -566,6 +571,10 @@ describe('Tauri Production Configuration', () => { trackedFiles.get('packages/marketplace/marketplace.db')!, ); expect(fs.readFileSync(marketplaceResourcePath)).toEqual(committedMarketplace); + // UF-066: the SDK reads packs and starter skills next to service.js. + const resourcesRoot = path.join(fixtureRoot, 'app', 'src-tauri', 'resources'); + expect(fs.existsSync(path.join(resourcesRoot, 'capability-packs', 'research-workflow.json'))).toBe(true); + expect(fs.existsSync(path.join(resourcesRoot, 'starter-skills', 'brainstorm.md'))).toBe(true); fs.writeFileSync(marketplacePath, 'dirty worktree database'); const dirtyMarketplaceResult = runResult( diff --git a/scripts/build-sidecar.mjs b/scripts/build-sidecar.mjs index 135dc2b..64a0e52 100644 --- a/scripts/build-sidecar.mjs +++ b/scripts/build-sidecar.mjs @@ -298,6 +298,20 @@ try { fs.rmSync(marketplaceTemp, { force: true }); } console.log('[build-sidecar] Copied canonical marketplace.db'); + + // @waggle/sdk reads its capability packs and starter skills from disk, next + // to its own module. In the bundle that module is service.js, so the files + // go next to it (getCapabilityPacksDir, getStarterSkillsDir). + for (const [name, extension] of [['capability-packs', '.json'], ['starter-skills', '.md']]) { + const source = path.join(root, 'packages', 'sdk', 'src', name); + const target = path.join(resourcesDir, name); + fs.rmSync(target, { recursive: true, force: true }); + if (!fs.existsSync(source)) continue; + fs.mkdirSync(target, { recursive: true }); + const files = fs.readdirSync(source).filter((file) => file.endsWith(extension)); + for (const file of files) fs.copyFileSync(path.join(source, file), path.join(target, file)); + console.log(`[build-sidecar] Copied ${files.length} ${name} files`); + } } catch (err) { console.error('[build-sidecar] Build failed:', err.message); process.exit(1);