优化skill
CI / Select checks (push) Has been cancelled
CI / Format and repository checks (push) Has been cancelled
CI / Compile RISC-V (manual) (push) Has been cancelled
Docker / image (push) Has been cancelled
Generated files / Regenerate and commit (push) Has been cancelled
Kernel rig / Select the rig areas (push) Has been cancelled
Lists / Design format changes merge cleanly (push) Has been cancelled
Lists / Lists are sorted one item per line (push) Has been cancelled
Packaging lint / lint (push) Has been cancelled
Pages / build (push) Has been cancelled
CI / Dependency advisories (push) Has been cancelled
CI / Quick compile (push) Has been cancelled
CI / Native Linux Clippy (push) Has been cancelled
CI / Build tests (push) Has been cancelled
CI / Native Linux tests (push) Has been cancelled
CI / GPU path tests (1/4) (push) Has been cancelled
CI / GPU path tests (2/4) (push) Has been cancelled
CI / GPU path tests (3/4) (push) Has been cancelled
CI / GPU path tests (4/4) (push) Has been cancelled
CI / Action matrix (1/16) (push) Has been cancelled
CI / Action matrix (10/16) (push) Has been cancelled
CI / Action matrix (11/16) (push) Has been cancelled
CI / Action matrix (12/16) (push) Has been cancelled
CI / Action matrix (13/16) (push) Has been cancelled
CI / Action matrix (14/16) (push) Has been cancelled
CI / Action matrix (15/16) (push) Has been cancelled
CI / Action matrix (16/16) (push) Has been cancelled
CI / Action matrix (2/16) (push) Has been cancelled
CI / Action matrix (3/16) (push) Has been cancelled
CI / Action matrix (4/16) (push) Has been cancelled
CI / Action matrix (5/16) (push) Has been cancelled
CI / Action matrix (6/16) (push) Has been cancelled
CI / Action matrix (7/16) (push) Has been cancelled
CI / Action matrix (8/16) (push) Has been cancelled
CI / Action matrix (9/16) (push) Has been cancelled
CI / Action matrix determinism (push) Has been cancelled
CI / Property tests (many cases) (push) Has been cancelled
CI / Doc tests (push) Has been cancelled
CI / Reference tests (push) Has been cancelled
CI / Windows D3D12 FXC shaders (push) Has been cancelled
CI / Windows app startup (push) Has been cancelled
CI / ci (push) Has been cancelled
CI / Compile WebAssembly (push) Has been cancelled
CI / Nightly alert (push) Has been cancelled
Kernel rig / Build the CLI (push) Has been cancelled
Kernel rig / Kernel rig (${{ matrix.shard }}) (push) Has been cancelled
Kernel rig / kernel-rig (push) Has been cancelled
Pages / deploy (push) Has been cancelled

