vibe-learning-opencode 0.2.10 → 0.2.11

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 +20 -112
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,63 +1,4 @@
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
-
9
1
  // src/index.ts
10
- import * as path from "node:path";
11
- import * as os from "node:os";
12
- import * as fs from "node:fs";
13
- var DB_DIR = ".vibe-learning";
14
- var DB_FILENAME = "learning.db";
15
- function getLearningStatus() {
16
- try {
17
- const dbPath = path.join(os.homedir(), DB_DIR, DB_FILENAME);
18
- if (!fs.existsSync(dbPath)) {
19
- return {
20
- unknownUnknowns: { count: 0 },
21
- dueReviews: { count: 0 }
22
- };
23
- }
24
- const Database = __require("better-sqlite3");
25
- const db = new Database(dbPath, { readonly: true });
26
- try {
27
- const unknownsCount = db.prepare(
28
- "SELECT COUNT(*) as count FROM unknown_unknowns WHERE explored = 0"
29
- ).get();
30
- const firstUnknown = db.prepare(
31
- "SELECT concept_id FROM unknown_unknowns WHERE explored = 0 ORDER BY appearances DESC, first_seen DESC LIMIT 1"
32
- ).get();
33
- const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
34
- const reviewsCount = db.prepare(
35
- "SELECT COUNT(*) as count FROM concept_progress WHERE next_review IS NOT NULL AND next_review <= ?"
36
- ).get(today);
37
- const firstReview = db.prepare(
38
- "SELECT concept_id FROM concept_progress WHERE next_review IS NOT NULL AND next_review <= ? ORDER BY next_review ASC LIMIT 1"
39
- ).get(today);
40
- return {
41
- unknownUnknowns: {
42
- count: unknownsCount?.count ?? 0,
43
- first: firstUnknown?.concept_id
44
- },
45
- dueReviews: {
46
- count: reviewsCount?.count ?? 0,
47
- first: firstReview?.concept_id
48
- }
49
- };
50
- } finally {
51
- db.close();
52
- }
53
- } catch (error) {
54
- return {
55
- unknownUnknowns: { count: 0 },
56
- dueReviews: { count: 0 },
57
- error: error instanceof Error ? error.message : "Unknown error"
58
- };
59
- }
60
- }
61
2
  var CONFIG = {
62
3
  TOOL_THRESHOLD: 3,
63
4
  COOLDOWN_MS: 15 * 60 * 1e3,
@@ -70,6 +11,7 @@ var recentConcepts = [];
70
11
  var seniorEnabled = true;
71
12
  var afterEnabled = true;
72
13
  var lastSessionID = null;
14
+ var shownToastForSession = null;
73
15
  var FILE_CONCEPTS = [
74
16
  { pattern: /test|spec|__tests__/i, concept: "unit-testing" },
75
17
  { pattern: /auth|login|session|jwt|oauth/i, concept: "authentication" },
@@ -239,7 +181,7 @@ var VibeLearningPlugin = async (ctx) => {
239
181
  const { client } = ctx;
240
182
  client.app.log({
241
183
  level: "info",
242
- message: "[VibeLearning] Plugin loaded (v3 - session toast)"
184
+ message: "[VibeLearning] Plugin loaded (v2 - independent toggles)"
243
185
  }).catch(() => {
244
186
  });
245
187
  const injectPrompt = (sessionID, prompt) => {
@@ -253,60 +195,22 @@ var VibeLearningPlugin = async (ctx) => {
253
195
  });
254
196
  };
255
197
  return {
256
- // Session created - show toast with learning status
257
- "session.created": async (input) => {
258
- lastSessionID = input.id;
259
- const status = getLearningStatus();
260
- let message;
261
- let variant = "info";
262
- if (status.error) {
263
- message = "Learning mode active. Use /learn to check status.";
264
- } else if (status.unknownUnknowns.count === 0 && status.dueReviews.count === 0) {
265
- message = "All caught up! No pending reviews.";
266
- variant = "success";
267
- } else {
268
- const parts = [];
269
- if (status.unknownUnknowns.count > 0) {
270
- const { first, count } = status.unknownUnknowns;
271
- if (first) {
272
- if (count === 1) {
273
- parts.push(`New concept: "${first}"`);
274
- } else {
275
- parts.push(`New concepts: "${first}" +${count - 1} more`);
198
+ "tool.execute.before": async (input) => {
199
+ if (input.tool.startsWith("mcp__vibe-learning__")) {
200
+ if (shownToastForSession !== input.sessionID) {
201
+ shownToastForSession = input.sessionID;
202
+ const modeInfo = seniorEnabled && afterEnabled ? "Full mode" : seniorEnabled ? "Senior mode" : afterEnabled ? "After mode" : "Off";
203
+ client.tui.showToast({
204
+ body: {
205
+ title: "\u{1F393} VibeLearning",
206
+ message: `Active (${modeInfo}). /learn for status.`,
207
+ variant: "info",
208
+ duration: 3e3
276
209
  }
277
- } else {
278
- parts.push(`${count} new concepts to learn`);
279
- }
280
- }
281
- if (status.dueReviews.count > 0) {
282
- const { first, count } = status.dueReviews;
283
- if (first) {
284
- if (count === 1) {
285
- parts.push(`Due for review: "${first}"`);
286
- } else {
287
- parts.push(`Due for review: "${first}" +${count - 1} more`);
288
- }
289
- } else {
290
- parts.push(`${count} concepts due for review`);
291
- }
210
+ }).catch(() => {
211
+ });
292
212
  }
293
- message = parts.join(" | ");
294
- variant = "warning";
295
213
  }
296
- client.tui.showToast({
297
- body: {
298
- title: "\u{1F4DA} VibeLearning",
299
- message,
300
- variant,
301
- duration: 5e3
302
- }
303
- }).catch(() => {
304
- });
305
- client.app.log({
306
- level: "info",
307
- message: `[VibeLearning] Session created: ${input.id} (unknowns: ${status.unknownUnknowns.count}, reviews: ${status.dueReviews.count})`
308
- }).catch(() => {
309
- });
310
214
  },
311
215
  "tool.execute.after": async (input, output) => {
312
216
  lastSessionID = input.sessionID;
@@ -365,11 +269,15 @@ var VibeLearningPlugin = async (ctx) => {
365
269
  }
366
270
  const prompt = COMMAND_PROMPTS[cmd];
367
271
  if (prompt) {
272
+ client.tui.showToast({
273
+ body: { title: "\u{1F393} VibeLearning", message: `Executing /learn ${cmd}...`, variant: "info", duration: 2e3 }
274
+ }).catch(() => {
275
+ });
368
276
  setTimeout(() => {
369
277
  if (lastSessionID) {
370
278
  injectPrompt(lastSessionID, prompt);
371
279
  }
372
- }, 100);
280
+ }, 500);
373
281
  }
374
282
  client.app.log({ level: "info", message: `[VibeLearning] Command: ${cmd}` }).catch(() => {
375
283
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibe-learning-opencode",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "VibeLearning plugin for OpenCode - spaced repetition learning while coding",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",