mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-16 13:54:44 +00:00
Compare commits
11 Commits
dev
...
v0.0.2-fea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5dcccfd7e | ||
|
|
1f7086fe03 | ||
|
|
5f1417f1a1 | ||
|
|
740f9dadef | ||
|
|
4b66048e2b | ||
|
|
e019b097ff | ||
|
|
7409236838 | ||
|
|
7caf149e46 | ||
|
|
f1db3a2d29 | ||
|
|
c454918144 | ||
|
|
c5153772c6 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -11,3 +11,9 @@ playground
|
||||
tmp
|
||||
dist
|
||||
.turbo
|
||||
|
||||
# Test suite artifacts
|
||||
opencode/.bun/
|
||||
opencode/.local/
|
||||
opencode/.cache/
|
||||
opencode/node_modules
|
||||
|
||||
9
STATS.md
9
STATS.md
@@ -129,3 +129,12 @@
|
||||
| 2025-11-01 | 636,100 (+9,488) | 581,806 (+17,227) | 1,217,906 (+26,715) |
|
||||
| 2025-11-02 | 644,067 (+7,967) | 590,004 (+8,198) | 1,234,071 (+16,165) |
|
||||
| 2025-11-03 | 653,130 (+9,063) | 597,139 (+7,135) | 1,250,269 (+16,198) |
|
||||
| 2025-11-04 | 663,907 (+10,777) | 608,056 (+10,917) | 1,271,963 (+21,694) |
|
||||
| 2025-11-05 | 675,059 (+11,152) | 619,690 (+11,634) | 1,294,749 (+22,786) |
|
||||
| 2025-11-06 | 686,249 (+11,190) | 630,885 (+11,195) | 1,317,134 (+22,385) |
|
||||
| 2025-11-07 | 696,626 (+10,377) | 642,146 (+11,261) | 1,338,772 (+21,638) |
|
||||
| 2025-11-08 | 706,032 (+9,406) | 653,489 (+11,343) | 1,359,521 (+20,749) |
|
||||
| 2025-11-09 | 713,462 (+7,430) | 660,459 (+6,970) | 1,373,921 (+14,400) |
|
||||
| 2025-11-10 | 722,280 (+8,818) | 668,225 (+7,766) | 1,390,505 (+16,584) |
|
||||
| 2025-11-11 | 729,769 (+7,489) | 677,501 (+9,276) | 1,407,270 (+16,765) |
|
||||
| 2025-11-12 | 740,168 (+10,399) | 686,454 (+8,953) | 1,426,622 (+19,352) |
|
||||
|
||||
101
sprints/maxsteps/opencode-02-maxsteps.md
Normal file
101
sprints/maxsteps/opencode-02-maxsteps.md
Normal file
@@ -0,0 +1,101 @@
|
||||
# Sprint: Agent MaxSteps Feature
|
||||
|
||||
## Problem Statement
|
||||
Users need the ability to limit the number of steps that agents (especially subagents) can take during execution, as outlined in [Issue #3631](https://github.com/sst/opencode/issues/3631). This feature will prevent runaway agent loops and give users better control over agent execution limits.
|
||||
|
||||
## Context
|
||||
### Existing System
|
||||
OpenCode has an agentic loop system controlled in `packages/opencode/src/session/prompt.ts`. Currently, agents can run indefinitely without any step limits, which can lead to:
|
||||
- Excessive resource consumption
|
||||
- Runaway loops in faulty agent logic
|
||||
- Unpredictable costs when using paid APIs
|
||||
- Difficulty in debugging agent behavior
|
||||
|
||||
### MaxSteps Feature Requirements
|
||||
The maxSteps feature must:
|
||||
- Allow optional step limits for agent definitions
|
||||
- Work for both primary agents and subagents (primary use case is subagents)
|
||||
- Stop execution when the limit is reached
|
||||
- On the n-1 step, remove all tools from the request to force a text-only response
|
||||
- Be configurable per agent definition
|
||||
- Default to unlimited if not specified (backward compatibility)
|
||||
|
||||
## Success Criteria
|
||||
- [ ] Agent definitions accept optional `maxSteps` parameter
|
||||
- [ ] Step counter tracks execution steps accurately
|
||||
- [ ] Agent stops at maxSteps limit
|
||||
- [ ] On step n-1, tools are removed from the request
|
||||
- [ ] Final step produces a text-only response summarizing status
|
||||
- [ ] Feature works for both primary and subagents
|
||||
- [ ] No breaking changes to existing agent definitions
|
||||
- [ ] Step limit is logged for debugging purposes
|
||||
- [ ] Clear error/status message when limit is reached
|
||||
- [ ] Tests cover various step limit scenarios
|
||||
- [ ] Documentation updated with maxSteps usage
|
||||
|
||||
## Technical Requirements
|
||||
|
||||
### Agent Definition Schema
|
||||
```typescript
|
||||
interface AgentDefinition {
|
||||
name: string;
|
||||
description: string;
|
||||
tools?: Tool[];
|
||||
maxSteps?: number; // New optional field
|
||||
// ... other existing fields
|
||||
}
|
||||
```
|
||||
|
||||
### Implementation Location
|
||||
- Primary implementation in: `packages/opencode/src/session/prompt.ts`
|
||||
- Agent definition types updated
|
||||
- Step counter logic added to agentic loop
|
||||
|
||||
### Step Counting Logic
|
||||
1. Initialize step counter when agent starts
|
||||
2. Increment counter after each tool execution
|
||||
3. Check if current step === maxSteps - 1
|
||||
- If true: Remove tools from next request
|
||||
4. Check if current step === maxSteps
|
||||
- If true: Stop execution and return final response
|
||||
|
||||
### Edge Cases to Handle
|
||||
- maxSteps = 0 (should be invalid)
|
||||
- maxSteps = 1 (immediate text response)
|
||||
- maxSteps = 2 (one tool call, then text)
|
||||
- Nested subagent calls (each has own counter)
|
||||
- Error handling when limit reached mid-operation
|
||||
|
||||
## Testing Strategy
|
||||
1. Unit tests for step counter logic
|
||||
2. Integration tests with mock agents
|
||||
3. Test various maxSteps values (1, 2, 10, undefined)
|
||||
4. Test tool removal on n-1 step
|
||||
5. Test nested agent scenarios
|
||||
6. Test error cases and boundary conditions
|
||||
7. Performance tests to ensure no overhead when maxSteps not used
|
||||
|
||||
## Validation Checklist
|
||||
- [ ] maxSteps parameter accepted in agent definitions
|
||||
- [ ] Step counter increments correctly
|
||||
- [ ] Execution stops at limit
|
||||
- [ ] Tools removed on penultimate step
|
||||
- [ ] Final response is text-only
|
||||
- [ ] No regression in unlimited agents
|
||||
- [ ] Logs show step count and limit
|
||||
- [ ] Clear status message on limit reached
|
||||
- [ ] Tests pass for all scenarios
|
||||
- [ ] Documentation includes examples
|
||||
|
||||
## Example Usage
|
||||
```typescript
|
||||
const limitedAgent = {
|
||||
name: "limited-helper",
|
||||
description: "An agent with step limits",
|
||||
maxSteps: 5, // Will stop after 5 steps
|
||||
tools: [/* ... tools ... */]
|
||||
};
|
||||
|
||||
// On step 4, tools will be removed
|
||||
// On step 5, execution stops with text response
|
||||
```
|
||||
79
sprints/uninstaller/opencode-01-uninstaller.md
Normal file
79
sprints/uninstaller/opencode-01-uninstaller.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# Sprint: OpenCode Uninstaller Feature
|
||||
|
||||
## Problem Statement
|
||||
Users need a reliable way to completely remove OpenCode from their system, including all configuration files, cached data, and installed components, as outlined in [Issue #3900](https://github.com/sst/opencode/issues/3900).
|
||||
|
||||
## Context
|
||||
### Existing System
|
||||
OpenCode is a CLI tool that installs various components and configurations across the system. Currently, there is no comprehensive uninstall command that cleanly removes all traces of the installation.
|
||||
|
||||
### Uninstaller Feature Requirements
|
||||
The uninstaller must provide a complete removal process that:
|
||||
- Removes the OpenCode binary/executable
|
||||
- Cleans up configuration files from user directories
|
||||
- Removes cached data and temporary files
|
||||
- Provides options for selective removal (keep configs, etc.)
|
||||
- Confirms actions before destructive operations
|
||||
|
||||
## Success Criteria
|
||||
- [ ] Uninstall command (`opencode uninstall`) is available in the CLI
|
||||
- [ ] Command removes OpenCode executable from installation path
|
||||
- [ ] Configuration files in ~/.opencode are removed (with --all flag)
|
||||
- [ ] Cache directories are cleaned up
|
||||
- [ ] User is prompted for confirmation before removal
|
||||
- [ ] Option to keep configuration files (--keep-config)
|
||||
- [ ] Uninstaller provides clear feedback on what was removed
|
||||
- [ ] Process is reversible by reinstalling OpenCode
|
||||
- [ ] Exit code 0 on successful uninstallation
|
||||
- [ ] Comprehensive error handling for permission issues
|
||||
- [ ] Documentation updated with uninstall instructions
|
||||
|
||||
## Technical Requirements
|
||||
|
||||
### CLI Interface
|
||||
```bash
|
||||
opencode uninstall [options]
|
||||
--all Remove everything including configs
|
||||
--keep-config Keep configuration files
|
||||
--force Skip confirmation prompts
|
||||
--dry-run Show what would be removed without doing it
|
||||
```
|
||||
|
||||
### File Locations to Handle
|
||||
- **Binary**: `/usr/local/bin/opencode` or installation path
|
||||
- **Config**: `~/.opencode/` directory
|
||||
- **Cache**: `~/.cache/opencode/` directory
|
||||
- **Temp**: `/tmp/opencode-*` files
|
||||
- **Logs**: `~/.opencode/logs/` directory
|
||||
|
||||
### Implementation Steps
|
||||
1. Parse command arguments and flags
|
||||
2. Identify all OpenCode-related files and directories
|
||||
3. Show user what will be removed (with confirmation)
|
||||
4. Remove files in correct order (temp -> cache -> config -> binary)
|
||||
5. Verify removal and report status
|
||||
6. Clean up any remaining symlinks or PATH entries
|
||||
|
||||
### Error Handling
|
||||
- Permission denied errors should suggest using sudo
|
||||
- Missing files should not cause failure
|
||||
- Partial uninstall should be reported clearly
|
||||
- Network operations should have timeout handling
|
||||
|
||||
## Testing Strategy
|
||||
1. Install OpenCode in a test container
|
||||
2. Create configuration and cache files
|
||||
3. Run uninstall command with various flags
|
||||
4. Verify complete removal of all components
|
||||
5. Test edge cases (permissions, missing files, etc.)
|
||||
6. Validate that reinstallation works after uninstall
|
||||
|
||||
## Validation Checklist
|
||||
- [ ] Binary file removed from system
|
||||
- [ ] Config directory removed (when using --all)
|
||||
- [ ] Cache directory cleaned up
|
||||
- [ ] No orphaned files remain
|
||||
- [ ] PATH environment cleaned if modified
|
||||
- [ ] Exit codes match expected values
|
||||
- [ ] Help text includes uninstall command
|
||||
- [ ] Man page or docs updated
|
||||
Reference in New Issue
Block a user