Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions packages/@webex/contact-center/ai-docs/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Contact Center SDK - Templates

> **Purpose**: Code generation templates for AI agents to create, modify, and document SDK components.

---

## Template Categories

| Category | Purpose | Use When |
|----------|---------|----------|
| **new-service/** | Creating new services (like AddressBook, Queue) | Adding new data/API services |
| **new-method/** | Adding methods to existing services | Extending service capabilities |
| **existing-service/** | Bug fixes, feature enhancements, and modifications to existing methods | Modifying existing code |
| **documentation/** | Generating AGENTS.md and ARCHITECTURE.md | Creating service-level docs |

---

## Template Directory Structure

```
templates/
├── README.md # This file
├── new-service/ # New service creation
│ ├── 00-master.md # Orchestrator
│ ├── 01-pre-questions.md # Requirements gathering (STOP gate)
│ ├── 02-code-generation.md # Service class generation
│ ├── 03-integration.md # Registration and exports
│ ├── 04-test-generation.md # Test file generation
│ └── 05-validation.md # Quality checklist
├── new-method/ # New method addition
│ ├── 00-master.md # Orchestrator
│ ├── 01-requirements.md # Method requirements (STOP gate)
│ ├── 02-implementation.md # Code implementation
│ ├── 03-tests.md # Test generation
│ └── 04-validation.md # Quality checklist
├── existing-service/ # Modifications
│ ├── bug-fix.md # Bug fix workflow (STOP gate in Section A)
│ └── feature-enhancement.md # Feature addition / modify existing method (STOP gate in Step 0)
└── documentation/ # Doc generation
├── create-agents-md.md # AGENTS.md template
└── create-architecture-md.md # ARCHITECTURE.md template
```

---

## Quick Reference

### Creating a New Service (Task Type A)
Start with: [`new-service/00-master.md`](new-service/00-master.md)

### Adding a New Method (Task Type B)
Start with: [`new-method/00-master.md`](new-method/00-master.md)

### Fixing a Bug (Task Type C)
Use: [`existing-service/bug-fix.md`](existing-service/bug-fix.md)

### Adding a Feature (Task Type D)
Start with: [`existing-service/feature-enhancement.md`](existing-service/feature-enhancement.md)

**Important:** Feature template includes a mandatory placement triage:
- if feature fits existing service -> continue feature-enhancement flow
- if feature needs standalone ownership -> reroute to [`new-service/00-master.md`](new-service/00-master.md)

### Modifying an Existing Method (Task Type F)
Use: [`existing-service/feature-enhancement.md`](existing-service/feature-enhancement.md)

**Important:** When modifying an existing method (changing signature, parameters, return type, or behavior), use the feature-enhancement template but **skip Step 0 (Placement Triage)** since the method already exists. Start directly at Step 0B (Pre-Enhancement Questions).

### Creating Service Documentation (Task Type E)
Use: [`documentation/create-agents-md.md`](documentation/create-agents-md.md)
Comment on lines +69 to +70

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep task type E mapped to architecture analysis

The root decision tree defines Type E as read-only architecture understanding (packages/@webex/contact-center/AGENTS.md), but this README labels Type E as “Creating Service Documentation” and routes it to documentation/create-agents-md.md. That mismatch will misroute Type E requests to a doc-generation workflow instead of the intended analysis flow.

Useful? React with 👍 / 👎.


---

## Template Usage Flow

```
1. Classify task using root AGENTS.md decision tree (../../AGENTS.md)
|
v
2. Route to appropriate template
|
v
3. STOP — Present pre-questions to developer, wait for answers
|
v
4. Present Spec Summary to developer, wait for approval
|
v
5. If task is "Add Feature", run placement triage (existing vs new service)
Comment on lines +86 to +89

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Run feature placement triage before spec approval

The usage flow asks for a Spec Summary approval before running feature placement triage, but triage determines whether the work should stay in existing-service/feature-enhancement.md or reroute to new-service/00-master.md. Following this order can produce an approved spec for the wrong scope and then force a post-approval reroute.

Useful? React with 👍 / 👎.

|
v
6. Load relevant patterns as specified
|
v
7. Generate/modify code
|
v
8. Run validation checklist
|
v
9. Update documentation if needed
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
# Create AGENTS.md Template

> **Purpose**: Template for generating service-level AGENTS.md files optimized for LLM consumption.

---

## Pre-Generation Questions

Answer before writing:

1. **Package/Service Name**: What is this service called?
2. **Purpose**: What problem does this service solve? (1-2 sentences)
3. **Key Capabilities**: What are the main features? (3-5 bullets)
4. **Usage Examples**: What are the most common use cases?
5. **API Surface**: What methods/properties are exposed?
6. **Dependencies**: What does this service depend on?

---

## AGENTS.md Structure

```markdown
# [Service Name] - AI Agent Guide

> **Purpose**: [One sentence describing what this service does]

---

## Quick Start

[3-5 line code example showing most basic usage]

---

## Key Capabilities

- [Capability 1]: [Brief description]
- [Capability 2]: [Brief description]
- [Capability 3]: [Brief description]

---

## Usage Examples

### [Use Case 1]
```typescript

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Escape nested fences in AGENTS template sample

The ## AGENTS.md Structure block is opened with ```markdown and then contains an unescaped inner fence at this line, which closes the outer block in standard Markdown renderers. In GitHub/docs rendering, everything after this point is interpreted as live document content instead of the intended literal template, so agents cannot reliably copy the full sample structure.

Useful? React with 👍 / 👎.

// Example code
```

### [Use Case 2]
```typescript
// Example code
```

---

## API Reference

### Properties

| Property | Type | Description |
|----------|------|-------------|
| `propertyName` | `Type` | Description |

### Methods

#### `methodName(params)`

Description of what this method does.

**Parameters**:
- `param1` (Type): Description
- `param2` (Type, optional): Description

**Returns**: `Promise<ReturnType>` - Description

**Example**:
```typescript
const result = await service.methodName({
param1: 'value',
});
```

---

## Events (if applicable)

| Event | Data | When Emitted |
|-------|------|--------------|
| `event:name` | `EventData` | Description |

---

## Common Patterns

### [Pattern Name]
```typescript
// Pattern example
```

---

## Error Handling

Errors are thrown as `Error` with:
- `message`: Error description
- `data.reason`: Error reason code

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Describe the real error reason field in AGENTS template

This template tells readers to inspect error.data.reason, but SDK errors produced by getErrorDetails store the human-readable reason in error.message and only attach {message, fieldName} to error.data (src/services/core/Utils.ts). If service docs are generated from this template, developers following the documented error-handling pattern will read an undefined field and miss the actual failure reason.

Useful? React with 👍 / 👎.


```typescript
try {
await service.method();
} catch (error) {
console.error(error.message);
console.error(error.data?.reason);
}
```

---

## Dependencies

- Requires: [dependency description]
- Used by: [what uses this service]

---

## Related Documentation

- [ARCHITECTURE.md](ARCHITECTURE.md) - Technical deep-dive
- [Pattern files](../../../ai-docs/patterns/) - Coding patterns

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fix broken pattern-docs link in generated AGENTS template

This template is meant to generate service docs under src/services/<service>/ai-docs/AGENTS.md, but the embedded link ../../../ai-docs/patterns/ resolves to src/ai-docs/patterns from that location, not the package-level ai-docs/patterns directory. As a result, every generated AGENTS file will contain a dead “Pattern files” reference, so agents following the docs cannot reach the intended guidance.

Useful? React with 👍 / 👎.

```

---

## Content Guidelines

### Purpose Section
- One clear sentence
- Focus on business value, not implementation

### Quick Start
- Show the happy path
- Minimal code to demonstrate value
- Include all required setup steps

### Examples
- Use realistic parameter values
- Show common variations
- Include error handling when relevant

### API Reference
- List all public methods
- Include parameter types and descriptions
- Show return types
- Provide example for each method

### Error Handling
- Document common error scenarios
- Show how to access error details

---

## Token Optimization Strategy

For LLM efficiency:
1. **AGENTS.md first**: Contains usage info (most commonly needed)
2. **ARCHITECTURE.md linked at end**: For deep technical questions
3. **Concise examples**: Just enough to demonstrate
4. **Tables for reference**: Quick scanning

---

## Validation Checklist

- [ ] Purpose is clear and concise
- [ ] Quick start works as-is
- [ ] All public methods documented
- [ ] Examples are realistic and working
- [ ] Error handling documented
- [ ] Links to ARCHITECTURE.md included
- [ ] No implementation details (save for ARCHITECTURE.md)

---

## Example: Services/Agent AGENTS.md

```markdown
# Agent Service - AI Agent Guide

> **Purpose**: Manage agent lifecycle including login, logout, and state changes.

---

## Quick Start

```typescript
const cc = webex.cc;
await cc.register();

// Login
await cc.stationLogin({
teamId: 'team-123',
loginOption: 'BROWSER',
});

// Set available
await cc.setAgentState({
state: 'Available',
auxCodeId: '0',
});
```

---

## Key Capabilities

- **Station Login**: Login with browser, extension, or dial number
- **Station Logout**: Logout from current station
- **State Management**: Change between Available/Idle states
- **Buddy Agents**: Retrieve list of available agents

---

## API Reference

### `stationLogin(params)`

Login agent to a station.

**Parameters**:
- `teamId` (string): Team to login to
- `loginOption` ('BROWSER' | 'EXTENSION' | 'AGENT_DN'): Device type
- `dialNumber` (string, optional): Required for EXTENSION/AGENT_DN

**Returns**: `Promise<StationLoginResponse>`

---

See [ARCHITECTURE.md](ARCHITECTURE.md) for technical details.
```
Loading
Loading