23
packages/api-server/.ruler/AGENTS.md
Normal file
23
packages/api-server/.ruler/AGENTS.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# packages/api-server
|
||||
|
||||
## Scope
|
||||
|
||||
- This package is the HTTP transport layer over `@marketplace-scrapers/core`.
|
||||
- Route files in `src/routes/*.ts` should parse inputs, call core, and map responses/errors.
|
||||
|
||||
## Keep Thin
|
||||
|
||||
- Do not move scraping, parsing, selector, or cookie-loading logic into routes.
|
||||
- If route code starts branching on marketplace behavior, push that behavior back into `packages/core`.
|
||||
|
||||
## Route Conventions
|
||||
|
||||
- Register new routes in `src/index.ts`.
|
||||
- Follow existing input precedence where present: `query` header first, then `q` search param.
|
||||
- Preserve existing response shape style: `Response.json(...)`, `400` for bad input/errors, `404` for empty result sets, `200` for success.
|
||||
- Keep query parameter names aligned with the MCP server because MCP builds URLs against these endpoints.
|
||||
|
||||
## Verify
|
||||
|
||||
- `bun run --cwd packages/api-server build`
|
||||
- `bun run ci`
|
||||
31
packages/core/.ruler/AGENTS.md
Normal file
31
packages/core/.ruler/AGENTS.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# packages/core
|
||||
|
||||
## Scope
|
||||
|
||||
- This package owns scraper behavior, parsing, result shapes, shared cookie handling, and shared HTTP utilities.
|
||||
- Put marketplace-specific logic in `src/scrapers/*.ts`.
|
||||
- Put reusable cross-marketplace helpers in `src/utils/*` only when at least two callers need them.
|
||||
|
||||
## Keep Stable
|
||||
|
||||
- Cookie loading order is a hard invariant: parameter > env var > file.
|
||||
- Exported names in `src/index.ts` are the package contract for `api-server` and `mcp-server`.
|
||||
- Keep result field semantics stable across refactors; adapter packages should not need to reinterpret core results.
|
||||
|
||||
## Editing Rules
|
||||
|
||||
- New marketplace behavior belongs here, not in route or protocol layers.
|
||||
- Isolate marketplace-specific hacks/selectors inside the owning scraper file unless they are genuinely shared.
|
||||
- If a new helper is scraper-local, keep it local. Do not promote it into `utils` early.
|
||||
- If you change shared types or exports, check downstream imports in both adapter packages.
|
||||
|
||||
## Tests
|
||||
|
||||
- Tests live in `test/*.test.ts` and use `bun:test`.
|
||||
- Mock network and file edges. Do not depend on live cookies, live HTTP, wall clock timing, or external sessions.
|
||||
- Favor parser/extraction tests with fixture-like inline HTML/JSON over broad end-to-end behavior.
|
||||
|
||||
## Verify
|
||||
|
||||
- `bun test packages/core/test`
|
||||
- `bun run ci`
|
||||
25
packages/mcp-server/.ruler/AGENTS.md
Normal file
25
packages/mcp-server/.ruler/AGENTS.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# packages/mcp-server
|
||||
|
||||
## Scope
|
||||
|
||||
- This package is the MCP/JSON-RPC adapter over the API server.
|
||||
- `src/protocol/tools.ts` defines tool schemas.
|
||||
- `src/protocol/handler.ts` maps tool calls to API requests and JSON-RPC responses.
|
||||
- `src/protocol/metadata.ts` exposes discovery metadata and protocol versioning.
|
||||
|
||||
## Keep In Sync
|
||||
|
||||
- Tool definitions, handler argument mapping, and server metadata must stay consistent.
|
||||
- When adding or renaming a tool, update `tools.ts` and `handler.ts` together.
|
||||
- If protocol version or server-card details change, update both `metadata.ts` and initialize responses in `handler.ts`.
|
||||
|
||||
## Protocol Rules
|
||||
|
||||
- Use MCP/JSON-RPC error codes and response envelopes, not ad-hoc API-style payloads.
|
||||
- Keep this layer transport-focused. Marketplace behavior belongs in `packages/core`; HTTP semantics belong in `packages/api-server`.
|
||||
- Preserve the current tool result shape unless the protocol contract is being changed deliberately: text content with JSON-stringified API results.
|
||||
|
||||
## Verify
|
||||
|
||||
- `bun run --cwd packages/mcp-server build`
|
||||
- `bun run ci`
|
||||
Reference in New Issue
Block a user