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.
Files changed (64) hide show
  1. package/.claude/commands/eduorchestrate-card.md +5 -0
  2. package/.claude/commands/eduorchestrate-log.md +6 -0
  3. package/.claude/commands/eduorchestrate-next.md +5 -0
  4. package/.claude/commands/eduorchestrate-research.md +6 -0
  5. package/.claude/commands/eduorchestrate-send.md +5 -0
  6. package/.claude/commands/eduorchestrate-status.md +5 -0
  7. package/.claude/commands/eduorchestrate-weekly.md +6 -0
  8. package/.claude/commands/kordexa-card.md +5 -0
  9. package/.claude/commands/kordexa-log.md +6 -0
  10. package/.claude/commands/kordexa-next.md +5 -0
  11. package/.claude/commands/kordexa-research.md +6 -0
  12. package/.claude/commands/kordexa-send.md +5 -0
  13. package/.claude/commands/kordexa-status.md +5 -0
  14. package/.claude/commands/kordexa-weekly.md +6 -0
  15. package/.claude/skills/eduorchestrate/SKILL.md +24 -0
  16. package/.claude/skills/kordexa/SKILL.md +24 -0
  17. package/.eduorchestrate/adapters/antigravity/manifest.json +31 -0
  18. package/.eduorchestrate/adapters/codex/AGENTS.md +23 -0
  19. package/.eduorchestrate/adapters/generic/EDUORCHESTRATE.md +19 -0
  20. package/.eduorchestrate/adapters/hermas/manifest.json +31 -0
  21. package/.eduorchestrate/adapters/openclaw/SKILL.md +24 -0
  22. package/.eduorchestrate/mcp/manifest.json +19 -0
  23. package/.eduorchestrate/mcp/server.js +47 -0
  24. package/.kordexa/adapters/antigravity/manifest.json +31 -0
  25. package/.kordexa/adapters/codex/AGENTS.md +23 -0
  26. package/.kordexa/adapters/generic/KORDEXA.md +19 -0
  27. package/.kordexa/adapters/hermas/manifest.json +31 -0
  28. package/.kordexa/adapters/openclaw/SKILL.md +24 -0
  29. package/.kordexa/mcp/manifest.json +19 -0
  30. package/.kordexa/mcp/server.js +47 -0
  31. package/AGENTS.md +25 -0
  32. package/GEMINI.md +7 -0
  33. package/LICENSE +22 -0
  34. package/README.md +311 -2
  35. package/agents/eduorchestrate-agent.yaml +18 -0
  36. package/agents/kordexa-agent.yaml +18 -0
  37. package/bin/kordexa.js +8 -0
  38. package/package.json +38 -4
  39. package/skills/eduorchestrate/SKILL.md +115 -0
  40. package/skills/eduorchestrate/agents/openai.yaml +4 -0
  41. package/skills/eduorchestrate/assets/default-terminal-card.svg +1 -0
  42. package/skills/eduorchestrate/references/agent-contracts.md +107 -0
  43. package/skills/eduorchestrate/references/learning-system.md +119 -0
  44. package/skills/kordexa/SKILL.md +115 -0
  45. package/skills/kordexa/agents/openai.yaml +4 -0
  46. package/skills/kordexa/assets/default-terminal-card.svg +1 -0
  47. package/skills/kordexa/references/agent-contracts.md +107 -0
  48. package/skills/kordexa/references/learning-system.md +119 -0
  49. package/src/adapters.js +203 -0
  50. package/src/card-components.js +103 -0
  51. package/src/cli.js +505 -0
  52. package/src/config.js +118 -0
  53. package/src/courses.js +150 -0
  54. package/src/email.js +173 -0
  55. package/src/harness.js +130 -0
  56. package/src/planner.js +423 -0
  57. package/src/progress.js +93 -0
  58. package/src/progression-card.js +137 -0
  59. package/src/prompts.js +77 -0
  60. package/src/research.js +288 -0
  61. package/src/workflow.js +161 -0
  62. package/tests/node/eduorchestrate.test.js +558 -0
  63. package/tests/node/launch-ready.test.js +101 -0
  64. package/tests/node/safe-setup.test.js +313 -0
