@deftai/directive-core 0.89.0 → 0.90.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.
Files changed (43) hide show
  1. package/dist/doctor/constants.d.ts +1 -1
  2. package/dist/doctor/constants.js +2 -0
  3. package/dist/doctor/flags.js +21 -1
  4. package/dist/doctor/index.d.ts +1 -0
  5. package/dist/doctor/index.js +1 -0
  6. package/dist/doctor/main.js +22 -0
  7. package/dist/doctor/openclaw-skills.d.ts +109 -0
  8. package/dist/doctor/openclaw-skills.js +463 -0
  9. package/dist/doctor/types.d.ts +11 -0
  10. package/dist/hooks/dispatcher.js +20 -5
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.js +1 -0
  13. package/dist/lifecycle/events.js +2 -0
  14. package/dist/lifecycle/index.d.ts +1 -0
  15. package/dist/lifecycle/index.js +1 -0
  16. package/dist/lifecycle/stats.d.ts +53 -0
  17. package/dist/lifecycle/stats.js +286 -0
  18. package/dist/release/spawn.js +13 -0
  19. package/dist/release-e2e/git-ops.d.ts +7 -0
  20. package/dist/release-e2e/git-ops.js +35 -2
  21. package/dist/session/index.d.ts +2 -0
  22. package/dist/session/index.js +2 -0
  23. package/dist/session/process-cost-constants.d.ts +9 -0
  24. package/dist/session/process-cost-constants.js +11 -0
  25. package/dist/session/process-cost.d.ts +53 -0
  26. package/dist/session/process-cost.js +82 -0
  27. package/dist/session/ritual-sentinel.d.ts +5 -0
  28. package/dist/session/ritual-sentinel.js +12 -1
  29. package/dist/session/session-ready.d.ts +67 -0
  30. package/dist/session/session-ready.js +264 -0
  31. package/dist/session/session-start.d.ts +56 -1
  32. package/dist/session/session-start.js +378 -24
  33. package/dist/session/verify-session-ritual.d.ts +8 -0
  34. package/dist/session/verify-session-ritual.js +95 -35
  35. package/dist/tool-events/classify.d.ts +20 -0
  36. package/dist/tool-events/classify.js +634 -0
  37. package/dist/tool-events/index.d.ts +10 -0
  38. package/dist/tool-events/index.js +10 -0
  39. package/dist/tool-events/summarize.d.ts +34 -0
  40. package/dist/tool-events/summarize.js +93 -0
  41. package/dist/tool-events/types.d.ts +52 -0
  42. package/dist/tool-events/types.js +13 -0
  43. package/package.json +7 -3
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Aggregate tool-event classifications into counts, anomalies, and status lines (#2967).
3
+ * Pure: no I/O.
4
+ */
5
+ import { classifyToolEvent } from "./classify.js";
6
+ import { TOOL_EVENT_BUCKETS, } from "./types.js";
7
+ export function emptyBucketCounts() {
8
+ return {
9
+ explore: 0,
10
+ commit: 0,
11
+ verify: 0,
12
+ coordinate: 0,
13
+ unknown: 0,
14
+ };
15
+ }
16
+ /** Count classified buckets for a sequence of tool events. */
17
+ export function countToolEventBuckets(events) {
18
+ const counts = {
19
+ explore: 0,
20
+ commit: 0,
21
+ verify: 0,
22
+ coordinate: 0,
23
+ unknown: 0,
24
+ };
25
+ for (const event of events) {
26
+ const { bucket } = classifyToolEvent(event);
27
+ counts[bucket] += 1;
28
+ }
29
+ return counts;
30
+ }
31
+ /**
32
+ * Detect operator-facing anomalies from bucket counts.
33
+ *
34
+ * Rules (conservative — only fire when the mix is clearly wrong):
35
+ * - commit-without-explore: commit > 0 and explore === 0
36
+ * - verify-skipped: commit > 0 and verify === 0 (ship without gates)
37
+ * - explore-only: explore > 0, commit === 0, verify === 0, and total >= 3
38
+ * (thrash / stuck-reading signal; small explore-only sessions stay quiet)
39
+ */
40
+ export function detectToolEventAnomalies(counts) {
41
+ const anomalies = [];
42
+ const total = counts.explore + counts.commit + counts.verify + counts.coordinate + counts.unknown;
43
+ if (counts.commit > 0 && counts.explore === 0) {
44
+ anomalies.push({
45
+ code: "commit-without-explore",
46
+ message: `commit-without-explore: ${counts.commit} commit event(s) with 0 explore`,
47
+ });
48
+ }
49
+ if (counts.commit > 0 && counts.verify === 0) {
50
+ anomalies.push({
51
+ code: "verify-skipped",
52
+ message: `verify-skipped: ${counts.commit} commit event(s) with 0 verify`,
53
+ });
54
+ }
55
+ if (counts.explore > 0 && counts.commit === 0 && counts.verify === 0 && total >= 3) {
56
+ anomalies.push({
57
+ code: "explore-only",
58
+ message: `explore-only: ${counts.explore} explore event(s) with 0 commit and 0 verify (possible thrash)`,
59
+ });
60
+ }
61
+ return anomalies;
62
+ }
63
+ /**
64
+ * Compact status line for swarm monitor / review-cycle batch brief.
65
+ * Example: `tools: explore=3 commit=2 verify=1 coordinate=0 unknown=0`
66
+ */
67
+ export function formatToolEventStatusLine(counts) {
68
+ const parts = TOOL_EVENT_BUCKETS.map((b) => `${b}=${counts[b]}`);
69
+ return `tools: ${parts.join(" ")}`;
70
+ }
71
+ /**
72
+ * One-line anomaly suffix for status surfaces.
73
+ * Empty string when no anomalies.
74
+ */
75
+ export function formatToolEventAnomalyLine(anomalies) {
76
+ if (anomalies.length === 0)
77
+ return "";
78
+ return `anomalies: ${anomalies.map((a) => a.code).join(",")}`;
79
+ }
80
+ /**
81
+ * Full summary for a tool-event sequence — counts, anomalies, status line.
82
+ * When anomalies exist, statusLine appends `| anomalies: …`.
83
+ */
84
+ export function summarizeToolEvents(events) {
85
+ const counts = countToolEventBuckets(events);
86
+ const anomalies = detectToolEventAnomalies(counts);
87
+ const total = counts.explore + counts.commit + counts.verify + counts.coordinate + counts.unknown;
88
+ const base = formatToolEventStatusLine(counts);
89
+ const anomalyLine = formatToolEventAnomalyLine(anomalies);
90
+ const statusLine = anomalyLine.length > 0 ? `${base} | ${anomalyLine}` : base;
91
+ return { total, counts, anomalies, statusLine };
92
+ }
93
+ //# sourceMappingURL=summarize.js.map
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Tool-event taxonomy types for explore/commit/verify classification (#2967).
3
+ * Pure types only — no I/O.
4
+ */
5
+ /** Deterministic activity buckets for swarm/review operator skim. */
6
+ export type ToolEventBucket = "explore" | "commit" | "verify" | "coordinate" | "unknown";
7
+ /** All buckets in stable report order (unknown last). */
8
+ export declare const TOOL_EVENT_BUCKETS: readonly ToolEventBucket[];
9
+ /**
10
+ * Minimal tool-event input. Prefer tool name + coarse args; never require
11
+ * full host payloads. Shell tools should pass `command` when known.
12
+ */
13
+ export interface ToolEventInput {
14
+ /** Host tool name (e.g. `Read`, `Shell`, `Write`, `Task`). */
15
+ readonly name: string;
16
+ /**
17
+ * Coarse args bag — common keys: `command`, `cmd`, `path`, `file_path`,
18
+ * `query`, `pattern`. Values may be strings or other JSON-ish primitives.
19
+ */
20
+ readonly args?: Readonly<Record<string, unknown>> | null;
21
+ /**
22
+ * Explicit shell/command string when not nested under `args`.
23
+ * Wins over `args.command` / `args.cmd` when both are set.
24
+ */
25
+ readonly command?: string | null;
26
+ }
27
+ /** Result of classifying one tool event. */
28
+ export interface ClassifyToolEventResult {
29
+ readonly bucket: ToolEventBucket;
30
+ /** Stable machine-oriented reason code for tests and debug. */
31
+ readonly reason: string;
32
+ }
33
+ /** Per-bucket event counts (always includes every bucket key). */
34
+ export type ToolEventBucketCounts = Readonly<Record<ToolEventBucket, number>>;
35
+ /**
36
+ * Operator-facing anomaly codes derived from a sequence of classified events.
37
+ * Detection is conservative: only fire when the mix is clearly wrong.
38
+ */
39
+ export type ToolEventAnomalyCode = "commit-without-explore" | "verify-skipped" | "explore-only";
40
+ export interface ToolEventAnomaly {
41
+ readonly code: ToolEventAnomalyCode;
42
+ readonly message: string;
43
+ }
44
+ /** Aggregate summary for monitor status lines and batch briefs. */
45
+ export interface ToolEventSummary {
46
+ readonly total: number;
47
+ readonly counts: ToolEventBucketCounts;
48
+ readonly anomalies: readonly ToolEventAnomaly[];
49
+ /** Compact one-liner: `tools: explore=3 commit=2 verify=1 coordinate=0 unknown=0`. */
50
+ readonly statusLine: string;
51
+ }
52
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Tool-event taxonomy types for explore/commit/verify classification (#2967).
3
+ * Pure types only — no I/O.
4
+ */
5
+ /** All buckets in stable report order (unknown last). */
6
+ export const TOOL_EVENT_BUCKETS = [
7
+ "explore",
8
+ "commit",
9
+ "verify",
10
+ "coordinate",
11
+ "unknown",
12
+ ];
13
+ //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deftai/directive-core",
3
- "version": "0.89.0",
3
+ "version": "0.90.0",
4
4
  "description": "TypeScript engine core for the Directive framework.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -263,6 +263,10 @@
263
263
  "types": "./dist/swarm/index.d.ts",
264
264
  "default": "./dist/swarm/index.js"
265
265
  },
266
+ "./tool-events": {
267
+ "types": "./dist/tool-events/index.d.ts",
268
+ "default": "./dist/tool-events/index.js"
269
+ },
266
270
  "./review-monitor": {
267
271
  "types": "./dist/review-monitor/index.d.ts",
268
272
  "default": "./dist/review-monitor/index.js"
@@ -330,8 +334,8 @@
330
334
  "provenance": true
331
335
  },
332
336
  "dependencies": {
333
- "@deftai/directive-content": "^0.89.0",
334
- "@deftai/directive-types": "^0.89.0",
337
+ "@deftai/directive-content": "^0.90.0",
338
+ "@deftai/directive-types": "^0.90.0",
335
339
  "archiver": "^8.0.0"
336
340
  },
337
341
  "scripts": {