|
| 1 | +<!-- version-type: patch --> |
| 2 | +# service |
| 3 | + |
| 4 | +<!-- |
| 5 | +FORMATTING GUIDE: |
| 6 | +
|
| 7 | +### Detailed Entry (appears first when merging) |
| 8 | +
|
| 9 | +Use h3 (###) and below for detailed entries with paragraphs, code examples, and lists. |
| 10 | +
|
| 11 | +### Simple List Items |
| 12 | +
|
| 13 | +- Simple changes can be added as list items |
| 14 | +- They are collected together at the bottom of each section |
| 15 | +
|
| 16 | +TIP: When multiple changelog drafts are merged, heading-based entries |
| 17 | +appear before simple list items within each section. |
| 18 | +--> |
| 19 | + |
| 20 | +## ✨ Features |
| 21 | + |
| 22 | +### REST API Endpoints |
| 23 | + |
| 24 | +Added per-domain REST API modules with full CRUD and custom actions: |
| 25 | + |
| 26 | +- `ServicesApi` — service lifecycle (start/stop/restart/install/build/pull/setup/update), log retrieval and clearing, state history, and file application |
| 27 | +- `StacksApi` — stack CRUD, export to portable JSON, import with config overrides, and stack setup orchestration |
| 28 | +- `PrerequisitesApi` — prerequisite CRUD and dependency check execution (supports command, package manager, and environment variable checks) |
| 29 | +- `GithubRepositoriesApi` — repository CRUD with Git URL validation |
| 30 | +- `TokensApi` — API token creation with SHA-256 hashing, listing (public view only), and revocation |
| 31 | +- `IdentityApi` — session-based authentication and password reset |
| 32 | +- `InstallApi` — first-run service status check and initial admin setup |
| 33 | +- `SystemApi` — environment variable availability checks |
| 34 | + |
| 35 | +### Process Manager |
| 36 | + |
| 37 | +Added `ProcessManager` service that orchestrates child process lifecycle for stack services: clone repositories, install dependencies, build projects, and run services. Captures stdout/stderr streams, persists log entries via `LogStorageService`, and broadcasts status changes over WebSocket. |
| 38 | + |
| 39 | +### MCP Server |
| 40 | + |
| 41 | +Added Model Context Protocol server on a dedicated HTTP port (default 9091) with tools for managing stacks, services, repositories, prerequisites, environment variables, service files, and system status — enabling AI assistant integration. |
| 42 | + |
| 43 | +### Git Integration |
| 44 | + |
| 45 | +- Added `GitService` for repository operations: clone, fetch, pull (with update detection), branch listing, current branch, and checkout |
| 46 | +- Added `GitWatcher` for periodic polling of branch changes with WebSocket notifications |
| 47 | + |
| 48 | +### Log Storage |
| 49 | + |
| 50 | +Added `LogStorageService` with durable log entry persistence, per-service pruning to cap storage, text search filtering, and batch clearing. |
| 51 | + |
| 52 | +### Bearer Token Authentication |
| 53 | + |
| 54 | +Added `bearer-token-auth` middleware that resolves `Authorization: Bearer <token>` headers by SHA-256 hashing the token, looking up the matching `ApiToken`, and returning the associated user. |
| 55 | + |
| 56 | +### Real-Time Communication |
| 57 | + |
| 58 | +- Added `WebsocketService` for broadcasting typed messages to connected clients |
| 59 | +- Added entity sync setup with debounced updates for `ServiceLogEntry` and `ServiceStateHistory` |
| 60 | + |
| 61 | +### Configuration |
| 62 | + |
| 63 | +- Added configurable CORS origins via `CORS_ORIGINS` environment variable (comma-separated list) |
| 64 | +- Added `MCP_PORT` environment variable for MCP server port configuration |
| 65 | +- Extended `Config` with stack-craft-specific settings (`mainDirectory`, data storage path) |
| 66 | + |
| 67 | +### Data Store |
| 68 | + |
| 69 | +- Added `setup-data-store` with in-memory stores, filesystem persistence, and authorization rules for all entities |
| 70 | +- Added `setup-log-store` for service log entries with auto-incrementing IDs |
| 71 | + |
| 72 | +### Utilities |
| 73 | + |
| 74 | +- Added `resolve-service-cwd` for computing service working directories from stack/service/repo config |
| 75 | +- Added `apply-service-files` for writing required files into service directories |
| 76 | +- Added `resolve-path` for safe path resolution within allowed directories |
| 77 | + |
| 78 | +## 🐛 Bug Fixes |
| 79 | + |
| 80 | +- Fixed detached child processes not being properly terminated on service stop |
| 81 | +- Fixed missing entity sync causing stale data in frontend views |
| 82 | +- Fixed service installer not correctly reporting installation completion status |
| 83 | + |
| 84 | +## ♻️ Refactoring |
| 85 | + |
| 86 | +- Restructured REST API handlers from a single file into per-domain modules under `app-models/` |
| 87 | +- Extracted service lifecycle logic into dedicated action handlers with proper authorization |
| 88 | + |
| 89 | +## 🧪 Tests |
| 90 | + |
| 91 | +- Added unit tests for `ProcessManager` covering spawn, kill, and concurrent process scenarios |
| 92 | +- Added unit tests for `check-prerequisite-action` covering command, package manager, and env variable checks |
| 93 | +- Added unit tests for `service-lifecycle-action` covering start, stop, and restart flows |
| 94 | +- Added unit tests for `setup-tokens-rest-api` covering token creation, listing, and revocation |
| 95 | +- Added unit tests for `import-export-actions` covering stack export and import with conflict handling |
| 96 | +- Added unit tests for `check-env-availability-action` covering env variable presence detection |
| 97 | +- Added unit tests for `bearer-token-auth` covering valid/invalid/missing token scenarios |
| 98 | +- Added unit tests for `LogStorageService` covering entry storage, retrieval, pruning, and clearing |
| 99 | +- Added unit tests for `GitService` covering clone, pull, branch listing, and checkout |
| 100 | +- Added unit tests for `ServiceInstaller` covering installation flow |
| 101 | +- Added unit tests for `get-cors-options` and `get-port` configuration helpers |
| 102 | +- Added unit tests for `Config` service |
0 commit comments