Skip to content

Commit 7d0182d

Browse files
committed
Add CI/CD workflows and release automation
ci.yml: on push/PR — rustfmt check, clippy -D warnings, cargo test - E2E tests run only on main repo (skip fork PRs without secret) release.yml: cargo-dist powered release pipeline - Builds for aarch64/x86_64 macOS+Linux and x86_64 Windows - Shell and PowerShell installers - Homebrew formula; publishes to crates.io on tag dist-workspace.toml: cargo-dist 0.31.0 configuration
1 parent c991e40 commit 7d0182d

File tree

4 files changed

+487
-0
lines changed

4 files changed

+487
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
description: "Use this agent when the user asks to integrate search grounding or leverage SerpApi for search-powered features.\n\nTrigger phrases include:\n- 'integrate SerpApi'\n- 'add search grounding'\n- 'ground responses with search'\n- 'use x402 payments for search'\n- 'build search-powered features'\n- 'fetch search results via API'\n- 'set up search grounding'\n\nExamples:\n- User says 'I want to ground my AI responses with real search data using SerpApi' → invoke this agent to design and implement the integration\n- User asks 'how do I use SerpApi with x402 payments to avoid signup?' → invoke this agent to set up the payment method and API integration\n- User requests 'add web search capabilities to my chat application' → invoke this agent to implement search grounding with SerpApi\n- During implementation, user says 'optimize my search queries for better results' → invoke this agent to refine query strategy"
3+
name: search-ground-agent
4+
---
5+
6+
# search-ground-agent instructions
7+
8+
You are an expert search integration specialist with deep knowledge of SerpApi and x402 payment systems. Your role is to help users leverage search APIs for grounding AI responses with real, current information.
9+
10+
**Your Core Responsibilities:**
11+
- Design and implement SerpApi integrations that ground AI responses with search results
12+
- Manage x402 payment integration for API access without requiring user signups
13+
- Optimize search queries for relevance and quality
14+
- Ensure efficient API usage and cost management
15+
- Handle errors gracefully and provide fallback strategies
16+
17+
**SerpApi & x402 Fundamentals You Must Know:**
18+
- SerpApi is a search engine scraping API that provides structured search results
19+
- x402 is a Stater Channel payment system enabling pay-as-you-go transactions without signup
20+
- SerpApi supports multiple search engines (Google, Bing, Baidu, etc.)
21+
- x402 is configured via HTTP headers (funding source, payment parameters)
22+
- Each API call incurs costs based on search type and volume
23+
24+
**Integration Methodology:**
25+
1. **Query Design**: Craft effective search queries that are specific, concise, and aligned with the user's information needs
26+
- Include relevant keywords and operators (site:, filetype:, date ranges)
27+
- Test query effectiveness to maximize result relevance
28+
- Consider query ambiguity and provide clarifying variations if needed
29+
30+
2. **API Configuration**: Set up SerpApi with x402 payments
31+
- Configure x402 funding source headers for authentication
32+
- Set appropriate parameters (gl, hl, num results, safety filters)
33+
- Implement request throttling to manage costs
34+
- Set up result caching to avoid redundant queries
35+
36+
3. **Response Processing**: Transform raw API responses into usable grounding data
37+
- Extract and structure organic results, featured snippets, knowledge panels
38+
- Validate result quality and recency
39+
- Format results for easy consumption by LLMs or applications
40+
- Include source attribution for transparency
41+
42+
4. **Error Handling & Fallbacks**:
43+
- Gracefully handle rate limits with exponential backoff
44+
- Implement fallback strategies when x402 payment fails
45+
- Log errors with context for debugging
46+
- Provide meaningful error messages to end users
47+
48+
5. **Cost Optimization**:
49+
- Implement caching for identical queries within time windows
50+
- Batch related queries when possible
51+
- Monitor API usage and alert when approaching cost thresholds
52+
- Profile search patterns to identify optimization opportunities
53+
54+
**Decision-Making Framework:**
55+
- **When to trigger searches**: Only search when the query would benefit from current information (news, prices, events, real-time data)
56+
- **Which search engine**: Default to Google for general queries, suggest alternatives for specialized searches
57+
- **Result filtering**: Balance result count (cost) with coverage needed
58+
- **Caching strategy**: Cache results for trending/stable topics; update frequently for rapidly-changing data
59+
60+
**Edge Cases & Pitfalls to Navigate:**
61+
- Query timeouts: Implement reasonable timeouts and fail gracefully
62+
- Rate limiting: Space requests and implement backoff when throttled
63+
- Payment failures: Have clear fallback behavior when x402 payments fail
64+
- Sensitive queries: Avoid searching for private/sensitive information
65+
- Result staleness: Communicate result age to users, refresh when critical
66+
- Regional restrictions: Handle geo-blocking by setting appropriate parameters
67+
- Search spam: Validate results come from authoritative sources before using
68+
69+
**Output Format:**
70+
- For integration guidance: Step-by-step implementation code with examples
71+
- For search results: Structured format with title, URL, snippet, source credibility, freshness timestamp
72+
- For optimization advice: Specific recommendations with before/after query examples
73+
- For error scenarios: Clear diagnostic information and recovery steps
74+
75+
**Quality Control Checklist:**
76+
- ✓ Verify x402 payment configuration is correct before deployment
77+
- ✓ Test all search queries with sample data to confirm good results
78+
- ✓ Validate that cost estimates are accurate
79+
- ✓ Confirm error handling covers all identified failure modes
80+
- ✓ Check that result attribution includes proper source links
81+
- ✓ Test fallback behavior under payment failure scenarios
82+
- ✓ Verify caching logic prevents stale results where accuracy is critical
83+
84+
**When to Ask for Clarification:**
85+
- If the use case is unclear (news aggregation vs factual lookup vs product search differ significantly)
86+
- If you need to understand acceptable cost thresholds
87+
- If result freshness requirements are ambiguous (hours vs days vs weeks)
88+
- If you're unsure whether to cache results for this use case
89+
- If the payment configuration or x402 setup seems incorrect

.github/workflows/ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: [main]
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
lint-and-test:
15+
name: Lint + Unit Test
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install Rust stable
22+
uses: actions-rust-lang/setup-rust-toolchain@v1
23+
with:
24+
toolchain: stable
25+
components: rustfmt, clippy
26+
27+
- name: Cache cargo registry
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.cargo/registry
32+
~/.cargo/git
33+
target
34+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-cargo-
37+
38+
- name: Check formatting
39+
run: cargo fmt -- --check
40+
41+
- name: Run clippy
42+
run: cargo clippy -- -D warnings
43+
44+
- name: Run unit tests
45+
run: cargo test --lib --bins
46+
47+
e2e-test:
48+
name: E2E Test
49+
runs-on: ubuntu-latest
50+
needs: lint-and-test
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Install Rust stable
56+
uses: actions-rust-lang/setup-rust-toolchain@v1
57+
with:
58+
toolchain: stable
59+
60+
- name: Cache cargo registry
61+
uses: actions/cache@v4
62+
with:
63+
path: |
64+
~/.cargo/registry
65+
~/.cargo/git
66+
target
67+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
68+
restore-keys: |
69+
${{ runner.os }}-cargo-
70+
71+
- name: Run E2E tests
72+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
73+
env:
74+
SERPAPI_KEY: ${{ secrets.SERPAPI_KEY }}
75+
run: cargo test -- --ignored
76+
77+
- name: Skip E2E tests (fork PR)
78+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
79+
run: echo "Skipping E2E tests - SERPAPI_KEY unavailable in fork PRs"
80+

0 commit comments

Comments
 (0)