tpmkms_4wp 9.3.0 → 9.4.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.
- package/common/animals.instance.json +0 -65
- package/common/animals.js +2 -3
- package/common/animals.test.json +1607 -1
- package/common/articles.js +2 -4
- package/common/asking.js +21 -5
- package/common/avatar.js +4 -12
- package/common/characters.js +2 -2
- package/common/colors.instance.json +0 -70
- package/common/colors.js +2 -2
- package/common/comparable.instance.json +0 -15
- package/common/comparable.js +2 -2
- package/common/concept.js +1 -2
- package/common/concept.test.json +279 -193
- package/common/conjunction.js +3 -5
- package/common/countable.js +2 -14
- package/common/crew.instance.json +0 -130
- package/common/crew.js +2 -2
- package/common/currency.js +2 -3
- package/common/dateTimeSelectors.instance.json +175 -0
- package/common/dateTimeSelectors.js +168 -0
- package/common/dateTimeSelectors.test.json +85622 -0
- package/common/dates.instance.json +504 -486
- package/common/dates.js +128 -16
- package/common/dates.test.json +16867 -373
- package/common/dialogues.js +13 -49
- package/common/dimension.instance.json +0 -5
- package/common/dimension.js +4 -4
- package/common/edible.instance.json +0 -216
- package/common/edible.js +2 -2
- package/common/emotions.instance.json +0 -5
- package/common/emotions.js +2 -2
- package/common/errors.js +3 -0
- package/common/evaluate.js +2 -2
- package/common/events.js +1 -2
- package/common/fastfood.instance.json +28 -975
- package/common/fastfood.js +2 -4
- package/common/fastfood.test.json +16291 -6597
- package/common/formulas.instance.json +0 -5
- package/common/formulas.js +3 -1
- package/common/gdefaults.js +7 -4
- package/common/help.js +2 -2
- package/common/helpers/dateTimeSelectors.js +198 -0
- package/common/helpers/dialogues.js +11 -8
- package/common/helpers/properties.js +2 -2
- package/common/helpers.js +23 -47
- package/common/hierarchy.js +12 -13
- package/common/javascript.js +2 -3
- package/common/kirk.instance.json +30 -119
- package/common/kirk.js +2 -3
- package/common/length.instance.json +0 -75
- package/common/length.js +2 -3
- package/common/listener.js +3 -1
- package/common/math.instance.json +0 -5
- package/common/math.js +2 -3
- package/common/menus.instance.json +0 -35
- package/common/menus.js +3 -1
- package/common/meta.js +4 -5
- package/common/nameable.js +3 -1
- package/common/negation.js +2 -2
- package/common/numbers.js +7 -4
- package/common/numbers.test.json +89 -23
- package/common/ordering.instance.json +0 -10
- package/common/ordering.js +2 -3
- package/common/ordinals.js +2 -3
- package/common/people.instance.json +0 -40
- package/common/people.js +2 -3
- package/common/percentages.js +3 -4
- package/common/percentages.test.json +57 -11
- package/common/pipboy.instance.json +0 -85
- package/common/pipboy.js +1 -1
- package/common/pipboy.test.json +4377 -3386
- package/common/pokemon.instance.json +0 -65
- package/common/pokemon.js +1 -2
- package/common/pos.js +2 -2
- package/common/pressure.instance.json +0 -20
- package/common/pressure.js +2 -2
- package/common/properties.instance.json +0 -5
- package/common/properties.js +11 -13
- package/common/punctuation.js +2 -2
- package/common/reminders.instance.json +237 -0
- package/common/reminders.js +394 -0
- package/common/reminders.test.json +81932 -0
- package/common/reports.instance.json +2 -12
- package/common/reports.js +1 -1
- package/common/scorekeeper.js +2 -2
- package/common/scorekeeper.test.json +3565 -7550
- package/common/sdefaults.js +1 -1
- package/common/self.instance.json +2 -0
- package/common/self.js +49 -0
- package/common/self.test.json +2 -0
- package/common/sizeable.js +2 -2
- package/common/spock.instance.json +30 -119
- package/common/spock.js +1 -1
- package/common/stgame.js +1 -1
- package/common/stm.js +1 -1
- package/common/tell.js +2 -2
- package/common/temperature.instance.json +84 -20
- package/common/temperature.js +2 -2
- package/common/tester.js +0 -1
- package/common/testing.js +0 -1
- package/common/time.js +57 -30
- package/common/time.test.json +4159 -205
- package/common/tokenize.js +1 -1
- package/common/ui.instance.json +0 -5
- package/common/ui.js +4 -2
- package/common/weight.instance.json +0 -60
- package/common/weight.js +2 -2
- package/common/wp.instance.json +386 -72
- package/common/wp.js +1 -5
- package/common/wp.test.json +8057 -3867
- package/common/yesno.js +2 -2
- package/main.js +6 -0
- package/package.json +16 -4
@@ -0,0 +1,394 @@
|
|
1
|
+
const { knowledgeModule, where } = require('./runtime').theprogrammablemind
|
2
|
+
const { defaultContextCheck } = require('./helpers')
|
3
|
+
const reminders_tests = require('./reminders.test.json')
|
4
|
+
const reminders_instance = require('./reminders.instance.json')
|
5
|
+
const selfKM = require('./self')
|
6
|
+
const dateTimeSelectors = require('./dateTimeSelectors')
|
7
|
+
const helpers = require('./helpers')
|
8
|
+
|
9
|
+
/*
|
10
|
+
friday instead
|
11
|
+
change it to friday
|
12
|
+
delete it
|
13
|
+
make it friday instead
|
14
|
+
2 sundays from now
|
15
|
+
the sunday after july 1st
|
16
|
+
remind every truck driver to whatever tomorrow at 8 am
|
17
|
+
add the user greg
|
18
|
+
add greg as a user
|
19
|
+
*/
|
20
|
+
|
21
|
+
const query = (missing, reminder_id) => {
|
22
|
+
return {
|
23
|
+
where: where(),
|
24
|
+
// oneShot: false,
|
25
|
+
onNevermind: ({verbatim, ...args}) => {
|
26
|
+
const api = args.kms.reminders.api
|
27
|
+
api.delete_reminder(reminder_id)
|
28
|
+
},
|
29
|
+
|
30
|
+
matchq: ({ api, context }) => api.missing(missing, reminder_id) && context.marker == 'controlEnd',
|
31
|
+
applyq: async ({ api, context, gs, enable }) => {
|
32
|
+
context.cascade = false
|
33
|
+
const item = api.missing(missing, reminder_id)
|
34
|
+
let who
|
35
|
+
if (Array.isArray(item.who)) {
|
36
|
+
who = await gs(item.who.map((who) => who.text), ', ', ' and ')
|
37
|
+
} else {
|
38
|
+
if (item.who.text == 'me') {
|
39
|
+
who = 'you'
|
40
|
+
} else {
|
41
|
+
who = item.who.text
|
42
|
+
}
|
43
|
+
}
|
44
|
+
if (item.missingDate) {
|
45
|
+
return `When should I remind ${who} to ${item.text}`
|
46
|
+
}
|
47
|
+
if (item.missingReminder) {
|
48
|
+
enable(['remindResponse', 0])
|
49
|
+
return `What should I remind ${who} to do?`
|
50
|
+
}
|
51
|
+
},
|
52
|
+
|
53
|
+
matchr: ({ isA, api, context }) => {
|
54
|
+
if (context.evaluate || context.isControl || context.isResponse) {
|
55
|
+
return false
|
56
|
+
}
|
57
|
+
const gotADate = ((isA(context.marker, 'onDateValue_dates') || isA(context.marker, 'dateTimeSelector')) && api.missing(missing, reminder_id))
|
58
|
+
if (missing == 'missingDate') {
|
59
|
+
return gotADate
|
60
|
+
} else {
|
61
|
+
// return !gotADate && !context.isControl
|
62
|
+
}
|
63
|
+
return false
|
64
|
+
},
|
65
|
+
applyr: async ({ context, api, gp }) => {
|
66
|
+
const item = api.missing(missing, reminder_id)
|
67
|
+
await api.update({ id: item.id, dateTimeSelector: context, dateTimeSelectorText: await gp(context) })
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
class API {
|
73
|
+
initialize({ objects }) {
|
74
|
+
this._objects = objects
|
75
|
+
this._objects.reminders = []
|
76
|
+
this._objects.id = 0
|
77
|
+
this._objects.current = null
|
78
|
+
this._objects.defaultTime = { hour: 9, minute: 0, second: 0, millisecond: 0 }
|
79
|
+
}
|
80
|
+
|
81
|
+
async add(reminder) {
|
82
|
+
await this.instantiate(reminder)
|
83
|
+
const id = ++this._objects.id
|
84
|
+
reminder.id = id
|
85
|
+
this._objects.reminders.push(reminder)
|
86
|
+
this.args.mentioned({ context: reminder })
|
87
|
+
this._objects.current = id
|
88
|
+
}
|
89
|
+
|
90
|
+
getCurrentId() {
|
91
|
+
return this._objects.current
|
92
|
+
}
|
93
|
+
|
94
|
+
// addUser to current
|
95
|
+
addUser(user) {
|
96
|
+
const reminder = this.reminders().find((r) => r.id == this._objects.current)
|
97
|
+
if (reminder) {
|
98
|
+
if (Array.isArray(reminder.who)) {
|
99
|
+
reminder.who = [...reminder.who, user]
|
100
|
+
} else {
|
101
|
+
reminder.who = [reminder.who, user]
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
removeUser(user) {
|
107
|
+
const reminder = this.reminders().find((r) => r.id == this._objects.current)
|
108
|
+
if (reminder) {
|
109
|
+
reminder.who = reminder.who.filter((who) => who.remindee_id != user.remindee_id)
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
async addRemindable(id, text) {
|
114
|
+
if (!text) {
|
115
|
+
text = id
|
116
|
+
}
|
117
|
+
await this.args.makeObject({ ...this.args, context: { word: text, value: id, number: 'one', remindee_id: id }, initial: { remindee_id: `${id}` }, types: ['remindable'] })
|
118
|
+
}
|
119
|
+
|
120
|
+
async instantiate(reminder) {
|
121
|
+
if (reminder.dateTimeSelector) {
|
122
|
+
reminder.dateTimeSelector.defaultTime = this._objects.defaultTime
|
123
|
+
}
|
124
|
+
const value = await this.args.e(reminder.dateTimeSelector)
|
125
|
+
reminder.nextISODate = value?.evalue
|
126
|
+
}
|
127
|
+
|
128
|
+
contextToWho(who) {
|
129
|
+
if (who.isList) {
|
130
|
+
const whos = []
|
131
|
+
for (const element of this.args.values(who)) {
|
132
|
+
whos.push(this.contextToWho(element))
|
133
|
+
}
|
134
|
+
return whos
|
135
|
+
} else {
|
136
|
+
return { id: who.value || who.text, text: who.text, remindee_id: who.remindee_id }
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
missing(what, reminder_id) {
|
141
|
+
const reminder = this.reminder(reminder_id)
|
142
|
+
if (what == 'missingReminder' && !reminder.text) {
|
143
|
+
return { when: true, who: reminder.who, text: reminder.text, id: reminder.id, missingReminder: true }
|
144
|
+
}
|
145
|
+
if (what == 'missingDate' && !reminder.dateTimeSelector) {
|
146
|
+
return { when: true, who: reminder.who, text: reminder.text, id: reminder.id, missingDate: true }
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
reminder(id) {
|
151
|
+
return this._objects.reminders.find((reminder) => reminder.id == id)
|
152
|
+
}
|
153
|
+
|
154
|
+
reminders() {
|
155
|
+
return this._objects.reminders
|
156
|
+
}
|
157
|
+
|
158
|
+
setReminders(reminders) {
|
159
|
+
this._objects.reminders = reminders
|
160
|
+
}
|
161
|
+
|
162
|
+
askAbout(what) {
|
163
|
+
const items = []
|
164
|
+
for (const item of this.reminders()) {
|
165
|
+
if (this.missing('missingReminder', item.id)) {
|
166
|
+
items.push(this.missing('missingReminder', item.id))
|
167
|
+
}
|
168
|
+
if (this.missing('missingDate', item.id)) {
|
169
|
+
items.push(this.missing('missingDate', item.id))
|
170
|
+
}
|
171
|
+
}
|
172
|
+
return items
|
173
|
+
}
|
174
|
+
|
175
|
+
show() {
|
176
|
+
if (this.reminders().length == 0) {
|
177
|
+
return "There are no reminders"
|
178
|
+
}
|
179
|
+
let s = 'The reminders are\n'
|
180
|
+
let counter = 1
|
181
|
+
for (const item of this.reminders()) {
|
182
|
+
s += ` ${counter}. ${item.text}\n`
|
183
|
+
counter += 1
|
184
|
+
}
|
185
|
+
return s;
|
186
|
+
// -> return a table object. then have ability to talk about the table. maybe later let's focus on this for now
|
187
|
+
}
|
188
|
+
|
189
|
+
delete_reminder(id) {
|
190
|
+
const reminder = this.reminders().find((reminder) => reminder.id)
|
191
|
+
if (reminder) {
|
192
|
+
if (reminder.cleanUp) {
|
193
|
+
reminder.cleanUp()
|
194
|
+
}
|
195
|
+
this.setReminders(this.reminders().filter((reminder) => reminder.id != id))
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
async update(update) {
|
200
|
+
if (!update.id) {
|
201
|
+
update.id = this.getCurrentId()
|
202
|
+
}
|
203
|
+
for (const item of this._objects.reminders) {
|
204
|
+
if (item.id == update.id) {
|
205
|
+
Object.assign(item, update)
|
206
|
+
await this.instantiate(item)
|
207
|
+
return
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
213
|
+
/*
|
214
|
+
remind me to go to the store tuesday
|
215
|
+
*/
|
216
|
+
const template = {
|
217
|
+
configs: [
|
218
|
+
{
|
219
|
+
operators: [
|
220
|
+
"([remindable])",
|
221
|
+
{ pattern: "([addRemindable] (word)*)", development: true },
|
222
|
+
"([remind:justWhoBridge] (remindable/*))",
|
223
|
+
"([remind] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')*)",
|
224
|
+
"([remind:withDateBridge] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')* (dateTimeSelector))",
|
225
|
+
"([remind:withDateFirstBridge] (remindable/*) (dateTimeSelector) (!@<= 'dateTimeSelector' && !@<= 'inAddition')*)",
|
226
|
+
"([remind:withDateAndTimeBridge] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')* (dateTimeSelector) (atTime))",
|
227
|
+
"([remindResponse] (!@<= 'remindResponse' && !@<= 'dateTimeSelector' && !@<= 'inAddition')+ (dateTimeSelector))",
|
228
|
+
"([show] ([reminders]))",
|
229
|
+
"([delete_reminders|delete,cancel] (number/*))",
|
230
|
+
"([add] (remindable/*))",
|
231
|
+
"([remove|] (remindable/*))",
|
232
|
+
"((verb/*) [inAddition|also,too])",
|
233
|
+
],
|
234
|
+
bridges: [
|
235
|
+
{
|
236
|
+
id: 'inAddition',
|
237
|
+
after: ['verb'],
|
238
|
+
bridge: "{ ...before[0], inAddition: true, verb: before[0], operator: operator, interpolate: '${verb} ${operator}' }",
|
239
|
+
},
|
240
|
+
{
|
241
|
+
id: 'add',
|
242
|
+
isA: ['verb'],
|
243
|
+
bridge: "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
244
|
+
semantic: ({api, context}) => {
|
245
|
+
api.addUser(api.contextToWho(context.arg))
|
246
|
+
}
|
247
|
+
},
|
248
|
+
{
|
249
|
+
id: 'remove',
|
250
|
+
words: ['delete', 'remove'],
|
251
|
+
isA: ['verb'],
|
252
|
+
bridge: "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
253
|
+
semantic: ({api, context}) => {
|
254
|
+
api.removeUser(api.contextToWho(context.arg))
|
255
|
+
}
|
256
|
+
},
|
257
|
+
{
|
258
|
+
id: 'addRemindable',
|
259
|
+
isA: ['verb'],
|
260
|
+
development: true,
|
261
|
+
bridge: "{ ...next(operator), flatten: true, arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
262
|
+
semantic: async ({api, context}) => {
|
263
|
+
const name = context.arg.map( (word) => word.text ).join(' ')
|
264
|
+
await api.addRemindable(name)
|
265
|
+
}
|
266
|
+
},
|
267
|
+
{
|
268
|
+
id: 'remindable',
|
269
|
+
isA: ['listable'],
|
270
|
+
},
|
271
|
+
{
|
272
|
+
id: 'remindResponse',
|
273
|
+
isA: ['verb'],
|
274
|
+
convolution: true,
|
275
|
+
disabled: true,
|
276
|
+
bridge: "{ ...next(operator), operator: operator, reminder: after[0], date: after[1], interpolate: '${reminder} ${date}' }",
|
277
|
+
semantic: async ({context, api, gp, gsp}) => {
|
278
|
+
const text = await gsp(context.reminder.slice(0));
|
279
|
+
const update = { text }
|
280
|
+
if (context.date) {
|
281
|
+
update.dateTimeSelector = context.date
|
282
|
+
update.dateTimeSelectorText = await gp(context.date)
|
283
|
+
}
|
284
|
+
await api.update(update)
|
285
|
+
}
|
286
|
+
},
|
287
|
+
{
|
288
|
+
id: 'remind',
|
289
|
+
isA: ['verb'],
|
290
|
+
localHierarchy: [['self', 'remindable']],
|
291
|
+
bridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], interpolate: '${operator} ${who} ${reminder}' }",
|
292
|
+
justWhoBridge: "{ ...next(operator), bridge: 'justWhoBridge', operator: operator, who: after[0], interpolate: '${operator} ${who}' }",
|
293
|
+
withDateBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], interpolate: '${operator} ${who} ${reminder} ${date}' }",
|
294
|
+
withDateFirstBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[2], date: after[1], interpolate: '${operator} ${who} ${date} ${reminder}' }",
|
295
|
+
withDateAndTimeBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], time: after[3], interpolate: '${operator} ${who} ${reminder} ${date} ${time}' }",
|
296
|
+
semantics: [
|
297
|
+
{
|
298
|
+
match: ({context}) => context.marker == 'remind' && context.inAddition,
|
299
|
+
apply: ({context, api}) => {
|
300
|
+
api.addUser(api.contextToWho(context.who))
|
301
|
+
}
|
302
|
+
},
|
303
|
+
],
|
304
|
+
semantic: async ({ask, api, gsp, gp, context}) => {
|
305
|
+
const who = api.contextToWho(context.who)
|
306
|
+
let text;
|
307
|
+
if (context.reminder) {
|
308
|
+
text = await gsp(context.reminder.slice(1));
|
309
|
+
}
|
310
|
+
const reminder = { text, dateTimeSelector: context.date, who }
|
311
|
+
if (context.date) {
|
312
|
+
reminder.dateTimeSelector = context.date
|
313
|
+
reminder.dateTimeSelectorText = await gp(context.date)
|
314
|
+
}
|
315
|
+
// await api.instantiate(reminder)
|
316
|
+
await api.add(reminder)
|
317
|
+
reminder.cleanUp = ask([
|
318
|
+
query('missingReminder', reminder.id),
|
319
|
+
query('missingDate', reminder.id),
|
320
|
+
])
|
321
|
+
},
|
322
|
+
},
|
323
|
+
{
|
324
|
+
id: 'reminders',
|
325
|
+
isA: ['noun'],
|
326
|
+
},
|
327
|
+
{
|
328
|
+
id: 'show',
|
329
|
+
isA: ['verb'],
|
330
|
+
bridge: "{ ...next(operator), operator: operator, reminders: after[0], interpolate: '${operator} ${reminders}' }",
|
331
|
+
semantic: ({context, api, verbatim}) => {
|
332
|
+
verbatim(api.show())
|
333
|
+
}
|
334
|
+
},
|
335
|
+
{
|
336
|
+
id: 'delete_reminders',
|
337
|
+
isA: ['verb'],
|
338
|
+
bridge: "{ ...next(operator), operator: operator, reminders: after[0], interpolate: '${operator} ${reminders}' }",
|
339
|
+
semantic: ({context, api, verbatim}) => {
|
340
|
+
const s = api.delete_reminder(context.reminders.value)
|
341
|
+
if (s) {
|
342
|
+
verbatim(s)
|
343
|
+
}
|
344
|
+
}
|
345
|
+
},
|
346
|
+
]
|
347
|
+
},
|
348
|
+
/*
|
349
|
+
({ask, api}) => {
|
350
|
+
ask([
|
351
|
+
query('missingReminder'),
|
352
|
+
query('missingDate'),
|
353
|
+
])
|
354
|
+
}
|
355
|
+
*/
|
356
|
+
],
|
357
|
+
}
|
358
|
+
|
359
|
+
knowledgeModule( {
|
360
|
+
config: { name: 'reminders' },
|
361
|
+
includes: [dateTimeSelectors, selfKM],
|
362
|
+
api: () => new API(),
|
363
|
+
|
364
|
+
module,
|
365
|
+
description: 'talking about reminders',
|
366
|
+
test: {
|
367
|
+
name: './reminders.test.json',
|
368
|
+
contents: reminders_tests,
|
369
|
+
checks: {
|
370
|
+
context: [defaultContextCheck({ extra: ['who', 'reminder'] })],
|
371
|
+
objects: [
|
372
|
+
{
|
373
|
+
property: 'reminders',
|
374
|
+
filter: [
|
375
|
+
'text',
|
376
|
+
'dateTimeSelectorText',
|
377
|
+
'nextISODate',
|
378
|
+
'who',
|
379
|
+
'stm',
|
380
|
+
{
|
381
|
+
property: 'dateTimeSelector',
|
382
|
+
filter: ['marker', 'text', 'value'],
|
383
|
+
},
|
384
|
+
],
|
385
|
+
}
|
386
|
+
],
|
387
|
+
},
|
388
|
+
},
|
389
|
+
template: {
|
390
|
+
template,
|
391
|
+
instance: reminders_instance,
|
392
|
+
},
|
393
|
+
|
394
|
+
})
|