feat: tfcode

This commit is contained in:
Gab
2026-04-04 17:56:41 +11:00
parent ffc99307a8
commit c5af4f99e1
17 changed files with 643 additions and 10 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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") {