@polymorphism-tech/morph-spec 7.0.0 → 7.1.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 (79) hide show
  1. package/README.md +367 -367
  2. package/framework/agents.json +132 -127
  3. package/framework/rubrics/backend.json +41 -36
  4. package/framework/rules/ai-agents-standards.md +45 -15
  5. package/framework/rules/neon-standards.md +25 -26
  6. package/framework/standards/STANDARDS.json +1729 -1133
  7. package/framework/standards/ai-agents/agent-session.md +160 -0
  8. package/framework/standards/ai-agents/batching.md +193 -0
  9. package/framework/standards/ai-agents/context-providers.md +188 -0
  10. package/framework/standards/ai-agents/mcp-server.md +250 -0
  11. package/framework/standards/ai-agents/mcp-tools.md +197 -0
  12. package/framework/standards/ai-agents/middleware-patterns.md +207 -0
  13. package/framework/standards/ai-agents/modalities-image-gen.md +173 -0
  14. package/framework/standards/ai-agents/modalities-speech-to-text.md +171 -0
  15. package/framework/standards/ai-agents/modalities-text-to-speech.md +181 -0
  16. package/framework/standards/ai-agents/modalities-vision.md +201 -0
  17. package/framework/standards/ai-agents/multi-agent-patterns.md +155 -0
  18. package/framework/standards/ai-agents/production.md +114 -258
  19. package/framework/standards/ai-agents/prompts-in-db.md +214 -0
  20. package/framework/standards/ai-agents/providers/model-registry.md +158 -0
  21. package/framework/standards/ai-agents/rag-custom-pgvector.md +243 -0
  22. package/framework/standards/ai-agents/service-tier-flex.md +135 -0
  23. package/framework/standards/ai-agents/setup.md +142 -316
  24. package/framework/standards/ai-agents/structured-output.md +249 -0
  25. package/framework/standards/ai-agents/sweet-spot.md +109 -0
  26. package/framework/standards/ai-agents/workflows.md +114 -284
  27. package/framework/standards/architecture/vertical-slice/vertical-slice.md +433 -429
  28. package/framework/standards/backend/api/validation.md +92 -88
  29. package/framework/standards/backend/database/postgresql/database.md +336 -332
  30. package/framework/standards/backend/database/vector-search-rag.md +599 -541
  31. package/framework/standards/backend/dotnet/fluent-validation-vsa.md +4 -0
  32. package/framework/standards/backend/dotnet/result-pattern.md +4 -0
  33. package/framework/standards/backend/dotnet/scalar-ui.md +176 -172
  34. package/framework/standards/backend/dotnet/scrutor.md +4 -0
  35. package/framework/standards/backend/dotnet/vsa-handler-patterns.md +278 -274
  36. package/framework/standards/backend/integrations/asaas/asaas-api.md +260 -216
  37. package/framework/standards/backend/integrations/hangfire/hangfire-jobs.md +354 -350
  38. package/framework/standards/backend/integrations/neon-auth/neon-auth.md +30 -19
  39. package/framework/standards/backend/integrations/resend/resend-email.md +400 -385
  40. package/framework/standards/data/nosql/cache/redis.md +106 -97
  41. package/framework/standards/data/nosql/cosmos-db.md +127 -118
  42. package/framework/standards/data/vector-search/rag-chunking.md +113 -104
  43. package/framework/standards/frontend/design-system/ai-image-generation.md +4 -0
  44. package/framework/standards/frontend/design-system/animations.md +164 -160
  45. package/framework/standards/frontend/design-system/naming.md +68 -64
  46. package/framework/standards/frontend/gsap/gsap-core.md +14 -8
  47. package/framework/standards/frontend/gsap/gsap-plugins.md +26 -21
  48. package/framework/standards/frontend/gsap/gsap-scrolltrigger.md +9 -7
  49. package/framework/standards/frontend/nextjs/app-router.md +127 -123
  50. package/framework/standards/frontend/nextjs/components.md +136 -132
  51. package/framework/standards/frontend/nextjs/data-fetching.md +130 -126
  52. package/framework/standards/frontend/nextjs/forms.md +134 -128
  53. package/framework/standards/frontend/nextjs/motion-patterns.md +328 -322
  54. package/framework/standards/frontend/nextjs/naming-conventions.md +71 -67
  55. package/framework/standards/frontend/nextjs/nextjs-patterns.md +229 -225
  56. package/framework/standards/frontend/nextjs/project-structure.md +106 -102
  57. package/framework/standards/frontend/nextjs/state-management.md +76 -72
  58. package/framework/standards/frontend/nextjs/testing.md +115 -111
  59. package/framework/standards/infrastructure/docker/easypanel-deploy.md +196 -192
  60. package/framework/standards/infrastructure/neon/neon-pgrag.md +6 -2
  61. package/framework/standards/infrastructure/neon/neon-pgvector.md +4 -0
  62. package/framework/standards/infrastructure/neon/neon-setup.md +5 -1
  63. package/framework/standards/integration/mcp/mcp-tools.md +471 -462
  64. package/framework/templates/REGISTRY.json +1745 -1239
  65. package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +39 -0
  66. package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +68 -0
  67. package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +117 -0
  68. package/framework/templates/code/dotnet/ai-agents/PromptRepository.cs.template +95 -0
  69. package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +61 -0
  70. package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +107 -0
  71. package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +58 -0
  72. package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +58 -0
  73. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +91 -0
  74. package/package.json +89 -83
  75. package/src/core/templates/template-registry.js +289 -256
  76. package/src/lib/generators/context-generator.js +516 -518
  77. package/src/lib/generators/scaffold-generator.js +23 -26
  78. package/framework/standards/infrastructure/neon/neon-semantic-kernel.md +0 -310
  79. package/framework/templates/integrations/semantic-kernel-neon.cs +0 -125
@@ -0,0 +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;
package/package.json CHANGED
@@ -1,83 +1,89 @@
1
- {
2
- "name": "@polymorphism-tech/morph-spec",
3
- "version": "7.0.0",
4
- "description": "MORPH-SPEC: NLH (Natural Language Harness) for spec-driven development with Claude Code",
5
- "keywords": [
6
- "claude-code",
7
- "claude",
8
- "ai-coding",
9
- "ai-first",
10
- "spec-driven",
11
- "nlh",
12
- "natural-language-harness",
13
- "autonomy",
14
- "dotnet",
15
- "dotnet10",
16
- "nextjs",
17
- "vsa",
18
- "vertical-slice",
19
- "framework",
20
- "morph",
21
- "polymorphism"
22
- ],
23
- "main": "src/index.js",
24
- "bin": {
25
- "morph-spec": "bin/morph-spec.js"
26
- },
27
- "files": [
28
- "bin/",
29
- "src/",
30
- "framework/",
31
- "claude-plugin.json",
32
- "docs/QUICKSTART.md",
33
- "docs/CHEATSHEET.md",
34
- "README.md",
35
- "LICENSE",
36
- "CLAUDE.md"
37
- ],
38
- "type": "module",
39
- "engines": {
40
- "node": ">=18.0.0"
41
- },
42
- "scripts": {
43
- "start": "node bin/morph-spec.js",
44
- "generate": "node scripts/generate-refs.js",
45
- "test": "node --test --test-concurrency=1",
46
- "test:coverage": "c8 --reporter=text --reporter=html --reporter=lcov node --test --test-concurrency=1",
47
- "test:coverage:summary": "c8 --reporter=text-summary node --test --test-concurrency=1",
48
- "docs": "jsdoc -c jsdoc.json",
49
- "docs:watch": "jsdoc -c jsdoc.json --watch",
50
- "docs:serve": "npx http-server docs/api -p 8080 -o",
51
- "release": "node scripts/release.js",
52
- "postinstall": "node src/scripts/global-install.js"
53
- },
54
- "dependencies": {
55
- "chalk": "^5.3.0",
56
- "commander": "^12.0.0",
57
- "fs-extra": "^11.2.0",
58
- "glob": "^13.0.6",
59
- "handlebars": "^4.7.8",
60
- "inquirer": "^9.2.0",
61
- "minimatch": "^9.0.5",
62
- "ora": "^8.0.0"
63
- },
64
- "repository": {
65
- "type": "git",
66
- "url": "git+https://github.com/lucasPolymorphism/morph-spec-framework.git"
67
- },
68
- "author": "Polymorphism Tech <contact@polymorphism.com.br>",
69
- "license": "SEE LICENSE IN LICENSE",
70
- "homepage": "https://polymorphism.com.br/morph-spec",
71
- "bugs": {
72
- "email": "support@polymorphism.com.br"
73
- },
74
- "private": false,
75
- "publishConfig": {
76
- "access": "public"
77
- },
78
- "devDependencies": {
79
- "c8": "^11.0.0",
80
- "docdash": "^2.0.2",
81
- "jsdoc": "^4.0.5"
82
- }
83
- }
1
+ {
2
+ "name": "@polymorphism-tech/morph-spec",
3
+ "version": "7.1.0",
4
+ "description": "MORPH-SPEC: NLH (Natural Language Harness) for spec-driven development with Claude Code",
5
+ "keywords": [
6
+ "claude-code",
7
+ "claude",
8
+ "ai-coding",
9
+ "ai-first",
10
+ "spec-driven",
11
+ "nlh",
12
+ "natural-language-harness",
13
+ "autonomy",
14
+ "dotnet",
15
+ "dotnet10",
16
+ "nextjs",
17
+ "vsa",
18
+ "vertical-slice",
19
+ "framework",
20
+ "morph",
21
+ "polymorphism"
22
+ ],
23
+ "main": "src/index.js",
24
+ "bin": {
25
+ "morph-spec": "bin/morph-spec.js"
26
+ },
27
+ "files": [
28
+ "bin/",
29
+ "src/",
30
+ "framework/",
31
+ "claude-plugin.json",
32
+ "docs/QUICKSTART.md",
33
+ "docs/CHEATSHEET.md",
34
+ "README.md",
35
+ "LICENSE",
36
+ "CLAUDE.md"
37
+ ],
38
+ "type": "module",
39
+ "engines": {
40
+ "node": ">=22.0.0"
41
+ },
42
+ "scripts": {
43
+ "start": "node bin/morph-spec.js",
44
+ "generate": "node scripts/generate-refs.js",
45
+ "generate:check": "node scripts/generate-refs.js --check",
46
+ "generate-standards": "node scripts/generate-standards-registry.js",
47
+ "generate-standards:check": "node scripts/generate-standards-registry.js --check",
48
+ "validate": "node scripts/validate-framework.js",
49
+ "freshness": "node scripts/check-freshness.js",
50
+ "verify": "npm run generate:check && npm run generate-standards:check && npm run validate && npm run freshness && npm test",
51
+ "test": "node scripts/run-tests.mjs",
52
+ "test:coverage": "c8 --reporter=text --reporter=html --reporter=lcov node scripts/run-tests.mjs",
53
+ "test:coverage:summary": "c8 --reporter=text-summary node scripts/run-tests.mjs",
54
+ "docs": "jsdoc -c jsdoc.json",
55
+ "docs:watch": "jsdoc -c jsdoc.json --watch",
56
+ "docs:serve": "npx http-server docs/api -p 8080 -o",
57
+ "release": "node scripts/release.js",
58
+ "postinstall": "node src/scripts/global-install.js"
59
+ },
60
+ "dependencies": {
61
+ "chalk": "^5.3.0",
62
+ "commander": "^12.0.0",
63
+ "fs-extra": "^11.2.0",
64
+ "glob": "^13.0.6",
65
+ "handlebars": "^4.7.8",
66
+ "inquirer": "^9.2.0",
67
+ "minimatch": "^9.0.5",
68
+ "ora": "^8.0.0"
69
+ },
70
+ "repository": {
71
+ "type": "git",
72
+ "url": "git+https://github.com/lucasPolymorphism/morph-spec-framework.git"
73
+ },
74
+ "author": "Polymorphism Tech <contact@polymorphism.com.br>",
75
+ "license": "SEE LICENSE IN LICENSE",
76
+ "homepage": "https://polymorphism.com.br/morph-spec",
77
+ "bugs": {
78
+ "email": "support@polymorphism.com.br"
79
+ },
80
+ "private": false,
81
+ "publishConfig": {
82
+ "access": "public"
83
+ },
84
+ "devDependencies": {
85
+ "c8": "^11.0.0",
86
+ "docdash": "^2.0.2",
87
+ "jsdoc": "^4.0.5"
88
+ }
89
+ }