@calcit/procs 0.13.27 → 0.13.28
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/.yarn/install-state.gz +0 -0
- package/README.md +34 -34
- package/RFCs/02-04-runtime-traits-plan.md +1 -1
- package/RFCs/02-17-register-platform-api-rfc.md +1 -1
- package/RFCs/02-18-language-theory-evolution-plan.md +3 -3
- package/RFCs/03-05-function-schema-dual-track-rfc.md +3 -3
- package/RFCs/03-18-query-def-tree-show-chunked-display-plan.md +11 -11
- package/RFCs/04-13-type-slot-mechanism-rfc.md +10 -10
- package/RFCs/05-12-program-diff-rfc.md +7 -7
- package/RFCs/06-15-effects-graph-rfc.md +16 -16
- package/RFCs/07-06-semantic-tree-navigation-rfc.md +33 -33
- package/RFCs/07-19-doc-knowledge-index-rfc.md +15 -15
- package/RFCs/07-19-type-introspection-consistency-rfc.md +3 -3
- package/RFCs/07-26-agent-docs-and-evaluation-rfc.md +1 -1
- package/RFCs/07-26-agent-machine-protocol-rfc.md +5 -5
- package/RFCs/07-26-safe-structured-editing-rfc.md +4 -4
- package/RFCs/07-26-static-semantic-analysis-rfc.md +9 -9
- package/RFCs/07-28-git-module-store-rfc.md +4 -4
- package/RFCs/07-28-persistent-tree-cursor-rfc.md +54 -54
- package/RFCs/08-08-cross-backend-host-ffi-contracts-rfc.md +4 -4
- package/RFCs/08-14-architecture-scaffold-rfc.md +7 -7
- package/RFCs/08-14-todo-placeholder-rfc.md +2 -2
- package/RFCs/08-18-calcit-typed-js-ffi-boundary-rfc.md +2 -2
- package/RFCs/08-21-js-ffi-runtime-contract-validation-rfc.md +295 -0
- package/RFCs/08-21-setup-calcit-version-and-toolchain-contract-rfc.md +241 -0
- package/RFCs/08-21-static-type-system-evolution-roadmap.md +315 -0
- package/RFCs/08-21-type-quality-ci-adoption-rfc.md +272 -0
- package/RFCs/README.md +7 -4
- package/editing-history/20260820-1704-repository-maintenance-review.md +20 -0
- package/editing-history/20260821-1512-type-system-ecosystem-rfcs.md +25 -0
- package/editing-history/20260821-1648-type-quality-and-ffi-doc-hints.md +12 -0
- package/editing-history/202608211958-calcit-command-alias.md +6 -0
- package/editing-history/202608212018-cli-review-followups.md +4 -0
- package/editing-history/ARCHIVE.md +45 -4
- package/editing-history/README.md +3 -1
- package/history/202608212020-release-01328.md +5 -0
- package/lib/package.json +11 -11
- package/package.json +11 -11
- package/profiling/README.md +3 -3
- package/profiling/profile-once.sh +1 -1
- package/profiling/samply-once.sh +4 -4
- package/profiling/samply-summary.py +1 -1
- package/editing-history/2026-07-28-1346-edit-transaction.md +0 -27
- package/editing-history/2026-07-28-1454-persistent-tree-cursor.md +0 -30
- package/editing-history/2026-07-28-1651-cursor-focus-stack-clipboard.md +0 -30
- package/editing-history/2026-07-28-1719-cursor-navigation-search-selection.md +0 -21
- package/editing-history/2026-07-28-1958-agent-rfc-split.md +0 -14
- package/editing-history/2026-07-28-2004-cursor-editing-docs.md +0 -14
- package/editing-history/2026-07-28-2132-cursor-recoverable-clipboard.md +0 -18
- package/editing-history/2026-07-28-2151-cursor-native-structural-editing.md +0 -20
- package/editing-history/2026-07-28-2158-document-cursor-native-workflows.md +0 -13
- package/editing-history/2026-07-29-0022-add-cursor-cli-options.md +0 -7
- package/editing-history/2026-07-29-0022-audit-cursor-development-scenarios.md +0 -6
- package/editing-history/2026-07-29-0022-complete-cursor-structural-edits.md +0 -8
- package/editing-history/2026-07-29-0022-document-cursor-edit-recipes.md +0 -8
- package/editing-history/2026-07-29-0022-edit-target-cursor-alias.md +0 -6
- package/editing-history/2026-07-29-0022-guide-agents-through-cursor-workflows.md +0 -7
- package/editing-history/2026-07-29-0022-query-from-active-cursor.md +0 -8
- package/editing-history/2026-07-29-0022-tree-target-cursor-alias.md +0 -5
- package/editing-history/202608021730-release-0.12.58.md +0 -5
- package/editing-history/202608021928-release-0.12.59.md +0 -5
- package/editing-history/202608082312-release-0.13.5.md +0 -10
- package/editing-history/202608090107-release-0.13.6.md +0 -10
- package/editing-history/202608091812-release-0.13.7.md +0 -8
- package/editing-history/202608101042-release-0.13.8.md +0 -6
- package/editing-history/202608101101-release-pr-workflow.md +0 -8
- package/editing-history/202608101102-release-doc-tracked-path.md +0 -5
- package/editing-history/202608110140-release-0.13.9.md +0 -4
- package/editing-history/202608111349-release-0.13.10.md +0 -13
- package/editing-history/202608111650-release-0.13.11.md +0 -5
- package/editing-history/202608121900-release-0.13.12.md +0 -5
- package/editing-history/202608130003-release-0.13.13.md +0 -9
- package/editing-history/202608131650-release-0.13.15.md +0 -10
- package/editing-history/20260816-0254-release-0.13.17.md +0 -5
- package/editing-history/20260817-0006-release-0-13-18.md +0 -6
- package/editing-history/202608171118-project-module-runtime-resolution.md +0 -6
- package/editing-history/202608171133-visible-module-versions-and-cleanup.md +0 -6
- package/editing-history/202608171140-module-caches-root.md +0 -5
- package/editing-history/202608171200-module-cache-review-follow-up.md +0 -5
- package/editing-history/202608171205-release-0-13-19.md +0 -4
- package/editing-history/202608171215-module-path-resolution-docs.md +0 -4
- package/editing-history/202608171409-module-cache-review-followup.md +0 -5
- package/editing-history/202608171427-module-cache-review-followup-locking.md +0 -5
- package/editing-history/202608171438-module-docs-home-lock.md +0 -4
- package/editing-history/202608171611-dependency-audit-review.md +0 -4
- package/editing-history/202608181000-release-0-13-20.md +0 -5
- package/editing-history/202608181930-release-0-13-21.md +0 -5
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
状态:Draft
|
|
4
4
|
日期:2026-07-06
|
|
5
|
-
关联:`
|
|
5
|
+
关联:`calcit tree search-replace`、`calcit tree show`、`calcit query search`、`03-18-query-def-tree-show-chunked-display-plan.md`
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## 1. 概要
|
|
10
10
|
|
|
11
|
-
当前 `
|
|
11
|
+
当前 `calcit tree` 系列编辑命令在定位子表达式时依赖纯数字点号路径(如 `--path '0.3.2.1'`)。对于人类而言手动数坐标已经不方便,对于 LLM 而言更是结构性难题——LLM 在精确计数方面的可靠性与人类手动数行号相当。
|
|
12
12
|
|
|
13
13
|
本 RFC 提出 **四层互补方案**,从近到远逐步提升编辑体验:
|
|
14
14
|
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
当前 LLM 编辑 Calcit 代码的标准工作流:
|
|
36
36
|
|
|
37
37
|
```
|
|
38
|
-
1.
|
|
38
|
+
1. calcit tree show 'app.main/main!' → 查看代码结构
|
|
39
39
|
2. LLM 自己数目标表达式的坐标 → 容易数错
|
|
40
|
-
3.
|
|
40
|
+
3. calcit tree replace 'app.main/main!' --path '...' → 可能用错路径
|
|
41
41
|
4. 出错后重新数、重新试 → 迭代成本高
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
或者用 `search-replace`:
|
|
45
45
|
|
|
46
46
|
```
|
|
47
|
-
1.
|
|
47
|
+
1. calcit tree search-replace 'app.main/main!' --pattern 'old-expr' ...
|
|
48
48
|
→ 报错:"Found 3 matches"
|
|
49
49
|
2. LLM 需要切回 tree show 手动辨别是哪个匹配
|
|
50
50
|
3. 回到手动数坐标模式
|
|
@@ -53,16 +53,16 @@
|
|
|
53
53
|
### 2.2 目标工作流
|
|
54
54
|
|
|
55
55
|
```
|
|
56
|
-
1.
|
|
56
|
+
1. calcit tree show 'app.main/main!' → 输出自动带路径注释
|
|
57
57
|
2. LLM 直接从注释中复制路径 → 不需要数
|
|
58
|
-
3.
|
|
58
|
+
3. calcit tree replace 'app.main/main!' --path '复制来的路径' ...
|
|
59
59
|
→ 一次成功
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
或者在多匹配场景:
|
|
63
63
|
|
|
64
64
|
```
|
|
65
|
-
1.
|
|
65
|
+
1. calcit tree search-replace ... --pattern '...'
|
|
66
66
|
→ 列出 3 个候选(带路径和上下文)
|
|
67
67
|
2. LLM 用 --pick 0 或 --path 指定
|
|
68
68
|
→ 一次成功
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
|
|
75
75
|
### 3.1 方案
|
|
76
76
|
|
|
77
|
-
在 `
|
|
77
|
+
在 `calcit tree show` 的输出中,为每个 **list 节点**的末尾追加一条路径注释。注释放在末尾而非开头,避免插入前导节点导致已有子节点索引偏移。格式为 Cirru 行注释语法:
|
|
78
78
|
|
|
79
79
|
```cirru
|
|
80
80
|
defn add (a b)
|
|
@@ -88,10 +88,10 @@ defn add (a b)
|
|
|
88
88
|
|
|
89
89
|
```bash
|
|
90
90
|
# 默认行为:纯代码展示,无路径注释
|
|
91
|
-
|
|
91
|
+
calcit tree show 'app.main/main!'
|
|
92
92
|
|
|
93
93
|
# 开启路径标注(所有嵌套层级末尾标注路径)
|
|
94
|
-
|
|
94
|
+
calcit tree show 'app.main/main!' --path-annotations
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
当展示的节点包含较多子节点(如超过阈值)时,在输出底部提示可用选项:
|
|
@@ -114,7 +114,7 @@ defn process (xs)
|
|
|
114
114
|
foldl zs 0 add
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
默认 `
|
|
117
|
+
默认 `calcit tree show` 输出(无标注,保持旧行为):
|
|
118
118
|
|
|
119
119
|
```cirru
|
|
120
120
|
defn process (xs)
|
|
@@ -177,18 +177,18 @@ defn process (xs)
|
|
|
177
177
|
|
|
178
178
|
```bash
|
|
179
179
|
# 多匹配时列出候选
|
|
180
|
-
|
|
180
|
+
calcit tree search-replace 'app.main/main!' \
|
|
181
181
|
--pattern 'old-name' \
|
|
182
182
|
--code 'new-name'
|
|
183
183
|
|
|
184
184
|
# 输出候选列表后,选择第 2 个候选
|
|
185
|
-
|
|
185
|
+
calcit tree search-replace 'app.main/main!' \
|
|
186
186
|
--pattern 'old-name' \
|
|
187
187
|
--code 'new-name' \
|
|
188
188
|
--pick 2
|
|
189
189
|
|
|
190
190
|
# 或直接用路径指定
|
|
191
|
-
|
|
191
|
+
calcit tree search-replace 'app.main/main!' \
|
|
192
192
|
--pattern 'old-name' \
|
|
193
193
|
--code 'new-name' \
|
|
194
194
|
--at '1.3.0'
|
|
@@ -203,15 +203,15 @@ Found 3 matches for pattern "old-name":
|
|
|
203
203
|
|
|
204
204
|
[0] Path [1.3.0]: "old-name"
|
|
205
205
|
Context: defn update $ old-name new-name
|
|
206
|
-
Command:
|
|
206
|
+
Command: calcit tree search-replace 'app.main/main!' --pattern 'old-name' ... --pick 0
|
|
207
207
|
|
|
208
208
|
[1] Path [2.5.2]: "old-name"
|
|
209
209
|
Context: let $ old-name x $ do-something old-name
|
|
210
|
-
Command:
|
|
210
|
+
Command: calcit tree search-replace 'app.main/main!' --pattern 'old-name' ... --pick 1
|
|
211
211
|
|
|
212
212
|
[2] Path [3.0.1]: "old-name"
|
|
213
213
|
Context: cond $ = old-name nil $ handle-nil old-name
|
|
214
|
-
Command:
|
|
214
|
+
Command: calcit tree search-replace 'app.main/main!' --pattern 'old-name' ... --pick 2
|
|
215
215
|
|
|
216
216
|
Use --pick <index> to select a candidate, or --at '<path>' to specify directly.
|
|
217
217
|
```
|
|
@@ -236,14 +236,14 @@ Use --pick <index> to select a candidate, or --at '<path>' to specify directly.
|
|
|
236
236
|
|
|
237
237
|
```bash
|
|
238
238
|
# 基本形式:在匹配 anchor 的节点的第 N 个子节点中做搜索替换
|
|
239
|
-
|
|
239
|
+
calcit tree search-replace 'app.main/main!' \
|
|
240
240
|
--at 'defn add' \
|
|
241
241
|
--child 2 \
|
|
242
242
|
--pattern 'old-call' \
|
|
243
243
|
--code 'new-call'
|
|
244
244
|
|
|
245
245
|
# 多层锚定:在 anchor 内的第 N 个子节点中再锚定
|
|
246
|
-
|
|
246
|
+
calcit tree search-replace 'app.main/main!' \
|
|
247
247
|
--at 'let' \
|
|
248
248
|
--child 0 \
|
|
249
249
|
--at 'cond' \
|
|
@@ -396,7 +396,7 @@ integer = /\d+/
|
|
|
396
396
|
|
|
397
397
|
```bash
|
|
398
398
|
# 搜索 add 函数的 def,拿到路径
|
|
399
|
-
|
|
399
|
+
calcit query path 'app.main' \
|
|
400
400
|
--selector 'path
|
|
401
401
|
heading def {} :name |add'
|
|
402
402
|
|
|
@@ -407,7 +407,7 @@ cr query path 'app.main' \
|
|
|
407
407
|
|
|
408
408
|
```bash
|
|
409
409
|
# 在 add 函数的第一个 let 绑定中搜索并替换
|
|
410
|
-
|
|
410
|
+
calcit tree search-replace 'app.main/main!' \
|
|
411
411
|
--path-selector 'path
|
|
412
412
|
heading def {} :name |add
|
|
413
413
|
nth 2
|
|
@@ -421,13 +421,13 @@ cr tree search-replace 'app.main/main!' \
|
|
|
421
421
|
|
|
422
422
|
```bash
|
|
423
423
|
# 获取路径后用于后续编辑
|
|
424
|
-
PATH=$(
|
|
425
|
-
|
|
424
|
+
PATH=$(calcit query path 'app.main' --selector 'path heading def {} :name |init-fn $ nth 2')
|
|
425
|
+
calcit tree replace 'app.main/main!' --path "$PATH" --code '...'
|
|
426
426
|
```
|
|
427
427
|
|
|
428
428
|
### 6.6 与现有路径的互操作
|
|
429
429
|
|
|
430
|
-
- `
|
|
430
|
+
- `calcit query path` 输出标准数字路径(如 `1.3.0`),可直接用于 `--path`
|
|
431
431
|
- `--path-selector` 是 `--path` 的超集替代,内部先解析为数字路径再执行
|
|
432
432
|
- 解析失败时给出明确错误信息(哪一步匹配失败、已匹配到的范围、剩余选择器是什么)
|
|
433
433
|
|
|
@@ -457,23 +457,23 @@ defn main! ()
|
|
|
457
457
|
|
|
458
458
|
`noted` 是已有 macro,接受 tag 和表达式两个参数。`@anchor:<name>` 作为 tag 标记该表达式,`noted` 在运行时透传表达式的值,锚点信息不参与运行时语义。
|
|
459
459
|
|
|
460
|
-
锚点附着在表达式上,表达式被移动/复制时锚点跟随。`
|
|
460
|
+
锚点附着在表达式上,表达式被移动/复制时锚点跟随。`calcit query anchors` 遍历 AST 中所有 `noted` 调用,提取 `@anchor:` 前缀的 tag 及其路径。
|
|
461
461
|
|
|
462
462
|
### 7.2 命令
|
|
463
463
|
|
|
464
464
|
```bash
|
|
465
465
|
# 列出所有锚点
|
|
466
|
-
|
|
466
|
+
calcit query anchors 'app.main'
|
|
467
467
|
|
|
468
468
|
# 输出:
|
|
469
469
|
# @anchor:init-state → app.main/main! [1]
|
|
470
470
|
# @anchor:render-loop → app.main/main! [4.2]
|
|
471
471
|
|
|
472
472
|
# 用锚点定位
|
|
473
|
-
|
|
473
|
+
calcit tree show 'app.main/main!' --anchor 'init-state'
|
|
474
474
|
|
|
475
475
|
# 用锚点编辑:在锚点后插入
|
|
476
|
-
|
|
476
|
+
calcit tree insert-after 'app.main/main!' \
|
|
477
477
|
--anchor 'init-state' \
|
|
478
478
|
--code 'println |loaded'
|
|
479
479
|
```
|
|
@@ -483,7 +483,7 @@ cr tree insert-after 'app.main/main!' \
|
|
|
483
483
|
- 锚点 tag 以 `@anchor:` 前缀标识,在同一 namespace 内必须唯一(不唯一时报错)
|
|
484
484
|
- `noted` 在运行时透传表达式值,锚点不参与运行时语义
|
|
485
485
|
- 锚点跟随表达式移动:`tree delete` / `tree insert` 等操作后,锚点随 `noted` 节点自然位移
|
|
486
|
-
- `
|
|
486
|
+
- `calcit query anchors` 遍历 AST 中所有 `noted` 调用,提取路径和名称
|
|
487
487
|
|
|
488
488
|
### 7.4 锚点与路径的对比
|
|
489
489
|
|
|
@@ -518,7 +518,7 @@ cr tree insert-after 'app.main/main!' \
|
|
|
518
518
|
### Phase 3:L4 结构化查询语言
|
|
519
519
|
|
|
520
520
|
- `path` 选择器解析器
|
|
521
|
-
- `
|
|
521
|
+
- `calcit query path` 命令
|
|
522
522
|
- `--path-selector` 替代 `--path` 的编辑命令集成
|
|
523
523
|
|
|
524
524
|
**预计工作量**:~5-7 天
|
|
@@ -527,7 +527,7 @@ cr tree insert-after 'app.main/main!' \
|
|
|
527
527
|
### Phase 4:锚点注释
|
|
528
528
|
|
|
529
529
|
- `noted @anchor:<name>` 的识别与提取
|
|
530
|
-
- `
|
|
530
|
+
- `calcit query anchors` 命令
|
|
531
531
|
- `--anchor` 参数集成到编辑命令
|
|
532
532
|
|
|
533
533
|
**预计工作量**:~4-6 天
|
|
@@ -564,6 +564,6 @@ cr tree insert-after 'app.main/main!' \
|
|
|
564
564
|
- 当前暂不支持,可作为后续增强
|
|
565
565
|
|
|
566
566
|
4. **锚点应缓存还是每次遍历 AST?**
|
|
567
|
-
- 缓存:`
|
|
567
|
+
- 缓存:`calcit query anchors` 首次解析后缓存到 snapshot 元数据,编辑后失效重算
|
|
568
568
|
- 实时遍历:更简单,无需维护缓存一致性
|
|
569
569
|
- 由于 `noted` 节点在 AST 中自然存在,遍历成本可控,建议先实时遍历
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## 1. 概要
|
|
8
8
|
|
|
9
|
-
在保持 Markdown 可读、可 Git 管理的前提下,为 `
|
|
9
|
+
在保持 Markdown 可读、可 Git 管理的前提下,为 `calcit docs` 增加一层结构化的文档知识索引:
|
|
10
10
|
|
|
11
11
|
```text
|
|
12
12
|
Markdown / Calcit snapshot
|
|
@@ -34,7 +34,7 @@ Markdown 和 Calcit 源码仍然是事实来源;缓存只是可以删除并重
|
|
|
34
34
|
- 当前不引入 RDF、SPARQL、Neo4j 或 SurrealDB。
|
|
35
35
|
- 当前不强制把每个章节拆成独立文件。
|
|
36
36
|
- 当前不把缓存当作用户需要手工维护的知识源。
|
|
37
|
-
- 当前不改变既有 `
|
|
37
|
+
- 当前不改变既有 `calcit docs search/read` 的默认输出语义。
|
|
38
38
|
|
|
39
39
|
## 4. 文档元数据
|
|
40
40
|
|
|
@@ -125,41 +125,41 @@ leads_to:
|
|
|
125
125
|
已完成第一版面向知识节点的查询:
|
|
126
126
|
|
|
127
127
|
```bash
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
calcit docs graph build
|
|
129
|
+
calcit docs graph check
|
|
130
|
+
calcit docs graph children <node>
|
|
131
|
+
calcit docs graph related <node>
|
|
132
|
+
calcit docs graph path <from> <to>
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
查询当前从 Markdown 构建 JSON cache,并通过双向 BFS 查找关系路径:
|
|
136
136
|
|
|
137
137
|
```bash
|
|
138
|
-
|
|
138
|
+
calcit docs graph path core/features/list core/run/edit-tree
|
|
139
139
|
# core/features/list -> core/run/query -> core/run/edit-tree
|
|
140
140
|
```
|
|
141
141
|
|
|
142
142
|
当前已支持通过 `code_refs` 反查关联文档节点;后续再增加源码定义、示例和正文聚合:
|
|
143
143
|
|
|
144
144
|
```bash
|
|
145
|
-
|
|
145
|
+
calcit docs graph explain <definition>
|
|
146
146
|
```
|
|
147
147
|
|
|
148
148
|
### Phase C:完整性检查
|
|
149
149
|
|
|
150
150
|
```bash
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
calcit docs graph check
|
|
152
|
+
calcit docs graph orphans
|
|
153
|
+
calcit docs graph missing
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
检查断链、孤立节点、无正文定义、缺少示例和缺少必要章节。
|
|
157
157
|
|
|
158
158
|
当前已实现:
|
|
159
159
|
|
|
160
|
-
- `
|
|
161
|
-
- `
|
|
162
|
-
- `
|
|
160
|
+
- `calcit docs graph check`:检查关系边是否指向已知文档节点;
|
|
161
|
+
- `calcit docs graph missing [--ns <prefix>] [--limit <n>]`:按 namespace 分批检查带有 snapshot 文档说明、但没有 `code_refs` 的定义;
|
|
162
|
+
- `calcit docs graph orphans`:检查没有任何关系的文档节点。
|
|
163
163
|
|
|
164
164
|
## 8. 验证标准
|
|
165
165
|
|
|
@@ -56,18 +56,18 @@
|
|
|
56
56
|
3. ✅ **修正 `to-pairs`/`keys` 的类型签名**,让 record 也能匹配,消除虚假类型告警。
|
|
57
57
|
- 实现:[src/calcit/type_annotation.rs](../src/calcit/type_annotation.rs) `matches_with_bindings` 里 `(TypeRef, Record)` 分支新增:当 `TypeRef` 名字就是泛化的 `"map"` 时,结构性地匹配任意 record(不要求 record 名字等于 `"map"`)。
|
|
58
58
|
- 测试:新增单元测试 `generic_map_type_ref_accepts_records_structurally`,直接验证 `TypeRef("map")` 与 `Record(Person)` 现在双向匹配,同时确认无关的 `TypeRef` 名字仍然不会误匹配。
|
|
59
|
-
- 备注:实测 `
|
|
59
|
+
- 备注:实测 `calcit --check-only` 在当前仓库测试集里并未因这个 gap 产生可观察的告警(`test-record.cirru` 里 `keys p2` 这行本来就没有触发过告警,猜测是这条路径上的静态类型推断没有把 `p2` 识别为具体的 `Record` 类型,所以没有触发 `check_proc_arg_types` 这条检查分支)。但 `matches_with_bindings` 的错误比较逻辑本身是真实存在的 bug,属于防御性修复:一旦未来静态推断能力增强(例如给变量加显式类型标注后传入 `to-pairs`/`keys`),就不会再误报。
|
|
60
60
|
4. ⏸️ **(可选,视时间,本轮未实现)** 新增 `&struct:fields`/`&enum:variants` 之类的编程接口,让“裸类型定义”的字段/variant 列表也能被程序消费,而不仅仅是打印文本。
|
|
61
61
|
- 未实现原因:新增一个 proc 需要贯穿 `proc_name.rs`(注册+类型签名)、`builtins.rs`(分发)、`builtins/records.rs`或`meta.rs`(实现)、以及 JS/IR/WASM 三个 codegen 目标的同步实现,工作量与收益相比前三项更低(前三项已经解决了运行时能力不对齐的核心问题;字段/variant 名字目前仍可通过 `Display`/`println` 人肉获取,只是没有编程接口)。留作后续独立迭代。
|
|
62
62
|
|
|
63
63
|
## 4. 兼容性 / 风险
|
|
64
64
|
|
|
65
|
-
- 第 1、2、3 项都已实现并通过 `cargo test`、`cargo run --bin
|
|
65
|
+
- 第 1、2、3 项都已实现并通过 `cargo test`、`cargo run --bin calcit -- calcit/test.cirru`、`yarn check-all`、`cargo clippy -- -D warnings`、`cargo fmt` 验证,纯粹的能力扩展/告警范围放宽,不改变现有行为,向后兼容。
|
|
66
66
|
- 第 4 项延后,不影响现有行为。
|
|
67
67
|
|
|
68
68
|
## 5. 验证方式(已执行)
|
|
69
69
|
|
|
70
70
|
- `cargo test`:新增/更新的 Rust 单元测试全部通过,覆盖 `Display for Enum`、`&methods-of` 对裸类型定义的调用、`to-pairs`/`keys` 的类型匹配放宽。
|
|
71
|
-
- `cargo run --bin
|
|
71
|
+
- `cargo run --bin calcit -- calcit/test.cirru`:Cirru 集成测试套件全部通过,包括新增的裸类型 `&methods-of` 断言。
|
|
72
72
|
- `yarn check-all`:JS/IR/WASM 三个目标同步验证通过(`&methods-of` 的 JS 实现已同步补齐)。
|
|
73
73
|
- `cargo clippy -- -D warnings` / `cargo fmt`:均无告警。
|
|
@@ -22,7 +22,7 @@ calcit://definition/<namespace>/<name>
|
|
|
22
22
|
|
|
23
23
|
前端搜索、知识图和校验必须复用同一个版本化 frontmatter parser。逐步校验必填/enum、duplicate ID、dangling edge、scope、可解析 code refs 与可执行的 current 示例;旧文档可兼容读取,再分阶段变严格。
|
|
24
24
|
|
|
25
|
-
默认 `
|
|
25
|
+
默认 `calcit docs search` 只覆盖 current guide/reference 与 definition metadata。RFC、草稿与 `editing-history/` 必须显式带 scope 才进入结果,避免历史语法污染 Agent 上下文。
|
|
26
26
|
|
|
27
27
|
## 3. 可重复的 Agent 基准
|
|
28
28
|
|
|
@@ -122,10 +122,10 @@ query、docs、静态分析与 builtin fallback 应从同一只读描述视图
|
|
|
122
122
|
优先完善以下只读命令,而不是新增多套近似查询:
|
|
123
123
|
|
|
124
124
|
```bash
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
calcit capabilities --format edn
|
|
126
|
+
calcit query context <ns/def> --budget 2500 --format edn
|
|
127
|
+
calcit query type <type-or-definition> --format edn
|
|
128
|
+
calcit query type-at <ns/def> --path code@3.2 --format edn
|
|
129
129
|
```
|
|
130
130
|
|
|
131
131
|
`capabilities` 返回命令、参数/结果 schema、只读性、幂等性和支持的格式,使 Agent 不必加载所有 CLI help。
|
|
@@ -143,7 +143,7 @@ cr query type-at <ns/def> --path code@3.2 --format edn
|
|
|
143
143
|
3. editor/LSP 映射不把行号变成新的事实来源;
|
|
144
144
|
4. 有明确维护者承担协议兼容、进程恢复和跨平台测试。
|
|
145
145
|
|
|
146
|
-
届时优先实现 `
|
|
146
|
+
届时优先实现 `calcit serve --stdio`,复用本 RFC typed result。stdio 使用一行一个
|
|
147
147
|
请求、一行一个响应的 framing;每一行必须是一个完整 EDN value,或在握手后是
|
|
148
148
|
一个完整 JSON value,禁止把日志写入 stdout。客户端首先发送:
|
|
149
149
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## 1. 原则
|
|
8
8
|
|
|
9
|
-
Calcit 的编辑对象是 EDN tree,不是文本行。`
|
|
9
|
+
Calcit 的编辑对象是 EDN tree,不是文本行。`calcit edit` / `calcit tree` 的安全性应来自 revision、semantic selector、subtree fingerprint、preview 与原子写入;不应把行号 patch 作为主工作流。
|
|
10
10
|
|
|
11
11
|
数字 path 依然有价值,但只代表某一个 snapshot revision 下的瞬时坐标。任何会改变同级节点的操作后,调用方必须重新查询或使用 selector/fingerprint。
|
|
12
12
|
|
|
@@ -30,7 +30,7 @@ dry-run 返回语义 diff、计划写入、受影响 definitions 和 diagnostics
|
|
|
30
30
|
新增:
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
|
|
33
|
+
calcit edit transaction --file changes.cirru --dry-run --format json
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
第一版 transaction 以 Cirru EDN 为主输入:外层 list 中,每个内层 list 是一条完整的 `edit`、`tree` 或 `config` 参数序列;`--code` 后可以直接嵌入 `quote` AST 节点,不需要把 Calcit 代码转义成字符串。JSON argument lists 仅作为兼容机器输入保留。这样不复制子命令的参数与校验语义;后续只有在 operation-level precondition 确有需要时,才在兼容此格式的基础上增加 typed operation record。
|
|
@@ -47,12 +47,12 @@ transaction 可包含 tree replace、definition/import/config 改动;整体通
|
|
|
47
47
|
|
|
48
48
|
任何失败都不修改原 snapshot。输出保存 operation ID,方便 Agent 精确重试。
|
|
49
49
|
|
|
50
|
-
当前实现进度(2026-07-28):已加入 `
|
|
50
|
+
当前实现进度(2026-07-28):已加入 `calcit edit transaction` 第一版,以可直接嵌入 quoted code 的 Cirru EDN argument lists 为主格式,同时兼容 JSON;支持 `--dry-run`、snapshot `--expect-revision`、human/JSON 输出、同目录 staging、最终 revision 复核与原子 rename。子命令仍作用于 staged snapshot,因此沿用已有 `edit/tree/config` 校验;失败与 stale revision 不写原文件。operation-level precondition、semantic diff 与 `--check-after` 留待后续阶段。
|
|
51
51
|
|
|
52
52
|
## 4. 受影响范围验证
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
|
|
55
|
+
calcit analyze verify-changed --format json
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
它读取 Git diff 或最近 transaction result,基于 usages、call graph、schema dependency 找到直接修改项与调用者;执行可信的静态检查,并区分 `executed`、`recommended`、`not_run`。JS/IR/WASM 与全量测试先作为推荐项,避免从不可靠图自动宣称“已全覆盖”。
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
## 2. 静态查询
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
calcit query type :number --format json
|
|
15
|
+
calcit query type ':: :list :number' --format json
|
|
16
|
+
calcit query type app.schema/Person --format json
|
|
17
|
+
calcit query type-at app.main/f --path code@3.2 --format json
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
返回 canonical type、可用 methods 与其 impl 优先级、schema/推断证据,以及可用时的 fields、enum variants、constructors、trait 和 examples。`type-at` 返回 inferred/expected type、lexical bindings、method candidates、evidence、definition revision 和 diagnostics。
|
|
@@ -27,7 +27,7 @@ cr query type-at app.main/f --path code@3.2 --format json
|
|
|
27
27
|
|
|
28
28
|
- `proven`:schema 或静态规则已证明;
|
|
29
29
|
- `partial`:信息只覆盖一部分结构;
|
|
30
|
-
- `intentional-js-ffi` / `intentional-macro`:设计上允许的动态边界;
|
|
30
|
+
- `intentional-js-ffi` / `intentional-macro` / `intentional-type-slot-dynamic`:设计上允许的动态边界;
|
|
31
31
|
- `unresolved`:应补 schema 或推断规则;
|
|
32
32
|
- `unknown`:当前没有足够静态证据;
|
|
33
33
|
- `failed`:静态处理本身失败。
|
|
@@ -96,10 +96,10 @@ cr query type-at app.main/f --path code@3.2 --format json
|
|
|
96
96
|
逐步提供:
|
|
97
97
|
|
|
98
98
|
```bash
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
calcit --check-only --format json
|
|
100
|
+
calcit query diagnostics --format json
|
|
101
|
+
calcit analyze check-types --format json
|
|
102
|
+
calcit analyze weak-types --intent unresolved --format json
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
验收包括:稳定 diagnostic code/phase、expected/actual 为结构数据、`type-at` 不执行程序、故意 FFI dynamic 不被误报、`:any` 输入 canonicalize 为 `:dynamic`、泛型/where/callback/container 中的 dynamic 能说明丢失的多态关系,以及正常/未知/显式 schema 分支的回归测试。
|
|
@@ -143,8 +143,8 @@ Windows 上优先使用 directory junction;不支持链接时允许显式 copy
|
|
|
143
143
|
1. `deps.cirru :version` 存在时,它是发布工具的权威值;
|
|
144
144
|
2. 只有 `calcit.cirru :version` 时,`caps version get` 读取旧值并提示迁移;
|
|
145
145
|
3. `caps version set/bump` 只写入 `deps.cirru`,不隐式改写机器生成的 snapshot;
|
|
146
|
-
迁移期 snapshot `:version` 继续作为旧版 `
|
|
147
|
-
4. `
|
|
146
|
+
迁移期 snapshot `:version` 继续作为旧版 `calcit` 的兼容字段,允许暂时不同;
|
|
147
|
+
4. `calcit config set version` 先保留,但提示改用 `caps version set`;
|
|
148
148
|
5. 等生态完成迁移后,再让 snapshot 的 `:version` 变为可选并停止写入镜像。
|
|
149
149
|
|
|
150
150
|
建议命令:
|
|
@@ -302,7 +302,7 @@ root
|
|
|
302
302
|
列出全部直接版本请求和最终选择理由。稠密依赖图不枚举所有简单路径,避免输出
|
|
303
303
|
组合爆炸。
|
|
304
304
|
|
|
305
|
-
## 8. `
|
|
305
|
+
## 8. `calcit` 的模块查找兼容层
|
|
306
306
|
|
|
307
307
|
目前多个命令各自拼接 `~/.config/calcit/modules/`。实现项目视图前先把它们
|
|
308
308
|
收敛到共享 resolver,至少覆盖运行、query、config、call-graph、docs 和 wasm
|
|
@@ -419,7 +419,7 @@ override 的正式语法另开小 RFC,不阻塞 store 和递归解析。
|
|
|
419
419
|
|
|
420
420
|
### Phase A:共享路径解析和元数据
|
|
421
421
|
|
|
422
|
-
- 集中 `
|
|
422
|
+
- 集中 `calcit`/docs/query 的 module resolver;
|
|
423
423
|
- 项目 `.calcit/modules` 优先、legacy global fallback;
|
|
424
424
|
- `PackageDeps` 支持 `:version` 与可选 `:native`;
|
|
425
425
|
- 增加 `caps version`,只管理 `deps.cirru`;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
Calcit 源码以 EDN tree 保存,数字 path 只是某个 snapshot revision 下的瞬时坐标。复杂表达式需要连续执行 show、insert、wrap、replace、delete 等操作时,Agent 即使第一次选对节点,也可能因为前方兄弟节点增删而继续使用已经漂移的 path。
|
|
10
10
|
|
|
11
|
-
引入项目本地 `.calcit/cursor.cirru` 与 `
|
|
11
|
+
引入项目本地 `.calcit/cursor.cirru` 与 `calcit cursor`,保存当前选择的 namespace、definition 和 tree path。Cursor 不是新的源码身份,也不写进 snapshot;它是 CLI 在多次调用之间维护的结构化选择状态。`.calcit/` 同时作为 error、snippets 与后续模块链接等小型项目本地工件的统一目录,避免继续增加顶层隐藏文件。
|
|
12
12
|
|
|
13
13
|
核心要求:一旦 cursor 已存在,任何作用于同一 definition 的 tree mutation 都必须尝试迁移 cursor。能够确定新位置时更新坐标并提示;不能确定时明确标为 stale 或移动到可证明安全的父节点,不允许静默指向另一个节点。
|
|
14
14
|
|
|
@@ -90,50 +90,50 @@ cursor 文件位于 snapshot 同目录的 `.calcit/`,使用目标文件所在
|
|
|
90
90
|
## 3. CLI 契约
|
|
91
91
|
|
|
92
92
|
```bash
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
93
|
+
calcit cursor set app.main/render! --path @3.2.1
|
|
94
|
+
calcit cursor show
|
|
95
|
+
calcit cursor parent
|
|
96
|
+
calcit cursor child # first child
|
|
97
|
+
calcit cursor child 2
|
|
98
|
+
calcit cursor child --last # last child
|
|
99
|
+
calcit cursor next --count 3
|
|
100
|
+
calcit cursor prev --count 2
|
|
101
|
+
calcit cursor forward --count 8
|
|
102
|
+
calcit cursor backward --count 5
|
|
103
|
+
calcit cursor back --count 4
|
|
104
|
+
calcit cursor push
|
|
105
|
+
calcit cursor pop
|
|
106
|
+
calcit cursor anchor
|
|
107
|
+
calcit cursor region
|
|
108
|
+
calcit cursor clear-anchor
|
|
109
|
+
calcit cursor mark render-start
|
|
110
|
+
calcit cursor goto render-start
|
|
111
|
+
calcit cursor marks
|
|
112
|
+
calcit cursor rm-mark render-start
|
|
113
|
+
calcit cursor apply swap-next
|
|
114
|
+
calcit cursor apply wrap --code 'quote $ when visible? self'
|
|
115
|
+
calcit cursor slurp-next
|
|
116
|
+
calcit cursor slurp-prev
|
|
117
|
+
calcit cursor barf-last
|
|
118
|
+
calcit cursor barf-first
|
|
119
|
+
calcit cursor duplicate --at after
|
|
120
|
+
calcit cursor copy
|
|
121
|
+
calcit cursor cut
|
|
122
|
+
calcit cursor paste --at after
|
|
123
|
+
calcit cursor clipboard
|
|
124
|
+
calcit cursor clear-clipboard
|
|
125
|
+
calcit cursor clear
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
definition-oriented query/tree/edit 命令的 target 与 tree path 都可用 `@cursor` 引用 active cursor:
|
|
129
129
|
|
|
130
130
|
```bash
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
calcit query context @cursor --format json
|
|
132
|
+
calcit query type-at @cursor --path @cursor --format json
|
|
133
|
+
calcit tree show @cursor --path @cursor
|
|
134
|
+
calcit tree replace @cursor --path @cursor --code 'quote $ render-list items'
|
|
135
|
+
calcit tree wrap @cursor --path @cursor --code 'quote $ when visible? self'
|
|
136
|
+
calcit edit split-def @cursor --path @cursor --name render-items
|
|
137
137
|
```
|
|
138
138
|
|
|
139
139
|
对连续编辑中最常用的操作,`cursor apply <operation>` 进一步省略重复的 target 和 path,但内部仍构造并调用既有 tree 命令,不另外实现 mutation 语义。支持 `delete`、`swap-next`、`swap-prev`、`unwrap`、`raise`、`replace`、`wrap`、`insert-before`、`insert-after`、`insert-child` 与 `append-child`。其中 `unwrap` 的语义是把选中 list 的所有 child 展开到 parent,不承诺与包含额外语法节点的 wrap 模板严格互逆。
|
|
@@ -155,9 +155,9 @@ CURSOR
|
|
|
155
155
|
编辑后的 cursor 回显由顶层参数控制:
|
|
156
156
|
|
|
157
157
|
```bash
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
calcit --cursor-after none calcit.cirru tree replace app.main/render! --path @cursor --code 'quote nil'
|
|
159
|
+
calcit --cursor-after summary calcit.cirru edit cp app.main/render! --from @3 --path @cursor
|
|
160
|
+
calcit --cursor-after focus calcit.cirru tree wrap app.main/render! --path @cursor --code 'quote $ when ok? self'
|
|
161
161
|
```
|
|
162
162
|
|
|
163
163
|
`summary` 是默认值,只向 stderr 输出 target、更新后 path 与迁移原因;`focus` 额外输出结构聚焦预览;`none` 关闭自动回显。三种模式都不改变 cursor 的实际维护。
|
|
@@ -169,12 +169,12 @@ cr --cursor-after focus calcit.cirru tree wrap app.main/render! --path @cursor -
|
|
|
169
169
|
搜索结果可直接成为 cursor,不需要 Agent 从展示文本复制 target/path:
|
|
170
170
|
|
|
171
171
|
```bash
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
calcit query search render-item --filter app.main/render! --exact --set-cursor 0
|
|
173
|
+
calcit query search-expr 'map items' --filter app.main/render! --set-cursor 1
|
|
174
|
+
calcit query search state --start-path @cursor --set-cursor 0
|
|
175
|
+
calcit query search-expr 'div $ {}' --start-path @cursor
|
|
176
|
+
calcit query next
|
|
177
|
+
calcit query prev
|
|
178
178
|
```
|
|
179
179
|
|
|
180
180
|
`query search` 与 `query search-expr` 在 human 输出为每个 match 显示稳定的全局 `[#N]`,JSON match 增加 `cursor_index`。`--filter @cursor` 限定当前 definition;`--start-path @cursor` 同时推导 definition filter 并把搜索根限制到当前 subtree,冲突 filter 直接报错。显式 `--set-cursor N` 采用同一排序后的结果,在返回查询结果前更新 sidecar;成功提示写 stderr,因此 `--format json` 的 stdout 仍是单个 JSON。越界或 dependency-only match 无法映射到当前可编辑 snapshot 时拒绝设置,并提示用 `--filter <project-namespace>` 缩小范围。`query next/prev` 从 last query 计算相邻 index、重新执行搜索并只回显新 cursor;若 snapshot revision 已变化则拒绝复用旧 index,要求重新执行原搜索选中结果,避免结果重排后跳错节点。
|
|
@@ -223,7 +223,7 @@ workspace/module 解析、全项目分析、namespace 批量更新与可复现 t
|
|
|
223
223
|
|
|
224
224
|
## 5. 外部变化与 stale 恢复
|
|
225
225
|
|
|
226
|
-
`
|
|
226
|
+
`calcit cursor show` 和 `--path @cursor` 每次都重新解析 snapshot:
|
|
227
227
|
|
|
228
228
|
1. revision 与 fingerprint 均匹配时状态为 `exact`;
|
|
229
229
|
2. revision 变化但 path fingerprint 仍匹配时刷新 revision,状态为 `verified-at-path`;
|
|
@@ -255,9 +255,9 @@ snapshot 与 cursor 是两个文件,无法依靠单次 rename 同时提交。
|
|
|
255
255
|
CLI 将引入项目本地 `cursor user`,取代进程间共享的 active selection:
|
|
256
256
|
|
|
257
257
|
```bash
|
|
258
|
-
|
|
259
|
-
CALCIT_CURSOR_USER=agent-b
|
|
260
|
-
|
|
258
|
+
calcit --cursor-user agent-a cursor show
|
|
259
|
+
CALCIT_CURSOR_USER=agent-b calcit tree show @cursor --path @cursor
|
|
260
|
+
calcit cursor show # 未指定时使用 default
|
|
261
261
|
```
|
|
262
262
|
|
|
263
263
|
解析优先级为 `--cursor-user` > `CALCIT_CURSOR_USER` > `default`。`@cursor`、history、stack、anchor、marks、last-query 和 clipboard 全部按 user 隔离;`cursor whoami/users` 提供发现接口。
|
|
@@ -269,7 +269,7 @@ source mutation 只立即迁移发起 user 的 cursor/anchor/marks;其他 user
|
|
|
269
269
|
## 7. 第一阶段实现范围
|
|
270
270
|
|
|
271
271
|
1. Cirru EDN cursor 状态的读取、v1-v3→v4 兼容、旧路径一次性迁移、校验、64 KiB 上限和原子写入;
|
|
272
|
-
2. `
|
|
272
|
+
2. `calcit cursor set/show/clear/parent/child/next/prev/forward/backward/back/push/pop`,含末子节点、同级多步与跨 list 的深度优先导航;
|
|
273
273
|
3. 结构化 `copy/cut/paste/clipboard`,clipboard 不经过文本序列化;
|
|
274
274
|
4. definition-oriented query/tree/edit 接受 `@cursor` target;tree/type-at/edit 的 path 可同时引用 `@cursor`;
|
|
275
275
|
5. `edit cp/mv/split-def` 接受 `@cursor`,definition replace/rename/move/delete 与 cursor 协作;
|