-
Notifications
You must be signed in to change notification settings - Fork 12
docs(NODE-7685): add AGENTS.md file #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
johnmtll
wants to merge
4
commits into
main
Choose a base branch
from
NODE-7685/add-agents-file
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../.agents/skills |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # AGENTS.md | ||
|
|
||
| Instructions for AI coding agents working in this repository. This file is the source of truth; tool-specific files (e.g. CLAUDE.md) should only import it. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| `@mongodb-js/zstd` is a Node.js native addon exposing [Zstandard](https://github.com/facebook/zstd) `compress`/`decompress` as async functions. It is used by the MongoDB Node.js driver to compress wire-protocol messages. The C++ addon is built with node-gyp against a vendored zstd static library. On install, `prebuild-install` looks for a *local* cached addon binary (no remote is configured in package.json `binary`), falling back to a source build. | ||
|
|
||
| ## Commands | ||
|
|
||
| - `npm run clean-install` — download zstd into `deps/` and compile the addon (required before testing after a fresh clone). | ||
| - `npm run compile` — recompile the addon only. | ||
| - `npm test` — run mocha tests (`test/*.js`); requires a compiled addon. | ||
| - `npm run check:eslint` — lint JS/TS. | ||
| - `npm run check:clang-format` — check C++ formatting; `npm run clang-format` to fix. | ||
|
|
||
| ## Structure | ||
|
|
||
| - `addon/` — C++ addon files. `zstd.cpp` implements the N-API `compress`/`decompress` bindings, `compression.{h,cpp}` defines/implements the wrappers leveraging zstd. `compression_worker.h` holds the 'async' component of the wrapper fns. | ||
| - `lib/index.js` — The entrypoint. Loads the compiled `.node` binary and exports promise-based wrappers. | ||
| - `index.d.ts` — The public types. | ||
| - `deps/` — vendored zstd sources (version pinned by `mongodb:zstd_version` in package.json). Populated by `etc/install-zstd.sh`, untracked. | ||
| - `build/` — node-gyp output, holds .node files to be imported in index.js. | ||
| - `test/` — mocha tests, plus `test/bundling/webpack` for bundler compatibility. | ||
| - `etc/docker.sh` — runs tests in glibc and musl Docker containers. | ||
| - `binding.gyp` — node-gyp build config linking the addon against `deps/`. | ||
|
|
||
| ## Code Conventions | ||
|
|
||
| - **Null checks** — loose equality (`== null`), not `=== null`/`=== undefined`. | ||
| - **Type imports** — inline: `import { type Foo }`. | ||
| - **Formatting** — Prettier: single quotes, 2-space indent, 100-char width, no trailing commas. | ||
|
|
||
| ## Commit Messages | ||
|
|
||
| - [Conventional Commits](https://www.conventionalcommits.org/) with a Jira ticket: `<type>(NODE-XXXX): <subject>` — types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `chore`; breaking changes use `!` (e.g. `feat(NODE-XXXX)!: …`). | ||
|
|
||
| ## Related Repositories | ||
|
|
||
| - [mongodb/node-mongodb-native](https://github.com/mongodb/node-mongodb-native) — the MongoDB Node.js driver, the primary consumer of this package. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @AGENTS.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| #!/usr/bin/env bash | ||
| # 1. Ensure every staged AGENTS.md has a companion CLAUDE.md containing | ||
| # "@AGENTS.md" (a Claude Code import reference). | ||
| # 2. Ensure .claude/skills is a symlink to .agents/skills. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| claude_file_for_agents() { | ||
| local agents_file="$1" | ||
| local dir | ||
|
|
||
| dir=$(dirname "$agents_file") | ||
|
|
||
| if [ "$dir" = "." ]; then | ||
| printf 'CLAUDE.md\n' | ||
| else | ||
| printf '%s/CLAUDE.md\n' "$dir" | ||
| fi | ||
| } | ||
|
|
||
| remove_generated_file() { | ||
| local generated_file="$1" | ||
|
|
||
| if git ls-files --error-unmatch -- "$generated_file" > /dev/null 2>&1 || [ -e "$generated_file" ]; then | ||
| rm -f "$generated_file" | ||
| git add -u -- "$generated_file" | ||
| echo "auto-removed: $generated_file" | ||
| fi | ||
|
johnmtll marked this conversation as resolved.
|
||
| } | ||
|
|
||
| sync_claude_skills_dir() { | ||
| local claude_skills_dir=".claude/skills" | ||
| local expected_target="../.agents/skills" | ||
| local current_target | ||
|
|
||
| if [ -L "$claude_skills_dir" ]; then | ||
| current_target=$(readlink "$claude_skills_dir") | ||
| if [ "$current_target" = "$expected_target" ]; then | ||
| return | ||
| fi | ||
|
|
||
| rm -f "$claude_skills_dir" | ||
| elif [ -e "$claude_skills_dir" ]; then | ||
| rm -rf "$claude_skills_dir" | ||
| fi | ||
|
|
||
| mkdir -p .claude | ||
| ln -s "$expected_target" "$claude_skills_dir" | ||
| git add "$claude_skills_dir" | ||
| echo "auto-synced: $claude_skills_dir -> $expected_target" | ||
| } | ||
|
|
||
| sync_claude_skills_dir | ||
|
|
||
| staged_agents=() | ||
| deleted_agents=() | ||
|
|
||
| while IFS=$'\t ' read -r status first_path second_path; do | ||
|
johnmtll marked this conversation as resolved.
|
||
| [ -n "$status" ] || continue | ||
|
|
||
| case "$status" in | ||
| R*) | ||
| if [[ "$first_path" =~ (^|/)AGENTS\.md$ ]]; then | ||
| deleted_agents+=("$first_path") | ||
| fi | ||
| if [[ "$second_path" =~ (^|/)AGENTS\.md$ ]]; then | ||
| staged_agents+=("$second_path") | ||
| fi | ||
| ;; | ||
| D) | ||
| if [[ "$first_path" =~ (^|/)AGENTS\.md$ ]]; then | ||
| deleted_agents+=("$first_path") | ||
| fi | ||
| ;; | ||
| *) | ||
| if [[ "$first_path" =~ (^|/)AGENTS\.md$ ]]; then | ||
| staged_agents+=("$first_path") | ||
| fi | ||
| ;; | ||
| esac | ||
| done < <(git diff --cached --name-status --find-renames --diff-filter=ADMR) | ||
|
|
||
| # --- CLAUDE.md sync --- | ||
| if [ "${#staged_agents[@]}" -gt 0 ]; then | ||
| for agents_file in "${staged_agents[@]}"; do | ||
| claude_file=$(claude_file_for_agents "$agents_file") | ||
|
|
||
| # Skip if already a regular file with the correct content | ||
| if [ -f "$claude_file" ] && ! [ -L "$claude_file" ] && [ "$(cat "$claude_file")" = "@AGENTS.md" ]; then | ||
| continue | ||
| fi | ||
|
|
||
| # Remove symlink if present, then write the reference file | ||
| rm -f "$claude_file" | ||
| printf '@AGENTS.md\n' > "$claude_file" | ||
| git add "$claude_file" | ||
| echo "auto-created: $claude_file with @AGENTS.md reference" | ||
| done | ||
| fi | ||
|
|
||
| if [ "${#deleted_agents[@]}" -gt 0 ]; then | ||
| for agents_file in "${deleted_agents[@]}"; do | ||
| remove_generated_file "$(claude_file_for_agents "$agents_file")" | ||
| done | ||
| fi | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.