Skip to content

Commit 4adf3c5

Browse files
sragssclaude
andauthored
chore: track OpenClaw config, scripts, and version pin
* chore: track OpenClaw config, credentials, and version pin Add deploy/openclaw.json as the canonical OpenClaw config (secrets blanked, rendered with secrets.json at deploy time via jq merge). Add deploy/openclaw-pin to pin the Merit-Systems/openclaw fork commit. Add deploy/craig/ with GitHub App token generation and git credential helper scripts, plus the systemd override for openclaw-gateway. Update AGENTS.md to instruct Craig to PR config changes to deploy/openclaw.json rather than editing ~/.openclaw/openclaw.json directly. Update deploy/setup.sh for the new setup flow (pnpm, fork clone, secrets.json, credential scripts). Note: deploy.yml is intentionally unchanged in this commit. The old pipeline still works. Switching to the new deploy flow happens after manual verification on EC2. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: add start-openclaw.sh and missing guilds.users config Add deploy/craig/start-openclaw.sh (startup wrapper, was only on EC2). Fix deploy/openclaw.json to include guilds["*"].users: ["*"] matching the live config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: tell Craig about the OpenClaw fork and PR workflow Update the OpenClaw Self-Reference section to point at Merit-Systems/openclaw instead of upstream. Explain the two-step flow: PR the fix on the fork, then update deploy/openclaw-pin here. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 423d610 commit 4adf3c5

File tree

9 files changed

+214
-22
lines changed

9 files changed

+214
-22
lines changed

AGENTS.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,21 @@ For code work, figure out which repo to target:
6262

6363
## OpenClaw Self-Reference
6464

65-
Your runtime is OpenClaw. The OpenClaw source is cloned locally at `~/Code/openclaw/openclaw`. When answering questions about your own functionality, capabilities, or configuration:
65+
Your runtime is OpenClaw. Merit-Systems maintains a fork at `Merit-Systems/openclaw`
66+
(upstream: `openclaw/openclaw`). The fork is cloned locally at `~/Code/openclaw/openclaw`.
67+
68+
When answering questions about your own functionality, capabilities, or configuration:
6669

6770
1. Pull latest: `cd ~/Code/openclaw/openclaw && git fetch && git pull`
6871
2. Read the relevant source or docs to give an accurate answer
69-
3. Cross-reference with your installed version: `ls /home/ubuntu/.npm-global/lib/node_modules/openclaw/`
7072

71-
The local docs are at `~/Code/openclaw/openclaw/docs/` and the source at `~/Code/openclaw/openclaw/src/`. Don't guess about how you work — check the code.
73+
The local docs are at `~/Code/openclaw/openclaw/docs/` and the source at
74+
`~/Code/openclaw/openclaw/src/`. Don't guess about how you work — check the code.
75+
76+
To fix bugs or add features to OpenClaw itself, create a PR on `Merit-Systems/openclaw`
77+
(same branch/PR workflow as any other repo). After the PR is merged, update the pin
78+
in this repo by editing `deploy/openclaw-pin` to the new commit hash and creating a
79+
PR here too — that triggers a rebuild and deploy of the new version.
7280

7381
## When Analyzing Discord Conversations
7482

@@ -85,6 +93,21 @@ After taking action, respond with a single short message:
8593

8694
Example: "Created PR #42 -- fixes the auth timeout in the login middleware."
8795

96+
## OpenClaw Configuration
97+
98+
Your OpenClaw config lives at `deploy/openclaw.json` in this repo. It is the
99+
source of truth — on every deploy it overwrites `~/.openclaw/openclaw.json`
100+
(merged with secrets that stay on EC2).
101+
102+
To change your own config (heartbeat interval, mention patterns, concurrency,
103+
etc.), edit `deploy/openclaw.json` on a branch and create a PR. Never edit
104+
`~/.openclaw/openclaw.json` directly — changes will be overwritten on next
105+
deploy.
106+
107+
The OpenClaw source is forked at `Merit-Systems/openclaw`. The deployed
108+
version is pinned by commit hash in `deploy/openclaw-pin`. Source changes
109+
go through PRs on that fork repo.
110+
88111
## x402 Payment Tools
89112

90113
You have access to x402 payment APIs via mcporter:

