@mikulgohil/ai-kit 1.1.0 → 1.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.
Files changed (41) hide show
  1. package/README.md +85 -12
  2. package/agents/architect.md +79 -0
  3. package/agents/build-resolver.md +54 -0
  4. package/agents/code-reviewer.md +60 -0
  5. package/agents/doc-updater.md +46 -0
  6. package/agents/e2e-runner.md +64 -0
  7. package/agents/planner.md +56 -0
  8. package/agents/refactor-cleaner.md +58 -0
  9. package/agents/security-reviewer.md +67 -0
  10. package/agents/sitecore-specialist.md +96 -0
  11. package/agents/tdd-guide.md +115 -0
  12. package/commands/checkpoint.md +78 -0
  13. package/commands/harness-audit.md +73 -0
  14. package/commands/middleware.md +80 -0
  15. package/commands/orchestrate.md +67 -0
  16. package/commands/quality-gate-check.md +109 -0
  17. package/commands/quality-gate.md +82 -0
  18. package/commands/resume-session.md +40 -0
  19. package/commands/save-session.md +65 -0
  20. package/commands/search-first.md +60 -0
  21. package/commands/server-action.md +93 -0
  22. package/commands/sitecore-debug.md +58 -0
  23. package/contexts/dev.md +35 -0
  24. package/contexts/research.md +56 -0
  25. package/contexts/review.md +49 -0
  26. package/dist/index.js +891 -119
  27. package/dist/index.js.map +1 -1
  28. package/guides/getting-started.md +74 -21
  29. package/guides/hooks-and-agents.md +124 -0
  30. package/package.json +9 -4
  31. package/templates/claude-md/nextjs-app-router.md +35 -1
  32. package/templates/claude-md/sitecore-xmc.md +99 -2
  33. package/templates/claude-md/typescript.md +79 -1
  34. package/templates/cursorrules/nextjs-app-router.md +6 -1
  35. package/templates/cursorrules/sitecore-xmc.md +5 -1
  36. package/templates/cursorrules/typescript.md +6 -1
  37. package/commands/ci-fix.md +0 -102
  38. package/commands/db-migrate.md +0 -138
  39. package/commands/dependency-graph.md +0 -138
  40. package/commands/docker-debug.md +0 -111
  41. package/commands/visual-diff.md +0 -131
