From e2dd38e9230cd3e71544af9f52850a285017c0d3 Mon Sep 17 00:00:00 2001 From: cadamsmith Date: Thu, 30 Apr 2026 19:42:42 -0400 Subject: [PATCH] update claude.md and readme --- CLAUDE.md | 42 +++++++++++++++++++++++++++++------------- README.md | 11 +++++++++++ 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 4386b3d..0ac73ea 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -17,35 +17,51 @@ No external API calls. No secrets needed beyond the standard `GITHUB_TOKEN`. ## project structure ``` -.github/workflows/example.yml # example workflow for consumers of this action -src/index.ts # all action logic — edit this +.github/workflows/ci.yml # typecheck + test + build + dist freshness check +.github/workflows/self-test.yml # runs the action on its own PRs against the local checkout +src/mood.ts # pure scoring logic (sentiment, comment parsing, mood tiers) +src/index.ts # action entrypoint — Octokit calls, comment rendering, posting +tests/mood.test.ts # vitest suite covering src/mood.ts dist/index.js # compiled bundle — must be committed, GitHub runs this directly action.yml # action metadata and input definitions -package.json # deps: sentiment, @actions/core, @actions/github +.husky/pre-commit # rebuilds dist when src/ changes, runs `npm test` +package.json # deps: sentiment, @actions/core, @actions/github; dev: vitest, husky, ncc ``` ## dev workflow ```bash -npm install -# make changes to src/index.ts -npm run build # compiles + bundles into dist/index.js via ncc -# commit both src/ and dist/ +npm install # also installs husky pre-commit hook via `prepare` +# edit src/mood.ts or src/index.ts +npm test # runs vitest once +npm run typecheck # tsc --noEmit +npm run build # bundles src/index.ts → dist/index.js via ncc ``` -Always run `npm run build` before committing. The action runs `dist/index.js` directly — if you forget to rebuild, your changes won't take effect. +The husky `pre-commit` hook auto-rebuilds `dist/` and re-stages it whenever `src/`, `package.json`, `package-lock.json`, or `tsconfig.json` is staged, then runs `npm test`. CI also enforces this — `.github/workflows/ci.yml` fails the build if the committed `dist/` is stale. ## key files -### src/index.ts +### src/mood.ts -All logic lives here. Key sections: +Pure functions, no I/O — this is what the test suite covers. Key exports: -- `COMMIT_EXTRAS` — custom sentiment overrides tuned for commit message language (`wtf: -4`, `release: 3`, etc.). add more here freely. +- `COMMIT_EXTRAS` — custom sentiment overrides tuned for commit/code language (`wtf: -4`, `release: 3`, etc.). add more here freely. - `MOOD_TIERS` — array of mood buckets ordered by `minScore`. each has a label, emoji, summary line, and stability score (1–10). add new tiers or tweak thresholds here. - `parseCommentsFromDiff(diff)` — extracts added comment lines from a raw git diff. supports `//`, `#`, `/*`, `*`, `` HTML marker). + +Scoring blend: commits weighted 60%, code comments 40%. if no code comments are found, falls back to commits only. tweak the weights in `run()`. + +### tests/mood.test.ts + +Vitest covers the pure logic in `src/mood.ts`: diff parsing across comment syntaxes, `COMMIT_EXTRAS` overrides, `getMostTelling` selection, and `getMood` tier boundaries. When adding new mood tiers or comment patterns, add a test here too. ### action.yml diff --git a/README.md b/README.md index 4a80c5c..2ef1bab 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,17 @@ Code comments are extracted from added lines (`+`) in the diff across languages: No external API calls are made. Everything runs in the GitHub Actions runner. +## development + +```bash +npm install # installs deps + the husky pre-commit hook +npm test # vitest — covers src/mood.ts +npm run typecheck # tsc --noEmit +npm run build # bundles src/index.ts → dist/index.js via ncc +``` + +The pre-commit hook rebuilds `dist/` whenever `src/` changes and runs the test suite. CI runs typecheck, tests, build, and verifies the committed `dist/` matches what `npm run build` produces. + ## license MIT