@polymorphism-tech/morph-spec 9.1.0 → 9.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 (104) hide show
  1. package/CLAUDE.md +14 -78
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +14 -1
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +4 -3
  8. package/framework/MORPH.md +7 -10
  9. package/framework/agents.json +15 -12
  10. package/framework/commands/morph-status.md +2 -2
  11. package/framework/docs/CLI.md +24 -16
  12. package/framework/evals/review-checklist.md +15 -2
  13. package/framework/hooks/README.md +8 -44
  14. package/framework/hooks/claude-code/__pycache__/statusline.cpython-313.pyc +0 -0
  15. package/framework/hooks/claude-code/core/state-sync.js +1 -1
  16. package/framework/hooks/claude-code/core/worktree-context.js +23 -0
  17. package/framework/hooks/claude-code/statusline.py +3 -2
  18. package/framework/hooks/claude-code/statusline.sh +11 -11
  19. package/framework/hooks/shared/gate-event.js +18 -0
  20. package/framework/hooks/shared/next-step.js +107 -0
  21. package/framework/hooks/shared/slice-progress.js +18 -5
  22. package/framework/hooks/shared/state-writer.js +6 -1
  23. package/framework/mcp/registry.json +31 -1
  24. package/framework/rules/nextjs-standards.md +1 -1
  25. package/framework/schemas/feature.schema.json +1 -0
  26. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  27. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  28. package/framework/skills/core/morph-apply/SKILL.md +6 -4
  29. package/framework/skills/core/morph-hotfix/SKILL.md +3 -3
  30. package/framework/skills/core/morph-machine/SKILL.md +1 -1
  31. package/framework/skills/core/morph-media/SKILL.md +1 -1
  32. package/framework/skills/core/morph-plan/SKILL.md +8 -6
  33. package/framework/skills/core/morph-review/SKILL.md +9 -6
  34. package/framework/skills/core/morph-standards/SKILL.md +1 -1
  35. package/framework/skills/core/morph-uiux/SKILL.md +2 -1
  36. package/framework/standards/STANDARDS.json +2 -2
  37. package/framework/standards/STANDARDS.meta.json +1 -1
  38. package/framework/standards/ai-agents/setup.md +2 -0
  39. package/framework/standards/backend/dotnet/testing.md +10 -4
  40. package/framework/standards/frontend/nextjs/testing.md +10 -6
  41. package/framework/standards/integration/mcp/mcp-tools.md +3 -1
  42. package/framework/templates/.idea/morph-templates.xml +92 -0
  43. package/framework/templates/.vscode/morph-templates.code-snippets +186 -0
  44. package/framework/templates/IDE-SNIPPETS.md +262 -262
  45. package/framework/templates/code/dotnet/abstractions/api-endpoint.cs +7 -7
  46. package/framework/templates/code/dotnet/feature/request.cs.hbs +4 -4
  47. package/framework/templates/code/dotnet/feature/response.cs.hbs +4 -4
  48. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +91 -91
  49. package/framework/templates/docs/plan.md +3 -1
  50. package/framework/templates/frontend/nextjs/client-component.tsx.hbs +26 -26
  51. package/framework/templates/frontend/nextjs/feature-form.tsx.hbs +56 -56
  52. package/framework/templates/frontend/nextjs/tsconfig.json.hbs +26 -26
  53. package/framework/templates/infrastructure/docker/Dockerfile.template +58 -58
  54. package/framework/templates/infrastructure/docker/dockerfile-api.dockerfile +38 -38
  55. package/framework/templates/infrastructure/docker/dockerfile-web.dockerfile +48 -48
  56. package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +45 -45
  57. package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +27 -27
  58. package/framework/templates/infrastructure/github/workflows/docker-build-push.yml.hbs +59 -59
  59. package/framework/templates/infrastructure/github/workflows/dotnet-build.yml.hbs +39 -39
  60. package/framework/templates/meta-prompts/fusion/fusion-agent.md +76 -76
  61. package/framework/templates/meta-prompts/fusion/fusion-aggregator.md +100 -100
  62. package/framework/templates/state.template.json +17 -17
  63. package/framework/templates/ui/design-system.css +226 -226
  64. package/package.json +1 -1
  65. package/src/commands/observability/cost.js +12 -0
  66. package/src/commands/project/status.js +6 -68
  67. package/src/commands/state/advance.js +1 -1
  68. package/src/commands/state/approve.js +2 -2
  69. package/src/commands/state/gate-check.js +2 -2
  70. package/src/commands/state/gate-decision.js +4 -1
  71. package/src/commands/state/next.js +24 -0
  72. package/src/commands/state/report-check.js +3 -1
  73. package/src/commands/validation/mutate.js +9 -6
  74. package/src/commands/validation/plan-check.js +4 -2
  75. package/src/commands/validation/tests-audit.js +7 -0
  76. package/src/commands/validation/validate-feature.js +4 -2
  77. package/src/commands/validation/verify.js +21 -16
  78. package/src/core/state/state-manager.js +4 -0
  79. package/src/dashboard/app/main.jsx +13 -13
  80. package/src/dashboard/app/pages/FeatureDetail.jsx +6 -2
  81. package/src/dashboard/scanner/features-scanner.js +5 -2
  82. package/src/dashboard/vite.config.js +24 -24
  83. package/src/lib/ci/workflow-scaffold.js +12 -0
  84. package/src/lib/e2e/applicability.js +37 -0
  85. package/src/lib/generators/handoff-generator.js +11 -25
  86. package/src/lib/mutation/adapters.js +6 -17
  87. package/src/lib/mutation/runner.js +23 -75
  88. package/src/lib/mutation/trx.js +0 -1
  89. package/src/lib/next-step.js +10 -0
  90. package/src/lib/plan/checks.js +29 -2
  91. package/src/lib/plan/plan-parser.js +6 -2
  92. package/src/lib/review-reports.js +6 -3
  93. package/src/lib/risk-detector.js +20 -7
  94. package/src/lib/stack/stack-scan.js +13 -1
  95. package/src/lib/telemetry/metrics.js +46 -0
  96. package/src/lib/tests-audit/audit.js +96 -0
  97. package/src/lib/validators/code-budget/code-budget-validator.js +1 -1
  98. package/src/lib/validators/validation-runner.js +6 -38
  99. package/src/lib/validators/verify-runner.js +37 -22
  100. package/src/utils/agents-installer.js +24 -1
  101. package/framework/hooks/git/commit-msg/conventional-commits.sh +0 -33
  102. package/framework/hooks/git/pre-commit/agents.sh +0 -25
  103. package/framework/hooks/git/pre-commit/orchestrator.sh +0 -64
  104. package/framework/hooks/git/pre-push/run-tests.sh +0 -44
