fix: address CodeRabbit review — deduplicate prompt, fix skill count

- Swap loadHistory/appendTurn order to prevent user message appearing
  twice in the prompt (once in history, once as USER MESSAGE)
- Calculate actual loaded skill count via fs.existsSync instead of
  counting requested skill names (banner now reflects reality)
- Add err.stack to test harness error output for better debugging
This commit is contained in:
andydiaz122
2026-02-24 10:20:17 -05:00
parent 853c64d7c1
commit e0b3a7be65
2 changed files with 8 additions and 4 deletions

View File

@@ -174,11 +174,14 @@ function main() {
const sessionPath = getSessionPath(sessionName); const sessionPath = getSessionPath(sessionName);
const eccContext = loadECCContext(); const eccContext = loadECCContext();
const skillCount = (process.env.CLAW_SKILLS || '').split(',').filter(s => s.trim()).length; const requestedSkills = (process.env.CLAW_SKILLS || '').split(',').map(s => s.trim()).filter(Boolean);
const loadedCount = requestedSkills.filter(name =>
fs.existsSync(path.join(process.cwd(), 'skills', name, 'SKILL.md'))
).length;
console.log('NanoClaw v1.0 — Session: ' + sessionName); console.log('NanoClaw v1.0 — Session: ' + sessionName);
if (skillCount > 0) { if (loadedCount > 0) {
console.log('Loaded ' + skillCount + ' skill(s) as context.'); console.log('Loaded ' + loadedCount + ' skill(s) as context.');
} }
console.log('Type /help for commands, exit to quit.\n'); console.log('Type /help for commands, exit to quit.\n');
@@ -227,8 +230,8 @@ function main() {
} }
// Regular message — send to Claude // Regular message — send to Claude
appendTurn(sessionPath, 'User', line);
const history = loadHistory(sessionPath); const history = loadHistory(sessionPath);
appendTurn(sessionPath, 'User', line);
const response = askClaude(eccContext, history, line); const response = askClaude(eccContext, history, line);
console.log('\n' + response + '\n'); console.log('\n' + response + '\n');
appendTurn(sessionPath, 'Assistant', response); appendTurn(sessionPath, 'Assistant', response);

View File

@@ -33,6 +33,7 @@ function test(name, fn) {
} catch (err) { } catch (err) {
console.log(` \u2717 ${name}`); console.log(` \u2717 ${name}`);
console.log(` Error: ${err.message}`); console.log(` Error: ${err.message}`);
if (err.stack) { console.log(` Stack: ${err.stack}`); }
return false; return false;
} }
} }