@phren/cli 0.1.31 → 0.1.33

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 (73) hide show
  1. package/dist/capabilities/cli.js +2 -2
  2. package/dist/cli/config-access.d.ts +1 -0
  3. package/dist/cli/config-access.js +59 -0
  4. package/dist/cli/config-llm.d.ts +1 -0
  5. package/dist/cli/config-llm.js +60 -0
  6. package/dist/cli/config-policy.d.ts +11 -0
  7. package/dist/cli/config-policy.js +328 -0
  8. package/dist/cli/config-proactivity.d.ts +15 -0
  9. package/dist/cli/config-proactivity.js +129 -0
  10. package/dist/cli/config-shared.d.ts +6 -0
  11. package/dist/cli/config-shared.js +23 -0
  12. package/dist/cli/config-synonyms.d.ts +1 -0
  13. package/dist/cli/config-synonyms.js +60 -0
  14. package/dist/cli/config.d.ts +6 -24
  15. package/dist/cli/config.js +13 -670
  16. package/dist/finding-graph-id.d.ts +15 -0
  17. package/dist/finding-graph-id.js +58 -0
  18. package/dist/generated/memory-ui-graph.browser.js +15 -15
  19. package/dist/governance/activity.d.ts +36 -0
  20. package/dist/governance/activity.js +83 -0
  21. package/dist/governance/rbac.d.ts +17 -0
  22. package/dist/governance/rbac.js +37 -1
  23. package/dist/memory-ui-graph.runtime.js +15 -15
  24. package/dist/phren-paths.d.ts +6 -0
  25. package/dist/phren-paths.js +8 -0
  26. package/dist/shared/governance.d.ts +1 -0
  27. package/dist/shared/governance.js +1 -0
  28. package/dist/shared.d.ts +1 -1
  29. package/dist/shared.js +1 -1
  30. package/dist/tools/config.js +39 -2
  31. package/dist/tools/finding.js +5 -11
  32. package/dist/tools/search.js +28 -1
  33. package/dist/tools/tasks.js +3 -12
  34. package/dist/ui/data.d.ts +2 -0
  35. package/dist/ui/data.js +8 -3
  36. package/dist/ui/graph.js +2 -0
  37. package/dist/ui/page.js +45 -2
  38. package/dist/ui/scripts.d.ts +13 -0
  39. package/dist/ui/scripts.js +229 -2
  40. package/dist/ui/server.js +165 -1
  41. package/dist/ui/styles.d.ts +1 -0
  42. package/dist/ui/styles.js +38 -0
  43. package/package.json +1 -1
  44. package/dist/cli-hooks-prompt.d.ts +0 -18
  45. package/dist/cli-hooks-prompt.js +0 -359
  46. package/dist/cli-hooks-session-handlers.d.ts +0 -3
  47. package/dist/cli-hooks-session-handlers.js +0 -356
  48. package/dist/cli-hooks-stop.d.ts +0 -11
  49. package/dist/cli-hooks-stop.js +0 -584
  50. package/dist/init-bootstrap.d.ts +0 -5
  51. package/dist/init-bootstrap.js +0 -21
  52. package/dist/init-detect.d.ts +0 -8
  53. package/dist/init-detect.js +0 -38
  54. package/dist/init-env.d.ts +0 -6
  55. package/dist/init-env.js +0 -114
  56. package/dist/init-fresh.d.ts +0 -10
  57. package/dist/init-fresh.js +0 -234
  58. package/dist/init-hooks.d.ts +0 -5
  59. package/dist/init-hooks.js +0 -26
  60. package/dist/init-mcp.d.ts +0 -8
  61. package/dist/init-mcp.js +0 -65
  62. package/dist/init-modes.d.ts +0 -4
  63. package/dist/init-modes.js +0 -135
  64. package/dist/init-npm.d.ts +0 -10
  65. package/dist/init-npm.js +0 -37
  66. package/dist/init-project-local.d.ts +0 -2
  67. package/dist/init-project-local.js +0 -99
  68. package/dist/init-semantic.d.ts +0 -4
  69. package/dist/init-semantic.js +0 -48
  70. package/dist/init-types.d.ts +0 -59
  71. package/dist/init-types.js +0 -1
  72. package/dist/init-update.d.ts +0 -10
  73. package/dist/init-update.js +0 -96
