Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions competitor-scout-cli/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OPENAI_API_KEY=
TINYFISH_API_KEY=
16 changes: 16 additions & 0 deletions competitor-scout-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# v0 runtime files (should only exist in preview, not in git)
__v0_runtime_loader.js
__v0_devtools.tsx
__v0_jsx-dev-runtime.ts
instrumentation-client.js
instrumentation-client.ts

# Common ignores
node_modules/
.next/
.env*.local
.DS_Store
.scout.json
.scout-runs.json
scout-report-*.md
scout-results-*.json
1 change: 1 addition & 0 deletions competitor-scout-cli/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
46 changes: 46 additions & 0 deletions competitor-scout-cli/FILE_ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# File Architecture

High‑level map of the project and what each file is for.

```
.
├─ app/
│ ├─ api/
│ │ └─ research/
│ │ └─ route.ts # API route: orchestrates OpenAI + Tinyfish runs
│ ├─ globals.css # Global styles and Tailwind theme tokens
│ ├─ layout.tsx # Root layout, fonts, metadata
│ └─ page.tsx # Main UI page (competitors, query, results)
├─ cli/
│ └─ scout.mjs # CLI entrypoint and commands
├─ components/
│ ├─ cli-preview.tsx # CLI preview + rolling log panel in GUI
│ ├─ competitor-panel.tsx # Add/remove competitor form + list
│ ├─ event-log.tsx # Streaming event log UI
│ ├─ query-input.tsx # Research question input UI
│ └─ report-view.tsx # Summary + comparison report UI
├─ lib/
│ ├─ env.ts # Local env loader for dev
│ ├─ openai-client.ts # OpenAI planning + summarization + report
│ ├─ tinyfish.ts # Tinyfish/Mino API client
│ ├─ types.ts # Shared TypeScript types
│ └─ utils.ts # Shared utilities (className helpers, etc.)
├─ public/
│ ├─ v0-logo-dark.svg # Logo asset
│ └─ v0-logo-light.svg # Logo asset
├─ .env.example # Env template (no secrets)
├─ .gitignore # Git ignore rules (includes env + run output)
├─ .vscode/settings.json # Local editor settings
├─ next-env.d.ts # Next.js TypeScript declarations
├─ next.config.mjs # Next.js config
├─ package.json # App metadata + scripts + dependencies
├─ package-lock.json # npm lockfile
├─ pnpm-lock.yaml # pnpm lockfile (if you use pnpm)
├─ postcss.config.mjs # PostCSS config (Tailwind v4)
├─ PRODUCT.md # Product brief + PRD content
├─ README.md # Setup + usage guide
└─ tsconfig.json # TypeScript config
```

Notes
- Runtime‑generated files like `.env.local`, `.scout.json`, and `.scout-runs.json` are ignored by git.
103 changes: 103 additions & 0 deletions competitor-scout-cli/PRODUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Product Description

## Product Name

Competitor Research CLI

## The Why

Teams waste time manually checking competitor sites for feature changes and market signals. This CLI lets you set a list of competitors once, then ask natural‑language questions as your project evolves. The tool dispatches Tinyfish (Mino) web agents to each competitor site, gathers evidence, and returns a structured report that can inform product decisions without the manual research overhead.

---

## PRD

### 1. Product Architecture Overview

- **Overview:**
The system has a CLI/GUI front end, a planning layer (OpenAI), and an execution layer (Tinyfish/Mino). The planner translates a user question into per‑competitor browsing goals. The executor runs those goals and returns raw results. A summarizer turns results into per‑competitor findings and a comparison report.

- **APIs called:**
- **OpenAI Chat Completions**: planning goals, summarizing each competitor, and generating the comparison report.
- **Tinyfish (Mino) Web Agent API**: executes browsing goals for each competitor URL.

- **Relationship between APIs:**
- OpenAI creates the goal list.
- Tinyfish runs those goals and returns raw results.
- OpenAI summarizes each raw result and synthesizes a final report.

- **Call counts (for N competitors):**
- OpenAI:
- 1 call to create goals
- N calls to summarize each competitor
- 1 call to generate the comparison report
**Total: N + 2**
- Tinyfish:
- 1 run per competitor
**Total: N**

- **Orchestration:**
1. User submits a research question.
2. OpenAI generates a goal per competitor (URL + goal).
3. Tinyfish runs each goal asynchronously.
4. Results are polled until completed.
5. OpenAI summarizes each result and produces a final report.

