diff --git a/skills-engine/apply.ts b/skills-engine/apply.ts index 3d5e761..219d025 100644 --- a/skills-engine/apply.ts +++ b/skills-engine/apply.ts @@ -5,9 +5,10 @@ import os from 'os'; import path from 'path'; import { clearBackup, createBackup, restoreBackup } from './backup.js'; -import { NANOCLAW_DIR } from './constants.js'; +import { NANOCLAW_DIR, STATE_FILE } from './constants.js'; import { copyDir } from './fs-utils.js'; import { isCustomizeActive } from './customize.js'; +import { initNanoclawDir } from './init.js'; import { executeFileOps } from './file-ops.js'; import { acquireLock } from './lock.js'; import { @@ -38,7 +39,12 @@ export async function applySkill(skillDir: string): Promise { const manifest = readManifest(skillDir); // --- Pre-flight checks --- - const currentState = readState(); // Validates state exists and version is compatible + // Auto-initialize skills system if state file doesn't exist + const statePath = path.join(projectRoot, NANOCLAW_DIR, STATE_FILE); + if (!fs.existsSync(statePath)) { + initNanoclawDir(); + } + const currentState = readState(); // Check skills system version compatibility const sysCheck = checkSystemVersion(manifest);