flavor-code 1.2.7 → 1.2.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.
Files changed (41) hide show
  1. package/README.md +405 -369
  2. package/README.zh-CN.md +387 -356
  3. package/dist/agent/loop.d.ts +4 -0
  4. package/dist/agent/types.d.ts +10 -0
  5. package/dist/{app-R3SDG2OH.js → app-USAFQVSX.js} +379 -12
  6. package/dist/{chunk-NVLYFU6P.js → chunk-F2HMO5Q2.js} +28 -11
  7. package/dist/{chunk-WN2EZV3Y.js → chunk-G32MCAZA.js} +1 -1
  8. package/dist/{chunk-N2S7USST.js → chunk-RQTYHUMK.js} +2 -1
  9. package/dist/{chunk-5RHJ3PQN.js → chunk-WGYNTR4Q.js} +1834 -495
  10. package/dist/{chunk-HFR2WS6T.js → chunk-XFCJXRJ2.js} +18 -5
  11. package/dist/{claude-ink-WPWPEL5A.js → claude-ink-ORUA7GWG.js} +2 -2
  12. package/dist/cli.js +9 -8
  13. package/dist/config/protected-file.d.ts +6 -0
  14. package/dist/config/schema.d.ts +2 -0
  15. package/dist/context/manager.d.ts +2 -0
  16. package/dist/context/workspace-instructions.d.ts +10 -0
  17. package/dist/desktop/main.js +12736 -5178
  18. package/dist/desktop/pixel-worker.js +73 -0
  19. package/dist/desktop/preload.cjs +80 -2
  20. package/dist/desktop-renderer/assets/index-D-s27J39.js +151 -0
  21. package/dist/desktop-renderer/assets/index-DMZBSGrp.css +1 -0
  22. package/dist/desktop-renderer/index.html +3 -4
  23. package/dist/harness/local.d.ts +4 -1
  24. package/dist/jobs/registry.d.ts +48 -0
  25. package/dist/{load-XC5JYYBQ.js → load-6ZMEBHSG.js} +1 -1
  26. package/dist/models/anthropic.d.ts +4 -0
  27. package/dist/permissions/engine.d.ts +7 -0
  28. package/dist/production.d.ts +13 -1
  29. package/dist/sdk/index.js +4 -4
  30. package/dist/terminal/service.d.ts +57 -0
  31. package/dist/tools/files.d.ts +10 -0
  32. package/dist/tools/jobs.d.ts +4 -0
  33. package/dist/tools/runtime.d.ts +2 -0
  34. package/dist/tools/shell.d.ts +13 -3
  35. package/dist/tools/terminal.d.ts +3 -0
  36. package/dist/tools/types.d.ts +76 -4
  37. package/dist/tools/web.d.ts +53 -0
  38. package/package.json +13 -2
  39. package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +752 -1
  40. package/dist/desktop-renderer/assets/index-CLrVaR9H.js +0 -143
  41. package/dist/desktop-renderer/assets/index-Cm_ktmXm.css +0 -1
