@davidorex/pi-behavior-monitors 0.1.4 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,88 +1,52 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project will be documented in this file.
3
+ ## [0.3.0] - 2026-03-18
4
4
 
5
- ## v0.1.4
5
+ ## [0.2.0] - 2026-03-17
6
6
 
7
- [compare changes](https://github.com/davidorex/pi-behavior-monitors/compare/v0.1.3...v0.1.4)
7
+ ### Changed
8
+ - Version aligned to 0.2.0 for monorepo lockstep versioning
9
+ - Integrated into pi-project-workflows monorepo
8
10
 
9
- ### 🚀 Enhancements
11
+ ### Fixed
12
+ - `pendingAgentEndSteers` scoping bug: variable was declared inside export function but referenced in module-level `activate` — added as parameter
13
+ - `extractText` parameter type widened for upstream `ThinkingContent` addition to message content arrays
14
+ - `MessageEndEvent` import removed (no longer exported from pi-coding-agent main entry)
10
15
 
11
- - Add ui.select menus to /monitors command for TUI discoverability ([4391ca3](https://github.com/davidorex/pi-behavior-monitors/commit/4391ca3))
16
+ ## [0.1.4] - 2026-03-16
12
17
 
13
- ### 📖 Documentation
14
-
15
- - Update SKILL.md with buffered steer delivery and TUI autocomplete ([94aee6e](https://github.com/davidorex/pi-behavior-monitors/commit/94aee6e))
16
-
17
- ### ❤️ Contributors
18
-
19
- - David Ryan <davidryan@gmail.com>
20
-
21
- ## v0.1.3
22
-
23
- [compare changes](https://github.com/davidorex/pi-behavior-monitors/compare/v0.1.2...v0.1.3)
24
-
25
- ### 🩹 Fixes
26
-
27
- - Buffer steer delivery at agent_end to work around pi async event queue ([c899fa5](https://github.com/davidorex/pi-behavior-monitors/commit/c899fa5))
28
-
29
- ### 📖 Documentation
30
-
31
- - Add npm publish commands to CLAUDE.md ([91dbe87](https://github.com/davidorex/pi-behavior-monitors/commit/91dbe87))
32
-
33
- ### 🏡 Chore
34
-
35
- - Scope package name to @davidorex/pi-behavior-monitors ([e9a9882](https://github.com/davidorex/pi-behavior-monitors/commit/e9a9882))
36
-
37
- ### ❤️ Contributors
38
-
39
- - David Ryan <davidryan@gmail.com>
40
-
41
- ## v0.1.2
42
-
43
- [compare changes](https://github.com/davidorex/pi-behavior-monitors/compare/v0.1.1...v0.1.2)
44
-
45
- ### 🚀 Enhancements
46
-
47
- - Unify monitor management under /monitors command with subcommand routing ([dbffaa0](https://github.com/davidorex/pi-behavior-monitors/commit/dbffaa0))
48
- - Add vitest test suite for pure functions in index.ts ([fed0d75](https://github.com/davidorex/pi-behavior-monitors/commit/fed0d75))
49
-
50
- ### 🩹 Fixes
51
-
52
- - Address conformance audit findings — unused param, session_switch, headless escalate ([f2d3baa](https://github.com/davidorex/pi-behavior-monitors/commit/f2d3baa))
53
-
54
- ### 🏡 Chore
55
-
56
- - Add .claude/ to gitignore, version conformance audit in docs/ ([d6a8395](https://github.com/davidorex/pi-behavior-monitors/commit/d6a8395))
57
-
58
- ### ❤️ Contributors
59
-
60
- - David Ryan <davidryan@gmail.com>
18
+ ### Added
19
+ - UI select menus for `/monitors` command for TUI discoverability
61
20
 
62
- ## v0.1.1
21
+ ### Changed
22
+ - Updated SKILL.md with buffered steer delivery and TUI autocomplete
63
23
 
64
- [compare changes](https://github.com/davidorex/pi-behavior-monitors/compare/v0.1.0...v0.1.1)
24
+ ## [0.1.3] - 2026-03-15
65
25
 
66
- ### 📖 Documentation
26
+ ### Fixed
27
+ - Buffer steer delivery at agent_end to work around pi async event queue
67
28
 
68
- - Add CLAUDE.md with project conventions ([5f5b427](https://github.com/davidorex/pi-behavior-monitors/commit/5f5b427))
69
- - Expand SKILL.md to cover full runtime behavior and bundled monitors ([5c9980d](https://github.com/davidorex/pi-behavior-monitors/commit/5c9980d))
29
+ ### Changed
30
+ - Scoped package name to `@davidorex/pi-behavior-monitors`
70
31
 
71
- ### 🏡 Chore
32
+ ## [0.1.2] - 2026-03-14
72
33
 
73
- - Add npm publish metadata, files whitelist, and normalize repository URL ([4b3f1f4](https://github.com/davidorex/pi-behavior-monitors/commit/4b3f1f4))
74
- - Add .gitignore, remove runtime .workflow/ from tracking ([c1d4ae5](https://github.com/davidorex/pi-behavior-monitors/commit/c1d4ae5))
34
+ ### Added
35
+ - Unified monitor management under `/monitors` command with subcommand routing
36
+ - Vitest test suite for pure functions in index.ts
75
37
 
76
- ### ❤️ Contributors
38
+ ### Fixed
39
+ - Conformance audit findings: unused param, session_switch, headless escalate
77
40
 
78
- - David Ryan <davidryan@gmail.com>
41
+ ## [0.1.1] - 2026-03-13
79
42
 
80
- ## v0.1.0
43
+ ### Changed
44
+ - Expanded SKILL.md to cover full runtime behavior and bundled monitors
45
+ - Added npm publish metadata, files whitelist, normalized repository URL
81
46
 
82
- Initial release.
47
+ ## [0.1.0] - 2026-03-12
83
48
 
84
49
  ### Added
85
-
86
50
  - Monitor extension with event-driven classification (message_end, turn_end, agent_end, command)
87
51
  - JSON-based monitor definitions (.monitor.json), pattern libraries (.patterns.json), instructions (.instructions.json)
88
52
  - Side-channel LLM classification with CLEAN/FLAG/NEW verdict protocol
package/README.md CHANGED
@@ -7,9 +7,11 @@ Monitors are JSON files (`.monitor.json`) with typed blocks: classify (LLM side-
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- pi install npm:pi-behavior-monitors
10
+ pi install npm:@davidorex/pi-behavior-monitors
11
11
  ```
12
12
 
13
+ Or install all three extensions at once: `pi install npm:@davidorex/pi-project-workflows`
14
+
13
15
  On first run, if no monitors exist in your project, example monitors are seeded into `.pi/monitors/`. Edit or delete them to customize.
14
16
 
15
17
  ## Bundled Example Monitors
@@ -57,3 +59,9 @@ Create a `.monitor.json` file in `.pi/monitors/` conforming to `schemas/monitor.
57
59
 
58
60
  - `schemas/monitor.schema.json` — monitor definition format
59
61
  - `schemas/monitor-pattern.schema.json` — pattern library entry format
62
+
63
+ ## Development
64
+
65
+ Part of the [`pi-project-workflows`](../../README.md) monorepo. All three packages (pi-project, pi-workflows, pi-behavior-monitors) are versioned in lockstep at 0.2.0.
66
+
67
+ `npm run build` compiles TypeScript to `dist/` via `tsc`. The package ships `dist/`, not `src/`. Tests use `vitest run` (`npm test`).
@@ -0,0 +1,149 @@
1
+ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
+ export interface CollectorDescriptor {
3
+ name: string;
4
+ description: string;
5
+ limits?: string;
6
+ }
7
+ export declare const COLLECTOR_DESCRIPTORS: CollectorDescriptor[];
8
+ export interface WhenConditionDescriptor {
9
+ name: string;
10
+ description: string;
11
+ parameterized: boolean;
12
+ }
13
+ export declare const WHEN_CONDITIONS: WhenConditionDescriptor[];
14
+ export declare const VERDICT_TYPES: readonly ["clean", "flag", "new"];
15
+ export declare const SCOPE_TARGETS: readonly ["main", "subagent", "all", "workflow"];
16
+ export interface MonitorScope {
17
+ target: "main" | "subagent" | "all" | "workflow";
18
+ filter?: {
19
+ agent_type?: string[];
20
+ step_name?: string;
21
+ workflow?: string;
22
+ };
23
+ }
24
+ export interface MonitorAction {
25
+ steer?: string | null;
26
+ learn_pattern?: boolean;
27
+ write?: {
28
+ path: string;
29
+ schema?: string;
30
+ merge: "append" | "upsert";
31
+ array_field: string;
32
+ template: Record<string, string>;
33
+ };
34
+ }
35
+ export interface MonitorSpec {
36
+ name: string;
37
+ description: string;
38
+ event: MonitorEvent;
39
+ when: string;
40
+ scope: MonitorScope;
41
+ classify: {
42
+ model: string;
43
+ context: string[];
44
+ excludes: string[];
45
+ prompt: string;
46
+ promptTemplate?: string;
47
+ };
48
+ patterns: {
49
+ path: string;
50
+ learn: boolean;
51
+ };
52
+ instructions: {
53
+ path: string;
54
+ };
55
+ actions: {
56
+ on_flag?: MonitorAction | null;
57
+ on_new?: MonitorAction | null;
58
+ on_clean?: MonitorAction | null;
59
+ };
60
+ ceiling: number;
61
+ escalate: "ask" | "dismiss";
62
+ }
63
+ export interface MonitorPattern {
64
+ id: string;
65
+ description: string;
66
+ severity?: string;
67
+ category?: string;
68
+ examples?: string[];
69
+ learned_at?: string;
70
+ source?: string;
71
+ }
72
+ export interface MonitorInstruction {
73
+ text: string;
74
+ added_at?: string;
75
+ }
76
+ export interface Monitor extends MonitorSpec {
77
+ dir: string;
78
+ resolvedPatternsPath: string;
79
+ resolvedInstructionsPath: string;
80
+ activationCount: number;
81
+ whileCount: number;
82
+ lastUserText: string;
83
+ dismissed: boolean;
84
+ }
85
+ export interface ClassifyResult {
86
+ verdict: "clean" | "flag" | "new";
87
+ description?: string;
88
+ newPattern?: string;
89
+ }
90
+ export interface MonitorMessageDetails {
91
+ monitorName: string;
92
+ verdict: "flag" | "new";
93
+ description: string;
94
+ steer: string;
95
+ whileCount: number;
96
+ ceiling: number;
97
+ }
98
+ type MonitorEvent = "message_end" | "turn_end" | "agent_end" | "command";
99
+ export declare const VALID_EVENTS: Set<string>;
100
+ /** Collector names derived from the runtime registry — used for consistency testing. */
101
+ export declare const COLLECTOR_NAMES: string[];
102
+ export type MonitorsCommand = {
103
+ type: "list";
104
+ } | {
105
+ type: "on";
106
+ } | {
107
+ type: "off";
108
+ } | {
109
+ type: "inspect";
110
+ name: string;
111
+ } | {
112
+ type: "rules-list";
113
+ name: string;
114
+ } | {
115
+ type: "rules-add";
116
+ name: string;
117
+ text: string;
118
+ } | {
119
+ type: "rules-remove";
120
+ name: string;
121
+ index: number;
122
+ } | {
123
+ type: "rules-replace";
124
+ name: string;
125
+ index: number;
126
+ text: string;
127
+ } | {
128
+ type: "patterns-list";
129
+ name: string;
130
+ } | {
131
+ type: "dismiss";
132
+ name: string;
133
+ } | {
134
+ type: "reset";
135
+ name: string;
136
+ } | {
137
+ type: "error";
138
+ message: string;
139
+ };
140
+ export declare function parseMonitorsArgs(args: string, knownNames: Set<string>): MonitorsCommand;
141
+ export declare function parseVerdict(raw: string): ClassifyResult;
142
+ export declare function parseModelSpec(spec: string): {
143
+ provider: string;
144
+ modelId: string;
145
+ };
146
+ export declare function generateFindingId(monitorName: string, _description: string): string;
147
+ export default function (pi: ExtensionAPI): void;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