tpmkms_4wp 8.0.0-beta.3 → 8.0.0-beta.31

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.
Files changed (86) hide show
  1. package/common/animals.instance.json +2542 -1375
  2. package/common/animals.js +2 -2
  3. package/common/avatar.js +2 -2
  4. package/common/characters.js +9 -11
  5. package/common/colors.instance.json +6646 -3529
  6. package/common/colors.js +2 -2
  7. package/common/colors.test.json +345 -780
  8. package/common/comparable.js +2 -15
  9. package/common/concept.js +17 -11
  10. package/common/countable.js +5 -5
  11. package/common/crew.instance.json +12534 -6597
  12. package/common/crew.js +4 -4
  13. package/common/crew.test.json +714 -452
  14. package/common/currency.js +7 -7
  15. package/common/dialogues.js +53 -138
  16. package/common/dimension.instance.json +246 -265
  17. package/common/dimension.js +12 -12
  18. package/common/dimension.test.json +446 -1640
  19. package/common/edible.instance.json +19308 -10008
  20. package/common/edible.js +2 -2
  21. package/common/emotions.instance.json +122 -129
  22. package/common/emotions.js +4 -4
  23. package/common/events.js +6 -6
  24. package/common/fastfood.instance.json +219409 -111252
  25. package/common/fastfood.js +24 -24
  26. package/common/formulas.instance.json +222 -256
  27. package/common/formulas.js +14 -14
  28. package/common/gdefaults.js +13 -13
  29. package/common/help.js +4 -4
  30. package/common/help.test.json +10 -22
  31. package/common/helpers/concept.js +9 -6
  32. package/common/helpers/dialogues.js +2 -3
  33. package/common/helpers/properties.js +48 -58
  34. package/common/hierarchy.js +12 -16
  35. package/common/javascript.js +8 -8
  36. package/common/kirk.instance.json +564 -290
  37. package/common/kirk.js +2 -2
  38. package/common/length.instance.json +5153 -4677
  39. package/common/length.js +2 -2
  40. package/common/math.instance.json +152 -1169
  41. package/common/math.js +11 -11
  42. package/common/meta.js +22 -29
  43. package/common/negation.instance.json +2 -0
  44. package/common/negation.js +38 -0
  45. package/common/negation.test.json +308 -0
  46. package/common/numbers.js +3 -3
  47. package/common/ordering.instance.json +292 -230
  48. package/common/ordering.js +5 -5
  49. package/common/people.instance.json +1902 -1015
  50. package/common/people.js +4 -5
  51. package/common/percentages.instance.json +2 -0
  52. package/common/percentages.js +57 -0
  53. package/common/percentages.test.json +751 -0
  54. package/common/pipboy.instance.json +7720 -6386
  55. package/common/pipboy.js +29 -32
  56. package/common/pokemon.instance.json +3954 -2081
  57. package/common/pokemon.js +4 -4
  58. package/common/pos.js +1 -1
  59. package/common/pressure.instance.json +1265 -1193
  60. package/common/pressure.js +2 -2
  61. package/common/properties.instance.json +106 -61
  62. package/common/properties.js +54 -125
  63. package/common/punctuation.js +2 -2
  64. package/common/reports.instance.json +557 -559
  65. package/common/reports.js +54 -74
  66. package/common/scorekeeper.js +13 -21
  67. package/common/sdefaults.js +13 -3
  68. package/common/sizeable.js +2 -2
  69. package/common/spock.instance.json +564 -290
  70. package/common/spock.js +2 -2
  71. package/common/stgame.js +13 -9
  72. package/common/stm.js +4 -4
  73. package/common/tell.js +10 -10
  74. package/common/temperature.instance.json +1297 -1209
  75. package/common/temperature.js +2 -2
  76. package/common/tester.js +2 -2
  77. package/common/testing.js +5 -5
  78. package/common/time.js +7 -7
  79. package/common/tokenize.js +1 -1
  80. package/common/ui.instance.json +238 -259
  81. package/common/ui.js +9 -9
  82. package/common/weight.instance.json +4905 -4166
  83. package/common/weight.js +2 -2
  84. package/common/yesno.js +1 -1
  85. package/main.js +51 -46
  86. package/package.json +13 -6
