- Added `--route` and `--method` options to `function execute` command for better HTTP handling. - Improved `get function` command to display additional function metadata including HTTP settings, cache status, network restrictions, RAM limits, timeouts, and tags. - Removed deprecated `helloworld` command. - Expanded `update function` command with new options for Docker mounts, network restrictions, and various installation flags, including better error handling for boolean and number options. - Introduced environment variable management commands: `add`, `list`, and `remove` for account-wide environment variables. - Added `export` command to export authenticated account data. - Implemented `api openapi` and `api request` commands for direct API interaction. - Created logging and rate limit management commands for functions. - Added MCP tool commands for calling tools, fetching documentation, and initializing sessions. - Introduced utility functions for JSON handling and environment variable normalization. - Set up CI/CD pipeline with Gitea Actions for automated testing, building, and publishing. - Updated configuration loading to support environment variables for instance and token.
2.4 KiB
Agent Notes for SHSF CLI
This repository is the TypeScript CLI for SHSF. The sibling repository ../shsf is the authoritative source for backend routes, request bodies, MCP tools, and platform behavior.
Before Changing Commands
- Inspect
../shsf/Backend/src/routesfor the live REST route. - Inspect
../shsf/Backend/src/lib/mcpfor agent-facing MCP tool behavior. - Prefer updating typed command wrappers for common workflows and rely on
shsf api requestfor rare or admin-only routes. - Run
pnpm testandpnpm buildbefore considering the change complete.
Command Architecture
Commands are auto-loaded from src/commands. Directory names become command groups. Each command file exports a definition object:
export const commandDefinition = {
name: "example <arg>",
description: "Do something",
options: [{ name: "--flag <value>", description: "Example option" }],
action: async (arg: string, options: any) => {}
};
Use getApiClient() from src/api.ts for REST calls. It handles SHSF_INSTANCE, SHSF_TOKEN, auth headers, content type, user agent, and timeout.
Current Backend Alignment
The live backend expects function settings under settings for fields such as:
allow_httpsecure_headermax_ramtimeouttagsretry_on_failureretry_countcache_enabledcache_ttl
Top-level function fields include runtime/container controls such as image, startup_file, namespaceId, executionAlias, docker_mount, network_restricted, ffmpeg_install, opencv_install, imported, ai_kicked_off, and cors_origins.
Agent-Ready Interfaces
Keep these commands working because they let agents recover when the typed CLI surface is behind the backend:
shsf api openapishsf api request <method> <path>shsf mcp infoshsf mcp initshsf mcp toolsshsf mcp docsshsf mcp call <tool>
Agents writing SHSF function source should call shsf mcp docs first. The SHSF MCP server also instructs clients to call get_docs before writing function code.
CI/CD
Use Gitea Actions only. Workflow files live in .gitea/workflows. Do not add GitHub Actions or Copilot instructions back unless the project owner explicitly requests that migration.
The workflow should keep pnpm-store caching, test/build gates, npm publish guarded by NPM_TOKEN, and Gitea release creation guarded by GITEA_TOKEN.