@phren/cli 0.1.2 → 0.1.4

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/dist/hooks.js CHANGED
@@ -135,13 +135,54 @@ function withHookToolLifecycleCommands(lifecycle, tool) {
135
135
  };
136
136
  }
137
137
  function installSessionWrapper(tool, phrenPath) {
138
+ const isWindows = process.platform === "win32";
138
139
  const realBinary = resolveToolBinary(tool);
139
140
  if (!realBinary)
140
141
  return false;
141
142
  const entry = resolveCliEntryScript();
142
143
  const localBinDir = homePath(".local", "bin");
143
- const wrapperPath = path.join(localBinDir, tool);
144
+ const wrapperPath = path.join(localBinDir, isWindows ? `${tool}.cmd` : tool);
144
145
  const packageSpec = phrenPackageSpec();
146
+ if (isWindows) {
147
+ const sessionStartCmd = entry
148
+ ? `node "${entry}" hook-session-start`
149
+ : `npx -y ${packageSpec} hook-session-start`;
150
+ const stopCmd = entry
151
+ ? `node "${entry}" hook-stop`
152
+ : `npx -y ${packageSpec} hook-stop`;
153
+ const content = `@echo off\r
154
+ setlocal\r
155
+ set "REAL_BIN=${realBinary}"\r
156
+ if not defined PHREN_PATH set "PHREN_PATH=${phrenPath}"\r
157
+ set "PHREN_HOOK_TOOL=${tool}"\r
158
+ \r
159
+ if "%~1"=="-h" goto :passthrough\r
160
+ if "%~1"=="--help" goto :passthrough\r
161
+ if "%~1"=="help" goto :passthrough\r
162
+ if "%~1"=="-V" goto :passthrough\r
163
+ if "%~1"=="--version" goto :passthrough\r
164
+ if "%~1"=="version" goto :passthrough\r
165
+ if "%~1"=="completion" goto :passthrough\r
166
+ \r
167
+ ${sessionStartCmd} >nul 2>&1\r
168
+ "%REAL_BIN%" %*\r
169
+ set "EXIT_STATUS=%ERRORLEVEL%"\r
170
+ ${stopCmd} >nul 2>&1\r
171
+ exit /b %EXIT_STATUS%\r
172
+ \r
173
+ :passthrough\r
174
+ "%REAL_BIN%" %*\r
175
+ `;
176
+ try {
177
+ fs.mkdirSync(localBinDir, { recursive: true });
178
+ atomicWriteText(wrapperPath, content);
179
+ return true;
180
+ }
181
+ catch (err) {
182
+ debugLog(`installSessionWrapper: failed for ${tool}: ${errorMessage(err)}`);
183
+ return false;
184
+ }
185
+ }
145
186
  const sessionStartCmd = entry
146
187
  ? `env PHREN_PATH="$PHREN_PATH" node "$ENTRY_SCRIPT" hook-session-start`
147
188
  : `env PHREN_PATH="$PHREN_PATH" npx -y ${packageSpec} hook-session-start`;
@@ -206,11 +247,12 @@ exit $status
206
247
  * `node <entry_script> "$@"`.
207
248
  */
208
249
  export function installPhrenCliWrapper(phrenPath) {
250
+ const isWindows = process.platform === "win32";
209
251
  const entry = resolveCliEntryScript();
210
252
  if (!entry)
211
253
  return false;
212
254
  const localBinDir = homePath(".local", "bin");
213
- const wrapperPath = path.join(localBinDir, "phren");
255
+ const wrapperPath = path.join(localBinDir, isWindows ? "phren.cmd" : "phren");
214
256
  // Don't overwrite a real global install — only our own wrapper
215
257
  if (fs.existsSync(wrapperPath)) {
216
258
  try {
@@ -223,7 +265,9 @@ export function installPhrenCliWrapper(phrenPath) {
223
265
  return false;
224
266
  }
225
267
  }
226
- const content = `#!/bin/sh
268
+ const content = isWindows
269
+ ? `@echo off\r\nrem PHREN_CLI_WRAPPER — managed by phren init; safe to delete\r\nif not defined PHREN_PATH set "PHREN_PATH=${phrenPath}"\r\nnode "${entry}" %*\r\n`
270
+ : `#!/bin/sh
227
271
  # PHREN_CLI_WRAPPER — managed by phren init; safe to delete
228
272
  set -u
229
273
  PHREN_PATH="\${PHREN_PATH:-${phrenPath}}"
@@ -233,7 +277,8 @@ exec node ${shellEscape(entry)} "$@"
233
277
  try {
234
278
  fs.mkdirSync(localBinDir, { recursive: true });
235
279
  atomicWriteText(wrapperPath, content);
236
- fs.chmodSync(wrapperPath, 0o755);
280
+ if (!isWindows)
281
+ fs.chmodSync(wrapperPath, 0o755);
237
282
  return true;
238
283
  }
239
284
  catch (err) {
@@ -13,7 +13,7 @@ export { VERSION };
13
13
  export const STARTER_DIR = path.join(ROOT, "starter");
14
14
  export const DEFAULT_PHREN_PATH = homePath(".phren");
15
15
  export function resolveEntryScript() {
16
- return path.join(ROOT, "mcp", "dist", "index.js");
16
+ return path.join(ROOT, "dist", "index.js");
17
17
  }
18
18
  export function log(msg) {
19
19
  process.stdout.write(msg + "\n");
package/dist/utils-fts.js CHANGED
@@ -83,7 +83,7 @@ export function extractKeywordEntries(text) {
83
83
  export function extractKeywords(text) {
84
84
  return extractKeywordEntries(text).join(" ");
85
85
  }
86
- // Base synonym map for fuzzy search expansion — source of truth is mcp/src/synonyms.json
86
+ // Base synonym map for fuzzy search expansion — source of truth is src/synonyms.json
87
87
  const BASE_SYNONYMS = _baseSynonymsJson;
88
88
  const LEARNED_SYNONYMS_FILE = "learned-synonyms.json";
89
89
  function normalizeSynonymTerm(term) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phren/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Knowledge layer for AI agents — CLI, MCP server, and data layer",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,10 +9,11 @@
9
9
  */
10
10
 
11
11
  import fs from "node:fs";
12
+ import os from "node:os";
12
13
  import path from "node:path";
13
14
  import { fileURLToPath } from "node:url";
14
15
 
15
- const home = process.env.HOME || process.env.USERPROFILE || "/tmp";
16
+ const home = os.homedir();
16
17
  const homePath = (...parts) => path.join(home, ...parts);
17
18
 
18
19
  /** Read JSON, apply mutator, write back. */