Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 34 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Taskmaster is built around one idea: progress is not completion.
Compliance prompts force the model back to the user’s actual request, not its
own local notion of “good enough”.
- Automation-safe signaling:
A deterministic done token makes completion parseable for wrappers and
CI-style flows.
A deterministic done token makes completion parseable for stop hooks and
external tooling.

## Core Contract

Expand All @@ -30,34 +30,31 @@ A run is complete only when the assistant emits:
TASKMASTER_DONE::<session_id>
```

If that token is missing at stop time, Taskmaster blocks stop and pushes the
current turn to continue. Codex monitoring stays active for later turns in the
same long-lived session.
### Codex Native Stop Contract

### Enforcement Prompt
The native Codex stop hook preserves the same completion signal as the original
Taskmaster:

Taskmaster uses one shared compliance prompt for both Codex and Claude.

- Codex: the wrapper/injector path injects this shared prompt back into the
same running session when stop conditions are not met.
- Claude: the Stop hook returns this same shared prompt as the block reason.

The shared prompt source lives in `taskmaster-compliance-prompt.sh`.
```text
TASKMASTER_DONE::<session_id>
```

## How It Works

- Codex path:
- Runs through a wrapper (`codex` shim / `codex-taskmaster` launcher).
- Enables Codex session logs.
- Watches `task_complete` / `turn_complete` events.
- If done token is missing, injects a continuation prompt into the same
running Codex process via expect PTY.
- A done token suppresses injection for that completed turn only; it does
not permanently disable Taskmaster for future turns in the same session.
- Installs native `SessionStart` and `Stop` hooks in `~/.codex/hooks.json`.
- Enables Codex hook support via `~/.codex/config.toml`.
- `SessionStart` injects a small durable completion contract into the session.
- The `Stop` hook reconstructs the active task from the transcript.
- If the latest assistant message already contains the done token, stop is
allowed immediately.
- Otherwise the `Stop` hook continues the same turn with the original rich
Taskmaster compliance prompt plus the reconstructed task anchor.
- Optional repo verification can be enforced with a shell command.
- Claude path:
- Registers a `Stop` command hook.
- Hook runs `check-completion.sh`.
- If done token is missing, the stop is blocked with corrective feedback.
- The hook runs `check-completion.sh`.
- If the done token is missing, the stop is blocked with corrective feedback.

## Install

Expand All @@ -82,8 +79,9 @@ TASKMASTER_INSTALL_TARGET=both bash ~/.codex/skills/taskmaster/install.sh
Installed artifacts:
- Codex:
- `~/.codex/skills/taskmaster/`
- `~/.codex/bin/codex-taskmaster`
- `~/.codex/bin/codex` (shim to Taskmaster wrapper)
- `~/.codex/config.toml` updated with `codex_hooks = true`
- `~/.codex/hooks.json` updated with Taskmaster `SessionStart` and `Stop`
hooks
- Claude:
- `~/.claude/skills/taskmaster/`
- `~/.claude/hooks/taskmaster-check-completion.sh`
Expand All @@ -93,31 +91,29 @@ Installed artifacts:

### Codex

Run normally:
Run Codex normally:

```bash
codex [args]
```

Explicit alias is also available:

```bash
codex-taskmaster [args]
```

Interactive resume is also supported:

```bash
codex resume [session-or-thread]
```
The Taskmaster hooks activate automatically on startup, resume, clear, and
stop.

### Claude

Run Claude normally after install. Taskmaster hook enforcement is automatic.

## Configuration

- `TASKMASTER_VERIFY_COMMAND`:
- Codex only.
- Runs a native verifier before stop is allowed after the done token is present.
- `TASKMASTER_VERIFY_MAX_OUTPUT` (default `4000`):
- Codex only.
- Truncates verifier output echoed back into a block reason.
- `TASKMASTER_MAX` (default `0`):
- Claude only.
- Limits stop-block warnings in hook checks.
- `0` means unlimited warnings.

Expand All @@ -142,12 +138,11 @@ TASKMASTER_UNINSTALL_TARGET=both bash ~/.codex/skills/taskmaster/uninstall.sh

- `bash`
- `jq`
- `python3`
- Codex integration:
- Codex CLI
- `expect`
- Codex CLI with native hooks support enabled
- Claude integration:
- Claude Code with `Stop` hooks enabled
- `python3` (for install/uninstall settings updates)

## License

Expand Down
47 changes: 22 additions & 25 deletions SKILL.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
---
name: taskmaster
description: |
Codex wrapper plus same-process expect PTY injector
that keeps work moving until an explicit parseable done signal is emitted.
Native Codex SessionStart/Stop hooks plus a Claude stop hook
that keep work moving until an explicit parseable done signal is emitted.
author: blader
version: 4.2.0
version: 5.0.0
---

# Taskmaster

Taskmaster for Codex uses session-log polling plus automatic continuation.
Codex TUI does not currently expose arbitrary writable stop hooks, so this
skill implements the same completion contract externally.
Taskmaster uses native hooks to enforce completion without a wrapper process.

## How It Works

1. **Run Codex via wrapper**: `run-taskmaster-codex.sh` sets
`CODEX_TUI_RECORD_SESSION=1` and a log path.
2. **Injector parses log events** and checks completion on each
`task_complete` event.
3. **Parseable token contract**:
`TASKMASTER_DONE::<session_id>`
4. **Token missing**:
- inject follow-up user message into the same running process via
expect PTY bridge transport, using the shared compliance prompt.
5. **Token present**: no further injection.
1. **Codex SessionStart hook** injects a compact completion contract when a
session starts, resumes, or clears.
2. **Codex Stop hook** reconstructs the active task from the transcript and
continues the same turn with the original compliance prompt when the done
token is missing.
3. **Completion contract**:
- `TASKMASTER_DONE::<session_id>` only when the goal is truly complete
4. **Optional verifier**:
- If `TASKMASTER_VERIFY_COMMAND` is set, stop remains blocked until that
command passes.
5. **Claude path** keeps the existing stop-hook enforcement based on the done
token plus the shared compliance prompt.

## Parseable Done Signal

Expand All @@ -39,20 +39,17 @@ This gives external automation a deterministic completion marker to parse.

## Configuration

- `TASKMASTER_MAX` (default `0`): max warning count before suppression in the
stop hook. `0` means unlimited warnings.

Fixed behavior (not configurable):
- Done token prefix: `TASKMASTER_DONE`
- Poll interval: `1` second
- Transport: expect only
- Expect payload mode and submit delay are fixed
- `TASKMASTER_VERIFY_COMMAND`: Codex only. Require a repo verification command
before stop is allowed.
- `TASKMASTER_VERIFY_MAX_OUTPUT` (default `4000`): Codex only. Limit verifier
output echoed back into the hook block reason.
- `TASKMASTER_MAX` (default `0`): Claude only. Limit repeated stop warnings.

## Setup

Install and run:

```bash
bash ~/.codex/skills/taskmaster/install.sh
codex-taskmaster
codex
```
117 changes: 72 additions & 45 deletions docs/SPEC.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Taskmaster
## Product & Technical Specification

**Version**: 4.2.0
**Version**: 5.0.0
**Scope**:
- `taskmaster/check-completion.sh`
- `taskmaster/taskmaster-compliance-prompt.sh`
- `taskmaster/hooks/inject-continue-codex.sh`
- `taskmaster/hooks/run-codex-expect-bridge.exp`
- `taskmaster/run-taskmaster-codex.sh`
- `taskmaster/hooks/taskmaster-session-start.sh`
- `taskmaster/hooks/taskmaster-stop.sh`
- `taskmaster/install.sh`
- `taskmaster/uninstall.sh`

## 1. Goal

Prevent premature agent stopping and provide a deterministic, machine-parseable
completion signal while remaining usable across long-lived Codex sessions.
completion signal while remaining usable across long-lived Codex and Claude
sessions.

Taskmaster enforces explicit completion through a done-token contract and
continuation/hook feedback when that contract is not satisfied.
hook-based feedback when that contract is not satisfied.

Both Codex and Claude paths consume the same shared compliance prompt text from
Both Codex and Claude paths consume shared prompt text from
`taskmaster-compliance-prompt.sh`.

## 2. Completion Contract
Expand All @@ -32,51 +32,52 @@ TASKMASTER_DONE::<session_id>

- `<session_id>` is session-scoped.
- The line must be emitted only when that turn's work is truly complete.
- Automation can parse this line as the authoritative completion marker for the
completed turn without disabling monitoring for later turns in the same
Codex process.

## 3. Architecture
### 2.1 Codex Native Stop Contract

### 3.1 Codex Wrapper Path
The Codex native-hook path preserves the same completion signal as the original
Taskmaster:

`run-taskmaster-codex.sh`:
```text
TASKMASTER_DONE::<session_id>
```

1. Resolves real Codex binary and enables session logging.
2. Starts queue-emitter injector (`hooks/inject-continue-codex.sh`).
3. Runs Codex in managed expect PTY (`hooks/run-codex-expect-bridge.exp`).
4. On incomplete turn (missing done token), injector emits continuation prompt
files and expect bridge injects them into the same running process.
5. On complete turn (done token present), injector skips injection for that
turn and keeps following the session log for subsequent turns.
6. Interactive `codex resume ...` launches stay on this managed path rather
than bypassing Taskmaster as a direct passthrough.
- The hook may continue the same turn when the token is missing.
- There is no mandatory visible self-check protocol in the supported design.

### 3.2 Claude Stop-Hook Path
## 3. Architecture

`check-completion.sh`:
### 3.1 Codex Native Hooks Path

1. Executes as Claude `Stop` hook command.
2. Verifies done token in session transcript.
3. If missing, returns a blocking decision with compliance instructions.
4. If present, allows stop.
`hooks/taskmaster-session-start.sh`:

### 3.3 Queue Emitter
1. Executes as a Codex `SessionStart` hook on `startup`, `resume`, and `clear`.
2. Emits a compact durable completion contract referencing the session-scoped
done token.

`hooks/inject-continue-codex.sh`:
`hooks/taskmaster-stop.sh`:

- Follows Codex session log.
- Handles `task_complete` / `turn_complete` events.
- Dedupe by turn-id/signature.
- Writes continuation payloads as `inject.*.txt` queue files.
1. Executes as a Codex `Stop` hook.
2. Reads `session_id`, `transcript_path`, `last_assistant_message`, and `cwd`
from hook input.
3. Reconstructs the active task by segmenting the transcript after the most
recent `TASKMASTER_DONE::<session_id>`.
4. If the latest assistant message already contains
`TASKMASTER_DONE::<session_id>`, the hook allows stop immediately.
5. Otherwise the hook blocks stop and continues Codex with:
- the reconstructed current-task anchor
- the original rich Taskmaster compliance prompt
6. Optionally runs `TASKMASTER_VERIFY_COMMAND` in the session working
directory. Stop stays blocked until that verifier succeeds.

### 3.4 Expect Bridge
### 3.2 Claude Stop-Hook Path

`hooks/run-codex-expect-bridge.exp`:
`check-completion.sh`:

- Polls queue files.
- Injects payload into the same Codex PTY via bracketed paste.
- Submits prompt with Enter after fixed short delay.
1. Executes as a Claude `Stop` hook command.
2. Verifies the done token in the latest assistant message or transcript.
3. If missing, returns a blocking decision with the shared compliance prompt.
4. If present, allows stop.

## 4. Installation Behavior

Expand All @@ -87,18 +88,44 @@ Override knobs:
- `TASKMASTER_INSTALL_TARGET=auto|codex|claude|both`
- `TASKMASTER_UNINSTALL_TARGET=auto|codex|claude|both`

### 4.1 Codex Install

Install updates:
- `~/.codex/skills/taskmaster/`
- `~/.codex/config.toml` to ensure `[features] codex_hooks = true`
- `~/.codex/hooks.json` to ensure Taskmaster `SessionStart` and `Stop` command
hooks are present

Install also removes legacy Taskmaster wrapper symlinks from:
- `~/.codex/bin/codex`
- `~/.codex/bin/codex-taskmaster`

### 4.2 Claude Install

Install updates:
- `~/.claude/skills/taskmaster/`
- `~/.claude/hooks/taskmaster-check-completion.sh`
- `~/.claude/settings.json` to ensure the stop hook is configured

## 5. Configuration

Configurable:
- `TASKMASTER_MAX` (default `0`): warning cap in stop-hook checks.
- `TASKMASTER_VERIFY_COMMAND`: Codex only. Require a shell verifier command
before stop is allowed.
- `TASKMASTER_VERIFY_MAX_OUTPUT` (default `4000`): Codex only. Limit verifier
output in hook block reasons.
- `TASKMASTER_MAX` (default `0`): Claude only. Warning cap in stop-hook checks.

Fixed:
- done token prefix: `TASKMASTER_DONE`
- poll interval: `1` second
- Codex transport: expect only
- expect payload mode + submit timing

## 6. Operational Notes

- Enforcement is same-process for Codex and stop-hook based for Claude.
- There is no standalone monitor-only mode in this design.
- Codex enforcement is entirely native-hook based. There is no wrapper or
expect bridge in the supported architecture.
- The stop hook segments tasks inside a long-lived Codex session using the most
recent done token as the boundary.
- If no prior done token exists, the stop hook falls back to the active user
instructions found in the transcript to infer the task anchor.
- Uninstall removes Taskmaster hook entries but preserves `codex_hooks = true`
so unrelated native-hook workflows are not broken.
Loading