anti-trace 0.1.1 → 0.1.4

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 (3) hide show
  1. package/README.en.md +83 -109
  2. package/README.md +83 -108
  3. package/package.json +4 -2
package/README.en.md CHANGED
@@ -1,155 +1,129 @@
1
1
  # Anti-trace
2
2
 
3
- [中文](README.md) | **English**
3
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
4
+ [![npm version](https://img.shields.io/npm/v/anti-trace)](https://www.npmjs.com/package/anti-trace)
5
+ [![CI](https://github.com/sadgsk/Anti-trace/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/sadgsk/Anti-trace/actions/workflows/ci.yml)
6
+ [![Release](https://github.com/sadgsk/Anti-trace/actions/workflows/release.yml/badge.svg)](https://github.com/sadgsk/Anti-trace/actions/workflows/release.yml)
7
+ <br>
8
+ [Quick start](#quick-start) · [Documentation](#documentation) · [Issues](https://github.com/sadgsk/Anti-trace/issues) · [中文](README.md)
4
9
 
5
- Anti-trace is an AI coding agent that runs in your terminal. It can read and edit code, execute shell commands, find project files, and decide what to do next based on the results. Bring your own API credentials to connect a model provider through OpenAI Chat Completions, OpenAI Responses, or Anthropic Messages.
10
+ Anti-trace is an AI coding assistant for your terminal. It reads and edits project files, runs builds and tests, and follows up on tool results. Connect a supported model provider with your own API key and review commands, output, and diffs in the terminal.
6
11
 
7
- ![Anti-trace proposed architecture: the existing agent foundation, planned feature changes, validation, and hot restart](docs/assets/target-architecture.svg)
12
+ ## Install
8
13
 
9
- ## What it can do
14
+ Requires Node.js 22 or newer.
10
15
 
11
- - **Understand a project:** read source files, trace module relationships, and explain code.
12
- - **Write and change code:** implement features, fix bugs, refactor code, or write documentation from your instructions.
13
- - **Run development tasks:** use the shell to find files, run builds and tests, and investigate problems using command output.
14
- - **Continue previous work:** save project conversations and restore them with `/resume`; track context usage and compact conversation history.
15
- - **Work with text and images:** multiline editing, long-text pasting, image input, and draft undo/redo.
16
+ ```sh
17
+ npm install -g anti-trace
18
+ ```
19
+
20
+ `ati` and `anti-trace` launch the same CLI. Shell tools use Bash on macOS and Linux. On Windows, Anti-trace prefers PowerShell 7 and falls back to Windows PowerShell 5.1. Git for Windows also enables Git Bash. If Anti-trace cannot find a custom installation, set `ANTI_TRACE_GIT_BASH_PATH` to the absolute path of Git for Windows' `bin\bash.exe`.
16
21
 
17
22
  ## Quick start
18
23
 
19
- You need Node.js 22 or newer and API credentials for your chosen model provider.
24
+ 1. Open a terminal in your project directory and launch Anti-trace.
20
25
 
21
- ```sh
22
- git clone https://github.com/sadgsk/Anti-trace.git
23
- cd Anti-trace
24
- npm install
25
- ```
26
+ ```sh
27
+ cd your-project
28
+ ati
29
+ ```
26
30
 
27
- Copy [byok.example.json](byok.example.json) to `~/.anti-trace/profiles/local/configs/main.json` in your home directory (create the directories first) and configure:
31
+ 2. Enter `/config` and choose **Add configuration**. Fill in the configuration file name, provider API URL, API key, model ID, and API protocol. Set the context window for your model and optionally set an output limit. Choose **Save and use configuration** or press `Ctrl+S`.
32
+ 3. Enter your first task.
28
33
 
29
- - The connection's API key and service URL.
30
- - The model ID, context window, and output limit.
31
- - `currentModel`: the model configuration key to use.
34
+ ```text
35
+ Find this project's entry points and test commands, and explain how its main modules fit together.
36
+ ```
32
37
 
33
- The default `main` entry contains a placeholder URL and model ID. Replace them before making a model request. Then start the CLI:
38
+ Once a model is configured, you can also pipe in a single prompt. The CLI reads standard input as one message, processes it, and exits. Pipe mode blocks tools that require interactive approval.
34
39
 
35
40
  ```sh
36
- npm start
41
+ echo "Explain the entry points in this project." | ati
37
42
  ```
38
43
 
39
- To register the equivalent local commands `ati` and `anti-trace`, run these commands from this repository:
44
+ ## Key features
40
45
 
41
- ```sh
42
- npm run build
43
- npm link
44
- ```
46
+ - **File and shell tools.** Read, create, and edit files. Use the shell to search the project, build, and run tests. Shell commands default to a 120-second timeout. Long output is shortened in the transcript, with the full output saved for later reads.
47
+ - **Terminal UI.** Stream responses with Markdown, syntax highlighting, tables, tool cards, and diffs. Type `/` to open the command menu or `@` to find and complete workspace file paths. Edit multiline drafts with undo and redo, and switch between English and Chinese with `/language`.
48
+ - **Image input.** Paste a path to an image file or use `Alt+V` (Windows) or `Ctrl+V` (macOS and Linux) to try reading an image from the clipboard. Supported formats include PNG, JPEG, GIF, and WebP. Clipboard support depends on the terminal and system tools, and the selected model must accept images.
49
+ - **Sessions and context.** Save conversations and attachments per project and continue with `/resume`. The status line shows context usage. Anti-trace can compact older messages automatically, and `/compact` lets you request compaction manually.
45
50
 
46
- You can then run `ati` or `anti-trace` from any working directory; that directory becomes the CLI's cwd, while model configuration is loaded from your user data directory. `CLI_AGENT_CONFIG` can explicitly select another JSON file. The commands run the compiled `dist` files, so run `npm run build` again after source changes; linking again is unnecessary. `npm link` registers the commands locally and does not publish to npm.
51
+ ## Permissions and approvals
47
52
 
48
- macOS and Linux use Bash. Windows prefers PowerShell 7, falling back to Windows PowerShell 5.1. Installing Git for Windows also enables the Bash tool for Bash scripts and POSIX commands. For a custom Git installation, set `ANTI_TRACE_GIT_BASH_PATH` to the absolute path of its `bin\bash.exe` before startup. You can launch Anti-trace from CMD or PowerShell; each tool selects its own interpreter. Commands default to a 120-second timeout.
53
+ Reads are allowed by default. Writes, edits, and shell commands prompt for approval. You can approve once, allow for the current session, or deny with feedback. File changes can be previewed as diffs before approval. A session approval for file changes covers subsequent file writes and edits, while a shell approval applies to the same command in the same tool.
49
54
 
50
- Describe a task directly in the conversation, for example:
55
+ | Mode | Behavior |
56
+ | --- | --- |
57
+ | Default | Ask before writes, edits, and shell commands |
58
+ | `auto-edit` | Allow writes and edits automatically and ask before shell commands |
59
+ | `yolo` | Allow all tool calls automatically |
51
60
 
52
- ```text
53
- Explain this project's entry points and main modules.
54
- Fix this function's handling of empty input and add a test.
55
- Run the build, investigate the errors, and update the relevant code.
56
- ```
61
+ Press `Shift+Tab` to cycle through modes, or launch with `ati --auto-edit` or `ati --yolo`. Tools run with the current user's system permissions.
57
62
 
58
- The agent reads files, edits code, and runs commands as needed. These actions affect your project files directly; use a recoverable copy for initial evaluation.
63
+ ## Model configuration
59
64
 
60
- ## Model providers
65
+ Use `/config` to create, select, and edit configuration files. Each file can define multiple models, which you can switch between with `/model`. Anti-trace supports these APIs.
61
66
 
62
- Use BYOK JSON to configure your own model service:
63
-
64
- | API | Configuration value |
65
- |---|---|
67
+ | API | JSON `api` value |
68
+ | --- | --- |
66
69
  | OpenAI Chat Completions | `openai-completions` |
67
70
  | OpenAI Responses | `openai-responses` |
68
71
  | Anthropic Messages | `anthropic-messages` |
69
72
 
70
- Models reference a connection through `connection`; `currentModel` selects a key in `models`. Set `apiKey` directly or use `apiKeyEnv` to reference a process environment variable.
71
-
72
- The user data root defaults to `~/.anti-trace`; override it with `ANTI_TRACE_HOME`. Model configurations and `/config` creations use `profiles/local/configs/`. The `local` profile is the current local user; the code accepts a `profileId` for future user separation without implementing login.
73
-
74
- Startup selects an explicit `CLI_AGENT_CONFIG`, the project's last selection, the user's default selection, or the sole valid configuration, in that order. Multiple configurations without a saved selection require `/config`. Explicit configuration/model choices update the user default; reopening a project does not overwrite that default with its project selection. Missing saved paths warn and fall back; invalid explicit paths fail. Workspace `byok.json`, `.env` and old storage directories are not automatically read.
73
+ You can also copy the [example configuration](byok.example.json) to `~/.anti-trace/profiles/local/configs/main.json`. Replace the example URL, key, and model ID, then set `contextWindow` and optionally `maxOutputTokens` for your model. Each entry in `models` references a connection in `connections`, and `currentModel` is the key of the selected model entry.
75
74
 
76
- ```text
77
- ~/.anti-trace/
78
- ├── preferences.json # Machine-wide language preference
79
- └── profiles/local/
80
- ├── configs/ # Model connection configuration
81
- ├── default-model.json # Default selection for new projects
82
- └── projects/<SHA-256 of workspace>/
83
- ├── project.json # Workspace path
84
- ├── last-model.json # Project model/config selection
85
- ├── sessions/ # Conversations and image attachments
86
- └── tool-results/ # Complete tool output
87
- ```
88
-
89
- Selection files contain only configuration paths and model keys. Conversations and tool output are separated by workspace and profile, while language is shared on this machine. File operations and shells keep the startup cwd. Image conversion uses the system temporary directory. Old conversations are not migrated; existing files remain untouched.
90
-
91
- Anthropic Messages defaults to `32000` when `maxOutputTokens` is omitted, capped at the configured `contextWindow` if it is smaller. An explicit output limit takes precedence.
92
-
93
- Include any required version prefix in `baseUrl`, such as `/v1`. Alternatively, select connection presets and models from the [provider configuration example](byok.providers.example.json), then set the corresponding API key environment variables. The example includes 36 connection options across nine providers, with explicit rules for supported protocols, regions, and models.
75
+ - Set either `apiKey` or `apiKeyEnv` for each connection. `apiKeyEnv` refers to an environment variable available to the CLI process. You can also use a connection from the [provider presets example](byok.providers.example.json).
76
+ - Set `baseUrl` to the API root, including any required version prefix such as `/v1`. Put a full inference URL in `endpoint` when needed.
77
+ - Startup checks `CLI_AGENT_CONFIG`, the project's last selection, the user's default selection, and the sole valid configuration in the config directory, in that order. When several valid configurations are available on first launch, choose one with `/config`.
78
+ - Local data lives in `~/.anti-trace` by default. Override it with `ANTI_TRACE_HOME`. Model configurations are stored in `profiles/local/configs/`. Conversations, attachments, and long tool output are grouped by working directory under `profiles/local/projects/`.
94
79
 
95
- ## Common commands
80
+ ## Commands and shortcuts
96
81
 
97
- Type `/` to open the command menu; use arrows to select, Enter to confirm, Tab to complete and Esc to return. Model, effort, thinking, thinking display, session resume and configuration commands open selection screens without typed arguments. Explicit arguments remain compatible. Input starts at the bottom; use the mouse wheel or PgUp/PgDn to review history, Ctrl+End to return to the latest output, and Shift+drag to select text.
82
+ Type `/` and keep typing to filter the command menu. Use the arrow keys to select, `Enter` to confirm, `Tab` to complete, and `Esc` to close.
98
83
 
99
84
  | Command | Purpose |
100
- |---|---|
101
- | `/help` | Show help |
102
- | `/new` | Start a new session |
103
- | `/resume` | Select and restore a session with arrow keys |
104
- | `/model` | Select from models in the current configuration |
105
- | `/config` | Choose, add or edit configurations; add models to one file and edit each field on a separate page |
106
- | `/reload` | Reload model configuration |
107
- | `/thinking` | Select reasoning on/off |
108
- | `/effort` | Select low/medium/high/xhigh/max with arrow keys |
109
- | `/thinking-display` | Select the default reasoning text visibility |
110
- | `/language` | Switch between Chinese and English and remember the preference |
111
- | `/context [positive integer]` | View or adjust the context window |
112
- | `/compact` | Attempt manual context compaction |
85
+ | --- | --- |
86
+ | `/help` | Show commands and shortcuts |
87
+ | `/new` / `/resume` | Start a session or resume one for the current project |
88
+ | `/config [path]` | Manage configurations or load a specific JSON file |
89
+ | `/model [model key]` | Select a model from the current configuration |
90
+ | `/reload` | Reload the current configuration |
91
+ | `/thinking [on\|off\|default]` | Enable reasoning, disable it, or use the provider default |
92
+ | `/effort` | Select `low`, `medium`, `high`, `xhigh`, or `max`. The effect depends on the model and API |
93
+ | `/thinking-display [on\|off]` | Choose whether reasoning text starts expanded |
94
+ | `/context [positive integer]` / `/compact` | Inspect or adjust the context window, or request compaction |
95
+ | `/language [zh\|en]` | Switch and remember the interface language |
113
96
  | `/exit` | Exit |
114
97
 
115
- The complete TUI is ready for trial; see the [architecture and interaction notes](docs/architecture.md#4-分层) and [progress record](docs/progress.md) for validation and remaining work. It includes Markdown, code and tables, tool cards and diffs, permission approval, file completion with `@`, and attachment indicators. Ctrl+O expands/collapses content at the current reading position, or opens the latest tool when following live output; Shift+Tab cycles permission modes. Use `npm start -- --auto-edit` or `npm start -- --yolo` to choose a startup mode explicitly.
116
-
117
- Enter submits. Shift/Alt+Enter, or a backslash followed by Enter, inserts a newline. Ctrl+C interrupts generation or clears the draft; when idle with an empty draft, it exits. Ctrl+Z undoes; Ctrl+Y redoes. Shortcut recognition depends on the terminal.
118
-
119
- `/reload` reloads model configuration while preserving the current model selection and reasoning preferences. `/new` inherits the current settings; `/resume` resolves saved model references against the loaded catalog. The reasoning display switch only affects display, not model requests.
120
-
121
- ## Project direction
98
+ | Shortcut | Action |
99
+ | --- | --- |
100
+ | `Enter` / `Shift+Enter` or `Alt+Enter` | Submit / insert a newline |
101
+ | `Ctrl+Z` / `Ctrl+Y` or `Ctrl+Shift+Z` | Undo / redo draft changes |
102
+ | `Ctrl+C` | Interrupt generation or clear the draft. Exit when idle with an empty draft |
103
+ | `Ctrl+O` | Expand or collapse tool output and reasoning text |
104
+ | Scroll wheel or `PgUp` / `PgDn` / `Ctrl+End` | Browse history / return to the latest output |
122
105
 
123
- The project is in early development. Its long-term goal is to let users describe a feature in natural language, have the agent modify its own tools or CLI interface, and apply those changes through a hot restart.
106
+ Shortcut support depends on the terminal.
124
107
 
125
- This capability has not been implemented. The diagram above shows the proposed design. Current work focuses on the underlying model integration, tool execution, sessions, and context management.
108
+ ## Development
126
109
 
127
- - [ ] Dynamically modify tools, the CLI interface, and other capabilities from natural-language requests.
128
- - [ ] Validate capability changes and load them through a hot restart.
129
- - [x] Provider presets, reasoning controls, and the unified settings workflow.
130
- - [ ] Improve TUI interaction in v1.3.
131
- - [x] Establish reproducible offline tests and Windows/Linux/macOS CI.
132
- - [ ] Expand real-model and native-terminal acceptance checks.
133
- - [ ] Fix remaining issues with tool pairing and context-overflow error display.
134
-
135
- ## Known limitations
136
-
137
- - Windows requires a working PowerShell or Git Bash installation. Without Git Bash, only PowerShell is exposed. An invalid explicit Bash path produces a configuration error. See [future-issues.md](docs/future-issues.md).
138
- - Premature display of recoverable context-overflow errors still needs work. Interrupted tool-batch pairing was fixed in the TUI implementation; see the [review records](docs/review-records.md).
139
- - Local HTTP SSE and macOS POSIX PTY verification records exist. Coverage of real models, clipboards, and other terminal platforms remains incomplete.
140
- - Formal tests live in `tests/`. Run `npm test` for offline tests or `npm run check` for type checks, tests and a build. See the [testing guide](docs/testing.md) for commands, coverage and the three-platform CI matrix. Real-model checks have a separate explicit entry point.
110
+ ```sh
111
+ git clone https://github.com/sadgsk/Anti-trace.git
112
+ cd Anti-trace
113
+ npm ci
114
+ npm start
115
+ ```
141
116
 
142
- ## Development documentation and origins
117
+ `npm test` runs the offline tests. `npm run check` runs type checks, tests, and a build. Branch pushes and pull requests trigger GitHub Actions CI on Windows, macOS, and Linux with Node.js 22 and 24.
143
118
 
144
- The detailed development documents are currently in Chinese.
119
+ Pushing a `vX.Y.Z` version tag triggers the npm release workflow. It checks that the tag matches the package version and that the commit is in `main`, then publishes after CI and package installation checks pass.
145
120
 
146
- - [Development progress](docs/progress.md): current status, pending work, and development history.
147
- - [Architecture](docs/architecture.md): module responsibilities and design.
148
- - [Testing and CI](docs/testing.md): commands, test authoring, isolation, coverage and the CI matrix (Chinese).
149
- - [npm releases](docs/releases.md): connect npm to GitHub and publish stable releases using version tags (Chinese).
121
+ ## Documentation
150
122
 
151
- The project started by studying and referencing [Pi](https://github.com/earendil-works/pi). Some foundational code was adapted from Pi. Anti-trace uses its own `Harness` and feature design, and does not currently depend on Pi runtime packages.
123
+ - [Testing and CI](docs/testing.md)
124
+ - [npm release process](docs/releases.md)
125
+ - [Architecture and implementation notes](docs/architecture.md)
152
126
 
153
127
  ## License
154
128
 
155
- [MIT](LICENSE). Portions derived from Pi retain their original copyright and license notice.
129
+ [MIT](LICENSE). Portions adapted from [Pi](https://github.com/earendil-works/pi) retain their original copyright and license notices.
package/README.md CHANGED
@@ -1,154 +1,129 @@
1
1
  # Anti-trace
2
2
 
3
- **中文** | [English](README.en.md)
3
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
4
+ [![npm version](https://img.shields.io/npm/v/anti-trace)](https://www.npmjs.com/package/anti-trace)
5
+ [![CI](https://github.com/sadgsk/Anti-trace/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/sadgsk/Anti-trace/actions/workflows/ci.yml)
6
+ [![Release](https://github.com/sadgsk/Anti-trace/actions/workflows/release.yml/badge.svg)](https://github.com/sadgsk/Anti-trace/actions/workflows/release.yml)
7
+ <br>
8
+ [快速开始](#快速开始) · [文档](#文档) · [Issues](https://github.com/sadgsk/Anti-trace/issues) · [English](README.en.md)
4
9
 
5
- Anti-trace 是一个运行在终端里的 AI 编程 agent,可以帮你阅读和修改代码、执行 shell 命令、查找项目文件,并根据执行结果自主决定下一步动作。你可以使用自己的 API 密钥接入模型服务,目前支持 OpenAI Chat Completions、OpenAI Responses 和 Anthropic Messages 三种接口。
10
+ Anti-trace 是一个运行在终端里的 AI 编程助手。它能读取和修改项目文件、运行构建与测试,并根据工具返回的结果继续排查。你可以用自己的 API 密钥接入支持的模型服务,在终端查看命令、输出和文件差异。
6
11
 
7
- ![Anti-trace 预计架构:现有 agent 基础与计划中的功能修改、验证和热启动流程(英文)](docs/assets/target-architecture.svg)
12
+ ## 安装
8
13
 
9
- ## 能做什么
14
+ 需要 Node.js 22 或更新版本。
10
15
 
11
- - **理解项目**:阅读源码,梳理模块关系,解释代码逻辑。
12
- - **编写和修改代码**:根据需求实现功能、修复 bug、重构代码或编写文档。
13
- - **执行开发任务**:调用 shell 查找文件、运行构建和测试,并结合命令输出继续排查问题。
14
- - **继续已有工作**:保存项目会话,通过 `/resume` 恢复对话;支持上下文用量显示和摘要压缩。
15
- - **处理图文输入**:支持多行编辑、长文本粘贴、图片输入,以及草稿撤销和重做。
16
+ ```sh
17
+ npm install -g anti-trace
18
+ ```
19
+
20
+ `ati` 和 `anti-trace` 是等价的启动命令。macOS 和 Linux 的命令工具使用 Bash。Windows 优先使用 PowerShell 7,找不到时使用 Windows PowerShell 5.1。安装 Git for Windows 后也可使用 Git Bash,若安装路径未被识别,可将 `ANTI_TRACE_GIT_BASH_PATH` 设为 Git for Windows 中 `bin\bash.exe` 的绝对路径。
16
21
 
17
22
  ## 快速开始
18
23
 
19
- 需要 Node.js 22 或更新版本,以及所选模型服务的 API 密钥。
24
+ 1. 在终端进入你的项目目录,启动 Anti-trace。
20
25
 
21
- ```sh
22
- git clone https://github.com/sadgsk/Anti-trace.git
23
- cd Anti-trace
24
- npm install
25
- ```
26
+ ```sh
27
+ cd your-project
28
+ ati
29
+ ```
26
30
 
27
- 将 [byok.example.json](byok.example.json) 复制为用户目录下的 `~/.anti-trace/profiles/local/configs/main.json`(请先创建目录),填写:
31
+ 2. 输入 `/config`,选择「新增配置文件」。填写配置文件名、服务商的 API URL、API Key、模型 ID 和接口协议。按模型规格设置上下文窗口,可按需填写最大输出。选择「保存并使用此配置」或按 `Ctrl+S`。
32
+ 3. 输入你的第一个任务。
28
33
 
29
- - 连接的 API key 和服务地址。
30
- - 模型 ID、上下文窗口与输出上限。
31
- - `currentModel`:要使用的模型配置键。
34
+ ```text
35
+ 找到这个项目的入口和测试命令,解释主要模块之间是怎么配合的。
36
+ ```
32
37
 
33
- 示例默认选择的 `main` 使用占位地址和模型 ID,需要替换后才能调用。配置完成后启动:
38
+ 已配置模型后,也可以通过管道提交一条提示词。CLI 会读取完整的标准输入,执行一次并退出。管道模式会阻止需要交互审批的工具调用。
34
39
 
35
40
  ```sh
36
- npm start
41
+ echo "Explain the entry points in this project." | ati
37
42
  ```
38
43
 
39
- 也可以在本机注册 `ati` 和 `anti-trace` 两个等价的启动命令。先在本仓库目录执行:
44
+ ## 主要功能
40
45
 
41
- ```sh
42
- npm run build
43
- npm link
44
- ```
46
+ - **读写代码与执行命令。** 读取、创建和编辑文件,通过 Shell 搜索项目、运行构建与测试。Shell 命令默认超时为 120 秒,过长的输出会截取展示,并保存完整内容供后续读取。
47
+ - **终端交互。** 流式展示模型回复,支持 Markdown、代码高亮、表格、工具卡片和文件差异。输入 `/` 打开命令菜单,输入 `@` 搜索并补全工作区文件。可编辑多行草稿、撤销和重做,也可用 `/language` 切换中英文界面。
48
+ - **图片输入。** 粘贴图片文件路径,或用 `Alt+V`(Windows)和 `Ctrl+V`(macOS/Linux)尝试读取剪贴板图片。支持 PNG、JPEG、GIF 和 WebP,剪贴板读取取决于终端和系统工具,所选模型也须支持图片输入。
49
+ - **会话与上下文。** 按项目保存对话和图片附件,用 `/resume` 继续之前的会话。状态栏显示上下文用量,长会话可自动压缩旧内容,也可用 `/compact` 手动尝试压缩。
45
50
 
46
- 之后在任意工作目录运行 `ati` 或 `anti-trace`,程序会使用该目录作为 cwd,模型配置默认从用户目录加载。`CLI_AGENT_CONFIG` 可显式指定其他 JSON 文件。命令运行的是编译后的 `dist`;修改源码后重新执行 `npm run build` 即可,无需再次 link。`npm link` 只注册本地命令,不会发布到 npm。
51
+ ## 权限与审批
47
52
 
48
- macOS/Linux 使用 Bash。Windows 优先使用 PowerShell(优先 7,回退到系统 5.1);安装 Git for Windows 后还会提供 Git Bash,用于 Bash 脚本和 POSIX 命令。Git Bash 安装在特殊目录时,可在启动前设置 `ANTI_TRACE_GIT_BASH_PATH` 为其 `bin\bash.exe` 的绝对路径。可以从 CMD 或 PowerShell 启动 Anti-trace,工具执行器由程序独立选择。命令默认超时为 120 秒。
53
+ 默认允许读取文件。写入、编辑和 Shell 命令会弹出审批,可以允许一次、在本会话内授权,或拒绝并给出修改意见。审批时可预览待写入的文件差异。会话授权对文件修改类操作生效,Shell 授权仅匹配同一工具中的相同命令。
49
54
 
50
- 进入对话后,可以直接描述任务,例如:
55
+ | 模式 | 行为 |
56
+ | --- | --- |
57
+ | 默认 | 审批写入、编辑和 Shell 命令 |
58
+ | `auto-edit` | 自动允许写入和编辑,Shell 命令仍需审批 |
59
+ | `yolo` | 自动允许所有工具调用 |
51
60
 
52
- ```text
53
- 梳理这个项目的入口和主要模块。
54
- 修复这个函数对空输入的处理,并补上对应测试。
55
- 运行构建,分析报错并修改相关代码。
56
- ```
61
+ 按 `Shift+Tab` 切换模式,也可用 `ati --auto-edit` 或 `ati --yolo` 指定启动模式。工具使用当前用户的系统权限执行。
57
62
 
58
- Agent 会按任务需要读取文件、修改代码和执行命令。这些操作会直接影响项目文件,首次试用建议使用可恢复的项目副本。
63
+ ## 模型配置
59
64
 
60
- ## 模型接入
65
+ 可通过 `/config` 新增、选择和编辑配置文件。一个配置可以包含多个模型,用 `/model` 切换。支持以下接口。
61
66
 
62
- 通过 BYOK JSON 配置自己的模型服务:
63
-
64
- | 接口 | 配置中的 api |
65
- |---|---|
67
+ | 接口 | JSON 中的 `api` |
68
+ | --- | --- |
66
69
  | OpenAI Chat Completions | `openai-completions` |
67
70
  | OpenAI Responses | `openai-responses` |
68
71
  | Anthropic Messages | `anthropic-messages` |
69
72
 
70
- 模型通过 `connection` 引用连接配置,`currentModel` 选择 `models` 中的模型键。连接可以直接填写 `apiKey`,也可以用 `apiKeyEnv` 引用进程环境变量。
71
-
72
- CLI 使用统一的用户数据目录,默认是 `~/.anti-trace`,可通过 `ANTI_TRACE_HOME` 覆盖。模型配置保存在 `profiles/local/configs/`,`/config` 新建的文件也写入这里。`local` 是当前本地用户空间;代码通过 `profileId` 预留未来的用户隔离能力,当前没有登录功能。
73
+ 也可将 [配置示例](byok.example.json) 复制到 `~/.anti-trace/profiles/local/configs/main.json`,替换示例地址、密钥和模型 ID,再按模型规格设置 `contextWindow` 和可选的 `maxOutputTokens`。`models` 中的每个模型通过 `connection` 引用 `connections` 中的连接,`currentModel` 填写要使用的模型配置键。
73
74
 
74
- 启动时依次使用:显式 `CLI_AGENT_CONFIG`、当前项目上次选择、当前用户默认选择、配置目录中唯一有效的配置。首次没有选择记录且存在多个配置时,需要通过 `/config` 选择。用户主动选择配置或模型后,会更新用户默认选择;打开已有项目不会用它的项目选择覆盖用户默认。不存在的记忆路径会提示并回退,显式路径错误会报错。不会自动读取工作目录的 `byok.json` 或 `.env`,也不读取旧目录的配置、偏好和会话。
75
+ - 每个连接填写 `apiKey` 或 `apiKeyEnv` 二者之一。`apiKeyEnv` 引用启动 CLI 的进程环境变量。也可从 [服务商预设示例](byok.providers.example.json) 选取连接。
76
+ - `baseUrl` 填写服务的 API 基址,包含所需的版本前缀(如 `/v1`)。如需指定完整推理地址,将其填入 `endpoint`。
77
+ - 启动时依次尝试 `CLI_AGENT_CONFIG` 指定的配置、当前项目上次选择、用户默认选择、配置目录中唯一有效的配置。首次遇到多个有效配置时,可用 `/config` 选择。
78
+ - 本地数据目录默认为 `~/.anti-trace`,可用 `ANTI_TRACE_HOME` 覆盖。模型配置位于 `profiles/local/configs/`,会话、附件和长工具输出按工作目录归档到 `profiles/local/projects/`。
75
79
 
76
- ```text
77
- ~/.anti-trace/
78
- ├── preferences.json # 全局语言偏好
79
- └── profiles/local/
80
- ├── configs/ # 模型连接配置
81
- ├── default-model.json # 新项目的默认配置与模型
82
- └── projects/<工作目录的 SHA-256>/
83
- ├── project.json # 实际工作路径
84
- ├── last-model.json # 当前项目的配置与模型选择
85
- ├── sessions/ # 会话及图片附件
86
- └── tool-results/ # 完整工具输出
87
- ```
80
+ ## 命令与快捷键
88
81
 
89
- 选择记录只包含配置路径和模型键,不包含凭据。每个项目的会话和工具输出独立;语言偏好在本机共享。文件读写与 Shell 执行继续使用启动目录作为 cwd。临时图片转换文件使用系统临时目录。旧会话不迁移,原文件保留。
90
-
91
- Anthropic Messages 未填写 `maxOutputTokens` 时默认使用 `32000`;若配置的 `contextWindow` 更小,默认输出上限会降到窗口大小。显式填写的输出上限优先。
92
-
93
- `baseUrl` 应包含服务所需的版本前缀,例如 `/v1`。也可从 [厂商配置示例](byok.providers.example.json) 选取连接预设与模型,设置对应的环境变量密钥。示例覆盖九家厂商的 36 个连接选项;各协议、地区和模型的参数按明确规则适配。
94
-
95
- ## 常用命令
96
-
97
- 交互界面默认收起命令列表。输入 `/` 打开命令菜单,继续输入按名称筛选;↑↓ 选择,Enter 确认,Tab 仅补全,Esc 返回。模型、effort、思考及展示开关、会话恢复和配置管理使用二级界面,无需手输参数;原有显式参数仍兼容。输入框默认位于底部,滚轮和 PgUp/PgDn 回看历史,Ctrl+End 返回最新;Shift+拖动选中文本。
82
+ 输入 `/` 后可继续输入以筛选命令,用方向键选择,按 `Enter` 确认、`Tab` 补全、`Esc` 关闭。
98
83
 
99
84
  | 命令 | 用途 |
100
- |---|---|
101
- | `/help` | 查看帮助 |
102
- | `/new` | 开始新会话 |
103
- | `/resume` | 方向键选择并恢复会话 |
104
- | `/model` | 从当前配置选择模型 |
105
- | `/config` | 配置文件菜单,同级新增/修改;同一文件新增多个模型,Enter 独立编辑字段 |
106
- | `/reload` | 重新读取模型配置 |
107
- | `/thinking` | 选择开启/关闭模型思考 |
108
- | `/effort` | 方向键选择 low/medium/high/xhigh/max |
109
- | `/thinking-display` | 选择开启/关闭思考文字默认展示 |
110
- | `/language` | 切换中文/English 界面,即时生效并记住偏好 |
111
- | `/context [正整数]` | 查看或调整上下文窗口 |
112
- | `/compact` | 尝试手动压缩上下文 |
85
+ | --- | --- |
86
+ | `/help` | 查看命令和快捷键 |
87
+ | `/new` / `/resume` | 开始新会话或恢复当前项目的已有会话 |
88
+ | `/config [路径]` | 管理配置,或直接加载指定 JSON 文件 |
89
+ | `/model [模型键]` | 从当前配置中选择模型 |
90
+ | `/reload` | 重新读取当前配置 |
91
+ | `/thinking [on\|off\|default]` | 开启、关闭模型思考,或使用服务商默认值 |
92
+ | `/effort` | 选择思考档位,支持 `low`、`medium`、`high`、`xhigh`、`max`,实际效果取决于模型与接口 |
93
+ | `/thinking-display [on\|off]` | 设置思考文本是否默认展开 |
94
+ | `/context [正整数]` / `/compact` | 查看或调整上下文窗口,或尝试压缩上下文 |
95
+ | `/language [zh\|en]` | 切换并记住界面语言 |
113
96
  | `/exit` | 退出 |
114
97
 
115
- 当前整体 TUI 已进入试用,交互与实现见 [架构文档](docs/architecture.md#4-分层),验证和待办见 [开发进度](docs/progress.md)。支持 Markdown/代码/表格、工具卡与 Diff、权限审批、@ 文件补全和附件栏。Ctrl+O 在回看处原位展开/收起,在最新处定位并展开最近工具;Shift+Tab 切换权限模式。可用 `npm start -- --auto-edit` 或 `npm start -- --yolo` 显式指定启动模式。
116
-
117
- Enter 提交,Shift/Alt+Enter 或反斜杠后 Enter 换行;Ctrl+C 中断生成或清空草稿,空闲且草稿为空时退出。Ctrl+Z 撤销,Ctrl+Y 重做。快捷键识别取决于终端。
118
-
119
- `/reload` 重新读取模型配置,保留当前模型选择和思考偏好;`/new` 继承当前设置,`/resume` 从已加载目录解析会话保存的模型引用。思考显示开关只影响显示,不改变模型请求。
120
-
121
- ## 项目方向
98
+ | 快捷键 | 用途 |
99
+ | --- | --- |
100
+ | `Enter` / `Shift+Enter` 或 `Alt+Enter` | 提交 / 换行 |
101
+ | `Ctrl+Z` / `Ctrl+Y` 或 `Ctrl+Shift+Z` | 撤销 / 重做草稿修改 |
102
+ | `Ctrl+C` | 中断生成或清空草稿,空闲且草稿为空时退出 |
103
+ | `Ctrl+O` | 展开或收起工具输出和思考文本 |
104
+ | 滚轮或 `PgUp` / `PgDn` / `Ctrl+End` | 回看对话 / 返回最新输出 |
122
105
 
123
- 项目目前处于早期开发阶段。长期目标是让用户用自然语言描述希望增加或修改的功能,由 agent 修改自身的工具、CLI 界面等能力,再通过热启动应用变更。
106
+ 快捷键能否被识别取决于终端。
124
107
 
125
- 这项能力尚未实现,顶部架构图展示的是预计设计。当前先完善模型接入、工具执行、会话与上下文管理等基础能力。
108
+ ## 开发
126
109
 
127
- - [ ] 根据自然语言需求动态修改工具、CLI 界面等功能。
128
- - [ ] 验证功能变更,并通过热启动加载修改。
129
- - [x] 厂商预设、思考控制与统一设置链路。
130
- - [ ] 在 v1.3 完善 TUI 交互。
131
- - [x] 建立可复现的离线测试框架和 Windows/Linux/macOS CI。
132
- - [ ] 扩展真实模型与原生终端验收。
133
- - [ ] 修复剩余的工具配对和上下文溢出提示问题。
134
-
135
- ## 已知限制
110
+ ```sh
111
+ git clone https://github.com/sadgsk/Anti-trace.git
112
+ cd Anti-trace
113
+ npm ci
114
+ npm start
115
+ ```
136
116
 
137
- - Windows 需要可用的 PowerShell 或 Git Bash;没有 Git Bash 时只提供 PowerShell,显式配置的 Bash 路径无效时会提示配置错误。见 [问题记录](docs/future-issues.md)。
138
- - 可恢复的上下文溢出错误提前显示问题仍待处理;工具批次中断配对已在 TUI 批次修复,见 [评审记录](docs/review-records.md)。
139
- - 已有本地 HTTP SSE 和 macOS POSIX PTY 验证记录,真实模型、剪贴板和其他终端平台的覆盖仍不完整。
140
- - 正式测试位于 `tests/`。运行 `npm test` 执行离线测试,`npm run check` 执行类型检查、测试和构建;命令、覆盖范围与三端 CI 见 [测试指南](docs/testing.md)。真实模型检查使用独立的显式入口。
117
+ `npm test` 运行离线测试,`npm run check` 运行类型检查、测试和构建。推送分支或提交 Pull Request 会触发 GitHub Actions,在 Windows、macOS 和 Linux 上用 Node.js 22 和 24 运行 CI。
141
118
 
142
- ## 开发文档与来源
119
+ 推送 `vX.Y.Z` 格式的版本标签会触发 npm 发布流程。工作流确认标签版本与包版本一致、提交已进入 `main`,通过 CI 和安装检查后发布到 npm。
143
120
 
144
- - [开发进度](docs/progress.md):当前状态、待办与开发记录。
145
- - [架构书](docs/architecture.md):模块职责与设计。
146
- - [测试与 CI](docs/testing.md):本地命令、测试编写、隔离、覆盖率和三端 CI。
147
- - [npm 自动发布](docs/releases.md):首次绑定 npm 与 GitHub,以及通过版本 tag 自动发布。
148
- - [关键认知](docs/key-points.md):读码时形成的确定结论(工具字段位置、缓存前缀等),含原因与验证方式。
121
+ ## 文档
149
122
 
150
- 项目从阅读和参考 [Pi](https://github.com/earendil-works/pi) 起步,部分基础代码参考并改写自 Pi,使用自己的 `Harness` 和功能设计,当前不依赖 Pi 的运行时包。
123
+ - [测试与 CI](docs/testing.md)
124
+ - [npm 发布流程](docs/releases.md)
125
+ - [架构与实现说明](docs/architecture.md)
151
126
 
152
127
  ## 许可证
153
128
 
154
- [MIT](LICENSE)。源自 Pi 的部分保留其原有版权和许可声明。
129
+ [MIT](LICENSE)。项目部分基础代码参考并改写自 [Pi](https://github.com/earendil-works/pi),相关代码保留原有版权和许可声明。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anti-trace",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "license": "MIT",
5
5
  "description": "Terminal AI coding agent with bring-your-own-key model support",
6
6
  "repository": {
@@ -31,7 +31,8 @@
31
31
  "start": "tsx src/cli/main.ts",
32
32
  "typecheck": "tsc --noEmit",
33
33
  "build": "tsc",
34
- "prepack": "npm run build",
34
+ "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
35
+ "prepack": "npm run clean && npm run build",
35
36
  "test": "node scripts/run-tests.mjs",
36
37
  "test:unit": "node scripts/run-tests.mjs unit",
37
38
  "test:integration": "node scripts/run-tests.mjs integration regressions",
@@ -59,6 +60,7 @@
59
60
  "devDependencies": {
60
61
  "@types/node": "22.19.19",
61
62
  "@types/react": "19.2.18",
63
+ "@xterm/headless": "6.0.0",
62
64
  "c8": "12.0.0",
63
65
  "tsx": "4.21.0",
64
66
  "typescript": "5.9.3"