Created nimble package and installation instructions.

This commit is contained in:
Jakob Friedl
2025-08-22 10:48:00 +02:00
parent 0ccafaccdd
commit 5922a5b850
10 changed files with 85 additions and 20 deletions

View File

@@ -1,5 +1,6 @@
import terminal, strformat, strutils, sequtils, tables, system, osproc, streams, parsetoml
import ../globals
import ../core/logger
import ../db/database
import ../../common/[types, utils, profile, serialize, crypto]
@@ -51,10 +52,13 @@ proc replaceAfterPrefix(content, prefix, value: string): string =
proc compile(cq: Conquest, placeholderLength: int): string =
let
cqDir = cq.profile.getString("conquest_directory")
configFile = fmt"{cqDir}/src/agent/nim.cfg"
exeFile = fmt"{cqDir}/bin/monarch.x64.exe"
agentBuildScript = fmt"{cqDir}/src/agent/build.sh"
configFile = fmt"{CONQUEST_ROOT}/src/agent/nim.cfg"
exeFile = fmt"{CONQUEST_ROOT}/bin/monarch.x64.exe"
agentBuildScript = fmt"{CONQUEST_ROOT}/src/agent/build.sh"
# Update conquest root directory in agent build script
var buildScript = readFile(agentBuildScript).replaceAfterPrefix("CONQUEST_ROOT=", CONQUEST_ROOT)
writeFile(agentBuildScript, buildScript)
# Update placeholder and configuration values
let placeholder = PLACEHOLDER & "A".repeat(placeholderLength - (2 * len(PLACEHOLDER))) & PLACEHOLDER

View File

@@ -1,11 +1,12 @@
import times, strformat, strutils, prompt, terminal
import std/[dirs, paths]
import ../globals
import ../../common/[types, profile]
proc makeAgentLogDirectory*(cq: Conquest, agentId: string): bool =
try:
let cqDir = cq.profile.getString("conquest_directory")
createDir(cast[Path](fmt"{cqDir}/data/logs/{agentId}"))
createDir(cast[Path](fmt"{CONQUEST_ROOT}/data/logs/{agentId}"))
return true
except OSError:
return false
@@ -13,8 +14,7 @@ proc makeAgentLogDirectory*(cq: Conquest, agentId: string): bool =
proc log*(cq: Conquest, logEntry: string) =
let
date = now().format("dd-MM-yyyy")
cqDir = cq.profile.getString("conquest_directory")
agentLogPath = fmt"{cqDir}/data/logs/{cq.interactAgent.agentId}/{date}.session.log"
agentLogPath = fmt"{CONQUEST_ROOT}/data/logs/{cq.interactAgent.agentId}/{date}.session.log"
# Write log entry to file
let file = open(agentLogPath, fmAppend)

View File

@@ -134,12 +134,16 @@ proc init*(T: type Conquest, profile: Profile): Conquest =
cq.agents = initTable[string, Agent]()
cq.interactAgent = nil
cq.profile = profile
cq.keyPair = loadKeyPair(profile.getString("private_key_file"))
cq.dbPath = profile.getString("database_file")
cq.keyPair = loadKeyPair(CONQUEST_ROOT & "/" & profile.getString("private-key-file"))
cq.dbPath = CONQUEST_ROOT & "/" & profile.getString("database-file")
return cq
proc startServer*(profilePath: string) =
# Ensure that the conquest root directory was passed as a compile-time define
when not defined(CONQUEST_ROOT):
quit(0)
# Handle CTRL+C,
proc exit() {.noconv.} =
echo "Received CTRL+C. Type \"exit\" to close the application.\n"
@@ -154,7 +158,6 @@ proc startServer*(profilePath: string) =
cq = Conquest.init(profile)
cq.info("Using profile \"", profile.getString("name"), "\" (", profilePath ,").")
cq.info("Using private key \"", profile.getString("private_key_file"), "\".")
except CatchableError as err:
echo err.msg