@calcit/procs 0.12.54 → 0.12.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/README.md CHANGED
@@ -139,8 +139,9 @@ Run `caps` to download. Sources are downloaded into `~/.config/calcit/modules/`.
139
139
  To load modules, use `:modules` configuration and the runtime snapshot file `calcit.cirru` (legacy: `compact.cirru`):
140
140
 
141
141
  ```cirru
142
- :configs $ {}
143
- :modules $ [] |memof/calcit.cirru |lilac/
142
+ :entries $ {}
143
+ :default $ {}
144
+ :modules $ [] |memof/calcit.cirru |lilac/
144
145
  ```
145
146
 
146
147
  Paths defined in `:modules` field are just loaded as files from `~/.config/calcit/modules/`,
@@ -281,13 +281,15 @@ evaluate(with-type-slot body) -> 在遇到 dependency 时临时影响编译
281
281
 
282
282
  ### 8.2 已实现的配置语法
283
283
 
284
- 默认 entry 在 `:configs` 中绑定短 slot 名,值必须是完整 definition path 或 `:dynamic`:
284
+ 默认 entry 在 `:entries.default` 中绑定短 slot 名,值必须是完整 definition path 或 `:dynamic`:
285
285
 
286
286
  ```cirru
287
- :configs $ {}
288
- :init-fn |app.main/main!
289
- :type-slots $ {}
290
- :dispatch-op |app.schema/Op
287
+ :entries $ {}
288
+ :default $ {}
289
+ :mode :native
290
+ :init-fn |app.main/main!
291
+ :type-slots $ {}
292
+ :dispatch-op |app.schema/Op
291
293
  ```
292
294
 
293
295
  命名 entry 使用自己的完整配置,可以选择另一类型:
@@ -295,12 +297,13 @@ evaluate(with-type-slot body) -> 在遇到 dependency 时临时影响编译
295
297
  ```cirru
296
298
  :entries $ {}
297
299
  :server $ {}
300
+ :mode :native
298
301
  :init-fn |app.server/main!
299
302
  :type-slots $ {}
300
303
  :dispatch-op |app.schema/ServerOp
301
304
  ```
302
305
 
303
- 命名 entry 不继承默认 `:configs.type-slots`。这里使用完整 definition path,而不是在配置解析阶段求值任意 Calcit expression,因此配置可序列化、可查询,也不依赖入口函数的执行顺序。对应命令为:
306
+ 命名 entry 不继承 `:entries.default.type-slots`。这里使用完整 definition path,而不是在配置解析阶段求值任意 Calcit expression,因此配置可序列化、可查询,也不依赖入口函数的执行顺序。对应命令为:
304
307
 
