claude-coder 1.9.0 → 1.9.2

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 (74) hide show
  1. package/README.md +214 -214
  2. package/bin/cli.js +155 -155
  3. package/package.json +55 -55
  4. package/recipes/_shared/roles/developer.md +11 -11
  5. package/recipes/_shared/roles/product.md +12 -12
  6. package/recipes/_shared/roles/tester.md +12 -12
  7. package/recipes/_shared/test/report-format.md +86 -86
  8. package/recipes/backend/base.md +27 -27
  9. package/recipes/backend/components/auth.md +18 -18
  10. package/recipes/backend/components/crud-api.md +18 -18
  11. package/recipes/backend/components/file-service.md +15 -15
  12. package/recipes/backend/manifest.json +20 -20
  13. package/recipes/backend/test/api-test.md +25 -25
  14. package/recipes/console/base.md +37 -37
  15. package/recipes/console/components/modal-form.md +20 -20
  16. package/recipes/console/components/pagination.md +17 -17
  17. package/recipes/console/components/search.md +17 -17
  18. package/recipes/console/components/table-list.md +18 -18
  19. package/recipes/console/components/tabs.md +14 -14
  20. package/recipes/console/components/tree.md +15 -15
  21. package/recipes/console/components/upload.md +15 -15
  22. package/recipes/console/manifest.json +24 -24
  23. package/recipes/console/test/crud-e2e.md +47 -47
  24. package/recipes/h5/base.md +26 -26
  25. package/recipes/h5/components/animation.md +11 -11
  26. package/recipes/h5/components/countdown.md +11 -11
  27. package/recipes/h5/components/share.md +11 -11
  28. package/recipes/h5/components/swiper.md +11 -11
  29. package/recipes/h5/manifest.json +21 -21
  30. package/recipes/h5/test/h5-e2e.md +20 -20
  31. package/src/commands/auth.js +420 -362
  32. package/src/commands/setup-modules/helpers.js +100 -100
  33. package/src/commands/setup-modules/index.js +25 -25
  34. package/src/commands/setup-modules/mcp.js +115 -115
  35. package/src/commands/setup-modules/provider.js +260 -260
  36. package/src/commands/setup-modules/safety.js +47 -47
  37. package/src/commands/setup-modules/simplify.js +52 -52
  38. package/src/commands/setup.js +172 -172
  39. package/src/common/assets.js +245 -245
  40. package/src/common/config.js +125 -125
  41. package/src/common/constants.js +55 -55
  42. package/src/common/indicator.js +260 -260
  43. package/src/common/interaction.js +170 -170
  44. package/src/common/logging.js +77 -77
  45. package/src/common/sdk.js +50 -50
  46. package/src/common/tasks.js +88 -88
  47. package/src/common/utils.js +213 -213
  48. package/src/core/coding.js +33 -33
  49. package/src/core/go.js +264 -264
  50. package/src/core/hooks.js +500 -500
  51. package/src/core/init.js +166 -165
  52. package/src/core/plan.js +188 -187
  53. package/src/core/prompts.js +247 -247
  54. package/src/core/repair.js +36 -36
  55. package/src/core/runner.js +471 -458
  56. package/src/core/scan.js +93 -93
  57. package/src/core/session.js +280 -271
  58. package/src/core/simplify.js +74 -74
  59. package/src/core/state.js +105 -105
  60. package/src/index.js +76 -76
  61. package/templates/bash-process.md +12 -12
  62. package/templates/codingSystem.md +65 -65
  63. package/templates/codingUser.md +17 -17
  64. package/templates/coreProtocol.md +29 -29
  65. package/templates/goSystem.md +130 -130
  66. package/templates/guidance.json +72 -72
  67. package/templates/planSystem.md +78 -78
  68. package/templates/planUser.md +8 -8
  69. package/templates/requirements.example.md +57 -57
  70. package/templates/scanSystem.md +120 -120
  71. package/templates/scanUser.md +10 -10
  72. package/templates/test_rule.md +194 -194
  73. package/templates/web-testing.md +17 -17
  74. package/types/index.d.ts +217 -217
