Skip to content

Commit 3e43fa7

Browse files
committed
Add extractors_cds_tools_ts.instructions.md
Creates the `.github/instructions/` directory and adds the first `*.instructions.md` file intended for use by Copilot (or other LLM) in reviewing and maintaining code for this repository.
1 parent dcfc88b commit 3e43fa7

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
applyTo: 'extractors/cds/tools/**/*.ts'
3+
description: 'Instructions for CodeQL CDS extractor TypeScript source and test files.'
4+
---
5+
6+
# Copilot Instructions for `extractors/cds/tools/**/*.ts` files
7+
8+
## PURPOSE
9+
10+
This file contains instructions for working with TypeScript source code files in the `extractors/cds/tools/` directory of the `codeql-sap-js` repository. This includes the main `cds-extractor.ts` entry-point, modular source files in `src/**/*.ts`, and comprehensive test files in `test/**/*.test.ts`.
11+
12+
## REQUIREMENTS
13+
14+
## COMMON REQUIREMENTS
15+
16+
- ALWAYS use modern TypeScript syntax and features compatible with the configured target (ES2020).
17+
- ALWAYS follow best practices for implementing secure and efficient CodeQL extractor functionality.
18+
- ALWAYS order imports, definitions, static lists, and similar constructs alphabetically.
19+
- ALWAYS follow a test-driven development (TDD) approach by writing comprehensive tests for new features or bug fixes.
20+
- ALWAYS fix lint errors by running `npm run lint:fix` from the `extractors/cds/tools/` directory before committing changes.
21+
- ALWAYS maintain consistency between the CDS extractor's compilation behavior and the `extractors/cds/tools/test/cds-compilation-for-actions.test.sh` script to prevent CI/CD workflow failures.
22+
- **ALWAYS run `npm run build:all` from the `extractors/cds/tools/` directory and ensure it passes completely before committing any changes. This is MANDATORY and includes lint checks, test coverage, and bundle validation.**
23+
24+
### CDS EXTRACTOR SOURCE REQUIREMENTS
25+
26+
The following requirements are specific to the CDS extractor main entry-point `cds-extractor.ts` and source files matching `extractors/cds/tools/src/**/*.ts`.
27+
28+
- ALWAYS keep the main entry-point `cds-extractor.ts` focused on orchestration, delegating specific tasks to well-defined modules in `src/`.
29+
- ALWAYS gracefully handle extraction failures using tool-level diagnostics in order to avoid disrupting the overall CodeQL extraction process. Instead of exiting with a non-zero code, the CDS extractor should generate a diagnostic error (or warning) that points to the relative path (from source root) of the problematic source (e.g. `.cds`) file.
30+
31+
### CDS EXTRACTOR TESTING REQUIREMENTS
32+
33+
The following requirements are specific to the CDS extractor test files matching `extractors/cds/tools/test/**/*.test.ts`.
34+
35+
- ALWAYS write unit tests for new functions and classes in corresponding `test/src/**/*.test.ts` files.
36+
- ALWAYS use Jest testing framework with the configured `ts-jest` preset.
37+
- ALWAYS follow the AAA pattern (Arrange, Act, Assert) for test structure.
38+
- ALWAYS mock external dependencies (filesystem, child processes, network calls) using Jest mocks or `mock-fs`.
39+
- ALWAYS test both success and error scenarios with appropriate edge cases.
40+
- ALWAYS maintain test coverage above the established threshold.
41+
- **ALWAYS run `npm test` or `npm run test:coverage` from the `extractors/cds/tools/` directory and ensure all tests pass before committing changes.**
42+
43+
## PREFERENCES
44+
45+
- PREFER modular design with each major functionality implemented in its own dedicated file or module under `src/`.
46+
- PREFER the existing architectural patterns:
47+
- `src/cds/compiler/` for CDS compiler specific logic
48+
- `src/cds/parser/` for CDS parser specific logic
49+
- `src/logging/` for unified logging and performance tracking
50+
- `src/packageManager/` for dependency management and caching
51+
- `src/codeql.ts` for CodeQL JavaScript extractor integration
52+
- `src/environment.ts` for environment setup and validation
53+
- PREFER comprehensive error handling with diagnostic reporting through the `src/diagnostics.ts` module.
54+
- PREFER performance-conscious implementations that minimize filesystem operations and dependency installations.
55+
- PREFER project-aware processing that understands CDS file relationships and dependencies.
56+
57+
## CONSTRAINTS
58+
59+
- NEVER leave any trailing whitespace on any line.
60+
- NEVER directly modify any compiled files in the `dist/` directory; all changes must be made in the corresponding `src/` files and built using the build process.
61+
- NEVER commit changes without verifying that `npm run build:all` passes completely when run from the `extractors/cds/tools/` directory.
62+
- NEVER modify compilation behavior without updating the corresponding test script `extractors/cds/tools/test/cds-compilation-for-actions.test.sh`.
63+
- NEVER process CDS files in isolation - maintain project-aware context for accurate extraction.
64+
- NEVER bypass the unified logging system - use `src/logging/` utilities for all output and diagnostics.
65+
- NEVER commit extra documentation files that purely explain what has been changed and/or fixed; use git commit messages instead of adding any `.md` files that you have not explicitly been requested to create.

0 commit comments

Comments
 (0)