tpmkms_4wp 9.5.1 → 9.6.0-beta.1

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 (135) hide show
  1. package/common/animals.instance.json +151 -61
  2. package/common/animals.js +3 -5
  3. package/common/asking.js +116 -106
  4. package/common/avatar.test.json +1001 -860
  5. package/common/can.instance.json +2194 -0
  6. package/common/can.js +251 -0
  7. package/common/can.test.json +51307 -0
  8. package/common/characters.js +5 -5
  9. package/common/colors.instance.json +152 -12
  10. package/common/colors.js +3 -6
  11. package/common/comparable.instance.json +33 -3
  12. package/common/comparable.js +3 -6
  13. package/common/concept.js +25 -27
  14. package/common/concept.test.json +180 -144
  15. package/common/conjunction.js +13 -5
  16. package/common/conjunction.test.json +32 -42
  17. package/common/crew.instance.json +433 -173
  18. package/common/crew.js +4 -7
  19. package/common/crew.test.json +4148 -3324
  20. package/common/currency.js +1 -1
  21. package/common/dateTimeSelectors.instance.json +2 -2
  22. package/common/dateTimeSelectors.js +6 -9
  23. package/common/dateTimeSelectors.test.json +76935 -35739
  24. package/common/dates.instance.json +53 -3
  25. package/common/dates.js +3 -6
  26. package/common/dates.test.json +284 -287
  27. package/common/dialogues.js +43 -122
  28. package/common/dialogues.test.json +1248 -1152
  29. package/common/dimension.instance.json +21493 -561
  30. package/common/dimension.js +150 -55
  31. package/common/dimension.test.json +10979 -4625
  32. package/common/drone.instance.json +24709 -0
  33. package/common/drone.js +662 -0
  34. package/common/drone.test.json +30522 -0
  35. package/common/drone_v1.instance.json +24703 -0
  36. package/common/drone_v1.js +596 -0
  37. package/common/drone_v1.test.json +115538 -0
  38. package/common/edible.instance.json +388 -32
  39. package/common/edible.js +3 -5
  40. package/common/emotions.instance.json +85 -76
  41. package/common/emotions.js +4 -7
  42. package/common/emotions.test.json +242 -174
  43. package/common/english_helpers.js +336 -0
  44. package/common/errors.js +6 -6
  45. package/common/evaluate.js +2 -2
  46. package/common/events.js +8 -8
  47. package/common/fastfood.instance.json +1071 -393
  48. package/common/fastfood.js +14 -16
  49. package/common/fastfood.test.json +6970 -6829
  50. package/common/formulas.instance.json +11 -1
  51. package/common/formulas.js +3 -2
  52. package/common/gdefaults.js +111 -17
  53. package/common/help.js +12 -12
  54. package/common/help.test.json +65 -11
  55. package/common/helpers/concept.js +1 -1
  56. package/common/helpers/conjunction.js +54 -44
  57. package/common/helpers/dateTimeSelectors.js +2 -2
  58. package/common/helpers/dialogues.js +10 -2
  59. package/common/helpers/formulas.js +13 -11
  60. package/common/helpers/menus.js +12 -12
  61. package/common/helpers/meta.js +9 -9
  62. package/common/helpers/properties.js +186 -64
  63. package/common/helpers.js +167 -48
  64. package/common/hierarchy.js +12 -10
  65. package/common/kirk.instance.json +11 -1
  66. package/common/kirk.js +4 -6
  67. package/common/kirk.test.json +600 -424
  68. package/common/latin.instance.json +12 -12
  69. package/common/latin.js +12 -14
  70. package/common/length.instance.json +34660 -3158
  71. package/common/length.js +11 -6
  72. package/common/length.test.json +54357 -2557
  73. package/common/math.instance.json +39 -29
  74. package/common/math.js +49 -47
  75. package/common/menus.instance.json +77 -10
  76. package/common/menus.js +4 -13
  77. package/common/meta.js +80 -65
  78. package/common/nameable.js +36 -22
  79. package/common/nameable.test.json +436 -0
  80. package/common/numbers.js +1 -1
  81. package/common/ordering.instance.json +107 -19
  82. package/common/ordering.js +4 -6
  83. package/common/ordering.test.json +835 -417
  84. package/common/people.instance.json +176 -348
  85. package/common/people.js +9 -9
  86. package/common/people.test.json +4135 -3606
  87. package/common/pipboy.instance.json +187 -17
  88. package/common/pipboy.js +4 -4
  89. package/common/pokemon.instance.json +143 -13
  90. package/common/pokemon.js +4 -6
  91. package/common/pressure.instance.json +3610 -1601
  92. package/common/pressure.js +3 -5
  93. package/common/pressure.test.json +433 -477
  94. package/common/properties.instance.json +16 -17
  95. package/common/properties.js +32 -13
  96. package/common/properties.test.json +9565 -6951
  97. package/common/rates.instance.json +59 -0
  98. package/common/rates.js +95 -0
  99. package/common/rates.test.json +27702 -0
  100. package/common/reminders.instance.json +4 -4
  101. package/common/reminders.js +8 -11
  102. package/common/reminders.test.json +64635 -25787
  103. package/common/reports.instance.json +23 -3
  104. package/common/reports.js +21 -21
  105. package/common/scorekeeper.js +9 -12
  106. package/common/sdefaults.js +22 -2
  107. package/common/spock.instance.json +11 -1
  108. package/common/spock.js +4 -7
  109. package/common/spock.test.json +606 -430
  110. package/common/stgame.js +1 -1
  111. package/common/stm.js +41 -24
  112. package/common/tell.js +1 -1
  113. package/common/temperature.instance.json +3163 -1154
  114. package/common/temperature.js +3 -5
  115. package/common/temperature.test.json +433 -477
  116. package/common/tester.js +3 -3
  117. package/common/time.instance.json +24852 -0
  118. package/common/time.js +138 -141
  119. package/common/time.test.json +31876 -3757
  120. package/common/tokenize.js +5 -2
  121. package/common/ui.instance.json +12 -5
  122. package/common/ui.js +4 -13
  123. package/common/weight.instance.json +10501 -4099
  124. package/common/weight.js +3 -5
  125. package/common/weight.test.json +2601 -2263
  126. package/common/words.instance.json +9 -0
  127. package/common/words.js +50 -0
  128. package/common/words.test.json +2 -0
  129. package/common/wp.instance.json +548 -8
  130. package/common/wp.js +10 -8
  131. package/common/wp.test.json +7385 -6906
  132. package/main.js +6 -2
  133. package/package.json +25 -6
  134. package/common/listener.js +0 -50
  135. package/common/listener.test.json +0 -142
