pi2dsh 0.12.1 → 0.12.3
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 +37 -7
- package/README.zh.md +32 -6
- package/dist/{analyzer-CsrBeS8r.mjs → analyzer-2Nx5XYOA.mjs} +3 -3
- package/dist/{analyzer-CsrBeS8r.mjs.map → analyzer-2Nx5XYOA.mjs.map} +1 -1
- package/dist/cli.mjs +7 -44
- package/dist/cli.mjs.map +1 -1
- package/dist/client.js +139 -0
- package/dist/compat/pi-coding-agent.d.mts +82 -14
- package/dist/compat/pi-coding-agent.d.mts.map +1 -1
- package/dist/compat/pi-coding-agent.mjs +1 -1
- package/dist/credentials-oauth.mjs +1 -1
- package/dist/host.d.mts +1 -11
- package/dist/host.d.mts.map +1 -1
- package/dist/host.mjs +3 -98
- package/dist/host.mjs.map +1 -1
- package/dist/index.d.mts +18 -19
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -14
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-config-Cjae0vot.mjs +766 -0
- package/dist/mcp-config-Cjae0vot.mjs.map +1 -0
- package/dist/{pi-coding-agent-Ctw-BhoY.mjs → pi-coding-agent-CYnmeJEx.mjs} +0 -0
- package/dist/pi-coding-agent-CYnmeJEx.mjs.map +1 -0
- package/dist/{runtime-Xy8yU8wO.mjs → runtime-B_Ig28og.mjs} +1122 -223
- package/dist/runtime-B_Ig28og.mjs.map +1 -0
- package/dist/runtime.d.mts +33 -0
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -1
- package/package.json +23 -9
- package/dist/generator-CSOv6wYT.mjs +0 -298
- package/dist/generator-CSOv6wYT.mjs.map +0 -1
- package/dist/mcp-config-Cn5gWemZ.mjs +0 -707
- package/dist/mcp-config-Cn5gWemZ.mjs.map +0 -1
- package/dist/pi-coding-agent-Ctw-BhoY.mjs.map +0 -1
- package/dist/runtime-Xy8yU8wO.mjs.map +0 -1
package/dist/client.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "pi2dsh",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react = require("react");
|
|
8
|
+
//#region src/client.ts
|
|
9
|
+
/** Services this half needs before it can take a seat. */
|
|
10
|
+
const inject = ["slots"];
|
|
11
|
+
const POLL_MS = 1e3;
|
|
12
|
+
const styles = {
|
|
13
|
+
panel: {
|
|
14
|
+
position: "fixed",
|
|
15
|
+
right: "20px",
|
|
16
|
+
bottom: "108px",
|
|
17
|
+
zIndex: 40,
|
|
18
|
+
width: "340px",
|
|
19
|
+
maxHeight: "48vh",
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexDirection: "column",
|
|
22
|
+
pointerEvents: "auto",
|
|
23
|
+
overflow: "hidden",
|
|
24
|
+
borderRadius: "12px",
|
|
25
|
+
border: "1px solid rgba(120,120,130,0.28)",
|
|
26
|
+
background: "var(--dsh-color-bg-elevated, rgba(24,24,27,0.96))",
|
|
27
|
+
color: "var(--dsh-color-text, #fafafa)",
|
|
28
|
+
boxShadow: "0 12px 32px rgba(0,0,0,0.32)",
|
|
29
|
+
font: "400 13px/1.55 system-ui, -apple-system, sans-serif"
|
|
30
|
+
},
|
|
31
|
+
header: {
|
|
32
|
+
display: "flex",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
justifyContent: "space-between",
|
|
35
|
+
gap: "8px",
|
|
36
|
+
padding: "10px 12px",
|
|
37
|
+
borderBottom: "1px solid rgba(120,120,130,0.22)",
|
|
38
|
+
fontWeight: 500,
|
|
39
|
+
fontSize: "12px",
|
|
40
|
+
letterSpacing: "0.01em"
|
|
41
|
+
},
|
|
42
|
+
badge: {
|
|
43
|
+
opacity: .6,
|
|
44
|
+
fontWeight: 400
|
|
45
|
+
},
|
|
46
|
+
body: {
|
|
47
|
+
padding: "10px 12px",
|
|
48
|
+
overflowY: "auto",
|
|
49
|
+
display: "flex",
|
|
50
|
+
flexDirection: "column",
|
|
51
|
+
gap: "10px"
|
|
52
|
+
},
|
|
53
|
+
role: {
|
|
54
|
+
fontSize: "11px",
|
|
55
|
+
textTransform: "uppercase",
|
|
56
|
+
letterSpacing: "0.06em",
|
|
57
|
+
opacity: .55
|
|
58
|
+
},
|
|
59
|
+
text: {
|
|
60
|
+
whiteSpace: "pre-wrap",
|
|
61
|
+
wordBreak: "break-word"
|
|
62
|
+
},
|
|
63
|
+
close: {
|
|
64
|
+
cursor: "pointer",
|
|
65
|
+
opacity: .55,
|
|
66
|
+
background: "none",
|
|
67
|
+
border: "none",
|
|
68
|
+
color: "inherit",
|
|
69
|
+
font: "inherit"
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The panel: one card per live side thread of the session on screen.
|
|
74
|
+
*
|
|
75
|
+
* The current session comes from the framework's own global seat
|
|
76
|
+
* (`useSessions().current`), not from the address bar — the app keeps the open
|
|
77
|
+
* conversation in its state, so the URL never names it.
|
|
78
|
+
* @param props - the global standard kit every root slot component receives.
|
|
79
|
+
*/
|
|
80
|
+
function SidePanel({ useSessions }) {
|
|
81
|
+
const session = useSessions((state) => state.current);
|
|
82
|
+
const [threads, setThreads] = (0, react.useState)([]);
|
|
83
|
+
const [dismissed, setDismissed] = (0, react.useState)([]);
|
|
84
|
+
(0, react.useEffect)(() => {
|
|
85
|
+
let alive = true;
|
|
86
|
+
const poll = async () => {
|
|
87
|
+
if (session === void 0 || session === "") {
|
|
88
|
+
if (alive) setThreads([]);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const response = await fetch(`/pi2dsh/side-panel?session=${encodeURIComponent(session)}`);
|
|
93
|
+
if (!response.ok) return;
|
|
94
|
+
const payload = await response.json();
|
|
95
|
+
if (alive) setThreads(Array.isArray(payload.threads) ? payload.threads : []);
|
|
96
|
+
} catch {}
|
|
97
|
+
};
|
|
98
|
+
poll();
|
|
99
|
+
const timer = window.setInterval(() => {
|
|
100
|
+
poll();
|
|
101
|
+
}, POLL_MS);
|
|
102
|
+
return () => {
|
|
103
|
+
alive = false;
|
|
104
|
+
window.clearInterval(timer);
|
|
105
|
+
};
|
|
106
|
+
}, [session]);
|
|
107
|
+
const shown = threads.filter((thread) => !dismissed.includes(thread.id));
|
|
108
|
+
if (shown.length === 0) return null;
|
|
109
|
+
return (0, react.createElement)("div", {
|
|
110
|
+
"data-pi2dsh": "side-panel",
|
|
111
|
+
style: styles.panel
|
|
112
|
+
}, ...shown.map((thread) => (0, react.createElement)("div", {
|
|
113
|
+
key: thread.id,
|
|
114
|
+
style: { display: "contents" }
|
|
115
|
+
}, (0, react.createElement)("div", { style: styles.header }, (0, react.createElement)("span", null, thread.label), (0, react.createElement)("span", { style: styles.badge }, thread.running ? "running" : `${thread.messages.length} msg`), (0, react.createElement)("button", {
|
|
116
|
+
style: styles.close,
|
|
117
|
+
title: "Hide",
|
|
118
|
+
onClick: () => setDismissed((list) => [...list, thread.id])
|
|
119
|
+
}, "×")), (0, react.createElement)("div", { style: styles.body }, ...thread.messages.map((message, index) => (0, react.createElement)("div", { key: index }, (0, react.createElement)("div", { style: styles.role }, message.role), (0, react.createElement)("div", { style: styles.text }, message.text)))))));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Client plugin body: take the frame-wide overlay seat.
|
|
123
|
+
* @param ctx - client root context.
|
|
124
|
+
*/
|
|
125
|
+
function apply(ctx) {
|
|
126
|
+
ctx.inject(["slots"], (scope) => {
|
|
127
|
+
scope.slots.inject("shell.overlay", () => scope.slots.register({
|
|
128
|
+
name: "shell.overlay",
|
|
129
|
+
id: "pi2dsh-side-panel",
|
|
130
|
+
order: 1
|
|
131
|
+
}, SidePanel));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
exports.apply = apply;
|
|
136
|
+
exports.inject = inject;
|
|
137
|
+
return module.exports;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
@@ -1047,6 +1047,48 @@ declare function loadSkills(options: LoadSkillsOptions): LoadSkillsResult;
|
|
|
1047
1047
|
*/
|
|
1048
1048
|
declare function formatSkillsForPrompt(skills: any): string;
|
|
1049
1049
|
//#endregion
|
|
1050
|
+
//#region src/compat/vendor/pi-shell-config.d.ts
|
|
1051
|
+
interface ShellConfig {
|
|
1052
|
+
shell: string;
|
|
1053
|
+
args: string[];
|
|
1054
|
+
commandTransport?: "argv" | "stdin";
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Resolve shell configuration based on platform and an optional explicit shell path.
|
|
1058
|
+
* Resolution order:
|
|
1059
|
+
* 1. User-specified shellPath
|
|
1060
|
+
* 2. On Windows: Git Bash in known locations, then bash on PATH
|
|
1061
|
+
* 3. On Unix: /bin/bash, then bash on PATH, then fallback to sh
|
|
1062
|
+
*/
|
|
1063
|
+
declare function getShellConfig(customShellPath?: string): ShellConfig;
|
|
1064
|
+
//#endregion
|
|
1065
|
+
//#region src/compat/vendor/pi-tools/visual-truncate.d.ts
|
|
1066
|
+
/**
|
|
1067
|
+
* Truncate text to a maximum number of visual lines (from the end).
|
|
1068
|
+
* This accounts for line wrapping based on terminal width.
|
|
1069
|
+
*
|
|
1070
|
+
* @param text - The text content (may contain newlines)
|
|
1071
|
+
* @param maxVisualLines - Maximum number of visual lines to show
|
|
1072
|
+
* @param width - Terminal/render width
|
|
1073
|
+
* @param paddingX - Horizontal padding for Text component (default 0).
|
|
1074
|
+
* Use 0 when result will be placed in a Box (Box adds its own padding).
|
|
1075
|
+
* Use 1 when result will be placed in a plain Container.
|
|
1076
|
+
* @returns The truncated visual lines and count of skipped lines
|
|
1077
|
+
*/
|
|
1078
|
+
declare function truncateToVisualLines(text: any, maxVisualLines: any, width: any, paddingX?: number): {
|
|
1079
|
+
visualLines: string[];
|
|
1080
|
+
skippedCount: number;
|
|
1081
|
+
};
|
|
1082
|
+
//#endregion
|
|
1083
|
+
//#region src/compat/vendor/pi-tools/diff-component.d.ts
|
|
1084
|
+
/**
|
|
1085
|
+
* Render a diff string with colored lines and intra-line change highlighting.
|
|
1086
|
+
* - Context lines: dim/gray
|
|
1087
|
+
* - Removed lines: red, with inverse on changed tokens
|
|
1088
|
+
* - Added lines: green, with inverse on changed tokens
|
|
1089
|
+
*/
|
|
1090
|
+
declare function renderDiff(diffText: any, _options?: {}): string;
|
|
1091
|
+
//#endregion
|
|
1050
1092
|
//#region src/compat/pi-coding-agent.d.ts
|
|
1051
1093
|
interface ToolNamedEvent {
|
|
1052
1094
|
toolName?: unknown;
|
|
@@ -1100,24 +1142,52 @@ declare function generateSummaryWithUsage(currentMessages: unknown, model: unkno
|
|
|
1100
1142
|
declare function generateBranchSummary(entries: unknown, options: Record<string, unknown>): Promise<unknown>;
|
|
1101
1143
|
declare function copyToClipboard(text: string): Promise<boolean>;
|
|
1102
1144
|
interface ImageResizeOptions {
|
|
1145
|
+
/** Pi's default: 2000. */
|
|
1103
1146
|
maxWidth?: number;
|
|
1147
|
+
/** Pi's default: 2000. */
|
|
1104
1148
|
maxHeight?: number;
|
|
1105
|
-
|
|
1149
|
+
/** Pi's default: 4.5MB of base64 payload. */
|
|
1150
|
+
maxBytes?: number;
|
|
1151
|
+
/** Pi's default: 80. */
|
|
1152
|
+
jpegQuality?: number;
|
|
1106
1153
|
}
|
|
1154
|
+
/** Pi's exact result shape: base64 payload plus both the original and final size. */
|
|
1107
1155
|
interface ResizedImage {
|
|
1108
1156
|
data: string;
|
|
1109
1157
|
mimeType: string;
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
declare function convertToPng(data: string, mimeType: string): Promise<ResizedImage>;
|
|
1116
|
-
interface ShellConfig {
|
|
1117
|
-
shell: string;
|
|
1118
|
-
args: string[];
|
|
1158
|
+
originalWidth: number;
|
|
1159
|
+
originalHeight: number;
|
|
1160
|
+
width: number;
|
|
1161
|
+
height: number;
|
|
1162
|
+
wasResized: boolean;
|
|
1119
1163
|
}
|
|
1120
|
-
|
|
1164
|
+
/**
|
|
1165
|
+
* Encode an image for inline use, reporting its true dimensions.
|
|
1166
|
+
*
|
|
1167
|
+
* Pi resizes here, using a worker and an image codec. This bridge has no
|
|
1168
|
+
* codec, so it does not resize — but it must not lie about the rest: the
|
|
1169
|
+
* payload really is base64 (packages feed this straight to a model), the
|
|
1170
|
+
* dimensions are read from the file header, and `wasResized` is honestly
|
|
1171
|
+
* false. When the image exceeds the caller's byte budget it cannot be made to
|
|
1172
|
+
* fit, so this returns `null` — Pi's own "cannot produce a usable image"
|
|
1173
|
+
* answer — rather than handing back something over the limit.
|
|
1174
|
+
* @param inputBytes - the complete image file.
|
|
1175
|
+
* @param mimeType - the declared image type.
|
|
1176
|
+
* @param options - Pi's resize budget; only `maxBytes` can be honoured here.
|
|
1177
|
+
*/
|
|
1178
|
+
declare function resizeImage(inputBytes: Uint8Array, mimeType: string, options?: ImageResizeOptions): Promise<ResizedImage | null>;
|
|
1179
|
+
/**
|
|
1180
|
+
* Pi's PNG conversion. Already-PNG input passes through; anything else needs
|
|
1181
|
+
* an image codec this bridge does not carry, so it answers `null` — the same
|
|
1182
|
+
* answer Pi gives when its own conversion fails, and one every caller already
|
|
1183
|
+
* handles.
|
|
1184
|
+
* @param base64Data - the image payload, base64 encoded.
|
|
1185
|
+
* @param mimeType - its declared type.
|
|
1186
|
+
*/
|
|
1187
|
+
declare function convertToPng(base64Data: string, mimeType: string): Promise<{
|
|
1188
|
+
data: string;
|
|
1189
|
+
mimeType: string;
|
|
1190
|
+
} | null>;
|
|
1121
1191
|
declare function getPackageDir(): string;
|
|
1122
1192
|
interface StoredCredential {
|
|
1123
1193
|
type?: string;
|
|
@@ -1330,15 +1400,13 @@ interface SettingsCallbacks {
|
|
|
1330
1400
|
interface RenderDiffOptions {
|
|
1331
1401
|
[key: string]: unknown;
|
|
1332
1402
|
}
|
|
1333
|
-
declare function renderDiff(oldText: string, newText: string, _options?: RenderDiffOptions): string[];
|
|
1334
1403
|
interface VisualTruncateResult {
|
|
1335
1404
|
visualLines: string[];
|
|
1336
1405
|
skippedCount: number;
|
|
1337
1406
|
}
|
|
1338
|
-
declare function truncateToVisualLines(text: string, maxVisualLines: number, width: number, paddingX?: number): VisualTruncateResult;
|
|
1339
1407
|
declare function keyHint(keybinding: string, description: string): string;
|
|
1340
1408
|
declare function keyText(keybinding: string): string;
|
|
1341
1409
|
declare function rawKeyHint(key: string, description: string): string;
|
|
1342
1410
|
//#endregion
|
|
1343
|
-
export { AssistantMessageComponent, BRANCH_SUMMARY_PREFIX, BRANCH_SUMMARY_SUFFIX, type BashExecutionMessage, BorderedLoader, type BranchPreparation, type BranchSummaryEntry, type BranchSummaryMessage, type BranchSummaryResult, COMPACTION_SUMMARY_PREFIX, COMPACTION_SUMMARY_SUFFIX, CONFIG_DIR_NAME, CURRENT_SESSION_VERSION, type CollectEntriesResult, ColorMode, type CompactionEntry, type CompactionPreparation, type CompactionResult, type CompactionSettings, type CompactionSummaryMessage, CustomEditor, type CustomEntry, type CustomMessage, CustomMessageComponent, type CustomMessageEntry, type CutPointResult, DEFAULT_COMPACTION_SETTINGS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DefaultPackageManager, DefaultProjectTrust, DefaultResourceLoader, DynamicBorder, ExtensionEditorComponent, ExtensionInputComponent, ExtensionRunner, type ExtensionRuntime, ExtensionSelectorComponent, type FileOperations, FileSettingsStorage, FooterComponent, type GenerateBranchSummaryOptions, ImageResizeOptions, InMemorySettingsStorage, type LabelEntry, type ModelChangeEntry, ModelRegistry, ModelRuntime, PackageSource, ParsedSkillBlock, ProjectTrustStore, RegisteredToolRecord, RenderDiffOptions, ResizedImage, RetrySettings, type SessionContext, type SessionEntry, type SessionHeader, type SessionInfo, type SessionInfoEntry, SessionManager, type SessionMessageEntry, type SessionTreeNode, SettingsCallbacks, SettingsConfig, SettingsManager, SettingsManagerCreateOptions, SettingsSelectorComponent, ShellConfig, StoredCredential, Theme, ThemeBg, ThemeColor, type ThinkingLevelChangeEntry, ToolExecutionComponent, ToolExecutionOptions, type TruncationOptions, type TruncationResult, TuiMode, UserMessageComponent, VERSION, VisualTruncateResult, __setSubagentSessionFactory, assertValidSessionId, bashExecutionToText, bashToolSystemPromptContribution, buildContextEntries, buildSessionContext, calculateContextTokens, collectEntriesForBranchSummary, compact, convertToLlm, convertToPng, copyToClipboard, createAgentSession, createBashTool, createBashToolDefinition, createBranchSummaryMessage, createCodingTools, createCompactionSummaryMessage, createCustomMessage, createEditTool, createEditToolDefinition, createEventBus, createExtensionRuntime, createFindTool, createFindToolDefinition, createGrepTool, createGrepToolDefinition, createLocalBashOperations, createLsTool, createLsToolDefinition, createReadOnlyTools, createReadTool, createReadToolDefinition, createWriteTool, createWriteToolDefinition, defineTool, ensureTool, estimateTokens, findCutPoint, findMostRecentSession, findTurnStartIndex, formatSize, formatSkillsForPrompt, generateBranchSummary, generateSummary, generateSummaryWithUsage, getAgentDir, getBinDir, getDefaultSessionDir, getLanguageFromPath, getLastAssistantUsage, getLatestCompactionEntry, getMarkdownTheme, getPackageDir, getReadmePath, getSelectListTheme, getSettingsListTheme, getShellConfig, getToolPath, highlightCode, initTheme, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, keyHint, keyText, loadEntriesFromFile, loadSkills, loadSkillsFromDir, migrateSessionEntries, parseFrontmatter, parseSessionEntries, parseSkillBlock, prepareBranchEntries, prepareCompaction, processImage, rawKeyHint, readStoredCredential, renderDiff, resizeImage, serializeConversation, sessionEntryToContextMessages, shouldCompact, stripFrontmatter, theme, truncateHead, truncateLine, truncateTail, truncateToVisualLines, withFileMutationQueue, wrapRegisteredTool, wrapRegisteredTools, wrapToolDefinition, wrapToolDefinitions };
|
|
1411
|
+
export { AssistantMessageComponent, BRANCH_SUMMARY_PREFIX, BRANCH_SUMMARY_SUFFIX, type BashExecutionMessage, BorderedLoader, type BranchPreparation, type BranchSummaryEntry, type BranchSummaryMessage, type BranchSummaryResult, COMPACTION_SUMMARY_PREFIX, COMPACTION_SUMMARY_SUFFIX, CONFIG_DIR_NAME, CURRENT_SESSION_VERSION, type CollectEntriesResult, ColorMode, type CompactionEntry, type CompactionPreparation, type CompactionResult, type CompactionSettings, type CompactionSummaryMessage, CustomEditor, type CustomEntry, type CustomMessage, CustomMessageComponent, type CustomMessageEntry, type CutPointResult, DEFAULT_COMPACTION_SETTINGS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DefaultPackageManager, DefaultProjectTrust, DefaultResourceLoader, DynamicBorder, ExtensionEditorComponent, ExtensionInputComponent, ExtensionRunner, type ExtensionRuntime, ExtensionSelectorComponent, type FileOperations, FileSettingsStorage, FooterComponent, type GenerateBranchSummaryOptions, ImageResizeOptions, InMemorySettingsStorage, type LabelEntry, type ModelChangeEntry, ModelRegistry, ModelRuntime, PackageSource, ParsedSkillBlock, ProjectTrustStore, RegisteredToolRecord, RenderDiffOptions, ResizedImage, RetrySettings, type SessionContext, type SessionEntry, type SessionHeader, type SessionInfo, type SessionInfoEntry, SessionManager, type SessionMessageEntry, type SessionTreeNode, SettingsCallbacks, SettingsConfig, SettingsManager, SettingsManagerCreateOptions, SettingsSelectorComponent, type ShellConfig, StoredCredential, Theme, ThemeBg, ThemeColor, type ThinkingLevelChangeEntry, ToolExecutionComponent, ToolExecutionOptions, type TruncationOptions, type TruncationResult, TuiMode, UserMessageComponent, VERSION, VisualTruncateResult, __setSubagentSessionFactory, assertValidSessionId, bashExecutionToText, bashToolSystemPromptContribution, buildContextEntries, buildSessionContext, calculateContextTokens, collectEntriesForBranchSummary, compact, convertToLlm, convertToPng, copyToClipboard, createAgentSession, createBashTool, createBashToolDefinition, createBranchSummaryMessage, createCodingTools, createCompactionSummaryMessage, createCustomMessage, createEditTool, createEditToolDefinition, createEventBus, createExtensionRuntime, createFindTool, createFindToolDefinition, createGrepTool, createGrepToolDefinition, createLocalBashOperations, createLsTool, createLsToolDefinition, createReadOnlyTools, createReadTool, createReadToolDefinition, createWriteTool, createWriteToolDefinition, defineTool, ensureTool, estimateTokens, findCutPoint, findMostRecentSession, findTurnStartIndex, formatSize, formatSkillsForPrompt, generateBranchSummary, generateSummary, generateSummaryWithUsage, getAgentDir, getBinDir, getDefaultSessionDir, getLanguageFromPath, getLastAssistantUsage, getLatestCompactionEntry, getMarkdownTheme, getPackageDir, getReadmePath, getSelectListTheme, getSettingsListTheme, getShellConfig, getToolPath, highlightCode, initTheme, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, keyHint, keyText, loadEntriesFromFile, loadSkills, loadSkillsFromDir, migrateSessionEntries, parseFrontmatter, parseSessionEntries, parseSkillBlock, prepareBranchEntries, prepareCompaction, processImage, rawKeyHint, readStoredCredential, renderDiff, resizeImage, serializeConversation, sessionEntryToContextMessages, shouldCompact, stripFrontmatter, theme, truncateHead, truncateLine, truncateTail, truncateToVisualLines, withFileMutationQueue, wrapRegisteredTool, wrapRegisteredTools, wrapToolDefinition, wrapToolDefinitions };
|
|
1344
1412
|
//# sourceMappingURL=pi-coding-agent.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-coding-agent.d.mts","names":[],"sources":["../../src/compat/vendor/pi-messages.ts","../../src/compat/vendor/pi-session-manager.ts","../../src/compat/vendor/pi-truncate.ts","../../src/compat/vendor/pi-file-mutation-queue.ts","../../src/compat/vendor/pi-config-shim.ts","../../src/compat/vendor/pi-extension-runtime.ts","../../src/compat/vendor/pi-tools/bash.ts","../../src/compat/vendor/pi-tools/read.ts","../../src/compat/vendor/pi-tools/edit.ts","../../src/compat/vendor/pi-tools/write.ts","../../src/compat/vendor/pi-tools/grep.ts","../../src/compat/vendor/pi-tools/find.ts","../../src/compat/vendor/pi-tools/ls.ts","../../src/compat/vendor/pi-compaction.ts","../../src/compat/vendor/pi-frontmatter.ts","../../src/compat/vendor/pi-tool-wrapper.ts","../../src/compat/vendor/pi-trust-store.ts","../../src/compat/vendor/pi-skills-load.ts","../../src/compat/vendor/pi-skills-format.ts","../../src/compat/pi-coding-agent.ts"],"mappings":";;;;;;cAUa;cAKA;cAGA;cAKA;;;;UAKI;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;;;;;UAOgB,cAAc;EAC9B;EACA;EACA,mBAAmB,cAAc;EACjC;EACA,UAAU;EACV;;UAGgB;EAChB;EACA;EACA;EACA;;UAGgB;EAChB;EACA;EACA;EACA;;;;;iBAOe,oBAAoB,KAAK;iBAkBzB,2BAA2B,iBAAiB,gBAAgB,oBAAoB;iBAShF,+BACf,iBACA,sBACA,oBACE;;iBAUa,oBACf,oBACA,mBAAmB,cAAc,iBACjC,kBACA,8BACA,oBACE;;;;;;;;;iBAmBa,aAAa,UAAU,iBAAiB;;;cC5G3C;UAEI;EAChB;EACA;EACA;EACA;EACA;EACA;;UAGgB;EAChB;EACA;;UAGgB;EAChB;EACA;EACA;EACA;;UAGgB,4BAA4B;EAC5C;EACA,SAAS;;UAGO,iCAAiC;EACjD;EACA;;UAGgB,yBAAyB;EACzC;EACA;EACA;;UAGgB,gBAAgB,qBAAqB;EACrD;EACA;EACA;EACA;;EAEA,UAAU;;EAEV,QAAQ;;EAER;;UAGgB,mBAAmB,qBAAqB;EACxD;EACA;EACA;;EAEA,UAAU;;EAEV,QAAQ;;EAER;;;;;;;;;;;;UAagB,YAAY,qBAAqB;EACjD;EACA;EACA,OAAO;;;UAIS,mBAAmB;EACnC;EACA;EACA;;;UAIgB,yBAAyB;EACzC;EACA;;;;;;;;;;;;;;UAegB,mBAAmB,qBAAqB;EACxD;EACA;EACA,mBAAmB,cAAc;EACjC,UAAU;EACV;;;KAIW,eACT,sBACA,2BACA,mBACA,kBACA,qBACA,cACA,qBACA,aACA;;KAGS,YA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kB;cASR,mBAAoB;;;;iBCjCjB,mBAAmB,iBAAY;;;;;;;;;;;iBAe/B,oBAAoB,kBAAa;;;;;iBAQjC,mBAAmB,qBAAgB;yEAAnC;;;;;;;;;;;;;iBA0BA,oBAAoB,sBAAiB;;;KC7CzC;UAEK;EACf;EACA;;UAGe;EACf;EACA,UAAU;;cAwGC;UACH;EAEI,YAAA;EAIZ,IAAI,cAAc;EAIlB,SAAS,cAAc;EAOvB,IAAI,aAAa,UAAU;EAI3B,QAAQ,WAAW;;;;UCvDJ;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,QAAQ;EACR;;UA4Ce;;EAEf;;EAEA;;;;;;;;;;iBAmCc,kBAAkB,SAAS,2BAA2B;UA4JrD;;EAEf;;EAEA;;EAEA;;EAEA;;;;;;iBAOc,WAAW,SAAS,oBAAoB;;;;;;;;;;;iBC1VxC,sBAAsB;;;
|
|
1
|
+
{"version":3,"file":"pi-coding-agent.d.mts","names":[],"sources":["../../src/compat/vendor/pi-messages.ts","../../src/compat/vendor/pi-session-manager.ts","../../src/compat/vendor/pi-truncate.ts","../../src/compat/vendor/pi-file-mutation-queue.ts","../../src/compat/vendor/pi-config-shim.ts","../../src/compat/vendor/pi-extension-runtime.ts","../../src/compat/vendor/pi-tools/bash.ts","../../src/compat/vendor/pi-tools/read.ts","../../src/compat/vendor/pi-tools/edit.ts","../../src/compat/vendor/pi-tools/write.ts","../../src/compat/vendor/pi-tools/grep.ts","../../src/compat/vendor/pi-tools/find.ts","../../src/compat/vendor/pi-tools/ls.ts","../../src/compat/vendor/pi-compaction.ts","../../src/compat/vendor/pi-frontmatter.ts","../../src/compat/vendor/pi-tool-wrapper.ts","../../src/compat/vendor/pi-trust-store.ts","../../src/compat/vendor/pi-skills-load.ts","../../src/compat/vendor/pi-skills-format.ts","../../src/compat/vendor/pi-shell-config.ts","../../src/compat/vendor/pi-tools/visual-truncate.ts","../../src/compat/vendor/pi-tools/diff-component.ts","../../src/compat/pi-coding-agent.ts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;iBAIR,WAAW,aAAa"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as isToolCallEventType, $t as formatSize, A as createEventBus, At as shouldCompact, B as getPackageDir, Bt as createEditToolDefinition, C as VERSION, Cn as createCustomMessage, Ct as estimateTokens, D as copyToClipboard, Dt as prepareBranchEntries, E as convertToPng, Et as getLastAssistantUsage, F as generateSummary, Ft as createGrepTool, G as highlightCode, Gt as createBashTool, H as getSelectListTheme, Ht as createReadTool, I as generateSummaryWithUsage, It as createGrepToolDefinition, J as isEditToolResult, Jt as truncateToVisualLines, K as initTheme, Kt as createBashToolDefinition, L as getBinDir, Lt as createWriteTool, M as defineTool, Mt as createLsToolDefinition, N as ensureTool, Nt as createFindTool, O as createAgentSession, Ot as prepareCompaction, P as generateBranchSummary, Pt as createFindToolDefinition, Q as isReadToolResult, Qt as DEFAULT_MAX_LINES, R as getLanguageFromPath, Rt as createWriteToolDefinition, S as UserMessageComponent, Sn as createCompactionSummaryMessage, St as collectEntriesForBranchSummary, T as compact, Tt as findTurnStartIndex, U as getSettingsListTheme, Ut as createReadToolDefinition, V as getReadmePath, Vt as renderDiff, W as getToolPath, Wt as bashToolSystemPromptContribution, X as isGrepToolResult, Xt as withFileMutationQueue, Y as isFindToolResult, Yt as createExtensionRuntime, Z as isLsToolResult, Zt as DEFAULT_MAX_BYTES, _ as ModelRuntime, _n as COMPACTION_SUMMARY_PREFIX, _t as wrapToolDefinitions, a as CustomMessageComponent, an as assertValidSessionId, at as rawKeyHint, b as Theme, bn as convertToLlm, bt as DEFAULT_COMPACTION_SETTINGS, c as DynamicBorder, cn as findMostRecentSession, ct as theme, d as ExtensionRunner, dn as loadEntriesFromFile, dt as loadSkills, en as truncateHead, et as isWriteToolResult, f as ExtensionSelectorComponent, fn as migrateSessionEntries, ft as loadSkillsFromDir, g as ModelRegistry, gn as BRANCH_SUMMARY_SUFFIX, gt as wrapToolDefinition, h as InMemorySettingsStorage, hn as BRANCH_SUMMARY_PREFIX, ht as wrapRegisteredTools, i as CustomEditor, in as SessionManager, it as processImage, j as createReadOnlyTools, jt as createLsTool, k as createCodingTools, kt as serializeConversation, l as ExtensionEditorComponent, ln as getDefaultSessionDir, lt as getShellConfig, m as FooterComponent, mn as sessionEntryToContextMessages, mt as wrapRegisteredTool, n as BorderedLoader, nn as truncateTail, nt as keyText, o as DefaultPackageManager, on as buildContextEntries, ot as readStoredCredential, p as FileSettingsStorage, pn as parseSessionEntries, pt as ProjectTrustStore, q as isBashToolResult, qt as createLocalBashOperations, r as CONFIG_DIR_NAME, rn as CURRENT_SESSION_VERSION, rt as parseSkillBlock, s as DefaultResourceLoader, sn as buildSessionContext, st as resizeImage, t as AssistantMessageComponent, tn as truncateLine, tt as keyHint, u as ExtensionInputComponent, un as getLatestCompactionEntry, ut as formatSkillsForPrompt, v as SettingsManager, vn as COMPACTION_SUMMARY_SUFFIX, vt as parseFrontmatter, w as __setSubagentSessionFactory, wt as findCutPoint, x as ToolExecutionComponent, xn as createBranchSummaryMessage, xt as calculateContextTokens, y as SettingsSelectorComponent, yn as bashExecutionToText, yt as stripFrontmatter, z as getMarkdownTheme, zt as createEditTool } from "../pi-coding-agent-CYnmeJEx.mjs";
|
|
3
3
|
import { t as getAgentDir } from "../pi-config-shim-CZ1wFzqM.mjs";
|
|
4
4
|
export { AssistantMessageComponent, BRANCH_SUMMARY_PREFIX, BRANCH_SUMMARY_SUFFIX, BorderedLoader, COMPACTION_SUMMARY_PREFIX, COMPACTION_SUMMARY_SUFFIX, CONFIG_DIR_NAME, CURRENT_SESSION_VERSION, CustomEditor, CustomMessageComponent, DEFAULT_COMPACTION_SETTINGS, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, DefaultPackageManager, DefaultResourceLoader, DynamicBorder, ExtensionEditorComponent, ExtensionInputComponent, ExtensionRunner, ExtensionSelectorComponent, FileSettingsStorage, FooterComponent, InMemorySettingsStorage, ModelRegistry, ModelRuntime, ProjectTrustStore, SessionManager, SettingsManager, SettingsSelectorComponent, Theme, ToolExecutionComponent, UserMessageComponent, VERSION, __setSubagentSessionFactory, assertValidSessionId, bashExecutionToText, bashToolSystemPromptContribution, buildContextEntries, buildSessionContext, calculateContextTokens, collectEntriesForBranchSummary, compact, convertToLlm, convertToPng, copyToClipboard, createAgentSession, createBashTool, createBashToolDefinition, createBranchSummaryMessage, createCodingTools, createCompactionSummaryMessage, createCustomMessage, createEditTool, createEditToolDefinition, createEventBus, createExtensionRuntime, createFindTool, createFindToolDefinition, createGrepTool, createGrepToolDefinition, createLocalBashOperations, createLsTool, createLsToolDefinition, createReadOnlyTools, createReadTool, createReadToolDefinition, createWriteTool, createWriteToolDefinition, defineTool, ensureTool, estimateTokens, findCutPoint, findMostRecentSession, findTurnStartIndex, formatSize, formatSkillsForPrompt, generateBranchSummary, generateSummary, generateSummaryWithUsage, getAgentDir, getBinDir, getDefaultSessionDir, getLanguageFromPath, getLastAssistantUsage, getLatestCompactionEntry, getMarkdownTheme, getPackageDir, getReadmePath, getSelectListTheme, getSettingsListTheme, getShellConfig, getToolPath, highlightCode, initTheme, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, keyHint, keyText, loadEntriesFromFile, loadSkills, loadSkillsFromDir, migrateSessionEntries, parseFrontmatter, parseSessionEntries, parseSkillBlock, prepareBranchEntries, prepareCompaction, processImage, rawKeyHint, readStoredCredential, renderDiff, resizeImage, serializeConversation, sessionEntryToContextMessages, shouldCompact, stripFrontmatter, theme, truncateHead, truncateLine, truncateTail, truncateToVisualLines, withFileMutationQueue, wrapRegisteredTool, wrapRegisteredTools, wrapToolDefinition, wrapToolDefinitions };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { a as builtinProviders } from "./pi-ai-Dyg4zyLZ.mjs";
|
|
3
|
-
import "./pi-coding-agent-
|
|
3
|
+
import "./pi-coding-agent-CYnmeJEx.mjs";
|
|
4
4
|
import { t as getAgentDir } from "./pi-config-shim-CZ1wFzqM.mjs";
|
|
5
5
|
import { i as resolveOAuthApiKey, o as storedOAuthCredential, r as providerSupportsOAuth, t as FileCredentialStore } from "./oauth-bridge-CfyImWx4.mjs";
|
|
6
6
|
import { join } from "node:path";
|
package/dist/host.d.mts
CHANGED
|
@@ -22,16 +22,6 @@ declare function manifestForInstalled(pkg: ResolvedPiPackage): Promise<Generated
|
|
|
22
22
|
* host or their siblings — matching Pi's own per-extension error isolation.
|
|
23
23
|
*/
|
|
24
24
|
declare function applyPiHost(ctx: Context, config: PiHostConfig, anchor?: string): Promise<void>;
|
|
25
|
-
interface HostBundleOptions {
|
|
26
|
-
outDir: string;
|
|
27
|
-
/** npm specs, e.g. "@narumitw/pi-lsp@0.49.4" or "pi-ask-user". */
|
|
28
|
-
packages: string[];
|
|
29
|
-
bundleName?: string;
|
|
30
|
-
}
|
|
31
|
-
declare function generateHostBundle(options: HostBundleOptions): Promise<{
|
|
32
|
-
outDir: string;
|
|
33
|
-
packageName: string;
|
|
34
|
-
}>;
|
|
35
25
|
//#endregion
|
|
36
|
-
export {
|
|
26
|
+
export { PiHostConfig, PiHostPackageSpec, applyPiHost, manifestForInstalled };
|
|
37
27
|
//# sourceMappingURL=host.d.mts.map
|
package/dist/host.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.mts","names":[],"sources":["../src/host.ts"],"mappings":";;;;KAmBK,gBAAgB;UAEJ;;EAEf;;EAEA,SAAS;;UAGM;EACf,UAAU,eAAe;;EAEzB,2BAA2B;;;iBAuBP,qBAAqB,KAAK,oBAAoB,QAAQ;;;;;;iBA8DtD,YAAY,KAAK,SAAS,QAAQ,cAAc,kBAAkB
|
|
1
|
+
{"version":3,"file":"host.d.mts","names":[],"sources":["../src/host.ts"],"mappings":";;;;KAmBK,gBAAgB;UAEJ;;EAEf;;EAEA,SAAS;;UAGM;EACf,UAAU,eAAe;;EAEzB,2BAA2B;;;iBAuBP,qBAAqB,KAAK,oBAAoB,QAAQ;;;;;;iBA8DtD,YAAY,KAAK,SAAS,QAAQ,cAAc,kBAAkB"}
|
package/dist/host.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import { r as registerVisionCompanions, t as applyPiPackage } from "./runtime-
|
|
2
|
+
import { r as registerVisionCompanions, t as applyPiPackage } from "./runtime-B_Ig28og.mjs";
|
|
3
3
|
import { t as resolvePiPackage } from "./source-0sA5z08z.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
|
-
import {
|
|
5
|
+
import { readFile } from "node:fs/promises";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import { basename, dirname, join, relative } from "node:path";
|
|
8
8
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -109,102 +109,7 @@ async function applyPiHost(ctx, config, anchor) {
|
|
|
109
109
|
}
|
|
110
110
|
if (errors.length > 0 && errors.length === normalizeSpecs(config).length) throw new Error(`pi2dsh host mounted no packages; first failure: ${errors[0].name}: ${errors[0].error}`);
|
|
111
111
|
}
|
|
112
|
-
function splitSpec(spec) {
|
|
113
|
-
const at = spec.lastIndexOf("@");
|
|
114
|
-
if (at > 0) return {
|
|
115
|
-
name: spec.slice(0, at),
|
|
116
|
-
range: spec.slice(at + 1)
|
|
117
|
-
};
|
|
118
|
-
return {
|
|
119
|
-
name: spec,
|
|
120
|
-
range: "*"
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
async function firstExisting(paths) {
|
|
124
|
-
for (const path of paths) try {
|
|
125
|
-
await stat(path);
|
|
126
|
-
return path;
|
|
127
|
-
} catch {}
|
|
128
|
-
throw new Error(`cannot locate pi2dsh runtime artifact; tried: ${paths.join(", ")}`);
|
|
129
|
-
}
|
|
130
|
-
async function copyEmbeddedHostRuntime(outDir) {
|
|
131
|
-
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
132
|
-
const hostSource = await firstExisting([join(moduleDir, "host.mjs"), join(moduleDir, "../dist/host.mjs")]);
|
|
133
|
-
const distRoot = dirname(hostSource);
|
|
134
|
-
const targetRoot = join(outDir, "runtime");
|
|
135
|
-
await mkdir(join(targetRoot, "compat", "vendor"), { recursive: true });
|
|
136
|
-
for (const entry of await readdir(distRoot)) if (entry.endsWith(".mjs") || entry.endsWith(".d.mts")) await cp(join(distRoot, entry), join(targetRoot, entry));
|
|
137
|
-
for (const sub of ["compat", join("compat", "vendor")]) {
|
|
138
|
-
const dir = join(distRoot, sub);
|
|
139
|
-
try {
|
|
140
|
-
for (const entry of await readdir(dir)) if (entry.endsWith(".mjs")) await cp(join(dir, entry), join(targetRoot, sub, entry));
|
|
141
|
-
} catch {}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
async function generateHostBundle(options) {
|
|
145
|
-
const specs = options.packages.map(splitSpec);
|
|
146
|
-
if (specs.length === 0) throw new Error("host bundle requires at least one Pi package spec");
|
|
147
|
-
const packageName = options.bundleName ?? "dsh-pi-host";
|
|
148
|
-
await mkdir(options.outDir, { recursive: true });
|
|
149
|
-
await copyEmbeddedHostRuntime(options.outDir);
|
|
150
|
-
const packageJson = {
|
|
151
|
-
name: packageName,
|
|
152
|
-
version: "0.1.0",
|
|
153
|
-
description: `pi2dsh host bundle mounting ${specs.map((spec) => spec.name).join(", ")} as native DSH plugins`,
|
|
154
|
-
type: "module",
|
|
155
|
-
main: "./index.js",
|
|
156
|
-
files: [
|
|
157
|
-
"index.js",
|
|
158
|
-
"cordis.patch.yml",
|
|
159
|
-
"runtime",
|
|
160
|
-
"PI2DSH-LICENSE",
|
|
161
|
-
"README.md"
|
|
162
|
-
],
|
|
163
|
-
dependencies: {
|
|
164
|
-
...Object.fromEntries(specs.map((spec) => [spec.name, spec.range])),
|
|
165
|
-
jiti: "^2.7.0",
|
|
166
|
-
"get-east-asian-width": "^1.6.0",
|
|
167
|
-
marked: "^16.4.1",
|
|
168
|
-
typebox: "^1.0.4",
|
|
169
|
-
tinyglobby: "^0.2.15",
|
|
170
|
-
"cross-spawn": "^7.0.6",
|
|
171
|
-
diff: "^9.0.0",
|
|
172
|
-
"@deepseek-ai/dsh-skill-filesystem": "^0.1.0-rc.6",
|
|
173
|
-
openai: "^6.40.0"
|
|
174
|
-
},
|
|
175
|
-
peerDependencies: {
|
|
176
|
-
"@deepseek-ai/dsh-llm": "^0.1.0-rc.6",
|
|
177
|
-
"@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.6"
|
|
178
|
-
},
|
|
179
|
-
keywords: [
|
|
180
|
-
"dsh-plugin",
|
|
181
|
-
"deepseek-harness",
|
|
182
|
-
"pi-package",
|
|
183
|
-
"pi2dsh",
|
|
184
|
-
"pi-host"
|
|
185
|
-
],
|
|
186
|
-
license: "MIT",
|
|
187
|
-
dsh: { bundle: { patch: "./cordis.patch.yml" } }
|
|
188
|
-
};
|
|
189
|
-
await writeFile(join(options.outDir, "package.json"), `${JSON.stringify(packageJson, null, 2)}\n`);
|
|
190
|
-
const hostConfig = { packages: specs.map((spec) => spec.name) };
|
|
191
|
-
const indexSource = `import { applyPiHost } from './runtime/host.mjs'\n\nexport const name = ${JSON.stringify(packageName)}\nexport const inject = ${JSON.stringify([
|
|
192
|
-
"tools",
|
|
193
|
-
"systemPrompt",
|
|
194
|
-
"commands",
|
|
195
|
-
"skills"
|
|
196
|
-
])}\n\nconst hostConfig = ${JSON.stringify(hostConfig, null, 2)}\n\nexport async function apply(ctx, config = {}) {\n await applyPiHost(ctx, { ...hostConfig, ...config }, new URL(import.meta.url).pathname)\n}\n`;
|
|
197
|
-
await writeFile(join(options.outDir, "index.js"), indexSource);
|
|
198
|
-
await writeFile(join(options.outDir, "cordis.patch.yml"), `- insert:\n - id: ${packageName}\n name: ${JSON.stringify(packageName)}\n`);
|
|
199
|
-
const licenseSource = await firstExisting([join(dirname(fileURLToPath(import.meta.url)), "compat/vendor/PI-LICENSE"), join(dirname(fileURLToPath(import.meta.url)), "../src/compat/vendor/PI-LICENSE")]);
|
|
200
|
-
await cp(licenseSource, join(options.outDir, "PI2DSH-LICENSE"));
|
|
201
|
-
await writeFile(join(options.outDir, "README.md"), `# ${packageName}\n\nA [pi2dsh](https://github.com/weijiafu14/pi2dsh) host bundle. The Pi packages below are installed as ordinary npm dependencies and mounted at load time — no per-package conversion, no vendored source snapshots.\n\n` + specs.map((spec) => `- \`${spec.name}@${spec.range}\`\n`).join("") + "\nInstall:\n\n```sh\ndsh plugin --profile headless add file:$PWD\ndsh --profile headless --dump-config\n```\n\nThe packages execute their original Pi extension source inside the pi2dsh Host ABI; install only sources you trust. Run `pi2dsh inspect <package>` for each package's compatibility report.\n");
|
|
202
|
-
return {
|
|
203
|
-
outDir: options.outDir,
|
|
204
|
-
packageName
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
112
|
//#endregion
|
|
208
|
-
export { applyPiHost,
|
|
113
|
+
export { applyPiHost, manifestForInstalled };
|
|
209
114
|
|
|
210
115
|
//# sourceMappingURL=host.mjs.map
|
package/dist/host.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.mjs","names":[],"sources":["../src/host.ts"],"sourcesContent":["// PiHostOnDSH: one DSH plugin that hosts unmodified Pi packages.\n//\n// Instead of converting each package into a vendored bundle, the host bundle\n// declares Pi packages as ordinary npm dependencies; DSH's plugin manager\n// (pnpm) installs them, and at load time this module resolves each installed\n// package, discovers its Pi entry points, and mounts it through the same\n// package-agnostic runtime as converted bundles. One host, any package —\n// there is deliberately no per-package branching here.\n\nimport { existsSync, readFileSync } from 'node:fs'\nimport { readdir, readFile, stat, writeFile, mkdir, cp } from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nimport { basename, dirname, join, relative } from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport type { Context } from '@deepseek-ai/cordis'\nimport { applyPiPackage, registerVisionCompanions } from './runtime.js'\nimport { resolvePiPackage } from './source.js'\nimport type { GeneratedRuntimeManifest, ResolvedPiPackage } from './types.js'\n\ntype UnknownRecord = Record<string, unknown>\n\nexport interface PiHostPackageSpec {\n /** npm package name as installed in the host bundle's node_modules. */\n name: string\n /** Optional per-package config forwarded to the runtime. */\n config?: UnknownRecord\n}\n\nexport interface PiHostConfig {\n packages: Array<string | PiHostPackageSpec>\n /** Image-admission companions: default automatic; `false` off; explicit map narrows. */\n visionCompanions?: false | Record<string, readonly string[]>\n}\n\nfunction parseFrontmatter(text: string): { attributes: Record<string, string>; body: string } {\n const normalized = text.replace(/\\r\\n?/gu, '\\n')\n if (!normalized.startsWith('---')) return { attributes: {}, body: normalized }\n const endIndex = normalized.indexOf('\\n---', 3)\n if (endIndex === -1) return { attributes: {}, body: normalized }\n const attributes: Record<string, string> = {}\n for (const line of normalized.slice(4, endIndex).split('\\n')) {\n const separator = line.indexOf(':')\n if (separator === -1) continue\n const key = line.slice(0, separator).trim()\n let value = line.slice(separator + 1).trim()\n if ((value.startsWith('\"') && value.endsWith('\"')) || (value.startsWith(\"'\") && value.endsWith(\"'\"))) {\n value = value.slice(1, -1)\n }\n if (key.length > 0) attributes[key] = value\n }\n return { attributes, body: normalized.slice(endIndex + 4).trim() }\n}\n\n/** Build a runtime manifest in place over an installed Pi package directory. */\nexport async function manifestForInstalled(pkg: ResolvedPiPackage): Promise<GeneratedRuntimeManifest> {\n const relativeTo = (file: string): string => relative(pkg.rootDir, file).replaceAll('\\\\', '/')\n\n const skillDirs = new Set<string>()\n for (const file of pkg.resources.skills) {\n // <dir>/<name>/SKILL.md contributes <dir>; a flat <dir>/<name>.md contributes <dir>.\n skillDirs.add(relativeTo(basename(file) === 'SKILL.md' ? dirname(dirname(file)) : dirname(file)))\n }\n\n const prompts: GeneratedRuntimeManifest['prompts'] = []\n const promptNames = new Set<string>()\n for (const source of pkg.resources.prompts) {\n const name = basename(source, '.md').toLowerCase().replace(/[^a-z0-9_-]+/gu, '-')\n if (promptNames.has(name)) throw new Error(`prompt command name collision in ${pkg.identity.name}: ${name}`)\n promptNames.add(name)\n const { attributes, body } = parseFrontmatter(await readFile(source, 'utf8'))\n const firstLine = body.split(/\\r?\\n/u).map(line => line.trim()).find(Boolean)\n prompts.push({\n name,\n description: attributes.description ?? firstLine ?? `Run migrated Pi prompt ${name}`,\n ...(attributes['argument-hint'] !== undefined ? { argumentHint: attributes['argument-hint'] } : {}),\n path: relativeTo(source),\n })\n }\n\n return {\n schemaVersion: 1,\n package: pkg.identity,\n extensions: pkg.resources.extensions.map(relativeTo),\n skillDirs: [...skillDirs].sort(),\n prompts,\n }\n}\n\nfunction normalizeSpecs(config: PiHostConfig): PiHostPackageSpec[] {\n const packages = Array.isArray(config?.packages) ? config.packages : []\n return packages.map(spec => (typeof spec === 'string' ? { name: spec } : spec))\n .filter(spec => typeof spec?.name === 'string' && spec.name.length > 0)\n}\n\nfunction resolveInstalledDir(anchor: string, packageName: string): string {\n const require = createRequire(anchor)\n try {\n return dirname(require.resolve(`${packageName}/package.json`))\n } catch {\n // Modern strict `exports` maps refuse the package.json subpath, and pure\n // ESM packages (no \"require\" condition) refuse CJS entry resolution too.\n // Locate the installed directory on the filesystem instead: probe every\n // node_modules candidate on the resolution path — no exports involved.\n for (const candidate of require.resolve.paths(packageName) ?? []) {\n const dir = join(candidate, packageName)\n if (existsSync(join(dir, 'package.json'))) return dir\n }\n throw new Error(`cannot locate the installed package directory for ${JSON.stringify(packageName)} near ${JSON.stringify(anchor)}`)\n }\n}\n\n/**\n * Mount every configured Pi package from the host bundle's own node_modules.\n * Packages that fail to mount report their error and do not take down the\n * host or their siblings — matching Pi's own per-extension error isolation.\n */\nexport async function applyPiHost(ctx: Context, config: PiHostConfig, anchor?: string): Promise<void> {\n const anchorPath = anchor ?? fileURLToPath(import.meta.url)\n registerVisionCompanions(ctx, config.visionCompanions)\n const errors: Array<{ name: string; error: string }> = []\n for (const spec of normalizeSpecs(config)) {\n try {\n const dir = resolveInstalledDir(anchorPath, spec.name)\n const pkg = await resolvePiPackage(dir)\n try {\n const manifest = await manifestForInstalled(pkg)\n await applyPiPackage(ctx, {\n rootUrl: pathToFileURL(`${pkg.rootDir}/`),\n manifest,\n ...(spec.config === undefined ? {} : { config: spec.config }),\n })\n } finally {\n await pkg.dispose()\n }\n } catch (error) {\n errors.push({ name: spec.name, error: error instanceof Error ? error.message : String(error) })\n }\n }\n for (const failure of errors) {\n const log = (ctx as unknown as { logger?: { warn?(message: string): void } }).logger\n const warn = log?.warn?.bind(log) ?? console.warn\n warn(`[pi2dsh host] failed to mount ${failure.name}: ${failure.error}`)\n }\n if (errors.length > 0 && errors.length === normalizeSpecs(config).length) {\n throw new Error(`pi2dsh host mounted no packages; first failure: ${errors[0]!.name}: ${errors[0]!.error}`)\n }\n}\n\n// ---------------------------------------------------------------------------\n// Host bundle generation\n// ---------------------------------------------------------------------------\n\nexport interface HostBundleOptions {\n outDir: string\n /** npm specs, e.g. \"@narumitw/pi-lsp@0.49.4\" or \"pi-ask-user\". */\n packages: string[]\n bundleName?: string\n}\n\nfunction splitSpec(spec: string): { name: string; range: string } {\n const at = spec.lastIndexOf('@')\n if (at > 0) return { name: spec.slice(0, at), range: spec.slice(at + 1) }\n return { name: spec, range: '*' }\n}\n\nasync function firstExisting(paths: string[]): Promise<string> {\n for (const path of paths) {\n try {\n await stat(path)\n return path\n } catch {\n // Try the next layout.\n }\n }\n throw new Error(`cannot locate pi2dsh runtime artifact; tried: ${paths.join(', ')}`)\n}\n\nasync function copyEmbeddedHostRuntime(outDir: string): Promise<void> {\n const moduleDir = dirname(fileURLToPath(import.meta.url))\n const hostSource = await firstExisting([\n join(moduleDir, 'host.mjs'),\n join(moduleDir, '../dist/host.mjs'),\n ])\n const distRoot = dirname(hostSource)\n const targetRoot = join(outDir, 'runtime')\n await mkdir(join(targetRoot, 'compat', 'vendor'), { recursive: true })\n for (const entry of await readdir(distRoot)) {\n if (entry.endsWith('.mjs') || entry.endsWith('.d.mts')) {\n await cp(join(distRoot, entry), join(targetRoot, entry))\n }\n }\n for (const sub of ['compat', join('compat', 'vendor')]) {\n const dir = join(distRoot, sub)\n try {\n for (const entry of await readdir(dir)) {\n if (entry.endsWith('.mjs')) await cp(join(dir, entry), join(targetRoot, sub, entry))\n }\n } catch {\n // dist layout without that subdirectory\n }\n }\n}\n\nexport async function generateHostBundle(options: HostBundleOptions): Promise<{ outDir: string; packageName: string }> {\n const specs = options.packages.map(splitSpec)\n if (specs.length === 0) throw new Error('host bundle requires at least one Pi package spec')\n const packageName = options.bundleName ?? 'dsh-pi-host'\n await mkdir(options.outDir, { recursive: true })\n await copyEmbeddedHostRuntime(options.outDir)\n\n const packageJson = {\n name: packageName,\n version: '0.1.0',\n description: `pi2dsh host bundle mounting ${specs.map(spec => spec.name).join(', ')} as native DSH plugins`,\n type: 'module',\n main: './index.js',\n files: ['index.js', 'cordis.patch.yml', 'runtime', 'PI2DSH-LICENSE', 'README.md'],\n dependencies: {\n ...Object.fromEntries(specs.map(spec => [spec.name, spec.range])),\n jiti: '^2.7.0',\n 'get-east-asian-width': '^1.6.0',\n marked: '^16.4.1',\n typebox: '^1.0.4',\n tinyglobby: '^0.2.15',\n // The vendored Pi built-in tool constructors spawn through cross-spawn\n // and diff exactly as Pi does — same runtime set the convert bundle\n // carries (generator.ts keeps the sibling list).\n 'cross-spawn': '^7.0.6',\n diff: '^9.0.0',\n '@deepseek-ai/dsh-skill-filesystem': '^0.1.0-rc.6',\n // The bridge's own openai-completions client (openai SDK) serves the\n // common gateway protocol; rarer apis lazily use a real pi-ai from\n // the mounted packages' own dependency trees. A direct pi-ai\n // dependency would drag @google/genai → protobufjs, whose blocked\n // install script fails `dsh plugin add` for transitive dependencies.\n openai: '^6.40.0',\n },\n peerDependencies: {\n '@deepseek-ai/dsh-llm': '^0.1.0-rc.6',\n '@deepseek-ai/dsh-system-prompt': '^0.1.0-rc.6',\n },\n keywords: ['dsh-plugin', 'deepseek-harness', 'pi-package', 'pi2dsh', 'pi-host'],\n license: 'MIT',\n dsh: { bundle: { patch: './cordis.patch.yml' } },\n }\n await writeFile(join(options.outDir, 'package.json'), `${JSON.stringify(packageJson, null, 2)}\\n`)\n\n const hostConfig: PiHostConfig = { packages: specs.map(spec => spec.name) }\n const indexSource = `import { applyPiHost } from './runtime/host.mjs'\\n\\n`\n + `export const name = ${JSON.stringify(packageName)}\\n`\n + `export const inject = ${JSON.stringify(['tools', 'systemPrompt', 'commands', 'skills'])}\\n\\n`\n + `const hostConfig = ${JSON.stringify(hostConfig, null, 2)}\\n\\n`\n + `export async function apply(ctx, config = {}) {\\n`\n + ` await applyPiHost(ctx, { ...hostConfig, ...config }, new URL(import.meta.url).pathname)\\n`\n + `}\\n`\n await writeFile(join(options.outDir, 'index.js'), indexSource)\n\n await writeFile(join(options.outDir, 'cordis.patch.yml'),\n `- insert:\\n - id: ${packageName}\\n name: ${JSON.stringify(packageName)}\\n`)\n\n const licenseSource = await firstExisting([\n join(dirname(fileURLToPath(import.meta.url)), 'compat/vendor/PI-LICENSE'),\n join(dirname(fileURLToPath(import.meta.url)), '../src/compat/vendor/PI-LICENSE'),\n ])\n await cp(licenseSource, join(options.outDir, 'PI2DSH-LICENSE'))\n\n await writeFile(join(options.outDir, 'README.md'),\n `# ${packageName}\\n\\n`\n + `A [pi2dsh](https://github.com/weijiafu14/pi2dsh) host bundle. The Pi packages below are installed as ordinary npm dependencies and mounted at load time — no per-package conversion, no vendored source snapshots.\\n\\n`\n + specs.map(spec => `- \\`${spec.name}@${spec.range}\\`\\n`).join('')\n + `\\nInstall:\\n\\n\\`\\`\\`sh\\ndsh plugin --profile headless add file:$PWD\\ndsh --profile headless --dump-config\\n\\`\\`\\`\\n`\n + `\\nThe packages execute their original Pi extension source inside the pi2dsh Host ABI; install only sources you trust. Run \\`pi2dsh inspect <package>\\` for each package's compatibility report.\\n`)\n\n return { outDir: options.outDir, packageName }\n}\n"],"mappings":";;;;;;;;;AAkCA,SAAS,iBAAiB,MAAoE;CAC5F,MAAM,aAAa,KAAK,QAAQ,WAAW,IAAI;CAC/C,IAAI,CAAC,WA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gBAAgB,CAAC;CAE9D,MAAM,UAAU,KAAK,QAAQ,QAAQ,WAAW,GAC9C,KAAK,YAAY,8NAEf,MAAM,KAAI,SAAQ,OAAO,KAAK,KAAK,GAAG,KAAK,MAAM,KAAK,CAAC,CAAC,KAAK,EAAE,IAC/D,8SACmM;CAEvM,OAAO;EAAE,QAAQ,QAAQ;EAAQ;CAAY;AAC/C"}
|
|
1
|
+
{"version":3,"file":"host.mjs","names":[],"sources":["../src/host.ts"],"sourcesContent":["// PiHostOnDSH: one DSH plugin that hosts unmodified Pi packages.\n//\n// Instead of converting each package into a vendored bundle, the host bundle\n// declares Pi packages as ordinary npm dependencies; DSH's plugin manager\n// (pnpm) installs them, and at load time this module resolves each installed\n// package, discovers its Pi entry points, and mounts it through the same\n// package-agnostic runtime as converted bundles. One host, any package —\n// there is deliberately no per-package branching here.\n\nimport { existsSync, readFileSync } from 'node:fs'\nimport { readdir, readFile, stat, writeFile, mkdir, cp } from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nimport { basename, dirname, join, relative } from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport type { Context } from '@deepseek-ai/cordis'\nimport { applyPiPackage, registerVisionCompanions } from './runtime.js'\nimport { resolvePiPackage } from './source.js'\nimport type { GeneratedRuntimeManifest, ResolvedPiPackage } from './types.js'\n\ntype UnknownRecord = Record<string, unknown>\n\nexport interface PiHostPackageSpec {\n /** npm package name as installed in the host bundle's node_modules. */\n name: string\n /** Optional per-package config forwarded to the runtime. */\n config?: UnknownRecord\n}\n\nexport interface PiHostConfig {\n packages: Array<string | PiHostPackageSpec>\n /** Image-admission companions: default automatic; `false` off; explicit map narrows. */\n visionCompanions?: false | Record<string, readonly string[]>\n}\n\nfunction parseFrontmatter(text: string): { attributes: Record<string, string>; body: string } {\n const normalized = text.replace(/\\r\\n?/gu, '\\n')\n if (!normalized.startsWith('---')) return { attributes: {}, body: normalized }\n const endIndex = normalized.indexOf('\\n---', 3)\n if (endIndex === -1) return { attributes: {}, body: normalized }\n const attributes: Record<string, string> = {}\n for (const line of normalized.slice(4, endIndex).split('\\n')) {\n const separator = line.indexOf(':')\n if (separator === -1) continue\n const key = line.slice(0, separator).trim()\n let value = line.slice(separator + 1).trim()\n if ((value.startsWith('\"') && value.endsWith('\"')) || (value.startsWith(\"'\") && value.endsWith(\"'\"))) {\n value = value.slice(1, -1)\n }\n if (key.length > 0) attributes[key] = value\n }\n return { attributes, body: normalized.slice(endIndex + 4).trim() }\n}\n\n/** Build a runtime manifest in place over an installed Pi package directory. */\nexport async function manifestForInstalled(pkg: ResolvedPiPackage): Promise<GeneratedRuntimeManifest> {\n const relativeTo = (file: string): string => relative(pkg.rootDir, file).replaceAll('\\\\', '/')\n\n const skillDirs = new Set<string>()\n for (const file of pkg.resources.skills) {\n // <dir>/<name>/SKILL.md contributes <dir>; a flat <dir>/<name>.md contributes <dir>.\n skillDirs.add(relativeTo(basename(file) === 'SKILL.md' ? dirname(dirname(file)) : dirname(file)))\n }\n\n const prompts: GeneratedRuntimeManifest['prompts'] = []\n const promptNames = new Set<string>()\n for (const source of pkg.resources.prompts) {\n const name = basename(source, '.md').toLowerCase().replace(/[^a-z0-9_-]+/gu, '-')\n if (promptNames.has(name)) throw new Error(`prompt command name collision in ${pkg.identity.name}: ${name}`)\n promptNames.add(name)\n const { attributes, body } = parseFrontmatter(await readFile(source, 'utf8'))\n const firstLine = body.split(/\\r?\\n/u).map(line => line.trim()).find(Boolean)\n prompts.push({\n name,\n description: attributes.description ?? firstLine ?? `Run migrated Pi prompt ${name}`,\n ...(attributes['argument-hint'] !== undefined ? { argumentHint: attributes['argument-hint'] } : {}),\n path: relativeTo(source),\n })\n }\n\n return {\n schemaVersion: 1,\n package: pkg.identity,\n extensions: pkg.resources.extensions.map(relativeTo),\n skillDirs: [...skillDirs].sort(),\n prompts,\n }\n}\n\nfunction normalizeSpecs(config: PiHostConfig): PiHostPackageSpec[] {\n const packages = Array.isArray(config?.packages) ? config.packages : []\n return packages.map(spec => (typeof spec === 'string' ? { name: spec } : spec))\n .filter(spec => typeof spec?.name === 'string' && spec.name.length > 0)\n}\n\nfunction resolveInstalledDir(anchor: string, packageName: string): string {\n const require = createRequire(anchor)\n try {\n return dirname(require.resolve(`${packageName}/package.json`))\n } catch {\n // Modern strict `exports` maps refuse the package.json subpath, and pure\n // ESM packages (no \"require\" condition) refuse CJS entry resolution too.\n // Locate the installed directory on the filesystem instead: probe every\n // node_modules candidate on the resolution path — no exports involved.\n for (const candidate of require.resolve.paths(packageName) ?? []) {\n const dir = join(candidate, packageName)\n if (existsSync(join(dir, 'package.json'))) return dir\n }\n throw new Error(`cannot locate the installed package directory for ${JSON.stringify(packageName)} near ${JSON.stringify(anchor)}`)\n }\n}\n\n/**\n * Mount every configured Pi package from the host bundle's own node_modules.\n * Packages that fail to mount report their error and do not take down the\n * host or their siblings — matching Pi's own per-extension error isolation.\n */\nexport async function applyPiHost(ctx: Context, config: PiHostConfig, anchor?: string): Promise<void> {\n const anchorPath = anchor ?? fileURLToPath(import.meta.url)\n registerVisionCompanions(ctx, config.visionCompanions)\n const errors: Array<{ name: string; error: string }> = []\n for (const spec of normalizeSpecs(config)) {\n try {\n const dir = resolveInstalledDir(anchorPath, spec.name)\n const pkg = await resolvePiPackage(dir)\n try {\n const manifest = await manifestForInstalled(pkg)\n await applyPiPackage(ctx, {\n rootUrl: pathToFileURL(`${pkg.rootDir}/`),\n manifest,\n ...(spec.config === undefined ? {} : { config: spec.config }),\n })\n } finally {\n await pkg.dispose()\n }\n } catch (error) {\n errors.push({ name: spec.name, error: error instanceof Error ? error.message : String(error) })\n }\n }\n for (const failure of errors) {\n const log = (ctx as unknown as { logger?: { warn?(message: string): void } }).logger\n const warn = log?.warn?.bind(log) ?? console.warn\n warn(`[pi2dsh host] failed to mount ${failure.name}: ${failure.error}`)\n }\n if (errors.length > 0 && errors.length === normalizeSpecs(config).length) {\n throw new Error(`pi2dsh host mounted no packages; first failure: ${errors[0]!.name}: ${errors[0]!.error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as ResourceInventory, i as GenerateOptions, n as CompatibilityLevel, o as PackageIdentity, r as CompatibilityReport, s as ResolvedPiPackage, t as CompatibilityFinding } from "./types-7IWJPPvS.mjs";
|
|
3
|
-
import { applyPiHost,
|
|
3
|
+
import { applyPiHost, manifestForInstalled } from "./host.mjs";
|
|
4
4
|
import { Context } from "@deepseek-ai/cordis";
|
|
5
|
-
//#region src/generator.d.ts
|
|
6
|
-
declare function generateBundle$1(pkg: ResolvedPiPackage, options: GenerateOptions): Promise<{
|
|
7
|
-
outDir: string;
|
|
8
|
-
report: CompatibilityReport;
|
|
9
|
-
packageName: string;
|
|
10
|
-
}>;
|
|
11
|
-
//#endregion
|
|
12
5
|
//#region src/engine.d.ts
|
|
13
6
|
interface EngineConfig {
|
|
14
7
|
/** Mount exactly these packages (skips discovery). */
|
|
@@ -49,15 +42,27 @@ declare function apply(ctx: Context, config?: EngineConfig): Promise<void>;
|
|
|
49
42
|
interface Rule {
|
|
50
43
|
level: CompatibilityLevel;
|
|
51
44
|
detail: string;
|
|
45
|
+
/** How the mapping is built — the DSH seam or service that carries it. */
|
|
46
|
+
design?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A Pi extension surface. `design` is REQUIRED here and optional on Rule: an
|
|
50
|
+
* imported symbol is served by a shim family the docs describe once, but every
|
|
51
|
+
* surface a package can call has to name the DSH mechanism behind it, or the
|
|
52
|
+
* documentation degrades into a list of verdicts nobody can act on. Adding a
|
|
53
|
+
* surface without one is a type error, which is the point.
|
|
54
|
+
*/
|
|
55
|
+
interface SurfaceRule extends Rule {
|
|
56
|
+
design: string;
|
|
52
57
|
}
|
|
53
58
|
declare const PI_CODING_AGENT_PACKAGES: readonly ["@earendil-works/pi-coding-agent", "@mariozechner/pi-coding-agent"];
|
|
54
59
|
declare const PI_TUI_PACKAGES: readonly ["@earendil-works/pi-tui", "@mariozechner/pi-tui"];
|
|
55
60
|
declare const PI_AI_PACKAGES: readonly ["@earendil-works/pi-ai", "@mariozechner/pi-ai"];
|
|
56
61
|
declare const HOST_IMPORT_RULES: Readonly<Record<string, Readonly<Record<string, Rule>>>>;
|
|
57
|
-
declare const CONTEXT_RULES: Readonly<Record<string,
|
|
58
|
-
declare const UI_CONTEXT_RULES: Readonly<Record<string,
|
|
59
|
-
declare const API_RULES: Readonly<Record<string,
|
|
60
|
-
declare const EVENT_RULES: Readonly<Record<string,
|
|
62
|
+
declare const CONTEXT_RULES: Readonly<Record<string, SurfaceRule>>;
|
|
63
|
+
declare const UI_CONTEXT_RULES: Readonly<Record<string, SurfaceRule>>;
|
|
64
|
+
declare const API_RULES: Readonly<Record<string, SurfaceRule>>;
|
|
65
|
+
declare const EVENT_RULES: Readonly<Record<string, SurfaceRule>>;
|
|
61
66
|
declare function ruleForApi(method: string): Rule | undefined;
|
|
62
67
|
declare function ruleForEvent(event: string): Rule;
|
|
63
68
|
declare function ruleForHostImport(packageName: string, importedName: string): Rule | undefined;
|
|
@@ -106,12 +111,6 @@ declare function resolvePiPackage(source: string, cwd?: string): Promise<Resolve
|
|
|
106
111
|
* @returns the compatibility report.
|
|
107
112
|
*/
|
|
108
113
|
declare function analyzePackage(pkg: ResolvedPiPackage): Promise<CompatibilityReport>;
|
|
109
|
-
/**
|
|
110
|
-
* Generate a vendored per-package bundle (CLI `convert`).
|
|
111
|
-
* @param options - generation options (see the generator module).
|
|
112
|
-
* @returns the generation result.
|
|
113
|
-
*/
|
|
114
|
-
declare function generateBundle(...args: Parameters<typeof generateBundle$1>): ReturnType<typeof generateBundle$1>;
|
|
115
114
|
//#endregion
|
|
116
|
-
export { API_RULES, CONTEXT_RULES, type CompatibilityFinding, type CompatibilityLevel, type CompatibilityReport, EVENT_RULES, type EngineConfig, type GenerateOptions, type GeneratedRuntimeManifest, HOST_IMPORT_RULES, PI_AI_PACKAGES, PI_CODING_AGENT_PACKAGES, PI_TUI_PACKAGES, type PackageIdentity, type ResolvedPiPackage, type ResourceInventory, UI_CONTEXT_RULES, analyzePackage, apply, applyPiHost, collectPiMcpServers, convertPiMcpConfig, discoverProfilePiPackages, findProfileRoot,
|
|
115
|
+
export { API_RULES, CONTEXT_RULES, type CompatibilityFinding, type CompatibilityLevel, type CompatibilityReport, EVENT_RULES, type EngineConfig, type GenerateOptions, type GeneratedRuntimeManifest, HOST_IMPORT_RULES, PI_AI_PACKAGES, PI_CODING_AGENT_PACKAGES, PI_TUI_PACKAGES, type PackageIdentity, type ResolvedPiPackage, type ResourceInventory, UI_CONTEXT_RULES, analyzePackage, apply, applyPiHost, collectPiMcpServers, convertPiMcpConfig, discoverProfilePiPackages, findProfileRoot, inject, manifestForInstalled, name, renderMcpPatch, resolvePiPackage, ruleForApi, ruleForContextProperty, ruleForEvent, ruleForHostImport, ruleForUiContextProperty };
|
|
117
116
|
//# sourceMappingURL=index.d.mts.map
|