eklavya 1.26.0 → 1.27.1

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 (47) hide show
  1. package/README.md +48 -42
  2. package/dist/artifacts.js +214 -0
  3. package/dist/artifacts.js.map +1 -0
  4. package/dist/assets/artifact-template.html +144 -0
  5. package/dist/assets/dashboard.html +131 -11
  6. package/dist/assets/tokens.css +6 -4
  7. package/dist/assets/tutor/SKILL.md +7 -0
  8. package/dist/cli-memory.js +6 -3
  9. package/dist/cli-memory.js.map +1 -1
  10. package/dist/cli.js +85 -2
  11. package/dist/cli.js.map +1 -1
  12. package/dist/config.js +3 -0
  13. package/dist/config.js.map +1 -1
  14. package/dist/dashboard.js +41 -1
  15. package/dist/dashboard.js.map +1 -1
  16. package/dist/hooks/memory-lib.js +1 -1
  17. package/dist/hooks/memory-lib.js.map +1 -1
  18. package/dist/hooks/session-start.js +10 -2
  19. package/dist/hooks/session-start.js.map +1 -1
  20. package/dist/install-lock.js +155 -0
  21. package/dist/install-lock.js.map +1 -0
  22. package/dist/install.js +64 -45
  23. package/dist/install.js.map +1 -1
  24. package/dist/memory/reservation.js +15 -5
  25. package/dist/memory/reservation.js.map +1 -1
  26. package/dist/memory/worker.js +72 -31
  27. package/dist/memory/worker.js.map +1 -1
  28. package/dist/migrations/015_event_link_indexes.sql +24 -0
  29. package/dist/paths.js +8 -0
  30. package/dist/paths.js.map +1 -1
  31. package/dist/plugin/.claude-plugin/plugin.json +1 -1
  32. package/dist/plugin/agents/explainer.md +57 -0
  33. package/dist/plugin/agents/tutor.md +7 -0
  34. package/dist/plugin/cli/CLAUDE.md +60 -108
  35. package/dist/plugin/hooks/CLAUDE.md +118 -357
  36. package/dist/plugin/hooks/run.mjs +104 -21
  37. package/dist/plugin/skills/CLAUDE.md +106 -291
  38. package/dist/plugin/skills/tutor/SKILL.md +7 -0
  39. package/dist/tools/config_tools.js +4 -0
  40. package/dist/tools/config_tools.js.map +1 -1
  41. package/dist/tools/record_attempt.js +25 -1
  42. package/dist/tools/record_attempt.js.map +1 -1
  43. package/dist/update.js +7 -83
  44. package/dist/update.js.map +1 -1
  45. package/dist/user-skill/eklavya/SKILL.md +8 -0
  46. package/dist/user-skill/eklavya-artifacts/SKILL.md +135 -0
  47. package/package.json +1 -1
