aggrega search
搜尋已設定登錄庫的本機索引
概要
aggrega search [query] [flags]說明
Search the local index of the configured registries for entities matching afree-text query and optional facet filters.
The index is the offline snapshot written by 'aggrega registry update'; searchreads it and contacts no network. Run 'aggrega registry update' first, and againwhenever you want to pick up newly published entities. A freshness line namingeach searched registry and when its index was last updated is written to standarderror, so standard output carries only the result data.
The optional positional query is a case-insensitive substring matched againsteach entity's name and description. The facet filters narrow the result further,combining as AND across facets and OR within a repeatable facet:
--kind entity kind (component, feature, recipe, featurerecipe, workload, plugin); repeatable, case-insensitive --capability a plugin capability; repeatable --plugin-type a plugin socket type (for example provider, governance) -l, --selector a label selector over the entity's catalog labels
Category is matched through the label selector, not a dedicated flag: a catalogcategory is the label component.aggrega.ai/category, so'-l component.aggrega.ai/category=compute' scopes the result to that category.
With no --registry, every configured registry's index is searched and theresults are merged. With --registry (a host or a friendly alias), only thatregistry's index is searched.
A search needs at least one configured registry. With none configured there isnowhere to look, so the command refuses: the reason goes to standard error,standard output carries nothing, and the exit status is non-zero. That is whatlets a caller tell a search that ran and matched nothing from a search thatcould not be performed. Run 'aggrega config init' to register a registry withits signature trust policy, then 'aggrega registry update' to build the index.
The version reported for an entity is the one a resolution would take: aversion a publisher has retracted, where the retraction carries a signaturethis workspace's trust policy verifies, is not reported. Such an entity isstill listed, and the versions left out are named in a NOTES column, so anentity whose every published version is retracted is reported as existing withno version to take rather than disappearing from the result. Pass--include-retracted to report the highest published version whatever itsretraction status; the NOTES column names the retracted versions either way.The same holds for 'aggrega search -o json', where the 'version' field carriesthe version a resolution would take and a 'retracted' array names the versionsleft out.旗標
| 旗標 | 預設 | 說明 |
|---|---|---|
--capability | [] | 要比對的 Plugin 能力。可重複;宣告其中任何一個的記錄會被保留。 |
--include-retracted | false | 即使已驗證的標記撤回了最高的已發布版本,也回報該版本。預設回報的版本是解析會採用的版本。 |
--kind | [] | 要比對的實體種類(component|feature|recipe|featurerecipe|workload|plugin)。可重複;比對到其中任何一個的記錄會被保留。不分大小寫。 |
--limit | 0 | 限制結果數量(0 表示不限制)。 |
--output, -o | table | 輸出格式:table|json|names。 |
--plugin-type | — | 要比對的 Plugin 插槽型別(例如 provider、governance、linter)。 |
--registry | — | 只搜尋這個登錄庫,以主機或易記別名指定。預設搜尋每個已設定的登錄庫。 |
--selector, -l | — | 對實體目錄標籤的標籤選擇器,其中包含它的類別(-l component.aggrega.ai/category=compute)。 |
未設定任何登錄庫時
搜尋會讀取此機器所設定要連線的登錄庫之本機索引,因此至少需要其中一個。若沒有設定任何一個,就無處可查,而 aggrega search 會拒絕而不是回答:它會將原因寫入標準錯誤、以非零代碼結束,並讓標準輸出保持空白——在每種輸出格式中皆然,--output json 也包括在內。
這項拒絕讓兩種不同的答案得以區分。執行了但沒有比對到任何東西的搜尋會以零結束,並在標準輸出回報 (no matches);完全無法執行的搜尋會以非零結束,並在那裡不回報任何東西。因此依結束狀態分支的指令碼,可以區分「這個實體沒有發布」與「這台機器沒有可詢問的登錄庫」,而標準輸出上的通知加上零狀態是無法表達這點的。
請執行 aggrega config init,將登錄庫連同其簽章信任原則一起註冊,然後執行 aggrega registry update 來建立搜尋所讀取的本機索引。
aggrega registry list 與 aggrega registry update 對相同的情況有不同的回答,而且是刻意的。在沒有任何登錄庫時列出登錄庫,是對空集合的完整列表,而沒有任何東西可走訪的索引建置沒有任何事要做:兩者都是已完成的操作,因此兩者都在標準輸出回報並以零結束。只有搜尋是在回報它無法做到被要求的事。
搜尋所回報的版本
VERSION 欄帶有解析會採用的版本。發布者已撤回的版本不會被回報,前提是該撤回帶有此工作區的信任原則能驗證的簽章——這與決定撤回是否影響 pull 的兩個條件相同,因此搜尋與 pull 對哪個版本是答案意見一致。
不符合任一條件的撤回,不會改變所回報的任何內容。諮詢嚴重程度的標記會讓其版本仍可被選取,而簽章未通過驗證的標記,不是此工作區據以行動的主張。在這兩種情況下,最高的已發布版本都會被回報,與完全沒有標記時完全相同。
帶有已撤回版本的實體仍會被列出。NOTES 欄會指名被排除的版本,且只出現在有東西要回報的結果中。每個已發布版本都已被撤回的實體,會以 (none) 作為其版本並附上說明沒有剩餘版本的註記來回報,而不是從結果中被省略——被省略的實體會與不存在的實體無從區分。
傳入 --include-retracted 可回報最高的已發布版本,無論其撤回狀態如何,這回答的是「發布了什麼?」而不是「我該用什麼?」。它只改變所回報的版本;NOTES 欄無論如何都會指名被撤回的版本。
搜尋所讀取的是 aggrega registry update 所寫入的本機索引,因此它回報的是每個登錄庫在該索引上次建立時所陳述的內容。自那之後被撤回的版本尚未被記錄,而寫入標準錯誤的新鮮度那一行會指名每個索引建立的時刻。
機器可讀的結果
--output json 以兩個欄位帶有相同的契約:
version是解析會採用的版本。當每個已發布版本都被撤回時,它是空字串,並與指名它們全部的retracted清單配對。retracted列出被排除在該選擇之外的版本,依版本遞增順序。當沒有任何東西被排除時,它不存在。
詢問自己會得到哪個版本的使用端,應讀取 version。改從 deprecations 陣列推導,意味著重新實作嚴重程度與簽章條件,而那些條件的第二個實作可能與編譯器所套用的不一致;retracted 回報的是那些條件已經產生的結果。
每筆記錄也帶有 published:索引所記錄的每個版本,依版本遞增順序,各帶有建立索引時其標籤所解析到的 manifestDigest,而在此工作區的信任原則驗證了該版本自己的簽章之處,還帶有其 signer——在驗證成功的多個簽章之中,是透明度記錄最早記錄的那一個。沒有 signer 的版本,不帶有該原則所驗證的簽章,並且不再多說什麼。讀取某個版本內容的使用端,會以該摘要為它定址——例如 aggrega inspect oci://<host>/<repository>@<digest>——因此它所讀取的是索引所記錄的位元組,無論之後標籤發生什麼事。
當有任何東西記錄了版本何時發布時,它的項目也會帶有 publishedAt(以 UTC 表示、精確到秒的 RFC 3339 時間戳記)與 publishedAtSource(說明它從何而來)。transparency-log 是透明度記錄記下版本之無金鑰簽章的時間,此工作區的信任原則連同記錄對該時間的簽署承諾一起驗證了它——即 signer 的簽章,是驗證成功的那些簽章中最早的,因此再次簽署版本兩者都不會移動。publisher 是發布在其所發布內容旁邊所載明的時間,來自發布機器自己的時鐘,沒有任何東西證明它。兩者被分開保存,讓依日期排序的使用端仍能區分被證明的時間與被陳述的時間。兩者皆無的版本不帶有日期,並且不再多說什麼;每一個何時被記錄,請見 aggrega registry update。