@m8i-51/shoal 0.1.0 → 0.1.2

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/.env.example ADDED
@@ -0,0 +1,76 @@
1
+ # ================================================================
2
+ # LLM Provider
3
+ # ================================================================
4
+ # LLM_PROVIDER に使いたいプロバイダ名を設定してください。
5
+ # LLM_BASE_URL / LLM_MODEL は省略時にプロバイダのデフォルト値が使われます。
6
+
7
+ # --- Anthropic (default) ---
8
+ # LLM_PROVIDER=anthropic
9
+ # ANTHROPIC_API_KEY=sk-ant-...
10
+ # LLM_MODEL=claude-haiku-4-5-20251001 # 省略可
11
+
12
+ # --- OpenAI ---
13
+ # LLM_PROVIDER=openai
14
+ # LLM_API_KEY=sk-...
15
+ # LLM_MODEL=gpt-4o-mini # 省略可(デフォルト: gpt-4o-mini)
16
+
17
+ # --- OpenAI Codex (ChatGPT サブスク OAuth) ---
18
+ # 事前に認証が必要: npm run auth:codex
19
+ # LLM_PROVIDER=codex
20
+ # LLM_MODEL=gpt-5.1-codex-mini # 省略可
21
+
22
+ # --- Groq (無料枠あり・高速) ---
23
+ # https://console.groq.com でキー取得
24
+ # LLM_PROVIDER=groq
25
+ # LLM_API_KEY=gsk_...
26
+ # LLM_MODEL=llama-3.3-70b-versatile # 省略可
27
+
28
+ # --- Google Gemini (無料枠あり) ---
29
+ # https://aistudio.google.com でキー取得
30
+ # LLM_PROVIDER=gemini
31
+ # LLM_API_KEY=AIzaSy...
32
+ # LLM_MODEL=gemini-2.0-flash # 省略可
33
+
34
+ # --- Ollama (ローカル / クラウド) ---
35
+ # LLM_PROVIDER=ollama
36
+ # LLM_MODEL=llama3.2 # 省略可
37
+ # LLM_API_KEY= # クラウドモデルの場合は API キーを設定
38
+ # LLM_BASE_URL=http://localhost:11434/v1 # 省略可(ローカルのデフォルト値)
39
+
40
+ # --- LM Studio (ローカル) ---
41
+ # LLM_PROVIDER=lm-studio
42
+ # LLM_MODEL=<LM Studio に表示されるモデル名>
43
+ # LLM_BASE_URL=http://localhost:1234/v1 # 省略可(デフォルト値)
44
+
45
+ # --- OpenRouter (多数のモデルにアクセス可) ---
46
+ # https://openrouter.ai でキー取得
47
+ # LLM_PROVIDER=openrouter
48
+ # LLM_API_KEY=sk-or-...
49
+ # LLM_MODEL=google/gemini-flash-1.5 # 省略可 / モデル一覧: openrouter.ai/models
50
+
51
+ # --- その他 OpenAI 互換エンドポイント ---
52
+ # LLM_PROVIDER=openai
53
+ # LLM_BASE_URL=https://your-endpoint/v1
54
+ # LLM_API_KEY=your-key
55
+ # LLM_MODEL=your-model
56
+
57
+ # ================================================================
58
+ # Target app
59
+ # ================================================================
60
+
61
+ TARGET=none # example | none | カスタムターゲット名
62
+ BASE_URL=http://localhost:3000
63
+
64
+ # ================================================================
65
+ # GitHub Issues (optional)
66
+ # ================================================================
67
+
68
+ GITHUB_TOKEN=
69
+ GITHUB_REPO=owner/repo
70
+
71
+ # ================================================================
72
+ # Run config
73
+ # ================================================================
74
+
75
+ MAX_EXPLORERS=4
76
+ MAX_BROWSERS=2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 m8i-51
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,13 +2,16 @@
2
2
 
3
3
  # shoal
4
4
 
