Skip to content

Commit d47d305

Browse files
committed
Merge branch 'release/2.7.0'
* release/2.7.0: (31 commits) Bump package version to 2.7.0 Update master -> main Fix string argument handling and achieve 100% mutation coverage Remove claude local settings from git Fix ESLint and TypeScript type safety errors Update packages including new eslint config and fix issues Add local Claude settings Add Claude Code MCP configuration Basic Claude setup Add GitHub Actions CI with bun [Codex] Document mutation testing Re-enable stryker Add Jest support with ts-jest Add tsc step to development instructions [Codex] Add res._header handling test [Codex] add intercept double restore test Fix eslint issues [Codex] refine ts tests Convert index.js to typescript remove split no idea where that snuck in ...
2 parents d2137b5 + 5d47b3f commit d47d305

26 files changed

+2820
-4727
lines changed

.claude/settings.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(bun test:*)",
5+
"mcp__eslint",
6+
"mcp__language-server",
7+
"mcp__tmux",
8+
"Bash(tsc --pretty false --watch)"
9+
],
10+
"deny": []
11+
},
12+
"enableAllProjectMcpServers": true,
13+
"hooks": {
14+
"PostToolUse": [
15+
{
16+
"matcher": "Write|Edit|MultiEdit|Update|mcp__language-server__edit_file",
17+
"hooks": [
18+
{
19+
"type": "command",
20+
"command": "jq -r '.tool_input?.filePath // .tool_input?.file_path // error(\"Missing filePath or file_path in tool_input\")' | xargs bun run eslint --cache --format=unix --fix --max-warnings=0 1>&2 || exit 2"
21+
}
22+
]
23+
}
24+
]
25+
}
26+
}

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: ["**"]
5+
pull_request:
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: oven-sh/setup-bun@v1
12+
with:
13+
bun-version: latest
14+
- run: bun install
15+
- run: bun lint
16+
- run: bun test
17+
- run: bun mutate

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ reports/
3939
# Sublime workspace
4040
*.sublime-workspace
4141
.nyc_output/
42+
43+
# Claude local config file
44+
.claude/settings.local.json

.mcp.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"mcpServers": {
3+
"language-server": {
4+
"command": "${HOME}/go/bin/mcp-language-server",
5+
"args": ["--workspace", ".", "--lsp", "bunx", "--", "--bun", "typescript-language-server@latest", "--stdio"]
6+
},
7+
"tmux": {
8+
"command": "bunx",
9+
"args": ["--bun", "@hughescr/tmux-mcp-server@latest"]
10+
}
11+
}
12+
}

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ logger.sublime-*
44
.eslintrc.js
55
Gruntfile.js
66
README.md
7-
.travis.yml
87

98
test
109
coverage

.travis.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

AGENTS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Contributor Guide
2+
3+
## Basics
4+
- The code is developed with the bun runtime
5+
6+
## Code style guidelines
7+
- Check the eslint rules to understand style guidelines
8+
- Verify style compliance with `bun lint`
9+
10+
## Testing Instructions
11+
- Find the CI plan in the .github/workflows folder if there is one.
12+
- Run `bun lint` to check for any lint errors
13+
- From the package root you can just call `bun test`. The commit should pass all tests before you merge.
14+
- Fix any test or type errors until the whole suite is green.
15+
- After moving files or changing imports, run `bun lint` to be sure ESLint and TypeScript rules still pass.
16+
- Add or update tests for the code you change, even if nobody asked.
17+
18+
## PR instructions
19+
Title format: [Codex] <Title>

