theprogrammablemind 8.9.0-beta.18 → 8.9.0-beta.2
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/client.js +0 -2
- package/package.json +1 -1
- package/src/configHelpers.js +41 -14
- package/src/digraph.js +2 -24
- package/src/digraph_internal.js +2 -24
package/client.js
CHANGED
@@ -1654,13 +1654,11 @@ const knowledgeModuleImpl = async ({
|
|
1654
1654
|
}
|
1655
1655
|
}
|
1656
1656
|
} else {
|
1657
|
-
/*
|
1658
1657
|
if (results.length > 0 && args.vimdiff) {
|
1659
1658
|
for (const result of results) {
|
1660
1659
|
vimdiff(result.actual, result.expected)
|
1661
1660
|
}
|
1662
1661
|
}
|
1663
|
-
*/
|
1664
1662
|
}
|
1665
1663
|
if (hasError) {
|
1666
1664
|
if (!headerShown) {
|
package/package.json
CHANGED
package/src/configHelpers.js
CHANGED
@@ -29,20 +29,23 @@ const gs = (g) => async (contexts, separator, lastSeparator) => {
|
|
29
29
|
return s
|
30
30
|
}
|
31
31
|
|
32
|
-
const
|
32
|
+
const asList = (context) => {
|
33
|
+
if (context.marker === 'list') {
|
34
|
+
return context
|
35
|
+
}
|
36
|
+
return {
|
37
|
+
marker: 'list',
|
38
|
+
types: [context.marker],
|
39
|
+
value: [context]
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
const isA = (hierarchy) => (child, parent, { extended=false } = {}) => {
|
33
44
|
if (!child || !parent) {
|
34
45
|
return false
|
35
46
|
}
|
36
47
|
|
37
|
-
if (
|
38
|
-
if (child.marker) {
|
39
|
-
child = child.marker
|
40
|
-
}
|
41
|
-
if (parent.marker) {
|
42
|
-
parent = parent.marker
|
43
|
-
}
|
44
|
-
return hierarchy.isA(child, parent)
|
45
|
-
} else {
|
48
|
+
if (extended) {
|
46
49
|
if (hierarchy.isA(child.marker || child, parent.marker || parent)) {
|
47
50
|
return true
|
48
51
|
}
|
@@ -54,6 +57,14 @@ const isA = (hierarchy) => (child, parent, { strict=false } = {}) => {
|
|
54
57
|
}
|
55
58
|
}
|
56
59
|
return false
|
60
|
+
} else {
|
61
|
+
if (child.marker) {
|
62
|
+
child = child.marker
|
63
|
+
}
|
64
|
+
if (parent.marker) {
|
65
|
+
parent = parent.marker
|
66
|
+
}
|
67
|
+
return hierarchy.isA(child, parent)
|
57
68
|
}
|
58
69
|
}
|
59
70
|
|
@@ -64,6 +75,23 @@ class ErrorReason extends Error {
|
|
64
75
|
}
|
65
76
|
}
|
66
77
|
|
78
|
+
const listable = (hierarchy) => (c, type) => {
|
79
|
+
if (!c) {
|
80
|
+
return false
|
81
|
+
}
|
82
|
+
if (hierarchy.isA(c.marker, type)) {
|
83
|
+
return true
|
84
|
+
}
|
85
|
+
if (c.marker === 'list') {
|
86
|
+
for (const t of c.types) {
|
87
|
+
if (hierarchy.isA(t, type)) {
|
88
|
+
return true
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
return false
|
93
|
+
}
|
94
|
+
|
67
95
|
const cleanAssign = (dest, ...srcs) => {
|
68
96
|
for (const key in dest) {
|
69
97
|
let found = false
|
@@ -97,8 +125,8 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
97
125
|
args.config = config
|
98
126
|
args.hierarchy = hierarchy
|
99
127
|
args.isA = isA(hierarchy)
|
100
|
-
|
101
|
-
|
128
|
+
args.listable = listable(hierarchy)
|
129
|
+
args.asList = asList
|
102
130
|
args.retry = () => { throw new RetryError() }
|
103
131
|
args.fragments = (query) => {
|
104
132
|
return config.fragment(args, query)
|
@@ -433,12 +461,11 @@ const loadInstance = async (config, instance) => {
|
|
433
461
|
module.exports = {
|
434
462
|
setupProcessB,
|
435
463
|
ErrorReason,
|
436
|
-
|
464
|
+
listable,
|
437
465
|
setupArgs,
|
438
466
|
processContext,
|
439
467
|
getObjects,
|
440
468
|
gs,
|
441
469
|
processContextsB,
|
442
470
|
loadInstance,
|
443
|
-
isA,
|
444
471
|
}
|
package/src/digraph.js
CHANGED
@@ -118,12 +118,8 @@ class Digraph {
|
|
118
118
|
return this.acdcs(s, 1, 0)
|
119
119
|
}
|
120
120
|
|
121
|
-
ancestors (s
|
122
|
-
|
123
|
-
if (includeSelf) {
|
124
|
-
ancestors.add(s)
|
125
|
-
}
|
126
|
-
return ancestors
|
121
|
+
ancestors (s) {
|
122
|
+
return this.acdcs(s, 0, 1)
|
127
123
|
}
|
128
124
|
|
129
125
|
minima (nodes) {
|
@@ -151,24 +147,6 @@ class Digraph {
|
|
151
147
|
return minima
|
152
148
|
}
|
153
149
|
|
154
|
-
lub (nodes) {
|
155
|
-
if (nodes.length === 0) {
|
156
|
-
return new Set([])
|
157
|
-
}
|
158
|
-
debugger
|
159
|
-
nodes = Array.from(nodes);
|
160
|
-
let common = this.ancestors(nodes[0], { includeSelf: true })
|
161
|
-
|
162
|
-
for (let i = 1; i < nodes.length; i++) {
|
163
|
-
const ancestors = this.ancestors(nodes[i], { includeSelf: true })
|
164
|
-
common = new Set([...common].filter(x => ancestors.has(x)))
|
165
|
-
if (common.size === 0) {
|
166
|
-
break;
|
167
|
-
}
|
168
|
-
}
|
169
|
-
return this.minima(common);
|
170
|
-
}
|
171
|
-
|
172
150
|
/*
|
173
151
|
maxima (nodes) {
|
174
152
|
const maxima = new Set(nodes)
|
package/src/digraph_internal.js
CHANGED
@@ -86,13 +86,8 @@ class DigraphInternal {
|
|
86
86
|
return this.acdcs(s, 1, 0)
|
87
87
|
}
|
88
88
|
|
89
|
-
ancestors (s
|
90
|
-
|
91
|
-
if (includeSelf) {
|
92
|
-
ancestors.add(s)
|
93
|
-
}
|
94
|
-
return ancestors
|
95
|
-
|
89
|
+
ancestors (s) {
|
90
|
+
return this.acdcs(s, 0, 1)
|
96
91
|
}
|
97
92
|
|
98
93
|
minima (nodes) {
|
@@ -120,23 +115,6 @@ class DigraphInternal {
|
|
120
115
|
return minima
|
121
116
|
}
|
122
117
|
|
123
|
-
lub (nodes) {
|
124
|
-
if (nodes.length === 0) {
|
125
|
-
return new Set([])
|
126
|
-
}
|
127
|
-
nodes = Array.from(nodes);
|
128
|
-
let common = this.ancestors(nodes[0], { includeSelf: true })
|
129
|
-
|
130
|
-
for (let i = 1; i < nodes.length; i++) {
|
131
|
-
const ancestors = this.ancestors(nodes[i], { includeSelf: true })
|
132
|
-
common = new Set([...common].filter(x => ancestors.has(x)))
|
133
|
-
if (common.size === 0) {
|
134
|
-
break;
|
135
|
-
}
|
136
|
-
}
|
137
|
-
return this.minima(common);
|
138
|
-
}
|
139
|
-
|
140
118
|
/*
|
141
119
|
maxima (nodes) {
|
142
120
|
const maxima = new Set(nodes)
|