|
| 1 | +## **AI Agent Instructions for eclipse-thingweb/node-wot** |
| 2 | + |
| 3 | +### **Repository Context** |
| 4 | + |
| 5 | +- **Project**: Eclipse Thingweb Node-WoT |
| 6 | +- **Language**: TypeScript, JavaScript |
| 7 | +- **Purpose**: A fast and extensible framework to connect any device with your browser and backend applications |
| 8 | +- **Standards**: W3C Web of Things (WoT) specifications |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## **WHEN PROVIDING CODE** |
| 13 | + |
| 14 | +### **Pre-Development Requirements** |
| 15 | + |
| 16 | +1. **Read the CONTRIBUTING.md file** at https://github.com/eclipse-thingweb/node-wot/blob/master/CONTRIBUTING.md |
| 17 | +2. **Understand the W3C WoT standards** at https://www.w3.org/TR/2023/REC-wot-thing-description11-20231205/ |
| 18 | +3. **Verify Eclipse Foundation compliance**: |
| 19 | + - Contributor must have an Eclipse Foundation account with GitHub ID linked |
| 20 | + - Contributor must have signed the Eclipse Contributor Agreement (ECA) |
| 21 | + |
| 22 | +### **Code Quality Standards** |
| 23 | + |
| 24 | +1. **Linting & Formatting**: |
| 25 | + |
| 26 | + - Run `npm run lint` before committing |
| 27 | + - Run `npm run format` to automatically fix style issues |
| 28 | + - Ensure no ESLint warnings or errors remain |
| 29 | + - Follow the strict boolean expressions rule (use `==` or `!=` for null/undefined checks, not `if (var)`) |
| 30 | + |
| 31 | +2. **Scope & Minimal Diffs**: |
| 32 | + |
| 33 | + - Keep changes limited to the specific feature/fix scope |
| 34 | + - Do not modify unrelated parts of files |
| 35 | + - Strive for the minimum git diff (fewest lines changed) |
| 36 | + - Avoid unnecessary refactoring outside the scope of work |
| 37 | + |
| 38 | +3. **Testing**: |
| 39 | + |
| 40 | + - Run the full test suite before committing: `npm run test` or equivalent |
| 41 | + - Ensure all tests pass |
| 42 | + - Add tests for new features or fixes |
| 43 | + |
| 44 | +4. **Special Attention for Core Changes**: |
| 45 | + |
| 46 | + - If modifying `packages/core`, understand that this impacts ALL other packages |
| 47 | + - Check if changes contradict the W3C WoT Scripting API specification: https://w3c.github.io/wot-scripting-api/ |
| 48 | + - Verify all dependent packages are updated accordingly |
| 49 | + - Validate compatibility with existing protocol bindings |
| 50 | + |
| 51 | +5. **Bypassing the Problem**: |
| 52 | + |
| 53 | + - If you do not find a solution to the problem, do not bypass it by typecasting, ignoring the tests etc. |
| 54 | + |
| 55 | +6. **Commit Requirements**: |
| 56 | + |
| 57 | + - **All commits MUST be signed** using the contributor's Eclipse Foundation account email |
| 58 | + - Configure git: `git config user.email "<eclipse-account-email>"` |
| 59 | + - Commit with `-s` flag: `git commit -s -m "<message>"` |
| 60 | + - Follow Conventional Changelog format: |
| 61 | + |
| 62 | + ``` |
| 63 | + <type>(<scope>): <subject> |
| 64 | +
|
| 65 | + <body> |
| 66 | +
|
| 67 | + <footer> |
| 68 | + ``` |
| 69 | +
|
| 70 | + - **Allowed types**: `feat`, `fix`, `refactor`, `perf`, `style`, `test`, `chore`, `docs` |
| 71 | + - **Subject**: imperative mood, present tense, lowercase, no period |
| 72 | + - **Example**: `feat(binding-coap): add support for observe option` |
| 73 | +
|
| 74 | +### **Pull Request Requirements** |
| 75 | +
|
| 76 | +1. **PR Body MUST include**: |
| 77 | +
|
| 78 | + - **Explanation of AI assistance used**: Describe how AI tools assisted in generating the code, specific aspects AI helped with, and what human review/validation was performed |
| 79 | + - **Concise change description**: Exactly what was changed, why, and technical details |
| 80 | + - **Do NOT discuss**: Benefits, impact on users, or general statements about the value of the change |
| 81 | +
|
| 82 | +2. **Example PR Body**: |
| 83 | +
|
| 84 | + ```markdown |
| 85 | + ## AI Assistance Summary |
| 86 | +
|
| 87 | + This PR was generated with AI assistance for boilerplate code generation and structural |
| 88 | + implementation. The AI helped with [specific aspect], while human verification confirmed |
| 89 | + [what was validated]. |
| 90 | +
|
| 91 | + ## Changes |
| 92 | +
|
| 93 | + - Modified `packages/binding-foo/src/foo-client.ts` to implement ProtocolClient interface |
| 94 | + - Added error handling for connection timeouts |
| 95 | + - Updated corresponding test file |
| 96 | +
|
| 97 | + Fixes #123 |
| 98 | + ``` |
| 99 | +
|
| 100 | +3. **PR Process**: |
| 101 | + - Create feature branch from master |
| 102 | + - Do NOT merge with master while developing |
| 103 | + - If master updates are needed, rebase: `git checkout master && git pull && git checkout - && git rebase master` |
| 104 | + - Ensure CI/CD checks pass |
| 105 | + - Do NOT force push unless absolutely necessary |
| 106 | +
|
| 107 | +--- |
| 108 | +
|
| 109 | +## **WHEN REVIEWING CODE** |
| 110 | +
|
| 111 | +### **Review Scope & Guidelines** |
| 112 | +
|
| 113 | +1. **Primary Focus Areas**: |
| 114 | +
|
| 115 | + - Code correctness and adherence to W3C WoT standards |
| 116 | + - Compliance with repository coding standards (ESLint, Prettier, style guide) |
| 117 | + - Proper testing and test coverage |
| 118 | + - Commit message quality and signing |
| 119 | + - PR description completeness (especially AI assistance disclosure) |
| 120 | +
|
| 121 | +2. **Avoid Redundancy**: |
| 122 | +
|
| 123 | + - Do NOT repeat observations already in the PR author's initial summary/first comment |
| 124 | + - Read the PR description first to understand context and intent |
| 125 | +
|
| 126 | +3. **W3C WoT Standards Validation**: |
| 127 | +
|
| 128 | + - Verify implementation matches W3C WoT Thing Description specification |
| 129 | + - Check W3C WoT Scripting API compliance for any core changes |
| 130 | + - Validate protocol binding implementations against expected interfaces |
| 131 | +
|
| 132 | +4. **Ecosystem Impact Assessment**: |
| 133 | + - If reviewing core changes: verify impact across all dependent packages |
| 134 | + - Check if breaking changes are properly documented in PR body |
| 135 | + - Validate that bindings still function correctly |
| 136 | +
|
| 137 | +### **Comment Management** |
| 138 | +
|
| 139 | +1. **Consolidation Rule**: |
| 140 | +
|
| 141 | + - If you find yourself writing more than 5 separate comments: |
| 142 | + - Consolidate into a single summarized comment |
| 143 | + - Organize by category (critical issues, style, suggestions) |
| 144 | + - Clearly mark blockers vs. optional improvements |
| 145 | + - Ask contributor to review and respond to the summary comment |
| 146 | +
|
| 147 | +2. **Comment Examples**: |
| 148 | + - ✅ **Good**: Points out specific issue with concrete fix suggestion |
| 149 | + - ❌ **Avoid**: Repeating the same point multiple times across different comments |
| 150 | + - ✅ **Good**: Consolidating multiple style issues into: "Code style issues found in 3 locations: [list]. Please run `npm run format`" |
| 151 | +
|
| 152 | +### **Approval Criteria** |
| 153 | +
|
| 154 | +- [ ] All commits are signed with Eclipse account email |
| 155 | +- [ ] Code passes `npm run lint` and `npm run format` |
| 156 | +- [ ] All tests pass (`npm run test`) |
| 157 | +- [ ] PR body explains AI assistance and changes clearly |
| 158 | +- [ ] Conventional commit format followed |
| 159 | +- [ ] No unrelated changes to files |
| 160 | +- [ ] W3C WoT standards compliance verified |
| 161 | +- [ ] If core changes: dependent packages updated/validated |
| 162 | +- [ ] No merge conflicts with master |
| 163 | +
|
| 164 | +--- |
| 165 | +
|
| 166 | +## **Key References for AI Agents** |
| 167 | +
|
| 168 | +| Resource | Purpose | |
| 169 | +| --------------------------------------------------------------------------------------------- | ----------------------------- | |
| 170 | +| [CONTRIBUTING.md](https://github.com/eclipse-thingweb/node-wot/blob/master/CONTRIBUTING.md) | Full contribution guidelines | |
| 171 | +| [W3C WoT Thing Description](https://www.w3.org/TR/2023/REC-wot-thing-description11-20231205/) | Core specification | |
| 172 | +| [W3C WoT Scripting API](https://w3c.github.io/wot-scripting-api/) | Required for core/API changes | |
| 173 | +| [Eclipse ECA](http://www.eclipse.org/legal/ECA.php) | Legal requirements | |
| 174 | +| [Eclipse Committer Handbook](https://www.eclipse.org/projects/handbook/) | Best practices | |
| 175 | +
|
| 176 | +--- |
| 177 | +
|
| 178 | +## **Common Pitfalls to Avoid** |
| 179 | +
|
| 180 | +1. ❌ Unsigned commits → ✅ Always use `-s` flag with Eclipse account email |
| 181 | +2. ❌ Linting warnings → ✅ Run `npm run lint && npm run format` before commit |
| 182 | +3. ❌ Scope creep → ✅ Only modify files related to the specific change |
| 183 | +4. ❌ Missing AI disclosure → ✅ Always explain AI assistance in PR body |
| 184 | +5. ❌ Core changes without validation → ✅ Test impact on all dependent packages |
| 185 | +6. ❌ Large diffs → ✅ Strive for minimal, focused changes |
| 186 | +7. ❌ Verbose PR descriptions → ✅ Be concise and technical, not marketing-focused |
| 187 | +8. ❌ Excessive review comments → ✅ Consolidate into organized summary at 5+ comments |
0 commit comments