Skip to main content

Knowledge

The Knowledge module provides functionality for knowledge management and handling within your Codebolt applications. This module is currently in development and will be expanded with additional capabilities in future releases.

Overview

The Knowledge module is designed to support knowledge-based operations, including:

  • Knowledge base management
  • Information retrieval and storage
  • Knowledge graph operations
  • Semantic search capabilities
  • Context-aware knowledge access

Current Status

This module is currently a placeholder for future knowledge management features. The implementation is being developed to provide comprehensive knowledge handling capabilities for AI agents.

Planned Features

Knowledge Base Operations

// Future API (not yet implemented)
import codebolt from '@codebolt/codeboltjs';

// Create knowledge base
const kb = await codebolt.knowledge.createKnowledgeBase({
name: 'Project Knowledge',
description: 'Knowledge base for project documentation'
});

// Add knowledge items
await codebolt.knowledge.addItem(kb.id, {
title: 'API Documentation',
content: 'Documentation content...',
tags: ['api', 'documentation'],
metadata: {
version: '1.0',
author: 'dev-team'
}
});

// Query knowledge
const results = await codebolt.knowledge.query({
query: 'How to implement authentication?',
knowledgeBaseId: kb.id,
limit: 10
});
// Future API (not yet implemented)

// Search by semantic similarity
const results = await codebolt.knowledge.semanticSearch({
query: 'user authentication implementation',
knowledgeBaseId: kb.id,
threshold: 0.7
});

// Get related knowledge items
const related = await codebolt.knowledge.getRelated({
itemId: 'knowledge-item-id',
limit: 5
});

Knowledge Graph Integration

// Future API (not yet implemented)

// Create knowledge graph connections
await codebolt.knowledge.createConnection({
fromId: 'item-1',
toId: 'item-2',
relationship: 'implements',
metadata: {
confidence: 0.95
}
});

// Traverse knowledge graph
const path = await codebolt.knowledge.findPath({
startId: 'item-1',
endId: 'item-10',
maxDepth: 5
});

Integration with Existing Modules

While the Knowledge module is in development, you can use related modules for knowledge management:

Using Knowledge Graph Module

For graph-based knowledge operations, use the Knowledge Graph module:

// Create knowledge graph instance
const kg = await codebolt.knowledgeGraph.createInstance({
name: 'Project Knowledge Graph',
description: 'Graph of project knowledge'
});

// Add nodes and edges
await codebolt.knowledgeGraph.addMemoryRecords(kg.instanceId, [
{
id: 'concept-1',
type: 'concept',
properties: {
name: 'Authentication',
description: 'User authentication system'
}
}
]);

await codebolt.knowledgeGraph.addEdges(kg.instanceId, [
{
from: 'concept-1',
to: 'concept-2',
type: 'related-to'
}
]);

Using Persistent Memory Module

For persistent knowledge storage:

// Store knowledge in persistent memory
await codebolt.persistentMemory.add({
type: 'knowledge',
content: 'Important project information',
metadata: {
category: 'documentation',
importance: 'high'
}
});

// Retrieve knowledge
const knowledge = await codebolt.persistentMemory.get({
type: 'knowledge',
category: 'documentation'
});

Using RAG Module

For retrieval-augmented generation:

// Use RAG for knowledge-based responses
const response = await codebolt.rag.query({
query: 'How do I implement authentication?',
context: 'project-documentation',
maxResults: 5
});

Temporary Workarounds

Until the Knowledge module is fully implemented, consider these approaches:

1. Document Storage

// Use Memory module for document storage
await codebolt.memory.markdown.save(
'# Authentication Guide\n\nImplementation details...',
{
category: 'knowledge',
topic: 'authentication',
tags: ['security', 'backend']
}
);

// Retrieve documents
const docs = await codebolt.memory.markdown.list({
category: 'knowledge',
topic: 'authentication'
});

2. Structured Knowledge

// Use Memory module for structured knowledge
await codebolt.memory.json.save({
type: 'knowledge-item',
title: 'API Best Practices',
content: {
practices: [
'Use RESTful conventions',
'Implement proper error handling',
'Add rate limiting'
]
},
tags: ['api', 'best-practices'],
references: ['doc-1', 'doc-2']
});

3. Knowledge Indexing

// Use VectorDB for semantic search
await codebolt.vectordb.addVectorItem({
content: 'Authentication implementation guide',
metadata: {
type: 'knowledge',
category: 'security'
}
});

// Search knowledge
const results = await codebolt.vectordb.queryVectorItem(
'how to implement auth'
);

Future Development

The Knowledge module is being actively developed with the following roadmap:

Phase 1: Basic Operations

  • Knowledge base creation and management
  • Item storage and retrieval
  • Basic search functionality
  • Tagging and categorization

Phase 2: Advanced Features

  • Semantic search
  • Knowledge graph integration
  • Automatic knowledge extraction
  • Context-aware retrieval

