Your first plugin
What kcode plugins scaffold gives you: a manifest, a tool, an event hook, and durable storage.
~/.kcode/plugins/hello/
Checked with kcode plugins validate before publishing.
name = "hello"
version = "0.1.0"
description = "What kcode plugins scaffold gives you: a tool, a hook, durable storage"
kind = "Lua"
[capabilities]
kv = true
hooks = true-- Runs when the plugin loads. Everything registered here joins the session.
kcode.register_tool("hello", "Say hello and count how often you did", function(args)
local name = args.name or "world"
local count = tonumber(kcode.kv_get("greetings") or "0") + 1
kcode.kv_set("greetings", tostring(count))
return { text = "Hello, " .. name .. "! Greeting number " .. count }
end)
kcode.on_event("core.app.turn-finished", function(ev)
kcode.log("turn finished (" .. ev.kind .. ")")
end)---
description: Greet the current project by name
---
Use the `hello` tool with the name of the project in the working directory,
then reply with one line.---
name: hello
description: How to greet politely
---
When asked to greet someone, use the `hello` tool once and keep the reply to a single line.