@agentplugins/adapter-pimono 0.1.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/README.md +43 -0
- package/dist/index.cjs +576 -0
- package/dist/index.d.cts +154 -0
- package/dist/index.d.ts +154 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +548 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
- package/src/index.ts +978 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { PlatformAdapter, TargetPlatform, UniversalHookName, HandlerType, PluginManifest, ValidationIssue, AdapterOutput } from '@agentplugins/core';
|
|
2
|
+
export { AdapterOutput, InlineHookHandler, PluginManifest, ToolDefinition, ValidationIssue } from '@agentplugins/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @agentplugins/adapter-pimono
|
|
6
|
+
*
|
|
7
|
+
* Pi Mono platform adapter for AgentPlugins.
|
|
8
|
+
*
|
|
9
|
+
* Generates TypeScript-native extensions for the Pi agent runtime (jiti-loaded).
|
|
10
|
+
* Pi Mono extensions are single or multi-file TS modules that export a default
|
|
11
|
+
* factory function receiving an ExtensionAPI instance at load time.
|
|
12
|
+
*
|
|
13
|
+
* Key features:
|
|
14
|
+
* - Maps universal hooks to Pi Mono's 30+ lifecycle events (session.*, agent.*,
|
|
15
|
+
* message.*, tool.*, model.*, context.*)
|
|
16
|
+
* - Generates inline handler code for pi.on(event, handler) registrations
|
|
17
|
+
* - Emits pi.registerTool() calls for tools defined in the plugin manifest
|
|
18
|
+
* - Emits pi.registerCommand() / pi.registerShortcut() / pi.registerFlag() for
|
|
19
|
+
* commands, shortcuts, and CLI flags respectively
|
|
20
|
+
* - Supports multi-file extensions via a generated package.json with a "pi" key
|
|
21
|
+
* - Single-file extensions need no manifest metadata file
|
|
22
|
+
*
|
|
23
|
+
* @see https://github.com/earendil-works/pi-coding-agent (Pi Mono platform)
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Extended handler type including reference type for this adapter. */
|
|
27
|
+
type ExtendedHandlerType = HandlerType | "reference";
|
|
28
|
+
/** Plugin command definition. */
|
|
29
|
+
interface PluginCommand {
|
|
30
|
+
name: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
args?: Array<{
|
|
33
|
+
name: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
required?: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
handler?: unknown;
|
|
39
|
+
}
|
|
40
|
+
/** Plugin shortcut definition. */
|
|
41
|
+
interface PluginShortcut {
|
|
42
|
+
key: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
command: string;
|
|
45
|
+
when?: string;
|
|
46
|
+
action?: string;
|
|
47
|
+
}
|
|
48
|
+
/** Plugin flag definition. */
|
|
49
|
+
interface PluginFlag {
|
|
50
|
+
name: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
defaultValue?: string;
|
|
53
|
+
alias?: string;
|
|
54
|
+
type?: string;
|
|
55
|
+
handler?: unknown;
|
|
56
|
+
}
|
|
57
|
+
/** Module augmentation to extend core types. */
|
|
58
|
+
declare module "@agentplugins/core" {
|
|
59
|
+
interface PluginManifest {
|
|
60
|
+
commands?: PluginCommand[];
|
|
61
|
+
shortcuts?: PluginShortcut[];
|
|
62
|
+
flags?: PluginFlag[];
|
|
63
|
+
config?: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Universal hooks this adapter supports.
|
|
68
|
+
*
|
|
69
|
+
* Not every Pi Mono event has a universal counterpart. Unsupported hooks are
|
|
70
|
+
* left out so the compiler can emit a diagnostic when a plugin declares them.
|
|
71
|
+
*/
|
|
72
|
+
declare const SUPPORTED_HOOKS: readonly UniversalHookName[];
|
|
73
|
+
/** Handler types Pi Mono can express natively. */
|
|
74
|
+
declare const SUPPORTED_HANDLERS: readonly ExtendedHandlerType[];
|
|
75
|
+
/**
|
|
76
|
+
* Mapping from universal hook names to Pi Mono event strings.
|
|
77
|
+
*
|
|
78
|
+
* Pi Mono uses dot-namespaced events (category.EventName) for its 30+
|
|
79
|
+
* lifecycle hooks across 6 categories:
|
|
80
|
+
* - session.* (SessionStart, SessionEnd, CompactStart)
|
|
81
|
+
* - agent.* (AgentStart, AgentStop)
|
|
82
|
+
* - message.* (MessageReceive, MessageSend, Notification)
|
|
83
|
+
* - tool.* (ToolCall, ToolResult)
|
|
84
|
+
* - model.* (ModelRequest, ModelResponse)
|
|
85
|
+
* - context.* (ContextUpdate, ProviderChange)
|
|
86
|
+
*/
|
|
87
|
+
declare const HOOK_TO_EVENT: {
|
|
88
|
+
sessionStart: string;
|
|
89
|
+
sessionEnd: string;
|
|
90
|
+
preToolUse: string;
|
|
91
|
+
postToolUse: string;
|
|
92
|
+
userPromptSubmit: string;
|
|
93
|
+
notification: string;
|
|
94
|
+
subagentStart: string;
|
|
95
|
+
subagentStop: string;
|
|
96
|
+
preCompact: string;
|
|
97
|
+
stop: string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Pi Mono platform adapter.
|
|
101
|
+
*
|
|
102
|
+
* Implements the AgentPlugins `PlatformAdapter` interface to compile universal
|
|
103
|
+
* plugin manifests into Pi Mono native TypeScript extensions.
|
|
104
|
+
*
|
|
105
|
+
* Usage:
|
|
106
|
+
* ```ts
|
|
107
|
+
* import { piMonoAdapter } from "@agentplugins/adapter-pimono";
|
|
108
|
+
* import { createBridge } from "@agentplugins/core";
|
|
109
|
+
*
|
|
110
|
+
* const bridge = createBridge({ adapter: piMonoAdapter });
|
|
111
|
+
* const output = bridge.compile(myPluginManifest);
|
|
112
|
+
* // output.files["index.ts"] → the generated extension
|
|
113
|
+
* // output.files["package.json"] → metadata (multi-file only)
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
declare class PiMonoAdapter implements PlatformAdapter {
|
|
117
|
+
/** @inheritdoc */
|
|
118
|
+
readonly name: TargetPlatform;
|
|
119
|
+
/** @inheritdoc */
|
|
120
|
+
readonly displayName: string;
|
|
121
|
+
/** @inheritdoc */
|
|
122
|
+
readonly supportedHooks: readonly UniversalHookName[];
|
|
123
|
+
/** @inheritdoc */
|
|
124
|
+
readonly supportedHandlers: readonly HandlerType[];
|
|
125
|
+
/** @inheritdoc */
|
|
126
|
+
readonly manifestPath: string;
|
|
127
|
+
/** @inheritdoc */
|
|
128
|
+
readonly manifestFormat: "json" | "toml";
|
|
129
|
+
/**
|
|
130
|
+
* Validate a plugin manifest for Pi Mono compatibility.
|
|
131
|
+
*
|
|
132
|
+
* @param plugin - The plugin manifest.
|
|
133
|
+
* @returns Array of validation issues (empty if valid).
|
|
134
|
+
*/
|
|
135
|
+
validate(plugin: PluginManifest): ValidationIssue[];
|
|
136
|
+
/**
|
|
137
|
+
* Compile a plugin manifest into Pi Mono extension files.
|
|
138
|
+
*
|
|
139
|
+
* @param plugin - The plugin manifest.
|
|
140
|
+
* @returns AdapterOutput containing generated files and metadata.
|
|
141
|
+
*/
|
|
142
|
+
compile(plugin: PluginManifest): AdapterOutput;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Singleton instance of the Pi Mono adapter.
|
|
146
|
+
*
|
|
147
|
+
* Most consumers should use this pre-constructed instance rather than
|
|
148
|
+
* constructing `PiMonoAdapter` directly.
|
|
149
|
+
*/
|
|
150
|
+
declare const piMonoAdapter: PiMonoAdapter;
|
|
151
|
+
/** Factory function for creating a new Pi Mono adapter instance. */
|
|
152
|
+
declare function createPiMonoAdapter(): PlatformAdapter;
|
|
153
|
+
|
|
154
|
+
export { HOOK_TO_EVENT, PiMonoAdapter, SUPPORTED_HANDLERS, SUPPORTED_HOOKS, createPiMonoAdapter, piMonoAdapter };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { PlatformAdapter, TargetPlatform, UniversalHookName, HandlerType, PluginManifest, ValidationIssue, AdapterOutput } from '@agentplugins/core';
|
|
2
|
+
export { AdapterOutput, InlineHookHandler, PluginManifest, ToolDefinition, ValidationIssue } from '@agentplugins/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @agentplugins/adapter-pimono
|
|
6
|
+
*
|
|
7
|
+
* Pi Mono platform adapter for AgentPlugins.
|
|
8
|
+
*
|
|
9
|
+
* Generates TypeScript-native extensions for the Pi agent runtime (jiti-loaded).
|
|
10
|
+
* Pi Mono extensions are single or multi-file TS modules that export a default
|
|
11
|
+
* factory function receiving an ExtensionAPI instance at load time.
|
|
12
|
+
*
|
|
13
|
+
* Key features:
|
|
14
|
+
* - Maps universal hooks to Pi Mono's 30+ lifecycle events (session.*, agent.*,
|
|
15
|
+
* message.*, tool.*, model.*, context.*)
|
|
16
|
+
* - Generates inline handler code for pi.on(event, handler) registrations
|
|
17
|
+
* - Emits pi.registerTool() calls for tools defined in the plugin manifest
|
|
18
|
+
* - Emits pi.registerCommand() / pi.registerShortcut() / pi.registerFlag() for
|
|
19
|
+
* commands, shortcuts, and CLI flags respectively
|
|
20
|
+
* - Supports multi-file extensions via a generated package.json with a "pi" key
|
|
21
|
+
* - Single-file extensions need no manifest metadata file
|
|
22
|
+
*
|
|
23
|
+
* @see https://github.com/earendil-works/pi-coding-agent (Pi Mono platform)
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Extended handler type including reference type for this adapter. */
|
|
27
|
+
type ExtendedHandlerType = HandlerType | "reference";
|
|
28
|
+
/** Plugin command definition. */
|
|
29
|
+
interface PluginCommand {
|
|
30
|
+
name: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
args?: Array<{
|
|
33
|
+
name: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
required?: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
handler?: unknown;
|
|
39
|
+
}
|
|
40
|
+
/** Plugin shortcut definition. */
|
|
41
|
+
interface PluginShortcut {
|
|
42
|
+
key: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
command: string;
|
|
45
|
+
when?: string;
|
|
46
|
+
action?: string;
|
|
47
|
+
}
|
|
48
|
+
/** Plugin flag definition. */
|
|
49
|
+
interface PluginFlag {
|
|
50
|
+
name: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
defaultValue?: string;
|
|
53
|
+
alias?: string;
|
|
54
|
+
type?: string;
|
|
55
|
+
handler?: unknown;
|
|
56
|
+
}
|
|
57
|
+
/** Module augmentation to extend core types. */
|
|
58
|
+
declare module "@agentplugins/core" {
|
|
59
|
+
interface PluginManifest {
|
|
60
|
+
commands?: PluginCommand[];
|
|
61
|
+
shortcuts?: PluginShortcut[];
|
|
62
|
+
flags?: PluginFlag[];
|
|
63
|
+
config?: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Universal hooks this adapter supports.
|
|
68
|
+
*
|
|
69
|
+
* Not every Pi Mono event has a universal counterpart. Unsupported hooks are
|
|
70
|
+
* left out so the compiler can emit a diagnostic when a plugin declares them.
|
|
71
|
+
*/
|
|
72
|
+
declare const SUPPORTED_HOOKS: readonly UniversalHookName[];
|
|
73
|
+
/** Handler types Pi Mono can express natively. */
|
|
74
|
+
declare const SUPPORTED_HANDLERS: readonly ExtendedHandlerType[];
|
|
75
|
+
/**
|
|
76
|
+
* Mapping from universal hook names to Pi Mono event strings.
|
|
77
|
+
*
|
|
78
|
+
* Pi Mono uses dot-namespaced events (category.EventName) for its 30+
|
|
79
|
+
* lifecycle hooks across 6 categories:
|
|
80
|
+
* - session.* (SessionStart, SessionEnd, CompactStart)
|
|
81
|
+
* - agent.* (AgentStart, AgentStop)
|
|
82
|
+
* - message.* (MessageReceive, MessageSend, Notification)
|
|
83
|
+
* - tool.* (ToolCall, ToolResult)
|
|
84
|
+
* - model.* (ModelRequest, ModelResponse)
|
|
85
|
+
* - context.* (ContextUpdate, ProviderChange)
|
|
86
|
+
*/
|
|
87
|
+
declare const HOOK_TO_EVENT: {
|
|
88
|
+
sessionStart: string;
|
|
89
|
+
sessionEnd: string;
|
|
90
|
+
preToolUse: string;
|
|
91
|
+
postToolUse: string;
|
|
92
|
+
userPromptSubmit: string;
|
|
93
|
+
notification: string;
|
|
94
|
+
subagentStart: string;
|
|
95
|
+
subagentStop: string;
|
|
96
|
+
preCompact: string;
|
|
97
|
+
stop: string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Pi Mono platform adapter.
|
|
101
|
+
*
|
|
102
|
+
* Implements the AgentPlugins `PlatformAdapter` interface to compile universal
|
|
103
|
+
* plugin manifests into Pi Mono native TypeScript extensions.
|
|
104
|
+
*
|
|
105
|
+
* Usage:
|
|
106
|
+
* ```ts
|
|
107
|
+
* import { piMonoAdapter } from "@agentplugins/adapter-pimono";
|
|
108
|
+
* import { createBridge } from "@agentplugins/core";
|
|
109
|
+
*
|
|
110
|
+
* const bridge = createBridge({ adapter: piMonoAdapter });
|
|
111
|
+
* const output = bridge.compile(myPluginManifest);
|
|
112
|
+
* // output.files["index.ts"] → the generated extension
|
|
113
|
+
* // output.files["package.json"] → metadata (multi-file only)
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
declare class PiMonoAdapter implements PlatformAdapter {
|
|
117
|
+
/** @inheritdoc */
|
|
118
|
+
readonly name: TargetPlatform;
|
|
119
|
+
/** @inheritdoc */
|
|
120
|
+
readonly displayName: string;
|
|
121
|
+
/** @inheritdoc */
|
|
122
|
+
readonly supportedHooks: readonly UniversalHookName[];
|
|
123
|
+
/** @inheritdoc */
|
|
124
|
+
readonly supportedHandlers: readonly HandlerType[];
|
|
125
|
+
/** @inheritdoc */
|
|
126
|
+
readonly manifestPath: string;
|
|
127
|
+
/** @inheritdoc */
|
|
128
|
+
readonly manifestFormat: "json" | "toml";
|
|
129
|
+
/**
|
|
130
|
+
* Validate a plugin manifest for Pi Mono compatibility.
|
|
131
|
+
*
|
|
132
|
+
* @param plugin - The plugin manifest.
|
|
133
|
+
* @returns Array of validation issues (empty if valid).
|
|
134
|
+
*/
|
|
135
|
+
validate(plugin: PluginManifest): ValidationIssue[];
|
|
136
|
+
/**
|
|
137
|
+
* Compile a plugin manifest into Pi Mono extension files.
|
|
138
|
+
*
|
|
139
|
+
* @param plugin - The plugin manifest.
|
|
140
|
+
* @returns AdapterOutput containing generated files and metadata.
|
|
141
|
+
*/
|
|
142
|
+
compile(plugin: PluginManifest): AdapterOutput;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Singleton instance of the Pi Mono adapter.
|
|
146
|
+
*
|
|
147
|
+
* Most consumers should use this pre-constructed instance rather than
|
|
148
|
+
* constructing `PiMonoAdapter` directly.
|
|
149
|
+
*/
|
|
150
|
+
declare const piMonoAdapter: PiMonoAdapter;
|
|
151
|
+
/** Factory function for creating a new Pi Mono adapter instance. */
|
|
152
|
+
declare function createPiMonoAdapter(): PlatformAdapter;
|
|
153
|
+
|
|
154
|
+
export { HOOK_TO_EVENT, PiMonoAdapter, SUPPORTED_HANDLERS, SUPPORTED_HOOKS, createPiMonoAdapter, piMonoAdapter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAOjB,MAAM,mBAAmB,CAAC;AAI3B,uEAAuE;AACvE,KAAK,mBAAmB,GAAG,WAAW,GAAG,WAAW,CAAC;AAiBrD,iCAAiC;AACjC,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM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