Skip to content

Commit dc3632f

Browse files
authored
Merge pull request #607 from TencentCloudBase/fix/prompt-skills-view-url
fix: skills.sh URL and issue-auto-processor test
2 parents 36f1dc1 + be5f4aa commit dc3632f

18 files changed

Lines changed: 138 additions & 40 deletions

.github/workflows/issue-auto-processor-simple.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ jobs:
416416
build_bug_prompt
417417
418418
set +e
419-
raw_output=$(timeout 1200s codebuddy -p "$(cat /tmp/codebuddy-prompt.txt)" -y --output-format json --permission-mode acceptEdits --model hy3-preview-ioa 2>&1)
419+
raw_output=$(timeout 1200s codebuddy -p "$(cat /tmp/codebuddy-prompt.txt)" -y --output-format json --permission-mode acceptEdits --model hy3-preview-ioa </dev/null> 2>&1)
420420
exit_code=$?
421421
set -e
422422

doc/prompts/auth-http-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ npx skills add tencentcloudbase/cloudbase-skills
3131
npx skills add https://github.com/tencentcloudbase/skills --skill http-api
3232
```
3333

34-
当前 Skill 在线查看: [http-api](https://skills.sh/tencentcloudbase/skills/http-api)
34+
当前 Skill 在线查看: [http-api](https://skills.sh/tencentcloudbase/skills/http-api-cloudbase)
3535

3636
---
3737

doc/prompts/auth-nodejs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ npx skills add tencentcloudbase/cloudbase-skills
3131
npx skills add https://github.com/tencentcloudbase/skills --skill auth-nodejs
3232
```
3333

