summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-11-20 14:52:02 -0500
committerBen Sima <ben@bsima.me>2025-11-20 14:52:02 -0500
commit9ab85c33379f98229235a30dbf5108ad31a01d1f (patch)
tree47bdaf08057e54fa85f7dd9500c29d0e0e7a0e1b
parent22e4ad1406100fc4377568fe1aa4cb235be21257 (diff)
bild: fix --plan to output only JSON without logging
- Remove Log.wipe from --plan output path - Add isPlanMode parameter to analyzeAll to skip LogC.withLineManager when planning - Update all analyzeAll call sites to pass isPlanMode flag - Remove grep workaround from repl.sh (no longer needed) Now 'bild --plan' outputs clean JSON that can be piped directly to jq. This fixes typecheck.sh and other tools that rely on clean JSON output. Amp-Thread-ID: https://ampcode.com/threads/T-4e6225cf-3e78-4538-963c-5377bbbccee8 Co-authored-by: Amp <amp@ampcode.com>
-rw-r--r--.tasks/tasks.jsonl1
-rw-r--r--Omni/Bild.hs30
-rwxr-xr-xOmni/Ide/repl.sh3
3 files changed, 21 insertions, 13 deletions
diff --git a/.tasks/tasks.jsonl b/.tasks/tasks.jsonl
index 0580698..67ec7e2 100644
--- a/.tasks/tasks.jsonl
+++ b/.tasks/tasks.jsonl
@@ -119,3 +119,4 @@
{"taskCreatedAt":"2025-11-20T15:25:27.948491266Z","taskDependencies":[],"taskId":"t-YBTC0p","taskNamespace":null,"taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Discovered-from flag broken","taskType":"WorkTask","taskUpdatedAt":"2025-11-20T15:58:12.685064773Z"}
{"taskCreatedAt":"2025-11-20T15:58:11.740041636Z","taskDependencies":[],"taskId":"t-10KNtTF","taskNamespace":null,"taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Docopt flag order matters incorrectly","taskType":"WorkTask","taskUpdatedAt":"2025-11-20T18:35:44.798128524Z"}
{"taskCreatedAt":"2025-11-20T18:44:29.330834039Z","taskDependencies":[{"depId":"t-Uumhrq","depType":"DiscoveredFrom"}],"taskId":"t-1bE2r3q","taskNamespace":"Omni/Task.hs","taskParent":null,"taskPriority":"P2","taskStatus":"Done","taskTitle":"Document TASK_TEST_MODE in AGENTS.md","taskType":"WorkTask","taskUpdatedAt":"2025-11-20T18:53:22.852670919Z"}
+{"taskCreatedAt":"2025-11-20T19:46:53.636713383Z","taskDependencies":[],"taskId":"t-1fJra3K","taskNamespace":"Omni/Bild.hs","taskParent":null,"taskPriority":"P1","taskStatus":"Done","taskTitle":"Fix bild --plan to output only JSON without logging","taskType":"WorkTask","taskUpdatedAt":"2025-11-20T19:51:46.854882315Z"}
diff --git a/Omni/Bild.hs b/Omni/Bild.hs
index aac0d2d..53d96a5 100644
--- a/Omni/Bild.hs
+++ b/Omni/Bild.hs
@@ -190,7 +190,7 @@ test_bildBild =
case Namespace.fromPath root path of
Nothing -> Test.assertFailure "can't find ns for bild"
Just ns ->
- analyzeAll [ns]
+ analyzeAll False [ns]
+> build False False 1 2
+> \case
[Exit.ExitFailure _] ->
@@ -207,7 +207,7 @@ test_bildExamples =
|> traverse Dir.makeAbsolute
/> map (Namespace.fromPath root)
/> catMaybes
- +> analyzeAll
+ +> analyzeAll False
+> build False False 4 1
+> \case
[] -> Test.assertFailure "asdf"
@@ -226,7 +226,8 @@ move args = do
+> traverse Dir.makeAbsolute
+> traverse (namespaceFromPathOrDie root)
/> filter isBuildableNs
- analysis <- analyzeAll namespaces
+ let isPlanMode = args `Cli.has` Cli.longOption "plan"
+ analysis <- analyzeAll isPlanMode namespaces
printOrBuild root analysis
|> Timeout.timeout (toMillis minutes)
+> \case
@@ -253,7 +254,7 @@ move args = do
>> Log.br
>> exitWith (ExitFailure 1)
| args `Cli.has` Cli.longOption "plan" =
- Log.wipe >> putJSON targets >> pure [Exit.ExitSuccess]
+ putJSON targets >> pure [Exit.ExitSuccess]
| otherwise = do
nproc <- GHC.getNumProcessors
createHier root
@@ -463,7 +464,7 @@ dev_getTarget fp = do
|> \case
Nothing -> panic "Could not get namespace from path"
Just ns ->
- analyzeAll [ns]
+ analyzeAll False [ns]
/> Map.lookup ns
/> \case
Nothing -> panic "Could not retrieve target from analysis"
@@ -551,12 +552,19 @@ removeVersion = takeWhile (/= '.') .> butlast2
type Analysis = Map Namespace Target
-analyzeAll :: [Namespace] -> IO Analysis
-analyzeAll nss = do
- LogC.withLineManager nss <| \lineMgr -> do
- LogC.initializeLines lineMgr
- targets <- mapConcurrentlyBounded 8 analyzeOne nss
- pure <| Map.fromList <| catMaybes <| zipWith (\ns mt -> (ns,) </ mt) nss targets
+analyzeAll :: Bool -> [Namespace] -> IO Analysis
+analyzeAll isPlanMode nss = do
+ if isPlanMode
+ then do
+ -- Plan mode: no logging, just analyze
+ targets <- mapConcurrentlyBounded 8 analyzeOne nss
+ pure <| Map.fromList <| catMaybes <| zipWith (\ns mt -> (ns,) </ mt) nss targets
+ else do
+ -- Normal mode: use concurrent logging
+ LogC.withLineManager nss <| \lineMgr -> do
+ LogC.initializeLines lineMgr
+ targets <- mapConcurrentlyBounded 8 analyzeOne nss
+ pure <| Map.fromList <| catMaybes <| zipWith (\ns mt -> (ns,) </ mt) nss targets
where
analyzeOne :: Namespace -> IO (Maybe Target)
analyzeOne namespace@(Namespace parts ext) = do
diff --git a/Omni/Ide/repl.sh b/Omni/Ide/repl.sh
index ad6bc02..6225078 100755
--- a/Omni/Ide/repl.sh
+++ b/Omni/Ide/repl.sh
@@ -30,8 +30,7 @@ fi
shift
fi
targets="${*:?}"
- # Extract only the JSON line from bild --plan output (skip progress indicators)
- json=$(bild --plan "${targets[@]}" 2>&1 | grep -E '^\{')
+ json=$(bild --plan "${targets[@]}" 2>&1)
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")