@@ -221,7 +221,7 @@ let configStruct = {
221
221
  notes: 'expression with constraints',
222
222
  where: where(),
223
223
  match: ({context}) => context.constraints && context.paraphrase,
224
- apply: ({context, g}) => {
224
+ apply: async ({context, g}) => {
225
225
  // TODO assume one constaints deal with more in the future
226
226
  const constraint = context.constraints[0]
227
227
  const constrained = Object.assign({}, constraint.constraint)
@@ -234,86 +234,25 @@ let configStruct = {
234
234
  paraphrase.paraphrase = true;
235
235
  paraphrase[constraint.property] = property
236
236
  if (false && context.isResponse) {
237
- return g({...constraint.paraphrase, paraphrase: true})
237
+ return await g({...constraint.paraphrase, paraphrase: true})
238
238
  } else {
239
- return g(constrained)
239
+ return await g(constrained)
240
240
  }
241
241
  },
242
242
  },
243
243
  {
244
244
  where: where(),
245
245
  match: ({context}) => context.marker == 'xfx',
246
- apply: ({context, g}) => `${context.word} between ${g(context.arguments)}`
246
+ apply: async ({context, g}) => `${context.word} between ${await g(context.arguments)}`
247
247
  },
248
- // {
249
- // notes: '"fire type, water type and earth type" to "fire water and earth type"',
250
- // tests: [
251
- // 'chicken modifies strips',
252
- // ],
253
- // /*
254
- // {
255
- // "water": {
256
- // "marker": "water",
257
- // "value": "water",
258
- // "word": "water"
259
- // },
260
- // "marker": "water_type",
261
- // "modifiers": [
262
- // "water"
263
- // ],
264
- // "types": [
265
- // "water_type"
266
- // ],
267
- // "value": "water_type",
268
- // "word": "type",
269
- // "paraphrase": true
270
- // },
271
- // */
272
- // where: where(),
273
- // match: ({context}) => {
274
- // if (!context.paraphrase) {
275
- // return
276
- // }
277
- // if (context.marker !== 'list') {
278
- // return
279
- // }
280
- // if ((context.value || []).length < 2) {
281
- // return
282
- // }
283
- // if (!context.value[0].word) {
284
- // return
285
- // }
286
- // const word = context.value[0].word
287
-
288
- // for (let value of context.value) {
289
- // if (!(value.modifiers && value.modifiers.length == 1 && value.word == word)) {
290
- // return
291
- // }
292
- // }
293
- // return true
294
- // },
295
- // apply: ({g, context}) => {
296
- // const modifiers = context.value.map( (p) => p[p.modifiers[0]] )
297
- // context.word = context.value[0].word
298
- // context.value = null
299
- // context.modifiers = ['modifier']
300
- // context.modifier = {
301
- // marker: 'list',
302
- // paraphrase: true,
303
- // value: modifiers
304
- // }
305
- // context.paraphrase = true
306
- // return g(context)
307
- // }
308
- // },
309
248
  {
310
249
  notes: 'add possession ending',
311
250
  priority: -1,
312
251
  where: where(),
313
252
  match: ({context}) => context.paraphrase && context.possessive,
314
- apply: ({context, g}) => {
253
+ apply: async ({context, g}) => {
315
254
  context.possessive = false
316
- const phrase = g(context)
255
+ const phrase = await g(context)
317
256
  context.possessive = true
318
257
  if (phrase.endsWith('s')) {
319
258
  return `${phrase}'`
@@ -322,13 +261,6 @@ let configStruct = {
322
261
  }
323
262
  }
324
263
  },
325
- /*
326
- {
327
- where: where(),
328
- match: ({context}) => context.marker == 'modifies' && context.paraphrase,
329
- apply: ({context}) => `${context.modifier.word} modifies ${context.concept.word}`,
330
- },
331
- */
332
264
  {
333
265
  where: where(),
334
266
  match: ({context}) => context.marker == 'objectPrefix' && context.value == 'other' && context.paraphrase,
@@ -353,15 +285,8 @@ let configStruct = {
353
285
  notes: 'negative do questions',
354
286
  where: where(),
355
287
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeDoQuestion') && context.paraphrase && context.negation,
356
- apply: ({context, g}) => {
357
- /*
358
- let query = ''
359
- if (context.query) {
360
- query = "?"
361
- }
362
- return `${g(context.object)} ${context.word} ${g(context.property)}${query}`
363
- */
364
- return `${g(context[context.do.left])} doesnt ${pluralize.plural(context.word)} ${g(context[context.do.right])}`
288
+ apply: async ({context, g}) => {
289
+ return `${await g(context[context.do.left])} doesnt ${pluralize.plural(context.word)} ${await g(context[context.do.right])}`
365
290
  },
366
291
  },
367
292
  {
@@ -369,23 +294,22 @@ let configStruct = {
369
294
  // debug: 'call9',
370
295
  where: where(),
371
296
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeDoQuestion') && context.paraphrase && context.query && context.do,
372
- apply: ({context, g}) => {
297
+ apply: async ({context, g}) => {
373
298
  const right = context['do'].right
374
299
  if (context[right].query) {
375
300
  const left = context['do'].left
376
- return `${g(context[right])} ${chooseNumber(context[right], "does", "do")} ${g(context[left])} ${context.word}`
301
+ return `${await g(context[right])} ${chooseNumber(context[right], "does", "do")} ${await g(context[left])} ${context.word}`
377
302
  } else {
378
- // return `does ${g(context[context.do.left])} ${pluralize.singular(context.word)} ${g(context[context.do.right])}`
379
303
  // the marker is the infinite form
380
- return `${chooseNumber(context[context.do.left], "does", "do")} ${g(context[context.do.left])} ${context.marker} ${g(context[context.do.right])}`
304
+ return `${chooseNumber(context[context.do.left], "does", "do")} ${await g(context[context.do.left])} ${context.marker} ${await g(context[context.do.right])}`
381
305
  }
382
306
  },
383
307
  },
384
308
  {
385
309
  where: where(),
386
310
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeDoQuestion') && context.paraphrase && !context.query,
387
- apply: ({context, g}) => {
388
- return `${g(context.object)} ${context.word} ${g(context.property)}`
311
+ apply: async ({context, g}) => {
312
+ return `${await g(context.object)} ${context.word} ${await g(context.property)}`
389
313
  }
390
314
  },
391
315
  {
@@ -393,17 +317,21 @@ let configStruct = {
393
317
  where: where(),
394
318
  // match: ({context}) => context.paraphrase && context.modifiers && context.object,
395
319
  match: ({context}) => context.paraphrase && !context.possession && context.object,
396
- apply: ({context, g, gs}) => {
320
+ apply: async ({context, g, gs}) => {
397
321
  const base = { ...context }
398
322
  base.object = undefined;
399
323
  if (context.object.marker == 'objectPrefix') {
400
- return `${g(context.object)} ${g(base)}`
324
+ return `${await g(context.object)} ${await g(base)}`
401
325
  } else {
402
326
  if (context.objects) {
403
- return gs(context.objects.map( (c) => g({...c, paraphrase: true}) ), ' of ')
327
+ const gObjects = []
328
+ for (const object of context.objects) {
329
+ gObjects.push(await g({...object, paraphrase: true}))
330
+ }
331
+ return await gs(gObjects, ' of ')
404
332
  } else {
405
333
  // TODO make paraphrase be a default when paraphrasing?
406
- return `${g(base)} of ${g({...context.object, paraphrase: true})}`
334
+ return `${await g(base)} of ${await g({...context.object, paraphrase: true})}`
407
335
  }
408
336
  }
409
337
  },
@@ -412,9 +340,9 @@ let configStruct = {
412
340
  // ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.value && !context.evaluate,
413
341
  where: where(),
414
342
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.object && !context.possession && !context.evaluate && !context.object.marker == 'objectPrefix',
415
- apply: ({context, g}) => {
343
+ apply: async ({context, g}) => {
416
344
  const property = Object.assign({}, context, { object: undefined })
417
- return `${g(property)} of ${g({ ...context.object, paraphrase: true })}`
345
+ return `${await g(property)} of ${await g({ ...context.object, paraphrase: true })}`
418
346
  }
419
347
  },
420
348
  {
@@ -422,25 +350,25 @@ let configStruct = {
422
350
  where: where(),
423
351
  // match: ({context}) => context.paraphrase && !context.modifiers && context.object,
424
352
  match: ({context}) => !context.modifiers && context.object,
425
- apply: ({context, g, gs}) => {
353
+ apply: async ({context, g, gs}) => {
426
354
  if (context.objects) {
427
355
  const objects = [ ...context.objects ]
428
356
  objects.reverse()
429
357
  let phrase = ''
430
358
  let separator = ''
431
359
  for (let i = 0; i < objects.length-1; ++i) {
432
- phrase = phrase + separator + g({...objects[i], paraphrase: context.paraphrase, possessive: true})
360
+ phrase = phrase + separator + await g({...objects[i], paraphrase: context.paraphrase, possessive: true})
433
361
  separator = ' '
434
362
  }
435
- phrase = phrase + separator + g({...objects[objects.length-1], paraphrase: context.paraphrase})
363
+ phrase = phrase + separator + await g({...objects[objects.length-1], paraphrase: context.paraphrase})
436
364
  return phrase
437
365
  } else {
438
366
  const base = { ...context }
439
367
  base.object = undefined; // TODO make paraphrase be a default when paraphrasing?
440
368
  if (context.object.marker == 'objectPrefix') {
441
- return `${g(context.object)} ${g(base)}`
369
+ return `${await g(context.object)} ${await g(base)}`
442
370
  } else {
443
- return `${g({...context.object, paraphrase: context.paraphrase})}'s ${g(base)}`
371
+ return `${await g({...context.object, paraphrase: context.paraphrase})}'s ${await g(base)}`
444
372
  }
445
373
  }
446
374
  },
@@ -534,15 +462,15 @@ let configStruct = {
534
462
  notes: 'greg has eyes?',
535
463
  where: where(),
536
464
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'have') && context.query,
537
- apply: ({context, g, api, objects}) => {
465
+ apply: async ({context, g, api, objects}) => {
538
466
  const object = pluralize.singular(context.object.value);
539
467
  const property = pluralize.singular(context.property.value);
540
468
  context.isResponse = true
541
- if (!api.knownObject(object)) {
542
- context.verbatim = `There is no object named ${g({...context.object, paraphrase: true})}`
469
+ if (!await api.knownObject(object)) {
470
+ context.verbatim = `There is no object named ${await g({...context.object, paraphrase: true})}`
543
471
  return
544
472
  }
545
- if (!api.hasProperty(object, property)) {
473
+ if (!await api.hasProperty(object, property)) {
546
474
  context.evalue = {
547
475
  marker: 'yesno',
548
476
  value: false,
@@ -561,7 +489,7 @@ let configStruct = {
561
489
  where: where(),
562
490
  // match: ({context}) => context.marker == 'property' && context.same && context.object,
563
491
  match: ({context, hierarchy, uuid}) => hierarchy.isA(context.marker, 'property') && context.same && context.objects && !context[`disable${uuid}`],
564
- apply: ({context, objects, km, api, log, s, uuid}) => {
492
+ apply: async ({context, objects, km, api, log, s, uuid}) => {
565
493
  const objectContext = context.object;
566
494
  const propertyContext = context;
567
495
  const objectId = context.object.value
@@ -576,7 +504,7 @@ let configStruct = {
576
504
  // greg HERE
577
505
  */
578
506
  propertyContext[`disable${uuid}`] = true
579
- const propertyId = km("dialogues").api.evaluateToConcept(propertyContext, context, log, s).evalue;
507
+ const propertyId = (await km("dialogues").api.evaluateToConcept(propertyContext, context, log, s)).evalue;
580
508
  try{
581
509
  // greg
582
510
  // api.makeObject({config, context: objectContext, doPluralize: false})
@@ -589,7 +517,7 @@ let configStruct = {
589
517
  log(`Error processing set property of an object: ${e}`)
590
518
  const config = km('properties')
591
519
  const fragment = config.fragment("the property1 of object1 is value1")
592
- const value = api.getProperty(objectId, propertyId)
520
+ const value = await api.getProperty(objectId, propertyId)
593
521
  if (value.value == context.same.value) {
594
522
  context.evalue = [
595
523
  { marker: 'yesno', value: true, paraphrase: true },
@@ -620,7 +548,7 @@ let configStruct = {
620
548
  context.evalue = [
621
549
  { marker: 'yesno', value: false, paraphrase: true },
622
550
  ]
623
- context.evalue = context.evalue.concat(fragment.instantiate(mappings))
551
+ context.evalue = context.evalue.concat(await fragment.instantiate(mappings))
624
552
  context.evalue.forEach( (r) => r.paraphrase = true )
625
553
  context.isResponse = true
626
554
  context.sameWasProcessed = true
@@ -638,48 +566,47 @@ let configStruct = {
638
566
  !context.evaluate.toConcept, // && !context.value,
639
567
  // greghere
640
568
  // match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'property') && context.evaluate,
641
- apply: ({context, api, kms, objects, g, s, log}) => {
569
+ apply: async ({context, api, kms, objects, g, s, log}) => {
642
570
  const toDo = [ ...context.objects ]
643
571
 
644
- const toValue = (objectContext) => {
572
+ const toValue = async (objectContext) => {
645
573
  if (!objectContext.value) {
646
574
  return objectContext;
647
575
  }
648
576
  let objectValue = kms.stm.api.getVariable(objectContext.value);
649
- if (!api.knownObject(objectValue)) {
650
- context.verbatim = `There is no object named "${g({...objectContext, paraphrase: true})}"`
577
+ if (!await api.knownObject(objectValue)) {
578
+ context.verbatim = `There is no object named "${await g({...objectContext, paraphrase: true})}"`
651
579
  return
652
580
  }
653
581
  return objectValue
654
582
  }
655
583
 
656
584
  let currentContext = toDo.pop()
657
- let currentValue = toValue(currentContext)
585
+ let currentValue = await toValue(currentContext)
658
586
  while (toDo.length > 0) {
659
587
  const nextContext = toDo.pop()
660
- const nextValue = toValue(nextContext)
588
+ const nextValue = await toValue(nextContext)
661
589
  if (!nextValue) {
662
590
  // TODO maybe this I aware so it can say "I don't know about blah..." and below
663
591
  // if (currentContext.unknown || !currentContext.value) {
664
592
  if (!api.conceptExists(currentContext.value)) {
665
593
  // api.conceptExists(currentContext)
666
- const objectPhrase = g({...currentContext, paraphrase: true})
594
+ const objectPhrase = await g({...currentContext, paraphrase: true})
667
595
  context.verbatim = `What "${objectPhrase}" means is unknown`
668
596
  return
669
597
  }
670
598
 
671
- const propertyPhrase = g({...nextContext, paraphrase: true})
672
- const objectPhrase = g({...currentContext, paraphrase: true})
599
+ const propertyPhrase = await g({...nextContext, paraphrase: true})
600
+ const objectPhrase = await g({...currentContext, paraphrase: true})
673
601
  context.verbatim = `There is no interpretation for "${propertyPhrase} of ${objectPhrase}"`
674
602
  return
675
603
  }
676
604
 
677
- if (!api.knownProperty(currentContext, nextContext)) {
678
- api.knownProperty(currentContext, nextContext)
679
- context.verbatim = `There is no property ${g({...nextContext, paraphrase: true})} of ${g({...currentContext, paraphrase: true})}`
605
+ if (!await api.knownProperty(currentContext, nextContext)) {
606
+ context.verbatim = `There is no property ${await g({...nextContext, paraphrase: true})} of ${await g({...currentContext, paraphrase: true})}`
680
607
  return
681
608
  }
682
- currentContext = api.getProperty(currentValue, nextValue, g)
609
+ currentContext = await api.getProperty(currentValue, nextValue, g)
683
610
  currentValue = currentContext.value
684
611
  }
685
612
  context.focusable = ['object[0]']
@@ -690,12 +617,12 @@ let configStruct = {
690
617
  ]
691
618
  };
692
619
 
693
- const createConfig = () => {
620
+ const createConfig = async () => {
694
621
  const config = new Config(configStruct, module)
695
622
  config.stop_auto_rebuild()
696
- config.api = api
697
- config.add(concept(), meta(), dialogues())
698
- config.restart_auto_rebuild()
623
+ await config.setApi(api)
624
+ await config.add(concept, meta, dialogues)
625
+ await config.restart_auto_rebuild()
699
626
  return config
700
627
  }
701
628
 
@@ -708,12 +635,14 @@ knowledgeModule( {
708
635
  contents: properties_tests,
709
636
  checks: {
710
637
  context: defaultContextCheck,
638
+ /*
711
639
  objects: [
712
640
  'children',
713
641
  'concept',
714
642
  'parents',
715
643
  'properties'
716
644
  ]
645
+ */
717
646
  },
718
647
  include: {
719
648
  words: true,
@@ -45,12 +45,12 @@ let configStruct = {
45
45
  where: where(),
46
46
  priority: -1,
47
47
  match: ({context}) => context.parenthesis == '(',
48
- apply: ({context, g}) => `(${g({ ...context, parenthesis: null })})`
48
+ apply: async ({context, g}) => `(${await g({ ...context, parenthesis: null })})`
49
49
  },
50
50
  ],
51
51
  };
52
52
 
53
- const createConfig = () => new Config(configStruct, module).add(gdefaults())
53
+ const createConfig = async () => new Config(configStruct, module).add(gdefaults)
54
54
 
55
55
  knowledgeModule( {
56
56
  module,