跳到內容
AggregaAggregaAggregaAggrega
選擇語言: 繁體中文
本頁為機器翻譯。閱讀英文原文。

aggrega config

檢視並管理工作區設定

概要

aggrega config

說明

Inspect and manage the configuration Aggrega reads.
Most projects need two files.
One .aggrega-config.yaml at your project root, carrying a "workspace:" block —
that block is what marks the root — holds how this project builds: its catalog
directories, its provider bindings, which lint rules it relaxes. It is
committed, so a teammate who clones the project builds it the same way.
One global file is shared across every workspace on this machine:
~/.config/aggrega/config.yaml, or on Windows aggrega\config.yaml inside the
directory the APPDATA environment variable names. It holds what belongs to the
machine rather than to any one project: the registries you pull from and the
signature trust policy for each, how large the compiled-module store may grow,
any command extension you have installed. It loads automatically when it is
there, and nothing breaks when it is not.
Your project's file wins over the global one, an environment variable wins
over both, and a flag wins over everything.
Secrets are not configuration. A registry password or a signing identity token
is never a field in either file; it is supplied by environment variable or flag
at the moment it is needed.
Because the effective configuration is assembled rather than written anywhere,
"aggrega config show" is how you see what actually applies, and --origin is how
you find out which layer each setting came from. "aggrega config init" seeds a
working configuration, and "aggrega config capture" freezes the effective
build-critical settings into this workspace so a build does not depend on a
global file that is not committed.
Larger projects have more to work with. None of it is needed to start, and each
piece exists for the shape it solves:
More than one file inside a project. Every .aggrega-config.yaml from the
project root down to the directory you run in contributes, a nearer file
overriding a farther one. Only a file carrying "workspace:" marks the root;
one without it contributes settings without anchoring anything.
Extending a list instead of replacing it. A nearer file's list replaces the
farther one's. The companions catalog_dirs_append, governance_append,
linter_append, importer_append and providers_append concatenate onto the
resolved list at each layer instead of shadowing it.
A file your pipeline owns. .aggrega-config-append-ci.yaml may sit beside the
hand-authored file in any of those directories, so automation can overwrite
it wholesale without touching what a person wrote. It is additive only: it
removes nothing and overrides no scalar, and a scalar key written in it is
ignored and named in a warning. It never marks a root.
A relative path anchors to the file that declared it. A catalog directory, a
local plugin path, or an entry under a plugin's with.sources resolves against
the directory of the config file it was written in — not the project root,
and not the directory you ran the command from. So the same "./catalog" names
a different directory depending on which file carries it. Two settings sit
outside this rule: artifact_cache_dir is interpreted relative to the project
root wherever you run from, and AGGREGA_CATALOG_DIRS has no declaring file at
all, so supply absolute paths in it.
The other root markers. A "workspace:" block wins outright at whatever depth
it sits. Failing one, the nearest .aggrega/ directory or aggregate*.yaml,
release*.yaml or manifest*.yaml file anchors the root, in that order within a
directory; failing everything, your working directory is used.
--workspace-root skips discovery entirely.
Naming the global file. --config <path> wins over the AGGREGA_CONFIG
environment variable, which wins over the default location. Both name a file
deliberately, so a path either gives that does not exist is a loud error
rather than a silent fallback. Whichever file resolves is also the one a
config-writing command writes when it writes globally.

子命令

命令說明
aggrega config capture將有效的建置關鍵設定凍結到這個工作區中
aggrega config init以登錄庫及其信任原則建立可運作的設定
aggrega config show顯示有效設定,以及每項設定的來源

aggrega config capture 說明

Write the effective build-critical configuration into this project's workspace
config file, so the workspace builds identically without relying on the
machine's global configuration.
The build-critical subset is the configuration a build participates in: a set of
plugin socket attachments and the catalog directories. By default the captured
sockets are only those that determine the
rendered output — the provider bindings and the transform-role governance attachments — since only those must
travel with the project for byte-identical output. Pass --all-plugins to also
freeze the verdict-role governance, linter, and importer sockets, which otherwise stay free to
vary by environment. Each field is written at its effective value — the value
that resolves right now with the global configuration and the workspace tree
merged together — so a binding that today comes only from the global config is
materialized into the workspace and travels with the project.
Machine-wide tooling settings, such as a registry's trust policy, are not
captured: they stay in the global config by their nature. Capture always writes
this project's workspace config file. Running it again on an unchanged
configuration rewrites the same file byte-for-byte. Run in a folder that is not
inside a workspace, with no --workspace-root naming one, it writes nothing and
exits with an error saying so.

aggrega config capture 旗標

