codetopo / index.html
ataimlds's picture
Upload 2 files
fb36d81 verified
Raw History Blame Contribute Delete
11.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>codetopo — Agent-Friendly Topology</title>
<style>
:root {
--indigo: #1b1f4b;
--navy: #10243e;
--teal: #0f766e;
--teal-bright: #14a08f;
--cream: #faf6ed;
--paper: #fffdf7;
--ink: #1e2433;
--muted: #5a6070;
--line: #e3dcc9;
}
* { box-sizing: border-box; }
body {
margin: 0;
background: var(--cream);
color: var(--ink);
font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
line-height: 1.6;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 0 20px 48px; }
header {
background: linear-gradient(135deg, var(--indigo), var(--navy));
color: var(--cream);
padding: 44px 20px 36px;
text-align: center;
}
header .mark { font-size: 2.4rem; }
header h1 { margin: 8px 0 6px; font-size: 2rem; letter-spacing: 0.01em; }
header p { margin: 0 auto; max-width: 640px; color: #cfd6ea; }
header p strong { color: #fff; }
section {
background: var(--paper);
border: 1px solid var(--line);
border-radius: 12px;
padding: 22px 26px;
margin: 18px 0;
}
h2 { color: var(--indigo); margin: 0 0 10px; font-size: 1.25rem; }
p { margin: 8px 0; }
ul { margin: 8px 0 8px 4px; padding-left: 22px; }
li { margin: 5px 0; }
a { color: var(--teal); }
.fineprint { color: var(--muted); font-size: 0.9rem; }
.demo-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 6px; }
.demo-row input {
flex: 1 1 320px;
padding: 10px 14px;
font-size: 1rem;
border: 1px solid var(--line);
border-radius: 8px;
background: #fff;
color: var(--ink);
font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
}
.demo-row button {
background: var(--teal);
color: #fff;
border: none;
border-radius: 8px;
padding: 10px 20px;
font-size: 1rem;
cursor: pointer;
}
.demo-row button:hover { background: var(--teal-bright); }
.demo-row button:disabled { background: var(--muted); cursor: wait; }
pre.output {
background: var(--indigo);
color: #eef1ff;
border-radius: 10px;
padding: 16px 18px;
overflow-x: auto;
white-space: pre;
font-size: 0.86rem;
line-height: 1.5;
min-height: 120px;
font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
}
footer {
text-align: center;
color: var(--muted);
font-size: 0.92rem;
padding: 26px 12px 6px;
letter-spacing: 0.02em;
}
</style>
</head>
<body>
<header>
<div class="mark">🕸️</div>
<h1>codetopo — agent-friendly topology</h1>
<p><strong>Agent-friendly topology</strong> — codetopo builds the graph of a
codebase as a surface agents query directly: symbols, calls, blast
radius, proof-checked snapshots, over MCP, API, and CLI. Humans
welcome — see the shape of a repo in the live demo below.</p>
</header>
<div class="wrap">
<section>
<h2>What codetopo does</h2>
<p>codetopo builds the graph of a codebase — files, imports, calls,
dependencies — and answers questions about its shape:</p>
<ul>
<li><strong>Rank</strong> — blast radius, PageRank, betweenness,
closeness, eigenvector and Katz centrality: what matters, and
what breaks.</li>
<li><strong>Topological sort</strong> — a build/reading order, with
cycles reported honestly as cyclic groups instead of being
silently hidden.</li>
<li><strong>Communities</strong> — the clusters the graph actually
forms.</li>
<li><strong>Render</strong> — the graph as data or as an SVG
picture.</li>
</ul>
<p>It sells on three surfaces: a <strong>hosted API</strong>
(<code>codetopo-api.aimlds.org</code>), a <strong>CLI</strong>,
and an <strong>MCP server</strong> (listed on the Official MCP
Registry). Plans: Free · Team US$19/mo · Guardrails US$49/mo
<span class="fineprint">(limits and current pricing are confirmed
on the product site)</span>. Service status:
<a href="https://codetopo.aimlds.org/status" target="_blank" rel="noopener">codetopo.aimlds.org/status</a>.</p>
</section>
<section>
<h2>Connect an agent</h2>
<p>codetopo is listed on the <strong>Official MCP Registry</strong> as
<code>io.github.nrupala/codetopo</code> — &ldquo;code graph for AI
agents&rdquo;. Its MCP server ships as the
<code>codetopo-mcp</code> package on crates.io (stdio transport);
point any MCP client at it:</p>
<pre style="background:#10243e;color:#faf6ed;padding:14px 16px;border-radius:10px;overflow:auto;font-size:13px;line-height:1.5">{
"mcpServers": {
"codetopo": {
"command": "codetopo-mcp",
"args": []
}
}
}</pre>
<p>Prefer a hosted surface? The API runs at
<code>codetopo-api.aimlds.org</code> — keys and plans live on the
product site, never on this page.</p>
</section>
<section>
<h2>Live demo — a model repo's topology</h2>
<p>The same idea at Hugging Face scale: give it any <strong>public
model repo id</strong> and the page fetches the repo's file list
from the Hugging Face API — directly from your browser — and
renders its topology: a tree plus a grouped summary of what the
repo is made of. No API key is used, and only public repos are
read.</p>
<div class="demo-row">
<input id="repo-id" type="text" value="Qwen/Qwen2.5-0.5B-Instruct"
aria-label="Public model repo id" spellcheck="false">
<button id="render-btn" type="button">Render topology</button>
</div>
<pre class="output" id="output">Press “Render topology” to fetch the repo's file list live from the Hugging Face API.</pre>
<p class="fineprint">Output is capped so a huge repo degrades into a
summary instead of a wall of text.</p>
</section>
<section>
<h2>For real codebases</h2>
<p>For your own repositories, private indexes, and the full query
set, use production codetopo through its hosted API, CLI, or MCP
server:
<a href="https://codetopo.aimlds.org/status" target="_blank" rel="noopener">codetopo.aimlds.org/status</a> ·
Company: <a href="https://aimlds.org" target="_blank" rel="noopener">aimlds.org</a>.</p>
</section>
<footer>AIMLDS · 2351485 ALBERTA INC. · aimlds.org</footer>
</div>
<script>
"use strict";
// Mirrors the Gradio demo (app.py) in spaces/codetopo/: same API, same
// classification, same tree rendering, same caps, same error wording.
var HF_API = "https://huggingface.co/api/models/";
var DEFAULT_REPO = "Qwen/Qwen2.5-0.5B-Instruct";
var MAX_TREE_LINES = 250;
var WEIGHT_SUFFIXES = [".safetensors", ".bin", ".gguf", ".pt", ".pth", ".onnx"];
var TOKENIZER_HINTS = ["tokenizer", "vocab", "merges.txt", "special_tokens_map"];
var CONFIG_HINTS = ["config.json", "generation_config", "preprocessor_config"];
var CODE_SUFFIXES = [".py", ".js", ".ts", ".cpp", ".h", ".cu"];
function classify(path) {
var name = path.split("/").pop().toLowerCase();
if (WEIGHT_SUFFIXES.some(function (s) { return name.endsWith(s); })) {
return "weights";
}
if (TOKENIZER_HINTS.some(function (h) { return name.indexOf(h) !== -1; })) {
return "tokenizer";
}
if (CONFIG_HINTS.some(function (h) { return name.indexOf(h) !== -1; }) ||
name.endsWith(".json")) {
return "config";
}
if (name.endsWith(".md")) {
return "docs";
}
if (CODE_SUFFIXES.some(function (s) { return name.endsWith(s); })) {
return "code";
}
return "other";
}
function renderTree(paths) {
var lines = [];
var sorted = paths.slice().sort();
for (var i = 0; i < sorted.length; i++) {
var path = sorted[i];
var depth = path.split("/").length - 1;
var indent = "";
for (var d = 0; d < depth; d++) { indent += " "; }
lines.push(indent + "├─ " + path.split("/").pop());
if (lines.length >= MAX_TREE_LINES) {
lines.push("… (tree truncated at " + MAX_TREE_LINES + " entries)");
break;
}
}
return lines.join("\n");
}
function fmtBucket(bucket) {
var rows = Object.keys(bucket).map(function (k) { return [k, bucket[k]]; });
rows.sort(function (a, b) { return b[1][1] - a[1][1]; });
return rows.map(function (row) {
var name = row[0], count = row[1][0], size = row[1][1];
var padded = (name + " ").slice(0, 22);
var countStr = (" " + count).slice(-4);
var sizeStr = (" " + (size / 1e6).toFixed(1)).slice(-10);
return " " + padded + " " + countStr + " files " + sizeStr + " MB";
}).join("\n");
}
function renderTopology(repoId, files) {
var totalSize = 0;
var byDir = {};
var byClass = {};
files.forEach(function (f) {
var size = f.size || 0;
totalSize += size;
var top = f.path.indexOf("/") !== -1 ? f.path.split("/")[0] : "(root)";
[[byDir, top], [byClass, classify(f.path)]].forEach(function (pair) {
var bucket = pair[0], key = pair[1];
if (!bucket[key]) { bucket[key] = [0, 0]; }
bucket[key][0] += 1;
bucket[key][1] += size;
});
});
return "Topology of " + repoId + "\n" +
files.length + " files · " + (totalSize / 1e6).toFixed(1) + " MB total\n\n" +
"By directory:\n" + fmtBucket(byDir) + "\n\n" +
"By class:\n" + fmtBucket(byClass) + "\n\n" +
"Tree:\n" + renderTree(files.map(function (f) { return f.path; })) + "\n\n" +
"— Rendered live in your browser by the codetopo showcase page. " +
"Production codetopo does this for whole codebases (imports, calls, " +
"blast radius, centrality, build order, cycles) via its API, CLI, " +
"and MCP server: https://codetopo.aimlds.org/status";
}
function fetchRepoFiles(repoId) {
var url = HF_API + repoId.trim() + "?blobs=true";
return fetch(url).then(function (resp) {
if (!resp.ok) {
throw new Error(
"Hugging Face API answered HTTP " + resp.status + " for '" +
repoId + "'. Check the repo id — it must be a public model " +
"repo, e.g. 'Qwen/Qwen2.5-0.5B-Instruct'."
);
}
return resp.json();
}).then(function (data) {
var files = (data.siblings || []).map(function (s) {
return { path: s.rfilename || "", size: (s.size === undefined ? null : s.size) };
});
if (!files.length) {
throw new Error("No files listed for '" + repoId + "'.");
}
return files;
}).catch(function (err) {
if (err instanceof TypeError) {
// fetch() rejects with TypeError on network failure.
throw new Error("Could not reach the Hugging Face API: " + err.message);
}
throw err;
});
}
var input = document.getElementById("repo-id");
var button = document.getElementById("render-btn");
var output = document.getElementById("output");
function run() {
var repoId = (input.value || DEFAULT_REPO).trim() || DEFAULT_REPO;
button.disabled = true;
output.textContent = "Fetching " + repoId + " from the Hugging Face API…";
fetchRepoFiles(repoId).then(function (files) {
output.textContent = renderTopology(repoId, files);
}).catch(function (err) {
output.textContent = err.message;
}).then(function () {
button.disabled = false;
});
}
button.addEventListener("click", run);
input.addEventListener("keydown", function (ev) {
if (ev.key === "Enter") { run(); }
});
run();
</script>
</body>
</html>