@davidorex/pi-behavior-monitors 0.1.3 → 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,72 +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.3
5
+ ## [0.2.0] - 2026-03-17
6
6
 
7
- [compare changes](https://github.com/davidorex/pi-behavior-monitors/compare/v0.1.2...v0.1.3)
7
+ ### Changed
8
+ - Version aligned to 0.2.0 for monorepo lockstep versioning
9
+ - Integrated into pi-project-workflows monorepo
8
10
 
9
- ### 🩹 Fixes
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
- - Buffer steer delivery at agent_end to work around pi async event queue ([c899fa5](https://github.com/davidorex/pi-behavior-monitors/commit/c899fa5))
16
+ ## [0.1.4] - 2026-03-16
12
17
 
13
- ### 📖 Documentation
14
-
15
- - Add npm publish commands to CLAUDE.md ([91dbe87](https://github.com/davidorex/pi-behavior-monitors/commit/91dbe87))
16
-
17
- ### 🏡 Chore
18
-
19
- - Scope package name to @davidorex/pi-behavior-monitors ([e9a9882](https://github.com/davidorex/pi-behavior-monitors/commit/e9a9882))
20
-
21
- ### ❤️ Contributors
22
-
23
- - David Ryan <davidryan@gmail.com>
24
-
25
- ## v0.1.2
26
-
27
- [compare changes](https://github.com/davidorex/pi-behavior-monitors/compare/v0.1.1...v0.1.2)
28
-
29
- ### 🚀 Enhancements
30
-
31
- - Unify monitor management under /monitors command with subcommand routing ([dbffaa0](https://github.com/davidorex/pi-behavior-monitors/commit/dbffaa0))
32
- - Add vitest test suite for pure functions in index.ts ([fed0d75](https://github.com/davidorex/pi-behavior-monitors/commit/fed0d75))
33
-
34
- ### 🩹 Fixes
35
-
36
- - Address conformance audit findings — unused param, session_switch, headless escalate ([f2d3baa](https://github.com/davidorex/pi-behavior-monitors/commit/f2d3baa))
37
-
38
- ### 🏡 Chore
39
-
40
- - Add .claude/ to gitignore, version conformance audit in docs/ ([d6a8395](https://github.com/davidorex/pi-behavior-monitors/commit/d6a8395))
41
-
42
- ### ❤️ Contributors
43
-
44
- - David Ryan <davidryan@gmail.com>
18
+ ### Added
19
+ - UI select menus for `/monitors` command for TUI discoverability
45
20
 
46
- ## v0.1.1
21
+ ### Changed
22
+ - Updated SKILL.md with buffered steer delivery and TUI autocomplete
47
23
 
48
- [compare changes](https://github.com/davidorex/pi-behavior-monitors/compare/v0.1.0...v0.1.1)
24
+ ## [0.1.3] - 2026-03-15
49
25
 
50
- ### 📖 Documentation
26
+ ### Fixed
27
+ - Buffer steer delivery at agent_end to work around pi async event queue
51
28
 
52
- - Add CLAUDE.md with project conventions ([5f5b427](https://github.com/davidorex/pi-behavior-monitors/commit/5f5b427))
53
- - 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`
54
31
 
55
- ### 🏡 Chore
32
+ ## [0.1.2] - 2026-03-14
56
33
 
57
- - Add npm publish metadata, files whitelist, and normalize repository URL ([4b3f1f4](https://github.com/davidorex/pi-behavior-monitors/commit/4b3f1f4))
58
- - 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
59
37
 
60
- ### ❤️ Contributors
38
+ ### Fixed
39
+ - Conformance audit findings: unused param, session_switch, headless escalate
61
40
 
62
- - David Ryan <davidryan@gmail.com>
41
+ ## [0.1.1] - 2026-03-13
63
42
 
64
- ## 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
65
46
 
66
- Initial release.
47
+ ## [0.1.0] - 2026-03-12
67
48
 
68
49
  ### Added
69
-
70
50
  - Monitor extension with event-driven classification (message_end, turn_end, agent_end, command)
71
51
  - JSON-based monitor definitions (.monitor.json), pattern libraries (.patterns.json), instructions (.instructions.json)
72
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;
148
+ export {};
149
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAIX,YAAY,EAKZ,MAAM,+BAA+B,CAAC;AAavC,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,qBAAqB,EAAE,mBAAmB,EAStD,CAAC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