Guidance for coding agents working in this repository.
# Full build (backend, frontend, and tests)
./gradlew build
# Backend compile and tests
./gradlew compileJava
./gradlew test
# Run one backend test class
./gradlew :app:test --tests "run.halo.aifoundation.provider.AbstractAiProviderTypeTest"
# Start the Halo development server
./gradlew haloServer
# Frontend development and verification
cd ui
corepack pnpm install
corepack pnpm dev
corepack pnpm test:unit
corepack pnpm lint
corepack pnpm type-checkAI Foundation is a multi-module Halo plugin that provides shared AI capabilities to other plugins:
api/— Public Java SDK (run.halo.aifoundation:api), published to Maven Central. It contains theAiModelServiceextension point and provider-neutral model APIs.app/— Plugin implementation, including Extensions, provider integrations, model resolution, runtime services, Console endpoints, and validation. It may use Spring AI internally.ui/— Vue 3 Console UI, generated OpenAPI client, and the public@halo-dev/ai-foundation-sdkpackage underui/packages/sdk/.
- Consumer plugins obtain
AiModelServicethroughExtensionGetter.getEnabledExtension(AiModelService.class). Plugin application contexts are isolated; do not introduce static service locators or cross-plugin@Autowiredassumptions. AiModel.spec.providerNamereferencesAiProvider.metadata.name.AiModelServiceresolves models byAiModel.metadata.name, not by provider type or provider-side model ID.- Provider types are Spring components implementing
AiProviderType. Their metadata is exposed by the provider-types Console API; the frontend must not maintain a hardcoded provider list. - API keys are stored as Halo Secret references (
spec.apiKeySecretName) and resolved at runtime. Never store credentials in plaintext Extension fields. - Public SDK APIs must remain provider-neutral and must not expose Spring AI types.
- Server-side validation is authoritative. UI validation should improve feedback, not replace backend checks.
- Never manually edit
api-docs/orui/src/api/generated/. - Use the repository-pinned pnpm through Corepack; never edit
ui/pnpm-lock.yamlmanually. - After changing backend API endpoints or fields, run
./gradlew generateApiClientand update frontend callers through the generated client. - When validating backend changes against a running development server, restart it with
docker rm halo-for-plugin-development -f && ./gradlew haloServer. - The Console UI is written in Chinese (
zh-CN) and is intended for super administrators. Do not add role-specific permission configuration for other roles.
The project has been released since v1.0.0. Preserve public Java/npm APIs, persisted Extension data, and externally documented contracts by default. A breaking change must be explicitly identified and include affected versions, migration or upgrade handling, and release impact. Internal implementations may be refactored freely when these contracts remain intact.