needware-cli 1.6.0 → 1.6.2
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/tools/supabase-deploy-functions-tool.d.ts +1 -3
- package/dist/tools/supabase-deploy-functions-tool.d.ts.map +1 -1
- package/dist/tools/supabase-deploy-functions-tool.js +38 -39
- package/dist/tools/supabase-deploy-functions-tool.js.map +1 -1
- package/package.json +1 -1
- package/skills/resend-integration/SKILL.md +3 -2
|
@@ -8,10 +8,8 @@ import { z } from 'zod';
|
|
|
8
8
|
export declare class SupabaseDeployFunctionsTool extends BaseTool {
|
|
9
9
|
definition: ToolDefinition;
|
|
10
10
|
getZodSchema(): {
|
|
11
|
-
functionName: z.
|
|
11
|
+
functionName: z.ZodString;
|
|
12
12
|
functionPath: z.ZodOptional<z.ZodString>;
|
|
13
|
-
noVerifyJwt: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
-
importMap: z.ZodOptional<z.ZodString>;
|
|
15
13
|
};
|
|
16
14
|
execute(input: Record<string, any>): Promise<ToolResult>;
|
|
17
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supabase-deploy-functions-tool.d.ts","sourceRoot":"","sources":["../../src/tools/supabase-deploy-functions-tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"supabase-deploy-functions-tool.d.ts","sourceRoot":"","sources":["../../src/tools/supabase-deploy-functions-tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkBxB,qBAAa,2BAA4B,SAAQ,QAAQ;IACvD,UAAU,EAAE,cAAc,CAiBxB;IAEF,YAAY;;;;IAON,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;CA2G/D"}
|
|
@@ -5,48 +5,58 @@
|
|
|
5
5
|
import { BaseTool } from './base-tool.js';
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
import fs from 'fs/promises';
|
|
9
|
+
import path from 'path';
|
|
8
10
|
export class SupabaseDeployFunctionsTool extends BaseTool {
|
|
9
11
|
definition = {
|
|
10
12
|
name: 'supabase-deploy-functions',
|
|
11
|
-
description: 'Deploy Supabase Edge
|
|
13
|
+
description: 'Deploy a Supabase Edge Function by reading the function code and deploying it to your Supabase project.',
|
|
12
14
|
input_schema: {
|
|
13
15
|
type: 'object',
|
|
14
16
|
properties: {
|
|
15
17
|
functionName: {
|
|
16
18
|
type: 'string',
|
|
17
|
-
description: 'Name of the function to deploy
|
|
19
|
+
description: 'Name of the function to deploy (required)',
|
|
18
20
|
},
|
|
19
21
|
functionPath: {
|
|
20
22
|
type: 'string',
|
|
21
|
-
description: 'Path to the function
|
|
22
|
-
},
|
|
23
|
-
noVerifyJwt: {
|
|
24
|
-
type: 'boolean',
|
|
25
|
-
description: 'Deploy without JWT verification (useful for public functions)',
|
|
26
|
-
},
|
|
27
|
-
importMap: {
|
|
28
|
-
type: 'string',
|
|
29
|
-
description: 'Path to import map file',
|
|
23
|
+
description: 'Path to the function file. Defaults to supabase/functions/<functionName>/index.ts',
|
|
30
24
|
},
|
|
31
25
|
},
|
|
32
|
-
required: [],
|
|
26
|
+
required: ['functionName'],
|
|
33
27
|
},
|
|
34
28
|
};
|
|
35
29
|
getZodSchema() {
|
|
36
30
|
return {
|
|
37
|
-
functionName: z.string().
|
|
38
|
-
functionPath: z.string().optional().describe('Path to the function
|
|
39
|
-
noVerifyJwt: z.boolean().optional().describe('Deploy without JWT verification'),
|
|
40
|
-
importMap: z.string().optional().describe('Path to import map file'),
|
|
31
|
+
functionName: z.string().describe('Name of the function to deploy'),
|
|
32
|
+
functionPath: z.string().optional().describe('Path to the function file'),
|
|
41
33
|
};
|
|
42
34
|
}
|
|
43
35
|
async execute(input) {
|
|
44
36
|
try {
|
|
45
37
|
// 验证并获取 Gateway 配置
|
|
46
38
|
this.validateGatewayConfig();
|
|
47
|
-
const { apiKey, chatId
|
|
48
|
-
const { functionName, functionPath
|
|
49
|
-
|
|
39
|
+
const { apiKey, chatId } = this.getGatewayConfig();
|
|
40
|
+
const { functionName, functionPath } = input;
|
|
41
|
+
if (!functionName) {
|
|
42
|
+
throw new Error('functionName is required');
|
|
43
|
+
}
|
|
44
|
+
// 1. 确定函数文件路径
|
|
45
|
+
const workspacePath = process.cwd();
|
|
46
|
+
const defaultFunctionPath = path.join('supabase', 'functions', functionName, 'index.ts');
|
|
47
|
+
const actualFunctionPath = functionPath || defaultFunctionPath;
|
|
48
|
+
const fullPath = path.join(workspacePath, actualFunctionPath);
|
|
49
|
+
console.log(chalk.blue(`📖 读取函数代码: ${actualFunctionPath}`));
|
|
50
|
+
// 2. 读取函数代码
|
|
51
|
+
let functionCode;
|
|
52
|
+
try {
|
|
53
|
+
functionCode = await fs.readFile(fullPath, 'utf-8');
|
|
54
|
+
console.log(chalk.green(`✓ 成功读取函数代码 (${functionCode.length} 字符)`));
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new Error(`Failed to read function file at ${actualFunctionPath}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
58
|
+
}
|
|
59
|
+
// 3. 先检查 Supabase 项目状态
|
|
50
60
|
console.log(chalk.blue('🔍 检查 Supabase 项目状态...'));
|
|
51
61
|
const statusUrl = `https://www.needware.dev/api/supabase/status?chatId=${chatId}`;
|
|
52
62
|
const statusResponse = await fetch(statusUrl, {
|
|
@@ -64,26 +74,14 @@ export class SupabaseDeployFunctionsTool extends BaseTool {
|
|
|
64
74
|
}
|
|
65
75
|
const projectId = statusData.data.projectId;
|
|
66
76
|
console.log(chalk.green(`✓ 找到 Supabase 项目: ${projectId}`));
|
|
67
|
-
//
|
|
68
|
-
console.log(chalk.blue(`🚀 开始部署 Edge Function
|
|
69
|
-
const deployUrl = 'https://www.needware.dev/api/supabase/deploy-
|
|
77
|
+
// 4. 部署 Edge Function
|
|
78
|
+
console.log(chalk.blue(`🚀 开始部署 Edge Function: ${functionName}...`));
|
|
79
|
+
const deployUrl = 'https://www.needware.dev/api/supabase/deploy-function';
|
|
70
80
|
const deployPayload = {
|
|
71
81
|
chatId,
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
functionName,
|
|
83
|
+
functionCode,
|
|
74
84
|
};
|
|
75
|
-
if (functionName) {
|
|
76
|
-
deployPayload.functionName = functionName;
|
|
77
|
-
}
|
|
78
|
-
if (functionPath) {
|
|
79
|
-
deployPayload.functionPath = functionPath;
|
|
80
|
-
}
|
|
81
|
-
if (noVerifyJwt !== undefined) {
|
|
82
|
-
deployPayload.noVerifyJwt = noVerifyJwt;
|
|
83
|
-
}
|
|
84
|
-
if (importMap) {
|
|
85
|
-
deployPayload.importMap = importMap;
|
|
86
|
-
}
|
|
87
85
|
const deployResponse = await fetch(deployUrl, {
|
|
88
86
|
method: 'POST',
|
|
89
87
|
headers: {
|
|
@@ -101,7 +99,7 @@ export class SupabaseDeployFunctionsTool extends BaseTool {
|
|
|
101
99
|
throw new Error(`Deploy failed: ${deployData.error || deployData.message || 'Unknown error'}`);
|
|
102
100
|
}
|
|
103
101
|
console.log(chalk.green('✓ Edge Function 部署成功'));
|
|
104
|
-
//
|
|
102
|
+
// 5. 构建返回信息
|
|
105
103
|
const resultMessage = `Supabase Edge Function deployed successfully!
|
|
106
104
|
|
|
107
105
|
${deployData.message}
|
|
@@ -114,11 +112,12 @@ ${deployData.data ? `Deployment Details:
|
|
|
114
112
|
- Deployed At: ${deployData.data.deployedAt}` : ''}
|
|
115
113
|
|
|
116
114
|
Project ID: ${projectId}
|
|
117
|
-
|
|
115
|
+
Function: ${functionName}
|
|
116
|
+
Source File: ${actualFunctionPath}`;
|
|
118
117
|
return this.successWithContent(resultMessage);
|
|
119
118
|
}
|
|
120
119
|
catch (error) {
|
|
121
|
-
const message = error instanceof Error ? error.message : 'Failed to deploy Supabase Edge
|
|
120
|
+
const message = error instanceof Error ? error.message : 'Failed to deploy Supabase Edge Function';
|
|
122
121
|
console.log(chalk.red(`\n✖ ${message}\n`));
|
|
123
122
|
return this.errorWithContent(message);
|
|
124
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supabase-deploy-functions-tool.js","sourceRoot":"","sources":["../../src/tools/supabase-deploy-functions-tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"supabase-deploy-functions-tool.js","sourceRoot":"","sources":["../../src/tools/supabase-deploy-functions-tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAgBxB,MAAM,OAAO,2BAA4B,SAAQ,QAAQ;IACvD,UAAU,GAAmB;QAC3B,IAAI,EAAE,2BAA2B;QACjC,WAAW,EAAE,yGAAyG;QACtH,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,YAAY,EAAE;oBACZ,I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,EAAE;;cAEpC,SAAS;YACX,YAAY;eACT,kBAAkB,EAAE,CAAC;YAE9B,OAAO,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,yCAAyC,CAAC;YACnG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,OAAO,IAAI,CAAC,CAAC,CAAC;YAC3C,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -35,8 +35,9 @@ Check if Supabase is already integrated:
|
|
|
35
35
|
Once Supabase is confirmed integrated:
|
|
36
36
|
1. Call `add-secret` tool to add the Resend API key
|
|
37
37
|
2. The tool will prompt user to add the `RESEND_API_KEY` secret
|
|
38
|
-
3.
|
|
39
|
-
4.
|
|
38
|
+
3. **IMMEDIATELY PAUSE and wait** - Do NOT proceed until user confirmation
|
|
39
|
+
4. Wait for user confirmation: `needware tool use: Approved`
|
|
40
|
+
5. Proceed to next step only after Approved
|
|
40
41
|
|
|
41
42
|
|
|
42
43
|
**Step 4: Verify Edge Functions Support**
|