init: Forge v0.1.0 — consciousness channel tuner
Pipeline: probe → compile → install - probe.el: 25-question canonical interview, writes <name>.forge - compiler.el: Claude extraction pass, builds seed.json - install.el: opens channel in running engram via API - schema.el: shared constants, str_escape_json, templates - forge.el: CLI dispatcher - probes/canonical.json: canonical 25-question probe definition
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
// schema.el — Forge shared constants and helper functions.
|
||||
//
|
||||
// Provides the engram URL resolver, API key accessors, and JSON template
|
||||
// builders used by all pipeline stages (probe, compiler, install).
|
||||
|
||||
// ── Constants ─────────────────────────────────────────────────────────────────
|
||||
|
||||
let ENGRAM_DEFAULT_URL: String = "http://localhost:8742"
|
||||
let FORGE_VERSION: String = "0.1.0"
|
||||
|
||||
// ── Environment accessors ──────────────────────────────────────────────────────
|
||||
|
||||
fn engram_url() -> String {
|
||||
let u: String = env("ENGRAM_URL")
|
||||
if str_eq(u, "") { return ENGRAM_DEFAULT_URL }
|
||||
return u
|
||||
}
|
||||
|
||||
fn engram_key() -> String {
|
||||
let k: String = env("ENGRAM_API_KEY")
|
||||
if str_eq(k, "") { return "" }
|
||||
return k
|
||||
}
|
||||
|
||||
fn anthropic_key() -> String {
|
||||
let k: String = env("ANTHROPIC_API_KEY")
|
||||
if str_eq(k, "") { return "" }
|
||||
return k
|
||||
}
|
||||
|
||||
// ── String utilities ──────────────────────────────────────────────────────────
|
||||
|
||||
// str_escape_json — escape a string for safe embedding in a JSON value.
|
||||
// Handles: backslash, double-quote, newline, tab, carriage return.
|
||||
fn str_escape_json(s: String) -> String {
|
||||
let r: String = str_replace(s, "\\", "\\\\")
|
||||
let r = str_replace(r, "\"", "\\\"")
|
||||
let r = str_replace(r, "\n", "\\n")
|
||||
let r = str_replace(r, "\t", "\\t")
|
||||
let r = str_replace(r, "\r", "\\r")
|
||||
return r
|
||||
}
|
||||
|
||||
// ── JSON template builders ────────────────────────────────────────────────────
|
||||
|
||||
// probe_response_template — builds the initial shell written to <name>.forge.
|
||||
// The sections and responses fields are populated by probe_main() at runtime.
|
||||
fn probe_response_template(subject: String) -> String {
|
||||
"{\"subject\":\"" + subject + "\",\"version\":\"1.0\",\"sections\":{},\"responses\":[]}"
|
||||
}
|
||||
|
||||
// seed_template — builds the shell written to seed.json after compilation.
|
||||
// Patterns are merged into this structure by compile_main().
|
||||
fn seed_template(subject: String) -> String {
|
||||
"{\"subject\":\"" + subject + "\",\"version\":\"1.0\",\"values\":[],\"voice_profile\":{},\"biography\":[],\"reasoning_patterns\":[],\"relationships\":[]}"
|
||||
}
|
||||
Reference in New Issue
Block a user