@calcit/procs 0.12.11 → 0.12.13

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.
Binary file
@@ -2,5 +2,4 @@
2
2
 
3
3
  - Unified run mode behavior for `cr`, `cr js`, and `cr ir`: default to once.
4
4
  - Added explicit `-w/--watch` switches for top-level direct run and `ir` subcommand.
5
- - Kept `-1/--once` for backward compatibility.
6
5
  - Updated watch-mode related docs in `Agents.md` and `docs/CalcitAgent.md`.
@@ -3,17 +3,20 @@
3
3
  This commit moves JSON parsing and serialization into Calcit builtins and aligns the surrounding runtime/docs/tooling updates needed to ship it cleanly.
4
4
 
5
5
  1. Added builtin JSON runtime functions
6
+
6
7
  - Introduced `json-parse`, `json-stringify`, and `json-pretty` in Rust builtin dispatch and JS runtime exports.
7
8
  - Added fast arity/type checks on exposed runtime entry points.
8
9
  - Normalized integer-valued numbers to encode as JSON integers in Rust, matching JS output.
9
10
  - Added native tests and Calcit-level coverage for parse/stringify/pretty behavior and error paths.
10
11
 
11
12
  2. Updated core docs and runtime placeholder naming
13
+
12
14
  - Added `calcit.core` docs/examples for the JSON runtime functions.
13
15
  - Renamed the runtime placeholder spelling from `runtime-inplementation` to `runtime-implementation` across core snapshot metadata and Rust handling.
14
16
  - Preserved an explicit `cr <snapshot-file> edit format` example in `docs/CalcitAgent.md`.
15
17
 
16
18
  3. Snapshot formatting workflow
19
+
17
20
  - Re-ran `cr edit format` against the touched Cirru snapshot files:
18
21
  - `src/cirru/calcit-core.cirru`
19
22
  - `calcit/test.cirru`
