headson 0.6.1__tar.gz → 0.6.2__tar.gz

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.

Potentially problematic release.


This version of headson might be problematic. Click here for more details.

Files changed (83) hide show
  1. {headson-0.6.1 → headson-0.6.2}/Cargo.lock +93 -19
  2. {headson-0.6.1 → headson-0.6.2}/Cargo.toml +11 -1
  3. {headson-0.6.1 → headson-0.6.2}/PKG-INFO +54 -38
  4. {headson-0.6.1 → headson-0.6.2}/README.md +53 -36
  5. headson-0.6.2/docs/assets/tapes/demo.gif +0 -0
  6. {headson-0.6.1 → headson-0.6.2}/pyproject.toml +2 -2
  7. {headson-0.6.1 → headson-0.6.2}/python/Cargo.lock +67 -10
  8. {headson-0.6.1 → headson-0.6.2}/python/Cargo.toml +1 -1
  9. headson-0.6.2/python/README.md +53 -0
  10. headson-0.6.2/python/headson/__init__.py +11 -0
  11. headson-0.6.2/python/src/lib.rs +128 -0
  12. headson-0.6.2/src/format.rs +68 -0
  13. headson-0.6.2/src/ingest/mod.rs +120 -0
  14. {headson-0.6.1 → headson-0.6.2}/src/json_ingest/builder.rs +6 -3
  15. {headson-0.6.1 → headson-0.6.2}/src/lib.rs +38 -9
  16. {headson-0.6.1 → headson-0.6.2}/src/main.rs +173 -19
  17. {headson-0.6.1 → headson-0.6.2}/src/order/build.rs +120 -34
  18. headson-0.6.2/src/order/snapshots/headson__order__build__tests__order_empty_array_order.snap +6 -0
  19. headson-0.6.2/src/order/snapshots/headson__order__build__tests__order_single_string_array_order.snap +9 -0
  20. {headson-0.6.1 → headson-0.6.2}/src/order/types.rs +62 -9
  21. {headson-0.6.1 → headson-0.6.2}/src/serialization/color.rs +0 -7
  22. headson-0.6.2/src/serialization/fileset.rs +106 -0
  23. headson-0.6.2/src/serialization/mod.rs +1254 -0
  24. {headson-0.6.1 → headson-0.6.2}/src/serialization/output.rs +12 -17
  25. headson-0.6.2/src/serialization/snapshots/headson__serialization__tests__arena_render_empty_yaml.snap +6 -0
  26. headson-0.6.2/src/serialization/snapshots/headson__serialization__tests__arena_render_single_yaml.snap +5 -0
  27. headson-0.6.2/src/serialization/snapshots/headson__serialization__tests__array_internal_gaps_yaml.snap +9 -0
  28. headson-0.6.2/src/serialization/snapshots/headson__serialization__tests__array_omitted_yaml_head.snap +7 -0
  29. headson-0.6.2/src/serialization/snapshots/headson__serialization__tests__array_omitted_yaml_tail.snap +7 -0
  30. headson-0.6.2/src/serialization/snapshots/headson__serialization__tests__inline_open_array_in_object_yaml.snap +9 -0
  31. headson-0.6.2/src/serialization/templates/core.rs +130 -0
  32. headson-0.6.2/src/serialization/templates/js.rs +104 -0
  33. headson-0.6.2/src/serialization/templates/json.rs +32 -0
  34. {headson-0.6.1 → headson-0.6.2}/src/serialization/templates/mod.rs +11 -3
  35. {headson-0.6.1 → headson-0.6.2}/src/serialization/templates/pseudo.rs +50 -29
  36. headson-0.6.2/src/serialization/templates/yaml.rs +269 -0
  37. {headson-0.6.1 → headson-0.6.2}/src/serialization/types.rs +14 -3
  38. {headson-0.6.1 → headson-0.6.2}/src/snapshots/headson__order__tests__order_empty_array_order.snap +1 -1
  39. {headson-0.6.1 → headson-0.6.2}/src/snapshots/headson__order__tests__order_single_string_array_order.snap +4 -4
  40. {headson-0.6.1 → headson-0.6.2}/src/utils/tree_arena.rs +4 -5
  41. headson-0.6.2/src/yaml_ingest/mod.rs +292 -0
  42. headson-0.6.1/LICENSE +0 -21
  43. headson-0.6.1/docs/assets/tapes/demo.gif +0 -0
  44. headson-0.6.1/python/README.md +0 -45
  45. headson-0.6.1/python/headson/__init__.py +0 -6
  46. headson-0.6.1/python/src/lib.rs +0 -80
  47. headson-0.6.1/src/order/snapshots/headson__order__build__tests__order_empty_array_order.snap +0 -6
  48. headson-0.6.1/src/order/snapshots/headson__order__build__tests__order_single_string_array_order.snap +0 -9
  49. headson-0.6.1/src/serialization/fileset.rs +0 -164
  50. headson-0.6.1/src/serialization/mod.rs +0 -745
  51. headson-0.6.1/src/serialization/templates/core.rs +0 -124
  52. headson-0.6.1/src/serialization/templates/js.rs +0 -75
  53. headson-0.6.1/src/serialization/templates/json.rs +0 -29
  54. headson-0.6.1/src/snapshots/headson__order__tests__pq_empty_array_queue.snap +0 -6
  55. headson-0.6.1/src/snapshots/headson__order__tests__pq_single_string_array_queue.snap +0 -9
  56. headson-0.6.1/src/snapshots/headson__queue__tests__pq_empty_array_queue.snap +0 -7
  57. headson-0.6.1/src/snapshots/headson__queue__tests__pq_single_string_array_queue.snap +0 -10
  58. headson-0.6.1/src/snapshots/headson__tree__tests__build_tree_empty.snap +0 -5
  59. headson-0.6.1/src/snapshots/headson__tree__tests__build_tree_single.snap +0 -7
  60. {headson-0.6.1 → headson-0.6.2}/docs/assets/algorithm.svg +0 -0
  61. {headson-0.6.1 → headson-0.6.2}/docs/assets/logo.png +0 -0
  62. {headson-0.6.1 → headson-0.6.2}/docs/assets/logo.svg +0 -0
  63. {headson-0.6.1 → headson-0.6.2}/src/json_ingest/mod.rs +0 -0
  64. {headson-0.6.1 → headson-0.6.2}/src/json_ingest/samplers/default.rs +0 -0
  65. {headson-0.6.1 → headson-0.6.2}/src/json_ingest/samplers/head.rs +0 -0
  66. {headson-0.6.1 → headson-0.6.2}/src/json_ingest/samplers/mod.rs +0 -0
  67. {headson-0.6.1 → headson-0.6.2}/src/json_ingest/samplers/tail.rs +0 -0
  68. {headson-0.6.1 → headson-0.6.2}/src/order/mod.rs +0 -0
  69. {headson-0.6.1 → headson-0.6.2}/src/order/scoring.rs +0 -0
  70. {headson-0.6.1 → headson-0.6.2}/src/serialization/snapshots/headson__serialization__tests__arena_render_empty.snap +0 -0
  71. {headson-0.6.1 → headson-0.6.2}/src/serialization/snapshots/headson__serialization__tests__arena_render_single.snap +0 -0
  72. {headson-0.6.1 → headson-0.6.2}/src/serialization/snapshots/headson__serialization__tests__array_omitted_js_head.snap +0 -0
  73. {headson-0.6.1 → headson-0.6.2}/src/serialization/snapshots/headson__serialization__tests__array_omitted_js_tail.snap +0 -0
  74. {headson-0.6.1 → headson-0.6.2}/src/serialization/snapshots/headson__serialization__tests__array_omitted_pseudo_head.snap +0 -0
  75. {headson-0.6.1 → headson-0.6.2}/src/serialization/snapshots/headson__serialization__tests__array_omitted_pseudo_tail.snap +0 -0
  76. {headson-0.6.1 → headson-0.6.2}/src/serialization/snapshots/headson__serialization__tests__inline_open_array_in_object_json.snap +0 -0
  77. {headson-0.6.1 → headson-0.6.2}/src/utils/graph.rs +0 -0
  78. {headson-0.6.1 → headson-0.6.2}/src/utils/json.rs +0 -0
  79. {headson-0.6.1 → headson-0.6.2}/src/utils/mod.rs +0 -0
  80. {headson-0.6.1 → headson-0.6.2}/src/utils/search.rs +0 -0
  81. {headson-0.6.1 → headson-0.6.2}/src/utils/text.rs +0 -0
  82. {headson-0.6.1 → headson-0.6.2/tests/fixtures/json}/JSONTestSuite/LICENSE +0 -0
  83. {headson-0.6.1 → headson-0.6.2/tests/fixtures/json}/JSONTestSuite/README.md +0 -0
