@sulhadin/orchestrator 1.15.5 → 1.15.7
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/bin/index.js +57 -5
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const templateDir = path.join(__dirname, "..", "template");
|
|
|
9
9
|
const ORCHESTRA_SECTION_START = "<!-- orchestra -->";
|
|
10
10
|
const ORCHESTRA_SECTION_END = "<!-- /orchestra -->";
|
|
11
11
|
|
|
12
|
-
const USER_DIRS = ["milestones"];
|
|
12
|
+
const USER_DIRS = ["milestones", "skills", "blueprints"];
|
|
13
13
|
|
|
14
14
|
const ALLOW_PERMISSIONS = [
|
|
15
15
|
"Bash(*)",
|
|
@@ -178,6 +178,20 @@ function run() {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
// Backup knowledge.md (single file, not a directory)
|
|
182
|
+
const knowledgeSrc = path.join(orchestraDest, "knowledge.md");
|
|
183
|
+
const knowledgeBackup = path.join(targetDir, ".orchestra-backup-knowledge.md");
|
|
184
|
+
let hasKnowledge = false;
|
|
185
|
+
if (fs.existsSync(knowledgeSrc)) {
|
|
186
|
+
const content = fs.readFileSync(knowledgeSrc, "utf-8");
|
|
187
|
+
// Only backup if it has user entries (not just the template)
|
|
188
|
+
if (content.includes("# Active Knowledge") && content.trim().split("\n").length > 30) {
|
|
189
|
+
fs.copyFileSync(knowledgeSrc, knowledgeBackup);
|
|
190
|
+
hasKnowledge = true;
|
|
191
|
+
console.log(" [~] Backed up knowledge.md");
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
181
195
|
rmDirRecursive(orchestraDest);
|
|
182
196
|
console.log(" [~] Removed old .orchestra/");
|
|
183
197
|
|
|
@@ -186,14 +200,52 @@ function run() {
|
|
|
186
200
|
|
|
187
201
|
for (const [dir, backupPath] of Object.entries(backups)) {
|
|
188
202
|
const restorePath = path.join(orchestraDest, dir);
|
|
203
|
+
const templateDirPath = path.join(orchestraSrc, dir);
|
|
189
204
|
|
|
190
|
-
if (
|
|
191
|
-
|
|
205
|
+
if (dir === "milestones") {
|
|
206
|
+
// Milestones are fully user-owned — restore everything
|
|
207
|
+
if (fs.existsSync(restorePath)) {
|
|
208
|
+
rmDirRecursive(restorePath);
|
|
209
|
+
}
|
|
210
|
+
copyDirRecursive(backupPath, restorePath);
|
|
211
|
+
console.log(" [+] Restored " + dir + "/");
|
|
212
|
+
} else {
|
|
213
|
+
// Skills & blueprints: template files get updated, user-created files are preserved
|
|
214
|
+
// Template files are already in place from clean install.
|
|
215
|
+
// Only copy back files that DON'T exist in template (user-created).
|
|
216
|
+
const templateFiles = fs.existsSync(templateDirPath)
|
|
217
|
+
? fs.readdirSync(templateDirPath)
|
|
218
|
+
: [];
|
|
219
|
+
const backupFiles = fs.readdirSync(backupPath).filter((f) => f !== ".gitkeep");
|
|
220
|
+
let restored = 0;
|
|
221
|
+
|
|
222
|
+
for (const file of backupFiles) {
|
|
223
|
+
if (!templateFiles.includes(file)) {
|
|
224
|
+
const srcFile = path.join(backupPath, file);
|
|
225
|
+
const destFile = path.join(restorePath, file);
|
|
226
|
+
if (fs.statSync(srcFile).isDirectory()) {
|
|
227
|
+
copyDirRecursive(srcFile, destFile);
|
|
228
|
+
} else {
|
|
229
|
+
fs.copyFileSync(srcFile, destFile);
|
|
230
|
+
}
|
|
231
|
+
restored++;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (restored > 0) {
|
|
236
|
+
console.log(" [+] Restored " + restored + " user-created files in " + dir + "/");
|
|
237
|
+
}
|
|
238
|
+
console.log(" [~] Updated template files in " + dir + "/");
|
|
192
239
|
}
|
|
193
240
|
|
|
194
|
-
copyDirRecursive(backupPath, restorePath);
|
|
195
241
|
rmDirRecursive(backupPath);
|
|
196
|
-
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Restore knowledge.md
|
|
245
|
+
if (hasKnowledge && fs.existsSync(knowledgeBackup)) {
|
|
246
|
+
fs.copyFileSync(knowledgeBackup, path.join(orchestraDest, "knowledge.md"));
|
|
247
|
+
fs.unlinkSync(knowledgeBackup);
|
|
248
|
+
console.log(" [+] Restored knowledge.md");
|
|
197
249
|
}
|
|
198
250
|
} else {
|
|
199
251
|
copyDirRecursive(orchestraSrc, orchestraDest);
|