@mikulgohil/ai-kit 1.9.0 → 1.10.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.
@@ -2,6 +2,8 @@
2
2
  name: build-resolver
3
3
  description: Build error resolution agent — diagnoses and fixes Next.js, TypeScript, and Sitecore build errors.
4
4
  tools: Read, Edit, Glob, Grep, Bash
5
+ isolation: worktree
6
+ initialPrompt: Run the build command from package.json and diagnose any errors found.
5
7
  ---
6
8
 
7
9
  # Build Error Resolver
@@ -2,6 +2,8 @@
2
2
  name: e2e-runner
3
3
  description: Playwright E2E test agent — generates and runs Playwright tests using Page Object Model for Next.js applications.
4
4
  tools: Read, Write, Edit, Glob, Grep, Bash
5
+ isolation: worktree
6
+ initialPrompt: Analyze existing test coverage and identify critical user flows that need E2E tests.
5
7
  ---
6
8
 
7
9
  # E2E Test Runner
@@ -1,7 +1,9 @@
1
1
  ---
2
2
  name: migration-specialist
3
3
  description: Migration specialist agent — framework upgrades, breaking change detection, codemods, dependency migration, and incremental adoption strategies.
4
- tools: Read, Glob, Grep, Bash
4
+ tools: Read, Edit, Glob, Grep, Bash
5
+ isolation: worktree
6
+ initialPrompt: Audit the current dependency versions and identify available upgrades with breaking changes.
5
7
  ---
6
8
 
7
9
  # Migration Specialist
@@ -2,6 +2,8 @@
2
2
  name: refactor-cleaner
3
3
  description: Dead code cleanup and refactoring agent — finds unused exports, cleans imports, and removes dead code.
4
4
  tools: Read, Edit, Glob, Grep, Bash
5
+ isolation: worktree
6
+ initialPrompt: Scan for dead code and unused exports in this project using Knip or manual analysis.
5
7
  ---
6
8
 
7
9
  # Refactor & Cleanup Agent
