@agentuity/claude-code 2.0.10 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +16 -6
- package/AGENTS.md +48 -60
- package/README.md +51 -126
- package/dist/install.d.ts +2 -2
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +4 -4
- package/dist/install.js.map +1 -1
- package/hooks/hooks.json +2 -56
- package/hooks/session-start.sh +43 -0
- package/package.json +12 -8
- package/skills/agentuity-backend/SKILL.md +181 -378
- package/skills/agentuity-cloud/SKILL.md +34 -75
- package/skills/agentuity-frontend/SKILL.md +79 -218
- package/skills/agentuity-ops/SKILL.md +72 -180
- package/skills/agentuity-project/SKILL.md +507 -0
- package/src/install.ts +4 -6
- package/agents/architect.md +0 -322
- package/agents/builder.md +0 -414
- package/agents/lead.md +0 -738
- package/agents/memory.md +0 -1015
- package/agents/product.md +0 -520
- package/agents/reviewer.md +0 -374
- package/agents/scout.md +0 -320
- package/commands/agentuity-cadence-cancel.md +0 -20
- package/commands/agentuity-cadence.md +0 -76
- package/commands/agentuity-coder.md +0 -15
- package/commands/agentuity-memory-share.md +0 -31
- package/commands/agentuity-sandbox.md +0 -33
- package/hooks/scripts/block-sensitive-commands.sh +0 -43
- package/hooks/scripts/cadence-stop.sh +0 -180
- package/hooks/scripts/pre-compact.sh +0 -24
- package/hooks/scripts/session-end.sh +0 -203
- package/hooks/scripts/session-start.sh +0 -68
- package/hooks/scripts/setup-cadence.sh +0 -133
- package/hooks/scripts/stop-memory-save.sh +0 -69
- package/skills/agentuity-command-runner/SKILL.md +0 -128
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: agentuity-cadence-cancel
|
|
3
|
-
description: Cancel an active Cadence loop
|
|
4
|
-
allowed-tools:
|
|
5
|
-
[
|
|
6
|
-
'Bash(test -f .claude/agentuity-cadence.local.md:*)',
|
|
7
|
-
'Bash(rm .claude/agentuity-cadence.local.md)',
|
|
8
|
-
'Read(.claude/agentuity-cadence.local.md)',
|
|
9
|
-
]
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
Check if there's an active Cadence loop and cancel it:
|
|
13
|
-
|
|
14
|
-
1. Check if `.claude/agentuity-cadence.local.md` exists: `test -f .claude/agentuity-cadence.local.md && echo "EXISTS" || echo "NOT_FOUND"`
|
|
15
|
-
2. If NOT_FOUND: Tell the user "No active Cadence loop found."
|
|
16
|
-
3. If EXISTS:
|
|
17
|
-
- Read the file to get the current iteration from the frontmatter
|
|
18
|
-
- Delete it: `rm .claude/agentuity-cadence.local.md`
|
|
19
|
-
- Tell the user: "Cancelled Cadence loop (was at iteration N)"
|
|
20
|
-
- Offer to save session memory via the Memory agent
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: agentuity-cadence
|
|
3
|
-
description: Start a long-running Cadence loop for autonomous task completion (Lead orchestrates with Architect, Memory checkpoints, Product PRD validation)
|
|
4
|
-
argument-hint: 'TASK [--max-iterations N] [--completion-promise TEXT]'
|
|
5
|
-
allowed-tools: ['Bash(${CLAUDE_PLUGIN_ROOT}/hooks/scripts/setup-cadence.sh:*)']
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
First, initialize the Cadence loop by running the setup script with the user's task:
|
|
9
|
-
|
|
10
|
-
```
|
|
11
|
-
"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/setup-cadence.sh" $ARGUMENTS
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
After the setup script completes successfully, begin working on the task in Cadence mode.
|
|
15
|
-
|
|
16
|
-
<cadence-mode>
|
|
17
|
-
|
|
18
|
-
You are now in **Cadence mode** — a long-running autonomous loop. A Stop hook will keep the loop running automatically. Each time you try to stop, the hook will block the exit and re-inject your task with continuation instructions (including Memory checkpoint triggers).
|
|
19
|
-
|
|
20
|
-
You will keep working until the task is truly complete. Do NOT stop after a single step.
|
|
21
|
-
|
|
22
|
-
## Your Team (use Task tool to delegate)
|
|
23
|
-
|
|
24
|
-
| Agent | subagent_type | Use For |
|
|
25
|
-
| --------- | ----------------------------------------- | --------------------------------------------------------- |
|
|
26
|
-
| Scout | agentuity-coder:agentuity-coder-scout | Explore codebase, find patterns (read-only) |
|
|
27
|
-
| Builder | agentuity-coder:agentuity-coder-builder | Quick fixes, simple implementations |
|
|
28
|
-
| Architect | agentuity-coder:agentuity-coder-architect | Complex autonomous implementation (PREFERRED for Cadence) |
|
|
29
|
-
| Reviewer | agentuity-coder:agentuity-coder-reviewer | Review changes, catch issues |
|
|
30
|
-
| Memory | agentuity-coder:agentuity-coder-memory | Store context, checkpoints, corrections |
|
|
31
|
-
| Product | agentuity-coder:agentuity-coder-product | Clarify requirements, validate features, PRD |
|
|
32
|
-
|
|
33
|
-
## Cadence Workflow
|
|
34
|
-
|
|
35
|
-
### Phase 1: Setup (do this FIRST)
|
|
36
|
-
|
|
37
|
-
1. **Establish PRD** — Delegate to Product agent: "Establish the PRD for this task: [task description]. Define requirements, success criteria, and phases."
|
|
38
|
-
2. **Check Memory** — Delegate to Memory agent: "Any context, corrections, or past decisions relevant to [task area]?"
|
|
39
|
-
3. **Plan phases** — Generate a loop ID (format: `lp_short_name_01`), plan your phases
|
|
40
|
-
|
|
41
|
-
### Phase 2: Iterate (repeat until done)
|
|
42
|
-
|
|
43
|
-
For each iteration:
|
|
44
|
-
|
|
45
|
-
1. **Plan** — What's the next concrete step? (Use extended thinking for complex planning)
|
|
46
|
-
2. **Delegate** — Send work to **Architect** (preferred) or Builder
|
|
47
|
-
3. **Review** — Have Reviewer check the work
|
|
48
|
-
4. **Checkpoint** — Tell Memory: "Store checkpoint for iteration N: [what changed, what's next]"
|
|
49
|
-
5. **Continue** — Move to the next iteration. Do NOT stop.
|
|
50
|
-
|
|
51
|
-
### Phase 3: Finalize
|
|
52
|
-
|
|
53
|
-
When truly complete:
|
|
54
|
-
|
|
55
|
-
1. Have Reviewer do a final review
|
|
56
|
-
2. Tell Product to validate against the PRD
|
|
57
|
-
3. Tell Memory to memorialize the full session
|
|
58
|
-
4. Output exactly: `<promise>DONE</promise>`
|
|
59
|
-
|
|
60
|
-
## Completion
|
|
61
|
-
|
|
62
|
-
When the task is TRULY complete (all requirements met, tests passing, reviewed), output exactly:
|
|
63
|
-
|
|
64
|
-
<promise>DONE</promise>
|
|
65
|
-
|
|
66
|
-
This signals the Cadence Stop hook to let the session end. The statement MUST be completely and unequivocally TRUE — do NOT output the promise until the task is genuinely done.
|
|
67
|
-
|
|
68
|
-
## Critical Rules
|
|
69
|
-
|
|
70
|
-
- **Keep going.** Each time you finish a step, immediately start the next one. Do not wait for the user.
|
|
71
|
-
- **Use Architect** for implementation — it has deep reasoning, ideal for autonomous work.
|
|
72
|
-
- **Checkpoint every iteration** via Memory — this protects against context loss during compaction.
|
|
73
|
-
- **If stuck**: Try once more with a different approach. If still stuck, explain the blocker and ask the user.
|
|
74
|
-
- **To cancel**: User can run `/agentuity-cadence-cancel` at any time.
|
|
75
|
-
|
|
76
|
-
</cadence-mode>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: agentuity-coder
|
|
3
|
-
description: Activate the Agentuity Coder team to work on a task with full orchestration (Lead delegates to Scout, Builder, Architect, Reviewer, Memory, Product)
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Activate the Agentuity Coder Lead agent to orchestrate this task. Use the Task tool with agent type "agentuity-coder:agentuity-coder-lead" to delegate the user's request.
|
|
7
|
-
|
|
8
|
-
The Lead agent will:
|
|
9
|
-
|
|
10
|
-
1. Classify the request (feature, bug, refactor, research, infra, memory, meta)
|
|
11
|
-
2. Plan the approach
|
|
12
|
-
3. Delegate to specialized agents (Scout, Builder, Architect, Reviewer, Memory, Product)
|
|
13
|
-
4. Synthesize results and report back
|
|
14
|
-
|
|
15
|
-
Pass the user's full request to the Lead agent.
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: agentuity-memory-share
|
|
3
|
-
description: Share memory content publicly with a shareable URL via Agentuity Cloud Streams
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Share content publicly using Agentuity Cloud Streams.
|
|
7
|
-
|
|
8
|
-
The user wants to share session content, decisions, or other information publicly with a shareable URL.
|
|
9
|
-
|
|
10
|
-
## How to share
|
|
11
|
-
|
|
12
|
-
Use the Bash tool to create a stream with the content:
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
agentuity cloud stream create --content "<markdown content>" --ttl <duration> --json
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
TTL options: `1h`, `24h`, `7d`, `30d` (default: `24h`)
|
|
19
|
-
|
|
20
|
-
## What to share
|
|
21
|
-
|
|
22
|
-
- **Current session summary**: Compile key decisions, patterns, and outcomes from this conversation
|
|
23
|
-
- **Specific content**: Whatever the user requests (decisions, code review, architecture notes, etc.)
|
|
24
|
-
- **Past session data**: Use the Task tool to delegate to the Memory agent (agentuity-coder:agentuity-coder-memory) to retrieve stored sessions, then share the results
|
|
25
|
-
|
|
26
|
-
## Guidelines
|
|
27
|
-
|
|
28
|
-
1. Format the content as clean, readable markdown
|
|
29
|
-
2. Include relevant context (project, branch, date)
|
|
30
|
-
3. Do NOT include secrets, credentials, or PII
|
|
31
|
-
4. Return the shareable URL to the user
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: agentuity-sandbox
|
|
3
|
-
description: Agentuity sandboxes — isolated execution environments for running code, tests, and builds
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Help with Agentuity sandboxes using the `agentuity cloud sandbox` CLI.
|
|
7
|
-
|
|
8
|
-
## Common Commands
|
|
9
|
-
|
|
10
|
-
```
|
|
11
|
-
agentuity cloud sandbox runtime list --json # List available runtimes
|
|
12
|
-
agentuity cloud sandbox run [--memory 1Gi] [--cpu 1000m] \
|
|
13
|
-
[--runtime <name>] [--name <name>] -- <command> # One-shot execution
|
|
14
|
-
agentuity cloud sandbox create --json [--memory 1Gi] [--cpu 1000m] \
|
|
15
|
-
[--network] [--runtime <name>] [--name <name>] # Create persistent sandbox
|
|
16
|
-
agentuity cloud sandbox list --json # List sandboxes
|
|
17
|
-
agentuity cloud sandbox exec <id> -- <command> # Run in existing sandbox
|
|
18
|
-
agentuity cloud sandbox files <id> [path] --json # List files
|
|
19
|
-
agentuity cloud sandbox cp ./local <id>:/home/agentuity # Copy files to sandbox
|
|
20
|
-
agentuity cloud sandbox delete <id> --json # Delete sandbox
|
|
21
|
-
agentuity cloud sandbox snapshot create <id> \
|
|
22
|
-
[--name <name>] [--tag <tag>] # Save sandbox state
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Guidelines
|
|
26
|
-
|
|
27
|
-
1. First check auth: `agentuity auth whoami`
|
|
28
|
-
2. Use `--json` for programmatic output
|
|
29
|
-
3. Default working directory inside sandboxes: `/home/agentuity`
|
|
30
|
-
4. Use `runtime list` to find runtimes, then pass `--runtime` on `run`/`create`
|
|
31
|
-
5. Use `--name` and `--description` for better tracking
|
|
32
|
-
|
|
33
|
-
Execute the user's sandbox request using the Bash tool with `agentuity cloud sandbox` commands.
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# PreToolUse hook: Block sensitive agentuity commands (secrets, apikeys, tokens).
|
|
3
|
-
#
|
|
4
|
-
# NOTE: CLI plugin hooks can only BLOCK commands (exit 2 = block).
|
|
5
|
-
# Auto-allowing is handled via permissions.allow in settings.local.json,
|
|
6
|
-
# which is configured by the install script (src/install.ts).
|
|
7
|
-
#
|
|
8
|
-
# Exit 0 = don't interfere (let normal permission rules handle it).
|
|
9
|
-
# Exit 2 + JSON to stderr = block the command.
|
|
10
|
-
|
|
11
|
-
INPUT=$(cat)
|
|
12
|
-
|
|
13
|
-
# Use jq if available, fall back to grep
|
|
14
|
-
if command -v jq &>/dev/null; then
|
|
15
|
-
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
16
|
-
else
|
|
17
|
-
COMMAND=$(echo "$INPUT" | grep -o '"command"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"command"[[:space:]]*:[[:space:]]*"\([^"]*\)"/\1/')
|
|
18
|
-
fi
|
|
19
|
-
|
|
20
|
-
# If we can't extract the command, don't interfere
|
|
21
|
-
if [ -z "$COMMAND" ]; then
|
|
22
|
-
exit 0
|
|
23
|
-
fi
|
|
24
|
-
|
|
25
|
-
# Block sensitive commands
|
|
26
|
-
case "$COMMAND" in
|
|
27
|
-
*"agentuity cloud secret"*|*"agentuity cloud secrets"*)
|
|
28
|
-
echo '{"decision":"block","reason":"Blocked: agentuity cloud secrets access is not allowed by the Agentuity Coder plugin"}' >&2
|
|
29
|
-
exit 2
|
|
30
|
-
;;
|
|
31
|
-
*"agentuity cloud apikey"*)
|
|
32
|
-
echo '{"decision":"block","reason":"Blocked: agentuity cloud apikey access is not allowed by the Agentuity Coder plugin"}' >&2
|
|
33
|
-
exit 2
|
|
34
|
-
;;
|
|
35
|
-
*"agentuity auth token"*)
|
|
36
|
-
echo '{"decision":"block","reason":"Blocked: agentuity auth token access is not allowed by the Agentuity Coder plugin"}' >&2
|
|
37
|
-
exit 2
|
|
38
|
-
;;
|
|
39
|
-
esac
|
|
40
|
-
|
|
41
|
-
# For anything else, don't interfere — permission rules in settings.local.json
|
|
42
|
-
# handle auto-allowing agentuity cloud commands.
|
|
43
|
-
exit 0
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Cadence Stop Hook: Keeps the Cadence loop running until completion.
|
|
3
|
-
#
|
|
4
|
-
# Checks for active Cadence state file (.claude/agentuity-cadence.local.md).
|
|
5
|
-
# If active:
|
|
6
|
-
# - Reads the last assistant message from the transcript
|
|
7
|
-
# - Checks for <promise>DONE</promise> completion signal
|
|
8
|
-
# - Checks max iterations
|
|
9
|
-
# - If continuing: saves state to KV, blocks stop, re-injects prompt
|
|
10
|
-
# - If done: saves final state to KV, allows stop
|
|
11
|
-
# If not active: allows stop normally (exit 0)
|
|
12
|
-
#
|
|
13
|
-
# State is persisted to Agentuity Cloud KV at each iteration for cross-session
|
|
14
|
-
# recall and crash recovery. Local file is the control mechanism; KV is durable storage.
|
|
15
|
-
#
|
|
16
|
-
# Exit 0 = allow stop (no active cadence, or task complete)
|
|
17
|
-
# Exit 2 + JSON with decision:block = prevent stop and re-inject prompt
|
|
18
|
-
|
|
19
|
-
INPUT=$(cat)
|
|
20
|
-
|
|
21
|
-
# State file location (following Ralph Wiggum convention)
|
|
22
|
-
STATE_FILE=".claude/agentuity-cadence.local.md"
|
|
23
|
-
|
|
24
|
-
# If no active Cadence session, allow normal stop
|
|
25
|
-
if [ ! -f "$STATE_FILE" ]; then
|
|
26
|
-
exit 0
|
|
27
|
-
fi
|
|
28
|
-
|
|
29
|
-
# Parse YAML frontmatter from state file
|
|
30
|
-
LOOP_ID=$(sed -n '/^---$/,/^---$/{ /^loop_id:/s/loop_id: *//p }' "$STATE_FILE" | tr -d '"')
|
|
31
|
-
ITERATION=$(sed -n '/^---$/,/^---$/{ /^iteration:/s/iteration: *//p }' "$STATE_FILE")
|
|
32
|
-
MAX_ITERATIONS=$(sed -n '/^---$/,/^---$/{ /^max_iterations:/s/max_iterations: *//p }' "$STATE_FILE")
|
|
33
|
-
COMPLETION_PROMISE=$(sed -n '/^---$/,/^---$/{ /^completion_promise:/s/completion_promise: *//p }' "$STATE_FILE" | tr -d '"')
|
|
34
|
-
CREATED_AT=$(sed -n '/^---$/,/^---$/{ /^created_at:/s/created_at: *//p }' "$STATE_FILE")
|
|
35
|
-
|
|
36
|
-
# Defaults
|
|
37
|
-
LOOP_ID=${LOOP_ID:-unknown}
|
|
38
|
-
ITERATION=${ITERATION:-1}
|
|
39
|
-
MAX_ITERATIONS=${MAX_ITERATIONS:-50}
|
|
40
|
-
COMPLETION_PROMISE=${COMPLETION_PROMISE:-DONE}
|
|
41
|
-
CREATED_AT=${CREATED_AT:-unknown}
|
|
42
|
-
|
|
43
|
-
# Validate iteration is numeric
|
|
44
|
-
if ! [[ "$ITERATION" =~ ^[0-9]+$ ]]; then
|
|
45
|
-
echo "Cadence error: Invalid iteration '$ITERATION'. Removing state file." >&2
|
|
46
|
-
rm -f "$STATE_FILE"
|
|
47
|
-
exit 0
|
|
48
|
-
fi
|
|
49
|
-
|
|
50
|
-
if ! [[ "$MAX_ITERATIONS" =~ ^[0-9]+$ ]]; then
|
|
51
|
-
echo "Cadence error: Invalid max_iterations '$MAX_ITERATIONS'. Removing state file." >&2
|
|
52
|
-
rm -f "$STATE_FILE"
|
|
53
|
-
exit 0
|
|
54
|
-
fi
|
|
55
|
-
|
|
56
|
-
# Get git branch for context
|
|
57
|
-
GIT_BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
|
|
58
|
-
NOW=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
59
|
-
|
|
60
|
-
# Helper: save cadence state to KV
|
|
61
|
-
save_to_kv() {
|
|
62
|
-
local status="$1"
|
|
63
|
-
if command -v agentuity &>/dev/null && [ "$LOOP_ID" != "unknown" ]; then
|
|
64
|
-
KV_STATE=$(jq -n \
|
|
65
|
-
--arg loopId "$LOOP_ID" \
|
|
66
|
-
--arg branch "$GIT_BRANCH" \
|
|
67
|
-
--arg createdAt "$CREATED_AT" \
|
|
68
|
-
--arg lastActivity "$NOW" \
|
|
69
|
-
--argjson iteration "$ITERATION" \
|
|
70
|
-
--argjson maxIterations "$MAX_ITERATIONS" \
|
|
71
|
-
--arg completionPromise "$COMPLETION_PROMISE" \
|
|
72
|
-
--arg status "$status" \
|
|
73
|
-
'{
|
|
74
|
-
loopId: $loopId,
|
|
75
|
-
branch: $branch,
|
|
76
|
-
iteration: $iteration,
|
|
77
|
-
maxIterations: $maxIterations,
|
|
78
|
-
completionPromise: $completionPromise,
|
|
79
|
-
status: $status,
|
|
80
|
-
startedAt: $createdAt,
|
|
81
|
-
lastActivity: $lastActivity
|
|
82
|
-
}')
|
|
83
|
-
agentuity cloud kv set agentuity-opencode-memory "cadence:${LOOP_ID}" "$KV_STATE" --region use 2>/dev/null || true
|
|
84
|
-
fi
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
# Check max iterations
|
|
88
|
-
if [[ $MAX_ITERATIONS -gt 0 ]] && [[ $ITERATION -ge $MAX_ITERATIONS ]]; then
|
|
89
|
-
echo "Cadence: Max iterations ($MAX_ITERATIONS) reached. Loop complete." >&2
|
|
90
|
-
save_to_kv "completed_max_iterations"
|
|
91
|
-
rm -f "$STATE_FILE"
|
|
92
|
-
exit 0
|
|
93
|
-
fi
|
|
94
|
-
|
|
95
|
-
# Get transcript path from hook input
|
|
96
|
-
TRANSCRIPT_PATH=$(echo "$INPUT" | jq -r '.transcript_path // empty' 2>/dev/null)
|
|
97
|
-
|
|
98
|
-
# Check for completion promise in transcript
|
|
99
|
-
if [ -n "$TRANSCRIPT_PATH" ] && [ -f "$TRANSCRIPT_PATH" ]; then
|
|
100
|
-
# Get the last assistant message
|
|
101
|
-
LAST_ASSISTANT=$(grep '"role":"assistant"' "$TRANSCRIPT_PATH" | tail -1 2>/dev/null)
|
|
102
|
-
|
|
103
|
-
if [ -n "$LAST_ASSISTANT" ]; then
|
|
104
|
-
LAST_TEXT=$(echo "$LAST_ASSISTANT" | jq -r '
|
|
105
|
-
.message.content |
|
|
106
|
-
map(select(.type == "text")) |
|
|
107
|
-
map(.text) |
|
|
108
|
-
join("\n")
|
|
109
|
-
' 2>/dev/null)
|
|
110
|
-
|
|
111
|
-
# Check for completion promise using perl (handles multiline)
|
|
112
|
-
if [ -n "$LAST_TEXT" ]; then
|
|
113
|
-
PROMISE_TEXT=$(echo "$LAST_TEXT" | perl -0777 -pe 's/.*?<promise>(.*?)<\/promise>.*/\1/s; s/^\s+|\s+$//g; s/\s+/ /g' 2>/dev/null)
|
|
114
|
-
|
|
115
|
-
if [ -n "$PROMISE_TEXT" ] && [ "$PROMISE_TEXT" = "$COMPLETION_PROMISE" ]; then
|
|
116
|
-
echo "Cadence: Completion detected (<promise>$COMPLETION_PROMISE</promise>). Loop finished." >&2
|
|
117
|
-
save_to_kv "completed"
|
|
118
|
-
rm -f "$STATE_FILE"
|
|
119
|
-
exit 0
|
|
120
|
-
fi
|
|
121
|
-
fi
|
|
122
|
-
fi
|
|
123
|
-
fi
|
|
124
|
-
|
|
125
|
-
# Extract the original prompt (everything after the second --- delimiter)
|
|
126
|
-
PROMPT_TEXT=$(awk 'BEGIN{c=0} /^---$/{c++; next} c>=2{print}' "$STATE_FILE")
|
|
127
|
-
|
|
128
|
-
if [ -z "$PROMPT_TEXT" ]; then
|
|
129
|
-
echo "Cadence error: No prompt found in state file. Removing." >&2
|
|
130
|
-
rm -f "$STATE_FILE"
|
|
131
|
-
exit 0
|
|
132
|
-
fi
|
|
133
|
-
|
|
134
|
-
# Increment iteration
|
|
135
|
-
NEXT_ITERATION=$((ITERATION + 1))
|
|
136
|
-
|
|
137
|
-
# Update state file atomically
|
|
138
|
-
sed "s/^iteration: *[0-9]*/iteration: $NEXT_ITERATION/" "$STATE_FILE" > "${STATE_FILE}.tmp" && mv "${STATE_FILE}.tmp" "$STATE_FILE"
|
|
139
|
-
|
|
140
|
-
# Save iteration state to KV
|
|
141
|
-
ITERATION=$NEXT_ITERATION
|
|
142
|
-
save_to_kv "active"
|
|
143
|
-
|
|
144
|
-
# Build system message
|
|
145
|
-
SYSTEM_MSG="Cadence iteration ${NEXT_ITERATION}/${MAX_ITERATIONS} | Loop: ${LOOP_ID} | Branch: ${GIT_BRANCH} | To complete: output <promise>${COMPLETION_PROMISE}</promise>"
|
|
146
|
-
|
|
147
|
-
# Build continuation prompt with Memory checkpoint trigger
|
|
148
|
-
read -r -d '' CONTINUATION << CONT_EOF || true
|
|
149
|
-
[CADENCE CONTINUATION - Iteration ${NEXT_ITERATION}/${MAX_ITERATIONS}]
|
|
150
|
-
|
|
151
|
-
You are in Cadence mode. Loop ID: ${LOOP_ID}. This is iteration ${NEXT_ITERATION} of ${MAX_ITERATIONS}.
|
|
152
|
-
|
|
153
|
-
BEFORE continuing work, checkpoint with Memory:
|
|
154
|
-
- Use the Task tool: subagent_type=agentuity-coder:agentuity-coder-memory
|
|
155
|
-
- Prompt: "Checkpoint iteration ${ITERATION} for loop ${LOOP_ID}: Store what was accomplished and what's next. Update the cadence record in KV (key: cadence:${LOOP_ID}, namespace: agentuity-opencode-memory). Read the existing record, append this checkpoint to the checkpoints array, and save back. Branch: ${GIT_BRANCH}"
|
|
156
|
-
|
|
157
|
-
Then continue working on the task below. Pick up where you left off — do NOT restart from the beginning.
|
|
158
|
-
|
|
159
|
-
When the task is TRULY complete (all requirements met, tests passing, reviewed):
|
|
160
|
-
1. Have Reviewer do a final review
|
|
161
|
-
2. Have Product validate against the PRD
|
|
162
|
-
3. Tell Memory to memorialize the full session (save to KV and Vector)
|
|
163
|
-
4. Output: <promise>${COMPLETION_PROMISE}</promise>
|
|
164
|
-
|
|
165
|
-
## Original Task
|
|
166
|
-
|
|
167
|
-
${PROMPT_TEXT}
|
|
168
|
-
CONT_EOF
|
|
169
|
-
|
|
170
|
-
# Output JSON to block stop and re-inject the prompt
|
|
171
|
-
jq -n \
|
|
172
|
-
--arg reason "$CONTINUATION" \
|
|
173
|
-
--arg msg "$SYSTEM_MSG" \
|
|
174
|
-
'{
|
|
175
|
-
"decision": "block",
|
|
176
|
-
"reason": $reason,
|
|
177
|
-
"systemMessage": $msg
|
|
178
|
-
}'
|
|
179
|
-
|
|
180
|
-
exit 2
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# PreCompact hook: Inject memory-save instructions before context compaction.
|
|
3
|
-
#
|
|
4
|
-
# When Claude Code compacts context (auto or manual), this hook adds
|
|
5
|
-
# additionalContext instructing the LLM to save important session context
|
|
6
|
-
# via the Memory agent before the compaction erases it.
|
|
7
|
-
#
|
|
8
|
-
# Output: JSON with additionalContext field to stdout.
|
|
9
|
-
|
|
10
|
-
INPUT=$(cat)
|
|
11
|
-
|
|
12
|
-
# Check if agentuity CLI is available
|
|
13
|
-
if ! command -v agentuity &>/dev/null; then
|
|
14
|
-
exit 0
|
|
15
|
-
fi
|
|
16
|
-
|
|
17
|
-
# Get current git branch for context
|
|
18
|
-
GIT_BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
|
|
19
|
-
|
|
20
|
-
cat <<EOF
|
|
21
|
-
{
|
|
22
|
-
"additionalContext": "[COMPACTION IMMINENT — SAVE CONTEXT NOW]\n\nContext is about to be compacted. You MUST delegate to the Memory agent BEFORE compaction erases conversation history.\n\nUse the Task tool with these parameters:\n- subagent_type: agentuity-coder:agentuity-coder-memory\n- description: Save pre-compaction memory\n- prompt: \"COMPACTION IMMINENT. You are being invoked automatically before context compaction. Review the conversation above and perform these steps:\\n\\n1. Create/update session record in KV (session:{sessionId}) with: title, summary, decisions[], corrections[], files[], and append to compactions[] array\\n2. Extract corrections/mistakes as separate KV entries (correction:{name}) — these are HIGH PRIORITY\\n3. Extract key decisions as KV entries (decision:{name})\\n4. Upsert FULL session document to Vector (agentuity-opencode-sessions) as readable markdown — NOT a summary, the FULL content\\n5. Apply reasoning: extract explicit, deductive, inductive, abductive conclusions and update entity representations\\n6. Branch: ${GIT_BRANCH}\\n\\nDo NOT ask questions. Extract and store everything you can. This conversation will be compacted after you finish.\"\n\nThis is CRITICAL — do this immediately before any other work."
|
|
23
|
-
}
|
|
24
|
-
EOF
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Session end hook: Save session context via TWO paths:
|
|
3
|
-
#
|
|
4
|
-
# PATH 1 (Immediate): Structured KV save — session metadata + conversation extract.
|
|
5
|
-
# Fast, reliable, always works. Extracts actual text content from transcript.
|
|
6
|
-
#
|
|
7
|
-
# PATH 2 (Async/Agentic): Spawn background `claude -p` with the plugin loaded.
|
|
8
|
-
# Delegates to the Memory agent for full agentic processing:
|
|
9
|
-
# entity extraction, corrections, Vector upsert, structured conclusions.
|
|
10
|
-
# Runs as a fire-and-forget background process.
|
|
11
|
-
#
|
|
12
|
-
# This dual approach ensures:
|
|
13
|
-
# - Something is ALWAYS saved (Path 1, even if claude -p fails)
|
|
14
|
-
# - Full agentic memory processing happens asynchronously (Path 2)
|
|
15
|
-
#
|
|
16
|
-
# Receives JSON on stdin with:
|
|
17
|
-
# - session_id: session identifier
|
|
18
|
-
# - transcript_path: path to conversation JSONL file
|
|
19
|
-
# - cwd: working directory
|
|
20
|
-
# - reason: why session ended
|
|
21
|
-
#
|
|
22
|
-
# Claude Code JSONL format notes:
|
|
23
|
-
# - Each line is a JSON object with top-level .type field
|
|
24
|
-
# - Types: "user", "assistant", "progress", "file-history-snapshot"
|
|
25
|
-
# - Text content: .message.content[] where item .type == "text" and text in .text
|
|
26
|
-
# - "progress" entries (subagent updates) can be very large (100KB+)
|
|
27
|
-
# - Filter by line size (< 5KB) before jq processing to avoid OOM/hangs
|
|
28
|
-
|
|
29
|
-
set -uo pipefail
|
|
30
|
-
|
|
31
|
-
INPUT=$(cat)
|
|
32
|
-
|
|
33
|
-
if ! command -v agentuity &>/dev/null; then
|
|
34
|
-
exit 0
|
|
35
|
-
fi
|
|
36
|
-
|
|
37
|
-
# Derive plugin root from this script's location
|
|
38
|
-
# Script is at: <plugin_root>/hooks/scripts/session-end.sh
|
|
39
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
40
|
-
PLUGIN_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
41
|
-
|
|
42
|
-
# Extract fields from input JSON
|
|
43
|
-
if command -v jq &>/dev/null; then
|
|
44
|
-
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty' 2>/dev/null)
|
|
45
|
-
TRANSCRIPT_PATH=$(echo "$INPUT" | jq -r '.transcript_path // empty' 2>/dev/null)
|
|
46
|
-
REASON=$(echo "$INPUT" | jq -r '.reason // empty' 2>/dev/null)
|
|
47
|
-
CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null)
|
|
48
|
-
else
|
|
49
|
-
SESSION_ID=$(echo "$INPUT" | grep -o '"session_id"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)"$/\1/')
|
|
50
|
-
TRANSCRIPT_PATH=$(echo "$INPUT" | grep -o '"transcript_path"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)"$/\1/')
|
|
51
|
-
REASON=$(echo "$INPUT" | grep -o '"reason"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)"$/\1/')
|
|
52
|
-
CWD=$(echo "$INPUT" | grep -o '"cwd"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)"$/\1/')
|
|
53
|
-
fi
|
|
54
|
-
|
|
55
|
-
if [ -z "$SESSION_ID" ] || [ -z "$TRANSCRIPT_PATH" ] || [ ! -f "$TRANSCRIPT_PATH" ]; then
|
|
56
|
-
exit 0
|
|
57
|
-
fi
|
|
58
|
-
|
|
59
|
-
GIT_BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
|
|
60
|
-
GIT_REMOTE=$(git remote get-url origin 2>/dev/null || echo "unknown")
|
|
61
|
-
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
62
|
-
|
|
63
|
-
# ─────────────────────────────────────────────────────
|
|
64
|
-
# Extract conversation content from JSONL transcript
|
|
65
|
-
# ─────────────────────────────────────────────────────
|
|
66
|
-
# Key: filter lines < 5KB to skip huge "progress" entries that crash jq.
|
|
67
|
-
# Only extract .message.content[] items with .type == "text"
|
|
68
|
-
|
|
69
|
-
CONVERSATION=""
|
|
70
|
-
if command -v jq &>/dev/null && command -v awk &>/dev/null; then
|
|
71
|
-
CONVERSATION=$(awk 'length < 5000' "$TRANSCRIPT_PATH" 2>/dev/null | jq -r '
|
|
72
|
-
if .type == "assistant" then
|
|
73
|
-
.message.content[]? | select(.type == "text") | "ASSISTANT: " + (.text // "")
|
|
74
|
-
elif .type == "user" then
|
|
75
|
-
.message.content[]? | select(.type == "text") | "USER: " + (.text // "")
|
|
76
|
-
else empty end
|
|
77
|
-
' 2>/dev/null | tail -40 | head -c 8000)
|
|
78
|
-
fi
|
|
79
|
-
|
|
80
|
-
# Fallback: raw tail
|
|
81
|
-
if [ -z "$CONVERSATION" ]; then
|
|
82
|
-
CONVERSATION=$(tail -20 "$TRANSCRIPT_PATH" 2>/dev/null | head -c 4000)
|
|
83
|
-
fi
|
|
84
|
-
|
|
85
|
-
# ─────────────────────────────────────────────────────
|
|
86
|
-
# PATH 1: Immediate structured KV save
|
|
87
|
-
# ─────────────────────────────────────────────────────
|
|
88
|
-
|
|
89
|
-
SESSION_RECORD=$(jq -n \
|
|
90
|
-
--arg sid "$SESSION_ID" \
|
|
91
|
-
--arg branch "$GIT_BRANCH" \
|
|
92
|
-
--arg remote "$GIT_REMOTE" \
|
|
93
|
-
--arg reason "$REASON" \
|
|
94
|
-
--arg ts "$TIMESTAMP" \
|
|
95
|
-
--arg cwd "$CWD" \
|
|
96
|
-
--arg convo "$CONVERSATION" \
|
|
97
|
-
'{
|
|
98
|
-
sessionId: $sid,
|
|
99
|
-
branch: $branch,
|
|
100
|
-
remote: $remote,
|
|
101
|
-
endReason: $reason,
|
|
102
|
-
timestamp: $ts,
|
|
103
|
-
source: "claude-code",
|
|
104
|
-
cwd: $cwd,
|
|
105
|
-
conversation: $convo
|
|
106
|
-
}' 2>/dev/null)
|
|
107
|
-
|
|
108
|
-
if [ -n "$SESSION_RECORD" ]; then
|
|
109
|
-
agentuity cloud kv set agentuity-opencode-memory "session:cc:${SESSION_ID}" "$SESSION_RECORD" --region use 2>/dev/null || true
|
|
110
|
-
fi
|
|
111
|
-
|
|
112
|
-
# ─────────────────────────────────────────────────────
|
|
113
|
-
# PATH 2: Async agentic processing via background claude -p
|
|
114
|
-
# ─────────────────────────────────────────────────────
|
|
115
|
-
# Spawns a background claude -p with the plugin loaded, delegating to the
|
|
116
|
-
# Memory agent for full agentic processing (entity extraction, corrections,
|
|
117
|
-
# Vector upsert, structured conclusions).
|
|
118
|
-
#
|
|
119
|
-
# Key learnings from iteration:
|
|
120
|
-
# - --allowedTools must be SEPARATE arguments, not comma-separated
|
|
121
|
-
# - Pattern syntax is Bash(agentuity *) not Bash(pattern agentuity*)
|
|
122
|
-
# - Memory agent (via Task tool) handles all KV/Vector storage
|
|
123
|
-
# - --plugin-dir loads the plugin so Task can access the Memory agent
|
|
124
|
-
#
|
|
125
|
-
# This is "Option A" — local/sandbox use. For production at scale,
|
|
126
|
-
# replace with queue-based worker (Option B) or control plane (Option C).
|
|
127
|
-
|
|
128
|
-
if command -v claude &>/dev/null; then
|
|
129
|
-
# Write session context to temp file for claude -p to read
|
|
130
|
-
MEMORY_FILE=$(mktemp /tmp/agentuity-session-XXXXXX.md)
|
|
131
|
-
|
|
132
|
-
cat > "$MEMORY_FILE" <<MEMORY_CONTEXT
|
|
133
|
-
# Session Memorialization Request
|
|
134
|
-
|
|
135
|
-
**Session ID:** ${SESSION_ID}
|
|
136
|
-
**Branch:** ${GIT_BRANCH}
|
|
137
|
-
**Repository:** ${GIT_REMOTE}
|
|
138
|
-
**Working Directory:** ${CWD}
|
|
139
|
-
**End Reason:** ${REASON}
|
|
140
|
-
**Timestamp:** ${TIMESTAMP}
|
|
141
|
-
|
|
142
|
-
## Conversation Transcript
|
|
143
|
-
|
|
144
|
-
${CONVERSATION}
|
|
145
|
-
MEMORY_CONTEXT
|
|
146
|
-
|
|
147
|
-
LOG_DIR="/tmp/agentuity-memory-logs"
|
|
148
|
-
mkdir -p "$LOG_DIR" 2>/dev/null
|
|
149
|
-
|
|
150
|
-
# Spawn background claude -p with plugin loaded.
|
|
151
|
-
# Delegates to Memory agent via Task tool for full agentic processing.
|
|
152
|
-
# --dangerously-skip-permissions: background process, no user to prompt.
|
|
153
|
-
# --tools: restricts available tools to Task, Read, Bash (scoped).
|
|
154
|
-
nohup claude -p "Read the file ${MEMORY_FILE} which contains a session transcript to memorialize.
|
|
155
|
-
|
|
156
|
-
Use the Task tool to delegate to the Memory agent:
|
|
157
|
-
- subagent_type: agentuity-coder:agentuity-coder-memory
|
|
158
|
-
- description: Memorialize session ${SESSION_ID}
|
|
159
|
-
- prompt: Memorialize this session. You are being invoked automatically at session end. Read the file ${MEMORY_FILE} for the full session context. Then perform a full session memorialization: create a session summary (PROBLEM, CONTEXT, DECISIONS, CORRECTIONS, SOLUTIONS, PATTERNS, FILES, OPEN QUESTIONS), extract and store corrections to KV, store decisions to KV, upsert the full session document to Vector for semantic search, and apply reasoning to extract conclusions. Session ID: ${SESSION_ID}, Branch: ${GIT_BRANCH}, Repo: ${GIT_REMOTE}. Do NOT ask questions. Prioritize corrections and decisions.
|
|
160
|
-
|
|
161
|
-
After the Memory agent completes, clean up by running: rm ${MEMORY_FILE}" \
|
|
162
|
-
--plugin-dir "$PLUGIN_ROOT" \
|
|
163
|
-
--dangerously-skip-permissions \
|
|
164
|
-
--tools "Task,Read,Bash" \
|
|
165
|
-
> "$LOG_DIR/session-${SESSION_ID}.log" 2>&1 &
|
|
166
|
-
|
|
167
|
-
# Don't wait for completion — fire and forget
|
|
168
|
-
fi
|
|
169
|
-
|
|
170
|
-
# ─────────────────────────────────────────────────────
|
|
171
|
-
# (Future) PATH 3: Queue publish for worker-based processing
|
|
172
|
-
# ─────────────────────────────────────────────────────
|
|
173
|
-
# Uncomment when a queue worker (Option B/C) is available.
|
|
174
|
-
# The queue provides durability, retry, and DLQ for production use.
|
|
175
|
-
#
|
|
176
|
-
# QUEUE_PAYLOAD=$(jq -n \
|
|
177
|
-
# --arg type "session-memorialize" \
|
|
178
|
-
# --arg sid "$SESSION_ID" \
|
|
179
|
-
# --arg branch "$GIT_BRANCH" \
|
|
180
|
-
# --arg remote "$GIT_REMOTE" \
|
|
181
|
-
# --arg cwd "$CWD" \
|
|
182
|
-
# --arg reason "$REASON" \
|
|
183
|
-
# --arg ts "$TIMESTAMP" \
|
|
184
|
-
# --arg convo "$CONVERSATION" \
|
|
185
|
-
# '{
|
|
186
|
-
# type: $type,
|
|
187
|
-
# sessionId: $sid,
|
|
188
|
-
# branch: $branch,
|
|
189
|
-
# remote: $remote,
|
|
190
|
-
# cwd: $cwd,
|
|
191
|
-
# endReason: $reason,
|
|
192
|
-
# timestamp: $ts,
|
|
193
|
-
# transcript: $convo
|
|
194
|
-
# }' 2>/dev/null)
|
|
195
|
-
#
|
|
196
|
-
# if [ -n "$QUEUE_PAYLOAD" ]; then
|
|
197
|
-
# agentuity cloud queue publish coder-memory-processing "$QUEUE_PAYLOAD" \
|
|
198
|
-
# --metadata "{\"sessionId\":\"$SESSION_ID\",\"branch\":\"$GIT_BRANCH\",\"type\":\"session-memorialize\"}" \
|
|
199
|
-
# --idempotency-key "session:$SESSION_ID" \
|
|
200
|
-
# 2>/dev/null || true
|
|
201
|
-
# fi
|
|
202
|
-
|
|
203
|
-
exit 0
|