Skip to content

Commit 96d2f6d

Browse files
committed
Refactor 3/3 | Command Folder & Tree Rearrangement
1 parent c06058f commit 96d2f6d

64 files changed

Lines changed: 2622 additions & 1766 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,22 @@ MAX_DOCUMENT_OPERATIONS_PER_DAY=20
151151
DEFAULT_COMMAND_COOLDOWN=1600
152152
# Cooldown for /config commands
153153
COOLDOWN_CONFIG=3000
154-
# Cooldown for /teach commands
154+
# Legacy fallback cooldown for pre-Wave-3 /teach commands
155155
COOLDOWN_TEACH=3000
156-
# Cooldown for /data commands
156+
# Legacy fallback cooldown for pre-Wave-3 /data commands
157157
COOLDOWN_DATA=3000
158-
# Cooldown for /forget commands
158+
# Legacy fallback cooldown for pre-Wave-3 /forget commands
159159
COOLDOWN_FORGET=3000
160160
# Cooldown for /persona commands
161161
COOLDOWN_PERSONA=10000
162+
# Cooldown for /memory commands
163+
COOLDOWN_MEMORY=3000
162164
# Cooldown for /server commands
163165
COOLDOWN_SERVER=3000
164166
# Cooldown for /personal commands
165167
COOLDOWN_PERSONAL=3000
168+
# Cooldown for /conditioning commands
169+
COOLDOWN_CONDITIONING=3000
166170

167171
# Memory & Media Protection (Optional)
168172
# Number of most recent messages that can contain full media (images, videos, GIFs)

docs/ai/conditioning-memory.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ This means a persona can accumulate different reward/punish patterns in differen
1414

1515
## User Commands
1616

17-
### `/reward`
17+
### `/conditioning reward`
1818

1919
Reward actions remain direct interaction commands:
2020

21-
- `/reward headpat`
22-
- `/reward hug`
23-
- `/reward kiss`
24-
- `/reward tickle`
21+
- `/conditioning reward headpat`
22+
- `/conditioning reward hug`
23+
- `/conditioning reward kiss`
24+
- `/conditioning reward tickle`
2525

2626
Each subcommand now accepts an optional `reason` string.
2727

28-
### `/punish`
28+
### `/conditioning punish`
2929

3030
Punishment uses the parallel interaction surface:
3131

32-
- `/punish spank`
33-
- `/punish pinch`
34-
- `/punish bite`
35-
- `/punish squeeze`
32+
- `/conditioning punish spank`
33+
- `/conditioning punish pinch`
34+
- `/conditioning punish bite`
35+
- `/conditioning punish squeeze`
3636

3737
Each subcommand also accepts an optional `reason` string.
3838

@@ -47,10 +47,12 @@ Management is centralized under `/conditioning`:
4747
`/conditioning manage` is now server-wide:
4848

4949
- it does not require picking a persona first
50-
- it shows stored reward and punishment entries from every persona in the server
50+
- it shows only injected reward and punishment entries from every persona in the server
5151
- each checklist entry includes the persona name plus a ❤️ reward or 💀 punishment marker
5252
- lists beyond one modal use a page-selection step and page-scoped checkbox modals
5353

54+
Entries that are stored but not currently injectable stay in the database but are hidden from `/conditioning manage`.
55+
5456
## Storage Rules
5557

5658
Conditioning rows are stored in `conditioning_history`.
@@ -137,6 +139,6 @@ These are documented in `.env.example`.
137139
- `src/utils/conditioning/conditioning.ts`
138140
- `src/utils/text/contextBuilder.ts`
139141
- `src/utils/text/presetContextBuilder.ts`
140-
- `src/commands/reward/*`
141-
- `src/commands/punish/*`
142+
- `src/commands/conditioning/reward/*`
143+
- `src/commands/conditioning/punish/*`
142144
- `src/commands/conditioning/*`