@@ -64,15 +64,20 @@ version = "1.0.100"
64
64
  source = "registry+https://github.com/rust-lang/crates.io-index"
65
65
  checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
66
66
 
67
+ [[package]]
68
+ name = "arraydeque"
69
+ version = "0.5.1"
70
+ source = "registry+https://github.com/rust-lang/crates.io-index"
71
+ checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236"
72
+
67
73
  [[package]]
68
74
  name = "assert_cmd"
69
- version = "2.0.17"
75
+ version = "2.1.1"
70
76
  source = "registry+https://github.com/rust-lang/crates.io-index"
71
- checksum = "2bd389a4b2970a01282ee455294913c0a43724daedcd1a24c3eb0ec1c1320b66"
77
+ checksum = "bcbb6924530aa9e0432442af08bbcafdad182db80d2e560da42a6d442535bf85"
72
78
  dependencies = [
73
79
  "anstyle",
74
80
  "bstr",
75
- "doc-comment",
76
81
  "libc",
77
82
  "predicates",
78
83
  "predicates-core",
@@ -111,9 +116,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
111
116
 
112
117
  [[package]]
113
118
  name = "clap"
114
- version = "4.5.50"
119
+ version = "4.5.51"
115
120
  source = "registry+https://github.com/rust-lang/crates.io-index"
116
- checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623"
121
+ checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5"
117
122
  dependencies = [
118
123
  "clap_builder",
119
124
  "clap_derive",
@@ -121,9 +126,9 @@ dependencies = [
121
126
 
122
127
  [[package]]
123
128
  name = "clap_builder"
124
- version = "4.5.50"
129
+ version = "4.5.51"
125
130
  source = "registry+https://github.com/rust-lang/crates.io-index"
126
- checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0"
131
+ checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a"
127
132
  dependencies = [
128
133
  "anstream",
129
134
  "anstyle",
@@ -182,18 +187,21 @@ version = "0.4.0"
182
187
  source = "registry+https://github.com/rust-lang/crates.io-index"
183
188
  checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
184
189
 
185
- [[package]]
186
- name = "doc-comment"
187
- version = "0.3.3"
188
- source = "registry+https://github.com/rust-lang/crates.io-index"
189
- checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
190
-
191
190
  [[package]]
192
191
  name = "encode_unicode"
193
192
  version = "1.0.0"
194
193
  source = "registry+https://github.com/rust-lang/crates.io-index"
195
194
  checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
196
195
 
196
+ [[package]]
197
+ name = "encoding_rs"
198
+ version = "0.8.35"
199
+ source = "registry+https://github.com/rust-lang/crates.io-index"
200
+ checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
201
+ dependencies = [
202
+ "cfg-if",
203
+ ]
204
+
197
205
  [[package]]
198
206
  name = "equivalent"
199
207
  version = "1.0.2"
@@ -207,7 +215,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
207
215
  checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
208
216
  dependencies = [
209
217
  "libc",
210
- "windows-sys 0.60.2",
218
+ "windows-sys 0.59.0",
211
219
  ]
212
220
 
213
221
  [[package]]
@@ -225,6 +233,12 @@ dependencies = [
225
233
  "num-traits",
226
234
  ]
227
235
 
236
+ [[package]]
237
+ name = "foldhash"
238
+ version = "0.1.5"
239
+ source = "registry+https://github.com/rust-lang/crates.io-index"
240
+ checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
241
+
228
242
  [[package]]
229
243
  name = "foldhash"
230
244
  version = "0.2.0"
@@ -249,10 +263,19 @@ version = "0.4.0"
249
263
  source = "registry+https://github.com/rust-lang/crates.io-index"
250
264
  checksum = "0c7ed2f2edad8a14c8186b847909a41fbb9c3eafa44f88bd891114ed5019da09"
251
265
  dependencies = [
252
- "hashbrown",
266
+ "hashbrown 0.16.0",
253
267
  "serde",
254
268
  ]
255
269
 
270
+ [[package]]
271
+ name = "hashbrown"
272
+ version = "0.15.5"
273
+ source = "registry+https://github.com/rust-lang/crates.io-index"
274
+ checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
275
+ dependencies = [
276
+ "foldhash 0.1.5",
277
+ ]
278
+
256
279
  [[package]]
257
280
  name = "hashbrown"
258
281
  version = "0.16.0"
@@ -261,12 +284,21 @@ checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
261
284
  dependencies = [
262
285
  "allocator-api2",
263
286
  "equivalent",
264
- "foldhash",
287
+ "foldhash 0.2.0",
288
+ ]
289
+
290
+ [[package]]
291
+ name = "hashlink"
292
+ version = "0.10.0"
293
+ source = "registry+https://github.com/rust-lang/crates.io-index"
294
+ checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
295
+ dependencies = [
296
+ "hashbrown 0.15.5",
265
297
  ]
266
298
 
267
299
  [[package]]
268
300
  name = "headson"
269
- version = "0.6.1"
301
+ version = "0.6.2"
270
302
  dependencies = [
271
303
  "anyhow",
272
304
  "assert_cmd",
@@ -277,10 +309,12 @@ dependencies = [
277
309
  "rand_chacha",
278
310
  "serde",
279
311
  "serde_json",
312
+ "serde_yaml",
280
313
  "simd-json",
281
314
  "tempfile",
282
315
  "test_each_file",
283
316
  "unicode-segmentation",
317
+ "yaml-rust2",
284
318
  ]
285
319
 
286
320
  [[package]]
@@ -289,6 +323,16 @@ version = "0.5.0"
289
323
  source = "registry+https://github.com/rust-lang/crates.io-index"
290
324
  checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
291
325
 
326
+ [[package]]
327
+ name = "indexmap"
328
+ version = "2.12.0"
329
+ source = "registry+https://github.com/rust-lang/crates.io-index"
330
+ checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f"
331
+ dependencies = [
332
+ "equivalent",
333
+ "hashbrown 0.16.0",
334
+ ]
335
+
292
336
  [[package]]
293
337
  name = "insta"
294
338
  version = "1.43.2"
@@ -476,7 +520,7 @@ dependencies = [
476
520
  "errno",
477
521
  "libc",
478
522
  "linux-raw-sys",
479
- "windows-sys 0.60.2",
523
+ "windows-sys 0.59.0",
480
524
  ]
481
525
 
482
526
  [[package]]
@@ -528,6 +572,19 @@ dependencies = [
528
572
  "serde_core",
529
573
  ]
530
574
 
575
+ [[package]]
576
+ name = "serde_yaml"
577
+ version = "0.9.34+deprecated"
578
+ source = "registry+https://github.com/rust-lang/crates.io-index"
579
+ checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
580
+ dependencies = [
581
+ "indexmap",
582
+ "itoa",
583
+ "ryu",
584
+ "serde",
585
+ "unsafe-libyaml",
586
+ ]
587
+
531
588
  [[package]]
532
589
  name = "simd-json"
533
590
  version = "0.17.0"
@@ -581,7 +638,7 @@ dependencies = [
581
638
  "getrandom",
582
639
  "once_cell",
583
640
  "rustix",
584
- "windows-sys 0.60.2",
641
+ "windows-sys 0.59.0",
585
642
  ]
586
643
 
587
644
  [[package]]
@@ -614,6 +671,12 @@ version = "1.12.0"
614
671
  source = "registry+https://github.com/rust-lang/crates.io-index"
615
672
  checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
616
673
 
674
+ [[package]]
675
+ name = "unsafe-libyaml"
676
+ version = "0.2.11"
677
+ source = "registry+https://github.com/rust-lang/crates.io-index"
678
+ checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
679
+
617
680
  [[package]]
618
681
  name = "utf8parse"
619
682
  version = "0.2.2"
@@ -809,6 +872,17 @@ version = "0.46.0"
809
872
  source = "registry+https://github.com/rust-lang/crates.io-index"
810
873
  checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
811
874
 
875
+ [[package]]
876
+ name = "yaml-rust2"
877
+ version = "0.10.4"
878
+ source = "registry+https://github.com/rust-lang/crates.io-index"
879
+ checksum = "2462ea039c445496d8793d052e13787f2b90e750b833afee748e601c17621ed9"
880
+ dependencies = [
881
+ "arraydeque",
882
+ "encoding_rs",
883
+ "hashlink",
884
+ ]
885
+
812
886
  [[package]]
813
887
  name = "zerocopy"
814
888
  version = "0.8.27"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "headson"
3
- version = "0.6.1"
3
+ version = "0.6.2"
4
4
  edition = "2024"
5
5
  description = "Budget‑constrained JSON preview renderer"
6
6
  readme = "README.md"
@@ -27,6 +27,15 @@ serde_json = "1.0.145"
27
27
  unicode-segmentation = "1.12.0"
28
28
  simd-json = { version = "0.17", features = ["serde_impl"] }
29
29
  content_inspector = "0.2"
30
+ yaml-rust2 = "0.10"
31
+
32
+
33
+
34
+ [features]
35
+ default = []
36
+
37
+ [lib]
38
+ doctest = false
30
39
 
31
40
  [dev-dependencies]
32
41
  insta = "1.40.0"
@@ -35,6 +44,7 @@ test_each_file = "0.3"
35
44
  rand = "0.9"
36
45
  rand_chacha = "0.9"
37
46
  tempfile = "3"
47
+ serde_yaml = "0.9"
38
48
 
39
49
  [profile.release]
40
50
  # Prioritize runtime speed for large inputs
@@ -1,13 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: headson
3
- Version: 0.6.1
3
+ Version: 0.6.2
4
4
  Classifier: Programming Language :: Python
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Rust
7
7
  Classifier: Operating System :: OS Independent
8
8
  Requires-Dist: pytest>=8 ; extra == 'test'
9
9
  Provides-Extra: test
10
- License-File: LICENSE
11
10
  Summary: Budget‑constrained JSON preview renderer (Python bindings)
12
11
  Keywords: json,preview,summarize,cli,bindings
13
12
  Requires-Python: >=3.10
@@ -21,7 +20,7 @@ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
21
20
  <br/>
22
21
  </p>
23
22
 
24
- Head/tail for JSON — but structure‑aware. Get a compact preview that shows both the shape and representative values of your data, all within a strict character budget.
23
+ Head/tail for JSON and YAML — but structure‑aware. Get a compact preview that shows both the shape and representative values of your data, all within a strict character budget.
25
24
 
26
25
  Available as:
27
26
  - CLI (see [Usage](#usage))
@@ -41,11 +40,14 @@ From source:
41
40
 
42
41
  ## Features
43
42
 
44
- - *Budgeted output*: specify exactly how much JSON you want to see
45
- - *Multiple output formats* : `json` (machine‑readable), `pseudo` (human‑friendly), `js` (valid JavaScript, most detailed metadata).
46
- - *Multiple inputs*: preview many files at once with a shared or per‑file budget.
47
- - *Fast*: can process gigabyte-scale files in seconds (mostly disk-constrained)
48
- - *Available as a CLI app and as a Python library*
43
+ - Budgeted output: specify exactly how much you want to see
44
+ - Output formats: `auto | json | yaml`
45
+ - Styles: `strict | default | detailed`
46
+ - JSON family: `strict` strict JSON, `default` human‑friendly Pseudo, `detailed` → JS with inline comments
47
+ - YAML: always YAML; `strict` has no comments, `default` uses “# …”, `detailed` uses “# N more …”
48
+ - Multiple inputs: preview many files at once with a shared or per‑file budget
49
+ - Fast: processes gigabyte‑scale files in seconds (mostly disk‑bound)
50
+ - Available as a CLI app and as a Python library
49
51
 
50
52
  ## Fits into command line workflows
51
53
 
@@ -59,47 +61,54 @@ If you’re comfortable with tools like `head` and `tail`, use `headson` when yo
59
61
 
60
62
  headson [FLAGS] [INPUT...]
61
63
 
62
- - INPUT (optional, repeatable): file path(s). If omitted, reads JSON from stdin. Multiple input files are supported.
64
+ - INPUT (optional, repeatable): file path(s). If omitted, reads from stdin. Multiple input files are supported.
63
65
  - Prints the preview to stdout. On parse errors, exits non‑zero and prints an error to stderr.
64
66
 
65
67
  Common flags:
66
68
 
67
- - `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the default total budget equals `<BYTES> * number_of_inputs`.
68
- - `-N, --global-budget <BYTES>`: total output budget across all inputs. Useful when you want a fixed-size preview across many files (may omit entire files).
69
- - When used together with `--budget`, the final total budget is `min(global, per_file * number_of_inputs)`. Files are only truncated if they don't fit into this final global limit, and no single file expands beyond the per‑file budget.
70
- - `-f, --template <json|pseudo|js>`: output style (default: `pseudo`)
69
+ - `-n, --budget <BYTES>`: per‑file output budget. For multiple inputs, default total budget is `<BYTES> * number_of_inputs`.
70
+ - `-N, --global-budget <BYTES>`: total output budget across all inputs. With `--budget`, the effective total is the smaller of the two.
71
+ - `-f, --format <auto|json|yaml>`: output format (default: `auto`).
72
+ - Auto: stdin JSON family; filesets → per‑file based on extension (`.json` → JSON family, `.yaml`/`.yml` → YAML).
73
+ - `-t, --template <strict|default|detailed>`: output style (default: `default`).
74
+ - JSON family: `strict` → strict JSON; `default` → Pseudo; `detailed` → JS with inline comments.
75
+ - YAML: always YAML; style only affects comments (`strict` none, `default` “# …”, `detailed` “# N more …”).
76
+ - `-i, --input-format <json|yaml>`: ingestion format (default: `json`). For filesets in `auto` format, ingestion is chosen by extensions.
71
77
  - `-m, --compact`: no indentation, no spaces, no newlines
72
78
  - `--no-newline`: single line output
73
79
  - `--no-space`: no space after `:` in objects
74
80
  - `--indent <STR>`: indentation unit (default: two spaces)
75
81
  - `--string-cap <N>`: max graphemes to consider per string (default: 500)
76
- - `--head`: prefer the beginning of arrays when truncating (keep first N). Strings are unaffected. In `pseudo`/`js` templates the omission marker appears near the end; `json` remains strict. Mutually exclusive with `--tail`.
77
- - `--tail`: prefer the end of arrays when truncating (keep last N). Strings are unaffected. In `pseudo`/`js` templates the omission marker appears at the start; `json` remains strict. Mutually exclusive with `--head`.
82
+ - `--head`: prefer the beginning of arrays when truncating (keep first N). Strings are unaffected. Display styles place omission markers accordingly; strict JSON remains unannotated. Mutually exclusive with `--tail`.
83
+ - `--tail`: prefer the end of arrays when truncating (keep last N). Strings are unaffected. Display styles place omission markers accordingly; strict JSON remains unannotated. Mutually exclusive with `--head`.
78
84
 
79
85
  Notes:
80
86
 
81
- - With multiple input files:
82
- - JSON template outputs a single JSON object keyed by the input file paths.
83
- - Pseudo and JS templates render file sections with human-readable headers when newlines are enabled.
84
- - If you use `--compact` or `--no-newline` (both disable newlines), fileset output falls back to standard inline rendering (no per-file headers) to remain compact.
85
- - Using `--global-budget` may truncate or omit entire files to respect the total budget.
86
- - The tool finds the largest preview that fits the budget; if even the tiniest preview exceeds it, you still get a minimal, valid preview.
87
- - When passing file paths, directories and binary files are ignored; a notice is printed to stderr for each (e.g., `Ignored binary file: ./path/to/file`). Stdin mode reads the stream as-is.
88
- - Head vs Tail sampling: these options bias which part of arrays are kept before rendering. They guarantee the kept segment is contiguous at the chosen side (prefix for `--head`, suffix for `--tail`). Display templates may still insert additional internal gap markers inside that kept segment to honor very small budgets; `json` remains strict and unannotated.
87
+ - Multiple inputs:
88
+ - With newlines enabled, file sections are rendered with human‑readable headers. In compact/single‑line modes, headers are omitted.
89
+ - In `--format auto`, each file uses its own best format: JSON family for `.json`, YAML for `.yaml`/`.yml`.
90
+ - `--global-budget` may truncate or omit entire files to respect the total budget.
91
+ - The tool finds the largest preview that fits the budget; even if extremely tight, you still get a minimal, valid preview.
92
+ - Directories and binary files are ignored; a notice is printed to stderr for each. Stdin reads the stream as‑is.
93
+ - Head vs Tail sampling: these options bias which part of arrays are kept before rendering. Display styles may still insert internal gap markers to honor very small budgets; strict JSON stays unannotated.
89
94
 
90
95
  Quick one‑liners:
91
96
 
92
97
  - Peek a big JSON stream (keeps structure):
93
98
 
94
- zstdcat huge.json.zst | headson -n 800 -f pseudo
99
+ zstdcat huge.json.zst | headson -n 800 -f json -t default
95
100
 
96
101
  - Many files with a fixed overall size:
97
102
 
98
- headson -N 1200 -f json logs/*.json
103
+ headson -N 1200 -f json -t strict logs/*.json
99
104
 
100
105
  - Glance at a file, JavaScript‑style comments for omissions:
101
106
 
102
- headson -n 400 -f js data.json
107
+ headson -n 400 -f json -t detailed data.json
108
+
109
+ - YAML with detailed comments:
110
+
111
+ headson -n 400 -f yaml -t detailed config.yaml
103
112
 
104
113
  Show help:
105
114
 
@@ -120,10 +129,10 @@ jq -c . users.json | head -c 80
120
129
  # {"users":[{"id":1,"name":"Ana","roles":["admin","dev"]},{"id":2,"name":"Bo"}],"me
121
130
  ```
122
131
 
123
- Structured preview with headson (pseudo):
132
+ Structured preview with headson (JSON family, default style → Pseudo):
124
133
 
125
134
  ```bash
126
- headson -n 120 -f pseudo users.json
135
+ headson -n 120 -f json -t default users.json
127
136
  # {
128
137
  # users: [
129
138
  # { id: 1, name: "Ana", roles: [ "admin", … ] },
@@ -133,10 +142,10 @@ headson -n 120 -f pseudo users.json
133
142
  # }
134
143
  ```
135
144
 
136
- Machine‑readable preview (json):
145
+ Machine‑readable preview (JSON family, strict style → strict JSON):
137
146
 
138
147
  ```bash
139
- headson -n 120 -f json users.json
148
+ headson -n 120 -f json -t strict users.json
140
149
  # {"users":[{"id":1,"name":"Ana","roles":["admin"]}],"meta":{"count":2}}
141
150
  ```
142
151
 
@@ -152,32 +161,39 @@ Regenerate locally:
152
161
 
153
162
  A thin Python extension module is available on PyPI as `headson`.
154
163
 
155
- - Install: `pip install headson` (ABI3 wheels for Python 3.10+ on Linux/macOS/Windows).
164
+ - Install: `pip install headson` (ABI3 wheels for Python 3.10+ on Linux/macOS/Windows).
156
165
  - API:
157
- - `headson.summarize(text: str, *, template: str = "pseudo", character_budget: int | None = None, skew: str = "balanced") -> str`
158
- - `template`: one of `"json" | "pseudo" | "js"`
166
+ - `headson.summarize(text: str, *, format: str = "auto", style: str = "default", input_format: str = "json", character_budget: int | None = None, skew: str = "balanced") -> str`
167
+ - `format`: `"auto" | "json" | "yaml"` (auto maps to JSON family for single inputs)
168
+ - `style`: `"strict" | "default" | "detailed"`
169
+ - `input_format`: `"json" | "yaml"` (ingestion)
159
170
  - `character_budget`: maximum output size in characters (default: 500)
160
- - `skew`: one of `"balanced" | "head" | "tail"` (focus arrays on start vs end; only affects display templates; `json` remains strict).
171
+ - `skew`: `"balanced" | "head" | "tail"` (affects display styles; strict JSON remains unannotated)
161
172
 
162
- Example:
173
+ Examples:
163
174
 
164
175
  ```python
165
176
  import json
166
177
  import headson
167
178
 
168
179
  data = {"foo": [1, 2, 3], "bar": {"x": "y"}}
169
- preview = headson.summarize(json.dumps(data), template="json", character_budget=200)
180
+ preview = headson.summarize(json.dumps(data), format="json", style="strict", character_budget=200)
170
181
  print(preview)
171
182
 
172
- # Prefer the tail of arrays (annotations show in pseudo/js only)
183
+ # Prefer the tail of arrays (annotations show with style="default"/"detailed")
173
184
  print(
174
185
  headson.summarize(
175
186
  json.dumps(list(range(100))),
176
- template="pseudo",
187
+ format="json",
188
+ style="detailed",
177
189
  character_budget=80,
178
190
  skew="tail",
179
191
  )
180
192
  )
193
+
194
+ # YAML support
195
+ doc = "root:\n items: [1,2,3,4,5,6,7,8,9,10]\n"
196
+ print(headson.summarize(doc, format="yaml", style="default", input_format="yaml", character_budget=60))
181
197
  ```
182
198
 
183
199
  # Algorithm
@@ -6,7 +6,7 @@
6
6
  <br/>
7
7
  </p>
8
8
 
9
- Head/tail for JSON — but structure‑aware. Get a compact preview that shows both the shape and representative values of your data, all within a strict character budget.
9
+ Head/tail for JSON and YAML — but structure‑aware. Get a compact preview that shows both the shape and representative values of your data, all within a strict character budget.
10
10
 
11
11
  Available as:
12
12
  - CLI (see [Usage](#usage))
@@ -26,11 +26,14 @@ From source:
26
26
 
27
27
  ## Features
28
28
 
29
- - *Budgeted output*: specify exactly how much JSON you want to see
30
- - *Multiple output formats* : `json` (machine‑readable), `pseudo` (human‑friendly), `js` (valid JavaScript, most detailed metadata).
31
- - *Multiple inputs*: preview many files at once with a shared or per‑file budget.
32
- - *Fast*: can process gigabyte-scale files in seconds (mostly disk-constrained)
33
- - *Available as a CLI app and as a Python library*
29
+ - Budgeted output: specify exactly how much you want to see
30
+ - Output formats: `auto | json | yaml`
31
+ - Styles: `strict | default | detailed`
32
+ - JSON family: `strict` strict JSON, `default` human‑friendly Pseudo, `detailed` → JS with inline comments
33
+ - YAML: always YAML; `strict` has no comments, `default` uses “# …”, `detailed` uses “# N more …”
34
+ - Multiple inputs: preview many files at once with a shared or per‑file budget
35
+ - Fast: processes gigabyte‑scale files in seconds (mostly disk‑bound)
36
+ - Available as a CLI app and as a Python library
34
37
 
35
38
  ## Fits into command line workflows
36
39
 
@@ -44,47 +47,54 @@ If you’re comfortable with tools like `head` and `tail`, use `headson` when yo
44
47
 
45
48
  headson [FLAGS] [INPUT...]
46
49
 
47
- - INPUT (optional, repeatable): file path(s). If omitted, reads JSON from stdin. Multiple input files are supported.
50
+ - INPUT (optional, repeatable): file path(s). If omitted, reads from stdin. Multiple input files are supported.
48
51
  - Prints the preview to stdout. On parse errors, exits non‑zero and prints an error to stderr.
49
52
 
50
53
  Common flags:
51
54
 
52
- - `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the default total budget equals `<BYTES> * number_of_inputs`.
53
- - `-N, --global-budget <BYTES>`: total output budget across all inputs. Useful when you want a fixed-size preview across many files (may omit entire files).
54
- - When used together with `--budget`, the final total budget is `min(global, per_file * number_of_inputs)`. Files are only truncated if they don't fit into this final global limit, and no single file expands beyond the per‑file budget.
55
- - `-f, --template <json|pseudo|js>`: output style (default: `pseudo`)
55
+ - `-n, --budget <BYTES>`: per‑file output budget. For multiple inputs, default total budget is `<BYTES> * number_of_inputs`.
56
+ - `-N, --global-budget <BYTES>`: total output budget across all inputs. With `--budget`, the effective total is the smaller of the two.
57
+ - `-f, --format <auto|json|yaml>`: output format (default: `auto`).
58
+ - Auto: stdin JSON family; filesets → per‑file based on extension (`.json` → JSON family, `.yaml`/`.yml` → YAML).
59
+ - `-t, --template <strict|default|detailed>`: output style (default: `default`).
60
+ - JSON family: `strict` → strict JSON; `default` → Pseudo; `detailed` → JS with inline comments.
61
+ - YAML: always YAML; style only affects comments (`strict` none, `default` “# …”, `detailed` “# N more …”).
62
+ - `-i, --input-format <json|yaml>`: ingestion format (default: `json`). For filesets in `auto` format, ingestion is chosen by extensions.
56
63
  - `-m, --compact`: no indentation, no spaces, no newlines
57
64
  - `--no-newline`: single line output
58
65
  - `--no-space`: no space after `:` in objects
59
66
  - `--indent <STR>`: indentation unit (default: two spaces)
60
67
  - `--string-cap <N>`: max graphemes to consider per string (default: 500)
61
- - `--head`: prefer the beginning of arrays when truncating (keep first N). Strings are unaffected. In `pseudo`/`js` templates the omission marker appears near the end; `json` remains strict. Mutually exclusive with `--tail`.
62
- - `--tail`: prefer the end of arrays when truncating (keep last N). Strings are unaffected. In `pseudo`/`js` templates the omission marker appears at the start; `json` remains strict. Mutually exclusive with `--head`.
68
+ - `--head`: prefer the beginning of arrays when truncating (keep first N). Strings are unaffected. Display styles place omission markers accordingly; strict JSON remains unannotated. Mutually exclusive with `--tail`.
69
+ - `--tail`: prefer the end of arrays when truncating (keep last N). Strings are unaffected. Display styles place omission markers accordingly; strict JSON remains unannotated. Mutually exclusive with `--head`.
63
70
 
64
71
  Notes:
65
72
 
66
- - With multiple input files:
67
- - JSON template outputs a single JSON object keyed by the input file paths.
68
- - Pseudo and JS templates render file sections with human-readable headers when newlines are enabled.
69
- - If you use `--compact` or `--no-newline` (both disable newlines), fileset output falls back to standard inline rendering (no per-file headers) to remain compact.
70
- - Using `--global-budget` may truncate or omit entire files to respect the total budget.
71
- - The tool finds the largest preview that fits the budget; if even the tiniest preview exceeds it, you still get a minimal, valid preview.
72
- - When passing file paths, directories and binary files are ignored; a notice is printed to stderr for each (e.g., `Ignored binary file: ./path/to/file`). Stdin mode reads the stream as-is.
73
- - Head vs Tail sampling: these options bias which part of arrays are kept before rendering. They guarantee the kept segment is contiguous at the chosen side (prefix for `--head`, suffix for `--tail`). Display templates may still insert additional internal gap markers inside that kept segment to honor very small budgets; `json` remains strict and unannotated.
73
+ - Multiple inputs:
74
+ - With newlines enabled, file sections are rendered with human‑readable headers. In compact/single‑line modes, headers are omitted.
75
+ - In `--format auto`, each file uses its own best format: JSON family for `.json`, YAML for `.yaml`/`.yml`.
76
+ - `--global-budget` may truncate or omit entire files to respect the total budget.
77
+ - The tool finds the largest preview that fits the budget; even if extremely tight, you still get a minimal, valid preview.
78
+ - Directories and binary files are ignored; a notice is printed to stderr for each. Stdin reads the stream as‑is.
79
+ - Head vs Tail sampling: these options bias which part of arrays are kept before rendering. Display styles may still insert internal gap markers to honor very small budgets; strict JSON stays unannotated.
74
80
 
75
81
  Quick one‑liners:
76
82
 
77
83
  - Peek a big JSON stream (keeps structure):
78
84
 
79
- zstdcat huge.json.zst | headson -n 800 -f pseudo
85
+ zstdcat huge.json.zst | headson -n 800 -f json -t default
80
86
 
81
87
  - Many files with a fixed overall size:
82
88
 
83
- headson -N 1200 -f json logs/*.json
89
+ headson -N 1200 -f json -t strict logs/*.json
84
90
 
85
91
  - Glance at a file, JavaScript‑style comments for omissions:
86
92
 
87
- headson -n 400 -f js data.json
93
+ headson -n 400 -f json -t detailed data.json
94
+
95
+ - YAML with detailed comments:
96
+
97
+ headson -n 400 -f yaml -t detailed config.yaml
88
98
 
89
99
  Show help:
90
100
 
@@ -105,10 +115,10 @@ jq -c . users.json | head -c 80
105
115
  # {"users":[{"id":1,"name":"Ana","roles":["admin","dev"]},{"id":2,"name":"Bo"}],"me
106
116
  ```
107
117
 
108
- Structured preview with headson (pseudo):
118
+ Structured preview with headson (JSON family, default style → Pseudo):
109
119
 
110
120
  ```bash
111
- headson -n 120 -f pseudo users.json
121
+ headson -n 120 -f json -t default users.json
112
122
  # {
113
123
  # users: [
114
124
  # { id: 1, name: "Ana", roles: [ "admin", … ] },
@@ -118,10 +128,10 @@ headson -n 120 -f pseudo users.json
118
128
  # }
119
129
  ```
120
130
 
121
- Machine‑readable preview (json):
131
+ Machine‑readable preview (JSON family, strict style → strict JSON):
122
132
 
123
133
  ```bash
124
- headson -n 120 -f json users.json
134
+ headson -n 120 -f json -t strict users.json
125
135
  # {"users":[{"id":1,"name":"Ana","roles":["admin"]}],"meta":{"count":2}}
126
136
  ```
127
137
 
@@ -137,32 +147,39 @@ Regenerate locally:
137
147
 
138
148
  A thin Python extension module is available on PyPI as `headson`.
139
149
 
140
- - Install: `pip install headson` (ABI3 wheels for Python 3.10+ on Linux/macOS/Windows).
150
+ - Install: `pip install headson` (ABI3 wheels for Python 3.10+ on Linux/macOS/Windows).
141
151
  - API:
142
- - `headson.summarize(text: str, *, template: str = "pseudo", character_budget: int | None = None, skew: str = "balanced") -> str`
143
- - `template`: one of `"json" | "pseudo" | "js"`
152
+ - `headson.summarize(text: str, *, format: str = "auto", style: str = "default", input_format: str = "json", character_budget: int | None = None, skew: str = "balanced") -> str`
153
+ - `format`: `"auto" | "json" | "yaml"` (auto maps to JSON family for single inputs)
154
+ - `style`: `"strict" | "default" | "detailed"`
155
+ - `input_format`: `"json" | "yaml"` (ingestion)
144
156
  - `character_budget`: maximum output size in characters (default: 500)
145
- - `skew`: one of `"balanced" | "head" | "tail"` (focus arrays on start vs end; only affects display templates; `json` remains strict).
157
+ - `skew`: `"balanced" | "head" | "tail"` (affects display styles; strict JSON remains unannotated)
146
158
 
147
- Example:
159
+ Examples:
148
160
 
149
161
  ```python
150
162
  import json
151
163
  import headson
152
164
 
153
165
  data = {"foo": [1, 2, 3], "bar": {"x": "y"}}
154
- preview = headson.summarize(json.dumps(data), template="json", character_budget=200)
166
+ preview = headson.summarize(json.dumps(data), format="json", style="strict", character_budget=200)
155
167
  print(preview)
156
168
 
157
- # Prefer the tail of arrays (annotations show in pseudo/js only)
169
+ # Prefer the tail of arrays (annotations show with style="default"/"detailed")
158
170
  print(
159
171
  headson.summarize(
160
172
  json.dumps(list(range(100))),
161
- template="pseudo",
173
+ format="json",
174
+ style="detailed",
162
175
  character_budget=80,
163
176
  skew="tail",
164
177
  )
165
178
  )
179
+
180
+ # YAML support
181
+ doc = "root:\n items: [1,2,3,4,5,6,7,8,9,10]\n"
182
+ print(headson.summarize(doc, format="yaml", style="default", input_format="yaml", character_budget=60))
166
183
  ```
167
184
 
168
185
  # Algorithm
Binary file