@phren/cli 0.1.27 → 0.1.29
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/cli/actions.d.ts +1 -1
- package/dist/cli/actions.js +1 -12
- package/dist/cli/namespaces-profile.d.ts +1 -1
- package/dist/cli/namespaces-profile.js +4 -6
- package/dist/cli/namespaces-skills.js +2 -2
- package/dist/cli/namespaces-store.js +1 -2
- package/dist/cli/namespaces-utils.d.ts +0 -1
- package/dist/cli/namespaces-utils.js +0 -7
- package/dist/cli/search.js +0 -12
- package/dist/cli/team.js +1 -23
- package/dist/cli-handlers.d.ts +17 -0
- package/dist/cli-handlers.js +204 -0
- package/dist/cli-help.d.ts +6 -0
- package/dist/cli-help.js +125 -0
- package/dist/cli-registry.d.ts +45 -0
- package/dist/cli-registry.js +715 -0
- package/dist/core/project.d.ts +4 -1
- package/dist/core/project.js +10 -5
- package/dist/entrypoint.d.ts +0 -1
- package/dist/entrypoint.js +74 -420
- package/dist/init/setup.d.ts +1 -0
- package/dist/init/setup.js +3 -2
- package/dist/phren-paths.d.ts +1 -0
- package/dist/phren-paths.js +1 -1
- package/dist/proactivity.d.ts +1 -0
- package/dist/proactivity.js +1 -1
- package/dist/shared.d.ts +2 -2
- package/dist/shared.js +2 -2
- package/dist/tools/ops.js +1 -1
- package/dist/utils-helpers.d.ts +2 -0
- package/dist/utils-helpers.js +24 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +4 -6
- package/package.json +1 -1
- package/dist/cli/cli.d.ts +0 -3
- package/dist/cli/cli.js +0 -125
package/dist/cli/actions.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare function handleDoctor(args: string[]): Promise<void>;
|
|
|
9
9
|
export declare function handleStatus(): Promise<void>;
|
|
10
10
|
export declare function handleQualityFeedback(args: string[]): Promise<void>;
|
|
11
11
|
export declare function handleMemoryUi(args: string[]): Promise<void>;
|
|
12
|
-
export declare function handleShell(
|
|
12
|
+
export declare function handleShell(_args: string[], profile: string): Promise<void>;
|
|
13
13
|
export declare function handleUpdate(args: string[]): Promise<void>;
|
|
14
14
|
export declare function handleReview(args: string[]): Promise<void>;
|
|
15
15
|
export declare function handleConsolidationStatus(args: string[]): Promise<void>;
|
package/dist/cli/actions.js
CHANGED
|
@@ -307,21 +307,10 @@ export async function handleMemoryUi(args) {
|
|
|
307
307
|
allowPortFallback: !portArg,
|
|
308
308
|
});
|
|
309
309
|
}
|
|
310
|
-
export async function handleShell(
|
|
311
|
-
if (args.includes("--help") || args.includes("-h")) {
|
|
312
|
-
console.log("Usage: phren shell");
|
|
313
|
-
console.log("Interactive shell with views for Projects, Task, Findings, Review Queue, Skills, Hooks, Machines/Profiles, and Health.");
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
310
|
+
export async function handleShell(_args, profile) {
|
|
316
311
|
await startShell(getPhrenPath(), profile);
|
|
317
312
|
}
|
|
318
313
|
export async function handleUpdate(args) {
|
|
319
|
-
if (args.includes("--help") || args.includes("-h")) {
|
|
320
|
-
console.log("Usage: phren update [--refresh-starter]");
|
|
321
|
-
console.log("Updates phren to the latest version (local git clone when available, otherwise npm global package).");
|
|
322
|
-
console.log("Pass --refresh-starter to refresh global starter assets in the same flow.");
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
314
|
const result = await runPhrenUpdate({ refreshStarter: args.includes("--refresh-starter") });
|
|
326
315
|
console.log(result.message);
|
|
327
316
|
if (!result.ok) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function handleProfileNamespace(args: string[]): void
|
|
1
|
+
export declare function handleProfileNamespace(args: string[]): Promise<void>;
|
|
@@ -4,7 +4,7 @@ function printProfileUsage() {
|
|
|
4
4
|
console.log(" phren profile list List all available profiles");
|
|
5
5
|
console.log(" phren profile switch <name> Switch to an active profile");
|
|
6
6
|
}
|
|
7
|
-
export function handleProfileNamespace(args) {
|
|
7
|
+
export async function handleProfileNamespace(args) {
|
|
8
8
|
const subcommand = args[0];
|
|
9
9
|
if (!subcommand || subcommand === "--help" || subcommand === "-h") {
|
|
10
10
|
printProfileUsage();
|
|
@@ -12,7 +12,7 @@ export function handleProfileNamespace(args) {
|
|
|
12
12
|
}
|
|
13
13
|
const phrenPath = getPhrenPath();
|
|
14
14
|
if (subcommand === "list") {
|
|
15
|
-
const { listProfiles } =
|
|
15
|
+
const { listProfiles, listMachines } = await import("../profile-store.js");
|
|
16
16
|
const result = listProfiles(phrenPath);
|
|
17
17
|
if (!result.ok) {
|
|
18
18
|
console.error(`Failed to list profiles: ${result.error}`);
|
|
@@ -23,10 +23,9 @@ export function handleProfileNamespace(args) {
|
|
|
23
23
|
console.log("No profiles available.");
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const { listMachines } = require("../profile-store.js");
|
|
27
26
|
const machinesResult = listMachines(phrenPath);
|
|
28
27
|
const machines = machinesResult.ok ? machinesResult.data : {};
|
|
29
|
-
const { getMachineName } =
|
|
28
|
+
const { getMachineName } = await import("../machine-identity.js");
|
|
30
29
|
const currentMachine = getMachineName();
|
|
31
30
|
const activeProfile = machines[currentMachine];
|
|
32
31
|
console.log(`${profiles.length} profile(s):\n`);
|
|
@@ -45,8 +44,7 @@ export function handleProfileNamespace(args) {
|
|
|
45
44
|
console.error("Usage: phren profile switch <name>");
|
|
46
45
|
process.exit(1);
|
|
47
46
|
}
|
|
48
|
-
const { setMachineProfile, getDefaultMachineAlias, listProfiles } =
|
|
49
|
-
// Validate that profile exists
|
|
47
|
+
const { setMachineProfile, getDefaultMachineAlias, listProfiles } = await import("../profile-store.js");
|
|
50
48
|
const listResult = listProfiles(phrenPath);
|
|
51
49
|
if (!listResult.ok) {
|
|
52
50
|
console.error(`Failed to list profiles: ${listResult.error}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
import { expandHomePath, getPhrenPath, getProjectDirs, homePath, hookConfigPath, } from "../shared.js";
|
|
4
|
-
import { isValidProjectName, errorMessage } from "../utils.js";
|
|
4
|
+
import { isValidProjectName, errorMessage, getOptionValue } from "../utils.js";
|
|
5
5
|
import { logger } from "../logger.js";
|
|
6
6
|
import { readInstallPreferences, writeInstallPreferences } from "../init/preferences.js";
|
|
7
7
|
import { buildSkillManifest, findLocalSkill, findSkill, getAllSkills } from "../skill/registry.js";
|
|
@@ -11,7 +11,7 @@ import { findProjectDir } from "../project-locator.js";
|
|
|
11
11
|
import { readCustomHooks, getHookTarget, HOOK_EVENT_VALUES, validateCustomHookCommand } from "../hooks.js";
|
|
12
12
|
import { runtimeFile } from "../shared.js";
|
|
13
13
|
import { readProjectConfig, PROJECT_HOOK_EVENTS, isProjectHookEnabled, } from "../project-config.js";
|
|
14
|
-
import { resolveProjectStorePath,
|
|
14
|
+
import { resolveProjectStorePath, openInEditor } from "./namespaces-utils.js";
|
|
15
15
|
const HOOK_TOOLS = ["claude", "copilot", "cursor", "codex"];
|
|
16
16
|
function printSkillsUsage() {
|
|
17
17
|
console.log("Usage:");
|
|
@@ -2,9 +2,8 @@ import * as fs from "fs";
|
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
import { execFileSync } from "child_process";
|
|
4
4
|
import { getPhrenPath } from "../shared.js";
|
|
5
|
-
import { isValidProjectName, errorMessage } from "../utils.js";
|
|
5
|
+
import { isValidProjectName, errorMessage, getOptionValue } from "../utils.js";
|
|
6
6
|
import { resolveAllStores, addStoreToRegistry, removeStoreFromRegistry, generateStoreId, readTeamBootstrap, } from "../store-registry.js";
|
|
7
|
-
import { getOptionValue } from "./namespaces-utils.js";
|
|
8
7
|
function printStoreUsage() {
|
|
9
8
|
console.log("Usage:");
|
|
10
9
|
console.log(" phren store list List registered stores");
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare function resolveProjectStorePath(phrenPath: string, project: string): string;
|
|
2
|
-
export declare function getOptionValue(args: string[], name: string): string | undefined;
|
|
3
2
|
export declare function parseMcpToggle(raw: string | undefined): boolean | undefined;
|
|
4
3
|
export declare function openInEditor(filePath: string): void;
|
|
@@ -16,13 +16,6 @@ export function resolveProjectStorePath(phrenPath, project) {
|
|
|
16
16
|
catch { /* fall through */ }
|
|
17
17
|
return phrenPath;
|
|
18
18
|
}
|
|
19
|
-
export function getOptionValue(args, name) {
|
|
20
|
-
const exactIdx = args.indexOf(name);
|
|
21
|
-
if (exactIdx !== -1)
|
|
22
|
-
return args[exactIdx + 1];
|
|
23
|
-
const prefixed = args.find((arg) => arg.startsWith(`${name}=`));
|
|
24
|
-
return prefixed ? prefixed.slice(name.length + 1) : undefined;
|
|
25
|
-
}
|
|
26
19
|
export function parseMcpToggle(raw) {
|
|
27
20
|
if (!raw)
|
|
28
21
|
return undefined;
|
package/dist/cli/search.js
CHANGED
|
@@ -103,10 +103,6 @@ export function parseSearchArgs(phrenPath, args) {
|
|
|
103
103
|
let searchAll = false;
|
|
104
104
|
for (let i = 0; i < args.length; i++) {
|
|
105
105
|
const arg = args[i];
|
|
106
|
-
if (arg === "--help" || arg === "-h") {
|
|
107
|
-
printSearchUsage();
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
106
|
if (arg === "--history") {
|
|
111
107
|
showHistory = true;
|
|
112
108
|
continue;
|
|
@@ -337,10 +333,6 @@ export function parseFragmentSearchArgs(args) {
|
|
|
337
333
|
let limit;
|
|
338
334
|
for (let i = 0; i < args.length; i++) {
|
|
339
335
|
const arg = args[i];
|
|
340
|
-
if (arg === "--help" || arg === "-h") {
|
|
341
|
-
console.error("Usage: phren search-fragments <query> [--project <name>] [--limit <n>]");
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
336
|
if (arg === "--project" && args[i + 1]) {
|
|
345
337
|
project = args[++i];
|
|
346
338
|
continue;
|
|
@@ -388,10 +380,6 @@ export function parseRelatedDocsArgs(args) {
|
|
|
388
380
|
let limit;
|
|
389
381
|
for (let i = 0; i < args.length; i++) {
|
|
390
382
|
const arg = args[i];
|
|
391
|
-
if (arg === "--help" || arg === "-h") {
|
|
392
|
-
console.error("Usage: phren related-docs <fragment-name> [--project <name>] [--limit <n>]");
|
|
393
|
-
return null;
|
|
394
|
-
}
|
|
395
383
|
if (arg === "--project" && args[i + 1]) {
|
|
396
384
|
project = args[++i];
|
|
397
385
|
continue;
|
package/dist/cli/team.js
CHANGED
|
@@ -8,32 +8,10 @@ import { execFileSync } from "child_process";
|
|
|
8
8
|
import { getPhrenPath } from "../shared.js";
|
|
9
9
|
import { FINDINGS_FILENAME } from "../data/access.js";
|
|
10
10
|
import { TASKS_FILENAME } from "../data/tasks.js";
|
|
11
|
-
import { isValidProjectName } from "../utils.js";
|
|
11
|
+
import { isValidProjectName, getOptionValue, getPositionalArgs } from "../utils.js";
|
|
12
12
|
import { addProjectToProfile, resolveActiveProfile } from "../profile-store.js";
|
|
13
13
|
import { addStoreToRegistry, findStoreByName, generateStoreId, readTeamBootstrap, updateStoreProjects, } from "../store-registry.js";
|
|
14
14
|
const EXEC_TIMEOUT_MS = 30_000;
|
|
15
|
-
function getOptionValue(args, name) {
|
|
16
|
-
const exactIdx = args.indexOf(name);
|
|
17
|
-
if (exactIdx !== -1)
|
|
18
|
-
return args[exactIdx + 1];
|
|
19
|
-
const prefixed = args.find((arg) => arg.startsWith(`${name}=`));
|
|
20
|
-
return prefixed ? prefixed.slice(name.length + 1) : undefined;
|
|
21
|
-
}
|
|
22
|
-
function getPositionalArgs(args, optionNames) {
|
|
23
|
-
const positions = [];
|
|
24
|
-
for (let i = 0; i < args.length; i++) {
|
|
25
|
-
const arg = args[i];
|
|
26
|
-
if (optionNames.includes(arg)) {
|
|
27
|
-
i++;
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (optionNames.some((name) => arg.startsWith(`${name}=`)))
|
|
31
|
-
continue;
|
|
32
|
-
if (!arg.startsWith("--"))
|
|
33
|
-
positions.push(arg);
|
|
34
|
-
}
|
|
35
|
-
return positions;
|
|
36
|
-
}
|
|
37
15
|
function atomicWriteText(filePath, content) {
|
|
38
16
|
const dir = path.dirname(filePath);
|
|
39
17
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native handler implementations for top-level CLI commands.
|
|
3
|
+
*
|
|
4
|
+
* These were the inline if/else branches inside entrypoint.ts's runTopLevelCommand.
|
|
5
|
+
* They moved here so the command registry can dispatch to them without
|
|
6
|
+
* eagerly pulling init/init.js (which is heavy) into every phren invocation.
|
|
7
|
+
*
|
|
8
|
+
* Loaded only when a native command actually runs, via dynamic import from cli-registry.ts.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runAddCommand(args: string[]): Promise<number>;
|
|
11
|
+
export declare function runInitCommand(args: string[]): Promise<number>;
|
|
12
|
+
export declare function runUninstallCommand(args: string[]): Promise<number>;
|
|
13
|
+
export declare function runStatusCommand(_args: string[]): Promise<number>;
|
|
14
|
+
export declare function runVerifyCommand(_args: string[]): Promise<number>;
|
|
15
|
+
export declare function runMcpModeCommand(args: string[]): Promise<number>;
|
|
16
|
+
export declare function runHooksModeCommand(args: string[]): Promise<number>;
|
|
17
|
+
export declare function runLinkRemovedNotice(_args: string[]): Promise<number>;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native handler implementations for top-level CLI commands.
|
|
3
|
+
*
|
|
4
|
+
* These were the inline if/else branches inside entrypoint.ts's runTopLevelCommand.
|
|
5
|
+
* They moved here so the command registry can dispatch to them without
|
|
6
|
+
* eagerly pulling init/init.js (which is heavy) into every phren invocation.
|
|
7
|
+
*
|
|
8
|
+
* Loaded only when a native command actually runs, via dynamic import from cli-registry.ts.
|
|
9
|
+
*/
|
|
10
|
+
import * as fs from "fs";
|
|
11
|
+
import * as path from "path";
|
|
12
|
+
import { defaultPhrenPath, findPhrenPath, isInstallMode, parseProactivityLevel, } from "./shared.js";
|
|
13
|
+
import { errorMessage, getOptionValue, getPositionalArgs } from "./utils.js";
|
|
14
|
+
import { addProjectFromPath } from "./core/project.js";
|
|
15
|
+
import { PROJECT_OWNERSHIP_MODES, getProjectOwnershipDefault, parseProjectOwnershipMode, } from "./project-config.js";
|
|
16
|
+
import { VALID_TASK_MODES } from "./governance/policy.js";
|
|
17
|
+
function parseTaskModeFlag(raw) {
|
|
18
|
+
if (!raw)
|
|
19
|
+
return undefined;
|
|
20
|
+
const normalized = raw.trim().toLowerCase();
|
|
21
|
+
return VALID_TASK_MODES.includes(normalized)
|
|
22
|
+
? normalized
|
|
23
|
+
: undefined;
|
|
24
|
+
}
|
|
25
|
+
function parseInstallModeFlag(raw) {
|
|
26
|
+
if (!raw)
|
|
27
|
+
return undefined;
|
|
28
|
+
const normalized = raw.trim();
|
|
29
|
+
return isInstallMode(normalized) ? normalized : undefined;
|
|
30
|
+
}
|
|
31
|
+
async function promptProjectOwnership(phrenPath, fallback) {
|
|
32
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
|
33
|
+
return fallback;
|
|
34
|
+
const readline = await import("readline");
|
|
35
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
36
|
+
return new Promise((resolve) => {
|
|
37
|
+
rl.question(`Project ownership [${PROJECT_OWNERSHIP_MODES.join("/")}] (${fallback}): `, (input) => {
|
|
38
|
+
rl.close();
|
|
39
|
+
resolve(parseProjectOwnershipMode(input.trim()) ?? fallback);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
// ── Native handlers ─────────────────────────────────────────────────────────
|
|
44
|
+
export async function runAddCommand(args) {
|
|
45
|
+
const positional = getPositionalArgs(args, ["--ownership"]);
|
|
46
|
+
const targetPath = positional[0] || process.cwd();
|
|
47
|
+
const ownershipArg = getOptionValue(args, "--ownership");
|
|
48
|
+
const phrenPath = defaultPhrenPath();
|
|
49
|
+
const profile = (process.env.PHREN_PROFILE) || undefined;
|
|
50
|
+
if (!fs.existsSync(phrenPath) || !fs.existsSync(path.join(phrenPath, ".config"))) {
|
|
51
|
+
console.log("phren is not set up yet. Run: phren init");
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
const ownership = ownershipArg
|
|
55
|
+
? parseProjectOwnershipMode(ownershipArg)
|
|
56
|
+
: await promptProjectOwnership(phrenPath, getProjectOwnershipDefault(phrenPath));
|
|
57
|
+
if (ownershipArg && !ownership) {
|
|
58
|
+
console.error(`Invalid --ownership value "${ownershipArg}". Use one of: ${PROJECT_OWNERSHIP_MODES.join(", ")}`);
|
|
59
|
+
return 1;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const added = addProjectFromPath(phrenPath, path.resolve(targetPath), profile, ownership);
|
|
63
|
+
if (!added.ok) {
|
|
64
|
+
console.error(added.error);
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
67
|
+
console.log(`Added project "${added.data.project}" (${added.data.ownership})`);
|
|
68
|
+
if (added.data.files.claude)
|
|
69
|
+
console.log(` ${added.data.files.claude}`);
|
|
70
|
+
console.log(` ${added.data.files.findings}`);
|
|
71
|
+
console.log(` ${added.data.files.task}`);
|
|
72
|
+
console.log(` ${added.data.files.summary}`);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
console.error(`Could not add project: ${e instanceof Error ? e.message : String(e)}`);
|
|
76
|
+
return 1;
|
|
77
|
+
}
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
export async function runInitCommand(args) {
|
|
81
|
+
const { parseMcpMode, runInit } = await import("./init/init.js");
|
|
82
|
+
const machineIdx = args.indexOf("--machine");
|
|
83
|
+
const profileIdx = args.indexOf("--profile");
|
|
84
|
+
const mcpIdx = args.indexOf("--mcp");
|
|
85
|
+
const templateIdx = args.indexOf("--template");
|
|
86
|
+
const modeArg = getOptionValue(args, "--mode");
|
|
87
|
+
const installMode = parseInstallModeFlag(modeArg);
|
|
88
|
+
if (modeArg && !installMode) {
|
|
89
|
+
console.error(`Invalid --mode value "${modeArg}". Use "shared" or "project-local".`);
|
|
90
|
+
return 1;
|
|
91
|
+
}
|
|
92
|
+
const ownershipMode = parseProjectOwnershipMode(getOptionValue(args, "--project-ownership"));
|
|
93
|
+
const taskMode = parseTaskModeFlag(getOptionValue(args, "--task-mode"));
|
|
94
|
+
const findingsProactivity = parseProactivityLevel(getOptionValue(args, "--findings-proactivity"));
|
|
95
|
+
const taskProactivity = parseProactivityLevel(getOptionValue(args, "--task-proactivity"));
|
|
96
|
+
const mcpMode = mcpIdx !== -1 ? parseMcpMode(args[mcpIdx + 1]) : undefined;
|
|
97
|
+
if (mcpIdx !== -1 && !mcpMode) {
|
|
98
|
+
console.error(`Invalid --mcp value "${args[mcpIdx + 1] || ""}". Use "on" or "off".`);
|
|
99
|
+
return 1;
|
|
100
|
+
}
|
|
101
|
+
const ownershipArg = getOptionValue(args, "--project-ownership");
|
|
102
|
+
if (ownershipArg && !ownershipMode) {
|
|
103
|
+
console.error(`Invalid --project-ownership value "${ownershipArg}". Use one of: ${PROJECT_OWNERSHIP_MODES.join(", ")}`);
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
const taskModeArg = getOptionValue(args, "--task-mode");
|
|
107
|
+
if (taskModeArg && !taskMode) {
|
|
108
|
+
console.error(`Invalid --task-mode value "${taskModeArg}". Use one of: off, manual, suggest, auto.`);
|
|
109
|
+
return 1;
|
|
110
|
+
}
|
|
111
|
+
const findingsArg = getOptionValue(args, "--findings-proactivity");
|
|
112
|
+
if (findingsArg && !findingsProactivity) {
|
|
113
|
+
console.error(`Invalid --findings-proactivity value "${findingsArg}". Use one of: high, medium, low.`);
|
|
114
|
+
return 1;
|
|
115
|
+
}
|
|
116
|
+
const taskArg = getOptionValue(args, "--task-proactivity");
|
|
117
|
+
if (taskArg && !taskProactivity) {
|
|
118
|
+
console.error(`Invalid --task-proactivity value "${taskArg}". Use one of: high, medium, low.`);
|
|
119
|
+
return 1;
|
|
120
|
+
}
|
|
121
|
+
const cloneUrl = getOptionValue(args, "--clone-url");
|
|
122
|
+
try {
|
|
123
|
+
await runInit({
|
|
124
|
+
mode: installMode,
|
|
125
|
+
machine: machineIdx !== -1 ? args[machineIdx + 1] : undefined,
|
|
126
|
+
profile: profileIdx !== -1 ? args[profileIdx + 1] : undefined,
|
|
127
|
+
mcp: mcpMode,
|
|
128
|
+
projectOwnershipDefault: ownershipMode,
|
|
129
|
+
taskMode,
|
|
130
|
+
findingsProactivity,
|
|
131
|
+
taskProactivity,
|
|
132
|
+
template: templateIdx !== -1 ? args[templateIdx + 1] : undefined,
|
|
133
|
+
applyStarterUpdate: args.includes("--apply-starter-update"),
|
|
134
|
+
dryRun: args.includes("--dry-run"),
|
|
135
|
+
yes: args.includes("--yes") || args.includes("-y"),
|
|
136
|
+
express: args.includes("--express"),
|
|
137
|
+
force: args.includes("--force"),
|
|
138
|
+
_walkthroughCloneUrl: cloneUrl,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
console.error(errorMessage(err));
|
|
143
|
+
return 1;
|
|
144
|
+
}
|
|
145
|
+
return 0;
|
|
146
|
+
}
|
|
147
|
+
export async function runUninstallCommand(args) {
|
|
148
|
+
const { runUninstall } = await import("./init/init.js");
|
|
149
|
+
const skipConfirm = args.includes("--yes") || args.includes("-y");
|
|
150
|
+
await runUninstall({ yes: skipConfirm });
|
|
151
|
+
return 0;
|
|
152
|
+
}
|
|
153
|
+
export async function runStatusCommand(_args) {
|
|
154
|
+
const { runStatus } = await import("./status.js");
|
|
155
|
+
await runStatus();
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
158
|
+
export async function runVerifyCommand(_args) {
|
|
159
|
+
const { runPostInitVerify, getVerifyOutcomeNote } = await import("./init/init.js");
|
|
160
|
+
const { getWorkflowPolicy } = await import("./shared/governance.js");
|
|
161
|
+
const phrenPath = findPhrenPath() || defaultPhrenPath();
|
|
162
|
+
const result = runPostInitVerify(phrenPath);
|
|
163
|
+
console.log(`phren verify: ${result.ok ? "ok" : "issues found"}`);
|
|
164
|
+
console.log(` tasks: ${getWorkflowPolicy(phrenPath).taskMode} mode`);
|
|
165
|
+
for (const check of result.checks) {
|
|
166
|
+
console.log(` ${check.ok ? "pass" : "FAIL"} ${check.name}: ${check.detail}`);
|
|
167
|
+
if (!check.ok && check.fix) {
|
|
168
|
+
console.log(` fix: ${check.fix}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (!result.ok) {
|
|
172
|
+
const note = getVerifyOutcomeNote(phrenPath, result.checks);
|
|
173
|
+
if (note)
|
|
174
|
+
console.log(`\nNote: ${note}`);
|
|
175
|
+
console.log(`\nRun \`phren init\` to fix setup issues.`);
|
|
176
|
+
}
|
|
177
|
+
return result.ok ? 0 : 1;
|
|
178
|
+
}
|
|
179
|
+
export async function runMcpModeCommand(args) {
|
|
180
|
+
const { runMcpMode } = await import("./init/init.js");
|
|
181
|
+
try {
|
|
182
|
+
await runMcpMode(args[0]);
|
|
183
|
+
return 0;
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
console.error(errorMessage(err));
|
|
187
|
+
return 1;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
export async function runHooksModeCommand(args) {
|
|
191
|
+
const { runHooksMode } = await import("./init/init.js");
|
|
192
|
+
try {
|
|
193
|
+
await runHooksMode(args[0]);
|
|
194
|
+
return 0;
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
console.error(errorMessage(err));
|
|
198
|
+
return 1;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
export async function runLinkRemovedNotice(_args) {
|
|
202
|
+
console.error("`phren link` has been removed. Use `phren init` instead.");
|
|
203
|
+
return 1;
|
|
204
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Topic } from "./cli-registry.js";
|
|
2
|
+
export declare function formatCheatSheet(): string;
|
|
3
|
+
export declare function formatTopic(topic: Topic): string;
|
|
4
|
+
export declare function formatDocTopic(name: string): string | null;
|
|
5
|
+
export declare function formatCommand(name: string): string | null;
|
|
6
|
+
export declare function formatFullHelp(): string;
|
package/dist/cli-help.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Help formatters. Pure functions over the command registry.
|
|
2
|
+
import { REGISTRY, TOPIC_ORDER, DOC_TOPICS, lookupCommand, } from "./cli-registry.js";
|
|
3
|
+
const TOPIC_TITLES = {
|
|
4
|
+
core: "Core commands",
|
|
5
|
+
projects: "Projects",
|
|
6
|
+
skills: "Skills",
|
|
7
|
+
hooks: "Hooks",
|
|
8
|
+
config: "Configuration",
|
|
9
|
+
maintain: "Maintenance",
|
|
10
|
+
setup: "Setup",
|
|
11
|
+
stores: "Stores",
|
|
12
|
+
team: "Team",
|
|
13
|
+
};
|
|
14
|
+
const ALIGN_COL = 40;
|
|
15
|
+
function pad(usage, summary) {
|
|
16
|
+
const text = " " + usage;
|
|
17
|
+
if (!summary)
|
|
18
|
+
return text;
|
|
19
|
+
const gap = Math.max(2, ALIGN_COL - text.length);
|
|
20
|
+
return text + " ".repeat(gap) + summary;
|
|
21
|
+
}
|
|
22
|
+
function visibleCommands() {
|
|
23
|
+
return REGISTRY.filter((c) => !c.hidden);
|
|
24
|
+
}
|
|
25
|
+
function commandsInTopic(topic) {
|
|
26
|
+
return visibleCommands().filter((c) => c.topic === topic);
|
|
27
|
+
}
|
|
28
|
+
function renderCommandLine(cmd) {
|
|
29
|
+
return pad(cmd.usage, cmd.summary);
|
|
30
|
+
}
|
|
31
|
+
function renderCheatSheetLine(cmd) {
|
|
32
|
+
return pad(cmd.cheatUsage ?? cmd.usage, cmd.summary);
|
|
33
|
+
}
|
|
34
|
+
function renderSubcommandLine(sub) {
|
|
35
|
+
return pad(sub.usage, sub.summary);
|
|
36
|
+
}
|
|
37
|
+
function renderCommandWithSubs(cmd) {
|
|
38
|
+
const lines = [renderCommandLine(cmd)];
|
|
39
|
+
if (cmd.subcommands?.length) {
|
|
40
|
+
for (const sub of cmd.subcommands) {
|
|
41
|
+
lines.push(renderSubcommandLine(sub));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return lines;
|
|
45
|
+
}
|
|
46
|
+
// ── Cheat sheet (phren --help) ───────────────────────────────────────────────
|
|
47
|
+
export function formatCheatSheet() {
|
|
48
|
+
const lines = [];
|
|
49
|
+
lines.push("phren - persistent memory for AI agents");
|
|
50
|
+
lines.push("");
|
|
51
|
+
lines.push(pad("phren", "Interactive memory shell"));
|
|
52
|
+
for (const cmd of visibleCommands()) {
|
|
53
|
+
if (!cmd.featured)
|
|
54
|
+
continue;
|
|
55
|
+
lines.push(renderCheatSheetLine(cmd));
|
|
56
|
+
}
|
|
57
|
+
lines.push("");
|
|
58
|
+
lines.push(pad("phren manage <command>", "Alias for the top-level commands above"));
|
|
59
|
+
lines.push(pad("phren mem <command>", "Alias for `phren manage`"));
|
|
60
|
+
lines.push("");
|
|
61
|
+
lines.push(pad("phren help <topic>", "Detailed help"));
|
|
62
|
+
lines.push(`Topics: ${[...TOPIC_ORDER, ...Object.keys(DOC_TOPICS), "all"].join(", ")}`);
|
|
63
|
+
lines.push("");
|
|
64
|
+
return lines.join("\n");
|
|
65
|
+
}
|
|
66
|
+
// ── Topic help (phren help <topic>) ──────────────────────────────────────────
|
|
67
|
+
export function formatTopic(topic) {
|
|
68
|
+
const cmds = commandsInTopic(topic);
|
|
69
|
+
const lines = [];
|
|
70
|
+
lines.push(`${TOPIC_TITLES[topic]}:`);
|
|
71
|
+
for (const cmd of cmds) {
|
|
72
|
+
for (const line of renderCommandWithSubs(cmd)) {
|
|
73
|
+
lines.push(line);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
lines.push("");
|
|
77
|
+
return lines.join("\n");
|
|
78
|
+
}
|
|
79
|
+
// ── Doc topic (phren help env) ───────────────────────────────────────────────
|
|
80
|
+
export function formatDocTopic(name) {
|
|
81
|
+
return DOC_TOPICS[name] ?? null;
|
|
82
|
+
}
|
|
83
|
+
// ── Single command (phren <name> --help / phren help <name>) ─────────────────
|
|
84
|
+
export function formatCommand(name) {
|
|
85
|
+
const cmd = lookupCommand(name);
|
|
86
|
+
if (!cmd)
|
|
87
|
+
return null;
|
|
88
|
+
const lines = [];
|
|
89
|
+
lines.push(`${cmd.usage}`);
|
|
90
|
+
lines.push(` ${cmd.summary}`);
|
|
91
|
+
if (cmd.subcommands?.length) {
|
|
92
|
+
lines.push("");
|
|
93
|
+
lines.push("Subcommands:");
|
|
94
|
+
for (const sub of cmd.subcommands) {
|
|
95
|
+
lines.push(renderSubcommandLine(sub));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
lines.push("");
|
|
99
|
+
return lines.join("\n");
|
|
100
|
+
}
|
|
101
|
+
// ── Full help (phren help all) ───────────────────────────────────────────────
|
|
102
|
+
export function formatFullHelp() {
|
|
103
|
+
const lines = [];
|
|
104
|
+
lines.push("phren - persistent knowledge for your agents");
|
|
105
|
+
lines.push("");
|
|
106
|
+
lines.push("Usage:");
|
|
107
|
+
lines.push(pad("phren", "Interactive shell"));
|
|
108
|
+
for (const cmd of visibleCommands()) {
|
|
109
|
+
if (!cmd.featured)
|
|
110
|
+
continue;
|
|
111
|
+
lines.push(renderCheatSheetLine(cmd));
|
|
112
|
+
}
|
|
113
|
+
lines.push("");
|
|
114
|
+
for (const topic of TOPIC_ORDER) {
|
|
115
|
+
const cmds = commandsInTopic(topic);
|
|
116
|
+
if (!cmds.length)
|
|
117
|
+
continue;
|
|
118
|
+
lines.push(formatTopic(topic));
|
|
119
|
+
}
|
|
120
|
+
for (const [docName, body] of Object.entries(DOC_TOPICS)) {
|
|
121
|
+
lines.push(`${docName.charAt(0).toUpperCase()}${docName.slice(1)} reference:`);
|
|
122
|
+
lines.push(body);
|
|
123
|
+
}
|
|
124
|
+
return lines.join("\n");
|
|
125
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command registry - single source of truth for help generation and dispatch.
|
|
3
|
+
*
|
|
4
|
+
* Order in REGISTRY is load-bearing: it drives cheat-sheet ordering and
|
|
5
|
+
* within-topic ordering. Don't sort.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TOPIC_ORDER: readonly ["core", "projects", "skills", "hooks", "config", "maintain", "setup", "stores", "team"];
|
|
8
|
+
export type Topic = typeof TOPIC_ORDER[number];
|
|
9
|
+
export interface Subcommand {
|
|
10
|
+
name: string;
|
|
11
|
+
usage: string;
|
|
12
|
+
summary?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Lazy accessors passed to every `run`. Both throw or resolve only when
|
|
16
|
+
* called, so commands that dispatch without a configured phren root
|
|
17
|
+
* (`verify`, `init`, `add`, the help router) avoid touching them.
|
|
18
|
+
*/
|
|
19
|
+
export interface CliContext {
|
|
20
|
+
phrenPath: () => string;
|
|
21
|
+
profile: () => string;
|
|
22
|
+
}
|
|
23
|
+
export type RunFn = (argv: string[], ctx: CliContext) => Promise<number | void>;
|
|
24
|
+
export interface Command {
|
|
25
|
+
name: string;
|
|
26
|
+
aliases?: string[];
|
|
27
|
+
topic: Topic;
|
|
28
|
+
/** Full usage line shown in topic help and per-command help. */
|
|
29
|
+
usage: string;
|
|
30
|
+
/** Optional shorter form for the cheat sheet. Falls back to `usage`. */
|
|
31
|
+
cheatUsage?: string;
|
|
32
|
+
summary: string;
|
|
33
|
+
subcommands?: Subcommand[];
|
|
34
|
+
featured?: boolean;
|
|
35
|
+
hidden?: boolean;
|
|
36
|
+
run: RunFn;
|
|
37
|
+
}
|
|
38
|
+
export declare const ENV_HELP = "Environment variables:\n PHREN_PATH Override phren directory (default: ~/.phren)\n PHREN_PROFILE Active profile name\n PHREN_DEBUG Enable debug logging (set to 1)\n\n Embeddings:\n PHREN_OLLAMA_URL Ollama base URL (default: http://localhost:11434, 'off' to disable)\n PHREN_EMBEDDING_API_URL OpenAI-compatible /embeddings endpoint\n PHREN_EMBEDDING_API_KEY API key for embedding endpoint\n PHREN_EMBEDDING_MODEL Embedding model (default: nomic-embed-text)\n\n Context injection:\n PHREN_CONTEXT_TOKEN_BUDGET Max tokens injected per prompt (default: 550)\n PHREN_MAX_INJECT_TOKENS Hard cap on total injected tokens (default: 2000)\n PHREN_HOOK_TIMEOUT_MS Hook subprocess timeout in ms (default: 14000)\n\n Feature flags:\n PHREN_FEATURE_AUTO_EXTRACT=0 Disable auto memory extraction\n PHREN_FEATURE_AUTO_CAPTURE=1 Extract insights from conversations\n PHREN_FEATURE_SEMANTIC_DEDUP=1 LLM-based dedup on add_finding\n PHREN_FEATURE_HYBRID_SEARCH=0 Disable TF-IDF cosine fallback\n\n Run 'phren help all' to see everything.\n";
|
|
39
|
+
export declare const DOC_TOPICS: Record<string, string>;
|
|
40
|
+
export declare const REGISTRY: Command[];
|
|
41
|
+
export declare function lookupCommand(name: string): Command | undefined;
|
|
42
|
+
/** Topic IDs available to `phren help <topic>`, including doc topics and `all`. */
|
|
43
|
+
export declare function helpTopicNames(): string[];
|
|
44
|
+
/** Topic IDs that are command groups (excludes doc topics and `all`). */
|
|
45
|
+
export declare function commandTopics(): readonly Topic[];
|