semantic-primitives 0.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.
- package/LICENSE +201 -0
- package/README.md +449 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25016 -0
- package/dist/llm/client.d.ts +82 -0
- package/dist/llm/client.d.ts.map +1 -0
- package/dist/llm/index.d.ts +11 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.d.ts +13 -0
- package/dist/llm/providers/anthropic.d.ts.map +1 -0
- package/dist/llm/providers/google.d.ts +13 -0
- package/dist/llm/providers/google.d.ts.map +1 -0
- package/dist/llm/providers/index.d.ts +7 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/openai.d.ts +13 -0
- package/dist/llm/providers/openai.d.ts.map +1 -0
- package/dist/llm/types.d.ts +91 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/primitives/bigint/bigint.d.ts +197 -0
- package/dist/primitives/bigint/bigint.d.ts.map +1 -0
- package/dist/primitives/bigint/index.d.ts +7 -0
- package/dist/primitives/bigint/index.d.ts.map +1 -0
- package/dist/primitives/bigint/prompts.d.ts +37 -0
- package/dist/primitives/bigint/prompts.d.ts.map +1 -0
- package/dist/primitives/boolean/boolean.d.ts +194 -0
- package/dist/primitives/boolean/boolean.d.ts.map +1 -0
- package/dist/primitives/boolean/evals/from.evals.d.ts +7 -0
- package/dist/primitives/boolean/evals/from.evals.d.ts.map +1 -0
- package/dist/primitives/boolean/evals/index.d.ts +5 -0
- package/dist/primitives/boolean/evals/index.d.ts.map +1 -0
- package/dist/primitives/boolean/index.d.ts +6 -0
- package/dist/primitives/boolean/index.d.ts.map +1 -0
- package/dist/primitives/boolean/prompts.d.ts +29 -0
- package/dist/primitives/boolean/prompts.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +14 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/null/index.d.ts +6 -0
- package/dist/primitives/null/index.d.ts.map +1 -0
- package/dist/primitives/null/null.d.ts +181 -0
- package/dist/primitives/null/null.d.ts.map +1 -0
- package/dist/primitives/null/prompts.d.ts +39 -0
- package/dist/primitives/null/prompts.d.ts.map +1 -0
- package/dist/primitives/number/index.d.ts +6 -0
- package/dist/primitives/number/index.d.ts.map +1 -0
- package/dist/primitives/number/number.d.ts +154 -0
- package/dist/primitives/number/number.d.ts.map +1 -0
- package/dist/primitives/number/number.prompts.d.ts +53 -0
- package/dist/primitives/number/number.prompts.d.ts.map +1 -0
- package/dist/primitives/string/evals/classify.evals.d.ts +7 -0
- package/dist/primitives/string/evals/classify.evals.d.ts.map +1 -0
- package/dist/primitives/string/evals/index.d.ts +6 -0
- package/dist/primitives/string/evals/index.d.ts.map +1 -0
- package/dist/primitives/string/evals/semanticallyEquals.evals.d.ts +7 -0
- package/dist/primitives/string/evals/semanticallyEquals.evals.d.ts.map +1 -0
- package/dist/primitives/string/index.d.ts +206 -0
- package/dist/primitives/string/index.d.ts.map +1 -0
- package/dist/primitives/string/string.prompts.d.ts +45 -0
- package/dist/primitives/string/string.prompts.d.ts.map +1 -0
- package/dist/primitives/symbol/index.d.ts +6 -0
- package/dist/primitives/symbol/index.d.ts.map +1 -0
- package/dist/primitives/symbol/symbol.d.ts +176 -0
- package/dist/primitives/symbol/symbol.d.ts.map +1 -0
- package/dist/primitives/symbol/symbol.prompts.d.ts +53 -0
- package/dist/primitives/symbol/symbol.prompts.d.ts.map +1 -0
- package/dist/primitives/undefined/index.d.ts +5 -0
- package/dist/primitives/undefined/index.d.ts.map +1 -0
- package/dist/primitives/undefined/prompts.d.ts +40 -0
- package/dist/primitives/undefined/prompts.d.ts.map +1 -0
- package/dist/primitives/undefined/undefined.d.ts +216 -0
- package/dist/primitives/undefined/undefined.d.ts.map +1 -0
- package/dist/primitives/void/index.d.ts +5 -0
- package/dist/primitives/void/index.d.ts.map +1 -0
- package/dist/primitives/void/prompts.d.ts +37 -0
- package/dist/primitives/void/prompts.d.ts.map +1 -0
- package/dist/primitives/void/void.d.ts +172 -0
- package/dist/primitives/void/void.d.ts.map +1 -0
- package/dist/shared/base-classes.d.ts +331 -0
- package/dist/shared/base-classes.d.ts.map +1 -0
- package/dist/shared/eval-types.d.ts +82 -0
- package/dist/shared/eval-types.d.ts.map +1 -0
- package/dist/shared/index.d.ts +25 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/interfaces.d.ts +799 -0
- package/dist/shared/interfaces.d.ts.map +1 -0
- package/dist/shared/types.d.ts +335 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/types/array/array.d.ts +250 -0
- package/dist/types/array/array.d.ts.map +1 -0
- package/dist/types/array/index.d.ts +6 -0
- package/dist/types/array/index.d.ts.map +1 -0
- package/dist/types/array/prompts.d.ts +63 -0
- package/dist/types/array/prompts.d.ts.map +1 -0
- package/dist/types/blob-file/blob.d.ts +188 -0
- package/dist/types/blob-file/blob.d.ts.map +1 -0
- package/dist/types/blob-file/file.d.ts +144 -0
- package/dist/types/blob-file/file.d.ts.map +1 -0
- package/dist/types/blob-file/index.d.ts +8 -0
- package/dist/types/blob-file/index.d.ts.map +1 -0
- package/dist/types/blob-file/prompts.d.ts +101 -0
- package/dist/types/blob-file/prompts.d.ts.map +1 -0
- package/dist/types/bun/bun.d.ts +266 -0
- package/dist/types/bun/bun.d.ts.map +1 -0
- package/dist/types/bun/index.d.ts +7 -0
- package/dist/types/bun/index.d.ts.map +1 -0
- package/dist/types/bun/prompts.d.ts +93 -0
- package/dist/types/bun/prompts.d.ts.map +1 -0
- package/dist/types/callable/callable.d.ts +200 -0
- package/dist/types/callable/callable.d.ts.map +1 -0
- package/dist/types/callable/index.d.ts +6 -0
- package/dist/types/callable/index.d.ts.map +1 -0
- package/dist/types/callable/prompts.d.ts +45 -0
- package/dist/types/callable/prompts.d.ts.map +1 -0
- package/dist/types/constructable/constructable.d.ts +150 -0
- package/dist/types/constructable/constructable.d.ts.map +1 -0
- package/dist/types/constructable/index.d.ts +5 -0
- package/dist/types/constructable/index.d.ts.map +1 -0
- package/dist/types/constructable/prompts.d.ts +41 -0
- package/dist/types/constructable/prompts.d.ts.map +1 -0
- package/dist/types/date/date.d.ts +258 -0
- package/dist/types/date/date.d.ts.map +1 -0
- package/dist/types/date/index.d.ts +6 -0
- package/dist/types/date/index.d.ts.map +1 -0
- package/dist/types/date/prompts.d.ts +93 -0
- package/dist/types/date/prompts.d.ts.map +1 -0
- package/dist/types/error/error.d.ts +191 -0
- package/dist/types/error/error.d.ts.map +1 -0
- package/dist/types/error/index.d.ts +6 -0
- package/dist/types/error/index.d.ts.map +1 -0
- package/dist/types/error/prompts.d.ts +49 -0
- package/dist/types/error/prompts.d.ts.map +1 -0
- package/dist/types/event-emitter/event-emitter.d.ts +230 -0
- package/dist/types/event-emitter/event-emitter.d.ts.map +1 -0
- package/dist/types/event-emitter/index.d.ts +6 -0
- package/dist/types/event-emitter/index.d.ts.map +1 -0
- package/dist/types/event-emitter/prompts.d.ts +51 -0
- package/dist/types/event-emitter/prompts.d.ts.map +1 -0
- package/dist/types/fetch/headers.d.ts +126 -0
- package/dist/types/fetch/headers.d.ts.map +1 -0
- package/dist/types/fetch/index.d.ts +9 -0
- package/dist/types/fetch/index.d.ts.map +1 -0
- package/dist/types/fetch/prompts.d.ts +139 -0
- package/dist/types/fetch/prompts.d.ts.map +1 -0
- package/dist/types/fetch/request.d.ts +188 -0
- package/dist/types/fetch/request.d.ts.map +1 -0
- package/dist/types/fetch/response.d.ts +155 -0
- package/dist/types/fetch/response.d.ts.map +1 -0
- package/dist/types/form-data/form-data.d.ts +277 -0
- package/dist/types/form-data/form-data.d.ts.map +1 -0
- package/dist/types/form-data/index.d.ts +7 -0
- package/dist/types/form-data/index.d.ts.map +1 -0
- package/dist/types/form-data/prompts.d.ts +80 -0
- package/dist/types/form-data/prompts.d.ts.map +1 -0
- package/dist/types/index.d.ts +29 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/map/index.d.ts +6 -0
- package/dist/types/map/index.d.ts.map +1 -0
- package/dist/types/map/map.d.ts +204 -0
- package/dist/types/map/map.d.ts.map +1 -0
- package/dist/types/map/prompts.d.ts +56 -0
- package/dist/types/map/prompts.d.ts.map +1 -0
- package/dist/types/never/index.d.ts +5 -0
- package/dist/types/never/index.d.ts.map +1 -0
- package/dist/types/never/never.d.ts +220 -0
- package/dist/types/never/never.d.ts.map +1 -0
- package/dist/types/never/prompts.d.ts +50 -0
- package/dist/types/never/prompts.d.ts.map +1 -0
- package/dist/types/object/index.d.ts +6 -0
- package/dist/types/object/index.d.ts.map +1 -0
- package/dist/types/object/object.d.ts +162 -0
- package/dist/types/object/object.d.ts.map +1 -0
- package/dist/types/object/prompts.d.ts +55 -0
- package/dist/types/object/prompts.d.ts.map +1 -0
- package/dist/types/object-literal/index.d.ts +6 -0
- package/dist/types/object-literal/index.d.ts.map +1 -0
- package/dist/types/object-literal/object-literal.d.ts +223 -0
- package/dist/types/object-literal/object-literal.d.ts.map +1 -0
- package/dist/types/object-literal/prompts.d.ts +49 -0
- package/dist/types/object-literal/prompts.d.ts.map +1 -0
- package/dist/types/promise/index.d.ts +6 -0
- package/dist/types/promise/index.d.ts.map +1 -0
- package/dist/types/promise/promise.d.ts +240 -0
- package/dist/types/promise/promise.d.ts.map +1 -0
- package/dist/types/promise/prompts.d.ts +45 -0
- package/dist/types/promise/prompts.d.ts.map +1 -0
- package/dist/types/record/index.d.ts +5 -0
- package/dist/types/record/index.d.ts.map +1 -0
- package/dist/types/record/prompts.d.ts +45 -0
- package/dist/types/record/prompts.d.ts.map +1 -0
- package/dist/types/record/record.d.ts +179 -0
- package/dist/types/record/record.d.ts.map +1 -0
- package/dist/types/regexp/index.d.ts +7 -0
- package/dist/types/regexp/index.d.ts.map +1 -0
- package/dist/types/regexp/prompts.d.ts +56 -0
- package/dist/types/regexp/prompts.d.ts.map +1 -0
- package/dist/types/regexp/regexp.d.ts +160 -0
- package/dist/types/regexp/regexp.d.ts.map +1 -0
- package/dist/types/set/index.d.ts +6 -0
- package/dist/types/set/index.d.ts.map +1 -0
- package/dist/types/set/prompts.d.ts +60 -0
- package/dist/types/set/prompts.d.ts.map +1 -0
- package/dist/types/set/set.d.ts +261 -0
- package/dist/types/set/set.d.ts.map +1 -0
- package/dist/types/streams/index.d.ts +8 -0
- package/dist/types/streams/index.d.ts.map +1 -0
- package/dist/types/streams/prompts.d.ts +53 -0
- package/dist/types/streams/prompts.d.ts.map +1 -0
- package/dist/types/streams/readable-stream.d.ts +148 -0
- package/dist/types/streams/readable-stream.d.ts.map +1 -0
- package/dist/types/streams/transform-stream.d.ts +67 -0
- package/dist/types/streams/transform-stream.d.ts.map +1 -0
- package/dist/types/streams/writable-stream.d.ts +111 -0
- package/dist/types/streams/writable-stream.d.ts.map +1 -0
- package/dist/types/text-codec/index.d.ts +12 -0
- package/dist/types/text-codec/index.d.ts.map +1 -0
- package/dist/types/text-codec/prompts.d.ts +79 -0
- package/dist/types/text-codec/prompts.d.ts.map +1 -0
- package/dist/types/text-codec/text-codec.d.ts +305 -0
- package/dist/types/text-codec/text-codec.d.ts.map +1 -0
- package/dist/types/tuple/index.d.ts +6 -0
- package/dist/types/tuple/index.d.ts.map +1 -0
- package/dist/types/tuple/prompts.d.ts +41 -0
- package/dist/types/tuple/prompts.d.ts.map +1 -0
- package/dist/types/tuple/tuple.d.ts +221 -0
- package/dist/types/tuple/tuple.d.ts.map +1 -0
- package/dist/types/unknown/index.d.ts +5 -0
- package/dist/types/unknown/index.d.ts.map +1 -0
- package/dist/types/unknown/prompts.d.ts +45 -0
- package/dist/types/unknown/prompts.d.ts.map +1 -0
- package/dist/types/unknown/unknown.d.ts +220 -0
- package/dist/types/unknown/unknown.d.ts.map +1 -0
- package/dist/types/url/index.d.ts +7 -0
- package/dist/types/url/index.d.ts.map +1 -0
- package/dist/types/url/prompts.d.ts +93 -0
- package/dist/types/url/prompts.d.ts.map +1 -0
- package/dist/types/url/url.d.ts +270 -0
- package/dist/types/url/url.d.ts.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticConstructable
|
|
3
|
+
* A constructor type with LLM-powered semantic understanding
|
|
4
|
+
*
|
|
5
|
+
* Implements shared interfaces:
|
|
6
|
+
* - Semantic<T> - Base semantic wrapper
|
|
7
|
+
* - Comparable<SemanticConstructable<T>> - Semantic equality comparison
|
|
8
|
+
*/
|
|
9
|
+
import type { LLMClient } from '../../llm/client.ts';
|
|
10
|
+
import type { SemanticEqualsResult, ValidateResult, DetectPatternResult, ImprovementSuggestion } from '../../shared/types.ts';
|
|
11
|
+
import type { Semantic } from '../../shared/interfaces.ts';
|
|
12
|
+
export type { SemanticEqualsResult, ValidateResult, DetectPatternResult, ImprovementSuggestion, } from '../../shared/types.ts';
|
|
13
|
+
/** Constructor type constraint - uses any[] to support constructors with typed parameters */
|
|
14
|
+
export type Constructor<T = unknown> = new (...args: any[]) => T;
|
|
15
|
+
/** Extended semantic equals result with instance differences */
|
|
16
|
+
export interface ConstructableSemanticEqualsResult extends SemanticEqualsResult {
|
|
17
|
+
instanceDifferences: string[];
|
|
18
|
+
}
|
|
19
|
+
/** Result of analyzing instance shape */
|
|
20
|
+
export interface InstanceShapeResult {
|
|
21
|
+
properties: Record<string, string>;
|
|
22
|
+
methods: string[];
|
|
23
|
+
instanceOf: string[];
|
|
24
|
+
}
|
|
25
|
+
/** Result of createValidated operation */
|
|
26
|
+
export type CreateValidatedResult<T> = {
|
|
27
|
+
success: true;
|
|
28
|
+
instance: T;
|
|
29
|
+
} | {
|
|
30
|
+
success: false;
|
|
31
|
+
errors: string[];
|
|
32
|
+
};
|
|
33
|
+
/** Documentation format options */
|
|
34
|
+
export type DocFormat = 'jsdoc' | 'markdown' | 'plain';
|
|
35
|
+
/**
|
|
36
|
+
* SemanticConstructable - Constructor with LLM-powered semantic understanding
|
|
37
|
+
*
|
|
38
|
+
* Wraps constructor functions/classes to enable semantic analysis,
|
|
39
|
+
* validation, and intelligent instantiation patterns.
|
|
40
|
+
*
|
|
41
|
+
* @template T - The constructor type
|
|
42
|
+
*/
|
|
43
|
+
export declare class SemanticConstructable<T extends Constructor> implements Semantic<T> {
|
|
44
|
+
private readonly ctor;
|
|
45
|
+
private readonly description?;
|
|
46
|
+
private readonly client;
|
|
47
|
+
private constructor();
|
|
48
|
+
/**
|
|
49
|
+
* Create a SemanticConstructable from a constructor function or class
|
|
50
|
+
*
|
|
51
|
+
* @param ctor - Constructor function/class to wrap
|
|
52
|
+
* @param description - Optional description of what the constructor creates
|
|
53
|
+
* @param client - Optional LLM client
|
|
54
|
+
* @returns SemanticConstructable wrapper
|
|
55
|
+
*/
|
|
56
|
+
static from<T extends Constructor>(ctor: T, description?: string, client?: LLMClient): SemanticConstructable<T>;
|
|
57
|
+
/**
|
|
58
|
+
* Get the underlying constructor
|
|
59
|
+
*/
|
|
60
|
+
valueOf(): T;
|
|
61
|
+
/**
|
|
62
|
+
* Get the constructor name
|
|
63
|
+
*/
|
|
64
|
+
get name(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Get the source representation of the constructor
|
|
67
|
+
*/
|
|
68
|
+
private getSource;
|
|
69
|
+
/**
|
|
70
|
+
* Check if an instance was created by this constructor
|
|
71
|
+
*
|
|
72
|
+
* @param instance - Instance to check
|
|
73
|
+
* @returns Whether it's an instance of this constructor
|
|
74
|
+
*/
|
|
75
|
+
isInstance(instance: unknown): instance is InstanceType<T>;
|
|
76
|
+
/**
|
|
77
|
+
* Create an instance using the constructor
|
|
78
|
+
*
|
|
79
|
+
* @param args - Constructor arguments
|
|
80
|
+
* @returns New instance
|
|
81
|
+
*/
|
|
82
|
+
create(...args: ConstructorParameters<T>): InstanceType<T>;
|
|
83
|
+
/**
|
|
84
|
+
* Create an instance with validation
|
|
85
|
+
*
|
|
86
|
+
* @param args - Constructor arguments
|
|
87
|
+
* @returns New instance or validation errors
|
|
88
|
+
*/
|
|
89
|
+
createValidated(...args: ConstructorParameters<T>): Promise<CreateValidatedResult<InstanceType<T>>>;
|
|
90
|
+
/**
|
|
91
|
+
* Check if two constructors create semantically equivalent instances
|
|
92
|
+
*
|
|
93
|
+
* @param other - Constructor to compare
|
|
94
|
+
* @param testArgs - Arguments to test with
|
|
95
|
+
* @returns Equivalence result
|
|
96
|
+
*/
|
|
97
|
+
semanticallyEquals(other: Constructor | SemanticConstructable<Constructor>, testArgs?: ConstructorParameters<T>[]): Promise<ConstructableSemanticEqualsResult>;
|
|
98
|
+
/**
|
|
99
|
+
* Validate constructor arguments
|
|
100
|
+
*
|
|
101
|
+
* @param args - Arguments to validate
|
|
102
|
+
* @param rules - Additional validation rules
|
|
103
|
+
* @returns Validation result
|
|
104
|
+
*/
|
|
105
|
+
validateArgs(args: ConstructorParameters<T>, rules?: string[]): Promise<ValidateResult>;
|
|
106
|
+
/**
|
|
107
|
+
* Analyze the shape of instances this constructor creates
|
|
108
|
+
*
|
|
109
|
+
* @returns Instance shape analysis
|
|
110
|
+
*/
|
|
111
|
+
analyzeInstanceShape(): Promise<InstanceShapeResult>;
|
|
112
|
+
/**
|
|
113
|
+
* Explain what this constructor creates
|
|
114
|
+
*
|
|
115
|
+
* @returns Human-readable explanation
|
|
116
|
+
*/
|
|
117
|
+
explain(): Promise<string>;
|
|
118
|
+
/**
|
|
119
|
+
* Detect design patterns used by this constructor
|
|
120
|
+
*
|
|
121
|
+
* @returns Detected patterns
|
|
122
|
+
*/
|
|
123
|
+
detectPatterns(): Promise<DetectPatternResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Generate documentation for this constructor
|
|
126
|
+
*
|
|
127
|
+
* @param format - Documentation format (jsdoc, markdown, or plain)
|
|
128
|
+
* @returns Generated documentation
|
|
129
|
+
*/
|
|
130
|
+
generateDocs(format?: DocFormat): Promise<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Suggest improvements for the constructor
|
|
133
|
+
*
|
|
134
|
+
* @returns Suggested improvements
|
|
135
|
+
*/
|
|
136
|
+
suggestImprovements(): Promise<ImprovementSuggestion[]>;
|
|
137
|
+
/**
|
|
138
|
+
* Convert to string representation
|
|
139
|
+
*/
|
|
140
|
+
toString(): string;
|
|
141
|
+
/**
|
|
142
|
+
* Convert to JSON representation
|
|
143
|
+
*/
|
|
144
|
+
toJSON(): {
|
|
145
|
+
name: string;
|
|
146
|
+
description?: string;
|
|
147
|
+
source: string;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=constructable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constructable.d.ts","sourceRoot":"","sources":["../../../src/types/constructable/constructable.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAY3D,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,6FAA6F;AAE7F,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEjE,gEAAgE;AAChE,MAAM,WAAW,iCAAkC,SAAQ,oBAAoB;IAC7E,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,yCAAyC;AACzC,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,0CAA0C;AAC1C,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAC/B;IAAE,OAA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D,QAAQ,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAAE,GACpC,OAAO,CAAC,iCAAiC,CAAC;IAqB7C;;;;;;OAMG;IACG,YAAY,CAChB,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAC9B,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,OAAO,CAAC,cAAc,CAAC;IAiB1B;;;;OAIG;IACG,oBAAoB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAe1D;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAiBhC;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAepD;;;;;OAKG;IACG,YAAY,CAAC,MAAM,GAAE,SAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBhE;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAgB7D;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,MAAM,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;CAOjE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticConstructable module exports
|
|
3
|
+
*/
|
|
4
|
+
export { SemanticConstructable, type Constructor, type ConstructableSemanticEqualsResult, type InstanceShapeResult, type CreateValidatedResult, type DocFormat, type SemanticEqualsResult, type ValidateResult, type DetectPatternResult, type ImprovementSuggestion, } from './constructable.ts';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/constructable/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,qBAAqB,EACrB,KAAK,WAAW,EAChB,KAAK,iCAAiC,EACtC,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,GAC3B,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticConstructable LLM operations
|
|
3
|
+
* These prompts enable semantic analysis of constructor functions and classes
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for constructable semantic operations
|
|
7
|
+
*/
|
|
8
|
+
export declare const CONSTRUCTABLE_SYSTEM_PROMPT = "You are a semantic constructor analyzer. Your task is to analyze JavaScript/TypeScript class constructors and provide semantic understanding.\n\nYou must respond with valid JSON only, no additional text or explanation.\n\nGuidelines:\n- Consider constructor signatures, parameter types, and instance shapes\n- Analyze design patterns, class relationships, and best practices\n- Provide confidence scores from 0.0 to 1.0\n- Be precise and consistent in your analysis";
|
|
9
|
+
/**
|
|
10
|
+
* Prompt for semantic equality comparison between constructors
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSemanticallyEqualsPrompt(ctor1Source: string, ctor1Name: string, ctor2Source: string, ctor2Name: string, testArgsStr?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Prompt for validating constructor arguments
|
|
15
|
+
*/
|
|
16
|
+
export declare function createValidateArgsPrompt(ctorSource: string, ctorName: string, argsStr: string, rules?: string[]): string;
|
|
17
|
+
/**
|
|
18
|
+
* Prompt for analyzing instance shape
|
|
19
|
+
*/
|
|
20
|
+
export declare function createAnalyzeInstanceShapePrompt(ctorSource: string, ctorName: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Prompt for explaining what a constructor creates
|
|
23
|
+
*/
|
|
24
|
+
export declare function createExplainPrompt(ctorSource: string, ctorName: string, description?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Prompt for detecting design patterns
|
|
27
|
+
*/
|
|
28
|
+
export declare function createDetectPatternsPrompt(ctorSource: string, ctorName: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Prompt for generating documentation
|
|
31
|
+
*/
|
|
32
|
+
export declare function createGenerateDocsPrompt(ctorSource: string, ctorName: string, format: 'jsdoc' | 'markdown' | 'plain'): string;
|
|
33
|
+
/**
|
|
34
|
+
* Prompt for suggesting improvements
|
|
35
|
+
*/
|
|
36
|
+
export declare function createSuggestImprovementsPrompt(ctorSource: string, ctorName: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Prompt for validating instance type
|
|
39
|
+
*/
|
|
40
|
+
export declare function createIsInstancePrompt(ctorSource: string, ctorName: string, instanceStr: string): string;
|
|
41
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/constructable/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,2BAA2B,sdAQK,CAAC;AAE9C;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CA8BR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,MAAM,CA6BR;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,MAAM,CAoBR;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAyBR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,MAAM,CAuBR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,GACrC,MAAM,CAwBR;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,MAAM,CAwBR;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,MAAM,CAoBR"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticDate - LLM-enhanced date type with semantic understanding
|
|
3
|
+
*
|
|
4
|
+
* Extends the native JavaScript Date with semantic operations including:
|
|
5
|
+
* - Natural language date parsing
|
|
6
|
+
* - Context-aware equality comparison
|
|
7
|
+
* - Intelligent formatting for different contexts
|
|
8
|
+
* - Period membership checking
|
|
9
|
+
* - Semantic duration calculations
|
|
10
|
+
* - Meaning inference
|
|
11
|
+
*
|
|
12
|
+
* Implements shared interfaces:
|
|
13
|
+
* - Semantic<Date> - Base semantic wrapper
|
|
14
|
+
* - Comparable<Date | SemanticDate> - Semantic equality comparison
|
|
15
|
+
* - ContextValidatable - Reasonableness checks
|
|
16
|
+
* - Describable - Human-friendly descriptions
|
|
17
|
+
*/
|
|
18
|
+
import type { LLMConfig, Message } from '../../llm/types.ts';
|
|
19
|
+
import type { SemanticEqualsResult, ReasonableResult, DurationResult, InferMeaningResult } from '../../shared/types.ts';
|
|
20
|
+
import type { Semantic, Comparable, ContextValidatable, Describable } from '../../shared/interfaces.ts';
|
|
21
|
+
export type { SemanticEqualsResult, ReasonableResult, DurationResult, InferMeaningResult, } from '../../shared/types.ts';
|
|
22
|
+
/** Options for date parsing */
|
|
23
|
+
export interface ParseDateOptions {
|
|
24
|
+
referenceDate?: Date;
|
|
25
|
+
timezone?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Precision levels for date comparison */
|
|
28
|
+
export type DatePrecision = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'exact';
|
|
29
|
+
/** Options for semantic date equals comparison */
|
|
30
|
+
export interface DateSemanticEqualsOptions {
|
|
31
|
+
precision?: DatePrecision;
|
|
32
|
+
}
|
|
33
|
+
/** LLM client interface for dependency injection */
|
|
34
|
+
export interface DateLLMClientInterface {
|
|
35
|
+
chat(options: {
|
|
36
|
+
messages: Message[];
|
|
37
|
+
systemPrompt?: string;
|
|
38
|
+
} & LLMConfig): Promise<{
|
|
39
|
+
content: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* SemanticDate class
|
|
44
|
+
* Wraps a Date value with LLM-powered semantic operations
|
|
45
|
+
*
|
|
46
|
+
* Implements:
|
|
47
|
+
* - Semantic<Date> - valueOf() returns the date value
|
|
48
|
+
* - Comparable<Date | SemanticDate> - semanticallyEquals() for comparison
|
|
49
|
+
* - ContextValidatable - isReasonable() for context-aware validation
|
|
50
|
+
* - Describable - describe() for human-friendly descriptions
|
|
51
|
+
*/
|
|
52
|
+
export declare class SemanticDate implements Semantic<Date>, Comparable<Date | SemanticDate>, ContextValidatable, Describable {
|
|
53
|
+
private readonly _value;
|
|
54
|
+
private readonly _llmClient;
|
|
55
|
+
private readonly _llmConfig?;
|
|
56
|
+
/**
|
|
57
|
+
* Create a SemanticDate instance
|
|
58
|
+
* @param value - The Date value to wrap
|
|
59
|
+
* @param llmClient - Optional LLM client for dependency injection (useful for testing)
|
|
60
|
+
* @param llmConfig - Optional LLM configuration
|
|
61
|
+
*/
|
|
62
|
+
constructor(value: Date, llmClient?: DateLLMClientInterface, llmConfig?: LLMConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Parse a date from natural language
|
|
65
|
+
* Understands relative expressions, cultural references, and various formats
|
|
66
|
+
*
|
|
67
|
+
* @param input - Natural language date expression
|
|
68
|
+
* @param options - Parsing options including reference date and timezone
|
|
69
|
+
* @param llmClient - Optional LLM client for dependency injection
|
|
70
|
+
* @param llmConfig - Optional LLM configuration
|
|
71
|
+
* @returns SemanticDate instance
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* SemanticDate.from("next Friday")
|
|
75
|
+
* SemanticDate.from("two weeks ago")
|
|
76
|
+
* SemanticDate.from("the day after tomorrow")
|
|
77
|
+
* SemanticDate.from("Q4 2024")
|
|
78
|
+
*/
|
|
79
|
+
static from(input: string | Date, options?: ParseDateOptions, llmClient?: DateLLMClientInterface, llmConfig?: LLMConfig): Promise<SemanticDate>;
|
|
80
|
+
/**
|
|
81
|
+
* Check if two dates are semantically equivalent
|
|
82
|
+
* Considers precision level (day vs exact time)
|
|
83
|
+
*
|
|
84
|
+
* @param other - Date to compare with
|
|
85
|
+
* @param options - Comparison options with optional precision (default: "day")
|
|
86
|
+
* @returns Equivalence result with confidence
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* date1.semanticallyEquals(date2, { precision: "day" })
|
|
90
|
+
* // Same day regardless of time
|
|
91
|
+
*/
|
|
92
|
+
semanticallyEquals(other: Date | SemanticDate, options?: Record<string, unknown>): Promise<SemanticEqualsResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Describe the date in natural language relative to now
|
|
95
|
+
*
|
|
96
|
+
* @param context - Optional context for description (e.g., "relative", "absolute", or custom context)
|
|
97
|
+
* @returns Human-readable description
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* date.describe()
|
|
101
|
+
* // "3 days ago" or "next Tuesday" or "in 2 weeks"
|
|
102
|
+
*/
|
|
103
|
+
describe(context?: string): Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* Format the date for a specific context or audience
|
|
106
|
+
*
|
|
107
|
+
* @param context - Formatting context
|
|
108
|
+
* @returns Formatted date string
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* date.formatFor("formal business document") // "January 15, 2024"
|
|
112
|
+
* date.formatFor("casual chat") // "Jan 15"
|
|
113
|
+
* date.formatFor("API response") // "2024-01-15T00:00:00Z"
|
|
114
|
+
*/
|
|
115
|
+
formatFor(context: string): Promise<string>;
|
|
116
|
+
/**
|
|
117
|
+
* Check if the date falls within a semantic time period
|
|
118
|
+
*
|
|
119
|
+
* @param period - Natural language period description
|
|
120
|
+
* @returns Whether date is in period
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* date.isIn("this week")
|
|
124
|
+
* date.isIn("business hours")
|
|
125
|
+
* date.isIn("holiday season")
|
|
126
|
+
*/
|
|
127
|
+
isIn(period: string): Promise<boolean>;
|
|
128
|
+
/**
|
|
129
|
+
* Get the next occurrence of a semantic event
|
|
130
|
+
*
|
|
131
|
+
* @param event - Event description
|
|
132
|
+
* @returns Next occurrence as SemanticDate
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* date.next("Monday")
|
|
136
|
+
* date.next("business day")
|
|
137
|
+
* date.next("end of month")
|
|
138
|
+
*/
|
|
139
|
+
next(event: string): Promise<SemanticDate>;
|
|
140
|
+
/**
|
|
141
|
+
* Get the previous occurrence of a semantic event
|
|
142
|
+
*
|
|
143
|
+
* @param event - Event description
|
|
144
|
+
* @returns Previous occurrence as SemanticDate
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* date.previous("payday")
|
|
148
|
+
* date.previous("quarter start")
|
|
149
|
+
*/
|
|
150
|
+
previous(event: string): Promise<SemanticDate>;
|
|
151
|
+
/**
|
|
152
|
+
* Calculate semantic duration to another date
|
|
153
|
+
*
|
|
154
|
+
* @param other - Target date
|
|
155
|
+
* @returns Human-readable duration with day counts
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* startDate.durationTo(endDate)
|
|
159
|
+
* // { description: "about 2 weeks", days: 14, businessDays: 10 }
|
|
160
|
+
*/
|
|
161
|
+
durationTo(other: Date | SemanticDate): Promise<DurationResult>;
|
|
162
|
+
/**
|
|
163
|
+
* Validate if the date is reasonable for a context
|
|
164
|
+
*
|
|
165
|
+
* @param context - Context for validation
|
|
166
|
+
* @returns Validation result with reason
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* date.isReasonable("birth date")
|
|
170
|
+
* // { reasonable: false, reason: "Date is in the future" }
|
|
171
|
+
*/
|
|
172
|
+
isReasonable(context: string): Promise<ReasonableResult>;
|
|
173
|
+
/**
|
|
174
|
+
* Add a semantic duration to the date
|
|
175
|
+
*
|
|
176
|
+
* @param duration - Natural language duration
|
|
177
|
+
* @returns New SemanticDate
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* date.add("2 business days")
|
|
181
|
+
* date.add("1 quarter")
|
|
182
|
+
*/
|
|
183
|
+
add(duration: string): Promise<SemanticDate>;
|
|
184
|
+
/**
|
|
185
|
+
* Infer what this date likely represents
|
|
186
|
+
*
|
|
187
|
+
* @param context - Additional context
|
|
188
|
+
* @returns Inferred meaning with type and confidence
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* SemanticDate.from("2024-12-25").inferMeaning()
|
|
192
|
+
* // { meaning: "Christmas Day", type: "holiday", confidence: 0.98 }
|
|
193
|
+
*/
|
|
194
|
+
inferMeaning(context?: string): Promise<InferMeaningResult>;
|
|
195
|
+
/**
|
|
196
|
+
* Get the raw Date value
|
|
197
|
+
* @returns The underlying Date
|
|
198
|
+
*/
|
|
199
|
+
valueOf(): Date;
|
|
200
|
+
/**
|
|
201
|
+
* Explain the date in a human-readable way.
|
|
202
|
+
* Implements Explainable interface.
|
|
203
|
+
*
|
|
204
|
+
* @param context - Optional context for the explanation
|
|
205
|
+
* @returns Human-readable explanation
|
|
206
|
+
*/
|
|
207
|
+
explain(context?: string): Promise<string>;
|
|
208
|
+
/**
|
|
209
|
+
* Get the underlying Date's getTime() value
|
|
210
|
+
* @returns Milliseconds since epoch
|
|
211
|
+
*/
|
|
212
|
+
getTime(): number;
|
|
213
|
+
/**
|
|
214
|
+
* Convert to ISO string
|
|
215
|
+
*/
|
|
216
|
+
toISOString(): string;
|
|
217
|
+
/**
|
|
218
|
+
* Convert to string
|
|
219
|
+
*/
|
|
220
|
+
toString(): string;
|
|
221
|
+
/**
|
|
222
|
+
* Convert to JSON (ISO string)
|
|
223
|
+
*/
|
|
224
|
+
toJSON(): string;
|
|
225
|
+
/**
|
|
226
|
+
* Get the year
|
|
227
|
+
*/
|
|
228
|
+
getFullYear(): number;
|
|
229
|
+
/**
|
|
230
|
+
* Get the month (0-11)
|
|
231
|
+
*/
|
|
232
|
+
getMonth(): number;
|
|
233
|
+
/**
|
|
234
|
+
* Get the day of month (1-31)
|
|
235
|
+
*/
|
|
236
|
+
getDate(): number;
|
|
237
|
+
/**
|
|
238
|
+
* Get the day of week (0-6, Sunday = 0)
|
|
239
|
+
*/
|
|
240
|
+
getDay(): number;
|
|
241
|
+
/**
|
|
242
|
+
* Get the hours (0-23)
|
|
243
|
+
*/
|
|
244
|
+
getHours(): number;
|
|
245
|
+
/**
|
|
246
|
+
* Get the minutes (0-59)
|
|
247
|
+
*/
|
|
248
|
+
getMinutes(): number;
|
|
249
|
+
/**
|
|
250
|
+
* Get the seconds (0-59)
|
|
251
|
+
*/
|
|
252
|
+
getSeconds(): number;
|
|
253
|
+
/**
|
|
254
|
+
* Get the milliseconds (0-999)
|
|
255
|
+
*/
|
|
256
|
+
getMilliseconds(): number;
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/types/date/date.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAC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C,MAAM,CAAC;IAQhD;;;OAGG;IACH,OAAO,IAAI,MAAM;IAIjB;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,MAAM,IAAI,MAAM;IAIhB;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,OAAO,IAAI,MAAM;IAIjB;;OAEG;IACH,MAAM,IAAI,MAAM;IAIhB;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;OAEG;IACH,eAAe,IAAI,MAAM;CAG1B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticDate module
|
|
3
|
+
* LLM-enhanced date type with semantic understanding
|
|
4
|
+
*/
|
|
5
|
+
export { SemanticDate, type ParseDateOptions, type DatePrecision, type DateSemanticEqualsOptions, type DateLLMClientInterface, type SemanticEqualsResult, type ReasonableResult, type DurationResult, type InferMeaningResult, } from './date.ts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/date/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticDate LLM operations
|
|
3
|
+
* These prompts are used for various semantic date operations that require LLM understanding
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for date parsing operations
|
|
7
|
+
*/
|
|
8
|
+
export declare const PARSE_DATE_SYSTEM = "You are a date parsing assistant. Your task is to extract dates from natural language expressions.\n\nRules:\n- Parse relative expressions (e.g., \"next Friday\", \"two weeks ago\", \"the day after tomorrow\")\n- Parse quarter references (e.g., \"Q4 2024\", \"end of Q1\")\n- Parse semantic expressions (e.g., \"Thanksgiving 2024\", \"next Christmas\")\n- Use the reference date provided to resolve relative expressions\n- Return dates in ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ)\n- If timezone is provided, adjust accordingly\n- Return null if the input cannot be parsed as a date\n\nAlways respond with valid JSON only.";
|
|
9
|
+
/**
|
|
10
|
+
* User prompt template for parsing dates
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseDatePrompt(input: string, referenceDate: string, timezone?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* System prompt for semantic equality comparison
|
|
15
|
+
*/
|
|
16
|
+
export declare const SEMANTIC_EQUALS_SYSTEM = "You are a date comparison assistant. Your task is to determine if two dates are semantically equivalent at a specified precision level.\n\nPrecision levels:\n- \"year\": Same year\n- \"month\": Same year and month\n- \"day\": Same calendar day\n- \"hour\": Same day and hour\n- \"minute\": Same day, hour, and minute\n- \"exact\": Exact timestamp match\n\nAlways respond with valid JSON only.";
|
|
17
|
+
/**
|
|
18
|
+
* User prompt template for semantic date equality
|
|
19
|
+
*/
|
|
20
|
+
export declare function semanticEqualsPrompt(date1: string, date2: string, precision: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* System prompt for date description
|
|
23
|
+
*/
|
|
24
|
+
export declare const DESCRIBE_DATE_SYSTEM = "You are a date description assistant. Your task is to describe dates in natural language.\n\nStyles:\n- \"relative\": Express relative to now (e.g., \"3 days ago\", \"in 2 weeks\")\n- \"absolute\": Full date format (e.g., \"January 15, 2024\")\n- \"smart\": Choose the most natural expression based on proximity to now\n\nAlways respond with valid JSON only.";
|
|
25
|
+
/**
|
|
26
|
+
* User prompt template for describing dates
|
|
27
|
+
*/
|
|
28
|
+
export declare function describeDatePrompt(date: string, referenceDate: string, style: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* System prompt for date formatting
|
|
31
|
+
*/
|
|
32
|
+
export declare const FORMAT_DATE_SYSTEM = "You are a date formatting assistant. Your task is to format dates appropriately for different contexts.\n\nConsider:\n- Formal contexts: Use full date formats (e.g., \"January 15, 2024\")\n- Casual contexts: Use abbreviated formats (e.g., \"Jan 15\")\n- API contexts: Use ISO 8601 format (e.g., \"2024-01-15T00:00:00Z\")\n- International contexts: Be aware of locale differences (DD/MM vs MM/DD)\n\nAlways respond with valid JSON only.";
|
|
33
|
+
/**
|
|
34
|
+
* User prompt template for formatting dates
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatDatePrompt(date: string, context: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* System prompt for period checking
|
|
39
|
+
*/
|
|
40
|
+
export declare const IS_IN_PERIOD_SYSTEM = "You are a date period assistant. Your task is to determine if a date falls within a semantic time period.\n\nHandle:\n- Calendar periods: \"this week\", \"last month\", \"Q4\"\n- Business periods: \"business hours\", \"weekend\"\n- Cultural periods: \"holiday season\", \"summer\"\n- Custom periods: Any natural language period description\n\nAlways respond with valid JSON only.";
|
|
41
|
+
/**
|
|
42
|
+
* User prompt template for period checking
|
|
43
|
+
*/
|
|
44
|
+
export declare function isInPeriodPrompt(date: string, period: string, referenceDate: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* System prompt for finding next occurrence
|
|
47
|
+
*/
|
|
48
|
+
export declare const NEXT_OCCURRENCE_SYSTEM = "You are a date calculation assistant. Your task is to find the next occurrence of a semantic event from a given date.\n\nHandle:\n- Days of week: \"Monday\", \"Friday\"\n- Business events: \"business day\", \"end of month\", \"payday\"\n- Calendar events: \"quarter start\", \"end of year\"\n- Holidays: \"Christmas\", \"Thanksgiving\"\n\nAlways respond with valid JSON only.";
|
|
49
|
+
/**
|
|
50
|
+
* User prompt template for next occurrence
|
|
51
|
+
*/
|
|
52
|
+
export declare function nextOccurrencePrompt(date: string, event: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* System prompt for finding previous occurrence
|
|
55
|
+
*/
|
|
56
|
+
export declare const PREVIOUS_OCCURRENCE_SYSTEM = "You are a date calculation assistant. Your task is to find the previous occurrence of a semantic event before a given date.\n\nHandle:\n- Days of week: \"Monday\", \"Friday\"\n- Business events: \"business day\", \"payday\", \"quarter start\"\n- Calendar events: \"end of month\", \"start of year\"\n- Holidays: \"Christmas\", \"Thanksgiving\"\n\nAlways respond with valid JSON only.";
|
|
57
|
+
/**
|
|
58
|
+
* User prompt template for previous occurrence
|
|
59
|
+
*/
|
|
60
|
+
export declare function previousOccurrencePrompt(date: string, event: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* System prompt for duration calculation
|
|
63
|
+
*/
|
|
64
|
+
export declare const DURATION_SYSTEM = "You are a duration calculation assistant. Your task is to calculate and describe the duration between two dates.\n\nProvide:\n- Human-readable description (e.g., \"about 2 weeks\")\n- Exact number of days\n- Number of business days (excluding weekends)\n\nAlways respond with valid JSON only.";
|
|
65
|
+
/**
|
|
66
|
+
* User prompt template for duration calculation
|
|
67
|
+
*/
|
|
68
|
+
export declare function durationPrompt(startDate: string, endDate: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* System prompt for reasonableness validation
|
|
71
|
+
*/
|
|
72
|
+
export declare const IS_REASONABLE_SYSTEM = "You are a date validation assistant. Your task is to determine if a date is reasonable for a given context.\n\nConsider:\n- Birth dates: Should be in the past, within human lifespan\n- Future events: Should not be too far in the future for certain contexts\n- Historical events: Should match known historical timelines\n- Domain-specific constraints: e.g., employment start dates, graduation dates\n\nAlways respond with valid JSON only.";
|
|
73
|
+
/**
|
|
74
|
+
* User prompt template for reasonableness check
|
|
75
|
+
*/
|
|
76
|
+
export declare function isReasonablePrompt(date: string, context: string, referenceDate: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* System prompt for adding duration
|
|
79
|
+
*/
|
|
80
|
+
export declare const ADD_DURATION_SYSTEM = "You are a date arithmetic assistant. Your task is to add a semantic duration to a date.\n\nHandle:\n- Standard durations: \"2 days\", \"3 weeks\", \"1 month\"\n- Business durations: \"2 business days\", \"next business week\"\n- Semantic durations: \"1 quarter\", \"half a year\"\n\nAlways respond with valid JSON only.";
|
|
81
|
+
/**
|
|
82
|
+
* User prompt template for adding duration
|
|
83
|
+
*/
|
|
84
|
+
export declare function addDurationPrompt(date: string, duration: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* System prompt for meaning inference
|
|
87
|
+
*/
|
|
88
|
+
export declare const INFER_MEANING_SYSTEM = "You are a date meaning assistant. Your task is to infer what a specific date likely represents.\n\nConsider:\n- Holidays: Christmas (Dec 25), Thanksgiving (4th Thursday of Nov), etc.\n- Cultural events: New Year's Day, Independence Day\n- Religious observances: Easter, Hanukkah\n- Business events: Tax day, fiscal year end\n\nAlways respond with valid JSON only.";
|
|
89
|
+
/**
|
|
90
|
+
* User prompt template for meaning inference
|
|
91
|
+
*/
|
|
92
|
+
export declare function inferMeaningPrompt(date: string, context?: string): string;
|
|
93
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/date/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB,onBAWO,CAAC;AAEtC;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CASR;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,6YAUE,CAAC;AAEtC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,MAAM,CASR;AAED;;GAEG;AACH,eAAO,MAAM,oBA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