pi-continuous-learning 0.6.0 → 0.8.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 +78 -0
- package/dist/agents-md.d.ts +23 -2
- package/dist/agents-md.d.ts.map +1 -1
- package/dist/agents-md.js +58 -3
- package/dist/agents-md.js.map +1 -1
- package/dist/analysis-event-log.d.ts +50 -0
- package/dist/analysis-event-log.d.ts.map +1 -0
- package/dist/analysis-event-log.js +120 -0
- package/dist/analysis-event-log.js.map +1 -0
- package/dist/analysis-notification.d.ts +20 -0
- package/dist/analysis-notification.d.ts.map +1 -0
- package/dist/analysis-notification.js +63 -0
- package/dist/analysis-notification.js.map +1 -0
- package/dist/cli/analyze-single-shot.d.ts +20 -2
- package/dist/cli/analyze-single-shot.d.ts.map +1 -1
- package/dist/cli/analyze-single-shot.js +109 -5
- package/dist/cli/analyze-single-shot.js.map +1 -1
- package/dist/cli/analyze.js +132 -16
- package/dist/cli/analyze.js.map +1 -1
- package/dist/command-scaffold.d.ts +25 -0
- package/dist/command-scaffold.d.ts.map +1 -0
- package/dist/command-scaffold.js +77 -0
- package/dist/command-scaffold.js.map +1 -0
- package/dist/confidence.d.ts +12 -1
- package/dist/confidence.d.ts.map +1 -1
- package/dist/confidence.js +37 -9
- package/dist/confidence.js.map +1 -1
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +31 -0
- package/dist/config.js.map +1 -1
- package/dist/graduation.d.ts +63 -0
- package/dist/graduation.d.ts.map +1 -0
- package/dist/graduation.js +155 -0
- package/dist/graduation.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/instinct-cleanup.d.ts +57 -0
- package/dist/instinct-cleanup.d.ts.map +1 -0
- package/dist/instinct-cleanup.js +150 -0
- package/dist/instinct-cleanup.js.map +1 -0
- package/dist/instinct-graduate.d.ts +43 -0
- package/dist/instinct-graduate.d.ts.map +1 -0
- package/dist/instinct-graduate.js +253 -0
- package/dist/instinct-graduate.js.map +1 -0
- package/dist/instinct-parser.d.ts.map +1 -1
- package/dist/instinct-parser.js +18 -0
- package/dist/instinct-parser.js.map +1 -1
- package/dist/instinct-tools.d.ts.map +1 -1
- package/dist/instinct-tools.js +19 -0
- package/dist/instinct-tools.js.map +1 -1
- package/dist/instinct-validator.d.ts +61 -0
- package/dist/instinct-validator.d.ts.map +1 -0
- package/dist/instinct-validator.js +235 -0
- package/dist/instinct-validator.js.map +1 -0
- package/dist/observation-signal.d.ts +34 -0
- package/dist/observation-signal.d.ts.map +1 -0
- package/dist/observation-signal.js +66 -0
- package/dist/observation-signal.js.map +1 -0
- package/dist/prompts/analyzer-system-single-shot.d.ts.map +1 -1
- package/dist/prompts/analyzer-system-single-shot.js +82 -3
- package/dist/prompts/analyzer-system-single-shot.js.map +1 -1
- package/dist/prompts/analyzer-user-single-shot.d.ts.map +1 -1
- package/dist/prompts/analyzer-user-single-shot.js +5 -3
- package/dist/prompts/analyzer-user-single-shot.js.map +1 -1
- package/dist/skill-scaffold.d.ts +23 -0
- package/dist/skill-scaffold.d.ts.map +1 -0
- package/dist/skill-scaffold.js +62 -0
- package/dist/skill-scaffold.js.map +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agents-md.ts +73 -3
- package/src/analysis-event-log.ts +171 -0
- package/src/analysis-notification.ts +79 -0
- package/src/cli/analyze-single-shot.ts +131 -5
- package/src/cli/analyze.ts +157 -15
- package/src/command-scaffold.ts +105 -0
- package/src/confidence.ts +35 -8
- package/src/config.ts +40 -0
- package/src/graduation.ts +243 -0
- package/src/index.ts +16 -0
- package/src/instinct-cleanup.ts +204 -0
- package/src/instinct-graduate.ts +377 -0
- package/src/instinct-parser.ts +18 -0
- package/src/instinct-tools.ts +26 -0
- package/src/instinct-validator.ts +287 -0
- package/src/observation-signal.ts +80 -0
- package/src/prompts/analyzer-system-single-shot.ts +82 -3
- package/src/prompts/analyzer-user-single-shot.ts +11 -2
- package/src/skill-scaffold.ts +90 -0
- package/src/types.ts +11 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instinct-tools.js","sourceRoot":"","sources":["../src/instinct-tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAEtB,SAAS,eAAe,CACtB,KAA2B,EAC3B,SAAwB,EACxB,OAAgB;IAEhB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnF,CAAC;IACD,OAAO,qBAAqB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,gBAAgB,CACvB,EAAU,EACV,SAAwB,EACxB,OAAgB;IAEhB,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,OAAO,GAAG,sBAAsB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3C,IAAI,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IACxE,CAAC;I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AAY,CAAC,EAAE,GAAG,uBAAuB,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC,CAAC;AACjH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instinct validation and semantic deduplication.
|
|
3
|
+
* Rejects instincts with empty, undefined, nonsense, or low-quality fields,
|
|
4
|
+
* and detects near-duplicate instincts via Jaccard similarity.
|
|
5
|
+
*/
|
|
6
|
+
import type { Instinct } from "./types.js";
|
|
7
|
+
export declare const KNOWN_DOMAINS: Set<string>;
|
|
8
|
+
/** Common imperative verbs expected at the start of an instinct action. */
|
|
9
|
+
export declare const KNOWN_VERBS: Set<string>;
|
|
10
|
+
export interface ValidationResult {
|
|
11
|
+
valid: boolean;
|
|
12
|
+
reason?: string;
|
|
13
|
+
/** Non-fatal warnings that indicate lower-quality instincts. */
|
|
14
|
+
warnings?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Validates that an instinct's fields meet quality requirements.
|
|
18
|
+
*
|
|
19
|
+
* Rules:
|
|
20
|
+
* - action and trigger must be non-empty, non-null, non-"undefined", and >= 10 chars
|
|
21
|
+
* - action first word should be a known imperative verb (warning if not)
|
|
22
|
+
* - domain, if provided, must be in KNOWN_DOMAINS (with "other" as escape hatch)
|
|
23
|
+
*
|
|
24
|
+
* Returns { valid: true } or { valid: false, reason: "..." }.
|
|
25
|
+
* Non-fatal issues are reported in the optional `warnings` array.
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateInstinct(fields: {
|
|
28
|
+
action: unknown;
|
|
29
|
+
trigger: unknown;
|
|
30
|
+
domain?: unknown;
|
|
31
|
+
}): ValidationResult;
|
|
32
|
+
/**
|
|
33
|
+
* Tokenizes text into a set of meaningful lowercase words.
|
|
34
|
+
* Splits on non-alphanumeric characters and filters stop words and short tokens.
|
|
35
|
+
*/
|
|
36
|
+
export declare function tokenize(text: string): Set<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Computes Jaccard similarity between two token sets.
|
|
39
|
+
* Returns 1.0 for two empty sets, 0.0 if one is empty.
|
|
40
|
+
*/
|
|
41
|
+
export declare function jaccardSimilarity(a: Set<string>, b: Set<string>): number;
|
|
42
|
+
export interface SimilarityMatch {
|
|
43
|
+
instinct: Instinct;
|
|
44
|
+
similarity: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Checks whether a candidate instinct is semantically similar to any existing instinct.
|
|
48
|
+
*
|
|
49
|
+
* Tokenizes trigger+action for both candidate and each existing instinct,
|
|
50
|
+
* computes Jaccard similarity, and returns the closest match above the threshold.
|
|
51
|
+
*
|
|
52
|
+
* @param candidate - The new instinct being considered (trigger + action)
|
|
53
|
+
* @param existing - All current instincts to check against
|
|
54
|
+
* @param skipId - ID to skip (the candidate's own ID on updates)
|
|
55
|
+
* @param threshold - Similarity threshold; default 0.6
|
|
56
|
+
*/
|
|
57
|
+
export declare function findSimilarInstinct(candidate: {
|
|
58
|
+
trigger: string;
|
|
59
|
+
action: string;
|
|
60
|
+
}, existing: Instinct[], skipId?: string, threshold?: number): SimilarityMatch | null;
|
|
61
|
+
//# sourceMappingURL=instinct-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instinct-validator.d.ts","sourceRoot":"","sources":["../src/instinct-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAS3C,eAAO,MAAM,aAAa,aAqBxB,CAAC;AAMH,2EAA2E;AAC3E,eAAO,MAAM,WAAW,aAwEtB,CAAC;AAMH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AA2BD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GAAG,gBAAgB,CAiCnB;AAeD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAOlD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAWxE;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC9C,QAAQ,EAAE,QAAQ,EAAE,EACpB,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,SAAM,GACd,eAAe,GAAG,IAAI,CAmBxB"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instinct validation and semantic deduplication.
|
|
3
|
+
* Rejects instincts with empty, undefined, nonsense, or low-quality fields,
|
|
4
|
+
* and detects near-duplicate instincts via Jaccard similarity.
|
|
5
|
+
*/
|
|
6
|
+
const MIN_FIELD_LENGTH = 10;
|
|
7
|
+
const INVALID_LITERALS = new Set(["undefined", "null", "none", ""]);
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Known domains (with "other" as escape hatch)
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
export const KNOWN_DOMAINS = new Set([
|
|
12
|
+
"git",
|
|
13
|
+
"testing",
|
|
14
|
+
"debugging",
|
|
15
|
+
"workflow",
|
|
16
|
+
"typescript",
|
|
17
|
+
"javascript",
|
|
18
|
+
"python",
|
|
19
|
+
"go",
|
|
20
|
+
"css",
|
|
21
|
+
"design",
|
|
22
|
+
"security",
|
|
23
|
+
"performance",
|
|
24
|
+
"documentation",
|
|
25
|
+
"react",
|
|
26
|
+
"node",
|
|
27
|
+
"database",
|
|
28
|
+
"api",
|
|
29
|
+
"devops",
|
|
30
|
+
"architecture",
|
|
31
|
+
"other",
|
|
32
|
+
]);
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Verb heuristic for action field
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
/** Common imperative verbs expected at the start of an instinct action. */
|
|
37
|
+
export const KNOWN_VERBS = new Set([
|
|
38
|
+
"add",
|
|
39
|
+
"always",
|
|
40
|
+
"analyze",
|
|
41
|
+
"apply",
|
|
42
|
+
"ask",
|
|
43
|
+
"avoid",
|
|
44
|
+
"build",
|
|
45
|
+
"call",
|
|
46
|
+
"catch",
|
|
47
|
+
"check",
|
|
48
|
+
"clean",
|
|
49
|
+
"confirm",
|
|
50
|
+
"consider",
|
|
51
|
+
"create",
|
|
52
|
+
"define",
|
|
53
|
+
"delete",
|
|
54
|
+
"document",
|
|
55
|
+
"emit",
|
|
56
|
+
"ensure",
|
|
57
|
+
"exclude",
|
|
58
|
+
"export",
|
|
59
|
+
"extract",
|
|
60
|
+
"fetch",
|
|
61
|
+
"find",
|
|
62
|
+
"fix",
|
|
63
|
+
"follow",
|
|
64
|
+
"format",
|
|
65
|
+
"generate",
|
|
66
|
+
"get",
|
|
67
|
+
"handle",
|
|
68
|
+
"import",
|
|
69
|
+
"include",
|
|
70
|
+
"inspect",
|
|
71
|
+
"load",
|
|
72
|
+
"log",
|
|
73
|
+
"look",
|
|
74
|
+
"merge",
|
|
75
|
+
"monitor",
|
|
76
|
+
"move",
|
|
77
|
+
"never",
|
|
78
|
+
"parse",
|
|
79
|
+
"pass",
|
|
80
|
+
"prefer",
|
|
81
|
+
"print",
|
|
82
|
+
"read",
|
|
83
|
+
"record",
|
|
84
|
+
"refactor",
|
|
85
|
+
"reject",
|
|
86
|
+
"rename",
|
|
87
|
+
"require",
|
|
88
|
+
"resolve",
|
|
89
|
+
"return",
|
|
90
|
+
"run",
|
|
91
|
+
"save",
|
|
92
|
+
"scan",
|
|
93
|
+
"search",
|
|
94
|
+
"send",
|
|
95
|
+
"set",
|
|
96
|
+
"show",
|
|
97
|
+
"skip",
|
|
98
|
+
"start",
|
|
99
|
+
"stop",
|
|
100
|
+
"test",
|
|
101
|
+
"track",
|
|
102
|
+
"update",
|
|
103
|
+
"use",
|
|
104
|
+
"validate",
|
|
105
|
+
"verify",
|
|
106
|
+
"watch",
|
|
107
|
+
"wrap",
|
|
108
|
+
"write",
|
|
109
|
+
]);
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
// Internal helpers
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
function isInvalidField(value, fieldName) {
|
|
114
|
+
if (value === undefined || value === null) {
|
|
115
|
+
return `${fieldName} is ${String(value)}`;
|
|
116
|
+
}
|
|
117
|
+
if (typeof value !== "string") {
|
|
118
|
+
return `${fieldName} is not a string (got ${typeof value})`;
|
|
119
|
+
}
|
|
120
|
+
const trimmed = value.trim();
|
|
121
|
+
if (INVALID_LITERALS.has(trimmed.toLowerCase())) {
|
|
122
|
+
return `${fieldName} is the literal string "${trimmed}"`;
|
|
123
|
+
}
|
|
124
|
+
if (trimmed.length < MIN_FIELD_LENGTH) {
|
|
125
|
+
return `${fieldName} is too short (${trimmed.length} chars, minimum ${MIN_FIELD_LENGTH})`;
|
|
126
|
+
}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
// ---------------------------------------------------------------------------
|
|
130
|
+
// validateInstinct
|
|
131
|
+
// ---------------------------------------------------------------------------
|
|
132
|
+
/**
|
|
133
|
+
* Validates that an instinct's fields meet quality requirements.
|
|
134
|
+
*
|
|
135
|
+
* Rules:
|
|
136
|
+
* - action and trigger must be non-empty, non-null, non-"undefined", and >= 10 chars
|
|
137
|
+
* - action first word should be a known imperative verb (warning if not)
|
|
138
|
+
* - domain, if provided, must be in KNOWN_DOMAINS (with "other" as escape hatch)
|
|
139
|
+
*
|
|
140
|
+
* Returns { valid: true } or { valid: false, reason: "..." }.
|
|
141
|
+
* Non-fatal issues are reported in the optional `warnings` array.
|
|
142
|
+
*/
|
|
143
|
+
export function validateInstinct(fields) {
|
|
144
|
+
const actionError = isInvalidField(fields.action, "action");
|
|
145
|
+
if (actionError) {
|
|
146
|
+
return { valid: false, reason: actionError };
|
|
147
|
+
}
|
|
148
|
+
const triggerError = isInvalidField(fields.trigger, "trigger");
|
|
149
|
+
if (triggerError) {
|
|
150
|
+
return { valid: false, reason: triggerError };
|
|
151
|
+
}
|
|
152
|
+
const warnings = [];
|
|
153
|
+
// Domain validation
|
|
154
|
+
if (fields.domain !== undefined) {
|
|
155
|
+
if (typeof fields.domain !== "string" || !KNOWN_DOMAINS.has(fields.domain.toLowerCase().trim())) {
|
|
156
|
+
return {
|
|
157
|
+
valid: false,
|
|
158
|
+
reason: `domain "${String(fields.domain)}" is not in the known set. Use one of: ${[...KNOWN_DOMAINS].join(", ")}`,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Verb heuristic (warning only - does not reject)
|
|
163
|
+
const action = fields.action.trim();
|
|
164
|
+
const firstWord = action.split(/\s+/)[0]?.toLowerCase() ?? "";
|
|
165
|
+
if (firstWord && !KNOWN_VERBS.has(firstWord)) {
|
|
166
|
+
warnings.push(`action should start with an imperative verb (got "${firstWord}"). Consider rewriting as a clear instruction.`);
|
|
167
|
+
}
|
|
168
|
+
return warnings.length > 0 ? { valid: true, warnings } : { valid: true };
|
|
169
|
+
}
|
|
170
|
+
// ---------------------------------------------------------------------------
|
|
171
|
+
// Jaccard similarity deduplication
|
|
172
|
+
// ---------------------------------------------------------------------------
|
|
173
|
+
const STOP_WORDS = new Set([
|
|
174
|
+
"a", "an", "the", "is", "are", "was", "were", "be", "been", "being",
|
|
175
|
+
"have", "has", "had", "do", "does", "did", "will", "would", "should",
|
|
176
|
+
"could", "may", "might", "shall", "can", "of", "in", "on", "at", "to",
|
|
177
|
+
"for", "with", "by", "from", "up", "about", "into", "it", "its", "this",
|
|
178
|
+
"that", "these", "those", "and", "or", "but", "if", "as", "when", "where",
|
|
179
|
+
"how", "what", "which", "who", "not", "no", "so",
|
|
180
|
+
]);
|
|
181
|
+
/**
|
|
182
|
+
* Tokenizes text into a set of meaningful lowercase words.
|
|
183
|
+
* Splits on non-alphanumeric characters and filters stop words and short tokens.
|
|
184
|
+
*/
|
|
185
|
+
export function tokenize(text) {
|
|
186
|
+
return new Set(text
|
|
187
|
+
.toLowerCase()
|
|
188
|
+
.split(/[^a-z0-9]+/)
|
|
189
|
+
.filter((t) => t.length > 2 && !STOP_WORDS.has(t)));
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Computes Jaccard similarity between two token sets.
|
|
193
|
+
* Returns 1.0 for two empty sets, 0.0 if one is empty.
|
|
194
|
+
*/
|
|
195
|
+
export function jaccardSimilarity(a, b) {
|
|
196
|
+
if (a.size === 0 && b.size === 0)
|
|
197
|
+
return 1.0;
|
|
198
|
+
if (a.size === 0 || b.size === 0)
|
|
199
|
+
return 0.0;
|
|
200
|
+
let intersection = 0;
|
|
201
|
+
for (const token of a) {
|
|
202
|
+
if (b.has(token))
|
|
203
|
+
intersection++;
|
|
204
|
+
}
|
|
205
|
+
const union = a.size + b.size - intersection;
|
|
206
|
+
return intersection / union;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Checks whether a candidate instinct is semantically similar to any existing instinct.
|
|
210
|
+
*
|
|
211
|
+
* Tokenizes trigger+action for both candidate and each existing instinct,
|
|
212
|
+
* computes Jaccard similarity, and returns the closest match above the threshold.
|
|
213
|
+
*
|
|
214
|
+
* @param candidate - The new instinct being considered (trigger + action)
|
|
215
|
+
* @param existing - All current instincts to check against
|
|
216
|
+
* @param skipId - ID to skip (the candidate's own ID on updates)
|
|
217
|
+
* @param threshold - Similarity threshold; default 0.6
|
|
218
|
+
*/
|
|
219
|
+
export function findSimilarInstinct(candidate, existing, skipId, threshold = 0.6) {
|
|
220
|
+
const candidateTokens = tokenize(`${candidate.trigger} ${candidate.action}`);
|
|
221
|
+
let bestMatch = null;
|
|
222
|
+
for (const instinct of existing) {
|
|
223
|
+
if (instinct.id === skipId)
|
|
224
|
+
continue;
|
|
225
|
+
const existingTokens = tokenize(`${instinct.trigger} ${instinct.action}`);
|
|
226
|
+
const similarity = jaccardSimilarity(candidateTokens, existingTokens);
|
|
227
|
+
if (similarity >= threshold) {
|
|
228
|
+
if (bestMatch === null || similarity > bestMatch.similarity) {
|
|
229
|
+
bestMatch = { instinct, similarity };
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return bestMatch;
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=instinct-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instinct-validator.js","sourceRoot":"","sources":["../src/instinct-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpE,8EAA8E;AAC9E,+CAA+C;AAC/C,8EAA8E;AAE9E,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IACnC,KAAK;IACL,SAAS;IACT,WAAW;IACX,UAAU;IACV,YAAY;IACZ,YAAY;IACZ,QAAQ;IACR,IAAI;IACJ,KAAK;IACL,QAAQ;IACR,UAAU;IACV,aAAa;IACb,eAAe;IACf,OAAO;IACP,MAAM;IACN,UAAU;IACV,KAAK;IACL,QAAQ;IACR,cAAc;IACd,OAAO;CACR,CAAC,CAAC;AAEH,8EAA8E;AA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AC,OAAO,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IAE7E,IAAI,SAAS,GAA2B,IAAI,CAAC;IAE7C,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;QAChC,IAAI,QAAQ,CAAC,EAAE,KAAK,MAAM;YAAE,SAAS;QAErC,MAAM,cAAc,GAAG,QAAQ,CAAC,GAAG,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1E,MAAM,UAAU,GAAG,iBAAiB,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;QAEtE,IAAI,UAAU,IAAI,SAAS,EAAE,CAAC;YAC5B,IAAI,SAAS,KAAK,IAAI,IAAI,UAAU,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;gBAC5D,SAAS,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observation batch signal scoring.
|
|
3
|
+
* Determines whether a batch of observations contains enough signal
|
|
4
|
+
* to warrant running the analyzer (and spending tokens).
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Score threshold below which a batch is considered low-signal.
|
|
8
|
+
* Batches scoring below this are skipped with a log entry.
|
|
9
|
+
*/
|
|
10
|
+
export declare const LOW_SIGNAL_THRESHOLD = 3;
|
|
11
|
+
interface ScoreResult {
|
|
12
|
+
readonly score: number;
|
|
13
|
+
readonly errors: number;
|
|
14
|
+
readonly corrections: number;
|
|
15
|
+
readonly userPrompts: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Scores an observation batch for signal richness.
|
|
19
|
+
*
|
|
20
|
+
* Scoring rules:
|
|
21
|
+
* - Error observation (is_error: true): +2 points
|
|
22
|
+
* - user_prompt after an error (user correction): +3 points
|
|
23
|
+
* - Other user_prompt events (potential corrections/redirections): +1 point
|
|
24
|
+
*
|
|
25
|
+
* @param lines - Raw JSONL observation lines (preprocessed or raw)
|
|
26
|
+
* @returns Score result with breakdown
|
|
27
|
+
*/
|
|
28
|
+
export declare function scoreObservationBatch(lines: string[]): ScoreResult;
|
|
29
|
+
/**
|
|
30
|
+
* Returns true if the batch is low-signal and analysis should be skipped.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isLowSignalBatch(lines: string[]): boolean;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=observation-signal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observation-signal.d.ts","sourceRoot":"","sources":["../src/observation-signal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,UAAU,WAAW;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,WAAW,CAuClE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAGzD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observation batch signal scoring.
|
|
3
|
+
* Determines whether a batch of observations contains enough signal
|
|
4
|
+
* to warrant running the analyzer (and spending tokens).
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Score threshold below which a batch is considered low-signal.
|
|
8
|
+
* Batches scoring below this are skipped with a log entry.
|
|
9
|
+
*/
|
|
10
|
+
export const LOW_SIGNAL_THRESHOLD = 3;
|
|
11
|
+
/**
|
|
12
|
+
* Scores an observation batch for signal richness.
|
|
13
|
+
*
|
|
14
|
+
* Scoring rules:
|
|
15
|
+
* - Error observation (is_error: true): +2 points
|
|
16
|
+
* - user_prompt after an error (user correction): +3 points
|
|
17
|
+
* - Other user_prompt events (potential corrections/redirections): +1 point
|
|
18
|
+
*
|
|
19
|
+
* @param lines - Raw JSONL observation lines (preprocessed or raw)
|
|
20
|
+
* @returns Score result with breakdown
|
|
21
|
+
*/
|
|
22
|
+
export function scoreObservationBatch(lines) {
|
|
23
|
+
let score = 0;
|
|
24
|
+
let errors = 0;
|
|
25
|
+
let corrections = 0;
|
|
26
|
+
let userPrompts = 0;
|
|
27
|
+
let lastWasError = false;
|
|
28
|
+
for (const line of lines) {
|
|
29
|
+
const trimmed = line.trim();
|
|
30
|
+
if (!trimmed)
|
|
31
|
+
continue;
|
|
32
|
+
let obs;
|
|
33
|
+
try {
|
|
34
|
+
obs = JSON.parse(trimmed);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
continue; // Skip malformed lines
|
|
38
|
+
}
|
|
39
|
+
if (obs.is_error) {
|
|
40
|
+
score += 2;
|
|
41
|
+
errors++;
|
|
42
|
+
lastWasError = true;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (obs.event === "user_prompt") {
|
|
46
|
+
userPrompts++;
|
|
47
|
+
if (lastWasError) {
|
|
48
|
+
score += 3;
|
|
49
|
+
corrections++;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
score += 1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
lastWasError = false;
|
|
56
|
+
}
|
|
57
|
+
return { score, errors, corrections, userPrompts };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns true if the batch is low-signal and analysis should be skipped.
|
|
61
|
+
*/
|
|
62
|
+
export function isLowSignalBatch(lines) {
|
|
63
|
+
const { score } = scoreObservationBatch(lines);
|
|
64
|
+
return score < LOW_SIGNAL_THRESHOLD;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=observation-signal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observation-signal.js","sourceRoot":"","sources":["../src/observation-signal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAStC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAe;IACnD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,YAAY,GAAG,KAAK,CAAC;IAEzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO;YAAE,SAAS;QAEvB,IAAI,GAAyB,CAAC;QAC9B,IAAI,CAAC;YACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAyB,CAAC;QACpD,CAAC;QAAC,MAAM,CAAC;YACP,SAAS,CAAC,uBAAuB;QACnC,CAAC;QAED,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YACjB,KAAK,IAAI,CAAC,CAAC;YACX,MAAM,EAAE,CAAC;YACT,YAAY,GAAG,IAAI,CAAC;YACpB,SAAS;QACX,CAAC;QAED,IAAI,GAAG,CAAC,KAAK,KAAK,aAAa,EAAE,CAAC;YAChC,WAAW,EAAE,CAAC;YACd,IAAI,YAAY,EAAE,CAAC;gBACjB,KAAK,IAAI,CAAC,CAAC;gBACX,WAAW,EAAE,CAAC;YAChB,CAAC;iBAAM,CAAC;gBACN,KAAK,IAAI,CAAC,CAAC;YACb,CAAC;QACH,CAAC;QAED,YAAY,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAe;IAC9C,MAAM,EAAE,KAAK,EAAE,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,KAAK,GAAG,oBAAoB,CAAC;AACtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer-system-single-shot.d.ts","sourceRoot":"","sources":["../../src/prompts/analyzer-system-single-shot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"analyzer-system-single-shot.d.ts","sourceRoot":"","sources":["../../src/prompts/analyzer-system-single-shot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAqMpD"}
|
|
@@ -88,11 +88,50 @@ Each observation may include an active_instincts field listing instinct IDs
|
|
|
88
88
|
that were injected into the agent's system prompt before that turn.
|
|
89
89
|
|
|
90
90
|
Use this to update existing instinct confidence scores:
|
|
91
|
-
- Confirmed
|
|
91
|
+
- Confirmed: instinct was active, agent followed guidance, user did NOT correct
|
|
92
92
|
- Contradicted (-0.15): instinct was active but user corrected the agent
|
|
93
93
|
- Inactive (no change): instinct was injected but trigger never arose
|
|
94
94
|
|
|
95
|
-
When updating, increment the corresponding count field
|
|
95
|
+
When updating, increment the corresponding count field.
|
|
96
|
+
|
|
97
|
+
### Confirmation confidence deltas (diminishing returns)
|
|
98
|
+
Do NOT apply a flat +0.05 for every confirmation. Use these tiers based on the
|
|
99
|
+
instinct's current confirmed_count BEFORE this update:
|
|
100
|
+
- 1st-3rd confirmation (confirmed_count 0-2): +0.05
|
|
101
|
+
- 4th-6th confirmation (confirmed_count 3-5): +0.03
|
|
102
|
+
- 7th+ confirmation (confirmed_count 6+): +0.01
|
|
103
|
+
|
|
104
|
+
Note: the client applies these deltas automatically from confirmed_count.
|
|
105
|
+
You should still set the correct confirmed_count so the client can compute it.
|
|
106
|
+
|
|
107
|
+
### Per-session confirmation deduplication
|
|
108
|
+
An instinct may only be confirmed ONCE per unique session_id. Each existing
|
|
109
|
+
instinct includes a last_confirmed_session field (if it has been confirmed before).
|
|
110
|
+
|
|
111
|
+
Rules:
|
|
112
|
+
- If all observations showing this instinct active belong to the same session as
|
|
113
|
+
last_confirmed_session, do NOT increment confirmed_count. The instinct already
|
|
114
|
+
received credit for that session.
|
|
115
|
+
- If a NEW session_id (different from last_confirmed_session) shows the instinct
|
|
116
|
+
active and followed, increment confirmed_count by 1 and set last_confirmed_session
|
|
117
|
+
to that new session_id.
|
|
118
|
+
- When creating a new instinct with initial confirmed_count > 0, set
|
|
119
|
+
last_confirmed_session to the session_id that provided the confirmation.
|
|
120
|
+
|
|
121
|
+
### Baseline behavior filtering
|
|
122
|
+
Do NOT mark an instinct as "confirmed" if the agent's behavior would be expected
|
|
123
|
+
baseline practice regardless of whether the instinct was injected.
|
|
124
|
+
|
|
125
|
+
Examples of baseline behavior that should NOT count as confirmation:
|
|
126
|
+
- Reading a file before editing it
|
|
127
|
+
- Running a linter or type-checker after code changes
|
|
128
|
+
- Using conventional commit message format
|
|
129
|
+
- Checking for errors after tool calls
|
|
130
|
+
- Clarifying ambiguous requirements before starting
|
|
131
|
+
|
|
132
|
+
Only count a confirmation when the instinct guided behavior that would plausibly
|
|
133
|
+
NOT have occurred without it (e.g., a project-specific workflow, a non-obvious
|
|
134
|
+
convention, or a recovery pattern the agent had to learn).
|
|
96
135
|
|
|
97
136
|
## Confidence Scoring Rules
|
|
98
137
|
|
|
@@ -119,6 +158,46 @@ When in doubt, prefer project scope.
|
|
|
119
158
|
4. New instincts from observation data alone are capped at 0.85 confidence.
|
|
120
159
|
5. Check existing instincts (provided in the user message) for duplicates before creating. Update instead.
|
|
121
160
|
6. Write actions as clear instructions starting with a verb.
|
|
122
|
-
7. Be skeptical of outliers - patterns seen only in unusual circumstances should not become instincts
|
|
161
|
+
7. Be skeptical of outliers - patterns seen only in unusual circumstances should not become instincts.
|
|
162
|
+
|
|
163
|
+
## Quality Tiers
|
|
164
|
+
|
|
165
|
+
Not all patterns are worth recording as instincts. Use this classification before creating:
|
|
166
|
+
|
|
167
|
+
### Tier 1 - Project Conventions (RECORD as instinct)
|
|
168
|
+
Patterns specific to this project's tech stack, codebase conventions, or team practices.
|
|
169
|
+
Examples:
|
|
170
|
+
- "Use the Result<T, E> type for error handling in this project"
|
|
171
|
+
- "Place tests next to source files as *.test.ts"
|
|
172
|
+
- "Prefer functional style - avoid class-based patterns in this codebase"
|
|
173
|
+
|
|
174
|
+
### Tier 2 - Workflow Patterns (RECORD as global instinct)
|
|
175
|
+
Recurring multi-step workflows that apply across many projects.
|
|
176
|
+
Examples:
|
|
177
|
+
- "Run linter and type-checker after every code change"
|
|
178
|
+
- "Write tests before implementation in TDD projects"
|
|
179
|
+
|
|
180
|
+
### Tier 3 - Generic Agent Behavior (DO NOT RECORD - already known)
|
|
181
|
+
Fundamental behaviors all coding agents should follow. These are not project-specific patterns.
|
|
182
|
+
|
|
183
|
+
**DO NOT create instincts for:**
|
|
184
|
+
- Reading files before editing them ("read before edit")
|
|
185
|
+
- Grepping for context before modifying code
|
|
186
|
+
- Clarifying ambiguous requirements before starting
|
|
187
|
+
- Using conventional commit message formats
|
|
188
|
+
- Checking for errors after tool calls
|
|
189
|
+
- Any behavior that is basic good practice for any coding agent
|
|
190
|
+
|
|
191
|
+
These patterns belong in AGENTS.md from the start, not in learned instincts.
|
|
192
|
+
|
|
193
|
+
## AGENTS.md Deduplication
|
|
194
|
+
|
|
195
|
+
The user message includes the current AGENTS.md content for this project and globally.
|
|
196
|
+
Before creating any instinct, check: **is this pattern already covered by AGENTS.md?**
|
|
197
|
+
|
|
198
|
+
If yes: do NOT create an instinct. The pattern is already enforced.
|
|
199
|
+
If a pattern appears in AGENTS.md in the same form, skip it entirely.
|
|
200
|
+
|
|
201
|
+
Only create instincts for patterns that are genuinely absent from AGENTS.md.`;
|
|
123
202
|
}
|
|
124
203
|
//# sourceMappingURL=analyzer-system-single-shot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer-system-single-shot.js","sourceRoot":"","sources":["../../src/prompts/analyzer-system-single-shot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO
|
|
1
|
+
{"version":3,"file":"analyzer-system-single-shot.js","sourceRoot":"","sources":["../../src/prompts/analyzer-system-single-shot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6EAmMoE,CAAC;AAC9E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer-user-single-shot.d.ts","sourceRoot":"","sources":["../../src/prompts/analyzer-user-single-shot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG1E,MAAM,WAAW,uBAAuB;IACtC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,YAAY,EACrB,iBAAiB,EAAE,QAAQ,EAAE,EAC7B,gBAAgB,EAAE,MAAM,EAAE,EAC1B,OAAO,GAAE,uBAA4B,GACpC,MAAM,
|
|
1
|
+
{"version":3,"file":"analyzer-user-single-shot.d.ts","sourceRoot":"","sources":["../../src/prompts/analyzer-user-single-shot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG1E,MAAM,WAAW,uBAAuB;IACtC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,YAAY,EACrB,iBAAiB,EAAE,QAAQ,EAAE,EAC7B,gBAAgB,EAAE,MAAM,EAAE,EAC1B,OAAO,GAAE,uBAA4B,GACpC,MAAM,CAoER"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatInstinctsCompact } from "../cli/analyze-single-shot.js";
|
|
2
2
|
/**
|
|
3
3
|
* Builds the user prompt for the single-shot analyzer.
|
|
4
4
|
* Embeds all current instincts inline so the model has full context
|
|
@@ -14,7 +14,9 @@ export function buildSingleShotUserPrompt(project, existingInstincts, observatio
|
|
|
14
14
|
const observationBlock = observationLines.length > 0
|
|
15
15
|
? observationLines.join("\n")
|
|
16
16
|
: "(no observations recorded yet)";
|
|
17
|
-
const instinctBlock =
|
|
17
|
+
const instinctBlock = existingInstincts.length > 0
|
|
18
|
+
? formatInstinctsCompact(existingInstincts)
|
|
19
|
+
: "(no existing instincts)";
|
|
18
20
|
const parts = [
|
|
19
21
|
"## Project Context",
|
|
20
22
|
"",
|
|
@@ -47,7 +49,7 @@ export function buildSingleShotUserPrompt(project, existingInstincts, observatio
|
|
|
47
49
|
}
|
|
48
50
|
parts.push("");
|
|
49
51
|
}
|
|
50
|
-
parts.push("", "## Instructions", "", "1. Review the existing instincts above.", "2. Analyze the new observations for patterns per the system prompt rules.", "3. Return a JSON change-set: create new instincts, update existing ones, or delete obsolete ones.", "4. Apply feedback analysis using the active_instincts field in each observation.", "5. Passive confidence decay has already been applied before this analysis.", "", "Return ONLY the JSON object. No prose, no markdown fences.");
|
|
52
|
+
parts.push("", "## Instructions", "", "1. Review the existing instincts above.", "2. Analyze the new observations for patterns per the system prompt rules.", "3. Return a JSON change-set: create new instincts, update existing ones, or delete obsolete ones.", "4. Apply feedback analysis using the active_instincts field in each observation.", "5. Passive confidence decay has already been applied before this analysis.", "6. Before creating any instinct, check the Existing Guidelines section above.", " If the pattern is already covered by AGENTS.md, do NOT create an instinct for it.", "7. Apply the Quality Tier rules from the system prompt:", " - Generic agent behaviors (read-before-edit, clarify-before-implement) -> skip entirely", " - Project-specific patterns -> project-scoped instinct", " - Universal workflow patterns -> global-scoped instinct", "", "Return ONLY the JSON object. No prose, no markdown fences.");
|
|
51
53
|
return parts.join("\n");
|
|
52
54
|
}
|
|
53
55
|
//# sourceMappingURL=analyzer-user-single-shot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer-user-single-shot.js","sourceRoot":"","sources":["../../src/prompts/analyzer-user-single-shot.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"analyzer-user-single-shot.js","sourceRoot":"","sources":["../../src/prompts/analyzer-user-single-shot.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAQvE;;;;;;;;;GASG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAqB,EACrB,iBAA6B,EAC7B,gBAA0B,EAC1B,UAAmC,EAAE;IAErC,MAAM,EAAE,eAAe,GAAG,IAAI,EAAE,cAAc,GAAG,IAAI,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAExF,MAAM,gBAAgB,GACpB,gBAAgB,CAAC,MAAM,GAAG,CAAC;QACzB,CAAC,CAAC,gB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