@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.
- package/dist/auth/profiles.js +59 -5
- package/dist/cli/actions.js +12 -16
- package/dist/cli/config-access.js +8 -1
- package/dist/cli/extract.d.ts +27 -1
- package/dist/cli/extract.js +244 -9
- package/dist/cli/govern.js +6 -87
- package/dist/cli/hooks-context.d.ts +1 -1
- package/dist/cli/hooks-context.js +1 -1
- package/dist/cli/namespaces-review.js +14 -1
- package/dist/cli/namespaces-utils.js +1 -1
- package/dist/cli/session-git.d.ts +18 -0
- package/dist/cli/session-git.js +47 -0
- package/dist/cli/session-start.js +2 -2
- package/dist/cli/session-stop.d.ts +11 -0
- package/dist/cli/session-stop.js +141 -33
- package/dist/cli/session-tool-hook.js +17 -5
- package/dist/cli-registry.d.ts +1 -1
- package/dist/cli-registry.js +1 -0
- package/dist/content/archive.js +3 -2
- package/dist/content/dedup.d.ts +1 -4
- package/dist/content/dedup.js +11 -66
- package/dist/content/learning.d.ts +20 -2
- package/dist/content/learning.js +26 -7
- package/dist/content/quality.d.ts +23 -0
- package/dist/content/quality.js +123 -0
- package/dist/content/secrets.d.ts +52 -0
- package/dist/content/secrets.js +196 -0
- package/dist/data/access.d.ts +56 -2
- package/dist/data/access.js +255 -32
- package/dist/data/tasks.js +46 -6
- package/dist/entrypoint.js +5 -1
- package/dist/finding/impact.js +170 -43
- package/dist/finding/lifecycle.d.ts +19 -2
- package/dist/finding/lifecycle.js +18 -5
- package/dist/git-worktree.d.ts +19 -0
- package/dist/git-worktree.js +117 -0
- package/dist/governance/policy.d.ts +84 -4
- package/dist/governance/policy.js +213 -17
- package/dist/governance/rbac.d.ts +8 -0
- package/dist/governance/rbac.js +26 -0
- package/dist/hooks.d.ts +20 -0
- package/dist/hooks.js +113 -3
- package/dist/index.js +5 -1
- package/dist/init/guard-globals.d.ts +20 -0
- package/dist/init/guard-globals.js +72 -6
- package/dist/init/init-configure.js +6 -6
- package/dist/init/init.js +10 -6
- package/dist/init/setup.d.ts +4 -3
- package/dist/init/setup.js +120 -16
- package/dist/init/store-gitignore.d.ts +29 -0
- package/dist/init/store-gitignore.js +48 -0
- package/dist/link/doctor.js +86 -20
- package/dist/phren-core.d.ts +35 -8
- package/dist/phren-core.js +35 -8
- package/dist/phren-paths.d.ts +90 -1
- package/dist/phren-paths.js +150 -5
- package/dist/proactivity.js +1 -1
- package/dist/project-config.js +3 -2
- package/dist/project-topics.js +13 -12
- package/dist/shared/data-utils.js +13 -3
- package/dist/shared/embedding-cache.d.ts +16 -0
- package/dist/shared/embedding-cache.js +24 -0
- package/dist/shared/fragment-graph.js +10 -0
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/index.js +523 -138
- package/dist/shared/ollama.d.ts +14 -2
- package/dist/shared/ollama.js +84 -5
- package/dist/shared/retrieval.d.ts +22 -1
- package/dist/shared/retrieval.js +30 -1
- package/dist/shared/search-fallback.js +15 -3
- package/dist/shared/vector-index.d.ts +20 -1
- package/dist/shared/vector-index.js +18 -4
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +1 -1
- package/dist/status.js +18 -1
- package/dist/store-registry.d.ts +22 -0
- package/dist/store-registry.js +36 -3
- package/dist/store-routing.d.ts +8 -0
- package/dist/store-routing.js +23 -1
- package/dist/task/lifecycle.js +31 -0
- package/dist/tools/config.js +19 -9
- package/dist/tools/data.js +1 -1
- package/dist/tools/extract-facts.js +3 -2
- package/dist/tools/extract.js +2 -2
- package/dist/tools/finding.js +20 -8
- package/dist/tools/graph.js +9 -1
- package/dist/tools/memory.js +1 -1
- package/dist/tools/notes.js +3 -3
- package/dist/tools/ops.js +19 -18
- package/dist/tools/search.js +2 -2
- package/dist/tools/session.js +2 -2
- package/dist/tools/tasks.js +2 -2
- package/dist/tools/types.d.ts +32 -2
- package/dist/tools/types.js +41 -8
- package/dist/ui/scripts.js +2 -2
- package/dist/ui/server.js +7 -6
- package/dist/utils-fts.js +3 -2
- package/dist/utils-paths.d.ts +1 -0
- package/dist/utils-paths.js +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/cli-hooks-git.d.ts +0 -50
- package/dist/cli-hooks-git.js +0 -288
- package/starter/my-api/.claude/skills/README.md +0 -7
- package/starter/my-api/CLAUDE.md +0 -33
- package/starter/my-api/FINDINGS.md +0 -9
- package/starter/my-api/summary.md +0 -7
- package/starter/my-api/tasks.md +0 -7
- package/starter/my-first-project/.claude/skills/README.md +0 -7
- package/starter/my-first-project/CLAUDE.md +0 -49
- package/starter/my-first-project/FINDINGS.md +0 -24
- package/starter/my-first-project/summary.md +0 -11
- package/starter/my-first-project/tasks.md +0 -25
- package/starter/my-frontend/.claude/skills/README.md +0 -7
- package/starter/my-frontend/CLAUDE.md +0 -33
- package/starter/my-frontend/FINDINGS.md +0 -9
- package/starter/my-frontend/summary.md +0 -7
- 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.
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -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:
|