Commit Graph

168 Commits

Author SHA1 Message Date
Steve Yegge
7c723f251c docs(harness): document harness concept comprehensively
Add docs/harness.md covering:
- What a harness (installation directory) is
- Directory structure with mayor/ config files
- Town-level vs rig-level mayor presence
- Beads architecture and resolution via BEADS_DIR
- Relationship between harness and rigs
- Example configurations and setup workflow

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 12:07:19 -08:00
Steve Yegge
95ba8fcb6b fix(tmux): add debounce to SendKeys to prevent Enter racing paste
When sending keys via tmux send-keys, there is a race condition where the
Enter key can be processed before the pasted text completes. This causes
messages to appear in the prompt but not be submitted.

- Add SendKeysDebounced method with configurable delay between paste and Enter
- Update SendKeys to use 100ms default debounce
- Update Inject to scale debounce based on message size (100ms + 50ms/KB)

Fixes beads-62h
2025-12-19 01:57:02 -08:00
Steve Yegge
4b1be156e7 Merge polecat/Corpus: handoffs using pinned beads (gt-cu7r)
Resolved conflict in handoff.go by keeping pinned bead implementation.
2025-12-19 01:55:53 -08:00
Steve Yegge
e993ba1aca Merge polecat/Bullet: ephemeral polecat model (gt-7ik)
Resolved conflict in spawn.go by keeping --polecat flag feature.
2025-12-19 01:55:21 -08:00
Steve Yegge
f5601471a5 Merge polecat/Flamer: real beads DB for town-level (gt-jpt) 2025-12-19 01:54:42 -08:00
Steve Yegge
690e8dfd81 Merge polecat/Scabrous: polecat done/reset commands (gt-s3m0) 2025-12-19 01:54:40 -08:00
Steve Yegge
7d206c3efc Merge polecat/Immortan: spawn --polecat flag (gt-selw) 2025-12-19 01:54:33 -08:00
Steve Yegge
cbd30e76a2 Merge polecat/Buzzard: mq integration create (gt-h5n.4) 2025-12-19 01:54:30 -08:00
Steve Yegge
4edacde590 Implement handoffs using pinned beads (gt-cu7r)
Replace mail-based handoff system with pinned beads that persist
across sessions. This fixes the issue where handoff messages get
closed before successors can read them.

Changes:
- beads: Add StatusPinned constant and handoff functions:
  - HandoffBeadTitle() for well-known naming
  - FindHandoffBead() to locate role handoff bead
  - GetOrCreateHandoffBead() to ensure bead exists
  - UpdateHandoffContent() to set handoff message
  - ClearHandoffContent() to reset after reading

- cmd/handoff: Update to use pinned beads instead of mail
  - sendHandoffMail() now updates pinned bead content

- cmd/prime: Display handoff content on startup
  - outputHandoffContent() reads and shows handoff bead

- cmd/rig: Add reset command with --handoff flag
  - gt rig reset --handoff clears handoff content

Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 01:51:14 -08:00
Steve Yegge
231d6e92e0 feat: implement ephemeral polecat model
This implements the ephemeral polecat model where polecats are spawned
fresh for each task and deleted upon completion.

Key changes:

**Spawn (internal/cmd/spawn.go):**
- Always create fresh worktree from main branch
- Run bd init in new worktree to initialize beads
- Remove --create flag (now implicit)
- Replace stale polecats with fresh worktrees

**Handoff (internal/cmd/handoff.go):**
- Add rig/polecat detection from environment and tmux session
- Send shutdown requests to correct witness (rig/witness)
- Include polecat name in lifecycle request body

**Witness (internal/witness/manager.go):**
- Add mail checking in monitoring loop
- Process LIFECYCLE shutdown requests
- Implement full cleanup sequence:
  - Kill tmux session
  - Remove git worktree
  - Delete polecat branch

**Polecat state machine (internal/polecat/types.go):**
- Primary states: working, done, stuck
- Deprecate idle/active (kept for backward compatibility)
- New polecats start in working state
- ClearIssue transitions to done (not idle)

**Polecat commands (internal/cmd/polecat.go):**
- Update list to show "Active Polecats"
- Normalize legacy states for display
- Add deprecation warnings to wake/sleep commands

Closes gt-7ik

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 01:48:59 -08:00
Steve Yegge
ba8abf8463 fix(install): use real beads DB instead of redirect file
Changes:
- Remove creation of mayor/mail/ directory with legacy JSONL inbox
- Initialize town-level beads DB (gm- prefix) via `bd init` instead of
  creating a .beads/redirect placeholder file
- Update help text and next-steps output to reflect new architecture

Town beads (gm-*) store mayor mail, cross-rig coordination, and handoffs.
Rig beads remain separate with their own prefixes.

Closes: gt-jpt

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 01:47:48 -08:00
Steve Yegge
231e7a422e Add --polecat flag to gt spawn command
The spawn command now accepts --polecat and --rig flags as an
alternative to the positional rig/polecat argument. When using
--polecat without --rig, the rig is inferred from the current
working directory.

Examples:
  gt spawn --issue gt-xyz --polecat Angharad
  gt spawn --issue gt-abc --rig gastown --polecat Toast

Fixes gt-selw

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 01:46:23 -08:00
Steve Yegge
50cdd638cb feat(mq): add gt mq integration create command
Implement 'gt mq integration create <epic>' command to create integration
branches for batch work on epics. The command:

1. Verifies the epic exists in beads
2. Creates branch integration/<epic-id> from origin/main
3. Pushes the branch to origin
4. Stores integration branch info in the epic's metadata

Also adds helper methods to git package:
- CreateBranchFrom: create branch from specific ref
- BranchExists: check if local branch exists
- RemoteBranchExists: check if branch exists on remote

Future MRs for the epic's children can target the integration branch
with: gt mq submit --epic <epic-id>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 01:46:04 -08:00
Steve Yegge
aa3c1d41ef Add done/finish and reset commands for polecat state management
Adds two new commands to transition polecats back to idle state:

- gt polecat done (alias: finish): Transitions from working/done/stuck
  states to idle, clearing the assigned issue. For normal workflow when
  work is complete but session was not properly cleaned up.

- gt polecat reset: Force resets any state to idle. For recovery when
  polecat is stuck in an unexpected state.

Both commands check that the session is stopped before modifying state.

Fixes gt-s3m0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 01:45:56 -08:00
Steve Yegge
007acf8f01 feat(beads): add molecule instantiation for workflow templates
Implement ParseMoleculeSteps() and InstantiateMolecule() for creating
child beads from molecule templates. Molecules are composable workflow
patterns that define steps with dependencies.

Key features:
- Parse `## Step: <ref>` sections from molecule descriptions
- Extract `Needs:` dependencies and `Tier:` hints
- Support `{{variable}}` template parameterization
- Create child issues atomically with proper parent/dependency wiring
- Validate molecules for duplicate refs, unknown deps, self-deps

Closes: gt-4nn.2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 01:45:06 -08:00
Steve Yegge
717bc89132 Merge remote-tracking branch 'origin/polecat/Buzzard' 2025-12-19 01:30:57 -08:00
Steve Yegge
37de0c5330 Merge remote-tracking branch 'origin/polecat/Immortan' 2025-12-19 01:30:55 -08:00
Steve Yegge
b47da4baae Merge remote-tracking branch 'origin/polecat/Angharad' 2025-12-19 01:30:54 -08:00
Steve Yegge
e20778fc1e Merge remote-tracking branch 'origin/polecat/Warboy' 2025-12-19 01:30:52 -08:00
Steve Yegge
5493180920 Merge remote-tracking branch 'origin/polecat/Bullet' 2025-12-19 01:30:41 -08:00
Steve Yegge
dfae2a9401 Merge remote-tracking branch 'origin/polecat/Scabrous' 2025-12-19 01:30:40 -08:00
Steve Yegge
19a36d7744 Merge remote-tracking branch 'origin/polecat/Rictus' 2025-12-19 01:30:38 -08:00
Steve Yegge
82e10e4ef2 fix: create role-specific CLAUDE.md for crew/refinery/mayor on rig add
When gt rig add creates workspaces by cloning a repository, the cloned
repos CLAUDE.md would be inherited, causing crew workers to show refinery
context. Now explicitly create role-appropriate CLAUDE.md files after each
clone to ensure correct agent prompting.

Fixes gt-vdp0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 00:36:35 -08:00
Steve Yegge
9bf2e91dea feat(witness): add gt witness start/stop/status commands
Add the witness monitoring agent command with start, stop, and status
subcommands. The witness monitors polecats for stuck/idle states and
can nudge blocked workers.

