@calcit/procs 0.12.55 → 0.12.57

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.
Files changed (161) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/RFCs/07-31-unsafe-coerce-driven-static-type-boundary-plan.md +170 -0
  3. package/build.rs +36 -2
  4. package/editing-history/202607310224-strengthen-namespace-import-diagnostics.md +23 -0
  5. package/editing-history/202607311940-strengthen-unsafe-coerce-boundaries.md +20 -0
  6. package/editing-history/202608010103-warn-on-duplicate-imports.md +18 -0
  7. package/editing-history/202608010111-release-0.12.56.md +15 -0
  8. package/editing-history/202608011654-library-quality-gates.md +23 -0
  9. package/editing-history/202608011759-issue-routing-in-agent-guide.md +17 -0
  10. package/editing-history/202608011833-schema-type-symbols.md +20 -0
  11. package/editing-history/202608011852-wasm-dynamic-string-tag.md +7 -0
  12. package/editing-history/202608011908-consolidate-history.md +6 -0
  13. package/editing-history/202608012022-consolidate-cli-and-test-duplication.md +28 -0
  14. package/editing-history/202608012123-review-follow-up.md +18 -0
  15. package/editing-history/202608012320-release-0.12.57.md +5 -0
  16. package/editing-history/ARCHIVE.md +15 -0
  17. package/editing-history/README.md +21 -0
  18. package/lib/package.json +1 -1
  19. package/package.json +1 -1
  20. package/editing-history/2026-02-13-1841-trait-origin-structural-eq.md +0 -91
  21. package/editing-history/2026-02-14-2050-js-codegen-recursion-tag-migration.md +0 -39
  22. package/editing-history/2026-02-14-2358-emit-js-modularization-shift-left.md +0 -63
  23. package/editing-history/2026-02-15-0000-diagnostics-consolidated.md +0 -35
  24. package/editing-history/2026-02-15-1941-macro-diagnostics-refinement.md +0 -39
  25. package/editing-history/2026-02-16-2043-core-api-docs-cleanup.md +0 -40
  26. package/editing-history/2026-02-23-0834-migrate-to-defstruct.md +0 -91
  27. package/editing-history/2026-02-23-2321-ns-imports-code-fixes.md +0 -42
  28. package/editing-history/2026-02-25-0002-language-behavior-eval-mode.md +0 -93
  29. package/editing-history/2026-02-25-0111-guidebook-no-check-block-upgrades.md +0 -52
  30. package/editing-history/2026-02-25-0113-runtime-type-validation-and-macro-quoting.md +0 -41
  31. package/editing-history/2026-02-25-1131-check-md-eval-improvements.md +0 -13
  32. package/editing-history/2026-02-26-1324-check-md-inprocess-cache-and-path-labels.md +0 -7
  33. package/editing-history/2026-02-27-1640-unify-markdown-readers.md +0 -16
  34. package/editing-history/2026-02-27-1958-tree-rewrite-command-and-reference-model.md +0 -18
  35. package/editing-history/2026-02-27-2200-split-def-command.md +0 -29
  36. package/editing-history/2026-02-27-2212-tree-raise-wrap.md +0 -33
  37. package/editing-history/2026-02-27-2223-calcit-agent-docs-optimize.md +0 -41
  38. package/editing-history/2026-03-01-0212-query-search-entry-and-ffi-warning.md +0 -53
  39. package/editing-history/2026-03-03-1934-check-types-and-core-annotations.md +0 -17
  40. package/editing-history/2026-03-04-0000-generics-fn-typevar-identity.md +0 -30
  41. package/editing-history/2026-03-04-1331-tag-call-warning-and-dot-access-migration.md +0 -28
  42. package/editing-history/2026-03-04-1548-impl-new-dot-method-input-and-doc-hints.md +0 -33
  43. package/editing-history/2026-03-04-1645-calcit-eq-contract-refactor-and-macro-tests.md +0 -28
  44. package/editing-history/2026-03-04-2200-assert-type-assert-traits-composable-runtime-checks.md +0 -18
  45. package/editing-history/2026-03-05-0042-type-inference-argtypes-and-core-hints.md +0 -54
  46. package/editing-history/2026-03-05-0115-calcit-core-generic-refinements.md +0 -57
  47. package/editing-history/2026-03-05-1930-schema-migration-cr-edit.md +0 -30
  48. package/editing-history/2026-03-05-1939-query-schema-adaptation.md +0 -42
  49. package/editing-history/2026-03-06-0120-schema-hint-migration-batch.md +0 -38
  50. package/editing-history/2026-03-06-1416-core-macro-schema-migration.md +0 -20
  51. package/editing-history/2026-03-06-1552-core-schema-and-hintfn-migration.md +0 -63
  52. package/editing-history/2026-03-06-1936-schema-normalization-and-preprocess-preload.md +0 -12
  53. package/editing-history/2026-03-07-0000-migrate-hint-fn-to-schema.md +0 -29
  54. package/editing-history/2026-03-07-0000-remove-enum-prototype-field.md +0 -43
  55. package/editing-history/2026-03-07-0000-schema-args-type-enforcement.md +0 -66
  56. package/editing-history/2026-03-07-0142-unit-type-and-builtin-schemas.md +0 -82
  57. package/editing-history/2026-03-07-1652-decouple-snapshot-schema-to-calcit-type.md +0 -112
  58. package/editing-history/2026-03-07-1821-snapshot-schema-validation.md +0 -6
  59. package/editing-history/2026-03-07-1959-schema-def-kind-arity-validation.md +0 -96
  60. package/editing-history/2026-03-08-0031-schema-generics-quote-normalization.md +0 -35
  61. package/editing-history/2026-03-08-1905-schema-typeref-and-assert-migration.md +0 -34
  62. package/editing-history/2026-03-08-2033-schema-wrapper-migration.md +0 -45
  63. package/editing-history/2026-03-08-2315-late-schema-cleanup-and-warning-compat.md +0 -27
  64. package/editing-history/2026-03-09-1753-schema-type-fail-tests.md +0 -17
  65. package/editing-history/2026-03-10-1040-edit-schema-primitive-tag-support.md +0 -42
  66. package/editing-history/2026-03-10-1754-ns-entry-snapshot-migration.md +0 -66
  67. package/editing-history/2026-03-13-2216-validate-struct-type-arg-arity.md +0 -24
  68. package/editing-history/2026-03-16-2353-runtime-boundary-cleanup.md +0 -14
  69. package/editing-history/2026-03-17-0150-runtime-boundary-lookup-cleanup.md +0 -28
  70. package/editing-history/2026-03-20-0116-json-builtins-and-runtime-docs.md +0 -48
  71. package/editing-history/2026-03-26-2013-docs-frontmatter-and-module-search.md +0 -58
  72. package/editing-history/2026-04-07-1550-path-format-at-prefix-migration.md +0 -46
  73. package/editing-history/2026-04-12-1524-js-codegen-map-to-record.md +0 -26
  74. package/editing-history/2026-04-12-1549-map-to-record-field-validation.md +0 -29
  75. package/editing-history/2026-04-13-1600-tuple-to-enum-rewrite.md +0 -13
  76. package/editing-history/2026-04-13-2309-typeslot-enum-compile-safety.md +0 -45
  77. package/editing-history/2026-04-14-1500-loose-record-syntax.md +0 -32
  78. package/editing-history/2026-04-14-2259-bidir-type-check-refactor.md +0 -63
  79. package/editing-history/2026-04-15-0120-match-syntax-exhaustiveness.md +0 -20
  80. package/editing-history/2026-04-15-1211-record-nth-optimization.md +0 -44
  81. package/editing-history/2026-04-16-1936-predicate-narrowing-expansion.md +0 -31
  82. package/editing-history/2026-04-17-0132-monomorphize-map-filter.md +0 -50
  83. package/editing-history/2026-04-17-0135-monomorphize-includes-reverse.md +0 -31
  84. package/editing-history/2026-04-17-0140-fold-type-predicates.md +0 -44
  85. package/editing-history/2026-04-17-0154-generic-dispatch-records-tuples.md +0 -52
  86. package/editing-history/2026-04-17-0520-simplify-generic-defns-via-method-dispatch.md +0 -49
  87. package/editing-history/2026-05-21-0055-tree-show-cr-config-and-edit-cleanup.md +0 -81
  88. package/editing-history/2026-05-31-2052-macro-schema-roundtrip-and-weak-types.md +0 -6
  89. package/editing-history/2026-05-31-2105-map-generic-weak-types-followup.md +0 -15
  90. package/editing-history/2026-06-01-0003-update-callback-field-specialization.md +0 -19
  91. package/editing-history/2026-06-01-2317-data-definition-where-bounds.md +0 -6
  92. package/editing-history/2026-06-02-0114-data-definition-where-macro-followup.md +0 -21
  93. package/editing-history/2026-06-03-0000-check-md-edn-errors.md +0 -5
  94. package/editing-history/2026-06-03-1600-check-md-entry-modules.md +0 -6
  95. package/editing-history/2026-06-04-0000-check-md-app-main-init.md +0 -6
  96. package/editing-history/2026-06-04-2218-compiled-executable-runtime-backfill.md +0 -6
  97. package/editing-history/2026-06-09-0000-with-type-slot-scoped-binding.md +0 -83
  98. package/editing-history/2026-06-09-1241-remove-bind-type.md +0 -64
  99. package/editing-history/2026-06-09-1800-core-effect-tags.md +0 -57
  100. package/editing-history/2026-06-10-1200-get-def-doc-schema-builtin.md +0 -7
  101. package/editing-history/2026-06-15-1500-effects-graph-mvp.md +0 -30
  102. package/editing-history/2026-06-16-1700-effects-graph-ste-tree.md +0 -84
  103. package/editing-history/2026-06-27-0052-cli-improvements.md +0 -41
  104. package/editing-history/2026-06-27-0202-docs-indexing-improvements.md +0 -22
  105. package/editing-history/2026-06-27-0315-file-splits.md +0 -17
  106. package/editing-history/2026-06-27-0416-agent-advanced-split.md +0 -15
  107. package/editing-history/archived/2025-04-12-1453-map-to-record-rewrite.md +0 -33
  108. package/editing-history/archived/2025-04-16-0117-wasm-codegen-and-catalog-update.md +0 -40
  109. package/editing-history/archived/2025-07-16-0207-wasm-encoder-migration.md +0 -48
  110. package/editing-history/archived/2025-07-16-1633-wasm-data-structures.md +0 -61
  111. package/editing-history/archived/2026-02-13-1926-docs-tests-followup.md +0 -33
  112. package/editing-history/archived/2026-02-16-2128-docs-smoke-and-trait-errors.md +0 -20
  113. package/editing-history/archived/2026-02-25-1234-watch-mode-default-once.md +0 -5
  114. package/editing-history/archived/2026-03-07-1302-calcit-agent-docs-update.md +0 -32
  115. package/editing-history/archived/2026-03-09-1819-add-test-fail-script.md +0 -5
  116. package/editing-history/archived/2026-03-09-1944-split-type-fail-tests.md +0 -8
  117. package/editing-history/archived/2026-03-16-1449-profiling-tools-reorg.md +0 -13
  118. package/editing-history/archived/2026-03-17-2026-afternoon-runtime-boundary-optimization-summary.md +0 -87
  119. package/editing-history/archived/2026-03-18-1802-tips-level-and-overwrite-schema-preservation.md +0 -26
  120. package/editing-history/archived/2026-03-20-1229-query-window-3-with-parent-preview.md +0 -72
  121. package/editing-history/archived/2026-03-23-1137-command-echo-tool-output-cleanup.md +0 -71
  122. package/editing-history/archived/2026-04-10-0011-snapshot-empty-version-pipe-marker.md +0 -23
  123. package/editing-history/archived/2026-04-16-0131-wasm-math-and-test-integration.md +0 -28
  124. package/editing-history/archived/2026-04-16-1507-wasm-data-structures-and-rfc-rename.md +0 -27
  125. package/editing-history/archived/2026-04-16-1520-wasm-bitwise-and-match.md +0 -21
  126. package/editing-history/archived/2026-04-16-1542-wasm-cross-ns-host-imports.md +0 -38
  127. package/editing-history/archived/2026-04-17-0026-wasm-rest-args.md +0 -62
  128. package/editing-history/archived/2026-04-17-0048-wasm-type-of.md +0 -70
  129. package/editing-history/archived/2026-04-17-0051-wasm-derived-predicates.md +0 -34
  130. package/editing-history/archived/2026-04-17-2316-wasm-do-println-fixes.md +0 -41
  131. package/editing-history/archived/2026-04-18-1208-split-emit-wasm-and-bump-version.md +0 -15
  132. package/editing-history/archived/2026-04-18-1430-wasm-list-match-and-method-dispatch.md +0 -5
  133. package/editing-history/archived/2026-04-18-2041-cr-wasm-split-and-runtime-stability.md +0 -18
  134. package/editing-history/archived/2026-04-18-2045-v0.12.23-ci-wasm-fix.md +0 -13
  135. package/editing-history/archived/2026-04-21-1818-wasm-string-ops-v2.md +0 -57
  136. package/editing-history/archived/2026-04-21-2332-split-emit-wasm.md +0 -45
  137. package/editing-history/archived/2026-04-22-0114-wasm-hof-intercepts-and-set-intersection.md +0 -82
  138. package/editing-history/archived/2026-04-22-0136-wasm-enum-tuple-bool-str-fixes.md +0 -68
  139. package/editing-history/archived/2026-04-22-1340-wasm-map-diff-new-and-let-intercept.md +0 -53
  140. package/editing-history/archived/2026-04-23-1419-v0.12.26-wasm-bisection-fixes.md +0 -7
  141. package/editing-history/archived/2026-04-23-1645-release-conventions.md +0 -14
  142. package/editing-history/archived/2026-04-25-1940-wasm-suite-multi-module-entry.md +0 -53
  143. package/editing-history/archived/2026-04-25-2003-wasm-method-includes-string-and-set-refactor.md +0 -71
  144. package/editing-history/archived/2026-04-25-2010-wasm-suite-add-fn-lens-edn.md +0 -43
  145. package/editing-history/archived/2026-04-25-2051-display-by.md +0 -39
  146. package/editing-history/archived/2026-04-28-1728-fix-gensym-stable.md +0 -31
  147. package/editing-history/archived/2026-04-29-1400-fix-bind-type-precompile.md +0 -38
  148. package/editing-history/archived/2026-05-26-0957-match-docs-check-md.md +0 -24
  149. package/editing-history/archived/2026-05-31-2059-ci-docs-test-and-fn-helper-tightening.md +0 -3
  150. package/editing-history/archived/2026-06-01-0005-release-0.12.36.md +0 -16
  151. package/editing-history/archived/2026-06-01-2230-enum-struct-payload-docs.md +0 -4
  152. package/editing-history/archived/2026-06-03-1620-release-0.12.38.md +0 -6
  153. package/editing-history/archived/2026-06-04-0000-release-0.12.39.md +0 -4
  154. package/editing-history/archived/2026-06-04-2230-release-0.12.40.md +0 -5
  155. package/editing-history/archived/2026-06-12-1525-weak-types-dots-format.md +0 -15
  156. package/editing-history/archived/2026-06-13-1200-primitive_schema_tags.md +0 -9
  157. package/editing-history/archived/2026-06-20-1142-ts-declaration-d-mts.md +0 -5
  158. package/editing-history/archived/2026-06-29-0117-upgrade-doc-snapshot-migration.md +0 -2
  159. package/editing-history/archived/2026-06-29-calcit-cli.md +0 -80
  160. package/editing-history/archived/2026-06-29-typed-calcit-cli-schemas.md +0 -23
  161. package/editing-history/archived/20260630-duplication-analysis.md +0 -116
