kordexa 0.4.2 → 0.4.4
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/bin/kordexa.js +8 -2
- package/package.json +1 -1
- package/src/cli.js +210 -54
- package/src/email.js +68 -0
- package/src/prompts.js +433 -49
- package/src/research.js +12 -5
- package/src/setup-answers.js +282 -0
- package/src/terminal-view.js +308 -0
- package/src/workflow.js +3 -0
- package/tests/node/guided-setup.test.js +366 -0
- package/tests/node/resend.test.js +177 -0
- package/tests/node/terminal-view.test.js +106 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { hasRoleMatch, inferRoleKey } from "./research.js";
|
|
2
|
+
|
|
3
|
+
// Every setup answer goes through one of these parsers. A parser returns
|
|
4
|
+
// { ok: true, value, note? } or { ok: false, error }, and never throws.
|
|
5
|
+
|
|
6
|
+
export const MIN_PLAN_DAYS = 30;
|
|
7
|
+
export const MAX_PLAN_DAYS = 365;
|
|
8
|
+
export const MAX_WEEKLY_HOURS = 80;
|
|
9
|
+
|
|
10
|
+
export const ROLE_OPTIONS = [
|
|
11
|
+
"Agentic AI and LLM Engineer",
|
|
12
|
+
"Full-Stack Developer",
|
|
13
|
+
"Cybersecurity Analyst",
|
|
14
|
+
"Data Scientist"
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const ROLE_LABELS = {
|
|
18
|
+
"agentic-ai": "Agentic AI and LLM Engineer",
|
|
19
|
+
"full-stack": "Full-Stack Developer",
|
|
20
|
+
cybersecurity: "Cybersecurity Analyst",
|
|
21
|
+
"data-science": "Data Scientist"
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Each suggestion matches real topics in that role's plan.
|
|
25
|
+
const SKILL_SUGGESTIONS = {
|
|
26
|
+
"agentic-ai": ["RAG", "Prompt engineering", "Agent tools", "Evaluation"],
|
|
27
|
+
"full-stack": ["React", "API design", "Auth", "Testing"],
|
|
28
|
+
cybersecurity: ["SIEM", "Incident response", "Threat modeling", "Phishing"],
|
|
29
|
+
"data-science": ["pandas", "SQL", "Statistics", "Classification"]
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const STAGE_OPTIONS = ["beginner", "intermediate", "advanced"];
|
|
33
|
+
export const NOT_STARTED = "not started yet";
|
|
34
|
+
|
|
35
|
+
const UNSURE_ANSWERS = new Set([
|
|
36
|
+
"no", "n", "nope", "nah", "none", "nothing", "nothing yet", "na", "n/a", "nil", "null",
|
|
37
|
+
"not yet", "not started", "not started yet", "yet to start", "no idea", "idk", "i dont know",
|
|
38
|
+
"dont know", "not sure", "unsure", "skip", "-", "--", "."
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
const EMAIL_TYPOS = {
|
|
42
|
+
"gmial.com": "gmail.com",
|
|
43
|
+
"gamil.com": "gmail.com",
|
|
44
|
+
"gmai.com": "gmail.com",
|
|
45
|
+
"gmal.com": "gmail.com",
|
|
46
|
+
"gmail.co": "gmail.com",
|
|
47
|
+
"gmail.con": "gmail.com",
|
|
48
|
+
"gmail.cm": "gmail.com",
|
|
49
|
+
"yaho.com": "yahoo.com",
|
|
50
|
+
"yahoo.con": "yahoo.com",
|
|
51
|
+
"hotmal.com": "hotmail.com",
|
|
52
|
+
"hotmail.con": "hotmail.com",
|
|
53
|
+
"outlok.com": "outlook.com",
|
|
54
|
+
"outlook.con": "outlook.com"
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const TIMEZONE_ALIASES = {
|
|
58
|
+
ist: "Asia/Kolkata", india: "Asia/Kolkata", "indian standard time": "Asia/Kolkata", kolkata: "Asia/Kolkata",
|
|
59
|
+
calcutta: "Asia/Kolkata", "asia/calcutta": "Asia/Kolkata", chennai: "Asia/Kolkata", madras: "Asia/Kolkata",
|
|
60
|
+
mumbai: "Asia/Kolkata", bombay: "Asia/Kolkata", delhi: "Asia/Kolkata", "new delhi": "Asia/Kolkata",
|
|
61
|
+
bangalore: "Asia/Kolkata", bengaluru: "Asia/Kolkata", hyderabad: "Asia/Kolkata", pune: "Asia/Kolkata",
|
|
62
|
+
coimbatore: "Asia/Kolkata", "utc+5:30": "Asia/Kolkata", "utc+05:30": "Asia/Kolkata", "gmt+5:30": "Asia/Kolkata",
|
|
63
|
+
"gmt+05:30": "Asia/Kolkata", "+5:30": "Asia/Kolkata", "+05:30": "Asia/Kolkata",
|
|
64
|
+
utc: "UTC", gmt: "UTC", z: "UTC", "etc/utc": "UTC",
|
|
65
|
+
uk: "Europe/London", bst: "Europe/London", cet: "Europe/Paris", cest: "Europe/Paris",
|
|
66
|
+
est: "America/New_York", edt: "America/New_York", et: "America/New_York",
|
|
67
|
+
cst: "America/Chicago", cdt: "America/Chicago", ct: "America/Chicago",
|
|
68
|
+
mst: "America/Denver", mdt: "America/Denver", mt: "America/Denver",
|
|
69
|
+
pst: "America/Los_Angeles", pdt: "America/Los_Angeles", pt: "America/Los_Angeles",
|
|
70
|
+
jst: "Asia/Tokyo", sgt: "Asia/Singapore", pkt: "Asia/Karachi", npt: "Asia/Kathmandu",
|
|
71
|
+
"asia/katmandu": "Asia/Kathmandu", "asia/saigon": "Asia/Ho_Chi_Minh", "asia/rangoon": "Asia/Yangon",
|
|
72
|
+
aest: "Australia/Sydney", aedt: "Australia/Sydney", uae: "Asia/Dubai"
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const accept = (value, note) => ({ ok: true, value, ...(note ? { note } : {}) });
|
|
76
|
+
const reject = (error) => ({ ok: false, error });
|
|
77
|
+
|
|
78
|
+
// Removes arrow-key escape codes, control characters, wrapping quotes and extra spaces.
|
|
79
|
+
export function cleanText(value) {
|
|
80
|
+
const text = String(value ?? "")
|
|
81
|
+
.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "")
|
|
82
|
+
.replace(/[\u0000-\u001f\u007f]/g, " ")
|
|
83
|
+
.replace(/\s+/g, " ")
|
|
84
|
+
.trim();
|
|
85
|
+
const quoted = /^(["'])(.*)\1$/.exec(text);
|
|
86
|
+
return quoted ? quoted[2].trim() : text;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function isUnsureAnswer(value) {
|
|
90
|
+
const text = cleanText(value).toLowerCase().replace(/['’]/g, "");
|
|
91
|
+
return UNSURE_ANSWERS.has(text.replace(/[.!]+$/, "") || text);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const hasLetter = (text) => /\p{L}/u.test(text);
|
|
95
|
+
|
|
96
|
+
export function parseName(raw) {
|
|
97
|
+
const text = cleanText(raw);
|
|
98
|
+
if (!text) return reject("Please enter your name.");
|
|
99
|
+
if (isUnsureAnswer(text)) return reject("Please enter the name you'd like on your daily plan.");
|
|
100
|
+
if (!hasLetter(text)) return reject("A name needs at least one letter.");
|
|
101
|
+
if (text.length > 60) return reject("Please keep your name under 60 characters.");
|
|
102
|
+
return accept(text);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function parseEmail(raw, { allowPlaceholder = true } = {}) {
|
|
106
|
+
const text = cleanText(raw);
|
|
107
|
+
if (!text) return reject("Please enter your email address, like name@gmail.com.");
|
|
108
|
+
if (text.length > 254 || !/^[^\s@]+@[^\s@.]+(\.[^\s@.]+)*\.[^\s@.]{2,}$/.test(text)) {
|
|
109
|
+
return reject("That doesn't look like an email address. Try the format name@gmail.com.");
|
|
110
|
+
}
|
|
111
|
+
const [local, domain] = text.split("@");
|
|
112
|
+
const suggestion = EMAIL_TYPOS[domain.toLowerCase()];
|
|
113
|
+
if (suggestion) return reject(`Did you mean ${local}@${suggestion}?`);
|
|
114
|
+
if (!allowPlaceholder && /(^|\.)example\.(com|org|net)$/i.test(domain)) {
|
|
115
|
+
return reject("Please enter your real email address so your daily plan can reach you.");
|
|
116
|
+
}
|
|
117
|
+
return accept(text);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function parseRole(raw) {
|
|
121
|
+
const text = cleanText(raw);
|
|
122
|
+
if (!text || isUnsureAnswer(text)) {
|
|
123
|
+
return accept(ROLE_OPTIONS[0], `Starting with ${ROLE_OPTIONS[0]}. You can change this later.`);
|
|
124
|
+
}
|
|
125
|
+
if (/^\d+$/.test(text)) {
|
|
126
|
+
const choice = ROLE_OPTIONS[Number(text) - 1];
|
|
127
|
+
return choice ? accept(choice) : reject(`Please choose a number from 1 to ${ROLE_OPTIONS.length}, or type a job title.`);
|
|
128
|
+
}
|
|
129
|
+
if (!hasLetter(text) || text.length < 2) return reject("Please choose a number or type a job title, like Backend Developer.");
|
|
130
|
+
if (text.length > 80) return reject("Please keep the job title under 80 characters.");
|
|
131
|
+
const exact = ROLE_OPTIONS.find((role) => role.toLowerCase() === text.toLowerCase());
|
|
132
|
+
if (exact) return accept(exact);
|
|
133
|
+
const planLabel = ROLE_LABELS[inferRoleKey(text)];
|
|
134
|
+
if (!hasRoleMatch(text)) {
|
|
135
|
+
return accept(text, `There's no dedicated plan for ${text} yet, so Kordexa will use the ${planLabel} plan.`);
|
|
136
|
+
}
|
|
137
|
+
return accept(text, `${text} will use the ${planLabel} plan.`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function parseCurrentLearning(raw) {
|
|
141
|
+
const text = cleanText(raw);
|
|
142
|
+
if (!text || isUnsureAnswer(text)) return accept(NOT_STARTED);
|
|
143
|
+
if (!/[\p{L}\p{N}]/u.test(text)) return reject("Please type a topic, or press Enter if you haven't started.");
|
|
144
|
+
if (text.length > 120) return reject("Please keep this under 120 characters.");
|
|
145
|
+
return accept(text);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function skillSuggestions(role) {
|
|
149
|
+
return SKILL_SUGGESTIONS[inferRoleKey(role || "")];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function recommendedSkill(role) {
|
|
153
|
+
return skillSuggestions(role)[0];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function parseSkill(raw, role) {
|
|
157
|
+
const text = cleanText(raw);
|
|
158
|
+
const suggestions = skillSuggestions(role);
|
|
159
|
+
if (!text || isUnsureAnswer(text)) return accept(suggestions[0], `Starting with ${suggestions[0]}, the recommended first skill for this role.`);
|
|
160
|
+
if (/^\d+$/.test(text)) {
|
|
161
|
+
const choice = suggestions[Number(text) - 1];
|
|
162
|
+
return choice ? accept(choice) : reject(`Please choose a number from 1 to ${suggestions.length}, or type a skill.`);
|
|
163
|
+
}
|
|
164
|
+
if (!hasLetter(text) || text.length < 2) return reject("Please choose a number or type a skill, like SQL.");
|
|
165
|
+
if (text.length > 80) return reject("Please keep the skill under 80 characters.");
|
|
166
|
+
return accept(text);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function parseStage(raw) {
|
|
170
|
+
const text = cleanText(raw).toLowerCase();
|
|
171
|
+
if (!text || isUnsureAnswer(text)) return accept("beginner", "Starting at beginner level.");
|
|
172
|
+
if (/^\d+$/.test(text)) {
|
|
173
|
+
const choice = STAGE_OPTIONS[Number(text) - 1];
|
|
174
|
+
return choice ? accept(choice) : reject("Please choose 1, 2 or 3.");
|
|
175
|
+
}
|
|
176
|
+
if (/^(b|beg|begin\w*|fresher|new|newbie|novice|student)$/.test(text)) return accept("beginner");
|
|
177
|
+
if (/^(i|int|inter|intermediate|medium|mid)$/.test(text)) return accept("intermediate");
|
|
178
|
+
if (/^(a|adv|advance|advanced|expert|senior)$/.test(text)) return accept("advanced");
|
|
179
|
+
return reject("Please choose 1 for Beginner, 2 for Intermediate or 3 for Advanced.");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function parseWeeklyHours(raw) {
|
|
183
|
+
const text = cleanText(raw).toLowerCase();
|
|
184
|
+
const match = /^(\d+(?:\.\d+)?)\s*(?:h|hr|hrs|hour|hours)?(?:\s*(?:a|per|\/)\s*(?:week|wk))?$/.exec(text);
|
|
185
|
+
if (!match) return reject("Please enter a number of hours, like 8.");
|
|
186
|
+
const hours = Math.round(Number(match[1]));
|
|
187
|
+
if (hours < 1) return reject("Please plan for at least 1 hour a week.");
|
|
188
|
+
if (hours > MAX_WEEKLY_HOURS) return reject(`Please enter ${MAX_WEEKLY_HOURS} hours a week or fewer.`);
|
|
189
|
+
return accept(hours);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function parsePlanDays(raw) {
|
|
193
|
+
const text = cleanText(raw).toLowerCase();
|
|
194
|
+
const match = /^(\d+)\s*(d|day|days|w|wk|wks|week|weeks|m|mo|month|months)?$/.exec(text);
|
|
195
|
+
if (!match) return reject(`Please enter a number of days from ${MIN_PLAN_DAYS} to ${MAX_PLAN_DAYS}.`);
|
|
196
|
+
const unit = match[2] || "d";
|
|
197
|
+
const size = unit.startsWith("w") ? 7 : unit.startsWith("m") ? 30 : 1;
|
|
198
|
+
const days = Number(match[1]) * size;
|
|
199
|
+
if (days > MAX_PLAN_DAYS) return reject(`Plans can be up to ${MAX_PLAN_DAYS} days long.`);
|
|
200
|
+
if (days < MIN_PLAN_DAYS) return accept(MIN_PLAN_DAYS, `Plans start at ${MIN_PLAN_DAYS} days, so Kordexa will use ${MIN_PLAN_DAYS}.`);
|
|
201
|
+
return accept(days);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function parseEmailTime(raw) {
|
|
205
|
+
const text = cleanText(raw).toLowerCase();
|
|
206
|
+
const invalid = reject("Please enter a time like 20:00 or 8pm.");
|
|
207
|
+
if (text === "noon") return accept("12:00");
|
|
208
|
+
if (text === "midnight") return accept("00:00");
|
|
209
|
+
const format = (hour, minute) => `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`;
|
|
210
|
+
|
|
211
|
+
const meridiem = /^(\d{1,2})(?:[:.](\d{2}))?\s*([ap])\.?m?\.?$/.exec(text);
|
|
212
|
+
if (meridiem) {
|
|
213
|
+
const hour = Number(meridiem[1]);
|
|
214
|
+
const minute = Number(meridiem[2] || 0);
|
|
215
|
+
if (hour < 1 || hour > 12 || minute > 59) return invalid;
|
|
216
|
+
return accept(format((hour % 12) + (meridiem[3] === "p" ? 12 : 0), minute));
|
|
217
|
+
}
|
|
218
|
+
const clock = /^(\d{1,2})(?:[:.](\d{2}))?$/.exec(text) || /^(\d{2})(\d{2})$/.exec(text);
|
|
219
|
+
if (!clock) return invalid;
|
|
220
|
+
const hour = Number(clock[1]);
|
|
221
|
+
const minute = Number(clock[2] || 0);
|
|
222
|
+
if (hour > 23 || minute > 59) return invalid;
|
|
223
|
+
return accept(format(hour, minute));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function canonicalTimezone(zone) {
|
|
227
|
+
return TIMEZONE_ALIASES[zone.toLowerCase()] || zone;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function detectTimezone() {
|
|
231
|
+
try {
|
|
232
|
+
return canonicalTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC");
|
|
233
|
+
} catch {
|
|
234
|
+
return "UTC";
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export function parseTimezone(raw) {
|
|
239
|
+
const text = cleanText(raw);
|
|
240
|
+
const invalid = reject("Kordexa doesn't recognize that timezone. Try a city or code, like Chennai, London or IST.");
|
|
241
|
+
if (!text) return invalid;
|
|
242
|
+
const lowered = text.toLowerCase();
|
|
243
|
+
if (TIMEZONE_ALIASES[lowered]) return accept(TIMEZONE_ALIASES[lowered]);
|
|
244
|
+
const zones = typeof Intl.supportedValuesOf === "function" ? Intl.supportedValuesOf("timeZone") : [];
|
|
245
|
+
const city = zones.find((zone) => zone.split("/").at(-1).replace(/_/g, " ").toLowerCase() === lowered);
|
|
246
|
+
if (city) return accept(canonicalTimezone(city));
|
|
247
|
+
if (!text.includes("/")) return invalid;
|
|
248
|
+
try {
|
|
249
|
+
return accept(canonicalTimezone(new Intl.DateTimeFormat("en-US", { timeZone: text }).resolvedOptions().timeZone));
|
|
250
|
+
} catch {
|
|
251
|
+
return invalid;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function parseSmtpHost(raw) {
|
|
256
|
+
const text = cleanText(raw).toLowerCase().replace(/^smtps?:\/\//, "").replace(/\/$/, "");
|
|
257
|
+
if (!/^(?=.{4,253}$)([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/.test(text)) {
|
|
258
|
+
return reject("Please enter a mail server address, like smtp.zoho.com.");
|
|
259
|
+
}
|
|
260
|
+
return accept(text);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function parseSmtpPort(raw) {
|
|
264
|
+
const text = cleanText(raw);
|
|
265
|
+
const port = Number(text);
|
|
266
|
+
if (!/^\d+$/.test(text) || port < 1 || port > 65535) return reject("Please enter a port number, usually 587 or 465.");
|
|
267
|
+
return accept(port);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function parseSmtpUser(raw) {
|
|
271
|
+
const text = cleanText(raw);
|
|
272
|
+
if (!text || /\s/.test(text) || text.length > 254) return reject("Please enter your email login, usually your full email address.");
|
|
273
|
+
return accept(text);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export function parseGmailAppPassword(raw) {
|
|
277
|
+
const text = String(raw ?? "").replace(/\s/g, "");
|
|
278
|
+
if (!/^[a-zA-Z]{16}$/.test(text)) {
|
|
279
|
+
return reject("A Gmail app password has exactly 16 letters. Your normal Gmail password won't work here.");
|
|
280
|
+
}
|
|
281
|
+
return accept(text);
|
|
282
|
+
}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { cleanText } from "./setup-answers.js";
|
|
2
|
+
|
|
3
|
+
// Readable command results for people. Agents and scripts keep receiving JSON.
|
|
4
|
+
|
|
5
|
+
const OPEN_COMMAND = { darwin: "open", win32: "start" }[process.platform] || "xdg-open";
|
|
6
|
+
const STYLES = { bold: 1, dim: 2, accent: 36, good: 32, warn: 33 };
|
|
7
|
+
const MOMENTUM = { strong: "Strong", steady: "Steady", "needs-support": "Needs support", blocked: "Blocked", "not-started": "Not started" };
|
|
8
|
+
const DOCTOR_CHECKS = {
|
|
9
|
+
config: "Learner settings",
|
|
10
|
+
agentsMd: "Codex and generic agent instructions",
|
|
11
|
+
geminiMd: "Gemini instructions",
|
|
12
|
+
claudeSkill: "Claude Code skill",
|
|
13
|
+
mcpManifest: "MCP connection",
|
|
14
|
+
workflow: "Daily email schedule",
|
|
15
|
+
localEnv: "Local settings file",
|
|
16
|
+
localEmail: "Email connection"
|
|
17
|
+
};
|
|
18
|
+
const DOCTOR_STATUS = {
|
|
19
|
+
ready: "Everything is ready.",
|
|
20
|
+
"needs-setup": "Setup isn't finished yet.",
|
|
21
|
+
"needs-upgrade": "Your project needs a small update.",
|
|
22
|
+
"needs-email-setup": "Kordexa is ready, but email isn't connected yet."
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function createPainter({ color, width }) {
|
|
26
|
+
const paint = (style, text) => (color ? `\u001b[${STYLES[style]}m${text}\u001b[0m` : text);
|
|
27
|
+
const pageWidth = Math.max(40, Math.min(width || 80, 88));
|
|
28
|
+
|
|
29
|
+
const wrap = (value, indent = 2) => {
|
|
30
|
+
const limit = pageWidth - indent;
|
|
31
|
+
const lines = [];
|
|
32
|
+
let line = "";
|
|
33
|
+
for (const word of cleanText(value).split(" ")) {
|
|
34
|
+
if (line && `${line} ${word}`.length > limit) {
|
|
35
|
+
lines.push(line);
|
|
36
|
+
line = word;
|
|
37
|
+
} else {
|
|
38
|
+
line = line ? `${line} ${word}` : word;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (line) lines.push(line);
|
|
42
|
+
return lines.map((text) => `${" ".repeat(indent)}${text}`);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const rows = (entries) => {
|
|
46
|
+
const visible = entries.filter(([, value]) => value !== undefined && value !== null && value !== "");
|
|
47
|
+
const labelWidth = Math.max(...visible.map(([label]) => label.length), 0) + 2;
|
|
48
|
+
return visible.flatMap(([label, value]) => {
|
|
49
|
+
const [first, ...rest] = wrap(value, labelWidth + 2).map((line) => line.trimStart());
|
|
50
|
+
return [
|
|
51
|
+
` ${paint("dim", label.padEnd(labelWidth))}${first}`,
|
|
52
|
+
...rest.map((line) => `${" ".repeat(labelWidth + 2)}${line}`)
|
|
53
|
+
];
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
paint,
|
|
59
|
+
wrap,
|
|
60
|
+
rows,
|
|
61
|
+
title: (text) => [paint("bold", cleanText(text))],
|
|
62
|
+
section: (text) => ["", paint("accent", paint("bold", text))],
|
|
63
|
+
rule: () => [paint("dim", "─".repeat(Math.min(pageWidth, 56)))],
|
|
64
|
+
success: (text) => [`${paint("good", "✓")} ${paint("bold", cleanText(text))}`],
|
|
65
|
+
notice: (text) => [`${paint("warn", "!")} ${paint("bold", cleanText(text))}`],
|
|
66
|
+
bullets: (items) => items.flatMap((item) => {
|
|
67
|
+
const [first, ...rest] = wrap(item, 4);
|
|
68
|
+
return [` • ${first.trimStart()}`, ...rest];
|
|
69
|
+
}),
|
|
70
|
+
command: (text, purpose) => [` ${paint("accent", text)}${purpose ? ` ${paint("dim", purpose)}` : ""}`],
|
|
71
|
+
resource: (label, item) => {
|
|
72
|
+
if (!item?.url) return [];
|
|
73
|
+
const name = cleanText(item.title) || item.url;
|
|
74
|
+
return [` ${paint("dim", label.padEnd(7))}${name}`, ` ${" ".repeat(7)}${paint("accent", cleanText(item.url))}`];
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function momentumLabel(value) {
|
|
80
|
+
return MOMENTUM[value] || value;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const VIEWS = {
|
|
84
|
+
email(p, result, { day, digest, review, totalDays, completedDays, previewPath, emailConnected }) {
|
|
85
|
+
const message = result.message || result;
|
|
86
|
+
const time = day.timeBox;
|
|
87
|
+
return [
|
|
88
|
+
...(result.dryRun ? p.notice("Preview only. No email was sent.") : p.success(`Email sent to ${result.to}`)),
|
|
89
|
+
"",
|
|
90
|
+
...p.title(message.subject),
|
|
91
|
+
...p.rows([["To", message.to]]),
|
|
92
|
+
...p.rule(),
|
|
93
|
+
...p.section("Today's task"),
|
|
94
|
+
...p.wrap(day.setupOrBuildTask),
|
|
95
|
+
"",
|
|
96
|
+
...p.rows([
|
|
97
|
+
["Skill", day.primarySkill],
|
|
98
|
+
["Concepts", day.concepts.join(", ")],
|
|
99
|
+
["Time", `Learn ${time.learnMinutes}m · Build ${time.buildMinutes}m · Review ${time.reviewMinutes}m`],
|
|
100
|
+
["Level", day.difficulty.replaceAll("-", " ")]
|
|
101
|
+
]),
|
|
102
|
+
...p.section("Open these first"),
|
|
103
|
+
...p.resource("Watch", digest.topVideo),
|
|
104
|
+
...p.resource("Build", digest.topRepo),
|
|
105
|
+
...p.resource("Read", digest.topDoc),
|
|
106
|
+
...p.section("Before you finish"),
|
|
107
|
+
...p.bullets(day.reviewQuestions),
|
|
108
|
+
...p.section("Your progress"),
|
|
109
|
+
...p.rows([
|
|
110
|
+
["Completed", `${completedDays} of ${totalDays} days`],
|
|
111
|
+
["Momentum", momentumLabel(review.momentum)]
|
|
112
|
+
]),
|
|
113
|
+
...(result.dryRun ? [
|
|
114
|
+
...p.section("Next"),
|
|
115
|
+
...p.command(`${OPEN_COMMAND} ${previewPath}`, "See the full email"),
|
|
116
|
+
...p.command(emailConnected ? "npx kordexa send-today" : "npx kordexa setup-email", emailConnected ? "Send it" : "Connect your email")
|
|
117
|
+
] : [])
|
|
118
|
+
];
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
skipped(p, result) {
|
|
122
|
+
return [
|
|
123
|
+
...p.success("Your plan is complete, so no email was sent."),
|
|
124
|
+
...p.rows([["Next skill", result.recommendation?.recommendedNextSkill]]),
|
|
125
|
+
...p.section("Next"),
|
|
126
|
+
...p.command("npx kordexa recommend-next", "See what to learn next")
|
|
127
|
+
];
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
plan(p, result, { plan }) {
|
|
131
|
+
return [
|
|
132
|
+
...p.success(`Your ${result.days}-day plan is ready`),
|
|
133
|
+
"",
|
|
134
|
+
...p.rows([
|
|
135
|
+
["Goal", plan.learner.targetRole],
|
|
136
|
+
["First skill", plan.primarySkill],
|
|
137
|
+
["Day 1", plan.days[0].title]
|
|
138
|
+
]),
|
|
139
|
+
...p.section("Plan phases"),
|
|
140
|
+
...p.rows(plan.phases.map((phase) => [`Days ${phase.days}`, phase.name])),
|
|
141
|
+
...p.section("Next"),
|
|
142
|
+
...p.command("npx kordexa status", "See today's task")
|
|
143
|
+
];
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
status(p, status) {
|
|
147
|
+
return [
|
|
148
|
+
...p.title(`${status.learner}'s learning plan`),
|
|
149
|
+
...p.rule(),
|
|
150
|
+
...p.rows([
|
|
151
|
+
["Goal", status.targetRole],
|
|
152
|
+
["First skill", status.primarySkill],
|
|
153
|
+
["Progress", `${status.completedDays} of ${status.daysPlanned} days`],
|
|
154
|
+
["Current day", `Day ${status.activeDay}`],
|
|
155
|
+
["Momentum", momentumLabel(status.momentum)],
|
|
156
|
+
["Daily email", status.emailTime]
|
|
157
|
+
]),
|
|
158
|
+
...p.section("Next task"),
|
|
159
|
+
...p.wrap(status.nextAction),
|
|
160
|
+
...(status.latestEvidence ? [...p.section("Latest proof"), ...p.wrap(status.latestEvidence)] : []),
|
|
161
|
+
...(/^Resolve blocker/.test(status.risk) ? [...p.section("Needs attention"), ...p.wrap(status.risk)] : [])
|
|
162
|
+
];
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
research(p, { path, digest }) {
|
|
166
|
+
return [
|
|
167
|
+
...p.success(`Research is ready for Day ${digest.day}`),
|
|
168
|
+
"",
|
|
169
|
+
...p.title(digest.topic),
|
|
170
|
+
...p.section("Start here"),
|
|
171
|
+
...p.resource("Watch", digest.topVideo),
|
|
172
|
+
...p.resource("Build", digest.topRepo),
|
|
173
|
+
...p.resource("Read", digest.topDoc),
|
|
174
|
+
"",
|
|
175
|
+
...p.rows([["Saved to", path]])
|
|
176
|
+
];
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
links(p, result) {
|
|
180
|
+
return [
|
|
181
|
+
...p.success(`Links are ready for Day ${result.day}`),
|
|
182
|
+
"",
|
|
183
|
+
...p.title(result.topic),
|
|
184
|
+
...p.section("Start here"),
|
|
185
|
+
...p.resource("Watch", result.topVideo),
|
|
186
|
+
...p.resource("Build", result.topRepo),
|
|
187
|
+
...p.resource("Read", result.topDoc),
|
|
188
|
+
"",
|
|
189
|
+
...p.rows([["Saved to", result.path]])
|
|
190
|
+
];
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
harness(p, { jsonPath, harness }) {
|
|
194
|
+
return [
|
|
195
|
+
...p.success("Your AI agent instructions are ready"),
|
|
196
|
+
"",
|
|
197
|
+
...p.rows([
|
|
198
|
+
["Current day", `Day ${harness.activeDay.day}: ${harness.activeDay.title}`],
|
|
199
|
+
["Task", harness.activeDay.task],
|
|
200
|
+
["Saved to", jsonPath]
|
|
201
|
+
])
|
|
202
|
+
];
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
courses(p, { markdownPath, learningSources }) {
|
|
206
|
+
const list = (items) => items.flatMap((item) => [` ${cleanText(item.title)}`, ` ${p.paint("accent", cleanText(item.url))}`]);
|
|
207
|
+
return [
|
|
208
|
+
...p.success(`Learning sources are ready for ${learningSources.targetRole}`),
|
|
209
|
+
...p.section("Recommended courses"),
|
|
210
|
+
...list(learningSources.recommendedSources.slice(0, 5)),
|
|
211
|
+
...p.section("Stay updated"),
|
|
212
|
+
...list(learningSources.newsletters.slice(0, 3)),
|
|
213
|
+
"",
|
|
214
|
+
...p.rows([["Full list", markdownPath]])
|
|
215
|
+
];
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
logged(p, { entry, review }) {
|
|
219
|
+
return [
|
|
220
|
+
...p.success(`Day ${entry.day} is logged`),
|
|
221
|
+
"",
|
|
222
|
+
...p.rows([
|
|
223
|
+
["Completed", entry.completed],
|
|
224
|
+
["Proof", entry.evidence],
|
|
225
|
+
["Progress", `${review.completedDays} days completed`],
|
|
226
|
+
["Momentum", momentumLabel(review.momentum)]
|
|
227
|
+
]),
|
|
228
|
+
...p.section(`Next: Day ${review.activeDay}`),
|
|
229
|
+
...p.wrap(review.nextAction)
|
|
230
|
+
];
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
weekly(p, summary) {
|
|
234
|
+
return [
|
|
235
|
+
...p.title(`Week ${summary.week} summary`),
|
|
236
|
+
...p.rows([["Days", summary.range]]),
|
|
237
|
+
...p.rule(),
|
|
238
|
+
...p.wrap(summary.summary),
|
|
239
|
+
...(summary.completed.length ? [...p.section("Completed"), ...p.bullets(summary.completed.map((item) => `Day ${item.day}: ${item.completed}`))] : []),
|
|
240
|
+
...p.section("Next week's focus"),
|
|
241
|
+
...p.wrap(summary.nextWeekFocus)
|
|
242
|
+
];
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
recommendation(p, result) {
|
|
246
|
+
return [
|
|
247
|
+
...p.title("Your next skill"),
|
|
248
|
+
...p.rule(),
|
|
249
|
+
...p.wrap(result.recommendedNextSkill),
|
|
250
|
+
"",
|
|
251
|
+
...p.rows([
|
|
252
|
+
["Why", result.reason],
|
|
253
|
+
["Progress", `${result.completedDays} of ${result.requiredDays} days completed`]
|
|
254
|
+
]),
|
|
255
|
+
...(result.canAdvance ? [] : ["", ...p.wrap("Finish your current plan before moving to this skill.")])
|
|
256
|
+
];
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
card(p, { card, markdownPath, terminalSvgPath }) {
|
|
260
|
+
return [
|
|
261
|
+
...p.title(`${card.role} progress`),
|
|
262
|
+
...p.rule(),
|
|
263
|
+
...p.rows([
|
|
264
|
+
["First skill", card.skill],
|
|
265
|
+
["Progress", `${card.completedDays} of ${card.totalDays} days`],
|
|
266
|
+
["Current day", `Day ${card.activeDay}: ${card.activeTopic}`]
|
|
267
|
+
]),
|
|
268
|
+
...p.section("Your plan"),
|
|
269
|
+
...card.grid.map((row) => ` ${row}`),
|
|
270
|
+
"",
|
|
271
|
+
...p.wrap("# done > today . upcoming"),
|
|
272
|
+
"",
|
|
273
|
+
...p.rows([["Report", markdownPath], ["Image", terminalSvgPath]])
|
|
274
|
+
];
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
terminalCard(p, { terminalSvgPath }) {
|
|
278
|
+
return [...p.success("Your progress image is ready"), "", ...p.rows([["Saved to", terminalSvgPath]])];
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
secrets(p, { commands }) {
|
|
282
|
+
return [
|
|
283
|
+
...p.title("Add these secrets to GitHub"),
|
|
284
|
+
...p.wrap("Run each command from your project folder after signing in with GitHub CLI."),
|
|
285
|
+
"",
|
|
286
|
+
...commands.flatMap((command) => p.command(command))
|
|
287
|
+
];
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
doctor(p, { status, checks, nextSteps = [], warnings = [] }) {
|
|
291
|
+
return [
|
|
292
|
+
...(status === "ready" ? p.success(DOCTOR_STATUS[status]) : p.notice(DOCTOR_STATUS[status])),
|
|
293
|
+
"",
|
|
294
|
+
...Object.entries(DOCTOR_CHECKS).map(([key, label]) => ` ${checks[key] ? p.paint("good", "✓") : p.paint("warn", "•")} ${label}`),
|
|
295
|
+
...(nextSteps.length ? [...p.section("Next"), ...p.bullets(nextSteps)] : []),
|
|
296
|
+
...(warnings.length ? [...p.section("Warnings"), ...p.bullets(warnings)] : [])
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export function renderView(kind, payload, context = {}, options = {}) {
|
|
302
|
+
const painter = createPainter({ color: Boolean(options.color), width: options.width });
|
|
303
|
+
return VIEWS[kind](painter, payload, context).join("\n");
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export function terminalSupportsColor(stream = process.stdout, env = process.env) {
|
|
307
|
+
return Boolean(stream.isTTY) && !env.NO_COLOR && env.TERM !== "dumb";
|
|
308
|
+
}
|
package/src/workflow.js
CHANGED
|
@@ -79,6 +79,8 @@ export function workflowContent(config) {
|
|
|
79
79
|
" SMTP_USER: ${{ secrets.SMTP_USER }}",
|
|
80
80
|
" SMTP_PASS: ${{ secrets.SMTP_PASS }}",
|
|
81
81
|
" SMTP_FROM: ${{ secrets.SMTP_FROM }}",
|
|
82
|
+
" RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}",
|
|
83
|
+
" RESEND_FROM: ${{ secrets.RESEND_FROM }}",
|
|
82
84
|
` run: npx --yes kordexa@${PACKAGE_VERSION} send-today`,
|
|
83
85
|
""
|
|
84
86
|
].join("\n");
|
|
@@ -128,6 +130,7 @@ function normalizeWorkflow(content) {
|
|
|
128
130
|
|
|
129
131
|
const GENERATED_WORKFLOWS = new Set([
|
|
130
132
|
workflowContent({}),
|
|
133
|
+
workflowContent({}).replace(/ {10}RESEND_API_KEY: .*\n {10}RESEND_FROM: .*\n/, ""),
|
|
131
134
|
previousWorkflow("Kordexa", "node bin/kordexa.js send-today || node bin/eduorchestrate.js send-today"),
|
|
132
135
|
previousWorkflow("EduOrchestrate", "node bin/eduorchestrate.js send-today")
|
|
133
136
|
].map(normalizeWorkflow));
|