theprogrammablemind 8.9.0 → 8.9.1-beta.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/client.js CHANGED
@@ -1654,11 +1654,13 @@ const knowledgeModuleImpl = async ({
1654
1654
  }
1655
1655
  }
1656
1656
  } else {
1657
+ /*
1657
1658
  if (results.length > 0 && args.vimdiff) {
1658
1659
  for (const result of results) {
1659
1660
  vimdiff(result.actual, result.expected)
1660
1661
  }
1661
1662
  }
1663
+ */
1662
1664
  }
1663
1665
  if (hasError) {
1664
1666
  if (!headerShown) {
package/package.json CHANGED
@@ -65,6 +65,6 @@
65
65
  "sort-json": "^2.0.0",
66
66
  "uuid": "^8.3.2"
67
67
  },
68
- "version": "8.9.0",
68
+ "version": "8.9.1-beta.1",
69
69
  "license": "UNLICENSED"
70
70
  }
@@ -29,23 +29,20 @@ const gs = (g) => async (contexts, separator, lastSeparator) => {
29
29
  return s
30
30
  }
31
31
 
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 } = {}) => {
32
+ const isA = (hierarchy) => (child, parent, { strict=false } = {}) => {
44
33
  if (!child || !parent) {
45
34
  return false
46
35
  }
47
36
 
48
- if (extended) {
37
+ if (strict) {
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 {
49
46
  if (hierarchy.isA(child.marker || child, parent.marker || parent)) {
50
47
  return true
51
48
  }
@@ -57,14 +54,6 @@ const isA = (hierarchy) => (child, parent, { extended=false } = {}) => {
57
54
  }
58
55
  }
59
56
  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)
68
57
  }
69
58
  }
70
59
 
@@ -75,23 +64,6 @@ class ErrorReason extends Error {
75
64
  }
76
65
  }
77
66
 
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
-
95
67
  const cleanAssign = (dest, ...srcs) => {
96
68
  for (const key in dest) {
97
69
  let found = false
@@ -125,8 +97,8 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
125
97
  args.config = config
126
98
  args.hierarchy = hierarchy
127
99
  args.isA = isA(hierarchy)
128
- args.listable = listable(hierarchy)
129
- args.asList = asList
100
+ // args.listable = listable(hierarchy)
101
+ // args.asList = asList
130
102
  args.retry = () => { throw new RetryError() }
131
103
  args.fragments = (query) => {
132
104
  return config.fragment(args, query)
@@ -461,11 +433,12 @@ const loadInstance = async (config, instance) => {
461
433
  module.exports = {
462
434
  setupProcessB,
463
435
  ErrorReason,
464
- listable,
436
+ // listable,
465
437
  setupArgs,
466
438
  processContext,
467
439
  getObjects,
468
440
  gs,
469
441
  processContextsB,
470
442
  loadInstance,
443
+ isA,
471
444
  }
package/src/digraph.js CHANGED
@@ -118,8 +118,12 @@ class Digraph {
118
118
  return this.acdcs(s, 1, 0)
119
119
  }
120
120
 
121
- ancestors (s) {
122
- return this.acdcs(s, 0, 1)
121
+ ancestors (s, { includeSelf } = {}) {
122
+ const ancestors = this.acdcs(s, 0, 1)
123
+ if (includeSelf) {
124
+ ancestors.add(s)
125
+ }
126
+ return ancestors
123
127
  }
124
128
 
125
129
  minima (nodes) {
@@ -147,6 +151,24 @@ class Digraph {
147
151
  return minima
148
152
  }
149
153
 
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
+
150
172
  /*
151
173
  maxima (nodes) {
152
174
  const maxima = new Set(nodes)
@@ -86,8 +86,13 @@ class DigraphInternal {
86
86
  return this.acdcs(s, 1, 0)
87
87
  }
88
88
 
89
- ancestors (s) {
90
- return this.acdcs(s, 0, 1)
89
+ ancestors (s, { includeSelf } = {}) {
90
+ const ancestors = this.acdcs(s, 0, 1)
91
+ if (includeSelf) {
92
+ ancestors.add(s)
93
+ }
94
+ return ancestors
95
+
91
96
  }
92
97
 
93
98
  minima (nodes) {
@@ -115,6 +120,23 @@ class DigraphInternal {
115
120
  return minima
116
121
  }
117
122
 
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
+
118
140
  /*
119
141
  maxima (nodes) {
120
142
  const maxima = new Set(nodes)