@ltm-blueverse/alpha-semantic-hub 0.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.
Files changed (146) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1674 -0
  3. package/explorer/README.md +282 -0
  4. package/explorer/src/App.css +0 -0
  5. package/explorer/src/App.tsx +2035 -0
  6. package/explorer/src/ErrorBoundary.tsx +112 -0
  7. package/explorer/src/ExploreWorkspaceTabs.tsx +29 -0
  8. package/explorer/src/assets/hero.png +0 -0
  9. package/explorer/src/assets/react.svg +1 -0
  10. package/explorer/src/assets/vite.svg +1 -0
  11. package/explorer/src/explorerCapabilities.ts +24 -0
  12. package/explorer/src/index.css +71 -0
  13. package/explorer/src/main.tsx +7 -0
  14. package/explorer/src/store/edgePairKeys.d.ts +2 -0
  15. package/explorer/src/store/edgePairKeys.js +7 -0
  16. package/explorer/src/store/graphStore.ts +183 -0
  17. package/explorer/src/store/registryStore.ts +78 -0
  18. package/explorer/src/types.d.ts +16 -0
  19. package/explorer/src/ui/primitives.css +414 -0
  20. package/explorer/src/ui/primitives.tsx +170 -0
  21. package/explorer/src/workspaces/DecisionWorkspace/DecisionWorkspace.tsx +279 -0
  22. package/explorer/src/workspaces/DiffMergeWorkspace/DiffMergeWorkspace.tsx +121 -0
  23. package/explorer/src/workspaces/EnrichWorkspace/EntityResolutionTab.tsx +454 -0
  24. package/explorer/src/workspaces/EnrichWorkspace/RegistryTab.tsx +285 -0
  25. package/explorer/src/workspaces/GraphWorkspace/GraphCanvas.tsx +2673 -0
  26. package/explorer/src/workspaces/GraphWorkspace/GraphInspectorPanel.tsx +771 -0
  27. package/explorer/src/workspaces/GraphWorkspace/GraphLoadingOverlay.tsx +410 -0
  28. package/explorer/src/workspaces/GraphWorkspace/GraphWorkspace.tsx +3584 -0
  29. package/explorer/src/workspaces/GraphWorkspace/MarkdownContentViewer.tsx +705 -0
  30. package/explorer/src/workspaces/GraphWorkspace/SigmaSceneAdapter.tsx +55 -0
  31. package/explorer/src/workspaces/GraphWorkspace/TimelinePanel.tsx +193 -0
  32. package/explorer/src/workspaces/GraphWorkspace/behaviors/clickSelectionBehavior.ts +29 -0
  33. package/explorer/src/workspaces/GraphWorkspace/behaviors/fitViewBehavior.ts +15 -0
  34. package/explorer/src/workspaces/GraphWorkspace/behaviors/focusCameraBehavior.ts +25 -0
  35. package/explorer/src/workspaces/GraphWorkspace/behaviors/hoverActivationBehavior.ts +15 -0
  36. package/explorer/src/workspaces/GraphWorkspace/behaviors/pathHighlightBehavior.ts +52 -0
  37. package/explorer/src/workspaces/GraphWorkspace/behaviors/searchFocusBehavior.ts +36 -0
  38. package/explorer/src/workspaces/GraphWorkspace/behaviors/types.ts +41 -0
  39. package/explorer/src/workspaces/GraphWorkspace/behaviors/viewModeSwitchBehavior.ts +29 -0
  40. package/explorer/src/workspaces/GraphWorkspace/graphAnalytics.ts +779 -0
  41. package/explorer/src/workspaces/GraphWorkspace/graphColorLegend.ts +36 -0
  42. package/explorer/src/workspaces/GraphWorkspace/graphConfig.ts +102 -0
  43. package/explorer/src/workspaces/GraphWorkspace/graphEntityShape.ts +34 -0
  44. package/explorer/src/workspaces/GraphWorkspace/graphLoading.ts +84 -0
  45. package/explorer/src/workspaces/GraphWorkspace/graphSceneLayers.ts +775 -0
  46. package/explorer/src/workspaces/GraphWorkspace/graphSceneState.ts +2753 -0
  47. package/explorer/src/workspaces/GraphWorkspace/graphStructureLayer.ts +335 -0
  48. package/explorer/src/workspaces/GraphWorkspace/graphTheme.ts +1078 -0
  49. package/explorer/src/workspaces/GraphWorkspace/graphViewCopy.ts +41 -0
  50. package/explorer/src/workspaces/GraphWorkspace/localGraphTransition.ts +9 -0
  51. package/explorer/src/workspaces/GraphWorkspace/markdownEditorState.ts +114 -0
  52. package/explorer/src/workspaces/GraphWorkspace/markdownResourceClient.ts +103 -0
  53. package/explorer/src/workspaces/GraphWorkspace/markdownUrlSafety.ts +29 -0
  54. package/explorer/src/workspaces/GraphWorkspace/nodeMarkdownSync.ts +81 -0
  55. package/explorer/src/workspaces/GraphWorkspace/pluginRegistryPredicates.ts +24 -0
  56. package/explorer/src/workspaces/GraphWorkspace/plugins/explorationEffectsPlugin.tsx +353 -0
  57. package/explorer/src/workspaces/GraphWorkspace/plugins/explorationEffectsPluginPhaseC.tsx +522 -0
  58. package/explorer/src/workspaces/GraphWorkspace/plugins/index.ts +16 -0
  59. package/explorer/src/workspaces/GraphWorkspace/plugins/legendPlugin.tsx +120 -0
  60. package/explorer/src/workspaces/GraphWorkspace/plugins/neighborhoodPanelPlugin.tsx +231 -0
  61. package/explorer/src/workspaces/GraphWorkspace/plugins/temporalOverlayPlugin.tsx +142 -0
  62. package/explorer/src/workspaces/GraphWorkspace/plugins/types.ts +106 -0
  63. package/explorer/src/workspaces/GraphWorkspace/realtimeGraphAttributes.ts +50 -0
  64. package/explorer/src/workspaces/GraphWorkspace/scene.ts +79 -0
  65. package/explorer/src/workspaces/GraphWorkspace/sigmaNativeRendering.ts +421 -0
  66. package/explorer/src/workspaces/GraphWorkspace/smallGraphLayout.ts +135 -0
  67. package/explorer/src/workspaces/GraphWorkspace/temporalLifecyclePredicates.ts +31 -0
  68. package/explorer/src/workspaces/GraphWorkspace/temporalScrubberBounds.ts +46 -0
  69. package/explorer/src/workspaces/GraphWorkspace/temporalSnapshotGuards.ts +113 -0
  70. package/explorer/src/workspaces/GraphWorkspace/types.ts +395 -0
  71. package/explorer/src/workspaces/GraphWorkspace/useLoadGraph.ts +746 -0
  72. package/explorer/src/workspaces/GraphWorkspace/useMarkdownEditor.ts +177 -0
  73. package/explorer/src/workspaces/ImportExportWorkspace/ImportExportWorkspace.tsx +196 -0
  74. package/explorer/src/workspaces/LineageWorkspace/LineageDiagram.tsx +177 -0
  75. package/explorer/src/workspaces/ManageWorkspace/KGOverviewTab.tsx +291 -0
  76. package/explorer/src/workspaces/ManageWorkspace/OntologySummaryTab.tsx +346 -0
  77. package/explorer/src/workspaces/MemoryWorkspace.tsx +464 -0
  78. package/explorer/src/workspaces/OntologyWorkspace/AlignmentsTab.tsx +437 -0
  79. package/explorer/src/workspaces/OntologyWorkspace/HealthTab.tsx +214 -0
  80. package/explorer/src/workspaces/OntologyWorkspace/OntologyEditor.tsx +770 -0
  81. package/explorer/src/workspaces/OntologyWorkspace/OntologyLoader.tsx +913 -0
  82. package/explorer/src/workspaces/OntologyWorkspace/OntologyManager.tsx +930 -0
  83. package/explorer/src/workspaces/OntologyWorkspace/OntologySearch.tsx +590 -0
  84. package/explorer/src/workspaces/OntologyWorkspace/ProposalReview.tsx +429 -0
  85. package/explorer/src/workspaces/OntologyWorkspace/SKOSVocabularyManager.tsx +696 -0
  86. package/explorer/src/workspaces/OntologyWorkspace/ShaclStudio.tsx +363 -0
  87. package/explorer/src/workspaces/OntologyWorkspace/VersionsTab.tsx +546 -0
  88. package/explorer/src/workspaces/OntologyWorkspace/api.ts +164 -0
  89. package/explorer/src/workspaces/OntologyWorkspace/index.tsx +101 -0
  90. package/explorer/src/workspaces/OntologyWorkspace/ontologyEditorModel.ts +87 -0
  91. package/explorer/src/workspaces/OntologyWorkspace/ontologyUrlState.ts +94 -0
  92. package/explorer/src/workspaces/OntologyWorkspace/types.ts +119 -0
  93. package/explorer/src/workspaces/ReasoningWorkspace.tsx +243 -0
  94. package/explorer/src/workspaces/SparqlWorkspace/SparqlWorkspace.tsx +271 -0
  95. package/explorer/src/workspaces/VocabularyWorkspace/ConceptTree.tsx +97 -0
  96. package/explorer/src/workspaces/VocabularyWorkspace/ImportDropzone.tsx +95 -0
  97. package/explorer/src/workspaces/VocabularyWorkspace/PropertyPanel.tsx +116 -0
  98. package/explorer/src/workspaces/VocabularyWorkspace/Sidebar.tsx +112 -0
  99. package/explorer/src/workspaces/VocabularyWorkspace/VocabularyWorkspace.tsx +70 -0
  100. package/explorer/src/workspaces/VocabularyWorkspace/queries.ts +52 -0
  101. package/explorer/src/workspaces/VocabularyWorkspace/types.ts +24 -0
  102. package/package.json +31 -0
  103. package/plugins/.claude-plugin/README.md +262 -0
  104. package/plugins/.claude-plugin/marketplace.json +20 -0
  105. package/plugins/.claude-plugin/plugin.json +33 -0
  106. package/plugins/.cline-plugin/README.md +32 -0
  107. package/plugins/.cline-plugin/marketplace.json +17 -0
  108. package/plugins/.cline-plugin/plugin.json +35 -0
  109. package/plugins/.codex-plugin/marketplace.json +21 -0
  110. package/plugins/.codex-plugin/plugin.json +35 -0
  111. package/plugins/.continue-plugin/README.md +34 -0
  112. package/plugins/.continue-plugin/marketplace.json +17 -0
  113. package/plugins/.continue-plugin/plugin.json +33 -0
  114. package/plugins/.cursor-plugin/marketplace.json +18 -0
  115. package/plugins/.cursor-plugin/plugin.json +32 -0
  116. package/plugins/.openclaw-plugin/README.md +62 -0
  117. package/plugins/.openclaw-plugin/marketplace.json +18 -0
  118. package/plugins/.openclaw-plugin/plugin.json +46 -0
  119. package/plugins/.pi-plugin/README.md +35 -0
  120. package/plugins/.vscode-plugin/README.md +48 -0
  121. package/plugins/.vscode-plugin/marketplace.json +17 -0
  122. package/plugins/.vscode-plugin/plugin.json +35 -0
  123. package/plugins/.windsurf-plugin/README.md +39 -0
  124. package/plugins/.windsurf-plugin/marketplace.json +17 -0
  125. package/plugins/.windsurf-plugin/plugin.json +35 -0
  126. package/plugins/agents/decision-advisor.md +126 -0
  127. package/plugins/agents/explainability.md +129 -0
  128. package/plugins/agents/kg-assistant.md +73 -0
  129. package/plugins/hooks/hooks.json +12 -0
  130. package/plugins/skills/causal/SKILL.md +74 -0
  131. package/plugins/skills/change/SKILL.md +80 -0
  132. package/plugins/skills/decision/SKILL.md +197 -0
  133. package/plugins/skills/deduplicate/SKILL.md +41 -0
  134. package/plugins/skills/embed/SKILL.md +230 -0
  135. package/plugins/skills/explain/SKILL.md +44 -0
  136. package/plugins/skills/export/SKILL.md +67 -0
  137. package/plugins/skills/extract/SKILL.md +93 -0
  138. package/plugins/skills/ingest/SKILL.md +38 -0
  139. package/plugins/skills/ontology/SKILL.md +89 -0
  140. package/plugins/skills/policy/SKILL.md +66 -0
  141. package/plugins/skills/provenance/SKILL.md +70 -0
  142. package/plugins/skills/query/SKILL.md +84 -0
  143. package/plugins/skills/reason/SKILL.md +201 -0
  144. package/plugins/skills/temporal/SKILL.md +164 -0
  145. package/plugins/skills/validate/SKILL.md +228 -0
  146. package/plugins/skills/visualize/SKILL.md +249 -0
