clanka 0.15.1 → 0.16.1

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.
package/src/cli.ts CHANGED
@@ -106,14 +106,19 @@ const selectModel = Effect.fnUntraced(function* (provider: Provider) {
106
106
 
107
107
  const isProvider = Schema.is(ModelsRepo.Provider)
108
108
 
109
- // `<provider>/<model>/<effort>` as accepted by the `acp` --model flag.
109
+ const isThoughtLevel = Schema.is(Acp.ThoughtLevel)
110
+
111
+ // `<provider>/<model>[/<effort>]` as accepted by the `acp` --model flag.
110
112
  const parseModelId = (modelId: string) => {
111
113
  const [provider, model, effort, ...rest] = modelId.split("/")
112
114
  return isProvider(provider) &&
113
115
  model !== undefined &&
114
- Schema.is(Acp.ThoughtLevel)(effort) &&
116
+ (effort === undefined || isThoughtLevel(effort)) &&
115
117
  rest.length === 0
116
- ? Option.some({ model: `${provider}:${model}`, thoughtLevel: effort })
118
+ ? Option.some({
119
+ model: `${provider}:${model}`,
120
+ thoughtLevel: Option.fromUndefinedOr(effort),
121
+ })
117
122
  : Option.none()
118
123
  }
119
124
 
@@ -122,7 +127,7 @@ const ModelId = Schema.String.pipe(
122
127
  Schema.makeFilter(
123
128
  (modelId: string) =>
124
129
  Option.isSome(parseModelId(modelId)) ||
125
- `Invalid model "${modelId}", expected <provider>/<model>/<effort> with effort one of ${Acp.ThoughtLevel.literals.join(", ")}`,
130
+ `Invalid model "${modelId}", expected <provider>/<model>[/<effort>] with effort one of ${Acp.ThoughtLevel.literals.join(", ")}`,
126
131
  ),
127
132
  ),
128
133
  )
@@ -283,10 +288,10 @@ const Search = (directory: string) =>
283
288
  const acpModel = Flag.String("model").pipe(
284
289
  Flag.withAlias("m"),
285
290
  Flag.withDescription(
286
- "Default model as <provider>/<model>/<effort>, e.g. openai/gpt-6-astra/medium",
291
+ "Default model as <provider>/<model>[/<effort>], e.g. openai/gpt-6-astra/medium. Without an effort, uses CLANKA_REASONING, or medium.",
287
292
  ),
288
293
  Flag.withSchema(ModelId),
289
- Flag.withDefault("openai/gpt-6-astra/medium"),
294
+ Flag.withDefault("openai/gpt-6-astra"),
290
295
  Flag.map((modelId) => Option.getOrThrow(parseModelId(modelId))),
291
296
  )
292
297
 
@@ -299,6 +304,12 @@ const trustAllTools = Flag.Boolean("trust-all-tools").pipe(
299
304
  Flag.withDefault(false),
300
305
  )
301
306
 
307
+ // The effort for an `acp` --model without one. Read even when --model has an
308
+ // effort, so an invalid value always fails startup.
309
+ const reasoning = Config.schema(Acp.ThoughtLevel, "CLANKA_REASONING").pipe(
310
+ Config.withDefault("medium"),
311
+ )
312
+
302
313
  const acp = Command.make("acp", {
303
314
  model: acpModel,
304
315
  trustAllTools,
@@ -313,10 +324,14 @@ const acp = Command.make("acp", {
313
324
  Command.withHandler(({ model, fast, apiKey, apiUrl }) =>
314
325
  Effect.gen(function* () {
315
326
  const repo = yield* ModelsRepo.ModelsRepo
327
+ const defaultThoughtLevel = yield* reasoning
316
328
  return yield* Acp.runStdio({
317
329
  version,
318
330
  defaultModel: model.model,
319
- defaultThoughtLevel: model.thoughtLevel,
331
+ defaultThoughtLevel: Option.getOrElse(
332
+ model.thoughtLevel,
333
+ () => defaultThoughtLevel,
334
+ ),
320
335
  defaultFastMode: fast,
321
336
  supportsFastMode: ModelLayer.acpSupportsFastMode,
322
337
  availableModels: Effect.map(repo.models, ModelLayer.acpModels),