mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-09 18:29:39 +00:00
feat: releases
This commit is contained in:
@@ -58,12 +58,9 @@ function getPythonSyncPath(): string {
|
||||
return "tf_sync"
|
||||
}
|
||||
|
||||
async function runPythonSync(
|
||||
method: string,
|
||||
args: Record<string, unknown> = {},
|
||||
): Promise<unknown> {
|
||||
async function runPythonSync(method: string, args: Record<string, unknown> = {}): Promise<unknown> {
|
||||
const credentials = await loadCredentials()
|
||||
|
||||
|
||||
const pythonCode = `
|
||||
import json
|
||||
import sys
|
||||
@@ -458,8 +455,7 @@ const ToolsCredentialsSetCommand = cmd({
|
||||
const ToolsCommand = cmd({
|
||||
command: "tools",
|
||||
describe: "manage ToothFairyAI tools",
|
||||
builder: (yargs) =>
|
||||
yargs.command(ToolsListCommand).command(ToolsCredentialsSetCommand).demandCommand(),
|
||||
builder: (yargs) => yargs.command(ToolsListCommand).command(ToolsCredentialsSetCommand).demandCommand(),
|
||||
async handler() {},
|
||||
})
|
||||
|
||||
@@ -561,8 +557,106 @@ export const ToolsMainCommand = cmd({
|
||||
command: "tools",
|
||||
describe: "manage ToothFairyAI tools",
|
||||
builder: (yargs) =>
|
||||
yargs.command(ToolsListCommand).command(ToolsCredentialsSetCommand).command(ToolsDebugCommand).command(ToolsTestCommand).demandCommand(),
|
||||
yargs
|
||||
.command(ToolsListCommand)
|
||||
.command(ToolsCredentialsSetCommand)
|
||||
.command(ToolsDebugCommand)
|
||||
.command(ToolsTestCommand)
|
||||
.demandCommand(),
|
||||
async handler() {},
|
||||
})
|
||||
|
||||
export { ValidateCommand, SyncCommand, ToolsCommand }
|
||||
export const SetupCommand = cmd({
|
||||
command: "setup",
|
||||
describe: "configure ToothFairyAI credentials",
|
||||
builder: (yargs) =>
|
||||
yargs
|
||||
.option("api-key", {
|
||||
type: "string",
|
||||
describe: "API key",
|
||||
})
|
||||
.option("workspace-id", {
|
||||
type: "string",
|
||||
describe: "Workspace ID",
|
||||
})
|
||||
.option("region", {
|
||||
type: "string",
|
||||
describe: "Region (dev, au, eu, us)",
|
||||
default: "au",
|
||||
}),
|
||||
handler: async (args) => {
|
||||
const configPath = getConfigPath()
|
||||
const credFile = getCredentialsFilePath()
|
||||
|
||||
// Load existing credentials
|
||||
let existing: { api_key?: string; workspace_id?: string; region?: string } = {}
|
||||
if (await Filesystem.exists(credFile)) {
|
||||
try {
|
||||
existing = await Bun.file(credFile).json()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// Get credentials from args or prompt
|
||||
let apiKey = args["api-key"]
|
||||
let workspaceId = args["workspace-id"]
|
||||
let region = args.region || existing.region || "au"
|
||||
|
||||
if (!apiKey || !workspaceId) {
|
||||
info("")
|
||||
info("ToothFairyAI Credentials Setup")
|
||||
info("━".repeat(40))
|
||||
info("")
|
||||
|
||||
if (!workspaceId) {
|
||||
process.stdout.write(`Workspace ID [${existing.workspace_id || ""}]: `)
|
||||
const input = await new Promise<string>((resolve) => {
|
||||
process.stdin.once("data", (data) => resolve(data.toString().trim()))
|
||||
})
|
||||
workspaceId = input || existing.workspace_id
|
||||
}
|
||||
|
||||
if (!apiKey) {
|
||||
process.stdout.write(`API Key [${existing.api_key ? "****" + existing.api_key.slice(-4) : ""}]: `)
|
||||
const input = await new Promise<string>((resolve) => {
|
||||
process.stdin.once("data", (data) => resolve(data.toString().trim()))
|
||||
})
|
||||
apiKey = input || existing.api_key
|
||||
}
|
||||
|
||||
process.stdout.write(`Region [${region}]: `)
|
||||
const regionInput = await new Promise<string>((resolve) => {
|
||||
process.stdin.once("data", (data) => resolve(data.toString().trim()))
|
||||
})
|
||||
if (regionInput) region = regionInput
|
||||
}
|
||||
|
||||
if (!apiKey || !workspaceId) {
|
||||
printError("API key and workspace ID are required")
|
||||
process.exitCode = 1
|
||||
return
|
||||
}
|
||||
|
||||
// Save credentials
|
||||
await mkdir(configPath, { recursive: true })
|
||||
await Bun.write(
|
||||
credFile,
|
||||
JSON.stringify(
|
||||
{
|
||||
api_key: apiKey,
|
||||
workspace_id: workspaceId,
|
||||
region,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
)
|
||||
|
||||
success(`✓ Credentials saved to ${credFile}`)
|
||||
info(` Workspace: ${workspaceId}`)
|
||||
info(` Region: ${region}`)
|
||||
info("")
|
||||
info("Run 'tfcode validate' to test your credentials")
|
||||
},
|
||||
})
|
||||
|
||||
export { ValidateCommand, SyncCommand, ToolsCommand }
|
||||
|
||||
Reference in New Issue
Block a user