feat: prompts

This commit is contained in:
Gab
2026-03-28 16:48:01 +11:00
parent 3cc0f7401a
commit 5b9cc6c0de
17 changed files with 237 additions and 69 deletions

View File

@@ -4,6 +4,7 @@ import { makeRunPromise } from "@/effect/run-service"
import { SessionID, MessageID } from "@/session/schema"
import { Effect, Layer, ServiceMap } from "effect"
import z from "zod"
import { Agent } from "../agent/agent"
import { Config } from "../config/config"
import { MCP } from "../mcp"
import { Skill } from "../skill"
@@ -75,6 +76,12 @@ export namespace Command {
export const layer = Layer.effect(
Service,
Effect.gen(function* () {
const log = (msg: string) => {
const timestamp = new Date().toISOString()
const line = `[${timestamp}] ${msg}\n`
Bun.write("/tmp/tfcode-debug.log", line).catch(() => {})
}
const init = Effect.fn("Command.state")(function* (ctx) {
const cfg = yield* Effect.promise(() => Config.get())
const commands: Record<string, Info> = {}
@@ -115,6 +122,7 @@ export namespace Command {
}
for (const [name, prompt] of Object.entries(yield* Effect.promise(() => MCP.prompts()))) {
log(`[Command.init] MCP prompt: ${name}`)
commands[name] = {
name,
source: "mcp",
@@ -166,7 +174,13 @@ export namespace Command {
const list = Effect.fn("Command.list")(function* () {
const state = yield* InstanceState.get(cache)
return Object.values(state.commands)
const commands = Object.values(state.commands)
log(`[Command.list] Total commands: ${commands.length}`)
const promptsCmd = commands.find((c) => c.name === "prompts")
if (promptsCmd) {
log(`[Command.list] Found 'prompts' command with source: ${promptsCmd.source}`)
}
return commands
})
return Service.of({ get, list })