tpmkms 9.8.0-beta.8 → 9.9.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 (65) hide show
  1. package/common/actions.instance.json +4 -4
  2. package/common/actions.js +9 -9
  3. package/common/askfor.instance.json +12 -184
  4. package/common/askfor.js +19 -11
  5. package/common/asking.js +13 -5
  6. package/common/can.instance.json +2 -18
  7. package/common/can.js +2 -2
  8. package/common/comparable.instance.json +6 -12
  9. package/common/concept.instance.json +8 -4
  10. package/common/concept.js +2 -0
  11. package/common/conjunction.js +6 -4
  12. package/common/control.js +5 -5
  13. package/common/countable.js +1 -0
  14. package/common/dateTimeSelectors.instance.json +1 -1
  15. package/common/dateTimeSelectors.js +1 -1
  16. package/common/dates.instance.json +11 -1
  17. package/common/dates.js +6 -1
  18. package/common/debug.instance.json +5 -1
  19. package/common/debug.js +2 -0
  20. package/common/dialogues.js +37 -35
  21. package/common/dimension.instance.json +144 -446
  22. package/common/dimension.js +14 -8
  23. package/common/drone.instance.json +43 -19
  24. package/common/drone.js +29 -35
  25. package/common/drone_v1.instance.json +13 -3
  26. package/common/drone_v1.js +14 -9
  27. package/common/evaluate.js +2 -2
  28. package/common/fastfood.instance.json +12 -4
  29. package/common/fastfood.js +27 -12
  30. package/common/formulas.instance.json +138 -12
  31. package/common/formulas.js +15 -6
  32. package/common/gdefaults.js +2 -71
  33. package/common/helpers/dialogues.js +1 -10
  34. package/common/helpers/properties.js +6 -10
  35. package/common/helpers.js +5 -2
  36. package/common/hierarchy.js +11 -7
  37. package/common/math.instance.json +141 -4
  38. package/common/math.js +18 -5
  39. package/common/menus.instance.json +6 -2
  40. package/common/menus.js +5 -2
  41. package/common/meta.js +12 -12
  42. package/common/nameable.js +6 -2
  43. package/common/ordering.instance.json +1 -2
  44. package/common/percentages.js +4 -2
  45. package/common/pipboy.instance.json +38 -27
  46. package/common/pipboy.js +21 -14
  47. package/common/properties.instance.json +2319 -560
  48. package/common/properties.js +146 -37
  49. package/common/punctuation.js +1 -0
  50. package/common/rates.instance.json +1 -1
  51. package/common/rates.js +2 -2
  52. package/common/reminders.instance.json +16 -0
  53. package/common/reminders.js +23 -19
  54. package/common/reports.instance.json +4 -6
  55. package/common/reports.js +12 -12
  56. package/common/sdefaults.js +11 -9
  57. package/common/stm.js +11 -14
  58. package/common/testing.js +2 -2
  59. package/common/time.instance.json +42 -15
  60. package/common/time.js +7 -6
  61. package/common/ui.js +5 -5
  62. package/common/words.js +106 -1
  63. package/common/wp.instance.json +10 -3
  64. package/common/wp.js +5 -1
  65. package/package.json +2 -2
@@ -39,11 +39,13 @@ const config = {
39
39
  passthrough: true
40
40
  },
41
41
  bridge: "{ ...operator, value: append(before, operator.value) }",