package/types/index.d.ts CHANGED
@@ -1,217 +1,217 @@
1
- import { WriteStream } from 'fs';
2
-
3
- // ─── Config ───────────────────────────────────────────────
4
-
5
- export interface Config {
6
- provider?: string;
7
- model?: string;
8
- defaultOpus?: string;
9
- maxTurns?: number;
10
- stallTimeout: number;
11
- editThreshold?: number;
12
- webTestTool?: 'playwright' | 'chrome-devtools' | '';
13
- webTestMode?: 'persistent' | 'isolated' | 'extension' | '';
14
- simplifyInterval: number;
15
- simplifyCommits: number;
16
- [key: string]: unknown;
17
- }
18
-
19
- // ─── Main Options ─────────────────────────────────────────
20
-
21
- export interface MainOpts {
22
- max?: number;
23
- pause?: number;
24
- dryRun?: boolean;
25
- readFile?: string;
26
- model?: string;
27
- n?: number;
28
- planOnly?: boolean;
29
- interactive?: boolean;
30
- reset?: boolean;
31
- deployTemplates?: boolean;
32
- projectRoot?: string;
33
- reqFile?: string;
34
- }
35
-
36
- // ─── Session ──────────────────────────────────────────────
37
-
38
- export interface SessionRunOptions {
39
- logFileName: string;
40
- logStream?: WriteStream;
41
- sessionNum?: number;
42
- label?: string;
43
- execute: (session: Session) => Promise<Record<string, unknown>>;
44
- }
45
-
46
- export interface QueryResult {
47
- messages: SDKMessage[];
48
- success: boolean;
49
- subtype: string | null;
50
- cost: number | null;
51
- usage: { input_tokens: number; output_tokens: number } | null;
52
- turns: number | null;
53
- }
54
-
55
- export interface RunQueryOpts {
56
- onMessage?: (message: SDKMessage, messages: SDKMessage[]) => void | 'break';
57
- }
58
-
59
- export interface SDKMessage {
60
- type: 'assistant' | 'tool_result' | 'result' | string;
61
- message?: {
62
- content?: Array<{
63
- type: 'text' | 'tool_use' | string;
64
- text?: string;
65
- name?: string;
66
- input?: Record<string, unknown>;
67
- }>;
68
- };
69
- result?: string;
70
- subtype?: string;
71
- total_cost_usd?: number;
72
- usage?: { input_tokens: number; output_tokens: number };
73
- num_turns?: number;
74
- is_error?: boolean;
75
- content?: string;
76
- [key: string]: unknown;
77
- }
78
-
79
- export interface SessionRunResult {
80
- exitCode: number;
81
- logFile: string | null;
82
- stalled: boolean;
83
- [key: string]: unknown;
84
- }
85
-
86
- export declare class Session {
87
- static _sdk: unknown;
88
-
89
- /** 确保 SDK 已加载(懒加载单例) */
90
- static ensureSDK(config: Config): Promise<unknown>;
91
-
92
- /** 创建 Session 实例并执行回调,自动管理生命周期 */
93
- static run(type: string, config: Config, options: SessionRunOptions): Promise<SessionRunResult>;
94
-
95
- readonly config: Config;
96
- readonly type: string;
97
- readonly indicator: Indicator;
98
- logStream: WriteStream | null;
99
- logFile: string | null;
100
- hooks: unknown;
101
- abortController: AbortController;
102
-
103
- constructor(
104
- type: string,
105
- config: Config,
106
- options: { logFileName: string; logStream?: WriteStream; sessionNum?: number; label?: string },
107
- );
108
-
109
- /** 构建 SDK query 选项,自动附加 hooks、abortController、权限模式 */
110
- buildQueryOptions(overrides?: Record<string, unknown>): Record<string, unknown>;
111
-
112
- /** 执行一次 SDK 查询,遍历消息流并收集结果 */
113
- runQuery(prompt: string, queryOpts: Record<string, unknown>, opts?: RunQueryOpts): Promise<QueryResult>;
114
-
115
- /** 检查会话是否因停顿超时 */
116
- isStalled(): boolean;
117
-
118
- /** 结束会话:清理 hooks、关闭日志流、停止 indicator */
119
- finish(): void;
120
- }
121
-
122
- // ─── Indicator ────────────────────────────────────────────
123
-
124
- export declare class Indicator {
125
- phase: 'thinking' | 'coding';
126
- step: string;
127
- toolTarget: string;
128
- sessionNum: number;
129
- startTime: number;
130
- stallTimeoutMin: number;
131
- toolRunning: boolean;
132
- currentToolName: string;
133
- projectRoot: string;
134
-
135
- /** 启动 indicator 渲染循环 */
136
- start(sessionNum: number, stallTimeoutMin: number, projectRoot: string): void;
137
-
138
- /** 停止渲染循环并清除终端行 */
139
- stop(): void;
140
-
141
- updatePhase(phase: 'thinking' | 'coding'): void;
142
- updateStep(step: string): void;
143
- appendActivity(toolName: string, summary: string): void;
144
- updateActivity(): void;
145
-
146
- /** 标记工具开始执行 */
147
- startTool(name: string): void;
148
-
149
- /** 标记工具执行结束 */
150
- endTool(): void;
151
-
152
- pauseRendering(): void;
153
- resumeRendering(): void;
154
-
155
- /** 生成当前状态行文本 */
156
- getStatusLine(): string;
157
- }
158
-
159
- /** 根据工具名称和输入推断当前阶段和步骤,更新 indicator 状态 */
160
- export declare function inferPhaseStep(
161
- indicator: Indicator,
162
- toolName: string,
163
- toolInput: Record<string, unknown> | string,
164
- ): void;
165
-
166
- // ─── Main ─────────────────────────────────────────────────
167
-
168
- /** 应用入口:初始化资产、加载配置、分发命令 */
169
- export declare function main(
170
- command: string,
171
- input: string,
172
- opts?: MainOpts,
173
- ): Promise<unknown>;
174
-
175
- // ─── Logging ──────────────────────────────────────────────
176
-
177
- /** 处理 SDK 消息并写入日志流 */
178
- export declare function logMessage(
179
- message: SDKMessage,
180
- logStream: WriteStream,
181
- indicator?: Indicator,
182
- ): void;
183
-
184
- /** 从消息列表中提取 type='result' 的消息 */
185
- export declare function extractResult(messages: SDKMessage[]): SDKMessage | null;
186
-
187
- /** 从消息列表中提取结果文本 */
188
- export declare function extractResultText(messages: SDKMessage[]): string;
189
-
190
- // ─── AssetManager ─────────────────────────────────────────
191
-
192
- export declare class AssetManager {
193
- projectRoot: string | null;
194
- loopDir: string | null;
195
- assetsDir: string | null;
196
- bundledDir: string;
197
-
198
- init(projectRoot?: string): void;
199
- path(name: string): string | null;
200
- dir(name: string): string | null;
201
- exists(name: string): boolean;
202
- read(name: string): string | null;
203
- readJson(name: string, fallback?: unknown): unknown;
204
- write(name: string, content: string): void;
205
- writeJson(name: string, data: unknown): void;
206
- render(name: string, vars?: Record<string, string>): string;
207
- ensureDirs(): void;
208
- deployAll(): string[];
209
- deployRecipes(): string[];
210
-
211
- /** 解析 recipes 目录:先查项目 .claude-coder/recipes/,再 fallback 到 bundled */
212
- recipesDir(): string;
213
-
214
- clearCache(): void;
215
- }
216
-
217
- export declare const assets: AssetManager;
1
+ import { WriteStream } from 'fs';
2
+
3
+ // ─── Config ───────────────────────────────────────────────
4
+
5
+ export interface Config {
6
+ provider?: string;
7
+ model?: string;
8
+ defaultOpus?: string;
9
+ maxTurns?: number;
10
+ stallTimeout: number;
11
+ editThreshold?: number;
12
+ webTestTool?: 'playwright' | 'chrome-devtools' | '';
13
+ webTestMode?: 'persistent' | 'isolated' | 'extension' | '';
14
+ simplifyInterval: number;
15
+ simplifyCommits: number;
16
+ [key: string]: unknown;
17
+ }
18
+
19
+ // ─── Main Options ─────────────────────────────────────────
20
+
21
+ export interface MainOpts {
22
+ max?: number;
23
+ pause?: number;
24
+ dryRun?: boolean;
25
+ readFile?: string;
26
+ model?: string;
27
+ n?: number;
28
+ planOnly?: boolean;
29
+ interactive?: boolean;
30
+ reset?: boolean;
31
+ deployTemplates?: boolean;
32
+ projectRoot?: string;
33
+ reqFile?: string;
34
+ }
35
+
36
+ // ─── Session ──────────────────────────────────────────────
37
+
38
+ export interface SessionRunOptions {
39
+ logFileName: string;
40
+ logStream?: WriteStream;
41
+ sessionNum?: number;
42
+ label?: string;
43
+ execute: (session: Session) => Promise<Record<string, unknown>>;
44
+ }
45
+
46
+ export interface QueryResult {
47
+ messages: SDKMessage[];
48
+ success: boolean;
49
+ subtype: string | null;
50
+ cost: number | null;
51
+ usage: { input_tokens: number; output_tokens: number } | null;
52
+ turns: number | null;
53
+ }
54
+
55
+ export interface RunQueryOpts {
56
+ onMessage?: (message: SDKMessage, messages: SDKMessage[]) => void | 'break';
57
+ }
58
+
59
+ export interface SDKMessage {
60
+ type: 'assistant' | 'tool_result' | 'result' | string;
61
+ message?: {
62
+ content?: Array<{
63
+ type: 'text' | 'tool_use' | string;
64
+ text?: string;
65
+ name?: string;
66
+ input?: Record<string, unknown>;
67
+ }>;
68
+ };
69
+ result?: string;
70
+ subtype?: string;
71
+ total_cost_usd?: number;
72
+ usage?: { input_tokens: number; output_tokens: number };
73
+ num_turns?: number;
74
+ is_error?: boolean;
75
+ content?: string;
76
+ [key: string]: unknown;
77
+ }
78
+
79
+ export interface SessionRunResult {
80
+ exitCode: number;
81
+ logFile: string | null;
82
+ stalled: boolean;
83
+ [key: string]: unknown;
84
+ }
85
+
86
+ export declare class Session {
87
+ static _sdk: unknown;
88
+
89
+ /** 确保 SDK 已加载(懒加载单例) */
90
+ static ensureSDK(config: Config): Promise<unknown>;
91
+
92
+ /** 创建 Session 实例并执行回调,自动管理生命周期 */
93
+ static run(type: string, config: Config, options: SessionRunOptions): Promise<SessionRunResult>;
94
+
95
+ readonly config: Config;
96
+ readonly type: string;
97
+ readonly indicator: Indicator;
98
+ logStream: WriteStream | null;
99
+ logFile: string | null;
100
+ hooks: unknown;
101
+ abortController: AbortController;
102
+
103
+ constructor(
104
+ type: string,
105
+ config: Config,
106
+ options: { logFileName: string; logStream?: WriteStream; sessionNum?: number; label?: string },
107
+ );
108
+
109
+ /** 构建 SDK query 选项,自动附加 hooks、abortController、权限模式 */
110
+ buildQueryOptions(overrides?: Record<string, unknown>): Record<string, unknown>;
111
+
112
+ /** 执行一次 SDK 查询,遍历消息流并收集结果 */
113
+ runQuery(prompt: string, queryOpts: Record<string, unknown>, opts?: RunQueryOpts): Promise<QueryResult>;
114
+
115
+ /** 检查会话是否因停顿超时 */
116
+ isStalled(): boolean;
117
+
118
+ /** 结束会话:清理 hooks、关闭日志流、停止 indicator */
119
+ finish(): void;
120
+ }
121
+
122
+ // ─── Indicator ────────────────────────────────────────────
123
+
124
+ export declare class Indicator {
125
+ phase: 'thinking' | 'coding';
126
+ step: string;
127
+ toolTarget: string;
128
+ sessionNum: number;
129
+ startTime: number;
130
+ stallTimeoutMin: number;
131
+ toolRunning: boolean;
132
+ currentToolName: string;
133
+ projectRoot: string;
134
+
135
+ /** 启动 indicator 渲染循环 */
136
+ start(sessionNum: number, stallTimeoutMin: number, projectRoot: string): void;
137
+
138
+ /** 停止渲染循环并清除终端行 */
139
+ stop(): void;
140
+
141
+ updatePhase(phase: 'thinking' | 'coding'): void;
142
+ updateStep(step: string): void;
143
+ appendActivity(toolName: string, summary: string): void;
144
+ updateActivity(): void;
145
+
146
+ /** 标记工具开始执行 */
147
+ startTool(name: string): void;
148
+
149
+ /** 标记工具执行结束 */
150
+ endTool(): void;
151
+
152
+ pauseRendering(): void;
153
+ resumeRendering(): void;
154
+
155
+ /** 生成当前状态行文本 */
156
+ getStatusLine(): string;
157
+ }
158
+
159
+ /** 根据工具名称和输入推断当前阶段和步骤,更新 indicator 状态 */
160
+ export declare function inferPhaseStep(
161
+ indicator: Indicator,
162
+ toolName: string,
163
+ toolInput: Record<string, unknown> | string,
164
+ ): void;
165
+
166
+ // ─── Main ─────────────────────────────────────────────────
167
+
168
+ /** 应用入口:初始化资产、加载配置、分发命令 */
169
+ export declare function main(
170
+ command: string,
171
+ input: string,
172
+ opts?: MainOpts,
173
+ ): Promise<unknown>;
174
+
175
+ // ─── Logging ──────────────────────────────────────────────
176
+
177
+ /** 处理 SDK 消息并写入日志流 */
178
+ export declare function logMessage(
179
+ message: SDKMessage,
180
+ logStream: WriteStream,
181
+ indicator?: Indicator,
182
+ ): void;
183
+
184
+ /** 从消息列表中提取 type='result' 的消息 */
185
+ export declare function extractResult(messages: SDKMessage[]): SDKMessage | null;
186
+
187
+ /** 从消息列表中提取结果文本 */
188
+ export declare function extractResultText(messages: SDKMessage[]): string;
189
+
190
+ // ─── AssetManager ─────────────────────────────────────────
191
+
192
+ export declare class AssetManager {
193
+ projectRoot: string | null;
194
+ loopDir: string | null;
195
+ assetsDir: string | null;
196
+ bundledDir: string;
197
+
198
+ init(projectRoot?: string): void;
199
+ path(name: string): string | null;
200
+ dir(name: string): string | null;
201
+ exists(name: string): boolean;
202
+ read(name: string): string | null;
203
+ readJson(name: string, fallback?: unknown): unknown;
204
+ write(name: string, content: string): void;
205
+ writeJson(name: string, data: unknown): void;
206
+ render(name: string, vars?: Record<string, string>): string;
207
+ ensureDirs(): void;
208
+ deployAll(): string[];
209
+ deployRecipes(): string[];
210
+
211
+ /** 解析 recipes 目录:先查项目 .claude-coder/recipes/,再 fallback 到 bundled */
212
+ recipesDir(): string;
213
+
214
+ clearCache(): void;
215
+ }
216
+
217
+ export declare const assets: AssetManager;