Spaces:
Running
Running
feat: add GitHub project import + fix Agent tab scroll (shallow clone, heavy-dir stripping, /github slash command, UI box)
873734c verified A newer version of the Gradio SDK is available: 6.19.0
metadata
name: github
description: Import a GitHub repository into the workspace so the agent can edit it
argument-hint: <github-url> [subdir] [--branch <name>] [--into <path>]
allowed-tools: >-
read_file, write_file, edit_file, multi_edit, list_dir, glob, grep, bash,
todo_read, todo_write, todo_update
GitHub Import Command
The user invoked /github with arguments: $ARGUMENTS
Parse the arguments
The argument string after /github is $ARGUMENTS. Parse it as:
- A required GitHub URL (first token starting with
https://github.com/orgit@github.com:). - An optional subdir β the second positional token if it doesn't start with
--. - Optional flags:
--branch <name>β checkout this branch/tag instead of the URL's default.--into <path>β place the import under<path>/inside the workspace instead of the root.--depth <N>β git clone depth (default 1).--timeout <s>β clone timeout in seconds (default 120).
Execute the import
Use the bash tool to call the Python helper directly:
python -c "from code.tools.github import import_github_repo; import json; print(json.dumps(import_github_repo(url='<URL>', branch='<BRANCH>', subdir='<SUBDIR>', target_subdir='<INTO>', depth=<DEPTH>, timeout=<TIMEOUT>), default=str))"
(Quote arguments correctly; if any are empty, pass the empty string.)
If the bash tool is unavailable, use write_file to drop a small script and then run it with bash.
After the import
- Read the JSON output of the command above.
- If
successistrue:- Use
list_diron the workspace root (or the--intopath) to confirm what landed. - Read the top-level files you expect to find:
README.md,package.json,requirements.txt,pyproject.toml,app.py,index.htmlβ whichever exist. - Summarize for the user:
- Repo imported:
owner/repo(branch: X) - Files imported: N
- Heavy dirs stripped: M
- Workspace location:
path/ - A 5-10 line preview of what's in the workspace now.
- Repo imported:
- Suggest next steps based on the project type (e.g. "Want me to add tests? Modernize the build? Add a Dockerfile?").
- Use
- If
successisfalse:- Surface the
messageto the user verbatim. - If the error mentions
subdir_not_found, list the top-level directories of the repo (you can re-run the import with--depth 1and no subdir to discover what's there, or usegit ls-treevia bash). - If the error mentions
git binary not found, tell the user git must be installed in the SoniCoder runtime.
- Surface the
Examples the user might type
/github https://github.com/fastapi/fastapi/github https://github.com/vercel/next.js examples/with-typescript --into next-ts-demo/github https://github.com/pallets/flask --branch 2.3.x/github git@github.com:owner/repo.git
Rules
- NEVER push to or modify the upstream repo. The clone is local-only and stripped of
.git. - NEVER include secrets, API keys, or
.envfiles in your summary β if you spot any, warn the user. - If the workspace already has files, warn the user that the import will overwrite the destination directory before running.