pnpm installThe install hook builds sdk/factory so plugins started during development can resolve dist/index.js. Run pnpm build:sdk-factory again after changing the SDK source.
pnpm build:sdk-factory
pnpm build:sdk-client
pnpm build:cli
pnpm build:server
pnpm build:debug-runtime-monitorpnpm dev:server
pnpm dev:cli
pnpm dev:debug-runtime-monitorpnpm test
pnpm typecheck
pnpm lintThis repository is a pnpm workspace monorepo.
| Path | Purpose |
|---|---|
apps/server |
FastGPT Plugin HTTP service and route composition. |
apps/cli |
Plugin create, build, check, debug, and pack CLI. |
apps/debug-runtime-monitor |
Local runtime monitor UI. |
packages/domain |
Entities, value objects, and port definitions. |
packages/usecase |
Application use cases for plugins, tools, models, and runtime metrics. |
packages/interface-adapter |
HTTP contracts, DTOs, and auth adapters. |
packages/infrastructure |
Hono, Mongo, S3, Redis, static data, logging, metrics, and plugin runtime implementations. |
packages/shared |
Cross-layer pure utilities. |
sdk/client |
Client SDK for calling the FastGPT Plugin service. |
sdk/factory |
SDK for authoring tool plugins. |
test |
Shared fixtures and cross-package test utilities. |
See Architecture for the full layering model.
Use @fastgpt-plugin/cli and @fastgpt-plugin/sdk-factory for tool plugins.
pnpx @fastgpt-plugin/cli create my-tool --type tool --cwd packages/tools
pnpx @fastgpt-plugin/cli create my-tool-suite --type tool-suite --cwd packages/toolsInside a plugin project:
pnpm run test
pnpm run build
pnpx @fastgpt-plugin/cli check --entry . --output ./dist
pnpm run packUseful references:
Use English for variables, functions, files, and public API names. Keep legacy non-English identifiers only when required for compatibility.
Follow the existing dependency direction:
- Define stable business types and ports in
packages/domain. - Implement orchestration in
packages/usecase. - Put DTOs and OpenAPI contracts in
packages/interface-adapter. - Implement framework, storage, runtime, and external-service details in
packages/infrastructure. - Wire concrete dependencies in
apps/server/src/deps.tsand route files.
Use Vitest for tests. Prefer focused tests near the code being changed:
- Usecase tests should mock ports.
- Infrastructure tests should isolate external IO and cover serialization, error mapping, and security constraints.
- CLI changes should cover command behavior and generated artifacts.
- SDK changes should cover TypeScript-facing API behavior and runtime channel behavior.
Use const by default. Use let only when a variable is intentionally reassigned.
Prefer explicit types, Zod schemas, and domain value objects. Use unknown at boundaries and parse before use.
Keep variables and helper functions close to where they are used. Extract helpers when they clarify business intent or remove meaningful duplication.
Model provider presets now live under packages/infrastructure/src/static-data/models/provider.
To add or update a model provider:
- Update or add the provider config in
packages/infrastructure/src/static-data/models/provider/<Provider>/index.ts. - Add or update the provider logo in the same directory when needed.
- Add channel avatars under
packages/infrastructure/src/static-data/models/channel-avatarwhen needed. - Register new providers in
packages/infrastructure/src/static-data/models/index.ts. - Run tests or typecheck for the affected package.
- Local-pool runtime design: process-pool-design.md
- Runtime metrics and OpenTelemetry: runtime-metrics-otel.md
- Upgrade guide: v1.0.0.md