@kyo-so/cli 0.8.0 → 0.9.1

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.zh-CN.md CHANGED
@@ -36,6 +36,45 @@ Kyoso 不会应用代码更改。
36
36
 
37
37
  无需全局安装。通过 `npx` 或 `bunx` 运行 Kyoso。
38
38
 
39
+ ### 集成模式
40
+
41
+ | 模式 | 安装内容 | MCP | 客户端 |
42
+ | ------------------ | -------------------- | --: | ------------------ |
43
+ | Marketplace Plugin | Skill+本地stdio MCP | 有 | Codex/Claude Code |
44
+ | CLI+Skill-only | npm CLI+Skill | 无 | Codex/Claude Code |
45
+ | 手动setup | 手动MCP注册+Skill | 有 | Codex/Claude Code |
46
+
47
+ 拿不准时请选择Marketplace Plugin:两条命令即可同时安装Skill和MCP server。步骤见下方的[Codex](#codex)/[Claude Code](#claude-code)小节。
48
+
49
+ #### Marketplace Plugin
50
+
51
+ Plugin包含Skill和pin到已发布Kyoso CLI精确版本的MCP定义,但不包含CLI本体。MCP首次启动需要访问npm网络。已缓存的package可能可以offline启动,但不作保证。manifest中的`Read` capability仅是显示metadata,不会授予额外filesystem权限。
52
+
53
+ Plugin中的Skill将内置的`kyoso` MCP server声明为dependency,因此显式Kyoso review会通过MCP而不是CLI fallback。如果禁用内置Plugin MCP,应将Plugin Skill视为不可用:重新启用MCP,或移除Plugin并改用CLI+Skill-only。Plugin不是CLI fallback mode。
54
+
55
+ #### CLI+Skill-only
56
+
57
+ ```bash
58
+ # Global CLI+Codex Skill
59
+ npm install -g @kyo-so/cli
60
+ kyoso setup codex --write --skill-only --global
61
+
62
+ # Project CLI+Codex Skill
63
+ npm install -D @kyo-so/cli
64
+ npx kyoso setup codex --write --skill-only
65
+ ```
66
+
67
+ Claude Code请将`codex`替换为`claude-code`。默认仍为dry-run。`--skill-only`不会读写MCP配置,也不能与`--runner`/`--command`组合使用。
68
+
69
+ Skill-only有意不声明MCP dependency。当它到达`npx`或`bunx`的package-runner fallback时,Codex Auto mode可能要求sandbox network escalation approval;在PATH上安装`kyoso`可以避免该fallback。
70
+
71
+ #### 迁移
72
+
73
+ - 从手动MCP迁移到CLI+Skill:先安装CLI和Skill,再运行`codex mcp remove kyoso`或`claude mcp remove kyoso --scope local|project|user`。
74
+ - 从CLI+Skill迁移到Plugin:添加Plugin并确认enabled后,再删除手动MCP注册。手动复制的Skill不会自动删除。
75
+ - 从Plugin迁移到CLI+Skill:先安装CLI和Skill,再运行`codex plugin remove kyoso@kyoso`。
76
+ - 从CLI+Skill恢复到手动MCP:运行`kyoso setup codex --write`或`kyoso setup claude-code --write`。
77
+
39
78
  ### Claude Only / Codex Only
40
79
 
41
80
  Kyoso 可以在只有 Claude 或只有 Codex 可用时运行。请在 `kyoso.toml` 中禁用缺失的 backend;示例见 `examples/claude-only.toml` 和 `examples/codex-only.toml`。
@@ -54,21 +93,32 @@ claude setup-token
54
93
 
55
94
  设置该命令得到的 `CLAUDE_CODE_OAUTH_TOKEN`,或设置 `ANTHROPIC_API_KEY` 以使用 direct API billing。
56
95
 
57
- 2. 注册 MCP 并安装 review skill
96
+ 2. 安装 Marketplace Plugin(推荐)
97
+
98
+ ```text
99
+ /plugin marketplace add hokupod/kyoso
100
+ /plugin install kyoso@kyoso
101
+ ```
102
+
103
+ Plugin 会安装 Kyoso review Skill 和 pin 到已发布 CLI version 的本地 stdio MCP server。通过 Plugin 安装时,无需运行 `kyoso setup claude-code`。
104
+
105
+ 3. 或者,注册 MCP 并安装 review skill。
58
106
 
59
107
  ```bash
60
108
  npx @kyo-so/cli setup claude-code --write
61
109
  bunx @kyo-so/cli setup claude-code --write
62
110
  ```
63
111
 
64
- 3. 验证 setup。
112
+ 需要手动注册 MCP 时,请使用 `examples/claude-code-mcp.json`。
113
+
114
+ 4. 验证 setup。
65
115
 
66
116
  ```bash
67
117
  npx @kyo-so/cli doctor
68
118
  bunx @kyo-so/cli doctor
69
119
  ```
70
120
 
71
- 4. 从 Claude Code 请求 review。
121
+ 5. 从 Claude Code 请求 review。
72
122
 
73
123
  ```text
74
124
  Use Kyoso plan_review on this plan before implementation.
@@ -82,21 +132,56 @@ Use Kyoso plan_review on this plan before implementation.
82
132
  codex login
83
133
  ```
84
134
 
85
- 2. 注册 MCP 并安装 review skill
135
+ 2. 安装 Marketplace Plugin(推荐)
136
+
137
+ ```bash
138
+ codex plugin marketplace add hokupod/kyoso
139
+ codex plugin add kyoso@kyoso
140
+ ```
141
+
142
+ 也可以在Codex desktop的Plugins page或`/plugins`中选择Kyoso。若新添加的Marketplace未显示,请refresh/restart desktop app。使用`codex plugin list --marketplace kyoso --json`确认安装,使用`codex plugin remove kyoso@kyoso`删除Plugin。通过 Plugin 安装时,无需运行 `kyoso setup codex`。
143
+
144
+ 在Codex Auto mode中,需要approval的Kyoso tool调用可能会被拒绝。若要仅为个人账户预先批准,请将以下设置添加到`~/.codex/config.toml`(若已设置`CODEX_HOME`,则为`$CODEX_HOME/config.toml`)。**只有在你信任Kyoso,并接受所选代码与review context可能发送给已配置的外部model provider时,才应启用此设置。** Plugin默认不会启用它。
145
+
146
+ ```toml
147
+ [plugins."kyoso@kyoso".mcp_servers.kyoso.tools.diff_review]
148
+ approval_mode = "approve"
149
+
150
+ [plugins."kyoso@kyoso".mcp_servers.kyoso.tools.plan_review]
151
+ approval_mode = "approve"
152
+
153
+ [plugins."kyoso@kyoso".mcp_servers.kyoso.tools.security_review]
154
+ approval_mode = "approve"
155
+ ```
156
+
157
+ 如果Kyoso不是通过Plugin、而是直接注册为MCP server(`kyoso setup codex --write` 或手动设置),请使用不带 `plugins."kyoso@kyoso".` 前缀的 `mcp_servers.kyoso` 键:
158
+
159
+ ```toml
160
+ [mcp_servers.kyoso.tools.diff_review]
161
+ approval_mode = "approve"
162
+
163
+ [mcp_servers.kyoso.tools.plan_review]
164
+ approval_mode = "approve"
165
+
166
+ [mcp_servers.kyoso.tools.security_review]
167
+ approval_mode = "approve"
168
+ ```
169
+
170
+ 3. 或者,注册 MCP 并安装 review skill。
86
171
 
87
172
  ```bash
88
173
  npx @kyo-so/cli setup codex --write
89
174
  bunx @kyo-so/cli setup codex --write
90
175
  ```
91
176
 
92
- 3. 验证 setup。
177
+ 4. 验证 setup。
93
178
 
94
179
  ```bash
95
180
  npx @kyo-so/cli doctor
96
181
  bunx @kyo-so/cli doctor
97
182
  ```
98
183
 
99
- 4. 从 Codex 请求 review。
184
+ 5. 从 Codex 请求 review。
100
185
 
101
186
  ```text
102
187
  Use Kyoso diff_review on the current diff. I need a second opinion before merging.
@@ -141,6 +226,8 @@ kyoso doctor
141
226
  kyoso init
142
227
  kyoso setup codex
143
228
  kyoso setup claude-code
229
+ kyoso setup codex --write --skill-only
230
+ kyoso setup claude-code --write --skill-only
144
231
  ```
145
232
 
146
233
  ## Usage Examples
@@ -203,11 +290,13 @@ MCP stdout 专用于 protocol messages。Logs 会写到 stderr 或 local audit t
203
290
 
204
291
  内置的 `kyoso-review` skill 有意保持范围很窄。只有当你明确请求 Kyoso、multi-agent review、plan review、security review、CISA Secure by Design review 或 diff review 时,才应触发它。
205
292
 
206
- Kyoso MCP tools 可用时,skill 会优先使用它们。如果尚未注册 MCP server,skill 会按照文档中的 CLI fallback,通过 `npx -y @kyo-so/cli` 或 `bunx @kyo-so/cli` 获取 JSON output
293
+ Skill使用第一个可用路径,顺序是Kyoso MCP tools、PATH上已安装的`kyoso`、`npx -y @kyo-so/cli`、`bunx @kyo-so/cli`。package runner fallback可能需要network access,也可能发生version drift,因此MCP-less正常路径应使用已安装CLI
294
+
295
+ `kyoso setup codex --write --skill-only`默认将canonical Skill directory复制到`.agents/skills/kyoso-review/`。添加`--global`后复制到`~/.agents/skills/kyoso-review/`。
207
296
 
208
- `npx @kyo-so/cli setup codex --write` 和 `bunx @kyo-so/cli setup codex --write` 默认将其复制到 `.agents/skills/kyoso-review/`。添加 `--global` 会复制到 `~/.agents/skills/kyoso-review/`。
297
+ `kyoso setup claude-code --write --skill-only`默认复制到`.claude/skills/kyoso-review/`。添加`--global`后复制到`~/.claude/skills/kyoso-review/`。
209
298
 
210
- `npx @kyo-so/cli setup claude-code --write` `bunx @kyo-so/cli setup claude-code --write` 默认将其复制到 `.claude/skills/kyoso-review/`。添加 `--global` 会复制到 `~/.claude/skills/kyoso-review/`。
299
+ managed install会把canonical directory digestCLI version记录到`.kyoso-install.json`。当前或已知historical copy会被adopt并自动更新;修改过或未知的copy会报告conflict并保持不变。`--force`只替换该Skill directory,不会删除或覆盖MCP配置。
211
300
 
212
301
  ## Safety Model
213
302
 
@@ -221,6 +310,10 @@ Repository content、plans、diffs 和 selected files 在 backend prompts 中被
221
310
 
222
311
  Finding title 会为 aggregation 规范化为简洁英文;evidence、recommendations 和 summaries 可以继续使用用户的语言。
223
312
 
313
+ Audit trace 写入受信任的 user state root,而不是由 workspace 控制的 path。在受支持的 POSIX runtime 上,Kyoso 会在可用时使用 absolute `$XDG_STATE_HOME`,否则使用 `$HOME/.local/state`;只有 owner、permission、containment 和 symlink 检查均成功时才会写入。验证或 safe open 失败时,它不会静默 fallback 到其他 location:会为该 review fail-close 禁用 Audit 写入,返回 sanitized warning,并继续 review。
314
+
315
+ Windows,以及无法证明所需 filesystem capability 的环境,会 fail-close 禁用 Audit 写入。能够修改 trusted state root 或 rename 已验证 inode 的 same OS user hostile process 不在此保证范围内;防御该威胁需要 OS sandbox 或 native dirfd-based support。
316
+
224
317
  ## Agent Auth
225
318
 
226
319
  可用时,Codex 使用 local `codex` login。默认 subscription-backed path 不需要 API key。
@@ -266,15 +359,15 @@ effort 的工作方式不同:Kyoso 不会为它设置 env var,而是在每
266
359
 
267
360
  ## Audit
268
361
 
269
- Audit traces 写入:
362
+ 在受支持的 POSIX runtime 上,Audit traces 会写入 user state base(absolute `$XDG_STATE_HOME`,否则 `$HOME/.local/state`)下:
270
363
 
271
364
  ```text
272
- .kyoso/traces/<yyyy-mm-dd>/<traceId>.jsonl
365
+ <state-base>/kyoso/workspaces/<sha256(realpath(cwd))>/<logical audit.directory>/<yyyy-mm-dd>/<traceId>.jsonl
273
366
  ```
274
367
 
275
- Raw agent output raw file contents 默认禁用。
368
+ `audit.directory`是 logical relative directory(默认:`.kyoso/traces`),不是 workspace 内的 directory。现有 workspace `.kyoso/traces`不会被自动迁移或删除。
276
369
 
277
- 不要将 `.kyoso/traces/` 提交到 Git。`kyoso init` 会把 `.kyoso/` 添加到 `.gitignore`,本 repository 也同样如此。如果启用 `audit.includeRawAgentOutput`,traces 可能会保留 sensitive review output;请按照 local retention policy 定期删除旧 traces。
370
+ Raw agent output raw file contents 默认禁用。如果启用 `audit.includeRawAgentOutput`,traces 可能会保留 sensitive review output;请按照 local retention policy 删除旧 traces。在 Windows 或无法证明安全 filesystem capability 的环境中,Audit trace 写入会保持禁用,review 会返回 sanitized warning
278
371
 
279
372
  ## Config
280
373
 
@@ -0,0 +1,20 @@
1
+ import type { FileHandle } from "node:fs/promises";
2
+ export declare const AUDIT_WARNING_UNSUPPORTED_OPEN_CAPABILITY = "AUDIT_DISABLED_UNSUPPORTED_CAPABILITY: Audit trace writing requires unavailable filesystem capabilities.";
3
+ export type AuditOpenConstants = Partial<Record<"O_CREAT" | "O_EXCL" | "O_APPEND" | "O_WRONLY" | "O_NOFOLLOW" | "O_NONBLOCK", number>>;
4
+ export type OpenVerifiedTraceFileOptions = {
5
+ kyosoRoot: string;
6
+ workspaceHash: string;
7
+ logicalDirectory: string;
8
+ date: string;
9
+ traceId: string;
10
+ uid: number;
11
+ workspaceRoot: string;
12
+ openConstants?: AuditOpenConstants;
13
+ beforeOpen?: (tracePath: string) => Promise<void> | void;
14
+ };
15
+ export type OpenedTraceFile = {
16
+ handle: FileHandle;
17
+ tracePath: string;
18
+ };
19
+ export declare function openVerifiedTraceFile(options: OpenVerifiedTraceFileOptions): Promise<OpenedTraceFile>;
20
+ export declare function secureOpenFlags(provided?: AuditOpenConstants): number | undefined;
@@ -0,0 +1,38 @@
1
+ export declare const AUDIT_WARNING_DIRECTORY_IGNORED = "AUDIT_DIRECTORY_IGNORED: Audit directory is invalid; using the default logical directory.";
2
+ export declare const AUDIT_WARNING_UNSUPPORTED_PLATFORM = "AUDIT_DISABLED_UNSUPPORTED_PLATFORM: Audit trace writing is unavailable on this platform.";
3
+ export declare const AUDIT_WARNING_UNSUPPORTED_CAPABILITY = "AUDIT_DISABLED_UNSUPPORTED_CAPABILITY: Audit trace writing requires unavailable filesystem capabilities.";
4
+ export declare const AUDIT_WARNING_UNSAFE_STATE_ROOT = "AUDIT_DISABLED_UNSAFE_STATE_ROOT: Audit state root could not be verified.";
5
+ export type AuditRuntimeOptions = {
6
+ env?: NodeJS.ProcessEnv;
7
+ platform?: NodeJS.Platform;
8
+ getuid?: () => number | undefined;
9
+ };
10
+ export type ResolvedAuditStateRoot = {
11
+ stateBase: string;
12
+ kyosoRoot: string;
13
+ workspaceRoot: string;
14
+ workspaceHash: string;
15
+ logicalDirectory: string;
16
+ uid: number;
17
+ warnings: string[];
18
+ };
19
+ export type AuditStateRootResolution = ResolvedAuditStateRoot | {
20
+ warnings: string[];
21
+ };
22
+ export type AuditStateRootCapability = {
23
+ available: boolean;
24
+ };
25
+ export declare function resolveAuditStateRoot(options: {
26
+ cwd: string;
27
+ directory: string;
28
+ } & AuditRuntimeOptions): Promise<AuditStateRootResolution>;
29
+ export declare function inspectAuditStateRootCapability(options: {
30
+ cwd: string;
31
+ } & AuditRuntimeOptions): Promise<AuditStateRootCapability>;
32
+ export declare function ensureTrustedDirectory(options: {
33
+ root: string;
34
+ segments: string[];
35
+ uid: number;
36
+ workspaceRoot?: string;
37
+ }): Promise<string>;
38
+ export declare function isResolvedAuditStateRoot(resolution: AuditStateRootResolution): resolution is ResolvedAuditStateRoot;
@@ -1,12 +1,24 @@
1
+ import type { FileHandle } from "node:fs/promises";
2
+ import { type AuditRuntimeOptions } from "./stateRoot.js";
3
+ import { type AuditOpenConstants } from "./safeTraceFile.js";
4
+ export declare const AUDIT_WARNING_WRITE_FAILED = "AUDIT_WRITE_FAILED: Audit trace writing failed; no further audit events will be written.";
5
+ export declare const AUDIT_WARNING_FINALIZE_FAILED = "AUDIT_FINALIZE_FAILED: Audit trace close failed.";
6
+ export declare const AUDIT_WARNING_WRITE_AFTER_FINALIZE = "AUDIT_WRITE_AFTER_FINALIZE: Audit trace is already finalized.";
1
7
  export type TraceWriter = {
2
- tracePath?: string;
8
+ readonly tracePath?: string;
3
9
  warnings: string[];
4
10
  write(event: Record<string, unknown>): Promise<void>;
11
+ finalize(): Promise<void>;
5
12
  };
6
- export declare function createTraceWriter(options: {
13
+ export type TraceWriterOptions = {
7
14
  enabled: boolean;
8
15
  directory: string;
9
16
  traceId: string;
10
17
  cwd: string;
11
18
  includeRawAgentOutput?: boolean;
12
- }): TraceWriter;
19
+ openConstants?: AuditOpenConstants;
20
+ beforeOpen?: (tracePath: string) => Promise<void> | void;
21
+ closeHandle?: (handle: FileHandle) => Promise<void>;
22
+ writeChunk?: (handle: FileHandle, buffer: Buffer, offset: number) => Promise<number>;
23
+ } & AuditRuntimeOptions;
24
+ export declare function createTraceWriter(options: TraceWriterOptions): TraceWriter;