docs/ai/context-assembly.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@ The `metadataTag` is a stable interface between the native builder and the prese
7272
| Tag | Block # | Description | Configured via |
7373
|-----|---------|-------------|---------------|
7474
| `SYSTEM_HUMANIZER_RULES` | 1 | System prompt + persona prompt | `/sysprompt`, `/persona` |
75-
| `SYSTEM_PERSONALITY` | 2 | Personality attributes | `/teach attribute`, `/forget attribute` |
75+
| `SYSTEM_PERSONALITY` | 2 | Personality attributes | `/persona attribute add`, `/persona attribute remove` |
7676
| `KNOWLEDGE_SERVER_INFO` | 3 | Server name, description, channel info | Automatic (Discord metadata) |
77-
| `KNOWLEDGE_SERVER_MEMORIES` | 4 | Server-level memories | `/teach memory server`, `/forget memory server` |
77+
| `KNOWLEDGE_SERVER_MEMORIES` | 4 | Server-level memories | `/memory server add`, `/memory server remove` |
7878
| `KNOWLEDGE_SERVER_EMOJIS` | 5 | Available custom emojis | `/server initialize expressions` |
7979
| `KNOWLEDGE_SERVER_STICKERS` | 6 | Available stickers | `/server initialize expressions` |
80-
| `KNOWLEDGE_USERS_IN_CONVERSATION` | 7 | User list + personal memories + status + reminders + time/channel info | `/teach memory personal`, `/forget memory personal` |
80+
| `KNOWLEDGE_USERS_IN_CONVERSATION` | 7 | User list + personal memories + status + reminders + time/channel info | `/memory personal add`, `/memory personal remove` |
8181
| `KNOWLEDGE_SHORT_TERM_MEMORY` | 8 | Recent conversation summaries from other channels (STM) | `/personal cache` |
82-
| `KNOWLEDGE_SERVER_DOCUMENTS` | 9 | RAG document chunks | `/teach document`, `/teach history`, `/forget document` |
83-
| `KNOWLEDGE_SERVER_CONDITIONING` | 10 | Reward/punish conditioning guidance for the active persona | `/reward`, `/punish`, `/conditioning manage` |
84-
| `DIALOGUE_SAMPLE` | 11 | Sample dialogue pairs | `/teach sampledialogue`, `/forget sampledialogue` |
82+
| `KNOWLEDGE_SERVER_DOCUMENTS` | 9 | RAG document chunks | `/memory document add`, `/memory history import`, `/memory document remove` |
83+
| `KNOWLEDGE_SERVER_CONDITIONING` | 10 | Reward/punish conditioning guidance for the active persona | `/conditioning reward`, `/conditioning punish`, `/conditioning manage` |
84+
| `DIALOGUE_SAMPLE` | 11 | Sample dialogue pairs | `/persona sample-dialogue add`, `/persona sample-dialogue remove` |
8585
| `DIALOGUE_HISTORY` | 12 | Actual conversation history | `/config message-fetch-limit` |
8686

