### Start HiMarket Developer Portal (Bash) Source: https://github.com/higress-group/himarket/blob/main/README.md Install dependencies and start the HiMarket developer portal development server. ```bash # Start developer portal cd himarket-web/himarket-frontend npm install npm run dev ``` -------------------------------- ### Start Development Server Source: https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-frontend/CLAUDE.md Starts the development server. Runs on http://0.0.0.0:5173. ```bash npm run dev ``` -------------------------------- ### Start HiMarket Admin Portal (Bash) Source: https://github.com/higress-group/himarket/blob/main/README.md Install dependencies and start the HiMarket admin portal development server. The portal will be accessible at http://localhost:5174. ```bash # Start admin portal cd himarket-web/himarket-admin npm install npm run dev # Admin portal: http://localhost:5174 ``` -------------------------------- ### Install Dependencies Source: https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-frontend/CLAUDE.md Use this command to install all project dependencies. ```bash npm install ``` -------------------------------- ### Start HiMarket Backend (Bash) Source: https://github.com/higress-group/himarket/blob/main/README.md Build and start the HiMarket backend service. This command compiles the code, stops any existing processes, and starts the backend in the background, waiting until it's ready. The backend API will be available at http://localhost:8080. ```bash make run # Or run the script directly: ./scripts/run.sh # The script auto-loads ~/.env, compiles, stops old processes, starts in background, and waits until ready # Backend API: http://localhost:8080 ``` -------------------------------- ### Deploy HiMarket with Docker Compose Source: https://github.com/higress-group/himarket/blob/main/README.md Clone the repository and run the install script to deploy the full stack with Docker Compose. Ensure Docker and Docker Compose are installed. ```bash git clone https://github.com/higress-group/himarket.git cd himarket/deploy/docker ./install.sh ``` ```bash ./install.sh --uninstall ``` -------------------------------- ### Administrator Initialization and Login Source: https://context7.com/higress-group/himarket/llms.txt Use these endpoints to check if initial setup is needed, perform first-time initialization of the admin account, log in to obtain a JWT token, and change the admin password. Ensure correct Content-Type and Authorization headers are used for authenticated requests. ```bash # Check whether initial setup is needed curl -s http://localhost:8080/admins/need-init # Response: {"code":"SUCCESS","data":true} ``` ```bash # First-time initialization curl -s -X POST http://localhost:8080/admins/init \ -H "Content-Type: application/json" \ -d '{"username":"admin","password":"Admin@123456"}' | jq . # Response: # { # "code": "SUCCESS", # "data": { # "id": "abc123", # "username": "admin", # "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." # } # } ``` ```bash # Regular login ADMIN_TOKEN=$(curl -s -X POST http://localhost:8080/admins/login \ -H "Content-Type: application/json" \ -d '{"username":"admin","password":"Admin@123456"}' \ | jq -r '.data.access_token') echo "Token: $ADMIN_TOKEN" ``` ```bash # Change admin password curl -s -X PATCH http://localhost:8080/admins/password \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{"oldPassword":"Admin@123456","newPassword":"NewPass@789"}' # Response: {"code":"SUCCESS"} ``` -------------------------------- ### JavaDoc for Method Source: https://github.com/higress-group/himarket/blob/main/himarket-server/BACKEND_CODING_STANDARDS.md Example of JavaDoc comment for a private method, including a brief description and `@param` tag. ```java /** * Fill product details, including product categories and product reference config. * * @param products the list of products to fill */ private void fillProducts(List products) { ... } ``` -------------------------------- ### Product Controller Example Source: https://github.com/higress-group/himarket/blob/main/himarket-server/BACKEND_CODING_STANDARDS.md A standard REST controller for product management, utilizing annotations for Swagger documentation, request mapping, request bodies, path variables, and authorization. All logic is delegated to the Service layer. ```java @Tag(name = "API Product Management") @RestController @RequestMapping("/products") @RamResource("product") @Slf4j @RequiredArgsConstructor public class ProductController { private final ProductService productService; @Operation(summary = "Create API product") @PostMapping @AdminAuth public ProductResult createProduct(@RequestBody @Valid CreateProductParam param) { return productService.createProduct(param); } @Operation(summary = "List API products") @GetMapping public PageResult listProducts( QueryProductParam param, Pageable pageable) { return productService.listProducts(param, pageable); } @Operation(summary = "Get API product details") @GetMapping("/{productId}") public ProductResult getProduct(@PathVariable String productId) { return productService.getProduct(productId); } @Operation(summary = "Update API product") @PutMapping("/{productId}") @AdminAuth public ProductResult updateProduct( @PathVariable String productId, @RequestBody @Valid UpdateProductParam param) { return productService.updateProduct(productId, param); } @Operation(summary = "Delete API product") @DeleteMapping("/{productId}") @AdminAuth public void deleteProduct(@PathVariable String productId) { productService.deleteProduct(productId); } } ``` -------------------------------- ### Get Categories for Product Source: https://context7.com/higress-group/himarket/llms.txt Retrieve the list of categories associated with a specific product. Requires a developer token for access. ```bash # Get categories for a product curl -s http://localhost:8080/products/prod-001/categories \ -H "Authorization: Bearer $DEV_TOKEN" | jq . ``` -------------------------------- ### Deploy HiMarket with Helm Chart Source: https://github.com/higress-group/himarket/blob/main/README.md Clone the repository and execute the install script to deploy HiMarket to a Kubernetes cluster using Helm. Requires kubectl and Helm. ```bash git clone https://github.com/higress-group/himarket.git cd himarket/deploy/helm ./install.sh ``` ```bash ./install.sh --uninstall ``` -------------------------------- ### Example PR Description Source: https://github.com/higress-group/himarket/blob/main/CONTRIBUTING.md A sample Pull Request description demonstrating the required sections: Description, Related Issues, and Checklist. Ensure all required items are addressed. ```markdown ## Description - Add feature configuration field to Product entity - Create ModelFeatureForm component for the admin UI - Implement backend service to persist feature settings - Add Flyway migration script for database schema changes ## Related Issues Fix #123 Close #456 ## Checklist - [x] Code has been formatted with `mvn spotless:apply` - [x] Code is self-reviewed - [x] Tests added/updated (if applicable) - [x] Documentation updated (if applicable) ``` -------------------------------- ### Code Reuse Examples Source: https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-admin/ADMIN_CODING_STANDARDS.md Illustrates when to reuse components based on identical business meaning versus when not to force reuse due to differing business logic. ```tsx // Same business meaning -> should reuse // MCP config displayed in multiple places // Different business meaning -> should NOT force reuse // MCP product form // REST API product form (fields differ significantly) ``` -------------------------------- ### Get Available CLI Providers Source: https://context7.com/higress-group/himarket/llms.txt Retrieves a list of available CLI providers and their features. No authorization token is required for this endpoint. ```bash curl -s http://localhost:8080/cli-providers | jq . ``` -------------------------------- ### React Internationalization (i18n) Setup Source: https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-frontend/FRONTEND_CODING_STANDARDS.md Integrate internationalization using react-i18next. Organize translation files by namespace and ensure corresponding files exist for 'zh-CN' and 'en-US'. ```tsx import { useTranslation } from 'react-i18next'; function WorkerDetail() { const { t } = useTranslation('workerDetail'); return

