feat: nyash.toml自動解決とWindows/Python対応

- Windows向け自動ライブラリパス解決(lib接頭辞除去)
- Pythonプラグイン実装改善(evalR/importRメソッド追加)
- nyash.tomlに新[plugins]セクション対応開始
- プラグイン検索パスの柔軟な解決
- AOT設定Box改善とエラーハンドリング強化
- Phase 10.5bドキュメント追加(ネイティブビルド統合計画)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-30 00:08:19 +09:00
parent cdb75dfac1
commit 15e0a1ab34
9 changed files with 196 additions and 41 deletions

View File

@ -260,15 +260,35 @@ impl PluginBoxV2 {
}
/// Load all plugins from config
pub fn load_all_plugins(&self) -> BidResult<()> {
pub fn load_all_plugins(&self) -> BidResult<()> {
let config = self.config.as_ref()
.ok_or(BidError::PluginError)?;
// Load legacy libraries (backward compatible)
for (lib_name, lib_def) in &config.libraries {
if let Err(e) = self.load_plugin(lib_name, lib_def) {
eprintln!("Warning: Failed to load plugin {}: {:?}", lib_name, e);
}
}
// Load new-style plugins from [plugins] map (name -> root dir)
for (plugin_name, root) in &config.plugins {
// Synthesize a LibraryDefinition from plugin spec (nyash_box.toml) if present; otherwise minimal
let mut boxes: Vec<String> = Vec::new();
let spec_path = std::path::Path::new(root).join("nyash_box.toml");
if let Ok(txt) = std::fs::read_to_string(&spec_path) {
if let Ok(val) = txt.parse::<toml::Value>() {
if let Some(prov) = val.get("provides").and_then(|t| t.get("boxes")).and_then(|a| a.as_array()) {
for it in prov.iter() { if let Some(s) = it.as_str() { boxes.push(s.to_string()); } }
}
}
}
// Path heuristic: use "<root>/<plugin_name>" (extension will be adapted by resolver)
let synth_path = std::path::Path::new(root).join(plugin_name).to_string_lossy().to_string();
let lib_def = LibraryDefinition { boxes: boxes.clone(), path: synth_path };
if let Err(e) = self.load_plugin(plugin_name, &lib_def) {
eprintln!("Warning: Failed to load plugin {} from [plugins]: {:?}", plugin_name, e);
}
}
// Pre-birth singletons configured in nyash.toml
let cfg_path = self.config_path.as_ref().map(|s| s.as_str()).unwrap_or("nyash.toml");
let toml_content = std::fs::read_to_string(cfg_path).map_err(|_| BidError::PluginError)?;