semantic-atlas 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -1,82 +1,135 @@
1
- # Semantic Atlas
1
+ <div align="center">
2
+ <h1>Semantic Atlas</h1>
3
+ <p><strong>A local, evidence-bound world map for AI coding agents.</strong></p>
4
+ <p>Connect code structure to verified business meaning, then keep both revision-aware.</p>
2
5
 
3
- Semantic Atlas is a local, revision-aware project world model for AI coding agents. It combines CodeGraph-backed TypeScript and JavaScript structure with agent-verified business capabilities, flows, data, rules, and interfaces in one evidence-bound map.
6
+ <p>
7
+ <a href="https://www.npmjs.com/package/semantic-atlas"><img alt="npm version" src="https://img.shields.io/npm/v/semantic-atlas?style=flat-square&color=cb3837"></a>
8
+ <a href="https://github.com/lzj960515/semantic-atlas/actions/workflows/ci.yml"><img alt="continuous integration" src="https://img.shields.io/github/actions/workflow/status/lzj960515/semantic-atlas/ci.yml?branch=main&style=flat-square&label=ci"></a>
9
+ <a href="https://www.npmjs.com/package/semantic-atlas"><img alt="supported Node.js version" src="https://img.shields.io/node/v/semantic-atlas?style=flat-square&color=43853d"></a>
10
+ <a href="./LICENSE"><img alt="MIT license" src="https://img.shields.io/github/license/lzj960515/semantic-atlas?style=flat-square&color=2d5b46"></a>
11
+ </p>
4
12
 
5
- Semantic Atlas is an AI-agent tool, not a natural-language engine. The deterministic CLI accepts commands, lexical search terms, graph identifiers, and structured GraphPatch input. The calling agent interprets a task, judges evidence, reads source when the map is insufficient, and performs all code and Git work.
13
+ <p><strong>English</strong> · <a href="./README.zh-CN.md">简体中文</a></p>
14
+ </div>
6
15
 
7
- ## Requirements
16
+ ## What is Semantic Atlas?
8
17
 
9
- - Node.js 22.12 through 24
10
- - A Git worktree containing TypeScript or JavaScript
11
- - Codex or another agent that can follow the packaged Skill workflow
18
+ Semantic Atlas gives coding agents one local map that joins two kinds of project knowledge:
12
19
 
13
- ## Install the CLI
20
+ - **Structural evidence** from TypeScript and JavaScript: files, symbols, relations, framework entry points, and unresolved boundaries.
21
+ - **Agent-verified business knowledge**: capabilities, scenarios, operations, interfaces, data, rules, tests, and the evidence that supports them.
14
22
 
15
- Install the public executable globally:
23
+ The `semantic-atlas` CLI provides deterministic, versioned JSON operations. The packaged Codex Skill teaches an agent when to query, when to return to source, and when verified knowledge should be retained. The embedded CodeGraph SDK is an internal structural backend, not a second product or workflow.
24
+
25
+ > **Query first. Confirm in source. Learn only what the evidence proves.**
26
+
27
+ Source code remains authoritative. Atlas is a revision-aware projection that makes useful context reusable without pretending static analysis knows every runtime behavior.
28
+
29
+ ## Why use it?
30
+
31
+ - **Start from business meaning.** Find the capability, operation, data, and dependency path before opening a broad slice of the repository.
32
+ - **Spend less source context.** Use graph evidence to choose a bounded source seed set, then read only the code needed to decide the task.
33
+ - **Keep knowledge honest.** Evidence is tied to a snapshot; changed or missing evidence becomes visibly stale instead of silently remaining current.
34
+ - **Preserve uncertainty.** Dynamic dispatch, reflection, unsupported structure, and unresolved targets stay explicit and route the agent back to source.
35
+ - **Leave the project untouched.** Generated state stays inside the worktree's ignored `.atlas/` directory; tracked source and configuration are not rewritten.
36
+
37
+ ## One project world map
38
+
39
+ ![Semantic Atlas capability map showing structural evidence, business knowledge, the Agent loop, one unified world map, explicit uncertainty, and local storage](docs/mindmaps/semantic-atlas-overview.png)
40
+
41
+ The overview is an editable draw.io mind map: [open the English source](docs/mindmaps/semantic-atlas-overview.drawio). The [Simplified Chinese source](docs/mindmaps/semantic-atlas-overview.zh-CN.drawio) is maintained alongside its localized image.
42
+
43
+ ## Quick start
44
+
45
+ Semantic Atlas supports Node.js 22.12 through 24 and Git worktrees containing TypeScript or JavaScript.
46
+
47
+ ### Install the CLI
16
48
 
17
49
  ```sh
18
50
  npm install --global semantic-atlas
19
51
  semantic-atlas status --repo /path/to/project
20
52
  ```
