@phren/cli 0.1.44 → 0.1.45

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.
Files changed (74) hide show
  1. package/dist/cli/actions.d.ts +1 -1
  2. package/dist/cli/actions.js +7 -2
  3. package/dist/cli/config-proactivity.d.ts +6 -6
  4. package/dist/cli/hooks.d.ts +1 -1
  5. package/dist/cli/hooks.js +14 -3
  6. package/dist/cli/session-stop.d.ts +1 -1
  7. package/dist/cli/session-tool-hook.d.ts +1 -1
  8. package/dist/cli-registry.js +1 -1
  9. package/dist/data/access.js +2 -1
  10. package/dist/generated/memory-ui-graph.browser.js +481 -318
  11. package/dist/governance/locks.js +6 -0
  12. package/dist/graph-core/index.d.ts +2 -0
  13. package/dist/graph-core/index.js +2 -0
  14. package/dist/graph-core/model.d.ts +84 -0
  15. package/dist/graph-core/model.js +355 -0
  16. package/dist/graph-core/types.d.ts +110 -0
  17. package/dist/graph-core/types.js +43 -0
  18. package/dist/index.js +4 -1
  19. package/dist/init/init-uninstall.d.ts +1 -0
  20. package/dist/init/init-uninstall.js +1 -1
  21. package/dist/init/setup.js +11 -4
  22. package/dist/link/context.js +2 -1
  23. package/dist/link/link.js +3 -2
  24. package/dist/link/skills.js +2 -1
  25. package/dist/memory-ui-graph.runtime.js +481 -318
  26. package/dist/phren-core.d.ts +16 -0
  27. package/dist/phren-core.js +21 -0
  28. package/dist/phren-paths.js +8 -4
  29. package/dist/profile-store.js +3 -2
  30. package/dist/project-config.js +2 -1
  31. package/dist/shared/index.js +1 -1
  32. package/dist/shared/retrieval.d.ts +28 -0
  33. package/dist/shared/retrieval.js +45 -0
  34. package/dist/shell/entry.d.ts +3 -3
  35. package/dist/shell/entry.js +19 -44
  36. package/dist/shell/graph/canvas.d.ts +64 -0
  37. package/dist/shell/graph/canvas.js +256 -0
  38. package/dist/shell/graph/controller.d.ts +164 -0
  39. package/dist/shell/graph/controller.js +645 -0
  40. package/dist/shell/graph/glyphs.d.ts +12 -0
  41. package/dist/shell/graph/glyphs.js +31 -0
  42. package/dist/shell/graph/graph-view.d.ts +12 -0
  43. package/dist/shell/graph/graph-view.js +408 -0
  44. package/dist/shell/graph/layout.d.ts +68 -0
  45. package/dist/shell/graph/layout.js +267 -0
  46. package/dist/shell/input.d.ts +3 -0
  47. package/dist/shell/input.js +24 -4
  48. package/dist/shell/intro.d.ts +37 -0
  49. package/dist/shell/intro.js +82 -0
  50. package/dist/shell/logo-fx.d.ts +35 -0
  51. package/dist/shell/logo-fx.js +128 -0
  52. package/dist/shell/render.d.ts +2 -2
  53. package/dist/shell/render.js +12 -28
  54. package/dist/shell/shell.d.ts +13 -1
  55. package/dist/shell/shell.js +45 -7
  56. package/dist/shell/startup.d.ts +37 -0
  57. package/dist/shell/startup.js +105 -0
  58. package/dist/shell/state-store.d.ts +1 -1
  59. package/dist/shell/state-store.js +1 -1
  60. package/dist/shell/types.js +1 -0
  61. package/dist/shell/view.d.ts +3 -0
  62. package/dist/shell/view.js +24 -3
  63. package/dist/store-registry.js +3 -3
  64. package/dist/test-global-setup.d.ts +1 -0
  65. package/dist/test-global-setup.js +22 -0
  66. package/dist/tool-registry.js +1 -0
  67. package/dist/ui/data.d.ts +15 -7
  68. package/dist/ui/data.js +102 -3
  69. package/dist/utils-fts.js +2 -1
  70. package/dist/utils-helpers.d.ts +1 -0
  71. package/dist/utils-helpers.js +6 -0
  72. package/dist/utils.d.ts +1 -1
  73. package/dist/utils.js +1 -1
  74. package/package.json +11 -7
@@ -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(_args: string[], profile: string): Promise<void>;
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>;
@@ -303,8 +303,13 @@ export async function handleMemoryUi(args) {
303
303
  allowPortFallback: !portRequested,
304
304
  });
305
305
  }
