@davidorex/pi-behavior-monitors 0.12.0 → 0.14.1
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/agents/commit-hygiene-classifier.agent.yaml +11 -0
- package/agents/fragility-classifier.agent.yaml +11 -0
- package/agents/hedge-classifier.agent.yaml +11 -0
- package/agents/unauthorized-action-classifier.agent.yaml +11 -0
- package/agents/work-quality-classifier.agent.yaml +11 -0
- package/dist/index.d.ts +28 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +343 -132
- package/dist/index.js.map +1 -1
- package/examples/commit-hygiene/classify.md +4 -3
- package/examples/commit-hygiene.monitor.json +1 -3
- package/examples/fragility/classify.md +4 -6
- package/examples/fragility.monitor.json +1 -3
- package/examples/hedge/classify.md +17 -8
- package/examples/hedge.monitor.json +2 -4
- package/examples/unauthorized-action/classify.md +4 -3
- package/examples/unauthorized-action.monitor.json +1 -3
- package/examples/work-quality/classify.md +4 -5
- package/examples/work-quality.monitor.json +1 -3
- package/package.json +4 -2
- package/schemas/monitor.schema.json +3 -11
- package/schemas/verdict.schema.json +14 -0
- package/skills/pi-behavior-monitors/SKILL.md +5 -4
- package/skills/pi-behavior-monitors/references/bundled-resources.md +10 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name: commit-hygiene-classifier
|
|
2
|
+
role: sensor
|
|
3
|
+
description: Classifies whether agent committed changes with proper hygiene
|
|
4
|
+
model: claude-sonnet-4-6
|
|
5
|
+
thinking: "on"
|
|
6
|
+
output:
|
|
7
|
+
format: json
|
|
8
|
+
schema: ../schemas/verdict.schema.json
|
|
9
|
+
prompt:
|
|
10
|
+
task:
|
|
11
|
+
template: commit-hygiene/classify.md
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name: fragility-classifier
|
|
2
|
+
role: sensor
|
|
3
|
+
description: Classifies whether agent left unaddressed fragilities
|
|
4
|
+
model: claude-sonnet-4-6
|
|
5
|
+
thinking: "on"
|
|
6
|
+
output:
|
|
7
|
+
format: json
|
|
8
|
+
schema: ../schemas/verdict.schema.json
|
|
9
|
+
prompt:
|
|
10
|
+
task:
|
|
11
|
+
template: fragility/classify.md
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name: hedge-classifier
|
|
2
|
+
role: sensor
|
|
3
|
+
description: Classifies whether assistant deviated from user intent
|
|
4
|
+
model: claude-sonnet-4-6
|
|
5
|
+
thinking: "on"
|
|
6
|
+
output:
|
|
7
|
+
format: json
|
|
8
|
+
schema: ../schemas/verdict.schema.json
|
|
9
|
+
prompt:
|
|
10
|
+
task:
|
|
11
|
+
template: hedge/classify.md
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name: unauthorized-action-classifier
|
|
2
|
+
role: sensor
|
|
3
|
+
description: Classifies whether agent is about to take an unauthorized action
|
|
4
|
+
model: claude-sonnet-4-6
|
|
5
|
+
thinking: "on"
|
|
6
|
+
output:
|
|
7
|
+
format: json
|
|
8
|
+
schema: ../schemas/verdict.schema.json
|
|
9
|
+
prompt:
|
|
10
|
+
task:
|
|
11
|
+
template: unauthorized-action/classify.md
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name: work-quality-classifier
|
|
2
|
+
role: sensor
|
|
3
|
+
description: Classifies work quality issues in agent output
|
|
4
|
+
model: claude-sonnet-4-6
|
|
5
|
+
thinking: "on"
|
|
6
|
+
output:
|
|
7
|
+
format: json
|
|
8
|
+
schema: ../schemas/verdict.schema.json
|
|
9
|
+
prompt:
|
|
10
|
+
task:
|
|
11
|
+
template: work-quality/classify.md
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
1
|
+
import type { ExtensionAPI, SessionEntry } from "@mariozechner/pi-coding-agent";
|
|
2
2
|
export interface CollectorDescriptor {
|
|
3
3
|
name: string;
|
|
4
4
|
description: string;
|
|
@@ -11,7 +11,7 @@ export interface WhenConditionDescriptor {
|
|
|
11
11
|
parameterized: boolean;
|
|
12
12
|
}
|
|
13
13
|
export declare const WHEN_CONDITIONS: WhenConditionDescriptor[];
|
|
14
|
-
export declare const VERDICT_TYPES: readonly ["clean", "flag", "new"];
|
|
14
|
+
export declare const VERDICT_TYPES: readonly ["clean", "flag", "new", "error"];
|
|
15
15
|
export declare const SCOPE_TARGETS: readonly ["main", "subagent", "all", "workflow"];
|
|
16
16
|
export interface MonitorScope {
|
|
17
17
|
target: "main" | "subagent" | "all" | "workflow";
|
|
@@ -54,11 +54,9 @@ export interface MonitorSpec {
|
|
|
54
54
|
when: string;
|
|
55
55
|
scope: MonitorScope;
|
|
56
56
|
classify: {
|
|
57
|
-
model: string;
|
|
58
57
|
context: string[];
|
|
59
58
|
excludes: string[];
|
|
60
|
-
|
|
61
|
-
promptTemplate?: string;
|
|
59
|
+
agent: string;
|
|
62
60
|
};
|
|
63
61
|
patterns: {
|
|
64
62
|
path: string;
|
|
@@ -104,10 +102,11 @@ export interface Monitor extends MonitorSpec {
|
|
|
104
102
|
classifySkipRemaining: number;
|
|
105
103
|
}
|
|
106
104
|
export interface ClassifyResult {
|
|
107
|
-
verdict: "clean" | "flag" | "new";
|
|
105
|
+
verdict: "clean" | "flag" | "new" | "error";
|
|
108
106
|
description?: string;
|
|
109
107
|
newPattern?: string;
|
|
110
108
|
severity?: string;
|
|
109
|
+
error?: string;
|
|
111
110
|
}
|
|
112
111
|
export interface MonitorMessageDetails {
|
|
113
112
|
monitorName: string;
|
|
@@ -119,6 +118,15 @@ export interface MonitorMessageDetails {
|
|
|
119
118
|
}
|
|
120
119
|
type MonitorEvent = "message_end" | "turn_end" | "agent_end" | "command" | "tool_call";
|
|
121
120
|
export declare const VALID_EVENTS: Set<string>;
|
|
121
|
+
export declare function discoverMonitors(): Monitor[];
|
|
122
|
+
export declare function resolveProjectMonitorsDir(): string;
|
|
123
|
+
/**
|
|
124
|
+
* Detect whether the current user message references prior conversation context
|
|
125
|
+
* via backreferences, affirmations, or short messages without action verbs.
|
|
126
|
+
* Exported for testing.
|
|
127
|
+
*/
|
|
128
|
+
export declare function isReferentialMessage(text: string): boolean;
|
|
129
|
+
export declare function collectConversationHistory(branch: SessionEntry[]): string;
|
|
122
130
|
/** Collector names derived from the runtime registry — used for consistency testing. */
|
|
123
131
|
export declare const COLLECTOR_NAMES: string[];
|
|
124
132
|
export type MonitorsCommand = {
|
|
@@ -167,6 +175,20 @@ export declare function parseModelSpec(spec: string): {
|
|
|
167
175
|
provider: string;
|
|
168
176
|
modelId: string;
|
|
169
177
|
};
|
|
178
|
+
/**
|
|
179
|
+
* Extract response text from LLM response parts, falling back to thinking
|
|
180
|
+
* block content when no text parts are present. Fixes issue-024 where
|
|
181
|
+
* models with thinking enabled place the entire verdict inside the thinking
|
|
182
|
+
* block, leaving text content empty.
|
|
183
|
+
*/
|
|
184
|
+
export declare function extractResponseText(parts: readonly {
|
|
185
|
+
type: string;
|
|
186
|
+
}[]): string;
|
|
187
|
+
/**
|
|
188
|
+
* Map a parsed JSON verdict object to a ClassifyResult.
|
|
189
|
+
* Handles case-insensitive verdict strings and optional fields.
|
|
190
|
+
*/
|
|
191
|
+
export declare function mapVerdictToClassifyResult(parsed: Record<string, unknown>): ClassifyResult;
|
|
170
192
|
export declare function generateFindingId(monitorName: string, _description: string): string;
|
|
171
193
|
/**
|
|
172
194
|
* Programmatic monitor invocation — runs classification and write actions for
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAIX,YAAY,EAEZ,YAAY,EAGZ,MAAM,+BAA+B,CAAC;AA0BvC,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CA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