tricorder 1.1.0.0 → 1.1.1.0
raw patch · 32 files changed
+316/−245 lines, 32 filesdep ~atelier-coredep ~brickdep ~tricorder-types
Dependency ranges changed: atelier-core, brick, tricorder-types
Files
- CHANGELOG.md +17/−0
- src/Tricorder/CLI/App.hs +3/−1
- src/Tricorder/CLI/App/Daemon.hs +6/−0
- src/Tricorder/CLI/App/Test.hs +15/−0
- src/Tricorder/CLI/Daemon.hs +31/−2
- src/Tricorder/CLI/Main.hs +2/−1
- src/Tricorder/CLI/Operations.hs +1/−1
- src/Tricorder/CLI/UI/Brick.hs +8/−13
- src/Tricorder/Daemon/Arguments.hs +27/−0
- src/Tricorder/Daemon/Dispatch.hs +9/−8
- src/Tricorder/Daemon/Main.hs +11/−5
- src/Tricorder/Daemon/Watch.hs +2/−2
- src/Tricorder/Logging.hs +0/−74
- src/Tricorder/Logging/Severity/Config.hs +37/−0
- src/Tricorder/Session.hs +3/−3
- src/Tricorder/Session/CabalFile.hs +19/−16
- src/Tricorder/Session/Stage/Build/Session.hs +1/−1
- src/Tricorder/Session/State.hs +2/−2
- src/Tricorder/Session/Target.hs +2/−2
- src/Tricorder/Session/WatchDirs.hs +10/−10
- src/Tricorder/SourceLookup.hs +5/−5
- test/Unit/Tricorder/Daemon/BuilderSpec.hs +1/−1
- test/Unit/Tricorder/Daemon/DispatchSpec.hs +5/−5
- test/Unit/Tricorder/Daemon/Ghci/ProcessSpec.hs +4/−3
- test/Unit/Tricorder/Daemon/WatchSpec.hs +11/−11
- test/Unit/Tricorder/Session/CabalFileSpec.hs +19/−18
- test/Unit/Tricorder/Session/Helpers.hs +11/−10
- test/Unit/Tricorder/Session/TargetSpec.hs +9/−9
- test/Unit/Tricorder/Session/WatchDirsSpec.hs +16/−15
- test/Unit/Tricorder/SessionSpec.hs +17/−16
- test/Unit/Tricorder/SourceLookupSpec.hs +4/−4
- tricorder.cabal +8/−7
CHANGELOG.md view
@@ -7,6 +7,23 @@ ## [Unreleased] +## [1.1.1.0] - 2026-11-23++### Changed++- The statically linked binaries (GitHub release artifacts and the+ `tricorder-static` Nix package) now bundle terminfo entries for common+ terminals (xterm, screen, tmux, linux, alacritty, foot, wezterm), so the TUI+ starts on hosts without a terminfo database.+- The standalone Tricorder daemon `tricorder-daemon` now properly writes its+ output to `stderr` instead to a file when started directly instead of as a+ daemonized process from Tricorder's CLI. This simplifies debugging daemon+ issues by properly exposing the error output from the daemon.+- `tricorder-daemon`, the optional standalone daemon binary for Tricorder, is+ now statically built and included in GitHub releases.+- Bumped `atelier-core` requirement to `==1.2.*`.+- Bumped `tricorder-types` requirement to `==1.2.*`.+ ## [1.1.0.0] - 2026-11-18 ### Changed
src/Tricorder/CLI/App.hs view
@@ -4,6 +4,7 @@ import Atelier.Effects.Conc (Conc) import Atelier.Effects.Console (Console) import Atelier.Effects.Delay (Delay)+import Atelier.Effects.Env (Env) import Atelier.Effects.Exit (Exit) import Atelier.Effects.Handles (Handles) import Atelier.Effects.Input (Input)@@ -59,15 +60,16 @@ , Console :> es , Daemons :> es , Delay :> es+ , Env :> es , Exit :> es , FileSystem :> es , GhcPkg :> es , Hackage :> es , Handles :> es , IOE :> es+ , Input (Set CabalFile) :> es , Input Build.Session :> es , Input DaemonInfo :> es- , Input [CabalFile] :> es , Log :> es , PackageStore :> es , Process :> es
src/Tricorder/CLI/App/Daemon.hs view
@@ -2,11 +2,13 @@ import Atelier.Effects.Console (Console) import Atelier.Effects.Delay (Delay)+import Atelier.Effects.Env (Env) import Atelier.Effects.Handles (Handles) import Atelier.Effects.Input (Input, input) import Atelier.Effects.Posix.Daemons (Daemons) import Atelier.Effects.Timeout (Timeout) import Effectful (IOE)+import Effectful.FileSystem (FileSystem) import Effectful.Reader.Static (Reader) import Tricorder.API.Daemon.Command (Command (..)) import Prelude hiding (force)@@ -17,6 +19,7 @@ import Tricorder.CLI.Daemon (restartDaemon, startDaemon, stopDaemon, waitForDaemon) import Tricorder.CLI.Operations (showDaemonInfo) import Tricorder.Daemon.DaemonInfo (DaemonInfo)+import Tricorder.Runtime.LogPath (LogPath) import Tricorder.Runtime.PidFile (PidFile) import Tricorder.Runtime.SocketPath (SocketPath) import Tricorder.Socket.Client (isDaemonRunning)@@ -27,9 +30,12 @@ :: ( Console :> es , Daemons :> es , Delay :> es+ , Env :> es+ , FileSystem :> es , Handles :> es , IOE :> es , Input DaemonInfo :> es+ , Reader LogPath :> es , Reader PidFile :> es , Reader SocketPath :> es , Timeout :> es
src/Tricorder/CLI/App/Test.hs view
@@ -2,10 +2,12 @@ import Atelier.Effects.Console (Console) import Atelier.Effects.Delay (Delay)+import Atelier.Effects.Env (Env) import Atelier.Effects.Exit (Exit) import Atelier.Effects.Handles (Handles) import Atelier.Effects.Posix.Daemons (Daemons, PidFile) import Effectful (IOE)+import Effectful.FileSystem (FileSystem) import Effectful.Reader.Static (Reader) import Tricorder.API.IfBuildIsPending (IfBuildIsPending (..)) import Tricorder.API.IfDaemonIsStopped (IfDaemonIsStopped)@@ -20,6 +22,7 @@ import Tricorder.API.IfDaemonIsStopped qualified as IfDaemonIsStopped import Tricorder.API.Test.SuiteView.Schema qualified as SuiteView.Schema +import Tricorder.Runtime.LogPath (LogPath) import Tricorder.Runtime.SocketPath (SocketPath (..)) import Tricorder.Socket.Client (queryStatus, queryStatusWait) import Tricorder.Socket.UnixSocket (UnixSocket)@@ -36,9 +39,12 @@ :: ( Console :> es , Daemons :> es , Delay :> es+ , Env :> es , Exit :> es+ , FileSystem :> es , Handles :> es , IOE :> es+ , Reader LogPath :> es , Reader PidFile :> es , Reader SocketPath :> es , UnixSocket :> es@@ -61,8 +67,11 @@ showSuites :: ( Daemons :> es , Delay :> es+ , Env :> es+ , FileSystem :> es , Handles :> es , IOE :> es+ , Reader LogPath :> es , Reader PidFile :> es , Reader SocketPath :> es , UnixSocket :> es@@ -119,7 +128,10 @@ ensureDaemonRunning :: ( Daemons :> es , Delay :> es+ , Env :> es+ , FileSystem :> es , IOE :> es+ , Reader LogPath :> es , Reader PidFile :> es , Reader SocketPath :> es , UnixSocket :> es@@ -138,7 +150,10 @@ ensureDaemonIsRunning :: ( Daemons :> es , Delay :> es+ , Env :> es+ , FileSystem :> es , IOE :> es+ , Reader LogPath :> es , Reader PidFile :> es , Reader SocketPath :> es , UnixSocket :> es
src/Tricorder/CLI/Daemon.hs view
@@ -7,11 +7,14 @@ where import Atelier.Effects.Delay (Delay)+import Atelier.Effects.Env (Env) import Atelier.Effects.Handles (Handles) import Atelier.Effects.Posix.Daemons (Daemons) import Atelier.Effects.Timeout (Timeout) import Atelier.Time (Millisecond, Second) import Effectful (IOE)+import Effectful.Exception (trySync)+import Effectful.FileSystem (FileSystem) import Effectful.NonDet (OnEmptyPolicy (..), emptyEff, runNonDet) import Effectful.Reader.Static (Reader, ask) import Effectful.Writer.Static.Local (runWriter, tell)@@ -19,10 +22,15 @@ import Prelude hiding (force) import Atelier.Effects.Delay qualified as Delay+import Atelier.Effects.Env qualified as Env import Atelier.Effects.Posix.Daemons qualified as Daemons import Atelier.Effects.Timeout qualified as Timeout+import Atelier.FileSystem.File qualified as File+import Atelier.FileSystem.Path qualified as Path+import Effectful.Reader.Static qualified as Reader import Tricorder.API.IfThereArePendingQueries qualified as IfThereArePendingQueries +import Tricorder.Runtime.LogPath (LogPath (..)) import Tricorder.Runtime.PidFile (PidFile) import Tricorder.Runtime.SocketPath (SocketPath (..)) import Tricorder.Socket.Client (isDaemonReady, isDaemonRunning, requestShutdown)@@ -33,13 +41,18 @@ startDaemon :: ( Daemons :> es+ , Env :> es+ , FileSystem :> es , IOE :> es+ , Reader LogPath :> es , Reader PidFile :> es ) => Eff es () startDaemon = do- pidFile <- ask- Daemons.daemonize pidFile $ liftIO Daemon.Main.main+ pidFile <- Reader.ask+ LogPath logPath <- Reader.ask+ truncateLog logPath+ Daemons.daemonizeTo (Just logPath) pidFile $ liftIO Daemon.Main.main -- | Attempts to stop the daemon in progressively more forceful ways.@@ -108,8 +121,11 @@ restartDaemon :: ( Daemons :> es , Delay :> es+ , Env :> es+ , FileSystem :> es , Handles :> es , IOE :> es+ , Reader LogPath :> es , Reader PidFile :> es , Reader SocketPath :> es , Timeout :> es@@ -153,3 +169,16 @@ else do Delay.wait (200 :: Millisecond) go sockPath (n - 1)+++noTruncateVarName :: String+noTruncateVarName = "TRICORDER_NO_LOG_TRUNCATE"+++truncateLog+ :: (Env :> es, FileSystem :> es)+ => Path.Absolute -> Eff es ()+truncateLog path = do+ doTruncate <- (\x -> x == Nothing || x == Just "0") <$> Env.lookup noTruncateVarName+ when doTruncate do+ void $ trySync $ File.write path ("" :: ByteString)
src/Tricorder/CLI/Main.hs view
@@ -19,6 +19,7 @@ import Atelier.Effects.Handles qualified as Handles import Atelier.Effects.Input qualified as Input import Atelier.Effects.Log qualified as Log+import Atelier.Effects.Log.Severity qualified as Log.Severity import Atelier.Effects.Posix.Daemons qualified as Daemons import Atelier.Effects.Process qualified as Process import Atelier.Effects.Timeout qualified as Timeout@@ -71,7 +72,7 @@ . Runtime.ProjectRoot.asReader . Runtime.ProjectHash.asReader . Runtime.Cache.asReader- . Log.runToHandle stderr Log.INFO+ . Log.runToHandle stderr Log.Severity.INFO . Runtime.Directory.asReader . Runtime.PidFile.asReader . Runtime.SocketPath.asReader
src/Tricorder/CLI/Operations.hs view
@@ -206,8 +206,8 @@ , FileSystem :> es , GhcPkg :> es , Hackage :> es+ , Input (Set CabalFile) :> es , Input Build.Session :> es- , Input [CabalFile] :> es , Log :> es , PackageStore :> es )
src/Tricorder/CLI/UI/Brick.hs view
@@ -34,16 +34,11 @@ runBrick :: (IOE :> es) => Eff (Brick : es) a -> Eff es a runBrick = interpret_ \case- RunBrickApp chan app initialState -> liftIO do- let buildVty = do- cfg <- userConfig- vty <- mkVty cfg- setMode (outputIface vty) Mouse True- pure vty- initialVty <- liftIO buildVty- customMain- initialVty- buildVty- (Just chan)- app- initialState+ RunBrickApp chan app initialState ->+ liftIO $ customMain (Just buildVty) (Just chan) app initialState+ where+ buildVty = do+ cfg <- userConfig+ vty <- mkVty cfg+ setMode (outputIface vty) Mouse True+ pure vty
+ src/Tricorder/Daemon/Arguments.hs view
@@ -0,0 +1,27 @@+module Tricorder.Daemon.Arguments (run) where++import Atelier.Effects.Arguments (Arguments)+import Options.Applicative (Parser, ParserInfo)++import Atelier.Effects.Arguments qualified as Args+import Options.Applicative qualified as Opt++import Tricorder.Version qualified as Version+++run :: (Arguments :> es) => Eff es a -> Eff es a+run eff = do+ () <- Args.execParser opts+ eff+++opts :: ParserInfo ()+opts =+ Opt.info (pure () <**> versionOption <**> Opt.helper)+ $ Opt.fullDesc+ <> Opt.progDesc "tricorder-daemon — daemon for the Tricorder CLI"+++versionOption :: Parser (a -> a)+versionOption =+ Opt.infoOption (toString Version.gitHash) (Opt.long "version" <> Opt.help "Show version and exit")
src/Tricorder/Daemon/Dispatch.hs view
@@ -182,14 +182,15 @@ -- home-unit GHC plugin that can't load under @--enable-multi-repl@) that must -- not be dropped, or the build would silently read as clean. filterToWatchDirs :: Path.Absolute -> WatchDirs -> [Diagnostic] -> [Diagnostic]-filterToWatchDirs _ (WatchDirs []) diags = diags-filterToWatchDirs projectRoot (WatchDirs watchDirs) diags =- filter- ( \d -> case d.file of- Locationless -> True- Location file -> isUnderAnyWatchDir file- )- diags+filterToWatchDirs projectRoot (WatchDirs watchDirs) diags+ | Set.null watchDirs = diags+ | otherwise =+ filter+ ( \d -> case d.file of+ Locationless -> True+ Location file -> isUnderAnyWatchDir file+ )+ diags where isUnderAnyWatchDir = \case file | isCPPMangledFile file -> False
src/Tricorder/Daemon/Main.hs view
@@ -4,10 +4,13 @@ import Data.Default (def) import Effectful (runEff) import Effectful.Concurrent (runConcurrent)+import System.IO (stderr) +import Atelier.Effects.Arguments qualified as Arguments import Atelier.Effects.Chan qualified as Chan import Atelier.Effects.Clock qualified as Clock import Atelier.Effects.Conc qualified as Conc+import Atelier.Effects.Console qualified as Console import Atelier.Effects.Debounce qualified as Debounce import Atelier.Effects.Delay qualified as Delay import Atelier.Effects.Env qualified as Env@@ -37,6 +40,7 @@ import Tricorder.Build.Phase qualified as Build (Phase) import Tricorder.Build.Phase qualified as Build.Phase import Tricorder.Config.LoadedConfig qualified as LoadedConfig+import Tricorder.Daemon.Arguments qualified as Daemon.Arguments import Tricorder.Daemon.Core qualified as Core import Tricorder.Daemon.EvalCommentRunner qualified as EvalCommentRunner import Tricorder.Daemon.Ghci.Session qualified as Ghci.Session@@ -46,10 +50,9 @@ import Tricorder.Daemon.IdleTimer qualified as IdleTimer import Tricorder.Daemon.TestRunner qualified as TestRunner import Tricorder.Daemon.Watch qualified as Watch-import Tricorder.Logging qualified as Logging+import Tricorder.Logging.Severity.Config qualified as Log.Severity.Config import Tricorder.Runtime.Cache qualified as Runtime.Cache import Tricorder.Runtime.Directory qualified as Runtime.Directory-import Tricorder.Runtime.LogPath qualified as Runtime.LogPath import Tricorder.Runtime.ProjectHash qualified as Runtime.ProjectHash import Tricorder.Runtime.ProjectRoot qualified as Runtime.ProjectRoot import Tricorder.Runtime.SocketPath qualified as Runtime.SocketPath@@ -67,6 +70,8 @@ main :: IO () main = runEff+ . Arguments.runIO+ . Daemon.Arguments.run . runConcurrent . FileSystem.runFileSystem . Conc.runIO@@ -81,10 +86,10 @@ . Runtime.ProjectRoot.asReader . Runtime.ProjectHash.asReader . Runtime.Cache.asReader- . Runtime.LogPath.asReader . LoadedConfig.asInput- . Handles.run- . Logging.run+ . Console.runHandle stderr+ . Log.Severity.Config.asInput+ . Log.runIO . FileWatcher.runIO . Runtime.Directory.asReader . Runtime.SocketPath.asReader@@ -93,6 +98,7 @@ . inputCabalFiles . Process.run . runGhcPkgIO+ . Handles.run . UnixSocket.runIO . Ghci.Session.run . State.evalState (Build.Id 1)
src/Tricorder/Daemon/Watch.hs view
@@ -75,13 +75,13 @@ specs :: ProjectRoot -> WatchExclusionPatterns -> WatchDirs -> [FileWatcher.Watch] specs projectRoot watchExclusionPatterns watchDirs =- sourceWatches (coerce watchExclusionPatterns) (coerce watchDirs)+ sourceWatches (coerce watchExclusionPatterns) (toList watchDirs.getWatchDirs) <> projectWatches projectRoot sourceWatches :: [Pattern] -> [Path.Absolute] -> [FileWatcher.Watch] sourceWatches exclusionPatterns =- map \d ->+ fmap \d -> Watch.dirExt d ".hs" `Watch.excluding` Watch.containing "dist-newstyle" `Watch.excluding` exclusionMatches exclusionPatterns
− src/Tricorder/Logging.hs
@@ -1,74 +0,0 @@-module Tricorder.Logging (run) where--import Atelier.Effects.Env (Env)-import Atelier.Effects.Handles (BufferMode (..), Handles)-import Atelier.Effects.Input (Input)-import Atelier.Effects.Log (Log, Severity (..))-import Effectful (IOE)-import Effectful.Exception (trySync)-import Effectful.FileSystem (FileSystem)-import Effectful.Reader.Static (Reader)--import Atelier.Effects.Env qualified as Env-import Atelier.Effects.Handles qualified as Handles-import Atelier.Effects.Input qualified as Input-import Atelier.Effects.Log qualified as Log-import Atelier.FileSystem.File qualified as File-import Atelier.FileSystem.Path qualified as Path-import Effectful.Reader.Static qualified as Reader--import Tricorder.Config.LoadedConfig (LoadedConfig)-import Tricorder.Runtime.LogPath (LogPath (..))--import Tricorder.Config.LoadedConfig qualified as LoadedConfig---run- :: ( Env :> es- , FileSystem :> es- , Handles :> es- , IOE :> es- , Input LoadedConfig :> es- , Reader LogPath :> es- )- => Eff (Log : es) a -> Eff es a-run act = do- LogPath path <- Reader.ask- truncateLog path- Handles.with path AppendMode \h -> do- Handles.hSetBuffering h LineBuffering- (maybeErr, sev) <- getMinimumSeverity- Log.runToHandle h sev do- whenJust maybeErr \err -> Log.err err- act---getMinimumSeverity- :: ( Env :> es- , Input LoadedConfig :> es- )- => Eff es (Maybe Text, Severity)-getMinimumSeverity = do- mSev <- Log.minimumSeverityFromEnv- case mSev of- Just sev -> pure (Nothing, sev)- Nothing -> LoadedConfig.asNestedInput @"session.logging" @Log.Config do- logConfigRes <- Input.input- case logConfigRes of- Left err -> do- pure (Just $ "failed to parse log config: " <> err, Log.INFO)- Right cfg ->- pure (Nothing, cfg.minimumSeverity)---noTruncateVarName :: String-noTruncateVarName = "TRICORDER_NO_LOG_TRUNCATE"---truncateLog- :: (Env :> es, FileSystem :> es)- => Path.Absolute -> Eff es ()-truncateLog path = do- doTruncate <- (\x -> x == Nothing || x == Just "0") <$> Env.lookup noTruncateVarName- when doTruncate do- void $ trySync $ File.write path ("" :: ByteString)
+ src/Tricorder/Logging/Severity/Config.hs view
@@ -0,0 +1,37 @@+module Tricorder.Logging.Severity.Config (asInput) where++import Atelier.Effects.Console (Console)+import Atelier.Effects.Env (Env)+import Atelier.Effects.Input (Input)+import Effectful.Reader.Static (Reader)++import Atelier.Effects.Console qualified as Console+import Atelier.Effects.Input qualified as Input+import Atelier.Effects.Log.Config qualified as Log+import Atelier.Effects.Log.Severity qualified as Severity+import Effectful.Reader.Static qualified as Reader++import Tricorder.Config.LoadedConfig (LoadedConfig (..))++import Tricorder.Config.LoadedConfig qualified as LoadedConfig+++asInput+ :: ( Console :> es+ , Env :> es+ , Input LoadedConfig :> es+ )+ => Eff (Reader Severity.Config : es) a -> Eff es a+asInput act = do+ mSev <- Severity.minimumSeverityFromEnv+ severity <- case mSev of+ Just sev -> pure $ Severity.Config sev+ Nothing -> LoadedConfig.asNestedInput @"session.logging" @Log.Config do+ logConfigRes <- Input.input+ case logConfigRes of+ Left err -> do+ Console.putTextLn $ "[WARN] failed to parse log config: " <> err+ pure $ Severity.Config Severity.INFO+ Right cfg ->+ pure $ Severity.Config cfg.minimumSeverity+ Reader.runReader severity act
src/Tricorder/Session.hs view
@@ -84,7 +84,7 @@ load :: ( FileSystem :> es , Input (Either Text Tricorder.Config) :> es- , Input [CabalFile] :> es+ , Input (Set CabalFile) :> es , Log :> es , Reader ProjectRoot :> es )@@ -100,7 +100,7 @@ mkSession- :: (FileSystem :> es, Input [CabalFile] :> es, Log :> es, Reader ProjectRoot :> es)+ :: (FileSystem :> es, Input (Set CabalFile) :> es, Log :> es, Reader ProjectRoot :> es) => Config -> Eff es (Either Text Session) mkSession cfgFile = do projectRoot <- Reader.ask @ProjectRoot@@ -224,7 +224,7 @@ , "Eval comments configuration:" , indent $ Eval.Session.display session.evalSession , "Watch dirs:"- , indent $ displayList toText session.watchDirs.getWatchDirs+ , indent $ displayList toText $ toList session.watchDirs.getWatchDirs , "Watch exclusion patterns:" , indent $ displayList
src/Tricorder/Session/CabalFile.hs view
@@ -39,9 +39,13 @@ { projectFilePath :: Path.Absolute , projectPackageDescription :: GenericPackageDescription }- deriving stock (Show)+ deriving stock (Eq, Show) +instance Ord CabalFile where+ compare (CabalFile a _) (CabalFile b _) = compare a b++ inputCabalFiles :: ( FileSystem :> es , Glob :> es@@ -49,7 +53,7 @@ , Log :> es , Reader ProjectRoot :> es )- => Eff (Input [CabalFile] : es) a -> Eff es a+ => Eff (Input (Set CabalFile) : es) a -> Eff es a inputCabalFiles = Input.withEff $ Log.withNamespace "CabalFile" do packageRes <- discoverPackages case packageRes of@@ -57,12 +61,12 @@ Right projectFilePaths -> do (faileds, packageDescriptions) <- logFailure- $ partitionEithers <$> for projectFilePaths readProjectFile+ $ partitionEithers <$> for (toList projectFilePaths) readProjectFile unless (null faileds) do Log.warn $ "Failed to parse .cabal files for the following packages: " <> T.intercalate ", " (toText . Path.toFilePath <$> faileds)- pure $ packageDescriptions+ pure $ fromList packageDescriptions where logFailure = ( `catch`@@ -105,7 +109,7 @@ , Input StackProject :> es , Reader ProjectRoot :> es )- => Eff es (Either Text [Path.Absolute])+ => Eff es (Either Text (Set Path.Absolute)) discoverPackages = do ProjectRoot projectRoot <- Reader.ask hasStackYaml <- File.exists $ projectRoot </> Path.relative @"stack.yaml"@@ -121,7 +125,7 @@ , Glob :> es , Reader ProjectRoot :> es )- => Eff es (Either Text [Path.Absolute])+ => Eff es (Either Text (Set Path.Absolute)) discoverCabalPackages = do ProjectRoot projectRoot <- Reader.ask homeCabalFiles <-@@ -139,7 +143,7 @@ packages <- fmap (find (not . null)) $ for projectFiles \projectFile -> do contents <- File.read projectFile- concat+ mconcat <$> traverse (cabalFilesForEntry projectRoot) (projectPackageEntries contents)@@ -157,29 +161,28 @@ cabalFilesForEntry projectRoot (entry :: Path.Relative) | hasWildcard entry = do matches <- globDir1 (compile $ Path.toFilePath entry) projectRoot- concat <$> traverse resolveMatch matches- | isCabalFile entry = pure [projectRoot </> entry]+ mconcat <$> traverse resolveMatch matches+ | isCabalFile entry = pure $ fromList [projectRoot </> entry] | otherwise = cabalFilesIn $ Path.normalise $ projectRoot </> entry where resolveMatch path- | isCabalFile path = pure [Path.normalise path]+ | isCabalFile path = pure $ fromList [Path.normalise path] | otherwise = cabalFilesIn (Path.normalise path) discoverStackPackages :: (Input StackProject :> es, Reader ProjectRoot :> es)- => Eff es (Either Text [Path.Absolute])+ => Eff es (Either Text (Set Path.Absolute)) discoverStackPackages = do ProjectRoot projectRoot <- Reader.ask project <- Input.input- pure $ Right $ Path.normalise . (projectRoot </>) <$> project.packages+ pure $ Right $ fromList $ Path.normalise . (projectRoot </>) <$> project.packages -- | List the @.cabal@ files directly inside a directory.-cabalFilesIn :: (FileSystem :> es) => Path.Absolute -> Eff es [Path.Absolute]-cabalFilesIn dir = do- entries <- filter isCabalFile <$> Directory.list dir- pure $ (dir </>) <$> entries+cabalFilesIn :: (FileSystem :> es) => Path.Absolute -> Eff es (Set Path.Absolute)+cabalFilesIn dir =+ fromList . fmap (dir </>) . filter isCabalFile <$> Directory.list dir -- | Does a @packages:@ entry contain a glob wildcard?
src/Tricorder/Session/Stage/Build/Session.hs view
@@ -47,7 +47,7 @@ resolve :: (FileSystem :> es, Reader ProjectRoot :> es)- => Config -> Repl -> [CabalFile] -> Eff es Session+ => Config -> Repl -> Set CabalFile -> Eff es Session resolve config repl projectFiles = do projectRoot <- Reader.ask (commandTemplate, targets) <- BuildCommand.resolve projectRoot config repl effectiveTargets
src/Tricorder/Session/State.hs view
@@ -74,7 +74,7 @@ , FileSystem :> es , FileWatcher :> es , Input (Either Text Tricorder.Config) :> es- , Input [CabalFile] :> es+ , Input (Set CabalFile) :> es , Log :> es , Reader ProjectRoot :> es , Waiters :> es@@ -104,7 +104,7 @@ :: ( Concurrent :> es , FileSystem :> es , Input (Either Text Tricorder.Config) :> es- , Input [CabalFile] :> es+ , Input (Set CabalFile) :> es , Log :> es , Pub Reloaded :> es , Reader ProjectRoot :> es
src/Tricorder/Session/Target.hs view
@@ -138,7 +138,7 @@ -- discovered package are auto-detected when no targets are configured. Either -- way the result is sorted with 'compare' so libraries exposing a custom -- @Prelude@ come last [ref:lib_sort_order].-resolve :: [CabalFile] -> [Text] -> [Target]+resolve :: Set CabalFile -> [Text] -> [Target] resolve cabalFiles = \case targets@(_ : _) -> sortTargets $ parse <$> targets [] -> sortTargets $ foldMap (allComponentTargets . (.projectPackageDescription)) cabalFiles@@ -167,7 +167,7 @@ -- module for the given target. Used to build the predicate passed to -- 'compare' so that only the libraries that actually cause the GHCi -- startup failure are sorted last [ref:lib_sort_order].-definesCustomPrelude :: [CabalFile] -> Target -> Bool+definesCustomPrelude :: Set CabalFile -> Target -> Bool definesCustomPrelude cabalFiles target = any check cabalFiles where check cabalFile = any hasPrelude $ relevantLibs cabalFile.projectPackageDescription
src/Tricorder/Session/WatchDirs.hs view
@@ -39,13 +39,13 @@ import Tricorder.Session.Target (ComponentKind (..), Target (..)) -newtype WatchDirs = WatchDirs {getWatchDirs :: [Path.Absolute]}+newtype WatchDirs = WatchDirs {getWatchDirs :: Set Path.Absolute} deriving stock (Eq, Generic, Show)- deriving (FromJSON, ToJSON) via [Path.Absolute]+ deriving (FromJSON, ToJSON) via Set Path.Absolute instance Default WatchDirs where- def = WatchDirs []+ def = WatchDirs mempty -- | Resolve the directories to watch.@@ -57,27 +57,27 @@ -- against the project root; absolute entries are used as-is) -- 2. @hs-source-dirs@ inferred from cabal targets, if targets are set -- 3. Falls back to the project root if neither is available-resolve :: ProjectRoot -> [CabalFile] -> Config -> [Target] -> Either Text WatchDirs+resolve :: ProjectRoot -> Set CabalFile -> Config -> [Target] -> Either Text WatchDirs resolve (ProjectRoot projectRoot) projectFiles cfg targets | List.null cfg.watchDirs = resolveWatchDirsFromTargets projectRoot projectFiles targets | otherwise = fmap- ( WatchDirs . fmap \case+ ( WatchDirs . fromList . fmap \case Path.Absolute p -> p Path.Relative p -> projectRoot </> p ) $ traverse Path.fromFilePath cfg.watchDirs -resolveWatchDirsFromTargets :: Path.Absolute -> [CabalFile] -> [Target] -> Either Text WatchDirs-resolveWatchDirsFromTargets projectRoot _ [] = Right $ WatchDirs [projectRoot]+resolveWatchDirsFromTargets :: Path.Absolute -> Set CabalFile -> [Target] -> Either Text WatchDirs+resolveWatchDirsFromTargets projectRoot _ [] = Right $ WatchDirs $ one projectRoot resolveWatchDirsFromTargets projectRoot projectFiles targets = case dirs of Left err -> Left $ "Could not resolve watch dirs from target: " <> err- Right [] -> Right $ WatchDirs [projectRoot]- Right ds -> Right $ WatchDirs ds+ Right [] -> Right $ WatchDirs $ one projectRoot+ Right ds -> Right $ WatchDirs $ fromList ds where- dirs = nub . concat <$> traverse watchDirsForCabal projectFiles+ dirs = fromList . concat <$> traverse watchDirsForCabal (toList projectFiles) -- @hs-source-dirs@ are relative to the package's own directory, so scope -- them to the directory holding that package's @.cabal@. In a -- single-package project that directory is the project root; in a
src/Tricorder/SourceLookup.hs view
@@ -44,18 +44,18 @@ -- | The directories holding the project's own modules: the @hs-source-dirs@ of -- every component of every project package, resolved against the package dir.-newtype ProjectSourceDirs = ProjectSourceDirs [Path.Absolute]+newtype ProjectSourceDirs = ProjectSourceDirs (Set Path.Absolute) deriving stock (Eq, Show) -projectSourceDirs :: [CabalFile] -> ProjectSourceDirs+projectSourceDirs :: Set CabalFile -> ProjectSourceDirs projectSourceDirs cabalFiles = ProjectSourceDirs- $ ordNub+ $ fromList [ Path.normalise $ case dir of Path.Relative d -> Path.takeDirectory cabalFile.projectFilePath </> d Path.Absolute d -> d- | cabalFile <- cabalFiles+ | cabalFile <- toList cabalFiles , dir <- orRoot (either (const []) id $ allSourceDirs cabalFile.projectPackageDescription) ] where@@ -155,7 +155,7 @@ findProjectModule (ProjectSourceDirs dirs) modName = firstExisting [ dir </> relPath <.> toString rawExt- | dir <- dirs+ | dir <- toList dirs , rawExt <- sourceExtensions , Right relPath <- one $ Path.fromFilePath $ toString $ T.replace "." "/" (unModuleName modName) ]
test/Unit/Tricorder/Daemon/BuilderSpec.hs view
@@ -100,7 +100,7 @@ ] where root = ProjectRoot (Path.absolute @"/")- watchDirs = WatchDirs [Path.absolute @"/src"]+ watchDirs = WatchDirs $ one $ Path.absolute @"/src" --------------------------------------------------------------------------------
test/Unit/Tricorder/Daemon/DispatchSpec.hs view
@@ -210,7 +210,7 @@ filterToWatchDirs root watchDirs [d] @?= [d] , testCase "keeps diagnostics under \".\" watched directory" do let d = errMsg {file = Location (Path.Relative (Path.rel @"src/Foo.hs"))}- filterToWatchDirs root (WatchDirs [root]) [d] @?= [d]+ filterToWatchDirs root (WatchDirs $ one root) [d] @?= [d] , testCase "drops diagnostics from outside the project (e.g. Nix store .h files)" do let d = errMsg {file = Location (Path.Absolute (Path.abs @"/nix/store/abc123/ghcautoconf.h"))} filterToWatchDirs root watchDirs [d] @?= []@@ -224,14 +224,14 @@ -- A mangled path joined onto projectRoot would incorrectly start with -- projectRoot+"/", so this case requires an explicit guard. let d = errMsg {file = Location (Path.Relative (Path.rel @"In file included from src/Foo.hs"))}- filterToWatchDirs root (WatchDirs [root]) [d] @?= []+ filterToWatchDirs root (WatchDirs $ one root) [d] @?= [] , testCase "passes everything through when watchDirs is empty" do let d = errMsg {file = Location (Path.Absolute (Path.abs @"/nix/store/abc123/ghcautoconf.h"))}- filterToWatchDirs root (WatchDirs []) [d] @?= [d]+ filterToWatchDirs root (WatchDirs mempty) [d] @?= [d] , testCase "works with the '.' fallback watch dir (whole project root)" do let d = errMsg {file = Location errPath} nixD = errMsg {file = Location (Path.Absolute (Path.abs @"/nix/store/abc123/ghcautoconf.h"))}- filterToWatchDirs root (WatchDirs [root]) [d, nixD] @?= [d]+ filterToWatchDirs root (WatchDirs $ one root) [d, nixD] @?= [d] , testGroup "when diagnostic has no path it" [ testCase "keeps location-less <no location info> errors" do@@ -269,7 +269,7 @@ ] where root = Path.absolute @"/project"- watchDirs = WatchDirs [Path.absolute @"/project/src"]+ watchDirs = WatchDirs $ one $ Path.absolute @"/project/src" testPlanActions :: [TestTree]
test/Unit/Tricorder/Daemon/Ghci/ProcessSpec.hs view
@@ -1,6 +1,6 @@ module Unit.Tricorder.Daemon.Ghci.ProcessSpec (test_Process) where -import Atelier.Effects.Log (Message (..), Severity (..))+import Atelier.Effects.Log (Message (..)) import Atelier.Effects.Process (terminateProcessGroup, withProcessGroup) import Atelier.Effects.Process.Internal (RunningProcess (..)) import Atelier.Time (Millisecond)@@ -37,6 +37,7 @@ import Atelier.Effects.Delay qualified as Delay import Atelier.Effects.Handles qualified as Handles import Atelier.Effects.Log qualified as Log+import Atelier.Effects.Log.Severity qualified as Severity import Atelier.Effects.Process qualified as AProc import Atelier.Effects.Process qualified as Atelier.Process import Atelier.Effects.Timeout qualified as Timeout@@ -175,7 +176,7 @@ $ do Handles.hClose w trySync (Process.drainUntil r (finishMarker 3) (\_ -> pure ()))- case filter (\m -> m.severity == ERROR) msgs of+ case filter (\m -> m.severity == Severity.ERROR) msgs of [] -> assertFailure "expected an ERROR log message" (logMsg : _) -> do (finishMarker 3 `T.isInfixOf` logMsg.text) @?= True@@ -191,7 +192,7 @@ for_ ["oops-line-1", "oops-line-2"] (Handles.hPutTextLn w) Handles.hClose w trySync (Process.drainUntil r (finishMarker 4) (\_ -> pure ()))- case filter (\m -> m.severity == ERROR) msgs of+ case filter (\m -> m.severity == Severity.ERROR) msgs of [] -> assertFailure "expected an ERROR log message" (logMsg : _) -> do (finishMarker 4 `T.isInfixOf` logMsg.text) @?= True
test/Unit/Tricorder/Daemon/WatchSpec.hs view
@@ -64,21 +64,21 @@ Watch.specs (ProjectRoot (Path.absolute @"/proj")) (WatchExclusionPatterns [])- (WatchDirs [Path.absolute @"/proj/src"])+ (WatchDirs $ one $ Path.absolute @"/proj/src") matchesAny watches (Path.absolute @"/proj/src/Foo.hs") @?= True , testCase "does not match non-.hs files" do let watches = Watch.specs (ProjectRoot (Path.absolute @"/proj")) (WatchExclusionPatterns [])- (WatchDirs [Path.absolute @"/proj/src"])+ (WatchDirs $ one $ Path.absolute @"/proj/src") matchesAny watches (Path.absolute @"/proj/src/Foo.txt") @?= False , testCase "excludes paths containing dist-newstyle" do let watches = Watch.specs (ProjectRoot (Path.absolute @"/proj")) (WatchExclusionPatterns [])- (WatchDirs [Path.absolute @"/proj/src"])+ (WatchDirs $ one $ Path.absolute @"/proj/src") matchesAny watches (Path.absolute @"/proj/src/dist-newstyle/Foo.hs") @?= False , testCase "excludes paths matching an exclusion pattern" do let pat = parsePattern "vendor"@@ -86,7 +86,7 @@ Watch.specs (ProjectRoot (Path.absolute @"/proj")) (WatchExclusionPatterns [pat])- (WatchDirs [Path.absolute @"/proj/src"])+ (WatchDirs $ one $ Path.absolute @"/proj/src") matchesAny watches (Path.absolute @"/proj/src/vendor/Foo.hs") @?= False matchesAny watches (Path.absolute @"/proj/src/Foo.hs") @?= True , testCase "matches .hs files across multiple watch dirs" do@@ -94,7 +94,7 @@ Watch.specs (ProjectRoot (Path.absolute @"/proj")) (WatchExclusionPatterns [])- (WatchDirs [Path.absolute @"/proj/src", Path.absolute @"/proj/test"])+ (WatchDirs $ fromList [Path.absolute @"/proj/src", Path.absolute @"/proj/test"]) matchesAny watches (Path.absolute @"/proj/src/Foo.hs") @?= True matchesAny watches (Path.absolute @"/proj/test/FooSpec.hs") @?= True , -- Second line of defense: 'cabalWatches' registers the whole project@@ -107,7 +107,7 @@ Watch.specs (ProjectRoot (Path.absolute @"/proj")) (WatchExclusionPatterns [])- (WatchDirs [Path.absolute @"/proj/pkg-a/src"])+ (WatchDirs $ one $ Path.absolute @"/proj/pkg-a/src") matchesAny watches (Path.absolute @"/proj/pkg-a/src/Foo.hs") @?= True matchesAny watches (Path.absolute @"/proj/pkg-b/src/Foo.hs") @?= False ]@@ -118,35 +118,35 @@ Watch.specs (ProjectRoot (Path.absolute @"/proj")) (WatchExclusionPatterns [])- (WatchDirs [])+ (WatchDirs mempty) matchesAny watches (Path.absolute @"/proj/foo.cabal") @?= True , testCase "matches cabal.project under project root" do let watches = Watch.specs (ProjectRoot (Path.absolute @"/proj")) (WatchExclusionPatterns [])- (WatchDirs [])+ (WatchDirs mempty) matchesAny watches (Path.absolute @"/proj/cabal.project") @?= True , testCase "does not match package.yaml (its .cabal file is watched instead)" do let watches = Watch.specs (ProjectRoot (Path.absolute @"/proj")) (WatchExclusionPatterns [])- (WatchDirs [])+ (WatchDirs mempty) matchesAny watches (Path.absolute @"/proj/package.yaml") @?= False , testCase "does not match non-cabal files" do let watches = Watch.specs (ProjectRoot (Path.absolute @"/proj")) (WatchExclusionPatterns [])- (WatchDirs [])+ (WatchDirs mempty) matchesAny watches (Path.absolute @"/proj/README.md") @?= False , testCase "excludes cabal files under dist-newstyle" do let watches = Watch.specs (ProjectRoot (Path.absolute @"/proj")) (WatchExclusionPatterns [])- (WatchDirs [])+ (WatchDirs mempty) matchesAny watches (Path.absolute @"/proj/dist-newstyle/foo.cabal") @?= False ] ]
test/Unit/Tricorder/Session/CabalFileSpec.hs view
@@ -11,6 +11,7 @@ import Atelier.Effects.Log qualified as Log import Atelier.FileSystem.Path qualified as Path import Data.Map.Strict qualified as Map+import Data.Set qualified as Set import Tricorder.Runtime.ProjectRoot (ProjectRoot (..)) import Tricorder.Session.CabalFile@@ -54,16 +55,16 @@ "when there is no cabal.project" [ testCase "finds the .cabal files in the project root" do actual <- runDiscovery (Map.singleton (rel "myapp.cabal") cabalFixture)- actual @?= Right [rel "myapp.cabal"]+ actual @?= Right (fromList [rel "myapp.cabal"]) , testCase "returns no files when the root has no cabal file" do actual <- runDiscovery mempty- actual @?= Right []+ actual @?= Right mempty ] , testGroup "when there is a multi-package cabal.project" [ testCase "resolves each listed package to its .cabal (regression: was root-only)" do actual <- runDiscovery multiPackageFs- actual @?= Right [rel "pkg-a/pkg-a.cabal", rel "pkg-b/pkg-b.cabal"]+ actual @?= Right (fromList [rel "pkg-a/pkg-a.cabal", rel "pkg-b/pkg-b.cabal"]) ] , testGroup "priority among cabal.project.local, cabal.project.freeze, and cabal.project"@@ -75,7 +76,7 @@ , (rel "cabal.project", "packages: pkg-b\n") ] `Map.union` multiPackageCabalFs- actual @?= Right [rel "pkg-a/pkg-a.cabal"]+ actual @?= Right (fromList [rel "pkg-a/pkg-a.cabal"]) , testCase "prefers cabal.project.freeze over cabal.project" do actual <- runDiscovery@@ -84,7 +85,7 @@ , (rel "cabal.project", "packages: pkg-b\n") ] `Map.union` multiPackageCabalFs- actual @?= Right [rel "pkg-a/pkg-a.cabal"]+ actual @?= Right (fromList [rel "pkg-a/pkg-a.cabal"]) , testGroup "when a higher-priority file lists no packages" [ testCase "falls through to the next file in priority order" do@@ -95,29 +96,29 @@ , (rel "cabal.project", "packages: pkg-b\n") ] `Map.union` multiPackageCabalFs- actual @?= Right [rel "pkg-b/pkg-b.cabal"]+ actual @?= Right (fromList [rel "pkg-b/pkg-b.cabal"]) ] ] , testGroup "packages: entry resolution" [ testCase "uses a direct .cabal path entry verbatim, without scanning a directory" do actual <- runDiscovery $ Map.singleton (rel "cabal.project") "packages: sub/foo.cabal\n"- actual @?= Right [rel "sub/foo.cabal"]+ actual @?= Right (fromList [rel "sub/foo.cabal"]) , testCase "expands a glob entry matching .cabal files directly" do actual <- runDiscovery $ Map.singleton (rel "cabal.project") "packages: */*.cabal\n" `Map.union` multiPackageCabalFs- fromRight [] actual @?= [rel "pkg-a/pkg-a.cabal", rel "pkg-b/pkg-b.cabal"]+ actual @?= Right (fromList [rel "pkg-a/pkg-a.cabal", rel "pkg-b/pkg-b.cabal"]) , testCase "expands a glob entry matching package directories" do actual <- runDiscovery $ Map.singleton (rel "cabal.project") "packages: */\n" `Map.union` multiPackageCabalFs- fromRight [] actual @?= [rel "pkg-a/pkg-a.cabal", rel "pkg-b/pkg-b.cabal"]+ actual @?= Right (fromList [rel "pkg-a/pkg-a.cabal", rel "pkg-b/pkg-b.cabal"]) , testCase "returns no files when a glob entry matches nothing" do actual <- runDiscovery $ Map.singleton (rel "cabal.project") "packages: */*.cabal\n"- actual @?= Right []+ actual @?= Right mempty ] , testGroup "$HOME/.cabal/config fallback"@@ -128,7 +129,7 @@ runDiscovery $ Map.singleton (rel "home/.cabal/config") "packages: pkg-a\n" `Map.union` multiPackageCabalFs- actual @?= Right [rel "pkg-a/pkg-a.cabal"]+ actual @?= Right (fromList [rel "pkg-a/pkg-a.cabal"]) ] , testGroup "when $HOME/.cabal/config exists but lists no packages"@@ -139,7 +140,7 @@ [ (rel "home/.cabal/config", "") , (rel "myapp.cabal", cabalFixture) ]- actual @?= Right [rel "myapp.cabal"]+ actual @?= Right (fromList [rel "myapp.cabal"]) ] ] , testGroup@@ -151,7 +152,7 @@ runDiscovery $ Map.singleton (rel "cabal.project") "packages: pkg-a, pkg-b\n" `Map.union` multiPackageCabalFs- fromRight [] actual @?= [rel "pkg-a/pkg-a.cabal", rel "pkg-b/pkg-b.cabal"]+ actual @?= Right (fromList [rel "pkg-a/pkg-a.cabal", rel "pkg-b/pkg-b.cabal"]) ] ] ]@@ -167,7 +168,7 @@ -- @$HOME@ is pointed at @home/@ inside the root, so a test can seed -- @home/.cabal/config@ and tests that don't are unaffected by the real -- @$HOME@.-runDiscovery :: Map Path.Relative ByteString -> IO (Either Text [Path.Relative])+runDiscovery :: Map Path.Relative ByteString -> IO (Either Text (Set Path.Relative)) runDiscovery files = withProjectFiles files \root -> do let pr = ProjectRoot root@@ -175,7 +176,7 @@ withHome (root </> Path.relative @"home") $ Glob.runIO $ runReader pr discoverCabalPackages- pure $ fmap (fmap (Path.makeRelative root)) result+ pure $ fmap (Set.map (Path.makeRelative root)) result -- | Pins the discovery contract: with a @stack.yaml@, package paths come@@ -184,13 +185,13 @@ testDiscoverStackPackages = [ testCase "resolves each package path against the project root" do let actual = runStack (StackProject [Path.rel @"pkg-a", Path.rel @"pkg-b"]) discoverStackPackages- actual @?= Right [Path.absolute @"/pkg-a", Path.absolute @"/pkg-b"]+ actual @?= Right (fromList [Path.absolute @"/pkg-a", Path.absolute @"/pkg-b"]) , testCase "normalises resolved paths" do let actual = runStack (StackProject [Path.rel @"./pkg-a"]) discoverStackPackages- actual @?= Right [Path.absolute @"/pkg-a"]+ actual @?= Right (fromList [Path.absolute @"/pkg-a"]) , testCase "returns no packages when the list is empty" do let actual = runStack (StackProject []) discoverStackPackages- actual @?= Right []+ actual @?= Right mempty ] where pr = ProjectRoot (Path.absolute @"/")
test/Unit/Tricorder/Session/Helpers.hs view
@@ -39,15 +39,16 @@ $ parseGenericPackageDescriptionMaybe cabalFixture -multiCabalFiles :: [CabalFile]+multiCabalFiles :: Set CabalFile multiCabalFiles =- uncurry CabalFile- . bimap- (Path.absolute @"/" </>)- ( fromMaybe (error "multiCabalFiles failed to parse")- . parseGenericPackageDescriptionMaybe- )- <$> Map.toList multiPackageCabalFs+ fromList+ $ uncurry CabalFile+ . bimap+ (Path.absolute @"/" </>)+ ( fromMaybe (error "multiCabalFiles failed to parse")+ . parseGenericPackageDescriptionMaybe+ )+ <$> Map.toList multiPackageCabalFs -- | An in-memory project root with a @cabal.project@ listing two packages,@@ -139,8 +140,8 @@ ] -singleCabalFile :: [CabalFile]-singleCabalFile = [CabalFile (Path.absolute @"/myapp.cabal") gpdFixture]+singleCabalFile :: Set CabalFile+singleCabalFile = one $ CabalFile (Path.absolute @"/myapp.cabal") gpdFixture gpdFixture :: GenericPackageDescription
test/Unit/Tricorder/Session/TargetSpec.hs view
@@ -75,7 +75,7 @@ [ testGroup "when targets are configured" [ testCase "parses and sorts configured targets" do- let actual = resolve [] ["lib:foo", "test:foo-test"]+ let actual = resolve mempty ["lib:foo", "test:foo-test"] actual @?= [Qualified Lib "foo", Qualified Test "foo-test"] ] , testGroup@@ -97,7 +97,7 @@ assertBool "expected myapp-test among the targets" $ PackageQualified "myapp" Test "myapp-test" `elem` actual , testCase "returns no targets when there are no cabal files" do- let actual = resolve [] []+ let actual = resolve mempty [] actual @?= [] , -- [tag: test_resolve_targest_aggregate] testCase "aggregates components across every package (regression: was 0)" do@@ -113,7 +113,7 @@ CabalFile (Path.absolute @"/myprelude.cabal") $ fromMaybe (error "libWithPreludeCabal failed to parse") $ parseGenericPackageDescriptionMaybe (libWithPreludeCabal "myprelude")- let actual = resolve [cabalFile] []+ let actual = resolve (one cabalFile) [] actual @?= [ PackageQualified "myprelude" Exe "myprelude-exe" , PackageQualified "myprelude" Lib "myprelude"@@ -239,11 +239,11 @@ [ testGroup "when the main library exposes Prelude" [ testCase "returns True for Qualified Lib \"\" (unnamed main lib)" do- definesCustomPrelude [preludeCF] (Qualified Lib "") @?= True+ definesCustomPrelude (one preludeCF) (Qualified Lib "") @?= True , testCase "returns True for Qualified Lib matching the package name" do- definesCustomPrelude [preludeCF] (Qualified Lib "myprelude") @?= True+ definesCustomPrelude (one preludeCF) (Qualified Lib "myprelude") @?= True , testCase "returns True for Bare matching the package name" do- definesCustomPrelude [preludeCF] (Bare "myprelude") @?= True+ definesCustomPrelude (one preludeCF) (Bare "myprelude") @?= True ] , testGroup "when no library exposes Prelude"@@ -255,14 +255,14 @@ , testGroup "for non-library targets" [ testCase "returns False for Qualified Exe" do- definesCustomPrelude [preludeCF] (Qualified Exe "myprelude-exe") @?= False+ definesCustomPrelude (one preludeCF) (Qualified Exe "myprelude-exe") @?= False , testCase "returns False for Qualified Test" do definesCustomPrelude singleCabalFile (Qualified Test "myapp-test") @?= False , testCase "returns False for Unrecognized" do- definesCustomPrelude [preludeCF] (Unrecognized "library:myprelude") @?= False+ definesCustomPrelude (one preludeCF) (Unrecognized "library:myprelude") @?= False ] , testCase "returns False when the cabal file list is empty" do- definesCustomPrelude [] (Qualified Lib "anything") @?= False+ definesCustomPrelude mempty (Qualified Lib "anything") @?= False ] where preludeCF =
test/Unit/Tricorder/Session/WatchDirsSpec.hs view
@@ -31,34 +31,34 @@ "when watch_dirs is set in config" [ testCase "uses config dirs relative to project root" do let actual =- WatchDirs.resolve pr [] def {watchDirs = ["src", "test"]} []+ WatchDirs.resolve pr mempty def {watchDirs = ["src", "test"]} [] actual- @?= Right (WatchDirs [Path.absolute @"/src", Path.absolute @"/test"])+ @?= Right (WatchDirs $ fromList [Path.absolute @"/src", Path.absolute @"/test"]) ] , testGroup "when watch_dirs is not set" [ testCase "falls back to [\".\"] when targets list is empty" do- let actual = WatchDirs.resolve pr [] def []+ let actual = WatchDirs.resolve pr mempty def [] actual- @?= Right (WatchDirs [Path.absolute @"/"])+ @?= Right (WatchDirs $ fromList [Path.absolute @"/"]) , testCase "infers source dirs from resolved targets" do let actual = WatchDirs.resolve pr singleCabalFile def (mkTargets ["lib:myapp", "test:myapp-test"]) actual- @?= Right (WatchDirs [Path.absolute @"/src", Path.absolute @"/test"])+ @?= Right (WatchDirs $ fromList [Path.absolute @"/src", Path.absolute @"/test"]) , testCase "falls back to [\".\"] when there are no cabal files" do let actual =- WatchDirs.resolve pr [] def (mkTargets ["lib:myapp"])+ WatchDirs.resolve pr mempty def (mkTargets ["lib:myapp"]) actual- @?= Right (WatchDirs [Path.absolute @"/"])+ @?= Right (WatchDirs $ fromList [Path.absolute @"/"]) , -- Sharp edge: an unparseable .cabal yields no source dirs, so resolution -- falls back to watching the whole project root. This pins the current -- behavior; if it ever changes to something narrower, update this test. testCase "falls back to [\".\"] when no cabal files are found or parsed" do let actual =- WatchDirs.resolve pr [] def (mkTargets ["lib:myapp"])+ WatchDirs.resolve pr mempty def (mkTargets ["lib:myapp"]) actual- @?= Right (WatchDirs [Path.absolute @"/"])+ @?= Right (WatchDirs $ fromList [Path.absolute @"/"]) ] , testGroup "when the project is a multi-package cabal.project"@@ -72,17 +72,18 @@ actual @?= Right ( WatchDirs- [ Path.absolute @"/pkg-a/src"- , Path.absolute @"/pkg-a/test"- , Path.absolute @"/pkg-b/src"- , Path.absolute @"/pkg-b/test"- ]+ $ fromList+ [ Path.absolute @"/pkg-a/src"+ , Path.absolute @"/pkg-a/test"+ , Path.absolute @"/pkg-b/src"+ , Path.absolute @"/pkg-b/test"+ ] ) , testCase "scopes a bare package-name target to that package, ignoring siblings" do let actual = WatchDirs.resolve pr multiCabalFiles def (mkTargets ["pkg-a"]) actual- @?= Right (WatchDirs [Path.absolute @"/pkg-a/src", Path.absolute @"/pkg-a/test"])+ @?= Right (WatchDirs $ fromList [Path.absolute @"/pkg-a/src", Path.absolute @"/pkg-a/test"]) ] ] where
test/Unit/Tricorder/SessionSpec.hs view
@@ -1,6 +1,6 @@ module Unit.Tricorder.SessionSpec (test_Session) where -import Atelier.Effects.Log (Message (..), Severity (..))+import Atelier.Effects.Log (Message (..)) import Data.Aeson (object, (.=)) import Distribution.PackageDescription.Parsec (parseGenericPackageDescriptionMaybe) import Effectful.Reader.Static (runReader)@@ -10,6 +10,7 @@ import Atelier.Effects.Input qualified as Input import Atelier.Effects.Log qualified as Log+import Atelier.Effects.Log.Severity qualified as Severity import Atelier.FileSystem.Path qualified as Path import Data.Aeson qualified as Aeson import Data.Text qualified as T@@ -41,13 +42,13 @@ [ testGroup "when every resolved target exposes a custom Prelude module" [ testCase "logs one message" do- msgs <- captureSessionLogs [preludeOnlyCF]+ msgs <- captureSessionLogs $ one preludeOnlyCF length msgs @?= 1 , testCase "emits a WARN" do- msgs <- fmap (\m -> (m.severity, m.text)) <$> captureSessionLogs [preludeOnlyCF]+ msgs <- fmap (\m -> (m.severity, m.text)) <$> captureSessionLogs (one preludeOnlyCF) case msgs of [(sev, msg)] -> do- sev @?= WARN+ sev @?= Severity.WARN "Every resolved target exposes a custom Prelude module" `T.isPrefixOf` msg @? "does not start with expected string" xs ->@@ -57,12 +58,12 @@ "when not every resolved target exposes a custom Prelude module" [ testCase "does not emit a WARN" do -- libWithPreludeCabal has both a lib (custom Prelude) and an exe (no Prelude)- msgs <- captureSessionLogs [mixedCF]- any (\m -> m.severity == WARN) msgs @?= False+ msgs <- captureSessionLogs (one mixedCF)+ any (\m -> m.severity == Severity.WARN) msgs @?= False ] , testCase "does not emit a WARN when there are no resolved targets" do- msgs <- captureSessionLogs []- any (\m -> m.severity == WARN) msgs @?= False+ msgs <- captureSessionLogs mempty+ any (\m -> m.severity == Severity.WARN) msgs @?= False ] where preludeOnlyCF =@@ -76,7 +77,7 @@ captureSessionLogs = captureSessionLogs' $ Aeson.Object mempty captureSessionLogs' cfg cabalFiles = withProjectFiles mempty \root ->- fmap (filter (\m -> m.severity /= DEBUG))+ fmap (filter (\m -> m.severity /= Severity.DEBUG)) . execWriter @[Message] . Log.runWriter . Input.withConst cabalFiles@@ -95,29 +96,29 @@ [ testCase "emits a WARN when it has no {target} placeholder" do let cfg = sessionCfg ["test" .= object ["command_template" .= ("cabal repl test:foo" :: Text)]] logs <- captureLogsFor cfg- any (\m -> m.severity == WARN) logs @?= True+ any (\m -> m.severity == Severity.WARN) logs @?= True , testCase "does not emit a WARN when it has the {target} placeholder" do let cfg = sessionCfg ["test" .= object ["command_template" .= ("cabal repl {target}" :: Text)]] logs <- captureLogsFor cfg- any (\m -> m.severity == WARN) logs @?= False+ any (\m -> m.severity == Severity.WARN) logs @?= False ] , testGroup "eval.command_template" [ testCase "emits a WARN when it has no {target} placeholder" do let cfg = sessionCfg ["eval" .= object ["command_template" .= ("cabal repl Tricorder.Foo" :: Text)]] logs <- captureLogsFor cfg- any (\m -> m.severity == WARN) logs @?= True+ any (\m -> m.severity == Severity.WARN) logs @?= True , testCase "does not emit a WARN when it has the {target} placeholder" do let cfg = sessionCfg ["eval" .= object ["command_template" .= ("cabal repl {target}" :: Text)]] logs <- captureLogsFor cfg- any (\m -> m.severity == WARN) logs @?= False+ any (\m -> m.severity == Severity.WARN) logs @?= False ] , testGroup "build.command_template" [ testCase "does not emit a WARN when it has no {targets} placeholder" do let cfg = sessionCfg ["build" .= object ["command_template" .= ("cabal repl lib:foo" :: Text)]] logs <- captureLogsFor cfg- any (\m -> m.severity == WARN) logs @?= False+ any (\m -> m.severity == Severity.WARN) logs @?= False ] ] where@@ -126,7 +127,7 @@ withProjectFiles mempty \root -> execWriter @[Message] . Log.runWriter- . Input.withConst ([] :: [CabalFile])+ . Input.withConst (mempty :: Set CabalFile) . runReader (ProjectRoot root) . Input.withConst (LoadedConfig $ toStrict $ Aeson.encode cfg) . Tricorder.Config.asInput@@ -149,7 +150,7 @@ loadSessionWith cfg = withProjectFiles mempty \root -> Log.runNoOp- . Input.withConst ([] :: [CabalFile])+ . Input.withConst (mempty :: Set CabalFile) . runReader (ProjectRoot root) . Input.withConst (LoadedConfig $ toStrict $ Aeson.encode cfg) . Tricorder.Config.asInput
test/Unit/Tricorder/SourceLookupSpec.hs view
@@ -161,8 +161,8 @@ , testGroup "project modules" [ testCase "resolves every component's source dirs against the package dir" do- projectSourceDirs [projectCabalFile (Path.absolute @"/")]- @?= ProjectSourceDirs [Path.absolute @"/p/src", Path.absolute @"/p/test"]+ projectSourceDirs (fromList [projectCabalFile (Path.absolute @"/")])+ @?= ProjectSourceDirs (fromList [Path.absolute @"/p/src", Path.absolute @"/p/test"]) , testCase "reads a module from the project's source dirs" do result <- runTestAt [] projectFiles noFetch@@ -281,11 +281,11 @@ projectDirs :: Path.Absolute -> ProjectSourceDirs-projectDirs root = projectSourceDirs [projectCabalFile root]+projectDirs root = projectSourceDirs $ one $ projectCabalFile root noProjectDirs :: ProjectSourceDirs-noProjectDirs = ProjectSourceDirs []+noProjectDirs = ProjectSourceDirs mempty projectTypesSource :: Text
tricorder.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: tricorder-version: 1.1.0.0+version: 1.1.1.0 synopsis: Continuous Haskell build status, diagnostics, and tests via a shared daemon description: tricorder rebuilds your Haskell project continuously and surfaces build status, diagnostics, test results, and documentation - for developers and LLM coding agents. Like ghcid and ghciwatch it reloads on every change, but builds run in a background daemon so multiple clients (an interactive TUI, a status CLI, an agent skill) share a single build state without triggering redundant rebuilds. It discovers components across multi-package cabal.project workspaces automatically and ships context-friendly output for agentic use via the CLI. category: Development@@ -71,6 +71,7 @@ Tricorder.CLI.UI.View Tricorder.Config Tricorder.Config.LoadedConfig+ Tricorder.Daemon.Arguments Tricorder.Daemon.Builder Tricorder.Daemon.Core Tricorder.Daemon.DaemonInfo@@ -104,7 +105,7 @@ Tricorder.Daemon.Main Tricorder.Daemon.TestRunner Tricorder.Daemon.Watch- Tricorder.Logging+ Tricorder.Logging.Severity.Config Tricorder.Runtime.Cache Tricorder.Runtime.Directory Tricorder.Runtime.LogPath@@ -185,11 +186,11 @@ , Cabal-syntax >=3.12 && <3.17 , Glob ==0.10.* , aeson >=2.2 && <2.4- , atelier-core ==1.1.*+ , atelier-core ==1.2.* , atelier-prelude ==0.4.* , autodocodec >=0.6 && <0.8 , base >=4.18 && <4.23- , brick ==3.0.*+ , brick ==3.1.* , bytestring >=0.11 && <0.13 , casing ==0.1.* , containers >=0.6 && <0.9@@ -215,7 +216,7 @@ , text ==2.1.* , time >=1.12 && <1.17 , time-units ==1.0.*- , tricorder-types ==1.1.*+ , tricorder-types ==1.2.* , vty >=6.5 && <6.8 , vty-crossplatform ==0.5.* , yaml ==0.11.*@@ -408,7 +409,7 @@ build-depends: Cabal-syntax >=3.12 && <3.17 , aeson >=2.2 && <2.4- , atelier-core ==1.1.*+ , atelier-core ==1.2.* , atelier-prelude ==0.4.* , base >=4.18 && <4.23 , bytestring >=0.11 && <0.13@@ -430,7 +431,7 @@ , time >=1.12 && <1.17 , time-units ==1.0.* , tricorder-internal- , tricorder-types ==1.1.*+ , tricorder-types ==1.2.* , typed-process ==0.2.* , unagi-chan ==0.4.* , unix ==2.8.*