@nahisaho/musubix-yata-client 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/index.test.d.ts +2 -0
- package/dist/__tests__/index.test.d.ts.map +1 -0
- package/dist/__tests__/index.test.js +58 -0
- package/dist/__tests__/index.test.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/index.d.ts +11 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/index.js +11 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/knowledge/ontology.d.ts +192 -0
- package/dist/knowledge/ontology.d.ts.map +1 -0
- package/dist/knowledge/ontology.js +261 -0
- package/dist/knowledge/ontology.js.map +1 -0
- package/dist/knowledge/query.d.ts +111 -0
- package/dist/knowledge/query.d.ts.map +1 -0
- package/dist/knowledge/query.js +207 -0
- package/dist/knowledge/query.js.map +1 -0
- package/dist/mcp/client.d.ts +128 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +294 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +8 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/reasoning/confidence.d.ts +175 -0
- package/dist/reasoning/confidence.d.ts.map +1 -0
- package/dist/reasoning/confidence.js +278 -0
- package/dist/reasoning/confidence.js.map +1 -0
- package/dist/reasoning/contradiction.d.ts +236 -0
- package/dist/reasoning/contradiction.d.ts.map +1 -0
- package/dist/reasoning/contradiction.js +487 -0
- package/dist/reasoning/contradiction.js.map +1 -0
- package/dist/reasoning/index.d.ts +12 -0
- package/dist/reasoning/index.d.ts.map +1 -0
- package/dist/reasoning/index.js +15 -0
- package/dist/reasoning/index.js.map +1 -0
- package/dist/reasoning/integrator.d.ts +230 -0
- package/dist/reasoning/integrator.d.ts.map +1 -0
- package/dist/reasoning/integrator.js +364 -0
- package/dist/reasoning/integrator.js.map +1 -0
- package/dist/types.d.ts +171 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +22 -0
- package/dist/types.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @musubix/yata-client - Basic Tests
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from 'vitest';
|
|
5
|
+
describe('@musubix/yata-client', () => {
|
|
6
|
+
describe('Package Export', () => {
|
|
7
|
+
it('should export VERSION', async () => {
|
|
8
|
+
const { VERSION } = await import('../index.js');
|
|
9
|
+
expect(VERSION).toBeDefined();
|
|
10
|
+
expect(typeof VERSION).toBe('string');
|
|
11
|
+
});
|
|
12
|
+
it('should export YataMCPClient', async () => {
|
|
13
|
+
const { YataMCPClient } = await import('../index.js');
|
|
14
|
+
expect(YataMCPClient).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
it('should export NeuroSymbolicIntegrator', async () => {
|
|
17
|
+
const { NeuroSymbolicIntegrator } = await import('../index.js');
|
|
18
|
+
expect(NeuroSymbolicIntegrator).toBeDefined();
|
|
19
|
+
});
|
|
20
|
+
it('should export OntologyMapper', async () => {
|
|
21
|
+
const { OntologyMapper } = await import('../index.js');
|
|
22
|
+
expect(OntologyMapper).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
it('should export ContradictionDetector', async () => {
|
|
25
|
+
const { ContradictionDetector } = await import('../index.js');
|
|
26
|
+
expect(ContradictionDetector).toBeDefined();
|
|
27
|
+
});
|
|
28
|
+
it('should export ConfidenceEvaluator', async () => {
|
|
29
|
+
const { ConfidenceEvaluator } = await import('../index.js');
|
|
30
|
+
expect(ConfidenceEvaluator).toBeDefined();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('Factory Functions', () => {
|
|
34
|
+
it('should export createYataClient', async () => {
|
|
35
|
+
const { createYataClient } = await import('../index.js');
|
|
36
|
+
expect(createYataClient).toBeDefined();
|
|
37
|
+
expect(typeof createYataClient).toBe('function');
|
|
38
|
+
});
|
|
39
|
+
it('should export createNeuroSymbolicIntegrator', async () => {
|
|
40
|
+
const { createNeuroSymbolicIntegrator } = await import('../index.js');
|
|
41
|
+
expect(createNeuroSymbolicIntegrator).toBeDefined();
|
|
42
|
+
expect(typeof createNeuroSymbolicIntegrator).toBe('function');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe('Constants', () => {
|
|
46
|
+
it('should export MUSUBIX_NAMESPACES', async () => {
|
|
47
|
+
const { MUSUBIX_NAMESPACES } = await import('../index.js');
|
|
48
|
+
expect(MUSUBIX_NAMESPACES).toBeDefined();
|
|
49
|
+
expect(typeof MUSUBIX_NAMESPACES).toBe('object');
|
|
50
|
+
});
|
|
51
|
+
it('should export MUSUBIX_CONCEPTS', async () => {
|
|
52
|
+
const { MUSUBIX_CONCEPTS } = await import('../index.js');
|
|
53
|
+
expect(MUSUBIX_CONCEPTS).toBeDefined();
|
|
54
|
+
expect(typeof MUSUBIX_CONCEPTS).toBe('object');
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,EAAE,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;YAC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AAC,QAAQ,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @musubix/yata-client - MUSUBIX YATA Client
|
|
3
|
+
*
|
|
4
|
+
* Knowledge Graph Client Library for YATA MCP Server
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Knowledge graph queries
|
|
8
|
+
* - Symbolic reasoning
|
|
9
|
+
* - Pattern matching
|
|
10
|
+
* - Constraint validation
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
* @module @musubix/yata-client
|
|
14
|
+
*
|
|
15
|
+
* @see REQ-INT-001 - Neuro-Symbolic Integration
|
|
16
|
+
* @see DES-MUSUBIX-001 Section 2.2 - Container Diagram
|
|
17
|
+
*/
|
|
18
|
+
export declare const VERSION = "0.1.0";
|
|
19
|
+
export type { MCPTransport, YataClientConfig, ConnectionState, YataToolName, ToolCallRequest, ToolCallResponse, KnowledgeNode, KnowledgeEdge, KnowledgeQueryResult, PatternMatchResult, ConstraintValidationResult, ReasoningStep, ReasoningChainResult, } from './types.js';
|
|
20
|
+
export { DEFAULT_YATA_CONFIG } from './types.js';
|
|
21
|
+
export { YataMCPClient, createYataClient, type YataClientEvents } from './mcp/index.js';
|
|
22
|
+
export { GraphQueryInterface, createGraphQuery, OntologyMapper, createOntologyMapper, type QueryOptions, type GraphPath, type Subgraph, type OntologyNamespace, type OntologyConcept, type OntologyProperty, type OntologyRelation, type MappingRule, MUSUBIX_NAMESPACES, MUSUBIX_CONCEPTS, DEFAULT_QUERY_OPTIONS, } from './knowledge/index.js';
|
|
23
|
+
export { NeuroSymbolicIntegrator, createNeuroSymbolicIntegrator, ConfidenceEvaluator, createConfidenceEvaluator, combineConfidence, ContradictionDetector, createContradictionDetector, type IntegrationMode, type IntegratorConfig, type NeuralInput, type SymbolicConstraints, type ValidationRule, type ValidationContext, type IntegrationResult, type ConfidenceSource, type ConfidenceScore, type CombinedConfidence, type CombinationMethod, type ContradictionType, type Contradiction, type Resolution, type DetectionReport, DEFAULT_INTEGRATOR_CONFIG, DEFAULT_EVALUATOR_CONFIG, DEFAULT_DETECTOR_CONFIG, } from './reasoning/index.js';
|
|
24
|
+
/**
|
|
25
|
+
* YATA Client Entry Point
|
|
26
|
+
*
|
|
27
|
+
* This module provides the client interface for YATA knowledge graph.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { createYataClient, VERSION } from '@musubix/yata-client';
|
|
32
|
+
*
|
|
33
|
+
* const client = createYataClient({
|
|
34
|
+
* server: 'yata-server',
|
|
35
|
+
* transport: 'stdio',
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* await client.connect();
|
|
39
|
+
* console.log(`MUSUBIX YATA Client v${VERSION} connected`);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,0BAA0B,EAC1B,aAAa,EACb,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGxF,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAC3B,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;GAiBG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @musubix/yata-client - MUSUBIX YATA Client
|
|
3
|
+
*
|
|
4
|
+
* Knowledge Graph Client Library for YATA MCP Server
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Knowledge graph queries
|
|
8
|
+
* - Symbolic reasoning
|
|
9
|
+
* - Pattern matching
|
|
10
|
+
* - Constraint validation
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
* @module @musubix/yata-client
|
|
14
|
+
*
|
|
15
|
+
* @see REQ-INT-001 - Neuro-Symbolic Integration
|
|
16
|
+
* @see DES-MUSUBIX-001 Section 2.2 - Container Diagram
|
|
17
|
+
*/
|
|
18
|
+
// Version
|
|
19
|
+
export const VERSION = '0.1.0';
|
|
20
|
+
export { DEFAULT_YATA_CONFIG } from './types.js';
|
|
21
|
+
// MCP Client
|
|
22
|
+
export { YataMCPClient, createYataClient } from './mcp/index.js';
|
|
23
|
+
// Knowledge Module
|
|
24
|
+
export { GraphQueryInterface, createGraphQuery, OntologyMapper, createOntologyMapper, MUSUBIX_NAMESPACES, MUSUBIX_CONCEPTS, DEFAULT_QUERY_OPTIONS, } from './knowledge/index.js';
|
|
25
|
+
// Reasoning Module
|
|
26
|
+
export { NeuroSymbolicIntegrator, createNeuroSymbolicIntegrator, ConfidenceEvaluator, createConfidenceEvaluator, combineConfidence, ContradictionDetector, createContradictionDetector, DEFAULT_INTEGRATOR_CONFIG, DEFAULT_EVALUATOR_CONFIG, DEFAULT_DETECTOR_CONFIG, } from './reasoning/index.js';
|
|
27
|
+
/**
|
|
28
|
+
* YATA Client Entry Point
|
|
29
|
+
*
|
|
30
|
+
* This module provides the client interface for YATA knowledge graph.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { createYataClient, VERSION } from '@musubix/yata-client';
|
|
35
|
+
*
|
|
36
|
+
* const client = createYataClient({
|
|
37
|
+
* server: 'yata-server',
|
|
38
|
+
* transport: 'stdio',
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* await client.connect();
|
|
42
|
+
* console.log(`MUSUBIX YATA Client v${VERSION} connected`);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,UAAU;AACV,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAmB/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,aAAa;AACb,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAyB,MAAM,gBAAgB,CAAC;AAExF,mBAAmB;AACnB,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EASpB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,mBAAmB;AACnB,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAgB3B,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;GAiBG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Module
|
|
3
|
+
*
|
|
4
|
+
* Knowledge graph operations and queries
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module knowledge
|
|
8
|
+
*/
|
|
9
|
+
export { GraphQueryInterface, createGraphQuery, type QueryOptions, type GraphPath, type Subgraph, DEFAULT_QUERY_OPTIONS, } from './query.js';
|
|
10
|
+
export { OntologyMapper, createOntologyMapper, type OntologyNamespace, type OntologyConcept, type OntologyProperty, type PropertyConstraint, type OntologyRelation, type MappingRule, type PropertyMapping, type ValidationResult, MUSUBIX_NAMESPACES, MUSUBIX_CONCEPTS, } from './ontology.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/knowledge/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Module
|
|
3
|
+
*
|
|
4
|
+
* Knowledge graph operations and queries
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module knowledge
|
|
8
|
+
*/
|
|
9
|
+
export { GraphQueryInterface, createGraphQuery, DEFAULT_QUERY_OPTIONS, } from './query.js';
|
|
10
|
+
export { OntologyMapper, createOntologyMapper, MUSUBIX_NAMESPACES, MUSUBIX_CONCEPTS, } from './ontology.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/knowledge/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAIhB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,cAAc,EACd,oBAAoB,EASpB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ontology Mapper
|
|
3
|
+
*
|
|
4
|
+
* Maps between MUSUBIX concepts and YATA ontology
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module knowledge/ontology
|
|
8
|
+
*
|
|
9
|
+
* @see REQ-INT-101 - YATA Integration
|
|
10
|
+
* @see REQ-NS-102 - Knowledge Base
|
|
11
|
+
*/
|
|
12
|
+
import type { KnowledgeNode, KnowledgeEdge } from '../types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Ontology namespace
|
|
15
|
+
*/
|
|
16
|
+
export interface OntologyNamespace {
|
|
17
|
+
prefix: string;
|
|
18
|
+
uri: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Concept definition in ontology
|
|
22
|
+
*/
|
|
23
|
+
export interface OntologyConcept {
|
|
24
|
+
/** Concept ID */
|
|
25
|
+
id: string;
|
|
26
|
+
/** Namespace prefix */
|
|
27
|
+
namespace: string;
|
|
28
|
+
/** Local name */
|
|
29
|
+
localName: string;
|
|
30
|
+
/** Human-readable label */
|
|
31
|
+
label: string;
|
|
32
|
+
/** Description */
|
|
33
|
+
description?: string;
|
|
34
|
+
/** Parent concepts */
|
|
35
|
+
parents?: string[];
|
|
36
|
+
/** Properties */
|
|
37
|
+
properties?: Record<string, OntologyProperty>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Property definition
|
|
41
|
+
*/
|
|
42
|
+
export interface OntologyProperty {
|
|
43
|
+
/** Property name */
|
|
44
|
+
name: string;
|
|
45
|
+
/** Property type */
|
|
46
|
+
type: 'string' | 'number' | 'boolean' | 'date' | 'uri' | 'object';
|
|
47
|
+
/** Is required */
|
|
48
|
+
required: boolean;
|
|
49
|
+
/** Is array */
|
|
50
|
+
isArray?: boolean;
|
|
51
|
+
/** Default value */
|
|
52
|
+
default?: unknown;
|
|
53
|
+
/** Constraints */
|
|
54
|
+
constraints?: PropertyConstraint[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Property constraint
|
|
58
|
+
*/
|
|
59
|
+
export interface PropertyConstraint {
|
|
60
|
+
type: 'min' | 'max' | 'pattern' | 'enum' | 'range';
|
|
61
|
+
value: unknown;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Relation definition
|
|
65
|
+
*/
|
|
66
|
+
export interface OntologyRelation {
|
|
67
|
+
/** Relation ID */
|
|
68
|
+
id: string;
|
|
69
|
+
/** Source concept ID */
|
|
70
|
+
sourceConceptId: string;
|
|
71
|
+
/** Target concept ID */
|
|
72
|
+
targetConceptId: string;
|
|
73
|
+
/** Relation type */
|
|
74
|
+
type: string;
|
|
75
|
+
/** Cardinality */
|
|
76
|
+
cardinality: 'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many';
|
|
77
|
+
/** Is inverse relation */
|
|
78
|
+
inverse?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Mapping rule
|
|
82
|
+
*/
|
|
83
|
+
export interface MappingRule {
|
|
84
|
+
/** Rule ID */
|
|
85
|
+
id: string;
|
|
86
|
+
/** Source concept */
|
|
87
|
+
sourceConcept: string;
|
|
88
|
+
/** Target concept */
|
|
89
|
+
targetConcept: string;
|
|
90
|
+
/** Property mappings */
|
|
91
|
+
propertyMappings: PropertyMapping[];
|
|
92
|
+
/** Transformation function */
|
|
93
|
+
transform?: (node: KnowledgeNode) => KnowledgeNode;
|
|
94
|
+
/** Condition for applying rule */
|
|
95
|
+
condition?: (node: KnowledgeNode) => boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Property mapping
|
|
99
|
+
*/
|
|
100
|
+
export interface PropertyMapping {
|
|
101
|
+
/** Source property path */
|
|
102
|
+
source: string;
|
|
103
|
+
/** Target property path */
|
|
104
|
+
target: string;
|
|
105
|
+
/** Value transformer */
|
|
106
|
+
transformer?: (value: unknown) => unknown;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* MUSUBIX domain ontology namespaces
|
|
110
|
+
*/
|
|
111
|
+
export declare const MUSUBIX_NAMESPACES: Record<string, OntologyNamespace>;
|
|
112
|
+
/**
|
|
113
|
+
* Built-in MUSUBIX concepts
|
|
114
|
+
*/
|
|
115
|
+
export declare const MUSUBIX_CONCEPTS: Record<string, OntologyConcept>;
|
|
116
|
+
/**
|
|
117
|
+
* Ontology Mapper
|
|
118
|
+
*
|
|
119
|
+
* Maps between different ontology systems
|
|
120
|
+
*/
|
|
121
|
+
export declare class OntologyMapper {
|
|
122
|
+
private namespaces;
|
|
123
|
+
private concepts;
|
|
124
|
+
private relations;
|
|
125
|
+
private mappingRules;
|
|
126
|
+
constructor();
|
|
127
|
+
/**
|
|
128
|
+
* Load namespaces
|
|
129
|
+
*/
|
|
130
|
+
loadNamespaces(namespaces: Record<string, OntologyNamespace>): void;
|
|
131
|
+
/**
|
|
132
|
+
* Load concepts
|
|
133
|
+
*/
|
|
134
|
+
loadConcepts(concepts: Record<string, OntologyConcept>): void;
|
|
135
|
+
/**
|
|
136
|
+
* Add mapping rule
|
|
137
|
+
*/
|
|
138
|
+
addMappingRule(rule: MappingRule): void;
|
|
139
|
+
/**
|
|
140
|
+
* Get concept by ID
|
|
141
|
+
*/
|
|
142
|
+
getConcept(id: string): OntologyConcept | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* Get namespace by prefix
|
|
145
|
+
*/
|
|
146
|
+
getNamespace(prefix: string): OntologyNamespace | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* Resolve full URI
|
|
149
|
+
*/
|
|
150
|
+
resolveUri(prefixedName: string): string;
|
|
151
|
+
/**
|
|
152
|
+
* Compress URI to prefixed name
|
|
153
|
+
*/
|
|
154
|
+
compressUri(uri: string): string;
|
|
155
|
+
/**
|
|
156
|
+
* Map node to target concept
|
|
157
|
+
*/
|
|
158
|
+
mapNode(node: KnowledgeNode, targetConceptId: string): KnowledgeNode;
|
|
159
|
+
/**
|
|
160
|
+
* Map edge type
|
|
161
|
+
*/
|
|
162
|
+
mapEdgeType(edge: KnowledgeEdge, _sourceMapping: string, _targetMapping: string): KnowledgeEdge;
|
|
163
|
+
/**
|
|
164
|
+
* Validate node against concept
|
|
165
|
+
*/
|
|
166
|
+
validateNode(node: KnowledgeNode, conceptId: string): ValidationResult;
|
|
167
|
+
/**
|
|
168
|
+
* Get concept hierarchy
|
|
169
|
+
*/
|
|
170
|
+
getConceptHierarchy(conceptId: string): string[];
|
|
171
|
+
/**
|
|
172
|
+
* Check if concept is subtype of another
|
|
173
|
+
*/
|
|
174
|
+
isSubtypeOf(conceptId: string, parentConceptId: string): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Get all concepts of type
|
|
177
|
+
*/
|
|
178
|
+
getConceptsOfType(typeId: string): OntologyConcept[];
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Validation result
|
|
182
|
+
*/
|
|
183
|
+
export interface ValidationResult {
|
|
184
|
+
valid: boolean;
|
|
185
|
+
errors: string[];
|
|
186
|
+
warnings?: string[];
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Create ontology mapper instance
|
|
190
|
+
*/
|
|
191
|
+
export declare function createOntologyMapper(): OntologyMapper;
|
|
192
|
+
//# sourceMappingURL=ontology.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ontology.d.ts","sourceRoot":"","sources":["../../src/knowledge/ontology.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,iBAAiB;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,iBAAiB;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,o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aAAa;IAYhB;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,gBAAgB;IA0BtE;;OAEG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAahD;;OAEG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO;IAehE;;OAEG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,EAAE;CASrD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAErD"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ontology Mapper
|
|
3
|
+
*
|
|
4
|
+
* Maps between MUSUBIX concepts and YATA ontology
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module knowledge/ontology
|
|
8
|
+
*
|
|
9
|
+
* @see REQ-INT-101 - YATA Integration
|
|
10
|
+
* @see REQ-NS-102 - Knowledge Base
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* MUSUBIX domain ontology namespaces
|
|
14
|
+
*/
|
|
15
|
+
export const MUSUBIX_NAMESPACES = {
|
|
16
|
+
musubix: {
|
|
17
|
+
prefix: 'musubix',
|
|
18
|
+
uri: 'https://musubix.dev/ontology#',
|
|
19
|
+
},
|
|
20
|
+
ears: {
|
|
21
|
+
prefix: 'ears',
|
|
22
|
+
uri: 'https://musubix.dev/ontology/ears#',
|
|
23
|
+
},
|
|
24
|
+
c4: {
|
|
25
|
+
prefix: 'c4',
|
|
26
|
+
uri: 'https://musubix.dev/ontology/c4#',
|
|
27
|
+
},
|
|
28
|
+
task: {
|
|
29
|
+
prefix: 'task',
|
|
30
|
+
uri: 'https://musubix.dev/ontology/task#',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Built-in MUSUBIX concepts
|
|
35
|
+
*/
|
|
36
|
+
export const MUSUBIX_CONCEPTS = {
|
|
37
|
+
// EARS Requirements
|
|
38
|
+
'ears:Requirement': {
|
|
39
|
+
id: 'ears:Requirement',
|
|
40
|
+
namespace: 'ears',
|
|
41
|
+
localName: 'Requirement',
|
|
42
|
+
label: 'Requirement',
|
|
43
|
+
description: 'EARS format requirement',
|
|
44
|
+
properties: {
|
|
45
|
+
id: { name: 'id', type: 'string', required: true },
|
|
46
|
+
pattern: { name: 'pattern', type: 'string', required: true },
|
|
47
|
+
text: { name: 'text', type: 'string', required: true },
|
|
48
|
+
priority: { name: 'priority', type: 'string', required: false },
|
|
49
|
+
rationale: { name: 'rationale', type: 'string', required: false },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
// C4 Architecture
|
|
53
|
+
'c4:System': {
|
|
54
|
+
id: 'c4:System',
|
|
55
|
+
namespace: 'c4',
|
|
56
|
+
localName: 'System',
|
|
57
|
+
label: 'System',
|
|
58
|
+
description: 'C4 System context',
|
|
59
|
+
parents: ['c4:Container'],
|
|
60
|
+
},
|
|
61
|
+
'c4:Container': {
|
|
62
|
+
id: 'c4:Container',
|
|
63
|
+
namespace: 'c4',
|
|
64
|
+
localName: 'Container',
|
|
65
|
+
label: 'Container',
|
|
66
|
+
description: 'C4 Container',
|
|
67
|
+
parents: ['c4:Component'],
|
|
68
|
+
},
|
|
69
|
+
'c4:Component': {
|
|
70
|
+
id: 'c4:Component',
|
|
71
|
+
namespace: 'c4',
|
|
72
|
+
localName: 'Component',
|
|
73
|
+
label: 'Component',
|
|
74
|
+
description: 'C4 Component',
|
|
75
|
+
},
|
|
76
|
+
// Task
|
|
77
|
+
'task:Task': {
|
|
78
|
+
id: 'task:Task',
|
|
79
|
+
namespace: 'task',
|
|
80
|
+
localName: 'Task',
|
|
81
|
+
label: 'Task',
|
|
82
|
+
description: 'Implementation task',
|
|
83
|
+
properties: {
|
|
84
|
+
id: { name: 'id', type: 'string', required: true },
|
|
85
|
+
title: { name: 'title', type: 'string', required: true },
|
|
86
|
+
status: { name: 'status', type: 'string', required: true },
|
|
87
|
+
estimatedHours: { name: 'estimatedHours', type: 'number', required: false },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Ontology Mapper
|
|
93
|
+
*
|
|
94
|
+
* Maps between different ontology systems
|
|
95
|
+
*/
|
|
96
|
+
export class OntologyMapper {
|
|
97
|
+
namespaces = new Map();
|
|
98
|
+
concepts = new Map();
|
|
99
|
+
relations = new Map();
|
|
100
|
+
mappingRules = new Map();
|
|
101
|
+
constructor() {
|
|
102
|
+
// Initialize with MUSUBIX defaults
|
|
103
|
+
this.loadNamespaces(MUSUBIX_NAMESPACES);
|
|
104
|
+
this.loadConcepts(MUSUBIX_CONCEPTS);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Load namespaces
|
|
108
|
+
*/
|
|
109
|
+
loadNamespaces(namespaces) {
|
|
110
|
+
for (const [key, ns] of Object.entries(namespaces)) {
|
|
111
|
+
this.namespaces.set(key, ns);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Load concepts
|
|
116
|
+
*/
|
|
117
|
+
loadConcepts(concepts) {
|
|
118
|
+
for (const [key, concept] of Object.entries(concepts)) {
|
|
119
|
+
this.concepts.set(key, concept);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Add mapping rule
|
|
124
|
+
*/
|
|
125
|
+
addMappingRule(rule) {
|
|
126
|
+
this.mappingRules.set(rule.id, rule);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get concept by ID
|
|
130
|
+
*/
|
|
131
|
+
getConcept(id) {
|
|
132
|
+
return this.concepts.get(id);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get namespace by prefix
|
|
136
|
+
*/
|
|
137
|
+
getNamespace(prefix) {
|
|
138
|
+
return this.namespaces.get(prefix);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Resolve full URI
|
|
142
|
+
*/
|
|
143
|
+
resolveUri(prefixedName) {
|
|
144
|
+
const [prefix, localName] = prefixedName.split(':');
|
|
145
|
+
const ns = this.namespaces.get(prefix);
|
|
146
|
+
if (!ns) {
|
|
147
|
+
return prefixedName;
|
|
148
|
+
}
|
|
149
|
+
return `${ns.uri}${localName}`;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Compress URI to prefixed name
|
|
153
|
+
*/
|
|
154
|
+
compressUri(uri) {
|
|
155
|
+
for (const [prefix, ns] of this.namespaces) {
|
|
156
|
+
if (uri.startsWith(ns.uri)) {
|
|
157
|
+
return `${prefix}:${uri.slice(ns.uri.length)}`;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return uri;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Map node to target concept
|
|
164
|
+
*/
|
|
165
|
+
mapNode(node, targetConceptId) {
|
|
166
|
+
const sourceType = node.type;
|
|
167
|
+
const ruleKey = `${sourceType}->${targetConceptId}`;
|
|
168
|
+
const rule = this.mappingRules.get(ruleKey);
|
|
169
|
+
if (rule && rule.transform) {
|
|
170
|
+
return rule.transform(node);
|
|
171
|
+
}
|
|
172
|
+
// Default mapping: just change type
|
|
173
|
+
return {
|
|
174
|
+
...node,
|
|
175
|
+
type: targetConceptId,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Map edge type
|
|
180
|
+
*/
|
|
181
|
+
mapEdgeType(edge, _sourceMapping, _targetMapping) {
|
|
182
|
+
const relation = this.relations.get(edge.type);
|
|
183
|
+
if (!relation) {
|
|
184
|
+
return edge;
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
...edge,
|
|
188
|
+
type: relation.type,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Validate node against concept
|
|
193
|
+
*/
|
|
194
|
+
validateNode(node, conceptId) {
|
|
195
|
+
const concept = this.concepts.get(conceptId);
|
|
196
|
+
if (!concept) {
|
|
197
|
+
return {
|
|
198
|
+
valid: false,
|
|
199
|
+
errors: [`Unknown concept: ${conceptId}`],
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const errors = [];
|
|
203
|
+
// Validate required properties
|
|
204
|
+
if (concept.properties) {
|
|
205
|
+
for (const [name, prop] of Object.entries(concept.properties)) {
|
|
206
|
+
if (prop.required && !(name in node.properties)) {
|
|
207
|
+
errors.push(`Missing required property: ${name}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
valid: errors.length === 0,
|
|
213
|
+
errors,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get concept hierarchy
|
|
218
|
+
*/
|
|
219
|
+
getConceptHierarchy(conceptId) {
|
|
220
|
+
const hierarchy = [conceptId];
|
|
221
|
+
const concept = this.concepts.get(conceptId);
|
|
222
|
+
if (concept?.parents) {
|
|
223
|
+
for (const parentId of concept.parents) {
|
|
224
|
+
hierarchy.push(...this.getConceptHierarchy(parentId));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return hierarchy;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Check if concept is subtype of another
|
|
231
|
+
*/
|
|
232
|
+
isSubtypeOf(conceptId, parentConceptId) {
|
|
233
|
+
if (conceptId === parentConceptId) {
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
const concept = this.concepts.get(conceptId);
|
|
237
|
+
if (!concept?.parents) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
return concept.parents.some((parentId) => this.isSubtypeOf(parentId, parentConceptId));
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Get all concepts of type
|
|
244
|
+
*/
|
|
245
|
+
getConceptsOfType(typeId) {
|
|
246
|
+
const results = [];
|
|
247
|
+
for (const concept of this.concepts.values()) {
|
|
248
|
+
if (this.isSubtypeOf(concept.id, typeId)) {
|
|
249
|
+
results.push(concept);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return results;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Create ontology mapper instance
|
|
257
|
+
*/
|
|
258
|
+
export function createOntologyMapper() {
|
|
259
|
+
return new OntologyMapper();
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=ontology.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ontology.js","sourceRoot":"","sources":["../../src/knowledge/ontology.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA0GH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAsC;IACnE,OAAO,EAAE;QACP,MAAM,EAAE,SAAS;QACjB,GAAG,EAAE,+BAA+B;KACrC;IACD,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,oCAAoC;KAC1C;IACD,EAAE,EAAE;QACF,MAAM,EAAE,IAAI;QACZ,GAAG,EAAE,kCAAkC;KACxC;IACD,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,oCAAoC;KAC1C;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAoC;IAC/D,oBAAoB;IACpB,kBAAkB,EAAE;QAClB,EAAE,EAAE,kBAAkB;QACtB,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,aAAa;QACxB,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,yBAAyB;QACtC,UAAU,EAAE;YACV,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,I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