@nestjs-mcp/server 0.1.0-alpha.4
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/.copilotignore +38 -0
- package/.devcontainer/Dockerfile.dev +28 -0
- package/.devcontainer/devcontainer.json +56 -0
- package/.devcontainer/docker-compose.yml +15 -0
- package/.dockerignore +37 -0
- package/.github/codeql-config.yml +4 -0
- package/.github/copilot-instructions.md +138 -0
- package/.github/prompts/memory.prompt.md +120 -0
- package/.github/workflows/auto-tag-release.yml +84 -0
- package/.github/workflows/codeql-analysis.yml +56 -0
- package/.github/workflows/npm-publish.yml +58 -0
- package/.github/workflows/pr-branch-validation.yml +78 -0
- package/.github/workflows/run-tests.yml +41 -0
- package/.github/workflows/sync-main-to-develop.yml +53 -0
- package/.handbook/GIT_GUIDELINES.md +250 -0
- package/.handbook/PACKAGE_VERSIONING.md +140 -0
- package/.handbook/STACK.md +75 -0
- package/.prettierrc +4 -0
- package/.vscode/extensions.json +44 -0
- package/.vscode/settings.json +40 -0
- package/CONTRIBUTING.md +261 -0
- package/LICENSE +21 -0
- package/README.md +490 -0
- package/dist/examples/async-import/app.module.d.ts +2 -0
- package/dist/examples/async-import/app.module.js +33 -0
- package/dist/examples/async-import/app.module.js.map +1 -0
- package/dist/examples/async-import/main.d.ts +1 -0
- package/dist/examples/async-import/main.js +17 -0
- package/dist/examples/async-import/main.js.map +1 -0
- package/dist/examples/guards/app.module.d.ts +6 -0
- package/dist/examples/guards/app.module.js +48 -0
- package/dist/examples/guards/app.module.js.map +1 -0
- package/dist/examples/guards/guards.resolver.d.ts +13 -0
- package/dist/examples/guards/guards.resolver.js +61 -0
- package/dist/examples/guards/guards.resolver.js.map +1 -0
- package/dist/examples/guards/main.d.ts +1 -0
- package/dist/examples/guards/main.js +11 -0
- package/dist/examples/guards/main.js.map +1 -0
- package/dist/examples/mixed/app.module.d.ts +2 -0
- package/dist/examples/mixed/app.module.js +31 -0
- package/dist/examples/mixed/app.module.js.map +1 -0
- package/dist/examples/mixed/main.d.ts +1 -0
- package/dist/examples/mixed/main.js +11 -0
- package/dist/examples/mixed/main.js.map +1 -0
- package/dist/examples/mixed/mixed.resolver.d.ts +6 -0
- package/dist/examples/mixed/mixed.resolver.js +78 -0
- package/dist/examples/mixed/mixed.resolver.js.map +1 -0
- package/dist/examples/prompts/app.module.d.ts +2 -0
- package/dist/examples/prompts/app.module.js +31 -0
- package/dist/examples/prompts/app.module.js.map +1 -0
- package/dist/examples/prompts/main.d.ts +1 -0
- package/dist/examples/prompts/main.js +11 -0
- package/dist/examples/prompts/main.js.map +1 -0
- package/dist/examples/prompts/prompts.resolver.d.ts +14 -0
- package/dist/examples/prompts/prompts.resolver.js +165 -0
- package/dist/examples/prompts/prompts.resolver.js.map +1 -0
- package/dist/examples/resources/app.module.d.ts +2 -0
- package/dist/examples/resources/app.module.js +31 -0
- package/dist/examples/resources/app.module.js.map +1 -0
- package/dist/examples/resources/main.d.ts +1 -0
- package/dist/examples/resources/main.js +11 -0
- package/dist/examples/resources/main.js.map +1 -0
- package/dist/examples/resources/resources.resolver.d.ts +12 -0
- package/dist/examples/resources/resources.resolver.js +114 -0
- package/dist/examples/resources/resources.resolver.js.map +1 -0
- package/dist/examples/tools/app.module.d.ts +2 -0
- package/dist/examples/tools/app.module.js +31 -0
- package/dist/examples/tools/app.module.js.map +1 -0
- package/dist/examples/tools/main.d.ts +1 -0
- package/dist/examples/tools/main.js +11 -0
- package/dist/examples/tools/main.js.map +1 -0
- package/dist/examples/tools/tools.resolver.d.ts +23 -0
- package/dist/examples/tools/tools.resolver.js +175 -0
- package/dist/examples/tools/tools.resolver.js.map +1 -0
- package/dist/src/controllers/sse/index.d.ts +2 -0
- package/dist/src/controllers/sse/index.js +19 -0
- package/dist/src/controllers/sse/index.js.map +1 -0
- package/dist/src/controllers/sse/sse.controller.d.ts +8 -0
- package/dist/src/controllers/sse/sse.controller.js +51 -0
- package/dist/src/controllers/sse/sse.controller.js.map +1 -0
- package/dist/src/controllers/sse/sse.service.d.ts +16 -0
- package/dist/src/controllers/sse/sse.service.js +78 -0
- package/dist/src/controllers/sse/sse.service.js.map +1 -0
- package/dist/src/controllers/streamable/index.d.ts +2 -0
- package/dist/src/controllers/streamable/index.js +19 -0
- package/dist/src/controllers/streamable/index.js.map +1 -0
- package/dist/src/controllers/streamable/streamable.controller.d.ts +9 -0
- package/dist/src/controllers/streamable/streamable.controller.js +62 -0
- package/dist/src/controllers/streamable/streamable.controller.js.map +1 -0
- package/dist/src/controllers/streamable/streamable.service.d.ts +24 -0
- package/dist/src/controllers/streamable/streamable.service.js +117 -0
- package/dist/src/controllers/streamable/streamable.service.js.map +1 -0
- package/dist/src/decorators/capabilities.constants.d.ts +4 -0
- package/dist/src/decorators/capabilities.constants.js +8 -0
- package/dist/src/decorators/capabilities.constants.js.map +1 -0
- package/dist/src/decorators/capabilities.decorators.d.ts +8 -0
- package/dist/src/decorators/capabilities.decorators.js +49 -0
- package/dist/src/decorators/capabilities.decorators.js.map +1 -0
- package/dist/src/decorators/index.d.ts +2 -0
- package/dist/src/decorators/index.js +19 -0
- package/dist/src/decorators/index.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +21 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/capabilities.interface.d.ts +52 -0
- package/dist/src/interfaces/capabilities.interface.js +3 -0
- package/dist/src/interfaces/capabilities.interface.js.map +1 -0
- package/dist/src/interfaces/guards.interface.d.ts +4 -0
- package/dist/src/interfaces/guards.interface.js +3 -0
- package/dist/src/interfaces/guards.interface.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +2 -0
- package/dist/src/interfaces/index.js +19 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/interfaces/mcp-server-options.interface.d.ts +42 -0
- package/dist/src/interfaces/mcp-server-options.interface.js +3 -0
- package/dist/src/interfaces/mcp-server-options.interface.js.map +1 -0
- package/dist/src/mcp.module.d.ts +13 -0
- package/dist/src/mcp.module.js +176 -0
- package/dist/src/mcp.module.js.map +1 -0
- package/dist/src/registry/discovery.service.d.ts +16 -0
- package/dist/src/registry/discovery.service.js +85 -0
- package/dist/src/registry/discovery.service.js.map +1 -0
- package/dist/src/registry/index.d.ts +2 -0
- package/dist/src/registry/index.js +19 -0
- package/dist/src/registry/index.js.map +1 -0
- package/dist/src/registry/logger.service.d.ts +16 -0
- package/dist/src/registry/logger.service.js +97 -0
- package/dist/src/registry/logger.service.js.map +1 -0
- package/dist/src/registry/registry.service.d.ts +14 -0
- package/dist/src/registry/registry.service.js +165 -0
- package/dist/src/registry/registry.service.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/eslint.config.mjs +40 -0
- package/examples/README.md +56 -0
- package/examples/async-import/app.module.ts +22 -0
- package/examples/async-import/main.ts +15 -0
- package/examples/guards/app.module.ts +44 -0
- package/examples/guards/guards.resolver.ts +52 -0
- package/examples/guards/main.ts +11 -0
- package/examples/mixed/app.module.ts +20 -0
- package/examples/mixed/main.ts +11 -0
- package/examples/mixed/mixed.resolver.ts +56 -0
- package/examples/prompts/app.module.ts +20 -0
- package/examples/prompts/main.ts +11 -0
- package/examples/prompts/prompts.resolver.ts +184 -0
- package/examples/resources/app.module.ts +19 -0
- package/examples/resources/main.ts +11 -0
- package/examples/resources/resources.resolver.ts +123 -0
- package/examples/tools/app.module.ts +20 -0
- package/examples/tools/main.ts +11 -0
- package/examples/tools/tools.resolver.ts +205 -0
- package/nest-cli.json +8 -0
- package/package.json +106 -0
- package/scripts/npm-publish.js +301 -0
- package/src/controllers/sse/index.ts +2 -0
- package/src/controllers/sse/sse.controller.ts +19 -0
- package/src/controllers/sse/sse.service.ts +90 -0
- package/src/controllers/streamable/index.ts +2 -0
- package/src/controllers/streamable/streamable.controller.ts +24 -0
- package/src/controllers/streamable/streamable.service.ts +168 -0
- package/src/decorators/capabilities.constants.ts +7 -0
- package/src/decorators/capabilities.decorators.ts +150 -0
- package/src/decorators/index.ts +2 -0
- package/src/index.ts +11 -0
- package/src/interfaces/capabilities.interface.ts +95 -0
- package/src/interfaces/guards.interface.ts +13 -0
- package/src/interfaces/index.ts +2 -0
- package/src/interfaces/mcp-server-options.interface.ts +105 -0
- package/src/mcp.module.ts +233 -0
- package/src/mcp.service.spec.ts +28 -0
- package/src/registry/discovery.service.ts +116 -0
- package/src/registry/index.ts +2 -0
- package/src/registry/logger.service.ts +143 -0
- package/src/registry/registry.service.ts +281 -0
- package/test/base.e2e-spec.ts +74 -0
- package/test/jest-e2e.json +9 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +23 -0
package/.copilotignore
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Ignore dependencies and lock files
|
|
2
|
+
node_modules/
|
|
3
|
+
pnpm-lock.yaml
|
|
4
|
+
package-lock.json
|
|
5
|
+
yarn.lock
|
|
6
|
+
|
|
7
|
+
# Ignore environment configuration files
|
|
8
|
+
.env
|
|
9
|
+
.env.*
|
|
10
|
+
|
|
11
|
+
# Ignore build outputs and temporary directories
|
|
12
|
+
dist/
|
|
13
|
+
build/
|
|
14
|
+
out/
|
|
15
|
+
.tmp/
|
|
16
|
+
.cache/
|
|
17
|
+
|
|
18
|
+
# Ignore Docker and container configuration files
|
|
19
|
+
.dockerignore
|
|
20
|
+
Dockerfile*
|
|
21
|
+
.docker/
|
|
22
|
+
|
|
23
|
+
# Ignore IDE and system configuration files
|
|
24
|
+
.vscode/
|
|
25
|
+
.idea/
|
|
26
|
+
*.swp
|
|
27
|
+
|
|
28
|
+
# Ignore log files
|
|
29
|
+
*.log
|
|
30
|
+
|
|
31
|
+
# Ignore test and coverage files
|
|
32
|
+
coverage/
|
|
33
|
+
*.test.*
|
|
34
|
+
*.spec.*
|
|
35
|
+
|
|
36
|
+
# Ignore internal instruction files
|
|
37
|
+
.github/
|
|
38
|
+
copilot-instructions.md
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
FROM node:22.14
|
|
2
|
+
|
|
3
|
+
# Set working directory
|
|
4
|
+
WORKDIR /package
|
|
5
|
+
|
|
6
|
+
# Install required system dependencies
|
|
7
|
+
RUN apt-get update && \
|
|
8
|
+
apt-get install -y --no-install-recommends \
|
|
9
|
+
git \
|
|
10
|
+
curl \
|
|
11
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
12
|
+
|
|
13
|
+
# Install PNPM and NestJS CLI
|
|
14
|
+
RUN npm install -g pnpm@10 @nestjs/cli
|
|
15
|
+
|
|
16
|
+
# Copy package files
|
|
17
|
+
COPY package.json pnpm-lock.yaml ./
|
|
18
|
+
|
|
19
|
+
# Install dependencies as root first
|
|
20
|
+
RUN pnpm install
|
|
21
|
+
|
|
22
|
+
# Copy the rest of the application code
|
|
23
|
+
COPY . .
|
|
24
|
+
|
|
25
|
+
EXPOSE 3000 9229 6277
|
|
26
|
+
|
|
27
|
+
# Command to start development server
|
|
28
|
+
CMD ["tail", "-f", "/dev/null"]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "NestJS MCP Server",
|
|
3
|
+
"dockerComposeFile": "docker-compose.yml",
|
|
4
|
+
"service": "package",
|
|
5
|
+
"workspaceFolder": "/package",
|
|
6
|
+
"remoteUser": "node",
|
|
7
|
+
"features": {
|
|
8
|
+
"ghcr.io/devcontainers/features/git:1": {}
|
|
9
|
+
},
|
|
10
|
+
"customizations": {
|
|
11
|
+
"vscode": {
|
|
12
|
+
"extensions": [
|
|
13
|
+
// TypeScript & NestJS
|
|
14
|
+
"vscode.typescript-language-features",
|
|
15
|
+
"christian-kohler.path-intellisense",
|
|
16
|
+
"yoavbls.pretty-ts-errors",
|
|
17
|
+
"meganrogge.template-string-converter",
|
|
18
|
+
|
|
19
|
+
// ESLint & Prettier
|
|
20
|
+
"dbaeumer.vscode-eslint",
|
|
21
|
+
"esbenp.prettier-vscode",
|
|
22
|
+
|
|
23
|
+
// Testing
|
|
24
|
+
"orta.vscode-jest",
|
|
25
|
+
"firsttris.vscode-jest-runner",
|
|
26
|
+
|
|
27
|
+
// Docker
|
|
28
|
+
"ms-azuretools.vscode-docker",
|
|
29
|
+
|
|
30
|
+
// Database
|
|
31
|
+
"mtxr.sqltools",
|
|
32
|
+
"mtxr.sqltools-driver-pg",
|
|
33
|
+
|
|
34
|
+
// Git
|
|
35
|
+
"eamodio.gitlens",
|
|
36
|
+
"github.vscode-github-actions",
|
|
37
|
+
"mhutchie.git-graph",
|
|
38
|
+
|
|
39
|
+
// Environment & Configuration
|
|
40
|
+
"mikestead.dotenv",
|
|
41
|
+
"redhat.vscode-yaml",
|
|
42
|
+
"editorconfig.editorconfig",
|
|
43
|
+
|
|
44
|
+
// Documentation
|
|
45
|
+
"yzhang.markdown-all-in-one",
|
|
46
|
+
"bierner.markdown-mermaid",
|
|
47
|
+
|
|
48
|
+
// Utilities
|
|
49
|
+
"visualstudioexptteam.vscodeintellicode",
|
|
50
|
+
"wayou.vscode-todo-highlight",
|
|
51
|
+
"gruntfuggly.todo-tree",
|
|
52
|
+
"pkief.material-icon-theme"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
version: '3.8'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
package:
|
|
5
|
+
container_name: nestjs-mcp-server
|
|
6
|
+
build:
|
|
7
|
+
context: ..
|
|
8
|
+
dockerfile: .devcontainer/Dockerfile.dev
|
|
9
|
+
ports:
|
|
10
|
+
- 3000:3000
|
|
11
|
+
- 9229:9229
|
|
12
|
+
- 6277:6277
|
|
13
|
+
volumes:
|
|
14
|
+
- ..:/package
|
|
15
|
+
- /package/node_modules
|
package/.dockerignore
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Development files and directories
|
|
2
|
+
node_modules
|
|
3
|
+
npm-debug.log
|
|
4
|
+
yarn-debug.log
|
|
5
|
+
yarn-error.log
|
|
6
|
+
*.log
|
|
7
|
+
.git
|
|
8
|
+
.github
|
|
9
|
+
.vscode
|
|
10
|
+
.idea
|
|
11
|
+
*.iml
|
|
12
|
+
.DS_Store
|
|
13
|
+
Thumbs.db
|
|
14
|
+
|
|
15
|
+
# Environment and local configuration files
|
|
16
|
+
.env
|
|
17
|
+
.env.*
|
|
18
|
+
.eslintcache
|
|
19
|
+
.stylelintcache
|
|
20
|
+
*.tsbuildinfo
|
|
21
|
+
|
|
22
|
+
# Build and test files
|
|
23
|
+
dist
|
|
24
|
+
coverage
|
|
25
|
+
.nyc_output
|
|
26
|
+
|
|
27
|
+
# Temporary files
|
|
28
|
+
*.swp
|
|
29
|
+
*.bak
|
|
30
|
+
*.tmp
|
|
31
|
+
.temp/
|
|
32
|
+
|
|
33
|
+
# Documentation and files not needed at runtime
|
|
34
|
+
README.md
|
|
35
|
+
CHANGELOG.md
|
|
36
|
+
LICENSE
|
|
37
|
+
jest.config.ts
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Copilot Rules
|
|
2
|
+
|
|
3
|
+
> This document defines the rules and guidelines for code generation with Copilot in our NestJS module library for MCP Server building. **This project is a wrapper for the @modelcontextprotocol/sdk for TypeScript to create MCP Server** ([GitHub Repository](https://github.com/modelcontextprotocol/typescript-sdk/tree/server)). It is essential to maintain compatibility with this library at all times, using its defined types and ensuring correct implementation of the MCP Server specification as a NestJS module.
|
|
4
|
+
|
|
5
|
+
## 🎯 Response Principles
|
|
6
|
+
|
|
7
|
+
- Prioritize code correctness and functionality first
|
|
8
|
+
- Generate maintainable, readable solutions
|
|
9
|
+
- Consider security implications in all code
|
|
10
|
+
- Respect project-specific configurations
|
|
11
|
+
- Verify code quality before delivering final answers
|
|
12
|
+
- Ensure compatibility with @modelcontextprotocol/sdk
|
|
13
|
+
- After code changes, verify that examples in `../examples/*` remain valid and update them if necessary
|
|
14
|
+
|
|
15
|
+
## 🌐 Language
|
|
16
|
+
|
|
17
|
+
**STRICT**: Generate all code, comments, docs, and identifiers in English unless:
|
|
18
|
+
|
|
19
|
+
- User explicitly requests another language
|
|
20
|
+
- Specific project requirements override this rule
|
|
21
|
+
|
|
22
|
+
## 💡 Code Style & Quality
|
|
23
|
+
|
|
24
|
+
**STRICT**: All generated code MUST follow style and formatting defined in:
|
|
25
|
+
|
|
26
|
+
- `eslint.config.mjs`
|
|
27
|
+
- `tsconfig.json` and `tsconfig.build.json`
|
|
28
|
+
- `.prettierrc` (if present)
|
|
29
|
+
|
|
30
|
+
- Use descriptive, meaningful names for variables, functions, and classes
|
|
31
|
+
- Apply appropriate type annotations where supported
|
|
32
|
+
- Prefer explicit over implicit logic
|
|
33
|
+
- Keep functions focused on single responsibility
|
|
34
|
+
- Verify generated code against linting rules before providing the final solution
|
|
35
|
+
- If linting issues are detected, fix them and explain the changes
|
|
36
|
+
|
|
37
|
+
## 📝 Documentation & Comments
|
|
38
|
+
|
|
39
|
+
- Add concise docstrings for functions and classes
|
|
40
|
+
- Document parameters with types and constraints
|
|
41
|
+
- Document return values and possible exceptions
|
|
42
|
+
- Provide usage examples for complex interfaces
|
|
43
|
+
|
|
44
|
+
**STRICT**: Include comments only for:
|
|
45
|
+
|
|
46
|
+
- Complex/non-obvious logic
|
|
47
|
+
- Workarounds (with explanation)
|
|
48
|
+
- Security considerations
|
|
49
|
+
- Critical design decisions
|
|
50
|
+
- TODO/FIXME items (with context)
|
|
51
|
+
|
|
52
|
+
## 🔐 Security
|
|
53
|
+
|
|
54
|
+
- Never include hardcoded credentials
|
|
55
|
+
- Always validate and sanitize input
|
|
56
|
+
- Use parameterized queries for database operations
|
|
57
|
+
- Apply proper authentication and authorization checks
|
|
58
|
+
- Flag potential security vulnerabilities in generated code
|
|
59
|
+
- Suggest security improvements for existing code
|
|
60
|
+
|
|
61
|
+
## 📦 Dependencies
|
|
62
|
+
|
|
63
|
+
- Suggest dependencies with clear justification
|
|
64
|
+
- Prefer established, well-maintained libraries
|
|
65
|
+
- Include single installation command
|
|
66
|
+
- Pin dependency versions precisely
|
|
67
|
+
- Avoid deprecated or vulnerable libraries
|
|
68
|
+
- Respect licensing requirements
|
|
69
|
+
- Minimize the number of dependencies
|
|
70
|
+
|
|
71
|
+
## ✅ Testing & Verification
|
|
72
|
+
|
|
73
|
+
Verify generated code against:
|
|
74
|
+
|
|
75
|
+
- Project linting rules
|
|
76
|
+
- Type checking requirements
|
|
77
|
+
- Security best practices
|
|
78
|
+
|
|
79
|
+
- Generate appropriate unit tests on request
|
|
80
|
+
- Test both success and error paths
|
|
81
|
+
- Consider edge cases in implementations
|
|
82
|
+
- Fix issues before delivering final code
|
|
83
|
+
- If requested, suggest test scenarios
|
|
84
|
+
- After each implementation, check if examples in `../examples/*` need to be updated
|
|
85
|
+
|
|
86
|
+
## 🤖 Response Format
|
|
87
|
+
|
|
88
|
+
- Structure responses clearly
|
|
89
|
+
- Highlight key decisions and tradeoffs
|
|
90
|
+
- When providing complex implementations:
|
|
91
|
+
- Break down the solution into logical parts
|
|
92
|
+
- Explain complex or non-obvious patterns
|
|
93
|
+
- Offer alternative approaches when relevant
|
|
94
|
+
- Include example usage for module integration
|
|
95
|
+
- Verify if your solution meets all requirements before submitting
|
|
96
|
+
|
|
97
|
+
## 💬 Interaction Guidelines
|
|
98
|
+
|
|
99
|
+
- Be specific and concise
|
|
100
|
+
- Ask clarifying questions when requirements are ambiguous
|
|
101
|
+
- Break complex tasks into manageable units
|
|
102
|
+
- Reuse existing code patterns when appropriate
|
|
103
|
+
- Maintain consistent terminology with the project
|
|
104
|
+
- Focus responses on the specific request
|
|
105
|
+
- If a request cannot be fulfilled completely, explain why and offer alternatives
|
|
106
|
+
|
|
107
|
+
## ⚙️ Implementation Rules
|
|
108
|
+
|
|
109
|
+
### TypeScript Types vs Interfaces
|
|
110
|
+
|
|
111
|
+
**STRICT**: Follow these rules for type definitions:
|
|
112
|
+
|
|
113
|
+
- Use `interface` for:
|
|
114
|
+
- Object shapes that may be implemented or extended
|
|
115
|
+
- Class contracts
|
|
116
|
+
- Use `type` for:
|
|
117
|
+
- Union types
|
|
118
|
+
- Intersection types
|
|
119
|
+
- Primitive type aliases
|
|
120
|
+
- Tuple types
|
|
121
|
+
- Function types
|
|
122
|
+
- Mapped and conditional types
|
|
123
|
+
- Prefer interfaces when both options are viable (for better error messages and performance)
|
|
124
|
+
- Reuse and extend types from @modelcontextprotocol/sdk whenever possible
|
|
125
|
+
- Follow naming conventions established in the @modelcontextprotocol/sdk library
|
|
126
|
+
|
|
127
|
+
### NestJS Code Generation Rules
|
|
128
|
+
|
|
129
|
+
- Use NestJS CLI for generating files whenever possible (controllers, services, etc.)
|
|
130
|
+
- Only generate files manually when they cannot be created through the CLI
|
|
131
|
+
- Use NestJS module, controller, and service conventions
|
|
132
|
+
- Decorate classes and methods appropriately (@Module, @Controller, @Injectable, etc.)
|
|
133
|
+
- Use dependency injection for services and providers
|
|
134
|
+
- Structure files and folders according to NestJS best practices
|
|
135
|
+
- Use constructor-based injection
|
|
136
|
+
- Follow NestJS module patterns for library development
|
|
137
|
+
- Follow NestJS exception handling patterns
|
|
138
|
+
- Implement Logger in strategic areas for better debugging capabilities
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Persistent Memory System - Usage Guide
|
|
2
|
+
|
|
3
|
+
## Main Objective
|
|
4
|
+
|
|
5
|
+
This system enables the AI to **avoid repeating past mistakes** and **apply learned optimizations** across implementations. Through persistent memory, the AI:
|
|
6
|
+
|
|
7
|
+
1. Applies previously discovered optimized solutions
|
|
8
|
+
2. Consistently respects user preferences
|
|
9
|
+
3. Builds a knowledge base of effective practices
|
|
10
|
+
4. Eliminates problematic patterns identified in past work
|
|
11
|
+
|
|
12
|
+
## Core Components
|
|
13
|
+
|
|
14
|
+
This system operates through two distinct files:
|
|
15
|
+
|
|
16
|
+
- **.memory/ia-learnings.md**: Technical findings and optimizations (AI can modify)
|
|
17
|
+
- **.memory/user-learnings.md**: User preferences and requirements (read-only for AI)
|
|
18
|
+
|
|
19
|
+
> **Important**: The AI can read but never modify `.memory/user-learnings.md`. Only the user has authority to update this file.
|
|
20
|
+
|
|
21
|
+
## Implementation Workflow
|
|
22
|
+
|
|
23
|
+
### 1. Initial Request Processing
|
|
24
|
+
|
|
25
|
+
1. **Read Both Memory Files**
|
|
26
|
+
|
|
27
|
+
- Read both `.memory/ia-learnings.md` and `.memory/user-learnings.md` at the start of each new request
|
|
28
|
+
- Apply this knowledge when planning the implementation
|
|
29
|
+
|
|
30
|
+
2. **Apply Relevant Knowledge**
|
|
31
|
+
- Identify applicable patterns from previous learnings
|
|
32
|
+
- Respect all documented user preferences
|
|
33
|
+
- Resolve any conflicts by prioritizing user preferences
|
|
34
|
+
|
|
35
|
+
### 2. During Implementation
|
|
36
|
+
|
|
37
|
+
1. **Reference Knowledge Base**
|
|
38
|
+
|
|
39
|
+
- Apply optimizations from `.memory/ia-learnings.md` when relevant
|
|
40
|
+
- Ensure compliance with all `.memory/user-learnings.md` preferences
|
|
41
|
+
- Reference specific findings: "Applying the optimization pattern for X from [date]"
|
|
42
|
+
|
|
43
|
+
2. **Identify New Patterns**
|
|
44
|
+
- Recognize new optimizations and effective practices
|
|
45
|
+
- Evaluate their potential for reuse in future implementations
|
|
46
|
+
- Abstract specific implementations into general principles
|
|
47
|
+
|
|
48
|
+
### 3. Knowledge Preservation
|
|
49
|
+
|
|
50
|
+
1. **Document New Findings**
|
|
51
|
+
|
|
52
|
+
- After successful implementation, record valuable insights in `.memory/ia-learnings.md`
|
|
53
|
+
- Use the established format with before/after examples and clear context
|
|
54
|
+
- Focus on reusable patterns with broad applicability
|
|
55
|
+
|
|
56
|
+
2. **Knowledge Refinement**
|
|
57
|
+
|
|
58
|
+
- Update existing entries when finding improvements to known patterns
|
|
59
|
+
- Add context notes about evolving understanding
|
|
60
|
+
- Maintain organized and searchable structure
|
|
61
|
+
|
|
62
|
+
3. **Handle User Feedback**
|
|
63
|
+
- When receiving user feedback about preferences, suggest they document it
|
|
64
|
+
- Example: "Would you like to add this preference to your .memory/user-learnings.md for future implementations?"
|
|
65
|
+
|
|
66
|
+
## Benefits
|
|
67
|
+
|
|
68
|
+
1. **Continuous Improvement**
|
|
69
|
+
|
|
70
|
+
- Each interaction builds upon accumulated knowledge
|
|
71
|
+
- Implementation quality improves over time
|
|
72
|
+
|
|
73
|
+
2. **Efficiency Gains**
|
|
74
|
+
|
|
75
|
+
- Eliminates repetitive instructions
|
|
76
|
+
- Accelerates implementation through applied knowledge
|
|
77
|
+
|
|
78
|
+
3. **Transparency**
|
|
79
|
+
- All optimization decisions can be traced to specific learnings
|
|
80
|
+
- Clear history of applied practices
|
|
81
|
+
|
|
82
|
+
## Practical Application Examples
|
|
83
|
+
|
|
84
|
+
### Technical Optimization Application
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
User: "Create a database query function for product filtering"
|
|
88
|
+
|
|
89
|
+
AI: "Based on a previous optimization I documented on [date], I'll implement
|
|
90
|
+
the filtering directly at the database level rather than in application code,
|
|
91
|
+
which significantly reduces data transfer and improves performance..."
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### User Preference Application
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
User: "Build a new React component"
|
|
98
|
+
|
|
99
|
+
AI: "I'll implement this following your documented preferences:
|
|
100
|
+
- Using TypeScript with functional components
|
|
101
|
+
- Following Atomic Design principles
|
|
102
|
+
- Implementing WCAG accessibility standards
|
|
103
|
+
- Using your preferred naming conventions..."
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Considerations
|
|
107
|
+
|
|
108
|
+
1. **Context Sensitivity**
|
|
109
|
+
|
|
110
|
+
- Not all learnings apply universally - evaluate relevance
|
|
111
|
+
- User preferences always take priority when conflicts arise
|
|
112
|
+
|
|
113
|
+
2. **Knowledge Evolution**
|
|
114
|
+
|
|
115
|
+
- Technical optimizations may become obsolete with new technology versions
|
|
116
|
+
- Regular review of outdated patterns is recommended
|
|
117
|
+
|
|
118
|
+
3. **System Boundaries**
|
|
119
|
+
- The AI reads from `.memory/user-learnings.md` but never modifies it
|
|
120
|
+
- Knowledge persistence improves over repeated interactions
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
name: Auto Tag Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types:
|
|
6
|
+
- closed
|
|
7
|
+
branches:
|
|
8
|
+
- main
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
tag-release:
|
|
12
|
+
if: >-
|
|
13
|
+
github.event.pull_request.merged == true &&
|
|
14
|
+
(startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix/'))
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout code
|
|
18
|
+
uses: actions/checkout@v3
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
|
|
22
|
+
- name: Setup Node
|
|
23
|
+
uses: actions/setup-node@v3
|
|
24
|
+
with:
|
|
25
|
+
node-version: '22.x'
|
|
26
|
+
registry-url: 'https://registry.npmjs.org'
|
|
27
|
+
|
|
28
|
+
- name: Install jq
|
|
29
|
+
run: sudo apt-get update && sudo apt-get install -y jq
|
|
30
|
+
|
|
31
|
+
- name: Get versions
|
|
32
|
+
id: versions
|
|
33
|
+
run: |
|
|
34
|
+
# Get previous version from main branch
|
|
35
|
+
git fetch origin main
|
|
36
|
+
PREV_VERSION=$(git show origin/main:package.json | jq -r .version)
|
|
37
|
+
echo "PREV_VERSION=$PREV_VERSION" >> $GITHUB_ENV
|
|
38
|
+
|
|
39
|
+
# Get current version from merged PR
|
|
40
|
+
CURR_VERSION=$(jq -r .version package.json)
|
|
41
|
+
echo "CURR_VERSION=$CURR_VERSION" >> $GITHUB_ENV
|
|
42
|
+
|
|
43
|
+
echo "Previous version: $PREV_VERSION"
|
|
44
|
+
echo "Current version: $CURR_VERSION"
|
|
45
|
+
|
|
46
|
+
- name: Validate version change
|
|
47
|
+
run: |
|
|
48
|
+
if [ "$PREV_VERSION" = "$CURR_VERSION" ]; then
|
|
49
|
+
echo "::error::Version in package.json did not change ($CURR_VERSION). A release or hotfix must increment the version number."
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
echo "Version changed from $PREV_VERSION to $CURR_VERSION ✓"
|
|
53
|
+
|
|
54
|
+
- name: Comment on PR if version did not change
|
|
55
|
+
if: failure()
|
|
56
|
+
env:
|
|
57
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
58
|
+
run: |
|
|
59
|
+
gh pr comment ${{ github.event.pull_request.number }} --body "❌ Tag not created: Please update the version in package.json to create a new release tag."
|
|
60
|
+
|
|
61
|
+
- name: Check if tag exists
|
|
62
|
+
id: check_tag
|
|
63
|
+
run: |
|
|
64
|
+
git fetch --tags
|
|
65
|
+
if git rev-parse "v$CURR_VERSION" >/dev/null 2>&1; then
|
|
66
|
+
echo "::error::Tag v$CURR_VERSION already exists. Cannot create duplicate tag."
|
|
67
|
+
exit 1
|
|
68
|
+
fi
|
|
69
|
+
echo "Tag v$CURR_VERSION does not exist yet ✓"
|
|
70
|
+
|
|
71
|
+
- name: Create tag and push
|
|
72
|
+
run: |
|
|
73
|
+
git config user.name "github-actions[bot]"
|
|
74
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
75
|
+
git tag v$CURR_VERSION
|
|
76
|
+
git push origin v$CURR_VERSION
|
|
77
|
+
echo "✅ Successfully created and pushed tag v$CURR_VERSION"
|
|
78
|
+
|
|
79
|
+
- name: Comment on PR if tag created
|
|
80
|
+
if: success() && env.EXISTS == 'false'
|
|
81
|
+
env:
|
|
82
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
83
|
+
run: |
|
|
84
|
+
gh pr comment ${{ github.event.pull_request.number }} --body "✅ Tag v${{ env.VERSION }} created successfully."
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: 'CodeQL Security Analysis'
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main, develop]
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: '0 0 * * 1'
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
analyze:
|
|
11
|
+
name: Analyze
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
permissions:
|
|
14
|
+
actions: read
|
|
15
|
+
contents: read
|
|
16
|
+
security-events: write
|
|
17
|
+
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
language: ['typescript']
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- name: Checkout repository
|
|
25
|
+
uses: actions/checkout@v3
|
|
26
|
+
with:
|
|
27
|
+
fetch-depth: 0
|
|
28
|
+
|
|
29
|
+
- name: Setup Node
|
|
30
|
+
uses: actions/setup-node@v3
|
|
31
|
+
with:
|
|
32
|
+
node-version: '22.x'
|
|
33
|
+
registry-url: 'https://registry.npmjs.org'
|
|
34
|
+
|
|
35
|
+
- name: Install PNPM
|
|
36
|
+
uses: pnpm/action-setup@v2
|
|
37
|
+
with:
|
|
38
|
+
version: 10
|
|
39
|
+
|
|
40
|
+
- name: Install dependencies
|
|
41
|
+
run: pnpm install --frozen-lockfile
|
|
42
|
+
|
|
43
|
+
- name: Initialize CodeQL
|
|
44
|
+
uses: github/codeql-action/init@v3
|
|
45
|
+
with:
|
|
46
|
+
languages: ${{ matrix.language }}
|
|
47
|
+
queries: security-extended
|
|
48
|
+
config-file: ./.github/codeql-config.yml
|
|
49
|
+
|
|
50
|
+
- name: Build project for analysis
|
|
51
|
+
run: pnpm run build
|
|
52
|
+
|
|
53
|
+
- name: Perform CodeQL Analysis
|
|
54
|
+
uses: github/codeql-action/analyze@v3
|
|
55
|
+
with:
|
|
56
|
+
category: '/language:${{matrix.language}}'
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: Build and Deploy to NPM on Tag
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
- '*.*.*' # Also trigger on tags without 'v' prefix
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build-and-publish:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout code
|
|
14
|
+
uses: actions/checkout@v3
|
|
15
|
+
with:
|
|
16
|
+
fetch-depth: 0 # Importante para acceder al historial completo
|
|
17
|
+
|
|
18
|
+
- name: Setup Node
|
|
19
|
+
uses: actions/setup-node@v3
|
|
20
|
+
with:
|
|
21
|
+
node-version: '22.x'
|
|
22
|
+
registry-url: 'https://registry.npmjs.org'
|
|
23
|
+
|
|
24
|
+
- name: Install PNPM
|
|
25
|
+
uses: pnpm/action-setup@v2
|
|
26
|
+
with:
|
|
27
|
+
version: 10
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: pnpm install --frozen-lockfile
|
|
31
|
+
|
|
32
|
+
- name: Build package
|
|
33
|
+
run: pnpm run build
|
|
34
|
+
|
|
35
|
+
- name: Ensure tag matches package.json version
|
|
36
|
+
run: |
|
|
37
|
+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
|
|
38
|
+
PKG_VERSION=$(node -p "require('./package.json').version")
|
|
39
|
+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
|
|
40
|
+
echo "Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)."
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
- name: Ensure tag is on main (for latest only)
|
|
45
|
+
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-')
|
|
46
|
+
run: |
|
|
47
|
+
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref }})
|
|
48
|
+
MAIN_COMMIT=$(git rev-parse origin/main)
|
|
49
|
+
if [ "$TAG_COMMIT" != "$MAIN_COMMIT" ]; then
|
|
50
|
+
echo "Tag is not on main. Aborting publish as latest."
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
- name: Publish to NPM (with validations)
|
|
55
|
+
run: pnpm run publish -- --no-dry-run
|
|
56
|
+
env:
|
|
57
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
58
|
+
CI: true
|