@@ -316,23 +316,29 @@ export async function superviseWorker(db, token, config, opts) {
316
316
  // A stop that landed after the last job — SIGTERM, Ctrl-C, a closed
317
317
  // terminal — still means stop: no successor.
318
318
  let handedOff = false;
319
+ // The token that holds the slot now: this run's, or its successor's once handed on.
320
+ let holding = token;
319
321
  if ((result.stopped === 'limit' || result.stopped === 'empty') &&
320
322
  config.providers.observer &&
321
323
  stillOn() &&
322
324
  !cancel.signal.aborted &&
323
325
  !opts.signal?.aborted) {
326
+ let next = null;
324
327
  try {
325
- handedOff = handOffWorker(db, token, () => hasClaimableJob(db) && queueDepth(db).paused === 0);
328
+ next = handOffWorker(db, token, () => hasClaimableJob(db) && queueDepth(db).paused === 0);
326
329
  }
327
330
  catch {
328
- handedOff = false;
331
+ next = null;
332
+ }
333
+ // From here on the slot is `next`'s, and this run's `token` matches
334
+ // nothing. A successor that cannot start is released below under `next`.
335
+ if (next) {
336
+ holding = next;
337
+ handedOff = (opts.launch ?? launchWorker)(db, next);
329
338
  }
330
- // A successor that cannot start releases the slot itself.
331
- if (handedOff)
332
- handedOff = (opts.launch ?? launchWorker)(db, token);
333
339
  }
334
340
  const released = handedOff ? false : await persist(() => {
335
- if (!releaseWorker(db, token))
341
+ if (!releaseWorker(db, holding))
336
342
  throw new Error('busy');
337
343
  });
338
344
  return { ...result, handedOff, released };
@@ -372,26 +378,48 @@ export function queueDepth(db) {
372
378
  * list, never an error. Unsummarised evidence is never touched, however old: it
373
379
  * is work not yet distilled, and deleting it would lose it outright.
374
380
  *
375
- * The same pass bounds the bookkeeping that otherwise grows once per session:
376
- * finished jobs (nothing reads a `done` row), reuse receipts and their items,
377
- * the per-session "already recalled" rows, and notification ledger rows. The
378
- * receipts are the one visible cost — the dashboard's savings then cover the
381
+ * **One project per call.** `retention_days` is resolved per project (a project
382
+ * config can set it or unset it) over one shared database, so the sweep only
383
+ * touches rows it can attribute to `project`: that project's evidence, its
384
+ * batches' finished jobs, its receipts, and the `recalled:`/`notified:` rows of
385
+ * sessions that belong to it and to no other project. A bookkeeping row it
386
+ * cannot place is left alone — a few stale `meta` rows are cheaper than one
387
+ * project's policy deleting another's state, which it once did to every
388
+ * project's evidence.
389
+ *
390
+ * The receipts are the one visible cost — the dashboard's savings then cover the
379
391
  * retention window rather than all time — and they hold only ids and counts.
380
392
  *
381
393
  * `limit` caps the events removed in one call so a seam never pays for a
382
- * backlog in one go. A capped run does not stamp `memory_pruned_at`, so the
383
- * next seam carries on instead of waiting out the interval.
394
+ * backlog in one go. A capped run does not stamp the project's
395
+ * `memory_pruned_at:<project>`, so the next seam carries on instead of waiting
396
+ * out the interval.
384
397
  */
385
- export function pruneEvidence(db, config, opts = {}) {
398
+ export function pruneEvidence(db, config, opts) {
386
399
  const days = config.memory.retention_days;
387
400
  if (!days)
388
401
  return 0;
389
402
  const cutoff = new Date(Date.now() - days * 86_400_000).toISOString();
403
+ const project = opts.project;
390
404
  return db.transaction(() => {
405
+ // Which bookkeeping rows are this project's is read first: the receipts and
406
+ // events that prove a session belongs here are what this pass deletes.
407
+ const keys = (sql, params) => db.prepare(sql).all(params).map((r) => r.key);
408
+ const recalled = keys(`SELECT key FROM meta WHERE key LIKE 'recalled:%' AND ${ownedSession('substr(key, 10)')}`, { project });
409
+ // Ledger rows stop being retried after a day; past the window they only
410
+ // take space. A row this version cannot read is left for what wrote it.
411
+ // `notified:session:<sid>:<sink>` belongs to its session's project;
412
+ // `notified:queue-paused:<project>:…` names the project outright.
413
+ const sessionOf = "substr(key, 18, instr(substr(key, 18), ':') - 1)";
414
+ const notified = keys(`SELECT key FROM meta WHERE key LIKE 'notified:%'
415
+ AND (CASE WHEN json_valid(value) THEN json_extract(value, '$.first') END) < @cutoff
416
+ AND ((key LIKE 'notified:session:%' AND ${ownedSession(sessionOf)})
417
+ OR substr(key, 1, length(@paused)) = @paused)`, { project, cutoff, paused: `notified:queue-paused:${project}:` });
391
418
  const ids = db
392
- .prepare(`SELECT id FROM evidence_events WHERE occurred_at < ? AND status = 'summarized' ORDER BY id
419
+ .prepare(`SELECT id FROM evidence_events
420
+ WHERE project = ? AND occurred_at < ? AND status = 'summarized' ORDER BY id
393
421
  ${opts.limit ? 'LIMIT ?' : ''}`)
394
- .all(...(opts.limit ? [cutoff, opts.limit] : [cutoff])).map((r) => r.id);
422
+ .all(...(opts.limit ? [project, cutoff, opts.limit] : [project, cutoff])).map((r) => r.id);
395
423
  const list = JSON.stringify(ids);
396
424
  const inList = 'IN (SELECT value FROM json_each(?))';
397
425
  // A candidate is a proposal about the learner, not evidence: it outlives the
@@ -401,39 +429,52 @@ export function pruneEvidence(db, config, opts = {}) {
401
429
  // connection opened without it cannot leave links pointing at nothing.
402
430
  db.prepare(`DELETE FROM memory_entry_events WHERE event_id ${inList}`).run(list);
403
431
  const removed = db.prepare(`DELETE FROM evidence_events WHERE id ${inList}`).run(list).changes;
404
- db.prepare("DELETE FROM memory_jobs WHERE status = 'done' AND updated_at < ?").run(cutoff);
405
- db.prepare('DELETE FROM context_receipt_items WHERE receipt_id IN (SELECT id FROM context_receipts WHERE created_at < ?)').run(cutoff);
406
- db.prepare('DELETE FROM context_receipts WHERE created_at < ?').run(cutoff);
432
+ db.prepare(`DELETE FROM memory_jobs WHERE status = 'done' AND updated_at < ?
433
+ AND batch_id IN (SELECT id FROM memory_batches WHERE project = ?)`).run(cutoff, project);
434
+ db.prepare(`DELETE FROM context_receipt_items WHERE receipt_id IN
435
+ (SELECT id FROM context_receipts WHERE project = ? AND created_at < ?)`).run(project, cutoff);
436
+ db.prepare('DELETE FROM context_receipts WHERE project = ? AND created_at < ?').run(project, cutoff);
407
437
  // `recalled:<session>` has no date of its own; every recall writes a
408
- // receipt, so a session with none left inside the window is over.
409
- db.prepare(`DELETE FROM meta WHERE key LIKE 'recalled:%'
410
- AND substr(key, 10) NOT IN (SELECT session_id FROM context_receipts WHERE session_id IS NOT NULL)`).run();
411
- // Ledger rows stop being retried after a day; past the window they only
412
- // take space. A row this version cannot read is left for what wrote it.
413
- db.prepare(`DELETE FROM meta WHERE key LIKE 'notified:%'
414
- AND (CASE WHEN json_valid(value) THEN json_extract(value, '$.first') END) < ?`).run(cutoff);
438
+ // receipt, so a session of this project with none left is over.
439
+ db.prepare(`DELETE FROM meta WHERE key ${inList}
440
+ AND substr(key, 10) NOT IN (SELECT session_id FROM context_receipts WHERE session_id IS NOT NULL)`).run(JSON.stringify(recalled));
441
+ db.prepare(`DELETE FROM meta WHERE key ${inList}`).run(JSON.stringify(notified));
415
442
  if (!opts.limit || ids.length < opts.limit) {
416
- db.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES ('memory_pruned_at', ?)").run(nowIso());
443
+ db.prepare('INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)').run(prunedKey(project), nowIso());
417
444
  }
418
445
  return removed;
419
446
  })();
420
447
  }
448
+ /**
449
+ * SQL: the session named by `sid` left a trace in `@project` and in no other
450
+ * project. Entries count because they outlive the evidence, so a session stays
451
+ * attributable after its events have aged out.
452
+ */
453
+ function ownedSession(sid) {
454
+ const traces = (cmp) => ['evidence_events', 'memory_entries', 'context_receipts']
455
+ .map((t) => `EXISTS (SELECT 1 FROM ${t} WHERE session_id = ${sid} AND project ${cmp} @project)`)
456
+ .join(' OR ');
457
+ return `((${traces('=')}) AND NOT (${traces('<>')}))`;
458
+ }
459
+ /** Each project's last sweep, so one project's run never postpones another's. */
460
+ export const prunedKey = (project) => `memory_pruned_at:${project}`;
421
461
  /** How often a seam may run the retention sweep. Retention is counted in days. */
422
462
  const PRUNE_EVERY_MS = 6 * 60 * 60 * 1000;
423
463
  /** Events one seam may delete: enough to keep up, small enough to stay unnoticed inside a hook. */
424
464
  const PRUNE_SEAM_LIMIT = 5_000;
425
465
  /**
426
- * The sweep, from a session seam: only with `retention_days` set, at most once
427
- * per `PRUNE_EVERY_MS`, and bounded. `eklavya memory prune` stays the way to run
466
+ * The sweep, from a session seam: this project only, only with its
467
+ * `retention_days` set, at most once per `PRUNE_EVERY_MS` per project, and
468
+ * bounded. `eklavya memory prune` stays the way to run
428
469
  * it now and in full.
429
470
  */
430
- export function pruneIfDue(db, config) {
471
+ export function pruneIfDue(db, config, project) {
431
472
  if (!config.memory.retention_days)
432
473
  return 0;
433
- const row = db.prepare("SELECT value FROM meta WHERE key = 'memory_pruned_at'").get();
474
+ const row = db.prepare('SELECT value FROM meta WHERE key = ?').get(prunedKey(project));
434
475
  const last = row ? parseStamp(row.value) : null;
435
476
  if (last !== null && Date.now() - last < PRUNE_EVERY_MS)
436
477
  return 0;
437
- return pruneEvidence(db, config, { limit: PRUNE_SEAM_LIMIT });
478
+ return pruneEvidence(db, config, { project, limit: PRUNE_SEAM_LIMIT });
438
479
  }
439
480
  //# sourceMappingURL=worker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/memory/worker.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EACL,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,SAAS,EACT,eAAe,EACf,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB;;;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;IACxH,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAChD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,cAAc;QAAE,OAAO,CAAC,CAAC;IAClE,OAAO,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC;AACzE,CAAC"}
@@ -0,0 +1,24 @@
1
+ -- The lookups the retention sweep (`pruneEvidence`) makes, indexed.
2
+ --
3
+ -- First, the two tables that point at an evidence event by `event_id`.
4
+ --
5
+ -- `pruneEvidence` deletes aged-out events, and for every deleted event SQLite
6
+ -- has to find the rows referencing it: the explicit `UPDATE learning_sources
7
+ -- ... WHERE event_id IN (...)` and `DELETE FROM memory_entry_events WHERE
8
+ -- event_id IN (...)`, and the foreign-key actions on both columns. Neither was
9
+ -- indexed -- `memory_entry_events`'s primary key starts with `entry_id`, which
10
+ -- a lookup by `event_id` alone cannot use -- so each deleted event cost a scan
11
+ -- of every link and every candidate. One illustrative fixture, 1,000 expired
12
+ -- events against 10,000 retained links: ~238ms to prune before, ~3ms after.
13
+ --
14
+ -- `context_receipts(session_id)` serves the same sweep: it decides which
15
+ -- `recalled:`/`notified:` rows belong to the project being pruned by asking,
16
+ -- per row, whether any other project's receipt names that session. Without it
17
+ -- each row scanned every receipt -- 2,000 rows against 20,000 receipts took
18
+ -- ~1.1s per sweep inside a hook, ~5ms with it.
19
+ --
20
+ -- Nothing else changes: no row is touched, and both are plain b-tree indexes a
21
+ -- downgrade would simply ignore.
22
+ CREATE INDEX IF NOT EXISTS idx_entry_events_event ON memory_entry_events(event_id);
23
+ CREATE INDEX IF NOT EXISTS idx_sources_event ON learning_sources(event_id);
24
+ CREATE INDEX IF NOT EXISTS idx_receipts_session ON context_receipts(session_id);
package/dist/paths.js CHANGED
@@ -83,6 +83,14 @@ export function projectConfigPath(repoRoot) {
83
83
  export function projectPacksDir(repoRoot) {
84
84
  return path.join(projectsDir(), projectSlug(repoRoot), 'packs');
85
85
  }
86
+ /**
87
+ * Explainer pages and other artifacts, one folder per project, named with the
88
+ * same slug as `projects/`. Outside the checkout for the same reason settings
89
+ * and packs are: Eklavya creates no files in your project.
90
+ */
91
+ export function artifactsDir() {
92
+ return path.join(eklavyaHome(), 'artifacts');
93
+ }
86
94
  /**
87
95
  * Private to the person whose history it is.
88
96
  *
package/dist/paths.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,MAAM;IACpB,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,cAAc,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,aAAa,CAAC,CAAC;AACjD,CAAC;AAED,0EAA0E;AAC1E,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;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C,MAAM,CAAC,KAAK,CAAC;YAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;IACxF,CAAC;IAAC,MAAM,CAAC;QACP,qCAAqC;IACvC,CAAC;AACH,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,iBAAiB;IAC/B,MAAM,IAAI,GAAG,WAAW,EAAE,CAAC;IAC3B,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACrD,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzB,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eklavya",
3
3
  "displayName": "Eklavya",
4
- "version": "1.26.0",
4
+ "version": "1.27.1",
5
5
  "description": "Learn while your agent works. Turns coding-agent generation time into adaptive, Socratic learning grounded in the code being written.",
6
6
  "author": {
7
7
  "name": "Ajay Kumar"
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: eklavya-explainer
3
+ description: Writes an Eklavya explainer page — one concept, in plain English with diagrams — under ~/.eklavya/artifacts/ and opens it. Started in the background after a missed quiz question or when the developer asks for something to be explained, so the session never waits for it.
4
+ tools: Read, Write, Edit, Bash, Glob, Grep
5
+ ---
6
+
7
+ You are Eklavya's explainer. The main session just told a developer they got a
8
+ question wrong, or they asked for something to be explained, and handed the
9
+ page to you so it could get back to work. Nobody is watching this transcript:
10
+ do not ask anything, and do not quiz. Write one page, open it, and report its
11
+ path in one line.
12
+
13
+ You were handed some of: the concept slug and name, the question as it was
14
+ asked, the developer's answer, the right answer, and the code it came from.
15
+ Work with what you have; do not go looking for a conversation you cannot see.
16
+
17
+ ## Make the page
18
+
19
+ 1. If `~/.claude/skills/eklavya-artifacts/SKILL.md` exists, read it: it is the
20
+ full set of rules for an Eklavya artifact, and it wins over the summary
21
+ below.
22
+ 2. Find the binary and write its path into every later command:
23
+ `command -v eklavya || command -v "$HOME/.eklavya/runtime/node_modules/.bin/eklavya"`
24
+ (on Windows, `eklavya.cmd` in that `.bin`; failing both, `npx -y eklavya`).
25
+ 3. Start the page from the directory you were started in:
26
+ `eklavya artifacts new "<Concept name>, explained" --kind explainer --concept <slug> --description "<the one-line answer>"`.
27
+ It prints the file's path. Never pick a path yourself.
28
+ 4. Replace the `<!-- CONTENT … -->` comment in that file with the explanation.
29
+ Leave the `<head>` and the download buttons alone.
30
+ 5. `eklavya artifacts open "<path>"`, then reply with the path, one line.
31
+
32
+ ## What goes on it
33
+
34
+ In this order, each under its own `<h2>`:
35
+
36
+ - **The short answer.** Two or three sentences a newcomer could repeat: what the
37
+ thing *does*, before what it is called.
38
+ - **Where the answer went wrong.** Name the misconception in the answer given
39
+ — kindly, specifically — and why it is tempting. If there was no answer
40
+ ("I don't know"), skip this and start from the mechanism.
41
+ - **How it works.** At least one inline-SVG diagram in a `<figure>`: a
42
+ sequence, a before/after, a decision. Use the template's `.svg-box`,
43
+ `.svg-box-spot`, `.svg-line`, `.svg-line-spot`, `.svg-label`, `.svg-small`
44
+ classes, and a `<figcaption>` that states the takeaway.
45
+ - **A concrete example.** A tiny snippet or a timeline, broken versus fixed,
46
+ ideally in the language the developer was working in.
47
+ - **The rule that transfers.** When this applies in a different codebase, and
48
+ the one gotcha to watch for.
49
+
50
+ Plain English, short sentences, no jargon without a gloss. Any CSS you add
51
+ follows the design rules in the `eklavya-artifacts` skill: role tokens only
52
+ (`--ink --dim --faint --line --spot …`, never a raw hex or `--vd-*` step), one
53
+ verdigris accent, square corners, hairlines instead of shadows, the three font
54
+ variables, readable on both ink and paper, no emoji. One self-contained file.
55
+
56
+ Never reveal or restate the answer to a *different* question, and never grade
57
+ anything: the session already recorded the answer.
@@ -82,3 +82,10 @@ You are competing for attention with an agent that is producing code. Ask one qu
82
82
  Never record a grade for a question that was not answered. Record a decline (`outcome: "declined"`) only when they actually say so.
83
83
 
84
84
  "I don't know" is not silence and not a decline — it is a request. Teach it: the mechanism, the real lines from the diff, what it generalises to, one takeaway. Then record grade 0 with `outcome: "dont_know"` and move on. The full shape is in the tutor skill's `skills/tutor/references/grading.md`.
85
+
86
+ ## When `record_attempt` returns `explain`
87
+
88
+ You cannot start another agent, so you cannot follow its `instruction` yourself.
89
+ Give the verdict as usual, then add one line for the main session: start
90
+ `eklavya-explainer` in the background with the concept slug, the question, the
91
+ developer's answer and the right answer. Do not write the explanation here.
@@ -1,110 +1,62 @@
1
1
  # Working in `cli/`
2
2
 
3
- **This directory is not the `eklavya` binary.** That is `mcp/src/cli.ts`,
4
- published as `dist/cli.js` and the package's only `bin`. `cli/` holds exactly one
5
- file: `eklavya-gate`, the POSIX commit-gate script. The name invites the
6
- confusion, so check which one a request means before you edit anything —
7
- `eklavya config`, `eklavya doctor`, `eklavya dashboard` and `eklavya install` all
8
- live in `mcp/src/cli.ts`.
9
-
10
- It is a shell script and not Node on purpose: it runs as a git `pre-commit` hook
11
- on every commit, and a git hook must not pay Node's startup cost. Keep it POSIX
12
- `sh` — the installed hook execs it with `#!/bin/sh`, and `mcp/test/gate.test.ts`
13
- drives it through `/bin/sh`.
14
-
15
- ## It is opt-in, twice over
16
-
17
- Nothing in `eklavya install` puts this on a repo. `scripts/install-git-hook.sh`
18
- does, as a separate step the user runs per repo; it writes `pre-commit` in the
19
- **common** git directory's `hooks/` (so a linked worktree gets the main
20
- checkout's hook, which is the one git runs), between the `# >>> eklavya gate >>>`
21
- markers, and if a `pre-commit` already existed it moves it to `pre-commit.local`
22
- and chains it first. `--uninstall` restores it. Re-running it rewrites an older
23
- Eklavya hook in place. With `core.hooksPath` set (husky, lefthook) it installs
24
- nothing, prints the line to add to the manager's hook, and exits 2.
25
-
26
- The installed hook does not `exec` this file at a fixed path any more. It runs
27
- the first that exists of `~/.eklavya/runtime/node_modules/eklavya/dist/plugin/cli/eklavya-gate`
28
- (honouring `EKLAVYA_RUNTIME` and `EKLAVYA_HOME`) and the path the installer ran
29
- from, with `sh` so a lost executable bit cannot block. If neither exists the
30
- commit goes through with one stderr line. The old fixed-path `exec` meant a
31
- plugin update that moved the directory made every commit fail — the one failure
32
- this gate must never have. `eklavya uninstall` warns about the hook and prints
33
- the command to remove it; it never deletes it.
34
-
35
- Then the script itself only acts on a project whose config sets `quiz.enforced`
36
- (or the retired `"mode": "enforced"`, which it still reads). That config is at
37
- `~/.eklavya/projects/<slug>/config.json` — the script rebuilds the slug itself,
38
- in shell, from `git rev-parse --show-toplevel` folded to the main checkout via
39
- `--git-common-dir`, because a worktree shares its parent's settings. Note that it
40
- reads enforcement from **only** the project file — not `~/.eklavya/config.json` —
41
- so a globally set gate does not hold a bare terminal. The global file is read for
42
- one thing: a `quiz.enabled: false` (or `mode: off`) there, not overridden by the
43
- project, releases the gate, exactly as `coerce()` does — otherwise a terminal
44
- commit is held by a gate no quiz will ever run to clear. The slug path is built
45
- with `pwd -P` so a checkout reached through a symlink still finds its file.
46
-
47
- It reads `<repo>/.eklavya.json` as a fallback and does **not** migrate it. The
48
- node half moves that file out automatically; a git pre-commit hook is the wrong
49
- place to start rewriting somebody's working tree, so it reads the old location
50
- and lets the next ordinary session do the move. Any doc claiming a terminal commit is gated has to attach the installer
51
- step and the repo config; `web/src/content/docs/docs/commit-gate.mdx` and
52
- `skills/setup/SKILL.md` are where that lives.
53
-
54
- ## It fails open, always
55
-
56
- A learning tool that bricks commits gets uninstalled, and an unpassable gate
57
- teaches nothing. Every one of these exits 0:
58
-
59
- - not inside a git repo, or `git rev-parse` fails;
60
- - no config for this project, at either the current or the legacy location;
61
- - `jq` not on PATH (warns on stderr) — **or** `sqlite3` not on PATH (warns too).
62
- It needs both, not just `jq`;
63
- - the config does not ask for enforcement — `quiz.enforced` false or absent with
64
- no `mode: enforced` behind it, or `quiz.enabled` false — in the project file,
65
- or in the global one when the project does not say;
66
- - the database file does not exist;
67
- - the `sqlite3` query errors, or returns no gate row for this repo.
68
-
69
- Exit 1 happens on exactly one condition: a gate row for this repo whose `passed`
70
- is not `1`. Adding a new failure mode means adding a new `exit 0` path.
71
-
72
- ## It reads the database directly
73
-
74
- There is no server in a git hook, so the script talks to `knowledge.db` in raw
75
- SQL and duplicates things it cannot import. Keep it in step with:
76
-
77
- - the `gates` table shape — it selects `passed, required, answered` and picks the
78
- repo's most recent row by `updated_at`. `syncGate` in `mcp/src/store.ts` is the
79
- only writer; a renamed or added column lands here in the same commit.
80
- - `DEFAULT_CONFIG.quiz` in `mcp/src/config.ts` — the script defaults a config
81
- with neither `quiz` nor `mode` to unenforced.
82
- - `projectSlug` in `mcp/src/paths.ts` — the script rebuilds it with
83
- `tr '/\\:' '-'`, and `test/gate.test.ts` runs both parsers over one set of
84
- configs so the two cannot drift apart silently.
85
- - the `mode` → `quiz` alias in `normalizeLegacyKeys`, and the rule that
86
- `quiz.enabled: false` forces `enforced` off. Both are duplicated here in jq,
87
- spelled out with `if`/`elif` rather than `//`: jq's `//` is an alternative
88
- operator, so `.quiz.enforced // (.mode == "enforced")` reads an explicit
89
- `false` as unset and falls back to a stale `mode` in the same file — a gate
90
- that keeps holding commits after somebody switched it off.
91
- `test/gate.test.ts` runs both parsers over the same five configs.
92
-
93
- The pass/fail arithmetic itself (`PASSING_GRADE`, `pass_threshold`,
94
- `ceil(required * pass_threshold)`) is **not** duplicated here — the script trusts
95
- the persisted `passed` column. Keep it that way: a change to the gate's rule
96
- belongs in `syncGate` alone. What is duplicated is the lookup key, and it differs
97
- from the in-session hook on purpose: `mcp/src/hooks/pre-tool-gate.ts` looks the
98
- gate up by `session_id`, this script by `repo`, because a terminal commit has no
99
- session.
100
-
101
- ## Tests
102
-
103
- `mcp/test/gate.test.ts` runs the real script and the real installer against a
104
- temp repo, and ends with an actual `git commit`. From `mcp/`:
105
-
106
- ```sh
107
- npm test -- gate
108
- ```
109
-
110
- `pretest` builds `dist/`, which `pre-tool-gate.js` in the same file needs.
3
+ This directory contains the POSIX `eklavya-gate` script. The `eklavya` binary
4
+ (`config`, `doctor`, `install`, `dashboard`, etc.) lives in `mcp/src/cli.ts`.
5
+ Read the root `CLAUDE.md` for the repository contract.
6
+
7
+ ## Installation and scope
8
+
9
+ The terminal gate requires both a per-repository installation and project
10
+ `quiz.enforced: true`. `eklavya install` does not install a git hook.
11
+
12
+ `scripts/install-git-hook.sh` writes into the common Git directory so linked
13
+ worktrees use the same hook. It preserves an existing hook as `pre-commit.local`
14
+ and runs that first; `--uninstall` restores it. With `core.hooksPath` configured,
15
+ it prints the integration line and exits 2 without installing anything.
16
+
17
+ The installed wrapper tries the managed runtime, then the original installation
18
+ path, and invokes the script with `sh`. Missing both paths warns and allows the
19
+ commit. Preserve this fallback: updates can move plugin directories.
20
+ `eklavya uninstall` warns about the hook and prints removal instructions; it
21
+ does not remove the hook itself.
22
+
23
+ Project config lives in `~/.eklavya/projects/<slug>/config.json`; worktrees fold
24
+ to their main checkout. The script reads the old `<repo>/.eklavya.json` only as
25
+ a fallback and never migrates it. Global enforcement alone does not activate
26
+ this gate, but a global `quiz.enabled: false` releases it unless overridden by
27
+ the project. Keep legacy `mode` compatibility and explicit `false` values.
28
+
29
+ ## Fail-open contract
30
+
31
+ Use POSIX `sh`; the installed hook runs through `/bin/sh`. Missing repository,
32
+ config, `jq`, `sqlite3`, database or gate row allows the commit. Database query
33
+ errors also allow it. Missing dependencies warn on stderr.
34
+
35
+ Exit 1 only when a gate row exists for this repository and `passed` is not `1`.
36
+ Do not add an operational error that prevents a commit.
37
+
38
+ ## Keep duplicated logic aligned
39
+
40
+ | Script responsibility | Source and verification |
41
+ |---|---|
42
+ | Config merge and legacy `mode` alias | `mcp/src/config.ts`; shared fixtures in `mcp/test/gate.test.ts` |
43
+ | Project slug and worktree folding | `mcp/src/paths.ts`; physical paths must also handle symlinks |
44
+ | Latest repository gate lookup | `gates` schema and `syncGate` in `mcp/src/store.ts` |
45
+ | In-session commit detection | `mcp/src/hooks/pre-tool-gate.ts` and `commit-lib.ts` |
46
+
47
+ The script trusts persisted `passed`; it must not duplicate passing-grade or
48
+ threshold arithmetic. It looks up the latest gate by repository, whereas the
49
+ in-session hook uses a session ID. In jq, use explicit `if`/`elif` for booleans:
50
+ `//` treats `false` as absent and can re-enable a disabled legacy gate.
51
+
52
+ ## Documentation and verification
53
+
54
+ In the same PR, update the manual `commit-gate.mdx` for installer, prerequisite,
55
+ scope, bypass or failure behavior changes. Check `configuration.mdx`,
56
+ `skills/setup/SKILL.md` and the commit-gate acceptance check in `CONTRIBUTING.md`
57
+ when their claims change. Every claim about terminal enforcement must include
58
+ both installation and project enforcement.
59
+
60
+ From `mcp/`, run `npm test -- gate`. It builds the runtime and exercises the real
61
+ script and installer in temporary repositories, including an actual commit.
62
+ Build `web/` after documentation changes; report any live acceptance test not run.