21
53
 
22
- The installed runtime works offline. Indexing, graph queries, evidence validation, and change inspection do not call a model or a network service. Package installation itself still requires normal npm registry access.
54
+ After installation, indexing and queries run locally without model or network calls. npm registry access is needed only to install the package.
23
55
 
24
- ## Install the Codex Skill
56
+ ### Install the Codex Skill
25
57
 
26
- The Skill teaches Codex when to trust the map, when to reindex, how to preserve unknown boundaries, and when to fall back to authoritative source. In Codex, invoke the built-in installer with the repository-owned Skill URL:
58
+ Install the Skill from the repository's current `main` branch:
27
59
 
28
60
  ```text
29
- $skill-installer Install semantic-atlas from https://github.com/lzj960515/semantic-atlas/tree/v0.1.0/.agents/skills/semantic-atlas
61
+ $skill-installer Install semantic-atlas from https://github.com/lzj960515/semantic-atlas/tree/main/.agents/skills/semantic-atlas
30
62
  ```
31
63
 
32
- For repository development, Codex discovers the checked-in Skill automatically from `.agents/skills/semantic-atlas`. Codex detects newly installed skills automatically; restart Codex if it does not appear in the skill list.
33
-
34
- Invoke it explicitly with `$semantic-atlas`, or let Codex select it for project understanding and impact-analysis tasks.
64
+ Codex can then select `$semantic-atlas` from the task description, or you can invoke it explicitly. Repository contributors already get the checked-in Skill from `.agents/skills/semantic-atlas`.
35
65
 
36
- ## First use
66
+ ### Run the first query
37
67
 
38
- Run these commands from the target worktree. `--repo <path>` can be supplied before the command when the current directory is elsewhere.
68
+ Run commands serially from the exact target worktree:
39
69
 
40
70
  ```sh
41
71
  semantic-atlas status
42
72
  semantic-atlas index
43
73
  semantic-atlas map roots
44
- semantic-atlas map search checkout --limit 10
74
+ semantic-atlas map search "checkout" --limit 10
45
75
  semantic-atlas map show module:src --depth 1
46
76
  ```
47
77
 
48
- The normal agent loop is:
78
+ Every command writes one versioned JSON envelope to standard output. Diagnostics stay on standard error, so agents consume stable fields and warning codes instead of scraping prose.
49
79
 
50
- 1. Check `status` before trusting stored knowledge.
51
- 2. Run `index` when the snapshot is missing, stale, failed, or incomplete.
52
- 3. Use `map roots`, `map search`, `map children`, and `map show` for bounded context.
53
- 4. Inspect source for stale, unsupported, unresolved, ambiguous, or insufficient results.
54
- 5. After source changes, reindex and inspect `changes`.
55
- 6. Submit verified business knowledge with `learn --stdin` against the current snapshot.
80
+ ## The Agent loop
56
81
 
57
- Every command writes one versioned JSON envelope to standard output. Diagnostics remain on standard error, so callers can parse output without scraping prose.
82
+ 1. **Status.** Confirm the exact repository root, snapshot freshness, and structural-backend completeness before broad source discovery.
83
+ 2. **Index.** Publish or refresh the worktree-local snapshot when state is missing, stale, failed, or incomplete.
84
+ 3. **Query.** Search compact business and symbol vocabulary, then traverse only the promising nodes and relationships.
85
+ 4. **Confirm source.** Open the cited ranges and resolve the decisive behavior in authoritative code. Keep partial, stale, unsupported, and unknown results bounded.
86
+ 5. **Do the engineering work.** The calling agent edits code, runs tests, reviews diffs, and owns Git; Atlas performs none of those actions.
87
+ 6. **Reconcile and learn.** Reindex after relevant source changes, inspect semantic `changes`, and submit only durable, verified business knowledge through `learn --stdin`. Verify learned nodes with `map show`.
58
88
 
59
- ## Zero-intrusion storage
89
+ This loop grows the business map one verified capability at a time. It does not attempt to convert the whole repository into speculative documentation.
60
90
 
61
- Each worktree owns one generated store:
91
+ ## Measured results
62
92
 
63
- ```text
64
- <worktree>/.atlas/codegraph.db
65
- ```
93
+ ### Frozen comparative evaluation
66
94
 
67
- Semantic Atlas creates an Atlas-owned `.atlas/.gitignore`, keeps transient locks and SQLite sidecars under `.atlas/`, and leaves tracked source and project configuration unchanged. CodeGraph owns structural tables while Atlas owns namespaced `atlas_*` business, evidence, snapshot, and validity tables in the same database. Public queries compose one world graph without copying the structural graph.
95
+ The retained [`fresh-agent-v1` report](evaluation/results/fresh-agent-v1/report.json) covers `framework-evaluation@fixture-v1`: 12 paired cases and 24 fresh-agent runs across NestJS, GraphQL, TypeORM, and BullMQ location and dependency-impact tasks.
68
96
 
