Skip to content

feat: implement inflector and naming engine#2

Draft
nallenscott wants to merge 5 commits intomainfrom
feat/inflector-and-naming-engine
Draft

feat: implement inflector and naming engine#2
nallenscott wants to merge 5 commits intomainfrom
feat/inflector-and-naming-engine

Conversation

@nallenscott
Copy link
Copy Markdown
Member

@nallenscott nallenscott commented Mar 7, 2026

Replaces operationId-based tool naming with a deterministic path-based naming engine.

How it works

Each path is parsed into typed components (RESOURCE or PARAM), then processed to produce a camelCase tool name:

/repos/{owner}/{repo}/issues/{id}
   |     |       |      |      |
   |    [params - skipped]     |
   |                           |
container                   resource
(skipped)                 singularized
                        -> "getRepoIssue"

A container is a resource that scopes other resources through path parameters — it's dropped since it does not describe the operation. The remaining resource chain is singularized or pluralized based on position and HTTP method, then abbreviated where applicable.

This generalizes across API conventions:

Path Method Tool name
/repos/{owner}/{repo}/issues GET listRepoIssues
/v1/payment_intents POST createPaymentIntent
/2010-04-01/Accounts/{Sid}/Calls.json GET listCalls
/chat.postMessage POST createChatMsg

Changes

  • Adds inflector.ts.. English pluralization/singularization for API resource names
  • Adds tool_naming.ts.. ToolNamingEngine generates consistent camelCase tool names from REST paths
  • Adds dictionaries/abbrs.json (mirrored from ocp-registry).. abbreviation dictionary used by the naming engine
  • Updates openapi_parser.ts to use ToolNamingEngine instead of normalizing operationId

- Add splitHeadWord() to extract first word of a compound resource
  segment (handles snake_case, kebab-case, camelCase)
- Add deduplicateAdjacentPrefix() to collapse stutter from source
  API paths where resources[i+1] starts with the tail word of resources[i]
  (e.g. workflow + workflowSchemes -> workflow + Schemes)
- Insert as step 7b in generateToolName() pipeline, after
  singularization and before abbreviation expansion
- Add unit tests for splitHeadWord, deduplicateAdjacentPrefix,
  and integration tests for end-to-end name generation (362 tests total)
- Fix irregular inflections in inflector.ts
- Remove 5 extra irregulars not present in Python (human, sex, move,
  zombie, yes) — boilerplate remnants not relevant to API paths
- Change datum → data to datum → datums, matching Python's explicit
  override of the Latin -um→-a rule (datum is a geodetic term)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant