@hyperfixi/patterns-reference 2.0.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.
@@ -0,0 +1,123 @@
1
+ import { C as ConnectionOptions, e as Pattern, k as SearchOptions, m as PatternStats, T as Translation, V as VerificationResult, W as WordOrder, d as LLMExample } from './index-CBoczxz7.js';
2
+
3
+ /**
4
+ * Pattern Queries API
5
+ *
6
+ * Provides functions to query patterns from the database.
7
+ */
8
+
9
+ /**
10
+ * Get a pattern by ID.
11
+ */
12
+ declare function getPatternById(id: string, options?: ConnectionOptions): Promise<Pattern | null>;
13
+ /**
14
+ * Get patterns by category (feature in hyperscript-lsp schema).
15
+ */
16
+ declare function getPatternsByCategory(category: string, options?: ConnectionOptions): Promise<Pattern[]>;
17
+ /**
18
+ * Get patterns by command (extracted from raw_code).
19
+ */
20
+ declare function getPatternsByCommand(command: string, options?: ConnectionOptions): Promise<Pattern[]>;
21
+ /**
22
+ * Search patterns by text query.
23
+ */
24
+ declare function searchPatterns(query: string, searchOptions?: SearchOptions, connOptions?: ConnectionOptions): Promise<Pattern[]>;
25
+ /**
26
+ * Get all patterns.
27
+ */
28
+ declare function getAllPatterns(searchOptions?: SearchOptions, connOptions?: ConnectionOptions): Promise<Pattern[]>;
29
+ /**
30
+ * Get pattern statistics.
31
+ */
32
+ declare function getPatternStats(connOptions?: ConnectionOptions): Promise<PatternStats>;
33
+
34
+ /**
35
+ * Translation Operations API
36
+ *
37
+ * Provides functions to query and manage translations.
38
+ */
39
+
40
+ /**
41
+ * Get a translation for a pattern in a specific language.
42
+ */
43
+ declare function getTranslation(patternId: string, language: string, options?: ConnectionOptions): Promise<Translation | null>;
44
+ /**
45
+ * Get all translations for a pattern.
46
+ */
47
+ declare function getAllTranslations(patternId: string, options?: ConnectionOptions): Promise<Translation[]>;
48
+ /**
49
+ * Get translations by language.
50
+ */
51
+ declare function getTranslationsByLanguage(language: string, limit?: number, options?: ConnectionOptions): Promise<Translation[]>;
52
+ /**
53
+ * Get verified translations (successfully parsed).
54
+ */
55
+ declare function getVerifiedTranslations(language: string, limit?: number, options?: ConnectionOptions): Promise<Translation[]>;
56
+ /**
57
+ * Get high-confidence translations.
58
+ */
59
+ declare function getHighConfidenceTranslations(minConfidence?: number, limit?: number, options?: ConnectionOptions): Promise<Translation[]>;
60
+ /**
61
+ * Verify a translation parses correctly.
62
+ * Note: This requires @lokascript/semantic to be available.
63
+ */
64
+ declare function verifyTranslation(translation: Translation, options?: ConnectionOptions): Promise<VerificationResult>;
65
+ /**
66
+ * Get translation statistics by language.
67
+ */
68
+ declare function getTranslationStats(options?: ConnectionOptions): Promise<Record<string, {
69
+ total: number;
70
+ verified: number;
71
+ avgConfidence: number;
72
+ }>>;
73
+ /**
74
+ * Get word order for a language.
75
+ */
76
+ declare function getWordOrder(language: string): WordOrder;
77
+
78
+ /**
79
+ * LLM Examples API
80
+ *
81
+ * Provides functions to query and manage LLM examples for few-shot learning.
82
+ */
83
+
84
+ /**
85
+ * Get LLM examples relevant to a prompt.
86
+ * Uses text similarity to find relevant patterns.
87
+ */
88
+ declare function getLLMExamples(prompt: string, language?: string, limit?: number, options?: ConnectionOptions): Promise<LLMExample[]>;
89
+ /**
90
+ * Get examples by command type.
91
+ */
92
+ declare function getExamplesByCommand(command: string, language?: string, limit?: number, options?: ConnectionOptions): Promise<LLMExample[]>;
93
+ /**
94
+ * Get high-quality examples (for few-shot prompts).
95
+ */
96
+ declare function getHighQualityExamples(language?: string, minQuality?: number, limit?: number, options?: ConnectionOptions): Promise<LLMExample[]>;
97
+ /**
98
+ * Get most used examples (popular).
99
+ */
100
+ declare function getMostUsedExamples(language?: string, limit?: number, options?: ConnectionOptions): Promise<LLMExample[]>;
101
+ /**
102
+ * Build few-shot context for LLM prompting.
103
+ */
104
+ declare function buildFewShotContext(prompt: string, language?: string, numExamples?: number, options?: ConnectionOptions): Promise<string>;
105
+ /**
106
+ * Add a new LLM example.
107
+ */
108
+ declare function addLLMExample(example: Omit<LLMExample, 'id' | 'usageCount' | 'createdAt'>, options?: ConnectionOptions): Promise<number>;
109
+ /**
110
+ * Update example quality score.
111
+ */
112
+ declare function updateQualityScore(id: number, qualityScore: number, options?: ConnectionOptions): Promise<void>;
113
+ /**
114
+ * Get LLM example statistics.
115
+ */
116
+ declare function getLLMStats(options?: ConnectionOptions): Promise<{
117
+ total: number;
118
+ byLanguage: Record<string, number>;
119
+ avgQuality: number;
120
+ totalUsage: number;
121
+ }>;
122
+
123
+ export { getPatternsByCategory as a, getPatternsByCommand as b, getAllPatterns as c, getPatternStats as d, getTranslation as e, getAllTranslations as f, getPatternById as g, getTranslationsByLanguage as h, getVerifiedTranslations as i, getHighConfidenceTranslations as j, getTranslationStats as k, getWordOrder as l, getLLMExamples as m, getExamplesByCommand as n, getHighQualityExamples as o, getMostUsedExamples as p, buildFewShotContext as q, addLLMExample as r, searchPatterns as s, getLLMStats as t, updateQualityScore as u, verifyTranslation as v };
@@ -0,0 +1,123 @@
1
+ import { C as ConnectionOptions, e as Pattern, k as SearchOptions, m as PatternStats, T as Translation, V as VerificationResult, W as WordOrder, d as LLMExample } from './index-CBoczxz7.mjs';
2
+
3
+ /**
4
+ * Pattern Queries API
5
+ *
6
+ * Provides functions to query patterns from the database.
7
+ */
8
+
9
+ /**
10
+ * Get a pattern by ID.
11
+ */
12
+ declare function getPatternById(id: string, options?: ConnectionOptions): Promise<Pattern | null>;
13
+ /**
14
+ * Get patterns by category (feature in hyperscript-lsp schema).
15
+ */
16
+ declare function getPatternsByCategory(category: string, options?: ConnectionOptions): Promise<Pattern[]>;
17
+ /**
18
+ * Get patterns by command (extracted from raw_code).
19
+ */
20
+ declare function getPatternsByCommand(command: string, options?: ConnectionOptions): Promise<Pattern[]>;
21
+ /**
22
+ * Search patterns by text query.
23
+ */
24
+ declare function searchPatterns(query: string, searchOptions?: SearchOptions, connOptions?: ConnectionOptions): Promise<Pattern[]>;
25
+ /**
26
+ * Get all patterns.
27
+ */
28
+ declare function getAllPatterns(searchOptions?: SearchOptions, connOptions?: ConnectionOptions): Promise<Pattern[]>;
29
+ /**
30
+ * Get pattern statistics.
31
+ */
32
+ declare function getPatternStats(connOptions?: ConnectionOptions): Promise<PatternStats>;
33
+
34
+ /**
35
+ * Translation Operations API
36
+ *
37
+ * Provides functions to query and manage translations.
38
+ */
39
+
40
+ /**
41
+ * Get a translation for a pattern in a specific language.
42
+ */
43
+ declare function getTranslation(patternId: string, language: string, options?: ConnectionOptions): Promise<Translation | null>;
44
+ /**
45
+ * Get all translations for a pattern.
46
+ */
47
+ declare function getAllTranslations(patternId: string, options?: ConnectionOptions): Promise<Translation[]>;
48
+ /**
49
+ * Get translations by language.
50
+ */
51
+ declare function getTranslationsByLanguage(language: string, limit?: number, options?: ConnectionOptions): Promise<Translation[]>;
52
+ /**
53
+ * Get verified translations (successfully parsed).
54
+ */
55
+ declare function getVerifiedTranslations(language: string, limit?: number, options?: ConnectionOptions): Promise<Translation[]>;
56
+ /**
57
+ * Get high-confidence translations.
58
+ */
59
+ declare function getHighConfidenceTranslations(minConfidence?: number, limit?: number, options?: ConnectionOptions): Promise<Translation[]>;
60
+ /**
61
+ * Verify a translation parses correctly.
62
+ * Note: This requires @lokascript/semantic to be available.
63
+ */
64
+ declare function verifyTranslation(translation: Translation, options?: ConnectionOptions): Promise<VerificationResult>;
65
+ /**
66
+ * Get translation statistics by language.
67
+ */
68
+ declare function getTranslationStats(options?: ConnectionOptions): Promise<Record<string, {
69
+ total: number;
70
+ verified: number;
71
+ avgConfidence: number;
72
+ }>>;
73
+ /**
74
+ * Get word order for a language.
75
+ */
76
+ declare function getWordOrder(language: string): WordOrder;
77
+
78
+ /**
79
+ * LLM Examples API
80
+ *
81
+ * Provides functions to query and manage LLM examples for few-shot learning.
82
+ */
83
+
84
+ /**
85
+ * Get LLM examples relevant to a prompt.
86
+ * Uses text similarity to find relevant patterns.
87
+ */
88
+ declare function getLLMExamples(prompt: string, language?: string, limit?: number, options?: ConnectionOptions): Promise<LLMExample[]>;
89
+ /**
90
+ * Get examples by command type.
91
+ */
92
+ declare function getExamplesByCommand(command: string, language?: string, limit?: number, options?: ConnectionOptions): Promise<LLMExample[]>;
93
+ /**
94
+ * Get high-quality examples (for few-shot prompts).
95
+ */
96
+ declare function getHighQualityExamples(language?: string, minQuality?: number, limit?: number, options?: ConnectionOptions): Promise<LLMExample[]>;
97
+ /**
98
+ * Get most used examples (popular).
99
+ */
100
+ declare function getMostUsedExamples(language?: string, limit?: number, options?: ConnectionOptions): Promise<LLMExample[]>;
101
+ /**
102
+ * Build few-shot context for LLM prompting.
103
+ */
104
+ declare function buildFewShotContext(prompt: string, language?: string, numExamples?: number, options?: ConnectionOptions): Promise<string>;
105
+ /**
106
+ * Add a new LLM example.
107
+ */
108
+ declare function addLLMExample(example: Omit<LLMExample, 'id' | 'usageCount' | 'createdAt'>, options?: ConnectionOptions): Promise<number>;
109
+ /**
110
+ * Update example quality score.
111
+ */
112
+ declare function updateQualityScore(id: number, qualityScore: number, options?: ConnectionOptions): Promise<void>;
113
+ /**
114
+ * Get LLM example statistics.
115
+ */
116
+ declare function getLLMStats(options?: ConnectionOptions): Promise<{
117
+ total: number;
118
+ byLanguage: Record<string, number>;
119
+ avgQuality: number;
120
+ totalUsage: number;
121
+ }>;
122
+
123
+ export { getPatternsByCategory as a, getPatternsByCommand as b, getAllPatterns as c, getPatternStats as d, getTranslation as e, getAllTranslations as f, getPatternById as g, getTranslationsByLanguage as h, getVerifiedTranslations as i, getHighConfidenceTranslations as j, getTranslationStats as k, getWordOrder as l, getLLMExamples as m, getExamplesByCommand as n, getHighQualityExamples as o, getMostUsedExamples as p, buildFewShotContext as q, addLLMExample as r, searchPatterns as s, getLLMStats as t, updateQualityScore as u, verifyTranslation as v };
@@ -0,0 +1,42 @@
1
+ import { n as SyncOptions, o as SyncResult, p as ValidationOptions, q as ValidationResult, D as DiscoveryResult } from '../index-CBoczxz7.mjs';
2
+ import '@lokascript/semantic';
3
+
4
+ /**
5
+ * Sync Module
6
+ *
7
+ * Re-exports sync operations that were migrated from packages/semantic/scripts/.
8
+ * These are typically run via CLI scripts rather than imported directly.
9
+ */
10
+
11
+ /**
12
+ * Sync translations from code_examples to pattern_translations.
13
+ *
14
+ * This is a placeholder - the actual implementation is in
15
+ * packages/semantic/scripts/sync-lsp-translations.ts
16
+ */
17
+ declare function syncTranslations(_options?: SyncOptions): Promise<SyncResult>;
18
+ /**
19
+ * Validate all translations in the database.
20
+ *
21
+ * This is a placeholder - the actual implementation is in
22
+ * packages/semantic/scripts/validate-translations.ts
23
+ */
24
+ declare function validateAllTranslations(_options?: ValidationOptions): Promise<ValidationResult>;
25
+ /**
26
+ * Discover and analyze patterns in the database.
27
+ *
28
+ * This is a placeholder - the actual implementation is in
29
+ * packages/semantic/scripts/pattern-discovery.ts
30
+ */
31
+ declare function discoverPatterns(_verbose?: boolean): Promise<DiscoveryResult>;
32
+ /**
33
+ * Seed LLM examples from verified translations.
34
+ *
35
+ * This is a placeholder - the actual implementation is in
36
+ * packages/semantic/scripts/seed-llm-examples.ts
37
+ */
38
+ declare function seedLLMExamples(_dryRun?: boolean): Promise<{
39
+ count: number;
40
+ }>;
41
+
42
+ export { DiscoveryResult, SyncOptions, SyncResult, ValidationOptions, ValidationResult, discoverPatterns, seedLLMExamples, syncTranslations, validateAllTranslations };
@@ -0,0 +1,42 @@
1
+ import { n as SyncOptions, o as SyncResult, p as ValidationOptions, q as ValidationResult, D as DiscoveryResult } from '../index-CBoczxz7.js';
2
+ import '@lokascript/semantic';
3
+
4
+ /**
5
+ * Sync Module
6
+ *
7
+ * Re-exports sync operations that were migrated from packages/semantic/scripts/.
8
+ * These are typically run via CLI scripts rather than imported directly.
9
+ */
10
+
11
+ /**
12
+ * Sync translations from code_examples to pattern_translations.
13
+ *
14
+ * This is a placeholder - the actual implementation is in
15
+ * packages/semantic/scripts/sync-lsp-translations.ts
16
+ */
17
+ declare function syncTranslations(_options?: SyncOptions): Promise<SyncResult>;
18
+ /**
19
+ * Validate all translations in the database.
20
+ *
21
+ * This is a placeholder - the actual implementation is in
22
+ * packages/semantic/scripts/validate-translations.ts
23
+ */
24
+ declare function validateAllTranslations(_options?: ValidationOptions): Promise<ValidationResult>;
25
+ /**
26
+ * Discover and analyze patterns in the database.
27
+ *
28
+ * This is a placeholder - the actual implementation is in
29
+ * packages/semantic/scripts/pattern-discovery.ts
30
+ */
31
+ declare function discoverPatterns(_verbose?: boolean): Promise<DiscoveryResult>;
32
+ /**
33
+ * Seed LLM examples from verified translations.
34
+ *
35
+ * This is a placeholder - the actual implementation is in
36
+ * packages/semantic/scripts/seed-llm-examples.ts
37
+ */
38
+ declare function seedLLMExamples(_dryRun?: boolean): Promise<{
39
+ count: number;
40
+ }>;
41
+
42
+ export { DiscoveryResult, SyncOptions, SyncResult, ValidationOptions, ValidationResult, discoverPatterns, seedLLMExamples, syncTranslations, validateAllTranslations };
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ // src/sync/index.ts
4
+ async function syncTranslations(_options = {}) {
5
+ throw new Error(
6
+ "syncTranslations should be run via: bun run packages/semantic/scripts/sync-lsp-translations.ts"
7
+ );
8
+ }
9
+ async function validateAllTranslations(_options = {}) {
10
+ throw new Error(
11
+ "validateAllTranslations should be run via: bun run packages/semantic/scripts/validate-translations.ts"
12
+ );
13
+ }
14
+ async function discoverPatterns(_verbose = false) {
15
+ throw new Error(
16
+ "discoverPatterns should be run via: bun run packages/semantic/scripts/pattern-discovery.ts"
17
+ );
18
+ }
19
+ async function seedLLMExamples(_dryRun = false) {
20
+ throw new Error(
21
+ "seedLLMExamples should be run via: bun run packages/semantic/scripts/seed-llm-examples.ts"
22
+ );
23
+ }
24
+
25
+ exports.discoverPatterns = discoverPatterns;
26
+ exports.seedLLMExamples = seedLLMExamples;
27
+ exports.syncTranslations = syncTranslations;
28
+ exports.validateAllTranslations = validateAllTranslations;
@@ -0,0 +1,23 @@
1
+ // src/sync/index.ts
2
+ async function syncTranslations(_options = {}) {
3
+ throw new Error(
4
+ "syncTranslations should be run via: bun run packages/semantic/scripts/sync-lsp-translations.ts"
5
+ );
6
+ }
7
+ async function validateAllTranslations(_options = {}) {
8
+ throw new Error(
9
+ "validateAllTranslations should be run via: bun run packages/semantic/scripts/validate-translations.ts"
10
+ );
11
+ }
12
+ async function discoverPatterns(_verbose = false) {
13
+ throw new Error(
14
+ "discoverPatterns should be run via: bun run packages/semantic/scripts/pattern-discovery.ts"
15
+ );
16
+ }
17
+ async function seedLLMExamples(_dryRun = false) {
18
+ throw new Error(
19
+ "seedLLMExamples should be run via: bun run packages/semantic/scripts/seed-llm-examples.ts"
20
+ );
21
+ }
22
+
23
+ export { discoverPatterns, seedLLMExamples, syncTranslations, validateAllTranslations };
package/package.json ADDED
@@ -0,0 +1,92 @@
1
+ {
2
+ "name": "@hyperfixi/patterns-reference",
3
+ "version": "2.0.0",
4
+ "description": "Queryable patterns database for hyperscript with multilingual translations and LLM support",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./api": {
15
+ "types": "./dist/api/index.d.ts",
16
+ "import": "./dist/api/index.mjs",
17
+ "require": "./dist/api/index.js"
18
+ },
19
+ "./sync": {
20
+ "types": "./dist/sync/index.d.ts",
21
+ "import": "./dist/sync/index.mjs",
22
+ "require": "./dist/sync/index.js"
23
+ }
24
+ },
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "dev": "tsup --watch",
28
+ "test": "vitest",
29
+ "test:run": "vitest run",
30
+ "typecheck": "tsc --noEmit",
31
+ "db:init": "tsx scripts/init-db.ts",
32
+ "db:init:force": "tsx scripts/init-db.ts --force",
33
+ "sync:translations": "tsx scripts/sync-translations.ts",
34
+ "seed:llm": "tsx scripts/seed-llm-examples.ts",
35
+ "populate": "npm run db:init:force && npm run sync:translations && npm run seed:llm && npm run db:fix-translations",
36
+ "db:fix-translations": "tsx scripts/run-sql.ts scripts/fix-translations.sql",
37
+ "populate:dry-run": "npm run db:init:force && tsx scripts/sync-translations.ts --dry-run && tsx scripts/seed-llm-examples.ts --dry-run",
38
+ "validate": "tsx scripts/validate-all.ts",
39
+ "validate:fix": "tsx scripts/validate-all.ts --fix",
40
+ "verify": "tsx scripts/verify-translations.ts",
41
+ "verify:verbose": "tsx scripts/verify-translations.ts --verbose",
42
+ "verify:engine": "tsx scripts/verify-engine-compat.ts",
43
+ "verify:engine:verbose": "tsx scripts/verify-engine-compat.ts --verbose",
44
+ "verify:engine:dry-run": "tsx scripts/verify-engine-compat.ts --dry-run --verbose"
45
+ },
46
+ "keywords": [
47
+ "hyperscript",
48
+ "patterns",
49
+ "multilingual",
50
+ "i18n",
51
+ "reference",
52
+ "llm",
53
+ "database"
54
+ ],
55
+ "author": "LokaScript Contributors",
56
+ "license": "MIT",
57
+ "engines": {
58
+ "node": ">=18.0.0"
59
+ },
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "git+https://github.com/codetalcott/hyperfixi.git",
63
+ "directory": "packages/patterns-reference"
64
+ },
65
+ "bugs": {
66
+ "url": "https://github.com/codetalcott/hyperfixi/issues"
67
+ },
68
+ "homepage": "https://github.com/codetalcott/hyperfixi/tree/main/packages/patterns-reference#readme",
69
+ "dependencies": {
70
+ "@lokascript/semantic": "*",
71
+ "better-sqlite3": "^12.6.2"
72
+ },
73
+ "devDependencies": {
74
+ "@types/better-sqlite3": "^7.6.0",
75
+ "@types/node": "^20.0.0",
76
+ "tsup": "^8.0.0",
77
+ "tsx": "^4.0.0",
78
+ "typescript": "^5.0.0",
79
+ "vitest": "^4.0.0"
80
+ },
81
+ "files": [
82
+ "dist",
83
+ "data",
84
+ "src",
85
+ "!src/**/*.test.ts",
86
+ "!src/**/*.spec.ts"
87
+ ],
88
+ "sideEffects": false,
89
+ "publishConfig": {
90
+ "access": "public"
91
+ }
92
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Adapters for cross-package integration.
3
+ *
4
+ * @module @hyperfixi/patterns-reference/adapters
5
+ */
6
+
7
+ export * from './llm-adapter';