feat: tfcode

This commit is contained in:
Gab
2026-03-28 17:30:08 +11:00
parent 5b9cc6c0de
commit b45da1bc6b
4 changed files with 30 additions and 17 deletions

View File

@@ -79,13 +79,18 @@ export namespace Command {
const log = (msg: string) => {
const timestamp = new Date().toISOString()
const line = `[${timestamp}] ${msg}\n`
Bun.write("/tmp/tfcode-debug.log", line).catch(() => {})
try {
const fs = require("fs")
fs.appendFileSync("/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> = {}
log(`[Command.init] Starting command initialization`)
commands[Default.INIT] = {
name: Default.INIT,
description: "create/update AGENTS.md",
@@ -147,8 +152,14 @@ export namespace Command {
}
}
for (const skill of yield* Effect.promise(() => Skill.all())) {
if (commands[skill.name]) continue
const skills = yield* Effect.promise(() => Skill.all())
log(`[Command.init] Skills loaded: ${skills.length} - ${skills.map((s) => s.name).join(", ")}`)
for (const skill of skills) {
if (commands[skill.name]) {
log(`[Command.init] Skipping skill ${skill.name} - already exists`)
continue
}
log(`[Command.init] Adding skill as command: ${skill.name}`)
commands[skill.name] = {
name: skill.name,
description: skill.description,
@@ -160,6 +171,14 @@ export namespace Command {
}
}
log(`[Command.init] Total commands: ${Object.keys(commands).length}`)
const promptsCmds = Object.values(commands).filter((c) => c.name.toLowerCase().includes("prompt"))
if (promptsCmds.length > 0) {
log(
`[Command.init] Commands with 'prompt' in name: ${promptsCmds.map((c) => `${c.name}(${c.source})`).join(", ")}`,
)
}
return {
commands,
}