-
Notifications
You must be signed in to change notification settings - Fork 1
Sync AWS PRs and add coding guidelines #25
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a50ff91
Add SKILL.md for porting PRs and AGENTS.md for coding guidelines
conico974 1d3b7e5
update skill
conico974 dc05a5a
Port https://github.com/opennextjs/opennextjs-aws/pull/1118 as a test
conico974 8614793
Port https://github.com/opennextjs/opennextjs-aws/pull/1117
conico974 a559cfe
update skill
conico974 132ad05
Port https://github.com/opennextjs/opennextjs-aws/pull/1114
conico974 fe987a1
Port PR https://github.com/opennextjs/opennextjs-aws/pull/1107
conico974 6f3d001
update skills
conico974 643b158
Port PR https://github.com/opennextjs/opennextjs-aws/pull/1108
conico974 e9d9243
Port PR https://github.com/opennextjs/opennextjs-aws/pull/1104
conico974 3abe5d2
Port PR https://github.com/opennextjs/opennextjs-aws/pull/1101
conico974 b4463be
Port PR https://github.com/opennextjs/opennextjs-aws/pull/1098
conico974 3459aba
Merge remote-tracking branch 'origin/main' into conico/port-skills
conico974 fa26619
review
conico974 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
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,7 @@ | ||
| --- | ||
| "@opennextjs/aws": patch | ||
| --- | ||
|
|
||
| Ported PR #1098 from source repository | ||
|
|
||
| https://github.com/opennextjs/opennextjs-aws/pull/1098 |
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,5 @@ | ||
| --- | ||
| "@opennextjs/aws": patch | ||
| --- | ||
|
|
||
| Fix `findNextConfig` returning the incorrect result and also expend the return result to be an object with both the path and a new flag indicating whether the file is in TypeScript or not | ||
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,136 @@ | ||
| --- | ||
| name: port-pr | ||
| description: Port PRs from a GitHub repository. Use when you need to bring changes from a source repo. Invoke with /port-pr <github-pr-url> | ||
| argument-hint: <github-pr-url> | ||
| disable-model-invocation: true | ||
| --- | ||
|
|
||
| # Port PR Skill | ||
|
|
||
| This skill enables porting PRs from a GitHub repository into this repository. | ||
|
|
||
| ## Required Inputs | ||
|
|
||
| This skill receives arguments via `$ARGUMENTS`: | ||
|
|
||
| - `$ARGUMENTS`: GitHub PR URL (e.g., `https://github.com/owner/repo/pull/123`) | ||
|
|
||
| ## Workflow | ||
|
|
||
| ### 1. Extract PR Information | ||
|
|
||
| ```bash | ||
| gh pr view <url> --json mergeCommit,title,body,headRepository | ||
| # Exclude lockfiles from diff - they should be regenerated via pnpm install | ||
| git diff <mergeCommit>^..<mergeCommit> -- . ':!pnpm-lock.yaml' ':!package-lock.json' ':!yarn.lock' | ||
| ``` | ||
|
|
||
| Run these commands in the source repository using `workdir` parameter. | ||
|
|
||
| **Important:** Never read or port lockfile changes (pnpm-lock.yaml, package-lock.json, yarn.lock). Always regenerate the lockfile by running `pnpm install` after updating package.json dependencies. | ||
|
|
||
| ### 2. Analyze Changes | ||
|
|
||
| - Identify all files changed, added, and deleted | ||
| - Understand the purpose and scope of the change | ||
| - Note any dependencies or related changes | ||
|
|
||
| ### 3. Map to Target Repository | ||
|
|
||
| - Find equivalent files in this repository | ||
| - Identify any structural differences between repos | ||
| - Note files that don't exist or have different paths | ||
|
|
||
| ### 4. Ask for Guidance | ||
|
|
||
| Before implementing, ask the user for clarification when: | ||
|
|
||
| - A file doesn't exist in the target repo | ||
| - The code structure differs significantly between repos | ||
| - The feature/change may not apply to this repository | ||
| - There's ambiguity about how to adapt the changes | ||
|
|
||
| ### 5. Implement Changes | ||
|
|
||
| Apply similar changes following this repository's conventions: | ||
|
|
||
| - Follow AGENTS.md guidelines (formatting, imports, naming) | ||
| - Maintain consistent code style with surrounding code | ||
| - Use explicit file extensions (`.js`) for local imports | ||
| - Use `node:` prefix for Node.js built-ins | ||
|
|
||
| ### 6. Verification | ||
|
|
||
| After implementation, run: | ||
|
|
||
| ```bash | ||
| pnpm code:checks | ||
| ``` | ||
|
|
||
| This runs formatting, linting, and TypeScript checks. | ||
|
|
||
| ### 7. Run Unit Tests | ||
|
|
||
| After code checks pass, run only the unit tests from the tests-unit package: | ||
|
|
||
| ```bash | ||
| pnpm --filter tests-unit test | ||
| ``` | ||
|
|
||
| **Important:** Do NOT run `pnpm test` (which runs all tests), `pnpm e2e:test`, or any full test suite. Only unit tests from the tests-unit package should be run during the porting process. | ||
|
|
||
| ### 8. Ask for Package | ||
|
|
||
| Before creating the changeset, determine which package the changes apply to: | ||
|
|
||
| Ask the user: **"Which package should this changeset be for - `@opennextjs/aws` or `@opennextjs/cloudflare`?"** | ||
|
|
||
| Store the answer in `$PACKAGE_NAME` (e.g., "@opennextjs/cloudflare"). | ||
|
|
||
| ### 9. Create Changeset | ||
|
|
||
| Create a patch changeset with the link to the PR: | ||
|
|
||
| ```bash | ||
| # Extract PR number from the URL (e.g., "123" from "https://github.com/owner/repo/pull/123") | ||
| PR_NUMBER=$(echo "$ARGUMENTS" | grep -oE '[0-9]+$') | ||
|
|
||
| # Create the changeset file with the PR link (use the package name from step 7) | ||
| echo "--- | ||
| \"$PACKAGE_NAME\": patch | ||
| --- | ||
|
|
||
| Ported PR #$PR_NUMBER from source repository | ||
|
|
||
| $ARGUMENTS" > .changeset/port-pr-$PR_NUMBER.md | ||
| ``` | ||
|
|
||
| ### 10. Stage Changes and Prepare Commit | ||
|
|
||
| Stage the changeset file and prepare a commit message (but do not commit): | ||
|
|
||
| ```bash | ||
| # Stage the changeset file | ||
| git add .changeset/port-pr-$PR_NUMBER.md | ||
|
|
||
| # Prepare the commit message with the PR link (stored for later) | ||
| echo "chore: port PR #$PR_NUMBER from source repository | ||
|
|
||
| $ARGUMENTS | ||
|
|
||
| Changeset: .changeset/port-pr-$PR_NUMBER.md" > /tmp/commit-message-port-pr-$PR_NUMBER.txt | ||
|
|
||
| # Display the prepared commit message | ||
| cat /tmp/commit-message-port-pr-$PR_NUMBER.txt | ||
| ``` | ||
|
|
||
| The changeset is staged and ready to commit. The commit message is saved at `/tmp/commit-message-port-pr-$PR_NUMBER.txt` for reference. | ||
|
|
||
| ### 11. Summary | ||
|
|
||
| Provide a summary of: | ||
|
|
||
| - What was ported | ||
| - Any adaptations made | ||
| - Files modified/created | ||
| - Any remaining TODOs or follow-up items |
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,165 @@ | ||
| # AGENTS.md | ||
|
|
||
| Guidelines for AI coding agents working in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| This is a monorepo for OpenNext.js adapters, enabling Next.js deployment to various platforms (AWS Lambda, Cloudflare Workers, Node.js). The repository uses pnpm workspaces with multiple packages under `packages/` and example applications under `examples/` and `examples-cloudflare/`. | ||
|
|
||
| ## Build/Lint/Test Commands | ||
|
|
||
| ### Root-level commands (run from repository root) | ||
|
|
||
| ```bash | ||
| # Install dependencies | ||
| pnpm install | ||
|
|
||
| # Build all packages | ||
| pnpm build | ||
|
|
||
| # Build only opennext packages | ||
| pnpm build:opennext | ||
|
|
||
| # Run linter | ||
| pnpm lint | ||
|
|
||
| # Fix linting issues | ||
| pnpm lint:fix | ||
|
|
||
| # Check formatting | ||
| pnpm fmt | ||
|
|
||
| # Fix formatting issues | ||
| pnpm fmt:fix | ||
|
|
||
| # TypeScript type checking (all packages) | ||
| pnpm ts:check | ||
|
|
||
| # Run all code checks (fmt + lint + ts:check) | ||
| pnpm code:checks | ||
|
|
||
| # Run all unit tests | ||
| pnpm test | ||
|
|
||
| # Run e2e tests | ||
| pnpm e2e:test | ||
| ``` | ||
|
|
||
| ### Running single tests | ||
|
|
||
| ```bash | ||
| # Run a specific test file in the cloudflare package | ||
| pnpm --filter @opennextjs/cloudflare vitest run path/to/test.spec.ts | ||
|
|
||
| # Run tests matching a pattern in the tests-unit package | ||
| pnpm --filter tests-unit vitest run --testNamePattern="test name pattern" | ||
|
|
||
| # Run a single test file with vitest directly | ||
| cd packages/tests-unit && pnpm vitest run tests/core/routing/matcher.test.ts | ||
|
|
||
| # Run tests in watch mode | ||
| pnpm --filter tests-unit vitest | ||
|
|
||
| # Run tests in a specific package | ||
| pnpm --filter @opennextjs/cloudflare test | ||
| ``` | ||
|
|
||
| ### Package-specific commands | ||
|
|
||
| ```bash | ||
| # Build a specific package | ||
| pnpm --filter @opennextjs/cloudflare build | ||
|
|
||
| # Type check a specific package | ||
| pnpm --filter @opennextjs/cloudflare ts:check | ||
| ``` | ||
|
|
||
| ## Code Style Guidelines | ||
|
|
||
| ### Imports | ||
|
|
||
| - Use explicit file extensions (`.js`) for local imports: `import { foo } from "./bar.js"` | ||
| - Use Node.js built-in imports with `node:` prefix: `import fs from "node:fs"` | ||
| - Group imports logically: built-ins first, then external packages, then local modules | ||
| - Use workspace protocol for internal packages: `"@opennextjs/aws": "workspace:*"` | ||
|
|
||
| ### TypeScript | ||
|
|
||
| - TypeScript strict mode is enabled via `@tsconfig/strictest` | ||
| - Use explicit type annotations for function parameters and return types | ||
| - Prefer `type` for object types, `interface` for extensible types | ||
| - Use `import type` for type-only imports | ||
| - Avoid `any` - use `unknown` or specific types; if unavoidable, add `// oxlint-disable @typescript-eslint/no-explicit-any` comment | ||
| - Target ES2022 for compilation | ||
|
|
||
| ### Formatting | ||
|
|
||
| - Tabs for indentation (check .editorconfig if present) | ||
| - Single quotes for strings | ||
|
conico974 marked this conversation as resolved.
Outdated
|
||
| - Trailing commas in objects/arrays | ||
| - Semicolons are required | ||
|
|
||
| ### Naming Conventions | ||
|
|
||
| - camelCase for variables and functions | ||
| - PascalCase for types, interfaces, and classes | ||
| - SCREAMING_SNAKE_CASE for constants | ||
| - kebab-case for file names: `my-component.ts`, `use-cache.ts` | ||
| - `.spec.ts` suffix for test files (unit tests use vitest) | ||
| - `.test.ts` suffix for test files in tests-unit package | ||
|
|
||
| ### Error Handling | ||
|
|
||
| - Throw descriptive `Error` objects with context | ||
| - Use typed errors when specific error handling is needed | ||
| - Log errors with console.error/console.log for CLI commands | ||
| - Handle async errors with try/catch or .catch() | ||
|
|
||
| ### File Organization | ||
|
|
||
| - Source code in `src/` directory | ||
| - Test files co-located with source (`.spec.ts`) or in separate tests directory (`.test.ts`) | ||
| - Export public API through `index.ts` files | ||
| - Use barrel exports: `export * from "./module.js"` | ||
| - Configuration files at package root | ||
|
|
||
| ### Testing | ||
|
|
||
| - Use vitest for unit tests | ||
| - Use `describe`/`test`/`expect` from vitest | ||
| - Test file naming: `*.spec.ts` for co-located tests, `*.test.ts` for tests-unit package | ||
| - Mock external dependencies with `vi.mock()` and `vi.fn()` | ||
| - Run tests in Node.js environment (not jsdom) by default | ||
|
|
||
| ### Comments and Documentation | ||
|
|
||
| - Use JSDoc comments for public APIs | ||
| - Document complex logic with inline comments | ||
| - Use `// TODO(username)` or `// TODO: description` for TODOs | ||
| - Keep comments concise and relevant | ||
|
|
||
| ## Package Manager | ||
|
|
||
| This project uses **pnpm** exclusively. Do not use npm or yarn commands. | ||
|
|
||
| ```bash | ||
| # Add a dependency to a specific package | ||
| pnpm --filter <package-name> add <dependency> | ||
|
|
||
| # Add a dev dependency | ||
| pnpm --filter <package-name> add -D <dependency> | ||
|
|
||
| # Run a script in a specific package | ||
| pnpm --filter <package-name> <script-name> | ||
| ``` | ||
|
|
||
| ## Pre-commit Checks | ||
|
|
||
| Before committing, ensure: | ||
|
|
||
| 1. `pnpm fmt:fix` - Code is properly formatted | ||
| 2. `pnpm lint:fix` - No linting errors | ||
| 3. `pnpm ts:check` - TypeScript compiles without errors | ||
| 4. `pnpm test` - All tests pass | ||
|
|
||
| Run `pnpm code:checks` to verify all checks pass. | ||
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
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
Oops, something went wrong.
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.