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 <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-03-02 14:54:27 +02:00
parent bae8538695
commit 5c58ea04e2

View File

@@ -5,9 +5,10 @@ import os from 'os';
import path from 'path'; import path from 'path';
import { clearBackup, createBackup, restoreBackup } from './backup.js'; 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 { copyDir } from './fs-utils.js';
import { isCustomizeActive } from './customize.js'; import { isCustomizeActive } from './customize.js';
import { initNanoclawDir } from './init.js';
import { executeFileOps } from './file-ops.js'; import { executeFileOps } from './file-ops.js';
import { acquireLock } from './lock.js'; import { acquireLock } from './lock.js';
import { import {
@@ -38,7 +39,12 @@ export async function applySkill(skillDir: string): Promise<ApplyResult> {
const manifest = readManifest(skillDir); const manifest = readManifest(skillDir);
// --- Pre-flight checks --- // --- 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 // Check skills system version compatibility
const sysCheck = checkSystemVersion(manifest); const sysCheck = checkSystemVersion(manifest);