polish: add install.sh, XDG setup, deployments/ examples, and github-token docs\n\n- Add install.sh following XDG Base Directory specification (~/.config/archie, ~/.local/share/archie, ~/.local/bin)\n- Add interactive setup for code forge (GitHub / Gitea / Standalone) and LLM provider selection (Ollama model picker / Cloud keys)\n- Implement NoopForge in internal/forge/noop.go for running Archie in standalone mode without a forge\n- Enable loginctl user linger and systemd user unit setup in install.sh\n- Add docs/github-token.md with step-by-step guidance for Classic PAT generation\n- Add top-level deployments/ directory with scenario templates (single-forge GitHub, multi-forge GitHub+Gitea, local Ollama standalone, systemd runbook)
This commit is contained in:
1 parent
52d21d6607
commit
6be754787d
19 files changed
+936
-53
No files matched your search
+34
-18
@@ -180,15 +180,23 @@ func run() int {
|
||||
cfg := doc.Config
|
||||
|
||||
secrets := secret.NewRegistry()
|
||||
token, err := cfg.Forge.Token.Resolve(secrets)
|
||||
if err != nil || token == "" {
|
||||
fmt.Fprintf(os.Stderr, "forge token (engine %q, key %q) is required: %v\n", cfg.Forge.Token.Engine, cfg.Forge.Token.Key, err)
|
||||
return 1
|
||||
}
|
||||
forgeClient, err := forge.New(cfg.Forge.Type, token, cfg.Forge.Host, log)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
return 1
|
||||
var forgeClient forge.Forge
|
||||
var token string
|
||||
if cfg.Forge.Type == "none" || cfg.Forge.Type == "off" || cfg.Forge.Type == "disabled" {
|
||||
forgeClient = forge.NewNoop(log)
|
||||
} else {
|
||||
var errToken error
|
||||
token, errToken = cfg.Forge.Token.Resolve(secrets)
|
||||
if errToken != nil || token == "" {
|
||||
fmt.Fprintf(os.Stderr, "forge token (engine %q, key %q) is required: %v\n", cfg.Forge.Token.Engine, cfg.Forge.Token.Key, errToken)
|
||||
return 1
|
||||
}
|
||||
var errForge error
|
||||
forgeClient, errForge = forge.New(cfg.Forge.Type, token, cfg.Forge.Host, log)
|
||||
if errForge != nil {
|
||||
fmt.Fprintln(os.Stderr, errForge)
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
st, err := nell.OpenStore(cfg.DBPath, cfg.BotUser)
|
||||
@@ -458,15 +466,23 @@ func run() int {
|
||||
// and Run() takes the legacy single-identity path unchanged.
|
||||
var identityRunners []*daemon.IdentityRunner
|
||||
for _, idCfg := range cfg.Identities {
|
||||
idToken, err := idCfg.Forge.Token.Resolve(secrets)
|
||||
if err != nil || idToken == "" {
|
||||
log.Error("identity forge token unresolved", "identity", idCfg.Name, "err", err)
|
||||
return 1
|
||||
}
|
||||
idForge, err := forge.New(idCfg.Forge.Type, idToken, idCfg.Forge.Host, log)
|
||||
if err != nil {
|
||||
log.Error("identity forge client failed", "identity", idCfg.Name, "err", err)
|
||||
return 1
|
||||
var idForge forge.Forge
|
||||
var idToken string
|
||||
if idCfg.Forge.Type == "none" || idCfg.Forge.Type == "off" || idCfg.Forge.Type == "disabled" {
|
||||
idForge = forge.NewNoop(log)
|
||||
} else {
|
||||
var errToken error
|
||||
idToken, errToken = idCfg.Forge.Token.Resolve(secrets)
|
||||
if errToken != nil || idToken == "" {
|
||||
log.Error("identity forge token unresolved", "identity", idCfg.Name, "err", errToken)
|
||||
return 1
|
||||
}
|
||||
var errForge error
|
||||
idForge, errForge = forge.New(idCfg.Forge.Type, idToken, idCfg.Forge.Host, log)
|
||||
if errForge != nil {
|
||||
log.Error("identity forge client failed", "identity", idCfg.Name, "err", errForge)
|
||||
return 1
|
||||
}
|
||||
}
|
||||
idTrees := &worktree.Manager{
|
||||
WorkDir: filepath.Join(cfg.WorkDir, "identity-"+idCfg.Name),
|
||||
|
||||
+2
-2
@@ -64,7 +64,7 @@ class = "ollama"
|
||||
# queued behind it.
|
||||
# [chat]
|
||||
# operator = "Ada Lovelace"
|
||||
# workspace = "/var/lib/archie/workspace"
|
||||
# workspace = "~/.local/share/archie/workspace"
|
||||
# max_steps = 100
|
||||
# models = [
|
||||
# "openai/gpt-5.6-sol",
|
||||
@@ -101,7 +101,7 @@ command = "archie-agent" # executable path for subprocess mode (not used in n
|
||||
listen = "127.0.0.1:8484" # "off" disables
|
||||
|
||||
[notify] # optional webhook for human-in-the-loop moments (n8n -> email)
|
||||
# webhook = "https://n8n.catlow.cloud/webhook/archie"
|
||||
# webhook = "https://n8n.example.com/webhook/archie"
|
||||
|
||||
[budgets]
|
||||
max_steps = 60
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# Archie Core Deployment Examples
|
||||
|
||||
This directory contains configuration templates and guides for different deployment scenarios of Archie Core.
|
||||
|
||||
## Directory Structure
|
||||
|
||||
* **[`single-forge-github.toml`](./single-forge-github.toml)**:
|
||||
Standard single-forge deployment managing multiple GitHub repositories under a single bot account and GitHub token.
|
||||
|
||||
* **[`multi-forge-github-gitea.toml`](./multi-forge-github-gitea.toml)**:
|
||||
Multi-identity deployment running GitHub and a self-hosted Gitea instance simultaneously with distinct bot accounts, tokens, and repository sets.
|
||||
|
||||
* **[`local-ollama-standalone.toml`](./local-ollama-standalone.toml)**:
|
||||
Self-hosted deployment running local LLM models via Ollama (e.g., `llama3`, `qwen2.5`) with optional standalone (forge-disabled) operation.
|
||||
|
||||
* **[`systemd-user-service.md`](./systemd-user-service.md)**:
|
||||
Operational runbook for running `archied` as a persistent 24/7 background service via systemd user units and `loginctl enable-linger`.
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
Copy any scenario template to your XDG configuration directory (`${XDG_CONFIG_HOME:-~/.config}/archie/config.toml`):
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.config/archie
|
||||
cp deployments/single-forge-github.toml ~/.config/archie/config.toml
|
||||
```
|
||||
|
||||
Edit API keys in `~/.config/archie/env` or directly in `config.toml`, then launch Archie Core:
|
||||
|
||||
```bash
|
||||
archied
|
||||
# or via systemd:
|
||||
systemctl --user start archied
|
||||
```
|
||||
@@ -0,0 +1,40 @@
|
||||
# ==============================================================================
|
||||
# Self-Hosted Ollama + Standalone Mode Deployment Example
|
||||
#
|
||||
# Runs local open-weights models via Ollama (e.g. llama3, qwen2.5) with forge
|
||||
# polling disabled (standalone execution mode).
|
||||
# ==============================================================================
|
||||
|
||||
work_dir = "~/.local/share/archie/work"
|
||||
db_path = "~/.local/share/archie/archie.db"
|
||||
poll_interval = "60s"
|
||||
|
||||
# Standalone execution: Forge polling is disabled
|
||||
[forge]
|
||||
type = "none"
|
||||
|
||||
[models]
|
||||
triage = "ollama/llama3:latest"
|
||||
planner = "ollama/llama3:latest"
|
||||
builder = "ollama/llama3:latest"
|
||||
|
||||
[providers.ollama]
|
||||
class = "ollama"
|
||||
|
||||
# Optional chat workspace configuration
|
||||
[chat]
|
||||
operator = "Local Operator"
|
||||
workspace = "~/.local/share/archie/workspace"
|
||||
max_steps = 100
|
||||
models = [
|
||||
"ollama/llama3:latest",
|
||||
"ollama/qwen2.5:7b"
|
||||
]
|
||||
|
||||
[agent]
|
||||
mode = "inprocess"
|
||||
command = "archie-agent"
|
||||
|
||||
[budgets]
|
||||
max_steps = 60
|
||||
wall_clock = "30m"
|
||||
@@ -0,0 +1,82 @@
|
||||
# ==============================================================================
|
||||
# Multi-Forge (GitHub + Gitea) Deployment Example
|
||||
#
|
||||
# Runs GitHub and a self-hosted Gitea instance simultaneously.
|
||||
# Each [[identities]] entry defines its own forge, token, and repository list.
|
||||
# Each identity runs in an isolated background goroutine and worktree directory.
|
||||
# ==============================================================================
|
||||
|
||||
work_dir = "~/.local/share/archie/work"
|
||||
db_path = "~/.local/share/archie/archie.db"
|
||||
poll_interval = "60s"
|
||||
|
||||
[models]
|
||||
triage = "openai/gpt-4o"
|
||||
planner = "openai/gpt-4o"
|
||||
builder = "openai/gpt-4o"
|
||||
|
||||
[providers.openai]
|
||||
class = "openai"
|
||||
api_key_env = "OPENAI_API_KEY"
|
||||
|
||||
[agent]
|
||||
mode = "inprocess"
|
||||
command = "archie-agent"
|
||||
|
||||
[budgets]
|
||||
max_steps = 60
|
||||
wall_clock = "30m"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Identity 1: GitHub Bot
|
||||
# ------------------------------------------------------------------------------
|
||||
[[identities]]
|
||||
name = "github-bot"
|
||||
bot_user = "archie-github"
|
||||
bot_email = "archie-github@users.noreply.github.com"
|
||||
|
||||
[identities.forge]
|
||||
type = "github"
|
||||
host = "https://github.com"
|
||||
token = { engine = "env", key = "ARCHIE_GITHUB_TOKEN" }
|
||||
|
||||
[identities.dispatch]
|
||||
trigger = "assignee"
|
||||
ack_reaction = "eyes"
|
||||
|
||||
[[identities.repos]]
|
||||
owner = "my-org"
|
||||
name = "github-repo-one"
|
||||
ecosystem = "go"
|
||||
|
||||
[[identities.repos]]
|
||||
owner = "my-org"
|
||||
name = "github-repo-two"
|
||||
ecosystem = "node"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Identity 2: Self-Hosted Gitea Bot
|
||||
# ------------------------------------------------------------------------------
|
||||
[[identities]]
|
||||
name = "gitea-bot"
|
||||
bot_user = "archie-gitea"
|
||||
bot_email = "archie-gitea@example.com"
|
||||
|
||||
[identities.forge]
|
||||
type = "gitea"
|
||||
host = "https://gitea.example.com"
|
||||
token = { engine = "env", key = "ARCHIE_GITEA_TOKEN" }
|
||||
|
||||
[identities.dispatch]
|
||||
trigger = "label"
|
||||
ack_reaction = "eyes"
|
||||
|
||||
[[identities.repos]]
|
||||
owner = "internal-team"
|
||||
name = "gitea-repo-alpha"
|
||||
ecosystem = "go"
|
||||
|
||||
[[identities.repos]]
|
||||
owner = "internal-team"
|
||||
name = "gitea-repo-beta"
|
||||
ecosystem = "python"
|
||||
@@ -0,0 +1,71 @@
|
||||
# ==============================================================================
|
||||
# Single-Forge GitHub Deployment Example
|
||||
#
|
||||
# Manages multiple GitHub repositories using a single bot account and token.
|
||||
# One [forge] block applies to ALL [[repos]] entries below.
|
||||
# ==============================================================================
|
||||
|
||||
work_dir = "~/.local/share/archie/work"
|
||||
db_path = "~/.local/share/archie/archie.db"
|
||||
poll_interval = "60s"
|
||||
label = "archie"
|
||||
bot_user = "archie-bot"
|
||||
bot_email = "archie-bot@users.noreply.github.com"
|
||||
diff_cap_lines = 400
|
||||
|
||||
[forge]
|
||||
type = "github"
|
||||
host = "https://github.com"
|
||||
token = { engine = "env", key = "ARCHIE_GITHUB_TOKEN" }
|
||||
|
||||
[dispatch]
|
||||
trigger = "assignee" # "assignee", "label", or "either"
|
||||
ack_reaction = "eyes" # Emoji reaction on issue pickup
|
||||
|
||||
[dispatch.labels]
|
||||
queued = "archie:queued"
|
||||
working = "archie:working"
|
||||
waiting = "archie:waiting"
|
||||
pr = "archie:pr"
|
||||
parked = "archie:parked"
|
||||
|
||||
[models]
|
||||
triage = "openai/gpt-4o"
|
||||
planner = "openai/gpt-4o"
|
||||
builder = "openai/gpt-4o"
|
||||
|
||||
[providers.openai]
|
||||
class = "openai"
|
||||
api_key_env = "OPENAI_API_KEY"
|
||||
|
||||
[agent]
|
||||
mode = "inprocess"
|
||||
command = "archie-agent"
|
||||
|
||||
[budgets]
|
||||
max_steps = 60
|
||||
max_tokens = 400000
|
||||
wall_clock = "30m"
|
||||
|
||||
# List of repositories managed by this single GitHub forge configuration:
|
||||
[[repos]]
|
||||
owner = "my-org"
|
||||
name = "frontend-app"
|
||||
base = "main"
|
||||
ecosystem = "node"
|
||||
|
||||
[[repos]]
|
||||
owner = "my-org"
|
||||
name = "backend-service"
|
||||
base = "main"
|
||||
ecosystem = "go"
|
||||
gate = [
|
||||
["go", "vet", "./..."],
|
||||
["go", "test", "./...", "-count=1"]
|
||||
]
|
||||
|
||||
[[repos]]
|
||||
owner = "my-org"
|
||||
name = "shared-library"
|
||||
base = "main"
|
||||
ecosystem = "go"
|
||||
@@ -0,0 +1,71 @@
|
||||
# Managing `archied` with Systemd User Services
|
||||
|
||||
This runbook describes how to manage `archied` as a background user service on Linux servers.
|
||||
|
||||
---
|
||||
|
||||
## 1. Unit File (`~/.config/systemd/user/archied.service`)
|
||||
|
||||
Create the systemd user service file at `~/.config/systemd/user/archied.service`:
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Archie Core Orchestrator Daemon
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=%h/.local/bin/archied -config %h/.config/archie/config.toml
|
||||
EnvironmentFile=-%h/.config/archie/env
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Enabling User Linger (`loginctl`)
|
||||
|
||||
By default, systemd terminates user services when you log out of SSH. Enabling **linger** allows your `archied` service to run continuously 24/7 across reboots and logouts:
|
||||
|
||||
```bash
|
||||
loginctl enable-linger "$USER"
|
||||
```
|
||||
|
||||
Verify linger status:
|
||||
```bash
|
||||
loginctl show-user "$USER" | grep Linger
|
||||
# Output: Linger=yes
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Service Commands
|
||||
|
||||
Reload systemd daemon files:
|
||||
```bash
|
||||
systemctl --user daemon-reload
|
||||
```
|
||||
|
||||
Enable and start the service immediately:
|
||||
```bash
|
||||
systemctl --user enable --now archied
|
||||
```
|
||||
|
||||
Check service status:
|
||||
```bash
|
||||
systemctl --user status archied
|
||||
```
|
||||
|
||||
Tail live daemon logs:
|
||||
```bash
|
||||
journalctl --user -u archied -f
|
||||
```
|
||||
|
||||
Restart or stop the service:
|
||||
```bash
|
||||
systemctl --user restart archied
|
||||
systemctl --user stop archied
|
||||
```
|
||||
@@ -0,0 +1,53 @@
|
||||
# Generating a GitHub Token for Archie Core
|
||||
|
||||
This guide walks you through creating a GitHub Personal Access Token (PAT) for Archie Core.
|
||||
|
||||
> **Important**: Archie Core requires a **Classic Personal Access Token** (starts with `ghp_...`). Fine-grained PATs currently lack necessary scope permissions for Git HTTP push operations, repository invitation acceptance, and cross-repository operations needed by the orchestrator.
|
||||
|
||||
---
|
||||
|
||||
## Why Archie Core Needs a GitHub Token
|
||||
Archie Core uses the GitHub API to:
|
||||
1. Poll assigned or labelled issues (`archie:queued`).
|
||||
2. Update issue labels as tasks transition (`archie:working`, `archie:pr`, `archie:parked`).
|
||||
3. Post status comments and emoji reactions.
|
||||
4. Create branches, commit code changes, and open Pull Requests for human review.
|
||||
|
||||
---
|
||||
|
||||
## Step-by-Step Instructions: Creating a Classic Token
|
||||
|
||||
1. Navigate to [GitHub Settings → Developer Settings → Tokens (classic)](https://github.com/settings/tokens).
|
||||
2. Click **Generate new token** → **Generate new token (classic)**.
|
||||
3. Set the **Note**: `Archie Core` (or your bot's name).
|
||||
4. Choose an **Expiration** (e.g. 90 days, 1 year, or No expiration for dedicated bot accounts).
|
||||
5. Select the required scope:
|
||||
- **`repo`** (Full control of private repositories — required for polling, commenting, pushing branches, and opening PRs).
|
||||
- **`workflow`** (Optional — required if Archie needs to update GitHub Actions workflows).
|
||||
6. Scroll to the bottom and click **Generate token**.
|
||||
7. **Copy your token immediately** (starts with `ghp_...`). You won't be able to see it again!
|
||||
|
||||
---
|
||||
|
||||
## Configuring the Token in Archie Core
|
||||
|
||||
Save your token using any of the following methods:
|
||||
|
||||
### Method A: Environment File (Default XDG Location)
|
||||
Add your token to `${XDG_CONFIG_HOME:-~/.config}/archie/env`:
|
||||
```bash
|
||||
ARCHIE_GITHUB_TOKEN="ghp_YOUR_CLASSIC_TOKEN_HERE"
|
||||
```
|
||||
|
||||
### Method B: Environment Variable in Current Shell
|
||||
```bash
|
||||
export ARCHIE_GITHUB_TOKEN="ghp_YOUR_CLASSIC_TOKEN_HERE"
|
||||
```
|
||||
|
||||
### Method C: Directly in Configuration File (`~/.config/archie/config.toml`)
|
||||
```toml
|
||||
[forge]
|
||||
type = "github"
|
||||
host = "https://github.com"
|
||||
token = { engine = "env", key = "ARCHIE_GITHUB_TOKEN" }
|
||||
```
|
||||
@@ -70,7 +70,7 @@
|
||||
// dashboard) is reachable from the browser — reverse-proxy it under
|
||||
// this same host to avoid CORS. Override per-load with ?webui=.
|
||||
const WEBUI_BASE = new URLSearchParams(location.search).get("webui")
|
||||
|| "https://gitea.catlow.cloud/agent-events";
|
||||
|| "https://gitea.example.com/agent-events";
|
||||
|
||||
const term = new Terminal({ convertEol: true, disableStdin: true, cursorBlink: false, fontSize: 13 });
|
||||
term.open(el);
|
||||
|
||||
Executable
+447
@@ -0,0 +1,447 @@
|
||||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# install.sh - Installer for Archie Core (archied & archie-agent)
|
||||
#
|
||||
# Follows the XDG Base Directory Specification:
|
||||
# Config: ${XDG_CONFIG_HOME:-~/.config}/archie
|
||||
# - config.toml
|
||||
# - env (environment variables & API secrets)
|
||||
# - persona/
|
||||
# - skills/
|
||||
# Data: ${XDG_DATA_HOME:-~/.local/share}/archie
|
||||
# - archie.db
|
||||
# - work/
|
||||
# - memories/
|
||||
# - tasks/
|
||||
# - plugins/
|
||||
# Bin: ${XDG_BIN_HOME:-~/.local/bin}
|
||||
# - archied
|
||||
# - archie-agent
|
||||
# ==============================================================================
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Determine script location / repo root if executed from within archie-core
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_URL="https://github.com/samcharles93/archie-core.git"
|
||||
|
||||
# XDG Base Directory resolution
|
||||
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}"
|
||||
XDG_DATA_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}"
|
||||
XDG_BIN_HOME="${XDG_BIN_HOME:-${HOME}/.local/bin}"
|
||||
|
||||
ARCHIE_CONFIG_DIR="${XDG_CONFIG_HOME}/archie"
|
||||
ARCHIE_DATA_DIR="${XDG_DATA_HOME}/archie"
|
||||
ARCHIE_BIN_DIR="${XDG_BIN_HOME}"
|
||||
ENV_FILE="${ARCHIE_CONFIG_DIR}/env"
|
||||
|
||||
# Parse optional arguments
|
||||
INSTALL_SYSTEMD=true
|
||||
ENABLE_LINGER=true
|
||||
AUTO_START=true
|
||||
FORCE_BUILD=false
|
||||
INTERACTIVE=true
|
||||
|
||||
[ ! -t 0 ] && INTERACTIVE=false
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--no-systemd)
|
||||
INSTALL_SYSTEMD=false
|
||||
AUTO_START=false
|
||||
shift
|
||||
;;
|
||||
--no-linger)
|
||||
ENABLE_LINGER=false
|
||||
shift
|
||||
;;
|
||||
--no-start)
|
||||
AUTO_START=false
|
||||
shift
|
||||
;;
|
||||
--non-interactive|--batch)
|
||||
INTERACTIVE=false
|
||||
shift
|
||||
;;
|
||||
--force)
|
||||
FORCE_BUILD=true
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
echo "Usage: ./install.sh [options]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --no-systemd Skip systemd user unit installation"
|
||||
echo " --no-linger Skip loginctl enable-linger execution"
|
||||
echo " --no-start Install service but do not auto-start archied"
|
||||
echo " --non-interactive Run without interactive setup prompts"
|
||||
echo " --force Force rebuild binaries even if up to date"
|
||||
echo " --help, -h Show this help message"
|
||||
echo ""
|
||||
echo "XDG Target Directories:"
|
||||
echo " Config: ${ARCHIE_CONFIG_DIR}"
|
||||
echo " Data: ${ARCHIE_DATA_DIR}"
|
||||
echo " Bin: ${ARCHIE_BIN_DIR}"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "============================================================"
|
||||
echo " Archie Core Installer (XDG Standard)"
|
||||
echo "============================================================"
|
||||
echo "Config directory : ${ARCHIE_CONFIG_DIR}"
|
||||
echo "Data directory : ${ARCHIE_DATA_DIR}"
|
||||
echo "Bin directory : ${ARCHIE_BIN_DIR}"
|
||||
echo "============================================================"
|
||||
echo ""
|
||||
|
||||
# 1. Prerequisite checks
|
||||
echo "==> Checking prerequisites..."
|
||||
for cmd in git go; do
|
||||
if ! command -v "$cmd" &>/dev/null; then
|
||||
echo "Error: '$cmd' is required but not installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
GO_VERSION="$(go version | awk '{print $3}')"
|
||||
echo " [OK] git: $(git --version)"
|
||||
echo " [OK] go: ${GO_VERSION}"
|
||||
|
||||
if command -v docker &>/dev/null; then
|
||||
echo " [OK] docker: $(docker --version)"
|
||||
else
|
||||
echo " [INFO] docker is not installed (required only for NATS container mode)."
|
||||
fi
|
||||
|
||||
# 2. Create directory structure according to XDG standards
|
||||
echo "==> Creating XDG directory structure..."
|
||||
mkdir -p "${ARCHIE_CONFIG_DIR}"/{persona,skills}
|
||||
mkdir -p "${ARCHIE_DATA_DIR}"/{work,memories,tasks,plugins}
|
||||
mkdir -p "${ARCHIE_BIN_DIR}"
|
||||
|
||||
# 3. Determine source location
|
||||
SRC_DIR=""
|
||||
if [ -f "${SCRIPT_DIR}/go.mod" ] && grep -q "github.com/samcharles93/archie-core" "${SCRIPT_DIR}/go.mod"; then
|
||||
SRC_DIR="${SCRIPT_DIR}"
|
||||
echo "==> Installing from local repository: ${SRC_DIR}"
|
||||
else
|
||||
SRC_DIR="${ARCHIE_DATA_DIR}/src/archie-core"
|
||||
if [ -d "${SRC_DIR}/.git" ]; then
|
||||
echo "==> Updating source repository in ${SRC_DIR}..."
|
||||
git -C "${SRC_DIR}" pull --rebase
|
||||
else
|
||||
echo "==> Cloning archie-core repository to ${SRC_DIR}..."
|
||||
mkdir -p "$(dirname "${SRC_DIR}")"
|
||||
git clone "${REPO_URL}" "${SRC_DIR}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 4. Build and install binaries
|
||||
echo "==> Building archied and archie-agent..."
|
||||
(
|
||||
cd "${SRC_DIR}"
|
||||
go build -o "${ARCHIE_BIN_DIR}/archied" ./cmd/archied
|
||||
go build -o "${ARCHIE_BIN_DIR}/archie-agent" ./cmd/archie-agent
|
||||
)
|
||||
echo " Installed binaries to ${ARCHIE_BIN_DIR}/"
|
||||
|
||||
# 5. Interactive Configuration: Forge & LLM Provider Setup
|
||||
if [ ! -f "${ENV_FILE}" ]; then
|
||||
touch "${ENV_FILE}"
|
||||
chmod 600 "${ENV_FILE}"
|
||||
fi
|
||||
|
||||
# Detect existing environment keys
|
||||
FOUND_ENV_KEYS=()
|
||||
[ -n "${OPENAI_API_KEY:-}" ] && FOUND_ENV_KEYS+=("OpenAI")
|
||||
[ -n "${ANTHROPIC_API_KEY:-}" ] && FOUND_ENV_KEYS+=("Anthropic")
|
||||
[ -n "${OPENROUTER_API_KEY:-}" ] && FOUND_ENV_KEYS+=("OpenRouter")
|
||||
[ -n "${GEMINI_API_KEY:-}" ] && FOUND_ENV_KEYS+=("Gemini")
|
||||
[ -n "${GROQ_API_KEY:-}" ] && FOUND_ENV_KEYS+=("Groq")
|
||||
[ -n "${DEEPSEEK_API_KEY:-}" ] && FOUND_ENV_KEYS+=("DeepSeek")
|
||||
[ -n "${MISTRAL_API_KEY:-}" ] && FOUND_ENV_KEYS+=("Mistral")
|
||||
|
||||
# Detect local LLM binaries
|
||||
FOUND_OLLAMA=false
|
||||
FOUND_LLAMA_SERVER=false
|
||||
command -v ollama &>/dev/null && FOUND_OLLAMA=true
|
||||
command -v llama-server &>/dev/null && FOUND_LLAMA_SERVER=true
|
||||
|
||||
FORGE_TYPE="github"
|
||||
GITEA_URL="https://gitea.example.com"
|
||||
SELF_HOST_LLM=false
|
||||
OLLAMA_MODEL=""
|
||||
|
||||
if [ "${INTERACTIVE}" = true ]; then
|
||||
echo ""
|
||||
echo "------------------------------------------------------------"
|
||||
echo " Step 1: Code Forge Configuration (GitHub / Gitea / Standalone)"
|
||||
echo "------------------------------------------------------------"
|
||||
echo "Do you want to configure a code forge to watch for issues/PRs?"
|
||||
echo " 1) GitHub (Default - recommended for GitHub repos)"
|
||||
echo " 2) Gitea (Self-hosted Gitea instance)"
|
||||
echo " 3) None (Run Archie in standalone mode without forge polling)"
|
||||
read -rp "Select option [1-3, default=1]: " forge_option || forge_option="1"
|
||||
forge_option="${forge_option:-1}"
|
||||
|
||||
case "${forge_option}" in
|
||||
1)
|
||||
FORGE_TYPE="github"
|
||||
echo " See docs/github-token.md for instructions (Note: Archie requires a Classic PAT, ghp_...)."
|
||||
read -rp "Enter ARCHIE_GITHUB_TOKEN (leave blank to configure later): " gh_token_input || gh_token_input=""
|
||||
if [ -n "${gh_token_input}" ]; then
|
||||
echo "ARCHIE_GITHUB_TOKEN=\"${gh_token_input}\"" >> "${ENV_FILE}"
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
FORGE_TYPE="gitea"
|
||||
read -rp "Enter Gitea Base URL [https://gitea.example.com]: " gitea_url_input || gitea_url_input=""
|
||||
GITEA_URL="${gitea_url_input:-https://gitea.example.com}"
|
||||
read -rp "Enter ARCHIE_GITEA_TOKEN (leave blank to configure later): " gitea_token_input || gitea_token_input=""
|
||||
if [ -n "${gitea_token_input}" ]; then
|
||||
echo "ARCHIE_GITEA_TOKEN=\"${gitea_token_input}\"" >> "${ENV_FILE}"
|
||||
fi
|
||||
# Copy Gitea plugin scripts if available
|
||||
if [ -d "${SRC_DIR}/extras/gitea" ]; then
|
||||
cp -rn "${SRC_DIR}/extras/gitea/"* "${ARCHIE_DATA_DIR}/plugins/" 2>/dev/null || true
|
||||
fi
|
||||
;;
|
||||
3)
|
||||
FORGE_TYPE="none"
|
||||
echo " Forge polling disabled. Archie will run in standalone mode."
|
||||
;;
|
||||
esac
|
||||
|
||||
echo ""
|
||||
echo "------------------------------------------------------------"
|
||||
echo " Step 2: LLM Provider Configuration"
|
||||
echo "------------------------------------------------------------"
|
||||
|
||||
if [ "${FOUND_OLLAMA}" = true ] || [ "${FOUND_LLAMA_SERVER}" = true ]; then
|
||||
echo "Detected local LLM engines on your system:"
|
||||
[ "${FOUND_OLLAMA}" = true ] && echo " - Ollama"
|
||||
[ "${FOUND_LLAMA_SERVER}" = true ] && echo " - llama-server"
|
||||
echo ""
|
||||
read -rp "Do you want Archie to use a self-hosted local LLM? [y/N]: " self_host_choice || self_host_choice="n"
|
||||
if [[ "${self_host_choice}" =~ ^[Yy] ]]; then
|
||||
SELF_HOST_LLM=true
|
||||
fi
|
||||
else
|
||||
read -rp "Do you want to set up Archie with a self-hosted local LLM (Ollama / llama.cpp)? [y/N]: " self_host_choice || self_host_choice="n"
|
||||
if [[ "${self_host_choice}" =~ ^[Yy] ]]; then
|
||||
SELF_HOST_LLM=true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${SELF_HOST_LLM}" = true ]; then
|
||||
if [ "${FOUND_OLLAMA}" = true ]; then
|
||||
echo "Querying installed Ollama models ('ollama list')..."
|
||||
OLLAMA_MODELS=($(ollama list 2>/dev/null | tail -n +2 | awk '{print $1}'))
|
||||
|
||||
if [ ${#OLLAMA_MODELS[@]} -gt 0 ]; then
|
||||
echo "Installed Ollama models found:"
|
||||
for idx in "${!OLLAMA_MODELS[@]}"; do
|
||||
echo " $((idx+1))) ${OLLAMA_MODELS[$idx]}"
|
||||
done
|
||||
read -rp "Select model number [1-${#OLLAMA_MODELS[@]}, default=1]: " model_idx || model_idx="1"
|
||||
model_idx="${model_idx:-1}"
|
||||
selected_i=$((model_idx - 1))
|
||||
if [ ${selected_i} -ge 0 ] && [ ${selected_i} -lt ${#OLLAMA_MODELS[@]} ]; then
|
||||
OLLAMA_MODEL="${OLLAMA_MODELS[$selected_i]}"
|
||||
echo "Selected model: ${OLLAMA_MODEL}"
|
||||
fi
|
||||
else
|
||||
echo "No models found in Ollama yet."
|
||||
read -rp "Enter model name to pull or use (e.g. llama3 or qwen2.5:7b): " OLLAMA_MODEL || OLLAMA_MODEL="llama3"
|
||||
fi
|
||||
else
|
||||
echo "Ollama is not currently found on \$PATH."
|
||||
echo "Install Ollama from https://ollama.com and pull a model (e.g. 'ollama pull llama3')."
|
||||
read -rp "Enter model name to configure (default: llama3): " OLLAMA_MODEL || OLLAMA_MODEL="llama3"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Prompt for cloud provider key if not self-hosting and no keys detected
|
||||
if [ "${SELF_HOST_LLM}" = false ] && [ ${#FOUND_ENV_KEYS[@]} -eq 0 ]; then
|
||||
echo "No existing cloud provider API keys were detected."
|
||||
read -rp "Enter OPENAI_API_KEY (leave blank to configure later): " openai_key_input || openai_key_input=""
|
||||
if [ -n "${openai_key_input}" ]; then
|
||||
echo "OPENAI_API_KEY=\"${openai_key_input}\"" >> "${ENV_FILE}"
|
||||
FOUND_ENV_KEYS+=("OpenAI")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Write config.toml with selected options if config.toml doesn't exist
|
||||
if [ ! -f "${ARCHIE_CONFIG_DIR}/config.toml" ]; then
|
||||
echo "==> Generating initial config.toml..."
|
||||
if [ "${SELF_HOST_LLM}" = true ] && [ -n "${OLLAMA_MODEL}" ]; then
|
||||
cat <<EOF > "${ARCHIE_CONFIG_DIR}/config.toml"
|
||||
# archied configuration generated by install.sh
|
||||
poll_interval = "60s"
|
||||
label = "archie"
|
||||
bot_user = "archie-bot"
|
||||
|
||||
[forge]
|
||||
type = "${FORGE_TYPE}"
|
||||
host = "${GITEA_URL}"
|
||||
token = { engine = "env", key = "ARCHIE_GITHUB_TOKEN" }
|
||||
|
||||
[models]
|
||||
triage = "ollama/${OLLAMA_MODEL}"
|
||||
planner = "ollama/${OLLAMA_MODEL}"
|
||||
builder = "ollama/${OLLAMA_MODEL}"
|
||||
|
||||
[providers.ollama]
|
||||
class = "ollama"
|
||||
|
||||
[agent]
|
||||
mode = "inprocess"
|
||||
command = "archie-agent"
|
||||
|
||||
[budgets]
|
||||
max_steps = 60
|
||||
wall_clock = "30m"
|
||||
EOF
|
||||
else
|
||||
cp "${SRC_DIR}/config.example.toml" "${ARCHIE_CONFIG_DIR}/config.toml"
|
||||
if [ "${FORGE_TYPE}" = "none" ]; then
|
||||
sed -i 's/type = "github"/type = "none"/' "${ARCHIE_CONFIG_DIR}/config.toml" 2>/dev/null || true
|
||||
elif [ "${FORGE_TYPE}" = "gitea" ]; then
|
||||
sed -i 's/type = "github"/type = "gitea"/' "${ARCHIE_CONFIG_DIR}/config.toml" 2>/dev/null || true
|
||||
sed -i "s|https://github.com|${GITEA_URL}|" "${ARCHIE_CONFIG_DIR}/config.toml" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
chmod 600 "${ARCHIE_CONFIG_DIR}/config.toml"
|
||||
echo " Created ${ARCHIE_CONFIG_DIR}/config.toml"
|
||||
else
|
||||
echo " [SKIP] ${ARCHIE_CONFIG_DIR}/config.toml already exists (preserving user config)."
|
||||
fi
|
||||
|
||||
# 6. Seed skills, personas, memories, and onboarding tasks
|
||||
echo "==> Seeding skills and templates..."
|
||||
|
||||
# Copy built-in skills from .agents/skills and examples/skills
|
||||
if [ -d "${SRC_DIR}/.agents/skills" ]; then
|
||||
cp -rf "${SRC_DIR}/.agents/skills/"* "${ARCHIE_CONFIG_DIR}/skills/" 2>/dev/null || true
|
||||
fi
|
||||
if [ -d "${SRC_DIR}/examples/skills" ]; then
|
||||
cp -rn "${SRC_DIR}/examples/skills/"* "${ARCHIE_CONFIG_DIR}/skills/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Seed example personas without overwriting existing files
|
||||
if [ -d "${SRC_DIR}/examples/persona" ]; then
|
||||
cp -rn "${SRC_DIR}/examples/persona/"* "${ARCHIE_CONFIG_DIR}/persona/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Seed initial tasks without overwriting existing files
|
||||
if [ -d "${SRC_DIR}/examples/tasks" ]; then
|
||||
cp -rn "${SRC_DIR}/examples/tasks/"* "${ARCHIE_DATA_DIR}/tasks/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# 7. Systemd user service setup & linger configuration
|
||||
SERVICE_INSTALLED=false
|
||||
if [ "${INSTALL_SYSTEMD}" = true ] && command -v systemctl &>/dev/null && [ -d "${XDG_CONFIG_HOME}" ]; then
|
||||
SYSTEMD_USER_DIR="${XDG_CONFIG_HOME}/systemd/user"
|
||||
SERVICE_FILE="${SYSTEMD_USER_DIR}/archied.service"
|
||||
|
||||
echo "==> Configuring systemd user service..."
|
||||
mkdir -p "${SYSTEMD_USER_DIR}"
|
||||
cat <<EOF > "${SERVICE_FILE}"
|
||||
[Unit]
|
||||
Description=Archie Core Orchestrator Daemon
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=${ARCHIE_BIN_DIR}/archied -config ${ARCHIE_CONFIG_DIR}/config.toml
|
||||
EnvironmentFile=-${ENV_FILE}
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
EOF
|
||||
systemctl --user daemon-reload || true
|
||||
SERVICE_INSTALLED=true
|
||||
echo " Installed ${SERVICE_FILE}"
|
||||
|
||||
# Enable linger so systemd --user runs continuously without an active login session
|
||||
if [ "${ENABLE_LINGER}" = true ] && command -v loginctl &>/dev/null; then
|
||||
if loginctl show-user "${USER}" 2>/dev/null | grep -q "Linger=no"; then
|
||||
echo "==> Enabling systemd user linger (loginctl enable-linger ${USER})..."
|
||||
loginctl enable-linger "${USER}" || echo " Notice: Could not enable linger automatically. Run 'loginctl enable-linger ${USER}' manually if needed."
|
||||
else
|
||||
echo " [OK] User linger is already enabled."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Auto-enable and start service
|
||||
if [ "${AUTO_START}" = true ]; then
|
||||
echo "==> Enabling and starting archied systemd service..."
|
||||
systemctl --user enable --now archied || echo " Notice: Could not start service automatically. Check systemctl --user status archied"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 8. Post-installation summary & instructions
|
||||
echo ""
|
||||
echo "============================================================"
|
||||
echo " ✓ Archie Core Installation Complete!"
|
||||
echo "============================================================"
|
||||
echo ""
|
||||
echo "Installation Details:"
|
||||
echo " - Binaries : ${ARCHIE_BIN_DIR}/archied"
|
||||
echo " ${ARCHIE_BIN_DIR}/archie-agent"
|
||||
echo " - Config : ${ARCHIE_CONFIG_DIR}/config.toml"
|
||||
echo " - Secrets : ${ENV_FILE}"
|
||||
echo " - Data : ${ARCHIE_DATA_DIR}/"
|
||||
echo " - Forge Mode : ${FORGE_TYPE}"
|
||||
|
||||
if [ "${SELF_HOST_LLM}" = true ] && [ -n "${OLLAMA_MODEL}" ]; then
|
||||
echo " - LLM Model : ollama/${OLLAMA_MODEL}"
|
||||
elif [ ${#FOUND_ENV_KEYS[@]} -gt 0 ]; then
|
||||
echo " - LLM Keys : Found (${FOUND_ENV_KEYS[*]})"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Check PATH
|
||||
if [[ ":$PATH:" != *":${ARCHIE_BIN_DIR}:"* ]]; then
|
||||
echo "NOTE: ${ARCHIE_BIN_DIR} is not in your current PATH."
|
||||
echo "Add it to your shell configuration file (~/.bashrc or ~/.zshrc):"
|
||||
echo " export PATH=\"${ARCHIE_BIN_DIR}:\$PATH\""
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${SELF_HOST_LLM}" = false ] && [ ${#FOUND_ENV_KEYS[@]} -eq 0 ] && ! grep -q "=" "${ENV_FILE}" 2>/dev/null; then
|
||||
echo "============================================================"
|
||||
echo " Notice: LLM Provider Configuration Needed"
|
||||
echo "============================================================"
|
||||
echo "No LLM provider keys or local models were configured yet."
|
||||
echo "Archie requires an LLM provider to run workflows."
|
||||
echo ""
|
||||
echo "To finish configuration:"
|
||||
echo " 1. For Cloud Providers (OpenAI, Anthropic, OpenRouter, etc.):"
|
||||
echo " Add your API key to ${ENV_FILE}:"
|
||||
echo " OPENAI_API_KEY=\"sk-...\""
|
||||
echo " 2. For Local LLMs (Ollama):"
|
||||
echo " Install Ollama (https://ollama.com), run 'ollama pull llama3',"
|
||||
echo " and set [models] in ${ARCHIE_CONFIG_DIR}/config.toml to 'ollama/llama3'."
|
||||
echo ""
|
||||
echo "See documentation: ${SRC_DIR}/docs/github-token.md"
|
||||
echo "============================================================"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${SERVICE_INSTALLED}" = true ] && [ "${AUTO_START}" = true ]; then
|
||||
echo "Service Management:"
|
||||
echo " - View live logs : journalctl --user -u archied -f"
|
||||
echo " - Service status : systemctl --user status archied"
|
||||
echo " - Restart daemon : systemctl --user restart archied"
|
||||
else
|
||||
echo "Manual Startup:"
|
||||
echo " 1. Add tokens to ${ENV_FILE} or ${ARCHIE_CONFIG_DIR}/config.toml"
|
||||
echo " 2. Run daemon : archied"
|
||||
fi
|
||||
echo ""
|
||||
@@ -406,8 +406,7 @@ func TestStopCancelsRunningChatTurn(t *testing.T) {
|
||||
const allowedUserID = int64(42)
|
||||
g := New("1:test", "", "", []int64{allowedUserID}, slog.Default())
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
ctx := t.Context()
|
||||
g.turns = gateway.NewTurns(slog.Default())
|
||||
|
||||
// stopCurrentTurn resolves the session through the router; with none
|
||||
|
||||
@@ -2,6 +2,7 @@ package daemon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"sort"
|
||||
"sync"
|
||||
)
|
||||
@@ -84,7 +85,7 @@ func (r *runningTasks) stopAll(identity string) []int64 {
|
||||
for _, cancel := range cancels {
|
||||
cancel()
|
||||
}
|
||||
sort.Slice(ids, func(i, j int) bool { return ids[i] < ids[j] })
|
||||
slices.Sort(ids)
|
||||
return ids
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,10 @@ func New(forgeType, token, host string, log *slog.Logger) (Forge, error) {
|
||||
return NewGitHub(token, host, log)
|
||||
case "gitea":
|
||||
return NewGitea(token, host, log)
|
||||
case "none", "off", "disabled", "":
|
||||
return NewNoop(log), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported forge type %q (want github or gitea)", forgeType)
|
||||
return nil, fmt.Errorf("unsupported forge type %q (want github, gitea, or none)", forgeType)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package forge
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
)
|
||||
|
||||
// NoopForge is a zero-op Forge implementation used when forge polling is disabled ("none", "off", or "disabled").
|
||||
type NoopForge struct {
|
||||
log *slog.Logger
|
||||
}
|
||||
|
||||
// NewNoop returns a NoopForge instance.
|
||||
func NewNoop(log *slog.Logger) Forge {
|
||||
if log == nil {
|
||||
log = slog.Default()
|
||||
}
|
||||
return &NoopForge{log: log}
|
||||
}
|
||||
|
||||
func (n *NoopForge) AssignedIssues(ctx context.Context, owner, repo, assignee string) ([]Issue, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) IssuesWithLabel(ctx context.Context, owner, repo, label string) ([]Issue, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) Comment(ctx context.Context, owner, repo string, number int, body string) (int64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) RepliesAfter(ctx context.Context, owner, repo string, number int, afterID int64, exclude string) ([]Reply, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) CloseIssue(ctx context.Context, owner, repo string, number int, comment string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) CreateIssue(ctx context.Context, owner, repo, title, body string, labels []string) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) React(ctx context.Context, owner, repo string, number int, reaction string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) SetStateLabel(ctx context.Context, owner, repo string, number int, label string, knownLabels []string) {
|
||||
}
|
||||
|
||||
func (n *NoopForge) CreatePR(ctx context.Context, owner, repo, title, head, base, body string) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) PRState(ctx context.Context, owner, repo string, number int) (string, error) {
|
||||
return "closed", nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) AcceptInvitations(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) VerifyPush(ctx context.Context, owner, repo string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *NoopForge) LinkBranch(ctx context.Context, owner, repo string, issueNumber int, branch string) error {
|
||||
return nil
|
||||
}
|
||||
@@ -116,8 +116,7 @@ func TestStopLeavesTheCallersContextAlone(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
turns := testTurns(t)
|
||||
callerCtx, callerCancel := context.WithCancel(context.Background())
|
||||
defer callerCancel()
|
||||
callerCtx := t.Context()
|
||||
|
||||
started := make(chan struct{})
|
||||
turns.Submit(callerCtx, "s1", func(ctx context.Context) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"sort"
|
||||
)
|
||||
|
||||
@@ -44,7 +45,7 @@ func (fs fileSet) sortedFeatures() []Feature {
|
||||
for f := range fs.features {
|
||||
names = append(names, f)
|
||||
}
|
||||
sort.Slice(names, func(i, j int) bool { return names[i] < names[j] })
|
||||
slices.Sort(names)
|
||||
return names
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
@@ -17,8 +18,11 @@ const (
|
||||
agentModeSubprocess = "subprocess"
|
||||
agentModeNATS = "nats"
|
||||
|
||||
forgeTypeGitHub = "github"
|
||||
forgeTypeGitea = "gitea"
|
||||
forgeTypeGitHub = "github"
|
||||
forgeTypeGitea = "gitea"
|
||||
forgeTypeNone = "none"
|
||||
forgeTypeOff = "off"
|
||||
forgeTypeDisabled = "disabled"
|
||||
|
||||
dispatchTriggerAssignee = "assignee"
|
||||
dispatchTriggerLabel = "label"
|
||||
@@ -27,7 +31,7 @@ const (
|
||||
|
||||
var (
|
||||
agentModes = []string{agentModeInProcess, agentModeSubprocess, agentModeNATS}
|
||||
forgeTypes = []string{forgeTypeGitHub, forgeTypeGitea}
|
||||
forgeTypes = []string{forgeTypeGitHub, forgeTypeGitea, forgeTypeNone, forgeTypeOff, forgeTypeDisabled}
|
||||
dispatchTriggers = []string{dispatchTriggerAssignee, dispatchTriggerLabel, dispatchTriggerEither}
|
||||
)
|
||||
|
||||
@@ -108,7 +112,7 @@ func validateIdentities(identities []config.IdentityConfig) error {
|
||||
if !oneOf(id.Forge.Type, forgeTypes) {
|
||||
return fmt.Errorf("%w: identities[%d].forge.type %q (want %s)", ErrInvalidInput, i, id.Forge.Type, list(forgeTypes))
|
||||
}
|
||||
if id.Forge.Token == (secret.SecretRef{}) {
|
||||
if !isForgeDisabled(id.Forge.Type) && id.Forge.Token == (secret.SecretRef{}) {
|
||||
return fmt.Errorf("%w: identities[%d].forge.token is required (each identity needs its own secret reference; unlike the top-level [forge], there is no default)", ErrInvalidInput, i)
|
||||
}
|
||||
if err := validateRepos(id.Repos); err != nil {
|
||||
@@ -118,6 +122,10 @@ func validateIdentities(identities []config.IdentityConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func isForgeDisabled(t string) bool {
|
||||
return t == forgeTypeNone || t == forgeTypeOff || t == forgeTypeDisabled
|
||||
}
|
||||
|
||||
func validateSingleIdentity(cfg *config.Config) error {
|
||||
if cfg.BotUser == "" {
|
||||
return fmt.Errorf("%w: bot_user is required (or define [[identities]])", ErrInvalidInput)
|
||||
@@ -165,12 +173,7 @@ func validateContainers(cfg *config.Config) error {
|
||||
|
||||
// oneOf reports whether value is in allowed.
|
||||
func oneOf(value string, allowed []string) bool {
|
||||
for _, a := range allowed {
|
||||
if value == a {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(allowed, value)
|
||||
}
|
||||
|
||||
// list renders allowed values for an error message.
|
||||
|
||||
@@ -3,6 +3,7 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -310,10 +311,8 @@ func checkKillAll(seg Segment) (string, bool) {
|
||||
if baseName(seg.Name) != "kill" {
|
||||
return "", false
|
||||
}
|
||||
for _, arg := range seg.Args {
|
||||
if arg == "-1" {
|
||||
return "signals every process on the system", true
|
||||
}
|
||||
if slices.Contains(seg.Args, "-1") {
|
||||
return "signals every process on the system", true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
@@ -438,20 +437,13 @@ func namesDaemon(arg string) bool {
|
||||
}
|
||||
|
||||
func anyNamesDaemon(args []string) bool {
|
||||
for _, arg := range args {
|
||||
if namesDaemon(arg) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.ContainsFunc(args, namesDaemon)
|
||||
}
|
||||
|
||||
func hasAny(args []string, wanted ...string) bool {
|
||||
for _, arg := range args {
|
||||
for _, w := range wanted {
|
||||
if arg == w {
|
||||
return true
|
||||
}
|
||||
if slices.Contains(wanted, arg) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -63,7 +63,7 @@ func Split(line string) []Segment {
|
||||
}
|
||||
|
||||
runes := []rune(line)
|
||||
for i := 0; i < len(runes); i++ {
|
||||
for i := range runes {
|
||||
r := runes[i]
|
||||
|
||||
if escaped {
|
||||
|
||||
Reference in new issue
Block a user