{t('title')}

; } ``` -------------------------------- ### Build and Serve Source: https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-frontend/CLAUDE.md Builds the project and serves the production build locally. ```bash npm run serve ``` -------------------------------- ### Example Conventional Commit Messages Source: https://github.com/higress-group/himarket/blob/main/CONTRIBUTING.md Examples of valid and invalid commit messages following the Conventional Commits specification. Ensure the type is present and the description is lowercase and concise. ```text ✅ feat: add product feature configuration ✅ fix: resolve pagination issue in product list ✅ docs: update deployment guide in README ✅ refactor: simplify client initialization logic ❌ Add new feature (missing type) ❌ feat: Add Feature (description should be lowercase) ❌ update code (not descriptive) ``` -------------------------------- ### Create an API Product Source: https://context7.com/higress-group/himarket/llms.txt Use this endpoint to define and create a new product in the marketplace. Products wrap AI resources and expose them with versioning and policies. Requires administrator token. ```bash curl -s -X POST http://localhost:8080/products \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "GPT-4o Completions", "type": "MODEL_API", "description": "Access to GPT-4o via the Higress AI Gateway", "icon": "https://example.com/icons/gpt4o.png" }' | jq . ``` -------------------------------- ### 项目快速命令 Source: https://github.com/higress-group/himarket/blob/main/AGENTS.md 提供了一系列用于项目编译、构建、测试、格式检查和运行的 make 命令。 ```bash make compile # 快速编译(跳过测试和格式检查) make build # 完整构建(编译 + 格式检查 + 测试) make test # 运行单元测试 make lint # 代码格式检查(Spotless) make lint-fix # 自动修复代码格式 make run # 编译并启动后端服务 ``` -------------------------------- ### Event Handler and Data Fetching Naming Source: https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-frontend/FRONTEND_CODING_STANDARDS.md Establishes naming conventions for event handlers and data fetching functions. Event handlers start with `handle`, and data fetching functions start with `fetch`. ```tsx const handleSearch = () => { ... }; ``` ```tsx const handleTryNow = () => { ... }; ``` ```tsx const handleCopy = (text: string) => { ... }; ``` ```tsx const fetchCategories = async () => { ... }; ``` ```tsx const fetchDetail = async () => { ... }; ``` -------------------------------- ### Preview Production Build Source: https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-frontend/CLAUDE.md Previews the production build locally. ```bash npm run preview ``` -------------------------------- ### Get primary consumer Source: https://context7.com/higress-group/himarket/llms.txt Retrieves the primary consumer associated with the authenticated developer. ```APIDOC ## GET /consumers/primary ### Description Retrieves the primary consumer for the authenticated developer. ### Method GET ### Endpoint `/consumers/primary` ``` -------------------------------- ### Get Workspace Changes Source: https://context7.com/higress-group/himarket/llms.txt Retrieves a list of files that have changed in the workspace since a specified timestamp. ```APIDOC ## GET /workspace/changes ### Description Fetches a list of files that have been modified in the workspace after a given timestamp. ### Method GET ### Endpoint /workspace/changes ### Parameters #### Query Parameters - **cwd** (string) - Required - The directory to check for changes. - **since** (integer) - Required - The timestamp (in milliseconds) to check for changes since. #### Headers - **Authorization** (string) - Required - Bearer token for authentication. ### Request Example ```bash curl -s "http://localhost:8080/workspace/changes?cwd=/workspace/project&since=1704067200000" \ -H "Authorization: Bearer $DEV_TOKEN" ``` ### Response #### Success Response (200) - **data.changes** (array) - An array of objects, each containing the `path` and `mtimeMs` of a changed file. ``` -------------------------------- ### Publish Product to a Portal Source: https://context7.com/higress-group/himarket/llms.txt Makes a product available for subscription on a specific portal. Requires administrator token. ```bash curl -s -X POST http://localhost:8080/products/prod-001/publications \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{"portalId":"portal-001"}' ``` -------------------------------- ### Get Subscribed Models for HiCoding CLI Source: https://context7.com/higress-group/himarket/llms.txt Retrieves the list of models subscribed to by the HiCoding CLI. ```APIDOC ## GET /cli-providers/market-models ### Description Lists the AI models that are currently subscribed to and available for use with the HiCoding CLI. ### Method GET ### Endpoint /cli-providers/market-models ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. ``` -------------------------------- ### Get CLI Provider Features Source: https://context7.com/higress-group/himarket/llms.txt Retrieves the feature flags for CLI providers, such as terminal enablement. ```APIDOC ## GET /cli-providers/features ### Description Fetches the feature flags associated with CLI providers, indicating available functionalities like terminal support. ### Method GET ### Endpoint /cli-providers/features ### Response #### Success Response (200) - **data.terminalEnabled** (boolean) - Indicates whether the terminal feature is enabled for CLI providers. ``` -------------------------------- ### Build for Production Source: https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-frontend/CLAUDE.md Builds the project for production deployment. ```bash npm run build ``` -------------------------------- ### Subscribe Consumer to Product Source: https://context7.com/higress-group/himarket/llms.txt Enrolls a consumer into a product, granting them access. Requires developer token. ```bash curl -s -X POST http://localhost:8080/consumers/con-001/subscriptions \ -H "Authorization: Bearer $DEV_TOKEN" \ -H "Content-Type: application/json" \ -d '{"productId":"prod-001"}' | jq . ``` -------------------------------- ### Upload Skill Package Source: https://context7.com/higress-group/himarket/llms.txt Upload a ZIP package for a skill to create a draft version. Ensure the Authorization header is set. ```bash # Upload a Skill ZIP package (creates draft version) curl -s -X POST http://localhost:8080/skills/prod-skill-001/package \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -F "file=@./my-skill-v1.0.0.zip" ``` -------------------------------- ### Get Subscribed MCP Servers for HiCoding CLI Source: https://context7.com/higress-group/himarket/llms.txt Retrieves the list of MCP servers subscribed to by the HiCoding CLI. ```APIDOC ## GET /cli-providers/market-mcps ### Description Lists the MCP (Machine Control Protocol) servers that are subscribed to and accessible by the HiCoding CLI. ### Method GET ### Endpoint /cli-providers/market-mcps ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. ``` -------------------------------- ### Batch Import Products from Gateway Source: https://context7.com/higress-group/himarket/llms.txt Imports multiple APIs from a specified gateway as products into the marketplace. Requires administrator token. ```bash curl -s -X POST http://localhost:8080/products/import \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{"gatewayId":"gw-001","apiIds":["api-001","api-002","api-003"]}' | jq . ``` -------------------------------- ### Get Available CLI Providers Source: https://context7.com/higress-group/himarket/llms.txt Fetches a list of available command-line interface (CLI) providers and their feature flags. ```APIDOC ## GET /cli-providers ### Description Retrieves information about the available CLI providers, including their display names and support for custom models. ### Method GET ### Endpoint /cli-providers ### Response #### Success Response (200) - **data** (array) - An array of objects, each representing a CLI provider with properties like `id`, `displayName`, and `supportsCustomModel`. ``` -------------------------------- ### Get CLI Provider Features Source: https://context7.com/higress-group/himarket/llms.txt Fetches the feature flags for CLI providers. This endpoint does not require an authorization token. ```bash curl -s http://localhost:8080/cli-providers/features | jq . ``` -------------------------------- ### Initialize External Project Repositories Source: https://github.com/higress-group/himarket/blob/main/AGENTS.md Use these bash commands to clone external project repositories. You can clone all repositories, a specific one, or provide a fork URL for editable projects. ```bash ./scripts/setup-repos.sh # 克隆所有外部仓库(可编辑项目会提示输入 fork 地址) ./scripts/setup-repos.sh nacos # 只克隆 nacos(只读) ./scripts/setup-repos.sh higress-doc # 克隆 higress 文档站(交互式输入 fork 地址) ./scripts/setup-repos.sh higress-doc git@github.com:yourname/higress-group.github.io.git # 直接指定 fork 地址,跳过交互提示 ``` -------------------------------- ### Configure Database Connection (Bash) Source: https://github.com/higress-group/himarket/blob/main/README.md Set environment variables for database connection details. Ensure these are exported before running the backend. ```bash export DB_HOST=localhost export DB_PORT=3306 export DB_NAME=himarket export DB_USERNAME=root export DB_PASSWORD=your_password ``` -------------------------------- ### Get cluster info from kubeconfig Source: https://context7.com/higress-group/himarket/llms.txt Retrieves information about a Kubernetes cluster by providing its kubeconfig. Requires an administrator token for authentication. ```bash curl -s -X POST http://localhost:8080/sandboxes/cluster-info \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{"kubeConfig":"apiVersion: v1\nkind: Config\n..."}' | jq . ``` -------------------------------- ### Get Subscribed Models for HiCoding CLI Source: https://context7.com/higress-group/himarket/llms.txt Retrieves the models subscribed to by the HiCoding CLI. Requires a development token for authorization. ```bash curl -s http://localhost:8080/cli-providers/market-models \ -H "Authorization: Bearer $DEV_TOKEN" | jq . ``` -------------------------------- ### List active sandbox instances Source: https://context7.com/higress-group/himarket/llms.txt Lists all currently active and ready sandbox instances. Requires an administrator token for authentication. ```bash curl -s http://localhost:8080/sandboxes/active \ -H "Authorization: Bearer $ADMIN_TOKEN" | jq '.data[]|{id,name,status}' ``` -------------------------------- ### Get portal profile Source: https://context7.com/higress-group/himarket/llms.txt Retrieves the profile information for a portal. This endpoint is public and resolves by the request's Host header. ```APIDOC ## GET /portals/profile ### Description Retrieves the public profile of a portal based on the Host header. ### Method GET ### Endpoint `/portals/profile` ### Parameters #### Query Parameters - **Host** (string) - Required - The custom domain name of the portal. ``` -------------------------------- ### Manage Products in Category Source: https://context7.com/higress-group/himarket/llms.txt Add multiple products to a category by their IDs or remove specific products from a category. Requires administrator token. ```bash # Add products to a category curl -s -X POST http://localhost:8080/product-categories/cat-001/products \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '["prod-001","prod-002","prod-003"]' ``` ```bash # Remove a product from a category curl -s -X DELETE http://localhost:8080/product-categories/cat-001/products \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '["prod-002"]' ``` -------------------------------- ### Get Primary Consumer Source: https://context7.com/higress-group/himarket/llms.txt Retrieves the details of the currently designated primary consumer for the authenticated developer. Requires developer token. ```bash curl -s http://localhost:8080/consumers/primary \ -H "Authorization: Bearer $DEV_TOKEN" | jq . ``` -------------------------------- ### Portal Creation Source: https://context7.com/higress-group/himarket/llms.txt Create a new portal, which serves as an isolated multi-tenant instance for the developer marketplace. This involves providing a name and description for the portal. The administrator token is required for this operation. ```bash # Create a portal curl -s -X POST http://localhost:8080/portals \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Enterprise AI Hub", "description": "Internal AI marketplace for engineering teams" }' | jq . # Response: # { # "code": "SUCCESS", # "data": {"id": "portal-001", "name": "Enterprise AI Hub", ...} # } ``` -------------------------------- ### Get Public MCP Tools List Source: https://context7.com/higress-group/himarket/llms.txt Retrieves the list of tools exposed by an MCP server for public consumption by AI clients. ```bash curl -s http://localhost:8080/products/prod-mcp-001/tools | jq . ``` -------------------------------- ### List All Portals Source: https://context7.com/higress-group/himarket/llms.txt Fetches a list of all available portals. Requires administrator authentication. ```bash curl -s http://localhost:8080/portals \ -H "Authorization: Bearer $ADMIN_TOKEN" | jq '.data.items[]|{id,name}' ``` -------------------------------- ### 启动后端服务脚本 Source: https://github.com/higress-group/himarket/blob/main/AGENTS.md 提供了一个用于启动后端服务的 shell 脚本。该脚本会自动处理环境变量加载、旧进程关闭、编译打包和后台启动。 ```bash ./scripts/run.sh ``` -------------------------------- ### Skeleton Screen Component Source: https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-frontend/FRONTEND_CODING_STANDARDS.md Example of a skeleton screen component using Tailwind's `animate-pulse`. This provides a visual placeholder while content is loading. ```tsx
``` ```tsx { loading ? : ; } ``` -------------------------------- ### Create a Coding Session Source: https://context7.com/higress-group/himarket/llms.txt Creates a new coding session in the cloud IDE. Specifies the session name and runtime environment. Requires a development token. ```bash # Create a coding session curl -s -X POST http://localhost:8080/coding-sessions \ -H "Authorization: Bearer $DEV_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Python Data Analysis", "runtime": "remote" }' | jq . ``` -------------------------------- ### Get Subscribed MCP Servers for HiCoding CLI Source: https://context7.com/higress-group/himarket/llms.txt Retrieves the MCP servers subscribed to by the HiCoding CLI. Requires a development token for authorization. ```bash curl -s http://localhost:8080/cli-providers/market-mcps \ -H "Authorization: Bearer $DEV_TOKEN" | jq . ``` -------------------------------- ### Browse and Read Skill Files Source: https://context7.com/higress-group/himarket/llms.txt Browse the file tree of a specific skill version or read the content of a particular file within that version. ```bash # Browse the Skill file tree curl -s "http://localhost:8080/skills/prod-skill-001/files?version=1.0.0" | jq . ``` ```bash # Read a specific file curl -s "http://localhost:8080/skills/prod-skill-001/files/src/index.ts?version=1.0.0" | jq . ``` -------------------------------- ### Download Skill Package Source: https://context7.com/higress-group/himarket/llms.txt Download a specific version of a skill package as a ZIP file. Developer token is required for this operation. ```bash # Download the Skill as ZIP curl -s -o my-skill.zip -L \ "http://localhost:8080/skills/prod-skill-001/download?version=1.0.0" \ -H "Authorization: Bearer $DEV_TOKEN" ``` -------------------------------- ### Get active MCP deployment count Source: https://context7.com/higress-group/himarket/llms.txt Fetches the count of active MCP deployments for a given sandbox. Requires the sandbox ID and an administrator token. ```bash curl -s http://localhost:8080/sandboxes/sandbox-001/active-deployments \ -H "Authorization: Bearer $ADMIN_TOKEN" | jq . ``` -------------------------------- ### Manage Skill Versions Source: https://context7.com/higress-group/himarket/llms.txt List available skill versions, publish a draft as a specific version, and set a version as the latest. Requires administrator token. ```bash # List available versions curl -s http://localhost:8080/skills/prod-skill-001/versions | jq . ``` ```bash # Publish the draft as version 1.0.0 curl -s -X POST http://localhost:8080/skills/prod-skill-001/versions \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{"version":"1.0.0"}' ``` ```bash # Set version 1.0.0 as latest curl -s -X PUT http://localhost:8080/skills/prod-skill-001/versions/latest \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{"version":"1.0.0"}' ``` -------------------------------- ### Administrator Login and Initialization Source: https://context7.com/higress-group/himarket/llms.txt APIs for administrator authentication, including initial setup, login, and password changes. These endpoints are crucial for managing the HiMarket platform. ```APIDOC ## Check Initialization Status ### Description Checks if the initial administrator account setup is required. ### Method GET ### Endpoint `/admins/need-init` ### Response #### Success Response (200) - **code** (string) - Response status code, e.g., "SUCCESS" - **data** (boolean) - True if initialization is needed, false otherwise. ### Response Example ```json { "code": "SUCCESS", "data": true } ``` ## Initialize Administrator Account ### Description Creates the first administrator account for the system. This should only be called if no admin account exists. ### Method POST ### Endpoint `/admins/init` ### Parameters #### Request Body - **username** (string) - Required - The desired username for the admin. - **password** (string) - Required - The desired password for the admin. ### Request Example ```json { "username": "admin", "password": "Admin@123456" } ``` ### Response #### Success Response (200) - **code** (string) - Response status code, e.g., "SUCCESS" - **data** (object) - Contains admin details and access token. - **id** (string) - The unique identifier for the admin user. - **username** (string) - The admin's username. - **access_token** (string) - JWT token for authenticating subsequent admin API calls. ### Response Example ```json { "code": "SUCCESS", "data": { "id": "abc123", "username": "admin", "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } } ``` ## Administrator Login ### Description Authenticates an existing administrator user and returns a JWT token. ### Method POST ### Endpoint `/admins/login` ### Parameters #### Request Body - **username** (string) - Required - The admin's username. - **password** (string) - Required - The admin's password. ### Request Example ```json { "username": "admin", "password": "Admin@123456" } ``` ### Response #### Success Response (200) - **code** (string) - Response status code, e.g., "SUCCESS" - **data** (object) - Contains login details and access token. - **id** (string) - The unique identifier for the admin user. - **username** (string) - The admin's username. - **access_token** (string) - JWT token for authenticating subsequent admin API calls. ### Response Example ```json { "code": "SUCCESS", "data": { "id": "abc123", "username": "admin", "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } } ``` ## Change Administrator Password ### Description Allows an administrator to change their password. ### Method PATCH ### Endpoint `/admins/password` ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. #### Request Body - **oldPassword** (string) - Required - The current password of the administrator. - **newPassword** (string) - Required - The new password for the administrator. ### Request Example ```json { "oldPassword": "Admin@123456", "newPassword": "NewPass@789" } ``` ### Response #### Success Response (200) - **code** (string) - Response status code, e.g., "SUCCESS" ### Response Example ```json { "code": "SUCCESS" } ``` ``` -------------------------------- ### Create an API product Source: https://context7.com/higress-group/himarket/llms.txt Creates a new API product, which wraps AI resources and exposes them with versioning and policy enforcement. ```APIDOC ## POST /products ### Description Creates a new API product. ### Method POST ### Endpoint `/products` ### Parameters #### Request Body - **name** (string) - Required - The name of the product. - **type** (string) - Required - The type of the product (e.g., MODEL_API). - **description** (string) - Optional - A description of the product. - **icon** (string) - Optional - URL of the product's icon. ``` -------------------------------- ### 格式化代码 Source: https://github.com/higress-group/himarket/blob/main/CONTRIBUTING_zh.md 在提交代码前,使用 Maven 或 npm 命令格式化 Java 或前端代码以符合项目规范。 ```bash mvn spotless:apply ``` ```bash cd himarket-web/himarket-admin npm run format ``` -------------------------------- ### Import a sandbox cluster Source: https://context7.com/higress-group/himarket/llms.txt Imports a Kubernetes cluster as a sandbox environment. Requires the cluster name and its kubeconfig. An administrator token is necessary. ```bash curl -s -X POST http://localhost:8080/sandboxes \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Production Sandbox", "kubeConfig": "apiVersion: v1\nkind: Config\n..." }' ``` -------------------------------- ### Check HiMarket Rollout Status and Get IPs Source: https://context7.com/higress-group/himarket/llms.txt Monitor the deployment status of HiMarket components in Kubernetes and retrieve the external IP addresses assigned to the LoadBalancer services. ```bash kubectl rollout status deployment/himarket-server -n himarket kubectl rollout status deployment/himarket-frontend -n himarket kubectl get svc -n himarket ``` -------------------------------- ### 同步仓库并创建新分支 Source: https://github.com/higress-group/himarket/blob/main/CONTRIBUTING_zh.md 在开始新功能开发前,同步你的 Fork 与上游仓库,并创建一个新的功能分支。 ```bash git checkout main git pull upstream main git push origin main git checkout -b feat/your-feature-name ``` -------------------------------- ### Get changed files since a timestamp Source: https://context7.com/higress-group/himarket/llms.txt Retrieves a list of files that have changed in the sandbox since a given Unix timestamp. Requires the current working directory and the timestamp. ```bash curl -s -X POST $SANDBOX/files/changes \ -H "Content-Type: application/json" \ -d '{"cwd":"/workspace","since":1704067200000}' | jq . ``` -------------------------------- ### Update MCP Server Service Introduction Source: https://context7.com/higress-group/himarket/llms.txt Updates the markdown description for an MCP server's service introduction. Requires administrator token. ```bash curl -s -X PUT http://localhost:8080/mcp-servers/meta/mcp-001/service-intro \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{"serviceIntro":"## Weather MCP\nProvides real-time and forecast weather data globally."}' ``` -------------------------------- ### Sync Computation and Constant Naming Source: https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-frontend/FRONTEND_CODING_STANDARDS.md Outlines naming conventions for synchronous computation functions and constants. Sync functions use `get`, `is`, or `has` prefixes, while constants use `UPPER_SNAKE_CASE`. ```tsx const getIconUrl = (icon?: IProductIcon): string => { ... }; ``` ```tsx const isActiveTab = (path: string) => { ... }; ``` ```tsx const READ_ONLY_KINDS = new Set(['read', 'search', 'think']); ``` ```tsx const EXT_TO_LANG: Record = { ... }; ``` -------------------------------- ### Download File from Sandbox Source: https://context7.com/higress-group/himarket/llms.txt Downloads a file from the remote sandbox as binary. Requires the file path and a development token. ```bash # Download a file as binary curl -s -o analysis.py -L \ "http://localhost:8080/workspace/download?path=/workspace/project/analysis.py" \ -H "Authorization: Bearer $DEV_TOKEN" ``` -------------------------------- ### Link Gateway API Reference to Product Source: https://context7.com/higress-group/himarket/llms.txt Associates an existing API reference from a gateway with a product. This makes the API available under the product's offering. Requires administrator token. ```bash curl -s -X POST http://localhost:8080/products/prod-001/ref \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{"gatewayId":"gw-001","apiId":"api-001"}' ``` -------------------------------- ### Get Portal Profile by Host Source: https://context7.com/higress-group/himarket/llms.txt Retrieves the public profile of a portal, resolving based on the request's Host header. Useful for accessing portal information via its domain. ```bash curl -s http://localhost:8080/portals/profile \ -H "Host: ai.example.com" | jq . ``` -------------------------------- ### List Coding Sessions Source: https://context7.com/higress-group/himarket/llms.txt Lists all available coding sessions. Requires a development token for authorization. ```bash curl -s http://localhost:8080/coding-sessions \ -H "Authorization: Bearer $DEV_TOKEN" | jq '.data.items[]|{id,name}' ``` -------------------------------- ### Get Files Changed Since Timestamp Source: https://context7.com/higress-group/himarket/llms.txt Retrieves a list of files that have changed in the workspace since a specified timestamp. Requires the current working directory and timestamp. A development token is needed. ```bash # Get files changed since a timestamp curl -s "http://localhost:8080/workspace/changes?cwd=/workspace/project&since=1704067200000" \ -H "Authorization: Bearer $DEV_TOKEN" | jq '.data.changes[]|{path,mtimeMs}' ``` -------------------------------- ### Deploy HiMarket with Kubernetes Helm Source: https://context7.com/higress-group/himarket/llms.txt This deploys HiMarket to a Kubernetes cluster. Nacos must be installed first. Customize resource sizes, enable sandboxes, and specify allowed commands using Helm values. ```bash helm dependency update deploy/helm/nacos helm dependency update deploy/helm/himarket helm install nacos deploy/helm/nacos \ --namespace himarket \ --create-namespace helm install himarket deploy/helm/himarket \ --namespace himarket \ --set size=standard \ --set server.jwtSecret="$(openssl rand -hex 32)" \ --set mysql.auth.password="$(openssl rand -hex 16)" \ --set sandbox.enabled=true \ --set sandbox.allowedCommands="qodercli,qwen,claude-agent-acp,opencode" ``` -------------------------------- ### Create Chat Session Source: https://context7.com/higress-group/himarket/llms.txt Initiate a new chat session, optionally associating it with multiple subscribed products. The response includes the session ID. ```bash # Create a chat session with multiple products curl -s -X POST http://localhost:8080/sessions \ -H "Authorization: Bearer $DEV_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Research Session", "products": ["prod-gpt4o-001", "prod-mcp-weather-001"] }' | jq . ``` -------------------------------- ### List Products with Filtering Source: https://context7.com/higress-group/himarket/llms.txt Retrieves a paginated list of products, with options to filter by type, keyword, and other parameters. Useful for discovering available products. ```bash curl -s "http://localhost:8080/products?page=0&size=10&type=MODEL_API&keyword=GPT" | jq . ``` -------------------------------- ### Format Code Source: https://github.com/higress-group/himarket/blob/main/CONTRIBUTING.md Format your Java and frontend code before committing to adhere to project style guidelines. Ensure `mvn spotless:apply` is run for Java code. ```bash # Format Java code (required) mvn spotless:apply # Format frontend code if you modified it cd himarket-web/himarket-admin npm run format ``` -------------------------------- ### Download File from Workspace Source: https://context7.com/higress-group/himarket/llms.txt Downloads a file from the sandbox workspace as binary data. ```APIDOC ## GET /workspace/download ### Description Downloads a file from the sandbox workspace. The response is binary data. ### Method GET ### Endpoint /workspace/download ### Parameters #### Query Parameters - **path** (string) - Required - The path to the file in the workspace. #### Headers - **Authorization** (string) - Required - Bearer token for authentication. ### Request Example ```bash curl -s -o analysis.py -L \ "http://localhost:8080/workspace/download?path=/workspace/project/analysis.py" \ -H "Authorization: Bearer $DEV_TOKEN" ``` ``` -------------------------------- ### Create Product Category Source: https://context7.com/higress-group/himarket/llms.txt Create a new product category with a name, icon, and sort order. The response includes the newly created category's ID. ```bash # Create a category curl -s -X POST http://localhost:8080/product-categories \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name":"Natural Language Processing","icon":"🧠","sortOrder":1}' | jq . ``` -------------------------------- ### Set Product Categories Source: https://context7.com/higress-group/himarket/llms.txt Assigns categories to a product for better organization and discoverability. Requires administrator token. ```bash curl -s -X POST http://localhost:8080/products/prod-001/categories \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '["cat-nlp","cat-vision"]' ``` -------------------------------- ### List Portal Subscriptions Source: https://context7.com/higress-group/himarket/llms.txt Retrieves a paginated list of subscriptions for a specific portal. Requires administrator authentication. ```bash curl -s "http://localhost:8080/portals/portal-001/subscriptions?page=0&size=20" \ -H "Authorization: Bearer $ADMIN_TOKEN" | jq . ``` -------------------------------- ### Refresh MCP Server Tools List Source: https://context7.com/higress-group/himarket/llms.txt Queries the live MCP server to refresh its list of available tools. Requires administrator token. ```bash curl -s -X POST http://localhost:8080/mcp-servers/meta/mcp-001/refresh-tools \ -H "Authorization: Bearer $ADMIN_TOKEN" | jq '.data.tools' ``` -------------------------------- ### Developer Registration and Login Source: https://context7.com/higress-group/himarket/llms.txt Manage developer accounts by registering new developers, approving their accounts (if required), logging them in to obtain JWT tokens, and retrieving or updating their profiles. Ensure the correct bearer token is used for authenticated requests. ```bash # Register a new developer curl -s -X POST http://localhost:8080/developers \ -H "Content-Type: application/json" \ -d '{ "username": "dev_alice", "password": "Dev@123456", "email": "alice@example.com", "portalId": "portal-001" }' | jq . # Response: # { # "code": "SUCCESS", # "data": { # "id": "dev-001", # "username": "dev_alice", # "access_token": "eyJhbGciOiJIUzI1NiJ9...", # "status": "PENDING" # } # } ``` ```bash # Admin approves developer curl -s -X PATCH http://localhost:8080/developers/dev-001/status \ -H "Authorization: Bearer $ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{"status":"APPROVED"}' ``` ```bash # Developer login DEV_TOKEN=$(curl -s -X POST http://localhost:8080/developers/login \ -H "Content-Type: application/json" \ -d '{"username":"dev_alice","password":"Dev@123456"}' \ | jq -r '.data.access_token') ``` ```bash # Get developer profile curl -s http://localhost:8080/developers/profile \ -H "Authorization: Bearer $DEV_TOKEN" | jq . ``` ```bash # Update profile curl -s -X PUT http://localhost:8080/developers/profile \ -H "Authorization: Bearer $DEV_TOKEN" \ -H "Content-Type: application/json" \ -d '{"email":"alice-new@example.com","avatarUrl":"https://example.com/avatar.png"}' ``` -------------------------------- ### Component and Props Interface Naming Source: https://github.com/higress-group/himarket/blob/main/himarket-web/himarket-admin/ADMIN_CODING_STANDARDS.md Use PascalCase for component names and `{ComponentName}Props` for their corresponding interface names. ```tsx export function ApiProductOverview() { ... } interface ApiProductOverviewProps { ... } ``` -------------------------------- ### 数据库访问示例 Source: https://github.com/higress-group/himarket/blob/main/AGENTS.md 演示了如何使用 shell 环境变量连接到数据库并执行 SQL 查询。请注意敏感信息的使用。 ```bash mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USERNAME" -p"$DB_PASSWORD" "$DB_NAME" -e "YOUR_SQL_HERE" ```