Skip to content

Commit f5c413d

Browse files
koki-developclaude
andcommitted
docs: Update CLAUDE.md with file editing system documentation
- Add comprehensive File Editing System section - Document core architecture components (FileEditor, Git, EditAction) - Explain file editing behavior and 20% trigger probability - Detail diff display system with ANSI256 color usage - Document git integration patterns and fallback strategies 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 3ae1ada commit f5c413d

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

CLAUDE.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,32 @@ The cat response system uses emotion detection and vocabulary mapping:
106106
- **Playful**: ニャーン, ミャミャ, ニャオッ (for games, toys)
107107
- **Sleepy**: ニャ…, フニャ~, ニャ~ン (for tired, sleep)
108108
- **Hungry**: ニャオォン, ミャーオ, ニャンニャン! (for food, eating)
109-
- **Default**: ニャー, ニャン, ミャー (for unrecognized input)
109+
- **Default**: ニャー, ニャン, ミャー (for unrecognized input)
110+
111+
## File Editing System
112+
113+
The cat occasionally "plays" with code files, making random edits and showing diffs:
114+
115+
### Core Architecture
116+
- **FileEditor Class** (`src/lib/fileEditor.ts`): Handles file selection, editing, and diff generation
117+
- **Git Integration** (`src/lib/git.ts`): Abstraction layer for git operations using simple-git
118+
- **EditAction Component** (`src/components/EditAction.tsx`): Displays file diffs with Claude Code-style formatting
119+
- **Action System** (`src/components/types.ts`): Structured type definitions for extensible action handling
120+
121+
### File Editing Behavior
122+
- **Trigger Probability**: 20% chance during cat responses (configurable in `cat.ts`)
123+
- **File Selection**: Prefers git-tracked files, falls back to glob patterns for text files
124+
- **Cat Word Replacement**: Randomly replaces up to 3 instances of words with cat sounds (ニャー, ミャー, etc.)
125+
- **Supported File Types**: txt, md, js, jsx, ts, tsx, json, css, html, xml, yml, yaml
126+
127+
### Diff Display System
128+
- **ANSI256 Colors**: Uses ansi256(52) for deletions (red background), ansi256(22) for additions (green background)
129+
- **Structured Format**: Line numbers in gray, `- content` for deletions, `+ content` for additions
130+
- **Component Integration**: EditAction appears before cat message when file editing occurs
131+
- **Message Architecture**: Uses action-based message system with optional action field
132+
133+
### Git Integration Patterns
134+
- **Repository Detection**: Automatically detects git initialization status
135+
- **File Tracking**: Uses `git ls-files` for tracked file enumeration
136+
- **Fallback Strategy**: Glob-based file discovery when git is unavailable
137+
- **Text File Filtering**: Consistent file type detection across both git and glob methods

0 commit comments

Comments
 (0)