@cognitap/galactica

中文文档
0.2.3发布于 2026/11/07MITES Module构建来源已验证近 30 天下载 2487

Trace JavaScript and TypeScript imports, find the tests a change can affect, and explore the dependency graph offline.

原始使用文档
文档目录4 节
  1. Quick start
  2. Use it with a coding agent
  3. CLI
  4. Agent benchmark

Galactica

Galactica maps imports in JavaScript and TypeScript repositories. Browse the dependency graph in an offline HTML file, or use the CLI to find what a change affects and which tests cover it.

Three layers of Immich’s web app. The selected side-bar area depends on modals, and layouts depends on side-bar.

Quick start

Requires Node.js 24.1.0 or newer. From a project you trust, open a dependency map with one command.

npx @cognitap/galactica html --open

Galactica writes galactica.html in the current directory and opens it in your browser. Select a folder to see its modules, or select a file to trace what it imports and what depends on it. The map is a single HTML file you can share or open offline.

For regular use, install the CLI globally and run the same commands as galactica.

npm install -g @cognitap/galactica
galactica html --open

To inspect an unfamiliar checkout, run Galactica from a trusted directory and pass --root /path/to/checkout. How Galactica reads repositories safely

Use it with a coding agent

Run npx @cognitap/galactica init in your own repository (or galactica init after a global install) to install the skill for Codex, Claude Code and Cursor. Ask your agent which files and tests a change could affect. The skill uses the same import graph as the HTML map and points the agent toward feature-name searches for tests loaded at runtime.

CLI

CommandWhat it shows
overviewPackages, areas and dependency layers
where <name>Definitions of a named symbol
outline <file>A file’s exports and signatures
uses <file>Importers and tests that reach the file
deps <file>The file’s dependencies
cyclesImport cycles and where to break them
healthCycles, oversized areas and cross-package private imports

Add --json for structured output. Test reach follows imports, so tests that load code at runtime may need a separate search. Command reference · Configuration

Agent benchmark

We ran six tasks on Hono, Vite and NestJS with Sonnet and Opus. The clearest benefit came when agents had to name the tests that exercise an edited file in Hono or Vite.

Share of required tests named on those two tasksWithout GalacticaInstructed to use the skill
Sonnet47%78%
Opus82%100%

The Hono task shows why following imports matters. Four adapter tests reach the edited function through a package import. Opus missed all four on each baseline run. With the skill instruction, it named all 12 required tests on every run.

All three conditions scored 100% on the other four tasks. Across all six, instructing the models to use Galactica increased average cost per run by 7% for Sonnet and 17% for Opus. The study covered 144 runs, four per task, model and condition. Grading checked edits statically and gave credit for required tests named. Extra tests carried no penalty, and the target test suites were never executed. Full results, method and limitations

The map was inspired by codemap. MIT licensed.

版本与发布记录

@cognitap/galactica 共发布 12 个版本,首次发布于 2026/11/05;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.3latest2026/11/073 天前
0.2.22026/11/073 天前
0.2.12026/11/073 天前
0.2.02026/11/073 天前
0.1.62026/11/064 天前
0.1.52026/11/064 天前

关于 @cognitap/galactica 的常见问题

@cognitap/galactica 是什么?

Trace JavaScript and TypeScript imports, find the tests a change can affect, and explore the dependency graph offline.

如何安装 @cognitap/galactica?

在项目目录运行 npm install @cognitap/galactica,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 galactica,可以用 npx galactica 直接运行。

@cognitap/galactica 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cognitap__galactica 是否存在。

@cognitap/galactica 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cognitap/galactica 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24.1.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cognitap/galactica 可以商用吗?

@cognitap/galactica 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cognitap/galactica 的下载量有多少?

根据 npm 官方下载统计,@cognitap/galactica 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,487 次,日均约 83 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cognitap/galactica 还在维护吗?

最新版本 0.2.3 发布于 2026/11/07(3 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/11/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。