Refresh sources #2

Merged
tangent merged 21 commits from refresh_sources into main 2026-09-16 18:01:28 -06:00
Showing only changes of commit 1b7c211aa2 - Show all commits
+6 -39
View File
@@ -6,16 +6,13 @@ local json = utility.require("dkjson")
local file_name = arg[1]
print("---")
print(utility.capture_safe("shasum -p"))
print("---")
local function strip_markdown(text)
local tab = text:split("\n")
table.remove(tab, 1) -- codeblock opening
table.remove(tab, #tab) -- end of codeblock
print(table.concat(tab, "\n"))
end
print("---")
print(utility.capture_safe("shasum -U -t -a 512 test.lua"))
print("---")
local prompt = [[Return JSON: category, tags (array), summary (short)]]
-- local prompt = [[Return YAML: category, tags (array), summary (short)]]
@@ -29,34 +26,4 @@ local file_contents = utility.open(file_name, "r", function(file)
end)
prompt = prompt .. file_contents
local model = "gemma3:4b"
-- local output = utility.capture_safe("ollama run " .. model .. " --nowordwrap " .. prompt:enquote())
-- local embedding_model = "nomic-embed-text"
-- local output = utility.capture_safe("ollama run " .. embedding_model .. " " .. file_contents:enquote())
-- output = output:sub(1, -2) -- strip extra newline from utility.capture_safe
-- strip YAML frontmatter (if present)
-- can error, will return nil & error message
local function strip_frontmatter(text)
local tab = text:split("\n")
if tab[1] == "---" then
table.remove(tab, 1)
while true do
local done = tab[1] == "---"
table.remove(tab, 1)
if done then
return table.concat(tab, "\n")
elseif #tab < 1 then
return nil, "Invalid YAML frontmatter."
end
end
end
return text
end
-- print(output)
print(strip_frontmatter(file_contents))
-- print(strip_markdown(output))