Foundation models keep getting stronger, yet they still stall on the same thing: context. Model This
Google Cloud introduced the Open Knowledge Format (OKF), an open specification that formalizes the LLM-wiki pattern into a portable, interoperable format. The
Open Knowledge Format (OKF)
OKF is a format, not a service or a platform. OKF v0.1 represents knowledge as a directory of markdown files with YAML frontmatter. With
This The Bun The
The OK
// tiny markdown -> html (headings, tables, inline code, links)
function mdToHtml(md){
var lines = md.split(“n”), out = [], i = 0;
while(i “+inline(ln.replace(/^#s/,””))+””); i++; continue; }
if(/^##s/.test(ln)){ out.push(“
“+inline(ln.replace(/^##s/,””))+”
“); i++; continue; }
if(/^|/.test(ln)){
var tbl = []; while(i “+inline(lines[i].replace(/^-s/,””))+””); i++; }
out.push(“”); continue;
}
if(ln.trim()===””){ i++; continue; }
out.push(“
“+inline(ln)+”
“); i++;
}
return out.join(“”);
}
function renderTable(rows){
var cells = rows.map(function(r){ return r.replace(/^|||$/g,””).split(“|”).map(function(c){return c.trim();}); });
var head = cells[0], body = cells.slice(2);
var h = “
“;}).join(“”)+”
“;
var b = body.map(function(r){ return “
“;}).join(“”)+”
“; }).join(“”);
return “”;
}
function inline(s){
s = esc(s);
s = s.replace(/`([^`]+)`/g,’$1‘);
s = s.replace(/[([^]]+)]((/[^)]+.md))/g, function(_,t,href){
return ‘‘+t+’‘;
});
return s;
}
// —- tree —-
function buildTree(){
var t = document.getElementById(‘okf-tree’); t.innerHTML = “”;
var dirs = {};
ORDER.forEach(function(p) []).push(p);
);
// root files first
(dirs[“”]||[]).forEach(function(p){ t.appendChild(fileNode(p,0)); });
Object.keys(dirs).forEach(function(d){
if(d===””) return;
var dn = document.createElement(‘div’);
dn.className = “okf-node okf-dirname”;
dn.innerHTML = ‘[dir] ‘+d+”/”;
t.appendChild(dn);
dirs[d].forEach(function(p){ t.appendChild(fileNode(p,1)); });
});
markTree();
}
function fileNode(p, depth){
var n = document.createElement(‘div’);
n.className = “okf-node”; n.dataset.path = p;
var name = p.split(“/”).pop();
n.innerHTML = (depth?’└─ ‘:”)+’● ‘+name;
n.addEventListener(‘click’, function(){ select(p); });
return n;
}
function markTree(){
root.querySelectorAll(‘.okf-node[data-path]’).forEach(function(n){
n.classList.toggle(‘okf-sel’, n.dataset.path === current);
});
}
// —- render concept —-
function renderConcept(){
var c = BUNDLE[current]; if(!c) return;
var fm = document.getElementById(‘okf-fm’); fm.innerHTML = “”;
var keys = [“type”,”title”,”description”,”resource”,”tags”,”timestamp”];
keys.forEach(function(k){
if(c.fm[k]===undefined) return;
var row = document.createElement(‘div’); row.className = “okf-fmrow”;
var val = c.fm[k];
var valHtml;
if(k===”tags” && Array.isArray(val)){
valHtml = val.map(function(tg){return ‘‘+esc(tg)+’‘;}).join(“”);
} else { valHtml = esc(val); }
row.innerHTML = ‘‘+k+’‘+valHtml+’‘;
fm.appendChild(row);
});
document.getElementById(‘okf-doc’).innerHTML = mdToHtml(c.body);
// raw view
document.getElementById(‘okf-raw’).textContent = rawOf(current);
bindXlinks();
}
function rawOf(p){
var c = BUNDLE[p], fm = c.fm, out = “—n”;
[“type”,”title”,”description”,”resource”,”tags”,”timestamp”].forEach(function(k){
if(fm[k]===undefined) return;
var v = Array.isArray(fm[k]) ? “[“+fm[k].join(“, “)+”]” : fm[k];
out += k+”: “+v+”n”;
});
out += “—nn”+c.body+”n”;
return out;
}
function bindXlinks(){
root.querySelectorAll(‘.okf-xlink’).forEach(function(a){
a.addEventListener(‘click’, function(){ if(BUNDLE[a.dataset.go]) select(a.dataset.go); });
});
}
// —- graph —-
var POS = {
“/index.md”:[260,50],
“/datasets/orders_db.md”:[110,150],
“/tables/orders.md”:[260,200],
“/tables/customers.md”:[410,150],
“/metrics/weekly_active_users.md”:[260,320]
};
function edges(){
var e = [];
ORDER.forEach(function(p){
var b = BUNDLE[p].body, m, re = /((/[^)]+.md))/g;
var seen = {};
while((m = re.exec(b))){ var tgt = m[1]; if(POS[tgt] && tgt!==p && !seen[tgt]){ seen[tgt]=1; e.push([p,tgt]); } }
});
return e;
}
function buildGraph(){
var svg = document.getElementById(‘okf-graph’); svg.innerHTML = “”;
var ns = “http://www.w3.org/2000/svg”;
edges().forEach(function(pair){
var a = POS[pair[0]], b = POS[pair[1]];
var ln = document.createElementNS(ns,’line’);
ln.setAttribute(‘x1’,a[0]); ln.setAttribute(‘y1’,a[1]);
ln.setAttribute(‘x2’,b[0]); ln.setAttribute(‘y2’,b[1]);
ln.setAttribute(‘class’,’okf-edge’);
ln.dataset.a = pair[0]; ln.dataset.b = pair[1];
svg.appendChild(ln);
});
ORDER.forEach(function(p){
var pos = POS[p];
var g = document.createElementNS(ns,’g’); g.setAttribute(‘class’,’okf-gn’); g.dataset.path = p;
var ci = document.createElementNS(ns,’circle’);
ci.setAttribute(‘cx’,pos[0]); ci.setAttribute(‘cy’,pos[1]); ci.setAttribute(‘r’,22);
var tx = document.createElementNS(ns,’text’);
tx.setAttribute(‘x’,pos[0]); tx.setAttribute(‘y’,pos[1]+36); tx.setAttribute(’text-anchor’,’middle’);
tx.textContent = p.split(“/”).pop().replace(“.md”,””);
g.appendChild(ci); g.appendChild(tx);
g.addEventListener(‘click’, function(){ select(p); });
svg.appendChild(g);
});
markGraph();
}
function markGraph(){
root.querySelectorAll(‘.okf-gn’).forEach(function(g){
g.classList.toggle(‘okf-gsel’, g.dataset.path === current);
});
root.querySelectorAll(‘.okf-edge’).forEach(function(e) e.dataset.b === current);
);
}
// —- select / tabs —-
function select(p){ current = p; renderConcept(); markTree(); markGraph(); }
root.querySelectorAll(‘.okf-tab’).forEach(function(tab){
tab.addEventListener(‘click’, function(){
root.querySelectorAll(‘.okf-tab’).forEach(function(t){ t.classList.remove(‘okf-active’); });
tab.classList.add(‘okf-active’);
var v = tab.dataset.view;
root.querySelectorAll(‘.okf-pane’).forEach(function(pn){
pn.classList.toggle(‘okf-pane-on’, pn.dataset.pane === v);
});
});
});
// —- init —-
buildTree(); renderConcept(); buildGraph();
})();

