@really-knows-ai/foundry 3.3.7 → 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,10 +110,11 @@ 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) {
116
- const { runOrchestrate } = await import('../../scripts/orchestrate.js');
117
+ const { runOrchestrate } = await import('../../../scripts/orchestrate.js');
117
118
  const io = makeIO(context.worktree);
118
119
  const cwd = context.worktree;
119
120
  const secret = readOrCreateSecret(context.worktree);
@@ -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,30 @@
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
+
16
+ ## [3.3.8] - 2026-05-19
17
+
18
+ ### Fixed
19
+
20
+ - **Build script now rewrites dynamic `import()` paths.** The `rewriteImports`
21
+ function only handled static `from '...'` imports, missing `await import()`
22
+ calls in `orchestrate-tool.js`. Added a second regex pass for dynamic imports.
23
+ - **New packaging test** verifies every relative import in `dist/` resolves.
24
+ - **add-flow now offers next steps after building.** After creating a flow on a
25
+ `config/*` branch, the skill presents dry-run / merge / leave options instead
26
+ of telling the LLM to auto-merge.
27
+
3
28
  ## [3.3.7] - 2026-05-18
4
29
 
5
30
  ### 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({
@@ -145,7 +145,17 @@ After all dependencies are built, create the flow itself:
145
145
 
146
146
  If the tool returns `{ ok: false, errors }` because the target file already exists, read the existing flow file, incorporate the user's requested changes into the current body, propose the merged result for review, then write and commit the updated file.
147
147
 
148
- 3. **Report**: Show the user the flow file and the commit hash. Also summarise each dependency that was created, with its commit hash. Tell the user they can now ask the Foundry agent to run the flow.
148
+ 3. **Report and offer next steps**: Show the user the flow file and the commit hash. Summarise each dependency that was created, with its commit hash. Then present these options:
149
+
150
+ > The flow is built on the `config/*` branch. Before merging to main, you can:
151
+ >
152
+ > 1. **Dry-run the flow** — test it safely from the config branch without touching main. I'll run a dry-run: `dry-run/haiku-flow/01`.
153
+ > 2. **Merge to main** — commit the configuration and make the flow available for normal runs.
154
+ > 3. **Leave it on this branch** — you can review the configuration or come back later.
155
+ >
156
+ > Which would you like?
157
+
158
+ Do NOT automatically merge or call `foundry_git_finish` unless the user explicitly asks for it.
149
159
 
150
160
  ## Safety Rules
151
161
 
@@ -153,3 +163,4 @@ After all dependencies are built, create the flow itself:
153
163
  - Do not skip dependency validation.
154
164
  - Do not expose internal tool-call syntax to the user.
155
165
  - Do not continue when a branch or worktree state could overwrite user changes.
166
+ - Do not merge or call `foundry_git_finish` unless the user explicitly asks — always offer to dry-run first.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@really-knows-ai/foundry",
3
- "version": "3.3.7",
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",