octocode-cli 1.3.0 → 1.3.1

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,262 @@
1
+ ---
2
+ name: octocode-brainstorming
3
+ description: Idea brainstorming and validation grounded in evidence. Triggers on "brainstorm", "is this worth building", "has anyone built X", "validate my idea", "check if X exists", "research this idea", "what are the prior-art options for Y". Researches GitHub, npm/PyPI, and the web in parallel, then synthesizes a decision-ready brief — not code or designs.
4
+ ---
5
+
6
+ # Octocode Brainstorming — Idea Discovery & Validation
7
+
8
+ Research-first skill that turns a raw idea into a grounded brief by hitting **every available surface in parallel** — then synthesizes what exists, what's missing, and what's next. No designs, specs, or code.
9
+
10
+
11
+ ---
12
+
13
+ ## Researcher Mindset
14
+
15
+ You are a **technical researcher**, not a search-engine wrapper.
16
+
17
+ - **Assume nothing is novel.** Find who tried it, where they stopped, and why.
18
+ - **Follow the trail.** README → blog → competitor → issues page → hard unsolved problem. Keep pulling threads.
19
+ - **Web ↔ Code cross-pollination.** Web and GitHub are not separate tracks — they feed each other. A blog post names a tool → search its repo on GitHub. A GitHub repo README links to docs → `WebFetch` those docs. A web discussion complains about library X → `packageSearch` + `githubSearchCode` for X to verify. Always use findings from one surface to refine queries on the other.
20
+ - **Go deep when results are thin.** Read code, check issue trackers, inspect PRs, check download trends. Shallow matches are starting points.
21
+ - **Use parallel agents aggressively.** Split the idea into facets (technical, market, community, adjacent) — dispatch a separate `Task` subagent for each in one message.
22
+ - **Force disagreement.** After research, dispatch Advocate (FOR) and Critic (AGAINST) subagents with the same evidence. Agreement = high confidence; disagreement = the real decision.
23
+ - **Synthesize, don't summarize.** Original analysis of what the landscape means, not just a link list.
24
+
25
+ ---
26
+
27
+ ## Hard Gates
28
+
29
+ Stop and ask the user before proceeding past any of these. State the situation in 1–2 lines, name the options, and recommend one.
30
+
31
+ 1. **Idea too broad** — the idea maps to 3+ unrelated problem spaces and cannot be meaningfully researched in one pass. Stop after the clarify step, before dispatching any subagents. Ask the user to pick one facet or confirm they want a shallow sweep.
32
+ 2. **Zero results across surfaces** — after the parallel research phase, all three surfaces (GitHub, packages, web) returned <2 meaningful results each even after synonym expansion. Do not proceed to Advocate vs Critic. Present what you found, flag the gap, and ask: narrow the idea, broaden keywords further, or accept thin evidence?
33
+ 3. **Contradictory evidence** — GitHub/packages show a crowded space but web sources say the problem is unsolved (or vice versa). Do not bury the contradiction in the brief. Stop, surface both sides with citations, and ask the user which signal to weight before synthesizing.
34
+ 4. **Subagent ceiling reached** — maximum **5 `Task` subagents** per brainstorm session (web slices + Advocate + Critic combined). If more seem needed, synthesize what you have first and ask whether the user wants a second research pass.
35
+
36
+ Do not silently continue past a hard gate. Do not ask outside of gates — gates exist to reduce bad briefs, not to offload decisions.
37
+
38
+ ---
39
+
40
+ ## Tools
41
+
42
+ ### GitHub & packages — Octocode MCP
43
+
44
+ | Tool | Use for |
45
+ |------|---------|
46
+ | `packageSearch` | npm/PyPI libraries |
47
+ | `githubSearchRepositories` | Repos by topic, language, stars |
48
+ | `githubViewRepoStructure` | How a similar project is organized |
49
+ | `githubSearchCode` | Confirm a concept is actually implemented |
50
+ | `githubGetFileContent` | Read key files for specific answers |
51
+ | `githubSearchPullRequests` | How similar features were shipped (deep mode) |
52
+
53
+ **Smart querying:**
54
+ - **Semantic expansion** — don't search only the user's exact words. Generate 2–3 synonym/related queries (e.g. "code review" → also "pull request analysis", "diff feedback", "static analysis AI"). Run them in parallel.
55
+ - **Recency first** — sort by recently updated/pushed. Ignore repos inactive >2 years unless the user asks for historical context. Stale repos are prior art, not competition.
56
+ - **Quality filter** — skip forks, skeleton/tutorial repos, and <10-star repos unless they're the only match. Prefer repos with recent commits, open issues with engagement, and multiple contributors.
57
+
58
+ ### Web — search scripts + WebFetch
59
+
60
+ Two layers: **search** (find URLs via Tavily) → **read** (`WebFetch` full content) → **follow** (chase leads). Use all three every time.
61
+
62
+ **Search script** in `scripts/`:
63
+
64
+ | Script | Key needed | Best for |
65
+ |--------|------------|----------|
66
+ | `tavily-search.mjs` | `TAVILY_API_KEY` | AI-curated, deep research mode |
67
+
68
+ **Startup — check Tavily:**
69
+ 1. Run `node <skill_dir>/scripts/tavily-search.mjs --check`
70
+ 2. Exit 0 → ready. Exit 1 → tell user once:
71
+ > Tavily not configured. Add your key to `<absolute_path_to_skill_dir>/.env`: `TAVILY_API_KEY=tvly-YOUR_KEY_HERE` (get one at https://app.tavily.com/)
72
+
73
+ **Run searches:**
74
+ ```bash
75
+ node <skill_dir>/scripts/tavily-search.mjs --query "<query>" --depth advanced --max-results 8 --time-range year
76
+ ```
77
+
78
+ Tavily: `--depth basic|advanced`, `--topic general|news`, `--time-range day|week|month|year`, `--help`.
79
+
80
+ **Smart querying:**
81
+ - **Semantic expansion** — generate 2–3 synonym/reframed queries per search pass (e.g. "AI code review" → also "LLM pull request feedback", "automated diff analysis"). Run them in parallel.
82
+ - **Recency first** — default to `--time-range year`. Only widen to all-time if the user asks or the year window returns <3 results.
83
+ - **Quality filter** — prioritize: official docs > technical blog posts > HN/Reddit discussions > general articles. Skip SEO spam, listicles, and paywalled pages. When `WebFetch`-ing, verify the page has substantive content before citing it.
84
+
85
+ **Research loop:** run Tavily → `WebFetch` best URLs (quality over quantity) → follow leads in fetched pages → repeat until bedrock.
86
+
87
+ **Subagents:** spawn `Task` (subagent_type `generalPurpose`) for independent web slices. Each runs Tavily + `WebFetch`. Dispatch multiple in one message.
88
+
89
+ **Subagent template:**
90
+ > Research <slice> for "<idea>".
91
+ > 1. Run `node <skill_dir>/scripts/tavily-search.mjs --query "<q>" --depth advanced --max-results 8`
92
+ > 2. `WebFetch` best URLs.
93
+ > 3. Report: who's doing this, what they got right/wrong, gaps, best URLs with notes. Cite all sources.
94
+
95
+ ### Tavily key setup
96
+
97
+ Script auto-loads `<skill_dir>/.env`. Set up: `cp <skill_dir>/.env.example <skill_dir>/.env` and fill in the key. Env vars override `.env`.
98
+
99
+ **Safety:** Never print/log/commit `TAVILY_API_KEY`. The `.env` is gitignored.
100
+
101
+ ### Tavily-down fallback (web research without Tavily)
102
+
103
+ When Tavily is unavailable (missing key, 401/403, 429/5xx), do not abandon web research. Use this fallback chain:
104
+
105
+ 1. **Seed URLs from GitHub** — GitHub repo READMEs, `awesome-*` lists, and package pages link to docs, blogs, and competitor products. `WebFetch` those URLs. This is your primary URL source when Tavily is down.
106
+ 2. **`WebFetch` well-known aggregators** — try `WebFetch` on curated sources relevant to the idea:
107
+
108
+ Examples:
109
+ - `https://news.ycombinator.com/` + search path for the topic
110
+ - `https://www.producthunt.com/` for product-level prior art
111
+ - `https://alternativeto.net/` for competitive landscape
112
+ - `https://dev.to/search?q=<topic>` for community discussion
113
+ 3. **Follow leads** — every `WebFetch`-ed page may contain links to deeper sources. Follow them the same way Tavily results are followed.
114
+
115
+ Fallback produces fewer results than Tavily. Flag in the TL;DR: "Web research limited — Tavily unavailable, results seeded from GitHub links and known aggregators."
116
+
117
+ **Error reporting:**
118
+ - Tavily 401/403 → key invalid. Tell user: update `<absolute_path>/.env`. Switch to fallback chain.
119
+ - Tavily 429/5xx → switch to fallback chain. Continue.
120
+ - Always print **absolute path** to `.env`. Never block on search failures.
121
+
122
+ ---
123
+
124
+ ## Workflow
125
+
126
+ Clarify → Parallel research → Advocate vs Critic → Synthesize → Present.
127
+
128
+ ### 1. Clarify
129
+
130
+ If ambiguous, ask one focused question. If clear enough to search, skip.
131
+
132
+ ### 2. Parallel Research
133
+
134
+ **Every brainstorm must hit all three surfaces.** Main agent handles GitHub + packages via Octocode MCP; subagents handle web slices using Tavily + `WebFetch`.
135
+
136
+ | Track | Runner | Tools |
137
+ |-------|--------|-------|
138
+ | GitHub prior-art | Main agent | `githubSearchRepositories` → `githubViewRepoStructure` → `githubSearchCode` |
139
+ | Package landscape | Main agent | `packageSearch` |
140
+ | Web — products | Subagent | Tavily → `WebFetch` |
141
+ | Web — community | Subagent | Tavily → `WebFetch` |
142
+ | Web — adjacent angles | Subagent | Tavily → `WebFetch` |
143
+
144
+ **Cross-pollination pass:** after the initial parallel sweep, use each surface's findings to sharpen the other:
145
+ - Web mentions a tool/library name → `githubSearchRepositories` + `packageSearch` for it
146
+ - GitHub repo links to docs/blog/product page → `WebFetch` it
147
+ - Package README references competitors → search those on both web and GitHub
148
+ - Web discussion names an unsolved problem → `githubSearchCode` to see if anyone solved it in code
149
+
150
+ **CHECKPOINT — do not proceed to Advocate vs Critic until:**
151
+ 1. At least **one cross-pollination query** has been dispatched per surface (web finding → GitHub search, GitHub finding → `WebFetch`, package finding → web or GitHub search).
152
+ 2. Results from cross-pollination have been received and incorporated.
153
+ 3. If a surface returned zero useful results, at least one synonym-expanded retry was attempted before marking it failed.
154
+
155
+ Skip cross-pollination only if the **Subagent ceiling** gate fires first — in that case, note "cross-pollination skipped (budget)" in the brief.
156
+
157
+ **Go deeper** if results are sparse: read code, check issues, inspect PRs, run synonym searches, check funding/traction. Spawn additional subagents (within the 5-subagent ceiling) rather than sequential follow-ups.
158
+
159
+ **Minimum bar:** findings from all three surfaces (GitHub, packages, web) with at least one cross-pollination pass. Flag explicitly if a track failed.
160
+
161
+ ### 2b. Advocate vs Critic
162
+
163
+ After research, dispatch **two competing subagents** in one message with the same findings:
164
+
165
+ **Advocate:**
166
+ > You are the ADVOCATE for "<idea>". Build the strongest case FOR. Cite repos, packages, web sources. Bull case only — not balanced.
167
+ > Research findings: <paste>
168
+
169
+ **Critic:**
170
+ > You are the CRITIC of "<idea>". Build the strongest case AGAINST. Cite crowded competitors, abandoned repos, complaints, unsolved problems. Bear case only — not encouraging.
171
+ > Research findings: <paste>
172
+
173
+ ### 3. Synthesize
174
+
175
+ Merge all tracks + Advocate vs Critic. Analyze, don't list.
176
+
177
+ - Both **agree** → high-confidence signal, lead with these
178
+ - They **disagree** → real decision points, present both sides with evidence
179
+ - Uncountered risk → flag as blocker. Unchallenged strength → flag as best direction.
180
+
181
+ Every claim needs a source (repo URL, npm page, web URL). Surface contradictions. Look for: prior art, gaps, risks, angles, traction signals.
182
+
183
+ ### 4. Present
184
+
185
+ ```markdown
186
+ # Idea: <one-line restatement>
187
+
188
+ ## TL;DR
189
+ <Crowded, underserved, or contested? 2–3 sentences. Note any research limitations (e.g. Tavily unavailable, cross-pollination skipped).>
190
+
191
+ ## Prior Art (GitHub)
192
+ - **<repo>** — <what, stars, activity>. `<confidence>` <URL>
193
+
194
+ ## Prior Art (Packages)
195
+ - **<package>** — <what, downloads, maintenance>. `<confidence>` <URL>
196
+
197
+ ## Prior Art (Web / Products)
198
+ - **<product>** — <positioning, pricing>. `<confidence>` <URL>
199
+
200
+ ## Bull Case (Advocate)
201
+ <Strongest FOR arguments with evidence.>
202
+
203
+ ## Bear Case (Critic)
204
+ <Strongest AGAINST arguments with evidence.>
205
+
206
+ ## Verdict
207
+ <Agreement, disagreement, key unknowns.>
208
+
209
+ ## Gaps & Opportunities
210
+ - <gap — with source>
211
+
212
+ ## Risks / Known Hard Problems
213
+ - <risk — with source>
214
+
215
+ ## Angles To Pursue
216
+ 1. **<angle>** — <why>. Closest prior art: <repo/product/package>.
217
+
218
+ ## Recommended Next Step
219
+ <e.g. "Prototype the hardest unknown first", "Too broad — narrow down", "Ready to build — start with X">
220
+ ```
221
+
222
+ **Confidence markers** — every prior-art entry MUST carry one:
223
+
224
+ | Marker | Meaning | Criteria |
225
+ |--------|---------|----------|
226
+ | `strong` | Active, validated, high-signal | Stars >500 OR downloads >10k/week OR multiple independent sources confirm |
227
+ | `moderate` | Exists and relevant, but incomplete signal | Stars 50–500 OR downloads 1k–10k/week OR single credible source |
228
+ | `weak` | Thin evidence, stale, or tangential | Stars <50 OR inactive >1 year OR only marketing copy, no independent validation |
229
+
230
+ Do not omit the marker. If you cannot assess confidence, mark `weak` and note why.
231
+
232
+ Scale sections to real content — don't pad.
233
+
234
+ **Present in chat first.** Then ask:
235
+ > Want me to save this brief? I'll write it to `.octocode/brainstorming/<YYYY-MM-DD>-<topic-slug>.md`
236
+
237
+ Only write if confirmed.
238
+
239
+
240
+ ---
241
+
242
+ ## Evidence Rules
243
+
244
+ - GitHub → repo URL + file:line for code + confidence marker. Web → URL + date + confidence marker.
245
+ - Every prior-art claim carries `strong`, `moderate`, or `weak` (see Confidence markers table above).
246
+ - Contradictions → surface both sides, pick on recency/authority. If contradiction triggers the **Contradictory evidence** gate, stop and ask.
247
+ - Marketing copy ≠ validation — mark it `weak` regardless of source authority.
248
+ - Zero prior art is usually a red flag, not a moat. If zero across all surfaces, the **Zero results** gate fires.
249
+
250
+ ---
251
+
252
+ ## Error Recovery
253
+
254
+ | Situation | Action |
255
+ |-----------|--------|
256
+ | Octocode MCP not installed | Tell user how to install; continue web-only |
257
+ | GitHub rate-limited | Reduce concurrency; continue |
258
+ | Tavily key missing/invalid | Switch to **Tavily-down fallback** chain; tell user absolute path to `.env` |
259
+ | All web tools down | GitHub-only; flag in TL;DR |
260
+ | Idea too broad | **Hard gate 1** fires — ask user to narrow before dispatching subagents |
261
+ | Zero prior art | Synonym-expand and retry once. If still zero, **Hard gate 2** fires — ask user before proceeding |
262
+ | Contradictory evidence across surfaces | **Hard gate 3** fires — surface both sides and ask user which signal to weight |
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Tavily web search for octocode-brainstorming.
4
+ *
5
+ * Usage:
6
+ * node tavily-search.mjs --query "prior art for X" [--depth basic|advanced] [--max-results 8] [--topic general|news] [--time-range month|year]
7
+ * node tavily-search.mjs --check # exits 0 if key is set, 1 otherwise
8
+ *
9
+ * Requires TAVILY_API_KEY in env or in <skill_dir>/.env
10
+ * Outputs JSON to stdout; progress/errors to stderr. Never prints the key.
11
+ */
12
+
13
+ import { readFileSync } from 'node:fs';
14
+ import { resolve, dirname } from 'node:path';
15
+ import { fileURLToPath } from 'node:url';
16
+
17
+ const __dirname = dirname(fileURLToPath(import.meta.url));
18
+ const SKILL_DIR = resolve(__dirname, '..');
19
+ const ENV_PATH = resolve(SKILL_DIR, '.env');
20
+
21
+ try {
22
+ const lines = readFileSync(ENV_PATH, 'utf8').split('\n');
23
+ for (const line of lines) {
24
+ const trimmed = line.trim();
25
+ if (!trimmed || trimmed.startsWith('#')) continue;
26
+ const eqIdx = trimmed.indexOf('=');
27
+ if (eqIdx === -1) continue;
28
+ const key = trimmed.slice(0, eqIdx).trim();
29
+ const val = trimmed.slice(eqIdx + 1).trim().replace(/^["']|["']$/g, '');
30
+ if (!process.env[key]) process.env[key] = val;
31
+ }
32
+ } catch { /* .env not present */ }
33
+
34
+ const ENDPOINT = 'https://api.tavily.com/search';
35
+
36
+ function die(msg, code = 1) {
37
+ process.stderr.write(`ERROR: ${msg}\n`);
38
+ process.exitCode = code;
39
+ }
40
+
41
+ function parseArgs(argv) {
42
+ const opts = { query: '', searchDepth: 'advanced', maxResults: 8, topic: 'general', timeRange: 'year', check: false, help: false };
43
+ for (let i = 0; i < argv.length; i++) {
44
+ const a = argv[i];
45
+ if (a === '--help' || a === '-h') { opts.help = true; continue; }
46
+ if (a === '--check') { opts.check = true; continue; }
47
+ if (a === '--query' || a === '-q') { opts.query = argv[++i] || ''; continue; }
48
+ if (a === '--depth') { opts.searchDepth = argv[++i] || 'advanced'; continue; }
49
+ if (a === '--max-results') { opts.maxResults = Number(argv[++i]) || 8; continue; }
50
+ if (a === '--topic') { opts.topic = argv[++i] || 'general'; continue; }
51
+ if (a === '--time-range') { opts.timeRange = argv[++i] || 'year'; continue; }
52
+ if (!opts.query) { opts.query = a; continue; }
53
+ die(`Unknown argument: ${a}`); return null;
54
+ }
55
+ return opts;
56
+ }
57
+
58
+ async function search(opts, apiKey) {
59
+ const body = {
60
+ query: opts.query,
61
+ search_depth: opts.searchDepth,
62
+ topic: opts.topic,
63
+ max_results: opts.maxResults,
64
+ include_answer: true,
65
+ include_raw_content: false,
66
+ time_range: opts.timeRange,
67
+ };
68
+
69
+ const res = await fetch(ENDPOINT, {
70
+ method: 'POST',
71
+ headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
72
+ body: JSON.stringify(body),
73
+ signal: AbortSignal.timeout(30_000),
74
+ });
75
+
76
+ if (!res.ok) {
77
+ const text = await res.text().catch(() => '');
78
+ die(`Tavily API ${res.status}: ${text}`);
79
+ return null;
80
+ }
81
+ return res.json();
82
+ }
83
+
84
+ async function main() {
85
+ const opts = parseArgs(process.argv.slice(2));
86
+ if (!opts) return;
87
+
88
+ if (opts.help) {
89
+ console.log(`Tavily web search — octocode-brainstorming
90
+
91
+ Usage:
92
+ node tavily-search.mjs --query "query" [options]
93
+ node tavily-search.mjs --check
94
+
95
+ Options:
96
+ --query, -q Search query (required unless --check)
97
+ --depth basic or advanced (default: advanced)
98
+ --max-results Number of results (default: 8)
99
+ --topic general or news (default: general)
100
+ --time-range day, week, month, or year (default: year)
101
+ --check Exit 0 if TAVILY_API_KEY is set, 1 otherwise
102
+
103
+ .env file: ${ENV_PATH}`);
104
+ return;
105
+ }
106
+
107
+ const apiKey = process.env.TAVILY_API_KEY;
108
+
109
+ if (opts.check) {
110
+ if (apiKey) {
111
+ console.log('tavily: available');
112
+ process.exitCode = 0;
113
+ } else {
114
+ console.log(`tavily: unavailable (TAVILY_API_KEY not set)`);
115
+ console.log(`Add TAVILY_API_KEY to: ${ENV_PATH}`);
116
+ process.exitCode = 1;
117
+ }
118
+ return;
119
+ }
120
+
121
+ if (!apiKey) {
122
+ die(`TAVILY_API_KEY is not set. Add it to ${ENV_PATH} or export it in your shell.`);
123
+ return;
124
+ }
125
+ if (!opts.query) {
126
+ die('--query is required. Use --help for usage.');
127
+ return;
128
+ }
129
+
130
+ process.stderr.write(`Searching Tavily: "${opts.query}" (depth=${opts.searchDepth}, max=${opts.maxResults})\n`);
131
+ const result = await search(opts, apiKey);
132
+ if (result) {
133
+ result.engine = 'tavily';
134
+ console.log(JSON.stringify(result, null, 2));
135
+ }
136
+ }
137
+
138
+ main().catch(err => die(err.message || String(err)));