@phren/cli 0.0.54 → 0.0.55

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.
@@ -7,10 +7,10 @@ import { handleExtractMemories } from "./extract.js";
7
7
  import { handleGovernMemories, handlePruneMemories, handleConsolidateMemories, handleMaintain, handleBackgroundMaintenance, } from "./govern.js";
8
8
  import { handleConfig, handleIndexPolicy, handleRetentionPolicy, handleWorkflowPolicy, } from "./config.js";
9
9
  import { parseSearchArgs } from "./search.js";
10
- import { handleDetectSkills, handleFindingNamespace, handleHooksNamespace, handleProjectsNamespace, handleSkillsNamespace, handleSkillList, handlePromoteNamespace, handleStoreNamespace, handleTaskNamespace, } from "./namespaces.js";
10
+ import { handleDetectSkills, handleFindingNamespace, handleHooksNamespace, handleProfileNamespace, handleProjectsNamespace, handleSkillsNamespace, handleSkillList, handlePromoteNamespace, handleReviewNamespace, handleStoreNamespace, handleTaskNamespace, } from "./namespaces.js";
11
11
  import { handleTeamNamespace } from "./team.js";
12
12
  import { handleTaskView, handleSessionsView, handleQuickstart, handleDebugInjection, handleInspectIndex, } from "./ops.js";
13
- import { handleAddFinding, handleDoctor, handleFragmentSearch, handleMemoryUi, handleTruths, handlePinCanonical, handleQualityFeedback, handleRelatedDocs, handleReview, handleConsolidationStatus, handleSessionContext, handleSearch, handleShell, handleStatus, handleUpdate, } from "./actions.js";
13
+ import { handleAddFinding, handleDoctor, handleFragmentSearch, handleMemoryUi, handleTruths, handlePinCanonical, handleQualityFeedback, handleRelatedDocs, handleConsolidationStatus, handleSessionContext, handleSearch, handleShell, handleStatus, handleUpdate, } from "./actions.js";
14
14
  import { handleGraphNamespace } from "./graph.js";
15
15
  import { resolveRuntimeProfile } from "../runtime-profile.js";
16
16
  // ── CLI router ───────────────────────────────────────────────────────────────
