Skip to content

Commit 3af2ce9

Browse files
chore: sync config from main
1 parent d550ac9 commit 3af2ce9

3,118 files changed

Lines changed: 30730 additions & 3354 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

airules/codebuddy/rules/ai-model-nodejs/rule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: ai-model-nodejs
33
description: "Use this skill for Node.js backend AI via @cloudbase/node-sdk (>=3.16.0) — cloud functions, CloudRun, Express, Koa, NestJS, serverless APIs, scheduled jobs, LLM proxies. Only SDK supporting image generation (ai.createImageModel + generateImage). Text models via ai.createModel with groups cloudbase, hunyuan-exp, or custom-*. Model IDs (deepseek-v4-flash, deepseek-v3.2, hunyuan-2.0-instruct-20251111, glm-5, kimi-k2.6) go in the model field of generateText/streamText. MUST run two-step preflight before code — see body. Keywords: backend, 云函数, 云托管, serverless, LLM proxy, agent orchestration, generateText, streamText, generateImage, createModel, hunyuan-image, Token Credits, TokenHub, Hunyuan, DeepSeek, GLM, Kimi, MiniMax. NOT for browser/Web (use ai-model-web) or Mini Program (use ai-model-wechat)."
4-
version: 2.23.3
4+
version: 2.23.4
55
alwaysApply: false
66
---
77

airules/codebuddy/rules/ai-model-web/rule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: ai-model-web
33
description: "Use this skill when a browser/Web app (React, Vue, Angular, Next, Nuxt, static sites, SPAs, dashboards, AI chat UI) needs AI models via @cloudbase/js-sdk. Default routing for page/页面/Web/前端/frontend/网页/H5 AI — call directly from browser, do NOT propose a Node.js proxy. Covers generateText and streamText. Models via ai.createModel with groups cloudbase, hunyuan-exp, or custom-*. Model IDs (deepseek-v4-flash, deepseek-v3.2, hunyuan-2.0-instruct-20251111, glm-5, kimi-k2.6) go in the model field. MUST run two-step preflight before code — see body. Keywords: 页面, Web, 前端, React, Vue, Next, Nuxt, SPA, AI chat UI, generateText, streamText, createModel, hunyuan-exp, Token Credits, TokenHub, Hunyuan, DeepSeek, GLM, Kimi, MiniMax. NOT for Node.js backend (use ai-model-nodejs), Mini Program (use ai-model-wechat), or image generation (Node SDK only)."
4-
version: 2.23.3
4+
version: 2.23.4
55
alwaysApply: false
66
---
77

airules/codebuddy/rules/ai-model-wechat/rule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: ai-model-wechat
33
description: "Use this skill for WeChat Mini Program AI via wx.cloud.extend.AI (小程序, 企业微信小程序, wx.cloud apps). Features generateText and streamText with callbacks (onText, onEvent, onFinish). Models via wx.cloud.extend.AI.createModel with groups hunyuan-exp (小程序成长计划), cloudbase (main managed), or custom-*. Model IDs (deepseek-v4-flash, deepseek-v3.2, hunyuan-2.0-instruct-20251111, glm-5, kimi-k2.6) go in the data wrapper model field. API differs from JS/Node SDK — streamText needs data wrapper, generateText returns raw response. MUST run two-step preflight before code — see body. Keywords: Mini Program AI, wx.cloud.extend.AI, 小程序成长计划, ai_miniprogram_inspire_plan, Token Credits 资源包, generateText, streamText, createModel, hunyuan-exp, TokenHub, Hunyuan, DeepSeek, GLM, Kimi, MiniMax. NOT for browser/Web (use ai-model-web), Node.js backend (use ai-model-nodejs), or image generation (use ai-model-nodejs)."
4-
version: 2.23.3
4+
version: 2.23.4
55
alwaysApply: false
66
---
77

airules/codebuddy/rules/auth-nodejs/rule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: auth-nodejs-cloudbase
33
description: CloudBase Node SDK auth guide for server-side identity, user lookup, and custom login tickets. This skill should be used when Node.js code must read caller identity, inspect end users, or bridge an existing user system into CloudBase; not when configuring providers or building client login UI.
4-
version: 2.23.3
4+
version: 2.23.4
55
alwaysApply: false
66
---
77

