kordexa 0.0.0-stage → 0.4.2
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/.claude/commands/eduorchestrate-card.md +5 -0
- package/.claude/commands/eduorchestrate-log.md +6 -0
- package/.claude/commands/eduorchestrate-next.md +5 -0
- package/.claude/commands/eduorchestrate-research.md +6 -0
- package/.claude/commands/eduorchestrate-send.md +5 -0
- package/.claude/commands/eduorchestrate-status.md +5 -0
- package/.claude/commands/eduorchestrate-weekly.md +6 -0
- package/.claude/commands/kordexa-card.md +5 -0
- package/.claude/commands/kordexa-log.md +6 -0
- package/.claude/commands/kordexa-next.md +5 -0
- package/.claude/commands/kordexa-research.md +6 -0
- package/.claude/commands/kordexa-send.md +5 -0
- package/.claude/commands/kordexa-status.md +5 -0
- package/.claude/commands/kordexa-weekly.md +6 -0
- package/.claude/skills/eduorchestrate/SKILL.md +24 -0
- package/.claude/skills/kordexa/SKILL.md +24 -0
- package/.eduorchestrate/adapters/antigravity/manifest.json +31 -0
- package/.eduorchestrate/adapters/codex/AGENTS.md +23 -0
- package/.eduorchestrate/adapters/generic/EDUORCHESTRATE.md +19 -0
- package/.eduorchestrate/adapters/hermas/manifest.json +31 -0
- package/.eduorchestrate/adapters/openclaw/SKILL.md +24 -0
- package/.eduorchestrate/mcp/manifest.json +19 -0
- package/.eduorchestrate/mcp/server.js +47 -0
- package/.kordexa/adapters/antigravity/manifest.json +31 -0
- package/.kordexa/adapters/codex/AGENTS.md +23 -0
- package/.kordexa/adapters/generic/KORDEXA.md +19 -0
- package/.kordexa/adapters/hermas/manifest.json +31 -0
- package/.kordexa/adapters/openclaw/SKILL.md +24 -0
- package/.kordexa/mcp/manifest.json +19 -0
- package/.kordexa/mcp/server.js +47 -0
- package/AGENTS.md +25 -0
- package/GEMINI.md +7 -0
- package/LICENSE +22 -0
- package/README.md +311 -2
- package/agents/eduorchestrate-agent.yaml +18 -0
- package/agents/kordexa-agent.yaml +18 -0
- package/bin/kordexa.js +8 -0
- package/package.json +38 -4
- package/skills/eduorchestrate/SKILL.md +115 -0
- package/skills/eduorchestrate/agents/openai.yaml +4 -0
- package/skills/eduorchestrate/assets/default-terminal-card.svg +1 -0
- package/skills/eduorchestrate/references/agent-contracts.md +107 -0
- package/skills/eduorchestrate/references/learning-system.md +119 -0
- package/skills/kordexa/SKILL.md +115 -0
- package/skills/kordexa/agents/openai.yaml +4 -0
- package/skills/kordexa/assets/default-terminal-card.svg +1 -0
- package/skills/kordexa/references/agent-contracts.md +107 -0
- package/skills/kordexa/references/learning-system.md +119 -0
- package/src/adapters.js +203 -0
- package/src/card-components.js +103 -0
- package/src/cli.js +505 -0
- package/src/config.js +118 -0
- package/src/courses.js +150 -0
- package/src/email.js +173 -0
- package/src/harness.js +130 -0
- package/src/planner.js +423 -0
- package/src/progress.js +93 -0
- package/src/progression-card.js +137 -0
- package/src/prompts.js +77 -0
- package/src/research.js +288 -0
- package/src/workflow.js +161 -0
- package/tests/node/eduorchestrate.test.js +558 -0
- package/tests/node/launch-ready.test.js +101 -0
- package/tests/node/safe-setup.test.js +313 -0
package/src/cli.js
ADDED
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { writeAgentAdapters } from "./adapters.js";
|
|
4
|
+
import { appendGitignore, loadConfig, loadEnvFile, readJson, resolveDataDir, saveConfig, writeJson, writeLocalEnv, validateConfig, CONFIG_FILE } from "./config.js";
|
|
5
|
+
import { createCoursePack, saveCoursePack } from "./courses.js";
|
|
6
|
+
import { sendMail, smtpConfigFromEnv } from "./email.js";
|
|
7
|
+
import { createHarness, saveHarness } from "./harness.js";
|
|
8
|
+
import { generate30DayPlan, renderDailyEmail } from "./planner.js";
|
|
9
|
+
import { buildProgressionCard, copyDefaultTerminalCard, saveProgressionCard } from "./progression-card.js";
|
|
10
|
+
import { appendProgress, createWeeklySummary, planStatus, reviewProgress } from "./progress.js";
|
|
11
|
+
import { collectOnboarding } from "./prompts.js";
|
|
12
|
+
import { appendResearchIndex, createResearchDigest, enrichDigestLinks, saveResearchDigest } from "./research.js";
|
|
13
|
+
import { workflowStatus, writeGithubWorkflow } from "./workflow.js";
|
|
14
|
+
|
|
15
|
+
export async function main(argv = []) {
|
|
16
|
+
const command = normalizeCommand(argv[0]);
|
|
17
|
+
if (command === "send-today") return sendToday(argv.slice(1));
|
|
18
|
+
if (command === "plan") return regeneratePlan(argv.slice(1));
|
|
19
|
+
if (command === "status") return showStatus();
|
|
20
|
+
if (command === "research") return research(argv.slice(1));
|
|
21
|
+
if (command === "links") return links(argv.slice(1));
|
|
22
|
+
if (command === "harness") return harness(argv.slice(1));
|
|
23
|
+
if (command === "courses") return courses();
|
|
24
|
+
if (command === "log-progress") return logProgress(argv.slice(1));
|
|
25
|
+
if (command === "weekly-summary") return weeklySummary(argv.slice(1));
|
|
26
|
+
if (command === "recommend-next") return recommendNext();
|
|
27
|
+
if (command === "progress-card") return progressCard();
|
|
28
|
+
if (command === "terminal-card") return terminalCard();
|
|
29
|
+
if (command === "setup-secrets") return setupSecrets();
|
|
30
|
+
if (command === "doctor") return doctor();
|
|
31
|
+
if (command === "help") return printHelp();
|
|
32
|
+
return init(argv);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function normalizeCommand(value) {
|
|
36
|
+
if (!value || value === "/kordexa" || value === "kordexa" || value === "/eduorchestrate" || value === "eduorchestrate" || value === "init") return "init";
|
|
37
|
+
if (value === "--help" || value === "-h") return "help";
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function init(argv) {
|
|
42
|
+
const nonInteractive = argv.includes("--yes") || argv.includes("--non-interactive");
|
|
43
|
+
const overrides = parseKeyValues(argv);
|
|
44
|
+
const existing = existingSetup();
|
|
45
|
+
const answers = await collectOnboarding({ defaults: existing.defaults, nonInteractive, overrides });
|
|
46
|
+
const config = {
|
|
47
|
+
version: 1,
|
|
48
|
+
command: "/kordexa",
|
|
49
|
+
dataDir: "data",
|
|
50
|
+
learner: answers.learner,
|
|
51
|
+
schedule: answers.schedule,
|
|
52
|
+
email: {
|
|
53
|
+
provider: "smtp",
|
|
54
|
+
to: answers.learner.email,
|
|
55
|
+
fromEnv: ["SMTP_HOST", "SMTP_PORT", "SMTP_USER", "SMTP_PASS", "SMTP_FROM"]
|
|
56
|
+
},
|
|
57
|
+
agents: ["claude", "codex", "gemini", "openclaw", "antigravity", "hermas", "generic"]
|
|
58
|
+
};
|
|
59
|
+
const keepStartDate = !argv.includes("--restart") && Number.isFinite(dateStringToUtc(existing.startDate).getTime());
|
|
60
|
+
config.schedule.startDate = keepStartDate ? existing.startDate : localDateString(new Date(), config.schedule.timezone);
|
|
61
|
+
saveConfig(config);
|
|
62
|
+
appendGitignore(["__pycache__/", "*.py[cod]", ".pytest_cache/", "node_modules/", ".env.local", "data/"]);
|
|
63
|
+
writeLocalEnv({
|
|
64
|
+
SMTP_HOST: answers.smtp.host,
|
|
65
|
+
SMTP_PORT: answers.smtp.port,
|
|
66
|
+
SMTP_USER: answers.smtp.user,
|
|
67
|
+
SMTP_PASS: answers.smtp.pass,
|
|
68
|
+
SMTP_FROM: answers.smtp.from
|
|
69
|
+
});
|
|
70
|
+
const adapterFiles = writeAgentAdapters();
|
|
71
|
+
const plan = generate30DayPlan(config.learner);
|
|
72
|
+
writeDataJson(config, "30-day-plan.json", plan);
|
|
73
|
+
const defaultTerminalCard = copyDefaultTerminalCard(config);
|
|
74
|
+
const cardPaths = saveProgressionCard(config, buildProgressionCard(config, plan));
|
|
75
|
+
const harnessPaths = saveHarness(config, createHarness(config, plan, "init"));
|
|
76
|
+
const coursePaths = saveCoursePack(config, createCoursePack(config, plan));
|
|
77
|
+
const digest = createResearchDigest({ config, topic: plan.days[0].title, day: 1, roleKey: plan.roleKey });
|
|
78
|
+
await enrichDigestLinks(digest, { offline: argv.includes("--offline") });
|
|
79
|
+
const digestPath = saveResearchDigest(config, digest);
|
|
80
|
+
appendResearchIndex(config, digestPath, digest);
|
|
81
|
+
const workflowPath = writeGithubWorkflow(config);
|
|
82
|
+
const { warnings } = workflowStatus();
|
|
83
|
+
outputJson({
|
|
84
|
+
status: "initialized",
|
|
85
|
+
command: "/kordexa",
|
|
86
|
+
adapters: adapterFiles,
|
|
87
|
+
plan: "data/30-day-plan.json",
|
|
88
|
+
defaultTerminalCard,
|
|
89
|
+
progressionCard: cardPaths.markdownPath,
|
|
90
|
+
harness: harnessPaths.jsonPath,
|
|
91
|
+
learningSources: coursePaths.jsonPath,
|
|
92
|
+
workflow: path.relative(process.cwd(), workflowPath),
|
|
93
|
+
firstResearchDigest: digestPath,
|
|
94
|
+
startDate: config.schedule.startDate,
|
|
95
|
+
next: "Run npx kordexa send-today --dry-run to preview the first email.",
|
|
96
|
+
...(warnings.length ? { warnings } : {})
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Re-running setup must not reset a learner's profile, email login or schedule.
|
|
101
|
+
function existingSetup() {
|
|
102
|
+
let config = null;
|
|
103
|
+
try {
|
|
104
|
+
config = loadConfig();
|
|
105
|
+
} catch {
|
|
106
|
+
config = null;
|
|
107
|
+
}
|
|
108
|
+
const env = loadEnvFile(path.join(process.cwd(), ".env.local"));
|
|
109
|
+
const { learner = {}, schedule = {} } = config || {};
|
|
110
|
+
const saved = {
|
|
111
|
+
name: learner.name,
|
|
112
|
+
email: learner.email,
|
|
113
|
+
targetRole: learner.targetRole,
|
|
114
|
+
currentLearning: learner.currentLearning,
|
|
115
|
+
focusSkill: learner.focusSkill,
|
|
116
|
+
currentStage: learner.currentStage,
|
|
117
|
+
weeklyHours: learner.weeklyHours,
|
|
118
|
+
planDays: learner.planDays,
|
|
119
|
+
dailyEmailTime: schedule.dailyEmailTime,
|
|
120
|
+
timezone: schedule.timezone,
|
|
121
|
+
smtpHost: env.SMTP_HOST,
|
|
122
|
+
smtpPort: env.SMTP_PORT,
|
|
123
|
+
smtpUser: env.SMTP_USER,
|
|
124
|
+
smtpPass: env.SMTP_PASS,
|
|
125
|
+
smtpFrom: env.SMTP_FROM
|
|
126
|
+
};
|
|
127
|
+
return {
|
|
128
|
+
startDate: schedule.startDate,
|
|
129
|
+
defaults: Object.fromEntries(Object.entries(saved).filter(([, value]) => value !== undefined && value !== ""))
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function regeneratePlan(argv) {
|
|
134
|
+
const config = loadConfig();
|
|
135
|
+
const roleArg = valueAfter(argv, "--role");
|
|
136
|
+
if (roleArg) config.learner.targetRole = roleArg;
|
|
137
|
+
const focusSkill = valueAfter(argv, "--skill") || valueAfter(argv, "--focus-skill");
|
|
138
|
+
if (focusSkill) config.learner.focusSkill = focusSkill;
|
|
139
|
+
const currentLearning = valueAfter(argv, "--current-learning");
|
|
140
|
+
if (currentLearning) config.learner.currentLearning = currentLearning;
|
|
141
|
+
const days = Number.parseInt(valueAfter(argv, "--days") || "", 10);
|
|
142
|
+
if (days) config.learner.planDays = Math.max(30, days);
|
|
143
|
+
const plan = generate30DayPlan(config.learner);
|
|
144
|
+
writeDataJson(config, "30-day-plan.json", plan);
|
|
145
|
+
saveConfig(config);
|
|
146
|
+
outputJson({ status: "saved", plan: "data/30-day-plan.json", days: plan.days.length });
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function sendToday(argv) {
|
|
150
|
+
const dryRun = argv.includes("--dry-run");
|
|
151
|
+
const explicitDay = valueAfter(argv, "--day");
|
|
152
|
+
const { config, plan } = loadRuntime();
|
|
153
|
+
const day = explicitDay ? parsePositiveDay(explicitDay, plan) : resolveScheduledDay(config, plan);
|
|
154
|
+
if (!explicitDay && day > plan.days.length) {
|
|
155
|
+
const result = {
|
|
156
|
+
skipped: true,
|
|
157
|
+
reason: "plan-complete",
|
|
158
|
+
day,
|
|
159
|
+
planDays: plan.days.length,
|
|
160
|
+
recommendation: plan.nextSkillRecommendation
|
|
161
|
+
};
|
|
162
|
+
writeDataJson(config, "latest-email.json", { generatedAt: new Date().toISOString(), ...result });
|
|
163
|
+
outputJson(result);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const progressReview = reviewProgress(config, plan);
|
|
167
|
+
const progressionCard = buildProgressionCard(config, plan);
|
|
168
|
+
saveProgressionCard(config, progressionCard);
|
|
169
|
+
const coursePack = createCoursePack(config, plan);
|
|
170
|
+
saveCoursePack(config, coursePack);
|
|
171
|
+
const digest = createResearchDigest({
|
|
172
|
+
config,
|
|
173
|
+
topic: plan.days.find((entry) => entry.day === day)?.title || config.learner.targetRole,
|
|
174
|
+
day,
|
|
175
|
+
roleKey: plan.roleKey
|
|
176
|
+
});
|
|
177
|
+
await enrichDigestLinks(digest, { offline: argv.includes("--offline") });
|
|
178
|
+
const digestPath = saveResearchDigest(config, digest);
|
|
179
|
+
appendResearchIndex(config, digestPath, digest);
|
|
180
|
+
const env = { ...process.env, ...loadEnvFile(path.join(process.cwd(), ".env.local")) };
|
|
181
|
+
const smtp = smtpConfigFromEnv(env);
|
|
182
|
+
const message = renderDailyEmail(config, plan, day, { progressReview, researchDigest: digest, progressionCard, coursePack });
|
|
183
|
+
const result = await sendMail({ smtp, message, dryRun });
|
|
184
|
+
writeDataJson(config, "latest-email.json", { generatedAt: new Date().toISOString(), researchDigest: digestPath, ...result });
|
|
185
|
+
outputJson(result);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function resolveScheduledDay(config, plan, now = new Date()) {
|
|
189
|
+
const startDate = config.schedule?.startDate;
|
|
190
|
+
if (!startDate) return 1;
|
|
191
|
+
const today = localDateString(now, config.schedule?.timezone);
|
|
192
|
+
const elapsedDays = daysBetweenDateStrings(startDate, today);
|
|
193
|
+
const day = elapsedDays + 1;
|
|
194
|
+
return Number.isFinite(day) ? Math.max(1, day) : 1;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function showStatus() {
|
|
198
|
+
const { config, plan } = loadRuntime();
|
|
199
|
+
outputJson(planStatus(config, plan));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async function research(argv) {
|
|
203
|
+
const { config, plan } = loadRuntime();
|
|
204
|
+
const day = Number.parseInt(valueAfter(argv, "--day") || "1", 10);
|
|
205
|
+
const topic = valueAfter(argv, "--topic") || plan.days.find((entry) => entry.day === day)?.title || config.learner.targetRole;
|
|
206
|
+
const digest = createResearchDigest({ config, topic, day, roleKey: plan.roleKey });
|
|
207
|
+
await enrichDigestLinks(digest, { offline: argv.includes("--offline") });
|
|
208
|
+
const digestPath = saveResearchDigest(config, digest);
|
|
209
|
+
appendResearchIndex(config, digestPath, digest);
|
|
210
|
+
outputJson({ status: "saved", path: digestPath, digest });
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function links(argv) {
|
|
214
|
+
const { config, plan } = loadRuntime();
|
|
215
|
+
const day = Number.parseInt(valueAfter(argv, "--day") || "1", 10);
|
|
216
|
+
const topic = valueAfter(argv, "--topic") || plan.days.find((entry) => entry.day === day)?.title || config.learner.targetRole;
|
|
217
|
+
const digest = createResearchDigest({ config, topic, day, roleKey: plan.roleKey });
|
|
218
|
+
await enrichDigestLinks(digest, { offline: argv.includes("--offline"), limit: 3 });
|
|
219
|
+
const payload = {
|
|
220
|
+
generatedAt: new Date().toISOString(),
|
|
221
|
+
day,
|
|
222
|
+
topic,
|
|
223
|
+
liveResolved: digest.liveResolved,
|
|
224
|
+
topVideo: digest.topVideo,
|
|
225
|
+
topRepo: digest.topRepo,
|
|
226
|
+
topDoc: digest.topDoc,
|
|
227
|
+
videos: digest.videos || [],
|
|
228
|
+
repos: digest.repos || []
|
|
229
|
+
};
|
|
230
|
+
writeDataJson(config, "links.json", payload);
|
|
231
|
+
outputJson({ status: "resolved", path: "data/links.json", ...payload });
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function harness(argv) {
|
|
235
|
+
const { config, plan } = loadRuntime();
|
|
236
|
+
const mode = valueAfter(argv, "--mode") || "daily";
|
|
237
|
+
const payload = createHarness(config, plan, mode);
|
|
238
|
+
const paths = saveHarness(config, payload);
|
|
239
|
+
outputJson({ status: "saved", ...paths, harness: payload });
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function courses() {
|
|
243
|
+
const { config, plan } = loadRuntime();
|
|
244
|
+
const pack = createCoursePack(config, plan);
|
|
245
|
+
const paths = saveCoursePack(config, pack);
|
|
246
|
+
outputJson({ status: "saved", ...paths, learningSources: pack });
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function logProgress(argv) {
|
|
250
|
+
const { config, plan } = loadRuntime();
|
|
251
|
+
const entry = appendProgress(config, {
|
|
252
|
+
day: valueAfter(argv, "--day"),
|
|
253
|
+
completed: valueAfter(argv, "--completed"),
|
|
254
|
+
evidence: valueAfter(argv, "--evidence"),
|
|
255
|
+
minutes: valueAfter(argv, "--minutes"),
|
|
256
|
+
confidence: valueAfter(argv, "--confidence"),
|
|
257
|
+
blocker: valueAfter(argv, "--blocker")
|
|
258
|
+
});
|
|
259
|
+
const review = reviewProgress(config, plan);
|
|
260
|
+
const cardPaths = saveProgressionCard(config, buildProgressionCard(config, plan));
|
|
261
|
+
writeDataJson(config, "latest-review.json", review);
|
|
262
|
+
outputJson({ status: "logged", entry, review, progressionCard: cardPaths.markdownPath });
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function weeklySummary(argv) {
|
|
266
|
+
const { config, plan } = loadRuntime();
|
|
267
|
+
const week = Number.parseInt(valueAfter(argv, "--week") || "1", 10);
|
|
268
|
+
const summary = createWeeklySummary(config, plan, week);
|
|
269
|
+
writeDataJson(config, `weekly-summary-${week}.json`, summary);
|
|
270
|
+
outputJson(summary);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function recommendNext() {
|
|
274
|
+
const { config, plan } = loadRuntime();
|
|
275
|
+
const review = reviewProgress(config, plan);
|
|
276
|
+
const currentFocus = config.learner.focusSkill || plan.primarySkill;
|
|
277
|
+
const recommendation = plan.nextSkillRecommendation || {
|
|
278
|
+
afterDay: plan.days.length,
|
|
279
|
+
currentFocus,
|
|
280
|
+
recommendedNextSkill: "portfolio-level capstone improvement",
|
|
281
|
+
reason: "Finish the current plan, then deepen the artifact with evaluation, deployment, and interview proof."
|
|
282
|
+
};
|
|
283
|
+
const payload = {
|
|
284
|
+
generatedAt: new Date().toISOString(),
|
|
285
|
+
canAdvance: review.completedDays >= plan.days.length,
|
|
286
|
+
completedDays: review.completedDays,
|
|
287
|
+
requiredDays: plan.days.length,
|
|
288
|
+
currentFocus,
|
|
289
|
+
...recommendation
|
|
290
|
+
};
|
|
291
|
+
writeDataJson(config, "next-skill-recommendation.json", payload);
|
|
292
|
+
outputJson(payload);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function progressCard() {
|
|
296
|
+
const { config, plan } = loadRuntime();
|
|
297
|
+
const card = buildProgressionCard(config, plan);
|
|
298
|
+
const paths = saveProgressionCard(config, card);
|
|
299
|
+
outputJson({ status: "saved", ...paths, card });
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function terminalCard() {
|
|
303
|
+
const { config, plan } = loadRuntime();
|
|
304
|
+
const card = buildProgressionCard(config, plan);
|
|
305
|
+
const paths = saveProgressionCard(config, card);
|
|
306
|
+
outputJson({
|
|
307
|
+
status: "saved",
|
|
308
|
+
terminalSvgPath: paths.terminalSvgPath,
|
|
309
|
+
terminalLines: card.terminalLines
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function setupSecrets() {
|
|
314
|
+
const config = loadConfig();
|
|
315
|
+
const env = loadEnvFile(path.join(process.cwd(), ".env.local"));
|
|
316
|
+
const commands = [
|
|
317
|
+
secretCommand("SMTP_HOST", env.SMTP_HOST || "<smtp-host>"),
|
|
318
|
+
secretCommand("SMTP_PORT", env.SMTP_PORT || "465"),
|
|
319
|
+
secretCommand("SMTP_USER", env.SMTP_USER || "<smtp-user>"),
|
|
320
|
+
"gh secret set SMTP_PASS",
|
|
321
|
+
secretCommand("SMTP_FROM", env.SMTP_FROM || config.email.to)
|
|
322
|
+
];
|
|
323
|
+
const payload = {
|
|
324
|
+
status: "manual-secret-commands",
|
|
325
|
+
note: "Run these after gh auth login. Secrets are not committed.",
|
|
326
|
+
commands
|
|
327
|
+
};
|
|
328
|
+
outputJson(payload);
|
|
329
|
+
return payload;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function secretCommand(key, value) {
|
|
333
|
+
return `gh secret set ${key} --body "${String(value).replace(/"/g, '\\"')}"`;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function doctor() {
|
|
337
|
+
const configPath = path.join(process.cwd(), CONFIG_FILE);
|
|
338
|
+
const configExists = fs.existsSync(configPath);
|
|
339
|
+
const parsedConfig = configExists ? readJson(configPath) : null;
|
|
340
|
+
const configValidation = parsedConfig ? validateConfig(parsedConfig) : { valid: false, errors: ["Missing configuration"] };
|
|
341
|
+
|
|
342
|
+
const scheduled = workflowStatus();
|
|
343
|
+
const localSettings = { ...process.env, ...loadEnvFile(path.join(process.cwd(), ".env.local")) };
|
|
344
|
+
const missingEmailSettings = ["SMTP_HOST", "SMTP_USER", "SMTP_PASS"].filter((key) => !localSettings[key]);
|
|
345
|
+
|
|
346
|
+
const checks = {
|
|
347
|
+
agentsMd: fs.existsSync(path.join(process.cwd(), "AGENTS.md")),
|
|
348
|
+
geminiMd: fs.existsSync(path.join(process.cwd(), "GEMINI.md")),
|
|
349
|
+
claudeSkill: fs.existsSync(path.join(process.cwd(), ".claude", "skills", "kordexa", "SKILL.md")) || fs.existsSync(path.join(process.cwd(), ".claude", "skills", "eduorchestrate", "SKILL.md")),
|
|
350
|
+
mcpManifest: fs.existsSync(path.join(process.cwd(), ".kordexa", "mcp", "manifest.json")) || fs.existsSync(path.join(process.cwd(), ".eduorchestrate", "mcp", "manifest.json")),
|
|
351
|
+
config: (configExists && configValidation.valid) || (fs.existsSync(path.join(process.cwd(), "eduorchestrate.config.json")) && validateConfig(readJson(path.join(process.cwd(), "eduorchestrate.config.json"))).valid),
|
|
352
|
+
workflow: scheduled.current,
|
|
353
|
+
localEnv: fs.existsSync(path.join(process.cwd(), ".env.local")),
|
|
354
|
+
localEmail: missingEmailSettings.length === 0
|
|
355
|
+
};
|
|
356
|
+
const { workflow, localEnv, localEmail, ...setupChecks } = checks;
|
|
357
|
+
const setupComplete = Object.values(setupChecks).every(Boolean);
|
|
358
|
+
const needsUpgrade = setupComplete && scheduled.outdated;
|
|
359
|
+
const nextSteps = [];
|
|
360
|
+
if (!setupComplete || (!workflow && !scheduled.outdated)) nextSteps.push("Run npx kordexa to finish setup.");
|
|
361
|
+
if (needsUpgrade) nextSteps.push("Run npx kordexa --yes to update the scheduled workflow. Your profile, email settings, progress and start date are kept.");
|
|
362
|
+
if (!localEmail) nextSteps.push(`Add ${missingEmailSettings.join(", ")} to .env.local to send email from this machine. For scheduled email, run npx kordexa setup-secrets.`);
|
|
363
|
+
let status = "ready";
|
|
364
|
+
if (!setupComplete || (!workflow && !scheduled.outdated)) status = "needs-setup";
|
|
365
|
+
else if (needsUpgrade) status = "needs-upgrade";
|
|
366
|
+
else if (!localEmail) status = "needs-email-setup";
|
|
367
|
+
const result = {
|
|
368
|
+
status,
|
|
369
|
+
checks,
|
|
370
|
+
...(nextSteps.length ? { nextSteps } : {}),
|
|
371
|
+
...(scheduled.warnings.length ? { warnings: scheduled.warnings } : {}),
|
|
372
|
+
...(configValidation.errors.length > 0 && configExists ? { configErrors: configValidation.errors } : {})
|
|
373
|
+
};
|
|
374
|
+
outputJson(result);
|
|
375
|
+
return result;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function printHelp() {
|
|
379
|
+
console.log(`Kordexa — AI-powered daily learning command center
|
|
380
|
+
|
|
381
|
+
Commands:
|
|
382
|
+
npx kordexa Run one-command onboarding
|
|
383
|
+
npx kordexa /kordexa Same as onboarding
|
|
384
|
+
npx kordexa --yes --restart Run setup again and restart the plan today
|
|
385
|
+
npx kordexa plan --role "Agentic AI and LLM Engineer"
|
|
386
|
+
npx kordexa plan --days 45 --skill "RAG evaluation"
|
|
387
|
+
npx kordexa status
|
|
388
|
+
npx kordexa harness
|
|
389
|
+
npx kordexa courses
|
|
390
|
+
npx kordexa research --day 1
|
|
391
|
+
npx kordexa links --day 1
|
|
392
|
+
npx kordexa send-today --dry-run
|
|
393
|
+
npx kordexa log-progress --day 1 --completed "Built setup" --evidence "Repo link"
|
|
394
|
+
npx kordexa weekly-summary --week 1
|
|
395
|
+
npx kordexa recommend-next
|
|
396
|
+
npx kordexa progress-card
|
|
397
|
+
npx kordexa terminal-card
|
|
398
|
+
npx kordexa setup-secrets
|
|
399
|
+
npx kordexa doctor
|
|
400
|
+
|
|
401
|
+
Note: /eduorchestrate stays available inside agents as a legacy alias for /kordexa.
|
|
402
|
+
`);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function parseKeyValues(argv) {
|
|
406
|
+
const map = {
|
|
407
|
+
"--name": "name",
|
|
408
|
+
"--email": "email",
|
|
409
|
+
"--role": "targetRole",
|
|
410
|
+
"--target-role": "targetRole",
|
|
411
|
+
"--current-learning": "currentLearning",
|
|
412
|
+
"--skill": "focusSkill",
|
|
413
|
+
"--focus-skill": "focusSkill",
|
|
414
|
+
"--stage": "currentStage",
|
|
415
|
+
"--current-stage": "currentStage",
|
|
416
|
+
"--weekly-hours": "weeklyHours",
|
|
417
|
+
"--days": "planDays",
|
|
418
|
+
"--time": "dailyEmailTime",
|
|
419
|
+
"--timezone": "timezone",
|
|
420
|
+
"--smtp-host": "smtpHost",
|
|
421
|
+
"--smtp-port": "smtpPort",
|
|
422
|
+
"--smtp-user": "smtpUser",
|
|
423
|
+
"--smtp-pass": "smtpPass",
|
|
424
|
+
"--smtp-from": "smtpFrom"
|
|
425
|
+
};
|
|
426
|
+
const overrides = {};
|
|
427
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
428
|
+
const key = map[argv[index]];
|
|
429
|
+
if (key && argv[index + 1]) overrides[key] = argv[index + 1];
|
|
430
|
+
}
|
|
431
|
+
return overrides;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function valueAfter(argv, flag) {
|
|
435
|
+
const index = argv.indexOf(flag);
|
|
436
|
+
return index >= 0 ? argv[index + 1] : undefined;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function parsePositiveDay(value, plan) {
|
|
440
|
+
if (!/^\d+$/.test(String(value || ""))) throw new Error(`Invalid day: ${value}`);
|
|
441
|
+
const day = Number.parseInt(value, 10);
|
|
442
|
+
if (!Number.isInteger(day) || day < 1) throw new Error(`Invalid day: ${value}`);
|
|
443
|
+
if (plan?.days?.length && day > plan.days.length) throw new Error(`Day ${day} is outside this ${plan.days.length}-day plan.`);
|
|
444
|
+
return day;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function localDateString(date = new Date(), timezone = "UTC") {
|
|
448
|
+
try {
|
|
449
|
+
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
450
|
+
timeZone: timezone || "UTC",
|
|
451
|
+
year: "numeric",
|
|
452
|
+
month: "2-digit",
|
|
453
|
+
day: "2-digit"
|
|
454
|
+
}).formatToParts(date);
|
|
455
|
+
const values = Object.fromEntries(parts.map((part) => [part.type, part.value]));
|
|
456
|
+
return `${values.year}-${values.month}-${values.day}`;
|
|
457
|
+
} catch {
|
|
458
|
+
return date.toISOString().slice(0, 10);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function daysBetweenDateStrings(startDate, endDate) {
|
|
463
|
+
const start = dateStringToUtc(startDate);
|
|
464
|
+
const end = dateStringToUtc(endDate);
|
|
465
|
+
return Math.floor((end.getTime() - start.getTime()) / 86400000);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function dateStringToUtc(value) {
|
|
469
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value || "");
|
|
470
|
+
if (!match) return new Date(Number.NaN);
|
|
471
|
+
const year = Number(match[1]);
|
|
472
|
+
const month = Number(match[2]);
|
|
473
|
+
const day = Number(match[3]);
|
|
474
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
475
|
+
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {
|
|
476
|
+
return new Date(Number.NaN);
|
|
477
|
+
}
|
|
478
|
+
return date;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function loadRuntime() {
|
|
482
|
+
const config = loadConfig();
|
|
483
|
+
return { config, plan: loadOrCreatePlan(config) };
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function loadOrCreatePlan(config) {
|
|
487
|
+
const planPath = path.join(resolveDataDir(config), "30-day-plan.json");
|
|
488
|
+
const existing = readJson(planPath);
|
|
489
|
+
if (hasPlanDays(existing)) return existing;
|
|
490
|
+
const plan = generate30DayPlan(config.learner);
|
|
491
|
+
writeJson(planPath, plan);
|
|
492
|
+
return plan;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function hasPlanDays(plan) {
|
|
496
|
+
return Array.isArray(plan?.days) && plan.days.length > 0;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function writeDataJson(config, fileName, payload) {
|
|
500
|
+
writeJson(path.join(resolveDataDir(config), fileName), payload);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function outputJson(payload) {
|
|
504
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
505
|
+
}
|
package/src/config.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export const CONFIG_FILE = "kordexa.config.json";
|
|
5
|
+
export const LEGACY_CONFIG_FILE = "eduorchestrate.config.json";
|
|
6
|
+
export const LOCAL_ENV_FILE = ".env.local";
|
|
7
|
+
|
|
8
|
+
export function ensureDir(dirPath) {
|
|
9
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function readJson(filePath, fallback = null) {
|
|
13
|
+
if (!fs.existsSync(filePath)) return fallback;
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
16
|
+
} catch {
|
|
17
|
+
return fallback;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function writeJson(filePath, payload) {
|
|
22
|
+
ensureDir(path.dirname(filePath));
|
|
23
|
+
fs.writeFileSync(filePath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function fileSafeDate(date = new Date()) {
|
|
27
|
+
return date.toISOString().replace(/[:.]/g, "");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function validateConfig(config) {
|
|
31
|
+
const errors = [];
|
|
32
|
+
if (!config || typeof config !== "object") {
|
|
33
|
+
return { valid: false, errors: ["Configuration must be an object"] };
|
|
34
|
+
}
|
|
35
|
+
if (!config.learner || typeof config.learner !== "object") {
|
|
36
|
+
errors.push("Missing required 'learner' profile section");
|
|
37
|
+
} else {
|
|
38
|
+
if (!config.learner.name) errors.push("Missing 'learner.name'");
|
|
39
|
+
if (!config.learner.email) errors.push("Missing 'learner.email'");
|
|
40
|
+
if (!config.learner.targetRole) errors.push("Missing 'learner.targetRole'");
|
|
41
|
+
}
|
|
42
|
+
if (!config.schedule || typeof config.schedule !== "object") {
|
|
43
|
+
errors.push("Missing required 'schedule' section");
|
|
44
|
+
} else {
|
|
45
|
+
if (!config.schedule.dailyEmailTime) errors.push("Missing 'schedule.dailyEmailTime'");
|
|
46
|
+
if (!config.schedule.timezone) errors.push("Missing 'schedule.timezone'");
|
|
47
|
+
}
|
|
48
|
+
return { valid: errors.length === 0, errors };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function loadConfig(rootDir = process.cwd()) {
|
|
52
|
+
// File times are not reliable after a git checkout, so the primary file
|
|
53
|
+
// always wins and the legacy file is only used when it is the sole config.
|
|
54
|
+
const primaryPath = path.join(rootDir, CONFIG_FILE);
|
|
55
|
+
const legacyPath = path.join(rootDir, LEGACY_CONFIG_FILE);
|
|
56
|
+
const configPath = fs.existsSync(primaryPath) ? primaryPath : legacyPath;
|
|
57
|
+
const config = fs.existsSync(configPath) ? readJson(configPath) : null;
|
|
58
|
+
if (!config) {
|
|
59
|
+
throw new Error(`No ${CONFIG_FILE} found. Run npx kordexa first.`);
|
|
60
|
+
}
|
|
61
|
+
return config;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function saveConfig(config, rootDir = process.cwd()) {
|
|
65
|
+
writeJson(path.join(rootDir, CONFIG_FILE), config);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function appendGitignore(entries, rootDir = process.cwd()) {
|
|
69
|
+
const gitignorePath = path.join(rootDir, ".gitignore");
|
|
70
|
+
const existing = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, "utf8") : "";
|
|
71
|
+
const lines = new Set(existing.split(/\r?\n/).filter(Boolean));
|
|
72
|
+
let changed = false;
|
|
73
|
+
for (const entry of entries) {
|
|
74
|
+
if (!lines.has(entry)) {
|
|
75
|
+
lines.add(entry);
|
|
76
|
+
changed = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (changed) {
|
|
80
|
+
fs.writeFileSync(gitignorePath, `${Array.from(lines).join("\n")}\n`, "utf8");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Updates only the provided keys, so saved passwords, API keys and comments stay.
|
|
85
|
+
export function writeLocalEnv(values, rootDir = process.cwd()) {
|
|
86
|
+
const envPath = path.join(rootDir, LOCAL_ENV_FILE);
|
|
87
|
+
const updates = new Map(
|
|
88
|
+
Object.entries(values)
|
|
89
|
+
.filter(([, value]) => value !== undefined && value !== "")
|
|
90
|
+
.map(([key, value]) => [key, String(value).replace(/\n/g, "\\n")])
|
|
91
|
+
);
|
|
92
|
+
const existing = fs.existsSync(envPath) ? fs.readFileSync(envPath, "utf8").split(/\r?\n/) : [];
|
|
93
|
+
const lines = existing.map((line) => {
|
|
94
|
+
const key = line.trim().startsWith("#") || !line.includes("=") ? null : line.split("=")[0].trim();
|
|
95
|
+
if (!key || !updates.has(key)) return line;
|
|
96
|
+
const value = updates.get(key);
|
|
97
|
+
updates.delete(key);
|
|
98
|
+
return `${key}=${value}`;
|
|
99
|
+
});
|
|
100
|
+
while (lines.at(-1) === "") lines.pop();
|
|
101
|
+
for (const [key, value] of updates) lines.push(`${key}=${value}`);
|
|
102
|
+
fs.writeFileSync(envPath, `${lines.join("\n")}\n`, "utf8");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function loadEnvFile(filePath) {
|
|
106
|
+
if (!fs.existsSync(filePath)) return {};
|
|
107
|
+
const env = {};
|
|
108
|
+
for (const line of fs.readFileSync(filePath, "utf8").split(/\r?\n/)) {
|
|
109
|
+
if (!line || line.trim().startsWith("#") || !line.includes("=")) continue;
|
|
110
|
+
const [key, ...rest] = line.split("=");
|
|
111
|
+
env[key.trim()] = rest.join("=").trim();
|
|
112
|
+
}
|
|
113
|
+
return env;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function resolveDataDir(config, rootDir = process.cwd()) {
|
|
117
|
+
return path.join(rootDir, config.dataDir || "data");
|
|
118
|
+
}
|