@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.
@@ -9,7 +9,7 @@ const DEFAULT_PROACTIVITY_LEVEL = "high";
9
9
  const EXPLICIT_FINDING_SIGNAL_PATTERN = /\b(add finding|worth remembering)\b/i;
10
10
  const EXPLICIT_FINDING_TAG_PATTERN = /\[(pitfall|decision|pattern|tradeoff|architecture|bug)\]/i;
11
11
  const EXPLICIT_TASK_SIGNAL_PATTERN = /\b(?:add(?:\s+(?:this|that|it))?\s+(?:to\s+(?:the\s+)?)?(?:task|todo(?:\s+list)?|task(?:\s+list)?)|add\s+(?:a\s+)?task|put(?:\s+(?:this|that|it))?\s+(?:in|on)\s+(?:the\s+)?(?:task|todo(?:\s+list)?|task(?:\s+list)?))\b/i;
12
- function parseProactivityLevel(raw) {
12
+ export function parseProactivityLevel(raw) {
13
13
  if (!raw)
14
14
  return undefined;
15
15
  const normalized = raw.trim().toLowerCase();
package/dist/shared.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export type { HookToolName } from "./provider-adapters.js";
2
2
  export { HOOK_TOOL_NAMES, hookConfigPath } from "./provider-adapters.js";
3
3
  export { EXEC_TIMEOUT_MS, EXEC_TIMEOUT_QUICK_MS, PhrenError, type PhrenErrorCode, type PhrenResult, phrenOk, phrenErr, forwardErr, parsePhrenErrorCode, isRecord, withDefaults, FINDING_TYPES, type FindingType, FINDING_TAGS, type FindingTag, KNOWN_OBSERVATION_TAGS, DOC_TYPES, type DocType, capCache, RESERVED_PROJECT_DIR_NAMES, } from "./phren-core.js";
4
- export { ROOT_MANIFEST_FILENAME, type InstallMode, type SyncMode, type PhrenRootManifest, type InstallContext, homeDir, homePath, expandHomePath, defaultPhrenPath, rootManifestPath, readRootManifest, writeRootManifest, resolveInstallContext, findNearestPhrenPath, isProjectLocalMode, runtimeDir, tryUnlink, sessionsDir, runtimeFile, installPreferencesFile, runtimeHealthFile, shellStateFile, sessionMetricsFile, memoryScoresFile, memoryUsageLogFile, sessionMarker, debugLog, appendIndexEvent, resolveFindingsPath, findPhrenPath, ensurePhrenPath, findPhrenPathWithArg, normalizeProjectNameForCreate, findProjectNameCaseInsensitive, findArchivedProjectNameCaseInsensitive, getProjectDirs, listInvalidProjectDirs, collectNativeMemoryFiles, computePhrenLiveStateToken, getPhrenPath, qualityMarkers, atomicWriteText, } from "./phren-paths.js";
5
- export { PROACTIVITY_LEVELS, type ProactivityLevel, getProactivityLevel, getProactivityLevelForFindings, getProactivityLevelForTask, hasExplicitFindingSignal, hasExplicitTaskSignal, hasExecutionIntent, hasDiscoveryIntent, shouldAutoCaptureFindingsForLevel, shouldAutoCaptureTaskForLevel, } from "./proactivity.js";
4
+ export { ROOT_MANIFEST_FILENAME, type InstallMode, type SyncMode, type PhrenRootManifest, type InstallContext, isInstallMode, homeDir, homePath, expandHomePath, defaultPhrenPath, rootManifestPath, readRootManifest, writeRootManifest, resolveInstallContext, findNearestPhrenPath, isProjectLocalMode, runtimeDir, tryUnlink, sessionsDir, runtimeFile, installPreferencesFile, runtimeHealthFile, shellStateFile, sessionMetricsFile, memoryScoresFile, memoryUsageLogFile, sessionMarker, debugLog, appendIndexEvent, resolveFindingsPath, findPhrenPath, ensurePhrenPath, findPhrenPathWithArg, normalizeProjectNameForCreate, findProjectNameCaseInsensitive, findArchivedProjectNameCaseInsensitive, getProjectDirs, listInvalidProjectDirs, collectNativeMemoryFiles, computePhrenLiveStateToken, getPhrenPath, qualityMarkers, atomicWriteText, } from "./phren-paths.js";
5
+ export { PROACTIVITY_LEVELS, type ProactivityLevel, parseProactivityLevel, getProactivityLevel, getProactivityLevelForFindings, getProactivityLevelForTask, hasExplicitFindingSignal, hasExplicitTaskSignal, hasExecutionIntent, hasDiscoveryIntent, shouldAutoCaptureFindingsForLevel, shouldAutoCaptureTaskForLevel, } from "./proactivity.js";
6
6
  export declare function normalizeMemoryScope(scope?: string | null): string | undefined;
7
7
  export declare function isMemoryScopeVisible(itemScope: string | undefined, activeScope?: string): boolean;
8
8
  export declare function impactLogFile(phrenPath: string): string;
package/dist/shared.js CHANGED
@@ -6,8 +6,8 @@ import { withFileLock } from "./governance/locks.js";
6
6
  const MAX_LOG_LINES = 1000;
7
7
  export { HOOK_TOOL_NAMES, hookConfigPath } from "./provider-adapters.js";
8
8
  export { EXEC_TIMEOUT_MS, EXEC_TIMEOUT_QUICK_MS, PhrenError, phrenOk, phrenErr, forwardErr, parsePhrenErrorCode, isRecord, withDefaults, FINDING_TYPES, FINDING_TAGS, KNOWN_OBSERVATION_TAGS, DOC_TYPES, capCache, RESERVED_PROJECT_DIR_NAMES, } from "./phren-core.js";
9
- export { ROOT_MANIFEST_FILENAME, homeDir, homePath, expandHomePath, defaultPhrenPath, rootManifestPath, readRootManifest, writeRootManifest, resolveInstallContext, findNearestPhrenPath, isProjectLocalMode, runtimeDir, tryUnlink, sessionsDir, runtimeFile, installPreferencesFile, runtimeHealthFile, shellStateFile, sessionMetricsFile, memoryScoresFile, memoryUsageLogFile, sessionMarker, debugLog, appendIndexEvent, resolveFindingsPath, findPhrenPath, ensurePhrenPath, findPhrenPathWithArg, normalizeProjectNameForCreate, findProjectNameCaseInsensitive, findArchivedProjectNameCaseInsensitive, getProjectDirs, listInvalidProjectDirs, collectNativeMemoryFiles, computePhrenLiveStateToken, getPhrenPath, qualityMarkers, atomicWriteText, } from "./phren-paths.js";
10
- export { PROACTIVITY_LEVELS, getProactivityLevel, getProactivityLevelForFindings, getProactivityLevelForTask, hasExplicitFindingSignal, hasExplicitTaskSignal, hasExecutionIntent, hasDiscoveryIntent, shouldAutoCaptureFindingsForLevel, shouldAutoCaptureTaskForLevel, } from "./proactivity.js";
9
+ export { ROOT_MANIFEST_FILENAME, isInstallMode, homeDir, homePath, expandHomePath, defaultPhrenPath, rootManifestPath, readRootManifest, writeRootManifest, resolveInstallContext, findNearestPhrenPath, isProjectLocalMode, runtimeDir, tryUnlink, sessionsDir, runtimeFile, installPreferencesFile, runtimeHealthFile, shellStateFile, sessionMetricsFile, memoryScoresFile, memoryUsageLogFile, sessionMarker, debugLog, appendIndexEvent, resolveFindingsPath, findPhrenPath, ensurePhrenPath, findPhrenPathWithArg, normalizeProjectNameForCreate, findProjectNameCaseInsensitive, findArchivedProjectNameCaseInsensitive, getProjectDirs, listInvalidProjectDirs, collectNativeMemoryFiles, computePhrenLiveStateToken, getPhrenPath, qualityMarkers, atomicWriteText, } from "./phren-paths.js";
10
+ export { PROACTIVITY_LEVELS, parseProactivityLevel, getProactivityLevel, getProactivityLevelForFindings, getProactivityLevelForTask, hasExplicitFindingSignal, hasExplicitTaskSignal, hasExecutionIntent, hasDiscoveryIntent, shouldAutoCaptureFindingsForLevel, shouldAutoCaptureTaskForLevel, } from "./proactivity.js";
11
11
  const MEMORY_SCOPE_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/;
12
12
  export function normalizeMemoryScope(scope) {
13
13
  if (typeof scope !== "string")
package/dist/tools/ops.js CHANGED
@@ -51,7 +51,7 @@ async function handleAddProject(ctx, { path: targetPath, profile: requestedProfi
51
51
  }
52
52
  }
53
53
  }
54
- const added = addProjectFromPath(targetPhrenPath, targetPath, requestedProfile || profile || undefined, parseProjectOwnershipMode(ownership) ?? undefined);
54
+ const added = addProjectFromPath(phrenPath, targetPath, requestedProfile || profile || undefined, parseProjectOwnershipMode(ownership) ?? undefined, { writeToPath: targetPhrenPath });
55
55
  if (!added.ok) {
56
56
  return mcpResponse({
57
57
  ok: false,
@@ -9,4 +9,6 @@ export declare function resolveExecCommand(cmd: string): ResolvedExecCommand;
9
9
  export declare function errorMessage(err: unknown): string;
10
10
  export declare function isFeatureEnabled(envName: string, defaultValue?: boolean): boolean;
11
11
  export declare function clampInt(raw: string | undefined, fallback: number, min: number, max: number): number;
12
+ export declare function getOptionValue(args: string[], name: string): string | undefined;
13
+ export declare function getPositionalArgs(args: string[], optionNamesWithValues: string[]): string[];
12
14
  export {};
@@ -78,3 +78,27 @@ export function clampInt(raw, fallback, min, max) {
78
78
  return fallback;
79
79
  return Math.min(max, Math.max(min, parsed));
80
80
  }
81
+ // ── Argv parsing helpers ────────────────────────────────────────────────────
82
+ export function getOptionValue(args, name) {
83
+ const exactIdx = args.indexOf(name);
84
+ if (exactIdx !== -1)
85
+ return args[exactIdx + 1];
86
+ const prefixed = args.find((arg) => arg.startsWith(`${name}=`));
87
+ return prefixed ? prefixed.slice(name.length + 1) : undefined;
88
+ }
89
+ export function getPositionalArgs(args, optionNamesWithValues) {
90
+ const positions = [];
91
+ for (let i = 0; i < args.length; i += 1) {
92
+ const arg = args[i];
93
+ if (optionNamesWithValues.includes(arg)) {
94
+ i += 1;
95
+ continue;
96
+ }
97
+ if (optionNamesWithValues.some((name) => arg.startsWith(`${name}=`))) {
98
+ continue;
99
+ }
100
+ if (!arg.startsWith("--"))
101
+ positions.push(arg);
102
+ }
103
+ return positions;
104
+ }
package/dist/utils.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { runGitOrThrow, runGit, normalizeExecCommand, resolveExecCommand, errorMessage, isFeatureEnabled, clampInt, } from "./utils-helpers.js";
1
+ export { runGitOrThrow, runGit, normalizeExecCommand, resolveExecCommand, errorMessage, isFeatureEnabled, clampInt, getOptionValue, getPositionalArgs, } from "./utils-helpers.js";
2
2
  export { isValidProjectName, safeProjectPath, queueFilePath, } from "./utils-paths.js";
3
3
  export { STOP_WORDS, extractKeywordEntries, extractKeywords, learnedSynonymsPath, loadLearnedSynonyms, loadSynonymMap, learnSynonym, removeLearnedSynonym, sanitizeFts5Query, buildRobustFtsQuery, buildRelaxedFtsQuery, buildFtsQueryVariants, } from "./utils-fts.js";
package/dist/utils.js CHANGED
@@ -1,8 +1,6 @@
1
- // Barrel re-export — all public API preserved for existing importers.
2
- // Actual implementations live in:
3
- // utils-helpers.ts — errorMessage, runGit*, isFeatureEnabled, clampInt, exec helpers
4
- // utils-paths.ts — isValidProjectName, safeProjectPath, queueFilePath
5
- // utils-fts.ts — FTS5 sanitization, synonym expansion, keyword extraction, query building
6
- export { runGitOrThrow, runGit, normalizeExecCommand, resolveExecCommand, errorMessage, isFeatureEnabled, clampInt, } from "./utils-helpers.js";
1
+ // Barrel re-export. Implementations split across utils-helpers.ts (general
2
+ // helpers, argv parsing, exec helpers), utils-paths.ts (path validation),
3
+ // utils-fts.ts (FTS5 query building, synonym/keyword extraction).
4
+ export { runGitOrThrow, runGit, normalizeExecCommand, resolveExecCommand, errorMessage, isFeatureEnabled, clampInt, getOptionValue, getPositionalArgs, } from "./utils-helpers.js";
7
5
  export { isValidProjectName, safeProjectPath, queueFilePath, } from "./utils-paths.js";
8
6
  export { STOP_WORDS, extractKeywordEntries, extractKeywords, learnedSynonymsPath, loadLearnedSynonyms, loadSynonymMap, learnSynonym, removeLearnedSynonym, sanitizeFts5Query, buildRobustFtsQuery, buildRelaxedFtsQuery, buildFtsQueryVariants, } from "./utils-fts.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phren/cli",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Knowledge layer for AI agents — CLI, MCP server, and data layer",
5
5
  "type": "module",
6
6
  "bin": {
package/dist/cli/cli.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { detectTaskIntent, parseHookInput, applyTrustFilter, rankResults, selectSnippets, buildHookOutput, trackSessionMetrics, filterTaskByPriority, parseCitations, validateCitation, annotateStale, getProjectGlobBoost, clearProjectGlobCache, clearCitationValidCache, filterConversationInsightsForProactivity, extractToolFindings, filterToolFindingsForProactivity, type HookPromptInput, type SelectedSnippet, } from "./hooks.js";
2
- export { scoreFindingCandidate } from "./extract.js";
3
- export declare function runCliCommand(command: string, args: string[]): Promise<void | import("./govern.js").GovernanceSummary>;
package/dist/cli/cli.js DELETED
@@ -1,125 +0,0 @@
1
- import { getPhrenPath } from "../shared.js";
2
- // Re-export from split modules so existing test imports keep working
3
- export { detectTaskIntent, parseHookInput, applyTrustFilter, rankResults, selectSnippets, buildHookOutput, trackSessionMetrics, filterTaskByPriority, parseCitations, validateCitation, annotateStale, getProjectGlobBoost, clearProjectGlobCache, clearCitationValidCache, filterConversationInsightsForProactivity, extractToolFindings, filterToolFindingsForProactivity, } from "./hooks.js";
4
- export { scoreFindingCandidate } from "./extract.js";
5
- import { handleHookPrompt, handleHookSessionStart, handleHookStop, handleBackgroundSync, handleHookContext, handleHookTool, } from "./hooks.js";
6
- import { handleExtractMemories } from "./extract.js";
7
- import { handleGovernMemories, handlePruneMemories, handleConsolidateMemories, handleMaintain, handleBackgroundMaintenance, } from "./govern.js";
8
- import { handleConfig, handleIndexPolicy, handleRetentionPolicy, handleWorkflowPolicy, } from "./config.js";
9
- import { parseSearchArgs } from "./search.js";
10
- import { handleDetectSkills, handleFindingNamespace, handleHooksNamespace, handleProfileNamespace, handleProjectsNamespace, handleSkillsNamespace, handleSkillList, handlePromoteNamespace, handleReviewNamespace, handleStoreNamespace, handleTaskNamespace, } from "./namespaces.js";
11
- import { handleTeamNamespace } from "./team.js";
12
- import { handleTaskView, handleSessionsView, handleQuickstart, handleDebugInjection, handleInspectIndex, } from "./ops.js";
13
- import { handleAddFinding, handleDoctor, handleFragmentSearch, handleMemoryUi, handleTruths, handlePinCanonical, handleQualityFeedback, handleRelatedDocs, handleConsolidationStatus, handleSessionContext, handleSearch, handleShell, handleStatus, handleUpdate, } from "./actions.js";
14
- import { handleGraphNamespace } from "./graph.js";
15
- import { resolveRuntimeProfile } from "../runtime-profile.js";
16
- // ── CLI router ───────────────────────────────────────────────────────────────
17
- export async function runCliCommand(command, args) {
18
- const getProfile = () => resolveRuntimeProfile(getPhrenPath());
19
- switch (command) {
20
- case "search":
21
- {
22
- const opts = parseSearchArgs(getPhrenPath(), args);
23
- if (!opts)
24
- return;
25
- return handleSearch(opts, getProfile());
26
- }
27
- case "hook-prompt":
28
- return handleHookPrompt();
29
- case "hook-session-start":
30
- return handleHookSessionStart();
31
- case "hook-stop":
32
- return handleHookStop();
33
- case "background-sync":
34
- return handleBackgroundSync();
35
- case "hook-context":
36
- return handleHookContext();
37
- case "hook-tool":
38
- return handleHookTool();
39
- case "add-finding":
40
- return handleAddFinding(args[0], args.slice(1).join(" "));
41
- case "extract-memories":
42
- return handleExtractMemories(args[0]);
43
- case "govern-memories":
44
- return handleGovernMemories(args[0]);
45
- case "pin":
46
- return handlePinCanonical(args[0], args.slice(1).join(" "));
47
- case "doctor":
48
- return handleDoctor(args);
49
- case "status":
50
- return handleStatus();
51
- case "quality-feedback":
52
- return handleQualityFeedback(args);
53
- case "prune-memories":
54
- return handlePruneMemories(args);
55
- case "consolidate-memories":
56
- return handleConsolidateMemories(args);
57
- case "index-policy":
58
- return handleIndexPolicy(args);
59
- case "policy":
60
- return handleRetentionPolicy(args);
61
- case "workflow":
62
- return handleWorkflowPolicy(args);
63
- case "web-ui":
64
- return handleMemoryUi(args);
65
- case "shell":
66
- return handleShell(args, getProfile());
67
- case "update":
68
- return handleUpdate(args);
69
- case "config":
70
- return handleConfig(args);
71
- case "maintain":
72
- return handleMaintain(args);
73
- case "skill-list":
74
- return handleSkillList(getProfile());
75
- case "skills":
76
- return handleSkillsNamespace(args, getProfile());
77
- case "hooks":
78
- return handleHooksNamespace(args);
79
- case "tasks":
80
- return handleTaskView(getProfile());
81
- case "sessions":
82
- return await handleSessionsView(args);
83
- case "task":
84
- return handleTaskNamespace(args);
85
- case "finding":
86
- return handleFindingNamespace(args);
87
- case "projects":
88
- return handleProjectsNamespace(args, args[0] === "--help" || args[0] === "-h" ? "" : getProfile());
89
- case "quickstart":
90
- return handleQuickstart();
91
- case "background-maintenance":
92
- return handleBackgroundMaintenance(args[0]);
93
- case "debug-injection":
94
- return handleDebugInjection(args, getProfile());
95
- case "inspect-index":
96
- return handleInspectIndex(args, getProfile());
97
- case "search-fragments":
98
- return handleFragmentSearch(args, getProfile());
99
- case "related-docs":
100
- return handleRelatedDocs(args, getProfile());
101
- case "detect-skills":
102
- return handleDetectSkills(args, getProfile());
103
- case "graph":
104
- return handleGraphNamespace(args);
105
- case "review":
106
- return handleReviewNamespace(args);
107
- case "consolidation-status":
108
- return handleConsolidationStatus(args);
109
- case "session-context":
110
- return handleSessionContext();
111
- case "truths":
112
- return handleTruths(args[0]);
113
- case "store":
114
- return handleStoreNamespace(args);
115
- case "profile":
116
- return handleProfileNamespace(args);
117
- case "team":
118
- return handleTeamNamespace(args);
119
- case "promote":
120
- return handlePromoteNamespace(args);
121
- default:
122
- console.error(`Unknown command: ${command}\nRun 'phren --help' for available commands.`);
123
- process.exit(1);
124
- }
125
- }