-
Notifications
You must be signed in to change notification settings - Fork 164
Add AGENTS.md for a unified guideline for AI agents #1648
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,63 +1 @@ | ||
| # Guidelines for Junie | ||
|
|
||
| This document provides guidelines for contributing to the OpenOps project, focusing on pull requests and commit practices. | ||
|
|
||
| ## Pull Request Guidelines | ||
|
|
||
| ### Size and Scope | ||
|
|
||
| - **Prefer small PRs**: Keep pull requests focused on a single feature, bug fix, or improvement. | ||
| - **Small commits**: Break down your work into logical, small commits that each represent a complete change. | ||
| - **One change per PR**: The PR should only contain changes related to the issue, with no unrelated modifications. | ||
|
|
||
| ### Naming and Formatting | ||
|
|
||
| - **Use imperative mood** for PR titles and commit messages (e.g., "Add feature" not "Added feature" or "Adding feature"). | ||
| - **PR title requirements** (as defined in `.github/prlint.json`): | ||
| - Must start with a capital letter and a real word (e.g., "Add GO support") | ||
| - Must have at least three words | ||
| - Must use imperative mood (e.g., "Fix bug" not "Fixed bug" or "Fixing bug") | ||
|
|
||
| ### Creating Pull Requests | ||
|
|
||
| 1. **Use GitHub CLI to create a draft PR**: | ||
| ```bash | ||
| # Create a draft PR | ||
| gh pr create --draft --title "Add feature name" --body "Fixes #12345" | ||
| ``` | ||
|
|
||
| 2. **Reference issues**: | ||
| - Reference a GitHub issue in the PR body (e.g., "Fixes #12345") | ||
| - Reference a Linear issue if one was mentioned (e.g., "Fixes OPS-1234") | ||
| - If no relevant issue exists, create a GitHub issue first: | ||
| ```bash | ||
| # Create a GitHub issue | ||
| gh issue create --title "Issue title" --body "Issue description" | ||
| ``` | ||
|
|
||
| 3. **Follow the PR template**: | ||
| - Provide a clear description of the changes | ||
| - Complete the testing checklist | ||
| - Include visual changes if applicable | ||
|
|
||
| ## Commit Guidelines | ||
|
|
||
| - **Use imperative mood** in commit messages (e.g., "Fix bug" not "Fixed bug") | ||
| - **Keep commits small and focused** on a single change | ||
| - **Write descriptive commit messages** that explain what the change does and why | ||
| - **Follow this format** for commit messages: | ||
| ``` | ||
| Short summary in imperative mood (under 50 chars) | ||
| More detailed explanation if necessary. Wrap at around 72 | ||
| characters. Explain what and why, not how (the code shows that). | ||
| Fixes #issue_number | ||
| ``` | ||
| ## Additional Resources | ||
| - [CONTRIBUTING.md](../CONTRIBUTING.md): General contribution guidelines | ||
| - [.github/pull_request_template.md](../.github/pull_request_template.md): PR template | ||
| - [.github/prlint.json](../.github/prlint.json): PR linting rules | ||
| - [docs.openops.com](https://docs.openops.com): Official OpenOps documentation | ||
| See AGENTS.md in root folder. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| ## General Principles | ||
|
|
||
| - Follow existing code style and patterns in the repository | ||
| - Write clear, self-documenting code with descriptive variable and function names | ||
| - Include comments for complex logic or non-obvious behavior | ||
| - Always write tests for new functionality and changes | ||
| - Update documentation for user-facing changes | ||
| - Do not introduce new dependencies without discussion | ||
|
|
||
|
|
||
| ## Structure | ||
|
|
||
| The repository is using nx, with the source code under the "packages" directory. | ||
| Use nx to run tests (e.g. npx nx test server-shared). | ||
| Run "npx nx lint" before committing. | ||
|
|
||
| ## Code Style | ||
|
|
||
| ### Formatting | ||
|
|
||
| - **Indentation:** 2 spaces (TypeScript/JavaScript, shell scripts) | ||
| - **Line length:** 100–120 characters preferred | ||
| - **Braces:** Required for all control blocks, even single-line | ||
| - **Spacing:** | ||
| - One space between keywords and parentheses: `if (condition) {` | ||
| - No trailing whitespace | ||
| - Newline at end of file | ||
| - **Linting:** Use ESLint as configured in each package | ||
| - **Formatting:** Follow Prettier rules if configured | ||
| - Respect `.editorconfig`, `.eslintrc`, `.prettierrc`, and other config files | ||
|
|
||
| ### Naming Conventions | ||
|
|
||
| - **Variables/Functions:** `camelCase` | ||
| - **Classes/Types:** `PascalCase` | ||
| - **Constants:** `UPPER_SNAKE_CASE` | ||
| - **Files:** Lowercase with hyphens (e.g., `user-profile.ts`) | ||
|
|
||
| ### Comments | ||
|
|
||
| - Explain _why_ something is done, not _what_ (the code should be self-explanatory) | ||
| - Use `TODO:` for actionable technical debt | ||
| - Document public functions, classes, and modules | ||
|
|
||
| ## TypeScript/JavaScript | ||
|
|
||
| ### General Guidelines | ||
|
|
||
| - Use types and interfaces where appropriate | ||
| - Prefer `const` over `let` or `var` | ||
| - Prefer arrow functions for callbacks and functional components | ||
| - Use explicit return types for exported functions | ||
|
|
||
| ### Example | ||
|
|
||
| ```typescript | ||
| export function getUserProfile(userId: string): UserProfile { | ||
| if (!userId) { | ||
| throw new Error('User ID required'); | ||
| } | ||
| // TODO: Replace with real data source | ||
| return { id: userId, name: 'Sample User' }; | ||
| } | ||
| ``` | ||
|
|
||
| ## Frontend Guidelines | ||
|
|
||
| ### Project Structure | ||
|
|
||
| - Use the `react-ui` package for main application logic | ||
| - Place pure, reusable components in the `ui-components` package, documented in Storybook | ||
| - Place and write tests in a separate `tests` folder | ||
|
|
||
| ### Tech Stack | ||
|
|
||
| - **React 18** | ||
| - **Zustand** for state management | ||
| - **react-query v5** for data fetching | ||
| - **shadcn** for UI components | ||
| - **Axios** (use existing wrapper in `api.ts`), use `qs` package for query strings | ||
|
|
||
| ### Best Practices | ||
|
|
||
| - Follow best practices for React hooks | ||
| - Prefer small, composable components | ||
| - Extract helper functions where possible | ||
| - Do not make breaking changes to existing code interfaces (component props, names) without discussion | ||
| - Ensure compliance with strict linter setups (including Sonar) | ||
| - Use `cn` utility to group Tailwind classnames: | ||
|
|
||
| ```tsx | ||
| <div | ||
| className={cn( | ||
| 'absolute bottom-[-20px] left-1/2 -translate-x-1/2', | ||
| 'w-[118px] h-[24px] flex items-center justify-center', | ||
| 'font-satoshi font-medium text-xs text-blueAccent-500', | ||
| 'border border-solid border-blueAccent-500 rounded-[4px]', | ||
| 'bg-background-800', | ||
| { | ||
| 'pt-2': !someVar | ||
| } | ||
| )} | ||
| > | ||
| {t('Sample output data')} | ||
| </div> | ||
| ``` | ||
|
|
||
| ## Testing | ||
|
|
||
| - Use Jest for testing | ||
| - Place unit tests in a `tests` folder alongside the code | ||
| - Run tests using Nx commands: | ||
|
|
||
| ```bash | ||
| nx test react-ui | ||
| nx test ui-components | ||
| nx test-unit server-api | ||
| nx test engine | ||
| nx lint react-ui | ||
| ``` | ||
|
|
||
| ## Git Workflow | ||
|
|
||
| ### Commits | ||
|
|
||
| - Use imperative mood (e.g., "Fix bug" not "Fixed bug" or "Fixing bug") | ||
| - Keep commits small and focused on a single change | ||
| - Write descriptive commit messages that explain what and why, not how | ||
|
|
||
| **Commit message format:** | ||
|
|
||
| ``` | ||
| Short summary in imperative mood (under 50 chars) | ||
| More detailed explanation if necessary. Wrap at around 72 | ||
| characters. Explain what and why, not how (the code shows that). | ||
| Fixes #issue_number | ||
| ``` | ||
|
|
||
| ### Pull Requests | ||
|
|
||
| #### Size and Scope | ||
|
|
||
| - Keep PRs focused on a single feature, bug fix, or improvement | ||
| - Break down work into logical, small commits | ||
| - Only include changes related to the issue, no unrelated modifications | ||
|
|
||
| #### Title Requirements | ||
|
|
||
| - Must start with a capital letter and a real word | ||
| - Must have at least three words | ||
| - Must use imperative mood (e.g., "Add GO support" not "Added GO support") | ||
|
|
||
| #### Reference an issue | ||
|
|
||
| All PRs must reference a linear issue in their body. | ||
|
|
||
| Examples: | ||
| - Fixes OPS-100. | ||
| - Resolves OPS-101. | ||
| - Part of CI-102. | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| - [CONTRIBUTING.md](./CONTRIBUTING.md) - General contribution guidelines | ||
| - [.github/pull_request_template.md](./.github/pull_request_template.md) - PR template | ||
| - [.github/prlint.json](./.github/prlint.json) - PR linting rules | ||
| - [docs.openops.com](https://docs.openops.com) - Official OpenOps documentation | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some better prompt, generated by Claude Code: CLAUDE.mdCommon Development CommandsRunning the Application# Start all services (Frontend + API + Engine)
npm run dev
# Start backend only (API + Engine)
npm run dev:backend
# Start frontend only
npm run dev:frontend
# Full start with Docker dependencies
npm startBuilding# Build frontend
npm run build:frontend
# Build all blocks
npm run build:blocks
# Build server worker
npm run build:server-workerTesting# Run tests for specific packages
nx test react-ui
nx test ui-components
nx test-unit server-api
nx test engine
# Run linting
nx lint react-ui
nx lint server-apiBlock Development# Create new block
npm run create-block
# Create new action in existing block
npm run create-action
# Create new trigger in existing block
npm run create-trigger
# Sync block metadata to database
npm run sync-blocks
# Publish block to npm
npm run publish-blockDatabase Migrations# Create new migration
nx db-migration server-api --name MigrationName
# Migrations run automatically on app startupArchitecture OverviewMonorepo Structure (Nx)OpenOps uses Nx as a monorepo build system with the following key packages:
Three-Tier Architecture
Supporting Components
Workflow Execution ModelFlow Structure (Graph-based)Flows are defined as a directed graph:
Execution Flow
Variable Resolution SystemVariables use mustache-style syntax:
Custom parser in Blocks/Actions/Triggers Plugin SystemBlock DefinitionBlocks are defined in createBlock({
displayName: "AWS",
logoUrl: "...",
auth: amazonAuth, // Authentication strategy
actions: [...], // Array of actions
triggers: [...], // Array of triggers
categories: [...]
})Action DefinitioncreateAction({
name: 'ec2_stop_instance',
displayName: 'Stop EC2 Instance',
props: {
/* input properties */
},
run: async (ctx) => {
/* execution logic */
},
requireAuth: true,
isWriteAction: true,
riskLevel: RiskLevel.HIGH,
});Key Patterns
Block Development Workflow
Each block package structure: Database Architecture (TypeORM)Primary Entities
Database Configuration
Migrations
Code Execution Sandbox
Real-time Updates (Socket.io)
Multi-tenancy
Error Handling Patterns
Frontend Guidelines
<div
className={cn(
'absolute bottom-[-20px] left-1/2 -translate-x-1/2',
'w-[118px] h-[24px] flex items-center justify-center',
'font-satoshi font-medium text-xs text-blueAccent-500',
'border border-solid border-blueAccent-500 rounded-[4px]',
'bg-background-800',
{
'pt-2': !someVar,
},
)}
>
{t('Sample output data')}
</div>Code Style
Docker Compose (Development)The
Environment ConfigurationConfiguration managed via DeploymentDocker Images
Production Services
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit bloated don't you think? A lot of information that might not be relevant. By the way, do you allow the agent to start the application ( |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need the same for claude code
anthropics/claude-code#6235
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's unfortunate