@rkarim08/sia 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/.claude-plugin/marketplace.json +35 -0
- package/.claude-plugin/plugin.json +27 -0
- package/.mcp.json +13 -0
- package/CLAUDE.md +226 -0
- package/LICENSE +202 -0
- package/PLUGIN_README.md +253 -0
- package/README.md +1013 -0
- package/agents/sia-changelog-writer.md +89 -0
- package/agents/sia-code-reviewer.md +86 -0
- package/agents/sia-conflict-resolver.md +100 -0
- package/agents/sia-convention-enforcer.md +69 -0
- package/agents/sia-debug.md +106 -0
- package/agents/sia-decision-reviewer.md +101 -0
- package/agents/sia-dependency-tracker.md +80 -0
- package/agents/sia-explain.md +126 -0
- package/agents/sia-feature.md +116 -0
- package/agents/sia-knowledge-capture.md +117 -0
- package/agents/sia-lead-architecture-advisor.md +93 -0
- package/agents/sia-lead-team-health.md +107 -0
- package/agents/sia-migration.md +100 -0
- package/agents/sia-onboarding.md +115 -0
- package/agents/sia-orientation.md +99 -0
- package/agents/sia-pm-briefing.md +106 -0
- package/agents/sia-pm-risk-advisor.md +82 -0
- package/agents/sia-qa-analyst.md +116 -0
- package/agents/sia-qa-regression-map.md +94 -0
- package/agents/sia-refactor.md +115 -0
- package/agents/sia-regression.md +112 -0
- package/agents/sia-security-audit.md +125 -0
- package/agents/sia-test-advisor.md +91 -0
- package/hooks/hooks.json +98 -0
- package/migrations/bridge/001_initial.sql +34 -0
- package/migrations/episodic/001_initial.sql +35 -0
- package/migrations/meta/001_initial.sql +68 -0
- package/migrations/semantic/001_initial.sql +292 -0
- package/migrations/semantic/002_ontology.sql +89 -0
- package/migrations/semantic/003_freshness.sql +63 -0
- package/migrations/semantic/004_v5_unified_schema.sql +194 -0
- package/migrations/semantic/005_backfill_event_kinds.sql +8 -0
- package/migrations/semantic/006_tree_sitter.sql +6 -0
- package/migrations/semantic/007_branch_snapshots.sql +22 -0
- package/package.json +110 -0
- package/scripts/branch-switch.sh +13 -0
- package/scripts/build-wasm-grammars.sh +81 -0
- package/scripts/post-compact.sh +8 -0
- package/scripts/post-tool-use.sh +10 -0
- package/scripts/pre-compact.sh +8 -0
- package/scripts/session-end.sh +8 -0
- package/scripts/session-start.sh +8 -0
- package/scripts/start-mcp.ts +45 -0
- package/scripts/stop-hook.sh +8 -0
- package/scripts/user-prompt-submit.sh +8 -0
- package/scripts/viz-server.ts +152 -0
- package/skills/sia-brainstorm/SKILL.md +156 -0
- package/skills/sia-brainstorm/scripts/frame-template.html +214 -0
- package/skills/sia-brainstorm/scripts/helper.js +95 -0
- package/skills/sia-brainstorm/scripts/server.cjs +338 -0
- package/skills/sia-brainstorm/scripts/start-server.sh +153 -0
- package/skills/sia-brainstorm/scripts/stop-server.sh +55 -0
- package/skills/sia-brainstorm/spec-document-reviewer-prompt.md +49 -0
- package/skills/sia-brainstorm/visual-companion.md +286 -0
- package/skills/sia-capture/SKILL.md +64 -0
- package/skills/sia-compare/SKILL.md +33 -0
- package/skills/sia-conflicts/SKILL.md +38 -0
- package/skills/sia-debug-workflow/SKILL.md +120 -0
- package/skills/sia-debug-workflow/root-cause-tracing.md +70 -0
- package/skills/sia-debug-workflow/scripts/find-polluter.sh +64 -0
- package/skills/sia-debug-workflow/temporal-investigation.md +72 -0
- package/skills/sia-digest/SKILL.md +23 -0
- package/skills/sia-dispatch/SKILL.md +69 -0
- package/skills/sia-dispatch/agent-task-template.md +99 -0
- package/skills/sia-doctor/SKILL.md +39 -0
- package/skills/sia-execute/SKILL.md +70 -0
- package/skills/sia-execute-plan/SKILL.md +85 -0
- package/skills/sia-export-import/SKILL.md +49 -0
- package/skills/sia-export-knowledge/SKILL.md +46 -0
- package/skills/sia-finish/SKILL.md +100 -0
- package/skills/sia-finish/pr-summary-template.md +54 -0
- package/skills/sia-freshness/SKILL.md +38 -0
- package/skills/sia-history/SKILL.md +42 -0
- package/skills/sia-impact/SKILL.md +70 -0
- package/skills/sia-index/SKILL.md +54 -0
- package/skills/sia-install/SKILL.md +39 -0
- package/skills/sia-lead-compliance/SKILL.md +16 -0
- package/skills/sia-lead-drift-report/SKILL.md +16 -0
- package/skills/sia-lead-knowledge-map/SKILL.md +16 -0
- package/skills/sia-learn/SKILL.md +58 -0
- package/skills/sia-plan/SKILL.md +68 -0
- package/skills/sia-plan/plan-reviewer-prompt.md +63 -0
- package/skills/sia-playbooks/SKILL.md +29 -0
- package/skills/sia-playbooks/reference-feature.md +100 -0
- package/skills/sia-playbooks/reference-flagging.md +50 -0
- package/skills/sia-playbooks/reference-orientation.md +92 -0
- package/skills/sia-playbooks/reference-regression.md +115 -0
- package/skills/sia-playbooks/reference-review.md +64 -0
- package/skills/sia-playbooks/reference-tools.md +239 -0
- package/skills/sia-pm-decision-log/SKILL.md +28 -0
- package/skills/sia-pm-risk-dashboard/SKILL.md +24 -0
- package/skills/sia-pm-sprint-summary/SKILL.md +27 -0
- package/skills/sia-prune/SKILL.md +45 -0
- package/skills/sia-qa-coverage/SKILL.md +28 -0
- package/skills/sia-qa-flaky/SKILL.md +20 -0
- package/skills/sia-qa-report/SKILL.md +26 -0
- package/skills/sia-reindex/SKILL.md +30 -0
- package/skills/sia-review-respond/SKILL.md +88 -0
- package/skills/sia-review-respond/pushback-patterns.md +90 -0
- package/skills/sia-search/SKILL.md +47 -0
- package/skills/sia-setup/SKILL.md +82 -0
- package/skills/sia-setup/setup-checklist.md +97 -0
- package/skills/sia-stats/SKILL.md +36 -0
- package/skills/sia-status/SKILL.md +44 -0
- package/skills/sia-sync/SKILL.md +46 -0
- package/skills/sia-team/SKILL.md +64 -0
- package/skills/sia-test/SKILL.md +92 -0
- package/skills/sia-test/testing-anti-patterns.md +104 -0
- package/skills/sia-tour/SKILL.md +29 -0
- package/skills/sia-upgrade/SKILL.md +43 -0
- package/skills/sia-verify/SKILL.md +81 -0
- package/skills/sia-visualize/SKILL.md +28 -0
- package/skills/sia-visualize-live/SKILL.md +55 -0
- package/skills/sia-visualize-live/scripts/graph-template.html +389 -0
- package/skills/sia-visualize-live/scripts/start-visualizer.sh +161 -0
- package/skills/sia-visualize-live/scripts/stop-visualizer.sh +55 -0
- package/skills/sia-visualize-live/scripts/visualizer-server.cjs +264 -0
- package/skills/sia-workspace/SKILL.md +57 -0
- package/src/agent/claude-md-template-flagging.md +219 -0
- package/src/agent/claude-md-template.md +213 -0
- package/src/agent/modules/sia-feature.md +100 -0
- package/src/agent/modules/sia-flagging.md +50 -0
- package/src/agent/modules/sia-orientation.md +92 -0
- package/src/agent/modules/sia-regression.md +115 -0
- package/src/agent/modules/sia-review.md +64 -0
- package/src/agent/modules/sia-tools.md +239 -0
- package/src/ast/extractors/c-include.ts +189 -0
- package/src/ast/extractors/csharp-project.ts +260 -0
- package/src/ast/extractors/prisma-schema.ts +44 -0
- package/src/ast/extractors/project-manifest.ts +111 -0
- package/src/ast/extractors/sql-schema.ts +67 -0
- package/src/ast/extractors/tier-a.ts +423 -0
- package/src/ast/extractors/tier-b.ts +289 -0
- package/src/ast/extractors/tier-dispatch.ts +247 -0
- package/src/ast/index-worker.ts +108 -0
- package/src/ast/indexer.ts +484 -0
- package/src/ast/languages.ts +408 -0
- package/src/ast/pagerank-builder.ts +125 -0
- package/src/ast/path-utils.ts +137 -0
- package/src/ast/tree-sitter/backends/native.ts +57 -0
- package/src/ast/tree-sitter/backends/wasm.ts +39 -0
- package/src/ast/tree-sitter/call-walker.ts +44 -0
- package/src/ast/tree-sitter/edit-computer.ts +55 -0
- package/src/ast/tree-sitter/query-runner.ts +46 -0
- package/src/ast/tree-sitter/service.ts +174 -0
- package/src/ast/tree-sitter/tree-cache.ts +39 -0
- package/src/ast/tree-sitter/types.ts +79 -0
- package/src/ast/watcher.ts +322 -0
- package/src/capture/chunker.ts +169 -0
- package/src/capture/consolidate.ts +127 -0
- package/src/capture/edge-inferrer.ts +161 -0
- package/src/capture/embedder.ts +166 -0
- package/src/capture/embedding-cache.ts +73 -0
- package/src/capture/flag-processor.ts +64 -0
- package/src/capture/hook.ts +67 -0
- package/src/capture/pipeline.ts +450 -0
- package/src/capture/prompts/consolidate.ts +25 -0
- package/src/capture/prompts/edge-infer.ts +29 -0
- package/src/capture/prompts/extract-flagged.ts +36 -0
- package/src/capture/prompts/extract.ts +42 -0
- package/src/capture/tokenizer.ts +147 -0
- package/src/capture/track-a-ast.ts +93 -0
- package/src/capture/track-b-llm.ts +149 -0
- package/src/capture/types.ts +64 -0
- package/src/cli/commands/community.ts +137 -0
- package/src/cli/commands/compare.ts +123 -0
- package/src/cli/commands/conflicts.ts +41 -0
- package/src/cli/commands/digest.ts +197 -0
- package/src/cli/commands/disable-flagging.ts +34 -0
- package/src/cli/commands/doctor.ts +240 -0
- package/src/cli/commands/download-model.ts +161 -0
- package/src/cli/commands/enable-flagging.ts +34 -0
- package/src/cli/commands/export-knowledge.ts +208 -0
- package/src/cli/commands/export.ts +85 -0
- package/src/cli/commands/freshness.ts +164 -0
- package/src/cli/commands/graph.ts +51 -0
- package/src/cli/commands/history.ts +139 -0
- package/src/cli/commands/import.ts +335 -0
- package/src/cli/commands/install.ts +156 -0
- package/src/cli/commands/lead-report.ts +241 -0
- package/src/cli/commands/learn.ts +321 -0
- package/src/cli/commands/pm-report.ts +413 -0
- package/src/cli/commands/prune.ts +75 -0
- package/src/cli/commands/qa-report.ts +278 -0
- package/src/cli/commands/reindex.ts +104 -0
- package/src/cli/commands/rollback.ts +70 -0
- package/src/cli/commands/search.ts +103 -0
- package/src/cli/commands/server.ts +91 -0
- package/src/cli/commands/share.ts +33 -0
- package/src/cli/commands/stats.ts +79 -0
- package/src/cli/commands/status.ts +176 -0
- package/src/cli/commands/sync.ts +96 -0
- package/src/cli/commands/team.ts +118 -0
- package/src/cli/commands/tour.ts +157 -0
- package/src/cli/commands/visualize-live.ts +162 -0
- package/src/cli/commands/workspace.ts +117 -0
- package/src/cli/index.ts +424 -0
- package/src/cli/learn-progress.ts +87 -0
- package/src/community/detection-bridge.ts +344 -0
- package/src/community/leiden.ts +462 -0
- package/src/community/raptor.ts +210 -0
- package/src/community/scheduler.ts +74 -0
- package/src/community/summarize.ts +115 -0
- package/src/decay/archiver.ts +73 -0
- package/src/decay/bridge-orphan-cleanup.ts +212 -0
- package/src/decay/consolidation-sweep.ts +112 -0
- package/src/decay/decay.ts +116 -0
- package/src/decay/deep-validator.ts +62 -0
- package/src/decay/episodic-promoter.ts +132 -0
- package/src/decay/maintenance-scheduler.ts +326 -0
- package/src/decay/scheduler.ts +6 -0
- package/src/decay/session-sweeper.ts +79 -0
- package/src/decay/types.ts +17 -0
- package/src/freshness/confidence-decay.ts +122 -0
- package/src/freshness/cuckoo-filter.ts +176 -0
- package/src/freshness/deep-validation.ts +345 -0
- package/src/freshness/dirty-tracker.ts +237 -0
- package/src/freshness/file-watcher-layer.ts +119 -0
- package/src/freshness/firewall.ts +64 -0
- package/src/freshness/git-reconcile-layer.ts +161 -0
- package/src/freshness/inverted-index.ts +158 -0
- package/src/freshness/stale-read-layer.ts +222 -0
- package/src/graph/audit.ts +69 -0
- package/src/graph/bridge-db.ts +141 -0
- package/src/graph/communities.ts +195 -0
- package/src/graph/db-interface.ts +259 -0
- package/src/graph/edges.ts +163 -0
- package/src/graph/entities.ts +327 -0
- package/src/graph/episodic-db.ts +113 -0
- package/src/graph/flags.ts +31 -0
- package/src/graph/meta-db.ts +200 -0
- package/src/graph/semantic-db.ts +101 -0
- package/src/graph/session-resume.ts +56 -0
- package/src/graph/snapshots.ts +342 -0
- package/src/graph/staging.ts +151 -0
- package/src/graph/types.ts +128 -0
- package/src/hooks/adapters/claude-code.ts +21 -0
- package/src/hooks/adapters/cline.ts +43 -0
- package/src/hooks/adapters/cursor.ts +65 -0
- package/src/hooks/adapters/generic.ts +12 -0
- package/src/hooks/agent-detect.ts +34 -0
- package/src/hooks/claude-md-directives.ts +32 -0
- package/src/hooks/event-router.ts +182 -0
- package/src/hooks/extractors/pattern-detector.ts +111 -0
- package/src/hooks/handlers/post-compact.ts +30 -0
- package/src/hooks/handlers/post-tool-use.ts +403 -0
- package/src/hooks/handlers/pre-compact.ts +100 -0
- package/src/hooks/handlers/session-end.ts +47 -0
- package/src/hooks/handlers/session-start.ts +154 -0
- package/src/hooks/handlers/stop.ts +128 -0
- package/src/hooks/handlers/user-prompt-submit.ts +68 -0
- package/src/hooks/plugin-branch-switch.ts +68 -0
- package/src/hooks/plugin-common.ts +47 -0
- package/src/hooks/plugin-post-compact.ts +28 -0
- package/src/hooks/plugin-post-tool-use.ts +38 -0
- package/src/hooks/plugin-pre-compact.ts +37 -0
- package/src/hooks/plugin-session-end.ts +37 -0
- package/src/hooks/plugin-session-start.ts +75 -0
- package/src/hooks/plugin-stop.ts +61 -0
- package/src/hooks/plugin-user-prompt-submit.ts +47 -0
- package/src/hooks/types.ts +43 -0
- package/src/knowledge/discovery.ts +238 -0
- package/src/knowledge/external-refs.ts +98 -0
- package/src/knowledge/freshness.ts +221 -0
- package/src/knowledge/ingest.ts +330 -0
- package/src/knowledge/markdown-export.ts +229 -0
- package/src/knowledge/markdown-import.ts +359 -0
- package/src/knowledge/patterns.ts +74 -0
- package/src/knowledge/templates.ts +307 -0
- package/src/llm/ai-sdk-adapter.ts +46 -0
- package/src/llm/config.ts +88 -0
- package/src/llm/cost-tracker.ts +110 -0
- package/src/llm/prompts/extraction.ts +55 -0
- package/src/llm/prompts/summarization.ts +36 -0
- package/src/llm/prompts/validation.ts +37 -0
- package/src/llm/provider-registry.ts +68 -0
- package/src/llm/reliability.ts +179 -0
- package/src/llm/schemas.ts +52 -0
- package/src/mcp/freshness-annotator.ts +69 -0
- package/src/mcp/server.ts +949 -0
- package/src/mcp/tools/sia-ast-query.ts +225 -0
- package/src/mcp/tools/sia-at-time.ts +151 -0
- package/src/mcp/tools/sia-backlinks.ts +87 -0
- package/src/mcp/tools/sia-batch-execute.ts +169 -0
- package/src/mcp/tools/sia-by-file.ts +89 -0
- package/src/mcp/tools/sia-community.ts +113 -0
- package/src/mcp/tools/sia-doctor.ts +73 -0
- package/src/mcp/tools/sia-execute-file.ts +122 -0
- package/src/mcp/tools/sia-execute.ts +104 -0
- package/src/mcp/tools/sia-expand.ts +158 -0
- package/src/mcp/tools/sia-fetch-and-index.ts +241 -0
- package/src/mcp/tools/sia-flag.ts +65 -0
- package/src/mcp/tools/sia-index.ts +111 -0
- package/src/mcp/tools/sia-note.ts +134 -0
- package/src/mcp/tools/sia-search.ts +105 -0
- package/src/mcp/tools/sia-stats.ts +63 -0
- package/src/mcp/tools/sia-sync-status.ts +44 -0
- package/src/mcp/tools/sia-upgrade.ts +247 -0
- package/src/mcp/truncate.ts +231 -0
- package/src/native/bridge.ts +167 -0
- package/src/native/fallback-ast-diff.ts +144 -0
- package/src/native/fallback-graph.ts +325 -0
- package/src/ontology/constraints.ts +56 -0
- package/src/ontology/errors.ts +8 -0
- package/src/ontology/middleware.ts +266 -0
- package/src/retrieval/bm25-search.ts +151 -0
- package/src/retrieval/context-assembly.ts +76 -0
- package/src/retrieval/graph-traversal.ts +168 -0
- package/src/retrieval/pagerank.ts +40 -0
- package/src/retrieval/query-classifier.ts +106 -0
- package/src/retrieval/reranker.ts +156 -0
- package/src/retrieval/search.ts +236 -0
- package/src/retrieval/throttle.ts +102 -0
- package/src/retrieval/vector-search.ts +203 -0
- package/src/retrieval/workspace-search.ts +130 -0
- package/src/sandbox/context-mode.ts +285 -0
- package/src/sandbox/credential-pass.ts +55 -0
- package/src/sandbox/executor.ts +235 -0
- package/src/security/pattern-detector.ts +127 -0
- package/src/security/rule-of-two.ts +50 -0
- package/src/security/sanitize.ts +46 -0
- package/src/security/semantic-consistency.ts +93 -0
- package/src/security/staging-promoter.ts +154 -0
- package/src/shared/config.ts +302 -0
- package/src/shared/diagnostics.ts +210 -0
- package/src/shared/errors.ts +48 -0
- package/src/shared/git-utils.ts +143 -0
- package/src/shared/llm-client.ts +120 -0
- package/src/shared/logger.ts +99 -0
- package/src/shared/types.ts +79 -0
- package/src/sync/client.ts +43 -0
- package/src/sync/conflict.ts +106 -0
- package/src/sync/dedup.ts +183 -0
- package/src/sync/hlc.ts +117 -0
- package/src/sync/keychain.ts +144 -0
- package/src/sync/pull.ts +232 -0
- package/src/sync/push.ts +131 -0
- package/src/types/chokidar.d.ts +23 -0
- package/src/visualization/graph-renderer.ts +312 -0
- package/src/visualization/subgraph-extract.ts +208 -0
- package/src/visualization/views/community-clusters.ts +246 -0
- package/src/visualization/views/dependency-map.ts +189 -0
- package/src/visualization/views/graph-explorer.ts +364 -0
- package/src/visualization/views/timeline.ts +247 -0
- package/src/workspace/api-contracts.ts +226 -0
- package/src/workspace/cross-repo.ts +61 -0
- package/src/workspace/detector.ts +190 -0
- package/src/workspace/manifest.ts +141 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
// Module: community-clusters — Generate community cluster view HTML with D3.js
|
|
2
|
+
//
|
|
3
|
+
// Grouped force layout where communities are visually clustered with
|
|
4
|
+
// colored convex hull boundaries. Clicking a community shows its members.
|
|
5
|
+
|
|
6
|
+
export interface CommunityData {
|
|
7
|
+
communities: Array<{
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
level: number;
|
|
11
|
+
summary: string;
|
|
12
|
+
memberCount: number;
|
|
13
|
+
}>;
|
|
14
|
+
members: Array<{
|
|
15
|
+
entityId: string;
|
|
16
|
+
communityId: string;
|
|
17
|
+
entityName: string;
|
|
18
|
+
entityType: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function escapeHtml(s: string): string {
|
|
23
|
+
return s
|
|
24
|
+
.replace(/&/g, "&")
|
|
25
|
+
.replace(/</g, "<")
|
|
26
|
+
.replace(/>/g, ">")
|
|
27
|
+
.replace(/"/g, """);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Generate a self-contained HTML page showing community clusters with hull boundaries.
|
|
32
|
+
*/
|
|
33
|
+
export function generateCommunityClusterHtml(data: CommunityData): string {
|
|
34
|
+
const pageTitle = "SIA Community Clusters";
|
|
35
|
+
const communitiesJson = JSON.stringify(data.communities);
|
|
36
|
+
const membersJson = JSON.stringify(data.members);
|
|
37
|
+
|
|
38
|
+
return `<!DOCTYPE html>
|
|
39
|
+
<html lang="en">
|
|
40
|
+
<head>
|
|
41
|
+
<meta charset="UTF-8">
|
|
42
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
43
|
+
<title>${escapeHtml(pageTitle)}</title>
|
|
44
|
+
<style>
|
|
45
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
46
|
+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #1a1a2e; color: #e0e0e0; overflow: hidden; }
|
|
47
|
+
#cluster-container { width: 100vw; height: 100vh; }
|
|
48
|
+
svg { width: 100%; height: 100%; }
|
|
49
|
+
.title-bar { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 10; font-size: 18px; font-weight: 600; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
|
|
50
|
+
.stats { font-size: 11px; color: #888; text-align: center; margin-top: 2px; }
|
|
51
|
+
.panel { position: fixed; top: 16px; right: 16px; z-index: 10; background: #2a2a4a; border: 1px solid #444; border-radius: 8px; padding: 16px; max-width: 340px; max-height: 80vh; overflow-y: auto; display: none; }
|
|
52
|
+
.panel.visible { display: block; }
|
|
53
|
+
.panel h2 { font-size: 16px; margin-bottom: 4px; color: #fff; }
|
|
54
|
+
.panel p { font-size: 12px; color: #aaa; margin-bottom: 8px; }
|
|
55
|
+
.panel .member-list { list-style: none; }
|
|
56
|
+
.panel .member-list li { font-size: 12px; color: #ccc; padding: 3px 0; border-bottom: 1px solid #333; }
|
|
57
|
+
.panel .member-type { font-size: 10px; color: #888; margin-left: 6px; }
|
|
58
|
+
path.hull { fill-opacity: 0.12; stroke-width: 2; stroke-opacity: 0.5; cursor: pointer; }
|
|
59
|
+
path.hull:hover { fill-opacity: 0.2; stroke-opacity: 0.8; }
|
|
60
|
+
circle.member-node { stroke: #fff; stroke-width: 1; cursor: pointer; }
|
|
61
|
+
circle.member-node:hover { stroke-width: 2.5; }
|
|
62
|
+
text.member-label { font-size: 9px; fill: #aaa; pointer-events: none; text-anchor: middle; }
|
|
63
|
+
text.community-label { font-size: 13px; font-weight: 600; fill: #fff; pointer-events: none; text-anchor: middle; text-shadow: 0 1px 3px rgba(0,0,0,0.7); }
|
|
64
|
+
</style>
|
|
65
|
+
</head>
|
|
66
|
+
<body>
|
|
67
|
+
<div class="title-bar">
|
|
68
|
+
<div>${escapeHtml(pageTitle)}</div>
|
|
69
|
+
<div class="stats" id="stats"></div>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="panel" id="detail-panel">
|
|
72
|
+
<h2 id="panel-name"></h2>
|
|
73
|
+
<p id="panel-summary"></p>
|
|
74
|
+
<ul class="member-list" id="panel-members"></ul>
|
|
75
|
+
</div>
|
|
76
|
+
<div id="cluster-container"></div>
|
|
77
|
+
<script src="https://d3js.org/d3.v7.min.js"></script>
|
|
78
|
+
<script>
|
|
79
|
+
(function() {
|
|
80
|
+
var communities = ${communitiesJson};
|
|
81
|
+
var members = ${membersJson};
|
|
82
|
+
|
|
83
|
+
document.getElementById("stats").textContent =
|
|
84
|
+
communities.length + " communities, " + members.length + " members";
|
|
85
|
+
|
|
86
|
+
var colors = d3.scaleOrdinal(d3.schemeTableau10);
|
|
87
|
+
var width = window.innerWidth;
|
|
88
|
+
var height = window.innerHeight;
|
|
89
|
+
|
|
90
|
+
// Build member nodes with community assignment
|
|
91
|
+
var membersByCommunity = {};
|
|
92
|
+
communities.forEach(function(c) { membersByCommunity[c.id] = []; });
|
|
93
|
+
members.forEach(function(m) {
|
|
94
|
+
if (!membersByCommunity[m.communityId]) membersByCommunity[m.communityId] = [];
|
|
95
|
+
membersByCommunity[m.communityId].push(m);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Create nodes for simulation
|
|
99
|
+
var nodes = members.map(function(m) {
|
|
100
|
+
return { id: m.entityId, name: m.entityName, type: m.entityType, communityId: m.communityId };
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Community centers for clustering force
|
|
104
|
+
var commCenters = {};
|
|
105
|
+
var angle = 0;
|
|
106
|
+
var radius = Math.min(width, height) * 0.25;
|
|
107
|
+
communities.forEach(function(c, i) {
|
|
108
|
+
angle = (2 * Math.PI * i) / Math.max(communities.length, 1);
|
|
109
|
+
commCenters[c.id] = { x: width / 2 + radius * Math.cos(angle), y: height / 2 + radius * Math.sin(angle) };
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
var svg = d3.select("#cluster-container")
|
|
113
|
+
.append("svg")
|
|
114
|
+
.attr("width", width)
|
|
115
|
+
.attr("height", height);
|
|
116
|
+
|
|
117
|
+
var g = svg.append("g");
|
|
118
|
+
|
|
119
|
+
var zoom = d3.zoom()
|
|
120
|
+
.scaleExtent([0.1, 8])
|
|
121
|
+
.on("zoom", function(event) { g.attr("transform", event.transform); });
|
|
122
|
+
svg.call(zoom);
|
|
123
|
+
|
|
124
|
+
// Clustering force
|
|
125
|
+
var simulation = d3.forceSimulation(nodes)
|
|
126
|
+
.force("charge", d3.forceManyBody().strength(-60))
|
|
127
|
+
.force("collision", d3.forceCollide().radius(12))
|
|
128
|
+
.force("x", d3.forceX(function(d) { return (commCenters[d.communityId] || {x: width/2}).x; }).strength(0.3))
|
|
129
|
+
.force("y", d3.forceY(function(d) { return (commCenters[d.communityId] || {y: height/2}).y; }).strength(0.3));
|
|
130
|
+
|
|
131
|
+
// Hull layer
|
|
132
|
+
var hullG = g.append("g");
|
|
133
|
+
// Node layer
|
|
134
|
+
var nodeG = g.append("g");
|
|
135
|
+
// Label layer
|
|
136
|
+
var labelG = g.append("g");
|
|
137
|
+
// Community name layer
|
|
138
|
+
var commLabelG = g.append("g");
|
|
139
|
+
|
|
140
|
+
var nodeElements = nodeG.selectAll("circle").data(nodes).join("circle")
|
|
141
|
+
.attr("class", "member-node")
|
|
142
|
+
.attr("r", 7)
|
|
143
|
+
.attr("fill", function(d) { return colors(d.communityId); })
|
|
144
|
+
.on("click", function(event, d) { showCommunityDetail(d.communityId); })
|
|
145
|
+
.call(d3.drag()
|
|
146
|
+
.on("start", function(event, d) {
|
|
147
|
+
if (!event.active) simulation.alphaTarget(0.3).restart();
|
|
148
|
+
d.fx = d.x; d.fy = d.y;
|
|
149
|
+
})
|
|
150
|
+
.on("drag", function(event, d) { d.fx = event.x; d.fy = event.y; })
|
|
151
|
+
.on("end", function(event, d) {
|
|
152
|
+
if (!event.active) simulation.alphaTarget(0);
|
|
153
|
+
d.fx = null; d.fy = null;
|
|
154
|
+
}));
|
|
155
|
+
|
|
156
|
+
var memberLabels = labelG.selectAll("text").data(nodes).join("text")
|
|
157
|
+
.attr("class", "member-label")
|
|
158
|
+
.text(function(d) { return d.name.length > 15 ? d.name.slice(0, 13) + "..." : d.name; })
|
|
159
|
+
.attr("dy", 18);
|
|
160
|
+
|
|
161
|
+
// Convex hull computation
|
|
162
|
+
function computeHulls() {
|
|
163
|
+
var hulls = [];
|
|
164
|
+
communities.forEach(function(c) {
|
|
165
|
+
var pts = [];
|
|
166
|
+
nodes.forEach(function(n) {
|
|
167
|
+
if (n.communityId === c.id && n.x != null && n.y != null) {
|
|
168
|
+
// Add padding points for a rounder hull
|
|
169
|
+
pts.push([n.x - 15, n.y - 15]);
|
|
170
|
+
pts.push([n.x + 15, n.y - 15]);
|
|
171
|
+
pts.push([n.x - 15, n.y + 15]);
|
|
172
|
+
pts.push([n.x + 15, n.y + 15]);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
if (pts.length >= 6) { // need at least 3 original points (6 padded)
|
|
176
|
+
hulls.push({ id: c.id, name: c.name, path: d3.polygonHull(pts) });
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return hulls;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
simulation.on("tick", function() {
|
|
183
|
+
nodeElements.attr("cx", function(d) { return d.x; }).attr("cy", function(d) { return d.y; });
|
|
184
|
+
memberLabels.attr("x", function(d) { return d.x; }).attr("y", function(d) { return d.y; });
|
|
185
|
+
|
|
186
|
+
// Update hulls
|
|
187
|
+
var hulls = computeHulls();
|
|
188
|
+
var hullPaths = hullG.selectAll("path.hull").data(hulls, function(d) { return d.id; });
|
|
189
|
+
hullPaths.enter().append("path")
|
|
190
|
+
.attr("class", "hull")
|
|
191
|
+
.attr("fill", function(d) { return colors(d.id); })
|
|
192
|
+
.attr("stroke", function(d) { return colors(d.id); })
|
|
193
|
+
.on("click", function(event, d) { showCommunityDetail(d.id); })
|
|
194
|
+
.merge(hullPaths)
|
|
195
|
+
.attr("d", function(d) {
|
|
196
|
+
return d.path ? "M" + d.path.map(function(p) { return p.join(","); }).join("L") + "Z" : "";
|
|
197
|
+
});
|
|
198
|
+
hullPaths.exit().remove();
|
|
199
|
+
|
|
200
|
+
// Update community labels at hull centers
|
|
201
|
+
var commLabels = commLabelG.selectAll("text.community-label")
|
|
202
|
+
.data(hulls, function(d) { return d.id; });
|
|
203
|
+
commLabels.enter().append("text")
|
|
204
|
+
.attr("class", "community-label")
|
|
205
|
+
.merge(commLabels)
|
|
206
|
+
.text(function(d) { return d.name; })
|
|
207
|
+
.attr("x", function(d) {
|
|
208
|
+
if (!d.path) return 0;
|
|
209
|
+
return d3.mean(d.path, function(p) { return p[0]; });
|
|
210
|
+
})
|
|
211
|
+
.attr("y", function(d) {
|
|
212
|
+
if (!d.path) return 0;
|
|
213
|
+
return d3.mean(d.path, function(p) { return p[1]; }) - 20;
|
|
214
|
+
});
|
|
215
|
+
commLabels.exit().remove();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// Detail panel
|
|
219
|
+
function showCommunityDetail(communityId) {
|
|
220
|
+
var comm = communities.find(function(c) { return c.id === communityId; });
|
|
221
|
+
if (!comm) return;
|
|
222
|
+
var panel = document.getElementById("detail-panel");
|
|
223
|
+
panel.classList.add("visible");
|
|
224
|
+
document.getElementById("panel-name").textContent = comm.name;
|
|
225
|
+
document.getElementById("panel-summary").textContent = comm.summary;
|
|
226
|
+
|
|
227
|
+
var memberList = document.getElementById("panel-members");
|
|
228
|
+
// Clear existing members safely
|
|
229
|
+
while (memberList.firstChild) memberList.removeChild(memberList.firstChild);
|
|
230
|
+
|
|
231
|
+
var communityMembers = membersByCommunity[communityId] || [];
|
|
232
|
+
communityMembers.forEach(function(m) {
|
|
233
|
+
var li = document.createElement("li");
|
|
234
|
+
li.textContent = m.entityName;
|
|
235
|
+
var typeSpan = document.createElement("span");
|
|
236
|
+
typeSpan.className = "member-type";
|
|
237
|
+
typeSpan.textContent = m.entityType;
|
|
238
|
+
li.appendChild(typeSpan);
|
|
239
|
+
memberList.appendChild(li);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
})();
|
|
243
|
+
</script>
|
|
244
|
+
</body>
|
|
245
|
+
</html>`;
|
|
246
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// Module: dependency-map — Generate file dependency map HTML with D3.js
|
|
2
|
+
//
|
|
3
|
+
// Hierarchical force-directed graph showing file-level dependencies
|
|
4
|
+
// (imports/calls edges). Directional arrows show dependency direction.
|
|
5
|
+
|
|
6
|
+
import type { SubgraphData } from "@/visualization/subgraph-extract";
|
|
7
|
+
|
|
8
|
+
const TYPE_COLORS: Record<string, string> = {
|
|
9
|
+
FileNode: "#4A90D9",
|
|
10
|
+
CodeEntity: "#4A90D9",
|
|
11
|
+
PackageNode: "#E67E22",
|
|
12
|
+
Decision: "#5DB85D",
|
|
13
|
+
Convention: "#5DB85D",
|
|
14
|
+
Bug: "#E74C3C",
|
|
15
|
+
Solution: "#2ECC71",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const DEFAULT_COLOR = "#95A5A6";
|
|
19
|
+
|
|
20
|
+
function escapeHtml(s: string): string {
|
|
21
|
+
return s
|
|
22
|
+
.replace(/&/g, "&")
|
|
23
|
+
.replace(/</g, "<")
|
|
24
|
+
.replace(/>/g, ">")
|
|
25
|
+
.replace(/"/g, """);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Generate a self-contained HTML page showing file dependency relationships.
|
|
30
|
+
*/
|
|
31
|
+
export function generateDependencyMapHtml(
|
|
32
|
+
data: SubgraphData,
|
|
33
|
+
opts?: { rootFile?: string },
|
|
34
|
+
): string {
|
|
35
|
+
const pageTitle = opts?.rootFile ? `Dependencies: ${opts.rootFile}` : "SIA Dependency Map";
|
|
36
|
+
const nodesJson = JSON.stringify(data.nodes);
|
|
37
|
+
const edgesJson = JSON.stringify(data.edges);
|
|
38
|
+
const typeColorsJson = JSON.stringify(TYPE_COLORS);
|
|
39
|
+
const rootFile = opts?.rootFile ?? "";
|
|
40
|
+
|
|
41
|
+
return `<!DOCTYPE html>
|
|
42
|
+
<html lang="en">
|
|
43
|
+
<head>
|
|
44
|
+
<meta charset="UTF-8">
|
|
45
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
46
|
+
<title>${escapeHtml(pageTitle)}</title>
|
|
47
|
+
<style>
|
|
48
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
49
|
+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #1a1a2e; color: #e0e0e0; overflow: hidden; }
|
|
50
|
+
#dep-container { width: 100vw; height: 100vh; }
|
|
51
|
+
svg { width: 100%; height: 100%; }
|
|
52
|
+
.title-bar { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 10; font-size: 18px; font-weight: 600; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
|
|
53
|
+
.stats { font-size: 11px; color: #888; text-align: center; margin-top: 2px; }
|
|
54
|
+
.tooltip { position: absolute; background: #2a2a4a; border: 1px solid #444; border-radius: 6px; padding: 10px 14px; font-size: 12px; color: #e0e0e0; pointer-events: none; opacity: 0; transition: opacity 0.15s; z-index: 20; max-width: 300px; }
|
|
55
|
+
line.dep-edge { stroke-opacity: 0.5; }
|
|
56
|
+
line.dep-edge:hover { stroke-opacity: 0.9; }
|
|
57
|
+
circle.dep-node { cursor: pointer; stroke: #fff; stroke-width: 1.5; }
|
|
58
|
+
circle.dep-node:hover { stroke-width: 3; }
|
|
59
|
+
circle.dep-node.root { stroke: #e94560; stroke-width: 3; }
|
|
60
|
+
text.dep-label { font-size: 10px; fill: #ccc; pointer-events: none; text-anchor: middle; }
|
|
61
|
+
marker { fill: #888; }
|
|
62
|
+
</style>
|
|
63
|
+
</head>
|
|
64
|
+
<body>
|
|
65
|
+
<div class="title-bar">
|
|
66
|
+
<div>${escapeHtml(pageTitle)}</div>
|
|
67
|
+
<div class="stats" id="stats"></div>
|
|
68
|
+
</div>
|
|
69
|
+
<div class="tooltip" id="tooltip"></div>
|
|
70
|
+
<div id="dep-container"></div>
|
|
71
|
+
<script src="https://d3js.org/d3.v7.min.js"></script>
|
|
72
|
+
<script>
|
|
73
|
+
(function() {
|
|
74
|
+
var rawNodes = ${nodesJson};
|
|
75
|
+
var rawEdges = ${edgesJson};
|
|
76
|
+
var typeColors = ${typeColorsJson};
|
|
77
|
+
var defaultColor = "${DEFAULT_COLOR}";
|
|
78
|
+
var rootFile = "${escapeHtml(rootFile)}";
|
|
79
|
+
|
|
80
|
+
document.getElementById("stats").textContent =
|
|
81
|
+
rawNodes.length + " files, " + rawEdges.length + " dependencies";
|
|
82
|
+
|
|
83
|
+
var nodes = rawNodes.map(function(n) { return Object.assign({}, n); });
|
|
84
|
+
var edges = rawEdges.map(function(e) {
|
|
85
|
+
return Object.assign({}, e, { source: e.from_id, target: e.to_id });
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
var nodeById = new Map();
|
|
89
|
+
nodes.forEach(function(n) { nodeById.set(n.id, n); });
|
|
90
|
+
edges = edges.filter(function(e) { return nodeById.has(e.source) && nodeById.has(e.target); });
|
|
91
|
+
|
|
92
|
+
var width = window.innerWidth;
|
|
93
|
+
var height = window.innerHeight;
|
|
94
|
+
|
|
95
|
+
var svg = d3.select("#dep-container")
|
|
96
|
+
.append("svg")
|
|
97
|
+
.attr("width", width)
|
|
98
|
+
.attr("height", height);
|
|
99
|
+
|
|
100
|
+
// Arrow marker for directed edges
|
|
101
|
+
svg.append("defs").append("marker")
|
|
102
|
+
.attr("id", "arrow")
|
|
103
|
+
.attr("viewBox", "0 -5 10 10")
|
|
104
|
+
.attr("refX", 20)
|
|
105
|
+
.attr("refY", 0)
|
|
106
|
+
.attr("markerWidth", 6)
|
|
107
|
+
.attr("markerHeight", 6)
|
|
108
|
+
.attr("orient", "auto")
|
|
109
|
+
.append("path")
|
|
110
|
+
.attr("d", "M0,-5L10,0L0,5")
|
|
111
|
+
.attr("fill", "#888");
|
|
112
|
+
|
|
113
|
+
var g = svg.append("g");
|
|
114
|
+
|
|
115
|
+
var zoom = d3.zoom()
|
|
116
|
+
.scaleExtent([0.1, 8])
|
|
117
|
+
.on("zoom", function(event) { g.attr("transform", event.transform); });
|
|
118
|
+
svg.call(zoom);
|
|
119
|
+
|
|
120
|
+
var simulation = d3.forceSimulation(nodes)
|
|
121
|
+
.force("link", d3.forceLink(edges).id(function(d) { return d.id; }).distance(120))
|
|
122
|
+
.force("charge", d3.forceManyBody().strength(-300))
|
|
123
|
+
.force("center", d3.forceCenter(width / 2, height / 2))
|
|
124
|
+
.force("collision", d3.forceCollide().radius(20));
|
|
125
|
+
|
|
126
|
+
function nodeRadius(d) { return 6 + (d.importance || 0.5) * 12; }
|
|
127
|
+
function nodeColor(d) { return typeColors[d.type] || defaultColor; }
|
|
128
|
+
|
|
129
|
+
var edgeElements = g.append("g").selectAll("line").data(edges).join("line")
|
|
130
|
+
.attr("class", "dep-edge")
|
|
131
|
+
.attr("stroke", "#556")
|
|
132
|
+
.attr("stroke-width", 1.5)
|
|
133
|
+
.attr("marker-end", "url(#arrow)");
|
|
134
|
+
|
|
135
|
+
var nodeElements = g.append("g").selectAll("circle").data(nodes).join("circle")
|
|
136
|
+
.attr("class", function(d) {
|
|
137
|
+
return "dep-node" + (rootFile && d.name === rootFile ? " root" : "");
|
|
138
|
+
})
|
|
139
|
+
.attr("r", nodeRadius)
|
|
140
|
+
.attr("fill", nodeColor)
|
|
141
|
+
.call(d3.drag()
|
|
142
|
+
.on("start", function(event, d) {
|
|
143
|
+
if (!event.active) simulation.alphaTarget(0.3).restart();
|
|
144
|
+
d.fx = d.x; d.fy = d.y;
|
|
145
|
+
})
|
|
146
|
+
.on("drag", function(event, d) { d.fx = event.x; d.fy = event.y; })
|
|
147
|
+
.on("end", function(event, d) {
|
|
148
|
+
if (!event.active) simulation.alphaTarget(0);
|
|
149
|
+
d.fx = null; d.fy = null;
|
|
150
|
+
}));
|
|
151
|
+
|
|
152
|
+
var labelElements = g.append("g").selectAll("text").data(nodes).join("text")
|
|
153
|
+
.attr("class", "dep-label")
|
|
154
|
+
.text(function(d) {
|
|
155
|
+
var name = d.name;
|
|
156
|
+
// Show just filename for paths
|
|
157
|
+
var parts = name.split("/");
|
|
158
|
+
var short = parts[parts.length - 1];
|
|
159
|
+
return short.length > 20 ? short.slice(0, 18) + "..." : short;
|
|
160
|
+
})
|
|
161
|
+
.attr("dy", function(d) { return nodeRadius(d) + 14; });
|
|
162
|
+
|
|
163
|
+
var tooltipEl = document.getElementById("tooltip");
|
|
164
|
+
|
|
165
|
+
nodeElements.on("mouseover", function(event, d) {
|
|
166
|
+
tooltipEl.textContent = d.name + " (" + d.type + ")";
|
|
167
|
+
tooltipEl.style.opacity = 1;
|
|
168
|
+
tooltipEl.style.left = (event.pageX + 12) + "px";
|
|
169
|
+
tooltipEl.style.top = (event.pageY - 10) + "px";
|
|
170
|
+
}).on("mouseout", function() { tooltipEl.style.opacity = 0; });
|
|
171
|
+
|
|
172
|
+
simulation.on("tick", function() {
|
|
173
|
+
edgeElements
|
|
174
|
+
.attr("x1", function(d) { return d.source.x; })
|
|
175
|
+
.attr("y1", function(d) { return d.source.y; })
|
|
176
|
+
.attr("x2", function(d) { return d.target.x; })
|
|
177
|
+
.attr("y2", function(d) { return d.target.y; });
|
|
178
|
+
nodeElements
|
|
179
|
+
.attr("cx", function(d) { return d.x; })
|
|
180
|
+
.attr("cy", function(d) { return d.y; });
|
|
181
|
+
labelElements
|
|
182
|
+
.attr("x", function(d) { return d.x; })
|
|
183
|
+
.attr("y", function(d) { return d.y; });
|
|
184
|
+
});
|
|
185
|
+
})();
|
|
186
|
+
</script>
|
|
187
|
+
</body>
|
|
188
|
+
</html>`;
|
|
189
|
+
}
|