@@ -0,0 +1,82 @@
1
+ # Quality Gate — Comprehensive Quality Checks
2
+
3
+ Run all quality checks and present a pass/fail summary.
4
+
5
+ ## Checks
6
+
7
+ ### TypeScript Type Check
8
+ ```bash
9
+ npx tsc --noEmit --pretty
10
+ ```
11
+ **Pass criteria**: zero errors
12
+
13
+ ### Lint (ESLint)
14
+ ```bash
15
+ npx eslint . --max-warnings 0 --format compact
16
+ ```
17
+ **Pass criteria**: zero errors, zero warnings
18
+
19
+ ### Format (Prettier or Biome)
20
+ ```bash
21
+ npx prettier --check "**/*.{ts,tsx,js,jsx,json,css,scss,md}"
22
+ # or
23
+ npx @biomejs/biome check .
24
+ ```
25
+ **Pass criteria**: all files formatted
26
+
27
+ ### Unit Tests
28
+ ```bash
29
+ npm test -- --run --reporter=verbose
30
+ ```
31
+ **Pass criteria**: all tests pass
32
+
33
+ ### Build
34
+ ```bash
35
+ npm run build
36
+ ```
37
+ **Pass criteria**: build succeeds without errors
38
+
39
+ ### Bundle Size (if @next/bundle-analyzer available)
40
+ Check for significant size increases compared to main branch.
41
+
42
+ ### Accessibility (if axe-core available)
43
+ ```bash
44
+ npx playwright test --grep @a11y
45
+ ```
46
+ **Pass criteria**: no critical or serious violations
47
+
48
+ ### Security
49
+ ```bash
50
+ npm audit --production --audit-level=high
51
+ ```
52
+ **Pass criteria**: no high or critical vulnerabilities
53
+
54
+ Check for common issues:
55
+ - `console.log` statements in production code
56
+ - Hardcoded secrets or API keys
57
+ - `any` types in TypeScript
58
+
59
+ ## Output Format
60
+
61
+ ```
62
+ ┌─────────────┬────────┬─────────────────────────┐
63
+ │ Check │ Status │ Details │
64
+ ├─────────────┼────────┼─────────────────────────┤
65
+ │ TypeScript │ ✓ PASS │ 0 errors │
66
+ │ Lint │ ✓ PASS │ 0 warnings │
67
+ │ Format │ ✓ PASS │ All files formatted │
68
+ │ Tests │ ✓ PASS │ 42/42 passed (87% cov) │
69
+ │ Build │ ✓ PASS │ 12.3s │
70
+ │ Bundle │ ⚠ WARN │ +15KB from main │
71
+ │ A11y │ ✓ PASS │ 0 violations │
72
+ │ Security │ ✓ PASS │ 0 high/critical │
73
+ │ Console.log │ ✗ FAIL │ 3 files have console.log│
74
+ └─────────────┴────────┴─────────────────────────┘
75
+
76
+ Result: 8/9 passed — fix console.log before merge
77
+ ```
78
+
79
+ ## Gate Policy
80
+ - **All PASS**: safe to merge
81
+ - **Any WARN**: merge with acknowledgment
82
+ - **Any FAIL**: fix before merge (no exceptions in strict mode)
@@ -0,0 +1,40 @@
1
+ # Resume Session — Restore Previous Context
2
+
3
+ Restore context from a saved session and continue where you left off.
4
+
5
+ ## Process
6
+
7
+ ### 1. Find the Session
8
+ - Look in `ai-kit/sessions/` for saved session files
9
+ - List available sessions sorted by date (most recent first)
10
+ - If user specifies a topic, filter by filename
11
+ - Otherwise, offer the most recent session
12
+
13
+ ### 2. Read and Summarize
14
+ Read the session file and present:
15
+ - **What was done**: summary of previous work
16
+ - **What's pending**: remaining checklist items
17
+ - **Key decisions**: important context from last time
18
+ - **Files involved**: which files were being worked on
19
+
20
+ ### 3. Verify Current State
21
+ Before resuming work, check:
22
+ - Are the files from the session still in the expected state?
23
+ - Have other changes been made since the session was saved?
24
+ - Is the build currently passing?
25
+ - Are there any uncommitted changes that might conflict?
26
+
27
+ ### 4. Resume
28
+ - Pick up from the first unchecked item in the pending list
29
+ - Reference previous decisions to maintain consistency
30
+ - Update the session file as work progresses
31
+
32
+ ## If No Sessions Found
33
+ - Check `ai-kit/sessions/` directory exists
34
+ - Suggest running `/save-session` at the end of future sessions
35
+ - Offer to start fresh by creating a new session
36
+
37
+ ## Tips
38
+ - Always verify file state before making changes — the codebase may have evolved
39
+ - If significant time has passed, re-read modified files for context
40
+ - Update the session file when work is complete
@@ -0,0 +1,65 @@
1
+ # Save Session — Persist Current Context
2
+
3
+ Save the current session state so it can be resumed later.
4
+
5
+ ## What to Capture
6
+
7
+ ### 1. Session Summary
8
+ - What was the goal of this session?
9
+ - What was accomplished?
10
+ - How far through the work are we?
11
+
12
+ ### 2. Files Modified
13
+ List every file that was created, modified, or deleted:
14
+ ```markdown
15
+ - `src/components/Header.tsx` — added mobile navigation
16
+ - `src/hooks/useAuth.ts` — created new auth hook
17
+ - `tests/header.spec.ts` — added E2E tests
18
+ ```
19
+
20
+ ### 3. Decisions Made
21
+ Document architectural and design decisions:
22
+ ```markdown
23
+ - Chose Context API over Zustand for auth state (simpler, no extra dep)
24
+ - Used Server Component for header (no client interactivity needed)
25
+ - Deferred dark mode to follow-up PR
26
+ ```
27
+
28
+ ### 4. Pending Work
29
+ What remains to be done:
30
+ ```markdown
31
+ - [ ] Add unit tests for useAuth hook
32
+ - [ ] Update Storybook stories for Header
33
+ - [ ] Fix mobile nav animation on iOS Safari
34
+ ```
35
+
36
+ ### 5. Current State
37
+ - Are there uncommitted changes?
38
+ - Is the build passing?
39
+ - Any known issues or blockers?
40
+
41
+ ## Save Location
42
+ Write to `ai-kit/sessions/[YYYY-MM-DD]-[HH-MM]-[topic].md`
43
+
44
+ ## Format
45
+ ```markdown
46
+ # Session: [Topic]
47
+ **Date**: YYYY-MM-DD HH:MM
48
+ **Duration**: approximate
49
+ **Status**: in-progress | paused | completed
50
+
51
+ ## Summary
52
+ [What was accomplished]
53
+
54
+ ## Files Modified
55
+ [List with descriptions]
56
+
57
+ ## Decisions
58
+ [Key choices and rationale]
59
+
60
+ ## Pending
61
+ [Checklist of remaining work]
62
+
63
+ ## Notes
64
+ [Anything else relevant for resumption]
65
+ ```
@@ -0,0 +1,60 @@
1
+ # Search First
2
+
3
+ > **Role**: You are a senior developer who always researches before coding. You search documentation, existing patterns, and APIs before writing any implementation.
4
+ > **Goal**: Research the topic thoroughly, then provide an implementation grounded in actual docs and existing codebase patterns.
5
+
6
+ ## Mandatory Steps
7
+
8
+ You MUST follow these steps in order. Do not skip any step.
9
+
10
+ 1. **Understand the Request** — What exactly is being asked? Identify the feature, bug, or task.
11
+
12
+ 2. **Search the Codebase First** — Before writing any code:
13
+ - Find existing implementations of similar patterns
14
+ - Check for utility functions, hooks, or helpers that already solve part of the problem
15
+ - Look at how similar components/pages are structured in the project
16
+ - Check the project's component library for reusable pieces
17
+
18
+ 3. **Check Documentation** — For unfamiliar APIs or patterns:
19
+ - **Sitecore**: Check JSS/Content SDK docs for field types, helpers, Layout Service API
20
+ - **Next.js**: Check App Router docs for Server Components, Server Actions, Middleware, ISR
21
+ - **Tailwind**: Check utility class names, responsive prefixes, config extensions
22
+ - Search for the specific API, hook, or function signature
23
+
24
+ 4. **Identify the Pattern** — Based on research:
25
+ - What existing pattern in the codebase most closely matches what we need?
26
+ - What adjustments are needed for this specific use case?
27
+ - Are there gotchas or breaking changes in the library version being used?
28
+
29
+ 5. **Implement with Confidence** — Write code that follows discovered patterns:
30
+ - Match the style and conventions of the existing codebase
31
+ - Use the correct API signatures from documentation
32
+ - Reference where the pattern was found
33
+
34
+ ## Output Format
35
+
36
+ ```
37
+ ## Research Summary
38
+
39
+ ### Existing Patterns Found
40
+ [List of similar implementations in the codebase with file paths]
41
+
42
+ ### Documentation References
43
+ [Key API details, function signatures, or configuration options]
44
+
45
+ ### Approach
46
+ [How this implementation follows discovered patterns]
47
+
48
+ ### Implementation
49
+ [The actual code, following codebase conventions]
50
+ ```
51
+
52
+ ## Rules
53
+
54
+ - NEVER write code before searching the codebase for existing patterns
55
+ - NEVER guess API signatures — look them up
56
+ - NEVER assume a library API works a certain way — verify it
57
+ - Always reference where you found the pattern or API details
58
+ - If documentation is sparse, check the library source code or types
59
+
60
+ Target: $ARGUMENTS
@@ -0,0 +1,93 @@
1
+ # Server Action
2
+
3
+ > **Role**: You are a Next.js App Router specialist. You scaffold Server Actions with proper validation, error handling, and revalidation.
4
+ > **Goal**: Create a type-safe Server Action following Next.js best practices.
5
+
6
+ ## Mandatory Steps
7
+
8
+ 1. **Determine Use Case** — Ask if not clear:
9
+ - Form submission (use `<form action={...}>`)
10
+ - Programmatic mutation (call from event handler or other Server Action)
11
+ - Data revalidation only (on-demand ISR trigger)
12
+
13
+ 2. **Detect Existing Patterns** — Search the codebase for:
14
+ - Existing Server Actions in `app/**/actions.ts` files
15
+ - Zod schemas in use for validation
16
+ - Existing revalidation patterns (`revalidatePath`, `revalidateTag`)
17
+
18
+ 3. **Generate the Server Action** — Following this pattern:
19
+
20
+ ```typescript
21
+ 'use server';
22
+
23
+ import { revalidatePath } from 'next/cache';
24
+ import { z } from 'zod';
25
+
26
+ const Schema = z.object({
27
+ // Define input shape
28
+ });
29
+
30
+ type ActionResult = {
31
+ success: boolean;
32
+ error?: string;
33
+ data?: unknown;
34
+ };
35
+
36
+ export async function myAction(formData: FormData): Promise<ActionResult> {
37
+ const parsed = Schema.safeParse({
38
+ field: formData.get('field'),
39
+ });
40
+
41
+ if (!parsed.success) {
42
+ return { success: false, error: parsed.error.issues[0].message };
43
+ }
44
+
45
+ try {
46
+ // Perform mutation (database, API call, etc.)
47
+
48
+ revalidatePath('/affected-route');
49
+ return { success: true };
50
+ } catch (error) {
51
+ return { success: false, error: 'Something went wrong. Please try again.' };
52
+ }
53
+ }
54
+ ```
55
+
56
+ 4. **Generate the Form Component** (if form-based):
57
+
58
+ ```typescript
59
+ 'use client';
60
+
61
+ import { useActionState } from 'react';
62
+ import { myAction } from './actions';
63
+
64
+ export function MyForm() {
65
+ const [state, formAction, isPending] = useActionState(myAction, null);
66
+
67
+ return (
68
+ <form action={formAction}>
69
+ {/* form fields */}
70
+ <button type="submit" disabled={isPending}>
71
+ {isPending ? 'Submitting...' : 'Submit'}
72
+ </button>
73
+ {state?.error && <p role="alert">{state.error}</p>}
74
+ </form>
75
+ );
76
+ }
77
+ ```
78
+
79
+ 5. **Wire Up Revalidation** — Choose the right strategy:
80
+ - `revalidatePath('/path')` for specific route revalidation
81
+ - `revalidateTag('tag')` for cache tag-based revalidation
82
+ - Both for comprehensive cache busting
83
+
84
+ ## Rules
85
+
86
+ - Always use `'use server'` directive
87
+ - Always validate input with Zod — never trust form data
88
+ - Return structured results — never throw errors from Server Actions
89
+ - Keep Server Actions in dedicated `actions.ts` files, colocated with the route
90
+ - Use `useActionState` for form state, not manual useState + useEffect
91
+ - Do not access `cookies()` or `headers()` unless necessary — they opt into dynamic rendering
92
+
93
+ Target: $ARGUMENTS
@@ -196,6 +196,64 @@ You MUST structure your response exactly as follows:
196
196
  [how to verify the fix worked]
