@4yi/cli 0.1.7 → 0.1.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/opencode.mjs +14 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4yi/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "4YI command-line launcher for OAuth login and OpenCode runtime",
5
5
  "type": "module",
6
6
  "bin": {
package/src/opencode.mjs CHANGED
@@ -10,6 +10,7 @@ const DEFAULT_CONTEXT_LIMIT = 200000;
10
10
  const DEFAULT_OUTPUT_LIMIT = 8192;
11
11
 
12
12
  function isClaudeModel(model) {
13
+ if (model?.family === "claude") return true;
13
14
  const id = model?.id || "";
14
15
  const name = model?.display_name || "";
15
16
  return /claude/i.test(id) || /claude/i.test(name);
@@ -23,14 +24,23 @@ function modelOutputLimit(model) {
23
24
  return model.output_limit || model.max_output_tokens || model.max_tokens || DEFAULT_OUTPUT_LIMIT;
24
25
  }
25
26
 
27
+ function modelPickerName(model) {
28
+ const displayName = model.display_name || model.id;
29
+ if (model.family === "claude") {
30
+ return `Claude · ${displayName.replace(/^(?:anthropic[ ._-]*)?claude[ ._-]*/i, "")}`;
31
+ }
32
+ if (model.family === "codex") return `Codex · ${displayName}`;
33
+ return displayName;
34
+ }
35
+
26
36
  export function buildOpenCodeConfig({ modelConfig, preferredModel = null, tokenEnv = "FOURYI_CLI_TOKEN", orgEnv = "FOURYI_ORG_ID" }) {
27
- // Register EVERY model the server returned so OpenCode's native switcher
28
- // (`Tab` / `/models`) can move between them. Claude stays the default.
37
+ // Register every server-approved coding model so OpenCode's native switcher
38
+ // (`Tab` / `/models`) can move between Claude and Codex. Claude stays the default.
29
39
  const list = modelConfig.models || [];
30
40
  const models = {};
31
41
  for (const model of list) {
32
42
  const entry = {
33
- name: model.display_name || model.id,
43
+ name: modelPickerName(model),
34
44
  limit: {
35
45
  context: modelContextLimit(model),
36
46
  output: modelOutputLimit(model),
@@ -111,7 +121,7 @@ export function ensureOpenCodeRuntime({ home = os.homedir(), stdout = console.lo
111
121
 
112
122
  export async function runCode({ session, home = os.homedir(), argv = [], stdout = console.log, preferredModel = null } = {}) {
113
123
  if (!session?.token) throw new Error("Not signed in. Run `4yi login`.");
114
- const modelConfig = await requestJson(session.baseUrl, "/api/cli/models", { token: session.token });
124
+ const modelConfig = await requestJson(session.baseUrl, "/api/cli/models?runtime=opencode", { token: session.token });
115
125
  const list = modelConfig.models || [];
116
126
  if (list.length === 0) throw new Error("No chat models available for this organization.");
117
127