@startsimpli/integrations 0.2.180 → 0.2.181
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 +3 -3
- package/src/__tests__/corpus-ask-projects.test.ts +74 -0
- package/src/__tests__/library-asks-line.test.ts +27 -0
- package/src/components/documentText.ts +13 -4
- package/src/components/pages/AskPage.tsx +9 -1
- package/src/corpus/ask-projects.ts +94 -0
- package/src/corpus/ask.ts +21 -2
- package/src/corpus/index.ts +3 -0
- package/src/native/app/registry.tsx +1 -1
- package/src/native/talk/TalkTab.tsx +5 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startsimpli/integrations",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.181",
|
|
4
4
|
"description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps, plus foundry customer email (subpath ./comms).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://startsimpli.com",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"react-native": ">=0.74.0",
|
|
51
51
|
"@startsimpli/ui-native": ">=0.1.12",
|
|
52
52
|
"react-native-safe-area-context": ">=4.0.0",
|
|
53
|
+
"@startsimpli/auth": "^0.4.53",
|
|
53
54
|
"@startsimpli/ui": "^0.4.186",
|
|
54
|
-
"@startsimpli/utils": "^0.4.20"
|
|
55
|
-
"@startsimpli/auth": "^0.4.53"
|
|
55
|
+
"@startsimpli/utils": "^0.4.20"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"react": {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ask over projects (found on the live QA tenant, 2026-11-16): "What projects are active?" searched only
|
|
3
|
+
* documents, so a workspace with 64 projects and 9 briefing/conversation records answered "none of them
|
|
4
|
+
* matched". Projects are records an answer can cite, selected by status in code, like tracked items.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, it } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { askCorpus } from '../corpus/ask';
|
|
9
|
+
import { projectIntent, selectProjects } from '../corpus/ask-projects';
|
|
10
|
+
import { createFixtureCorpusApi, FIXTURE_ORG } from '../corpus/fixtures';
|
|
11
|
+
import type { AnswerDraft, AnswerRequest, CorpusLlm, Focus } from '../corpus/types';
|
|
12
|
+
|
|
13
|
+
const SCOPE = { orgId: FIXTURE_ORG };
|
|
14
|
+
const focus = (id: string, title: string, status: Focus['status']): Focus =>
|
|
15
|
+
({ id, externalId: `focus:${id}`, title, detail: '', status, scope: SCOPE }) as Focus;
|
|
16
|
+
const FOCUSES = [
|
|
17
|
+
focus('a', 'Crochets V2 launch', 'active'),
|
|
18
|
+
focus('b', 'Pre-seed fundraise', 'at_risk'),
|
|
19
|
+
focus('c', 'Scope & Plan Team', 'draft'),
|
|
20
|
+
focus('d', 'Old sales target', 'cancelled'),
|
|
21
|
+
focus('e', 'Onboarding', 'on_track'),
|
|
22
|
+
];
|
|
23
|
+
const projects = { listFocuses: async () => ({ count: FOCUSES.length, next: null, previous: null, results: FOCUSES }) };
|
|
24
|
+
|
|
25
|
+
function llmCiting(ids: string[], calls: AnswerRequest[] = []): CorpusLlm {
|
|
26
|
+
return {
|
|
27
|
+
describe: () => ({ provider: 'scripted', model: 's', live: false }),
|
|
28
|
+
async answer(input): Promise<AnswerDraft> { calls.push(input); return { answer: 'ok', citations: ids.map((documentId) => ({ documentId })) }; },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('projectIntent', () => {
|
|
33
|
+
it('is null for a question that is not about projects or goals', () => {
|
|
34
|
+
expect(projectIntent('what did Acme say about pricing')).toBeNull();
|
|
35
|
+
});
|
|
36
|
+
it('reads "active" as everything in play, and a named status as that status', () => {
|
|
37
|
+
expect(projectIntent('What projects are active?')!.statuses).toEqual(['active', 'on_track', 'at_risk', 'off_track']);
|
|
38
|
+
expect(projectIntent('which goals are at risk')!.statuses).toEqual(['at_risk']);
|
|
39
|
+
expect(projectIntent('list my draft projects')!.statuses).toEqual(['draft']);
|
|
40
|
+
expect(projectIntent('what projects did we finish')!.statuses).toEqual(['completed']);
|
|
41
|
+
});
|
|
42
|
+
it('with no status word, everything but cancelled', () => {
|
|
43
|
+
expect(projectIntent('what projects do we have')!.statuses).toEqual(['draft', 'active', 'on_track', 'at_risk', 'off_track', 'completed']);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('Ask over projects', () => {
|
|
48
|
+
it('selects by status', () => {
|
|
49
|
+
const intent = projectIntent('What projects are active?')!;
|
|
50
|
+
expect(selectProjects(FOCUSES, intent).map((f) => f.title)).toEqual(['Crochets V2 launch', 'Onboarding', 'Pre-seed fundraise']);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('answers a project question from the projects, cites them, and never says "none of them matched"', async () => {
|
|
54
|
+
const calls: AnswerRequest[] = [];
|
|
55
|
+
const result = await askCorpus(
|
|
56
|
+
{ question: 'What projects are active?', mode: 'ask', scope: SCOPE },
|
|
57
|
+
{ corpus: createFixtureCorpusApi({ documents: [] } as never), llm: llmCiting(['project:a', 'project:e'], calls), projects },
|
|
58
|
+
);
|
|
59
|
+
expect(result.status).toBe('answered');
|
|
60
|
+
expect(result.citations.map((c) => c.documentId)).toEqual(['project:a', 'project:e']);
|
|
61
|
+
expect(result.answer).not.toMatch(/none of them matched/);
|
|
62
|
+
expect(JSON.stringify(calls[0])).toContain('Pre-seed fundraise');
|
|
63
|
+
expect(JSON.stringify(calls[0])).not.toContain('Old sales target');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('a question that is not about projects does not read them', async () => {
|
|
67
|
+
let read = 0;
|
|
68
|
+
await askCorpus(
|
|
69
|
+
{ question: 'what did Acme say about pricing', mode: 'ask', scope: SCOPE },
|
|
70
|
+
{ corpus: createFixtureCorpusApi(), llm: llmCiting([]), projects: { listFocuses: async () => { read += 1; return { count: 0, next: null, previous: null, results: [] }; } } },
|
|
71
|
+
);
|
|
72
|
+
expect(read).toBe(0);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records filed before the Plan change keep their text: a Conversation lists its asks under "## Asks" (or
|
|
3
|
+
* "Next steps"), a note under "Next steps". Render time, text-based: any such section becomes "N to-dos ... in Plan".
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { withoutNextSteps } from '../components/documentText';
|
|
8
|
+
|
|
9
|
+
describe('withoutNextSteps covers every to-do list heading', () => {
|
|
10
|
+
it.each(['Asks', 'Next steps', 'Next Steps', 'Action items', 'To-dos', 'Todos', 'Follow-ups'])('strips a "%s" section and counts its bullets', (heading) => {
|
|
11
|
+
const out = withoutNextSteps(`We talked.\n\n## ${heading}\n\n- Send the deck\n- Book the room\n\n## Decisions\n\nShip Friday.`);
|
|
12
|
+
expect(out.todos).toBe(2);
|
|
13
|
+
expect(out.text).toContain('We talked.');
|
|
14
|
+
expect(out.text).toContain('Ship Friday.');
|
|
15
|
+
expect(out.text).not.toContain('Send the deck');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('works on a bold-title bullet list and an "Asks:" colon heading line', () => {
|
|
19
|
+
const out = withoutNextSteps('Hi.\n\n**Asks**\n\n- **Call Dana**\n- **Email Rae**');
|
|
20
|
+
expect(out.todos).toBe(2);
|
|
21
|
+
expect(out.text).toBe('Hi.');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('leaves a record without such a section untouched', () => {
|
|
25
|
+
expect(withoutNextSteps('Just prose.\n\n## Decisions\n\n- Ship')).toEqual({ text: 'Just prose.\n\n## Decisions\n\n- Ship', todos: 0 });
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -30,9 +30,15 @@ export function fullTextOf(document: SourceDocument): string {
|
|
|
30
30
|
return body && body !== summaryOf(document) ? body : '';
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/** Headings that introduce a note's list of to-dos: a Conversation's "Asks", a note's "Next steps", and their cousins. */
|
|
34
|
+
const TODO_HEADING = /^(?:next\s+steps?|asks?|action\s+items?|to-?dos?|follow-?\s?ups?)$/i;
|
|
35
|
+
const BULLET = /^\s*(?:[-*+]|\d+[.)])\s+\S/;
|
|
36
|
+
|
|
33
37
|
/**
|
|
34
|
-
* A
|
|
35
|
-
*
|
|
38
|
+
* A record's markdown without its to-do list, and how many to-dos that list held. The to-dos live only in Plan
|
|
39
|
+
* (Quinn, 2026-11-16): a record shows its prose and a link, never a second to-do list. TEXT-BASED and applied when
|
|
40
|
+
* rendering, so a record filed before that change shows it too. A list is introduced by a markdown heading
|
|
41
|
+
* (`## Asks`), a bold line (`**Next steps**`) or a colon line (`Asks:`) and runs until the next heading.
|
|
36
42
|
*/
|
|
37
43
|
export function withoutNextSteps(markdown: string): { text: string; todos: number } {
|
|
38
44
|
const lines = (markdown ?? '').split('\n');
|
|
@@ -41,9 +47,12 @@ export function withoutNextSteps(markdown: string): { text: string; todos: numbe
|
|
|
41
47
|
let todos = 0;
|
|
42
48
|
for (const line of lines) {
|
|
43
49
|
const heading = line.match(/^\s*#{1,6}\s+(.+?)\s*$/);
|
|
44
|
-
|
|
50
|
+
const bold = line.match(/^\s*\*\*(.+?)\*\*:?\s*$/);
|
|
51
|
+
const colon = line.match(/^\s*([A-Za-z][A-Za-z -]{1,24}):\s*$/);
|
|
52
|
+
const title = (heading ?? bold ?? colon)?.[1]?.replace(/:$/, '').trim();
|
|
53
|
+
if (heading || ((bold || colon) && title && TODO_HEADING.test(title))) skipping = Boolean(title && TODO_HEADING.test(title));
|
|
45
54
|
if (skipping) {
|
|
46
|
-
if (
|
|
55
|
+
if (BULLET.test(line)) todos += 1;
|
|
47
56
|
continue;
|
|
48
57
|
}
|
|
49
58
|
out.push(line);
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
import * as React from 'react';
|
|
33
33
|
|
|
34
34
|
import { itemIdOf } from '../../corpus/ask-items';
|
|
35
|
+
import { projectIdOf } from '../../corpus/ask-projects';
|
|
35
36
|
import { Markdown, stripMarkdown } from '../Markdown';
|
|
36
37
|
import {
|
|
37
38
|
UNCITED_NOTICE, askFailureMessage as failureMessage, droppedNotice, freshnessNotice,
|
|
@@ -53,6 +54,8 @@ export interface AskPageProps {
|
|
|
53
54
|
onOpenDocument?: (documentId: string) => void;
|
|
54
55
|
/** Click-through from a cited TRACKED ITEM (an `item:` record) to the item, by its external id. */
|
|
55
56
|
onOpenItem?: (itemId: string) => void;
|
|
57
|
+
/** Click-through from a cited PROJECT (a `project:` record) to the project, by its id. */
|
|
58
|
+
onOpenProject?: (projectId: string) => void;
|
|
56
59
|
/** Prefill, e.g. from a `?q=` param. */
|
|
57
60
|
initialQuestion?: string;
|
|
58
61
|
initialMode?: AskMode;
|
|
@@ -106,6 +109,7 @@ export function AskPage({
|
|
|
106
109
|
scope,
|
|
107
110
|
onOpenDocument,
|
|
108
111
|
onOpenItem,
|
|
112
|
+
onOpenProject,
|
|
109
113
|
initialQuestion = '',
|
|
110
114
|
initialMode = 'ask',
|
|
111
115
|
listProjects,
|
|
@@ -235,6 +239,7 @@ export function AskPage({
|
|
|
235
239
|
classNames={cn}
|
|
236
240
|
onOpenDocument={onOpenDocument}
|
|
237
241
|
onOpenItem={onOpenItem}
|
|
242
|
+
onOpenProject={onOpenProject}
|
|
238
243
|
canSave={canSave}
|
|
239
244
|
saveState={saveState}
|
|
240
245
|
onSave={async () => {
|
|
@@ -262,12 +267,13 @@ export function AskPage({
|
|
|
262
267
|
// ---------------------------------------------------------------------------
|
|
263
268
|
|
|
264
269
|
function AnswerPanel({
|
|
265
|
-
result, classNames: cn, onOpenDocument, onOpenItem, canSave, saveState, onSave,
|
|
270
|
+
result, classNames: cn, onOpenDocument, onOpenItem, onOpenProject, canSave, saveState, onSave,
|
|
266
271
|
}: {
|
|
267
272
|
result: AskResult;
|
|
268
273
|
classNames: Record<AskSlot, string>;
|
|
269
274
|
onOpenDocument?: (documentId: string) => void;
|
|
270
275
|
onOpenItem?: (itemId: string) => void;
|
|
276
|
+
onOpenProject?: (projectId: string) => void;
|
|
271
277
|
canSave: boolean;
|
|
272
278
|
saveState: 'idle' | 'saving' | 'saved';
|
|
273
279
|
onSave: () => void;
|
|
@@ -335,7 +341,9 @@ function AnswerPanel({
|
|
|
335
341
|
className="text-sm font-medium text-blue-700 underline"
|
|
336
342
|
onClick={() => {
|
|
337
343
|
const itemId = itemIdOf(citation.documentId);
|
|
344
|
+
const projectId = projectIdOf(citation.documentId);
|
|
338
345
|
if (itemId) onOpenItem?.(itemId);
|
|
346
|
+
else if (projectId) onOpenProject?.(projectId);
|
|
339
347
|
else onOpenDocument?.(citation.documentId);
|
|
340
348
|
}}
|
|
341
349
|
>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projects (focuses, goals) as ANSWERABLE, CITABLE records, the way tracked items are (bd startsim-tmrvi).
|
|
3
|
+
*
|
|
4
|
+
* Ask used to retrieve documents only. "What projects are active?" therefore searched a workspace's briefings and
|
|
5
|
+
* conversations for the word "projects" and answered "none of them matched" while 64 projects existed (live QA
|
|
6
|
+
* tenant, 2026-11-16). A project question is a question about states, which a keyword ranker over documents cannot
|
|
7
|
+
* answer: the projects are selected by status here, in code, and the model only phrases what it was handed.
|
|
8
|
+
* The id is `project:<id>`, which can never collide with a document or an `item:` id.
|
|
9
|
+
*/
|
|
10
|
+
import { displayProgress, focusStatusLabel } from './planning';
|
|
11
|
+
import { isInScope } from './retrieval';
|
|
12
|
+
import type { CorpusScope, Focus, FocusStatus, PlanningApi, RetrievedDocument, SourceDocument } from './types';
|
|
13
|
+
|
|
14
|
+
export const PROJECT_ID_PREFIX = 'project:';
|
|
15
|
+
/** The project id behind a cited record id, or null when it is a document or an item. */
|
|
16
|
+
export const projectIdOf = (documentId: string): string | null =>
|
|
17
|
+
documentId.startsWith(PROJECT_ID_PREFIX) ? documentId.slice(PROJECT_ID_PREFIX.length) : null;
|
|
18
|
+
export const PROJECT_SUBTYPE = 'project';
|
|
19
|
+
|
|
20
|
+
const PROJECT_WORDS = /\b(projects?|goals?|initiatives?|objectives?|okrs?)\b/i;
|
|
21
|
+
const IN_PLAY: FocusStatus[] = ['active', 'on_track', 'at_risk', 'off_track'];
|
|
22
|
+
const NOT_CANCELLED: FocusStatus[] = ['draft', 'active', 'on_track', 'at_risk', 'off_track', 'completed'];
|
|
23
|
+
|
|
24
|
+
export interface ProjectIntent { statuses: FocusStatus[] }
|
|
25
|
+
|
|
26
|
+
/** The intent, or null when the question is not about projects or goals at all. */
|
|
27
|
+
export function projectIntent(question: string): ProjectIntent | null {
|
|
28
|
+
const q = question.toLowerCase();
|
|
29
|
+
if (!PROJECT_WORDS.test(q)) return null;
|
|
30
|
+
let statuses: FocusStatus[] = NOT_CANCELLED;
|
|
31
|
+
if (/\bat[\s-]risk\b/.test(q)) statuses = ['at_risk'];
|
|
32
|
+
else if (/\boff[\s-]track\b|\bbehind\b|\bslipping\b/.test(q)) statuses = ['off_track'];
|
|
33
|
+
else if (/\bon[\s-]track\b/.test(q)) statuses = ['on_track'];
|
|
34
|
+
else if (/\bdraft(?:s|ed)?\b|\bplanned\b|\bnot started\b/.test(q)) statuses = ['draft'];
|
|
35
|
+
else if (/\b(complete[d]?|finish(?:ed)?|done|achieved|shipped)\b/.test(q)) statuses = ['completed'];
|
|
36
|
+
else if (/\b(cancel(?:l)?ed|dropped|abandoned)\b/.test(q)) statuses = ['cancelled'];
|
|
37
|
+
else if (/\b(active|current(?:ly)?|open|in progress|running|live|underway|ongoing)\b/.test(q)) statuses = IN_PLAY;
|
|
38
|
+
return { statuses };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** One project as a record the model can read and the screen can cite. */
|
|
42
|
+
export function projectAsDocument(focus: Focus): SourceDocument {
|
|
43
|
+
const progress = displayProgress(focus, null);
|
|
44
|
+
const lines = [
|
|
45
|
+
`Status: ${focusStatusLabel(focus.status)}`,
|
|
46
|
+
// "Active" in a question means in play: on track, at risk and off track projects are all active.
|
|
47
|
+
`Active (in play): ${IN_PLAY.includes(focus.status) ? 'yes' : 'no'}`,
|
|
48
|
+
focus.category ? `Category: ${focus.category}` : '',
|
|
49
|
+
focus.endDate ? `Due: ${focus.endDate.slice(0, 10)}` : '',
|
|
50
|
+
progress !== null && progress !== undefined ? `Progress: ${Math.round(progress * 100)}%` : '',
|
|
51
|
+
focus.targetValue ? `Target: ${focus.currentValue ?? 0} of ${focus.targetValue}${focus.unit ? ` ${focus.unit}` : ''}` : '',
|
|
52
|
+
focus.detail ? `Detail: ${focus.detail}` : '',
|
|
53
|
+
].filter(Boolean);
|
|
54
|
+
return {
|
|
55
|
+
id: `${PROJECT_ID_PREFIX}${focus.id}`,
|
|
56
|
+
title: focus.title,
|
|
57
|
+
body: lines.join('\n'),
|
|
58
|
+
sections: [],
|
|
59
|
+
occurredAt: focus.startDate ?? null,
|
|
60
|
+
source: 'planning',
|
|
61
|
+
sourceLabel: 'Project',
|
|
62
|
+
subtype: PROJECT_SUBTYPE,
|
|
63
|
+
sourceRef: focus.id,
|
|
64
|
+
participants: [],
|
|
65
|
+
scope: focus.scope,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Which of `focuses` the intent asks about, in the order worth reading. Pure. */
|
|
70
|
+
export function selectProjects(focuses: Focus[], intent: ProjectIntent): Focus[] {
|
|
71
|
+
const wanted = new Set(intent.statuses);
|
|
72
|
+
return focuses
|
|
73
|
+
.filter((f) => wanted.has(f.status))
|
|
74
|
+
.sort((a, b) => a.title.localeCompare(b.title));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Projects for a question: read, scope-check, select, convert. Empty when it is not a project question. */
|
|
78
|
+
export async function retrieveProjects(
|
|
79
|
+
question: string,
|
|
80
|
+
api: Pick<PlanningApi, 'listFocuses'> | undefined,
|
|
81
|
+
scope: CorpusScope,
|
|
82
|
+
limit: number,
|
|
83
|
+
): Promise<{ intent: ProjectIntent | null; retrieved: RetrievedDocument[]; matched: number }> {
|
|
84
|
+
const intent = projectIntent(question);
|
|
85
|
+
if (!intent || !api) return { intent: null, retrieved: [], matched: 0 };
|
|
86
|
+
const page = await api.listFocuses({ pageSize: 200 }).catch(() => null);
|
|
87
|
+
if (!page) return { intent, retrieved: [], matched: 0 };
|
|
88
|
+
const selected = selectProjects(page.results.filter((f) => isInScope(f, scope)), intent);
|
|
89
|
+
const retrieved = selected.slice(0, limit).map((focus): RetrievedDocument => {
|
|
90
|
+
const document = projectAsDocument(focus);
|
|
91
|
+
return { document, score: 1, matchedTerms: [], snippet: document.body.split('\n').slice(0, 2).join(' · ') };
|
|
92
|
+
});
|
|
93
|
+
return { intent, retrieved, matched: selected.length };
|
|
94
|
+
}
|
package/src/corpus/ask.ts
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* given has invented a source, and the only safe rendering of that is to say so.
|
|
20
20
|
*/
|
|
21
21
|
import { retrieveItems } from './ask-items';
|
|
22
|
+
import { retrieveProjects } from './ask-projects';
|
|
22
23
|
import { moneyEventAsDocument } from './entities';
|
|
23
24
|
import { retrieveForQuestion, searchTermFor } from './retrieval';
|
|
24
25
|
import { documentText } from './text';
|
|
@@ -30,6 +31,7 @@ import type {
|
|
|
30
31
|
CommitmentApi,
|
|
31
32
|
CorpusApi,
|
|
32
33
|
CorpusLlm,
|
|
34
|
+
PlanningApi,
|
|
33
35
|
PromptDocument,
|
|
34
36
|
RetrievedDocument,
|
|
35
37
|
SourceDocument,
|
|
@@ -349,7 +351,7 @@ function noEvidenceCopy(total: number): string {
|
|
|
349
351
|
*/
|
|
350
352
|
export async function askCorpus(
|
|
351
353
|
request: AskRequest,
|
|
352
|
-
deps: { corpus: CorpusApi; llm: CorpusLlm; commitments?: Pick<CommitmentApi, 'listCommitments'> },
|
|
354
|
+
deps: { corpus: CorpusApi; llm: CorpusLlm; commitments?: Pick<CommitmentApi, 'listCommitments'>; /** Lets a project or goal question be answered from the projects themselves. */ projects?: Pick<PlanningApi, 'listFocuses'> },
|
|
353
355
|
options: AskCorpusOptions = {},
|
|
354
356
|
): Promise<AskResult> {
|
|
355
357
|
const { candidateLimit, contextLimit, maxCharsPerDocument, itemLimit } = { ...DEFAULTS, ...options };
|
|
@@ -384,10 +386,27 @@ export async function askCorpus(
|
|
|
384
386
|
itemLimit,
|
|
385
387
|
)
|
|
386
388
|
: { intent: null, retrieved: [], matched: 0 };
|
|
387
|
-
|
|
389
|
+
// PROJECTS, the same way: a question about them is answered from their status, not from document text.
|
|
390
|
+
const projectHits = request.mode === 'ask'
|
|
391
|
+
? await retrieveProjects(request.question, deps.projects, request.scope, itemLimit)
|
|
392
|
+
: { intent: null, retrieved: [], matched: 0 };
|
|
393
|
+
const retrieved = [...items.retrieved, ...projectHits.retrieved, ...documents];
|
|
388
394
|
|
|
389
395
|
const freshness = await corpus.listSources().catch(() => [] as SourceFreshness[]);
|
|
390
396
|
|
|
397
|
+
if (retrieved.length === 0 && projectHits.intent && deps.projects) {
|
|
398
|
+
return {
|
|
399
|
+
status: 'no_evidence',
|
|
400
|
+
answer: 'No projects match that, and no documents do either.',
|
|
401
|
+
citations: [],
|
|
402
|
+
considered: [],
|
|
403
|
+
unresolvedCitations: [],
|
|
404
|
+
droppedOutOfScope,
|
|
405
|
+
provider: llm.describe(),
|
|
406
|
+
freshness,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
|
|
391
410
|
if (retrieved.length === 0 && items.intent && deps.commitments) {
|
|
392
411
|
return {
|
|
393
412
|
status: 'no_evidence',
|
package/src/corpus/index.ts
CHANGED
|
@@ -330,3 +330,6 @@ export * from './liability-plan';
|
|
|
330
330
|
export * from './liability-client';
|
|
331
331
|
// Tab names and one-line subtitles shared by the web and iPhone shells.
|
|
332
332
|
export * from './nav-copy';
|
|
333
|
+
|
|
334
|
+
// Projects as answerable records for Ask.
|
|
335
|
+
export { PROJECT_ID_PREFIX, projectIdOf, projectIntent, retrieveProjects, selectProjects } from './ask-projects';
|
|
@@ -95,7 +95,7 @@ export const BUILTIN_FACTORIES: Record<string, ScreenFactory> = {
|
|
|
95
95
|
},
|
|
96
96
|
tracker: ({ config, corpus, member, openUrl, itemsChanged }, tab) => trackerTab({ api: corpus, itemsChanged, key: tab.key, label: tabLabel(tab), notesKey: firstKey(config, 'notes'), memberConnections: member.connections, openUrl }),
|
|
97
97
|
plan: ({ config, corpus, member, openUrl, itemsChanged }, tab) => planTab({ api: corpus, key: tab.key, label: tabLabel(tab), notesKey: firstKey(config, 'notes'), documentTab: firstKey(config, 'library'), memberConnections: member.connections, openUrl, itemsChanged }),
|
|
98
|
-
talk: ({ config, corpus, converse, converseSpeed }, tab) => talkTab({ api: corpus, converse, speed: converseSpeed, key: tab.key, label: tabLabel(tab), libraryKey: firstKey(config, 'library') }),
|
|
98
|
+
talk: ({ config, corpus, converse, converseSpeed }, tab) => talkTab({ api: corpus, converse, speed: converseSpeed, key: tab.key, label: tabLabel(tab), libraryKey: firstKey(config, 'library'), planKey: firstKey(config, 'plan') }),
|
|
99
99
|
library: ({ config, corpus }, tab) => libraryTab(corpus, { key: tab.key, label: tabLabel(tab), planKey: firstKey(config, 'plan') }),
|
|
100
100
|
ask: ({ corpus }, tab) => askTab(corpus, { key: tab.key, label: tabLabel(tab) }),
|
|
101
101
|
planning: ({ config, corpus }, tab) => createPlanningTab({ api: corpus, key: tab.key, label: tabLabel(tab), documentTab: firstKey(config, 'library') }),
|
|
@@ -2,6 +2,7 @@ import { useMemo, useState } from 'react';
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { Header, SegmentedControl, Text, useTheme } from '@startsimpli/ui-native';
|
|
4
4
|
import { TAB_COPY, TALK_MODES, type TalkMode } from '../../corpus/nav-copy';
|
|
5
|
+
import { projectIdOf } from '../../corpus/ask-projects';
|
|
5
6
|
import type { MeetingController } from '../../corpus/converse/meeting';
|
|
6
7
|
import type { FoundryTab, TabContext } from '../components/FoundryTabsShell';
|
|
7
8
|
import type { NativeCorpusApi } from '../corpus/api';
|
|
@@ -21,11 +22,13 @@ export interface TalkTabOptions {
|
|
|
21
22
|
label?: string;
|
|
22
23
|
/** The Library tab, where a cited source opens. */
|
|
23
24
|
libraryKey?: string;
|
|
25
|
+
/** The Plan tab, where a cited PROJECT opens. */
|
|
26
|
+
planKey?: string;
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
function TalkBody({ opts, ctx }: { opts: TalkTabOptions; ctx: TabContext }) {
|
|
27
30
|
const theme = useTheme();
|
|
28
|
-
const { api, converse, speed, libraryKey = 'library' } = opts;
|
|
31
|
+
const { api, converse, speed, libraryKey = 'library', planKey } = opts;
|
|
29
32
|
const modes = TALK_MODES.filter((m) => m.key === 'ask' || converse);
|
|
30
33
|
// `-tgTab talk -tgDetail ask` (and a link) land on Ask.
|
|
31
34
|
const [mode, setMode] = useState<TalkMode>(ctx.route?.id === 'ask' || !converse ? 'ask' : 'talk');
|
|
@@ -47,7 +50,7 @@ function TalkBody({ opts, ctx }: { opts: TalkTabOptions; ctx: TabContext }) {
|
|
|
47
50
|
</View>
|
|
48
51
|
) : null}
|
|
49
52
|
<View style={{ flex: 1, display: current.key === 'ask' ? 'flex' : 'none' }}>
|
|
50
|
-
<AskScreen controller={ask} onOpenDocument={(id) => ctx.openTab(libraryKey, id)} embedded />
|
|
53
|
+
<AskScreen controller={ask} onOpenDocument={(id) => { const project = projectIdOf(id); if (project && planKey) ctx.openTab(planKey, `project/${project}`); else ctx.openTab(libraryKey, id); }} embedded />
|
|
51
54
|
</View>
|
|
52
55
|
</View>
|
|
53
56
|
);
|