306
- export async function handleShell(_args, profile) {
307
- await startShell(getPhrenPath(), profile);
306
+ export async function handleShell(args, profile) {
307
+ const phrenPath = getPhrenPath();
308
+ const { parseShellArgs, resolveShellStartup } = await import("../shell/startup.js");
309
+ const { startup, warnings } = resolveShellStartup(parseShellArgs(args), { phrenPath, profile });
310
+ if (warnings.length)
311
+ startup.notice = warnings.join(" ");
312
+ await startShell(phrenPath, profile, startup);
308
313
  }
309
314
  export async function handleUpdate(args) {
310
315
  const result = await runPhrenUpdate({ refreshStarter: args.includes("--refresh-starter") });
@@ -1,14 +1,14 @@
1
1
  export declare function buildProactivitySnapshot(phrenPath: string): {
2
2
  path: string;
3
3
  configured: {
4
- proactivity: "high" | "medium" | "low" | null;
5
- proactivityFindings: "high" | "medium" | "low" | null;
6
- proactivityTask: "high" | "medium" | "low" | null;
4
+ proactivity: "high" | "low" | "medium" | null;
5
+ proactivityFindings: "high" | "low" | "medium" | null;
6
+ proactivityTask: "high" | "low" | "medium" | null;
7
7
  };
8
8
  effective: {
9
- proactivity: "high" | "medium" | "low";
10
- proactivityFindings: "high" | "medium" | "low";
11
- proactivityTask: "high" | "medium" | "low";
9
+ proactivity: "high" | "low" | "medium";
10
+ proactivityFindings: "high" | "low" | "medium";
11
+ proactivityTask: "high" | "low" | "medium";
12
12
  };
13
13
  };
14
14
  export declare function handleConfigProactivity(subcommand: "proactivity" | "proactivity.findings" | "proactivity.tasks", args: string[]): void;
@@ -1,6 +1,6 @@
1
1
  export { parseCitations, validateCitation, annotateStale, clearCitationValidCache, type ParsedCitation, } from "./hooks-citations.js";
2
2
  export { getProjectGlobBoost, clearProjectGlobCache, } from "./hooks-globs.js";
3
- export { detectTaskIntent, filterTaskByPriority, searchDocuments, applyTrustFilter, rankResults, selectSnippets, type SelectedSnippet, } from "../shared/retrieval.js";
3
+ export { detectTaskIntent, filterTaskByPriority, searchDocuments, applyTrustFilter, rankResults, applyRelevanceFloor, DEFAULT_MIN_QUERY_RELEVANCE, selectSnippets, type SelectedSnippet, } from "../shared/retrieval.js";
4
4
  export { buildHookOutput, } from "./hooks-output.js";
5
5
  export { handleHookSessionStart, handleHookStop, handleBackgroundSync, handleHookContext, handleHookTool, trackSessionMetrics, filterConversationInsightsForProactivity, extractToolFindings, filterToolFindingsForProactivity, resolveSubprocessArgs, } from "./hooks-session.js";
6
6
  export interface HookPromptInput {
package/dist/cli/hooks.js CHANGED
@@ -9,7 +9,7 @@ import { mergeConfig, } from "../shared/governance.js";
9
9
  import { loadIndexForHook, detectProject, } from "../shared/index.js";
10
10
  import { isProjectHookEnabled } from "../project-config.js";
11
11
  import { checkConsolidationNeeded, } from "../shared/content.js";
12
- import { buildRobustFtsQuery, extractKeywordEntries, isFeatureEnabled, clampInt, errorMessage, } from "../utils.js";
12
+ import { buildRobustFtsQuery, extractKeywordEntries, isFeatureEnabled, clampInt, clampFloat, errorMessage, } from "../utils.js";
13
13
  import { getHooksEnabledPreference } from "../init/init.js";
14
14
  import { logger } from "../logger.js";
15
15
  import { isToolHookEnabled, runPrePromptHooks } from "../hooks.js";
@@ -25,13 +25,13 @@ export { parseCitations, validateCitation, annotateStale, clearCitationValidCach
25
25
  // Globs
26
26
  export { getProjectGlobBoost, clearProjectGlobCache, } from "./hooks-globs.js";
27
27
  // Retrieval
28
- export { detectTaskIntent, filterTaskByPriority, searchDocuments, applyTrustFilter, rankResults, selectSnippets, } from "../shared/retrieval.js";
28
+ export { detectTaskIntent, filterTaskByPriority, searchDocuments, applyTrustFilter, rankResults, applyRelevanceFloor, DEFAULT_MIN_QUERY_RELEVANCE, selectSnippets, } from "../shared/retrieval.js";
29
29
  // Output
30
30
  export { buildHookOutput, } from "./hooks-output.js";
31
31
  // Session
32
32
  export { handleHookSessionStart, handleHookStop, handleBackgroundSync, handleHookContext, handleHookTool, trackSessionMetrics, filterConversationInsightsForProactivity, extractToolFindings, filterToolFindingsForProactivity, resolveSubprocessArgs, } from "./hooks-session.js";
33
33
  // ── Imports for the orchestrator ─────────────────────────────────────────────
34
- import { searchDocumentsAsync, applyTrustFilter, rankResults, selectSnippets, detectTaskIntent, } from "../shared/retrieval.js";
34
+ import { searchDocumentsAsync, applyTrustFilter, rankResults, applyRelevanceFloor, DEFAULT_MIN_QUERY_RELEVANCE, selectSnippets, detectTaskIntent, } from "../shared/retrieval.js";
35
35
  import { buildHookOutput } from "./hooks-output.js";
36
36
  import { getGitContext, trackSessionMetrics, } from "./hooks-session.js";
37
37
  import { approximateTokens, SNIPPET_OVERHEAD_TOKENS } from "../shared/retrieval.js";
@@ -172,6 +172,17 @@ export async function handleHookPrompt() {
172
172
  const tRank0 = Date.now();
173
173
  rows = rankResults(rows, intent, gitCtx, detectedProject, getPhrenPath(), db, cwd, keywords);
174
174
  stage.rankMs = Date.now() - tRank0;
175
+ if (!rows.length)
176
+ process.exit(0);
177
+ // Relevance floor: inject signal or nothing. Ranking scores on priors too,
178
+ // so a doc can rank well with no real tie to this prompt — drop those rather
179
+ // than pad to a quota with noise (env PHREN_MIN_QUERY_RELEVANCE=0 disables).
180
+ const relevanceFloor = clampFloat(process.env.PHREN_MIN_QUERY_RELEVANCE, DEFAULT_MIN_QUERY_RELEVANCE, 0, 1);
181
+ const preFloorCount = rows.length;
182
+ rows = applyRelevanceFloor(rows, keywords, gitCtx, detectedProject, relevanceFloor);
183
+ if (rows.length !== preFloorCount) {
184
+ debugLog(`relevance-floor: ${preFloorCount} -> ${rows.length} rows (floor=${relevanceFloor})`);
185
+ }
175
186
  if (!rows.length)
176
187
  process.exit(0);
177
188
  let safeTokenBudget = clampInt(process.env.PHREN_CONTEXT_TOKEN_BUDGET, 550, 180, 10000);
@@ -4,7 +4,7 @@ import { type PushStatus, type SyncStatus } from "../shared/governance.js";
4
4
  * Returns lines that contain insight-signal words and look like actionable knowledge.
5
5
  */
6
6
  export declare function extractConversationInsights(text: string): string[];
7
- export declare function filterConversationInsightsForProactivity(insights: string[], level?: "high" | "medium" | "low"): string[];
7
+ export declare function filterConversationInsightsForProactivity(insights: string[], level?: "high" | "low" | "medium"): string[];
8
8
  /**
9
9
  * Build the `lastSync` patch for a sync attempt, carrying the failure streak
10
10
  * forward. Success resets the counter and stamps `lastSuccessfulPushAt`;
@@ -8,7 +8,7 @@ export declare function filterToolFindingsForProactivity(candidates: Array<{
8
8
  text: string;
9
9
  confidence: number;
10
10
  explicit?: boolean;
11
- }>, level?: "high" | "medium" | "low"): Array<{
11
+ }>, level?: "high" | "low" | "medium"): Array<{
12
12
  text: string;
13
13
  confidence: number;
14
14
  explicit?: boolean;
@@ -226,7 +226,7 @@ export const REGISTRY = [
226
226
  {
227
227
  name: "shell",
228
228
  topic: "core",
229
- usage: "phren shell",
229
+ usage: "phren shell [--view <view>] [--project <name>] [--here]",
230
230
  summary: "Interactive memory shell",
231
231
  featured: true,
232
232
  run: async (args, ctx) => {
@@ -4,6 +4,7 @@
4
4
  import * as fs from "fs";
5
5
  import * as path from "path";
6
6
  import * as yaml from "js-yaml";
7
+ import { loadYamlDocument } from "../phren-core.js";
7
8
  import { appendAuditLog, phrenErr, PhrenError, phrenOk, forwardErr, getProjectDirs, isRecord, } from "../shared.js";
8
9
  import { normalizeQueueEntryText, } from "../shared/governance.js";
9
10
  import { addFindingToFile, } from "../shared/content.js";
@@ -111,7 +112,7 @@ function validateAggregateQueueProfile(phrenPath, profile) {
111
112
  }
112
113
  let data;
113
114
  try {
114
- data = yaml.load(fs.readFileSync(profilePath, "utf-8"), { schema: yaml.CORE_SCHEMA });
115
+ data = loadYamlDocument(fs.readFileSync(profilePath, "utf-8"), (text) => yaml.load(text, { schema: yaml.CORE_SCHEMA }));
115
116
  }
116
117
  catch {
117
118
  return phrenErr(`Malformed profile YAML: ${profilePath}`, PhrenError.MALFORMED_YAML);