-
Notifications
You must be signed in to change notification settings - Fork 35
chore: Create agents.md file #917
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
Copilot
wants to merge
4
commits into
master
Choose a base branch
from
copilot/fix-916
base: master
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.
+115
−0
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
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,115 @@ | ||
# Apify CLI - AI Agent Instructions | ||
|
||
This file contains instructions for AI agents working on the Apify CLI project to understand the codebase structure, conventions, and best practices. | ||
|
||
## Project Overview | ||
|
||
The Apify CLI is a command-line interface that helps developers create, develop, build, and run Apify Actors, and manage their Actors on the Apify cloud platform. It's built with TypeScript and uses a modular command framework. | ||
|
||
## Command Development Guidelines | ||
|
||
When creating new CLI commands, follow these guidelines: | ||
|
||
### Command Structure | ||
|
||
- **Base Class**: All commands must extend `ApifyCommand` from `src/lib/command-framework/apify-command.ts` | ||
- Import: `import { ApifyCommand } from '../lib/command-framework/apify-command.js'` | ||
- Do NOT use `BuiltApifyCommand` class | ||
|
||
- **Arguments**: Import from `src/lib/command-framework/args.ts` | ||
- Import: `import { Args } from '../lib/command-framework/args.js'` | ||
- Usage example: `Args.string()` | ||
|
||
- **Flags**: Import from `src/lib/command-framework/flags.ts` | ||
- Import: `import { Flags } from '../lib/command-framework/flags.js'` | ||
- Usage example: `Flags.string()` | ||
|
||
### Naming Conventions | ||
|
||
- Command names must be lowercase | ||
- Use dashes for separators (NOT spaces, NOT underscores) | ||
- Example: `my-command`, `validate-schema`, `push-data` | ||
|
||
### Command Class Template | ||
|
||
```typescript | ||
export class MyCommandCommand extends ApifyCommand<typeof MyCommandCommand> { | ||
static override name = "my-command" as const; | ||
|
||
static override description = "Description of what this command does"; | ||
|
||
static override args = { | ||
// Define arguments here using Args.* | ||
}; | ||
|
||
static override flags = { | ||
// Define flags here using Flags.* | ||
}; | ||
|
||
async run() { | ||
// Command logic implementation | ||
} | ||
} | ||
``` | ||
|
||
### Command Registration | ||
|
||
After creating a command: | ||
|
||
1. **For general Apify commands**: Add to the end of the `apifyCommands` array in `src/commands/_register.ts` | ||
2. **For Actor-specific commands**: Add to the `actorCommands` array in `src/commands/_register.ts` | ||
|
||
### Reference Examples | ||
|
||
Study these existing commands for patterns and best practices: | ||
|
||
- `src/commands/validate-schema.ts` - Simple command with validation | ||
- `src/commands/cli-management/upgrade.ts` - Command with flags and external API calls | ||
- `src/commands/_register.ts` - Command registration patterns | ||
|
||
### File Organization | ||
|
||
- Commands are organized in `src/commands/` directory | ||
- Group related commands in subdirectories (e.g., `cli-management/`, `actor-management/`) | ||
- Use descriptive filenames that match the command name | ||
|
||
## Code Style and Conventions | ||
|
||
### TypeScript Guidelines | ||
|
||
- Always mark class properties as `static override` when extending base classes | ||
- Use proper type annotations and generics | ||
- Follow the existing import patterns and module structure | ||
|
||
### Error Handling | ||
|
||
- Use appropriate exit error codes from `src/lib/consts.ts` | ||
- Provide helpful error messages to users | ||
- Handle edge cases gracefully | ||
|
||
### Configuration | ||
|
||
- Actor configuration uses `.actor/actor.json` (new format) | ||
- Reference constants from `src/lib/consts.ts` for file paths and configurations | ||
|
||
## Testing | ||
|
||
- Write tests for new commands following existing patterns in the `test/` directory | ||
- Use the testing utilities and setup from the project | ||
Comment on lines
+97
to
+98
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. Let's describe this in concrete words so that the agent doesn't have to re-analyze the project every time |
||
- Test both success and error scenarios | ||
|
||
## Development Workflow | ||
|
||
1. Install dependencies: `yarn install` | ||
2. Lint code: `yarn lint` or `yarn lint:fix` | ||
3. Format code: `yarn format` or `yarn format:fix` | ||
4. Build project: `yarn build` | ||
5. Run tests: `yarn test:local` | ||
|
||
## Important Notes | ||
|
||
- Always prompt users for required information if not provided | ||
- Follow the established patterns for command structure and organization | ||
- When in doubt about command type (apify vs actor), ask for clarification | ||
- Maintain backward compatibility when possible | ||
- Do NOT override the documentation when adding new commands, as it is automatically generated |
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.
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 should explain feature tests here