agent-composer 0.1.5 → 0.1.7

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/dist/index.js CHANGED
@@ -11,7 +11,12 @@ import { ProviderRegistry } from "./registry.js";
11
11
  import { createComposerServer } from "./server.js";
12
12
  import { runInit, runGlobalInit } from "./cli/init.js";
13
13
  const CONFIG_PATH = process.env["COMPOSER_CONFIG"] ?? "composer.config.json";
14
- const ENV_PATH = process.env["COMPOSER_ENV"] ?? ".env.json";
14
+ // Pass undefined when COMPOSER_ENV is unset so loadEnvJson uses the lookup
15
+ // chain (cwd → ~/.config/composer/). Passing ".env.json" as a literal explicit
16
+ // path makes loadEnvJson skip the global fallback — broke running
17
+ // agent-composer from any cwd that lacks a local .env.json (manifested as
18
+ // "missing ANTHROPIC_AUTH_TOKEN" from composer_code).
19
+ const ENV_PATH = process.env["COMPOSER_ENV"];
15
20
  async function main() {
16
21
  const subcommand = process.argv[2];
17
22
  const flag = process.argv[3];
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,2EAA2E;AAC3E,kEAAkE;AAClE,EAAE;AACF,oDAAoD;AACpD,2EAA2E;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,sBAAsB,CAAC;AAC7E,MAAM,QAAQ,GAAG,OAAO,CAAC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,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,wEAAwE;IACxE,2BAA2B;IAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,mDAAmD,WAAW,IAAI,CACnE,CAAC;AACJ,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uCAAuC,GAAG,IAAI,CAAC,CAAC;IACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,6 +1,14 @@
1
1
  // Wave 1 F1.1 — Anthropic-SDK-shaped provider, used against GLM's
2
2
  // Anthropic-compatible endpoint and any future compatible host.
3
3
  // Real network calls happen here; tests inject a fake via clientFactory.
4
+ //
5
+ // KNOWN BUG: provider uses non-streaming messages.create. The Anthropic SDK
6
+ // refuses non-streaming requests when configured size suggests >10 min
7
+ // duration ("Streaming is required for operations that may take longer than
8
+ // 10 minutes"). Workaround: keep role.maxTokens ≲ 16k and
9
+ // role.thinking.budgetTokens ≲ 8k. Proper fix: switch to .stream()
10
+ // (or .create({stream:true})) and aggregate events — requires updating
11
+ // AnthropicLike interface + test mocks.
4
12
  import Anthropic from "@anthropic-ai/sdk";
5
13
  const DEFAULT_FACTORY = ({ baseURL, apiKey }) => new Anthropic({ baseURL, apiKey });
6
14
  const DEFAULT_MAX_TOKENS = 4096;
@@ -1 +1 @@
1
- {"version":3,"file":"AnthropicCompatibleProvider.js","sourceRoot":"","sources":["../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3E,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,OAAO;YACL,IAAI;YACJ,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,YAAY;YAChC,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,aAAa;SACnC,CAAC;IACJ,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-composer",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "description": "Multi-agent orchestration MCP server. Claude orchestrates; GLM and agy do the work.",
6
6
  "bin": {
@@ -1,27 +1,32 @@
1
1
  ---
2
2
  name: coder
3
- description: Use when the orchestrator needs code written, refactored, debugged, or implemented. Delegates the actual coding to the composer_code MCP tool.
4
- tools: mcp__composer__composer_code, Read, Glob
3
+ description: Use when the orchestrator needs code written, refactored, debugged, or implemented. Delegates code generation to composer_code (GLM) and applies the patch to disk.
4
+ tools: mcp__composer__composer_code, Read, Glob, Edit, Write
5
5
  model: haiku
6
6
  ---
7
7
 
8
- You are the Composer **Coder** subagent. Your only job is to call the
9
- `composer_code` MCP tool with the orchestrator's implementation request
10
- and return its output.
8
+ You are the Composer **Coder** subagent. Your job is two-step:
9
+ 1. Call `mcp__composer__composer_code` to get the code/patch from GLM.
10
+ 2. Apply that patch to disk using `Edit` or `Write`.
11
11
 
12
- # What you DO
12
+ # Workflow
13
13
 
14
- - Receive the orchestrator's `{ prompt, context? }` brief.
15
- - Use `Read` / `Glob` to pin exact file paths, surrounding code, and
16
- imports into the `prompt` / `context` arguments — the coder provider
17
- cannot see the repo itself.
18
- - Call `mcp__composer__composer_code` once.
19
- - Return the tool output verbatim (usually a diff or code block).
14
+ 1. Receive the orchestrator's `{ prompt, context? }` brief.
15
+ 2. Use `Read` / `Glob` to pin exact file paths, surrounding code, and imports — feed these into the `prompt` / `context` arguments. GLM cannot see the repo itself.
16
+ 3. Call `mcp__composer__composer_code` ONCE with the assembled brief.
17
+ 4. Parse GLM's response:
18
+ - If GLM returns a unified diff → apply via `Edit` (or multiple `Edit` calls).
19
+ - If GLM returns full file content use `Write`.
20
+ - If GLM returns a code block targeting a specific location → use `Edit` with the matching `old_string` / `new_string`.
21
+ 5. After applying, use `Read` to verify the change landed at the expected lines.
22
+ 6. Return a 1-3 sentence summary of what changed (file + line range + intent). DO NOT return GLM's raw output — only the final result.
20
23
 
21
- # What you DO NOT do
24
+ # Hard rules
22
25
 
23
- - DO NOT write code yourself.
24
- - DO NOT edit files.
25
- - DO NOT execute commands.
26
- - DO NOT call any tool other than `composer_code`, `Read`, or `Glob`.
26
+ - DO call `composer_code` exactly ONCE per task. If GLM's output is malformed, fail to the orchestrator with a short error.
27
+ - DO apply patches via Edit/Write — that's why those tools are in your list.
28
+ - DO use Read post-edit to verify.
29
+ - DO NOT write code yourself or modify GLM's output beyond mechanical patch application.
30
+ - DO NOT call composer_code more than once — if it fails, return the error.
31
+ - DO NOT use Bash/sed/awk/perl. Edit/Write only.
27
32
  - DO NOT critique the returned code — that is the reviewer's job.
@@ -1,72 +1,72 @@
1
1
  #!/usr/bin/env bash
2
- # Wave 1 F1.5 — Composer boundary enforcement (PreToolUse hook).
3
- # Contract per docs/adr/0001-contracts.md §C0.4:
4
- # stdin: Anthropic PreToolUse JSON
5
- # stdout: optional {"permissionDecision":"deny"|"allow"|"ask", ...}
6
- # exit: always 0; semantics carried by JSON
7
- # Fail-closed: any unexpected condition (missing jq / empty stdin /
8
- # malformed JSON / absent tool_name) MUST emit a deny payload.
2
+ # Composer boundary enforcement (PreToolUse hook) — pragmatic profile for
3
+ # daily dev in arbitrary projects.
4
+ #
5
+ # Behaviour:
6
+ # - Denies Edit/Write/NotebookEdit on the main thread → forces dispatch via
7
+ # Task(subagent_type="coder") so GLM does code changes.
8
+ # - Allows Bash on the main thread (light shell ops stay inline).
9
+ # - Allows Edit/Write inside a subagent — that is how `coder` applies the
10
+ # patch composer_code returned. Detection covers three field-name shapes
11
+ # Claude Code has emitted across versions: transcript_path containing
12
+ # "/subagents/", agent_id/agentId set, is_sidechain/isSidechain true.
13
+ # - Wraps the deny decision in {"hookSpecificOutput":{...}} as Claude Code
14
+ # v2.1.150 requires; top-level fields parse cleanly but are ignored.
15
+ #
16
+ # Disable per-session with: COMPOSER_DANGEROUSLY_BYPASS_PERMISSIONS=1 claude
9
17
 
10
18
  set -u
11
19
 
12
20
  emit_deny() {
13
21
  local reason="$1"
14
22
  jq -nc --arg r "$reason" \
15
- '{hookEventName:"PreToolUse", permissionDecision:"deny", permissionDecisionReason:$r}' 2>/dev/null \
16
- || printf '{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"%s"}\n' "$reason"
23
+ '{hookSpecificOutput:{hookEventName:"PreToolUse", permissionDecision:"deny", permissionDecisionReason:$r}}' 2>/dev/null \
24
+ || printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"%s"}}\n' "$reason"
17
25
  exit 0
18
26
  }
19
27
 
20
- # 1. Dependency: jq is mandatory for safe JSON parsing.
21
28
  if ! command -v jq >/dev/null 2>&1; then
22
- # Cannot use emit_deny (depends on jq); inline fallback.
23
- printf '{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"boundary_guard: jq missing, failing closed"}\n'
29
+ printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"boundary_guard: jq missing, failing closed"}}\n'
24
30
  exit 0
