@polymorphism-tech/morph-spec 8.2.1 → 8.3.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.
- package/README.md +70 -99
- package/bin/morph-spec.js +12 -0
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +76 -135
- package/docs/QUICKSTART.md +35 -51
- package/framework/CLAUDE.md +1 -0
- package/framework/agents.json +3 -1
- package/framework/hooks/README.md +3 -0
- package/framework/hooks/claude-code/core/telemetry-log.js +102 -0
- package/framework/hooks/shared/telemetry-logger.js +75 -0
- package/framework/rules/ai-agents-standards.md +1 -0
- package/framework/schemas/feature.schema.json +0 -5
- package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
- package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
- package/framework/skills/core/morph-apply/SKILL.md +1 -1
- package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
- package/framework/skills/core/morph-eval/SKILL.md +1 -1
- package/framework/skills/core/morph-hotfix/SKILL.md +1 -1
- package/framework/skills/core/morph-implement/SKILL.md +1 -1
- package/framework/skills/core/morph-plan/SKILL.md +1 -1
- package/framework/skills/core/morph-proposal/SKILL.md +1 -1
- package/framework/skills/core/morph-review/SKILL.md +1 -1
- package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
- package/framework/skills/core/morph-standards/SKILL.md +1 -1
- package/framework/standards/STANDARDS.json +43 -1
- package/framework/standards/ai-agents/observability-patterns.md +156 -0
- package/framework/standards/ai-agents/production.md +3 -47
- package/framework/templates/REGISTRY.json +0 -93
- package/package.json +1 -1
- package/src/commands/observability/telemetry.js +75 -0
- package/src/core/state/state-manager.js +0 -128
- package/src/dashboard/app/pages/LiveState.jsx +0 -43
- package/src/lib/detectors/design-system-detector.js +0 -43
- package/src/lib/generators/index.js +0 -1
- package/src/lib/telemetry/telemetry-reader.js +103 -0
- package/src/lib/validators/validation-runner.js +9 -73
- package/src/utils/hooks-installer.js +27 -3
- package/framework/templates/context/CONTEXT-FEATURE.md +0 -269
- package/framework/templates/context/CONTEXT.md +0 -181
- package/src/lib/agents/metrics-aggregator.js +0 -56
- package/src/lib/agents/metrics-calculator.js +0 -125
- package/src/lib/generators/metadata-extractor.js +0 -385
package/docs/QUICKSTART.md
CHANGED
|
@@ -19,11 +19,11 @@ morph-spec init
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
`init` does the following:
|
|
22
|
-
- Auto-detects your stack (
|
|
22
|
+
- Auto-detects your stack (.NET, Next.js, Node.js, monorepo)
|
|
23
23
|
- Creates `.morph/` with framework files, standards, and templates
|
|
24
24
|
- Creates `.morph/context/` with inferred project context
|
|
25
25
|
- Installs `.claude/skills/`, `.claude/agents/`, `.claude/rules/`
|
|
26
|
-
- Writes `.claude/settings.local.json` with
|
|
26
|
+
- Writes `.claude/settings.local.json` with the fail-open Claude Code hooks (see `docs/ARCHITECTURE.md`)
|
|
27
27
|
- Copies `CLAUDE.md` with runtime instructions
|
|
28
28
|
|
|
29
29
|
Verify the installation:
|
|
@@ -44,42 +44,31 @@ Open your project in Claude Code and run:
|
|
|
44
44
|
|
|
45
45
|
Replace `my-feature` with a short kebab-case name for your feature (e.g., `user-notifications`, `payment-flow`).
|
|
46
46
|
|
|
47
|
-
The proposal pipeline runs phases
|
|
47
|
+
The proposal pipeline runs the `proposal` and `plan` phases (plus the optional `uiux` phase), with an approval gate at each:
|
|
48
48
|
|
|
49
|
-
###
|
|
49
|
+
### Proposal (Gate 1)
|
|
50
50
|
|
|
51
|
-
Claude analyzes your request, detects
|
|
51
|
+
Claude analyzes your request, detects the relevant stack and standards, and produces `0-proposal/proposal.md`. You review it and approve (or request changes).
|
|
52
52
|
|
|
53
|
-
###
|
|
53
|
+
### UI/UX — optional (Gate)
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
Only runs for UI-heavy features. Claude generates, under `1-design/`:
|
|
56
|
+
- `design-system.md` — colors, typography, spacing
|
|
57
|
+
- `mockups.md` — ASCII wireframes
|
|
58
|
+
- `components.md` — component specs
|
|
59
|
+
- `flows.md` — user flows and edge cases
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
You approve the UI design before moving on.
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
- `1-design/design-system.md` — colors, typography, spacing
|
|
61
|
-
- `1-design/mockups.md` — ASCII wireframes
|
|
62
|
-
- `1-design/components.md` — component specs
|
|
63
|
-
- `1-design/flows.md` — user flows and edge cases
|
|
63
|
+
### Plan (Gate 2)
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
Claude produces, under `2-plan/`:
|
|
66
|
+
- `spec.md` — full requirements, use cases, validations
|
|
67
|
+
- `mandate.md` — the implementation contract (stack defaults, forbidden patterns)
|
|
68
|
+
- `tasks.json` — ordered task breakdown (`T001`, `T002`, …)
|
|
69
|
+
- `decisions.md` — architectural decision records (optional)
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Claude produces the technical specification:
|
|
70
|
-
- `2-design/spec.md` — full requirements, use cases, validations
|
|
71
|
-
- `2-design/contracts.cs` — C# interfaces, DTOs, enums
|
|
72
|
-
- `2-design/decisions.md` — architectural decision records (ADRs)
|
|
73
|
-
|
|
74
|
-
You review and approve the design.
|
|
75
|
-
|
|
76
|
-
### Phase 4 — Clarify
|
|
77
|
-
|
|
78
|
-
Claude identifies 3–7 ambiguities in the spec, asks you to resolve them, then updates the spec. No gate.
|
|
79
|
-
|
|
80
|
-
### Phase 6 — Tasks
|
|
81
|
-
|
|
82
|
-
Claude breaks the spec into atomic tasks (`T001`, `T002`, …) saved to `3-tasks/tasks.md`. You approve the task list.
|
|
71
|
+
Claude identifies ambiguities in the spec and resolves them with you before finalizing. You review and approve the spec + mandate + task list together.
|
|
83
72
|
|
|
84
73
|
At this point, planning is complete:
|
|
85
74
|
|
|
@@ -95,11 +84,11 @@ At this point, planning is complete:
|
|
|
95
84
|
/morph-apply my-feature
|
|
96
85
|
```
|
|
97
86
|
|
|
98
|
-
Claude reads `spec.md`, `
|
|
99
|
-
-
|
|
100
|
-
- Runs
|
|
101
|
-
-
|
|
102
|
-
- Generates `
|
|
87
|
+
Claude reads `spec.md`, `mandate.md`, and `tasks.json`, then implements task by task with auto-advance (no pause between tasks unless there's a blocking ambiguity):
|
|
88
|
+
- Tracks task progress with the native `TaskCreate`/`TaskUpdate` tools, persisted to `tasks.json`
|
|
89
|
+
- Runs the validators relevant to your stack after each task (e.g. `architecture`/`packages`/`contract-compliance` for .NET, `nextjs-component`/`css`/`design-system` for Next.js) via `morph-spec verify`
|
|
90
|
+
- Applies `morph-eval` after each task — a score below 9 triggers an autonomous correction loop, not a pause
|
|
91
|
+
- Generates `3-implement/recap.md` on completion, then Gate 3 review (`4-review/`)
|
|
103
92
|
|
|
104
93
|
---
|
|
105
94
|
|
|
@@ -108,21 +97,16 @@ Claude reads `spec.md`, `contracts.cs`, and `tasks.md`, then implements task by
|
|
|
108
97
|
Check feature state:
|
|
109
98
|
|
|
110
99
|
```bash
|
|
111
|
-
morph-spec state get my-feature
|
|
112
100
|
morph-spec status my-feature
|
|
113
101
|
```
|
|
114
102
|
|
|
115
|
-
|
|
103
|
+
Approve the current gate and scaffold the next phase folder in one step:
|
|
116
104
|
|
|
117
105
|
```bash
|
|
118
|
-
morph-spec
|
|
106
|
+
morph-spec advance my-feature
|
|
119
107
|
```
|
|
120
108
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
morph-spec task done my-feature T001
|
|
125
|
-
```
|
|
109
|
+
Task progress is tracked with the native `TaskCreate`/`TaskUpdate` tools and persisted to `tasks.json` — there is no separate CLI command for marking a task done.
|
|
126
110
|
|
|
127
111
|
Run validators at any time:
|
|
128
112
|
|
|
@@ -195,23 +179,23 @@ morph-spec worktree list
|
|
|
195
179
|
|
|
196
180
|
## Multiple features
|
|
197
181
|
|
|
198
|
-
You can have multiple features in progress simultaneously. Each has its own directory under `.morph/features
|
|
182
|
+
You can have multiple features in progress simultaneously. Each has its own directory under `.morph/features/`, with its own committed `feature.json`:
|
|
199
183
|
|
|
200
184
|
```
|
|
201
185
|
.morph/features/
|
|
202
186
|
├── user-notifications/
|
|
187
|
+
│ ├── feature.json
|
|
203
188
|
│ ├── 0-proposal/
|
|
204
|
-
│
|
|
205
|
-
│ └── 3-tasks/
|
|
189
|
+
│ └── 2-plan/
|
|
206
190
|
└── payment-flow/
|
|
207
|
-
├──
|
|
208
|
-
└──
|
|
191
|
+
├── feature.json
|
|
192
|
+
└── 0-proposal/
|
|
209
193
|
```
|
|
210
194
|
|
|
211
|
-
See
|
|
195
|
+
See every active feature — root and worktrees — with phase, gates, and activity:
|
|
212
196
|
|
|
213
197
|
```bash
|
|
214
|
-
morph-spec
|
|
198
|
+
morph-spec fleet
|
|
215
199
|
```
|
|
216
200
|
|
|
217
201
|
---
|
|
@@ -256,4 +240,4 @@ morph-spec doctor
|
|
|
256
240
|
|
|
257
241
|
---
|
|
258
242
|
|
|
259
|
-
*morph-spec v8.
|
|
243
|
+
*morph-spec v8.3.0 by Polymorphism Tech*
|
package/framework/CLAUDE.md
CHANGED
|
@@ -53,6 +53,7 @@ Se não houver feature ativa, pergunte ao usuário qual feature trabalhar.
|
|
|
53
53
|
- `morph-spec worktree setup|link|finish|list` — gerencia o ciclo do worktree por feature (`setup` cria `.worktrees/{f}/` na branch `morph/{f}`, aloca o bloco de portas e escreve `.morph/worktree.env`; `link` religa infra compartilhada; `finish` faz merge `--no-ff`, limpa e libera o bloco; `list` mostra fase/gate de cada worktree ativo).
|
|
54
54
|
- `morph-spec handoff <feature>` — regenera o documento de retomada (`.morph/features/{f}/handoff.md`): comprimido, derivado, aponta para os artefatos em vez de copiá-los. Gerado automaticamente em `setup`/`create --worktree`/`advance`.
|
|
55
55
|
- `morph-spec fleet` — visão da frota: toda feature ativa (raiz + worktrees) com fase, gates pendentes, tasks, portas, handoff e atividade. Use entre sessões para decidir onde atuar.
|
|
56
|
+
- `morph-spec telemetry [--json] [--feature <f>] [--limit <n>]` — reconstrói o caminho de execução da sessão a partir de `.morph/logs/events.jsonl` (skills invocadas, personas despachadas + prompts, standards/base de conhecimento lidos, mix de tools, prompts do usuário). Capturado silenciosamente pelo hook `telemetry-log` em todo tool call e todo UserPromptSubmit.
|
|
56
57
|
|
|
57
58
|
## Skills core (em `.claude/skills/`)
|
|
58
59
|
|
package/framework/agents.json
CHANGED
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"ai-agents-prompts-in-db",
|
|
65
65
|
"ai-agents-rag-custom-pgvector",
|
|
66
66
|
"ai-agents-middleware-patterns",
|
|
67
|
+
"ai-agents-observability-patterns",
|
|
67
68
|
"ai-agents-multi-agent-patterns"
|
|
68
69
|
],
|
|
69
70
|
"mcp": ["context7"],
|
|
@@ -125,7 +126,8 @@
|
|
|
125
126
|
"standards": [
|
|
126
127
|
"backend-integrations-hangfire-hangfire-jobs",
|
|
127
128
|
"infrastructure-docker-coolify-deploy",
|
|
128
|
-
"backend-dotnet-scrutor"
|
|
129
|
+
"backend-dotnet-scrutor",
|
|
130
|
+
"ai-agents-observability-patterns"
|
|
129
131
|
],
|
|
130
132
|
"mcp": ["context7"],
|
|
131
133
|
"model": "sonnet",
|
|
@@ -51,7 +51,9 @@ framework/hooks/
|
|
|
51
51
|
| **PostToolUse** (Write\|Edit) | trace-autogen.js | State sync | Auto-generates `.morph/traces/YYYY-MM-DD-{feature}-implement.json` from tasks.json + recap.md + taskScores on every tasks.json write — the skills never write traces by hand |
|
|
52
52
|
| **PostToolUse** (Write\|Edit\|AskUserQuestion) | state-sync.js | State sync | Autonomous state updates (feature register, output tracking, gate approval) |
|
|
53
53
|
| **PostToolUse** (Write\|Edit\|AskUserQuestion) | gate-guard.js | Advisory | Warns (never blocks) when a gate action disagrees with the persisted gateDecisions; logs one `coherent`/`divergent` line per check in `.morph/logs/activity.json` (issue #63) |
|
|
54
|
+
| **PostToolUse** (all tools) | telemetry-log.js | Telemetry | Appends every tool call (skill, sub-agent dispatch + prompt, knowledge-base read, bash/edit) to `.morph/logs/events.jsonl`; silent, fail-open — the NLH execution-path capture read back by `morph-spec telemetry` |
|
|
54
55
|
| **PostToolUse** (all tools) | loop-detect.js | Advisory | Warns when the last 8 actions collapse to ≤2 unique signatures |
|
|
56
|
+
| **UserPromptSubmit** | telemetry-log.js | Telemetry | Appends the user's prompt to the same `events.jsonl` stream; silent, fail-open |
|
|
55
57
|
| **Stop** | validate-completion.js | Advisory | Warns about incomplete tasks/missing outputs/recap drift; build check; session snapshot |
|
|
56
58
|
|
|
57
59
|
## Design Principles
|
|
@@ -112,6 +114,7 @@ All Claude Code hooks import from `framework/hooks/shared/`:
|
|
|
112
114
|
| `phase-utils.js` | Phase constants, path extraction, file classification |
|
|
113
115
|
| `hook-response.js` | `block(reason)`, `approve(context)`, `injectContext(text)`, `pass()` |
|
|
114
116
|
| `stdin-reader.js` | `readStdin()` — Promise-based stdin JSON reader |
|
|
117
|
+
| `telemetry-logger.js` | `appendTelemetryEvent()`, `readTelemetryEvents()` — append-only JSONL event stream (`.morph/logs/events.jsonl`) |
|
|
115
118
|
|
|
116
119
|
`injectContext(text)` is how `worktree-context.js` (and any other SessionStart hook) delivers context: it emits `{ "hookSpecificOutput": { "hookEventName": "SessionStart", "additionalContext": text } }` on stdout. Claude Code only honors additional context nested under `hookSpecificOutput` — a bare top-level field is ignored.
|
|
117
120
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Telemetry Hook: harness execution-path capture
|
|
5
|
+
*
|
|
6
|
+
* Events: PostToolUse (all tools) + UserPromptSubmit
|
|
7
|
+
*
|
|
8
|
+
* morph-spec is a Natural Language Harness: there is no central runtime to
|
|
9
|
+
* instrument — Claude Code executes the skills and sub-agents. The only
|
|
10
|
+
* vantage points are hooks. This one is the generic capture point: every tool
|
|
11
|
+
* call and every user prompt is appended (one JSON line) to
|
|
12
|
+
* .morph/logs/events.jsonl, from which `morph-spec telemetry` reconstructs the
|
|
13
|
+
* whole path — which skills ran, which personas were dispatched (with their
|
|
14
|
+
* prompts), which standards/knowledge-base files were read.
|
|
15
|
+
*
|
|
16
|
+
* Correlation is by an EXPLICIT key (feature + phase) written into each event,
|
|
17
|
+
* not by ambient span context — hooks fire as separate node processes with no
|
|
18
|
+
* shared trace context (the enrichment lesson from the observability standard:
|
|
19
|
+
* propagate a correlation key, a TraceId does not survive the boundary).
|
|
20
|
+
*
|
|
21
|
+
* SILENT: never blocks, never injects context — only appends. Fail-open on any
|
|
22
|
+
* error (exit 0). Only active inside a morph project (stateExists gate).
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { readStdin } from '../../shared/stdin-reader.js';
|
|
26
|
+
import { stateExists, getActiveFeature, derivePhaseForFeature } from '../../shared/state-reader.js';
|
|
27
|
+
import { appendTelemetryEvent } from '../../shared/telemetry-logger.js';
|
|
28
|
+
import { pass } from '../../shared/hook-response.js';
|
|
29
|
+
|
|
30
|
+
function normalize(p) {
|
|
31
|
+
return (p || '').replace(/\\/g, '/');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
if (!stateExists()) pass();
|
|
36
|
+
|
|
37
|
+
const payload = await readStdin();
|
|
38
|
+
if (!payload) pass();
|
|
39
|
+
|
|
40
|
+
const cwd = process.cwd();
|
|
41
|
+
|
|
42
|
+
// Correlation key: active feature + its phase (explicit, not ambient).
|
|
43
|
+
// NOTE (perf): getActiveFeature → loadState hydrates every .morph/features/*/
|
|
44
|
+
// feature.json, so enrichment is O(active-feature-count) per tool call. That
|
|
45
|
+
// is fine for realistic projects (archive removes finished features, so the
|
|
46
|
+
// dir holds only the few in-flight ones) but would grow on a project that
|
|
47
|
+
// keeps many un-archived features. If that ever bites, resolve the active
|
|
48
|
+
// feature from the thin state.json index alone. Kept accurate-over-cheap for
|
|
49
|
+
// now because phase is not stored in feature.json — it needs derivation.
|
|
50
|
+
let feature = null;
|
|
51
|
+
let phase = null;
|
|
52
|
+
try {
|
|
53
|
+
const active = getActiveFeature(cwd);
|
|
54
|
+
if (active) {
|
|
55
|
+
feature = active.name;
|
|
56
|
+
phase = active.feature?.phase || derivePhaseForFeature(active.name, cwd);
|
|
57
|
+
}
|
|
58
|
+
} catch {
|
|
59
|
+
// enrichment is best-effort — a missing feature never blocks capture
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let event;
|
|
63
|
+
|
|
64
|
+
// UserPromptSubmit carries the user's prompt and no tool_name.
|
|
65
|
+
if (payload.hook_event_name === 'UserPromptSubmit' || (!payload.tool_name && typeof payload.prompt === 'string')) {
|
|
66
|
+
event = { event: 'UserPromptSubmit', tool: 'UserPrompt', prompt: payload.prompt || '' };
|
|
67
|
+
} else {
|
|
68
|
+
const tool = payload.tool_name;
|
|
69
|
+
if (!tool) pass();
|
|
70
|
+
const input = payload.tool_input || {};
|
|
71
|
+
event = { event: 'PostToolUse', tool };
|
|
72
|
+
|
|
73
|
+
if (tool === 'Skill') {
|
|
74
|
+
event.skill = input.skill || '';
|
|
75
|
+
} else if (tool === 'Agent' || tool === 'Task') {
|
|
76
|
+
event.persona = input.subagent_type || '';
|
|
77
|
+
if (input.description) event.desc = input.description;
|
|
78
|
+
event.prompt = input.prompt || '';
|
|
79
|
+
} else if (tool === 'Read') {
|
|
80
|
+
event.target = normalize(input.file_path || input.path);
|
|
81
|
+
if (/\/standards\//.test(event.target)) event.kind = 'standard';
|
|
82
|
+
} else if (tool === 'Bash') {
|
|
83
|
+
event.command = input.command || '';
|
|
84
|
+
} else if (tool === 'Write' || tool === 'Edit') {
|
|
85
|
+
event.target = normalize(input.file_path || input.path);
|
|
86
|
+
} else {
|
|
87
|
+
// Every other tool still counts toward "the whole path" — record a
|
|
88
|
+
// compact target so Grep/Glob/WebFetch bursts remain distinguishable.
|
|
89
|
+
const target = input.file_path || input.path || input.pattern || input.query || input.url || '';
|
|
90
|
+
if (target) event.target = normalize(String(target));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
event.feature = feature;
|
|
95
|
+
event.phase = phase;
|
|
96
|
+
|
|
97
|
+
appendTelemetryEvent(event, cwd);
|
|
98
|
+
pass();
|
|
99
|
+
} catch {
|
|
100
|
+
// Fail-open
|
|
101
|
+
process.exit(0);
|
|
102
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telemetry Logger — append-only harness event stream
|
|
3
|
+
*
|
|
4
|
+
* Writes one JSON line per event to .morph/logs/events.jsonl. This is the sink
|
|
5
|
+
* for the `telemetry-log` hook, which fires on every tool call (PostToolUse,
|
|
6
|
+
* all tools) and on every user prompt (UserPromptSubmit) — the only vantage
|
|
7
|
+
* points an NLH exposes. The whole execution path (skills, sub-agent dispatch,
|
|
8
|
+
* knowledge-base reads, prompts) is reconstructable by reading this file.
|
|
9
|
+
*
|
|
10
|
+
* Design constraints (same discipline as activity-logger, plus one):
|
|
11
|
+
* - Synchronous only (hooks run in process, no async overhead)
|
|
12
|
+
* - Fail-silent (never throws — hooks must not be blocked by the logger)
|
|
13
|
+
* - APPEND-ONLY: one `appendFileSync` line per event, O(1) per call. The
|
|
14
|
+
* read-modify-write of a whole JSON doc (activity-logger) is O(n²) across a
|
|
15
|
+
* session and blows the ≤5ms budget once tool calls number in the hundreds.
|
|
16
|
+
* - Windows-safe paths via path.join
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { appendFileSync, readFileSync, mkdirSync, existsSync } from 'fs';
|
|
20
|
+
import { join, dirname } from 'path';
|
|
21
|
+
|
|
22
|
+
const LOGS_DIR = '.morph/logs';
|
|
23
|
+
export const EVENTS_FILE = join(LOGS_DIR, 'events.jsonl');
|
|
24
|
+
|
|
25
|
+
function getEventsPath(projectPath) {
|
|
26
|
+
return join(projectPath || process.cwd(), EVENTS_FILE);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Append a single telemetry event as one JSON line.
|
|
31
|
+
* Stamps an ISO `ts` when the caller omits one.
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} event - Event payload (tool, skill/persona/target/prompt, feature, phase…)
|
|
34
|
+
* @param {string} [projectPath] - Project root (defaults to cwd)
|
|
35
|
+
*/
|
|
36
|
+
export function appendTelemetryEvent(event, projectPath) {
|
|
37
|
+
try {
|
|
38
|
+
const eventsPath = getEventsPath(projectPath);
|
|
39
|
+
const dir = dirname(eventsPath);
|
|
40
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
41
|
+
|
|
42
|
+
const stamped = { ts: event?.ts || new Date().toISOString(), ...event };
|
|
43
|
+
appendFileSync(eventsPath, JSON.stringify(stamped) + '\n', 'utf-8');
|
|
44
|
+
} catch {
|
|
45
|
+
// Fail-silent — never block hooks
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Read the full event stream back into an array. A corrupt/truncated line
|
|
51
|
+
* (e.g. a killed process mid-write) is skipped, not fatal.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} [projectPath]
|
|
54
|
+
* @returns {Object[]} events in write order (may be empty)
|
|
55
|
+
*/
|
|
56
|
+
export function readTelemetryEvents(projectPath) {
|
|
57
|
+
try {
|
|
58
|
+
const eventsPath = getEventsPath(projectPath);
|
|
59
|
+
if (!existsSync(eventsPath)) return [];
|
|
60
|
+
const raw = readFileSync(eventsPath, 'utf-8');
|
|
61
|
+
const events = [];
|
|
62
|
+
for (const line of raw.split('\n')) {
|
|
63
|
+
const trimmed = line.trim();
|
|
64
|
+
if (!trimmed) continue;
|
|
65
|
+
try {
|
|
66
|
+
events.push(JSON.parse(trimmed));
|
|
67
|
+
} catch {
|
|
68
|
+
// skip a single corrupt line — don't lose the whole stream
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return events;
|
|
72
|
+
} catch {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -20,6 +20,7 @@ stacks:
|
|
|
20
20
|
@.morph/framework/standards/ai-agents/prompts-in-db.md
|
|
21
21
|
@.morph/framework/standards/ai-agents/rag-custom-pgvector.md
|
|
22
22
|
@.morph/framework/standards/ai-agents/middleware-patterns.md
|
|
23
|
+
@.morph/framework/standards/ai-agents/observability-patterns.md
|
|
23
24
|
@.morph/framework/standards/ai-agents/workflows.md
|
|
24
25
|
@.morph/framework/standards/ai-agents/production.md
|
|
25
26
|
|
|
@@ -195,12 +195,7 @@
|
|
|
195
195
|
},
|
|
196
196
|
"additionalProperties": true
|
|
197
197
|
},
|
|
198
|
-
"activeAgents": { "type": "array", "items": { "type": "string" } },
|
|
199
198
|
"checkpoints": { "type": "array" },
|
|
200
|
-
"dispatchLog": {
|
|
201
|
-
"type": "array",
|
|
202
|
-
"description": "Dispatch events (capped at 50). Entries: { timestamp, phase, mode, agents: [{ id, subagentType, group, tasks }] }."
|
|
203
|
-
},
|
|
204
199
|
"trustConfig": { "type": "object" },
|
|
205
200
|
"contextBundles": { "type": "array" },
|
|
206
201
|
"fileChanges": { "type": "array" },
|
|
@@ -4,7 +4,7 @@ description: Guia a criação de uma landing page nova ponta-a-ponta a partir do
|
|
|
4
4
|
version: core
|
|
5
5
|
when-to-invoke: ao iniciar um novo projeto de LP com o template Umbraco genérico
|
|
6
6
|
user-invokable: true
|
|
7
|
-
cliVersion: "8.
|
|
7
|
+
cliVersion: "8.3.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# create-umbraco-lp
|
|
@@ -4,7 +4,7 @@ description: Migra uma landing page existente (React/Vite, Next.js estático ou
|
|
|
4
4
|
version: core
|
|
5
5
|
when-to-invoke: ao receber instrução "use /migrate-lp-to-umbraco {projeto}" do usuário, ou quando o usuário descrever necessidade de migrar uma LP para Umbraco
|
|
6
6
|
user-invokable: true
|
|
7
|
-
cliVersion: "8.
|
|
7
|
+
cliVersion: "8.3.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# migrate-lp-to-umbraco
|
|
@@ -4,7 +4,7 @@ description: Orquestra a execução autônoma de tasks de uma feature morph-spec
|
|
|
4
4
|
version: core
|
|
5
5
|
when-to-invoke: após Gate 2 aprovado, ao receber instrução "use /morph-apply" ou "implementar feature"
|
|
6
6
|
user-invokable: true
|
|
7
|
-
cliVersion: "8.
|
|
7
|
+
cliVersion: "8.3.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-apply
|
|
@@ -4,7 +4,7 @@ description: Entende o negócio, os usuários e a arquitetura antes de qualquer
|
|
|
4
4
|
version: core
|
|
5
5
|
when-to-invoke: ao receber um novo request de feature, antes de morph-plan
|
|
6
6
|
user-invokable: true
|
|
7
|
-
cliVersion: "8.
|
|
7
|
+
cliVersion: "8.3.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-brainstorming
|
|
@@ -4,7 +4,7 @@ description: Avalia a qualidade de uma tarefa ou fase com rubricas graduadas 0-1
|
|
|
4
4
|
version: core
|
|
5
5
|
when-to-invoke: ao completar uma tarefa ou ao finalizar uma fase de implementação
|
|
6
6
|
user-invokable: false
|
|
7
|
-
cliVersion: "8.
|
|
7
|
+
cliVersion: "8.3.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-eval
|
|
@@ -4,7 +4,7 @@ description: ADW cirúrgico de hotfix — resolve uma queda/bug crítico de prod
|
|
|
4
4
|
version: core
|
|
5
5
|
when-to-invoke: ao receber "/morph-hotfix {feature}", quando a morph-proposal classifica o pedido como workType hotfix (Passo 0), ou o usuário diz "produção caiu / hotfix / urgente"
|
|
6
6
|
user-invokable: true
|
|
7
|
-
cliVersion: "8.
|
|
7
|
+
cliVersion: "8.3.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-hotfix
|
|
@@ -4,7 +4,7 @@ description: Guia a produção dos três artefatos de planejamento de uma featur
|
|
|
4
4
|
version: core
|
|
5
5
|
when-to-invoke: ao iniciar a fase plan de uma feature, após o Gate 1 (proposal aprovado)
|
|
6
6
|
user-invokable: true
|
|
7
|
-
cliVersion: "8.
|
|
7
|
+
cliVersion: "8.3.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-plan
|
|
@@ -4,7 +4,7 @@ description: Orquestra a fase de proposta+plano de uma feature morph-spec. Encad
|
|
|
4
4
|
version: core
|
|
5
5
|
when-to-invoke: ao receber instrução "use /morph-proposal" do usuário, ou ao iniciar uma nova feature
|
|
6
6
|
user-invokable: true
|
|
7
|
-
cliVersion: "8.
|
|
7
|
+
cliVersion: "8.3.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-proposal
|
|
@@ -4,7 +4,7 @@ description: Conduz a fase de revisão e produz o review-report.md para o Gate 3
|
|
|
4
4
|
version: core
|
|
5
5
|
when-to-invoke: ao iniciar a fase review, após todas as tasks de tasks.json estarem com status `done`
|
|
6
6
|
user-invokable: true
|
|
7
|
-
cliVersion: "8.
|
|
7
|
+
cliVersion: "8.3.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-review
|
|
@@ -4,7 +4,7 @@ description: Varre o codebase existente, detecta stack atual, compara com o stac
|
|
|
4
4
|
version: core
|
|
5
5
|
when-to-invoke: ao iniciar uma feature em projeto brownfield (codebase já existente)
|
|
6
6
|
user-invokable: true
|
|
7
|
-
cliVersion: "8.
|
|
7
|
+
cliVersion: "8.3.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-stack-scan
|
|
@@ -4,7 +4,7 @@ description: Localiza e carrega um standard específico do STANDARDS.json sob de
|
|
|
4
4
|
version: core
|
|
5
5
|
when-to-invoke: quando precisar consultar um standard específico durante a implementação
|
|
6
6
|
user-invokable: true
|
|
7
|
-
cliVersion: "8.
|
|
7
|
+
cliVersion: "8.3.0"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# morph-standards
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"mcp": "#mcp-integration-model-context-protocol",
|
|
30
30
|
"observability": "#observability--opentelemetry"
|
|
31
31
|
},
|
|
32
|
-
"digest": "Production panorama for MAF agents. Middleware (3 levels)
|
|
32
|
+
"digest": "Production panorama for MAF agents. Middleware (3 levels), MCP integration, and observability/OpenTelemetry are summarized here and treated canonically in ai-agents-middleware-patterns / ai-agents-mcp-tools / ai-agents-mcp-server / ai-agents-observability-patterns. Owns: A2A protocol via Microsoft.Agents.AI.A2A; Redis semantic + HybridCache caching; security and production checklists."
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"id": "ai-agents-setup",
|
|
@@ -309,6 +309,40 @@
|
|
|
309
309
|
},
|
|
310
310
|
"digest": "Three middleware levels intercept agent behavior: Agent Run (whole invocation), Function Calling (individual tool calls), IChatClient (raw LLM calls). Register via .AsBuilder().Use(...). Patterns: telemetry, resilience (retry/rate-limit), anti-hallucination (validate tool args before next())."
|
|
311
311
|
},
|
|
312
|
+
{
|
|
313
|
+
"id": "ai-agents-observability-patterns",
|
|
314
|
+
"name": "observability patterns",
|
|
315
|
+
"path": "ai-agents/observability-patterns.md",
|
|
316
|
+
"category": "ai-agents",
|
|
317
|
+
"subcategory": null,
|
|
318
|
+
"tags": [
|
|
319
|
+
"ai-agents",
|
|
320
|
+
"maf",
|
|
321
|
+
"observability"
|
|
322
|
+
],
|
|
323
|
+
"stacks": [
|
|
324
|
+
"dotnet"
|
|
325
|
+
],
|
|
326
|
+
"aliases": [
|
|
327
|
+
"observability",
|
|
328
|
+
"opentelemetry",
|
|
329
|
+
"telemetry",
|
|
330
|
+
"logging",
|
|
331
|
+
"tracing",
|
|
332
|
+
"log investigation",
|
|
333
|
+
"troubleshooting",
|
|
334
|
+
"aspire dashboard",
|
|
335
|
+
"correlation id",
|
|
336
|
+
"agent observability",
|
|
337
|
+
"agent telemetry"
|
|
338
|
+
],
|
|
339
|
+
"anchors": {
|
|
340
|
+
"setup": "#setup--opentelemetry",
|
|
341
|
+
"enrichment": "#enrichment--o-que-preencher-em-spans-e-logs",
|
|
342
|
+
"investigation": "#investigação-e-análise--quando-algo-dá-errado"
|
|
343
|
+
},
|
|
344
|
+
"digest": "OpenTelemetry setup for MAF agents (AgentOpenTelemetryConsts.DefaultSourceName, traces+metrics+logging). Enrichment: correlation_id propagation across async boundaries, gen_ai.* span attributes, structured ILogger scopes, sensitive-data logging rules. Investigation workflow for production incidents: anchor on correlation_id/time window, drill from root span to children, check metrics before theorizing, reproduce with Debug in staging (never production)."
|
|
345
|
+
},
|
|
312
346
|
{
|
|
313
347
|
"id": "ai-agents-modalities-vision",
|
|
314
348
|
"name": "modalities vision",
|
|
@@ -1756,6 +1790,14 @@
|
|
|
1756
1790
|
"ai-agents-production",
|
|
1757
1791
|
"ai-agents-middleware-patterns"
|
|
1758
1792
|
],
|
|
1793
|
+
"agent observability": [
|
|
1794
|
+
"ai-agents-production",
|
|
1795
|
+
"ai-agents-observability-patterns"
|
|
1796
|
+
],
|
|
1797
|
+
"agent telemetry": [
|
|
1798
|
+
"ai-agents-production",
|
|
1799
|
+
"ai-agents-observability-patterns"
|
|
1800
|
+
],
|
|
1759
1801
|
"when not to use workflow": [
|
|
1760
1802
|
"ai-agents-workflows",
|
|
1761
1803
|
"ai-agents-sweet-spot"
|