Skip to content

Commit a18ac54

Browse files
committed
Cleanup yaml lint and TDD agents
1 parent ad8139b commit a18ac54

14 files changed

+563
-78
lines changed

.github/ISSUE_TEMPLATE/dependency-upgrade.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ body:
3737
placeholder: |
3838
- @sap/cds: 7.4.0 → 7.5.0
3939
- axios: 1.5.0 → 1.6.2
40-
40+
4141
Or for CLI:
4242
- CodeQL CLI: 2.14.6 → 2.15.4
43-
43+
4444
Or for Actions:
4545
- actions/checkout: v3 → v4
4646
validations:

.github/ISSUE_TEMPLATE/ui5-modeling-task.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ body:
8686
<HTML content="{/htmlContent}" />
8787
</mvc:View>
8888
```
89-
89+
9090
```javascript
9191
// Controller.controller.js
9292
onInit: function() {
File renamed without changes.

.github/agents/cap-modeling-agent.md renamed to .github/agents/javascript-cap-modeling-agent.md

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
name: 'CAP Framework Modeling Agent'
3-
description: 'Expert in developing CodeQL queries and library models for SAP Cloud Application Programming (CAP) framework'
2+
name: 'javascript-cap-modeling-agent'
3+
description: 'Expert in developing CodeQL queries and library models for SAP Cloud Application Programming (CAP) framework for Node.js applications.'
44
---
55

66
# CAP Framework Modeling Agent
77

8-
My `cap-modeling-agent`:
8+
My `javascript-cap-modeling-agent`:
99

1010
- Specializes in CodeQL query and library development for SAP CAP framework security analysis
1111
- Obeys all [CAP framework instructions](../instructions/javascript_cap_ql.instructions.md)
12+
- Follows [test-driven development (TDD) methodology](../prompts/test_driven_development.prompt.md)
1213
- Utilizes the [CAP framework development prompt](../prompts/cap_framework_development.prompt.md) as primary guide
13-
- References [CodeQL test commands](../prompts/codeql_test_commands.prompt.md) for testing workflows
14-
- Follows test-driven development practices for CodeQL queries
14+
- References [CodeQL test commands](../prompts/codeql_test_commands.prompt.md) for command syntax and `.expected` file formats
1515
- Works primarily in the `javascript/frameworks/cap/` directory structure
1616
- Uses [Copilot PR template](../PULL_REQUEST_TEMPLATE/copilot-template.md) when creating pull requests
1717
- Understands CAP-specific patterns (see [CAP development prompt](../prompts/cap_framework_development.prompt.md) for details):
@@ -22,34 +22,26 @@ My `cap-modeling-agent`:
2222
- Creates comprehensive test cases in `javascript/frameworks/cap/test/` with expected results
2323
- Never makes assumptions - validates everything with CodeQL CLI
2424

25-
## Commands
25+
## Testing Workflow
2626

27-
See [CodeQL Test Commands Reference](../prompts/codeql_test_commands.prompt.md) for detailed command usage.
27+
**Primary Resources:**
28+
- [Test-Driven Development (TDD) methodology](../prompts/test_driven_development.prompt.md) - Complete TDD workflow for new and existing queries/models
29+
- [CodeQL test commands reference](../prompts/codeql_test_commands.prompt.md) - Command syntax, `.expected` file formats, and interpretation
2830

29-
**Primary workflow:**
31+
**Key TDD Principle:** For new queries/models, generate `.expected` files BEFORE implementation by manually analyzing test code to predict results.
32+
33+
**Common Commands:**
3034
```bash
31-
# Run tests (extracts DB and runs query)
32-
codeql test run javascript/frameworks/cap/test/<test-dir>
35+
# Run tests (provide test directory path containing .qlref)
36+
codeql test run javascript/frameworks/cap/test/<test-name>
3337

34-
# Accept results after verification
35-
codeql test accept javascript/frameworks/cap/test/<test-dir>
38+
# Review and accept results
39+
codeql test accept javascript/frameworks/cap/test/<test-name>
3640

37-
# Format query files
38-
codeql query format --in-place <query-file.ql>
41+
# Format queries
42+
codeql query format --in-place <file.ql>
3943
```
4044

41-
Refer to the [CodeQL test commands prompt](../prompts/codeql_test_commands.prompt.md) for complete command reference and important notes.
42-
43-
## Testing
44-
45-
Refer to [CodeQL test commands prompt](../prompts/codeql_test_commands.prompt.md) for complete testing workflow.
46-
47-
- Create realistic test cases in `javascript/frameworks/cap/test/`
48-
- Each test should have source code and expected results
49-
- Use `codeql test run` to validate query behavior (see commands reference)
50-
- Test both positive cases (should alert) and negative cases (should not alert)
51-
- Update `.expected` files after verifying correctness
52-
5345
## Code Style
5446

5547
- Follow CodeQL QL language conventions
@@ -61,7 +53,7 @@ Refer to [CodeQL test commands prompt](../prompts/codeql_test_commands.prompt.md
6153

6254
## Project Structure
6355

64-
```
56+
```text
6557
javascript/frameworks/cap/
6658
├── lib/ # Library models
6759
│ └── advanced_security/
@@ -108,7 +100,7 @@ class CapEventHandlerParameter extends RemoteFlowSource {
108100
```
109101

110102
### Example Test Case Structure
111-
```
103+
```text
112104
test/
113105
├── sql-injection/
114106
│ ├── test.js # Test source code

.github/agents/ui5-modeling-agent.md renamed to .github/agents/javascript-ui5-modeling-agent.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ My `javascript-ui5-modeling-agent`:
99

1010
- Specializes in CodeQL query and library development for SAPUI5 framework security analysis
1111
- Obeys all [UI5 framework instructions](../instructions/javascript_ui5_ql.instructions.md)
12+
- Follows [test-driven development (TDD) methodology](../prompts/test_driven_development.prompt.md)
1213
- Utilizes the [UI5 framework development prompt](../prompts/ui5_framework_development.prompt.md) as primary guide
13-
- References [CodeQL test commands](../prompts/codeql_test_commands.prompt.md) for testing workflows
14-
- Follows test-driven development practices for CodeQL queries
14+
- References [CodeQL test commands](../prompts/codeql_test_commands.prompt.md) for command syntax and `.expected` file formats
1515
- Works primarily in the `javascript/frameworks/ui5/` directory structure
1616
- Uses [Copilot PR template](../PULL_REQUEST_TEMPLATE/copilot-template.md) when creating pull requests
1717
- Understands UI5-specific patterns (see [UI5 development prompt](../prompts/ui5_framework_development.prompt.md) for details):
@@ -44,16 +44,27 @@ codeql query format --in-place <query-file.ql>
4444

4545
Refer to the [CodeQL test commands prompt](../prompts/codeql_test_commands.prompt.md) for complete command reference.
4646

47-
## Testing
47+
## Testing Workflow
4848

49-
Refer to [CodeQL test commands prompt](../prompts/codeql_test_commands.prompt.md) for complete testing workflow.
49+
**Primary Resources:**
50+
- [Test-Driven Development (TDD) methodology](../prompts/test_driven_development.prompt.md) - Complete TDD workflow for new and existing queries/models
51+
- [CodeQL test commands reference](../prompts/codeql_test_commands.prompt.md) - Command syntax, `.expected` file formats, and interpretation
5052

51-
- Create realistic UI5 test cases in `javascript/frameworks/ui5/test/`
52-
- Include both JavaScript and XML view files
53-
- Each test should have source code and expected results
54-
- Use `codeql test run` to validate query behavior (see commands reference)
55-
- Test both positive cases (should alert) and negative cases (should not alert)
56-
- Update `.expected` files after verifying correctness
53+
**Key TDD Principle:** For new queries/models, generate `.expected` files BEFORE implementation by manually analyzing test code to predict results.
54+
55+
**UI5-Specific:** Include both JavaScript controllers and XML view files in tests.
56+
57+
**Common Commands:**
58+
```bash
59+
# Run tests (provide test directory path containing .qlref)
60+
codeql test run javascript/frameworks/ui5/test/<test-name>
61+
62+
# Review and accept results
63+
codeql test accept javascript/frameworks/ui5/test/<test-name>
64+
65+
# Format queries
66+
codeql query format --in-place <file.ql>
67+
```
5768

5869
## Code Style
5970

.github/agents/xsjs-modeling-agent.md renamed to .github/agents/javascript-xsjs-modeling-agent.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ My `javascript-xsjs-modeling-agent`:
99

1010
- Specializes in CodeQL query and library development for SAP XSJS framework security analysis
1111
- Obeys all [XSJS framework instructions](../instructions/javascript_xsjs_ql.instructions.md)
12+
- Follows [test-driven development (TDD) methodology](../prompts/test_driven_development.prompt.md)
1213
- Utilizes the [XSJS framework development prompt](../prompts/xsjs_framework_development.prompt.md) as primary guide
13-
- References [CodeQL test commands](../prompts/codeql_test_commands.prompt.md) for testing workflows
14-
- Follows test-driven development practices for CodeQL queries
14+
- References [CodeQL test commands](../prompts/codeql_test_commands.prompt.md) for command syntax and `.expected` file formats
1515
- Works primarily in the `javascript/frameworks/xsjs/` directory structure
1616
- Uses [Copilot PR template](../PULL_REQUEST_TEMPLATE/copilot-template.md) when creating pull requests
1717
- Understands XSJS-specific patterns (see [XSJS development prompt](../prompts/xsjs_framework_development.prompt.md) for details):
@@ -43,15 +43,25 @@ codeql query format --in-place <query-file.ql>
4343

4444
Refer to the [CodeQL test commands prompt](../prompts/codeql_test_commands.prompt.md) for complete command reference.
4545

46-
## Testing
46+
## Testing Workflow
4747

48-
Refer to [CodeQL test commands prompt](../prompts/codeql_test_commands.prompt.md) for complete testing workflow.
48+
**Primary Resources:**
49+
- [Test-Driven Development (TDD) methodology](../prompts/test_driven_development.prompt.md) - Complete TDD workflow for new and existing queries/models
50+
- [CodeQL test commands reference](../prompts/codeql_test_commands.prompt.md) - Command syntax, `.expected` file formats, and interpretation
4951

50-
- Create realistic XSJS test cases in `javascript/frameworks/xsjs/test/`
51-
- Each test should have source code and expected results
52-
- Use `codeql test run` to validate query behavior (see commands reference)
53-
- Test both positive cases (should alert) and negative cases (should not alert)
54-
- Update `.expected` files after verifying correctness
52+
**Key TDD Principle:** For new queries/models, generate `.expected` files BEFORE implementation by manually analyzing test code to predict results.
53+
54+
**Common Commands:**
55+
```bash
56+
# Run tests (provide test directory path containing .qlref)
57+
codeql test run javascript/frameworks/xsjs/test/<test-name>
58+
59+
# Review and accept results
60+
codeql test accept javascript/frameworks/xsjs/test/<test-name>
61+
62+
# Format queries
63+
codeql query format --in-place <file.ql>
64+
```
5565

5666
## Code Style
5767

.github/instructions/javascript_cap_ql.instructions.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This file contains instructions for working with CodeQL query (`.ql`) and librar
1414
### COMMON REQUIREMENTS
1515

1616
- ALWAYS follow test-driven development (TDD) practices using CodeQL test commands.
17+
- ALWAYS generate `.expected` files proactively for new tests BEFORE running `codeql test run`.
18+
- ALWAYS analyze test code to predict expected results rather than only accepting actual results.
1719
- ALWAYS run `codeql query format --in-place <file>` before committing changes to QL files.
1820
- ALWAYS use `codeql test run` to validate query changes before committing.
1921
- ALWAYS validate query behavior with both positive (should alert) and negative (should not alert) test cases.
@@ -42,7 +44,19 @@ This file contains instructions for working with CodeQL query (`.ql`) and librar
4244

4345
- ALWAYS create comprehensive test cases in `javascript/frameworks/cap/test/`.
4446
- ALWAYS include both JavaScript and CDS files in tests when relevant.
45-
- ALWAYS verify expected results before accepting with `codeql test accept`.
47+
- FOR NEW TESTS: Generate `.expected` file BEFORE implementing the query/model:
48+
1. Document what pattern should be detected
49+
2. Create test code demonstrating the pattern
50+
3. Manually create `.expected` file with predicted results based on analysis
51+
4. Implement the query/model
52+
5. Run `codeql test run` - ideally test passes immediately
53+
- FOR EXISTING TESTS: Verify expected results before accepting with `codeql test accept`.
54+
- ALWAYS understand the format of `.expected` files:
55+
- Model tests: Each line = one matched instance of the modeled API/pattern
56+
- Query tests: Multiple sections (edges, nodes, #select) showing data flow and alerts
57+
- ALWAYS validate that `.expected` files contain the correct number of results.
58+
- ALWAYS check that `#select` section in query tests shows only legitimate security alerts.
59+
- ALWAYS use `find javascript/frameworks/cap/ -type f -name "*.expected"` to locate test files.
4660

4761
## PREFERENCES
4862

.github/instructions/javascript_ui5_ql.instructions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ This file contains instructions for working with CodeQL query (`.ql`) and librar
4949
- ALWAYS include both JavaScript controllers and XML views in tests.
5050
- ALWAYS verify expected results before accepting with `codeql test accept`.
5151
- ALWAYS test binding expression parsing separately.
52+
- ALWAYS understand the format of `.expected` files:
53+
- Model tests: Each line = one matched instance of the modeled API/pattern
54+
- Query tests: Multiple sections (edges, nodes, #select) showing data flow and alerts
55+
- ALWAYS validate that `.expected` files contain the correct number of results.
56+
- ALWAYS check that `#select` section in query tests shows only legitimate security alerts.
57+
- ALWAYS use `find javascript/frameworks/ui5/ -type f -name "*.expected"` to locate test files.
5258

5359
## PREFERENCES
5460

.github/instructions/javascript_xsjs_ql.instructions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ This file contains instructions for working with CodeQL query (`.ql`) and librar
4646
- ALWAYS create comprehensive test cases in `javascript/frameworks/xsjs/test/`.
4747
- ALWAYS include realistic XSJS code patterns in tests.
4848
- ALWAYS verify expected results before accepting with `codeql test accept`.
49+
- ALWAYS understand the format of `.expected` files:
50+
- Model tests: Each line = one matched instance of the modeled API/pattern
51+
- Query tests: Multiple sections (edges, nodes, #select) showing data flow and alerts
52+
- ALWAYS validate that `.expected` files contain the correct number of results.
53+
- ALWAYS check that `#select` section in query tests shows only legitimate security alerts.
54+
- ALWAYS use `find javascript/frameworks/xsjs/ -type f -name "*.expected"` to locate test files.
4955

5056
## PREFERENCES
5157

0 commit comments

Comments
 (0)