ralph-mem 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ralph-mem contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,232 @@
1
+ # ralph-mem
2
+
3
+ Claude Code를 위한 Ralph Loop 기반 지속적 컨텍스트 관리 플러그인
4
+
5
+ ## 개요
6
+
7
+ ralph-mem은 [Ralph Loop](https://ghuntley.com/ralph/)의 "성공할 때까지 반복" 철학과 [claude-mem](https://github.com/thedotmack/claude-mem)의 "지능적 컨텍스트 관리"를 결합한 Claude Code 플러그인입니다.
8
+
9
+ ### 해결하는 문제
10
+
11
+ | 문제 | 설명 |
12
+ | ----------------- | -------------------------------------------- |
13
+ | **Context Rot** | 누적된 불필요한 정보로 인한 모델 성능 저하 |
14
+ | **Compaction** | context window 60-70% 초과 시 출력 품질 급락 |
15
+ | **Forgetfulness** | 세션 간 작업 맥락 손실 |
16
+ | **One-shot 실패** | 복잡한 작업에서 단일 시도 성공률 저조 |
17
+
18
+ ## 핵심 기능
19
+
20
+ ### 1. Ralph Loop Engine
21
+
22
+ 성공 기준 달성까지 자동으로 반복 실행합니다.
23
+
24
+ ```bash
25
+ /ralph start "Add user authentication with JWT"
26
+ ```
27
+
28
+ ```mermaid
29
+ flowchart LR
30
+ A[Prompt + Context] --> B[Agent Execute]
31
+ B --> C{Success?}
32
+ C -->|YES| D[Done]
33
+ C -->|NO| E[Append Result]
34
+ E --> A
35
+ ```
36
+
37
+ **지원하는 성공 기준:**
38
+
39
+ - `test_pass` - 테스트 통과 (`npm test`, `pytest`)
40
+ - `build_success` - 빌드 성공
41
+ - `lint_clean` - Lint 오류 없음
42
+ - `type_check` - 타입 체크 통과
43
+ - `custom` - 사용자 정의 명령
44
+
45
+ ### 2. Persistent Memory
46
+
47
+ 세션 간 컨텍스트를 자동으로 저장하고 복원합니다.
48
+
49
+ ```mermaid
50
+ flowchart TB
51
+ A[새 세션 시작] --> B[관련 메모리 검색]
52
+ B --> C[이전 작업 컨텍스트 주입]
53
+ C --> D[세션 진행]
54
+ D --> E[관찰 기록]
55
+ E --> F[세션 종료]
56
+ F --> G[요약 생성 및 저장]
57
+ ```
58
+
59
+ **Lifecycle Hooks:**
60
+
61
+ - `SessionStart` - 관련 메모리 자동 주입
62
+ - `PostToolUse` - 도구 사용 결과 기록
63
+ - `SessionEnd` - 세션 요약 생성 및 저장
64
+
65
+ ### 3. Progressive Disclosure
66
+
67
+ 토큰 효율적인 3계층 검색으로 약 10배 토큰 절약:
68
+
69
+ | Layer | 내용 | 토큰 |
70
+ | ------- | -------------------------- | --------------- |
71
+ | Layer 1 | Index (ID + 점수) | 50-100/result |
72
+ | Layer 2 | Timeline (시간순 컨텍스트) | 200-300/result |
73
+ | Layer 3 | Full Details | 500-1000/result |
74
+
75
+ ```bash
76
+ /mem-search "authentication error" # Layer 1
77
+ /mem-search --layer 3 obs-a1b2 # Layer 3
78
+ ```
79
+
80
+ ## 설치
81
+
82
+ ```bash
83
+ # Claude Code 플러그인으로 설치
84
+ claude plugins install ralph-mem
85
+ ```
86
+
87
+ ## 사용법
88
+
89
+ ### Ralph Loop
90
+
91
+ ```bash
92
+ # Loop 시작 (기본: 테스트 통과까지)
93
+ /ralph start "Implement feature X"
94
+
95
+ # 커스텀 성공 기준으로 시작
96
+ /ralph start "Fix lint errors" --criteria lint_clean
97
+
98
+ # Loop 상태 확인
99
+ /ralph status
100
+
101
+ # Loop 중단
102
+ /ralph stop
103
+ ```
104
+
105
+ ### Memory 검색
106
+
107
+ ```bash
108
+ # 키워드 검색
109
+ /mem-search "JWT authentication"
110
+
111
+ # 특정 관찰 상세 조회
112
+ /mem-search --layer 3 <observation-id>
113
+
114
+ # 시간 범위 검색
115
+ /mem-search "database" --since 7d
116
+ ```
117
+
118
+ ### Memory 관리
119
+
120
+ ```bash
121
+ # 메모리 상태 확인
122
+ /mem-status
123
+
124
+ # 수동 컨텍스트 주입
125
+ /mem-inject "이 프로젝트는 Express + Prisma 기반"
126
+
127
+ # 특정 메모리 제거
128
+ /mem-forget <observation-id>
129
+ ```
130
+
131
+ ## 설정
132
+
133
+ `~/.config/ralph-mem/config.yaml`:
134
+
135
+ ```yaml
136
+ ralph:
137
+ max_iterations: 10 # 최대 반복 횟수
138
+ context_budget: 0.6 # context window 사용률 상한
139
+ cooldown_ms: 1000 # 반복 간 대기 시간
140
+ success_criteria:
141
+ - type: test_pass
142
+ command: "npm test"
143
+
144
+ memory:
145
+ auto_inject: true # 세션 시작 시 자동 주입
146
+ max_inject_tokens: 2000 # 주입 최대 토큰
147
+ retention_days: 30 # 메모리 보관 기간
148
+
149
+ privacy:
150
+ exclude_patterns: # 저장 제외 패턴
151
+ - "*.env"
152
+ - "*password*"
153
+ - "*secret*"
154
+ ```
155
+
156
+ ## 아키텍처
157
+
158
+ ```mermaid
159
+ flowchart TB
160
+ subgraph Plugin["ralph-mem Plugin"]
161
+ subgraph Interface["Interface Layer"]
162
+ Hooks[Hooks]
163
+ Skills[Skills]
164
+ Loop[Loop Engine]
165
+ end
166
+
167
+ subgraph Core["Core Service"]
168
+ Store[Memory Store]
169
+ Search[Search Engine]
170
+ Compress[Compressor]
171
+ end
172
+
173
+ subgraph Storage["Storage"]
174
+ DB[(SQLite + FTS5)]
175
+ end
176
+
177
+ Hooks --> Core
178
+ Skills --> Core
179
+ Loop --> Core
180
+ Core --> DB
181
+ end
182
+ ```
183
+
184
+ ## 프로젝트 구조
185
+
186
+ ```text
187
+ ralph-mem/
188
+ ├── src/
189
+ │ ├── hooks/ # Lifecycle hooks
190
+ │ ├── skills/ # Slash commands
191
+ │ ├── loop/ # Ralph Loop engine
192
+ │ ├── memory/ # Memory store & search
193
+ │ └── db/ # SQLite + FTS5
194
+ ├── prompts/ # AI 프롬프트
195
+ ├── docs/
196
+ │ └── PRD.md # Product Requirements
197
+ └── tests/
198
+ ```
199
+
200
+ ## 기술 스택
201
+
202
+ - **Runtime**: Bun
203
+ - **Language**: TypeScript
204
+ - **Database**: SQLite + FTS5
205
+ - **Testing**: Vitest
206
+
207
+ ## 개발
208
+
209
+ ```bash
210
+ # 의존성 설치
211
+ bun install
212
+
213
+ # 개발 모드
214
+ bun run dev
215
+
216
+ # 테스트
217
+ bun test
218
+
219
+ # 빌드
220
+ bun run build
221
+ ```
222
+
223
+ ## 참고 자료
224
+
225
+ - [Ralph Loop - Geoffrey Huntley](https://ghuntley.com/ralph/)
226
+ - [claude-mem](https://github.com/thedotmack/claude-mem)
227
+ - [Inventing the Ralph Wiggum Loop (Podcast)](https://linearb.io/dev-interrupted/podcast/inventing-the-ralph-wiggum-loop)
228
+ - [The Brief History of Ralph](https://www.humanlayer.dev/blog/brief-history-of-ralph)
229
+
230
+ ## 라이선스
231
+
232
+ MIT