docs(contact-center): add SDD templates for new method creation#4735
docs(contact-center): add SDD templates for new method creation#4735ciscoRankush wants to merge 1 commit intowebex:task-refactorfrom
Conversation
Add Spec-Driven Development templates for adding new methods: - 00-master.md — Orchestrator with workflow overview - 01-requirements.md — STOP gate with 12 interrogative questions, event contract table, metrics section, spec summary with example - 02-implementation.md — Method implementation patterns - 03-tests.md — Unit test generation patterns - 04-validation.md — Quality checklist with correct workspace commands Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| @@ -0,0 +1,80 @@ | |||
| # New Method - Master Template | |||
|
|
|||
| > **Purpose**: Orchestrator for adding new methods to existing services. | |||
There was a problem hiding this comment.
| > **Purpose**: Orchestrator for adding new methods to existing services. | |
| > **Purpose**: Orchestrator for adding new methods to existing services and utils. |
| ## Workflow Overview | ||
|
|
||
| ``` | ||
| Step 1: Requirements → Step 2: Implementation → Step 3: Tests → Step 4: Validation |
There was a problem hiding this comment.
Lets make this a flowchart
| | Endpoint | "What is the full endpoint path?" | | ||
| | Request Payload | "What fields does the request body contain? Which are required vs optional?" | | ||
| | Response Structure | "What does the response look like?" | | ||
| | Error Shape | "What error reason codes can this return?" | |
There was a problem hiding this comment.
Where is the response received? WS or in response of the request?
|
|
||
| --- | ||
|
|
||
| ## Method Template (for cc.ts) |
There was a problem hiding this comment.
We should remove 'for cc.ts' part from the heading. The same tmeplate can be used anywhere in the sdk
| ); | ||
|
|
||
| // 11. Throw augmented error | ||
| throw detailedError; |
There was a problem hiding this comment.
In this template can we emit an event so that there is an example of emitting events. A success and failure event
| Add tests to existing test file or create new one: | ||
| - For `cc.ts` methods: `test/unit/spec/cc.ts` | ||
| - For service methods: `test/unit/spec/services/[service]/index.ts` | ||
|
|
There was a problem hiding this comment.
We should also have an entry for files not in service fodler.
| yarn workspace @webex/contact-center test -- --testPathPattern=cc --testNamePattern="methodName" | ||
|
|
||
| # Run with coverage | ||
| yarn workspace @webex/contact-center test -- --coverage |
There was a problem hiding this comment.
| yarn workspace @webex/contact-center test -- --testPathPattern=cc --testNamePattern="methodName" | |
| # Run with coverage | |
| yarn workspace @webex/contact-center test -- --coverage | |
| yarn workspace @webex/contact-center test:unit -- <path_to_specific-file> | |
| # Run with coverage | |
| yarn workspace @webex/contact-center test:unit --coverage |
| 1. [`../../patterns/typescript-patterns.md`](../../patterns/typescript-patterns.md) | ||
| 2. [`../../patterns/sdk-plugin-patterns.md`](../../patterns/sdk-plugin-patterns.md) - For cc.ts methods | ||
| 3. [`../../patterns/testing-patterns.md`](../../patterns/testing-patterns.md) |
There was a problem hiding this comment.
This needs update now
| ## Use Case | ||
|
|
||
| Use this template when: | ||
| - Adding a new method to an existing service |
There was a problem hiding this comment.
It should be adding a new method or feature
|
|
||
| Use this template when: | ||
| - Adding a new method to an existing service | ||
| - Adding a new public API method to `cc.ts` |
There was a problem hiding this comment.
Same update here as well adding public method from cc or taks object
| ``` | ||
| ## Spec Summary — New Method | ||
|
|
||
| **Method**: `getBuddyAgents(data: BuddyAgents): Promise<BuddyAgentsResponse>` |
There was a problem hiding this comment.
We should also be talking about where and ho BuddyAgent, BuddyAgnetresponse type are defined and how that data can be figured
| } | ||
|
|
||
| // 4. Call service method | ||
| const result = await this.services.someService.method({ |
There was a problem hiding this comment.
For method implementations, there is also this small note we should add that actula method implementation sometime shappen in the service module but we still need to write a method from public object like cc or task and we do internal invocation if service method. And soemtimes we could be directly calling cc.service.method also.
|
|
||
| ## Pattern Verification | ||
|
|
||
| ### Correct Logging Pattern |
There was a problem hiding this comment.
Error logging section should be added too under logging pattern and also dofferentiation ebtween when to use warn and when to use error
|
|
||
| ```bash | ||
| # Run specific test | ||
| yarn workspace @webex/contact-center test -- --testPathPattern=cc --testNamePattern="methodName" |
There was a problem hiding this comment.
These should be test:unit
|
|
||
| // Assert | ||
| expect(mockServicesInstance.someService.method).toHaveBeenCalledWith({ | ||
| data: expect.objectContaining({ |
There was a problem hiding this comment.
We should avoid using objectcontaining. We should highlight that expect statement macthes should be accurate in most cases
COMPLETES #SPARK-775697
This pull request addresses
AI agents need structured templates to guide new method addition in the @webex/contact-center SDK, ensuring they gather complete requirements including API contracts, event contracts, and metrics before implementation.
by making the following changes
Adds
ai-docs/templates/new-method/with 5 template files:00-master.md— Orchestrator with workflow overview and pattern links01-requirements.md— STOP gate with 12 interrogative questions covering method identity, signature, API integration, event contract, metrics, and behavior details. Includes completion gate, spec summary template, and getBuddyAgents example02-implementation.md— Method implementation patterns03-tests.md— Unit test generation patterns04-validation.md— Quality checklist with correct workspace commands (test:styles, test:unit, build:src)Change Type
The following scenarios were tested
The GAI Coding Policy And Copyright Annotation Best Practices
I certified that