mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-15 13:14:35 +00:00
feat: prompts
This commit is contained in:
@@ -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 })
|
||||
|
||||
Reference in New Issue
Block a user