tpmkms_4wp 9.3.0-beta.31 → 9.3.0-beta.32
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/asking.js +18 -4
- package/common/colors.instance.json +0 -28
- package/common/crew.instance.json +36 -36
- package/common/dateTimeSelectors.instance.json +1 -1
- package/common/dates.instance.json +0 -84
- package/common/dialogues.js +0 -41
- package/common/edible.instance.json +0 -56
- package/common/fastfood.instance.json +0 -348
- package/common/people.instance.json +36 -0
- package/common/pipboy.instance.json +0 -56
- package/common/reminders.instance.json +86 -20
- package/common/reminders.js +83 -46
- package/common/reminders.test.json +1809 -0
- package/common/reports.instance.json +1 -1
- package/common/wp.instance.json +0 -56
- package/package.json +2 -2
@@ -7,24 +7,58 @@
|
|
7
7
|
"pattern": "([addRemindable] (word)*)",
|
8
8
|
"development": true
|
9
9
|
},
|
10
|
-
"([remind] (remindable/*)
|
11
|
-
"([remind
|
12
|
-
"([remind:
|
10
|
+
"([remind:justWhoBridge] (remindable/*))",
|
11
|
+
"([remind] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')*)",
|
12
|
+
"([remind:withDateBridge] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')* (dateTimeSelector))",
|
13
|
+
"([remind:withDateAndTimeBridge] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')* (dateTimeSelector) (atTime))",
|
13
14
|
"([show] ([reminders]))",
|
14
|
-
"([delete_reminders|delete,cancel] (number/*))"
|
15
|
+
"([delete_reminders|delete,cancel] (number/*))",
|
16
|
+
"([add] (remindable/*))",
|
17
|
+
"([remove|] (remindable/*))",
|
18
|
+
"((verb/*) [inAddition|also,too])"
|
15
19
|
],
|
16
20
|
"bridges": [
|
21
|
+
{
|
22
|
+
"id": "inAddition",
|
23
|
+
"after": [
|
24
|
+
"verb"
|
25
|
+
],
|
26
|
+
"bridge": "{ ...before[0], inAddition: true, verb: before[0], operator: operator, interpolate: '${verb} ${operator}' }"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"id": "add",
|
30
|
+
"isA": [
|
31
|
+
"verb"
|
32
|
+
],
|
33
|
+
"bridge": "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
34
|
+
"semantic": "({api, context}) => {\n api.addUser(api.contextToWho(context.arg))\n }"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"id": "remove",
|
38
|
+
"words": [
|
39
|
+
"delete",
|
40
|
+
"remove"
|
41
|
+
],
|
42
|
+
"isA": [
|
43
|
+
"verb"
|
44
|
+
],
|
45
|
+
"bridge": "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
46
|
+
"semantic": "({api, context}) => {\n api.removeUser(api.contextToWho(context.arg))\n }"
|
47
|
+
},
|
17
48
|
{
|
18
49
|
"id": "addRemindable",
|
19
50
|
"isA": [
|
20
51
|
"verb"
|
21
52
|
],
|
22
53
|
"development": true,
|
23
|
-
"bridge": "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
54
|
+
"bridge": "{ ...next(operator), flatten: true, arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }",
|
24
55
|
"semantic": "({api, context}) => {\n const name = context.arg.map( (word) => word.text ).join(' ')\n api.addRemindable(name)\n }"
|
25
56
|
},
|
26
57
|
{
|
27
|
-
"id": "remindable"
|
58
|
+
"id": "remindable",
|
59
|
+
"isA": [
|
60
|
+
"listable"
|
61
|
+
]
|
28
62
|
},
|
29
63
|
{
|
30
64
|
"id": "remind",
|
@@ -38,9 +72,11 @@
|
|
38
72
|
]
|
39
73
|
],
|
40
74
|
"bridge": "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], interpolate: '${operator} ${who} ${reminder}' }",
|
75
|
+
"justWhoBridge": "{ ...next(operator), bridge: 'justWhoBridge', operator: operator, who: after[0], interpolate: '${operator} ${who}' }",
|
41
76
|
"withDateBridge": "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], interpolate: '${operator} ${who} ${reminder} ${date}' }",
|
42
77
|
"withDateAndTimeBridge": "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], time: after[3], interpolate: '${operator} ${who} ${reminder} ${date} ${time}' }",
|
43
|
-
"
|
78
|
+
"semantics": "[object Object]",
|
79
|
+
"semantic": "async ({ask, api, gsp, gp, context}) => {\n const who = api.contextToWho(context.who)\n let text;\n if (context.reminder) {\n text = await gsp(context.reminder.slice(1));\n }\n const reminder = { text, dateTimeSelector: context.date, who }\n if (context.date) {\n reminder.dateTimeSelector = context.date\n reminder.dateTimeSelectorText = await gp(context.date)\n }\n // await api.instantiate(reminder)\n await api.add(reminder)\n ask([\n query('missingReminder', reminder),\n query('missingDate', reminder),\n ])\n }"
|
44
80
|
},
|
45
81
|
{
|
46
82
|
"id": "reminders",
|
@@ -65,9 +101,6 @@
|
|
65
101
|
"semantic": "({context, api, verbatim}) => {\n const s = api.delete_reminder(context.reminders.value)\n if (s) {\n verbatim(s)\n }\n }"
|
66
102
|
}
|
67
103
|
]
|
68
|
-
},
|
69
|
-
{
|
70
|
-
"apply": "({ask, api}) => {\n ask([\n {\n where: where(),\n oneShot: false,\n onNevermind: ({verbatim, ...args}) => {\n // this is cross km boundaries from the dialogues km to this one so the api if for dialogs.\n // i need to get the one for fastfood here.\n const api = args.kms.fastfood.api\n const needsDrink = askAbout({ args, api })\n for (const item of needsDrink) {\n api.remove(item)\n }\n },\n\n matchq: ({ api, context }) => api.askAbout().length > 0 && context.marker == 'controlEnd',\n applyq: ({ api, context }) => {\n context.cascade = false\n const items = api.askAbout()\n const item = items[0]\n return 'When should I remind you to ' + item.text;\n },\n\n matchr: ({ isA, api, context }) => {\n if ((isA(context.marker, 'onDateValue_dates') || isA(context.marker, 'dateTimeSelector')) && api.askAbout().length > 0) {\n return true\n }\n return false\n },\n applyr: async ({ context, api, gp }) => {\n const items = api.askAbout()\n await api.update({ id: items[0].id, dateTimeSelector: context, dateTimeSelectorText: await gp(context) })\n }\n },\n ])\n }"
|
71
104
|
}
|
72
105
|
],
|
73
106
|
"resultss": [
|
@@ -79,23 +112,55 @@
|
|
79
112
|
"pattern": "([addRemindable] (word)*)",
|
80
113
|
"development": true
|
81
114
|
},
|
82
|
-
"([remind] (remindable/*)
|
83
|
-
"([remind
|
84
|
-
"([remind:
|
115
|
+
"([remind:justWhoBridge] (remindable/*))",
|
116
|
+
"([remind] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')*)",
|
117
|
+
"([remind:withDateBridge] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')* (dateTimeSelector))",
|
118
|
+
"([remind:withDateAndTimeBridge] (remindable/*) (!@<= 'dateTimeSelector' && !@<= 'inAddition')* (dateTimeSelector) (atTime))",
|
85
119
|
"([show] ([reminders]))",
|
86
|
-
"([delete_reminders|delete,cancel] (number/*))"
|
120
|
+
"([delete_reminders|delete,cancel] (number/*))",
|
121
|
+
"([add] (remindable/*))",
|
122
|
+
"([remove|] (remindable/*))",
|
123
|
+
"((verb/*) [inAddition|also,too])"
|
87
124
|
],
|
88
125
|
"bridges": [
|
126
|
+
{
|
127
|
+
"id": "inAddition",
|
128
|
+
"after": [
|
129
|
+
"verb"
|
130
|
+
],
|
131
|
+
"bridge": "{ ...before[0], inAddition: true, verb: before[0], operator: operator, interpolate: '${verb} ${operator}' }"
|
132
|
+
},
|
133
|
+
{
|
134
|
+
"id": "add",
|
135
|
+
"isA": [
|
136
|
+
"verb"
|
137
|
+
],
|
138
|
+
"bridge": "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }"
|
139
|
+
},
|
140
|
+
{
|
141
|
+
"id": "remove",
|
142
|
+
"words": [
|
143
|
+
"delete",
|
144
|
+
"remove"
|
145
|
+
],
|
146
|
+
"isA": [
|
147
|
+
"verb"
|
148
|
+
],
|
149
|
+
"bridge": "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }"
|
150
|
+
},
|
89
151
|
{
|
90
152
|
"id": "addRemindable",
|
91
153
|
"isA": [
|
92
154
|
"verb"
|
93
155
|
],
|
94
156
|
"development": true,
|
95
|
-
"bridge": "{ ...next(operator), arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }"
|
157
|
+
"bridge": "{ ...next(operator), flatten: true, arg: after[0], operator: operator, interpolate: '${operator} ${arg}' }"
|
96
158
|
},
|
97
159
|
{
|
98
|
-
"id": "remindable"
|
160
|
+
"id": "remindable",
|
161
|
+
"isA": [
|
162
|
+
"listable"
|
163
|
+
]
|
99
164
|
},
|
100
165
|
{
|
101
166
|
"id": "remind",
|
@@ -109,8 +174,12 @@
|
|
109
174
|
]
|
110
175
|
],
|
111
176
|
"bridge": "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], interpolate: '${operator} ${who} ${reminder}' }",
|
177
|
+
"justWhoBridge": "{ ...next(operator), bridge: 'justWhoBridge', operator: operator, who: after[0], interpolate: '${operator} ${who}' }",
|
112
178
|
"withDateBridge": "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], interpolate: '${operator} ${who} ${reminder} ${date}' }",
|
113
|
-
"withDateAndTimeBridge": "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], time: after[3], interpolate: '${operator} ${who} ${reminder} ${date} ${time}' }"
|
179
|
+
"withDateAndTimeBridge": "{ ...next(operator), operator: operator, who: after[0], reminder: after[1], date: after[2], time: after[3], interpolate: '${operator} ${who} ${reminder} ${date} ${time}' }",
|
180
|
+
"semantics": [
|
181
|
+
{}
|
182
|
+
]
|
114
183
|
},
|
115
184
|
{
|
116
185
|
"id": "reminders",
|
@@ -133,9 +202,6 @@
|
|
133
202
|
"bridge": "{ ...next(operator), operator: operator, reminders: after[0], interpolate: '${operator} ${reminders}' }"
|
134
203
|
}
|
135
204
|
]
|
136
|
-
},
|
137
|
-
{
|
138
|
-
"apply": "({ask, api}) => {\n ask([\n {\n where: where(),\n oneShot: false,\n onNevermind: ({verbatim, ...args}) => {\n // this is cross km boundaries from the dialogues km to this one so the api if for dialogs.\n // i need to get the one for fastfood here.\n const api = args.kms.fastfood.api\n const needsDrink = askAbout({ args, api })\n for (const item of needsDrink) {\n api.remove(item)\n }\n },\n\n matchq: ({ api, context }) => api.askAbout().length > 0 && context.marker == 'controlEnd',\n applyq: ({ api, context }) => {\n context.cascade = false\n const items = api.askAbout()\n const item = items[0]\n return 'When should I remind you to ' + item.text;\n },\n\n matchr: ({ isA, api, context }) => {\n if ((isA(context.marker, 'onDateValue_dates') || isA(context.marker, 'dateTimeSelector')) && api.askAbout().length > 0) {\n return true\n }\n return false\n },\n applyr: async ({ context, api, gp }) => {\n const items = api.askAbout()\n await api.update({ id: items[0].id, dateTimeSelector: context, dateTimeSelectorText: await gp(context) })\n }\n },\n ])\n }"
|
139
205
|
}
|
140
206
|
],
|
141
207
|
"fragments": [],
|
package/common/reminders.js
CHANGED
@@ -16,6 +16,54 @@ const helpers = require('./helpers')
|
|
16
16
|
remind every truck driver to whatever tomorrow at 8 am
|
17
17
|
*/
|
18
18
|
|
19
|
+
const query = (missing, reminder) => {
|
20
|
+
return {
|
21
|
+
where: where(),
|
22
|
+
// oneShot: false,
|
23
|
+
onNevermind: ({verbatim, ...args}) => {
|
24
|
+
const api = args.kms.reminders.api
|
25
|
+
api.delete_reminder(reminder.id)
|
26
|
+
},
|
27
|
+
|
28
|
+
matchq: ({ api, context }) => api.missing(missing, reminder) && context.marker == 'controlEnd',
|
29
|
+
applyq: async ({ api, context, gs }) => {
|
30
|
+
context.cascade = false
|
31
|
+
const item = api.missing(missing, reminder)
|
32
|
+
let who
|
33
|
+
if (Array.isArray(item.who)) {
|
34
|
+
who = await gs(item.who.map((who) => who.text), ', ', ' and ')
|
35
|
+
} else {
|
36
|
+
if (item.who.text == 'me') {
|
37
|
+
who = 'you'
|
38
|
+
} else {
|
39
|
+
who = item.who.text
|
40
|
+
}
|
41
|
+
}
|
42
|
+
if (item.missingDate) {
|
43
|
+
return `When should I remind ${who} to ${item.text}`
|
44
|
+
}
|
45
|
+
if (item.missingReminder) {
|
46
|
+
return `What should I remind ${who} to do?`
|
47
|
+
}
|
48
|
+
},
|
49
|
+
|
50
|
+
matchr: ({ isA, api, context }) => {
|
51
|
+
const gotADate = ((isA(context.marker, 'onDateValue_dates') || isA(context.marker, 'dateTimeSelector')) && api.missing(missing, reminder))
|
52
|
+
if (missing == 'missingDate') {
|
53
|
+
return gotADate
|
54
|
+
} else {
|
55
|
+
// debugger
|
56
|
+
// return !gotADate && !context.isControl
|
57
|
+
}
|
58
|
+
return false
|
59
|
+
},
|
60
|
+
applyr: async ({ context, api, gp }) => {
|
61
|
+
const item = api.missing(missing, reminder)
|
62
|
+
await api.update({ id: item.id, dateTimeSelector: context, dateTimeSelectorText: await gp(context) })
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
19
67
|
class API {
|
20
68
|
initialize({ objects }) {
|
21
69
|
this._objects = objects
|
@@ -84,11 +132,23 @@ class API {
|
|
84
132
|
getCurrent() {
|
85
133
|
}
|
86
134
|
|
87
|
-
|
135
|
+
missing(what, reminder) {
|
136
|
+
if (what == 'missingReminder' && !reminder.text) {
|
137
|
+
return { when: true, who: reminder.who, text: reminder.text, id: reminder.id, missingReminder: true }
|
138
|
+
}
|
139
|
+
if (what == 'missingDate' && !reminder.dateTimeSelector) {
|
140
|
+
return { when: true, who: reminder.who, text: reminder.text, id: reminder.id, missingDate: true }
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
askAbout(what) {
|
88
145
|
const items = []
|
89
146
|
for (const item of this._objects.reminders) {
|
90
|
-
if (
|
91
|
-
items.push(
|
147
|
+
if (this.missing('missingReminder', item)) {
|
148
|
+
items.push(this.missing('missingReminder', item))
|
149
|
+
}
|
150
|
+
if (this.missing('missingDate', item)) {
|
151
|
+
items.push(this.missing('missingDate', item))
|
92
152
|
}
|
93
153
|
}
|
94
154
|
return items
|
@@ -108,12 +168,23 @@ class API {
|
|
108
168
|
// -> return a table object. then have ability to talk about the table. maybe later let's focus on this for now
|
109
169
|
}
|
110
170
|
|
171
|
+
/*
|
111
172
|
delete_reminder(ordinal) {
|
112
173
|
if (ordinal < 1 || ordinal > this._objects.reminders.length) {
|
113
174
|
return `Not possible`
|
114
175
|
}
|
115
176
|
this._objects.reminders = this._objects.reminders.splice(ordinal, 1)
|
116
177
|
}
|
178
|
+
*/
|
179
|
+
delete_reminder(id) {
|
180
|
+
const reminder = this._objects.reminders.find((reminder) => reminder.id)
|
181
|
+
if (reminder) {
|
182
|
+
if (reminder.cleanUp) {
|
183
|
+
reminder.cleanUp()
|
184
|
+
}
|
185
|
+
this._objects.reminders = this._objects.reminders.filter((reminder) => reminder.id != id)
|
186
|
+
}
|
187
|
+
}
|
117
188
|
|
118
189
|
async update(update) {
|
119
190
|
for (const item of this._objects.reminders) {
|
@@ -198,7 +269,7 @@ const template = {
|
|
198
269
|
}
|
199
270
|
},
|
200
271
|
],
|
201
|
-
semantic: async ({api, gsp, gp, context}) => {
|
272
|
+
semantic: async ({ask, api, gsp, gp, context}) => {
|
202
273
|
const who = api.contextToWho(context.who)
|
203
274
|
let text;
|
204
275
|
if (context.reminder) {
|
@@ -211,6 +282,10 @@ const template = {
|
|
211
282
|
}
|
212
283
|
// await api.instantiate(reminder)
|
213
284
|
await api.add(reminder)
|
285
|
+
reminder.cleanUp = ask([
|
286
|
+
query('missingReminder', reminder),
|
287
|
+
query('missingDate', reminder),
|
288
|
+
])
|
214
289
|
},
|
215
290
|
},
|
216
291
|
{
|
@@ -238,52 +313,14 @@ const template = {
|
|
238
313
|
},
|
239
314
|
]
|
240
315
|
},
|
316
|
+
/*
|
241
317
|
({ask, api}) => {
|
242
318
|
ask([
|
243
|
-
|
244
|
-
|
245
|
-
oneShot: false,
|
246
|
-
onNevermind: ({verbatim, ...args}) => {
|
247
|
-
// this is cross km boundaries from the dialogues km to this one so the api if for dialogs.
|
248
|
-
// i need to get the one for fastfood here.
|
249
|
-
const api = args.kms.fastfood.api
|
250
|
-
const needsDrink = askAbout({ args, api })
|
251
|
-
for (const item of needsDrink) {
|
252
|
-
api.remove(item)
|
253
|
-
}
|
254
|
-
},
|
255
|
-
|
256
|
-
matchq: ({ api, context }) => api.askAbout().length > 0 && context.marker == 'controlEnd',
|
257
|
-
applyq: async ({ api, context, gs }) => {
|
258
|
-
context.cascade = false
|
259
|
-
const items = api.askAbout()
|
260
|
-
const item = items[0]
|
261
|
-
let who
|
262
|
-
if (Array.isArray(item.who)) {
|
263
|
-
who = await gs(item.who.map((who) => who.text), ', ', ' and ')
|
264
|
-
} else {
|
265
|
-
if (item.who.text == 'me') {
|
266
|
-
who = 'you'
|
267
|
-
} else {
|
268
|
-
who = item.who.text
|
269
|
-
}
|
270
|
-
}
|
271
|
-
return `When should I remind ${who} to ${item.text}`
|
272
|
-
},
|
273
|
-
|
274
|
-
matchr: ({ isA, api, context }) => {
|
275
|
-
if ((isA(context.marker, 'onDateValue_dates') || isA(context.marker, 'dateTimeSelector')) && api.askAbout().length > 0) {
|
276
|
-
return true
|
277
|
-
}
|
278
|
-
return false
|
279
|
-
},
|
280
|
-
applyr: async ({ context, api, gp }) => {
|
281
|
-
const items = api.askAbout()
|
282
|
-
await api.update({ id: items[0].id, dateTimeSelector: context, dateTimeSelectorText: await gp(context) })
|
283
|
-
}
|
284
|
-
},
|
319
|
+
query('missingReminder'),
|
320
|
+
query('missingDate'),
|
285
321
|
])
|
286
322
|
}
|
323
|
+
*/
|
287
324
|
],
|
288
325
|
}
|
289
326
|
|