package/common/meta.js CHANGED
@@ -5,7 +5,7 @@ const gdefaults = require('./gdefaults.js')
5
5
  ensureTestFile(module, 'meta', 'test')
6
6
  ensureTestFile(module, 'meta', 'instance')
7
7
  const meta_tests = require('./meta.test.json')
8
- const meta_instance = require('./meta.instance.json')
8
+ const instance = require('./meta.instance.json')
9
9
  const { hashIndexesGet, hashIndexesSet, translationMapping, translationMappings } = require('./helpers/meta.js')
10
10
  const { zip, words } = require('./helpers.js')
11
11
 
@@ -26,13 +26,13 @@ const config = {
26
26
  "(([orAble|]) [orList|or] ([orAble|]))",
27
27
  // "cats is the plural of cat"
28
28
  // "is cat the plural of cats"
29
- { pattern: "([x])", development: true },
29
+ { pattern: "([x])", scope: "testing" },
30
30
  // if f x then g x
31
- { pattern: "([e])", development: true },
32
- { pattern: "([f])", development: true },
33
- { pattern: "([g])", development: true },
34
- { pattern: "([undefined])", development: true },
35
- { pattern: "([defined])", development: true },
31
+ { pattern: "([e])", scope: "testing" },
32
+ { pattern: "([f])", scope: "testing" },
33
+ { pattern: "([g])", scope: "testing" },
34
+ { pattern: "([undefined])", scope: "testing" },
35
+ { pattern: "([defined])", scope: "testing" },
36
36
 
37
37
  /*
38
38
  if creating a new word make a motivation to ask if word is plura or singlar of anohter wordA
@@ -61,9 +61,9 @@ const config = {
61
61
  // [['means', 0], ['is', 0]],
62
62
  ],
63
63
  hierarchy: [
64
- { child: 'e', parent: 'orAble', development: true },
65
- { child: 'f', parent: 'orAble', development: true },
66
- { child: 'g', parent: 'ifAble', development: true },
64
+ { child: 'e', parent: 'orAble', scope: "testing" },
65
+ { child: 'f', parent: 'orAble', scope: "testing" },
66
+ { child: 'g', parent: 'ifAble', scope: "testing" },
67
67
  { child: 'orAble', parent: 'ifAble' },
68
68
  ],
69
69
  bridges: [
@@ -94,12 +94,12 @@ const config = {
94
94
  { id: "then", level: 0, bridge: "{ ...next(operator), consequence: after[0] }" },
95
95
  { id: "ifAble" },
96
96
  { id: "orAble" },
97
- { id: "x", development: true },
98
- { id: "e", development: true },
99
- { id: "f", development: true },
100
- { id: "g", development: true },
101
- { id: "undefined", development: true },
102
- { id: "defined", development: true },
97
+ { id: "x", scope: "testing" },
98
+ { id: "e", scope: "testing" },
99
+ { id: "f", scope: "testing" },
100
+ { id: "g", scope: "testing" },
101
+ { id: "undefined", scope: "testing" },
102
+ { id: "defined", scope: "testing" },
103
103
  // { id: "testWord2", level: 0, bridge: "{ ...next(operator) }" },
104
104
  ],
105
105
  version: '3',
@@ -107,12 +107,12 @@ const config = {
107
107
  "literals": {
108
108
  // 'testWord2': [{"id": "testWord2", "initial": "{ value: 'testWord2Value' }" }],
109
109
  // TODO make this development and select out for module
110
- // 'x': [{id: "x", initial: "{ value: 'x' }", development: true }],
111
- // 'f': [{id: "ifAble", initial: "{ word: 'f' }", development: true }],
112
- // 'g': [{id: "ifAble", initial: "{ word: 'g' }", development: true }],
113
- 'f': [{id: "f", initial: "{ value: 'f', word: 'f' }", development: true }],
114
- 'x': [{id: "x", initial: "{ value: 'x', word: 'x' }", development: true }],
115
- 'gq': [{id: "g", initial: "{ word: 'gq', query: true }", development: true }],
110
+ // 'x': [{id: "x", initial: "{ value: 'x' }", scope: "testing" }],
111
+ // 'f': [{id: "ifAble", initial: "{ word: 'f' }", scope: "testing" }],
112
+ // 'g': [{id: "ifAble", initial: "{ word: 'g' }", scope: "testing" }],
113
+ 'f': [{id: "f", initial: "{ value: 'f', word: 'f' }", scope: "testing" }],
114
+ 'x': [{id: "x", initial: "{ value: 'x', word: 'x' }", scope: "testing" }],
115
+ 'gq': [{id: "g", initial: "{ word: 'gq', query: true }", scope: "testing" }],
116
116
  }
117
117
  },
118
118
  generators: [
@@ -120,19 +120,19 @@ const config = {
120
120
  where: where(),
121
121
  match: ({context}) => context.marker == 'undefined',
122
122
  apply: ({context}) => 'undefined',
123
- development: true,
123
+ scope: "testing",
124
124
  },
125
125
  {
126
126
  where: where(),
127
127
  match: ({context}) => context.marker == 'defined',
128
128
  apply: ({context}) => 'defined',
129
- development: true,
129
+ scope: "testing",
130
130
  },
131
131
  {
132
132
  where: where(),
133
133
  match: ({context}) => context.evalue && !context.paraphrase,
134
134
  apply: ({context}) => context.evalue.verbatim,
135
- development: true,
135
+ scope: "testing",
136
136
  },
137
137
  {
138
138
  where: where(),
@@ -154,13 +154,13 @@ const config = {
154
154
  where: where(),
155
155
  match: ({context}) => context.marker === 'ifAble',
156
156
  apply: ({context}) => context.value,
157
- development: true,
157
+ scope: "testing",
158
158
  },
159
159
  {
160
160
  where: where(),
161
161
  match: ({context}) => ['x', 'g', 'f', 'e', 'ifAble'].includes(context.marker),
162
162
  apply: ({context}) => `${context.word}`,
163
- development: true,
163
+ scope: "testing",
164
164
  },
165
165
  {
166
166
  where: where(),
@@ -182,7 +182,7 @@ const config = {
182
182
  }
183
183
  context.isResponse = true
184
184
  },
185
- development: true,
185
+ scope: "testing",
186
186
  },
187
187
  {
188
188
  where: where(),
@@ -206,10 +206,14 @@ const config = {
206
206
  // setup the read semantic
207
207
 
208
208
  // !topLevel or maybe !value??!?!
209
- const match = (defContext) => ({context}) => context.marker == (defContext.consequence || {}).marker && context.query // && !context.value
210
- const apply = (DEFINITIONs, DERIVED) => {
209
+ function match(defContext) {
210
+ return ({context}) => context.marker == (defContext.consequence || {}).marker && context.query // && !context.value
211
+ }
212
+ function apply(DEFINITIONs, DERIVED) {
211
213
  const mappingss = translationMappings(DEFINITIONs, DERIVED)
212
- const invertMappings = (mappings) => mappings.map( ({ from, to }) => { return { to: from, from: to } } )
214
+ function invertMappings(mappings) {
215
+ return mappings.map( ({ from, to }) => { return { to: from, from: to } } )
216
+ }
213
217
  return async ({context, s, config}) => {
214
218
  DEFINITIONs = _.cloneDeep(DEFINITIONs)
215
219
  //const mappings = mappingss[0]
@@ -292,6 +296,7 @@ const config = {
292
296
  }
293
297
  if (context.to.value) {
294
298
  kms.stm.api.setVariable(context.from.value, context.to.value)
299
+ // config.addWord(context.from.word, context.to)
295
300
  } else {
296
301
  await kms.dialogues.api.makeObject({ context: context.from, types: context.to.types || [], config });
297
302
  kms.stm.api.setVariable(context.from.value, context.to)
@@ -306,15 +311,21 @@ const config = {
306
311
  apply: async ({config, context, g}) => {
307
312
  // setup the write semantic
308
313
  {
309
- const matchByMarker = (defContext) => ({context}) => context.marker == defContext.from.marker && !context.query && !context.objects
310
- const matchByValue = (defContext) => ({context}) => context.evalue == defContext.from.value && !context.query && !context.objects
311
- const apply = (mappings, TO) => async ({context, s}) => {
312
- TO = _.cloneDeep(TO)
313
- for (const { from, to } of mappings) {
314
- hashIndexesSet(TO, to, hashIndexesGet(context, from))
314
+ function matchByMarker(defContext) {
315
+ return ({context}) => context.marker == defContext.from.marker && !context.query && !context.objects
316
+ }
317
+ function matchByValue(defContext) {
318
+ return ({context}) => context.evalue == defContext.from.value && !context.query && !context.objects
319
+ }
320
+ function apply(mappings, TO) {
321
+ return async ({context, s}) => {
322
+ TO = _.cloneDeep(TO)
323
+ for (const { from, to } of mappings) {
324
+ hashIndexesSet(TO, to, hashIndexesGet(context, from))
325
+ }
326
+ toPrime = await s(TO)
327
+ context.result = toPrime.result
315
328
  }
316
- toPrime = await s(TO)
317
- context.result = toPrime.result
318
329
  }
319
330
  const mappings = translationMapping(context.from, context.to)
320
331
  let match = matchByMarker(context)
@@ -333,30 +344,36 @@ const config = {
333
344
 
334
345
  // setup the read semantic
335
346
  {
336
- const matchByMarker = (defContext) => ({context, uuid}) => context.marker == defContext.from.marker && (context.query || context.evaluate) && !context[`disable${uuid}`]
337
- const matchByValue = (defContext) => ({context, uuid}) => context.value == defContext.from.value && (context.query || context.evaluate) && !context[`disable${uuid}`]
338
- const apply = (mappings, TO) => async ({uuid, context, s, g, config}) => {
339
- TO = _.cloneDeep(TO)
340
- for (const { from, to } of mappings) {
341
- hashIndexesSet(TO, to, hashIndexesGet(context, from))
342
- }
343
- // next move add debug arg to s and g
344
- // TODO why is there query and evaluate?
345
- if (context.query) {
346
- TO.query = context.query
347
- } else {
348
- TO.evaluate = context.evaluate
349
- }
350
- TO[`disable${uuid}`] = true
351
- toPrime = await s(TO)
352
- if (context.query) {
353
- if (toPrime.evalue) {
354
- context.evalue = toPrime.evalue
347
+ function matchByMarker(defContext) {
348
+ return ({context, uuid}) => context.marker == defContext.from.marker && (context.query || context.evaluate) && !context[`disable${uuid}`]
349
+ }
350
+ function matchByValue(defContext) {
351
+ return ({context, uuid}) => context.value == defContext.from.value && (context.query || context.evaluate) && !context[`disable${uuid}`]
352
+ }
353
+ function apply(mappings, TO) {
354
+ return async ({uuid, context, s, g, config}) => {
355
+ TO = _.cloneDeep(TO)
356
+ for (const { from, to } of mappings) {
357
+ hashIndexesSet(TO, to, hashIndexesGet(context, from))
358
+ }
359
+ // next move add debug arg to s and g
360
+ // TODO why is there query and evaluate?
361
+ if (context.query) {
362
+ TO.query = context.query
363
+ } else {
364
+ TO.evaluate = context.evaluate
365
+ }
366
+ TO[`disable${uuid}`] = true
367
+ toPrime = await s(TO)
368
+ if (context.query) {
369
+ if (toPrime.evalue) {
370
+ context.evalue = toPrime.evalue
371
+ } else {
372
+ context.evalue = toPrime
373
+ }
355
374
  } else {
356
- context.evalue = toPrime
375
+ context.evalue = toPrime.evalue
357
376
  }
358
- } else {
359
- context.evalue = toPrime.evalue
360
377
  }
361
378
  }
362
379
  const mappings = translationMapping(context.from, context.to)
@@ -396,8 +413,6 @@ knowledgeModule({
396
413
  context: [defaultContextCheck()],
397
414
  },
398
415
  },
399
- template: {
400
- template,
401
- instance: meta_instance,
402
- },
416
+ instance,
417
+ template,
403
418
  })
@@ -1,5 +1,5 @@
1
1
  const { knowledgeModule, where } = require('./runtime').theprogrammablemind
2
- const { defaultContextCheck } = require('./helpers')
2
+ const { defaultContextCheck, defaultContextCheckProperties } = require('./helpers')
3
3
  const helpers = require('./helpers')
4
4
  const stm = require('./stm')
5
5
  const nameable_tests = require('./nameable.test.json')
@@ -14,13 +14,10 @@ class API {
14
14
 
15
15
  // report is a context
16
16
  setName(context, name) {
17
- if (!context.stm) {
18
- context.stm = {}
19
- }
20
- if (!context.stm.names) {
21
- context.stm.names = []
22
- }
17
+ context.stm ??= {}
18
+ context.stm.names ??= []
23
19
  context.stm.names.push(name)
20
+ this.args.config.addWord(name, { id: context.marker, initial: `{ value: "${name}", pullFromContext: true, nameable_named: true }` })
24
21
  }
25
22
 
26
23
  get(type, name) {
@@ -70,32 +67,42 @@ class API {
70
67
  }
71
68
  }
72
69
 
73
- const api = new API()
74
-
70
+ function initializer({config}) {
71
+ config.addArgs(({kms, mentioned}) => {
72
+ return {
73
+ mentioned: (args) => {
74
+ mentioned(args)
75
+ if (args.name) {
76
+ kms.nameable.api.setName(args.context, args.name)
77
+ }
78
+ },
79
+ }
80
+ })
81
+ }
75
82
  const config = {
76
83
  name: 'nameable',
77
84
  operators: [
78
85
  // "([call] ([nameable]) (name))",
79
86
  "([call] ([nameable]) (!@<=endOfSentence)*)",
80
- { pattern: "([getNamesByType] (type))", development: true },
81
- { pattern: "([m1])", development: true },
82
- // { pattern: "([testPullFromContext] ([memorable]))", development: true }
87
+ { pattern: "([getNamesByType] (type))", scope: "testing" },
88
+ { pattern: "([m1])", scope: "testing" },
89
+ // { pattern: "([testPullFromContext] ([memorable]))", scope: "testing" }
83
90
  ],
84
91
  words: {
85
92
  literals: {
86
- // "m1": [{"id": "memorable", development: true, "initial": "{ value: 'm1' }" }],
87
- // "m2": [{"id": "memorable", development: true, "initial": "{ value: 'm2' }" }],
93
+ // "m1": [{"id": "memorable", scope: "testing", "initial": "{ value: 'm1' }" }],
94
+ // "m2": [{"id": "memorable", scope: "testing", "initial": "{ value: 'm2' }" }],
88
95
  },
89
96
  },
90
97
  bridges: [
91
98
  {
92
99
  id: 'm1',
93
100
  isA: ['memorable', 'nameable'],
94
- development: true,
101
+ scope: "testing",
95
102
  },
96
103
  {
97
104
  id: 'getNamesByType',
98
- development: true,
105
+ scope: "testing",
99
106
  isA: ['verb'],
100
107
  bridge: "{ ...next(operator), type: after[0] }",
101
108
  semantic: async ({context, api}) => {
@@ -107,19 +114,25 @@ const config = {
107
114
  id: 'call',
108
115
  isA: ['verb'],
109
116
  bridge: "{ ...next(operator), nameable: after[0], name: after[1:][0] }",
110
- // bridge: "{ ...next(operator), nameable: after[0], name: after[1] }",
111
- // generatorp: async ({context, g}) => `call ${await g(context.nameable)} ${await g(context.name)}`,
112
117
  generatorp: async ({context, g, gs}) => `call ${await g(context.nameable)} ${await gs(context.name)}`,
113
- semantic: async ({config, context, api, e}) => {
118
+ semantic: async ({config, context, api, e, verbatim, g}) => {
114
119
  // TODO find report being referred to
115
120
  const nameable = (await e(context.nameable)).evalue
121
+ if (!nameable) {
122
+ verbatim(`${await g(context.nameable)} is not known`)
123
+ return
124
+ }
116
125
  const name = context.name.map((n) => n.text).join(' ')
117
126
  // const name = context.name.text
118
- config.addWord(name, { id: nameable.marker, initial: `{ value: "${name}", pullFromContext: true, nameable_named: true }` })
119
127
  api.setName(nameable, name)
120
- }
128
+ },
129
+ check: defaultContextCheckProperties(['nameable', 'name']),
130
+ },
131
+ {
132
+ id: 'nameable',
133
+ words: helpers.words('nameable'),
134
+ children: ['thisitthat'],
121
135
  },
122
- { id: 'nameable', words: helpers.words('nameable')},
123
136
  ]
124
137
  }
125
138
 
@@ -127,6 +140,7 @@ knowledgeModule( {
127
140
  config,
128
141
  api: () => new API(),
129
142
  includes: [stm],
143
+ initializer,
130
144
 
131
145
  module,
132
146
  description: 'namable objects',