@calcit/procs 0.12.47 → 0.12.49
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/07-06-semantic-tree-navigation-rfc.md +569 -0
- package/RFCs/07-08-ffi-features-and-js-object-type-rfc.md +223 -0
- package/RFCs/README.md +21 -19
- 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/2026-07-07-0000-semantic-tree-navigation.md +49 -0
- package/editing-history/2026-07-08-1650-features-and-js-object-type.md +25 -0
- package/editing-history/202607040040-fix-format-cirru-edn-quoting.md +14 -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/js-cirru.mjs +2 -4
- 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-0609-1800-core-effect-tags.md → 2026-06-09-1800-core-effect-tags.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/{2026-0615-1500-effects-graph-mvp.md → 2026-06-15-1500-effects-graph-mvp.md} +0 -0
- /package/editing-history/{202606161700-effects-graph-ste-tree.md → 2026-06-16-1700-effects-graph-ste-tree.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/editing-history/{202606131200_primitive_schema_tags.md → archived/2026-06-13-1200-primitive_schema_tags.md} +0 -0
- /package/editing-history/{202606201142-ts-declaration-d-mts.md → archived/2026-06-20-1142-ts-declaration-d-mts.md} +0 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# RFC: `:features` 函数能力标记 + `:js-object` 类型收敛
|
|
2
|
+
|
|
3
|
+
状态:Draft
|
|
4
|
+
日期:2026-07-08
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. 概要
|
|
9
|
+
|
|
10
|
+
在函数 schema 中新增 `:features` 属性(HashSet),标记当前函数可使用的语言能力子集。默认空集合。使用 JS interop 语法(`aget`、`&js-object`、`new` 等)要求函数显式标记 `:features $ #{} :js-ffi`,从类型层面将 FFI 隔离在有限的 binding 函数中。
|
|
11
|
+
|
|
12
|
+
同步新增 `:js-object` 类型注解,表示 JavaScript FFI 操作产生的外部 opaque 数据,阻断 JS 对象向纯 Calcit 函数的无意识泄露。
|
|
13
|
+
|
|
14
|
+
## 2. 动机
|
|
15
|
+
|
|
16
|
+
### 问题
|
|
17
|
+
|
|
18
|
+
当前 JS FFI 函数(`is_js_syntax_procs` 收录 21 个)在 `codegen::codegen_mode()` 下全局放行,任何函数都可以随意调用:
|
|
19
|
+
|
|
20
|
+
```cirru
|
|
21
|
+
;; 任意函数都能直接调用 FFI,无任何约束
|
|
22
|
+
defn my-pure-fn (x)
|
|
23
|
+
aget x |someProp ;; 静默通过
|
|
24
|
+
&js-object $ {} (:a 1) ;; 静默通过
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
这导致:
|
|
28
|
+
|
|
29
|
+
- **边界模糊**:无法从代码中区分"纯 Calcit 函数"和"FFI binding 函数"
|
|
30
|
+
- **审查困难**:排查 JS interop 使用点需要全文搜索 21 个函数名
|
|
31
|
+
- **类型不安全**:JS 对象可以自由流经所有函数,静态分析无法追踪外部数据
|
|
32
|
+
- **重构风险**:修改 FFI 层时无法确定影响范围
|
|
33
|
+
|
|
34
|
+
### 目标
|
|
35
|
+
|
|
36
|
+
| 目标 | 说明 |
|
|
37
|
+
| -------- | ------------------------------------------------------------------------ |
|
|
38
|
+
| 权限收敛 | 只有 schema 中声明 `:js-ffi` 的函数才能调用 JS FFI |
|
|
39
|
+
| 类型隔离 | `:js-object` 类型标注 JS 对象,跨非 FFI 边界时产生告警 |
|
|
40
|
+
| 渐进迁移 | 先 warning 后 error,给生态适配时间 |
|
|
41
|
+
| 可扩展 | `:features` 设计预留 `:side-effects`、`:async`、`:unsafe` 等未来能力标记 |
|
|
42
|
+
|
|
43
|
+
## 3. 设计
|
|
44
|
+
|
|
45
|
+
### 3.1 `:features` — Schema 属性
|
|
46
|
+
|
|
47
|
+
在 `CalcitFnTypeAnnotation` 中新增 `features` 字段:
|
|
48
|
+
|
|
49
|
+
```rust
|
|
50
|
+
pub struct CalcitFnTypeAnnotation {
|
|
51
|
+
pub generics: Arc<Vec<Arc<str>>>,
|
|
52
|
+
pub where_bounds: Arc<Vec<CalcitGenericBound>>,
|
|
53
|
+
pub arg_types: Vec<Arc<CalcitTypeAnnotation>>,
|
|
54
|
+
pub return_type: Arc<CalcitTypeAnnotation>,
|
|
55
|
+
pub fn_kind: SchemaKind,
|
|
56
|
+
pub rest_type: Option<Arc<CalcitTypeAnnotation>>,
|
|
57
|
+
/// Feature flags declared in schema, e.g. `:features $ #{} :js-ffi`
|
|
58
|
+
pub features: Arc<HashSet<EdnTag>>,
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 3.2 `:js-object` — 类型注解
|
|
63
|
+
|
|
64
|
+
在 `CalcitTypeAnnotation` 枚举中新增变体:
|
|
65
|
+
|
|
66
|
+
```rust
|
|
67
|
+
pub enum CalcitTypeAnnotation {
|
|
68
|
+
// ... 现有变体不变 ...
|
|
69
|
+
/// JavaScript FFI external object (opaque to Calcit type system)
|
|
70
|
+
JsObject,
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
EDN 序列化:tag 名为 `:js-object`。
|
|
75
|
+
|
|
76
|
+
### 3.3 Canonical Cirru EDN 形态
|
|
77
|
+
|
|
78
|
+
```cirru
|
|
79
|
+
%{} :CodeEntry
|
|
80
|
+
:doc "|FFI binding for DOM event handling"
|
|
81
|
+
:code $ quote
|
|
82
|
+
defn handle-click (event)
|
|
83
|
+
let
|
|
84
|
+
target $ aget event |target
|
|
85
|
+
value $ aget target |value
|
|
86
|
+
println value
|
|
87
|
+
:schema $ :: :fn
|
|
88
|
+
{}
|
|
89
|
+
:args $ [] :js-object
|
|
90
|
+
:return :unit
|
|
91
|
+
:features $ #{} :js-ffi
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
一行 Cirru EDN 示例:
|
|
95
|
+
|
|
96
|
+
```cirru
|
|
97
|
+
(:: :fn ({} (:args ([] :js-object)) (:return :unit) (:features (#{} :js-ffi))))
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 3.4 校验流程
|
|
101
|
+
|
|
102
|
+
```mermaid
|
|
103
|
+
flowchart TD
|
|
104
|
+
A[preprocess_expr 符号解析] --> B{调用目标是 JS FFI 函数?}
|
|
105
|
+
B -->|否| C[正常预处理]
|
|
106
|
+
B -->|是| D{当前正在编译的 def 有 :js-ffi?}
|
|
107
|
+
D -->|是| C
|
|
108
|
+
D -->|否| E[产生 Error/Warning]
|
|
109
|
+
|
|
110
|
+
F[函数 A 返回 JsObject] --> G[函数 B 接收 JsObject 作为参数]
|
|
111
|
+
G --> H{B 的 schema 有 :js-ffi?}
|
|
112
|
+
H -->|否| I[类型告警: JsObject 流入非 FFI 函数]
|
|
113
|
+
H -->|是| J[放行]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 3.5 校验位置
|
|
117
|
+
|
|
118
|
+
| 校验点 | 位置 | 触发条件 |
|
|
119
|
+
| ----------------- | ------------------------------------------ | ----------------------------------------------------------------------------------- |
|
|
120
|
+
| FFI 函数调用 | `preprocess_expr` → `preprocess_list_call` | head 解析为 `is_js_syntax_procs` 且当前编译上下文中 `defn` 无 `:js-ffi` |
|
|
121
|
+
| `ns js/...` 语法 | `preprocess_expr` 中 `RawCode(Js, _)` 分支 | 同上的 features 检查 |
|
|
122
|
+
| `JsObject` 跨边界 | `check_user_fn_arg_types` | 实参类型为 `JsObject` 且形参 schema 非 `JsObject` 且函数无 `:js-ffi` |
|
|
123
|
+
| `JsObject` 返回值 | `check_function_return_type` | 返回值推断为 `JsObject` 且函数 schema 的 `:return` 非 `JsObject` 且函数无 `:js-ffi` |
|
|
124
|
+
|
|
125
|
+
### 3.6 默认值与兼容
|
|
126
|
+
|
|
127
|
+
- `:features` 默认 `Arc::new(HashSet::new())`,即空集合 = 无任何特殊能力
|
|
128
|
+
- `:js-object` 类型的默认行为:在无 `:js-ffi` 的函数中作为 `:dynamic` 等效处理(宽松模式),或产生类型告警(严格模式)
|
|
129
|
+
- 第一阶段以 **warning** 形式上线,通过 `--warn-ffi` flag 控制,后续升级为 error
|
|
130
|
+
|
|
131
|
+
## 4. FFI 函数清单
|
|
132
|
+
|
|
133
|
+
当前 `is_js_syntax_procs()` 收录的函数,全部受 `:js-ffi` 管控:
|
|
134
|
+
|
|
135
|
+
| 函数 | 用途 | 返回类型建议 |
|
|
136
|
+
| --------------------------------------- | -------------------- | -------------------------- |
|
|
137
|
+
| `aget` / `js-get` | JS 属性读取 | `:js-object` 或 `:dynamic` |
|
|
138
|
+
| `aset` / `js-set` | JS 属性写入 | `:unit` |
|
|
139
|
+
| `js-delete` | JS 属性删除 | `:unit` |
|
|
140
|
+
| `exists?` | JS 属性存在性检查 | `:bool` |
|
|
141
|
+
| `instance?` | JS instanceof | `:bool` |
|
|
142
|
+
| `&js-object` | 创建 JS 对象 | `:js-object` |
|
|
143
|
+
| `js-array` | 创建 JS 数组 | `:js-object` |
|
|
144
|
+
| `js-await` / `js-for-await` | Promise/异步迭代 | `:js-object` |
|
|
145
|
+
| `new` | JS new 构造 | `:js-object` |
|
|
146
|
+
| `set!` | JS 赋值 | `:unit` |
|
|
147
|
+
| `to-js-data` | Calcit → JS 转换 | `:js-object` |
|
|
148
|
+
| `to-calcit-data` | JS → Calcit 转换 | `:dynamic` |
|
|
149
|
+
| `extract-cirru-edn` / `to-cirru-edn` | EDN 序列化 | `:string` / `:dynamic` |
|
|
150
|
+
| `&raw-code` | 原始 JS 代码 | `:js-object` |
|
|
151
|
+
| `timeout-call` | 异步定时 | `:js-object` |
|
|
152
|
+
| `foldl` | fold-left(JS 实现) | 依赖元素类型 |
|
|
153
|
+
| `load-console-formatter!` / `printable` | 控制台输出 | `:unit` |
|
|
154
|
+
|
|
155
|
+
> **注**:`foldl` 虽然在 JS FFI 列表中,但它是纯函数式的 fold 操作,未来可考虑移出 FFI 列表或单独归类。
|
|
156
|
+
|
|
157
|
+
## 5. 实现计划
|
|
158
|
+
|
|
159
|
+
### Phase 1: 数据层(~2h)
|
|
160
|
+
|
|
161
|
+
- [ ] `CalcitFnTypeAnnotation.features` 字段新增
|
|
162
|
+
- [ ] EDN 序列化 / 反序列化(`to_schema_edn` / `parse_loaded_schema_annotation`)
|
|
163
|
+
- [ ] `CalcitTypeAnnotation::JsObject` 变体新增 + 全量 match 补齐
|
|
164
|
+
- [ ] `JsObject` 的 EDN tag 解析(`:js-object`)
|
|
165
|
+
|
|
166
|
+
### Phase 2: 校验层(~4h)
|
|
167
|
+
|
|
168
|
+
- [ ] `preprocess_list_call` 中 FFI 调用权限校验
|
|
169
|
+
- [ ] `preprocess_expr` 中 `ns js/...` 语法的 FFI 权限校验
|
|
170
|
+
- [ ] 编译上下文传递:在 `ensure_ns_def_preprocessed` 链路中追踪当前 `defn` 的 features
|
|
171
|
+
- [ ] `check_user_fn_arg_types` 中 `JsObject` 跨边界告警
|
|
172
|
+
- [ ] `check_function_return_type` 中 `JsObject` 返回值告警
|
|
173
|
+
- [ ] `--warn-ffi` CLI flag(默认开启 warning 模式)
|
|
174
|
+
|
|
175
|
+
### Phase 3: 类型推断(~2h)
|
|
176
|
+
|
|
177
|
+
- [ ] `&js-object`、`js-array`、`new` 等 FFI 函数的返回值推断为 `JsObject`
|
|
178
|
+
- [ ] `aget` 对 `JsObject` 参数的接收校验
|
|
179
|
+
- [ ] `to-calcit-data` 作为 `JsObject → Dynamic` 的转换边界
|
|
180
|
+
|
|
181
|
+
### Phase 4: 迁移与测试(~3h)
|
|
182
|
+
|
|
183
|
+
- [ ] 现有 `calcit/` 下使用 JS FFI 的测试文件 schema 迁移
|
|
184
|
+
- [ ] 新增 `calcit/test-ffi-features.cirru` 测试用例:
|
|
185
|
+
- 无 `:js-ffi` 调用 `aget` → 预期 warning/error
|
|
186
|
+
- 有 `:js-ffi` 调用 `aget` → 预期通过
|
|
187
|
+
- 无 `:js-ffi` 接收 `JsObject` 参数 → 预期类型告警
|
|
188
|
+
- 有 `:js-ffi` 接收 `JsObject` → 预期通过
|
|
189
|
+
- `to-calcit-data` 边界转换后不再需要 `:js-ffi`
|
|
190
|
+
- [ ] 文档更新(`docs/features.md`)
|
|
191
|
+
|
|
192
|
+
### Phase 5: 严格模式(后续版本)
|
|
193
|
+
|
|
194
|
+
- [ ] 缺少 `:js-ffi` 的 FFI 调用从 warning 升级为 hard error
|
|
195
|
+
- [ ] `:js-object` 可能扩展到区分 `:js-object` vs `:js-array` vs `:js-promise`
|
|
196
|
+
|
|
197
|
+
## 6. 风险与缓解
|
|
198
|
+
|
|
199
|
+
| 风险 | 影响 | 缓解 |
|
|
200
|
+
| --------------------------------------- | ------------------ | ---------------------------------------------------- |
|
|
201
|
+
| 现有 Cirru 代码大量使用 FFI 但无 schema | 迁移工作量大 | 先 warning 后 error;提供迁移脚本 |
|
|
202
|
+
| `foldl` 列入 FFI 引起误报 | 纯函数被标记为 FFI | 考虑将 `foldl` 移出 `is_js_syntax_procs` 或单独分类 |
|
|
203
|
+
| 宏生成的函数自动获取 `:js-ffi` | 权限继承不明确 | 宏生成函数的 features 从宏定义处显式声明,不自动继承 |
|
|
204
|
+
| 第三方库适配周期长 | 生态断裂 | 预留至少一个大版本的 warning-only 过渡期 |
|
|
205
|
+
|
|
206
|
+
## 7. 未来扩展
|
|
207
|
+
|
|
208
|
+
`:features` 设计为 `HashSet<EdnTag>`,天然支持未来新增能力标记:
|
|
209
|
+
|
|
210
|
+
| 标记 | 含义 |
|
|
211
|
+
| --------------- | ------------------------------------------------ |
|
|
212
|
+
| `:js-ffi` | 可使用 JS interop 语法(本次实现) |
|
|
213
|
+
| `:side-effects` | 函数可能产生副作用(未来:配合 effects graph) |
|
|
214
|
+
| `:async` | 函数内部使用异步操作(未来:配合 effect 系统) |
|
|
215
|
+
| `:unsafe` | 函数绕过了类型检查(未来:配合 unsafe block) |
|
|
216
|
+
| `:host` | 函数需要宿主环境 API(未来:配合多 target 编译) |
|
|
217
|
+
|
|
218
|
+
## 8. 参考资料
|
|
219
|
+
|
|
220
|
+
- 现有 JS FFI 函数定义:`src/builtins.rs:649` `is_js_syntax_procs()`
|
|
221
|
+
- 现有 Schema 结构:`src/calcit/type_annotation.rs:3826` `CalcitFnTypeAnnotation`
|
|
222
|
+
- 现有预处理入口:`src/runner/preprocess/mod.rs` `preprocess_expr()`
|
|
223
|
+
- 相关 RFC:[Type Slot 机制](./04-13-type-slot-mechanism-rfc.md)、[泛型 `:where` 约束](./05-31-generic-where-bounds-mfs.md)
|
package/RFCs/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# RFC 整理索引
|
|
2
2
|
|
|
3
|
-
更新时间:2026-06-
|
|
3
|
+
更新时间:2026-06-29
|
|
4
4
|
|
|
5
5
|
## 目录原则
|
|
6
6
|
|
|
@@ -10,24 +10,26 @@
|
|
|
10
10
|
|
|
11
11
|
## 当前保留文件
|
|
12
12
|
|
|
13
|
-
| 文件
|
|
14
|
-
|
|
|
15
|
-
| `03-05-function-schema-dual-track-rfc.md`
|
|
16
|
-
| `02-04-runtime-traits-plan.md`
|
|
17
|
-
| `02-17-register-platform-api-rfc.md`
|
|
18
|
-
| `02-18-language-theory-evolution-plan.md`
|
|
19
|
-
| `02-23-optional-record-macro-plan.md`
|
|
20
|
-
| `02-14-project-modernization-roadmap.md`
|
|
21
|
-
| `03-16-runtime-boundary-refactor-plan.md`
|
|
22
|
-
| `03-18-query-def-tree-show-chunked-display-plan.md` | Review-needed | query/tree show 分块展示方案。
|
|
23
|
-
| `04-13-call-arg-literal-rewrite-rfc.md`
|
|
24
|
-
| `04-13-type-slot-mechanism-rfc.md`
|
|
25
|
-
| `04-15-match-syntax-rfc.md`
|
|
26
|
-
| `04-15-type-directed-optimization-catalog.md`
|
|
27
|
-
| `04-15-wasm-compilation-feasibility.md`
|
|
28
|
-
| `04-16-wasm-data-structures.md`
|
|
29
|
-
| `05-31-generic-where-bounds-mfs.md`
|
|
30
|
-
| `06-15-effects-graph-rfc.md`
|
|
13
|
+
| 文件 | 状态 | 建议 |
|
|
14
|
+
| --------------------------------------------------- | ------------- | ----------------------------------------------------------------------------------------- |
|
|
15
|
+
| `03-05-function-schema-dual-track-rfc.md` | Active | 已收敛为当前 schema 约定说明,涉及函数 schema 时优先参考。 |
|
|
16
|
+
| `02-04-runtime-traits-plan.md` | Active | runtime traits 主设计文档。 |
|
|
17
|
+
| `02-17-register-platform-api-rfc.md` | Active | host capability / register API 规范草案。 |
|
|
18
|
+
| `02-18-language-theory-evolution-plan.md` | Review-needed | 偏理论路线图,阅读时需区分愿景与已落地内容。 |
|
|
19
|
+
| `02-23-optional-record-macro-plan.md` | Review-needed | 小范围提案,尚未进入稳定实现。 |
|
|
20
|
+
| `02-14-project-modernization-roadmap.md` | Review-needed | 工程路线图可参考,但不要当作语法或行为文档。 |
|
|
21
|
+
| `03-16-runtime-boundary-refactor-plan.md` | Review-needed | 运行时边界重构方案。 |
|
|
22
|
+
| `03-18-query-def-tree-show-chunked-display-plan.md` | Review-needed | query/tree show 分块展示方案。 |
|
|
23
|
+
| `04-13-call-arg-literal-rewrite-rfc.md` | Active | 调用参数字面量重写优化提案。 |
|
|
24
|
+
| `04-13-type-slot-mechanism-rfc.md` | Active | Type slot 机制提案。 |
|
|
25
|
+
| `04-15-match-syntax-rfc.md` | Active | match 语法改进提案。 |
|
|
26
|
+
| `04-15-type-directed-optimization-catalog.md` | Active | 基于 `&record:nth` 经验,系统梳理 Record/Tuple/Scope 等类型导向优化机会。 |
|
|
27
|
+
| `04-15-wasm-compilation-feasibility.md` | Active | WASM 编译三条路径(解释器→WASM / AOT 子集 / WASM GC)的可行性评估。 |
|
|
28
|
+
| `04-16-wasm-data-structures.md` | Active | WASM codegen 中 Tag/Record/Tuple 等数据结构的内存布局与编译策略。 |
|
|
29
|
+
| `05-31-generic-where-bounds-mfs.md` | Active | 函数 schema 泛型 `:where` 约束的最小功能规格,先作为主链路开发基线。 |
|
|
30
|
+
| `06-15-effects-graph-rfc.md` | Draft | `cr analyze effects-graph`:State/Transform/Effect 语义分解图与类型驱动 effect 标注路线。 |
|
|
31
|
+
| `06-29-cr-exec-cli-builtins-rfc.md` | **Active** | `cr exec` + `calcit.cli/*` 内建函数:绕过 Shell 转义的 Cirru 函数调用方案。 |
|
|
32
|
+
| `07-06-semantic-tree-navigation-rfc.md` | Draft | 语义化树形导航与编辑:路径标注、多候选交互、锚点搜索替换、结构化查询语言。 |
|
|
31
33
|
|
|
32
34
|
## 已执行的清理
|
|
33
35
|
|
|
@@ -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,49 @@
|
|
|
1
|
+
# 语义化树形导航实现 (2026-07-07)
|
|
2
|
+
|
|
3
|
+
## 变更概要
|
|
4
|
+
|
|
5
|
+
实现 RFC `07-06-semantic-tree-navigation-rfc.md` 全部四个 Phase。
|
|
6
|
+
|
|
7
|
+
## 实现功能
|
|
8
|
+
|
|
9
|
+
### L1: `--path-annotations`
|
|
10
|
+
- `cr tree show` 新增 `--path-annotations` flag
|
|
11
|
+
- 开启后递归为所有嵌套 `Cirru::List` 末尾追加 `; "previous node path: X.Y.Z"` 注释节点
|
|
12
|
+
- AST 层面操作:`children.push(Cirru::List([Cirru::Leaf(";"), Cirru::Leaf(path_string)]))`
|
|
13
|
+
- 子节点 > 8 时底部 tip 提示可开启
|
|
14
|
+
|
|
15
|
+
### L2: `--pick` 多候选选择
|
|
16
|
+
- `search-replace` 多匹配时展示带路径、上下文的候选列表
|
|
17
|
+
- `--pick <N>` 直接选择第 N 个候选执行替换
|
|
18
|
+
|
|
19
|
+
### L4: 语义路径表达式
|
|
20
|
+
- `cr query path <ns> --selector 'path heading ... nth ...'`
|
|
21
|
+
- 三个选择器:裸叶子(精确匹配)、`heading`(前缀匹配)、`nth`(位置导航)
|
|
22
|
+
- `resolve_path_expression` 函数解析并返回数字路径
|
|
23
|
+
|
|
24
|
+
### L4: `--selector` 限定搜索范围
|
|
25
|
+
- `search-replace --selector 'path ...'` 在语义路径定位的子树内搜索替换
|
|
26
|
+
- 与 `cr query path` 共用同一套选择器语法
|
|
27
|
+
|
|
28
|
+
### Phase 4: `cr query anchors`
|
|
29
|
+
- 遍历 AST 中 `noted @anchor:<name>` 调用,输出锚点名称和路径
|
|
30
|
+
|
|
31
|
+
## 修改文件
|
|
32
|
+
|
|
33
|
+
| 文件 | 变更 |
|
|
34
|
+
|------|------|
|
|
35
|
+
| `src/cli_args.rs` | 新增 `path_annotations`, `pick`, `selector` 字段;新增 `QueryPathCommand`, `QueryAnchorsCommand` |
|
|
36
|
+
| `src/bin/cli_handlers/tree.rs` | `annotate_paths` 函数;`handle_show` 路径标注 + tip;`handle_search_replace` 多候选 + selector |
|
|
37
|
+
| `src/bin/cli_handlers/query.rs` | `resolve_path_expression`(pub), `starts_with_pattern`, `handle_query_path`, `handle_query_anchors`, `find_anchors` |
|
|
38
|
+
| `src/bin/cli_handlers/command_echo.rs` | Path/Anchors 子命令 echo 支持 |
|
|
39
|
+
| `docs/CalcitAgent.md` | 精简引用新功能 |
|
|
40
|
+
| `docs/run/agent-advanced.md` | 详细示例文档 |
|
|
41
|
+
| `RFCs/07-06-semantic-tree-navigation-rfc.md` | 新增 RFC |
|
|
42
|
+
|
|
43
|
+
## 设计决策
|
|
44
|
+
|
|
45
|
+
- `--at`/`--child` 链式语法被 `--selector` 替代,代码中已移除
|
|
46
|
+
- `exact` 选择器不纳入——链式导航模型不需要独立精确匹配,`heading` 无多余子节点时等同
|
|
47
|
+
- `sub-path` 选择器不纳入——L1 路径标注让 `nth` 足够
|
|
48
|
+
- 路径注释放在 list 末尾(不破坏已有子节点索引)
|
|
49
|
+
- `Cirru::Leaf` 存原始内容,格式化时自动加引号
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# `:features` function schema + `:js-object` type + CLI simplification
|
|
2
|
+
|
|
3
|
+
## Changes
|
|
4
|
+
|
|
5
|
+
### Feature: `:features` and `:js-object` type system
|
|
6
|
+
- Added `features: Arc<HashSet<EdnTag>>` to `CalcitFnTypeAnnotation` for marking function capabilities
|
|
7
|
+
- Added `CalcitTypeAnnotation::JsObject` variant for opaque JS FFI data
|
|
8
|
+
- EDN round-trip for both (`features_to_edn` + `parse_fn_features_from_form`)
|
|
9
|
+
- Manually implemented `PartialOrd`/`Ord`/`Hash` for `CalcitFnTypeAnnotation`
|
|
10
|
+
- `CURRENT_FN_FEATURES` thread-local + `lookup_def_schema` fallback for FFI checking
|
|
11
|
+
- `as_fn()` helper on `CalcitTypeAnnotation`
|
|
12
|
+
- `#{}` hashset support in `schema_cirru_to_edn`
|
|
13
|
+
- `:features` field validation in `validate_schema_for_write`
|
|
14
|
+
- All direct FFI callers marked with `:features $ #{} :js-ffi`
|
|
15
|
+
|
|
16
|
+
### Refactor: CLI simplification
|
|
17
|
+
- Removed `--json` option and `--json-input` switch from all edit/tree subcommands
|
|
18
|
+
- Auto-detect JSON (`[` prefix) vs Cirru EDN (`quote` prefix) in `parse_input_to_cirru`
|
|
19
|
+
- Simplified `read_code_input` to `(file, code)` params; stdin fallback
|
|
20
|
+
- Removed `json()`/`json_input()` from `InsertOperation` trait
|
|
21
|
+
- Simplified `CodeInputParts` to only carry `file`+`code`
|
|
22
|
+
- Added stdin mention to all edit subcommand help texts
|
|
23
|
+
- Updated agent docs (CalcitAgent.md, agent-advanced.md, cirru-syntax.md, edit-tree.md)
|
|
24
|
+
- Cleaned up stale short flag mentions (`-j`, `-J`, `-e`)
|
|
25
|
+
- Changed js-interop doc blocks to `no-check` to avoid FFI warnings
|
|
@@ -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,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 |
|