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