@phren/cli 0.1.40 → 0.1.42

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 (119) hide show
  1. package/dist/auth/profiles.js +59 -5
  2. package/dist/cli/actions.js +12 -16
  3. package/dist/cli/config-access.js +8 -1
  4. package/dist/cli/extract.d.ts +27 -1
  5. package/dist/cli/extract.js +244 -9
  6. package/dist/cli/govern.js +6 -87
  7. package/dist/cli/hooks-context.d.ts +1 -1
  8. package/dist/cli/hooks-context.js +1 -1
  9. package/dist/cli/namespaces-review.js +14 -1
  10. package/dist/cli/namespaces-utils.js +1 -1
  11. package/dist/cli/session-git.d.ts +18 -0
  12. package/dist/cli/session-git.js +47 -0
  13. package/dist/cli/session-start.js +2 -2
  14. package/dist/cli/session-stop.d.ts +11 -0
  15. package/dist/cli/session-stop.js +141 -33
  16. package/dist/cli/session-tool-hook.js +17 -5
  17. package/dist/cli-registry.d.ts +1 -1
  18. package/dist/cli-registry.js +1 -0
  19. package/dist/content/archive.js +3 -2
  20. package/dist/content/dedup.d.ts +1 -4
  21. package/dist/content/dedup.js +11 -66
  22. package/dist/content/learning.d.ts +20 -2
  23. package/dist/content/learning.js +26 -7
  24. package/dist/content/quality.d.ts +23 -0
  25. package/dist/content/quality.js +123 -0
  26. package/dist/content/secrets.d.ts +52 -0
  27. package/dist/content/secrets.js +196 -0
  28. package/dist/data/access.d.ts +56 -2
  29. package/dist/data/access.js +255 -32
  30. package/dist/data/tasks.js +46 -6
  31. package/dist/entrypoint.js +5 -1
  32. package/dist/finding/impact.js +170 -43
  33. package/dist/finding/lifecycle.d.ts +19 -2
  34. package/dist/finding/lifecycle.js +18 -5
  35. package/dist/git-worktree.d.ts +19 -0
  36. package/dist/git-worktree.js +117 -0
  37. package/dist/governance/policy.d.ts +84 -4
  38. package/dist/governance/policy.js +213 -17
  39. package/dist/governance/rbac.d.ts +8 -0
  40. package/dist/governance/rbac.js +26 -0
  41. package/dist/hooks.d.ts +20 -0
  42. package/dist/hooks.js +113 -3
  43. package/dist/index.js +5 -1
  44. package/dist/init/guard-globals.d.ts +20 -0
  45. package/dist/init/guard-globals.js +72 -6
  46. package/dist/init/init-configure.js +6 -6
  47. package/dist/init/init.js +10 -6
  48. package/dist/init/setup.d.ts +4 -3
  49. package/dist/init/setup.js +120 -16
  50. package/dist/init/store-gitignore.d.ts +29 -0
  51. package/dist/init/store-gitignore.js +48 -0
  52. package/dist/link/doctor.js +86 -20
  53. package/dist/phren-core.d.ts +35 -8
  54. package/dist/phren-core.js +35 -8
  55. package/dist/phren-paths.d.ts +90 -1
  56. package/dist/phren-paths.js +150 -5
  57. package/dist/proactivity.js +1 -1
  58. package/dist/project-config.js +3 -2
  59. package/dist/project-topics.js +13 -12
  60. package/dist/shared/data-utils.js +13 -3
  61. package/dist/shared/embedding-cache.d.ts +16 -0
  62. package/dist/shared/embedding-cache.js +24 -0
  63. package/dist/shared/fragment-graph.js +10 -0
  64. package/dist/shared/index.d.ts +6 -0
  65. package/dist/shared/index.js +523 -138
  66. package/dist/shared/ollama.d.ts +14 -2
  67. package/dist/shared/ollama.js +84 -5
  68. package/dist/shared/retrieval.d.ts +22 -1
  69. package/dist/shared/retrieval.js +30 -1
  70. package/dist/shared/search-fallback.js +15 -3
  71. package/dist/shared/vector-index.d.ts +20 -1
  72. package/dist/shared/vector-index.js +18 -4
  73. package/dist/shared.d.ts +1 -1
  74. package/dist/shared.js +1 -1
  75. package/dist/status.js +18 -1
  76. package/dist/store-registry.d.ts +22 -0
  77. package/dist/store-registry.js +36 -3
  78. package/dist/store-routing.d.ts +8 -0
  79. package/dist/store-routing.js +23 -1
  80. package/dist/task/lifecycle.js +31 -0
  81. package/dist/tools/config.js +19 -9
  82. package/dist/tools/data.js +1 -1
  83. package/dist/tools/extract-facts.js +3 -2
  84. package/dist/tools/extract.js +2 -2
  85. package/dist/tools/finding.js +20 -8
  86. package/dist/tools/graph.js +9 -1
  87. package/dist/tools/memory.js +1 -1
  88. package/dist/tools/notes.js +3 -3
  89. package/dist/tools/ops.js +19 -18
  90. package/dist/tools/search.js +2 -2
  91. package/dist/tools/session.js +2 -2
  92. package/dist/tools/tasks.js +2 -2
  93. package/dist/tools/types.d.ts +32 -2
  94. package/dist/tools/types.js +41 -8
  95. package/dist/ui/scripts.js +2 -2
  96. package/dist/ui/server.js +7 -6
  97. package/dist/utils-fts.js +3 -2
  98. package/dist/utils-paths.d.ts +1 -0
  99. package/dist/utils-paths.js +1 -1
  100. package/dist/utils.d.ts +1 -1
  101. package/dist/utils.js +1 -1
  102. package/package.json +1 -1
  103. package/dist/cli-hooks-git.d.ts +0 -50
  104. package/dist/cli-hooks-git.js +0 -288
  105. package/starter/my-api/.claude/skills/README.md +0 -7
  106. package/starter/my-api/CLAUDE.md +0 -33
  107. package/starter/my-api/FINDINGS.md +0 -9
  108. package/starter/my-api/summary.md +0 -7
  109. package/starter/my-api/tasks.md +0 -7
  110. package/starter/my-first-project/.claude/skills/README.md +0 -7
  111. package/starter/my-first-project/CLAUDE.md +0 -49
  112. package/starter/my-first-project/FINDINGS.md +0 -24
  113. package/starter/my-first-project/summary.md +0 -11
  114. package/starter/my-first-project/tasks.md +0 -25
  115. package/starter/my-frontend/.claude/skills/README.md +0 -7
  116. package/starter/my-frontend/CLAUDE.md +0 -33
  117. package/starter/my-frontend/FINDINGS.md +0 -9
  118. package/starter/my-frontend/summary.md +0 -7
  119. package/starter/my-frontend/tasks.md +0 -7
