packx
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePACKX - AI Context Bundler
PACKX - AI上下文打包工具
Bundle and filter code files for AI context.
为AI上下文打包并过滤代码文件。
CRITICAL: Always Use --limit 49k
--limit 49k重要提示:请始终使用--limit 49k
--limit 49kMANDATORY: Every packx command MUST include unless the user explicitly requests a different limit. This is non-negotiable. Using 49k instead of 50k provides a safety buffer.
--limit 49kbash
undefined强制要求:所有packx命令必须包含,除非用户明确要求其他限制。这一点没有商量余地。使用49k而非50k是为了留出安全缓冲空间。
--limit 49kbash
undefinedCORRECT - always include --limit 49k
正确示例 - 始终包含--limit 49k
packx --limit 49k -c src/
packx --limit 49k -s "pattern" -i "*.ts" -c
packx --limit 49k -c src/
packx --limit 49k -s "pattern" -i "*.ts" -c
WRONG - never omit the limit
错误示例 - 绝不能省略限制参数
packx -c src/ # NO! Missing --limit
packx -s "pattern" -i "*.ts" -c # NO! Missing --limit
undefinedpackx -c src/ # 错误!缺少--limit
packx -s "pattern" -i "*.ts" -c # 错误!缺少--limit
undefinedPrerequisites
前置条件
bash
packx --version # Verify installed
npm install -g packx # If not installedbash
packx --version # 验证是否已安装
npm install -g packx # 若未安装则执行此命令Standard Command Pattern
标准命令格式
bash
packx --limit 49k [filters] [output] [paths]Always start with , then add filters and output options.
--limit 49kbash
packx --limit 49k [过滤参数] [输出参数] [路径]请始终以开头,然后添加过滤和输出选项。
--limit 49kCLI Reference
CLI参考
Token Budget (Required)
Token预算(必填)
bash
undefinedbash
undefinedStandard (default for all commands)
标准用法(所有命令的默认设置)
packx --limit 49k -c src/
packx --limit 49k -c src/
Only use different limits if user explicitly requests
仅当用户明确要求时才使用不同的限制
packx --limit 32k -c src/ # User said "32k"
packx --limit 128k -c src/ # User said "large context"
packx --limit 32k -c src/ # 用户要求"32k"
packx --limit 128k -c src/ # 用户要求"大上下文"
Split into chunks if content exceeds limit (requires -o for numbered files)
若内容超出限制则拆分块(需要使用-o参数生成编号文件)
packx -M 49k -o context src/ # Creates context-1.xml, context-2.xml
**Limit formats:** `8k`=8,000 | `32K`=32,768 | `50000`=50,000packx -M 49k -o context src/ # 生成context-1.xml, context-2.xml
**限制格式**:`8k`=8,000 | `32K`=32,768 | `50000`=50,000Search & Filter
搜索与过滤
bash
undefinedbash
undefinedFind files containing text
查找包含指定文本的文件
packx --limit 49k -s "TODO" -c
packx --limit 49k -s "useState" -i "*.tsx" -c
packx --limit 49k -s "error" -s "warning" -c
packx --limit 49k -s "TODO" -c
packx --limit 49k -s "useState" -i "*.tsx" -c
packx --limit 49k -s "error" -s "warning" -c
Exclude content
排除指定内容
packx --limit 49k -S "test" -S "mock" -c
packx --limit 49k -S "test" -S "mock" -c
Filter by glob patterns
按glob模式过滤
packx --limit 49k -i ".ts" -c
packx --limit 49k -i "src/**/.tsx" -c
packx --limit 49k -x ".test.ts" -x ".spec.ts" -c
packx --limit 49k -i ".ts" -c
packx --limit 49k -i "src/**/.tsx" -c
packx --limit 49k -x ".test.ts" -x ".spec.ts" -c
Regex patterns
正则表达式模式
packx --limit 49k -R -s "function\s+\w+" -c
packx --limit 49k -R -s "function\s+\w+" -c
Case-sensitive
区分大小写
packx --limit 49k -C -s "Error" -c
undefinedpackx --limit 49k -C -s "Error" -c
undefinedGit Integration
Git集成
bash
packx --limit 49k --staged -c # Staged files
packx --limit 49k --diff -c # Changed from main
packx --limit 49k --dirty -c # Modified/untrackedbash
packx --limit 49k --staged -c # 暂存区文件
packx --limit 49k --diff -c # 与main分支相比有变更的文件
packx --limit 49k --dirty -c # 已修改/未跟踪的文件Processing Options
处理选项
bash
undefinedbash
undefinedStrip comments (reduces tokens)
移除注释(减少Token数量)
packx --limit 49k --strip-comments -c src/
packx --limit 49k --strip-comments -c src/
Minify (remove empty lines)
压缩(移除空行)
packx --limit 49k --minify -c src/
packx --limit 49k --minify -c src/
Both (maximum token efficiency)
同时使用两者(最大化Token效率)
packx --limit 49k --strip-comments --minify -c src/
packx --limit 49k --strip-comments --minify -c src/
Context lines around matches
匹配内容的上下文行数
packx --limit 49k -s "TODO" -l 5 -c
packx --limit 49k -s "TODO" -l 5 -c
Follow imports
跟随导入关系
packx --limit 49k --follow-imports src/index.ts -c
packx --limit 49k --follow-imports src/index.ts -c
Related files (tests, stories)
关联文件(测试、Storybook文件)
packx --limit 49k -r src/utils.ts -c
undefinedpackx --limit 49k -r src/utils.ts -c
undefinedOutput Options
输出选项
bash
undefinedbash
undefinedCopy to clipboard (most common)
复制到剪贴板(最常用)
packx --limit 49k -c src/
packx --limit 49k -c src/
Save to file (use --stdout > to avoid WriteFile hook limits)
保存到文件(使用--stdout > 以避免WriteFile钩子的大小限制)
packx --limit 49k --stdout src/ > context.md
packx --limit 49k --stdout src/ > context.md
Output formats
输出格式
packx --limit 49k -f xml -c src/ # XML (default)
packx --limit 49k -f markdown -c src/ # Markdown
packx --limit 49k -f plain -c src/ # Plain text
packx --limit 49k -f jsonl -c src/ # JSONL
**IMPORTANT:** Always use `--stdout > <file>` instead of `--output <file>` to avoid triggering WriteFile hook size limits on large bundles.packx --limit 49k -f xml -c src/ # XML(默认格式)
packx --limit 49k -f markdown -c src/ # Markdown
packx --limit 49k -f plain -c src/ # 纯文本
packx --limit 49k -f jsonl -c src/ # JSONL
**重要提示**:请始终使用`--stdout > <file>`而非`--output <file>`,以避免在打包大文件时触发WriteFile钩子的大小限制。Preview (Check Before Packing)
预览(打包前检查)
bash
undefinedbash
undefinedPreview matching files without packing
预览匹配的文件但不执行打包
packx --limit 49k --preview src/
packx --limit 49k -s "pattern" --preview
undefinedpackx --limit 49k --preview src/
packx --limit 49k -s "pattern" --preview
undefinedInteractive Mode
交互模式
bash
packx --limit 49k -I src/ # Interactive selection
packx --limit 49k --no-interactive src/ # Scripting modeControls: Tab=preview focus | PgUp/PgDn=scroll | Enter=confirm
bash
packx --limit 49k -I src/ # 交互式选择
packx --limit 49k --no-interactive src/ # 脚本模式操作说明:Tab=切换预览焦点 | PgUp/PgDn=滚动 | Enter=确认
Bundles (Saved Configs)
打包配置(已保存的配置)
bash
packx -b api # Load .pack/bundles/apibash
packx -b api # 加载.pack/bundles/api配置Common Workflows
常见工作流
Default: Feature Context
默认:功能上下文
bash
undefinedbash
undefinedMost common - search for feature, copy to clipboard
最常用 - 搜索功能相关代码,复制到剪贴板
packx --limit 49k -s "auth" -i "*.ts" -c
undefinedpackx --limit 49k -s "auth" -i "*.ts" -c
undefinedPR Review Context
PR评审上下文
bash
packx --limit 49k --diff -c
packx --limit 49k --staged -f markdown --stdout > pr.mdbash
packx --limit 49k --diff -c
packx --limit 49k --staged -f markdown --stdout > pr.mdDebug Context
调试上下文
bash
packx --limit 49k --follow-imports src/problem.ts -c
packx --limit 49k -r src/problem.ts -c # Include testsbash
packx --limit 49k --follow-imports src/problem.ts -c
packx --limit 49k -r src/problem.ts -c # 包含测试文件Minimal Context (Max Efficiency)
最小化上下文(最高效率)
bash
packx --limit 49k --strip-comments --minify -i "*.ts" -c src/bash
packx --limit 49k --strip-comments --minify -i "*.ts" -c src/Specific Files
指定文件
bash
undefinedbash
undefinedList specific files directly
直接列出指定文件
packx --limit 49k src/auth.ts src/user.ts src/api.ts -c
undefinedpackx --limit 49k src/auth.ts src/user.ts src/api.ts -c
undefinedBest Practices
最佳实践
- ALWAYS use - No exceptions unless user specifies
--limit 49k - Use for clipboard - Most common output method
-c - Preview first - to check file selection
--preview - Strip noise - when token-tight
--strip-comments --minify - Be specific - Use search and
-sglobs to narrow scope-i - Check git state - and
--difffor PR context--staged
- 始终使用- 除非用户指定,否则无例外
--limit 49k - 使用复制到剪贴板 - 最常用的输出方式
-c - 先预览 - 使用检查文件选择是否正确
--preview - 移除冗余内容 - 当Token紧张时使用
--strip-comments --minify - 精准定位 - 使用搜索和
-sglob模式缩小范围-i - 检查Git状态 - 使用和
--diff获取PR上下文--staged
Troubleshooting
故障排除
| Problem | Solution |
|---|---|
| Too many tokens | Add |
| Missing files | Check globs, use |
| Over 49k needed | Split with |
| WriteFile hook error | Use |
| 问题 | 解决方案 |
|---|---|
| Token数量过多 | 添加 |
| 文件缺失 | 检查glob模式,使用 |
| 需要超过49k的上下文 | 使用 |
| WriteFile钩子错误 | 使用 |