deploy/craig/get-github-token.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Generate a GitHub App installation token using PyJWT.
3+
# Requires: python3, PyJWT (pip install pyjwt[crypto])
4+
# Requires: ~/.config/craig/github-app-key.pem (private key, not tracked in repo)
5+
python3 -c "
6+
import json, time, urllib.request, jwt
7+
8+
app_id = 2840368
9+
now = int(time.time())
10+
payload = {\"iat\": now - 60, \"exp\": now + 600, \"iss\": app_id}
11+
12+
with open(\"/home/ubuntu/.config/craig/github-app-key.pem\") as f:
13+
private_key = f.read()
14+
15+
token = jwt.encode(payload, private_key, algorithm=\"RS256\")
16+
17+
req = urllib.request.Request(
18+
\"https://api.github.com/app/installations/109362995/access_tokens\",
19+
method=\"POST\",
20+
headers={
21+
\"Authorization\": f\"Bearer {token}\",
22+
\"Accept\": \"application/vnd.github+json\",
23+
}
24+
)
25+
resp = urllib.request.urlopen(req)
26+
data = json.loads(resp.read())
27+
print(data[\"token\"])
28+
"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
# Git credential helper for GitHub App installation tokens.
3+
# Configured via: git config --global credential.helper /path/to/this/script
4+
if echo "$1" | grep -q "get"; then
5+
TOKEN=$(/home/ubuntu/.config/craig/get-github-token.sh 2>/dev/null)
6+
echo "protocol=https"
7+
echo "host=github.com"
8+
echo "username=x-access-token"
9+
echo "password=$TOKEN"
10+
fi

deploy/craig/github.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Systemd drop-in override for openclaw-gateway.service
2+
# Injects a fresh GitHub App token into the environment on each (re)start.
3+
# Deployed to: ~/.config/systemd/user/openclaw-gateway.service.d/github.conf
4+
[Service]
5+
ExecStart=
6+
ExecStart=/bin/bash -c "export GH_TOKEN=$(/home/ubuntu/.config/craig/get-github-token.sh) && exec /usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/openclaw/dist/index.js gateway --port 18789"

deploy/craig/start-openclaw.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
# Startup wrapper for OpenClaw gateway.
3+
# Mints a fresh GitHub App token and execs the gateway process.
4+
# Note: largely redundant with github.conf systemd override, but kept
5+
# for manual restarts outside of systemd.
6+
export GH_TOKEN=$(/home/ubuntu/.config/craig/get-github-token.sh 2>/dev/null)
7+
export PATH="/home/ubuntu/.local/bin:/home/ubuntu/.npm-global/bin:/home/ubuntu/bin:/usr/local/bin:/usr/bin:/bin"
8+
exec /usr/bin/node /home/ubuntu/.npm-global/lib/node_modules/openclaw/dist/index.js gateway --port 18789

deploy/openclaw-pin

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0ada807

deploy/openclaw.json

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"auth": {
3+
"profiles": {
4+
"anthropic:default": {
5+
"provider": "anthropic",
6+
"mode": "api_key"
7+
}
8+
}
9+
},
10+
"agents": {
11+
"defaults": {
12+
"model": {
13+
"primary": "anthropic/claude-opus-4-6"
14+
},
15+
"workspace": "/home/ubuntu/Code/merit-systems/CraigClaw",
16+
"contextPruning": {
17+
"mode": "cache-ttl",
18+
"ttl": "1h"
19+
},
20+
"compaction": {
21+
"mode": "safeguard"
22+
},
23+
"heartbeat": {
24+
"every": "30m",
25+
"target": "discord",
26+
"to": "channel:1470899181383061504"
27+
},
28+
"maxConcurrent": 4,
29+
"subagents": {
30+
"maxConcurrent": 8
31+
}
32+
}
33+
},
34+
"messages": {
35+
"groupChat": {
36+
"mentionPatterns": [
37+
"\\bcraig\\b",
38+
"\\bbiden\\b"
39+
]
40+
},
41+
"ackReactionScope": "group-mentions"
42+
},
43+
"commands": {
44+
"native": "auto",
45+
"nativeSkills": "auto"
46+
},
47+
"channels": {
48+
"discord": {
49+
"enabled": true,
50+
"token": "",
51+
"allowBots": false,
52+
"groupPolicy": "open",
53+
"historyLimit": 50,
54+
"guilds": {
55+
"*": {
56+
"requireMention": true,
57+
"users": [
58+
"*"
59+
]
60+
}
61+
}
62+
}
63+
},
64+
"gateway": {
65+
"port": 18789,
66+
"mode": "local",
67+
"bind": "loopback",
68+
"auth": {
69+
"mode": "token",
70+
"token": ""
71+
},
72+
"tailscale": {
73+
"mode": "off",
74+
"resetOnExit": false
75+
}
76+
},
77+
"skills": {
78+
"install": {
79+
"nodeManager": "npm"
80+
}
81+
},
82+
"plugins": {
83+
"entries": {
84+
"discord": {
85+
"enabled": true
86+
}
87+
}
88+
}
89+
}

deploy/secrets.json.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"channels": {
3+
"discord": {
4+
"token": "YOUR_DISCORD_BOT_TOKEN"
5+
}
6+
},
7+
"gateway": {
8+
"auth": {
9+
"token": "YOUR_GATEWAY_AUTH_TOKEN"
10+
}
11+
}
12+
}

deploy/setup.sh

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ set -euo pipefail
1212
# ssh ubuntu@<ip> 'bash -s' < deploy/setup.sh
1313
#
1414
# After running this script, you still need to:
15-
# 1. Set environment variables (ANTHROPIC_API_KEY, DISCORD_BOT_TOKEN)
16-
# 2. Configure openclaw.json from the template
17-
# 3. Set up the GitHub App credentials
15+
# 1. Run OpenClaw onboard (see Next Steps output)
16+
# 2. Create ~/.openclaw/secrets.json (see deploy/secrets.json.example)
17+
# 3. Place GitHub App private key at ~/.config/craig/github-app-key.pem
1818
# 4. Install x402 (see Merit-Systems/OpenClawX402/x402.md)
1919

2020
echo "=== CraigClaw EC2 Setup ==="
@@ -24,9 +24,9 @@ echo "Installing Node.js 22..."
2424
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
2525
sudo apt-get install -y nodejs
2626

27-
# 2. Install OpenClaw
28-
echo "Installing OpenClaw..."
29-
curl -fsSL https://openclaw.ai/install.sh | bash
27+
# 2. Install pnpm (needed to build OpenClaw from fork source)
28+
echo "Installing pnpm..."
29+
npm install -g pnpm
3030

3131
# 3. Install GitHub CLI
3232
echo "Installing GitHub CLI..."
@@ -41,26 +41,33 @@ echo "Installing GitHub CLI..."
4141

4242
# 4. Create directory structure
4343
echo "Creating directory structure..."
44-
mkdir -p ~/Code/merit-systems
44+
mkdir -p ~/Code/merit-systems ~/Code/openclaw ~/.config/craig
4545

4646
# 5. Clone CraigClaw workspace
4747
echo "Cloning CraigClaw workspace..."
4848
git clone https://github.com/Merit-Systems/CraigClaw.git ~/Code/merit-systems/CraigClaw
4949

50-
# 6. Configure git
50+
# 6. Clone OpenClaw fork
51+
echo "Cloning OpenClaw fork..."
52+
git clone https://github.com/Merit-Systems/openclaw.git ~/Code/openclaw/openclaw
53+
54+
# 7. Configure git
5155
echo "Configuring git..."
5256
git config --global user.name "craig2-bot"
5357
git config --global user.email "craig2@merit-systems.dev"
5458
git config --global init.defaultBranch main
5559

56-
# 7. Run OpenClaw onboard
60+
# 8. Copy credential scripts from repo
61+
echo "Setting up credential scripts..."
62+
cp ~/Code/merit-systems/CraigClaw/deploy/craig/get-github-token.sh ~/.config/craig/
63+
cp ~/Code/merit-systems/CraigClaw/deploy/craig/git-credential-helper.sh ~/.config/craig/
64+
chmod +x ~/.config/craig/*.sh
65+
git config --global credential.helper /home/ubuntu/.config/craig/git-credential-helper.sh
66+
5767
echo ""
5868
echo "=== Next Steps ==="
59-
echo "1. Set your environment variables:"
69+
echo "1. Set your Anthropic API key and run OpenClaw onboard:"
6070
echo " export ANTHROPIC_API_KEY='your-key'"
61-
echo " export DISCORD_BOT_TOKEN='your-token'"
62-
echo ""
63-
echo "2. Run OpenClaw onboard:"
6471
echo " openclaw onboard --non-interactive --accept-risk \\"
6572
echo " --mode local \\"
6673
echo " --auth-choice apiKey \\"
@@ -70,15 +77,23 @@ echo " --gateway-bind loopback \\"
7077
echo " --install-daemon \\"
7178
echo " --daemon-runtime node"
7279
echo ""
73-
echo "3. Configure the workspace path in openclaw.json:"
74-
echo " openclaw config set agents.defaults.workspace ~/Code/merit-systems/CraigClaw"
80+
echo "2. Create ~/.openclaw/secrets.json with Discord + gateway tokens:"
81+
echo " See deploy/secrets.json.example for the format."
7582
echo ""
76-
echo "4. Add Discord channel:"
77-
echo " openclaw channels add --channel discord --token \"\$DISCORD_BOT_TOKEN\""
83+
echo "3. Place the GitHub App private key:"
84+
echo " scp github-app-key.pem ubuntu@<ip>:~/.config/craig/github-app-key.pem"
7885
echo ""
79-
echo "5. Install x402 (see Merit-Systems/OpenClawX402/x402.md)"
86+
echo "4. Set up the systemd override:"
87+
echo " mkdir -p ~/.config/systemd/user/openclaw-gateway.service.d"
88+
echo " cp ~/Code/merit-systems/CraigClaw/deploy/craig/github.conf \\"
89+
echo " ~/.config/systemd/user/openclaw-gateway.service.d/"
90+
echo " systemctl --user daemon-reload"
8091
echo ""
81-
echo "6. Restart the gateway:"
92+
echo "5. Render config and start:"
93+
echo " jq -s '.[0] * .[1]' ~/Code/merit-systems/CraigClaw/deploy/openclaw.json \\"
94+
echo " ~/.openclaw/secrets.json > ~/.openclaw/openclaw.json"
8295
echo " systemctl --user restart openclaw-gateway"
8396
echo ""
97+
echo "6. Install x402 (see Merit-Systems/OpenClawX402/x402.md)"
98+
echo ""
8499
echo "=== Setup complete ==="

0 commit comments

Comments
 (0)