42
+ where: where(),
42
43
  semantic: {
43
44
  match: ({context, namespaced}) => !namespaced.get('conjunction', context, 'atomic'),
44
- apply: async ({context, flatten, s}) => {
45
+ apply: async ({context, flatten, e}) => {
45
46
  for (const value of flatten(context)) {
46
- await s(value)
47
+ value.topLevel = context.topLevel;
48
+ await e(value, where())
47
49
  }
48
50
  }
49
51
  }
@@ -53,11 +55,11 @@ const config = {
53
55
  {
54
56
  where: where(),
55
57
  notes: 'evaluate elements of the list individually',
56
- match: ({context, callId}) => context.marker == 'list' && context.evaluate,
58
+ match: ({context, callId}) => context.marker == 'list' && !context.topLevel,
57
59
  apply: async ({context, toArray, toList, e, resolveEvaluate}) => {
58
60
  const list = []
59
61
  for (const element of toArray(context)) {
60
- list.push(await e(element))
62
+ list.push(await e(element, where()))
61
63
  }
62
64
  resolveEvaluate(context, toList(list))
63
65
  }
package/common/control.js CHANGED
@@ -3,8 +3,11 @@ const tests = require('./control.test.json')
3
3
 
4
4
  function initializer({config}) {
5
5
  config.addArgs((args) => ({
6
- callOnce: (args, tag, condition) => {
7
- if (condition(args)) {
6
+ callOnce: async (args, tag, condition) => {
7
+ if (args.context.control?.seen[tag]) {
8
+ return false
9
+ }
10
+ if (await condition(args)) {
8
11
  const { context } = args
9
12
 
10
13
  if (!context.control) {
@@ -12,9 +15,6 @@ function initializer({config}) {
12
15
  seen: {},
13
16
  }
14
17
  }
15
- if (context.control.seen[tag]) {
16
- return false
17
- }
18
18
  context.control.seen[tag] = true
19
19
 
20
20
  args._finally( () => {
@@ -98,6 +98,7 @@ const config = {
98
98
  },
99
99
  {
100
100
  id: "all",
101
+ where: where(),
101
102
  generatorp: ({context}) => 'all',
102
103
  bridge: "{ ...next(operator), number: 'many', quantity: 'all' }"
103
104
  },
@@ -68,7 +68,7 @@
68
68
  "semantics": [
69
69
  {
70
70
  "match": "({context, isA}) => onOrIs('dayAfterDate', context)",
71
- "apply": "async ({context, isProcess, isTest, kms, isA, e}) => {\n try {\n const now = kms.time.api.now()\n const date = afterOrIs('dayAfterDate', context)\n const afterISO = (await e(date.after)).evalue\n const day_ordinal = date.day.day_ordinal\n const ordinal = date.day.ordinal.value\n context.evalue = dateTimeSelectors_helpers.getNthWeekdayAfterDate(afterISO, day_ordinal, ordinal)\n } catch ( e ) {\n context.evalue = `Implement instatiate for this type of date, ${context.marker}. See the dateTimeSelectors KM ${where()}. ${e}`\n }\n }"
71
+ "apply": "async ({context, isProcess, isTest, kms, isA, e}) => {\n try {\n const now = kms.time.api.now()\n const date = afterOrIs('dayAfterDate', context)\n const afterISO = (await e(date.after, where())).evalue\n const day_ordinal = date.day.day_ordinal\n const ordinal = date.day.ordinal.value\n context.evalue = dateTimeSelectors_helpers.getNthWeekdayAfterDate(afterISO, day_ordinal, ordinal)\n } catch ( e ) {\n context.evalue = `Implement instatiate for this type of date, ${context.marker}. See the dateTimeSelectors KM ${where()}. ${e}`\n }\n }"
72
72
  },
73
73
  {
74
74
  "match": "({context, isA}) => onOrIs('dayOfMonth', context)",
@@ -99,7 +99,7 @@ const template = {
99
99
  try {
100
100
  const now = kms.time.api.now()
101
101
  const date = afterOrIs('dayAfterDate', context)
102
- const afterISO = (await e(date.after)).evalue
102
+ const afterISO = (await e(date.after, where())).evalue
103
103
  const day_ordinal = date.day.day_ordinal
104
104
  const ordinal = date.day.ordinal.value
105
105
  context.evalue = dateTimeSelectors_helpers.getNthWeekdayAfterDate(afterISO, day_ordinal, ordinal)
@@ -184,6 +184,7 @@
184
184
  },
185
185
  {
186
186
  "id": "dateEra_dates",
187
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dates.js:129",
187
188
  "isA": [
188
189
  "date_dates"
189
190
  ],
@@ -215,6 +216,7 @@
215
216
  },
216
217
  {
217
218
  "id": "monthDayYearWithSlashes_dates",
219
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dates.js:143",
218
220
  "isA": [
219
221
  "date_dates"
220
222
  ],
@@ -266,6 +268,7 @@
266
268
  },
267
269
  {
268
270
  "id": "monthDay_dates",
271
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dates.js:170",
269
272
  "convolution": true,
270
273
  "localHierarchy": [
271
274
  [
@@ -300,6 +303,7 @@
300
303
  },
301
304
  {
302
305
  "id": "monthYear_dates",
306
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dates.js:181",
303
307
  "convolution": true,
304
308
  "before": [
305
309
  "preposition"
@@ -328,6 +332,7 @@
328
332
  },
329
333
  {
330
334
  "id": "monthDayYear_dates",
335
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dates.js:191",
331
336
  "convolution": true,
332
337
  "before": [
333
338
  "preposition",
@@ -336,7 +341,7 @@
336
341
  "isA": [
337
342
  "date_dates"
338
343
  ],
339
- "evaluator": "({context}) => {\n const year = context.year.value\n const day = context.day.value\n const month_ordinal = context.month.month_ordinal\n context.evalue = new Date(year, month_ordinal-1, day).toISOString()\n }",
344
+ "semantic": "({context}) => {\n const year = context.year.value\n const day = context.day.value\n const month_ordinal = context.month.month_ordinal\n context.evalue = new Date(year, month_ordinal-1, day).toISOString()\n }",
340
345
  "localHierarchy": [
341
346
  [
342
347
  "ordinal",
@@ -15147,6 +15152,7 @@
15147
15152
  },
15148
15153
  {
15149
15154
  "id": "dateEra_dates",
15155
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dates.js:129",
15150
15156
  "isA": [
15151
15157
  "date_dates"
15152
15158
  ],
@@ -15177,6 +15183,7 @@
15177
15183
  },
15178
15184
  {
15179
15185
  "id": "monthDayYearWithSlashes_dates",
15186
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dates.js:143",
15180
15187
  "isA": [
15181
15188
  "date_dates"
15182
15189
  ],
@@ -15227,6 +15234,7 @@
15227
15234
  },
15228
15235
  {
15229
15236
  "id": "monthDay_dates",
15237
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dates.js:170",
15230
15238
  "convolution": true,
15231
15239
  "localHierarchy": [
15232
15240
  [
@@ -15260,6 +15268,7 @@
15260
15268
  },
15261
15269
  {
15262
15270
  "id": "monthYear_dates",
15271
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dates.js:181",
15263
15272
  "convolution": true,
15264
15273
  "before": [
15265
15274
  "preposition"
@@ -15287,6 +15296,7 @@
15287
15296
  },
15288
15297
  {
15289
15298
  "id": "monthDayYear_dates",
15299
+ "where": "/home/dev/code/theprogrammablemind/kms/common/dates.js:191",
15290
15300
  "convolution": true,
15291
15301
  "before": [
15292
15302
  "preposition",
package/common/dates.js CHANGED
@@ -126,6 +126,7 @@ const template = {
126
126
  },
127
127
  {
128
128
  id: 'dateEra_dates',
129
+ where: where(),
129
130
  isA: ['date_dates'],
130
131
  convolution: true,
131
132
  bridge: "{ ...next(after[0]), era: after[1], interpolate: concat(after[0].interpolate, ' ${era}') }",
@@ -139,6 +140,7 @@ const template = {
139
140
  },
140
141
  {
141
142
  id: 'monthDayYearWithSlashes_dates',
143
+ where: where(),
142
144
  isA: ['date_dates'],
143
145
  before: ['preposition'],
144
146
  separators: "||||",
@@ -165,6 +167,7 @@ const template = {
165
167
  },
166
168
  {
167
169
  id: 'monthDay_dates',
170
+ where: where(),
168
171
  convolution: true,
169
172
  localHierarchy: [['ordinal', 'dayNumber_dates']],
170
173
  before: ['preposition'],
@@ -175,6 +178,7 @@ const template = {
175
178
  },
176
179
  {
177
180
  id: 'monthYear_dates',
181
+ where: where(),
178
182
  convolution: true,
179
183
  before: ['preposition'],
180
184
  isA: ['date_dates'],
@@ -184,10 +188,11 @@ const template = {
184
188
  },
185
189
  {
186
190
  id: 'monthDayYear_dates',
191
+ where: where(),
187
192
  convolution: true,
188
193
  before: ['preposition', 'monthDay_dates'],
189
194
  isA: ['date_dates'],
190
- evaluator: ({context}) => {
195
+ semantic: ({context}) => {
191
196
  const year = context.year.value
192
197
  const day = context.day.value
193
198
  const month_ordinal = context.month.month_ordinal
@@ -8,11 +8,13 @@
8
8
  "bridges": [
9
9
  {
10
10
  "id": "setdebugbreak",
11
+ "where": "/home/dev/code/theprogrammablemind/kms/common/debug.js:16",
11
12
  "bridge": "{\n ...next(operator),\n tag: after[0]\n }",
12
13
  "semantic": "({context, debug}) => {\n debug.hit(context.tag.word)\n }"
13
14
  },
14
15
  {
15
16
  "id": "debugger",
17
+ "where": "/home/dev/code/theprogrammablemind/kms/common/debug.js:27",
16
18
  "semantic": "(args) => {\n debugger // eslint-disable-line no-debugger\n debugger // eslint-disable-line no-debugger\n }"
17
19
  }
18
20
  ]
@@ -28,10 +30,12 @@
28
30
  "bridges": [
29
31
  {
30
32
  "id": "setdebugbreak",
33
+ "where": "/home/dev/code/theprogrammablemind/kms/common/debug.js:16",
31
34
  "bridge": "{\n ...next(operator),\n tag: after[0]\n }"
32
35
  },
33
36
  {
34
- "id": "debugger"
37
+ "id": "debugger",
38
+ "where": "/home/dev/code/theprogrammablemind/kms/common/debug.js:27"
35
39
  }
36
40
  ]
37
41
  }
package/common/debug.js CHANGED
@@ -13,6 +13,7 @@ const template = {
13
13
  bridges: [
14
14
  {
15
15
  id: 'setdebugbreak',
16
+ where: where(),
16
17
  bridge: `{
17
18
  ...next(operator),
18
19
  tag: after[0]
@@ -23,6 +24,7 @@ const template = {
23
24
  },
24
25
  {
25
26
  id: 'debugger',
27
+ where: where(),
26
28
  semantic: (args) => {
27
29
  debugger // eslint-disable-line no-debugger
28
30
  debugger // eslint-disable-line no-debugger
@@ -57,6 +57,7 @@ const config = {
57
57
 
58
58
  "(<what> ([whatAble|]))",
59
59
  "([what:optional])",
60
+ "([who])",
60
61
 
61
62
  "([be] ([briefOrWordy|]))",
62
63
 
@@ -110,6 +111,7 @@ const config = {
110
111
  },
111
112
  {
112
113
  id: 'makeObject',
114
+ where: where(),
113
115
  bridge: "{ ...next(operator), object: after[0] }",
114
116
  enhanced_associations: false,
115
117
  generatorp: async ({context, gp}) => `${context.word} ${await gp(context.object)}`,
@@ -119,6 +121,7 @@ const config = {
119
121
  },
120
122
  {
121
123
  id: 'setIdSuffix',
124
+ where: where(),
122
125
  enhanced_associations: false,
123
126
  bridge: "{ ...next(operator), suffix: after[0] }",
124
127
  generatorp: async ({context, gp}) => `${context.word} ${await gp(context.suffix)}`,
@@ -128,6 +131,7 @@ const config = {
128
131
  },
129
132
  {
130
133
  id: 'resetIdSuffix',
134
+ where: where(),
131
135
  semantic: ({context, api}) => {
132
136
  api.setIdSuffix('')
133
137
  }
@@ -142,9 +146,15 @@ const config = {
142
146
 
143
147
  {
144
148
  id: "what",
149
+ isA: ['queryable'],
145
150
  optional: "{ ...next(operator), query: ['what'], determined: true, isVariable: true }",
146
151
  bridge: "{ ...after, query: ['what'], modifiers: ['what'], what: operator, isVariable: true }"
147
152
  },
153
+ {
154
+ id: "who",
155
+ isA: ['queryable'],
156
+ initial: { query: true, isVariable: true },
157
+ },
148
158
  { id: "whatAble" },
149
159
 
150
160
  // context.isInstance == variables.isInstance (unification)
@@ -226,7 +236,7 @@ const config = {
226
236
  "literals": {
227
237
  "?": [{"id": "questionMark", "initial": "{}" }],
228
238
  // TODO make who its own concept
229
- "who": [{"id": "what", "initial": "{ modifiers: [], query: true }" }],
239
+ // "who": [{"id": "what", "initial": "{ modifiers: [], query: true }" }],
230
240
  "yes": [{"id": "yesno", "initial": "{ value: true }" }],
231
241
  "no": [{"id": "yesno", "initial": "{ value: false }" }],
232
242
  "brief": [{"id": "briefOrWordy", "initial": "{ value: 'brief' }" }],
@@ -266,7 +276,6 @@ const config = {
266
276
  ['the', 'article'],
267
277
  ['theAble', 'queryable'],
268
278
  ['it', 'queryable'],
269
- ['what', 'queryable'],
270
279
  ['whatAble', 'queryable'],
271
280
  ['negatable', 'queryable'],
272
281
  ['is', 'canBeQuestion'],
@@ -405,7 +414,9 @@ const config = {
405
414
  },
406
415
  {
407
416
  where: where(),
408
- match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeQuestion') && context.paraphrase && context.topLevel && context.query,
417
+ match: ({context, hierarchy, debug}) => {
418
+ return hierarchy.isA(context.marker, 'canBeQuestion') && context.paraphrase && context.topLevel && context.query
419
+ },
409
420
  apply: async ({context, gp}) => {
410
421
  return `${await gp({...context, topLevel: undefined})}?`
411
422
  },
@@ -486,6 +497,9 @@ const config = {
486
497
  if (focus == 'one' && isA(context[focus], 'thisitthat')) {
487
498
  focus = other
488
499
  }
500
+ if (focus == 'two' && context[other].isPropertyValue) {
501
+ focus = other
502
+ }
489
503
  // greg101
490
504
  if (focus == 'one') {
491
505
  let number = 'one'
@@ -509,11 +523,12 @@ const config = {
509
523
  {
510
524
  where: where(),
511
525
  match: ({context}) => {
512
- return context.evaluate && context.marker == 'unify' && context.terms.some((term) => term.marker == 'what')
526
+ return context.marker == 'unify' && context.terms.some((term) => ['what', 'who'].includes(term.marker))
513
527
  },
514
- apply: async ({context, resolveEvaluate, toEValue}) => {
515
- const value = context.terms.find((term) => term.marker !== 'what')
516
- await resolveEvaluate(context, value)
528
+ apply: async ({context, resolveEvaluate, e, toFinalValue}) => {
529
+ const value = context.terms.find((term) => !['what', 'who'].includes(term.marker))
530
+ instance = await e(value, where())
531
+ await resolveEvaluate(context, instance)
517
532
  }
518
533
  },
519
534
  {
@@ -528,9 +543,10 @@ const config = {
528
543
  where: where(),
529
544
  match: ({context}) => context.marker === 'error',
530
545
  apply: async ({context, g, gp}) => {
531
- context.evalue = "That is not known"
532
546
  if (context.reason) {
533
- context.evalue += ` because ${await g(context.reason)}`
547
+ context.evalue = `${await g(context.reason)}`
548
+ } else {
549
+ context.evalue = "That is not known"
534
550
  }
535
551
  context.isResponse = true
536
552
  }
@@ -585,7 +601,12 @@ const config = {
585
601
  value = one;
586
602
  }
587
603
 
588
- let instance = await e(value)
604
+ const unification = await e({
605
+ marker: 'unify',
606
+ terms: [query, value],
607
+ }, where())
608
+ instance = unification.evalue || { marker: 'undefined' }
609
+
589
610
  if (instance.verbatim) {
590
611
  context.evalue = { verbatim: instance.verbatim }
591
612
  context.isResponse = true
@@ -598,16 +619,6 @@ const config = {
598
619
  return
599
620
  }
600
621
 
601
- if (true) {
602
- if (query.query || value.query) {
603
- const unification = await e({
604
- marker: 'unify',
605
- terms: [query, instance],
606
- })
607
- instance = unification.evalue
608
- }
609
- }
610
-
611
622
  const concept = _.cloneDeep(value)
612
623
  concept.isQuery = undefined
613
624
  instance.focus = true
@@ -625,10 +636,7 @@ const config = {
625
636
  word: many ? "are" : "is",
626
637
  number: many ? "many" : undefined,
627
638
  }
628
- if (false) {
629
- evalue.one = instance
630
- evalue.two = concept
631
- }
639
+
632
640
  context.evalue = evalue
633
641
  context.isResponse = true
634
642
  }
@@ -662,7 +670,7 @@ const config = {
662
670
  where: where(),
663
671
  notes: 'x is y. handles x is a kind of y or x = y in the stm',
664
672
  match: ({context}) => context.marker == 'is' && !context.query && context.one && context.two,
665
- apply: async ({_continue, context, s, debug, log, api, kms, config}) => {
673
+ apply: async ({_continue, context, e, debug, log, api, kms, config}) => {
666
674
  function warningSameNotEvaluated(log, one) {
667
675
  const description = 'WARNING from Dialogues KM: For the "X is Y" type phrase implement a same handler.'
668
676
  const match = `({context}) => context.marker == '${one.marker}' && context.same && <other conditions as you like>`
@@ -674,7 +682,7 @@ const config = {
674
682
 
675
683
  const one = context.one;
676
684
  const two = context.two;
677
- const onePrime = await s({ marker: 'same', one: one, two: two })
685
+ const onePrime = await e({ marker: 'same', one: one, two: two }, where())
678
686
  if (!onePrime.sameWasProcessed) {
679
687
  warningSameNotEvaluated(log, one)
680
688
  } else {
@@ -706,14 +714,13 @@ const config = {
706
714
  {
707
715
  where: where(),
708
716
  notes: 'get variable from stm',
709
- match: ({context, kms}) => context.evaluate && kms.stm.api.getVariable(context),
710
- // match: ({context, kms}) => context.evaluate,
717
+ match: ({context, kms}) => kms.stm.api.getVariable(context),
711
718
  priority: -1,
712
719
  apply: async ({context, kms, e}) => {
713
720
  const api = kms.stm.api
714
721
  context.value = api.getVariable(context)
715
722
  if (context.value && context.value.marker) {
716
- context.evalue = await e(context.value)
723
+ context.evalue = await e(context.value, where())
717
724
  }
718
725
  context.focusableForPhrase = true
719
726
  }
@@ -722,11 +729,6 @@ const config = {
722
729
  };
723
730
 
724
731
  function initializer({objects, config, isModule}) {
725
- /* TODO add this beck in. some stuff from config needs to be here
726
- config.addArgs((args) => ({
727
- e: (context) => config.api.getEvaluator(args.s, args.log, context),
728
- }))
729
- */
730
732
  config.addArgs(({config, api, isA, e}) => ({
731
733
  toScopedId: (context) => {
732
734
  return api('dialogues').toScopedId(context)
@@ -741,7 +743,7 @@ function initializer({objects, config, isModule}) {
741
743
  const unification = await e({
742
744
  marker: 'unify',
743
745
  terms: [term1, term2],
744
- })
746
+ }, where())
745
747
  return unification?.evalue
746
748
  }
747
749
  }))