servherd 0.0.1 → 1.0.0

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.
Files changed (95) hide show
  1. package/CONTRIBUTING.md +250 -0
  2. package/LICENSE +21 -0
  3. package/README.md +653 -29
  4. package/dist/cli/commands/config.d.ts +35 -0
  5. package/dist/cli/commands/config.js +336 -0
  6. package/dist/cli/commands/info.d.ts +37 -0
  7. package/dist/cli/commands/info.js +98 -0
  8. package/dist/cli/commands/list.d.ts +26 -0
  9. package/dist/cli/commands/list.js +86 -0
  10. package/dist/cli/commands/logs.d.ts +46 -0
  11. package/dist/cli/commands/logs.js +292 -0
  12. package/dist/cli/commands/mcp.d.ts +5 -0
  13. package/dist/cli/commands/mcp.js +17 -0
  14. package/dist/cli/commands/refresh.d.ts +20 -0
  15. package/dist/cli/commands/refresh.js +139 -0
  16. package/dist/cli/commands/remove.d.ts +20 -0
  17. package/dist/cli/commands/remove.js +144 -0
  18. package/dist/cli/commands/restart.d.ts +25 -0
  19. package/dist/cli/commands/restart.js +177 -0
  20. package/dist/cli/commands/start.d.ts +37 -0
  21. package/dist/cli/commands/start.js +293 -0
  22. package/dist/cli/commands/stop.d.ts +20 -0
  23. package/dist/cli/commands/stop.js +108 -0
  24. package/dist/cli/index.d.ts +9 -0
  25. package/dist/cli/index.js +160 -0
  26. package/dist/cli/output/formatters.d.ts +117 -0
  27. package/dist/cli/output/formatters.js +454 -0
  28. package/dist/cli/output/json-formatter.d.ts +22 -0
  29. package/dist/cli/output/json-formatter.js +40 -0
  30. package/dist/index.d.ts +15 -0
  31. package/dist/index.js +25 -0
  32. package/dist/mcp/index.d.ts +14 -0
  33. package/dist/mcp/index.js +352 -0
  34. package/dist/mcp/resources/servers.d.ts +14 -0
  35. package/dist/mcp/resources/servers.js +128 -0
  36. package/dist/mcp/tools/config.d.ts +33 -0
  37. package/dist/mcp/tools/config.js +88 -0
  38. package/dist/mcp/tools/info.d.ts +36 -0
  39. package/dist/mcp/tools/info.js +65 -0
  40. package/dist/mcp/tools/list.d.ts +36 -0
  41. package/dist/mcp/tools/list.js +49 -0
  42. package/dist/mcp/tools/logs.d.ts +44 -0
  43. package/dist/mcp/tools/logs.js +55 -0
  44. package/dist/mcp/tools/refresh.d.ts +33 -0
  45. package/dist/mcp/tools/refresh.js +54 -0
  46. package/dist/mcp/tools/remove.d.ts +23 -0
  47. package/dist/mcp/tools/remove.js +43 -0
  48. package/dist/mcp/tools/restart.d.ts +23 -0
  49. package/dist/mcp/tools/restart.js +42 -0
  50. package/dist/mcp/tools/start.d.ts +38 -0
  51. package/dist/mcp/tools/start.js +73 -0
  52. package/dist/mcp/tools/stop.d.ts +23 -0
  53. package/dist/mcp/tools/stop.js +40 -0
  54. package/dist/services/config.service.d.ts +80 -0
  55. package/dist/services/config.service.js +227 -0
  56. package/dist/services/port.service.d.ts +82 -0
  57. package/dist/services/port.service.js +151 -0
  58. package/dist/services/process.service.d.ts +61 -0
  59. package/dist/services/process.service.js +220 -0
  60. package/dist/services/registry.service.d.ts +50 -0
  61. package/dist/services/registry.service.js +157 -0
  62. package/dist/types/config.d.ts +107 -0
  63. package/dist/types/config.js +44 -0
  64. package/dist/types/errors.d.ts +102 -0
  65. package/dist/types/errors.js +197 -0
  66. package/dist/types/pm2.d.ts +50 -0
  67. package/dist/types/pm2.js +4 -0
  68. package/dist/types/registry.d.ts +230 -0
  69. package/dist/types/registry.js +33 -0
  70. package/dist/utils/ci-detector.d.ts +31 -0
  71. package/dist/utils/ci-detector.js +68 -0
  72. package/dist/utils/config-drift.d.ts +71 -0
  73. package/dist/utils/config-drift.js +128 -0
  74. package/dist/utils/error-handler.d.ts +21 -0
  75. package/dist/utils/error-handler.js +38 -0
  76. package/dist/utils/log-follower.d.ts +10 -0
  77. package/dist/utils/log-follower.js +98 -0
  78. package/dist/utils/logger.d.ts +11 -0
  79. package/dist/utils/logger.js +24 -0
  80. package/dist/utils/names.d.ts +7 -0
  81. package/dist/utils/names.js +20 -0
  82. package/dist/utils/template.d.ts +88 -0
  83. package/dist/utils/template.js +180 -0
  84. package/dist/utils/time-parser.d.ts +19 -0
  85. package/dist/utils/time-parser.js +54 -0
  86. package/docs/ci-cd.md +408 -0
  87. package/docs/configuration.md +325 -0
  88. package/docs/mcp-integration.md +411 -0
  89. package/examples/basic-usage/README.md +187 -0
  90. package/examples/ci-github-actions/workflow.yml +195 -0
  91. package/examples/mcp-claude-code/README.md +213 -0
  92. package/examples/multi-server/README.md +270 -0
  93. package/examples/storybook/README.md +187 -0
  94. package/examples/vite-project/README.md +251 -0
  95. package/package.json +123 -6
