@sprintdock/backend 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/README.md +252 -0
- package/SERVER.md +25 -0
- package/dist/index.d.ts +1536 -0
- package/dist/index.js +4103 -0
- package/drizzle/0000_fresh_roxanne_simpson.sql +51 -0
- package/drizzle/0001_sprint_markdown_content.sql +1 -0
- package/drizzle/0002_task_touched_files.sql +8 -0
- package/drizzle/meta/0000_snapshot.json +372 -0
- package/drizzle/meta/0001_snapshot.json +379 -0
- package/drizzle/meta/_journal.json +27 -0
- package/drizzle.config.ts +14 -0
- package/package.json +40 -0
- package/src/application/container.ts +44 -0
- package/src/application/dto/plan-sprint-analytics.dto.ts +30 -0
- package/src/application/plan.service.ts +123 -0
- package/src/application/sprint.service.ts +118 -0
- package/src/application/task.service.ts +389 -0
- package/src/db/connection.ts +25 -0
- package/src/db/migrator.ts +46 -0
- package/src/db/schema/index.ts +14 -0
- package/src/db/schema/plans.ts +18 -0
- package/src/db/schema/relations.ts +36 -0
- package/src/db/schema/sprints.ts +33 -0
- package/src/db/schema/tasks.ts +62 -0
- package/src/domain/entities/index.ts +30 -0
- package/src/domain/entities/plan.entity.ts +33 -0
- package/src/domain/entities/sprint.entity.ts +44 -0
- package/src/domain/entities/task.entity.ts +80 -0
- package/src/domain/repositories/index.ts +9 -0
- package/src/domain/repositories/plan.repository.ts +21 -0
- package/src/domain/repositories/sprint.repository.ts +19 -0
- package/src/domain/repositories/task.repository.ts +35 -0
- package/src/domain/services/index.ts +9 -0
- package/src/domain/services/plan-domain.service.ts +44 -0
- package/src/domain/services/sprint-domain.service.ts +44 -0
- package/src/domain/services/task-domain.service.ts +136 -0
- package/src/errors/backend-errors.ts +75 -0
- package/src/http/app-factory.ts +55 -0
- package/src/http/controllers/health.controller.ts +33 -0
- package/src/http/controllers/plan.controller.ts +153 -0
- package/src/http/controllers/sprint.controller.ts +111 -0
- package/src/http/controllers/task.controller.ts +158 -0
- package/src/http/express-augmentation.d.ts +20 -0
- package/src/http/middleware/cors.ts +41 -0
- package/src/http/middleware/error-handler.ts +50 -0
- package/src/http/middleware/request-id.ts +28 -0
- package/src/http/middleware/validate.ts +54 -0
- package/src/http/routes/v1/index.ts +39 -0
- package/src/http/routes/v1/plan.routes.ts +51 -0
- package/src/http/routes/v1/schemas.ts +175 -0
- package/src/http/routes/v1/sprint.routes.ts +49 -0
- package/src/http/routes/v1/task.routes.ts +64 -0
- package/src/index.ts +34 -0
- package/src/infrastructure/observability/audit-log.ts +34 -0
- package/src/infrastructure/observability/request-correlation.ts +20 -0
- package/src/infrastructure/repositories/drizzle/drizzle-plan.repository.ts +138 -0
- package/src/infrastructure/repositories/drizzle/drizzle-sprint.repository.ts +137 -0
- package/src/infrastructure/repositories/drizzle/drizzle-task.repository.ts +403 -0
- package/src/infrastructure/repositories/drizzle/index.ts +16 -0
- package/src/infrastructure/repositories/drizzle/row-mappers.ts +106 -0
- package/src/infrastructure/repositories/drizzle/sqlite-db.ts +13 -0
- package/src/infrastructure/repositories/repository-factory.ts +54 -0
- package/src/infrastructure/security/auth-context.ts +35 -0
- package/src/infrastructure/security/input-guard.ts +21 -0
- package/src/infrastructure/security/rate-limiter.ts +65 -0
- package/src/mcp/bootstrap-sprintdock-sqlite.ts +45 -0
- package/src/mcp/mcp-query-helpers.ts +89 -0
- package/src/mcp/mcp-text-formatters.ts +204 -0
- package/src/mcp/mcp-tool-error.ts +24 -0
- package/src/mcp/plugins/context-tools.plugin.ts +107 -0
- package/src/mcp/plugins/default-plugins.ts +23 -0
- package/src/mcp/plugins/index.ts +21 -0
- package/src/mcp/plugins/mcp-tool-kit.ts +90 -0
- package/src/mcp/plugins/plan-tools.plugin.ts +426 -0
- package/src/mcp/plugins/sprint-tools.plugin.ts +396 -0
- package/src/mcp/plugins/task-tools.plugin.ts +528 -0
- package/src/mcp/plugins/task-workflow.plugin.ts +275 -0
- package/src/mcp/plugins/types.ts +45 -0
- package/src/mcp/register-sprintdock-mcp-tools.ts +50 -0
- package/src/mcp/sprintdock-mcp-capabilities.ts +14 -0
- package/src/mcp/sprintdock-mcp-runtime.ts +119 -0
- package/src/mcp/tool-guard.ts +58 -0
- package/src/mcp/transports/http-app-factory.ts +31 -0
- package/src/mcp/transports/http-entry.ts +27 -0
- package/src/mcp/transports/stdio-entry.ts +17 -0
- package/tests/application/container.test.ts +36 -0
- package/tests/application/plan.service.test.ts +114 -0
- package/tests/application/sprint.service.test.ts +138 -0
- package/tests/application/task.service.test.ts +325 -0
- package/tests/db/test-db.test.ts +112 -0
- package/tests/domain/plan-domain.service.test.ts +44 -0
- package/tests/domain/sprint-domain.service.test.ts +38 -0
- package/tests/domain/task-domain.service.test.ts +105 -0
- package/tests/errors/backend-errors.test.ts +44 -0
- package/tests/helpers/test-db.ts +43 -0
- package/tests/http/error-handler.test.ts +37 -0
- package/tests/http/plan.routes.test.ts +128 -0
- package/tests/http/sprint.routes.test.ts +72 -0
- package/tests/http/task.routes.test.ts +130 -0
- package/tests/http/test-app.ts +17 -0
- package/tests/infrastructure/drizzle-plan.repository.test.ts +62 -0
- package/tests/infrastructure/drizzle-sprint.repository.test.ts +49 -0
- package/tests/infrastructure/drizzle-task.repository.test.ts +132 -0
- package/tests/mcp/mcp-text-formatters.test.ts +246 -0
- package/tests/mcp/register-sprintdock-mcp-tools.test.ts +207 -0
- package/tsconfig.json +9 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @sprintdock/backend
|
|
2
|
+
|
|
3
|
+
## 0.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- chore: republish @sprintdock after auth token fix
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @sprintdock/env-manager@0.2.2
|
|
10
|
+
- @sprintdock/shared@0.2.2
|
|
11
|
+
|
|
12
|
+
## 0.4.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- chore: bump 7 workspace package(s) with a patch release.
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @sprintdock/env-manager@0.2.1
|
|
19
|
+
- @sprintdock/shared@0.2.1
|
|
20
|
+
|
|
21
|
+
## Unreleased
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- **REST:** **`GET /api/v1/dashboard-overview`** returns **200** with **`execution: { plan: null, activeSprints: [] }`** and **`throughput`** when there is no active plan (instead of surfacing **404**). Root **`GET /`** discovery JSON notes the separate **`@sprintdock/webui`** app and **`SPRINTDOCK_API_BASE_URL`**.
|
|
26
|
+
- **MCP:** `create_task` and `bulk_create_tasks` use a single **`sprintIdOrSlug`** field (full UUID or sprint slug under the resolved plan), matching `get_sprint` / `get_sprint_detail` and producing JSON Schema that strict MCP clients accept. `list_sprints` lines include `| sprintId:<uuid>` and the footer points agents at **`sprintIdOrSlug`**.
|
|
27
|
+
- **Tooling:** `drizzle.config.ts` uses an explicit **`Config`** type from `drizzle-kit` so the default export does not infer non-portable internal types (TypeScript / IDE clean).
|
|
28
|
+
|
|
29
|
+
## 0.4.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- **Sprints:** `markdownContent` on sprint entity, schema, HTTP `PATCH`, and MCP (`create_sprint` / `update_sprint` / `update_sprint_markdown`).
|
|
34
|
+
- **Tasks:** `task_touched_files` table (repo-relative paths + `fileType`: test, implementation, doc, config, other), hydration on list/get, `create_task` / `update_task` / `PATCH /tasks/:id`, MCP `touchedFiles` on create/update.
|
|
35
|
+
- **Plans:** `GET /plans/:slug/analytics` and plan–sprint task rollup DTO; MCP text formatters adjusted.
|
|
36
|
+
- **Migrations:** `0001_sprint_markdown_content.sql`, `0002_task_touched_files.sql` (single-statement migration for SQLite drivers).
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies
|
|
41
|
+
- @sprintdock/env-manager@0.2.0
|
|
42
|
+
- @sprintdock/shared@0.2.0
|
|
43
|
+
|
|
44
|
+
## 0.3.0
|
|
45
|
+
|
|
46
|
+
### Minor Changes
|
|
47
|
+
|
|
48
|
+
- MCP plugin architecture with 29 tools: rich actionable text, pagination, plan/sprint/task CRUD extensions, bulk create/status, task dependencies and progress tools; exports for registerSprintdockMcpTools and defaultSprintdockMcpPlugins; development guide in README.
|
|
49
|
+
|
|
50
|
+
## 0.2.0
|
|
51
|
+
|
|
52
|
+
### Breaking
|
|
53
|
+
|
|
54
|
+
- **Package identity:** This package is now the **Drizzle + SQLite** implementation (REST `/api/v1`, `runSprintdockMcpServer`, nineteen MCP tools). The previous **JSON plan-tree–only** MCP stack that lived under the same name has been **removed** from the repository.
|
|
55
|
+
|
|
56
|
+
### Added (carried forward from former `@sprintdock/backend-v2`)
|
|
57
|
+
|
|
58
|
+
- SQLite at `.sprintdock/sprintdock.db` (optional `SPRINTDOCK_DB_PATH`), migrations under `drizzle/`, application services, Express HTTP API, MCP stdio and streamable HTTP transports.
|
|
59
|
+
|
|
60
|
+
## 0.1.1 (historical — plan-tree MCP only)
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- fix: improve init overwrite handling, align env resolution sources, and clean backend MCP runtime naming/defaults.
|
|
65
|
+
- Updated dependencies
|
|
66
|
+
- @sprintdock/env-manager@0.1.1
|
|
67
|
+
- @sprintdock/shared@0.1.1
|
|
68
|
+
|
|
69
|
+
## 0.1.0 (historical)
|
|
70
|
+
|
|
71
|
+
### Minor Changes
|
|
72
|
+
|
|
73
|
+
- chore: bump 7 workspace package(s) with a minor release.
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- Updated dependencies
|
|
78
|
+
- @sprintdock/env-manager@0.1.0
|
|
79
|
+
- @sprintdock/shared@0.1.0
|
|
80
|
+
|
|
81
|
+
## 0.0.1 (historical)
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- chore: bump 7 workspace package(s) with a patch release.
|
|
86
|
+
- Updated dependencies
|
|
87
|
+
- @sprintdock/env-manager@0.0.1
|
|
88
|
+
- @sprintdock/shared@0.0.1
|
package/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# `@sprintdock/backend`
|
|
2
|
+
|
|
3
|
+
Sprintdock’s **SQLite-backed** backend: **Drizzle ORM**, **Express REST** under `/api/v1`, and a **Model Context Protocol (MCP)** server with **29** plan/sprint/task tools (rich agent-facing text, bulk helpers, and dependency tools). This package replaces the older JSON plan-tree implementation that previously shipped under the same name (see [CHANGELOG.md](./CHANGELOG.md)).
|
|
4
|
+
|
|
5
|
+
**Version:** `0.3.0` (see `package.json`).
|
|
6
|
+
**Author:** Vikash Sharma.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## What you get
|
|
11
|
+
|
|
12
|
+
| Layer | Responsibility |
|
|
13
|
+
|--------|----------------|
|
|
14
|
+
| **Domain** | Entities, repositories (interfaces), domain services (validation, transitions). |
|
|
15
|
+
| **Application** | `PlanService`, `SprintService`, `TaskService` orchestrating repositories. |
|
|
16
|
+
| **Infrastructure** | Drizzle repositories on **better-sqlite3**. |
|
|
17
|
+
| **HTTP** | Express app factory, JSON body, CORS (optional), request IDs, Zod validation. |
|
|
18
|
+
| **MCP** | Tool registration, stdio or HTTP transport, SQLite bootstrap and migrations. |
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Install & consume (workspace)
|
|
23
|
+
|
|
24
|
+
This repo treats `@sprintdock/backend` as a **private** workspace package. Depend on it from other packages with:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
"@sprintdock/backend": "workspace:*"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Entry is ESM-only: `dist/index.js` + `dist/index.d.ts` (build before tools that read types from `dist`).
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Public API (`src/index.ts`)
|
|
35
|
+
|
|
36
|
+
| Export | Purpose |
|
|
37
|
+
|--------|---------|
|
|
38
|
+
| `createApplicationServices` / `ServiceSet` | Wire app services from a `RepositorySet`. |
|
|
39
|
+
| `createRepositories` / `RepositorySet` / `StorageConfig` | Build repositories (e.g. `sqlite`). |
|
|
40
|
+
| `createHttpApp` / `HttpAppOptions` | Express app with `/api/v1` routes. |
|
|
41
|
+
| `runSprintdockMcpServer` | One-shot MCP process (used by `apps/server`). |
|
|
42
|
+
| `SprintdockMcpRuntime` / `SprintdockMcpRuntimeOptions` / `SprintdockMcpTransportMode` | Class-based MCP lifecycle (`stdio` \| `http`). |
|
|
43
|
+
| `bootstrapSprintdockSqlite` / `SprintdockSqliteBootstrapResult` | Open DB, run migrations, return `ServiceSet` + paths. |
|
|
44
|
+
| `registerSprintdockMcpTools` / `RegisterSprintdockMcpToolsOptions` | Register MCP tools on an SDK `McpServer` (uses `defaultSprintdockMcpPlugins` unless overridden). |
|
|
45
|
+
| `defaultSprintdockMcpPlugins` / `SprintdockMcpToolPlugin` / related types | Plugin list and contract for custom or extended tool registration. |
|
|
46
|
+
| `createSprintdockMcpToolKit` / `SprintdockMcpToolKit` | Shared Zod helpers (`optionalPlanSlug`, pagination, `jsonStructured`) for plugin authors. |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Development guide
|
|
51
|
+
|
|
52
|
+
Use this when you change domain logic, HTTP routes, or MCP tools.
|
|
53
|
+
|
|
54
|
+
### Layout (`src/`)
|
|
55
|
+
|
|
56
|
+
| Area | Path | Notes |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| Domain | `domain/entities`, `domain/repositories`, `domain/services` | Entities, repo interfaces, status transitions & validation. |
|
|
59
|
+
| Application | `application/*.service.ts`, `container.ts` | Orchestration; call domain services + repos. |
|
|
60
|
+
| Infrastructure | `infrastructure/repositories/drizzle/` | SQLite implementations; row mappers. |
|
|
61
|
+
| HTTP | `http/routes/v1/`, `http/middleware/` | Express + Zod (`schemas.ts`). |
|
|
62
|
+
| MCP | `mcp/plugins/*.plugin.ts`, `mcp/register-sprintdock-mcp-tools.ts` | Tool registration; bootstrap/runtime/transports alongside. |
|
|
63
|
+
| Text for agents | `mcp/mcp-text-formatters.ts` | Human-readable `content[0].text` for list/context tools; keep in sync with plugins. |
|
|
64
|
+
| DB schema | `db/schema/` | Drizzle tables; pair changes with `pnpm --filter @sprintdock/backend run db:generate`. |
|
|
65
|
+
|
|
66
|
+
### Workflow
|
|
67
|
+
|
|
68
|
+
1. **Edit code** in `src/` (prefer small, focused changes per layer).
|
|
69
|
+
2. **Schema change?** Update `db/schema/`, run `db:generate`, commit generated SQL under `drizzle/`.
|
|
70
|
+
3. **New or changed behavior?** Add or extend tests under `tests/` (application, http, infrastructure, `tests/mcp/`).
|
|
71
|
+
4. **Verify** (from repo root or this package):
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pnpm --filter @sprintdock/backend run build
|
|
75
|
+
pnpm --filter @sprintdock/backend run typecheck
|
|
76
|
+
pnpm --filter @sprintdock/backend test
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
5. **Consumers** (`apps/server`, etc.) resolve types from **`dist/`** after `build` — run build before relying on new exports.
|
|
80
|
+
|
|
81
|
+
### Adding or changing MCP tools
|
|
82
|
+
|
|
83
|
+
- Prefer a **plugin** under `src/mcp/plugins/` (or extend `defaultSprintdockMcpPlugins` in `default-plugins.ts`). Each plugin implements `SprintdockMcpToolPlugin` (`register(server, { deps, kit })`).
|
|
84
|
+
- Use **`kit`** from `mcp-tool-kit.ts` for `optionalPlanSlug`, pagination fields, and `jsonStructured` for `structuredContent`.
|
|
85
|
+
- **List/read tools** should return **actionable text** (slugs, titles, short ids) via helpers in `mcp-text-formatters.ts`, not only counts.
|
|
86
|
+
- **Mutations** should call **`guardToolExecution`** (see existing plugins) so rate limit / auth stay consistent.
|
|
87
|
+
- After adding a tool, update **`tests/mcp/register-sprintdock-mcp-tools.test.ts`** (`EXPECTED_TOOL_NAMES`) and this README’s tool list.
|
|
88
|
+
|
|
89
|
+
### REST vs MCP
|
|
90
|
+
|
|
91
|
+
REST and MCP share the same services and domain rules. If you add a capability only to MCP, consider whether `/api/v1` should expose it too for parity (see route files under `http/routes/v1/`).
|
|
92
|
+
|
|
93
|
+
### Further docs
|
|
94
|
+
|
|
95
|
+
- Root repo **Local Development** (requirements, `pnpm build`, smoke tests): [../../README.md](../../README.md).
|
|
96
|
+
- Runtime wiring for MCP: [SERVER.md](./SERVER.md).
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Environment
|
|
101
|
+
|
|
102
|
+
Resolution order (low → high): `~/.sprintdock/.env` → `<workspace>/.sprintdock/.env` → `process.env` (via `@sprintdock/env-manager`). See **[`packages/env-manager/.env.example`](../env-manager/.env.example)** for a full template.
|
|
103
|
+
|
|
104
|
+
| Variable | Role |
|
|
105
|
+
|----------|------|
|
|
106
|
+
| `SPRINTDOCK_DB_PATH` | Optional SQLite file path. Absolute, or relative to workspace root. Default: `<workspace>/.sprintdock/sprintdock.db`. |
|
|
107
|
+
| `SPRINTDOCK_MCP_TRANSPORT` | `stdio` (default) or `http`. |
|
|
108
|
+
| `SPRINTDOCK_MCP_HTTP_HOST` | Bind host when transport is `http` (default `127.0.0.1`). |
|
|
109
|
+
| `SPRINTDOCK_MCP_HTTP_PORT` | Port when transport is `http` (default `3030`). |
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Database & migrations
|
|
114
|
+
|
|
115
|
+
- **Driver:** [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) (requires a compatible Node version; prebuilds cover current LTS targets).
|
|
116
|
+
- **ORM:** [Drizzle](https://orm.drizzle.team/).
|
|
117
|
+
- **Migrations:** SQL files under [`drizzle/`](./drizzle/). At runtime, `runMigrations` locates `drizzle/meta/_journal.json` by walking up from the loaded module so it works from both `src` and bundled `dist`.
|
|
118
|
+
- **Schema:** `src/db/schema/` — plans, sprints, tasks (and relations).
|
|
119
|
+
|
|
120
|
+
Generate new migrations after schema changes:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
pnpm --filter @sprintdock/backend run db:generate
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## REST API
|
|
129
|
+
|
|
130
|
+
Base path: **`/api/v1`** (mount `createHttpApp` at the server root so routes are `/api/v1/...`).
|
|
131
|
+
|
|
132
|
+
### Health
|
|
133
|
+
|
|
134
|
+
| Method | Path |
|
|
135
|
+
|--------|------|
|
|
136
|
+
| `GET` | `/health` |
|
|
137
|
+
|
|
138
|
+
### Plans & context
|
|
139
|
+
|
|
140
|
+
| Method | Path |
|
|
141
|
+
|--------|------|
|
|
142
|
+
| `GET` | `/plans` |
|
|
143
|
+
| `POST` | `/plans` |
|
|
144
|
+
| `GET` | `/plans/:idOrSlug` |
|
|
145
|
+
| `PATCH` | `/plans/:idOrSlug` |
|
|
146
|
+
| `POST` | `/plans/:idOrSlug/activate` |
|
|
147
|
+
| `GET` | `/execution-context` |
|
|
148
|
+
|
|
149
|
+
### Sprints
|
|
150
|
+
|
|
151
|
+
| Method | Path |
|
|
152
|
+
|--------|------|
|
|
153
|
+
| `GET` | `/plans/:planId/sprints` |
|
|
154
|
+
| `POST` | `/plans/:planId/sprints` |
|
|
155
|
+
| `GET` | `/sprints/:id` |
|
|
156
|
+
| `PATCH` | `/sprints/:id/status` |
|
|
157
|
+
|
|
158
|
+
### Tasks
|
|
159
|
+
|
|
160
|
+
| Method | Path |
|
|
161
|
+
|--------|------|
|
|
162
|
+
| `GET` | `/sprints/:sprintId/tasks` |
|
|
163
|
+
| `POST` | `/sprints/:sprintId/tasks` |
|
|
164
|
+
| `GET` | `/tasks/:id` |
|
|
165
|
+
| `PATCH` | `/tasks/:id/status` |
|
|
166
|
+
| `PATCH` | `/tasks/:id/assign` |
|
|
167
|
+
| `POST` | `/tasks/:id/move` |
|
|
168
|
+
| `DELETE` | `/tasks/:id` |
|
|
169
|
+
|
|
170
|
+
Request/response shapes are validated with Zod in `src/http/routes/v1/schemas.ts`.
|
|
171
|
+
|
|
172
|
+
### Domain enums (API / MCP)
|
|
173
|
+
|
|
174
|
+
- **Plan status:** `draft` \| `active` \| `completed` \| `archived` (see domain entity).
|
|
175
|
+
- **Sprint status:** `planned` \| `active` \| `completed` \| `archived` (transitions enforced in domain).
|
|
176
|
+
- **Task status:** `todo` \| `in_progress` \| `blocked` \| `done`.
|
|
177
|
+
- **Task priority:** `low` \| `medium` \| `high` \| `critical`.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## MCP
|
|
182
|
+
|
|
183
|
+
- **Server name:** `sprintdock-backend` (SDK `McpServer` metadata).
|
|
184
|
+
- **Transports:** **stdio** (default) or **HTTP** (streamable HTTP entry in `src/mcp/transports/`).
|
|
185
|
+
- **Bootstrap:** Opens SQLite, ensures `.sprintdock` directory as needed, runs migrations, wires `registerSprintdockMcpTools` with in-memory rate limiting, local auth context, request correlation, and console audit logging.
|
|
186
|
+
|
|
187
|
+
### Tools (29)
|
|
188
|
+
|
|
189
|
+
**Plans:** `list_plans` (optional `limit`/`offset`, `total`), `create_plan`, `set_active_plan`, `get_active_plan`, `get_plan_summary`, `update_plan_markdown`, `delete_plan`, `update_plan`, `get_plan_progress`.
|
|
190
|
+
|
|
191
|
+
**Context:** `get_execution_context`, `get_sprint_detail`.
|
|
192
|
+
|
|
193
|
+
**Sprints:** `create_sprint`, `list_sprints` (optional pagination), `get_sprint` (`sprintIdOrSlug`), `update_sprint_status` (`sprintIdOrSlug`), `delete_sprint` (`sprintIdOrSlug`), `update_sprint` (`sprintIdOrSlug`).
|
|
194
|
+
|
|
195
|
+
**Tasks:** `create_task`, `list_tasks` (optional pagination), `get_task`, `update_task_status`, `assign_task`, `move_task`, `delete_task`, `update_task`, `bulk_create_tasks`, `bulk_update_task_status`, `get_task_dependencies`, `update_task_dependencies`.
|
|
196
|
+
|
|
197
|
+
List/read tools format **actionable lines** in `content[0].text` (slugs, titles, short ids, counts). Many tools accept optional **`planSlug`** to target a non-active plan. Mutations go through **`guardToolExecution`** (rate limit / auth).
|
|
198
|
+
|
|
199
|
+
### Plugin-style registration
|
|
200
|
+
|
|
201
|
+
Tools are registered from small **plugins** under `src/mcp/plugins/` (plan, context, sprint, task, task-workflow). `registerSprintdockMcpTools(server, deps)` runs `defaultSprintdockMcpPlugins` in order. To add tools, pass a custom list (or append to the default):
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
import {
|
|
205
|
+
defaultSprintdockMcpPlugins,
|
|
206
|
+
registerSprintdockMcpTools,
|
|
207
|
+
type SprintdockMcpToolPlugin
|
|
208
|
+
} from "@sprintdock/backend";
|
|
209
|
+
|
|
210
|
+
const myPlugin: SprintdockMcpToolPlugin = {
|
|
211
|
+
id: "acme/extra-tools",
|
|
212
|
+
register(server, { deps, kit }) {
|
|
213
|
+
server.registerTool(/* name, schema, handler */);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
registerSprintdockMcpTools(server, deps, {
|
|
218
|
+
plugins: [...defaultSprintdockMcpPlugins, myPlugin]
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Shared Zod fields and helpers live in `mcp/plugins/mcp-tool-kit.ts` (`kit` on the plugin context). Advanced use: import `createSprintdockMcpToolKit` from `./mcp/plugins/mcp-tool-kit.js` in-repo.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Scripts (`package.json`)
|
|
227
|
+
|
|
228
|
+
| Script | Command |
|
|
229
|
+
|--------|---------|
|
|
230
|
+
| `build` | `tsup` ESM bundle + `.d.ts` to `dist/`. |
|
|
231
|
+
| `typecheck` | `tsc --noEmit`. |
|
|
232
|
+
| `test` | Node test runner with `tsx` import hook (`tests/**/*.test.ts`). |
|
|
233
|
+
| `db:generate` | `drizzle-kit generate`. |
|
|
234
|
+
| `clean` | Remove `dist/`. |
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Verify locally
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
pnpm --filter @sprintdock/backend run build
|
|
242
|
+
pnpm --filter @sprintdock/backend run typecheck
|
|
243
|
+
pnpm --filter @sprintdock/backend test
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Further reading
|
|
249
|
+
|
|
250
|
+
- **[Development guide](#development-guide)** — Package layout, MCP plugins, tests, and workflow (above).
|
|
251
|
+
- **[SERVER.md](./SERVER.md)** — Runtime notes (what calls `runSprintdockMcpServer`, verify commands).
|
|
252
|
+
- **[CHANGELOG.md](./CHANGELOG.md)** — Version history and breaking changes (`0.2.0` migration from plan-tree MCP).
|
package/SERVER.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# `@sprintdock/backend` runtime notes
|
|
2
|
+
|
|
3
|
+
## What this package is
|
|
4
|
+
|
|
5
|
+
`@sprintdock/backend` provides:
|
|
6
|
+
|
|
7
|
+
- **SQLite** persistence (default `.sprintdock/sprintdock.db`, override with `SPRINTDOCK_DB_PATH`)
|
|
8
|
+
- **REST** via `createHttpApp` → `/api/v1/*`
|
|
9
|
+
- **MCP** via `runSprintdockMcpServer` / `SprintdockMcpRuntime` (stdio or HTTP)
|
|
10
|
+
|
|
11
|
+
`apps/server` MCP mode calls **`runSprintdockMcpServer`** from this package.
|
|
12
|
+
|
|
13
|
+
**REST** can be started from the same binary with **`sprintdock serve`**, which mounts **`createHttpApp`** and listens on **`SPRINTDOCK_REST_HTTP_HOST`** / **`SPRINTDOCK_REST_HTTP_PORT`** (default `127.0.0.1:8787`). See `packages/env-manager/.env.example`.
|
|
14
|
+
|
|
15
|
+
## Environment
|
|
16
|
+
|
|
17
|
+
See **`packages/env-manager/.env.example`**. Resolution: `~/.sprintdock/.env` → `<workspace>/.sprintdock/.env` → `process.env`.
|
|
18
|
+
|
|
19
|
+
## Verify
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm --filter @sprintdock/backend typecheck
|
|
23
|
+
pnpm --filter @sprintdock/backend test
|
|
24
|
+
pnpm --filter @sprintdock/backend run build
|
|
25
|
+
```
|