@@ -103,7 +103,7 @@ export async function runCliCommand(command, args) {
103
103
  case "graph":
104
104
  return handleGraphNamespace(args);
105
105
  case "review":
106
- return handleReview(args);
106
+ return handleReviewNamespace(args);
107
107
  case "consolidation-status":
108
108
  return handleConsolidationStatus(args);
109
109
  case "session-context":
@@ -112,6 +112,8 @@ export async function runCliCommand(command, args) {
112
112
  return handleTruths(args[0]);
113
113
  case "store":
114
114
  return handleStoreNamespace(args);
115
+ case "profile":
116
+ return handleProfileNamespace(args);
115
117
  case "team":
116
118
  return handleTeamNamespace(args);
117
119
  case "promote":
@@ -1771,6 +1771,82 @@ export async function handleStoreNamespace(args) {
1771
1771
  printStoreUsage();
1772
1772
  process.exit(1);
1773
1773
  }
1774
+ // ── Profile namespace ────────────────────────────────────────────────────────
1775
+ function printProfileUsage() {
1776
+ console.log("Usage:");
1777
+ console.log(" phren profile list List all available profiles");
1778
+ console.log(" phren profile switch <name> Switch to an active profile");
1779
+ }
1780
+ export function handleProfileNamespace(args) {
1781
+ const subcommand = args[0];
1782
+ if (!subcommand || subcommand === "--help" || subcommand === "-h") {
1783
+ printProfileUsage();
1784
+ return;
1785
+ }
1786
+ const phrenPath = getPhrenPath();
1787
+ if (subcommand === "list") {
1788
+ const { listProfiles } = require("../profile-store.js");
1789
+ const result = listProfiles(phrenPath);
1790
+ if (!result.ok) {
1791
+ console.error(`Failed to list profiles: ${result.error}`);
1792
+ process.exit(1);
1793
+ }
1794
+ const profiles = result.data || [];
1795
+ if (profiles.length === 0) {
1796
+ console.log("No profiles available.");
1797
+ return;
1798
+ }
1799
+ const { listMachines } = require("../profile-store.js");
1800
+ const machinesResult = listMachines(phrenPath);
1801
+ const machines = machinesResult.ok ? machinesResult.data : {};
1802
+ const { getMachineName } = require("../machine-identity.js");
1803
+ const currentMachine = getMachineName();
1804
+ const activeProfile = machines[currentMachine];
1805
+ console.log(`${profiles.length} profile(s):\n`);
1806
+ for (const profile of profiles) {
1807
+ const isCurrent = profile.name === activeProfile ? " (current)" : "";
1808
+ const projectCount = profile.projects?.length ?? 0;
1809
+ console.log(` ${profile.name}${isCurrent}`);
1810
+ console.log(` projects: ${projectCount}`);
1811
+ console.log();
1812
+ }
1813
+ return;
1814
+ }
1815
+ if (subcommand === "switch") {
1816
+ const profileName = args[1];
1817
+ if (!profileName) {
1818
+ console.error("Usage: phren profile switch <name>");
1819
+ process.exit(1);
1820
+ }
1821
+ const { setMachineProfile, getDefaultMachineAlias, listProfiles } = require("../profile-store.js");
1822
+ // Validate that profile exists
1823
+ const listResult = listProfiles(phrenPath);
1824
+ if (!listResult.ok) {
1825
+ console.error(`Failed to list profiles: ${listResult.error}`);
1826
+ process.exit(1);
1827
+ }
1828
+ const profiles = listResult.data || [];
1829
+ if (!profiles.some((p) => p.name === profileName)) {
1830
+ console.error(`Profile not found: "${profileName}"`);
1831
+ console.log("Available profiles:");
1832
+ for (const p of profiles) {
1833
+ console.log(` - ${p.name}`);
1834
+ }
1835
+ process.exit(1);
1836
+ }
1837
+ const machineAlias = getDefaultMachineAlias();
1838
+ const result = setMachineProfile(phrenPath, machineAlias, profileName);
1839
+ if (!result.ok) {
1840
+ console.error(`Failed to switch profile: ${result.error}`);
1841
+ process.exit(1);
1842
+ }
1843
+ console.log(`Switched to profile: ${profileName} (machine: ${machineAlias})`);
1844
+ return;
1845
+ }
1846
+ console.error(`Unknown profile subcommand: ${subcommand}`);
1847
+ printProfileUsage();
1848
+ process.exit(1);
1849
+ }
1774
1850
  // ── Promote namespace ────────────────────────────────────────────────────────
1775
1851
  export async function handlePromoteNamespace(args) {
1776
1852
  if (!args[0] || args[0] === "--help" || args[0] === "-h") {
@@ -1836,6 +1912,50 @@ export async function handlePromoteNamespace(args) {
1836
1912
  console.log(`Promoted to ${toStore}/${project}:`);
1837
1913
  console.log(` "${match.text.slice(0, 120)}${match.text.length > 120 ? "..." : ""}"`);
1838
1914
  }
1915
+ // ── Review namespace ────────────────────────────────────────────────────────
1916
+ export async function handleReviewNamespace(args) {
1917
+ const subcommand = args[0];
1918
+ if (!subcommand || subcommand === "--help" || subcommand === "-h") {
1919
+ console.log("Usage:");
1920
+ console.log(" phren review [project] Show review queue items");
1921
+ console.log(" phren review approve <project> <text> Approve and remove item");
1922
+ console.log(" phren review reject <project> <text> Reject and remove item");
1923
+ console.log("");
1924
+ console.log("Examples:");
1925
+ console.log(' phren review myproject');
1926
+ console.log(' phren review approve myproject "Always validate input"');
1927
+ console.log(' phren review reject myproject "Avoid async in loops"');
1928
+ return;
1929
+ }
1930
+ // Handle "approve" and "reject" subcommands
1931
+ if (subcommand === "approve" || subcommand === "reject") {
1932
+ const action = subcommand;
1933
+ const project = args[1];
1934
+ const lineText = args.slice(2).join(" ");
1935
+ if (!project || !lineText) {
1936
+ console.error(`Usage: phren review ${action} <project> <text>`);
1937
+ process.exit(1);
1938
+ }
1939
+ if (!isValidProjectName(project)) {
1940
+ console.error(`Invalid project name: "${project}".`);
1941
+ process.exit(1);
1942
+ }
1943
+ const phrenPath = getPhrenPath();
1944
+ const { approveQueueItem, rejectQueueItem } = await import("../data/access.js");
1945
+ const result = action === "approve"
1946
+ ? approveQueueItem(phrenPath, project, lineText)
1947
+ : rejectQueueItem(phrenPath, project, lineText);
1948
+ if (!result.ok) {
1949
+ console.error(`Failed to ${action} item: ${result.error ?? "Unknown error"}`);
1950
+ process.exit(1);
1951
+ }
1952
+ console.log(`${action === "approve" ? "✓ Approved" : "✗ Rejected"}: ${lineText.slice(0, 100)}${lineText.length > 100 ? "..." : ""}`);
1953
+ return;
1954
+ }
1955
+ // Default: show review queue (first arg is project name if not a subcommand)
1956
+ const { handleReview } = await import("./actions.js");
1957
+ return handleReview(args);
1958
+ }
1839
1959
  function countStoreProjects(store) {
1840
1960
  if (!fs.existsSync(store.path))
1841
1961
  return 0;