### 2. Code Snippet (TypeScript)

```typescript
type Goal = { competitor_name: string; competitor_url: string; goal: string };

async function openaiPlanGoals(question: string, competitors: { name: string; url: string }[]) {
const res = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
},
body: JSON.stringify({
model: "gpt-4o",
messages: [
{ role: "system", content: "Create web research goals per competitor." },
{ role: "user", content: `Question: ${question}\nCompetitors: ${JSON.stringify(competitors)}` },
],
response_format: { type: "json_object" },
}),
});
const data = await res.json();
return (JSON.parse(data.choices[0].message.content).goals || []) as Goal[];
}

async function submitMinoRun(url: string, goal: string) {
const res = await fetch("https://agent.tinyfish.ai/v1/automation/run-async", {
method: "POST",
headers: {
"X-API-Key": process.env.TINYFISH_API_KEY!,
"Content-Type": "application/json",
},
body: JSON.stringify({ url, goal }),
});
const data = await res.json();
return data.run_id as string;
}
```

### 3. Goal (Prompt) Sent to Mino

**Prompt label:**
`Mino Goal`

**Exact goal example:**
```
Visit https://www.notion.com. Find where Notion describes its product features or pricing. Identify the key features mentioned and summarize them with direct references to the page sections you found.
```

### 4. Sample Output (Streaming JSON)

```
data: {"run_id":"run_2f8a...","status":"RUNNING","progress":"Navigating to /pricing"}

data: {"run_id":"run_2f8a...","status":"RUNNING","progress":"Extracting feature list"}

data: {"run_id":"run_2f8a...","status":"COMPLETED","result":{"features":["AI writing assistant","Collaborative docs","Database views"],"sources":["/pricing","/features"]}}
```
79 changes: 79 additions & 0 deletions competitor-scout-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Competitor Scout

Teams waste time manually checking competitor sites as their product evolves. This CLI tool with a user interface option lets you set competitors once and ask natural‑language questions to research the feature decisions that your competitors make. It would use ChatGPT to compose workflows and dispatch Tinyfish Web agents to each competitor, extracts evidence, and returns a structured report so product decisions can be made faster and with less manual research.

## Requirements

- Node.js 18+
- npm
- OpenAI API key
- Tinyfish API key

## Setup

1. Install dependencies:
- `npm install`

2. Create your local env file:
- `cp .env.example .env.local`
- Add:
- `OPENAI_API_KEY=...`
- `TINYFISH_API_KEY=...`

## Run the GUI (Next.js)

- Start the dev server:
- `npm run dev`
- Open:
- `http://localhost:3000`

## Run the CLI

The CLI lives in `cli/scout.mjs`.

- Initialize a workspace config:
- `node cli/scout.mjs init`
- Add competitors:
- `node cli/scout.mjs add --name "Notion" --url "https://www.notion.com"`
- List competitors:
- `node cli/scout.mjs list`
- Remove a competitor:
- `node cli/scout.mjs remove --name "Notion"`
- Remove all competitors:
- `node cli/scout.mjs clear`
- Run research:
- `node cli/scout.mjs research "What sign-in methods do my competitors support?"`
- List past runs:
- `node cli/scout.mjs runs`
- Cancel the latest run:
- `node cli/scout.mjs cancel`
- Cancel a specific run:
- `node cli/scout.mjs cancel --run "RUN_ID"`
- Reset CLI state:
- `node cli/scout.mjs reset`

## Help

Use straight quotes in the terminal. Smart quotes (like “ ”) can cause `dquote>` prompts.

```
node cli/scout.mjs
```

Commands:

- `init` — create `.scout.json`
- `add` — add a competitor (`--name`, `--url`)
- `list` — list competitors (alias: `ls`)
- `remove` — remove a competitor by name (alias: `rm`)
- `clear` — remove all competitors (alias: `rm-all`)
- `research` — run research (alias: `ask`)
- `runs` — list recorded runs
- `cancel` — cancel latest or `--run` by id
- `reset` — delete `.scout.json` and `.scout-runs.json`

## Notes

- `.env.local` is ignored by git via `.gitignore`.
- Reports and raw results generated by the CLI are saved to your current working directory.
- Run history is stored in `.scout-runs.json` in your project directory.
Loading