Skip to content

Commit e7889ec

Browse files
committed
fix: include schemas in crates.io package via build.rs
Schemas from the acp-spec submodule are now copied to schemas/v1/ at build time, ensuring they're included in the crates.io package. - Add build.rs to copy schema files from submodule - Update include_str! paths to use vendored location - Add schemas/ to .gitignore (generated at build time) - Add include list to Cargo.toml for packaging
1 parent b2bc6ea commit e7889ec

6 files changed

Lines changed: 56 additions & 9 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Generated by Cargo
22
/target/
33

4+
# Vendored schemas (generated by build.rs from acp-spec submodule)
5+
/schemas/
6+
47
# IDE
58
.idea/
69
.vscode/

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.4.1] - 2025-12-30
11+
12+
### Fixed
13+
- Fixed crates.io packaging: schema files from acp-spec submodule are now properly included via build.rs
14+
1015
## [0.4.0] - 2025-12-30
1116

1217
### Added

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@
77
# @acp:summary "Package metadata and publishing information"
88
[package]
99
name = "acp-protocol"
10-
version = "0.4.0"
10+
version = "0.4.1"
1111
edition = "2021"
1212
authors = ["ACP Contributors"]
1313
description = "AI Context Protocol - Token-efficient and context enhancing code documentation for AI systems"
1414
license = "MIT"
1515
repository = "https://github.com/acp-protocol/acp-cli"
1616
keywords = ["ai", "documentation", "code-analysis", "context", "llm"]
1717
categories = ["development-tools", "command-line-utilities"]
18+
build = "build.rs"
19+
include = [
20+
"src/**/*",
21+
"schemas/**/*",
22+
"build.rs",
23+
"Cargo.toml",
24+
"LICENSE",
25+
"README.md",
26+
]
1827

1928
# @acp:summary "Library crate configuration"
2029
[lib]

build.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//! Build script to copy schema files from acp-spec submodule to vendored location.
2+
//!
3+
//! This ensures the schemas are available for include_str!() at compile time
4+
//! and get packaged into the crates.io release.
5+
6+
use std::fs;
7+
use std::path::Path;
8+
9+
fn main() {
10+
let src_dir = Path::new("acp-spec/schemas/v1");
11+
let dst_dir = Path::new("schemas/v1");
12+
13+
// Only copy if source (submodule) exists
14+
if src_dir.exists() {
15+
fs::create_dir_all(dst_dir).expect("Failed to create schemas/v1 directory");
16+
17+
for entry in fs::read_dir(src_dir).expect("Failed to read acp-spec/schemas/v1") {
18+
let entry = entry.expect("Failed to read directory entry");
19+
let src_path = entry.path();
20+
21+
if src_path.extension().map(|e| e == "json").unwrap_or(false) {
22+
let dst_path = dst_dir.join(entry.file_name());
23+
fs::copy(&src_path, &dst_path).expect("Failed to copy schema file");
24+
}
25+
}
26+
}
27+
28+
// Tell Cargo to rerun build.rs if submodule schemas change
29+
println!("cargo:rerun-if-changed=acp-spec/schemas/v1");
30+
}

src/schema.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ use crate::error::{AcpError, Result};
1111
use jsonschema::{Draft, Retrieve, Uri, Validator};
1212
use std::sync::OnceLock;
1313

14-
// Embed schemas at compile time from acp-spec submodule (source of truth)
15-
static CACHE_SCHEMA_STR: &str = include_str!("../acp-spec/schemas/v1/cache.schema.json");
16-
static VARS_SCHEMA_STR: &str = include_str!("../acp-spec/schemas/v1/vars.schema.json");
17-
static CONFIG_SCHEMA_STR: &str = include_str!("../acp-spec/schemas/v1/config.schema.json");
18-
static ATTEMPTS_SCHEMA_STR: &str = include_str!("../acp-spec/schemas/v1/attempts.schema.json");
19-
static SYNC_SCHEMA_STR: &str = include_str!("../acp-spec/schemas/v1/sync.schema.json");
20-
static PRIMER_SCHEMA_STR: &str = include_str!("../acp-spec/schemas/v1/primer.schema.json");
14+
// Embed schemas at compile time (copied from acp-spec submodule by build.rs)
15+
static CACHE_SCHEMA_STR: &str = include_str!("../schemas/v1/cache.schema.json");
16+
static VARS_SCHEMA_STR: &str = include_str!("../schemas/v1/vars.schema.json");
17+
static CONFIG_SCHEMA_STR: &str = include_str!("../schemas/v1/config.schema.json");
18+
static ATTEMPTS_SCHEMA_STR: &str = include_str!("../schemas/v1/attempts.schema.json");
19+
static SYNC_SCHEMA_STR: &str = include_str!("../schemas/v1/sync.schema.json");
20+
static PRIMER_SCHEMA_STR: &str = include_str!("../schemas/v1/primer.schema.json");
2121

2222
// Compiled schema validators (lazy initialization)
2323
static CACHE_VALIDATOR: OnceLock<Validator> = OnceLock::new();

0 commit comments

Comments
 (0)