旗標預設說明
--all-pluginsfalse擷取所有外掛程式插槽,包括裁決角色的治理、linter 與匯入器關卡。不帶它時,capture 只凍結決定渲染輸出的插槽(提供者繫結與轉換角色的治理附加項目)。

aggrega config init 說明

Seed a working configuration by registering a registry and its signature trust
policy, so a fresh machine can pull and verify signed artifacts without editing
YAML by hand.
By default it registers the official hub (hub.aggrega.ai) with signatures
required and the official trusted identities. The registry's advertised trust
policy is fetched once from its own origin and pinned locally — trust-on-first-
use; when the hub is unreachable, advertises nothing, or the workspace is
offline, its built-in official baseline is written instead, so init still
produces a usable config offline. Pass --registry to seed a different registry
(for an air-gapped or private hub). Such a registry has no built-in baseline,
so seeding it while the workspace is offline is refused: init takes no
identities or key to pin by hand, so register it once while online, or add it
with "aggrega registry add --identity" or "--key".
The entry is written to the global config shared across every workspace by
default; pass --workspace to write it to this project's workspace config
instead. If the target config file already exists, init refuses rather than
overwrite it — pass --force to write anyway (the registry entry is merged into
the existing file, other settings preserved).
Before anything else, init says where things are: the configuration file it
created — or, under --force, the one already there that it wrote into — and
the directory the machine-wide caches are kept in. On Windows that directory is
aggrega\cache inside the directory the LOCALAPPDATA environment variable names;
elsewhere it is a directory named aggrega under the per-user cache directory:
~/.cache/aggrega on Linux unless XDG_CACHE_HOME names another, and
~/Library/Caches/aggrega on macOS.
A seeded configuration is a document you own and go on editing, so --dry-run does
everything init does except write: it hands the content back, creating and
modifying nothing. The answer names the file the content is for — which matters
here, because the target is the global config unless --workspace selects this
project's own. A caller that keeps its own document model puts the content there,
where it is visible before it is saved and can be amended or undone. The registry
is still contacted for its advertised trust policy, because the policy in that
content is the policy a write would have pinned.
Because a dry run does everything else init does, it refuses an existing config
file exactly as a write refuses it, and for the same reason. So its exit code
predicts the write's: if the dry run refuses, init would have refused. Pass
--force alongside it to see the merge an overwriting write would produce.
Under --dry-run standard output carries that content and nothing else, so it stays
parseable. A registry seeded with no trust policy, because it advertises none,
still produces its notice, on standard error: read that stream too, or that
configuration arrives without the advice to pin identities by hand. A pinned
policy, whether advertised or the hub's built-in baseline, is in the content
itself and produces no notice.

aggrega config init 旗標

旗標預設說明
--dry-runfalse除了寫入之外,其他一切都照做:把建立的設定當作內容交回,指名它所屬的檔案,且不建立或修改任何東西。其他每個行為都與寫入相同,所以既有的設定檔會與寫入一樣被拒絕——並用 —force 可得到覆寫式寫入會產生的合併結果。
--forcefalse覆寫既有的設定檔。不帶它時,目標檔案已存在,init 會拒絕。
--globalfalse將該項目寫入所有工作區共用的全域設定。這是預設。
--registryhub.aggrega.ai要連同其信任原則一起建立的登錄庫主機。預設為官方 hub。
--workspacefalse改為將該項目寫入這個專案的工作區設定,而不是全域設定。

aggrega config show 說明

Show the configuration that applies right now.
By default it leads with the cascade of config files and environment overrides
that contributed, lowest precedence first, then prints the effective merged
configuration — the global config, the workspace-tree cascade, and any
environment override combined into what applies right now.
Pass --global or --workspace to print a single layer's own file bytes verbatim,
preserving its comments and formatting; when that layer's file does not exist it
says so rather than failing. The two are mutually exclusive.
Pass --origin to annotate each effective setting with the layer it came from —
a command-line flag, an environment variable, a config file, or the built-in
defaults, highest precedence first. A flag is named as the reader typed it, so
a setting a flag decided reports that flag as its source. A setting is
attributed to the highest-precedence layer that sets it, whatever value that
layer writes: a file restating the default is the file named, not the built-in
defaults. List and map settings are attributed as a whole. The signing
requirement is the one exception: any layer may turn it on and none can turn it
off, so it names the first layer that turns it on.

aggrega config show 旗標

旗標預設說明
--globalfalse逐字印出全域設定檔自己的位元組,保留其註解與格式。
--originfalse為每個有效設定標註它來自的層(命令列旗標、環境變數、設定檔,或內建預設)。
--workspacefalse逐字印出這個專案的工作區設定檔自己的位元組,保留其註解與格式。