This commit is contained in:
2026-11-16 11:32:34 +08:00
parent 2cdf535fd1
commit 678058c940
76 changed files with 3937 additions and 707 deletions
+64
View File
@@ -0,0 +1,64 @@
//! Embed the complete, sorted skill library without runtime filesystem access.
use std::{
env,
error::Error,
fs,
path::{Path, PathBuf},
};
fn files(directory: &Path) -> Result<Vec<PathBuf>, Box<dyn Error>> {
let mut result = Vec::new();
for entry in fs::read_dir(directory)? {
let entry = entry?;
let kind = entry.file_type()?;
if kind.is_symlink() {
return Err(format!("Skill resources may not be symlinks: {}", entry.path().display()).into());
}
if kind.is_dir() {
result.extend(files(&entry.path())?);
} else if kind.is_file() {
result.push(entry.path());
}
}
result.sort();
Ok(result)
}
pub fn generate() -> Result<(), Box<dyn Error>> {
let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?).join("../../skills").canonicalize()?;
println!("cargo:rerun-if-changed={}", root.display());
let mut folders = fs::read_dir(&root)?.collect::<Result<Vec<_>, _>>()?;
folders.sort_by_key(|entry| entry.file_name());
let mut output = String::from("const SKILLS: &[Skill] = &[\n");
let mut catalog = Vec::new();
for entry in folders {
let folder = entry.path();
if !entry.file_type()?.is_dir() || !folder.join("SKILL.md").is_file() {
continue;
}
let name = entry.file_name().to_string_lossy().into_owned();
let text = fs::read_to_string(folder.join("SKILL.md"))?;
let description = text
.lines()
.find_map(|line| line.strip_prefix("description: "))
.ok_or_else(|| format!("Missing skill description: {name}"))?
.trim_matches('"');
output.push_str(&format!("Skill {{ name: {name:?}, description: {description:?}, files: &[\n"));
let paths = files(&folder)?;
let mut names = Vec::new();
for path in paths {
let relative = path.strip_prefix(&folder)?.to_string_lossy().replace('\\', "/");
names.push(relative.clone());
// Include only text resources. A new non-text asset must get an explicit transport.
fs::read_to_string(&path)?;
output.push_str(&format!("({relative:?}, include_str!({path:?})),\n"));
}
output.push_str("] },\n");
catalog.push(format!("- {name}: {description} Files: {}", names.join(", ")));
}
output.push_str("];\n");
let out = PathBuf::from(env::var("OUT_DIR")?);
fs::write(out.join("skills.rs"), output)?;
fs::write(out.join("skill_catalog.rs"), format!("const AGENT_SKILL_CATALOG: &str = {:?};\n", catalog.join("\n")))?;
Ok(())
}
+1 -1
View File
@@ -43,7 +43,7 @@ EMBEDDED = {
}
# Folders that only some packages read: the UI embeds the catalogs and xtask checks them; the MCP
# server's tests read the agent skills.
EMBEDDED_PREFIXES = {"assets/locales/": ("solidcraft-ui-egui", "xtask"), "skills/": ("solidcraft-mcp",)}
EMBEDDED_PREFIXES = {"assets/locales/": ("solidcraft-ui-egui", "xtask"), "skills/": ("solidcraft-mcp", "solidcraft-ui-egui", "xtask")}
# Test data and the package directories whose tests (or xtask) read it. Any other folder under
# tests/ selects the full workspace.
TEST_DATA = {
+1 -1
View File
@@ -127,7 +127,7 @@ class RealWorkspace(unittest.TestCase):
def test_embedded_root_files_select_their_crate(self):
for path, pkg in [("ATTRIBUTION.md", "solidcraft-ui-egui"), ("LICENSE-MIT", "solidcraft-engine"),
("NOTICE", "solidcraft-engine"), ("THIRD-PARTY-LICENSES.txt", "solidcraft-engine"),
("skills/solidcraft-modeling/SKILL.md", "solidcraft-mcp")]:
("skills/makecad-modeling/SKILL.md", "solidcraft-mcp")]:
full, pk = affected.select(self.meta, [path])
self.assertFalse(full, path)
self.assertIn(pkg, pk, path)
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env node
// One source for native MCP, desktop, WASM and the packaged Java model gateway.
import { createHash } from 'node:crypto';
import { readFileSync, readdirSync, lstatSync, writeFileSync, mkdirSync } from 'node:fs';
import { resolve, dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const args = process.argv.slice(2);
if (args.some((arg) => arg.startsWith('--') && arg !== '--check')) throw new Error('Unknown option. Usage: node scripts/sync-cad-ai-skills.mjs [--check] <community-root>');
const check = args.includes('--check');
const paths = args.filter((arg) => arg !== '--check');
if (paths.length !== 1) throw new Error('Usage: node scripts/sync-cad-ai-skills.mjs [--check] <community-root>');
const communityRoot = resolve(paths[0]);
if (!readFileSync(join(communityRoot, 'pom.xml'), 'utf8').includes('<artifactId>vibemake</artifactId>')) throw new Error('Target must be the community Maven project root');
const skillsRoot = join(root, 'skills');
const walk = (folder, prefix = '') => readdirSync(folder).sort().flatMap((name) => {
const path = join(folder, name), relative = prefix + name, stat = lstatSync(path);
if (stat.isSymbolicLink()) throw new Error(`Skill resource is a symlink: ${relative}`);
return stat.isDirectory() ? walk(path, relative + '/') : [[relative, readFileSync(path, 'utf8')]];
});
const skills = readdirSync(skillsRoot).sort().filter((name) => lstatSync(join(skillsRoot, name)).isDirectory()).map((name) => {
const files = Object.fromEntries(walk(join(skillsRoot, name)));
const entry = files['SKILL.md'];
if (!entry) throw new Error(`Missing SKILL.md: ${name}`);
const declared = entry.match(/^name:\s*(.+)$/m)?.[1];
const description = entry.match(/^description:\s*(.+)$/m)?.[1].replace(/^"|"$/g, '');
if (declared !== name || !description || !/^makecad-[a-z-]+$/.test(name)) throw new Error(`Invalid skill metadata: ${name}`);
if (Object.values(files).some((text) => text.includes('Solid' + 'Craft'))) throw new Error(`Legacy display name in ${name}`);
return { name, description, files };
});
const source = { formatVersion: 1, workflow: readFileSync(join(skillsRoot, 'agent-workflow.md'), 'utf8'), skills };
const revision = createHash('sha256').update(JSON.stringify(source)).digest('hex');
const bundle = JSON.stringify({ ...source, revision }, null, 2) + '\n';
const target = resolve(communityRoot, 'vibemake-service/src/main/resources/cad/ai/skills.json');
if (check) {
if (readFileSync(target, 'utf8') !== bundle) throw new Error('Packaged skills differ from the MCP/desktop source. Run the sync command before building.');
} else {
mkdirSync(dirname(target), { recursive: true });
writeFileSync(target, bundle);
}
console.log(`${check ? 'Verified' : 'Synchronized'} ${skills.length} skills, revision ${revision}`);