theprogrammablemind_4wp 7.5.5 → 7.5.6-beta.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 +49 -19
- package/package.json +1 -1
- package/src/config.js +5 -6
- package/src/generators.js +10 -1
- package/src/semantics.js +10 -1
package/client.js
CHANGED
@@ -130,6 +130,10 @@ const setupArgs = (args, config, logs, hierarchy) => {
|
|
130
130
|
}
|
131
131
|
}
|
132
132
|
args.motivation = (m) => config.addMotivation(m)
|
133
|
+
args.breakOnSemantics = false
|
134
|
+
args.theDebugger = {
|
135
|
+
breakOnSemantics: (value) => args.breakOnSemantics = value
|
136
|
+
}
|
133
137
|
args.s = (c) => config.getSemantics(logs).apply(args, c)
|
134
138
|
args.g = (c) => config.getGenerators(logs).apply(args, c)
|
135
139
|
args.gp = (c) => config.getGenerators(logs).apply(args, { ...c, paraphrase: true, isResponse: false, response: false})
|
@@ -240,14 +244,18 @@ const processContext = (context, { objects = {}, config, logs = [] }) => {
|
|
240
244
|
}
|
241
245
|
|
242
246
|
const convertToStable = (objects) => {
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
stableObjects.namespaced
|
248
|
-
counter
|
249
|
-
|
250
|
-
|
247
|
+
if (true) {
|
248
|
+
return objects
|
249
|
+
} else {
|
250
|
+
const stableObjects = Object.assign({}, objects)
|
251
|
+
stableObjects.namespaced = {}
|
252
|
+
let counter = 0
|
253
|
+
Object.keys(((objects || {}).namespaced || {})).forEach((uuid) => {
|
254
|
+
stableObjects.namespaced[`${counter}`] = objects.namespaced[uuid]
|
255
|
+
counter += 1
|
256
|
+
})
|
257
|
+
return stableObjects
|
258
|
+
}
|
251
259
|
}
|
252
260
|
|
253
261
|
const writeTestFile = (fn, tests) => {
|
@@ -330,7 +338,7 @@ const setupContexts = (rawContexts) => {
|
|
330
338
|
return contexts
|
331
339
|
}
|
332
340
|
|
333
|
-
const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, query, data, retries, url }) => {
|
341
|
+
const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, query, data, retries, url, commandLineArgs }) => {
|
334
342
|
// TODO fix this name to contextsPrime
|
335
343
|
const contextsPrime = []
|
336
344
|
const generatedPrime = []
|
@@ -344,6 +352,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
344
352
|
const toDo = [...contexts]
|
345
353
|
args.insert = (context) => toDo.unshift(context)
|
346
354
|
let overlap, lastRange;
|
355
|
+
config.debugLoops = commandLineArgs && commandLineArgs.debugLoops
|
347
356
|
while (toDo.length > 0) {
|
348
357
|
const context = toDo.shift()
|
349
358
|
/*
|
@@ -373,7 +382,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
373
382
|
context.topLevel = true
|
374
383
|
try {
|
375
384
|
if (json.has_errors) {
|
376
|
-
throw new Error('There are errors in the logs')
|
385
|
+
throw new Error('There are errors in the logs. Run with the -d flag and grep for Error')
|
377
386
|
}
|
378
387
|
if (!config.get('skipSemantics')) {
|
379
388
|
if (!config.doMotivations(args, context)) {
|
@@ -523,7 +532,7 @@ const processInstance = (config, instance) => {
|
|
523
532
|
// config.addInternal(config.template.queries[i], { handleCalculatedProps: true } )
|
524
533
|
config.addInternal(instance.template.queries[i], { handleCalculatedProps: true } )
|
525
534
|
} else {
|
526
|
-
processContextsB({ config, hierarchy, json: results/*, generators, semantics
|
535
|
+
processContextsB({ config, hierarchy, json: results/*, generators, semantics */, commandLineArgs: {} })
|
527
536
|
}
|
528
537
|
}
|
529
538
|
global.transitoryMode = transitoryMode
|
@@ -604,7 +613,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
604
613
|
throw json
|
605
614
|
} else {
|
606
615
|
const { contextsPrime, generatedPrime, paraphrasesPrime, responsesPrime } =
|
607
|
-
processContextsB({ isTest, config, hierarchy, json/*, generators, semantics */ })
|
616
|
+
processContextsB({ isTest, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
|
608
617
|
response.associations = json.associations
|
609
618
|
response.hierarchy = json.hierarchy
|
610
619
|
response.load_cache_time += json.load_cache_time
|
@@ -685,8 +694,10 @@ const runTest = async (config, expected, { verbose, afterTest, testConfig, debug
|
|
685
694
|
}
|
686
695
|
|
687
696
|
let objects = getObjects(config.config.objects)(config.uuid)
|
697
|
+
let testConfigName = config.name
|
688
698
|
if (testConfig.testModuleName) {
|
689
699
|
objects = getObjects(config.config.objects)(config.getConfigs()[testConfig.testModuleName].uuid)
|
700
|
+
testConfigName = testConfig.testModuleName
|
690
701
|
}
|
691
702
|
config.beforeQuery({ query: test, isModule: false, objects })
|
692
703
|
// config.resetMotivations()
|
@@ -717,7 +728,8 @@ const runTest = async (config, expected, { verbose, afterTest, testConfig, debug
|
|
717
728
|
}
|
718
729
|
return picked
|
719
730
|
}
|
720
|
-
|
731
|
+
debugger
|
732
|
+
const expected_checked = sortJson(pickEm(expected.objects.namespaced[expected.objects.nameToUUID[testConfigName]]), { depth: 25 })
|
721
733
|
const actual_checked = sortJson(pickEm(objects), { depth: 25 })
|
722
734
|
const failed_checked = !matching(actual_objects, expected_objects)
|
723
735
|
|
@@ -806,7 +818,14 @@ const saveTest = async (testFile, config, test, expected, testConfig, saveDevelo
|
|
806
818
|
const result = await _process(config, test, { isTest: true })
|
807
819
|
// const actualObjects = config.config.objects
|
808
820
|
const actualConfig = getConfigForTest(config, testConfig)
|
809
|
-
|
821
|
+
const args = {
|
822
|
+
}
|
823
|
+
const saveObjects = {...config.config.objects}
|
824
|
+
saveObjects.nameToUUID = {}
|
825
|
+
for (let km of config.configs) {
|
826
|
+
saveObjects.nameToUUID[km.name] = km.uuid
|
827
|
+
}
|
828
|
+
writeTest(testFile, test, saveObjects, result.generated, result.paraphrases, result.responses, result.contexts, result.associations, result.metadata, actualConfig, saveDeveloper)
|
810
829
|
}
|
811
830
|
|
812
831
|
const saveTestsHelper = async (testFile, config, tests, todo, testConfig, saveDeveloper) => {
|
@@ -935,6 +954,7 @@ const defaultErrorHandler = async (error) => {
|
|
935
954
|
console.log(error.stack)
|
936
955
|
}
|
937
956
|
|
957
|
+
let doErrorExit = false
|
938
958
|
if (error.errors) {
|
939
959
|
console.log('error: ')
|
940
960
|
for (const e of error.errors) {
|
@@ -949,19 +969,25 @@ const defaultErrorHandler = async (error) => {
|
|
949
969
|
} else {
|
950
970
|
console.log('\n ', e)
|
951
971
|
}
|
972
|
+
doErrorExit = true
|
952
973
|
}
|
953
974
|
}
|
954
975
|
if (error.error) {
|
955
976
|
console.log('error: ')
|
956
977
|
for (const e of error.error) {
|
957
978
|
console.log('\n ', e)
|
979
|
+
doErrorExit = true
|
958
980
|
}
|
959
981
|
}
|
960
982
|
|
961
983
|
if (error.query) {
|
962
984
|
console.log('query: ', error.query)
|
985
|
+
doErrorExit = true
|
963
986
|
}
|
964
987
|
|
988
|
+
if (doErrorExit) {
|
989
|
+
runtime.process.exit(-1)
|
990
|
+
}
|
965
991
|
// throw error
|
966
992
|
}
|
967
993
|
|
@@ -1136,6 +1162,8 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
|
|
1136
1162
|
delete result.load_cache_time
|
1137
1163
|
delete result.times
|
1138
1164
|
delete result.memory_free_percent
|
1165
|
+
delete result.logs
|
1166
|
+
delete result.version
|
1139
1167
|
result.hierarchy.sort()
|
1140
1168
|
stabilizeAssociations(result.associations)
|
1141
1169
|
}
|
@@ -1251,9 +1279,11 @@ const knowledgeModule = async ({
|
|
1251
1279
|
processResults = processResults({ config, errorHandler })
|
1252
1280
|
config.description = description
|
1253
1281
|
config.demo = demo
|
1254
|
-
if (typeof test === 'object'
|
1255
|
-
|
1256
|
-
|
1282
|
+
if (typeof test === 'object') {
|
1283
|
+
if (test.contents) {
|
1284
|
+
config.tests = test.contents
|
1285
|
+
test = test.name
|
1286
|
+
}
|
1257
1287
|
} else {
|
1258
1288
|
if (runtime.fs && runtime.fs.existsSync(test)) {
|
1259
1289
|
config.tests = JSON.parse(runtime.fs.readFileSync(test))
|
@@ -1261,6 +1291,7 @@ const knowledgeModule = async ({
|
|
1261
1291
|
config.tests = {}
|
1262
1292
|
}
|
1263
1293
|
}
|
1294
|
+
config.setTestConfig(testConfig)
|
1264
1295
|
|
1265
1296
|
if (!isProcess) {
|
1266
1297
|
if (template) {
|
@@ -1300,6 +1331,7 @@ const knowledgeModule = async ({
|
|
1300
1331
|
parser.add_argument('-s', '--save', { action: 'store_true', help: 'When running with the --query flag this will save the current run to the test file. When running without the --query flag all tests will be run and resaved.' })
|
1301
1332
|
parser.add_argument('-sd', '--saveDeveloper', { action: 'store_true', help: 'Same as -s but the query will not show up in the info command.' })
|
1302
1333
|
parser.add_argument('-dic', '--debugIncludeConvolutions', { action: 'store_true', help: 'When running with the --debugIncludeConvolutions flag the logs will include convolutions which are somewhat annoying verbose. Default is false' })
|
1334
|
+
parser.add_argument('-dl', '--debugLoops', { action: 'store_true', help: 'When running with the --debugLoops flag the logs calls to semantics and generators will be immediately written to the console '})
|
1303
1335
|
parser.add_argument('-d', '--debug', { action: 'store_true', help: 'When running with the --debug flag this set the debug flag in the config' })
|
1304
1336
|
parser.add_argument('-da', '--debugAssociation', { help: 'When running with the --debugAssociation flag the debugging will break when the specified association is added to the config' })
|
1305
1337
|
parser.add_argument('-dh', '--debugHierarchy', { help: 'When running with the --debugHierarchy flag the debugging will break when the specified child-parent pair is added to the config for the main config. Set DEBUG_HIERARCHY to debug any config loaded. For example DEBUG_HIERARCHY=\'["cat", "mammel"]\'' })
|
@@ -1508,7 +1540,6 @@ const knowledgeModule = async ({
|
|
1508
1540
|
test = useTestConfig.name
|
1509
1541
|
|
1510
1542
|
}
|
1511
|
-
// runTests(config, args.testFileName ? `${args.testFileName}.test.json` : test, { debug: args.debug, testConfig: testConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
|
1512
1543
|
runTests(config, test, { debug: args.debug, testConfig: useTestConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
|
1513
1544
|
if (results.length > 0 && args.vimdiff) {
|
1514
1545
|
for (const result of results) {
|
@@ -1638,7 +1669,6 @@ const knowledgeModule = async ({
|
|
1638
1669
|
}
|
1639
1670
|
} else {
|
1640
1671
|
config.addAssociationsFromTests(config.tests);
|
1641
|
-
config.setTestConfig(testConfig)
|
1642
1672
|
//for (let query in config.tests) {
|
1643
1673
|
// config.addAssociations(config.tests[query].associations || []);
|
1644
1674
|
//}
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -1220,6 +1220,9 @@ class Config {
|
|
1220
1220
|
config.priorities = config.priorities || []
|
1221
1221
|
}
|
1222
1222
|
|
1223
|
+
this.maxDepth = 20 // for generators and semantics
|
1224
|
+
this.debugLoops = false // for generators and semantics
|
1225
|
+
|
1223
1226
|
this.allowDelta = false
|
1224
1227
|
this.resetDelta()
|
1225
1228
|
|
@@ -1482,6 +1485,8 @@ class Config {
|
|
1482
1485
|
this.valid()
|
1483
1486
|
const cp = new Config()
|
1484
1487
|
cp.logs = []
|
1488
|
+
cp.maxDepth = this.maxDepth
|
1489
|
+
cp.debugLoops = this.debugLoops
|
1485
1490
|
cp.transitoryMode = this.transitoryMode
|
1486
1491
|
cp.configs = this.configs.map((km) => km.copy2(Object.assign({}, options, { getCounter: (name) => cp.getCounter(name), callInitializers: false })))
|
1487
1492
|
cp._uuid = cp.configs[0]._uuid
|
@@ -1883,12 +1888,6 @@ class Config {
|
|
1883
1888
|
const addInternals = []
|
1884
1889
|
const inits = []
|
1885
1890
|
const initAfterApis = []
|
1886
|
-
if (false && this.config.hierarchy.find( (pair) => JSON.stringify(pair) === JSON.stringify(["equipable2","property"]))) {
|
1887
|
-
debugger // happened
|
1888
|
-
}
|
1889
|
-
if (false && this.name == 'countable') {
|
1890
|
-
debugger // in rebuild
|
1891
|
-
}
|
1892
1891
|
const reverseIt = true
|
1893
1892
|
const interleaved = true
|
1894
1893
|
this.configs.forEach((km) => {
|
package/src/generators.js
CHANGED
@@ -77,7 +77,13 @@ class Generator {
|
|
77
77
|
if (!log) {
|
78
78
|
throw 'generators.apply argument log is required'
|
79
79
|
}
|
80
|
+
if (baseArgs.call && config && sbaseArgs.calls.stack.length > config.maxDepth) {
|
81
|
+
throw new Error(`Max depth of ${config.maxDepth} 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`)
|
82
|
+
}
|
80
83
|
|
84
|
+
if (config && config.debugLoops) {
|
85
|
+
console.log("apply", this.toLabel())
|
86
|
+
}
|
81
87
|
// this.getAPI(config)
|
82
88
|
let n = (id) => id
|
83
89
|
if (config && 'nsToString' in config) {
|
@@ -109,6 +115,9 @@ class Generator {
|
|
109
115
|
apis: this.getAPIs(config)
|
110
116
|
}
|
111
117
|
const args = Object.assign({}, baseArgs, moreArgs, (baseArgs.getUUIDScoped || (() => { return {} }))(this.uuid))
|
118
|
+
if (this.property == 'generatorp') {
|
119
|
+
args.g = args.gp
|
120
|
+
}
|
112
121
|
// if (this.callId) {
|
113
122
|
// greg
|
114
123
|
/*
|
@@ -256,10 +265,10 @@ class Generators {
|
|
256
265
|
lines.newRow()
|
257
266
|
lines.setElement(0, 1, 'STACK')
|
258
267
|
lines.setElement(0, 2, stack)
|
259
|
-
lines.newRow()
|
260
268
|
lines.newRow()
|
261
269
|
lines.setElement(0, 1, 'DEBUG')
|
262
270
|
lines.setElement(0, 2, `To debug this use args.callId == '${args.calls.current()}'`)
|
271
|
+
lines.newRow()
|
263
272
|
lines.setElement(0, 1, 'TO')
|
264
273
|
lines.setElement(0, 2, `(HASHCODE ${helpers.hashCode(JSON.stringify(helpers.sortJson(context, { depth: 25 })))})`)
|
265
274
|
lines.setElement(1, 2, JSON.stringify(helpers.sortJson(context, { depth: 25 }), null, 2))
|
package/src/semantics.js
CHANGED
@@ -79,6 +79,13 @@ class Semantic {
|
|
79
79
|
apply (baseArgs, context, s, log, options = {}) {
|
80
80
|
const { hierarchy, config, response } = baseArgs
|
81
81
|
const objects = baseArgs.getObjects(this.uuid)
|
82
|
+
if (config && config.debugLoops) {
|
83
|
+
console.log("apply", this.toLabel())
|
84
|
+
}
|
85
|
+
if (baseArgs.calls && config && baseArgs.calls.stack.length > config.maxDepth) {
|
86
|
+
throw new Error(`Max depth of ${config.maxDepth} 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`)
|
87
|
+
}
|
88
|
+
|
82
89
|
// const ask = baseArgs.getAsk(this.uuid)
|
83
90
|
if (!log) {
|
84
91
|
console.trace()
|
@@ -111,6 +118,9 @@ class Semantic {
|
|
111
118
|
callId == this.callId) {
|
112
119
|
debugger;
|
113
120
|
}
|
121
|
+
if (args.breakOnSemantics) {
|
122
|
+
debugger
|
123
|
+
}
|
114
124
|
this._apply(args)
|
115
125
|
return contextPrime
|
116
126
|
}
|
@@ -168,7 +178,6 @@ class Semantics {
|
|
168
178
|
if (!(context instanceof Array || context instanceof Object)) {
|
169
179
|
return context
|
170
180
|
}
|
171
|
-
|
172
181
|
const config = args.config
|
173
182
|
let contextPrime = Object.assign({}, context)
|
174
183
|
const s = (context, options) => this.apply(args, context, options)
|