summaryrefslogtreecommitdiff
path: root/Omni/Ide
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-11-16 03:23:47 -0500
committerBen Sima <ben@bsima.me>2025-11-16 03:23:47 -0500
commit3b917a87e12c8ef97bc52afd3903ac22c082f7b1 (patch)
tree5f0f0a05a77b4a721e43066778070edd0f633f02 /Omni/Ide
parent4106020d713ea1d8ed815b1180d8df3ea60ae46e (diff)
Fix repl.sh and typecheck.sh to properly parse bild --plan JSON
The issue was that bild --plan outputs progress indicators before the JSON, causing jq to fail parsing. Fixed by: - Using grep to extract only lines starting with '{' (the JSON output) - This filters out progress lines like '[…] target' - Restored typecheck.sh to use repl.sh for proper environment setup Now typecheck.sh correctly provisions the environment via repl.sh instead of trying to use bild or raw python.
Diffstat (limited to 'Omni/Ide')
-rwxr-xr-xOmni/Ide/repl.sh3
-rwxr-xr-xOmni/Ide/typecheck.sh28
2 files changed, 25 insertions, 6 deletions
diff --git a/Omni/Ide/repl.sh b/Omni/Ide/repl.sh
index d4ff200..ad6bc02 100755
--- a/Omni/Ide/repl.sh
+++ b/Omni/Ide/repl.sh
@@ -30,7 +30,8 @@ fi
shift
fi
targets="${*:?}"
- json=$(bild --plan "${targets[@]}")
+ # Extract only the JSON line from bild --plan output (skip progress indicators)
+ json=$(bild --plan "${targets[@]}" 2>&1 | grep -E '^\{')
mapfile -t langdeps < <(jq --raw-output '.[].langdeps | select(length > 0) | join("\n")' <<< "$json")
mapfile -t sysdeps < <(jq --raw-output '.[].sysdeps | select(length > 0) | join("\n")' <<< "$json")
mapfile -t rundeps < <(jq --raw-output '.[].rundeps | select(length > 0) | join("\n")' <<< "$json")
diff --git a/Omni/Ide/typecheck.sh b/Omni/Ide/typecheck.sh
index 5f92c90..0d9648d 100755
--- a/Omni/Ide/typecheck.sh
+++ b/Omni/Ide/typecheck.sh
@@ -4,8 +4,8 @@
###
### > typecheck.sh <target..>
###
-### Runs the typechecker for the given target by building it with bild.
-### This leverages bild's built-in typechecking without running tests.
+### Uses repl.sh to provision the environment for target, then runs the
+### appropriate typechecker for the given module.
###
help() {
sed -rn 's/^### ?//;T;p' "$0"
@@ -16,6 +16,24 @@ if [[ $# == 0 ]] || [[ "$1" == "-h" ]]; then
fi
target="$1"
-# Use bild to typecheck (bild runs mypy for Python, ghc for Haskell, etc.)
-# This is simpler than trying to set up the environment ourselves
-bild "$target"
+# Determine file extension
+ext="${target##*.}"
+
+case "$ext" in
+ py)
+ # Python: use mypy via repl.sh environment
+ repl.sh --cmd "python -m mypy $target" "$target"
+ ;;
+ hs)
+ # Haskell: use ghc -fno-code
+ # This would need the right environment from repl.sh
+ echo "Haskell typechecking not yet implemented in typecheck.sh"
+ echo "Use 'bild $target' to build and typecheck"
+ exit 1
+ ;;
+ *)
+ echo "Unknown file extension: $ext"
+ echo "Typechecking not supported for this file type"
+ exit 1
+ ;;
+esac