@the-magic-tower/fixhive-opencode-plugin 0.1.1 → 0.1.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 (2) hide show
  1. package/dist/index.js +61 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1254,19 +1254,41 @@ ${errorRecord.errorStack || ""}`;
1254
1254
  };
1255
1255
  }
1256
1256
  /**
1257
- * Vote on a knowledge entry
1257
+ * Vote on a knowledge entry (with duplicate vote prevention)
1258
1258
  */
1259
1259
  async vote(knowledgeId, helpful) {
1260
- const column = helpful ? "upvotes" : "downvotes";
1261
- await this.supabase.rpc("increment_vote", {
1262
- entry_id: knowledgeId,
1263
- vote_type: column
1260
+ const voteType = helpful ? "up" : "down";
1261
+ const { data, error } = await this.supabase.rpc("safe_vote", {
1262
+ p_entry_id: knowledgeId,
1263
+ p_user_hash: this.contributorId,
1264
+ p_vote_type: voteType
1264
1265
  });
1265
- await this.supabase.from("usage_logs").insert({
1266
- knowledge_id: knowledgeId,
1267
- action: helpful ? "upvote" : "downvote",
1268
- user_hash: this.contributorId
1266
+ if (error) {
1267
+ return { success: false, error: error.message };
1268
+ }
1269
+ const result = data;
1270
+ if (result.success) {
1271
+ await this.supabase.from("usage_logs").insert({
1272
+ knowledge_id: knowledgeId,
1273
+ action: helpful ? "upvote" : "downvote",
1274
+ user_hash: this.contributorId
1275
+ });
1276
+ }
1277
+ return result;
1278
+ }
1279
+ /**
1280
+ * Report an entry for review
1281
+ */
1282
+ async reportEntry(knowledgeId, reason) {
1283
+ const { data, error } = await this.supabase.rpc("report_entry", {
1284
+ p_entry_id: knowledgeId,
1285
+ p_user_hash: this.contributorId,
1286
+ p_reason: reason || null
1269
1287
  });
1288
+ if (error) {
1289
+ return { success: false };
1290
+ }
1291
+ return data;
1270
1292
  }
1271
1293
  /**
1272
1294
  * Report helpful usage
@@ -1452,10 +1474,33 @@ function createTools(localStore, cloudClient, privacyFilter, context) {
1452
1474
  helpful: tool.schema.boolean().describe("True for upvote, false for downvote")
1453
1475
  },
1454
1476
  async execute(args) {
1455
- await cloudClient.vote(args.knowledgeId, args.helpful);
1477
+ const result = await cloudClient.vote(args.knowledgeId, args.helpful);
1478
+ if (!result.success) {
1479
+ if (result.error === "Already voted") {
1480
+ return "You have already voted on this solution.";
1481
+ }
1482
+ return `Vote failed: ${result.error}`;
1483
+ }
1456
1484
  return args.helpful ? "Thanks for the feedback! Solution upvoted." : "Thanks for the feedback! Solution downvoted.";
1457
1485
  }
1458
1486
  }),
1487
+ /**
1488
+ * Report inappropriate content
1489
+ */
1490
+ fixhive_report: tool({
1491
+ description: "Report a FixHive solution for inappropriate content, spam, or incorrect information.",
1492
+ args: {
1493
+ knowledgeId: tool.schema.string().describe("Knowledge entry ID to report"),
1494
+ reason: tool.schema.string().optional().describe("Reason for reporting (spam, incorrect, inappropriate, etc.)")
1495
+ },
1496
+ async execute(args) {
1497
+ const result = await cloudClient.reportEntry(args.knowledgeId, args.reason);
1498
+ if (!result.success) {
1499
+ return "Failed to submit report. Please try again later.";
1500
+ }
1501
+ return "Report submitted. Thank you for helping keep FixHive clean!";
1502
+ }
1503
+ }),
1459
1504
  /**
1460
1505
  * Get usage statistics
1461
1506
  */
@@ -1691,10 +1736,14 @@ ${errors.map((e) => `- [${e.id.slice(0, 8)}] ${e.errorType}: ${e.errorMessage.sl
1691
1736
  })
1692
1737
  };
1693
1738
  }
1739
+ var COMMUNITY_SUPABASE = {
1740
+ url: "https://flpqzkrpufrgnpxvftip.supabase.co",
1741
+ anonKey: "sb_publishable_w3Y2uo-0vb4bFVamntChVw_Aqi0rv2y"
1742
+ };
1694
1743
  function loadConfig() {
1695
1744
  return {
1696
- supabaseUrl: process.env.FIXHIVE_SUPABASE_URL || "",
1697
- supabaseAnonKey: process.env.FIXHIVE_SUPABASE_KEY || "",
1745
+ supabaseUrl: process.env.FIXHIVE_SUPABASE_URL || COMMUNITY_SUPABASE.url,
1746
+ supabaseAnonKey: process.env.FIXHIVE_SUPABASE_KEY || COMMUNITY_SUPABASE.anonKey,
1698
1747
  openaiApiKey: process.env.OPENAI_API_KEY || process.env.FIXHIVE_OPENAI_KEY || "",
1699
1748
  contributorId: process.env.FIXHIVE_CONTRIBUTOR_ID || "",
1700
1749
  cacheExpirationMs: DEFAULT_CONFIG.cacheExpirationMs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-magic-tower/fixhive-opencode-plugin",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Community-based error knowledge sharing for OpenCode",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",