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
23 changes: 23 additions & 0 deletions bin/acp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,13 @@ function buildCommandHelp(command: string): string | undefined {
"",
cmd("cancel <bounty-id>", "Cancel a bounty (soft delete)"),
cmd("cleanup <bounty-id>", "Remove local bounty state"),
cmd("get <bounty-id>", "Get any bounty details from server (not just local)"),
cmd("search <query>", "Search bounties by title/description/tags"),
flag("--status <status>", "Filter by status (open, pending_match, claimed, etc.)"),
flag("--category <category>", "Filter by category"),
flag("--min-budget <number>", "Minimum budget filter"),
flag("--max-budget <number>", "Maximum budget filter"),
flag("--limit <number>", "Max results (default: 20)"),
"",
].join("\n"),

Expand Down Expand Up @@ -688,6 +695,22 @@ async function main(): Promise<void> {
if (subcommand === "select") return bounty.select(rest[0]);
if (subcommand === "cancel") return bounty.cancel(rest[0]);
if (subcommand === "cleanup") return bounty.cleanup(rest[0]);
if (subcommand === "get") return bounty.get(rest[0]);
if (subcommand === "search") {
const searchQuery = rest.filter((a) => a != null && !String(a).startsWith("--")).join(" ");
const searchStatus = getFlagValue(rest, "--status");
const searchCategory = getFlagValue(rest, "--category");
const searchMinBudget = getFlagValue(rest, "--min-budget");
const searchMaxBudget = getFlagValue(rest, "--max-budget");
const searchLimit = getFlagValue(rest, "--limit");
return bounty.search(searchQuery, {
status: searchStatus,
category: searchCategory,
minBudget: searchMinBudget != null ? Number(searchMinBudget) : undefined,
maxBudget: searchMaxBudget != null ? Number(searchMaxBudget) : undefined,
limit: searchLimit != null ? Number(searchLimit) : undefined,
});
}
console.log(buildCommandHelp("bounty"));
return;
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 100 additions & 0 deletions src/commands/bounty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1100,3 +1100,103 @@ export async function cleanup(bountyId: string): Promise<void> {
}
output.log(` Cleaned up bounty ${bountyId}\n`);
}

// =============================================================================
// acp bounty get <bountyId>
// =============================================================================

export async function get(bountyId: string): Promise<void> {
if (!bountyId) output.fatal("Usage: acp bounty get <bountyId>");

const details = await getBountyDetails(bountyId);

output.output(
{
bountyId,
status: details.status,
title: details.title,
description: details.description,
budget: details.budget,
category: details.category,
tags: details.tags,
posterName: details.poster_name,
createdAt: details.created_at,
...(details.expires_at ? { expiresAt: details.expires_at } : {}),
},
(data) => {
output.heading(`Bounty ${data.bountyId}`);
output.field("Status", data.status);
output.field("Title", data.title);
output.field("Description", data.description);
output.field("Budget", `${data.budget} USDC`);
output.field("Category", data.category);
output.field("Tags", data.tags);
if (data.posterName) output.field("Posted by", data.posterName);
if (data.createdAt) output.field("Created", data.createdAt);
if (data.expiresAt) output.field("Expires", data.expiresAt);
output.log("");
}
);
}

// =============================================================================
// acp bounty search <query>
// =============================================================================

export interface BountySearchFlags {
status?: string;
category?: string;
minBudget?: number;
maxBudget?: number;
limit?: number;
}

export async function search(query: string, flags?: BountySearchFlags): Promise<void> {
if (!query) output.fatal("Usage: acp bounty search <query>");

const { searchBounties } = await import("../lib/bounty.js");
const result = await searchBounties(query, {
status: flags?.status,
category: flags?.category,
minBudget: flags?.minBudget,
maxBudget: flags?.maxBudget,
limit: flags?.limit ?? 20,
});

const bounties = result.data || [];
const meta = result.meta || {};

output.output(
{
query,
total: meta.total ?? bounties.length,
bounties: bounties.map((b: any) => ({
id: b.id,
title: b.title,
status: b.status,
budget: b.budget,
category: b.category,
tags: b.tags,
posterName: b.poster_name,
})),
},
(data) => {
output.heading(`Search: "${data.query}"`);
output.field("Total results", data.total);
output.log("");
if (data.bounties.length === 0) {
output.log(" No bounties found.\n");
return;
}
for (const b of data.bounties) {
output.field("ID", b.id);
output.field("Title", b.title);
output.field("Status", b.status);
output.field("Budget", `${b.budget} USDC`);
output.field("Category", b.category);
if (b.tags) output.field("Tags", b.tags);
output.log("");
}
}
);
}
32 changes: 32 additions & 0 deletions src/lib/bounty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,35 @@ export async function syncBountyJobStatus(params: {
});
return extractData<unknown>(res.data);
}

export interface BountySearchFilters {
status?: string;
category?: string;
minBudget?: number;
maxBudget?: number;
limit?: number;
}

export interface BountySearchResult {
data: Array<Record<string, unknown>>;
meta?: {
total?: number;
page?: number;
per_page?: number;
};
}

export async function searchBounties(
query: string,
filters?: BountySearchFilters
): Promise<BountySearchResult> {
const params = new URLSearchParams();
params.append("search", query);
if (filters?.status) params.append("status", filters.status);
if (filters?.category) params.append("category", filters.category);
if (filters?.minBudget != null) params.append("min_budget", String(filters.minBudget));
if (filters?.maxBudget != null) params.append("max_budget", String(filters.maxBudget));
if (filters?.limit) params.append("limit", String(filters.limit));
const res = await api.get(`/bounties?${params.toString()}`);
return extractData<BountySearchResult>(res.data);
}