運作方式

config 子命令用來建立、檢視與凍結管轄建置的設定。至於某項設定該放在哪個檔案,以及各層如何結合,請見設定——它從多數專案所需的兩個檔案開始,其餘的則收在後面。

config init — 建立可運作的設定

aggrega config init 會在全新的機器上註冊一個登錄庫及其簽章信任原則,以建立設定,讓已簽署的成品不必手動編輯 YAML 就能 pull 並驗證。預設會註冊官方 hub(hub.aggrega.ai),要求簽章,並附上它的官方受信任身分。登錄庫所公告的信任原則會從它自己的來源擷取一次,並固定在本機(首次使用即信任);當 hub 無法連上、沒有公告任何東西,或工作區處於離線時,會改為寫入它內建的官方基準,所以 init 即使離線仍能產生可用的設定。

在任何其他動作之前,init 會先說明各項東西在哪裡。在全新的 Linux 機器上建立時,開頭是:

Created the global configuration file at /home/you/.config/aggrega/config.yaml
Machine-wide caches are kept in /home/you/.cache/aggrega

而在全新的 Windows 機器上是:

Created the global configuration file at C:\Users\you\AppData\Roaming\aggrega\config.yaml
Machine-wide caches are kept in C:\Users\you\AppData\Local\aggrega\cache

第一行指名 init 所寫入的設定檔:該檔案原本不存在時是 Created,而它已存在、且 --force 讓 init 寫入其中時是 Using;在 --workspace 下,它指名的是工作區設定檔,而不是全域設定檔。第二行指名機器範圍快取——已編譯的外掛程式及其描述——所保存的目錄,也就是各平台存放使用者快取的位置;哪些快取屬於這個專案,哪些屬於這台機器給出了各平台的規則。每一行都以它的路徑結尾,後面沒有任何東西,所以路徑可以原樣複製。接下來的幾行是註冊本身的:信任原則的擷取找到了什麼,以及登錄庫註冊在哪個檔案中。被拒絕的建立不會印出這兩行,因為它沒有建立任何東西,--dry-run 也不會,它的標準輸出只含它交回的內容。

  • --registry <host> 會建立另一個登錄庫——隔離網路或私有的 hub——而不是官方的。這樣的登錄庫沒有內建基準,所以當它沒有公告任何東西時,項目會在沒有原則的情況下寫入,而且在離線的工作區中,建立它會被拒絕(短代碼 E0310):無法擷取原則,而 init 沒有 --identity 或 --key 可用來手動固定一個。請在連線時建立一次,或以 aggrega registry add 加上你提供的原則來加入它。
  • 如果目標檔案已存在,init 會拒絕而不是覆寫它;--force 則仍會寫入,將登錄庫項目合併到既有檔案中,並保留其他設定。
  • --dry-run 會做 init 所做的一切,除了寫入。它把建立的設定當作內容交回,不建立也不修改任何東西,而且回答會指名該內容所屬的檔案——這在此很重要,因為除非 --workspace 選了這個專案自己的設定,否則目標是全域設定。自己保有文件模型的呼叫端,例如編輯器,會把內容放在那裡,在儲存之前就能看見,並可修改或復原。
  • 因為試執行會做 init 所做的其他一切,它的結束代碼可預測寫入的結果。它會與寫入一樣、基於同樣的理由拒絕既有的設定檔,所以你可以在確定變更之前,用它詢問 init 是否會成功。若要查看覆寫式寫入會產生的文件,請並用 --force:--force --dry-run 會回報合併結果,但仍然不寫入任何東西。
  • 登錄庫仍然會被聯繫以取得它所公告的信任原則,因為所回報內容中的原則,就是寫入時會固定的原則。試執行會對該登錄庫自己的來源發出與寫入相同的單一未經驗證的請求。
  • 在 --dry-run 下,標準輸出只攜帶該內容,不含其他任何東西,所以它仍可被解析。內容無法表達的一件事是缺席:當登錄庫沒有公告信任原則、且建立時沒有任何原則時,說明此事——並告訴你以 --identity 或 --key 固定身分——的通知會送到標準錯誤。沒有受信任身分的設定文件,無論是原則被固定而剛好是空的,或是完全沒有公告,看起來都一樣,所以兩個串流都要讀;丟棄標準錯誤的程式不會得知這件事。當登錄庫確實公告了原則,或官方 hub 內建的基準被固定來取代它時,被固定的原則就在所回報的內容本身之中,不會另外產生通知。