airules/codebuddy/rules/auth-tool/rule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: auth-tool-cloudbase
33
description: CloudBase auth provider configuration and login-readiness guide. This skill should be used when users need to inspect, enable, disable, or configure auth providers, publishable-key prerequisites, login methods, SMS/email sender setup, or other provider-side readiness before implementing a client or backend auth flow.
4-
version: 2.23.3
4+
version: 2.23.4
55
alwaysApply: false
66
---
77

airules/codebuddy/rules/auth-web/rule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: auth-web-cloudbase
33
description: CloudBase Web Authentication Quick Guide for frontend integration after auth-tool has already been checked. Provides concise and practical Web authentication solutions with multiple login methods and complete user management.
4-
version: 2.23.3
4+
version: 2.23.4
55
alwaysApply: false
66
---
77

airules/codebuddy/rules/auth-wechat/rule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: auth-wechat-miniprogram
33
description: CloudBase WeChat Mini Program native authentication guide. This skill should be used when users need mini program identity handling, OPENID/UNIONID access, or `wx.cloud` auth behavior in projects where login is native and automatic.
4-
version: 2.23.3
4+
version: 2.23.4
55
alwaysApply: false
66
---
77

airules/codebuddy/rules/cloud-functions/checklist.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@ Use this checklist before creating or updating a CloudBase function.
88
- Event Function: `exports.main(event, context)`, SDK/timer driven
99
- HTTP Function: `req` / `res`, listens on port `9000`
1010
2. Pick the runtime before creation and state it explicitly.
11-
3. For HTTP Functions, confirm `scf_bootstrap` exists and the Node.js binary path matches the runtime (e.g. `Nodejs18.15``/var/lang/node18/bin/node`).
12-
4. Confirm the function root path points to the parent directory, not the function directory itself.
13-
5. For HTTP Functions that need public access, configure the function security rule with `managePermissions(action="updateResourcePermission", resourceType="function")` after creation. Default rules reject unauthenticated callers with `EXCEED_AUTHORITY`. Note: anonymous login is disabled by default — use `rule: "true"` for public endpoints.
14-
6. If the request is really for a long-running container service, reroute to `cloudrun-development`.
11+
- For a managed runtime, choose a language runtime (e.g. `Nodejs18.15`).
12+
- For a container-image HTTP Function, set `runtime: "CustomImage"` and provide `imageConfig` (`imageUri` with tag; `registryId` for enterprise TCR). The image still listens on port `9000`. See `references/http-functions-custom-image.md`.
13+
3. For HTTP Functions on a managed runtime, confirm `scf_bootstrap` exists and the Node.js binary path matches the runtime (e.g. `Nodejs18.15``/var/lang/node18/bin/node`). Custom Image functions do not use `scf_bootstrap`.
14+
4. Confirm the function root path points to the parent directory, not the function directory itself. (Not needed for Custom Image deploys — the code lives in the image.)
15+
5. For Custom Image deploys, confirm TCR, the CloudApp build, and SCF are in the same region, and the image tag is unique (not `:latest`). Remember Stage A (CloudApp custom build → TCR push) is a raw Tencent Cloud API path, not covered by MCP tools.
16+
6. For HTTP Functions that need public access, configure the function security rule with `managePermissions(action="updateResourcePermission", resourceType="function")` after creation. Default rules reject unauthenticated callers with `EXCEED_AUTHORITY`. Note: anonymous login is disabled by default — use `rule: "true"` for public endpoints.
17+
7. If the request is really for a long-running container service, reroute to `cloudrun-development`.
1518

1619
## Common failure patterns
1720

1821
- Choosing the wrong function type and compensating later.
1922
- Mixing Event Function and HTTP Function handler shapes in the same implementation.
2023
- Forgetting that runtime cannot be changed after creation.
2124
- Mismatching the `scf_bootstrap` Node.js binary path with the function runtime.
25+
- For Custom Image functions: using `:latest`, mismatched regions across TCR/CloudApp/SCF, or assuming MCP covers the CloudApp build → TCR push stage (it does not).
2226
- Forgetting to configure function security rules for HTTP Functions that need public access.
2327
- Treating Cloud Functions as the default answer for Web authentication.
2428

airules/codebuddy/rules/cloud-functions/references.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ Read this when the task is about:
2727
- `scf_bootstrap`
2828
- browser/public access paths for HTTP Functions
2929