@@ -1,91 +1,91 @@
1
- -- TEMPLATE: pgvector-embeddings-migration.sql
2
- -- PURPOSE: Creates the kb_embeddings table for custom RAG — chunk storage with pgvector.
3
- -- READS STANDARD: ai-agents-rag-custom-pgvector
4
- -- PLACEHOLDERS:
5
- -- {{SCHEMA}} — target schema (default: public)
6
- -- LAST-VERIFIED: 2026-05-19
7
- --
8
- -- PREREQUISITES:
9
- -- - pgvector extension enabled in Neon (see infrastructure-neon-pgvector).
10
- -- - NpgsqlDataSourceBuilder.UseVector() called in the project's DB setup.
11
- --
12
- -- DIMENSION NOTE:
13
- -- embedding vector(1536) matches text-embedding-3-small (default 1536 dimensions).
14
- -- If the project uses a different embedding model, adjust the dimension to match.
15
- -- NEVER mix embedding models on a single column — vectors live in different spaces.
16
-
17
- -- ============================================================
18
- -- 1. EXTENSION
19
- -- ============================================================
20
-
21
- CREATE EXTENSION IF NOT EXISTS vector;
22
-
23
- -- ============================================================
24
- -- 2. TABLE
25
- -- ============================================================
26
-
27
- CREATE TABLE {{SCHEMA}}.kb_embeddings (
28
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
29
- tenant_id uuid NOT NULL,
30
- source text NOT NULL, -- document identifier or source URL
31
- chunk_index int NOT NULL, -- position of this chunk within the source document
32
- content text NOT NULL, -- chunk text returned to the agent as context
33
- embedding vector(1536) NOT NULL, -- vector dimension must match embedding model
34
- metadata jsonb NOT NULL DEFAULT '{}',
35
- created_at timestamptz NOT NULL DEFAULT now()
36
- );
37
-
38
- COMMENT ON TABLE {{SCHEMA}}.kb_embeddings IS 'RAG knowledge base — chunk text and pgvector embeddings for semantic search.';
39
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.tenant_id IS 'Tenant partition. Every query MUST filter on this column. Never query across tenants.';
40
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.source IS 'Document identifier or URL. Used for citation and re-indexing detection.';
41
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.chunk_index IS 'Zero-based position of this chunk within the source document.';
42
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.content IS 'Chunk text returned to the agent. Plain text, no markup.';
43
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.embedding IS 'Float vector. Dimension MUST match the embedding model declared in model-registry.json.';
44
- COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.metadata IS 'Arbitrary JSON metadata (section headers, page numbers, doc type, etc.). Used for filtering.';
45
-
46
- -- ============================================================
47
- -- 3. INDEXES
48
- -- ============================================================
49
-
50
- -- HNSW index for cosine similarity — production-grade recall, no training data required.
51
- -- vector_cosine_ops: use <=> operator (cosine distance, ascending = most similar first).
52
- -- m=16, ef_construction=64 are pgvector defaults. Tune per infrastructure-neon-pgvector §HNSW Parameters.
53
- CREATE INDEX ix_kb_embeddings_hnsw
54
- ON {{SCHEMA}}.kb_embeddings
55
- USING hnsw (embedding vector_cosine_ops)
56
- WITH (m = 16, ef_construction = 64);
57
-
58
- -- Index for the mandatory tenant_id filter (applied in every search query).
59
- CREATE INDEX ix_kb_embeddings_tenant
60
- ON {{SCHEMA}}.kb_embeddings (tenant_id);
61
-
62
- -- Composite index for source-level operations (re-indexing, deletion by document).
63
- CREATE INDEX ix_kb_embeddings_source
64
- ON {{SCHEMA}}.kb_embeddings (tenant_id, source);
65
-
66
- -- ============================================================
67
- -- 4. ROW-LEVEL SECURITY (multi-tenant)
68
- -- ============================================================
69
-
70
- -- RLS enforces tenant isolation at the database level as a second line of defence.
71
- -- The application already filters on tenant_id in every query; RLS is the backstop.
72
- --
73
- -- See templates/code/sql/postgresql-rls-policy.sql for the policy pattern that
74
- -- binds app.current_tenant_id (a session-level setting) to the RLS policy.
75
- --
76
- -- Uncomment and adapt once RLS is wired in the project:
77
- --
78
- -- ALTER TABLE {{SCHEMA}}.kb_embeddings ENABLE ROW LEVEL SECURITY;
79
- --
80
- -- CREATE POLICY kb_embeddings_tenant_isolation
81
- -- ON {{SCHEMA}}.kb_embeddings
82
- -- USING (tenant_id = current_setting('app.current_tenant_id')::uuid);
83
-
84
- -- ============================================================
85
- -- ROLLBACK
86
- -- ============================================================
87
-
88
- -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_hnsw;
89
- -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_tenant;
90
- -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_source;
91
- -- DROP TABLE IF EXISTS {{SCHEMA}}.kb_embeddings CASCADE;
1
+ -- TEMPLATE: pgvector-embeddings-migration.sql
2
+ -- PURPOSE: Creates the kb_embeddings table for custom RAG — chunk storage with pgvector.
3
+ -- READS STANDARD: ai-agents-rag-custom-pgvector
4
+ -- PLACEHOLDERS:
5
+ -- {{SCHEMA}} — target schema (default: public)
6
+ -- LAST-VERIFIED: 2026-05-19
7
+ --
8
+ -- PREREQUISITES:
9
+ -- - pgvector extension enabled in Neon (see infrastructure-neon-pgvector).
10
+ -- - NpgsqlDataSourceBuilder.UseVector() called in the project's DB setup.
11
+ --
12
+ -- DIMENSION NOTE:
13
+ -- embedding vector(1536) matches text-embedding-3-small (default 1536 dimensions).
14
+ -- If the project uses a different embedding model, adjust the dimension to match.
15
+ -- NEVER mix embedding models on a single column — vectors live in different spaces.
16
+
17
+ -- ============================================================
18
+ -- 1. EXTENSION
19
+ -- ============================================================
20
+
21
+ CREATE EXTENSION IF NOT EXISTS vector;
22
+
23
+ -- ============================================================
24
+ -- 2. TABLE
25
+ -- ============================================================
26
+
27
+ CREATE TABLE {{SCHEMA}}.kb_embeddings (
28
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
29
+ tenant_id uuid NOT NULL,
30
+ source text NOT NULL, -- document identifier or source URL
31
+ chunk_index int NOT NULL, -- position of this chunk within the source document
32
+ content text NOT NULL, -- chunk text returned to the agent as context
33
+ embedding vector(1536) NOT NULL, -- vector dimension must match embedding model
34
+ metadata jsonb NOT NULL DEFAULT '{}',
35
+ created_at timestamptz NOT NULL DEFAULT now()
36
+ );
37
+
38
+ COMMENT ON TABLE {{SCHEMA}}.kb_embeddings IS 'RAG knowledge base — chunk text and pgvector embeddings for semantic search.';
39
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.tenant_id IS 'Tenant partition. Every query MUST filter on this column. Never query across tenants.';
40
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.source IS 'Document identifier or URL. Used for citation and re-indexing detection.';
41
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.chunk_index IS 'Zero-based position of this chunk within the source document.';
42
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.content IS 'Chunk text returned to the agent. Plain text, no markup.';
43
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.embedding IS 'Float vector. Dimension MUST match the embedding model declared in model-registry.json.';
44
+ COMMENT ON COLUMN {{SCHEMA}}.kb_embeddings.metadata IS 'Arbitrary JSON metadata (section headers, page numbers, doc type, etc.). Used for filtering.';
45
+
46
+ -- ============================================================
47
+ -- 3. INDEXES
48
+ -- ============================================================
49
+
50
+ -- HNSW index for cosine similarity — production-grade recall, no training data required.
51
+ -- vector_cosine_ops: use <=> operator (cosine distance, ascending = most similar first).
52
+ -- m=16, ef_construction=64 are pgvector defaults. Tune per infrastructure-neon-pgvector §HNSW Parameters.
53
+ CREATE INDEX ix_kb_embeddings_hnsw
54
+ ON {{SCHEMA}}.kb_embeddings
55
+ USING hnsw (embedding vector_cosine_ops)
56
+ WITH (m = 16, ef_construction = 64);
57
+
58
+ -- Index for the mandatory tenant_id filter (applied in every search query).
59
+ CREATE INDEX ix_kb_embeddings_tenant
60
+ ON {{SCHEMA}}.kb_embeddings (tenant_id);
61
+
62
+ -- Composite index for source-level operations (re-indexing, deletion by document).
63
+ CREATE INDEX ix_kb_embeddings_source
64
+ ON {{SCHEMA}}.kb_embeddings (tenant_id, source);
65
+
66
+ -- ============================================================
67
+ -- 4. ROW-LEVEL SECURITY (multi-tenant)
68
+ -- ============================================================
69
+
70
+ -- RLS enforces tenant isolation at the database level as a second line of defence.
71
+ -- The application already filters on tenant_id in every query; RLS is the backstop.
72
+ --
73
+ -- See templates/code/sql/postgresql-rls-policy.sql for the policy pattern that
74
+ -- binds app.current_tenant_id (a session-level setting) to the RLS policy.
75
+ --
76
+ -- Uncomment and adapt once RLS is wired in the project:
77
+ --
78
+ -- ALTER TABLE {{SCHEMA}}.kb_embeddings ENABLE ROW LEVEL SECURITY;
79
+ --
80
+ -- CREATE POLICY kb_embeddings_tenant_isolation
81
+ -- ON {{SCHEMA}}.kb_embeddings
82
+ -- USING (tenant_id = current_setting('app.current_tenant_id')::uuid);
83
+
84
+ -- ============================================================
85
+ -- ROLLBACK
86
+ -- ============================================================
87
+
88
+ -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_hnsw;
89
+ -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_tenant;
90
+ -- DROP INDEX IF EXISTS {{SCHEMA}}.ix_kb_embeddings_source;
91
+ -- DROP TABLE IF EXISTS {{SCHEMA}}.kb_embeddings CASCADE;
@@ -17,11 +17,13 @@
17
17
 
