claude-flow-novice
Version:
Claude Flow Novice - Advanced orchestration platform for multi-agent AI workflows with CFN Loop architecture Includes Local RuVector Accelerator and all CFN skills for complete functionality.
68 lines (67 loc) • 2.21 kB
JavaScript
import Redis from 'ioredis';
const argValue = (flag)=>{
const index = process.argv.indexOf(flag);
if (index === -1 || index + 1 >= process.argv.length) {
return undefined;
}
return process.argv[index + 1];
};
const parseArgs = ()=>{
const taskId = argValue('--task-id');
const criteriaRaw = argValue('--criteria');
if (!taskId) throw new Error('--task-id is required');
if (!/^[A-Za-z0-9_-]+$/.test(taskId)) {
throw new Error('Invalid task id format; use alphanumeric, dash, underscore only');
}
if (!criteriaRaw) throw new Error('--criteria is required');
return {
taskId,
criteriaRaw,
redisHost: process.env.REDIS_HOST || 'localhost',
redisPort: Number(process.env.REDIS_PORT || 6379),
ttlSeconds: 86400
};
};
const validateCriteria = (criteria)=>{
if (!Array.isArray(criteria.test_suites)) {
throw new Error('success criteria must include test_suites array');
}
if (criteria.test_suites.length === 0) {
throw new Error('test_suites cannot be empty');
}
};
const storeCriteria = async (args)=>{
let parsed;
try {
parsed = JSON.parse(args.criteriaRaw);
} catch {
throw new Error('criteria is not valid JSON');
}
validateCriteria(parsed);
const redis = new Redis({
host: args.redisHost,
port: args.redisPort,
lazyConnect: true
});
try {
await redis.connect();
const key = `swarm:${args.taskId}:context`;
const serialized = JSON.stringify(parsed);
await redis.hset(key, 'success-criteria', serialized);
await redis.expire(key, args.ttlSeconds);
console.log(`✅ Success criteria stored in Redis: ${key}`);
console.log(` Test suites: ${parsed.test_suites.length}`);
console.log(` TTL: ${args.ttlSeconds} seconds`);
} finally{
redis.disconnect();
}
};
const main = async ()=>{
const args = parseArgs();
await storeCriteria(args);
};
main().catch((error)=>{
console.error(`❌ Failed to store success criteria: ${error.message}`);
process.exitCode = 1;
});
//# sourceMappingURL=store-success-criteria.js.map