@@ -1,63 +0,0 @@
1
- # 2026-02-14 23:58 emit_js modularization + shift-left contracts
2
-
3
- ## Scope
4
-
5
- This round focuses on two tracks:
6
-
7
- 1. Continue low-risk modularization of `src/codegen/emit_js.rs` without changing runtime semantics.
8
- 2. Introduce AI-oriented "shift-left" validation contracts for expected warning/error paths.
9
-
10
- ## What changed
11
-
12
- ### Rust codegen modularization
13
-
14
- - Removed duplicate legacy module file:
15
- - `src/calcit/struct.rs`
16
- - Split helpers from `emit_js.rs` into cohesive submodules:
17
- - `src/codegen/emit_js/tags.rs`
18
- - `src/codegen/emit_js/symbols.rs`
19
- - `src/codegen/emit_js/paths.rs`
20
- - `src/codegen/emit_js/runtime.rs`
21
- - `src/codegen/emit_js/args.rs`
22
- - `src/codegen/emit_js/deps.rs`
23
- - `src/codegen/emit_js/helpers.rs`
24
- - Kept behavior stable by only moving logic and wiring imports/call sites.
25
- - Added targeted unit tests in extracted modules.
26
-
27
- ### Runtime helper boundary cleanup (TS)
28
-
29
- - Grouped runtime helpers into dedicated modules:
30
- - `ts-src/js-arity-helpers.mts` (`_args_throw`, `_args_fewer_throw`, `_args_between_throw`)
31
- - `ts-src/js-tag-helpers.mts` (`init_tags` + internal cache)
32
- - Switched `ts-src/calcit.procs.mts` to re-export these modules, keeping public API names unchanged.
33
-
34
- ### Test/validation workflow improvements
35
-
36
- - Added contract-based shift-left script:
37
- - `scripts/check-shift-left.mjs`
38
- - Added npm script:
39
- - `check-shift-left` in `package.json`
40
- - This script enforces both:
41
- - positive baseline must pass (`calcit/test.cirru -1`)
42
- - selected negative cases must fail with expected diagnostic tokens.
43
-
44
- ### Planning/documentation updates
45
-
46
- - Expanded and updated roadmap status:
47
- - `drafts/project-modernization-roadmap.md`
48
- - Added AI-oriented long-term section for:
49
- - immutable core constraints
50
- - earlier error detection
51
- - contractized diagnostics
52
- - staged execution strategy.
53
-
54
- ## Verification
55
-
56
- - Ran targeted unit tests for extracted modules (`tags/symbols/paths/runtime/args/deps/helpers` where applicable).
57
- - Repeated full validation with `yarn check-all` after each refactor batch.
58
- - Ran `yarn check-shift-left` to validate diagnostic contracts.
59
-
60
- ## Notes
61
-
62
- - Some standalone `calcit/test-*.cirru` files are intentionally warning/error reproductions or independent package entries; they are not safe to inline into `test.cirru` module list directly.
63
- - Using a separate shift-left contract script avoids namespace collisions and preserves intent.
@@ -1,35 +0,0 @@
1
- # 2026-02-15 diagnostics 合并记录
2
-
3
- 本文件合并以下 diagnostics 相关记录,避免碎片化:
4
-
5
- - 2026-0215-1011-preprocess-diagnostic-v1.md
6
- - 2026-0215-1026-cli-diag-json.md
7
- - 2026-0215-1104-diag-expected-actual-action-let.md
8
- - 2026-0215-1110-eval-diag-fallbacks.md
9
- - 2026-0215-1116-macro-diagnostic-protocol.md
10
- - 2026-0215-1134-macro-diag-expansion-if-defn-assert.md
11
- - 2026-0215-1152-runtime-fallback-tag-match-arity.md
12
- - 2026-0215-1202-warning-arity-fallback-compat.md
13
- - 2026-0215-1211-warning-learning-fields.md
14
- - 2026-0215-1238-convergence-help-docs-diag.md
15
- - 2026-0215-1306-text-diagnostics-convergence-fix.md
16
- - 2026-0215-1332-diagnostics-simplification-example-driven.md
17
-
18
- ## 合并后的结论(当前保留)
19
-
20
- - 已移除 `--diag json` 路径,CLI 统一使用文本诊断输出。
21
- - warning 维持最小字段与文本展示,不再维护 JSON 结构演进。
22
- - error 维持 call stack + examples 辅助定位,避免复杂规则映射。
23
- - 文本模式保持简洁:优先 message/hint/location/stack,便于直接修复。
24
-
25
- ## 本轮简化(减法)
26
-
27
- - 移除 warning 侧复杂增强字段:`fingerprint/convergence/help/learning`。
28
- - 移除 error 侧复杂增强字段:`fingerprint/convergence/help/learning` 与大段规则映射。
29
- - 将 error 的 expected/actual/action 处理改为“hint 优先 + 通用 message 提取 + 最小 fallback”。
30
-
31
- ## 设计原则(后续继续遵循)
32
-
33
- - 诊断能力优先复用编译器已有信息(hint、message、stack、examples)。
34
- - 尽量减少按错误码硬编码规则,避免语言层复杂度膨胀。
35
- - LLM 修复入口尽量通用化:`query examples` + 最小可执行动作。
@@ -1,39 +0,0 @@
1
- # Macro Diagnostics Refinement (2026-02-15 19:41)
2
-
3
- ## Summary
4
-
5
- This change improves diagnostic quality for macro misuse and warning flows without changing macro semantics.
6
-
7
- ## Key updates
8
-
9
- - Added a shared diagnostics helper module:
10
- - `src/diagnostics_help.rs`
11
- - Centralizes message-to-help inference logic.
12
- - Improved stack-rendered failure guidance:
13
- - `src/call_stack.rs`
14
- - Uses macro-context-aware help text.
15
- - Keeps examples targeting user-facing macros over internal helper macros.
16
- - Improved warning-path guidance:
17
- - `src/bin/cr.rs`
18
- - Reuses shared help inference for preprocessing/codegen warning blocks.
19
- - Improved macro argument binding diagnostics in runtime:
20
- - `src/runner.rs`
21
- - Replaces low-level `Idx(...)` style arity failures with readable signatures and missing argument names.
22
- - Refined macro-side error wording:
23
- - `src/cirru/calcit-core.cirru`
24
- - Better `list-match` branch-shape messages.
25
- - Kept macro signatures intact where requested:
26
- - `when`, `when-not`, `when-let` remain with explicit parameter forms.
27
-
28
- ## Validation
29
-
30
- - Spot checks executed with `cr eval` for macro misuse cases:
31
- - `when`, `when-not`, `when-let`, `if-not`, `tag-match`, `record-match`, `list-match`, `cond`, `let`, `thread-first`, `thread-last`.
32
- - Confirmed help text differentiates macro misuse vs proc/function arity warnings.
33
- - Full regression passed:
34
- - `yarn check-all` => `EXIT:0`.
35
-
36
- ## Notes
37
-
38
- - This iteration focuses on user-facing diagnostics quality.
39
- - Behavior and compatibility are preserved; changes are primarily in error/help reporting paths.
@@ -1,40 +0,0 @@
1
- # 2026-02-16 20:43 core API/docs cleanup
2
-
3
- ## Scope
4
-
5
- - Cleaned outdated draft references and status notes.
6
- - Aligned core internal API names around trait attachment (`*:impl-traits`).
7
- - Fixed `wo-js-log` export/definition mismatch.
8
- - Merged symbol-resolution note into drafts and removed duplicated doc file.
9
-
10
- ## Key updates
11
-
12
- 1. **drafts cleanup**
13
- - Added `drafts/README.md` as a state index (active/review-needed/archived).
14
- - Fixed stale links between `assert-types-plan.md` and `assert-types.md`.
15
- - Marked `drafts/last-session.md` as archived historical snapshot.
16
-
17
- 2. **core naming consistency**
18
- - Updated internal entries in `src/cirru/calcit-core.cirru`:
19
- - `&record:with-impls` -> `&record:impl-traits`
20
- - `&tuple:with-impls` -> `&tuple:impl-traits`
21
- - `&struct:with-impls` -> `&struct:impl-traits`
22
- - `&enum:with-impls` -> `&enum:impl-traits`
23
- - Updated `%::` doc hint to reference `&tuple:impl-traits`.
24
-
25
- 3. **debug macro fix**
26
- - Fixed `wo-js-log` entry to define `wo-js-log` (not `w-js-log`).
27
-
28
- 4. **symbol note consolidation**
29
- - Appended symbol-resolution appendix into `drafts/runtime-traits-plan.md`.
30
- - Removed duplicated `docs/symbol-spec.md` after migration.
31
-
32
- ## Validation notes
33
-
34
- - Verified `wo-js-log` evaluates successfully.
35
- - Verified `&struct:impl-traits` resolves as runtime proc.
36
- - Confirmed old `&struct:with-impls` now reports unknown symbol (no compatibility layer, by design).
37
-
38
- ## Follow-up
39
-
40
- - If needed, add explicit migration note/changelog entry for removed `*-with-impls` internal names.
@@ -1,91 +0,0 @@
1
- # 2026-0223-0834 — 迁移到 defstruct 方案并实现 `%{}?` 可选字段 Record 宏
2
-
3
- ## 背景
4
-
5
- 将 Calcit Record 系统从旧的 `new-record`/`defrecord`/`defrecord!` 方案全面迁移到基于 `defstruct` 的新方案,同时新增 `%{}?` / `&%{}?` 支持可选字段初始化与更新。
6
-
7
- ---
8
-
9
- ## 知识点一:`%{}?` 与 `&%{}?` 的语义设计
10
-
11
- `struct` 初始化为 record 时,部分字段在语义上是可选的,对应 TypeScript 中的 `{ a?: number; b?: number }`。原有的 `%{}` / `&%{}` 要求所有字段都必须显式传入。
12
-
13
- ### `%{}?`(macro)
14
-
15
- - 初始化 record 时允许省略字段,省略的字段自动填 `nil`。
16
- - 用法:`%{}? MyRecord (:x 1)`
17
-
18
- ### `&%{}?`(proc)
19
-
20
- `call_record_partial` 的语义:
21
-
22
- - **proto 是 Struct**:以全 `nil` 为基础 `values`,用传入的 k-v 覆盖对应位置。
23
- - 传入未知字段 → 报错;传入重复字段 → 报错;`(args_size - 1) % 2 != 0` → 报错。
24
-
25
- 关键实现细节:`CalcitStruct.fields` 元素类型是 `EdnTag`,比较时用 `f.ref_str()` 而非 `f.as_ref()`(后者无 `AsRef` impl)。
26
-
27
- ### `%{}?` 宏定义
28
-
29
- ```cirru
30
- defmacro %{}? (R & xs)
31
- if
32
- not $ and (list? xs) (every? xs list?)
33
- raise $ str-spaced "|%{}? expects field entries in list, got:" xs
34
- &let
35
- args $ &list:concat & xs
36
- quasiquote $ &%{}? ~R ~@args
37
- ```
38
-
39
- ---
40
-
41
- ## 知识点二:Rust proc 注册流程
42
-
43
- 新增一个内置 proc 需要同时修改四处:
44
-
45
- | 文件 | 修改内容 |
46
- | -------------------------- | -------------------------------------------------------- |
47
- | `src/calcit/proc_name.rs` | 添加枚举变体 `NativeRecordPartial` + `ProcTypeSignature` |
48
- | `src/builtins/records.rs` | 实现 `call_record_partial` 函数 |
49
- | `src/builtins.rs` | 在 `match proc` 中添加分发分支 |
50
- | `src/runner/preprocess.rs` | 将新 proc 加入"跳过 arity 检查"的 `matches!` 列表 |
51
-
52
- ---
53
-
54
- ## 知识点三:`%{}` 严格要求 Struct proto
55
-
56
- - `call_record`(`%{}`):若 proto 为 `Calcit::Record`,直接返回错误提示改用 `defstruct`。
57
- - `defstruct` 产生 `Calcit::Struct`(含 `field_types`),并作为 `%{}` / `%{}?` 的唯一原型来源。
58
-
59
- ### `&record:get-name` / `&record:struct` 的参数约束
60
-
61
- - 两者统一要求传入 `record`,避免 `struct` / `record` 混用语义。
62
-
63
- ### `&record:matches?` 的参数约束
64
-
65
- - 第一参数要求 `record`。
66
- - 第二参数接受 `record` 或 `struct`(用于 `record-match` 的模式匹配场景)。
67
-
68
- ---
69
-
70
- ## 修改文件
71
-
72
- | 文件 | 变更内容 |
73
- | ----------------------------- | ------------------------------------------------------------------------------------------------------------- |
74
- | `src/calcit/proc_name.rs` | 新增 `NativeRecordPartial` 枚举变体与类型签名;移除 `NewRecord` 变体 |
75
- | `src/builtins/records.rs` | 新增 `call_record_partial`(struct-only);`matches` 调整为 `(record, record/struct)`;移除 `new_record` 函数 |
76
- | `src/builtins.rs` | 分发 `NativeRecordPartial`;移除 `NewRecord` 分发 |
77
- | `src/runner/preprocess.rs` | arity 检查豁免新增 `NativeRecordPartial` |
78
- | `src/cirru/calcit-core.cirru` | 新增 `%{}?` 宏定义与 `&%{}?` 文档条目;`defrecord`/`defrecord!` 改为 raise error;删除 `new-record` 定义 |
79
- | `calcit/test-record.cirru` | Cat/BirdShape/Person/City/A/B/C/Demo 全部改为 `defstruct`;删除所有 `new-record` let 绑定;修复各测试函数体 |
80
- | `docs/CalcitAgent.md` | 类型标注示例中 `new-record` 改为 `defstruct` |
81
-
82
- ---
83
-
84
- ## 验证
85
-
86
- ```bash
87
- cargo run --bin cr -- calcit/test-record.cirru -1
88
- cargo clippy -- -D warnings
89
- ```
90
-
91
- 全部通过,无 warning。
@@ -1,42 +0,0 @@
1
- # 2026-0223 命名空间 imports 操作 Bug 修复
2
-
3
- ## 背景
4
-
5
- 通过在 `demos/calcit.cirru` 上逐一测试 `cr edit` 的 namespace 相关子命令,发现三处导致 Agent 频繁用错的根本原因。
6
-
7
- ## 发现的 Bug
8
-
9
- ### Bug 1:`imports --code 'rule'` 产生平坦结构,与 `extract_require_rules` 不兼容
10
-
11
- - **现象**:`imports --code 'respo.core :refer $ sym'` 成功,但之后执行 `add-import` 会丢失已有 imports
12
- - **根因**:`handle_imports` 手工拼接 `ns_code_items`(平坦 list),产生结构:
13
- ```
14
- ["ns", "my.ns", ":require", "respo.core", ":refer", "$", "sym"]
15
- ```
16
- 而 `extract_require_rules`/`build_ns_code` 期望嵌套结构:
17
- ```
18
- ["ns", "my.ns", [":require", ["respo.core", ":refer", "$", "sym"]]]
19
- ```
20
- 导致后续任何依赖 `extract_require_rules` 的操作(`add-import`、`rm-import`)全部解析不到已有规则。
21
- - **修复**:重写 `handle_imports` 的 rules 解析逻辑,统一调用 `build_ns_code` 生成嵌套结构。同时自动区分输入是单条规则(flat array of strings)还是多条规则(array of arrays)。
22
-
23
- ### Bug 2:`imports --code ':require ...'` 静默产生 `:require :require` 重复
24
-
25
- - **现象**:写 `:require respo.core :refer $ sym` 不报错,但生成 `ns my.ns :require :require respo.core ...`
26
- - **修复**:当 Cirru 解析后发现数组第一元素为 `:require` 字符串,立即返回错误消息,引导用户不包含 `:require` 前缀。
27
-
28
- ### Bug 3:`add-ns --code 'ns WRONG_NAME ...'` 名称不一致静默通过
29
-
30
- - **现象**:`cr edit add-ns my.ns --code 'ns wrong.ns ...'` 成功,file-key 是 `my.ns`,但 ns 声明内写的是 `wrong.ns`,导致 `query ns my.ns` 看到内部名称错误
31
- - **修复**:当输入解析为 `ns` 表达式时,校验第二个元素是否与位置参数一致,不一致则 Error。
32
-
33
- ## 修改文件
34
-
35
- - `src/bin/cli_handlers/edit.rs`:`handle_imports`、`handle_add_ns` 函数
36
-
37
- ## 知识点
38
-
39
- - `imports` 命令的 `--code` 输入格式:**不含 `:require` 前缀**,直接是规则体(`src-ns :refer $ sym`)。单条规则用 `--code`,多条规则用 `--file`(每行一条)或通过 stdin 传 JSON 数组(元素为数组)。
40
- - `add-import` 和 `imports` 的格式一致,都是 `src-ns :refer $ sym`(无 `:require` 前缀)。
41
- - `add-ns --code` 中若传完整 `ns` 表达式,内部名称必须与位置参数完全匹配。
42
- - 最佳实践:优先使用 `add-import`(带保护和覆盖控制),`imports` 只在需要全量重置时使用。
@@ -1,93 +0,0 @@
1
- # 2026-0225-0002 eval 模式下的语言行为要点
2
-
3
- 通过对 guidebook 文档代码块进行 eval 验证,发现以下 Calcit 运行时与预处理器的关键行为。
4
-
5
- ## `list-match` 仅适用于 List,不接受 Tuple
6
-
7
- `list-match` 的展开宏内部调用 `&list:slice`,该函数在 `src/builtins/lists.rs` 中要求输入为 `:list` 类型。
8
- 若传入 `::` 创建的 tuple,预处理阶段报 `Proc &list:slice arg 1 expects type :list, but got :tuple`。
9
-
10
- 正确用法只针对 list,且分支模式是 **`(head tail)`**,`tail` 是剩余元素组成的 list(不是按位置展开多个变量):
11
-
12
- ```cirru
13
- list-match ([] :point 10 20)
14
- () |Empty
15
- (h tl) ([] h tl)
16
- ; => ([] :point ([] 10 20))
17
- ```
18
-
19
- ## `.-field` 属性访问是 JS codegen 专用
20
-
21
- `.-x p` 这类属性访问在 `src/codegen/emit_js.rs` 中实现,Rust 解释器(`src/runner/`)没有对应路径。
22
- eval 模式下报:`method kind access (.-x) is only available in JS codegen, not supported in Rust runtime`.
23
-
24
- 替代方式:对 struct record 字段用 `(:field-name record)` 或 `get record :field-name`。
25
-
26
- ## 数值/字符串字面量在 fn 体内裸行的解析问题
27
-
28
- `fn`/`defn` 体内,一个字面量(数值 `3.14159` 或字符串 `|demo`)若单独占一行,Cirru 解析器会把该行当作以字面量为 head 的调用列表,从而报 `unknown head 3.14159` 或 `unknown head |demo`。
29
-
30
- 修复方式:加 `, ` 前缀强制作为数据表达式(expression terminator 后接值):
31
-
32
- ```cirru
33
- defn get-pi () :number
34
- , 3.14159
35
- ```
36
-
37
- ## `tag-match` 要求 defenum variant 的 payload 数量严格匹配
38
-
39
- `:ok` 无 payload 类型时,`%:: E :ok 42` 传 1 个值报:`enum variant ok expects 0 payload(s), but received: 1`。
40
- 需在 `defenum` 定义中声明对应类型:`defenum Result (:ok :number) (:err :string)`。
41
-
42
- 该检查在 `src/runner/` 中 `%::` 调用路径执行(运行时,非预处理)。
43
-
44
- ## 变量名遮蔽 calcit.core 时触发 warning 并中止 eval
45
-
46
- 预处理器对以下 core 名字的遮蔽一律报 warning,而 eval 模式将任何 warning 视为错误:
47
-
48
- - `first` → 遮蔽 `calcit.core/first`
49
- - `rest` → 遮蔽 `calcit.core/rest`
50
- - 宏参数名 `cond` → 遮蔽 `calcit.core/cond`(在 `defmacro when-not (cond & body)` 中出现)
51
-
52
- 命名建议:用 `n`, `tl`, `h`, `item` 等无冲突名。
53
-
54
- ## `let (x 1)` 单括号写法是无效语法
55
-
56
- Cirru `let` 绑定在 `src/runner/` 中要求双层 list `((name value) ...)` 形式。
57
- `let (x 1)` 单括号会得到 `expects pairs in list for let, got: ([] 'x 1)` 错误。
58
-
59
- 有效形式:
60
-
61
- ```cirru
62
- ; 多行缩进
63
- let
64
- x 1
65
- x
66
-
67
- ; 单行(需双括号)
68
- let ((x 1)) x
69
- ```
70
-
71
- ## deftrait/defimpl/defenum/defstruct 在 let 绑定中可正常执行
72
-
73
- 所有类型定义表达式都是普通可求值的形式(返回定义值),可放入 let 绑定:
74
-
75
- ```cirru
76
- let
77
- MyFoo $ deftrait MyFoo
78
- :foo $ :: :fn ('T) ('T) :string
79
- MyFooImpl $ defimpl MyFooImpl MyFoo
80
- :foo $ fn (p) (str-spaced |foo (:name p))
81
- Person0 $ defstruct Person (:name :string)
82
- Person $ impl-traits Person0 MyFooImpl
83
- p $ %{} Person (:name |Alice)
84
- .foo p
85
- ```
86
-
87
- 这使得在 eval/check-md snippet 中也能完整测试 trait dispatch,无需顶层 `ns/def` 定义。
88
- `def` 是顶层定义专用,eval 模式下不可用,需替换为 `let (Name $ ...)` 形式。
89
-
90
- ## 多行类型注解 tuple 在运行时报错
91
-
92
- `:: :fn ([] :number) :string` 的多行缩进形式中,最后 `:string` 独占一行,被运行时当作 field access 调用,导致错误。
93
- 紧凑单行形式 `(:: :fn ([] :number) :string)` 可运行。
@@ -1,52 +0,0 @@
1
- # Guidebook No-Check Block Upgrades (2026-02-25)
2
-
3
- ## 概要
4
-
5
- 对 Calcit guidebook (`/Users/chenyong/repo/calcit-lang/guidebook`) 中的代码块进行系统性升级,
6
- 将 `cirru.no-check` 标记替换为可验证的 `cirru` 或 `cirru.no-run` 块。
7
-
8
- ## 修改范围
9
-
10
- ### 1. `docs/features/static-analysis.md`
11
-
12
- **双重求值 Bug 修复**:
13
-
14
- - 原始代码:`assert= a ([] "b" 2 "a" 2)` 使用了导致误报的冗余赋值写法。
15
- - 修复为直接 `assert= (get xs :xs) ys` 模式,规避了 `$ (expr)` 双重求值陷阱。
16
- - 将 4 个 `cirru.no-check` 块正确转换为可运行/可类型检查的 `cirru` 块。
17
-
18
- **核心知识点**:在 `let` 绑定中 `x $ (f a)` 会将 `(f a)` 的结果再作为操作符调用,
19
- 必须改为 `x (f a)` 或省略 `$` 的形式。
20
-
21
- ### 2. `docs/features/tuples.md`
22
-
23
- **伪代码替换**:
24
-
25
- - 将 5 个含 `&tuple:with-class` 调用的 `cirru.no-check` 块全部移除或替换。
26
- - `&tuple:with-class` 已从语言中删除,不再作为公共 API 存在。
27
- - 涉及内部机制的 3 个伪代码块改为 `text` 或 `code` 块并加注释。
28
- - 保留可运行的 `cirru` 示例块(使用 `defrecord` / `defenum` 实际语法)。
29
-
30
- ### 3. `docs/features/common-patterns.md`
31
-
32
- - 将 3 个 `cirru.no-check` 块改为 `cirru.no-run`(语法正确但不运行的说明性代码)。
33
- - 涉及 `println` 副作用型示例以及占位符 `...` 形式的模板代码。
34
-
35
- ### 4. 其他文档
36
-
37
- - `docs/features/sets.md`, `docs/data/persistent-data.md`, `docs/features/hashmap.md` 等多处:
38
- - 将说明性 `cirru.no-check` 改为 `cirru.no-run`(语法正确、无副作用但不执行)。
39
- - 将可验证的示例改为 `cirru`(加入 `assert=` 或 `assert` 验证)。
40
-
41
- ## 测试结果
42
-
43
- 全量测试通过:`yarn check-all` → 188/188 ✅
44
-
45
- ## 相关知识点
46
-
47
- - **`cirru.no-check` vs `cirru.no-run` vs `cirru`**:
48
- - `cirru`:完全运行并类型检查,推断语法语义。
49
- - `cirru.no-run`:语法和类型检查,但不执行(适合副作用或模板代码)。
50
- - `cirru.no-check`:完全跳过检查(仅在代码不可验证时使用,如调用不存在的 API)。
51
- - **`check-md` 子命令**:`cr docs check-md <file>` 用于单文件验证,加快 debug 循环。
52
- - **双重求值陷阱**:`let` 中 `x $ (f a)` 等价于 `x ((f a))`,结果被再次调用,触发 "cannot be used as operator" 错误。
@@ -1,41 +0,0 @@
1
- # Runtime Type Validation & Macro Quoting Fix
2
-
3
- ## Summary
4
-
5
- Added runtime type validation for struct record and enum tuple creation. Fixed `defstruct`/`defenum` macros to support complex type annotations (e.g., `(:optional :string)`) by conditionally quoting list-type forms in macro expansion.
6
-
7
- ## Changes
8
-
9
- ### 1. Runtime Type Validation (`src/calcit/type_annotation.rs`)
10
-
11
- - Added `value_matches_type_annotation(value: &Calcit, expected: &CalcitTypeAnnotation) -> bool`
12
- - Checks if a runtime value matches a type annotation
13
- - Handles all annotation variants: Bool, Number, String, Tag, List, Map, Set, Ref, Buffer, Tuple, Record, Struct, Enum, Trait, Optional (allows nil), Dynamic (always true), TypeVar (always true), etc.
14
- - Added `brief_type_of_value(value: &Calcit) -> &'static str` for error messages
15
-
16
- ### 2. Type Checking at Record/Enum Creation
17
-
18
- - `src/builtins/records.rs`: Validates field values against struct `field_types` in:
19
- - `call_record_with_prototype` (`%{}`)
20
- - `call_record_partial` (`&%{}?`)
21
- - `record_with` (`&record:with`)
22
- - `record_from_map` (`&record:from-map`)
23
- - `src/builtins/meta.rs`: Validates enum payload values in `new_enum_tuple_no_class` (`%::`)
24
-
25
- ### 3. Macro Quoting Fix (`src/cirru/calcit-core.cirru`)
26
-
27
- **Problem**: `defstruct` and `defenum` are macros that expand to `&struct::new`/`&enum::new` (procs). Proc arguments are fully evaluated at runtime. Complex type annotations like `(:optional :string)` were evaluated as function calls (`(:optional :string)` → `(get :string :optional)` → error).
28
-
29
- **Fix**: Conditionally quote type annotations in the macro expansion:
30
-
31
- - List-type forms (e.g., `(:optional :string)`) are wrapped in `(quote ...)` to prevent evaluation
32
- - Tag/symbol forms (e.g., `:string`, `Status`) are left unquoted for normal evaluation/resolution
33
-
34
- ### 4. Test Updates (`calcit/test-record.cirru`)
35
-
36
- - `Lagopus0`: `:name :string` → `:name (:optional :string)`
37
- - `Person`: field types changed to `(:optional :type)` to support nil initialization
38
-
39
- ## Key Insight
40
-
41
- `defstruct`/`defenum` are macros → expand to proc calls (`&struct::new`/`&enum::new`) → args are evaluated before the handler receives them. Nested list type annotations must be quoted to survive evaluation, but symbol type references (e.g., enum/struct names) must NOT be quoted so they resolve correctly. The fix uses `(list? type-form)` to discriminate.
@@ -1,13 +0,0 @@
1
- # check-md and eval improvements
2
-
3
- - Added `docs check-md --dep` (repeatable) and forwarded deps to internal eval/check-only.
4
- - Added ns-first snippet handling in eval: merge `ns ...` tail nodes into `ns app.main`.
5
- - Added check-md hint when `cirru` blocks are fewer than `cirru.no-check` blocks.
6
-
7
- ## 2026-02-26 follow-up
8
-
9
- - Refactored `docs check-md` to run `cirru` / `cirru.no-run` / `cirru.no-check` in-process instead of spawning `cr` subprocesses for each block.
10
- - Added shared dependency/core loading cache in `check-md` so modules and core snapshot load once per markdown file, then reuse per block.
11
- - Kept warning/error details visible in failed block output while preserving pass/fail summary behavior.
12
- - Simplified path display in logs and header output for default modules: replaced absolute module root with `<mods>/...` placeholder.
13
- - Shortened displayed `entry` path in `check-md` header by preferring current-directory relative paths when available.
@@ -1,7 +0,0 @@
1
- # check-md in-process cache and path labels
2
-
3
- - Replaced process-per-block `docs check-md` execution with in-process Rust checks for `cirru`, `cirru.no-run`, and `cirru.no-check`.
4
- - Added shared cache for deps/core loading in `check-md`, reducing repeated module/core startup per markdown block.
5
- - Kept warning/error details visible in block-level failure output.
6
- - Replaced default module absolute path displays with `<mods>/...` in `loading:` logs and `check-md` deps preview.
7
- - Normalized `check-md` entry path display to prefer current-directory relative path.
@@ -1,16 +0,0 @@
1
- # 2026-02-27 16:40
2
-
3
- ## 知识点
4
-
5
- - 将 `docs read` / `docs agents` / `libs readme` 的 Markdown 读取行为统一到共享模块。
6
- - 共享能力包括:标题提取、章节匹配、`--full`、`--with-lines`、`--no-subheadings`、提示输出与无匹配错误处理。
7
- - `docs agents` 增加本地缓存刷新路径与长度展示,并复用统一渲染逻辑。
8
- - `libs readme` 对齐结构化读取参数,支持本地与远程 README 的一致体验。
9
-
10
- ## 改动概要
11
-
12
- - 新增 `src/bin/cli_handlers/markdown_read.rs`,沉淀可复用的 markdown section 渲染流程。
13
- - `src/bin/cli_handlers/docs.rs` 切换为共享渲染入口,并精简参数传递结构。
14
- - `src/bin/cli_handlers/libs.rs` 切换为共享渲染入口,收敛本地/远程 header 打印样板。
15
- - `src/bin/cli_handlers/mod.rs` 注册新模块。
16
- - `src/cli_args.rs` 对齐 `libs readme` 参数与 `docs` 系列的一致性。
@@ -1,18 +0,0 @@
1
- # 2026-02-27 19:58
2
-
3
- ## 知识点
4
-
5
- - `tree structural` 改名为动词化的 `tree rewrite`,更贴近“结构重写”语义,也更容易让 AI 模型理解用途。
6
- - `rewrite` 明确为**引用驱动**命令:必须提供至少一个 `--with name=path`,否则应提示改用 `tree replace`。
7
- - 结构引用从旧的 `--refer-*` 模型统一为 `--with` 映射模型(如 `--with self=.`, `--with rhs=2`),减少参数心智负担。
8
-
9
- ## 改动概要
10
-
11
- - CLI 路由与文案:`TreeSubcommand::Structural` 改为 `TreeSubcommand::Rewrite`,子命令名改为 `rewrite`。
12
- - `tree` handler:将 `handle_structural` 更名为 `handle_rewrite`,并更新输出提示与错误信息。
13
- - 结构引用处理:在 `tree` 中统一使用 `parse_with_references` + `process_node_with_references`。
14
- - 文档更新:`docs/CalcitAgent.md` 与 `Agents.md` 全部改用 `tree rewrite` 与 `--with` 示例。
15
- - 真实命令验证(基于 `demos/calcit.cirru`):
16
- - `tree replace` 可执行普通替换;
17
- - `tree rewrite` 无 `--with` 会按预期报错;
18
- - `tree rewrite` 携带 `--with` 可按预期执行。
@@ -1,29 +0,0 @@
1
- # 202602272200 — 新增 `edit split-def` 命令
2
-
3
- ## 改动概要
4
-
5
- 新增 `cr edit split-def <ns/def> --path <path> --name <new-name>` 命令,用于将某定义内指定路径的子表达式提取为同命名空间内的一个新定义,原位置替换为新定义的名字。
6
-
7
- ## 修改文件
8
-
9
- - `src/cli_args.rs`:新增 `EditSplitDefCommand` struct(参数:`target`, `--path`, `--name`);在 `EditSubcommand` 枚举中新增 `SplitDef(EditSplitDefCommand)` 变体。
10
- - `src/bin/cli_handlers/edit.rs`:import 增加 `EditSplitDefCommand`;dispatch 增加 `EditSubcommand::SplitDef`;实现 `handle_split_def` 函数。
11
- - `docs/CalcitAgent.md`:
12
- 1. 修复 `tree unwrap` 示例(移除已废弃的 `-i 1` 参数,更新描述为 splice 所有子节点语义)。
13
- 2. 在"结构化变更示例"中增加 `split-def` 的使用示例。
14
- 3. 在"定义操作"列表中增加 `cr edit split-def` 条目。
15
- 4. 新增"🔧 实战重构场景"章节,列举提取子表达式、rename、mv-def、mv/cp、unwrap/rewrite、批量批量重命名等常见重构操作的完整命令序列。
16
-
17
- ## 实现逻辑(`handle_split_def`)
18
-
19
- 1. 用 `navigate_to_path` 读取指定路径的子节点(`extracted`)。
20
- 2. 验证新名称在当前 ns 中不存在(不允许覆盖)。
21
- 3. 用 `apply_operation_at_path(..., "replace", Some(&leaf_new_name))` 将原定义的该路径替换为引用叶子节点。
22
- 4. 用 `CodeEntry::from_code(extracted)` 创建新定义,插入到同 ns 的 `defs` 中。
23
- 5. 保存 snapshot。
24
-
25
- ## 知识点
26
-
27
- - `split-def` 只操作 AST,不会自动添加 import。如果新定义需要被其他 ns 引用,需手动 `cr edit add-import`。
28
- - 路径索引规则与 `cr tree` 系列一致(逗号分隔,0-based)。
29
- - 提取后如需给新定义包装成 `defn` 函数形式,用 `cr tree replace <ns/new-name> --path '' --code 'quote (defn new-name (args...) ...)'`。
@@ -1,33 +0,0 @@
1
- # 202602272212 — 新增 `tree raise` 和 `tree wrap` 命令
2
-
3
- ## 改动概要
4
-
5
- 补齐两个 Lisp 社区(Paredit)常用的结构化编辑操作,完善 `cr tree` 命令集。
6
-
7
- ## 修改文件
8
-
9
- - `src/cli_args.rs`:新增 `TreeRaiseCommand`、`TreeWrapCommand` 结构体;在 `TreeSubcommand` 枚举中新增 `Raise`、`Wrap` 变体。
10
- - `src/bin/cli_handlers/tree.rs`:import 增加两个命令结构体;dispatch 增加两个分支;新增 `handle_raise` 和 `handle_wrap` 函数。
11
- - `docs/CalcitAgent.md`:更新主要操作列表、结构化变更示例、实战重构场景。
12
-
13
- ## 命令语义
14
-
15
- ### `cr tree raise <ns/def> --path <child-path>`
16
-
17
- 等价 Paredit `raise-sexp`。将指定子节点**整体替换掉其父节点**。
18
-
19
- - `path` 必须至少一个元素(才有父节点)
20
- - `parent_path = path[..n-1]`,用 `apply_operation_at_path(..., "replace", child)` 实现
21
- - 典型用途:去掉 `if` 只保留某分支、去掉 `let` 只保留最终返回值表达式
22
-
23
- ### `cr tree wrap <ns/def> --path <path> --code '<template>'`
24
-
25
- 等价 `cr tree rewrite ... --with 'self=.'`,但更简洁。模板中 `self` 自动绑定为原节点。
26
-
27
- - 适合"加一层调用"的常见模式:`wrap --code 'println self'`、`wrap --code 'let ((x self)) x'`
28
- - 当需要引用原节点的**子节点**(不只是整体)时,仍需用 `rewrite --with`
29
-
30
- ## 知识点
31
-
32
- - 三个互相对应的操作:`wrap`(包裹)→ `unwrap`(所有子节点展开)→ `raise`(单子节点替换父)
33
- - `wrap` 与 `rewrite` 的关系:`wrap` = `rewrite` 固定了 `self=.` 的语法糖,降低常用操作的命令复杂度