@calcit/procs 0.12.46 → 0.12.48
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/RFCs/02-17-register-platform-api-rfc.md +1 -0
- package/RFCs/06-15-effects-graph-rfc.md +499 -0
- package/RFCs/README.md +20 -18
- package/editing-history/2026-06-09-1800-core-effect-tags.md +57 -0
- package/editing-history/2026-06-15-1500-effects-graph-mvp.md +30 -0
- package/editing-history/2026-06-16-1700-effects-graph-ste-tree.md +84 -0
- package/editing-history/2026-06-27-0052-cli-improvements.md +41 -0
- package/editing-history/2026-06-27-0202-docs-indexing-improvements.md +22 -0
- package/editing-history/2026-06-27-0315-file-splits.md +17 -0
- package/editing-history/2026-06-27-0416-agent-advanced-split.md +15 -0
- package/editing-history/202607040040-fix-format-cirru-edn-quoting.md +14 -0
- package/editing-history/archived/2026-06-20-1142-ts-declaration-d-mts.md +5 -0
- package/editing-history/archived/2026-06-29-0117-upgrade-doc-snapshot-migration.md +2 -0
- package/editing-history/archived/2026-06-29-calcit-cli.md +80 -0
- package/editing-history/archived/2026-06-29-typed-calcit-cli-schemas.md +23 -0
- package/editing-history/archived/20260630-duplication-analysis.md +116 -0
- package/lib/calcit-data.d.mts +39 -0
- package/lib/calcit.procs.d.mts +306 -0
- package/lib/custom-formatter.d.mts +8 -0
- package/lib/js-arity-helpers.d.mts +3 -0
- package/lib/js-buf-list.d.mts +11 -0
- package/lib/js-cirru.d.mts +23 -0
- package/lib/js-cirru.mjs +2 -4
- package/lib/js-enum.d.mts +11 -0
- package/lib/js-impl.d.mts +15 -0
- package/lib/js-list.d.mts +61 -0
- package/lib/js-map.d.mts +60 -0
- package/lib/js-primes.d.mts +15 -0
- package/lib/js-record.d.mts +36 -0
- package/lib/js-ref.d.mts +12 -0
- package/lib/js-set.d.mts +23 -0
- package/lib/js-struct.d.mts +13 -0
- package/lib/js-tag-helpers.d.mts +2 -0
- package/lib/js-trait.d.mts +9 -0
- package/lib/js-tuple.d.mts +18 -0
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/ts-src/js-cirru.mts +2 -4
- /package/editing-history/{2026-0213-1841-trait-origin-structural-eq.md → 2026-02-13-1841-trait-origin-structural-eq.md} +0 -0
- /package/editing-history/{2026-0214-2050-js-codegen-recursion-tag-migration.md → 2026-02-14-2050-js-codegen-recursion-tag-migration.md} +0 -0
- /package/editing-history/{2026-0214-2358-emit-js-modularization-shift-left.md → 2026-02-14-2358-emit-js-modularization-shift-left.md} +0 -0
- /package/editing-history/{2026-0215-0000-diagnostics-consolidated.md → 2026-02-15-0000-diagnostics-consolidated.md} +0 -0
- /package/editing-history/{2026-0215-1941-macro-diagnostics-refinement.md → 2026-02-15-1941-macro-diagnostics-refinement.md} +0 -0
- /package/editing-history/{2026-0216-2043-core-api-docs-cleanup.md → 2026-02-16-2043-core-api-docs-cleanup.md} +0 -0
- /package/editing-history/{2026-0223-0834-migrate-to-defstruct.md → 2026-02-23-0834-migrate-to-defstruct.md} +0 -0
- /package/editing-history/{2026-0223-2321-ns-imports-code-fixes.md → 2026-02-23-2321-ns-imports-code-fixes.md} +0 -0
- /package/editing-history/{2026-0225-0002-language-behavior-eval-mode.md → 2026-02-25-0002-language-behavior-eval-mode.md} +0 -0
- /package/editing-history/{2026-0225-0111-guidebook-no-check-block-upgrades.md → 2026-02-25-0111-guidebook-no-check-block-upgrades.md} +0 -0
- /package/editing-history/{2026-0225-0113-runtime-type-validation-and-macro-quoting.md → 2026-02-25-0113-runtime-type-validation-and-macro-quoting.md} +0 -0
- /package/editing-history/{2026-0225-1131-check-md-eval-improvements.md → 2026-02-25-1131-check-md-eval-improvements.md} +0 -0
- /package/editing-history/{2026-0226-1324-check-md-inprocess-cache-and-path-labels.md → 2026-02-26-1324-check-md-inprocess-cache-and-path-labels.md} +0 -0
- /package/editing-history/{2026-0227-1640-unify-markdown-readers.md → 2026-02-27-1640-unify-markdown-readers.md} +0 -0
- /package/editing-history/{2026-0227-1958-tree-rewrite-command-and-reference-model.md → 2026-02-27-1958-tree-rewrite-command-and-reference-model.md} +0 -0
- /package/editing-history/{2026-0227-2200-split-def-command.md → 2026-02-27-2200-split-def-command.md} +0 -0
- /package/editing-history/{2026-0227-2212-tree-raise-wrap.md → 2026-02-27-2212-tree-raise-wrap.md} +0 -0
- /package/editing-history/{2026-0227-2223-calcit-agent-docs-optimize.md → 2026-02-27-2223-calcit-agent-docs-optimize.md} +0 -0
- /package/editing-history/{2026-0301-0212-query-search-entry-and-ffi-warning.md → 2026-03-01-0212-query-search-entry-and-ffi-warning.md} +0 -0
- /package/editing-history/{2026-0303-1934-check-types-and-core-annotations.md → 2026-03-03-1934-check-types-and-core-annotations.md} +0 -0
- /package/editing-history/{2026-0304-0000-generics-fn-typevar-identity.md → 2026-03-04-0000-generics-fn-typevar-identity.md} +0 -0
- /package/editing-history/{2026-0304-1331-tag-call-warning-and-dot-access-migration.md → 2026-03-04-1331-tag-call-warning-and-dot-access-migration.md} +0 -0
- /package/editing-history/{2026-0304-1548-impl-new-dot-method-input-and-doc-hints.md → 2026-03-04-1548-impl-new-dot-method-input-and-doc-hints.md} +0 -0
- /package/editing-history/{2026-0304-1645-calcit-eq-contract-refactor-and-macro-tests.md → 2026-03-04-1645-calcit-eq-contract-refactor-and-macro-tests.md} +0 -0
- /package/editing-history/{2026-0304-2200-assert-type-assert-traits-composable-runtime-checks.md → 2026-03-04-2200-assert-type-assert-traits-composable-runtime-checks.md} +0 -0
- /package/editing-history/{2026-0305-0042-type-inference-argtypes-and-core-hints.md → 2026-03-05-0042-type-inference-argtypes-and-core-hints.md} +0 -0
- /package/editing-history/{2026-0305-0115-calcit-core-generic-refinements.md → 2026-03-05-0115-calcit-core-generic-refinements.md} +0 -0
- /package/editing-history/{2026-0305-1930-schema-migration-cr-edit.md → 2026-03-05-1930-schema-migration-cr-edit.md} +0 -0
- /package/editing-history/{2026-0305-1939-query-schema-adaptation.md → 2026-03-05-1939-query-schema-adaptation.md} +0 -0
- /package/editing-history/{2026-0306-0120-schema-hint-migration-batch.md → 2026-03-06-0120-schema-hint-migration-batch.md} +0 -0
- /package/editing-history/{2026-0306-1416-core-macro-schema-migration.md → 2026-03-06-1416-core-macro-schema-migration.md} +0 -0
- /package/editing-history/{2026-0306-1552-core-schema-and-hintfn-migration.md → 2026-03-06-1552-core-schema-and-hintfn-migration.md} +0 -0
- /package/editing-history/{2026-0306-1936-schema-normalization-and-preprocess-preload.md → 2026-03-06-1936-schema-normalization-and-preprocess-preload.md} +0 -0
- /package/editing-history/{2026-0307-0000-migrate-hint-fn-to-schema.md → 2026-03-07-0000-migrate-hint-fn-to-schema.md} +0 -0
- /package/editing-history/{2026-0307-0000-remove-enum-prototype-field.md → 2026-03-07-0000-remove-enum-prototype-field.md} +0 -0
- /package/editing-history/{2026-0307-0000-schema-args-type-enforcement.md → 2026-03-07-0000-schema-args-type-enforcement.md} +0 -0
- /package/editing-history/{2026-0307-0142-unit-type-and-builtin-schemas.md → 2026-03-07-0142-unit-type-and-builtin-schemas.md} +0 -0
- /package/editing-history/{2026-0307-1652-decouple-snapshot-schema-to-calcit-type.md → 2026-03-07-1652-decouple-snapshot-schema-to-calcit-type.md} +0 -0
- /package/editing-history/{2026-0307-1821-snapshot-schema-validation.md → 2026-03-07-1821-snapshot-schema-validation.md} +0 -0
- /package/editing-history/{2026-0307-1959-schema-def-kind-arity-validation.md → 2026-03-07-1959-schema-def-kind-arity-validation.md} +0 -0
- /package/editing-history/{2026-0308-0031-schema-generics-quote-normalization.md → 2026-03-08-0031-schema-generics-quote-normalization.md} +0 -0
- /package/editing-history/{2026-0308-1905-schema-typeref-and-assert-migration.md → 2026-03-08-1905-schema-typeref-and-assert-migration.md} +0 -0
- /package/editing-history/{2026-0308-2033-schema-wrapper-migration.md → 2026-03-08-2033-schema-wrapper-migration.md} +0 -0
- /package/editing-history/{2026-0308-2315-late-schema-cleanup-and-warning-compat.md → 2026-03-08-2315-late-schema-cleanup-and-warning-compat.md} +0 -0
- /package/editing-history/{2026-0309-1753-schema-type-fail-tests.md → 2026-03-09-1753-schema-type-fail-tests.md} +0 -0
- /package/editing-history/{2026-0310-1040-edit-schema-primitive-tag-support.md → 2026-03-10-1040-edit-schema-primitive-tag-support.md} +0 -0
- /package/editing-history/{2026-0310-1754-ns-entry-snapshot-migration.md → 2026-03-10-1754-ns-entry-snapshot-migration.md} +0 -0
- /package/editing-history/{2026-0313-2216-validate-struct-type-arg-arity.md → 2026-03-13-2216-validate-struct-type-arg-arity.md} +0 -0
- /package/editing-history/{2026-0316-2353-runtime-boundary-cleanup.md → 2026-03-16-2353-runtime-boundary-cleanup.md} +0 -0
- /package/editing-history/{2026-0317-0150-runtime-boundary-lookup-cleanup.md → 2026-03-17-0150-runtime-boundary-lookup-cleanup.md} +0 -0
- /package/editing-history/{2026-0320-0116-json-builtins-and-runtime-docs.md → 2026-03-20-0116-json-builtins-and-runtime-docs.md} +0 -0
- /package/editing-history/{2026-0326-2013-docs-frontmatter-and-module-search.md → 2026-03-26-2013-docs-frontmatter-and-module-search.md} +0 -0
- /package/editing-history/{2026-0412-1524-js-codegen-map-to-record.md → 2026-04-12-1524-js-codegen-map-to-record.md} +0 -0
- /package/editing-history/{2026-0412-1549-map-to-record-field-validation.md → 2026-04-12-1549-map-to-record-field-validation.md} +0 -0
- /package/editing-history/{2026-0413-1600-tuple-to-enum-rewrite.md → 2026-04-13-1600-tuple-to-enum-rewrite.md} +0 -0
- /package/editing-history/{2026-0413-2309-typeslot-enum-compile-safety.md → 2026-04-13-2309-typeslot-enum-compile-safety.md} +0 -0
- /package/editing-history/{2026-0414-1500-loose-record-syntax.md → 2026-04-14-1500-loose-record-syntax.md} +0 -0
- /package/editing-history/{2026-0414-2259-bidir-type-check-refactor.md → 2026-04-14-2259-bidir-type-check-refactor.md} +0 -0
- /package/editing-history/{2026-0415-0120-match-syntax-exhaustiveness.md → 2026-04-15-0120-match-syntax-exhaustiveness.md} +0 -0
- /package/editing-history/{202604151211-record-nth-optimization.md → 2026-04-15-1211-record-nth-optimization.md} +0 -0
- /package/editing-history/{20260416-1936-predicate-narrowing-expansion.md → 2026-04-16-1936-predicate-narrowing-expansion.md} +0 -0
- /package/editing-history/{202604170132-monomorphize-map-filter.md → 2026-04-17-0132-monomorphize-map-filter.md} +0 -0
- /package/editing-history/{202604170135-monomorphize-includes-reverse.md → 2026-04-17-0135-monomorphize-includes-reverse.md} +0 -0
- /package/editing-history/{202604170140-fold-type-predicates.md → 2026-04-17-0140-fold-type-predicates.md} +0 -0
- /package/editing-history/{202604170154-generic-dispatch-records-tuples.md → 2026-04-17-0154-generic-dispatch-records-tuples.md} +0 -0
- /package/editing-history/{202604170520-simplify-generic-defns-via-method-dispatch.md → 2026-04-17-0520-simplify-generic-defns-via-method-dispatch.md} +0 -0
- /package/editing-history/{202605210055-tree-show-cr-config-and-edit-cleanup.md → 2026-05-21-0055-tree-show-cr-config-and-edit-cleanup.md} +0 -0
- /package/editing-history/{202605312052-macro-schema-roundtrip-and-weak-types.md → 2026-05-31-2052-macro-schema-roundtrip-and-weak-types.md} +0 -0
- /package/editing-history/{202605312105-map-generic-weak-types-followup.md → 2026-05-31-2105-map-generic-weak-types-followup.md} +0 -0
- /package/editing-history/{2026-0601-0003-update-callback-field-specialization.md → 2026-06-01-0003-update-callback-field-specialization.md} +0 -0
- /package/editing-history/{2026-0601-2317-data-definition-where-bounds.md → 2026-06-01-2317-data-definition-where-bounds.md} +0 -0
- /package/editing-history/{2026-0602-0114-data-definition-where-macro-followup.md → 2026-06-02-0114-data-definition-where-macro-followup.md} +0 -0
- /package/editing-history/{2026-0603-check-md-edn-errors.md → 2026-06-03-0000-check-md-edn-errors.md} +0 -0
- /package/editing-history/{2026-0603-1600-check-md-entry-modules.md → 2026-06-03-1600-check-md-entry-modules.md} +0 -0
- /package/editing-history/{2026-0604-check-md-app-main-init.md → 2026-06-04-0000-check-md-app-main-init.md} +0 -0
- /package/editing-history/{202606042218-compiled-executable-runtime-backfill.md → 2026-06-04-2218-compiled-executable-runtime-backfill.md} +0 -0
- /package/editing-history/{2026-0609-with-type-slot-scoped-binding.md → 2026-06-09-0000-with-type-slot-scoped-binding.md} +0 -0
- /package/editing-history/{2026-0609-1241-remove-bind-type.md → 2026-06-09-1241-remove-bind-type.md} +0 -0
- /package/editing-history/{2026-0610-1200-get-def-doc-schema-builtin.md → 2026-06-10-1200-get-def-doc-schema-builtin.md} +0 -0
- /package/editing-history/{2025-0412-1453-map-to-record-rewrite.md → archived/2025-04-12-1453-map-to-record-rewrite.md} +0 -0
- /package/editing-history/{202504160117-wasm-codegen-and-catalog-update.md → archived/2025-04-16-0117-wasm-codegen-and-catalog-update.md} +0 -0
- /package/editing-history/{202507160207-wasm-encoder-migration.md → archived/2025-07-16-0207-wasm-encoder-migration.md} +0 -0
- /package/editing-history/{202507161633-wasm-data-structures.md → archived/2025-07-16-1633-wasm-data-structures.md} +0 -0
- /package/editing-history/{2026-0213-1926-docs-tests-followup.md → archived/2026-02-13-1926-docs-tests-followup.md} +0 -0
- /package/editing-history/{2026-0216-2128-docs-smoke-and-trait-errors.md → archived/2026-02-16-2128-docs-smoke-and-trait-errors.md} +0 -0
- /package/editing-history/{2026-0225-1234-watch-mode-default-once.md → archived/2026-02-25-1234-watch-mode-default-once.md} +0 -0
- /package/editing-history/{2026-0307-1302-calcit-agent-docs-update.md → archived/2026-03-07-1302-calcit-agent-docs-update.md} +0 -0
- /package/editing-history/{2026-0309-1819-add-test-fail-script.md → archived/2026-03-09-1819-add-test-fail-script.md} +0 -0
- /package/editing-history/{2026-0309-1944-split-type-fail-tests.md → archived/2026-03-09-1944-split-type-fail-tests.md} +0 -0
- /package/editing-history/{2026-0316-1449-profiling-tools-reorg.md → archived/2026-03-16-1449-profiling-tools-reorg.md} +0 -0
- /package/editing-history/{2026-0317-2026-afternoon-runtime-boundary-optimization-summary.md → archived/2026-03-17-2026-afternoon-runtime-boundary-optimization-summary.md} +0 -0
- /package/editing-history/{2026-0318-1802-tips-level-and-overwrite-schema-preservation.md → archived/2026-03-18-1802-tips-level-and-overwrite-schema-preservation.md} +0 -0
- /package/editing-history/{2026-0320-1229-query-window-3-with-parent-preview.md → archived/2026-03-20-1229-query-window-3-with-parent-preview.md} +0 -0
- /package/editing-history/{2026-0323-1137-command-echo-tool-output-cleanup.md → archived/2026-03-23-1137-command-echo-tool-output-cleanup.md} +0 -0
- /package/editing-history/{2026-0410-0011-snapshot-empty-version-pipe-marker.md → archived/2026-04-10-0011-snapshot-empty-version-pipe-marker.md} +0 -0
- /package/editing-history/{202604160131-wasm-math-and-test-integration.md → archived/2026-04-16-0131-wasm-math-and-test-integration.md} +0 -0
- /package/editing-history/{202604161507-wasm-data-structures-and-rfc-rename.md → archived/2026-04-16-1507-wasm-data-structures-and-rfc-rename.md} +0 -0
- /package/editing-history/{202604161520-wasm-bitwise-and-match.md → archived/2026-04-16-1520-wasm-bitwise-and-match.md} +0 -0
- /package/editing-history/{202604161542-wasm-cross-ns-host-imports.md → archived/2026-04-16-1542-wasm-cross-ns-host-imports.md} +0 -0
- /package/editing-history/{20260417-0026-wasm-rest-args.md → archived/2026-04-17-0026-wasm-rest-args.md} +0 -0
- /package/editing-history/{202604170048-wasm-type-of.md → archived/2026-04-17-0048-wasm-type-of.md} +0 -0
- /package/editing-history/{202604170051-wasm-derived-predicates.md → archived/2026-04-17-0051-wasm-derived-predicates.md} +0 -0
- /package/editing-history/{202604172316-wasm-do-println-fixes.md → archived/2026-04-17-2316-wasm-do-println-fixes.md} +0 -0
- /package/editing-history/{202604181208-split-emit-wasm-and-bump-version.md → archived/2026-04-18-1208-split-emit-wasm-and-bump-version.md} +0 -0
- /package/editing-history/{202604181430-wasm-list-match-and-method-dispatch.md → archived/2026-04-18-1430-wasm-list-match-and-method-dispatch.md} +0 -0
- /package/editing-history/{202604182041-cr-wasm-split-and-runtime-stability.md → archived/2026-04-18-2041-cr-wasm-split-and-runtime-stability.md} +0 -0
- /package/editing-history/{202604182045-v0.12.23-ci-wasm-fix.md → archived/2026-04-18-2045-v0.12.23-ci-wasm-fix.md} +0 -0
- /package/editing-history/{202604211818-wasm-string-ops-v2.md → archived/2026-04-21-1818-wasm-string-ops-v2.md} +0 -0
- /package/editing-history/{202604212332-split-emit-wasm.md → archived/2026-04-21-2332-split-emit-wasm.md} +0 -0
- /package/editing-history/{2026-0422-0114-wasm-hof-intercepts-and-set-intersection.md → archived/2026-04-22-0114-wasm-hof-intercepts-and-set-intersection.md} +0 -0
- /package/editing-history/{2026-0422-0136-wasm-enum-tuple-bool-str-fixes.md → archived/2026-04-22-0136-wasm-enum-tuple-bool-str-fixes.md} +0 -0
- /package/editing-history/{202604221340-wasm-map-diff-new-and-let-intercept.md → archived/2026-04-22-1340-wasm-map-diff-new-and-let-intercept.md} +0 -0
- /package/editing-history/{202604231419-v0.12.26-wasm-bisection-fixes.md → archived/2026-04-23-1419-v0.12.26-wasm-bisection-fixes.md} +0 -0
- /package/editing-history/{202604231645-release-conventions.md → archived/2026-04-23-1645-release-conventions.md} +0 -0
- /package/editing-history/{202604251940-wasm-suite-multi-module-entry.md → archived/2026-04-25-1940-wasm-suite-multi-module-entry.md} +0 -0
- /package/editing-history/{202604252003-wasm-method-includes-string-and-set-refactor.md → archived/2026-04-25-2003-wasm-method-includes-string-and-set-refactor.md} +0 -0
- /package/editing-history/{202604252010-wasm-suite-add-fn-lens-edn.md → archived/2026-04-25-2010-wasm-suite-add-fn-lens-edn.md} +0 -0
- /package/editing-history/{202604252051-display-by.md → archived/2026-04-25-2051-display-by.md} +0 -0
- /package/editing-history/{202604281728-fix-gensym-stable.md → archived/2026-04-28-1728-fix-gensym-stable.md} +0 -0
- /package/editing-history/{202604291400-fix-bind-type-precompile.md → archived/2026-04-29-1400-fix-bind-type-precompile.md} +0 -0
- /package/editing-history/{2026-0526-0957-match-docs-check-md.md → archived/2026-05-26-0957-match-docs-check-md.md} +0 -0
- /package/editing-history/{202605312059-ci-docs-test-and-fn-helper-tightening.md → archived/2026-05-31-2059-ci-docs-test-and-fn-helper-tightening.md} +0 -0
- /package/editing-history/{2026-0601-0005-release-0.12.36.md → archived/2026-06-01-0005-release-0.12.36.md} +0 -0
- /package/editing-history/{2026-0601-2230-enum-struct-payload-docs.md → archived/2026-06-01-2230-enum-struct-payload-docs.md} +0 -0
- /package/editing-history/{2026-0603-1620-release-0.12.38.md → archived/2026-06-03-1620-release-0.12.38.md} +0 -0
- /package/editing-history/{2026-0604-release-0.12.39.md → archived/2026-06-04-0000-release-0.12.39.md} +0 -0
- /package/editing-history/{202606042230-release-0.12.40.md → archived/2026-06-04-2230-release-0.12.40.md} +0 -0
- /package/editing-history/{202606121525-weak-types-dots-format.md → archived/2026-06-12-1525-weak-types-dots-format.md} +0 -0
- /package/{202606131200_primitive_schema_tags.md → editing-history/archived/2026-06-13-1200-primitive_schema_tags.md} +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# effects-graph STE Tree 格式改进
|
|
2
|
+
|
|
3
|
+
日期: 2026-06-16
|
|
4
|
+
|
|
5
|
+
## 问题
|
|
6
|
+
|
|
7
|
+
`cr analyze effects-graph` 默认 `sketch` 格式产出的是项目级鸟瞰图(调用树+聚合 effect/state),而非 RFC 预想的 per-function State/Transform/Effect 分解图。用户无法通过输出快速理解单个函数的功能。
|
|
8
|
+
|
|
9
|
+
## 改动
|
|
10
|
+
|
|
11
|
+
### 1. State 提取:从操作名改为目标名
|
|
12
|
+
|
|
13
|
+
`record_state_operator` 原先记录操作名(如 `swap!`),现改为提取目标 atom 名称(如 `*store`)。
|
|
14
|
+
|
|
15
|
+
- 新增 `extract_state_target(list, op_name)` 从 AST 列表中提取第一个参数
|
|
16
|
+
- `swap!/reset!/deref/set!` → 提取第一个参数名
|
|
17
|
+
- `defatom/atom` → 提取第一个参数名
|
|
18
|
+
- 修改 `walk_expr` → `inspect_call_head` 传参,传入完整 list
|
|
19
|
+
|
|
20
|
+
### 2. Effect 分类:添加 Respo 约定函数
|
|
21
|
+
|
|
22
|
+
`classify_by_name` 新增:
|
|
23
|
+
- `render-app!/mount-app!/rerender-app!/clear-cache!/realize-ssr!` → `render`
|
|
24
|
+
- `send-to-component!/dispatch!` → `lifecycle`
|
|
25
|
+
- `save-store!` → `storage`
|
|
26
|
+
|
|
27
|
+
`heuristic_effect_kinds` 优化:
|
|
28
|
+
- `unknown/effect!` → `effect`(更简洁)
|
|
29
|
+
- 函数名含 `load/init/setup` 时归类为 `io`
|
|
30
|
+
|
|
31
|
+
`set!` 加入 `is_state_operator` 和 early-return 列表(之前会被误分类为 effect)
|
|
32
|
+
|
|
33
|
+
### 3. 深度截断节点保留分析
|
|
34
|
+
|
|
35
|
+
原先 `max_depth` 到达时直接返回空壳节点(`empty_shell_node`)。
|
|
36
|
+
现改为:始终执行 `analyze_code` 提取 state/effects/transform,仅在 children 构建时跳过。
|
|
37
|
+
新增 `depth_exceeded` 字段标记截断节点。
|
|
38
|
+
|
|
39
|
+
### 4. STE Tree 格式(`--format tree`)
|
|
40
|
+
|
|
41
|
+
新增 `format_as_ste_tree` 函数,输出每个函数的 State/Transform/Effect 树形分解:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
└── respo.main/main! [program]
|
|
45
|
+
├── State
|
|
46
|
+
│ ├── atom *store (write)
|
|
47
|
+
│ ├── return unit
|
|
48
|
+
│ └── watch *store
|
|
49
|
+
├── Transform (calls: 3)
|
|
50
|
+
│ ├── → respo.app.core/render-app!
|
|
51
|
+
│ └── → respo.main/save-store!
|
|
52
|
+
└── Effects
|
|
53
|
+
├── console println
|
|
54
|
+
├── render render-app!
|
|
55
|
+
└── storage save-store!
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- `[program]` = 含 effect 的函数
|
|
59
|
+
- `[transform]` = 纯变换函数
|
|
60
|
+
- `[depth limit ↑]` = 深度截断(有分析但无子节点)
|
|
61
|
+
- `(summary)` = 折叠节点的单行摘要(doc + effects)
|
|
62
|
+
|
|
63
|
+
`cr.rs` 中 `format=tree` 调度改为 `format_as_ste_tree`(原为 `format_for_llm` mermaid)。
|
|
64
|
+
|
|
65
|
+
### 5. 其他修复
|
|
66
|
+
|
|
67
|
+
- `birdview_state_labels` 匹配逻辑修复(kind 匹配而非 name 匹配)
|
|
68
|
+
- `effect_channel_name` 新增 `storage`/`lifecycle` 通道映射
|
|
69
|
+
- `ste_state_detail` 对 `return` 类型简化显示(仅类型,不显 "return" 前缀)
|
|
70
|
+
- `node_transform_summary` 修复 doc 与 summary 重复问题
|
|
71
|
+
- `empty_shell_node` 函数删除(不再使用)
|
|
72
|
+
|
|
73
|
+
## 涉及文件
|
|
74
|
+
|
|
75
|
+
- `src/effects_graph.rs` — 主要改动
|
|
76
|
+
- `src/bin/cr.rs` — tree 格式调度
|
|
77
|
+
- `src/cli_args.rs` — 无改动(格式字符串不变)
|
|
78
|
+
|
|
79
|
+
## 验证
|
|
80
|
+
|
|
81
|
+
- `cargo test effects_graph` — 5/5 通过
|
|
82
|
+
- `cargo clippy -- -D warnings` — 通过
|
|
83
|
+
- `yarn compile` — 通过
|
|
84
|
+
- `cr analyze effects-graph --format tree` on respo — 产出可用的 per-function STE 分解
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
## CLI 改进: target-replace → search-replace, 新增 batch-delete, --parent-path
|
|
2
|
+
|
|
3
|
+
### 改动机
|
|
4
|
+
根据 pudica-schedule-viewer 升级过程中暴露的多次 cr 命令使用痛点:
|
|
5
|
+
|
|
6
|
+
1. `target-replace` 命名不直观("目标替换"不如"搜索替换"清晰)
|
|
7
|
+
2. 连续删除多个属性时需要手动从高到低删除,容易出错
|
|
8
|
+
3. 搜索结果的路径是叶子路径,用户需要手动去掉末尾索引得到可编辑父路径
|
|
9
|
+
4. map 属性中用 `$` 编辑的规则未在文档中明确
|
|
10
|
+
|
|
11
|
+
### 改动清单
|
|
12
|
+
|
|
13
|
+
**src/cli_args.rs:**
|
|
14
|
+
- `TargetReplace(TreeTargetReplaceCommand)` → `SearchReplace(TreeSearchReplaceCommand)`
|
|
15
|
+
- `#[argh(subcommand, name = "target-replace")]` → `#[argh(subcommand, name = "search-replace")]`
|
|
16
|
+
- 新增 `BatchDelete(TreeBatchDeleteCommand)` 枚举变体
|
|
17
|
+
- 新增 `TreeBatchDeleteCommand` 结构体(`-p` 接受多个路径)
|
|
18
|
+
- `QuerySearchCommand` 新增 `--parent-path` 开关
|
|
19
|
+
|
|
20
|
+
**src/bin/cli_handlers/tree.rs:**
|
|
21
|
+
- `handle_target_replace` → `handle_search_replace`
|
|
22
|
+
- 新增 `handle_batch_delete`: 按路径降序依次调用 `handle_delete`
|
|
23
|
+
|
|
24
|
+
**src/bin/cli_handlers/query.rs:**
|
|
25
|
+
- `SearchCommonOpts` 新增 `parent_path: bool` 字段
|
|
26
|
+
- 搜索结果中 `--parent-path` 开启时额外打印父路径
|
|
27
|
+
|
|
28
|
+
**src/bin/cli_handlers/command_echo.rs:**
|
|
29
|
+
- 更新所有 `TargetReplace` → `SearchReplace` 分发
|
|
30
|
+
- 新增 `BatchDelete` 的三个 match arm
|
|
31
|
+
|
|
32
|
+
**src/bin/cli_handlers/edit.rs:**
|
|
33
|
+
- 错误提示 `target-replace` → `search-replace`
|
|
34
|
+
|
|
35
|
+
**src/bin/cli_handlers/docs_tests.rs:**
|
|
36
|
+
- 测试数据中 `target-replace` → `search-replace`
|
|
37
|
+
|
|
38
|
+
**docs/CalcitAgent.md + 其他文档:**
|
|
39
|
+
- 所有 `target-replace` 替换为 `search-replace`
|
|
40
|
+
- 新增 `batch-delete` 和 `--parent-path` 用法说明
|
|
41
|
+
- 新增 `$` 在属性 map 中的编辑指南
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
## 文档索引改进: abstract 字段 + --summary 模式 + Hub 标记
|
|
2
|
+
|
|
3
|
+
### 改动内容
|
|
4
|
+
|
|
5
|
+
**P0: abstract/summary 字段**
|
|
6
|
+
- `GuideDocFrontmatter` 新增 `summary: Option<String>` 字段
|
|
7
|
+
- `parse_doc_frontmatter` 支持解析 `summary:` 键值对
|
|
8
|
+
- `score_metadata_hit` 加入 summary 评分(exact 200,contains 130)
|
|
9
|
+
- 8 个核心文档已添加 summary 描述
|
|
10
|
+
|
|
11
|
+
**P0: `cr docs search --summary` 模式**
|
|
12
|
+
- `DocsSearchCommand` 新增 `--summary` 开关
|
|
13
|
+
- 搜索时只显示文档标题 + summary,不输出内容片段
|
|
14
|
+
- 无 summary 的文档显示 `(no summary)`
|
|
15
|
+
|
|
16
|
+
**P0: Hub 标记**
|
|
17
|
+
- 搜索结果中 `kind: hub` 的文档显示 `[Hub]` 前缀
|
|
18
|
+
- 帮助 LLM 快速识别导航页 vs 详细页
|
|
19
|
+
|
|
20
|
+
**文档更新**
|
|
21
|
+
- `docs-indexing.md` 新增 `summary` 字段规范说明和 `--summary` 用法
|
|
22
|
+
- `docs-validation.md` 新增 `--summary` 和 hub 标记的验证用例
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
## 文档拆分: agent-advanced.md 和 CalcitAgent.md 的部分内容拆成独立文件
|
|
2
|
+
|
|
3
|
+
### 改动内容
|
|
4
|
+
|
|
5
|
+
**从 `run/agent-advanced.md` 拆分:**
|
|
6
|
+
- `## 快速开始` 节 (原 lines 24-58) → 新建 `run/quick-start.md` (47行)
|
|
7
|
+
- 原文替换为交叉链接
|
|
8
|
+
|
|
9
|
+
**从 `CalcitAgent.md` 拆分:**
|
|
10
|
+
- `calcit.cirru EDN 结构` + `deps.cirru` 两节 (原 lines 156-231) → 新建 `run/project-structure.md` (82行)
|
|
11
|
+
- `结构化策略(5 招)` 节 → 新建 `run/structural-strategies.md` (53行)
|
|
12
|
+
- 原文替换为交叉链接
|
|
13
|
+
|
|
14
|
+
### 新文件
|
|
15
|
+
- `docs/run/quick-start.md` — 新 LLM 快速开始工作流
|
|
16
|
+
- `docs/run/project-structure.md` — calcit.cirru EDN 结构 + deps.cirru
|
|
17
|
+
- `docs/run/structural-strategies.md` — cp/mv/wrap/raise/rewrite 策略
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## agent-advanced.md 拆分: CLI 命令和语言基础节替换为交叉链接, 开发调试拆出独立文件
|
|
2
|
+
|
|
3
|
+
### 改动
|
|
4
|
+
|
|
5
|
+
**`run/agent-advanced.md` 精简 (1598→807 行, ~49%):**
|
|
6
|
+
|
|
7
|
+
- `## Calcit CLI 命令` 节 (~508行): 替换为独立文件链接列表,保留 `LLM 辅助:动态方法提示` 和 `复杂表达式分段组装策略` 两个独特子节
|
|
8
|
+
- `## Calcit 语言基础` 节 (~266行): 替换为 cirru-syntax.md / features/tuples.md / features/static-analysis.md 链接,保留 `其他易错点`
|
|
9
|
+
- `## 开发调试` 节 (~99行): 拆出为独立 `run/debugging.md`
|
|
10
|
+
|
|
11
|
+
**新增文件:**
|
|
12
|
+
- `run/debugging.md` — watcher 监听模式、增量更新、编译检查
|
|
13
|
+
|
|
14
|
+
### 删除的重复内容
|
|
15
|
+
CLI 命令和语言基础的子节内容在 `run/query.md`、`run/edit-tree.md`、`cirru-syntax.md`、`features/static-analysis.md` 等文件中已有完整覆盖。
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## fix format-cirru-edn missing quotes for strings with spaces in JS codegen
|
|
2
|
+
|
|
3
|
+
### 问题
|
|
4
|
+
`format-cirru-edn` 在 JS runtime 中对含空格的字符串(如 `"a b"`)输出缺少外层双引号,产生 `|a b` 而非正确的 `"|a b"`。
|
|
5
|
+
|
|
6
|
+
### 定位
|
|
7
|
+
`ts-src/js-cirru.mts:439` — `format_cirru_edn` 对字符串类型直接拼接 `"\ndo " + to_cirru_edn(data)`,跳过了 `writer.ts` 中 `generateLeaf` 的 `JSON.stringify` 引号回退逻辑。
|
|
8
|
+
|
|
9
|
+
### 修复
|
|
10
|
+
改为走 `writeCirruCode([[to_cirru_edn(data)]])` → `generateLeaf` 路径,利用已有的字符合法性检查(`isCharAllowed`)决定是否加引号。同时保持 `\ndo ... \n` 外围格式与 Rust 版本一致。
|
|
11
|
+
|
|
12
|
+
### 文件变更
|
|
13
|
+
- `ts-src/js-cirru.mts` — 字符串分支改用 `writeCirruCode` 格式化
|
|
14
|
+
- `calcit/test-edn.cirru` — 新增含空格字符串和无空格字符串的测试用例
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
- `tsconfig.json` 添加 `declaration: true`,使 `yarn compile` 生成 `.d.mts` 类型声明文件
|
|
2
|
+
- `yarn compile` 后 `lib/` 中与 `.mjs` 一一对应生成 18 个 `.d.mts` 文件
|
|
3
|
+
- `.npmignore` 不排除 `lib/`,这些声明文件在 npm publish 时会被包含
|
|
4
|
+
- 对 hovenia-editor:移除手动 `calcit-procs.d.ts`,改用上游生成的 `.d.mts`
|
|
5
|
+
- 本地验证:`cargo fmt` `cargo clippy` `yarn compile` `cargo test` `yarn check-all` 全部通过
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
- docs/run/upgrade.md: added snapshot migration section — documents the transition from two-file setup (calcit.cirru snapshot + compact.cirru compact code) to single calcit.cirru with compact code only, no separate snapshot file needed
|
|
2
|
+
- Recommended: delete old snapshot file, compact code saved directly in calcit.cirru for cr command to use directly
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# calcit.cli / cr exec 完整实现
|
|
2
|
+
|
|
3
|
+
## 概要
|
|
4
|
+
|
|
5
|
+
实现 `cr exec` + `calcit.cli/*` 内建函数(共 77 个),让 Agent 用 Cirru heredoc 调用常用 `cr query` / `edit` / `tree` / `analyze` / `docs` 能力,绕开 Shell 转义。RFC:`RFCs/06-29-cr-exec-cli-builtins-rfc.md`。
|
|
6
|
+
|
|
7
|
+
## 架构
|
|
8
|
+
|
|
9
|
+
- **运行时**:`src/bin/injection/mod.rs` 注册 handler;**单一 options map 参数**(arity 1)
|
|
10
|
+
- **参数解析**:`calcit_cli_args.rs` — `resolve_cli_args`、类型 coercion、默认值填充、command echo
|
|
11
|
+
- **参数规格**:`calcit_cli_specs.rs` — 每个函数的 `CliArgSpec` 列表(语义化键名)
|
|
12
|
+
- **元数据**:`src/cirru/calcit-core.cirru` 的 `|calcit.cli` — schema 为 `(:args $ [] (:: :map :tag :dynamic))`
|
|
13
|
+
- **同步**:`python3 scripts/gen_calcit_cli_core.py`(从 mod.rs + calcit_cli_specs.rs 生成)
|
|
14
|
+
- **约束**:`calcit_cli*` 不得依赖 `cli_handlers`(保证 `cr-wasm` 可编译)
|
|
15
|
+
|
|
16
|
+
### 调用约定(2026-06-29 重构)
|
|
17
|
+
|
|
18
|
+
```cirru
|
|
19
|
+
calcit.cli/peek-def $ {} (:file-path |calcit.cirru) (:target |app.main/main!)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- 唯一参数为 options map;键为 tag(`:file-path`、`:target`、`:lines` 等)
|
|
23
|
+
- 省略的可选键由 Rust 侧默认值填充;非 quiet 模式下 stderr echo 展示完整调用(含默认值)
|
|
24
|
+
- 位置参数已移除(breaking change)
|
|
25
|
+
|
|
26
|
+
| 文件 | 职责 |
|
|
27
|
+
|------|------|
|
|
28
|
+
| `calcit_cli_args.rs` | map 解析、echo、docs_hint 生成 |
|
|
29
|
+
| `calcit_cli_specs.rs` | 77 个函数的参数 spec 常量 |
|
|
30
|
+
| `calcit_cli.rs` | 基础 query/write、snapshot 读写、`load_calcit_snapshot_with_deps` |
|
|
31
|
+
| `calcit_cli_tree.rs` | AST 树变换(delete/insert/wrap/cp/mv…) |
|
|
32
|
+
| `calcit_cli_extra.rs` | edit/config/cirru 工具、trigger-inc、semver bump |
|
|
33
|
+
| `calcit_cli_program.rs` | 加载 snapshot+modules+core 并 preprocess(analyze/validate) |
|
|
34
|
+
| `calcit_cli_analyze.rs` | call/effects/count + check-types/weak-types |
|
|
35
|
+
| `calcit_cli_query.rs` | show-pkg/ns、list-defs-by-tag、validate-file、search-*、list-host-procs |
|
|
36
|
+
| `calcit_cli_docs.rs` | docs-agents/read/sections |
|
|
37
|
+
| `src/type_coverage.rs` | check-types / weak-types 共享逻辑(`cr analyze` 与 calcit.cli 共用) |
|
|
38
|
+
|
|
39
|
+
## 分批功能(合并记录)
|
|
40
|
+
|
|
41
|
+
### 第一批:树/定义/import 写操作(17)
|
|
42
|
+
|
|
43
|
+
`tree-delete` `tree-insert` `tree-wrap` `tree-unwrap` `tree-raise` `tree-cp` `tree-mv` `rename-def` `rm-def` `mv-def` `split-def` `add-ns` `edit-doc` `edit-schema` `add-example` `rm-import` `show-error`
|
|
44
|
+
|
|
45
|
+
要点:`tree-wrap` 用 `self` leaf;`position` 同 CLI(`|before` `|after` 等)。
|
|
46
|
+
|
|
47
|
+
### 第二批:edit/config/cirru(20)
|
|
48
|
+
|
|
49
|
+
`rm-ns` `set-imports` `format-file` `show-doc` `show-ns-doc` `list-tags` `set-tags` `rm-example` `clear-examples` `set-examples` `tree-replace-leaf` `tree-swap-*` `tree-batch-delete` `tree-rewrite` `set-config` `add/rm-module` `cirru-parse/format` `read-text-file`
|
|
50
|
+
|
|
51
|
+
修复:`build_ns_code` 对齐 `(ns name (:require ...))` 嵌套结构。
|
|
52
|
+
|
|
53
|
+
### 第三批:analyze / inc / docs 搜索(9)
|
|
54
|
+
|
|
55
|
+
`trigger-inc` `cirru-parse-edn` `cirru-show-guide` `docs-search` `tree-replace-leaf-regex` `analyze-call-graph` `analyze-effects-graph` `analyze-count-calls`
|
|
56
|
+
|
|
57
|
+
### 第四批:P0–P3(15)
|
|
58
|
+
|
|
59
|
+
- **P0**:`show-pkg` `show-ns` `list-defs-by-tag` `validate-file` `bump-version` `edit-ns-doc`
|
|
60
|
+
- **P1**:`search-project` `search-def-regex` `search-expr` `list-host-procs`
|
|
61
|
+
- **P2**:`analyze-check-types` `analyze-weak-types`(依赖 `type_coverage` 提取)
|
|
62
|
+
- **P3**:`docs-agents` `docs-read` `docs-sections`
|
|
63
|
+
|
|
64
|
+
### Core 声明 + 预处理
|
|
65
|
+
|
|
66
|
+
- core 可选参数 schema 用 `(:rest :dynamic)`,勿写 `:rest $ :dynamic`(EDN 解析失败)
|
|
67
|
+
- 预处理:`is_registered_proc` 必须在 `has_def_code` 之前,避免 core 元数据 stub 被当作普通 def 编译(`preprocess/mod.rs`)
|
|
68
|
+
|
|
69
|
+
## 验证
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python3 scripts/gen_calcit_cli_core.py
|
|
73
|
+
unset CARGO_TARGET_DIR && cargo fmt
|
|
74
|
+
cargo clippy --all-targets -- -D warnings
|
|
75
|
+
cargo test --bin cr
|
|
76
|
+
./target/debug/cr calcit/test.cirru exec << 'EOF'
|
|
77
|
+
calcit.cli/show-pkg $ {} (:file-path |calcit/test.cirru)
|
|
78
|
+
calcit.cli/validate-file $ {} (:file-path |calcit/test.cirru)
|
|
79
|
+
EOF
|
|
80
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# calcit.cli 选项 map 类型化 schema(Rust spec 直检)
|
|
2
|
+
|
|
3
|
+
## 变更概要
|
|
4
|
+
|
|
5
|
+
- 选项 spec 收敛到 `src/builtins/cli_options.rs`(Rust 单一来源),注册时写入 `RegisteredProcDescriptor.cli_options`。
|
|
6
|
+
- preprocess 直接读 Rust spec 校验 options map,不再生成 defstruct / 不做 map→record 转换。
|
|
7
|
+
- core 中 `:args` 仍由脚本生成 inline 类型 map(供 query/docs),校验走 Rust 而非 Calcit 类型系统。
|
|
8
|
+
|
|
9
|
+
## 后续优化(Rust spec 直检)
|
|
10
|
+
|
|
11
|
+
- preprocess 热路径改用 `registered_proc_cli_options()`,不再 clone 整个 `RegisteredProcDescriptor`。
|
|
12
|
+
- `registered_proc_has_tag` 同样改为只读 map 查询。
|
|
13
|
+
- `check_cli_options_map` 与 `resolve_cli_args` 共用 `collect_validation_errors`,preprocess 侧用引用收集 map 条目,避免多余 clone。
|
|
14
|
+
- Registered 调用检查复用已有的 `processed_args`,去掉重复 `ys.drop_left()` 和 `alias` clone。
|
|
15
|
+
|
|
16
|
+
## 验证案例(cr eval)
|
|
17
|
+
|
|
18
|
+
| 案例 | 结果 |
|
|
19
|
+
|------|------|
|
|
20
|
+
| `:file-pth` 拼写错误 | `W_CLI_OPTION_UNKNOWN_KEY` |
|
|
21
|
+
| 缺少 `:file-path` | `W_CLI_OPTION_MISSING_REQUIRED` |
|
|
22
|
+
| `:lines \|bad` 类型错误 | `W_CLI_OPTION_TYPE_MISMATCH` |
|
|
23
|
+
| 正确调用 | Check passed |
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# calcit.cli 与 CLI handlers 重复代码分析与重构方案
|
|
2
|
+
|
|
3
|
+
时间: 2026-06-30
|
|
4
|
+
作者: AI Agent
|
|
5
|
+
|
|
6
|
+
## 现状
|
|
7
|
+
|
|
8
|
+
### 两套独立实现
|
|
9
|
+
|
|
10
|
+
| 方面 | `injection/calcit_cli*.rs` | `cli_handlers/*.rs` |
|
|
11
|
+
|------|---------------------------|---------------------|
|
|
12
|
+
| 代码量 | ~2714 行 | ~5967 行 |
|
|
13
|
+
| 入口 | `fn(xs: Vec<Calcit>, _: &CallStackList) -> Result<Calcit, CalcitErr>` | `fn(opts: &SpecificCommandStruct, snapshot_file: &str) -> Result<(), String>` |
|
|
14
|
+
| 参数解析 | `resolve_cli_args()` → `ResolvedCliArgs` (从 Calcit Map 中提取) | argh 自动解析 CLI 参数到结构体 |
|
|
15
|
+
| 输出 | `Calcit::Str(...)` 返回给 Calcit 运行时 | `println!()` 直接输出 |
|
|
16
|
+
| 快照加载 | `load_calcit_snapshot()` | `load_snapshot()` |
|
|
17
|
+
| 快照保存 | `save_calcit_snapshot()` | `save_snapshot()` |
|
|
18
|
+
|
|
19
|
+
### 完全重复的辅助函数
|
|
20
|
+
|
|
21
|
+
| 函数 | injection/ 位置 | cli_handlers/ 位置 |
|
|
22
|
+
|------|----------------|-------------------|
|
|
23
|
+
| load_snapshot | calcit_cli.rs:1155 | edit.rs:101 |
|
|
24
|
+
| save_snapshot | calcit_cli.rs:1217 | edit.rs:109 |
|
|
25
|
+
| parse_path | calcit_cli.rs:933 | common.rs:182 |
|
|
26
|
+
| navigate_to_node | calcit_cli.rs:905 | edit.rs:1267 |
|
|
27
|
+
| parse_target | calcit_cli_args.rs (复用 cli_options) | edit.rs:22 |
|
|
28
|
+
| check_ns_editable | calcit_cli.rs:1033 | edit.rs:114 |
|
|
29
|
+
| apply_operation_at_path | calcit_cli_tree.rs | edit.rs:1152 |
|
|
30
|
+
| process_node_with_references | calcit_cli_tree.rs | edit.rs:1290 |
|
|
31
|
+
|
|
32
|
+
## 推荐的桥接方案
|
|
33
|
+
|
|
34
|
+
### 方案: 提取共享核心 + 让 calcit.cli 代理到 cli_handlers
|
|
35
|
+
|
|
36
|
+
不直接让 `calcit.cli` procs 调用 `cli_handlers`(因为接口类型不同),而是:
|
|
37
|
+
|
|
38
|
+
1. **将核心业务逻辑(load → modify → save)提取到共享函数**,放在 `snapshot.rs` 或新建 `src/snapshot_ops.rs`
|
|
39
|
+
2. **`cli_handlers` 调用共享函数**
|
|
40
|
+
3. **`calcit.cli` 内部转发到共享函数**,而不是自己再实现一遍
|
|
41
|
+
|
|
42
|
+
### 关键接口对齐
|
|
43
|
+
|
|
44
|
+
calcit.cli proc 的处理流程:
|
|
45
|
+
```
|
|
46
|
+
Vec<Calcit> → resolve_cli_args() → ResolvedCliArgs → 提取参数 → 业务逻辑 → Calcit
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
CLI handler 的处理流程:
|
|
50
|
+
```
|
|
51
|
+
CLI struct → 提取参数 → 业务逻辑 → println!
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
共同点: 都需要 `(file_path, target, path, code)` 等参数, 都调用 `load_snapshot` / `save_snapshot` / `navigate_to_path` / `apply_operation_at_path`
|
|
55
|
+
|
|
56
|
+
### 具体步骤
|
|
57
|
+
|
|
58
|
+
1. 把 `load_snapshot`, `save_snapshot`, `navigate_to_path`, `parse_path`, `check_ns_editable`, `apply_operation_at_path`, `process_node_with_references` 等辅助函数统一放到 `src/snapshot_ops.rs` (或 `src/bin/cli_handlers/ops.rs`)
|
|
59
|
+
2. 把每个业务操作(如 tree-replace、show-def、list-defs)提取为纯函数:
|
|
60
|
+
```rust
|
|
61
|
+
pub fn op_tree_replace(snapshot: &mut Snapshot, ns: &str, def: &str, path: &[usize], new_node: &Cirru) -> Result<(), String>
|
|
62
|
+
pub fn op_show_def(snapshot: &Snapshot, ns: &str, def: &str) -> Result<String, String>
|
|
63
|
+
```
|
|
64
|
+
3. `calcit.cli` 的每个 proc handler 变成薄薄的代理层:
|
|
65
|
+
```rust
|
|
66
|
+
pub fn tree_replace(xs: Vec<Calcit>, _cs: &CallStackList) -> Result<Calcit, CalcitErr> {
|
|
67
|
+
let args = resolve_cli_args("calcit.cli/tree-replace", &xs, TREE_REPLACE)?;
|
|
68
|
+
let mut snapshot = load_snapshot(&args.file_path()?)?;
|
|
69
|
+
let (ns, def) = args.target("target")?;
|
|
70
|
+
let path = parse_path(&args.string("path")?, false)?;
|
|
71
|
+
let code = args.cirru_quote("code")?;
|
|
72
|
+
ops::op_tree_replace(&mut snapshot, &ns, &def, &path, &code)?;
|
|
73
|
+
save_snapshot(&snapshot, &args.file_path()?)?;
|
|
74
|
+
Ok(Calcit::Str(Arc::from("replaced")))
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
4. CLI handlers 也变成薄代理:
|
|
78
|
+
```rust
|
|
79
|
+
fn handle_replace(opts: &TreeReplaceCommand, snapshot_file: &str) -> Result<(), String> {
|
|
80
|
+
let (ns, def) = parse_target(&opts.target)?;
|
|
81
|
+
let path = parse_path(&opts.path)?;
|
|
82
|
+
let code = parse_input_to_cirru(...)?;
|
|
83
|
+
let mut snapshot = load_snapshot(snapshot_file)?;
|
|
84
|
+
ops::op_tree_replace(&mut snapshot, ns, def, &path, &code)?;
|
|
85
|
+
save_snapshot(&snapshot, snapshot_file)?;
|
|
86
|
+
// print preview...
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 收益
|
|
91
|
+
- 消除 ~2000 行重复代码
|
|
92
|
+
- 修复 bug 只需改一处
|
|
93
|
+
- 新功能只需写一次共享逻辑
|
|
94
|
+
|
|
95
|
+
### 风险
|
|
96
|
+
- 大规模重构需要充分测试
|
|
97
|
+
- 需要迁移 `calcit_cli_tree.rs` 中的复杂逻辑(rewrite with references)
|
|
98
|
+
- `calcit.cli` 的 `CalcitErr` 错误类型和 `cli_handlers` 的 `String` 错误类型需要对齐
|
|
99
|
+
|
|
100
|
+
## 代码规模统计
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
src/bin/injection/
|
|
104
|
+
calcit_cli.rs 1297 行 ← 需要拆解: 辅助函数 + proc handlers
|
|
105
|
+
calcit_cli_extra.rs 846 行 ← 同上
|
|
106
|
+
calcit_cli_tree.rs 232 行 ← 纯辅助函数, 可整体移出
|
|
107
|
+
calcit_cli_args.rs 147 行 ← 桥接层, 保留
|
|
108
|
+
calcit_cli_specs.rs 192 行 ← 参数规格定义, 保留
|
|
109
|
+
mod.rs ~60 行 ← 注册代码, 保留
|
|
110
|
+
|
|
111
|
+
src/bin/cli_handlers/
|
|
112
|
+
edit.rs 2026 行 ← 辅助函数 + handler 逻辑
|
|
113
|
+
tree.rs 1433 行 ← handler 逻辑
|
|
114
|
+
query.rs 2135 行 ← handler 逻辑
|
|
115
|
+
common.rs 373 行 ← 工具函数
|
|
116
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Hash } from "@calcit/ternary-tree";
|
|
2
|
+
import { CalcitValue } from "./js-primes.mjs";
|
|
3
|
+
import { CalcitRef } from "./js-ref.mjs";
|
|
4
|
+
export declare class CalcitTag {
|
|
5
|
+
value: string;
|
|
6
|
+
cachedHash: Hash;
|
|
7
|
+
idx: number;
|
|
8
|
+
constructor(x: string);
|
|
9
|
+
toString(): string;
|
|
10
|
+
cmp(other: CalcitTag): number;
|
|
11
|
+
}
|
|
12
|
+
export declare class CalcitSymbol {
|
|
13
|
+
value: string;
|
|
14
|
+
cachedHash: Hash;
|
|
15
|
+
constructor(x: string);
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
18
|
+
export declare class CalcitRecur {
|
|
19
|
+
args: CalcitValue[];
|
|
20
|
+
cachedHash: Hash;
|
|
21
|
+
constructor(xs: CalcitValue[]);
|
|
22
|
+
toString(): string;
|
|
23
|
+
}
|
|
24
|
+
export declare let isNestedCalcitData: (x: CalcitValue) => boolean;
|
|
25
|
+
export declare let tipNestedCalcitData: (x: CalcitValue) => string;
|
|
26
|
+
export type CalcitFn = (...xs: CalcitValue[]) => CalcitValue;
|
|
27
|
+
export declare let getStringName: (x: CalcitValue) => string;
|
|
28
|
+
/** returns -1 when not found */
|
|
29
|
+
export declare function findInFields(xs: Array<CalcitTag>, y: CalcitTag): number;
|
|
30
|
+
export declare let newTag: (content: string) => CalcitTag;
|
|
31
|
+
export declare let castTag: (x: CalcitValue) => CalcitTag;
|
|
32
|
+
export declare var refsRegistry: Map<string, CalcitRef>;
|
|
33
|
+
export declare let hashFunction: (x: CalcitValue) => Hash;
|
|
34
|
+
export declare let toString: (x: CalcitValue, escaped: boolean, disableJsDataWarning?: boolean) => string;
|
|
35
|
+
export declare let to_js_data: (x: CalcitValue, addColon?: boolean) => any;
|
|
36
|
+
export declare let _$n_map_$o_get: (xs: CalcitValue, k: CalcitValue) => CalcitValue;
|
|
37
|
+
export declare let _$n__$e_: (x: CalcitValue, y: CalcitValue) => boolean;
|
|
38
|
+
/** special trick for disabling ternary tree list check */
|
|
39
|
+
export declare let disable_list_structure_check_$x_: () => void;
|