vibe-learning-opencode 0.2.12 → 0.2.14

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 (2) hide show
  1. package/dist/index.js +80 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,52 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined")
5
+ return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
1
9
  // src/index.ts
10
+ import { homedir } from "node:os";
11
+ import { join } from "node:path";
12
+ import { existsSync } from "node:fs";
13
+ var DB_DIR = ".vibe-learning";
14
+ var DB_FILENAME = "learning.db";
15
+ function getLearningStatus() {
16
+ try {
17
+ const dbPath = join(homedir(), DB_DIR, DB_FILENAME);
18
+ if (!existsSync(dbPath)) {
19
+ return { unknownCount: 0, unknownFirst: null, dueCount: 0, dueFirst: null };
20
+ }
21
+ const { Database } = __require("bun:sqlite");
22
+ const db = new Database(dbPath, { readonly: true });
23
+ try {
24
+ const unknownsCount = db.query(
25
+ "SELECT COUNT(*) as count FROM unknown_unknowns WHERE explored = 0"
26
+ ).get();
27
+ const unknownsFirst = db.query(
28
+ "SELECT concept_id FROM unknown_unknowns WHERE explored = 0 ORDER BY appearances DESC, first_seen DESC LIMIT 1"
29
+ ).get();
30
+ const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
31
+ const reviewsCount = db.query(
32
+ "SELECT COUNT(*) as count FROM concept_progress WHERE next_review IS NOT NULL AND next_review <= ?"
33
+ ).get(today);
34
+ const reviewsFirst = db.query(
35
+ "SELECT concept_id FROM concept_progress WHERE next_review IS NOT NULL AND next_review <= ? ORDER BY next_review ASC LIMIT 1"
36
+ ).get(today);
37
+ return {
38
+ unknownCount: unknownsCount?.count ?? 0,
39
+ unknownFirst: unknownsFirst?.concept_id ?? null,
40
+ dueCount: reviewsCount?.count ?? 0,
41
+ dueFirst: reviewsFirst?.concept_id ?? null
42
+ };
43
+ } finally {
44
+ db.close();
45
+ }
46
+ } catch {
47
+ return { unknownCount: 0, unknownFirst: null, dueCount: 0, dueFirst: null };
48
+ }
49
+ }
2
50
  var CONFIG = {
3
51
  TOOL_THRESHOLD: 3,
4
52
  COOLDOWN_MS: 15 * 60 * 1e3,
@@ -193,18 +241,40 @@ var VibeLearningPlugin = async (ctx) => {
193
241
  });
194
242
  });
195
243
  };
244
+ let toastShownForSession = null;
196
245
  return {
197
- "session.created": async (input) => {
198
- const modeInfo = seniorEnabled && afterEnabled ? "Full mode" : seniorEnabled ? "Senior mode" : afterEnabled ? "After mode" : "Off";
199
- client.tui.showToast({
200
- body: {
201
- title: "\u{1F393} VibeLearning",
202
- message: `Active (${modeInfo}). /learn for status.`,
203
- variant: "info",
204
- duration: 3e3
246
+ "tool.execute.before": async (input) => {
247
+ if (input.tool.startsWith("vibe-learning_")) {
248
+ if (toastShownForSession !== input.sessionID) {
249
+ toastShownForSession = input.sessionID;
250
+ const status = getLearningStatus();
251
+ const parts = [];
252
+ if (status.unknownCount > 0) {
253
+ const unknownInfo = status.unknownFirst ? `${status.unknownCount} unexplored (${status.unknownFirst})` : `${status.unknownCount} unexplored`;
254
+ parts.push(unknownInfo);
255
+ }
256
+ if (status.dueCount > 0) {
257
+ const dueInfo = status.dueFirst ? `${status.dueCount} due (${status.dueFirst})` : `${status.dueCount} due`;
258
+ parts.push(dueInfo);
259
+ }
260
+ let message;
261
+ if (parts.length > 0) {
262
+ message = parts.join(", ") + ". /learn unknowns or /learn review";
263
+ } else {
264
+ const modeInfo = seniorEnabled && afterEnabled ? "Full mode" : seniorEnabled ? "Senior mode" : afterEnabled ? "After mode" : "Off";
265
+ message = `Active (${modeInfo}). /learn for status.`;
266
+ }
267
+ client.tui.showToast({
268
+ body: {
269
+ title: "\u{1F393} VibeLearning",
270
+ message,
271
+ variant: "info",
272
+ duration: 5e3
273
+ }
274
+ }).catch(() => {
275
+ });
205
276
  }
206
- }).catch(() => {
207
- });
277
+ }
208
278
  },
209
279
  "tool.execute.after": async (input, output) => {
210
280
  lastSessionID = input.sessionID;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibe-learning-opencode",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "description": "VibeLearning plugin for OpenCode - spaced repetition learning while coding",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",