메뉴
HN
Hacker News 50일 전

이맥스(Emacs)용 AI 페어 프로그래머 공개

IMP
6/10
핵심 요약

해커뉴스에 Emacs 기반 AI 코딩 튜터 패키지인 'CodeTutor'가 공개되었습니다. 이 도구는 로컬 AI를 활용해 파일 저장 시 코드를 리뷰하고 실무자 관점의 피드백을 제공하지만, 사용자의 직접적인 성장을 위해 소스코드를 직접 수정해주지는 않는 것이 특징입니다. 개발자가 코딩을 주도하고 AI는 멘토링을 담당하는 형태로, 개인 환경에서의 학습과 코드 품질 향상에 유용하게 쓰일 수 있습니다.

번역된 본문

CodeTutor

CodeTutor는 코딩을 하면서 함께 배울 수 있도록 도와주는 Emacs 패키지입니다. 화면 우측에 튜터 패널을 열고, 파일 저장을 감지하여 프로젝트의 맥락을 수집한 뒤, 수석 엔지니어나 테크 리더급 페어 프로그래밍 튜터처럼 답변하는 로컬 AI 어시스턴트에게 질문합니다.

중요한 경계: CodeTutor는 사용자가 직접 코드를 작성하도록 '도와줍니다'. 대신 프로젝트 파일을 자동으로 작성해주지는 않습니다.

할 수 있는 것:

  • 저장 후 변경된 사항 리뷰
  • 피드백 배경에 있는 개념 설명
  • 간결하고 이해하기 쉬운 코드 샘플 제공
  • 다음 단계로 가장 좋은 방법 추천
  • 미니버퍼 프롬프트에 답변
  • 최근 대화 내용을 바탕으로 후속 질문에 답변
  • .codetutor/ARCHITECTURE.md 파일에 지속적인 아키텍처 노트 보관

하지 않는 것:

  • 소스 파일 직접 편집
  • 패치(Patch) 생성
  • 파일 전체 내용 교체
  • 당장 복사해서 붙여넣을 수 있는 완성된 구현체 제공

현재 상태 이 패키지는 초기 로컬 패키지입니다. 기본 Emacs 및 Doom Emacs 환경에서 작동하도록 설계되었으며, 로컬 'codex' 및 'pi' 백엔드를 사용합니다.

요구 사항

  • Emacs 28.1 이상
  • 선택 사항이지만 Emacs 29 이상의 내장 tree-sitter 지원 권장
  • 로컬 백엔드 중 하나: codex 또는 pi
  • tree-sitter를 사용할 수 없는 환경에서는 imenu를 최대한 활용하여 기능이 부드럽게 저하(gracefully degrades)됩니다.

설치 방법

Stock Emacs