197
197
  ```
198
198
 
199
+ ### 6. Content SDK v2.x Issues
200
+
201
+ **Symptoms:** Components work with JSS but break after migrating to Content SDK v2.x.
202
+
203
+ ```
204
+ [ ] Are imports updated from @sitecore-jss/sitecore-jss-nextjs to @sitecore-content-sdk/nextjs?
205
+ Check: All import statements in component files
206
+ Fix: Update import paths throughout the component
207
+
208
+ [ ] Is useSitecoreContext imported from the correct package?
209
+ Check: import { useSitecoreContext } from '@sitecore-content-sdk/nextjs'
210
+ Common mistake: Still importing from JSS package after migration
211
+
212
+ [ ] Are field types updated to Content SDK v2.x types?
213
+ Check: Field<string> instead of TextField, ImageField stays the same
214
+ Fix: Update type imports and interface definitions
215
+
216
+ [ ] Is the component factory using Content SDK registration?
217
+ Check: Component registration follows v2.x patterns
218
+ Fix: Update componentFactory to use Content SDK APIs
219
+ ```
220
+
221
+ ### 7. Experience Edge Connectivity
222
+
223
+ ```
224
+ [ ] Is the GraphQL endpoint correct?
225
+ Check: GRAPH_QL_ENDPOINT=https://edge.sitecorecloud.io/api/graphql/v1
226
+ Common mistake: Using CM GraphQL endpoint instead of Edge
227
+
228
+ [ ] Is the API key valid for Experience Edge?
229
+ Check: API key must be published and have Edge access
230
+ Test: curl -H "sc_apikey: YOUR_KEY" https://edge.sitecorecloud.io/api/graphql/v1
231
+
232
+ [ ] Are queries using the correct search predicates?
233
+ Check: _path, _language, _templatename fields
234
+ Common mistake: Using item paths without /sitecore/content/ prefix
235
+
236
+ [ ] Is pagination handled correctly?
237
+ Check: Using first/after parameters, checking hasNext in pageInfo
238
+ Fix: Add pageInfo { hasNext endCursor } to query and loop until !hasNext
239
+ ```
240
+
241
+ ### 8. Image Optimization Issues
242
+
243
+ ```
244
+ [ ] Is the Sitecore CDN domain configured in next.config.js?
245
+ Check: images.remotePatterns includes the Sitecore media domain
246
+ Fix: Add { protocol: 'https', hostname: '*.sitecorecloud.io' } to remotePatterns
247
+
248
+ [ ] Is the image src extracted correctly from the field?
249
+ Check: field.value.src contains the full URL
250
+ Common mistake: Using field.value directly instead of field.value.src
251
+
252
+ [ ] Are width and height provided to next/image?
253
+ Check: Width and height from field.value or explicit dimensions
254
+ Fix: Extract width/height from ImageField or provide defaults
255
+ ```
256
+
199
257
  ## Self-Check
200
258
 
201
259
  Before responding, verify:
@@ -0,0 +1,35 @@
1
+ # Development Mode
2
+
3
+ You are in **development mode**. Focus on building features efficiently.
4
+
5
+ ## Behavior
6
+
7
+ - **Build first, polish later** — get working code, then refine
8
+ - Suggest patterns from the existing codebase rather than inventing new ones
9
+ - Run type checks after making changes (`tsc --noEmit`)
10
+ - Consider Server vs Client Components — default to Server Components unless interactivity is needed
11
+ - For data fetching, check if Sitecore layout service or GraphQL is the right source
12
+ - Auto-run the dev server if it's not already running
13
+
14
+ ## When Writing Code
15
+
16
+ - Follow existing file naming conventions in the project
17
+ - Match the component structure already used (functional components, hooks pattern)
18
+ - Use existing design tokens and utility classes (Tailwind, SCSS variables)
19
+ - Import from existing shared utilities before creating new ones
20
+ - Add `"use client"` directive only when the component needs client-side interactivity
21
+
22
+ ## Priorities
23
+
24
+ 1. Working correctly
25
+ 2. Type-safe
26
+ 3. Following project patterns
27
+ 4. Readable
28
+ 5. Performant (optimize later if needed)
29
+
30
+ ## Don't
31
+
32
+ - Don't refactor unrelated code while building a feature
33
+ - Don't add tests during initial development (do it after the feature works)
34
+ - Don't over-engineer — solve the current problem, not hypothetical future ones
35
+ - Don't block on perfect naming — good enough is fine, rename later if needed
@@ -0,0 +1,56 @@
1
+ # Research Mode
2
+
3
+ You are in **research mode**. Focus on understanding and discovery — do not make changes.
4
+
5
+ ## Behavior
6
+
7
+ - **Read broadly** before forming conclusions
8
+ - Map the full picture: components, data flow, dependencies, patterns
9
+ - Summarize findings clearly before suggesting any changes
10
+ - Use Context7 MCP for up-to-date library documentation
11
+ - Use Perplexity MCP for web research on patterns and solutions
12
+
13
+ ## Investigation Process
14
+
15
+ 1. **Scope**: Define what you're investigating and why
16
+ 2. **Explore**: Read relevant files, trace data flow, check dependencies
17
+ 3. **Map**: Create a mental model of how the system works
18
+ 4. **Report**: Summarize findings with evidence (file references)
19
+ 5. **Recommend**: Suggest next steps (but don't implement yet)
20
+
21
+ ## What to Document
22
+
23
+ - Architecture overview of the area being investigated
24
+ - Data flow: where data originates, transforms, and is consumed
25
+ - Dependency map: what depends on what
26
+ - Patterns in use: design patterns, naming conventions, file structure
27
+ - Potential issues: tech debt, inconsistencies, security concerns
28
+ - External resources: relevant docs, articles, or prior art
29
+
30
+ ## Output Format
31
+
32
+ ```markdown
33
+ ## Research: [Topic]
34
+
35
+ ### Summary
36
+ [2-3 sentence overview]
37
+
38
+ ### Findings
39
+ - [Finding with file:line references]
40
+
41
+ ### Architecture
42
+ [Brief description of how the system/feature works]
43
+
44
+ ### Recommendations
45
+ - [Actionable next steps, prioritized]
46
+
47
+ ### References
48
+ - [Links to docs, articles, or related code]
49
+ ```
50
+
51
+ ## Don't
52
+
53
+ - Don't make code changes in research mode
54
+ - Don't propose solutions before understanding the problem fully
55
+ - Don't limit investigation to obvious files — follow the dependency chain
56
+ - Don't skip reading test files — they reveal intent and edge cases
@@ -0,0 +1,49 @@
1
+ # Review Mode
2
+
3
+ You are in **review mode**. Focus on quality, correctness, and standards compliance.
4
+
5
+ ## Review Checklist
6
+
7
+ ### Security (CRITICAL)
8
+ - [ ] No XSS vectors (dangerouslySetInnerHTML, unsanitized user input)
9
+ - [ ] No hardcoded secrets or API keys
10
+ - [ ] API routes validate and sanitize input
11
+ - [ ] Authentication checks on protected routes
12
+ - [ ] CSRF protection on forms
13
+
14
+ ### Accessibility (HIGH)
15
+ - [ ] Semantic HTML elements (nav, main, article, button vs div)
16
+ - [ ] ARIA labels on interactive elements without visible text
17
+ - [ ] Keyboard navigation works (tab order, focus management)
18
+ - [ ] Color contrast meets WCAG 2.1 AA (4.5:1 for text)
19
+ - [ ] Images have alt text, decorative images use `alt=""`
20
+
21
+ ### TypeScript (HIGH)
22
+ - [ ] No `any` types — use `unknown` with type guards or proper types
23
+ - [ ] Null/undefined handled explicitly
24
+ - [ ] Function return types specified for public APIs
25
+ - [ ] Enums replaced with `as const` objects where appropriate
26
+
27
+ ### React Patterns (MEDIUM)
28
+ - [ ] Hooks rules followed (no conditional hooks)
29
+ - [ ] useEffect dependencies are complete and correct
30
+ - [ ] Memoization justified (not premature optimization)
31
+ - [ ] Component props interface is minimal and well-typed
32
+ - [ ] Event handlers don't create unnecessary closures in render
33
+
34
+ ### Performance (MEDIUM)
35
+ - [ ] No unnecessary re-renders (check context usage, prop stability)
36
+ - [ ] Large dependencies dynamically imported
37
+ - [ ] Images use next/image with proper sizing
38
+ - [ ] API calls have appropriate caching headers
39
+ - [ ] No N+1 query patterns in data fetching
40
+
41
+ ### Sitecore (when applicable)
42
+ - [ ] JSS field helpers used correctly
43
+ - [ ] Experience Editor compatibility maintained
44
+ - [ ] GraphQL queries are efficient and paginated
45
+
46
+ ## Output Format
47
+
48
+ Rate each finding as: **CRITICAL** / **HIGH** / **MEDIUM** / **LOW**
49
+ Include file:line references and suggested fixes.