cc-devflow 2.4.0 → 2.4.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/CHANGELOG.md CHANGED
@@ -7,7 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ---
9
9
 
10
- ## [2.3.0] - 2025-12-19
10
+ ## [2.4.2] - 2026-01-09
11
+
12
+ ### 🩹 CLI 增强:增量更新 (Incremental Update)
13
+
14
+ `cc-devflow init` 命令现在支持增量更新,不再强制覆盖用户已修改的文件。
15
+
16
+ #### Added
17
+
18
+ - **增量更新机制**: 当目标目录已存在时,`init` 默认进入增量模式。
19
+ - 仅复制目标目录中**缺失**的文件。
20
+ - **保留**所有已存在的文件(即使用户修改过)。
21
+ - 若目标文件存在但内容与新版模板不同,生成 `filename.new` 并提示 `[UPDATE]`。
22
+ - 输出 `[NEW] filename` 提示新增文件。
23
+ - **强制模式重构**: `--force` 选项现在的行为更明确:彻底删除旧目录并重新安装。
24
+
25
+ ---
26
+
27
+ ## [2.4.0] - 2025-12-19
11
28
 
12
29
  ### 🎯 REQ-005 完成:Command Emitter (Multi-Platform Adapter Compiler)
13
30
 
@@ -87,6 +87,41 @@ function parseCliArgs(args) {
87
87
  return { options, rest };
88
88
  }
89
89
 
90
+ function copyIncremental(src, dest) {
91
+ const stats = fs.statSync(src);
92
+ if (stats.isDirectory()) {
93
+ if (!fs.existsSync(dest)) {
94
+ fs.mkdirSync(dest);
95
+ }
96
+ const entries = fs.readdirSync(src);
97
+ for (const entry of entries) {
98
+ copyIncremental(path.join(src, entry), path.join(dest, entry));
99
+ }
100
+ } else {
101
+ if (!fs.existsSync(dest)) {
102
+ // Case 1: File missing - Copy it
103
+ fs.copyFileSync(src, dest);
104
+ console.log(`[NEW] ${path.relative(process.cwd(), dest)}`);
105
+ } else {
106
+ // Case 2: File exists - Compare content
107
+ try {
108
+ const srcContent = fs.readFileSync(src);
109
+ const destContent = fs.readFileSync(dest);
110
+
111
+ if (!srcContent.equals(destContent)) {
112
+ // Content differs - Create .new version
113
+ const newFile = `${dest}.new`;
114
+ fs.copyFileSync(src, newFile);
115
+ console.log(`[UPDATE] ${path.relative(process.cwd(), newFile)} (conflict detected)`);
116
+ }
117
+ // else: Content identical - Silent skip
118
+ } catch (err) {
119
+ console.warn(`[WARN] Could not compare ${path.relative(process.cwd(), dest)}: ${err.message}`);
120
+ }
121
+ }
122
+ }
123
+ }
124
+
90
125
  function runInit(args) {
91
126
  const { options } = parseCliArgs(args);
92
127
 
@@ -103,17 +138,26 @@ function runInit(args) {
103
138
  return 1;
104
139
  }
105
140
 
106
- if (fs.existsSync(targetDir)) {
107
- if (!options.force) {
108
- console.error(`Target already exists: ${targetDir}`);
109
- console.error('Use --force to overwrite.');
110
- return 1;
111
- }
141
+ // Case 1: Directory does not exist - Clean Install
142
+ if (!fs.existsSync(targetDir)) {
143
+ fs.cpSync(TEMPLATE_DIR, targetDir, { recursive: true });
144
+ console.log(`Initialized .claude in ${targetRoot}`);
145
+ return 0;
146
+ }
147
+
148
+ // Case 2: Directory exists + Force - Hard Reset
149
+ if (options.force) {
150
+ console.log('Force flag detected. Resetting .claude directory...');
112
151
  fs.rmSync(targetDir, { recursive: true, force: true });
152
+ fs.cpSync(TEMPLATE_DIR, targetDir, { recursive: true });
153
+ console.log(`Re-initialized .claude in ${targetRoot}`);
154
+ return 0;
113
155
  }
114
156
 
115
- fs.cpSync(TEMPLATE_DIR, targetDir, { recursive: true });
116
- console.log(`Initialized .claude in ${targetRoot}`);
157
+ // Case 3: Directory exists - Incremental Update
158
+ console.log(`Target ${targetDir} already exists. Performing incremental update...`);
159
+ copyIncremental(TEMPLATE_DIR, targetDir);
160
+ console.log('Incremental update complete. Existing files were preserved.');
117
161
  return 0;
118
162
  }
119
163
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-devflow",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "DevFlow CLI tool",
5
5
  "main": "bin/cc-devflow.js",
6
6
  "bin": {
@@ -47,4 +47,4 @@
47
47
  "engines": {
48
48
  "node": ">=18"
49
49
  }
50
- }
50
+ }