hebbian 0.8.2 → 0.9.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/dist/bin/hebbian.js +49 -18
- package/dist/bin/hebbian.js.map +1 -1
- package/dist/digest.d.ts.map +1 -1
- package/dist/index.js +49 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/hebbian.js
CHANGED
|
@@ -2373,12 +2373,15 @@ function extractCorrections(messages) {
|
|
|
2373
2373
|
const corrections = [];
|
|
2374
2374
|
for (const text of messages) {
|
|
2375
2375
|
if (corrections.length >= MAX_CORRECTIONS_PER_SESSION) break;
|
|
2376
|
+
const trimmed = text.trim();
|
|
2376
2377
|
if (text.length < MIN_CORRECTION_LENGTH) continue;
|
|
2377
|
-
if (/^[\/!]/.test(
|
|
2378
|
-
if (
|
|
2379
|
-
if (/^<[a-zA-Z]/.test(
|
|
2380
|
-
if (/^Base directory for this skill:/i.test(
|
|
2381
|
-
if (/^[•·▸▶\-\*]\s/.test(
|
|
2378
|
+
if (/^[\/!]/.test(trimmed)) continue;
|
|
2379
|
+
if (/[??]\s*[!!]?\s*$/.test(trimmed)) continue;
|
|
2380
|
+
if (/^<[a-zA-Z]/.test(trimmed)) continue;
|
|
2381
|
+
if (/^Base directory for this skill:/i.test(trimmed)) continue;
|
|
2382
|
+
if (/^[•·▸▶\-\*]\s/.test(trimmed)) continue;
|
|
2383
|
+
if (/<[a-zA-Z][a-zA-Z-]*>/.test(trimmed) && /<\/[a-zA-Z]/.test(trimmed)) continue;
|
|
2384
|
+
if (isNarrativeKorean(trimmed)) continue;
|
|
2382
2385
|
const correction = detectCorrection(text);
|
|
2383
2386
|
if (correction) {
|
|
2384
2387
|
corrections.push(correction);
|
|
@@ -2386,12 +2389,43 @@ function extractCorrections(messages) {
|
|
|
2386
2389
|
}
|
|
2387
2390
|
return corrections;
|
|
2388
2391
|
}
|
|
2392
|
+
function isNarrativeKorean(text) {
|
|
2393
|
+
const NARRATIVE_MARKERS = [
|
|
2394
|
+
/이유는/,
|
|
2395
|
+
// "the reason is..."
|
|
2396
|
+
/예를\s*들면/,
|
|
2397
|
+
// "for example..."
|
|
2398
|
+
/그래서/,
|
|
2399
|
+
// "so/therefore..."
|
|
2400
|
+
/그런데/,
|
|
2401
|
+
// "but then..."
|
|
2402
|
+
/왜냐하면/,
|
|
2403
|
+
// "because..."
|
|
2404
|
+
/거든/,
|
|
2405
|
+
// "...you see" (explanatory)
|
|
2406
|
+
/있었[던거어]/,
|
|
2407
|
+
// "there was..." (past narrative)
|
|
2408
|
+
/중인데/,
|
|
2409
|
+
// "...in the middle of" (ongoing situation)
|
|
2410
|
+
/거 같은데/,
|
|
2411
|
+
// "it seems like..." (speculation)
|
|
2412
|
+
/어떻게\s*생각/
|
|
2413
|
+
// "what do you think?" (asking opinion)
|
|
2414
|
+
];
|
|
2415
|
+
const markerCount = NARRATIVE_MARKERS.filter((p) => p.test(text)).length;
|
|
2416
|
+
return markerCount >= 2;
|
|
2417
|
+
}
|
|
2389
2418
|
function detectCorrection(text) {
|
|
2390
2419
|
const isNegation = NEGATION_PATTERNS.some((p) => p.test(text));
|
|
2391
2420
|
const isMust = MUST_PATTERNS.some((p) => p.test(text));
|
|
2392
2421
|
const isWarn = WARN_PATTERNS.some((p) => p.test(text));
|
|
2393
2422
|
const isAffirmation = AFFIRMATION_PATTERNS.some((p) => p.test(text));
|
|
2394
2423
|
if (!isNegation && !isMust && !isWarn && !isAffirmation) return null;
|
|
2424
|
+
const categories = [isNegation, isMust, isWarn, isAffirmation].filter(Boolean).length;
|
|
2425
|
+
const koreanRatio = (text.match(/[\uAC00-\uD7AF]/g) || []).length / Math.max(text.length, 1);
|
|
2426
|
+
if (koreanRatio > 0.3 && categories < 2) {
|
|
2427
|
+
if (text.length > 100) return null;
|
|
2428
|
+
}
|
|
2395
2429
|
let prefix;
|
|
2396
2430
|
if (isNegation) prefix = "NO";
|
|
2397
2431
|
else if (isMust) prefix = "MUST";
|
|
@@ -2590,24 +2624,21 @@ var init_digest = __esm({
|
|
|
2590
2624
|
/\bnever\b/i,
|
|
2591
2625
|
/\binstead\b/i,
|
|
2592
2626
|
/^no[,.\s!]/i,
|
|
2593
|
-
/\bdon[''\u2019]?t\s+use\b/i,
|
|
2594
2627
|
/\bavoid\b/i,
|
|
2595
|
-
// Korean negation —
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
/쓰지\s*않/
|
|
2603
|
-
// "do not use" specifically
|
|
2628
|
+
// Korean negation — require AI-directed imperative context:
|
|
2629
|
+
// "X하지 마" (don't X) — must have a verb object before 지 마
|
|
2630
|
+
/[을를은는도이가]\s*[가-힣]+지\s*마/,
|
|
2631
|
+
// "X 하면 안 돼" (must not X) — conditional + prohibition
|
|
2632
|
+
/하면\s*안\s*돼/,
|
|
2633
|
+
// "X 쓰지 마" (don't use X) — explicit "don't use"
|
|
2634
|
+
/쓰지\s*마/
|
|
2604
2635
|
];
|
|
2605
2636
|
AFFIRMATION_PATTERNS = [
|
|
2606
|
-
/\balways\b/i,
|
|
2607
2637
|
/\bshould\s+always\b/i,
|
|
2608
2638
|
/\buse\s+\w+\s+instead\b/i,
|
|
2609
|
-
// Korean affirmation
|
|
2610
|
-
|
|
2639
|
+
// Korean affirmation — require directive context
|
|
2640
|
+
/항상\s*[가-힣]+[해하]/
|
|
2641
|
+
// "항상 X해" (always do X)
|
|
2611
2642
|
];
|
|
2612
2643
|
MUST_PATTERNS = [
|
|
2613
2644
|
/\bmust\b/i,
|