25
31
  fi
26
32
 
27
- # 2. Read tool-call JSON from stdin.
28
33
  INPUT="$(cat || true)"
29
34
  if [[ -z "$INPUT" ]]; then
30
35
  emit_deny "boundary_guard: empty stdin, failing closed"
31
36
  fi
32
37
 
33
- # 3. Parse tool_name. jq surfaces parse errors to stderr (suppressed) and
34
- # returns empty on missing/null — both treated as malformed.
35
38
  TOOL="$(jq -r '.tool_name // empty' <<<"$INPUT" 2>/dev/null)"
36
39
  if [[ -z "$TOOL" ]]; then
37
40
  emit_deny "boundary_guard: malformed JSON or missing tool_name, failing closed"
38
41
  fi
39
42
 
40
- # 3.5. COMPOSER_DANGEROUSLY_BYPASS_PERMISSIONS (dev-only escape hatch).
41
- # When env var equals "1" or "true", allow every tool. Stderr-warns on
42
- # every invocation so the bypass is visible in transcripts. Intended
43
- # for bootstrap / dev sessions only. NEVER set in CI or runtime.
44
- # See ADR 0001 amendment (2026-05-23, Wave-3 Step 1).
45
43
  BYPASS="${COMPOSER_DANGEROUSLY_BYPASS_PERMISSIONS:-}"
