Skip to content

InferHaven/agent-skills / codetrain

codetrain

Flagged

CodeTrain is an open-source Socratic coding tutor with a local lesson page where the learner writes every line while the agent sets small steps, gives hints and reviews the work without putting the solution into the lesson. Use when the user wants to be taught/walked through code one tiny step at a time — triggers like "teach me this code", "walk me through this", "hold my hand", "explain step by step", "tutor me", "guide me through", "I want to learn this", or asks for a safe practice exercise to learn a concept.

FileKindSize
LICENSEother11.1 KB
NOTICEother768 B
README.mdmarkdown22.7 KB
SKILL.mdskill md20.1 KB
app/answer_guard.pyscript7.8 KB
app/checkpoint-hook.shexecutablescript1.2 KB
app/ctl.shexecutablescript4.5 KB
app/install-permissions.pyscript6.8 KB
app/patch.pyexecutablescript4.1 KB
app/profile.pyexecutablescript9.3 KB
app/server.pyexecutablescript23.1 KB
app/static/Archivo.woff2binary88.0 KB
app/static/JetBrainsMono.woff2binary30.7 KB
app/static/app.jsscript57.1 KB
app/static/docklint.jsscript4.3 KB
app/static/editor.jsscript4.4 KB
app/static/fonts-OFL.txtmarkdown9.0 KB
app/static/glossary.jsscript50.8 KB
app/static/index.htmlother8.0 KB
app/static/js-worker.jsscript3.9 KB
app/static/liveness.jsscript1.8 KB
app/static/logo-anim.svgother1.9 KB
app/static/prism.jsscript20.6 KB
app/static/prose.jsscript18.8 KB
app/static/pyodide-worker.jsscript7.0 KB
app/static/runner.jsscript4.5 KB
app/static/sheet.cssother32.7 KB
app/static/styles.cssother51.4 KB
app/static/theme-toggle.jsscript9.5 KB
app/static/theme.jsscript5.2 KB
app/static/visuals.jsscript14.8 KB
app/watch.shexecutablescript2.5 KB
install.shexecutablescript2.0 KB
references/session-protocol.mdmarkdown19.6 KB
references/spaced-repetition.mdmarkdown3.4 KB
references/teach-on-diff.mdmarkdown2.5 KB

app/static/js-worker.js

View on GitHub
/* CodeTrain — JavaScript runtime worker (classic worker).
   Runs the user's JS in the worker scope (no DOM, no page access), captures
   console output, and calls the entry function for each test case.

   BYTE-IDENTICAL COPY: engine/app/static/js-worker.js. Copy one over the other,
   never hand-merge. */

function jsonSafe(v) {
  try { return JSON.parse(JSON.stringify(v)); } catch (e) { return String(v); }
}

/* This runtime has no module system, and the two ways a learner discovers that are both
   unreadable. `import` is a static parse error, because the code below is compiled as a
   FUNCTION BODY (`new Function`), which the spec parses with the Script goal — so browsers
   answer with "import declarations may only appear at top level of a module" (Firefox),
   "Cannot use import statement outside a module" (V8) or "Unexpected keyword 'import'"
   (Safari). `require(...)` is not a syntax error at all; it throws ReferenceError when the
   factory runs. Neither tells anyone what to do instead.

   This matches on the THROWN ERROR, never by scanning the source. Scanning would flag a
   string literal, a comment, `important`, `requireAuth(...)` or a property named `.import`
   and refuse to run code that is perfectly fine. Rewriting an error that already happened
   cannot produce a false positive, because there was nothing valid to break. */
var NO_MODULES =
  "This runtime has no module system: import, export and require() are not available, and "
  + "there is no package registry to load from. Everything you need is already in the "
  + "JavaScript language itself.";

function explainModuleError(err, code) {
  if (!err || !err.name) return null;
  var msg = String(err.message || "");
  if (err.name === "SyntaxError") {
    // Every engine names the offending keyword in the message. The source check is a
    // fallback for a wording we have not seen, anchored to a line-leading declaration so a
    // string containing the word cannot match.
    if (/\b(import|export)\b/.test(msg)) return NO_MODULES;
    if (/^\s*(import|export)[\s{*]/m.test(String(code || ""))) return NO_MODULES;
    return null;
  }
  if (err.name === "ReferenceError" && /\brequire\b/.test(msg)) return NO_MODULES;
  return null;
}

/* Concise message, not the worker's internal stack frames. When the failure is the missing
   module system we lead with the explanation and keep the browser's own wording after it —
   the learner may search for that text, and the tutor reads the whole string. */
function errorText(err, code) {
  var raw = String((err && err.name) ? err.name + ": " + err.message : err);
  var hint = explainModuleError(err, code);
  return hint ? hint + "\n\n" + raw : raw;
}

self.onmessage = (e) => {
  const { id, code, entry, cases } = e.data;
  const reply = (msg) => self.postMessage(Object.assign({ id }, msg));
  let out = "";
  const log = (...a) => { out += a.map((x) => (typeof x === "object" ? JSON.stringify(x) : String(x))).join(" ") + "\n"; };
  const sandboxConsole = { log, info: log, warn: log, error: log, debug: log };

  try {
    // Define the user's code in an isolated function scope, then hand back the
    // entry symbol if it exists. `entry` is a validated identifier (see runner).
    const factory = new Function("console", `${code}\n;return (typeof ${entry || "undefined"} !== "undefined") ? ${entry || "undefined"} : undefined;`);
    const entryFn = factory(sandboxConsole);

    let resultCases = [];
    if (entry && cases && cases.length) {
      resultCases = cases.map((c) => {
        try {
          const got = entryFn.apply(null, c.args || []);
          return { name: c.name, ok: true, got: jsonSafe(got), error: null };
        } catch (err) {
          return { name: c.name, ok: false, error: errorText(err, code) };
        }
      });
    }
    reply({ result: { stdout: out, stderr: "", cases: resultCases } });
  } catch (err) {
    reply({ result: { stdout: out, stderr: errorText(err, code), cases: [] } });
  }
};
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall