From 5c58ea04e29a24626da0e120a9de7e358990e689 Mon Sep 17 00:00:00 2001 From: gavrielc Date: Mon, 2 Mar 2026 14:54:27 +0200 Subject: [PATCH] fix: auto-initialize skills system when applying first skill applySkill() now creates .nanoclaw/ automatically if state.yaml is missing, removing the need to run --init as a separate step. Co-Authored-By: Claude Opus 4.6 --- skills-engine/apply.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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);