Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): repoint provider pins across all top-level data/*.json
[._.]/ Adam Eivy0593d9cd8116
diff --git a/scripts/migrations/146-claude-ollama-providers.js b/scripts/migrations/146-claude-ollama-providers.jsindex 9a56051f30..cc82d0bafc 100644--- a/scripts/migrations/146-claude-ollama-providers.js+++ b/scripts/migrations/146-claude-ollama-providers.js@@ -27,7 +27,7 @@* existing ones, so deployed installs need this migration to pick up the rename.*/-import { readFile, writeFile } from 'fs/promises';+import { readFile, writeFile, readdir } from 'fs/promises';import { join } from 'path';const PROVIDERS_REL_PATH = 'data/providers.json';@@ -84,17 +84,18 @@ const CLAUDE_OLLAMA_TUI = {tuiIdleTimeoutMs: 180000,};-// Provider pins live OUTSIDE providers.json: scheduled tasks-// (data/task-schedule.json) and autonomous jobs (data/autonomous-jobs.json)-// persist the chosen provider as a `providerId` / `provider` field (including-// nested pipeline stages). Renaming the provider id above would orphan those-// pins — they'd resolve as "provider not found" and silently fall back to the-// active provider instead of the user's local model. So rewrite them too.-// Generic recursive walk keyed on field name + the EXACT old id (no other field-// legitimately holds the literal string "clawed-ollama", so false positives are-// impossible). Idempotent — a second run finds nothing left to rewrite.+// Provider pins live OUTSIDE providers.json in many stores: scheduled tasks+// (task-schedule.json), autonomous jobs (autonomous-jobs.json), and AI-assignment+// settings (settings.json — autofixer/calendarSync/etc. `providerId`, resolved by+// pickCliProvider) all persist the chosen provider as a `providerId` / `provider`+// field (including nested pipeline stages). Renaming the provider id above would+// orphan those pins — they'd resolve as "provider not found" and silently fall+// back to the active provider instead of the user's local model. Rather than+// enumerate every store, scan ALL top-level data/*.json generically (see+// rewriteDataJsonPins) — a recursive walk keyed on field name + the EXACT old id+// (no other field legitimately holds the literal string "clawed-ollama", so+// false positives are impossible). Idempotent — a second run finds nothing left.const PIN_KEYS = new Set(['providerId', 'provider']);-const PIN_FILES = ['data/task-schedule.json', 'data/autonomous-jobs.json'];function rewriteProviderPins(node) {let changed = false;@@ -158,6 +159,25 @@ async function rewritePinFile(rootDir, relPath) {}}+// Scan every TOP-LEVEL data/*.json for orphaned pins. Deliberately NOT recursive+// into subdirectories: data/cos/worktrees/ holds full git checkouts of the repo+// (source that legitimately contains the "clawed-ollama" string), and data/cos/+// agent records are run history, not re-resolved pins — rewriting either would+// corrupt working copies / falsify history. providers.json is skipped here (its+// registry id + activeProvider/fallbackProvider are handled in up()).+async function rewriteDataJsonPins(rootDir) {+ const dataDir = join(rootDir, 'data');+ const entries = await readdir(dataDir, { withFileTypes: true }).catch((err) => {+ if (err.code === 'ENOENT') return [];+ throw err;+ });+ for (const entry of entries) {+ if (!entry.isFile() || !entry.name.endsWith('.json')) continue;+ if (entry.name === 'providers.json') continue;+ await rewritePinFile(rootDir, `data/${entry.name}`);+ }+}+export default {async up({ rootDir }) {const providersPath = join(rootDir, PROVIDERS_REL_PATH);@@ -232,9 +252,7 @@ export default {// Repoint persisted provider pins (schedules / autonomous jobs) off the// retired id — runs regardless of whether providers.json changed this run,// since a pin can outlive the provider entry (e.g. already removed by hand).- for (const relPath of PIN_FILES) {- await rewritePinFile(rootDir, relPath);- }+ await rewriteDataJsonPins(rootDir);for (const relPath of PIN_TEXT_FILES) {await rewritePinTextFile(rootDir, relPath);}diff --git a/scripts/migrations/146-claude-ollama-providers.test.js b/scripts/migrations/146-claude-ollama-providers.test.jsindex 7c351b54c3..15ad146310 100644--- a/scripts/migrations/146-claude-ollama-providers.test.js+++ b/scripts/migrations/146-claude-ollama-providers.test.js@@ -219,6 +219,40 @@ describe('migration 146 — Claude Ollama providers', () => {expect(readFileSync(tasksPath, 'utf-8')).toBe(before);});+ it('repoints clawed-ollama pins in any top-level data/*.json (settings AI assignments, etc.)', async () => {+ writeJson(providersPath, { providers: { 'clawed-ollama': clawed() } });+ const settingsPath = join(rootDir, 'data/settings.json');+ const arbitraryPath = join(rootDir, 'data/some-other-feature.json');+ writeJson(settingsPath, {+ autofixer: { providerId: 'clawed-ollama' },+ calendarSync: { providerId: 'clawed-ollama' },+ unrelated: { providerId: 'codex' },+ });+ writeJson(arbitraryPath, { nested: { deep: [{ provider: 'clawed-ollama' }] } });++ await migration.up({ rootDir });++ const settings = readJson(settingsPath);+ expect(settings.autofixer.providerId).toBe('claude-ollama');+ expect(settings.calendarSync.providerId).toBe('claude-ollama');+ expect(settings.unrelated.providerId).toBe('codex');+ expect(readJson(arbitraryPath).nested.deep[0].provider).toBe('claude-ollama');+ });++ it('does not recurse into data/ subdirectories (e.g. cos worktrees with source)', async () => {+ writeJson(providersPath, { providers: { 'clawed-ollama': clawed() } });+ // a nested store (subdir) that legitimately contains the slug must be left alone+ const worktreeJsonDir = join(rootDir, 'data/cos/worktrees/agent-x');+ mkdirSync(worktreeJsonDir, { recursive: true });+ const nestedPath = join(worktreeJsonDir, 'config.json');+ writeJson(nestedPath, { providerId: 'clawed-ollama' });+ const before = readFileSync(nestedPath, 'utf-8');++ await migration.up({ rootDir });++ expect(readFileSync(nestedPath, 'utf-8')).toBe(before);+ });+it('leaves pin files untouched when they have no clawed-ollama references', async () => {writeJson(providersPath, { providers: { 'claude-code': { id: 'claude-code', type: 'cli', command: 'claude' } } });const schedulePath = join(rootDir, 'data/task-schedule.json');