feat: update Copilot instructions for Discord.js 15.0.0-dev and enhance validation steps

This commit is contained in:
2025-10-03 22:39:16 -05:00
parent 1c769289c3
commit 97bd198f6e
11 changed files with 555 additions and 203 deletions

View File

@@ -1,31 +1,38 @@
# Custom instructions for GitHub Copilot
# Custom instructions for GitHub Copilot (discord.js 15.0.0-dev)
Whenever generating code, commit messages, or explanations related to Discord.js or the Discord API:
When generating or modifying code for Discord.js version `15.0.0-dev.1759363313-f510b5ffa`:
1. Always **consult and reference** the following sources for accurate and up-to-date information:
- [Discord.js Guide](https://discordjs.guide)
- [discord.js GitHub Repository](https://github.com/discordjs/discord.js)
- [Discord API Types GitHub Repository](https://github.com/discordjs/discord-api-types)
- [Discord Developer Documentation](https://discord.com/developers/docs/intro)
1. **Primary Source of Truth**
- Do not assume the official docs, guide, or GitHub repositories are fully up-to-date.
- Always prioritize the installed package in `node_modules/discord.js` as the most reliable source.
- Always cross-reference with the provided file `example.ts.txt` to understand new or experimental APIs.
2. Always **prefer official documentation** over blogs, forums, or tutorials.
- If no clear answer is found in docs, **inspect the installed dependency in `node_modules`** to confirm if a method, property, or class truly exists.
2. **Secondary Sources**
- Only use these as references when the information is still valid:
- [Discord.js Guide](https://discordjs.guide)
- [discord.js GitHub](https://github.com/discordjs/discord.js)
- [Discord API Types GitHub](https://github.com/discordjs/discord-api-types)
- [Discord Developer Documentation](https://discord.com/developers/docs/intro)
- Mark clearly if the information is outdated compared to the development version.
3. When suggesting code, ensure it matches the **latest stable release of Discord.js and related packages (June 2025 or newer)**.
- If examples belong to an older version, adapt them to the most recent stable release.
- If uncertain, indicate that verification against the `node_modules` implementation is required.
3. **Code Analysis**
- Inspect the type definitions and source files inside `node_modules/discord.js` before suggesting new methods or classes.
- If `example.ts.txt` shows usage not covered in documentation, assume that is the intended API for this development version.
4. When installing or suggesting npm packages related to Discord.js:
- Verify against their **GitHub repository** for recent updates, breaking changes, or migration notes.
- Always check if the changelog or releases page contains updates after **June 2025** and adjust suggestions accordingly.
5. Always provide **links to relevant official documentation** (Discord.js Guide, GitHub repos, or Discord Developer Docs).
- If the info is missing in docs, but exists in the actual installed package, explain that and provide the discovered usage.
6. **Error validation requirement:**
- After generating or modifying code, always remind the user to check for TypeScript errors by running:
4. **Validation**
- Always suggest running:
```bash
npx tsc --noEmit
```
(or equivalent `tsc` command).
- If type errors are found, propose fixes before finalizing the solution.
to validate typings.
- Remind to check runtime memory and CPU usage with:
```js
console.log(process.memoryUsage());
```
and external profilers if needed.
5. **Communication**
- When suggesting code, state explicitly whether it comes from:
- `node_modules` (preferred, authoritative)
- `example.ts.txt` (author-provided experimental reference)
- official docs (secondary, possibly outdated)

View File

@@ -1,15 +0,0 @@
# Prompt: Discord.js + Discord API Expert Mode
Whenever assisting with Discord.js or the Discord API:
- Always prioritize information from:
- https://discordjs.guide
- https://github.com/discordjs/discord.js
- https://github.com/discordjs/discord-api-types
- https://discord.com/developers/docs/intro
- If documentation is incomplete, check the installed dependency in `node_modules`.
- Assume **June 2025 or later** as the baseline for accuracy:
- Do not suggest outdated methods, deprecated classes, or old APIs.
- Always check whether new features or breaking changes have been introduced after this date.
- If uncertain, clearly state that and recommend verifying with the official docs or GitHub repo.
- Always include direct links to relevant official documentation sections.

View File

@@ -1,14 +0,0 @@
# Prompt: Discord.js Expert Mode (Post-June 2025)
Whenever assisting with Discord.js or related dependencies:
- Always check official resources:
- https://discordjs.guide
- https://github.com/discordjs/discord.js
- https://github.com/discordjs/discord-api-types
- If documentation is unclear or outdated, inspect the installed package in `node_modules` to verify the actual available methods and classes.
- Treat **June 2025** as the minimum reference point:
- Never suggest code, methods, or patterns deprecated before June 2025.
- Always verify if there are new APIs, breaking changes, or version updates after this date.
- Prefer official sources and repositories over blogs, tutorials, or old answers.
- Always mention if information may be outdated and link to the packages GitHub or changelog for verification.

View File

@@ -0,0 +1,11 @@
# Prompt: Discord.js 15 Development Mode
When assisting with Discord.js version `15.0.0-dev.1759363313-f510b5ffa`:
- Treat the installed code in `node_modules/discord.js` as the primary and most reliable reference.
- Always analyze the file `example.ts.txt` to extract API patterns, since it reflects the intended usage of this dev version.
- Do not rely blindly on official docs or the guide; use them only to compare and note differences with the dev version.
- Highlight when functionality has changed from v14 to v15, based on observed code and `example.ts.txt`.
- Encourage verification by:
```bash
npx tsc --noEmit

28
.github/prompts/error-strict.prompt.md vendored Normal file
View File

@@ -0,0 +1,28 @@
# Prompt: TypeScript Strict Error Resolver
Whenever Copilot generates or modifies code:
1. **Never ignore compiler errors** like `TS2339`, `TS2345`, or similar.
- Always explain what the error means in plain language.
- Always suggest at least one concrete fix.
2. **For missing properties or methods (e.g. `TS2339`)**:
- Check if the method exists in the installed `node_modules`.
- If it doesnt exist, assume the API changed in `discord.js@15-dev`.
- Propose alternatives based on actual available methods (`example.ts.txt` must be consulted).
3. **For type mismatches (e.g. `TS2345`)**:
- Suggest code changes that handle `null`/`undefined` safely.
- Show how to cast or coerce types **without breaking strict typing**.
4. **Validation step**:
- Always remind to rerun:
```bash
npx tsc --noEmit
```
until the project compiles cleanly.
- Do not consider the task “done” if compiler errors remain.
5. **Explicitness**:
- Always specify: “This code suggestion resolves TS2339 / TS2345.”
- Never produce a code snippet that still triggers the same error.

View File

@@ -1,41 +0,0 @@
# Prompt: Node.js Resource Checker (Memory & CPU)
Whenever Copilot generates, modifies, or reviews code in Node.js:
1. **Memory Monitoring**
- Always remind to check memory usage with:
```js
logger.info(process.memoryUsage());
```
which returns RSS, Heap Used, Heap Total, External, and Array Buffers.
- If `Heap Used` grows continuously without freeing, suggest potential memory leaks (unreleased timers, listeners, or large cached data).
- If `RSS` (Resident Set Size) is unusually higher than `Heap Total`, warn that external/native modules might be consuming memory.
2. **CPU Usage**
- Remind to check CPU load using:
```bash
top -p <pid>
```
or Node.js profiling (`--inspect`, `clinic flame`).
- Flag infinite loops, synchronous blocking calls, or heavy computations running on the main thread as potential CPU overuse.
- Encourage offloading heavy tasks to Workers, child processes, or queues when appropriate.
3. **Best Practices**
- Always validate memory and CPU usage after implementing new features.
- Suggest garbage collection checks (`global.gc()`) in development when Node is run with `--expose-gc`.
- Warn if long-living references (e.g., large Maps, Sets, caches, or listeners) might not be released.
- Highlight that CPU and memory efficiency are as important as correctness.
4. **Output Analysis**
- When given memory stats like:
```
RSS: 186.9MB
Heap Used: 67.6MB
Heap Total: 71.2MB
External: 5.0MB
```
- Compare `Heap Used` vs `Heap Total`: if close to the limit, risk of OOM.
- Compare `RSS` vs `Heap Total`: if RSS is much larger, check for native module or buffer leaks.
- If growth is unbounded, warn about potential memory leaks.
5. **Always remind** to rerun tests with `npx tsc --noEmit` (for type safety) and memory checks together, ensuring both correctness and performance.

View File

@@ -1,7 +0,0 @@
# Prompt: TypeScript Validation Mode
Whenever Copilot generates or modifies TypeScript code:
- Immediately remind the user to validate changes by running:
```bash
npx tsc --noEmit