Generate AI-ready repository context with native AST compression, Git diffs/history, HTTPS inputs and exact o200k token counts.
./bin/moon-repomix /path/to/project.\bin\moon-repomix.exe "C:\path\to\project"moon update
moon run src/cmd/moon-repomix --release -- examples/demo -f md -o -moon run --target native scripts/install.mbtx "$HOME/.local"# 当前目录,默认输出 repomix-output.xml
moon-repomix
# 导出 Markdown;加 --compress 提取骨架
moon-repomix ./project -f md -o context.md
moon-repomix ./project --compress -f md -o structure.md
# 只选源码和 README,导出 JSON
moon-repomix ./project --include 'src/**,README.md' -f json -o context.json
# 检查单文档预算,或按每卷硬上限分卷
moon-repomix ./project --budget 12000
moon-repomix ./project --compress --split 12000 -f md -o review-parts
moon-repomix --webuiimport {
"Delthin/moon_repomix" @repomix,
}let runtime = @repomix.Runtime::load("/absolute/share/moon-repomix/o200k_base.tiktoken")
let options = @repomix.options("/absolute/project", style=@repomix.Style::Json, compress=true)
let result = @repomix.pack(options, runtime)
// result.text 是完整文档,result.tokens 是最终 token 数。
// result.document 提供规范模型;files / skipped / findings / security / budget 提供处理结果。pub(all) suberror CodeContextError {
InvalidCodeSpec
}pub(all) suberror PackError {
ConfigurationError
ContextTextError(String)
ContextSecurityFinding(String)
SelectionError
InputLimitExceeded(kind~ : String, limit~ : Int64)
ScanError
ResourceError
GitError
RemoteError
}pub(all) suberror TaskContextError {
InvalidTaskSpec
}pub struct CodeContextPlan {
status : String
text : String?
tokens : Int
bytes : Int
required_tokens : Int?
audit : Json
security : SecurityStatus
}pub struct CodeContextSpec {
max_tokens : Int
// private fields
}test "code context request example" {
let spec = @moon_repomix.CodeContextSpec::from_json({
"maxTokens": 4000,
"requests": [{ "path": "lib/response.js", "symbols": ["res.render"] }],
})
assert_eq(spec.max_tokens, 4000)
}pub(all) struct FileStats {
path : String
disk_bytes : Int
tokens : Int
original_tokens : Int
}pub struct PackResult {
document : Document
text : String
bytes : Int
tokens : Int
files : Array[FileStats]
skipped : Array[Skipped]
findings : Array[Finding]
security : SecurityStatus
budget : BudgetStatus
}pub struct PathExplanation {
path : String
eligible : Bool
status : String
stage : String
reason : String
origin : RuleOrigin?
finding_count : Int
finding_rules : Array[String]
}pub struct SelectionReport {
paths : Array[PathExplanation]
security : SecurityStatus
style : Style
candidate_count : Int
accepted_count : Int
read_bytes : Int64
max_files : Int
max_total_size : Int64
}pub struct TaskContextPlan {
status : String
text : String?
tokens : Int
bytes : Int
audit : Json
audit_text : String
audit_tokens : Int
audit_bytes : Int
security : SecurityStatus
}pub struct TaskContextSpec {
max_tokens : Int
// private fields
}fn options(directory : String, style? : Style, split_output? : SplitOutput, compress? : Bool, keep_full_patterns? : Array[String], header_text? : String, instruction_file_path? : String?, full_metadata? : Bool, file_summary? : Bool, directory_structure? : Bool, include_files? : Bool, git_sections? : Bool, metadata? : Bool, show_line_numbers? : Bool, output_file_path_style? : PathStyle, file_paths? : Array[String]?, include_diffs? : Bool, include_logs? : Bool, include_logs_count? : Int, remote? : String?, remote_branch? : String?, max_files? : Int, max_total_size? : Int64) -> Options raiseasync fn plan_task_context(options : Options, runtime : Runtime, spec : TaskContextSpec) -> TaskContextPlanasync fn read_code_context(options : Options, runtime : Runtime, spec : CodeContextSpec) -> CodeContextPlanInstall
Download zipGenerate AI-ready repository context with native AST compression, Git diffs/history, HTTPS inputs and exact o200k token counts.