Closes gt-kcee

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 00:30:15 -08:00
Steve Yegge
1907eea102 fix(spawn): auto-add polecat when --create flag is set
When using `gt spawn rig --create` and no polecats exist (or all are
busy), the command now automatically generates a Mad Max themed polecat
name and creates it, rather than failing with "no available polecats".

This improves agent UX by making the --create flag work intuitively.

Fixes: gt-szsq

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 00:29:57 -08:00
Steve Yegge
dc876d1783 fix(refinery): start command now spawns tmux session
The refinery start command was only updating state.json without
actually starting a session. Now it spawns a tmux session named
gt-{rig}-refinery that runs the refinery in foreground mode.

Also updated Stop() and Status() to properly check tmux session
state alongside the PID-based tracking for backwards compatibility.

Fixes: gt-17zr

🤝 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 00:29:50 -08:00
Steve Yegge
3f924234ad feat(config): add merge_queue section to rig config schema
Add MergeQueueConfig struct and RigConfig type with:
- All merge queue settings (enabled, target_branch, on_conflict, etc.)
- Default values via DefaultMergeQueueConfig()
- Validation for on_conflict strategy and poll_interval duration
- Load/Save/Validate functions following existing config patterns
- Comprehensive tests for round-trip, custom config, and validation

Implements gt-h5n.8.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 00:29:40 -08:00
Steve Yegge
67c952290a feat(session): add positional line count to capture command
'gt session capture rig/polecat 50' now works in addition to
'gt session capture rig/polecat -n 50'. Agent UX: commands should
work the way agents guess they work.

Closes: gt-d7i

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 00:28:21 -08:00
Steve Yegge
e799fe5491 fix: normalize mayor identity to 'mayor/' for mail routing
The addressToIdentity function was stripping the trailing slash from
'mayor/' addresses, causing a mismatch with beads messages that have
assignee 'mayor/'. This fix ensures mayor addresses always use 'mayor/'
for consistent mail routing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 23:30:24 -08:00
Steve Yegge
2edf2358dd fix: session start timing and MR type issues
- Add 200ms delay after NewSession before sending keys to fix race
  condition where shell is not ready (mayor.go, crew.go)
- Use merge-request type instead of task for gt mq submit (mq.go)

Fixes gt-tulx

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 22:17:13 -08:00
Steve Yegge
5f92183843 fix(mail): add crew worker detection in detectSender()
detectSender() only detected polecats, not crew workers. Crew workers
like Emma at /Users/stevey/gt/beads/crew/emma were incorrectly
defaulting to mayor/ instead of getting their proper address.

Added /crew/ directory pattern matching parallel to the existing
/polecats/ detection, extracting rig/crewName address format.

Fixes: gt-70b3

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 21:55:49 -08:00
Steve Yegge
ce6fecbc57 bd sync: 2025-12-18 21:41:14 2025-12-18 21:41:14 -08:00
Steve Yegge
4fb0d55975 bd sync: 2025-12-18 21:32:17 2025-12-18 21:32:17 -08:00
Steve Yegge
1229b98bdf fix(tmux): add debounce delay between paste and Enter
Fixes race condition where Enter key arrives before paste is fully
processed, causing workers to sit idle at prompts.

- SendKeys now uses 100ms default debounce
- New SendKeysDebounced allows configurable delay
- Inject scales delay 100-500ms based on message size

Closes: gt-w3bu

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 21:08:23 -08:00
Steve Yegge
bc8e7e66ea Merge polecat/Coma: gt mq status + Engineer main loop 2025-12-18 20:49:46 -08:00
Steve Yegge
4685308393 bd sync: close gt-svi.3, gt-3x1.1 2025-12-18 20:44:50 -08:00
Steve Yegge
c1954b3431 fix(crew): use strings.Split instead of filepath.SplitList for path parsing
filepath.SplitList is for PATH-like env vars (colon/semicolon separated),
not for splitting file paths. This caused inferRigFromCwd to always fail
since SplitList returns the whole path as one element, making the fallback
logic never trigger.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:42:03 -08:00
Steve Yegge
eb0ac8e384 feat(mq): implement gt mq submit command
Adds the merge queue submit command for workers to submit completed
work to the merge queue. The command creates a merge-request bead
that the Engineer will process.