@@ -0,0 +1,203 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { ensureDir } from "./config.js";
4
+
5
+ const MAIL_RESUME_POLICY = `Mail resume policy: apply this to every supported agent, not only Codex. When an agent runs in a resumable browser or workspace instance, treat each resume as a daily-mail checkpoint: load the harness or status, resolve the current plan day, and run npx kordexa send-today for the due day after SMTP setup. If SMTP secrets are missing or real sending has not been approved, run npx kordexa send-today --dry-run and ask before sending. GitHub Actions remains the scheduled no-browser path.`;
6
+
7
+ const UNIVERSAL_PROMPT = `Use /kordexa (or legacy /eduorchestrate) as the learner command. When invoked, load the Kordexa workflow and its prebuilt terminal-card program; never recreate, type out, or hand-design the card UI in the agent prompt. Ask for missing learner profile details, ask what the learner is currently studying, ask the first skill they want to focus on, generate or update an adaptive plan with a fixed 30-day minimum, research current and trending references, send or preview daily emails, log progress, load the bundled default card or CLI-produced card artifact, summarize the week, recommend the next skill after the plan window, and keep recommendations practical, sourced, and focused. Research resolves a concrete top video link (digest.topVideo.url) and top GitHub repo (digest.topRepo.url) so the daily email carries a watchable link, not only search queries; on network failure it falls back to search URLs, and --offline or KORDEXA_OFFLINE=1 skips resolution. The dependency-free mailer supports implicit TLS (port 465) and STARTTLS (port 587). ${MAIL_RESUME_POLICY} If native slash commands are unavailable, treat "kordexa", "use Kordexa", "eduorchestrate", or "use EduOrchestrate" as equivalent to /kordexa.`;
8
+
9
+ // Primary adapters carry the Kordexa name. Legacy /eduorchestrate adapters stay
10
+ // available, but every adapter runs the kordexa package: on npm, the
11
+ // eduorchestrate name belongs to the separate upstream project.
12
+ const LEGACY_MENTIONS = [
13
+ ["legacy /eduorchestrate", "\u0001"],
14
+ ['"eduorchestrate", or "use EduOrchestrate"', "\u0002"]
15
+ ];
16
+
17
+ const MANAGED_START = "<!-- kordexa:start -->";
18
+ const MANAGED_END = "<!-- kordexa:end -->";
19
+ const OLD_GENERATED_HEADING = /^# (?:(?:EduOrchestrate|Kordexa) Agent Instructions|Gemini (?:EduOrchestrate|Kordexa) Context)\s/;
20
+
21
+ function primary(text) {
22
+ let output = text;
23
+ for (const [mention, token] of LEGACY_MENTIONS) output = output.split(mention).join(token);
24
+ output = output.replace(/EDUORCHESTRATE/g, "KORDEXA").replace(/EduOrchestrate/g, "Kordexa").replace(/eduorchestrate/g, "kordexa");
25
+ for (const [mention, token] of LEGACY_MENTIONS) output = output.split(token).join(mention);
26
+ return output;
27
+ }
28
+
29
+ // Per-command Claude Code slash commands. Each becomes a separate /<name>
30
+ // entry in the slash menu so the daily loop is reachable without typing npx.
31
+ const CLAUDE_COMMANDS = [
32
+ {
33
+ name: "eduorchestrate-status",
34
+ description: "EduOrchestrate: current learning day, momentum, and next action",
35
+ allowedTools: "Bash(npx kordexa status:*)",
36
+ body: "Show the learner's EduOrchestrate status. Run `npx kordexa status` and present, using only the command output: learner, role, primary skill, currently learning, active day, progress (completed/total), momentum, risk, and the next action. Do not invent values."
37
+ },
38
+ {
39
+ name: "eduorchestrate-research",
40
+ description: "EduOrchestrate: resolve today's sourced links (video, docs, repo)",
41
+ argumentHint: "[day]",
42
+ allowedTools: "Bash(npx kordexa research:*), Bash(npx kordexa status:*)",
43
+ body: "Resolve the learner's research links. If \"$ARGUMENTS\" contains a day number use it, otherwise read the current day from `npx kordexa status`. Then run `npx kordexa research --day <day>` and present the resolved top YouTube video link (with its title), the official docs, and the GitHub repo result. Keep it short and link-first."
44
+ },
45
+ {
46
+ name: "eduorchestrate-send",
47
+ description: "EduOrchestrate: preview today's learning email (dry-run, never sends)",
48
+ allowedTools: "Bash(npx kordexa send-today --dry-run:*)",
49
+ body: "Preview today's EduOrchestrate email. Run `npx kordexa send-today --dry-run` and summarize what would be sent: subject, the top video link, docs, build task, and timebox. This command is preview-only — never run it without --dry-run."
50
+ },
51
+ {
52
+ name: "eduorchestrate-log",
53
+ description: "EduOrchestrate: log today's progress with evidence",
54
+ argumentHint: "<what you did> | <evidence link>",
55
+ allowedTools: "Bash(npx kordexa log-progress:*), Bash(npx kordexa status:*)",
56
+ body: "Log the learner's progress. Read what they completed and an evidence link/path from \"$ARGUMENTS\". If either is missing, ASK for it — never log a placeholder entry. Read the current day from `npx kordexa status`, then run `npx kordexa log-progress --day <day> --completed \"<note>\" --evidence \"<link>\"` (optionally --confidence <1-5>) and confirm the updated momentum."
57
+ },
58
+ {
59
+ name: "eduorchestrate-card",
60
+ description: "EduOrchestrate: render the skill progression card",
61
+ allowedTools: "Bash(npx kordexa progress-card:*)",
62
+ body: "Render the learner's skill progression card. Run `npx kordexa progress-card` and show completed/total days, the commit-style grid, and the terminal-card status lines. Mention the saved data/terminal-card.svg."
63
+ },
64
+ {
65
+ name: "eduorchestrate-weekly",
66
+ description: "EduOrchestrate: summarize a learning week",
67
+ argumentHint: "[week]",
68
+ allowedTools: "Bash(npx kordexa weekly-summary:*)",
69
+ body: "Summarize a learning week. Run `npx kordexa weekly-summary --week <n>` (n from \"$ARGUMENTS\", default 1) and present planned vs completed days and the next-week focus."
70
+ },
71
+ {
72
+ name: "eduorchestrate-next",
73
+ description: "EduOrchestrate: recommend the next skill after the plan window",
74
+ allowedTools: "Bash(npx kordexa recommend-next:*)",
75
+ body: "Recommend the next skill. Run `npx kordexa recommend-next` and present whether the learner can advance, the recommended next skill, and the reason."
76
+ }
77
+ ];
78
+
79
+ function commandMarkdown(command) {
80
+ const frontmatter = ["---", `description: ${command.description}`];
81
+ if (command.argumentHint) frontmatter.push(`argument-hint: ${command.argumentHint}`);
82
+ if (command.allowedTools) frontmatter.push(`allowed-tools: ${command.allowedTools}`);
83
+ frontmatter.push("---", "");
84
+ return `${frontmatter.join("\n")}${command.body}\n`;
85
+ }
86
+
87
+ export function writeAgentAdapters(rootDir = process.cwd()) {
88
+ const outputs = [];
89
+ // Kordexa primary adapters
90
+ outputs.push(writeFile(rootDir, ".claude/skills/kordexa/SKILL.md", primary(claudeSkill())));
91
+ outputs.push(writeFile(rootDir, ".kordexa/adapters/codex/AGENTS.md", primary(agentsMd())));
92
+ outputs.push(writeFile(rootDir, ".kordexa/adapters/openclaw/SKILL.md", primary(genericSkill("openclaw"))));
93
+ outputs.push(writeFile(rootDir, ".kordexa/adapters/antigravity/manifest.json", primary(adapterManifest("antigravity"))));
94
+ outputs.push(writeFile(rootDir, ".kordexa/adapters/hermas/manifest.json", primary(adapterManifest("hermas"))));
95
+ outputs.push(writeFile(rootDir, ".kordexa/adapters/generic/KORDEXA.md", primary(genericInstructions())));
96
+ outputs.push(writeFile(rootDir, ".kordexa/mcp/server.js", primary(mcpServer())));
97
+ outputs.push(writeFile(rootDir, ".kordexa/mcp/manifest.json", primary(mcpManifest())));
98
+
99
+ // EduOrchestrate legacy compatibility adapters
100
+ outputs.push(writeFile(rootDir, ".claude/skills/eduorchestrate/SKILL.md", claudeSkill()));
101
+ outputs.push(writeManagedFile(rootDir, "AGENTS.md", primary(agentsMd())));
102
+ outputs.push(writeManagedFile(rootDir, "GEMINI.md", primary(geminiMd())));
103
+ outputs.push(writeFile(rootDir, ".eduorchestrate/adapters/codex/AGENTS.md", agentsMd()));
104
+ outputs.push(writeFile(rootDir, ".eduorchestrate/adapters/openclaw/SKILL.md", genericSkill("openclaw")));
105
+ outputs.push(writeFile(rootDir, ".eduorchestrate/adapters/antigravity/manifest.json", adapterManifest("antigravity")));
106
+ outputs.push(writeFile(rootDir, ".eduorchestrate/adapters/hermas/manifest.json", adapterManifest("hermas")));
107
+ outputs.push(writeFile(rootDir, ".eduorchestrate/adapters/generic/EDUORCHESTRATE.md", genericInstructions()));
108
+ outputs.push(writeFile(rootDir, ".eduorchestrate/mcp/server.js", mcpServer()));
109
+ outputs.push(writeFile(rootDir, ".eduorchestrate/mcp/manifest.json", mcpManifest()));
110
+
111
+ for (const command of CLAUDE_COMMANDS) {
112
+ outputs.push(writeFile(rootDir, `.claude/commands/${command.name}.md`, commandMarkdown(command)));
113
+ const kordexaName = command.name.replace("eduorchestrate-", "kordexa-");
114
+ outputs.push(writeFile(rootDir, `.claude/commands/${kordexaName}.md`, primary(commandMarkdown(command))));
115
+ }
116
+ return outputs;
117
+ }
118
+
119
+ function writeFile(rootDir, relativePath, content) {
120
+ const filePath = path.join(rootDir, relativePath);
121
+ ensureDir(path.dirname(filePath));
122
+ fs.writeFileSync(filePath, content, "utf8");
123
+ return relativePath;
124
+ }
125
+
126
+ // AGENTS.md and GEMINI.md are shared with the learner's project, so Kordexa only
127
+ // owns the section between these markers.
128
+ function writeManagedFile(rootDir, relativePath, content) {
129
+ const filePath = path.join(rootDir, relativePath);
130
+ const block = `${MANAGED_START}\n${content.trimEnd()}\n${MANAGED_END}\n`;
131
+ if (!fs.existsSync(filePath)) return writeFile(rootDir, relativePath, block);
132
+ const existing = fs.readFileSync(filePath, "utf8");
133
+ const start = existing.indexOf(MANAGED_START);
134
+ const end = existing.indexOf(MANAGED_END);
135
+ if (start >= 0 && end > start) {
136
+ return writeFile(rootDir, relativePath, `${existing.slice(0, start)}${block.trimEnd()}${existing.slice(end + MANAGED_END.length)}`);
137
+ }
138
+ if (OLD_GENERATED_HEADING.test(existing)) {
139
+ const backupPath = `${filePath}.kordexa-backup`;
140
+ if (!fs.existsSync(backupPath)) fs.copyFileSync(filePath, backupPath);
141
+ return writeFile(rootDir, relativePath, block);
142
+ }
143
+ return writeFile(rootDir, relativePath, `${existing.trimEnd()}\n\n${block}`);
144
+ }
145
+
146
+ function cliExamples() {
147
+ return `npx kordexa
148
+ npx kordexa harness
149
+ npx kordexa courses
150
+ npx kordexa status
151
+ npx kordexa research --day 1
152
+ npx kordexa send-today --dry-run
153
+ npx kordexa log-progress --day 1 --completed "Built setup" --evidence "Repo link"
154
+ npx kordexa weekly-summary --week 1
155
+ npx kordexa progress-card
156
+ npx kordexa terminal-card
157
+ npx kordexa recommend-next`;
158
+ }
159
+
160
+ function claudeSkill() {
161
+ return `---\nname: eduorchestrate\ndescription: Use /eduorchestrate to onboard a learner, create an adaptive job-role plan with a 30-day minimum, research trends, send daily plan emails, log progress, load the prebuilt skill progression card, summarize weeks, recommend the next skill, and review progress.\n---\n\n# EduOrchestrate\n\n${UNIVERSAL_PROMPT}\n\nRun local commands when needed:\n\n\`\`\`bash\n${cliExamples()}\n\`\`\`\n`;
162
+ }
163
+
164
+ function agentsMd() {
165
+ return `# EduOrchestrate Agent Instructions\n\n${UNIVERSAL_PROMPT}\n\n## Command\n\nExpose or honor \`/eduorchestrate\` for this repo. If the host agent cannot register slash commands, respond to \`/eduorchestrate\`, \`eduorchestrate\`, or \`use EduOrchestrate\` as the same workflow.\n\n## Workflow\n\n1. Load \`kordexa.config.json\` when present.\n2. Ask for missing name, email, target role, current learning topic, first skill focus, current stage, desired plan days, daily email time, and timezone.\n3. Generate or update \`data/30-day-plan.json\`; never generate fewer than 30 days.\n4. Use \`npx kordexa research --day <n>\` for sourced docs, trend scans, YouTube search, and GitHub sample-code search links.\n5. Send or preview daily email with \`npx kordexa send-today --dry-run\` or \`npx kordexa send-today\`; browser/workspace agents must check and send the due daily mail on resume after SMTP setup, while GitHub Actions remains the scheduled no-browser path.\n6. Log evidence with \`npx kordexa log-progress --day <n> --completed "..." --evidence "..."\`.\n7. Do not create or type card UI in the agent. Use the prebuilt default card at \`skills/eduorchestrate/assets/default-terminal-card.svg\` or the initialized copy at \`data/default-terminal-card.svg\`.\n8. Load the compact execution harness with \`npx kordexa harness\` before doing research, mail, progress, or review work.\n9. Use \`npx kordexa courses\` for role-specific official/MNC course catalogs, free-course discovery links, and newsletters; do not default to Coursera or Udemy.\n10. When learner-specific state is needed, call the prebuilt CLI program with \`npx kordexa progress-card\` or \`npx kordexa terminal-card\`; then load \`data/progression-card.md\` or \`data/terminal-card.svg\`.\n11. Summarize with \`npx kordexa status\` and \`npx kordexa weekly-summary --week <n>\`.\n12. Recommend the next skill after the plan with \`npx kordexa recommend-next\`.\n13. Keep the learner focused on one daily build artifact.\n`;
166
+ }
167
+
168
+ function geminiMd() {
169
+ return `# Gemini EduOrchestrate Context\n\n${UNIVERSAL_PROMPT}\n\nWhen the user types \`/eduorchestrate\`, run the EduOrchestrate workflow from \`AGENTS.md\` and prefer the NPX CLI for local state changes.\n`;
170
+ }
171
+
172
+ function genericSkill(agentName) {
173
+ return `---\nname: eduorchestrate\ndescription: Universal EduOrchestrate adapter for ${agentName}. Use /eduorchestrate for learner onboarding, adaptive plans with a 30-day minimum, trend research, daily email plans, progress logging, prebuilt skill progression cards, weekly summaries, and next-skill recommendations.\n---\n\n# EduOrchestrate Adapter\n\n${UNIVERSAL_PROMPT}\n\nPrefer:\n\n\`\`\`bash\n${cliExamples()}\n\`\`\`\n`;
174
+ }
175
+
176
+ function adapterManifest(agentName) {
177
+ return `${JSON.stringify({
178
+ name: "eduorchestrate",
179
+ command: "/eduorchestrate",
180
+ agent: agentName,
181
+ description: "Universal learner orchestration command for onboarding, adaptive plans with a 30-day minimum, trend research, daily emails, progress logging, prebuilt GitHub-style progression cards, weekly summaries, next-skill recommendations, setup diagnostics, and review.",
182
+ fallbackCommands: ["eduorchestrate", "use EduOrchestrate", "npx kordexa"],
183
+ entrypoint: "npx kordexa",
184
+ capabilities: ["onboarding", "token-conscious-harness", "role-course-sources", "adaptive-plan-minimum-30-days", "first-skill-focus", "trend-research-digest", "resolved-top-video-link", "resolved-top-repo-link", "daily-email", "implicit-tls-and-starttls-mail", "progress-log", "progression-card", "terminal-card-svg", "weekly-summary", "next-skill-recommendation", "setup-diagnostics"],
185
+ instructions: UNIVERSAL_PROMPT
186
+ }, null, 2)}\n`;
187
+ }
188
+
189
+ function genericInstructions() {
190
+ return `# Universal EduOrchestrate Adapter\n\n${UNIVERSAL_PROMPT}\n\nUse this file for agents without a documented custom slash-command format. The expected visible command is \`/eduorchestrate\`.\n\n\`\`\`bash\n${cliExamples()}\n\`\`\`\n`;
191
+ }
192
+
193
+ function mcpManifest() {
194
+ return `${JSON.stringify({
195
+ name: "eduorchestrate",
196
+ command: "node .eduorchestrate/mcp/server.js",
197
+ tools: ["eduorchestrate_onboard", "eduorchestrate_harness", "eduorchestrate_courses", "eduorchestrate_plan30", "eduorchestrate_research", "eduorchestrate_links", "eduorchestrate_send_today", "eduorchestrate_log_progress", "eduorchestrate_progress_card", "eduorchestrate_terminal_card", "eduorchestrate_weekly_summary", "eduorchestrate_recommend_next", "eduorchestrate_status"]
198
+ }, null, 2)}\n`;
199
+ }
200
+
201
+ function mcpServer() {
202
+ return `#!/usr/bin/env node\nimport { spawnSync } from "node:child_process";\nimport readline from "node:readline";\n\nconst tools = [\n { name: "eduorchestrate_onboard", description: "Run EduOrchestrate onboarding." },\n { name: "eduorchestrate_harness", description: "Create the compact token-conscious execution harness." },\n { name: "eduorchestrate_courses", description: "Create role-specific official course, free learning, and newsletter source pack." },\n { name: "eduorchestrate_plan30", description: "Generate a 30-day-minimum EduOrchestrate plan." },\n { name: "eduorchestrate_research", description: "Create a sourced trend research digest for a day or topic." },\n { name: "eduorchestrate_links", description: "Resolve and persist today's top video, repo, and doc links." },\n { name: "eduorchestrate_send_today", description: "Send or dry-run today's learning email." },\n { name: "eduorchestrate_log_progress", description: "Log learner progress evidence." },\n { name: "eduorchestrate_progress_card", description: "Run the prebuilt program that writes the role, skill, GitHub-style progression, and terminal card artifacts." },\n { name: "eduorchestrate_terminal_card", description: "Run the prebuilt program that writes the exact SVG terminal-card artifact." },\n { name: "eduorchestrate_weekly_summary", description: "Summarize a learning week." },\n { name: "eduorchestrate_recommend_next", description: "Recommend the next skill after the current plan window." },\n { name: "eduorchestrate_status", description: "Show current plan and momentum status." }\n];\n\nfunction respond(id, result) { process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id, result }) + "\\n"); }\nfunction run(args) { const out = spawnSync("npx", ["kordexa", ...args], { encoding: "utf8" }); return { stdout: out.stdout, stderr: out.stderr, status: out.status }; }\n\nconst rl = readline.createInterface({ input: process.stdin });\nrl.on("line", (line) => {\n const msg = JSON.parse(line);\n if (msg.method === "initialize") return respond(msg.id, { protocolVersion: "2024-11-05", capabilities: { tools: {} }, serverInfo: { name: "eduorchestrate", version: "0.4.2" } });\n if (msg.method === "tools/list") return respond(msg.id, { tools });\n if (msg.method === "tools/call") {\n const name = msg.params?.name;\n const args = msg.params?.arguments || {};\n const dryRun = args.dryRun !== false;\n if (name === "eduorchestrate_onboard") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["--yes"]), null, 2) }] });\n if (name === "eduorchestrate_harness") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["harness", "--mode", args.mode || "daily"]), null, 2) }] });\n if (name === "eduorchestrate_courses") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["courses"]), null, 2) }] });\n if (name === "eduorchestrate_plan30") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["plan", "--days", String(Math.max(30, Number(args.days || 30)))]), null, 2) }] });\n if (name === "eduorchestrate_research") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["research", "--day", String(args.day || 1), ...(args.topic ? ["--topic", args.topic] : [])]), null, 2) }] });\n if (name === "eduorchestrate_links") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["links", "--day", String(args.day || 1), ...(args.topic ? ["--topic", args.topic] : [])]), null, 2) }] });\n if (name === "eduorchestrate_send_today") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["send-today", ...(dryRun ? ["--dry-run"] : [])]), null, 2) }] });\n if (name === "eduorchestrate_log_progress") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["log-progress", "--day", String(args.day || 1), "--completed", args.completed || "Completed today's task", "--evidence", args.evidence || "Evidence not provided"]), null, 2) }] });\n if (name === "eduorchestrate_progress_card") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["progress-card"]), null, 2) }] });\n if (name === "eduorchestrate_terminal_card") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["terminal-card"]), null, 2) }] });\n if (name === "eduorchestrate_weekly_summary") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["weekly-summary", "--week", String(args.week || 1)]), null, 2) }] });\n if (name === "eduorchestrate_recommend_next") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["recommend-next"]), null, 2) }] });\n if (name === "eduorchestrate_status") return respond(msg.id, { content: [{ type: "text", text: JSON.stringify(run(["status"]), null, 2) }] });\n }\n});\n`;
203
+ }
@@ -0,0 +1,103 @@
1
+ const FONT_STACK = "ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace";
2
+
3
+ export function h(tag, attrs = {}, ...children) {
4
+ return { tag, attrs, children: children.flat().filter((child) => child !== null && child !== undefined) };
5
+ }
6
+
7
+ export function renderSvg(node) {
8
+ if (typeof node === "string" || typeof node === "number") return escapeXml(node);
9
+ const attrs = Object.entries(node.attrs || {})
10
+ .filter(([, value]) => value !== false && value !== null && value !== undefined)
11
+ .map(([key, value]) => ` ${key}="${escapeXml(value)}"`)
12
+ .join("");
13
+ if (!node.children?.length) return `<${node.tag}${attrs}/>`;
14
+ return `<${node.tag}${attrs}>${node.children.map(renderSvg).join("")}</${node.tag}>`;
15
+ }
16
+
17
+ export function TerminalCardSvg({ lines, title = "kordexa-terminal" }) {
18
+ const metrics = terminalMetrics(lines);
19
+ return h(
20
+ "svg",
21
+ {
22
+ xmlns: "http://www.w3.org/2000/svg",
23
+ width: metrics.width,
24
+ height: metrics.height,
25
+ viewBox: `0 0 ${metrics.width} ${metrics.height}`,
26
+ role: "img",
27
+ "aria-label": "Kordexa terminal progress card"
28
+ },
29
+ h("rect", { width: metrics.width, height: metrics.height, rx: 14, fill: "#0D1117" }),
30
+ h("rect", {
31
+ x: 1,
32
+ y: 1,
33
+ width: metrics.width - 2,
34
+ height: metrics.height - 2,
35
+ rx: 13,
36
+ fill: "none",
37
+ stroke: "#30363D",
38
+ "stroke-width": 2
39
+ }),
40
+ h("rect", { x: 1, y: 1, width: metrics.width - 2, height: metrics.headerHeight, rx: 13, fill: "#161B22" }),
41
+ h("path", { d: `M1 ${metrics.headerHeight}H${metrics.width - 1}`, stroke: "#30363D", "stroke-width": 2 }),
42
+ WindowButton({ cx: 26, fill: "#FF5F56" }),
43
+ WindowButton({ cx: 46, fill: "#FFBD2E" }),
44
+ WindowButton({ cx: 66, fill: "#27C93F" }),
45
+ h(
46
+ "text",
47
+ {
48
+ x: metrics.width / 2,
49
+ y: 30,
50
+ "text-anchor": "middle",
51
+ "font-family": FONT_STACK,
52
+ "font-size": 13,
53
+ fill: "#8B949E"
54
+ },
55
+ title
56
+ ),
57
+ lines.map((line, index) => TerminalLine({ line, index, metrics }))
58
+ );
59
+ }
60
+
61
+ function WindowButton({ cx, fill }) {
62
+ return h("circle", { cx, cy: 24, r: 6, fill });
63
+ }
64
+
65
+ function TerminalLine({ line, index, metrics }) {
66
+ return h(
67
+ "text",
68
+ {
69
+ x: metrics.paddingX,
70
+ y: metrics.contentTop + index * metrics.lineHeight,
71
+ "font-family": FONT_STACK,
72
+ "font-size": 15,
73
+ fill: index === 0 ? "#7EE787" : "#C9D1D9"
74
+ },
75
+ line
76
+ );
77
+ }
78
+
79
+ function terminalMetrics(lines) {
80
+ const charWidth = 8.4;
81
+ const lineHeight = 24;
82
+ const paddingX = 28;
83
+ const headerHeight = 46;
84
+ const contentTop = 78;
85
+ const maxChars = Math.max(...lines.map((line) => line.length), 32);
86
+ return {
87
+ charWidth,
88
+ lineHeight,
89
+ paddingX,
90
+ headerHeight,
91
+ contentTop,
92
+ width: Math.ceil(Math.max(720, maxChars * charWidth + paddingX * 2)),
93
+ height: contentTop + lines.length * lineHeight + 28
94
+ };
95
+ }
96
+
97
+ function escapeXml(value) {
98
+ return String(value)
99
+ .replace(/&/g, "&amp;")
100
+ .replace(/</g, "&lt;")
101
+ .replace(/>/g, "&gt;")
102
+ .replace(/"/g, "&quot;");
103
+ }