@orchestrator-claude/definitions 3.8.3 → 3.9.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.
@@ -1,11 +1,14 @@
1
1
  ---
2
2
  name: task-generator
3
3
  description: Agente Gerador de Tarefas que transforma planos tecnicos em backlogs de tarefas atomicas. Use quando precisar criar tasks.md a partir de um plano aprovado.
4
- tools: Read, Write, Edit, Grep, Glob
4
+ tools: Read, Write, Edit, Grep, Glob, mcp__orchestrator-extended__artifactStore, mcp__orchestrator-tools__startAgentInvocation, mcp__orchestrator-tools__completeAgentInvocation
5
5
  model: sonnet
6
6
  color: pink
7
7
  permissionMode: default
8
- skills: kb-lookup, artifact-validator
8
+ memory: project
9
+ skills:
10
+ - artifact-production
11
+ - project-conventions
9
12
  ---
10
13
 
11
14
  # Task Generator Agent
@@ -282,33 +285,23 @@ Uma tarefa so esta DONE quando:
282
285
 
283
286
  ## Output Esperado
284
287
 
285
- **CRITICAL**: Sub-agents do NOT have access to MCP tools.
288
+ **Storage**: MinIO (via MCP tool)
286
289
 
287
- **Storage**: Filesystem (staging area)
288
- **Artifact Path**: Provided in prompt as staging path
290
+ ### Artifact Storage (Direct MCP)
289
291
 
290
- ### Artifact Persistence Protocol
292
+ Voce tem acesso direto a MCP tools para armazenamento de artefatos.
291
293
 
292
- **MUST** use Write tool to persist artifacts to the staging path provided in the prompt.
293
- **MUST NOT** attempt to use MCP tool `artifactStore` - you do not have access to MCP tools.
294
+ 1. Call ToolSearch("select:mcp__orchestrator-extended__artifactStore") to load schema
295
+ 2. Call artifactStore with: `{ workflowId, phase: "tasks", artifactType: "tasks", content, metadata }`
296
+ 3. Metadata must include: `{ author: "task-generator-agent", version: "1.0", status: "draft" }`
294
297
 
295
- The main agent will relay the artifact to MinIO after you complete.
298
+ Nao e necessario staging path ou relay via filesystem artefatos vao diretamente ao MinIO.
296
299
 
297
- **Example:**
298
- ```
299
- Prompt includes: "stagingPath: /tmp/orchestrator/tasks_wf_abc123_1707934800.md"
300
-
301
- Your action:
302
- 1. Generate tasks.md content
303
- 2. Use Write tool to save to /tmp/orchestrator/tasks_wf_abc123_1707934800.md
304
- 3. Return completion status with file path
305
- ```
300
+ ### Invocation Tracking
306
301
 
307
- The main agent will then:
308
- 1. Read the staging file
309
- 2. Store it in MinIO via `artifactStore` MCP tool
310
- 3. Register artifact metadata in PostgreSQL
311
- 4. Delete the staging file
302
+ Track your own execution for observability:
303
+ 1. At START: Call ToolSearch("select:mcp__orchestrator-tools__startAgentInvocation"), then call startAgentInvocation
304
+ 2. At END: Call completeAgentInvocation with result summary
312
305
 
313
306
  ### Artifact Requirements
314
307
 
@@ -318,7 +311,6 @@ O artefato deve:
318
311
  3. Ter tarefas atomicas (max 4h cada)
319
312
  4. Ter dependencias sem ciclos
320
313
  5. Ter criterios de aceite verificaveis
321
- 6. Ser escrito no staging path fornecido usando Write tool
322
314
 
323
315
  ## Criterios de Qualidade
324
316
 
@@ -1,157 +1,11 @@
1
1
  #!/bin/bash
2
- # Post-Agent Artifact Relay Hook
3
- # TD-039: Automatically relays artifacts from staging to MinIO after agent completion.
2
+ # Post-Agent Artifact Relay Hook (DEPRECATED — ADR-012)
4
3
  #
5
- # Called as a PostToolUse hook on the Task matcher.
6
- # Reads stdin JSON with structure:
7
- # { "tool_name": "Task", "tool_input": { "subagent_type": "...", ... } }
4
+ # With ADR-012 F1, agents store artifacts directly via MCP artifactStore.
5
+ # This hook is no longer needed. Kept as documentation.
8
6
  #
9
- # Flow:
10
- # 1. Extract subagent_type from stdin
11
- # 2. Skip non-artifact agents (orchestrator, reviewer, docs-guardian, etc.)
12
- # 3. Get active workflow from API
13
- # 4. Login to get JWT token
14
- # 5. Call DELETE /api/v1/workflows/:id/pending-action to trigger relay
15
- # 6. Log result
16
-
17
- set -e
18
-
19
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20
- PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
21
- STATE_DIR="$PROJECT_ROOT/.orchestrator/.state"
22
- LOG_FILE="$STATE_DIR/relay-hook.log"
23
-
24
- # Ensure state directory exists
25
- mkdir -p "$STATE_DIR"
26
-
27
- # Log rotation: max 1MB
28
- MAX_LOG_SIZE=1048576
29
- if [ -f "$LOG_FILE" ]; then
30
- LOG_SIZE=$(stat -f%z "$LOG_FILE" 2>/dev/null || stat -c%s "$LOG_FILE" 2>/dev/null || echo 0)
31
- if [ "$LOG_SIZE" -gt "$MAX_LOG_SIZE" ]; then
32
- [ -f "${LOG_FILE}.1" ] && mv "${LOG_FILE}.1" "${LOG_FILE}.2"
33
- mv "$LOG_FILE" "${LOG_FILE}.1"
34
- fi
35
- fi
36
-
37
- log() {
38
- echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] $*" >> "$LOG_FILE"
39
- }
40
-
41
- # Configuration
42
- API_URL="${ORCHESTRATOR_API_URL:-http://localhost:3001}"
43
- AUTH_EMAIL="${ORCHESTRATOR_AUTH_EMAIL:-admin@orchestrator.local}"
44
- AUTH_PASSWORD="${ORCHESTRATOR_AUTH_PASSWORD:-admin123}"
45
-
46
- # Read stdin
47
- STDIN_DATA=""
48
- if [ ! -t 0 ]; then
49
- STDIN_DATA=$(cat)
50
- fi
51
-
52
- if [ -z "$STDIN_DATA" ]; then
53
- log "SKIP: No stdin data"
54
- exit 0
55
- fi
56
-
57
- # Extract agent type from stdin JSON
58
- AGENT_TYPE=$(echo "$STDIN_DATA" | node -e "
59
- let data = '';
60
- process.stdin.on('data', chunk => data += chunk);
61
- process.stdin.on('end', () => {
62
- try {
63
- const json = JSON.parse(data);
64
- const type = json.tool_input?.subagent_type
65
- || json.subagent_type
66
- || json.tool_input?.type
67
- || '';
68
- console.log(type);
69
- } catch { console.log(''); }
70
- });
71
- " 2>/dev/null)
72
-
73
- if [ -z "$AGENT_TYPE" ]; then
74
- log "SKIP: Could not extract agent type"
75
- exit 0
76
- fi
77
-
78
- # TD-039 Phase 3: Inverted whitelist → blacklist.
79
- # All agents produce artifacts EXCEPT orchestrator (coordinator only).
80
- case "$AGENT_TYPE" in
81
- orchestrator)
82
- log "SKIP: Agent '$AGENT_TYPE' is a coordinator, not an artifact producer"
83
- exit 0
84
- ;;
85
- *)
86
- log "RELAY: Agent '$AGENT_TYPE' completed, starting relay..."
87
- ;;
88
- esac
89
-
90
- # Get active workflow status
91
- STATUS_RESPONSE=$(curl -s -f "${API_URL}/api/v1/workflows/status" 2>/dev/null) || {
92
- log "SKIP: Could not reach API at ${API_URL}/api/v1/workflows/status"
93
- exit 0
94
- }
95
-
96
- WORKFLOW_ID=$(echo "$STATUS_RESPONSE" | node -e "
97
- let data = '';
98
- process.stdin.on('data', chunk => data += chunk);
99
- process.stdin.on('end', () => {
100
- try {
101
- const json = JSON.parse(data);
102
- // Support both { id } and { data: { id } } shapes
103
- const id = json.data?.id || json.id || '';
104
- console.log(id);
105
- } catch { console.log(''); }
106
- });
107
- " 2>/dev/null)
108
-
109
- if [ -z "$WORKFLOW_ID" ]; then
110
- log "SKIP: No active workflow found"
111
- exit 0
112
- fi
113
-
114
- log "RELAY: Active workflow=$WORKFLOW_ID"
115
-
116
- # Login to get JWT token
117
- LOGIN_PAYLOAD=$(node -e "console.log(JSON.stringify({email:'${AUTH_EMAIL}',password:'${AUTH_PASSWORD}'}))")
118
- LOGIN_RESPONSE=$(curl -s -f -X POST "${API_URL}/api/v1/auth/login" \
119
- -H "Content-Type: application/json" \
120
- -d "$LOGIN_PAYLOAD" 2>/dev/null) || {
121
- log "ERROR: Login failed"
122
- exit 0
123
- }
124
-
125
- TOKEN=$(echo "$LOGIN_RESPONSE" | node -e "
126
- let data = '';
127
- process.stdin.on('data', chunk => data += chunk);
128
- process.stdin.on('end', () => {
129
- try {
130
- const json = JSON.parse(data);
131
- console.log(json.data?.accessToken || json.accessToken || json.token || '');
132
- } catch { console.log(''); }
133
- });
134
- " 2>/dev/null)
135
-
136
- if [ -z "$TOKEN" ]; then
137
- log "ERROR: Could not extract token from login response"
138
- exit 0
139
- fi
140
-
141
- # Call relay endpoint: DELETE /api/v1/workflows/:id/pending-action
142
- RELAY_RESPONSE=$(curl -s -w "\n%{http_code}" -X DELETE \
143
- "${API_URL}/api/v1/workflows/${WORKFLOW_ID}/pending-action" \
144
- -H "Content-Type: application/json" \
145
- -H "Authorization: Bearer ${TOKEN}" \
146
- -d '{}' 2>/dev/null)
147
-
148
- HTTP_CODE=$(echo "$RELAY_RESPONSE" | tail -1)
149
- BODY=$(echo "$RELAY_RESPONSE" | sed '$d')
150
-
151
- if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "204" ]; then
152
- log "SUCCESS: Relay completed for workflow=$WORKFLOW_ID agent=$AGENT_TYPE http=$HTTP_CODE"
153
- else
154
- log "ERROR: Relay failed for workflow=$WORKFLOW_ID agent=$AGENT_TYPE http=$HTTP_CODE body=$BODY"
155
- fi
7
+ # Previous behavior: relayed artifacts from filesystem staging to MinIO.
8
+ # Now: agents call mcp__orchestrator-extended__artifactStore directly.
156
9
 
10
+ # No-op: agents handle artifact storage directly
157
11
  exit 0
@@ -1,139 +1,102 @@
1
1
  #!/bin/bash
2
- # Post-Implement Validation Hook
3
- # Validates orchestrator-index.json consistency after IMPLEMENT phase
4
- # Detects possible delegation bypass where code was written directly
5
- # instead of through the implementer subagent
2
+ # Post-Implement Validation Hook (v2 — REST API)
3
+ # Validates workflow consistency after IMPLEMENT phase.
4
+ # Defense-in-depth: agents track progress via MCP, this validates externally.
6
5
  #
7
6
  # Exit codes:
8
- # 0 = Validation passed or skipped (jq not available)
9
- # 1 = Warning detected (possible delegation bypass)
10
- #
11
- # Author: Orchestrator System
12
- # Version: 1.0.0
7
+ # 0 = Validation passed or skipped
8
+ # 1 = Warning detected (TDD violation detected)
13
9
 
14
10
  set -e
15
11
 
16
12
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17
13
  PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
18
- INDEX_FILE="$PROJECT_ROOT/.orchestrator/orchestrator-index.json"
14
+ STATE_DIR="$PROJECT_ROOT/.orchestrator/.state"
15
+
16
+ # API Configuration
17
+ API_URL="${ORCHESTRATOR_API_URL:-http://localhost:3001}"
18
+ AUTH_EMAIL="${ORCHESTRATOR_AUTH_EMAIL:-admin@orchestrator.local}"
19
+ AUTH_PASSWORD="${ORCHESTRATOR_AUTH_PASSWORD:-admin123}"
20
+ PROJECT_ID="${ORCHESTRATOR_PROJECT_ID:-d001d65d-25f5-4d13-b1dc-d006873e949c}"
19
21
 
20
- # Colors for output
22
+ # Colors
21
23
  RED='\033[0;31m'
22
24
  YELLOW='\033[1;33m'
23
25
  GREEN='\033[0;32m'
24
- CYAN='\033[0;36m'
25
- NC='\033[0m' # No Color
26
-
27
- log_info() {
28
- echo -e "${GREEN}[post-implement-validate]${NC} $1" >&2
29
- }
30
-
31
- log_warn() {
32
- echo -e "${YELLOW}[post-implement-validate] WARNING:${NC} $1" >&2
33
- }
34
-
35
- log_error() {
36
- echo -e "${RED}[post-implement-validate] ERROR:${NC} $1" >&2
37
- }
38
-
39
- log_debug() {
40
- if [ "${DEBUG:-false}" = "true" ]; then
41
- echo -e "${CYAN}[post-implement-validate] DEBUG:${NC} $1" >&2
26
+ NC='\033[0m'
27
+
28
+ log_info() { echo -e "${GREEN}[post-implement-validate]${NC} $1" >&2; }
29
+ log_warn() { echo -e "${YELLOW}[post-implement-validate] WARNING:${NC} $1" >&2; }
30
+
31
+ # Auth: get cached token
32
+ get_token() {
33
+ mkdir -p "$STATE_DIR"
34
+ local cached="$STATE_DIR/jwt-token"
35
+ if [ -f "$cached" ]; then
36
+ local age=$(( $(date +%s) - $(stat -c%Y "$cached" 2>/dev/null || stat -f%m "$cached" 2>/dev/null || echo 0) ))
37
+ if [ "$age" -lt 3500 ]; then
38
+ cat "$cached"
39
+ return
42
40
  fi
41
+ fi
42
+ local resp
43
+ resp=$(curl -s -f -X POST "${API_URL}/api/v1/auth/login" \
44
+ -H "Content-Type: application/json" \
45
+ -d "{\"email\":\"${AUTH_EMAIL}\",\"password\":\"${AUTH_PASSWORD}\"}" 2>/dev/null) || return 1
46
+ local token
47
+ token=$(echo "$resp" | node -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{try{const j=JSON.parse(d);console.log(j.data?.accessToken||j.accessToken||j.token||'')}catch{console.log('')}})" 2>/dev/null)
48
+ if [ -n "$token" ]; then
49
+ echo "$token" > "$cached"
50
+ echo "$token"
51
+ fi
43
52
  }
44
53
 
45
- # Check if jq is available
46
- if ! command -v jq &> /dev/null; then
47
- log_warn "jq not found, skipping validation (install jq for full validation)"
48
- exit 0
49
- fi
50
-
51
- # Check if orchestrator-index.json exists
52
- if [ ! -f "$INDEX_FILE" ]; then
53
- log_debug "orchestrator-index.json not found at $INDEX_FILE, skipping validation"
54
- exit 0
55
- fi
56
-
57
- # Read statistics from orchestrator-index.json
58
- TASKS_COMPLETED=$(jq -r '.statistics.tasksCompleted // 0' "$INDEX_FILE" 2>/dev/null || echo "0")
59
- TASKS_PENDING=$(jq -r '.statistics.tasksPending // 0' "$INDEX_FILE" 2>/dev/null || echo "0")
60
- CURRENT_PHASE=$(jq -r '.activeWorkflow.currentPhase // "unknown"' "$INDEX_FILE" 2>/dev/null || echo "unknown")
61
- STATUS=$(jq -r '.activeWorkflow.status // "unknown"' "$INDEX_FILE" 2>/dev/null || echo "unknown")
62
-
63
- # Count TypeScript files in src/ (if directory exists)
54
+ # Get workflow status from REST API
55
+ TOKEN=$(get_token) || { exit 0; } # Can't auth → skip silently
56
+
57
+ WORKFLOW_RESP=$(curl -s -f "${API_URL}/api/v1/workflows?status=in_progress" \
58
+ -H "Authorization: Bearer $TOKEN" \
59
+ -H "X-Project-ID: $PROJECT_ID" 2>/dev/null) || { exit 0; }
60
+
61
+ # Extract workflow info
62
+ WORKFLOW_INFO=$(echo "$WORKFLOW_RESP" | node -e "
63
+ let d='';
64
+ process.stdin.on('data',c=>d+=c);
65
+ process.stdin.on('end',()=>{
66
+ try {
67
+ const j=JSON.parse(d);
68
+ const wfs=j.data||j;
69
+ const wf=Array.isArray(wfs)?wfs[0]:wfs;
70
+ if(!wf){console.log('{}');return;}
71
+ console.log(JSON.stringify({
72
+ id:wf.id||'',
73
+ phase:wf.currentPhase||wf.phase||'',
74
+ status:wf.status||''
75
+ }));
76
+ }catch{console.log('{}')}
77
+ });
78
+ " 2>/dev/null)
79
+
80
+ CURRENT_PHASE=$(echo "$WORKFLOW_INFO" | node -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{try{console.log(JSON.parse(d).phase||'unknown')}catch{console.log('unknown')}})" 2>/dev/null)
81
+ STATUS=$(echo "$WORKFLOW_INFO" | node -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{try{console.log(JSON.parse(d).status||'unknown')}catch{console.log('unknown')}})" 2>/dev/null)
82
+
83
+ # Count source and test files
64
84
  TS_FILES_COUNT=0
65
85
  if [ -d "$PROJECT_ROOT/src" ]; then
66
- TS_FILES_COUNT=$(find "$PROJECT_ROOT/src" -name "*.ts" 2>/dev/null | wc -l | tr -d ' ' || echo "0")
86
+ TS_FILES_COUNT=$(find "$PROJECT_ROOT/src" -name "*.ts" 2>/dev/null | wc -l | tr -d ' ')
67
87
  fi
68
-
69
- # Count test files
70
88
  TEST_FILES_COUNT=0
71
89
  if [ -d "$PROJECT_ROOT/tests" ]; then
72
- TEST_FILES_COUNT=$(find "$PROJECT_ROOT/tests" -name "*.spec.ts" -o -name "*.test.ts" 2>/dev/null | wc -l | tr -d ' ' || echo "0")
90
+ TEST_FILES_COUNT=$(find "$PROJECT_ROOT/tests" \( -name "*.test.ts" -o -name "*.spec.ts" \) 2>/dev/null | wc -l | tr -d ' ')
73
91
  fi
74
92
 
75
- log_info "Validating IMPLEMENT phase consistency..."
76
- log_info " Current Phase: $CURRENT_PHASE"
77
- log_info " Status: $STATUS"
78
- log_info " Tasks Completed: $TASKS_COMPLETED"
79
- log_info " Tasks Pending: $TASKS_PENDING"
80
- log_info " TypeScript Files: $TS_FILES_COUNT"
81
- log_info " Test Files: $TEST_FILES_COUNT"
82
-
83
- # Detection logic
84
- WARNINGS=0
85
- MESSAGES=()
86
-
87
- # Check 1: Few tasks completed but many pending (primary indicator)
88
- if [ "$TASKS_COMPLETED" -le 1 ] && [ "$TASKS_PENDING" -gt 5 ]; then
89
- MESSAGES+=("Only $TASKS_COMPLETED task(s) completed but $TASKS_PENDING pending.")
90
- MESSAGES+=("This suggests the implementer agent may not have been properly invoked.")
91
- WARNINGS=$((WARNINGS + 1))
92
- fi
93
+ log_info "Phase: $CURRENT_PHASE | Status: $STATUS | Src: $TS_FILES_COUNT | Tests: $TEST_FILES_COUNT"
93
94
 
94
- # Check 2: Many source files but few tasks completed
95
- if [ "$TS_FILES_COUNT" -gt 10 ] && [ "$TASKS_COMPLETED" -lt 5 ]; then
96
- MESSAGES+=("Found $TS_FILES_COUNT TypeScript files but only $TASKS_COMPLETED tasks completed.")
97
- MESSAGES+=("Code may have been generated without proper task tracking.")
98
- WARNINGS=$((WARNINGS + 1))
99
- fi
100
-
101
- # Check 3: Status still "ready_for_implementation" after code exists
102
- if [ "$STATUS" = "ready_for_implementation" ] && [ "$TS_FILES_COUNT" -gt 5 ]; then
103
- MESSAGES+=("Status is still 'ready_for_implementation' but $TS_FILES_COUNT code files exist.")
104
- MESSAGES+=("Workflow state may not have been updated correctly.")
105
- WARNINGS=$((WARNINGS + 1))
106
- fi
107
-
108
- # Check 4: Source files exist but no test files (TDD violation)
95
+ # TDD check: source files without tests
109
96
  if [ "$TS_FILES_COUNT" -gt 5 ] && [ "$TEST_FILES_COUNT" -eq 0 ]; then
110
- MESSAGES+=("Found $TS_FILES_COUNT source files but no test files.")
111
- MESSAGES+=("TDD methodology may not have been followed.")
112
- WARNINGS=$((WARNINGS + 1))
97
+ log_warn "Found $TS_FILES_COUNT source files but no test files. TDD may not have been followed."
98
+ exit 1
113
99
  fi
114
100
 
115
- # Summary
116
- if [ "$WARNINGS" -gt 0 ]; then
117
- echo "" >&2
118
- log_warn "============================================"
119
- log_warn "Detected $WARNINGS potential issue(s):"
120
- log_warn "============================================"
121
- for msg in "${MESSAGES[@]}"; do
122
- log_warn " - $msg"
123
- done
124
- echo "" >&2
125
- log_warn "Possible causes:"
126
- log_warn " 1. Implementer agent was not invoked via Task tool"
127
- log_warn " 2. Code was written directly instead of through delegation"
128
- log_warn " 3. orchestrator-index.json was not updated during implementation"
129
- echo "" >&2
130
- log_warn "Recommended actions:"
131
- log_warn " 1. Review CLAUDE.md section: MANDATORY: IMPLEMENT Phase Delegation"
132
- log_warn " 2. Ensure Task tool is used with subagent_type='implementer'"
133
- log_warn " 3. Update orchestrator-index.json with correct task progress"
134
- echo "" >&2
135
- exit 1
136
- else
137
- log_info "Validation passed. No issues detected."
138
- exit 0
139
- fi
101
+ log_info "Validation passed."
102
+ exit 0