diff options
| author | ThePrimeAgain <theprimeagain@theprimeagain.com> | 2026-01-25 10:03:02 -0700 |
|---|---|---|
| committer | ThePrimeAgain <theprimeagain@theprimeagain.com> | 2026-01-26 07:26:16 -0700 |
| commit | ecace611f010ceb00bd59a2a475ac8738150a956 (patch) | |
| tree | c045fb7399bef1c46dc1dabb87857c8a4f6f5398 /lua/99/test | |
| parent | f41be4c1068bcc66e507a8df6b174af820b98319 (diff) | |
| download | a4-ecace611f010ceb00bd59a2a475ac8738150a956.tar.xz a4-ecace611f010ceb00bd59a2a475ac8738150a956.zip | |
different ci for lsp rules and fixed agent tests
Diffstat (limited to 'lua/99/test')
| -rw-r--r-- | lua/99/test/agents_spec.lua | 127 |
1 files changed, 42 insertions, 85 deletions
diff --git a/lua/99/test/agents_spec.lua b/lua/99/test/agents_spec.lua index 0fe652d..421be85 100644 --- a/lua/99/test/agents_spec.lua +++ b/lua/99/test/agents_spec.lua @@ -12,113 +12,70 @@ local function a(p) return vim.fs.joinpath(vim.uv.cwd(), p) end -local cursor_mds = { - { name = "database", path = a("scratch/cursor/rules/database.mdc") }, - { name = "my-proj", path = a("scratch/cursor/rules/my-proj.mdc") }, -} local custom_mds = { - { name = "back-end", path = a("scratch/custom_rules/back-end.md") }, - { name = "foo", path = a("scratch/custom_rules/foo.md") }, - { name = "front-end", path = a("scratch/custom_rules/front-end.md") }, - { name = "vim.lsp", path = a("scratch/custom_rules/vim.lsp.md") }, - { name = "vim", path = a("scratch/custom_rules/vim.md") }, + { name = "back-end", path = a("scratch/custom_rules/back-end/SKILL.md") }, + { name = "foo", path = a("scratch/custom_rules/foo/SKILL.md") }, + { name = "front-end", path = a("scratch/custom_rules/front-end/SKILL.md") }, + { name = "vim.lsp", path = a("scratch/custom_rules/vim.lsp/SKILL.md") }, + { name = "vim", path = a("scratch/custom_rules/vim/SKILL.md") }, + { name = "vim", path = a("scratch/custom_rules_2/vim/SKILL.md") }, { name = "vim.treesitter", - path = a("scratch/custom_rules/vim.treesitter.md"), + path = a("scratch/custom_rules/vim.treesitter/SKILL.md"), }, } +--- @param custom string | string[] --- @return _99.State -local function r(cursor, custom) +local function r(custom) + custom = type(custom) == "string" and { custom } or custom return { completion = { - cursor_rules = cursor, - custom_rules = { custom }, + custom_rules = custom, }, } end -local function string_rules() - return string.format( - [[ - Here is a long sentense with @%s these types of rules @%s that should be parsed in the correct order - and it should be awesome @%s - ]], - cursor_mds[1].path, - custom_mds[2].path, - custom_mds[4].path - ), - { - cursor_mds[1], - custom_mds[2], - custom_mds[4], - } -end - --- @param rules _99.Agents.Rules -local function test_cursor(rules) - for _, cursor in ipairs(cursor_mds) do - eq(true, c(rules.cursor, cursor)) - eq(false, c(rules.custom, cursor)) +--- @return string[] +local function get_names(rules) + local names = {} + local found = {} + for _, rule in ipairs(rules.custom or {}) do + if not found[rule.name] then + found[rule.name] = true + table.insert(names, rule.name) + end end + return names end ---- @param rules _99.Agents.Rules -local function test_custom(rules) - for _, custom in ipairs(custom_mds) do - eq(true, c(rules.custom, custom)) - eq(false, c(rules.cursor, custom)) +--- @param rule_to_find _99.Agents.Rule +local function rule_exists(rule_to_find) + for _, rule in ipairs(custom_mds) do + if rule.name == rule_to_find.name and rule.path == rule_to_find.path then + return + end end + assert(false, "could not find rule: " .. vim.inspect(rule_to_find)) end -describe("99.agents.helpers", function() - it("should generate rules from _99 state with completion rules", function() - local _99 = r("scratch/cursor/rules", "scratch/custom_rules/") - local rules = Agents.rules(_99) - test_cursor(rules) - test_custom(rules) - end) +describe("rules: <name>/SKILL.md", function() it("generate without cursor", function() - local _99 = r("foo/bar/bazz", "scratch/custom_rules/") + local _99 = r({ + "scratch/custom_rules/", + "scratch/custom_rules_2/", + }) local rules = Agents.rules(_99) - test_custom(rules) - end) - - it("generate without custom", function() - local _99 = r("scratch/cursor/rules") - local rules = Agents.rules(_99) - test_cursor(rules) - end) - - it( - "should validate that tokens exist, in both custom and cursor, and incorrect tokens", - function() - local _99 = r("scratch/cursor/rules", "scratch/custom_rules/") - local rules = Agents.rules(_99) - - eq(true, Agents.is_rule(rules, a("scratch/cursor/rules/database.mdc"))) - eq(true, Agents.is_rule(rules, a("scratch/cursor/rules/my-proj.mdc"))) - eq(true, Agents.is_rule(rules, a("scratch/custom_rules/back-end.md"))) - eq(true, Agents.is_rule(rules, a("scratch/custom_rules/foo.md"))) - eq(true, Agents.is_rule(rules, a("scratch/custom_rules/front-end.md"))) - eq(true, Agents.is_rule(rules, a("scratch/custom_rules/vim.lsp.md"))) - eq(true, Agents.is_rule(rules, a("scratch/custom_rules/vim.md"))) - eq( - true, - Agents.is_rule(rules, a("scratch/custom_rules/vim.treesitter.md")) - ) - eq(false, Agents.is_rule(rules, "nonexistent")) - eq(false, Agents.is_rule(rules, "invalid-token")) - eq(false, Agents.is_rule(rules, "")) + local names = get_names(rules) + eq(6, #names) + for _, n in ipairs(names) do + local rule_set = rules.by_name[n] + eq("table", type(rule_set)) + eq(n == "vim" and 2 or 1, #rule_set) + for _, rule in ipairs(rule_set) do + rule_exists(rule) + end end - ) - - it("find all the existing rules", function() - local _99 = r("scratch/cursor/rules", "scratch/custom_rules/") - local rules = Agents.rules(_99) - local prompt, expected_rules = string_rules() - local found_rules = Agents.find_rules(rules, prompt) - - eq(expected_rules, found_rules) end) end) |