@@ -0,0 +1,90 @@
1
+ # Fetch Docs
2
+
3
+ > **Role**: You are a documentation researcher. Your job is to fetch the latest, version-specific documentation for this project's tech stack and summarize it into the conversation context so all subsequent coding is informed by current APIs.
4
+ > **Goal**: Pre-load current documentation for the detected frameworks so the AI doesn't rely on potentially outdated training data.
5
+
6
+ ## Mandatory Steps
7
+
8
+ You MUST follow these steps in order. Do not skip any step.
9
+
10
+ 1. **Detect the Stack** — Read `ai-kit.config.json` (or `package.json` if config doesn't exist) to identify:
11
+ - Framework and version (e.g., Next.js 16.2.2)
12
+ - CMS and version (e.g., Sitecore Content SDK v2.x, Optimizely SaaS)
13
+ - Styling framework (e.g., Tailwind CSS v4)
14
+ - Any other key libraries in dependencies
15
+
16
+ 2. **Fetch Documentation** — For each detected framework, fetch current docs using the best available method:
17
+
18
+ **Next.js**:
19
+ - Primary: Use Context7 MCP → `resolve-library-id` for "next.js" → `query-docs` for the specific topic
20
+ - Fallback: WebFetch `https://nextjs.org/docs/llms-full.txt` (AI-optimized full docs)
21
+ - Focus on: App Router APIs, Server Components, Server Actions, Middleware, ISR, Turbopack (if v16+)
22
+
23
+ **Tailwind CSS**:
24
+ - Primary: Use Context7 MCP → `resolve-library-id` for "tailwindcss" → `query-docs`
25
+ - Focus on: v4 `@theme` syntax (if v4 detected), utility classes, responsive patterns, plugin API
26
+
27
+ **Sitecore XM Cloud / Content SDK**:
28
+ - Primary: Use Context7 MCP → `resolve-library-id` for "sitecore" → `query-docs`
29
+ - Fallback: Check project repo for `LLMs.txt` file
30
+ - Focus on: Component bindings, field helpers, Experience Edge GraphQL, personalization
31
+
32
+ **React**:
33
+ - Primary: Use Context7 MCP → `resolve-library-id` for "react" → `query-docs`
34
+ - Focus on: React 19 APIs (useActionState, use, Server Components), hooks rules
35
+
36
+ **Other libraries** (if specified in $ARGUMENTS):
37
+ - Use Context7 MCP → `resolve-library-id` → `query-docs`
38
+
39
+ 3. **Summarize Key APIs** — For each framework, produce a concise summary:
40
+ - Current stable version
41
+ - Key API changes since the AI's likely training cutoff
42
+ - API signatures for commonly used functions
43
+ - Breaking changes or deprecations to watch for
44
+ - Code examples from the official docs
45
+
46
+ 4. **Report What Was Loaded** — Print a summary table:
47
+
48
+ ## Output Format
49
+
50
+ ```
51
+ ## Documentation Loaded
52
+
53
+ | Framework | Version | Source | Key APIs Fetched |
54
+ |-----------|---------|--------|-----------------|
55
+ | Next.js | 16.2.x | Context7 | App Router, Server Actions, Turbopack |
56
+ | Tailwind | 4.x | Context7 | @theme syntax, utility classes |
57
+ | Sitecore | SDK v2.x | LLMs.txt | Field helpers, Experience Edge |
58
+
59
+ ## Key API Reference
60
+
61
+ ### Next.js 16
62
+ [Concise API reference with signatures and examples]
63
+
64
+ ### Tailwind CSS v4
65
+ [Key patterns and syntax differences from v3]
66
+
67
+ ### Sitecore Content SDK v2.x
68
+ [Component patterns and field helper usage]
69
+
70
+ ## What's New Since Training Cutoff
71
+ [Notable changes the AI might not know about]
72
+ ```
73
+
74
+ ## Rules
75
+
76
+ - ALWAYS check Context7 MCP first — it's the fastest and most reliable source
77
+ - If Context7 is not available, use WebFetch against official docs
78
+ - Keep summaries concise — focus on API signatures and patterns, not tutorials
79
+ - Highlight breaking changes and deprecations prominently
80
+ - If a specific library is passed as $ARGUMENTS, fetch docs for that library too
81
+ - Do NOT skip any detected framework — even if you think you know the APIs
82
+
83
+ ## When to Use This Skill
84
+
85
+ - At the **start of a coding session** — run once to pre-load context
86
+ - Before **major framework upgrades** — fetch docs for both current and target versions
87
+ - When you encounter **unexpected API behavior** — refresh docs for the specific library
88
+ - When working with **niche libraries** (Sitecore, Optimizely) that models know less about
89
+
90
+ Target: $ARGUMENTS
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ var GUIDES_DIR = path.join(PACKAGE_ROOT, "guides");
15
15
  var DOCS_SCAFFOLDS_DIR = path.join(PACKAGE_ROOT, "docs-scaffolds");
16
16
  var AGENTS_DIR = path.join(PACKAGE_ROOT, "agents");
17
17
  var CONTEXTS_DIR = path.join(PACKAGE_ROOT, "contexts");
18
- var VERSION = "1.9.0";
18
+ var VERSION = "1.10.0";
19
19
  var AI_KIT_CONFIG_FILE = "ai-kit.config.json";
20
20
  var GENERATED_FILES = {
21
21
  claudeMd: "CLAUDE.md",
@@ -118,13 +118,14 @@ function detectNextjs(projectPath, pkg) {
118
118
  return { framework: "unknown" };
119
119
  }
120
120
  const nextjsVersion = deps.next.replace(/[\^~>=<]/g, "");
121
+ const nextjsMajorVersion = parseInt(nextjsVersion.split(".")[0], 10) || void 0;
121
122
  const hasAppDir = dirExists(path2.join(projectPath, "app")) || dirExists(path2.join(projectPath, "src", "app"));
122
123
  const hasPagesDir = dirExists(path2.join(projectPath, "pages")) || dirExists(path2.join(projectPath, "src", "pages"));
123
124
  let routerType;
124
125
  if (hasAppDir && hasPagesDir) routerType = "hybrid";
125
126
  else if (hasAppDir) routerType = "app";
126
127
  else if (hasPagesDir) routerType = "pages";
127
- return { framework: "nextjs", nextjsVersion, routerType };
128
+ return { framework: "nextjs", nextjsVersion, nextjsMajorVersion, routerType };
128
129
  }
129
130
 
130
131
  // src/scanner/sitecore.ts
@@ -1053,7 +1054,7 @@ var MDC_CONFIG = {
1053
1054
  function generateMdcFiles(scan) {
1054
1055
  const fragments = selectFragments(scan);
1055
1056
  const variables = buildCursorVariables(scan);
1056
- return fragments.map((fragment) => {
1057
+ const mdcFiles = fragments.map((fragment) => {
1057
1058
  const config = MDC_CONFIG[fragment] || {
1058
1059
  description: fragment,
1059
1060
  globs: "**/*"
@@ -1076,6 +1077,42 @@ function generateMdcFiles(scan) {
1076
1077
  ${replaced}`
1077
1078
  };
1078
1079
  });
1080
+ const techStack = [
1081
+ scan.framework === "nextjs" ? `Next.js ${scan.nextjsVersion || ""}`.trim() : scan.framework,
1082
+ scan.cms !== "none" ? scan.cms : null,
1083
+ scan.styling.length > 0 ? scan.styling.join(", ") : null,
1084
+ scan.typescript ? "TypeScript" : null,
1085
+ scan.monorepo ? scan.monorepoTool : null
1086
+ ].filter(Boolean).join(" + ");
1087
+ const indexContent = [
1088
+ "---",
1089
+ `description: ${scan.projectName} \u2014 repo-wide project conventions and AI rules`,
1090
+ "globs: **/*",
1091
+ "alwaysApply: true",
1092
+ "---",
1093
+ "",
1094
+ `<!-- Generated by ai-kit v${VERSION} -->`,
1095
+ "",
1096
+ `# ${scan.projectName}`,
1097
+ "",
1098
+ `**Tech Stack**: ${techStack}`,
1099
+ "",
1100
+ "## Active Rules",
1101
+ ...fragments.map((f) => `- [\`${f}\`](./${f}.mdc) \u2014 ${MDC_CONFIG[f]?.description || f}`),
1102
+ "",
1103
+ "## Conventions",
1104
+ "- Follow existing patterns in the codebase",
1105
+ "- Match naming conventions already in use",
1106
+ `- Package manager: \`${scan.packageManager}\``,
1107
+ scan.routerType ? `- Router: ${scan.routerType === "app" ? "App Router" : scan.routerType === "pages" ? "Pages Router" : "Hybrid (App + Pages)"}` : "",
1108
+ "",
1109
+ "> Rules are auto-generated by [ai-kit](https://github.com/mikulgohil/ai-kit). Run `ai-kit update` to refresh."
1110
+ ].filter((line) => line !== void 0).join("\n");
1111
+ mdcFiles.unshift({
1112
+ filename: "index.mdc",
1113
+ content: indexContent
1114
+ });
1115
+ return mdcFiles;
1079
1116
  }
1080
1117
 
1081
1118
  // src/generator/config.ts
@@ -1103,6 +1140,7 @@ function generateHooks(scan, profile = "standard") {
1103
1140
  const hooks = {};
1104
1141
  const preToolUse = [];
1105
1142
  const postToolUse = [];
1143
+ const postCompact = [];
1106
1144
  const stop = [];
1107
1145
  preToolUse.push({
1108
1146
  matcher: "Bash(git push*)",
@@ -1277,6 +1315,25 @@ function generateHooks(scan, profile = "standard") {
1277
1315
  ]
1278
1316
  });
1279
1317
  }
1318
+ if (profile !== "minimal") {
1319
+ postCompact.push({
1320
+ matcher: "",
1321
+ hooks: [
1322
+ {
1323
+ type: "command",
1324
+ command: [
1325
+ 'echo "\u{1F504} Context was compacted. Key reminders:"',
1326
+ 'if [ -f "CLAUDE.md" ]; then echo " \u2192 CLAUDE.md is loaded \u2014 project rules are preserved"; fi',
1327
+ 'if [ -f "ai-kit.config.json" ]; then',
1328
+ ` STACK=$(node -e "try{const c=JSON.parse(require('fs').readFileSync('ai-kit.config.json','utf8'));console.log([c.scanResult.framework,c.scanResult.cms,c.scanResult.styling?.join(',')].filter(Boolean).join(' + '))}catch{}" 2>/dev/null)`,
1329
+ ' if [ -n "$STACK" ]; then echo " \u2192 Tech stack: $STACK"; fi',
1330
+ "fi",
1331
+ 'echo " \u2192 Run /effort to adjust reasoning depth if needed"'
1332
+ ].join("\n")
1333
+ }
1334
+ ]
1335
+ });
1336
+ }
1280
1337
  if (profile === "strict") {
1281
1338
  stop.push({
1282
1339
  matcher: "",
@@ -1290,6 +1347,7 @@ function generateHooks(scan, profile = "standard") {
1290
1347
  }
1291
1348
  if (preToolUse.length > 0) hooks.PreToolUse = preToolUse;
1292
1349
  if (postToolUse.length > 0) hooks.PostToolUse = postToolUse;
1350
+ if (postCompact.length > 0) hooks.PostCompact = postCompact;
1293
1351
  if (stop.length > 0) hooks.Stop = stop;
1294
1352
  return hooks;
1295
1353
  }
@@ -1351,7 +1409,9 @@ var AVAILABLE_SKILLS = [
1351
1409
  "harness-audit",
1352
1410
  // New skills (v1.7.0) — requirements clarification (inspired by OMC Deep Interview)
1353
1411
  "deep-interview",
1354
- "clarify-requirements"
1412
+ "clarify-requirements",
1413
+ // New skills (v1.10.0) — documentation freshness
1414
+ "fetch-docs"
1355
1415
  ];
1356
1416
  var SKILL_DESCRIPTIONS = {
1357
1417
  "prompt-help": "Help developers write effective AI prompts with structured context",
@@ -1401,7 +1461,9 @@ var SKILL_DESCRIPTIONS = {
1401
1461
  "harness-audit": "Audit AI agent configuration \u2014 check CLAUDE.md, hooks, agents, skills, MCP servers",
1402
1462
  // New skills (v1.7.0) — requirements clarification
1403
1463
  "deep-interview": "Socratic requirements gathering \u2014 structured interview to transform vague ideas into detailed specifications",
1404
- "clarify-requirements": "Quick task clarification \u2014 identify gaps and ambiguities in under 5 minutes before coding"
1464
+ "clarify-requirements": "Quick task clarification \u2014 identify gaps and ambiguities in under 5 minutes before coding",
1465
+ // New skills (v1.10.0) — documentation freshness
1466
+ "fetch-docs": "Pre-load current, version-specific docs for your tech stack using Context7 MCP \u2014 run at session start to prevent outdated API usage"
1405
1467
  };
1406
1468
  async function copySkills(targetDir) {
1407
1469
  const copied = [];