Token导航 LogoToken导航

Agent Skill · 研究检索

constructive-functions(构造函数)

constructive-functions 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

constructive-functions 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 62,370。

总安装 336周安装 14GitHub Stars 公开资料未说明下载 112核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:constructive-functions(构造函数)
来源仓库:https://github.com/constructive-io/constructive-skills
仓库路径:skills/constructive-functions
安装命令:
npx skills add https://github.com/constructive-io/constructive-skills --skill constructive-functions
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/constructive-io/constructive-skills --skill constructive-functions

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于在 Constructive 平台上构建和部署 Knative 风格的 HTTP 云函数。支持 TypeScript 编写,处理邮件、Webhook 或后台任务等异步事件。可与 Constructive GraphQL API 交互,运行 PGPM 命令或数据库操作。

需部署于 Kubernetes 环境,默认监听端口 8080,适合无服务器场景。constructive-functions 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/constructive-functions

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/constructive-io/constructive-skills --skill co…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

constructive-functions 怎么安装?

在终端执行 npx skills add https://github.com/constructive-io/constructive-skills --skill constructive…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

constructive-functions 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

constructive-functions 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

constructive-functions 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

constructive-functions 用的人多吗?

公开数据是累计安装 336 次,近一周安装 14 次,下载 112 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

constructive-functions 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
constructive-functions

构造函数 · 本页

336—需要联网未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Build and deploy Knative-style HTTP cloud functions for the Constructive platform.

When to Apply

Use this skill when:

  • Creating serverless functions for Constructive (email, webhooks, background jobs)
  • Building functions that interact with the Constructive GraphQL API
  • Running PGPM commands programmatically in cloud functions
  • Executing SQL scripts or database operations as cloud functions

Architecture Overview

Constructive functions are TypeScript HTTP handlers deployed as Knative services on Kubernetes. Each function:

  • Exports a default async handler receiving (params, context)
  • Runs on port 8080 (Knative default)
  • Gets a GraphQL client via context.client for database access
  • Builds to dist/ and runs via a shared Node.js runner

Project Structure

constructive-functions/
  functions/
    my-function/
      src/
        index.ts          # Handler implementation
      __tests__/
        index.test.ts     # Tests
      package.json
      tsconfig.json
      Dockerfile          # Optional, for custom images
  _runtimes/
    node/
      runner.js           # Shared HTTP server wrapper
  k8s/
    base/                 # Base K8s manifests
    overlays/
      local/              # Local development overlay
      dev/                # Dev cluster overlay
  pnpm-workspace.yaml
  Makefile

Function Handler Pattern

Every function exports a default async handler:

import { createClient } from './generated/orm';

export default async (params: any, context: any) => {
  const db = createClient({
    endpoint: process.env.GRAPHQL_ENDPOINT || 'http://constructive-server:3000/graphql',
    headers: context.headers,
  });

  // Type-safe query using generated ORM client
  const result = await db.user
    .findMany({
      select: { id: true, username: true },
      first: 10,
    })
    .execute();

  if (!result.ok) {
    return { error: 'Query failed', details: result.errors };
  }

  return { success: true, users: result.data.users.nodes };
};

The context object provides:

  • client — Legacy GraphQL client (prefer using generated ORM client instead)
  • headers — Request headers from the incoming HTTP request

Important: Use the typed SDK from @constructive-io/graphql-codegen instead of raw gql strings. See the graphql-codegen skill for setup.

Creating a New Function

  1. Create the function directory:
mkdir -p functions/my-function/src
mkdir -p functions/my-function/__tests__
  1. Create functions/my-function/package.json:
{
  "name": "@constructive-io/my-function-fn",
  "version": "0.1.0",
  "description": "My Knative function",
  "author": "Constructive <developers@constructive.io>",
  "private": false,
  "main": "index.js",
  "module": "esm/index.js",
  "types": "index.d.ts",
  "publishConfig": {
    "access": "public",
    "directory": "dist"
  },
  "files": ["dist"],
  "scripts": {
    "copy": "makage assets",
    "clean": "makage clean",
    "prepublishOnly": "npm run build",
    "build": "makage build",
    "test": "jest --forceExit __tests__/index.test.ts",
    "start": "node ../../_runtimes/node/runner.js dist/index.js"
  },
  "dependencies": {
    "@constructive-io/knative-job-fn": "latest",
    "@pgpmjs/env": "latest",
    "graphql-tag": "^2.12.6",
    "cross-fetch": "^4.0.0",
    "graphql-request": "^6.1.0"
  },
  "devDependencies": {
    "@types/node": "latest",
    "@types/jest": "latest",
    "jest": "latest",
    "makage": "0.1.10",
    "ts-jest": "latest",
    "typescript": "latest",
    "pgsql-test": "latest"
  }
}