(add-to-list 'load-path "/Users/jacobwindle/Projects/codetutor")
(require 'codetutor)
(setq codetutor-backend 'auto)
(codetutor-mode 1)

Doom Emacs 로컬 패키지를 추가합니다 (~/.config/doom/packages.el):

(package! codetutor :recipe (:local-repo "~/Projects/codetutor"))

패키지를 설정합니다 (~/.config/doom/config.el):

(use-package! codetutor
  :commands (codetutor-open codetutor-what-next codetutor-ask codetutor-follow-up codetutor-refresh-architecture-memory)
  :init
  (setq codetutor-backend 'auto
        codetutor-open-on-enable nil
        codetutor-start-session-on-open t
        codetutor-review-on-save t)
  :config
  (codetutor-mode 1))

이후 터미널에서 ~/.config/emacs/bin/doom sync를 실행하고 Emacs를 재시작합니다.

명령어

  • codetutor-mode (단축키 없음): 전역 CodeTutor 훅(hooks)을 활성화/비활성화합니다.
  • codetutor-open (C-c t o): 사이드 패널을 열고 프로젝트 평가를 시작합니다.
  • codetutor-what-next (C-c t n): 가장 좋은 다음 단계를 묻습니다.
  • codetutor-ask (C-c t a): 현재 파일/프로젝트 맥락과 함께 미니버퍼에서 질문을 받아 답변합니다.
  • codetutor-follow-up (C-c t f): 이전 답변에 대해 최근 대화 내용을 바탕으로 후속 질문을 합니다.
  • codetutor-refresh-architecture-memory (C-c t m): 튜터에게 지속적인 아키텍처 노트를 새로고침하도록 요청합니다.

작동 방식 CodeTutor는 4가지 핵심 루프를 가지고 있습니다: 시작 평가, 저장 리뷰, 수동 프롬프트, 후속 질문.

시작 평가 (Startup Assessment) M-x codetutor-open을 실행하면, CodeTutor가 프로젝트의 루트를 감지하고 우측 패널을 엽니다. 프로젝트 맥락을 수집한 뒤 읽기 전용 백엔드 요청을 시작하며, 패널에 'Status: thinking'을 표시했다가 최종 튜터의 답변으로 교체합니다. 이 시작 답변은 어디서 시작해야 할지, 무엇을 먼저 배워야 할지, 코드를 작성하기 전에 어떤 엔지니어링적 판단이 중요한지 알려줍니다.

저장 리뷰 (Save Review) codetutor-modecodetutor-review-on-save가 활성화된 경우, Emacs 저장 시 다음과 같이 작동합니다: before-save-hook이 현재 디스크에 있는 파일을 읽고 저장이 정상적으로 이루어집니다. 이후 after-save-hook이 이전 내용과 방금 저장한 버퍼의 텍스트를 비교하여 통합 diff(차이점)를 만듭니다. CodeTutor는 이 diff와 프로젝트 맥락을 백엔드로 보내며, 사이드 패널에 'Status: thinking'을 표시한 뒤 최종 티칭 응답으로 교체합니다. 저장 리뷰는 diff의 크기에 비례하며, 튜터는 개념, 리스크, 아키텍처, 테스트 및 다음 한 단계에 집중합니다.

수동 프롬프트 (Manual Prompt) M-x codetutor-ask는 미니버프로부터 질문을 받습니다. 현재 파일의 tree-sitter 또는 imenu 개요, 프로젝트 맥락, 아키텍처 메모리, 파일 인덱스 및 최근 대화 내용이 포함됩니다. 지원되는 경우 백엔드는 읽기 전용 도구를 통해 다른 프로젝트 파일을 검사하거나 검색할 수도 있습니다.

후속 질문 (Follow-Up) M-x codetutor-follow-up은 이전 답변에 대한 질문을 던집니다. 사이드 패널에 프롬프트를 표시하지 않으며, 최근 대화 내용을 포함하므로 더 작은 단위의 코드를 보여달라거나 하는 심화 질문이 가능합니다.

원문 보기
원문 보기 (영어)
CodeTutor CodeTutor is an Emacs package for learning while you code. It opens a right-side tutor panel, watches file saves, gathers project context, and asks a local AI assistant to respond like a senior/staff engineer pair-programming tutor. The important boundary: CodeTutor helps you write the code. It does not write into your project files for you. It can: review what changed after a save explain the concept behind feedback show compact illustrative code samples recommend the best next step answer minibuffer prompts answer follow-up questions using recent conversation turns keep durable architecture notes in .codetutor/ARCHITECTURE.md It should not: edit your source files produce patches produce full-file replacements hand you a complete ready-to-paste implementation for the exact task Status This is an early local package. It is designed for stock Emacs and Doom Emacs, with local codex and pi backends. Requirements Emacs 28.1 or newer Optional but recommended: Emacs 29+ with built-in tree-sitter support One local backend: codex pi CodeTutor degrades gracefully when tree-sitter is not available by using imenu where possible. Install Stock Emacs ( add-to-list 'load-path " /Users/jacobwindle/Projects/codetutor " ) ( require 'codetutor ) ( setq codetutor-backend 'auto ) (codetutor-mode 1 ) Doom Emacs Add the local package: ; ; ~/.config/doom/packages.el (package! codetutor :recipe ( :local-repo " ~/Projects/codetutor " )) Configure it: ; ; ~/.config/doom/config.el (use-package! codetutor :commands (codetutor-open codetutor-what-next codetutor-ask codetutor-follow-up codetutor-refresh-architecture-memory) :init ( setq codetutor-backend 'auto codetutor-open-on-enable nil codetutor-start-session-on-open t codetutor-review-on-save t ) :config (codetutor-mode 1 )) Then run: ~ /.config/emacs/bin/doom sync Restart Emacs after syncing. Commands Command Keybinding What It Does codetutor-mode none Enables/disables global CodeTutor hooks. codetutor-open C-c t o Opens the side panel and starts a project assessment. codetutor-what-next C-c t n Asks for the single best next step. codetutor-ask C-c t a Prompts from the minibuffer with current file/project context. codetutor-follow-up C-c t f Asks a follow-up about the previous answer using recent turns. codetutor-refresh-architecture-memory C-c t m Asks the tutor to refresh durable architecture notes. How It Works CodeTutor has four core loops: startup assessment, save review, manual prompt, and follow-up. Startup Assessment When you run M-x codetutor-open , CodeTutor: Detects the project root. Opens a right-side panel. Gathers project context. Starts a read-only backend request. Replaces the panel with Status: thinking . Replaces that status with the final tutor answer. The startup answer should tell you where to begin, what to learn first, and what engineering judgment matters before writing code. Save Review When codetutor-mode and codetutor-review-on-save are enabled, CodeTutor hooks into Emacs saves: before-save-hook reads the current on-disk file. The save happens normally. after-save-hook compares the previous on-disk contents with the saved buffer text. CodeTutor builds a unified diff. CodeTutor sends the diff plus project context to the backend. The side panel shows Status: thinking . The side panel is replaced with the final teaching response. Save reviews are proportional to the diff. The tutor should focus on concept, risk, architecture, tests, and one next move. Manual Prompt M-x codetutor-ask prompts from the minibuffer. It includes: the current file tree-sitter or imenu outline project context architecture memory project file index recent conversation turns The backend may inspect/search other project files through read-only tools when supported. Follow-Up M-x codetutor-follow-up asks a question about the previous answer. It does not display the prompt in the side panel. Follow-ups include recent private conversation turns, so you can ask things like: Can you show me a smaller example? or: What would the test shape look like? The follow-up still includes current file and project context, so the tutor can connect the prior answer to where you are now. What Next M-x codetutor-what-next asks the tutor to inspect available context and recommend one best next step. This is useful when you are between implementation slices and want a senior engineer's judgment on what to do next. Architecture Memory The tutor is asked to include durable architecture observations in a fenced block: ``` codetutor-memory - Boundary: The editor integration owns context gathering; the backend owns tutoring. ``` CodeTutor extracts those lines and appends new ones to: .codetutor/ARCHITECTURE.md That memory file is the only project file CodeTutor writes automatically. Context Sources CodeTutor builds a prompt from several local sources. Source When Included Purpose PROJECT.md , Project.md , project.md Every request Product/project direction. spec/ Every request Specs, requirements, design notes. .codetutor/ARCHITECTURE.md Every request when present Durable project memory. Current file text Every request What you are actively editing. Tree-sitter summary Every request when available Syntax-level outline of the current buffer. Imenu summary Fallback when tree-sitter is unavailable Lightweight outline. Project file index Every request Helps the tutor decide what else to inspect. Diff since last save Save reviews The actual change being reviewed. Other open project buffers Save reviews Nearby work you already have open. Recent conversation turns Follow-ups and later prompts Continuity across questions. Open-buffer context is capped so a large Emacs session does not overwhelm the backend. Backends Codex The Codex backend uses codex exec non-interactively. It is configured with: read-only sandbox approval policy never ephemeral session no terminal color optional web search --output-last-message so the panel displays only the final answer The command is built roughly like this: codex \ --sandbox read-only \ --ask-for-approval never \ --search \ exec \ -C " $PROJECT_ROOT " \ --skip-git-repo-check \ --color never \ --ephemeral \ --output-last-message " $TEMP_FILE " \ - pi The pi backend uses non-interactive print mode with only read-only tools: pi --print --tools read,grep,find,ls It can inspect files, but should not write or edit them. Output Model The side panel is intentionally not a chat transcript. For every request, CodeTutor: Clears the panel. Shows Status: thinking . Runs the backend. Extracts the final answer. Clears the panel again. Shows only the answer. The panel should not show: your prompt text generated prompt metadata full project context file contents sent as context backend progress output CLI transcripts The tutor is asked to wrap visible answers in: < codetutor-answer > ... </ codetutor-answer > CodeTutor extracts that block when present and strips architecture memory blocks from the visible panel output. Teaching Posture The built-in prompt tells the tutor to: teach underlying concepts guide the user toward the solution ask useful questions give one concrete next move include compact code samples when they clarify the idea explain how to adapt examples instead of handing over final code avoid patches, full-file replacements, and complete ready-to-paste implementations Good CodeTutor output should feel like a senior engineer pairing with you, not like an autocomplete engine. Customization Common settings: ( setq codetutor-backend 'auto ) ; ; 'auto, 'codex, or 'pi ( setq codetutor-model nil ) ; ; nil uses backend default ( setq codetutor-window-width 84 ) ( setq codetutor-review-on-save t ) ( setq codetutor-enable-web-search t ) ( setq codetutor-include-open-buffers-on-save t ) Context limits: ( setq codetutor-max-project-context-bytes 80000 ) ( setq codetutor-max-current-file-bytes 50000 ) ( setq codetutor-max-diff-bytes 60000 ) ( setq codetutor-max-open-buffers 12 ) ( setq codetutor-max-open-buffer-bytes 20000 ) ( se