Commit Graph

207 Commits

Author SHA1 Message Date
Lauren ten Hoor
1464fa82d2 feat: enhance bootstrap hook with detailed logging and internal hook configuration 2026-02-16 15:43:53 +08:00
Lauren ten Hoor
6be920c31a Merge branch 'feat/195-rename-levels'
# Conflicts:
#	lib/bootstrap-hook.ts
2026-02-16 15:13:54 +08:00
Lauren ten Hoor
65a24bb0ea refactor: update loadRoleInstructions to prioritize new file layout 2026-02-16 15:08:22 +08:00
Lauren ten Hoor
d0d1bdda60 feat: enhance workspace scaffolding with new identity and soul templates, and support for default user file 2026-02-16 14:57:17 +08:00
Lauren ten Hoor
25ce06e14f feat: implement auto-merge for approved PRs and update workflow documentation 2026-02-16 14:34:08 +08:00
Lauren ten Hoor
f7aa47102f refactor: rename QA role to Tester and update related documentation
- Updated role references from "QA" to "Tester" in workflow and code comments.
- Revised documentation to reflect the new role structure, including role instructions and completion rules.
- Enhanced the testing guide with clearer instructions and examples for unit and E2E tests.
- Improved tools reference to align with the new role definitions and completion rules.
- Adjusted the roadmap to highlight recent changes in role configuration and workflow state machine.
2026-02-16 13:55:38 +08:00
Lauren ten Hoor
371e760d94 feat: enhance workflow and testing infrastructure
- Introduced ExecutionMode type for project execution modes (parallel, sequential).
- Updated SetupOpts to use ExecutionMode instead of string literals.
- Enhanced workflow states to include a new "In Review" state with appropriate transitions.
- Implemented TestHarness for end-to-end testing, including command interception and workspace setup.
- Created TestProvider for in-memory issue tracking during tests.
- Refactored project registration and setup tools to utilize ExecutionMode.
- Updated various tools to ensure compatibility with new workflow and execution modes.
- Added new dependencies: cockatiel for resilience and zod for schema validation.
2026-02-16 13:27:14 +08:00
Lauren ten Hoor
a359ffed34 feat(migration): implement workspace layout migration and testing
- Added `migrate-layout.ts` to handle migration from old workspace layouts to the new `devclaw/` structure.
- Introduced `migrate-layout.test.ts` for comprehensive tests covering various migration scenarios.
- Updated `workspace.ts` to ensure default files are created post-migration, including `workflow.yaml` and role-specific prompts.
- Refactored role instruction handling to accommodate new directory structure.
- Enhanced project registration to scaffold prompt files in the new `devclaw/projects/<project>/prompts/` directory.
- Adjusted setup tool descriptions and logic to reflect changes in file structure.
- Updated templates to align with the new workflow configuration and role instructions.
2026-02-15 20:19:09 +08:00
Lauren ten Hoor
89245f8ffa refactor: update task creation to use dynamic initial label from workflow config 2026-02-15 18:56:10 +08:00
Lauren ten Hoor
a85f4fd33e refactor: implement dynamic role and level handling with migration support 2026-02-15 18:46:00 +08:00
Lauren ten Hoor
0e24a68882 refactor: migrate role handling from tiers to roles module
- Removed the deprecated tiers.ts file and migrated all related functionality to roles/index.js.
- Updated tests and tools to reflect the new role structure, replacing references to "dev", "qa", and "architect" with "developer", "tester", and "architect".
- Adjusted workflow configurations and state management to accommodate the new role naming conventions.
- Enhanced project registration and health check tools to support dynamic role handling.
- Updated task creation, update, and completion processes to align with the new role definitions.
- Improved documentation and comments to clarify role responsibilities and usage.
2026-02-15 18:32:10 +08:00
Lauren ten Hoor
6a99752e5f refactor: standardize level names across all roles (#195 phase 1)
Rename levels to use consistent industry-standard terminology:
- dev: medior → mid
- qa: reviewer → mid, tester → junior, add senior level
- architect: opus → senior, sonnet → junior

Add backward-compatible migration for projects.json and openclaw.json
config via level aliases in selectors and projects parser.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 17:01:16 +08:00
Lauren ten Hoor
01ad5d326c fix: persist issue tracker provider type in projects.json (#193) (#194)
Problem: Provider type (github/gitlab) was auto-detected on every
createProvider() call but never persisted, causing loss of
configuration after session restart.

Solution:
- Add 'provider' field to Project type
- Store detected provider type during project registration
- Pass stored provider type to createProvider() calls

Changes:
- lib/projects.ts: Add provider field to Project type
- lib/tools/project-register.ts: Save providerType to projects.json
- lib/tool-helpers.ts: Pass project.provider to createProvider
- lib/services/*.ts: Pass project.provider to createProvider

Impact: Issue tracker source now persists across restarts. Existing
projects will auto-detect on next use and should be re-registered or
manually edited to add provider field.

Fixes #193
2026-02-14 18:36:40 +08:00
Lauren ten Hoor
c22c25bbe8 Merge pull request #192 from laurentenhoor/refactor/190-centralize-roles
refactor: Centralize role types and configuration
2026-02-14 17:16:14 +08:00
Lauren ten Hoor
be8e0f4db1 refactor: Centralize role types and configuration (#190)
Creates a single source of truth for all worker roles via lib/roles/.

## New: lib/roles/

- **registry.ts** — All role definitions (dev, qa, architect) with
  levels, models, emoji, completion results, session key patterns
- **types.ts** — RoleConfig interface
- **selectors.ts** — Query helpers: getRole(), getLevelsForRole(),
  resolveModel(), isValidResult(), roleForLevel(), etc.
- **index.ts** — Barrel exports

## Migrated Files

- **lib/tiers.ts** — Now delegates to registry (backward compat kept)
- **lib/dispatch.ts** — Uses registry for emoji resolution
- **lib/bootstrap-hook.ts** — Uses registry for session key pattern
- **lib/services/tick.ts** — Uses registry for level detection
- **lib/services/heartbeat.ts** — Uses registry for role iteration
- **lib/tools/health.ts** — Uses registry for role iteration
- **lib/tools/work-start.ts** — Uses registry for role enum
- **lib/tools/work-finish.ts** — Uses registry for result validation
- **lib/tools/project-register.ts** — Uses registry for level lists

## Key Benefits

- Adding a new role = add entry to registry.ts (single file)
- No more scattered role unions ("dev" | "qa" | "architect")
- Type-safe role/level/result validation from registry
- Session key pattern auto-generated from registry
- All 64 tests passing (22 new registry tests + 42 existing)
2026-02-14 17:15:54 +08:00
Lauren ten Hoor
a547127d19 Merge pull request #191 from laurentenhoor/feat/189-architect-role
feat: Implement Architect role & design_task tool
2026-02-14 17:08:41 +08:00
Lauren ten Hoor
57c78f3656 feat: Implement Architect role & design_task tool (#189)
Adds the Architect role for design/architecture investigations with
persistent sessions and structured design proposals.

## New Features

- **Architect role** with opus (complex) and sonnet (standard) levels
- **design_task tool** — Creates To Design issues and dispatches architect
- **Workflow states:** To Design → Designing → Planning
- **Completion rules:** architect:done → Planning, architect:blocked → Refining
- **Auto-level selection** based on complexity keywords

## Files Changed (22 files, 546 additions)

### New Files
- lib/tools/design-task.ts — design_task tool implementation
- lib/tools/design-task.test.ts — 16 tests for architect functionality

### Core Changes
- lib/tiers.ts — ARCHITECT_LEVELS, WorkerRole type, models, emoji
- lib/workflow.ts — toDesign/designing states, completion rules
- lib/projects.ts — architect WorkerState on Project type
- lib/dispatch.ts — architect role support in dispatch pipeline
- lib/services/pipeline.ts — architect completion rules
- lib/model-selector.ts — architect level selection heuristic

### Integration
- index.ts — Register design_task tool, architect config schema
- lib/notify.ts — architect role in notifications
- lib/bootstrap-hook.ts — architect session key parsing
- lib/services/tick.ts — architect in queue processing
- lib/services/heartbeat.ts — architect in health checks
- lib/tools/health.ts — architect in health scans
- lib/tools/status.ts — architect in status dashboard
- lib/tools/work-start.ts — architect role option
- lib/tools/work-finish.ts — architect validation
- lib/tools/project-register.ts — architect labels + role scaffolding
- lib/templates.ts — architect instructions + AGENTS.md updates
- lib/setup/workspace.ts — architect role file scaffolding
- lib/setup/smart-model-selector.ts — architect in model assignment
- lib/setup/llm-model-selector.ts — architect in LLM prompt
2026-02-14 17:08:17 +08:00
Lauren ten Hoor
310230772b chore: bump version to 1.2.2
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 14:28:14 +08:00
Lauren ten Hoor
1f8e7ae5bc Merge pull request #184 from laurentenhoor/feat/183-bootstrap-hook
feat: Implement bootstrap hook for role instruction injection
2026-02-14 14:13:35 +08:00
Lauren ten Hoor
9270d5aa97 feat: Implement bootstrap hook for role instruction injection (#183)
Replaces the file-read-network pattern in dispatch.ts with an OpenClaw
agent:bootstrap hook that injects role instructions at agent init time.

Changes:
- Add lib/bootstrap-hook.ts with hook registration, session key parsing,
  and role instruction loading (extracted from dispatch.ts)
- Register agent:bootstrap hook in index.ts
- Remove file I/O from dispatch.ts (no more fs/path imports)
- Remove role instructions from task message body (now injected via
  system prompt as WORKER_INSTRUCTIONS.md)
- Add 13 tests for session key parsing and instruction loading
- Remove obsolete docs/poc-bootstrap-hook.ts

The bootstrap hook intercepts DevClaw worker session startup, parses
the session key to extract project name and role, loads the appropriate
instructions from workspace, and injects them as a virtual bootstrap
file that OpenClaw automatically includes in the agent's system prompt.

This eliminates the security audit's potential-exfiltration warning
since dispatch.ts no longer performs any file reads.
2026-02-14 14:13:10 +08:00
Lauren ten Hoor
2893ba0507 research: document bootstrap hooks for context injection (#181)
Comprehensive investigation of OpenClaw-native alternatives to the
file-read-network pattern in dispatch.ts that triggers security audits.

Key Findings:
- Bootstrap hooks are the recommended solution
- Purpose-built for dynamic workspace file injection
- Plugin-only implementation (no core changes needed)
- Eliminates audit false positive

Deliverables:
- Full research document with pros/cons analysis
- PoC code demonstrating implementation approach
- Migration checklist and testing plan
- Decision matrix comparing alternatives

Recommendation: Implement agent:bootstrap hook to inject role
instructions at system prompt construction time instead of appending
to task message payload.

Addresses issue #181
2026-02-14 14:03:14 +08:00
Lauren ten Hoor
0f18568182 chore: bump version to 1.2.1
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 14:00:42 +08:00
Lauren ten Hoor
de449b5b25 Merge pull request #180 from laurentenhoor/fix/179-security-audit-comment
chore: Add clarifying comment for security audit false positive in dispatch.ts
2026-02-14 13:54:12 +08:00
Lauren ten Hoor
0b47b73a66 chore: Add clarifying comment for security audit false positive in dispatch.ts
Addresses issue #179. Adds JSDoc comment to loadRoleInstructions() explaining:
- Purpose: Load role-specific instruction files from workspace
- Intent: Intentionally included in task message context for workers
- Safety: Not data exfiltration, just standard task dispatch context

This clarifies the security audit finding and prevents future false positives.
2026-02-14 13:53:59 +08:00
Lauren ten Hoor
e0b374ce46 chore: bump version to 1.2.0 2026-02-13 21:13:48 +08:00
Lauren ten Hoor
64138b04bf docs: remove outdated scheduler tick references from AGENTS.md template (#177) (#178) 2026-02-13 21:04:16 +08:00
Lauren ten Hoor
be3095bbe9 docs: remove outdated auto-tick references from README.md (#174) (#176) 2026-02-13 20:57:28 +08:00
Lauren ten Hoor
cfd7ea9237 fix: update heartbeat.ts type signatures to accept SessionLookup | null (#169) (#175) 2026-02-13 20:49:20 +08:00
Lauren ten Hoor
abbf05777c fix: refactor queue.ts to use workflow config instead of hardcoded labels (#162) (#173)
## Problem

lib/services/queue.ts was not updated during workflow refactor (#147) and still
used hardcoded queue labels: QueueLabel type, QUEUE_PRIORITY constant.

## Solution

- Add getQueueLabelsWithPriority() to derive queue labels from workflow config
- Add getQueuePriority() to get priority for any label
- Update getTaskPriority() and getRoleForLabel() to accept workflow config
- Update fetchProjectQueues() to use workflow-derived labels
- Add getTotalQueuedCount() helper

## Files Changed

- lib/services/queue.ts — use workflow config for all queue operations
- lib/tools/status.ts — handle dynamic queue labels, include queueLabels in response

## Backward Compatibility

- QueueLabel type kept as deprecated alias
- QUEUE_PRIORITY kept as deprecated constant
- All functions accept optional workflow parameter, default to DEFAULT_WORKFLOW
2026-02-13 20:46:25 +08:00
Lauren ten Hoor
f6ea35324c Merge pull request #172 from laurentenhoor/docs/159-work-finish-auto-tick
docs: remove outdated auto-tick references from work_finish (#159)
2026-02-13 20:43:47 +08:00
Lauren ten Hoor
74db08abc5 docs: remove outdated auto-tick references from work_finish (#159) 2026-02-13 20:43:06 +08:00
Lauren ten Hoor
bdcc1b13de Merge pull request #171 from laurentenhoor/feat/170-orphaned-label-scan
feat: health check scans for orphaned Doing/Testing labels (#170)
2026-02-13 20:31:13 +08:00
Lauren ten Hoor
bf75db88c0 feat: health check scans for orphaned Doing/Testing labels (#170) 2026-02-13 20:30:28 +08:00
Lauren ten Hoor
70714388e8 fix: strip non-JSON prefix from gateway status output (#165) 2026-02-13 20:14:55 +08:00
Lauren ten Hoor
3440a3c187 fix: null safety for sessions in health tool (#165) 2026-02-13 19:51:52 +08:00
Lauren ten Hoor
8778f54f9a Merge pull request #168 from laurentenhoor/chore/167-remove-test-comment
chore: remove test comment from README.md (#167)
2026-02-13 19:45:30 +08:00
Lauren ten Hoor
45fd983c44 chore: remove test comment from README.md (#167) 2026-02-13 19:45:09 +08:00
Lauren ten Hoor
0606c9d970 Merge pull request #166 from laurentenhoor/fix/165-health-check-gateway-timeout
fix: health check skips session liveness checks when gateway unavailable (#165)
2026-02-13 19:41:22 +08:00
Lauren ten Hoor
8b5cfedb01 fix: health check skips session liveness checks when gateway unavailable (#165) 2026-02-13 19:40:43 +08:00
Lauren ten Hoor
19a2cb3bfc Merge pull request #164 from laurentenhoor/test/163-readme-comment
test: add comment to README.md (#163)
2026-02-13 19:30:15 +08:00
Lauren ten Hoor
c61060aff5 test: add comment to README.md (#163) 2026-02-13 19:29:50 +08:00
Lauren ten Hoor
dfeadf742a feat: make workflow states dynamic with XState-style statechart config (#147) (#160)
## Summary

Introduces a configurable workflow state machine that replaces all hardcoded
state labels. The default workflow matches current behavior exactly, ensuring
backward compatibility.

## Architecture

### lib/workflow.ts — Core workflow engine

XState-style statechart configuration:

```typescript
type StateConfig = {
  type: 'queue' | 'active' | 'hold' | 'terminal';
  role?: 'dev' | 'qa';
  label: string;
  color: string;
  priority?: number;
  on?: Record<string, TransitionTarget>;
};
```

All behavior is derived from the config:
- Queue states: `type: 'queue'`, grouped by role, ordered by priority
- Active states: `type: 'active'` — worker occupied
- Transitions: defined with optional actions (gitPull, detectPr, closeIssue, reopenIssue)
- Labels and colors: derived from state.label and state.color

### Derivation functions

- `getStateLabels()` — all labels for issue tracker sync
- `getLabelColors()` — label → color mapping
- `getQueueLabels(role)` — queue labels for a role, ordered by priority
- `getActiveLabel(role)` — the active/in-progress label for a role
- `getRevertLabel(role)` — queue label to revert to on failure
- `detectRoleFromLabel()` — detect role from a queue label
- `getCompletionRule(role, result)` — derive transition rule from config

## Files Changed

- **lib/workflow.ts** — NEW: workflow engine and default config
- **lib/providers/provider.ts** — deprecate STATE_LABELS, LABEL_COLORS; derive from workflow
- **lib/providers/github.ts** — use workflow config for label operations
- **lib/providers/gitlab.ts** — use workflow config for label operations
- **lib/services/pipeline.ts** — use getCompletionRule() from workflow
- **lib/services/tick.ts** — use workflow for queue/active labels
- **lib/services/health.ts** — use workflow for active/revert labels
- **lib/tools/work-start.ts** — use workflow for target label

## Backward Compatibility

- DEFAULT_WORKFLOW matches current hardcoded behavior exactly
- Deprecated exports kept for any external consumers
- No breaking changes to tool interfaces or project state

## Future Work

- Load per-project workflow overrides from projects.json
- User-facing config in projects/workflow.json
- Tool schema generation from workflow states
2026-02-13 18:50:09 +08:00
Lauren ten Hoor
24235cdbf7 Merge pull request #157 from laurentenhoor/fix/156-remove-chained-dispatch
fix: remove chained dispatch from work_finish - heartbeat only pickup path (#156)
2026-02-13 17:51:32 +08:00
Lauren ten Hoor
9dc5c66ce9 fix: remove chained dispatch from work_finish - heartbeat only pickup path (#156) 2026-02-13 17:50:50 +08:00
Lauren ten Hoor
c5c5e29e8f Merge pull request #155 from laurentenhoor/fix/138-orchestrator-issue-urls
fix: strengthen AGENTS.md to always include issue URLs in responses (#138)
2026-02-13 17:39:07 +08:00
Lauren ten Hoor
f2ccbe8bc8 fix: strengthen AGENTS.md to always include issue URLs in responses (#138) 2026-02-13 17:38:42 +08:00
Lauren ten Hoor
84d948ee68 fix: dispatch timeout causing missed Telegram notifications (#153) (#154)
## Problem

`dispatchTask()` shells out to `openclaw gateway call sessions.patch` which
times out when the gateway is busy, causing:
1. Notifications never fire (they're at the end of dispatchTask)
2. Worker state may not be recorded
3. Workers run silently

## Solution (3 changes)

### 1. Make `ensureSession` fire-and-forget
Session key is deterministic, so we don't need to wait for confirmation.
Health check catches orphaned state later.

### 2. Use runtime API for notifications instead of CLI
Pass `runtime` through opts and use direct API calls:
- `runtime.channel.telegram.sendMessageTelegram()`
- `runtime.channel.whatsapp.sendMessageWhatsApp()`
- etc.

### 3. Move notification before session dispatch
Fire workerStart/workerComplete notifications early (after label transition)
before the session calls that can timeout.

## Files Changed

- lib/dispatch.ts — fire-and-forget ensureSession, early notification, accept runtime
- lib/notify.ts — use runtime API for direct channel sends
- lib/services/pipeline.ts — early notification, accept runtime
- lib/services/tick.ts — pass runtime through to dispatchTask
- lib/tool-helpers.ts — accept runtime in tickAndNotify
- lib/tools/work-start.ts — pass api.runtime to dispatchTask
- lib/tools/work-finish.ts — pass api.runtime to executeCompletion/tickAndNotify
2026-02-13 17:29:32 +08:00
Lauren ten Hoor
24b35b3a3e fix: dispatch timeout causing missed Telegram notifications (#153) (#154)
## Problem

`dispatchTask()` shells out to `openclaw gateway call sessions.patch` which
times out when the gateway is busy, causing:
1. Notifications never fire (they're at the end of dispatchTask)
2. Worker state may not be recorded
3. Workers run silently

## Solution (3 changes)

### 1. Make `ensureSession` fire-and-forget
Session key is deterministic, so we don't need to wait for confirmation.
Health check catches orphaned state later.

### 2. Use runtime API for notifications instead of CLI
Pass `runtime` through opts and use direct API calls:
- `runtime.channel.telegram.sendMessageTelegram()`
- `runtime.channel.whatsapp.sendMessageWhatsApp()`
- etc.

### 3. Move notification before session dispatch
Fire workerStart/workerComplete notifications early (after label transition)
before the session calls that can timeout.

## Files Changed

- lib/dispatch.ts — fire-and-forget ensureSession, early notification, accept runtime
- lib/notify.ts — use runtime API for direct channel sends
- lib/services/pipeline.ts — early notification, accept runtime
- lib/services/tick.ts — pass runtime through to dispatchTask
- lib/tool-helpers.ts — accept runtime in tickAndNotify
- lib/tools/work-start.ts — pass api.runtime to dispatchTask
- lib/tools/work-finish.ts — pass api.runtime to executeCompletion/tickAndNotify
2026-02-13 17:29:25 +08:00
Lauren ten Hoor
d1106fc0bb Merge pull request #152 from laurentenhoor/fix/142-blocked-dispatch-loop
fix: blocked issues now go to Refining to prevent infinite dispatch loop (#142)
2026-02-13 17:12:57 +08:00
Lauren ten Hoor
130c38a314 fix: blocked issues now go to Refining to prevent infinite dispatch loop (#142) 2026-02-13 17:12:29 +08:00