tpmkms_4wp 9.3.0-beta.5 → 9.3.0-beta.51
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/asking.js +16 -2
- package/common/colors.instance.json +28 -70
- package/common/comparable.instance.json +0 -15
- package/common/concept.test.json +279 -193
- package/common/crew.instance.json +0 -166
- package/common/dateTimeSelectors.instance.json +151 -0
- package/common/dateTimeSelectors.js +171 -0
- package/common/dateTimeSelectors.test.json +85622 -0
- package/common/dates.instance.json +285 -479
- package/common/dates.js +111 -10
- package/common/dates.test.json +11021 -514
- package/common/dialogues.js +8 -46
- package/common/dimension.instance.json +0 -5
- package/common/edible.instance.json +56 -160
- package/common/emotions.instance.json +0 -5
- package/common/evaluate.js +1 -1
- package/common/events.js +1 -1
- package/common/fastfood.instance.json +149 -880
- package/common/fastfood.test.json +16291 -6597
- package/common/formulas.instance.json +0 -5
- 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 +57 -32
- package/common/hierarchy.js +9 -9
- package/common/kirk.instance.json +0 -5
- package/common/length.instance.json +0 -75
- package/common/math.instance.json +0 -5
- package/common/menus.instance.json +0 -35
- package/common/meta.js +2 -2
- package/common/numbers.js +1 -1
- package/common/numbers.test.json +89 -23
- package/common/ordering.instance.json +0 -10
- package/common/people.instance.json +36 -40
- package/common/percentages.js +1 -1
- package/common/pipboy.instance.json +56 -85
- package/common/pipboy.test.json +4377 -3386
- package/common/pokemon.instance.json +0 -65
- package/common/pressure.instance.json +0 -20
- package/common/properties.instance.json +0 -5
- package/common/properties.js +4 -4
- package/common/reminders.instance.json +196 -10
- package/common/reminders.js +273 -79
- package/common/reminders.test.json +71435 -23
- package/common/reports.instance.json +2 -12
- package/common/scorekeeper.test.json +3565 -7550
- package/common/spock.instance.json +0 -5
- package/common/temperature.instance.json +112 -20
- package/common/time.js +63 -30
- package/common/time.test.json +4124 -124
- package/common/ui.instance.json +0 -5
- package/common/ui.js +3 -1
- package/common/weight.instance.json +0 -60
- package/common/wp.instance.json +56 -70
- package/common/wp.test.json +8057 -3867
- package/main.js +2 -0
- package/package.json +8 -4
package/common/reminders.js
CHANGED
@@ -3,38 +3,182 @@ const { defaultContextCheck } = require('./helpers')
|
|
3
3
|
const reminders_tests = require('./reminders.test.json')
|
4
4
|
const reminders_instance = require('./reminders.instance.json')
|
5
5
|
const selfKM = require('./self')
|
6
|
-
const
|
6
|
+
const dateTimeSelectors = require('./dateTimeSelectors')
|
7
7
|
const helpers = require('./helpers')
|
8
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
|
+
|
9
72
|
class API {
|
10
73
|
initialize({ objects }) {
|
11
74
|
this._objects = objects
|
12
75
|
this._objects.reminders = []
|
13
76
|
this._objects.id = 0
|
77
|
+
this._objects.current = null
|
78
|
+
this._objects.defaultTime = { hour: 9, minute: 0, second: 0, millisecond: 0 }
|
14
79
|
}
|
15
80
|
|
16
|
-
add(reminder) {
|
81
|
+
async add(reminder) {
|
82
|
+
await this.instantiate(reminder)
|
17
83
|
const id = ++this._objects.id
|
18
|
-
|
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
|
19
160
|
}
|
20
161
|
|
21
|
-
askAbout() {
|
162
|
+
askAbout(what) {
|
22
163
|
const items = []
|
23
|
-
for (const item of this.
|
24
|
-
if (
|
25
|
-
items.push(
|
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))
|
26
170
|
}
|
27
171
|
}
|
28
172
|
return items
|
29
173
|
}
|
30
174
|
|
31
175
|
show() {
|
32
|
-
if (this.
|
176
|
+
if (this.reminders().length == 0) {
|
33
177
|
return "There are no reminders"
|
34
178
|
}
|
35
179
|
let s = 'The reminders are\n'
|
36
180
|
let counter = 1
|
37
|
-
for (const item of this.
|
181
|
+
for (const item of this.reminders()) {
|
38
182
|
s += ` ${counter}. ${item.text}\n`
|
39
183
|
counter += 1
|
40
184
|
}
|
@@ -42,21 +186,27 @@ class API {
|
|
42
186
|
// -> return a table object. then have ability to talk about the table. maybe later let's focus on this for now
|
43
187
|
}
|
44
188
|
|
45
|
-
delete_reminder(
|
46
|
-
|
47
|
-
|
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))
|
48
196
|
}
|
49
|
-
this._objects.reminders = this._objects.reminders.splice(ordinal, 1)
|
50
197
|
}
|
51
198
|
|
52
|
-
update(update) {
|
199
|
+
async update(update) {
|
200
|
+
if (!update.id) {
|
201
|
+
update.id = this.getCurrentId()
|
202
|
+
}
|
53
203
|
for (const item of this._objects.reminders) {
|
54
204
|
if (item.id == update.id) {
|
55
205
|
Object.assign(item, update)
|
206
|
+
await this.instantiate(item)
|
56
207
|
return
|
57
208
|
}
|
58
209
|
}
|
59
|
-
|
60
210
|
}
|
61
211
|
}
|
62
212
|
|
@@ -67,26 +217,106 @@ const template = {
|
|
67
217
|
configs: [
|
68
218
|
{
|
69
219
|
operators: [
|
70
|
-
"([
|
71
|
-
"([
|
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:withDateAndTimeBridge] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')* (dateTimeSelector) (atTime))",
|
226
|
+
"([remindResponse] (!@<= 'remindResponse' && !@<= 'dateTimeSelector' && !@<= 'inAddition')+ (dateTimeSelector))",
|
72
227
|
"([show] ([reminders]))",
|
73
228
|
"([delete_reminders|delete,cancel] (number/*))",
|
229
|
+
"([add] (remindable/*))",
|
230
|
+
"([remove|] (remindable/*))",
|
231
|
+
"((verb/*) [inAddition|also,too])",
|
74
232
|
],
|
75
233
|
bridges: [
|
76
234
|
{
|
77
|
-
id: '
|
235
|
+
id: 'inAddition',
|
236
|
+
after: ['verb'],
|
237
|
+
bridge: "{ ...before[0], inAddition: true, verb: before[0], operator: operator, interpolate: '${verb} ${operator}' }",
|
238
|
+
},
|
239
|
+
{
|
240
|
+
id: 'add',
|
78
241
|
isA: ['verb'],
|
79
|
-
bridge: "{ ...next(operator),
|
80
|
-
semantic:
|
81
|
-
|
82
|
-
|
83
|
-
},
|
242
|
+
bridge: "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
243
|
+
semantic: ({api, context}) => {
|
244
|
+
api.addUser(api.contextToWho(context.arg))
|
245
|
+
}
|
84
246
|
},
|
85
247
|
{
|
86
|
-
id: '
|
87
|
-
|
88
|
-
|
248
|
+
id: 'remove',
|
249
|
+
words: ['delete', 'remove'],
|
250
|
+
isA: ['verb'],
|
251
|
+
bridge: "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
252
|
+
semantic: ({api, context}) => {
|
253
|
+
api.removeUser(api.contextToWho(context.arg))
|
254
|
+
}
|
255
|
+
},
|
256
|
+
{
|
257
|
+
id: 'addRemindable',
|
258
|
+
isA: ['verb'],
|
259
|
+
development: true,
|
260
|
+
bridge: "{ ...next(operator), flatten: true, arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
261
|
+
semantic: async ({api, context}) => {
|
262
|
+
const name = context.arg.map( (word) => word.text ).join(' ')
|
263
|
+
await api.addRemindable(name)
|
264
|
+
}
|
265
|
+
},
|
266
|
+
{
|
267
|
+
id: 'remindable',
|
268
|
+
isA: ['listable'],
|
269
|
+
},
|
270
|
+
{
|
271
|
+
id: 'remindResponse',
|
272
|
+
isA: ['verb'],
|
273
|
+
convolution: true,
|
274
|
+
disabled: true,
|
275
|
+
bridge: "{ ...next(operator), operator: operator, reminder: after[0], date: after[1], interpolate: '${reminder} ${date}' }",
|
276
|
+
semantic: async ({context, api, gp, gsp}) => {
|
277
|
+
const text = await gsp(context.reminder.slice(0));
|
278
|
+
const update = { text }
|
279
|
+
if (context.date) {
|
280
|
+
update.dateTimeSelector = context.date
|
281
|
+
update.dateTimeSelectorText = await gp(context.date)
|
282
|
+
}
|
283
|
+
await api.update(update)
|
284
|
+
}
|
285
|
+
},
|
286
|
+
{
|
287
|
+
id: 'remind',
|
288
|
+
isA: ['verb'],
|
289
|
+
localHierarchy: [['self', 'remindable']],
|
290
|
+
bridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], interpolate: '${operator} ${who} ${reminder}' }",
|
291
|
+
justWhoBridge: "{ ...next(operator), bridge: 'justWhoBridge', operator: operator, who: after[0], interpolate: '${operator} ${who}' }",
|
292
|
+
withDateBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], interpolate: '${operator} ${who} ${reminder} ${date}' }",
|
293
|
+
withDateAndTimeBridge: "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], time: after[3], interpolate: '${operator} ${who} ${reminder} ${date} ${time}' }",
|
294
|
+
semantics: [
|
295
|
+
{
|
296
|
+
match: ({context}) => context.marker == 'remind' && context.inAddition,
|
297
|
+
apply: ({context, api}) => {
|
298
|
+
api.addUser(api.contextToWho(context.who))
|
299
|
+
}
|
300
|
+
},
|
89
301
|
],
|
302
|
+
semantic: async ({ask, api, gsp, gp, context}) => {
|
303
|
+
const who = api.contextToWho(context.who)
|
304
|
+
let text;
|
305
|
+
if (context.reminder) {
|
306
|
+
text = await gsp(context.reminder.slice(1));
|
307
|
+
}
|
308
|
+
const reminder = { text, dateTimeSelector: context.date, who }
|
309
|
+
if (context.date) {
|
310
|
+
reminder.dateTimeSelector = context.date
|
311
|
+
reminder.dateTimeSelectorText = await gp(context.date)
|
312
|
+
}
|
313
|
+
// await api.instantiate(reminder)
|
314
|
+
await api.add(reminder)
|
315
|
+
reminder.cleanUp = ask([
|
316
|
+
query('missingReminder', reminder.id),
|
317
|
+
query('missingDate', reminder.id),
|
318
|
+
])
|
319
|
+
},
|
90
320
|
},
|
91
321
|
{
|
92
322
|
id: 'reminders',
|
@@ -113,66 +343,20 @@ const template = {
|
|
113
343
|
},
|
114
344
|
]
|
115
345
|
},
|
346
|
+
/*
|
116
347
|
({ask, api}) => {
|
117
348
|
ask([
|
118
|
-
|
119
|
-
|
120
|
-
oneShot: false,
|
121
|
-
onNevermind: ({verbatim, ...args}) => {
|
122
|
-
// this is cross km boundaries from the dialogues km to this one so the api if for dialogs.
|
123
|
-
// i need to get the one for fastfood here.
|
124
|
-
const api = args.kms.fastfood.api
|
125
|
-
const needsDrink = askAbout({ args, api })
|
126
|
-
for (const item of needsDrink) {
|
127
|
-
api.remove(item)
|
128
|
-
}
|
129
|
-
},
|
130
|
-
|
131
|
-
matchq: ({ api, context }) => api.askAbout().length > 0 && context.marker == 'controlEnd',
|
132
|
-
applyq: ({ api, context }) => {
|
133
|
-
context.cascade = false
|
134
|
-
const items = api.askAbout()
|
135
|
-
const item = items[0]
|
136
|
-
return 'When should I remind you to ' + item.text;
|
137
|
-
},
|
138
|
-
|
139
|
-
matchr: ({ isA, api, context }) => {
|
140
|
-
if (isA(context.marker, 'reminderTime') && api.askAbout().length > 0) {
|
141
|
-
return true
|
142
|
-
}
|
143
|
-
return false
|
144
|
-
},
|
145
|
-
applyr: ({ context, api }) => {
|
146
|
-
const items = api.askAbout()
|
147
|
-
api.update({ id: items[0].id, when: context })
|
148
|
-
// TODO check for is available for all modifications
|
149
|
-
/*
|
150
|
-
const needsDrink = askAbout(args)
|
151
|
-
const { api, context } = args
|
152
|
-
if (isMany(context)) {
|
153
|
-
let count = getCount(context) || Number.MAX_SAFE_INTEGER
|
154
|
-
for (const item of needsDrink) {
|
155
|
-
if (count < 1) {
|
156
|
-
break
|
157
|
-
}
|
158
|
-
count -= 1
|
159
|
-
api.addDrink(item.item_id, { id: context.value })
|
160
|
-
}
|
161
|
-
} else {
|
162
|
-
const item_id = needsDrink[0].item_id
|
163
|
-
api.addDrink(item_id, { id: context.value })
|
164
|
-
}
|
165
|
-
*/
|
166
|
-
}
|
167
|
-
},
|
349
|
+
query('missingReminder'),
|
350
|
+
query('missingDate'),
|
168
351
|
])
|
169
352
|
}
|
353
|
+
*/
|
170
354
|
],
|
171
355
|
}
|
172
356
|
|
173
357
|
knowledgeModule( {
|
174
358
|
config: { name: 'reminders' },
|
175
|
-
includes: [
|
359
|
+
includes: [dateTimeSelectors, selfKM],
|
176
360
|
api: () => new API(),
|
177
361
|
|
178
362
|
module,
|
@@ -181,11 +365,21 @@ knowledgeModule( {
|
|
181
365
|
name: './reminders.test.json',
|
182
366
|
contents: reminders_tests,
|
183
367
|
checks: {
|
184
|
-
context: defaultContextCheck(['who', 'reminder']),
|
368
|
+
context: defaultContextCheck(['who', 'reminder', 'verbatim']),
|
185
369
|
objects: [
|
186
370
|
{
|
187
371
|
property: 'reminders',
|
188
|
-
filter: [
|
372
|
+
filter: [
|
373
|
+
'text',
|
374
|
+
'dateTimeSelectorText',
|
375
|
+
'nextISODate',
|
376
|
+
'who',
|
377
|
+
'stm',
|
378
|
+
{
|
379
|
+
property: 'dateTimeSelector',
|
380
|
+
filter: ['marker', 'text', 'value'],
|
381
|
+
},
|
382
|
+
],
|
189
383
|
}
|
190
384
|
],
|
191
385
|
},
|