mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-15 13:14:35 +00:00
feat: tfcode
This commit is contained in:
@@ -64,11 +64,20 @@ const TFCODE_CONFIG_DIR = ".tfcode"
|
||||
const TFCODE_TOOLS_FILE = "tools.json"
|
||||
|
||||
function getPythonSyncPath(): string {
|
||||
const possible = [
|
||||
// Check embedded python path first (for npm distribution)
|
||||
const embedded = [
|
||||
path.join(__dirname, "..", "..", "..", "..", "python"), // packages/tfcode/python
|
||||
path.join(__dirname, "..", "..", "..", "python"), // dist/python
|
||||
]
|
||||
for (const p of embedded) {
|
||||
if (existsSync(p)) return p
|
||||
}
|
||||
// Fallback to development paths
|
||||
const dev = [
|
||||
path.join(__dirname, "..", "..", "..", "..", "tf-sync", "src", "tf_sync"),
|
||||
path.join(process.cwd(), "packages", "tf-sync", "src", "tf_sync"),
|
||||
]
|
||||
for (const p of possible) {
|
||||
for (const p of dev) {
|
||||
if (existsSync(p)) return p
|
||||
}
|
||||
return "tf_sync"
|
||||
@@ -76,6 +85,7 @@ function getPythonSyncPath(): string {
|
||||
|
||||
async function runPythonSync(method: string, args: Record<string, unknown> = {}): Promise<unknown> {
|
||||
const credentials = await loadCredentials()
|
||||
const pythonPath = getPythonSyncPath()
|
||||
|
||||
const pythonCode = `
|
||||
import json
|
||||
@@ -83,6 +93,8 @@ import sys
|
||||
import os
|
||||
|
||||
try:
|
||||
# Add embedded tf_sync module path
|
||||
sys.path.insert(0, "${pythonPath.replace(/\\/g, "/")}")
|
||||
from tf_sync.config import load_config, validate_credentials
|
||||
from tf_sync.tools import sync_tools, sync_tools_by_type, ToolType
|
||||
from tf_sync.mcp import sync_mcp_servers
|
||||
|
||||
@@ -16,10 +16,17 @@ export async function upgrade() {
|
||||
|
||||
if (Installation.VERSION === latest) return
|
||||
|
||||
if (config.autoupdate === false || Flag.OPENCODE_DISABLE_AUTOUPDATE) return
|
||||
if (config.autoupdate === false) return
|
||||
|
||||
const kind = Installation.getReleaseType(Installation.VERSION, latest)
|
||||
|
||||
// When auto-upgrade is disabled (e.g. tfcode uses npm for updates),
|
||||
// still notify the user that a new version is available.
|
||||
if (Flag.OPENCODE_DISABLE_AUTOUPDATE) {
|
||||
await Bus.publish(Installation.Event.UpdateAvailable, { version: latest })
|
||||
return
|
||||
}
|
||||
|
||||
if (config.autoupdate === "notify" || kind !== "patch") {
|
||||
await Bus.publish(Installation.Event.UpdateAvailable, { version: latest })
|
||||
return
|
||||
|
||||
@@ -340,17 +340,12 @@ export namespace ProviderTransform {
|
||||
if (
|
||||
id.includes("deepseek") ||
|
||||
id.includes("minimax") ||
|
||||
id.includes("glm") ||
|
||||
id.includes("mistral") ||
|
||||
id.includes("kimi") ||
|
||||
// TODO: Remove this after models.dev data is fixed to use "kimi-k2.5" instead of "k2p5"
|
||||
id.includes("k2p5")
|
||||
)
|
||||
return {}
|
||||
|
||||
// ToothFairyAI doesn't support thinking/reasoning parameters yet
|
||||
if (model.api.npm === "@toothfairyai/sdk") return {}
|
||||
|
||||
// see: https://docs.x.ai/docs/guides/reasoning#control-how-hard-the-model-thinks
|
||||
if (id.includes("grok") && id.includes("grok-3-mini")) {
|
||||
if (model.api.npm === "@openrouter/ai-sdk-provider") {
|
||||
|
||||
Reference in New Issue
Block a user