Skip to content

Commit 9f16647

Browse files
joelhooksclaude
andcommitted
feat: auto-init store and auto-start daemon on install
- Install script now auto-initializes store if not exists - Auto-starts daemon in background after install - JSON output includes daemon_running status - Added daemon note to README Quick Start This makes agent-secrets install truly one-liner zero-config. Agents can immediately use `secrets add` after install. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 50a6ddf commit 9f16647

2 files changed

Lines changed: 53 additions & 12 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ secrets --help
5050
## Quick Start
5151

5252
```bash
53-
# Initialize encrypted store (creates ~/.agent-secrets/)
53+
# 1. Initialize store and start daemon (one-time setup)
5454
secrets init
55+
secrets serve & # Start daemon in background
5556

56-
# Add secrets
57+
# 2. Add secrets
5758
secrets add github_token --rotate-via "gh auth refresh"
5859
secrets add anthropic_key
5960
echo "sk-ant-..." | secrets add openai_key
6061

61-
# Get a lease (returns secret value, starts TTL timer)
62+
# 3. Get a lease (returns secret value, starts TTL timer)
6263
export GITHUB_TOKEN=$(secrets lease github_token --ttl 1h)
6364

6465
# View status
@@ -71,6 +72,8 @@ secrets audit --tail 20
7172
secrets revoke --all
7273
```
7374

75+
> **Note:** The daemon must be running for most commands to work. The install script auto-starts it, but if you see "daemon not running" errors, run `secrets serve &`.
76+
7477
## Architecture
7578

7679
```

install.sh

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,37 @@ check_path() {
172172
fi
173173
}
174174

175+
# Initialize store and start daemon
176+
setup_secrets() {
177+
local install_dir="$1"
178+
local binary="${install_dir}/${BINARY_NAME}"
179+
180+
# Initialize store if not already done
181+
if [[ ! -f "${HOME}/.agent-secrets/identity.age" ]]; then
182+
log_json "info" "Initializing secrets store"
183+
log_human "Initializing secrets store..."
184+
"$binary" init >/dev/null 2>&1 || true
185+
fi
186+
187+
# Start daemon if not running
188+
if ! "$binary" status >/dev/null 2>&1; then
189+
log_json "info" "Starting daemon"
190+
log_human "Starting daemon..."
191+
nohup "$binary" serve >/dev/null 2>&1 &
192+
sleep 1
193+
fi
194+
195+
# Verify daemon is running
196+
if "$binary" status >/dev/null 2>&1; then
197+
echo "true"
198+
else
199+
echo "false"
200+
fi
201+
}
202+
175203
# Main installation logic
176204
main() {
177-
local platform version_installed in_path
205+
local platform version_installed in_path daemon_running
178206

179207
platform=$(detect_platform)
180208
log_json "info" "Detected platform: $platform"
@@ -184,6 +212,9 @@ main() {
184212

185213
in_path=$(check_path "$INSTALL_DIR")
186214

215+
# Auto-setup: init store and start daemon
216+
daemon_running=$(setup_secrets "$INSTALL_DIR")
217+
187218
# Generate output
188219
if [[ "$OUTPUT_MODE" == "json" ]]; then
189220
# JSON output for agents
@@ -194,14 +225,11 @@ main() {
194225
"data": {
195226
"version": "${version_installed}",
196227
"path": "${INSTALL_DIR}/${BINARY_NAME}",
197-
"in_path": ${in_path}
228+
"in_path": ${in_path},
229+
"daemon_running": ${daemon_running},
230+
"store_path": "${HOME}/.agent-secrets"
198231
},
199232
"actions": [
200-
{
201-
"name": "init",
202-
"description": "Initialize secrets store",
203-
"command": "secrets init"
204-
},
205233
{
206234
"name": "add_secret",
207235
"description": "Add a secret",
@@ -211,6 +239,11 @@ main() {
211239
"name": "lease_secret",
212240
"description": "Get time-bounded lease",
213241
"command": "secrets lease <name> --ttl 1h"
242+
},
243+
{
244+
"name": "status",
245+
"description": "Check daemon status",
246+
"command": "secrets status"
214247
}
215248
$(if [[ "$in_path" == "false" ]]; then
216249
cat <<INNER
@@ -228,6 +261,11 @@ EOF
228261
# Human-readable output
229262
echo ""
230263
echo "✓ Installed agent-secrets ${version_installed} to ${INSTALL_DIR}/${BINARY_NAME}"
264+
if [[ "$daemon_running" == "true" ]]; then
265+
echo "✓ Daemon running"
266+
else
267+
echo "⚠ Daemon not running - start with: secrets serve &"
268+
fi
231269
echo ""
232270

233271
if [[ "$in_path" == "false" ]]; then
@@ -238,10 +276,10 @@ EOF
238276
echo ""
239277
fi
240278

241-
echo "Next steps:"
242-
echo " secrets init # Initialize encrypted store"
279+
echo "Ready to use:"
243280
echo " secrets add <name> # Add a secret"
244281
echo " secrets lease <name> # Get time-bounded lease"
282+
echo " secrets status # Check daemon status"
245283
echo ""
246284
echo "Run 'secrets --help' for more commands"
247285
fi

0 commit comments

Comments
 (0)