fcode-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFactorial Code — CLI
Factorial Code — CLI
The CLI develops and tests processes locally and syncs them with
Factorial Code Cloud. For the platform model see .
fcodefcode-core-conceptsfcodefcode-core-conceptsCommand flow
命令工作流
When making and testing changes:
- (optional, first) — if the cloud may have changed, sync down so you work with the latest version.
fcode pull - Edit local files (processes, modules, variables, dependencies).
- — only when you created NEW resources (new process, module, dependency, or variable). Skip for edits to existing code.
fcode add - — if you changed
fcode dependencies:installordependencies/package.json.dependencies/requirements.txt - — execute the process locally to test.
fcode run <process-slug> - — deploy to cloud when ready.
fcode push
Pushing updates the current (unversioned) code only: consumers pinned to the
alias — which webhook URLs and form embeds should always be — keep
running the released version until the alias moves. Releases (publishing a
workspace version and re-pointing ) happen separately, normally from the
web UI (see below).
stablestable进行变更和测试时:
- (可选,第一步)——如果云端可能有变更,先同步最新版本到本地,确保基于最新内容工作。
fcode pull - 编辑本地文件(流程、模块、变量、依赖项)。
- ——仅当你创建了新资源(新流程、模块、依赖项或变量)时执行。编辑现有代码时无需执行此命令。
fcode add - ——如果修改了
fcode dependencies:install或dependencies/package.json,执行此命令。dependencies/requirements.txt - ——在本地执行流程进行测试。
fcode run <process-slug> - ——准备就绪后部署到云端。
fcode push
推送操作仅更新当前(未版本化)代码:固定到别名的消费者——webhook URL和表单嵌入应始终使用该别名——会继续运行已发布版本,直到别名指向变更。发布操作(发布工作区版本并重新指向)需单独进行,通常通过Web UI完成(见下文)。
stablestableGotchas
注意事项
- Never run before
fcode runwhen the process (or other resource) was just created — you'll hit "Local process not found".fcode add - is only for NEW resources. For edits to existing process/module code or variables, go straight to
fcode add.fcode push - (on
--force/push) overwrites the other side. Both commands fail when local and cloud diverge; only usepullwith explicit user confirmation.--force - Never edit . It holds the parent workspaces' variables, is regenerated on pull, and
variables.inherited.envskips it with a warning. Overriding an inherited value means adding the key tofcode push.variables.env
- 当流程(或其他资源)刚创建时,切勿在之前运行
fcode add——否则会出现“Local process not found”错误。fcode run - 仅适用于新资源。对于现有流程/模块代码或变量的编辑,直接执行
fcode add即可。fcode push - 参数(用于
--force/push)会覆盖另一方内容。当本地和云端内容不一致时,两个命令都会失败;仅在获得用户明确确认后使用pull。--force - 切勿编辑。该文件存储父工作区的变量,会在pull操作时重新生成,
variables.inherited.env会跳过该文件并发出警告。要覆盖继承的值,需将键添加到fcode push中。variables.env
Commands
命令说明
fcode add
fcode addfcode add
fcode addRegisters new local resources with the CLI so they can be run or deployed.
Run after creating a new process/module/dependency/variable, before /.
Not needed after only editing existing resources.
runpush向CLI注册新的本地资源,以便运行或部署。创建新流程/模块/依赖项/变量后,在执行/之前运行此命令。仅编辑现有资源时无需执行。
runpushfcode dependencies:install
fcode dependencies:installfcode dependencies:install
fcode dependencies:installInstalls dependencies into the local workspace. Run after changing
or .
dependencies/package.jsondependencies/requirements.txt将依赖项安装到本地工作区。修改或后执行此命令。
dependencies/package.jsondependencies/requirements.txtfcode run <process-slug> --parameters <filepath | json>
fcode run <process-slug> --parameters <filepath | json>fcode run <process-slug> --parameters <filepath | json>
fcode run <process-slug> --parameters <filepath | json>Executes a process locally for development/testing. Uses /
and the given parameters (or the process's
by default). Shows logs, results, and errors.
variables.envvariables.local.envparameters.jsonsh
fcode run my-process --parameters '{"key": "value"}'
fcode run my-process --parameters ./params.json
fcode run my-process # default parameters.json
fcode run my-process --locale pt-BR # resolve fcode.i18n in that localePrerequisite: run first if the resource was just created.
fcode add--localefcode.i18ni18n/fcode-i18n在本地执行流程以进行开发/测试。使用/和指定的参数(默认使用流程的)。显示日志、结果和错误信息。
variables.envvariables.local.envparameters.jsonsh
fcode run my-process --parameters '{"key": "value"}'
fcode run my-process --parameters ./params.json
fcode run my-process # 默认使用parameters.json
fcode run my-process --locale pt-BR # 以该区域解析fcode.i18n前提条件:如果资源刚创建,需先运行。
fcode add--localei18n/fcode.i18nfcode-i18nfcode http
fcode httpfcode http
fcode httpStarts a local HTTP server (, default ) that replicates the cloud
webhook environment and also serves the workspace's form schemas, so
webhook-triggered processes and forms can be exercised without deploying.
--port3000--auth-user--auth-passwordwebhook.authModemetadata.jsonTEAMwebhookAuthteam.jsonBearer <token>Authorizationvariables.inherited.envvariables.envvariables.local.envTEAM403Two things to watch locally:
- A secret variable pulls down as the placeholder, so local auth only accepts
********until the real value is in********.variables.local.env - /
--auth-userconsume the--auth-passwordheader, so they can't be combined with a webhook expecting its credential there. The server warns about this at startup.Authorization
启动本地HTTP服务器(参数指定端口,默认3000),该服务器复制云端webhook环境,同时提供工作区的表单模式,无需部署即可测试webhook触发的流程和表单。
--port--auth-user--auth-passwordmetadata.jsonwebhook.authModeteam.jsonwebhookAuthTEAMAuthorizationBearer <token>variables.inherited.envvariables.envvariables.local.envTEAM403本地运行时需注意两点:
- 机密变量会以占位符的形式拉取,因此本地认证仅接受
********,直到真实值被添加到********中。variables.local.env - /
--auth-user会占用--auth-password头,因此无法与期望在该头中获取凭证的webhook结合使用。服务器在启动时会对此发出警告。Authorization
fcode pull
fcode pullfcode pull
fcode pullDownloads the latest processes, modules, variables, and dependencies from the
cloud, overwriting local files to match. Run before starting work if others may
have changed cloud resources, or to discard local changes. only with
user confirmation.
--force从云端下载最新的流程、模块、变量和依赖项,覆盖本地文件以保持一致。如果其他人可能修改了云端资源,或要丢弃本地变更,在开始工作前运行此命令。仅在获得用户确认后使用。
--forcefcode push
fcode pushfcode push
fcode pushUploads local changes to the cloud. Run after local changes (run
first only if you created new resources); recommended to first.
only with user confirmation.
fcode addfcode run--force将本地变更上传到云端。本地变更完成后运行此命令(仅当创建了新资源时需先运行);建议先执行测试。仅在获得用户确认后使用。
fcode addfcode run--forcefcode team:pull
/ team:push
/ team:status
fcode team:pullteam:pushteam:statusfcode team:pull
/ team:push
/ team:status
fcode team:pullteam:pushteam:statusSync the workspace-level settings in on their own: writes
the cloud settings into the file, applies the file, and
reports whether they changed locally, in the cloud, or both. Plain /
include them too, running them last so a referenced error-handler
process slug resolves against processes that already exist.
team.jsonteam:pullteam:pushteam:statusfcode pullfcode push单独同步工作区根目录中的工作区级设置:将云端设置写入文件,应用文件中的设置,报告本地、云端或两者的设置是否有变更。普通的/也会包含这些设置,但会最后执行,确保引用的错误处理流程slug能解析到已存在的流程。
team.jsonteam:pullteam:pushteam:statusfcode pullfcode pushfcode team:versions:*
/ fcode team:aliases:*
fcode team:versions:*fcode team:aliases:*fcode team:versions:*
/ fcode team:aliases:*
fcode team:versions:*fcode team:aliases:*Workspace versioning publishes a version of the whole workspace: every
process and module the team owns gets a version with the same tag, and bare
module imports are pinned to it inside the published snapshots (model in
). Releases normally happen from the web UI (team
settings → Versions tab) — these commands are the scriptable equivalent.
Don't create versions or move unless explicitly asked.
fcode-core-conceptsstablesh
fcode team:versions:create v1.0.0 --comment "First stable release"
fcode team:versions:list
fcode team:versions:delete v1.0.0 # cascades; asks confirmation unless --force
fcode team:aliases:set stable v1.0.0 # create or re-point; rollback = older tag
fcode team:aliases:list
fcode team:aliases:delete stable- skips entities already carrying the exact tag and reports a per-entity summary (created / skipped / failed — the version's manifest), then pulls so the
team:versions:createfolders andversions/<tag>/refresh locally. Re-running the same tag after a partial failure only publishes what is still missing.team.json - cascades: every owned process/module version with the tag is deleted, together with the aliases, executions, and schedules referencing them.
team:versions:delete - upserts — it creates the alias or re-points an existing one on every owned entity that has the target tag published (entities without it are skipped and reported). Re-pointing
team:aliases:setat an older tag is the rollback: every consumer pinned tostableswitches in one operation.stable
工作区版本管理会发布整个工作区的版本:团队拥有的每个流程和模块都会获得相同标签的版本,裸模块导入会固定到已发布快照中的该版本(模型请参考)。发布操作通常通过Web UI完成(团队设置→Versions标签)——这些命令是可脚本化的等效操作。除非明确要求,否则不要创建版本或移动别名。
fcode-core-conceptsstablesh
fcode team:versions:create v1.0.0 --comment "First stable release"
fcode team:versions:list
fcode team:versions:delete v1.0.0 # 级联删除;除非使用--force,否则会要求确认
fcode team:aliases:set stable v1.0.0 # 创建或重新指向;回滚即指向旧标签
fcode team:aliases:list
fcode team:aliases:delete stable- ****会跳过已携带完全相同标签的实体,并报告每个实体的摘要(已创建/已跳过/失败——版本清单),然后执行pull操作,刷新本地的
team:versions:create文件夹和versions/<tag>/。部分失败后重新运行相同标签,仅发布仍缺失的内容。team.json - 会级联删除:所有带有该标签的自有流程/模块版本,以及引用它们的别名、执行记录和调度都会被删除。
team:versions:delete - 会更新或插入——它会在所有已发布目标标签的自有实体上创建别名或重新指向现有别名(没有该标签的实体会被跳过并报告)。将
team:aliases:set重新指向旧标签就是回滚操作:所有固定到stable的消费者会一次性切换版本。stable
fcode i18n:*
fcode i18n:*fcode i18n:*
fcode i18n:*i18n:pulli18n:pushi18n:statusi18n:add <locale>i18n:remove <locale>i18n:reseti18n/<locale>.yamli18n/<locale>.inherited.yamlpullfcode pullpushstatusfcode-i18ni18n:pulli18n:pushi18n:statusi18n:add <locale>i18n:remove <locale>i18n:reseti18n/<locale>.yamli18n/<locale>.inherited.yamlfcode pullpushstatusfcode-i18nProcess metadata — metadata.json
metadata.json流程元数据 — metadata.json
metadata.jsonEach process folder holds — the source of
truth for the process's name, description, tags, triggers, and settings. It
round-trips with /: edit the file and to change these
settings in the cloud, no dashboard needed. Changes show as 🔺 modified in
.
processes/<slug>/metadata.jsonpushpullfcode pushfcode status| Field | Type | Meaning |
|---|---|---|
| string | Display name (defaults to the slug) |
| string, optional | Process description |
| string[] | Tags (defaults to |
| object, optional | Webhook trigger: |
| object, optional | Form settings: |
json
{
"name": "Order sync",
"description": "Syncs Shopify orders into Factorial",
"tags": ["integration", "shopify"],
"webhook": {
"enabled": true,
"authMode": "CUSTOM",
"auth": { "variableKey": "SHOPIFY_WEBHOOK_TOKEN" }
},
"form": { "enabled": false }
}A webhook that inherits the workspace configuration carries
, and a public one only
.
"webhook": { "enabled": true, "authMode": "TEAM" }"webhook": { "enabled": true }json
{
"name": "Connect your account",
"tags": ["setup"],
"form": { "enabled": true, "authMode": "FACTORIAL", "appRole": "INSTALL" }
}Notes:
- stores only the variable name, never a token — so the file is safe to commit. The variable doesn't have to exist yet; until it does, every call to the webhook is rejected with
webhook.auth.variableKey. Both plain and secret variables work.403 - inherits
authMode: TEAMfromwebhookAuth. When that configuration is missing, the webhook rejects every call — it never reads as public. Through MCP this matters: an agent can setteam.jsonbut there is no team-settings tool, so the configuration has to exist already (set it inauthMode: TEAMandteam.json).fcode team:push - defaults to
webhook.auth.headerName, whose value must beAuthorization; any other header carries the raw variable value. Valid names are RFC 7230 token characters, at most 64 of them, andBearer <token>,Cookieand theHostprefix are rejected. Prefer the default: a bespoke header loses the redaction proxies and log pipelines giveFcode-. Use one only when the sender can't setAuthorization— Factorial's own webhook sender, which puts its token inAuthorization, is the case in point.x-factorial-wh-challenge - ,
form.authModeandform.appRoleare omitted when they arewebhook.authMode, as isNONEwhen it iswebhook.auth.headerName, so a plain public form carries onlyAuthorization. To lift protection from a protected form or webhook, write"form": { "enabled": true }explicitly — omitting the field leaves the stored mode untouched, and sending"authMode": "NONE"withoutauthis rejected.authMode: CUSTOM - Omit unless the process belongs to a marketplace app.
form.appRole - If is missing,
metadata.jsonscaffoldsfcode add; invalid JSON falls back to those defaults with a warning.{ "name": "<slug>", "tags": [] }
每个流程文件夹中都包含——这是流程名称、描述、标签、触发器和设置的权威来源。它会随/双向同步:编辑该文件并执行即可在云端更改这些设置,无需使用仪表板。变更会在中显示为🔺 modified。
processes/<slug>/metadata.jsonpushpullfcode pushfcode status| 字段 | 类型 | 含义 |
|---|---|---|
| string | 显示名称(默认值为slug) |
| string, optional | 流程描述 |
| string[] | 标签(默认值为 |
| object, optional | Webhook触发器: |
| object, optional | 表单设置: |
json
{
"name": "Order sync",
"description": "Syncs Shopify orders into Factorial",
"tags": ["integration", "shopify"],
"webhook": {
"enabled": true,
"authMode": "CUSTOM",
"auth": { "variableKey": "SHOPIFY_WEBHOOK_TOKEN" }
},
"form": { "enabled": false }
}继承工作区配置的webhook会携带,公开webhook仅携带。
"webhook": { "enabled": true, "authMode": "TEAM" }"webhook": { "enabled": true }json
{
"name": "Connect your account",
"tags": ["setup"],
"form": { "enabled": true, "authMode": "FACTORIAL", "appRole": "INSTALL" }
}注意事项:
- 仅存储变量名称,从不存储令牌——因此该文件可安全提交。变量无需预先存在;在变量创建之前,所有webhook调用都会被拒绝并返回
webhook.auth.variableKey。普通变量和机密变量均适用。403 - 继承
authMode: TEAM中的team.json。当该配置缺失时,webhook会拒绝所有调用——绝不会视为公开。通过MCP时这一点很重要:代理可设置webhookAuth,但没有团队设置工具,因此配置必须预先存在(在authMode: TEAM中设置并执行team.json)。fcode team:push - 默认为
webhook.auth.headerName,其值必须为Authorization;任何其他头都携带变量的原始值。有效名称为RFC 7230令牌字符,最多64个,Bearer <token>、Cookie和Host前缀会被拒绝。建议使用默认值:自定义头会失去代理和日志管道对Fcode-头的脱敏处理。仅当发送方无法设置Authorization时才使用自定义头——Factorial自身的webhook发送方会将令牌放入Authorization,就是这种情况。x-factorial-wh-challenge - 当、
form.authMode和form.appRole为webhook.authMode时会被省略,NONE为webhook.auth.headerName时也会被省略,因此普通公开表单仅携带Authorization。要取消受保护表单或webhook的保护,需显式写入"form": { "enabled": true }——省略该字段会保留存储的模式,发送"authMode": "NONE"但未设置auth会被拒绝。authMode: CUSTOM - 除非流程属于市场应用,否则省略。
form.appRole - 如果缺失,
metadata.json会生成脚手架fcode add;无效JSON会回退到这些默认值并发出警告。{ "name": "<slug>", "tags": [] }
Calling a webhook — pin the version in the URL
调用webhook — 在URL中固定版本
The webhook endpoint is
.
Always pin the version with the query parameter, pointing at the
alias — subscription systems rarely let you set request headers:
https://code.factorialhr.com/platform/api/<team-slug>/webhooks/<process-slug>version_tagstablesh
curl -X POST "https://code.factorialhr.com/platform/api/<team-slug>/webhooks/<process-slug>?version_tag=stable"- takes a version tag (
version_tag) or an alias. Usev1.0.0: it always exists, and releases/rollbacks then happen by moving the alias — the external system is never touched. It is equivalent to thestableheader and takes precedence over it.Fcode-Version-Tag,version_tagandasyncare reserved names, stripped before the parameters reach the process (localeselects the execution's language — seelocale).fcode-i18n - An unknown or malformed version does not fail the call. The process runs its current version and the platform only logs a server-side warning — a typo runs the current version silently. When a run behaves unexpectedly, check the execution's version.
Webhook端点为。始终使用查询参数固定版本,指向别名——订阅系统通常不允许设置请求头:
https://code.factorialhr.com/platform/api/<team-slug>/webhooks/<process-slug>version_tagstablesh
curl -X POST "https://code.factorialhr.com/platform/api/<team-slug>/webhooks/<process-slug>?version_tag=stable"- 接受版本标签(
version_tag)或别名。使用v1.0.0:它始终存在,发布/回滚操作只需移动别名——无需修改外部系统。它等效于stable头,且优先级更高。Fcode-Version-Tag、version_tag和async是保留名称,在参数到达流程前会被剥离(locale选择执行的语言——请参考locale)。fcode-i18n - 未知或格式错误的版本不会导致调用失败。流程会运行其当前版本,平台仅在服务器端记录警告——拼写错误会静默运行当前版本。当运行行为异常时,请检查执行的版本。
Team settings — team.json
team.json团队设置 — team.json
team.jsonA singleton file at the workspace root holding team-level settings. Synced by
/ / , and included in plain
/ (pushed last, so a referenced error-handler process
exists first).
fcode team:pullteam:pushteam:statusfcode pushpull| Field | Type | Meaning |
|---|---|---|
| string[] | Teams this workspace inherits processes, modules and variables from (direct parents only, max 5) |
| string, optional | Team timezone (e.g. for schedules) |
| object, optional | |
| object, optional | |
| string, optional | The workspace's main language: the locale used when a caller names none, and the key-level fallback for untranslated keys (see |
| array, pull-only | Workspace versions: |
| array, pull-only | Workspace aliases: |
json
{
"parentTeamSlugs": ["base-app"],
"zoneId": "Europe/Madrid",
"errorHandlerConfig": { "processSlug": "error-handler", "tag": null },
"webhookAuth": {
"headerName": "x-factorial-wh-challenge",
"variableKey": "FACTORIAL_CHALLENGE_TOKEN"
},
"versions": [
{ "tag": "v1.0.0", "comment": "First stable release", "createdAt": "2026-08-01T10:00:00" }
],
"aliases": [{ "name": "stable", "tag": "v1.0.0" }]
}The error handler is referenced by slug (not id) so is
portable across teams; the CLI resolves it to the cloud id on push.
team.jsonversionsaliasesteam:pullteam:pushteam:versions:*team:aliases:*webhookAuth- It is per-workspace and not inherited through . Auth is resolved against the workspace addressed in the webhook URL, not the one that owns the code, so an app inheriting a webhook process from a base app still needs its own
parentTeamSlugsentry.webhookAuth - Removing the object and pushing clears the cloud configuration, which makes every webhook inheriting it reject all calls.
工作区根目录的单例文件,存储团队级设置。通过//同步,普通的/也会包含这些设置(最后推送,确保引用的错误处理流程已存在)。
fcode team:pullteam:pushteam:statusfcode pushpull| 字段 | 类型 | 含义 |
|---|---|---|
| string[] | 该工作区继承流程、模块和变量的团队(仅直接父团队,最多5个) |
| string, optional | 团队时区(例如用于调度) |
| object, optional | |
| object, optional | |
| string, optional | 工作区的主要语言:当调用者未指定区域时使用的区域,以及未翻译键的键级回退(请参考 |
| array, pull-only | 工作区版本: |
| array, pull-only | 工作区别名: |
json
{
"parentTeamSlugs": ["base-app"],
"zoneId": "Europe/Madrid",
"errorHandlerConfig": { "processSlug": "error-handler", "tag": null },
"webhookAuth": {
"headerName": "x-factorial-wh-challenge",
"variableKey": "FACTORIAL_CHALLENGE_TOKEN"
},
"versions": [
{ "tag": "v1.0.0", "comment": "First stable release", "createdAt": "2026-08-01T10:00:00" }
],
"aliases": [{ "name": "stable", "tag": "v1.0.0" }]
}错误处理流程通过slug(而非ID)引用,因此可在团队间移植;CLI会在推送时将其解析为云端ID。
team.jsonversionsaliasesteam:pullteam:pushteam:versions:*team:aliases:*webhookAuth- 它是每个工作区独有的,不会通过继承。认证是针对webhook URL中指定的工作区解析的,而非拥有代码的工作区,因此从基础应用继承webhook流程的应用仍需自己的
parentTeamSlugs条目。webhookAuth - 删除该对象并推送会清除云端配置,这会使所有继承该配置的webhook拒绝所有调用。
The three variables files
三个变量文件
Team variables live in three files at the workspace root:
.env| File | Holds | Synced |
|---|---|---|
| The variables this workspace owns | Committed; pushed and pulled |
| The variables inherited from parent workspaces ( | Pull-only; gitignored (the CLI adds the entry) |
| Local-only overrides | Never pushed, never pulled |
Resolution order for a local run (highest wins), matching what the cloud
does: → → .
variables.local.envvariables.envvariables.inherited.envPrecedence is decided by which file declares a key, not by its value — so
blanking a key in overrides the inherited variable with an empty
string rather than falling through to the parent.
variables.env团队变量存储在工作区根目录的三个文件中:
.env| 文件 | 存储内容 | 同步方式 |
|---|---|---|
| 该工作区拥有的变量 | 可提交;会被推送和拉取 |
| 从父工作区( | 仅可拉取;已加入git忽略(CLI会添加该条目) |
| 仅本地生效的覆盖变量 | 从不推送,从不拉取 |
本地运行的解析顺序(优先级从高到低),与云端一致: → → 。
variables.local.envvariables.envvariables.inherited.env优先级由哪个文件声明键决定,而非值——因此在中将键设为空字符串会覆盖继承的变量,而非回退到父工作区的值。
variables.envOverriding an inherited variable
覆盖继承的变量
Adding the key to is the override. From that point the CLI
treats it as this workspace's own variable: shows it as new,
creates it here, and offers it.
variables.envfcode statusfcode pushfcode variables:add- Don't edit — it is regenerated on every pull, and
variables.inherited.envskips inherited variables with a warning. Editing one only warns.fcode push - Don't copy a parent's variables into a child workspace to "make them
available" — they already resolve. Only add a key when this workspace genuinely
needs a different value. (Workspaces provisioned before inheritance existed may
still hold such copies, which now shadow the parent — including untouched
placeholders shadowing a secret that would otherwise resolve. Flag those to the user rather than deleting them.)
******** - Deleting your override (removing the key from and pushing) brings the parent's value back.
variables.env
fcode variables:status🔗 <slug>fcode-core-conceptsfcode.variablesfcode-javascriptfcode-pythonThe file names are settings (,
, ) — assume the defaults
above unless the workspace says otherwise.
variablesFileNameinheritedVariablesFileNamelocalVariablesFileName将键添加到即完成覆盖。此后CLI会将其视为该工作区的自有变量:会显示为新增,会在云端创建它,会提供该变量。
variables.envfcode statusfcode pushfcode variables:add- 切勿编辑——它会在每次pull操作时重新生成,
variables.inherited.env会跳过继承变量并发出警告。编辑该文件只会收到警告。fcode push - 切勿将父工作区的变量复制到子工作区以“使其可用”——它们已被解析。仅当该工作区确实需要不同值时才添加键。(继承功能出现之前配置的工作区可能仍有此类副本,现在会覆盖父工作区的值——包括未修改的占位符会覆盖原本可解析的机密变量。需向用户标记这些情况,而非直接删除。)
******** - 删除覆盖项(从中移除键并推送)会恢复父工作区的值。
variables.env
fcode variables:status🔗 <slug>fcode-core-conceptsfcode.variablesfcode-javascriptfcode-python文件名是可配置的(、、)——除非工作区另有说明,否则使用上述默认名称。
variablesFileNameinheritedVariablesFileNamelocalVariablesFileNameVariable sensitivity — variables.meta.json
variables.meta.json变量敏感性 — variables.meta.json
variables.meta.jsonA workspace-root file mapping each variable to its sensitivity flag:
json
{
"ACME_API_KEY": { "isSensitive": true },
"ACME_BASE_URL": { "isSensitive": false }
}- Create a sensitive variable with (then set its value and push); the flag lands here.
fcode variables:add --sensitive - Variables created at runtime with are sensitive by default — pass
fcode.variables.set(JS) /sensitive: false(Python) for plain config. Seesensitive=False/fcode-javascript.fcode-python - Sensitive values never leave the cloud: writes the placeholder
pullinto********— and intovariables.envfor an inherited secret. Don't replace the placeholder in either file — put the real value invariables.inherited.envfor local runs. Remotely, an inherited secret's real value is available to executions (seevariables.local.env); only the local copy is masked.fcode-core-concepts - is immutable once pushed. Editing it in
isSensitiveis rejected on push (🚫 invariables.meta.json) — revert to match remote.fcode status
工作区根目录的文件,将每个变量映射到其敏感性标志:
json
{
"ACME_API_KEY": { "isSensitive": true },
"ACME_BASE_URL": { "isSensitive": false }
}- 使用创建机密变量(然后设置其值并推送);该标志会存储在此文件中。
fcode variables:add --sensitive - 通过在运行时创建的变量默认是机密的——对于普通配置,需传递
fcode.variables.set(JS)/sensitive: false(Python)。请参考sensitive=False/fcode-javascript。fcode-python - 机密值永远不会离开云端:操作会在
pull中写入占位符variables.env——对于继承的机密变量,会在********中写入该占位符。切勿替换任一文件中的占位符——将真实值放入variables.inherited.env用于本地运行。在远程环境中,继承的机密变量的真实值可用于执行(请参考variables.local.env);仅本地副本会被掩码。fcode-core-concepts - 一旦推送就不可变。在
isSensitive中编辑它会在推送时被拒绝(variables.meta.json中显示🚫)——需回退以匹配远程版本。fcode status
Getting secret values for local runs
获取本地运行的机密值
When a local run (, a discovery script) needs a real secret value
that isn't in yet, ask the user to provide it. If they
prefer not to share the value with the agent, ask them to add the
line to themselves — local runs pick it up
without the value ever appearing in the conversation.
fcode runvariables.local.envKEY=valuevariables.local.env- values are never pushed. Remind the user to also create those secret variables manually in the remote demo environment —
variables.local.envwon't carry the values.fcode push - : needed locally only — the remote environment populates it automatically, so don't create it there. To obtain it, the user completes the OAuth flow in the Factorial Code app details page, then copies the generated token with the copy dropdown option in the OAuth Dev app, and puts it in
FACTORIAL_TOKEN(or shares it, per their preference).variables.local.env - Once obtained, never echo secret values back in output or logs.
当本地运行(、发现脚本)需要真实的机密值且该值尚未在中时,请让用户提供该值。如果用户不愿与代理共享该值,请让他们自行将行添加到中——本地运行会自动读取该值,且值不会出现在对话中。
fcode runvariables.local.envKEY=valuevariables.local.env- 中的值永远不会被推送。提醒用户还需在远程演示环境中手动创建这些机密变量——
variables.local.env不会携带这些值。fcode push - :仅本地运行需要——远程环境会自动填充该值,因此无需在远程创建。要获取该令牌,用户需在Factorial Code应用详情页完成OAuth流程,然后在OAuth Dev应用中使用复制下拉选项复制生成的令牌,并将其放入
FACTORIAL_TOKEN中(或根据偏好共享)。variables.local.env - 获取后,切勿在输出或日志中回显机密值。
Examples
示例
Development cycle (new process):
sh
fcode add
fcode dependencies:install # if dependencies changed
fcode run shopify-order-sync --parameters '{"dateFrom":"2024-01-01","dateTo":"2024-01-31"}'
fcode push # no need to re-run `add` if nothing new was createdDeploy an existing, tested process:
sh
fcode push # `add` not needed — process already registered开发周期(新流程):
sh
fcode add
fcode dependencies:install # 如果依赖项有变更
fcode run shopify-order-sync --parameters '{"dateFrom":"2024-01-01","dateTo":"2024-01-31"}'
fcode push # 如果未创建新资源,无需重新运行`add`部署已测试的现有流程:
sh
fcode push # 无需`add`——流程已注册