Spaces:
Build error
Build error
|
Download docs/dev_a_prd.md from Danisz/spymaster-dev-b: direct link, hf CLI and curl.
- Browser
- Download file 7.82 kB
-
https://huggingface.co/spaces/Danisz/spymaster-dev-b/resolve/main/docs/dev_a_prd.md
- Command line
-
hf download hf://spaces/Danisz/spymaster-dev-b/docs/dev_a_prd.md
-
curl -L -o dev_a_prd.md https://huggingface.co/spaces/Danisz/spymaster-dev-b/resolve/main/docs/dev_a_prd.md
7.82 kB
| # **PRD β Dev A: Server Layer & Runner/Packaging** | |
| --- | |
| ## 1 β’ Goal | |
| As Dev A, your goal is to develop the **Server Layer** of the local Node.js application. This involves creating the MCP server, defining the resources and tools for interacting with the Codenames game, and handling communication with the Browser Layer via a defined interface (`ICodenamesBrowser`). You will also contribute to the top-level `runner.ts` script and the project's packaging configuration (`package.json`, `tsconfig.json`). | |
| --- | |
| ## 2 β’ Key Technologies (Focus) | |
| - **Node.js** & **npm** | |
| - **`modelcontextprotocol` SDK** (TypeScript) | |
| - **TypeScript** | |
| - Understanding of `npm link` / `npx` for integration and testing | |
| --- | |
| ## 3 β’ Responsibilities & Deliverables | |
| | Module / Layer | Responsibilities | Deliverables | | |
| | :--------------------- | :------------------------------------------------------------------------------------------------------------- | :-------------------------------- | | |
| | **Server Layer** | Node.js MCP server logic:<br>β’ Initialize MCP SDK<br>β’ Define MCP resources & tools (e.g., `getBoardState`, `giveClue`)<br>β’ Handle MCP requests<br>β’ Call Browser Layer API (`ICodenamesBrowser`) | `server/server.ts`, `server/schemas.ts`, `server/tests/` | | |
| | **Runner & Packaging** | Top-level script & setup contributions:<br>β’ Implement relevant parts of `runner.ts` (initialize Server Layer, wire to Browser Layer)<br>β’ **Drive definition** of `ICodenamesBrowser` interface<br>β’ Configure `package.json` (`name`, `version`, `bin`, `files`, `scripts`)<br>β’ Configure `tsconfig.json` | Contributions to: `runner.ts`, `package.json`, `tsconfig.json`, `shared/types.ts` | | |
| --- | |
| ## 4 β’ Suggested Folder Structure (Focus) | |
| ``` | |
| spymaster/ | |
| βββ server/ # <-- Your primary focus | |
| β βββ server.ts # <-- MCP logic | |
| β βββ schemas.ts # <-- MCP resource/tool schemas | |
| β βββ tests/ # <-- Your unit tests | |
| βββ browser/ # <-- Dev B's area (interact via ICodenamesBrowser) | |
| β βββ ... | |
| βββ runner.ts # <-- Collaborate on setup/wiring | |
| βββ shared/ # <-- Define ICodenamesBrowser here | |
| β βββ types.ts | |
| βββ package.json # <-- Configure build, link, run | |
| βββ tsconfig.json # <-- Configure TS compilation | |
| βββ README.md | |
| βββ docs/ | |
| βββ overall_prd.md | |
| βββ dev_a_prd.md # <-- This document | |
| ``` | |
| --- | |
| ## 5 β’ Architecture & Execution Flow (Your Role) | |
| 1. **Build:** Ensure `npm run build` (using `tsconfig.json` you configure) compiles `server/` and `runner.ts` correctly into `dist/`. | |
| 2. **Linking:** Use `npm link` to make the package executable. | |
| 3. **Execution:** `npx your-package-name` runs `dist/runner.js`. | |
| 4. **Runner (`dist/runner.js`):** | |
| - Initializes the **Browser Layer** (handled by Dev B, provides `ICodenamesBrowser` instance). | |
| - You ensure `runner.ts` initializes your **Server Layer**, passing the `ICodenamesBrowser` instance to it. | |
| - Your Server Layer starts the MCP server. | |
| 5. **Server Layer:** Your code handles incoming MCP requests, translates them into calls to the `ICodenamesBrowser` interface methods provided by the Browser Layer. | |
| --- | |
| ## 6 β’ Development Steps (Your Flow) | |
| | Phase | Your Actions (Dev A: Server Layer / Build / Runner) | Key Interaction / Synchronization Point | | |
| | :--------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------- | | |
| | **1. Setup, Config & Contract** | Setup `server/`. Configure `package.json`, `tsconfig.json`. **Drive definition** of `ICodenamesBrowser` interface in `shared/types.ts`. | **Critical Sync:** Agree with Dev B on `ICodenamesBrowser` interface & `package.json` structure (`bin`, `runner.ts`). | | |
| | **2. Independent Implementation** | Implement Server Layer (`server/`) against a **mock** implementation of `ICodenamesBrowser`. Implement `runner.ts` wiring logic. Unit test `server/` logic using the mock. | **None.** Focus on your layer using the defined interface and mock. | | |
| | **3. Build, Link & Smoke Test** | Run `npm run build`. Run `npm link`. Run `npx your-package-name` smoke test. Verify your server starts up correctly (even if browser part fails initially). | **Sync Point:** Verify successful build, link, basic `npx` execution. Inform Dev B. | | |
| | **4. Integration Test & Debug** | **Lead** E2E testing using MCP Inspector connected to the `npx`-run process. Debug MCP request/response flow and issues related to interaction with the Browser Layer API. | **Sync Point:** Collaborative E2E testing & debugging using `npx`-launched app. You lead, Dev B supports. | | |
| --- | |
| ## 7 β’ Testing Approach (Your Responsibility) | |
| - **Unit Tests (`server/tests/`):** | |
| - Thoroughly test your `server.ts` and `schemas.ts` logic. | |
| - **Crucially, mock the `ICodenamesBrowser` interface.** Your unit tests should *not* depend on the actual Playwright implementation. Verify that your server logic correctly calls the mock interface methods based on MCP requests. | |
| - **E2E & Primary Validation:** | |
| - After `npm run build` and `npm link`, you will primarily drive E2E testing. | |
| - Run `npx your-package-name`. | |
| - Connect MCP Inspector. | |
| - Execute MCP commands (`getBoardState`, `giveClue`, `makeGuess`, etc.). | |
| - Verify: | |
| - Correct MCP responses are generated by your server. | |
| - Expected actions occur in the browser (debugging with Dev B if browser actions fail). | |
| - Your server correctly handles the data/responses received from the Browser Layer via the `ICodenamesBrowser` interface. | |
| --- | |
| ## 8 β’ Key Risks (Focus) | |
| - **Interface Mismatch:** Your server code expects one thing from `ICodenamesBrowser`, but the Browser Layer implements it differently. | |
| - **Mitigation:** Clear TypeScript interface definition (`shared/types.ts`), early integration testing via `npx` run, frequent communication with Dev B. | |
| - **Build/Link Issues:** Problems with `tsconfig.json`, `package.json` (`bin`, `files`), or `npm link`. | |
| - **Mitigation:** Verify build output (`dist/`), check global links (`npm ls -g --depth=0 --link=true`), ensure `runner.ts` compiles correctly and `package.json` points to it. | |
| - **MCP Logic Errors:** Incorrectly handling MCP requests or formatting responses. | |
| - **Mitigation:** Strong unit tests with mocked browser interface, thorough E2E testing with MCP Inspector. | |
| --- | |
| ## 9 β’ Acceptance Criteria (Your Contribution) | |
| - `npm run build` successfully compiles `server/`, `shared/`, and `runner.ts` into `dist/`. | |
| - `npm link` successfully links the package defined in `package.json`. | |
| - `npx your-package-name` starts the `runner.ts` script, which successfully initializes and starts your MCP server. | |
| - MCP Inspector can connect to your server process. | |
| - MCP Inspector can invoke all defined MCP tools (`getBoardState`, `getTeamTurn`, `getClueLog`, `giveClue`, `makeGuess`, `endTurn`). | |
| - Your Server Layer correctly processes these requests, calls the appropriate methods on the (mocked or real) `ICodenamesBrowser` interface, and returns accurate responses based on the interface's return values. | |
| --- |