@itz4blitz/agentful 0.1.11 → 0.2.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.
@@ -0,0 +1,564 @@
1
+ ---
2
+ name: agentful-analyze
3
+ description: Unified analysis of agentful setup - detects gaps, validates configuration, identifies stale settings, and suggests/applies fixes
4
+ ---
5
+
6
+ # agentful Analyze
7
+
8
+ Unified analysis command that detects gaps in skills, agents, and configuration. Can be triggered manually or via hooks.
9
+
10
+ ## Command Syntax
11
+
12
+ ```bash
13
+ /agentful-analyze # Quick health check (default)
14
+ /agentful-analyze full # Comprehensive analysis
15
+ /agentful-analyze fix # Analyze and auto-fix issues
16
+ ```
17
+
18
+ ## Modes
19
+
20
+ ### Mode 1: QUICK (Default)
21
+
22
+ Fast health check (under 10 seconds). No deep codebase scanning.
23
+
24
+ **What it checks:**
25
+
26
+ 1. **Core Setup**
27
+ - `.agentful/architecture.json` exists and is valid JSON
28
+ - Core agents exist (backend, frontend, tester, reviewer, fixer, orchestrator)
29
+ - Skills directory structure is valid
30
+
31
+ 2. **Tech Stack Alignment**
32
+ - Read `package.json` or equivalent dependency file
33
+ - Check if detected frameworks have corresponding skills
34
+ - Identify major mismatches (e.g., using Next.js 15 but skill is for v14)
35
+
36
+ 3. **State Files**
37
+ - Check state files exist and are valid JSON
38
+ - Verify no corrupted state
39
+
40
+ **Process:**
41
+
42
+ ```typescript
43
+ // 1. Check architecture.json
44
+ const archPath = ".agentful/architecture.json";
45
+ if (!exists(archPath)) {
46
+ issues.push({ type: "critical", msg: "Missing architecture.json - run /agentful-start" });
47
+ } else {
48
+ const arch = JSON.parse(Read(archPath));
49
+ if (!arch.language || !arch.framework) {
50
+ issues.push({ type: "warning", msg: "Incomplete architecture analysis" });
51
+ }
52
+ }
53
+
54
+ // 2. Check core agents
55
+ const coreAgents = ["backend", "frontend", "tester", "reviewer", "fixer", "orchestrator"];
56
+ const existingAgents = Glob(".claude/agents/*.md").map(extractName);
57
+ const missingAgents = coreAgents.filter(a => !existingAgents.includes(a));
58
+ if (missingAgents.length > 0) {
59
+ issues.push({ type: "critical", msg: `Missing core agents: ${missingAgents.join(", ")}` });
60
+ }
61
+
62
+ // 3. Check tech stack alignment
63
+ const deps = detectDependencies();
64
+ const skills = Glob(".claude/skills/*/SKILL.md").map(extractSkillName);
65
+
66
+ for (const dep of deps) {
67
+ const expectedSkill = frameworkToSkill(dep.name);
68
+ if (!skills.includes(expectedSkill)) {
69
+ issues.push({
70
+ type: "warning",
71
+ msg: `Framework ${dep.name} detected but no skill found`,
72
+ fix: `generate_skill:${expectedSkill}`
73
+ });
74
+ } else {
75
+ // Check version alignment
76
+ const skillVersion = extractSkillVersion(expectedSkill);
77
+ if (skillVersion && dep.version && skillVersion < dep.version.split('.')[0]) {
78
+ issues.push({
79
+ type: "warning",
80
+ msg: `Skill ${expectedSkill} is outdated (v${skillVersion} vs v${dep.version})`,
81
+ fix: `regenerate_skill:${expectedSkill}`
82
+ });
83
+ }
84
+ }
85
+ }
86
+
87
+ // 4. Check state files
88
+ const stateFiles = [".agentful/state.json", ".agentful/completion.json"];
89
+ for (const file of stateFiles) {
90
+ if (exists(file)) {
91
+ try {
92
+ JSON.parse(Read(file));
93
+ } catch {
94
+ issues.push({ type: "error", msg: `Corrupted state file: ${file}`, fix: `reset_state:${file}` });
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ **Output Format:**
101
+
102
+ ```
103
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
104
+ agentful Health Check (Quick)
105
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
106
+
107
+ Status: ⚠️ WARNINGS
108
+
109
+ Core Setup:
110
+ ✓ architecture.json valid
111
+ ✓ All core agents present (6/6)
112
+ ✓ State files intact
113
+
114
+ Tech Stack Alignment:
115
+ Detected: Next.js 15.1, PostgreSQL, Prisma 5
116
+ Skills:
117
+ ⚠️ nextjs (outdated v14, current v15)
118
+ ✗ postgresql (missing)
119
+ ✓ prisma (ok)
120
+
121
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
122
+
123
+ Issues Found (2):
124
+
125
+ 1. Skill 'nextjs' is outdated (v14 vs v15)
126
+ Fix: Regenerate skill with latest docs
127
+
128
+ 2. Missing skill for PostgreSQL
129
+ Fix: Generate postgresql-db skill
130
+
131
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
132
+
133
+ Run `/agentful-analyze fix` to auto-apply fixes.
134
+ Run `/agentful-analyze full` for comprehensive analysis.
135
+ ```
136
+
137
+ ### Mode 2: FULL
138
+
139
+ Comprehensive analysis including codebase scanning.
140
+
141
+ **Additional checks beyond QUICK:**
142
+
143
+ 1. **Domain Analysis**
144
+ - Scan codebase for new domains (like `/agentful-agents` does)
145
+ - Check if discovered domains have agents
146
+ - Identify stale domain agents (domain no longer exists in code)
147
+
148
+ 2. **Skill Content Validation**
149
+ - Validate skill content matches current framework versions
150
+ - Check for deprecated patterns in skills
151
+ - Verify skills have comprehensive content (not placeholders)
152
+
153
+ 3. **Architecture Drift**
154
+ - Compare current codebase patterns vs architecture.json
155
+ - Detect if new frameworks/libraries added but not in architecture
156
+ - Identify removed dependencies still in architecture
157
+
158
+ 4. **Configuration Consistency**
159
+ - Check if product spec exists but not referenced in state
160
+ - Verify completion.json aligns with product spec structure
161
+ - Detect orphaned state files
162
+
163
+ **Process:**
164
+
165
+ ```typescript
166
+ // Run quick checks first
167
+ await runQuickChecks();
168
+
169
+ // 1. Domain discovery (lightweight version of /agentful-agents)
170
+ const domains = await Task("domain-explorer-lightweight", {
171
+ mode: "fast",
172
+ confidence_threshold: 0.75
173
+ });
174
+
175
+ const domainAgents = Glob(".claude/agents/*.md")
176
+ .filter(p => !["backend", "frontend", "tester", "reviewer", "fixer", "orchestrator"].includes(extractName(p)));
177
+
178
+ // Check for missing domain agents
179
+ for (const domain of domains) {
180
+ if (!domainAgents.some(a => extractName(a) === domain.name)) {
181
+ issues.push({
182
+ type: "info",
183
+ msg: `Domain '${domain.name}' detected (${domain.confidence}%) but no agent exists`,
184
+ fix: `generate_domain_agent:${domain.name}`
185
+ });
186
+ }
187
+ }
188
+
189
+ // Check for stale domain agents
190
+ for (const agent of domainAgents) {
191
+ const name = extractName(agent);
192
+ if (!domains.some(d => d.name === name)) {
193
+ issues.push({
194
+ type: "info",
195
+ msg: `Domain agent '${name}' exists but domain not found in codebase`,
196
+ fix: `archive_agent:${name}`
197
+ });
198
+ }
199
+ }
200
+
201
+ // 2. Skill content validation
202
+ const skills = Glob(".claude/skills/*/SKILL.md");
203
+ for (const skillPath of skills) {
204
+ const validation = await Task("skill-validator", { path: skillPath });
205
+ if (validation.status !== "valid") {
206
+ issues.push({
207
+ type: "warning",
208
+ msg: `Skill '${extractSkillName(skillPath)}' has issues: ${validation.issues.join(", ")}`,
209
+ fix: `regenerate_skill:${extractSkillName(skillPath)}`
210
+ });
211
+ }
212
+ }
213
+
214
+ // 3. Architecture drift detection
215
+ const currentDeps = detectDependencies();
216
+ const archDeps = architecture.dependencies || [];
217
+
218
+ const newDeps = currentDeps.filter(d => !archDeps.includes(d.name));
219
+ const removedDeps = archDeps.filter(d => !currentDeps.some(c => c.name === d));
220
+
221
+ for (const dep of newDeps) {
222
+ issues.push({
223
+ type: "info",
224
+ msg: `New dependency '${dep.name}' not in architecture.json`,
225
+ fix: `update_architecture:add:${dep.name}`
226
+ });
227
+ }
228
+
229
+ for (const dep of removedDeps) {
230
+ issues.push({
231
+ type: "info",
232
+ msg: `Dependency '${dep}' removed from project but still in architecture.json`,
233
+ fix: `update_architecture:remove:${dep}`
234
+ });
235
+ }
236
+ ```
237
+
238
+ **Output Format:**
239
+
240
+ ```
241
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
242
+ agentful Health Check (Full Analysis)
243
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
244
+
245
+ Status: ⚠️ WARNINGS
246
+
247
+ [... Quick check results ...]
248
+
249
+ Domain Analysis:
250
+ Discovered: 3 domains
251
+ ✓ authentication (92% confidence) - agent exists
252
+ ✓ billing (87% confidence) - agent exists
253
+ ⚠️ notifications (81% confidence) - no agent
254
+
255
+ Stale agents: 1
256
+ ⚠️ legacy-payments - domain no longer exists
257
+
258
+ Skill Validation:
259
+ ✓ 4 skills valid
260
+ ⚠️ 1 skill needs update (nextjs)
261
+
262
+ Architecture Drift:
263
+ New dependencies: 2
264
+ • @tanstack/react-query (not in architecture)
265
+ • stripe (not in architecture)
266
+
267
+ Removed dependencies: 1
268
+ • axios (removed from project)
269
+
270
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
271
+
272
+ Recommendations (6):
273
+
274
+ 1. Regenerate 'nextjs' skill for v15
275
+ 2. Generate 'postgresql-db' skill
276
+ 3. Generate domain agent for 'notifications'
277
+ 4. Archive stale agent 'legacy-payments'
278
+ 5. Update architecture.json with new dependencies
279
+ 6. Remove outdated dependencies from architecture.json
280
+
281
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
282
+
283
+ Run `/agentful-analyze fix` to auto-apply fixes.
284
+ ```
285
+
286
+ ### Mode 3: FIX
287
+
288
+ Auto-fix detected issues with user confirmation.
289
+
290
+ **Process:**
291
+
292
+ ```typescript
293
+ // 1. Run full analysis
294
+ const issues = await runFullAnalysis();
295
+
296
+ // 2. Group fixes by category
297
+ const fixGroups = {
298
+ critical: issues.filter(i => i.type === "critical"),
299
+ skills: issues.filter(i => i.fix?.startsWith("generate_skill") || i.fix?.startsWith("regenerate_skill")),
300
+ agents: issues.filter(i => i.fix?.startsWith("generate_domain_agent") || i.fix?.startsWith("archive_agent")),
301
+ architecture: issues.filter(i => i.fix?.startsWith("update_architecture")),
302
+ state: issues.filter(i => i.fix?.startsWith("reset_state"))
303
+ };
304
+
305
+ // 3. Show user what will be fixed
306
+ console.log(`
307
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
308
+ Auto-Fix Summary
309
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
310
+
311
+ Critical issues (${fixGroups.critical.length}):
312
+ ${fixGroups.critical.map(i => ` • ${i.msg}`).join("\n")}
313
+
314
+ Skills (${fixGroups.skills.length}):
315
+ ${fixGroups.skills.map(i => ` • ${i.msg}`).join("\n")}
316
+
317
+ Agents (${fixGroups.agents.length}):
318
+ ${fixGroups.agents.map(i => ` • ${i.msg}`).join("\n")}
319
+
320
+ Architecture (${fixGroups.architecture.length}):
321
+ ${fixGroups.architecture.map(i => ` • ${i.msg}`).join("\n")}
322
+
323
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
324
+
325
+ Apply these fixes? (y/n): `);
326
+
327
+ // 4. Wait for user confirmation
328
+ const confirmed = await getUserConfirmation();
329
+ if (!confirmed) {
330
+ console.log("Cancelled. No changes made.");
331
+ return;
332
+ }
333
+
334
+ // 5. Apply fixes in parallel where possible
335
+ const fixTasks = [];
336
+
337
+ // Critical fixes first (sequential)
338
+ for (const issue of fixGroups.critical) {
339
+ await applyFix(issue.fix);
340
+ }
341
+
342
+ // Skills (parallel)
343
+ if (fixGroups.skills.length > 0) {
344
+ console.log("\n🔧 Fixing skills...");
345
+ fixTasks.push(...fixGroups.skills.map(issue =>
346
+ Task("fix-applier", { fix: issue.fix, msg: issue.msg })
347
+ ));
348
+ }
349
+
350
+ // Agents (parallel)
351
+ if (fixGroups.agents.length > 0) {
352
+ console.log("\n🔧 Fixing agents...");
353
+ fixTasks.push(...fixGroups.agents.map(issue =>
354
+ Task("fix-applier", { fix: issue.fix, msg: issue.msg })
355
+ ));
356
+ }
357
+
358
+ await Promise.all(fixTasks);
359
+
360
+ // Architecture updates (sequential)
361
+ for (const issue of fixGroups.architecture) {
362
+ await applyFix(issue.fix);
363
+ }
364
+
365
+ // 6. Re-run analysis to verify
366
+ console.log("\n✓ Fixes applied. Re-running analysis...\n");
367
+ await runQuickChecks();
368
+ ```
369
+
370
+ **Output Format:**
371
+
372
+ ```
373
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
374
+ Auto-Fix Summary
375
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
376
+
377
+ Skills (2):
378
+ • Regenerate 'nextjs' skill for v15
379
+ • Generate 'postgresql-db' skill
380
+
381
+ Agents (1):
382
+ • Generate domain agent for 'notifications'
383
+
384
+ Architecture (2):
385
+ • Add @tanstack/react-query to architecture.json
386
+ • Remove axios from architecture.json
387
+
388
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
389
+
390
+ Apply these fixes? (y/n): y
391
+
392
+ 🔧 Fixing skills...
393
+ ✓ Regenerated nextjs skill (v15)
394
+ ✓ Generated postgresql-db skill
395
+
396
+ 🔧 Fixing agents...
397
+ ✓ Generated notifications domain agent
398
+
399
+ 🔧 Updating architecture...
400
+ ✓ Updated architecture.json
401
+
402
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
403
+
404
+ ✓ All fixes applied successfully.
405
+
406
+ Re-running health check...
407
+
408
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
409
+ agentful Health Check (Quick)
410
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
411
+
412
+ Status: ✓ HEALTHY
413
+
414
+ Core Setup:
415
+ ✓ architecture.json valid
416
+ ✓ All core agents present (6/6)
417
+ ✓ State files intact
418
+
419
+ Tech Stack Alignment:
420
+ Detected: Next.js 15.1, PostgreSQL, Prisma 5
421
+ Skills:
422
+ ✓ nextjs (v15)
423
+ ✓ postgresql-db (ok)
424
+ ✓ prisma (ok)
425
+
426
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
427
+
428
+ All checks passed!
429
+ ```
430
+
431
+ ## Fix Implementation
432
+
433
+ The `applyFix` function handles different fix types:
434
+
435
+ ```typescript
436
+ async function applyFix(fixString: string): Promise<void> {
437
+ const [action, ...params] = fixString.split(":");
438
+
439
+ switch (action) {
440
+ case "generate_skill":
441
+ await Task("skill-generator", { skill_name: params[0] });
442
+ break;
443
+
444
+ case "regenerate_skill":
445
+ await Task("skill-regenerator", { skill_name: params[0] });
446
+ break;
447
+
448
+ case "generate_domain_agent":
449
+ await Task("agent-generator", { domain: params[0] });
450
+ break;
451
+
452
+ case "archive_agent":
453
+ const agentPath = `.claude/agents/${params[0]}.md`;
454
+ const archivePath = `.claude/agents/archived/${params[0]}.md`;
455
+ const content = Read(agentPath);
456
+ Write(archivePath, content);
457
+ Bash(`rm ${agentPath}`);
458
+ break;
459
+
460
+ case "update_architecture":
461
+ const arch = JSON.parse(Read(".agentful/architecture.json"));
462
+ if (params[0] === "add") {
463
+ arch.dependencies = arch.dependencies || [];
464
+ arch.dependencies.push(params[1]);
465
+ } else if (params[0] === "remove") {
466
+ arch.dependencies = arch.dependencies.filter(d => d !== params[1]);
467
+ }
468
+ Write(".agentful/architecture.json", JSON.stringify(arch, null, 2));
469
+ break;
470
+
471
+ case "reset_state":
472
+ const statePath = params[0];
473
+ const backup = Read(statePath);
474
+ Write(`${statePath}.backup`, backup);
475
+ Write(statePath, "{}");
476
+ break;
477
+ }
478
+ }
479
+ ```
480
+
481
+ ## Hook Integration
482
+
483
+ This command can be called from PostToolUse hooks:
484
+
485
+ ### Hook: After package.json Changes
486
+
487
+ ```typescript
488
+ // .claude/hooks/post-edit-package-json.ts
489
+ if (file_path.includes("package.json")) {
490
+ Task("agentful-analyzer", { mode: "quick", context: "package.json changed" });
491
+ }
492
+ ```
493
+
494
+ ### Hook: After Architecture Changes
495
+
496
+ ```typescript
497
+ // .claude/hooks/post-architecture-update.ts
498
+ if (file_path === ".agentful/architecture.json") {
499
+ Task("agentful-analyzer", { mode: "quick", context: "architecture updated" });
500
+ }
501
+ ```
502
+
503
+ ## Usage Examples
504
+
505
+ ### Example 1: Quick Check During Development
506
+
507
+ ```bash
508
+ /agentful-analyze
509
+ # Takes 5-10 seconds
510
+ # Reports any immediate issues
511
+ ```
512
+
513
+ ### Example 2: After Dependency Update
514
+
515
+ ```bash
516
+ npm install next@15
517
+ /agentful-analyze
518
+ # Detects Next.js version change
519
+ # Suggests regenerating nextjs skill
520
+ ```
521
+
522
+ ### Example 3: Periodic Maintenance
523
+
524
+ ```bash
525
+ /agentful-analyze full
526
+ # Comprehensive analysis
527
+ # Finds stale agents, missing skills, drift
528
+ ```
529
+
530
+ ### Example 4: Auto-Fix Everything
531
+
532
+ ```bash
533
+ /agentful-analyze fix
534
+ # Runs full analysis
535
+ # Shows what will be fixed
536
+ # Applies fixes after confirmation
537
+ ```
538
+
539
+ ## Important Notes
540
+
541
+ 1. **Quick mode** is non-invasive and fast - suitable for hooks
542
+ 2. **Full mode** scans codebase - takes longer but thorough
543
+ 3. **Fix mode** requires user confirmation before changes
544
+ 4. All fixes are applied using existing sub-agents (skill-generator, agent-generator, etc.)
545
+ 5. State files are backed up before reset
546
+ 6. Agents are archived (not deleted) when stale
547
+
548
+ ## Integration with Other Commands
549
+
550
+ - **`/agentful-skills`**: Used for skill generation/regeneration
551
+ - **`/agentful-agents`**: Used for domain agent discovery/generation
552
+ - **`/agentful-validate`**: Complementary - validates code quality, this validates agentful setup
553
+ - **`/agentful-status`**: Shows progress, this shows health
554
+
555
+ ## Success Criteria
556
+
557
+ Command succeeds when:
558
+
559
+ 1. **Detection**: Accurately identifies gaps and issues
560
+ 2. **Prioritization**: Critical issues flagged first
561
+ 3. **Actionability**: Every issue has a clear fix path
562
+ 4. **Speed**: Quick mode completes in under 10 seconds
563
+ 5. **Safety**: Fix mode requires confirmation, backs up data
564
+ 6. **Integration**: Works seamlessly with hooks and other commands