feat(kebab-app): p9-fb-25 task 3 — init_workspace header lists supported extensions

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-05 11:55:38 +00:00
parent ef5d0770ae
commit d64282433c
2 changed files with 42 additions and 0 deletions

View File

@@ -146,6 +146,14 @@ pub fn init_workspace(force: bool) -> anyhow::Result<()> {
# — relative paths resolve against the directory of THIS
# config file, NOT the user's `cwd` at invocation time.
#
# 처리 가능한 형식 (extractor 가 자동 결정 — config 에 명시할 수 없음):
# • Markdown: .md
# • 이미지: .png .jpg .jpeg (OCR + caption)
# • PDF: .pdf
# 다른 확장자는 ingest 시 자동 skip + warning. 처리 대상 폴더의
# 일부만 ingest 하고 싶으면 `kebab ingest <path>` 로 root 명시
# 또는 `.kebabignore` 파일 / 본 `workspace.exclude` 로 denylist.
#
# Override individual keys at runtime with `KEBAB_*` env vars
# (e.g. `KEBAB_WORKSPACE_ROOT=/tmp/test kebab ingest`).
\n";

View File

@@ -0,0 +1,34 @@
//! p9-fb-25 task 3: `kebab init` produces config.toml with a header
//! comment listing the four supported extensions (md / png / jpg+jpeg
//! / pdf) so a user editing the config knows what's processable.
#[test]
fn init_workspace_header_lists_supported_extensions() {
let tmp = tempfile::tempdir().expect("tempdir");
// SAFETY: Rust 2024 marks set_var as unsafe — wrap in unsafe block.
// Each test sets process-wide XDG_CONFIG_HOME to point at the
// tempdir; init_workspace writes config.toml relative to it.
unsafe {
std::env::set_var("XDG_CONFIG_HOME", tmp.path());
// Same dir for data + cache to avoid touching real user paths.
std::env::set_var("XDG_DATA_HOME", tmp.path().join("data"));
std::env::set_var("XDG_CACHE_HOME", tmp.path().join("cache"));
std::env::set_var("XDG_STATE_HOME", tmp.path().join("state"));
}
kebab_app::init_workspace(true).expect("init_workspace");
let cfg_path = kebab_config::Config::xdg_config_path();
let body = std::fs::read_to_string(&cfg_path).unwrap_or_else(|e| {
panic!("read config at {}: {e}", cfg_path.display())
});
assert!(
body.contains("처리 가능한 형식"),
"header lists supported types section: body=\n{body}"
);
assert!(body.contains("Markdown: .md"), "md listed");
assert!(body.contains(".png .jpg .jpeg"), "image extensions listed");
assert!(body.contains("PDF: .pdf"), "pdf listed");
assert!(
!body.contains("workspace.include"),
"no leftover include reference"
);
}