acpx-team 0.2.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.
@@ -0,0 +1,374 @@
1
+ #!/usr/bin/env bash
2
+ # acpx-council — High-level CLI for multi-agent collaboration
3
+ # One command to run any protocol with any team preset
4
+ #
5
+ # Usage:
6
+ # acpx-council review <file> # Auto code review
7
+ # acpx-council council <task> # Full council with auto-protocol
8
+ # acpx-council debate <task> # Adversarial debate
9
+ # acpx-council synthesize # Synthesize current workspace
10
+ # acpx-council execute # Execute plan from workspace
11
+ # acpx-council status # Show workspace status
12
+ # acpx-council roles [list|create|infer] # Manage roles
13
+ # acpx-council workspace [init|cleanup|archive] # Manage workspace
14
+ #
15
+ # Examples:
16
+ # acpx-council review src/auth.ts
17
+ # acpx-council council "Should we migrate from REST to tRPC?" --protocol adversarial
18
+ # acpx-council council "Add Redis caching to the API" --roles security,perf,testing
19
+ # acpx-council council "Review PR #42" --agents claude,codex,gemini --preset code_review
20
+ # acpx-council council "Refactor auth module" --single-agent opencode --sessions 3
21
+ # acpx-council status
22
+ # acpx-council execute
23
+ # acpx-council roles infer "Add Stripe payment integration"
24
+
25
+ set -euo pipefail
26
+
27
+ ACPX_ROOT="${ACPX_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
28
+ ACPX_WORKSPACE="${ACPX_WORKSPACE:-.acpx-workspace}"
29
+
30
+ # Source libraries
31
+ source "${ACPX_ROOT}/lib/workspace.sh"
32
+ source "${ACPX_ROOT}/lib/roles.sh"
33
+ source "${ACPX_ROOT}/lib/protocols.sh"
34
+
35
+ # ─── Color Output ──────────────────────────────────────────────
36
+
37
+ RED='\033[0;31m'
38
+ GREEN='\033[0;32m'
39
+ YELLOW='\033[1;33m'
40
+ BLUE='\033[0;34m'
41
+ NC='\033[0m' # No Color
42
+
43
+ info() { echo -e "${BLUE}[acpx]${NC} $*"; }
44
+ ok() { echo -e "${GREEN}[ok]${NC} $*"; }
45
+ warn() { echo -e "${YELLOW}[warn]${NC} $*"; }
46
+ err() { echo -e "${RED}[error]${NC} $*" >&2; }
47
+
48
+ # ─── Argument Parsing ──────────────────────────────────────────
49
+
50
+ cmd="${1:-help}"
51
+ shift || true
52
+
53
+ # Default options
54
+ PROTOCOL="auto"
55
+ AGENTS="auto"
56
+ ROLES="auto"
57
+ ORCHESTRATOR="claude"
58
+ PRESET=""
59
+ TASK=""
60
+ FILE=""
61
+ SINGLE_AGENT=""
62
+ NUM_SESSIONS=3
63
+
64
+ parse_opts() {
65
+ while [[ $# -gt 0 ]]; do
66
+ case "$1" in
67
+ --protocol|-p)
68
+ PROTOCOL="$2"; shift 2 ;;
69
+ --agents|-a)
70
+ AGENTS="$2"; shift 2 ;;
71
+ --roles|-r)
72
+ ROLES="$2"; shift 2 ;;
73
+ --orchestrator|-o)
74
+ ORCHESTRATOR="$2"; shift 2 ;;
75
+ --preset|-t)
76
+ PRESET="$2"; shift 2 ;;
77
+ --single-agent|-s)
78
+ SINGLE_AGENT="$2"; shift 2 ;;
79
+ --sessions|-n)
80
+ NUM_SESSIONS="$2"; shift 2 ;;
81
+ --workspace|-w)
82
+ ACPX_WORKSPACE="$2"; shift 2 ;;
83
+ --help|-h)
84
+ usage; exit 0 ;;
85
+ *)
86
+ if [[ -z "$TASK" && -z "$FILE" ]]; then
87
+ # Check if it's a file path
88
+ if [[ -f "$1" ]]; then
89
+ FILE="$1"
90
+ else
91
+ TASK="$1"
92
+ fi
93
+ fi
94
+ shift ;;
95
+ esac
96
+ done
97
+ }
98
+
99
+ # ─── Commands ──────────────────────────────────────────────────
100
+
101
+ cmd_review() {
102
+ local target="${FILE:-$1}"
103
+ if [[ ! -f "$target" ]]; then
104
+ err "File not found: $target"
105
+ exit 1
106
+ fi
107
+
108
+ local content
109
+ content=$(cat "$target")
110
+
111
+ local task="Review the file ${target} for bugs, security issues, performance problems, and code quality.
112
+ File contents:
113
+ \`\`\`
114
+ ${content}
115
+ \`\`\`"
116
+
117
+ if [[ "$PROTOCOL" == "auto" ]]; then
118
+ PROTOCOL="role-council"
119
+ fi
120
+
121
+ if [[ "$ROLES" == "auto" ]]; then
122
+ ROLES="security,perf,testing,maintainer"
123
+ fi
124
+
125
+ info "Reviewing ${target}..."
126
+ cmd_council_impl "$task"
127
+ }
128
+
129
+ cmd_council() {
130
+ if [[ -z "$TASK" && -z "$FILE" ]]; then
131
+ err "Missing task description. Usage: acpx-council council <task>"
132
+ exit 1
133
+ fi
134
+
135
+ # If file provided, include its contents
136
+ local task="${TASK}"
137
+ if [[ -n "$FILE" ]]; then
138
+ local content
139
+ content=$(cat "$FILE")
140
+ task="${TASK}
141
+
142
+ File: ${FILE}
143
+ \`\`\`
144
+ ${content}
145
+ \`\`\`"
146
+ fi
147
+
148
+ cmd_council_impl "$task"
149
+ }
150
+
151
+ cmd_council_impl() {
152
+ local task="$1"
153
+
154
+ # Handle single-agent multi-session mode
155
+ if [[ -n "$SINGLE_AGENT" ]]; then
156
+ info "Single-agent mode: using ${SINGLE_AGENT} with ${NUM_SESSIONS} sessions"
157
+ local -a agent_list=()
158
+ for i in $(seq 1 "$NUM_SESSIONS"); do
159
+ agent_list+=("${SINGLE_AGENT}")
160
+ done
161
+ AGENTS=$(IFS=,; echo "${agent_list[*]}")
162
+ fi
163
+
164
+ # Handle presets — map preset to roles
165
+ if [[ -n "$PRESET" ]]; then
166
+ case "$PRESET" in
167
+ code_review) ROLES="security,perf,testing,maintainer,dx" ;;
168
+ security_audit) ROLES="security,skeptic,architect,dx,testing" ;;
169
+ architecture_review) ROLES="architect,perf,skeptic,maintainer,testing" ;;
170
+ devil_advocate) ROLES="skeptic,skeptic,architect,maintainer" ;;
171
+ balanced) ROLES="neutral,neutral,neutral" ;;
172
+ build_deploy) ROLES="architect,testing,maintainer" ;;
173
+ *) warn "Unknown preset: ${PRESET}. Using auto roles." ;;
174
+ esac
175
+ fi
176
+
177
+ # Auto-select protocol
178
+ if [[ "$PROTOCOL" == "auto" ]]; then
179
+ PROTOCOL=$(protocol_auto_select "$task")
180
+ info "Auto-selected protocol: ${PROTOCOL}"
181
+ fi
182
+
183
+ # Run the selected protocol
184
+ case "$PROTOCOL" in
185
+ fanout|fan-out|1)
186
+ protocol_fanout "$task" "$AGENTS" "$ORCHESTRATOR" ;;
187
+ deliberation|round-robin|2)
188
+ protocol_deliberation "$task" "$AGENTS" "$ORCHESTRATOR" ;;
189
+ role-council|council|3)
190
+ protocol_role_council "$task" "$AGENTS" "$ROLES" "$ORCHESTRATOR" ;;
191
+ adversarial|debate|4)
192
+ protocol_adversarial "$task" "$AGENTS" "$ORCHESTRATOR" ;;
193
+ pipeline|sequential|5)
194
+ protocol_pipeline "$task" "$AGENTS" "$ORCHESTRATOR" ;;
195
+ *)
196
+ protocol_role_council "$task" "$AGENTS" "$ROLES" "$ORCHESTRATOR" ;;
197
+ esac
198
+
199
+ ok "Council complete. Results in ${ACPX_WORKSPACE}/"
200
+ workspace_status
201
+ }
202
+
203
+ cmd_synthesize() {
204
+ if [[ ! -d "$ACPX_WORKSPACE" ]]; then
205
+ err "No active workspace. Run a council first."
206
+ exit 1
207
+ fi
208
+
209
+ local round="${1:-1}"
210
+ info "Synthesizing round ${round}..."
211
+ synthesize_round "$round" "$ORCHESTRATOR"
212
+ ok "Synthesis written to ${ACPX_WORKSPACE}/synynthesis.md"
213
+ }
214
+
215
+ cmd_execute() {
216
+ if [[ ! -f "$ACPX_WORKSPACE/plan.md" ]]; then
217
+ err "No plan found. Run a council first to generate a plan."
218
+ exit 1
219
+ fi
220
+
221
+ info "Executing plan..."
222
+ protocol_execute "$ACPX_WORKSPACE/plan.md" "$AGENTS" "$ORCHESTRATOR"
223
+ ok "Execution complete."
224
+ }
225
+
226
+ cmd_status() {
227
+ workspace_status
228
+ }
229
+
230
+ cmd_roles() {
231
+ local subcmd="${1:-list}"
232
+ shift || true
233
+
234
+ case "$subcmd" in
235
+ list|ls)
236
+ role_list
237
+ ;;
238
+ create|new)
239
+ if [[ -z "${1:-}" ]]; then
240
+ err "Usage: acpx-council roles create <name> [focus] [technologies]"
241
+ exit 1
242
+ fi
243
+ role_create "$1" "${2:-General analysis}" "${3:-}"
244
+ ;;
245
+ infer|auto)
246
+ if [[ -z "${1:-}" ]]; then
247
+ err "Usage: acpx-council roles infer <task description>"
248
+ exit 1
249
+ fi
250
+ info "Inferred roles for: $1"
251
+ role_infer_from_task "$1"
252
+ ;;
253
+ *)
254
+ err "Unknown subcommand: ${subcmd}"
255
+ echo "Available: list, create, infer"
256
+ exit 1
257
+ ;;
258
+ esac
259
+ }
260
+
261
+ cmd_workspace() {
262
+ local subcmd="${1:-status}"
263
+ shift || true
264
+
265
+ case "$subcmd" in
266
+ init)
267
+ if [[ -z "${1:-}" ]]; then
268
+ err "Usage: acpx-council workspace init <task>"
269
+ exit 1
270
+ fi
271
+ workspace_init "$1" "${2:-auto}"
272
+ ok "Workspace initialized at ${ACPX_WORKSPACE}"
273
+ ;;
274
+ cleanup|clean|rm)
275
+ workspace_cleanup
276
+ ok "Workspace cleaned up."
277
+ ;;
278
+ archive|save)
279
+ workspace_archive "${1:-council-$(date +%Y%m%d-%H%M%S)}"
280
+ ;;
281
+ status)
282
+ workspace_status
283
+ ;;
284
+ *)
285
+ err "Unknown subcommand: ${subcmd}"
286
+ echo "Available: init, cleanup, archive, status"
287
+ exit 1
288
+ ;;
289
+ esac
290
+ }
291
+
292
+ # ─── Usage ─────────────────────────────────────────────────────
293
+
294
+ usage() {
295
+ cat <<'USAGE'
296
+ acpx-council — Multi-agent collaboration CLI
297
+
298
+ Usage:
299
+ acpx-council <command> [options] [task]
300
+
301
+ Commands:
302
+ review <file> Code review with auto-assigned expert roles
303
+ council <task> Run a multi-agent council with auto-selected protocol
304
+ debate <task> Adversarial debate (advocate vs critic + judge)
305
+ synthesize Synthesize current workspace outputs into consensus
306
+ execute Execute the plan from current workspace
307
+ status Show current workspace status
308
+ roles <subcommand> Manage roles (list, create, infer)
309
+ workspace <subcmd> Manage workspace (init, cleanup, archive, status)
310
+
311
+ Options:
312
+ --protocol, -p Protocol: auto|fanout|deliberation|role-council|adversarial|pipeline
313
+ --agents, -a Agents: auto|comma-separated (e.g., claude,codex,gemini)
314
+ --roles, -r Roles: auto|comma-separated (e.g., security,perf,testing)
315
+ --orchestrator, -o Synthesis agent (default: claude)
316
+ --preset, -t Team preset: code_review|security_audit|architecture_review|devil_advocate|balanced|build_deploy
317
+ --single-agent, -s Use one agent client with multiple sessions (e.g., -s opencode)
318
+ --sessions, -n Number of sessions for single-agent mode (default: 3)
319
+ --workspace, -w Workspace directory (default: .acpx-workspace)
320
+
321
+ Examples:
322
+ # Quick code review
323
+ acpx-council review src/auth.ts
324
+
325
+ # Full council with auto-everything
326
+ acpx-council council "Should we use Redis or Memcached for session caching?"
327
+
328
+ # Adversarial debate
329
+ acpx-council council "Migrate to tRPC?" --protocol adversarial
330
+
331
+ # Single agent (OpenCode) with 5 role-playing sessions
332
+ acpx-council council "Refactor auth module" --single-agent opencode --sessions 5
333
+
334
+ # Custom roles
335
+ acpx-council council "Add Stripe integration" --roles "security,payments,testing,dx"
336
+
337
+ # Security audit preset
338
+ acpx-council council "Review login flow" --preset security_audit
339
+
340
+ # Check status
341
+ acpx-council status
342
+
343
+ # Execute the plan
344
+ acpx-council execute
345
+
346
+ # Infer roles from a task
347
+ acpx-council roles infer "Add PostgreSQL migration with Prisma"
348
+
349
+ # Create a custom role
350
+ acpx-council roles create "database-expert" "Database optimization" "PostgreSQL,Prisma"
351
+ USAGE
352
+ }
353
+
354
+ # ─── Main ──────────────────────────────────────────────────────
355
+
356
+ parse_opts "$@"
357
+
358
+ case "$cmd" in
359
+ review) cmd_review "$@" ;;
360
+ council) cmd_council ;;
361
+ debate) PROTOCOL="adversarial"; cmd_council ;;
362
+ synthesize) cmd_synthesize ;;
363
+ execute) cmd_execute ;;
364
+ status) cmd_status ;;
365
+ roles) cmd_roles "$@" ;;
366
+ workspace) cmd_workspace "$@" ;;
367
+ help|--help|-h)
368
+ usage ;;
369
+ *)
370
+ # Treat unknown command as a task
371
+ TASK="$cmd $*"
372
+ cmd_council
373
+ ;;
374
+ esac
@@ -0,0 +1,245 @@
1
+ # Agent Client Profiles — capability definitions for acpx council
2
+ # Used for automatic role assignment and single-agent multi-session support
3
+
4
+ agents:
5
+ claude:
6
+ command: "acpx claude"
7
+ install: "npm i -g @anthropic-ai/claude-code"
8
+ supports_plan_mode: true
9
+ supports_sessions: true
10
+ strengths:
11
+ - complex-reasoning
12
+ - architecture
13
+ - security
14
+ - code-quality
15
+ - debugging
16
+ - long-context
17
+ weaknesses:
18
+ - speed # slower but more thorough
19
+ preferred_roles:
20
+ - architect
21
+ - security
22
+ - maintainer
23
+ - skeptic
24
+ notes: "Best for complex reasoning, security analysis, and code quality assessment."
25
+
26
+ codex:
27
+ command: "acpx codex"
28
+ install: "npm i -g @openai/codex"
29
+ supports_plan_mode: true
30
+ supports_sessions: true
31
+ strengths:
32
+ - implementation
33
+ - testing
34
+ - algorithmic-analysis
35
+ - rapid-prototyping
36
+ weaknesses:
37
+ - complex-reasoning
38
+ - long-context
39
+ preferred_roles:
40
+ - perf
41
+ - testing
42
+ - maintainer
43
+ notes: "Strong at implementation and testing tasks."
44
+
45
+ gemini:
46
+ command: "acpx gemini"
47
+ install: "npm i -g @anthropic-ai/gemini-cli"
48
+ supports_plan_mode: true
49
+ supports_sessions: true
50
+ strengths:
51
+ - broad-knowledge
52
+ - performance
53
+ - multimodal
54
+ - long-context
55
+ weaknesses:
56
+ - domain-specific-depth
57
+ preferred_roles:
58
+ - perf
59
+ - neutral
60
+ - testing
61
+ notes: "Good broad perspective and performance analysis."
62
+
63
+ opencode:
64
+ command: "acpx opencode"
65
+ install: "npm i -g opencode-ai"
66
+ supports_plan_mode: true
67
+ supports_sessions: true
68
+ strengths:
69
+ - implementation
70
+ - flexibility
71
+ - local-first
72
+ weaknesses:
73
+ - cloud-scale-reasoning
74
+ preferred_roles:
75
+ - maintainer
76
+ - testing
77
+ - dx
78
+ notes: "Flexible local agent, good for implementation and DX."
79
+
80
+ openclaw:
81
+ command: "acpx openclaw"
82
+ install: "npm i -g @openclaw/acpx"
83
+ supports_plan_mode: true
84
+ supports_sessions: true
85
+ strengths:
86
+ - protocol-native
87
+ - headless
88
+ - automation
89
+ - multi-agent-orchestration
90
+ weaknesses:
91
+ - interactive
92
+ preferred_roles:
93
+ - neutral
94
+ - any # OpenClaw is the protocol layer itself
95
+ notes: "The ACP protocol implementation. Headless agent client that powers acpx under the hood. Can act as any role since it's protocol-native."
96
+
97
+ cursor:
98
+ command: "acpx cursor"
99
+ install: "Cursor app required"
100
+ supports_plan_mode: false
101
+ supports_sessions: false
102
+ strengths:
103
+ - ide-integration
104
+ - code-completion
105
+ - refactoring
106
+ weaknesses:
107
+ - headless-mode
108
+ - session-management
109
+ preferred_roles:
110
+ - dx
111
+ - maintainer
112
+ notes: "IDE-native, limited CLI support."
113
+
114
+ copilot:
115
+ command: "acpx copilot"
116
+ install: "npm i -g @githubnext/github-copilot-cli"
117
+ supports_plan_mode: false
118
+ supports_sessions: false
119
+ strengths:
120
+ - ide-integration
121
+ - code-suggestions
122
+ weaknesses:
123
+ - headless-mode
124
+ - complex-reasoning
125
+ preferred_roles:
126
+ - dx
127
+ - maintainer
128
+ notes: "IDE-native, limited CLI support."
129
+
130
+ pi:
131
+ command: "acpx pi"
132
+ install: "github.com/mariozechner/pi"
133
+ supports_plan_mode: false
134
+ supports_sessions: true
135
+ strengths:
136
+ - lightweight
137
+ - fast
138
+ weaknesses:
139
+ - complex-reasoning
140
+ preferred_roles:
141
+ - neutral
142
+ notes: "Lightweight agent."
143
+
144
+ qwen:
145
+ command: "acpx qwen"
146
+ install: "npm i -g @qwen/qwen-code"
147
+ supports_plan_mode: true
148
+ supports_sessions: true
149
+ strengths:
150
+ - multilingual
151
+ - implementation
152
+ weaknesses:
153
+ - english-heavy-contexts
154
+ preferred_roles:
155
+ - maintainer
156
+ - testing
157
+ notes: "Strong multilingual support."
158
+
159
+ # Role-to-task mapping for auto role inference
160
+ role_inference:
161
+ keywords:
162
+ security:
163
+ - "security"
164
+ - "vulnerability"
165
+ - "auth"
166
+ - "authentication"
167
+ - "authorization"
168
+ - "XSS"
169
+ - "SQL injection"
170
+ - "OWASP"
171
+ - "encryption"
172
+ - "token"
173
+ architect:
174
+ - "architecture"
175
+ - "design"
176
+ - "system design"
177
+ - "scalability"
178
+ - "migration"
179
+ - "refactor"
180
+ - "microservice"
181
+ - "monorepo"
182
+ perf:
183
+ - "performance"
184
+ - "latency"
185
+ - "throughput"
186
+ - "optimization"
187
+ - "bottleneck"
188
+ - "caching"
189
+ - "memory"
190
+ - "slow"
191
+ testing:
192
+ - "test"
193
+ - "coverage"
194
+ - "edge case"
195
+ - "regression"
196
+ - "integration test"
197
+ - "unit test"
198
+ - "e2e"
199
+ database:
200
+ - "database"
201
+ - "SQL"
202
+ - "query"
203
+ - "index"
204
+ - "migration"
205
+ - "schema"
206
+ - "PostgreSQL"
207
+ - "Redis"
208
+ - "MongoDB"
209
+ - "Prisma"
210
+ - "Drizzle"
211
+ frontend:
212
+ - "UI"
213
+ - "frontend"
214
+ - "React"
215
+ - "Next.js"
216
+ - "CSS"
217
+ - "component"
218
+ - "accessibility"
219
+ - "a11y"
220
+ payments:
221
+ - "payment"
222
+ - "Stripe"
223
+ - "billing"
224
+ - "checkout"
225
+ - "subscription"
226
+ devops:
227
+ - "deploy"
228
+ - "CI/CD"
229
+ - "Docker"
230
+ - "Kubernetes"
231
+ - "infrastructure"
232
+ - "pipeline"
233
+ dx:
234
+ - "developer experience"
235
+ - "DX"
236
+ - "API design"
237
+ - "ergonomics"
238
+ - "error message"
239
+ - "usability"
240
+ i18n:
241
+ - "internationalization"
242
+ - "i18n"
243
+ - "localization"
244
+ - "locale"
245
+ - "translation"
@@ -0,0 +1,41 @@
1
+ # Role Templates Directory
2
+
3
+ Drop `.md` files here to register custom role templates.
4
+
5
+ ## Naming Convention
6
+
7
+ - `{role-name}.md` — Round 1 prompt template
8
+ - `{role-name}-deliberation.md` — Round 2 deliberation template (optional)
9
+
10
+ ## Example: `database.md`
11
+
12
+ ```markdown
13
+ [ROLE: Database Expert]
14
+ Analyze this from a database perspective. Focus on:
15
+ - Query efficiency and index usage
16
+ - Schema design and normalization
17
+ - Transaction isolation and locking
18
+ - Migration safety and rollback strategy
19
+ - Connection pooling and resource management
20
+ ```
21
+
22
+ ## Example: `database-deliberation.md`
23
+
24
+ ```markdown
25
+ [ROLE: Database Expert — Deliberation]
26
+ Other reviewers provided their analysis below. Maintain your database perspective.
27
+ Check if their proposals introduce query performance regressions or schema issues.
28
+ ```
29
+
30
+ ## Builtin Roles
31
+
32
+ The following roles are builtin (defined in `lib/roles.sh`) and don't need template files:
33
+
34
+ - `security` — Vulnerability and auth analysis
35
+ - `architect` — System design and scalability
36
+ - `skeptic` — Devil's advocate, find problems
37
+ - `perf` — Latency, throughput, resource optimization
38
+ - `testing` — Coverage gaps, edge cases, regression risk
39
+ - `maintainer` — Code quality, readability, long-term health
40
+ - `dx` — Developer experience, API ergonomics
41
+ - `neutral` — Balanced, unbiased analysis