@@ -0,0 +1,164 @@
1
+ ---
2
+ name: temporal
3
+ description: Temporal graph operations on Alpha Semantic Hub — scoped queries at a point in time, graph snapshots, node change timelines, temporal causal analysis, and graph state reconstruction. Uses AgentContext.find_precedents(as_of=), ContextGraph.state_at(), CausalChainAnalyzer.trace_at_time(), and TemporalQueryRewriter. Sub-commands: query, snapshot, timeline, causal-at, precedents-at.
4
+ ---
5
+
6
+ # /alphasemantichub:temporal
7
+
8
+ Temporal graph operations. Usage: `/alphasemantichub:temporal <sub-command> [args]`
9
+
10
+ `$ARGUMENTS` = sub-command + query/node + date expression.
11
+
12
+ ---
13
+
14
+ ## `query "<question>" [at|before|after <date>]`
15
+
16
+ Temporally-scoped natural-language graph query.
17
+
18
+ ```python
19
+ from alphasemantichub.kg.temporal_query_rewriter import TemporalQueryRewriter
20
+ from alphasemantichub.kg.temporal_normalizer import TemporalNormalizer
21
+
22
+ normalizer = TemporalNormalizer()
23
+ # Normalize natural date expressions: "last month", "Q3 2024", "2025-01-15"
24
+ date = normalizer.normalize(date_expr)
25
+
26
+ rewriter = TemporalQueryRewriter()
27
+ # Rewrite query with temporal constraint
28
+ rewritten = rewriter.rewrite(
29
+ query=question,
30
+ temporal_constraint={"op": direction, "value": date}, # op: "at"|"before"|"after"
31
+ )
32
+ ```
33
+
34
+ Then run the rewritten query through `AgentContext.retrieve()` or `ContextGraph.query()`.
35
+
36
+ Return ranked results with `Valid From`, `Valid Until`, `Active At <date>` columns. Mark nodes that were not yet created at the target time as `[not yet created]`.
37
+
38
+ ---
39
+
40
+ ## `snapshot <date>`
41
+
42
+ Reconstruct the full graph state as it existed at a specific point in time.
43
+
44
+ ```python
45
+ from alphasemantichub.context import ContextGraph
46
+
47
+ graph = ContextGraph(advanced_analytics=True)
48
+
49
+ # state_at returns a dict snapshot of the graph at that timestamp
50
+ snapshot = graph.state_at(timestamp=date) # ISO string or datetime
51
+ ```
52
+
53
+ Output:
54
+ ```
55
+ Graph snapshot at <date>:
56
+ Nodes: N (M added since prev snapshot, K removed)
57
+ Edges: P
58
+ Density: 0.21
59
+ Communities: Q
60
+
61
+ Active decision categories at <date>:
62
+ | Category | Count | Avg Confidence |
63
+
64
+ Top 10 nodes (by degree at <date>):
65
+ | Node | Type | Degree |
66
+
67
+ [Compact Mermaid graph TD — top-10 most connected nodes at that time]
68
+ ```
69
+
70
+ ---
71
+
72
+ ## `timeline <node_id>`
73
+
74
+ Show attribute and relationship changes for a node across its full history.
75
+
76
+ ```python
77
+ from alphasemantichub.context import ContextGraph
78
+
79
+ graph = ContextGraph()
80
+
81
+ # Use state_at() at multiple time points to reconstruct history
82
+ # Check add_node timestamps and edge addition times from graph data
83
+ node_data = graph.find_node(node_id)
84
+ ```
85
+
86
+ Output as Markdown timeline:
87
+ ```
88
+ Timeline for "<node_id>" (<type>):
89
+
90
+ <timestamp> CREATED
91
+ Properties: {confidence: 0.71, category: "loan_approval"}
92
+ Source: extraction/pipeline
93
+
94
+ <timestamp> UPDATED
95
+ confidence: 0.71 → 0.91 [source: review]
96
+
97
+ <timestamp> RELATIONSHIP ADDED
98
+ "<node_id>" →[CAUSED]→ "Decision_B"
99
+
100
+ <timestamp> RELATIONSHIP REMOVED
101
+ "<node_id>" →[PRECEDED_BY]→ "Decision_X" (superseded)
102
+
103
+ Total lifespan: <duration>
104
+ Current state: <active|superseded>
105
+ ```
106
+
107
+ ---
108
+
109
+ ## `causal-at <decision_id> <date> [--direction upstream|downstream]`
110
+
111
+ Trace a causal chain as it existed at a specific point in time.
112
+
113
+ ```python
114
+ from alphasemantichub.context.causal_analyzer import CausalChainAnalyzer
115
+ from alphasemantichub.context import AgentContext
116
+
117
+ ctx = AgentContext(decision_tracking=True)
118
+ analyzer = CausalChainAnalyzer(graph_store=ctx.graph_store)
119
+
120
+ historical_chain = analyzer.trace_at_time(
121
+ event_id=decision_id,
122
+ at_time=date, # ISO string or datetime
123
+ direction=direction or "upstream",
124
+ max_depth=10,
125
+ )
126
+ ```
127
+
128
+ Output:
129
+ ```
130
+ Historical causal chain for <decision_id> at <date>:
131
+ Direction: upstream (what caused it?)
132
+
133
+ [Mermaid graph TD showing chain as it existed at <date>]
134
+
135
+ Decisions present then but not now: [list]
136
+ Decisions added since then: [list]
137
+ ```
138
+
139
+ ---
140
+
141
+ ## `precedents-at "<scenario>" <date> [--category <cat>]`
142
+
143
+ Find precedent decisions that existed as of a specific date — useful for auditing what context was available when a decision was made.
144
+
145
+ ```python
146
+ from alphasemantichub.context import AgentContext
147
+
148
+ ctx = AgentContext(decision_tracking=True, advanced_analytics=True)
149
+
150
+ # find_precedents supports as_of parameter for temporal precedent search
151
+ precedents = ctx.find_precedents(
152
+ scenario=scenario,
153
+ category=category or None,
154
+ limit=10,
155
+ use_hybrid_search=True,
156
+ include_context=True,
157
+ include_superseded=False,
158
+ as_of=date, # Only return precedents that existed at this date
159
+ )
160
+ ```
161
+
162
+ Return: `| Rank | Decision ID | Scenario | Outcome | Confidence | Set Date | Valid Until |`
163
+
164
+ Note decisions that were superseded before or after the target date.
@@ -0,0 +1,228 @@
1
+ ---
2
+ name: validate
3
+ description: Validate Alpha Semantic Hub pipelines, extraction quality, graph schemas, and ontology consistency. Returns structured error/warning checklists. Uses PipelineValidator, PipelineBuilder.validate_pipeline(), GraphValidator, and OntologyValidator. Sub-commands: pipeline, step, dependencies, extraction, graph, ontology, performance.
4
+ ---
5
+
6
+ # /alphasemantichub:validate
7
+
8
+ Validate pipeline and graph quality. Usage: `/alphasemantichub:validate <target> [options]`
9
+
10
+ `$ARGUMENTS` = target type + optional config or path.
11
+
12
+ ---
13
+
14
+ ## `pipeline [--config '<json>']`
15
+
16
+ Validate a full pipeline builder configuration.
17
+
18
+ ```python
19
+ from alphasemantichub.pipeline.pipeline_builder import PipelineBuilder
20
+ from alphasemantichub.pipeline.pipeline_validator import PipelineValidator
21
+
22
+ builder = PipelineBuilder()
23
+ if config_json:
24
+ import json
25
+ builder.build_pipeline(json.loads(config_json))
26
+
27
+ # PipelineBuilder has its own quick validate
28
+ quick = builder.validate_pipeline() # returns Dict
29
+
30
+ # PipelineValidator gives full ValidationResult(valid, errors, warnings)
31
+ # Does NOT raise — always returns a result object
32
+ validator = PipelineValidator()
33
+ result = validator.validate(builder)
34
+
35
+ # Also check inter-step dependencies
36
+ deps = validator.check_dependencies(builder)
37
+ ```
38
+
39
+ Output:
40
+ ```
41
+ Pipeline Validation: VALID ✓ | INVALID ✗
42
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
43
+ Steps: N registered
44
+ Valid: M steps
45
+
46
+ Errors (K):
47
+ ✗ [step_name] <error message>
48
+
49
+ Warnings (J):
50
+ ⚠ [step_name] <warning message>
51
+
52
+ Dependencies:
53
+ ✓ All dependencies resolved
54
+ ✗ Step "<name>" depends on missing step "<dep>"
55
+
56
+ Result: <valid> — K errors, J warnings
57
+ ```
58
+
59
+ ---
60
+
61
+ ## `step <step_name> [--type <type>] [--constraints '<json>']`
62
+
63
+ Validate a single pipeline step.
64
+
65
+ ```python
66
+ from alphasemantichub.pipeline.pipeline_builder import PipelineBuilder
67
+ from alphasemantichub.pipeline.pipeline_validator import PipelineValidator
68
+ import json
69
+
70
+ builder = PipelineBuilder()
71
+ step = builder.get_step(step_name)
72
+
73
+ validator = PipelineValidator()
74
+ result = validator.validate_step(
75
+ step=step,
76
+ **json.loads(constraints_json) if constraints_json else {},
77
+ )
78
+ ```
79
+
80
+ Output: same checklist format but scoped to a single step.
81
+
82
+ ---
83
+
84
+ ## `dependencies`
85
+
86
+ Check all inter-step dependency resolution for the active pipeline.
87
+
88
+ ```python
89
+ from alphasemantichub.pipeline.pipeline_builder import PipelineBuilder
90
+ from alphasemantichub.pipeline.pipeline_validator import PipelineValidator
91
+
92
+ builder = PipelineBuilder()
93
+ validator = PipelineValidator()
94
+
95
+ deps = validator.check_dependencies(builder)
96
+ ```
97
+
98
+ Output:
99
+ ```
100
+ Dependency Graph:
101
+ | Step | Depends On | Status |
102
+ | step_A | — | ✓ |
103
+ | step_B | step_A | ✓ |
104
+ | step_C | step_X | ✗ MISSING |
105
+
106
+ Cycles detected: YES / NO
107
+ Missing steps: [list]
108
+ ```
109
+
110
+ ---
111
+
112
+ ## `extraction <file_path>`
113
+
114
+ Validate extraction quality for a file — entity confidence, relation density, coverage.
115
+
116
+ ```python
117
+ from alphasemantichub.semantic_extract.extraction_validator import ExtractionValidator
118
+ from alphasemantichub.semantic_extract import (
119
+ NamedEntityRecognizer,
120
+ RelationExtractor,
121
+ )
122
+ from alphasemantichub.semantic_extract.cache import extraction_cache
123
+
124
+ extraction_cache.clear() # prevent cross-invocation cache pollution
125
+
126
+ text = open(file_path).read()
127
+
128
+ ner = NamedEntityRecognizer()
129
+ rel = RelationExtractor()
130
+ entities = ner.extract(text)
131
+ relations = rel.extract(text)
132
+
133
+ validator = ExtractionValidator()
134
+ issues = validator.validate(entities, relations)
135
+ ```
136
+
137
+ Output:
138
+ ```
139
+ Extraction Validation: <file_path>
140
+ Entities: N extracted
141
+ Relations: M extracted
142
+ Avg confidence: 0.83
143
+
144
+ Errors (K):
145
+ ✗ <issue>
146
+
147
+ Warnings (J):
148
+ ⚠ <warning>
149
+
150
+ Quality score: X/100
151
+ ```
152
+
153
+ ---
154
+
155
+ ## `graph`
156
+
157
+ Check schema conformance, referential integrity, and structural health.
158
+
159
+ ```python
160
+ from alphasemantichub.kg.graph_validator import GraphValidator
161
+ from alphasemantichub.context import ContextGraph
162
+
163
+ graph = ContextGraph()
164
+ validator = GraphValidator(graph)
165
+ result = validator.validate()
166
+ ```
167
+
168
+ Output:
169
+ ```
170
+ Graph Validation:
171
+ Nodes: N | Edges: M
172
+ Node types: K valid, J unknown
173
+
174
+ Referential integrity:
175
+ ✗ Dangling edge: <source> → <missing target>
176
+
177
+ Schema conformance:
178
+ ✗ Node "<id>" missing required property "<prop>"
179
+
180
+ Result: N errors, M warnings
181
+ ```
182
+
183
+ ---
184
+
185
+ ## `ontology`
186
+
187
+ Validate ontology consistency and evaluate competency questions.
188
+
189
+ ```python
190
+ from alphasemantichub.ontology import OntologyValidator
191
+
192
+ validator = OntologyValidator()
193
+ result = validator.validate()
194
+ cq_results = validator.evaluate_competency_questions()
195
+ ```
196
+
197
+ Output:
198
+ ```
199
+ Ontology Validation:
200
+ Classes: N
201
+ Properties: M
202
+ Consistent: YES ✓ | NO ✗
203
+
204
+ Competency questions:
205
+ ✓ "Can we find all instances of X?" — answered
206
+ ✗ "Is Y a subclass of Z?" — failed: <reason>
207
+
208
+ Result: N consistency errors, M CQ failures
209
+ ```
210
+
211
+ ---
212
+
213
+ ## `performance`
214
+
215
+ Validate pipeline performance characteristics — bottlenecks, parallelism, and resource use.
216
+
217
+ ```python
218
+ from alphasemantichub.pipeline.pipeline_builder import PipelineBuilder
219
+ from alphasemantichub.pipeline.pipeline_validator import PipelineValidator
220
+
221
+ builder = PipelineBuilder()
222
+ pipeline = builder.build()
223
+ validator = PipelineValidator()
224
+
225
+ perf = validator.validate_performance(pipeline)
226
+ ```
227
+
228
+ Output: step-by-step timing estimates, parallelism opportunities, and recommended parallelism level.
@@ -0,0 +1,249 @@
1
+ ---
2
+ name: visualize
3
+ description: Visualize the Alpha Semantic Hub knowledge graph — topology, centrality, communities, paths, embeddings, decision insights, and temporal evolution. Uses GraphAnalyzer, CentralityCalculator, CommunityDetector, PathFinder, and ContextGraph analytics. Sub-commands: topology, centrality, community, path, decision-graph, insights, temporal, embedding.
4
+ ---
5
+
6
+ # /alphasemantichub:visualize
7
+
8
+ Render graph visualizations as Mermaid, ASCII, or structured Markdown. Usage: `/alphasemantichub:visualize <sub-command> [args]`
9
+
10
+ `$ARGUMENTS` = sub-command + optional node label or filter.
11
+
12
+ ---
13
+
14
+ ## `topology [--filter <node_type>]`
15
+
16
+ Full graph structure analysis — node types, edge distribution, connectivity metrics.
17
+
18
+ ```python
19
+ from alphasemantichub.kg.graph_analyzer import GraphAnalyzer
20
+ from alphasemantichub.context import ContextGraph
21
+
22
+ graph = ContextGraph(advanced_analytics=True)
23
+ analyzer = GraphAnalyzer()
24
+
25
+ # Comprehensive analysis
26
+ analysis = analyzer.analyze_graph(graph=graph.to_dict())
27
+ metrics = analyzer.compute_metrics(graph=graph)
28
+ connectivity = analyzer.analyze_connectivity(graph=graph)
29
+ ```
30
+
31
+ Output:
32
+ ```
33
+ Graph Topology:
34
+ Nodes: N (M types)
35
+ Edges: P
36
+ Density: 0.23
37
+ Avg degree: 4.7
38
+ Connected: YES / NO (K components)
39
+
40
+ Node type distribution:
41
+ [Mermaid pie chart]
42
+ | Type | Count | % | Avg Degree |
43
+
44
+ Top-10 connected nodes:
45
+ | Node | Type | Degree | Betweenness |
46
+ ```
47
+
48
+ ---
49
+
50
+ ## `centrality [--type degree|betweenness|closeness|eigenvector|pagerank|all] [--top N]`
51
+
52
+ Calculate and rank nodes by centrality.
53
+
54
+ ```python
55
+ from alphasemantichub.kg.centrality_calculator import CentralityCalculator
56
+ from alphasemantichub.context import ContextGraph
57
+
58
+ graph = ContextGraph()
59
+ calc = CentralityCalculator()
60
+
61
+ if centrality_type == "all" or not centrality_type:
62
+ scores = calc.calculate_all_centrality(graph=graph)
63
+ elif centrality_type == "degree":
64
+ scores = calc.calculate_degree_centrality(graph=graph)
65
+ elif centrality_type == "betweenness":
66
+ scores = calc.calculate_betweenness_centrality(graph=graph)
67
+ elif centrality_type == "closeness":
68
+ scores = calc.calculate_closeness_centrality(graph=graph)
69
+ elif centrality_type == "eigenvector":
70
+ scores = calc.calculate_eigenvector_centrality(graph=graph)
71
+ elif centrality_type == "pagerank":
72
+ scores = calc.calculate_pagerank(
73
+ graph=graph,
74
+ max_iterations=100,
75
+ damping_factor=0.85,
76
+ )
77
+ ```
78
+
79
+ Return: `| Rank | Node | Type | Degree | Betweenness | Closeness | Eigenvector | PageRank |`
80
+
81
+ For a single node, also call `ContextGraph.get_node_centrality(node_id)` and `get_node_importance(node_id)`.
82
+
83
+ ---
84
+
85
+ ## `community [--algorithm louvain|leiden|label-propagation|overlapping]`
86
+
87
+ Detect and visualize graph communities/clusters.
88
+
89
+ ```python
90
+ from alphasemantichub.kg.community_detector import CommunityDetector
91
+ from alphasemantichub.context import ContextGraph
92
+
93
+ graph = ContextGraph()
94
+ detector = CommunityDetector()
95
+
96
+ algorithm = algo_arg or "louvain"
97
+
98
+ if algorithm == "louvain":
99
+ result = detector.detect_communities_louvain(graph, resolution=1.0)
100
+ elif algorithm == "leiden":
101
+ result = detector.detect_communities_leiden(graph, resolution=1.0)
102
+ elif algorithm == "label-propagation":
103
+ result = detector.detect_communities_label_propagation(graph)
104
+ elif algorithm == "overlapping":
105
+ result = detector.detect_overlapping_communities(graph)
106
+ else:
107
+ result = detector.detect_communities(graph, algorithm=algorithm)
108
+
109
+ structure = detector.analyze_community_structure(graph, result)
110
+ metrics = detector.calculate_community_metrics(graph, result)
111
+ ```
112
+
113
+ Output:
114
+ ```
115
+ Community Detection (algorithm: louvain)
116
+ Communities: N
117
+ Modularity: 0.71
118
+
119
+ Community summary:
120
+ | ID | Size | Top Node | Internal Density | Bridge Nodes |
121
+
122
+ [Mermaid graph TD — nodes colored/grouped by community ID]
123
+ ```
124
+
125
+ ---
126
+
127
+ ## `path <n1> <n2> [--k N] [--algorithm bfs|dijkstra|astar|k-shortest]`
128
+
129
+ Find and visualize paths between two nodes.
130
+
131
+ ```python
132
+ from alphasemantichub.kg.path_finder import PathFinder
133
+ from alphasemantichub.context import ContextGraph
134
+
135
+ graph = ContextGraph()
136
+ finder = PathFinder()
137
+
138
+ k = int(k_arg) if k_arg else 3
139
+
140
+ if algorithm == "bfs":
141
+ path = finder.bfs_shortest_path(graph, source=n1, target=n2)
142
+ paths = [path]
143
+ elif algorithm == "dijkstra":
144
+ path = finder.dijkstra_shortest_path(graph, source=n1, target=n2)
145
+ paths = [path]
146
+ else: # default: k-shortest
147
+ paths = finder.find_k_shortest_paths(graph, source=n1, target=n2, k=k)
148
+
149
+ lengths = [finder.path_length(graph, p) for p in paths]
150
+ ```
151
+
152
+ Output as Mermaid `sequenceDiagram` for each path:
153
+ ```
154
+ Path 1 (length: 2.3):
155
+ n1 →[rel_type]→ Middle →[rel_type]→ n2
156
+
157
+ Path 2 (length: 3.7): ...
158
+ ```
159
+
160
+ ---
161
+
162
+ ## `decision-graph [--category <cat>] [--depth N]`
163
+
164
+ Visualize the decision influence graph for a category or all decisions.
165
+
166
+ ```python
167
+ from alphasemantichub.context import ContextGraph
168
+ from alphasemantichub.context.causal_analyzer import CausalChainAnalyzer
169
+ from alphasemantichub.context import AgentContext
170
+
171
+ ctx = AgentContext(decision_tracking=True, advanced_analytics=True)
172
+ graph = ContextGraph(advanced_analytics=True)
173
+
174
+ # Get decision insights
175
+ insights = graph.get_decision_insights()
176
+
177
+ # Build causal network
178
+ analyzer = CausalChainAnalyzer(graph_store=ctx.graph_store)
179
+ network = analyzer.analyze_causal_network()
180
+ ```
181
+
182
+ Output as Mermaid `graph TD` with:
183
+ - Node size proportional to causal impact score
184
+ - Color by outcome (green=approved, red=rejected, yellow=deferred)
185
+ - Edge labels showing relationship type
186
+
187
+ ---
188
+
189
+ ## `insights`
190
+
191
+ Comprehensive decision analytics dashboard.
192
+
193
+ ```python
194
+ from alphasemantichub.context import ContextGraph, AgentContext
195
+
196
+ ctx = AgentContext(decision_tracking=True, advanced_analytics=True, kg_algorithms=True)
197
+ graph = ContextGraph(advanced_analytics=True, centrality_analysis=True)
198
+
199
+ insights = graph.get_decision_insights()
200
+ summary = graph.get_decision_summary()
201
+ graph_summary = graph.get_graph_summary()
202
+ context_insights = ctx.get_context_insights()
203
+ ```
204
+
205
+ Output a full analytics dashboard:
206
+ ```
207
+ Decision Intelligence Dashboard
208
+ ════════════════════════════════
209
+ Decisions: N total (M active)
210
+ Categories: K unique
211
+ Avg confidence: 0.87
212
+ Outcome split: approved 55% | rejected 30% | deferred 15%
213
+ Causal chains: P chains, longest: Q hops
214
+ Loops detected: R circular dependencies
215
+
216
+ Graph health:
217
+ Nodes: N | Edges: M | Density: 0.23
218
+ Communities: K | Isolated nodes: J
219
+
220
+ [Mermaid pie — outcome distribution]
221
+ [Mermaid bar — decisions by category]
222
+ ```
223
+
224
+ ---
225
+
226
+ ## `temporal [--node <id>] [--start <date>] [--end <date>]`
227
+
228
+ Analyze how the graph evolved over time.
229
+
230
+ ```python
231
+ from alphasemantichub.kg.graph_analyzer import GraphAnalyzer
232
+ from alphasemantichub.context import ContextGraph
233
+
234
+ graph = ContextGraph()
235
+ analyzer = GraphAnalyzer()
236
+
237
+ evolution = analyzer.analyze_temporal_evolution(
238
+ graph=graph,
239
+ start_time=start_date or None,
240
+ end_time=end_date or None,
241
+ metrics=["node_count", "edge_count", "density", "communities"],
242
+ )
243
+
244
+ # For a specific node, use ContextGraph.state_at()
245
+ if node_id:
246
+ snapshot = graph.state_at(timestamp=end_date or "now")
247
+ ```
248
+
249
+ Output as Markdown timeline with metrics per interval.