@@ -3,6 +3,15 @@ import * as crypto from "crypto";
3
3
  import { runtimeFile, debugLog } from "../shared.js";
4
4
  import { withFileLock } from "./governance.js";
5
5
  import { errorMessage } from "../utils.js";
6
+ function statSourceMarker(filePath) {
7
+ try {
8
+ const stat = fs.statSync(filePath);
9
+ return { mtimeMs: stat.mtimeMs, size: stat.size };
10
+ }
11
+ catch {
12
+ return null;
13
+ }
14
+ }
6
15
  function isEmbeddingEntry(value) {
7
16
  if (!value || typeof value !== "object" || Array.isArray(value))
8
17
  return false;
@@ -31,6 +40,7 @@ export class EmbeddingCache {
31
40
  dirty = false;
32
41
  dirtyUpserts = new Set();
33
42
  dirtyDeletes = new Set();
43
+ source = null;
34
44
  constructor(phrenPath) {
35
45
  this.phrenPath = phrenPath;
36
46
  }
@@ -38,20 +48,33 @@ export class EmbeddingCache {
38
48
  if (this.dirty)
39
49
  return;
40
50
  const filePath = runtimeFile(this.phrenPath, "embeddings.json");
51
+ // Stat before the read: if the file is rewritten mid-read, the recorded
52
+ // marker is the older one, so derived caches report stale rather than fresh.
53
+ const marker = statSourceMarker(filePath);
41
54
  try {
42
55
  const data = readEmbeddingMapFromDisk(filePath);
43
56
  this.cache = new Map(Object.entries(data));
57
+ this.source = marker;
44
58
  debugLog(`EmbeddingCache loaded: ${this.cache.size} entries`);
45
59
  }
46
60
  catch (err) {
47
61
  const code = err instanceof Error && "code" in err ? String(err.code ?? "") : "";
48
62
  if (code === "ENOENT") {
49
63
  this.cache.clear();
64
+ this.source = null;
50
65
  return;
51
66
  }
52
67
  debugLog(`EmbeddingCache load failed for ${filePath}: ${errorMessage(err)}`);
53
68
  }
54
69
  }
70
+ /**
71
+ * Marker for the embeddings.json revision this in-memory map reflects, or
72
+ * null when it was never loaded from a file. Pass it to anything that
73
+ * persists a derived view of `getAllEntries()`.
74
+ */
75
+ sourceMarker() {
76
+ return this.source;
77
+ }
55
78
  get(docPath, model) {
56
79
  const entry = this.cache.get(docPath);
57
80
  if (!entry || entry.model !== model)
@@ -95,6 +118,7 @@ export class EmbeddingCache {
95
118
  fs.writeFileSync(tmp, JSON.stringify(data));
96
119
  fs.renameSync(tmp, filePath);
97
120
  this.cache = new Map(Object.entries(data));
121
+ this.source = statSourceMarker(filePath);
98
122
  });
99
123
  this.dirty = false;
100
124
  this.dirtyUpserts.clear();
@@ -4,6 +4,16 @@ import { runtimeFile } from "../shared.js";
4
4
  import { logger } from "../logger.js";
5
5
  import { UNIVERSAL_TECH_TERMS_RE } from "../phren-core.js";
6
6
  import { errorMessage } from "../utils.js";
7
+ // NOTE on naming: "entity" was renamed to "fragment" everywhere user-facing
8
+ // (CHANGELOG 0.0.5) — tool names, titles, and descriptions in tools/graph.ts
9
+ // all say "fragment" now. The underlying SQLite tables (`entities`,
10
+ // `entity_links`, `global_entities`, created in shared/index.ts) and the
11
+ // on-disk `.runtime/manual-links.json` format (`{entity, entityType, ...}`)
12
+ // were never renamed to match. Both are effectively rebuilt/local-runtime
13
+ // state rather than synced source-of-truth files, so a rename would not need
14
+ // a store migration in the git-history sense, but it does require touching
15
+ // shared/index.ts (which creates the tables and reads manual-links.json) —
16
+ // out of scope for a change confined to this file.
7
17
  /** @internal Exported for tests. */
8
18
  export function escapeRegex(s) { return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
9
19
  /** Escape SQL LIKE wildcard characters so user input is treated literally.
@@ -23,6 +23,12 @@ export declare function normalizeIndexedContent(content: string, type: string, p
23
23
  */
24
24
  export declare function updateFileInIndex(db: SqlJsDatabase, filePath: string, phrenPath: string): void;
25
25
  export declare function buildIndex(phrenPath: string, profile?: string): Promise<SqlJsDatabase>;
26
+ /**
27
+ * @internal Exported for tests. The prune is a one-shot per process, so a test
28
+ * that needs to set up state *after* a build (which consumes it) has no other
29
+ * way to exercise the pruning logic a second time.
30
+ */
31
+ export declare function __resetFtsCachePruneGuardForTests(): void;
26
32
  /**
27
33
  * Non-blocking index loader for the UserPromptSubmit / PostToolUse hooks.
28
34
  * Unlike buildIndex(), this NEVER blocks a hook on a 2-12s rebuild: