Values Guide
This page is automatically synced from
docs-en/values.md. Language: English | 中文
Values Guide
Section titled “Values Guide”Values are reusable configuration snippets that rules and scripts can reference. They are stored under the Bifrost data directory.
Storage
Section titled “Storage”~/.bifrost/values/Each key maps to one file; the file content is the value.
Rule References
Section titled “Rule References”ℹ️
{key}resolves both embedded value blocks defined in the same rule file and global Values created withbifrost value add(verified on the realbifrost startpath:resBody://{myval}emits the stored value). Notefile:///tpl://treat their value as a file path, so to emit a value as content use a content op likeresBody://{key}, notfile://{key}.
Define the value as an embedded block in the rule file and reference it with {name}:
``` ua.txtMozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X)```pattern ua://{ua.txt}CLI Management
Section titled “CLI Management”bifrost value listbifrost value show <name>bifrost value add <name> <value> # `set` is a hidden alias of `add`bifrost value update <name> <value>bifrost value delete <name>bifrost value import <file>The canonical subcommands are list, show, add, update, delete, and import. get (alias of show) and set (alias of add) work but are not shown by bifrost value --help.
Script Access
Section titled “Script Access”Scripts are meant to read Values from ctx.values:
var token = ctx.values["API_TOKEN"];if (token) { request.headers["Authorization"] = "Bearer " + token;}ℹ️
ctx.valuesis populated from global Values (verified, 0.0.96, realbifrost startpath): afterbifrost value add API_TOKEN ..., a script reads it viactx.values["API_TOKEN"]and it appears inObject.keys(ctx.values). The example above works as written.