clawt 1.0.0 → 1.0.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.
- package/dist/index.js +16 -6
- package/dist/postinstall.js +3 -1
- package/package.json +1 -1
- package/src/commands/merge.ts +7 -3
- package/src/commands/run.ts +6 -2
- package/src/constants/config.ts +6 -0
- package/src/constants/index.ts +1 -1
- package/src/constants/messages.ts +1 -1
- package/src/types/config.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -50,8 +50,7 @@ var MESSAGES = {
|
|
|
50
50
|
\u63D0\u4EA4\u4FE1\u606F: ${message}
|
|
51
51
|
\u5DF2\u63A8\u9001\u5230\u8FDC\u7A0B\u4ED3\u5E93`,
|
|
52
52
|
/** merge 成功(无提交信息,目标 worktree 已提交过) */
|
|
53
|
-
MERGE_SUCCESS_NO_MESSAGE: (branch) => `\u2713 \u5206\u652F ${branch} \u5DF2\u6210\u529F\u5408\u5E76\u5230\u5F53\u524D\u5206\u652F
|
|
54
|
-
\u5DF2\u63A8\u9001\u5230\u8FDC\u7A0B\u4ED3\u5E93`,
|
|
53
|
+
MERGE_SUCCESS_NO_MESSAGE: (branch) => `\u2713 \u5206\u652F ${branch} \u5DF2\u6210\u529F\u5408\u5E76\u5230\u5F53\u524D\u5206\u652F`,
|
|
55
54
|
/** merge 冲突 */
|
|
56
55
|
MERGE_CONFLICT: "\u5408\u5E76\u5B58\u5728\u51B2\u7A81\uFF0C\u8BF7\u624B\u52A8\u5904\u7406",
|
|
57
56
|
/** merge 后清理 worktree 和分支成功 */
|
|
@@ -89,10 +88,13 @@ var EXIT_CODES = {
|
|
|
89
88
|
};
|
|
90
89
|
|
|
91
90
|
// src/constants/config.ts
|
|
91
|
+
var APPEND_SYSTEM_PROMPT = "After the code execution is completed, it is prohibited to build the project for verification.";
|
|
92
92
|
var DEFAULT_CONFIG = {
|
|
93
93
|
autoDeleteBranch: false,
|
|
94
94
|
/** 默认 Claude Code CLI 启动指令,用于不传 --tasks 时在 worktree 中打开交互式界面 */
|
|
95
|
-
claudeCodeCommand: "claude"
|
|
95
|
+
claudeCodeCommand: "claude",
|
|
96
|
+
/** 默认不自动执行 git pull 和 git push,需用户手动操作 */
|
|
97
|
+
autoPullPush: false
|
|
96
98
|
};
|
|
97
99
|
|
|
98
100
|
// src/errors/index.ts
|
|
@@ -569,7 +571,11 @@ function launchInteractiveClaude(worktree) {
|
|
|
569
571
|
const commandStr = getConfigValue("claudeCodeCommand");
|
|
570
572
|
const parts = commandStr.split(/\s+/).filter(Boolean);
|
|
571
573
|
const cmd = parts[0];
|
|
572
|
-
const args =
|
|
574
|
+
const args = [
|
|
575
|
+
...parts.slice(1),
|
|
576
|
+
"--append-system-prompt",
|
|
577
|
+
APPEND_SYSTEM_PROMPT
|
|
578
|
+
];
|
|
573
579
|
printInfo(`\u6B63\u5728 worktree \u4E2D\u542F\u52A8 Claude Code \u4EA4\u4E92\u5F0F\u754C\u9762...`);
|
|
574
580
|
printInfo(` \u5206\u652F: ${worktree.branch}`);
|
|
575
581
|
printInfo(` \u8DEF\u5F84: ${worktree.path}`);
|
|
@@ -876,8 +882,12 @@ async function handleMerge(options) {
|
|
|
876
882
|
if (hasMergeConflict(mainWorktreePath)) {
|
|
877
883
|
throw new ClawtError(MESSAGES.MERGE_CONFLICT);
|
|
878
884
|
}
|
|
879
|
-
|
|
880
|
-
|
|
885
|
+
if (getConfigValue("autoPullPush")) {
|
|
886
|
+
gitPull(mainWorktreePath);
|
|
887
|
+
gitPush(mainWorktreePath);
|
|
888
|
+
} else {
|
|
889
|
+
printInfo("\u5DF2\u8DF3\u8FC7\u81EA\u52A8 pull/push\uFF0C\u8BF7\u624B\u52A8\u6267\u884C git pull && git push");
|
|
890
|
+
}
|
|
881
891
|
if (options.message) {
|
|
882
892
|
printSuccess(MESSAGES.MERGE_SUCCESS(options.branch, options.message));
|
|
883
893
|
} else {
|
package/dist/postinstall.js
CHANGED
|
@@ -15,7 +15,9 @@ var WORKTREES_DIR = join(CLAWT_HOME, "worktrees");
|
|
|
15
15
|
var DEFAULT_CONFIG = {
|
|
16
16
|
autoDeleteBranch: false,
|
|
17
17
|
/** 默认 Claude Code CLI 启动指令,用于不传 --tasks 时在 worktree 中打开交互式界面 */
|
|
18
|
-
claudeCodeCommand: "claude"
|
|
18
|
+
claudeCodeCommand: "claude",
|
|
19
|
+
/** 默认不自动执行 git pull 和 git push,需用户手动操作 */
|
|
20
|
+
autoPullPush: false
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
// scripts/postinstall.ts
|
package/package.json
CHANGED
package/src/commands/merge.ts
CHANGED
|
@@ -124,9 +124,13 @@ async function handleMerge(options: MergeOptions): Promise<void> {
|
|
|
124
124
|
throw new ClawtError(MESSAGES.MERGE_CONFLICT);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
// 步骤 7
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
// 步骤 7:根据配置决定是否自动 pull 和 push
|
|
128
|
+
if (getConfigValue('autoPullPush')) {
|
|
129
|
+
gitPull(mainWorktreePath);
|
|
130
|
+
gitPush(mainWorktreePath);
|
|
131
|
+
} else {
|
|
132
|
+
printInfo('已跳过自动 pull/push,请手动执行 git pull && git push');
|
|
133
|
+
}
|
|
130
134
|
|
|
131
135
|
// 步骤 8:输出成功提示(根据是否有 message 选择对应模板)
|
|
132
136
|
if (options.message) {
|
package/src/commands/run.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ChildProcess } from 'node:child_process';
|
|
|
3
3
|
import { spawnSync } from 'node:child_process';
|
|
4
4
|
import { logger } from '../logger/index.js';
|
|
5
5
|
import { ClawtError } from '../errors/index.js';
|
|
6
|
-
import { MESSAGES } from '../constants/index.js';
|
|
6
|
+
import { MESSAGES, APPEND_SYSTEM_PROMPT } from '../constants/index.js';
|
|
7
7
|
import type { RunOptions, ClaudeCodeResult, TaskResult, TaskSummary } from '../types/index.js';
|
|
8
8
|
import {
|
|
9
9
|
validateMainWorktree,
|
|
@@ -47,7 +47,11 @@ function launchInteractiveClaude(worktree: WorktreeInfo): void {
|
|
|
47
47
|
const commandStr = getConfigValue('claudeCodeCommand');
|
|
48
48
|
const parts = commandStr.split(/\s+/).filter(Boolean);
|
|
49
49
|
const cmd = parts[0];
|
|
50
|
-
const args =
|
|
50
|
+
const args = [
|
|
51
|
+
...parts.slice(1),
|
|
52
|
+
'--append-system-prompt',
|
|
53
|
+
APPEND_SYSTEM_PROMPT,
|
|
54
|
+
];
|
|
51
55
|
|
|
52
56
|
printInfo(`正在 worktree 中启动 Claude Code 交互式界面...`);
|
|
53
57
|
printInfo(` 分支: ${worktree.branch}`);
|
package/src/constants/config.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { ClawtConfig } from '../types/index.js';
|
|
2
2
|
|
|
3
|
+
/** Claude Code 系统约束提示,禁止代码执行完成后构建项目验证 */
|
|
4
|
+
export const APPEND_SYSTEM_PROMPT =
|
|
5
|
+
'After the code execution is completed, it is prohibited to build the project for verification.';
|
|
6
|
+
|
|
3
7
|
/** 默认配置 */
|
|
4
8
|
export const DEFAULT_CONFIG: ClawtConfig = {
|
|
5
9
|
autoDeleteBranch: false,
|
|
6
10
|
/** 默认 Claude Code CLI 启动指令,用于不传 --tasks 时在 worktree 中打开交互式界面 */
|
|
7
11
|
claudeCodeCommand: 'claude',
|
|
12
|
+
/** 默认不自动执行 git pull 和 git push,需用户手动操作 */
|
|
13
|
+
autoPullPush: false,
|
|
8
14
|
};
|
package/src/constants/index.ts
CHANGED
|
@@ -3,4 +3,4 @@ export { INVALID_BRANCH_CHARS } from './branch.js';
|
|
|
3
3
|
export { MESSAGES } from './messages.js';
|
|
4
4
|
export { EXIT_CODES } from './exitCodes.js';
|
|
5
5
|
export { ENABLE_BRACKETED_PASTE, DISABLE_BRACKETED_PASTE, PASTE_THRESHOLD_MS } from './terminal.js';
|
|
6
|
-
export { DEFAULT_CONFIG } from './config.js';
|
|
6
|
+
export { DEFAULT_CONFIG, APPEND_SYSTEM_PROMPT } from './config.js';
|
|
@@ -33,7 +33,7 @@ export const MESSAGES = {
|
|
|
33
33
|
`✓ 分支 ${branch} 已成功合并到当前分支\n 提交信息: ${message}\n 已推送到远程仓库`,
|
|
34
34
|
/** merge 成功(无提交信息,目标 worktree 已提交过) */
|
|
35
35
|
MERGE_SUCCESS_NO_MESSAGE: (branch: string) =>
|
|
36
|
-
`✓ 分支 ${branch}
|
|
36
|
+
`✓ 分支 ${branch} 已成功合并到当前分支`,
|
|
37
37
|
/** merge 冲突 */
|
|
38
38
|
MERGE_CONFLICT: '合并存在冲突,请手动处理',
|
|
39
39
|
/** merge 后清理 worktree 和分支成功 */
|