@@ -0,0 +1,15 @@
1
+ /** Graph node id for a finding, derived from its score key (mirrors data.ts stableId("finding", …)). */
2
+ export declare function findingStableId(scoreKey: string): string;
3
+ /**
4
+ * Graph node id for a single FINDINGS.md bullet line, or null if the line is
5
+ * not a node-bearing finding. Covers tagged (`- [tag] text`) and plain
6
+ * (`- text`) bullets; heading-based findings are intentionally not matched
7
+ * here (they need multi-line context and are rare).
8
+ */
9
+ export declare function findingNodeIdForLine(project: string, line: string): string | null;
10
+ /**
11
+ * Pick the graph node id of the finding bullet in `content` that best matches
12
+ * `query` (by query-term overlap). Returns null when no bullet shares a query
13
+ * term, so callers can fall back to the project node.
14
+ */
15
+ export declare function bestFindingNodeId(project: string, content: string, query: string): string | null;
@@ -0,0 +1,58 @@
1
+ import { createHash } from "crypto";
2
+ import { entryScoreKey } from "./governance/scores.js";
3
+ import { FINDINGS_FILENAME } from "./data/access.js";
4
+ // Bullet-finding patterns — must stay in lockstep with the graph builder
5
+ // (ui/data.ts) so computed node ids match the rendered finding nodes.
6
+ const TAGGED_BULLET = /^-\s+\[([a-z_-]+)\]\s+(.+?)(?:\s*<!--.*-->)?$/;
7
+ const PLAIN_BULLET = /^-\s+(.+?)(?:\s*<!--.*-->)?$/;
8
+ const MIN_PLAIN_LENGTH = 10;
9
+ /** Graph node id for a finding, derived from its score key (mirrors data.ts stableId("finding", …)). */
10
+ export function findingStableId(scoreKey) {
11
+ return `finding:${createHash("sha1").update(scoreKey).digest("hex").slice(0, 12)}`;
12
+ }
13
+ /**
14
+ * Graph node id for a single FINDINGS.md bullet line, or null if the line is
15
+ * not a node-bearing finding. Covers tagged (`- [tag] text`) and plain
16
+ * (`- text`) bullets; heading-based findings are intentionally not matched
17
+ * here (they need multi-line context and are rare).
18
+ */
19
+ export function findingNodeIdForLine(project, line) {
20
+ const tagMatch = line.match(TAGGED_BULLET);
21
+ if (tagMatch) {
22
+ const tag = tagMatch[1];
23
+ const text = tagMatch[2].trim();
24
+ return findingStableId(entryScoreKey(project, FINDINGS_FILENAME, `[${tag}] ${text}`));
25
+ }
26
+ const plainMatch = line.match(PLAIN_BULLET);
27
+ if (plainMatch) {
28
+ const text = plainMatch[1].trim();
29
+ if (text.length < MIN_PLAIN_LENGTH)
30
+ return null;
31
+ return findingStableId(entryScoreKey(project, FINDINGS_FILENAME, text));
32
+ }
33
+ return null;
34
+ }
35
+ /**
36
+ * Pick the graph node id of the finding bullet in `content` that best matches
37
+ * `query` (by query-term overlap). Returns null when no bullet shares a query
38
+ * term, so callers can fall back to the project node.
39
+ */
40
+ export function bestFindingNodeId(project, content, query) {
41
+ const terms = query.toLowerCase().split(/\s+/).filter((t) => t.length > 2);
42
+ if (terms.length === 0)
43
+ return null;
44
+ let best = null;
45
+ for (const line of content.split("\n")) {
46
+ const id = findingNodeIdForLine(project, line);
47
+ if (!id)
48
+ continue;
49
+ const lower = line.toLowerCase();
50
+ let score = 0;
51
+ for (const t of terms)
52
+ if (lower.includes(t))
53
+ score++;
54
+ if (score > 0 && (!best || score > best.score))
55
+ best = { id, score };
56
+ }
57
+ return best ? best.id : null;
58
+ }