Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

actor-tool-registration

/actor-tool-registration

Rejestruje narzędzie aktora w rejestrze narzędzi: dodaje ToolId i GetToolDefinition oraz udostępnia schemat narzędzia.

Repozytorium
chromium ↗
Licencja
BSD-3-Clause
Ostatnia zmiana repozytorium
25.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 25.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

BSD-3-Clause, otwarta.

Co robi i kiedy

Rejestruje narzędzie aktora w rejestrze narzędzi: dodaje ToolId i GetToolDefinition oraz udostępnia schemat narzędzia.

Wyzwalacze z opisu

register a tool in the tool registryadd a ToolIdadd GetToolDefinitionexpose an actor tool schemaRegister XToolRequest in ToolRegistry
Oryginalny opis (EN)

Use when asked to "register a tool in the tool registry", "add a ToolId", "add GetToolDefinition", "expose an actor tool schema", or when working on a "Register XToolRequest in ToolRegistry" task. Don't use for implementing a brand-new Actor tool from scratch or for migrating ToolController callers to the registry.

Jak działa

  1. 1. Edit the 4 Files
  2. 2. Verify & Rebase
Sekcje z nagłówków SKILL.md, w oryginale · 149 linii, 523 słów
Podgląd SKILL.md
---
name: actor-tool-registration
description: >-
  Use when asked to "register a tool in the tool registry", "add a ToolId",
  "add GetToolDefinition", "expose an actor tool schema", or when working on a
  "Register XToolRequest in ToolRegistry" task. Don't use for implementing a
  brand-new Actor tool from scratch or for migrating ToolController callers to
  the registry.
---

# Registering an Actor Tool in `actor::ToolRegistry`

Each registration task gives an existing `ToolRequest` subclass in
`chrome/browser/actor/tools/` a model-facing schema. A registration CL touches
**strictly 4 files** (never touches `tool_registry.{h,cc}`, `BUILD.gn`, or
request unittests):

1. `chrome/browser/actor/tools/registry/tool_definition.h`
2. `chrome/browser/actor/tools/<stem>_tool_request.h`
3. `chrome/browser/actor/tools/<stem>_tool_request.cc`
4. `chrome/browser/actor/tools/registry/tool_registry_unittest.cc`

Follow the 1:1 `ToolRequest` → `ToolDefinition` exemplar in
[crrev.com/c/8477400](https://crrev.com/c/8477400) (`NavigateToolRequest` in
`chrome/browser/actor/tools/navigate_tool_request.{h,cc}`).

## 1. Edit the 4 Files

### `chrome/browser/actor/tools/registry/tool_definition.h`

- Append `k<Name> = <next_int>,` at the end of `enum class ToolId` (just before
  `kMaxValue`) with a one-line comment, and update `kMaxValue = k<Name>,`.
  `ToolId` is append-only; never renumber existing entries.

### `chrome/browser/actor/tools/<stem>_tool_request.h`

- Below `static constexpr char kName[]`, declare `kModelFacingName` and
  parameter keys (omit param constants for no-arg tools):
  ```cpp
  static constexpr std::string_view kModelFacingName = "<snake_case_name>";
  // JSON argument key for ...
  static constexpr std::string_view k<Param>Param = "<name>";
  ```
- Declare the static getter directly after the destructor:
  ```cpp
  // Returns the `ToolId::k<Name>` tool schema definition.
  static std::optional<ToolDefinition> GetToolDefinition();
  ```
- `#include <optional>` and `#include <string_view>`.

### `chrome/browser/actor/tools/<stem>_tool_request.cc`

- Include `<optional>`, `<string_view>`,
  `"chrome/browser/actor/tools/registry/tool_definition.h"`, and
  `"chrome/browser/actor/tools/registry/tool_definition_builder.h"`. (Include
  `"tool_schema_builder.h"` if referencing format constants or building
  non-empty schemas).
- Define `k<Name>ToolDescription` and `k<Param>ParamDescription` in the
  anonymous namespace. Match existing descriptions in
  `chrome/browser/ttc/core/tool_controller.cc` or `tools.mojom` verbatim.
- Build and return the definition:
  ```cpp
  // static
  std::optional<ToolDefinition> NavigateToolRequest::GetToolDefinition() {
    return ToolDefinitionBuilder(ToolId::kNavigate, kModelFacingName,
                                 kNavigateToolDescription)
        .SetToolParameterSchema(ToolSchemaBuilder().AddStringProperty(
            kUrlParam, kUrlParamDescription, ToolSchemaBuilder::kFormatUri))
        .Build();
  }
  ```
- **No-arg tools**: omit `.SetToolParameterSchema(...)`; `Build()` defaults to
  an empty object schema.
- **Required parameters**: `ToolSchemaBuilder` marks all properties required (no
  optional parameter support). If a tool has optional modes, split it into
  separate 1:1 `ToolRequest` subclasses.
- **Supported property builders**: `.AddStringProperty(name, desc, format)`,
  `.AddIntegerProperty(name, desc)`,
  `.AddStringEnumProperty(key, values, desc)`. Enum values use a plain C-array
  (`constexpr std::string_view kValues[] = {"a", "b"};`).
