@polymorphism-tech/morph-spec 7.3.0 → 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +4 -2
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +1 -1
  8. package/framework/MORPH.md +29 -12
  9. package/framework/agents.json +132 -132
  10. package/framework/evals/rubrics/README.md +9 -8
  11. package/framework/hooks/README.md +2 -0
  12. package/framework/hooks/claude-code/core/gate-guard.js +160 -0
  13. package/framework/hooks/claude-code/core/state-sync.js +15 -3
  14. package/framework/hooks/claude-code/core/validate-completion.js +105 -0
  15. package/framework/hooks/shared/state-reader.js +236 -221
  16. package/framework/skills/README.md +1 -1
  17. package/framework/skills/core/morph-apply/SKILL.md +63 -21
  18. package/framework/skills/core/morph-brainstorming/SKILL.md +5 -1
  19. package/framework/skills/core/morph-eval/SKILL.md +4 -5
  20. package/framework/skills/core/morph-implement/SKILL.md +47 -19
  21. package/framework/skills/core/morph-plan/SKILL.md +8 -2
  22. package/framework/skills/core/morph-proposal/SKILL.md +1 -1
  23. package/framework/skills/core/morph-review/SKILL.md +13 -6
  24. package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
  25. package/framework/skills/core/morph-standards/SKILL.md +1 -1
  26. package/framework/standards/ai-agents/setup.md +258 -244
  27. package/package.json +1 -1
  28. package/src/commands/project/init.js +517 -515
  29. package/src/commands/state/approve.js +251 -213
  30. package/src/commands/validation/validate-feature.js +64 -23
  31. package/src/core/state/state-manager.js +19 -9
  32. package/src/lib/risk-detector.js +2 -2
  33. package/src/utils/hooks-installer.js +527 -516
