Skip to content

feat: add prompt template system#2

Merged
Chanki-Min merged 9 commits intomainfrom
feat/prompt-template
Mar 6, 2026
Merged

feat: add prompt template system#2
Chanki-Min merged 9 commits intomainfrom
feat/prompt-template

Conversation

@Chanki-Min
Copy link
Copy Markdown
Owner

Summary

  • EJS와 유사한 {{변수}} 치환 방식의 프롬프트 템플릿 기능 추가
  • 글로벌 템플릿 + 레포별 오버라이드 지원 ({{global}}로 삽입 또는 생략하여 완전 오버라이드)
  • repos config에서 string | { path, promptTemplate? } 형태 지원 (하위 호환)
  • 내장 기본 템플릿(templates/default.txt)으로 미설정 시 기존 동작 유지

Changes

  • templates/default.txt — 내장 기본 템플릿 ({{thread}}{{prompt}})
  • src/prompt/template.ts — 템플릿 로딩, 변수 치환, buildPrompt() 파이프라인
  • src/config.tspromptTemplate 필드, repos object 형태 지원
  • src/slack/handler.tsbuildPrompt() 연동, resolveRepoPath{ repoName, repoPath } 반환
  • README 한/영 — 프롬프트 템플릿 문서 추가

Variables

Variable Description
{{prompt}} 사용자 입력 메시지
{{thread}} 스레드 대화 컨텍스트
{{repo}} 레포 이름
{{global}} 글로벌 템플릿 렌더링 결과 (레포별 템플릿에서만 의미)

Test plan

  • 67개 기존 + 신규 테스트 전부 통과
  • 글로벌 템플릿 파일 설정 후 실제 Slack 봇 테스트
  • 레포별 오버라이드 + {{global}} 삽입 동작 확인
  • 템플릿 미설정 시 기존 동작과 동일한지 확인

🤖 Generated with Claude Code

Chanki-Min and others added 9 commits March 6, 2026 09:43
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…oPath

- Replace existsSync+readFileSync with try/catch readFileSync in loadTemplate
- resolveRepoPath now returns { repoName, repoPath } to eliminate
  duplicated fallback logic in handler call sites

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Restore thread context prefix/separator in fetchThreadContext
- Restrict tilde expansion to ~/ only (not ~user)
- Add config validation: fail-fast on missing template files, require
  path in object repo config
- trimEnd() rendered templates to handle trailing newlines in files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Combine buildPrompt template system with session continuity (--resume).
When resuming a session, threadContext is passed as empty to buildPrompt
so the template still wraps the prompt but skips thread history.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Chanki-Min Chanki-Min merged commit 2462f41 into main Mar 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant