@humanu/orchestra 0.5.33 → 0.5.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humanu/orchestra",
3
- "version": "0.5.33",
3
+ "version": "0.5.34",
4
4
  "description": "AI-powered Git worktree and tmux session manager with modern TUI",
5
5
  "keywords": [
6
6
  "git",
@@ -23,9 +23,62 @@ bridge_init_json_backend() {
23
23
  # Internal helper to emit a JSON object.
24
24
  # Arguments use the format `key[:type]=value` where type defaults to `s` (string).
25
25
  # Supported types: s (string), n (numeric), b (boolean), j (raw JSON), null (null literal).
26
+ json_object_sh() {
27
+ local first=1
28
+ local spec key rest type value
29
+ printf '{'
30
+ for spec in "$@"; do
31
+ [[ -z "$spec" ]] && continue
32
+ key="${spec%%:*}"
33
+ rest="${spec#*:}"
34
+ if [[ "$rest" == "$spec" ]]; then
35
+ rest="s"
36
+ fi
37
+ if [[ "$rest" == *=* ]]; then
38
+ type="${rest%%=*}"
39
+ value="${rest#*=}"
40
+ else
41
+ type="s"
42
+ value="$rest"
43
+ fi
44
+ if [[ $first -eq 0 ]]; then
45
+ printf ','
46
+ fi
47
+ printf '"%s":' "$(json_escape "$key")"
48
+ case "$type" in
49
+ s)
50
+ printf '"%s"' "$(json_escape "$value")"
51
+ ;;
52
+ n)
53
+ printf '%s' "${value:-0}"
54
+ ;;
55
+ b)
56
+ case "$value" in
57
+ 1|true|TRUE|True|yes|on) printf 'true' ;;
58
+ *) printf 'false' ;;
59
+ esac
60
+ ;;
61
+ j)
62
+ [[ -n "$value" ]] && printf '%s' "$value" || printf 'null'
63
+ ;;
64
+ null)
65
+ printf 'null'
66
+ ;;
67
+ *)
68
+ printf '"%s"' "$(json_escape "$value")"
69
+ ;;
70
+ esac
71
+ first=0
72
+ done
73
+ printf '}'
74
+ }
75
+
26
76
  json_object() {
27
77
  bridge_init_json_backend
28
78
  case "$BRIDGE_JSON_BACKEND" in
79
+ sh)
80
+ json_object_sh "$@"
81
+ ;;
29
82
  jq)
30
83
  local -a jq_args=()
31
84
  local -a jq_expr_parts=()
@@ -184,10 +237,28 @@ NODE
184
237
  }
185
238
 
186
239
  # Helper to convert newline-delimited text into a JSON array (dropping trailing blank)
240
+ json_array_from_lines_sh() {
241
+ local input="$1"
242
+ local first=1
243
+ printf '['
244
+ while IFS= read -r line; do
245
+ [[ -z "$line" ]] && continue
246
+ if [[ $first -eq 0 ]]; then
247
+ printf ','
248
+ fi
249
+ printf '"%s"' "$(json_escape "$line")"
250
+ first=0
251
+ done <<<"$input"
252
+ printf ']'
253
+ }
254
+
187
255
  json_array_from_lines() {
188
256
  bridge_init_json_backend
189
257
  local input="$1"
190
258
  case "$BRIDGE_JSON_BACKEND" in
259
+ sh)
260
+ json_array_from_lines_sh "$input"
261
+ ;;
191
262
  jq)
192
263
  printf '%s' "$input" | jq -R -s 'split("\n")[:-1]'
193
264
  ;;
@@ -221,6 +292,9 @@ json_stringify() {
221
292
  bridge_init_json_backend
222
293
  local input="$1"
223
294
  case "$BRIDGE_JSON_BACKEND" in
295
+ sh)
296
+ printf '"%s"' "$(json_escape "$input")"
297
+ ;;
224
298
  jq)
225
299
  printf '%s' "$input" | jq -R -s .
226
300
  ;;
@@ -241,10 +315,28 @@ NODE
241
315
  }
242
316
 
243
317
  # Helper to convert newline-separated JSON objects into an array
318
+ json_array_from_json_lines_sh() {
319
+ local input="$1"
320
+ local first=1
321
+ printf '['
322
+ while IFS= read -r line; do
323
+ [[ -z "$line" ]] && continue
324
+ if [[ $first -eq 0 ]]; then
325
+ printf ','
326
+ fi
327
+ printf '%s' "$line"
328
+ first=0
329
+ done <<<"$input"
330
+ printf ']'
331
+ }
332
+
244
333
  json_array_from_json_lines() {
245
334
  bridge_init_json_backend
246
335
  local input="$1"
247
336
  case "$BRIDGE_JSON_BACKEND" in
337
+ sh)
338
+ json_array_from_json_lines_sh "$input"
339
+ ;;
248
340
  jq)
249
341
  printf '%s' "$input" | jq -s .
250
342
  ;;
@@ -332,9 +424,29 @@ git_error_summary() {
332
424
  }
333
425
 
334
426
  # Helper function to output structured worktree data
427
+ json_worktrees_sh() {
428
+ local first=1
429
+ printf '['
430
+ while IFS=$'\t' read -r path branch sha; do
431
+ [[ -z "$path" ]] && continue
432
+ if [[ $first -eq 0 ]]; then
433
+ printf ','
434
+ fi
435
+ printf '{"path":"%s","branch":"%s","sha":"%s"}' \
436
+ "$(json_escape "$path")" \
437
+ "$(json_escape "$branch")" \
438
+ "$(json_escape "$sha")"
439
+ first=0
440
+ done < <(git_list_worktrees)
441
+ printf ']'
442
+ }
443
+
335
444
  json_worktrees() {
336
445
  bridge_init_json_backend
337
446
  case "$BRIDGE_JSON_BACKEND" in
447
+ sh)
448
+ json_worktrees_sh
449
+ ;;
338
450
  jq)
339
451
  git_list_worktrees | jq -R -s '
340
452
  split("\n")[:-1] |