gregpriday/copy-tree
最新稳定版本:0.6
Composer 安装命令:
composer require gregpriday/copy-tree
包简介
Copy a directory and its files to your clipboard.
关键字:
README 文档
README
Note: This tool is designed exclusively for MacOS and is not compatible with other operating systems.
Ctree is a command-line utility that effortlessly copies the structure and contents of a local directory or GitHub repository to your clipboard. It formats the output specifically for use with AI assistants such as Claude, ChatGPT, and Gemini, making it ideal for code analysis, generation, and sharing.
Features
-
MacOS Integration:
Seamless clipboard operations using native tools (pbcopyandosascript). -
GitHub Integration:
Clone and cache GitHub repositories via URL for fast, offline access and updates. -
AI-Powered Capabilities:
- Intelligent File Filtering:
Use natural language descriptions to select relevant files. - Smart Filename Generation:
Automatically generate clear, hyphenated filenames for saved output based on content analysis.
- Intelligent File Filtering:
-
Flexible Directory Management:
- Dynamic Ruleset System:
Configure inclusion/exclusion rules with a powerful JSON format. - Multiple Rulesets & Auto-detection:
Define custom rulesets (e.g.,frontend.json,backend.json) or let Ctree auto-detect settings for common project types (Laravel, SvelteKit, etc.).
- Dynamic Ruleset System:
-
Versatile Output Options:
- Copy directly to the clipboard.
- Save output to a file (with AI-generated names if desired).
- Display output in the console.
- Stream output for piping.
- Copy a reference to a temporary file (to work around clipboard limitations).
Prerequisites
- MacOS
- PHP 8.2 or higher
- Git (required for GitHub repository support)
- Composer
Installation
-
Install via Composer (globally):
composer global require gregpriday/copy-tree
-
Add Composer’s Global Bin to Your PATH:
Edit your~/.zshrcor~/.bashrcand add:export PATH="$PATH:$HOME/.composer/vendor/bin"
-
(Optional) Configure AI Features:
Create a.envfile in~/.copytree/and add your OpenAI credentials:OPENAI_API_KEY=your-api-key OPENAI_API_ORG=your-org-id
Replace
your-api-keyandyour-org-idwith your actual values.
Quick Start
-
Copy the Current Directory:
ctree
-
Copy from a GitHub Repository:
ctree https://github.com/username/repo/tree/main/src
-
Use AI to Filter Files:
ctree --ai-filter="Find all authentication related files"
Workflows
Ctree is designed to integrate into various development processes. Detailed workflows are available for:
-
AI-Driven Design Workflow:
Iterate on web designs with SvelteKit, Tailwind CSS, and Claude. -
AI-Assisted Development Workflow:
Leverage AI for test-driven development, code generation, and managing large codebases. -
AI-Assisted Ruleset Creation Workflow:
Create and refine JSON-based rulesets with AI support. -
AI-Powered Business Plan Development:
Develop comprehensive business plans with in-depth market research and operational documentation.
Advanced Usage
GitHub Integration
Ctree caches GitHub repositories in ~/.copytree/cache for improved performance.
# Copy a specific branch or directory from GitHub ctree https://github.com/username/repo/tree/develop/src # Clear the cache ctree --clear-cache # Bypass the cache ctree https://github.com/username/repo --no-cache
AI Features
Intelligent File Filtering
Filter files using natural language:
# Interactive mode (prompts for a description) ctree --ai-filter # Provide a filtering description directly ctree --ai-filter="Show me all test files for the authentication system"
For more details, see AI Features Documentation.
Smart Filename Generation
Automatically generate descriptive filenames when saving output:
ctree --output
Output Options
-
Display in Console:
ctree --display -
Save to File (AI-generated name):
ctree --output -
Specify Output File:
ctree --output=my-output-file.txt -
Stream Output (for piping):
ctree --stream -
Copy as Reference (temporary file):
ctree --as-reference
Git Filtering
Focus on changes with Git-based options:
# Only include files modified since the last commit ctree --modified # Filter files changed between specific commits ctree --changes=abc123:def456
These options are ideal for sharing recent changes or reviewing specific updates.
Ruleset System
Ctree’s flexible ruleset system lets you precisely control file selection:
-
Configuration:
Ctree creates a.ctreedirectory in your project to store ruleset configurations. -
Multiple Named Rulesets:
Define and use custom rulesets (e.g.,frontend.json,backend.json). -
Auto-detection:
Ctree auto-selects appropriate rulesets for recognized project types (e.g., Laravel, SvelteKit).
To use a custom ruleset, run:
ctree --ruleset=my-ruleset
For more details, see:
Directory Structure
Ctree uses the following directory structure for configuration and output:
~/.copytree/
├── .env # OpenAI configuration (if using AI features)
├── cache/ # GitHub repository cache
│ └── repos/
└── files/ # Generated output files (when using --output)
Contributing
Contributions are welcome! Please note that this project is MacOS-only. To contribute:
- Fork the repository.
- Create a feature branch.
- Make your changes.
- Submit a pull request.
Testing
Run the tests with:
composer test
Security
If you discover any security issues, please email greg@siteorigin.com rather than using the issue tracker.
License
This project is licensed under the MIT License. See LICENSE.md for details.
gregpriday/copy-tree 适用场景与选型建议
gregpriday/copy-tree 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 05 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「gregpriday」 「copy-tree」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gregpriday/copy-tree 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gregpriday/copy-tree 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-06