69
- ## Scope and uncertainty
97
+ | Metric | Without Atlas | With Atlas | Fixture result |
98
+ | --- | ---: | ---: | --- |
99
+ | Final-answer correctness | 100% | 100% | No regression |
100
+ | Required-file recall | 100% | 100% | No regression |
101
+ | Required-symbol recall | 100% | 100% | No regression |
102
+ | Median unique source files opened | 6.5 | 4 | 38.46% fewer |
103
+ | Median observed source-input tokens | 1,351 | 688 | 49.07% fewer |
70
104
 
71
- v0.1 supports TypeScript and JavaScript, with initial business-flow coverage for NestJS, GraphQL, TypeORM, and BullMQ projects. The embedded `@colbymchenry/codegraph` SDK supplies static structure; Atlas adds revision-aware business interpretation and evidence.
105
+ The gate was declared before collection and all 61 routed uncertainty events were handled without a failure classification. Read the [evaluation methodology](docs/evaluation.md) and retained runs before interpreting the numbers.
72
106
 
73
- Runtime-only dispatch, reflection, generated behavior, unsupported syntax, and unresolved targets remain explicit boundaries. An `UnknownBoundary`, stale assertion, hypothesis, or unsupported result is a prompt for bounded source inspection, never an exact business claim. Source code remains authoritative.
107
+ These are fixture-scoped comparative results. They do **not** establish universal business accuracy, performance on every repository, or total model-token savings; the token metric counts observed source input under `tiktoken-o200k_base-v1`.
74
108
 
75
- Semantic Atlas does not edit source, run project tests, mutate Git history, review code, or publish releases on behalf of the calling agent.
109
+ ### Public-artifact dogfood
76
110
 
