@really-knows-ai/foundry 3.3.8 → 3.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -110,6 +110,7 @@ export function createOrchestrateTool({ tool, pending }) {
110
110
  error: tool.schema.string().optional(),
111
111
  }).optional(),
112
112
  cycleDef: tool.schema.string().optional().describe('Test-mode cycle definition override (path to cycle file)'),
113
+ defaultModel: tool.schema.string().optional().describe('Fallback model for stages with no explicit model in the cycle definition (e.g. "opencode-go/deepseek-v4-flash")'),
113
114
  },
114
115
 
115
116
  async execute(args, context) {
@@ -145,6 +146,7 @@ export function createOrchestrateTool({ tool, pending }) {
145
146
  cwd, cycleDef: args.cycleDef, git, mint, finalize,
146
147
  now: () => Date.now(),
147
148
  lastResult: args.lastResult ?? null,
149
+ defaultModel: args.defaultModel,
148
150
  }, io);
149
151
 
150
152
  await injectDispatchPromptExtras(result, cwd);
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.3.9] - 2026-05-19
4
+
5
+ ### Fixed
6
+
7
+ - **Stage model fallback.** When a cycle's `models:` map omits a stage (e.g.,
8
+ `quench`), the orchestrator now falls back to the caller's `defaultModel`,
9
+ then `models.default`, then any available model in the map, instead of
10
+ failing with a hard violation. `foundry_orchestrate` accepts an optional
11
+ `defaultModel` arg for this purpose.
12
+ - **No-models-map fallback.** When the cycle has no `models:` block at all but
13
+ `defaultModel` is provided, the orchestrator uses it — previously returned
14
+ a violation.
15
+
3
16
  ## [3.3.8] - 2026-05-19
4
17
 
5
18
  ### Fixed
@@ -87,6 +87,7 @@ function buildSortArgs(args, now) {
87
87
  mint: args.mint,
88
88
  now: typeof now === 'function' ? now() : now,
89
89
  ulid: args.ulid ?? defaultUlid,
90
+ defaultModel: args.defaultModel,
90
91
  };
91
92
  }
92
93
 
@@ -147,10 +147,26 @@ function resolveRoute(ctx) {
147
147
  return determineRoute(ctx.stages, ctx.history, ctx.feedback, ctx.maxIterations);
148
148
  }
149
149
 
150
- function resolveModel(route, frontmatter, agentsDir, io) {
151
- const routeBase = baseStage(route);
152
- if (!frontmatter.models || !frontmatter.models[routeBase]) return null;
153
- const modelId = frontmatter.models[routeBase];
150
+ function firstModelValue(models) {
151
+ if (!models) return undefined;
152
+ const keys = Object.keys(models);
153
+ return keys.length > 0 ? models[keys[0]] : undefined;
154
+ }
155
+
156
+ function resolveModelId(routeBase, models, defaultModel) {
157
+ return models[routeBase] || defaultModel || models.default || firstModelValue(models);
158
+ }
159
+
160
+ function pickModelId(route, frontmatter, defaultModel) {
161
+ const models = frontmatter.models;
162
+ if (!models) return defaultModel || null;
163
+ return resolveModelId(baseStage(route), models, defaultModel) || null;
164
+ }
165
+
166
+ function resolveModel(route, frontmatter, agentsDir, io, defaultModel) {
167
+ const modelId = pickModelId(route, frontmatter, defaultModel);
168
+ if (!modelId) return null;
169
+
154
170
  const model = `foundry-${modelId.replace(/[/.]/g, '-')}`;
155
171
  const agentPath = `${agentsDir}/${model}.md`;
156
172
  if (!io.exists(agentPath)) {
@@ -162,8 +178,8 @@ function resolveModel(route, frontmatter, agentsDir, io) {
162
178
  return model;
163
179
  }
164
180
 
165
- function checkModel(route, frontmatter, agentsDir, io) {
166
- const modelResult = resolveModel(route, frontmatter, agentsDir, io);
181
+ function checkModel(route, frontmatter, agentsDir, io, defaultModel) {
182
+ const modelResult = resolveModel(route, frontmatter, agentsDir, io, defaultModel);
167
183
  if (modelResult && modelResult.error) return { error: modelResult.error };
168
184
  return { model: typeof modelResult === 'string' ? modelResult : null };
169
185
  }
@@ -217,6 +233,7 @@ const RUN_SORT_DEFAULTS = Object.freeze({
217
233
  historyPath: 'WORK.history.yaml',
218
234
  foundryDir: 'foundry',
219
235
  cycleDef: undefined,
236
+ defaultModel: undefined,
220
237
  agentsDir: '.opencode/agents',
221
238
  mint: undefined,
222
239
  });
@@ -246,7 +263,7 @@ export function runSort(args = {}, io = defaultIO) {
246
263
  if (prep.kind !== 'ok') return { route: prep.kind, details: prep.details };
247
264
 
248
265
  const route = resolveRoute(buildRouteCtx(prep));
249
- const modelCheck = checkModel(route, prep.frontmatter, opts.agentsDir, io);
266
+ const modelCheck = checkModel(route, prep.frontmatter, opts.agentsDir, io, opts.defaultModel);
250
267
  if (modelCheck.error) return { route: 'violation', details: modelCheck.error };
251
268
 
252
269
  return mintToken({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@really-knows-ai/foundry",
3
- "version": "3.3.8",
3
+ "version": "3.3.9",
4
4
  "description": "A skill-driven framework for governed artefact generation with AI coding tools. Define your own artefact types, laws, and flows — Foundry handles the forge → quench → appraise pipeline with deterministic routing, quality gates, and iterative refinement.",
5
5
  "type": "module",
6
6
  "main": "dist/.opencode/plugins/foundry.js",