@pi-archimedes/diff 1.4.0 → 1.4.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/package.json +1 -1
- package/src/index.ts +35 -25
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -72,6 +72,28 @@ export function getDiffSettingsItems(): SettingItem[] {
|
|
|
72
72
|
// Extension entry point
|
|
73
73
|
// ---------------------------------------------------------------------------
|
|
74
74
|
|
|
75
|
+
// Load SDK dependencies at module evaluation time (top-level await) so they are
|
|
76
|
+
// ready before any session_start event fires. If these imports fail the
|
|
77
|
+
// extension will skip diff tool registration gracefully.
|
|
78
|
+
let _sdk: { createWriteTool: any; createEditTool: any } | null = null;
|
|
79
|
+
let _TextComponent: any = null;
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
const [sdk, tui] = await Promise.all([
|
|
83
|
+
import("@earendil-works/pi-coding-agent"),
|
|
84
|
+
import("@earendil-works/pi-tui"),
|
|
85
|
+
]);
|
|
86
|
+
_sdk = {
|
|
87
|
+
createWriteTool: sdk.createWriteTool,
|
|
88
|
+
createEditTool: sdk.createEditTool,
|
|
89
|
+
};
|
|
90
|
+
_TextComponent = tui.Text;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
console.error(
|
|
93
|
+
`[diff] failed to load Pi SDK: ${error instanceof Error ? error.message : String(error)}`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
75
97
|
export function registerDiffTools(
|
|
76
98
|
pi: ExtensionAPI,
|
|
77
99
|
_getTheme: () => Theme,
|
|
@@ -86,29 +108,17 @@ export function registerDiffTools(
|
|
|
86
108
|
setShikiConfig(() => getConfig());
|
|
87
109
|
setRenderConfig(() => getConfig());
|
|
88
110
|
|
|
89
|
-
(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
if (!createWriteTool || !createEditTool || !TextComponent) return;
|
|
104
|
-
|
|
105
|
-
const cwd = process.cwd();
|
|
106
|
-
const home = process.env.HOME ?? "";
|
|
107
|
-
|
|
108
|
-
// Register write tool override
|
|
109
|
-
registerWriteTool(pi, cwd, home, createWriteTool, TextComponent);
|
|
110
|
-
|
|
111
|
-
// Register edit tool override
|
|
112
|
-
registerEditTool(pi, cwd, home, createEditTool);
|
|
113
|
-
})().catch(console.error);
|
|
111
|
+
if (!_sdk?.createWriteTool || !_sdk?.createEditTool || !_TextComponent) {
|
|
112
|
+
console.warn("[diff] SDK not available, skipping diff tool registration");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const cwd = process.cwd();
|
|
117
|
+
const home = process.env.HOME ?? "";
|
|
118
|
+
|
|
119
|
+
// Register write tool override
|
|
120
|
+
registerWriteTool(pi, cwd, home, _sdk.createWriteTool, _TextComponent);
|
|
121
|
+
|
|
122
|
+
// Register edit tool override
|
|
123
|
+
registerEditTool(pi, cwd, home, _sdk.createEditTool);
|
|
114
124
|
}
|