77
- ## CLI reference
111
+ The separate [v0.1.1 release](https://github.com/lzj960515/semantic-atlas/releases/tag/v0.1.1) dogfood used only the public npm CLI and tagged Skill in an isolated `pietra-ex-api` worktree:
78
112
 
79
- ```sh
113
+ - A first fresh agent completed `missing → index → query → source confirmation → learn`: indexing took 6.52 seconds, published 42,789 facts, and created a 40,308,736-byte database. One atomic learning operation added 4 business nodes and 8 relations in 0.71 seconds; every learned node was then `valid`.
114
+ - A second fresh agent discovered and reused that knowledge through normal `status`, search, roots, and show commands without receiving the previous answer or repeating `learn`.
115
+ - The target revision and ordinary Git status stayed unchanged; generated state existed only in ignored `.atlas/` storage.
116
+
117
+ That run also exposed precision and discoverability backlog: one natural multi-term query missed a learned node in its top ten, a framework-adjacent `map show` result was too large, 27,060 reported unknown boundaries lacked useful candidates or priority, and source inspection found one false exact same-name link. The dogfood is operational evidence and a source of limitations, not another accuracy benchmark or a production-stability claim.
118
+
119
+ ## Evidence, uncertainty, and storage
120
+
121
+ | Boundary | Contract |
122
+ | --- | --- |
123
+ | Source authority | Every answer-controlling claim is confirmed in source; Atlas context never overrides the checked-out code. |
124
+ | Evidence validity | Business assertions carry source locators, hashes, certainty, and snapshot-derived validity. Failed rebinding produces `stale`, not silent deletion or promotion. |
125
+ | Explicit uncertainty | `UnknownBoundary`, `partial`, `unsupported`, `hypothesis`, and insufficient results narrow source fallback; they are never presented as exact facts. |
126
+ | One product | The CLI and Skill expose one Semantic Atlas workflow. CodeGraph stays behind the adapter and its CLI, MCP, schema, and backend types are not public Atlas interfaces. |
127
+ | One local store | Each worktree owns `.atlas/codegraph.db`: CodeGraph owns structural tables and Atlas owns namespaced `atlas_*` knowledge, evidence, snapshot, and validity tables. |
128
+ | Zero intrusion | Atlas prepares `.atlas/.gitignore`, writes no tracked source or project configuration, and does not edit, test, review, commit, merge, or release code. |
129
+
130
+ ## CLI and development
131
+
132
+ ```text
80
133
  semantic-atlas status [--repo <path>] [--pretty]
81
134
  semantic-atlas index [--repo <path>] [--pretty]
82
135
  semantic-atlas map roots [--repo <path>] [--pretty]
@@ -87,9 +140,7 @@ semantic-atlas learn --stdin [--repo <path>] [--pretty]
87
140
  semantic-atlas changes [--from <snapshot-id>] [--to <snapshot-id>] [--repo <path>] [--pretty]
88
141
  ```
89
142
 
90
- See the versioned [CLI contract](docs/contracts/cli-v1.md) and [GraphPatch contract](docs/contracts/graph-patch-v1.md) for field-level behavior.
91
-
92
- ## Development
143
+ Field-level behavior lives in the versioned [CLI v1](docs/contracts/cli-v1.md) and [GraphPatch v1](docs/contracts/graph-patch-v1.md) contracts.
93
144
 
94
145
  ```sh
95
146
  corepack enable
@@ -100,18 +151,15 @@ pnpm build
100
151
  pnpm package:verify
101
152
  ```
102
153
 
103
- `pnpm package:verify` packs the project, installs the tarball into a temporary consumer outside the checkout, and runs a real `status` -> `index` -> `map roots` CLI flow while checking that the fixture Git status stays clean. `pnpm validation:backend` provides the deeper pinned-backend and upgrade contract.
154
+ `package:verify` installs the packed artifact into an external temporary consumer and runs the real CLI. `validation:backend` adds the pinned CodeGraph coexistence, upgrade, preservation, recovery, rebinding, and worktree-isolation gate.
104
155
 
105
- CI runs typecheck, build, contract checks, and installed-package tests on Node.js 22.12 and 24. The complete source test suite runs on the Node.js 24 development runtime, while Linux, macOS, and Windows jobs execute the installed CLI smoke flow.
106
-
107
- ## Contracts
156
+ ## Reference
108
157
 
109
158
  - [Product contract](docs/product-contract.md)
110
- - [CodeGraph backend architecture](docs/architecture/codegraph-backend.md)
111
159
  - [Graph model](docs/contracts/graph-model.md)
112
- - [CLI v1](docs/contracts/cli-v1.md)
113
- - [GraphPatch v1](docs/contracts/graph-patch-v1.md)
114
- - [Fresh Agent evaluation](docs/evaluation.md)
160
+ - [CodeGraph backend architecture](docs/architecture/codegraph-backend.md)
161
+ - [Fresh Agent evaluation protocol](docs/evaluation.md)
162
+ - [Published evaluation artifacts](evaluation/results/fresh-agent-v1/README.md)
115
163
 
116
164
  ## License
117
165
 
@@ -0,0 +1,166 @@
1
+ <div align="center">
2
+ <h1>Semantic Atlas</h1>
3
+ <p><strong>为 AI 编程 Agent 准备的本地、证据约束项目世界图。</strong></p>
4
+ <p>把代码结构连接到经过验证的业务含义,并让两者始终感知版本变化。</p>
5
+
6
+ <p>
7
+ <a href="https://www.npmjs.com/package/semantic-atlas"><img alt="npm 版本" src="https://img.shields.io/npm/v/semantic-atlas?style=flat-square&color=cb3837"></a>
8
+ <a href="https://github.com/lzj960515/semantic-atlas/actions/workflows/ci.yml"><img alt="持续集成" src="https://img.shields.io/github/actions/workflow/status/lzj960515/semantic-atlas/ci.yml?branch=main&style=flat-square&label=ci"></a>
9
+ <a href="https://www.npmjs.com/package/semantic-atlas"><img alt="支持的 Node.js 版本" src="https://img.shields.io/node/v/semantic-atlas?style=flat-square&color=43853d"></a>
10
+ <a href="./LICENSE"><img alt="MIT 许可证" src="https://img.shields.io/github/license/lzj960515/semantic-atlas?style=flat-square&color=2d5b46"></a>
11
+ </p>
12
+
13
+ <p><a href="./README.md">English</a> · <strong>简体中文</strong></p>
14
+ </div>
15
+
16
+ ## Semantic Atlas 是什么?
17
+
18
+ Semantic Atlas 为编程 Agent 提供一张本地世界图,把两类项目知识连接在一起:
19
+
20
+ - **TypeScript 与 JavaScript 结构证据**:文件、符号、关系、框架入口和未解析边界。
21
+ - **由 Agent 验证的业务知识**:能力、场景、操作、接口、数据、规则、测试,以及支撑它们的证据。
22
+
23
+ `semantic-atlas` CLI 提供确定性、带版本的 JSON 操作;随包发布的 Codex Skill 则告诉 Agent 何时查询、何时回到源码,以及何时值得保留已经验证的知识。内嵌的 CodeGraph SDK 只是结构后端,不是第二个产品或工作流。
24
+
25
+ > **先查询,再确认源码;只学习证据真正证明的内容。**
26
+
27
+ 源码始终是权威事实。Atlas 是一份感知代码版本的投影:它让有用上下文可以复用,同时不会假装静态分析已经知道所有运行时行为。
28
+
29
+ ## 为什么使用它?
30
+
31
+ - **从业务含义开始。** 先找到能力、操作、数据和依赖路径,再打开范围广泛的仓库源码。
32
+ - **减少源码上下文。** 用图证据选择有边界的源码起点,只阅读当前判断真正需要的代码。
33
+ - **让知识保持诚实。** 证据绑定到快照;证据变化或消失后,断言会明确变为过期,而不会悄悄继续充当当前事实。
34
+ - **保留不确定性。** 动态分派、反射、不支持的结构和未解析目标会保持显式,并把 Agent 引导回源码。
35
+ - **不侵入目标项目。** 生成状态只进入工作树内被忽略的 `.atlas/`,不会改写跟踪中的源码和配置。
36
+
37
+ ## 一张项目世界图
38
+
39
+ ![Semantic Atlas 能力图,展示结构证据、业务知识、Agent 循环、统一世界图、显式不确定性与本地存储](docs/mindmaps/semantic-atlas-overview.zh-CN.png)
40
+
41
+ 这张总览是可编辑的 draw.io 思维导图:[打开简体中文源图](docs/mindmaps/semantic-atlas-overview.zh-CN.drawio)。[英文源图](docs/mindmaps/semantic-atlas-overview.drawio)与本地化图片一并维护。
42
+
43
+ ## 快速开始
44
+
45
+ Semantic Atlas 支持 Node.js 22.12 至 24,以及包含 TypeScript 或 JavaScript 的 Git 工作树。
46
+
47
+ ### 安装 CLI
48
+
49
+ ```sh
50
+ npm install --global semantic-atlas
51
+ semantic-atlas status --repo /path/to/project
52
+ ```
53
+
54
+ 安装完成后,索引和查询均在本机执行,不会调用模型或网络。只有安装软件包时需要正常访问 npm registry。
55
+
56
+ ### 安装 Codex Skill
57
+
58
+ 从仓库当前的 `main` 分支安装 Skill:
59
+
60
+ ```text
61
+ $skill-installer Install semantic-atlas from https://github.com/lzj960515/semantic-atlas/tree/main/.agents/skills/semantic-atlas
62
+ ```
63
+
64
+ 之后,Codex 可以根据任务描述自动选择 `$semantic-atlas`,你也可以显式调用它。仓库贡献者会直接获得 `.agents/skills/semantic-atlas` 中随仓库检入的 Skill。
65
+
66
+ ### 发起第一次查询
67
+
68
+ 从准确的目标工作树串行执行命令:
69
+
70
+ ```sh
71
+ semantic-atlas status
72
+ semantic-atlas index
73
+ semantic-atlas map roots
74
+ semantic-atlas map search "checkout" --limit 10
75
+ semantic-atlas map show module:src --depth 1
76
+ ```
77
+
78
+ 每条命令都会向标准输出写入一个带版本的 JSON 信封。诊断信息留在标准错误中,因此 Agent 可以读取稳定字段与告警代码,而不是抓取自然语言文本。
79
+
80
+ ## Agent 如何循环工作?
81
+
82
+ 1. **检查状态。** 在广泛发现源码前,确认准确的仓库根目录、快照新鲜度和结构后端完整性。
83
+ 2. **建立索引。** 当状态缺失、过期、失败或不完整时,发布或刷新当前工作树的本地快照。
84
+ 3. **查询世界图。** 搜索精简的业务词和符号词,只沿有希望的节点与关系继续遍历。
85
+ 4. **确认源码。** 打开图中引用的范围,在权威代码中确认决定性行为;让部分、过期、不支持和未知结果保持有边界。
86
+ 5. **完成工程工作。** 调用 Agent 负责改代码、跑测试、审查差异和操作 Git;Atlas 不接管这些动作。
87
+ 6. **对齐并学习。** 相关源码变化后重新索引,检查语义 `changes`,只通过 `learn --stdin` 写入持久且已验证的业务知识,再用 `map show` 验证学习结果。
88
+
89
+ 这个循环每次只增长一块经过验证的业务能力,而不是把整个仓库转换成推测性文档。
90
+
91
+ ## 实测结果
92
+
93
+ ### 冻结对照评测
94
+
95
+ 仓库保留的 [`fresh-agent-v1` 报告](evaluation/results/fresh-agent-v1/report.json)覆盖 `framework-evaluation@fixture-v1`:针对 NestJS、GraphQL、TypeORM 与 BullMQ 的定位和依赖影响任务,共有 12 组配对案例、24 次全新 Agent 运行。
96
+
97
+ | 指标 | 不使用 Atlas | 使用 Atlas | 固定 fixture 结果 |
98
+ | --- | ---: | ---: | --- |
99
+ | 最终答案正确率 | 100% | 100% | 无回退 |
100
+ | 必要文件召回率 | 100% | 100% | 无回退 |
101
+ | 必要符号召回率 | 100% | 100% | 无回退 |
102
+ | 打开的唯一源码文件中位数 | 6.5 | 4 | 减少 38.46% |
103
+ | 观测到的源码输入 token 中位数 | 1,351 | 688 | 减少 49.07% |
104
+
105
+ 评测门槛在收集结果前就已固定;61 个被路由的不确定性事件均得到处理,没有形成失败分类。解读数字前,请阅读[评测方法](docs/evaluation.md)和保留的运行记录。
106
+
107
+ 这些只是在固定 fixture 上得到的对照结果,**不能**证明所有仓库都具有相同业务准确率,也不能代表模型总 token 节省。这里的 token 指标只统计使用 `tiktoken-o200k_base-v1` 观测到的源码输入。
108
+
109
+ ### 公共产物 Dogfood
110
+
111
+ 独立的 [v0.1.1 版本](https://github.com/lzj960515/semantic-atlas/releases/tag/v0.1.1) dogfood 只使用公开 npm CLI 与标签 Skill,并在隔离的 `pietra-ex-api` 工作树中完成:
112
+
113
+ - 第一个全新 Agent 完成 `missing → index → query → 源码确认 → learn`:索引用时 6.52 秒,发布 42,789 个事实,数据库大小为 40,308,736 字节;一次原子学习在 0.71 秒内写入 4 个业务节点与 8 条关系,随后所有学习节点均为 `valid`。
114
+ - 第二个全新 Agent 没有看到前一个答案,也没有重复 `learn`,只通过正常的 `status`、搜索、根节点和详情查询就复用了这些知识。
115
+ - 目标 revision 与普通 Git 状态前后不变;生成状态只存在于被忽略的 `.atlas/` 中。
116
+
117
+ 同一次 dogfood 也暴露了精度和发现性欠账:一个自然多词查询未在前十名召回已学习节点,框架邻接的 `map show` 输出过大,报告的 27,060 个未知边界缺少有用候选或优先级,源码检查还发现了一条同名方法的错误精确连接。这些事实约束了产品声明;dogfood 是运行证据和局限性来源,不是另一份准确率基准,也不是生产稳定性结论。
118
+
119
+ ## 证据、不确定性与存储边界
120
+
121
+ | 边界 | 契约 |
122
+ | --- | --- |
123
+ | 源码权威 | 所有影响答案的结论都要回到源码确认;Atlas 上下文不会覆盖当前检出的代码。 |
124
+ | 证据有效性 | 业务断言携带源码定位、哈希、确定性和由快照推导的有效性。证据无法重绑定时会得到 `stale`,而不是被静默删除或升级。 |
125
+ | 显式不确定性 | `UnknownBoundary`、`partial`、`unsupported`、`hypothesis` 和信息不足的结果用于缩小源码回退范围,绝不会冒充精确事实。 |
126
+ | 一个产品 | CLI 与 Skill 组成一个 Semantic Atlas 工作流。CodeGraph 位于适配器之后,它的 CLI、MCP、表结构和后端类型不是 Atlas 公共接口。 |
127
+ | 一个本地存储 | 每个工作树拥有自己的 `.atlas/codegraph.db`:CodeGraph 管理结构表,Atlas 管理带 `atlas_*` 前缀的知识、证据、快照和有效性表。 |
128
+ | 零侵入 | Atlas 准备 `.atlas/.gitignore`,不写入跟踪中的源码或项目配置,也不负责编辑、测试、审查、提交、合入或发布代码。 |
129
+
130
+ ## CLI 与开发
131
+
132
+ ```text
133
+ semantic-atlas status [--repo <path>] [--pretty]
134
+ semantic-atlas index [--repo <path>] [--pretty]
135
+ semantic-atlas map roots [--repo <path>] [--pretty]
136
+ semantic-atlas map search <query> [--limit <n>] [--repo <path>] [--pretty]
137
+ semantic-atlas map children <node-id> [--repo <path>] [--pretty]
138
+ semantic-atlas map show <node-id> [--depth <n>] [--repo <path>] [--pretty]
139
+ semantic-atlas learn --stdin [--repo <path>] [--pretty]
140
+ semantic-atlas changes [--from <snapshot-id>] [--to <snapshot-id>] [--repo <path>] [--pretty]
141
+ ```
142
+
143
+ 字段级行为由带版本的 [CLI v1](docs/contracts/cli-v1.md)与 [GraphPatch v1](docs/contracts/graph-patch-v1.md)契约定义。
144
+
145
+ ```sh
146
+ corepack enable
147
+ pnpm install --frozen-lockfile
148
+ pnpm typecheck
149
+ pnpm test
150
+ pnpm build
151
+ pnpm package:verify
152
+ ```
153
+
154
+ `package:verify` 会把打包产物安装到仓库外的临时使用者中,并运行真实 CLI。`validation:backend` 则增加固定 CodeGraph 版本的共存、升级、保留、恢复、证据重绑定与工作树隔离门槛。
155
+
156
+ ## 参考资料
157
+
158
+ - [产品契约](docs/product-contract.md)
159
+ - [图模型](docs/contracts/graph-model.md)
160
+ - [CodeGraph 后端架构](docs/architecture/codegraph-backend.md)
161
+ - [Fresh Agent 评测协议](docs/evaluation.md)
162
+ - [已发布评测产物](evaluation/results/fresh-agent-v1/README.md)
163
+
164
+ ## 许可证
165
+
166
+ Semantic Atlas 使用 [MIT 许可证](LICENSE)发布。
package/dist/cli/bin.js CHANGED
@@ -2,13 +2,21 @@
2
2
  import { spawn } from "node:child_process";
3
3
  import { fileURLToPath } from "node:url";
4
4
  const arguments_ = process.argv.slice(2);
5
- if (process.getBuiltinModule("node:sqlite") === undefined) {
5
+ if (requiresSqliteCompatibilityProcess()) {
6
6
  process.exitCode = await runWithExperimentalSqlite(arguments_);
7
7
  }
8
8
  else {
9
9
  const { runCli } = await import("./main.js");
10
10
  process.exitCode = await runCli(arguments_, { stdin: process.stdin, stdout: process.stdout, stderr: process.stderr }, process.cwd());
11
11
  }
12
+ function requiresSqliteCompatibilityProcess() {
13
+ const nodeMajor = Number.parseInt(process.versions.node, 10);
14
+ const warningAlreadyDisabled = process.execArgv.some((argument) => (argument === "--no-warnings"
15
+ || argument === "--disable-warning=ExperimentalWarning"));
16
+ if (nodeMajor < 24 && !warningAlreadyDisabled)
17
+ return true;
18
+ return process.getBuiltinModule("node:sqlite") === undefined;
19
+ }
12
20
  async function runWithExperimentalSqlite(arguments_) {
13
21
  const child = spawn(process.execPath, [
14
22
  "--experimental-sqlite",
@@ -101,6 +101,25 @@ export declare const baselineEvaluationPlanSchema: z.ZodObject<{
101
101
  }, z.core.$strict>;
102
102
  }, z.core.$strict>>;
103
103
  }, z.core.$strict>;
104
+ export declare const knowledgeCaptureDecisionSchema: z.ZodObject<{
105
+ outcome: z.ZodEnum<{
106
+ persist: "persist";
107
+ reuse: "reuse";
108
+ transient: "transient";
109
+ unverified: "unverified";
110
+ }>;
111
+ summary: z.ZodString;
112
+ }, z.core.$strict>;
113
+ export declare const knowledgeCaptureAdjudicationSchema: z.ZodObject<{
114
+ outcome: z.ZodEnum<{
115
+ persist: "persist";
116
+ reuse: "reuse";
117
+ transient: "transient";
118
+ unverified: "unverified";
119
+ }>;
120
+ correct: z.ZodBoolean;
121
+ notes: z.ZodString;
122
+ }, z.core.$strict>;
104
123
  export declare const evaluationFailureClassificationSchema: z.ZodEnum<{
105
124
  "missed-dependency": "missed-dependency";
106
125
  "incorrect-answer": "incorrect-answer";
@@ -136,6 +155,47 @@ export declare const evaluationRunSchema: z.ZodObject<{
136
155
  policy: z.ZodLiteral<"fresh-agent-shell-allowlist-v4">;
137
156
  commands: z.ZodArray<z.ZodString>;
138
157
  }, z.core.$strict>;
158
+ skillDiscovery: z.ZodOptional<z.ZodObject<{
159
+ delivery: z.ZodLiteral<"repository">;
160
+ promptInjection: z.ZodLiteral<false>;
161
+ mainSkillLoaded: z.ZodLiteral<true>;
162
+ statusBeforeSource: z.ZodLiteral<true>;
163
+ mapBeforeSource: z.ZodLiteral<true>;
164
+ decisiveSourceRead: z.ZodLiteral<true>;
165
+ decisiveSourceFiles: z.ZodArray<z.ZodString>;
166
+ knowledgeCaptureDecision: z.ZodObject<{
167
+ outcome: z.ZodEnum<{
168
+ persist: "persist";
169
+ reuse: "reuse";
170
+ transient: "transient";
171
+ unverified: "unverified";
172
+ }>;
173
+ summary: z.ZodString;
174
+ }, z.core.$strict>;
175
+ conditionalReferences: z.ZodObject<{
176
+ snapshotBootstrap: z.ZodDiscriminatedUnion<[z.ZodObject<{
177
+ outcome: z.ZodLiteral<"not-required">;
178
+ }, z.core.$strict>, z.ZodObject<{
179
+ outcome: z.ZodLiteral<"loaded-after-trigger">;
180
+ triggerCommandSequence: z.ZodNumber;
181
+ loadCommandSequence: z.ZodNumber;
182
+ }, z.core.$strict>], "outcome">;
183
+ resultRouting: z.ZodDiscriminatedUnion<[z.ZodObject<{
184
+ outcome: z.ZodLiteral<"not-required">;
185
+ }, z.core.$strict>, z.ZodObject<{
186
+ outcome: z.ZodLiteral<"loaded-after-trigger">;
187
+ triggerCommandSequence: z.ZodNumber;
188
+ loadCommandSequence: z.ZodNumber;
189
+ }, z.core.$strict>], "outcome">;
190
+ graphPatch: z.ZodDiscriminatedUnion<[z.ZodObject<{
191
+ outcome: z.ZodLiteral<"not-loaded">;
192
+ }, z.core.$strict>, z.ZodObject<{
193
+ outcome: z.ZodLiteral<"loaded-after-source">;
194
+ sourceCommandSequence: z.ZodNumber;
195
+ loadCommandSequence: z.ZodNumber;
196
+ }, z.core.$strict>], "outcome">;
197
+ }, z.core.$strict>;
198
+ }, z.core.$strict>>;
139
199
  }, z.core.$strict>;
140
200
  startedAt: z.ZodISODateTime;
141
201
  finishedAt: z.ZodISODateTime;
@@ -143,12 +203,17 @@ export declare const evaluationRunSchema: z.ZodObject<{
143
203
  sourceTokenMethod: z.ZodString;
144
204
  sourceOpens: z.ZodArray<z.ZodObject<{
145
205
  sequence: z.ZodNumber;
206
+ commandSequence: z.ZodOptional<z.ZodNumber>;
207
+ exitCode: z.ZodOptional<z.ZodNumber>;
146
208
  file: z.ZodString;
147
209
  sourceTokens: z.ZodNumber;
148
210
  }, z.core.$strict>>;
149
211
  atlasCalls: z.ZodArray<z.ZodObject<{
150
212
  sequence: z.ZodNumber;
151
213
  command: z.ZodString;
214
+ commandSequence: z.ZodOptional<z.ZodNumber>;
215
+ exitCode: z.ZodOptional<z.ZodNumber>;
216
+ output: z.ZodOptional<z.ZodString>;
152
217
  }, z.core.$strict>>;
153
218
  atlasHandling: z.ZodArray<z.ZodObject<{
154
219
  sequence: z.ZodNumber;
@@ -162,6 +227,10 @@ export declare const evaluationRunSchema: z.ZodObject<{
162
227
  }>;
163
228
  action: z.ZodString;
164
229
  }, z.core.$strict>>;
230
+ skillLoads: z.ZodOptional<z.ZodArray<z.ZodObject<{
231
+ sequence: z.ZodNumber;
232
+ file: z.ZodString;
233
+ }, z.core.$strict>>>;
165
234
  }, z.core.$strict>;
166
235
  answer: z.ZodObject<{
167
236
  response: z.ZodString;
@@ -170,6 +239,15 @@ export declare const evaluationRunSchema: z.ZodObject<{
170
239
  file: z.ZodString;
171
240
  name: z.ZodString;
172
241
  }, z.core.$strict>>;
242
+ knowledgeCaptureDecision: z.ZodOptional<z.ZodObject<{
243
+ outcome: z.ZodEnum<{
244
+ persist: "persist";
245
+ reuse: "reuse";
246
+ transient: "transient";
247
+ unverified: "unverified";
248
+ }>;
249
+ summary: z.ZodString;
250
+ }, z.core.$strict>>;
173
251
  }, z.core.$strict>;
174
252
  adjudication: z.ZodObject<{
175
253
  correct: z.ZodBoolean;
@@ -183,6 +261,16 @@ export declare const evaluationRunSchema: z.ZodObject<{
183
261
  "unsupported-source": "unsupported-source";
184
262
  "protocol-violation": "protocol-violation";
185
263
  }>>;
264
+ knowledgeCaptureDecision: z.ZodOptional<z.ZodObject<{
265
+ outcome: z.ZodEnum<{
266
+ persist: "persist";
267
+ reuse: "reuse";
268
+ transient: "transient";
269
+ unverified: "unverified";
270
+ }>;
271
+ correct: z.ZodBoolean;
272
+ notes: z.ZodString;
273
+ }, z.core.$strict>>;
186
274
  }, z.core.$strict>;
187
275
  }, z.core.$strict>;
188
276
  export type EvaluationCase = z.infer<typeof evaluationCaseSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/evaluation/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;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