@supa-media/tex-contract 0.0.0-stage → 0.2.7
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/LICENSE +21 -0
- package/README.md +11 -2
- package/package.json +16 -4
- package/texContract/aboutLines.cjs +117 -0
- package/texContract/aboutLines.d.cts +14 -0
- package/texContract/aboutNoteLimits.cjs +41 -0
- package/texContract/aboutNoteLimits.d.cts +5 -0
- package/texContract/actionManual.cjs +104 -0
- package/texContract/activityHint.cjs +40 -0
- package/texContract/activityHint.d.cts +4 -0
- package/texContract/asks.cjs +16 -0
- package/texContract/asks.d.cts +6 -0
- package/texContract/asksToFile.cjs +20 -0
- package/texContract/asksToFile.d.cts +2 -0
- package/texContract/attention.cjs +138 -0
- package/texContract/attention.d.cts +20 -0
- package/texContract/browserHandback.cjs +13 -0
- package/texContract/browserHandback.d.cts +3 -0
- package/texContract/browserOwner.cjs +31 -0
- package/texContract/browserOwner.d.cts +2 -0
- package/texContract/bytes.cjs +12 -0
- package/texContract/chatHistoryPath.cjs +38 -0
- package/texContract/chatHistoryPath.d.cts +5 -0
- package/texContract/chatLedger.cjs +91 -0
- package/texContract/chatLedger.d.cts +21 -0
- package/texContract/computerTool.cjs +102 -0
- package/texContract/computerTool.d.cts +16 -0
- package/texContract/consentYes.cjs +22 -0
- package/texContract/consentYes.d.cts +5 -0
- package/texContract/contextGateway.cjs +52 -0
- package/texContract/contextGateway.d.cts +19 -0
- package/texContract/deskEligible.cjs +20 -0
- package/texContract/deskEligible.d.cts +3 -0
- package/texContract/downloads.cjs +129 -0
- package/texContract/downloads.d.cts +15 -0
- package/texContract/egressLedger.cjs +114 -0
- package/texContract/egressLedger.d.cts +14 -0
- package/texContract/emailRead.cjs +38 -0
- package/texContract/emailRead.d.cts +5 -0
- package/texContract/eventWords.cjs +35 -0
- package/texContract/eventWords.d.cts +4 -0
- package/texContract/fileParts.cjs +43 -0
- package/texContract/fileParts.d.cts +6 -0
- package/texContract/fileTables.cjs +243 -0
- package/texContract/fileWords.cjs +169 -0
- package/texContract/folded.cjs +16 -0
- package/texContract/folded.d.cts +3 -0
- package/texContract/googleAiAccess.cjs +12 -0
- package/texContract/googleAiAccess.d.cts +2 -0
- package/texContract/graphWires.cjs +18 -0
- package/texContract/graphWires.d.cts +5 -0
- package/texContract/groupSession.cjs +28 -0
- package/texContract/groupSession.d.cts +7 -0
- package/texContract/guestNames.cjs +136 -0
- package/texContract/guestNames.d.cts +35 -0
- package/texContract/heard.cjs +19 -0
- package/texContract/heard.d.cts +4 -0
- package/texContract/heldOffer.cjs +57 -0
- package/texContract/heldOffer.d.cts +8 -0
- package/texContract/helperCallers.cjs +29 -0
- package/texContract/helperCallers.d.cts +4 -0
- package/texContract/identity.cjs +179 -0
- package/texContract/identity.d.cts +8 -0
- package/texContract/jobLogEntries.cjs +93 -0
- package/texContract/jobLogEntries.d.cts +12 -0
- package/texContract/judgedActions.cjs +20 -0
- package/texContract/judgedActions.d.cts +4 -0
- package/texContract/labSandboxGate.cjs +63 -0
- package/texContract/labSandboxGate.d.cts +9 -0
- package/texContract/ledgerReadChars.cjs +4 -0
- package/texContract/ledgerReadChars.d.cts +3 -0
- package/texContract/mailCheck.cjs +90 -0
- package/texContract/mailCheck.d.cts +12 -0
- package/texContract/mailEntries.cjs +64 -0
- package/texContract/mailEntries.d.cts +13 -0
- package/texContract/mailHealth.cjs +60 -0
- package/texContract/mailHealth.d.cts +10 -0
- package/texContract/notePath.cjs +99 -0
- package/texContract/notePath.d.cts +4 -0
- package/texContract/noteRunFacts.cjs +136 -0
- package/texContract/noteRunFacts.d.cts +32 -0
- package/texContract/objectEtag.cjs +84 -0
- package/texContract/objectEtag.d.cts +4 -0
- package/texContract/objectPlace.cjs +32 -0
- package/texContract/objectPlace.d.cts +5 -0
- package/texContract/pageJobs.cjs +226 -0
- package/texContract/pageJobs.d.cts +13 -0
- package/texContract/pdfLinks.cjs +135 -0
- package/texContract/pdfLinks.d.cts +4 -0
- package/texContract/personHub.cjs +38 -0
- package/texContract/personHub.d.cts +5 -0
- package/texContract/personNameText.cjs +18 -0
- package/texContract/personNameText.d.cts +3 -0
- package/texContract/pinnedContext.cjs +12 -0
- package/texContract/pinnedContext.d.cts +3 -0
- package/texContract/quietHoursWindow.cjs +36 -0
- package/texContract/quietHoursWindow.d.cts +3 -0
- package/texContract/scopeClamp.cjs +117 -0
- package/texContract/scopeClamp.d.cts +5 -0
- package/texContract/scopes.cjs +29 -0
- package/texContract/scopes.d.cts +7 -0
- package/texContract/searchSettings.cjs +54 -0
- package/texContract/searchSettings.d.cts +6 -0
- package/texContract/settingHabits.cjs +87 -0
- package/texContract/settingHabits.d.cts +20 -0
- package/texContract/settingsNotes.cjs +217 -0
- package/texContract/settingsNotes.d.cts +26 -0
- package/texContract/shownEmail.cjs +181 -0
- package/texContract/texClients.cjs +53 -0
- package/texContract/texClients.d.cts +12 -0
- package/texContract/texGraph.cjs +593 -0
- package/texContract/texGraph.d.cts +55 -0
- package/texContract/texKeys.cjs +100 -0
- package/texContract/texKeys.d.cts +13 -0
- package/texContract/texOwnSources.cjs +9 -0
- package/texContract/texOwnSources.d.cts +3 -0
- package/texContract/texStoreNames.cjs +26 -0
- package/texContract/texStoreNames.d.cts +12 -0
- package/texContract/texStoreWire.cjs +306 -0
- package/texContract/texStoreWire.d.cts +32 -0
- package/texContract/threadsFold.cjs +75 -0
- package/texContract/threadsFold.d.cts +22 -0
- package/texContract/toolActions.cjs +253 -0
- package/texContract/toolCatalog.cjs +49 -0
- package/texContract/toolCatalog.generated.json +90 -0
- package/texContract/toolContract.cjs +52 -0
- package/texContract/toolContract.d.cts +12 -0
- package/texContract/toolShapes.cjs +14 -0
- package/texContract/transcription.cjs +101 -0
- package/texContract/transcription.d.cts +3 -0
- package/texContract/treeJobs.cjs +31 -0
- package/texContract/treeJobs.d.cts +3 -0
- package/texContract/turnSession.cjs +90 -0
- package/texContract/turnSession.d.cts +19 -0
- package/texContract/turnWords.cjs +90 -0
- package/texContract/turnWords.d.cts +9 -0
- package/texContract/uploadImages.cjs +131 -0
- package/texContract/uploadImages.d.cts +13 -0
- package/texContract/v2Names.cjs +41 -0
- package/texContract/v2SearchFetch.cjs +316 -0
- package/texContract/v2Translate.cjs +123 -0
- package/texContract/vaultTools.cjs +112 -0
- package/texContract/vaultTools.d.cts +15 -0
- package/texContract/yesWords.cjs +91 -0
- package/texShared/argumentCoercion.cjs +93 -0
- package/texShared/cellComments.cjs +122 -0
- package/texShared/cellComments.d.cts +21 -0
- package/texShared/comments.cjs +586 -0
- package/texShared/comments.d.cts +115 -0
- package/texShared/contentTypes.cjs +85 -0
- package/texShared/fileKinds.cjs +123 -0
- package/texShared/flags.cjs +124 -0
- package/texShared/flags.d.cts +21 -0
- package/texShared/folderJobInfo.cjs +301 -0
- package/texShared/folderJobInfo.d.cts +40 -0
- package/texShared/folderRoles.cjs +512 -0
- package/texShared/folderRoles.d.cts +73 -0
- package/texShared/githubOidc.ts +98 -0
- package/texShared/groupRunQuestions.cjs +98 -0
- package/texShared/groupRunQuestions.d.cts +4 -0
- package/texShared/inboxFolders.cjs +49 -0
- package/texShared/inboxFolders.d.cts +5 -0
- package/texShared/ink/drawing.cjs +474 -0
- package/texShared/ink/texFigure.cjs +252 -0
- package/texShared/ink/texFigure.d.cts +36 -0
- package/texShared/ink/texPoses.cjs +180 -0
- package/texShared/ink/texPoses.d.cts +20 -0
- package/texShared/jobPartEnd.cjs +133 -0
- package/texShared/jobPartEnd.d.cts +13 -0
- package/texShared/jobResume.cjs +31 -0
- package/texShared/jobResume.d.cts +5 -0
- package/texShared/jobSplit.cjs +90 -0
- package/texShared/jobSplit.d.cts +6 -0
- package/texShared/jobStart.cjs +56 -0
- package/texShared/jobStart.d.cts +9 -0
- package/texShared/mail.cjs +400 -0
- package/texShared/mail.d.cts +56 -0
- package/texShared/messageAnchors.cjs +38 -0
- package/texShared/models/aiKeys.cjs +137 -0
- package/texShared/models/aiKeys.d.cts +42 -0
- package/texShared/models/aiKeys.json +56 -0
- package/texShared/models/creditRest.cjs +269 -0
- package/texShared/models/promptBudget.cjs +295 -0
- package/texShared/models/promptSections.cjs +29 -0
- package/texShared/noteAppLink.cjs +23 -0
- package/texShared/notePreview.cjs +219 -0
- package/texShared/notePreview.d.cts +21 -0
- package/texShared/pages/blocks.cjs +215 -0
- package/texShared/pages/cover.cjs +164 -0
- package/texShared/pages/css.cjs +181 -0
- package/texShared/pages/cssBlocks.cjs +264 -0
- package/texShared/pages/draw.cjs +212 -0
- package/texShared/pages/drawRich.cjs +232 -0
- package/texShared/pages/html.cjs +168 -0
- package/texShared/pages/inline.cjs +251 -0
- package/texShared/pages/layout.cjs +76 -0
- package/texShared/pages/parse.cjs +418 -0
- package/texShared/pages/render.cjs +200 -0
- package/texShared/pages/skill.cjs +147 -0
- package/texShared/pages/skill.d.cts +5 -0
- package/texShared/pages/templates.cjs +336 -0
- package/texShared/r2Store.cjs +163 -0
- package/texShared/remoteImage.cjs +177 -0
- package/texShared/routines.cjs +656 -0
- package/texShared/routines.d.cts +86 -0
- package/texShared/servedListing.cjs +250 -0
- package/texShared/servedListing.d.cts +17 -0
- package/texShared/sheetCsv.cjs +566 -0
- package/texShared/sheetCsv.d.cts +91 -0
- package/texShared/storageLayout.cjs +88 -0
- package/texShared/storeKeys.cjs +144 -0
- package/texShared/toolArguments.cjs +323 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each built-in folder's job is for, in the words people and AI clients
|
|
3
|
+
* read, which jobs a person may hand to another folder or take away, and the
|
|
4
|
+
* guesses offered when a workspace's folders do not say their jobs (decided by
|
|
5
|
+
* the owner, 2026-10-18, picking every board of `folder-jobs-marking`;
|
|
6
|
+
* `docs/decisions/app-and-console/folder-jobs.md`).
|
|
7
|
+
*
|
|
8
|
+
* One module, read by the control plane (Settings › Built-in folders, the
|
|
9
|
+
* import picker, `folder_job`), the gateway (orient) and the app, so the line
|
|
10
|
+
* a person reads in Settings is the line an agent reads in orient.
|
|
11
|
+
*
|
|
12
|
+
* ## Three groups
|
|
13
|
+
*
|
|
14
|
+
* - **needed**: Inbox, Projects, Areas, Resources, Archive. Every workspace
|
|
15
|
+
* has one of each. Each can be given to another folder, never taken away.
|
|
16
|
+
* - **made**: Tex, Website, Data and Bots, made by Context the first time the
|
|
17
|
+
* feature is used. All three can be renamed and nested anywhere (Website
|
|
18
|
+
* since 2026-10-21); Website's job stays with its own folder, which its
|
|
19
|
+
* site is published from. Data's folder holds a workspace's data sources,
|
|
20
|
+
* one subfolder each, and its own `metrics/` (`DATA_PARTS`).
|
|
21
|
+
* - **optional**: Clients, Teams, Products, added when useful and removable.
|
|
22
|
+
*
|
|
23
|
+
* Meetings is a job on rows (its folder follows the meetings setting) but is
|
|
24
|
+
* shown as one of the Inbox's own folders, not a line of its own: the owner,
|
|
25
|
+
* 2026-10-18, "fold under inbox". Routines live in Tex's folder
|
|
26
|
+
* (`tex/routines/`), so they are part of Tex's line.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const { BOTS_FOLDER, DATA_FOLDER, DEFAULT_FOLDER, JOB_LABEL, MAIN_ROLES, EXTRA_ROLES, NO_JOB, ROW_ROLES, TEX_FOLDER, WEBSITE_FOLDER } = require("./folderRoles.cjs");
|
|
30
|
+
|
|
31
|
+
/** The jobs shown as lines, in the order they are drawn. */
|
|
32
|
+
const SHOWN_JOBS = Object.freeze([...MAIN_ROLES, "tex", "website", "data", "bots", ...EXTRA_ROLES]);
|
|
33
|
+
|
|
34
|
+
const JOB_GROUP = Object.freeze({
|
|
35
|
+
inbox: "needed",
|
|
36
|
+
projects: "needed",
|
|
37
|
+
areas: "needed",
|
|
38
|
+
resources: "needed",
|
|
39
|
+
archive: "needed",
|
|
40
|
+
tex: "made",
|
|
41
|
+
website: "made",
|
|
42
|
+
data: "made",
|
|
43
|
+
bots: "made",
|
|
44
|
+
meetings: "made",
|
|
45
|
+
clients: "optional",
|
|
46
|
+
teams: "optional",
|
|
47
|
+
products: "optional",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const GROUP_LABEL = Object.freeze({ needed: "Needed", made: "Made when used", optional: "Optional" });
|
|
51
|
+
|
|
52
|
+
/** One line per job: what Context does with that folder. */
|
|
53
|
+
const JOB_LINE = Object.freeze({
|
|
54
|
+
inbox: "Email, meetings and quick captures land here until they're filed.",
|
|
55
|
+
projects: "Work with a finish line, one folder each. Status, owner and due date show here.",
|
|
56
|
+
areas: "Ongoing responsibilities with no finish line.",
|
|
57
|
+
resources: "Reference worth finding again.",
|
|
58
|
+
archive: "Finished things. The Archive button files here.",
|
|
59
|
+
tex: "What Tex remembers about you, its routines and its daily notes.",
|
|
60
|
+
website: "Pages here are published to your site.",
|
|
61
|
+
data: "Data sources and metrics: synced sheets and the formulas worked out from them.",
|
|
62
|
+
bots: "One folder per bot: its card, its mail and where it works.",
|
|
63
|
+
meetings: "Recordings and transcripts are saved here.",
|
|
64
|
+
clients: "One folder per client: who they are and what was promised.",
|
|
65
|
+
teams: "One folder per team: what it owns and how it runs.",
|
|
66
|
+
products: "One folder per product: what it is and who it's for.",
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The folders Context itself files into inside the Inbox, by their exact
|
|
71
|
+
* names one level down (the same list `folderIcons.cjs` draws defaults for).
|
|
72
|
+
* They stay where they are: a person can add notes and folders of their own
|
|
73
|
+
* beside them, but not rename or move these (owner, 2026-10-18).
|
|
74
|
+
*/
|
|
75
|
+
const INBOX_PARTS = Object.freeze([
|
|
76
|
+
"calendar",
|
|
77
|
+
"contacts",
|
|
78
|
+
"email",
|
|
79
|
+
"forms",
|
|
80
|
+
"google-chat",
|
|
81
|
+
"imessage",
|
|
82
|
+
"meetings",
|
|
83
|
+
"memories",
|
|
84
|
+
"sessions",
|
|
85
|
+
]);
|
|
86
|
+
|
|
87
|
+
const INBOX_PART_LABEL = Object.freeze({
|
|
88
|
+
calendar: "Calendar",
|
|
89
|
+
contacts: "Contacts",
|
|
90
|
+
email: "Email",
|
|
91
|
+
forms: "Forms",
|
|
92
|
+
"google-chat": "Google Chat",
|
|
93
|
+
imessage: "iMessage",
|
|
94
|
+
meetings: "Meetings",
|
|
95
|
+
memories: "Memories",
|
|
96
|
+
sessions: "Sessions",
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/** A job a person or an agent may give to a folder they name. Website's stays with the folder its site is published from. */
|
|
100
|
+
function canGiveJob(job) {
|
|
101
|
+
return SHOWN_JOBS.includes(job) && job !== "website";
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** A job that may be taken away, leaving no folder doing it. */
|
|
105
|
+
function canRemoveJob(job) {
|
|
106
|
+
return EXTRA_ROLES.includes(job);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Jobs whose folder must sit at the top of the workspace. */
|
|
110
|
+
function topOnly(job) {
|
|
111
|
+
return job === "archive";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Whether `path` is one of the Inbox's own folders, given the path of the
|
|
116
|
+
* folder doing the Inbox's job now (null: no Inbox, nothing is).
|
|
117
|
+
*/
|
|
118
|
+
function isInboxPart(path, inboxPath) {
|
|
119
|
+
if (typeof path !== "string" || typeof inboxPath !== "string" || inboxPath === "") return false;
|
|
120
|
+
const clean = path.replace(/^\/+|\/+$/g, "");
|
|
121
|
+
if (!clean.startsWith(`${inboxPath}/`)) return false;
|
|
122
|
+
const rest = clean.slice(inboxPath.length + 1);
|
|
123
|
+
return !rest.includes("/") && INBOX_PARTS.includes(rest);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Tex's own folders, by their exact names one level inside Tex's folder
|
|
128
|
+
* (owner, 2026-10-21, "Context icon set" board 4): Tex files into each by
|
|
129
|
+
* name, so like the Inbox's own they stay where they are, are drawn with
|
|
130
|
+
* Context's icons (`folderIcons.cjs`), and a person adds notes and folders of
|
|
131
|
+
* their own beside them.
|
|
132
|
+
*/
|
|
133
|
+
const TEX_PARTS = Object.freeze(["attention", "chats", "dreams", "groups", "handbacks", "heartbeat", "housekeeping", "pictures", "routines", "skills", "templates", "transcripts"]);
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The folders a person's Tex has that a group chat's home cannot: `chats` and
|
|
137
|
+
* `groups` hold the chats themselves, and `transcripts` is no longer written
|
|
138
|
+
* (2026-11-02). Every other Tex folder stands in every home
|
|
139
|
+
* (`HOME_TEX_PARTS`), so a folder added to `TEX_PARTS` reaches the homes
|
|
140
|
+
* unless it is named here (owner, 2026-11-02: "I want 1:1 tex and group tex
|
|
141
|
+
* to start mirroring each other and not diverging so much").
|
|
142
|
+
*/
|
|
143
|
+
const PERSON_ONLY_TEX_PARTS = Object.freeze(["chats", "groups", "transcripts"]);
|
|
144
|
+
|
|
145
|
+
/** The folders every group chat's home holds: Tex's own, less the person-only ones. */
|
|
146
|
+
const HOME_TEX_PARTS = Object.freeze(TEX_PARTS.filter((part) => !PERSON_ONLY_TEX_PARTS.includes(part)));
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Whether `path` is one of Tex's own folders, given the path of the folder
|
|
150
|
+
* doing Tex's job now (null: no Tex folder, nothing is).
|
|
151
|
+
*/
|
|
152
|
+
function isTexPart(path, texPath) {
|
|
153
|
+
if (typeof path !== "string" || typeof texPath !== "string" || texPath === "") return false;
|
|
154
|
+
const clean = path.replace(/^\/+|\/+$/g, "");
|
|
155
|
+
if (!clean.startsWith(`${texPath}/`)) return false;
|
|
156
|
+
const rest = clean.slice(texPath.length + 1);
|
|
157
|
+
return !rest.includes("/") && TEX_PARTS.includes(rest);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The data folder's own folders, by their exact names one level inside it:
|
|
162
|
+
* `metrics`, where each metric is a note (`data/metrics/<name>.md`). Kept
|
|
163
|
+
* like Tex's own: Context reads metrics there by name, so the folder keeps its
|
|
164
|
+
* name and place wherever the data folder is nested, and a person adds notes
|
|
165
|
+
* and folders beside it. Each source's subfolder is the person's to rename.
|
|
166
|
+
*/
|
|
167
|
+
const DATA_PARTS = Object.freeze(["metrics"]);
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Whether `path` is one of the data folder's own folders, given the path of
|
|
171
|
+
* the folder doing the Data job now (null: no data folder, nothing is).
|
|
172
|
+
*/
|
|
173
|
+
function isDataPart(path, dataPath) {
|
|
174
|
+
if (typeof path !== "string" || typeof dataPath !== "string" || dataPath === "") return false;
|
|
175
|
+
const clean = path.replace(/^\/+|\/+$/g, "");
|
|
176
|
+
if (!clean.startsWith(`${dataPath}/`)) return false;
|
|
177
|
+
const rest = clean.slice(dataPath.length + 1);
|
|
178
|
+
return !rest.includes("/") && DATA_PARTS.includes(rest);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Words a folder's name may use for a job, besides the job's own name. Kept
|
|
183
|
+
* short on purpose: a guess the person has to untick costs more than one
|
|
184
|
+
* they have to pick.
|
|
185
|
+
*/
|
|
186
|
+
const SYNONYMS = Object.freeze({
|
|
187
|
+
inbox: ["inbox", "capture", "captures", "intake", "unsorted", "unfiled"],
|
|
188
|
+
projects: ["projects", "project", "active projects"],
|
|
189
|
+
areas: ["areas", "area", "areas of responsibility", "responsibilities"],
|
|
190
|
+
resources: ["resources", "resource", "reference", "references", "library"],
|
|
191
|
+
archive: ["archive", "archives", "archived"],
|
|
192
|
+
clients: ["clients", "client", "customers"],
|
|
193
|
+
teams: ["teams", "team"],
|
|
194
|
+
products: ["products", "product"],
|
|
195
|
+
tex: ["tex"],
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
/** A folder name as words: no leading number, emoji or punctuation, lower case. */
|
|
199
|
+
function nameWords(name) {
|
|
200
|
+
return String(name)
|
|
201
|
+
.normalize("NFKC")
|
|
202
|
+
.toLowerCase()
|
|
203
|
+
.replace(/[^\p{L}\p{N}]+/gu, " ")
|
|
204
|
+
.trim()
|
|
205
|
+
.replace(/^\d+\s*/, "")
|
|
206
|
+
.replace(/\s+/g, " ");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** What a name says it is, and how plainly: `own` (its job's name), `synonym`, or null. */
|
|
210
|
+
function nameSays(name) {
|
|
211
|
+
const words = nameWords(name);
|
|
212
|
+
if (words === "") return null;
|
|
213
|
+
for (const job of Object.keys(SYNONYMS)) {
|
|
214
|
+
const index = SYNONYMS[job].indexOf(words);
|
|
215
|
+
if (index < 0) continue;
|
|
216
|
+
return { job, own: index === 0 || words === JOB_LABEL[job].toLowerCase() };
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** Folders deeper than this are never guessed: past it, a name is somebody's own sub-topic. */
|
|
222
|
+
const GUESS_DEPTH = 3;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* For each shown job no folder does yet (`jobs.jobs[job] === null`), the
|
|
226
|
+
* folder whose name most plainly says it, with why: `{job, path, why}`.
|
|
227
|
+
* `folders` are the folders the caller can see, `{path}`; a folder already
|
|
228
|
+
* doing a job, or one a person said does none (`role: "none"`), is never
|
|
229
|
+
* guessed. Shallower beats deeper, the job's own word beats another word,
|
|
230
|
+
* then the path that sorts first, so the answer does not depend on listing
|
|
231
|
+
* order. Archive is guessed only at the top.
|
|
232
|
+
*/
|
|
233
|
+
function guessFolderJobs(folders, jobs) {
|
|
234
|
+
const taken = new Set(Object.values(jobs?.jobs ?? {}).filter((path) => typeof path === "string"));
|
|
235
|
+
const best = {};
|
|
236
|
+
for (const folder of folders) {
|
|
237
|
+
const path = typeof folder?.path === "string" ? folder.path.replace(/^\/+|\/+$/g, "") : "";
|
|
238
|
+
if (path === "" || taken.has(path) || folder.role === NO_JOB || ROW_ROLES.includes(folder.role)) continue;
|
|
239
|
+
const segments = path.split("/");
|
|
240
|
+
if (segments.length > GUESS_DEPTH) continue;
|
|
241
|
+
const said = nameSays(segments[segments.length - 1]);
|
|
242
|
+
if (said === null || !SHOWN_JOBS.includes(said.job) || jobs?.jobs?.[said.job] !== null) continue;
|
|
243
|
+
if (topOnly(said.job) && segments.length > 1) continue;
|
|
244
|
+
const rank = [segments.length, said.own ? 0 : 1, path];
|
|
245
|
+
const held = best[said.job];
|
|
246
|
+
if (held === undefined || compareRank(rank, held.rank) < 0) best[said.job] = { rank, said, path, depth: segments.length };
|
|
247
|
+
}
|
|
248
|
+
const guesses = [];
|
|
249
|
+
for (const job of SHOWN_JOBS) {
|
|
250
|
+
const held = best[job];
|
|
251
|
+
if (held === undefined) continue;
|
|
252
|
+
const label = JOB_LABEL[job];
|
|
253
|
+
const why = held.said.own ? (held.depth > 1 ? `nested, name says ${label}` : `name says ${label}`) : `another word for ${label}`;
|
|
254
|
+
guesses.push({ job, path: held.path, why });
|
|
255
|
+
}
|
|
256
|
+
return guesses;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function compareRank(a, b) {
|
|
260
|
+
if (a[0] !== b[0]) return a[0] - b[0];
|
|
261
|
+
if (a[1] !== b[1]) return a[1] - b[1];
|
|
262
|
+
return a[2] < b[2] ? -1 : a[2] > b[2] ? 1 : 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** The name a job's folder gets when Context makes it at the top. */
|
|
266
|
+
function defaultFolderName(job) {
|
|
267
|
+
if (job === "website") return WEBSITE_FOLDER;
|
|
268
|
+
if (job === "tex") return TEX_FOLDER;
|
|
269
|
+
if (job === "data") return DATA_FOLDER;
|
|
270
|
+
if (job === "bots") return BOTS_FOLDER;
|
|
271
|
+
return DEFAULT_FOLDER[job] ?? null;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** The jobs Context offers by name, for an answer to somebody asking for one it does not have. */
|
|
275
|
+
function jobNames() {
|
|
276
|
+
return SHOWN_JOBS.join(", ");
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
module.exports = {
|
|
280
|
+
SHOWN_JOBS,
|
|
281
|
+
JOB_GROUP,
|
|
282
|
+
GROUP_LABEL,
|
|
283
|
+
JOB_LINE,
|
|
284
|
+
INBOX_PARTS,
|
|
285
|
+
INBOX_PART_LABEL,
|
|
286
|
+
canGiveJob,
|
|
287
|
+
canRemoveJob,
|
|
288
|
+
topOnly,
|
|
289
|
+
isInboxPart,
|
|
290
|
+
TEX_PARTS,
|
|
291
|
+
PERSON_ONLY_TEX_PARTS,
|
|
292
|
+
HOME_TEX_PARTS,
|
|
293
|
+
isTexPart,
|
|
294
|
+
DATA_PARTS,
|
|
295
|
+
isDataPart,
|
|
296
|
+
nameWords,
|
|
297
|
+
nameSays,
|
|
298
|
+
guessFolderJobs,
|
|
299
|
+
defaultFolderName,
|
|
300
|
+
jobNames,
|
|
301
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Types for `folderJobInfo.cjs`; see that file for the rules and the reasons. */
|
|
2
|
+
|
|
3
|
+
import type { FolderJobs, RowRole } from "./folderRoles.cjs";
|
|
4
|
+
|
|
5
|
+
export type JobGroup = "needed" | "made" | "optional";
|
|
6
|
+
export type ShownJob = Exclude<RowRole, "meetings">;
|
|
7
|
+
export type InboxPart = "calendar" | "contacts" | "email" | "forms" | "google-chat" | "imessage" | "meetings" | "memories" | "sessions";
|
|
8
|
+
|
|
9
|
+
export interface FolderJobGuess {
|
|
10
|
+
job: ShownJob;
|
|
11
|
+
path: string;
|
|
12
|
+
why: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare const SHOWN_JOBS: readonly ShownJob[];
|
|
16
|
+
export declare const JOB_GROUP: Readonly<Record<RowRole, JobGroup>>;
|
|
17
|
+
export declare const GROUP_LABEL: Readonly<Record<JobGroup, string>>;
|
|
18
|
+
export declare const JOB_LINE: Readonly<Record<RowRole, string>>;
|
|
19
|
+
export declare const INBOX_PARTS: readonly InboxPart[];
|
|
20
|
+
export declare const INBOX_PART_LABEL: Readonly<Record<InboxPart, string>>;
|
|
21
|
+
export declare function canGiveJob(job: string): boolean;
|
|
22
|
+
export declare function canRemoveJob(job: string): boolean;
|
|
23
|
+
export declare function topOnly(job: string): boolean;
|
|
24
|
+
export declare function isInboxPart(path: string, inboxPath: string | null): boolean;
|
|
25
|
+
export type TexPart = "attention" | "chats" | "dreams" | "groups" | "handbacks" | "heartbeat" | "housekeeping" | "pictures" | "routines" | "skills" | "transcripts";
|
|
26
|
+
export declare const TEX_PARTS: readonly TexPart[];
|
|
27
|
+
export declare const PERSON_ONLY_TEX_PARTS: readonly TexPart[];
|
|
28
|
+
export declare const HOME_TEX_PARTS: readonly TexPart[];
|
|
29
|
+
export declare function isTexPart(path: string, texPath: string | null): boolean;
|
|
30
|
+
export type DataPart = "metrics";
|
|
31
|
+
export declare const DATA_PARTS: readonly DataPart[];
|
|
32
|
+
export declare function isDataPart(path: string, dataPath: string | null): boolean;
|
|
33
|
+
export declare function nameWords(name: string): string;
|
|
34
|
+
export declare function nameSays(name: string): { job: ShownJob; own: boolean } | null;
|
|
35
|
+
export declare function guessFolderJobs(
|
|
36
|
+
folders: Iterable<{ path: string; role?: string | null }>,
|
|
37
|
+
jobs: FolderJobs | null | undefined,
|
|
38
|
+
): FolderJobGuess[];
|
|
39
|
+
export declare function defaultFolderName(job: string): string | null;
|
|
40
|
+
export declare function jobNames(): string;
|