@@ -1,244 +1,258 @@
1
- # Microsoft Agent Framework — Setup Guide (.NET 10)
2
-
3
- > **Scope:** stacks=["dotnet"]
4
- > **Layer:** 0 (always-load via persona maf-expert)
5
- > **Keywords:** maf setup, microsoft agents ai, chatclient, ai agent, agent framework, agent dotnet, AsAIAgent
6
- > **Read by Claude in:** plan (pra citar pacote em tasks.json) + implement (pra escrever .csproj e Program.cs)
7
-
8
- **Verified against:** Microsoft.Agents.AI 1.0 GA (abril/2026). Last-verified: 2026-05-19.
9
-
10
- ---
11
-
12
- ## Provider philosophy — direct models always
13
-
14
- This framework is **provider-agnostic**. There is no "primary" provider hardcoded. Every model is reached as a **direct model** (you call the model API directly) — never via a hosted agent service. Hosted services lag 6-9 months on models and remove control.
15
-
16
- First-class providers: **OpenAI, Google (Gemini), Anthropic (Claude), Ollama** (local/on-prem).
17
- Azure OpenAI is also a direct model but is **not a default** — see note in §3.4.
18
-
19
- The concrete model choice lives in the project's Model Registry, not in this standard. See `ai-agents-providers-model-registry`.
20
-
21
- ## Decision tree (when reading this in plan phase)
22
-
23
- ```
24
- Está adicionando um agente AI a um projeto .NET?
25
- ├─ Sim → use este standard + ai-agents-sweet-spot + ai-agents-providers-model-registry
26
- │ ├─ Projeto tem >1 modelo ou >1 provider? → SEMPRE use Model Registry
27
- │ ├─ Provider OpenAI? → §3.1
28
- │ ├─ Provider Ollama (local)? → §3.2
29
- │ ├─ Provider Google / Anthropic? → §3.3
30
- │ └─ Provider Azure OpenAI (data residency)? → §3.4 (nota, não default)
31
- └─ Não → este standard não se aplica
32
- ```
33
-
34
- ---
35
-
36
- ## 1. Packages (NuGet)
37
-
38
- **Required for any MAF project:**
39
-
40
- ```xml
41
- <PackageReference Include="Microsoft.Agents.AI" Version="1.0.*" />
42
- ```
43
-
44
- **Provider-specific (escolha conforme o Model Registry do projeto):**
45
-
46
- ```xml
47
- <!-- OpenAI direct -->
48
- <PackageReference Include="Microsoft.Agents.AI.OpenAI" Version="1.0.*" />
49
- <PackageReference Include="OpenAI" Version="2.*" />
50
-
51
- <!-- Ollama (local / on-prem) — usa o mesmo OpenAI-compatible client -->
52
- <PackageReference Include="OpenAI" Version="2.*" />
53
-
54
- <!-- Google Gemini — SDK verificado no standard model-registry.md -->
55
- <!-- Anthropic Claude — SDK verificado no standard model-registry.md -->
56
- <!-- Azure OpenAI (somente se data residency exigir) — Azure.AI.OpenAI 2.* + Azure.Identity 1.* -->
57
- ```
58
-
59
- > The `.AsIChatClient()` extension on `OpenAI.ChatClient` comes from `Microsoft.Agents.AI.OpenAI`. The `IChatClient` abstraction itself lives in `Microsoft.Extensions.AI` (a transitive dependency of `Microsoft.Agents.AI`) — code that uses `IChatClient` needs `using Microsoft.Extensions.AI;`.
60
-
61
- > Os pacotes de Google e Anthropic mudam de nome/versão com frequência. O standard `ai-agents-providers-model-registry` mantém a lista verificada com data. Não trave SDK aqui.
62
-
63
- **Optional (only when feature requires):**
64
-
65
- ```xml
66
- <!-- Hosting helpers (AddAIAgent, AddSequentialWorkflow) -->
67
- <PackageReference Include="Microsoft.Agents.AI.Hosting" Version="1.0.*" />
68
-
69
- <!-- A2A protocol -->
70
- <PackageReference Include="Microsoft.Agents.AI.A2A" Version="1.0.*" />
71
- ```
72
-
73
- **Forbidden in new MAF projects:**
74
-
75
- - `Microsoft.SemanticKernel.*` — superseded by MAF, do not introduce.
76
- - `Microsoft.Extensions.AI.OpenAI` 9.* — replaced by `Microsoft.Agents.AI.OpenAI` in GA.
77
- - Hosted agent services (Foundry Agent Service, etc.) — use direct models.
78
-
79
- ---
80
-
81
- ## 2. Quick Start (canonical minimal agent)
82
-
83
- ```csharp
84
- using Microsoft.Agents.AI;
85
- using Microsoft.Extensions.AI;
86
- using OpenAI;
87
- using OpenAI.Chat;
88
-
89
- AIAgent agent = new ChatClient(model: "gpt-4o-mini", apiKey: "<from-config>")
90
- .AsIChatClient()
91
- .AsAIAgent(instructions: "You are a helpful assistant.");
92
-
93
- var response = await agent.RunAsync("Analyze this order.");
94
- Console.WriteLine(response.Text);
95
- ```
96
-
97
- This snippet is the baseline. In a real project you never hardcode the model — use the Model Registry (`ai-agents-providers-model-registry`). Anything more complex (DI, tools, structured output, RAG) layers on top via the other ai-agents standards.
98
-
99
- ---
100
-
101
- ## 3. Setup by Provider
102
-
103
- > In any project with >1 model or >1 provider, **do not register `IChatClient` directly** — use the Model Registry (`ai-agents-providers-model-registry`). The snippets below show the raw client construction the registry wraps.
104
-
105
- ### 3.1 OpenAI direct (most common)
106
-
107
- ```csharp
108
- using OpenAI;
109
- using OpenAI.Chat;
110
- using Microsoft.Extensions.AI;
111
-
112
- builder.Services.AddSingleton<IChatClient>(sp =>
113
- {
114
- var cfg = sp.GetRequiredService<IConfiguration>();
115
- return new ChatClient(
116
- model: cfg["OpenAI:Model"] ?? "gpt-4o-mini",
117
- apiKey: cfg["OpenAI:ApiKey"]!)
118
- .AsIChatClient();
119
- });
120
- ```
121
-
122
- ### 3.2 Ollama (local dev / on-prem)
123
-
124
- Ollama exposes an OpenAI-compatible endpoint — use the same `ChatClient`:
125
-
126
- ```csharp
127
- using OpenAI;
128
- using OpenAI.Chat;
129
- using System.ClientModel;
130
- using Microsoft.Extensions.AI;
131
-
132
- builder.Services.AddSingleton<IChatClient>(sp =>
133
- new ChatClient(
134
- model: "llama3.2:3b",
135
- credential: new ApiKeyCredential("ollama"), // any non-empty string
136
- options: new OpenAIClientOptions { Endpoint = new Uri("http://localhost:11434/v1") })
137
- .AsIChatClient());
138
- ```
139
-
140
- > Models < 3B params often fail tool calling. Use Ollama only for non-tool agents in dev.
141
-
142
- ### 3.3 Google (Gemini) / Anthropic (Claude)
143
-
144
- Both are first-class providers reached as direct models. The exact NuGet SDK and client construction are documented (with verification date) in `ai-agents-providers-model-registry` §providers — that standard is the single source of truth for provider SDKs, since they change names/versions often.
145
-
146
- ### 3.4 Azure OpenAI (note — not a default)
147
-
148
- Azure OpenAI is also a direct model, but requires an Azure resource + deployment per model. It is **not a default provider** in this framework — projects deploy to VPS, not Azure. Add an Azure branch to the Model Registry only when a client explicitly requires data residency in a specific Azure region. The pattern: `new AzureOpenAIClient(endpoint, credential).GetChatClient(deployment).AsIChatClient()`.
149
-
150
- ---
151
-
152
- ## 4. DI Registration (keyed agents)
153
-
154
- > The `builder.AddAIAgent(...)` extension requires the `Microsoft.Agents.AI.Hosting` package (see §1 Optional). For projects that register agents manually without `AddAIAgent`, the base `Microsoft.Agents.AI` package is enough.
155
-
156
- ```csharp
157
- // Program.cs
158
- builder.AddAIAgent("OrderAnalyzer", (sp, key) =>
159
- {
160
- var chatClient = sp.GetRequiredService<IChatClient>();
161
- return new ChatClientAgent(
162
- chatClient,
163
- name: key,
164
- instructions: "You are an order analysis expert.");
165
- });
166
- ```
167
-
168
- Inject by key:
169
-
170
- ```csharp
171
- public class AgentController(
172
- [FromKeyedServices("OrderAnalyzer")] AIAgent orderAgent) : ControllerBase { ... }
173
- ```
174
-
175
- For agents with tools and structured output, see `ai-agents-multi-agent-patterns` and `ai-agents-structured-output` (Onda 2).
176
-
177
- ---
178
-
179
- ## 5. OpenTelemetry
180
-
181
- ```csharp
182
- using OpenTelemetry;
183
- using OpenTelemetry.Trace;
184
- using Microsoft.Agents.AI;
185
-
186
- using var tracerProvider = Sdk.CreateTracerProviderBuilder()
187
- .AddSource(AgentOpenTelemetryConsts.DefaultSourceName)
188
- .AddOtlpExporter()
189
- .Build();
190
-
191
- // Wrap any agent (e.g. the `agent` from §2)
192
- var instrumented = agent.WithOpenTelemetry();
193
- ```
194
-
195
- > **Note:** Source name is `AgentOpenTelemetryConsts.DefaultSourceName` from `Microsoft.Agents.AI`. **Do NOT** use the old `Experimental.Microsoft.Extensions.AI.*` source — it belongs to a previous package family.
196
-
197
- ---
198
-
199
- ## 6. Security checklist
200
-
201
- - [ ] API keys never in source. Bind from environment variables / secret store (the VPS deploy uses env vars; Docker secrets or a vault are fine too).
202
- - [ ] `appsettings.json` checked into git never contains real keys — only placeholder/empty values.
203
- - [ ] Provider keys (`OpenAI:ApiKey`, `Google:ApiKey`, `Anthropic:ApiKey`) bound from environment.
204
- - [ ] No agent receives raw user input without input-validation middleware (see `ai-agents-middleware-patterns` — Onda 2).
205
-
206
- ---
207
-
208
- ## 7. What NOT to do (anti-patterns)
209
-
210
- | Wrong | Right |
211
- |-------|-------|
212
- | `using Microsoft.SemanticKernel` | `using Microsoft.Agents.AI` |
213
- | `Kernel.InvokePromptAsync()` | `agent.RunAsync()` |
214
- | `[KernelFunction]` | `[Description]` on method + parameters; register via `AIFunctionFactory.Create()` |
215
- | `ChatHistory` | `IEnumerable<ChatMessage>` |
216
- | Hardcoded model strings spread across codebase | Single source via Model Registry (see `ai-agents-providers-model-registry`) |
217
- | `Microsoft.Extensions.AI.OpenAI` 9.* | `Microsoft.Agents.AI.OpenAI` 1.* GA |
218
- | Hosted agent service "to simplify" | Direct models always |
219
-
220
- ---
221
-
222
- ## 8. Checklist (verifiable by morph-eval)
223
-
224
- - [ ] `Microsoft.Agents.AI` package present in `.csproj`
225
- - [ ] No `Microsoft.SemanticKernel.*` references
226
- - [ ] `IChatClient` registered (either directly or via Model Registry)
227
- - [ ] At least one `AIAgent` created via `AsAIAgent()` or `new ChatClientAgent()`
228
- - [ ] OpenTelemetry source name is `AgentOpenTelemetryConsts.DefaultSourceName` (if telemetry wired)
229
- - [ ] Models reference Model Registry alias when project has >1 model use case
230
-
231
- ---
232
-
233
- ## 9. References
234
-
235
- - `ai-agents-sweet-spot` — when to use agents vs workflows
236
- - `ai-agents-providers-model-registry` — provider-agnostic pattern
237
- - `ai-agents-structured-output` (Onda 2) — typed responses
238
- - `ai-agents-middleware-patterns` (Onda 2) — telemetry, retry, anti-hallucination, streaming agent responses
239
- - Microsoft.Agents.AI docs: https://learn.microsoft.com/agent-framework/
240
- - Verified packages list (context7 /microsoft/agent-framework): retrieved 2026-05-19
241
-
242
- ---
243
-
244
- *MORPH-SPEC by Polymorphism Tech — ai-agents/setup.md v2.0 (2026-05-19)*
1
+ # Microsoft Agent Framework — Setup Guide (.NET 10)
2
+
3
+ > **Scope:** stacks=["dotnet"]
4
+ > **Layer:** 0 (always-load via persona maf-expert)
5
+ > **Keywords:** maf setup, microsoft agents ai, chatclient, ai agent, agent framework, agent dotnet, AsAIAgent
6
+ > **Read by Claude in:** plan (pra citar pacote em tasks.json) + implement (pra escrever .csproj e Program.cs)
7
+
8
+ **Verified against:** Microsoft.Agents.AI 1.0 GA (abril/2026). Last-verified: 2026-05-19.
9
+
10
+ ---
11
+
12
+ ## Provider philosophy — direct models always
13
+
14
+ This framework is **provider-agnostic**. There is no "primary" provider hardcoded. Every model is reached as a **direct model** (you call the model API directly) — never via a hosted agent service. Hosted services lag 6-9 months on models and remove control.
15
+
16
+ First-class providers: **OpenAI, Google (Gemini), Anthropic (Claude), Ollama** (local/on-prem).
17
+ Azure OpenAI is also a direct model but is **not a default** — see note in §3.4.
18
+
19
+ The concrete model choice lives in the project's Model Registry, not in this standard. See `ai-agents-providers-model-registry`.
20
+
21
+ ## Decision tree (when reading this in plan phase)
22
+
23
+ ```
24
+ Está adicionando um agente AI a um projeto .NET?
25
+ ├─ Sim → use este standard + ai-agents-sweet-spot + ai-agents-providers-model-registry
26
+ │ ├─ Projeto tem >1 modelo ou >1 provider? → SEMPRE use Model Registry
27
+ │ ├─ Provider OpenAI? → §3.1
28
+ │ ├─ Provider Ollama (local)? → §3.2
29
+ │ ├─ Provider Google / Anthropic? → §3.3
30
+ │ └─ Provider Azure OpenAI (data residency)? → §3.4 (nota, não default)
31
+ └─ Não → este standard não se aplica
32
+ ```
33
+
34
+ ---
35
+
36
+ ## 1. Packages (NuGet)
37
+
38
+ **Required for any MAF project:**
39
+
40
+ ```xml
41
+ <PackageReference Include="Microsoft.Agents.AI" Version="1.0.*" />
42
+ ```
43
+
44
+ **Provider-specific (escolha conforme o Model Registry do projeto):**
45
+
46
+ ```xml
47
+ <!-- OpenAI direct -->
48
+ <PackageReference Include="Microsoft.Agents.AI.OpenAI" Version="1.0.*" />
49
+ <PackageReference Include="OpenAI" Version="2.*" />
50
+
51
+ <!-- Ollama (local / on-prem) — usa o mesmo OpenAI-compatible client -->
52
+ <PackageReference Include="OpenAI" Version="2.*" />
53
+
54
+ <!-- Google Gemini — SDK verificado no standard model-registry.md -->
55
+ <!-- Anthropic Claude — SDK verificado no standard model-registry.md -->
56
+ <!-- Azure OpenAI (somente se data residency exigir) — Azure.AI.OpenAI 2.* + Azure.Identity 1.* -->
57
+ ```
58
+
59
+ > The `.AsIChatClient()` extension on `OpenAI.ChatClient` comes from `Microsoft.Agents.AI.OpenAI`. The `IChatClient` abstraction itself lives in `Microsoft.Extensions.AI` (a transitive dependency of `Microsoft.Agents.AI`) — code that uses `IChatClient` needs `using Microsoft.Extensions.AI;`.
60
+
61
+ > Os pacotes de Google e Anthropic mudam de nome/versão com frequência. O standard `ai-agents-providers-model-registry` mantém a lista verificada com data. Não trave SDK aqui.
62
+
63
+ **Optional (only when feature requires):**
64
+
65
+ ```xml
66
+ <!-- Hosting helpers (AddAIAgent, AddSequentialWorkflow) -->
67
+ <PackageReference Include="Microsoft.Agents.AI.Hosting" Version="1.0.*" />
68
+
69
+ <!-- A2A protocol -->
70
+ <PackageReference Include="Microsoft.Agents.AI.A2A" Version="1.0.*" />
71
+ ```
72
+
73
+ **Forbidden in new MAF projects:**
74
+
75
+ - `Microsoft.SemanticKernel.*` — superseded by MAF, do not introduce.
76
+ - `Microsoft.Extensions.AI.OpenAI` 9.* — replaced by `Microsoft.Agents.AI.OpenAI` in GA.
77
+ - Hosted agent services (Foundry Agent Service, etc.) — use direct models.
78
+
79
+ ---
80
+
81
+ ## 2. Quick Start (canonical minimal agent)
82
+
83
+ ```csharp
84
+ using Microsoft.Agents.AI;
85
+ using Microsoft.Extensions.AI;
86
+ using OpenAI;
87
+ using OpenAI.Chat;
88
+
89
+ AIAgent agent = new ChatClient(model: "gpt-4o-mini", apiKey: "<from-config>")
90
+ .AsIChatClient()
91
+ .AsAIAgent(instructions: "You are a helpful assistant.");
92
+
93
+ var response = await agent.RunAsync("Analyze this order.");
94
+ Console.WriteLine(response.Text);
95
+ ```
96
+
97
+ This snippet is the baseline. In a real project you never hardcode the model — use the Model Registry (`ai-agents-providers-model-registry`). Anything more complex (DI, tools, structured output, RAG) layers on top via the other ai-agents standards.
98
+
99
+ ---
100
+
101
+ ## 3. Setup by Provider
102
+
103
+ > In any project with >1 model or >1 provider, **do not register `IChatClient` directly** — use the Model Registry (`ai-agents-providers-model-registry`). The snippets below show the raw client construction the registry wraps.
104
+
105
+ ### 3.1 OpenAI direct (most common)
106
+
107
+ ```csharp
108
+ using OpenAI;
109
+ using OpenAI.Chat;
110
+ using Microsoft.Extensions.AI;
111
+
112
+ builder.Services.AddSingleton<IChatClient>(sp =>
113
+ {
114
+ var cfg = sp.GetRequiredService<IConfiguration>();
115
+ var apiKey = cfg["OpenAI:ApiKey"];
116
+ if (string.IsNullOrWhiteSpace(apiKey))
117
+ {
118
+ throw new InvalidOperationException(
119
+ "OpenAI:ApiKey is required. Bind it from an environment variable or secret store.");
120
+ }
121
+ return new ChatClient(
122
+ model: cfg["OpenAI:Model"] ?? "gpt-4o-mini",
123
+ apiKey: apiKey)
124
+ .AsIChatClient();
125
+ });
126
+ ```
127
+
128
+ > **Why explicit `string.IsNullOrWhiteSpace` instead of `?? throw` or `!`?**
129
+ > `IConfiguration` returns the **empty string** (not `null`) for keys that
130
+ > exist with blank values — which is the common shape of a checked-in
131
+ > `appsettings.json` placeholder (`"OpenAI": { "ApiKey": "" }`). A
132
+ > `?? throw` guard against `null` therefore never fires; the program
133
+ > proceeds to `new ChatClient(model, "")` and crashes much later with
134
+ > an opaque OpenAI SDK error. Always check whitespace.
135
+
136
+ ### 3.2 Ollama (local dev / on-prem)
137
+
138
+ Ollama exposes an OpenAI-compatible endpoint — use the same `ChatClient`:
139
+
140
+ ```csharp
141
+ using OpenAI;
142
+ using OpenAI.Chat;
143
+ using System.ClientModel;
144
+ using Microsoft.Extensions.AI;
145
+
146
+ builder.Services.AddSingleton<IChatClient>(sp =>
147
+ new ChatClient(
148
+ model: "llama3.2:3b",
149
+ credential: new ApiKeyCredential("ollama"), // any non-empty string
150
+ options: new OpenAIClientOptions { Endpoint = new Uri("http://localhost:11434/v1") })
151
+ .AsIChatClient());
152
+ ```
153
+
154
+ > Models < 3B params often fail tool calling. Use Ollama only for non-tool agents in dev.
155
+
156
+ ### 3.3 Google (Gemini) / Anthropic (Claude)
157
+
158
+ Both are first-class providers reached as direct models. The exact NuGet SDK and client construction are documented (with verification date) in `ai-agents-providers-model-registry` §providers — that standard is the single source of truth for provider SDKs, since they change names/versions often.
159
+
160
+ ### 3.4 Azure OpenAI (note — not a default)
161
+
162
+ Azure OpenAI is also a direct model, but requires an Azure resource + deployment per model. It is **not a default provider** in this framework — projects deploy to VPS, not Azure. Add an Azure branch to the Model Registry only when a client explicitly requires data residency in a specific Azure region. The pattern: `new AzureOpenAIClient(endpoint, credential).GetChatClient(deployment).AsIChatClient()`.
163
+
164
+ ---
165
+
166
+ ## 4. DI Registration (keyed agents)
167
+
168
+ > The `builder.AddAIAgent(...)` extension requires the `Microsoft.Agents.AI.Hosting` package (see §1 Optional). For projects that register agents manually without `AddAIAgent`, the base `Microsoft.Agents.AI` package is enough.
169
+
170
+ ```csharp
171
+ // Program.cs
172
+ builder.AddAIAgent("OrderAnalyzer", (sp, key) =>
173
+ {
174
+ var chatClient = sp.GetRequiredService<IChatClient>();
175
+ return new ChatClientAgent(
176
+ chatClient,
177
+ name: key,
178
+ instructions: "You are an order analysis expert.");
179
+ });
180
+ ```
181
+
182
+ Inject by key:
183
+
184
+ ```csharp
185
+ public class AgentController(
186
+ [FromKeyedServices("OrderAnalyzer")] AIAgent orderAgent) : ControllerBase { ... }
187
+ ```
188
+
189
+ For agents with tools and structured output, see `ai-agents-multi-agent-patterns` and `ai-agents-structured-output` (Onda 2).
190
+
191
+ ---
192
+
193
+ ## 5. OpenTelemetry
194
+
195
+ ```csharp
196
+ using OpenTelemetry;
197
+ using OpenTelemetry.Trace;
198
+ using Microsoft.Agents.AI;
199
+
200
+ using var tracerProvider = Sdk.CreateTracerProviderBuilder()
201
+ .AddSource(AgentOpenTelemetryConsts.DefaultSourceName)
202
+ .AddOtlpExporter()
203
+ .Build();
204
+
205
+ // Wrap any agent (e.g. the `agent` from §2)
206
+ var instrumented = agent.WithOpenTelemetry();
207
+ ```
208
+
209
+ > **Note:** Source name is `AgentOpenTelemetryConsts.DefaultSourceName` from `Microsoft.Agents.AI`. **Do NOT** use the old `Experimental.Microsoft.Extensions.AI.*` source — it belongs to a previous package family.
210
+
211
+ ---
212
+
213
+ ## 6. Security checklist
214
+
215
+ - [ ] API keys never in source. Bind from environment variables / secret store (the VPS deploy uses env vars; Docker secrets or a vault are fine too).
216
+ - [ ] `appsettings.json` checked into git never contains real keys — only placeholder/empty values.
217
+ - [ ] Provider keys (`OpenAI:ApiKey`, `Google:ApiKey`, `Anthropic:ApiKey`) bound from environment.
218
+ - [ ] No agent receives raw user input without input-validation middleware (see `ai-agents-middleware-patterns` — Onda 2).
219
+
220
+ ---
221
+
222
+ ## 7. What NOT to do (anti-patterns)
223
+
224
+ | Wrong | Right |
225
+ |-------|-------|
226
+ | `using Microsoft.SemanticKernel` | `using Microsoft.Agents.AI` |
227
+ | `Kernel.InvokePromptAsync()` | `agent.RunAsync()` |
228
+ | `[KernelFunction]` | `[Description]` on method + parameters; register via `AIFunctionFactory.Create()` |
229
+ | `ChatHistory` | `IEnumerable<ChatMessage>` |
230
+ | Hardcoded model strings spread across codebase | Single source via Model Registry (see `ai-agents-providers-model-registry`) |
231
+ | `Microsoft.Extensions.AI.OpenAI` 9.* | `Microsoft.Agents.AI.OpenAI` 1.* GA |
232
+ | Hosted agent service "to simplify" | Direct models always |
233
+
234
+ ---
235
+
236
+ ## 8. Checklist (verifiable by morph-eval)
237
+
238
+ - [ ] `Microsoft.Agents.AI` package present in `.csproj`
239
+ - [ ] No `Microsoft.SemanticKernel.*` references
240
+ - [ ] `IChatClient` registered (either directly or via Model Registry)
241
+ - [ ] At least one `AIAgent` created via `AsAIAgent()` or `new ChatClientAgent()`
242
+ - [ ] OpenTelemetry source name is `AgentOpenTelemetryConsts.DefaultSourceName` (if telemetry wired)
243
+ - [ ] Models reference Model Registry alias when project has >1 model use case
244
+
245
+ ---
246
+
247
+ ## 9. References
248
+
249
+ - `ai-agents-sweet-spot` — when to use agents vs workflows
250
+ - `ai-agents-providers-model-registry` — provider-agnostic pattern
251
+ - `ai-agents-structured-output` (Onda 2) — typed responses
252
+ - `ai-agents-middleware-patterns` (Onda 2) — telemetry, retry, anti-hallucination, streaming agent responses
253
+ - Microsoft.Agents.AI docs: https://learn.microsoft.com/agent-framework/
254
+ - Verified packages list (context7 /microsoft/agent-framework): retrieved 2026-05-19
255
+
256
+ ---
257
+
258
+ *MORPH-SPEC by Polymorphism Tech — ai-agents/setup.md v2.0 (2026-05-19)*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polymorphism-tech/morph-spec",
3
- "version": "7.3.0",
3
+ "version": "7.4.0",
4
4
  "description": "MORPH-SPEC: NLH (Natural Language Harness) for spec-driven development with Claude Code",
5
5
  "keywords": [
6
6
  "claude-code",