mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-19 02:13:58 +00:00
fix: resolve multiple code quality and robustness issues
- Fix minimatch dependency: downgrade to ^9.0.0 for Node 18 compatibility - Fix command.ts export: handle directory paths and ensure parent directories exist - Fix command.ts merge: preserve curated examples when merging commands - Fix plan.ts: filter empty entries from comma-separated inputs - Fix audit logger pagination: respect explicit 0 for limit and offset - Fix audit logger: gracefully handle malformed JSON lines without data loss - Fix team orchestrator: prevent task assignment to non-idle agents - Fix plan executor: unblock waitIfPaused() when cancel() is called All 639 tests passing.
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@skillkit/core": "workspace:*",
|
||||
"minimatch": "^10.0.1"
|
||||
"minimatch": "^9.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import { Command, Option } from 'clipanion';
|
||||
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
||||
import { resolve, join, dirname, extname } from 'node:path';
|
||||
import * as path from 'node:path';
|
||||
import * as fs from 'node:fs/promises';
|
||||
import { existsSync } from 'node:fs';
|
||||
import {
|
||||
createCommandRegistry,
|
||||
@@ -207,7 +209,7 @@ export class CommandCmd extends Command {
|
||||
skill: this.skill,
|
||||
description: this.description ?? previous.description ?? command.description,
|
||||
category: this.category ?? previous.category,
|
||||
examples: command.examples ?? previous.examples,
|
||||
examples: command.examples?.length ? command.examples : previous.examples,
|
||||
// Preserve existing metadata if not provided
|
||||
aliases: previous.aliases,
|
||||
args: previous.args,
|
||||
@@ -390,7 +392,16 @@ export class CommandCmd extends Command {
|
||||
const bundle = registry.export(this.all);
|
||||
|
||||
if (this.output) {
|
||||
const outputPath = resolve(this.output);
|
||||
let outputPath = resolve(this.output);
|
||||
|
||||
// Check if output is a directory or ends with path separator
|
||||
const stat = await fs.stat(outputPath).catch(() => null);
|
||||
if ((stat && stat.isDirectory()) || this.output.endsWith(path.sep)) {
|
||||
outputPath = path.join(outputPath, 'commands.json');
|
||||
}
|
||||
|
||||
// Ensure parent directory exists
|
||||
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
||||
await writeFile(outputPath, JSON.stringify(bundle, null, 2));
|
||||
this.context.stdout.write(`Exported ${bundle.commands.length} commands to: ${outputPath}\n`);
|
||||
} else {
|
||||
|
||||
@@ -310,21 +310,21 @@ export class PlanCommand extends Command {
|
||||
const generator = createPlanGenerator({
|
||||
includeTests: true,
|
||||
includeCommits: true,
|
||||
techStack: this.techStack?.split(',').map((s) => s.trim()),
|
||||
techStack: this.techStack?.split(',').map((s) => s.trim()).filter((s) => s !== ''),
|
||||
});
|
||||
|
||||
let plan;
|
||||
|
||||
if (this.tasks) {
|
||||
const taskNames = this.tasks.split(',').map((s) => s.trim());
|
||||
const taskNames = this.tasks.split(',').map((s) => s.trim()).filter((s) => s !== '');
|
||||
plan = generator.fromTaskList(this.name, this.goal || 'Complete the tasks', taskNames, {
|
||||
template: this.template as keyof typeof TASK_TEMPLATES,
|
||||
techStack: this.techStack?.split(',').map((s) => s.trim()),
|
||||
techStack: this.techStack?.split(',').map((s) => s.trim()).filter((s) => s !== ''),
|
||||
});
|
||||
} else {
|
||||
plan = generator.createPlan(this.name, this.goal || 'Complete the project');
|
||||
if (this.techStack) {
|
||||
plan.techStack = this.techStack.split(',').map((s) => s.trim());
|
||||
plan.techStack = this.techStack.split(',').map((s) => s.trim()).filter((s) => s !== '');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -171,15 +171,28 @@ export class AuditLogger {
|
||||
private async loadEvents(): Promise<AuditEvent[]> {
|
||||
try {
|
||||
const content = await fs.readFile(this.logFile, 'utf-8');
|
||||
return content
|
||||
.split('\n')
|
||||
.filter((line) => line.trim())
|
||||
.map((line) => {
|
||||
const events: AuditEvent[] = [];
|
||||
|
||||
for (const line of content.split('\n')) {
|
||||
if (!line.trim()) continue;
|
||||
|
||||
try {
|
||||
const event = JSON.parse(line);
|
||||
event.timestamp = new Date(event.timestamp);
|
||||
return event;
|
||||
});
|
||||
} catch {
|
||||
events.push(event);
|
||||
} catch (error) {
|
||||
// Skip malformed lines silently to prevent data loss
|
||||
// Malformed lines are ignored, valid events are preserved
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return events;
|
||||
} catch (error) {
|
||||
// Only propagate genuine filesystem errors
|
||||
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
|
||||
throw error;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -222,11 +235,11 @@ export class AuditLogger {
|
||||
|
||||
filtered.sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime());
|
||||
|
||||
if (query.offset) {
|
||||
if (query.offset !== undefined && query.offset !== null) {
|
||||
filtered = filtered.slice(query.offset);
|
||||
}
|
||||
|
||||
if (query.limit) {
|
||||
if (query.limit !== undefined && query.limit !== null) {
|
||||
filtered = filtered.slice(0, query.limit);
|
||||
}
|
||||
|
||||
|
||||
@@ -469,7 +469,15 @@ export class TeamOrchestrator {
|
||||
}
|
||||
|
||||
// Find an idle agent to assign
|
||||
const idleAgent = team.teammates.find((a) => a.status === 'idle') || team.leader;
|
||||
const idleTeammate = team.teammates.find((a) => a.status === 'idle');
|
||||
const idleLeader = team.leader.status === 'idle' && !team.leader.currentTask ? team.leader : null;
|
||||
const idleAgent = idleTeammate || idleLeader;
|
||||
|
||||
// Skip task if no idle agent available
|
||||
if (!idleAgent) {
|
||||
// No agent available, task will be retried in next iteration
|
||||
break;
|
||||
}
|
||||
|
||||
// Assign and execute
|
||||
await this.assignTask(teamId, nextTask.id, idleAgent.id);
|
||||
|
||||
@@ -356,6 +356,14 @@ export class PlanExecutor {
|
||||
*/
|
||||
cancel(): void {
|
||||
this.abortController?.abort();
|
||||
|
||||
// Unblock any pending pause to prevent hanging
|
||||
if (this.isPaused && this.resumeResolve) {
|
||||
this.isPaused = false;
|
||||
this.resumeResolve();
|
||||
this.resumeResolve = undefined;
|
||||
this.resumePromise = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Generated
+22
-2
@@ -64,8 +64,8 @@ importers:
|
||||
specifier: workspace:*
|
||||
version: link:../core
|
||||
minimatch:
|
||||
specifier: ^10.0.1
|
||||
version: 10.1.1
|
||||
specifier: ^9.0.0
|
||||
version: 9.0.5
|
||||
devDependencies:
|
||||
'@types/node':
|
||||
specifier: ^22.10.5
|
||||
@@ -737,9 +737,15 @@ packages:
|
||||
resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
balanced-match@1.0.2:
|
||||
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
||||
|
||||
base64-js@1.5.1:
|
||||
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
||||
|
||||
brace-expansion@2.0.2:
|
||||
resolution: {integrity: sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==}
|
||||
|
||||
buffer@6.0.3:
|
||||
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
|
||||
|
||||
@@ -1168,6 +1174,10 @@ packages:
|
||||
resolution: {integrity: sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
minimatch@9.0.5:
|
||||
resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
|
||||
minimist@1.2.8:
|
||||
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
|
||||
|
||||
@@ -1966,8 +1976,14 @@ snapshots:
|
||||
dependencies:
|
||||
possible-typed-array-names: 1.1.0
|
||||
|
||||
balanced-match@1.0.2: {}
|
||||
|
||||
base64-js@1.5.1: {}
|
||||
|
||||
brace-expansion@2.0.2:
|
||||
dependencies:
|
||||
balanced-match: 1.0.2
|
||||
|
||||
buffer@6.0.3:
|
||||
dependencies:
|
||||
base64-js: 1.5.1
|
||||
@@ -2409,6 +2425,10 @@ snapshots:
|
||||
dependencies:
|
||||
'@isaacs/brace-expansion': 5.0.0
|
||||
|
||||
minimatch@9.0.5:
|
||||
dependencies:
|
||||
brace-expansion: 2.0.2
|
||||
|
||||
minimist@1.2.8: {}
|
||||
|
||||
minimisted@2.0.1:
|
||||
|
||||
Reference in New Issue
Block a user