ekms 8.0.0 → 8.1.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.
Files changed (122) hide show
  1. package/common/animals.instance.json +3003 -1651
  2. package/common/animals.js +17 -20
  3. package/common/articles.js +103 -0
  4. package/common/articles.test.json +310 -0
  5. package/common/asking.instance.json +2 -0
  6. package/common/asking.js +253 -0
  7. package/common/asking.test.json +2290 -0
  8. package/common/avatar.js +6 -10
  9. package/common/characters.js +23 -30
  10. package/common/colors.instance.json +25513 -0
  11. package/common/colors.js +67 -0
  12. package/common/colors.test.json +4425 -0
  13. package/common/comparable.instance.json +1750 -0
  14. package/common/comparable.js +36 -28
  15. package/common/comparable.test.json +1196 -2
  16. package/common/concept.js +121 -119
  17. package/common/conjunction.instance.json +2 -0
  18. package/common/conjunction.js +104 -0
  19. package/common/conjunction.test.json +322 -0
  20. package/common/countable.js +20 -14
  21. package/common/countable.test.json +1050 -0
  22. package/common/crew.instance.json +16855 -9731
  23. package/common/crew.js +39 -42
  24. package/common/crew.test.json +714 -452
  25. package/common/currency.js +28 -46
  26. package/common/dialogues.js +177 -426
  27. package/common/dialogues.test.json +684 -450
  28. package/common/dimension.instance.json +508 -289
  29. package/common/dimension.js +22 -24
  30. package/common/dimension.test.json +727 -1944
  31. package/common/edible.instance.json +20548 -10848
  32. package/common/edible.js +4 -9
  33. package/common/emotions.instance.json +255 -123
  34. package/common/emotions.js +36 -39
  35. package/common/evaluate.instance.json +2 -0
  36. package/common/evaluate.js +53 -0
  37. package/common/evaluate.test.json +574 -0
  38. package/common/events.js +11 -15
  39. package/common/fastfood.instance.json +223039 -113390
  40. package/common/fastfood.js +77 -87
  41. package/common/fastfood.test.json +8205 -3733
  42. package/common/formulas.instance.json +444 -244
  43. package/common/formulas.js +20 -27
  44. package/common/formulas.test.json +1027 -955
  45. package/common/gdefaults.js +40 -27
  46. package/common/help.js +9 -14
  47. package/common/help.test.json +71 -18
  48. package/common/helpers/concept.js +33 -10
  49. package/common/helpers/dialogues.js +22 -4
  50. package/common/helpers/formulas.js +0 -14
  51. package/common/helpers/meta.js +0 -1
  52. package/common/helpers/properties.js +72 -76
  53. package/common/helpers.js +35 -24
  54. package/common/hierarchy.js +17 -25
  55. package/common/javascript.js +12 -19
  56. package/common/kirk.instance.json +586 -298
  57. package/common/kirk.js +6 -9
  58. package/common/length.instance.json +9158 -5124
  59. package/common/length.js +5 -9
  60. package/common/listener.js +48 -0
  61. package/common/listener.test.json +104 -0
  62. package/common/math.instance.json +409 -1202
  63. package/common/math.js +17 -21
  64. package/common/meta.js +24 -50
  65. package/common/nameable.instance.json +2 -0
  66. package/common/nameable.js +144 -0
  67. package/common/nameable.test.json +3191 -0
  68. package/common/negation.instance.json +2 -0
  69. package/common/negation.js +38 -0
  70. package/common/negation.test.json +308 -0
  71. package/common/numbers.js +28 -32
  72. package/common/ordering.instance.json +449 -273
  73. package/common/ordering.js +81 -87
  74. package/common/ordinals.instance.json +2 -0
  75. package/common/ordinals.js +60 -0
  76. package/common/ordinals.test.json +306 -0
  77. package/common/people.instance.json +2176 -1141
  78. package/common/people.js +9 -14
  79. package/common/percentages.instance.json +2 -0
  80. package/common/percentages.js +53 -0
  81. package/common/percentages.test.json +751 -0
  82. package/common/pipboy.instance.json +12120 -6879
  83. package/common/pipboy.js +53 -62
  84. package/common/pipboy.test.json +2835 -0
  85. package/common/pokemon.instance.json +4415 -2351
  86. package/common/pokemon.js +8 -21
  87. package/common/pos.js +16 -14
  88. package/common/pressure.instance.json +2348 -1373
  89. package/common/pressure.js +5 -9
  90. package/common/properties.instance.json +151 -87
  91. package/common/properties.js +156 -167
  92. package/common/properties.test.json +17605 -4030
  93. package/common/punctuation.js +24 -8
  94. package/common/punctuation.test.json +233 -5
  95. package/common/reports.instance.json +1027 -551
  96. package/common/reports.js +77 -103
  97. package/common/reports.test.json +15623 -10458
  98. package/common/scorekeeper.js +19 -31
  99. package/common/sdefaults.js +17 -8
  100. package/common/sizeable.js +13 -12
  101. package/common/spock.instance.json +585 -297
  102. package/common/spock.js +6 -9
  103. package/common/stgame.js +20 -20
  104. package/common/stm.js +182 -29
  105. package/common/stm.test.json +1734 -1
  106. package/common/tell.js +15 -19
  107. package/common/temperature.instance.json +2480 -1493
  108. package/common/temperature.js +5 -9
  109. package/common/tester.js +15 -4
  110. package/common/testing.js +8 -13
  111. package/common/time.js +21 -26
  112. package/common/tokenize.js +8 -8
  113. package/common/tokenize.test.json +86 -1
  114. package/common/ui.instance.json +151 -460
  115. package/common/ui.js +22 -34
  116. package/common/ui.test.json +641 -5357
  117. package/common/weight.instance.json +8072 -4490
  118. package/common/weight.js +5 -9
  119. package/common/weight.test.json +242 -238
  120. package/common/yesno.js +6 -6
  121. package/main.js +68 -45
  122. package/package.json +44 -6