305
308
  ```bash
306
309
  cr config set-type-slot :dispatch-op app.schema/Op
@@ -574,7 +577,7 @@ cr config type-slots --entry server
574
577
 
575
578
  ## 15. 尚待决定的问题
576
579
 
577
- 已决定:`:configs` 与每个命名 entry 各自保存完整 `:type-slots`,不做隐式继承;配置值只接受完整 definition path 或 `:dynamic`。
580
+ 已决定:所有入口统一存放在 `:entries`,`:default` 是无参数入口;每个 entry 各自保存完整 `:type-slots`,不做隐式继承;配置值只接受完整 definition path 或 `:dynamic`。
578
581
 
579
582
  仍待决定:
580
583
 
package/build.rs CHANGED
@@ -6,16 +6,71 @@ use std::env;
6
6
  use std::fs;
7
7
  use std::path::Path;
8
8
 
9
+ #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
10
+ #[serde(rename_all = "lowercase")]
11
+ pub enum SnapshotRunMode {
12
+ #[default]
13
+ Native,
14
+ Js,
15
+ }
16
+
17
+ fn deserialize_run_mode<'de, D>(deserializer: D) -> Result<SnapshotRunMode, D::Error>
18
+ where
19
+ D: serde::Deserializer<'de>,
20
+ {
21
+ let value = Edn::deserialize(deserializer)?;
22
+ let mode = match value {
23
+ Edn::Tag(tag) => tag.ref_str().to_owned(),
24
+ Edn::Str(text) | Edn::Symbol(text) => text.trim_start_matches(':').to_owned(),
25
+ other => return Err(serde::de::Error::custom(format!("expected :native or :js, got {other:?}"))),
26
+ };
27
+ match mode.as_str() {
28
+ "native" => Ok(SnapshotRunMode::Native),
29
+ "js" => Ok(SnapshotRunMode::Js),
30
+ _ => Err(serde::de::Error::custom(format!("expected :native or :js, got {mode}"))),
31
+ }
32
+ }
33
+
34
+ fn deserialize_ns_def<'de, D>(deserializer: D) -> Result<String, D::Error>
35
+ where
36
+ D: serde::Deserializer<'de>,
37
+ {
38
+ match Edn::deserialize(deserializer)? {
39
+ Edn::Str(text) | Edn::Symbol(text) => Ok(text.to_string()),
40
+ other => Err(serde::de::Error::custom(format!(
41
+ "expected namespace/definition string or symbol, got {other:?}"
42
+ ))),
43
+ }
44
+ }
45
+
9
46
  #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10
- pub struct SnapshotConfigs {
11
- #[serde(rename = "init-fn")]
47
+ pub struct SnapshotEntry {
48
+ #[serde(default, deserialize_with = "deserialize_run_mode")]
49
+ pub mode: SnapshotRunMode,
50
+ #[serde(rename = "init-fn", deserialize_with = "deserialize_ns_def")]
12
51
  pub init_fn: String,
13
- #[serde(rename = "reload-fn")]
52
+ #[serde(rename = "reload-fn", deserialize_with = "deserialize_ns_def")]
53
+ pub reload_fn: String,
54
+ #[serde(default)]
55
+ pub description: String,
56
+ #[serde(default)]
57
+ pub modules: Vec<String>,
58
+ #[serde(default, rename = "type-slots")]
59
+ pub type_slots: HashMap<String, String>,
60
+ }
61
+
62
+ #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
63
+ pub struct LegacySnapshotConfigs {
64
+ #[serde(rename = "init-fn", deserialize_with = "deserialize_ns_def")]
65
+ pub init_fn: String,
66
+ #[serde(rename = "reload-fn", deserialize_with = "deserialize_ns_def")]
14
67
  pub reload_fn: String,
15
68
  #[serde(default)]
16
69
  pub modules: Vec<String>,
17
70
  #[serde(default)]
18
71
  pub version: String,
72
+ #[serde(default, rename = "type-slots")]
73
+ pub type_slots: HashMap<String, String>,
19
74
  }
20
75
 
21
76
  #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@@ -46,8 +101,9 @@ pub struct FileInSnapShot {
46
101
  pub struct Snapshot {
47
102
  pub package: String,
48
103
  pub about: Option<String>,
49
- pub configs: SnapshotConfigs,
50
- pub entries: HashMap<String, SnapshotConfigs>,
104
+ #[serde(default)]
105
+ pub version: String,
106
+ pub entries: HashMap<String, SnapshotEntry>,
51
107
  pub files: HashMap<String, FileInSnapShot>,
52
108
  }
53
109
 
@@ -417,11 +473,37 @@ fn main() {
417
473
 
418
474
  let files = parse_files(data.get_or_nil("files")).unwrap_or_else(|e| panic!("failed to parse calcit-core `:files`: {e}"));
419
475
 
476
+ let legacy_configs = match data.get_or_nil("configs") {
477
+ Edn::Nil => None,
478
+ value => {
479
+ Some(from_edn::<LegacySnapshotConfigs>(value).unwrap_or_else(|e| panic!("failed to parse calcit-core legacy `:configs`: {e}")))
480
+ }
481
+ };
482
+ let mut entries: HashMap<String, SnapshotEntry> =
483
+ from_edn(data.get_or_nil("entries")).unwrap_or_else(|e| panic!("failed to parse calcit-core `:entries`: {e}"));
484
+ if let Some(configs) = &legacy_configs {
485
+ entries.insert(
486
+ "default".to_owned(),
487
+ SnapshotEntry {
488
+ mode: SnapshotRunMode::Native,
489
+ init_fn: configs.init_fn.clone(),
490
+ reload_fn: configs.reload_fn.clone(),
491
+ description: String::new(),
492
+ modules: configs.modules.clone(),
493
+ type_slots: configs.type_slots.clone(),
494
+ },
495
+ );
496
+ }
497
+ let version = match data.get_or_nil("version") {
498
+ Edn::Nil => legacy_configs.map(|configs| configs.version).unwrap_or_default(),
499
+ value => from_edn(value).unwrap_or_else(|e| panic!("failed to parse calcit-core `:version`: {e}")),
500
+ };
501
+
420
502
  let snapshot = Snapshot {
421
503
  package: pkg,
422
504
  about,
423
- configs: from_edn(data.get_or_nil("configs")).unwrap_or_else(|e| panic!("failed to parse calcit-core `:configs`: {e}")),
424
- entries: from_edn(data.get_or_nil("entries")).unwrap_or_else(|e| panic!("failed to parse calcit-core `:entries`: {e}")),
505
+ version,
506
+ entries,
425
507
  files,
426
508
  };
427
509
 
@@ -0,0 +1,6 @@
1
+ # Program diff 补齐 entry type slots
2
+
3
+ - `SnapshotConfigs.type_slots` 已用于默认 `:configs` 和命名 `:entries`,但 program diff 仍只枚举旧的 `init-fn`、`reload-fn`、`version` 与 `modules` 字段,导致纯 type-slot 修改被误报为无变化。
4
+ - 为字符串 map 增加稳定按 key 排序的结构化 diff,slot 标签保留 `:dispatch-op` 形式;新增或删除整个 entry 时也完整展示其 type slots。
5
+ - `Snapshot` 与 `SnapshotConfigs` 的 program diff 改为无 `..` 的完整字段解构。以后新增字段而未更新 diff 时会产生编译错误,避免同类静默遗漏。
6
+ - 回归测试覆盖默认 entry 的 slot 新增、删除、替换,命名 entry 的 slot 修改,以及新增 entry 时的 slot 详情。
@@ -0,0 +1,7 @@
1
+ # Unify snapshot entries and run modes
2
+
3
+ - Replaced the split top-level `:configs` plus `:entries` model with a single `:entries` map. `:default` is now the required implicit entry and the project version lives at top-level `:version`.
4
+ - Added entry-level `:mode` with the supported values `:native` and `:js`. A bare `cr <snapshot> [--entry name]` now follows the selected entry's mode; the explicit `js` subcommand remains available as an override.
5
+ - Kept legacy snapshot loading compatible: old `:configs` is migrated in memory to `entries.default` with native mode, while canonical writes emit only the unified schema.
6
+ - Updated config/query/diff/type-slot/module selection, embedded core serialization, repository snapshots, bundle/sync scripts, CLI help, RFCs, and user/Agent documentation.
7
+ - Added coverage for new-format round trips, legacy migration, configured JS dispatch, and default-entry module extraction.
@@ -0,0 +1,7 @@
1
+ # Entry description snapshot metadata
2
+
3
+ - `SnapshotEntry` now carries an optional `description` string for semantic context about an executable entry.
4
+ - Existing snapshots without `:description` remain valid and deserialize to an empty string; canonical snapshot writes include the field.
5
+ - Keep the build-script snapshot model synchronized with runtime `SnapshotEntry`, otherwise the embedded core MessagePack snapshot cannot be decoded.
6
+ - `cr config set [--entry <name>] description "..."` updates the field, and `cr config show` displays it.
7
+ - Program diffs expose description changes independently from runtime configuration and type-slot changes.
@@ -0,0 +1,6 @@
1
+ # Initialize entry descriptions in repository snapshots
2
+
3
+ - Installed the current `cr` 0.12.54 binary globally from this checkout.
4
+ - Used `cr <snapshot> config set description ''` to canonicalize every complete `calcit/**/*.cirru` snapshot.
5
+ - The migration updates 58 snapshots and 60 entry configurations, including named entries, with an explicit empty `:description` field.
6
+ - Empty values preserve existing runtime behavior while providing a stable place for future semantic descriptions.
@@ -0,0 +1,7 @@
1
+ # Store entry functions as Calcit symbols
2
+
3
+ - `:init-fn` and `:reload-fn` describe namespace/definition references, so canonical snapshot output now writes them as Cirru EDN symbols such as `'app.main/main!`.
4
+ - Snapshot readers continue to accept the prior string form (`|app.main/main!`) for compatibility.
5
+ - The embedded core-snapshot build model accepts either representation when deserializing entry metadata.
6
+ - Reinstalled `cr` globally and used it to rewrite all `calcit/**/*.cirru` snapshots; 120 entry function references now use symbols.
7
+ - Updated snapshot documentation and round-trip coverage to make the canonical syntax explicit.
@@ -0,0 +1,5 @@
1
+ # Release 0.12.55
2
+
3
+ - Bumped the Rust crate and npm package versions together to `0.12.55`.
4
+ - Refreshed the workspace lockfile before the release commit.
5
+ - This release includes semantic snapshot entry descriptions and canonical symbol storage for entry functions, while preserving legacy string input compatibility.
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.12.54",
3
+ "version": "0.12.55",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.7.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calcit/procs",
3
- "version": "0.12.54",
3
+ "version": "0.12.55",
4
4
  "main": "./lib/calcit.procs.mjs",
5
5
  "devDependencies": {
6
6
  "@types/node": "^25.7.0",