agestra 4.7.0 → 4.8.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,7 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // Agestra UserPromptSubmit hook
4
- // Detects user intent and injects Agestra tool suggestions as additionalContext.
4
+ // Detects user intent and routes to debate mode with configured providers.
5
+ // If no providers.config.json exists, suggests /agestra setup first.
6
+
7
+ const { existsSync } = require("fs");
8
+ const { join } = require("path");
5
9
 
6
10
  let input = "";
7
11
  process.stdin.on("data", (chunk) => { input += chunk; });
@@ -33,37 +37,98 @@ process.stdin.on("end", () => {
33
37
  if (ideaKeywords.some((k) => prompt.includes(k))) matched.push("idea");
34
38
  if (designKeywords.some((k) => prompt.includes(k))) matched.push("design");
35
39
 
36
- if (matched.length > 0) {
40
+ if (matched.length === 0) return;
41
+
42
+ // Check if providers.config.json exists
43
+ const cwd = data.cwd || process.cwd();
44
+ const configPath = join(cwd, "providers.config.json");
45
+ const hasConfig = existsSync(configPath);
46
+
47
+ if (!hasConfig) {
48
+ // No config — suggest setup first
37
49
  const lines = [
38
- "[Agestra] 외부 AI(Ollama, Gemini, Codex)와 팀을 구성하여 작업할 수 있습니다.",
39
- "사용자에게 모드 사용 여부를 제안하세요.",
50
+ "[Agestra] 외부 AI 끝장토론을 하려면 먼저 초기 설정이 필요합니다.",
51
+ "`/agestra setup`을 실행하여 사용할 AI를 선택하세요.",
40
52
  "",
53
+ "설정 후 자동으로 끝장토론 모드로 진행됩니다.",
41
54
  ];
55
+ console.log(JSON.stringify({ additionalContext: lines.join("\n") }));
56
+ return;
57
+ }
42
58
 
43
- if (matched.includes("review")) {
44
- lines.push("• 코드 리뷰 → `environment_check` 실행 후 모드 선택 제공:");
45
- lines.push(" - Claude only: agestra-reviewer 단독 실행");
46
- lines.push(" - 각자 독립: 팀(moderator + reviewer + 외부 AI) 각자 리뷰 → 취합 문서");
47
- lines.push(" - 끝장토론: 각자 독립 + 합의까지 반복 리뷰");
48
- }
49
- if (matched.includes("idea")) {
50
- lines.push(" 아이디어 탐색 `environment_check` 실행 후 모드 선택 제공:");
51
- lines.push(" - Claude only: agestra-ideator 단독 탐색");
52
- lines.push(" - 각자 독립: 팀(moderator + ideator + 외부 AI) 각자 탐색 → 취합 문서");
53
- lines.push(" - 끝장토론: 각자 독립 + 합의까지 반복 토론");
54
- }
55
- if (matched.includes("design")) {
56
- lines.push("• 설계 탐색 → `environment_check` 실행 후 모드 선택 제공:");
57
- lines.push(" - Claude only: agestra-designer 단독 설계");
58
- lines.push(" - 각자 독립: 팀(moderator + designer + 외부 AI) 각자 설계 → 취합 문서");
59
- lines.push(" - 끝장토론: 각자 독립 + 합의까지 반복 토론");
60
- }
61
-
62
- lines.push("");
63
- lines.push("반드시 `environment_check`를 먼저 호출하여 사용 가능한 프로바이더를 확인한 후, 모드 선택지를 사용자에게 보여주세요.");
59
+ // Config exists — check selectionPolicy
60
+ let config;
61
+ try {
62
+ config = JSON.parse(require("fs").readFileSync(configPath, "utf-8"));
63
+ } catch {
64
+ // Corrupted config — suggest re-setup
65
+ console.log(JSON.stringify({
66
+ additionalContext: "[Agestra] providers.config.json이 손상되었습니다. `/agestra setup`으로 재설정하세요.",
67
+ }));
68
+ return;
69
+ }
70
+
71
+ // ask-each-session: always ask user before proceeding
72
+ if (config.selectionPolicy === "ask-each-session") {
73
+ const enabledProviders = (config.providers || [])
74
+ .filter((p) => p.enabled)
75
+ .map((p) => p.id);
76
+
77
+ const lines = [
78
+ `[Agestra] Session policy: ask-each-session.`,
79
+ `Currently enabled AI: ${enabledProviders.join(", ") || "none"}.`,
80
+ "",
81
+ "MANDATORY: You MUST use AskUserQuestion to ask the user:",
82
+ "Present in the user's language.",
83
+ "Question 1: 'Run multi-AI debate with current providers?'",
84
+ "Options: 'Yes' / 'No' / 'Change AI selection (run /agestra setup)'",
85
+ "",
86
+ "If YES: call `environment_check` then proceed with debate.",
87
+ "If NO: handle directly without Agestra.",
88
+ "If CHANGE: run the setup skill to reconfigure providers.",
89
+ ];
64
90
 
65
91
  console.log(JSON.stringify({ additionalContext: lines.join("\n") }));
92
+ return;
93
+ }
94
+
95
+ // Fixed or ask-each-session mode
96
+ const enabledProviders = (config.providers || [])
97
+ .filter((p) => p.enabled)
98
+ .map((p) => p.id);
99
+
100
+ if (enabledProviders.length === 0) {
101
+ console.log(JSON.stringify({
102
+ additionalContext: "[Agestra] No AI providers are enabled. Run `/agestra setup` to select AIs.",
103
+ }));
104
+ return;
66
105
  }
106
+
107
+ const intentMap = [];
108
+ if (matched.includes("review")) intentMap.push("code review");
109
+ if (matched.includes("idea")) intentMap.push("idea exploration");
110
+ if (matched.includes("design")) intentMap.push("design exploration");
111
+ const intentStr = intentMap.join(", ");
112
+
113
+ const lines = [
114
+ `[Agestra] Detected intent: ${intentStr}.`,
115
+ `Available AI providers: ${enabledProviders.join(", ")}.`,
116
+ "",
117
+ "MANDATORY: You MUST use AskUserQuestion to ask the user whether to proceed with Agestra multi-AI debate.",
118
+ "Present this question in the user's language.",
119
+ "Question: 'Should we run a multi-AI debate (끝장토론) with the enabled providers?'",
120
+ "Options: 'Yes, run debate' / 'No, I will handle it alone'",
121
+ "",
122
+ "If user selects YES:",
123
+ " 1. Call `environment_check` to verify provider availability",
124
+ " 2. Proceed with 끝장토론 using the enabled providers",
125
+ " 3. Follow the workflow in the relevant skill (agestra-review / agestra-idea / agestra-design)",
126
+ "",
127
+ "If user selects NO:",
128
+ " Proceed without Agestra. Handle the task directly.",
129
+ ];
130
+
131
+ console.log(JSON.stringify({ additionalContext: lines.join("\n") }));
67
132
  } catch (e) {
68
133
  // silent — do not block user prompt on error
69
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agestra",
3
- "version": "4.7.0",
3
+ "version": "4.8.0",
4
4
  "description": "Multi-host AI orchestration toolkit for Claude Code, Codex CLI, and Gemini CLI",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.11.0",
package/skills/design.md CHANGED
@@ -67,68 +67,45 @@ Brownfield: modifying or extending existing code.
67
67
 
68
68
  Call `environment_check` to determine available providers.
69
69
 
70
- Present mode selection (in the user's language):
70
+ - If **no providers are available**: proceed to Phase 3 (Explore Propose → Refine → Document) directly using `agestra-designer` agent (Claude only).
71
+ - If **1+ providers are available**: proceed to 끝장토론 execution below.
71
72
 
72
- | Option | Condition | Description |
73
- |--------|-----------|-------------|
74
- | **Claude only** | Always | 플러그인 전문 에이전트가 소크라테스식 질문으로 아키텍처 탐색 |
75
- | **각자 독립** | 1+ provider available | 에이전트 팀(moderator + designer + 외부 AI)이 각자 독립 설계 후 취합 문서 작성 |
76
- | **끝장토론** | 1+ provider available | 각자 독립 설계 후 취합 문서를 돌아가며 분석/피드백, 모두 동의할 때까지 |
73
+ ### Phase 3: Execute 끝장토론
77
74
 
78
- Only show options whose conditions are met. If no providers are available, run Claude only.
75
+ **팀 구성:** `agestra-moderator` (리더) + `agestra-designer` (Claude) + 사용 가능한 외부 AI (gemini, codex 등)
79
76
 
80
- ### Phase 3: Execute
77
+ 1. Independent work + initial aggregation:
81
78
 
82
- #### If "Claude only":
83
- Proceed to Phase 4 (Explore → Propose → Refine → Document) directly using `agestra-designer` agent.
79
+ a. In parallel:
80
+ - Spawn the `agestra-designer` agent for Claude's independent architecture exploration.
81
+ After the agent completes, save Claude's result as a document via `workspace_create_document`:
82
+ - **title:** `Architecture Design — claude/designer`
83
+ - **metadata:** `{ "Provider": "claude/designer", "Task": "{subject}", "Mode": "Independent" }`
84
+ - **content:** The designer agent's full output.
85
+ - For each available provider, call `ai_chat` with `save_as_document`:
86
+ - **save_as_document.title:** `Architecture Design — {provider}`
87
+ - **save_as_document.metadata:** `{ "Task": "{subject}", "Mode": "Independent" }`
88
+ - **prompt:** Create a complete design document for [subject]. Include: 1) Problem definition — what exactly we're solving and why. 2) Constraints and requirements — technical limits, compatibility needs, performance targets. 3) 2-3 architecture approaches — each with detailed pros/cons, component diagrams, data flow, and effort estimates. 4) Recommended approach — pick one and justify the choice. 5) Implementation plan — step-by-step build sequence with dependencies. 6) Risks and mitigations. Be thorough and detailed — this document will be debated and refined.
84
89
 
85
- #### If "각자 독립":
90
+ b. Collect all document IDs.
86
91
 
87
- **팀 구성:** `agestra-moderator` (리더) + `agestra-designer` (Claude) + 사용 가능한 외부 AI (gemini, codex, ollama 등)
92
+ c. Spawn the `agestra-moderator` agent in **Independent Aggregation** mode:
93
+ - Pass the document ID list.
94
+ - Moderator reads each document, classifies consensus/unique/disputed approaches.
95
+ - Moderator creates an aggregated document. This becomes the starting document.
88
96
 
89
- 1. In parallel:
90
- - Spawn the `agestra-designer` agent for Claude's independent architecture exploration.
91
- After the agent completes, save Claude's result as a document via `workspace_create_document`:
92
- - **title:** `Architecture Design — claude/designer`
93
- - **metadata:** `{ "Provider": "claude/designer", "Task": "{subject}", "Mode": "Independent" }`
94
- - **content:** The designer agent's full output.
95
- - For each available provider, call `ai_chat` with `save_as_document`:
96
- - **save_as_document.title:** `Architecture Design — {provider}`
97
- - **save_as_document.metadata:** `{ "Task": "{subject}", "Mode": "Independent" }`
98
- - **prompt:** Propose an architecture approach for [subject]. Consider existing patterns in the codebase, trade-offs (complexity, performance, maintainability), and implementation steps. Present 2-3 distinct approaches with pros/cons for each.
97
+ 2. Start a turn-based debate session with `agent_debate_create`.
99
98
 
100
- 2. Collect all document IDs.
99
+ 3. Document review rounds (no max — until all agree):
100
+ a. Moderator sends the current document to each AI for review.
101
+ b. Moderator collects all feedback and updates the working document.
102
+ c. If all providers agree on all sections → consensus reached.
103
+ d. If not → next round with the revised document.
104
+ e. **Every 10 rounds:** Ask the user whether to continue or stop with current state.
101
105
 
102
- 3. Spawn the `agestra-moderator` agent in **Independent Aggregation** mode:
103
- - Pass the document ID list.
104
- - Moderator reads each document, classifies consensus/unique/disputed approaches.
105
- - Moderator creates an aggregated document via `workspace_create_document`.
106
+ 4. When consensus is reached, record the final synthesis with `agent_debate_conclude`.
106
107
 
107
- 4. Present summary report to the user:
108
- - Key consensus approaches (1-3 lines).
109
- - Notable unique design ideas (if any).
110
- - Trade-off disagreements (if any).
111
- - Individual + aggregated document IDs.
112
-
113
- #### If "끝장토론":
114
-
115
- **팀 구성:** `agestra-moderator` (리더) + `agestra-designer` (Claude) + 사용 가능한 외부 AI (gemini, codex, ollama 등)
116
-
117
- 1. Execute "각자 독립" steps 1-3 above (independent work + initial aggregation).
118
- - The moderator's integrated document becomes the starting document.
119
-
120
- 2. Document review rounds (no max — until all agree):
121
- a. Moderator sends the current document to each AI for review:
122
- - Claude: spawn `agestra-designer` → analyze document → section-by-section feedback
123
- - Other providers: `agent_debate_turn` with the document as prompt, requesting agree/disagree per section
124
- b. Moderator collects all feedback.
125
- c. Classify: agree/disagree per section per provider.
126
- d. Revise document incorporating disagreement feedback.
127
- e. If all providers agree on all sections → consensus reached.
128
- f. If not → next round with revised document.
129
- g. **Every 10 rounds:** Ask the user whether to continue or stop with current state.
130
-
131
- 3. Present the final document:
108
+ 5. Present the final document:
132
109
  - Consensus sections: marked as agreed
133
110
  - Disputed sections: show split positions with each provider's rationale
134
111