Skip to content

Commit d60adaf

Browse files
Remove compaction hook
1 parent 7c6f255 commit d60adaf

5 files changed

Lines changed: 39 additions & 129 deletions

File tree

AGENTS.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ src/
4747
| Hook | Purpose |
4848
|------|---------|
4949
| `experimental.chat.system.transform` | Inject personality into system prompt |
50-
| `experimental.session.compacting` | Preserve personality during compaction |
5150
| `event` | Drift mood after assistant responses |
5251
| `command.execute.before` | Handle `/mood` and `/personality` commands |
5352

README.md

Lines changed: 25 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# OpenCode Personality Plugin
22

3-
A configurable personality and mood system plugin for [OpenCode](https://opencode.ai). Give your AI assistant a distinct personality with customizable moods that drift over time.
3+
**Stop talking to a machine. Give your AI a soul.**
4+
5+
The OpenCode Personality Plugin transforms your assistant from a generic text generator into a living, breathing character. With a sophisticated mood state machine and deep configuration options, your AI doesn't just follow instructions—it responds with attitude, emotion, and a personality that evolves over time.
46

57
> **Note:** This project is not built by the OpenCode team and is not affiliated with OpenCode in any way.
68
@@ -28,16 +30,14 @@ A configurable personality and mood system plugin for [OpenCode](https://opencod
2830

2931
## Features
3032

31-
- **Custom Personality**: Define your assistant's name, description, emoji usage, and slang intensity
32-
- **Dynamic Moods**: Configure custom moods with scores that drift naturally during conversations
33-
- **Multiple personalities**: Global and project-level configs with intelligent merging allow you to have a personality for all of your projects and to override per project.
34-
- **Toast Notifications**: Get notified when the mood shifts
35-
- **Commands**: Interactive commands to manage personality and mood
36-
- **Session Compaction**: Personality context preserved during session compaction
33+
- **Custom Personality**: Define name, description, emoji usage, and slang intensity.
34+
- **Dynamic Moods**: Configure custom moods with scores that drift naturally during conversations.
35+
- **Intelligent Merging**: Global and project-level configs allow for project-specific overrides.
36+
- **Toast Notifications**: Get visual feedback when the assistant's mood shifts.
37+
- **Interactive Commands**: Manage your assistant's persona directly from the chat.
3738

38-
## Installation
3939

40-
### From npm
40+
## Installation
4141

4242
Add to your `~/.config/opencode/opencode.json`:
4343

@@ -57,26 +57,16 @@ Add to your `~/.config/opencode/opencode.json`:
5757
}
5858
```
5959

60-
> **Note:** The `command` definitions are required because OpenCode's plugin API doesn't yet support programmatic command registration. Commands must be defined in your config file.
61-
62-
### From Source
63-
64-
Clone the repository and add to `opencode.json`:
65-
66-
```json
67-
{
68-
"plugin": ["./path/to/opencode-personality/src/index.ts"]
69-
}
70-
```
60+
> **Note:** Commands must be defined in your config file as OpenCode's plugin API doesn't yet support programmatic registration.
7161
7262
## Quick Start
7363

7464
1. Run `opencode`
75-
2. Use `/personality create` to have the assistant guide you through creating a configuration interactively.
65+
2. Use `/personality create` to have the assistant guide you through setup.
7666

7767
### Manual Setup
7868

79-
1. Create a personality config file at `~/.config/opencode/personality.json` (global) or `.opencode/personality.json` (project):
69+
Create a config at `~/.config/opencode/personality.json` (global) or `.opencode/personality.json` (project):
8070

8171
```json
8272
{
@@ -92,10 +82,6 @@ Clone the repository and add to `opencode.json`:
9282
}
9383
```
9484

95-
2. Start OpenCode - the personality will be automatically applied!
96-
97-
3. Use `/mood` to check or change the current mood.
98-
9985
## Configuration Reference
10086

10187
### PersonalityFile
@@ -105,7 +91,7 @@ Clone the repository and add to `opencode.json`:
10591
| `name` | string | `""` | Name the assistant uses when asked |
10692
| `description` | string | `""` | Personality description injected into prompts |
10793
| `emoji` | boolean | `false` | Whether to use emojis in responses |
108-
| `slangIntensity` | number | `0` | Slang usage intensity (0-1). 0=none, 0.3=light, 0.7=heavy |
94+
| `slangIntensity` | number | `0` | Slang usage intensity (0-1) |
10995
| `moods` | MoodDefinition[] | (defaults) | Custom mood definitions |
11096
| `mood` | MoodConfig | (see below) | Mood system configuration |
11197

@@ -129,8 +115,6 @@ Clone the repository and add to `opencode.json`:
129115

130116
### Default Moods
131117

132-
If `moods` is not specified, these defaults are used:
133-
134118
| Name | Hint | Score |
135119
|------|------|-------|
136120
| `bored` | Responses feel slightly disinterested | -2 |
@@ -143,46 +127,34 @@ If `moods` is not specified, these defaults are used:
143127

144128
### `/mood [mood|status]`
145129

146-
Check or set the current mood.
130+
Check or set the current mood permanently.
147131

148-
```
149-
/mood # Show current mood status
150-
/mood status # Same as above
132+
```bash
133+
/mood status # Show current mood status
151134
/mood happy # Set mood to "happy" permanently
152135
```
153136

154-
**Note:** The `/mood` command sets moods permanently. For temporary overrides (message or session duration), use the `setMood` tool.
155-
156137
### `/personality <subcommand>`
157138

158139
Manage personality configuration.
159140

160141
| Subcommand | Description |
161142
|------------|-------------|
162143
| `show` | Display the merged configuration |
163-
| `create` | Start an interactive conversation to create a new config |
164-
| `edit` | Start an interactive conversation to modify the config |
165-
| `edit --field <name> --value <value>` | Directly update a specific field |
166-
| `reset --confirm` | Delete the personality config file |
144+
| `create` | Interactive setup (use `--scope global` for global) |
145+
| `edit` | Interactive edit or direct update with `--field` and `--value` |
146+
| `reset` | Delete the config file (requires `--confirm`) |
167147

168148
**Examples:**
169-
170-
```
171-
/personality show # Show merged config
172-
/personality create # Create config (project scope)
173-
/personality create --scope global # Create config (global scope)
174-
/personality edit # Edit config interactively
175-
/personality edit --field name --value "Assistant" # Update single field
176-
/personality edit --field emoji --value true # Enable emojis
177-
/personality reset --scope project --confirm # Delete project config
149+
```bash
150+
/personality show
151+
/personality create --scope global
152+
/personality edit --field emoji --value true
153+
/personality reset --scope project --confirm
178154
```
179155

180-
**Editable fields:** `name`, `description`, `emoji`, `slangIntensity`, `mood.enabled`, `mood.default`, `mood.drift`
181-
182156
## Tools
183157

184-
The plugin exposes tools that the LLM can use during conversations.
185-
186158
### `setMood`
187159

188160
Override the current mood with optional duration.
@@ -192,32 +164,8 @@ Override the current mood with optional duration.
192164
| `mood` | string | Yes | Name of the mood to set |
193165
| `duration` | string | No | `"message"`, `"session"` (default), or `"permanent"` |
194166

195-
**Duration options:**
196-
- `message`: Override lasts for the next response only
197-
- `session`: Override lasts until OpenCode restarts (default)
198-
- `permanent`: Override persists across sessions
199-
200-
### `savePersonality`
201-
202-
Save a personality configuration. Used by the assistant when you run `/personality create` or `/personality edit`.
203-
204-
| Parameter | Type | Required | Description |
205-
|-----------|------|----------|-------------|
206-
| `description` | string | Yes | Personality description |
207-
| `name` | string | No | Name for the assistant |
208-
| `emoji` | boolean | No | Enable emoji usage |
209-
| `slangIntensity` | number | No | Slang level (0-1) |
210-
| `moodEnabled` | boolean | No | Enable mood system |
211-
| `moodDefault` | string | No | Default mood name |
212-
| `moodDrift` | number | No | Drift amount (0-1) |
213-
| `moodToast` | boolean | No | Show toast on mood change (default: true) |
214-
| `moods` | array | No | Custom mood definitions |
215-
| `scope` | string | No | `"project"` (default) or `"global"` |
216-
217167
## Custom Moods Example
218168

219-
Create moods tailored to your assistant's personality:
220-
221169
```json
222170
{
223171
"name": "Surfer Dude",
@@ -238,37 +186,7 @@ Create moods tailored to your assistant's personality:
238186
}
239187
```
240188

241-
**Tip:** Checkout the `examples`-folder for a few prebuilt personalities.
242-
243-
## Config Precedence
244-
245-
1. **Project config** (`.opencode/personality.json`) takes precedence
246-
2. **Global config** (`~/.config/opencode/personality.json`) is used as fallback
247-
3. When both exist, they are **deep merged** with project values overriding global
248-
249-
## How It Works
250-
251-
1. **System Prompt Injection**: The plugin injects personality traits into the system prompt via the `experimental.chat.system.transform` hook
252-
2. **Mood Drift**: After each assistant response, the mood score drifts randomly within the configured `drift` amount
253-
3. **Mood Resolution**: The current score maps to the nearest defined mood by score value
254-
4. **Toast Notifications**: When the mood changes, a toast notification appears
255-
5. **Session Compaction**: During session compaction, the personality context is preserved
256-
257-
## Development
258-
259-
```bash
260-
# Install dependencies
261-
npm install
262-
263-
# Type check
264-
npm run typecheck
265-
266-
# Lint
267-
npm run lint
268-
269-
# Build
270-
npm run build
271-
```
189+
**Tip:** Checkout the `examples` folder for more prebuilt personalities.
272190

273191
## License
274192

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opencode-personality",
3-
"version": "1.0.2",
3+
"version": "1.1.0",
44
"description": "Configurable personality and mood system plugin for OpenCode",
55
"type": "module",
66
"main": "dist/index.js",

src/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,6 @@ const personalityPlugin: Plugin = async (input: PluginInput) => {
8080
output.system.push(`<personality>\n${prompt}\n</personality>`)
8181
},
8282

83-
"experimental.session.compacting": async (_hookInput, output) => {
84-
const state = loadMoodState(statePath, config)
85-
output.context.push(
86-
`Assistant personality: ${config.description}. Current mood: ${state.current}.`
87-
)
88-
},
89-
9083
event: async ({ event }) => {
9184
if (event.type === "message.updated" && config.mood.enabled) {
9285
const msg = event.properties as { info?: { sessionID?: string; role?: string } }

src/tools/savePersonality.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,19 @@ export function createSavePersonalityTool(
6161
const scope = args.scope ?? "project"
6262
const scopePath = resolveScopePath(scope, configResult)
6363

64-
const config: Partial<PersonalityFile> = {
65-
name: args.name?.trim() ?? "",
66-
description: args.description.trim(),
67-
emoji: args.emoji ?? false,
68-
slangIntensity: args.slangIntensity ?? 0,
69-
mood: {
70-
enabled: args.moodEnabled ?? false,
71-
default: args.moodDefault ?? "happy",
72-
override: null,
73-
drift: args.moodDrift ?? 0.2,
74-
toast: args.moodToast ?? true,
75-
},
76-
}
64+
const config: Partial<PersonalityFile> = {
65+
name: args.name?.trim() ?? "",
66+
description: args.description.trim(),
67+
emoji: args.emoji ?? false,
68+
slangIntensity: args.slangIntensity ?? 0,
69+
mood: {
70+
enabled: args.moodEnabled ?? false,
71+
default: args.moodDefault ?? "happy",
72+
override: null,
73+
drift: args.moodDrift ?? 0.2,
74+
toast: args.moodToast ?? true,
75+
},
76+
}
7777

7878
if (args.moods && args.moods.length > 0) {
7979
config.moods = args.moods as MoodDefinition[]

0 commit comments

Comments
 (0)