- **Missing a property type?** (e.g. boolean, list): Add
  `ToolSchemaBuilder& Add<Type>Property(...)` in a separate parent CL in
  `chrome/browser/actor/tools/registry/tool_schema_builder.{h,cc}` routing
  through `AddPropertyImpl()`, covered in `tool_schema_builder_unittest.cc`:
  ```cpp
  ToolSchemaBuilder& ToolSchemaBuilder::AddBooleanProperty(
      std::string_view name, std::string_view description) {
    base::DictValue prop_schema;
    prop_schema.Set("type", "boolean");
    prop_schema.Set("description", description);
    AddPropertyImpl(name, std::move(prop_schema));
    return *this;
  }
  ```

### `chrome/browser/actor/tools/registry/tool_registry_unittest.cc`

All schema tests live here. Add the `#include` alphabetically and define two
tests (replace `Navigate` and `kUrlParam` with your tool and parameter keys):

```cpp
TEST(ToolRegistryTest, NavigateToolDefinition) {
  const std::optional<ToolDefinition> definition =
      NavigateToolRequest::GetToolDefinition();
  ASSERT_TRUE(definition.has_value());
  EXPECT_EQ(definition->id, ToolId::kNavigate);
  EXPECT_EQ(definition->name, NavigateToolRequest::kModelFacingName);
  EXPECT_THAT(*definition,
              HasParamOfType(NavigateToolRequest::kUrlParam, "string"));
  EXPECT_THAT(*definition, RequiresParam(NavigateToolRequest::kUrlParam));
}

TEST(ToolRegistryTest, GetAllToolsContainsNavigateTool) {
  base::test::ScopedFeatureList scoped_feature_list(features::kGlicActor);
  content::BrowserTaskEnvironment task_environment;
  TestingProfile profile;
  ActorKeyedService* service = ActorKeyedService::Get(&profile);
  CHECK(service);

  EXPECT_TRUE(std::ranges::contains(service->tool_registry().GetAllTools(),
                                    ToolId::kNavigate, &ToolDefinition::id));
}
```

- **No-arg tools**: replace `HasParamOfType`/`RequiresParam` with:
  ```cpp
  EXPECT_THAT(
      definition->parameters_json_schema,
      base::test::DictionaryHasValue("properties", base::DictValue()));
  ```
  (and include `"base/test/values_test_util.h"` and `"base/values.h"`).
- **Desktop-only tools**: If the tool header is guarded by
  `#if !BUILDFLAG(SKIP_ANDROID_UNMIGRATED_ACTOR_FILES)` in
  `chrome/browser/actor/tool_request_variant.h` (e.g.
  `switch_tab_tool_request.h`), wrap its include and tests with the same guard
  and `#include "chrome/browser/actor/actor_buildflags.h"`.
- Matchers `HasParamOfType` and `RequiresParam` live in
  `//chrome/browser/actor/tools/registry:test_support`. Do not add redundant
  tests for `NameToToolId` or uniqueness (`ToolRegistryCompletenessTest.*`
  already covers them).
- No test-only hooks in production code.

## 2. Verify & Rebase

```bash
tools/autotest.py -C out/Default \
  chrome/browser/actor/tools/registry/tool_registry_unittest.cc
gn check out/Default //chrome/browser/actor/tools/registry/* //chrome/browser/actor/*
git cl format
git status --short
```

Verify `git status --short` shows **strictly 4 `M` lines and zero `??` lines**.

- **Merge conflicts**: Registration CLs frequently conflict on
  `enum class ToolId` and includes/tests in `tool_registry_unittest.cc`. Rebase
  and assign the next sequential integer to `ToolId`, keeping other additions.

Wersje

W bazie nie ma innych skilli o nazwie actor-tool-registration.

Migawka bazy z 28.10.2026 · wersja paczki 72bd76659ebb (skrót SHA-256 całej paczki)

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90Linear OAuth + Actor Authorization
    Wdraża OAuth 2.0 w Linear, autoryzację aktora OAuth i uwierzytelnianie magazynu plików.
  • 100apify-generate-output-schema
    Generuje schematy wyjścia aktora Apify (dataset_schema.json, output_schema.json, key_value_store_schema.json) przez analizę jego kodu źródłowego.
  • 100apify-generate-output-schema
    Generuje schematy wyjścia aktora Apify (dataset_schema.json, output_schema.json, key_value_store_schema.json) przez analizę jego kodu źródłowego.
  • 100apify-hello-world
    Uruchamia pierwszego aktora Apify i pobiera wyniki przez apify-client, ucząc wzorca wywołania aktora i odczytu zbioru danych.
  • 100registry-component-patterns
    Rejestruje komponenty w registry.json dla polecenia shadcn/ui add, przy dodawaniu nowych komponentów 8-bit do biblioteki.
  • 87create-toolset
    Dodaje i rejestruje funkcje dla AI w zestawach narzędzi Unreal Engine, np. BlueprintTools czy StaticMeshTools, w serwerze MCP.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.