@yeyuan98/opencode-bioresearcher-plugin 1.5.0-alpha.0 → 1.5.1
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 +48 -36
- package/dist/index.js +8 -6
- package/dist/skills/bioresearcher-tests/README.md +90 -0
- package/dist/skills/bioresearcher-tests/SKILL.md +255 -0
- package/dist/skills/bioresearcher-tests/pyproject.toml +6 -0
- package/dist/skills/bioresearcher-tests/resources/json_samples/in_markdown.md.gz +0 -0
- package/dist/skills/bioresearcher-tests/resources/json_samples/nested_object.json.gz +0 -0
- package/dist/skills/bioresearcher-tests/resources/json_samples/schema_draft7.json.gz +0 -0
- package/dist/skills/bioresearcher-tests/resources/json_samples/simple_array.json.gz +0 -0
- package/dist/skills/bioresearcher-tests/resources/json_samples/simple_object.json.gz +0 -0
- package/dist/skills/bioresearcher-tests/resources/obo_sample.obo.gz +0 -0
- package/dist/skills/bioresearcher-tests/resources/pubmed_sample.xml.gz +0 -0
- package/dist/skills/bioresearcher-tests/resources/table_sample.xlsx.gz +0 -0
- package/dist/skills/bioresearcher-tests/test_cases/json_tests.md +137 -0
- package/dist/skills/bioresearcher-tests/test_cases/misc_tests.md +141 -0
- package/dist/skills/bioresearcher-tests/test_cases/parser_tests.md +80 -0
- package/dist/skills/bioresearcher-tests/test_cases/skill_tests.md +59 -0
- package/dist/skills/bioresearcher-tests/test_cases/table_tests.md +194 -0
- package/dist/skills/bioresearcher-tests/test_runner.py +607 -0
- package/dist/skills/env-jsonc-setup/SKILL.md +206 -206
- package/dist/skills/long-table-summary/SKILL.md +224 -153
- package/dist/skills/long-table-summary/combine_outputs.py +55 -9
- package/dist/skills/long-table-summary/generate_prompts.py +9 -0
- package/dist/skills/pubmed-weekly/pubmed_weekly.py +130 -29
- package/dist/{db-tools → tools/db}/backends/mysql/translator.js +23 -23
- package/dist/{db-tools → tools/db}/tools.js +34 -34
- package/dist/{misc-tools → tools/misc}/json-validate.js +4 -5
- package/dist/tools/parser/obo/index.d.ts +2 -0
- package/dist/tools/parser/obo/index.js +2 -0
- package/dist/tools/parser/obo/obo.d.ts +17 -0
- package/dist/tools/parser/obo/obo.js +216 -0
- package/dist/tools/parser/obo/types.d.ts +166 -0
- package/dist/tools/parser/obo/utils.d.ts +21 -0
- package/dist/tools/parser/obo/utils.js +411 -0
- package/dist/tools/parser/pubmed/types.js +1 -0
- package/dist/{skill-tools → tools/skill}/registry.js +1 -1
- package/package.json +1 -1
- package/dist/db-tools/executor.d.ts +0 -13
- package/dist/db-tools/executor.js +0 -54
- package/dist/db-tools/pool.d.ts +0 -8
- package/dist/db-tools/pool.js +0 -49
- package/dist/db-tools/tools/index.d.ts +0 -27
- package/dist/db-tools/tools/index.js +0 -191
- package/dist/db-tools/types.d.ts +0 -94
- package/dist/db-tools/types.js +0 -40
- package/dist/misc-tools/json-tools.d.ts +0 -33
- package/dist/misc-tools/json-tools.js +0 -187
- package/dist/skill/frontmatter.d.ts +0 -2
- package/dist/skill/frontmatter.js +0 -65
- package/dist/skill/index.d.ts +0 -3
- package/dist/skill/index.js +0 -2
- package/dist/skill/registry.d.ts +0 -11
- package/dist/skill/registry.js +0 -64
- package/dist/skill/tool.d.ts +0 -9
- package/dist/skill/tool.js +0 -115
- package/dist/skill/types.d.ts +0 -22
- package/dist/skill/types.js +0 -7
- /package/dist/{db-tools → tools/db}/backends/index.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/backends/index.js +0 -0
- /package/dist/{db-tools → tools/db}/backends/mongodb/backend.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/backends/mongodb/backend.js +0 -0
- /package/dist/{db-tools → tools/db}/backends/mongodb/connection.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/backends/mongodb/connection.js +0 -0
- /package/dist/{db-tools → tools/db}/backends/mongodb/index.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/backends/mongodb/index.js +0 -0
- /package/dist/{db-tools → tools/db}/backends/mongodb/translator.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/backends/mongodb/translator.js +0 -0
- /package/dist/{db-tools → tools/db}/backends/mysql/backend.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/backends/mysql/backend.js +0 -0
- /package/dist/{db-tools → tools/db}/backends/mysql/connection.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/backends/mysql/connection.js +0 -0
- /package/dist/{db-tools → tools/db}/backends/mysql/index.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/backends/mysql/index.js +0 -0
- /package/dist/{db-tools → tools/db}/backends/mysql/translator.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/core/base.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/core/base.js +0 -0
- /package/dist/{db-tools → tools/db}/core/config-loader.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/core/config-loader.js +0 -0
- /package/dist/{db-tools → tools/db}/core/index.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/core/index.js +0 -0
- /package/dist/{db-tools → tools/db}/core/jsonc-parser.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/core/jsonc-parser.js +0 -0
- /package/dist/{db-tools → tools/db}/core/validator.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/core/validator.js +0 -0
- /package/dist/{db-tools → tools/db}/index.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/index.js +0 -0
- /package/dist/{db-tools → tools/db}/interface/backend.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/interface/backend.js +0 -0
- /package/dist/{db-tools → tools/db}/interface/connection.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/interface/connection.js +0 -0
- /package/dist/{db-tools → tools/db}/interface/index.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/interface/index.js +0 -0
- /package/dist/{db-tools → tools/db}/interface/query.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/interface/query.js +0 -0
- /package/dist/{db-tools → tools/db}/interface/schema.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/interface/schema.js +0 -0
- /package/dist/{db-tools → tools/db}/tools.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/utils.d.ts +0 -0
- /package/dist/{db-tools → tools/db}/utils.js +0 -0
- /package/dist/{misc-tools → tools/misc}/calculator.d.ts +0 -0
- /package/dist/{misc-tools → tools/misc}/calculator.js +0 -0
- /package/dist/{misc-tools → tools/misc}/index.d.ts +0 -0
- /package/dist/{misc-tools → tools/misc}/index.js +0 -0
- /package/dist/{misc-tools → tools/misc}/json-extract.d.ts +0 -0
- /package/dist/{misc-tools → tools/misc}/json-extract.js +0 -0
- /package/dist/{misc-tools → tools/misc}/json-infer.d.ts +0 -0
- /package/dist/{misc-tools → tools/misc}/json-infer.js +0 -0
- /package/dist/{misc-tools → tools/misc}/json-validate.d.ts +0 -0
- /package/dist/{misc-tools → tools/misc}/timer.d.ts +0 -0
- /package/dist/{misc-tools → tools/misc}/timer.js +0 -0
- /package/dist/{parser-tools/pubmed → tools/parser/obo}/types.js +0 -0
- /package/dist/{parser-tools → tools/parser}/pubmed/index.d.ts +0 -0
- /package/dist/{parser-tools → tools/parser}/pubmed/index.js +0 -0
- /package/dist/{parser-tools → tools/parser}/pubmed/pubmed.d.ts +0 -0
- /package/dist/{parser-tools → tools/parser}/pubmed/pubmed.js +0 -0
- /package/dist/{parser-tools → tools/parser}/pubmed/types.d.ts +0 -0
- /package/dist/{parser-tools → tools/parser}/pubmed/utils.d.ts +0 -0
- /package/dist/{parser-tools → tools/parser}/pubmed/utils.js +0 -0
- /package/dist/{skill-tools → tools/skill}/frontmatter.d.ts +0 -0
- /package/dist/{skill-tools → tools/skill}/frontmatter.js +0 -0
- /package/dist/{skill-tools → tools/skill}/index.d.ts +0 -0
- /package/dist/{skill-tools → tools/skill}/index.js +0 -0
- /package/dist/{skill-tools → tools/skill}/registry.d.ts +0 -0
- /package/dist/{skill-tools → tools/skill}/tool.d.ts +0 -0
- /package/dist/{skill-tools → tools/skill}/tool.js +0 -0
- /package/dist/{skill-tools → tools/skill}/types.d.ts +0 -0
- /package/dist/{skill-tools → tools/skill}/types.js +0 -0
- /package/dist/{table-tools → tools/table}/index.d.ts +0 -0
- /package/dist/{table-tools → tools/table}/index.js +0 -0
- /package/dist/{table-tools → tools/table}/tools.d.ts +0 -0
- /package/dist/{table-tools → tools/table}/tools.js +0 -0
- /package/dist/{table-tools → tools/table}/utils.d.ts +0 -0
- /package/dist/{table-tools → tools/table}/utils.js +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
export interface OBOHeader {
|
|
2
|
+
format_version?: string;
|
|
3
|
+
data_version?: string;
|
|
4
|
+
date?: string;
|
|
5
|
+
saved_by?: string;
|
|
6
|
+
auto_generated_by?: string;
|
|
7
|
+
import?: string | string[];
|
|
8
|
+
subsetdefs: OBOSubsetDef[];
|
|
9
|
+
synonymtypedefs: OBOSynonymTypeDef[];
|
|
10
|
+
default_namespace?: string;
|
|
11
|
+
ontology?: string;
|
|
12
|
+
idspace?: string;
|
|
13
|
+
remark?: string | string[];
|
|
14
|
+
property_values?: OBOPropertyValue[];
|
|
15
|
+
owl_axioms?: string;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
export interface OBOSubsetDef {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
22
|
+
export interface OBOSynonymTypeDef {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
scope?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface OBOPropertyValue {
|
|
28
|
+
tag: string;
|
|
29
|
+
value: string;
|
|
30
|
+
xsd_type?: string;
|
|
31
|
+
qualifiers?: OBOSynonymTypeDef[];
|
|
32
|
+
}
|
|
33
|
+
export interface TermFrame {
|
|
34
|
+
frame_type: 'term';
|
|
35
|
+
id: string;
|
|
36
|
+
is_anonymous?: boolean;
|
|
37
|
+
name?: string;
|
|
38
|
+
namespace?: string;
|
|
39
|
+
alt_ids?: string[];
|
|
40
|
+
def?: string;
|
|
41
|
+
comment?: string;
|
|
42
|
+
subsets?: string[];
|
|
43
|
+
synonyms?: OBOSynonym[];
|
|
44
|
+
xrefs?: string[];
|
|
45
|
+
builtin?: boolean;
|
|
46
|
+
property_values?: OBOPropertyValue[];
|
|
47
|
+
is_a?: string[];
|
|
48
|
+
intersection_of?: string[];
|
|
49
|
+
union_of?: string[];
|
|
50
|
+
equivalent_to?: string[];
|
|
51
|
+
disjoint_from?: string[];
|
|
52
|
+
relationships?: OBORelationship[];
|
|
53
|
+
is_obsolete?: boolean;
|
|
54
|
+
replaced_by?: string;
|
|
55
|
+
consider?: string;
|
|
56
|
+
created_by?: string;
|
|
57
|
+
creation_date?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface TypedefFrame {
|
|
60
|
+
frame_type: 'typedef';
|
|
61
|
+
id: string;
|
|
62
|
+
is_anonymous?: boolean;
|
|
63
|
+
name?: string;
|
|
64
|
+
namespace?: string;
|
|
65
|
+
alt_ids?: string[];
|
|
66
|
+
def?: string;
|
|
67
|
+
comment?: string;
|
|
68
|
+
subsets?: string[];
|
|
69
|
+
synonyms?: OBOSynonym[];
|
|
70
|
+
xrefs?: string[];
|
|
71
|
+
builtin?: boolean;
|
|
72
|
+
property_values?: OBOPropertyValue[];
|
|
73
|
+
domain?: string;
|
|
74
|
+
range?: string;
|
|
75
|
+
holds_over_chain?: string[];
|
|
76
|
+
is_anti_symmetric?: boolean;
|
|
77
|
+
is_cyclic?: boolean;
|
|
78
|
+
is_reflexive?: boolean;
|
|
79
|
+
is_symmetric?: boolean;
|
|
80
|
+
is_transitive?: boolean;
|
|
81
|
+
is_functional?: boolean;
|
|
82
|
+
is_inverse_functional?: boolean;
|
|
83
|
+
is_a?: string[];
|
|
84
|
+
intersection_of?: string[];
|
|
85
|
+
union_of?: string[];
|
|
86
|
+
equivalent_to?: string[];
|
|
87
|
+
disjoint_from?: string[];
|
|
88
|
+
inverse_of?: string;
|
|
89
|
+
transitive_over?: string;
|
|
90
|
+
equivalent_to_chain?: string[];
|
|
91
|
+
disjoint_over?: string;
|
|
92
|
+
relationships?: OBORelationship[];
|
|
93
|
+
is_obsolete?: boolean;
|
|
94
|
+
replaced_by?: string;
|
|
95
|
+
consider?: string;
|
|
96
|
+
created_by?: string;
|
|
97
|
+
creation_date?: string;
|
|
98
|
+
expand_assertion_to?: string;
|
|
99
|
+
expand_expression_to?: string;
|
|
100
|
+
is_metadata_tag?: boolean;
|
|
101
|
+
is_class_level?: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface InstanceFrame {
|
|
104
|
+
frame_type: 'instance';
|
|
105
|
+
id: string;
|
|
106
|
+
is_anonymous?: boolean;
|
|
107
|
+
name?: string;
|
|
108
|
+
namespace?: string;
|
|
109
|
+
alt_ids?: string[];
|
|
110
|
+
def?: string;
|
|
111
|
+
comment?: string;
|
|
112
|
+
subsets?: string[];
|
|
113
|
+
synonyms?: OBOSynonym[];
|
|
114
|
+
xrefs?: string[];
|
|
115
|
+
builtin?: boolean;
|
|
116
|
+
property_values?: OBOPropertyValue[];
|
|
117
|
+
instance_of?: string;
|
|
118
|
+
relationships?: OBORelationship[];
|
|
119
|
+
is_obsolete?: boolean;
|
|
120
|
+
replaced_by?: string;
|
|
121
|
+
consider?: string;
|
|
122
|
+
created_by?: string;
|
|
123
|
+
creation_date?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface OBOSynonym {
|
|
126
|
+
text: string;
|
|
127
|
+
scope?: 'EXACT' | 'BROAD' | 'NARROW' | 'RELATED';
|
|
128
|
+
type?: string;
|
|
129
|
+
xrefs?: string[];
|
|
130
|
+
}
|
|
131
|
+
export interface OBORelationship {
|
|
132
|
+
type: string;
|
|
133
|
+
value: string;
|
|
134
|
+
qualifiers?: OBOSynonymTypeDef[];
|
|
135
|
+
}
|
|
136
|
+
export interface OBODocument {
|
|
137
|
+
header: OBOHeader;
|
|
138
|
+
frames: (TermFrame | TypedefFrame | InstanceFrame)[];
|
|
139
|
+
}
|
|
140
|
+
export interface CSVRow {
|
|
141
|
+
frame_type: string;
|
|
142
|
+
id: string;
|
|
143
|
+
name?: string;
|
|
144
|
+
namespace?: string;
|
|
145
|
+
def?: string;
|
|
146
|
+
synonyms?: string;
|
|
147
|
+
subsets?: string;
|
|
148
|
+
xrefs?: string;
|
|
149
|
+
relationships?: string;
|
|
150
|
+
comment?: string;
|
|
151
|
+
is_obsolete?: boolean;
|
|
152
|
+
created_by?: string;
|
|
153
|
+
creation_date?: string;
|
|
154
|
+
alt_ids?: string;
|
|
155
|
+
is_anonymous?: boolean;
|
|
156
|
+
parent?: string;
|
|
157
|
+
domain?: string;
|
|
158
|
+
range?: string;
|
|
159
|
+
instance_of?: string;
|
|
160
|
+
}
|
|
161
|
+
export interface ProcessingStats {
|
|
162
|
+
total: number;
|
|
163
|
+
terms: number;
|
|
164
|
+
typedefs: number;
|
|
165
|
+
instances: number;
|
|
166
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TermFrame, TypedefFrame, InstanceFrame, CSVRow, OBOSynonym, OBORelationship, OBOSubsetDef, OBOSynonymTypeDef } from './types.js';
|
|
2
|
+
export declare function stripComment(value: string): string;
|
|
3
|
+
export declare function parseLine(line: string): {
|
|
4
|
+
tag: string | null;
|
|
5
|
+
value: string;
|
|
6
|
+
} | null;
|
|
7
|
+
export declare function parseQuotedString(value: string): string;
|
|
8
|
+
export declare function parseXrefList(value: string): string[];
|
|
9
|
+
export declare function parseSynonym(value: string): OBOSynonym;
|
|
10
|
+
export declare function parseRelationship(input: string): OBORelationship;
|
|
11
|
+
export declare function createEmptyTermFrame(): TermFrame;
|
|
12
|
+
export declare function createEmptyTypedefFrame(): TypedefFrame;
|
|
13
|
+
export declare function createEmptyInstanceFrame(): InstanceFrame;
|
|
14
|
+
export declare function processTagValue(frame: TermFrame | TypedefFrame | InstanceFrame, tag: string, value: string): void;
|
|
15
|
+
export declare function parsePropertyValue(value: string): any;
|
|
16
|
+
export declare function parseHeader(lines: string[]): OBOSubsetDef[] | OBOSynonymTypeDef[];
|
|
17
|
+
export declare function flattenSynonyms(synonyms?: OBOSynonym[]): string;
|
|
18
|
+
export declare function flattenRelationships(relationships?: OBORelationship[]): string;
|
|
19
|
+
export declare function flattenArray(arr?: string[]): string;
|
|
20
|
+
export declare function frameToCSVRow(frame: TermFrame | TypedefFrame | InstanceFrame): CSVRow;
|
|
21
|
+
export declare function generateCSV(rows: CSVRow[]): string;
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
export function stripComment(value) {
|
|
2
|
+
const exclamationIndex = value.indexOf('!');
|
|
3
|
+
if (exclamationIndex === -1)
|
|
4
|
+
return value.trim();
|
|
5
|
+
return value.substring(0, exclamationIndex).trim();
|
|
6
|
+
}
|
|
7
|
+
export function parseLine(line) {
|
|
8
|
+
if (!line || line.trim().startsWith('!'))
|
|
9
|
+
return null;
|
|
10
|
+
const colonIndex = line.indexOf(':');
|
|
11
|
+
if (colonIndex === -1)
|
|
12
|
+
return null;
|
|
13
|
+
const tag = line.substring(0, colonIndex).trim();
|
|
14
|
+
const value = line.substring(colonIndex + 1).trim();
|
|
15
|
+
return { tag, value };
|
|
16
|
+
}
|
|
17
|
+
export function parseQuotedString(value) {
|
|
18
|
+
if (value.startsWith('"') && value.endsWith('"')) {
|
|
19
|
+
return value.slice(1, -1);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
export function parseXrefList(value) {
|
|
24
|
+
const stripped = stripComment(value);
|
|
25
|
+
if (stripped.startsWith('[') && stripped.endsWith(']')) {
|
|
26
|
+
const content = stripped.slice(1, -1).trim();
|
|
27
|
+
if (!content)
|
|
28
|
+
return [];
|
|
29
|
+
return content.split(',').map(x => x.trim()).filter(x => x.length > 0);
|
|
30
|
+
}
|
|
31
|
+
return [stripped];
|
|
32
|
+
}
|
|
33
|
+
export function parseSynonym(value) {
|
|
34
|
+
const stripped = stripComment(value);
|
|
35
|
+
let text = stripped;
|
|
36
|
+
let scope;
|
|
37
|
+
let type;
|
|
38
|
+
let xrefs;
|
|
39
|
+
const quotedMatch = stripped.match(/^"([^"]+)"/);
|
|
40
|
+
if (quotedMatch) {
|
|
41
|
+
text = quotedMatch[1];
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
text = stripped;
|
|
45
|
+
}
|
|
46
|
+
const parts = text.split(/\s+/).filter(p => p.length > 0);
|
|
47
|
+
const scopeIndex = parts.findIndex(p => p === 'EXACT' || p === 'BROAD' || p === 'NARROW' || p === 'RELATED');
|
|
48
|
+
if (scopeIndex !== -1) {
|
|
49
|
+
scope = parts[scopeIndex];
|
|
50
|
+
parts.splice(scopeIndex, 1);
|
|
51
|
+
}
|
|
52
|
+
if (parts.length > 1 && !parts[1].startsWith('[')) {
|
|
53
|
+
type = parts[1];
|
|
54
|
+
}
|
|
55
|
+
const xrefMatch = stripped.match(/\[([^\]]+)\]/);
|
|
56
|
+
if (xrefMatch) {
|
|
57
|
+
const xrefContent = xrefMatch[1].trim();
|
|
58
|
+
xrefs = xrefContent.split(',').map(x => x.trim()).filter(x => x.length > 0);
|
|
59
|
+
}
|
|
60
|
+
return { text, scope, type, xrefs };
|
|
61
|
+
}
|
|
62
|
+
export function parseRelationship(input) {
|
|
63
|
+
const stripped = stripComment(input);
|
|
64
|
+
const parts = stripped.split(/\s+/).filter(p => p.length > 0);
|
|
65
|
+
if (parts.length < 2) {
|
|
66
|
+
return { type: '', value: stripped };
|
|
67
|
+
}
|
|
68
|
+
const type = parts[0];
|
|
69
|
+
const relValue = parts.slice(1).join(' ');
|
|
70
|
+
return { type, value: relValue };
|
|
71
|
+
}
|
|
72
|
+
export function createEmptyTermFrame() {
|
|
73
|
+
return {
|
|
74
|
+
frame_type: 'term',
|
|
75
|
+
id: ''
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function createEmptyTypedefFrame() {
|
|
79
|
+
return {
|
|
80
|
+
frame_type: 'typedef',
|
|
81
|
+
id: ''
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function createEmptyInstanceFrame() {
|
|
85
|
+
return {
|
|
86
|
+
frame_type: 'instance',
|
|
87
|
+
id: ''
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export function processTagValue(frame, tag, value) {
|
|
91
|
+
const stripped = stripComment(value);
|
|
92
|
+
const unquoted = parseQuotedString(stripped);
|
|
93
|
+
switch (tag) {
|
|
94
|
+
case 'id':
|
|
95
|
+
frame.id = stripped;
|
|
96
|
+
break;
|
|
97
|
+
case 'name':
|
|
98
|
+
frame.name = unquoted;
|
|
99
|
+
break;
|
|
100
|
+
case 'namespace':
|
|
101
|
+
frame.namespace = stripped;
|
|
102
|
+
break;
|
|
103
|
+
case 'alt_id':
|
|
104
|
+
if (!frame.alt_ids)
|
|
105
|
+
frame.alt_ids = [];
|
|
106
|
+
frame.alt_ids.push(stripped);
|
|
107
|
+
break;
|
|
108
|
+
case 'def':
|
|
109
|
+
frame.def = unquoted;
|
|
110
|
+
break;
|
|
111
|
+
case 'comment':
|
|
112
|
+
frame.comment = unquoted;
|
|
113
|
+
break;
|
|
114
|
+
case 'subset':
|
|
115
|
+
if (!frame.subsets)
|
|
116
|
+
frame.subsets = [];
|
|
117
|
+
frame.subsets.push(stripped);
|
|
118
|
+
break;
|
|
119
|
+
case 'synonym':
|
|
120
|
+
if (!frame.synonyms)
|
|
121
|
+
frame.synonyms = [];
|
|
122
|
+
frame.synonyms.push(parseSynonym(value));
|
|
123
|
+
break;
|
|
124
|
+
case 'xref':
|
|
125
|
+
if (!frame.xrefs)
|
|
126
|
+
frame.xrefs = [];
|
|
127
|
+
frame.xrefs.push(...parseXrefList(value));
|
|
128
|
+
break;
|
|
129
|
+
case 'builtin':
|
|
130
|
+
frame.builtin = stripped.toLowerCase() === 'true';
|
|
131
|
+
break;
|
|
132
|
+
case 'is_a':
|
|
133
|
+
if ('is_a' in frame) {
|
|
134
|
+
if (!frame.is_a)
|
|
135
|
+
frame.is_a = [];
|
|
136
|
+
frame.is_a.push(stripped);
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
case 'intersection_of':
|
|
140
|
+
if ('intersection_of' in frame) {
|
|
141
|
+
if (!frame.intersection_of)
|
|
142
|
+
frame.intersection_of = [];
|
|
143
|
+
frame.intersection_of.push(stripped);
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
case 'union_of':
|
|
147
|
+
if ('union_of' in frame) {
|
|
148
|
+
if (!frame.union_of)
|
|
149
|
+
frame.union_of = [];
|
|
150
|
+
frame.union_of.push(stripped);
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
case 'equivalent_to':
|
|
154
|
+
if ('equivalent_to' in frame) {
|
|
155
|
+
if (!frame.equivalent_to)
|
|
156
|
+
frame.equivalent_to = [];
|
|
157
|
+
frame.equivalent_to.push(stripped);
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
case 'disjoint_from':
|
|
161
|
+
if ('disjoint_from' in frame) {
|
|
162
|
+
if (!frame.disjoint_from)
|
|
163
|
+
frame.disjoint_from = [];
|
|
164
|
+
frame.disjoint_from.push(stripped);
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
case 'relationship':
|
|
168
|
+
if (!frame.relationships)
|
|
169
|
+
frame.relationships = [];
|
|
170
|
+
frame.relationships.push(parseRelationship(value));
|
|
171
|
+
break;
|
|
172
|
+
case 'is_obsolete':
|
|
173
|
+
frame.is_obsolete = stripped.toLowerCase() === 'true';
|
|
174
|
+
break;
|
|
175
|
+
case 'replaced_by':
|
|
176
|
+
frame.replaced_by = stripped;
|
|
177
|
+
break;
|
|
178
|
+
case 'consider':
|
|
179
|
+
frame.consider = stripped;
|
|
180
|
+
break;
|
|
181
|
+
case 'created_by':
|
|
182
|
+
frame.created_by = stripped;
|
|
183
|
+
break;
|
|
184
|
+
case 'creation_date':
|
|
185
|
+
frame.creation_date = stripped;
|
|
186
|
+
break;
|
|
187
|
+
case 'is_anonymous':
|
|
188
|
+
frame.is_anonymous = stripped.toLowerCase() === 'true';
|
|
189
|
+
break;
|
|
190
|
+
case 'property_value':
|
|
191
|
+
if (!frame.property_values)
|
|
192
|
+
frame.property_values = [];
|
|
193
|
+
frame.property_values.push(parsePropertyValue(value));
|
|
194
|
+
break;
|
|
195
|
+
case 'domain':
|
|
196
|
+
if ('domain' in frame)
|
|
197
|
+
frame.domain = stripped;
|
|
198
|
+
break;
|
|
199
|
+
case 'range':
|
|
200
|
+
if ('range' in frame)
|
|
201
|
+
frame.range = stripped;
|
|
202
|
+
break;
|
|
203
|
+
case 'holds_over_chain':
|
|
204
|
+
if ('holds_over_chain' in frame)
|
|
205
|
+
frame.holds_over_chain = [];
|
|
206
|
+
frame.holds_over_chain?.push(stripped);
|
|
207
|
+
break;
|
|
208
|
+
case 'is_anti_symmetric':
|
|
209
|
+
if ('is_anti_symmetric' in frame)
|
|
210
|
+
frame.is_anti_symmetric = stripped.toLowerCase() === 'true';
|
|
211
|
+
break;
|
|
212
|
+
case 'is_cyclic':
|
|
213
|
+
if ('is_cyclic' in frame)
|
|
214
|
+
frame.is_cyclic = stripped.toLowerCase() === 'true';
|
|
215
|
+
break;
|
|
216
|
+
case 'is_reflexive':
|
|
217
|
+
if ('is_reflexive' in frame)
|
|
218
|
+
frame.is_reflexive = stripped.toLowerCase() === 'true';
|
|
219
|
+
break;
|
|
220
|
+
case 'is_symmetric':
|
|
221
|
+
if ('is_symmetric' in frame)
|
|
222
|
+
frame.is_symmetric = stripped.toLowerCase() === 'true';
|
|
223
|
+
break;
|
|
224
|
+
case 'is_transitive':
|
|
225
|
+
if ('is_transitive' in frame)
|
|
226
|
+
frame.is_transitive = stripped.toLowerCase() === 'true';
|
|
227
|
+
break;
|
|
228
|
+
case 'is_functional':
|
|
229
|
+
if ('is_functional' in frame)
|
|
230
|
+
frame.is_functional = stripped.toLowerCase() === 'true';
|
|
231
|
+
break;
|
|
232
|
+
case 'is_inverse_functional':
|
|
233
|
+
if ('is_inverse_functional' in frame)
|
|
234
|
+
frame.is_inverse_functional = stripped.toLowerCase() === 'true';
|
|
235
|
+
break;
|
|
236
|
+
case 'inverse_of':
|
|
237
|
+
if ('inverse_of' in frame)
|
|
238
|
+
frame.inverse_of = stripped;
|
|
239
|
+
break;
|
|
240
|
+
case 'transitive_over':
|
|
241
|
+
if ('transitive_over' in frame)
|
|
242
|
+
frame.transitive_over = stripped;
|
|
243
|
+
break;
|
|
244
|
+
case 'equivalent_to_chain':
|
|
245
|
+
if ('equivalent_to_chain' in frame)
|
|
246
|
+
frame.equivalent_to_chain = [];
|
|
247
|
+
frame.equivalent_to_chain?.push(stripped);
|
|
248
|
+
break;
|
|
249
|
+
case 'disjoint_over':
|
|
250
|
+
if ('disjoint_over' in frame)
|
|
251
|
+
frame.disjoint_over = stripped;
|
|
252
|
+
break;
|
|
253
|
+
case 'expand_assertion_to':
|
|
254
|
+
if ('expand_assertion_to' in frame)
|
|
255
|
+
frame.expand_assertion_to = unquoted;
|
|
256
|
+
break;
|
|
257
|
+
case 'expand_expression_to':
|
|
258
|
+
if ('expand_expression_to' in frame)
|
|
259
|
+
frame.expand_expression_to = unquoted;
|
|
260
|
+
break;
|
|
261
|
+
case 'is_metadata_tag':
|
|
262
|
+
if ('is_metadata_tag' in frame)
|
|
263
|
+
frame.is_metadata_tag = stripped.toLowerCase() === 'true';
|
|
264
|
+
break;
|
|
265
|
+
case 'is_class_level':
|
|
266
|
+
if ('is_class_level' in frame)
|
|
267
|
+
frame.is_class_level = stripped.toLowerCase() === 'true';
|
|
268
|
+
break;
|
|
269
|
+
case 'instance_of':
|
|
270
|
+
if ('instance_of' in frame)
|
|
271
|
+
frame.instance_of = stripped;
|
|
272
|
+
break;
|
|
273
|
+
default:
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
export function parsePropertyValue(value) {
|
|
278
|
+
const stripped = stripComment(value);
|
|
279
|
+
const parts = stripped.split(/\s+/);
|
|
280
|
+
if (parts.length < 1) {
|
|
281
|
+
return { tag: '', value: '' };
|
|
282
|
+
}
|
|
283
|
+
const tag = parts[0];
|
|
284
|
+
const remaining = parts.slice(1).join(' ');
|
|
285
|
+
if (remaining.startsWith('"')) {
|
|
286
|
+
const match = remaining.match(/^"([^"]*)"\s*(.*)$/);
|
|
287
|
+
if (match) {
|
|
288
|
+
return {
|
|
289
|
+
tag,
|
|
290
|
+
value: match[1],
|
|
291
|
+
xsd_type: match[2]?.trim() || undefined
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return { tag, value: remaining };
|
|
296
|
+
}
|
|
297
|
+
export function parseHeader(lines) {
|
|
298
|
+
const subsetdefs = [];
|
|
299
|
+
const synonymtypedefs = [];
|
|
300
|
+
for (const line of lines) {
|
|
301
|
+
const parsed = parseLine(line);
|
|
302
|
+
if (!parsed)
|
|
303
|
+
continue;
|
|
304
|
+
const { tag, value } = parsed;
|
|
305
|
+
if (tag === 'subsetdef') {
|
|
306
|
+
const parts = value.split(/\s+/);
|
|
307
|
+
const id = parts[0];
|
|
308
|
+
const nameMatch = value.match(/"([^"]+)"/);
|
|
309
|
+
const name = nameMatch ? nameMatch[1] : parts[1];
|
|
310
|
+
subsetdefs.push({ id, name });
|
|
311
|
+
}
|
|
312
|
+
else if (tag === 'synonymtypedef') {
|
|
313
|
+
const parts = value.split(/\s+/);
|
|
314
|
+
const id = parts[0];
|
|
315
|
+
const nameMatch = value.match(/"([^"]+)"/);
|
|
316
|
+
const name = nameMatch ? nameMatch[1] : parts[1];
|
|
317
|
+
const scope = parts.find(p => p === 'EXACT' || p === 'BROAD' || p === 'NARROW' || p === 'RELATED');
|
|
318
|
+
synonymtypedefs.push({ id, name, scope });
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return [...subsetdefs, ...synonymtypedefs];
|
|
322
|
+
}
|
|
323
|
+
export function flattenSynonyms(synonyms) {
|
|
324
|
+
if (!synonyms || synonyms.length === 0)
|
|
325
|
+
return '';
|
|
326
|
+
const json = synonyms.map(s => {
|
|
327
|
+
const obj = { v: s.text };
|
|
328
|
+
if (s.scope)
|
|
329
|
+
obj.s = s.scope;
|
|
330
|
+
if (s.type)
|
|
331
|
+
obj.t = s.type;
|
|
332
|
+
if (s.xrefs && s.xrefs.length > 0)
|
|
333
|
+
obj.x = s.xrefs;
|
|
334
|
+
return JSON.stringify(obj);
|
|
335
|
+
});
|
|
336
|
+
return JSON.stringify(json);
|
|
337
|
+
}
|
|
338
|
+
export function flattenRelationships(relationships) {
|
|
339
|
+
if (!relationships || relationships.length === 0)
|
|
340
|
+
return '';
|
|
341
|
+
const json = relationships.map(r => {
|
|
342
|
+
const obj = { v: r.value };
|
|
343
|
+
if (r.qualifiers && r.qualifiers.length > 0)
|
|
344
|
+
obj.q = r.qualifiers;
|
|
345
|
+
return JSON.stringify({ t: r.type, ...obj });
|
|
346
|
+
});
|
|
347
|
+
return JSON.stringify(json);
|
|
348
|
+
}
|
|
349
|
+
export function flattenArray(arr) {
|
|
350
|
+
if (!arr || arr.length === 0)
|
|
351
|
+
return '';
|
|
352
|
+
return JSON.stringify(arr);
|
|
353
|
+
}
|
|
354
|
+
export function frameToCSVRow(frame) {
|
|
355
|
+
const row = {
|
|
356
|
+
frame_type: frame.frame_type,
|
|
357
|
+
id: frame.id,
|
|
358
|
+
name: frame.name,
|
|
359
|
+
namespace: frame.namespace,
|
|
360
|
+
def: frame.def,
|
|
361
|
+
comment: frame.comment,
|
|
362
|
+
is_obsolete: frame.is_obsolete,
|
|
363
|
+
created_by: frame.created_by,
|
|
364
|
+
creation_date: frame.creation_date,
|
|
365
|
+
alt_ids: flattenArray(frame.alt_ids),
|
|
366
|
+
is_anonymous: frame.is_anonymous,
|
|
367
|
+
synonyms: flattenSynonyms(frame.synonyms),
|
|
368
|
+
subsets: flattenArray(frame.subsets),
|
|
369
|
+
xrefs: flattenArray(frame.xrefs),
|
|
370
|
+
relationships: flattenRelationships(frame.relationships)
|
|
371
|
+
};
|
|
372
|
+
if (frame.frame_type === 'term' && 'is_a' in frame) {
|
|
373
|
+
const term = frame;
|
|
374
|
+
row.parent = term.is_a?.[0];
|
|
375
|
+
}
|
|
376
|
+
else if (frame.frame_type === 'typedef' && 'domain' in frame) {
|
|
377
|
+
const typedef = frame;
|
|
378
|
+
row.domain = typedef.domain;
|
|
379
|
+
row.range = typedef.range;
|
|
380
|
+
}
|
|
381
|
+
else if (frame.frame_type === 'instance' && 'instance_of' in frame) {
|
|
382
|
+
const instance = frame;
|
|
383
|
+
row.instance_of = instance.instance_of;
|
|
384
|
+
}
|
|
385
|
+
return row;
|
|
386
|
+
}
|
|
387
|
+
export function generateCSV(rows) {
|
|
388
|
+
if (rows.length === 0)
|
|
389
|
+
return '';
|
|
390
|
+
const headers = [
|
|
391
|
+
'frame_type', 'id', 'name', 'namespace', 'def', 'comment',
|
|
392
|
+
'is_obsolete', 'created_by', 'creation_date', 'alt_ids', 'is_anonymous',
|
|
393
|
+
'synonyms', 'subsets', 'xrefs', 'relationships', 'parent', 'domain', 'range', 'instance_of'
|
|
394
|
+
];
|
|
395
|
+
const headerRow = headers.join(',');
|
|
396
|
+
const dataRows = rows.map(row => {
|
|
397
|
+
return headers.map(header => {
|
|
398
|
+
const value = row[header];
|
|
399
|
+
if (value === undefined || value === null || value === '')
|
|
400
|
+
return '';
|
|
401
|
+
if (typeof value === 'boolean')
|
|
402
|
+
return value ? 'true' : 'false';
|
|
403
|
+
if (typeof value === 'string') {
|
|
404
|
+
const escaped = value.replace(/"/g, '""');
|
|
405
|
+
return `"${escaped}"`;
|
|
406
|
+
}
|
|
407
|
+
return '';
|
|
408
|
+
}).join(',');
|
|
409
|
+
});
|
|
410
|
+
return [headerRow, ...dataRows].join('\n');
|
|
411
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -29,7 +29,7 @@ export class SkillConflictError extends Error {
|
|
|
29
29
|
}
|
|
30
30
|
function getPluginSkillsDir() {
|
|
31
31
|
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
32
|
-
return path.join(currentDir, "..", "skills");
|
|
32
|
+
return path.join(currentDir, "..", "..", "..", "skills");
|
|
33
33
|
}
|
|
34
34
|
async function loadSkillsFromDir(dir, source) {
|
|
35
35
|
if (!existsSync(dir))
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as mysql from 'mysql2/promise';
|
|
2
|
-
import type { DbConfig, QueryResponse } from './types';
|
|
3
|
-
type QueryParams = Record<string, unknown> | unknown[];
|
|
4
|
-
interface ExecuteQueryOptions {
|
|
5
|
-
sql: string;
|
|
6
|
-
params?: QueryParams;
|
|
7
|
-
}
|
|
8
|
-
export declare function getConfigFromEnv(): DbConfig;
|
|
9
|
-
export declare function validateConfig(config: DbConfig): void;
|
|
10
|
-
export declare function executeQuery(options: ExecuteQueryOptions): Promise<QueryResponse>;
|
|
11
|
-
export declare function executeRawQuery<T extends mysql.RowDataPacket[]>(sql: string, params?: QueryParams): Promise<[T, mysql.FieldPacket[]]>;
|
|
12
|
-
export { getPool } from './pool';
|
|
13
|
-
export { closePool } from './pool';
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_CONFIG as defaultConfig } from './types';
|
|
2
|
-
import { formatQueryResult, formatQueryError } from './utils';
|
|
3
|
-
import { getPool } from './pool';
|
|
4
|
-
export function getConfigFromEnv() {
|
|
5
|
-
const envConfig = {
|
|
6
|
-
host: process.env.DB_HOST || defaultConfig.host,
|
|
7
|
-
port: parseInt(process.env.DB_PORT || '', 10) || defaultConfig.port,
|
|
8
|
-
user: process.env.DB_USER || '',
|
|
9
|
-
password: process.env.DB_PASSWORD || '',
|
|
10
|
-
database: process.env.DB_DATABASE || '',
|
|
11
|
-
charset: process.env.DB_CHARSET || defaultConfig.charset,
|
|
12
|
-
connectionTimeout: parseInt(process.env.DB_CONNECTION_TIMEOUT || '', 10) || defaultConfig.connectionTimeout,
|
|
13
|
-
};
|
|
14
|
-
return envConfig;
|
|
15
|
-
}
|
|
16
|
-
export function validateConfig(config) {
|
|
17
|
-
const missing = [];
|
|
18
|
-
if (!config.user)
|
|
19
|
-
missing.push('DB_USER');
|
|
20
|
-
if (!config.database)
|
|
21
|
-
missing.push('DB_DATABASE');
|
|
22
|
-
if (missing.length > 0) {
|
|
23
|
-
throw new Error(`Missing required environment variables: ${missing.join(', ')}`);
|
|
24
|
-
}
|
|
25
|
-
if (config.port < 1 || config.port > 65535) {
|
|
26
|
-
throw new Error(`Invalid port number: ${config.port}. Must be between 1 and 65535.`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export async function executeQuery(options) {
|
|
30
|
-
const startTime = Date.now();
|
|
31
|
-
try {
|
|
32
|
-
const config = getConfigFromEnv();
|
|
33
|
-
validateConfig(config);
|
|
34
|
-
const pool = getPool(config);
|
|
35
|
-
const params = options.params ?? [];
|
|
36
|
-
const [rows, fields] = await pool.query(options.sql, params);
|
|
37
|
-
const executionTimeMs = Date.now() - startTime;
|
|
38
|
-
return formatQueryResult(rows, fields, executionTimeMs);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
const executionTimeMs = Date.now() - startTime;
|
|
42
|
-
return formatQueryError(error, executionTimeMs);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export async function executeRawQuery(sql, params) {
|
|
46
|
-
const config = getConfigFromEnv();
|
|
47
|
-
validateConfig(config);
|
|
48
|
-
const pool = getPool(config);
|
|
49
|
-
const queryParams = params ?? [];
|
|
50
|
-
const result = await pool.query(sql, queryParams);
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
export { getPool } from './pool';
|
|
54
|
-
export { closePool } from './pool';
|
package/dist/db-tools/pool.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as mysql from 'mysql2/promise';
|
|
2
|
-
import type { DbConfig } from './types';
|
|
3
|
-
export declare function getPool(config: DbConfig): mysql.Pool;
|
|
4
|
-
export declare function closePool(): Promise<void>;
|
|
5
|
-
export declare function getPoolStatus(): {
|
|
6
|
-
initialized: boolean;
|
|
7
|
-
hasConfig: boolean;
|
|
8
|
-
};
|