semble 0.7.0__tar.gz → 0.7.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {semble-0.7.0 → semble-0.7.2}/PKG-INFO +4 -3
- {semble-0.7.0 → semble-0.7.2}/README.md +3 -2
- {semble-0.7.0 → semble-0.7.2}/docs/installation.md +49 -2
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/kilo.md +2 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/opencode.md +2 -0
- semble-0.7.2/src/semble/agents/skill.md +45 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/cli.py +15 -3
- {semble-0.7.0 → semble-0.7.2}/src/semble/index/dense.py +11 -3
- {semble-0.7.0 → semble-0.7.2}/src/semble/installer/agents.py +17 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/installer/installer.py +50 -11
- {semble-0.7.0 → semble-0.7.2}/src/semble/mcp.py +6 -2
- {semble-0.7.0 → semble-0.7.2}/src/semble/version.py +1 -1
- {semble-0.7.0 → semble-0.7.2}/src/semble.egg-info/PKG-INFO +4 -3
- {semble-0.7.0 → semble-0.7.2}/src/semble.egg-info/SOURCES.txt +1 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble.egg-info/scm_file_list.json +1 -0
- semble-0.7.2/src/semble.egg-info/scm_version.json +8 -0
- {semble-0.7.0 → semble-0.7.2}/tests/test_cli.py +6 -4
- {semble-0.7.0 → semble-0.7.2}/tests/test_installer.py +39 -2
- {semble-0.7.0 → semble-0.7.2}/tests/test_mcp.py +26 -17
- {semble-0.7.0 → semble-0.7.2}/tests/test_search.py +8 -0
- semble-0.7.0/src/semble.egg-info/scm_version.json +0 -8
- {semble-0.7.0 → semble-0.7.2}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/.github/workflows/ci.yaml +0 -0
- {semble-0.7.0 → semble-0.7.2}/.github/workflows/release.yaml +0 -0
- {semble-0.7.0 → semble-0.7.2}/.gitignore +0 -0
- {semble-0.7.0 → semble-0.7.2}/.pre-commit-config.yaml +0 -0
- {semble-0.7.0 → semble-0.7.2}/CITATION.cff +0 -0
- {semble-0.7.0 → semble-0.7.2}/CONTRIBUTING.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/LICENSE +0 -0
- {semble-0.7.0 → semble-0.7.2}/MANIFEST.in +0 -0
- {semble-0.7.0 → semble-0.7.2}/Makefile +0 -0
- {semble-0.7.0 → semble-0.7.2}/pyproject.toml +0 -0
- {semble-0.7.0 → semble-0.7.2}/scripts/demo/dark.tape +0 -0
- {semble-0.7.0 → semble-0.7.2}/scripts/demo/light.tape +0 -0
- {semble-0.7.0 → semble-0.7.2}/scripts/demo/record.sh +0 -0
- {semble-0.7.0 → semble-0.7.2}/setup.cfg +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/__init__.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/antigravity.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/claude.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/codex.toml +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/commandcode.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/copilot.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/cursor.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/gemini.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/grok.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/kiro.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/pi.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/qwen.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/reasonix.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/agents/zcode.md +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/cache.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/chunking/__init__.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/chunking/chunking.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/chunking/core.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/index/__init__.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/index/bm25.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/index/create.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/index/file_walker.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/index/files.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/index/index.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/index/sparse.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/index/types.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/installer/__init__.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/installer/config.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/py.typed +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/ranking/__init__.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/ranking/boosting.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/ranking/penalties.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/search.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/stats.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/tokens.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/types.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble/utils.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble.egg-info/dependency_links.txt +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble.egg-info/entry_points.txt +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble.egg-info/requires.txt +0 -0
- {semble-0.7.0 → semble-0.7.2}/src/semble.egg-info/top_level.txt +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/__init__.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/conftest.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/index/test_bm25.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/index/test_create.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/index/test_dense.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/index/test_index.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/test_cache.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/test_chunker.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/test_file_walker.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/test_files.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/test_git.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/test_ranking.py +0 -0
- {semble-0.7.0 → semble-0.7.2}/tests/test_stats.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: semble
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: Fast and Accurate Code Search for Agents
|
|
5
5
|
Author-email: Thomas van Dongen <thomasvdongen@proton.me>, Stéphan Tulkens <stephantul@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -119,6 +119,7 @@ semble install
|
|
|
119
119
|
- **MCP server**: lets the agent call Semble directly as a tool.
|
|
120
120
|
- **Instructions**: adds CLI usage guidance to AGENTS.md / CLAUDE.md.
|
|
121
121
|
- **Sub-agent**: installs a dedicated `semble-search` sub-agent.
|
|
122
|
+
- **Skill**: installs a `semble` skill plus a one-line pointer to it in AGENTS.md / CLAUDE.md, instead of the full instructions.
|
|
122
123
|
|
|
123
124
|
To undo the setup, run `semble uninstall`.
|
|
124
125
|
|
|
@@ -143,7 +144,7 @@ For sandboxed or scripted environments, skip the prompts with `--agent` and, opt
|
|
|
143
144
|
semble install --agent claude --type mcp subagent --yes
|
|
144
145
|
```
|
|
145
146
|
|
|
146
|
-
`--agent` accepts one or more agent ids (e.g. `claude`, `codex`, `pi`); `--type` accepts `mcp`, `instructions`, `subagent`, or `all` (default: all); `--yes` skips the confirmation prompt (requires `--agent` for a fully non-interactive run).
|
|
147
|
+
`--agent` accepts one or more agent ids (e.g. `claude`, `codex`, `pi`); `--type` accepts `mcp`, `instructions`, `subagent`, `skill`, or `all` (default: all but `skill`); `--yes` skips the confirmation prompt (requires `--agent` for a fully non-interactive run).
|
|
147
148
|
|
|
148
149
|
</details>
|
|
149
150
|
|
|
@@ -319,7 +320,7 @@ Semble runs as an MCP server so agents can search any codebase directly as a nat
|
|
|
319
320
|
| `search` | Search a codebase with a natural-language or code query. Pass `repo` as a local path or an https:// git URL (or a list of them to search several repos together) and `content` as `code`, `docs`, `config`, or `all` (default: `code`). |
|
|
320
321
|
| `find_related` | Given a file path and line number, return chunks semantically similar to the code at that location. |
|
|
321
322
|
|
|
322
|
-
For per-agent setup instructions, see the [installation docs](docs/installation.md#mcp-server).
|
|
323
|
+
For per-agent setup instructions, see the [installation docs](docs/installation.md#mcp-server). To share one server across agent sessions, run `semble --http`; see [Shared server (HTTP)](docs/installation.md#shared-server-http).
|
|
323
324
|
|
|
324
325
|
|
|
325
326
|
## Benchmarks
|
|
@@ -47,6 +47,7 @@ semble install
|
|
|
47
47
|
- **MCP server**: lets the agent call Semble directly as a tool.
|
|
48
48
|
- **Instructions**: adds CLI usage guidance to AGENTS.md / CLAUDE.md.
|
|
49
49
|
- **Sub-agent**: installs a dedicated `semble-search` sub-agent.
|
|
50
|
+
- **Skill**: installs a `semble` skill plus a one-line pointer to it in AGENTS.md / CLAUDE.md, instead of the full instructions.
|
|
50
51
|
|
|
51
52
|
To undo the setup, run `semble uninstall`.
|
|
52
53
|
|
|
@@ -71,7 +72,7 @@ For sandboxed or scripted environments, skip the prompts with `--agent` and, opt
|
|
|
71
72
|
semble install --agent claude --type mcp subagent --yes
|
|
72
73
|
```
|
|
73
74
|
|
|
74
|
-
`--agent` accepts one or more agent ids (e.g. `claude`, `codex`, `pi`); `--type` accepts `mcp`, `instructions`, `subagent`, or `all` (default: all); `--yes` skips the confirmation prompt (requires `--agent` for a fully non-interactive run).
|
|
75
|
+
`--agent` accepts one or more agent ids (e.g. `claude`, `codex`, `pi`); `--type` accepts `mcp`, `instructions`, `subagent`, `skill`, or `all` (default: all but `skill`); `--yes` skips the confirmation prompt (requires `--agent` for a fully non-interactive run).
|
|
75
76
|
|
|
76
77
|
</details>
|
|
77
78
|
|
|
@@ -247,7 +248,7 @@ Semble runs as an MCP server so agents can search any codebase directly as a nat
|
|
|
247
248
|
| `search` | Search a codebase with a natural-language or code query. Pass `repo` as a local path or an https:// git URL (or a list of them to search several repos together) and `content` as `code`, `docs`, `config`, or `all` (default: `code`). |
|
|
248
249
|
| `find_related` | Given a file path and line number, return chunks semantically similar to the code at that location. |
|
|
249
250
|
|
|
250
|
-
For per-agent setup instructions, see the [installation docs](docs/installation.md#mcp-server).
|
|
251
|
+
For per-agent setup instructions, see the [installation docs](docs/installation.md#mcp-server). To share one server across agent sessions, run `semble --http`; see [Shared server (HTTP)](docs/installation.md#shared-server-http).
|
|
251
252
|
|
|
252
253
|
|
|
253
254
|
## Benchmarks
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Recommended: `semble install`
|
|
4
4
|
|
|
5
|
-
The interactive installer detects your installed agents and configures any combination of
|
|
5
|
+
The interactive installer detects your installed agents and configures any combination of four integrations globally:
|
|
6
6
|
|
|
7
7
|
- **[MCP server](#mcp-server)**: exposes Semble as a native tool your agent can call directly.
|
|
8
8
|
- **[AGENTS.md](#instructions-agentsmd--claudemd)**: adds a Semble usage guide to the agent's config file (`CLAUDE.md`, `AGENTS.md`, etc.).
|
|
9
9
|
- **[Sub-agent](#sub-agent)**: installs a dedicated `semble-search` sub-agent for harnesses that support it.
|
|
10
|
+
- **[Skill](#skill)**: installs a `semble` skill plus a one-line pointer to it in AGENTS.md / CLAUDE.md, as an alternative to the full block. Off by default.
|
|
10
11
|
|
|
11
12
|
Install the CLI with [uv](https://docs.astral.sh/uv/getting-started/installation/), then run:
|
|
12
13
|
|
|
@@ -34,7 +35,7 @@ semble install --agent claude pi --type mcp subagent --yes
|
|
|
34
35
|
```
|
|
35
36
|
|
|
36
37
|
- `--agent` — one or more agent ids (see the list above; use the lowercase form, e.g. `claude`, `codex`, `pi`).
|
|
37
|
-
- `--type` — one or more of `mcp`, `instructions`, `subagent`, or `all` (default: all). Requires `--agent`.
|
|
38
|
+
- `--type` — one or more of `mcp`, `instructions`, `subagent`, `skill`, or `all` (default: all but `skill`). Requires `--agent`.
|
|
38
39
|
- `-y`/`--yes` — skip the confirmation prompt. Requires `--agent` for a fully non-interactive run.
|
|
39
40
|
|
|
40
41
|
`semble uninstall` accepts the same flags.
|
|
@@ -407,6 +408,34 @@ claude mcp add semble -s user -- uvx --from "semble[mcp]" semble --content all
|
|
|
407
408
|
|
|
408
409
|
Indexes stay in memory for the lifetime of the server. To free memory while idle, set `SEMBLE_MCP_IDLE_TIMEOUT` to a number of seconds; indexes unused for that long are dropped from memory and reloaded from the disk cache on the next search.
|
|
409
410
|
|
|
411
|
+
#### Shared server (HTTP)
|
|
412
|
+
|
|
413
|
+
By default each agent session starts its own semble process. To share one server (and one copy of the model and indexes) across sessions, start it yourself over HTTP:
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
uvx --from "semble[mcp]" semble --http --port 8000
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
It listens on `127.0.0.1` only. Then point your agents at `http://127.0.0.1:8000/mcp` instead of the `uvx` command:
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
# Claude Code
|
|
423
|
+
claude mcp add --transport http semble -s user http://127.0.0.1:8000/mcp
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
```json
|
|
427
|
+
// Cursor (~/.cursor/mcp.json)
|
|
428
|
+
{ "mcpServers": { "semble": { "url": "http://127.0.0.1:8000/mcp" } } }
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
```toml
|
|
432
|
+
# Codex (~/.codex/config.toml)
|
|
433
|
+
[mcp_servers.semble]
|
|
434
|
+
url = "http://127.0.0.1:8000/mcp"
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
Relative `repo` paths resolve against the directory the server was started in, so agents should pass absolute paths. `semble install` only sets up the stdio server.
|
|
438
|
+
|
|
410
439
|
### Instructions (AGENTS.md / CLAUDE.md)
|
|
411
440
|
|
|
412
441
|
Add the snippet below to your `AGENTS.md` or `CLAUDE.md` so your agent knows when and how to call the semble CLI:
|
|
@@ -479,3 +508,21 @@ For harnesses that support sub-agents (Claude Code, Cursor, Gemini CLI, Kiro, Op
|
|
|
479
508
|
| Grok Build | `grok.md` | `~/.grok/agents/semble-search.md` |
|
|
480
509
|
| Qwen Code | `qwen.md` | `~/.qwen/agents/semble-search.md` |
|
|
481
510
|
| Kilo Code | `kilo.md` | `~/.config/kilo/agents/semble-search.md` |
|
|
511
|
+
|
|
512
|
+
### Skill
|
|
513
|
+
|
|
514
|
+
For harnesses that support [Agent Skills](https://agentskills.io), you can install a `semble` skill instead of the AGENTS.md block. Copy [`src/semble/agents/skill.md`](../src/semble/agents/skill.md) to the destination below as `SKILL.md`:
|
|
515
|
+
|
|
516
|
+
| Agent | Destination |
|
|
517
|
+
|---|---|
|
|
518
|
+
| Claude Code | `~/.claude/skills/semble/SKILL.md` |
|
|
519
|
+
| Qwen Code | `~/.qwen/skills/semble/SKILL.md` |
|
|
520
|
+
| Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, Pi, Kilo Code | `~/.agents/skills/semble/SKILL.md` |
|
|
521
|
+
|
|
522
|
+
`~/.agents/skills` is shared between agents, so uninstalling the skill for one of them removes it for all of them.
|
|
523
|
+
|
|
524
|
+
Agents rarely load a skill on their own, so also add this line to your AGENTS.md / CLAUDE.md (`semble install` does this for you):
|
|
525
|
+
|
|
526
|
+
```markdown
|
|
527
|
+
Use the `semble` skill for code search instead of Grep or Glob.
|
|
528
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: semble
|
|
3
|
+
description: Code search for the current repository. Use this before Grep, Glob or find whenever you need to locate code, such as where something is implemented, which file defines a function, class or symbol, how a feature works, or where docs and config live.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Use `semble search` to find code by describing what it does or naming a symbol/identifier, instead of grep:
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
semble search "authentication flow" ./my-project --max-snippet-lines 10 # first 10 lines only, concise
|
|
10
|
+
semble search "save_pretrained" ./my-project # full chunk content
|
|
11
|
+
semble search "save model to disk" ./my-project --top-k 10 # more results
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Results are cached automatically on first run and invalidated when files change.
|
|
15
|
+
|
|
16
|
+
Use `--content docs` to search documentation and prose, `--content config` for config files (yaml, toml, etc.), or `--content all` to search code, docs, and config:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
semble search "deployment guide" ./my-project --content docs
|
|
20
|
+
semble search "database host port" ./my-project --content config
|
|
21
|
+
semble search "authentication" ./my-project --content all
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use `semble find-related` to discover code similar to a known location (pass `file_path` and `line` from a prior search result):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
semble find-related src/auth.py 42 ./my-project
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`path` defaults to the current directory when omitted; git URLs are accepted. Pass several paths or URLs to search related repos together, e.g. when this project calls a service defined in a sibling repo. Result paths are then prefixed with the repo name and the output includes a `repos` map from prefix to location:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
semble search "invoice endpoint" ./service-a ../service-b
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
If `semble` is not on `$PATH`, use `uvx --from "semble[mcp]" semble` in its place.
|
|
37
|
+
|
|
38
|
+
### Workflow
|
|
39
|
+
|
|
40
|
+
1. Start with `semble search` to find relevant chunks. The index is built and cached automatically.
|
|
41
|
+
2. Use `--content docs` for documentation, `--content config` for config files, or `--content all` for everything.
|
|
42
|
+
3. Navigate directly to the returned file and line. Do not re-search or grep for the same content.
|
|
43
|
+
4. Optionally use `semble find-related` with a promising result's `file_path` and `line` to discover related implementations.
|
|
44
|
+
5. If the answer may live in a dependent or sibling repo, pass all relevant repo paths to one `semble search` call.
|
|
45
|
+
6. Use grep only when you need every occurrence of a literal string across the whole repo (e.g., all callers of a renamed function).
|
|
@@ -123,6 +123,12 @@ def _mcp_main() -> None:
|
|
|
123
123
|
description="Instant local code search for agents.",
|
|
124
124
|
)
|
|
125
125
|
_add_content_args(parser)
|
|
126
|
+
parser.add_argument(
|
|
127
|
+
"--http",
|
|
128
|
+
action="store_true",
|
|
129
|
+
help="Serve over streamable HTTP on localhost instead of stdio, so several agents can share one server.",
|
|
130
|
+
)
|
|
131
|
+
parser.add_argument("--port", type=int, default=8000, help="Port for --http (default: 8000).")
|
|
126
132
|
args = parser.parse_args()
|
|
127
133
|
if any(find_spec(dep) is None for dep in get_package_extras("semble", "mcp")):
|
|
128
134
|
print("MCP dependencies are not installed. Run: pip install 'semble[mcp]'", file=sys.stderr)
|
|
@@ -130,7 +136,7 @@ def _mcp_main() -> None:
|
|
|
130
136
|
from semble.mcp import serve
|
|
131
137
|
|
|
132
138
|
content = _resolve_content(args.content, args.include_text_files)
|
|
133
|
-
asyncio.new_event_loop().run_until_complete(serve(content))
|
|
139
|
+
asyncio.new_event_loop().run_until_complete(serve(content, port=args.port if args.http else None))
|
|
134
140
|
# Skip asyncio.run's shutdown, which waits for threads still loading the model or building an index.
|
|
135
141
|
os._exit(0)
|
|
136
142
|
|
|
@@ -332,7 +338,7 @@ def _cli_main() -> None:
|
|
|
332
338
|
nargs="+",
|
|
333
339
|
choices=[*(t.value for t in IntegrationType), "all"],
|
|
334
340
|
metavar="TYPE",
|
|
335
|
-
help="Integrations to include (mcp, instructions, subagent, or all). Default: all. Requires --agent.",
|
|
341
|
+
help="Integrations to include (mcp, instructions, subagent, skill, or all). Default: all but skill. Requires --agent.",
|
|
336
342
|
)
|
|
337
343
|
p.add_argument(
|
|
338
344
|
"-y",
|
|
@@ -351,7 +357,13 @@ def _cli_main() -> None:
|
|
|
351
357
|
|
|
352
358
|
from semble.installer import run
|
|
353
359
|
|
|
354
|
-
integration_ids =
|
|
360
|
+
integration_ids = (
|
|
361
|
+
None
|
|
362
|
+
if not args.type
|
|
363
|
+
else list(IntegrationType)
|
|
364
|
+
if "all" in args.type
|
|
365
|
+
else [IntegrationType(t) for t in args.type]
|
|
366
|
+
)
|
|
355
367
|
run(args.command, agent_ids=args.agent, integration_ids=integration_ids, yes=args.yes)
|
|
356
368
|
elif args.command == "clear":
|
|
357
369
|
_run_clear(args.type)
|
|
@@ -6,6 +6,7 @@ from pathlib import Path
|
|
|
6
6
|
|
|
7
7
|
import numpy as np
|
|
8
8
|
import numpy.typing as npt
|
|
9
|
+
from huggingface_hub.errors import LocalEntryNotFoundError
|
|
9
10
|
from huggingface_hub.utils.tqdm import disable_progress_bars
|
|
10
11
|
from model2vec import StaticModel
|
|
11
12
|
from vicinity.backends.basic import CosineBasicBackend
|
|
@@ -28,9 +29,16 @@ def _load_cached(model_path: str) -> StaticModel:
|
|
|
28
29
|
disable_progress_bars()
|
|
29
30
|
logging.getLogger("huggingface_hub.utils._http").addFilter(_drop_unauthenticated_warning)
|
|
30
31
|
try:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
try:
|
|
33
|
+
return StaticModel.from_pretrained(model_path, force_download=False)
|
|
34
|
+
except ValueError:
|
|
35
|
+
return StaticModel.from_pretrained(model_path, force_download=True)
|
|
36
|
+
except LocalEntryNotFoundError as e:
|
|
37
|
+
raise RuntimeError(
|
|
38
|
+
f"Could not download model '{model_path}' from the Hugging Face Hub (huggingface.co). This is a "
|
|
39
|
+
"one-time download that is cached afterwards. Check your network access to the Hub, or set "
|
|
40
|
+
"SEMBLE_MODEL_NAME to a local path."
|
|
41
|
+
) from e
|
|
34
42
|
|
|
35
43
|
|
|
36
44
|
def load_model(model_path: str | None = None) -> tuple[StaticModel, str]:
|
|
@@ -38,6 +38,7 @@ class IntegrationType(str, Enum):
|
|
|
38
38
|
MCP = "mcp"
|
|
39
39
|
INSTRUCTIONS = "instructions"
|
|
40
40
|
SUBAGENT = "subagent"
|
|
41
|
+
SKILL = "skill"
|
|
41
42
|
|
|
42
43
|
|
|
43
44
|
SEMBLE_START = "<!-- SEMBLE_START -->"
|
|
@@ -125,6 +126,8 @@ The index is built on first run and cached automatically. If `semble` is not on
|
|
|
125
126
|
{SEMBLE_END}
|
|
126
127
|
"""
|
|
127
128
|
|
|
129
|
+
SKILL_POINTER = f"{SEMBLE_START}\nUse the `semble` skill for code search instead of Grep or Glob.\n{SEMBLE_END}\n"
|
|
130
|
+
|
|
128
131
|
|
|
129
132
|
@dataclass(frozen=True)
|
|
130
133
|
class McpConfig:
|
|
@@ -155,6 +158,11 @@ class AgentTarget:
|
|
|
155
158
|
mcp: McpConfig | None
|
|
156
159
|
instructions_path: Path | None # None = not supported for this agent
|
|
157
160
|
subagent_path: Path | None = None # global (user-level) sub-agent file; None = unsupported
|
|
161
|
+
skill_path: Path | None = None # global (user-level) SKILL.md; None = unsupported
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# Cross-agent skills directory, read by Codex, Cursor, Gemini CLI, Copilot, OpenCode, Pi and Kilo.
|
|
165
|
+
_SHARED_SKILL_PATH = _HOME / ".agents" / "skills" / "semble" / "SKILL.md"
|
|
158
166
|
|
|
159
167
|
|
|
160
168
|
def _xdg_config_dir(app: str) -> Path:
|
|
@@ -191,6 +199,7 @@ AGENTS: list[AgentTarget] = [
|
|
|
191
199
|
mcp=McpConfig(_HOME / ".claude.json", "mcpServers", _STDIO_SERVER_CONFIG),
|
|
192
200
|
instructions_path=_HOME / ".claude" / "CLAUDE.md",
|
|
193
201
|
subagent_path=_HOME / ".claude" / "agents" / "semble-search.md",
|
|
202
|
+
skill_path=_HOME / ".claude" / "skills" / "semble" / "SKILL.md",
|
|
194
203
|
),
|
|
195
204
|
AgentTarget(
|
|
196
205
|
id="cursor",
|
|
@@ -200,6 +209,7 @@ AGENTS: list[AgentTarget] = [
|
|
|
200
209
|
mcp=McpConfig(_HOME / ".cursor" / "mcp.json", "mcpServers", _STDIO_SERVER_CONFIG),
|
|
201
210
|
instructions_path=None, # Cursor instructions are project-local .mdc files
|
|
202
211
|
subagent_path=_HOME / ".cursor" / "agents" / "semble-search.md",
|
|
212
|
+
skill_path=_SHARED_SKILL_PATH,
|
|
203
213
|
),
|
|
204
214
|
AgentTarget(
|
|
205
215
|
id="gemini",
|
|
@@ -209,6 +219,7 @@ AGENTS: list[AgentTarget] = [
|
|
|
209
219
|
mcp=McpConfig(_HOME / ".gemini" / "settings.json", "mcpServers", _STDIO_SERVER_CONFIG),
|
|
210
220
|
instructions_path=_HOME / ".gemini" / "GEMINI.md",
|
|
211
221
|
subagent_path=_HOME / ".gemini" / "agents" / "semble-search.md",
|
|
222
|
+
skill_path=_SHARED_SKILL_PATH,
|
|
212
223
|
),
|
|
213
224
|
AgentTarget(
|
|
214
225
|
id="kiro",
|
|
@@ -227,6 +238,7 @@ AGENTS: list[AgentTarget] = [
|
|
|
227
238
|
mcp=McpConfig(_xdg_jsonc_path("opencode"), "mcp", _OPENCODE_SERVER_CONFIG),
|
|
228
239
|
instructions_path=_xdg_config_dir("opencode") / "AGENTS.md",
|
|
229
240
|
subagent_path=_xdg_config_dir("opencode") / "agents" / "semble-search.md",
|
|
241
|
+
skill_path=_SHARED_SKILL_PATH,
|
|
230
242
|
),
|
|
231
243
|
AgentTarget(
|
|
232
244
|
id="copilot",
|
|
@@ -236,6 +248,7 @@ AGENTS: list[AgentTarget] = [
|
|
|
236
248
|
mcp=McpConfig(_HOME / ".copilot" / "mcp-config.json", "mcpServers", _BARE_STDIO_SERVER_CONFIG),
|
|
237
249
|
instructions_path=None,
|
|
238
250
|
subagent_path=_HOME / ".copilot" / "agents" / "semble-search.agent.md",
|
|
251
|
+
skill_path=_SHARED_SKILL_PATH,
|
|
239
252
|
),
|
|
240
253
|
AgentTarget(
|
|
241
254
|
id="codex",
|
|
@@ -245,6 +258,7 @@ AGENTS: list[AgentTarget] = [
|
|
|
245
258
|
mcp=McpConfig(_HOME / ".codex" / "config.toml", "mcp_servers", _STDIO_SERVER_CONFIG, format="toml"),
|
|
246
259
|
instructions_path=_HOME / ".codex" / "AGENTS.md",
|
|
247
260
|
subagent_path=_HOME / ".codex" / "agents" / "semble-search.toml",
|
|
261
|
+
skill_path=_SHARED_SKILL_PATH,
|
|
248
262
|
),
|
|
249
263
|
AgentTarget(
|
|
250
264
|
id="zcode",
|
|
@@ -299,6 +313,7 @@ AGENTS: list[AgentTarget] = [
|
|
|
299
313
|
mcp=McpConfig(_HOME / ".pi" / "agent" / "mcp.json", "mcpServers", _BARE_STDIO_SERVER_CONFIG),
|
|
300
314
|
instructions_path=None,
|
|
301
315
|
subagent_path=_HOME / ".pi" / "agents" / "semble-search.md",
|
|
316
|
+
skill_path=_SHARED_SKILL_PATH,
|
|
302
317
|
),
|
|
303
318
|
AgentTarget(
|
|
304
319
|
id="commandcode",
|
|
@@ -335,6 +350,7 @@ AGENTS: list[AgentTarget] = [
|
|
|
335
350
|
mcp=McpConfig(_HOME / ".qwen" / "settings.json", "mcpServers", _STDIO_SERVER_CONFIG),
|
|
336
351
|
instructions_path=_HOME / ".qwen" / "QWEN.md",
|
|
337
352
|
subagent_path=_HOME / ".qwen" / "agents" / "semble-search.md",
|
|
353
|
+
skill_path=_HOME / ".qwen" / "skills" / "semble" / "SKILL.md",
|
|
338
354
|
),
|
|
339
355
|
AgentTarget(
|
|
340
356
|
id="cline",
|
|
@@ -356,6 +372,7 @@ AGENTS: list[AgentTarget] = [
|
|
|
356
372
|
mcp=McpConfig(_xdg_jsonc_path("kilo"), "mcp", _OPENCODE_SERVER_CONFIG),
|
|
357
373
|
instructions_path=_xdg_config_dir("kilo") / "AGENTS.md",
|
|
358
374
|
subagent_path=_xdg_config_dir("kilo") / "agents" / "semble-search.md",
|
|
375
|
+
skill_path=_SHARED_SKILL_PATH,
|
|
359
376
|
),
|
|
360
377
|
]
|
|
361
378
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import sys
|
|
4
|
+
from contextlib import suppress
|
|
4
5
|
from dataclasses import dataclass
|
|
5
6
|
from importlib.resources import files
|
|
6
7
|
from pathlib import Path
|
|
@@ -12,6 +13,7 @@ from semble.installer.agents import (
|
|
|
12
13
|
AGENTS,
|
|
13
14
|
INSTRUCTIONS,
|
|
14
15
|
SEMBLE_PIN,
|
|
16
|
+
SKILL_POINTER,
|
|
15
17
|
AgentTarget,
|
|
16
18
|
IntegrationType,
|
|
17
19
|
Mode,
|
|
@@ -41,13 +43,14 @@ _ACTION_DETAIL: dict[str, str] = {
|
|
|
41
43
|
|
|
42
44
|
@dataclass(frozen=True)
|
|
43
45
|
class _Integration:
|
|
44
|
-
"""Descriptor for one installer integration (MCP server, instructions, sub-agent)."""
|
|
46
|
+
"""Descriptor for one installer integration (MCP server, instructions, sub-agent, skill)."""
|
|
45
47
|
|
|
46
48
|
id: IntegrationType
|
|
47
49
|
label: str
|
|
48
50
|
desc: str
|
|
49
51
|
apply: Callable[[AgentTarget, Mode], WriteResult | None]
|
|
50
52
|
plan_path: Callable[[AgentTarget], Path | None]
|
|
53
|
+
default: bool = True # selected when the user doesn't choose integrations
|
|
51
54
|
|
|
52
55
|
|
|
53
56
|
def merge_mcp(agent: AgentTarget) -> WriteResult:
|
|
@@ -83,11 +86,8 @@ def _apply_instructions(agent: AgentTarget, mode: Mode) -> WriteResult | None:
|
|
|
83
86
|
return WriteResult(path, action)
|
|
84
87
|
|
|
85
88
|
|
|
86
|
-
def
|
|
87
|
-
"""
|
|
88
|
-
dest = agent.subagent_path
|
|
89
|
-
if dest is None:
|
|
90
|
-
return None
|
|
89
|
+
def _sync_file(dest: Path, mode: Mode, render: Callable[[], str]) -> WriteResult:
|
|
90
|
+
"""Write the rendered file to dest on install, or delete it on uninstall."""
|
|
91
91
|
if mode == "uninstall":
|
|
92
92
|
if not dest.exists():
|
|
93
93
|
return WriteResult(dest, "not-found")
|
|
@@ -96,9 +96,8 @@ def _apply_subagent(agent: AgentTarget, mode: Mode) -> WriteResult | None:
|
|
|
96
96
|
existed = dest.exists()
|
|
97
97
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
98
98
|
try:
|
|
99
|
-
src = files("semble").joinpath(f"agents/{agent.id}{dest.suffix}").read_text(encoding="utf-8")
|
|
100
99
|
# Bytes on both sides: no newline translation on Windows, and an undecodable file is just stale.
|
|
101
|
-
content =
|
|
100
|
+
content = render().encode("utf-8")
|
|
102
101
|
if existed and dest.read_bytes() == content:
|
|
103
102
|
return WriteResult(dest, "unchanged")
|
|
104
103
|
dest.write_bytes(content)
|
|
@@ -107,6 +106,38 @@ def _apply_subagent(agent: AgentTarget, mode: Mode) -> WriteResult | None:
|
|
|
107
106
|
return WriteResult(dest, "updated" if existed else "created")
|
|
108
107
|
|
|
109
108
|
|
|
109
|
+
def _bundled(name: str) -> str:
|
|
110
|
+
"""Read a bundled agent file, pinning its uvx fallback to the installed semble version."""
|
|
111
|
+
src = files("semble").joinpath(f"agents/{name}").read_text(encoding="utf-8")
|
|
112
|
+
return src.replace('"semble[mcp]"', f'"{SEMBLE_PIN}"')
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _apply_subagent(agent: AgentTarget, mode: Mode) -> WriteResult | None:
|
|
116
|
+
"""Apply or remove the global sub-agent file for one agent."""
|
|
117
|
+
dest = agent.subagent_path
|
|
118
|
+
if dest is None:
|
|
119
|
+
return None
|
|
120
|
+
return _sync_file(dest, mode, lambda: _bundled(f"{agent.id}{dest.suffix}"))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _apply_skill(agent: AgentTarget, mode: Mode) -> WriteResult | None:
|
|
124
|
+
"""Apply or remove the global semble skill for one agent."""
|
|
125
|
+
dest = agent.skill_path
|
|
126
|
+
if dest is None:
|
|
127
|
+
return None
|
|
128
|
+
result = _sync_file(dest, mode, lambda: _bundled("skill.md"))
|
|
129
|
+
if result.action == "removed":
|
|
130
|
+
with suppress(OSError): # leave the skill directory if anything else is in it
|
|
131
|
+
dest.parent.rmdir()
|
|
132
|
+
# Agents rarely load a skill unprompted, so point to it from the instructions file.
|
|
133
|
+
pointer = agent.instructions_path
|
|
134
|
+
if pointer is not None and mode == "install":
|
|
135
|
+
replace_or_append_marked(pointer, SKILL_POINTER)
|
|
136
|
+
elif pointer is not None and pointer.exists() and SKILL_POINTER in pointer.read_text(encoding="utf-8"):
|
|
137
|
+
remove_marked(pointer) # leave a full instructions block alone
|
|
138
|
+
return result
|
|
139
|
+
|
|
140
|
+
|
|
110
141
|
_INTEGRATIONS: list[_Integration] = [
|
|
111
142
|
_Integration(
|
|
112
143
|
IntegrationType.MCP,
|
|
@@ -115,6 +146,14 @@ _INTEGRATIONS: list[_Integration] = [
|
|
|
115
146
|
_apply_mcp,
|
|
116
147
|
lambda a: a.mcp.path if a.mcp else None,
|
|
117
148
|
),
|
|
149
|
+
_Integration(
|
|
150
|
+
IntegrationType.SKILL,
|
|
151
|
+
"Skill",
|
|
152
|
+
"installs a semble skill, with a one-line pointer in AGENTS.md / CLAUDE.md",
|
|
153
|
+
_apply_skill,
|
|
154
|
+
lambda a: a.skill_path,
|
|
155
|
+
default=False, # alternative to the instructions block; listed first so a chosen full block wins
|
|
156
|
+
),
|
|
118
157
|
_Integration(
|
|
119
158
|
IntegrationType.INSTRUCTIONS,
|
|
120
159
|
"Instructions",
|
|
@@ -203,7 +242,7 @@ def run(
|
|
|
203
242
|
"""Install or uninstall semble across coding agents.
|
|
204
243
|
|
|
205
244
|
Prompts interactively unless `agent_ids` is given, in which case it runs unattended
|
|
206
|
-
against those agents (and `integration_ids`, or
|
|
245
|
+
against those agents (and `integration_ids`, or the default integrations if omitted).
|
|
207
246
|
"""
|
|
208
247
|
install = mode == "install"
|
|
209
248
|
print(f"\n {_BOLD}{'Semble Installer' if install else 'Semble Uninstaller'}{_RESET}\n")
|
|
@@ -213,7 +252,7 @@ def run(
|
|
|
213
252
|
chosen_integrations = (
|
|
214
253
|
[i for i in _INTEGRATIONS if i.id in integration_ids]
|
|
215
254
|
if integration_ids is not None
|
|
216
|
-
else
|
|
255
|
+
else [i for i in _INTEGRATIONS if i.default]
|
|
217
256
|
) or _exit("No matching integrations. Exiting.", code=1)
|
|
218
257
|
else:
|
|
219
258
|
agent_items = [
|
|
@@ -225,7 +264,7 @@ def run(
|
|
|
225
264
|
) or _exit("Nothing selected. Exiting.")
|
|
226
265
|
|
|
227
266
|
max_label = max(len(i.label) for i in _INTEGRATIONS)
|
|
228
|
-
integ_items = [(f"{i.label:<{max_label}} — {i.desc}", i,
|
|
267
|
+
integ_items = [(f"{i.label:<{max_label}} — {i.desc}", i, i.default) for i in _INTEGRATIONS]
|
|
229
268
|
chosen_integrations = _checkbox(
|
|
230
269
|
f"Select integrations to {'enable' if install else 'remove'}:", integ_items
|
|
231
270
|
) or _exit("Nothing selected. Exiting.")
|
|
@@ -175,8 +175,9 @@ def create_server(cache: _IndexCache, default_content: Sequence[ContentType] = (
|
|
|
175
175
|
|
|
176
176
|
async def serve(
|
|
177
177
|
content: Sequence[ContentType] = (ContentType.CODE,),
|
|
178
|
+
port: int | None = None,
|
|
178
179
|
) -> None:
|
|
179
|
-
"""Start an MCP stdio
|
|
180
|
+
"""Start an MCP server over stdio, or over streamable HTTP on localhost if a port is given."""
|
|
180
181
|
cache = _IndexCache()
|
|
181
182
|
|
|
182
183
|
async def _load_and_prewarm() -> None:
|
|
@@ -193,7 +194,10 @@ async def serve(
|
|
|
193
194
|
init_task = asyncio.create_task(_load_and_prewarm())
|
|
194
195
|
server = create_server(cache, default_content=content)
|
|
195
196
|
try:
|
|
196
|
-
|
|
197
|
+
if port is None:
|
|
198
|
+
await server.run_stdio_async()
|
|
199
|
+
else:
|
|
200
|
+
await server.run_streamable_http_async(port=port)
|
|
197
201
|
finally:
|
|
198
202
|
if not init_task.done():
|
|
199
203
|
init_task.cancel()
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version_triple__ = (0, 7,
|
|
1
|
+
__version_triple__ = (0, 7, 2)
|
|
2
2
|
__version__ = ".".join(map(str, __version_triple__))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: semble
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: Fast and Accurate Code Search for Agents
|
|
5
5
|
Author-email: Thomas van Dongen <thomasvdongen@proton.me>, Stéphan Tulkens <stephantul@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -119,6 +119,7 @@ semble install
|
|
|
119
119
|
- **MCP server**: lets the agent call Semble directly as a tool.
|
|
120
120
|
- **Instructions**: adds CLI usage guidance to AGENTS.md / CLAUDE.md.
|
|
121
121
|
- **Sub-agent**: installs a dedicated `semble-search` sub-agent.
|
|
122
|
+
- **Skill**: installs a `semble` skill plus a one-line pointer to it in AGENTS.md / CLAUDE.md, instead of the full instructions.
|
|
122
123
|
|
|
123
124
|
To undo the setup, run `semble uninstall`.
|
|
124
125
|
|
|
@@ -143,7 +144,7 @@ For sandboxed or scripted environments, skip the prompts with `--agent` and, opt
|
|
|
143
144
|
semble install --agent claude --type mcp subagent --yes
|
|
144
145
|
```
|
|
145
146
|
|
|
146
|
-
`--agent` accepts one or more agent ids (e.g. `claude`, `codex`, `pi`); `--type` accepts `mcp`, `instructions`, `subagent`, or `all` (default: all); `--yes` skips the confirmation prompt (requires `--agent` for a fully non-interactive run).
|
|
147
|
+
`--agent` accepts one or more agent ids (e.g. `claude`, `codex`, `pi`); `--type` accepts `mcp`, `instructions`, `subagent`, `skill`, or `all` (default: all but `skill`); `--yes` skips the confirmation prompt (requires `--agent` for a fully non-interactive run).
|
|
147
148
|
|
|
148
149
|
</details>
|
|
149
150
|
|
|
@@ -319,7 +320,7 @@ Semble runs as an MCP server so agents can search any codebase directly as a nat
|
|
|
319
320
|
| `search` | Search a codebase with a natural-language or code query. Pass `repo` as a local path or an https:// git URL (or a list of them to search several repos together) and `content` as `code`, `docs`, `config`, or `all` (default: `code`). |
|
|
320
321
|
| `find_related` | Given a file path and line number, return chunks semantically similar to the code at that location. |
|
|
321
322
|
|
|
322
|
-
For per-agent setup instructions, see the [installation docs](docs/installation.md#mcp-server).
|
|
323
|
+
For per-agent setup instructions, see the [installation docs](docs/installation.md#mcp-server). To share one server across agent sessions, run `semble --http`; see [Shared server (HTTP)](docs/installation.md#shared-server-http).
|
|
323
324
|
|
|
324
325
|
|
|
325
326
|
## Benchmarks
|
|
@@ -17,12 +17,14 @@ from tests.conftest import make_chunk
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
@pytest.mark.parametrize(
|
|
20
|
-
"argv",
|
|
20
|
+
("argv", "port"),
|
|
21
21
|
[
|
|
22
|
-
["semble"],
|
|
22
|
+
(["semble"], None),
|
|
23
|
+
(["semble", "--http"], 8000),
|
|
24
|
+
(["semble", "--http", "--port", "9000"], 9000),
|
|
23
25
|
],
|
|
24
26
|
)
|
|
25
|
-
def test_mcp_main_serves_then_exits(argv: list[str], monkeypatch: pytest.MonkeyPatch) -> None:
|
|
27
|
+
def test_mcp_main_serves_then_exits(argv: list[str], port: int | None, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
26
28
|
"""main() serves MCP, then hard-exits with 0 on stdin EOF or SIGTERM instead of joining worker threads."""
|
|
27
29
|
monkeypatch.setattr(sys, "argv", argv)
|
|
28
30
|
loop = asyncio.new_event_loop()
|
|
@@ -33,7 +35,7 @@ def test_mcp_main_serves_then_exits(argv: list[str], monkeypatch: pytest.MonkeyP
|
|
|
33
35
|
patch("semble.cli.os._exit") as mock_exit,
|
|
34
36
|
):
|
|
35
37
|
main()
|
|
36
|
-
mock_serve.
|
|
38
|
+
assert mock_serve.await_args.kwargs["port"] == port
|
|
37
39
|
mock_exit.assert_called_once_with(0)
|
|
38
40
|
signum, handler = mock_signal.call_args.args
|
|
39
41
|
assert signum == signal.SIGTERM
|
|
@@ -14,6 +14,7 @@ from semble.installer.agents import (
|
|
|
14
14
|
SEMBLE_END,
|
|
15
15
|
SEMBLE_PIN,
|
|
16
16
|
SEMBLE_START,
|
|
17
|
+
SKILL_POINTER,
|
|
17
18
|
IntegrationType,
|
|
18
19
|
_vscode_mcp_path,
|
|
19
20
|
_xdg_jsonc_path,
|
|
@@ -35,6 +36,7 @@ from semble.installer.installer import (
|
|
|
35
36
|
_INTEGRATIONS,
|
|
36
37
|
_apply_instructions,
|
|
37
38
|
_apply_mcp,
|
|
39
|
+
_apply_skill,
|
|
38
40
|
_apply_subagent,
|
|
39
41
|
_checkbox,
|
|
40
42
|
_print_plan,
|
|
@@ -57,6 +59,7 @@ def claude_agent(tmp_path):
|
|
|
57
59
|
mcp=replace(a.mcp, path=tmp_path / ".claude.json"),
|
|
58
60
|
instructions_path=tmp_path / ".claude" / "CLAUDE.md",
|
|
59
61
|
subagent_path=tmp_path / ".claude" / "agents" / "semble-search.md",
|
|
62
|
+
skill_path=tmp_path / ".claude" / "skills" / "semble" / "SKILL.md",
|
|
60
63
|
)
|
|
61
64
|
|
|
62
65
|
|
|
@@ -68,6 +71,7 @@ def run_setup(monkeypatch, tmp_path, claude_agent):
|
|
|
68
71
|
cursor,
|
|
69
72
|
mcp=replace(cursor.mcp, path=tmp_path / "cursor.json"),
|
|
70
73
|
subagent_path=tmp_path / "cursor_subagent.md",
|
|
74
|
+
skill_path=tmp_path / "cursor_skill" / "SKILL.md",
|
|
71
75
|
)
|
|
72
76
|
monkeypatch.setattr("semble.installer.installer.AGENTS", [claude_agent, cursor])
|
|
73
77
|
monkeypatch.setattr("semble.installer.installer._checkbox", lambda _p, items: [v for _, v, _ in items])
|
|
@@ -398,6 +402,33 @@ def test_apply_subagent(tmp_path):
|
|
|
398
402
|
assert _apply_subagent(replace(agent, id="zzz"), "install").action == "error"
|
|
399
403
|
|
|
400
404
|
|
|
405
|
+
def test_apply_skill(claude_agent):
|
|
406
|
+
"""_apply_skill installs the pinned SKILL.md plus a pointer, and removes only its own pointer on uninstall."""
|
|
407
|
+
dest, md = claude_agent.skill_path, claude_agent.instructions_path
|
|
408
|
+
|
|
409
|
+
assert _apply_skill(claude_agent, "install").action == "created"
|
|
410
|
+
text = dest.read_bytes().decode("utf-8")
|
|
411
|
+
assert text.startswith("---\nname: semble\n") and SEMBLE_PIN in text and '"semble[mcp]"' not in text
|
|
412
|
+
assert md.read_text(encoding="utf-8") == SKILL_POINTER
|
|
413
|
+
assert _apply_skill(claude_agent, "install").action == "unchanged"
|
|
414
|
+
assert _apply_skill(claude_agent, "uninstall").action == "removed"
|
|
415
|
+
assert not dest.parent.exists() and not md.exists()
|
|
416
|
+
assert _apply_skill(claude_agent, "uninstall").action == "not-found"
|
|
417
|
+
assert _apply_skill(replace(claude_agent, skill_path=None), "install") is None
|
|
418
|
+
|
|
419
|
+
_apply_instructions(claude_agent, "install")
|
|
420
|
+
_apply_skill(claude_agent, "uninstall")
|
|
421
|
+
assert md.read_text(encoding="utf-8") == INSTRUCTIONS
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
def test_run_skill_and_instructions_keeps_full_block(run_setup, claude_agent):
|
|
425
|
+
"""Choosing both skill and instructions leaves the full instructions block, not the pointer."""
|
|
426
|
+
both = [IntegrationType.INSTRUCTIONS, IntegrationType.SKILL]
|
|
427
|
+
run("install", agent_ids=["claude"], integration_ids=both, yes=True)
|
|
428
|
+
assert claude_agent.skill_path.exists()
|
|
429
|
+
assert claude_agent.instructions_path.read_text(encoding="utf-8") == INSTRUCTIONS
|
|
430
|
+
|
|
431
|
+
|
|
401
432
|
@pytest.mark.parametrize("agent", [a for a in AGENTS if a.subagent_path is not None], ids=lambda a: a.id)
|
|
402
433
|
def test_apply_subagent_bundled_file_for_every_agent(tmp_path, agent):
|
|
403
434
|
"""Every agent with a sub-agent path ships a bundled file that installs with the pinned uvx spec."""
|
|
@@ -662,6 +693,10 @@ def test_cli_unattended_flags(monkeypatch, command):
|
|
|
662
693
|
assert calls == [(command, {"agent_ids": ["pi"], "integration_ids": [IntegrationType.SUBAGENT], "yes": True})]
|
|
663
694
|
assert isinstance(calls[0][1]["integration_ids"][0], IntegrationType)
|
|
664
695
|
|
|
696
|
+
monkeypatch.setattr(sys, "argv", ["semble", command, "--agent", "pi", "--type", "all"])
|
|
697
|
+
cli.main()
|
|
698
|
+
assert calls[-1][1]["integration_ids"] == list(IntegrationType)
|
|
699
|
+
|
|
665
700
|
|
|
666
701
|
def test_cli_type_without_agent_errors(monkeypatch, capsys):
|
|
667
702
|
"""--type without --agent is rejected with a usage error."""
|
|
@@ -673,8 +708,8 @@ def test_cli_type_without_agent_errors(monkeypatch, capsys):
|
|
|
673
708
|
assert "--type requires --agent" in capsys.readouterr().err
|
|
674
709
|
|
|
675
710
|
|
|
676
|
-
def test_run_unattended_skips_prompts(run_setup, monkeypatch):
|
|
677
|
-
"""run() with agent_ids skips
|
|
711
|
+
def test_run_unattended_skips_prompts(run_setup, monkeypatch, claude_agent):
|
|
712
|
+
"""run() with agent_ids skips the prompts and installs only the default integrations."""
|
|
678
713
|
from semble.installer import run
|
|
679
714
|
|
|
680
715
|
def _boom(*_: object, **__: object) -> None:
|
|
@@ -683,6 +718,8 @@ def test_run_unattended_skips_prompts(run_setup, monkeypatch):
|
|
|
683
718
|
monkeypatch.setattr("semble.installer.installer._checkbox", _boom)
|
|
684
719
|
monkeypatch.setattr("semble.installer.installer.questionary.confirm", _boom)
|
|
685
720
|
run("install", agent_ids=["claude"], yes=True)
|
|
721
|
+
assert claude_agent.instructions_path.exists()
|
|
722
|
+
assert not claude_agent.skill_path.exists()
|
|
686
723
|
|
|
687
724
|
|
|
688
725
|
@pytest.mark.parametrize(
|
|
@@ -407,21 +407,23 @@ async def test_search_builds_exact_content_indexes(
|
|
|
407
407
|
|
|
408
408
|
@pytest.mark.anyio
|
|
409
409
|
@pytest.mark.parametrize(
|
|
410
|
-
("load_err", "stdio_yields"),
|
|
410
|
+
("load_err", "stdio_yields", "port"),
|
|
411
411
|
[
|
|
412
|
-
(None, True),
|
|
413
|
-
(RuntimeError("boom"), True),
|
|
414
|
-
(None, False),
|
|
412
|
+
(None, True, None),
|
|
413
|
+
(RuntimeError("boom"), True, None),
|
|
414
|
+
(None, False, None),
|
|
415
|
+
(None, True, 9000),
|
|
415
416
|
],
|
|
416
|
-
ids=["model_loads", "model_load_fails", "cancel_pending_init"],
|
|
417
|
+
ids=["model_loads", "model_load_fails", "cancel_pending_init", "http"],
|
|
417
418
|
)
|
|
418
|
-
async def
|
|
419
|
+
async def test_serve_runs_transport(
|
|
419
420
|
load_err: Exception | None,
|
|
420
421
|
stdio_yields: bool,
|
|
422
|
+
port: int | None,
|
|
421
423
|
) -> None:
|
|
422
|
-
"""serve() runs stdio and handles all background init outcomes without raising."""
|
|
424
|
+
"""serve() runs stdio, or HTTP when given a port, and handles all background init outcomes without raising."""
|
|
423
425
|
|
|
424
|
-
async def
|
|
426
|
+
async def fake_run(**_: Any) -> None:
|
|
425
427
|
if stdio_yields:
|
|
426
428
|
await asyncio.sleep(0.05) # let the background init task run
|
|
427
429
|
|
|
@@ -430,11 +432,17 @@ async def test_serve_runs_stdio(
|
|
|
430
432
|
)
|
|
431
433
|
with (
|
|
432
434
|
patch("semble.mcp.load_model", **load_kwargs),
|
|
433
|
-
patch("mcp.server.mcpserver.MCPServer.run_stdio_async", side_effect=
|
|
435
|
+
patch("mcp.server.mcpserver.MCPServer.run_stdio_async", side_effect=fake_run) as mock_stdio,
|
|
436
|
+
patch("mcp.server.mcpserver.MCPServer.run_streamable_http_async", side_effect=fake_run) as mock_http,
|
|
434
437
|
):
|
|
435
|
-
await serve()
|
|
438
|
+
await serve(port=port)
|
|
436
439
|
|
|
437
|
-
|
|
440
|
+
if port is None:
|
|
441
|
+
mock_stdio.assert_called_once()
|
|
442
|
+
mock_http.assert_not_called()
|
|
443
|
+
else:
|
|
444
|
+
mock_http.assert_called_once_with(port=port)
|
|
445
|
+
mock_stdio.assert_not_called()
|
|
438
446
|
|
|
439
447
|
|
|
440
448
|
@pytest.mark.anyio
|
|
@@ -459,17 +467,18 @@ async def test_serve_opens_stdio_before_model_loads() -> None:
|
|
|
459
467
|
|
|
460
468
|
@pytest.mark.anyio
|
|
461
469
|
async def test_index_cache_awaits_model(tmp_path: Path) -> None:
|
|
462
|
-
"""get() blocks until the model is installed, then
|
|
470
|
+
"""get() blocks until the model is installed, then concurrent callers share one build."""
|
|
463
471
|
cache = _IndexCache() # no model yet
|
|
464
472
|
fake_index = MagicMock()
|
|
465
|
-
with patch("semble.mcp.SembleIndex.from_path", return_value=fake_index):
|
|
466
|
-
|
|
473
|
+
with patch("semble.mcp.SembleIndex.from_path", return_value=fake_index) as from_path:
|
|
474
|
+
tasks = [asyncio.create_task(cache.get(str(tmp_path))) for _ in range(2)]
|
|
467
475
|
await asyncio.sleep(0.01)
|
|
468
|
-
assert not
|
|
476
|
+
assert not any(t.done() for t in tasks), "get() must block until the model is installed"
|
|
469
477
|
cache._model_path = "/fake/model"
|
|
470
478
|
cache._model_ready.set()
|
|
471
|
-
|
|
472
|
-
assert
|
|
479
|
+
results = await asyncio.wait_for(asyncio.gather(*tasks), timeout=1.0)
|
|
480
|
+
assert results == [fake_index, fake_index]
|
|
481
|
+
from_path.assert_called_once()
|
|
473
482
|
|
|
474
483
|
|
|
475
484
|
@pytest.mark.anyio
|
|
@@ -5,6 +5,7 @@ from unittest.mock import MagicMock, call, patch
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
import numpy.typing as npt
|
|
7
7
|
import pytest
|
|
8
|
+
from huggingface_hub.errors import LocalEntryNotFoundError
|
|
8
9
|
from model2vec import StaticModel
|
|
9
10
|
from vicinity.backends.basic import BasicArgs
|
|
10
11
|
|
|
@@ -160,6 +161,13 @@ def test_load_model(model_path: str | None, expected_call_arg: str, incomplete_c
|
|
|
160
161
|
assert mock_fp.call_args_list == expected_calls
|
|
161
162
|
|
|
162
163
|
|
|
164
|
+
def test_load_model_unreachable_hub_raises_helpful_error() -> None:
|
|
165
|
+
"""An unreachable Hub surfaces the model name and host instead of a generic Hub error."""
|
|
166
|
+
with patch("semble.index.dense.StaticModel.from_pretrained", side_effect=LocalEntryNotFoundError("offline")):
|
|
167
|
+
with pytest.raises(RuntimeError, match="huggingface.co"):
|
|
168
|
+
load_model("offline/model")
|
|
169
|
+
|
|
170
|
+
|
|
163
171
|
@pytest.mark.parametrize(
|
|
164
172
|
("message", "shown"),
|
|
165
173
|
[
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|