@aaswe/codebase-ai
Version:
AI-Assisted Software Engineering (AASWE) - Rich codebase context for IDE LLMs
354 lines • 15 kB
JavaScript
;
/**
* RDF Ontology Schema
*
* Defines the comprehensive ontology schema for code knowledge representation,
* optimized for both Neo4j ingestion and direct LLM consumption.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.VALIDATION_RULES = exports.NEO4J_OPTIMIZATION = exports.BUSINESS_CONTEXT_PLACEHOLDERS = exports.LLM_PREFIXES = exports.ONTOLOGY_SCHEMA = exports.ONTOLOGY_PROPERTIES = exports.ONTOLOGY_CLASSES = exports.RDF_NAMESPACES = void 0;
/**
* Standard RDF Namespaces
*/
exports.RDF_NAMESPACES = {
code: 'https://aaswe.ai/ontology/code#',
module: 'https://aaswe.ai/ontology/module#',
arch: 'https://aaswe.ai/ontology/architecture#',
business: 'https://aaswe.ai/ontology/business#',
quality: 'https://aaswe.ai/ontology/quality#',
rdfs: 'http://www.w3.org/2000/01/rdf-schema#',
owl: 'http://www.w3.org/2002/07/owl#',
xsd: 'http://www.w3.org/2001/XMLSchema#'
};
/**
* Core Ontology Classes
*/
exports.ONTOLOGY_CLASSES = {
// Core Code Elements
Module: `${exports.RDF_NAMESPACES.code}Module`,
Class: `${exports.RDF_NAMESPACES.code}Class`,
Interface: `${exports.RDF_NAMESPACES.code}Interface`,
Method: `${exports.RDF_NAMESPACES.code}Method`,
Function: `${exports.RDF_NAMESPACES.code}Function`,
Property: `${exports.RDF_NAMESPACES.code}Property`,
Parameter: `${exports.RDF_NAMESPACES.code}Parameter`,
Type: `${exports.RDF_NAMESPACES.code}Type`,
Annotation: `${exports.RDF_NAMESPACES.code}Annotation`,
// Dependencies and Relationships
Dependency: `${exports.RDF_NAMESPACES.code}Dependency`,
Import: `${exports.RDF_NAMESPACES.code}Import`,
Export: `${exports.RDF_NAMESPACES.code}Export`,
Inheritance: `${exports.RDF_NAMESPACES.code}Inheritance`,
Implementation: `${exports.RDF_NAMESPACES.code}Implementation`,
Composition: `${exports.RDF_NAMESPACES.code}Composition`,
Association: `${exports.RDF_NAMESPACES.code}Association`,
// Documentation and Knowledge
Documentation: `${exports.RDF_NAMESPACES.code}Documentation`,
CodeExample: `${exports.RDF_NAMESPACES.code}CodeExample`,
Comment: `${exports.RDF_NAMESPACES.code}Comment`,
// Architecture and Patterns
ArchitecturalPattern: `${exports.RDF_NAMESPACES.arch}Pattern`,
DesignPattern: `${exports.RDF_NAMESPACES.arch}DesignPattern`,
Component: `${exports.RDF_NAMESPACES.arch}Component`,
Layer: `${exports.RDF_NAMESPACES.arch}Layer`,
Service: `${exports.RDF_NAMESPACES.arch}Service`,
// Business Context
BusinessDomain: `${exports.RDF_NAMESPACES.business}Domain`,
BusinessRule: `${exports.RDF_NAMESPACES.business}Rule`,
UseCase: `${exports.RDF_NAMESPACES.business}UseCase`,
Stakeholder: `${exports.RDF_NAMESPACES.business}Stakeholder`,
QualityAttribute: `${exports.RDF_NAMESPACES.business}QualityAttribute`,
Constraint: `${exports.RDF_NAMESPACES.business}Constraint`,
// Quality and Metrics
ComplexityMetric: `${exports.RDF_NAMESPACES.quality}ComplexityMetric`,
QualityMetric: `${exports.RDF_NAMESPACES.quality}QualityMetric`,
TechnicalDebt: `${exports.RDF_NAMESPACES.quality}TechnicalDebt`,
CodeSmell: `${exports.RDF_NAMESPACES.quality}CodeSmell`,
SecurityIssue: `${exports.RDF_NAMESPACES.quality}SecurityIssue`,
TestCoverage: `${exports.RDF_NAMESPACES.quality}TestCoverage`,
PerformanceMetric: `${exports.RDF_NAMESPACES.quality}PerformanceMetric`
};
/**
* Core Ontology Properties
*/
exports.ONTOLOGY_PROPERTIES = {
// Basic Properties
name: `${exports.RDF_NAMESPACES.code}name`,
fullyQualifiedName: `${exports.RDF_NAMESPACES.code}fullyQualifiedName`,
signature: `${exports.RDF_NAMESPACES.code}signature`,
visibility: `${exports.RDF_NAMESPACES.code}visibility`,
type: `${exports.RDF_NAMESPACES.code}type`,
version: `${exports.RDF_NAMESPACES.code}version`,
language: `${exports.RDF_NAMESPACES.code}language`,
// Structural Properties
hasClass: `${exports.RDF_NAMESPACES.code}hasClass`,
hasMethod: `${exports.RDF_NAMESPACES.code}hasMethod`,
hasProperty: `${exports.RDF_NAMESPACES.code}hasProperty`,
hasParameter: `${exports.RDF_NAMESPACES.code}hasParameter`,
hasAnnotation: `${exports.RDF_NAMESPACES.code}hasAnnotation`,
hasDocumentation: `${exports.RDF_NAMESPACES.code}hasDocumentation`,
// Relationship Properties
extends: `${exports.RDF_NAMESPACES.code}extends`,
implements: `${exports.RDF_NAMESPACES.code}implements`,
dependsOn: `${exports.RDF_NAMESPACES.code}dependsOn`,
imports: `${exports.RDF_NAMESPACES.code}imports`,
exports: `${exports.RDF_NAMESPACES.code}exports`,
calls: `${exports.RDF_NAMESPACES.code}calls`,
uses: `${exports.RDF_NAMESPACES.code}uses`,
contains: `${exports.RDF_NAMESPACES.code}contains`,
// Behavioral Properties
isAbstract: `${exports.RDF_NAMESPACES.code}isAbstract`,
isStatic: `${exports.RDF_NAMESPACES.code}isStatic`,
isAsync: `${exports.RDF_NAMESPACES.code}isAsync`,
isOptional: `${exports.RDF_NAMESPACES.code}isOptional`,
isReadonly: `${exports.RDF_NAMESPACES.code}isReadonly`,
isDeprecated: `${exports.RDF_NAMESPACES.code}isDeprecated`,
// Location Properties
sourceFile: `${exports.RDF_NAMESPACES.code}sourceFile`,
startLine: `${exports.RDF_NAMESPACES.code}startLine`,
endLine: `${exports.RDF_NAMESPACES.code}endLine`,
startColumn: `${exports.RDF_NAMESPACES.code}startColumn`,
endColumn: `${exports.RDF_NAMESPACES.code}endColumn`,
// Documentation Properties
summary: `${exports.RDF_NAMESPACES.code}summary`,
description: `${exports.RDF_NAMESPACES.code}description`,
example: `${exports.RDF_NAMESPACES.code}example`,
seeAlso: `${exports.RDF_NAMESPACES.code}seeAlso`,
since: `${exports.RDF_NAMESPACES.code}since`,
deprecated: `${exports.RDF_NAMESPACES.code}deprecated`,
// Architecture Properties
followsPattern: `${exports.RDF_NAMESPACES.arch}followsPattern`,
belongsToLayer: `${exports.RDF_NAMESPACES.arch}belongsToLayer`,
providesService: `${exports.RDF_NAMESPACES.arch}providesService`,
consumesService: `${exports.RDF_NAMESPACES.arch}consumesService`,
// Business Properties
belongsToDomain: `${exports.RDF_NAMESPACES.business}belongsToDomain`,
implementsRule: `${exports.RDF_NAMESPACES.business}implementsRule`,
supportsUseCase: `${exports.RDF_NAMESPACES.business}supportsUseCase`,
hasStakeholder: `${exports.RDF_NAMESPACES.business}hasStakeholder`,
satisfiesAttribute: `${exports.RDF_NAMESPACES.business}satisfiesAttribute`,
subjectToConstraint: `${exports.RDF_NAMESPACES.business}subjectToConstraint`,
// Quality Properties
hasComplexity: `${exports.RDF_NAMESPACES.quality}hasComplexity`,
hasQualityMetric: `${exports.RDF_NAMESPACES.quality}hasQualityMetric`,
hasTechnicalDebt: `${exports.RDF_NAMESPACES.quality}hasTechnicalDebt`,
hasCodeSmell: `${exports.RDF_NAMESPACES.quality}hasCodeSmell`,
hasSecurityIssue: `${exports.RDF_NAMESPACES.quality}hasSecurityIssue`,
hasTestCoverage: `${exports.RDF_NAMESPACES.quality}hasTestCoverage`,
hasPerformanceMetric: `${exports.RDF_NAMESPACES.quality}hasPerformanceMetric`,
// Metric Values
cyclomaticComplexity: `${exports.RDF_NAMESPACES.quality}cyclomaticComplexity`,
cognitiveComplexity: `${exports.RDF_NAMESPACES.quality}cognitiveComplexity`,
linesOfCode: `${exports.RDF_NAMESPACES.quality}linesOfCode`,
maintainabilityIndex: `${exports.RDF_NAMESPACES.quality}maintainabilityIndex`,
technicalDebtMinutes: `${exports.RDF_NAMESPACES.quality}technicalDebtMinutes`,
coveragePercentage: `${exports.RDF_NAMESPACES.quality}coveragePercentage`,
// Timestamps and Metadata
createdAt: `${exports.RDF_NAMESPACES.code}createdAt`,
modifiedAt: `${exports.RDF_NAMESPACES.code}modifiedAt`,
generatedAt: `${exports.RDF_NAMESPACES.code}generatedAt`,
checksum: `${exports.RDF_NAMESPACES.code}checksum`
};
/**
* Ontology Schema Definition
*
* Defines the complete schema with class hierarchies, property domains/ranges,
* and constraints for validation.
*/
exports.ONTOLOGY_SCHEMA = {
classes: {
// Core hierarchy
[exports.ONTOLOGY_CLASSES.Module]: {
subClassOf: [`${exports.RDF_NAMESPACES.owl}Thing`],
properties: [
exports.ONTOLOGY_PROPERTIES.name,
exports.ONTOLOGY_PROPERTIES.version,
exports.ONTOLOGY_PROPERTIES.language,
exports.ONTOLOGY_PROPERTIES.hasClass,
exports.ONTOLOGY_PROPERTIES.hasDocumentation,
exports.ONTOLOGY_PROPERTIES.dependsOn
]
},
[exports.ONTOLOGY_CLASSES.Class]: {
subClassOf: [`${exports.RDF_NAMESPACES.code}CodeElement`],
properties: [
exports.ONTOLOGY_PROPERTIES.name,
exports.ONTOLOGY_PROPERTIES.fullyQualifiedName,
exports.ONTOLOGY_PROPERTIES.visibility,
exports.ONTOLOGY_PROPERTIES.isAbstract,
exports.ONTOLOGY_PROPERTIES.extends,
exports.ONTOLOGY_PROPERTIES.implements,
exports.ONTOLOGY_PROPERTIES.hasMethod,
exports.ONTOLOGY_PROPERTIES.hasProperty
]
},
[exports.ONTOLOGY_CLASSES.Method]: {
subClassOf: [`${exports.RDF_NAMESPACES.code}CodeElement`],
properties: [
exports.ONTOLOGY_PROPERTIES.name,
exports.ONTOLOGY_PROPERTIES.signature,
exports.ONTOLOGY_PROPERTIES.visibility,
exports.ONTOLOGY_PROPERTIES.isStatic,
exports.ONTOLOGY_PROPERTIES.isAsync,
exports.ONTOLOGY_PROPERTIES.hasParameter,
exports.ONTOLOGY_PROPERTIES.calls
]
}
},
properties: {
[exports.ONTOLOGY_PROPERTIES.name]: {
domain: [`${exports.RDF_NAMESPACES.code}CodeElement`],
range: [`${exports.RDF_NAMESPACES.xsd}string`],
functional: true
},
[exports.ONTOLOGY_PROPERTIES.extends]: {
domain: [exports.ONTOLOGY_CLASSES.Class],
range: [exports.ONTOLOGY_CLASSES.Class],
functional: true
},
[exports.ONTOLOGY_PROPERTIES.implements]: {
domain: [exports.ONTOLOGY_CLASSES.Class],
range: [exports.ONTOLOGY_CLASSES.Interface],
functional: false
},
[exports.ONTOLOGY_PROPERTIES.hasComplexity]: {
domain: [`${exports.RDF_NAMESPACES.code}CodeElement`],
range: [exports.ONTOLOGY_CLASSES.ComplexityMetric],
functional: true
}
}
};
/**
* LLM-Optimized Prefixes
*
* Human-readable prefixes for better LLM understanding
*/
exports.LLM_PREFIXES = {
'@prefix': {
'code': exports.RDF_NAMESPACES.code,
'module': exports.RDF_NAMESPACES.module,
'arch': exports.RDF_NAMESPACES.arch,
'business': exports.RDF_NAMESPACES.business,
'quality': exports.RDF_NAMESPACES.quality,
'rdfs': exports.RDF_NAMESPACES.rdfs,
'owl': exports.RDF_NAMESPACES.owl,
'xsd': exports.RDF_NAMESPACES.xsd
}
};
/**
* Business Context Placeholders
*
* Template placeholders to guide developer enhancement of TTL files
*/
exports.BUSINESS_CONTEXT_PLACEHOLDERS = {
domain: {
template: `# Business Domain: [REPLACE_WITH_DOMAIN]
# Purpose: [DESCRIBE_BUSINESS_PURPOSE]
# Key Stakeholders: [LIST_STAKEHOLDERS]`,
example: `# Business Domain: E-commerce Order Management
# Purpose: Handles customer order processing and fulfillment
# Key Stakeholders: Customers, Sales Team, Fulfillment Team`
},
businessRules: {
template: `# Business Rules:
# - [RULE_1]: [DESCRIPTION]
# - [RULE_2]: [DESCRIPTION]`,
example: `# Business Rules:
# - Order Validation: Orders must have valid payment before processing
# - Inventory Check: Items must be in stock before order confirmation`
},
useCases: {
template: `# Use Cases:
# - [USE_CASE_1]: [DESCRIPTION]
# - [USE_CASE_2]: [DESCRIPTION]`,
example: `# Use Cases:
# - Place Order: Customer creates new order with items
# - Process Payment: System validates and processes payment`
},
qualityAttributes: {
template: `# Quality Attributes:
# - Performance: [TARGET_RESPONSE_TIME]
# - Reliability: [AVAILABILITY_TARGET]
# - Security: [SECURITY_REQUIREMENTS]`,
example: `# Quality Attributes:
# - Performance: Order processing < 2 seconds
# - Reliability: 99.9% uptime
# - Security: PCI DSS compliance for payment data`
},
constraints: {
template: `# Constraints:
# - Technical: [TECHNICAL_CONSTRAINTS]
# - Business: [BUSINESS_CONSTRAINTS]
# - Regulatory: [COMPLIANCE_REQUIREMENTS]`,
example: `# Constraints:
# - Technical: Must integrate with legacy ERP system
# - Business: Maximum 5% cart abandonment rate
# - Regulatory: GDPR compliance for customer data`
}
};
/**
* Neo4j Optimization Hints
*
* Properties and structures optimized for Neo4j graph database ingestion
*/
exports.NEO4J_OPTIMIZATION = {
indexedProperties: [
exports.ONTOLOGY_PROPERTIES.name,
exports.ONTOLOGY_PROPERTIES.fullyQualifiedName,
exports.ONTOLOGY_PROPERTIES.type,
exports.ONTOLOGY_PROPERTIES.sourceFile
],
relationshipTypes: {
EXTENDS: 'EXTENDS',
IMPLEMENTS: 'IMPLEMENTS',
DEPENDS_ON: 'DEPENDS_ON',
HAS_METHOD: 'HAS_METHOD',
HAS_PROPERTY: 'HAS_PROPERTY',
CALLS: 'CALLS',
USES: 'USES',
BELONGS_TO: 'BELONGS_TO'
},
nodeLabels: {
Module: 'Module',
Class: 'Class',
Interface: 'Interface',
Method: 'Method',
Property: 'Property',
Dependency: 'Dependency'
}
};
/**
* Validation Rules
*
* Rules for validating RDF content and ensuring consistency
*/
exports.VALIDATION_RULES = {
required: {
[exports.ONTOLOGY_CLASSES.Module]: [
exports.ONTOLOGY_PROPERTIES.name,
exports.ONTOLOGY_PROPERTIES.language,
exports.ONTOLOGY_PROPERTIES.version
],
[exports.ONTOLOGY_CLASSES.Class]: [
exports.ONTOLOGY_PROPERTIES.name,
exports.ONTOLOGY_PROPERTIES.fullyQualifiedName,
exports.ONTOLOGY_PROPERTIES.visibility
],
[exports.ONTOLOGY_CLASSES.Method]: [
exports.ONTOLOGY_PROPERTIES.name,
exports.ONTOLOGY_PROPERTIES.signature,
exports.ONTOLOGY_PROPERTIES.visibility
]
},
patterns: {
fullyQualifiedName: /^[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*)*$/,
version: /^\d+\.\d+\.\d+(-[a-zA-Z0-9]+)?$/,
visibility: /^(public|private|protected|internal)$/
},
constraints: {
maxStringLength: 1000,
maxArraySize: 100,
requiredNamespaces: Object.values(exports.RDF_NAMESPACES)
}
};
//# sourceMappingURL=ontology.js.map