From ceefff12e045fd0f0207ed87f1790ea61f87d1d9 Mon Sep 17 00:00:00 2001 From: Minsu Lee Date: Mon, 22 Jun 2026 23:00:44 +0900 Subject: [PATCH] ci(release): publish the library crate to crates.io via Trusted Publishing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The short name `csp` is already taken on crates.io, so the library crate is published as `code-search-please` while keeping the library name `csp` (`[lib] name = "csp"`) — downstream code still writes `use csp::...`, matching the README and the @pleaseai/csp npm package. The csp-cli dependency keeps the `csp` key via `package = "code-search-please"`. - crates/csp: rename package -> code-search-please, add [lib] name = csp, add crates.io metadata (keywords, categories, homepage, docs, readme) + a crate README. - release-please.yml: new publish-crate job using rust-lang/crates-io-auth-action (OIDC, no token), gated on the CRATES_IO_PUBLISH repo variable so it stays dormant until the one-time bootstrap (claim name + configure trusted publisher) is done. - Verified: cargo fmt/clippy/test --workspace all green; cargo publish --dry-run packages and verifies the crate. The CLI crate (code-search-please-cli) is a follow-up: it needs intra-workspace dependency-version management before it can publish. --- .github/workflows/release-please.yml | 32 +++++++++++++++++++++++ Cargo.lock | 38 ++++++++++++++-------------- Cargo.toml | 4 ++- crates/csp/Cargo.toml | 14 +++++++++- crates/csp/README.md | 38 ++++++++++++++++++++++++++++ 5 files changed, 105 insertions(+), 21 deletions(-) create mode 100644 crates/csp/README.md diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 9af4e41..c84c25d 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -276,3 +276,35 @@ jobs: git push origin main env: GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} + + # Publish the `code-search-please` library crate to crates.io via Trusted + # Publishing (OIDC) — no CARGO_REGISTRY_TOKEN. Gated on the CRATES_IO_PUBLISH + # repo variable so it stays dormant until the one-time bootstrap is done: + # (1) claim the name with a manual `cargo publish` (crates.io TP can't be + # configured on a crate that doesn't exist yet), (2) add a GitHub Actions + # trusted publisher on crates.io (repo pleaseai/code-search, workflow + # release-please.yml), (3) set the repo variable CRATES_IO_PUBLISH=true. + # The CLI crate (code-search-please-cli) is a follow-up — it needs + # intra-workspace dependency-version management before it can publish. + publish-crate: + needs: [release-please] + if: ${{ needs.release-please.outputs.release_created && vars.CRATES_IO_PUBLISH == 'true' }} + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout the released tag + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + with: + ref: ${{ needs.release-please.outputs.tag_name }} + persist-credentials: false + + - name: Authenticate to crates.io (Trusted Publishing) + uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5 + id: auth + + - name: Publish code-search-please + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} + run: cargo publish -p code-search-please --locked diff --git a/Cargo.lock b/Cargo.lock index e241865..b7eaf0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -278,6 +278,24 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" +[[package]] +name = "code-search-please" +version = "0.1.4" +dependencies = [ + "fancy-regex", + "ignore", + "indexmap", + "model2vec-rs", + "regex", + "serde", + "serde_json", + "sha2 0.10.9", + "tempfile", + "thiserror 2.0.18", + "tree-sitter", + "tree-sitter-language-pack", +] + [[package]] name = "colorchoice" version = "1.0.5" @@ -441,31 +459,13 @@ dependencies = [ "hybrid-array", ] -[[package]] -name = "csp" -version = "0.1.4" -dependencies = [ - "fancy-regex", - "ignore", - "indexmap", - "model2vec-rs", - "regex", - "serde", - "serde_json", - "sha2 0.10.9", - "tempfile", - "thiserror 2.0.18", - "tree-sitter", - "tree-sitter-language-pack", -] - [[package]] name = "csp-cli" version = "0.1.4" dependencies = [ "anyhow", "clap", - "csp", + "code-search-please", "rmcp", "schemars", "serde", diff --git a/Cargo.toml b/Cargo.toml index 057448c..d168584 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,9 @@ authors = ["csp maintainers"] # Planned dependency menu (ADR-0003 crate mapping). Member crates opt in # phase by phase with `.workspace = true`; listing here does not fetch. [workspace.dependencies] -csp = { path = "crates/csp" } +# Published as `code-search-please`; the `csp` key keeps `use csp::...` working +# in member crates (the lib name stays `csp` via crates/csp `[lib]`). +csp = { path = "crates/csp", package = "code-search-please" } model2vec-rs = "0.2" # Phase 3 — dense embeddings (official MinishLab port) tree-sitter = "0.26" # Phase 2 — AST chunking ignore = "0.4" # Phase 3 — .gitignore / .cspignore file walking diff --git a/crates/csp/Cargo.toml b/crates/csp/Cargo.toml index 14bacfa..6c0a67a 100644 --- a/crates/csp/Cargo.toml +++ b/crates/csp/Cargo.toml @@ -1,11 +1,23 @@ +# Published to crates.io as `code-search-please` because the short name `csp` +# is already taken by an unrelated crate. The library name stays `csp` (see +# `[lib]`), so downstream code still writes `use csp::...` — matching the README +# example and the `@pleaseai/csp` npm package. [package] -name = "csp" +name = "code-search-please" description = "Hybrid code search for agents — core library (Rust rewrite of MinishLab/semble)." version.workspace = true edition.workspace = true license.workspace = true repository.workspace = true authors.workspace = true +homepage = "https://github.com/pleaseai/code-search" +documentation = "https://docs.rs/code-search-please" +readme = "README.md" +keywords = ["code-search", "search", "embeddings", "bm25", "agents"] +categories = ["development-tools", "text-processing"] + +[lib] +name = "csp" [dependencies] # Populated per the ADR-0003 migration phases. diff --git a/crates/csp/README.md b/crates/csp/README.md new file mode 100644 index 0000000..3b03988 --- /dev/null +++ b/crates/csp/README.md @@ -0,0 +1,38 @@ +# code-search-please (`csp`) + +Hybrid code search for agents — the core Rust library behind [`@pleaseai/csp`](https://github.com/pleaseai/code-search). A Rust rewrite of [MinishLab/semble](https://github.com/MinishLab/semble). + +> Published to crates.io as **`code-search-please`** (the short name `csp` was taken). The library name is `csp`, so you still write `use csp::...`. + +## Install + +```toml +[dependencies] +code-search-please = "0.1" +``` + +## Usage + +```rust +use std::path::Path; +use csp::indexing::index::{CspIndex, LoadOptions, QueryOptions}; + +// Index a local directory and search it +let index = CspIndex::from_path(Path::new("./my-project"), &LoadOptions::default())?; +let results = index.search("save model to disk", &QueryOptions { top_k: Some(3), ..Default::default() }); + +for r in &results { + println!("{}:{}-{}", r.chunk.file_path, r.chunk.start_line, r.chunk.end_line); +} +# Ok::<(), String>(()) +``` + +Hybrid scoring combines Model2Vec dense embeddings with BM25, fused via Reciprocal Rank Fusion. Chunking is tree-sitter AST-based with a line-based fallback. + +## CLI / MCP + +The `csp` binary (CLI + MCP server) ships via npm (`bunx @pleaseai/csp`) and Homebrew. See the [repository README](https://github.com/pleaseai/code-search) for the full surface. + +## License + +MIT. This is a derivative work of [MinishLab/semble](https://github.com/MinishLab/semble); see the repository for credits and citation.