34-
当前 Skill 在线查看: [auth-nodejs](https://skills.sh/tencentcloudbase/skills/auth-nodejs)
34+
当前 Skill 在线查看: [auth-nodejs](https://skills.sh/tencentcloudbase/skills/auth-nodejs-cloudbase)
3535

3636
---
3737

doc/prompts/auth-tool.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ npx skills add tencentcloudbase/cloudbase-skills
3333
npx skills add https://github.com/tencentcloudbase/skills --skill auth-tool
3434
```
3535

36-
当前 Skill 在线查看: [auth-tool](https://skills.sh/tencentcloudbase/skills/auth-tool)
36+
当前 Skill 在线查看: [auth-tool](https://skills.sh/tencentcloudbase/skills/auth-tool-cloudbase)
3737

3838
---
3939

@@ -132,7 +132,7 @@ Recommended MCP request:
132132
```json
133133
{
134134
"success": true,
135-
"envId": "env-xxx",
135+
"envId": "your-full-env-id",
136136
"loginMethods": {
137137
"usernamePassword": true,
138138
"email": true,
@@ -173,6 +173,7 @@ Parameter mapping for downstream Web auth code:
173173
- `UserNameLogin` also enables the broader password-login surface exposed by `auth.signInWithPassword({ username|email|phone, password })`
174174
- `SmsVerificationConfig.Type = "apis"` requires both `Name` and `Method`
175175
- `EnvId` is always the CloudBase environment ID, not the publishable key
176+
- If the conversation only contains an environment alias, nickname, or other shorthand, resolve it to the canonical full `EnvId` first before generating auth config, SDK init examples, or console links
176177

177178
Internal behavior of `manageAppAuth(action="patchLoginStrategy")`:
178179

doc/prompts/auth-web.mdx

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ npx skills add tencentcloudbase/cloudbase-skills
3131
npx skills add https://github.com/tencentcloudbase/skills --skill auth-web
3232
```
3333

34-
当前 Skill 在线查看: [auth-web](https://skills.sh/tencentcloudbase/skills/auth-web)
34+
当前 Skill 在线查看: [auth-web](https://skills.sh/tencentcloudbase/skills/auth-web-cloudbase)
3535

3636
---
3737

@@ -83,6 +83,7 @@ Keep local `references/...` paths for files that ship with the current skill dir
8383
- Using `signInWithEmailAndPassword` or `signUpWithEmailAndPassword` for username-style accounts such as `admin` and `editor`.
8484
- Keeping the login or register account input as `type="email"` when the task explicitly says the account identifier is a plain username string.
8585
- Starting implementation before calling `queryAppAuth(action="getLoginConfig")` and enabling `usernamePassword` when it is still off.
86+
- **Treating `auth.getUser()` returning a user as proof of real login.** When the SDK is initialized with a `publishableKey` / `accessKey`, it may silently create an anonymous session. A route guard's `checkAuth()` must verify that the user actually signed in with username/password (e.g. check `session.loginType !== 'ANONYMOUS'` or that `user.user_metadata?.username` exists), not just that `getUser()` returns non-null. Otherwise unauthenticated visitors pass the guard, protected pages render without a real user, and role-based UI (edit / delete buttons gated on `currentUser.role`) breaks because `currentUser` has no role record.
8687

8788
## Overview
8889

@@ -95,9 +96,8 @@ Keep local `references/...` paths for files that ship with the current skill dir
9596

9697
**Use Case**: Web frontend projects using `@cloudbase/js-sdk@2.24.0+` for user authentication
9798
**Key Benefits**: Supabase-like Auth API shape, supports phone, email, anonymous, username/password, and third-party login methods
98-
**Official `@cloudbase/js-sdk` CDN**: `https://static.cloudbase.net/cloudbase-js-sdk/latest/cloudbase.full.js`
9999

100-
Use the same CDN address as `web-development`. Prefer npm installation in modern bundler projects, and use the CDN form for static HTML, no-build demos, or low-friction examples.
100+
Use npm installation for modern Web projects. In React, Vue, Vite, and other bundler-based apps, install and import `@cloudbase/js-sdk` from the project dependencies instead of using a CDN script.
101101

102102
## Prerequisites
103103

@@ -107,6 +107,7 @@ Use the same CDN address as `web-development`. Prefer npm installation in modern
107107
### Parameter map
108108

109109
- For username-style identifiers, the required precondition is `loginMethods.usernamePassword === true` from `queryAppAuth(action="getLoginConfig")`. If it is false, enable it with `manageAppAuth(action="patchLoginStrategy", patch={ usernamePassword: true })` before wiring frontend auth code.
110+
- If the conversation only provides an environment alias, nickname, or other shorthand, resolve it with `envQuery(action="list", alias=..., aliasExact=true)` first and use the returned canonical full `EnvId` for SDK init, console links, and generated config. Do not pass alias-like short forms directly into `cloudbase.init({ env })`.
110111
- Treat CloudBase Web Auth as **Supabase-like**, not “every `supabase-js` auth example is valid unchanged”
111112
- When `queryAppAuth` / `manageAppAuth` returns `sdkStyle: "supabase-like"` and `sdkHints`, follow those method and parameter hints first
112113
- `auth.signInWithOtp({ phone })` and `auth.signUp({ phone })` use the phone number in a `phone` field, not `phone_number`
@@ -121,10 +122,11 @@ Use the same CDN address as `web-development`. Prefer npm installation in modern
121122
## Quick Start
122123

123124
```js
125+
// npm install @cloudbase/js-sdk
124126
import cloudbase from '@cloudbase/js-sdk'
125127

126128
const app = cloudbase.init({
127-
env: `env`, // CloudBase environment ID
129+
env: 'your-full-env-id', // Canonical full CloudBase environment ID resolved from envQuery or the console, not an alias or shorthand
128130
region: `region`, // CloudBase environment Region, default 'ap-shanghai'
129131
accessKey: 'publishable key', // required, get from auth-tool-cloudbase
130132
auth: { detectSessionInUrl: true }, // required
@@ -141,8 +143,9 @@ If the current task has not retrieved a real Publishable Key, omit `accessKey` i
141143

142144
**1. Phone OTP (Recommended)**
143145
- Automatically use `auth-tool-cloudbase` to turn on `SMS Login` through `manageAppAuth`
146+
- For phone registration, send the phone number to `auth.signUp({ phone, ... })` first, then call the returned `verifyOtp({ token })`. Do not swap the order.
144147
```js
145-
const { data, error } = await auth.signInWithOtp({ phone: '13800138000' })
148+
const { data, error } = await auth.signUp({ phone: '13800138000' })
146149
const { data: loginData, error: loginError } = await data.verifyOtp({ token:'123456' })
147150
```
148151

@@ -154,10 +157,35 @@ const { data: loginData, error: loginError } = await data.verifyOtp({ token: '65
154157
```
155158

156159
**3. Password**
160+
161+
All auth methods return `{ data, error }`. Always check `error` first:
157162
```js
158-
const usernameLogin = await auth.signInWithPassword({ username: 'test_user', password: 'pass123' })
159-
const emailLogin = await auth.signInWithPassword({ email: 'user@example.com', password: 'pass123' })
160-
const phoneLogin = await auth.signInWithPassword({ phone: '13800138000', password: 'pass123' })
163+
// Login — returns { data: { user, session }, error: null } on success
164+
const { data, error } = await auth.signInWithPassword({ username: 'test_user', password: 'pass123' })
165+
if (error) {
166+
// Handle login failure (wrong password, user not found, provider not enabled)
167+
console.error('Login failed:', error.message)
168+
return false
169+
}
170+
// data.user.id is the uid; data.session contains the active session
171+
const uid = data.user.id
172+
173+
// Also works with email or phone:
174+
// await auth.signInWithPassword({ email: 'user@example.com', password: 'pass123' })
175+
// await auth.signInWithPassword({ phone: '13800138000', password: 'pass123' })
176+
```
177+
178+
**Checking login state (for route guards / auth checks):**
179+
```js
180+
// Use auth.getLoginState() to get the current session.
181+
// IMPORTANT: uid alone is NOT enough — when the SDK is initialized with a
182+
// publishableKey it may create an anonymous session that also has a uid.
183+
// Route guards must reject anonymous sessions explicitly.
184+
const loginState = await auth.getLoginState()
185+
const isRealLogin = !!loginState
186+
&& !!loginState.uid
187+
&& loginState.loginType !== 'ANONYMOUS'
188+
// Use isRealLogin (not just !!uid) to gate protected routes.
161189
```
162190

163191
**4. Registration**
@@ -181,7 +209,7 @@ const emailVerifyResult = await emailSignUp.data.verifyOtp({ token: '123456' })
181209
// Phone Otp
182210
// Use only when the task explicitly requires phone numbers.
183211
// Phone Otp
184-
const phoneSignUp = await auth.signUp({ phone: '13800138000', nickname: 'User' })
212+
const phoneSignUp = await auth.signUp({ phone: '13800138000', password: 'pass123', nickname: 'User' })
185213
const phoneVerifyResult = await phoneSignUp.data.verifyOtp({ token: '123456' })
186214
```
187215

@@ -200,11 +228,13 @@ const handleRegister = async () => {
200228
}
201229

202230
const handleLogin = async () => {
203-
const { error } = await auth.signInWithPassword({
231+
const { data, error } = await auth.signInWithPassword({
204232
username,
205233
password,
206234
})
207235
if (error) throw error
236+
// Login succeeded — data.user.id is the uid
237+
return true
208238
}
209239
```
210240

@@ -214,25 +244,21 @@ Do not use email OTP or email-only helpers for these flows unless the task expli
214244
const handleSendCode = async () => {
215245
try {
216246
const { data, error } = await auth.signUp({
217-
email,
218-
name: username || email.split('@')[0],
247+
phone,
248+
password: password || undefined,
219249
})
220250
if (error) throw error
221-
setSignUpData(data)
251+
verifyOtpRef.current = data.verifyOtp
222252
} catch (error) {
223253
console.error('Failed to send sign-up code', error)
224254
}
225255
}
226256

227257
const handleRegister = async () => {
228258
try {
229-
if (!signUpData?.verifyOtp) throw new Error('Please send the code first')
259+
if (!verifyOtpRef.current) throw new Error('Please send the code first')
230260

231-
const { error } = await signUpData.verifyOtp({
232-
email,
233-
token: code,
234-
type: 'signup',
235-
})
261+
const { error } = await verifyOtpRef.current({ token: code })
236262
if (error) throw error
237263
} catch (error) {
238264
console.error('Failed to complete sign-up', error)

doc/prompts/auth-wechat.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ npx skills add tencentcloudbase/cloudbase-skills
3131
npx skills add https://github.com/tencentcloudbase/skills --skill auth-wechat
3232
```
3333

34-
当前 Skill 在线查看: [auth-wechat](https://skills.sh/tencentcloudbase/skills/auth-wechat)
34+
当前 Skill 在线查看: [auth-wechat](https://skills.sh/tencentcloudbase/skills/auth-wechat-miniprogram)
3535

3636
---
3737

doc/prompts/cloud-functions.mdx

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ Keep local `references/...` paths for files that ship with the current skill dir
9292
- Forgetting that runtime cannot be changed after creation.
9393
- Using cloud functions as the first answer for Web login.
9494
- Forgetting that HTTP Functions must ship `scf_bootstrap`, listen on port `9000`, and include dependencies.
95+
- Forgetting to configure function security rules after creating an HTTP Function. Default rules reject anonymous callers with `EXCEED_AUTHORITY`. Use `managePermissions(action="updateResourcePermission", resourceType="function")` to allow public access.
96+
- Mismatching the `scf_bootstrap` Node.js binary path with the function runtime (e.g. using `/var/lang/node18/bin/node` but setting `runtime: "Nodejs16.13"`).
9597

9698
### Minimal checklist
9799

@@ -110,8 +112,25 @@ Use this skill when developing, deploying, and operating CloudBase cloud functio
110112

111113
- If the request is for SDK calls, timers, or event-driven workflows, write an **Event Function** with `exports.main = async (event, context) => {}`.
112114
- If the request is for REST APIs, browser-facing endpoints, SSE, or WebSocket, write an **HTTP Function** with `req` / `res` on port `9000`.
115+
- For Node.js HTTP Functions, default to the native `http` module unless the user explicitly asks for Express, Koa, NestJS, or another framework.
113116
- If the user mentions HTTP access for an existing Event Function, keep the Event Function code shape and add gateway access separately.
114117

118+
## HTTP Function authoring contract
119+
120+
Use these rules whenever you are writing the function code itself:
121+
122+
- Do not write an HTTP Function as `exports.main(event, context)`. That is the Event Function contract.
123+
- Treat the function as a standard web server process that must listen on port `9000`.
124+
- With Node.js, prefer `http.createServer((req, res) => { ... })` by default so the runtime contract stays explicit.
125+
- With the Node.js native `http` module, do not assume Express-style helpers exist. `req.body`, `req.query`, and `req.params` are not provided for you.
126+
- For Node.js HTTP Functions, choose one module system up front and keep it consistent. Default to CommonJS for simple functions (`require(...)`, no `"type": "module"` in `package.json`) unless you explicitly want ES Modules.
127+
- If you do choose ES Modules (`"type": "module"` + `import ...`), do not mix in CommonJS-only globals or APIs such as `require(...)`, `module.exports`, or bare `__dirname`. In ESM, derive file paths from `import.meta.url` with `fileURLToPath(...)` only when needed.
128+
- With the native `http` module, parse `req.url` yourself with `new URL(...)`, collect the request body from the stream, and only then call `JSON.parse`. Empty bodies should be handled explicitly instead of assuming JSON is always present.
129+
- Return responses explicitly with `res.writeHead(...)` and `res.end(...)`, including `Content-Type` such as `application/json; charset=utf-8` for JSON APIs.
130+
- Keep routing and method handling explicit. Unknown paths should return `404`, and known paths with unsupported methods should normally return `405`.
131+
- Keep gateway setup and security-rule changes separate from the runtime code. They affect access, not the HTTP Function programming model.
132+
- Do not add HTTP access service configuration when the task is only to create an HTTP Function itself. Gateway paths or custom domains are separate access-layer work; anonymous or public invocation requirements should be handled through the function security rule workflow.
133+
115134
## Quick decision table
116135

117136
| Question | Choose |
@@ -137,7 +156,7 @@ Use this skill when developing, deploying, and operating CloudBase cloud functio
137156
3. **Write code and deploy, do not stop at local files**
138157
- Use `manageFunctions(action="createFunction")` for creation
139158
- Use `manageFunctions(action="updateFunctionCode")` for code updates
140-
- Keep `functionRootPath` as the parent directory of the function folder
159+
- Keep `functionRootPath` as the directory that directly contains function folders (e.g., `cloudfunctions/` or `functions/`), NOT the project root and NOT the function subdirectory itself
141160
- Use CLI only as a fallback when MCP tools are unavailable
142161

143162
4. **Prefer doc-first fallbacks**
@@ -198,10 +217,21 @@ exports.main = async (event, context) => {
198217

199218
```js
200219
const http = require("http");
220+
const { URL } = require("url");
221+
222+
function sendJson(res, statusCode, data) {
223+
res.writeHead(statusCode, { "Content-Type": "application/json; charset=utf-8" });
224+
res.end(JSON.stringify(data));
225+
}
201226

202227
const server = http.createServer((req, res) => {
203-
res.writeHead(200, { "Content-Type": "application/json" });
204-
res.end(JSON.stringify({ ok: true, message: "hello from http function" }));
228+
const url = new URL(req.url || "/", "http://127.0.0.1");
229+
230+
if (req.method === "GET" && url.pathname === "/") {
231+
sendJson(res, 200, { ok: true, message: "hello from http function" });
232+
} else {
233+
sendJson(res, 404, { error: "Not Found" });
234+
}
205235
});
206236

207237
server.listen(9000);
@@ -214,6 +244,8 @@ server.listen(9000);
214244
/var/lang/node18/bin/node index.js
215245
```
216246

247+
The `scf_bootstrap` binary path must match the runtime — see the full mapping table in `./references/http-functions.md`.
248+
217249
`cloudfunctions/hello-http/package.json`
218250

219251
```json

doc/prompts/cloudbase-platform.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ Use this skill for **CloudBase platform knowledge** when you need to:
150150
1. **SDK Initialization**:
151151
- CloudBase SDK initialization requires environment ID
152152
- Can query environment ID via `envQuery` tool
153+
- If the user only provides an environment alias, nickname, or other short form, resolve it with `envQuery(action="list", alias=..., aliasExact=true)` first and use the returned full `EnvId`
154+
- Do not pass alias-like short forms directly into SDK init, `auth.set_env`, console URLs, or generated config files
153155
- For Web, always initialize synchronously:
154-
- `import cloudbase from "@cloudbase/js-sdk"; const app = cloudbase.init({ env: "xxxx-yyy" });`
156+
- `import cloudbase from "@cloudbase/js-sdk"; const app = cloudbase.init({ env: "your-full-env-id" });`
155157
- Do **not** use dynamic imports like `import("@cloudbase/js-sdk")` or async wrappers such as `initCloudBase()` with internal `initPromise`
156158
- Then proceed with login, for example using anonymous login
157159

@@ -343,6 +345,7 @@ The CloudBase console is updated frequently. If a live, logged-in console shows
343345

344346
- **Base URL Pattern**: `https://tcb.cloud.tencent.com/dev?envId=${envId}#/{path}`
345347
- **Replace Variables**: Always replace `${envId}` with the actual environment ID queried via `envQuery` tool
348+
- **Alias Handling**: If the conversation only contains an alias or shorthand, first resolve it with `envQuery(action="list", alias=..., aliasExact=true)` and use the returned `EnvId`; if the alias is ambiguous or missing, ask the user to confirm before generating links
346349
- **Resource-Specific URLs**: For specific resources (collections, functions, models), replace resource name variables with actual values
347350
- **Usage**: After creating/deploying resources, provide these console links to users for management operations
348351

doc/prompts/database-http-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ npx skills add tencentcloudbase/cloudbase-skills
3131
npx skills add https://github.com/tencentcloudbase/skills --skill http-api
3232
```
3333

34-
当前 Skill 在线查看: [http-api](https://skills.sh/tencentcloudbase/skills/http-api)
34+
当前 Skill 在线查看: [http-api](https://skills.sh/tencentcloudbase/skills/http-api-cloudbase)
3535

3636
---
3737

doc/prompts/http-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ npx skills add tencentcloudbase/cloudbase-skills
3232
npx skills add https://github.com/tencentcloudbase/skills --skill http-api
3333
```
3434

35-
当前 Skill 在线查看: [http-api](https://skills.sh/tencentcloudbase/skills/http-api)
35+
当前 Skill 在线查看: [http-api](https://skills.sh/tencentcloudbase/skills/http-api-cloudbase)
3636

3737
---
3838

0 commit comments

Comments
 (0)