@@ -45,6 +45,10 @@ class API {
45
45
  }
46
46
 
47
47
  if (km('concept')) {
48
+ if (!km('concept').api) {
49
+ debugger
50
+ debugger
51
+ }
48
52
  km('concept').api.addDefaultTypesForObjectHierarchy([
49
53
  'theAble',
50
54
  'queryable',
@@ -81,7 +85,6 @@ class API {
81
85
  match: ({context}) => context[tm.to],
82
86
  apply: ({context}) => {
83
87
  // Object.assign(context[tm.to], from[tm.from])
84
- // debugger;
85
88
  context[tm.to] = from[tm.from]
86
89
  if (context[tm.to]) {
87
90
  context[tm.to].instantiated = true
@@ -137,7 +140,7 @@ class API {
137
140
  notes: 'semantic for setting value with constraint',
138
141
  match: ({context, isA}) => isA(context.marker, after[0].tag) && context.evaluate && context.constraints,
139
142
  // match: ({context, isA}) => context.marker == after[0].tag && context.evaluate,
140
- apply: ({km, context, e, log, isA, s}) => {
143
+ apply: async ({km, context, e, log, isA}) => {
141
144
  const constraint = context.constraints[0];
142
145
  const value = constraint.constraint;
143
146
  let property = constraint.property;
@@ -152,7 +155,7 @@ class API {
152
155
  // value.greg = true
153
156
  // value.ownee.query = true
154
157
  value.query = true
155
- let instance = e(value)
158
+ let instance = await e(value)
156
159
  if (instance.verbatim) {
157
160
  context.evalue = { verbatim: instance.verbatim }
158
161
  return
@@ -169,13 +172,13 @@ class API {
169
172
  config.addGenerator({
170
173
  notes: 'generator for constraint',
171
174
  match: ({context}) => context.marker == edAble.operator && context.paraphrase && context.constrained,
172
- apply: ({context, g}) => {
175
+ apply: async ({context, g}) => {
173
176
  if (context[before[0].tag].marker == 'by') {
174
177
  // the cat wendy owned
175
- return `${g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${g({...context[before[0].tag], paraphrase: true})}`
178
+ return `${await g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${await g({...context[before[0].tag], paraphrase: true})}`
176
179
  } else {
177
180
  // the cat owned by wendy
178
- return `${g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${['by', g({...context[before[0].tag], paraphrase: true})].filter((t) => t).join(' ')}`
181
+ return `${await g({...context[after[0].tag], paraphrase: true})} ${edAble.word} ${['by', await g({...context[before[0].tag], paraphrase: true})].filter((t) => t).join(' ')}`
179
182
  }
180
183
  },
181
184
  })
@@ -195,19 +198,19 @@ class API {
195
198
 
196
199
  return false;
197
200
  },
198
- apply: ({context, g}) => {
201
+ apply: async ({context, g}) => {
199
202
  const chosen = chooseNumber(context, word.singular, word.plural)
200
- return `${g(context[before[0].tag])} ${chosen} ${g(context[after[0].tag])}`
203
+ return `${await g(context[before[0].tag])} ${chosen} ${await g(context[after[0].tag])}`
201
204
  }
202
205
  })
203
206
  config.addGenerator({
204
207
  match: ({context}) => context.marker == edAble.operator && context.isEd,
205
- apply: ({context, g}) => {
208
+ apply: async ({context, g}) => {
206
209
  const chosen = chooseNumber(context[after[0].tag], 'is', 'are')
207
210
  if (context[before[0].tag].evalue && context[before[0].tag].evalue.marker == 'answerNotKnown') {
208
- return g(context[before[0].tag])
211
+ return await g(context[before[0].tag])
209
212
  }
210
- return `${g(context[after[0].tag])} ${chosen} ${edAble.word} by ${g(context[before[0].tag])}`
213
+ return `${await g(context[after[0].tag])} ${chosen} ${edAble.word} by ${await g(context[before[0].tag])}`
211
214
  }
212
215
  })
213
216
  /*
@@ -251,12 +254,10 @@ class API {
251
254
  notes: `generator for who/what is X owned by`,
252
255
  // match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.one && context.one.marker == 'ownee' && context.one.constraints && context.one.constraints[0] && context.one.constraints[0].constraint.marker == 'owned' && context.one.constraints[0].constraint.owner.implicit,
253
256
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.one && context.one.marker == after[0].tag && context.one.constraints && context.one.constraints[0] && context.one.constraints[0].constraint.marker == edAble.operator && context.one.constraints[0].constraint[before[0].tag].implicit,
254
- apply: ({context, g, gs, callId}) => {
257
+ apply: async ({context, fragments, g, gs, callId}) => {
255
258
  const isToFromM = [{"from":["one"],"to":["two"]},{"from":["two"],"to":["one"]}]
256
- const fromF = config.fragment(whoIsWhatVerbedBy).contexts()[0]
257
- // const fromF = config.fragment[before[0].tag]"ownerVar is owneeVar owned by").contexts()[0]
258
- // const toF = config.fragment("owneeVar is owned by ownerVar")
259
- const toF = config.fragment(thisIsVerbedByThat)
259
+ const fromF = fragments(whoIsWhatVerbedBy).contexts()[0]
260
+ const toF = fragments(thisIsVerbedByThat)
260
261
  const to = toF.contexts()[0]
261
262
  const tm = translationMapping(fromF, to)
262
263
  /*
@@ -270,11 +271,11 @@ class API {
270
271
  // const from = context.one.constraints[0].constraint
271
272
  const from = context
272
273
  const im = translationMappingToInstantiatorMappings(tmPrime, from, to)
273
- const translation = toF.instantiate(im)
274
+ const translation = await toF.instantiate(im)
274
275
  if (Array.isArray(translation)) {
275
- return gs(translation)
276
+ return await gs(translation)
276
277
  } else {
277
- return g(translation)
278
+ return await g(translation)
278
279
  }
279
280
  }
280
281
  }
@@ -315,7 +316,12 @@ class API {
315
316
  allowDups: true,
316
317
  })
317
318
  // config.addOperator({ id: operator, level: 1, words: [operator] })
318
- config.addBridge({ id: operator, level: 1, bridge: '{ ...next(operator) }', allowDups: true })
319
+ config.addBridge({
320
+ id: operator,
321
+ level: 1,
322
+ bridge: '{ ...next(operator) }',
323
+ allowDups: true,
324
+ })
319
325
  config.addPriority({ "context": [['does', 0], [operator, 1], ], "choose": [0] })
320
326
  config.addPriority({ "context": [['doesnt', 0], [operator, 1], ], "choose": [0] })
321
327
  config.addPriority({ "context": [[operator, 0], ['does', 0], ], "choose": [0] })
@@ -354,7 +360,13 @@ class API {
354
360
 
355
361
  const unflattenArgs = [ ...before.map( (arg) => arg.tag ), ...after.map( (arg) => arg.tag ) ]
356
362
  const focusable = [ ...before.map( (arg) => arg.tag ), ...after.map( (arg) => arg.tag ) ]
357
- config.addBridge({ id: operator, level: 0, localHierarchy, bridge: `{ ... next(operator) ${doParams} ${beforeArgs} ${afterArgs}, unflatten: ${JSON.stringify(unflattenArgs)}, focusable: ${JSON.stringify(focusable)} }`, allowDups: true })
363
+ config.addBridge({
364
+ id: operator,
365
+ level: 0,
366
+ localHierarchy: [...localHierarchy, ['object', 'unknown']],
367
+ bridge: `{ ... next(operator) ${doParams} ${beforeArgs} ${afterArgs}, unflatten: ${JSON.stringify(unflattenArgs)}, focusable: ${JSON.stringify(focusable)} }`,
368
+ allowDups: true
369
+ })
358
370
  if (words.length > 0) {
359
371
  for (const word of words) {
360
372
  config.addWord(word, { id: operator, initial: `{ value: "${operator}" }` })
@@ -384,11 +396,16 @@ class API {
384
396
  config.addGenerator({
385
397
  notes: 'ordering generator for paraphrase',
386
398
  match: ({context}) => context.marker == operator && context.paraphrase && !context.query,
387
- apply: ({context, gp, g}) => {
388
- const beforeGenerator = before.map( (arg) => g(context[arg.tag]) )
389
- const afterGenerator = after.map( (arg) => gp(context[arg.tag]) )
399
+ apply: async ({context, gp, g}) => {
400
+ const beforeGenerator = []
401
+ for (const arg of before) {
402
+ beforeGenerator.push(await g(context[arg.tag]))
403
+ }
404
+ const afterGenerator = []
405
+ for (const arg of after) {
406
+ afterGenerator.push(await gp(context[arg.tag]))
407
+ }
390
408
  const word = context.word
391
- // return beforeGenerator.concat([`${context.word}`]).concat(afterGenerator).join(' ')
392
409
  const sub = []
393
410
  if (context.subphrase) {
394
411
  sub.push(['that'])
@@ -400,7 +417,7 @@ class API {
400
417
  config.addGenerator({
401
418
  notes: 'ordering generator for response',
402
419
  match: ({context}) => context.marker == operator && context.evalue && context.isResponse,
403
- apply: ({context, g, km}) => {
420
+ apply: async ({context, g, km}) => {
404
421
  const brief = km("dialogues").api.getBrief()
405
422
 
406
423
  const { evalue } = context
@@ -415,7 +432,7 @@ class API {
415
432
  if (evalue.truthValueOnly || brief) {
416
433
  return `${yesno}`
417
434
  } else {
418
- return `${yesno} ${g(Object.assign({}, evalue, { paraphrase: true }))}`
435
+ return `${yesno} ${await g(Object.assign({}, evalue, { paraphrase: true }))}`
419
436
  }
420
437
  }
421
438
  })
@@ -501,12 +518,6 @@ class API {
501
518
  for (let argument of context.focusable || []) {
502
519
  const value = api.toValue(context[argument])
503
520
  if (value) {
504
- /*
505
- if (value == 'cleo') {
506
- debugger;
507
- hierarchy.isA()
508
- }
509
- */
510
521
  const minimas = hierarchy.minima(context[argument].types)
511
522
  for (let type of minimas) {
512
523
  if (config.exists(value)) {
@@ -635,8 +646,8 @@ class API {
635
646
  setValue: ([object, property], value, has) => {
636
647
  return this.setProperty(object, property, value, has, true)
637
648
  },
638
- getValue: ([object, property]) => {
639
- return this.getPropertyDirectly(object, property)
649
+ getValue: async ([object, property]) => {
650
+ return await this.getPropertyDirectly(object, property)
640
651
  },
641
652
  })
642
653
  }
@@ -652,16 +663,18 @@ class API {
652
663
  error.code = 'ReadOnly'
653
664
  throw error
654
665
  },
655
- getValue: ([object, property]) => {
656
- return this.getPropertyDirectly(object, property)
666
+ getValue: async ([object, property]) => {
667
+ return await this.getPropertyDirectly(object, property)
657
668
  },
658
669
  })
659
670
  this.propertiesFH.setHandler(path, handler)
660
671
  }
661
672
 
662
- getObject(object) {
673
+ /*
674
+ async getObject(object) {
663
675
  return this.propertiesFH.getValue([object])
664
676
  }
677
+ */
665
678
 
666
679
  getHandler(object, property) {
667
680
  return this.propertiesFH.getHandler([object, property])
@@ -678,34 +691,33 @@ class API {
678
691
  // return context.value
679
692
  }
680
693
 
681
- getProperty(object, property, g) {
694
+ async getProperty(object, property, g) {
682
695
  object = this.toValue(object)
683
696
  property = this.toValue(property)
684
697
  const handler = this.propertiesFH.getHandler([object, property])
685
698
  if (handler) {
686
- return handler.getValue([object, property])
699
+ return await handler.getValue([object, property])
687
700
  }
688
- return this.getPropertyDirectly(object, property, g)
701
+ return await this.getPropertyDirectly(object, property, g)
689
702
  }
690
703
 
691
- getPropertyDirectly(object, property, g) {
692
- if (property == 'properties') {
693
- const objectProps = this.propertiesFH.getValue([object])
704
+ async getPropertyDirectly(object, property, g) {
705
+ if (property == 'property') {
706
+ const objectProps = await this.propertiesFH.getValue([object])
694
707
  const values = []
695
708
  for (let key of Object.keys(objectProps)) {
696
709
  if (objectProps[key].has) {
697
- // values.push(`${g(key)}: ${g({ ...objectProps[key].value, evaluate: true })}`)
698
- values.push(`${g(key)}: ${g({ ...objectProps[key].value, paraphrase: true })}`)
710
+ values.push(`${await g(key)}: ${await g({ ...objectProps[key].value, paraphrase: true })}`)
699
711
  }
700
712
  }
701
713
  return { marker: 'list', value: values }
702
714
  } else {
703
- return this.propertiesFH.getValue([object, property]).value
715
+ return (await this.propertiesFH.getValue([object, property])).value
704
716
  }
705
717
  }
706
718
 
707
- hasProperty(object, property, has) {
708
- return this.propertiesFH.getValue([object, property]).has
719
+ async hasProperty(object, property, has) {
720
+ return (await this.propertiesFH.getValue([object, property])).has
709
721
  }
710
722
 
711
723
  setProperty(object, property, value, has, skipHandler) {
@@ -733,8 +745,8 @@ class API {
733
745
  }
734
746
  }
735
747
 
736
- knownObject(object) {
737
- if (object == 'properties') {
748
+ async knownObject(object) {
749
+ if (object == 'property') {
738
750
  return object
739
751
  }
740
752
  if ((object || {}).value) {
@@ -742,11 +754,11 @@ class API {
742
754
  }
743
755
  const path = [object]
744
756
  // return this.knownPropertyNew(path)
745
- return this.propertiesFH.knownProperty(path)
757
+ return await this.propertiesFH.knownProperty(path)
746
758
  }
747
759
 
748
- hasProperty(object, property) {
749
- if (property == 'properties') {
760
+ async hasProperty(object, property) {
761
+ if (property == 'property') {
750
762
  return true;
751
763
  }
752
764
 
@@ -755,7 +767,7 @@ class API {
755
767
  const seen = [object];
756
768
  while (todo.length > 0) {
757
769
  const next = todo.pop();
758
- if ((this.propertiesFH.getValue([next, property], false) || {}).has) {
770
+ if ((await this.propertiesFH.getValue([next, property], false) || {}).has) {
759
771
  return true
760
772
  }
761
773
  const parents = this._objects.parents[next] || [];
@@ -770,11 +782,12 @@ class API {
770
782
  }
771
783
 
772
784
  // NOT DONE
773
- knownProperty(object, property) {
785
+ async knownProperty(object, property) {
774
786
  object = this.toValue(object)
775
787
  property = this.toValue(property)
776
- if (property == 'properties') {
777
- return true;
788
+ if (property == 'property') {
789
+ const objectProps = await this.propertiesFH.getValue([object])
790
+ return !_.isEmpty(objectProps)
778
791
  }
779
792
 
780
793
  // go up the hierarchy
@@ -782,7 +795,7 @@ class API {
782
795
  const seen = [object];
783
796
  while (todo.length > 0) {
784
797
  const next = todo.pop();
785
- if ((this.propertiesFH.getValue([next, property], false) || {}).has) {
798
+ if ((await this.propertiesFH.getValue([next, property], false) || {}).has) {
786
799
  return true
787
800
  }
788
801
  const parents = this._objects.parents[next] || [];
@@ -916,24 +929,7 @@ class API {
916
929
  }
917
930
 
918
931
  set config(config) {
919
- debugger
920
932
  this._config = config
921
- /*
922
- const toJSON = (h) => {
923
- if (h.child && h.parent) {
924
- return h
925
- } else {
926
- return { child: h[0], parent: h[1] }
927
- }
928
- }
929
- for (const tuple of [...config().config.hierarchy]) {
930
- const h = toJSON(tuple);
931
- // TODO should this notice development flag?
932
- if (this.isOperator(h.child) && this.isOperator(h.parent)) {
933
- this.rememberIsA(h.child, h.parent)
934
- }
935
- }
936
- */
937
933
  }
938
934
 
939
935
  get config() {
package/common/helpers.js CHANGED
@@ -33,8 +33,8 @@ const getCount = (context) => {
33
33
  }
34
34
  }
35
35
 
36
- const words = (base, additional = {}) => {
37
- return [{ word: pluralize.singular(base), number: 'one', ...additional }, { word: pluralize.plural(base), number: 'many', ...additional }]
36
+ const words = (word, additional = {}) => {
37
+ return [{ word: pluralize.singular(word), number: 'one', ...additional }, { word: pluralize.plural(word), number: 'many', ...additional }]
38
38
  }
39
39
 
40
40
  const isMany = (context) => {
@@ -63,6 +63,12 @@ const isMany = (context) => {
63
63
  return false
64
64
  }
65
65
 
66
+ const requiredArgument = (value, name) => {
67
+ if (!value) {
68
+ throw new Error(`${name} is a required argument`)
69
+ }
70
+ }
71
+
66
72
  const chooseNumber = (context, one, many) => {
67
73
  if (isMany(context)) {
68
74
  return many;
@@ -131,31 +137,35 @@ const toEValue = (context) => {
131
137
  return context;
132
138
  }
133
139
 
134
- const defaultContextProperties = ['marker', 'text', 'verbatim', 'isResponse']
135
- const defaultContextCheck = [
136
- ...defaultContextProperties,
137
- (object) => {
138
- if (typeof object.value == 'object') {
139
- return { property: 'value', filter: defaultContextProperties }
140
- } else {
141
- return 'value'
142
- }
143
- },
144
- (object) => {
145
- if (!Array.isArray(object.modifiers)) {
146
- return
147
- }
148
- if (typeof object.modifiers[0] == 'object') {
149
- return { property: 'modifiers', filter: defaultContextProperties }
150
- } else {
151
- return 'modifiers'
152
- }
153
- },
154
- { property: 'modifiers', isPropertyList: true, filter: defaultContextProperties }
155
- ]
140
+ const defaultContextCheckProperties = ['marker', 'text', 'verbatim', 'isResponse', { property: 'response', filter: ['marker', 'text', 'verbatim'] }]
141
+ const defaultContextCheck = (properties = []) => {
142
+ return [
143
+ ...defaultContextCheckProperties,
144
+ ...properties.map((property) => { return { property, filter: defaultContextCheckProperties } }),
145
+ (object) => {
146
+ if (typeof object.value == 'object') {
147
+ return { property: 'value', filter: defaultContextCheckProperties }
148
+ } else {
149
+ return 'value'
150
+ }
151
+ },
152
+ (object) => {
153
+ if (!Array.isArray(object.modifiers)) {
154
+ return
155
+ }
156
+ if (typeof object.modifiers[0] == 'object') {
157
+ return { property: 'modifiers', filter: defaultContextCheckProperties }
158
+ } else {
159
+ return 'modifiers'
160
+ }
161
+ },
162
+ { property: 'modifiers', isPropertyList: true, filter: defaultContextCheckProperties }
163
+ ]
164
+ }
156
165
 
157
166
  module.exports = {
158
167
  defaultContextCheck,
168
+ defaultContextCheckProperties,
159
169
  toEValue,
160
170
  millisecondsUntilHourOfDay,
161
171
  indent,
@@ -167,4 +177,5 @@ module.exports = {
167
177
  words,
168
178
  propertyToArray,
169
179
  wordNumber,
180
+ requiredArgument,
170
181
  }
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const properties = require('./properties')
4
4
  const hierarchy_tests = require('./hierarchy.test.json')
@@ -32,7 +32,7 @@ const getTypes = ( km, concept, instance ) => {
32
32
 
33
33
  // TODO the types of rank are x y z ....
34
34
  // TODO x is a kind of y
35
- let configStruct = {
35
+ let config = {
36
36
  name: 'hierarchy',
37
37
  operators: [
38
38
  // "([hierarchyAble|])",
@@ -61,7 +61,7 @@ let configStruct = {
61
61
  notes: 'what type is pikachu',
62
62
  where: where(),
63
63
  match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.query && !['what'].includes(context.one.marker) && !['what'].includes(context.two.marker) && (context.one.query || context.two.query),
64
- apply: ({context, hierarchy, km, log, e, s}) => {
64
+ apply: async ({context, hierarchy, km, log, e}) => {
65
65
  const one = context.one;
66
66
  const two = context.two;
67
67
  let concept, value;
@@ -72,7 +72,7 @@ let configStruct = {
72
72
  concept = two;
73
73
  value = one;
74
74
  }
75
- let instance = e(value)
75
+ let instance = await e(value)
76
76
  if (instance.verbatim) {
77
77
  context.evalue = { verbatim: instance.verbatim }
78
78
  context.isResponse = true
@@ -80,9 +80,6 @@ let configStruct = {
80
80
  }
81
81
  instance = getTypes(km, concept, instance)
82
82
 
83
- // instance.focusable = ['one', 'two']
84
- // concept = JSON.parse(JSON.stringify(value))
85
- // greg
86
83
  concept = _.cloneDeep(value)
87
84
  concept.isQuery = undefined
88
85
 
@@ -106,10 +103,10 @@ let configStruct = {
106
103
  notes: 'type of pikachu', // the types of type is the next one
107
104
  where: where(),
108
105
  match: ({context}) => context.marker == 'type' && context.evaluate && context.object && context.objects[context.objects.length-1].number == 'one' && pluralize.isSingular(context.objects[0].word),
109
- apply: ({context, objects, e, gs, km, log, s}) => {
106
+ apply: async ({context, objects, e, gs, km, log}) => {
110
107
  const concept = context.objects[0];
111
108
  const value = context.objects[1];
112
- let instance = e(value)
109
+ let instance = await e(value)
113
110
  if (instance.verbatim) {
114
111
  context.evalue = { verbatim: instance.verbatim }
115
112
  return
@@ -135,14 +132,14 @@ let configStruct = {
135
132
  }
136
133
  return hierarchy.isA(context.marker, 'is') && context.query && args( { types: ['hierarchyAble', 'hierarchyAble'], properties: ['one', 'two'] } )
137
134
  },
138
- apply: ({context, km, objects, g}) => {
135
+ apply: async ({context, km, objects, g}) => {
139
136
  const api = km('properties').api
140
137
  const one = context.one
141
138
  const two = context.two
142
139
  const oneId = pluralize.singular(one.value);
143
140
  if (!api.conceptExists(oneId)) {
144
141
  context.evalue = {
145
- verbatim: `I don't know about ${g({ ...one, paraphrase: true})}`
142
+ verbatim: `I don't know about ${await g({ ...one, paraphrase: true})}`
146
143
  }
147
144
  context.isResponse = true
148
145
  return
@@ -150,7 +147,7 @@ let configStruct = {
150
147
  const twoId = pluralize.singular(two.value);
151
148
  if (!api.conceptExists(twoId)) {
152
149
  context.evalue = {
153
- verbatim: `I don't know about ${g({ ...two, paraphrase: true})}`
150
+ verbatim: `I don't know about ${await g({ ...two, paraphrase: true})}`
154
151
  }
155
152
  context.isResponse = true
156
153
  return
@@ -201,7 +198,6 @@ let configStruct = {
201
198
  },
202
199
  {
203
200
  notes: 'humans are mammels',
204
- // match: ({context, listable}) => listable(context, 'unknown') && context.same,
205
201
  where: where(),
206
202
  match: ({context, listable, hierarchy, isA, callId}) => {
207
203
  if (!context.same) {
@@ -270,7 +266,7 @@ let configStruct = {
270
266
  notes: 'types of type', // what are the types of animals
271
267
  where: where(),
272
268
  match: ({context}) => context.marker == 'type' && context.evaluate && context.object,
273
- apply: ({context, objects, gs, km, isA}) => {
269
+ apply: ({context, objects, km, isA}) => {
274
270
  const api = km('properties').api
275
271
  const conceptApi = km('concept').api
276
272
  const type = pluralize.singular(context.object.value);
@@ -288,23 +284,19 @@ let configStruct = {
288
284
  ]
289
285
  };
290
286
 
291
- const createConfig = () => {
292
- const config = new Config(configStruct, module)
293
- config.stop_auto_rebuild()
294
- config.add(properties())
295
- config.initializer( ({apis, hierarchy}) => {
287
+ const initializer = ({apis, hierarchy}) => {
296
288
  apis('stm').addIsA( (child, parent) => {
297
289
  return hierarchy.isA(child, parent)
298
290
  })
299
- })
300
- config.restart_auto_rebuild()
301
- return config
302
- }
291
+ }
303
292
 
304
293
  knowledgeModule( {
294
+ config,
295
+ includes: [properties],
296
+ initializer,
297
+
305
298
  module,
306
299
  description: 'hierarchy of objects',
307
- createConfig,
308
300
  test: {
309
301
  name: './hierarchy.test.json',
310
302
  contents: hierarchy_tests,
@@ -312,7 +304,7 @@ knowledgeModule( {
312
304
  checks: {
313
305
  objects: ['children', 'concept', 'parents', 'properties'],
314
306
  checks: {
315
- context: defaultContextCheck,
307
+ context: defaultContextCheck(),
316
308
  },
317
309
 
318
310
  },
@@ -1,9 +1,9 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const dialogues = require('./dialogues')
4
4
  const javascript_tests = require('./javascript.test.json')
5
5
 
6
- let configStruct = {
6
+ let config = {
7
7
  name: 'javascript',
8
8
  operators: [
9
9
  "((<let> ([variable|])) [assignment|] (value))",
@@ -36,14 +36,14 @@ let configStruct = {
36
36
  {
37
37
  where: where(),
38
38
  match: ({context}) => context.marker == 'assignment' && context.paraphrase,
39
- apply: ({context, g}) => `let ${g(context.variable)} = ${g(context.value)}`
39
+ apply: async ({context, g}) => `let ${await g(context.variable)} = ${await g(context.value)}`
40
40
  },
41
41
  {
42
42
  where: where(),
43
43
  match: ({context}) => context.marker == 'assignment' && context.isResponse,
44
- apply: ({context, g}) => {
45
- const value = g(context.variable)
46
- return `${g(context.variable)} == ${g(context.value)}`
44
+ apply: async ({context, g}) => {
45
+ // const value = await g(context.variable)
46
+ return `${await g(context.variable)} == ${await g(context.value)}`
47
47
  }
48
48
  },
49
49
  ],
@@ -60,27 +60,20 @@ let configStruct = {
60
60
  ],
61
61
  };
62
62
 
63
- const createConfig = () => {
64
- const config = new Config(configStruct, module)
65
- config.stop_auto_rebuild()
66
- config.add(dialogues())
67
-
68
- config.initializer( ({objects, uuid}) => {
63
+ knowledgeModule( {
64
+ config,
65
+ includes: [dialogues],
66
+ initializer: ({objects, uuid}) => {
69
67
  objects.variables = {}
70
- })
71
- config.restart_auto_rebuild()
72
- return config
73
- }
68
+ },
74
69
 
75
- knowledgeModule( {
76
70
  module,
77
71
  description: 'javascript interpreter',
78
- createConfig,
79
72
  test: {
80
73
  name: './javascript.test.json',
81
74
  contents: javascript_tests,
82
75
  checks: {
83
- context: defaultContextCheck,
76
+ context: defaultContextCheck(),
84
77
  },
85
78
 
86
79
  },