hebbian 0.8.1 → 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 +60 -19
- 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/digest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../src/digest.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,YAAY;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IACtC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,UAAU,cAAc;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC,CAAC;KACpG,CAAC;IACF,aAAa,CAAC,EAAE;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CA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5E"}
|
package/dist/index.js
CHANGED
|
@@ -1762,24 +1762,21 @@ var NEGATION_PATTERNS = [
|
|
|
1762
1762
|
/\bnever\b/i,
|
|
1763
1763
|
/\binstead\b/i,
|
|
1764
1764
|
/^no[,.\s!]/i,
|
|
1765
|
-
/\bdon[''\u2019]?t\s+use\b/i,
|
|
1766
1765
|
/\bavoid\b/i,
|
|
1767
|
-
// Korean negation —
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
/쓰지\s*않/
|
|
1775
|
-
// "do not use" specifically
|
|
1766
|
+
// Korean negation — require AI-directed imperative context:
|
|
1767
|
+
// "X하지 마" (don't X) — must have a verb object before 지 마
|
|
1768
|
+
/[을를은는도이가]\s*[가-힣]+지\s*마/,
|
|
1769
|
+
// "X 하면 안 돼" (must not X) — conditional + prohibition
|
|
1770
|
+
/하면\s*안\s*돼/,
|
|
1771
|
+
// "X 쓰지 마" (don't use X) — explicit "don't use"
|
|
1772
|
+
/쓰지\s*마/
|
|
1776
1773
|
];
|
|
1777
1774
|
var AFFIRMATION_PATTERNS = [
|
|
1778
|
-
/\balways\b/i,
|
|
1779
1775
|
/\bshould\s+always\b/i,
|
|
1780
1776
|
/\buse\s+\w+\s+instead\b/i,
|
|
1781
|
-
// Korean affirmation
|
|
1782
|
-
|
|
1777
|
+
// Korean affirmation — require directive context
|
|
1778
|
+
/항상\s*[가-힣]+[해하]/
|
|
1779
|
+
// "항상 X해" (always do X)
|
|
1783
1780
|
];
|
|
1784
1781
|
var MUST_PATTERNS = [
|
|
1785
1782
|
/\bmust\b/i,
|
|
@@ -1998,12 +1995,15 @@ function extractCorrections(messages) {
|
|
|
1998
1995
|
const corrections = [];
|
|
1999
1996
|
for (const text of messages) {
|
|
2000
1997
|
if (corrections.length >= MAX_CORRECTIONS_PER_SESSION) break;
|
|
1998
|
+
const trimmed = text.trim();
|
|
2001
1999
|
if (text.length < MIN_CORRECTION_LENGTH) continue;
|
|
2002
|
-
if (/^[\/!]/.test(
|
|
2003
|
-
if (
|
|
2004
|
-
if (/^<[a-zA-Z]/.test(
|
|
2005
|
-
if (/^Base directory for this skill:/i.test(
|
|
2006
|
-
if (/^[•·▸▶\-\*]\s/.test(
|
|
2000
|
+
if (/^[\/!]/.test(trimmed)) continue;
|
|
2001
|
+
if (/[??]\s*[!!]?\s*$/.test(trimmed)) continue;
|
|
2002
|
+
if (/^<[a-zA-Z]/.test(trimmed)) continue;
|
|
2003
|
+
if (/^Base directory for this skill:/i.test(trimmed)) continue;
|
|
2004
|
+
if (/^[•·▸▶\-\*]\s/.test(trimmed)) continue;
|
|
2005
|
+
if (/<[a-zA-Z][a-zA-Z-]*>/.test(trimmed) && /<\/[a-zA-Z]/.test(trimmed)) continue;
|
|
2006
|
+
if (isNarrativeKorean(trimmed)) continue;
|
|
2007
2007
|
const correction = detectCorrection(text);
|
|
2008
2008
|
if (correction) {
|
|
2009
2009
|
corrections.push(correction);
|
|
@@ -2011,12 +2011,43 @@ function extractCorrections(messages) {
|
|
|
2011
2011
|
}
|
|
2012
2012
|
return corrections;
|
|
2013
2013
|
}
|
|
2014
|
+
function isNarrativeKorean(text) {
|
|
2015
|
+
const NARRATIVE_MARKERS = [
|
|
2016
|
+
/이유는/,
|
|
2017
|
+
// "the reason is..."
|
|
2018
|
+
/예를\s*들면/,
|
|
2019
|
+
// "for example..."
|
|
2020
|
+
/그래서/,
|
|
2021
|
+
// "so/therefore..."
|
|
2022
|
+
/그런데/,
|
|
2023
|
+
// "but then..."
|
|
2024
|
+
/왜냐하면/,
|
|
2025
|
+
// "because..."
|
|
2026
|
+
/거든/,
|
|
2027
|
+
// "...you see" (explanatory)
|
|
2028
|
+
/있었[던거어]/,
|
|
2029
|
+
// "there was..." (past narrative)
|
|
2030
|
+
/중인데/,
|
|
2031
|
+
// "...in the middle of" (ongoing situation)
|
|
2032
|
+
/거 같은데/,
|
|
2033
|
+
// "it seems like..." (speculation)
|
|
2034
|
+
/어떻게\s*생각/
|
|
2035
|
+
// "what do you think?" (asking opinion)
|
|
2036
|
+
];
|
|
2037
|
+
const markerCount = NARRATIVE_MARKERS.filter((p) => p.test(text)).length;
|
|
2038
|
+
return markerCount >= 2;
|
|
2039
|
+
}
|
|
2014
2040
|
function detectCorrection(text) {
|
|
2015
2041
|
const isNegation = NEGATION_PATTERNS.some((p) => p.test(text));
|
|
2016
2042
|
const isMust = MUST_PATTERNS.some((p) => p.test(text));
|
|
2017
2043
|
const isWarn = WARN_PATTERNS.some((p) => p.test(text));
|
|
2018
2044
|
const isAffirmation = AFFIRMATION_PATTERNS.some((p) => p.test(text));
|
|
2019
2045
|
if (!isNegation && !isMust && !isWarn && !isAffirmation) return null;
|
|
2046
|
+
const categories = [isNegation, isMust, isWarn, isAffirmation].filter(Boolean).length;
|
|
2047
|
+
const koreanRatio = (text.match(/[\uAC00-\uD7AF]/g) || []).length / Math.max(text.length, 1);
|
|
2048
|
+
if (koreanRatio > 0.3 && categories < 2) {
|
|
2049
|
+
if (text.length > 100) return null;
|
|
2050
|
+
}
|
|
2020
2051
|
let prefix;
|
|
2021
2052
|
if (isNegation) prefix = "NO";
|
|
2022
2053
|
else if (isMust) prefix = "MUST";
|