CLAUDE.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Tooling Expectations
6+
7+
- **MCP tools before terminal:** Always prefer Claude's MCP tools (e.g., `Glob`, `Grep`, `Read`) before falling back to shell commands.
8+
- **Editing:** Use `mcp__language-server__edit_file` for TypeScript files to benefit from live diagnostics and type checking.
9+
- **Bun-first workflow:** Invoke project scripts via `bun`/`bunx`; avoid `npm`/`npx`.
10+
- **Watchers via tmux MCP:** Manage development watchers with the tmux MCP server (`mcp__tmux__list_workspaces`, `mcp__tmux__run_command`, `mcp__tmux__get_output`). Do not run `tsc --watch` or `bun test --watch` directly in background—use tmux windows instead.
11+
- **Lint enforcement:** Claude settings run ESLint automatically after each edit—review output and fix issues immediately.
12+
13+
## Watcher Windows
14+
15+
- Long-lived tmux windows: `tsc-watch`, `test-watch`. Do not close them once started.
16+
- Check for existing windows before launching new watchers using `mcp__tmux__list_workspaces`.
17+
- Temporary windows you create must be cleaned up (Ctrl+C, exit shell).
18+
19+
## Common Pitfalls
20+
21+
- Falling back to raw shell commands when an MCP tool exists.
22+
- Ignoring ESLint diagnostics emitted by the post-edit hook.
23+
- Running tests or type checkers outside the watcher workflow.
24+
- Not checking for existing tmux windows before creating new ones.
25+
26+
## Development Commands
27+
28+
### Linting and Type Checking
29+
```bash
30+
bun lint
31+
```
32+
Runs ESLint with auto-fix and TypeScript compiler (no emit, type checking only).
33+
34+
### Testing
35+
```bash
36+
bun test
37+
```
38+
Runs the full test suite using Jest via ts-jest.
39+
40+
### Mutation Testing
41+
```bash
42+
NODE_OPTIONS=--experimental-vm-modules bun x stryker run
43+
```
44+
Runs Stryker mutation testing with Jest runner and TypeScript checker.
45+
46+
## Architecture Overview
47+
48+
This is a Winston-based logging library with Express middleware integration and console interception capabilities.
49+
50+
### Core Components
51+
52+
**Logger Extension (`src/index.ts`)**:
53+
- Extends Winston Logger with custom methods: `interceptConsole()`, `restoreConsole()`, and `morganStream`
54+
- Single-file implementation exporting `logger`, `middleware`, and `noprefix` constant
55+
- Uses Luxon for timestamp formatting (ISO 8601 UTC)
56+
- Custom log levels: error(0), warn(1), info(2), noprefix(2), debug(3)
57+
58+
**Express Middleware**:
59+
- Built on Morgan with custom format string `mydev`
60+
- Dynamically generates color formatters based on HTTP status codes (cached on format function)
61+
- Custom tokens: `timestamp` (Luxon ISO), `route` (req.route.path), `user` (req.user._id)
62+
- Logs to `logger.morganStream` which wraps Winston output
63+
64+
**Console Interception**:
65+
- Replaces console methods (log, info, warn, error, dir) with Winston equivalents
66+
- Automatically adds `source: 'console'` metadata
67+
- Adds stack traces to console.error() calls
68+
- Preserves original console methods for restoration
69+
70+
### Technical Details
71+
72+
**Runtime**: Bun (development) / Node.js >=16 (production)
73+
74+
**Module System**: ESM (`"type": "module"`)
75+
- Main entry: `src/index.ts` (published as TypeScript, not transpiled)
76+
77+
**TypeScript Configuration**:
78+
- Target: ESNext with bundler module resolution
79+
- `noEmit: true` - no JavaScript output, type checking only
80+
- `verbatimModuleSyntax: true` - explicit import type syntax required
81+
- Strict mode enabled
82+
83+
**Testing Framework**:
84+
- Uses Bun test syntax (`bun:test`) in test files
85+
- Jest runner via ts-jest with ESM preset for execution
86+
- Special module mapper: `bun:test``test/bun-test.ts` for compatibility
87+
- Tests in `test/module.test.ts` cover all logger methods, console interception, and Express middleware
88+
89+
**Mutation Testing**:
90+
- Stryker with Jest runner and TypeScript checker
91+
- Targets: `src/*.ts`
92+
- Coverage analysis: perTest
93+
- Thresholds: high=100, low=75
94+
95+
## Git Flow
96+
97+
Uses git-flow branching model:
98+
- `develop` - main development branch
99+
- `master` - production releases only
100+
- Version bumps trigger automated release process via `postversion` script
101+
102+
## Package Publishing
103+
104+
- Published to npm as `@hughescr/logger` with public access
105+
- Entry point: `src/index.ts` (TypeScript source, not compiled)

0 commit comments

Comments
 (0)