@xcompiler/cli 0.2.2 → 0.2.3

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.
@@ -0,0 +1,149 @@
1
+ # OpenRouter Free Mode Guide
2
+
3
+ XCompiler defaults to OpenRouter Free mode through an OpenAI-compatible `/v1` endpoint.
4
+ The provider must declare `type: openai`; the provider name is only an identifier and is not used to infer the API protocol.
5
+
6
+ Official references:
7
+
8
+ - OpenRouter Quickstart: https://openrouter.ai/docs/quickstart
9
+ - API reference: https://openrouter.ai/docs/api_reference/overview
10
+ - Free model catalog: https://openrouter.ai/models?max_price=0
11
+ - API keys: https://openrouter.ai/settings/keys
12
+
13
+ ## 1. Create Local Environment
14
+
15
+ From a source checkout:
16
+
17
+ ```bash
18
+ cp .env.example .env
19
+ cp config.example.yaml config.yaml
20
+ ```
21
+
22
+ From the published npm package:
23
+
24
+ ```bash
25
+ npm install -g @xcompiler/cli
26
+ cp "$(npm root -g)/@xcompiler/cli/.env.example" .env
27
+ cp "$(npm root -g)/@xcompiler/cli/config.example.yaml" config.yaml
28
+ ```
29
+
30
+ Edit `.env` locally:
31
+
32
+ ```bash
33
+ OPENROUTER_API_KEY=<your-openrouter-api-key>
34
+ OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
35
+ OPENROUTER_MODEL=openrouter/free
36
+ ```
37
+
38
+ `.env` is ignored by git. Do not commit real API keys.
39
+ `config.yaml` and `llm_scores.yaml` are local runtime files; keep them outside commits. The package ships `config.example.yaml` and `.env.example` only as templates.
40
+
41
+ ## 2. Configure XCompiler
42
+
43
+ `config.example.yaml` already uses OpenRouter Free mode by default:
44
+
45
+ ```yaml
46
+ llm:
47
+ default: openrouter_free
48
+ providers:
49
+ openrouter_free:
50
+ type: openai
51
+ api_key: ${OPENROUTER_API_KEY}
52
+ base_url: https://openrouter.ai/api/v1
53
+ model: openrouter/free
54
+ tags: [cluster]
55
+ request_timeout_ms: 900000
56
+ stream_idle_timeout_ms: 300000
57
+ roles:
58
+ Planner: [openrouter_free]
59
+ Architect: [openrouter_free]
60
+ Coder: [openrouter_free]
61
+ Tester: [openrouter_free]
62
+ Debugger: [openrouter_free]
63
+ cluster_score_min: 0.2
64
+ cluster_score_max: 0.5
65
+ ```
66
+
67
+ `type: openai` means XCompiler will use the OpenAI-compatible chat completions client. This is also the correct type for local `/v1` endpoints such as vLLM or mlx-server.
68
+ `tags: [cluster]` marks the provider as an aggregated route. XCompiler scores those providers in a lower default band (`0.2..0.5`) so they behave as backups rather than replacing dedicated role models too early.
69
+ OpenRouter requires `OPENROUTER_API_KEY`. Local OpenAI-compatible endpoints may leave `api_key` empty when they run without authentication.
70
+
71
+ If an OpenAI-compatible request fails, XCompiler reports the provider, model, base URL, request mode, HTTP status/body when available, and a concrete hint such as setting `OPENROUTER_API_KEY`, changing `json_response_format`, checking quota/rate limits, or switching provider.
72
+
73
+ ## 3. Choose A Free Model
74
+
75
+ OpenRouter free models normally use model ids ending with `:free`.
76
+ Browse https://openrouter.ai/models?max_price=0, copy the model slug, and set:
77
+
78
+ ```yaml
79
+ providers:
80
+ openrouter_coder:
81
+ type: openai
82
+ api_key: ${OPENROUTER_API_KEY}
83
+ base_url: https://openrouter.ai/api/v1
84
+ model: qwen/qwen3-coder:free
85
+ openrouter_free:
86
+ type: openai
87
+ api_key: ${OPENROUTER_API_KEY}
88
+ base_url: https://openrouter.ai/api/v1
89
+ model: openrouter/free
90
+ tags: [cluster]
91
+ ```
92
+
93
+ If one free model returns quota, availability, or capability errors, pick another free model slug and rerun the task.
94
+
95
+ ## 4. Engineering Recommendation
96
+
97
+ For real development runs, avoid relying on a single aggregated route as the only model. Use a role-specific primary model, then append `openrouter_free` as the last fallback for every role:
98
+
99
+ ```yaml
100
+ roles:
101
+ Planner: [openrouter_planner, openrouter_free]
102
+ Architect: [openrouter_architect, openrouter_free]
103
+ Coder: [openrouter_coder, openrouter_free]
104
+ Tester: [openrouter_tester, openrouter_free]
105
+ Debugger: [openrouter_debugger, openrouter_free]
106
+ ```
107
+
108
+ Keep the default cluster score band (`cluster_score_min: 0.2`, `cluster_score_max: 0.5`) when `openrouter/free` is a safety net. Raise `cluster_score_max` toward `1.0` only when you intentionally want the aggregated route to compete with dedicated models.
109
+
110
+ ## 5. Optional Local Backups
111
+
112
+ Local OpenAI-compatible endpoints:
113
+
114
+ ```yaml
115
+ local_openai:
116
+ type: openai
117
+ api_key: ${LOCAL_OPENAI_API_KEY}
118
+ base_url: ${LOCAL_OPENAI_BASE_URL}
119
+ model: ${LOCAL_OPENAI_MODEL}
120
+ ```
121
+
122
+ For no-auth local servers, set `LOCAL_OPENAI_API_KEY=` or leave the provider `api_key` empty.
123
+
124
+ Ollama native endpoints:
125
+
126
+ ```yaml
127
+ ollama_code:
128
+ type: ollama
129
+ base_url: ${OLLAMA_BASE_URL}
130
+ model: ${OLLAMA_CODE_MODEL}
131
+ think: false
132
+ ```
133
+
134
+ Add backups to `roles` or `fallbacks` only after the provider block is enabled.
135
+
136
+ ## 6. Validate
137
+
138
+ ```bash
139
+ npm run typecheck
140
+ npm test
141
+ xcompiler doctor
142
+ ```
143
+
144
+ For a direct endpoint check:
145
+
146
+ ```bash
147
+ curl https://openrouter.ai/api/v1/models \
148
+ -H "Authorization: Bearer $OPENROUTER_API_KEY"
149
+ ```
@@ -24,10 +24,22 @@ npm run version:sync
24
24
 
