Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
125 lines
3.3 KiB
Markdown
125 lines
3.3 KiB
Markdown
# Bash Agent Example
|
||
|
||
A bash script demonstrating how an AI agent can use bd to manage tasks autonomously.
|
||
|
||
## Features
|
||
|
||
- Pure bash implementation (no Python/Node required)
|
||
- Colorized terminal output
|
||
- Automatic work discovery
|
||
- Random issue creation to simulate real agent behavior
|
||
- Dependency linking with `discovered-from`
|
||
- Statistics display
|
||
|
||
## Prerequisites
|
||
|
||
- bash 4.0+
|
||
- bd installed: `curl -fsSL https://raw.githubusercontent.com/gastownhall/beads/main/scripts/install.sh | bash`
|
||
- jq for JSON parsing: `brew install jq` (macOS) or `apt install jq` (Linux)
|
||
- A beads database initialized: `bd init`
|
||
|
||
## Usage
|
||
|
||
```bash
|
||
# Make executable
|
||
chmod +x agent.sh
|
||
|
||
# Run with default 10 iterations
|
||
./agent.sh
|
||
|
||
# Run with custom iteration limit
|
||
./agent.sh 20
|
||
```
|
||
|
||
## What It Does
|
||
|
||
The agent runs in a loop:
|
||
|
||
1. Looks for ready work (no blockers)
|
||
2. Claims the task (sets status to `in_progress`)
|
||
3. "Works" on it (simulates 1 second of work)
|
||
4. 50% chance to discover a follow-up issue
|
||
5. If discovered, creates and links the new issue
|
||
6. Completes the original task
|
||
7. Shows statistics and repeats
|
||
|
||
## Example Output
|
||
|
||
```
|
||
๐ Beads Agent starting...
|
||
Max iterations: 10
|
||
|
||
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
||
Beads Statistics
|
||
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
||
Open: 5 In Progress: 0 Closed: 2
|
||
|
||
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
||
Iteration 1/10
|
||
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
||
โน Looking for ready work...
|
||
โน Claiming task: bd-3
|
||
โ Task claimed
|
||
โน Working on: Fix authentication bug (bd-3)
|
||
Priority: 1
|
||
โ Discovered issue while working!
|
||
โ Created issue: bd-8
|
||
โ Linked bd-8 โ discovered-from โ bd-3
|
||
โน Completing task: bd-3
|
||
โ Task completed: bd-3
|
||
```
|
||
|
||
## Use Cases
|
||
|
||
**Continuous Integration**
|
||
```bash
|
||
# Run agent in CI to process testing tasks
|
||
./agent.sh 5
|
||
```
|
||
|
||
**Cron Jobs**
|
||
```bash
|
||
# Run agent every hour
|
||
0 * * * * cd /path/to/project && /path/to/agent.sh 3
|
||
```
|
||
|
||
**One-off Task Processing**
|
||
```bash
|
||
# Process exactly one task and exit
|
||
./agent.sh 1
|
||
```
|
||
|
||
## Customization
|
||
|
||
Edit the script to customize behavior:
|
||
|
||
```bash
|
||
# Change discovery probability (line ~80)
|
||
if [[ $((RANDOM % 2)) -eq 0 ]]; then # 50% chance
|
||
# Change to:
|
||
if [[ $((RANDOM % 10)) -lt 3 ]]; then # 30% chance
|
||
|
||
# Add assignee filtering
|
||
bd ready --json --assignee "bot" --limit 1
|
||
|
||
# Add priority filtering
|
||
bd ready --json --priority 1 --limit 1
|
||
|
||
# Add custom labels
|
||
bd create "New task" -l "automated,agent-discovered"
|
||
```
|
||
|
||
## Integration with Real Agents
|
||
|
||
This script is a starting point. To integrate with a real LLM:
|
||
|
||
1. Replace `do_work()` with calls to your LLM API
|
||
2. Parse the LLM's response for tasks to create
|
||
3. Use issue IDs to maintain context
|
||
4. Track conversation state in issue metadata
|
||
|
||
## See Also
|
||
|
||
- [../python-agent/](../python-agent/) - Python version with more flexibility
|
||
- [../git-hooks/](../git-hooks/) - Automatic export/import on git operations
|