musubix 1.4.4 → 1.7.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/AGENTS.md +48 -10
- package/README.ja.md +34 -5
- package/README.md +37 -6
- package/docs/API-REFERENCE.md +430 -2
- package/docs/INSTALL-GUIDE.ja.md +2 -2
- package/docs/INSTALL-GUIDE.md +2 -2
- package/docs/MUSUBIv1.6.1-enhancement_roadmap_20260105.md +291 -0
- package/docs/ROADMAP-v1.5.md +60 -56
- package/docs/USER-GUIDE.ja.md +717 -6
- package/docs/USER-GUIDE.md +717 -6
- package/docs/evolution-from-musubi-to-musubix.md +522 -6
- package/docs/getting-started-with-sdd.md +1 -1
- package/package.json +3 -2
package/docs/USER-GUIDE.md
CHANGED
|
@@ -15,10 +15,16 @@
|
|
|
15
15
|
7. [C4 Code Generation](#c4-code-generation)
|
|
16
16
|
8. [Symbolic Reasoning](#symbolic-reasoning) *(v1.2.0)*
|
|
17
17
|
9. [Consistency Validation](#consistency-validation) *(v1.4.1)*
|
|
18
|
-
10. [
|
|
19
|
-
11. [
|
|
20
|
-
12. [
|
|
21
|
-
13. [
|
|
18
|
+
10. [Advanced Inference](#advanced-inference) *(v1.4.5)*
|
|
19
|
+
11. [Interactive REPL Mode](#interactive-repl-mode) *(v1.5.0)*
|
|
20
|
+
12. [YATA Local](#yata-local) *(v1.6.3)*
|
|
21
|
+
13. [YATA Global](#yata-global) *(v1.6.3)*
|
|
22
|
+
14. [KGPR - Knowledge Graph Pull Request](#kgpr---knowledge-graph-pull-request) *(v1.6.4)*
|
|
23
|
+
15. [YATA Platform Enhancements](#yata-platform-enhancements) *(v1.7.0)*
|
|
24
|
+
16. [MCP Server Integration](#mcp-server-integration)
|
|
25
|
+
17. [YATA Integration](#yata-integration)
|
|
26
|
+
18. [Best Practices](#best-practices)
|
|
27
|
+
19. [Troubleshooting](#troubleshooting)
|
|
22
28
|
|
|
23
29
|
---
|
|
24
30
|
|
|
@@ -513,6 +519,580 @@ export function createAuthService(): IAuthService {
|
|
|
513
519
|
|
|
514
520
|
---
|
|
515
521
|
|
|
522
|
+
## Interactive REPL Mode
|
|
523
|
+
|
|
524
|
+
*(New in v1.5.0, Enhanced in v1.6.0)*
|
|
525
|
+
|
|
526
|
+
MUSUBIX provides an interactive REPL (Read-Eval-Print-Loop) shell for real-time command execution and exploration.
|
|
527
|
+
|
|
528
|
+
### Starting REPL
|
|
529
|
+
|
|
530
|
+
```bash
|
|
531
|
+
# Start interactive REPL
|
|
532
|
+
musubix repl
|
|
533
|
+
|
|
534
|
+
# With custom history file
|
|
535
|
+
musubix repl --history ~/.musubix-repl-history
|
|
536
|
+
|
|
537
|
+
# Without colors
|
|
538
|
+
musubix repl --no-color
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
### REPL Features
|
|
542
|
+
|
|
543
|
+
| Feature | Description |
|
|
544
|
+
|---------|-------------|
|
|
545
|
+
| Command completion | TAB completion for commands, options |
|
|
546
|
+
| History navigation | UP/DOWN arrows, history search |
|
|
547
|
+
| Session variables | `$name=value` to set, `$name` to reference |
|
|
548
|
+
| Output formatting | JSON, YAML, Table auto-formatting |
|
|
549
|
+
| CLI integration | Execute any CLI command directly |
|
|
550
|
+
|
|
551
|
+
### Basic Usage
|
|
552
|
+
|
|
553
|
+
```bash
|
|
554
|
+
musubix> help # Show all commands
|
|
555
|
+
musubix> help requirements # Show command details
|
|
556
|
+
musubix> requirements analyze input.md # Execute CLI command
|
|
557
|
+
musubix> $project=my-app # Set session variable
|
|
558
|
+
musubix> design generate $project # Use variable in command
|
|
559
|
+
musubix> history # Show command history
|
|
560
|
+
musubix> exit # Exit REPL
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### Session Variables
|
|
564
|
+
|
|
565
|
+
```bash
|
|
566
|
+
# Set variables
|
|
567
|
+
musubix> $req=REQ-001
|
|
568
|
+
musubix> $file=./docs/requirements.md
|
|
569
|
+
|
|
570
|
+
# Use in commands
|
|
571
|
+
musubix> requirements validate $file
|
|
572
|
+
musubix> trace impact $req
|
|
573
|
+
|
|
574
|
+
# Special variable: $_ holds last result
|
|
575
|
+
musubix> requirements analyze input.md
|
|
576
|
+
musubix> $_ # Access last result
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
### Output Formats
|
|
580
|
+
|
|
581
|
+
```bash
|
|
582
|
+
# Auto-detect best format (default)
|
|
583
|
+
musubix> learn status
|
|
584
|
+
|
|
585
|
+
# Force JSON output
|
|
586
|
+
musubix> set format json
|
|
587
|
+
musubix> learn patterns
|
|
588
|
+
|
|
589
|
+
# Force YAML output
|
|
590
|
+
musubix> set format yaml
|
|
591
|
+
|
|
592
|
+
# Force table output
|
|
593
|
+
musubix> set format table
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
### History Management
|
|
597
|
+
|
|
598
|
+
```bash
|
|
599
|
+
# Show recent commands
|
|
600
|
+
musubix> history
|
|
601
|
+
|
|
602
|
+
# Search history (Ctrl+R style)
|
|
603
|
+
musubix> history search requirements
|
|
604
|
+
|
|
605
|
+
# Clear history
|
|
606
|
+
musubix> history clear
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
### REPL Components
|
|
610
|
+
|
|
611
|
+
| Component | Purpose |
|
|
612
|
+
|-----------|---------|
|
|
613
|
+
| `ReplEngine` | Main REPL controller |
|
|
614
|
+
| `CommandCompleter` | TAB completion provider |
|
|
615
|
+
| `HistoryManager` | Command history persistence |
|
|
616
|
+
| `SessionState` | Variable storage |
|
|
617
|
+
| `OutputFormatter` | JSON/YAML/Table output |
|
|
618
|
+
| `PromptRenderer` | Dynamic prompt display |
|
|
619
|
+
|
|
620
|
+
---
|
|
621
|
+
|
|
622
|
+
## YATA Local
|
|
623
|
+
|
|
624
|
+
*(New in v1.6.3)*
|
|
625
|
+
|
|
626
|
+
YATA Local provides a high-performance, SQLite-based local knowledge graph with built-in inference capabilities. Designed for single-user, offline scenarios where data sovereignty and speed are critical.
|
|
627
|
+
|
|
628
|
+
### Features
|
|
629
|
+
|
|
630
|
+
| Feature | Description |
|
|
631
|
+
|---------|-------------|
|
|
632
|
+
| **SQLite Storage** | WAL mode for concurrent reads, single-writer |
|
|
633
|
+
| **Full-Text Search** | FTS5-based triple search |
|
|
634
|
+
| **Graph Traversal** | BFS/DFS with depth control |
|
|
635
|
+
| **Inference Engine** | 4 OWL-lite rules (transitivity, symmetry, inverse, domain/range) |
|
|
636
|
+
| **Constraints** | 4 validation rules (cardinality, disjoint, unique, required) |
|
|
637
|
+
| **ACID Transactions** | Full transaction support |
|
|
638
|
+
|
|
639
|
+
### Installation
|
|
640
|
+
|
|
641
|
+
```bash
|
|
642
|
+
npm install @nahisaho/yata-local
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
### Quick Start
|
|
646
|
+
|
|
647
|
+
```typescript
|
|
648
|
+
import { YataLocal } from '@nahisaho/yata-local';
|
|
649
|
+
|
|
650
|
+
// Initialize with default config
|
|
651
|
+
const yata = new YataLocal('./knowledge.db');
|
|
652
|
+
await yata.initialize();
|
|
653
|
+
|
|
654
|
+
// Add triples
|
|
655
|
+
await yata.addTriple({
|
|
656
|
+
subject: 'Person:john',
|
|
657
|
+
predicate: 'hasParent',
|
|
658
|
+
object: 'Person:mary'
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
// Query triples
|
|
662
|
+
const results = await yata.query({
|
|
663
|
+
subject: 'Person:john',
|
|
664
|
+
predicate: 'hasParent'
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
// Full-text search
|
|
668
|
+
const searchResults = await yata.search('john parent');
|
|
669
|
+
|
|
670
|
+
// Graph traversal (BFS)
|
|
671
|
+
const ancestors = await yata.traverse('Person:john', 'hasParent', {
|
|
672
|
+
direction: 'outgoing',
|
|
673
|
+
maxDepth: 5,
|
|
674
|
+
algorithm: 'bfs'
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
// Clean up
|
|
678
|
+
await yata.close();
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
### Inference Engine
|
|
682
|
+
|
|
683
|
+
YATA Local supports four OWL-lite inference rules:
|
|
684
|
+
|
|
685
|
+
| Rule | Description | Example |
|
|
686
|
+
|------|-------------|---------|
|
|
687
|
+
| **Transitivity** | If A→B and B→C then A→C | hasAncestor is transitive |
|
|
688
|
+
| **Symmetry** | If A→B then B→A | friendOf is symmetric |
|
|
689
|
+
| **Inverse** | If A→B via P then B→A via P⁻¹ | hasChild ↔ hasParent |
|
|
690
|
+
| **Domain/Range** | Type inference from predicate | hasAge implies Person |
|
|
691
|
+
|
|
692
|
+
```typescript
|
|
693
|
+
// Run inference
|
|
694
|
+
const inferred = await yata.infer();
|
|
695
|
+
console.log(`Inferred ${inferred.length} new triples`);
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
### Constraints
|
|
699
|
+
|
|
700
|
+
```typescript
|
|
701
|
+
// Define constraints
|
|
702
|
+
await yata.addConstraint({
|
|
703
|
+
type: 'cardinality',
|
|
704
|
+
predicate: 'hasSpouse',
|
|
705
|
+
max: 1
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
// Validate
|
|
709
|
+
const violations = await yata.validate();
|
|
710
|
+
if (violations.length > 0) {
|
|
711
|
+
console.error('Constraint violations:', violations);
|
|
712
|
+
}
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
### Configuration Options
|
|
716
|
+
|
|
717
|
+
```typescript
|
|
718
|
+
const yata = new YataLocal('./knowledge.db', {
|
|
719
|
+
// WAL mode for better concurrency (default: true)
|
|
720
|
+
walMode: true,
|
|
721
|
+
|
|
722
|
+
// Enable FTS5 search (default: true)
|
|
723
|
+
enableSearch: true,
|
|
724
|
+
|
|
725
|
+
// Auto-run inference on writes (default: false)
|
|
726
|
+
autoInfer: false,
|
|
727
|
+
|
|
728
|
+
// Journal mode (default: 'wal')
|
|
729
|
+
journalMode: 'wal'
|
|
730
|
+
});
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
---
|
|
734
|
+
|
|
735
|
+
## YATA Global
|
|
736
|
+
|
|
737
|
+
*(New in v1.6.3)*
|
|
738
|
+
|
|
739
|
+
YATA Global is a distributed knowledge graph platform for team collaboration. It provides REST API access to shared knowledge graphs with offline support and intelligent synchronization.
|
|
740
|
+
|
|
741
|
+
### Features
|
|
742
|
+
|
|
743
|
+
| Feature | Description |
|
|
744
|
+
|---------|-------------|
|
|
745
|
+
| **REST API** | Full CRUD operations via HTTP |
|
|
746
|
+
| **Offline Cache** | SQLite-based local cache |
|
|
747
|
+
| **Sync Engine** | Push/Pull with conflict resolution |
|
|
748
|
+
| **Conflict Resolution** | Last-write-wins or custom strategies |
|
|
749
|
+
| **Authentication** | API key-based auth |
|
|
750
|
+
| **Batch Operations** | Bulk triple operations |
|
|
751
|
+
|
|
752
|
+
### Installation
|
|
753
|
+
|
|
754
|
+
```bash
|
|
755
|
+
npm install @nahisaho/yata-global
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
### Quick Start
|
|
759
|
+
|
|
760
|
+
```typescript
|
|
761
|
+
import { YataGlobal } from '@nahisaho/yata-global';
|
|
762
|
+
|
|
763
|
+
// Initialize client
|
|
764
|
+
const yata = new YataGlobal({
|
|
765
|
+
endpoint: 'https://yata.example.com/api',
|
|
766
|
+
apiKey: 'your-api-key',
|
|
767
|
+
graphId: 'project-knowledge'
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
await yata.initialize();
|
|
771
|
+
|
|
772
|
+
// Add triples (batched)
|
|
773
|
+
await yata.addTriples([
|
|
774
|
+
{ subject: 'Task:001', predicate: 'assignedTo', object: 'User:alice' },
|
|
775
|
+
{ subject: 'Task:001', predicate: 'status', object: 'in-progress' }
|
|
776
|
+
]);
|
|
777
|
+
|
|
778
|
+
// Query with filters
|
|
779
|
+
const tasks = await yata.query({
|
|
780
|
+
predicate: 'assignedTo',
|
|
781
|
+
object: 'User:alice'
|
|
782
|
+
});
|
|
783
|
+
|
|
784
|
+
// Clean up
|
|
785
|
+
await yata.close();
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
### Offline Support
|
|
789
|
+
|
|
790
|
+
YATA Global supports offline-first operation with automatic synchronization:
|
|
791
|
+
|
|
792
|
+
```typescript
|
|
793
|
+
const yata = new YataGlobal({
|
|
794
|
+
endpoint: 'https://yata.example.com/api',
|
|
795
|
+
apiKey: 'your-api-key',
|
|
796
|
+
graphId: 'project-knowledge',
|
|
797
|
+
|
|
798
|
+
// Offline configuration
|
|
799
|
+
offlineMode: true,
|
|
800
|
+
cachePath: './yata-cache.db',
|
|
801
|
+
syncInterval: 60000 // Auto-sync every 60 seconds
|
|
802
|
+
});
|
|
803
|
+
|
|
804
|
+
// Works offline - cached locally
|
|
805
|
+
await yata.addTriple({
|
|
806
|
+
subject: 'Note:001',
|
|
807
|
+
predicate: 'content',
|
|
808
|
+
object: 'Important meeting notes'
|
|
809
|
+
});
|
|
810
|
+
|
|
811
|
+
// Manual sync when online
|
|
812
|
+
await yata.sync();
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
### Conflict Resolution
|
|
816
|
+
|
|
817
|
+
```typescript
|
|
818
|
+
const yata = new YataGlobal({
|
|
819
|
+
// ... other options
|
|
820
|
+
|
|
821
|
+
conflictStrategy: 'last-write-wins', // Default
|
|
822
|
+
// or: 'server-wins', 'client-wins', 'manual'
|
|
823
|
+
|
|
824
|
+
onConflict: async (local, remote) => {
|
|
825
|
+
// Custom resolution logic
|
|
826
|
+
console.log('Conflict detected:', local, remote);
|
|
827
|
+
return remote; // Prefer remote version
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
### Sync Status
|
|
833
|
+
|
|
834
|
+
```typescript
|
|
835
|
+
// Check sync status
|
|
836
|
+
const status = await yata.getSyncStatus();
|
|
837
|
+
console.log(`Pending changes: ${status.pendingPush}`);
|
|
838
|
+
console.log(`Last sync: ${status.lastSyncAt}`);
|
|
839
|
+
|
|
840
|
+
// Force full sync
|
|
841
|
+
await yata.sync({ force: true });
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
### When to Use YATA Local vs YATA Global
|
|
845
|
+
|
|
846
|
+
| Use Case | Recommended |
|
|
847
|
+
|----------|-------------|
|
|
848
|
+
| Personal knowledge base | YATA Local |
|
|
849
|
+
| Single-user application | YATA Local |
|
|
850
|
+
| Privacy-sensitive data | YATA Local |
|
|
851
|
+
| Team collaboration | YATA Global |
|
|
852
|
+
| Cross-device access | YATA Global |
|
|
853
|
+
| Shared project knowledge | YATA Global |
|
|
854
|
+
| Offline-first with sync | YATA Global |
|
|
855
|
+
|
|
856
|
+
---
|
|
857
|
+
|
|
858
|
+
## KGPR - Knowledge Graph Pull Request
|
|
859
|
+
|
|
860
|
+
*(v1.6.4)*
|
|
861
|
+
|
|
862
|
+
KGPR (Knowledge Graph Pull Request) enables safe sharing of knowledge graphs from YATA Local to YATA Global using a GitHub PR-like workflow.
|
|
863
|
+
|
|
864
|
+
### Workflow
|
|
865
|
+
|
|
866
|
+
```
|
|
867
|
+
┌─────────────┐ ┌──────────────┐ ┌───────────────┐
|
|
868
|
+
│ YATA Local │ ──► │ KGPR (Draft) │ ──► │ YATA Global │
|
|
869
|
+
│ (Local KG) │ │ (Extract) │ │ (Review/Merge)│
|
|
870
|
+
└─────────────┘ └──────────────┘ └───────────────┘
|
|
871
|
+
|
|
872
|
+
Status Flow:
|
|
873
|
+
draft → open → reviewing → approved/changes_requested → merged/closed
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
### Privacy Levels
|
|
877
|
+
|
|
878
|
+
| Level | Filtered Content |
|
|
879
|
+
|-------|------------------|
|
|
880
|
+
| `strict` | File paths, URLs, credentials, all metadata |
|
|
881
|
+
| `moderate` | File paths, URLs, credentials |
|
|
882
|
+
| `none` | No filtering |
|
|
883
|
+
|
|
884
|
+
### CLI Commands
|
|
885
|
+
|
|
886
|
+
```bash
|
|
887
|
+
# Create a KGPR
|
|
888
|
+
musubix kgpr create -t "Add authentication patterns"
|
|
889
|
+
|
|
890
|
+
# Preview diff before creating
|
|
891
|
+
musubix kgpr diff --namespace myproject --privacy moderate
|
|
892
|
+
|
|
893
|
+
# List KGPRs
|
|
894
|
+
musubix kgpr list
|
|
895
|
+
|
|
896
|
+
# Submit KGPR for review
|
|
897
|
+
musubix kgpr submit <id>
|
|
898
|
+
|
|
899
|
+
# Show KGPR details
|
|
900
|
+
musubix kgpr show <id>
|
|
901
|
+
|
|
902
|
+
# Close without merging
|
|
903
|
+
musubix kgpr close <id>
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
### MCP Tools
|
|
907
|
+
|
|
908
|
+
| Tool | Description |
|
|
909
|
+
|------|-------------|
|
|
910
|
+
| `kgpr_create` | Create KGPR from local knowledge graph |
|
|
911
|
+
| `kgpr_diff` | Preview diff before creating KGPR |
|
|
912
|
+
| `kgpr_list` | List all KGPRs |
|
|
913
|
+
| `kgpr_submit` | Submit KGPR for review |
|
|
914
|
+
| `kgpr_review` | Review KGPR (approve/changes_requested/commented) |
|
|
915
|
+
|
|
916
|
+
### Example Usage
|
|
917
|
+
|
|
918
|
+
```bash
|
|
919
|
+
# 1. Preview what will be shared
|
|
920
|
+
musubix kgpr diff --privacy strict
|
|
921
|
+
|
|
922
|
+
# 2. Create KGPR with description
|
|
923
|
+
musubix kgpr create -t "Share React patterns" -d "Learned patterns from project-x"
|
|
924
|
+
|
|
925
|
+
# 3. Review the KGPR
|
|
926
|
+
musubix kgpr show KGPR-001
|
|
927
|
+
|
|
928
|
+
# 4. Submit for review
|
|
929
|
+
musubix kgpr submit KGPR-001
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
---
|
|
933
|
+
|
|
934
|
+
## YATA Platform Enhancements
|
|
935
|
+
|
|
936
|
+
*(v1.7.0)*
|
|
937
|
+
|
|
938
|
+
Version 1.7.0 introduces significant enhancements to the YATA platform with 5 major features.
|
|
939
|
+
|
|
940
|
+
### Phase 1: Index Optimization
|
|
941
|
+
|
|
942
|
+
Optimized query performance for YATA Local with composite indexes.
|
|
943
|
+
|
|
944
|
+
```typescript
|
|
945
|
+
import { IndexOptimizer } from '@nahisaho/yata-local';
|
|
946
|
+
|
|
947
|
+
const optimizer = new IndexOptimizer(database);
|
|
948
|
+
|
|
949
|
+
// Analyze and create optimal indexes
|
|
950
|
+
const analysis = await optimizer.analyzeQueryPatterns();
|
|
951
|
+
const created = await optimizer.createOptimalIndexes();
|
|
952
|
+
|
|
953
|
+
// Check index health
|
|
954
|
+
const health = await optimizer.checkIndexHealth();
|
|
955
|
+
```
|
|
956
|
+
|
|
957
|
+
**Key Features:**
|
|
958
|
+
- Composite index creation for common query patterns
|
|
959
|
+
- Index health monitoring with fragmentation detection
|
|
960
|
+
- Automatic optimization recommendations
|
|
961
|
+
|
|
962
|
+
### Phase 2: Enhanced Export Pipeline
|
|
963
|
+
|
|
964
|
+
Powerful export capabilities with incremental export and multiple formats.
|
|
965
|
+
|
|
966
|
+
```typescript
|
|
967
|
+
import { ExportPipeline } from '@nahisaho/yata-local';
|
|
968
|
+
|
|
969
|
+
const pipeline = new ExportPipeline(database);
|
|
970
|
+
|
|
971
|
+
// Full export
|
|
972
|
+
const fullData = await pipeline.exportFull({ namespace: 'myproject' });
|
|
973
|
+
|
|
974
|
+
// Incremental export (changes since last export)
|
|
975
|
+
const changes = await pipeline.exportIncremental({
|
|
976
|
+
since: lastExportTimestamp,
|
|
977
|
+
format: 'json'
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
// Export with transformation
|
|
981
|
+
const transformed = await pipeline.exportWithTransform({
|
|
982
|
+
format: 'rdf',
|
|
983
|
+
includeMetadata: true
|
|
984
|
+
});
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
**Supported Formats:**
|
|
988
|
+
- JSON (default)
|
|
989
|
+
- RDF/Turtle
|
|
990
|
+
- N-Triples
|
|
991
|
+
- Custom transformers
|
|
992
|
+
|
|
993
|
+
### Phase 3: Global Sync Integration
|
|
994
|
+
|
|
995
|
+
Seamless synchronization between YATA Local and YATA Global.
|
|
996
|
+
|
|
997
|
+
```typescript
|
|
998
|
+
import { GlobalSyncClient, SyncEngine } from '@nahisaho/yata-global';
|
|
999
|
+
|
|
1000
|
+
const client = new GlobalSyncClient({
|
|
1001
|
+
endpoint: 'https://yata-global.example.com',
|
|
1002
|
+
offlineMode: true
|
|
1003
|
+
});
|
|
1004
|
+
|
|
1005
|
+
// Initialize sync
|
|
1006
|
+
await client.initialize();
|
|
1007
|
+
|
|
1008
|
+
// Push local changes
|
|
1009
|
+
const syncResult = await client.sync({
|
|
1010
|
+
namespace: 'myproject',
|
|
1011
|
+
direction: 'push'
|
|
1012
|
+
});
|
|
1013
|
+
|
|
1014
|
+
// Pull updates from global
|
|
1015
|
+
await client.sync({
|
|
1016
|
+
namespace: 'shared-patterns',
|
|
1017
|
+
direction: 'pull'
|
|
1018
|
+
});
|
|
1019
|
+
```
|
|
1020
|
+
|
|
1021
|
+
**Features:**
|
|
1022
|
+
- Offline-first with automatic sync
|
|
1023
|
+
- Conflict resolution strategies
|
|
1024
|
+
- Selective namespace sync
|
|
1025
|
+
- Framework pattern repository
|
|
1026
|
+
|
|
1027
|
+
### Phase 4: Code Generator Enhancement
|
|
1028
|
+
|
|
1029
|
+
Advanced code generation from design documents.
|
|
1030
|
+
|
|
1031
|
+
```typescript
|
|
1032
|
+
import { CodeGenerator } from '@nahisaho/yata-local';
|
|
1033
|
+
|
|
1034
|
+
const generator = new CodeGenerator({
|
|
1035
|
+
language: 'typescript',
|
|
1036
|
+
outputDir: './src/generated'
|
|
1037
|
+
});
|
|
1038
|
+
|
|
1039
|
+
// Generate from C4 design
|
|
1040
|
+
const result = await generator.generateFromC4(designDocument);
|
|
1041
|
+
|
|
1042
|
+
// Generate with custom templates
|
|
1043
|
+
await generator.generate({
|
|
1044
|
+
template: 'repository-pattern',
|
|
1045
|
+
context: { entityName: 'User' }
|
|
1046
|
+
});
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
**Supported Patterns:**
|
|
1050
|
+
- Repository Pattern
|
|
1051
|
+
- Service Layer
|
|
1052
|
+
- Factory Pattern
|
|
1053
|
+
- Domain Events
|
|
1054
|
+
- Value Objects
|
|
1055
|
+
|
|
1056
|
+
### Phase 5: YATA UI (Web Visualization)
|
|
1057
|
+
|
|
1058
|
+
Web-based visualization and management interface for knowledge graphs.
|
|
1059
|
+
|
|
1060
|
+
```typescript
|
|
1061
|
+
import { YataUIServer, createYataUIServer } from '@nahisaho/yata-ui';
|
|
1062
|
+
|
|
1063
|
+
// Create and start server
|
|
1064
|
+
const server = createYataUIServer({
|
|
1065
|
+
port: 3000,
|
|
1066
|
+
enableRealtime: true
|
|
1067
|
+
});
|
|
1068
|
+
|
|
1069
|
+
// Set data provider
|
|
1070
|
+
server.setDataProvider(async () => ({
|
|
1071
|
+
nodes: await getEntities(),
|
|
1072
|
+
edges: await getRelationships()
|
|
1073
|
+
}));
|
|
1074
|
+
|
|
1075
|
+
await server.start();
|
|
1076
|
+
console.log(`UI available at ${server.getUrl()}`);
|
|
1077
|
+
```
|
|
1078
|
+
|
|
1079
|
+
**UI Features:**
|
|
1080
|
+
- Interactive graph visualization
|
|
1081
|
+
- Real-time updates via WebSocket
|
|
1082
|
+
- Namespace filtering
|
|
1083
|
+
- Entity/Relationship editing
|
|
1084
|
+
- Export/Import functionality
|
|
1085
|
+
|
|
1086
|
+
### v1.7.0 Package Summary
|
|
1087
|
+
|
|
1088
|
+
| Package | Description |
|
|
1089
|
+
|---------|-------------|
|
|
1090
|
+
| `@nahisaho/yata-local` | IndexOptimizer, ExportPipeline, CodeGenerator |
|
|
1091
|
+
| `@nahisaho/yata-global` | GlobalSyncClient, SyncEngine, CacheManager |
|
|
1092
|
+
| `@nahisaho/yata-ui` | YataUIServer, Graph visualization |
|
|
1093
|
+
|
|
1094
|
+
---
|
|
1095
|
+
|
|
516
1096
|
## MCP Server Integration
|
|
517
1097
|
|
|
518
1098
|
### CLI Startup
|
|
@@ -800,6 +1380,137 @@ const semanticDuplicates = validator.findSemanticDuplicates(allTriples);
|
|
|
800
1380
|
|
|
801
1381
|
---
|
|
802
1382
|
|
|
1383
|
+
## Advanced Inference
|
|
1384
|
+
|
|
1385
|
+
*(v1.4.5 New Feature)*
|
|
1386
|
+
|
|
1387
|
+
### Overview
|
|
1388
|
+
|
|
1389
|
+
Advanced Inference provides OWL 2 RL reasoning and Datalog evaluation capabilities for the knowledge graph. It supports materialization of implicit facts, rule-based inference, and human-readable explanations.
|
|
1390
|
+
|
|
1391
|
+
### Key Components
|
|
1392
|
+
|
|
1393
|
+
| Component | Description |
|
|
1394
|
+
|-----------|-------------|
|
|
1395
|
+
| `OWL2RLReasoner` | OWL 2 RL profile reasoning with 20+ built-in rules |
|
|
1396
|
+
| `DatalogEngine` | Stratified Datalog evaluation engine |
|
|
1397
|
+
| `InferenceExplainer` | Natural language explanation generator |
|
|
1398
|
+
| `ProgressReporter` | Real-time inference progress tracking |
|
|
1399
|
+
|
|
1400
|
+
### OWL 2 RL Reasoning
|
|
1401
|
+
|
|
1402
|
+
```typescript
|
|
1403
|
+
import { OWL2RLReasoner } from '@nahisaho/musubix-ontology-mcp';
|
|
1404
|
+
|
|
1405
|
+
const reasoner = new OWL2RLReasoner({
|
|
1406
|
+
maxIterations: 100,
|
|
1407
|
+
enablePropertyChains: true,
|
|
1408
|
+
enableInverseProperties: true
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1411
|
+
// Run reasoning on store
|
|
1412
|
+
const result = await reasoner.reason(store, {
|
|
1413
|
+
onProgress: (progress) => {
|
|
1414
|
+
console.log(`Iteration ${progress.iteration}: ${progress.newTriples} new triples`);
|
|
1415
|
+
}
|
|
1416
|
+
});
|
|
1417
|
+
|
|
1418
|
+
console.log(`Inferred ${result.inferredCount} new facts`);
|
|
1419
|
+
console.log(`Rules applied: ${result.rulesApplied.join(', ')}`);
|
|
1420
|
+
```
|
|
1421
|
+
|
|
1422
|
+
### OWL 2 RL Rules
|
|
1423
|
+
|
|
1424
|
+
| Rule ID | Name | Description |
|
|
1425
|
+
|---------|------|-------------|
|
|
1426
|
+
| `prp-dom` | Property Domain | Infer type from property domain |
|
|
1427
|
+
| `prp-rng` | Property Range | Infer type from property range |
|
|
1428
|
+
| `prp-inv1/2` | Inverse Properties | Infer inverse relationships |
|
|
1429
|
+
| `prp-trp` | Transitive Properties | Chain transitive properties |
|
|
1430
|
+
| `prp-symp` | Symmetric Properties | Infer symmetric relationships |
|
|
1431
|
+
| `cax-sco` | SubClassOf | Propagate class membership |
|
|
1432
|
+
| `scm-spo` | SubPropertyOf | Property subsumption |
|
|
1433
|
+
| `eq-rep-s/p/o` | SameAs Replacement | Substitute equal individuals |
|
|
1434
|
+
|
|
1435
|
+
### Datalog Evaluation
|
|
1436
|
+
|
|
1437
|
+
```typescript
|
|
1438
|
+
import { DatalogEngine } from '@nahisaho/musubix-ontology-mcp';
|
|
1439
|
+
|
|
1440
|
+
const engine = new DatalogEngine();
|
|
1441
|
+
|
|
1442
|
+
// Define rules
|
|
1443
|
+
const rules = [
|
|
1444
|
+
{
|
|
1445
|
+
head: { predicate: 'ancestor', args: ['?x', '?y'] },
|
|
1446
|
+
body: [
|
|
1447
|
+
{ predicate: 'parent', args: ['?x', '?y'] }
|
|
1448
|
+
]
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
head: { predicate: 'ancestor', args: ['?x', '?z'] },
|
|
1452
|
+
body: [
|
|
1453
|
+
{ predicate: 'parent', args: ['?x', '?y'] },
|
|
1454
|
+
{ predicate: 'ancestor', args: ['?y', '?z'] }
|
|
1455
|
+
]
|
|
1456
|
+
}
|
|
1457
|
+
];
|
|
1458
|
+
|
|
1459
|
+
// Evaluate rules
|
|
1460
|
+
const result = await engine.evaluate(rules, facts, {
|
|
1461
|
+
onProgress: (progress) => {
|
|
1462
|
+
console.log(`Stratum ${progress.stratum}: evaluating ${progress.rule}`);
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
|
|
1466
|
+
console.log(`Derived ${result.derivedFacts.length} new facts`);
|
|
1467
|
+
```
|
|
1468
|
+
|
|
1469
|
+
### Inference Explanation
|
|
1470
|
+
|
|
1471
|
+
```typescript
|
|
1472
|
+
import { InferenceExplainer, ExplanationFormat } from '@nahisaho/musubix-ontology-mcp';
|
|
1473
|
+
|
|
1474
|
+
const explainer = new InferenceExplainer(reasoner.getProvenanceLog());
|
|
1475
|
+
|
|
1476
|
+
// Get explanation for a specific triple
|
|
1477
|
+
const explanation = explainer.explain(
|
|
1478
|
+
'http://example.org/Animal',
|
|
1479
|
+
'rdf:type',
|
|
1480
|
+
'owl:Class',
|
|
1481
|
+
ExplanationFormat.TEXT
|
|
1482
|
+
);
|
|
1483
|
+
|
|
1484
|
+
console.log(explanation);
|
|
1485
|
+
// Output: "Animal is a Class because it is declared as owl:Class via rule cax-sco"
|
|
1486
|
+
|
|
1487
|
+
// Generate HTML explanation
|
|
1488
|
+
const htmlExplanation = explainer.explain(
|
|
1489
|
+
subject, predicate, object,
|
|
1490
|
+
ExplanationFormat.HTML
|
|
1491
|
+
);
|
|
1492
|
+
```
|
|
1493
|
+
|
|
1494
|
+
### Progress Reporting
|
|
1495
|
+
|
|
1496
|
+
```typescript
|
|
1497
|
+
import { createProgressReporter } from '@nahisaho/musubix-ontology-mcp';
|
|
1498
|
+
|
|
1499
|
+
const reporter = createProgressReporter({
|
|
1500
|
+
onProgress: (info) => {
|
|
1501
|
+
console.log(`Phase: ${info.phase}`);
|
|
1502
|
+
console.log(`Iteration: ${info.iteration}/${info.maxIterations}`);
|
|
1503
|
+
console.log(`Triples: ${info.totalTriples}`);
|
|
1504
|
+
console.log(`New inferences: ${info.newInferences}`);
|
|
1505
|
+
},
|
|
1506
|
+
throttleMs: 500 // Report every 500ms
|
|
1507
|
+
});
|
|
1508
|
+
|
|
1509
|
+
await reasoner.reason(store, { progressReporter: reporter });
|
|
1510
|
+
```
|
|
1511
|
+
|
|
1512
|
+
---
|
|
1513
|
+
|
|
803
1514
|
## YATA Integration
|
|
804
1515
|
|
|
805
1516
|
### What is YATA?
|
|
@@ -992,6 +1703,6 @@ const client = createYATAClient({
|
|
|
992
1703
|
|
|
993
1704
|
---
|
|
994
1705
|
|
|
995
|
-
**Version**: 1.
|
|
996
|
-
**Last Updated**: 2026-01-
|
|
1706
|
+
**Version**: 1.6.0
|
|
1707
|
+
**Last Updated**: 2026-01-06
|
|
997
1708
|
**MUSUBIX Project**
|