30+
### `./references/http-functions-custom-image.md`
31+
32+
Read this when the task is about:
33+
34+
- deploying an HTTP Function from a **container image** (`Runtime: CustomImage`)
35+
- `imageConfig` / `ImageUri` / TCR image addresses
36+
- the zip → COS → CloudApp custom build → TCR → SCF image pipeline
37+
- choosing between a managed-runtime HTTP Function, a Custom Image HTTP Function, and a CloudRun container
38+
3039
### `./references/operations-and-config.md`
3140

3241
Read this when the task is about:
@@ -44,3 +53,4 @@ Read this when the task is about:
4453
- HTTP Function code shape: `req` / `res` web server on port `9000`
4554
- HTTP Access for Event Functions is a gateway configuration, not the HTTP Function runtime model
4655
- CloudRun is the right route when the task is actually a long-lived service or broader container workload
56+
- Custom Image HTTP Function (`Runtime: CustomImage`) still listens on the fixed port `9000` and is request-driven — distinct from a CloudRun container, which listens on the injected `PORT` and runs long-lived
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# HTTP Functions — Custom Image Deployment Reference
2+
3+
Use this reference when an HTTP Function must run from a **container image** instead of the managed Node.js/Python runtime. This is the `Runtime: CustomImage` path: the code is packaged as a Docker image, pushed to TCR (Tencent Container Registry), and SCF runs that image.
4+
5+
## When to choose Custom Image (vs the other two HTTP options)
6+
7+
| Deployment form | Choose when | How it deploys |
8+
| --- | --- | --- |
9+
| **Managed runtime** (default, see `http-functions.md`) | Plain Node.js / Python, dependencies are simple | `manageFunctions(createFunction)` + `scf_bootstrap` + zip |
10+
| **Custom Image** (this file) | Need custom system libraries / arbitrary runtime, but still want SCF request-driven execution and scale-to-zero | CloudApp custom build → TCR → SCF image function |
11+
| **CloudRun container** (see `cloudrun-development`) | Long-lived process, persistent connections, listens on injected `PORT` | `manageCloudRun` |
12+
13+
Keep Custom Image HTTP Functions distinct from CloudRun containers — both use a Dockerfile, but:
14+
15+
- **Custom Image HTTP Function**: container listens on a **fixed port `9000`**, request-driven, scales to zero. SCF gateway sends each HTTP request into the container.
16+
- **CloudRun container**: container listens on the **injected `PORT`** env var, long-lived process.
17+
18+
Do not blend the two contracts.
19+
20+
## End-to-end pipeline (6 steps)
21+
22+
The link between the two stages is the TCR image address:
23+
24+
```text
25+
ImageUri = {TCR_REGISTRY}/{TCR_NAMESPACE}/{ServiceName}:{VersionName}
26+
example: ccr.ccs.tencentyun.com/your-ns/demo-app:demo-app-001
27+
```
28+
29+
```text
30+
Stage A — build the image (CloudApp custom build pipeline)
31+
① DescribeCloudAppCosInfo -> get COS upload credentials + UnixTimestamp
32+
② PUT zip to COS -> upload source
33+
③ CreateCloudApp -> trigger docker build + docker push to TCR
34+
④ DescribeCloudAppVersion -> poll until Status=SUCCESS, read VersionName
35+
36+
Stage B — deploy to SCF (based on the TCR image)
37+
⑤ createFunction / updateFunctionCode -> SCF image function
38+
⑥ getFunctionDetail (optional) -> confirm Status=Active
39+
```
40+
41+
## Tooling boundary (read this before acting)
42+
43+
- **Stage B (SCF image deploy) is covered by `manageFunctions`.** Use `manageFunctions(action="createFunction")` with `func.runtime="CustomImage"` + `imageConfig`, and `manageFunctions(action="updateFunctionCode")` + `imageConfig` for later iterations. The Manager SDK auto-fills `ImageType=enterprise` and `ImagePort=9000`, and strips Handler / dependency install for image functions.
44+
- **Stage A (CloudApp custom build → TCR) is NOT covered by MCP tools.** The `manageApps` / `queryApps` tools only support `static-hosting`. The custom-build pipeline (`DeployType=custom`, `CustomSteps`, `DescribeCloudAppCosInfo` with `DeployType=custom`) is a **raw Tencent Cloud API path**. Treat it as a `callCloudApi` fallback:
45+
- Confirm the exact action name, parameters, and `X-TC-Version` from official docs **before** calling — do not guess payloads from memory.
46+
- CloudApp build APIs are on `tcb.tencentcloudapi.com` (`X-TC-Version: 2018-06-08`).
47+
- SCF APIs are on `scf.tencentcloudapi.com` (`X-TC-Version: 2018-04-16`).
48+
- **Region must match.** TCR, the CloudApp build, and SCF must be in the same region (e.g. all `ap-shanghai`). Cross-region image pulls time out.
49+
50+
## Stage B with `manageFunctions` (the supported path)
51+
52+
### Create (first deploy)
53+
54+
```javascript
55+
manageFunctions({
56+
action: "createFunction",
57+
func: {
58+
name: "my-scf-func",
59+
type: "HTTP",
60+
runtime: "CustomImage"
61+
},
62+
imageConfig: {
63+
imageType: "enterprise",
64+
imageUri: "ccr.ccs.tencentyun.com/your-ns/demo-app:demo-app-001",
65+
registryId: "tcr-xxxxxxxx",
66+
command: "python",
67+
args: "-u app.py",
68+
imagePort: 9000,
69+
containerImageAccelerate: true
70+
}
71+
});
72+
```
73+
74+
### Update image (later iterations)
75+
76+
Only the tag changes; no local code packaging.
77+
78+
```javascript
79+
manageFunctions({
80+
action: "updateFunctionCode",
81+
functionName: "my-scf-func",
82+
imageConfig: {
83+
imageType: "enterprise",
84+
imageUri: "ccr.ccs.tencentyun.com/your-ns/demo-app:demo-app-002",
85+
registryId: "tcr-xxxxxxxx"
86+
}
87+
});
88+
```
89+
90+
### `imageConfig` fields
91+
92+
| Field | Required | Notes |
93+
| --- | --- | --- |
94+
| `imageUri` | yes | Full address **with tag**: `{domain}/{ns}/{image}:{tag}`. Never `:latest`. |
95+
| `imageType` || `"enterprise"` (TCR enterprise) or `"personal"`. Defaults to `enterprise`. |
96+
| `registryId` | enterprise only | TCR instance id `tcr-xxxxxxxx`. Required when `imageType=enterprise`. |
97+
| `command` || Overrides `ENTRYPOINT`. Omit to use the Dockerfile default. |
98+
| `args` || Overrides `CMD`, space-separated. |
99+
| `imagePort` || Web Server: `9000` (default). Job-style image: `-1`. |
100+
| `containerImageAccelerate` || Image acceleration; enable for large images to cut cold-start time. |
101+
102+
After deploy, confirm readiness with `queryFunctions(action="getFunctionDetail", functionName="my-scf-func")` and look for `Status=Active`. For public/browser access, create gateway access explicitly with `manageGateway(action="createAccess", type="HTTP")` and set the function security rule (anonymous login is disabled by default — see `http-functions.md`).
103+
104+
## Source packaging (Stage A input)
105+
106+
Package the **contents** of the project root, with a `Dockerfile` at the root — do not nest an extra top-level folder.
107+
108+
```bash
109+
# correct: zip the contents from inside the project root
110+
cd ./my-app
111+
zip -r ../my-app.zip .
112+
113+
# wrong: this nests an extra my-app/ layer after extraction
114+
zip -r my-app.zip my-app/
115+
```
116+
117+
After extraction the build container sees:
118+
119+
```text
120+
/ (workspace root)
121+
├── Dockerfile <- must be at the root
122+
├── package.json / requirements.txt / pom.xml ...
123+
├── src/
124+
└── ...
125+
```
126+
127+
## Dockerfile contract for SCF image functions
128+
129+
```dockerfile
130+
FROM python:3.11-slim
131+
WORKDIR /app
132+
COPY . .
133+
RUN pip install --no-cache-dir -r requirements.txt
134+
EXPOSE 9000 # SCF Web Server functions must listen on 9000
135+
CMD ["python", "-u", "app.py"]
136+
```
137+
138+
SCF image constraints:
139+
140+
| Constraint | Detail |
141+
| --- | --- |
142+
| Web Server functions listen on `9000` | The SCF gateway sends HTTP requests into the container on this port. |
143+
| The image must start an HTTP server on its own | Not a CLI tool, not a blocking script. |
144+
| Image size ideally ≤ 500MB | Large images cold-start slowly; enable `containerImageAccelerate`. |
145+
| Container start ≤ health-check timeout | Default 60s. |
146+
147+
## TCR credentials (Stage A push, raw API)
148+
149+
Use STS temporary credentials + TCR `CreateInstanceToken` to obtain a short-lived registry login, instead of storing any long-term TCR password:
150+
151+
- The build container injects STS credentials as `$API_SECRET_ID` / `$API_SECRET_KEY` / `$API_TOKEN`.
152+
- In the build step, sign a TCR `CreateInstanceToken` call (`tcr.tencentcloudapi.com`, `X-TC-Version: 2019-09-24`) with those credentials to get a temporary token.
153+
- `docker login` with that token (always via `--password-stdin`), then `docker push`.
154+
155+
Security red lines:
156+
157+
- Never print `$API_SECRET_*` / `$API_TOKEN` or pass them outside the container.
158+
- Always use `docker login --password-stdin` so credentials never appear in `ps` or logs.
159+
160+
## Build-container variables (Stage A, custom build)
161+
162+
Use these inside `CustomSteps` commands:
163+
164+
| Variable | Meaning |
165+
| --- | --- |
166+
| `$CLOUDBASE_SERVICE_NAME` | Service name (= the `ServiceName` input) |
167+
| `$CLOUDBASE_VERSION_NAME` | Version name — **use this as the image tag**; available at build time, unique, traceable |
168+
| `$CLOUDBASE_VERSION_NUMBER` | Numeric version (e.g. `001`) |
169+
| `$CLOUDBASE_ENV_ID` | Environment id |
170+
| `$BUILD_TYPE` | `zip` / `git` |
171+
| `$ZIP_FILE_URL` | Zip download URL (injected automatically in zip mode) |
172+
| `$API_SECRET_ID` `$API_SECRET_KEY` `$API_TOKEN` | STS credentials (never print) |
173+
174+
- Reserved prefixes that must NOT be declared in `Env`: `API_*`, `CLOUDBASE_*`, `CODE_*`, `BUILD_TYPE`, `ZIP_FILE_URL`.
175+
- Do NOT reference non-existent variables such as `$BUILD_ID`, `$CLOUDBASE_BUILD_ID`, `$CLOUDBASE_VERSION` — use `$CLOUDBASE_VERSION_NAME` for the tag.
176+
177+
## Common errors
178+
179+
### Stage A (build)
180+
181+
| Symptom | Likely cause |
182+
| --- | --- |
183+
| `Source 不能为空` | `Source.Type` empty; zip flow must set `"zip"` |
184+
| `Commands 和 CustomSteps 不能同时为空` | Provide at least one `CustomSteps` entry |
185+
| COS upload 403 | Missing one of the `UploadHeaders`, or the upload URL expired (>15 min) |
186+
| `检出 ZIP 包` failed | `CosTimestamp` missing or wrong (must reuse the `UnixTimestamp` from step ①) |
187+
| `docker push :tag` empty tag | Used a non-existent variable; use `$CLOUDBASE_VERSION_NAME` |
188+
| `docker login unauthorized` | TCR namespace not authorized; check `TCR_INSTANCE_ID` |
189+
| `AuthFailure.SignatureFailure` | Push script `REGION` does not match the TCR instance region |
190+
191+
### Stage B (deploy)
192+
193+
| Symptom | Likely cause |
194+
| --- | --- |
195+
| `ResourceNotFound.ImageConfig` | `imageUri` does not exist or the tag is wrong |
196+
| `InvalidParameterValue.ImageUri` | Wrong format; must be `{domain}/{ns}/{image}:{tag}` |
197+
| SCF image pull timeout | TCR and SCF are not in the same region |
198+
| SCF image pull denied | `SCF_QcsRole` not authorized to pull from TCR |
199+
| Function start timeout (60s) | Image too large or startup too slow; enable image acceleration / slim the image |
200+
| Port 9000 no response | Dockerfile `EXPOSE` / `CMD` does not actually start an HTTP server on 9000 |
201+
202+
## Best practices
203+
204+
- Image tag = `$CLOUDBASE_VERSION_NAME` — available at build time, unique, traceable.
205+
- TCR push via STS + `CreateInstanceToken` — no long-term secrets to manage.
206+
- `Runtime` must be `"CustomImage"`, not a language runtime.
207+
- `imageUri` must include a tag — never `:latest`.
208+
- Keep TCR, CloudApp build, and SCF in the same region.
209+
- SCF image ≤ 500MB + enable acceleration to control cold-start time.

0 commit comments

Comments
 (0)