oh-my-imagicma 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/types.d.ts +17 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/ralph-loop/constants.d.ts +5 -0
- package/dist/hooks/ralph-loop/index.d.ts +21 -0
- package/dist/hooks/ralph-loop/storage.d.ts +21 -0
- package/dist/hooks/ralph-loop/types.d.ts +28 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +15810 -0
- package/dist/shared/claude-config-dir.d.ts +1 -0
- package/dist/shared/data-path.d.ts +11 -0
- package/dist/shared/frontmatter.d.ts +10 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/logger.d.ts +5 -0
- package/dist/shared/system-directive.d.ts +23 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/slashcommand/index.d.ts +2 -0
- package/dist/tools/slashcommand/templates.d.ts +2 -0
- package/dist/tools/slashcommand/tools.d.ts +3 -0
- package/dist/tools/slashcommand/types.d.ts +6 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Oh My Imagicma
|
|
2
|
+
|
|
3
|
+
A minimal OpenCode plugin with Ralph Loop - self-referential development loop until task completion.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **`/ralph-loop`** - Start a self-referential development loop that continues until task completion
|
|
8
|
+
- **`/ulw-loop`** - Start an ultrawork loop that continues until task completion
|
|
9
|
+
- **`/cancel-ralph`** - Cancel the currently active Ralph Loop
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Install the plugin
|
|
15
|
+
bun add oh-my-imagicma
|
|
16
|
+
# or
|
|
17
|
+
npm install oh-my-imagicma
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Add to your OpenCode config (`~/.config/opencode/opencode.json`):
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"plugin": ["oh-my-imagicma"]
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Ralph Loop
|
|
31
|
+
|
|
32
|
+
Start a loop that continues until the task is complete:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
/ralph-loop "Build a REST API with authentication"
|
|
36
|
+
/ralph-loop "Refactor the payment module" --max-iterations=50
|
|
37
|
+
/ralph-loop "Fix all TypeScript errors" --completion-promise=ALL_FIXED
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**How it works:**
|
|
41
|
+
1. The agent works on the provided task
|
|
42
|
+
2. When the session goes idle, the system checks if the completion promise was output
|
|
43
|
+
3. If not complete, the agent is prompted to continue
|
|
44
|
+
4. This repeats until:
|
|
45
|
+
- The completion promise is detected: `<promise>DONE</promise>`
|
|
46
|
+
- Maximum iterations reached (default: 100)
|
|
47
|
+
- User cancels with `/cancel-ralph`
|
|
48
|
+
|
|
49
|
+
### Ultrawork Loop
|
|
50
|
+
|
|
51
|
+
Start an ultrawork loop that runs at maximum intensity until completion:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
/ulw-loop "Build a REST API with authentication"
|
|
55
|
+
/ulw-loop "Refactor the payment module" --max-iterations=50
|
|
56
|
+
/ulw-loop "Fix all TypeScript errors" --completion-promise=ALL_FIXED
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Cancel Ralph Loop
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
/cancel-ralph
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Configuration
|
|
66
|
+
|
|
67
|
+
Create a config file at `.opencode/oh-my-imagicma.json` (project) or `~/.config/opencode/oh-my-imagicma.json` (user):
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"ralph_loop": {
|
|
72
|
+
"enabled": true,
|
|
73
|
+
"default_max_iterations": 100,
|
|
74
|
+
"state_dir": ".imagicma/ralph-loop.local.md"
|
|
75
|
+
},
|
|
76
|
+
"disabled_hooks": []
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Development
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Install dependencies
|
|
84
|
+
bun install
|
|
85
|
+
|
|
86
|
+
# Type check
|
|
87
|
+
bun run typecheck
|
|
88
|
+
|
|
89
|
+
# Build
|
|
90
|
+
bun run build
|
|
91
|
+
|
|
92
|
+
# Run tests
|
|
93
|
+
bun test
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Publishing
|
|
97
|
+
|
|
98
|
+
1. **登录 npm**(若未登录):
|
|
99
|
+
```bash
|
|
100
|
+
npm login
|
|
101
|
+
```
|
|
102
|
+
按提示输入 npm 用户名、密码和邮箱(或使用 2FA)。
|
|
103
|
+
|
|
104
|
+
2. **确认版本**:在 `package.json` 里改好 `version`,或使用:
|
|
105
|
+
```bash
|
|
106
|
+
npm version patch # 0.1.0 -> 0.1.1
|
|
107
|
+
npm version minor # 0.1.0 -> 0.2.0
|
|
108
|
+
npm version major # 0.1.0 -> 1.0.0
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
3. **发布**:
|
|
112
|
+
```bash
|
|
113
|
+
npm publish
|
|
114
|
+
```
|
|
115
|
+
发布前会自动执行 `prepublishOnly`(clean + build),因此会先构建再上传。
|
|
116
|
+
|
|
117
|
+
首次发布前请确认 [npmjs.com](https://www.npmjs.com/) 上还没有同名包 `oh-my-imagicma`,否则需要换包名或使用 scope(如 `@your-username/oh-my-imagicma`)。
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { RalphLoopConfig, OhMyImagicmaConfig } from "./types";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for oh-my-imagicma
|
|
3
|
+
*/
|
|
4
|
+
export interface RalphLoopConfig {
|
|
5
|
+
/** Enable/disable Ralph Loop feature */
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
/** Default maximum iterations before stopping (default: 100) */
|
|
8
|
+
default_max_iterations?: number;
|
|
9
|
+
/** Custom state file path (default: .imagicma/ralph-loop.local.md) */
|
|
10
|
+
state_dir?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface OhMyImagicmaConfig {
|
|
13
|
+
/** Ralph Loop configuration */
|
|
14
|
+
ralph_loop?: RalphLoopConfig;
|
|
15
|
+
/** Disabled hooks */
|
|
16
|
+
disabled_hooks?: string[];
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createRalphLoopHook, type RalphLoopHook, type RalphLoopState, type RalphLoopOptions, HOOK_NAME as RALPH_LOOP_HOOK_NAME, DEFAULT_MAX_ITERATIONS, DEFAULT_COMPLETION_PROMISE, } from "./ralph-loop";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const HOOK_NAME = "ralph-loop";
|
|
2
|
+
export declare const DEFAULT_STATE_FILE = ".imagicma/ralph-loop.local.md";
|
|
3
|
+
export declare const COMPLETION_TAG_PATTERN: RegExp;
|
|
4
|
+
export declare const DEFAULT_MAX_ITERATIONS = 100;
|
|
5
|
+
export declare const DEFAULT_COMPLETION_PROMISE = "DONE";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
import type { RalphLoopState, RalphLoopOptions } from "./types";
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export * from "./constants";
|
|
5
|
+
export { readState, writeState, clearState, incrementIteration } from "./storage";
|
|
6
|
+
export interface RalphLoopHook {
|
|
7
|
+
event: (input: {
|
|
8
|
+
event: {
|
|
9
|
+
type: string;
|
|
10
|
+
properties?: unknown;
|
|
11
|
+
};
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
startLoop: (sessionID: string, prompt: string, options?: {
|
|
14
|
+
maxIterations?: number;
|
|
15
|
+
completionPromise?: string;
|
|
16
|
+
ultrawork?: boolean;
|
|
17
|
+
}) => boolean;
|
|
18
|
+
cancelLoop: (sessionID: string) => boolean;
|
|
19
|
+
getState: () => RalphLoopState | null;
|
|
20
|
+
}
|
|
21
|
+
export declare function createRalphLoopHook(ctx: PluginInput, options?: RalphLoopOptions): RalphLoopHook;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RalphLoopState } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Get the full path to the state file
|
|
4
|
+
*/
|
|
5
|
+
export declare function getStateFilePath(directory: string, customPath?: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Read the current Ralph Loop state from disk
|
|
8
|
+
*/
|
|
9
|
+
export declare function readState(directory: string, customPath?: string): RalphLoopState | null;
|
|
10
|
+
/**
|
|
11
|
+
* Write Ralph Loop state to disk
|
|
12
|
+
*/
|
|
13
|
+
export declare function writeState(directory: string, state: RalphLoopState, customPath?: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Clear the Ralph Loop state file
|
|
16
|
+
*/
|
|
17
|
+
export declare function clearState(directory: string, customPath?: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Increment the iteration counter and save state
|
|
20
|
+
*/
|
|
21
|
+
export declare function incrementIteration(directory: string, customPath?: string): RalphLoopState | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RalphLoopConfig } from "../../config";
|
|
2
|
+
export interface RalphLoopState {
|
|
3
|
+
/** Whether the loop is currently active */
|
|
4
|
+
active: boolean;
|
|
5
|
+
/** Current iteration number */
|
|
6
|
+
iteration: number;
|
|
7
|
+
/** Maximum iterations before stopping */
|
|
8
|
+
max_iterations: number;
|
|
9
|
+
/** The promise text that signals completion */
|
|
10
|
+
completion_promise: string;
|
|
11
|
+
/** ISO timestamp when the loop started */
|
|
12
|
+
started_at: string;
|
|
13
|
+
/** The original task prompt */
|
|
14
|
+
prompt: string;
|
|
15
|
+
/** Session ID associated with this loop */
|
|
16
|
+
session_id?: string;
|
|
17
|
+
ultrawork?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface RalphLoopOptions {
|
|
20
|
+
/** Ralph loop configuration */
|
|
21
|
+
config?: RalphLoopConfig;
|
|
22
|
+
/** Custom function to get transcript path */
|
|
23
|
+
getTranscriptPath?: (sessionId: string) => string;
|
|
24
|
+
/** API timeout in milliseconds */
|
|
25
|
+
apiTimeout?: number;
|
|
26
|
+
/** Function to check if a session exists */
|
|
27
|
+
checkSessionExists?: (sessionId: string) => Promise<boolean>;
|
|
28
|
+
}
|
package/dist/index.d.ts
ADDED