@ia-ccun/code-agent-cli 0.0.16 → 0.0.17
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/package.json +1 -1
- package/scripts/postinstall.js +77 -1
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -114,6 +114,27 @@ function copyDirRecursive(src, dest) {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
// Force copy directory recursively (always overwrite destination)
|
|
118
|
+
function forceCopyDirRecursive(src, dest) {
|
|
119
|
+
if (!existsSync(src)) return;
|
|
120
|
+
|
|
121
|
+
const stats = statSync(src);
|
|
122
|
+
if (stats.isDirectory()) {
|
|
123
|
+
if (!existsSync(dest)) {
|
|
124
|
+
mkdirSync(dest, { recursive: true });
|
|
125
|
+
}
|
|
126
|
+
readdirSync(src).forEach(file => {
|
|
127
|
+
forceCopyDirRecursive(join(src, file), join(dest, file));
|
|
128
|
+
});
|
|
129
|
+
} else {
|
|
130
|
+
const parentDir = dirname(dest);
|
|
131
|
+
if (!existsSync(parentDir)) {
|
|
132
|
+
mkdirSync(parentDir, { recursive: true });
|
|
133
|
+
}
|
|
134
|
+
copyFileSync(src, dest);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
117
138
|
// Copy config.json if it doesn't exist
|
|
118
139
|
const packageConfigFile = join(__dirname, '..', 'config.json');
|
|
119
140
|
const userConfigFile = join(aicodeCliDir, 'config.json');
|
|
@@ -125,8 +146,58 @@ if (existsSync(packageConfigFile) && !existsSync(userConfigFile)) {
|
|
|
125
146
|
console.log('⚠ config.json not found in package');
|
|
126
147
|
}
|
|
127
148
|
|
|
128
|
-
//
|
|
149
|
+
// ============================================================================
|
|
150
|
+
// Files/folders that must be force-overwritten on every install
|
|
151
|
+
// ============================================================================
|
|
129
152
|
const packageConfigDir = join(__dirname, '..', 'config', 'agent');
|
|
153
|
+
|
|
154
|
+
const FORCE_OVERWRITE_LIST = [
|
|
155
|
+
'extensions/working-msg.ts',
|
|
156
|
+
// Add more files or folders here to force overwrite on every install
|
|
157
|
+
// Examples:
|
|
158
|
+
// 'skills/some-skill',
|
|
159
|
+
// 'prompts/some-prompt.md',
|
|
160
|
+
// 'themes/dark.json',
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
// Function to force overwrite specific files/folders
|
|
164
|
+
function forceOverwriteList(relativePaths) {
|
|
165
|
+
relativePaths.forEach(relativePath => {
|
|
166
|
+
const srcPath = join(packageConfigDir, relativePath);
|
|
167
|
+
const destPath = join(agentDir, relativePath);
|
|
168
|
+
|
|
169
|
+
if (existsSync(srcPath)) {
|
|
170
|
+
try {
|
|
171
|
+
const stats = statSync(srcPath);
|
|
172
|
+
if (stats.isDirectory()) {
|
|
173
|
+
// Force copy directory
|
|
174
|
+
if (!existsSync(destPath)) {
|
|
175
|
+
mkdirSync(destPath, { recursive: true });
|
|
176
|
+
}
|
|
177
|
+
forceCopyDirRecursive(srcPath, destPath);
|
|
178
|
+
console.log(`✓ Force overwritten (dir): ${relativePath}`);
|
|
179
|
+
} else {
|
|
180
|
+
// Force copy file
|
|
181
|
+
const parentDir = dirname(destPath);
|
|
182
|
+
if (!existsSync(parentDir)) {
|
|
183
|
+
mkdirSync(parentDir, { recursive: true });
|
|
184
|
+
}
|
|
185
|
+
copyFileSync(srcPath, destPath);
|
|
186
|
+
console.log(`✓ Force overwritten: ${relativePath}`);
|
|
187
|
+
}
|
|
188
|
+
} catch (e) {
|
|
189
|
+
console.log(`⚠ Could not force overwrite ${relativePath}: ${e.message}`);
|
|
190
|
+
if (e.stack) {
|
|
191
|
+
console.log(e.stack);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
console.log(`⚠ Source path does not exist: ${relativePath}`);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Copy config/agent contents to ~/.aicode-cli/agent only if they don't exist (preserve user customizations)
|
|
130
201
|
if (existsSync(packageConfigDir)) {
|
|
131
202
|
console.log(`📁 Syncing default config files to ${agentDir} (preserving user customizations)`);
|
|
132
203
|
|
|
@@ -134,6 +205,11 @@ if (existsSync(packageConfigDir)) {
|
|
|
134
205
|
copyDirRecursive(packageConfigDir, agentDir);
|
|
135
206
|
console.log('✓ Default config files synced successfully');
|
|
136
207
|
|
|
208
|
+
// Force overwrite specified files/folders
|
|
209
|
+
if (FORCE_OVERWRITE_LIST.length > 0) {
|
|
210
|
+
forceOverwriteList(FORCE_OVERWRITE_LIST);
|
|
211
|
+
}
|
|
212
|
+
|
|
137
213
|
// Check for extensions
|
|
138
214
|
const extensionsDir = join(agentDir, 'extensions');
|
|
139
215
|
if (existsSync(extensionsDir)) {
|