Phase 3: AI Integration

  • LLM-powered knowledge synthesis
  • Automatic knowledge updates
  • Intelligent recommendations
  • Knowledge validation

Contributing

If you have specific requirements or suggestions for the Knowledge module, please:

  1. Review the existing related modules (Knowledge Graph, Persistent Memory, RAG)
  2. Consider if your use case can be addressed with current modules
  3. Submit feature requests with detailed use cases
  4. Contribute to the module development

Best Practices (Interim)

While waiting for the Knowledge module:

1. Use Appropriate Modules

// For graph relationships: Use Knowledge Graph
await codebolt.knowledgeGraph.createInstance({...});

// For semantic search: Use VectorDB
await codebolt.vectordb.addVectorItem({...});

// For document storage: Use Memory
await codebolt.memory.markdown.save(...);

// For structured data: Use Memory JSON
await codebolt.memory.json.save({...});

2. Consistent Metadata

// Use consistent metadata structure
const knowledgeMetadata = {
type: 'knowledge',
category: 'documentation',
topic: 'authentication',
tags: ['security', 'backend'],
version: '1.0',
createdAt: new Date().toISOString()
};

await codebolt.memory.json.save(data, knowledgeMetadata);

3. Implement Search Abstraction

class KnowledgeManager {
async addKnowledge(title, content, metadata = {}) {
// Store in multiple systems for redundancy
const mdResult = await codebolt.memory.markdown.save(
`# ${title}\n\n${content}`,
{ ...metadata, type: 'knowledge' }
);

await codebolt.vectordb.addVectorItem({
content: `${title} ${content}`,
metadata: { ...metadata, memoryId: mdResult.memoryId }
});

return mdResult.memoryId;
}

async searchKnowledge(query) {
// Use vector search for semantic matching
const vectorResults = await codebolt.vectordb.queryVectorItem(query);

// Retrieve full content from memory
const knowledge = [];
for (const result of vectorResults.item || []) {
if (result.metadata?.memoryId) {
const content = await codebolt.memory.markdown.list({
memoryId: result.metadata.memoryId
});
knowledge.push(content.items[0]);
}
}

return knowledge;
}
}

// Usage
const km = new KnowledgeManager();
await km.addKnowledge(
'Authentication Guide',
'Implementation details...',
{ category: 'security' }
);

const results = await km.searchKnowledge('how to implement auth');

Migration Path

When the Knowledge module is released, migration will be supported:

// Future migration utility (not yet available)
await codebolt.knowledge.migrate({
from: 'memory',
filter: { type: 'knowledge' },
to: 'knowledge-base-id'
});

Stay Updated

Check the Codebolt documentation and release notes for updates on the Knowledge module development:

Support

For questions or support regarding knowledge management:

  1. Use existing modules (Knowledge Graph, Memory, VectorDB)
  2. Check documentation for related modules
  3. Contact support for specific requirements
  4. Join the community for discussions

Example: Complete Knowledge Management System

Here's a complete example using existing modules:

class TemporaryKnowledgeSystem {
constructor() {
this.kgInstanceId = null;
}

async initialize() {
// Create knowledge graph instance
const kg = await codebolt.knowledgeGraph.createInstance({
name: 'Knowledge System',
description: 'Temporary knowledge management'
});
this.kgInstanceId = kg.instanceId;
}

async addKnowledge(item) {
// Store in memory
const memResult = await codebolt.memory.json.save({
...item,
type: 'knowledge',
createdAt: new Date().toISOString()
});

// Add to knowledge graph
await codebolt.knowledgeGraph.addMemoryRecords(this.kgInstanceId, [{
id: memResult.memoryId,
type: 'knowledge-item',
properties: {
title: item.title,
category: item.category
}
}]);

// Add to vector DB for search
await codebolt.vectordb.addVectorItem({
content: `${item.title} ${item.content}`,
metadata: {
memoryId: memResult.memoryId,
category: item.category
}
});

return memResult.memoryId;
}

async search(query) {
const results = await codebolt.vectordb.queryVectorItem(query);

const knowledge = [];
for (const result of results.item || []) {
const mem = await codebolt.memory.json.list({
memoryId: result.metadata.memoryId
});
if (mem.items.length > 0) {
knowledge.push(mem.items[0].json);
}
}

return knowledge;
}

async getRelated(itemId) {
// Use knowledge graph to find related items
const edges = await codebolt.knowledgeGraph.listEdges(this.kgInstanceId, {
from: itemId
});

const related = [];
for (const edge of edges.edges || []) {
const mem = await codebolt.memory.json.list({
memoryId: edge.to
});
if (mem.items.length > 0) {
related.push(mem.items[0].json);
}
}

return related;
}
}

// Usage
const ks = new TemporaryKnowledgeSystem();
await ks.initialize();

await ks.addKnowledge({
title: 'Authentication Guide',
content: 'How to implement authentication...',
category: 'security'
});

const results = await ks.search('authentication');
console.log('Found:', results.length, 'items');

This temporary system provides knowledge management capabilities until the official Knowledge module is released.