Backend reference

From agent0ai/space-agent · View interactive version

Backend reference is an AI agent skill from the GitHub repository agent0ai/space-agent. Read-only reference for the backend contracts that the frontend depends on, including routing, APIs, auth, layers, and module resolution.

How to use this skill

Skill file

Use this skill when frontend work depends on understanding backend behavior. This skill is read-only context, not authorization to change backend files.

Hard Boundary

Page And Request Flow

Current request order is:

  1. API preflight handling
  2. /api/proxy
  3. /api/<endpoint>
  4. /mod/...
  5. /~/... and /L0/..., /L1/..., /L2/...
  6. page shells and page actions

The browser app mounts through page shells in server/pages/. /login is public. / and /admin require authentication.

API Families

Important frontend-facing endpoint families are:

These endpoints are thin wrappers over shared helpers in server/lib/customware/ and server/lib/auth/.

file_write still defaults to whole-file replacement, but it also supports operation: "append", "prepend", and "insert". Insert writes accept exactly one anchor through line, before, or after, use the first literal before or after match, treat line as a 1-based insertion point, and require utf8.

file_list and file_paths support access: "write" or writableOnly: true for writable-only discovery. They also support gitRepositories: true; with a pattern such as **/.git/, file_paths returns local-history owner roots like L1/team/ and L2/alice/ without exposing reserved .git metadata paths.

folder_download supports HEAD for permission-only validation and GET or POST for the streamed ZIP attachment. It creates the archive in server/tmp/ only for the actual download response, after the shared file-access layer approves the requested folder path.

git_history_list, git_history_diff, git_history_preview, git_history_rollback, and git_history_revert are enabled by CUSTOMWARE_GIT_HISTORY. The backend maps the requested path to a writable L1/<group>/ or L2/<user>/ owner repo, enforces permissions, paginates list metadata with optional file filters, reads per-file diffs separately, previews travel or revert affected files with optional operation-specific file patches, suppresses history scheduling during rollback, preserves ignored L2 auth files, preserves forward-travel refs during rollback when possible, and creates inverse commits for revert.

user_self_info is the frontend-facing identity snapshot. Frontend callers derive writable app roots from username, managedGroups, and _admin membership in groups without authorizing backend edits.

password_change is the authenticated self-service password-rotation endpoint for the current user. Frontend code should call it instead of writing ~/meta/password.json directly, because the backend validates the current password, seals the replacement verifier, clears sessions, and clears the current auth cookie.

user_crypto_session_key is the authenticated localStorage-restore endpoint. It returns the current session-derived wrapping key by hashing the live backend sessionId with the server-held session secret, so the browser can decrypt or encrypt the one persisted userCrypto localStorage blob without the server persisting that wrapping key or the user master key.

Module And Extension Resolution

Auth And User Storage

Why Frontend Developers Need This

Mandatory Doc Follow-Up

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.