Critical fields for publishing:

  • publishConfig.directory: "dist" — Publish from dist folder (prevents tree-shaking into weird paths)
  • main: "index.js" — Points to CJS build (in dist)
  • module: "esm/index.js" — Points to ESM build (in dist)
  • types: "index.d.ts" — Points to type declarations (in dist)
  1. Create functions/my-function/tsconfig.json:
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src",
    "declaration": true,
    "declarationMap": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist", "__tests__"]
}
  1. Create functions/my-function/src/index.ts:
import { parseEnvBoolean } from '@pgpmjs/env';

const isDryRun = parseEnvBoolean(process.env.MY_FUNCTION_DRY_RUN) ?? false;

export default async (params: any, context: any) => {
  const { client } = context;
  console.log('[my-function] processing request');

  if (isDryRun) {
    console.log('[my-function] DRY RUN', params);
    return { dryRun: true, params };
  }

  // Your function logic here
  return { success: true };
};

Using PGPM in Functions

Functions can use the pgpm library to run PGPM commands programmatically:

import { dump } from 'pgpm';

export default async (params: any, context: any) => {
  const argv = {
    _: [],
    database: params.database,
    out: params.out,
    'database-id': params.database_id
  };

  const prompter = {
    prompt: () => { throw new Error('Interactive prompt not supported'); }
  };

  await dump(argv, prompter, {});

  return { message: 'PGPM dump completed', args: argv };
};

Direct Database Access

For SQL execution, use pg-cache for connection pool management. It provides automatic caching, cleanup callbacks, and graceful shutdown handling:

import { getPgPool, close } from 'pg-cache';

export default async (params: any, context: any) => {
  const { query } = params;

  if (!query) {
    return { error: 'Missing "query" in payload' };
  }

  // Get or create a cached pool (automatically reused across requests)
  const pool = getPgPool({
    host: process.env.PGHOST,
    port: Number(process.env.PGPORT || 5432),
    database: process.env.PGDATABASE || 'launchql',
    user: process.env.PGUSER,
    password: process.env.PGPASSWORD,
  });

  const result = await pool.query(query);
  return { rowCount: result.rowCount, rows: result.rows };

  // Note: No manual cleanup needed - pg-cache handles pool lifecycle
};

Why pg-cache?

  • Automatic pool caching — Pools are reused across function invocations
  • Graceful shutdown — Handles idle connection errors during cleanup
  • LRU eviction — Automatically disposes unused pools
  • Cleanup callbacks — Register callbacks for resource cleanup when pools are disposed

For graceful shutdown in long-running processes:

import { close } from 'pg-cache';

process.on('SIGTERM', async () => {
  await close();  // Gracefully close all cached pools
  process.exit(0);
});

Build Workflow

Functions use makage for builds, which handles TypeScript compilation and asset copying:

# Install dependencies
pnpm install

# Build all functions (from workspace root)
pnpm -r run build

# Build a specific function
cd functions/my-function
pnpm build

# Clean build artifacts
pnpm clean

Build Output Structure

After makage build:

my-function/
├── src/
│   └── index.ts
├── dist/
│   ├── index.js          # CJS build
│   ├── index.d.ts        # Type declarations
│   ├── esm/
│   │   └── index.js      # ESM build
│   ├── package.json      # Copied from root
│   ├── README.md         # Copied from root
│   └── LICENSE           # Copied from root
└── package.json

Local Development

Run functions locally:

# Run a specific function locally
cd functions/my-function
pnpm start
# Function listens on http://localhost:8080

# Test with curl
curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{"key": "value"}'

Publishing Functions to npm

