@agentuity/claude-code 1.0.5

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.
@@ -0,0 +1,74 @@
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
+ 1. **Plan** — What's the next concrete step? (Use extended thinking for complex planning)
45
+ 2. **Delegate** — Send work to **Architect** (preferred) or Builder
46
+ 3. **Review** — Have Reviewer check the work
47
+ 4. **Checkpoint** — Tell Memory: "Store checkpoint for iteration N: [what changed, what's next]"
48
+ 5. **Continue** — Move to the next iteration. Do NOT stop.
49
+
50
+ ### Phase 3: Finalize
51
+
52
+ When truly complete:
53
+ 1. Have Reviewer do a final review
54
+ 2. Tell Product to validate against the PRD
55
+ 3. Tell Memory to memorialize the full session
56
+ 4. Output exactly: `<promise>DONE</promise>`
57
+
58
+ ## Completion
59
+
60
+ When the task is TRULY complete (all requirements met, tests passing, reviewed), output exactly:
61
+
62
+ <promise>DONE</promise>
63
+
64
+ 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.
65
+
66
+ ## Critical Rules
67
+
68
+ - **Keep going.** Each time you finish a step, immediately start the next one. Do not wait for the user.
69
+ - **Use Architect** for implementation — it has deep reasoning, ideal for autonomous work.
70
+ - **Checkpoint every iteration** via Memory — this protects against context loss during compaction.
71
+ - **If stuck**: Try once more with a different approach. If still stuck, explain the blocker and ask the user.
72
+ - **To cancel**: User can run `/agentuity-cadence-cancel` at any time.
73
+
74
+ </cadence-mode>
@@ -0,0 +1,14 @@
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
+ 1. Classify the request (feature, bug, refactor, research, infra, memory, meta)
10
+ 2. Plan the approach
11
+ 3. Delegate to specialized agents (Scout, Builder, Architect, Reviewer, Memory, Product)
12
+ 4. Synthesize results and report back
13
+
14
+ Pass the user's full request to the Lead agent.
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: agentuity-memory-save
3
+ description: Save the current session context to Agentuity Cloud memory (KV + Vector storage) for future recall
4
+ ---
5
+
6
+ Invoke the Agentuity Coder Memory agent to memorialize this session. Use the Task tool with agent type "agentuity-coder:agentuity-coder-memory".
7
+
8
+ Tell Memory to:
9
+ 1. Summarize what was accomplished in this session
10
+ 2. Extract key decisions, patterns, and corrections
11
+ 3. Store in KV and Vector storage for future recall
12
+ 4. Note any open questions or follow-ups
13
+
14
+ The Memory agent will use Agentuity Cloud KV and Vector storage to persist this session's context.
@@ -0,0 +1,31 @@
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
@@ -0,0 +1,33 @@
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.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @agentuity/claude-code - Agentuity Coder plugin for Claude Code
3
+ *
4
+ * Install script that configures the plugin for the current project.
5
+ * Sets up permissions for Agentuity Cloud CLI commands.
6
+ */
7
+ export interface InstallConfig {
8
+ projectId?: string;
9
+ orgId?: string;
10
+ region?: string;
11
+ }
12
+ /**
13
+ * Read agentuity.json from the current project if it exists.
14
+ */
15
+ export declare function readProjectConfig(): Promise<InstallConfig>;
16
+ /**
17
+ * Install the Agentuity Coder plugin.
18
+ * This is called when the plugin is first installed.
19
+ */
20
+ export declare function install(): Promise<void>;
21
+ export default install;
22
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,WAAW,aAAa;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAuBD;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,aAAa,CAAC,CAehE;AAoED;;;GAGG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAoB7C;AAED,eAAe,OAAO,CAAC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * @agentuity/claude-code - Agentuity Coder plugin for Claude Code
3
+ *
4
+ * Install script that configures the plugin for the current project.
5
+ * Sets up permissions for Agentuity Cloud CLI commands.
6
+ */
7
+ import { join } from "node:path";
8
+ import { homedir } from "node:os";
9
+ const AGENTUITY_PERMISSIONS = [
10
+ "Bash(agentuity cloud *)",
11
+ "Bash(agentuity auth whoami *)",
12
+ ];
13
+ const AGENTUITY_DENY_PERMISSIONS = [
14
+ "Bash(agentuity cloud secrets *)",
15
+ "Bash(agentuity cloud secret *)",
16
+ "Bash(agentuity cloud apikey *)",
17
+ "Bash(agentuity auth token *)",
18
+ ];
19
+ /**
20
+ * Read agentuity.json from the current project if it exists.
21
+ */
22
+ export async function readProjectConfig() {
23
+ try {
24
+ const file = Bun.file("agentuity.json");
25
+ if (await file.exists()) {
26
+ const config = await file.json();
27
+ return {
28
+ projectId: config.projectId,
29
+ orgId: config.orgId,
30
+ region: config.region,
31
+ };
32
+ }
33
+ }
34
+ catch {
35
+ // No agentuity.json found or invalid
36
+ }
37
+ return {};
38
+ }
39
+ /**
40
+ * Read a Claude Code settings JSON file.
41
+ */
42
+ async function readSettings(path) {
43
+ try {
44
+ const file = Bun.file(path);
45
+ if (await file.exists()) {
46
+ return await file.json();
47
+ }
48
+ }
49
+ catch {
50
+ // File doesn't exist or is invalid
51
+ }
52
+ return {};
53
+ }
54
+ /**
55
+ * Write a Claude Code settings JSON file.
56
+ */
57
+ async function writeSettings(path, settings) {
58
+ await Bun.write(path, JSON.stringify(settings, null, 2) + "\n");
59
+ }
60
+ /**
61
+ * Ensure Agentuity Cloud permissions are configured in Claude Code settings.
62
+ * Adds allow rules for agentuity cloud commands and deny rules for sensitive ones.
63
+ */
64
+ async function configurePermissions() {
65
+ const settingsPath = join(homedir(), ".claude", "settings.local.json");
66
+ const settings = await readSettings(settingsPath);
67
+ if (!settings.permissions) {
68
+ settings.permissions = {};
69
+ }
70
+ if (!settings.permissions.allow) {
71
+ settings.permissions.allow = [];
72
+ }
73
+ if (!settings.permissions.deny) {
74
+ settings.permissions.deny = [];
75
+ }
76
+ let added = 0;
77
+ for (const perm of AGENTUITY_PERMISSIONS) {
78
+ if (!settings.permissions.allow.includes(perm)) {
79
+ settings.permissions.allow.push(perm);
80
+ added++;
81
+ }
82
+ }
83
+ for (const perm of AGENTUITY_DENY_PERMISSIONS) {
84
+ if (!settings.permissions.deny.includes(perm)) {
85
+ settings.permissions.deny.push(perm);
86
+ added++;
87
+ }
88
+ }
89
+ if (added > 0) {
90
+ await writeSettings(settingsPath, settings);
91
+ }
92
+ return { added };
93
+ }
94
+ /**
95
+ * Install the Agentuity Coder plugin.
96
+ * This is called when the plugin is first installed.
97
+ */
98
+ export async function install() {
99
+ const config = await readProjectConfig();
100
+ // Configure Claude Code permissions for Agentuity Cloud commands
101
+ const { added } = await configurePermissions();
102
+ if (added > 0) {
103
+ console.log(`Configured ${added} permission rules for Agentuity Cloud commands`);
104
+ }
105
+ if (config.projectId) {
106
+ console.log(`Agentuity Coder configured for project: ${config.projectId}`);
107
+ }
108
+ else {
109
+ console.log("Agentuity Coder installed (no agentuity.json found - will use session-start hook for context)");
110
+ }
111
+ }
112
+ export default install;
113
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"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AAK,GAAG,CAAC,EAAE,CAAC;QACf,MAAM,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO;IAC5B,MAAM,MAAM,GAAG,MAAM,iBAAiB,EAAE,CAAC;IAEzC,iEAAiE;IACjE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,oBAAoB,EAAE,CAAC;IAC/C,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CACV,cAAc,KAAK,gDAAgD,CACnE,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CACV,2CAA2C,MAAM,CAAC,SAAS,EAAE,CAC7D,CAAC;IACH,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,GAAG,CACV,+FAA+F,CAC/F,CAAC;IACH,CAAC;AACF,CAAC;AAED,eAAe,OAAO,CAAC"}
@@ -0,0 +1,67 @@
1
+ {
2
+ "PreToolUse": [
3
+ {
4
+ "matcher": "Bash",
5
+ "hooks": [
6
+ {
7
+ "type": "command",
8
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/block-sensitive-commands.sh",
9
+ "timeout": 5
10
+ }
11
+ ]
12
+ }
13
+ ],
14
+ "PreCompact": [
15
+ {
16
+ "matcher": "",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/pre-compact.sh",
21
+ "timeout": 10
22
+ }
23
+ ]
24
+ }
25
+ ],
26
+ "Stop": [
27
+ {
28
+ "matcher": "",
29
+ "hooks": [
30
+ {
31
+ "type": "command",
32
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/cadence-stop.sh",
33
+ "timeout": 15
34
+ },
35
+ {
36
+ "type": "command",
37
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/stop-memory-save.sh",
38
+ "timeout": 10
39
+ }
40
+ ]
41
+ }
42
+ ],
43
+ "SessionStart": [
44
+ {
45
+ "matcher": "",
46
+ "hooks": [
47
+ {
48
+ "type": "command",
49
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/session-start.sh",
50
+ "timeout": 15
51
+ }
52
+ ]
53
+ }
54
+ ],
55
+ "SessionEnd": [
56
+ {
57
+ "matcher": "",
58
+ "hooks": [
59
+ {
60
+ "type": "command",
61
+ "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/session-end.sh",
62
+ "timeout": 30
63
+ }
64
+ ]
65
+ }
66
+ ]
67
+ }
@@ -0,0 +1,43 @@
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
@@ -0,0 +1,180 @@
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
@@ -0,0 +1,24 @@
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