一键导入
import-graph
Static import analysis that builds dependency graphs, domain clusters, hub files, git churn hotspots, and file priority rankings
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Static import analysis that builds dependency graphs, domain clusters, hub files, git churn hotspots, and file priority rankings
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when modifying imports, creating new files, refactoring modules, or understanding how components relate. Not needed for simple single-file edits.
LLM-powered injection of project context into installed agent templates via `aspens customize agents`
Core conventions, tech stack, and project structure for aspens
Claude/Codex CLI execution layer — prompt loading, stream-json parsing, file output extraction, path sanitization, skill file writing, and skill rule generation
Top-level Commander wiring, welcome screen, missing-hook warning, CliError exit handling, and the public programmatic API surface
Multi-target output system — target abstraction, backend routing, content transforms for Codex CLI and future targets
| name | import-graph |
| description | Static import analysis that builds dependency graphs, domain clusters, hub files, git churn hotspots, and file priority rankings |
| triggers | {"files":["src/lib/graph-builder.js","src/lib/graph-persistence.js","src/lib/parsers/**","src/commands/doc-graph.js","src/templates/hooks/graph-context-prompt.mjs"],"keywords":["graph","import-graph","hubs","clusters","hotspots","code-map","graph.json","subgraph","priority","fanIn"]} |
You are working on the import graph system — static analysis that parses JS/TS and Python source files to produce dependency graphs, plus persistence/query layers for runtime use.
The graph turns raw source into a queryable map of "what depends on what" so other aspens features (doc-init, doc-sync, doc-impact, the graph context hook) can rank files by importance, surface hubs, detect domain clusters, and inject just the relevant neighborhood into prompts. It is the substrate that makes context generation deterministic and code-aware rather than guess-based.
graph-builder.js — buildRepoGraph(repoPath, languages?) runs a 9-step pipeline:
graph-persistence.js — Persistence and query layer:
serializeGraph() converts raw graph to indexed format (O(1) lookups, file→cluster mapping)persistGraphArtifacts(repoPath, rawGraph, options?) writes .claude/graph.json + .claude/code-map.md + .claude/graph-index.json + auto-gitignores them. Target-aware: if options.target.supportsGraph === false, returns serialized data without writing files.extractSubgraph(graph, filePaths) returns 1-hop neighborhood of mentioned files + relevant hubs/hotspots/clustersformatNavigationContext(subgraph) renders compact markdown (~50 line budget) for prompt injectionextractFileReferences(prompt, graph) tiered extraction: explicit paths → bare filenames → cluster keywordsgenerateCodeMap() / writeCodeMap() standalone overview for graph hook consumption — emits a Domain clusters block (via formatDomainClusters) and framework entry points only; cross-domain coupling, hotspots, and the totals/date footer are intentionally omitted because they churn on every syncformatDomainClusters(clusters, files) — exported helper that renders the canonical Domain clusters block: clusters are merged by label, single-file clusters dropped, files per cluster capped at 5 and sorted by fanIn desc then path asc for sync stability; no per-cluster (N files) countsgenerateGraphIndex() / saveGraphIndex() tiny inverted index (export names → files, hub basenames, cluster labels)doc-graph.js — Target-aware: reads .aspens.json config, passes target to persistGraphArtifacts(). Shows different completion message for Codex target (artifacts not written).
await init before any parseJsImports call. es-module-lexer requires WASM initialization.fanIn * 3.0 + exportCount * 1.5 + (isEntry ? 10.0 : 0) + churn * 2.0 + (1/(depth+1)) * 1.0. Downstream consumers depend on this ranking.ensureGraphGitignore() (internal to persistence) adds .claude/graph.json, .claude/graph-index.json, .claude/code-map.md to prevent commit loops.supportsGraph: false, persistGraphArtifacts returns serialized data for embedding (e.g., condensed code-map in root AGENTS.md) but writes no files.extractSubgraph logic is mirrored in graph-context-prompt.mjs (buildNeighborhood()). Keep both in sync.buildRepoGraph + persistGraphArtifacts (with target) to keep it fresh.+N more suffixes. Anything that varies between syncs without a real code change must stay out of generated context.src/templates/hooks/graph-context-prompt.mjsLast Updated: 2026-05-11