pikakit 1.0.54 → 2.0.0
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.
- package/README.md +18 -14
- package/bin/{lib → __tests__}/helpers.test.js +1 -1
- package/bin/{lib → __tests__}/skills.test.js +1 -1
- package/package.json +2 -8
- package/lib/agent-cli/README.md +0 -21
- package/lib/agent-cli/__tests__/adaptive_engine.test.js +0 -190
- package/lib/agent-cli/__tests__/integration/cross_script.test.js +0 -222
- package/lib/agent-cli/__tests__/integration/full_cycle.test.js +0 -230
- package/lib/agent-cli/__tests__/pattern_analyzer.test.js +0 -173
- package/lib/agent-cli/__tests__/pre_execution_check.test.js +0 -167
- package/lib/agent-cli/__tests__/skill_injector.test.js +0 -191
- package/lib/agent-cli/bin/agent.js +0 -191
- package/lib/agent-cli/dashboard/index.html +0 -1126
- package/lib/agent-cli/lib/ab-testing.js +0 -508
- package/lib/agent-cli/lib/audit.js +0 -154
- package/lib/agent-cli/lib/audit.test.js +0 -100
- package/lib/agent-cli/lib/backup.js +0 -138
- package/lib/agent-cli/lib/backup.test.js +0 -78
- package/lib/agent-cli/lib/causality-engine.js +0 -623
- package/lib/agent-cli/lib/cognitive-lesson.js +0 -476
- package/lib/agent-cli/lib/command-failure-learner.js +0 -254
- package/lib/agent-cli/lib/completion.js +0 -149
- package/lib/agent-cli/lib/config.js +0 -35
- package/lib/agent-cli/lib/dashboard-data.js +0 -211
- package/lib/agent-cli/lib/eslint-fix.js +0 -238
- package/lib/agent-cli/lib/evolution-signal.js +0 -215
- package/lib/agent-cli/lib/export.js +0 -86
- package/lib/agent-cli/lib/export.test.js +0 -65
- package/lib/agent-cli/lib/fix.js +0 -337
- package/lib/agent-cli/lib/fix.test.js +0 -80
- package/lib/agent-cli/lib/gemini-export.js +0 -83
- package/lib/agent-cli/lib/generate-registry.js +0 -42
- package/lib/agent-cli/lib/hooks/install-hooks.js +0 -152
- package/lib/agent-cli/lib/hooks/lint-learn.js +0 -172
- package/lib/agent-cli/lib/ignore.js +0 -116
- package/lib/agent-cli/lib/ignore.test.js +0 -58
- package/lib/agent-cli/lib/init.js +0 -124
- package/lib/agent-cli/lib/knowledge.js +0 -360
- package/lib/agent-cli/lib/learn.js +0 -267
- package/lib/agent-cli/lib/learn.test.js +0 -70
- package/lib/agent-cli/lib/metrics-collector.js +0 -523
- package/lib/agent-cli/lib/metrics-schema.js +0 -410
- package/lib/agent-cli/lib/migrate-to-v6.js +0 -377
- package/lib/agent-cli/lib/precision-skill-generator.js +0 -584
- package/lib/agent-cli/lib/proposals.js +0 -199
- package/lib/agent-cli/lib/proposals.test.js +0 -56
- package/lib/agent-cli/lib/recall.js +0 -752
- package/lib/agent-cli/lib/recall.test.js +0 -107
- package/lib/agent-cli/lib/reinforcement.js +0 -610
- package/lib/agent-cli/lib/selfevolution-bridge.js +0 -167
- package/lib/agent-cli/lib/settings.js +0 -227
- package/lib/agent-cli/lib/skill-learn.js +0 -296
- package/lib/agent-cli/lib/stats.js +0 -132
- package/lib/agent-cli/lib/stats.test.js +0 -94
- package/lib/agent-cli/lib/types.js +0 -33
- package/lib/agent-cli/lib/ui/audit-ui.js +0 -146
- package/lib/agent-cli/lib/ui/backup-ui.js +0 -107
- package/lib/agent-cli/lib/ui/clack-helpers.js +0 -317
- package/lib/agent-cli/lib/ui/common.js +0 -83
- package/lib/agent-cli/lib/ui/completion-ui.js +0 -126
- package/lib/agent-cli/lib/ui/custom-select.js +0 -69
- package/lib/agent-cli/lib/ui/dashboard-ui.js +0 -216
- package/lib/agent-cli/lib/ui/evolution-signals-ui.js +0 -107
- package/lib/agent-cli/lib/ui/export-ui.js +0 -94
- package/lib/agent-cli/lib/ui/fix-all-ui.js +0 -191
- package/lib/agent-cli/lib/ui/help-ui.js +0 -49
- package/lib/agent-cli/lib/ui/index.js +0 -222
- package/lib/agent-cli/lib/ui/init-ui.js +0 -56
- package/lib/agent-cli/lib/ui/knowledge-ui.js +0 -55
- package/lib/agent-cli/lib/ui/learn-ui.js +0 -706
- package/lib/agent-cli/lib/ui/lessons-ui.js +0 -148
- package/lib/agent-cli/lib/ui/pretty.js +0 -145
- package/lib/agent-cli/lib/ui/proposals-ui.js +0 -99
- package/lib/agent-cli/lib/ui/recall-ui.js +0 -342
- package/lib/agent-cli/lib/ui/routing-demo.js +0 -79
- package/lib/agent-cli/lib/ui/routing-ui.js +0 -325
- package/lib/agent-cli/lib/ui/settings-ui.js +0 -381
- package/lib/agent-cli/lib/ui/stats-ui.js +0 -123
- package/lib/agent-cli/lib/ui/watch-ui.js +0 -236
- package/lib/agent-cli/lib/watcher.js +0 -181
- package/lib/agent-cli/lib/watcher.test.js +0 -85
- package/lib/agent-cli/package.json +0 -51
- package/lib/agent-cli/scripts/dashboard-server.js +0 -408
- package/lib/agent-cli/scripts/pre_execution_check.js +0 -623
- package/lib/agent-cli/scripts/rule_sharing.js +0 -374
- package/lib/agent-cli/src/MIGRATION.md +0 -418
- package/lib/agent-cli/src/README.md +0 -367
- package/lib/agent-cli/src/core/evolution/evolution-signal.js +0 -42
- package/lib/agent-cli/src/core/evolution/index.js +0 -17
- package/lib/agent-cli/src/core/evolution/review-gate.js +0 -40
- package/lib/agent-cli/src/core/evolution/signal-detector.js +0 -137
- package/lib/agent-cli/src/core/evolution/signal-queue.js +0 -79
- package/lib/agent-cli/src/core/evolution/threshold-checker.js +0 -79
- package/lib/agent-cli/src/core/index.js +0 -15
- package/lib/agent-cli/src/core/learning/cognitive-enhancer.js +0 -282
- package/lib/agent-cli/src/core/learning/index.js +0 -12
- package/lib/agent-cli/src/core/learning/lesson-synthesizer.js +0 -83
- package/lib/agent-cli/src/core/scanning/index.js +0 -14
- package/lib/agent-cli/src/data/index.js +0 -13
- package/lib/agent-cli/src/data/repositories/index.js +0 -8
- package/lib/agent-cli/src/data/repositories/lesson-repository.js +0 -130
- package/lib/agent-cli/src/data/repositories/signal-repository.js +0 -119
- package/lib/agent-cli/src/data/storage/index.js +0 -8
- package/lib/agent-cli/src/data/storage/json-storage.js +0 -64
- package/lib/agent-cli/src/data/storage/yaml-storage.js +0 -66
- package/lib/agent-cli/src/infrastructure/index.js +0 -13
- package/lib/agent-cli/src/presentation/formatters/skill-formatter.js +0 -232
- package/lib/agent-cli/src/services/export-service.js +0 -162
- package/lib/agent-cli/src/services/index.js +0 -13
- package/lib/agent-cli/src/services/learning-service.js +0 -99
- package/lib/agent-cli/types/index.d.ts +0 -343
- package/lib/agent-cli/utils/benchmark.js +0 -269
- package/lib/agent-cli/utils/logger.js +0 -303
- package/lib/agent-cli/utils/ml_patterns.js +0 -300
- package/lib/agent-cli/utils/recovery.js +0 -312
- package/lib/agent-cli/utils/telemetry.js +0 -290
- package/lib/agentskillskit-cli/README.md +0 -21
- package/lib/agentskillskit-cli/ag-smart.js +0 -158
- package/lib/agentskillskit-cli/package.json +0 -51
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **CLI installer for PikaKit - FAANG-grade AI skills, workflows, and agents**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/pikakit)
|
|
6
|
-
[](https://www.npmjs.com/package/pikakit)
|
|
7
7
|
[](https://github.com/pikakit/pikakit)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
|
|
@@ -25,7 +25,6 @@ npx pikakit
|
|
|
25
25
|
| **Rules** | GEMINI.md | AI behavior configuration |
|
|
26
26
|
| **Scripts** | 25 | JavaScript automation scripts |
|
|
27
27
|
| **Commands** | `kit` | CLI management tool |
|
|
28
|
-
| **Commands** | `agent` | Interactive learning (optional) |
|
|
29
28
|
|
|
30
29
|
---
|
|
31
30
|
|
|
@@ -73,7 +72,7 @@ your-project/
|
|
|
73
72
|
│ └── metrics/ # Tracking
|
|
74
73
|
│
|
|
75
74
|
├── kit.cmd / kit # CLI wrapper
|
|
76
|
-
└── agent
|
|
75
|
+
└── .agent/lib/agent-cli/ # Agent CLI (run locally)
|
|
77
76
|
```
|
|
78
77
|
|
|
79
78
|
---
|
|
@@ -113,14 +112,15 @@ kit cache status # View cache usage
|
|
|
113
112
|
kit cache clear # Clear cache
|
|
114
113
|
```
|
|
115
114
|
|
|
116
|
-
### `agent` Command (
|
|
115
|
+
### `agent` Command (Local Only - v2.0+)
|
|
117
116
|
|
|
118
117
|
```bash
|
|
119
|
-
|
|
120
|
-
agent
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
agent
|
|
118
|
+
# Run from project root:
|
|
119
|
+
node .agent/lib/agent-cli/bin/agent.js
|
|
120
|
+
|
|
121
|
+
# Or add to package.json:
|
|
122
|
+
"scripts": { "agent": "node .agent/lib/agent-cli/bin/agent.js" }
|
|
123
|
+
npm run agent
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
---
|
|
@@ -204,12 +204,16 @@ npm install # Node.js dependencies
|
|
|
204
204
|
|
|
205
205
|
## 📈 Version History
|
|
206
206
|
|
|
207
|
-
**
|
|
207
|
+
**v2.0.0 (Current)**
|
|
208
|
+
- ⚠️ BREAKING: Agent CLI removed from npm package
|
|
209
|
+
- ✅ Agent CLI now runs locally from `.agent/lib/agent-cli/`
|
|
210
|
+
- ✅ Package size reduced 75%
|
|
211
|
+
- ✅ Clearer separation: pikakit = installer only
|
|
212
|
+
|
|
213
|
+
**v1.0.0**
|
|
208
214
|
- ✅ Renamed to PikaKit for cross-platform npx support
|
|
209
215
|
- ✅ Works with `npx pikakit` on Windows, macOS, Linux
|
|
210
216
|
- ✅ 100% JavaScript - No Python required
|
|
211
|
-
- ✅ AutoLearn made optional
|
|
212
|
-
- ✅ Complete installation (config, scripts-js, metrics, policy docs)
|
|
213
217
|
|
|
214
218
|
---
|
|
215
219
|
|
|
@@ -235,8 +239,8 @@ MIT - Free for all projects.
|
|
|
235
239
|
|
|
236
240
|
---
|
|
237
241
|
|
|
238
|
-
**⚡ PikaKit
|
|
239
|
-
*One command. Complete AI setup.*
|
|
242
|
+
**⚡ PikaKit v2.0.0**
|
|
243
|
+
*One command. Complete AI setup. Installer only.*
|
|
240
244
|
|
|
241
245
|
---
|
|
242
246
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @fileoverview Tests for helpers.js
|
|
3
3
|
*/
|
|
4
4
|
import { describe, it, expect } from "vitest";
|
|
5
|
-
import { formatBytes, formatDate, parseSkillSpec } from "
|
|
5
|
+
import { formatBytes, formatDate, parseSkillSpec } from "../lib/helpers.js";
|
|
6
6
|
|
|
7
7
|
describe("formatBytes", () => {
|
|
8
8
|
it("formats bytes correctly", () => {
|
|
@@ -5,7 +5,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import os from "os";
|
|
8
|
-
import { parseSkillMdFrontmatter, detectSkillStructure } from "
|
|
8
|
+
import { parseSkillMdFrontmatter, detectSkillStructure } from "../lib/skills.js";
|
|
9
9
|
|
|
10
10
|
describe("parseSkillMdFrontmatter", () => {
|
|
11
11
|
let tempDir;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pikakit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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>",
|
|
@@ -15,17 +15,14 @@
|
|
|
15
15
|
"type": "module",
|
|
16
16
|
"bin": {
|
|
17
17
|
"pikakit": "bin/cli.mjs",
|
|
18
|
-
"kit": "bin/kit.js"
|
|
19
|
-
"agent": "lib/agent-cli/bin/agent.js"
|
|
18
|
+
"kit": "bin/kit.js"
|
|
20
19
|
},
|
|
21
20
|
"files": [
|
|
22
21
|
"bin/",
|
|
23
|
-
"lib/",
|
|
24
22
|
"specs/",
|
|
25
23
|
"README.md",
|
|
26
24
|
"LICENSE"
|
|
27
25
|
],
|
|
28
|
-
"types": "./lib/agent-cli/types/index.d.ts",
|
|
29
26
|
"engines": {
|
|
30
27
|
"node": ">=18.0.0"
|
|
31
28
|
},
|
|
@@ -68,12 +65,9 @@
|
|
|
68
65
|
"kleur": "^4.1.5",
|
|
69
66
|
"ora": "^9.1.0",
|
|
70
67
|
"picocolors": "^1.1.1",
|
|
71
|
-
"pikakit": "^1.0.7",
|
|
72
|
-
"pikakit-agent-skills": "^3.2.8",
|
|
73
68
|
"prompts": "^2.4.2"
|
|
74
69
|
},
|
|
75
70
|
"devDependencies": {
|
|
76
|
-
"agentskillskit-cli": "^3.2.0",
|
|
77
71
|
"eslint": "^8.57.0",
|
|
78
72
|
"prettier": "^3.2.5",
|
|
79
73
|
"vitest": "^4.0.18"
|
package/lib/agent-cli/README.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# PikaKit CLI
|
|
2
|
-
|
|
3
|
-
The intelligent CLI engine for PikaKit, featuring:
|
|
4
|
-
- **Routing Engine**: Semantic routing validation
|
|
5
|
-
- **Audit System**: Skill usage auditing and metrics
|
|
6
|
-
- **Interactive Mode**: Smart interactive agent interface
|
|
7
|
-
|
|
8
|
-
## Installation
|
|
9
|
-
|
|
10
|
-
This package is typically managed by the `add-skill-kit` installer.
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
# Global install (managed by installer)
|
|
14
|
-
npm install -g @agentskillskit/cli
|
|
15
|
-
|
|
16
|
-
# Usage
|
|
17
|
-
agent
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Documentation
|
|
21
|
-
See the main [PikaKit](https://github.com/agentskillskit/agent-skills) repository.
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unit Tests for adaptive_engine.js
|
|
3
|
-
*
|
|
4
|
-
* Tests:
|
|
5
|
-
* - adjustSeverity
|
|
6
|
-
* - promoteRules
|
|
7
|
-
* - demoteRules
|
|
8
|
-
* - analyzeRules
|
|
9
|
-
* - runAdaptiveCycle
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
13
|
-
|
|
14
|
-
// Mock fs module
|
|
15
|
-
vi.mock('fs', async () => {
|
|
16
|
-
const actual = await vi.importActual('fs');
|
|
17
|
-
return {
|
|
18
|
-
...actual,
|
|
19
|
-
default: {
|
|
20
|
-
...actual,
|
|
21
|
-
existsSync: vi.fn(() => false),
|
|
22
|
-
readFileSync: vi.fn(() => '{}'),
|
|
23
|
-
writeFileSync: vi.fn()
|
|
24
|
-
},
|
|
25
|
-
existsSync: vi.fn(() => false),
|
|
26
|
-
readFileSync: vi.fn(() => '{}')
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Severity levels constant
|
|
31
|
-
const SEVERITY_LEVELS = ['LOW', 'MEDIUM', 'HIGH', 'CRITICAL'];
|
|
32
|
-
|
|
33
|
-
describe('Adaptive Engine', () => {
|
|
34
|
-
describe('adjustSeverity', () => {
|
|
35
|
-
it('should increase severity for 10+ hits', () => {
|
|
36
|
-
const lesson = {
|
|
37
|
-
id: 'TEST-001',
|
|
38
|
-
hitCount: 15,
|
|
39
|
-
severity: 'MEDIUM'
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const currentIndex = SEVERITY_LEVELS.indexOf(lesson.severity);
|
|
43
|
-
|
|
44
|
-
if (lesson.hitCount >= 10 && currentIndex < SEVERITY_LEVELS.length - 1) {
|
|
45
|
-
lesson.severity = SEVERITY_LEVELS[currentIndex + 1];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
expect(lesson.severity).toBe('HIGH');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should increase to CRITICAL for 25+ hits', () => {
|
|
52
|
-
const lesson = {
|
|
53
|
-
id: 'TEST-001',
|
|
54
|
-
hitCount: 30,
|
|
55
|
-
severity: 'LOW'
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const currentIndex = SEVERITY_LEVELS.indexOf(lesson.severity);
|
|
59
|
-
|
|
60
|
-
if (lesson.hitCount >= 25 && currentIndex < SEVERITY_LEVELS.length - 2) {
|
|
61
|
-
lesson.severity = SEVERITY_LEVELS[currentIndex + 2];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
expect(lesson.severity).toBe('HIGH');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should decrease severity for 0 hits in 30 days', () => {
|
|
68
|
-
const thirtyDaysAgo = new Date(Date.now() - 31 * 24 * 60 * 60 * 1000);
|
|
69
|
-
const lesson = {
|
|
70
|
-
id: 'TEST-001',
|
|
71
|
-
hitCount: 0,
|
|
72
|
-
severity: 'HIGH',
|
|
73
|
-
lastHit: thirtyDaysAgo.toISOString()
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const lastHit = new Date(lesson.lastHit);
|
|
77
|
-
const thresholdDate = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
|
|
78
|
-
const currentIndex = SEVERITY_LEVELS.indexOf(lesson.severity);
|
|
79
|
-
|
|
80
|
-
if (lastHit < thresholdDate && currentIndex > 0) {
|
|
81
|
-
lesson.severity = SEVERITY_LEVELS[currentIndex - 1];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
expect(lesson.severity).toBe('MEDIUM');
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('should not decrease LOW severity further', () => {
|
|
88
|
-
const lesson = {
|
|
89
|
-
id: 'TEST-001',
|
|
90
|
-
severity: 'LOW'
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const currentIndex = SEVERITY_LEVELS.indexOf(lesson.severity);
|
|
94
|
-
expect(currentIndex).toBe(0);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('promoteRules', () => {
|
|
99
|
-
it('should promote rules with 95%+ accuracy', () => {
|
|
100
|
-
const lesson = {
|
|
101
|
-
id: 'TEST-001',
|
|
102
|
-
hitCount: 1,
|
|
103
|
-
successCount: 19, // 19/20 = 95%
|
|
104
|
-
severity: 'MEDIUM'
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const totalAttempts = lesson.hitCount + lesson.successCount;
|
|
108
|
-
const accuracy = lesson.successCount / totalAttempts;
|
|
109
|
-
|
|
110
|
-
if (accuracy >= 0.95 && lesson.severity !== 'CRITICAL') {
|
|
111
|
-
lesson.promoted = true;
|
|
112
|
-
lesson.severity = 'CRITICAL';
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
expect(lesson.promoted).toBe(true);
|
|
116
|
-
expect(lesson.severity).toBe('CRITICAL');
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('should not promote rules with <10 attempts', () => {
|
|
120
|
-
const lesson = {
|
|
121
|
-
id: 'TEST-001',
|
|
122
|
-
hitCount: 1,
|
|
123
|
-
successCount: 5, // Only 6 attempts
|
|
124
|
-
severity: 'MEDIUM'
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const totalAttempts = lesson.hitCount + lesson.successCount;
|
|
128
|
-
|
|
129
|
-
// Need 10+ attempts to evaluate
|
|
130
|
-
const shouldEvaluate = totalAttempts >= 10;
|
|
131
|
-
|
|
132
|
-
expect(shouldEvaluate).toBe(false);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe('demoteRules', () => {
|
|
137
|
-
it('should demote rules with <50% accuracy', () => {
|
|
138
|
-
const lesson = {
|
|
139
|
-
id: 'TEST-001',
|
|
140
|
-
hitCount: 8,
|
|
141
|
-
successCount: 2, // 2/10 = 20%
|
|
142
|
-
severity: 'HIGH'
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const totalAttempts = lesson.hitCount + lesson.successCount;
|
|
146
|
-
const accuracy = lesson.successCount / totalAttempts;
|
|
147
|
-
|
|
148
|
-
if (accuracy < 0.50 && lesson.severity !== 'LOW') {
|
|
149
|
-
lesson.demoted = true;
|
|
150
|
-
lesson.severity = 'LOW';
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
expect(lesson.demoted).toBe(true);
|
|
154
|
-
expect(lesson.severity).toBe('LOW');
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('should not demote LOW severity rules', () => {
|
|
158
|
-
const lesson = {
|
|
159
|
-
id: 'TEST-001',
|
|
160
|
-
severity: 'LOW'
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const shouldDemote = lesson.severity !== 'LOW';
|
|
164
|
-
|
|
165
|
-
expect(shouldDemote).toBe(false);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
describe('analyzeRules', () => {
|
|
170
|
-
it('should group lessons by severity', () => {
|
|
171
|
-
const lessons = [
|
|
172
|
-
{ severity: 'LOW' },
|
|
173
|
-
{ severity: 'MEDIUM' },
|
|
174
|
-
{ severity: 'MEDIUM' },
|
|
175
|
-
{ severity: 'HIGH' },
|
|
176
|
-
{ severity: 'CRITICAL' }
|
|
177
|
-
];
|
|
178
|
-
|
|
179
|
-
const bySeverity = {};
|
|
180
|
-
for (const lesson of lessons) {
|
|
181
|
-
bySeverity[lesson.severity] = (bySeverity[lesson.severity] || 0) + 1;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
expect(bySeverity.LOW).toBe(1);
|
|
185
|
-
expect(bySeverity.MEDIUM).toBe(2);
|
|
186
|
-
expect(bySeverity.HIGH).toBe(1);
|
|
187
|
-
expect(bySeverity.CRITICAL).toBe(1);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* E2E Integration Tests - Cross-Script Integration
|
|
3
|
-
*
|
|
4
|
-
* Tests integration between different scripts:
|
|
5
|
-
* - error_sensor ↔ pattern_analyzer
|
|
6
|
-
* - pattern_analyzer ↔ pre_execution_check
|
|
7
|
-
* - adaptive_engine ↔ skill_injector
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
11
|
-
|
|
12
|
-
describe('E2E: Cross-Script Integration', () => {
|
|
13
|
-
describe('Error Sensor → Pattern Analyzer', () => {
|
|
14
|
-
it('should pass error format between scripts', () => {
|
|
15
|
-
// Error format from error_sensor
|
|
16
|
-
const sensorOutput = {
|
|
17
|
-
id: 'ERR-001',
|
|
18
|
-
type: 'test-failure',
|
|
19
|
-
source: 'test',
|
|
20
|
-
message: 'Test failed',
|
|
21
|
-
severity: 'HIGH',
|
|
22
|
-
timestamp: new Date().toISOString(),
|
|
23
|
-
context: {
|
|
24
|
-
project: { projectType: 'nextjs' },
|
|
25
|
-
file: { fileType: '.tsx' }
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// Pattern analyzer input format
|
|
30
|
-
const analyzerInput = [sensorOutput];
|
|
31
|
-
|
|
32
|
-
// Verify format compatibility
|
|
33
|
-
expect(analyzerInput[0].type).toBeDefined();
|
|
34
|
-
expect(analyzerInput[0].severity).toBeDefined();
|
|
35
|
-
expect(analyzerInput[0].context).toBeDefined();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should aggregate errors correctly', () => {
|
|
39
|
-
const errors = [
|
|
40
|
-
{ type: 'lint', severity: 'LOW' },
|
|
41
|
-
{ type: 'lint', severity: 'LOW' },
|
|
42
|
-
{ type: 'test', severity: 'HIGH' },
|
|
43
|
-
{ type: 'lint', severity: 'LOW' }
|
|
44
|
-
];
|
|
45
|
-
|
|
46
|
-
// Pattern analyzer aggregation
|
|
47
|
-
const byType = {};
|
|
48
|
-
const bySeverity = {};
|
|
49
|
-
|
|
50
|
-
for (const err of errors) {
|
|
51
|
-
byType[err.type] = (byType[err.type] || 0) + 1;
|
|
52
|
-
bySeverity[err.severity] = (bySeverity[err.severity] || 0) + 1;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
expect(byType.lint).toBe(3);
|
|
56
|
-
expect(byType.test).toBe(1);
|
|
57
|
-
expect(bySeverity.LOW).toBe(3);
|
|
58
|
-
expect(bySeverity.HIGH).toBe(1);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe('Pattern Analyzer → Pre-Execution Check', () => {
|
|
63
|
-
it('should generate rules compatible with checker', () => {
|
|
64
|
-
// Pattern analyzer output
|
|
65
|
-
const highFrequency = [
|
|
66
|
-
{ pattern: 'missing-await', count: 5, type: 'error' },
|
|
67
|
-
{ pattern: 'no-try-catch', count: 4, type: 'error' }
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
// Generate rules for pre-execution check
|
|
71
|
-
const rules = highFrequency.map(hf => ({
|
|
72
|
-
id: `AUTO-${hf.pattern.toUpperCase()}`,
|
|
73
|
-
pattern: hf.pattern,
|
|
74
|
-
prevention: `Avoid ${hf.pattern}`,
|
|
75
|
-
severity: hf.count >= 5 ? 'HIGH' : 'MEDIUM',
|
|
76
|
-
status: 'proposed'
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
expect(rules[0].id).toBe('AUTO-MISSING-AWAIT');
|
|
80
|
-
expect(rules[0].severity).toBe('HIGH');
|
|
81
|
-
expect(rules[1].severity).toBe('MEDIUM');
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should match rules against intent', () => {
|
|
85
|
-
const rules = [
|
|
86
|
-
{ pattern: 'delete', severity: 'CRITICAL' },
|
|
87
|
-
{ pattern: 'async', severity: 'MEDIUM' }
|
|
88
|
-
];
|
|
89
|
-
|
|
90
|
-
const intent = 'create async function';
|
|
91
|
-
const matches = rules.filter(r =>
|
|
92
|
-
intent.toLowerCase().includes(r.pattern)
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
expect(matches.length).toBe(1);
|
|
96
|
-
expect(matches[0].pattern).toBe('async');
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe('Adaptive Engine → Skill Injector', () => {
|
|
101
|
-
it('should pass promoted lessons for skill generation', () => {
|
|
102
|
-
// Adaptive engine output
|
|
103
|
-
const promotedLessons = [
|
|
104
|
-
{ id: 'SAFE-001', pattern: 'backup-first', severity: 'CRITICAL', promoted: true },
|
|
105
|
-
{ id: 'SAFE-002', pattern: 'confirm-delete', severity: 'CRITICAL', promoted: true },
|
|
106
|
-
{ id: 'SAFE-003', pattern: 'check-exists', severity: 'CRITICAL', promoted: true }
|
|
107
|
-
];
|
|
108
|
-
|
|
109
|
-
// Skill injector categorization
|
|
110
|
-
const categories = {};
|
|
111
|
-
for (const lesson of promotedLessons) {
|
|
112
|
-
const category = lesson.id.split('-')[0];
|
|
113
|
-
if (!categories[category]) {
|
|
114
|
-
categories[category] = [];
|
|
115
|
-
}
|
|
116
|
-
categories[category].push(lesson);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
expect(categories.SAFE.length).toBe(3);
|
|
120
|
-
expect(categories.SAFE.every(l => l.promoted)).toBe(true);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('should generate skill from 3+ lessons', () => {
|
|
124
|
-
const lessons = [
|
|
125
|
-
{ id: 'CODE-001', pattern: 'type-annotation' },
|
|
126
|
-
{ id: 'CODE-002', pattern: 'null-check' },
|
|
127
|
-
{ id: 'CODE-003', pattern: 'error-handling' }
|
|
128
|
-
];
|
|
129
|
-
|
|
130
|
-
const canGenerateSkill = lessons.length >= 3;
|
|
131
|
-
expect(canGenerateSkill).toBe(true);
|
|
132
|
-
|
|
133
|
-
// Mock skill generation
|
|
134
|
-
const skill = {
|
|
135
|
-
name: 'code-patterns',
|
|
136
|
-
lessonCount: lessons.length,
|
|
137
|
-
generatedAt: new Date().toISOString()
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
expect(skill.name).toBe('code-patterns');
|
|
141
|
-
expect(skill.lessonCount).toBe(3);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
describe('Success Sensor → Pattern Analyzer', () => {
|
|
146
|
-
it('should pass success format for balance calculation', () => {
|
|
147
|
-
const successes = [
|
|
148
|
-
{ pattern: 'async-await', type: 'pattern' },
|
|
149
|
-
{ pattern: 'typescript', type: 'pattern' }
|
|
150
|
-
];
|
|
151
|
-
|
|
152
|
-
const errors = [
|
|
153
|
-
{ type: 'test', severity: 'HIGH' }
|
|
154
|
-
];
|
|
155
|
-
|
|
156
|
-
// Calculate balance
|
|
157
|
-
const totalSuccesses = successes.length;
|
|
158
|
-
const totalFailures = errors.length;
|
|
159
|
-
const total = totalSuccesses + totalFailures;
|
|
160
|
-
const ratio = totalSuccesses / total;
|
|
161
|
-
|
|
162
|
-
expect(ratio).toBeCloseTo(0.67, 1);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
describe('Rule Sharing → Pre-Execution Check', () => {
|
|
167
|
-
it('should import rules in correct format', () => {
|
|
168
|
-
// Exported rule format
|
|
169
|
-
const exportedRule = {
|
|
170
|
-
id: 'SAFE-001',
|
|
171
|
-
pattern: 'delete-without-backup',
|
|
172
|
-
severity: 'CRITICAL',
|
|
173
|
-
source: 'imported'
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
// Verify format for pre-execution
|
|
177
|
-
expect(exportedRule.id).toBeDefined();
|
|
178
|
-
expect(exportedRule.pattern).toBeDefined();
|
|
179
|
-
expect(exportedRule.severity).toBeDefined();
|
|
180
|
-
expect(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).toContain(exportedRule.severity);
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
describe('Full Cross-Script Pipeline', () => {
|
|
185
|
-
it('should maintain data integrity through pipeline', () => {
|
|
186
|
-
// 1. Error sensor detects
|
|
187
|
-
const error = {
|
|
188
|
-
id: 'ERR-001',
|
|
189
|
-
type: 'missing-return-type',
|
|
190
|
-
severity: 'MEDIUM',
|
|
191
|
-
timestamp: new Date().toISOString()
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
// 2. Pattern analyzer creates lesson
|
|
195
|
-
const lesson = {
|
|
196
|
-
id: 'CODE-001',
|
|
197
|
-
pattern: error.type,
|
|
198
|
-
severity: error.severity,
|
|
199
|
-
hitCount: 1
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
// 3. After multiple hits, adaptive engine promotes
|
|
203
|
-
lesson.hitCount = 25;
|
|
204
|
-
if (lesson.hitCount >= 25) {
|
|
205
|
-
lesson.severity = 'CRITICAL';
|
|
206
|
-
lesson.promoted = true;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// 4. Pre-execution check uses promoted rule
|
|
210
|
-
const intent = 'create function missing-return-type';
|
|
211
|
-
const matches = intent.includes(lesson.pattern);
|
|
212
|
-
|
|
213
|
-
// 5. Skill injector can use for skill
|
|
214
|
-
const canMakeSkill = lesson.promoted;
|
|
215
|
-
|
|
216
|
-
expect(error.type).toBe(lesson.pattern);
|
|
217
|
-
expect(lesson.severity).toBe('CRITICAL');
|
|
218
|
-
expect(matches).toBe(true);
|
|
219
|
-
expect(canMakeSkill).toBe(true);
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
});
|