pikakit 1.0.16 → 1.0.18

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.
@@ -19,6 +19,7 @@ import fs from "fs";
19
19
  import path from "path";
20
20
  import yaml from "js-yaml";
21
21
  import { KNOWLEDGE_DIR, LESSONS_PATH, DEBUG, VERSION } from "./config.js";
22
+ import { recordPatternEvent } from "./metrics-collector.js";
22
23
 
23
24
  // ============================================================================
24
25
  // CORE FUNCTIONS
@@ -111,6 +112,17 @@ function addLesson(pattern, message, severity = "WARNING", category = "general")
111
112
  db.lessons.push(lesson);
112
113
  saveKnowledge(db);
113
114
 
115
+ // Track this in metrics
116
+ try {
117
+ recordPatternEvent({
118
+ type: 'true_positive',
119
+ confidence: 0.8,
120
+ newPattern: true
121
+ });
122
+ } catch (e) {
123
+ // Ignore metrics errors
124
+ }
125
+
114
126
  console.log(`\nšŸŽ“ Lesson Learned: [${id}]`);
115
127
  console.log(` Pattern: /${pattern}/`);
116
128
  console.log(` Message: ${message}`);
@@ -40,6 +40,28 @@ function findProjectRoot() {
40
40
 
41
41
  const projectRoot = findProjectRoot();
42
42
  const dashboardPath = path.join(__dirname, '..', 'dashboard');
43
+ const knowledgeDir = path.join(projectRoot, '.agent', 'knowledge');
44
+
45
+ // Read lessons count from YAML files (same source as CLI)
46
+ function getLessonsCount() {
47
+ let count = 0;
48
+ const files = ['lessons-learned.yaml', 'mistakes.yaml', 'improvements.yaml'];
49
+
50
+ for (const file of files) {
51
+ const filePath = path.join(knowledgeDir, file);
52
+ if (fs.existsSync(filePath)) {
53
+ try {
54
+ const content = fs.readFileSync(filePath, 'utf-8');
55
+ // Simple YAML parsing - count items in lessons/mistakes/improvements arrays
56
+ const matches = content.match(/^\s*-\s+id:/gm);
57
+ if (matches) count += matches.length;
58
+ } catch (e) {
59
+ // Ignore read errors
60
+ }
61
+ }
62
+ }
63
+ return count;
64
+ }
43
65
 
44
66
  // ============================================================================
45
67
  // DATA PROVIDERS
@@ -78,26 +100,32 @@ const api = {
78
100
  // Full dashboard data
79
101
  '/api/dashboard': () => {
80
102
  try {
81
- const realKpis = metricsCollector?.getKPIs?.() || null;
82
- const hasRealData = realKpis?.kpis && Object.keys(realKpis.kpis).length > 0;
103
+ // Use getSummary from metrics-collector for real data
104
+ const summary = metricsCollector?.getSummary?.() || {};
105
+ const dashboardData = metricsCollector?.getDashboardData?.() || { kpis: {} };
106
+
107
+ // Also get lessons count from YAML files as fallback/supplement
108
+ const lessonsFromFiles = getLessonsCount();
83
109
 
84
- const kpis = hasRealData ? realKpis.kpis : {};
110
+ const totalTasks = summary.totalTasks || 0;
111
+ const patternsLearned = lessonsFromFiles || summary.patternsLearned || 0;
112
+ const skillsGenerated = summary.skillsGenerated || 0;
85
113
 
86
- const totalTasks = metricsCollector?.getMetricValue?.('total_tasks') || 0;
87
- const patternsLearned = causalityEngine?.getPatternCount?.() || 0;
88
- const skillsGenerated = skillGenerator?.getSkillCount?.() || 0;
114
+ // Determine if this is a new user (no lessons yet)
115
+ const isNewUser = patternsLearned === 0;
89
116
 
90
- // Determine if this is a new user (no data yet)
91
- const isNewUser = totalTasks === 0 && patternsLearned === 0;
117
+ // Build KPIs response
118
+ const kpis = dashboardData.kpis || {};
92
119
 
93
- const summary = {
120
+ const responseSummary = {
94
121
  totalTasks,
95
122
  patternsLearned,
96
123
  skillsGenerated,
97
124
  version: '7.0.0',
98
- isNewUser
125
+ isNewUser,
126
+ lastUpdated: summary.lastUpdated || new Date().toISOString()
99
127
  };
100
- return { kpis: { kpis }, summary, version: '7.0.0', isNewUser };
128
+ return { kpis: { kpis }, summary: responseSummary, version: '7.0.0', isNewUser };
101
129
  } catch (e) {
102
130
  return { kpis: { kpis: {} }, summary: { isNewUser: true }, error: e.message, version: '7.0.0', isNewUser: true };
103
131
  }
@@ -106,7 +134,7 @@ const api = {
106
134
  // KPIs only
107
135
  '/api/kpis': () => {
108
136
  try {
109
- return metricsCollector?.getKPIs?.() || { kpis: {} };
137
+ return metricsCollector?.getDashboardData?.() || { kpis: {} };
110
138
  } catch (e) {
111
139
  return { kpis: {}, error: e.message };
112
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pikakit",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Enterprise-grade Agent Skill Manager with Antigravity Skills support, Progressive Disclosure detection, and semantic routing validation",
5
5
  "license": "MIT",
6
6
  "author": "pikakit <pikakit@gmail.com>",