theprogrammablemind_4wp 7.5.5 → 7.5.6
Sign up to get free protection for your applications and to get access to all the features.
- package/client.js +18 -4
- package/package.json +1 -1
- package/src/config.js +5 -6
- package/src/generators.js +6 -0
- 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})
|
@@ -330,7 +334,7 @@ const setupContexts = (rawContexts) => {
|
|
330
334
|
return contexts
|
331
335
|
}
|
332
336
|
|
333
|
-
const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, query, data, retries, url }) => {
|
337
|
+
const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, query, data, retries, url, commandLineArgs }) => {
|
334
338
|
// TODO fix this name to contextsPrime
|
335
339
|
const contextsPrime = []
|
336
340
|
const generatedPrime = []
|
@@ -344,6 +348,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
344
348
|
const toDo = [...contexts]
|
345
349
|
args.insert = (context) => toDo.unshift(context)
|
346
350
|
let overlap, lastRange;
|
351
|
+
config.debugLoops = commandLineArgs && commandLineArgs.debugLoops
|
347
352
|
while (toDo.length > 0) {
|
348
353
|
const context = toDo.shift()
|
349
354
|
/*
|
@@ -523,7 +528,7 @@ const processInstance = (config, instance) => {
|
|
523
528
|
// config.addInternal(config.template.queries[i], { handleCalculatedProps: true } )
|
524
529
|
config.addInternal(instance.template.queries[i], { handleCalculatedProps: true } )
|
525
530
|
} else {
|
526
|
-
processContextsB({ config, hierarchy, json: results/*, generators, semantics
|
531
|
+
processContextsB({ config, hierarchy, json: results/*, generators, semantics */, commandLineArgs: {} })
|
527
532
|
}
|
528
533
|
}
|
529
534
|
global.transitoryMode = transitoryMode
|
@@ -604,7 +609,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
|
|
604
609
|
throw json
|
605
610
|
} else {
|
606
611
|
const { contextsPrime, generatedPrime, paraphrasesPrime, responsesPrime } =
|
607
|
-
processContextsB({ isTest, config, hierarchy, json/*, generators, semantics */ })
|
612
|
+
processContextsB({ isTest, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
|
608
613
|
response.associations = json.associations
|
609
614
|
response.hierarchy = json.hierarchy
|
610
615
|
response.load_cache_time += json.load_cache_time
|
@@ -935,6 +940,7 @@ const defaultErrorHandler = async (error) => {
|
|
935
940
|
console.log(error.stack)
|
936
941
|
}
|
937
942
|
|
943
|
+
let doErrorExit = false
|
938
944
|
if (error.errors) {
|
939
945
|
console.log('error: ')
|
940
946
|
for (const e of error.errors) {
|
@@ -949,19 +955,25 @@ const defaultErrorHandler = async (error) => {
|
|
949
955
|
} else {
|
950
956
|
console.log('\n ', e)
|
951
957
|
}
|
958
|
+
doErrorExit = true
|
952
959
|
}
|
953
960
|
}
|
954
961
|
if (error.error) {
|
955
962
|
console.log('error: ')
|
956
963
|
for (const e of error.error) {
|
957
964
|
console.log('\n ', e)
|
965
|
+
doErrorExit = true
|
958
966
|
}
|
959
967
|
}
|
960
968
|
|
961
969
|
if (error.query) {
|
962
970
|
console.log('query: ', error.query)
|
971
|
+
doErrorExit = true
|
963
972
|
}
|
964
973
|
|
974
|
+
if (doErrorExit) {
|
975
|
+
runtime.process.exit(-1)
|
976
|
+
}
|
965
977
|
// throw error
|
966
978
|
}
|
967
979
|
|
@@ -1136,6 +1148,8 @@ const build = async ({ config, target, template, errorHandler = defaultErrorHand
|
|
1136
1148
|
delete result.load_cache_time
|
1137
1149
|
delete result.times
|
1138
1150
|
delete result.memory_free_percent
|
1151
|
+
delete result.logs
|
1152
|
+
delete result.version
|
1139
1153
|
result.hierarchy.sort()
|
1140
1154
|
stabilizeAssociations(result.associations)
|
1141
1155
|
}
|
@@ -1300,6 +1314,7 @@ const knowledgeModule = async ({
|
|
1300
1314
|
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
1315
|
parser.add_argument('-sd', '--saveDeveloper', { action: 'store_true', help: 'Same as -s but the query will not show up in the info command.' })
|
1302
1316
|
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' })
|
1317
|
+
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
1318
|
parser.add_argument('-d', '--debug', { action: 'store_true', help: 'When running with the --debug flag this set the debug flag in the config' })
|
1304
1319
|
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
1320
|
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 +1523,6 @@ const knowledgeModule = async ({
|
|
1508
1523
|
test = useTestConfig.name
|
1509
1524
|
|
1510
1525
|
}
|
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
1526
|
runTests(config, test, { debug: args.debug, testConfig: useTestConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
|
1513
1527
|
if (results.length > 0 && args.vimdiff) {
|
1514
1528
|
for (const result of results) {
|
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) {
|
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)
|