gufi-cli 0.1.48 → 0.1.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp.js +68 -24
- package/package.json +1 -1
package/dist/mcp.js
CHANGED
|
@@ -941,25 +941,9 @@ Examples:
|
|
|
941
941
|
},
|
|
942
942
|
},
|
|
943
943
|
// ─────────────────────────────────────────────────────────────────────────
|
|
944
|
-
// Packages (
|
|
944
|
+
// 💜 DISABLED: Packages (not actively used, keeping MCP simple)
|
|
945
945
|
// ─────────────────────────────────────────────────────────────────────────
|
|
946
|
-
|
|
947
|
-
name: "gufi_package",
|
|
948
|
-
description: getDesc("gufi_package"),
|
|
949
|
-
inputSchema: {
|
|
950
|
-
type: "object",
|
|
951
|
-
properties: {
|
|
952
|
-
action: { type: "string", description: "Action: list, get, create, delete, add_module, remove_module, publish" },
|
|
953
|
-
id: { type: "string", description: "Package ID (for get, delete, add_module, remove_module, publish)" },
|
|
954
|
-
name: { type: "string", description: "Package name (for create)" },
|
|
955
|
-
description: { type: "string", description: "Package description (for create)" },
|
|
956
|
-
module_id: { type: "string", description: "Module ID (for add_module, remove_module)" },
|
|
957
|
-
company_id: { type: "string", description: "Source company ID (for add_module)" },
|
|
958
|
-
env: ENV_PARAM,
|
|
959
|
-
},
|
|
960
|
-
required: ["action"],
|
|
961
|
-
},
|
|
962
|
-
},
|
|
946
|
+
// gufi_package → Re-enable when marketplace packages become priority
|
|
963
947
|
];
|
|
964
948
|
// ════════════════════════════════════════════════════════════════════════════
|
|
965
949
|
// Tool Handlers
|
|
@@ -1858,9 +1842,18 @@ const toolHandlers = {
|
|
|
1858
1842
|
}
|
|
1859
1843
|
else {
|
|
1860
1844
|
// 💜 Web: Save to Claude Workspace BD
|
|
1845
|
+
// Get latest snapshot for version tracking
|
|
1846
|
+
let latestSnapshot;
|
|
1847
|
+
try {
|
|
1848
|
+
const snapshotResp = await apiRequest(`/api/marketplace/views/${viewId}/latest-snapshot`, {}, companyId, true, env);
|
|
1849
|
+
latestSnapshot = snapshotResp.latest_snapshot;
|
|
1850
|
+
}
|
|
1851
|
+
catch {
|
|
1852
|
+
// If endpoint not available, continue without snapshot tracking
|
|
1853
|
+
}
|
|
1861
1854
|
const saveResponse = await apiRequest(`/api/claude/workspace/view`, {
|
|
1862
1855
|
method: "POST",
|
|
1863
|
-
body: JSON.stringify({ view_id: viewId, files }),
|
|
1856
|
+
body: JSON.stringify({ view_id: viewId, files, snapshot: latestSnapshot, company_id: companyId }),
|
|
1864
1857
|
}, companyId, true, env);
|
|
1865
1858
|
const saveResult = saveResponse.data || saveResponse;
|
|
1866
1859
|
const viewFolder = saveResult?.folder || `views/view_${viewId}`;
|
|
@@ -1872,14 +1865,27 @@ const toolHandlers = {
|
|
|
1872
1865
|
local_path: `~/workspace/${viewFolder}`,
|
|
1873
1866
|
storage: "workspace",
|
|
1874
1867
|
files_count: files.length,
|
|
1875
|
-
_hint: `📥 View downloaded to Claude Workspace. Use Read/Edit tools to modify files. Then gufi_view_push({ view_id: ${viewId} }) to upload.`,
|
|
1868
|
+
_hint: `📥 View downloaded to Claude Workspace. Use Read/Edit tools to modify files. Then gufi_view_push({ view_id: ${viewId}, company_id: '${companyId}' }) to upload.`,
|
|
1876
1869
|
};
|
|
1877
1870
|
}
|
|
1878
1871
|
},
|
|
1879
1872
|
async gufi_view_push(params) {
|
|
1880
1873
|
const viewId = params.view_id;
|
|
1874
|
+
let companyId = params.company_id;
|
|
1881
1875
|
const env = params.env;
|
|
1882
1876
|
const useLocal = canWriteLocal();
|
|
1877
|
+
// 💜 Try to get company_id from view metadata if not provided
|
|
1878
|
+
if (!companyId && viewId && useLocal) {
|
|
1879
|
+
const metaPath = path.join(LOCAL_VIEWS_DIR, `view_${viewId}`, ".gufi-view.json");
|
|
1880
|
+
if (fs.existsSync(metaPath)) {
|
|
1881
|
+
try {
|
|
1882
|
+
const meta = JSON.parse(fs.readFileSync(metaPath, "utf-8"));
|
|
1883
|
+
if (meta.company_id)
|
|
1884
|
+
companyId = String(meta.company_id);
|
|
1885
|
+
}
|
|
1886
|
+
catch { /* ignore */ }
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1883
1889
|
if (!viewId) {
|
|
1884
1890
|
throw new Error("view_id is required");
|
|
1885
1891
|
}
|
|
@@ -1933,13 +1939,26 @@ const toolHandlers = {
|
|
|
1933
1939
|
}
|
|
1934
1940
|
else {
|
|
1935
1941
|
// 💜 Web: Read from Claude Workspace BD
|
|
1936
|
-
const workspaceResponse = await apiRequest(`/api/claude/workspace/view/${viewId}/files`, {},
|
|
1942
|
+
const workspaceResponse = await apiRequest(`/api/claude/workspace/view/${viewId}/files`, {}, companyId, true, env);
|
|
1937
1943
|
files = workspaceResponse.data || workspaceResponse || [];
|
|
1944
|
+
// 💜 Also read metadata for version tracking
|
|
1945
|
+
try {
|
|
1946
|
+
const metaResponse = await apiRequest(`/api/claude/workspace/view/${viewId}/meta`, {}, companyId, true, env);
|
|
1947
|
+
// sendData wraps response in { data: [...] } format
|
|
1948
|
+
const meta = metaResponse.data?.[0] || metaResponse;
|
|
1949
|
+
lastPulledSnapshot = meta.lastPulledSnapshot;
|
|
1950
|
+
if (!companyId && meta.company_id) {
|
|
1951
|
+
companyId = String(meta.company_id);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
catch {
|
|
1955
|
+
// Metadata not found - view wasn't pulled through workspace
|
|
1956
|
+
}
|
|
1938
1957
|
}
|
|
1939
1958
|
// 💜 VERSION CHECK: Always verify before push (don't rely on backend alone)
|
|
1940
1959
|
// This prevents overwriting changes from other developers
|
|
1941
1960
|
try {
|
|
1942
|
-
const snapshotResp = await apiRequest(`/api/marketplace/views/${viewId}/latest-snapshot`, {},
|
|
1961
|
+
const snapshotResp = await apiRequest(`/api/marketplace/views/${viewId}/latest-snapshot`, {}, companyId, true, env);
|
|
1943
1962
|
const serverSnapshot = snapshotResp.latest_snapshot;
|
|
1944
1963
|
// If server has versions but we don't have a local snapshot → conflict
|
|
1945
1964
|
// (means we pulled with an old CLI that didn't track versions)
|
|
@@ -1981,7 +2000,7 @@ const toolHandlers = {
|
|
|
1981
2000
|
result = await apiRequest(`/api/marketplace/views/${viewId}/files/bulk`, {
|
|
1982
2001
|
method: "POST",
|
|
1983
2002
|
body: JSON.stringify({ files, message: params.message, sync: true, lastPulledSnapshot }),
|
|
1984
|
-
},
|
|
2003
|
+
}, companyId, true, env);
|
|
1985
2004
|
}
|
|
1986
2005
|
catch (err) {
|
|
1987
2006
|
// 💜 Handle version conflict from backend
|
|
@@ -2015,11 +2034,36 @@ const toolHandlers = {
|
|
|
2015
2034
|
}
|
|
2016
2035
|
// Get view info for package
|
|
2017
2036
|
let packageInfo = null;
|
|
2018
|
-
const viewResponse = await apiRequest(`/api/marketplace/views/${viewId}`, {},
|
|
2037
|
+
const viewResponse = await apiRequest(`/api/marketplace/views/${viewId}`, {}, companyId, true, env);
|
|
2019
2038
|
const view = viewResponse.data || viewResponse;
|
|
2020
2039
|
if (view?.package_id) {
|
|
2021
2040
|
packageInfo = { id: view.package_id, publish_cmd: `gufi package:publish ${view.package_id}` };
|
|
2022
2041
|
}
|
|
2042
|
+
// 💜 Extract and save publicAutomations from core/automations.ts
|
|
2043
|
+
const automationsFile = files.find(f => f.file_path === '/core/automations.ts' || f.file_path === 'core/automations.ts');
|
|
2044
|
+
if (automationsFile && view?.company_id && view?.entity_id) {
|
|
2045
|
+
try {
|
|
2046
|
+
// Parse publicAutomations from the file content
|
|
2047
|
+
const content = automationsFile.content;
|
|
2048
|
+
const publicMatch = content.match(/export\s+const\s+publicAutomations\s*=\s*\[([\s\S]*?)\]/);
|
|
2049
|
+
if (publicMatch) {
|
|
2050
|
+
// Extract string values from the array
|
|
2051
|
+
const arrContent = publicMatch[1];
|
|
2052
|
+
const publicAutomations = [...arrContent.matchAll(/['"]([^'"]+)['"]/g)].map(m => m[1]);
|
|
2053
|
+
if (publicAutomations.length > 0) {
|
|
2054
|
+
// Update entity config with publicAutomations
|
|
2055
|
+
await apiRequest(`/api/entities/${view.entity_id}/config`, {
|
|
2056
|
+
method: "PATCH",
|
|
2057
|
+
body: JSON.stringify({ publicAutomations }),
|
|
2058
|
+
}, String(view.company_id), true, env);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
catch (err) {
|
|
2063
|
+
// Non-fatal: log but continue
|
|
2064
|
+
console.error("Warning: Could not update publicAutomations:", err);
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2023
2067
|
// Build response
|
|
2024
2068
|
const response = {
|
|
2025
2069
|
success: true,
|