diff --git a/README.md b/README.md index 2cdf0f8..ec68b73 100644 --- a/README.md +++ b/README.md @@ -10,28 +10,36 @@ ``` claudeskill/ -├── .claude/ # Claude 配置目录 -│ └── skills/ # Skill 创建器引用 +├── .claude/ # Claude 配置目录(已安装的 Skills) +│ └── skills/ # Skills 创建器引用 │ ├── skill-creator/ # Skill 创建指南和工具 │ ├── excel-to-markdown/ # Excel 转 Markdown Skill -│ └── excel-report-converter/ # Excel 报表转换 Skill -├── scripts/ # 独立脚本目录 -│ ├── excel_to_markdown.py # Excel 转 Markdown 转换器 -│ └── report_to_db_format.py # 报表格式转数据库格式脚本 -├── skills/ # 开发中的 Skills -│ └── excel-report-converter/ # Excel 报表转换器 +│ ├── excel-report-converter/ # Excel 报表转换 Skill +│ └── minio-upload/ # MinIO 文件上传 Skill +├── demo_scripts/ # 演示脚本目录 +│ └── excel_to_markdown.py # Excel 转 Markdown 转换器 +├── skills/ # 开发中的 Skills(用于测试和版本控制) +│ ├── excel-to-markdown/ # Excel 转 Markdown Skill +│ ├── excel-report-converter/ # Excel 报表转换 Skill +│ └── minio-upload/ # MinIO 文件上传 Skill +├── temp/ # 临时文件目录 ├── .venv/ # Python 虚拟环境 +├── CLAUDE.md # Claude Code 项目指南 └── README.md # 本文档 ``` +**说明:** +- `.claude/skills/` - 已安装的 Skills,由 Claude Code 自动加载(被 gitignore) +- `skills/` - Skills 的开发版本,用于版本控制和协作 +- `demo_scripts/` - 可独立运行的脚本文件 + ## 目录说明 -### `scripts/` +### `demo_scripts/` 存放可独立使用的脚本文件,这些脚本可以被 Skills 引用。 **当前脚本:** - `excel_to_markdown.py` - 将 Excel 文件转换为 Markdown 表格格式 -- `report_to_db_format.py` - 将报表格式的 Excel 文件转换为数据库记录格式 ### `skills/` 存放已创建的 Skills,每个 Skill 都是一个独立的功能模块。 @@ -69,6 +77,31 @@ claudeskill/ - 创建自定义的 Excel 报表转换脚本 - 将层级报表数据(表头 + 明细行 + 表尾)转换为规范化数据库记录 +#### minio-upload +上传文件到 MinIO obsidian 桶的 Skill,支持灵活的路径配置。 + +**功能:** +- 上传任意文件到 MinIO 的 obsidian 桶 +- 支持自定义子路径(如 `notes/2024`, `archive/projects`) +- 默认上传到 `main` 路径 +- 自动处理路径规范化和文件名附加 +- 完善的错误处理和验证 + +**使用场景:** +- 快速上传 Markdown 文档到云存储 +- 按年份/分类组织文件 +- 备份文件到 MinIO +- 批量上传文件到指定路径 + +**示例:** +```bash +# 上传到默认 main 路径 +.claude/skills/minio-upload/scripts/upload_to_obsidian.sh file.md + +# 上传到自定义子路径 +.claude/skills/minio-upload/scripts/upload_to_obsidian.sh file.md "notes/2024" +``` + ## 工作流程 ### 1. 创建新 Skill @@ -100,7 +133,7 @@ python3 .claude/skills/skill-creator/scripts/init_skill.py --path s ```bash # 测试 Excel 转 Markdown -python3 scripts/excel_to_markdown.py demo.xlsx -o demo.md --show-rows --show-cols +python3 demo_scripts/excel_to_markdown.py demo.xlsx -o demo.md --show-rows --show-cols ``` ### 4. 打包 Skill(当用户主动要求才打包) @@ -164,7 +197,7 @@ python3 .claude/skills/skill-creator/scripts/init_skill.py excel-to-markdown --p ### 步骤 2:添加脚本 ```bash -cp excel_to_markdown.py skills/excel-to-markdown/scripts/ +cp demo_scripts/excel_to_markdown.py skills/excel-to-markdown/scripts/ ``` ### 步骤 3:编写 SKILL.md diff --git a/skills/minio-upload/SKILL.md b/skills/minio-upload/SKILL.md new file mode 100644 index 0000000..4b15d94 --- /dev/null +++ b/skills/minio-upload/SKILL.md @@ -0,0 +1,59 @@ +--- +name: minio-upload +description: Upload files to MinIO obsidian bucket with configurable path support. Use when the user asks to upload files to MinIO, transfer to obsidian bucket specifically, upload markdown or other files to cloud storage, or specify custom subpaths within obsidian bucket +--- + +# MinIO Upload + +Upload files to the MinIO obsidian bucket with flexible path configuration. + +## Quick Start + +Upload a file to the default `main` path: +```bash +.claude/skills/minio-upload/scripts/upload_to_obsidian.sh path/to/file.md +``` + +Upload to a custom subpath: +```bash +.claude/skills/minio-upload/scripts/upload_to_obsidian.sh path/to/file.md "notes/2024" +``` + +## Workflow + +1. **Verify file exists** - Check that the source file is accessible +2. **Determine target path** - Use specified subpath or default to `main` +3. **Upload with mc** - Execute `mc cp` command to transfer file +4. **Confirm success** - Verify upload completed and report target location + +## Path Configuration + +The script accepts an optional subpath argument: + +- **Default**: Files upload to `minio/obsidian/main/` +- **Custom subpath**: Specify any subpath (e.g., `notes/2024`, `archive/old projects`) +- **Nested paths**: Multi-level paths are supported (e.g., `notes/personal/journal`) + +The script automatically: +- Appends the filename to the target path +- Normalizes multiple slashes in paths +- Uses the `minio` alias configured in mc + +## Error Handling + +The script will: +- Exit with error if file doesn't exist +- Exit with error if no file argument provided +- Propagate any mc command failures + +## Resources + +### scripts/upload_to_obsidian.sh + +Bash script that handles the upload process. Validates inputs, constructs the target path, and executes the mc copy command. + +**Key features:** +- Default to `main` path when no subpath specified +- Support nested subpaths with proper path normalization +- Clear error messages for invalid inputs +- Success confirmation with source and target paths diff --git a/skills/minio-upload/scripts/upload_to_obsidian.sh b/skills/minio-upload/scripts/upload_to_obsidian.sh new file mode 100755 index 0000000..e3ee77c --- /dev/null +++ b/skills/minio-upload/scripts/upload_to_obsidian.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Upload files to MinIO obsidian bucket +# Usage: upload_to_obsidian.sh [subpath] +# +# Arguments: +# file_path - Path to the file to upload +# subpath - Optional subpath within obsidian bucket (default: main) +# +# Examples: +# upload_to_obsidian.sh temp/file.md +# upload_to_obsidian.sh temp/file.md notes/2024 +# upload_to_obsidian.sh temp/file.md "archive/old projects" + +set -e + +# Check arguments +if [ $# -lt 1 ]; then + echo "Usage: $0 [subpath]" >&2 + exit 1 +fi + +FILE_PATH="$1" +SUBPATH="${2:-main}" # Default to 'main' if not specified + +# Validate file exists +if [ ! -f "$FILE_PATH" ]; then + echo "Error: File '$FILE_PATH' does not exist" >&2 + exit 1 +fi + +# Get filename +FILENAME=$(basename "$FILE_PATH") + +# Construct target path +TARGET_PATH="minio/obsidian/${SUBPATH}/${FILENAME}" + +# Ensure subpath ends without trailing slash for mc +TARGET_PATH=$(echo "$TARGET_PATH" | sed 's://*:/:g') + +# Upload file +mc cp "$FILE_PATH" "$TARGET_PATH" + +echo "✅ Uploaded: $FILE_PATH -> $TARGET_PATH"