package/README.md CHANGED
@@ -1,369 +1,405 @@
1
- <p align="center"><b><a href="./README.md">English</a></b> | <a href="./README.zh-CN.md">简体中文</a></p>
2
-
3
- <div align="center">
4
- <img src="./assets/icon-transparent-512.png" alt="Flavor Code Logo" width="168" />
5
- <h1>Flavor Code</h1>
6
- <p><strong>Local-first, auditable, resumable AI coding assistant</strong></p>
7
- <p>Read code, edit files, run commands, and complete complex tasks in the terminal, Electron desktop, and VS Code.</p>
8
-
9
- <p>
10
- <a href="https://www.npmjs.com/package/flavor-code"><img alt="npm version" src="https://img.shields.io/npm/v/flavor-code?color=cb3837&logo=npm" /></a>
11
- <a href="https://github.com/YachuanWzh/flavor-code/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/YachuanWzh/flavor-code/actions/workflows/ci.yml/badge.svg?branch=main" /></a>
12
- <img alt="Node.js 20+" src="https://img.shields.io/badge/Node.js-20%2B-339933?logo=nodedotjs&logoColor=white" />
13
- <a href="./LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
14
- </p>
15
-
16
- <p>
17
- <a href="#quick-start">Quick Start</a> ·
18
- <a href="#features">Features</a> ·
19
- <a href="#entry-points">Entry Points</a> ·
20
- <a href="#permissions--sandbox">Security</a> ·
21
- <a href="#development">Development</a>
22
- </p>
23
- </div>
24
-
25
- ---
26
-
27
- Flavor Code connects to OpenAI, Anthropic, or compatible services and works with file, search, Shell, MCP, and custom tools inside a controlled workspace. Complex tasks can be broken into plans and parallel sub-tasks; sessions, diffs, tool calls, checkpoints, and audit records are all stored locally so you can resume, review, and continue at any time.
28
-
29
- ## Features
30
-
31
- | | Capability | What you get |
32
- | --- | --- | --- |
33
- | 🖥️ | **One runtime, three entry points** | CLI, Electron, and VS Code share model configuration, sessions, and tooling |
34
- | 🧭 | **Controlled progress on complex tasks** | Task plans, sub-agents, steering, follow-ups, `/loop`, and `/goal` |
35
- | ⏪ | **Traceable, resumable results** | Full timeline, checkpoints, rewind, traces, diffs, and failure audits |
36
- | 🧠 | **Local long-term context** | Memory, Skills, plugins, and project guides stored on your machine |
37
- | 🛡️ | **Clear permission boundaries** | Independent control over read, write, Shell, network, and destructive actions; Docker supported |
38
-
39
- ## Quick Start
40
-
41
- > [!IMPORTANT]
42
- > The CLI requires Node.js 20 or later. Windows desktop builds can also be downloaded directly from [Releases](https://github.com/YachuanWzh/flavor-code/releases).
43
-
44
- **1. Install**
45
-
46
- ```bash
47
- npm install -g flavor-code
48
- ```
49
-
50
- **2. Start in your project**
51
-
52
- ```bash
53
- cd your-project
54
- flavor
55
- ```
56
-
57
- **3. Initialize project context**
58
-
59
- Run `/init` the first time you enter a project. Flavor analyzes the language, package manager, source directories, and verification commands, then generates a `FLAVOR.md` project guide.
60
-
61
- You can also run one-off tasks directly:
62
-
63
- ```bash
64
- flavor --print "Analyze this project and list the top three issues worth fixing"
65
- flavor --resume
66
- flavor --resume -p "Continue the remaining work"
67
- ```
68
-
69
- Non-interactive mode refuses actions that require human approval and never hangs waiting for input.
70
-
71
- ## Configuring Models
72
-
73
- The fastest way is to set environment variables:
74
-
75
- ```bash
76
- # macOS / Linux
77
- export OPENAI_API_KEY="sk-..."
78
-
79
- # Windows PowerShell
80
- $env:OPENAI_API_KEY = "sk-..."
81
- ```
82
-
83
- You can also put the key in a `.env` file at the project root.
84
-
85
- <details>
86
- <summary><strong>Configure multiple providers with <code>.flavor/flavor.json</code></strong></summary>
87
-
88
- Example project configuration:
89
-
90
- ```json
91
- {
92
- "providers": {
93
- "openai": {
94
- "type": "openai",
95
- "apiKey": "${OPENAI_API_KEY}",
96
- "defaultModel": "gpt-5",
97
- "cheapModel": "gpt-5-mini"
98
- }
99
- },
100
- "agents": {
101
- "main": { "model": "openai:gpt-5" },
102
- "subagent": { "model": "openai:gpt-5-mini" }
103
- },
104
- "permissionMode": "default",
105
- "maxSubagents": 3,
106
- "language": "zh-CN"
107
- }
108
- ```
109
-
110
- Configuration is merged in the following order, with later sources taking precedence:
111
-
112
- 1. Global `~/.flavor-code/flavor.json`
113
- 2. Project `.flavor/flavor.json`
114
- 3. `.env`
115
- 4. Process environment variables
116
-
117
- Commonly supported provider types:
118
-
119
- - `openai`: OpenAI's official API
120
- - `anthropic`: Anthropic's official API
121
- - `openai-compatible`: Services compatible with the OpenAI protocol
122
-
123
- </details>
124
-
125
- Runtime behavior and configuration conventions for OAuth PKCE are described in the [PKCE spec](./docs/specs/pkce-runtime-config.md). The [config schema](./src/config/schema.ts) is the source of truth for all fields.
126
-
127
- ## Entry Points
128
-
129
- | Entry point | Best for | How to start |
130
- | --- | --- | --- |
131
- | **CLI** | Daily development, remote environments, scripting, and CI | `flavor` |
132
- | **Electron** | Visual sessions, diffs, permissions, and resource management | `npm run desktop:start` |
133
- | **VS Code / Qoder** | Editor context, diagnostic fixes, and a task control plane | `npm run ide:install` |
134
-
135
- ### CLI
136
-
137
- Run `flavor` and type natural language. Typing `/` shows built-in commands, plugin commands, and Skills.
138
-
139
- Common commands:
140
-
141
- | Command | Purpose |
142
- | --- | --- |
143
- | `/init` | Generate or update `FLAVOR.md` |
144
- | `/model` | View or switch main/sub-agent models |
145
- | `/permissions` | Switch permission modes |
146
- | `/tasks` | View task plans and sub-agent status |
147
- | `/compact` | Manually compact long session context |
148
- | `/checkpoint`, `/tree` | Save state, view the session tree |
149
- | `/rewind`, `/unrevert`, `/fork` | Resume or fork sessions |
150
- | `/memory`, `/remember`, `/forget`, `/forget-cold` | Manage long-term memory; `/forget-cold` purges cold entries and their files |
151
- | `/mcp` | View and manage MCP servers |
152
- | `/loop <goal>` | Run an autonomous loop with verification |
153
- | `/goal <objective>` | Run the plan, execute, adversarial-review workflow |
154
- | `/audit` | View tool failure audits |
155
-
156
- You can submit steering or queue follow-ups while a run is in progress; once the current model response finishes, the task picks up new instructions at safe boundaries.
157
-
158
- ### Electron Desktop
159
-
160
- ```bash
161
- npm run desktop:dev # dev mode
162
- npm run desktop:start # build and start
163
- npm run desktop:pack # Windows portable directory
164
- npm run desktop:dist # Windows NSIS installer
165
- ```
166
-
167
- The desktop app provides project and session switching, streaming Markdown, tool and diff views, permission confirmations, task status, and management of Skills, MCP, memory, and models.
168
-
169
- ### VS Code / Qoder
170
-
171
- ```bash
172
- npm run vscode:install # install into VS Code
173
- npm run qoder:install # install into Qoder
174
- npm run ide:install # auto-select the installed IDE
175
- ```
176
-
177
- The extension includes the `@flavor` Chat Participant, Mission Control, Changes & Health, Time Machine, diagnostic fixes, CodeLens, checkpoints, and rewind. If `flavor` is not on your `PATH`, set `flavorCode.executable`.
178
-
179
- ## MCP, Skills & Plugins
180
-
181
- Flavor can connect to stdio or Streamable HTTP MCP servers. Example project configuration:
182
-
183
- <details>
184
- <summary><strong>MCP configuration and CLI examples</strong></summary>
185
-
186
- ```json
187
- {
188
- "mcpServers": {
189
- "docs": {
190
- "url": "https://example.com/mcp",
191
- "headers": {
192
- "Authorization": "Bearer ${MCP_TOKEN}"
193
- }
194
- }
195
- }
196
- }
197
- ```
198
-
199
- MCP configuration can also be managed from the CLI:
200
-
201
- ```bash
202
- flavor mcp list
203
- flavor mcp add docs --url https://example.com/mcp
204
- flavor mcp disable docs
205
- ```
206
-
207
- </details>
208
-
209
- A Skill is a `SKILL.md` with YAML frontmatter, placed in `.flavor/skills/<name>/` or `~/.flavor-code/skills/<name>/`. Flavor loads skills progressively based on the task, and you can invoke one explicitly with `/<skill-name>`.
210
-
211
- Plugins live in `.flavor/plugins/` and can register commands, tools, hooks, Skill roots, and model adapters.
212
-
213
- > [!WARNING]
214
- > Plugins and agent self-registered tools are in-process JavaScript, not a security sandbox. Only install, enable, and approve code you trust.
215
-
216
- ## Sessions, Memory & Execution Records
217
-
218
- Project runtime data lives under `.flavor/`:
219
-
220
- ```text
221
- .flavor/
222
- ├── flavor.json # Project config
223
- ├── sessions/ # Session timelines
224
- ├── session-assets/ # Image attachments
225
- ├── session-trees/ # Session branches
226
- ├── checkpoints/ # Workspace snapshots
227
- ├── memory/ # Long-term memory
228
- ├── traces/ # Optional execution traces
229
- ├── audit.jsonl # Tool failure audits
230
- ├── skills/ # Project skills
231
- └── plugins/ # Project plugins
232
- ```
233
-
234
- Long-term memory distinguishes user preferences, behavioral feedback, project conventions, and external references. Automatic extraction only keeps high-confidence candidates and provides confirm, ignore, and delete actions; secrets, tokens, raw tool output, and model guesses are rejected.
235
-
236
- Image prompts support PNG, JPEG, and WebP, with a 5 MiB per-image maximum and up to 5 images per prompt. The desktop app supports picking or drag-and-drop; CLI clipboard images currently work on Windows and macOS.
237
-
238
- ## Permissions & Sandbox
239
-
240
- | Mode | Behavior |
241
- | --- | --- |
242
- | `default` | Reads are auto-approved; writes, Shell, network, and destructive actions are confirmed on demand |
243
- | `acceptEdits` | Workspace writes and routine verification are auto-approved |
244
- | `plan` | Read-only planning; no modifications or execution |
245
- | `bypassPermissions` | The main agent executes as much as possible after hard safety checks |
246
- | `auto` | A classifier decides, falling back to human approval when uncertain |
247
- | `bubble` | Uncertain operations bubble up to the main session for approval |
248
-
249
- > [!CAUTION]
250
- > Local Shell still runs as your current user. Consider enabling Docker when working with untrusted projects.
251
-
252
- <details>
253
- <summary><strong>Docker execution environment example</strong></summary>
254
-
255
- ```json
256
- {
257
- "execution": {
258
- "mode": "docker",
259
- "image": "node:24-bookworm-slim",
260
- "network": false,
261
- "memory": "2g",
262
- "cpus": 2
263
- }
264
- }
265
- ```
266
-
267
- If Docker is unavailable, tasks fail rather than silently falling back to the host. Sensitive fields in config files and OAuth tokens are encrypted at rest with AES-256-GCM using a local configuration key.
268
-
269
- </details>
270
-
271
- ## SDK, RPC & Evaluation
272
-
273
- <details>
274
- <summary><strong>Node.js SDK example</strong></summary>
275
-
276
- ```ts
277
- import { createFlavorRuntime } from "flavor-code/sdk";
278
-
279
- const runtime = await createFlavorRuntime({
280
- workspace: process.cwd(),
281
- approvalPolicy: "deny",
282
- output: console.log,
283
- });
284
-
285
- await runtime.session.start();
286
- await runtime.session.submit("fix the failing tests");
287
- await runtime.dispose();
288
- ```
289
-
290
- </details>
291
-
292
- Other IDEs or languages can integrate over JSONL RPC:
293
-
294
- ```bash
295
- flavor --mode rpc --workspace . --trace .flavor/traces/run.jsonl
296
- ```
297
-
298
- Run evaluations:
299
-
300
- ```bash
301
- flavor eval eval.json --output report.json
302
- ```
303
-
304
- Design constraints for RPC, traces, replay, eval, session trees, and Docker are in the [control-plane spec](./docs/specs/2026-07-29-control-plane-sandbox-vscode.md).
305
-
306
- ## Development
307
-
308
- ```bash
309
- npm ci
310
- npm test
311
- npm run typecheck
312
- npm run vscode:typecheck
313
- npm run build
314
- npm run smoke:install
315
- ```
316
-
317
- - TypeScript strict, targeting ES2022, Node.js 20+
318
- - Vitest for unit and integration tests
319
- - tsup builds the CLI, SDK, Electron main process, and VS Code extension
320
- - Vite builds the Electron renderer
321
- - CI covers Windows/macOS with Node 20/24
322
-
323
- Release builds do not generate or package source maps by default. For a local debugging build, enable them explicitly:
324
-
325
- ```bash
326
- # macOS / Linux
327
- FLAVOR_SOURCEMAP=1 npm run build
328
-
329
- # Windows PowerShell
330
- $env:FLAVOR_SOURCEMAP = "1"
331
- npm run build
332
- ```
333
-
334
- ## Documentation
335
-
336
- - [Technical Design Report](./技术方案报告.md): overall architecture, agent loop, context, permissions, plugins, and security model
337
- - [Runtime reliability spec](./docs/specs/2026-07-26-runtime-reliability.md)
338
- - [Control plane, sandbox & VS Code spec](./docs/specs/2026-07-29-control-plane-sandbox-vscode.md)
339
- - [Multimodal image attachments spec](./docs/specs/2026-07-30-multimodal-image-attachments.md)
340
- - [VS Code next steps](./docs/specs/2026-08-01-flavor-code-vscode-next.md)
341
-
342
- ## Security Notes
343
-
344
- - Review model-generated code and commands, especially dependency installs, scripts, and deletions.
345
- - Do not treat `.flavor/sessions/`, traces, or long-term memory as secret stores.
346
- - Use least-privilege API keys and never commit `.env`.
347
- - Skill content can influence model behavior; plugins and self-registered tools also have in-process Node.js permissions.
348
- - Work under version control and create checkpoints before high-risk tasks.
349
-
350
- ## Contributing
351
-
352
- Issues and Pull Requests are welcome. Please at least run the following before submitting:
353
-
354
- ```bash
355
- npm test
356
- npm run typecheck
357
- npm run vscode:typecheck
358
- npm run build
359
- ```
360
-
361
- For architecture changes, read the [Technical Design Report](./技术方案报告.md) and the relevant [design specs](./docs/specs/) first.
362
-
363
- ## License
364
-
365
- [MIT](./LICENSE)
366
-
367
- <p align="center">
368
- Made with 🌶️ by Flavor Code contributors.
369
- </p>
1
+ <p align="center"><b><a href="./README.md">English</a></b> | <a href="./README.zh-CN.md">简体中文</a></p>
2
+
3
+ <div align="center">
4
+ <img src="./assets/icon-transparent-512.png" alt="Flavor Code Logo" width="168" />
5
+ <h1>Flavor Code</h1>
6
+ <p><strong>Local-first, auditable, resumable AI coding assistant</strong></p>
7
+ <p>Read code, edit files, run commands, and complete complex tasks in the terminal, Electron desktop, and VS Code.</p>
8
+
9
+ <p>
10
+ <a href="https://www.npmjs.com/package/flavor-code"><img alt="npm version" src="https://img.shields.io/npm/v/flavor-code?color=cb3837&logo=npm" /></a>
11
+ <a href="https://github.com/YachuanWzh/flavor-code/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/YachuanWzh/flavor-code/actions/workflows/ci.yml/badge.svg?branch=main" /></a>
12
+ <img alt="Node.js 20+" src="https://img.shields.io/badge/Node.js-20%2B-339933?logo=nodedotjs&logoColor=white" />
13
+ <a href="./LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
14
+ </p>
15
+
16
+ <p>
17
+ <a href="#quick-start">Quick Start</a> ·
18
+ <a href="#features">Features</a> ·
19
+ <a href="#entry-points">Entry Points</a> ·
20
+ <a href="#permissions--sandbox">Security</a> ·
21
+ <a href="#development">Development</a> ·
22
+ <a href="./CHANGELOG.md">Changelog</a>
23
+ </p>
24
+ </div>
25
+
26
+ ---
27
+
28
+ Flavor Code connects to OpenAI, Anthropic, or compatible services and works with file, search, Shell, MCP, and custom tools inside a controlled workspace. Complex tasks can be broken into plans and parallel sub-tasks; sessions, diffs, tool calls, checkpoints, and audit records are all stored locally so you can resume, review, and continue at any time.
29
+
30
+ ## Features
31
+
32
+ | | Capability | What you get |
33
+ | --- | --- | --- |
34
+ | 🖥️ | **One runtime, three entry points** | CLI, Electron, and VS Code share model configuration, sessions, and tooling |
35
+ | 🧭 | **Controlled progress on complex tasks** | Task plans, sub-agents, steering, follow-ups, `/loop`, and `/goal` |
36
+ | ⏪ | **Traceable, resumable results** | Full timeline, checkpoints, rewind, traces, diffs, and failure audits |
37
+ | 🧠 | **Local long-term context** | Memory, Skills, plugins, and project guides stored on your machine |
38
+ | 🎨 | **D2C design-to-code** | Import Pixso exports; the agent generates Vue/React implementations with automatic pixel-level visual evaluation (Electron only) |
39
+ | 🛡️ | **Clear permission boundaries** | Independent control over read, write, Shell, network, and destructive actions; Docker supported |
40
+
41
+ ## 1.2.9 Runtime Productivity
42
+
43
+ 1.2.9 adds layered project instructions, safe writes, background jobs, persistent terminals, and native web tools. Usually you can just describe the goal in natural language and the agent picks the right tool; when you need precise control, name the tool and its parameters explicitly in the prompt.
44
+
45
+ | Feature | How to use |
46
+ | --- | --- |
47
+ | **Layered project instructions** | Put `AGENTS.md` / `CLAUDE.md` in the project root or subdirectories; use `AGENTS.local.md` / `CLAUDE.local.md` for local additions in the same directory. Root rules load at startup; subdirectory rules load automatically when the agent touches files there. |
48
+ | **Per-turn change summary** | No configuration needed. After a successful `Write`, `Edit`, or `ApplyPatch`, the turn shows a color-coded `CHANGESET` receipt with workspace-relative paths, `CREATE` / `UPDATE` / `DELETE` operations, per-file line counts, and a total. At most 8 files are shown, with an explicit shown/total footer when more changed. |
49
+ | **File version protection** | No configuration needed. If the IDE, a formatter, or another process modifies a file after the agent read it, the next write fails with `Stale file`; ask the agent to re-read before editing. |
50
+ | **Standard tool presentation protocol** | Tool authors can declare `outputSchema`, `renderForModel`, `presentCall`, and `presentResult`, so the same result can use an appropriate form in the model context, CLI, and desktop. The CLI visually separates file diffs, web evidence, job receipts, foreground `COMMAND` output, and persistent `TERMINAL` output from the final answer. |
51
+ | **Background Shell / Jobs** | Say "start the dev server in the background" and the agent calls `Shell` with `background: true`. Use `JobList` to view jobs, `JobRead` for incremental output, `JobWait` to wait, and `JobKill` to stop. The CLI shows a color-bordered `JOB` receipt separating job metadata, logs, and the final answer; logs show at most the latest 12 lines and lists at most 8 items. Windows prefers UTF-8 and falls back automatically on GBK/GB18030 system diagnostics. |
52
+ | **Foreground command results** | Foreground `Shell` calls render as state-colored `COMMAND` receipts with separate command, stdout, stderr, and exit regions. Long output keeps the first and last 8 lines and explicitly folds the middle; persistent PTY output uses the distinct `TERMINAL` label. |
53
+ | **Desktop background status** | Electron automatically shows the number of running jobs in the session title bar, updated live on start, output, exit, or cancel. |
54
+ | **Persistent PTY** | Say "open a persistent terminal and keep interacting". The agent uses `TerminalOpen` to create a terminal, `TerminalWrite` for input, `TerminalRead` for incremental output, and `TerminalClose` to close it. |
55
+ | **Unified D2C/E2E process lifecycle** | No usage change. Preview and backend services still start/stop from the E2E/D2C workbench, but the underlying layer unifies output limits, process-tree termination, and idempotent cleanup. |
56
+ | **Native WebSearch** | Say "search the web for ...", or explicitly ask for `WebSearch`. It uses keyless DuckDuckGo Lite by default and degrades to Bing on connection failure, HTTP rejection, or no parseable results; up to 20 results per call. The CLI puts the top 5 into a bordered `WEB SEARCH` evidence block with titles and compact sources in search order. |
57
+ | **Native WebFetch** | Say "read this page: `https://...`", or explicitly ask for `WebFetch`. Supports HTTP(S), redirects, HTML-to-text, timeouts, and response size limits, and is compatible with Clash/TUN Fake-IP DNS. Direct access to Fake-IP, intranet, or cloud metadata addresses is still blocked; network operations still follow Flavor permission approval. |
58
+
59
+ Common precise usage:
60
+
61
+ ```text
62
+ Start npm run dev with Shell in background mode, then use JobRead to inspect the startup logs.
63
+ Open a persistent terminal, run a Python REPL in it, execute two snippets, then close the terminal.
64
+ Use WebSearch to find the official TypeScript 7 migration notes, then WebFetch the most relevant official page.
65
+ This directory has its own conventions; follow src/payments/AGENTS.md before modifying code here.
66
+ ```
67
+
68
+ See [Technical Design Report §38](./技术方案报告.md#38-129-运行时生产力与原生-web-能力) for tool parameters, state machines, security boundaries, and extension interfaces; acceptance criteria are in the [Runtime productivity spec](./docs/specs/2026-08-13-runtime-productivity-waves.md).
69
+
70
+ ## Quick Start
71
+
72
+ > [!IMPORTANT]
73
+ > The CLI requires Node.js 20 or later. Windows desktop builds can also be downloaded directly from [Releases](https://github.com/YachuanWzh/flavor-code/releases).
74
+
75
+ **1. Install**
76
+
77
+ ```bash
78
+ npm install -g flavor-code
79
+ ```
80
+
81
+ **2. Start in your project**
82
+
83
+ ```bash
84
+ cd your-project
85
+ flavor
86
+ ```
87
+
88
+ **3. Initialize project context**
89
+
90
+ Run `/init` the first time you enter a project. Flavor analyzes the language, package manager, source directories, and verification commands, then generates a `FLAVOR.md` project guide.
91
+
92
+ You can also run one-off tasks directly:
93
+
94
+ ```bash
95
+ flavor --print "Analyze this project and list the top three issues worth fixing"
96
+ flavor --resume
97
+ flavor --resume -p "Continue the remaining work"
98
+ ```
99
+
100
+ Non-interactive mode refuses actions that require human approval and never hangs waiting for input.
101
+
102
+ ## Configuring Models
103
+
104
+ The fastest way is to set environment variables:
105
+
106
+ ```bash
107
+ # macOS / Linux
108
+ export OPENAI_API_KEY="sk-..."
109
+
110
+ # Windows PowerShell
111
+ $env:OPENAI_API_KEY = "sk-..."
112
+ ```
113
+
114
+ You can also put the key in a `.env` file at the project root.
115
+
116
+ <details>
117
+ <summary><strong>Configure multiple providers with <code>.flavor/flavor.json</code></strong></summary>
118
+
119
+ Example project configuration:
120
+
121
+ ```json
122
+ {
123
+ "providers": {
124
+ "openai": {
125
+ "type": "openai",
126
+ "apiKey": "${OPENAI_API_KEY}",
127
+ "defaultModel": "gpt-5",
128
+ "cheapModel": "gpt-5-mini"
129
+ }
130
+ },
131
+ "agents": {
132
+ "main": { "model": "openai:gpt-5" },
133
+ "subagent": { "model": "openai:gpt-5-mini" }
134
+ },
135
+ "permissionMode": "default",
136
+ "maxSubagents": 3,
137
+ "language": "zh-CN"
138
+ }
139
+ ```
140
+
141
+ Configuration is merged in the following order, with later sources taking precedence:
142
+
143
+ 1. Global `~/.flavor-code/flavor.json`
144
+ 2. Project `.flavor/flavor.json`
145
+ 3. `.env`
146
+ 4. Process environment variables
147
+
148
+ Commonly supported provider types:
149
+
150
+ - `openai`: OpenAI's official API
151
+ - `anthropic`: Anthropic's official API
152
+ - `openai-compatible`: Services compatible with the OpenAI protocol
153
+
154
+ </details>
155
+
156
+ Runtime behavior and configuration conventions for OAuth PKCE are described in the [PKCE spec](./docs/specs/pkce-runtime-config.md). The [config schema](./src/config/schema.ts) is the source of truth for all fields.
157
+
158
+ ## Entry Points
159
+
160
+ | Entry point | Best for | How to start |
161
+ | --- | --- | --- |
162
+ | **CLI** | Daily development, remote environments, scripting, and CI | `flavor` |
163
+ | **Electron** | Visual sessions, diffs, permissions, and resource management | `npm run desktop:start` |
164
+ | **VS Code / Qoder** | Editor context, diagnostic fixes, and a task control plane | `npm run ide:install` |
165
+
166
+ ### CLI
167
+
168
+ Run `flavor` and type natural language. Typing `/` shows built-in commands, plugin commands, and Skills.
169
+
170
+ Common commands:
171
+
172
+ | Command | Purpose |
173
+ | --- | --- |
174
+ | `/init` | Generate or update `FLAVOR.md` |
175
+ | `/model` | View or switch main/sub-agent models |
176
+ | `/permissions` | Switch permission modes |
177
+ | `/tasks` | View task plans and sub-agent status |
178
+ | `/compact` | Manually compact long session context |
179
+ | `/checkpoint`, `/tree` | Save state, view the session tree |
180
+ | `/rewind`, `/unrevert`, `/fork` | Resume or fork sessions |
181
+ | `/memory`, `/remember`, `/forget`, `/forget-cold` | Manage long-term memory; `/forget-cold` purges cold entries and their files |
182
+ | `/mcp` | View and manage MCP servers |
183
+ | `/loop <goal>` | Run an autonomous loop with verification |
184
+ | `/goal <objective>` | Run the plan, execute, adversarial-review workflow |
185
+ | `/audit` | View tool failure audits |
186
+
187
+ You can submit steering or queue follow-ups while a run is in progress; once the current model response finishes, the task picks up new instructions at safe boundaries.
188
+
189
+ ### Electron Desktop
190
+
191
+ ```bash
192
+ npm run desktop:dev # dev mode
193
+ npm run desktop:start # build and start
194
+ npm run desktop:pack # Windows portable directory
195
+ npm run desktop:dist # Windows NSIS installer
196
+ ```
197
+
198
+ The desktop app provides project and session switching, streaming Markdown, tool and diff views, permission confirmations, task status, and management of Skills, MCP, memory, and models.
199
+
200
+ The **D2C** module in the sidebar supports a complete design-to-code loop: import a Pixso-exported HTML directory, choose a target framework (Vue 3 / React), and submit the generation task to the current session. The agent implements it under `src/d2c-output/<task>/` following the `d2c-pixso` skill (SOP); a Vite dev server then starts automatically for pixel-level comparison, producing a visual-fidelity score and a structured diff report (region offsets, color deviations, font differences). The results workbench offers overlay, curtain, flicker, and heatmap comparison modes, an SVG annotation layer, and a severity-sorted issue list, so each diff can be accepted or rejected individually and trigger module-level fixes. Once visual review passes, you can import a Swagger/OpenAPI document to auto-generate Axios wrappers and an Express mock server, moving into API integration and interactive acceptance.
201
+
202
+ ### VS Code / Qoder
203
+
204
+ ```bash
205
+ npm run vscode:install # install into VS Code
206
+ npm run qoder:install # install into Qoder
207
+ npm run ide:install # auto-select the installed IDE
208
+ ```
209
+
210
+ The extension includes the `@flavor` Chat Participant, Mission Control, Changes & Health, Time Machine, diagnostic fixes, CodeLens, checkpoints, and rewind. If `flavor` is not on your `PATH`, set `flavorCode.executable`.
211
+
212
+ ## MCP, Skills & Plugins
213
+
214
+ Flavor can connect to stdio or Streamable HTTP MCP servers. Example project configuration:
215
+
216
+ <details>
217
+ <summary><strong>MCP configuration and CLI examples</strong></summary>
218
+
219
+ ```json
220
+ {
221
+ "mcpServers": {
222
+ "docs": {
223
+ "url": "https://example.com/mcp",
224
+ "headers": {
225
+ "Authorization": "Bearer ${MCP_TOKEN}"
226
+ }
227
+ }
228
+ }
229
+ }
230
+ ```
231
+
232
+ MCP configuration can also be managed from the CLI:
233
+
234
+ ```bash
235
+ flavor mcp list
236
+ flavor mcp add docs --url https://example.com/mcp
237
+ flavor mcp disable docs
238
+ ```
239
+
240
+ </details>
241
+
242
+ A Skill is a `SKILL.md` with YAML frontmatter, placed in `.flavor/skills/<name>/` or `~/.flavor-code/skills/<name>/`. Flavor loads skills progressively based on the task, and you can invoke one explicitly with `/<skill-name>`.
243
+
244
+ Plugins live in `.flavor/plugins/` and can register commands, tools, hooks, Skill roots, and model adapters.
245
+
246
+ > [!WARNING]
247
+ > Plugins and agent self-registered tools are in-process JavaScript, not a security sandbox. Only install, enable, and approve code you trust.
248
+
249
+ ## Sessions, Memory & Execution Records
250
+
251
+ Project runtime data lives under `.flavor/`:
252
+
253
+ ```text
254
+ .flavor/
255
+ ├── flavor.json # Project config
256
+ ├── sessions/ # Session timelines
257
+ ├── session-assets/ # Image attachments
258
+ ├── session-trees/ # Session branches
259
+ ├── checkpoints/ # Workspace snapshots
260
+ ├── memory/ # Long-term memory
261
+ ├── traces/ # Optional execution traces
262
+ ├── audit.jsonl # Tool failure audits
263
+ ├── skills/ # Project skills
264
+ └── plugins/ # Project plugins
265
+ ```
266
+
267
+ Long-term memory distinguishes user preferences, behavioral feedback, project conventions, and external references. Automatic extraction only keeps high-confidence candidates and provides confirm, ignore, and delete actions; secrets, tokens, raw tool output, and model guesses are rejected.
268
+
269
+ Image prompts support PNG, JPEG, and WebP, with a 5 MiB per-image maximum and up to 5 images per prompt. The desktop app supports picking or drag-and-drop; CLI clipboard images currently work on Windows and macOS.
270
+
271
+ ## Permissions & Sandbox
272
+
273
+ | Mode | Behavior |
274
+ | --- | --- |
275
+ | `default` | Reads are auto-approved; writes, Shell, network, and destructive actions are confirmed on demand |
276
+ | `acceptEdits` | Workspace writes and routine verification are auto-approved |
277
+ | `plan` | Read-only planning; no modifications or execution |
278
+ | `bypassPermissions` | The main agent executes as much as possible after hard safety checks |
279
+ | `auto` | A classifier decides, falling back to human approval when uncertain |
280
+ | `bubble` | Uncertain operations bubble up to the main session for approval |
281
+
282
+ > [!CAUTION]
283
+ > Local Shell still runs as your current user. Consider enabling Docker when working with untrusted projects.
284
+
285
+ <details>
286
+ <summary><strong>Docker execution environment example</strong></summary>
287
+
288
+ ```json
289
+ {
290
+ "execution": {
291
+ "mode": "docker",
292
+ "image": "node:24-bookworm-slim",
293
+ "network": false,
294
+ "memory": "2g",
295
+ "cpus": 2
296
+ }
297
+ }
298
+ ```
299
+
300
+ If Docker is unavailable, tasks fail rather than silently falling back to the host. Sensitive fields in config files and OAuth tokens are encrypted at rest with AES-256-GCM using a local configuration key.
301
+
302
+ </details>
303
+
304
+ ## SDK, RPC & Evaluation
305
+
306
+ <details>
307
+ <summary><strong>Node.js SDK example</strong></summary>
308
+
309
+ ```ts
310
+ import { createFlavorRuntime } from "flavor-code/sdk";
311
+
312
+ const runtime = await createFlavorRuntime({
313
+ workspace: process.cwd(),
314
+ approvalPolicy: "deny",
315
+ output: console.log,
316
+ });
317
+
318
+ await runtime.session.start();
319
+ await runtime.session.submit("fix the failing tests");
320
+ await runtime.dispose();
321
+ ```
322
+
323
+ </details>
324
+
325
+ Other IDEs or languages can integrate over JSONL RPC:
326
+
327
+ ```bash
328
+ flavor --mode rpc --workspace . --trace .flavor/traces/run.jsonl
329
+ ```
330
+
331
+ Run evaluations:
332
+
333
+ ```bash
334
+ flavor eval eval.json --output report.json
335
+ ```
336
+
337
+ Design constraints for RPC, traces, replay, eval, session trees, and Docker are in the [control-plane spec](./docs/specs/2026-07-29-control-plane-sandbox-vscode.md).
338
+
339
+ ## Development
340
+
341
+ ```bash
342
+ npm ci
343
+ npm test
344
+ npm run typecheck
345
+ npm run vscode:typecheck
346
+ npm run build
347
+ npm run smoke:install
348
+ ```
349
+
350
+ - TypeScript strict, targeting ES2022, Node.js 20+
351
+ - Vitest for unit and integration tests
352
+ - tsup builds the CLI, SDK, Electron main process, and VS Code extension
353
+ - Vite builds the Electron renderer
354
+ - CI covers Windows/macOS with Node 20/24
355
+
356
+ Release builds do not generate or package source maps by default. For a local debugging build, enable them explicitly:
357
+
358
+ ```bash
359
+ # macOS / Linux
360
+ FLAVOR_SOURCEMAP=1 npm run build
361
+
362
+ # Windows PowerShell
363
+ $env:FLAVOR_SOURCEMAP = "1"
364
+ npm run build
365
+ ```
366
+
367
+ ## Documentation
368
+
369
+ - [Technical Design Report](./技术方案报告.md): overall architecture, agent loop, context, permissions, plugins, and security model
370
+ - [Runtime reliability spec](./docs/specs/2026-07-26-runtime-reliability.md)
371
+ - [Control plane, sandbox & VS Code spec](./docs/specs/2026-07-29-control-plane-sandbox-vscode.md)
372
+ - [Multimodal image attachments spec](./docs/specs/2026-07-30-multimodal-image-attachments.md)
373
+ - [D2C design-to-code spec](./docs/specs/2026-08-09-d2c-design-to-code.md)
374
+ - [D2C review & integration spec](./docs/specs/2026-08-10-d2c-review-and-integration.md)
375
+ - [1.2.9 runtime productivity spec](./docs/specs/2026-08-13-runtime-productivity-waves.md)
376
+ - [VS Code next steps](./docs/specs/2026-08-01-flavor-code-vscode-next.md)
377
+
378
+ ## Security Notes
379
+
380
+ - Review model-generated code and commands, especially dependency installs, scripts, and deletions.
381
+ - Do not treat `.flavor/sessions/`, traces, or long-term memory as secret stores.
382
+ - Use least-privilege API keys and never commit `.env`.
383
+ - Skill content can influence model behavior; plugins and self-registered tools also have in-process Node.js permissions.
384
+ - Work under version control and create checkpoints before high-risk tasks.
385
+
386
+ ## Contributing
387
+
388
+ Issues and Pull Requests are welcome. Please at least run the following before submitting:
389
+
390
+ ```bash
391
+ npm test
392
+ npm run typecheck
393
+ npm run vscode:typecheck
394
+ npm run build
395
+ ```
396
+
397
+ For architecture changes, read the [Technical Design Report](./技术方案报告.md) and the relevant [design specs](./docs/specs/) first.
398
+
399
+ ## License
400
+
401
+ [MIT](./LICENSE)
402
+
403
+ <p align="center">
404
+ Made with 🌶️ by Flavor Code contributors.
405
+ </p>