@startsimpli/integrations 0.2.197 → 0.2.201
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/package.json +7 -7
- package/src/__tests__/briefing-actions.test.ts +11 -0
- package/src/__tests__/briefing-edits.test.ts +98 -0
- package/src/__tests__/converse-brain.test.ts +64 -1
- package/src/__tests__/converse-handoff.test.ts +8 -0
- package/src/__tests__/converse-meeting-brief.test.ts +72 -8
- package/src/__tests__/converse-meeting-duplex.test.ts +132 -0
- package/src/__tests__/converse-meeting-keep-speech.test.ts +87 -0
- package/src/__tests__/converse-meeting-vad.test.ts +1 -1
- package/src/__tests__/converse-spoken-form.test.ts +10 -0
- package/src/__tests__/converse-spoken-summary.test.ts +27 -6
- package/src/__tests__/converse.test.ts +29 -2
- package/src/__tests__/corpus-ask-items.test.ts +14 -0
- package/src/__tests__/corpus-ask.test.ts +22 -0
- package/src/__tests__/corpus-tracker.test.tsx +12 -0
- package/src/__tests__/extract-classify.test.ts +17 -0
- package/src/__tests__/fleet-page.test.tsx +57 -0
- package/src/__tests__/fleet-view.test.ts +149 -0
- package/src/__tests__/project-basis-entity.test.ts +19 -0
- package/src/__tests__/project-basis.test.ts +21 -0
- package/src/__tests__/relay-cli.test.ts +10 -1
- package/src/__tests__/spoken-time.test.ts +4 -0
- package/src/__tests__/task-detail-project-guess.test.tsx +46 -0
- package/src/__tests__/voice-due-later-sentence.test.ts +26 -0
- package/src/components/index.ts +2 -0
- package/src/components/pages/FleetPage.tsx +115 -0
- package/src/components/pages/TaskDetailPage.tsx +27 -1
- package/src/components/pages/TrackerPage.tsx +1 -1
- package/src/components/pages/task-tracker/ProjectGuess.tsx +42 -0
- package/src/corpus/ask-items-intent.ts +24 -0
- package/src/corpus/ask-items.ts +7 -4
- package/src/corpus/ask.ts +1 -1
- package/src/corpus/briefing/actions/confirm.ts +9 -1
- package/src/corpus/briefing/actions/execute.ts +71 -11
- package/src/corpus/briefing/actions/log.ts +1 -1
- package/src/corpus/briefing/actions/seam.ts +18 -2
- package/src/corpus/briefing/actions/types.ts +14 -0
- package/src/corpus/briefing/intent/describe.ts +5 -1
- package/src/corpus/briefing/intent/edits.ts +92 -0
- package/src/corpus/briefing/intent/grammar.ts +3 -0
- package/src/corpus/briefing/intent/ground.ts +5 -1
- package/src/corpus/briefing/intent/match.ts +3 -1
- package/src/corpus/briefing/intent/model.ts +36 -3
- package/src/corpus/briefing/intent/resolve.ts +12 -1
- package/src/corpus/briefing/intent/types.ts +8 -0
- package/src/corpus/briefing/speak.ts +13 -0
- package/src/corpus/client.ts +2 -0
- package/src/corpus/converse/brain.ts +41 -13
- package/src/corpus/converse/briefing-queue.ts +105 -27
- package/src/corpus/converse/client.ts +6 -0
- package/src/corpus/converse/fleet-view.ts +126 -0
- package/src/corpus/converse/fleet.ts +18 -5
- package/src/corpus/converse/followups.ts +12 -2
- package/src/corpus/converse/handle.ts +21 -12
- package/src/corpus/converse/handoff.ts +7 -2
- package/src/corpus/converse/index.ts +5 -3
- package/src/corpus/converse/meeting-config.ts +8 -4
- package/src/corpus/converse/meeting.ts +66 -11
- package/src/corpus/converse/respond.ts +14 -2
- package/src/corpus/converse/spoken-form.ts +9 -2
- package/src/corpus/converse/spoken-summary.ts +30 -8
- package/src/corpus/converse/store.ts +2 -0
- package/src/corpus/converse/types.ts +14 -1
- package/src/corpus/entities.ts +2 -0
- package/src/corpus/extract.ts +9 -4
- package/src/corpus/project-basis.ts +23 -0
- package/src/corpus/spoken-time.ts +18 -2
- package/src/corpus/types.ts +6 -0
- package/src/corpus/voice-due.ts +24 -0
- package/src/native/app/converseServices.ts +5 -3
- package/src/native/app/device.ts +2 -0
- package/src/native/converse/ConverseScreen.tsx +28 -0
- package/src/native/converse/__tests__/liveScreen.test.tsx +35 -2
- package/src/native/converse/__tests__/meetingIO.test.ts +55 -1
- package/src/native/converse/format.ts +2 -2
- package/src/native/converse/io.ts +15 -5
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* FLEET (Tandem /fleet, read-only): relay -> project leads -> their sessions, what each is for, and what waits on the
|
|
5
|
+
* person. The data is the relay's synced snapshot (`GET /corpus/converse/fleet-status`), parsed in the package
|
|
6
|
+
* (`buildFleetView`); this only draws it. Re-reads every 30s and says how old the snapshot is.
|
|
7
|
+
*/
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
|
|
10
|
+
import { ageWords, FLEET_FRESH_MS } from '../../corpus/converse/fleet';
|
|
11
|
+
import type { FleetSession, FleetView } from '../../corpus/converse/fleet-view';
|
|
12
|
+
import { LoadError } from '../LoadError';
|
|
13
|
+
|
|
14
|
+
export interface FleetPayload { snapshot: { text: string; updatedAt: string; view: FleetView | null } | null }
|
|
15
|
+
export interface FleetPageProps { load: () => Promise<FleetPayload>; refreshMs?: number }
|
|
16
|
+
|
|
17
|
+
function SessionRow({ s, testId }: { s: FleetSession; testId?: string }) {
|
|
18
|
+
return (
|
|
19
|
+
<div className="flex flex-col gap-0.5 py-2" data-testid={testId}>
|
|
20
|
+
<div className="flex items-center gap-2">
|
|
21
|
+
<span className={`h-2 w-2 shrink-0 rounded-full ${s.status === 'live' ? 'bg-green-500' : 'bg-gray-300'}`} title={s.status} />
|
|
22
|
+
<span className="font-medium text-gray-900">{s.name || s.id}</span>
|
|
23
|
+
<span className="font-mono text-xs text-gray-400">{s.id}</span>
|
|
24
|
+
</div>
|
|
25
|
+
{s.goal ? <p className="pl-4 text-sm text-gray-700">{s.goal}</p> : null}
|
|
26
|
+
{s.repo ? <p className="pl-4 text-xs text-gray-400">{s.repo}{s.branch ? `@${s.branch}` : ''} · {s.machine}</p> : null}
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const Card = ({ title, children, testId, tone = 'border-gray-200 bg-white' }: { title: string; children: React.ReactNode; testId?: string; tone?: string }) => (
|
|
32
|
+
<section className={`rounded-xl border p-4 ${tone}`} data-testid={testId}>
|
|
33
|
+
<h2 className="mb-1 text-sm font-semibold uppercase tracking-wide text-gray-500">{title}</h2>
|
|
34
|
+
{children}
|
|
35
|
+
</section>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
function FleetBody({ view }: { view: FleetView }) {
|
|
39
|
+
return (
|
|
40
|
+
<div className="space-y-4">
|
|
41
|
+
<Card title={`Waiting on you (${view.waitingOnQuinn.length})`} testId="fleet-waiting-quinn" tone="border-amber-300 bg-amber-50">
|
|
42
|
+
{view.waitingOnQuinn.length ? <ul className="list-disc space-y-1 pl-5 text-sm text-gray-900">{view.waitingOnQuinn.map((t) => <li key={t}>{t}</li>)}</ul> : <p className="text-sm text-gray-600">Nothing is waiting on you.</p>}
|
|
43
|
+
{view.loopsUpdated ? <p className="mt-2 text-xs text-gray-500">Ledger updated {view.loopsUpdated}</p> : null}
|
|
44
|
+
</Card>
|
|
45
|
+
{view.relay ? <Card title="Relay" testId="fleet-relay"><SessionRow s={view.relay} /></Card> : null}
|
|
46
|
+
{view.leads.map((l) => (
|
|
47
|
+
<Card key={l.role} title={l.role} testId={`fleet-lead-${l.role}`}>
|
|
48
|
+
{l.session ? <SessionRow s={l.session} /> : <p className="py-2 text-sm text-gray-500">No live session{l.listedId ? ` (notes list ${l.listedId}, which is not on the bridge)` : ''}.</p>}
|
|
49
|
+
{l.session && l.listedId ? <p className="text-xs text-amber-700">Notes list {l.listedId}; this live session matches the role by name.</p> : null}
|
|
50
|
+
{l.notes ? <p className="pb-2 text-xs text-gray-500">{l.notes}</p> : null}
|
|
51
|
+
{l.children.length ? <div className="ml-3 divide-y divide-gray-100 border-l border-gray-200 pl-3">{l.children.map((c) => <SessionRow key={c.id} s={c} />)}</div> : null}
|
|
52
|
+
</Card>
|
|
53
|
+
))}
|
|
54
|
+
{view.waitingOnSessions.length ? (
|
|
55
|
+
<Card title="Relay is waiting on sessions" testId="fleet-waiting-sessions">
|
|
56
|
+
<ul className="list-disc space-y-1 pl-5 text-sm text-gray-800">{view.waitingOnSessions.map((t) => <li key={t}>{t}</li>)}</ul>
|
|
57
|
+
</Card>
|
|
58
|
+
) : null}
|
|
59
|
+
{view.sections?.length ? (
|
|
60
|
+
<Card title="Relay's notes" testId="fleet-sections">
|
|
61
|
+
<div className="space-y-2">
|
|
62
|
+
{view.sections.map((sec) => (
|
|
63
|
+
<details key={sec.title} className="rounded-md border border-gray-100 px-3 py-2">
|
|
64
|
+
<summary className="cursor-pointer text-sm font-medium text-gray-800">{sec.title} <span className="text-xs text-gray-400">({sec.items.length})</span></summary>
|
|
65
|
+
<ul className="mt-2 list-disc space-y-1 pl-5 text-sm text-gray-700">{sec.items.map((t, i) => <li key={i}>{t}</li>)}</ul>
|
|
66
|
+
</details>
|
|
67
|
+
))}
|
|
68
|
+
</div>
|
|
69
|
+
</Card>
|
|
70
|
+
) : null}
|
|
71
|
+
{view.ports?.length ? (
|
|
72
|
+
<Card title="Local stacks" testId="fleet-ports">
|
|
73
|
+
<ul className="divide-y divide-gray-100 text-sm">
|
|
74
|
+
{view.ports.map((p) => (
|
|
75
|
+
<li key={p.project} className="flex flex-wrap items-baseline gap-x-2 py-1.5">
|
|
76
|
+
<span className="font-medium text-gray-900">{p.project}</span>
|
|
77
|
+
{p.url ? <a className="text-indigo-600 underline" href={p.url} target="_blank" rel="noreferrer">{p.url}</a> : <span className="text-gray-500">{p.base}</span>}
|
|
78
|
+
<span className="text-xs text-gray-400">{p.range}{p.notes ? ` · ${p.notes}` : ''}</span>
|
|
79
|
+
</li>
|
|
80
|
+
))}
|
|
81
|
+
</ul>
|
|
82
|
+
</Card>
|
|
83
|
+
) : null}
|
|
84
|
+
{view.unparsed?.length ? (
|
|
85
|
+
<Card title="Other lines in the notes" testId="fleet-unparsed">
|
|
86
|
+
<ul className="space-y-1 text-xs text-gray-600">{view.unparsed.map((t, i) => <li key={i} className="whitespace-pre-wrap">{t}</li>)}</ul>
|
|
87
|
+
</Card>
|
|
88
|
+
) : null}
|
|
89
|
+
{view.others.length ? <Card title={`Other sessions (${view.others.length})`} testId="fleet-others"><div className="divide-y divide-gray-100">{view.others.map((s) => <SessionRow key={s.id} s={s} />)}</div></Card> : null}
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function FleetPage({ load, refreshMs = 30000 }: FleetPageProps) {
|
|
95
|
+
const [data, setData] = React.useState<FleetPayload | undefined>();
|
|
96
|
+
const [error, setError] = React.useState<string | null>(null);
|
|
97
|
+
const [, tick] = React.useState(0);
|
|
98
|
+
const run = React.useCallback(() => { load().then((d) => { setData(d); setError(null); }).catch((e) => setError(e instanceof Error ? e.message : 'Could not load.')); }, [load]);
|
|
99
|
+
React.useEffect(() => { run(); const t = setInterval(() => { run(); tick((n) => n + 1); }, refreshMs); return () => clearInterval(t); }, [run, refreshMs]);
|
|
100
|
+
const snap = data?.snapshot;
|
|
101
|
+
const stale = snap ? Date.now() - Date.parse(snap.updatedAt) > FLEET_FRESH_MS : false;
|
|
102
|
+
return (
|
|
103
|
+
<div className="space-y-4">
|
|
104
|
+
{error ? <LoadError what="the fleet" message={error} onRetry={run} /> : null}
|
|
105
|
+
{data && !snap ? <div className="rounded-xl border border-gray-200 bg-white p-6 text-center" data-testid="fleet-empty"><p className="font-medium text-gray-900">The relay has not posted a fleet snapshot yet.</p></div> : null}
|
|
106
|
+
{snap ? (
|
|
107
|
+
<p className="text-sm text-gray-600" data-testid="fleet-age" data-stale={stale ? 'true' : 'false'}>
|
|
108
|
+
Snapshot from {ageWords(snap.updatedAt, Date.now()) || 'an unknown time'}{stale ? ' — older than 10 minutes, so this is where things stood, not now.' : '.'}
|
|
109
|
+
</p>
|
|
110
|
+
) : null}
|
|
111
|
+
{snap?.view ? <FleetBody view={snap.view} /> : null}
|
|
112
|
+
{snap && !snap.view ? <pre className="whitespace-pre-wrap rounded-xl border border-gray-200 bg-white p-4 text-sm text-gray-800" data-testid="fleet-text">{snap.text}</pre> : null}
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -22,11 +22,12 @@ import { OwnerPicker } from './task-tracker/OwnerPicker';
|
|
|
22
22
|
import type { RosterMember } from '../../corpus/owner-link';
|
|
23
23
|
import { ExternalLinkChip } from './task-tracker/ExternalLinkChip';
|
|
24
24
|
import { failureMessage } from './work-items';
|
|
25
|
+
import { ProjectGuess } from './task-tracker/ProjectGuess';
|
|
25
26
|
import { PossiblyDoneNote, markDonePatch, notDonePatch } from './tracker/PossiblyDone';
|
|
26
27
|
import type { MemberConnectionsApi } from './types';
|
|
27
28
|
|
|
28
29
|
export interface TaskDetailPageProps {
|
|
29
|
-
api: Pick<CommitmentApi, 'listCommitments' | 'updateCommitment'> & {
|
|
30
|
+
api: Pick<CommitmentApi, 'listCommitments' | 'updateCommitment'> & Partial<Pick<CommitmentApi, 'fileCommitment'>> & {
|
|
30
31
|
/** The workspace roster; absent means the owner stays text, as before. */
|
|
31
32
|
listMembers?: () => Promise<RosterMember[]>;
|
|
32
33
|
};
|
|
@@ -146,6 +147,26 @@ export function TaskDetailPage({
|
|
|
146
147
|
}
|
|
147
148
|
};
|
|
148
149
|
|
|
150
|
+
const confirmProject = async () => {
|
|
151
|
+
await patchItem({ projectBasis: null });
|
|
152
|
+
setItem((cur) => { if (!cur) return cur; const { projectBasis: _was, ...rest } = cur; return rest as Commitment; });
|
|
153
|
+
};
|
|
154
|
+
const changeProject = async (focusId: string) => {
|
|
155
|
+
if (!item || !apiRef.current.fileCommitment) return;
|
|
156
|
+
setBusy(true);
|
|
157
|
+
setError('');
|
|
158
|
+
try {
|
|
159
|
+
await apiRef.current.fileCommitment(item, focusId);
|
|
160
|
+
await apiRef.current.updateCommitment?.(item, { projectBasis: null });
|
|
161
|
+
const { projectBasis: _was, ...rest } = item;
|
|
162
|
+
setItem({ ...rest, focusId } as Commitment);
|
|
163
|
+
} catch (err) {
|
|
164
|
+
setError(failureMessage(err));
|
|
165
|
+
} finally {
|
|
166
|
+
setBusy(false);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
149
170
|
const setStatus = async (status: CommitmentStatus) => {
|
|
150
171
|
if (!item || !apiRef.current.updateCommitment) return;
|
|
151
172
|
setBusy(true);
|
|
@@ -227,6 +248,11 @@ export function TaskDetailPage({
|
|
|
227
248
|
{project ? <span className={cn.badge}>{project}</span> : null}
|
|
228
249
|
{item.sync ? <ExternalLinkChip sync={item.sync} trackerName={trackerName} className={cn.badge} /> : null}
|
|
229
250
|
</div>
|
|
251
|
+
{item.projectBasis && project && !editing ? (
|
|
252
|
+
<ProjectGuess basis={item.projectBasis} projectId={item.focusId} projects={projectNames}
|
|
253
|
+
onConfirm={confirmProject} onChange={apiRef.current.fileCommitment ? changeProject : undefined}
|
|
254
|
+
disabled={busy || !canWrite} mutedClassName={cn.muted} buttonClassName={cn.secondaryButton} />
|
|
255
|
+
) : null}
|
|
230
256
|
{editing ? (
|
|
231
257
|
<form className="mt-3 space-y-3" onSubmit={(e) => { e.preventDefault(); void save(); }}>
|
|
232
258
|
<label className="block text-sm">Title
|
|
@@ -448,7 +448,7 @@ export function TrackerPage({
|
|
|
448
448
|
<CompactItemRow
|
|
449
449
|
key={entry.item.externalId}
|
|
450
450
|
item={entry.item} due={entry.due} days={entry.days}
|
|
451
|
-
project={extra?.chip ?? (entry.item.focusId ? projectNames[entry.item.focusId] : undefined)}
|
|
451
|
+
project={extra?.chip ?? (entry.item.focusId && projectNames[entry.item.focusId] ? `${projectNames[entry.item.focusId]}${entry.item.projectBasis ? ' (guessed)' : ''}` : undefined)}
|
|
452
452
|
trackerName={trackerName}
|
|
453
453
|
onOpen={onOpenItem || entry.item.mentions.length ? open : undefined}
|
|
454
454
|
actions={extra?.actions}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "WE GUESSED THIS PROJECT" (bd startsim-tmrvi.22, Quinn: keep guessing, but show it and make it one tap to fix).
|
|
3
|
+
* Shown under an item's project only while the item carries `projectBasis`. Confirming or changing clears it.
|
|
4
|
+
*/
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
|
|
7
|
+
export interface ProjectGuessProps {
|
|
8
|
+
basis: string;
|
|
9
|
+
projectId?: string;
|
|
10
|
+
projects: Record<string, string>;
|
|
11
|
+
/** Refile under another project. Absent: the picker is not offered. */
|
|
12
|
+
onChange?: (projectId: string) => Promise<void>;
|
|
13
|
+
onConfirm: () => Promise<void>;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
mutedClassName?: string;
|
|
16
|
+
buttonClassName?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function ProjectGuess({ basis, projectId, projects, onChange, onConfirm, disabled, mutedClassName, buttonClassName }: ProjectGuessProps) {
|
|
20
|
+
const ids = Object.keys(projects);
|
|
21
|
+
return (
|
|
22
|
+
<div className="mt-2 flex flex-wrap items-center gap-2 text-sm" data-testid="project-guess">
|
|
23
|
+
<span className={mutedClassName}>Project {basis}.</span>
|
|
24
|
+
<button type="button" className={buttonClassName} disabled={disabled} onClick={() => void onConfirm()}>That’s right</button>
|
|
25
|
+
{onChange && ids.length > 1 ? (
|
|
26
|
+
<label className="inline-flex items-center gap-1">
|
|
27
|
+
<span className="sr-only">Change project</span>
|
|
28
|
+
<select
|
|
29
|
+
aria-label="Change project"
|
|
30
|
+
className="rounded-md border border-gray-300 px-2 py-1 text-sm"
|
|
31
|
+
disabled={disabled}
|
|
32
|
+
value={projectId ?? ''}
|
|
33
|
+
onChange={(e) => { if (e.target.value && e.target.value !== projectId) void onChange(e.target.value); }}
|
|
34
|
+
>
|
|
35
|
+
{projectId ? null : <option value="">Pick a project</option>}
|
|
36
|
+
{ids.map((id) => <option key={id} value={id}>{projects[id]}</option>)}
|
|
37
|
+
</select>
|
|
38
|
+
</label>
|
|
39
|
+
) : null}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -32,6 +32,13 @@ export const addDays = (day: string, n: number): string => {
|
|
|
32
32
|
d.setUTCDate(d.getUTCDate() + n);
|
|
33
33
|
return d.toISOString().slice(0, 10);
|
|
34
34
|
};
|
|
35
|
+
const MONTHS = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];
|
|
36
|
+
const monthBounds = (year: number, month0: number): { from: string; to: string } => {
|
|
37
|
+
const mm = String(month0 + 1).padStart(2, '0');
|
|
38
|
+
const first = `${year}-${mm}-01`;
|
|
39
|
+
const lastDay = new Date(Date.UTC(year, month0 + 1, 0)).getUTCDate();
|
|
40
|
+
return { from: first, to: `${year}-${mm}-${String(lastDay).padStart(2, '0')}` };
|
|
41
|
+
};
|
|
35
42
|
const weekdayOf = (day: string): number => new Date(`${day}T00:00:00Z`).getUTCDay();
|
|
36
43
|
|
|
37
44
|
/** Monday-first week containing `day`. */
|
|
@@ -41,6 +48,14 @@ function weekOf(day: string): { from: string; to: string } {
|
|
|
41
48
|
return { from, to: addDays(from, 6) };
|
|
42
49
|
}
|
|
43
50
|
|
|
51
|
+
/** A month name with an optional year ("in december", "february 2027"); "may" only after in/during/of. */
|
|
52
|
+
function monthNamed(q: string): { index: number; year?: number } | null {
|
|
53
|
+
const m = q.match(new RegExp(`\\b(?:(?:in|during|of|for|by)\\s+)?(${MONTHS.join('|')})\\b(?:\\s+(20\\d{2}))?`));
|
|
54
|
+
if (!m) return null;
|
|
55
|
+
if (m[1] === 'may' && !/\b(?:in|during|of|for|by)\s+may\b/.test(q)) return null;
|
|
56
|
+
return { index: MONTHS.indexOf(m[1]), ...(m[2] ? { year: Number(m[2]) } : {}) };
|
|
57
|
+
}
|
|
58
|
+
|
|
44
59
|
/** The calendar window a question names ("yesterday", "last week", "this month"), in the reader's zone, or null. */
|
|
45
60
|
export function questionWindow(question: string, now: number, timeZone = 'UTC'): { from: string; to: string; label: string } | null {
|
|
46
61
|
const q = question.toLowerCase();
|
|
@@ -53,6 +68,15 @@ export function questionWindow(question: string, now: number, timeZone = 'UTC'):
|
|
|
53
68
|
else if (/\bthis week\b|\bthe week\b/.test(q)) { const w = weekOf(today); set(w.from, w.to, 'this week'); }
|
|
54
69
|
else if (/\blast month\b/.test(q)) { const first = `${today.slice(0, 8)}01`; const end = addDays(first, -1); set(`${end.slice(0, 8)}01`, end, 'last month'); }
|
|
55
70
|
else if (/\bthis month\b/.test(q)) set(`${today.slice(0, 8)}01`, today, 'this month');
|
|
71
|
+
else if (/\bnext month\b/.test(q)) { const m = monthBounds(Number(today.slice(0, 4)), Number(today.slice(5, 7))); set(m.from, m.to, 'next month'); }
|
|
72
|
+
else if (monthNamed(q)) {
|
|
73
|
+
// "in December", "in February 2027". A bare month already past this year means the coming one.
|
|
74
|
+
const { index, year } = monthNamed(q)!;
|
|
75
|
+
const thisYear = Number(today.slice(0, 4));
|
|
76
|
+
const y = year ?? (index >= Number(today.slice(5, 7)) - 1 ? thisYear : thisYear + 1);
|
|
77
|
+
const m = monthBounds(y, index);
|
|
78
|
+
set(m.from, m.to, `${MONTHS[index][0].toUpperCase()}${MONTHS[index].slice(1)} ${y}`);
|
|
79
|
+
}
|
|
56
80
|
else if (/\btomorrow\b/.test(q)) set(addDays(today, 1), addDays(today, 1), 'tomorrow');
|
|
57
81
|
else if (/\btoday\b/.test(q)) set(today, today, 'today');
|
|
58
82
|
else if (/\byesterday\b/.test(q)) set(addDays(today, -1), addDays(today, -1), 'yesterday');
|
package/src/corpus/ask-items.ts
CHANGED
|
@@ -26,11 +26,11 @@ export interface ItemContext {
|
|
|
26
26
|
/** The reader's member id, for "my". */
|
|
27
27
|
ownerSub?: string;
|
|
28
28
|
/** Project names by focus id, when the caller has them. */
|
|
29
|
-
focusNames?: Record<string, string
|
|
29
|
+
focusNames?: Record<string, string> | Promise<Record<string, string>>;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/** One item as a record the model can read and the screen can cite. */
|
|
33
|
-
export function itemAsDocument(item: Commitment, ctx: ItemContext): SourceDocument {
|
|
33
|
+
export function itemAsDocument(item: Commitment, ctx: Omit<ItemContext, 'focusNames'> & { focusNames?: Record<string, string> }): SourceDocument {
|
|
34
34
|
const zone = ctx.timeZone ?? 'UTC';
|
|
35
35
|
const due = dueDay(item.dueAt, zone);
|
|
36
36
|
const project = item.focusId ? ctx.focusNames?.[item.focusId] : undefined;
|
|
@@ -91,9 +91,12 @@ export async function retrieveItems(
|
|
|
91
91
|
if (!intent || !api) return { intent: null, retrieved: [], matched: 0 };
|
|
92
92
|
const page = await api.listCommitments({ pageSize: 200, sort: 'due', withFocus: true }).catch(() => null);
|
|
93
93
|
if (!page) return { intent, retrieved: [], matched: 0 };
|
|
94
|
-
|
|
94
|
+
// The project names load beside the item list (the caller starts both), so they are awaited only now.
|
|
95
|
+
const names = await Promise.resolve(ctx.focusNames).catch(() => undefined);
|
|
96
|
+
const resolved = { ...ctx, focusNames: names };
|
|
97
|
+
const selected = selectItems(page.results.filter((item) => isInScope(item, scope)), intent, resolved);
|
|
95
98
|
const retrieved = selected.slice(0, limit).map((item): RetrievedDocument => {
|
|
96
|
-
const document = itemAsDocument(item,
|
|
99
|
+
const document = itemAsDocument(item, resolved);
|
|
97
100
|
return { document, score: 1, matchedTerms: [], snippet: document.body.split('\n').slice(0, 2).join(' · ') };
|
|
98
101
|
});
|
|
99
102
|
return { intent, retrieved, matched: selected.length };
|
package/src/corpus/ask.ts
CHANGED
|
@@ -56,7 +56,7 @@ export interface AskCorpusOptions {
|
|
|
56
56
|
/** The reader's member id, for "what did I commit to". */
|
|
57
57
|
ownerSub?: string;
|
|
58
58
|
/** Project names by focus id, for the item records. */
|
|
59
|
-
focusNames?: Record<string, string
|
|
59
|
+
focusNames?: Record<string, string> | Promise<Record<string, string>>;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const DEFAULTS = {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { localDate } from '../../today';
|
|
3
3
|
import { spokenWhen } from '../intent/dates';
|
|
4
4
|
import { PRIORITY_NAMES } from '../intent/describe';
|
|
5
|
-
import { speakable } from '../speak';
|
|
5
|
+
import { spokenMinutes, speakable } from '../speak';
|
|
6
6
|
import type { BriefingAudio, BriefingSynthesize } from '../generate';
|
|
7
7
|
import type { ItemPatch, UndoEntry } from './types';
|
|
8
8
|
import type { VoiceAction } from '../intent/types';
|
|
@@ -21,6 +21,10 @@ export function confirmText(action: VoiceAction, title: string, now: number, tim
|
|
|
21
21
|
case 'drop': return `Dropped ${t}.`;
|
|
22
22
|
case 'set_priority': return `Made ${t} ${PRIORITY_NAMES[action.priority] ?? `priority ${action.priority}`}.`;
|
|
23
23
|
case 'add_item': return `Added ${shortTitle(action.title)}${action.dueDate ? ` for ${spokenWhen(action.dueDate, today)}` : ''}.`;
|
|
24
|
+
case 'rename': return `Renamed it to ${shortTitle(action.title)}.`;
|
|
25
|
+
case 'add_detail': return `Added a note to ${t}.`;
|
|
26
|
+
case 'set_estimate': return action.minutes === null ? `Cleared the estimate on ${t}.` : `Set ${t} to ${spokenMinutes(action.minutes)}.`;
|
|
27
|
+
case 'set_project': return action.project === null ? `Took ${t} out of its project.` : `Moved ${t} to ${shortTitle(action.project)}.`;
|
|
24
28
|
default: return '';
|
|
25
29
|
}
|
|
26
30
|
}
|
|
@@ -35,6 +39,10 @@ export function undoText(entry: UndoEntry, now: number, timeZone: string): strin
|
|
|
35
39
|
if ('dueAt' in b) parts.push(b.dueAt ? `due ${spokenWhen(String(b.dueAt).slice(0, 10), today)}` : 'no date');
|
|
36
40
|
if ('status' in b && b.status) parts.push(b.status === 'open' ? 'open' : String(b.status));
|
|
37
41
|
if ('priority' in b) parts.push(b.priority === null || b.priority === undefined ? 'no priority' : PRIORITY_NAMES[b.priority] ?? `priority ${b.priority}`);
|
|
42
|
+
if ('title' in b && b.title) parts.push(`called ${shortTitle(b.title)}`);
|
|
43
|
+
if ('detail' in b) parts.push('its old note');
|
|
44
|
+
if ('estimateMinutes' in b) parts.push(b.estimateMinutes ? `${spokenMinutes(b.estimateMinutes)}` : 'no estimate');
|
|
45
|
+
if ('focusId' in b) parts.push('its old project');
|
|
38
46
|
return `Undid it. ${t} is back to ${parts.join(', ') || 'how it was'}.`;
|
|
39
47
|
}
|
|
40
48
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* Only what really changed is on the undo stack.
|
|
11
11
|
*/
|
|
12
12
|
import { localDate } from '../../today';
|
|
13
|
+
import { speakCount } from '../speak';
|
|
13
14
|
import type { VoiceAction } from '../intent/types';
|
|
14
15
|
import { confirmText, shortTitle, undoText } from './confirm';
|
|
15
16
|
import { REMEMBERED_ACTIONS, UNDO_DEPTH } from './log';
|
|
@@ -41,6 +42,10 @@ function snapshot(item: EditableItem, patch: ItemPatch): ItemPatch {
|
|
|
41
42
|
else if (key === 'resolvedAt') before.resolvedAt = item.resolvedAt ?? null;
|
|
42
43
|
else if (key === 'statusReason') before.statusReason = item.statusReason ?? '';
|
|
43
44
|
else if (key === 'status') before.status = item.status;
|
|
45
|
+
else if (key === 'title') before.title = item.title;
|
|
46
|
+
else if (key === 'detail') before.detail = item.detail ?? '';
|
|
47
|
+
else if (key === 'estimateMinutes') before.estimateMinutes = item.estimateMinutes ?? null;
|
|
48
|
+
else if (key === 'focusId') before.focusId = item.focusId ?? null;
|
|
44
49
|
}
|
|
45
50
|
return before;
|
|
46
51
|
}
|
|
@@ -50,9 +55,43 @@ function changedSince(item: EditableItem, after: ItemPatch): boolean {
|
|
|
50
55
|
if ('dueAt' in after && !sameDay(item.dueAt, after.dueAt)) return true;
|
|
51
56
|
if ('status' in after && item.status !== after.status) return true;
|
|
52
57
|
if ('priority' in after && (item.priority ?? null) !== (after.priority ?? null)) return true;
|
|
58
|
+
if ('title' in after && item.title !== after.title) return true;
|
|
59
|
+
if ('detail' in after && (item.detail ?? '') !== (after.detail ?? '')) return true;
|
|
60
|
+
if ('estimateMinutes' in after && (item.estimateMinutes ?? null) !== (after.estimateMinutes ?? null)) return true;
|
|
61
|
+
if ('focusId' in after && (item.focusId ?? null) !== (after.focusId ?? null)) return true;
|
|
53
62
|
return false;
|
|
54
63
|
}
|
|
55
64
|
|
|
65
|
+
const projectKey = (name: string) => name.toLowerCase().replace(/\b(?:the|project|projects)\b/g, ' ').replace(/[^a-z0-9]+/g, ' ').trim();
|
|
66
|
+
|
|
67
|
+
/** The project a spoken name means: an exact match, else the one project whose name holds it (or it holds). */
|
|
68
|
+
function findProject(name: string, focuses: Array<{ id: string; title: string }>) {
|
|
69
|
+
const key = projectKey(name);
|
|
70
|
+
if (!key) return null;
|
|
71
|
+
const exact = focuses.filter((f) => projectKey(f.title) === key);
|
|
72
|
+
if (exact.length === 1) return exact[0];
|
|
73
|
+
const near = focuses.filter((f) => { const k = projectKey(f.title); return k.includes(key) || key.includes(k); });
|
|
74
|
+
return near.length === 1 ? near[0] : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type Planned = { patch: ItemPatch; action: VoiceAction } | { ask: string };
|
|
78
|
+
|
|
79
|
+
async function planFor(action: VoiceAction, item: EditableItem, today: string, nowIso: string, seam: ItemEditSeam): Promise<Planned> {
|
|
80
|
+
switch (action.type) {
|
|
81
|
+
case 'rename': return { patch: { title: action.title }, action };
|
|
82
|
+
case 'add_detail': return { patch: { detail: item.detail ? `${item.detail}\n\n${action.detail}` : action.detail }, action };
|
|
83
|
+
case 'set_estimate': return { patch: { estimateMinutes: action.minutes }, action };
|
|
84
|
+
case 'set_project': {
|
|
85
|
+
if (action.project === null) return { patch: { focusId: null }, action };
|
|
86
|
+
if (!seam.listFocuses) throw new Error('This client cannot change projects.');
|
|
87
|
+
const focus = findProject(action.project, await seam.listFocuses());
|
|
88
|
+
if (!focus) return { ask: `I could not find a project called ${shortTitle(action.project)}.` };
|
|
89
|
+
return { patch: { focusId: focus.id }, action: { ...action, project: focus.title } };
|
|
90
|
+
}
|
|
91
|
+
default: return { patch: patchFor(action, today, nowIso) as ItemPatch, action };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
56
95
|
function patchFor(action: VoiceAction, today: string, nowIso: string): ItemPatch | null {
|
|
57
96
|
switch (action.type) {
|
|
58
97
|
case 'defer': return { dueAt: action.to === 'later' ? null : action.to };
|
|
@@ -75,10 +114,10 @@ function remember(log: ActionLog, key: string, result: ActionResult) {
|
|
|
75
114
|
while (log.order.length > REMEMBERED_ACTIONS) delete log.applied[log.order.shift() as string];
|
|
76
115
|
}
|
|
77
116
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
117
|
+
const groupOf = (entry: UndoEntry) => entry.actionId.split('#')[0];
|
|
118
|
+
|
|
119
|
+
/** Restores one entry. The caller has already taken it off the stack. */
|
|
120
|
+
async function undoEntry(entry: UndoEntry, input: ExecuteInput, now: number): Promise<ActionResult> {
|
|
82
121
|
try {
|
|
83
122
|
const item = await input.seam.load(entry.itemId);
|
|
84
123
|
if (!item) return { status: 'asked', spoken: `${shortTitle(entry.title)} is gone, so I could not undo that.`, itemId: entry.itemId };
|
|
@@ -93,11 +132,29 @@ async function undoOne(log: ActionLog, input: ExecuteInput, now: number): Promis
|
|
|
93
132
|
}
|
|
94
133
|
return { status: 'applied', spoken: undoText(entry, now, input.timeZone), itemId: entry.itemId };
|
|
95
134
|
} catch (error) {
|
|
96
|
-
log.stack.push(entry); // nothing changed: it can be tried again
|
|
97
135
|
return { status: 'failed', spoken: `I could not undo that: ${error instanceof Error ? error.message : 'the change did not go through'}.`, itemId: entry.itemId, reason: reasonOf(error) };
|
|
98
136
|
}
|
|
99
137
|
}
|
|
100
138
|
|
|
139
|
+
/** "Undo" reverts the last reply: every change made under the same client action id, newest first. */
|
|
140
|
+
async function undoLast(log: ActionLog, input: ExecuteInput, now: number): Promise<ActionResult> {
|
|
141
|
+
const top = log.stack[log.stack.length - 1];
|
|
142
|
+
if (!top) return { status: 'asked', spoken: 'There is nothing to undo.' };
|
|
143
|
+
const group = groupOf(top);
|
|
144
|
+
const entries: UndoEntry[] = [];
|
|
145
|
+
// Popped either way: an entry that cannot be restored must not block the ones under it.
|
|
146
|
+
while (log.stack.length && groupOf(log.stack[log.stack.length - 1]) === group) entries.push(log.stack.pop() as UndoEntry);
|
|
147
|
+
const results: ActionResult[] = [];
|
|
148
|
+
for (const entry of entries) {
|
|
149
|
+
const r = await undoEntry(entry, input, now);
|
|
150
|
+
if (r.status === 'failed') log.stack.push(entry); // nothing changed: it can be tried again
|
|
151
|
+
results.push(r);
|
|
152
|
+
}
|
|
153
|
+
if (results.length === 1) return results[0];
|
|
154
|
+
if (results.every((r) => r.status === 'applied')) return { status: 'applied', spoken: `Undid all ${speakCount(results.length)} changes.` };
|
|
155
|
+
return { status: results.some((r) => r.status === 'failed') ? 'failed' : 'asked', spoken: results.map((r) => r.spoken).join(' ') };
|
|
156
|
+
}
|
|
157
|
+
|
|
101
158
|
export async function executeVoiceActions(input: ExecuteInput): Promise<ExecuteOutcome> {
|
|
102
159
|
const now = (input.now ?? Date.now)();
|
|
103
160
|
const today = localDate(now, input.timeZone);
|
|
@@ -115,7 +172,7 @@ export async function executeVoiceActions(input: ExecuteInput): Promise<ExecuteO
|
|
|
115
172
|
let result: ActionResult;
|
|
116
173
|
if (action.type === 'clarify') result = { status: 'asked', spoken: action.question };
|
|
117
174
|
else if (action.type === 'none') result = { status: 'asked', spoken: 'Sorry, I did not catch that. Can you say that again?' };
|
|
118
|
-
else if (action.type === 'undo') result = await
|
|
175
|
+
else if (action.type === 'undo') result = await undoLast(log, input, now);
|
|
119
176
|
else if (action.type === 'add_item') {
|
|
120
177
|
try {
|
|
121
178
|
const created = await input.seam.create({ title: action.title, ownerSub: input.ownerSub, dueAt: action.dueDate });
|
|
@@ -125,17 +182,20 @@ export async function executeVoiceActions(input: ExecuteInput): Promise<ExecuteO
|
|
|
125
182
|
result = { status: 'failed', spoken: `I could not add ${shortTitle(action.title)}.`, reason: reasonOf(error) };
|
|
126
183
|
}
|
|
127
184
|
} else {
|
|
128
|
-
const patch = patchFor(action, today, nowIso) as ItemPatch;
|
|
129
185
|
let title = 'that item';
|
|
130
186
|
try {
|
|
131
187
|
const item = await input.seam.load(action.itemId);
|
|
132
188
|
if (!item) result = { status: 'failed', spoken: 'I could not find that item.', itemId: action.itemId };
|
|
133
189
|
else {
|
|
134
190
|
title = item.title;
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
191
|
+
const plan = await planFor(action, item, today, nowIso, input.seam);
|
|
192
|
+
if ('ask' in plan) result = { status: 'asked', spoken: plan.ask, itemId: item.id };
|
|
193
|
+
else {
|
|
194
|
+
const before = snapshot(item, plan.patch);
|
|
195
|
+
await input.seam.update(item, plan.patch);
|
|
196
|
+
pushUndo(log, { actionId: key, kind: 'edit', itemId: item.id, title: item.title, before, after: plan.patch, at: nowIso });
|
|
197
|
+
result = { status: 'applied', spoken: confirmText(plan.action, item.title, now, input.timeZone), itemId: item.id };
|
|
198
|
+
}
|
|
139
199
|
}
|
|
140
200
|
} catch (error) {
|
|
141
201
|
result = { status: 'failed', spoken: `I could not update ${shortTitle(title)}.`, itemId: action.itemId, reason: reasonOf(error) };
|
|
@@ -42,7 +42,7 @@ export function createEntityActionLog(http: LogHttp, ownerSub: string): ActionLo
|
|
|
42
42
|
});
|
|
43
43
|
const hit = (page.results ?? []).find((r) => (r.external_id ?? (r as { externalId?: string }).externalId) === externalId && mine(r));
|
|
44
44
|
const stored = ((hit?.data ?? {}) as Record<string, unknown>).action_log as Partial<ActionLog> | undefined;
|
|
45
|
-
return stored ? { applied: stored.applied ?? {}, order: stored.order ?? [], stack: stored.stack ?? [], pending: stored.pending ?? [] } : emptyLog();
|
|
45
|
+
return stored ? { applied: stored.applied ?? {}, order: stored.order ?? [], stack: stored.stack ?? [], pending: stored.pending ?? [], ...(stored.skips ? { skips: stored.skips } : {}) } : emptyLog();
|
|
46
46
|
},
|
|
47
47
|
async save(log) {
|
|
48
48
|
await http.post('api/v1/entities/upsert', {
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
import type { CorpusHttp } from '../../client';
|
|
3
3
|
import { isRecord, notFound } from '../../client';
|
|
4
4
|
import { toCommitment } from '../../entities';
|
|
5
|
+
import { listFocusChoices } from '../../filing';
|
|
5
6
|
import type { Commitment, CommitmentApi, CorpusScope } from '../../types';
|
|
6
7
|
import type { EditableItem, ItemEditSeam } from './types';
|
|
7
8
|
|
|
8
9
|
export function commitmentEditSeam(options: {
|
|
9
|
-
api: Pick<CommitmentApi, 'updateCommitment' | 'createCommitment'
|
|
10
|
+
api: Pick<CommitmentApi, 'updateCommitment' | 'createCommitment'> & Partial<Pick<CommitmentApi, 'fileCommitment'>>;
|
|
10
11
|
http: Pick<CorpusHttp, 'get'>;
|
|
11
12
|
scope: CorpusScope;
|
|
12
13
|
entitiesPath?: string;
|
|
14
|
+
/** The projects an item can be filed under. Default: every focus the tenant has. */
|
|
15
|
+
listFocuses?: () => Promise<Array<{ id: string; title: string }>>;
|
|
13
16
|
}): ItemEditSeam {
|
|
14
17
|
const { api, http, scope } = options;
|
|
15
18
|
const entities = options.entitiesPath ?? 'api/v1/entities';
|
|
@@ -19,6 +22,8 @@ export function commitmentEditSeam(options: {
|
|
|
19
22
|
id: c.id, externalId: c.externalId, title: c.title, status: c.status, dueAt: c.dueAt ?? null,
|
|
20
23
|
...(c.priority !== undefined ? { priority: c.priority } : {}),
|
|
21
24
|
resolvedAt: c.resolvedAt ?? null, ...(c.statusReason ? { statusReason: c.statusReason } : {}),
|
|
25
|
+
...(c.detail ? { detail: c.detail } : {}), ...(c.estimateMinutes !== undefined ? { estimateMinutes: c.estimateMinutes } : {}),
|
|
26
|
+
focusId: c.focusId ?? null,
|
|
22
27
|
};
|
|
23
28
|
raw.set(item, c);
|
|
24
29
|
return item;
|
|
@@ -38,8 +43,19 @@ export function commitmentEditSeam(options: {
|
|
|
38
43
|
if (!api.updateCommitment) throw new Error('This client cannot edit items.');
|
|
39
44
|
const row = raw.get(item) ?? ({ id: item.id, externalId: item.externalId } as Commitment);
|
|
40
45
|
if (!row.externalId) throw new Error('This item has no stable identity to edit.');
|
|
41
|
-
|
|
46
|
+
const { focusId, estimateMinutes, ...fields } = patch;
|
|
47
|
+
let current = item;
|
|
48
|
+
if (Object.keys(fields).length || estimateMinutes !== undefined) {
|
|
49
|
+
current = wrap(await api.updateCommitment(row, { ...fields, ...(estimateMinutes !== undefined ? { estimateMinutes } : {}) } as never));
|
|
50
|
+
}
|
|
51
|
+
if (focusId !== undefined) {
|
|
52
|
+
if (!api.fileCommitment) throw new Error('This client cannot change projects.');
|
|
53
|
+
await api.fileCommitment(row, focusId);
|
|
54
|
+
current = { ...current, focusId };
|
|
55
|
+
}
|
|
56
|
+
return current;
|
|
42
57
|
},
|
|
58
|
+
listFocuses: options.listFocuses ?? (() => listFocusChoices(http as CorpusHttp, { entities })),
|
|
43
59
|
async create(draft) {
|
|
44
60
|
if (!api.createCommitment) throw new Error('This client cannot add items.');
|
|
45
61
|
return wrap(await api.createCommitment({
|
|
@@ -19,6 +19,10 @@ export interface EditableItem {
|
|
|
19
19
|
resolvedAt?: string | null;
|
|
20
20
|
statusReason?: string;
|
|
21
21
|
externalId?: string;
|
|
22
|
+
detail?: string;
|
|
23
|
+
estimateMinutes?: number;
|
|
24
|
+
focusId?: string | null;
|
|
25
|
+
focusName?: string;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
/** The fields a voice reply changes. `null` clears (due date, priority, resolved time). */
|
|
@@ -28,6 +32,12 @@ export interface ItemPatch {
|
|
|
28
32
|
dueAt?: string | null;
|
|
29
33
|
priority?: number | null;
|
|
30
34
|
resolvedAt?: string | null;
|
|
35
|
+
title?: string;
|
|
36
|
+
detail?: string;
|
|
37
|
+
/** Minutes; `null` clears it. */
|
|
38
|
+
estimateMinutes?: number | null;
|
|
39
|
+
/** The project's id; `null` takes the item out of its project. Written as an edge, not a field. */
|
|
40
|
+
focusId?: string | null;
|
|
31
41
|
}
|
|
32
42
|
|
|
33
43
|
export interface ItemDraft {
|
|
@@ -40,6 +50,8 @@ export interface ItemEditSeam {
|
|
|
40
50
|
load(id: string): Promise<EditableItem | null>;
|
|
41
51
|
update(item: EditableItem, patch: ItemPatch): Promise<EditableItem>;
|
|
42
52
|
create(draft: ItemDraft): Promise<EditableItem>;
|
|
53
|
+
/** The projects an item can be filed under. Absent: this seam cannot change projects. */
|
|
54
|
+
listFocuses?(): Promise<Array<{ id: string; title: string }>>;
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
export type ActionStatus = 'applied' | 'failed' | 'asked';
|
|
@@ -89,6 +101,8 @@ export interface ActionLog {
|
|
|
89
101
|
stack: UndoEntry[];
|
|
90
102
|
/** The latest replies understood, newest last (see `PendingReply`). */
|
|
91
103
|
pending?: PendingReply[];
|
|
104
|
+
/** What he skipped in a briefing today (by his local date): the next briefing does not bring it back. */
|
|
105
|
+
skips?: { date: string; keys: string[] };
|
|
92
106
|
}
|
|
93
107
|
|
|
94
108
|
export interface ActionLogStore {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** One line saying what was understood, shown BEFORE anything is applied. */
|
|
2
2
|
import { localDate } from '../../today';
|
|
3
|
-
import { speakable } from '../speak';
|
|
3
|
+
import { speakable, spokenMinutes } from '../speak';
|
|
4
4
|
import { spokenWhen } from './dates';
|
|
5
5
|
import type { IntentContext, VoiceAction } from './types';
|
|
6
6
|
|
|
@@ -18,6 +18,10 @@ export function describeActions(actions: VoiceAction[], ctx: IntentContext): str
|
|
|
18
18
|
case 'drop': return `Drop ${name(a.itemId)}`;
|
|
19
19
|
case 'set_priority': return `Make ${name(a.itemId)} ${PRIORITY_NAMES[a.priority] ?? 'priority ' + a.priority}`;
|
|
20
20
|
case 'add_item': return `Add ${a.title}${a.dueDate ? ` for ${spokenWhen(a.dueDate, today)}` : ''}`;
|
|
21
|
+
case 'rename': return `Rename ${name(a.itemId)} to ${speakable(a.title, 10)}`;
|
|
22
|
+
case 'add_detail': return `Add a note to ${name(a.itemId)}`;
|
|
23
|
+
case 'set_estimate': return a.minutes === null ? `Clear the estimate on ${name(a.itemId)}` : `Set ${name(a.itemId)} to ${spokenMinutes(a.minutes)}`;
|
|
24
|
+
case 'set_project': return a.project === null ? `Take ${name(a.itemId)} out of its project` : `Move ${name(a.itemId)} to ${speakable(a.project, 6)}`;
|
|
21
25
|
case 'undo': return 'Undo the last change';
|
|
22
26
|
case 'clarify': return a.question;
|
|
23
27
|
default: return '';
|