Features:
- Auto-detects branch, issue, worker, and rig from current context
- Parses polecat/<worker>/<issue> branch naming convention
- Supports explicit --branch, --issue, --epic, --priority flags
- Inherits priority from source issue by default
- Creates merge-request bead with structured MR fields

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:33:42 -08:00
Steve Yegge
6b7ed2de83 Merge polecat/Valkyrie: keepalive signal from gt commands
Adds keepalive.Touch() to signal agent activity during commands.
Also ignores state.json in .gitignore.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:28:34 -08:00
Steve Yegge
93b57b9acb chore: ignore state.json in .gitignore
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:25:44 -08:00
Steve Yegge
62bd8739d6 feat: keepalive signal from gt commands
Every gt command now touches .gastown/keepalive.json with the last
command and timestamp. This enables smarter daemon backoff:
- Fresh (< 2 min): agent is working, skip heartbeat
- Stale (2-5 min): might be thinking, gentle poke
- Very stale (> 5 min): likely idle, safe to interrupt

Uses PersistentPreRun hook to capture all commands including subcommands.

Closes gt-bfd

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:24:51 -08:00
Steve Yegge
e831b2cb1f Merge polecat/Razor: tmux notifications and merge execution
Adds:
- gt mail send now triggers tmux notification for recipients
- Merge execution with config and retry logic

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:24:27 -08:00
Steve Yegge
7fc16ef752 Merge polecat/Keeper: mail message types and threading support
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:23:50 -08:00
Steve Yegge
784c0582b5 Merge polecat/Ace: mq list + mq reject commands
Combined with Dag's mq retry from previous merge.
Full MQ CLI now includes: list, retry, reject subcommands.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:23:26 -08:00
Steve Yegge
5da8497a7e Merge polecat/Dag: mq retry + fetch/conflict check 2025-12-18 20:19:03 -08:00
Steve Yegge
884045f031 beads: sync closed issues from workers 2025-12-18 20:18:46 -08:00
Steve Yegge
999abe672c feat: add FetchBranch and CheckConflicts for merge queue
Add git helper functions for merge request conflict checking:
- FetchBranch(remote, branch): fetch a specific branch from remote
- CheckConflicts(source, target): test merge to detect conflicts
- Returns list of conflicting files without modifying working directory
- runMergeCheck helper to capture stdout (where CONFLICT appears)

Tests cover clean merges, conflicting merges, and working dir cleanup.

Closes gt-3x1.2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:17:42 -08:00
Steve Yegge
f032dd8c19 feat(refinery): implement merge execution with config and retry logic
Implements gt-3x1.3: Merge execution (merge, test, push)

Changes:
- Add MergeConfig struct with run_tests, test_command, delete_merged_branches,
  push_retry_count, and push_retry_delay_ms configuration options
- Add DefaultMergeConfig() with sensible defaults (tests enabled, go test ./...,
  branch cleanup, 3 retries with 1s base delay)
- Update ProcessMR to use MergeConfig for all settings
- Add pushWithRetry() with exponential backoff for transient failures
- Add gitOutput() helper to get command stdout (for merge commit SHA)
- Return merge commit SHA in MergeResult on success
- Conditional branch deletion based on config.DeleteMergedBranches

Configuration (in .gastown/config.json):
{
  "merge_queue": {
    "run_tests": true,
    "test_command": "go test ./...",
    "delete_merged_branches": true,
    "push_retry_count": 3,
    "push_retry_delay_ms": 1000
  }
}

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:17:35 -08:00
Steve Yegge
14abb8dfae Pivot molecules from YAML schema to Beads-native prose
- Closed gt-4nn.1 (YAML schema): molecules should be Beads issues
- Updated gt-4nn epic: type=molecule, prose-based step definitions
- Updated subtasks for transaction-based instantiation

AI agents parse prose natively - no rigid schemas needed.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:16:34 -08:00
Steve Yegge
dea935f647 feat: implement gt mq list command for merge queue display
- Add gt mq list <rig> command with table output
- Support --ready flag to show only unblocked MRs
- Support --status, --worker, --epic filtering
- Support --json output format
- Parse MR fields from beads issues for display
- Show blocking info for blocked MRs

Closes gt-svi.2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 20:16:10 -08:00