@phren/cli 0.0.7 → 0.0.8
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/mcp/dist/init-config.js +6 -6
- package/mcp/dist/init.js +29 -7
- package/mcp/dist/phren-paths.js +3 -3
- package/package.json +1 -1
package/mcp/dist/init-config.js
CHANGED
|
@@ -162,15 +162,15 @@ export function removeMcpServerAtPath(filePath) {
|
|
|
162
162
|
return removed;
|
|
163
163
|
}
|
|
164
164
|
export function isPhrenCommand(command) {
|
|
165
|
-
// Detect PHREN_PATH=
|
|
166
|
-
if (/\
|
|
165
|
+
// Detect PHREN_PATH= env var prefix (present in all lifecycle hook commands)
|
|
166
|
+
if (/\bPHREN_PATH=/.test(command))
|
|
167
167
|
return true;
|
|
168
|
-
// Detect npx phren
|
|
169
|
-
if (command.includes("phren")
|
|
168
|
+
// Detect npx phren package references
|
|
169
|
+
if (command.includes("phren"))
|
|
170
170
|
return true;
|
|
171
|
-
// Detect bare "phren"
|
|
171
|
+
// Detect bare "phren" executable segment
|
|
172
172
|
const segments = command.split(/[/\\\s]+/);
|
|
173
|
-
if (segments.some(seg => seg === "phren" || seg.startsWith("phren@")
|
|
173
|
+
if (segments.some(seg => seg === "phren" || seg.startsWith("phren@")))
|
|
174
174
|
return true;
|
|
175
175
|
// Also match commands that include hook subcommands (used when installed via absolute path)
|
|
176
176
|
const HOOK_MARKERS = ["hook-prompt", "hook-stop", "hook-session-start", "hook-tool"];
|
package/mcp/dist/init.js
CHANGED
|
@@ -109,7 +109,7 @@ function hasInstallMarkers(phrenPath) {
|
|
|
109
109
|
fs.existsSync(path.join(phrenPath, "global")));
|
|
110
110
|
}
|
|
111
111
|
function resolveInitPhrenPath(opts) {
|
|
112
|
-
const raw = opts._walkthroughStoragePath || (process.env.PHREN_PATH
|
|
112
|
+
const raw = opts._walkthroughStoragePath || (process.env.PHREN_PATH) || DEFAULT_PHREN_PATH;
|
|
113
113
|
return path.resolve(expandHomePath(raw));
|
|
114
114
|
}
|
|
115
115
|
function detectRepoRootForStorage(phrenPath) {
|
|
@@ -921,6 +921,28 @@ export async function runInit(opts = {}) {
|
|
|
921
921
|
console.log(`Migrated ~/.cortex → ~/.phren`);
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
|
+
// Rename stale cortex-*.md skill files left over from the rebrand.
|
|
925
|
+
// Runs on every init so users who already migrated the directory still get the fix.
|
|
926
|
+
const skillsMigrateDir = path.join(phrenPath, "global", "skills");
|
|
927
|
+
if (!dryRun && fs.existsSync(skillsMigrateDir)) {
|
|
928
|
+
for (const entry of fs.readdirSync(skillsMigrateDir)) {
|
|
929
|
+
if (!entry.endsWith(".md"))
|
|
930
|
+
continue;
|
|
931
|
+
if (entry === "cortex.md") {
|
|
932
|
+
const dest = path.join(skillsMigrateDir, "phren.md");
|
|
933
|
+
if (!fs.existsSync(dest)) {
|
|
934
|
+
fs.renameSync(path.join(skillsMigrateDir, entry), dest);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
else if (entry.startsWith("cortex-")) {
|
|
938
|
+
const newName = entry.replace(/^cortex-/, "phren-");
|
|
939
|
+
const dest = path.join(skillsMigrateDir, newName);
|
|
940
|
+
if (!fs.existsSync(dest)) {
|
|
941
|
+
fs.renameSync(path.join(skillsMigrateDir, entry), dest);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
924
946
|
let hasExistingInstall = hasInstallMarkers(phrenPath);
|
|
925
947
|
// Interactive walkthrough for first-time installs (skip with --yes or non-TTY)
|
|
926
948
|
if (!hasExistingInstall && !dryRun && !opts.yes && process.stdin.isTTY && process.stdout.isTTY) {
|
|
@@ -1415,7 +1437,7 @@ export async function runInit(opts = {}) {
|
|
|
1415
1437
|
log(``);
|
|
1416
1438
|
}
|
|
1417
1439
|
export async function runMcpMode(modeArg) {
|
|
1418
|
-
const phrenPath = findPhrenPath() || (process.env.PHREN_PATH
|
|
1440
|
+
const phrenPath = findPhrenPath() || (process.env.PHREN_PATH) || DEFAULT_PHREN_PATH;
|
|
1419
1441
|
const manifest = readRootManifest(phrenPath);
|
|
1420
1442
|
const normalizedArg = modeArg?.trim().toLowerCase();
|
|
1421
1443
|
if (!normalizedArg || normalizedArg === "status") {
|
|
@@ -1486,7 +1508,7 @@ export async function runMcpMode(modeArg) {
|
|
|
1486
1508
|
log(`Restart your agent to apply changes.`);
|
|
1487
1509
|
}
|
|
1488
1510
|
export async function runHooksMode(modeArg) {
|
|
1489
|
-
const phrenPath = findPhrenPath() || (process.env.PHREN_PATH
|
|
1511
|
+
const phrenPath = findPhrenPath() || (process.env.PHREN_PATH) || DEFAULT_PHREN_PATH;
|
|
1490
1512
|
const manifest = readRootManifest(phrenPath);
|
|
1491
1513
|
const normalizedArg = modeArg?.trim().toLowerCase();
|
|
1492
1514
|
if (!normalizedArg || normalizedArg === "status") {
|
|
@@ -1644,7 +1666,7 @@ export async function runUninstall() {
|
|
|
1644
1666
|
catch (err) {
|
|
1645
1667
|
debugLog(`uninstall: cleanup failed for ${codexToml}: ${errorMessage(err)}`);
|
|
1646
1668
|
}
|
|
1647
|
-
const codexCandidates = codexJsonCandidates((process.env.PHREN_PATH
|
|
1669
|
+
const codexCandidates = codexJsonCandidates((process.env.PHREN_PATH) || DEFAULT_PHREN_PATH);
|
|
1648
1670
|
for (const mcpFile of codexCandidates) {
|
|
1649
1671
|
try {
|
|
1650
1672
|
if (removeMcpServerAtPath(mcpFile)) {
|
|
@@ -1656,7 +1678,7 @@ export async function runUninstall() {
|
|
|
1656
1678
|
}
|
|
1657
1679
|
}
|
|
1658
1680
|
// Remove Copilot hooks file (written by configureAllHooks)
|
|
1659
|
-
const copilotHooksFile = hookConfigPath("copilot", (process.env.PHREN_PATH
|
|
1681
|
+
const copilotHooksFile = hookConfigPath("copilot", (process.env.PHREN_PATH) || DEFAULT_PHREN_PATH);
|
|
1660
1682
|
try {
|
|
1661
1683
|
if (fs.existsSync(copilotHooksFile)) {
|
|
1662
1684
|
fs.unlinkSync(copilotHooksFile);
|
|
@@ -1667,7 +1689,7 @@ export async function runUninstall() {
|
|
|
1667
1689
|
debugLog(`uninstall: cleanup failed for ${copilotHooksFile}: ${errorMessage(err)}`);
|
|
1668
1690
|
}
|
|
1669
1691
|
// Remove phren entries from Cursor hooks file (may contain non-phren entries)
|
|
1670
|
-
const cursorHooksFile = hookConfigPath("cursor", (process.env.PHREN_PATH
|
|
1692
|
+
const cursorHooksFile = hookConfigPath("cursor", (process.env.PHREN_PATH) || DEFAULT_PHREN_PATH);
|
|
1671
1693
|
try {
|
|
1672
1694
|
if (fs.existsSync(cursorHooksFile)) {
|
|
1673
1695
|
const raw = JSON.parse(fs.readFileSync(cursorHooksFile, "utf8"));
|
|
@@ -1688,7 +1710,7 @@ export async function runUninstall() {
|
|
|
1688
1710
|
debugLog(`uninstall: cleanup failed for ${cursorHooksFile}: ${errorMessage(err)}`);
|
|
1689
1711
|
}
|
|
1690
1712
|
// Remove Codex hooks file in phren path
|
|
1691
|
-
const uninstallPhrenPath = (process.env.PHREN_PATH
|
|
1713
|
+
const uninstallPhrenPath = (process.env.PHREN_PATH) || DEFAULT_PHREN_PATH;
|
|
1692
1714
|
const codexHooksFile = hookConfigPath("codex", uninstallPhrenPath);
|
|
1693
1715
|
try {
|
|
1694
1716
|
if (fs.existsSync(codexHooksFile)) {
|
package/mcp/dist/phren-paths.js
CHANGED
|
@@ -134,7 +134,7 @@ let cachedPhrenPath;
|
|
|
134
134
|
let cachedPhrenPathKey;
|
|
135
135
|
export function findPhrenPath() {
|
|
136
136
|
const cacheKey = [
|
|
137
|
-
((process.env.PHREN_PATH
|
|
137
|
+
((process.env.PHREN_PATH) ?? ""),
|
|
138
138
|
process.env.HOME ?? "",
|
|
139
139
|
process.env.USERPROFILE ?? "",
|
|
140
140
|
process.cwd(),
|
|
@@ -142,7 +142,7 @@ export function findPhrenPath() {
|
|
|
142
142
|
if (cachedPhrenPath !== undefined && cachedPhrenPathKey === cacheKey)
|
|
143
143
|
return cachedPhrenPath;
|
|
144
144
|
cachedPhrenPathKey = cacheKey;
|
|
145
|
-
const envVal = (process.env.PHREN_PATH
|
|
145
|
+
const envVal = (process.env.PHREN_PATH)?.trim();
|
|
146
146
|
if (envVal) {
|
|
147
147
|
const resolved = path.resolve(expandHomePath(envVal));
|
|
148
148
|
cachedPhrenPath = isPhrenRootCandidate(resolved) ? resolved : null;
|
|
@@ -170,7 +170,7 @@ export function ensurePhrenPath() {
|
|
|
170
170
|
});
|
|
171
171
|
cachedPhrenPath = defaultPath;
|
|
172
172
|
cachedPhrenPathKey = [
|
|
173
|
-
((process.env.PHREN_PATH
|
|
173
|
+
((process.env.PHREN_PATH) ?? ""),
|
|
174
174
|
process.env.HOME ?? "",
|
|
175
175
|
process.env.USERPROFILE ?? "",
|
|
176
176
|
process.cwd(),
|