Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions .cursor/commands/search-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@

Usage: `/search-docs <query>`

Prefer source + gate first (MCP is opt-in; `.cursor/mcp.json` is empty):

- `src/diffusers/schedulers/scheduling_euler_discrete.py`
- `src/diffusers/schedulers/scheduling_ddpm.py`
- `ramp-kit/conventions/rules.yaml`

Then, optional CLI (same server as MCP, no OAuth):
Prefer `ramp-kit/conventions/rules.yaml` + the gate. MCP is stdio
`diffusers-docs` (Cloud dropdown: `diffusers-docs-mcp`). No Hub HTTP.

```bash
python3 ramp-kit/tools/docs_mcp_server.py --query $1
Expand All @@ -20,5 +15,4 @@ If `$1` is empty:
python3 ramp-kit/tools/docs_mcp_server.py --query "scheduler set_timesteps step SchedulerMixin register_to_config"
```

Provenance should say `diffusers checkout`, not `bundled snapshot`. If the
MCP tool `search_docs` is in your list, call that instead.
If the MCP tool `search_docs` is in your list, call that instead.
3 changes: 2 additions & 1 deletion .cursor/environment.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"install": "if [ ! -d ramp-kit/.git ]; then git clone --depth 1 https://github.com/alex-16moro/diffuser_agent.git ramp-kit; fi && pip install -r ramp-kit/requirements.txt && python3 ramp-kit/tools/docs_mcp_server.py --selftest",
"install": "if [ ! -d ramp-kit/.git ]; then git clone --depth 1 https://github.com/alex-16moro/diffuser_agent.git ramp-kit; fi && pip install -r ramp-kit/requirements.txt && bash ramp-kit/.cursor/install-docs-mcp.sh && python3 ramp-kit/tools/docs_mcp_server.py --selftest",
"start": "bash ramp-kit/.cursor/install-docs-mcp.sh",
"repositoryDependencies": [
"github.com/alex-16moro/diffuser_agent"
]
Expand Down
42 changes: 35 additions & 7 deletions .cursor/mcp-diffusers-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"""Launch diffusers-docs MCP from any cwd.

Cloud Agent stdio cannot set `cwd` and does not expand `${workspaceFolder}`.
This launcher walks cwd, git root, /workspace, and its own path until it finds
`tools/docs_mcp_server.py`, then execs it. Desktop and Cloud then share one
command: `python3 -u .cursor/mcp-diffusers-docs.py`.
The dashboard command is often `python3 -u .cursor/mcp-diffusers-docs.py`,
spawned from the workspace root (e.g. `/agent`), not the git repo. This
launcher walks cwd, git root, `/agent/repos/*`, `/workspace`, and its own
path until it finds `tools/docs_mcp_server.py`, then execs it.

Desktop and Cloud share: `python3 -u .cursor/mcp-diffusers-docs.py`.
Cloud PATH fallback after install: `diffusers-docs-mcp`.
"""
from __future__ import annotations

Expand All @@ -14,6 +18,17 @@
from pathlib import Path


def _children(base: Path):
try:
if not base.is_dir():
return
for child in base.iterdir():
if child.is_dir():
yield child
except OSError:
return


