@icoretech/warden-mcp 0.2.0 → 0.2.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.
@@ -1,5 +1,5 @@
1
1
  import { spawnSync } from 'node:child_process';
2
- import { existsSync } from 'node:fs';
2
+ import { existsSync, rmSync, writeFileSync } from 'node:fs';
3
3
  import { createRequire } from 'node:module';
4
4
  import { dirname, isAbsolute, relative, resolve } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
@@ -75,12 +75,31 @@ export function resolvePatchPackagePlan({
75
75
  };
76
76
  }
77
77
 
78
+ const bootstrapPackageJson = `${JSON.stringify(
79
+ { name: 'warden-mcp-postinstall-bootstrap', private: true },
80
+ null,
81
+ 2,
82
+ )}\n`;
83
+
84
+ export function ensurePatchPackageAppRoot({
85
+ appRoot,
86
+ exists = existsSync,
87
+ writeFile = writeFileSync,
88
+ } = {}) {
89
+ const packageJsonPath = resolve(appRoot, 'package.json');
90
+ if (exists(packageJsonPath)) return null;
91
+ writeFile(packageJsonPath, bootstrapPackageJson);
92
+ return packageJsonPath;
93
+ }
94
+
78
95
  export function applyBundledBwPatch({
79
96
  packageDir = defaultPackageDir,
80
97
  resolveDependency,
81
98
  exists,
82
99
  spawn = spawnSync,
83
100
  nodeExecPath = process.execPath,
101
+ writeFile,
102
+ removeFile = (path) => rmSync(path, { force: true }),
84
103
  logError = (message) => console.error(message),
85
104
  } = {}) {
86
105
  let plan;
@@ -97,11 +116,24 @@ export function applyBundledBwPatch({
97
116
 
98
117
  if (!plan) return 0;
99
118
 
100
- const result = spawn(nodeExecPath, plan.args, {
101
- cwd: plan.cwd,
102
- stdio: 'inherit',
119
+ const temporaryPackageJsonPath = ensurePatchPackageAppRoot({
120
+ appRoot: plan.cwd,
121
+ exists,
122
+ writeFile,
103
123
  });
104
124
 
125
+ let result;
126
+ try {
127
+ result = spawn(nodeExecPath, plan.args, {
128
+ cwd: plan.cwd,
129
+ stdio: 'inherit',
130
+ });
131
+ } finally {
132
+ if (temporaryPackageJsonPath) {
133
+ removeFile(temporaryPackageJsonPath);
134
+ }
135
+ }
136
+
105
137
  if (result.error) {
106
138
  logError(
107
139
  `[warden-mcp] failed to execute patch-package: ${result.error.message}`,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@icoretech/warden-mcp",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "Vaultwarden/Bitwarden MCP server backed by Bitwarden CLI (bw).",