建立的設定是你擁有並持續編輯的文件,這就是它能被交回而不是寫入的原因。下方的凍結有效設定,所產生的是設定解析結果的記錄——編譯器對自身保存的狀態,而不是任何人撰寫的內容——所以它一律寫入,也不提供 --dry-run。

config show — 檢視目前適用的內容

aggrega config show 回報目前適用的設定。在預設檢視中,它先列出貢獻過的設定檔與環境覆寫的串接,優先順序最低者在前,然後印出有效的合併設定——全域設定、工作區樹的串接與任何環境覆疊,合併成單一結果。這份已載入檔案的串接,是你確認哪些檔案與環境覆寫形成了目前設定的地方。

有兩種聚焦的檢視可縮小輸出:

  • --global 或 --workspace 會逐字印出單一層自己的檔案位元組,保留註解與格式;當該層的檔案不存在時,它會說明這一點,而不是失敗。兩者互斥。
  • --origin 會為每個有效設定標註它來自的層——命令列旗標、環境變數、設定檔,或內建預設,優先順序最高者在前。旗標以你輸入的樣子命名,所以在這次執行中由 --offline 決定的設定,會回報 --offline 作為它的來源;環境變數在 env: 前綴之後命名,設定檔則以它的絕對路徑命名。

在 --origin 下,設定會歸屬於設定它的最高優先順序層,無論該層寫的是什麼值。所以寫了 default_registry: hub.aggrega.ai 的專案檔,即使內建預設是同一個登錄庫,仍會被指名為該設定的來源;而重述了全域檔已設定之值的專案檔,會被指名而不是全域檔:這兩種情況下,它都是就地持有該值的檔案,也是在預設值或其下方的檔案改變的那一天,移除它就會改變答案的檔案。沒有任何一層設定的設定,則回報內建預設。

  • **怎樣算設定了它。**設定檔在帶有該設定的鍵時就設定了它,清單設定在帶有該清單的 _append 伴隨鍵時也算。環境變數在以非空值匯出時設定它的設定,而旗標在你輸入時設定——--offline=false 與 --offline 一樣確實地設定了態勢。
  • 由你的管線擁有的設定檔,只會就讀取它所為的鍵被指名,也就是它的清單附加與簽署原則。它忽略並發出警告的鍵,絕不會被回報為某個值的來源。
  • 清單與對應表設定是整體歸屬的,歸屬於設定它們的最高優先順序層;清單的哪一項是由哪一層貢獻的,則不會回報。
  • **簽署要求是唯一的例外。**任何一層都可以開啟它,而沒有任何一層能關閉它,所以它指名第一個開啟它的層。寫了 required: false 的層不會開啟任何東西,所以沒有任何層開啟它時,該設定回報內建預設。

config capture — 凍結建置關鍵設定

aggrega config capture 會把有效的建置關鍵設定寫入這個專案的工作區設定檔,讓工作區不必依賴機器的全域設定也能以相同方式建置。機器範圍的工具設定,例如登錄庫的信任原則,不會被擷取;依其本性,它們留在全域設定中。對未改變的設定再次執行它,會逐位元組重寫同一個檔案。

被擷取的子集是一組外掛程式插槽附加項目與目錄資料夾:

  • 預設情況下,capture 只凍結決定渲染輸出的插槽——提供者繫結與轉換角色的治理附加項目——因為只有這些必須隨專案一起移動,才能得到位元組完全相同的建置。目錄資料夾一律會被擷取。
  • --all-plugins 會把被擷取的插槽擴大到也包含裁決角色的治理、linter 與匯入器插槽。不帶它時,這三者可以依環境自由變動。

Capture 一律寫入,而且不提供改為交回內容的方式。它產生的是設定解析結果的記錄,而不是任何人撰寫的文件,所以沒有東西可供作者檢閱與修改——回報它會誘使人去編輯一份解析結果的快照。

Capture 只寫入工作區。在不屬於任何工作區的資料夾中執行、又沒有 --workspace-root 或 AGGREGA_WORKSPACE_ROOT 指名一個時,它什麼都不寫——寫在那裡的設定檔會把該資料夾變成工作區——並以說明此事的錯誤結束。請先用 aggrega config init --workspace 讓該資料夾成為工作區。

另請參閱

  • configuration.md — 某項設定該放在哪個檔案、優先順序階梯,以及較大專案會用到的機制。
  • global-flags.md — --config 與 --workspace-root 旗標。
  • environment-variables.md — 在執行階段覆寫設定的 AGGREGA_* 變數。
  • aggrega-registry.md — 直接管理登錄庫及其信任原則。
  • aggrega-cache.md — artifact_cache_dir 所指名的目錄實際存放什麼,以及為什麼位於那裡、沒有任何鎖定檔固定的實體不會被建置找到。