@gadmin2n/cli 0.0.176 → 0.0.177
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/actions/update.action.js +20 -7
- package/package.json +1 -1
package/actions/update.action.js
CHANGED
|
@@ -52,7 +52,8 @@ function formatMaterializeError(schematicsVersion, err) {
|
|
|
52
52
|
* ------------------------------------------------------------------ */
|
|
53
53
|
/**
|
|
54
54
|
* Shallow-clone the remote .claude context repo into a temp dir and return
|
|
55
|
-
* the absolute path to the `.claude` subfolder
|
|
55
|
+
* the absolute path to the `.claude` subfolder plus the repo-root `CLAUDE.md`
|
|
56
|
+
* path (when present). Returns null on failure
|
|
56
57
|
* (e.g. no network, repo private, credentials missing, etc.).
|
|
57
58
|
*/
|
|
58
59
|
function fetchClaudeContextRepo(repoUrl, branch) {
|
|
@@ -66,6 +67,10 @@ function fetchClaudeContextRepo(repoUrl, branch) {
|
|
|
66
67
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
67
68
|
return null;
|
|
68
69
|
}
|
|
70
|
+
const rootClaudeMdSrc = path.join(tmpDir, 'CLAUDE.md');
|
|
71
|
+
const rootClaudeMd = fs.existsSync(rootClaudeMdSrc)
|
|
72
|
+
? rootClaudeMdSrc
|
|
73
|
+
: null;
|
|
69
74
|
// Caller is responsible for cleaning up the parent tmpDir.
|
|
70
75
|
// We return the inner path; we stash the parent on a property so caller
|
|
71
76
|
// can clean it. To keep things simple, register a process exit cleanup
|
|
@@ -78,7 +83,7 @@ function fetchClaudeContextRepo(repoUrl, branch) {
|
|
|
78
83
|
// ignore
|
|
79
84
|
}
|
|
80
85
|
});
|
|
81
|
-
return claudeSrc;
|
|
86
|
+
return { claudeDir: claudeSrc, rootClaudeMd };
|
|
82
87
|
}
|
|
83
88
|
catch (err) {
|
|
84
89
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
@@ -198,12 +203,13 @@ function syncClaudeContext(instanceDir, dryRun, source) {
|
|
|
198
203
|
console.info(chalk.bold(' Sync .claude context'));
|
|
199
204
|
console.info(chalk.bold('═══════════════════════════════════════════════════'));
|
|
200
205
|
console.info(`${chalk.gray('Source: ')} ${source.repo} (${source.branch}) :: ${CLAUDE_SOURCE_SUBDIR}/`);
|
|
201
|
-
console.info(`${chalk.gray('Targets:')} ${CLAUDE_TARGET_DIRS.map((d) => `${d}/`).join(', ')}\n`);
|
|
206
|
+
console.info(`${chalk.gray('Targets:')} ${CLAUDE_TARGET_DIRS.map((d) => `${d}/`).join(', ')}, AGENTS.md\n`);
|
|
202
207
|
if (dryRun) {
|
|
203
208
|
console.info(chalk.gray('(dry-run — no files written. The real run would:'));
|
|
204
209
|
console.info(chalk.gray(` 1. git clone ${source.repo} --branch ${source.branch} --depth 1 (into tmp dir)`));
|
|
205
210
|
console.info(chalk.gray(` 2. Copy <tmp>/${CLAUDE_SOURCE_SUBDIR}/** → each target dir, OVERWRITING same-named files`));
|
|
206
|
-
console.info(chalk.gray(' 3.
|
|
211
|
+
console.info(chalk.gray(' 3. Copy <tmp>/CLAUDE.md → project root AGENTS.md (overwriting if present)'));
|
|
212
|
+
console.info(chalk.gray(' 4. Files only present in target dirs (instance-only) are kept untouched)\n'));
|
|
207
213
|
return;
|
|
208
214
|
}
|
|
209
215
|
// Real run: warn the user that same-named files will be overwritten before
|
|
@@ -212,14 +218,14 @@ function syncClaudeContext(instanceDir, dryRun, source) {
|
|
|
212
218
|
// visible so changes to the local copy aren't silently clobbered.
|
|
213
219
|
console.info(chalk.yellow('⚠️ Same-named files in target dirs will be overwritten by the remote version.'));
|
|
214
220
|
console.info(chalk.gray(' Instance-only files (only present locally) are kept untouched.\n'));
|
|
215
|
-
const
|
|
216
|
-
if (!
|
|
221
|
+
const fetched = fetchClaudeContextRepo(source.repo, source.branch);
|
|
222
|
+
if (!fetched) {
|
|
217
223
|
return;
|
|
218
224
|
}
|
|
219
225
|
for (const targetName of CLAUDE_TARGET_DIRS) {
|
|
220
226
|
const destDir = path.join(instanceDir, targetName);
|
|
221
227
|
fs.mkdirSync(destDir, { recursive: true });
|
|
222
|
-
const { added, updated } = copyTreeOverwrite(
|
|
228
|
+
const { added, updated } = copyTreeOverwrite(fetched.claudeDir, destDir);
|
|
223
229
|
const summary = [];
|
|
224
230
|
if (added > 0)
|
|
225
231
|
summary.push(`${added} added`);
|
|
@@ -229,6 +235,13 @@ function syncClaudeContext(instanceDir, dryRun, source) {
|
|
|
229
235
|
summary.push('no files');
|
|
230
236
|
console.info(` ${chalk.cyan(targetName + '/')} ${summary.join(' | ')}`);
|
|
231
237
|
}
|
|
238
|
+
// Sync repo-root CLAUDE.md into the project root as AGENTS.md.
|
|
239
|
+
if (fetched.rootClaudeMd) {
|
|
240
|
+
const agentsDest = path.join(instanceDir, 'AGENTS.md');
|
|
241
|
+
const agentsExisted = fs.existsSync(agentsDest);
|
|
242
|
+
fs.copyFileSync(fetched.rootClaudeMd, agentsDest);
|
|
243
|
+
console.info(` ${chalk.cyan('AGENTS.md')} ${agentsExisted ? 'overwritten' : 'added'} (from CLAUDE.md)`);
|
|
244
|
+
}
|
|
232
245
|
console.info();
|
|
233
246
|
});
|
|
234
247
|
}
|