@nextsparkjs/ai-workflow 0.1.0-beta.100
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/LICENSE +21 -0
- package/README.md +115 -0
- package/claude/_docs/workflows-optimizations.md +359 -0
- package/claude/agents/api-tester.md +634 -0
- package/claude/agents/architecture-supervisor.md +1351 -0
- package/claude/agents/backend-developer.md +997 -0
- package/claude/agents/backend-validator.md +417 -0
- package/claude/agents/bdd-docs-writer.md +737 -0
- package/claude/agents/block-developer.md +677 -0
- package/claude/agents/code-reviewer.md +1432 -0
- package/claude/agents/db-developer.md +721 -0
- package/claude/agents/db-validator.md +407 -0
- package/claude/agents/demo-video-generator.md +493 -0
- package/claude/agents/documentation-writer.md +1268 -0
- package/claude/agents/frontend-developer.md +1234 -0
- package/claude/agents/frontend-validator.md +777 -0
- package/claude/agents/functional-validator.md +630 -0
- package/claude/agents/mock-analyst.md +387 -0
- package/claude/agents/product-manager.md +963 -0
- package/claude/agents/qa-automation.md +1762 -0
- package/claude/agents/release-manager.md +634 -0
- package/claude/agents/selectors-translator.md +262 -0
- package/claude/agents/unit-test-writer.md +785 -0
- package/claude/agents/visual-comparator.md +329 -0
- package/claude/agents/workflow-maintainer.md +352 -0
- package/claude/commands/do/README.md +88 -0
- package/claude/commands/do/create-api.md +64 -0
- package/claude/commands/do/create-entity.md +66 -0
- package/claude/commands/do/create-migration.md +64 -0
- package/claude/commands/do/create-plugin.md +56 -0
- package/claude/commands/do/create-theme.md +70 -0
- package/claude/commands/do/mock-data.md +67 -0
- package/claude/commands/do/reset-db.md +71 -0
- package/claude/commands/do/setup-scheduled-action.md +75 -0
- package/claude/commands/do/sync-code-review.md +117 -0
- package/claude/commands/do/update-selectors.md +112 -0
- package/claude/commands/do/use-skills.md +90 -0
- package/claude/commands/do/validate-blocks.md +69 -0
- package/claude/commands/how-to/README.md +261 -0
- package/claude/commands/how-to/add-metadata.md +692 -0
- package/claude/commands/how-to/add-taxonomies.md +806 -0
- package/claude/commands/how-to/add-translations.md +571 -0
- package/claude/commands/how-to/create-api.md +577 -0
- package/claude/commands/how-to/create-block.md +575 -0
- package/claude/commands/how-to/create-child-entities.md +771 -0
- package/claude/commands/how-to/create-entity.md +597 -0
- package/claude/commands/how-to/create-migrations.md +605 -0
- package/claude/commands/how-to/create-plugin.md +654 -0
- package/claude/commands/how-to/customize-app.md +481 -0
- package/claude/commands/how-to/customize-dashboard.md +553 -0
- package/claude/commands/how-to/customize-theme.md +438 -0
- package/claude/commands/how-to/define-features-flows.md +632 -0
- package/claude/commands/how-to/deploy.md +507 -0
- package/claude/commands/how-to/handle-file-uploads.md +746 -0
- package/claude/commands/how-to/implement-search.md +1001 -0
- package/claude/commands/how-to/install-plugins.md +352 -0
- package/claude/commands/how-to/manage-test-coverage.md +984 -0
- package/claude/commands/how-to/run-tests.md +400 -0
- package/claude/commands/how-to/set-app-languages.md +601 -0
- package/claude/commands/how-to/set-plans-and-permissions.md +575 -0
- package/claude/commands/how-to/set-scheduled-actions.md +527 -0
- package/claude/commands/how-to/set-user-roles-and-permissions.md +550 -0
- package/claude/commands/how-to/setup-authentication.md +388 -0
- package/claude/commands/how-to/setup-claude-code.md +440 -0
- package/claude/commands/how-to/setup-database.md +274 -0
- package/claude/commands/how-to/setup-email-providers.md +598 -0
- package/claude/commands/how-to/setup-mobile-dev.md +627 -0
- package/claude/commands/how-to/start.md +500 -0
- package/claude/commands/how-to/use-devtools.md +639 -0
- package/claude/commands/how-to/use-superadmin.md +622 -0
- package/claude/commands/session/README.md +193 -0
- package/claude/commands/session/block-create.md +190 -0
- package/claude/commands/session/block-list.md +203 -0
- package/claude/commands/session/block-update.md +192 -0
- package/claude/commands/session/block-validate.md +218 -0
- package/claude/commands/session/changelog.md +115 -0
- package/claude/commands/session/close.md +225 -0
- package/claude/commands/session/commit.md +174 -0
- package/claude/commands/session/db-entity.md +206 -0
- package/claude/commands/session/db-fix.md +212 -0
- package/claude/commands/session/db-sample.md +206 -0
- package/claude/commands/session/demo.md +178 -0
- package/claude/commands/session/doc-bdd.md +207 -0
- package/claude/commands/session/doc-feature.md +218 -0
- package/claude/commands/session/doc-read.md +225 -0
- package/claude/commands/session/execute.md +204 -0
- package/claude/commands/session/explain.md +202 -0
- package/claude/commands/session/fix-bug.md +210 -0
- package/claude/commands/session/fix-build.md +182 -0
- package/claude/commands/session/fix-test.md +189 -0
- package/claude/commands/session/pending.md +232 -0
- package/claude/commands/session/refine.md +188 -0
- package/claude/commands/session/resume.md +192 -0
- package/claude/commands/session/review.md +192 -0
- package/claude/commands/session/scope-change.md +181 -0
- package/claude/commands/session/start-blocks.md +347 -0
- package/claude/commands/session/start.md +604 -0
- package/claude/commands/session/status.md +169 -0
- package/claude/commands/session/test-fix.md +221 -0
- package/claude/commands/session/test-run.md +203 -0
- package/claude/commands/session/test-write.md +242 -0
- package/claude/commands/session/validate.md +162 -0
- package/claude/config/context.json +40 -0
- package/claude/config/github.json +69 -0
- package/claude/config/github.schema.json +106 -0
- package/claude/config/team.json +46 -0
- package/claude/config/team.schema.json +106 -0
- package/claude/config/workspace.json +43 -0
- package/claude/config/workspace.schema.json +75 -0
- package/claude/skills/README.md +228 -0
- package/claude/skills/accessibility/SKILL.md +573 -0
- package/claude/skills/api-bypass-layers/SKILL.md +550 -0
- package/claude/skills/asana-integration/SKILL.md +499 -0
- package/claude/skills/better-auth/SKILL.md +666 -0
- package/claude/skills/billing-subscriptions/SKILL.md +660 -0
- package/claude/skills/block-decision-matrix/SKILL.md +359 -0
- package/claude/skills/clickup-integration/SKILL.md +434 -0
- package/claude/skills/core-theme-responsibilities/SKILL.md +485 -0
- package/claude/skills/create-plugin/SKILL.md +425 -0
- package/claude/skills/create-theme/SKILL.md +331 -0
- package/claude/skills/cypress-api/SKILL.md +511 -0
- package/claude/skills/cypress-api/scripts/generate-api-controller.py +329 -0
- package/claude/skills/cypress-api/scripts/generate-api-test.py +930 -0
- package/claude/skills/cypress-e2e/SKILL.md +526 -0
- package/claude/skills/cypress-e2e/scripts/extract-selectors.py +383 -0
- package/claude/skills/cypress-e2e/scripts/generate-uat-test.py +788 -0
- package/claude/skills/cypress-selectors/SKILL.md +309 -0
- package/claude/skills/cypress-selectors/scripts/extract-missing.py +243 -0
- package/claude/skills/cypress-selectors/scripts/generate-block-selectors.py +283 -0
- package/claude/skills/cypress-selectors/scripts/validate-selectors.py +145 -0
- package/claude/skills/database-migrations/SKILL.md +335 -0
- package/claude/skills/database-migrations/scripts/generate-sample-data.py +284 -0
- package/claude/skills/database-migrations/scripts/validate-migration.py +323 -0
- package/claude/skills/design-system/SKILL.md +682 -0
- package/claude/skills/documentation/SKILL.md +540 -0
- package/claude/skills/entity-api/SKILL.md +482 -0
- package/claude/skills/entity-system/SKILL.md +635 -0
- package/claude/skills/entity-system/scripts/generate-child-migration.py +298 -0
- package/claude/skills/entity-system/scripts/generate-metas-migration.py +233 -0
- package/claude/skills/entity-system/scripts/generate-migration.py +382 -0
- package/claude/skills/entity-system/scripts/generate-sample-data.py +418 -0
- package/claude/skills/entity-system/scripts/scaffold-entity.py +661 -0
- package/claude/skills/github/SKILL.md +467 -0
- package/claude/skills/i18n-nextintl/SKILL.md +302 -0
- package/claude/skills/i18n-nextintl/scripts/add-translation.py +243 -0
- package/claude/skills/i18n-nextintl/scripts/extract-hardcoded.py +246 -0
- package/claude/skills/i18n-nextintl/scripts/validate-translations.py +260 -0
- package/claude/skills/impact-analysis/SKILL.md +203 -0
- package/claude/skills/jest-unit/SKILL.md +306 -0
- package/claude/skills/jest-unit/references/component-testing.md +371 -0
- package/claude/skills/jest-unit/references/mocking-patterns.md +380 -0
- package/claude/skills/jest-unit/references/service-hook-testing.md +454 -0
- package/claude/skills/jira-integration/SKILL.md +539 -0
- package/claude/skills/media-library/SKILL.md +743 -0
- package/claude/skills/mock-analysis/SKILL.md +276 -0
- package/claude/skills/monorepo-architecture/SKILL.md +162 -0
- package/claude/skills/nextjs-api-development/SKILL.md +364 -0
- package/claude/skills/nextjs-api-development/scripts/generate-crud-tests.py +456 -0
- package/claude/skills/nextjs-api-development/scripts/scaffold-endpoint.py +481 -0
- package/claude/skills/nextjs-api-development/scripts/validate-api.py +283 -0
- package/claude/skills/notion-integration/SKILL.md +641 -0
- package/claude/skills/npm-development-workflow/SKILL.md +480 -0
- package/claude/skills/page-builder-blocks/SKILL.md +530 -0
- package/claude/skills/page-builder-blocks/scripts/scaffold-block.py +444 -0
- package/claude/skills/permissions-system/SKILL.md +619 -0
- package/claude/skills/plugins/SKILL.md +340 -0
- package/claude/skills/plugins/references/plugin-templates.md +414 -0
- package/claude/skills/plugins/references/plugin-testing.md +353 -0
- package/claude/skills/plugins/references/plugin-types.md +198 -0
- package/claude/skills/plugins/scripts/scaffold-plugin.py +443 -0
- package/claude/skills/pom-patterns/SKILL.md +452 -0
- package/claude/skills/pom-patterns/scripts/generate-pom.py +392 -0
- package/claude/skills/rate-limiting/SKILL.md +342 -0
- package/claude/skills/react-best-practices/AGENTS.md +2410 -0
- package/claude/skills/react-best-practices/README.md +123 -0
- package/claude/skills/react-best-practices/SKILL.md +125 -0
- package/claude/skills/react-best-practices/metadata.json +15 -0
- package/claude/skills/react-best-practices/rules/_sections.md +46 -0
- package/claude/skills/react-best-practices/rules/_template.md +28 -0
- package/claude/skills/react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/claude/skills/react-best-practices/rules/advanced-use-latest.md +49 -0
- package/claude/skills/react-best-practices/rules/async-api-routes.md +38 -0
- package/claude/skills/react-best-practices/rules/async-defer-await.md +80 -0
- package/claude/skills/react-best-practices/rules/async-dependencies.md +36 -0
- package/claude/skills/react-best-practices/rules/async-parallel.md +28 -0
- package/claude/skills/react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/claude/skills/react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/claude/skills/react-best-practices/rules/bundle-conditional.md +31 -0
- package/claude/skills/react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/claude/skills/react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/claude/skills/react-best-practices/rules/bundle-preload.md +50 -0
- package/claude/skills/react-best-practices/rules/client-event-listeners.md +74 -0
- package/claude/skills/react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/claude/skills/react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/claude/skills/react-best-practices/rules/client-swr-dedup.md +56 -0
- package/claude/skills/react-best-practices/rules/js-batch-dom-css.md +82 -0
- package/claude/skills/react-best-practices/rules/js-cache-function-results.md +80 -0
- package/claude/skills/react-best-practices/rules/js-cache-property-access.md +28 -0
- package/claude/skills/react-best-practices/rules/js-cache-storage.md +70 -0
- package/claude/skills/react-best-practices/rules/js-combine-iterations.md +32 -0
- package/claude/skills/react-best-practices/rules/js-early-exit.md +50 -0
- package/claude/skills/react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/claude/skills/react-best-practices/rules/js-index-maps.md +37 -0
- package/claude/skills/react-best-practices/rules/js-length-check-first.md +49 -0
- package/claude/skills/react-best-practices/rules/js-min-max-loop.md +82 -0
- package/claude/skills/react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/claude/skills/react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/claude/skills/react-best-practices/rules/rendering-activity.md +26 -0
- package/claude/skills/react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/claude/skills/react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/claude/skills/react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/claude/skills/react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/claude/skills/react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/claude/skills/react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/claude/skills/react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/claude/skills/react-best-practices/rules/rerender-dependencies.md +45 -0
- package/claude/skills/react-best-practices/rules/rerender-derived-state.md +29 -0
- package/claude/skills/react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/claude/skills/react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/claude/skills/react-best-practices/rules/rerender-memo.md +44 -0
- package/claude/skills/react-best-practices/rules/rerender-transitions.md +40 -0
- package/claude/skills/react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/claude/skills/react-best-practices/rules/server-cache-lru.md +41 -0
- package/claude/skills/react-best-practices/rules/server-cache-react.md +76 -0
- package/claude/skills/react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/claude/skills/react-best-practices/rules/server-serialization.md +38 -0
- package/claude/skills/react-patterns/SKILL.md +688 -0
- package/claude/skills/registry-system/SKILL.md +331 -0
- package/claude/skills/scheduled-actions/SKILL.md +671 -0
- package/claude/skills/scope-enforcement/SKILL.md +542 -0
- package/claude/skills/scope-enforcement/scripts/validate-scope.py +357 -0
- package/claude/skills/server-actions/SKILL.md +493 -0
- package/claude/skills/service-layer/SKILL.md +587 -0
- package/claude/skills/session-management/SKILL.md +266 -0
- package/claude/skills/session-management/scripts/create-session.py +166 -0
- package/claude/skills/session-management/scripts/iteration-close.sh +105 -0
- package/claude/skills/session-management/scripts/iteration-init.sh +180 -0
- package/claude/skills/session-management/scripts/session-archive.sh +87 -0
- package/claude/skills/session-management/scripts/session-close.sh +133 -0
- package/claude/skills/session-management/scripts/session-init.sh +225 -0
- package/claude/skills/session-management/scripts/session-list.sh +163 -0
- package/claude/skills/session-management/scripts/split-plan.sh +116 -0
- package/claude/skills/shadcn-components/SKILL.md +586 -0
- package/claude/skills/shadcn-theming/SKILL.md +446 -0
- package/claude/skills/suspense-loading/SKILL.md +280 -0
- package/claude/skills/tailwind-theming/SKILL.md +507 -0
- package/claude/skills/tanstack-query/SKILL.md +608 -0
- package/claude/skills/test-coverage/SKILL.md +239 -0
- package/claude/skills/web-design-guidelines/SKILL.md +39 -0
- package/claude/skills/zod-validation/SKILL.md +537 -0
- package/claude/templates/blocks/progress.md +86 -0
- package/claude/templates/iteration/changes.md +61 -0
- package/claude/templates/iteration/progress.md +55 -0
- package/claude/templates/log.md +31 -0
- package/claude/templates/story/context.md +77 -0
- package/claude/templates/story/pendings.md +37 -0
- package/claude/templates/story/plan.md +299 -0
- package/claude/templates/story/requirements.md +109 -0
- package/claude/templates/story/scope.json +10 -0
- package/claude/templates/story/tests.md +91 -0
- package/claude/templates/task/progress.md +58 -0
- package/claude/templates/task/requirements.md +54 -0
- package/claude/workflows/README.md +154 -0
- package/claude/workflows/blocks.md +614 -0
- package/claude/workflows/story.md +1207 -0
- package/claude/workflows/task.md +927 -0
- package/claude/workflows/tweak.md +527 -0
- package/cursor/.gitkeep +0 -0
- package/package.json +35 -0
- package/scripts/postinstall.mjs +198 -0
- package/scripts/setup.mjs +282 -0
- package/scripts/sync.mjs +209 -0
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: npm-development-workflow
|
|
3
|
+
description: |
|
|
4
|
+
CRITICAL workflow for developing and testing NextSpark in dual-mode: monorepo AND npm.
|
|
5
|
+
ALL changes MUST be validated in both environments before publishing.
|
|
6
|
+
Defines the exact methodology, commands, and validation steps.
|
|
7
|
+
allowed-tools: Bash, Read, Write, Edit, Glob, Grep
|
|
8
|
+
version: "1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# NPM Development Workflow
|
|
12
|
+
|
|
13
|
+
## GOLDEN RULE
|
|
14
|
+
|
|
15
|
+
> **EVERY change to core packages MUST be tested in BOTH modes before publishing.**
|
|
16
|
+
> - Monorepo mode: `/repo` (port 5173)
|
|
17
|
+
> - npm mode: `/projects/my-app` (port 3000)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Philosophy: Root Cause Analysis
|
|
22
|
+
|
|
23
|
+
> **NOTHING in core is sacred. Challenge the status quo.**
|
|
24
|
+
>
|
|
25
|
+
> If you find disconnected systems, incoherent patterns, or code not designed for npm distribution,
|
|
26
|
+
> **propose architectural changes**. Quality and professionalism over legacy code preservation.
|
|
27
|
+
|
|
28
|
+
### The 7-Question Framework
|
|
29
|
+
|
|
30
|
+
Before fixing ANY issue, ask:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
1. What is the SYMPTOM? (error message, behavior)
|
|
34
|
+
2. What is the IMMEDIATE cause? (the line that fails)
|
|
35
|
+
3. What is the ROOT cause? (why does that code exist/fail?)
|
|
36
|
+
4. Does this affect monorepo mode? npm mode? Both?
|
|
37
|
+
5. Will my fix work in BOTH modes?
|
|
38
|
+
6. Is this a DESIGN FLAW in core? (disconnected systems, missing abstraction, wrong assumptions)
|
|
39
|
+
7. Should we FIX THE DESIGN instead of patching the symptom?
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Questioning Core Design
|
|
43
|
+
|
|
44
|
+
**When you find a bug, ask yourself:**
|
|
45
|
+
|
|
46
|
+
| Question | If YES → Action |
|
|
47
|
+
|----------|-----------------|
|
|
48
|
+
| Are there TWO systems doing the same thing? | **Unify them** - One source of truth |
|
|
49
|
+
| Does this code assume monorepo-only execution? | **Redesign for npm** - npm users are priority |
|
|
50
|
+
| Is there a "clever" workaround that's fragile? | **Replace with explicit solution** |
|
|
51
|
+
| Does fixing this require touching 5+ files? | **The abstraction is wrong** - Refactor first |
|
|
52
|
+
| Will this fix break if someone changes X? | **Make it robust** - Don't create time bombs |
|
|
53
|
+
| Is there duplicated logic across client/server? | **Create shared module** with proper boundaries |
|
|
54
|
+
|
|
55
|
+
### Real Example: Entity Registry Issue
|
|
56
|
+
|
|
57
|
+
**Symptom:** `Entity not found` in API routes (npm mode only)
|
|
58
|
+
|
|
59
|
+
**Bad approach (patch):**
|
|
60
|
+
```typescript
|
|
61
|
+
// Just add a try-catch and fallback
|
|
62
|
+
try {
|
|
63
|
+
return entityRegistry.get(slug)
|
|
64
|
+
} catch {
|
|
65
|
+
return null // Hide the problem
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Good approach (question the design):**
|
|
70
|
+
```
|
|
71
|
+
Q: Why does this fail in npm mode?
|
|
72
|
+
A: There are TWO registry systems that don't sync.
|
|
73
|
+
|
|
74
|
+
Q: Why are there two systems?
|
|
75
|
+
A: Historical accident - one was added for client, one for server.
|
|
76
|
+
|
|
77
|
+
Q: Is this a design flaw?
|
|
78
|
+
A: YES - violates single source of truth.
|
|
79
|
+
|
|
80
|
+
SOLUTION: Unify into ONE system with FACADE pattern.
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Result:** EntityRegistry became a facade that delegates to the singleton.
|
|
84
|
+
Problem solved at the root, not patched.
|
|
85
|
+
|
|
86
|
+
### Priority Order for Changes
|
|
87
|
+
|
|
88
|
+
When designing solutions, prioritize in this order:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
1. npm mode user experience (they can't debug our code)
|
|
92
|
+
2. Security (no exposed internals, no unsafe patterns)
|
|
93
|
+
3. Performance (bundle size, runtime efficiency)
|
|
94
|
+
4. Developer experience (clear errors, good types)
|
|
95
|
+
5. Monorepo convenience (last priority - we can work around issues)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Signs of Design Problems to Challenge
|
|
99
|
+
|
|
100
|
+
| Pattern You Find | What It Indicates | Action |
|
|
101
|
+
|------------------|-------------------|--------|
|
|
102
|
+
| `require()` in client code | Server/client boundary violation | Restructure module |
|
|
103
|
+
| Multiple registries for same data | Accidental complexity | Unify systems |
|
|
104
|
+
| Webpack aliases in runtime | Monorepo-only thinking | Use explicit imports |
|
|
105
|
+
| "Works in dev, fails in prod" | Missing abstraction | Design for production first |
|
|
106
|
+
| Complex initialization order | Implicit dependencies | Make dependencies explicit |
|
|
107
|
+
| `if (process.env.NODE_ENV)` everywhere | Missing proper configuration | Create config system |
|
|
108
|
+
| Duplicated types across packages | Missing shared types package | Centralize types |
|
|
109
|
+
| "Magic" that's hard to trace | Over-engineering | Simplify ruthlessly |
|
|
110
|
+
|
|
111
|
+
### Common Root Causes in Dual-Mode Systems
|
|
112
|
+
|
|
113
|
+
| Symptom | Immediate Cause | Root Cause (Question the Design) |
|
|
114
|
+
|---------|-----------------|----------------------------------|
|
|
115
|
+
| `require is not defined` | Using `require()` in browser | **Design flaw:** Client code has server dependencies |
|
|
116
|
+
| `Entity not found` in API | Registry not populated | **Design flaw:** Multiple disconnected registry systems |
|
|
117
|
+
| `Module not found` in npm | Webpack alias not resolved | **Design flaw:** Code assumes build-time resolution |
|
|
118
|
+
| `Context provider missing` | Component outside provider tree | **Design flaw:** Implicit provider assumptions |
|
|
119
|
+
| Hydration mismatch | Server/client render differently | **Design flaw:** Shared state not properly serialized |
|
|
120
|
+
|
|
121
|
+
### Decision Framework
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Can I use dynamic imports? → NO in most cases (breaks npm mode)
|
|
125
|
+
Can I use require()? → ONLY in server-only files with 'import server-only'
|
|
126
|
+
Can I use webpack aliases in runtime code? → NO (won't resolve in npm packages)
|
|
127
|
+
Should I fix just the error? → NO, trace to root cause first
|
|
128
|
+
Should I question if this is a design flaw? → YES, ALWAYS
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### When to Propose Architectural Changes
|
|
132
|
+
|
|
133
|
+
**DO propose changes when:**
|
|
134
|
+
- The same bug class keeps appearing
|
|
135
|
+
- A fix requires "magic" or complex workarounds
|
|
136
|
+
- You need to explain "why" something works a certain way
|
|
137
|
+
- npm mode requires special handling that monorepo doesn't
|
|
138
|
+
- You find yourself adding defensive code for edge cases
|
|
139
|
+
|
|
140
|
+
**Template for proposing changes:**
|
|
141
|
+
|
|
142
|
+
```markdown
|
|
143
|
+
## Proposed Architectural Change
|
|
144
|
+
|
|
145
|
+
### Current State
|
|
146
|
+
[What exists now and why it's problematic]
|
|
147
|
+
|
|
148
|
+
### Root Cause
|
|
149
|
+
[The design decision that led to this problem]
|
|
150
|
+
|
|
151
|
+
### Proposed Solution
|
|
152
|
+
[New architecture that solves the root cause]
|
|
153
|
+
|
|
154
|
+
### Migration Path
|
|
155
|
+
[How to get from current to proposed]
|
|
156
|
+
|
|
157
|
+
### Validation
|
|
158
|
+
[How to verify in both monorepo and npm modes]
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Environment Setup
|
|
164
|
+
|
|
165
|
+
### Directory Structure
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
nextspark/
|
|
169
|
+
├── repo/ # Monorepo (development)
|
|
170
|
+
│ ├── packages/
|
|
171
|
+
│ │ ├── core/ # @nextsparkjs/core
|
|
172
|
+
│ │ ├── cli/ # @nextsparkjs/cli
|
|
173
|
+
│ │ └── create-nextspark-app/
|
|
174
|
+
│ ├── themes/ # @nextsparkjs/theme-*
|
|
175
|
+
│ ├── plugins/ # @nextsparkjs/plugin-*
|
|
176
|
+
│ ├── apps/dev/ # Development app
|
|
177
|
+
│ └── .packages/ # Packed .tgz files
|
|
178
|
+
│
|
|
179
|
+
└── projects/
|
|
180
|
+
└── my-app/ # npm mode test project
|
|
181
|
+
├── .packages/ # Local .tgz files
|
|
182
|
+
└── package.json # file: references to .packages/
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Ports
|
|
186
|
+
|
|
187
|
+
| Environment | Port | URL |
|
|
188
|
+
|-------------|------|-----|
|
|
189
|
+
| Monorepo (`repo/`) | 5173 | http://localhost:5173 |
|
|
190
|
+
| npm mode (`projects/my-app/`) | 3000 | http://localhost:3000 |
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Development Workflow
|
|
195
|
+
|
|
196
|
+
### Phase 1: Develop in Monorepo
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
cd repo
|
|
200
|
+
|
|
201
|
+
# Make changes to packages/core, packages/cli, themes/, plugins/
|
|
202
|
+
# ...
|
|
203
|
+
|
|
204
|
+
# Start dev server
|
|
205
|
+
pnpm dev
|
|
206
|
+
|
|
207
|
+
# Test at http://localhost:5173
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Phase 2: Validate in Monorepo
|
|
211
|
+
|
|
212
|
+
Before moving to npm mode, verify:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# 1. TypeScript compiles
|
|
216
|
+
pnpm tsc --noEmit
|
|
217
|
+
|
|
218
|
+
# 2. Build succeeds
|
|
219
|
+
pnpm build
|
|
220
|
+
|
|
221
|
+
# 3. Manual testing checklist:
|
|
222
|
+
# [ ] Server starts without errors
|
|
223
|
+
# [ ] No console errors in browser
|
|
224
|
+
# [ ] API endpoints respond correctly
|
|
225
|
+
# [ ] Dashboard loads entities
|
|
226
|
+
# [ ] CRUD operations work (after login)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Phase 3: Update npm Test Project
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
# ONE COMMAND does everything:
|
|
233
|
+
pnpm setup:update-local
|
|
234
|
+
|
|
235
|
+
# This script:
|
|
236
|
+
# 1. Builds all packages
|
|
237
|
+
# 2. Creates .tgz files in repo/.packages/
|
|
238
|
+
# 3. Copies .tgz to my-app/.packages/
|
|
239
|
+
# 4. Updates my-app/package.json with file: references
|
|
240
|
+
# 5. Cleans .next cache
|
|
241
|
+
# 6. Runs pnpm install --force
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Options:**
|
|
245
|
+
```bash
|
|
246
|
+
pnpm setup:update-local # Full rebuild + update
|
|
247
|
+
pnpm setup:update-local -- --skip-build # Skip rebuild (faster)
|
|
248
|
+
pnpm setup:update-local -- --target ../projects/other-app # Different target
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Phase 4: Validate in npm Mode
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
cd ../projects/my-app
|
|
255
|
+
|
|
256
|
+
# Start dev server
|
|
257
|
+
pnpm dev
|
|
258
|
+
|
|
259
|
+
# Test at http://localhost:3000
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**CRITICAL Validation Checklist:**
|
|
263
|
+
```
|
|
264
|
+
[ ] Server starts without errors
|
|
265
|
+
[ ] No "require is not defined" errors
|
|
266
|
+
[ ] No "Module not found" errors
|
|
267
|
+
[ ] API returns correct responses (not "Entity not found")
|
|
268
|
+
[ ] Dashboard sidebar shows entities
|
|
269
|
+
[ ] CRUD create/edit/delete works
|
|
270
|
+
[ ] No hydration mismatches in console
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Phase 5: Publish (if both pass)
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
cd ../repo
|
|
277
|
+
|
|
278
|
+
# 1. Increment version
|
|
279
|
+
pnpm pkg:version -- patch # or minor, major, beta
|
|
280
|
+
|
|
281
|
+
# 2. Package
|
|
282
|
+
pnpm pkg:pack
|
|
283
|
+
|
|
284
|
+
# 3. Publish
|
|
285
|
+
pnpm pkg:publish -- --tag latest # or --tag beta
|
|
286
|
+
|
|
287
|
+
# 4. Commit
|
|
288
|
+
git add .
|
|
289
|
+
git commit -m "release: vX.Y.Z - description"
|
|
290
|
+
git push
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Quick Reference Commands
|
|
296
|
+
|
|
297
|
+
### From `/repo`:
|
|
298
|
+
|
|
299
|
+
| Command | Purpose |
|
|
300
|
+
|---------|---------|
|
|
301
|
+
| `pnpm dev` | Start monorepo dev server (port 5173) |
|
|
302
|
+
| `pnpm build` | Build monorepo |
|
|
303
|
+
| `pnpm setup:update-local` | **Repackage ALL + update my-app** |
|
|
304
|
+
| `pnpm setup:update-local -- --skip-build` | Repackage without rebuild |
|
|
305
|
+
| `pnpm pkg:version -- patch` | Increment version |
|
|
306
|
+
| `pnpm pkg:pack` | Create .tgz files |
|
|
307
|
+
| `pnpm pkg:publish -- --tag latest` | Publish to npm |
|
|
308
|
+
|
|
309
|
+
### From `/projects/my-app`:
|
|
310
|
+
|
|
311
|
+
| Command | Purpose |
|
|
312
|
+
|---------|---------|
|
|
313
|
+
| `pnpm dev` | Start npm mode dev server (port 3000) |
|
|
314
|
+
| `pnpm build` | Build npm mode project |
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## When to Reset my-app from Scratch
|
|
319
|
+
|
|
320
|
+
Reset the npm test project when:
|
|
321
|
+
|
|
322
|
+
1. **CLI/wizard changes** - The init process itself changed
|
|
323
|
+
2. **Template changes** - Generated files structure changed
|
|
324
|
+
3. **After 3-5 consecutive releases** - Accumulated drift
|
|
325
|
+
4. **Unexplainable npm-only bugs** - Fresh install isolates issues
|
|
326
|
+
|
|
327
|
+
### Reset Command
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
cd ../projects
|
|
331
|
+
rm -rf my-app
|
|
332
|
+
npx --yes create-nextspark-app@latest my-app
|
|
333
|
+
cd my-app
|
|
334
|
+
pnpm nextspark add:theme @nextsparkjs/theme-default
|
|
335
|
+
pnpm dev
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## Debugging Dual-Mode Issues
|
|
341
|
+
|
|
342
|
+
### Issue: Works in monorepo, fails in npm
|
|
343
|
+
|
|
344
|
+
**Diagnosis:**
|
|
345
|
+
```bash
|
|
346
|
+
# Check what's different
|
|
347
|
+
diff repo/packages/core/src/file.ts projects/my-app/node_modules/@nextsparkjs/core/dist/file.js
|
|
348
|
+
|
|
349
|
+
# Check if using runtime aliases
|
|
350
|
+
grep -r "require.*@nextsparkjs" repo/packages/core/src/
|
|
351
|
+
|
|
352
|
+
# Check for 'use client' with server code
|
|
353
|
+
grep -l "'use client'" repo/packages/core/src/**/*.ts | xargs grep -l "require("
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
**Common fixes:**
|
|
357
|
+
1. Move server-only code to files WITHOUT `'use client'`
|
|
358
|
+
2. Replace runtime `require()` with build-time imports
|
|
359
|
+
3. Use dependency injection instead of dynamic resolution
|
|
360
|
+
|
|
361
|
+
### Issue: Registry not populated in npm mode
|
|
362
|
+
|
|
363
|
+
**Root cause:** Multiple registry systems not synchronized
|
|
364
|
+
|
|
365
|
+
**Pattern to follow:**
|
|
366
|
+
```typescript
|
|
367
|
+
// API routes MUST initialize registry
|
|
368
|
+
import { setEntityRegistry, isRegistryInitialized } from '@nextsparkjs/core/lib/entities/queries'
|
|
369
|
+
import { ENTITY_REGISTRY, ENTITY_METADATA } from '@nextsparkjs/registries/entity-registry'
|
|
370
|
+
|
|
371
|
+
if (!isRegistryInitialized()) {
|
|
372
|
+
setEntityRegistry(ENTITY_REGISTRY, ENTITY_METADATA)
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Issue: Different behavior between modes
|
|
377
|
+
|
|
378
|
+
**Diagnosis:**
|
|
379
|
+
```bash
|
|
380
|
+
# Compare installed versions
|
|
381
|
+
cat projects/my-app/node_modules/@nextsparkjs/core/package.json | grep version
|
|
382
|
+
cat repo/packages/core/package.json | grep version
|
|
383
|
+
|
|
384
|
+
# Check if local packages are being used
|
|
385
|
+
cat projects/my-app/package.json | grep "file:"
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## Anti-Patterns
|
|
391
|
+
|
|
392
|
+
| Anti-Pattern | Why It Fails | Correct Approach |
|
|
393
|
+
|--------------|--------------|------------------|
|
|
394
|
+
| Testing only in monorepo | npm mode has different module resolution | ALWAYS test both |
|
|
395
|
+
| Using `require()` in client code | Browser doesn't have `require` | Use ES imports or move to server |
|
|
396
|
+
| Hardcoding webpack aliases | Aliases don't work in pre-compiled packages | Use explicit paths or dependency injection |
|
|
397
|
+
| Fixing symptoms not causes | Creates fragile patches | Trace to root cause first |
|
|
398
|
+
| Publishing without npm test | Breaks users' projects | Run full dual-mode validation |
|
|
399
|
+
| Skipping `.next` cache clear | Stale modules cause confusion | `setup:update-local` does this automatically |
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Validation Checklist (Copy-Paste)
|
|
404
|
+
|
|
405
|
+
Before ANY publish, verify ALL items:
|
|
406
|
+
|
|
407
|
+
```markdown
|
|
408
|
+
## Pre-Publish Checklist
|
|
409
|
+
|
|
410
|
+
### Monorepo (port 5173)
|
|
411
|
+
- [ ] `pnpm tsc --noEmit` passes
|
|
412
|
+
- [ ] `pnpm build` succeeds
|
|
413
|
+
- [ ] Server starts without errors
|
|
414
|
+
- [ ] API endpoints respond correctly
|
|
415
|
+
- [ ] Dashboard loads with entities
|
|
416
|
+
- [ ] CRUD operations work
|
|
417
|
+
|
|
418
|
+
### npm mode (port 3000)
|
|
419
|
+
- [ ] `pnpm setup:update-local` completed
|
|
420
|
+
- [ ] Server starts without errors
|
|
421
|
+
- [ ] No console errors in browser
|
|
422
|
+
- [ ] API endpoints respond correctly (not "Entity not found")
|
|
423
|
+
- [ ] Dashboard loads with entities
|
|
424
|
+
- [ ] CRUD operations work
|
|
425
|
+
- [ ] No hydration mismatches
|
|
426
|
+
|
|
427
|
+
### Ready to publish
|
|
428
|
+
- [ ] Both modes validated
|
|
429
|
+
- [ ] Version incremented: `pnpm pkg:version -- <type>`
|
|
430
|
+
- [ ] Changes committed to git
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## Related Skills
|
|
436
|
+
|
|
437
|
+
- **`monorepo-architecture`** - Package structure and dependencies
|
|
438
|
+
- **`registry-system`** - How registries work
|
|
439
|
+
- **`entity-system`** - Entity configuration
|
|
440
|
+
- **`create-plugin`** - Plugin creation with correct dependencies
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
## Script Reference
|
|
445
|
+
|
|
446
|
+
### `update-local.sh`
|
|
447
|
+
|
|
448
|
+
Location: `repo/scripts/setup/update-local.sh`
|
|
449
|
+
|
|
450
|
+
```bash
|
|
451
|
+
# Usage
|
|
452
|
+
./scripts/setup/update-local.sh [options]
|
|
453
|
+
|
|
454
|
+
# Options
|
|
455
|
+
--target <path> # Target project (default: ../projects/my-app)
|
|
456
|
+
--skip-build # Skip building packages
|
|
457
|
+
--skip-install # Skip pnpm install
|
|
458
|
+
|
|
459
|
+
# What it does
|
|
460
|
+
1. Runs pack.sh --all (build + package)
|
|
461
|
+
2. Copies .tgz to target/.packages/
|
|
462
|
+
3. Updates package.json with file: references
|
|
463
|
+
4. Cleans .next cache
|
|
464
|
+
5. Runs pnpm install --force
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### `pack.sh`
|
|
468
|
+
|
|
469
|
+
Location: `repo/scripts/packages/pack.sh`
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
# Package all
|
|
473
|
+
./scripts/packages/pack.sh --all
|
|
474
|
+
|
|
475
|
+
# Package specific
|
|
476
|
+
./scripts/packages/pack.sh --package core --package cli
|
|
477
|
+
|
|
478
|
+
# Skip rebuild
|
|
479
|
+
./scripts/packages/pack.sh --all --skip-build
|
|
480
|
+
```
|