cortexweaver
Version:
CortexWeaver is a command-line interface (CLI) tool that orchestrates a swarm of specialized AI agents, powered by Claude Code and Gemini CLI, to assist in software development. It transforms a high-level project plan (plan.md) into a series of coordinate
225 lines • 7.68 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KnowledgeUpdaterAgentIntegration = void 0;
/**
* Knowledge Updater Agent Integration Operations
* Handles operations specific to the KnowledgeUpdater agent
*/
class KnowledgeUpdaterAgentIntegration {
constructor(driver) {
this.driver = driver;
}
/**
* Get task details (for KnowledgeUpdater agent)
*/
async getTaskDetails(taskId) {
const session = this.driver.session();
try {
const result = await session.run(`
MATCH (t:Task {id: $taskId})
OPTIONAL MATCH (t)-[:PART_OF]->(p:Project)
OPTIONAL MATCH (t)-[:HAS_ARTIFACT]->(a)
RETURN t, p, collect(a) as artifacts
`, { taskId });
if (result.records.length === 0) {
return null;
}
const record = result.records[0];
return {
task: record.get('t').properties,
project: record.get('p')?.properties,
artifacts: record.get('artifacts').map((a) => a.properties)
};
}
finally {
await session.close();
}
}
/**
* Get related knowledge (for KnowledgeUpdater agent)
*/
async getRelatedKnowledge(taskId) {
const session = this.driver.session();
try {
const result = await session.run(`
MATCH (t:Task {id: $taskId})
OPTIONAL MATCH (t)-[:USES]->(c:Contract)
OPTIONAL MATCH (t)-[:IMPLEMENTS]->(ad:ArchitecturalDecision)
OPTIONAL MATCH (t)-[:PRODUCES]->(cm:CodeModule)
RETURN collect(DISTINCT c) as contracts,
collect(DISTINCT ad) as architecturalDecisions,
collect(DISTINCT cm) as codeModules
`, { taskId });
if (result.records.length === 0) {
return [];
}
const record = result.records[0];
return {
contracts: record.get('contracts')?.map((c) => c.properties) || [],
architecturalDecisions: record.get('architecturalDecisions')?.map((ad) => ad.properties) || [],
codeModules: record.get('codeModules')?.map((cm) => cm.properties) || []
};
}
finally {
await session.close();
}
}
/**
* Create knowledge extraction (for KnowledgeUpdater agent)
*/
async createKnowledgeExtraction(extractionData) {
const session = this.driver.session();
try {
const result = await session.run(`
CREATE (ke:KnowledgeExtraction {
id: $id,
insights: $insights,
patterns: $patterns,
improvements: $improvements,
createdAt: $createdAt
})
RETURN ke.id as id
`, {
id: extractionData.id || `knowledge-${Date.now()}`,
insights: extractionData.insights || [],
patterns: extractionData.patterns || [],
improvements: extractionData.improvements || [],
createdAt: new Date().toISOString()
});
return result.records[0].get('id');
}
finally {
await session.close();
}
}
/**
* Link knowledge extraction to task (for KnowledgeUpdater agent)
*/
async linkKnowledgeToTask(knowledgeId, taskId) {
const session = this.driver.session();
try {
await session.run(`
MATCH (ke:KnowledgeExtraction {id: $knowledgeId}), (t:Task {id: $taskId})
CREATE (ke)-[:EXTRACTED_FROM]->(t)
`, { knowledgeId, taskId });
}
finally {
await session.close();
}
}
/**
* Update pheromone strengths (for KnowledgeUpdater agent)
*/
async updatePheromoneStrengths(updates) {
const session = this.driver.session();
try {
if (updates) {
// Apply specific updates if provided
for (const [pheromoneId, newStrength] of Object.entries(updates)) {
await session.run(`
MATCH (p:Pheromone {id: $pheromoneId})
SET p.strength = $newStrength
`, { pheromoneId, newStrength });
}
}
else {
// Default decay behavior
await session.run(`
MATCH (p:Pheromone)
WHERE datetime(p.expiresAt) > datetime()
SET p.strength = p.strength * 0.95
`);
}
}
finally {
await session.close();
}
}
/**
* Get project knowledge (for KnowledgeUpdater agent)
*/
async getProjectKnowledge(projectId) {
const session = this.driver.session();
try {
const result = await session.run(`
MATCH (p:Project {id: $projectId})-[:HAS_KNOWLEDGE]->(ke:KnowledgeExtraction)
RETURN ke
ORDER BY ke.createdAt DESC
`, { projectId });
return result.records.map(record => record.get('ke').properties);
}
finally {
await session.close();
}
}
/**
* Validate knowledge consistency (for KnowledgeUpdater agent)
*/
async validateKnowledgeConsistency(projectId) {
const session = this.driver.session();
try {
const result = await session.run(`
MATCH (p:Project {id: $projectId})
OPTIONAL MATCH (p)-[:HAS_KNOWLEDGE]->(ke:KnowledgeExtraction)
OPTIONAL MATCH (p)-[:HAS_ARCHITECTURE]->(ad:ArchitecturalDecision)
RETURN collect(ke) as knowledge, collect(ad) as decisions
`, { projectId });
// Simple consistency validation - check for conflicting patterns
const inconsistencies = [];
if (result.records.length > 0) {
// Add specific validation logic here based on project needs
console.log('Knowledge consistency validation completed');
}
return inconsistencies;
}
finally {
await session.close();
}
}
/**
* Identify knowledge gaps (for KnowledgeUpdater agent)
*/
async identifyKnowledgeGaps(projectId) {
const session = this.driver.session();
try {
const result = await session.run(`
MATCH (p:Project {id: $projectId})-[:CONTAINS]->(t:Task)
WHERE t.status = 'completed'
OPTIONAL MATCH (t)-[:HAS_KNOWLEDGE]->(ke:KnowledgeExtraction)
WITH t, ke
WHERE ke IS NULL
RETURN t as taskWithoutKnowledge
`, { projectId });
return result.records.map(record => ({
type: 'missing_task_knowledge',
task: record.get('taskWithoutKnowledge').properties,
description: 'Task completed without knowledge extraction'
}));
}
finally {
await session.close();
}
}
/**
* Update project metrics (for KnowledgeUpdater agent)
*/
async updateProjectMetrics(projectId, metrics) {
const session = this.driver.session();
try {
await session.run(`
MATCH (p:Project {id: $projectId})
SET p.metrics = $metrics,
p.lastMetricsUpdate = $timestamp
`, {
projectId,
metrics,
timestamp: new Date().toISOString()
});
}
finally {
await session.close();
}
}
}
exports.KnowledgeUpdaterAgentIntegration = KnowledgeUpdaterAgentIntegration;
//# sourceMappingURL=agent-integration-knowledge.js.map