theprogrammablemind_4wp 9.5.1 → 9.6.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/client.js +100 -57
- package/lines.js +7 -0
- package/package.json +5 -4
- package/runtime.js +0 -1
- package/src/config.js +330 -76
- package/src/configHelpers.js +68 -35
- package/src/fragments.js +83 -0
- package/src/generators.js +20 -14
- package/src/helpers.js +107 -3
- package/src/project2.js +54 -4
- package/src/semantics.js +21 -16
package/src/semantics.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { args: contextArgs, normalizeGenerator, normalizeSemantic } = require('./helpers')
|
|
2
2
|
const Lines = require('../lines')
|
|
3
3
|
const helpers = require('./helpers')
|
|
4
|
+
const debug = require('./debug')
|
|
4
5
|
|
|
5
6
|
class Semantic {
|
|
6
7
|
// constructor ({match, apply, uuid, index, km, notes}) {
|
|
@@ -43,11 +44,13 @@ class Semantic {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
/*
|
|
46
48
|
getAPIs (config) {
|
|
47
49
|
if (config && config._api && config._api.multiApi) {
|
|
48
50
|
return config._api.apis
|
|
49
51
|
}
|
|
50
52
|
}
|
|
53
|
+
*/
|
|
51
54
|
|
|
52
55
|
fixUpArgs (args, context) {
|
|
53
56
|
args.uuid = this.uuid
|
|
@@ -57,7 +60,7 @@ class Semantic {
|
|
|
57
60
|
args.global = objects
|
|
58
61
|
const config = args.config
|
|
59
62
|
args.api = this.getAPI(config)
|
|
60
|
-
args.apis =
|
|
63
|
+
args.apis = config.getAPIs()
|
|
61
64
|
args.args = contextArgs(context, args.hierarchy)
|
|
62
65
|
args.context = context
|
|
63
66
|
let n = (id) => id
|
|
@@ -70,6 +73,7 @@ class Semantic {
|
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
async matches (args, context, options = {}) {
|
|
76
|
+
args = {...args}
|
|
73
77
|
this.fixUpArgs(args, context)
|
|
74
78
|
const matches = await this.matcher(args)
|
|
75
79
|
if (matches && (options.debug || {}).match || args.callId === this.callId) {
|
|
@@ -81,12 +85,13 @@ class Semantic {
|
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
async apply (args, context, s, options = {}) {
|
|
88
|
+
args = {...args}
|
|
84
89
|
const { config } = args
|
|
85
|
-
if (config && config.
|
|
90
|
+
if (config && config.getDebugLoops()) {
|
|
86
91
|
console.log('apply', this.toLabel())
|
|
87
92
|
}
|
|
88
|
-
if (args.calls && config && args.calls.stack.length > config.
|
|
89
|
-
throw new Error(`Max depth of ${config.
|
|
93
|
+
if (args.calls && config && args.calls.stack.length > config.getMaxDepth()) {
|
|
94
|
+
throw new Error(`Max depth of ${config.getMaxDepth()} for calls has been exceeded. maxDepth can be set on the config object. To see the calls run with the --dl or set the debugLoops property on the config`)
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
const contextPrime = Object.assign({}, context)
|
|
@@ -157,6 +162,7 @@ class Semantics {
|
|
|
157
162
|
}
|
|
158
163
|
args = { ...args }
|
|
159
164
|
const config = args.config
|
|
165
|
+
const debug = config.getDebug()
|
|
160
166
|
let contextPrime = Object.assign({}, context)
|
|
161
167
|
const s = (context, options) => this.apply(args, context, options)
|
|
162
168
|
let applied = false
|
|
@@ -197,7 +203,6 @@ class Semantics {
|
|
|
197
203
|
continue
|
|
198
204
|
}
|
|
199
205
|
if (!contextPrime.controlKeepMotivation && semantic.oneShot) {
|
|
200
|
-
// semantic.tied_ids.forEach((tied_id) => args.config.removeSemantic(tied_id))
|
|
201
206
|
args.config.removeSemantic(semantic)
|
|
202
207
|
}
|
|
203
208
|
for (const { listener } of deferred) {
|
|
@@ -218,7 +223,7 @@ class Semantics {
|
|
|
218
223
|
errorMessage = e.toString()
|
|
219
224
|
}
|
|
220
225
|
|
|
221
|
-
const widths = [10, 10
|
|
226
|
+
const widths = Lines.addRemainder([10, 10])
|
|
222
227
|
const lines = new Lines(widths)
|
|
223
228
|
lines.setElement(0, 0, 'Semantic')
|
|
224
229
|
const source = `${semantic.km}/#${semantic.index}`
|
|
@@ -226,6 +231,9 @@ class Semantics {
|
|
|
226
231
|
lines.newRow()
|
|
227
232
|
lines.setElement(0, 2, semantic.toString())
|
|
228
233
|
lines.newRow()
|
|
234
|
+
lines.setElement(0, 1, 'DEBUG')
|
|
235
|
+
lines.setElement(0, 2, `To debug this use args.callId === '${args.calls.current()}'`)
|
|
236
|
+
lines.newRow()
|
|
229
237
|
lines.setElement(0, 1, 'TO')
|
|
230
238
|
lines.setElement(0, 2, `context_id: ${context.context_id}`)
|
|
231
239
|
lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
|
|
@@ -233,9 +241,6 @@ class Semantics {
|
|
|
233
241
|
lines.setElement(0, 1, 'STACK')
|
|
234
242
|
lines.setElement(0, 2, stack)
|
|
235
243
|
lines.newRow()
|
|
236
|
-
lines.setElement(0, 1, 'DEBUG')
|
|
237
|
-
lines.setElement(0, 2, `To debug this use args.callId === '${args.calls.current()}'`)
|
|
238
|
-
lines.newRow()
|
|
239
244
|
lines.setElement(0, 1, 'ERROR')
|
|
240
245
|
lines.setElement(0, 2, errorMessage)
|
|
241
246
|
this.logs.push(lines.toString())
|
|
@@ -247,8 +252,8 @@ class Semantics {
|
|
|
247
252
|
}
|
|
248
253
|
args.calls.touch(contextPrime)
|
|
249
254
|
// this.logs.push(`Semantics: applied ${semantic.toString()}\n to\n ${JSON.stringify(context)}\n the result was ${JSON.stringify(contextPrime)}\n`)
|
|
250
|
-
if (
|
|
251
|
-
const widths = [10, 10
|
|
255
|
+
if (config.getDebug()) {
|
|
256
|
+
const widths = Lines.addRemainder([10, 10])
|
|
252
257
|
const lines = new Lines(widths)
|
|
253
258
|
lines.setElement(0, 0, 'Semantic')
|
|
254
259
|
if (semantic.index > -1 && semantic.km) {
|
|
@@ -261,6 +266,9 @@ class Semantics {
|
|
|
261
266
|
lines.newRow()
|
|
262
267
|
lines.setElement(0, 2, semantic.toString())
|
|
263
268
|
lines.newRow()
|
|
269
|
+
lines.setElement(0, 1, 'DEBUG')
|
|
270
|
+
lines.setElement(0, 2, `To debug this use args.callId === '${args.calls.current()}'`)
|
|
271
|
+
lines.newRow()
|
|
264
272
|
lines.setElement(0, 1, 'TO')
|
|
265
273
|
lines.setElement(0, 2, `context_id: ${context.context_id}`)
|
|
266
274
|
lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
|
|
@@ -268,9 +276,6 @@ class Semantics {
|
|
|
268
276
|
lines.setElement(0, 1, 'STACK')
|
|
269
277
|
lines.setElement(0, 2, stack)
|
|
270
278
|
lines.newRow()
|
|
271
|
-
lines.setElement(0, 1, 'DEBUG')
|
|
272
|
-
lines.setElement(0, 2, `To debug this use args.callId === '${args.calls.current()}'`)
|
|
273
|
-
lines.newRow()
|
|
274
279
|
lines.setElement(0, 1, 'RESULT')
|
|
275
280
|
lines.setElement(0, 2, `context_id: ${context.context_id}`)
|
|
276
281
|
lines.setElement(1, 2, JSON.stringify(contextPrime, null, 2))
|
|
@@ -294,8 +299,8 @@ class Semantics {
|
|
|
294
299
|
counter += 1
|
|
295
300
|
}
|
|
296
301
|
args.calls.pop()
|
|
297
|
-
if (!applied &&
|
|
298
|
-
const widths = [10, 10
|
|
302
|
+
if (!applied && debug) {
|
|
303
|
+
const widths = Lines.addRemainder([10, 10])
|
|
299
304
|
const lines = new Lines(widths)
|
|
300
305
|
lines.setElement(0, 0, 'Semantic')
|
|
301
306
|
lines.setElement(0, 2, 'No semantic applied')
|