18
18
  ## Cenários
19
19
 
20
- <!-- Um cenário por comportamento observável. `prova:` é teste | e2e | eval | manual.
20
+ <!-- Um cenário por comportamento observável. `prova:` é teste | e2e | eval | manual | leitura.
21
+ `prova: teste` exige `risco:` regra | dinheiro | contrato | concorrência | dado | regressão; sem risco, `leitura`.
21
22
  Cenário que fala de arquivo, grep ou texto exige a linha "> Por que artefato:" logo abaixo. -->
22
23
 
23
24
  - **C1** — Dado <estado>, quando <ação>, então <resultado observável>.
24
25
  prova: teste
26
+ risco: <regra | dinheiro | contrato | concorrência | dado | regressão>
25
27
 
26
28
  ## Decisões
27
29
 
@@ -1,26 +1,26 @@
1
- // features/{{kebabCase featureName}}/components/{{kebabCase featureName}}-list.tsx
2
- 'use client';
3
-
4
- import { use{{pascalCase featureName}}s } from '@/features/{{kebabCase featureName}}/hooks/use-{{kebabCase featureName}}s';
5
- import { DataTable } from '@/components/data-table';
6
- import type { {{pascalCase featureName}} } from '@/features/{{kebabCase featureName}}/types/{{kebabCase featureName}}.types';
7
- import type { ColumnDef } from '@tanstack/react-table';
8
-
9
- const columns: ColumnDef<{{pascalCase featureName}}>[] = [
10
- { accessorKey: 'id', header: 'ID' },
11
- { accessorKey: 'name', header: 'Name' },
12
- ];
13
-
14
- interface {{pascalCase featureName}}ListProps {
15
- initialData?: {{pascalCase featureName}}[];
16
- }
17
-
18
- export function {{pascalCase featureName}}List({ initialData }: {{pascalCase featureName}}ListProps) {
19
- const { data = initialData ?? [], isLoading } = use{{pascalCase featureName}}s();
20
-
21
- if (isLoading) {
22
- return <div className="flex items-center justify-center h-32">Loading...</div>;
23
- }
24
-
25
- return <DataTable columns={columns} data={data} />;
26
- }
1
+ // features/{{kebabCase featureName}}/components/{{kebabCase featureName}}-list.tsx
2
+ 'use client';
3
+
4
+ import { use{{pascalCase featureName}}s } from '@/features/{{kebabCase featureName}}/hooks/use-{{kebabCase featureName}}s';
5
+ import { DataTable } from '@/components/data-table';
6
+ import type { {{pascalCase featureName}} } from '@/features/{{kebabCase featureName}}/types/{{kebabCase featureName}}.types';
7
+ import type { ColumnDef } from '@tanstack/react-table';
8
+
9
+ const columns: ColumnDef<{{pascalCase featureName}}>[] = [
10
+ { accessorKey: 'id', header: 'ID' },
11
+ { accessorKey: 'name', header: 'Name' },
12
+ ];
13
+
14
+ interface {{pascalCase featureName}}ListProps {
15
+ initialData?: {{pascalCase featureName}}[];
16
+ }
17
+
18
+ export function {{pascalCase featureName}}List({ initialData }: {{pascalCase featureName}}ListProps) {
19
+ const { data = initialData ?? [], isLoading } = use{{pascalCase featureName}}s();
20
+
21
+ if (isLoading) {
22
+ return <div className="flex items-center justify-center h-32">Loading...</div>;
23
+ }
24
+
25
+ return <DataTable columns={columns} data={data} />;
26
+ }
@@ -1,56 +1,56 @@
1
- // features/{{kebabCase featureName}}/components/create-{{kebabCase featureName}}-form.tsx
2
- 'use client';
3
-
4
- import { useForm } from 'react-hook-form';
5
- import { zodResolver } from '@hookform/resolvers/zod';
6
- import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
7
- import { Input } from '@/components/ui/input';
8
- import { Button } from '@/components/ui/button';
9
- import { useCreate{{pascalCase featureName}} } from '@/features/{{kebabCase featureName}}/hooks/use-create-{{kebabCase featureName}}';
10
- import { create{{pascalCase featureName}}Schema, type Create{{pascalCase featureName}}Input } from '@/features/{{kebabCase featureName}}/types/{{kebabCase featureName}}.schemas';
11
-
12
- interface Create{{pascalCase featureName}}FormProps {
13
- onSuccess?: () => void;
14
- }
15
-
16
- export function Create{{pascalCase featureName}}Form({ onSuccess }: Create{{pascalCase featureName}}FormProps) {
17
- const form = useForm<Create{{pascalCase featureName}}Input>({
18
- resolver: zodResolver(create{{pascalCase featureName}}Schema),
19
- defaultValues: { name: '' },
20
- });
21
-
22
- const { mutate: create{{pascalCase featureName}}, isPending } = useCreate{{pascalCase featureName}}();
23
-
24
- function onSubmit(values: Create{{pascalCase featureName}}Input) {
25
- create{{pascalCase featureName}}(values, {
26
- onSuccess: () => { form.reset(); onSuccess?.(); },
27
- onError: (error) => { form.setError('root', { message: error.message }); },
28
- });
29
- }
30
-
31
- return (
32
- <Form {...form}>
33
- <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
34
- <FormField
35
- control={form.control}
36
- name="name"
37
- render={({ field }) => (
38
- <FormItem>
39
- <FormLabel>Name</FormLabel>
40
- <FormControl>
41
- <Input placeholder="Enter name" {...field} />
42
- </FormControl>
43
- <FormMessage />
44
- </FormItem>
45
- )}
46
- />
47
- {form.formState.errors.root && (
48
- <p className="text-sm text-destructive">{form.formState.errors.root.message}</p>
49
- )}
50
- <Button type="submit" disabled={isPending}>
51
- {isPending ? 'Creating...' : 'Create {{pascalCase featureName}}'}
52
- </Button>
53
- </form>
54
- </Form>
55
- );
56
- }
1
+ // features/{{kebabCase featureName}}/components/create-{{kebabCase featureName}}-form.tsx
2
+ 'use client';
3
+
4
+ import { useForm } from 'react-hook-form';
5
+ import { zodResolver } from '@hookform/resolvers/zod';
6
+ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
7
+ import { Input } from '@/components/ui/input';
8
+ import { Button } from '@/components/ui/button';
9
+ import { useCreate{{pascalCase featureName}} } from '@/features/{{kebabCase featureName}}/hooks/use-create-{{kebabCase featureName}}';
10
+ import { create{{pascalCase featureName}}Schema, type Create{{pascalCase featureName}}Input } from '@/features/{{kebabCase featureName}}/types/{{kebabCase featureName}}.schemas';
11
+
12
+ interface Create{{pascalCase featureName}}FormProps {
13
+ onSuccess?: () => void;
14
+ }
15
+
16
+ export function Create{{pascalCase featureName}}Form({ onSuccess }: Create{{pascalCase featureName}}FormProps) {
17
+ const form = useForm<Create{{pascalCase featureName}}Input>({
18
+ resolver: zodResolver(create{{pascalCase featureName}}Schema),
19
+ defaultValues: { name: '' },
20
+ });
21
+
22
+ const { mutate: create{{pascalCase featureName}}, isPending } = useCreate{{pascalCase featureName}}();
23
+
24
+ function onSubmit(values: Create{{pascalCase featureName}}Input) {
25
+ create{{pascalCase featureName}}(values, {
26
+ onSuccess: () => { form.reset(); onSuccess?.(); },
27
+ onError: (error) => { form.setError('root', { message: error.message }); },
28
+ });
29
+ }
30
+
31
+ return (
32
+ <Form {...form}>
33
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
34
+ <FormField
35
+ control={form.control}
36
+ name="name"
37
+ render={({ field }) => (
38
+ <FormItem>
39
+ <FormLabel>Name</FormLabel>
40
+ <FormControl>
41
+ <Input placeholder="Enter name" {...field} />
42
+ </FormControl>
43
+ <FormMessage />
44
+ </FormItem>
45
+ )}
46
+ />
47
+ {form.formState.errors.root && (
48
+ <p className="text-sm text-destructive">{form.formState.errors.root.message}</p>
49
+ )}
50
+ <Button type="submit" disabled={isPending}>
51
+ {isPending ? 'Creating...' : 'Create {{pascalCase featureName}}'}
52
+ </Button>
53
+ </form>
54
+ </Form>
55
+ );
56
+ }
@@ -1,26 +1,26 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "lib": ["dom", "dom.iterable", "esnext"],
5
- "allowJs": false,
6
- "skipLibCheck": true,
7
- "strict": true,
8
- "noUncheckedIndexedAccess": true,
9
- "noImplicitOverride": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "noEmit": true,
12
- "esModuleInterop": true,
13
- "module": "esnext",
14
- "moduleResolution": "bundler",
15
- "resolveJsonModule": true,
16
- "isolatedModules": true,
17
- "jsx": "preserve",
18
- "incremental": true,
19
- "plugins": [{ "name": "next" }],
20
- "paths": {
21
- "@/*": ["./src/*"]
22
- }
23
- },
24
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25
- "exclude": ["node_modules"]
26
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": false,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noUncheckedIndexedAccess": true,
9
+ "noImplicitOverride": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "noEmit": true,
12
+ "esModuleInterop": true,
13
+ "module": "esnext",
14
+ "moduleResolution": "bundler",
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "jsx": "preserve",
18
+ "incremental": true,
19
+ "plugins": [{ "name": "next" }],
20
+ "paths": {
21
+ "@/*": ["./src/*"]
22
+ }
23
+ },
24
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25
+ "exclude": ["node_modules"]
26
+ }
@@ -1,58 +1,58 @@
1
- # Multi-stage Dockerfile for Next.js Production Build
2
- # Optimized for Next.js 15 with App Router
3
-
4
- FROM node:20-alpine AS base
5
-
6
- # Install dependencies only when needed
7
- FROM base AS deps
8
- RUN apk add --no-cache libc6-compat
9
- WORKDIR /app
10
-
11
- # Copy package files
12
- COPY package.json package-lock.json* ./
13
- RUN npm ci
14
-
15
- # Rebuild the source code only when needed
16
- FROM base AS builder
17
- WORKDIR /app
18
- COPY --from=deps /app/node_modules ./node_modules
19
- COPY . .
20
-
21
- # Set build-time environment variables
22
- ENV NEXT_TELEMETRY_DISABLED 1
23
-
24
- # Build Next.js application
25
- RUN npm run build
26
-
27
- # Production image, copy all the files and run next
28
- FROM base AS runner
29
- WORKDIR /app
30
-
31
- ENV NODE_ENV production
32
- ENV NEXT_TELEMETRY_DISABLED 1
33
-
34
- # Create nextjs user
35
- RUN addgroup --system --gid 1001 nodejs
36
- RUN adduser --system --uid 1001 nextjs
37
-
38
- # Copy built application
39
- COPY --from=builder /app/public ./public
40
-
41
- # Set the correct permission for prerender cache
42
- RUN mkdir .next
43
- RUN chown nextjs:nodejs .next
44
-
45
- # Automatically leverage output traces to reduce image size
46
- # https://nextjs.org/docs/advanced-features/output-file-tracing
47
- COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
48
- COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
49
-
50
- USER nextjs
51
-
52
- EXPOSE 3000
53
-
54
- ENV PORT 3000
55
- ENV HOSTNAME "0.0.0.0"
56
-
57
- # Run Next.js server
58
- CMD ["node", "server.js"]
1
+ # Multi-stage Dockerfile for Next.js Production Build
2
+ # Optimized for Next.js 15 with App Router
3
+
4
+ FROM node:20-alpine AS base
5
+
6
+ # Install dependencies only when needed
7
+ FROM base AS deps
8
+ RUN apk add --no-cache libc6-compat
9
+ WORKDIR /app
10
+
11
+ # Copy package files
12
+ COPY package.json package-lock.json* ./
13
+ RUN npm ci
14
+
15
+ # Rebuild the source code only when needed
16
+ FROM base AS builder
17
+ WORKDIR /app
18
+ COPY --from=deps /app/node_modules ./node_modules
19
+ COPY . .
20
+
21
+ # Set build-time environment variables
22
+ ENV NEXT_TELEMETRY_DISABLED 1
23
+
24
+ # Build Next.js application
25
+ RUN npm run build
26
+
27
+ # Production image, copy all the files and run next
28
+ FROM base AS runner
29
+ WORKDIR /app
30
+
31
+ ENV NODE_ENV production
32
+ ENV NEXT_TELEMETRY_DISABLED 1
33
+
34
+ # Create nextjs user
35
+ RUN addgroup --system --gid 1001 nodejs
36
+ RUN adduser --system --uid 1001 nextjs
37
+
38
+ # Copy built application
39
+ COPY --from=builder /app/public ./public
40
+
41
+ # Set the correct permission for prerender cache
42
+ RUN mkdir .next
43
+ RUN chown nextjs:nodejs .next
44
+
45
+ # Automatically leverage output traces to reduce image size
46
+ # https://nextjs.org/docs/advanced-features/output-file-tracing
47
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
48
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
49
+
50
+ USER nextjs
51
+
52
+ EXPOSE 3000
53
+
54
+ ENV PORT 3000
55
+ ENV HOSTNAME "0.0.0.0"
56
+
57
+ # Run Next.js server
58
+ CMD ["node", "server.js"]
@@ -1,38 +1,38 @@
1
- # ============================================================
2
- # Dockerfile: .NET 10 API ({{titleCase FEATURE_NAME}})
3
- # Stack: Next.js + Neon + .NET API
4
- # Generated by MORPH Framework
5
- # ============================================================
6
-
7
- # Stage 1: Build
8
- FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
9
- WORKDIR /src
10
-
11
- # Copy project file and restore dependencies
12
- COPY *.csproj .
13
- RUN dotnet restore
14
-
15
- # Copy source code and publish
16
- COPY . .
17
- RUN dotnet publish -c Release -o /app/publish --no-restore
18
-
19
- # Stage 2: Runtime
20
- FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
21
- WORKDIR /app
22
-
23
- # Copy published output
24
- COPY --from=build /app/publish .
25
-
26
- # Configuration
27
- ENV ASPNETCORE_URLS=http://+:8080
28
- ENV ASPNETCORE_ENVIRONMENT=Production
29
-
30
- # Expose port
31
- EXPOSE 8080
32
-
33
- # Health check
34
- HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
35
- CMD curl -f http://localhost:8080/health || exit 1
36
-
37
- # Entrypoint
38
- ENTRYPOINT ["dotnet", "Api.dll"]
1
+ # ============================================================
2
+ # Dockerfile: .NET 10 API ({{titleCase FEATURE_NAME}})
3
+ # Stack: Next.js + Neon + .NET API
4
+ # Generated by MORPH Framework
5
+ # ============================================================
6
+
7
+ # Stage 1: Build
8
+ FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
9
+ WORKDIR /src
10
+
11
+ # Copy project file and restore dependencies
12
+ COPY *.csproj .
13
+ RUN dotnet restore
14
+
15
+ # Copy source code and publish
16
+ COPY . .
17
+ RUN dotnet publish -c Release -o /app/publish --no-restore
18
+
19
+ # Stage 2: Runtime
20
+ FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
21
+ WORKDIR /app
22
+
23
+ # Copy published output
24
+ COPY --from=build /app/publish .
25
+
26
+ # Configuration
27
+ ENV ASPNETCORE_URLS=http://+:8080
28
+ ENV ASPNETCORE_ENVIRONMENT=Production
29
+
30
+ # Expose port
31
+ EXPOSE 8080
32
+
33
+ # Health check
34
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
35
+ CMD curl -f http://localhost:8080/health || exit 1
36
+
37
+ # Entrypoint
38
+ ENTRYPOINT ["dotnet", "Api.dll"]