You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Example 1: Using Event Value as Instructions](#example-1-using-event-value-as-instructions)
59
+
-[Example 2: Using Event Value as Data in a Template](#example-2-using-event-value-as-data-in-a-template)
60
+
-[Comparing the Two Approaches](#comparing-the-two-approaches)
57
61
-[Why Shell?](#why-shell)
58
62
-[Community](#community)
59
63
-[Support Us](#support-us)
@@ -90,7 +94,7 @@ wget -qO- https://raw.githubusercontent.com/antinomyhq/forge/main/install.sh | b
90
94
```bash
91
95
# Your API key for accessing AI models (see Environment Configuration section)
92
96
OPENROUTER_API_KEY=<Enter your Open Router Key>
93
-
97
+
94
98
# Optional: Set a custom URL for OpenAI-compatible providers
95
99
#OPENAI_URL=https://custom-openai-provider.com/v1
96
100
```
@@ -319,6 +323,7 @@ Forge loads workflow configurations using the following precedence rules:
319
323
3.**Default Configuration**: An embedded default configuration is always available as a fallback
320
324
321
325
When a project configuration exists in the current directory, Forge creates a merged configuration where:
326
+
322
327
- Project settings in `forge.yaml` take precedence over default settings
323
328
- Any settings not specified in the project configuration inherit from defaults
324
329
@@ -368,6 +373,7 @@ Each agent needs tools to perform tasks, configured in the `tools` field:
368
373
-`user_prompt` - (Optional) Format for user inputs. If not provided, the raw event value is used.
369
374
370
375
**Example Agent Configuration:**
376
+
371
377
```yaml
372
378
agents:
373
379
- id: software-engineer
@@ -389,25 +395,121 @@ Forge provides templates to simplify system prompt creation:
389
395
390
396
Use these templates with the syntax: `{{> name-of-the-template.hbs }}`
391
397
398
+
#### Custom Commands
399
+
400
+
Forge allows you to define custom commands in your workflow configuration. These commands can be executed within the Forge CLI using the `/command_name` syntax.
401
+
402
+
**Configuration Options:**
403
+
404
+
- `name`- The name of the command (used as `/name` in the CLI)
405
+
- `description`- A description of what the command does
406
+
- `value`- (Optional) A default prompt value that will be used if no arguments are provided when executing the command
407
+
408
+
**Example Custom Command Configuration:**
409
+
410
+
```yaml
411
+
commands:
412
+
- name: commit
413
+
description: Commit changes with a standard prefix
414
+
value: |
415
+
Understand the diff produced and commit using the 'conventional commit' standard
416
+
417
+
- name: branch
418
+
description: Create and checkout a new branch
419
+
420
+
- name: pull-request
421
+
description: Create a pull request with standard template
422
+
value: |
423
+
Understand the diff with respect to `main` and create a pull-request.
424
+
Ensure it follows 'conventional commit' standard.
425
+
```
426
+
427
+
With this configuration, users can type `/commit` in the Forge CLI to execute the commit command with the default instructions for handling commits using the conventional commit standard. If specific instructions are needed, they can be provided as an argument: `/commit Create a detailed commit message for the login feature`. Commands without a default value like `/branch` require an argument to be provided: `/branch feature/new-auth`.
428
+
429
+
**How Custom Commands Work:**
430
+
431
+
**How Custom Commands Work With the Event System:**
432
+
433
+
When a custom command is executed in the Forge CLI, it follows a specific event flow:
434
+
435
+
1.**Command Execution** - User types a command like `/commit feat: add user authentication`
436
+
2.**Event Dispatch** - Forge dispatches an event with:
437
+
- Name: The command name (e.g., `commit`)
438
+
- Value: The provided argument or default value (e.g., `feat: add user authentication`)
439
+
3.**Agent Subscription** - Any agent that has subscribed to this event name receives the event
440
+
4.**Event Processing** - The agent processes the event according to its configuration
441
+
442
+
For an agent to respond to a custom command, it must explicitly subscribe to the event with the same name as the command in its configuration. The agent can then use conditional logic in its user prompt to handle different types of events appropriately.
443
+
392
444
#### Example Workflow Configuration
393
445
446
+
Forge provides two main approaches for handling custom command events in agents. Below are examples of both approaches.
447
+
448
+
##### Example 1: Using Event Value as Instructions
449
+
450
+
In this approach, the event value itself contains complete instructions that are passed directly to the agent:
In this example, the entire value from the event is passed directly as the task. The agent receives the complete instructions as they were defined in the command value or provided by the user.
410
494
495
+
##### Example 2: Using Event Value as Data in a Template
496
+
497
+
In this approach, the event value is used as data within a template that formats different tasks based on the event name:
<task>Create a git commit with the following message: {{event.value}}</task>
534
+
{{else if (eq event.name "pull-request")}}
535
+
<task>Create a pull request with the title: {{event.value}}</task>
536
+
{{else}}
428
537
<task>{{event.value}}</task>
538
+
{{/if}}
429
539
```
430
540
431
-
This example workflow creates two agents:
541
+
This example, the event value is a simpler string that gets embedded within a template. The template uses Handlebars conditional logic (`{{#if (eq event.name "commit")}}`) to format different tasks based on the event name. The event value is used as data within these task templates.
542
+
543
+
##### Comparing the Two Approaches
544
+
545
+
**Approach 1: Event Value as Instructions**
546
+
547
+
- **Best for**: When the command itself represents a complete task or instruction set
548
+
- **Flexibility**: Users can provide detailed, multi-line instructions via the command
549
+
- **Implementation**: Simpler user_prompt template that just passes the event value through
550
+
- **Example use case**: Complex operations where instructions vary significantly
551
+
552
+
**Approach 2: Event Value as Data**
553
+
554
+
- **Best for**: When commands follow predictable patterns with varying data points
555
+
- **Structure**: More consistent task formatting across different command types
556
+
- **Implementation**: More complex user_prompt template with conditional logic
557
+
- **Example use case**: Standardized workflows like git operations with varying messages/titles
432
558
433
-
1. A title generation worker that creates meaningful titles for user conversations
434
-
2. A developer agent that can perform comprehensive file and system operations
559
+
You can choose the approach that best fits your specific workflow needs. For simple command structures, Approach 2 provides more consistency, while Approach 1 offers greater flexibility for complex operations.
0 commit comments