feat: add generate_topology_block (S2 Phase 1)

Builds mermaid graph-LR source from manifest.deps + engine-calls.
Asset-libs (no deps, no engine) produce self-node-only output.
Per spec section 4.2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Axel Meyer
2026-05-16 13:33:34 +02:00
parent 24bd00ad9c
commit d71ea6df74

View File

@@ -74,4 +74,28 @@ function M.grep_engine_calls(source_string)
return out return out
end end
-- Generates mermaid topology-block from manifest + engine_calls.
-- engine_calls: array from grep_engine_calls (presence determines engine-node).
-- Returns: mermaid-source-string (no markers - caller wraps).
function M.generate_topology_block(manifest, engine_calls)
local lines = {"graph LR"}
local self_node = string.format(' this["%s"]', manifest.id)
table.insert(lines, self_node)
if manifest.deps then
for _, dep in ipairs(manifest.deps) do
local dep_var = string.gsub(dep.id, "[%-%.]", "_")
table.insert(lines, string.format(' %s["%s"]', dep_var, dep.id))
table.insert(lines, string.format(' this --> %s', dep_var))
end
end
if engine_calls and #engine_calls > 0 then
table.insert(lines, ' engine["engine.*"]')
table.insert(lines, ' this --> engine')
end
return table.concat(lines, "\n")
end
return M return M