5
+ [![npm](https://img.shields.io/npm/v/@m8i-51/shoal?color=red)](https://www.npmjs.com/package/@m8i-51/shoal)
5
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5-blue?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
6
7
  [![Playwright](https://img.shields.io/badge/Playwright-browser-45ba4b?logo=playwright&logoColor=white)](https://playwright.dev/)
7
8
  [![Anthropic](https://img.shields.io/badge/Anthropic-Claude-blueviolet?logo=anthropic&logoColor=white)](https://www.anthropic.com/)
8
9
 
9
10
  Point it at any web app. Agents explore it and file GitHub Issues.
10
11
 
11
- shoal drops a swarm of agents onto a web app. Each agent has a distinct persona and evaluation lens — accessibility, security, business logic, data integrity, new user experience. They explore independently via API and real browser, then a triage agent deduplicates findings and files GitHub Issues.
12
+ shoal drops a swarm of agents onto a web app. Each agent has a distinct persona and evaluation lens — accessibility, security, business logic, data integrity, new user experience, and goal alignment. They explore independently via API and real browser, then a triage agent deduplicates findings and files GitHub Issues.
13
+
14
+ A **web dashboard** lets you start runs, monitor live progress, review findings by category, and track estimated LLM cost per run.
12
15
 
13
16
  No test scripts. No test data. No prior knowledge of the app required.
14
17
 
@@ -19,7 +22,7 @@ No test scripts. No test data. No prior knowledge of the app required.
19
22
  ```
20
23
  Target App (any URL)
21
24
 
22
- ▼ autonomously learns what the app does
25
+ ▼ autonomously learns what the app does + its goals
23
26
  Product Discovery
24
27
 
25
28
  ▼ generates a user persona team for that app
@@ -42,6 +45,36 @@ Target App (any URL)
42
45
 
43
46
  ## Quick Start
44
47
 
48
+ **Install globally:**
49
+
50
+ ```bash
51
+ npm install -g @m8i-51/shoal
52
+ npx playwright install chromium
53
+ ```
54
+
55
+ Move to the project you want to test, then run:
56
+
57
+ ```bash
58
+ cd your-project
59
+ shoal init # creates .env with all available options
60
+ ```
61
+
62
+ Open `.env` and set at minimum:
63
+
64
+ ```env
65
+ ANTHROPIC_API_KEY=sk-ant-...
66
+ BASE_URL=http://localhost:3000 # URL of the app to test
67
+ ```
68
+
69
+ Then run:
70
+
71
+ ```bash
72
+ shoal serve # open web dashboard at http://localhost:4000
73
+ shoal # or run agents directly from the terminal
74
+ ```
75
+
76
+ **Or clone and develop locally:**
77
+
45
78
  ```bash
46
79
  git clone https://github.com/m8i-51/shoal
47
80
  cd shoal
@@ -52,6 +85,23 @@ npm start
52
85
 
53
86
  ---
54
87
 
88
+ ## Web dashboard
89
+
90
+ ```bash
91
+ shoal serve # global install
92
+ # or
93
+ npm run serve # from cloned repo
94
+ ```
95
+
96
+ Opens at `http://localhost:4000`. From there you can:
97
+
98
+ - **Start a run** — configure agent count, target URL, and custom instructions
99
+ - **Monitor live progress** — watch agents explore and file findings in real time
100
+ - **Review past runs** — findings by category, agent count, duration, and estimated cost
101
+ - **Edit app goals** — guide the goal-gap detector by defining what the app should achieve
102
+
103
+ ---
104
+
55
105
  ## Configuration
56
106
 
57
107
  | Variable | Default | Description |
@@ -70,20 +120,22 @@ npm start
70
120
 
71
121
  shoal loads `shoal.config.ts` from the **current working directory** at startup. Two common setups:
72
122
 
73
- **Option A — config inside the shoal repo** (simplest)
123
+ **Option A — config in your project directory** (recommended)
74
124
 
75
125
  ```bash
76
- cp shoal.config.example.ts shoal.config.ts
77
- # edit shoal.config.ts, then:
78
- npm start
126
+ # Copy the example from the repo (or create from scratch)
127
+ curl -O https://raw.githubusercontent.com/m8i-51/shoal/main/shoal.config.example.ts
128
+ mv shoal.config.example.ts shoal.config.ts
129
+ # Edit shoal.config.ts, then:
130
+ shoal
79
131
  ```
80
132
 
81
- **Option B — config in your project directory** (keeps shoal untouched)
133
+ **Option B — config inside the cloned repo** (simplest for development)
82
134
 
83
135
  ```bash
84
- cp /path/to/shoal/shoal.config.example.ts ./shoal.config.ts
85
- # edit shoal.config.ts, then run shoal from your project root:
86
- BASE_URL=http://localhost:3000 npm start --prefix /path/to/shoal
136
+ cp shoal.config.example.ts shoal.config.ts
137
+ # edit shoal.config.ts, then:
138
+ npm start
87
139
  ```
88
140
 
89
141
  `shoal.config.ts` must export a `target` object with two fields:
@@ -106,6 +158,21 @@ Alternatively, copy `targets/example.ts`, register it in `targets/index.ts`, and
106
158
 
107
159
  ---
108
160
 
161
+ ## Account Manager
162
+
163
+ For apps that require login, shoal includes an Account Manager agent that autonomously discovers and tests authentication. It finds login pages, tests credentials from `test-accounts/` (gitignored), and injects session state into explorer agents so they can reach authenticated routes.
164
+
165
+ Create `test-accounts/accounts.json` with your test credentials:
166
+
167
+ ```json
168
+ [
169
+ { "email": "test@example.com", "password": "testpassword", "role": "user" },
170
+ { "email": "admin@example.com", "password": "adminpassword", "role": "admin" }
171
+ ]
172
+ ```
173
+
174
+ ---
175
+
109
176
  ## LLM providers
110
177
 
111
178
  shoal defaults to Anthropic Claude. To use a different provider, set these variables in `.env`:
@@ -114,8 +181,15 @@ shoal defaults to Anthropic Claude. To use a different provider, set these varia
114
181
  |---|---|
115
182
  | Anthropic (default) | `ANTHROPIC_API_KEY` |
116
183
  | OpenAI | `LLM_PROVIDER=openai`, `LLM_API_KEY`, `LLM_MODEL` |
184
+ | OpenRouter | `LLM_PROVIDER=openrouter`, `LLM_API_KEY`, `LLM_MODEL` |
117
185
  | Codex (ChatGPT subscription) | run `npm run auth:codex` once, then `LLM_PROVIDER=codex` |
118
186
  | Ollama | `LLM_BASE_URL=http://localhost:11434/v1`, `LLM_MODEL` |
119
187
  | LM Studio | `LLM_BASE_URL=http://localhost:1234/v1`, `LLM_MODEL` |
120
188
 
121
189
  See `.env.example` for full examples.
190
+
191
+ ---
192
+
193
+ ## License
194
+
195
+ [MIT](LICENSE)
package/bin/init.js ADDED
@@ -0,0 +1,106 @@
1
+ import { intro, outro, select, text, isCancel, cancel } from "@clack/prompts";
2
+ import { writeFileSync, existsSync } from "fs";
3
+ import { join } from "path";
4
+
5
+ const PROVIDERS = [
6
+ { value: "anthropic", label: "Anthropic (Claude)", hint: "recommended", defaultModel: "claude-haiku-4-5-20251001" },
7
+ { value: "openai", label: "OpenAI", defaultModel: "gpt-4o-mini" },
8
+ { value: "groq", label: "Groq", hint: "free tier available", defaultModel: "llama-3.3-70b-versatile" },
9
+ { value: "gemini", label: "Gemini", hint: "free tier available", defaultModel: "gemini-2.0-flash" },
10
+ { value: "ollama", label: "Ollama", hint: "local", defaultModel: null },
11
+ { value: "lm-studio", label: "LM Studio", hint: "local", defaultModel: null },
12
+ { value: "openrouter", label: "OpenRouter", defaultModel: "google/gemini-flash-1.5" },
13
+ ];
14
+
15
+ function guard(value) {
16
+ if (isCancel(value)) {
17
+ cancel("Setup cancelled.");
18
+ process.exit(0);
19
+ }
20
+ return value;
21
+ }
22
+
23
+ export async function runInit(cwd) {
24
+ const envPath = join(cwd, ".env");
25
+
26
+ if (existsSync(envPath)) {
27
+ console.log(".env already exists. Delete it and run shoal init again.");
28
+ process.exit(0);
29
+ }
30
+
31
+ intro("shoal init");
32
+
33
+ // ── Provider ──────────────────────────────────────────────────────
34
+ const provider = guard(await select({
35
+ message: "LLM provider",
36
+ options: PROVIDERS,
37
+ }));
38
+
39
+ const env = {};
40
+
41
+ const providerDef = PROVIDERS.find((p) => p.value === provider);
42
+
43
+ // ── Provider-specific questions ───────────────────────────────────
44
+ if (provider === "anthropic") {
45
+ env.ANTHROPIC_API_KEY = guard(await text({
46
+ message: "ANTHROPIC_API_KEY",
47
+ placeholder: "sk-ant-...",
48
+ validate: (v) => v?.trim() ? undefined : "Required",
49
+ }));
50
+ } else if (provider === "ollama") {
51
+ env.LLM_PROVIDER = "ollama";
52
+ const baseUrl = guard(await text({
53
+ message: "Ollama base URL",
54
+ defaultValue: "http://localhost:11434/v1",
55
+ }));
56
+ if (baseUrl !== "http://localhost:11434/v1") env.LLM_BASE_URL = baseUrl;
57
+ } else if (provider === "lm-studio") {
58
+ env.LLM_PROVIDER = "lm-studio";
59
+ const baseUrl = guard(await text({
60
+ message: "LM Studio base URL",
61
+ defaultValue: "http://localhost:1234/v1",
62
+ }));
63
+ if (baseUrl !== "http://localhost:1234/v1") env.LLM_BASE_URL = baseUrl;
64
+ } else {
65
+ env.LLM_PROVIDER = provider;
66
+ env.LLM_API_KEY = guard(await text({
67
+ message: "API key",
68
+ placeholder: "sk-...",
69
+ validate: (v) => v?.trim() ? undefined : "Required",
70
+ }));
71
+ }
72
+
73
+ const defaultModel = providerDef?.defaultModel;
74
+ const model = guard(await text({
75
+ message: "Model name",
76
+ placeholder: defaultModel ? `leave blank to use ${defaultModel}` : "required",
77
+ validate: !defaultModel ? (v) => v?.trim() ? undefined : "Required" : undefined,
78
+ }));
79
+ if (model.trim()) env.LLM_MODEL = model.trim();
80
+
81
+ // ── Target app ────────────────────────────────────────────────────
82
+ env.BASE_URL = guard(await text({
83
+ message: "URL of the app to test",
84
+ defaultValue: "http://localhost:3000",
85
+ }));
86
+
87
+ // ── GitHub (optional) ─────────────────────────────────────────────
88
+ const githubToken = guard(await text({
89
+ message: "GitHub token (optional — for Issue creation)",
90
+ placeholder: "ghp_... leave blank to skip",
91
+ }));
92
+ if (githubToken.trim()) {
93
+ env.GITHUB_TOKEN = githubToken.trim();
94
+ const githubRepo = guard(await text({
95
+ message: "GitHub repo",
96
+ placeholder: "owner/repo",
97
+ }));
98
+ if (githubRepo.trim()) env.GITHUB_REPO = githubRepo.trim();
99
+ }
100
+
101
+ // ── Write .env ────────────────────────────────────────────────────
102
+ const lines = Object.entries(env).map(([k, v]) => `${k}=${v}`);
103
+ writeFileSync(envPath, lines.join("\n") + "\n", "utf-8");
104
+
105
+ outro("Created .env\n\n shoal serve — open the dashboard at http://localhost:4000\n shoal — run agents from the terminal");
106
+ }
package/bin/shoal.js CHANGED
@@ -3,9 +3,10 @@
3
3
  * shoal CLI entry point
4
4
  *
5
5
  * Usage:
6
- * npx shoal # run exploration
7
- * npx shoal triage # triage-only mode
8
- * npx shoal serve # local web dashboard
6
+ * shoal init # interactive setup — creates .env in current directory
7
+ * shoal serve # web dashboard at http://localhost:4000
8
+ * shoal # run agents from the terminal
9
+ * shoal triage # triage-only mode
9
10
  */
10
11
  import { spawn, spawnSync } from "child_process";
11
12
  import { fileURLToPath } from "url";
@@ -14,43 +15,55 @@ import { existsSync } from "fs";
14
15
 
15
16
  const __dirname = dirname(fileURLToPath(import.meta.url));
16
17
  const packageRoot = join(__dirname, "..");
17
-
18
18
  const subcommand = process.argv[2];
19
19
 
20
- // serve の場合、web/dist が存在しなければ自動ビルドする
21
- if (subcommand === "serve") {
22
- const distIndex = join(packageRoot, "web", "dist", "index.html");
23
- const webSrc = join(packageRoot, "web", "src");
24
- if (!existsSync(distIndex) && existsSync(webSrc)) {
25
- console.log("[shoal] web/dist not found — building frontend...");
26
- const viteBin = join(packageRoot, "node_modules", ".bin", "vite");
27
- const buildBin = existsSync(viteBin) ? viteBin : "vite";
28
- const result = spawnSync(buildBin, ["build", "web"], {
29
- stdio: "inherit",
30
- cwd: packageRoot,
31
- });
32
- if (result.status !== 0) {
33
- console.error("[shoal] Frontend build failed. Run: npm run build:web");
34
- process.exit(1);
20
+ async function main() {
21
+ // init 対話形式で .env をカレントディレクトリに生成する
22
+ if (subcommand === "init") {
23
+ const { runInit } = await import("./init.js");
24
+ await runInit(process.cwd());
25
+ process.exit(0);
26
+ }
27
+
28
+ // serve の場合、web/dist が存在しなければ自動ビルドする
29
+ if (subcommand === "serve") {
30
+ const distIndex = join(packageRoot, "web", "dist", "index.html");
31
+ const webSrc = join(packageRoot, "web", "src");
32
+ if (!existsSync(distIndex) && existsSync(webSrc)) {
33
+ console.log("[shoal] web/dist not found building frontend...");
34
+ const viteBin = join(packageRoot, "node_modules", ".bin", "vite");
35
+ const buildBin = existsSync(viteBin) ? viteBin : "vite";
36
+ const result = spawnSync(buildBin, ["build", "web"], {
37
+ stdio: "inherit",
38
+ cwd: packageRoot,
39
+ });
40
+ if (result.status !== 0) {
41
+ console.error("[shoal] Frontend build failed. Run: npm run build:web");
42
+ process.exit(1);
43
+ }
35
44
  }
36
45
  }
46
+
47
+ const scriptMap = {
48
+ serve: "server/index.ts",
49
+ triage: "triage-only.ts",
50
+ };
51
+ const script = scriptMap[subcommand] ?? "run.ts";
52
+
53
+ const tsxBin = join(packageRoot, "node_modules", ".bin", "tsx");
54
+ const bin = existsSync(tsxBin) ? tsxBin : "tsx";
55
+ const scriptPath = join(packageRoot, script);
56
+
57
+ const child = spawn(bin, [scriptPath, ...process.argv.slice(subcommand ? 3 : 2)], {
58
+ stdio: "inherit",
59
+ env: process.env,
60
+ cwd: process.cwd(),
61
+ });
62
+
63
+ child.on("exit", (code) => process.exit(code ?? 0));
37
64
  }
38
65
 
39
- const scriptMap = {
40
- serve: "server/index.ts",
41
- triage: "triage-only.ts",
42
- };
43
- const script = scriptMap[subcommand] ?? "run.ts";
44
-
45
- // tsx の bin を package 内から解決し、なければ PATH にフォールバック
46
- const tsxBin = join(packageRoot, "node_modules", ".bin", "tsx");
47
- const bin = existsSync(tsxBin) ? tsxBin : "tsx";
48
- const scriptPath = join(packageRoot, script);
49
-
50
- const child = spawn(bin, [scriptPath, ...process.argv.slice(subcommand ? 3 : 2)], {
51
- stdio: "inherit",
52
- env: process.env,
53
- cwd: process.cwd(),
66
+ main().catch((e) => {
67
+ console.error(e);
68
+ process.exit(1);
54
69
  });
55
-
56
- child.on("exit", (code) => process.exit(code ?? 0));
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@m8i-51/shoal",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "Multi-agent web exploration framework — finds bugs, UX issues, and missing features by running AI agents against your app",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/m8i-51/shoal"
9
+ },
6
10
  "bin": {
7
11
  "shoal": "./bin/shoal.js"
8
12
  },
@@ -13,7 +17,8 @@
13
17
  "server/",
14
18
  "web/dist/",
15
19
  "run.ts",
16
- "triage-only.ts"
20
+ "triage-only.ts",
21
+ ".env.example"
17
22
  ],
18
23
  "scripts": {
19
24
  "prepublishOnly": "npm run build:web",
@@ -29,7 +34,8 @@
29
34
  "test:watch": "vitest"
30
35
  },
31
36
  "dependencies": {
32
- "@anthropic-ai/sdk": "^0.81.0",
37
+ "@anthropic-ai/sdk": "^0.91.1",
38
+ "@clack/prompts": "^1.3.0",
33
39
  "dotenv": "^17.3.1",
34
40
  "express": "^5.2.1",
35
41
  "openai": "^6.33.0",