8787
## Native Assembly Order
@@ -92,9 +92,9 @@ All blocks marked with `*` are conditional (only included when enabled/available
9292
```text
9393
1. System prompt (/sysprompt) [SYSTEM_HUMANIZER_RULES]
9494
2. Persona prompt (/persona)* [SYSTEM_HUMANIZER_RULES]
95-
3. Personality attributes (/teach attribute)* [SYSTEM_PERSONALITY]
95+
3. Personality attributes (/persona attribute add)* [SYSTEM_PERSONALITY]
9696
4. Server info = server name + description [KNOWLEDGE_SERVER_INFO]
97-
5. Server memories (/teach memory server)* [KNOWLEDGE_SERVER_MEMORIES]
97+
5. Server memories (/memory server add)* [KNOWLEDGE_SERVER_MEMORIES]
9898
6. Server emojis* [KNOWLEDGE_SERVER_EMOJIS]
9999
7. Server stickers* [KNOWLEDGE_SERVER_STICKERS]
100100
8. Users in conversation = user list + personal [KNOWLEDGE_USERS_IN_CONVERSATION]
@@ -122,7 +122,7 @@ When a SillyTavern preset is active, the system uses a **Build-Then-Rearrange**
122122
5. Merge depth-injected nodes into dialogue history items
123123
6. Flush any remaining TomoriBot-only blocks at anchor points
124124

125-
This avoids refactoring the native builder while gaining full preset control over prompt ordering. The native blocks still contain the same content (system prompt from `/sysprompt`, personality from `/teach attribute`, etc.) — the preset only controls **where** each block appears and **what additional content** is injected around them.
125+
This avoids refactoring the native builder while gaining full preset control over prompt ordering. The native blocks still contain the same content (system prompt from `/sysprompt`, personality from `/persona attribute add`, etc.) — the preset only controls **where** each block appears and **what additional content** is injected around them.
126126

127127
If the preset is deactivated or deleted, context assembly immediately reverts to the native fixed order above. No data is lost — `/sysprompt`, personality attributes, memories, and all other settings are stored independently from the preset.
128128

docs/ai/providers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ Current command examples:
339339
- `src/commands/server/initialize/expressions.ts`
340340
- `src/commands/persona/generate.ts`
341341
- `src/commands/tool/compact.ts`
342-
- `src/commands/teach/history.ts`
342+
- `src/commands/memory/history/import.ts`
343343

344344
## Intentional Exceptions
345345

docs/ai/rag.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ ACTIVATE_LOCAL_RAG=true
1616

1717
This gate affects both schema initialization and runtime behavior:
1818
- The pgvector extension and document tables are not created locally unless RAG is enabled.
19-
- `/teach document` and `/forget document` are blocked locally unless RAG is enabled.
19+
- `/memory document add` and `/memory document remove` are blocked locally unless RAG is enabled.
2020
- Automatic retrieval is skipped locally unless RAG is enabled.
2121

2222
## End-to-End Flow (Detailed)
2323

24-
### 1) Upload (`/teach document`)
24+
### 1) Upload (`/memory document add`)
2525
Input:
2626
- `name` (string, unique per server)
2727
- `file` (attachment: .txt, .md, .pdf)
@@ -114,11 +114,11 @@ This block is injected as a system context item tagged:
114114
- If the model family changes, documents are re-embedded.
115115
- If RAG is disabled locally, re-embedding is skipped.
116116

117-
- `/teach document`
117+
- `/memory document add`
118118
- Upload + parse + chunk + embed + store.
119119
- Blocked when RAG is disabled locally.
120120

121-
- `/forget document`
121+
- `/memory document remove`
122122
- Deletes the selected document and cascades its chunks.
123123
- Blocked when RAG is disabled locally.
124124

@@ -170,9 +170,9 @@ pgvector requirement:
170170
## Code Pointers (Primary Paths)
171171

172172
- Upload + parse + chunk + embed:
173-
- `src/commands/teach/document.ts`
173+
- `src/commands/memory/document/add.ts`
174174
- Delete:
175-
- `src/commands/forget/document.ts`
175+
- `src/commands/memory/document/remove.ts`
176176
- Model selection + optional re-embed:
177177
- `src/commands/config/model/embedding.ts`
178178
- Embedding requests:

docs/core/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ TomoriBot is a TypeScript + Bun Discord AI chatbot focused on configurable perso
3232

3333
## Current Command Surface
3434

35-
Commands are loaded from folders under `src/commands/` (currently 19 top-level categories):
35+
Commands are loaded from folders under `src/commands/` (currently 17 top-level categories):
3636

37-
- `bot`, `conditioning`, `config`, `contribute`, `data`, `donate`, `forget`, `generate`, `help`, `legal`, `novelai`, `persona`, `personal`, `punish`, `reward`, `server`, `support`, `teach`, `tool`
37+
- `bot`, `conditioning`, `config`, `contribute`, `donate`, `generate`, `help`, `legal`, `memory`, `novelai`, `optional-key`, `persona`, `personal`, `server`, `st-preset`, `support`, `tool`
3838

3939
## Documentation Layout
4040

docs/integrations/matrix-bridge.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Matrix users can be set as reminder targets. Since they have no row in the `user
340340

341341
1. **`reminderTool.ts`**: Skips BigInt fuzzy-matching (Matrix IDs are not numeric), skips `users` table lookup, and trusts the AI-provided nickname directly.
342342
2. **`reminderTimer.ts`**: After delivering the reminder, calls `sendMatrixReminderMention()` instead of the Discord mention path. This sends a direct Matrix mention to the linked room if the AI response didn't already include the `@{localpart}` placeholder.
343-
3. **`forget/reminder.ts`**: Displays Matrix reminders with `(Matrix)` suffix and `for {nickname}` instead of `created by {nickname}` so server managers can identify them.
343+
3. **`personal/reminder/remove.ts`**: Displays Matrix reminders with `(Matrix)` suffix and `for {nickname}` instead of `created by {nickname}` so server managers can identify them.
344344

345345
Matrix user IDs are stored as-is in the `user_discord_id` TEXT column of the `reminders` table (which already accepts arbitrary strings). No schema changes were needed for reminder support.
346346

docs/integrations/modal-input-components.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,11 @@ These commands still remove one dynamic item at a time, but the data shape is a
418418

419419
| Command | File | Current Input | Why Checkbox Groups Fit | Notes |
420420
| -------------------------- | ---------------------------------- | --------------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------- |
421-
| `/forget attribute` | `forget/attribute.ts` | Persona picker + single paginated select | Personality attributes are usually reviewed and pruned in batches | Needs index-safe array rewrite if duplicate attributes must be preserved |
422-
| `/forget reminder` | `forget/reminder.ts` | Persona picker + single paginated select | Reminder cleanup is often batch-oriented, especially for stale schedules | Manager-only reminder views may need concise descriptions |
423-
| `/forget document` | `forget/document.ts` | Persona picker + single paginated select | Document cleanup is an obvious multi-select management flow | Large lists should keep paginated fallback |
424-
| `/forget history` | `forget/history.ts` | Persona picker + single paginated select | History entries are frequently pruned in groups | Large lists should keep paginated fallback |
425-
| `/forget sampledialogue` | `forget/sampledialogue.ts` | Persona picker + single paginated select | Dialogue cleanup is often batch-oriented and already has index-safe removal | Good fit for index-valued checkbox groups |
421+
| `/persona attribute remove` | `persona/attribute/remove.ts` | Persona picker + single paginated select | Personality attributes are usually reviewed and pruned in batches | Needs index-safe array rewrite if duplicate attributes must be preserved |
422+
| `/personal reminder remove` | `personal/reminder/remove.ts` | Persona picker + single paginated select | Reminder cleanup is often batch-oriented, especially for stale schedules | Manager-only reminder views may need concise descriptions |
423+
| `/memory document remove` | `memory/document/remove.ts` | Persona picker + single paginated select | Document cleanup is an obvious multi-select management flow | Large lists should keep paginated fallback |
424+
| `/memory history remove` | `memory/history/remove.ts` | Persona picker + single paginated select | History entries are frequently pruned in groups | Large lists should keep paginated fallback |
425+
| `/persona sample-dialogue remove` | `persona/sample-dialogue/remove.ts` | Persona picker + single paginated select | Dialogue cleanup is often batch-oriented and already has index-safe removal | Good fit for index-valued checkbox groups |
426426
| `/persona remove` | `persona/remove.ts` | Single paginated select | Alter persona cleanup could be batch-managed | Should pair the bulk UI with stronger destructive-action messaging |
427427

428428
### Not Candidates — Keep String Select
@@ -439,14 +439,14 @@ These modals have dynamic or large option sets that exceed Radio Group/Checkbox
439439
| `/config model fallback` | `config/model/fallback.ts` | Dynamic model list, uses pagination |
440440
| `/config system-prompt preset` | `config/system-prompt/preset.ts` | Dynamic preset list from DB |
441441
| `/config api-key set` | `config/api-key/set.ts` | Provider select + text input combo; list may grow |
442-
| `/teach personaprompt` | `teach/personaprompt.ts` | Dynamic persona list + free-form prompt (up to 16000 chars, 4 fields) |
443-
| `/teach attribute` | `teach/attribute.ts` | Dynamic persona list, uses pagination |
444-
| `/teach sampledialogue` | `teach/sampledialogue.ts` | Dynamic persona list, uses pagination |
445-
| `/teach memory personal` | `teach/memory/personal.ts` | Dynamic memory list |
446-
| `/teach memory server` | `teach/memory/server.ts` | Dynamic memory list |
442+
| `/persona prompt set` | `persona/prompt/set.ts` | Dynamic persona list + free-form prompt (up to 16000 chars, 4 fields) |
443+
| `/persona attribute add` | `persona/attribute/add.ts` | Dynamic persona list, uses pagination |
444+
| `/persona sample-dialogue add` | `persona/sample-dialogue/add.ts`| Dynamic persona list, uses pagination |
445+
| `/memory personal add` | `memory/personal/add.ts` | Dynamic memory list |
446+
| `/memory server add` | `memory/server/add.ts` | Dynamic memory list |
447447
| `/novelai image-tags character` | `novelai/tags/character.ts` | Dynamic persona list |
448-
| `/forget attribute` | `forget/attribute.ts` | Dynamic attribute list, uses pagination |
449-
| `/forget reminder` | `forget/reminder.ts` | Dynamic reminder list |
448+
| `/persona attribute remove` | `persona/attribute/remove.ts` | Dynamic attribute list, uses pagination |
449+
| `/personal reminder remove` | `personal/reminder/remove.ts` | Dynamic reminder list |
450450
| `/server welcome-channel set` | `server/welcome-channel/set.ts` | Channel option + dynamic persona list |
451451

452452
### Not Candidates — Keep Text Input
@@ -466,7 +466,7 @@ These modals collect free-form text and have no structured option set:
466466
| `/server trigger add` | `server/trigger/add.ts` | Free-form text fields (word, response, cooldown) |
467467
| `/server avatar` | `server/avatar.ts` | File upload only |
468468
| `/tool comment` | `tool/comment.ts` | Free-form paragraph text |
469-
| `/data import` | `data/import.ts` | File upload only |
469+
| `/memory personal import` | `memory/personal/import.ts` | File upload only |
470470

471471
---
472472

docs/integrations/sillytavern-preset-system.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ This section documents what our implementation supports versus what native Silly
389389
|-------|--------|-------|
390390
| `{{user}}` | Supported | Deferred to `convertMentions()` |
391391
| `{{char}}` / `{{bot}}` | Supported | Deferred to `convertMentions()` |
392-
| `{{personality}}` | Supported | Maps to `/teach attribute` values |
392+
| `{{personality}}` | Supported | Maps to `/persona attribute add` values |
393393
| `{{description}}` | Supported | Maps to persona prompt |
394394
| `{{mesExamples}}` | Supported | Maps to sample dialogues |
395395
| `{{lastChatMessage}}` | Supported | Most recent user message |

0 commit comments

Comments
 (0)