def _candidates():
out: list[Path] = []
here = Path(__file__).resolve().parent
Expand All @@ -25,7 +40,19 @@ def _candidates():
val = os.environ.get(key)
if val:
out.append(Path(val))
out.append(Path("/workspace"))
out.append(Path(val) / "ramp-kit")
for base in (
Path("/agent"),
Path("/agent/repos"),
Path("/workspace"),
Path("/workspace/repos"),
here.parent / "repos",
cwd / "repos",
):
out.append(base)
for child in _children(base):
out.append(child)
out.append(child / "ramp-kit")
try:
top = subprocess.check_output(
["git", "rev-parse", "--show-toplevel"],
Expand All @@ -34,6 +61,7 @@ def _candidates():
).strip()
if top:
out.append(Path(top))
out.append(Path(top) / "ramp-kit")
except (OSError, subprocess.CalledProcessError):
pass
seen: set[Path] = set()
Expand All @@ -55,12 +83,12 @@ def main(argv: list[str] | None = None) -> int:
if script.is_file():
os.chdir(root)
sys.argv = [str(script), "--serve", *extra]
# runpy would work; exec keeps stdin/stdout as the MCP pipes.
os.execv(sys.executable, [sys.executable, "-u", str(script), "--serve", *extra])
sys.stderr.write(
"diffusers-docs MCP: could not find tools/docs_mcp_server.py "
f"(cwd={Path.cwd()}). From the repo root run: "
"python3 -u .cursor/mcp-diffusers-docs.py\n"
f"(cwd={Path.cwd()} file={Path(__file__).resolve()}). "
"Install the PATH shim: bash .cursor/install-docs-mcp.sh "
"then spawn `diffusers-docs-mcp`.\n"
)
return 1

Expand Down
11 changes: 10 additions & 1 deletion .cursor/mcp.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{
"mcpServers": {}
"mcpServers": {
"diffusers-docs": {
"type": "stdio",
"command": "python3",
"args": ["-u", ".cursor/mcp-diffusers-docs.py"],
"env": {
"PYTHONUNBUFFERED": "1"
}
}
}
}
2 changes: 1 addition & 1 deletion .cursor/mcp.optional.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"diffusers-docs": {
"type": "stdio",
"command": "python3",
"args": ["-u", "/workspace/.cursor/mcp-diffusers-docs.py"],
"args": ["-u", ".cursor/mcp-diffusers-docs.py"],
"env": {
"PYTHONUNBUFFERED": "1"
}
Expand Down
10 changes: 5 additions & 5 deletions .cursor/skills/search-docs/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: search-docs
description: Optional docs CLI for this diffusers checkout. Prefer scheduler source + the gate; MCP is opt-in.
description: Optional docs CLI for this diffusers checkout. Prefer the gate; MCP is stdio search_docs.
---

# Search this library's docs
Expand All @@ -9,7 +9,7 @@ description: Optional docs CLI for this diffusers checkout. Prefer scheduler sou
python3 ramp-kit/tools/docs_mcp_server.py --query "<the question>"
```

Cite provenance (`diffusers checkout` vs bundled snapshot). Prefer reading
`src/diffusers/schedulers/scheduling_euler_discrete.py` and
`scheduling_ddpm.py` first. `ramp-kit/conventions/rules.yaml` is the gate.
`.cursor/mcp.json` is empty by default.
Cite provenance (`diffusers checkout` vs bundled snapshot).
`ramp-kit/conventions/rules.yaml` is the gate.
`.cursor/mcp.json` is stdio `diffusers-docs` only (no Hub HTTP).
Cloud dropdown: `diffusers-docs-mcp`.
9 changes: 7 additions & 2 deletions OVERLAY.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ The first contribution is what `ramp-kit/conventions/rules.yaml` checks:
Docs search and reading `scheduling_euler_discrete.py` / `scheduling_ddpm.py`
are how the *kit* verified the YAML. They are not part of the first PR.

`.cursor/mcp.json` is **empty by default** so Cloud launches do not hit Hub
OAuth or stdio cwd failures. Opt-in servers: `.cursor/mcp.optional.json`.
`.cursor/mcp.json` ships **stdio `diffusers-docs` only** (`python3 -u
.cursor/mcp-diffusers-docs.py`). Do not enable Hub HTTP MCP (OAuth). Cloud
dropdown: `diffusers-docs-mcp` (PATH shim from `install-docs-mcp.sh`) or the
same python3 command. The launcher finds `ramp-kit/tools/docs_mcp_server.py`
from `/agent` as well as the repo root.

Hub HTTP and extra servers stay in `.cursor/mcp.optional.json`.

## Demo (Cloud Agent)

Expand Down
Loading