packages feed

kioku-cli-0.7.0.0: src/Kioku/Cli.hs

module Kioku.Cli
  ( cliParserInfo,
    cliParserPrefs,
    main,
  )
where

import Kioku.Cli.Commands.Artifacts (ArtifactsOptions, artifactsOptionsParser, runArtifacts)
import Kioku.Cli.Commands.Demo (DemoOptions, demoOptionsParser, runDemo)
import Kioku.Cli.Commands.DemoSession (DemoSessionOptions, demoSessionOptionsParser, runDemoSession)
import Kioku.Cli.Commands.Distill (DistillOptions, distillOptionsParser, runDistill)
import Kioku.Cli.Commands.Persona (PersonaOptions, personaOptionsParser, runPersona)
import Kioku.Cli.Commands.Recall (RecallOptions, recallOptionsParser, runRecall)
import Kioku.Cli.Commands.Scenes (ScenesOptions, runScenes, scenesOptionsParser)
import Kioku.Cli.Commands.Worker (WorkerOptions, runWorker, workerOptionsParser)
import Options.Applicative

data Command = Artifacts ArtifactsOptions | Demo DemoOptions | DemoSession DemoSessionOptions | Distill DistillOptions | Persona PersonaOptions | Recall RecallOptions | Scenes ScenesOptions | Worker WorkerOptions

main :: IO ()
main = run =<< customExecParser cliParserPrefs cliParserInfo

-- | A fixed width makes help output stable in terminals, tests, and generated
-- documentation instead of inheriting the invoking process's console width.
cliParserPrefs :: ParserPrefs
cliParserPrefs = prefs (columns 100)

cliParserInfo :: ParserInfo Command
cliParserInfo =
  info
    (commandParser <**> helper)
    ( fullDesc
        <> progDesc "kioku reusable agent memory tools"
        <> header "kioku"
    )

commandParser :: Parser Command
commandParser =
  subparser $
    command
      "demo"
      (info (Demo <$> (helper <*> demoOptionsParser)) (progDesc "Run the memory/session demonstration (writes permanent events)"))
      <> command
        "demo-session"
        (info (DemoSession <$> (helper <*> demoSessionOptionsParser)) (progDesc "Run the session aggregate demonstration (writes permanent events)"))
      <> command
        "distill"
        (info (Distill <$> (helper <*> distillOptionsParser)) (progDesc "Run distillation commands"))
      <> command
        "migrate-artifacts"
        ( info
            (Artifacts <$> (helper <*> artifactsOptionsParser))
            (progDesc "Move pre-partition .kioku scene and persona mirrors into a memory space")
        )
      <> command
        "persona"
        (info (Persona <$> (helper <*> personaOptionsParser)) (progDesc "Print distilled L3 persona"))
      <> command
        "recall"
        (info (Recall <$> (helper <*> recallOptionsParser)) (progDesc "Recall memories by query"))
      <> command
        "scenes"
        (info (Scenes <$> (helper <*> scenesOptionsParser)) (progDesc "Print distilled L2 scenes"))
      <> command
        "worker"
        (info (Worker <$> (helper <*> workerOptionsParser)) (progDesc "Run kioku background workers"))

run :: Command -> IO ()
run (Artifacts opts) = runArtifacts opts
run (Demo opts) = runDemo opts
run (DemoSession opts) = runDemoSession opts
run (Distill opts) = runDistill opts
run (Persona opts) = runPersona opts
run (Recall opts) = runRecall opts
run (Scenes opts) = runScenes opts
run (Worker opts) = runWorker opts