theprogrammablemind_4wp 7.6.0-beta.4 → 7.6.0-beta.6
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 +51 -13
- package/package.json +1 -1
- package/runtime.js +1 -0
- package/src/flatten.js +3 -0
- package/src/project.js +0 -1
    
        package/client.js
    CHANGED
    
    | @@ -660,6 +660,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia | |
| 660 660 | 
             
                    opChoices: []
         | 
| 661 661 | 
             
                  },
         | 
| 662 662 | 
             
                  times: 0.0,
         | 
| 663 | 
            +
                  clientSideTimes: 0.0,
         | 
| 663 664 | 
             
                  trace: '',
         | 
| 664 665 | 
             
                  contexts: [],
         | 
| 665 666 | 
             
                  generated: [],
         | 
| @@ -701,8 +702,16 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia | |
| 701 702 | 
             
                  if (json.status !== 200) {
         | 
| 702 703 | 
             
                    throw json
         | 
| 703 704 | 
             
                  } else {
         | 
| 705 | 
            +
                    let clientSideTime
         | 
| 706 | 
            +
                    if (isTest) {
         | 
| 707 | 
            +
                      start = runtime.performance.performance.now()
         | 
| 708 | 
            +
                    }
         | 
| 704 709 | 
             
                    const { contextsPrime, generatedPrime, paraphrasesPrime, paraphrasesParenthesizedPrime, generatedParenthesizedPrime, responsesPrime } =
         | 
| 705 710 | 
             
                                              processContextsB({ isTest, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
         | 
| 711 | 
            +
                    if (isTest) {
         | 
| 712 | 
            +
                      end = runtime.performance.performance.now()
         | 
| 713 | 
            +
                      clientSideTime = end - start
         | 
| 714 | 
            +
                    }
         | 
| 706 715 | 
             
                    response.associations = json.associations
         | 
| 707 716 | 
             
                    response.learned_contextual_priorities = json.learned_contextual_priorities
         | 
| 708 717 | 
             
                    response.hierarchy = json.hierarchy
         | 
| @@ -713,6 +722,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia | |
| 713 722 | 
             
                    // appendNoDups(response.metadata.priorities, json.metadata.priorities)
         | 
| 714 723 | 
             
                    appendNoDups(response.metadata.opChoices, json.metadata.opChoices)
         | 
| 715 724 | 
             
                    response.times += json.times
         | 
| 725 | 
            +
                    response.clientSideTimes += clientSideTime
         | 
| 716 726 | 
             
                    response.trace = response.trace.concat(json.trace)
         | 
| 717 727 | 
             
                    response.version = json.version
         | 
| 718 728 | 
             
                    response.explain_priorities = json.explain_priorities
         | 
| @@ -802,10 +812,10 @@ const runTest = async (config, expected, { args, verbose, testConfig, debug }) = | |
| 802 812 | 
             
                    defaultInnerProcess(config, errorHandler, result)
         | 
| 803 813 | 
             
                  }
         | 
| 804 814 | 
             
                  if (verbose) {
         | 
| 805 | 
            -
                    const widths = [100,  | 
| 815 | 
            +
                    const widths = [100, 60]
         | 
| 806 816 | 
             
                    const lines = new Lines(widths)
         | 
| 807 817 | 
             
                    lines.setElement(0, 0, test)
         | 
| 808 | 
            -
                    lines.setElement(0, 1, `time on server ${result.times.toFixed(2)}`)
         | 
| 818 | 
            +
                    lines.setElement(0, 1, `time on server: ${result.times.toFixed(2)} client: ${(result.clientSideTimes/1000).toFixed(2)}`)
         | 
| 809 819 | 
             
                    lines.log()
         | 
| 810 820 | 
             
                  }
         | 
| 811 821 | 
             
                  const expected_objects = sortJson(convertToStable(expected.objects), { depth: 25 })
         | 
| @@ -1323,6 +1333,7 @@ const rebuildTemplate = async ({ config, target, template, errorHandler = defaul | |
| 1323 1333 | 
             
                      } else {
         | 
| 1324 1334 | 
             
                        delete result.load_cache_time
         | 
| 1325 1335 | 
             
                        delete result.times
         | 
| 1336 | 
            +
                        delete result.clientSideTimes
         | 
| 1326 1337 | 
             
                        delete result.memory_free_percent
         | 
| 1327 1338 | 
             
                        delete result.logs
         | 
| 1328 1339 | 
             
                        delete result.version
         | 
| @@ -1362,6 +1373,28 @@ const rebuildTemplate = async ({ config, target, template, errorHandler = defaul | |
| 1362 1373 | 
             
              await looper(Object.assign([], todo))
         | 
| 1363 1374 | 
             
            }
         | 
| 1364 1375 |  | 
| 1376 | 
            +
            const checkTemplate = (template) => {
         | 
| 1377 | 
            +
              return
         | 
| 1378 | 
            +
              if (!template) {
         | 
| 1379 | 
            +
                return
         | 
| 1380 | 
            +
              }
         | 
| 1381 | 
            +
              if (template.checks) {
         | 
| 1382 | 
            +
                throw new Error("The 'checks' property should be in the 'test' property not the 'template' property")
         | 
| 1383 | 
            +
              }
         | 
| 1384 | 
            +
            }
         | 
| 1385 | 
            +
             | 
| 1386 | 
            +
            const checkTest = (testConfig) => {
         | 
| 1387 | 
            +
              if (!testConfig) {
         | 
| 1388 | 
            +
                return
         | 
| 1389 | 
            +
              }
         | 
| 1390 | 
            +
              if (!testConfig.name) {
         | 
| 1391 | 
            +
                throw new Error("The 'test' property is missing the 'name' property that contains the name of the '<km>.test.json' file")
         | 
| 1392 | 
            +
              }
         | 
| 1393 | 
            +
              if (!testConfig.contents) {
         | 
| 1394 | 
            +
                throw new Error("The 'test' property is missing the 'contents' property that contains contents of the '<km>.test.json' file")
         | 
| 1395 | 
            +
              }
         | 
| 1396 | 
            +
            }
         | 
| 1397 | 
            +
             | 
| 1365 1398 | 
             
            const knowledgeModule = async ({
         | 
| 1366 1399 | 
             
              module: moduleFromJSFile,
         | 
| 1367 1400 | 
             
              description,
         | 
| @@ -1395,9 +1428,10 @@ const knowledgeModule = async ({ | |
| 1395 1428 | 
             
              if (!description) {
         | 
| 1396 1429 | 
             
                throw new Error("'description' is a required parameter. The value should the description of the knowledge module.")
         | 
| 1397 1430 | 
             
              }
         | 
| 1398 | 
            -
              if (! | 
| 1431 | 
            +
              if (!testConfig) {
         | 
| 1399 1432 | 
             
                throw new Error("'test' is a required parameter. The value should the path to the file used to store the tests of the knowledge module and the contents of the file in the form { name: <filePath>, contexts: <json> }.")
         | 
| 1400 1433 | 
             
              }
         | 
| 1434 | 
            +
              checkTest(testConfig)
         | 
| 1401 1435 |  | 
| 1402 1436 | 
             
              const isProcess = require.main === moduleFromJSFile
         | 
| 1403 1437 |  | 
| @@ -1666,6 +1700,8 @@ const knowledgeModule = async ({ | |
| 1666 1700 | 
             
                  }
         | 
| 1667 1701 | 
             
                }
         | 
| 1668 1702 |  | 
| 1703 | 
            +
                checkTemplate(template)
         | 
| 1704 | 
            +
             | 
| 1669 1705 | 
             
                if (template) {
         | 
| 1670 1706 | 
             
                  const needsRebuild = config.needsRebuild(template.template, template.instance, options)
         | 
| 1671 1707 | 
             
                  if (needsRebuild) {
         | 
| @@ -1674,7 +1710,9 @@ const knowledgeModule = async ({ | |
| 1674 1710 | 
             
                    config.config.rebuild = true
         | 
| 1675 1711 | 
             
                  }
         | 
| 1676 1712 | 
             
                  config.load(template.template, template.instance, { rebuild: needsRebuild })
         | 
| 1677 | 
            -
                   | 
| 1713 | 
            +
                  if (!args.query) {
         | 
| 1714 | 
            +
                    printConfig()
         | 
| 1715 | 
            +
                  }
         | 
| 1678 1716 | 
             
                  if (needsRebuild) {
         | 
| 1679 1717 | 
             
                    return
         | 
| 1680 1718 | 
             
                  }
         | 
| @@ -1687,7 +1725,6 @@ const knowledgeModule = async ({ | |
| 1687 1725 | 
             
                if (args.test || args.testVerbose || args.testAllVerbose || args.save) {
         | 
| 1688 1726 | 
             
                  global.transitoryMode = true
         | 
| 1689 1727 | 
             
                }
         | 
| 1690 | 
            -
             | 
| 1691 1728 | 
             
                if (!args.query && !args.test && !args.info && (args.save || args.saveDeveloper)) {
         | 
| 1692 1729 | 
             
                  global.transitoryMode = true
         | 
| 1693 1730 | 
             
                  saveTests(config, test, testConfig, args.saveDeveloper)
         | 
| @@ -1709,7 +1746,6 @@ const knowledgeModule = async ({ | |
| 1709 1746 | 
             
                        useTestConfig = config.getConfigs()[args.testModuleName].getTestConfig()
         | 
| 1710 1747 | 
             
                        useTestConfig.testModuleName = args.testModuleName
         | 
| 1711 1748 | 
             
                        test = useTestConfig.name
         | 
| 1712 | 
            -
             | 
| 1713 1749 | 
             
                      }
         | 
| 1714 1750 | 
             
                      runTests(config, test, { args, debug: args.debug, testConfig: useTestConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
         | 
| 1715 1751 | 
             
                        let newError = false
         | 
| @@ -1827,16 +1863,18 @@ const knowledgeModule = async ({ | |
| 1827 1863 | 
             
                              }
         | 
| 1828 1864 | 
             
                            }
         | 
| 1829 1865 | 
             
                          }
         | 
| 1830 | 
            -
                          if ( | 
| 1866 | 
            +
                          if (hasError) {
         | 
| 1867 | 
            +
                            if (!headerShown) {
         | 
| 1868 | 
            +
                              if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
         | 
| 1869 | 
            +
                                console.log('There are failures due to things other than paraphrases, responses and checked properties being different. They are not shown because you ran -tv or -tva which only shows difference in paraphrase and results. Usually what I do is -s and do a diff to make sure there are no other problems. If the paraphrases or results were different they would have shown here.')
         | 
| 1870 | 
            +
                              }
         | 
| 1871 | 
            +
                            }
         | 
| 1831 1872 | 
             
                            if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
         | 
| 1832 | 
            -
                              console.log(' | 
| 1873 | 
            +
                              console.log('use -v arg to write files expected.json and actual.json in the current directory for detailed comparison. Or do -s and then git diff the changes.')
         | 
| 1874 | 
            +
                              // console.log(JSON.stringify(contexts))
         | 
| 1875 | 
            +
                              console.log('**************************** ERRORS ************************')
         | 
| 1833 1876 | 
             
                            }
         | 
| 1834 1877 | 
             
                          }
         | 
| 1835 | 
            -
                          if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
         | 
| 1836 | 
            -
                            console.log('use -v arg to write files expected.json and actual.json in the current directory for detailed comparison. Or do -s and then git diff the changes.')
         | 
| 1837 | 
            -
                            // console.log(JSON.stringify(contexts))
         | 
| 1838 | 
            -
                            console.log('**************************** ERRORS ************************')
         | 
| 1839 | 
            -
                          }
         | 
| 1840 1878 | 
             
                        }
         | 
| 1841 1879 | 
             
                        // const contexts = { failures: results }
         | 
| 1842 1880 | 
             
                        l(n - 1, hasError || newError)
         | 
    
        package/package.json
    CHANGED
    
    
    
        package/runtime.js
    CHANGED
    
    
    
        package/src/flatten.js
    CHANGED