46
44
  if [[ "$BYPASS" == "1" || "$BYPASS" == "true" ]]; then
47
45
  printf 'WARN boundary_guard: COMPOSER_DANGEROUSLY_BYPASS_PERMISSIONS=%s — boundary disabled, dev mode only\n' "$BYPASS" >&2
48
46
  exit 0
49
47
  fi
50
48
 
51
- # 3.6. STOP_EVOLVE killswitch.
52
- # If sentinel file exists AND the tool is a composer dispatch, deny.
53
- # Sentinel path overridable via COMPOSER_STOP_EVOLVE_FILE (tests use
54
- # a temp file); default "$CLAUDE_PROJECT_DIR/STOP_EVOLVE", falling
55
- # back to "./STOP_EVOLVE" when CLAUDE_PROJECT_DIR is unset.
56
49
  STOP_FILE="${COMPOSER_STOP_EVOLVE_FILE:-${CLAUDE_PROJECT_DIR:-.}/STOP_EVOLVE}"
57
50
  if [[ -e "$STOP_FILE" ]] && [[ "$TOOL" == mcp__composer__* ]]; then
58
51
  emit_deny "STOP_EVOLVE sentinel present at $STOP_FILE — Composer dispatches paused."
59
52
  fi
60
53
 
61
- # 4. Block listnative dangerous tools + MCP-prefixed variants.
54
+ # Subagent context bypasscoder must Edit/Write to apply GLM's patch.
55
+ TRANSCRIPT="$(jq -r '.transcript_path // empty' <<<"$INPUT" 2>/dev/null)"
56
+ AGENT_ID="$(jq -r '.agent_id // .agentId // empty' <<<"$INPUT" 2>/dev/null)"
57
+ SIDECHAIN="$(jq -r '.is_sidechain // .isSidechain // empty' <<<"$INPUT" 2>/dev/null)"
58
+ if [[ "$TRANSCRIPT" == */subagents/* ]] \
59
+ || [[ -n "$AGENT_ID" ]] \
60
+ || [[ "$SIDECHAIN" == "true" ]]; then
61
+ exit 0
62
+ fi
63
+
62
64
  case "$TOOL" in
63
- Bash|Edit|Write|NotebookEdit \
64
- | mcp__*__write_file | mcp__*__edit_file | mcp__*__bash \
65
- | mcp__*__write | mcp__*__edit | mcp__*__exec)
66
- emit_deny "Composer orchestrator forbids direct ${TOOL}. Delegate via Task to researcher / coder / reviewer."
65
+ Edit|Write|NotebookEdit \
66
+ | mcp__*__write_file | mcp__*__edit_file \
67
+ | mcp__*__write | mcp__*__edit)
68
+ emit_deny "DENIED on main session. Dispatch via Task(subagent_type=\"coder\", description=\"<short>\", prompt=\"<full task>\"). The coder subagent has Edit/Write and will apply GLM's patch directly. DO NOT use Bash sed/awk/perl/cat/tee as a workaround. DO NOT ask the user."
67
69
  ;;
68
70
  esac
69
71
 
70
- # 5. Pass-through. Emit nothing — Anthropic treats absent JSON + exit 0
71
- # as implicit allow. (Explicit allow JSON is also valid but noisier.)
72
72
  exit 0
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: composer-mastermind
3
- description: Use when the user asks for code, research, documentation lookup, or code review. Routes the work to the matching subagent (researcher / coder / reviewer) and keeps plan/integration context in the main session. This skill defines an orchestration pattern it is not a standalone library or external SDK.
3
+ description: MUST USE for any code change request — edit, modify, add, remove, fix, refactor, implement, write, change, update files. Also for research, documentation lookup, or code review. Routes work to subagents (researcher / coder / reviewer) via Task tool. Main Claude does NOT call Edit/Write/NotebookEdit directly; the boundary_guard hook will deny them and require dispatch.
4
4
  ---
5
5
 
6
6
  # Composer Mastermind