Skip to content
Merged
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: 1 addition & 1 deletion skills/firecrawl-developer-index/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ There is **no fixed recipe**. Read the question, decide what kind it is, and cho
- HTTP: **`GET|POST https://api.firecrawl.dev/v2/search/developer`**
MCP: **`firecrawl_developer_search(query, k?, skills?)`**
CLI: **`firecrawl developer <query> [--limit <n>]`**
Ranked results over the whole index. Each carries `id` (`issue:owner/repo#123`), `url`, and the **matched passages in markdown**, so tables and code blocks survive. The artifact kind is the `id` prefix: `doc:`, `issue:`, `pull_request:`, or `readme:`.
Ranked results over the whole index. Each carries `id` (`issue:owner/repo#123`), `url`, and the **matched passages in markdown**, so tables and code blocks survive. The artifact kind is the `id` prefix: `doc:`, `issue:`, `pull_request:`, `readme:`, or `web:`. A `web:` result is a web page served beside the index hits; it is not a `types` value and cannot be requested. The CLI prints each result as `## [kind] title` and then its URL; `--json` keeps the full `id`.
The default first move for a developer question. It is the only surface that returns the passages, which is what lets you answer instead of pointing at a page.
`k` / `--limit` is 1–100 and defaults to 10. `skills="only"` (HTTP/MCP only) restricts the search to agent-skill files.
Keyless; send `Authorization: Bearer $FIRECRAWL_API_KEY` for higher rate limits.
Expand Down
34 changes: 13 additions & 21 deletions src/__tests__/commands/developer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,14 @@ describe('handleDeveloperSearchCommand', () => {
});

describe('output', () => {
it('renders id, type, title, url, and passage in readable output', async () => {
it('renders type, title, url, and passage in readable output', async () => {
mockHttpGet.mockResolvedValue(mockDeveloperResponse([sampleResult]));

await handleDeveloperSearchCommand({ query: 'tokio spawn_blocking' });

const [content] = vi.mocked(writeOutput).mock.calls[0];
expect(content).toContain(
'## [issue:tokio-rs/tokio#2309] (issue) spawn_blocking panics when exceeding the thread limit'
);
expect(content).toContain(
'https://github.com/tokio-rs/tokio/issues/2309'
'## [issue] spawn_blocking panics when exceeding the thread limit\nhttps://github.com/tokio-rs/tokio/issues/2309\n'
);
expect(content).toContain('It will panic if this limit is too low.');
});
Expand Down Expand Up @@ -147,36 +144,31 @@ describe('handleDeveloperSearchCommand', () => {
expect(content).toContain('rust: not indexed');
});

it('prints a result URL only when its id does not contain it', async () => {
const duplicateUrl = 'https://docs.rs/tokio/latest/tokio';
it('prints each result URL once, never inside the id', async () => {
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
const url = 'https://docs.rs/tokio/latest/tokio';
mockHttpGet.mockResolvedValue(
mockDeveloperResponse([
sampleResult,
{
id: `web:${duplicateUrl}`,
url: duplicateUrl,
id: `doc:${url}`,
url,
title: 'Tokio docs',
passages: [{ text: 'Runtime documentation.' }],
},
{
id: `web:${duplicateUrl}/search`,
url: duplicateUrl,
title: 'Tokio search',
passages: [{ text: 'Search documentation.' }],
id: `web:${url}`,
url,
title: 'Tokio runtime',
passages: [{ text: 'Runtime overview.' }],
},
])
);

await handleDeveloperSearchCommand({ query: 'tokio runtime' });

const [content] = vi.mocked(writeOutput).mock.calls[0] as [string];
expect(content.split(duplicateUrl).length - 1).toBe(3);
expect(content).toContain(
`## [web:${duplicateUrl}/search] Tokio search\n${duplicateUrl}\n`
);
expect(content).toContain(
'\nhttps://github.com/tokio-rs/tokio/issues/2309\n'
);
expect(content.split(url).length - 1).toBe(2);
expect(content).toContain(`## [doc] Tokio docs\n${url}\n`);
expect(content).toContain(`## [web] Tokio runtime\n${url}\n`);
});

it('does not render separators for empty passages', async () => {
Expand Down
15 changes: 4 additions & 11 deletions src/commands/developer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,12 @@ function fmtLicense(license: DeveloperLicense | string): string {
return `License: ${license.state.replace('_', ' ')}`;
}

function idEncodesUrl(id: string | undefined, url: string): boolean {
return id === url || id?.endsWith(`:${url}`) === true;
}

function fmtResult(item: DeveloperItem): string {
// The wire carries no type field; the artifact kind is the id prefix
// (doc:, issue:, pull_request:, readme:).
const prefix = (item.id ?? '').split(':', 1)[0];
const kind = ['doc', 'issue', 'pull_request', 'readme'].includes(prefix)
? ` (${prefix})`
: '';
const lines = [`## [${item.id ?? '?'}]${kind} ${item.title ?? '(untitled)'}`];
if (item.url && !idEncodesUrl(item.id, item.url)) lines.push(item.url);
// (doc:, issue:, pull_request:, readme:, web:).
const kind = item.id?.includes(':') ? `[${item.id.split(':', 1)[0]}] ` : '';
const lines = [`## ${kind}${item.title ?? '(untitled)'}`];
if (item.url) lines.push(item.url);
if (item.license) lines.push(fmtLicense(item.license));
const body = (item.passages ?? [])
.map((passage) =>
Expand Down
Loading