@@ -0,0 +1,72 @@
1
+ # Query 搜索结果分层、降噪与路径/预览优化(合并记录)
2
+
3
+ ## 变更概述
4
+
5
+ - 初始实现:为 `cr query` 搜索类命令引入结果分层展示(详情窗口 + 压缩输出)。
6
+ - 参数命名收敛:将 `--prefer` 直接改为 `--detail-offset`(不保留兼容别名)。
7
+ - 输出降噪:删除冗长提示,保留定位核心信息(定义、路径、命中片段)。
8
+ - 路径统一:搜索输出与 `--start-path` 示例统一为点号分隔;解析层仅接受点号输入。
9
+ - 详情窗口进一步从 5 缩小为 3,并在窗口内增加“所在表达式 + 父表达式”预览(可省略复杂父表达式)。
10
+
11
+ ## 覆盖命令
12
+
13
+ - `cr query find`
14
+ - `cr query usages`
15
+ - `cr query search`
16
+ - `cr query search-expr`
17
+
18
+ ## 关键实现
19
+
20
+ - `src/cli_args.rs`
21
+ - 参数字段统一为 `detail_offset`。
22
+ - 参数统一为 `#[argh(option, long = "detail-offset", default = "0")]`。
23
+ - 参数说明更新为“3 detailed items”。
24
+ - `query search --start-path` 示例更新为点号格式 `2.1.0`。
25
+
26
+ - `src/bin/cli_handlers/query.rs`
27
+ - 结果窗口逻辑:
28
+ - `DETAILED_RESULTS_WINDOW = 3`
29
+ - `detailed_window(detail_offset, total)`
30
+ - `in_detail_window(index, total, detail_offset)`
31
+ - `print_detail_window_hint(...)`
32
+ - 搜索结果降噪:
33
+ - `search/search-expr` 按命中数排序定义(高命中优先)。
34
+ - 详情行输出为 `[path] <preview>`;窗口外仅输出压缩条数(`N matches compressed outside window`)。
35
+ - 移除 `Next steps`/批量替换等长提示块。
36
+ - 预览增强:
37
+ - 新增 `preview_node_oneline(...)` 并修复叶子节点空预览问题。
38
+ - 新增 `path_parent(...)`、`get_node_at_path(...)`、`count_nodes_limited(...)`、`can_show_parent_preview(...)`、`expression_and_parent_preview(...)`。
39
+ - 最终形态改为“单行预览”:优先显示父节点预览;无父节点时回退到当前表达式(避免重复展示两遍)。
40
+
41
+ - Tips 与 exact 语义修正:
42
+ - `--exact` 高优先级提示文案统一为英文:`Many matches (N); add --exact to show exact matches only`。
43
+ - 仅在 contains 模式且命中数 `> 10` 时展示该提示;`--exact` 模式不再显示冗余提示。
44
+ - 修复 exact 模式下的误导性高亮:只在 token 边界高亮,避免将 `states` 中的 `state` 误标为命中。
45
+
46
+ - 命名收敛:将旧命名 `prefer` 在函数参数/调用链/提示文案中统一改为 `detail_offset` / `detail-offset`。
47
+
48
+ - `src/bin/cli_handlers/common.rs`
49
+ - `parse_path(...)` 改为仅接受点号分隔;逗号输入报错并提示改用点号。
50
+
51
+ ## 降噪策略
52
+
53
+ - 深度嵌套(路径过深)或分支复杂(节点过大)时,父表达式预览自动省略。
54
+ - 详细窗口外仍然输出压缩占位,不展开上下文。
55
+
56
+ ## 验证
57
+
58
+ - `cargo check --bin cr` 通过。
59
+ - `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/compact.cirru query find --help`
60
+ - 可见 `--detail-offset` 参数。
61
+ - `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/compact.cirru query search --help`
62
+ - `--start-path` 示例为点号格式。
63
+ - `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/compact.cirru query search state -f respo.app.comp.todolist/comp-todolist --detail-offset 5`
64
+ - 输出降噪,路径为点号,窗口外压缩。
65
+ - `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/compact.cirru query search state -f respo.app.comp.todolist/comp-todolist --detail-offset 0`
66
+ - 详情窗口为 `[0, 3)`,每条命中仅展示一行(优先父节点预览)。
67
+ - `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/compact.cirru query search state -f respo.app.comp.todolist/comp-todolist --detail-offset 0 --exact`
68
+ - 精确命中不再把 `states` 视觉误判为 `state`;且不显示“add --exact”提示。
69
+ - `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/compact.cirru query search-expr state -f respo.app.comp.todolist/comp-todolist --detail-offset 0`
70
+ - 输出样式一致(单行预览)。
71
+ - `cargo run --bin cr -- /Users/jon.chen/repo/respo/respo/compact.cirru query search-expr state -f respo.app.comp.todolist/comp-todolist --detail-offset 0 --exact`
72
+ - 结果为 `No matches found`,符合结构精确匹配预期。
@@ -0,0 +1,71 @@
1
+ # Command Echo 主导的工具输出收敛与 tree replace 差异摘要
2
+
3
+ ## 变更概述
4
+
5
+ - 将 `cr` 的命令回显进一步固定为工具主语境:前置、单行、语义化参数展示。
6
+ - 为工具型命令引入更安静的 runtime 输出模式,避免版本、模块目录、模块加载、平台 API 注册等噪音干扰结果读取。
7
+ - 大范围清理 `docs/query/tree` 正文里对 `target/path/pattern/entry/deps` 的重复回显,统一交给 command echo 表达。
8
+ - 修正 `docs/CalcitAgent.md` 中示意性 Cirru 代码块的检查模式,避免 `check-md` 将结构示例误判为 runnable 程序。
9
+ - 单独重构 `tree replace` 输出:从“Preview + From/To”双份重复,改成“Changed node + Containing expression”的单次差异摘要。
10
+
11
+ ## 关键实现
12
+
13
+ - `src/bin/cr.rs`
14
+ - 在启用 command echo 时同步启用 `calcit::set_quiet_tool_output(true)`。
15
+ - 屏蔽工具模式下的运行环境提示:
16
+ - `calcit version`
17
+ - `module folder`
18
+ - `stack trace disabled`
19
+ - `running entry`
20
+
21
+ - `src/lib.rs`
22
+ - 新增全局 quiet flag:
23
+ - `set_quiet_tool_output(...)`
24
+ - `quiet_tool_output()`
25
+ - `load_module(...)` 在工具模式下不再打印 `loading: ...`。
26
+
27
+ - `src/bin/injection/mod.rs`
28
+ - `inject_platform_apis()` 在工具模式下不再打印 `registered platform APIs`。
29
+
30
+ - `src/bin/cli_handlers/docs.rs`
31
+ - `docs check-md` 不再重复回显 `entry/deps`。
32
+ - 移除只服务旧回显的路径展示 helper。
33
+
34
+ - `src/bin/cli_handlers/query.rs`
35
+ - 删除 `query def/peek/schema/examples/usages` 中重复的 target 标题。
36
+ - 删除 `query search/search-expr` 中重复的 pattern/filter/entry/start-path 摘要。
37
+ - `query find` 摘要从“重复 symbol”收敛为纯结果计数。
38
+
39
+ - `src/bin/cli_handlers/tree.rs`
40
+ - 删除 `tree show` 与多类 tree 写操作中的冗余 follow-up 命令提示。
41
+ - 删除成功文案里重复的 `path/target/pattern` 回显。
42
+ - `tree replace` 改为:
43
+ - `✓ Replaced node`
44
+ - `Changed node` 下单次展示 `Before/After`
45
+ - 非 root path 额外展示 `Containing expression`,帮助快速看出修改落点。
46
+
47
+ - `docs/CalcitAgent.md`
48
+ - 将示意性代码块改成 `cirru.no-check`,避免 `docs check-md` 因不存在的符号或非独立程序片段失败。
49
+
50
+ ## 输出策略结论
51
+
52
+ - 输入参数语境:由 `Command: ...` 统一承担。
53
+ - 正文输出:只保留结果、差异、结构上下文、或真正新增的信息。
54
+ - 不再在正文里重复打印 command echo 已经覆盖的 target/path/pattern/entry/deps。
55
+
56
+ ## 验证摘要
57
+
58
+ - `cargo fmt`
59
+ - `cargo run --bin cr -- calcit/test.cirru analyze js-escape 'demo?'`
60
+ - `cargo run --bin cr -- calcit/test.cirru analyze js-unescape 'demo_$q_'`
61
+ - `cargo run --bin cr -- calcit/test.cirru query ns app.main`
62
+ - `cargo run --bin cr -- calcit/test.cirru query find render`
63
+ - `cargo run --bin cr -- calcit/test.cirru tree show app.main/test-json -p ''`
64
+ - `cargo run --bin cr -- calcit/test.cirru docs search chunk -f agent-advanced.md`
65
+ - `cargo run --bin cr -- demos/compact.cirru docs check-md docs/CalcitAgent.md`
66
+ - `cargo run --bin cr -- /tmp/calcit-cli-demo/compact.cirru tree replace ...` 多次人工检查 replace 输出形态
67
+
68
+ ## 经验
69
+
70
+ - command echo 一旦语义化,就应把正文里的“参数再描述一遍”系统性删掉,否则会让工具输出看起来像教程而不是结果。
71
+ - tree 类命令相比简单成功提示,更需要“差异摘要 + 所在表达式”,这样既不冗余,也能快速判断改动是否落在预期结构。
@@ -0,0 +1,58 @@
1
+ # Docs frontmatter 与模块检索整理
2
+
3
+ ## 变更概述
4
+
5
+ - 为 `cr docs search/read/read-lines` 增加 `scope/module` 维度,支持核心文档、模块文档和跨域检索。
6
+ - 为 core docs 建立统一的 frontmatter 规范,并补充 `title/scope/kind/category/aliases/entry_for` 元数据。
7
+ - 将 `docs` 检索逻辑从纯文件名匹配升级为结合 frontmatter、路径、标题与条目词的综合解析与排序。
8
+ - 给文档系统补充规范页与验证页,方便后续扩展 `cr docs` 时保持行为稳定。
9
+ - 调整 Cirru 校验错误提示,让“其实是字符串”的场景给出更直接的修复建议。
10
+
11
+ ## 关键实现
12
+
13
+ - `src/cli_args.rs`
14
+ - 为 `docs search`、`docs read`、`docs read-lines` 增加 `--scope`、`--module` 参数。
15
+
16
+ - `src/bin/cli_handlers/command_echo.rs`
17
+ - 同步回显新增 docs 参数,确保工具模式下能看到完整检索上下文。
18
+
19
+ - `src/bin/cli_handlers/docs.rs`
20
+ - 引入 `GuideDocFrontmatter`、`GuideDocScope`、`DocsSearchScope`。
21
+ - 支持解析 Markdown frontmatter,并在加载时校验 `category`。
22
+ - 支持从 core docs 与 `~/.config/calcit/modules/<module>/docs/` 同时加载文档。
23
+ - 统一 `search/read/read-lines` 的查询解析逻辑,允许通过文件名、路径片段、标题、`aliases`、`entry_for` 命中目标。
24
+ - 增加更偏向 guide/reference 页的排序策略,减少 spec/索引页抢占结果。
25
+ - 抽出 `match_score`、`accumulate_match_score`、`parse_guide_doc` 等辅助函数,压缩主文件重复逻辑。
26
+
27
+ - `src/bin/cli_handlers/docs_tests.rs`
28
+ - 将 docs 相关测试从 `docs.rs` 拆出,单独维护解析、排序、模块加载与校验场景。
29
+
30
+ - `docs/docs-indexing.md`
31
+ - 固化 frontmatter 字段、分类注册表、scope 布局与 authoring 约束。
32
+
33
+ - `docs/docs-validation.md`
34
+ - 记录 `cr docs` 的可执行回归命令,覆盖 `search/read/read-lines` 与 module scope。
35
+
36
+ - `src/bin/cli_handlers/cirru_validator.rs`
37
+ - 当 token 更像“应写成字符串的文本”时,提示使用 `|text` 或 `"|text with spaces"`,减少样式值与括号文本误写的排查成本。
38
+
39
+ ## 文档整理原则
40
+
41
+ - `category` 只允许稳定注册值,避免搜索元数据失控膨胀。
42
+ - `aliases` 主要承接用户会直接输入的别名或术语,`entry_for` 主要承接命令/API/任务入口。
43
+ - `Agents.md` 与普通 docs 页复用同一套 frontmatter 机制,但渲染时默认隐藏元数据正文。
44
+ - 模块领域知识保留在模块 docs 中,Calcit core 只提供通用索引与加载能力,不内置 Respo 特殊语义。
45
+
46
+ ## 验证
47
+
48
+ - `cargo fmt`
49
+ - `cargo test docs --bin cr`
50
+ - 手动验证:
51
+ - `cargo run --bin cr -- docs search target-replace`
52
+ - `cargo run --bin cr -- docs search 'cr eval'`
53
+ - `cargo run --bin cr -- docs read polymorphism.md`
54
+
55
+ ## 后续经验
56
+
57
+ - docs 元数据一旦进入 CLI 行为,就应该配套规范页与验证页,否则后续加字段很容易出现“文档能写、检索却不稳定”的分叉。
58
+ - 模块文档检索要尽量和 core docs 走同一套 resolver,这样使用者不需要记两套命令心智模型。
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.12.11",
3
+ "version": "0.12.13",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.0.9",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.12.11",
3
+ "version": "0.12.13",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.0.9",