feat(phase12.7): 糖衣構文Phase 12.7-B完了 + 自律型AI開発システム制御機能
🚀 Phase 12.7-B: ChatGPT5糖衣構文(基本実装完了) - パイプライン演算子(|>)実装 - セーフアクセス(?.)とデフォルト値(??)実装 - sugar gateによる段階的有効化機能 - 糖衣構文テストスイート追加 🤖 自律型AI開発システム改善 - codex-async-notify.sh: タスク制御指示追加 - "下の箱を積み過ぎないように先に進んでください" - "フェーズが終わったと判断したら止まってください" - プロセス数表示機能の改善(count_running_codex_display) - 自動停止機能が正常動作(Phase 12.7-C前で停止確認) 📚 ドキュメント更新 - Paper 13: 自律型AI協調開発システムの革新性を文書化 - ANCP可逆マッピング仕様追加 - nyfmt PoC(フォーマッター)計画追加 🧱 箱理論の体現 - 74k行のコードベース(Phase 15で20k行を目指す) - ANCP適用で最終的に6k行相当を狙う - 世界最小の実用コンパイラへの道 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1
src/syntax/mod.rs
Normal file
1
src/syntax/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod sugar_config;
|
||||
80
src/syntax/sugar_config.rs
Normal file
80
src/syntax/sugar_config.rs
Normal file
@ -0,0 +1,80 @@
|
||||
use std::{env, fs, path::Path};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum SugarLevel { None, Basic, Full }
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SugarConfig { pub level: SugarLevel }
|
||||
|
||||
impl Default for SugarConfig {
|
||||
fn default() -> Self { Self { level: SugarLevel::None } }
|
||||
}
|
||||
|
||||
impl SugarConfig {
|
||||
pub fn from_env_or_toml(path: impl AsRef<Path>) -> Self {
|
||||
// 1) env override
|
||||
if let Ok(s) = env::var("NYASH_SYNTAX_SUGAR_LEVEL") {
|
||||
return Self { level: parse_level(&s) };
|
||||
}
|
||||
// 2) toml [syntax].sugar_level
|
||||
let path = path.as_ref();
|
||||
if let Ok(content) = fs::read_to_string(path) {
|
||||
if let Ok(val) = toml::from_str::<toml::Value>(&content) {
|
||||
if let Some(table) = val.get("syntax").and_then(|v| v.as_table()) {
|
||||
if let Some(level_str) = table.get("sugar_level").and_then(|v| v.as_str()) {
|
||||
return Self { level: parse_level(level_str) };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 3) default
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_level(s: &str) -> SugarLevel {
|
||||
match s.to_ascii_lowercase().as_str() {
|
||||
"basic" => SugarLevel::Basic,
|
||||
"full" => SugarLevel::Full,
|
||||
_ => SugarLevel::None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::env;
|
||||
use tempfile::tempdir;
|
||||
|
||||
#[test]
|
||||
fn env_precedence_over_toml() {
|
||||
let dir = tempdir().unwrap();
|
||||
let file = dir.path().join("nyash.toml");
|
||||
fs::write(&file, "[syntax]\nsugar_level='full'\n").unwrap();
|
||||
env::set_var("NYASH_SYNTAX_SUGAR_LEVEL", "basic");
|
||||
let cfg = SugarConfig::from_env_or_toml(&file);
|
||||
env::remove_var("NYASH_SYNTAX_SUGAR_LEVEL");
|
||||
assert_eq!(cfg.level, SugarLevel::Basic);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn toml_level_when_env_absent() {
|
||||
let dir = tempdir().unwrap();
|
||||
let file = dir.path().join("nyash.toml");
|
||||
fs::write(&file, "[syntax]\nsugar_level='basic'\n").unwrap();
|
||||
let cfg = SugarConfig::from_env_or_toml(&file);
|
||||
assert_eq!(cfg.level, SugarLevel::Basic);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_none_on_missing_or_invalid() {
|
||||
let dir = tempdir().unwrap();
|
||||
let file = dir.path().join("nyash.toml");
|
||||
fs::write(&file, "[syntax]\nsugar_level='unknown'\n").unwrap();
|
||||
let cfg = SugarConfig::from_env_or_toml(&file);
|
||||
assert_eq!(cfg.level, SugarLevel::None);
|
||||
let cfg2 = SugarConfig::from_env_or_toml(dir.path().join("missing.toml"));
|
||||
assert_eq!(cfg2.level, SugarLevel::None);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user