Bun Spawn -> node child process in tools and seed versioning

This commit is contained in:
2026-02-25 02:15:54 +00:00
parent 21fde3d989
commit f2da4c0300
8 changed files with 107 additions and 74 deletions
+10 -5
View File
@@ -1,6 +1,7 @@
import { readdirSync, existsSync, mkdirSync, cpSync } from 'node:fs';
import { readdirSync, readFileSync, existsSync, mkdirSync, cpSync, rmSync } from 'node:fs';
import { join } from 'node:path';
import { SEED_PATH, DATA_PATH } from './data-path';
import { parseSeedVersion } from './sync-version';
const SEED_PROCESSES_DIR = join(SEED_PATH, 'processes');
const GLOBAL_PROCESSES_DIR = join(DATA_PATH, 'processes');
@@ -16,14 +17,18 @@ export function syncSeedProcesses(): void {
if (!entry.isDirectory()) continue;
const seedProcessDir = join(SEED_PROCESSES_DIR, entry.name);
const processFile = join(seedProcessDir, 'PROCESS.md');
if (!existsSync(processFile)) continue;
const seedFile = join(seedProcessDir, 'PROCESS.md');
if (!existsSync(seedFile)) continue;
const targetDir = join(GLOBAL_PROCESSES_DIR, entry.name);
const targetFile = join(targetDir, 'PROCESS.md');
if (existsSync(targetDir)) {
// Process already exists in DATA_PATH — skip to preserve user edits
continue;
const seedVersion = parseSeedVersion(readFileSync(seedFile, 'utf-8'));
const targetVersion = existsSync(targetFile) ? parseSeedVersion(readFileSync(targetFile, 'utf-8')) : 0;
if (seedVersion <= targetVersion) continue;
rmSync(targetDir, { recursive: true });
console.log(`[processes] Updating seed process: ${entry.name} (v${targetVersion} → v${seedVersion})`);
}
cpSync(seedProcessDir, targetDir, { recursive: true });
+10 -5
View File
@@ -1,6 +1,7 @@
import { readdirSync, existsSync, mkdirSync, cpSync } from 'node:fs';
import { readdirSync, readFileSync, existsSync, mkdirSync, cpSync, rmSync } from 'node:fs';
import { join } from 'node:path';
import { SEED_PATH, DATA_PATH } from './data-path';
import { parseSeedVersion } from './sync-version';
const SEED_SKILLS_DIR = join(SEED_PATH, 'skills');
const GLOBAL_SKILLS_DIR = join(DATA_PATH, 'skills');
@@ -16,14 +17,18 @@ export function syncSeedSkills(): void {
if (!entry.isDirectory()) continue;
const seedSkillDir = join(SEED_SKILLS_DIR, entry.name);
const skillFile = join(seedSkillDir, 'SKILL.md');
if (!existsSync(skillFile)) continue;
const seedFile = join(seedSkillDir, 'SKILL.md');
if (!existsSync(seedFile)) continue;
const targetDir = join(GLOBAL_SKILLS_DIR, entry.name);
const targetFile = join(targetDir, 'SKILL.md');
if (existsSync(targetDir)) {
// Skill already exists in DATA_PATH — skip to preserve user edits
continue;
const seedVersion = parseSeedVersion(readFileSync(seedFile, 'utf-8'));
const targetVersion = existsSync(targetFile) ? parseSeedVersion(readFileSync(targetFile, 'utf-8')) : 0;
if (seedVersion <= targetVersion) continue;
rmSync(targetDir, { recursive: true });
console.log(`[skills] Updating seed skill: ${entry.name} (v${targetVersion} → v${seedVersion})`);
}
cpSync(seedSkillDir, targetDir, { recursive: true });
+10 -5
View File
@@ -1,6 +1,7 @@
import { readdirSync, existsSync, mkdirSync, cpSync } from 'node:fs';
import { readdirSync, readFileSync, existsSync, mkdirSync, cpSync, rmSync } from 'node:fs';
import { join } from 'node:path';
import { SEED_PATH, DATA_PATH } from './data-path';
import { parseSeedVersion } from './sync-version';
const SEED_TASKS_DIR = join(SEED_PATH, 'tasks');
const GLOBAL_TASKS_DIR = join(DATA_PATH, 'tasks');
@@ -16,14 +17,18 @@ export function syncSeedTasks(): void {
if (!entry.isDirectory()) continue;
const seedTaskDir = join(SEED_TASKS_DIR, entry.name);
const taskFile = join(seedTaskDir, 'TASK.md');
if (!existsSync(taskFile)) continue;
const seedFile = join(seedTaskDir, 'TASK.md');
if (!existsSync(seedFile)) continue;
const targetDir = join(GLOBAL_TASKS_DIR, entry.name);
const targetFile = join(targetDir, 'TASK.md');
if (existsSync(targetDir)) {
// Task already exists in DATA_PATH — skip to preserve user edits
continue;
const seedVersion = parseSeedVersion(readFileSync(seedFile, 'utf-8'));
const targetVersion = existsSync(targetFile) ? parseSeedVersion(readFileSync(targetFile, 'utf-8')) : 0;
if (seedVersion <= targetVersion) continue;
rmSync(targetDir, { recursive: true });
console.log(`[tasks] Updating seed task: ${entry.name} (v${targetVersion} → v${seedVersion})`);
}
cpSync(seedTaskDir, targetDir, { recursive: true });
+10 -5
View File
@@ -1,6 +1,7 @@
import { readdirSync, existsSync, mkdirSync, cpSync } from 'node:fs';
import { readdirSync, readFileSync, existsSync, mkdirSync, cpSync, rmSync } from 'node:fs';
import { join } from 'node:path';
import { SEED_PATH, DATA_PATH } from './data-path';
import { parseSeedVersion } from './sync-version';
const SEED_TOOLS_DIR = join(SEED_PATH, 'tools');
const GLOBAL_TOOLS_DIR = join(DATA_PATH, 'tools');
@@ -16,14 +17,18 @@ export function syncSeedTools(): void {
if (!entry.isDirectory()) continue;
const seedToolDir = join(SEED_TOOLS_DIR, entry.name);
const toolFile = join(seedToolDir, 'TOOL.md');
if (!existsSync(toolFile)) continue;
const seedFile = join(seedToolDir, 'TOOL.md');
if (!existsSync(seedFile)) continue;
const targetDir = join(GLOBAL_TOOLS_DIR, entry.name);
const targetFile = join(targetDir, 'TOOL.md');
if (existsSync(targetDir)) {
// Tool already exists in DATA_PATH — skip to preserve user edits
continue;
const seedVersion = parseSeedVersion(readFileSync(seedFile, 'utf-8'));
const targetVersion = existsSync(targetFile) ? parseSeedVersion(readFileSync(targetFile, 'utf-8')) : 0;
if (seedVersion <= targetVersion) continue;
rmSync(targetDir, { recursive: true });
console.log(`[tools] Updating seed tool: ${entry.name} (v${targetVersion} → v${seedVersion})`);
}
cpSync(seedToolDir, targetDir, { recursive: true });
+10
View File
@@ -0,0 +1,10 @@
/**
* Extract the `version` field from YAML frontmatter.
* Returns 0 if no version is found.
*/
export function parseSeedVersion(content: string): number {
const match = content.match(/^---\n([\s\S]*?)\n---/);
if (!match) return 0;
const versionMatch = match[1]!.match(/^version:\s*(\d+)/m);
return versionMatch ? parseInt(versionMatch[1]!, 10) : 0;
}