25
25
  # 设置下一个核心版本并同步全部位置
26
26
  npm run version:set -- 0.1.4
27
+
28
+ # 准备一次本地发版(不 push)
29
+ npm run release:local -- v0.1.4
27
30
  ```
28
31
 
29
32
  核心版本遵循 SemVer。发布 tag 必须是 `v<package version>`,例如 `v0.1.3`;Release workflow 会在测试和打包前强制校验,版本不一致时停止发布。二进制分发包内包含 `VERSION` 文件,CLI 的 `--version` 也读取同一个生成常量。
30
33
 
34
+ `release:local` 会要求工作区干净,然后同步 `package.json`、`package-lock.json` 与 `src/version.ts`,执行本地发版门禁(`version:check`、`npm audit --omit=dev`、`typecheck`、`lint`、`test`、`build`、`npm pack --dry-run`),提交 `chore: release <tag>`,并创建本地 annotated tag。它不会 push;完成后手工执行:
35
+
36
+ ```bash
37
+ git push origin <branch>
38
+ git push origin <tag>
39
+ ```
40
+
41
+ 如果上一次本地 tag 创建错了但还没有推送远端,可使用 `npm run release:local -- v0.1.4 --replace-local-tag` 删除并重建本地 tag;该选项不会删除远端 tag。离线环境可加 `--skip-audit` 跳过本地 `npm audit`,但 GitHub Release workflow 仍会执行审计。
42
+
31
43
  Plugin API 版本独立于核心版本,只在插件公共接口出现不兼容修改时递增整数主版本。插件自身使用 SemVer,并在 manifest 中强制声明 `apiVersion` 和 `minXCompilerVersion`;详细规则见 [plugin_api.md](plugin_api.md)。
32
44
 
33
45
  审计内容默认使用 `redacted` 模式遮蔽 API key、token、密码等凭据。需要最小化留存时设置 `XC_AUDIT_CONTENT_MODE=metadata`(只保留长度和 SHA-256);只有在受控环境确实需要完整回放时才使用 `full`。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcompiler/cli",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "XCompiler — AI Software Factory: V-model driven, multi-LLM orchestrated software development agent.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -40,7 +40,10 @@
40
40
  "dist/plugins",
41
41
  "dist/runtime",
42
42
  "dist/acp",
43
+ "config.example.yaml",
44
+ ".env.example",
43
45
  "docs/acp.md",
46
+ "docs/openrouter.md",
44
47
  "docs/plugin_api.md",
45
48
  "docs/self_bootstrap.md",
46
49
  "docs/versioning.md",
@@ -52,6 +55,7 @@
52
55
  "version:check": "node scripts/version.mjs check",
53
56
  "version:sync": "node scripts/version.mjs sync",
54
57
  "version:set": "node scripts/version.mjs set",
58
+ "release:local": "bash scripts/release-local.sh",
55
59
  "prepack": "npm run version:check",
56
60
  "prebuild": "npm run version:check",
57
61
  "build": "tsup",