Skip to content

Commit 183cd1f

Browse files
committed
fix(desktop): prune stale schedule prompt dependency
1 parent 5beaaa3 commit 183cd1f

3 files changed

Lines changed: 55 additions & 11 deletions

File tree

packages/desktop/scripts/prepare-mindos-bundle.mjs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
realpathSync,
1313
rmSync,
1414
unlinkSync,
15+
writeFileSync,
1516
} from 'fs';
1617
import path from 'path';
1718
import { createRequire } from 'module';
@@ -25,9 +26,9 @@ export const BUILTIN_AGENT_EXTENSION_RUNTIME_DEPENDENCY_SEEDS = [
2526
'pi-web-access',
2627
];
2728

28-
export const PI_SCHEDULE_PROMPT_LEGACY_RUNTIME_DEPENDENCY_SEEDS = [
29-
// pi-schedule-prompt@0.1.2 still declares the pre-rename package. Keep this
30-
// as a packaging compatibility seed until the extension moves to @earendil.
29+
export const PI_SCHEDULE_PROMPT_STALE_RUNTIME_DEPENDENCIES = [
30+
// pi-schedule-prompt@0.1.2 still declares this pre-rename package, but the
31+
// MindOS wrapper only loads source files where it is a type-only import.
3132
'@mariozechner/pi-coding-agent',
3233
];
3334

@@ -64,7 +65,6 @@ export const RUNTIME_DEPENDENCY_SEEDS = [
6465
'typebox',
6566
'yaml',
6667
...BUILTIN_AGENT_EXTENSION_RUNTIME_DEPENDENCY_SEEDS,
67-
...PI_SCHEDULE_PROMPT_LEGACY_RUNTIME_DEPENDENCY_SEEDS,
6868
...IM_RUNTIME_DEPENDENCY_SEEDS,
6969
];
7070

@@ -113,6 +113,7 @@ export function materializeStandaloneAssets(appDir, options = {}) {
113113
pruneClaudeAgentSdkNativePackages(standaloneDir);
114114
prunePackageDevelopmentPayload(standaloneDir);
115115
pruneRuntimePackageAssets(standaloneDir);
116+
prunePiSchedulePromptStaleDependencies(standaloneDir);
116117
pruneOptionalLocalEmbeddingRuntime(standaloneDir, {
117118
bundleLocalEmbeddingRuntime: options.bundleLocalEmbeddingRuntime === true
118119
|| process.env.MINDOS_BUNDLE_LOCAL_EMBEDDING_RUNTIME === '1',
@@ -754,6 +755,30 @@ export function pruneRuntimePackageAssets(standaloneDir) {
754755
return removed;
755756
}
756757

758+
export function prunePiSchedulePromptStaleDependencies(standaloneDir) {
759+
const packageJsonPath = path.join(standaloneDir, 'node_modules', 'pi-schedule-prompt', 'package.json');
760+
if (!existsSync(packageJsonPath)) return 0;
761+
762+
let pkg;
763+
try {
764+
pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
765+
} catch {
766+
return 0;
767+
}
768+
769+
let removed = 0;
770+
for (const dependencyName of PI_SCHEDULE_PROMPT_STALE_RUNTIME_DEPENDENCIES) {
771+
if (!pkg.dependencies || !Object.hasOwn(pkg.dependencies, dependencyName)) continue;
772+
delete pkg.dependencies[dependencyName];
773+
removed += 1;
774+
}
775+
776+
if (removed > 0) {
777+
writeFileSync(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, 'utf-8');
778+
}
779+
return removed;
780+
}
781+
757782
export function pruneClaudeAgentSdkNativePackages(rootDir) {
758783
if (!existsSync(rootDir)) return 0;
759784
let removed = 0;

packages/desktop/src/prepare-mindos-bundle.test.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
BUILTIN_AGENT_EXTENSION_RUNTIME_DEPENDENCY_SEEDS,
77
IM_RUNTIME_DEPENDENCY_SEEDS,
88
MINDOS_WEB_RUNTIME_EXTENSION_SOURCE_ENTRIES,
9-
PI_SCHEDULE_PROMPT_LEGACY_RUNTIME_DEPENDENCY_SEEDS,
9+
PI_SCHEDULE_PROMPT_STALE_RUNTIME_DEPENDENCIES,
1010
copyAppForBundledRuntime,
1111
materializeStandaloneAssets,
1212
pruneClaudeAgentSdkNativePackages,
@@ -259,18 +259,39 @@ describe('materializeStandaloneAssets', () => {
259259

260260
it('seeds the current PI coding agent package into runtime bundles', () => {
261261
expect(RUNTIME_DEPENDENCY_SEEDS).toContain('@earendil-works/pi-coding-agent');
262+
expect(RUNTIME_DEPENDENCY_SEEDS).not.toContain('@mariozechner/pi-coding-agent');
262263
expect(BUILTIN_AGENT_EXTENSION_RUNTIME_DEPENDENCY_SEEDS).not.toContain('@mariozechner/pi-coding-agent');
263264
});
264265

265-
it('seeds the legacy PI coding agent package required by pi-schedule-prompt', () => {
266-
expect(PI_SCHEDULE_PROMPT_LEGACY_RUNTIME_DEPENDENCY_SEEDS).toEqual([
266+
it('tracks stale pi-schedule-prompt runtime dependencies without seeding them', () => {
267+
expect(PI_SCHEDULE_PROMPT_STALE_RUNTIME_DEPENDENCIES).toEqual([
267268
'@mariozechner/pi-coding-agent',
268269
]);
269-
expect(RUNTIME_DEPENDENCY_SEEDS).toEqual(
270-
expect.arrayContaining(PI_SCHEDULE_PROMPT_LEGACY_RUNTIME_DEPENDENCY_SEEDS),
270+
expect(RUNTIME_DEPENDENCY_SEEDS).not.toEqual(
271+
expect.arrayContaining(PI_SCHEDULE_PROMPT_STALE_RUNTIME_DEPENDENCIES),
271272
);
272273
});
273274

275+
it('prunes stale pi-schedule-prompt dependencies from the standalone package metadata', () => {
276+
const appDir = makeTemp('mindos-app-stale-schedule-prompt-deps-');
277+
writeStandaloneApp(appDir);
278+
279+
const schedulePromptPackage = path.join(appDir, '.next', 'standalone', 'node_modules', 'pi-schedule-prompt');
280+
mkdirSync(schedulePromptPackage, { recursive: true });
281+
writeFileSync(path.join(schedulePromptPackage, 'package.json'), JSON.stringify({
282+
name: 'pi-schedule-prompt',
283+
version: '0.1.2',
284+
dependencies: {
285+
'@mariozechner/pi-coding-agent': 'latest',
286+
},
287+
}));
288+
289+
materializeStandaloneAssets(appDir);
290+
291+
const pkg = JSON.parse(readFileSync(path.join(schedulePromptPackage, 'package.json'), 'utf-8'));
292+
expect(pkg.dependencies).not.toHaveProperty('@mariozechner/pi-coding-agent');
293+
});
294+
274295
it('materializes MindOS-owned runtime extension sources into standalone bundles', () => {
275296
const appDir = makeTemp('mindos-app-runtime-extension-sources-');
276297
writeStandaloneApp(appDir);

scripts/prepare-standalone.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { fileURLToPath } from 'node:url';
1515
import {
1616
BUILTIN_AGENT_EXTENSION_RUNTIME_DEPENDENCY_SEEDS,
1717
IM_RUNTIME_DEPENDENCY_SEEDS,
18-
PI_SCHEDULE_PROMPT_LEGACY_RUNTIME_DEPENDENCY_SEEDS,
1918
materializeStandaloneAssets,
2019
pruneClaudeAgentSdkNativePackages,
2120
pruneRuntimePackageAssets,
@@ -41,7 +40,6 @@ const runtimeDependencySeeds = [
4140
'@anthropic-ai/sdk',
4241
'openai',
4342
...BUILTIN_AGENT_EXTENSION_RUNTIME_DEPENDENCY_SEEDS,
44-
...PI_SCHEDULE_PROMPT_LEGACY_RUNTIME_DEPENDENCY_SEEDS,
4543
...IM_RUNTIME_DEPENDENCY_SEEDS,
4644
];
4745

0 commit comments

Comments
 (0)