Files
packet.ts/AGENTS.md
2026-03-12 17:07:09 +01:00

1.9 KiB

@hamview/packet project

This project implements low level packet parsing utilities and packet dissection.

Architecture

  • Use npm as dependency manager
  • Use Vitest for unit testing

Build & Commands

  • Install deps: npm install
  • Run tests: npm test:ci
  • Run single test: npm test:ci test/parser.test.ts

Code Style

  • Spaces for indentation (2 spaces)
  • Double quotes, semicolons, trailing commas
  • Use descriptive variable/function names and methods
  • Static functions that use strings, are called fromString, if they use bytes fromBytes
  • Methods that convert to strings are called toString, methods that convert to bytes toBytes
  • Functions prefer const foo: <typespec> = (<args>) => over bare function foo
  • Don't use any type
  • Don't CamelCase abbreviations, so prefer showSSID over showSsid and encodeKISS over encodeKiss
  • Import convention:
    • Remove unused imports
    • Sort imports: external modules first, local last. Sort both modules and the imports alphabetically.
    • Split multi imports over multiple lines if there are more than 3 imported with. One import statement per source module.

Testing

  • Use Vitest for unit testing
  • Test files: test/*.test.ts
  • Per source file in src/<name>.ts there is a matching test/<name>test.ts
  • Tests are done for all classes and its methods and functions
  • Tests are following this convention: describe("Class.method", () => { ... })
  • Tests are sorted alphabetically
  • Test runners follow this convension: it("returns <thing>", ...) and it("handles ...", ...), etc.

Git Workflow

  • ALWAYS remove temporary and debug files before committing
  • ALWAYS run npm test before committing
  • NEVER use git push --force on the main branch
  • Use git push --force-with-lease for feature branches if needed
  • Use conventional commits style for git commit messages
  • Use conventional commits style to describe Gitea PR titles