@polintpro/proposit-core 0.5.3 → 0.5.8
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/README.md +172 -1
- package/dist/cli/commands/arguments.d.ts.map +1 -1
- package/dist/cli/commands/arguments.js +33 -5
- package/dist/cli/commands/arguments.js.map +1 -1
- package/dist/cli/commands/claims.d.ts +3 -0
- package/dist/cli/commands/claims.d.ts.map +1 -0
- package/dist/cli/commands/claims.js +120 -0
- package/dist/cli/commands/claims.js.map +1 -0
- package/dist/cli/commands/parse.d.ts +3 -0
- package/dist/cli/commands/parse.d.ts.map +1 -0
- package/dist/cli/commands/parse.js +159 -0
- package/dist/cli/commands/parse.js.map +1 -0
- package/dist/cli/commands/render.d.ts.map +1 -1
- package/dist/cli/commands/render.js +77 -4
- package/dist/cli/commands/render.js.map +1 -1
- package/dist/cli/commands/sources.d.ts +1 -1
- package/dist/cli/commands/sources.d.ts.map +1 -1
- package/dist/cli/commands/sources.js +83 -45
- package/dist/cli/commands/sources.js.map +1 -1
- package/dist/cli/config.d.ts +1 -0
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +3 -0
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/engine.d.ts +14 -1
- package/dist/cli/engine.d.ts.map +1 -1
- package/dist/cli/engine.js +45 -2
- package/dist/cli/engine.js.map +1 -1
- package/dist/cli/import.d.ts +9 -1
- package/dist/cli/import.d.ts.map +1 -1
- package/dist/cli/import.js +22 -4
- package/dist/cli/import.js.map +1 -1
- package/dist/cli/llm/index.d.ts +6 -0
- package/dist/cli/llm/index.d.ts.map +1 -0
- package/dist/cli/llm/index.js +26 -0
- package/dist/cli/llm/index.js.map +1 -0
- package/dist/cli/llm/openai.d.ts +4 -0
- package/dist/cli/llm/openai.d.ts.map +1 -0
- package/dist/cli/llm/openai.js +44 -0
- package/dist/cli/llm/openai.js.map +1 -0
- package/dist/cli/llm/types.d.ts +14 -0
- package/dist/cli/llm/types.d.ts.map +1 -0
- package/dist/cli/llm/types.js +2 -0
- package/dist/cli/llm/types.js.map +1 -0
- package/dist/cli/logging.d.ts +8 -0
- package/dist/cli/logging.d.ts.map +1 -0
- package/dist/cli/logging.js +23 -0
- package/dist/cli/logging.js.map +1 -0
- package/dist/cli/router.d.ts.map +1 -1
- package/dist/cli/router.js +2 -0
- package/dist/cli/router.js.map +1 -1
- package/dist/cli/storage/libraries.d.ts +11 -0
- package/dist/cli/storage/libraries.d.ts.map +1 -0
- package/dist/cli/storage/libraries.js +61 -0
- package/dist/cli/storage/libraries.js.map +1 -0
- package/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/extensions/basics/argument-parser.d.ts +12 -0
- package/dist/extensions/basics/argument-parser.d.ts.map +1 -0
- package/dist/extensions/basics/argument-parser.js +27 -0
- package/dist/extensions/basics/argument-parser.js.map +1 -0
- package/dist/extensions/basics/index.d.ts +4 -0
- package/dist/extensions/basics/index.d.ts.map +1 -0
- package/dist/extensions/basics/index.js +3 -0
- package/dist/extensions/basics/index.js.map +1 -0
- package/dist/extensions/basics/schemata.d.ts +31 -0
- package/dist/extensions/basics/schemata.d.ts.map +1 -0
- package/dist/extensions/basics/schemata.js +55 -0
- package/dist/extensions/basics/schemata.js.map +1 -0
- package/dist/lib/core/argument-engine.d.ts +5 -2
- package/dist/lib/core/argument-engine.d.ts.map +1 -1
- package/dist/lib/core/argument-engine.js +20 -24
- package/dist/lib/core/argument-engine.js.map +1 -1
- package/dist/lib/core/claim-library.d.ts +2 -2
- package/dist/lib/core/claim-library.d.ts.map +1 -1
- package/dist/lib/core/claim-source-library.d.ts +2 -2
- package/dist/lib/core/claim-source-library.d.ts.map +1 -1
- package/dist/lib/core/expression-manager.d.ts +25 -2
- package/dist/lib/core/expression-manager.d.ts.map +1 -1
- package/dist/lib/core/expression-manager.js +211 -4
- package/dist/lib/core/expression-manager.js.map +1 -1
- package/dist/lib/core/interfaces/index.d.ts +1 -1
- package/dist/lib/core/interfaces/index.d.ts.map +1 -1
- package/dist/lib/core/interfaces/library.interfaces.d.ts +243 -14
- package/dist/lib/core/interfaces/library.interfaces.d.ts.map +1 -1
- package/dist/lib/core/interfaces/premise-engine.interfaces.d.ts +38 -0
- package/dist/lib/core/interfaces/premise-engine.interfaces.d.ts.map +1 -1
- package/dist/lib/core/parser/formula-gen.js +120 -47
- package/dist/lib/core/premise-engine.d.ts +8 -1
- package/dist/lib/core/premise-engine.d.ts.map +1 -1
- package/dist/lib/core/premise-engine.js +90 -21
- package/dist/lib/core/premise-engine.js.map +1 -1
- package/dist/lib/core/source-library.d.ts +2 -2
- package/dist/lib/core/source-library.d.ts.map +1 -1
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/parsing/argument-parser.d.ts +47 -0
- package/dist/lib/parsing/argument-parser.d.ts.map +1 -0
- package/dist/lib/parsing/argument-parser.js +307 -0
- package/dist/lib/parsing/argument-parser.js.map +1 -0
- package/dist/lib/parsing/index.d.ts +7 -0
- package/dist/lib/parsing/index.d.ts.map +1 -0
- package/dist/lib/parsing/index.js +4 -0
- package/dist/lib/parsing/index.js.map +1 -0
- package/dist/lib/parsing/prompt-builder.d.ts +11 -0
- package/dist/lib/parsing/prompt-builder.d.ts.map +1 -0
- package/dist/lib/parsing/prompt-builder.js +192 -0
- package/dist/lib/parsing/prompt-builder.js.map +1 -0
- package/dist/lib/parsing/schemata.d.ts +77 -0
- package/dist/lib/parsing/schemata.d.ts.map +1 -0
- package/dist/lib/parsing/schemata.js +88 -0
- package/dist/lib/parsing/schemata.js.map +1 -0
- package/dist/lib/parsing/types.d.ts +13 -0
- package/dist/lib/parsing/types.d.ts.map +1 -0
- package/dist/lib/parsing/types.js +2 -0
- package/dist/lib/parsing/types.js.map +1 -0
- package/dist/lib/types/grammar.d.ts +31 -0
- package/dist/lib/types/grammar.d.ts.map +1 -0
- package/dist/lib/types/grammar.js +11 -0
- package/dist/lib/types/grammar.js.map +1 -0
- package/package.json +5 -1
- package/dist/cli/storage/sources.d.ts +0 -4
- package/dist/cli/storage/sources.d.ts.map +0 -1
- package/dist/cli/storage/sources.js +0 -22
- package/dist/cli/storage/sources.js.map +0 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core property keys for each sub-schema in the parsed argument response.
|
|
3
|
+
* Used to distinguish extension fields from built-in fields.
|
|
4
|
+
*/
|
|
5
|
+
const CORE_CLAIM_KEYS = new Set(["miniId", "role", "sourceMiniIds"]);
|
|
6
|
+
const CORE_VARIABLE_KEYS = new Set(["miniId", "symbol", "claimMiniId"]);
|
|
7
|
+
const CORE_SOURCE_KEYS = new Set(["miniId", "text"]);
|
|
8
|
+
const CORE_PREMISE_KEYS = new Set(["miniId", "formula"]);
|
|
9
|
+
const CORE_ARGUMENT_KEYS = new Set([
|
|
10
|
+
"claims",
|
|
11
|
+
"variables",
|
|
12
|
+
"sources",
|
|
13
|
+
"premises",
|
|
14
|
+
"conclusionPremiseMiniId",
|
|
15
|
+
]);
|
|
16
|
+
const CORE_RESPONSE_KEYS = new Set([
|
|
17
|
+
"argument",
|
|
18
|
+
"uncategorizedText",
|
|
19
|
+
"selectionRationale",
|
|
20
|
+
"failureText",
|
|
21
|
+
]);
|
|
22
|
+
const CORE_PROMPT = `You are an expert argument analyst specializing in propositional logic. Your task is to analyze text and extract a structured propositional argument from it.
|
|
23
|
+
|
|
24
|
+
## Task
|
|
25
|
+
|
|
26
|
+
Given input text, identify:
|
|
27
|
+
1. The distinct claims (propositions) being made
|
|
28
|
+
2. Assign a variable (a short symbolic name) to each claim, one variable per claim
|
|
29
|
+
3. Write logical formula strings connecting those variables into premises
|
|
30
|
+
4. Identify which premise is the conclusion
|
|
31
|
+
|
|
32
|
+
## Formula Syntax
|
|
33
|
+
|
|
34
|
+
Formulas use infix notation with the following operators:
|
|
35
|
+
|
|
36
|
+
- **and**: logical conjunction (A and B)
|
|
37
|
+
- **or**: logical disjunction (A or B)
|
|
38
|
+
- **not**: logical negation (not A)
|
|
39
|
+
- **implies**: logical implication (A implies B)
|
|
40
|
+
- **iff**: logical biconditional (A iff B)
|
|
41
|
+
- **parentheses**: for grouping sub-expressions, e.g. (A or B) and C
|
|
42
|
+
|
|
43
|
+
### Root-Only Operators
|
|
44
|
+
|
|
45
|
+
The operators **implies** and **iff** must appear ONLY at the root level of a formula. They cannot be nested inside other operators. For example:
|
|
46
|
+
- Valid: "A implies B"
|
|
47
|
+
- Valid: "A and B"
|
|
48
|
+
- Invalid: "(A implies B) and C" — implies is nested, not at root
|
|
49
|
+
|
|
50
|
+
If you need to express a nested conditional, introduce an intermediate claim and a separate premise.
|
|
51
|
+
|
|
52
|
+
## Response Structure
|
|
53
|
+
|
|
54
|
+
Your response must conform to the provided JSON schema. Key fields:
|
|
55
|
+
|
|
56
|
+
- **argument**: The parsed argument object, or null if the text cannot be parsed as an argument
|
|
57
|
+
- **uncategorizedText**: Any portions of the input text that do not fit into the argument structure, or null
|
|
58
|
+
- **selectionRationale**: If the text contains multiple potential arguments, explain why you chose the one you did, or null
|
|
59
|
+
- **failureText**: If the argument cannot be parsed, explain why here, or null
|
|
60
|
+
|
|
61
|
+
## Edge Cases
|
|
62
|
+
|
|
63
|
+
- If the input text contains multiple distinct arguments, select the strongest or most complete one and explain your choice in selectionRationale.
|
|
64
|
+
- If the input text cannot be reasonably interpreted as a propositional argument, set argument to null and provide an explanation in failureText.
|
|
65
|
+
- If portions of the text are tangential or do not contribute to the argument, capture them in uncategorizedText.
|
|
66
|
+
|
|
67
|
+
## Variable Symbols
|
|
68
|
+
|
|
69
|
+
Each variable symbol should be a concise PascalCase summary of the claim it represents — short enough to scan at a glance, but specific enough to distinguish from other variables. Examples:
|
|
70
|
+
|
|
71
|
+
| Claim | Good symbol | Bad symbol |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| "The GDP grew an average of 4% every year for the past decade" | GDP_Growth | G |
|
|
74
|
+
| "Unrestricted free speech leads to the spread of misinformation" | FreeSpeech_Misinformation | Variable1 |
|
|
75
|
+
| "Increased funding reduces classroom overcrowding" | Funding_Reduces_Overcrowding | FundingEffect |
|
|
76
|
+
|
|
77
|
+
Use underscores to separate distinct concepts within a symbol when needed for clarity. Avoid single letters, numeric suffixes, or generic names like "Premise1".
|
|
78
|
+
|
|
79
|
+
Abbreviations are encouraged to keep symbols short. Aim for under 20 characters when possible. Examples: "Gross Domestic Product growth is 4%" → GDP_Growth, "The cost of a degree at most universities has risen sharply" → Uni_Cost_Increase, "Regulatory intervention is necessary" → Reg_Intervention.
|
|
80
|
+
|
|
81
|
+
## Writing Style
|
|
82
|
+
|
|
83
|
+
When formulating claims, write in third person, present tense, active voice. Each claim should be a clear, standalone declarative sentence.`;
|
|
84
|
+
/**
|
|
85
|
+
* Unwrap a Nullable union (anyOf with null) to get the inner schema.
|
|
86
|
+
*/
|
|
87
|
+
function unwrapNullable(schema) {
|
|
88
|
+
if (schema.anyOf) {
|
|
89
|
+
const nonNull = schema.anyOf.find((s) => !(s.type === "null" || s.type === undefined));
|
|
90
|
+
if (nonNull)
|
|
91
|
+
return nonNull;
|
|
92
|
+
}
|
|
93
|
+
return schema;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Find extension fields in an object schema by comparing against known core keys.
|
|
97
|
+
*/
|
|
98
|
+
function findExtensions(schema, coreKeys, entityName) {
|
|
99
|
+
if (!schema?.properties)
|
|
100
|
+
return [];
|
|
101
|
+
const extensions = [];
|
|
102
|
+
for (const [key, fieldSchema] of Object.entries(schema.properties)) {
|
|
103
|
+
if (coreKeys.has(key))
|
|
104
|
+
continue;
|
|
105
|
+
const unwrapped = unwrapNullable(fieldSchema);
|
|
106
|
+
extensions.push({
|
|
107
|
+
entity: entityName,
|
|
108
|
+
field: key,
|
|
109
|
+
description: unwrapped.description,
|
|
110
|
+
minLength: unwrapped.minLength,
|
|
111
|
+
maxLength: unwrapped.maxLength,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return extensions;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Walk the response schema to discover all extension fields.
|
|
118
|
+
*/
|
|
119
|
+
function discoverExtensionFields(responseSchema) {
|
|
120
|
+
const schema = responseSchema;
|
|
121
|
+
const extensions = [];
|
|
122
|
+
// Response-level extensions
|
|
123
|
+
extensions.push(...findExtensions(schema, CORE_RESPONSE_KEYS, "response"));
|
|
124
|
+
// Argument-level: response.argument is Nullable(ArgumentSchema)
|
|
125
|
+
const argumentField = schema.properties?.argument;
|
|
126
|
+
if (!argumentField)
|
|
127
|
+
return extensions;
|
|
128
|
+
const argumentSchema = unwrapNullable(argumentField);
|
|
129
|
+
extensions.push(...findExtensions(argumentSchema, CORE_ARGUMENT_KEYS, "argument"));
|
|
130
|
+
// Claims: argument.claims is Array(ClaimSchema)
|
|
131
|
+
const claimsArray = argumentSchema.properties?.claims;
|
|
132
|
+
if (claimsArray?.items) {
|
|
133
|
+
extensions.push(...findExtensions(claimsArray.items, CORE_CLAIM_KEYS, "claim"));
|
|
134
|
+
}
|
|
135
|
+
// Variables: argument.variables is Array(VariableSchema)
|
|
136
|
+
const variablesArray = argumentSchema.properties?.variables;
|
|
137
|
+
if (variablesArray?.items) {
|
|
138
|
+
extensions.push(...findExtensions(variablesArray.items, CORE_VARIABLE_KEYS, "variable"));
|
|
139
|
+
}
|
|
140
|
+
// Sources: argument.sources is Array(SourceSchema)
|
|
141
|
+
const sourcesArray = argumentSchema.properties?.sources;
|
|
142
|
+
if (sourcesArray?.items) {
|
|
143
|
+
extensions.push(...findExtensions(sourcesArray.items, CORE_SOURCE_KEYS, "source"));
|
|
144
|
+
}
|
|
145
|
+
// Premises: argument.premises is Array(PremiseSchema)
|
|
146
|
+
const premisesArray = argumentSchema.properties?.premises;
|
|
147
|
+
if (premisesArray?.items) {
|
|
148
|
+
extensions.push(...findExtensions(premisesArray.items, CORE_PREMISE_KEYS, "premise"));
|
|
149
|
+
}
|
|
150
|
+
return extensions;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Format extension fields into instruction text.
|
|
154
|
+
*/
|
|
155
|
+
function formatExtensionInstructions(fields) {
|
|
156
|
+
if (fields.length === 0)
|
|
157
|
+
return "";
|
|
158
|
+
const lines = ["\n\n## Extension Fields\n"];
|
|
159
|
+
for (const field of fields) {
|
|
160
|
+
const constraints = [];
|
|
161
|
+
if (field.description) {
|
|
162
|
+
constraints.push(field.description);
|
|
163
|
+
}
|
|
164
|
+
if (field.minLength !== undefined) {
|
|
165
|
+
constraints.push(`minLength: ${field.minLength}`);
|
|
166
|
+
}
|
|
167
|
+
if (field.maxLength !== undefined) {
|
|
168
|
+
constraints.push(`maxLength: ${field.maxLength}`);
|
|
169
|
+
}
|
|
170
|
+
const constraintStr = constraints.length > 0 ? ` — ${constraints.join("; ")}` : "";
|
|
171
|
+
lines.push(`- **${field.entity}.${field.field}**${constraintStr}`);
|
|
172
|
+
}
|
|
173
|
+
return lines.join("\n");
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Build the system prompt for LLM-based argument parsing.
|
|
177
|
+
*
|
|
178
|
+
* @param responseSchema - The TypeBox response schema (core or extended)
|
|
179
|
+
* @param options - Optional configuration including custom instructions
|
|
180
|
+
* @returns The complete system prompt string
|
|
181
|
+
*/
|
|
182
|
+
export function buildParsingPrompt(responseSchema, options) {
|
|
183
|
+
let prompt = CORE_PROMPT;
|
|
184
|
+
const extensionFields = discoverExtensionFields(responseSchema);
|
|
185
|
+
const extensionInstructions = formatExtensionInstructions(extensionFields);
|
|
186
|
+
prompt += extensionInstructions;
|
|
187
|
+
if (options?.customInstructions) {
|
|
188
|
+
prompt += `\n\n## Additional Instructions\n\n${options.customInstructions}`;
|
|
189
|
+
}
|
|
190
|
+
return prompt;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=prompt-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,SAAS,KAAK,SAAS,EAAE,CAAC;YAChC,WAAW,CAAC,IAAI,CAAC,cAAc,KAAK,CAAC,SAAS,EAAE,CAAC,CAAA;QACrD,CAAC;QACD,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAChC,WAAW,CAAC,IAAI,CAAC,cAAc,KAAK,CAAC,SAAS,EAAE,CAAC,CAAA;QACrD,CAAC;QACD,MAAM,aAAa,GACf,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAChE,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,aAAa,EAAE,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAC9B,cAAuB,EACvB,OAAwB;IAExB,IAAI,MAAM,GAAG,WAAW,CAAA;IAExB,MAAM,eAAe,GAAG,uBAAuB,CAAC,cAAc,CAAC,CAAA;IAC/D,MAAM,qBAAqB,GAAG,2BAA2B,CAAC,eAAe,CAAC,CAAA;IAC1E,MAAM,IAAI,qBAAqB,CAAA;IAE/B,IAAI,OAAO,EAAE,kBAAkB,EAAE,CAAC;QAC9B,MAAM,IAAI,qCAAqC,OAAO,CAAC,kBAAkB,EAAE,CAAA;IAC/E,CAAC;IAED,OAAO,MAAM,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import Type, { type Static, type TSchema } from "typebox";
|
|
2
|
+
import type { TParsingSchemaOptions } from "./types.js";
|
|
3
|
+
export declare const ParsedClaimRoleType: Type.TUnion<[Type.TLiteral<"premise">, Type.TLiteral<"conclusion">, Type.TLiteral<"intermediate">]>;
|
|
4
|
+
export declare const ParsedClaimSchema: Type.TObject<{
|
|
5
|
+
miniId: Type.TString;
|
|
6
|
+
role: Type.TUnion<[Type.TLiteral<"premise">, Type.TLiteral<"conclusion">, Type.TLiteral<"intermediate">]>;
|
|
7
|
+
sourceMiniIds: Type.TArray<Type.TString>;
|
|
8
|
+
}>;
|
|
9
|
+
export type TParsedClaim = Static<typeof ParsedClaimSchema>;
|
|
10
|
+
export declare const ParsedVariableSchema: Type.TObject<{
|
|
11
|
+
miniId: Type.TString;
|
|
12
|
+
symbol: Type.TString;
|
|
13
|
+
claimMiniId: Type.TString;
|
|
14
|
+
}>;
|
|
15
|
+
export type TParsedVariable = Static<typeof ParsedVariableSchema>;
|
|
16
|
+
export declare const ParsedSourceSchema: Type.TObject<{
|
|
17
|
+
miniId: Type.TString;
|
|
18
|
+
text: Type.TString;
|
|
19
|
+
}>;
|
|
20
|
+
export type TParsedSource = Static<typeof ParsedSourceSchema>;
|
|
21
|
+
export declare const ParsedPremiseSchema: Type.TObject<{
|
|
22
|
+
miniId: Type.TString;
|
|
23
|
+
formula: Type.TString;
|
|
24
|
+
}>;
|
|
25
|
+
export type TParsedPremise = Static<typeof ParsedPremiseSchema>;
|
|
26
|
+
export declare const ParsedArgumentSchema: Type.TObject<{
|
|
27
|
+
claims: Type.TArray<Type.TObject<{
|
|
28
|
+
miniId: Type.TString;
|
|
29
|
+
role: Type.TUnion<[Type.TLiteral<"premise">, Type.TLiteral<"conclusion">, Type.TLiteral<"intermediate">]>;
|
|
30
|
+
sourceMiniIds: Type.TArray<Type.TString>;
|
|
31
|
+
}>>;
|
|
32
|
+
variables: Type.TArray<Type.TObject<{
|
|
33
|
+
miniId: Type.TString;
|
|
34
|
+
symbol: Type.TString;
|
|
35
|
+
claimMiniId: Type.TString;
|
|
36
|
+
}>>;
|
|
37
|
+
sources: Type.TArray<Type.TObject<{
|
|
38
|
+
miniId: Type.TString;
|
|
39
|
+
text: Type.TString;
|
|
40
|
+
}>>;
|
|
41
|
+
premises: Type.TArray<Type.TObject<{
|
|
42
|
+
miniId: Type.TString;
|
|
43
|
+
formula: Type.TString;
|
|
44
|
+
}>>;
|
|
45
|
+
conclusionPremiseMiniId: Type.TString;
|
|
46
|
+
}>;
|
|
47
|
+
export type TParsedArgument = Static<typeof ParsedArgumentSchema>;
|
|
48
|
+
export declare const ParsedArgumentResponseSchema: Type.TObject<{
|
|
49
|
+
argument: Type.TUnion<[Type.TObject<{
|
|
50
|
+
claims: Type.TArray<Type.TObject<{
|
|
51
|
+
miniId: Type.TString;
|
|
52
|
+
role: Type.TUnion<[Type.TLiteral<"premise">, Type.TLiteral<"conclusion">, Type.TLiteral<"intermediate">]>;
|
|
53
|
+
sourceMiniIds: Type.TArray<Type.TString>;
|
|
54
|
+
}>>;
|
|
55
|
+
variables: Type.TArray<Type.TObject<{
|
|
56
|
+
miniId: Type.TString;
|
|
57
|
+
symbol: Type.TString;
|
|
58
|
+
claimMiniId: Type.TString;
|
|
59
|
+
}>>;
|
|
60
|
+
sources: Type.TArray<Type.TObject<{
|
|
61
|
+
miniId: Type.TString;
|
|
62
|
+
text: Type.TString;
|
|
63
|
+
}>>;
|
|
64
|
+
premises: Type.TArray<Type.TObject<{
|
|
65
|
+
miniId: Type.TString;
|
|
66
|
+
formula: Type.TString;
|
|
67
|
+
}>>;
|
|
68
|
+
conclusionPremiseMiniId: Type.TString;
|
|
69
|
+
}>, Type.TNull]>;
|
|
70
|
+
uncategorizedText: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
71
|
+
selectionRationale: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
72
|
+
failureText: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
73
|
+
}>;
|
|
74
|
+
export type TParsedArgumentResponse = Static<typeof ParsedArgumentResponseSchema>;
|
|
75
|
+
export declare function buildParsingResponseSchema(options?: TParsingSchemaOptions): TSchema;
|
|
76
|
+
export declare function getParsingResponseSchema(schema?: TSchema): Record<string, unknown>;
|
|
77
|
+
//# sourceMappingURL=schemata.d.ts.map
|
|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ebox";
|
|
2
|
+
import { Nullable } from "../schemata/shared.js";
|
|
3
|
+
export const ParsedClaimRoleType = Type.Union([
|
|
4
|
+
Type.Literal("premise"),
|
|
5
|
+
Type.Literal("conclusion"),
|
|
6
|
+
Type.Literal("intermediate"),
|
|
7
|
+
]);
|
|
8
|
+
export const ParsedClaimSchema = Type.Object({
|
|
9
|
+
miniId: Type.String(),
|
|
10
|
+
role: ParsedClaimRoleType,
|
|
11
|
+
sourceMiniIds: Type.Array(Type.String()),
|
|
12
|
+
}, { additionalProperties: true });
|
|
13
|
+
export const ParsedVariableSchema = Type.Object({
|
|
14
|
+
miniId: Type.String(),
|
|
15
|
+
symbol: Type.String(),
|
|
16
|
+
claimMiniId: Type.String(),
|
|
17
|
+
}, { additionalProperties: true });
|
|
18
|
+
export const ParsedSourceSchema = Type.Object({
|
|
19
|
+
miniId: Type.String(),
|
|
20
|
+
text: Type.String(),
|
|
21
|
+
}, { additionalProperties: true });
|
|
22
|
+
export const ParsedPremiseSchema = Type.Object({
|
|
23
|
+
miniId: Type.String(),
|
|
24
|
+
formula: Type.String(),
|
|
25
|
+
}, { additionalProperties: true });
|
|
26
|
+
export const ParsedArgumentSchema = Type.Object({
|
|
27
|
+
claims: Type.Array(ParsedClaimSchema, { minItems: 1 }),
|
|
28
|
+
variables: Type.Array(ParsedVariableSchema, { minItems: 1 }),
|
|
29
|
+
sources: Type.Array(ParsedSourceSchema),
|
|
30
|
+
premises: Type.Array(ParsedPremiseSchema, { minItems: 1 }),
|
|
31
|
+
conclusionPremiseMiniId: Type.String(),
|
|
32
|
+
}, { additionalProperties: true });
|
|
33
|
+
export const ParsedArgumentResponseSchema = Type.Object({
|
|
34
|
+
argument: Nullable(ParsedArgumentSchema),
|
|
35
|
+
uncategorizedText: Nullable(Type.String()),
|
|
36
|
+
selectionRationale: Nullable(Type.String()),
|
|
37
|
+
failureText: Nullable(Type.String()),
|
|
38
|
+
}, { additionalProperties: true });
|
|
39
|
+
function mergeObjectSchemas(base, extension) {
|
|
40
|
+
return Type.Object({ ...base.properties, ...extension.properties }, { additionalProperties: true });
|
|
41
|
+
}
|
|
42
|
+
export function buildParsingResponseSchema(options) {
|
|
43
|
+
if (!options)
|
|
44
|
+
return ParsedArgumentResponseSchema;
|
|
45
|
+
const claimSch = options.claimSchema
|
|
46
|
+
? mergeObjectSchemas(ParsedClaimSchema, options.claimSchema)
|
|
47
|
+
: ParsedClaimSchema;
|
|
48
|
+
const variableSch = options.variableSchema
|
|
49
|
+
? mergeObjectSchemas(ParsedVariableSchema, options.variableSchema)
|
|
50
|
+
: ParsedVariableSchema;
|
|
51
|
+
const sourceSch = options.sourceSchema
|
|
52
|
+
? mergeObjectSchemas(ParsedSourceSchema, options.sourceSchema)
|
|
53
|
+
: ParsedSourceSchema;
|
|
54
|
+
const premiseSch = options.premiseSchema
|
|
55
|
+
? mergeObjectSchemas(ParsedPremiseSchema, options.premiseSchema)
|
|
56
|
+
: ParsedPremiseSchema;
|
|
57
|
+
const baseArgProps = {
|
|
58
|
+
claims: Type.Array(claimSch, { minItems: 1 }),
|
|
59
|
+
variables: Type.Array(variableSch, { minItems: 1 }),
|
|
60
|
+
sources: Type.Array(sourceSch),
|
|
61
|
+
premises: Type.Array(premiseSch, { minItems: 1 }),
|
|
62
|
+
conclusionPremiseMiniId: Type.String(),
|
|
63
|
+
};
|
|
64
|
+
const argSch = options.parsedArgumentSchema
|
|
65
|
+
? Type.Object({
|
|
66
|
+
...baseArgProps,
|
|
67
|
+
...options.parsedArgumentSchema.properties,
|
|
68
|
+
}, { additionalProperties: true })
|
|
69
|
+
: Type.Object(baseArgProps, { additionalProperties: true });
|
|
70
|
+
const baseResponseProps = {
|
|
71
|
+
argument: Nullable(argSch),
|
|
72
|
+
uncategorizedText: Nullable(Type.String()),
|
|
73
|
+
selectionRationale: Nullable(Type.String()),
|
|
74
|
+
failureText: Nullable(Type.String()),
|
|
75
|
+
};
|
|
76
|
+
const responseSch = options.responseSchema
|
|
77
|
+
? Type.Object({
|
|
78
|
+
...baseResponseProps,
|
|
79
|
+
...options.responseSchema.properties,
|
|
80
|
+
}, { additionalProperties: true })
|
|
81
|
+
: Type.Object(baseResponseProps, { additionalProperties: true });
|
|
82
|
+
return responseSch;
|
|
83
|
+
}
|
|
84
|
+
export function getParsingResponseSchema(schema) {
|
|
85
|
+
const target = schema ?? ParsedArgumentResponseSchema;
|
|
86
|
+
return JSON.parse(JSON.stringify(target));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=schemata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemata.js","sourceRoot":"","sources":["../../../src/lib/parsing/schemata.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAA2C,MAAM,SAAS,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAGhD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC;IAC1C,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;IAC1B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;CAC/B,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CACxC;IACI,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;IACrB,IAAI,EAAE,mBAAmB;IACzB,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;CAC3C,EACD,EAAE,oBAAoB,EAAE,IAAI,EAAE,CACjC,CAAA;AAGD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,MAAM,CAC3C;IACI,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;IACrB,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;IACrB,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE;CAC7B,EACD,EAAE,oBAAoB,EAAE,IAAI,EAAE,CACj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+
import type { TSchema } from "typebox";
|
|
2
|
+
export type TPromptOptions = {
|
|
3
|
+
customInstructions?: string;
|
|
4
|
+
};
|
|
5
|
+
export type TParsingSchemaOptions = {
|
|
6
|
+
claimSchema?: TSchema;
|
|
7
|
+
sourceSchema?: TSchema;
|
|
8
|
+
variableSchema?: TSchema;
|
|
9
|
+
premiseSchema?: TSchema;
|
|
10
|
+
parsedArgumentSchema?: TSchema;
|
|
11
|
+
responseSchema?: TSchema;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/parsing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,MAAM,MAAM,cAAc,GAAG;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAChC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/parsing/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Individual structural rule toggles for expression tree grammar.
|
|
3
|
+
*
|
|
4
|
+
* Each boolean controls whether a specific structural constraint is enforced.
|
|
5
|
+
* When `true`, violations throw (or auto-normalize if `TGrammarConfig.autoNormalize`
|
|
6
|
+
* is also `true` — but only for operations that support it).
|
|
7
|
+
*/
|
|
8
|
+
export type TGrammarOptions = {
|
|
9
|
+
/** Require a `formula` node between a parent operator and a non-`not` operator child. */
|
|
10
|
+
enforceFormulaBetweenOperators: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Grammar enforcement configuration for expression trees.
|
|
14
|
+
*
|
|
15
|
+
* Controls which structural rules are enforced and whether violations are
|
|
16
|
+
* automatically corrected.
|
|
17
|
+
*
|
|
18
|
+
* **`autoNormalize` scope:** Auto-normalization is only supported by `addExpression`
|
|
19
|
+
* and bulk-loading paths (`loadInitialExpressions`). Compound operations
|
|
20
|
+
* (`insertExpression`, `wrapExpression`) and `removeExpression` always throw on
|
|
21
|
+
* violations regardless of this flag.
|
|
22
|
+
*/
|
|
23
|
+
export type TGrammarConfig = TGrammarOptions & {
|
|
24
|
+
/** When `true`, auto-fix violations where possible instead of throwing. */
|
|
25
|
+
autoNormalize: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** Default config: all rules enforced, auto-normalize off. */
|
|
28
|
+
export declare const DEFAULT_GRAMMAR_CONFIG: TGrammarConfig;
|
|
29
|
+
/** Permissive config: no enforcement. Used by default in `fromData`. */
|
|
30
|
+
export declare const PERMISSIVE_GRAMMAR_CONFIG: TGrammarConfig;
|
|
31
|
+
//# sourceMappingURL=grammar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grammar.d.ts","sourceRoot":"","sources":["../../../src/lib/types/grammar.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,yFAAyF;IACzF,8BAA8B,EAAE,OAAO,CAAA;CAC1C,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAC3C,2EAA2E;IAC3E,aAAa,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,8DAA8D;AAC9D,eAAO,MAAM,sBAAsB,EAAE,cAGpC,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,EAAE,cAGvC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Default config: all rules enforced, auto-normalize off. */
|
|
2
|
+
export const DEFAULT_GRAMMAR_CONFIG = {
|
|
3
|
+
enforceFormulaBetweenOperators: true,
|
|
4
|
+
autoNormalize: false,
|
|
5
|
+
};
|
|
6
|
+
/** Permissive config: no enforcement. Used by default in `fromData`. */
|
|
7
|
+
export const PERMISSIVE_GRAMMAR_CONFIG = {
|
|
8
|
+
enforceFormulaBetweenOperators: false,
|
|
9
|
+
autoNormalize: false,
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=grammar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grammar.js","sourceRoot":"","sources":["../../../src/lib/types/grammar.ts"],"names":[],"mappings":"AA4BA,8DAA8D;AAC9D,MAAM,CAAC,MAAM,sBAAsB,GAAmB;IAClD,8BAA8B,EAAE,IAAI;IACpC,aAAa,EAAE,KAAK;CACvB,CAAA;AAED,wEAAwE;AACxE,MAAM,CAAC,MAAM,yBAAyB,GAAmB;IACrD,8BAA8B,EAAE,KAAK;IACrC,aAAa,EAAE,KAAK;CACvB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polintpro/proposit-core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"description": "Core engine for building and manipulating propositional logic arguments.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"./extensions/ieee": {
|
|
23
23
|
"types": "./dist/extensions/ieee/index.d.ts",
|
|
24
24
|
"import": "./dist/extensions/ieee/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./extensions/basics": {
|
|
27
|
+
"types": "./dist/extensions/basics/index.d.ts",
|
|
28
|
+
"import": "./dist/extensions/basics/index.js"
|
|
25
29
|
}
|
|
26
30
|
},
|
|
27
31
|
"bin": {
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function claimSourceAssociationsPath(): string;
|
|
2
|
-
export declare function readClaimSourceAssociations(): Promise<unknown[]>;
|
|
3
|
-
export declare function writeClaimSourceAssociations(associations: unknown[]): Promise<void>;
|
|
4
|
-
//# sourceMappingURL=sources.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../../src/cli/storage/sources.ts"],"names":[],"mappings":"AAIA,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD;AAED,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAQtE;AAED,wBAAsB,4BAA4B,CAC9C,YAAY,EAAE,OAAO,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { getStateDir } from "../config.js";
|
|
4
|
-
export function claimSourceAssociationsPath() {
|
|
5
|
-
return path.join(getStateDir(), "claim-source-associations.json");
|
|
6
|
-
}
|
|
7
|
-
export async function readClaimSourceAssociations() {
|
|
8
|
-
const filePath = claimSourceAssociationsPath();
|
|
9
|
-
try {
|
|
10
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
11
|
-
return JSON.parse(content);
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export async function writeClaimSourceAssociations(associations) {
|
|
18
|
-
const filePath = claimSourceAssociationsPath();
|
|
19
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
20
|
-
await fs.writeFile(filePath, JSON.stringify(associations, null, 2));
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=sources.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sources.js","sourceRoot":"","sources":["../../../src/cli/storage/sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE1C,MAAM,UAAU,2BAA2B;IACvC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,gCAAgC,CAAC,CAAA;AACrE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B;IAC7C,MAAM,QAAQ,GAAG,2BAA2B,EAAE,CAAA;IAC9C,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAc,CAAA;IAC3C,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,CAAA;IACb,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAC9C,YAAuB;IAEvB,MAAM,QAAQ,GAAG,2BAA2B,EAAE,CAAA;IAC9C,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3D,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACvE,CAAC"}
|