KeiSeiKit-1.0/skills/drive-import/SKILL.md
Parfii-bot 036bc6a52e docs: SKILL.md triggers + STATUS-TRUTH footer + phase placeholders
Group G — markdown tech-debt cleanup (post-audit 2026-05-02).

- 36 SKILL.md files: added "## When to use" section. Was missing across the
  catalog; orchestrator routing by keyword could not auto-dispatch.

- 20 code-implementer agent .md files: added Output Footer block prescribing
  RULE 0.16 STATUS-TRUTH MARKER schema in agent's final report. Previously only
  code-implementer-rust.md had it; other 27 language/role variants were silent
  about the marker, breaking RULE 0.16 §3 status-truth aggregation for non-Rust
  batches.

- skills/site-create/: added phase-5-preview.md and phase-6-deploy.md skeleton
  files. SKILL.md table-of-contents referenced 7 phases; only 5 existed on disk.

- skills/{ai-animation,rag-pipeline}/skill.md: added migration banner comment
  noting they should be SKILL.md (canonical filename). Case-rename via git is a
  separate orchestrator task (macOS APFS is case-insensitive; Linux deploy needs
  explicit rename).

- 3 deprecated skills (site-builder, competitor-analysis, design-inspiration):
  added concrete removed-after dates (was vague "before v2").

- docs/CONVERGENCE-PLAN.md:129: TBD on _blocks/evidence-grading.md duplicate
  resolved (file exists, not duplicated).

- docs/DNA-INDEX.md: count edits made then overwritten by auto-encyclopedia-refresh
  hook during agent run. The .kei-registry-ignore files in test fixtures (Group F)
  are the structural fix; kei-registry walker implementation is the follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 21:41:41 +08:00

95 lines
4.4 KiB
Markdown

---
name: drive-import
description: Import one or more Google Drive folders as private repos into the local Forgejo dev-hub. Wraps the kei-drive-import bash wizard. Click-only path-picker, optional --scan auto-discover. Requires rclone OAuth (one-time) + Wave 45 dev-hub Forgejo running.
argument-hint: (optional) "drive:path/to/folder"
---
# /drive-import — Google Drive → Forgejo project import
## When to use
- Importing one or more Google Drive folders as private repos into a local Forgejo dev-hub.
- Auto-discovering and classifying Drive project folders via `--scan` before import.
- Migrating Drive-based project archives to version-controlled Forgejo repos.
Bridge to the kei-drive-import wizard. Two modes:
| Mode | When | How |
|---|---|---|
| **explicit** (default) | user knows the folder paths | one or more `drive:path/...` strings |
| **scan** | user wants auto-discover | `--scan drive:Projects/` walks + classifies + asks |
## Pre-flight (run once, idempotent)
1. `./install.sh --profile=full-hub --yes` — installs Forgejo + rclone + gitleaks, auto-creates admin user `$USER` with random password (Keychain `forgejo-admin-password`) and access token (Keychain `forgejo-api-token`), stamps `~/.claude/secrets/.env` with `KEI_FORGEJO_USER`, `KEI_FORGEJO_URL`, `KEI_DRIVE_REMOTE`, `RCLONE_CONFIG`. Implementation: [`install/lib-dev-hub-forgejo.sh::_dhf_bootstrap_admin_user`](../install/lib-dev-hub-forgejo.sh).
2. `rclone --config ~/.config/rclone/rclone.conf config` — interactive OAuth, scope `drive.readonly`, remote name `gdrive`. One-time browser click on "Allow".
## Pipeline — what happens per folder
```
classify (kei-gdrive-import classify --remote) → MUST not be ALREADY-REPO
rclone copy (frozen flag block: --drive-skip-gdocs --drive-skip-shortcuts +
7 OS-junk excludes + --tpslimit 10 --checksum) → /tmp/staging/
size + extension histogram (>50% .pdf or >30% media → user prompt)
gitleaks dir --no-banner --redact → exit non-zero = BLOCKED-SECRETS
language-aware .gitignore (SHA-pinned to github/gitignore@5763345…)
git init -b main + commit "Import from Drive: <name>"
POST /api/v1/user/repos {auto_init:false, private:true} (Basic auth, token from Keychain)
git remote add origin "${FORGEJO_URL}/${FORGEJO_USER}/<name>.git"
allowlist guard: case "$origin_url" in "${FORGEJO_URL}/"*) — derived from env
git -c http.extraHeader="Authorization: Basic <b64>" push -u origin main
ledger CSV row: timestamp,name,status,forgejo_url,staging_path
```
Status enum: `OK / SKIPPED-ALREADY-REPO / BLOCKED-SECRETS / BLOCKED-FORGEJO / FAILED-RCLONE / FAILED-PUSH`.
## Invocation
When user says "import these folders from drive" / "пилотную папку из Google Drive в форджео":
1. Ask user for one or more `drive:path` strings (use AskUserQuestion if more than one).
2. Run: `kei-drive-import "drive:path1" "drive:path2"`
3. Report: how many OK, how many SKIPPED, how many BLOCKED, ledger path.
For batch import, write a paths file:
```
drive:projects/A
drive:Work/clientB
# comments OK, blank lines OK
drive:foo/bar
```
Then: `kei-drive-import --paths-from list.txt`.
## Failure modes — diagnose
| Symptom | Cause | Fix |
|---|---|---|
| `RCLONE_CONFIG not set` | first install never ran preflight | `cat ~/.claude/secrets/.env.example | grep RCLONE_CONFIG` → copy to live `.env` |
| `remote 'gdrive:' missing` | OAuth not done | `rclone config` (one-time browser click) |
| `Forgejo not reachable` | dev-hub daemon down | `launchctl load ~/Library/LaunchAgents/com.keisei.forgejo.plist` |
| `BLOCKED-SECRETS` | gitleaks found AKIA / GitHub PAT / PEM key | edit fixture or `git rm` the leak in staging, then re-run |
| `REJECTED: remote not allowlisted` | `KEI_FORGEJO_URL` mismatch between env and actual URL | sync `.env` |
## Don't
- Don't try `--scan` on a 10k-folder root — preflight enumerates gdocs first which is slow
- Don't pass paths with trailing slash — wizard normalises but use `drive:foo` not `drive:foo/`
- Don't manually push to github after import — `tools/sync-public.sh` is the public-mirror channel
## See also
- Wizard source: `_templates/drive-import-wizard.sh.tmpl`
- Rust scorer: `_primitives/_rust/kei-gdrive-import/src/`
- Install lib: `install/lib-dev-hub-gdrive-import.sh`
- Integration tests: `tests/gdrive_import_integration.sh` (7/8 PASS, 1 graceful skip)
- Plan + audit history: `tasks/kei-gdrive-import/PLAN.md`