@@ -0,0 +1,250 @@
1
+ # Contributing to servherd
2
+
3
+ Thank you for your interest in contributing to servherd! This document provides guidelines and instructions for contributing.
4
+
5
+ ## Development Setup
6
+
7
+ ### Prerequisites
8
+
9
+ - Node.js 20 or later
10
+ - npm 9 or later
11
+ - Git
12
+
13
+ ### Getting Started
14
+
15
+ 1. Clone the repository:
16
+ ```bash
17
+ git clone https://github.com/yourusername/servherd.git
18
+ cd servherd
19
+ ```
20
+
21
+ 2. Install dependencies:
22
+ ```bash
23
+ npm install
24
+ ```
25
+
26
+ 3. Build the project:
27
+ ```bash
28
+ npm run build
29
+ ```
30
+
31
+ 4. Run tests:
32
+ ```bash
33
+ npm test
34
+ ```
35
+
36
+ ### Development Workflow
37
+
38
+ ```bash
39
+ # Run in development mode (with tsx)
40
+ npm run dev -- start --name test -- node -e "console.log('hello')"
41
+
42
+ # Run linting
43
+ npm run lint
44
+
45
+ # Run linting with auto-fix
46
+ npm run lint:fix
47
+
48
+ # Run unit tests
49
+ npm run test:unit
50
+
51
+ # Run tests in watch mode
52
+ npm run test:watch
53
+
54
+ # Run all tests with coverage
55
+ npm run test:coverage
56
+ ```
57
+
58
+ ## Project Structure
59
+
60
+ ```
61
+ servherd/
62
+ ├── src/
63
+ │ ├── cli/ # CLI commands and output formatting
64
+ │ │ ├── commands/ # Individual command handlers
65
+ │ │ └── output/ # Output formatters
66
+ │ ├── mcp/ # MCP server implementation
67
+ │ │ ├── tools/ # MCP tool handlers
68
+ │ │ └── resources/ # MCP resource handlers
69
+ │ ├── services/ # Core business logic
70
+ │ ├── types/ # TypeScript types and Zod schemas
71
+ │ ├── utils/ # Utility functions
72
+ │ └── index.ts # Entry point
73
+ ├── test/
74
+ │ ├── unit/ # Unit tests
75
+ │ ├── integration/ # Integration tests
76
+ │ ├── e2e/ # End-to-end tests
77
+ │ └── mocks/ # Test mocks
78
+ ├── docs/ # Documentation
79
+ ├── examples/ # Usage examples
80
+ └── scripts/ # Build/development scripts
81
+ ```
82
+
83
+ ## Code Style
84
+
85
+ ### TypeScript
86
+
87
+ - Use TypeScript strict mode
88
+ - Prefer explicit types over `any`
89
+ - Use Zod for runtime validation of external data
90
+ - Export types alongside implementations
91
+
92
+ ### ESLint
93
+
94
+ The project uses ESLint with the flat config format. Key rules:
95
+
96
+ - Double quotes for strings
97
+ - Semicolons required
98
+ - 2-space indentation
99
+ - Trailing commas in multi-line constructs
100
+
101
+ Run `npm run lint:fix` before committing to auto-fix issues.
102
+
103
+ ### Naming Conventions
104
+
105
+ - **Files**: kebab-case (e.g., `config.service.ts`)
106
+ - **Classes**: PascalCase (e.g., `ConfigService`)
107
+ - **Functions**: camelCase (e.g., `generatePort`)
108
+ - **Constants**: UPPER_SNAKE_CASE (e.g., `DEFAULT_CONFIG`)
109
+ - **Types/Interfaces**: PascalCase (e.g., `ServerEntry`)
110
+
111
+ ## Testing
112
+
113
+ ### Test Structure
114
+
115
+ Tests are organized by type:
116
+
117
+ - **Unit tests** (`test/unit/`): Test individual functions and classes in isolation
118
+ - **Integration tests** (`test/integration/`): Test component interactions
119
+ - **E2E tests** (`test/e2e/`): Test the full CLI and MCP server
120
+
121
+ ### Writing Tests
122
+
123
+ ```typescript
124
+ import { describe, it, expect, beforeEach, vi } from "vitest";
125
+
126
+ describe("FeatureName", () => {
127
+ beforeEach(() => {
128
+ // Setup
129
+ });
130
+
131
+ it("should do something specific", () => {
132
+ // Arrange
133
+ const input = "test";
134
+
135
+ // Act
136
+ const result = doSomething(input);
137
+
138
+ // Assert
139
+ expect(result).toBe("expected");
140
+ });
141
+ });
142
+ ```
143
+
144
+ ### Test Coverage
145
+
146
+ Aim for:
147
+ - 80% statement coverage
148
+ - 75% branch coverage
149
+ - 80% function coverage
150
+
151
+ Run `npm run test:coverage` to check coverage.
152
+
153
+ ## Pull Request Process
154
+
155
+ ### Before Submitting
156
+
157
+ 1. Create a feature branch from `main`:
158
+ ```bash
159
+ git checkout -b feature/my-feature
160
+ ```
161
+
162
+ 2. Make your changes with clear, focused commits
163
+
164
+ 3. Write or update tests for your changes
165
+
166
+ 4. Ensure all tests pass:
167
+ ```bash
168
+ npm test
169
+ ```
170
+
171
+ 5. Ensure linting passes:
172
+ ```bash
173
+ npm run lint
174
+ ```
175
+
176
+ 6. Update documentation if needed
177
+
178
+ ### PR Guidelines
179
+
180
+ - Keep PRs focused on a single feature or fix
181
+ - Write a clear description of what the PR does
182
+ - Link to any related issues
183
+ - Include screenshots for UI changes
184
+ - Ensure CI checks pass
185
+
186
+ ### Commit Messages
187
+
188
+ Follow [Conventional Commits](https://www.conventionalcommits.org/):
189
+
190
+ ```
191
+ <type>(<scope>): <description>
192
+
193
+ [optional body]
194
+
195
+ [optional footer]
196
+ ```
197
+
198
+ **Types:**
199
+ - `feat`: New feature
200
+ - `fix`: Bug fix
201
+ - `docs`: Documentation changes
202
+ - `test`: Test additions or changes
203
+ - `refactor`: Code refactoring
204
+ - `style`: Formatting changes
205
+ - `chore`: Maintenance tasks
206
+
207
+ **Examples:**
208
+ ```
209
+ feat(cli): add --filter option to list command
210
+ fix(mcp): handle connection timeout gracefully
211
+ docs: update README with new configuration options
212
+ test(services): add unit tests for PortService
213
+ ```
214
+
215
+ ## Architecture Decisions
216
+
217
+ ### Services
218
+
219
+ Services encapsulate business logic and are the primary way to interact with the system:
220
+
221
+ - `ConfigService`: Configuration management
222
+ - `RegistryService`: Server registry persistence
223
+ - `PortService`: Port allocation
224
+ - `ProcessService`: PM2 process management
225
+
226
+ ### CLI Commands
227
+
228
+ Each command is in its own file under `src/cli/commands/`. Commands:
229
+
230
+ 1. Parse and validate input
231
+ 2. Call appropriate services
232
+ 3. Format and output results
233
+
234
+ ### MCP Tools
235
+
236
+ MCP tools mirror CLI commands but return structured data for LLM consumption. Each tool:
237
+
238
+ 1. Validates input parameters
239
+ 2. Delegates to CLI command executors
240
+ 3. Formats output as MCP response
241
+
242
+ ## Getting Help
243
+
244
+ - Open an issue for bugs or feature requests
245
+ - Start a discussion for questions or ideas
246
+ - Check existing issues before creating new ones
247
+
248
+ ## License
249
+
250
+ By contributing, you agree that your contributions will be licensed under the MIT License.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 servherd contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.