u1s1-cli 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -23,11 +23,12 @@ u1s1
23
23
  | `u1s1` | 进入交互模式,直接开聊 |
24
24
  | `u1s1 -p "把 README 里的错别字修一下"` | 一句话模式,干完就退出 |
25
25
  | `u1s1 usage` | 看本月额度用了多少 |
26
+ | `u1s1 model` | 看/切模型:`u1s1 model grok` 切 Grok 4.6,`u1s1 model deepseek` 切回 |
26
27
  | `u1s1 login` / `u1s1 logout` | 登录 / 退出 |
27
28
 
28
29
  ## 有一说一
29
30
 
30
- - **背后模型**:DeepSeek V4 Flash,1M 超长上下文,写代码很能打,成本只有大牌模型的约 1/50。
31
+ - **背后模型**:默认 DeepSeek V4 Flash(1M 上下文,便宜大碗);难题可随时 `u1s1 model grok` 切 Grok 4.6(更强,但烧额度快约 20 倍)。对话中用 `/model` 可临时切换。
31
32
  - **怎么收费**:额度按 API 实际成本扣,不加价;每月 1 号自动重置。
32
33
  - **额度不够**:邀请朋友,你俩各得 $1 加量,永不过期 → [u1s1.io/dashboard](https://u1s1.io/dashboard)
33
34
  - **内核**:基于开源的 [pi](https://pi.dev) coding agent,会话管理、斜杠命令、皮肤等能力全都有。
package/dist/config.js CHANGED
@@ -2,8 +2,34 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "n
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  export const DEFAULT_BASE_URL = "https://api.u1s1.io/v1";
5
- export const MODEL_ID = "deepseek/deepseek-v4-flash";
6
5
  export const PROVIDER_ID = "u1s1";
6
+ export const MODELS = [
7
+ {
8
+ id: "deepseek/deepseek-v4-flash",
9
+ name: "DeepSeek V4 Flash (u1s1)",
10
+ aliases: ["deepseek", "flash", "v4-flash"],
11
+ reasoning: false,
12
+ contextWindow: 1_048_576,
13
+ maxTokens: 65_536,
14
+ cost: { input: 0.14, output: 0.28, cacheRead: 0, cacheWrite: 0 },
15
+ note: "默认 · 便宜大碗,日常写代码首选",
16
+ },
17
+ {
18
+ id: "x-ai/grok-4.6",
19
+ name: "Grok 4.6 (u1s1)",
20
+ aliases: ["grok", "grok4.6", "grok-4.6"],
21
+ reasoning: true,
22
+ contextWindow: 500_000,
23
+ maxTokens: 65_536,
24
+ cost: { input: 2, output: 6, cacheRead: 0, cacheWrite: 0 },
25
+ note: "更强 · 但烧额度快约 20 倍,难题再用",
26
+ },
27
+ ];
28
+ export const DEFAULT_MODEL_ID = MODELS[0].id;
29
+ export function resolveModel(nameOrAlias) {
30
+ const q = nameOrAlias.trim().toLowerCase();
31
+ return MODELS.find((m) => m.id.toLowerCase() === q || m.aliases.includes(q));
32
+ }
7
33
  export const u1s1Dir = join(homedir(), ".u1s1");
8
34
  const configFile = join(u1s1Dir, "config.json");
9
35
  /** pi keeps auth/models/settings/sessions under this dir — isolated from any real pi install. */
@@ -21,6 +47,7 @@ export function loadConfig() {
21
47
  return {
22
48
  apiKey: process.env["U1S1_API_KEY"] || file.apiKey,
23
49
  baseUrl: process.env["U1S1_BASE_URL"] || file.baseUrl || DEFAULT_BASE_URL,
50
+ model: file.model && resolveModel(file.model) ? file.model : undefined,
24
51
  };
25
52
  }
26
53
  export function saveConfig(cfg) {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import { createRequire } from "node:module";
5
- import { agentDir, loadConfig, MODEL_ID, PROVIDER_ID } from "./config.js";
5
+ import { agentDir, DEFAULT_MODEL_ID, loadConfig, MODELS, PROVIDER_ID } from "./config.js";
6
6
  const require = createRequire(import.meta.url);
7
7
  const VERSION = require("../package.json").version;
8
8
  const BRAND_APPEND = `## u1s1
@@ -36,23 +36,22 @@ async function runAgent(cfg, args) {
36
36
  baseUrl: cfg.baseUrl,
37
37
  api: "openai-completions",
38
38
  apiKey: "$U1S1_API_KEY",
39
- models: [
40
- {
41
- id: MODEL_ID,
42
- name: "DeepSeek V4 Flash (u1s1)",
43
- reasoning: false,
44
- input: ["text"],
45
- cost: { input: 0.14, output: 0.28, cacheRead: 0, cacheWrite: 0 },
46
- contextWindow: 1_048_576,
47
- maxTokens: 65_536,
48
- },
49
- ],
39
+ models: MODELS.map((m) => ({
40
+ id: m.id,
41
+ name: m.name,
42
+ reasoning: m.reasoning,
43
+ input: ["text"],
44
+ cost: m.cost,
45
+ contextWindow: m.contextWindow,
46
+ maxTokens: m.maxTokens,
47
+ })),
50
48
  });
51
49
  },
52
50
  },
53
51
  ];
54
52
  const hasModelArg = args.some((a) => a === "--model" || a.startsWith("--model=") || a === "--provider");
55
- const finalArgs = hasModelArg ? args : ["--model", `${PROVIDER_ID}/${MODEL_ID}`, ...args];
53
+ const defaultModel = cfg.model ?? DEFAULT_MODEL_ID;
54
+ const finalArgs = hasModelArg ? args : ["--model", `${PROVIDER_ID}/${defaultModel}`, ...args];
56
55
  await main(finalArgs, { extensionFactories: extension });
57
56
  }
58
57
  async function run() {
@@ -72,6 +71,11 @@ async function run() {
72
71
  await usage();
73
72
  return;
74
73
  }
74
+ if (cmd === "model") {
75
+ const { modelCommand } = await import("./model.js");
76
+ await modelCommand(args[1]);
77
+ return;
78
+ }
75
79
  if (cmd === "logout") {
76
80
  const { saveConfig } = await import("./config.js");
77
81
  saveConfig({ ...loadConfig(), apiKey: undefined });
package/dist/model.js ADDED
@@ -0,0 +1,24 @@
1
+ import { DEFAULT_MODEL_ID, loadConfig, MODELS, resolveModel, saveConfig } from "./config.js";
2
+ export async function modelCommand(nameOrAlias) {
3
+ const cfg = loadConfig();
4
+ const current = cfg.model ?? DEFAULT_MODEL_ID;
5
+ if (!nameOrAlias) {
6
+ console.log("");
7
+ for (const m of MODELS) {
8
+ const mark = m.id === current ? "●" : " ";
9
+ console.log(` ${mark} ${m.aliases[0].padEnd(10)} ${m.name}`);
10
+ console.log(` ${m.note} · $${m.cost.input}/$${m.cost.output} 每百万 token`);
11
+ }
12
+ console.log("");
13
+ console.log(" 切换:u1s1 model grok / u1s1 model deepseek(也可在对话里用 /model 临时切)");
14
+ console.log("");
15
+ return;
16
+ }
17
+ const m = resolveModel(nameOrAlias);
18
+ if (!m) {
19
+ console.error(` 没有叫「${nameOrAlias}」的模型,可选:${MODELS.map((x) => x.aliases[0]).join(" / ")}`);
20
+ process.exit(1);
21
+ }
22
+ saveConfig({ ...cfg, model: m.id });
23
+ console.log(` ✓ 默认模型已切到 ${m.name}(${m.note})`);
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u1s1-cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "u1s1 — 有一说一,最省心的 AI 编程搭子。终端里用中文说需求,AI 帮你读文件、改代码、跑命令。",
5
5
  "type": "module",
6
6
  "bin": {