Functions follow the same publishing workflow as other PNPM packages. See the pnpm-publishing skill for full details.

Quick Publishing Workflow

# 1. Build all functions
pnpm -r run build

# 2. Run tests
pnpm -r run test

# 3. Version (interactive)
pnpm lerna version

# 4. Publish to npm
pnpm lerna publish from-package

Dry Run

Test publishing without making changes:

# Test versioning
pnpm lerna version --no-git-tag-version --no-push

# Test publishing
pnpm lerna publish from-package --dry-run

Docker Build

Build Docker images for deployment:

# Build all function images
make docker-build

# Build a specific function
docker build -t ghcr.io/constructive-io/constructive-functions/my-function:latest functions/my-function

# Push to registry
docker push ghcr.io/constructive-io/constructive-functions/my-function:latest

Dockerfile Pattern

FROM node:22-alpine

WORKDIR /usr/src/app

COPY package.json ./

RUN npm install -g pnpm@10.12.2 && pnpm install --prod

COPY dist ./dist

ENV NODE_ENV=production
ENV PORT=8080

USER node

CMD ["node", "dist/index.js"]

Kubernetes Deployment

Local Development with Kind/Minikube

cd k8s

# Install Knative Serving + Kourier
make operators-knative-only

# Apply local overlay (Postgres, MinIO, functions)
make kustomize-local

# Port-forward to services
make proxy-server   # GraphQL API -> localhost:8080
make proxy-web      # Dashboard UI -> localhost:3000

Knative Service Manifest

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: my-function
  namespace: interweb
spec:
  template:
    spec:
      containers:
        - image: ghcr.io/constructive-io/constructive-functions/my-function:latest
          ports:
            - containerPort: 8080
          env:
            - name: MY_FUNCTION_DRY_RUN
              value: "false"
            - name: GRAPHQL_ENDPOINT
              value: "http://constructive-server:3000/graphql"

Environment Variables

Common environment variables for functions:

VariableDescription
PORTHTTP port (default: 8080)
GRAPHQL_ENDPOINTGraphQL API URL
PGHOSTPostgreSQL host
PGPORTPostgreSQL port
PGUSERPostgreSQL user
PGPASSWORDPostgreSQL password
PGDATABASEPostgreSQL database
*_DRY_RUNEnable dry-run mode (per function)

Testing Functions

// __tests__/index.test.ts
import handler from '../src/index';

describe('my-function', () => {
  const mockClient = {
    request: jest.fn()
  };

  it('should process request', async () => {
    const params = { key: 'value' };
    const context = { client: mockClient };

    const result = await handler(params, context);

    expect(result.success).toBe(true);
  });
});

Run tests:

cd functions/my-function
pnpm test

Error Handling

Return errors as JSON with appropriate status codes:

export default async (params: any, context: any) => {
  const { requiredField } = params;

  // 400 Bad Request - missing required field
  if (!requiredField) {
    return { error: 'Missing required field' };
  }

  try {
    // Function logic
    return { success: true };
  } catch (e: any) {
    // 500 Internal Server Error
    console.error('Function failed:', e);
    return { error: e.message };
  }
};

The runner automatically maps certain error messages to 400 status codes:

  • "Missing prompt"
  • "Missing required field"
  • "Missing "query" in payload"

All other errors return 500.

Best Practices

  1. Use typed SDK — Use @constructive-io/graphql-codegen ORM client instead of raw gql strings
  2. Use pg-cache — Use pg-cache for database connections instead of manual Pool management
  3. Use makage for builds — Consistent build tooling across all packages
  4. Publish from dist/ — Prevents tree-shaking into weird import paths
  5. Use dry-run mode — Support *_DRY_RUN env var for testing without side effects
  6. Log context — Log request details for debugging (but not sensitive data)
  7. Handle errors — Use discriminated unions (.execute()) for explicit error handling
  8. Validate input — Check required fields early and return clear error messages
  9. Use @pgpmjs/env — Parse boolean env vars consistently with parseEnvBoolean()

References

平台分布

Codex

38.02%
按下载量换算43

Claude

27.4%
按下载量换算31

Cursor

19.5%
按下载量换算22

Gemini CLI

9.42%
按下载量换算11

安全审计

Gen Agent Trust Hub

可疑

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills