A-gent-0.11.0.20: src/Agent/IO/Effects.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE NoGeneralizedNewtypeDeriving #-}
{-# LANGUAGE Safe #-}
--------------------------------------------------------------------------------
-- |
-- Copyright : (c) 2026 SPISE MISU ApS
-- License : SSPL-1.0 OR AGPL-3.0-only
-- Maintainer : SPISE MISU <mail+hackage@spisemisu.com>
-- Stability : experimental
--------------------------------------------------------------------------------
module Agent.IO.Effects
( -- * LLM (Config)
LlmConf(llmPathCWD)
-- * LLM (Chat)
, LlmChatConf(llmChatAPI, llmChatKey)
, LlmChatPost(llmChatWeb)
, -- * LLM (Repo)
LlmRepoRoot(llmRepoDir)
, LlmRepoAtom(llmRepoBrs)
, LlmRepoTail(llmRepoGet)
, LlmRepoDesc(llmRepoLab)
, LlmRepoDiff(llmRepoCmp)
, LlmRepoDisp(llmRepoRem)
, LlmRepoMeld(llmRepoAdd)
-- Additive changes. Once added, it can't be removed. Therefore, ONLY add
-- iif Spec test are passing for the local atomic branch
--
-- Pull request and if success (when fetch / pull from origin) then REMove
-- the local TAIL branch.
, LlmRepoPull(llmRepoReq, llmRepoTug, llmRepoDel)
, -- * LLM (Code)
LlmCodeRoot(llmCodeDir)
, LlmCodeMask(llmCodeMsk)
, LlmCodeTmpl(llmCodeIns, llmCodeExa)
, LlmCodeRead(llmCodeSeq, llmCodeGet)
, LlmCodeSave(llmCodePut)
, LlmCodeConf(llmCodeAPI, llmCodeKey)
, LlmCodePost(llmCodeWeb)
, -- * LLM (Plan)
LlmPlanRoot(llmPlanDir)
, LlmPlanMask(llmPlanMsk)
, LlmPlanRead(llmPlanSeq, llmPlanGet)
, LlmPlanConf(llmPlanKey, llmPlanAPI)
, LlmPlanPost(llmPlanWeb)
, -- * LLM (Spec)
LlmSpecConf(llmSpecLib, llmSpecDep, llmSpecMod, llmSpecFun, llmSpecOto)
, LlmSpecTest(llmSpecRun)
, -- * LLM (Hone)
LlmHoneRoot(llmHoneDir)
, LlmHoneMask(llmHoneMsk)
, LlmHoneRead(llmHoneSeq, llmHoneGet)
, LlmHoneSave(llmHonePut)
, LlmHoneConf(llmHoneSOM, llmHoneKey)
, LlmHonePost(llmHoneWeb)
)
where
--------------------------------------------------------------------------------
import qualified Internal.LLM as LLM
--------------------------------------------------------------------------------
class
Monad m
=> LlmConf m
where
llmPathCWD
:: m (Maybe LLM.Root)
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
class
Monad m
=> LlmChatConf m
where
llmChatAPI
:: m (Maybe String)
llmChatKey
:: m (Maybe String)
--------------------------------------------------------------------------------
class
LlmChatConf m
=> LlmChatPost m
where
llmChatWeb
:: String
-> m (Either String String)
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
class
LlmConf m
=> LlmRepoRoot m
where
llmRepoDir
:: m (Maybe LLM.Root)
class
LlmRepoRoot m
=> LlmRepoAtom m
where
llmRepoBrs
:: m (Either [String] LLM.Branches)
class
LlmRepoRoot m
=> LlmRepoTail m
where
llmRepoGet
:: m (Either String LLM.Branch)
class
( LlmRepoAtom m
, LlmRepoTail m
)
=> LlmRepoDesc m
where
llmRepoLab
:: LLM.UUID
-> LLM.Label
-> m (Either String String)
class
( LlmRepoAtom m
, LlmRepoTail m
)
=> LlmRepoDiff m
where
llmRepoCmp
:: LLM.UUID
-> m (Either String [String])
class
( LlmRepoAtom m
, LlmRepoTail m
)
=> LlmRepoDisp m
where
llmRepoRem
:: Maybe LLM.UUID
-> m (Either String [String])
class
( LlmRepoAtom m
, LlmRepoTail m
)
=> LlmRepoMeld m
where
llmRepoAdd
:: m (Either String [String])
class
LlmRepoTail m
=> LlmRepoPull m
where
llmRepoReq
:: m (Either String [String])
llmRepoTug
:: m (Either String [String])
llmRepoDel
:: m (Either String [String])
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
class
Monad m
=> LlmCodeRoot m
where
llmCodeDir
:: m String -- Ex: "src"
--------------------------------------------------------------------------------
class
Monad m
=> LlmCodeMask m
where
llmCodeMsk
:: m [ String ] -- Ex: [ "*.hs", "*.lhs" ]
--------------------------------------------------------------------------------
class
Monad m
=> LlmCodeTmpl m
where
llmCodeIns
:: m (Either [String] [LLM.File])
llmCodeExa
:: m [LLM.File]
--------------------------------------------------------------------------------
class
( LlmConf m
, LlmRepoRoot m
, LlmCodeRoot m
, LlmCodeMask m
)
=> LlmCodeRead m
where
llmCodeSeq
:: Maybe LLM.Filter
-> m (Either [String] LLM.FilePaths)
llmCodeGet
:: LLM.AbsoluteFilePath
-> m (Either String LLM.File)
--------------------------------------------------------------------------------
class
( LlmConf m
, LlmRepoRoot m
, LlmCodeRoot m
)
=> LlmCodeSave m
where
llmCodePut
:: LLM.Context a
-> Maybe LLM.UUID
-> String
-> LLM.Files
-> m (Either String String)
--------------------------------------------------------------------------------
class
Monad m
=> LlmCodeConf m
where
llmCodeAPI
:: m (Maybe String)
llmCodeKey
:: m (Maybe String)
--------------------------------------------------------------------------------
class
LlmCodeConf m
=> LlmCodePost m
where
llmCodeWeb
:: String
-> m (Either String String)
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
class
LlmConf m
=> LlmPlanRoot m
where
llmPlanDir
:: m String -- Ex: "llm"
--------------------------------------------------------------------------------
class
Monad m
=> LlmPlanMask m
where
llmPlanMsk
:: m [ String ] -- Ex: [ "plan_*.md" ]
--------------------------------------------------------------------------------
class
( LlmConf m
, LlmPlanRoot m
, LlmPlanMask m
, LlmCodeRead m
)
=> LlmPlanRead m
where
llmPlanSeq
:: Maybe LLM.Filter
-> m (Either [String] LLM.FilePaths)
llmPlanGet
:: String
-> m (Either String LLM.File)
--------------------------------------------------------------------------------
class
Monad m
=> LlmPlanConf m
where
llmPlanAPI
:: m (Maybe String)
llmPlanKey
:: m (Maybe String)
--------------------------------------------------------------------------------
class
LlmPlanConf m
=> LlmPlanPost m
where
llmPlanWeb
:: String
-> m (Either String String)
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
class
Monad m
=> LlmSpecConf m
where
llmSpecLib
:: m String -- Ex: "spec"
llmSpecMod
:: m String -- Ex: "Spec.Core"
llmSpecFun
:: m String -- Ex: "testSuite"
llmSpecDep
:: m [ String ] -- Ex: [ "core", "common", "utils" ]
llmSpecOto
:: m (Maybe Int) -- Ex: Just 45
--------------------------------------------------------------------------------
class
( LlmRepoAtom m
, LlmRepoTail m
, LlmCodeRoot m
, LlmSpecConf m
)
=> LlmSpecTest m
where
llmSpecRun
:: LLM.UUID
-> m (Either String LLM.TestCases)
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
class
LlmConf m
=> LlmHoneRoot m
where
llmHoneDir
:: m (Maybe LLM.Root)
--------------------------------------------------------------------------------
class
LlmCodeMask m
=> LlmHoneMask m
where
llmHoneMsk
:: m LLM.Mask -- NOTE: Limited to: [ "*.hs" ]
--------------------------------------------------------------------------------
class
( LlmCodeRoot m
, LlmHoneRoot m
, LlmRepoTail m
, LlmHoneMask m
)
=> LlmHoneRead m
where
llmHoneSeq
:: Maybe LLM.Filter
-> m (Either [String] LLM.FilePaths)
llmHoneGet
{-
:: LLM.AbsoluteFilePaths
-> m (Either [String] LLM.Files)
-}
:: LLM.AbsoluteFilePath
-> m (Either String LLM.File)
--------------------------------------------------------------------------------
class
( LlmConf m
, LlmRepoTail m
, LlmCodeRoot m
, LlmHoneRoot m
)
=> LlmHoneSave m
where
llmHonePut
:: LLM.Context a
-> String
-> LLM.Files
-> m (Either String String)
--------------------------------------------------------------------------------
class
Monad m
=> LlmHoneConf m
where
llmHoneSOM
:: m (Maybe String)
llmHoneKey
:: m (Maybe String)
--------------------------------------------------------------------------------
class
LlmHoneConf m
=> LlmHonePost m
where
llmHoneWeb
:: String
-> m (Either String String)
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------