@codemieai/code 0.12.0 → 0.13.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/README.md +146 -57
- package/bin/codemie-copilot.js +224 -0
- package/bin/codemie-pi.js +18 -0
- package/dist/agents/core/AgentCLI.d.ts.map +1 -1
- package/dist/agents/core/AgentCLI.js +16 -10
- package/dist/agents/core/AgentCLI.js.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.js +43 -19
- package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
- package/dist/agents/core/agent-aliases.d.ts +17 -0
- package/dist/agents/core/agent-aliases.d.ts.map +1 -0
- package/dist/agents/core/agent-aliases.js +41 -0
- package/dist/agents/core/agent-aliases.js.map +1 -0
- package/dist/agents/core/session/session-origin-audit.d.ts +13 -0
- package/dist/agents/core/session/session-origin-audit.d.ts.map +1 -1
- package/dist/agents/core/session/session-origin-audit.js +34 -0
- package/dist/agents/core/session/session-origin-audit.js.map +1 -1
- package/dist/agents/core/session/stale-session-reconciliation.d.ts +42 -0
- package/dist/agents/core/session/stale-session-reconciliation.d.ts.map +1 -0
- package/dist/agents/core/session/stale-session-reconciliation.js +141 -0
- package/dist/agents/core/session/stale-session-reconciliation.js.map +1 -0
- package/dist/agents/core/session/types.d.ts +19 -0
- package/dist/agents/core/session/types.d.ts.map +1 -1
- package/dist/agents/core/session/types.js +17 -1
- package/dist/agents/core/session/types.js.map +1 -1
- package/dist/agents/core/types.d.ts +1 -0
- package/dist/agents/core/types.d.ts.map +1 -1
- package/dist/agents/plugins/codex/codex.reconciliation.d.ts +15 -35
- package/dist/agents/plugins/codex/codex.reconciliation.d.ts.map +1 -1
- package/dist/agents/plugins/codex/codex.reconciliation.js +8 -139
- package/dist/agents/plugins/codex/codex.reconciliation.js.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.constants.d.ts +4 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.constants.d.ts.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.constants.js +4 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.constants.js.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.models.d.ts +8 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.models.d.ts.map +1 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.models.js +195 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.models.js.map +1 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.d.ts +4 -20
- package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.d.ts.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.js +237 -38
- package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.js.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.session.d.ts.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.session.js +14 -2
- package/dist/agents/plugins/copilot-cli/copilot-cli.session.js.map +1 -1
- package/dist/agents/plugins/copilot-cli/index.d.ts +2 -1
- package/dist/agents/plugins/copilot-cli/index.d.ts.map +1 -1
- package/dist/agents/plugins/copilot-cli/index.js +2 -1
- package/dist/agents/plugins/copilot-cli/index.js.map +1 -1
- package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.d.ts +6 -3
- package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.d.ts.map +1 -1
- package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.js +298 -5
- package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.js.map +1 -1
- package/dist/agents/plugins/pi/__tests__/home-redirect.d.ts +12 -0
- package/dist/agents/plugins/pi/__tests__/home-redirect.d.ts.map +1 -0
- package/dist/agents/plugins/pi/__tests__/home-redirect.js +27 -0
- package/dist/agents/plugins/pi/__tests__/home-redirect.js.map +1 -0
- package/dist/agents/plugins/pi/extension/README.md +68 -0
- package/dist/agents/plugins/pi/extension/index.js +161 -0
- package/dist/agents/plugins/pi/extension/package.json +8 -0
- package/dist/agents/plugins/pi/index.d.ts +3 -0
- package/dist/agents/plugins/pi/index.d.ts.map +1 -0
- package/dist/agents/plugins/pi/index.js +3 -0
- package/dist/agents/plugins/pi/index.js.map +1 -0
- package/dist/agents/plugins/pi/pi.extension.d.ts +60 -0
- package/dist/agents/plugins/pi/pi.extension.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.extension.js +201 -0
- package/dist/agents/plugins/pi/pi.extension.js.map +1 -0
- package/dist/agents/plugins/pi/pi.incremental-sync.d.ts +63 -0
- package/dist/agents/plugins/pi/pi.incremental-sync.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.incremental-sync.js +266 -0
- package/dist/agents/plugins/pi/pi.incremental-sync.js.map +1 -0
- package/dist/agents/plugins/pi/pi.models.d.ts +20 -0
- package/dist/agents/plugins/pi/pi.models.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.models.js +201 -0
- package/dist/agents/plugins/pi/pi.models.js.map +1 -0
- package/dist/agents/plugins/pi/pi.packages.d.ts +11 -0
- package/dist/agents/plugins/pi/pi.packages.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.packages.js +35 -0
- package/dist/agents/plugins/pi/pi.packages.js.map +1 -0
- package/dist/agents/plugins/pi/pi.paths.d.ts +37 -0
- package/dist/agents/plugins/pi/pi.paths.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.paths.js +146 -0
- package/dist/agents/plugins/pi/pi.paths.js.map +1 -0
- package/dist/agents/plugins/pi/pi.plugin.d.ts +30 -0
- package/dist/agents/plugins/pi/pi.plugin.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.plugin.js +453 -0
- package/dist/agents/plugins/pi/pi.plugin.js.map +1 -0
- package/dist/agents/plugins/pi/pi.session.d.ts +114 -0
- package/dist/agents/plugins/pi/pi.session.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.session.js +388 -0
- package/dist/agents/plugins/pi/pi.session.js.map +1 -0
- package/dist/agents/plugins/pi/pi.setup.d.ts +2 -0
- package/dist/agents/plugins/pi/pi.setup.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.setup.js +33 -0
- package/dist/agents/plugins/pi/pi.setup.js.map +1 -0
- package/dist/agents/plugins/pi/pi.types.d.ts +143 -0
- package/dist/agents/plugins/pi/pi.types.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.types.js +74 -0
- package/dist/agents/plugins/pi/pi.types.js.map +1 -0
- package/dist/agents/plugins/pi/session/pi-file-operations.d.ts +17 -0
- package/dist/agents/plugins/pi/session/pi-file-operations.d.ts.map +1 -0
- package/dist/agents/plugins/pi/session/pi-file-operations.js +98 -0
- package/dist/agents/plugins/pi/session/pi-file-operations.js.map +1 -0
- package/dist/agents/plugins/pi/session/pi-named-invocations.d.ts +52 -0
- package/dist/agents/plugins/pi/session/pi-named-invocations.d.ts.map +1 -0
- package/dist/agents/plugins/pi/session/pi-named-invocations.js +189 -0
- package/dist/agents/plugins/pi/session/pi-named-invocations.js.map +1 -0
- package/dist/agents/plugins/pi/session/pi-user-prompt.d.ts +14 -0
- package/dist/agents/plugins/pi/session/pi-user-prompt.d.ts.map +1 -0
- package/dist/agents/plugins/pi/session/pi-user-prompt.js +51 -0
- package/dist/agents/plugins/pi/session/pi-user-prompt.js.map +1 -0
- package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.d.ts +52 -0
- package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.d.ts.map +1 -0
- package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.js +716 -0
- package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.js.map +1 -0
- package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.d.ts +104 -0
- package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.d.ts.map +1 -0
- package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.js +595 -0
- package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.js.map +1 -0
- package/dist/agents/registry.d.ts.map +1 -1
- package/dist/agents/registry.js +2 -2
- package/dist/agents/registry.js.map +1 -1
- package/dist/cli/commands/analytics/agent-labels.d.ts.map +1 -1
- package/dist/cli/commands/analytics/agent-labels.js +1 -0
- package/dist/cli/commands/analytics/agent-labels.js.map +1 -1
- package/dist/cli/commands/analytics/cost/usage-readers.d.ts +24 -0
- package/dist/cli/commands/analytics/cost/usage-readers.d.ts.map +1 -1
- package/dist/cli/commands/analytics/cost/usage-readers.js +199 -54
- package/dist/cli/commands/analytics/cost/usage-readers.js.map +1 -1
- package/dist/cli/commands/analytics/index.js +1 -0
- package/dist/cli/commands/analytics/index.js.map +1 -1
- package/dist/cli/commands/analytics/native-loader.d.ts +21 -4
- package/dist/cli/commands/analytics/native-loader.d.ts.map +1 -1
- package/dist/cli/commands/analytics/native-loader.js +250 -96
- package/dist/cli/commands/analytics/native-loader.js.map +1 -1
- package/dist/cli/commands/analytics/report/client/app.js +47 -3
- package/dist/cli/commands/analytics/report/payload-builder.d.ts.map +1 -1
- package/dist/cli/commands/analytics/report/payload-builder.js +25 -2
- package/dist/cli/commands/analytics/report/payload-builder.js.map +1 -1
- package/dist/cli/commands/analytics/report/types.d.ts +1 -0
- package/dist/cli/commands/analytics/report/types.d.ts.map +1 -1
- package/dist/cli/commands/hook.d.ts.map +1 -1
- package/dist/cli/commands/hook.js +71 -29
- package/dist/cli/commands/hook.js.map +1 -1
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +7 -5
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/list.d.ts.map +1 -1
- package/dist/cli/commands/list.js +3 -1
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/proxy/connectors/desktop.d.ts +94 -4
- package/dist/cli/commands/proxy/connectors/desktop.d.ts.map +1 -1
- package/dist/cli/commands/proxy/connectors/desktop.js +244 -17
- package/dist/cli/commands/proxy/connectors/desktop.js.map +1 -1
- package/dist/cli/commands/proxy/connectors/managed-mcp-remote.d.ts +25 -0
- package/dist/cli/commands/proxy/connectors/managed-mcp-remote.d.ts.map +1 -1
- package/dist/cli/commands/proxy/connectors/managed-mcp-remote.js +59 -1
- package/dist/cli/commands/proxy/connectors/managed-mcp-remote.js.map +1 -1
- package/dist/cli/commands/proxy/index.d.ts.map +1 -1
- package/dist/cli/commands/proxy/index.js +10 -1
- package/dist/cli/commands/proxy/index.js.map +1 -1
- package/dist/cli/commands/uninstall.d.ts.map +1 -1
- package/dist/cli/commands/uninstall.js +5 -3
- package/dist/cli/commands/uninstall.js.map +1 -1
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +5 -3
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/first-time.d.ts.map +1 -1
- package/dist/cli/first-time.js +7 -6
- package/dist/cli/first-time.js.map +1 -1
- package/dist/providers/core/auth-validation.d.ts +7 -2
- package/dist/providers/core/auth-validation.d.ts.map +1 -1
- package/dist/providers/core/auth-validation.js +11 -5
- package/dist/providers/core/auth-validation.js.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts +8 -3
- package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js +46 -11
- package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.d.ts +23 -13
- package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.d.ts.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js +75 -18
- package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.d.ts +21 -0
- package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.d.ts.map +1 -0
- package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.js +133 -0
- package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.js.map +1 -0
- package/dist/providers/plugins/sso/proxy/plugins/header-injection.plugin.js +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/header-injection.plugin.js.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +2 -1
- package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/index.js +4 -2
- package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/types.d.ts +11 -0
- package/dist/providers/plugins/sso/proxy/plugins/types.d.ts.map +1 -1
- package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts +2 -0
- package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts.map +1 -1
- package/dist/providers/plugins/sso/proxy/sso.proxy.js +37 -1
- package/dist/providers/plugins/sso/proxy/sso.proxy.js.map +1 -1
- package/dist/providers/plugins/sso/session/SessionSyncer.d.ts.map +1 -1
- package/dist/providers/plugins/sso/session/SessionSyncer.js +13 -0
- package/dist/providers/plugins/sso/session/SessionSyncer.js.map +1 -1
- package/dist/providers/plugins/sso/session/processors/conversations/syncProcessor.js +6 -0
- package/dist/providers/plugins/sso/session/processors/conversations/syncProcessor.js.map +1 -1
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.d.ts +0 -6
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.d.ts.map +1 -1
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.js +28 -19
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.js.map +1 -1
- package/dist/telemetry/clients/claude-desktop/claude-desktop.discovery.d.ts.map +1 -1
- package/dist/telemetry/clients/claude-desktop/claude-desktop.discovery.js +13 -1
- package/dist/telemetry/clients/claude-desktop/claude-desktop.discovery.js.map +1 -1
- package/dist/telemetry/clients/claude-desktop/claude-desktop.paths.d.ts +12 -0
- package/dist/telemetry/clients/claude-desktop/claude-desktop.paths.d.ts.map +1 -1
- package/dist/telemetry/clients/claude-desktop/claude-desktop.paths.js +28 -1
- package/dist/telemetry/clients/claude-desktop/claude-desktop.paths.js.map +1 -1
- package/dist/utils/interactive.d.ts +14 -0
- package/dist/utils/interactive.d.ts.map +1 -0
- package/dist/utils/interactive.js +16 -0
- package/dist/utils/interactive.js.map +1 -0
- package/package.json +6 -4
- package/scripts/copy-plugins.js +6 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort TypeScript shapes for Pi session JSONL entries.
|
|
3
|
+
*
|
|
4
|
+
* Based on the shipped Pi CLI's v3 session format
|
|
5
|
+
* (packages/coding-agent/src/core/session-manager.ts), not the v4 harness format.
|
|
6
|
+
* Kept local so the plugin does not depend on the upstream Pi packages.
|
|
7
|
+
*/
|
|
8
|
+
export interface PiSessionHeader {
|
|
9
|
+
type: 'session';
|
|
10
|
+
version?: number;
|
|
11
|
+
id: string;
|
|
12
|
+
timestamp: string;
|
|
13
|
+
cwd: string;
|
|
14
|
+
parentSession?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PiEntryBase {
|
|
17
|
+
type: string;
|
|
18
|
+
id: string;
|
|
19
|
+
parentId: string | null;
|
|
20
|
+
timestamp: string;
|
|
21
|
+
}
|
|
22
|
+
export interface PiTextContent {
|
|
23
|
+
type: 'text';
|
|
24
|
+
text: string;
|
|
25
|
+
}
|
|
26
|
+
/** An image block, carried alongside text wherever Pi accepts rich content. */
|
|
27
|
+
export interface PiImageContent {
|
|
28
|
+
type: 'image';
|
|
29
|
+
data: string;
|
|
30
|
+
mimeType: string;
|
|
31
|
+
}
|
|
32
|
+
export interface PiToolCall {
|
|
33
|
+
type: 'toolCall';
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
arguments: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface PiUserMessage {
|
|
39
|
+
role: 'user';
|
|
40
|
+
content: string | (PiTextContent | unknown)[];
|
|
41
|
+
timestamp: number;
|
|
42
|
+
}
|
|
43
|
+
export interface PiAssistantMessage {
|
|
44
|
+
role: 'assistant';
|
|
45
|
+
content: (PiTextContent | PiToolCall | unknown)[];
|
|
46
|
+
model?: string;
|
|
47
|
+
usage?: Record<string, unknown>;
|
|
48
|
+
stopReason?: string;
|
|
49
|
+
errorMessage?: string;
|
|
50
|
+
timestamp: number;
|
|
51
|
+
}
|
|
52
|
+
export interface PiToolResultMessage {
|
|
53
|
+
role: 'toolResult';
|
|
54
|
+
toolCallId: string;
|
|
55
|
+
toolName: string;
|
|
56
|
+
content: (PiTextContent | unknown)[] | unknown;
|
|
57
|
+
details?: Record<string, unknown>;
|
|
58
|
+
usage?: Record<string, unknown>;
|
|
59
|
+
isError: boolean;
|
|
60
|
+
timestamp: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A `!command` shell escape the user ran directly, without the model. Pi persists the
|
|
64
|
+
* command and its full output rather than a tool call/result pair.
|
|
65
|
+
*/
|
|
66
|
+
export interface PiBashExecutionMessage {
|
|
67
|
+
role: 'bashExecution';
|
|
68
|
+
command: string;
|
|
69
|
+
output: string;
|
|
70
|
+
/** Absent when the command was cancelled before it could report a status. */
|
|
71
|
+
exitCode?: number;
|
|
72
|
+
cancelled: boolean;
|
|
73
|
+
truncated: boolean;
|
|
74
|
+
fullOutputPath?: string;
|
|
75
|
+
/** True for `!!`-prefixed commands, whose output is withheld from the model. */
|
|
76
|
+
excludeFromContext?: boolean;
|
|
77
|
+
timestamp: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A message an extension injected through `sendMessage()`. `customType` is the extension's
|
|
81
|
+
* own tag; the shape of `details` is whatever that extension defined.
|
|
82
|
+
*/
|
|
83
|
+
export interface PiCustomMessage {
|
|
84
|
+
role: 'custom';
|
|
85
|
+
customType: string;
|
|
86
|
+
content: string | (PiTextContent | PiImageContent)[];
|
|
87
|
+
display: boolean;
|
|
88
|
+
details?: unknown;
|
|
89
|
+
timestamp: number;
|
|
90
|
+
}
|
|
91
|
+
/** Written when the conversation returns from a branch. `summary` is conversation content. */
|
|
92
|
+
export interface PiBranchSummaryMessage {
|
|
93
|
+
role: 'branchSummary';
|
|
94
|
+
summary: string;
|
|
95
|
+
fromId: string;
|
|
96
|
+
timestamp: number;
|
|
97
|
+
}
|
|
98
|
+
/** Written when Pi compacts history. `summary` is conversation content. */
|
|
99
|
+
export interface PiCompactionSummaryMessage {
|
|
100
|
+
role: 'compactionSummary';
|
|
101
|
+
summary: string;
|
|
102
|
+
tokensBefore: number;
|
|
103
|
+
timestamp: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Every role Pi can persist under a `message` entry.
|
|
107
|
+
*
|
|
108
|
+
* Mirrors upstream's `AgentMessage` — the base LLM roles plus the four the coding agent
|
|
109
|
+
* declaration-merges into `CustomAgentMessages` (`core/messages.ts`). The last three are
|
|
110
|
+
* not read anywhere yet and every consumer skips them, but they must be in the union
|
|
111
|
+
* anyway: the guards below are declared over it, so a union narrower than the data makes
|
|
112
|
+
* any future exhaustive branch unsound — and two of these carry conversation text that
|
|
113
|
+
* must be handled deliberately rather than by falling through.
|
|
114
|
+
*/
|
|
115
|
+
export type PiAgentMessage = PiUserMessage | PiAssistantMessage | PiToolResultMessage | PiBashExecutionMessage | PiCustomMessage | PiBranchSummaryMessage | PiCompactionSummaryMessage;
|
|
116
|
+
export interface PiMessageEntry extends PiEntryBase {
|
|
117
|
+
type: 'message';
|
|
118
|
+
message: PiAgentMessage;
|
|
119
|
+
}
|
|
120
|
+
/** Written when the user switches models mid-session, e.g. through `/model`. */
|
|
121
|
+
export interface PiModelChangeEntry extends PiEntryBase {
|
|
122
|
+
type: 'model_change';
|
|
123
|
+
modelId: string;
|
|
124
|
+
provider?: string;
|
|
125
|
+
}
|
|
126
|
+
export type PiEntry = PiMessageEntry | PiModelChangeEntry | PiEntryBase;
|
|
127
|
+
export declare function isPiMessageEntry(entry: PiEntry): entry is PiMessageEntry;
|
|
128
|
+
export declare function isPiUserMessage(message: PiAgentMessage): message is PiUserMessage;
|
|
129
|
+
export declare function isPiAssistantMessage(message: PiAgentMessage): message is PiAssistantMessage;
|
|
130
|
+
export declare function isPiToolResultMessage(message: PiAgentMessage): message is PiToolResultMessage;
|
|
131
|
+
export declare function isPiBashExecutionMessage(message: PiAgentMessage): message is PiBashExecutionMessage;
|
|
132
|
+
export declare function isPiModelChangeEntry(entry: PiEntry): entry is PiModelChangeEntry;
|
|
133
|
+
/**
|
|
134
|
+
* Normalize the tool calls carried by an assistant message.
|
|
135
|
+
*
|
|
136
|
+
* Shared by the metrics processor and the named-invocation extractor so both tolerate
|
|
137
|
+
* the same two serializations: the flat `{type:'toolCall', id, name}` the Pi runtime
|
|
138
|
+
* writes, and a defensive `{type:'toolCall', toolCall:{...}}` wrapper in case a Pi
|
|
139
|
+
* version or provider nests it.
|
|
140
|
+
*/
|
|
141
|
+
export declare function extractPiToolCalls(message: PiAssistantMessage): PiToolCall[];
|
|
142
|
+
export declare function isPiSessionHeader(value: unknown): value is PiSessionHeader;
|
|
143
|
+
//# sourceMappingURL=pi.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi.types.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC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packages/coding-agent/src/core/session-manager.ts), not the v4 harness format.
|
|
6
|
+
* Kept local so the plugin does not depend on the upstream Pi packages.
|
|
7
|
+
*/
|
|
8
|
+
export function isPiMessageEntry(entry) {
|
|
9
|
+
return (entry !== null &&
|
|
10
|
+
typeof entry === 'object' &&
|
|
11
|
+
entry.type === 'message' &&
|
|
12
|
+
'message' in entry &&
|
|
13
|
+
entry.message !== null &&
|
|
14
|
+
typeof entry.message === 'object');
|
|
15
|
+
}
|
|
16
|
+
export function isPiUserMessage(message) {
|
|
17
|
+
return message.role === 'user';
|
|
18
|
+
}
|
|
19
|
+
export function isPiAssistantMessage(message) {
|
|
20
|
+
return message.role === 'assistant';
|
|
21
|
+
}
|
|
22
|
+
export function isPiToolResultMessage(message) {
|
|
23
|
+
return message.role === 'toolResult';
|
|
24
|
+
}
|
|
25
|
+
export function isPiBashExecutionMessage(message) {
|
|
26
|
+
return message.role === 'bashExecution';
|
|
27
|
+
}
|
|
28
|
+
export function isPiModelChangeEntry(entry) {
|
|
29
|
+
return (entry !== null &&
|
|
30
|
+
typeof entry === 'object' &&
|
|
31
|
+
entry.type === 'model_change' &&
|
|
32
|
+
typeof entry.modelId === 'string' &&
|
|
33
|
+
entry.modelId.length > 0);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Normalize the tool calls carried by an assistant message.
|
|
37
|
+
*
|
|
38
|
+
* Shared by the metrics processor and the named-invocation extractor so both tolerate
|
|
39
|
+
* the same two serializations: the flat `{type:'toolCall', id, name}` the Pi runtime
|
|
40
|
+
* writes, and a defensive `{type:'toolCall', toolCall:{...}}` wrapper in case a Pi
|
|
41
|
+
* version or provider nests it.
|
|
42
|
+
*/
|
|
43
|
+
export function extractPiToolCalls(message) {
|
|
44
|
+
if (!Array.isArray(message.content)) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
return message.content
|
|
48
|
+
.map((part) => {
|
|
49
|
+
if (typeof part !== 'object' || part === null) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const flat = part;
|
|
53
|
+
if (flat.type === 'toolCall' && typeof flat.id === 'string' && typeof flat.name === 'string') {
|
|
54
|
+
return flat;
|
|
55
|
+
}
|
|
56
|
+
const nested = part.toolCall;
|
|
57
|
+
if (nested && typeof nested.id === 'string' && typeof nested.name === 'string') {
|
|
58
|
+
return nested;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
})
|
|
62
|
+
.filter((toolCall) => toolCall !== undefined);
|
|
63
|
+
}
|
|
64
|
+
export function isPiSessionHeader(value) {
|
|
65
|
+
if (!value || typeof value !== 'object')
|
|
66
|
+
return false;
|
|
67
|
+
const header = value;
|
|
68
|
+
return (header.type === 'session' &&
|
|
69
|
+
typeof header.id === 'string' &&
|
|
70
|
+
header.id.length > 0 &&
|
|
71
|
+
typeof header.timestamp === 'string' &&
|
|
72
|
+
typeof header.cwd === 'string');
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=pi.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi.types.js","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgJH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,CACL,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,IAAI,KAAK,SAAS;QACxB,SAAS,IAAI,KAAK;QAClB,KAAK,CAAC,OAAO,KAAK,IAAI;QACtB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAuB;IACrD,OAAO,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAuB;IAC1D,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC;AACtC,CAAC;AAED,MAAM,U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AAS,CAAC;IACnB,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,QAAQ,EAA0B,EAAE,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,SAAS;QACzB,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ;QAC7B,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC;QACpB,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ;QACpC,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,CAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map Pi tool calls/results to CodeMie file-operation records.
|
|
3
|
+
*/
|
|
4
|
+
import type { FileOperation } from '../../../core/metrics/types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Count added/removed lines in a unified diff string.
|
|
7
|
+
*/
|
|
8
|
+
export declare function countPiDiffLines(patch: unknown): {
|
|
9
|
+
linesAdded: number;
|
|
10
|
+
linesRemoved: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Build a file-operation record for a Pi tool call, or undefined if the tool
|
|
14
|
+
* is not a tracked file/search tool.
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractPiFileOperation(toolName: string, toolArguments?: Record<string, unknown>, toolResultDetails?: Record<string, unknown>): FileOperation | undefined;
|
|
17
|
+
//# sourceMappingURL=pi-file-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-file-operations.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/pi/session/pi-file-operations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAqB,MAAM,gCAAgC,CAAC;AA4BvF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAgB7F;AAYD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC1C,aAAa,GAAG,SAAS,CAsC3B"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map Pi tool calls/results to CodeMie file-operation records.
|
|
3
|
+
*/
|
|
4
|
+
import { extractFormat, detectLanguage } from '../../../../utils/file-operations.js';
|
|
5
|
+
import { logger } from '../../../../utils/logger.js';
|
|
6
|
+
// Pi's closed tool registry is read | bash | edit | write | grep | find | ls
|
|
7
|
+
// (packages/coding-agent/src/core/tools/index.ts). `find` is Pi's glob-by-filename
|
|
8
|
+
// tool. `bash` is intentionally absent: it mutates files arbitrarily (`sed -i`,
|
|
9
|
+
// `>`, `mv`, `git apply`, etc.) and no reliable file-effect signal is persisted.
|
|
10
|
+
// `write` creates OR overwrites; the result does not record which occurred.
|
|
11
|
+
//
|
|
12
|
+
// Tool names are matched case-sensitively: extension tools may register arbitrary
|
|
13
|
+
// names, and lowercasing would misclassify an extension named `Write` as the
|
|
14
|
+
// built-in write tool.
|
|
15
|
+
//
|
|
16
|
+
// There is deliberately no 'delete' mapping, so `files_deleted` stays at 0. That is
|
|
17
|
+
// parity, not a gap: Pi ships no delete tool, and Claude's own TOOL_TYPE_MAP
|
|
18
|
+
// (claude/session/claude-file-operation.ts) has no delete entry either. Inferring
|
|
19
|
+
// deletions from `rm` inside a bash command would report a number Claude never reports
|
|
20
|
+
// and would be wrong whenever the command fails, is conditional, or is a dry run.
|
|
21
|
+
const TOOL_TYPE_MAP = {
|
|
22
|
+
read: 'read',
|
|
23
|
+
edit: 'edit',
|
|
24
|
+
write: 'write',
|
|
25
|
+
grep: 'grep',
|
|
26
|
+
ls: 'read',
|
|
27
|
+
find: 'glob',
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Count added/removed lines in a unified diff string.
|
|
31
|
+
*/
|
|
32
|
+
export function countPiDiffLines(patch) {
|
|
33
|
+
if (typeof patch !== 'string' || patch.length === 0) {
|
|
34
|
+
return { linesAdded: 0, linesRemoved: 0 };
|
|
35
|
+
}
|
|
36
|
+
let linesAdded = 0;
|
|
37
|
+
let linesRemoved = 0;
|
|
38
|
+
for (const line of patch.split('\n')) {
|
|
39
|
+
if (line.startsWith('@@'))
|
|
40
|
+
continue;
|
|
41
|
+
if (line.startsWith('+++ ') || line.startsWith('--- '))
|
|
42
|
+
continue;
|
|
43
|
+
if (line.startsWith('+'))
|
|
44
|
+
linesAdded++;
|
|
45
|
+
else if (line.startsWith('-'))
|
|
46
|
+
linesRemoved++;
|
|
47
|
+
}
|
|
48
|
+
return { linesAdded, linesRemoved };
|
|
49
|
+
}
|
|
50
|
+
function extractPath(args, details) {
|
|
51
|
+
const fromArgs = args?.path ?? args?.filePath ?? args?.file_path;
|
|
52
|
+
if (typeof fromArgs === 'string')
|
|
53
|
+
return fromArgs;
|
|
54
|
+
const fromDetails = details?.path ?? details?.filePath ?? details?.file_path;
|
|
55
|
+
if (typeof fromDetails === 'string')
|
|
56
|
+
return fromDetails;
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Build a file-operation record for a Pi tool call, or undefined if the tool
|
|
61
|
+
* is not a tracked file/search tool.
|
|
62
|
+
*/
|
|
63
|
+
export function extractPiFileOperation(toolName, toolArguments, toolResultDetails) {
|
|
64
|
+
const type = TOOL_TYPE_MAP[toolName];
|
|
65
|
+
if (!type) {
|
|
66
|
+
logger.debug(`[pi-file-ops] No file-operation mapping for tool: ${toolName}`);
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const operation = { type };
|
|
70
|
+
const filePath = extractPath(toolArguments, toolResultDetails);
|
|
71
|
+
if (filePath) {
|
|
72
|
+
operation.path = filePath;
|
|
73
|
+
operation.format = extractFormat(filePath);
|
|
74
|
+
operation.language = detectLanguage(filePath);
|
|
75
|
+
}
|
|
76
|
+
if (typeof toolArguments?.pattern === 'string') {
|
|
77
|
+
operation.pattern = toolArguments.pattern;
|
|
78
|
+
}
|
|
79
|
+
if (toolName === 'write') {
|
|
80
|
+
const content = toolArguments?.content;
|
|
81
|
+
if (typeof content === 'string' && content.length > 0) {
|
|
82
|
+
// Strip a single trailing newline so newline-terminated source files are
|
|
83
|
+
// not over-counted by one.
|
|
84
|
+
const normalized = content.endsWith('\n') ? content.slice(0, -1) : content;
|
|
85
|
+
operation.linesAdded = normalized.split('\n').length;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (toolName === 'edit') {
|
|
89
|
+
const patch = toolResultDetails?.diff ?? toolResultDetails?.patch;
|
|
90
|
+
const { linesAdded, linesRemoved } = countPiDiffLines(patch);
|
|
91
|
+
if (linesAdded > 0)
|
|
92
|
+
operation.linesAdded = linesAdded;
|
|
93
|
+
if (linesRemoved > 0)
|
|
94
|
+
operation.linesRemoved = linesRemoved;
|
|
95
|
+
}
|
|
96
|
+
return operation;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=pi-file-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-file-operations.js","sourceRoot":"","sources":["../../../../../src/agents/plugins/pi/session/pi-file-operations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,6EAA6E;AAC7E,mFAAmF;AACnF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,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAC3E,SAAS,CAAC,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QACvD,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,iBAAiB,EAAE,IAAI,IAAI,iBAAiB,EAAE,KAAK,CAAC;QAClE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC7D,IAAI,UAAU,GAAG,CAAC;YAAE,SAAS,CAAC,UAAU,GAAG,UAAU,CAAC;QACtD,IAAI,YAAY,GAAG,CAAC;YAAE,SAAS,CAAC,YAAY,GAAG,YAAY,CAAC;IAC9D,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Pi named-invocation extraction.
|
|
3
|
+
*
|
|
4
|
+
* Pulls the *names* of invoked skills and subagents out of Pi session JSONL entries, so
|
|
5
|
+
* the analytics report shows the same per-name breakdown Claude and Codex already do.
|
|
6
|
+
*
|
|
7
|
+
* - Skills: the `<skill name="..." location="...">` wrapper Pi prepends to the user
|
|
8
|
+
* message when a `/skill:<name>` command expands (upstream
|
|
9
|
+
* `core/agent-session.ts` builds it, and parses it back with the same shape).
|
|
10
|
+
* - Agents: an assistant `toolCall` named `subagent`, from the `pi-subagents` package
|
|
11
|
+
* this plugin installs. The child's name is `arguments.agent`.
|
|
12
|
+
* - Commands: always empty here. Pi expands a prompt template into plain user text before
|
|
13
|
+
* persisting it, so `/review` never reaches the JSONL and no regex over the
|
|
14
|
+
* transcript can recover it. Those counts come from the run ledger, which the
|
|
15
|
+
* CodeMie extension records from inside Pi at input time.
|
|
16
|
+
*
|
|
17
|
+
* @see ../pi.extension.ts — PiRunLedger.commandInvocations
|
|
18
|
+
*/
|
|
19
|
+
import type { NamedInvocationCounts } from '../../claude/session/claude-named-invocations.js';
|
|
20
|
+
export type { NamedInvocationCounts };
|
|
21
|
+
export interface PiSkillWrapper {
|
|
22
|
+
/** Skill name from the wrapper, or undefined when the text carries no wrapper. */
|
|
23
|
+
name?: string;
|
|
24
|
+
/** The prompt the user typed after the wrapper, or the original text when there was none. */
|
|
25
|
+
rest: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Split Pi's `<skill>` wrapper off a user text block.
|
|
29
|
+
*
|
|
30
|
+
* Single source of truth for the wrapper shape: the metrics processor consumes `rest`
|
|
31
|
+
* so the skill body is not reported as a user prompt, and the extractor below consumes
|
|
32
|
+
* `name`.
|
|
33
|
+
*
|
|
34
|
+
* The closing line is searched for from the END of the text, because the body between the
|
|
35
|
+
* wrapper's tags is a file the user wrote and may contain `</skill>` lines of its own — a
|
|
36
|
+
* skill documenting Pi's own format does. Everything after the LAST closing line, on the
|
|
37
|
+
* other hand, can only be the arguments the user typed: the real closer always leaves a
|
|
38
|
+
* well-formed tail behind it, so no closer after it exists to be picked instead.
|
|
39
|
+
*
|
|
40
|
+
* Anything else fails closed with no name and no text. `rest` leaves the machine — it is
|
|
41
|
+
* uploaded as the user's prompt and titles the analytics session — so a wrapper this parser
|
|
42
|
+
* cannot read unambiguously must cost a title rather than a private file's contents.
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseSkillWrapper(text: string): PiSkillWrapper;
|
|
45
|
+
/**
|
|
46
|
+
* Extract skill and agent name counts from Pi session entries.
|
|
47
|
+
*
|
|
48
|
+
* Safe against missing or malformed fields — anything that is not a recognized shape is
|
|
49
|
+
* skipped. `commandInvocations` is always empty; see the module comment.
|
|
50
|
+
*/
|
|
51
|
+
export declare function extractPiNamedInvocations(entries: readonly unknown[]): NamedInvocationCounts;
|
|
52
|
+
//# sourceMappingURL=pi-named-invocations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-named-invocations.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/pi/session/pi-named-invocations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kDAAkD,CAAC;AAU9F,YAAY,EAAE,qBAAqB,EAAE,CAAC;AA8CtC,MAAM,WAAW,cAAc;IAC7B,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6FAA6F;IAC7F,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CA8B9D;AA4DD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,GAAG,qBAAqB,CA8B5F"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Pi named-invocation extraction.
|
|
3
|
+
*
|
|
4
|
+
* Pulls the *names* of invoked skills and subagents out of Pi session JSONL entries, so
|
|
5
|
+
* the analytics report shows the same per-name breakdown Claude and Codex already do.
|
|
6
|
+
*
|
|
7
|
+
* - Skills: the `<skill name="..." location="...">` wrapper Pi prepends to the user
|
|
8
|
+
* message when a `/skill:<name>` command expands (upstream
|
|
9
|
+
* `core/agent-session.ts` builds it, and parses it back with the same shape).
|
|
10
|
+
* - Agents: an assistant `toolCall` named `subagent`, from the `pi-subagents` package
|
|
11
|
+
* this plugin installs. The child's name is `arguments.agent`.
|
|
12
|
+
* - Commands: always empty here. Pi expands a prompt template into plain user text before
|
|
13
|
+
* persisting it, so `/review` never reaches the JSONL and no regex over the
|
|
14
|
+
* transcript can recover it. Those counts come from the run ledger, which the
|
|
15
|
+
* CodeMie extension records from inside Pi at input time.
|
|
16
|
+
*
|
|
17
|
+
* @see ../pi.extension.ts — PiRunLedger.commandInvocations
|
|
18
|
+
*/
|
|
19
|
+
import { logger } from '../../../../utils/logger.js';
|
|
20
|
+
import { extractPiToolCalls, isPiAssistantMessage, isPiMessageEntry, isPiUserMessage, } from '../pi.types.js';
|
|
21
|
+
/** Name of the tool `pi-subagents` registers for delegating to a child agent. */
|
|
22
|
+
const SUBAGENT_TOOL = 'subagent';
|
|
23
|
+
/**
|
|
24
|
+
* The opening of Pi's skill wrapper, which only Pi itself writes (`_expandSkillCommand` in
|
|
25
|
+
* `core/agent-session.ts`). Group 1 is the skill name.
|
|
26
|
+
*
|
|
27
|
+
* Matching it is also what makes {@link parseSkillWrapper} fail closed: once the opening is
|
|
28
|
+
* there the text is a skill file's body, so a wrapper this parser cannot finish reading is
|
|
29
|
+
* dropped. That costs one prompt title; returning it would upload a private file.
|
|
30
|
+
*/
|
|
31
|
+
const SKILL_WRAPPER_OPENING = /^<skill name="([^"]+)" location="[^"]+">\n/;
|
|
32
|
+
/**
|
|
33
|
+
* The line that closes the wrapper. Pi writes it on a line of its own, so the leading
|
|
34
|
+
* newline is part of the delimiter.
|
|
35
|
+
*/
|
|
36
|
+
const SKILL_WRAPPER_CLOSING = '\n</skill>';
|
|
37
|
+
/**
|
|
38
|
+
* `agent: "<name>"` inside a `workflowScript`. The script is an opaque JavaScript string
|
|
39
|
+
* (`await runs.run(key, { agent, task })`), not a structured step list, so this is the
|
|
40
|
+
* only handle on the children it launches. It counts one invocation per launch site:
|
|
41
|
+
* a script that loops over the same site undercounts, and a computed agent name is
|
|
42
|
+
* missed entirely. Both are preferable to attributing a workflow to no agent at all.
|
|
43
|
+
*/
|
|
44
|
+
const WORKFLOW_AGENT = /\bagent\s*:\s*(['"`])([^'"`\n]+)\1/g;
|
|
45
|
+
/**
|
|
46
|
+
* The one `action` that launches a child rather than managing a record.
|
|
47
|
+
*
|
|
48
|
+
* `pi-subagents` rejects a `schedule.create` that does not name exactly one target —
|
|
49
|
+
* `agent` (with an optional `task`) or a `workflowScript` — and arms it to run later
|
|
50
|
+
* (`runs/background/scheduled-runs.ts`, `sanitizeTarget`). The launch is counted here, at
|
|
51
|
+
* the call that asked for it, because the firings themselves happen outside any CodeMie
|
|
52
|
+
* session and would otherwise be attributed to nothing. `schedule.run`/`schedule.run-due`
|
|
53
|
+
* stay management: they address an existing schedule by id and carry no agent name.
|
|
54
|
+
*/
|
|
55
|
+
const DEFERRED_LAUNCH_ACTION = 'schedule.create';
|
|
56
|
+
function bump(map, key) {
|
|
57
|
+
map[key] = (map[key] || 0) + 1;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Split Pi's `<skill>` wrapper off a user text block.
|
|
61
|
+
*
|
|
62
|
+
* Single source of truth for the wrapper shape: the metrics processor consumes `rest`
|
|
63
|
+
* so the skill body is not reported as a user prompt, and the extractor below consumes
|
|
64
|
+
* `name`.
|
|
65
|
+
*
|
|
66
|
+
* The closing line is searched for from the END of the text, because the body between the
|
|
67
|
+
* wrapper's tags is a file the user wrote and may contain `</skill>` lines of its own — a
|
|
68
|
+
* skill documenting Pi's own format does. Everything after the LAST closing line, on the
|
|
69
|
+
* other hand, can only be the arguments the user typed: the real closer always leaves a
|
|
70
|
+
* well-formed tail behind it, so no closer after it exists to be picked instead.
|
|
71
|
+
*
|
|
72
|
+
* Anything else fails closed with no name and no text. `rest` leaves the machine — it is
|
|
73
|
+
* uploaded as the user's prompt and titles the analytics session — so a wrapper this parser
|
|
74
|
+
* cannot read unambiguously must cost a title rather than a private file's contents.
|
|
75
|
+
*/
|
|
76
|
+
export function parseSkillWrapper(text) {
|
|
77
|
+
const opening = SKILL_WRAPPER_OPENING.exec(text);
|
|
78
|
+
if (!opening) {
|
|
79
|
+
return { rest: text };
|
|
80
|
+
}
|
|
81
|
+
// The opening's own trailing newline can double as the closing line's leading one, for a
|
|
82
|
+
// wrapper around an empty body. Nothing before that is part of the wrapper.
|
|
83
|
+
const earliestClosing = opening[0].length - 1;
|
|
84
|
+
for (let closing = text.lastIndexOf(SKILL_WRAPPER_CLOSING); closing >= earliestClosing; closing = text.lastIndexOf(SKILL_WRAPPER_CLOSING, closing - 1)) {
|
|
85
|
+
// Upstream appends `\n\n<args>` only when the `/skill:<name>` invocation carried
|
|
86
|
+
// arguments, so a well-formed tail is either nothing at all or exactly that.
|
|
87
|
+
const tail = text.slice(closing + SKILL_WRAPPER_CLOSING.length);
|
|
88
|
+
if (tail === '') {
|
|
89
|
+
return { name: opening[1], rest: '' };
|
|
90
|
+
}
|
|
91
|
+
const args = tail.startsWith('\n\n') ? tail.slice(2).trim() : '';
|
|
92
|
+
if (args) {
|
|
93
|
+
return { name: opening[1], rest: args };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Name only: the body is exactly what must not be logged. Without this line a change to
|
|
97
|
+
// Pi's wrapper would zero prompts and skill counts at once, silently.
|
|
98
|
+
logger.debug('[pi-skills] Unreadable skill wrapper; dropping the text', { skill: opening[1] });
|
|
99
|
+
return { rest: '' };
|
|
100
|
+
}
|
|
101
|
+
/** Every text block carried by a user message, whatever content shape Pi used. */
|
|
102
|
+
function userTextBlocks(message) {
|
|
103
|
+
if (typeof message.content === 'string') {
|
|
104
|
+
return [message.content];
|
|
105
|
+
}
|
|
106
|
+
if (!Array.isArray(message.content)) {
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
const texts = [];
|
|
110
|
+
for (const part of message.content) {
|
|
111
|
+
if (typeof part !== 'object' || part === null)
|
|
112
|
+
continue;
|
|
113
|
+
const typed = part;
|
|
114
|
+
if (typed.type === 'text' && typeof typed.text === 'string') {
|
|
115
|
+
texts.push(typed.text);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return texts;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Child agent names launched by one `subagent` tool call.
|
|
122
|
+
*
|
|
123
|
+
* A call carrying `action` is management or control (`status`, `stop`, `create`, ...);
|
|
124
|
+
* its `agent` names the record being managed, not a child being run, so it counts
|
|
125
|
+
* nothing. {@link DEFERRED_LAUNCH_ACTION} is the exception.
|
|
126
|
+
*/
|
|
127
|
+
function subagentNames(args) {
|
|
128
|
+
if (!args || typeof args !== 'object') {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
if (typeof args.action === 'string') {
|
|
132
|
+
const action = args.action.trim();
|
|
133
|
+
if (action && action !== DEFERRED_LAUNCH_ACTION) {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const names = [];
|
|
138
|
+
const single = args.agent;
|
|
139
|
+
if (typeof single === 'string' && single.trim()) {
|
|
140
|
+
names.push(single.trim());
|
|
141
|
+
}
|
|
142
|
+
const script = args.workflowScript;
|
|
143
|
+
if (typeof script === 'string') {
|
|
144
|
+
WORKFLOW_AGENT.lastIndex = 0;
|
|
145
|
+
let match;
|
|
146
|
+
while ((match = WORKFLOW_AGENT.exec(script)) !== null) {
|
|
147
|
+
const name = match[2].trim();
|
|
148
|
+
if (name)
|
|
149
|
+
names.push(name);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return names;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Extract skill and agent name counts from Pi session entries.
|
|
156
|
+
*
|
|
157
|
+
* Safe against missing or malformed fields — anything that is not a recognized shape is
|
|
158
|
+
* skipped. `commandInvocations` is always empty; see the module comment.
|
|
159
|
+
*/
|
|
160
|
+
export function extractPiNamedInvocations(entries) {
|
|
161
|
+
const skillInvocations = {};
|
|
162
|
+
const agentInvocations = {};
|
|
163
|
+
for (const raw of entries) {
|
|
164
|
+
const entry = raw;
|
|
165
|
+
if (!isPiMessageEntry(entry)) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const message = entry.message;
|
|
169
|
+
if (isPiUserMessage(message)) {
|
|
170
|
+
for (const text of userTextBlocks(message)) {
|
|
171
|
+
const { name } = parseSkillWrapper(text);
|
|
172
|
+
if (name)
|
|
173
|
+
bump(skillInvocations, name);
|
|
174
|
+
}
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (isPiAssistantMessage(message)) {
|
|
178
|
+
for (const toolCall of extractPiToolCalls(message)) {
|
|
179
|
+
if (toolCall.name !== SUBAGENT_TOOL)
|
|
180
|
+
continue;
|
|
181
|
+
for (const agent of subagentNames(toolCall.arguments)) {
|
|
182
|
+
bump(agentInvocations, agent);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return { skillInvocations, agentInvocations, commandInvocations: {} };
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=pi-named-invocations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-named-invocations.js","sourceRoot":"","sources":["../../../../../src/agents/plugins/pi/session/pi-named-invocations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAGhB,MAAM,gBAAgB,CAAC;AAIxB,iFAAiF;AACjF,MAAM,aAAa,GAAG,UAAU,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,qBAAqB,GAAG,4CAA4C,CAAC;AAE3E;;;GAGG;AACH,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,qCAAqC,CAAC;AAE7D;;;;;;;;;GASG;AACH,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAEjD,SAAS,IAAI,CAAC,GAA2B,EAAE,GAAW;IACpD,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC;AASD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,iB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C,OAAO,CAAC,EAAE,CAAC;YAClC,KAAK,MAAM,QAAQ,IAAI,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnD,IAAI,QAAQ,CAAC,IAAI,KAAK,aAAa;oBAAE,SAAS;gBAC9C,KAAK,MAAM,KAAK,IAAI,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;oBACtD,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the first real user prompt from Pi v3 session entries.
|
|
3
|
+
*
|
|
4
|
+
* A `/skill:<name>` invocation reaches the transcript as an ordinary user message whose text
|
|
5
|
+
* begins with Pi's literal `<skill …>…</skill>` block, followed by the prompt the user actually
|
|
6
|
+
* typed. Left in place that block becomes the session title in the report, so it is stripped
|
|
7
|
+
* via {@link parseSkillWrapper} — the single source of truth for the wrapper shape.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* First user prompt in transcript order that still carries text once the skill wrapper is
|
|
11
|
+
* stripped. A message that is nothing but a skill block contributes no prompt and is skipped.
|
|
12
|
+
*/
|
|
13
|
+
export declare function firstPiUserText(entries: readonly unknown[]): string | undefined;
|
|
14
|
+
//# sourceMappingURL=pi-user-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-user-prompt.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/pi/session/pi-user-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqCH;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,SAAS,CAY/E"}
|