@phren/cli 0.1.40 → 0.1.41
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 +11 -3
- package/dist/cli/config-access.js +8 -1
- package/dist/cli/extract.d.ts +27 -1
- package/dist/cli/extract.js +243 -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/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/dedup.d.ts +1 -4
- package/dist/content/dedup.js +7 -63
- package/dist/content/learning.d.ts +20 -2
- package/dist/content/learning.js +21 -3
- 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 +193 -0
- package/dist/data/access.d.ts +56 -2
- package/dist/data/access.js +246 -24
- 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 +15 -3
- 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 +209 -14
- 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/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/task/lifecycle.js +31 -0
- package/dist/tools/config.js +16 -7
- package/dist/tools/data.js +1 -1
- package/dist/tools/extract.js +2 -2
- package/dist/tools/finding.js +14 -3
- 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 +5 -0
- 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
package/dist/proactivity.js
CHANGED
|
@@ -7,7 +7,7 @@ import { getWorkflowPolicy } from "./governance/policy.js";
|
|
|
7
7
|
export const PROACTIVITY_LEVELS = ["high", "medium", "low"];
|
|
8
8
|
const DEFAULT_PROACTIVITY_LEVEL = "high";
|
|
9
9
|
const EXPLICIT_FINDING_SIGNAL_PATTERN = /\b(add finding|worth remembering)\b/i;
|
|
10
|
-
const EXPLICIT_FINDING_TAG_PATTERN = /\[(pitfall|decision|pattern|
|
|
10
|
+
const EXPLICIT_FINDING_TAG_PATTERN = /\[(pitfall|decision|pattern|bug|workaround|context)\]/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
12
|
export function parseProactivityLevel(raw) {
|
|
13
13
|
if (!raw)
|
|
@@ -6,14 +6,30 @@ export interface EmbeddingCoverage {
|
|
|
6
6
|
missingPct: number;
|
|
7
7
|
state: "empty" | "cold" | "warming" | "warm";
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* `[mtimeMs, size]` of the embeddings.json the in-memory map was last built
|
|
11
|
+
* from. Derived caches (the LSH vector index) stamp *this*, not a fresh stat of
|
|
12
|
+
* the file, so an index can never claim to describe bytes it never saw.
|
|
13
|
+
*/
|
|
14
|
+
export interface EmbeddingSourceMarker {
|
|
15
|
+
mtimeMs: number;
|
|
16
|
+
size: number;
|
|
17
|
+
}
|
|
9
18
|
export declare class EmbeddingCache {
|
|
10
19
|
private phrenPath;
|
|
11
20
|
private cache;
|
|
12
21
|
private dirty;
|
|
13
22
|
private dirtyUpserts;
|
|
14
23
|
private dirtyDeletes;
|
|
24
|
+
private source;
|
|
15
25
|
constructor(phrenPath: string);
|
|
16
26
|
load(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Marker for the embeddings.json revision this in-memory map reflects, or
|
|
29
|
+
* null when it was never loaded from a file. Pass it to anything that
|
|
30
|
+
* persists a derived view of `getAllEntries()`.
|
|
31
|
+
*/
|
|
32
|
+
sourceMarker(): EmbeddingSourceMarker | null;
|
|
17
33
|
get(docPath: string, model: string): number[] | null;
|
|
18
34
|
set(docPath: string, model: string, vec: number[]): void;
|
|
19
35
|
delete(docPath: string): void;
|
|
@@ -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:
|