semantic-atlas 0.1.1 → 0.1.3
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/.agents/skills/semantic-atlas/SKILL.md +2 -2
- package/.agents/skills/semantic-atlas/references/snapshot-bootstrap.md +5 -1
- package/README.md +98 -51
- package/README.zh-CN.md +167 -0
- package/dist/cli/cli-application.d.ts.map +1 -1
- package/dist/cli/cli-application.js +5 -5
- package/dist/graph/graph-store.d.ts +6 -0
- package/dist/graph/graph-store.d.ts.map +1 -1
- package/dist/graph/graph-store.js +261 -114
- package/dist/storage/atlas-database.d.ts +6 -2
- package/dist/storage/atlas-database.d.ts.map +1 -1
- package/dist/storage/atlas-database.js +388 -514
- package/dist/storage/snapshot-store.d.ts.map +1 -1
- package/dist/storage/snapshot-store.js +7 -10
- package/dist/structural-backend/codegraph-backend.d.ts +4 -1
- package/dist/structural-backend/codegraph-backend.d.ts.map +1 -1
- package/dist/structural-backend/codegraph-backend.js +10 -4
- package/dist/structural-backend/structural-projection-bootstrapper.d.ts +10 -0
- package/dist/structural-backend/structural-projection-bootstrapper.d.ts.map +1 -0
- package/dist/structural-backend/structural-projection-bootstrapper.js +295 -0
- package/dist/structural-backend/structural-publication.d.ts +1 -0
- package/dist/structural-backend/structural-publication.d.ts.map +1 -1
- package/dist/structural-backend/structural-publication.js +5 -2
- package/dist/world/world-model-service.d.ts.map +1 -1
- package/dist/world/world-model-service.js +14 -6
- package/dist/world/world-snapshot-store.d.ts.map +1 -1
- package/dist/world/world-snapshot-store.js +92 -66
- package/docs/architecture/codegraph-backend.md +26 -29
- package/docs/contracts/cli-v1.md +2 -1
- package/docs/contracts/graph-model.md +2 -2
- package/docs/mindmaps/semantic-atlas-overview.drawio +255 -0
- package/docs/mindmaps/semantic-atlas-overview.png +0 -0
- package/docs/mindmaps/semantic-atlas-overview.zh-CN.drawio +255 -0
- package/docs/mindmaps/semantic-atlas-overview.zh-CN.png +0 -0
- package/docs/product-contract.md +20 -17
- package/package.json +1 -1
|
@@ -21,8 +21,8 @@ and structured GraphPatch input; it does not interpret natural-language tasks.
|
|
|
21
21
|
that worktree or pass its absolute path with `--repo <path>`, and confirm the
|
|
22
22
|
response `repository.root` is the intended worktree.
|
|
23
23
|
2. Run one Atlas CLI command at a time and wait for its complete response. The
|
|
24
|
-
worktree
|
|
25
|
-
boundary.
|
|
24
|
+
current worktree publication and repository-wide knowledge transaction form
|
|
25
|
+
a serialized evidence boundary.
|
|
26
26
|
3. Start with `semantic-atlas status` before broad source discovery. Read the
|
|
27
27
|
versioned envelope, `data.freshness`, snapshot, warnings, and
|
|
28
28
|
`data.backend.completeness` by stable fields and codes.
|
|
@@ -8,7 +8,11 @@ worktree.
|
|
|
8
8
|
## Publish structural state
|
|
9
9
|
|
|
10
10
|
1. For `missing`, `stale`, failed, or incomplete state, run
|
|
11
|
-
`semantic-atlas index` and inspect the returned envelope.
|
|
11
|
+
`semantic-atlas index` and inspect the returned envelope. In a new Git
|
|
12
|
+
worktree, this command automatically restores a compatible sibling
|
|
13
|
+
CodeGraph projection and incrementally synchronizes it; no separate
|
|
14
|
+
initialization command is needed. When no candidate is compatible, the same
|
|
15
|
+
command performs the initial full index.
|
|
12
16
|
2. Run `semantic-atlas status` again. Continue with Atlas only when freshness is
|
|
13
17
|
`current` and backend completeness is `complete`.
|
|
14
18
|
3. Run `semantic-atlas map roots`. Structural `Module` roots are valid initial
|
package/README.md
CHANGED
|
@@ -1,84 +1,136 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
13
|
+
<p><strong>English</strong> · <a href="./README.zh-CN.md">简体中文</a></p>
|
|
14
|
+
</div>
|
|
6
15
|
|
|
7
|
-
##
|
|
16
|
+
## What is Semantic Atlas?
|
|
8
17
|
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.** Durable knowledge stays under `~/.semantic-atlas`; only a disposable CodeGraph projection enters the worktree's ignored `.atlas/` directory. Tracked source and configuration are not rewritten.
|
|
36
|
+
|
|
37
|
+
## One project world map
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
Semantic Atlas supports Node.js 22.12 through 24 and Git worktrees containing TypeScript or JavaScript.
|
|
44
|
+
|
|
45
|
+
### Install the CLI
|
|
16
46
|
|
|
17
47
|
```sh
|
|
18
48
|
npm install --global semantic-atlas
|
|
19
49
|
semantic-atlas status --repo /path/to/project
|
|
20
50
|
```
|
|
21
51
|
|
|
22
|
-
|
|
52
|
+
After installation, indexing and queries run locally without model or network calls. npm registry access is needed only to install the package.
|
|
23
53
|
|
|
24
|
-
|
|
54
|
+
### Install the Codex Skill
|
|
25
55
|
|
|
26
|
-
|
|
56
|
+
Install the Skill from the repository's current `main` branch:
|
|
27
57
|
|
|
28
58
|
```text
|
|
29
|
-
$skill-installer Install semantic-atlas from https://github.com/lzj960515/semantic-atlas/tree/
|
|
59
|
+
$skill-installer Install semantic-atlas from https://github.com/lzj960515/semantic-atlas/tree/main/.agents/skills/semantic-atlas
|
|
30
60
|
```
|
|
31
61
|
|
|
32
|
-
|
|
62
|
+
Codex can then select `$semantic-atlas` from the task description, or you can invoke it explicitly.
|
|
33
63
|
|
|
34
|
-
|
|
64
|
+
### Run the first query
|
|
35
65
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Run Atlas commands serially from the exact target worktree. `--repo <path>` can be supplied before the command when the current directory is elsewhere.
|
|
66
|
+
Run commands serially from the exact target worktree:
|
|
39
67
|
|
|
40
68
|
```sh
|
|
41
69
|
semantic-atlas status
|
|
42
70
|
semantic-atlas index
|
|
43
71
|
semantic-atlas map roots
|
|
44
|
-
semantic-atlas map search checkout --limit 10
|
|
72
|
+
semantic-atlas map search "checkout" --limit 10
|
|
45
73
|
semantic-atlas map show module:src --depth 1
|
|
46
74
|
```
|
|
47
75
|
|
|
48
|
-
|
|
76
|
+
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
77
|
|
|
50
|
-
|
|
51
|
-
2. Load the bootstrap procedure only when the snapshot needs publication, the current map lacks relevant business knowledge, or the user requests project initialization.
|
|
52
|
-
3. Query `map roots`, `map search`, `map children`, and `map show` to bound source exploration.
|
|
53
|
-
4. Confirm decisive behavior in authoritative source and preserve stale, unsupported, unresolved, ambiguous, or insufficient boundaries.
|
|
54
|
-
5. After relevant source changes, reindex and inspect `changes` before trusting the refreshed map.
|
|
55
|
-
6. Before completion, decide what source inspection taught: write every new durable verified business concept and relationship with `learn --stdin`, verify it through `map show`, and retain transient or unverified observations only in task context.
|
|
78
|
+
## The Agent loop
|
|
56
79
|
|
|
57
|
-
|
|
80
|
+
1. **Status.** Confirm the exact repository root, snapshot freshness, and structural-backend completeness before broad source discovery.
|
|
81
|
+
2. **Index.** Publish or refresh the worktree-local snapshot when state is missing, stale, failed, or incomplete.
|
|
82
|
+
3. **Query.** Search compact business and symbol vocabulary, then traverse only the promising nodes and relationships.
|
|
83
|
+
4. **Confirm source.** Open the cited ranges and resolve the decisive behavior in authoritative code. Keep partial, stale, unsupported, and unknown results bounded.
|
|
84
|
+
5. **Do the engineering work.** The calling agent edits code, runs tests, reviews diffs, and owns Git; Atlas performs none of those actions.
|
|
85
|
+
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
86
|
|
|
59
|
-
|
|
87
|
+
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
88
|
|
|
61
|
-
|
|
89
|
+
When `index` runs for a newly created Git worktree, Atlas automatically copies a compatible sibling CodeGraph projection and performs an incremental sync. Agents do not run a separate initialization command; a full index is used only when no compatible sibling projection is available.
|
|
62
90
|
|
|
63
|
-
|
|
91
|
+
## Measured results
|
|
64
92
|
|
|
65
|
-
|
|
66
|
-
<worktree>/.atlas/codegraph.db
|
|
67
|
-
```
|
|
93
|
+
### Frozen comparative evaluation
|
|
68
94
|
|
|
69
|
-
|
|
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.
|
|
70
96
|
|
|
71
|
-
|
|
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 |
|
|
72
104
|
|
|
73
|
-
|
|
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.
|
|
74
106
|
|
|
75
|
-
|
|
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`.
|
|
76
108
|
|
|
77
|
-
|
|
109
|
+
### Public workflow validation
|
|
78
110
|
|
|
79
|
-
|
|
111
|
+
An isolated TypeScript project was used to validate the public installation path with the registry-installed CLI and the Skill from this repository:
|
|
80
112
|
|
|
81
|
-
|
|
113
|
+
- A first fresh agent completed `missing → index → query → source confirmation → learn`.
|
|
114
|
+
- A second fresh agent discovered and reused the persisted 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; durable knowledge lived in the user Atlas home and the worktree contained only ignored CodeGraph state.
|
|
116
|
+
|
|
117
|
+
This validates installation, the Agent workflow, knowledge reuse, and zero-intrusion behavior in that project. It is not a universal 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
|
+
| Durable repository knowledge | `~/.semantic-atlas/repositories/<repository-id>/atlas.db` stores repository-wide business knowledge, snapshots, snapshot bindings, validity, and worktree publication state. Set absolute `SEMANTIC_ATLAS_HOME` only when tests or CI need isolation. |
|
|
128
|
+
| Disposable worktree projection | Each worktree owns `.atlas/codegraph.db`, containing CodeGraph structure only. A missing projection is bootstrapped from a compatible sibling and incrementally synchronized. |
|
|
129
|
+
| Zero intrusion | Atlas prepares `.atlas/.gitignore`, writes no tracked source or project configuration, and does not edit, test, review, commit, merge, or release code. Removing a worktree removes only its disposable projection. |
|
|
130
|
+
|
|
131
|
+
## CLI and development
|
|
132
|
+
|
|
133
|
+
```text
|
|
82
134
|
semantic-atlas status [--repo <path>] [--pretty]
|
|
83
135
|
semantic-atlas index [--repo <path>] [--pretty]
|
|
84
136
|
semantic-atlas map roots [--repo <path>] [--pretty]
|
|
@@ -89,9 +141,7 @@ semantic-atlas learn --stdin [--repo <path>] [--pretty]
|
|
|
89
141
|
semantic-atlas changes [--from <snapshot-id>] [--to <snapshot-id>] [--repo <path>] [--pretty]
|
|
90
142
|
```
|
|
91
143
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## Development
|
|
144
|
+
Field-level behavior lives in the versioned [CLI v1](docs/contracts/cli-v1.md) and [GraphPatch v1](docs/contracts/graph-patch-v1.md) contracts.
|
|
95
145
|
|
|
96
146
|
```sh
|
|
97
147
|
corepack enable
|
|
@@ -102,18 +152,15 @@ pnpm build
|
|
|
102
152
|
pnpm package:verify
|
|
103
153
|
```
|
|
104
154
|
|
|
105
|
-
`
|
|
106
|
-
|
|
107
|
-
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.
|
|
155
|
+
`package:verify` installs the packed artifact into an external temporary consumer and runs the real CLI. `validation:backend` adds the pinned CodeGraph projection, recovery, rebinding, sibling-bootstrap, and worktree-isolation gate.
|
|
108
156
|
|
|
109
|
-
##
|
|
157
|
+
## Reference
|
|
110
158
|
|
|
111
159
|
- [Product contract](docs/product-contract.md)
|
|
112
|
-
- [CodeGraph backend architecture](docs/architecture/codegraph-backend.md)
|
|
113
160
|
- [Graph model](docs/contracts/graph-model.md)
|
|
114
|
-
- [
|
|
115
|
-
- [
|
|
116
|
-
- [
|
|
161
|
+
- [CodeGraph backend architecture](docs/architecture/codegraph-backend.md)
|
|
162
|
+
- [Fresh Agent evaluation protocol](docs/evaluation.md)
|
|
163
|
+
- [Published evaluation artifacts](evaluation/results/fresh-agent-v1/README.md)
|
|
117
164
|
|
|
118
165
|
## License
|
|
119
166
|
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
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 何时查询、何时回到源码,以及何时值得保留已经验证的知识。
|
|
24
|
+
|
|
25
|
+
> **先查询,再确认源码;只学习证据真正证明的内容。**
|
|
26
|
+
|
|
27
|
+
源码始终是权威事实。Atlas 是一份感知代码版本的投影:它让有用上下文可以复用,同时不会假装静态分析已经知道所有运行时行为。
|
|
28
|
+
|
|
29
|
+
## 为什么使用它?
|
|
30
|
+
|
|
31
|
+
- **从业务含义开始。** 先找到能力、操作、数据和依赖路径,再打开范围广泛的仓库源码。
|
|
32
|
+
- **减少源码上下文。** 用图证据选择有边界的源码起点,只阅读当前判断真正需要的代码。
|
|
33
|
+
- **让知识保持诚实。** 证据绑定到快照;证据变化或消失后,断言会明确变为过期,而不会悄悄继续充当当前事实。
|
|
34
|
+
- **保留不确定性。** 动态分派、反射、不支持的结构和未解析目标会保持显式,并把 Agent 引导回源码。
|
|
35
|
+
- **不侵入目标项目。** 持久知识保存在 `~/.semantic-atlas`;工作树内只有被忽略、可丢弃的 CodeGraph 投影,不会改写跟踪中的源码和配置。
|
|
36
|
+
|
|
37
|
+
## 一张项目世界图
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
## 快速开始
|
|
42
|
+
|
|
43
|
+
Semantic Atlas 支持 Node.js 22.12 至 24,以及包含 TypeScript 或 JavaScript 的 Git 工作树。
|
|
44
|
+
|
|
45
|
+
### 安装 CLI
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm install --global semantic-atlas
|
|
49
|
+
semantic-atlas status --repo /path/to/project
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
安装完成后,索引和查询均在本机执行,不会调用模型或网络。只有安装软件包时需要正常访问 npm registry。
|
|
53
|
+
|
|
54
|
+
### 安装 Codex Skill
|
|
55
|
+
|
|
56
|
+
从仓库当前的 `main` 分支安装 Skill:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
$skill-installer Install semantic-atlas from https://github.com/lzj960515/semantic-atlas/tree/main/.agents/skills/semantic-atlas
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
之后,Codex 可以根据任务描述自动选择 `$semantic-atlas`,你也可以显式调用它。
|
|
63
|
+
|
|
64
|
+
### 发起第一次查询
|
|
65
|
+
|
|
66
|
+
从准确的目标工作树串行执行命令:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
semantic-atlas status
|
|
70
|
+
semantic-atlas index
|
|
71
|
+
semantic-atlas map roots
|
|
72
|
+
semantic-atlas map search "checkout" --limit 10
|
|
73
|
+
semantic-atlas map show module:src --depth 1
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
每条命令都会向标准输出写入一个带版本的 JSON 信封。诊断信息留在标准错误中,因此 Agent 可以读取稳定字段与告警代码,而不是抓取自然语言文本。
|
|
77
|
+
|
|
78
|
+
## Agent 如何循环工作?
|
|
79
|
+
|
|
80
|
+
1. **检查状态。** 在广泛发现源码前,确认准确的仓库根目录、快照新鲜度和结构后端完整性。
|
|
81
|
+
2. **建立索引。** 当状态缺失、过期、失败或不完整时,发布或刷新当前工作树的本地快照。
|
|
82
|
+
3. **查询世界图。** 搜索精简的业务词和符号词,只沿有希望的节点与关系继续遍历。
|
|
83
|
+
4. **确认源码。** 打开图中引用的范围,在权威代码中确认决定性行为;让部分、过期、不支持和未知结果保持有边界。
|
|
84
|
+
5. **完成工程工作。** 调用 Agent 负责改代码、跑测试、审查差异和操作 Git;Atlas 不接管这些动作。
|
|
85
|
+
6. **对齐并学习。** 相关源码变化后重新索引,检查语义 `changes`,只通过 `learn --stdin` 写入持久且已验证的业务知识,再用 `map show` 验证学习结果。
|
|
86
|
+
|
|
87
|
+
这个循环每次只增长一块经过验证的业务能力,而不是把整个仓库转换成推测性文档。
|
|
88
|
+
|
|
89
|
+
当新建 Git worktree 第一次运行 `index` 时,Atlas 会自动复制兼容 sibling worktree 的 CodeGraph 投影,再执行增量同步。Agent 不需要额外初始化命令;只有不存在兼容投影时才执行全量索引。
|
|
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
|
+
### 公开工作流验证
|
|
110
|
+
|
|
111
|
+
我们在一个隔离的 TypeScript 项目中,使用从 npm registry 安装的 CLI 和本仓库公开的 Skill 验证了公开安装路径:
|
|
112
|
+
|
|
113
|
+
- 第一个全新 Agent 完成 `missing → index → query → 源码确认 → learn`。
|
|
114
|
+
- 第二个全新 Agent 没有看到前一个答案,也没有重复 `learn`,只通过正常的 `status`、搜索、根节点和详情查询就发现并复用了已持久化的知识。
|
|
115
|
+
- 验证前后,目标 revision 与普通 Git 状态保持不变;持久知识位于用户级 Atlas 目录,工作树内只有被忽略的 CodeGraph 状态。
|
|
116
|
+
|
|
117
|
+
这次验证说明安装路径、Agent 工作流、知识复用和零侵入行为可以协同工作;它不构成通用准确率基准或生产稳定性结论。
|
|
118
|
+
|
|
119
|
+
## 证据、不确定性与存储边界
|
|
120
|
+
|
|
121
|
+
| 边界 | 契约 |
|
|
122
|
+
| --- | --- |
|
|
123
|
+
| 源码权威 | 所有影响答案的结论都要回到源码确认;Atlas 上下文不会覆盖当前检出的代码。 |
|
|
124
|
+
| 证据有效性 | 业务断言携带源码定位、哈希、确定性和由快照推导的有效性。证据无法重绑定时会得到 `stale`,而不是被静默删除或升级。 |
|
|
125
|
+
| 显式不确定性 | `UnknownBoundary`、`partial`、`unsupported`、`hypothesis` 和信息不足的结果用于缩小源码回退范围,绝不会冒充精确事实。 |
|
|
126
|
+
| 一个产品 | CLI 与 Skill 组成一个 Semantic Atlas 工作流。CodeGraph 位于适配器之后,它的 CLI、MCP、表结构和后端类型不是 Atlas 公共接口。 |
|
|
127
|
+
| 仓库级持久知识 | `~/.semantic-atlas/repositories/<repository-id>/atlas.db` 保存仓库共享的业务知识、快照、按快照绑定、有效性和 worktree publication 状态。测试与 CI 只能用绝对路径 `SEMANTIC_ATLAS_HOME` 隔离。 |
|
|
128
|
+
| 工作树级结构投影 | 每个 worktree 拥有只含 CodeGraph 结构的 `.atlas/codegraph.db`。缺失投影会从兼容 sibling 自动引导并增量同步。 |
|
|
129
|
+
| 零侵入 | Atlas 准备 `.atlas/.gitignore`,不写入跟踪中的源码或项目配置,也不负责编辑、测试、审查、提交、合入或发布代码。删除 worktree 只会删除其可丢弃结构投影。 |
|
|
130
|
+
|
|
131
|
+
## CLI 与开发
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
semantic-atlas status [--repo <path>] [--pretty]
|
|
135
|
+
semantic-atlas index [--repo <path>] [--pretty]
|
|
136
|
+
semantic-atlas map roots [--repo <path>] [--pretty]
|
|
137
|
+
semantic-atlas map search <query> [--limit <n>] [--repo <path>] [--pretty]
|
|
138
|
+
semantic-atlas map children <node-id> [--repo <path>] [--pretty]
|
|
139
|
+
semantic-atlas map show <node-id> [--depth <n>] [--repo <path>] [--pretty]
|
|
140
|
+
semantic-atlas learn --stdin [--repo <path>] [--pretty]
|
|
141
|
+
semantic-atlas changes [--from <snapshot-id>] [--to <snapshot-id>] [--repo <path>] [--pretty]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
字段级行为由带版本的 [CLI v1](docs/contracts/cli-v1.md)与 [GraphPatch v1](docs/contracts/graph-patch-v1.md)契约定义。
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
corepack enable
|
|
148
|
+
pnpm install --frozen-lockfile
|
|
149
|
+
pnpm typecheck
|
|
150
|
+
pnpm test
|
|
151
|
+
pnpm build
|
|
152
|
+
pnpm package:verify
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`package:verify` 会把打包产物安装到仓库外的临时使用者中,并运行真实 CLI。`validation:backend` 则增加固定 CodeGraph 版本的结构投影、恢复、证据重绑定、sibling 引导与工作树隔离门槛。
|
|
156
|
+
|
|
157
|
+
## 参考资料
|
|
158
|
+
|
|
159
|
+
- [产品契约](docs/product-contract.md)
|
|
160
|
+
- [图模型](docs/contracts/graph-model.md)
|
|
161
|
+
- [CodeGraph 后端架构](docs/architecture/codegraph-backend.md)
|
|
162
|
+
- [Fresh Agent 评测协议](docs/evaluation.md)
|
|
163
|
+
- [已发布评测产物](evaluation/results/fresh-agent-v1/README.md)
|
|
164
|
+
|
|
165
|
+
## 许可证
|
|
166
|
+
|
|
167
|
+
Semantic Atlas 使用 [MIT 许可证](LICENSE)发布。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-application.d.ts","sourceRoot":"","sources":["../../src/cli/cli-application.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-application.d.ts","sourceRoot":"","sources":["../../src/cli/cli-application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAK1E,OAAO,EAGL,KAAK,yBAAyB,EAC/B,MAAM,8CAA8C,CAAC;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,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AS;YAWT,OAAO;YAsBP,KAAK;IAwBnB,OAAO,CAAC,OAAO;IAuCf,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,mBAAmB;CAW5B"}
|
|
@@ -50,7 +50,6 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
50
50
|
var e = new Error(message);
|
|
51
51
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
52
|
});
|
|
53
|
-
import { join } from "node:path";
|
|
54
53
|
import { cliEnvelopeSchema } from "../contracts/cli.js";
|
|
55
54
|
import { graphPatchV1Schema } from "../contracts/graph.js";
|
|
56
55
|
import { GraphStore } from "../graph/graph-store.js";
|
|
@@ -59,6 +58,7 @@ import { hasSupportedRepositoryLanguage, inspectRepositoryLanguages, } from "../
|
|
|
59
58
|
import { inspectGitRepository, } from "../repository/repository-inspector.js";
|
|
60
59
|
import { createRepositorySnapshot } from "../snapshots/repository-snapshot.js";
|
|
61
60
|
import { SnapshotStore, } from "../storage/snapshot-store.js";
|
|
61
|
+
import { resolveAtlasDatabasePath } from "../storage/atlas-database.js";
|
|
62
62
|
import { CodeGraphStructuralBackend } from "../structural-backend/codegraph-backend.js";
|
|
63
63
|
import { WorldGraphQuery } from "../world/world-graph-query.js";
|
|
64
64
|
import { WorldModelService } from "../world/world-model-service.js";
|
|
@@ -159,7 +159,7 @@ export class CliApplication {
|
|
|
159
159
|
changes: changeCounts(context.currentSnapshot),
|
|
160
160
|
},
|
|
161
161
|
freshness,
|
|
162
|
-
storeLocation:
|
|
162
|
+
storeLocation: resolveAtlasDatabasePath(context.repository),
|
|
163
163
|
languages: [...context.languages],
|
|
164
164
|
backend: {
|
|
165
165
|
version: context.structural.backendVersion,
|
|
@@ -179,9 +179,9 @@ export class CliApplication {
|
|
|
179
179
|
? await new CodeGraphStructuralBackend(context.repository).listUnknownBoundaries()
|
|
180
180
|
: [];
|
|
181
181
|
const world = new WorldModelService(context.repository);
|
|
182
|
-
const publication = context.structural.completeness === "
|
|
183
|
-
? await world.
|
|
184
|
-
: await world.
|
|
182
|
+
const publication = context.structural.completeness === "incomplete"
|
|
183
|
+
? await world.build()
|
|
184
|
+
: await world.sync();
|
|
185
185
|
const unknownChanges = compareUnknownBoundaries(previousUnknowns, publication.structural.boundaries);
|
|
186
186
|
const warnings = [
|
|
187
187
|
...unsupportedLanguageWarnings(context.languages),
|
|
@@ -24,12 +24,18 @@ export declare class GraphStore implements Disposable {
|
|
|
24
24
|
private requireSnapshot;
|
|
25
25
|
private upsertBusinessNode;
|
|
26
26
|
private upsertBusinessRelation;
|
|
27
|
+
private storeBusinessRelation;
|
|
27
28
|
private removeBusinessNode;
|
|
28
29
|
private removeBusinessRelation;
|
|
29
30
|
private insertNodeEvidence;
|
|
30
31
|
private insertRelationEvidence;
|
|
32
|
+
private insertEvidenceBinding;
|
|
33
|
+
private insertStructuralTargetBinding;
|
|
31
34
|
private requireEvidence;
|
|
35
|
+
private currentSnapshotId;
|
|
32
36
|
private refreshAllBusinessValidity;
|
|
37
|
+
private reconcileEvidenceBindings;
|
|
38
|
+
private reconcileEvidenceBindingTable;
|
|
33
39
|
private refreshBusinessValidity;
|
|
34
40
|
private readBusinessNode;
|
|
35
41
|
private readNodeEvidence;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-store.d.ts","sourceRoot":"","sources":["../../src/graph/graph-store.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAEL,4BAA4B,EAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAEV,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EAKrB,QAAQ,EACR,aAAa,EACb,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EAEjB,qBAAqB,EAGtB,MAAM,YAAY,CAAC;AA0DpB,qBAAa,UAAW,YAAW,UAAU;;IAC3C,QAAQ,CAAC,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